diff --git a/README.md b/README.md index 9935ca7cd..59a4f1e74 100644 --- a/README.md +++ b/README.md @@ -92,7 +92,7 @@ installs and passes the conformance tests but has no certification run yet; | Hermes | experimental | `--host hermes` (every skill in `$HERMES_HOME/skills/gstack`; automatic when setup runs inside Hermes) | ask for the task, or `/gstack-review` | advisory, not blocked | — | `./setup --host hermes` | | GBrain (mod) | instruction-only | `--host gbrain` (brain-aware variants ship from the GBrain repo) | — | advisory, not blocked | — | — | -Per-host notes (agent harnesses, Copilot, Antigravity, Gemini CLI, OpenClaw and ClawHub, the Codex behavioral profile and model tiers, outside-review providers, the design binary's models) are in [docs/hosts.md](docs/hosts.md). Any rules-reading agent (Zed, Amp, Jules) can use the 2KB [agents digest](agents-digest/gstack-AGENTS.md) with no install. Adding a host: [docs/ADDING_A_HOST.md](docs/ADDING_A_HOST.md). +Per-host notes (agent harnesses, Copilot, Antigravity, Gemini CLI, OpenClaw native skills, the Codex behavioral profile and model tiers, outside-review providers, the design binary's models) are in [docs/hosts.md](docs/hosts.md). Any rules-reading agent (Zed, Amp, Jules) can use the 2KB [agents digest](agents-digest/gstack-AGENTS.md) with no install. Adding a host: [docs/ADDING_A_HOST.md](docs/ADDING_A_HOST.md). ## See it work @@ -262,7 +262,7 @@ On Windows without Developer Mode (MSYS2 / Git Bash), `setup` falls back to file | [gstack + Capy: the software factory](capy/README.md) | What we built with Capy Captains and gstack, how the pieces fit, the measured before/after, tips, and how Garry uses it | | [Why gstack](docs/why-gstack.md) | The story, the productivity numbers and their caveats, Karpathy's failure modes, parallel sprints | | [Install details](docs/install.md) | Setup timing, requirements in detail, team mode, the hooks setup registers, agent harness registration | -| [Other agents](docs/hosts.md) | Agent harnesses (OpenClaw, Hermes, dots, QM, Muse Code, Grok, any other), OpenClaw and ClawHub, per-host notes, the Codex profile and model tiers, outside-review providers, the design binary's models | +| [Other agents](docs/hosts.md) | Agent harnesses (OpenClaw, Hermes, dots, QM, Muse Code, Grok, any other), OpenClaw native skills, per-host notes, the Codex profile and model tiers, outside-review providers, the design binary's models | | [QA without a webpage](docs/qa-without-a-webpage.md) | `/qa` and `/qa-only` on CLIs, APIs, jobs, workers and webhooks | | [Standalone binaries](docs/standalone-binaries.md) | The standalone `gstack-*` CLIs (egress auditor, context bill, model benchmark, the review and evidence ledgers, the iOS QA daemon), and the CSO evaluation producer contract | | [Privacy & Telemetry](docs/privacy.md) | What is sent, what never is, the update check, outside reviews, egress receipts | diff --git a/bin/gstack-config b/bin/gstack-config index 89c4a8150..239c1ee1b 100755 --- a/bin/gstack-config +++ b/bin/gstack-config @@ -1280,7 +1280,9 @@ $_gstack_legacy_root" gstack_claude_overlay "$INSTALL_DIR" "$0" RENDER_TMP="$RENDER_DIR.tmp.$$" rm -rf "$RENDER_TMP" - if ( cd "$INSTALL_DIR" && bun run gen:skill-docs:user --host claude --out-dir "$RENDER_TMP" --link-root "$RENDER_DIR" --model "$_GSTACK_OVERLAY" ${_PLAN_MODE_ARG:+"$_PLAN_MODE_ARG"} ${_LOADOUT_ARG:+"$_LOADOUT_ARG"} >/dev/null 2>&1 ); then + _skill_prefix="$("$0" get skill_prefix 2>/dev/null || echo false)" + if ( cd "$INSTALL_DIR" && bun run gen:skill-docs:user --host claude --out-dir "$RENDER_TMP" --link-root "$RENDER_DIR" --model "$_GSTACK_OVERLAY" ${_PLAN_MODE_ARG:+"$_PLAN_MODE_ARG"} ${_LOADOUT_ARG:+"$_LOADOUT_ARG"} >/dev/null 2>&1 \ + && "$INSTALL_DIR/bin/gstack-patch-names" "$RENDER_TMP" "$_skill_prefix" >/dev/null ); then gstack_render_lock "$RENDER_DIR" _swap_in_render "$RENDER_DIR" "$RENDER_TMP" gstack_render_unlock "$RENDER_DIR" diff --git a/bin/gstack-issue-links b/bin/gstack-issue-links index 50241179e..764f45b97 100755 --- a/bin/gstack-issue-links +++ b/bin/gstack-issue-links @@ -25,7 +25,7 @@ import { spawnSync } from 'node:child_process'; import * as fs from 'node:fs'; import * as path from 'node:path'; import { EXIT, exitTableHelp } from '../lib/headless-artifacts'; -import { lineSources, mentionsIn, promotionCandidates, receiptIssues, relatedPrs, renderIssueLines, resolveLinks, selectFlakes, type ClosingPr, type FlakeLink, type IssueMention, type IssueRow } from '../lib/issue-links'; +import { lineSources, mentionsIn, ownRepoMentions, promotionCandidates, receiptIssues, relatedPrs, renderIssueLines, resolveLinks, selectFlakes, type ClosingPr, type FlakeLink, type IssueMention, type IssueRow } from '../lib/issue-links'; import { resultLine, resultLineWithDocs } from '../lib/result-codes'; import { resolveBaseBranch } from '../lib/ship-policy'; @@ -143,19 +143,20 @@ function main(argv: string[]): number { const log = git(['log', '--format=%H%n%B%x00', `origin/${base}..HEAD`], repoRoot) ?? git(['log', '--format=%H%n%B%x00', `${base}..HEAD`], repoRoot); if (log === undefined) { process.stderr.write(`gstack-issue-links: cannot read commits ${base}..HEAD (fetch origin/${base} first)\n`); return EXIT.usage; } - const mentions: IssueMention[] = []; + const named: IssueMention[] = []; for (const entry of log.split('\0')) { const nl = entry.indexOf('\n'); if (nl < 0) continue; - mentions.push(...mentionsIn(entry.slice(nl + 1), `commit ${entry.slice(0, nl).trim().slice(0, 12)}`)); + named.push(...mentionsIn(entry.slice(nl + 1), `commit ${entry.slice(0, nl).trim().slice(0, 12)}`)); } const readable = (issue: number): boolean => { const r = spawnSync(path.join(binDir, 'gstack-issue-guard'), ['issue', String(issue)], { cwd: repoRoot, encoding: 'utf8', timeout: 60_000, maxBuffer: 16 * 1024 * 1024 }); return r.status === 0 && r.stdout.length > 0; }; const gh = ghLookups(repoRoot); - const needRepo = runs.length > 0 || explicit.length > 0 || (autoLinks && mentions.some(m => m.intent === 'fixes')); + const needRepo = runs.length > 0 || explicit.length > 0 || named.some(m => m.repo?.includes('/')) || (autoLinks && named.some(m => m.intent === 'fixes')); const repo = flags(argv, '--repo')[0] ?? (needRepo ? gh.json<{ nameWithOwner?: string }>('repository', ['repo', 'view', '--json', 'nameWithOwner'])?.nameWithOwner : undefined); + const mentions = ownRepoMentions(named, repo); const flakes: FlakeLink[] = []; const rejectedFlakes: Array<{ issue: number; run: string; reason: string }> = []; diff --git a/bin/gstack-render-claude.sh b/bin/gstack-render-claude.sh index f626461cc..3353f074a 100644 --- a/bin/gstack-render-claude.sh +++ b/bin/gstack-render-claude.sh @@ -129,14 +129,18 @@ gstack_claude_render_action() { fi } +_GSTACK_RENDER_BIN="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" + # gstack_claude_render_plain SOURCE_DIR RENDER_DIR — render the pinned overlay -# without brain blocks into a temp dir and swap it in only on success. +# without brain blocks into a temp dir, apply the saved skill_prefix to its +# name: fields (#4413), and swap it in only on success. gstack_claude_render_plain() { local src="$1" RENDER_DIR="$2" RENDER_TMP out rc=0 RENDER_TMP="$RENDER_DIR.tmp.$$" rm -rf "$RENDER_TMP" _gstack_render_say "Rendering Claude skills with the $_GSTACK_OVERLAY overlay${_PLAN_MODE_ARG:+ and no plan-mode preamble}${_LOADOUT_ARG:+ and the ${_LOADOUT_ARG#--loadout=} loadout} into $RENDER_DIR (source checkout stays clean)..." out="$(cd "$src" && _gstack_render_bun run gen:skill-docs --host claude --out-dir "$RENDER_TMP" --link-root "$RENDER_DIR" --model "$_GSTACK_OVERLAY" ${_DISABLED_CSV:+"--disabled-skills=$_DISABLED_CSV"} ${_PLAN_MODE_ARG:+"$_PLAN_MODE_ARG"} ${_LOADOUT_ARG:+"$_LOADOUT_ARG"} 2>&1)" || rc=$? + [ "$rc" -ne 0 ] || out="$("$_GSTACK_RENDER_BIN/gstack-patch-names" "$RENDER_TMP" "$("$_GSTACK_RENDER_BIN/gstack-config" get skill_prefix 2>/dev/null || echo false)" 2>&1)" || rc=$? if [ "$rc" -ne 0 ]; then rm -rf "$RENDER_TMP" printf '%s\n' "$out" | tail -3 diff --git a/changelog.d/fix-skill-prefix-renders-clawhub-docs-issue-refs.md b/changelog.d/fix-skill-prefix-renders-clawhub-docs-issue-refs.md new file mode 100644 index 000000000..a8206dad0 --- /dev/null +++ b/changelog.d/fix-skill-prefix-renders-clawhub-docs-issue-refs.md @@ -0,0 +1,3 @@ +- **`skill_prefix=true` now survives updates when gbrain is installed.** Every Claude re-render (the brain-aware render in `./setup`, `gstack-config gbrain-refresh`, and the pinned-overlay render) applies your saved prefix before it goes live, so skills stay `/gstack-retro`, `/gstack-review` and so on instead of reverting to short names after each update (#4413). Thanks @fliaron for the report. +- The OpenClaw docs no longer send you to ClawHub, which held only April 2026 builds of office-hours, ceo-review and retro and no longer has gstack skills (the docs also said four skills while listing three). `docs/hosts.md` and `docs/OPENCLAW.md` now point to native registration (`./setup --host openclaw`), which already serves the current version of each, and tell you to remove the ClawHub copies if you installed them (#4421). Thanks @exGeni for the report. +- **`gstack-issue-links` no longer reads other repositories' issues as gstack's.** A parenthesis that cites several repositories, such as `(founderstar #837, harness-evals #393)`, now gives each its own cross-repo reference instead of `Refs #837` and `Refs #393` on this repository, and `owner/repo#N` naming the current repository counts as its own issue, so `Fixes garrytan/gstack#N` closes it. diff --git a/docs/OPENCLAW.md b/docs/OPENCLAW.md index 0ec78bc3a..48d498340 100644 --- a/docs/OPENCLAW.md +++ b/docs/OPENCLAW.md @@ -101,15 +101,14 @@ The orchestrator persists the plan link to its own memory store (brain repo, knowledge base, or whatever is configured in AGENTS.md). When the user is ready to build, spawn a FULL session that references the saved plan. -### Native methodology skills -Published to ClawHub. Install with `clawhub install`: -- `gstack-openclaw-office-hours` — Product interrogation (6 forcing questions) -- `gstack-openclaw-ceo-review` — Strategic challenge (10-section review, 4 modes) -- `gstack-openclaw-retro` — Operational retrospective (weekly review) +### Methodology skills in the OpenClaw agent +To run /office-hours, /plan-ceo-review or /retro in the OpenClaw agent itself, +use native registration (see [Installation](#installation)): its `gstack` router +skill serves the current version of each. -Source lives in `openclaw/skills/` in the gstack repo. These are hand-crafted -adaptations of the gstack methodology for OpenClaw's conversational context. -No gstack infrastructure (no browser, no telemetry, no preamble). +gstack no longer publishes skills on ClawHub. If you installed the April 2026 +`gstack-openclaw-office-hours`, `gstack-openclaw-ceo-review` or +`gstack-openclaw-retro` from there, remove them. ## Spawned session detection @@ -175,7 +174,7 @@ For OpenClaw users: tell your OpenClaw agent "install gstack for openclaw." The agent should: 1. Install gstack-lite CLAUDE.md into its coding session templates -2. Install the 4 native methodology skills +2. Register gstack's native skills with `./setup --host openclaw` (below) 3. Add dispatch routing to AGENTS.md 4. Verify with a test spawn diff --git a/docs/OPENCLAW_PUBLISHING.md b/docs/OPENCLAW_PUBLISHING.md index 8defe424e..ea3571a45 100644 --- a/docs/OPENCLAW_PUBLISHING.md +++ b/docs/OPENCLAW_PUBLISHING.md @@ -2,6 +2,11 @@ Moved verbatim from CLAUDE.md (token-load reduction). +**Status:** gstack's user docs no longer send anyone to ClawHub (#4421). Native +registration (`./setup --host openclaw`) gives OpenClaw's agent the current +/office-hours, /plan-ceo-review and /retro, and the gstack skills were removed +from ClawHub on 2026-11-17. + ## Workflow Native OpenClaw skills live in `openclaw/skills/gstack-openclaw-*/SKILL.md`. These are diff --git a/docs/hosts.md b/docs/hosts.md index e0a55a6cd..1138610ae 100644 --- a/docs/hosts.md +++ b/docs/hosts.md @@ -117,22 +117,17 @@ when Claude Code has gstack installed. Paste this to your OpenClaw agent: See [docs/OPENCLAW.md](OPENCLAW.md) for advanced dispatch routing and the gstack-lite/gstack-full prompt templates. -## Native OpenClaw Skills (via ClawHub) +## /office-hours, /plan-ceo-review and /retro in OpenClaw -Four methodology skills that work directly in your OpenClaw agent, no Claude Code -session needed. Install from ClawHub: +Your OpenClaw agent can run these directly in chat, with no Claude Code session. +They come with native registration: `./setup --host openclaw` registers gstack's +`gstack` router skill, which lists them with every other workflow and serves +the current version of each ([install, verify and remove](#agent-harnesses)). -``` -clawhub install gstack-openclaw-office-hours gstack-openclaw-ceo-review gstack-openclaw-retro -``` - -| Skill | What it does | -|-------|-------------| -| `gstack-openclaw-office-hours` | Product interrogation with 6 forcing questions | -| `gstack-openclaw-ceo-review` | Strategic challenge with 4 scope modes | -| `gstack-openclaw-retro` | Weekly engineering retrospective | - -These are conversational skills. Your OpenClaw agent runs them directly via chat. +Earlier docs sent you to ClawHub for `gstack-openclaw-office-hours`, +`gstack-openclaw-ceo-review` and `gstack-openclaw-retro`. Those were April 2026 +builds, and gstack no longer publishes skills on ClawHub. If you installed them, +remove them, so your agent doesn't load an old copy next to the current one. ## Which agents a checkout renders for diff --git a/docs/pregate.md b/docs/pregate.md index 6a51c6ace..4f72ae55b 100644 --- a/docs/pregate.md +++ b/docs/pregate.md @@ -2278,6 +2278,9 @@ cross-repo `owner/repo#N` are `Refs`. A parenthesised named reference, token that is not a closure, reference, filler or version word, is a cross-repo `Refs name#N`, never a same-repo Refs line or a promotion candidate; `(see #12)`, `(closing #12)` and `(#301)` stay bare refs. +Several in one parenthesis, `(founderstar #837, harness-evals #393)`, are each +their own name's reference. `owner/repo#N` naming this repository is its own +issue, so a `Fixes garrytan/gstack#N` trailer closes it. Same-repo references are printed as promotion candidates (`reference #N ← (promote: fix #N)` on stderr, `candidates` in `--json`): the owner's `fix #N` reply reruns with diff --git a/lib/issue-links.ts b/lib/issue-links.ts index f167f9bf4..1fd791d5f 100644 --- a/lib/issue-links.ts +++ b/lib/issue-links.ts @@ -14,6 +14,10 @@ * reference, filler or version word (`closing`, `cf.`, `e.g.`, `v1.2` * name nothing), is a cross-repo reference to `name`: rendered as * `Refs name#N`, never a same-repo Refs line or a promotion candidate. + * Several in one parenthesis, `(founderstar #837, harness-evals #393)`, + * are each their own name's reference. + * - `owner/repo#N` naming this repository (ownRepoMentions) is this + * repository's own issue, so `Fixes garrytan/gstack#N` closes it. * - A closure issue that cannot be read through gstack-issue-guard is * downgraded to `Refs #N` with ISSUE_UNREADABLE (never Fixes). * - Same-repo references are promotion candidates: the owner's `fix #N` @@ -41,12 +45,14 @@ export interface IssueRow { number: number; title?: string; body?: string; autho /** One `closedByPullRequestsReferences` node of an issue this PR fixes. */ export interface ClosingPr { number: number; state?: string; headRefName?: string; author?: { login?: string } | null; repository?: { nameWithOwner?: string } } -const CLOSURE = /^\s*(?:fix(?:es|ed)?|close[sd]?|resolve[sd]?)\s*:?\s+(?:#|GH-)(\d+)\s*$/i; +const CLOSURE = /^\s*(?:fix(?:es|ed)?|close[sd]?|resolve[sd]?)\s*:?\s+(?:([A-Za-z0-9_.-]+\/[A-Za-z0-9_.-]+)#|#|GH-)(\d+)\s*$/i; const PARTIAL = /\b(?:partial(?:ly)?|part of|defer(?:red)?|follow-?up|related|refs?|see|context)\b/i; const CROSS = /\b([A-Za-z0-9_.-]+\/[A-Za-z0-9_.-]+)#(\d+)\b/g; const BARE = /(? { - if (NOT_A_NAME.test(name)) return whole; + if (trailer && !PARTIAL.test(line)) { add({ issue: Number(trailer[2]), intent: 'fixes', ...(trailer[1] ? { repo: trailer[1] } : {}), source: `${source}: ${line.trim()}` }); continue; } + const rest = line.replace(NAMED, whole => whole.replace(NAMED_PART, (part, name: string, numbers: string) => { + if (NOT_A_NAME.test(name)) return part; for (const n of numbers.matchAll(/#(\d+)/g)) add({ issue: Number(n[1]), intent: 'refs', repo: name, source: `${source}: ${line.trim()}` }); return ' '; - }); + })); for (const c of rest.matchAll(CROSS)) add({ issue: Number(c[2]), intent: 'refs', repo: c[1], source: `${source}: ${line.trim()}` }); const stripped = rest.replace(CROSS, ''); for (const b of stripped.matchAll(BARE)) add({ issue: Number(b[1]), intent: 'refs', source: `${source}: ${line.trim()}` }); @@ -71,6 +77,18 @@ export function mentionsIn(message: string, source = 'commit'): IssueMention[] { return out; } +/** Mentions whose `owner/repo` is `repo` (case-insensitive) become this repository's own; the rest are unchanged. */ +export function ownRepoMentions(mentions: IssueMention[], repo: string | undefined): IssueMention[] { + if (!repo) return mentions; + const out: IssueMention[] = []; + for (const m of mentions) { + const { repo: named, ...own } = m; + const next: IssueMention = named?.toLowerCase() === repo.toLowerCase() ? own : m; + if (!out.some(o => o.repo === next.repo && o.issue === next.issue && o.intent === next.intent)) out.push(next); + } + return out; +} + /** * Resolve the final link set. `readable(n)` is the gstack-issue-guard probe * for a closure candidate; a false answer downgrades it to Refs. diff --git a/setup b/setup index af032fd94..c810f60c7 100755 --- a/setup +++ b/setup @@ -4548,6 +4548,9 @@ if [ -x "$DETECT_BIN" ]; then # main gen:skill-docs site had). Capture, show the tail, propagate. _GEN_USER_OUT=$(bun_cmd run gen:skill-docs:user --host claude --out-dir "$_GSTACK_RENDER_TMP" --link-root "$_GSTACK_RENDER_DIR" --model "$_GSTACK_OVERLAY" ${_DISABLED_CSV:+"--disabled-skills=$_DISABLED_CSV"} ${_PLAN_MODE_ARG:+"$_PLAN_MODE_ARG"} ${_LOADOUT_ARG:+"$_LOADOUT_ARG"} 2>&1) _GEN_USER_RC=$? + # The generator writes unprefixed name: fields; apply skill_prefix + # before the swap, as _render_install does (#4413). + [ "$_GEN_USER_RC" -ne 0 ] || "$SOURCE_GSTACK_DIR/bin/gstack-patch-names" "$_GSTACK_RENDER_TMP" "$SKILL_PREFIX" >/dev/null || _GEN_USER_RC=$? printf '%s\n' "$_GEN_USER_OUT" | tail -3 exit "$_GEN_USER_RC" ); then diff --git a/test/ship-issue-intent.test.ts b/test/ship-issue-intent.test.ts index 4f800f390..f4a5e95ac 100644 --- a/test/ship-issue-intent.test.ts +++ b/test/ship-issue-intent.test.ts @@ -9,7 +9,7 @@ import * as fs from 'node:fs'; import * as path from 'node:path'; import { splitAgentNotes } from '../lib/agent-notes'; import { EXIT } from '../lib/headless-artifacts'; -import { lineSources, mentionsIn, promotionCandidates, relatedPrs, renderIssueLines, resolveLinks, selectFlakes, type ClosingPr, type IssueRow } from '../lib/issue-links'; +import { lineSources, mentionsIn, ownRepoMentions, promotionCandidates, relatedPrs, renderIssueLines, resolveLinks, selectFlakes, type ClosingPr, type IssueRow } from '../lib/issue-links'; import { cleanup, commit, ghShim, makeFixtureRepo, runBin, type FixtureRepo } from './helpers/pregate-fixture'; const repos: FixtureRepo[] = []; @@ -47,6 +47,27 @@ describe('issue intent (pure)', () => { expect(mentionsIn('same line (gbrain #7625) and #13 here').map(x => [x.repo ?? '', x.issue])).toEqual([['gbrain', 7625], ['', 13]]); }); + // Value: protects=several named references in one parenthesis, "(founderstar #837, harness-evals #393)", are each a cross-repo reference to their own + // name, never this repository's #837 and #393, while "(see #12, #13)", "mentions #12" and "Fixes #14" keep their meaning; owner/repo#N naming this + // repository is its own issue (a Fixes trailer closes it) and another repository's never closes here; fails_when=a list of named references falls + // through to the bare-#N rule (GST-2967: wrong Refs lines and fix-#N offers for issues the commit never meant), or this repository's full form stays a + // cross-repo Refs line; why_new=the named-reference test covers one name per parenthesis only; seam=none; no_claim=prose outside parentheses + test('a list of named references is cross-repo; this repository\'s owner/repo#N is its own issue (GST-2967)', () => { + const listed = mentionsIn('docs audit: stop halting on prose (founderstar #837, harness-evals #393)\n\nSee #12 (gbrain #7625; acme/tools issue #4).\n'); + expect(listed.map(x => [x.repo ?? '', x.issue, x.intent])).toEqual([['founderstar', 837, 'refs'], ['harness-evals', 393, 'refs'], ['gbrain', 7625, 'refs'], ['acme/tools', 4, 'refs'], ['', 12, 'refs']]); + const links = resolveLinks(listed, [], () => true); + expect(links).toEqual({ fixes: [], refs: [12], flakes: [], cross: ['acme/tools#4', 'founderstar#837', 'gbrain#7625', 'harness-evals#393'], unreadable: [] }); + expect(promotionCandidates(listed, links).map(c => c.issue)).toEqual([12]); + expect(mentionsIn('retry (see #12, #13) and (closing #14; #15)').map(x => [x.repo ?? '', x.issue])).toEqual([['', 12], ['', 13], ['', 14], ['', 15]]); + expect(mentionsIn('mentions #12 only').map(x => [x.repo ?? '', x.issue])).toEqual([['', 12]]); + const own = ownRepoMentions(mentionsIn('Refs garrytan/gstack#40, same as #40, and owner/other#9\n\nFixes garrytan/gstack#41\nFixes owner/other#42\n'), 'garrytan/GStack'); + expect(own.map(x => [x.repo ?? '', x.issue, x.intent])).toEqual([['', 40, 'refs'], ['owner/other', 9, 'refs'], ['', 41, 'fixes'], ['owner/other', 42, 'fixes']]); + const ownLinks = resolveLinks(own, [], () => true); + expect(ownLinks).toEqual({ fixes: [41], refs: [40], flakes: [], cross: ['owner/other#42', 'owner/other#9'], unreadable: [] }); + expect(renderIssueLines(ownLinks)).toEqual(['Fixes #41', 'Refs #40', 'Refs owner/other#42', 'Refs owner/other#9']); + expect(ownRepoMentions(mentionsIn('Fixes garrytan/gstack#41'), undefined).map(x => [x.repo ?? '', x.issue])).toEqual([['garrytan/gstack', 41]]); + }); + test('resolution: explicit --issue is closure, unreadable closure becomes Refs, a flake issue is never a plain Ref', () => { const links = resolveLinks(mentionsIn('Fixes #14\nFixes #15\nsee #40 and #16'), [16], n => n !== 15, [{ issue: 40, run: '7' }]); expect(links).toEqual({ fixes: [14, 16], refs: [15], flakes: [{ issue: 40, run: '7' }], cross: [], unreadable: [15] }); @@ -77,6 +98,15 @@ describe('gstack-issue-links (bin)', () => { expect(JSON.parse(receipt.out).issues).toEqual({ fixes: [14, 16], refs: [12, 13, 15], flakes: [{ issue: 40, run: '123456' }] }); }); + + test('a named-reference list in a commit is cross-repo, and Fixes owner/repo#N for this repository closes it (GST-2967)', () => { + const repo = fixture(); + commit(repo, { 'lib/util.js': "exports.add = (a, b) => a + b + 0;\n" }, 'docs audit: stop halting on prose (founderstar #837, harness-evals #393)\n\nFixes owner/repo#14\n'); + const env = ghShim(repo, { issues: { '14': { title: 't', body: 'b', comments: [] } } }); + const r = runBin(repo, 'gstack-issue-links', ['--base', 'main', '--no-auto-links'], env); + expect(r).toMatchObject({ status: EXIT.ok, out: 'Fixes #14\nRefs founderstar#837\nRefs harness-evals#393\n' }); + expect(r.err).toContain('closure #14 ← commit '); + }); test('no mentions prints ISSUE_LINKS: none with exit 0; a bare mention never closes; bad flags are usage', () => { const repo = fixture(); commit(repo, { 'lib/util.js': "exports.add = (a, b) => a + b + 0;\n" }, 'tidy\n\nmentions #12 only\n'); diff --git a/test/user-render-out-dir-install.test.ts b/test/user-render-out-dir-install.test.ts index 3a73176cd..ff4c5b6f8 100644 --- a/test/user-render-out-dir-install.test.ts +++ b/test/user-render-out-dir-install.test.ts @@ -144,6 +144,70 @@ describe(':user render targets the out-dir, never the checkout (#2569)', () => { }); }); +// Value: protects=with skill_prefix=true every rendered Claude skill keeps its gstack- after a re-render, because each path that swaps a fresh +// render into a live render dir runs gstack-patch-names on it first; fails_when=a render path (setup's gbrain branch, gstack-config gbrain-refresh, +// gstack_claude_render_plain) swaps in the generator's unprefixed name: fields, the #4413 symptom; why_new=#2738 patched the render only from +// gstack-relink, which setup runs before these renders; seam=none; no_claim=the scan pins the call order, not each path's end-to-end behavior +describe('skill_prefix survives every Claude re-render (#4413)', () => { + const RENDER_HELPER = path.join(ROOT, 'bin', 'gstack-render-claude.sh'); + + test('every render swap is preceded by gstack-patch-names on the same temp dir', () => { + const sources: Array<[string, string]> = [ + ['setup', SETUP_SRC], + ['bin/gstack-config', CONFIG_SRC], + ['bin/gstack-render-claude.sh', fs.readFileSync(RENDER_HELPER, 'utf-8')], + ]; + let swaps = 0; + for (const [rel, src] of sources) { + const lines = src.split('\n'); + lines.forEach((line, i) => { + const m = /^\s*_swap_in_render "([^"]+)" "([^"]+)"/.exec(line); + if (!m) return; + swaps++; + const before = lines.slice(Math.max(0, i - 30), i).join('\n'); + expect(before, `${rel}:${i + 1} swaps ${m[2]} in without gstack-patch-names`).toContain(`gstack-patch-names" "${m[2]}"`); + }); + } + expect(swaps).toBe(4); + }); + + function renderPlain(prefix: string) { + const tmp = fs.mkdtempSync(path.join(os.tmpdir(), 'gstack-render-prefix-')); + try { + const state = path.join(tmp, 'state'); + fs.mkdirSync(state, { recursive: true }); + fs.writeFileSync(path.join(state, 'config.yaml'), `skill_prefix: ${prefix}\n`); + const render = path.join(tmp, 'render', 'claude'); + const script = [ + 'set -euo pipefail', + `. ${JSON.stringify(RENDER_HELPER)}`, + extractFn(SETUP_SRC, '_swap_in_render'), + 'bun_cmd() {', + ' local out="" prev=""', + ' for a in "$@"; do [ "$prev" = --out-dir ] && out="$a"; prev="$a"; done', + ' mkdir -p "$out/retro" "$out/gstack-upgrade"', + ` printf -- '---\\nname: gstack\\n---\\n' > "$out/SKILL.md"`, + ` printf -- '---\\nname: retro\\n---\\n' > "$out/retro/SKILL.md"`, + ` printf -- '---\\nname: gstack-upgrade\\n---\\n' > "$out/gstack-upgrade/SKILL.md"`, + '}', + '_GSTACK_OVERLAY=claude', + `gstack_claude_render_plain ${JSON.stringify(tmp)} ${JSON.stringify(render)}`, + ].join('\n'); + const r = runBashScript(script, { timeout: 30_000, env: { PATH: process.env.PATH ?? '/usr/bin:/bin', HOME: tmp, GSTACK_STATE_ROOT: state } }); + expect(r.status, r.stderr).toBe(0); + const name = (rel: string) => /^name: (.*)$/m.exec(fs.readFileSync(path.join(render, rel), 'utf-8'))?.[1]; + return { root: name('SKILL.md'), retro: name('retro/SKILL.md'), upgrade: name('gstack-upgrade/SKILL.md') }; + } finally { + fs.rmSync(tmp, { recursive: true, force: true }); + } + } + + test('gstack_claude_render_plain serves prefixed names with skill_prefix true and the generator names with it false', () => { + expect(renderPlain('true')).toEqual({ root: 'gstack', retro: 'gstack-retro', upgrade: 'gstack-upgrade' }); + expect(renderPlain('false')).toEqual({ root: 'gstack', retro: 'retro', upgrade: 'gstack-upgrade' }); + }); +}); + describe('link_claude_skill_dirs prefers rendered SKILL.md (behavior)', () => { test('a rendered variant is served; skills without one fall back to source', () => { const tmp = fs.mkdtempSync(path.join(os.tmpdir(), 'gstack-render-pref-'));