* fix(#2652): gate quick/diagnose dispatch on dispatch.isolation, not runtime name quick.md and diagnose-issues.md kept the pre-#2584 `RUNTIME != "claude"` worktree gate, so every non-Claude runtime failed closed regardless of the capability it negotiated — including Codex, which declares orchestrator-worktree. Route both through the negotiated dispatch.isolation seam via a new shared reference, and migrate the two execute-phase reference fragments that carried the same runtime-name gate. - new gsd-core/references/dispatch-isolation-gate.md: canonical ISOLATION resolution, harness-flag resolution, single-agent degrade rule - quick.md / diagnose-issues.md read the gate; dispatch uses the {harnessFlag} placeholder rather than a hardcoded isolation="worktree" - execute-phase-wave-guard.md / execute-phase-between-wave-reset.md: migrate [ "$RUNTIME" = "claude" ] -> [ "$ISOLATION" = "harness-worktree" ] - every degrade site now clears BOTH USE_WORKTREES and ISOLATION; clearing one dispatched an isolated agent with no base guard and no manifest - parity guard in host-integration.test.cjs scans workflows AND references and matches six reintroduction shapes - migrate four tests that pinned the pre-#2584 runtime-name contract Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> * fix(#2652): use the /gsd:<cmd> namespace in the isolation degrade messages The degrade warnings cited /gsd-execute-phase, the retired hyphen form that slash-command-namespace.test.cjs rejects in Claude-facing source. Same length, so the quick.md size budget is unaffected. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> * chore(#2652): add changeset for PR #2728 Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> * fix(#2652): normalize dispatch-site paths to forward slashes for Windows path.relative() returns backslash-separated paths on Windows, so the #2652 dispatch-site parity test compared "gsd-core\workflows\quick.md" against the hardcoded forward-slash literal "gsd-core/workflows/quick.md" and failed on every windows-latest CI lane. Normalize with .replace(/\\/g, '/'), matching the existing convention used elsewhere in this suite (e.g. tests/branch-no-track-guard.test.cjs:37). * test(#2652): restore the size-growth acknowledgment The rebase dropped tests/emitted-drift-ack.json. #2757/#2758 fixed the ATTRIBUTION axis, but the SIZE-GROWTH axis is independent: diagnose-issues.md (+2086) and quick.md (+230) still need an ack naming them and saying why. Verified: 65/66 without it (both files named), 66/66 with it. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> * fix(#2652): convert execute-plan.md Pattern A onto the dispatch-isolation gate Pattern A hardcoded `isolation="worktree"` — Claude Code's own literal — gated only on `workflow.use_worktrees`, with no capability negotiation at all. It is the same defect #2652 fixes at the other four sites, just a different shape: the file contains no RUNTIME variable, so the new detector correctly does not flag it. Concrete break: a Codex user who follows this PR's own newly-documented pattern and sets `workflow.use_worktrees: true` to get isolated dispatch via /gsd:quick then runs a plan through /gsd-execute-plan Pattern A, and hits an unconverted path — either an Agent() call erroring on an unrecognized parameter or silent unisolated execution, depending on host tolerance. Pattern A is a single-agent dispatch site through the host's own subagent tool, so it takes the same treatment as quick.md and diagnose-issues.md: resolve ISOLATION/HARNESS_FLAG through the canonical reference, degrade to sequential on orchestrator-worktree hosts, and substitute the host's declared {harnessFlag} instead of Claude Code's literal. while the area was open. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> * docs(#2652): add the INVENTORY row for dispatch-isolation-gate.md, refresh CONTEXT Two bookkeeping gaps flagged in review: INVENTORY.md had no row for the new gsd-core/references/dispatch-isolation-gate.md. INVENTORY-MANIFEST.json was regenerated correctly and its --check only diffs a live directory scan against the committed manifest, so CI passed regardless — but gen-inventory-manifest.cjs's own stderr guidance says to add the matching INVENTORY.md row. This is the repo's named "Inventory Drift" pattern. Placed with the dispatch/isolation cluster (worktree-branch-check, runtime-aware-dispatch) rather than alphabetically, matching how that table is grouped. CONTEXT.md's Host-Integration Interface entry still described dispatch.isolation as "declared and negotiated but not yet consumed by any scheduler — Phase 1 of #2584". That was already stale before this PR (execute-phase graduated in Phase 3) and more so now with three single-agent dispatch sites consuming it. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> * test(#2652): detect reversed-operand runtime gates; add a permutation property All five reintroduction regexes assumed $RUNTIME on the LEFT of the comparison, so `[ "claude" != "$RUNTIME" ]` — the same gate written backwards — evaded every one of them. Verified against the old patterns before fixing: all four reversed shapes (single bracket, double bracket, test builtin, JS template) scored EVADED. Each comparison shape is now generated in both operand orders from a single template, so a shape cannot be added in one order and forgotten in the other. The mutation table gains the four reversed cases. Also adds the fast-check property review suggested in place of the hand-rolled cases: it generates the cross product of the axes an author actually varies — bracket form, operator, operand order, quoting, spacing, runtime id — so a permutation the hand-written patterns miss surfaces here rather than in production. The 11 explicit cases stay as named regression anchors. execute-plan.md joins the scan's required-identities list now that it is a converted dispatch site. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> * test(#2652): acknowledge the execute-plan.md size growth The Pattern A conversion adds 811 bytes to an emitted workflow. Per #2719 the size axis needs its own acknowledgment, independent of attribution. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> * test(#2652): repin the execute-plan.md PROSE_ALLOWLIST line after the rebase The #2751 command-position gate pins its prose exemptions by line number. This branch inserts the dispatch-isolation resolution above the `validated downstream by gsd-tools uat classify-coverage` sentence, moving it from execute-plan.md:387 to :397 — which fired the gate twice for one displacement (an un-allowlisted mention at 397, a stale entry at 387). The prose itself is unchanged from next; only the pin moves. Fixes #2652 * fix(#2652): gate the #2649 base-check on ISOLATION in diagnose-issues.md The rebase onto next merged #2649's pre-dispatch base-check textually, but its degrade flipped USE_WORKTREES after ISOLATION was already resolved, so the degrade never reached the dispatch decision. Gate the block on ISOLATION = "harness-worktree" and degrade ISOLATION itself, the same pairing quick.md already uses. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> * fix(#2652): key quick.md post-dispatch bookkeeping on ISOLATION, not the Claude literal Review Blocker: the manifest append (l.822), worktree merge-back (l.825), and its skip clause (l.839) all conditioned on the literal isolation="worktree" — Claude Code's own rendering of {harnessFlag}. Cursor renders --worktree, so a newly-unblocked isolated Cursor run created a worktree whose committed work was never merged back and never cleaned up, silently. All three now key on ISOLATION = "harness-worktree" at dispatch. The existing parity detector cannot catch this class (its ISOLATION_TOKEN treats the literal as a legitimate marker), so this adds a dedicated literal-condition detector with a discrimination proof against both pre-fix sentences, a benign-mention control, and a positive pin on all three re-keyed conditions. Verified fail-first against the pre-fix quick.md. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> * fix(#2652): scope the use_worktrees=false install stamp to isolation=none runtimes `_stampNonClaudeRuntimeDefaults` rewrote every non-Claude runtime's `workflow.use_worktrees` read to `--default false`. That default resolved before `gsd_run query dispatch-isolation` was ever consulted, so the five runtimes that declare worktree support — cursor (harness-worktree) and codex/opencode/kimi/kimi-code (orchestrator-worktree) — got ISOLATION=none regardless of what they negotiated. The gate this PR migrates dispatch onto was therefore still deciding isolation by runtime name, one layer down. The stamp's #1521 premise was that worktree isolation *was* Claude Code's isolation="worktree" spawn parameter, which no other host honored. #2584 replaced that premise with the negotiated capability. The stamp is now scoped to runtimes whose negotiated isolation really is `none`, where the default it writes is the outcome the resolver reaches anyway. `_negotiatedDispatchIsolation` mirrors routeDispatchIsolation's resolution against the same registry — closed vocabulary, a harness-worktree host must declare its flag, an orchestrator-worktree host must carry a descriptor that resolves — and fails closed to `none` on anything else, so an undeclared or unknown runtime keeps today's behavior. Two #1515 tests pinned the superseded premise for codex and are re-pointed at the new contract rather than deleted: the safety property they protect is now held by the isolation gate's fail-closed resolution, not by a name-scoped install-time default. Verified fail-first — all five assertions red against the pre-fix source, green after. * test(#2652): acknowledge the emitted ripple and re-point the end-to-end stamp proof Scoping the use_worktrees stamp changes emitted output, and two gates caught it. `gsd-core/workflows/execute-phase.md` now differs at emit time for the five hosts that declare worktree support (cursor harness-worktree; codex, opencode, kimi, kimi-code orchestrator-worktree) — the source file is byte-identical, only the stamp is gone. Acknowledged in this PR's fragment. `tests/install.test.cjs`'s real-install assertion pinned the superseded premise end-to-end, asserting codex receives `--default false`. Re-pointed rather than deleted, matching the two unit tests: it now proves codex keeps the unstamped `true` read. A second arm installs windsurf — which declares isolation `none` — and asserts the false stamp is still applied there, so the change cannot silently degrade into "never stamp" without a test noticing. The ack entry collides with `2658-trae-instruction-file-path.json`, which is fully spent (merged via #2925, so all 25 of its entries are present at base and gate nothing) and is pruned for the same reason and by the same rule as the spent `2649-*` fragment this PR already removed. #2566 prunes the same file for the same collision on `new-project.md`; a delete/delete merges cleanly either way, and the base-side cleanup would make both unnecessary. * fix(#2652): re-record the sentinel when a dispatch site degrades isolation Review Blocker B1/B2/B3. Every isolation degrade in a dispatch site is decided in shell, where routeDispatchIsolation cannot see it. That resolver persists whatever it resolved to the run-scoped sentinel as an unconditional side effect (#3045), so a degrade that only reassigns $ISOLATION leaves the sentinel asserting harness-worktree while the dispatch correctly omits the harness flag. The shipped PreToolUse guard reads the sentinel at the instant of the Agent() call and denies that mismatch with exit 2 — the work does not run unisolated, it does not run at all. Latent on this branch and lands on rebase, since8f75e275(#3045) is not yet in the merge-base. Four sites now push the final shell-computed value through the same single write path with --force-isolation, matching the idiom #3045 established in executor-isolation-dispatch.md: - quick.md, after the #1941 base-check degrade - diagnose-issues.md, after the config-gate degrades and after #2649's - execute-plan.md Pattern A, before spawning - references/dispatch-isolation-gate.md, both degrade paths, plus a new "Re-record after every degrade" section — the canonical file taught the defect, so fixing only the call sites would leave the source of truth wrong Tests assert the RECORDED value, not $ISOLATION. Asserting the local variable is what let this class through: $ISOLATION was already `none` at every site and the defect was entirely in what reached the sentinel. Each workflow's own degrade block is executed under a gsd_run stub that captures the write, with a fail-first proof that the pre-fix shape records nothing (while $ISOLATION reads `none` in both), plus a coverage guard so a new degrade site cannot skip it. Also corrects the drift-ack rationale (review Minor 5): @-references are eagerly inlined, so extracting the gate does not reduce loaded context. The reason to extract is single-sourcing across five dispatch sites. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> * test(#2652): satisfy the new CRLF-portability and cleanup lint rules in host-integration.test.cjs next's local/no-crlf-fragile-split and no-raw-rmsync-in-tests rules now cover the fenced-block regexes, log-line split, and temp-dir removal this suite added: bash-fence matchers and line counting accept \r\n, and the raw fs.rmSync becomes helpers.cleanup (Windows-EBUSY retry budget). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> * fix(#2652): restore next's 2658 ack fragment, minus the one colliding key trek-e (PR #2728, 2026-08-07): the branch deleted tests/emitted-drift-acks/2658-trae-instruction-file-path.json wholesale while next had modified it. That was correct against the 08-03 base, where the fragment was fully spent; it is wrong against next @1d208e5a, which still carries 23 live entries. next's copy is restored byte-identical except for the single key that genuinely collides with this PR's own fragment, gsd-core/workflows/execute-phase.md. Both acks name that path for different deltas -- 2658's is the trae CLAUDE.md replacement-target rewrite, ours is the emit-time _stampNonClaudeRuntimeDefaults ripple from review round 3. Per the ack-lifecycle law (#2789), an entry already at the base is spent and inert, so this PR's entry is the live one and 2658's is dropped. This follows the guidance given on #2566 in the 08-06 round: "Regenerate rather than delete -- the collision is one entry." Verified: lint-emitted-drift-ack ok (0 problems, 357 keys, no cross-source duplicates); emitted-attribution 170/170 with GSD_EMITTED_BASE=upstream/next; host-integration 222/222; runtime-converters 130/130. * fix(#2652): bound the degrade-harness spawn and close the round-6 majors B1 (CI red, ours): tests/host-integration.test.cjs spawned bash with no timeout, violating local/no-unbounded-spawn. `next` deleted the allowlist outright (#3148), so the merge-commit run flags it even though this branch still carries the file's grandfathered entry. Bounded at 15s, with a named failure on timeout/signal rather than an opaque `exited null`. M1: add a parity test between `_negotiatedDispatchIsolation` (install time) and `routeDispatchIsolation` (dispatch time). Both read the same capability registry and the same `resolveOrchestratorExec`, but duplicate the DECISION on top of them across two surfaces with no call edge between them, so neither symbol appears in the other's impact graph and nothing static can catch them drifting apart. The resolver leg drives the real gsd-tools CLI per registered runtime, both ways it is really called: with `--cwd-target` (the executor spawn, which resolves the orchestrator descriptor — the same question install time asks) and without it (the `Resolve ISOLATION` call every dispatch site makes first, which does not). The second leg is what catches an orchestrator host whose descriptor stops resolving: the install would stamp `use_worktrees=false` while the workflow gate still reported `orchestrator-worktree`. M2: add install-level Cursor coverage. A real `--cursor` install, then the gate blocks that install emitted, run against the gsd-tools that install emitted, with the runtime declared through `.planning/config.json` — the tier `resolveRuntime` actually reads — and any ambient GSD_RUNTIME blanked, so the install has to reach the right resolver on its own. It then performs the documented `{harnessFlag}` substitution against the `Agent()` call that install emitted and asserts on the rendered dispatch: exactly one emitted Agent() call carries the slot, it is the gsd-executor / gsd-debugger dispatch rather than some other call in the same file, and rendering it yields `--worktree` with no residual placeholder and no `isolation="worktree"`. This is artifact-level — it proves the emitted wiring, not a live Cursor host invocation. Asserting the shell variable alone would have stayed green if the placeholder were deleted from the emitted dispatch, or drifted onto the reviewer call beside it. M3: diagnose-issues.md inlined a reordered copy of the reference this PR introduces as the single source of truth. It now reads the reference the same way quick.md and execute-plan.md do; the drift-ack entry is corrected to describe what the file actually contains, and to name the four files that reference the gate rather than claiming five. M4: CONTEXT.md still called `resolveOrchestratorExec` UNCONSUMED in the same paragraph this PR edits. It has been consumed since #2584 Phase 3 — routed through `query dispatch-isolation --json` and process-spawned by executor-isolation-dispatch.md — and #2652 adds a second consumer. Every new assertion verified fail-first against a real mutation: cursor's negotiated isolation (breaks the target-bound parity leg), the no-target orchestrator branch in routeDispatchIsolation (breaks the gate parity leg), cursor's harnessIsolationFlag (breaks the resolved value), deleting `{harnessFlag}` from quick.md's emitted Agent() call (breaks the slot), and moving it onto the code-reviewer dispatch (breaks the wrong-call guard). Refs #2652 * fix(#2652): serialize unisolated diagnosis, scope the execute-plan gate to dispatching patterns Round-7 review findings (independent cross-AI pass over the whole PR against the current base). BLOCKER — diagnose-issues.md announced sequential mode and then fanned out. The `orchestrator-worktree` degrade sets ISOLATION=none and prints "debug agents run sequentially on the main working tree", but the spawn step still said "All agents spawn in single message (parallel execution)". On Codex, OpenCode and Kimi that dispatched N unisolated debuggers concurrently against the primary checkout — the exact outcome the degrade exists to prevent, and reachable only because this PR removed the FATAL that used to stop those hosts earlier. Fan-out is now keyed on ISOLATION: parallel only when each agent has its own worktree, one at a time otherwise. BLOCKER — execute-plan.md Pattern B could not dispatch at all on Claude or Cursor. The gate recorded `harness-worktree` to the #3045 sentinel, but only Pattern A carries `{harnessFlag}`; Pattern B's segment executors carry none, and `hooks/gsd-agent-isolation-guard.js` blocks precisely that mismatch with exit 2. Segments are unisolated BY DESIGN — each continues on the working tree the previous one left behind, so per-agent worktrees would break the sequence — so Pattern B now records `none` before its first dispatch and dispatches without the flag. MAJOR — the same gate ran before routing was chosen, so an isolation-`none` host with `use_worktrees=true` hit the fail-closed FATAL even when routing would have selected Pattern C, which is fully inline and dispatches nothing. Resolution now happens after the pattern is known, and Pattern C skips it. MAJOR — tests/host-integration.test.cjs fed `fs.readFileSync` output straight to bash. The `\r?\n` fence regex guards only the delimiter, leaving embedded CR on every line of the captured body — DEFECT.WINDOWS-CRLF-TEST-PORTABILITY, which helpers.cjs documents by name. Now reads through `readFileNormalized`. MAJOR — the "every dispatch-site degrade block re-records" test hand-listed three files, so its name was a claim its scan could not support. The scan is now derived from the workflow/reference tree (SCAN_ROOTS/collectMarkdown hoisted to module scope so there is one definition, not two). Verified fail-first against execute-plan.md — a file the previous scan never opened. The two wave fragments are exempt because they delegate the re-record to per-plan-worktree-gate.md via USE_WORKTREES_FOR_PLAN; that delegation is now ASSERTED, so deleting the delegate fails this test instead of widening a hole silently. MINOR — the changeset claimed the FATAL was gone for "non-Claude runtimes" full stop. Narrowed: isolation-`none` hosts still fail closed when worktrees are explicitly enabled, which is the contract rather than the defect. Two further findings were investigated and rejected, with evidence: - Raw `spawnSync` vs `tests/helpers/process-seam.cjs`: the seam exposes runNode/runGit/runHook and cannot express the `bash -c` harness these tests need; `installAndRead` in this same file is byte-identical to the base and still uses raw spawnSync with an explicit timeout, which is the form the lint sanctions. Migrating only the new call sites would split the file's convention for no safety gain. - `pending-migration-to-typed-ir` on the runtime-converters parity test: the annotation and the rendered-text loop both exist at the merge-base under #3090. This PR extends an already-tracked test rather than adding a new one under a category CONTRIBUTING closes to new tests. Refs #2652 * test(#2652): re-point the execute-plan prose allowlist at its shifted line `PROSE_ALLOWLIST` in tests/no-bare-gsd-tools-command-position.test.cjs keys entries by LINE NUMBER. The previous commit added the post-routing isolation block to execute-plan.md, which pushed the `validated downstream by gsd-tools uat classify-coverage` prose mention from line 397 to 414. That broke the guard in both directions at once: the entry at 397 went stale, and the real mention at 414 became an unallowlisted offender. Caught by CI (7 red jobs, all shard 3/3 plus ubuntu-22) rather than locally, because I verified only the suites I believed the change touched. Any edit to a workflow .md shifts line numbers, and this repo carries line-keyed allowlists — so a workflow edit needs the full suite, not a subset. Refs #2652 * test(#2652): route the new subprocesses through the process seam Retracting a rejection I made on the record. In the round-6 response I argued these call sites could keep a hand-rolled `spawnSync` because the seam exposes only runNode/runGit/runHook and cannot express `bash -c`, and because `installAndRead` in the same file uses that shape. The first half was true and irrelevant, the second half is not a licence: CONTRIBUTING is unambiguous — "Anything that shells out goes through tests/helpers/process-seam.cjs — never a hand-rolled spawnSync/execFileSync in your suite", and "Never use try/finally inside test bodies." `runHook` already documents `interpreter: 'bash'` for running a shell script, so writing the harness to a file complies without extending the seam. I had the rule and the seam's own documentation in front of me and reasoned around both. Converted: - host-integration.test.cjs degrade harness: spawnSync('bash', ['-c', …]) → runHook(scriptFile, [], { interpreter: 'bash' }). - install.test.cjs cursor gate: `which bash` probe → process.platform; the installer spawn → runNode(…, { env: installSpawnEnv({HOME, USERPROFILE}) }), which also blanks ambient GSD_HOME/runtime-location vars that could otherwise make capability discovery host-dependent; the emitted-gate spawn → runHook(gateScript, [], { interpreter: 'bash' }). - Three try/finally test bodies → t.after(). Class-norm timeouts: tests/helpers/timeouts.cjs arrived with this branch's latest base merge, so the literals written earlier (15000/120000/60000) now duplicate PROBE_TIMEOUT_MS and INSTALL_TIMEOUT_MS. Imported instead — that module exists because INSTALL_TIMEOUT_MS had already drifted 60s→120s once after a real bench ETIMEDOUT. Deliberately NOT converted: `installAndRead`'s spawnSync, which is byte-identical to the merge-base and predates this PR — converting shared scaffolding is an unrelated change. Verified equivalent, not assumed: argv/cwd/env/encoding/timeout and every assertion are preserved; t.after() still cleans up on the assertion-failure path the try/finally covered; and the cursor test still resolves Cursor under a hostile ambient GSD_RUNTIME=claude. Refs #2652 * fix(#2652): replace the falsified use_worktrees doc row; distinguish an unresolvable gate from a declared none Round-8 review findings. BLOCKER — docs/CONFIGURATION.md's `Non-Claude note` asserted three things this PR overturns: that worktree isolation "no other runtime honors" (Cursor declares harness-worktree with `--worktree`, and this PR's own install test asserts that flag reaching the emitted Agent() slot), that non-Claude installs default the key to `false`, and that forcing `true` always fails closed. Replaced with the capability-based description, and the `#1515, #1521` citation dropped — those are the two issues whose premise this PR removes. The reviewer flagged that the fix is merge-order dependent, because #2531 rewrites the same row and its replacement text is written in anticipation of this PR landing. Rather than pick an order, BOTH sides are now order-independent: #2531's "Current default … until #2652" paragraph becomes a plain troubleshooting note, and this row states the capability rule without asserting a stamp state. Whichever merges first, the row is correct; the second merge is a textual conflict at worst. MINOR — the gate reported a capability verdict the tool never returned. `ISOLATION=$(… || echo "none")` made a shim-resolution failure, a non-zero exit and an empty stdout indistinguishable from a declared `none`, so a transient query failure aborted /gsd:quick on Claude Code with "runtime 'claude' declares no executor-isolation primitive" — false. The gate now tracks ISOLATION_RESOLVED separately: both paths still fail closed, but only a real verdict claims the host declares nothing; the unresolved branch says it could not resolve and points at the shim. Fixed in the canonical reference so every dispatch site inherits it. MINOR — quick.md:527 cited #2649 for its own degrade; that is #1941, and #2649 is the diagnose-issues/execute-plan gate. Corrected, and the distinction stated so the next reader does not chase it. MINOR — quick.md:413 (manifest init) and :429 (worktree_branch_check embed) still branched on USE_WORKTREES while dispatch, manifest-append, merge-back and the skip clause had all moved to ISOLATION. Safe only by coincidence — both now key on ISOLATION. MINOR — the diff removes a second drift-ack entry (the execute-phase.md key from 2658-trae-instruction-file-path.json), forced by the same duplicate-key lint rule as the 2649 removal. Disclosed in the PR comment; the earlier disclosure covered only one of the two. Verified: lint:ci green; 300/300 across host-integration, fix-1941-quick-worktree-stale-base, execute-phase-wave and workflow-guard. Refs #2652 * test(#2652): anchor the emitted-gate finder on the heading, not the assignment `b89c3fbf` added a finder that located the gate's `Resolve ISOLATION` block by the literal `ISOLATION=$(gsd_run query dispatch-isolation --raw`. `f3bccf21` then split that assignment into `_ISOLATION_RAW`/`ISOLATION_RESOLVED` so a shim failure stops masquerading as a declared `none` — and the finder stopped matching. The test did not report the drift it exists to catch; it reported "emitted dispatch-isolation-gate.md has no Resolve ISOLATION bash block" and went red, and stayed red because the earlier full-suite run was read from a truncated log. Anchored on the heading instead. The workflows tell a dispatch site to run the `Resolve ISOLATION` and `Resolve the harness flag` blocks BY NAME, so the heading is the contract and the body is free to change under it. Verified: 413/413 in tests/install.test.cjs. The test still bites — mutating the gate's `ISOLATION="$_ISOLATION_RAW"` to `ISOLATION=none` turns it red (the emitted gate then resolves cursor to none and exits 1 instead of printing harness-worktree), and reverting restores green. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> * fix(#2652): wire the canonical resolver at the one dispatch site that still inlined the old shape Codex review of the whole PR on the new base found one Major, and it was real. executor-isolation-dispatch.md declares references/dispatch-isolation-gate.md canonical at line 10, then kept the OLDER resolver inline: `|| echo "none"`, no ISOLATION_RESOLVED. So the one site that resolves isolation for the wave path collapsed a shim failure into a declared `none` and aborted with "runtime '$RUNTIME' declares no executor-isolation primitive" — false for a Claude or Cursor user whose resolver merely failed to answer. Still fail-closed, so not an unsafe-dispatch hole, but the correction this PR is about was unwired at the site that matters most. Replaced with the gate's exact shape: capture the raw value, track ISOLATION_RESOLVED, and emit the "could not resolve" FATAL when no verdict was learned. Added a regression test in the #2652 dispatch-site parity suite: every file that ASSIGNS from `gsd_run query dispatch-isolation --raw` must carry ISOLATION_RESOLVED, must not use the collapsing form, and must have a distinct unresolved message. Nothing covered this before — install.test.cjs checks the emitted REFERENCE, not each site's own inline copy, which is exactly how the two drifted apart. The test's first draft also flagged quick.md, diagnose-issues.md and execute-plan.md. That was a false positive worth recording: those three @-reference the gate and only make `--force-isolation` re-record calls, which carry no verdict. The predicate now matches an assignment from the resolver, not any mention of it, so it flags sites that can actually be wrong. Verified by mutation: restoring the collapsing line reds the new test. Validated: lint:ci clean; full suite shows the same 7 known failures as the pre-change baseline — #1160 _resolveManifest and the #3053 quick_id host-timezone tests (both reproduce on pristine next @33fca50d), plus helpers-cleanup "outside os.tmpdir()", which fails only in a worktree. * test(#2652): close two vacuous-pass holes in the new inline-resolver guard Codex cleared the push and flagged the guard test itself. Both holes were real. SCAN_ROOTS already yields references/dispatch-isolation-gate.md, and the test appended it a second time, so the candidate list was [executor, gate, gate] and `length >= 2` was satisfiable by the gate alone. If the executor site had dropped out of the predicate — the exact regression the test exists to catch — it would still have passed. Paths are deduped and the assertion now pins the two expected inliner identities instead of a count. The collapse detector keyed on `ISOLATION=$(…)`, so `_ISOLATION_RAW=$(… || echo "none")` restored the identical defect while satisfying every other assertion (ISOLATION_RESOLVED still appears in the file). Codex mutation-probed exactly that and it passed. The pattern now matches any assignment target and any `|| … echo` tail. Verified: that mutation now reds the test. Test-only change; the workflow bash is byte-identical to the commit the full suite ran green against. lint:ci clean, host-integration 223/223. --------- Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com> Co-authored-by: Tom Boucher <trekkie@nomorestars.com>
1732 lines
83 KiB
JavaScript
1732 lines
83 KiB
JavaScript
/**
|
||
* Runtime Converter Tests — OpenCode + Kilo
|
||
*
|
||
* Tests for small runtime-specific conversion functions from install.js.
|
||
* Larger runtime test suites (Copilot, Codex, Antigravity) have their own files.
|
||
*
|
||
* OpenCode/Kilo: flat-runtime frontmatter converters (agent + command modes)
|
||
* model: inherit is NOT added (runtime uses its configured default model)
|
||
* but mode: subagent IS added (required by both runtimes' agents).
|
||
*/
|
||
|
||
const { test, describe } = require('node:test');
|
||
const assert = require('node:assert/strict');
|
||
|
||
process.env.GSD_TEST_MODE = '1';
|
||
const {
|
||
convertClaudeToOpencodeFrontmatter,
|
||
convertClaudeToKiloFrontmatter,
|
||
convertClaudeAgentToAntigravityAgent,
|
||
convertClaudeCommandToOpencodeSkill,
|
||
convertClaudeCommandToKiloSkill,
|
||
convertClaudeCommandToTraeSkill,
|
||
convertClaudeCommandToKimiSkill,
|
||
buildKimiAgentArtifacts,
|
||
neutralizeAgentReferences,
|
||
} = require('../bin/install.js');
|
||
|
||
// Sample Claude agent frontmatter (matches actual GSD agent format)
|
||
const SAMPLE_AGENT = `---
|
||
name: gsd-executor
|
||
description: Executes GSD plans with atomic commits
|
||
tools: Read, Write, Edit, Bash, Grep, Glob
|
||
color: yellow
|
||
skills:
|
||
- gsd-executor-workflow
|
||
# hooks:
|
||
# PostToolUse:
|
||
# - matcher: "Write|Edit"
|
||
# hooks:
|
||
# - type: command
|
||
# command: "npx eslint --fix $FILE 2>/dev/null || true"
|
||
---
|
||
|
||
<role>
|
||
You are a GSD plan executor.
|
||
</role>`;
|
||
|
||
// Sample Claude command frontmatter (for comparison — commands work differently)
|
||
const SAMPLE_COMMAND = `---
|
||
name: gsd-execute-phase
|
||
description: Execute all plans in a phase
|
||
allowed-tools:
|
||
- Read
|
||
- Write
|
||
- Bash
|
||
---
|
||
|
||
Execute the phase plan.`;
|
||
|
||
const flatRuntimeSuites = [
|
||
{
|
||
label: 'OpenCode',
|
||
convert: convertClaudeToOpencodeFrontmatter,
|
||
configDir: '.config/opencode',
|
||
},
|
||
{
|
||
label: 'Kilo',
|
||
convert: convertClaudeToKiloFrontmatter,
|
||
configDir: '.config/kilo',
|
||
},
|
||
];
|
||
|
||
for (const { label, convert, configDir } of flatRuntimeSuites) {
|
||
describe(`${label} agent conversion (isAgent: true)`, () => {
|
||
test('keeps name: field for agents', () => {
|
||
const result = convert(SAMPLE_AGENT, { isAgent: true });
|
||
const frontmatter = result.split('---')[1];
|
||
assert.ok(frontmatter.includes('name: gsd-executor'), 'name: should be preserved for agents');
|
||
});
|
||
|
||
test('does not add model: inherit', () => {
|
||
const result = convert(SAMPLE_AGENT, { isAgent: true });
|
||
const frontmatter = result.split('---')[1];
|
||
assert.ok(!frontmatter.includes('model: inherit'), 'model: inherit should NOT be added');
|
||
});
|
||
|
||
test('adds mode: subagent', () => {
|
||
const result = convert(SAMPLE_AGENT, { isAgent: true });
|
||
const frontmatter = result.split('---')[1];
|
||
assert.ok(frontmatter.includes('mode: subagent'), 'mode: subagent should be added');
|
||
});
|
||
|
||
test('strips tools: field', () => {
|
||
const result = convert(SAMPLE_AGENT, { isAgent: true });
|
||
const frontmatter = result.split('---')[1];
|
||
assert.ok(!frontmatter.includes('tools:'), 'tools: should be stripped for agents');
|
||
assert.ok(!frontmatter.includes('read: true'), 'tools object should not be generated');
|
||
|
||
if (label === 'Kilo') {
|
||
assert.ok(frontmatter.includes('permission:'), 'Kilo agents should emit permission block');
|
||
assert.ok(frontmatter.includes('read: allow'), 'Read should map to read: allow');
|
||
assert.ok(frontmatter.includes('edit: allow'), 'Write/Edit should map to edit: allow');
|
||
assert.ok(frontmatter.includes('bash: allow'), 'Bash should map to bash: allow');
|
||
assert.ok(frontmatter.includes('grep: allow'), 'Grep should map to grep: allow');
|
||
assert.ok(frontmatter.includes('glob: allow'), 'Glob should map to glob: allow');
|
||
assert.ok(frontmatter.includes('task: deny'), 'unspecified permissions should be denied');
|
||
} else {
|
||
assert.ok(!frontmatter.includes('permission:'), 'OpenCode agents should not emit permission block');
|
||
}
|
||
});
|
||
|
||
test('strips skills: array', () => {
|
||
const result = convert(SAMPLE_AGENT, { isAgent: true });
|
||
const frontmatter = result.split('---')[1];
|
||
assert.ok(!frontmatter.includes('skills:'), 'skills: should be stripped');
|
||
assert.ok(!frontmatter.includes('gsd-executor-workflow'), 'skill entries should be stripped');
|
||
});
|
||
|
||
test('strips color: field', () => {
|
||
const result = convert(SAMPLE_AGENT, { isAgent: true });
|
||
const frontmatter = result.split('---')[1];
|
||
assert.ok(!frontmatter.includes('color:'), 'color: should be stripped for agents');
|
||
});
|
||
|
||
test('strips commented hooks block', () => {
|
||
const result = convert(SAMPLE_AGENT, { isAgent: true });
|
||
const frontmatter = result.split('---')[1];
|
||
assert.ok(!frontmatter.includes('# hooks:'), 'commented hooks should be stripped');
|
||
assert.ok(!frontmatter.includes('PostToolUse'), 'hook content should be stripped');
|
||
});
|
||
|
||
test('keeps description: field', () => {
|
||
const result = convert(SAMPLE_AGENT, { isAgent: true });
|
||
const frontmatter = result.split('---')[1];
|
||
assert.ok(frontmatter.includes('description: Executes GSD plans'), 'description should be kept');
|
||
});
|
||
|
||
test('preserves body content', () => {
|
||
const result = convert(SAMPLE_AGENT, { isAgent: true });
|
||
assert.ok(result.includes('<role>'), 'body should be preserved');
|
||
assert.ok(result.includes('You are a GSD plan executor.'), 'body content should be intact');
|
||
});
|
||
|
||
test('applies body text replacements', () => {
|
||
const agentWithClaudePaths = `---
|
||
name: test-agent
|
||
description: Test
|
||
tools: Read
|
||
---
|
||
|
||
Read ~/.claude/agent-memory/ for context.
|
||
Use $HOME/.claude/skills/ for reference.
|
||
Check .claude/skills/ and .claude/agents/ locally.
|
||
Use ./.claude/hooks/gsd-statusline.js during local testing.
|
||
Fallback skills live in .agents/skills/.`;
|
||
|
||
const result = convert(agentWithClaudePaths, { isAgent: true });
|
||
assert.ok(result.includes(`~/${configDir}/agent-memory/`), '~/.claude should be replaced');
|
||
assert.ok(result.includes(`$HOME/${configDir}/skills/`), '$HOME/.claude should be replaced');
|
||
|
||
if (label === 'Kilo') {
|
||
assert.ok(result.includes('.kilo/skills/'), '.claude/skills should be replaced for Kilo');
|
||
assert.ok(result.includes('.kilo/agents/'), '.claude/agents should be replaced for Kilo');
|
||
assert.ok(result.includes('./.kilo/hooks/'), './.claude should be replaced for Kilo');
|
||
assert.ok(result.includes('Fallback skills live in .kilo/skills/.'), '.agents/skills should be rewritten to Kilo skills dir');
|
||
assert.ok(!result.includes('.kilo/skill/'), 'singular Kilo skill dir should not be emitted');
|
||
}
|
||
});
|
||
});
|
||
|
||
describe(`${label} command conversion (isAgent: false, default)`, () => {
|
||
test('strips name: field for commands', () => {
|
||
const result = convert(SAMPLE_COMMAND);
|
||
const frontmatter = result.split('---')[1];
|
||
assert.ok(!frontmatter.includes('name:'), 'name: should be stripped for commands');
|
||
});
|
||
|
||
test('does not add model: or mode: for commands', () => {
|
||
const result = convert(SAMPLE_COMMAND);
|
||
const frontmatter = result.split('---')[1];
|
||
assert.ok(!frontmatter.includes('model:'), 'model: should not be added for commands');
|
||
assert.ok(!frontmatter.includes('mode:'), 'mode: should not be added for commands');
|
||
});
|
||
|
||
test('keeps description: for commands', () => {
|
||
const result = convert(SAMPLE_COMMAND);
|
||
const frontmatter = result.split('---')[1];
|
||
assert.ok(frontmatter.includes('description:'), 'description should be kept');
|
||
});
|
||
});
|
||
|
||
// ─── #2256: model_overrides support for OpenCode/Kilo agents ────────────────
|
||
// Only test OpenCode — Kilo uses the same converter but model override injection
|
||
// is wired only for OpenCode at the call site in install().
|
||
if (label === 'OpenCode') {
|
||
describe('OpenCode agent model override (modelOverride option) (#2256)', () => {
|
||
test('adds model: field when modelOverride is provided', () => {
|
||
const result = convert(SAMPLE_AGENT, { isAgent: true, modelOverride: 'gpt-5.3-codex' });
|
||
const frontmatter = result.split('---')[1];
|
||
assert.ok(frontmatter.includes('model: gpt-5.3-codex'), 'model: field must be added with override value');
|
||
});
|
||
|
||
test('does not add model: field when modelOverride is null', () => {
|
||
const result = convert(SAMPLE_AGENT, { isAgent: true, modelOverride: null });
|
||
const frontmatter = result.split('---')[1];
|
||
assert.ok(!frontmatter.includes('model:'), 'model: field must be absent when no override');
|
||
});
|
||
|
||
test('does not add model: field when modelOverride is omitted', () => {
|
||
const result = convert(SAMPLE_AGENT, { isAgent: true });
|
||
const frontmatter = result.split('---')[1];
|
||
assert.ok(!frontmatter.includes('model:'), 'model: field must be absent when option omitted');
|
||
});
|
||
|
||
test('model: field appears after mode: subagent', () => {
|
||
const result = convert(SAMPLE_AGENT, { isAgent: true, modelOverride: 'o4-mini' });
|
||
const frontmatter = result.split('---')[1];
|
||
const modeIdx = frontmatter.indexOf('mode: subagent');
|
||
const modelIdx = frontmatter.indexOf('model: o4-mini');
|
||
assert.ok(modeIdx !== -1, 'mode: subagent must be present');
|
||
assert.ok(modelIdx !== -1, 'model: field must be present');
|
||
assert.ok(modelIdx > modeIdx, 'model: must appear after mode: subagent');
|
||
});
|
||
|
||
test('model override does not affect command conversion', () => {
|
||
// modelOverride has no effect when isAgent is false (commands)
|
||
const result = convert(SAMPLE_COMMAND, { modelOverride: 'gpt-5.4' });
|
||
const frontmatter = result.split('---')[1];
|
||
assert.ok(!frontmatter.includes('model:'), 'model: must not appear in command output');
|
||
});
|
||
});
|
||
}
|
||
}
|
||
|
||
// ─────────────────────────────────────────────────────────────────────────────
|
||
// DEFECT.GENERATIVE-FIX output-parity guard: convertClaudeToKiloFrontmatter is
|
||
// defined TWICE — once in bin/install.js (the function bound at the top of this
|
||
// file, used by bin/install.js's own legacy install path) and once in
|
||
// src/runtime-artifact-conversion.cts, compiled to
|
||
// gsd-core/bin/lib/runtime-artifact-conversion.cjs (used by
|
||
// src/install-engine.cts's newer TS install path, see install-engine.cts ~L871).
|
||
// Both copies are LIVE — neither re-exports the other — so #2093's modelOverride
|
||
// edit had to be applied twice by hand. Source-text identity can't be asserted
|
||
// (they live in different module systems: plain CJS vs a tsc-compiled .cts
|
||
// output with different surrounding comments), so this instead proves the two
|
||
// implementations still produce IDENTICAL output for representative agent and
|
||
// command input. If a future edit changes one copy's behavior without mirroring
|
||
// it into the other, this test is the guard that catches the divergence.
|
||
// ─────────────────────────────────────────────────────────────────────────────
|
||
describe('convertClaudeToKiloFrontmatter output parity: bin/install.js vs runtime-artifact-conversion.cjs (#2093)', () => {
|
||
const { convertClaudeToKiloFrontmatter: convertViaConversionModule } =
|
||
require('../gsd-core/bin/lib/runtime-artifact-conversion.cjs');
|
||
|
||
test('identical output for an agent with a model override', () => {
|
||
const viaInstall = convertClaudeToKiloFrontmatter(SAMPLE_AGENT, { isAgent: true, modelOverride: 'anthropic/claude-sonnet-5' });
|
||
const viaModule = convertViaConversionModule(SAMPLE_AGENT, { isAgent: true, modelOverride: 'anthropic/claude-sonnet-5' });
|
||
assert.equal(viaInstall, viaModule, 'bin/install.js and runtime-artifact-conversion.cjs must emit identical agent output');
|
||
});
|
||
|
||
test('identical output for an agent with no model override', () => {
|
||
const viaInstall = convertClaudeToKiloFrontmatter(SAMPLE_AGENT, { isAgent: true, modelOverride: null });
|
||
const viaModule = convertViaConversionModule(SAMPLE_AGENT, { isAgent: true, modelOverride: null });
|
||
assert.equal(viaInstall, viaModule, 'bin/install.js and runtime-artifact-conversion.cjs must emit identical agent output with no override');
|
||
});
|
||
|
||
test('identical output for a command (model override never applies)', () => {
|
||
const viaInstall = convertClaudeToKiloFrontmatter(SAMPLE_COMMAND, { isAgent: false, modelOverride: 'x' });
|
||
const viaModule = convertViaConversionModule(SAMPLE_COMMAND, { isAgent: false, modelOverride: 'x' });
|
||
assert.equal(viaInstall, viaModule, 'bin/install.js and runtime-artifact-conversion.cjs must emit identical command output');
|
||
});
|
||
});
|
||
|
||
// ─────────────────────────────────────────────────────────────────────────────
|
||
// DEFECT.GENERATIVE-FIX output-parity guard: convertClaudeCommandToTraeSkill is
|
||
// defined TWICE — once in bin/install.js (dead for the live skills-install
|
||
// path; kept for this file's own module-level export/test surface) and once in
|
||
// src/runtime-artifact-conversion.cts, compiled to
|
||
// gsd-core/bin/lib/runtime-artifact-conversion.cjs (used by
|
||
// src/install-engine.cts's skills-install path via SKILLS_CONVERTER_REGISTRY,
|
||
// see install-engine.cts ~L754). Both copies are LIVE call surfaces — neither
|
||
// re-exports the other — so #2094's `stage:` emission had to be applied to
|
||
// bin/install.js's copy by hand to keep parity. Source-text identity can't be
|
||
// asserted (they live in different module systems: plain CJS vs a
|
||
// tsc-compiled .cts output with different surrounding comments), so this
|
||
// instead proves the two implementations still produce IDENTICAL output for
|
||
// representative command input. If a future edit changes one copy's behavior
|
||
// without mirroring it into the other, this test is the guard that catches
|
||
// the divergence.
|
||
// ─────────────────────────────────────────────────────────────────────────────
|
||
describe('convertClaudeCommandToTraeSkill output parity: bin/install.js vs runtime-artifact-conversion.cjs (#2094)', () => {
|
||
const { convertClaudeCommandToTraeSkill: convertViaConversionModule } =
|
||
require('../gsd-core/bin/lib/runtime-artifact-conversion.cjs');
|
||
|
||
test('identical output for a representative command, including the #2094 stage: field', () => {
|
||
const viaInstall = convertClaudeCommandToTraeSkill(SAMPLE_COMMAND, 'gsd-execute-phase');
|
||
const viaModule = convertViaConversionModule(SAMPLE_COMMAND, 'gsd-execute-phase');
|
||
assert.equal(viaInstall, viaModule, 'bin/install.js and runtime-artifact-conversion.cjs must emit identical command output');
|
||
assert.match(viaInstall, /\nstage: workflow\n/, 'both copies must emit the #2094 stage: field');
|
||
});
|
||
|
||
test('identical output when the source has no description (falls back to generic description)', () => {
|
||
const noDescriptionCommand = `---
|
||
name: gsd-noop
|
||
allowed-tools:
|
||
- Read
|
||
---
|
||
|
||
Do nothing.`;
|
||
const viaInstall = convertClaudeCommandToTraeSkill(noDescriptionCommand, 'gsd-noop');
|
||
const viaModule = convertViaConversionModule(noDescriptionCommand, 'gsd-noop');
|
||
assert.equal(viaInstall, viaModule, 'bin/install.js and runtime-artifact-conversion.cjs must emit identical output when description is absent');
|
||
});
|
||
});
|
||
|
||
// ─────────────────────────────────────────────────────────────────────────────
|
||
// DEFECT.GENERATIVE-FIX output-parity guard: convertClaudeCommandToKimiSkill
|
||
// and buildKimiAgentArtifacts are each defined TWICE — once in bin/install.js
|
||
// (dead for the live install path; kept for this file's own module-level
|
||
// export/test surface) and once in src/runtime-artifact-conversion.cts,
|
||
// compiled to gsd-core/bin/lib/runtime-artifact-conversion.cjs (used by
|
||
// src/install-engine.cts's skills-install path via SKILLS_CONVERTER_REGISTRY
|
||
// for skills, and by src/runtime-artifact-layout.cts's kimiAgentsKind for
|
||
// agent YAML — see runtime-artifact-layout.cts ~L268/L289). Both copies are
|
||
// LIVE call surfaces — neither re-exports the other, so any future
|
||
// kimi-specific fix (e.g. the #2095 code-review fixes) must be applied to
|
||
// both by hand. Source-text identity can't be asserted (different module
|
||
// systems: plain CJS vs a tsc-compiled .cts output with different
|
||
// surrounding comments), so this instead proves the two implementations
|
||
// still produce IDENTICAL output for representative command and agent
|
||
// input. If a future edit changes one copy's behavior without mirroring it
|
||
// into the other, this test is the guard that catches the divergence.
|
||
// ─────────────────────────────────────────────────────────────────────────────
|
||
describe('convertClaudeCommandToKimiSkill / buildKimiAgentArtifacts output parity: bin/install.js vs runtime-artifact-conversion.cjs (#2095)', () => {
|
||
const {
|
||
convertClaudeCommandToKimiSkill: convertViaConversionModule,
|
||
buildKimiAgentArtifacts: buildViaConversionModule,
|
||
} = require('../gsd-core/bin/lib/runtime-artifact-conversion.cjs');
|
||
|
||
test('identical skill output for a representative command', () => {
|
||
const viaInstall = convertClaudeCommandToKimiSkill(SAMPLE_COMMAND, 'gsd-execute-phase');
|
||
const viaModule = convertViaConversionModule(SAMPLE_COMMAND, 'gsd-execute-phase');
|
||
assert.equal(viaInstall, viaModule, 'bin/install.js and runtime-artifact-conversion.cjs must emit identical Kimi skill output');
|
||
});
|
||
|
||
test('identical skill output when the source has no description (falls back to generic description)', () => {
|
||
const noDescriptionCommand = `---
|
||
name: gsd-noop
|
||
allowed-tools:
|
||
- Read
|
||
---
|
||
|
||
Do nothing.`;
|
||
const viaInstall = convertClaudeCommandToKimiSkill(noDescriptionCommand, 'gsd-noop');
|
||
const viaModule = convertViaConversionModule(noDescriptionCommand, 'gsd-noop');
|
||
assert.equal(viaInstall, viaModule, 'bin/install.js and runtime-artifact-conversion.cjs must emit identical output when description is absent');
|
||
});
|
||
|
||
test('identical agent-artifact output for a representative agent with a subagent, including the Agent tool grant', () => {
|
||
const viaInstall = buildKimiAgentArtifacts({ rootAgent: SAMPLE_AGENT, subagents: [SAMPLE_AGENT] });
|
||
const viaModule = buildViaConversionModule({ rootAgent: SAMPLE_AGENT, subagents: [SAMPLE_AGENT] });
|
||
assert.deepEqual(viaInstall, viaModule, 'bin/install.js and runtime-artifact-conversion.cjs must emit an identical artifact bundle');
|
||
assert.match(viaInstall.root.yaml, /kimi_cli\.tools\.agent:Agent/,
|
||
'both copies must grant the Agent tool when a subagent is present (#2095 Upgrade 2)');
|
||
});
|
||
});
|
||
|
||
// ─────────────────────────────────────────────────────────────────────────────
|
||
// Antigravity agent conversion — shared Gemini-backend tool mapping (#1394 / #1928)
|
||
// ─────────────────────────────────────────────────────────────────────────────
|
||
//
|
||
// The gemini-RUNTIME's own top-level converter (convertClaudeToGeminiAgent) and
|
||
// its dedicated test coverage were removed with the gemini runtime (#1928,
|
||
// Google sunset Gemini CLI 2026-06-18). convertGeminiToolName and
|
||
// claudeToGeminiTools STAY — they are shared infra reused by Antigravity (which
|
||
// runs on the same backend tool-name vocabulary), so the Antigravity-facing
|
||
// regression coverage below is retained unchanged.
|
||
|
||
describe('#1394 regression: excludes Skill/SlashCommand from Antigravity frontmatter', () => {
|
||
// Skill/SlashCommand are Claude-only tools with no Gemini-backend built-in
|
||
// equivalent. Without explicit exclusion they hit the lowercase fallback and
|
||
// emit an invalid 'skill'/'slashcommand' tool name, which fails frontmatter
|
||
// validation (tools.N: Invalid tool name) and aborts the entire agent load.
|
||
|
||
// Antigravity reuses convertGeminiToolName (it runs on the Gemini backend),
|
||
// so the exclusion intentionally applies there too. Antigravity surfaces GSD
|
||
// skills through the skill surface (SKILL.md), not the agent tools: allowlist,
|
||
// so dropping the invalid 'skill' tool name does not remove skill access —
|
||
// this locks that cross-runtime behavior (criterion 4).
|
||
test('Antigravity conversion also excludes Skill/SlashCommand (shared Gemini backend)', () => {
|
||
const input = `---
|
||
name: gsd-planner
|
||
description: Creates executable phase plans.
|
||
tools: Read, Write, Bash, Skill, WebFetch, SlashCommand
|
||
---
|
||
|
||
<role>Plan the phase.</role>`;
|
||
|
||
const result = convertClaudeAgentToAntigravityAgent(input);
|
||
const toolsLine = result.split('\n').find(l => l.startsWith('tools:')) || '';
|
||
|
||
assert.ok(toolsLine.includes('read_file'), 'maps Read -> read_file');
|
||
assert.ok(toolsLine.includes('web_fetch'), 'maps WebFetch -> web_fetch');
|
||
assert.ok(!/\bskill\b/.test(toolsLine), 'no invalid skill tool in Antigravity frontmatter');
|
||
assert.ok(!/\bslashcommand\b/.test(toolsLine), 'no invalid slashcommand tool in Antigravity frontmatter');
|
||
});
|
||
});
|
||
|
||
// ─── neutralizeAgentReferences (#766) ─────────────────────────────────────────
|
||
|
||
describe('neutralizeAgentReferences', () => {
|
||
test('replaces standalone Claude with "the agent"', () => {
|
||
const input = 'Claude handles these decisions. Claude should read the file.';
|
||
const result = neutralizeAgentReferences(input, 'AGENTS.md');
|
||
assert.ok(!result.includes('Claude handles'), 'standalone Claude replaced');
|
||
assert.ok(result.includes('the agent handles'), 'replaced with "the agent"');
|
||
});
|
||
|
||
test('preserves Claude Code (product name)', () => {
|
||
const input = 'This is a Claude Code bug. Use Claude Code settings.';
|
||
const result = neutralizeAgentReferences(input, 'AGENTS.md');
|
||
assert.ok(result.includes('Claude Code bug'), 'Claude Code preserved');
|
||
assert.ok(result.includes('Claude Code settings'), 'Claude Code preserved');
|
||
});
|
||
|
||
test('preserves Claude model names', () => {
|
||
const input = 'Use Claude Opus for planning. Claude Sonnet for execution. Claude Haiku for research.';
|
||
const result = neutralizeAgentReferences(input, 'AGENTS.md');
|
||
assert.ok(result.includes('Claude Opus'), 'Opus preserved');
|
||
assert.ok(result.includes('Claude Sonnet'), 'Sonnet preserved');
|
||
assert.ok(result.includes('Claude Haiku'), 'Haiku preserved');
|
||
});
|
||
|
||
test('replaces CLAUDE.md with runtime instruction file', () => {
|
||
const input = 'Read CLAUDE.md for project instructions. Check ./CLAUDE.md if exists.';
|
||
const result = neutralizeAgentReferences(input, 'AGENTS.md');
|
||
assert.ok(result.includes('AGENTS.md'), 'CLAUDE.md -> AGENTS.md');
|
||
assert.ok(!result.includes('CLAUDE.md'), 'no CLAUDE.md remains');
|
||
});
|
||
|
||
test('uses different instruction file per runtime', () => {
|
||
const input = 'Read CLAUDE.md for instructions.';
|
||
assert.ok(neutralizeAgentReferences(input, 'GEMINI.md').includes('GEMINI.md'));
|
||
assert.ok(neutralizeAgentReferences(input, 'copilot-instructions.md').includes('copilot-instructions.md'));
|
||
assert.ok(neutralizeAgentReferences(input, 'AGENTS.md').includes('AGENTS.md'));
|
||
});
|
||
|
||
test('removes AGENTS.md load-blocking instruction', () => {
|
||
const input = 'Do NOT load full `AGENTS.md` files — they contain agent definitions.';
|
||
const result = neutralizeAgentReferences(input, 'AGENTS.md');
|
||
assert.ok(!result.includes('Do NOT load full'), 'blocking instruction removed');
|
||
});
|
||
|
||
test('preserves claude- prefixes (CSS classes, package names)', () => {
|
||
const input = 'The claude-ctx session and claude-code package.';
|
||
const result = neutralizeAgentReferences(input, 'AGENTS.md');
|
||
assert.ok(result.includes('claude-ctx'), 'claude- prefix preserved');
|
||
assert.ok(result.includes('claude-code'), 'claude-code preserved');
|
||
});
|
||
});
|
||
|
||
// ─── OpenCode-family skill converters (SKILL.md) — #784 ──────────────────────
|
||
|
||
const SKILL_SAMPLE_COMMAND = `---
|
||
description: Show available GSD commands and usage guide
|
||
argument-hint: "[topic]"
|
||
allowed-tools:
|
||
- Read
|
||
- Bash
|
||
---
|
||
|
||
Run \`/gsd:help\` to see the guide. AskUserQuestion when unsure.
|
||
`;
|
||
|
||
const SKILL_BETA_COMMAND = `---
|
||
description: "[BETA] Offload plan phase to the cloud and import back."
|
||
---
|
||
|
||
Body for /gsd:ultraplan-phase.
|
||
`;
|
||
|
||
describe('convertClaudeCommandToOpencodeSkill / convertClaudeCommandToKiloSkill (#784)', () => {
|
||
const cases = [
|
||
{ label: 'opencode', convert: convertClaudeCommandToOpencodeSkill },
|
||
{ label: 'kilo', convert: convertClaudeCommandToKiloSkill },
|
||
];
|
||
|
||
for (const { label, convert } of cases) {
|
||
describe(`${label} skill conversion`, () => {
|
||
test('emits SKILL.md frontmatter with name matching the skill dir', () => {
|
||
const out = convert(SKILL_SAMPLE_COMMAND, 'gsd-help');
|
||
assert.ok(out.startsWith('---\n'), 'opens with frontmatter');
|
||
assert.match(out, /^name: gsd-help$/m, 'name equals the skill name');
|
||
});
|
||
|
||
test('preserves the description from the source command', () => {
|
||
const out = convert(SKILL_SAMPLE_COMMAND, 'gsd-help');
|
||
assert.match(out, /^description: "Show available GSD commands and usage guide"$/m);
|
||
});
|
||
|
||
test('drops the command tools/permission block (skills inherit perms)', () => {
|
||
const out = convert(SKILL_SAMPLE_COMMAND, 'gsd-help');
|
||
const fmEnd = out.indexOf('\n---', 4);
|
||
const fm = out.slice(0, fmEnd);
|
||
assert.ok(!/tools:/.test(fm), 'no tools block in skill frontmatter');
|
||
assert.ok(!/permission:/.test(fm), 'no permission block in skill frontmatter');
|
||
});
|
||
|
||
test('rewrites /gsd: colon refs to hyphen form in the body', () => {
|
||
const out = convert(SKILL_SAMPLE_COMMAND, 'gsd-help');
|
||
assert.ok(!/\/gsd:/.test(out), 'no /gsd: colon refs remain');
|
||
assert.match(out, /\/gsd-help/, 'colon ref rewritten to hyphen form');
|
||
});
|
||
|
||
test('quotes descriptions with leading YAML flow indicators ([BETA])', () => {
|
||
const out = convert(SKILL_BETA_COMMAND, 'gsd-ultraplan-phase');
|
||
assert.match(out, /^description: "\[BETA\] /m, 'leading [BETA] safely quoted');
|
||
});
|
||
|
||
test('falls back to a synthetic description when none present', () => {
|
||
const out = convert('Body only, no frontmatter.', 'gsd-mystery');
|
||
assert.match(out, /^name: gsd-mystery$/m);
|
||
assert.match(out, /^description: "Run GSD workflow gsd-mystery\."$/m);
|
||
});
|
||
});
|
||
}
|
||
});
|
||
|
||
|
||
// ────────────────────────────────────────────────────────────────────────
|
||
// Folded from tests/feat-1173-agent-converters-descriptor.test.cjs — consolidation epic #1969 (B3 #1972)
|
||
// ────────────────────────────────────────────────────────────────────────
|
||
{
|
||
const { describe: __foldDescribe } = require('node:test');
|
||
__foldDescribe("folded:feat-1173-agent-converters-descriptor (consolidation epic #1969 B3 #1972)", () => {
|
||
'use strict';
|
||
|
||
/**
|
||
* feat-1173: Descriptor-driven agent converter wiring.
|
||
*
|
||
* Verifies that the descriptor-driven install path (dispatchKindEntry) applies
|
||
* per-runtime agent conversion when the 'agents' kind entry has a non-null
|
||
* converter — instead of silently raw-copying.
|
||
*
|
||
* Behavioral assertions: invoke the staging/dispatch seam, inspect the staged
|
||
* output files. NOT source-grep.
|
||
*
|
||
* TDD flow (REGRESSION-MUST-FAIL-FIRST rule):
|
||
* Before the fix, dispatchKindEntry ignores the converter for agents kind and
|
||
* raw-copies. The tests below prove conversion is applied by asserting that
|
||
* the staged .md contains runtime-specific frontmatter transformations absent
|
||
* in the raw source.
|
||
*/
|
||
|
||
const { describe, test } = require('node:test');
|
||
const assert = require('node:assert/strict');
|
||
const fs = require('node:fs');
|
||
const path = require('node:path');
|
||
const os = require('node:os');
|
||
|
||
const ROOT = path.join(__dirname, '..');
|
||
|
||
const {
|
||
resolveRuntimeArtifactLayoutFromRegistry,
|
||
} = require(path.join(ROOT, 'gsd-core', 'bin', 'lib', 'runtime-artifact-layout.cjs'));
|
||
|
||
const {
|
||
cleanupStagedSkills,
|
||
} = require(path.join(ROOT, 'gsd-core', 'bin', 'lib', 'install-profiles.cjs'));
|
||
|
||
const { cleanup } = require('./helpers.cjs');
|
||
|
||
// ─── fixtures ────────────────────────────────────────────────────────────────
|
||
|
||
/**
|
||
* Minimal Claude agent source with comma-separated tools (Claude format).
|
||
* Copilot conversion turns tools into a JSON array (CONV-04/05).
|
||
* Codex conversion adds <codex_agent_role> block.
|
||
* Cursor/Windsurf/Augment/Trae/Codebuddy/Cline conversion strips color field.
|
||
*/
|
||
const CLAUDE_AGENT_SOURCE = `---
|
||
name: gsd-planner
|
||
description: A GSD planning agent.
|
||
tools: Bash, Read, Write
|
||
color: blue
|
||
---
|
||
|
||
# GSD Planner
|
||
|
||
This agent plans GSD phases using ~/.claude/skills.
|
||
`;
|
||
|
||
/**
|
||
* Create a temp agents directory with a .gsd-source marker pointing back to it
|
||
* (so findAgentsSourceRoot finds the fixture dir, not the real agents/ dir).
|
||
* The .gsd-source convention expects the marker to point at a commands/gsd dir;
|
||
* agents/ is resolved as a sibling of commands/. So we set up:
|
||
* <tmproot>/
|
||
* commands/gsd/ (empty, satisfies the sibling check)
|
||
* agents/
|
||
* gsd-planner.md
|
||
* .gsd-source <- points to <tmproot>/commands/gsd
|
||
*/
|
||
function makeFixtureRoot(agentFiles) {
|
||
const root = fs.mkdtempSync(path.join(os.tmpdir(), 'gsd-1173-root-'));
|
||
const commandsDir = path.join(root, 'commands', 'gsd');
|
||
const agentsDir = path.join(root, 'agents');
|
||
fs.mkdirSync(commandsDir, { recursive: true });
|
||
fs.mkdirSync(agentsDir, { recursive: true });
|
||
// .gsd-source marker must point to commands/gsd so that agentsSourceRoot resolves to agents/
|
||
fs.writeFileSync(path.join(root, '.gsd-source'), commandsDir + '\n', 'utf8');
|
||
for (const { name, content } of agentFiles) {
|
||
fs.writeFileSync(path.join(agentsDir, name), content, 'utf8');
|
||
}
|
||
return root;
|
||
}
|
||
|
||
function makeSyntheticRegistry(converterName) {
|
||
return {
|
||
runtimes: {
|
||
testruntime: {
|
||
runtime: {
|
||
artifactLayout: {
|
||
global: [
|
||
{
|
||
kind: 'agents',
|
||
destSubpath: 'agents',
|
||
prefix: 'gsd-',
|
||
nesting: 'flat',
|
||
recursive: false,
|
||
converter: converterName,
|
||
},
|
||
],
|
||
local: [],
|
||
},
|
||
},
|
||
},
|
||
},
|
||
};
|
||
}
|
||
|
||
// ─── stageAgentsForRuntimeWithConverter unit tests ────────────────────────────
|
||
|
||
describe('feat-1173: stageAgentsForRuntimeWithConverter', () => {
|
||
test('is exported from install-profiles', () => {
|
||
const installProfiles = require(path.join(ROOT, 'gsd-core', 'bin', 'lib', 'install-profiles.cjs'));
|
||
assert.strictEqual(
|
||
typeof installProfiles.stageAgentsForRuntimeWithConverter,
|
||
'function',
|
||
'stageAgentsForRuntimeWithConverter must be exported',
|
||
);
|
||
});
|
||
|
||
test('applies converter to each staged agent file', (t) => {
|
||
const { stageAgentsForRuntimeWithConverter } = require(path.join(ROOT, 'gsd-core', 'bin', 'lib', 'install-profiles.cjs'));
|
||
|
||
const agentsDir = fs.mkdtempSync(path.join(os.tmpdir(), 'gsd-1173-agents-'));
|
||
fs.writeFileSync(path.join(agentsDir, 'gsd-planner.md'), CLAUDE_AGENT_SOURCE, 'utf8');
|
||
fs.writeFileSync(path.join(agentsDir, 'gsd-executor.md'), CLAUDE_AGENT_SOURCE.replace('gsd-planner', 'gsd-executor'), 'utf8');
|
||
|
||
t.after(() => {
|
||
cleanup(agentsDir);
|
||
cleanupStagedSkills();
|
||
});
|
||
|
||
const calls = [];
|
||
const converter = (content) => {
|
||
calls.push(content);
|
||
return content.replace('~/.claude/', '~/.copilot/');
|
||
};
|
||
|
||
const resolvedProfile = { name: 'full', skills: '*', agents: new Set() };
|
||
const stagedDir = stageAgentsForRuntimeWithConverter(agentsDir, resolvedProfile, converter);
|
||
|
||
assert.strictEqual(calls.length, 2, 'converter called for each agent file');
|
||
const stagedFiles = fs.readdirSync(stagedDir).sort();
|
||
assert.deepStrictEqual(stagedFiles, ['gsd-executor.md', 'gsd-planner.md']);
|
||
|
||
// Converter replaced ~/.claude/ with ~/.copilot/ in all staged files
|
||
for (const file of stagedFiles) {
|
||
const content = fs.readFileSync(path.join(stagedDir, file), 'utf8');
|
||
assert.ok(!content.includes('~/.claude/'), `${file}: converter must have replaced ~/.claude/`);
|
||
assert.ok(content.includes('~/.copilot/'), `${file}: converter must have injected ~/.copilot/`);
|
||
}
|
||
});
|
||
|
||
test('non-existent srcAgentsDir returns srcAgentsDir unchanged', () => {
|
||
const { stageAgentsForRuntimeWithConverter } = require(path.join(ROOT, 'gsd-core', 'bin', 'lib', 'install-profiles.cjs'));
|
||
const ghost = path.join(os.tmpdir(), 'gsd-1173-no-exist-' + Date.now());
|
||
const converter = (c) => c;
|
||
const result = stageAgentsForRuntimeWithConverter(ghost, { name: 'full', skills: '*', agents: new Set() }, converter);
|
||
assert.strictEqual(result, ghost, 'must return srcAgentsDir unchanged for non-existent dir');
|
||
});
|
||
|
||
test('only copies .md files (ignores non-.md)', (t) => {
|
||
const { stageAgentsForRuntimeWithConverter } = require(path.join(ROOT, 'gsd-core', 'bin', 'lib', 'install-profiles.cjs'));
|
||
const agentsDir = fs.mkdtempSync(path.join(os.tmpdir(), 'gsd-1173-agents-'));
|
||
fs.writeFileSync(path.join(agentsDir, 'gsd-planner.md'), CLAUDE_AGENT_SOURCE, 'utf8');
|
||
fs.writeFileSync(path.join(agentsDir, 'README.txt'), 'not an agent', 'utf8');
|
||
|
||
t.after(() => {
|
||
cleanup(agentsDir);
|
||
cleanupStagedSkills();
|
||
});
|
||
|
||
const converter = (c) => c;
|
||
const resolvedProfile = { name: 'full', skills: '*', agents: new Set() };
|
||
const stagedDir = stageAgentsForRuntimeWithConverter(agentsDir, resolvedProfile, converter);
|
||
const stagedFiles = fs.readdirSync(stagedDir);
|
||
assert.deepStrictEqual(stagedFiles, ['gsd-planner.md'], 'only .md files should be staged');
|
||
});
|
||
});
|
||
|
||
// ─── dispatchKindEntry wiring tests ──────────────────────────────────────────
|
||
|
||
describe('feat-1173: dispatchKindEntry agents converter wiring', () => {
|
||
test('agents kind with convertClaudeAgentToCopilotAgent converter applies copilot conversion', (t) => {
|
||
const fixtureRoot = makeFixtureRoot([{ name: 'gsd-planner.md', content: CLAUDE_AGENT_SOURCE }]);
|
||
t.after(() => {
|
||
cleanup(fixtureRoot);
|
||
cleanupStagedSkills();
|
||
});
|
||
|
||
const registry = makeSyntheticRegistry('convertClaudeAgentToCopilotAgent');
|
||
const layout = resolveRuntimeArtifactLayoutFromRegistry(
|
||
registry, 'testruntime', fixtureRoot, 'global',
|
||
);
|
||
|
||
assert.strictEqual(layout.kinds.length, 1);
|
||
const agentKind = layout.kinds[0];
|
||
assert.strictEqual(agentKind.kind, 'agents');
|
||
|
||
const resolvedProfile = { name: 'full', skills: '*', agents: new Set() };
|
||
const stagedDir = agentKind.stage(resolvedProfile);
|
||
|
||
const stagedFile = path.join(stagedDir, 'gsd-planner.md');
|
||
assert.ok(fs.existsSync(stagedFile), `staged file must exist: ${stagedFile}`);
|
||
|
||
const stagedContent = fs.readFileSync(stagedFile, 'utf8');
|
||
|
||
// Copilot CONV-04/05: tools converted from "Bash, Read, Write" to JSON array "['bash', 'read', 'write']"
|
||
// Raw copy would keep the original comma-separated "tools: Bash, Read, Write" line.
|
||
assert.notStrictEqual(stagedContent, CLAUDE_AGENT_SOURCE, 'converter must have transformed the content');
|
||
assert.ok(
|
||
stagedContent.includes("tools: ['") || stagedContent.includes('tools: ['),
|
||
`Copilot conversion must produce JSON array tools. Got:\n${stagedContent.slice(0, 300)}`,
|
||
);
|
||
});
|
||
|
||
test('agents kind with convertClaudeAgentToCodexAgent converter applies codex conversion', (t) => {
|
||
const fixtureRoot = makeFixtureRoot([{ name: 'gsd-planner.md', content: CLAUDE_AGENT_SOURCE }]);
|
||
t.after(() => {
|
||
cleanup(fixtureRoot);
|
||
cleanupStagedSkills();
|
||
});
|
||
|
||
const registry = makeSyntheticRegistry('convertClaudeAgentToCodexAgent');
|
||
const layout = resolveRuntimeArtifactLayoutFromRegistry(
|
||
registry, 'testruntime', fixtureRoot, 'global',
|
||
);
|
||
|
||
const agentKind = layout.kinds[0];
|
||
const resolvedProfile = { name: 'full', skills: '*', agents: new Set() };
|
||
const stagedDir = agentKind.stage(resolvedProfile);
|
||
|
||
const stagedContent = fs.readFileSync(path.join(stagedDir, 'gsd-planner.md'), 'utf8');
|
||
|
||
// Codex conversion adds <codex_agent_role> block
|
||
assert.notStrictEqual(stagedContent, CLAUDE_AGENT_SOURCE, 'converter must have transformed the content');
|
||
assert.ok(
|
||
stagedContent.includes('<codex_agent_role>'),
|
||
`Codex conversion must add <codex_agent_role>. Got:\n${stagedContent.slice(0, 300)}`,
|
||
);
|
||
});
|
||
|
||
test('agents kind with convertClaudeAgentToCursorAgent converter applies cursor conversion', (t) => {
|
||
const fixtureRoot = makeFixtureRoot([{ name: 'gsd-planner.md', content: CLAUDE_AGENT_SOURCE }]);
|
||
t.after(() => {
|
||
cleanup(fixtureRoot);
|
||
cleanupStagedSkills();
|
||
});
|
||
|
||
const registry = makeSyntheticRegistry('convertClaudeAgentToCursorAgent');
|
||
const layout = resolveRuntimeArtifactLayoutFromRegistry(
|
||
registry, 'testruntime', fixtureRoot, 'global',
|
||
);
|
||
|
||
const agentKind = layout.kinds[0];
|
||
const resolvedProfile = { name: 'full', skills: '*', agents: new Set() };
|
||
const stagedDir = agentKind.stage(resolvedProfile);
|
||
|
||
const stagedContent = fs.readFileSync(path.join(stagedDir, 'gsd-planner.md'), 'utf8');
|
||
|
||
// Cursor conversion strips color field and rewrites ~/.claude/ paths
|
||
assert.notStrictEqual(stagedContent, CLAUDE_AGENT_SOURCE, 'converter must have transformed the content');
|
||
assert.ok(
|
||
!stagedContent.includes('color:'),
|
||
`Cursor agent conversion should strip the color field. Got:\n${stagedContent.slice(0, 300)}`,
|
||
);
|
||
});
|
||
|
||
test('agents kind with converter=null still raw-copies (backward compat for claude)', (t) => {
|
||
const fixtureRoot = makeFixtureRoot([{ name: 'gsd-planner.md', content: CLAUDE_AGENT_SOURCE }]);
|
||
t.after(() => {
|
||
cleanup(fixtureRoot);
|
||
cleanupStagedSkills();
|
||
});
|
||
|
||
const registry = makeSyntheticRegistry(null);
|
||
const layout = resolveRuntimeArtifactLayoutFromRegistry(
|
||
registry, 'testruntime', fixtureRoot, 'global',
|
||
);
|
||
|
||
const agentKind = layout.kinds[0];
|
||
const resolvedProfile = { name: 'full', skills: '*', agents: new Set() };
|
||
const stagedDir = agentKind.stage(resolvedProfile);
|
||
|
||
// converter=null: stageAgentsForProfile with skills='*' returns srcAgentsDir unchanged
|
||
// (no staging dir is created; the source dir IS the staged dir, a passthrough)
|
||
const stagedContent = fs.readFileSync(path.join(stagedDir, 'gsd-planner.md'), 'utf8');
|
||
assert.strictEqual(stagedContent, CLAUDE_AGENT_SOURCE, 'converter=null must raw-copy the agent content');
|
||
});
|
||
|
||
test('scope threads isGlobal to a scope-aware converter (global vs local differ)', (t) => {
|
||
// The plumbing kept by #1173 (option a): convertedAgentsKind / dispatchKindEntry
|
||
// pass the install scope to the converter as isGlobal. A scope-aware converter
|
||
// (copilot) must therefore produce different output for global vs local. This
|
||
// proves the thread is live via a synthetic descriptor — no real runtime
|
||
// declares a converted agents kind yet (declarations deferred to the ADR-1235
|
||
// §0 parity follow-up).
|
||
const fixtureRoot = makeFixtureRoot([{ name: 'gsd-planner.md', content: CLAUDE_AGENT_SOURCE }]);
|
||
t.after(() => {
|
||
cleanup(fixtureRoot);
|
||
cleanupStagedSkills();
|
||
});
|
||
|
||
const agentsEntry = {
|
||
kind: 'agents',
|
||
destSubpath: 'agents',
|
||
prefix: 'gsd-',
|
||
nesting: 'flat',
|
||
recursive: false,
|
||
converter: 'convertClaudeAgentToCopilotAgent',
|
||
};
|
||
const registry = {
|
||
runtimes: { testruntime: { runtime: { artifactLayout: { global: [agentsEntry], local: [agentsEntry] } } } },
|
||
};
|
||
|
||
const profile = { name: 'full', skills: '*', agents: new Set() };
|
||
const stageFor = (scope) => {
|
||
const layout = resolveRuntimeArtifactLayoutFromRegistry(registry, 'testruntime', fixtureRoot, scope);
|
||
const agentKind = layout.kinds.find((k) => k.kind === 'agents');
|
||
assert.ok(agentKind, `${scope} layout must include an agents kind`);
|
||
return fs.readFileSync(path.join(agentKind.stage(profile), 'gsd-planner.md'), 'utf8');
|
||
};
|
||
|
||
const globalOut = stageFor('global');
|
||
const localOut = stageFor('local');
|
||
assert.notStrictEqual(
|
||
globalOut,
|
||
localOut,
|
||
'scope-aware converter output must differ by scope — proves isGlobal is threaded from the descriptor scope',
|
||
);
|
||
});
|
||
});
|
||
|
||
// ─── real registry: claude agents kind has converter=null ────────────────────
|
||
|
||
describe('feat-1173: real registry claude agents kind has converter=null (backward compat)', () => {
|
||
test('claude local artifacts layout has agents entry with converter=null', () => {
|
||
const registry = require(path.join(ROOT, 'gsd-core', 'bin', 'lib', 'capability-registry.cjs'));
|
||
const claudeDesc = registry.runtimes?.claude?.runtime?.artifactLayout?.local ?? [];
|
||
const agentsEntry = claudeDesc.find((e) => e.kind === 'agents');
|
||
assert.ok(agentsEntry, 'claude local artifactLayout must have an agents entry');
|
||
assert.strictEqual(agentsEntry.converter, null, 'claude agents entry must have converter=null');
|
||
});
|
||
});
|
||
});
|
||
}
|
||
|
||
|
||
// ────────────────────────────────────────────────────────────────────────
|
||
// Folded from tests/fix-1515-codex-runtime-default.test.cjs — consolidation epic #1969 (B3 #1972)
|
||
// ────────────────────────────────────────────────────────────────────────
|
||
{
|
||
const { describe: __foldDescribe } = require('node:test');
|
||
__foldDescribe("folded:fix-1515-codex-runtime-default (consolidation epic #1969 B3 #1972)", () => {
|
||
'use strict';
|
||
/**
|
||
* Regression tests for bug #1515: Codex install with runtime-neutral
|
||
* .planning/config.json resolves runtime as 'claude' and enables worktree
|
||
* isolation (unsafe for Codex).
|
||
*
|
||
* Root causes:
|
||
* A) config-get reads in workflows lacked --raw → output JSON-quoted →
|
||
* every comparison like [ "$RUNTIME" = "codex" ] failed silently.
|
||
* B) The conversion engine emitted --default claude for every runtime →
|
||
* neutral Codex config fell back to claude default.
|
||
*
|
||
* All tests assert on the SUT's RETURN VALUE (engine output), not raw file reads,
|
||
* except the integration test (test 4) which is explicitly the source↔engine
|
||
* parity guard and carries the allow-test-rule exemption.
|
||
*/
|
||
|
||
const { test } = require('node:test');
|
||
const assert = require('node:assert/strict');
|
||
const fs = require('node:fs');
|
||
const path = require('node:path');
|
||
const fc = require('fast-check');
|
||
const conversion = require('../gsd-core/bin/lib/runtime-artifact-conversion.cjs');
|
||
|
||
// ---------------------------------------------------------------------------
|
||
// Unit tests: engine stamps codex-specific defaults into emitted workflows
|
||
// ---------------------------------------------------------------------------
|
||
|
||
test('codex emit stamps its own runtime default into the runtime-resolution line', () => {
|
||
const line =
|
||
'RUNTIME=$(gsd_run query config-get runtime --default claude --raw 2>/dev/null || echo "claude")\n';
|
||
const out = conversion._applyRuntimeRewrites(line, 'codex', '$HOME/.codex/', true, undefined);
|
||
assert.ok(
|
||
out.includes('config-get runtime --default codex --raw'),
|
||
`Expected 'config-get runtime --default codex --raw' in output; got:\n${out}`,
|
||
);
|
||
assert.ok(
|
||
out.includes('|| echo "codex")'),
|
||
`Expected '|| echo "codex")' in output; got:\n${out}`,
|
||
);
|
||
assert.ok(
|
||
!out.includes('--default claude'),
|
||
`Expected '--default claude' to be fully rewritten; got:\n${out}`,
|
||
);
|
||
assert.ok(
|
||
!out.includes('echo "claude"'),
|
||
`Expected 'echo "claude"' to be fully rewritten; got:\n${out}`,
|
||
);
|
||
});
|
||
|
||
test('codex emit leaves workflow.use_worktrees at the true default — isolation is negotiated, not stamped (#1515 premise superseded by #2584/#2652)', () => {
|
||
// #1515 stamped `--default false` here because worktree isolation *was*
|
||
// Claude Code's isolation="worktree" spawn parameter, so a Codex install that
|
||
// resolved use_worktrees=true would have run unisolated while believing it was
|
||
// isolated. #2584 removed that premise: Codex declares
|
||
// `dispatch.isolation: orchestrator-worktree`, meaning GSD creates the
|
||
// worktree itself and spawns `codex exec --cd <worktree>` — supported, not
|
||
// unsafe. Keeping the stamp would resolve USE_WORKTREES=false before
|
||
// dispatch-isolation is consulted, re-deciding isolation by runtime name,
|
||
// which is the exact defect #2652 removes. The safety property #1515 protects
|
||
// is now held by the isolation gate's fail-closed resolution, not by a
|
||
// name-scoped install-time default.
|
||
const line =
|
||
'USE_WORKTREES=$(gsd_run query config-get workflow.use_worktrees --raw 2>/dev/null || echo "true")\n';
|
||
const out = conversion._applyRuntimeRewrites(line, 'codex', '$HOME/.codex/', true, undefined);
|
||
assert.strictEqual(
|
||
conversion._negotiatedDispatchIsolation('codex'),
|
||
'orchestrator-worktree',
|
||
'codex must declare orchestrator-worktree for this expectation to hold',
|
||
);
|
||
assert.strictEqual(
|
||
out,
|
||
line,
|
||
`Expected the use_worktrees read to survive codex emit untouched; got:\n${out}`,
|
||
);
|
||
});
|
||
|
||
test('claude runtime does NOT rewrite the runtime default — stamping is non-claude-scoped (#1521 inversion)', () => {
|
||
// #1521 generalizes stamping to ALL non-Claude runtimes. The negative case
|
||
// (no stamping) is now the 'claude' runtime, not other non-Claude runtimes.
|
||
const line =
|
||
'RUNTIME=$(gsd_run query config-get runtime --default claude --raw 2>/dev/null || echo "claude")\n';
|
||
const out = conversion._applyRuntimeRewrites(line, 'claude', '$HOME/.claude/', true, undefined);
|
||
assert.ok(
|
||
out.includes('--default claude --raw'),
|
||
`Expected claude output to preserve '--default claude --raw'; got:\n${out}`,
|
||
);
|
||
assert.ok(
|
||
!out.includes('--default codex'),
|
||
`Expected claude output NOT to contain '--default codex'; got:\n${out}`,
|
||
);
|
||
});
|
||
|
||
// ---------------------------------------------------------------------------
|
||
// Integration / parity guard: real source ↔ engine output for codex (all surfaces)
|
||
// ---------------------------------------------------------------------------
|
||
|
||
test('regression: every edited workflow gets codex-stamped (source↔engine parity, all surfaces) (#1515)', () => {
|
||
// allow-test-rule: pending-migration-to-typed-ir [#3090]
|
||
// `out` is _applyRuntimeRewrites's engine-transformed shell text, not shipped
|
||
// source — substring-matching it is the "Rendered file" row CONTRIBUTING
|
||
// requires a typed-IR builder for. No such IR exists yet for the shell
|
||
// rewrite output; production change out of scope here. Tracked under #3090.
|
||
const WORKFLOWS = ['execute-phase.md', 'autonomous.md', 'manager.md', 'diagnose-issues.md', 'quick.md'];
|
||
const CLAUDE_RUNTIME = 'config-get runtime --default claude --raw 2>/dev/null || echo "claude"';
|
||
const CODEX_RUNTIME = 'config-get runtime --default codex --raw 2>/dev/null || echo "codex"';
|
||
const TRUE_WT = 'config-get workflow.use_worktrees --raw 2>/dev/null || echo "true"';
|
||
const FALSE_WT = 'config-get workflow.use_worktrees --default false --raw 2>/dev/null || echo "false"';
|
||
for (const wf of WORKFLOWS) {
|
||
const src = fs.readFileSync(path.join(__dirname, '..', 'gsd-core', 'workflows', wf), 'utf8');
|
||
const out = conversion._applyRuntimeRewrites(src, 'codex', '$HOME/.codex/', true, undefined);
|
||
// No un-stamped claude runtime line may survive codex emit on ANY surface.
|
||
assert.ok(!out.includes(CLAUDE_RUNTIME), `${wf}: residual un-stamped runtime read — engine regex no longer matches source line (parity drift)`);
|
||
// If the source HAS such a read, the codex form must be present.
|
||
if (src.includes(CLAUDE_RUNTIME)) assert.ok(out.includes(CODEX_RUNTIME), `${wf}: runtime read not stamped to codex`);
|
||
// #2652: codex declares orchestrator-worktree, so the use_worktrees read is
|
||
// left for `gsd_run query dispatch-isolation` to decide at run time — the
|
||
// install-time `--default false` stamp would pre-empt that negotiation.
|
||
if (src.includes(TRUE_WT)) {
|
||
assert.ok(out.includes(TRUE_WT), `${wf}: use_worktrees read was stamped away for a runtime that negotiates worktree isolation (#2652)`);
|
||
assert.ok(!out.includes(FALSE_WT), `${wf}: codex gained the --default false use_worktrees stamp (#2652)`);
|
||
}
|
||
}
|
||
});
|
||
|
||
// ---------------------------------------------------------------------------
|
||
// Property tests (RULESET.TESTS.property-based-testing)
|
||
// ---------------------------------------------------------------------------
|
||
|
||
test('property: runtime stamping applies for ALL non-claude runtimes; only claude leaves --default claude unchanged (#1521)', () => {
|
||
// #1521: generalised from codex-only to all non-claude runtimes.
|
||
// Use the canonical list from the conversion module to avoid hand-rolled array drift.
|
||
const { NON_CLAUDE_RUNTIMES } = conversion;
|
||
const RUNTIMES = ['claude', ...NON_CLAUDE_RUNTIMES];
|
||
const line = 'RUNTIME=$(gsd_run query config-get runtime --default claude --raw 2>/dev/null || echo "claude")\n';
|
||
fc.assert(fc.property(fc.constantFrom(...RUNTIMES), (rt) => {
|
||
const out = conversion._applyRuntimeRewrites(line, rt, `$HOME/.${rt}/`, true, undefined);
|
||
return rt === 'claude'
|
||
? out.includes('--default claude --raw') && !out.includes('--default codex')
|
||
: out.includes(`--default ${rt} --raw`) && !out.includes('--default claude');
|
||
}));
|
||
});
|
||
|
||
test('property: codex stamping is idempotent on resolution lines (#1515)', () => {
|
||
fc.assert(fc.property(fc.constantFrom('runtime', 'use_worktrees'), (which) => {
|
||
const line = which === 'runtime'
|
||
? 'RUNTIME=$(gsd_run query config-get runtime --default claude --raw 2>/dev/null || echo "claude")\n'
|
||
: 'USE_WORKTREES=$(gsd_run query config-get workflow.use_worktrees --raw 2>/dev/null || echo "true")\n';
|
||
const once = conversion._applyRuntimeRewrites(line, 'codex', '$HOME/.codex/', true, undefined);
|
||
const twice = conversion._applyRuntimeRewrites(once, 'codex', '$HOME/.codex/', true, undefined);
|
||
return once === twice;
|
||
}));
|
||
});
|
||
});
|
||
}
|
||
|
||
|
||
// ────────────────────────────────────────────────────────────────────────
|
||
// Folded from tests/fix-1521-non-claude-runtime-default-resolution.test.cjs — consolidation epic #1969 (B3 #1972)
|
||
// ────────────────────────────────────────────────────────────────────────
|
||
{
|
||
const { describe: __foldDescribe } = require('node:test');
|
||
__foldDescribe("folded:fix-1521-non-claude-runtime-default-resolution (consolidation epic #1969 B3 #1972)", () => {
|
||
'use strict';
|
||
/**
|
||
* Regression tests for #1521: every non-Claude runtime stamps its own runtime
|
||
* identity into emitted workflows, and stamps workflow.use_worktrees=false
|
||
* where its negotiated dispatch.isolation is `none`.
|
||
*
|
||
* #1519 (Codex-only fix) was generalized here to ALL non-Claude runtimes on the
|
||
* premise that GSD's worktree isolation was Claude Code's isolation="worktree"
|
||
* spawn parameter, which no other runtime honored. #2584 replaced that premise
|
||
* with the negotiated `dispatch.isolation` capability, and #2652 scoped the
|
||
* use_worktrees stamp to match: a host declaring harness-worktree or
|
||
* orchestrator-worktree keeps the `true` default, because stamping it false
|
||
* pre-empts the negotiation and re-decides isolation by runtime name.
|
||
*
|
||
* All tests assert on the SUT's RETURN VALUE (engine output), not raw file reads,
|
||
* except the parity integration test which carries the allow-test-rule exemption.
|
||
*/
|
||
|
||
const { test } = require('node:test');
|
||
const assert = require('node:assert/strict');
|
||
const fs = require('node:fs');
|
||
const path = require('node:path');
|
||
const fc = require('fast-check');
|
||
const conversion = require('../gsd-core/bin/lib/runtime-artifact-conversion.cjs');
|
||
|
||
// #1521: use the canonical list from the conversion module rather than a hand-rolled
|
||
// local array that can drift from the real runtime set.
|
||
const { NON_CLAUDE_RUNTIMES: NON_CLAUDE } = conversion;
|
||
const WORKFLOWS = [
|
||
'execute-phase.md', 'autonomous.md', 'manager.md', 'diagnose-issues.md', 'quick.md',
|
||
];
|
||
|
||
const CLAUDE_RUNTIME_LINE = 'config-get runtime --default claude --raw 2>/dev/null || echo "claude"';
|
||
const TRUE_WT_LINE = 'config-get workflow.use_worktrees --raw 2>/dev/null || echo "true"';
|
||
const FALSE_WT_LINE = 'config-get workflow.use_worktrees --default false --raw 2>/dev/null || echo "false"';
|
||
|
||
// ---------------------------------------------------------------------------
|
||
// Parity across ALL non-Claude runtimes × all 5 workflows
|
||
// ---------------------------------------------------------------------------
|
||
|
||
test('parity: every non-Claude runtime stamps its own runtime default, and use_worktrees=false only where isolation negotiates to none (#1521, #2652)', () => {
|
||
// allow-test-rule: pending-migration-to-typed-ir [#3090]
|
||
// `out` is _applyRuntimeRewrites's engine-transformed shell text, not shipped
|
||
// source — substring-matching it is the "Rendered file" row CONTRIBUTING
|
||
// requires a typed-IR builder for. No such IR exists yet for the shell
|
||
// rewrite output; production change out of scope here. Tracked under #3090.
|
||
for (const rt of NON_CLAUDE) {
|
||
const isolation = conversion._negotiatedDispatchIsolation(rt);
|
||
for (const wf of WORKFLOWS) {
|
||
const src = fs.readFileSync(
|
||
path.join(__dirname, '..', 'gsd-core', 'workflows', wf),
|
||
'utf8',
|
||
);
|
||
const out = conversion._applyRuntimeRewrites(src, rt, `$HOME/.${rt}/`, true, undefined);
|
||
|
||
// No un-stamped claude runtime line may survive
|
||
assert.ok(
|
||
!out.includes(CLAUDE_RUNTIME_LINE),
|
||
`${rt}/${wf}: residual un-stamped claude runtime read — _stampNonClaudeRuntimeDefaults not applied`,
|
||
);
|
||
|
||
// If the source had a runtime read, the output must have --default <rt>
|
||
if (src.includes(CLAUDE_RUNTIME_LINE)) {
|
||
assert.ok(
|
||
out.includes(`config-get runtime --default ${rt} --raw 2>/dev/null || echo "${rt}"`),
|
||
`${rt}/${wf}: runtime line not stamped to --default ${rt}`,
|
||
);
|
||
}
|
||
|
||
if (!src.includes(TRUE_WT_LINE)) continue;
|
||
|
||
// #2652: the use_worktrees=false stamp is scoped to the runtimes whose
|
||
// negotiated dispatch.isolation really is `none`. A host that declares
|
||
// harness-worktree (cursor) or orchestrator-worktree (codex, opencode,
|
||
// kimi, kimi-code) must keep the unstamped `true` default, or the stamp
|
||
// resolves USE_WORKTREES=false before dispatch-isolation is consulted and
|
||
// the runtime is judged by its name after all.
|
||
if (isolation === 'none') {
|
||
assert.ok(
|
||
!out.includes(TRUE_WT_LINE),
|
||
`${rt}/${wf}: residual un-stamped use_worktrees=true read — _stampNonClaudeRuntimeDefaults not applied`,
|
||
);
|
||
assert.ok(
|
||
out.includes(FALSE_WT_LINE),
|
||
`${rt}/${wf}: use_worktrees line not defaulted to false`,
|
||
);
|
||
} else {
|
||
assert.ok(
|
||
out.includes(TRUE_WT_LINE),
|
||
`${rt}/${wf}: declares dispatch.isolation=${isolation} but the use_worktrees read was stamped away — the install-time default pre-empts the negotiated capability (#2652)`,
|
||
);
|
||
assert.ok(
|
||
!out.includes(FALSE_WT_LINE),
|
||
`${rt}/${wf}: declares dispatch.isolation=${isolation} but gained the --default false stamp`,
|
||
);
|
||
}
|
||
}
|
||
}
|
||
});
|
||
|
||
// ---------------------------------------------------------------------------
|
||
// #2652: the stamp's scope is the negotiated capability, not the runtime name
|
||
// ---------------------------------------------------------------------------
|
||
|
||
test('regression #2652: _stampNonClaudeRuntimeDefaults leaves use_worktrees alone for every runtime that negotiates a worktree isolation', () => {
|
||
const line =
|
||
'USE_WORKTREES=$(gsd_run query config-get workflow.use_worktrees --raw 2>/dev/null || echo "true")\n';
|
||
|
||
// The set is derived from the registry, not hand-listed, so a newly declared
|
||
// worktree host is covered the moment it lands — the same reason
|
||
// NON_CLAUDE_RUNTIMES is derived rather than literal (#1521).
|
||
const declaresWorktree = NON_CLAUDE.filter(
|
||
(rt) => conversion._negotiatedDispatchIsolation(rt) !== 'none',
|
||
);
|
||
const declaresNone = NON_CLAUDE.filter(
|
||
(rt) => conversion._negotiatedDispatchIsolation(rt) === 'none',
|
||
);
|
||
|
||
// Both arms must be non-empty or the test proves nothing about either.
|
||
assert.ok(
|
||
declaresWorktree.length > 0,
|
||
'no non-Claude runtime negotiates a worktree isolation — the regression this pins is unreachable',
|
||
);
|
||
assert.ok(
|
||
declaresNone.length > 0,
|
||
'every non-Claude runtime negotiates a worktree isolation — the false stamp is dead code',
|
||
);
|
||
|
||
for (const rt of declaresWorktree) {
|
||
assert.strictEqual(
|
||
conversion._stampNonClaudeRuntimeDefaults(line, rt),
|
||
line,
|
||
`${rt}: negotiates ${conversion._negotiatedDispatchIsolation(rt)} but its use_worktrees default was stamped false at install time, so dispatch-isolation-gate.md resolves ISOLATION=none regardless of what it declared (#2652)`,
|
||
);
|
||
}
|
||
|
||
for (const rt of declaresNone) {
|
||
assert.ok(
|
||
conversion._stampNonClaudeRuntimeDefaults(line, rt).includes(FALSE_WT_LINE),
|
||
`${rt}: negotiates none, so the false default must still be stamped (#1521)`,
|
||
);
|
||
}
|
||
});
|
||
|
||
test('regression #2652: _negotiatedDispatchIsolation fails closed on an undeclared or unknown runtime', () => {
|
||
// Mirrors routeDispatchIsolation's fail-closed contract (ADR-1239): anything
|
||
// outside the closed vocabulary resolves to `none`, so the #1521 stamp — and
|
||
// the workflows' isolation gate — degrade to sequential rather than to an
|
||
// unisolated dispatch that believes it is isolated.
|
||
for (const unknown of ['not-a-runtime', '', 'CLAUDE', '__proto__']) {
|
||
assert.strictEqual(
|
||
conversion._negotiatedDispatchIsolation(unknown),
|
||
'none',
|
||
`${JSON.stringify(unknown)}: expected fail-closed 'none'`,
|
||
);
|
||
}
|
||
|
||
// A registry-known host whose declared value is the `undocumented` sentinel
|
||
// (or absent) is out of vocabulary and must degrade the same way.
|
||
const registry = require('../gsd-core/bin/lib/capability-registry.cjs');
|
||
const undocumented = NON_CLAUDE.filter((rt) => {
|
||
const declared = registry?.runtimes?.[rt]?.runtime?.hostIntegration?.dispatch?.isolation;
|
||
return declared === 'undocumented' || declared == null;
|
||
});
|
||
assert.ok(undocumented.length > 0, 'no runtime declares the undocumented sentinel — nothing to pin');
|
||
for (const rt of undocumented) {
|
||
assert.strictEqual(conversion._negotiatedDispatchIsolation(rt), 'none', `${rt}: undocumented must degrade to none`);
|
||
}
|
||
});
|
||
|
||
// ---------------------------------------------------------------------------
|
||
// #2652 review round-5/6 Major 1 — PARITY with the runtime resolver.
|
||
//
|
||
// `_negotiatedDispatchIsolation` (install time, this module) and
|
||
// `routeDispatchIsolation` (dispatch time, gsd-core/bin/gsd-tools.cjs) are two
|
||
// implementations of ONE rule: what isolation may this host negotiate. They
|
||
// read the same inputs — the capability registry and `resolveOrchestratorExec`
|
||
// — but duplicate the DECISION on top of them, on two surfaces (the install
|
||
// engine and the CLI query hub) with no call edge between them. So neither
|
||
// symbol appears in the other's impact graph and no static analysis sees the
|
||
// duplication. Divergence would be silent, and its consequence is the #2652
|
||
// defect returning by the back door: the installer stamping
|
||
// `use_worktrees=false` for a host the resolver would have granted a worktree
|
||
// (or the reverse — an unstamped host whose dispatch then refuses).
|
||
//
|
||
// The assertion is therefore behavioral on BOTH sides: the resolver leg drives
|
||
// the REAL CLI and reads its actual stdout.
|
||
// ---------------------------------------------------------------------------
|
||
|
||
test('regression #2652: _negotiatedDispatchIsolation agrees with the routeDispatchIsolation CLI for every registered runtime', () => {
|
||
const { runGsdTools, createTempProject, cleanup: cleanupDir } = require('./helpers.cjs');
|
||
const registry = require('../gsd-core/bin/lib/capability-registry.cjs');
|
||
const RUNTIME_IDS = Object.keys(registry.runtimes).sort();
|
||
|
||
// Install time cannot know the worktree a future dispatch will target, so
|
||
// `_negotiatedDispatchIsolation` probes the orchestrator descriptor with a
|
||
// placeholder. The CLI is asked BOTH ways, because the two calls are both real:
|
||
//
|
||
// --cwd-target <probe> the executor-spawn call, which resolves the descriptor.
|
||
// Same question install time asks; must match exactly.
|
||
// (no --cwd-target) the FIRST call every dispatch site makes — the
|
||
// `Resolve ISOLATION` block in dispatch-isolation-gate.md.
|
||
// It skips descriptor resolution, so it can only differ
|
||
// from install time for an orchestrator host whose
|
||
// descriptor does not resolve. No such host exists today
|
||
// and that is worth pinning: if one lands, the install
|
||
// stamps `use_worktrees=false` while the workflow gate
|
||
// still reports `orchestrator-worktree` — the #2652 split
|
||
// brain, in the one shape the target-bound leg cannot see.
|
||
const PROBE_TARGET = '/gsd-orchestrator-worktree-probe';
|
||
|
||
const dir = createTempProject('gsd-2652-parity-');
|
||
try {
|
||
const disagreements = [];
|
||
const seen = new Set();
|
||
for (const rt of RUNTIME_IDS) {
|
||
const res = runGsdTools(
|
||
['query', 'dispatch-isolation', '--json', '--cwd-target', PROBE_TARGET],
|
||
dir,
|
||
{ GSD_RUNTIME: rt, HOME: dir },
|
||
);
|
||
assert.equal(res.success, true, `${rt}: dispatch-isolation query failed: ${res.error}`);
|
||
const parsed = JSON.parse(res.output);
|
||
|
||
// Guard the guard: if resolveRuntime normalized `rt` to some other id, the
|
||
// comparison below would be pinning the wrong host and silently pass.
|
||
assert.equal(
|
||
parsed.runtime,
|
||
rt,
|
||
`${rt}: the CLI resolved runtime "${parsed.runtime}" instead — parity would be measured against the wrong host`,
|
||
);
|
||
|
||
const gateRes = runGsdTools(
|
||
['query', 'dispatch-isolation', '--raw'],
|
||
dir,
|
||
{ GSD_RUNTIME: rt, HOME: dir },
|
||
);
|
||
assert.equal(gateRes.success, true, `${rt}: no-target dispatch-isolation query failed: ${gateRes.error}`);
|
||
const gateIsolation = gateRes.output.trim();
|
||
|
||
const installTime = conversion._negotiatedDispatchIsolation(rt);
|
||
seen.add(installTime);
|
||
if (installTime !== parsed.isolation) {
|
||
disagreements.push(
|
||
`${rt}: install-time _negotiatedDispatchIsolation → "${installTime}", ` +
|
||
`dispatch-time routeDispatchIsolation (--cwd-target) → "${parsed.isolation}"`,
|
||
);
|
||
}
|
||
if (installTime !== gateIsolation) {
|
||
disagreements.push(
|
||
`${rt}: install-time _negotiatedDispatchIsolation → "${installTime}", ` +
|
||
`workflow-gate routeDispatchIsolation (no --cwd-target) → "${gateIsolation}"`,
|
||
);
|
||
}
|
||
}
|
||
|
||
assert.deepEqual(
|
||
disagreements,
|
||
[],
|
||
'the install-time and dispatch-time isolation resolvers disagree. One of them was ' +
|
||
'changed without the other (DEFECT.GENERATIVE-FIX-DIVERGENCE): the installer and the ' +
|
||
'dispatch gate would then make opposite isolation decisions for the same host.\n' +
|
||
disagreements.join('\n'),
|
||
);
|
||
|
||
// A parity check over a set that only ever answers `none` proves nothing —
|
||
// both legs could be stubbed to a constant and still agree.
|
||
for (const mode of ['harness-worktree', 'orchestrator-worktree', 'none']) {
|
||
assert.ok(
|
||
seen.has(mode),
|
||
`no registered runtime resolves to "${mode}" — the parity above never exercised that branch`,
|
||
);
|
||
}
|
||
} finally {
|
||
cleanupDir(dir);
|
||
}
|
||
});
|
||
|
||
// ---------------------------------------------------------------------------
|
||
// Claude unchanged — no stamping for the native runtime
|
||
// ---------------------------------------------------------------------------
|
||
|
||
test('claude runtime leaves runtime default and use_worktrees=true unchanged (#1521)', () => {
|
||
const src = fs.readFileSync(
|
||
path.join(__dirname, '..', 'gsd-core', 'workflows', 'execute-phase.md'),
|
||
'utf8',
|
||
);
|
||
const out = conversion._applyRuntimeRewrites(src, 'claude', '$HOME/.claude/', true, undefined);
|
||
|
||
// Claude emit must preserve the original --default claude line
|
||
if (src.includes(CLAUDE_RUNTIME_LINE)) {
|
||
assert.ok(
|
||
out.includes(CLAUDE_RUNTIME_LINE),
|
||
`claude/execute-phase.md: expected original claude runtime line to survive; got mutated`,
|
||
);
|
||
}
|
||
|
||
// Claude emit must NOT gain --default false for use_worktrees
|
||
assert.ok(
|
||
!out.includes(FALSE_WT_LINE),
|
||
`claude/execute-phase.md: use_worktrees line must NOT be stamped false for claude runtime`,
|
||
);
|
||
});
|
||
|
||
// ---------------------------------------------------------------------------
|
||
// fc property — identity: each runtime stamps itself, claude stays unchanged
|
||
// ---------------------------------------------------------------------------
|
||
|
||
test('property: _stampNonClaudeRuntimeDefaults stamps each non-claude runtime and leaves claude unchanged (#1521)', () => {
|
||
const line =
|
||
'RUNTIME=$(gsd_run query config-get runtime --default claude --raw 2>/dev/null || echo "claude")\n';
|
||
fc.assert(
|
||
fc.property(fc.constantFrom(...NON_CLAUDE, 'claude'), (rt) => {
|
||
const out = conversion._applyRuntimeRewrites(line, rt, `$HOME/.${rt}/`, true, undefined);
|
||
if (rt === 'claude') {
|
||
return out.includes('--default claude') && !/--default (?!claude)/.test(out);
|
||
}
|
||
return out.includes(`--default ${rt}`) && !out.includes('--default claude');
|
||
}),
|
||
);
|
||
});
|
||
|
||
// ---------------------------------------------------------------------------
|
||
// fc property — idempotence: stamping twice equals once
|
||
// ---------------------------------------------------------------------------
|
||
|
||
test('property: _stampNonClaudeRuntimeDefaults is idempotent (#1521)', () => {
|
||
fc.assert(
|
||
fc.property(
|
||
fc.constantFrom(...NON_CLAUDE),
|
||
fc.constantFrom('runtime', 'use_worktrees'),
|
||
(rt, which) => {
|
||
const line =
|
||
which === 'runtime'
|
||
? 'RUNTIME=$(gsd_run query config-get runtime --default claude --raw 2>/dev/null || echo "claude")\n'
|
||
: 'USE_WORKTREES=$(gsd_run query config-get workflow.use_worktrees --raw 2>/dev/null || echo "true")\n';
|
||
const once = conversion._applyRuntimeRewrites(line, rt, `$HOME/.${rt}/`, true, undefined);
|
||
const twice = conversion._applyRuntimeRewrites(once, rt, `$HOME/.${rt}/`, true, undefined);
|
||
return once === twice;
|
||
},
|
||
),
|
||
);
|
||
});
|
||
|
||
// ---------------------------------------------------------------------------
|
||
// Guard generalization: execute-phase.md uses != "claude" not = "codex"
|
||
// ---------------------------------------------------------------------------
|
||
|
||
// ---------------------------------------------------------------------------
|
||
// Guard generalization: execute-phase.md, quick.md, and diagnose-issues.md
|
||
// all use != "claude" (not = "codex") for the worktree guard (#1521)
|
||
// ---------------------------------------------------------------------------
|
||
|
||
test('execute-phase.md, quick.md, and diagnose-issues.md guards are generalized to != "claude" (not Codex-specific) (#1521)', () => {
|
||
// allow-test-rule: source-text-is-the-product (#1521)
|
||
// Reads the raw shipped workflow .md source directly (not engine-transformed
|
||
// output) and asserts on its literal guard-clause text — the deployed prose
|
||
// IS the runtime contract here.
|
||
// #2584 Phase 3 (#2627): execute-phase.md graduated PAST the `!= "claude"`
|
||
// guard — worktree isolation there is now keyed on the negotiated
|
||
// `dispatch.isolation` capability, so no runtime name appears in its guard at
|
||
// all.
|
||
//
|
||
// #2652: quick.md and diagnose-issues.md have now graduated too. This block
|
||
// previously asserted they still carried the #1521 generalized form, with a
|
||
// comment noting "they do not negotiate isolation" — i.e. the test knowingly
|
||
// pinned the un-migrated state #2652 was filed about. They negotiate now, so
|
||
// they are held to the same capability-keyed contract as execute-phase.md.
|
||
const GUARD_WORKFLOWS = ['quick.md', 'diagnose-issues.md', 'execute-phase.md'];
|
||
for (const wf of GUARD_WORKFLOWS) {
|
||
const src = fs.readFileSync(
|
||
path.join(__dirname, '..', 'gsd-core', 'workflows', wf),
|
||
'utf8',
|
||
);
|
||
assert.ok(
|
||
!src.includes('[ "$RUNTIME" != "claude" ] && [ "$USE_WORKTREES" != "false" ]'),
|
||
`${wf}: worktree isolation must branch on dispatch.isolation, not on != "claude" (#2584/#2652)`,
|
||
);
|
||
assert.ok(
|
||
!src.includes('[ "$RUNTIME" = "codex" ] && [ "$USE_WORKTREES" != "false" ]'),
|
||
`${wf}: found Codex-specific guard — isolation is a negotiated capability (#2584/#2652)`,
|
||
);
|
||
}
|
||
|
||
// The two migrated sites must actually negotiate, not merely drop the guard.
|
||
for (const wf of ['quick.md', 'diagnose-issues.md']) {
|
||
const src = fs.readFileSync(
|
||
path.join(__dirname, '..', 'gsd-core', 'workflows', wf),
|
||
'utf8',
|
||
);
|
||
assert.ok(
|
||
src.includes('query dispatch-isolation'),
|
||
`${wf}: must resolve ISOLATION via \`gsd_run query dispatch-isolation\` (#2652)`,
|
||
);
|
||
}
|
||
|
||
// execute-phase.md: the guard must be capability-keyed, with NO runtime name.
|
||
const executePhase = fs.readFileSync(
|
||
path.join(__dirname, '..', 'gsd-core', 'workflows', 'execute-phase.md'),
|
||
'utf8',
|
||
);
|
||
assert.ok(
|
||
!/\[\s*"\$RUNTIME"\s*(?:!=|=)\s*"[a-z-]+"\s*\]\s*&&\s*\[\s*"\$USE_WORKTREES"/.test(executePhase),
|
||
'execute-phase.md: worktree isolation must branch on dispatch.isolation, not on a runtime name (#2584)',
|
||
);
|
||
assert.ok(
|
||
executePhase.includes('Resolve ISOLATION'),
|
||
'execute-phase.md: must resolve the negotiated ISOLATION capability',
|
||
);
|
||
});
|
||
|
||
// ---------------------------------------------------------------------------
|
||
// Orchestration gating: manager.md + autonomous.md gate background dispatch on
|
||
// the typed FLATTEN query. #1708 (ADR-1239 Phase B) graduated #1521's
|
||
// codex-specific check to a documentation-sourced shouldFlattenDispatch — the
|
||
// prose now branches on `FLATTEN` (false = background), not a runtime name.
|
||
// ---------------------------------------------------------------------------
|
||
|
||
test('manager.md and autonomous.md gate run_in_background on FLATTEN=false, not a runtime name (#1521, graduated by #1708)', () => {
|
||
// allow-test-rule: source-text-is-the-product (#1521/#1708)
|
||
// Reads the raw shipped manager.md/autonomous.md workflow prose directly —
|
||
// the deployed orchestration dispatch gating text IS the runtime contract.
|
||
const manager = fs.readFileSync(
|
||
path.join(__dirname, '..', 'gsd-core', 'workflows', 'manager.md'),
|
||
'utf8',
|
||
);
|
||
const autonomous = fs.readFileSync(
|
||
path.join(__dirname, '..', 'gsd-core', 'workflows', 'autonomous.md'),
|
||
'utf8',
|
||
);
|
||
|
||
// Both files must gate run_in_background on the typed FLATTEN decision (not a runtime name)
|
||
assert.ok(
|
||
/If `FLATTEN` is `false`[\s\S]{0,500}?run_in_background=true/.test(manager),
|
||
'manager.md: expected run_in_background dispatch gated on FLATTEN=false (typed dispatch-should-flatten query)',
|
||
);
|
||
assert.ok(
|
||
/If `FLATTEN` is `false`[\s\S]{0,1200}?run_in_background=true/.test(autonomous),
|
||
'autonomous.md: expected run_in_background dispatch gated on FLATTEN=false (typed dispatch-should-flatten query)',
|
||
);
|
||
|
||
// Inline is the else branch, keyed on FLATTEN — never a runtime name
|
||
assert.ok(
|
||
/Otherwise[\s\S]{0,250}?inline/i.test(manager),
|
||
'manager.md: expected "Otherwise ... inline" branch keyed on FLATTEN',
|
||
);
|
||
assert.ok(
|
||
/Otherwise[\s\S]{0,250}?inline/i.test(autonomous),
|
||
'autonomous.md: expected "Otherwise ... inline" branch keyed on FLATTEN',
|
||
);
|
||
// And the old runtime-name gating must be gone (no `RUNTIME` is `codex` dispatch gate)
|
||
assert.ok(
|
||
!/`RUNTIME` is `codex`[\s\S]{0,500}?run_in_background=true/.test(manager),
|
||
'manager.md: must no longer gate run_in_background on the runtime name',
|
||
);
|
||
});
|
||
|
||
test('manager.md and autonomous.md no longer contain old "not claude" background-dispatch gating (#1521)', () => {
|
||
// allow-test-rule: source-text-is-the-product (#1521)
|
||
// Reads the raw shipped manager.md/autonomous.md workflow prose directly —
|
||
// the deployed orchestration dispatch gating text IS the runtime contract.
|
||
const manager = fs.readFileSync(
|
||
path.join(__dirname, '..', 'gsd-core', 'workflows', 'manager.md'),
|
||
'utf8',
|
||
);
|
||
const autonomous = fs.readFileSync(
|
||
path.join(__dirname, '..', 'gsd-core', 'workflows', 'autonomous.md'),
|
||
'utf8',
|
||
);
|
||
|
||
// The old phrasing that unconditionally sent every non-claude runtime to background must be gone
|
||
assert.ok(
|
||
!manager.includes('If `RUNTIME` is not `claude` (e.g. Codex)'),
|
||
'manager.md: old "If `RUNTIME` is not `claude` (e.g. Codex)" gating must be replaced',
|
||
);
|
||
assert.ok(
|
||
!autonomous.includes('On other runtimes:'),
|
||
'autonomous.md: old "On other runtimes:" branch label must be replaced',
|
||
);
|
||
});
|
||
});
|
||
}
|
||
|
||
// ────────────────────────────────────────────────────────────────────────
|
||
// Folded from tests/bug-2876-skill-frontmatter-quote.test.cjs — consolidation epic #1969 (B8 #1977)
|
||
// ────────────────────────────────────────────────────────────────────────
|
||
{
|
||
const { describe: __foldDescribe } = require('node:test');
|
||
__foldDescribe("folded:bug-2876-skill-frontmatter-quote (consolidation epic #1969 B8 #1977)", () => {
|
||
/**
|
||
* Bug #2876: SKILL.md frontmatter parse failure when `description` begins
|
||
* with a YAML flow indicator like `[BETA]`.
|
||
*
|
||
* description: [BETA] Offload plan phase to Claude Code's ultraplan…
|
||
*
|
||
* YAML 1.2 treats a leading `[` as the start of a flow sequence, so any
|
||
* downstream parser (gh-copilot, JetBrains' kit, etc.) fails with
|
||
* "Unexpected scalar at node end". The Copilot/Antigravity/Trae/Codebuddy
|
||
* skill+agent converters in `bin/install.js` re-emit the description
|
||
* unquoted; the Claude variant `yamlQuote(...)`s it. Bring the others
|
||
* in line so any value is round-trip-safe regardless of leading char.
|
||
*
|
||
* The test is structural: it parses each emitted frontmatter into lines
|
||
* and asserts the `description` value is a quoted YAML scalar (double or
|
||
* single quoted) when the source description starts with a flow indicator.
|
||
* It does not regex the bytes for substrings.
|
||
*/
|
||
'use strict';
|
||
|
||
process.env.GSD_TEST_MODE = '1';
|
||
|
||
const { describe, test } = require('node:test');
|
||
const assert = require('node:assert/strict');
|
||
const path = require('node:path');
|
||
const fs = require('node:fs');
|
||
|
||
const REPO_ROOT = path.join(__dirname, '..');
|
||
const pkg = JSON.parse(fs.readFileSync(path.join(REPO_ROOT, 'package.json'), 'utf-8'));
|
||
const installPath = path.resolve(REPO_ROOT, pkg.bin['gsd-core']);
|
||
const install = require(installPath);
|
||
|
||
// Build a minimal Claude command source whose description starts with the
|
||
// reporter's exact flow-indicator prefix. Apostrophe in the body forces
|
||
// any naive single-quoting to also escape correctly — the canonical
|
||
// safe form is `JSON.stringify(...)` (used by yamlQuote).
|
||
const REPORTER_DESCRIPTION =
|
||
"[BETA] Offload plan phase to Claude Code's ultraplan cloud — drafts remotely while terminal stays free, review in browser with inline comments, import back via /gsd-import. Claude Code only.";
|
||
|
||
// Use unquoted description in the source frontmatter — that's exactly the
|
||
// shape that ships in commands/gsd/*.md when authors paste a description
|
||
// without quoting it (see commands/gsd/ultraplan-phase.md). The bug is
|
||
// triggered when the converter re-emits this same value to the destination
|
||
// runtime without quoting. `extractFrontmatterField` strips a single outer
|
||
// quote pair but does not unescape internal characters, so quoting the
|
||
// fixture input would actually mask the bug.
|
||
function buildClaudeCommand(description) {
|
||
return [
|
||
'---',
|
||
'name: gsd:ultraplan-phase',
|
||
`description: ${description}`,
|
||
'argument-hint: "[phase-number]"',
|
||
'allowed-tools:',
|
||
' - Read',
|
||
' - Bash',
|
||
'---',
|
||
'',
|
||
'# body',
|
||
'',
|
||
].join('\n');
|
||
}
|
||
|
||
function buildClaudeAgent(description) {
|
||
return [
|
||
'---',
|
||
'name: gsd-extract-learnings',
|
||
`description: ${description}`,
|
||
'tools: Read, Bash',
|
||
'---',
|
||
'',
|
||
'# body',
|
||
'',
|
||
].join('\n');
|
||
}
|
||
|
||
function extractFrontmatter(content) {
|
||
// Leading delimiter is `---\n`; closing is the next standalone `---`
|
||
// on its own line. Tests parse line-structurally so the assertion
|
||
// doesn't drift on whitespace/order changes (per project test-rigor).
|
||
assert.ok(content.startsWith('---'), `output must begin with frontmatter, got: ${content.slice(0, 40)}`);
|
||
const lines = content.split('\n');
|
||
let openIdx = -1;
|
||
let closeIdx = -1;
|
||
for (let i = 0; i < lines.length; i += 1) {
|
||
if (lines[i] === '---') {
|
||
if (openIdx === -1) openIdx = i;
|
||
else { closeIdx = i; break; }
|
||
}
|
||
}
|
||
assert.ok(openIdx !== -1 && closeIdx !== -1, `output must have a closed frontmatter block, got:\n${content}`);
|
||
return lines.slice(openIdx + 1, closeIdx);
|
||
}
|
||
|
||
function findDescriptionLine(frontmatterLines) {
|
||
for (const line of frontmatterLines) {
|
||
if (line.startsWith('description:')) return line;
|
||
}
|
||
assert.fail(`no description line found in frontmatter:\n${frontmatterLines.join('\n')}`);
|
||
return ''; // unreachable
|
||
}
|
||
|
||
function isQuotedYamlScalar(valueText) {
|
||
// YAML safe-quoted scalar: starts with `"` and ends with `"`, OR
|
||
// starts with `'` and ends with `'`. This is what `yamlQuote()`
|
||
// (JSON.stringify) and the Claude variant of these converters emit.
|
||
const trimmed = valueText.trim();
|
||
if (trimmed.startsWith('"') && trimmed.endsWith('"')) return true;
|
||
if (trimmed.startsWith("'") && trimmed.endsWith("'")) return true;
|
||
return false;
|
||
}
|
||
|
||
function parseQuotedYamlValue(valueText) {
|
||
const trimmed = valueText.trim();
|
||
if (trimmed.startsWith('"')) return JSON.parse(trimmed);
|
||
if (trimmed.startsWith("'")) return trimmed.slice(1, -1).replace(/''/g, "'");
|
||
return trimmed;
|
||
}
|
||
|
||
function assertDescriptionRoundTrips(emitted, expected, label) {
|
||
const fmLines = extractFrontmatter(emitted);
|
||
const descLine = findDescriptionLine(fmLines);
|
||
const valueText = descLine.slice('description:'.length);
|
||
assert.ok(
|
||
isQuotedYamlScalar(valueText),
|
||
`(${label}) description must be a quoted YAML scalar (parser-safe for leading flow indicators). Got line: ${descLine}`,
|
||
);
|
||
assert.strictEqual(
|
||
parseQuotedYamlValue(valueText),
|
||
expected,
|
||
`(${label}) description must round-trip through YAML quoting unchanged.`,
|
||
);
|
||
}
|
||
|
||
const COMMAND_CONVERTERS = [
|
||
{ label: 'convertClaudeCommandToCopilotSkill', fn: (src) => install.convertClaudeCommandToCopilotSkill(src, 'gsd-ultraplan-phase') },
|
||
{ label: 'convertClaudeCommandToAntigravitySkill', fn: (src) => install.convertClaudeCommandToAntigravitySkill(src, 'gsd-ultraplan-phase') },
|
||
{ label: 'convertClaudeCommandToTraeSkill', fn: (src) => install.convertClaudeCommandToTraeSkill(src, 'gsd-ultraplan-phase') },
|
||
{ label: 'convertClaudeCommandToCodebuddySkill', fn: (src) => install.convertClaudeCommandToCodebuddySkill(src, 'gsd-ultraplan-phase') },
|
||
];
|
||
|
||
const AGENT_CONVERTERS = [
|
||
{ label: 'convertClaudeAgentToCopilotAgent', fn: (src) => install.convertClaudeAgentToCopilotAgent(src) },
|
||
{ label: 'convertClaudeAgentToAntigravityAgent', fn: (src) => install.convertClaudeAgentToAntigravityAgent(src) },
|
||
];
|
||
|
||
// A grab-bag of leading characters that all break unquoted YAML scalar
|
||
// parsing per YAML 1.2 §7.3.3 / §6.9. The reporter's case is `[`; the
|
||
// rest defend against neighbouring drift.
|
||
const FLOW_HOSTILE_PREFIXES = ['[', '{', '*', '&', '!', '|', '>', '%', '@', '`'];
|
||
|
||
// Some converters (Trae, CodeBuddy) deliberately rewrite "Claude Code"
|
||
// in body content to their target runtime name, and the rewrite cuts
|
||
// across the description too. That's correct behavior — out of scope for
|
||
// the YAML-quoting fix — so for the reporter case we assert only the
|
||
// quoting requirement, not byte-equality of the round-tripped value.
|
||
function assertDescriptionIsQuoted(emitted, label) {
|
||
const fmLines = extractFrontmatter(emitted);
|
||
const descLine = findDescriptionLine(fmLines);
|
||
const valueText = descLine.slice('description:'.length);
|
||
assert.ok(
|
||
isQuotedYamlScalar(valueText),
|
||
`(${label}) description must be a quoted YAML scalar (parser-safe for leading flow indicators). Got line: ${descLine}`,
|
||
);
|
||
}
|
||
|
||
describe('bug-2876: skill+agent converters emit YAML-quoted description', () => {
|
||
for (const { label, fn } of COMMAND_CONVERTERS) {
|
||
test(`${label}: reporter's "[BETA] ..." description is quoted`, () => {
|
||
const out = fn(buildClaudeCommand(REPORTER_DESCRIPTION));
|
||
assertDescriptionIsQuoted(out, label);
|
||
});
|
||
for (const prefix of FLOW_HOSTILE_PREFIXES) {
|
||
test(`${label}: leading ${JSON.stringify(prefix)} is quoted`, () => {
|
||
// Avoid leading/trailing `'` or `"` in the payload — `extractFrontmatterField`
|
||
// strips a single outer quote char of either kind regardless of whether
|
||
// the value was actually quoted, which would obscure the round-trip
|
||
// assertion. Pre-existing behavior, out of scope for #2876.
|
||
const desc = `${prefix} edge-case payload — flow indicator at start`;
|
||
const out = fn(buildClaudeCommand(desc));
|
||
assertDescriptionRoundTrips(out, desc, `${label} prefix=${prefix}`);
|
||
});
|
||
}
|
||
}
|
||
|
||
for (const { label, fn } of AGENT_CONVERTERS) {
|
||
test(`${label}: reporter-shape "[BETA] ..." description is quoted`, () => {
|
||
const out = fn(buildClaudeAgent(REPORTER_DESCRIPTION));
|
||
assertDescriptionIsQuoted(out, label);
|
||
});
|
||
}
|
||
});
|
||
});
|
||
}
|