Files
msd-core/docs/adr/3660-runtime-artifact-layout-module.md
Tom Boucher 463cffd894 chore(#604): rename get-shit-done/ runtime directory to gsd-core/ (#615)
* chore(#604): rename get-shit-done/ runtime directory to gsd-core/

Renames the installed runtime directory `get-shit-done/` to `gsd-core/` so the
on-disk name matches the package (`@opengsd/gsd-core`), repo, and binary
(`gsd-tools`). The npm package name and binary are unchanged; npx/npm consumers
are unaffected.

Mechanical (bulk, ~90% of the diff):
- `git mv get-shit-done gsd-core`
- Swept path/identifier references across the repo via
  `perl -pe 's/get-shit-done(?!-\w)/gsd-core/g'`. The negative lookahead
  preserves the five legitimate slug variants that are NOT the directory:
  get-shit-done-{OLD,cc,classic,cli,redux} (old package/repo names).
- Build/manifest wiring: package.json (bin, files, coverage globs),
  tsconfig.build.json (outDir), ~86 .gitignore build-output entries,
  stryker.config.mjs, scan-ignore files, install.js path strings.
- Frozen (not rewritten): CHANGELOG.md history; translated docs
  (README.<locale>.md and docs/{ja-JP,ko-KR,pt-BR,zh-CN}/).

New logic (review here):
- src/installer-migrations/003-rename-get-shit-done-to-gsd-core.cts: a proper
  ADR-0008 installer migration. On upgrade it walks the legacy
  `~/.claude/get-shit-done/` tree, classifies each file via the prior install
  manifest, and emits remove-managed / backup-and-remove for managed files
  while PRESERVING unknown user-added files. Symlink-safe (skips a symlinked
  root and symlinked entries; bounds-checks every path under configDir). The
  framework rolls back on install failure. Emptied dirs may remain (framework
  has no recursive dir-removal primitive) — documented.
- scripts/lint-legacy-dir-name.cjs: CI regression guard forbidding the bare
  `get-shit-done` directory token (split token to avoid self-match; case-
  insensitive; `(?!-\w)` lookahead allows the slug variants; allowlists
  CHANGELOG, translated docs, and `gsd-allow-legacy-name` marker lines).
  Wired into the lint-tests CI job.
- Restored scripts/lint-package-identity-drift.cjs detection regexes (the
  mechanical sweep had wrongly rewritten the old-name patterns it exists to
  detect) and marked them as intentional legacy references.
- TDD tests for the migration and the guard; do.md slash-command guard regex
  tightened so a `/gsd-core/bin` path segment is not mistaken for a command;
  changeset + docs/installer-migrations.md row added.

Breaking: the installed runtime path moves `~/.claude/get-shit-done/` ->
`~/.claude/gsd-core/`. Migration 003 removes the stale legacy dir's managed
files (preserving user files) on upgrade. Users with custom hooks/configs
hardcoding the old path must update them.

Closes #604

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

* fix(#604): unsweep pending changesets + allowlist injection-example docs

CI fixes for the rename PR:
- Do not sweep pending .changeset/*.md (ephemeral release-note fragments,
  like CHANGELOG); reverted those body edits so 5 pre-existing malformed
  fragments (missing type/pr) no longer enter the PR diff and trip docs-lint.
  Allowlisted .changeset/ in the legacy-name guard accordingly.
- Allowlisted TEST-EXAMPLES.md and docs/explanation/security-model.md in
  prompt-injection-scan.sh: they contain intentional injection examples /
  security-model prose; the path-reference rewrites are kept.

CodeQL alerts on this PR are pre-existing (alert lines unchanged by this PR;
none in the new migration/guard) and are out of scope for the rename.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

* fix(#604): resolve CodeQL alerts surfaced on this PR

The rename diff touched files carrying pre-existing CodeQL findings; per the
no-pre-existing-dismissal rule, fixing every surfaced alert rather than waving
them off. All behavior-preserving:

- scripts/ci-test-scope.cjs: build the config-path match from string
  .includes() instead of a RegExp over an arg-derived value (js/regex-injection).
- src/profile-output.cts: escape backslashes before pipe-escaping desc/safeName
  so the table-cell escape is complete (js/incomplete-sanitization).
- tests/{bug-2643,bug-2808,docs-parity-live-registry}: two-pass HTML-comment
  strip so a bare/unclosed `<!--` cannot survive (js/incomplete-multi-character-sanitization).
- tests/inline-plan-threshold: drop the no-op `\s`->`\s` identity replace,
  keep the meaningful POSIX-class conversion (js/identity-replacement).

Verified: build:lib green; the touched test files + ci-test-scope + profile-output
suites pass; lint:legacy-name clean.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

* fix(#604): correctly resolve remaining CodeQL alerts (regex-injection + sanitization)

The prior commit's fixes for two alerts were ineffective:
- ci-test-scope.cjs js/regex-injection: the alert is the CLI-arg-derived `file`
  reaching static regex `.test(file)` calls (not the config rule). Removed ALL
  regex over file/t — startsWith/includes/=== string checks + an isWindowsHint
  helper — so there is no regex sink for the tainted value.
- js/incomplete-multi-character-sanitization (3 test files): a single
  `.replace(/<!--...-->/g,'')` can let `<!--` re-form. Replaced with a fixpoint
  loop (replace until stable) plus a final bare-opener strip.

Verified: no regex over file/t remains; ci-test-scope + the 3 test suites pass;
lint:legacy-name clean.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

* fix(#604): make ci-test-scope + comment-strippers regex-free to clear CodeQL

CodeQL flags the regex PATTERNS syntactically (regex-injection on the
--files arg split; incomplete-multi-character-sanitization on the <!--...-->
replace), so loop fixes do not satisfy it. Made these paths regex-free:
- ci-test-scope.cjs splitFiles: char-by-char separator tokenizer (no /[,\\s]+/).
- 3 test files: indexOf/slice HTML-comment stripper (no .replace(/<!--/)).
Behavior preserved; ci-test-scope + the 3 suites pass; guard clean.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

* fix(#604): unblock security base64 scan on the large rename diff

The security job hit its 10m timeout: base64-scan.sh choked on the binary
test fixture tests/feat-3594-parser-property-style.test.cjs (embedded NUL/
non-UTF8 bytes -> thousands of bogus blobs + "ignored null byte" warnings),
and the ~800-file rename diff is slow to scan regardless.

- scripts/base64-scan.sh: skip binary-by-content files (grep -Iq .) — they
  can't carry base64-obfuscated *text* and feeding NUL bytes through the
  per-line scanner is pathologically slow. collect_files already filtered
  binary *extensions*; this catches binary *content* in text extensions.
- .github/workflows/security-scan.yml: raise the security job timeout 10m->30m
  to accommodate very large diffs (the scan itself is unchanged).

Verified locally: scan skips the fixture, 0 "ignored null byte" warnings,
0 findings, exit 0.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

* fix(#604): sweep get-shit-done refs introduced by merging next

The branch was updated with next (#614/#384/#618 etc.), which reference the
get-shit-done/ dir (still named that on next). Swept the stale references in
the merged files to gsd-core so the rename stays consistent and lint:legacy-name
passes:
- commands/gsd/discuss-phase.md (runtime-launcher shim paths)
- src/core.cts (getAgentsDir layout comments)
- tests/bug-384-agents-runtime-aware.test.cjs (require path to runtime lib)

Verified: guard 0 violations; build green.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

* fix(#604): exclude gsd-core/ path segments from bug-3683 command cross-ref invariant

The #614 runtime-launcher shim added to discuss-phase.md references
`${_GSD_RUNTIME_ROOT}/gsd-core/bin/...`. bug-3683's REF_PATTERN excluded path-y
refs only via lookbehind, but `}` precedes `/gsd-core/` in the shim, so it
mis-read the directory path as a dangling `/gsd-core` command ref (same class as
the #604 bug-2954 fix). Added a trailing `(?![\w-]*\/)` so `/gsd-<x>/...` path
segments are not treated as slash-command references.

Verified locally on BOTH platforms before pushing:
- mac (node 26) full suite: 0 failures
- gsd-test-runner (linux, node22 image) full suite: 0 failures
- bug-3683 + bug-2954 pass.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

* fix(#604): lazily resolve findProjectRoot in gsd-tools (harden flaky CI)

CI intermittently failed state.test's gsd-tools subprocess with
"findProjectRoot is not a function" (flip-flopping across legs; not reproducible
on mac full suite, gsd-test linux full suite, test:unit, or state.test x8).
findProjectRoot is a re-export from core.cjs (sourced from project-root.cjs);
binding it via destructure at module-load can be undefined under a load-ordering
edge. Resolve it lazily at call time via a small wrapper so the lookup happens
after core.cjs is fully initialized.

Verified green on BOTH platforms before pushing:
- mac (node 26) full suite: 0 failures
- gsd-test-runner (linux, node22) full suite: 0 failures
- state.test.cjs: 106/106; gsd-tools loads cleanly.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

* fix(#604): allowlist verification-patterns.md placeholder examples in secret scan

The rename git-mv'd references/verification-patterns.md into gsd-core/, pulling
it into the secret-scan diff. It documents stub/placeholder RED-FLAG env-var
examples (illustrative Stripe test-key / database-URL / API-key placeholders) —
not real credentials. Added it to .secretscanignore with the strict annotation,
mirroring the existing gsd-core/workflows/plan-phase.md exception.

Verified locally: secret-scan-lint --strict OK; secret-scan --diff origin/next
exits 0 with 0 findings.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-02 18:35:29 -04:00

12 KiB
Raw Blame History

Runtime Artifact Layout Module owns per-runtime artifact placement

  • Status: Accepted
  • Date: 2026-05-17
  • Issue: #3660
  • Implementation: #3663 (Phase 1), feat/3663-runtime-artifact-layout-module-phase-1-m

The Runtime Surface Module (gsd-core/bin/lib/surface.cjs, introduced by ADR-0011 Phase 2) re-materializes a resolved Skill Surface profile to disk via applySurface. It currently hardcodes two artifact kinds (commands, agents) and re-derives their source directories via _findInstallSource / _findAgentsSource walk-up heuristics. The install and uninstall pipelines in bin/install.js each encode the same per-runtime artifact layout independently across ~14 install sites and ~6 uninstall sites. Bug #3659 surfaced the resulting drift: applySurface omits the skills kind for runtimes whose canonical layout is skills/gsd-<stem>/SKILL.md, so gsd-surface profile <name> leaves ~67 skill directories on disk under the install-time profile's footprint when the resolved profile should have pruned them — roughly 2.7k tokens per session on a measured workstation.

The root problem is the absence of a typed seam for "where does runtime R put artifact kind K." Three lifecycle sites (install, uninstall, surface) each independently encode this knowledge and drift independently.

Decision

  • Add a Runtime Artifact Layout Module at gsd-core/bin/lib/runtime-artifact-layout.cjs as the single owner of the per-runtime artifact-placement table.
  • The module requires runtime-homes.cjs for the canonical runtime enum and global config-dir resolution. It adds the artifact-kind axis on top.
  • Expose resolveRuntimeArtifactLayout(runtime, configDir) → Layout. The returned Layout is a plain typed object — { runtime, configDir, kinds: ArtifactKind[] } — with no I/O on resolution.
  • Each ArtifactKind is { kind: 'commands'|'agents'|'skills', destSubpath, prefix, stage }. stage is a function (resolvedProfile) → stagedDir that closes over the per-runtime converter where one is needed (e.g. convertClaudeCommandToClaudeSkill for the skills kind on Claude global).
  • The kinds array is empty for runtimes with no GSD surface (a hypothetical future runtime with no integration). The skills kind is absent for runtimes that don't materialize skill directories (Cline; Gemini today). The commands kind is absent for runtimes that consume only the skills/agents layout (Claude global, Codex, etc.).
  • Per-runtime quirks live in the layout's record fields, not in caller branches:
    • Hermes: { kind: 'skills', destSubpath: 'skills/gsd', prefix: '' } — preserves the nested namespace from #2841.
    • Cline: kinds: [] — Cline resolves to zero kinds in Phase 1 (no commands kind).
    • Gemini: kinds: [ { kind: 'commands', destSubpath: 'commands/gsd', prefix: 'gsd-' } ] — no agents, no skills.
  • applySurface migrates from (runtimeConfigDir, commandsDir, agentsDir, manifest, clusterMap) to (runtimeConfigDir, layout, manifest, clusterMap). Body collapses to for (const kind of layout.kinds) _syncGsdDir(kind.stage(resolved), path.join(layout.configDir, kind.destSubpath), kind.kind).
  • _findInstallSource and _findAgentsSource in surface.cjs are removed. The layout owns source resolution.
  • Phase 2 (separate PR): install and uninstall paths in bin/install.js migrate to iterate layout.kinds. Per-runtime if/else branches for skill-directory creation/removal collapse to one layout-driven loop per pipeline.
  • Legacy-layout migrations (bin/install.js:6710/:8402 for the pre-nested skills/gsd-*/ flat layout; migrateLegacyDevPreferencesToSkill for #2973) remain inside the Installer Migration Module (ADR-0008) and run before layout-driven copy. The layout module describes only the current canonical target — no historical kinds.

Initial Scope

Phase 1 should land the module and one consumer (the bug-#3659 fix):

  1. New gsd-core/bin/lib/runtime-artifact-layout.cjs — resolveRuntimeArtifactLayout, the typed Layout/ArtifactKind shapes, and the runtime table covering every runtime currently enumerated in runtime-homes.cjs.
  2. surface.cjs:applySurface migrates to layout-driven iteration. _findInstallSource and _findAgentsSource deleted. The skills kind is now iterated alongside commands and agents — bug #3659 closed.
  3. commands/gsd/surface.md and tests/surface-apply.test.cjs updated to construct + pass Layout values.
  4. New tests/runtime-artifact-layout-*.test.cjs covering:
    • Per-runtime fixture table: each runtime maps to the expected kinds[] shape.
    • Hermes skills/gsd nested case.
    • Cline / Gemini "kind absent" cases.
    • Source-root resolution (replacing the existing surface.cjs walk-up tests).
  5. Address the adjacent readSurface partial-field silent-null bug noted in #3659 — out of scope here; track as a separate confirmed-bug ticket.

Phase 1 should not:

  • Migrate the install/uninstall pipelines in bin/install.js in the same PR. That's a separate enhancement issue — same seam, larger blast radius. The layout module is dual-consumable from the start; converting bin/install.js is a sequenced follow-up.
  • Move the per-runtime skill converters (convertClaudeCommandToClaudeSkill, etc.). They survive at their current file location as the stage adapters; the layout module references them. A future ADR may consolidate them into a Skill Conversion Module if a second consumer emerges.

Migration Inventory

New file

  • gsd-core/bin/lib/runtime-artifact-layout.cjs — module body + runtime layout table.

Files modified (Phase 1)

  • gsd-core/bin/lib/surface.cjs — applySurface signature change; _findInstallSource + _findAgentsSource removal.
  • commands/gsd/surface.md — runbook updates the 3 sites that call applySurface to first call resolveRuntimeArtifactLayout.
  • tests/surface-apply.test.cjs — 5 call sites pass layout instead of commandsDir, agentsDir.

Files modified (Phase 2 — separate PR / separate issue)

  • bin/install.js — install path: 4 per-runtime skill-stage blocks collapse to one layout-driven loop.
  • bin/install.js — uninstall path: 6 per-runtime skill-removal blocks collapse to one layout-driven loop.
  • Estimated reduction: ~250 lines.

Files not touched

  • runtime-homes.cjs — its narrow contract (runtime → global config dir / skills base) stays. The layout module is its sibling.
  • install-profiles.cjs — stageSkillsForProfile, stageAgentsForProfile remain. The layout module's kinds[i].stage closures call them.
  • The four skill converters at bin/install.js:1622/1681/1792/2534 — remain in place; layout closures reference them.

Interface sketch

// runtime-artifact-layout.cjs

/**
 * @typedef {Object} ArtifactKind
 * @property {'commands'|'agents'|'skills'} kind
 * @property {string} destSubpath              joined to layout.configDir
 * @property {string} prefix                   'gsd-' or '' (Hermes nested case)
 * @property {(resolved) => string} stage      returns staged dir path
 */

/**
 * @typedef {Object} Layout
 * @property {string} runtime                  canonical enum from runtime-homes.cjs
 * @property {string} configDir                caller-supplied (local or global scope)
 * @property {ArtifactKind[]} kinds            empty array = runtime has no gsd-* surface
 */

function resolveRuntimeArtifactLayout(runtime, configDir) { … }

Call-site shape:

// commands/gsd/surface.md (runbook), tests/surface-apply.test.cjs, future install/uninstall
const layout = resolveRuntimeArtifactLayout(runtime, runtimeConfigDir);
applySurface(runtimeConfigDir, layout, manifest, CLUSTERS);

applySurface body after migration:

function applySurface(runtimeConfigDir, layout, manifest, clusterMap) {
  const resolved = resolveSurface(runtimeConfigDir, manifest, clusterMap);
  for (const kind of layout.kinds) {
    const staged = kind.stage(resolved);
    const dest = path.join(layout.configDir, kind.destSubpath);
    if (fs.existsSync(dest)) _syncGsdDir(staged, dest, kind.kind);
  }
}

Consequences

  • Bug #3659 becomes a fixture-table omission, not a forgotten if/else block. The layout-table test asserts every runtime's kinds[] shape — forgetting the skills kind on Claude global would fail there.
  • The cross-runtime test matrix collapses from N runtimes × 3 lifecycle verbs × 3 kinds (today: ~120 implicit assertion pairs) to N (layout table) + 3 (one per lifecycle verb iterating layout.kinds).
  • Adding a new runtime (recent example: Grok via commit 05316369) becomes one row in the layout table plus one fixture row in the test. The three lifecycle verbs pick it up automatically.
  • The four per-runtime skill converters become canonical adapters at the artifact-kind seam. Their existence is no longer accidental — they're the seam's content.
  • surface.cjs shrinks (_findInstallSource + _findAgentsSource removed). The walk-up heuristics — which were only ever-incidentally correct — are replaced by an explicit table.
  • Phase 2 (install/uninstall migration) shrinks bin/install.js by ~250 lines and removes a recurring class of bug: a new runtime added by a contributor who forgets to wire it through every install/uninstall branch.
  • Future architecture reviews should treat per-runtime artifact-placement knowledge added outside runtime-artifact-layout.cjs as drift, parallel to how ADR-0011 made out-of-seam skill staging drift.
  • The Skill Surface Budget Module's leverage (typed sets of { skills, agents }) now extends all the way to disk through one seam rather than three independent re-materializations.

Open questions

  • Whether the skills kind's stage closure should accept the per-runtime converter as a parameter (preserving converter-as-pure-function purity) or import it directly. Implementation detail — settle in the PR.
  • Whether the layout module should expose a listKinds(runtime) introspection helper for status/diagnostics surfaces, or keep Layout as the only public type. Lean toward a single public type; add helpers only when a second consumer needs them.
  • Whether Phase 2 (install/uninstall migration in bin/install.js) should land as a single follow-up PR or be split per pipeline. Lean toward single PR — the install and uninstall sides share the runtime branch structure and migrating only one introduces a temporary asymmetry inverse to today's.
  • The adjacent readSurface partial-field silent-null fallback in surface.cjs:55-75 (also flagged in #3659) is out of scope here — track separately. It's an independent shallow interface in the same module, not a runtime-layout concern.

References

  • Confirmed bug: #3659 — applySurface doesn't prune ~/.claude/skills/gsd-*/ dirs
  • See 0011-skill-surface-budget-module.md — the Runtime Surface Module this seam serves
  • See 0008-installer-migration-module.md — legacy-layout migrations stay there
  • See 0005-sdk-architecture-seam-map.md — the seam map this module joins
  • Existing canonical sibling: gsd-core/bin/lib/runtime-homes.cjs
  • Per-runtime skill converters this module references: bin/install.js:1622 (Copilot), :1681 (Claude), :1792 (Antigravity), :2534 (Codex)
  • Hermes nested-skills layout rationale: #2841

Implementation status

Phase 1 implementation landed on feat/3663-runtime-artifact-layout-module-phase-1-m:

  • gsd-core/bin/lib/runtime-artifact-layout.cjs — 15-runtime layout table (grok intentionally excluded), resolveRuntimeArtifactLayout(runtime, configDir, scope) → Layout, walk-up findInstallSourceRoot helper.
  • Clarification: in this Phase 1 implementation, Cline resolves to zero kinds (kinds: []), so it carries no commands kind in the layout table.
  • gsd-core/bin/lib/install-profiles.cjs — new stageSkillsForRuntimeAsSkills(srcCommandsDir, resolvedProfile, converter, prefix) → stagedDir helper.
  • gsd-core/bin/lib/surface.cjs — applySurface(runtimeConfigDir, layout, manifest, clusterMap) signature migration; _findInstallSource + _findAgentsSource deleted; _syncGsdDir extended to handle the skills kind via directory iteration.
  • Tests: runtime-artifact-layout-resolve.test.cjs (16), runtime-artifact-layout-edge-cases.test.cjs (10), runtime-artifact-layout-stage.test.cjs (5), install-profiles-stage.test.cjs (+7 new), surface-apply.test.cjs (updated 5 call sites + new skills-kind test).

Phase 2 (separate issue #3664 — bin/install.js install/uninstall pipeline migration) is blocked on Phase 1 merge.