@opengsd/gsd-core 1.5.0 → 1.6.0-rc.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (95) hide show
  1. package/.claude-plugin/plugin.json +1 -1
  2. package/agents/gsd-plan-checker.md +34 -0
  3. package/agents/gsd-planner.md +2 -0
  4. package/agents/gsd-roadmapper.md +6 -0
  5. package/bin/install.js +199 -365
  6. package/commands/gsd/capture.md +5 -1
  7. package/gemini-extension.json +1 -1
  8. package/gsd-core/bin/gsd-tools.cjs +695 -5
  9. package/gsd-core/bin/lib/adr-parser.cjs +45 -23
  10. package/gsd-core/bin/lib/audit.cjs +2 -2
  11. package/gsd-core/bin/lib/capability-consent.cjs +763 -0
  12. package/gsd-core/bin/lib/capability-ledger.cjs +831 -0
  13. package/gsd-core/bin/lib/capability-lifecycle.cjs +1551 -0
  14. package/gsd-core/bin/lib/capability-loader.cjs +764 -0
  15. package/gsd-core/bin/lib/capability-lock.cjs +553 -0
  16. package/gsd-core/bin/lib/capability-registry.cjs +198 -4
  17. package/gsd-core/bin/lib/capability-source.cjs +1242 -0
  18. package/gsd-core/bin/lib/capability-state.cjs +9 -6
  19. package/gsd-core/bin/lib/capability-trust.cjs +550 -0
  20. package/gsd-core/bin/lib/capability-validator.cjs +2066 -0
  21. package/gsd-core/bin/lib/capability-writer.cjs +14 -5
  22. package/gsd-core/bin/lib/check-command-router.cjs +69 -18
  23. package/gsd-core/bin/lib/command-aliases.cjs +8 -0
  24. package/gsd-core/bin/lib/commands.cjs +247 -0
  25. package/gsd-core/bin/lib/config-loader.cjs +98 -84
  26. package/gsd-core/bin/lib/config-schema.cjs +26 -7
  27. package/gsd-core/bin/lib/config.cjs +7 -1
  28. package/gsd-core/bin/lib/decisions.cjs +149 -60
  29. package/gsd-core/bin/lib/frontmatter.cjs +7 -3
  30. package/gsd-core/bin/lib/gap-checker.cjs +126 -11
  31. package/gsd-core/bin/lib/init.cjs +91 -22
  32. package/gsd-core/bin/lib/legacy-cleanup.cjs +96 -0
  33. package/gsd-core/bin/lib/loop-resolver.cjs +26 -2
  34. package/gsd-core/bin/lib/markdown-sectionizer.cjs +471 -0
  35. package/gsd-core/bin/lib/milestone.cjs +41 -2
  36. package/gsd-core/bin/lib/phase-command-router.cjs +5 -0
  37. package/gsd-core/bin/lib/phase-id.cjs +25 -11
  38. package/gsd-core/bin/lib/phase-lifecycle.cjs +14 -5
  39. package/gsd-core/bin/lib/phase.cjs +33 -4
  40. package/gsd-core/bin/lib/probe-core.cjs +7 -0
  41. package/gsd-core/bin/lib/prohibition-enforcement.cjs +59 -26
  42. package/gsd-core/bin/lib/project-root.cjs +89 -2
  43. package/gsd-core/bin/lib/resolution.cjs +26 -0
  44. package/gsd-core/bin/lib/roadmap-command-router.cjs +16 -3
  45. package/gsd-core/bin/lib/roadmap-parser.cjs +73 -106
  46. package/gsd-core/bin/lib/roadmap-upgrade.cjs +47 -17
  47. package/gsd-core/bin/lib/roadmap.cjs +5 -2
  48. package/gsd-core/bin/lib/runtime-artifact-conversion.cjs +423 -3
  49. package/gsd-core/bin/lib/runtime-artifact-install-plan.cjs +77 -0
  50. package/gsd-core/bin/lib/runtime-artifact-layout.cjs +1 -28
  51. package/gsd-core/bin/lib/runtime-homes.cjs +53 -1
  52. package/gsd-core/bin/lib/runtime-name-policy.cjs +44 -0
  53. package/gsd-core/bin/lib/semver-compare.cjs +127 -0
  54. package/gsd-core/bin/lib/shell-command-projection.cjs +55 -1
  55. package/gsd-core/bin/lib/state-document.cjs +4 -2
  56. package/gsd-core/bin/lib/state.cjs +317 -161
  57. package/gsd-core/bin/lib/surface.cjs +12 -19
  58. package/gsd-core/bin/lib/uat-predicate.cjs +7 -47
  59. package/gsd-core/bin/lib/uat.cjs +39 -26
  60. package/gsd-core/bin/lib/validate.cjs +5 -2
  61. package/gsd-core/bin/lib/verify.cjs +40 -15
  62. package/gsd-core/bin/lib/worktree-safety.cjs +202 -0
  63. package/gsd-core/bin/shared/config-defaults.manifest.json +6 -1
  64. package/gsd-core/bin/shared/config-schema.manifest.json +5 -1
  65. package/gsd-core/references/context-budget.md +8 -8
  66. package/gsd-core/references/execute-phase-between-wave-reset.md +43 -0
  67. package/gsd-core/references/execute-phase-context-guard.md +16 -0
  68. package/gsd-core/references/execute-phase-wave-guard.md +33 -0
  69. package/gsd-core/references/planner-antipatterns.md +48 -0
  70. package/gsd-core/references/planning-config.md +4 -0
  71. package/gsd-core/references/prohibition-probe.md +15 -9
  72. package/gsd-core/references/scout-codebase.md +2 -2
  73. package/gsd-core/workflows/autonomous.md +33 -33
  74. package/gsd-core/workflows/diagnose-issues.md +6 -1
  75. package/gsd-core/workflows/discuss-phase/templates/context.md +1 -1
  76. package/gsd-core/workflows/discuss-phase.md +1 -2
  77. package/gsd-core/workflows/execute-phase.md +12 -12
  78. package/gsd-core/workflows/help/modes/full.md +10 -0
  79. package/gsd-core/workflows/list-seeds.md +63 -0
  80. package/gsd-core/workflows/manager.md +37 -37
  81. package/gsd-core/workflows/pr-branch.md +156 -0
  82. package/gsd-core/workflows/quick.md +6 -1
  83. package/gsd-core/workflows/review.md +10 -2
  84. package/gsd-core/workflows/spec-phase.md +8 -3
  85. package/gsd-core/workflows/verify-phase.md +2 -2
  86. package/package.json +6 -3
  87. package/scripts/gen-capability-matrix.cjs +284 -0
  88. package/scripts/gen-capability-registry.cjs +96 -1853
  89. package/scripts/lint-regression-test-names.allowlist.json +1 -0
  90. package/scripts/lint-resolution-provenance.allowlist.json +1 -0
  91. package/scripts/lint-resolution-provenance.cjs +192 -0
  92. package/scripts/lint-test-file-count.allowlist.json +9 -0
  93. package/scripts/prompt-injection-scan.sh +1 -0
  94. package/scripts/run-tests.cjs +14 -0
  95. package/scripts/sync-manifest-versions.cjs +77 -5
@@ -0,0 +1,284 @@
1
+ #!/usr/bin/env node
2
+ 'use strict';
3
+
4
+ /**
5
+ * gen-capability-matrix.cjs — ADR-1244 Phase 6 (Decision D9).
6
+ *
7
+ * Generates docs/reference/capability-matrix.md FROM the committed capability
8
+ * registry (gsd-core/bin/lib/capability-registry.cjs), so the matrix can never
9
+ * drift from the actual capability set. Kept honest by a drift guard
10
+ * (tests/capability-matrix-sync.test.cjs runs `--check`).
11
+ *
12
+ * The matrix is RELEASE-STABLE by design: it does NOT embed each capability's
13
+ * exact `version` (which tracks the GSD package version in lockstep and would
14
+ * churn the committed file — and trip the drift guard — on every release). It
15
+ * shows `engines.gsd` (the stable host-compatibility RANGE) instead, and notes
16
+ * the version-lockstep rule in prose. The committed matrix therefore changes
17
+ * only on intentional capability edits (add/remove a capability, change its
18
+ * tier/role/engines/extension-points/hook-kinds) — never on a version bump.
19
+ *
20
+ * Usage:
21
+ * node scripts/gen-capability-matrix.cjs # print to stdout
22
+ * node scripts/gen-capability-matrix.cjs --write # write the committed file
23
+ * node scripts/gen-capability-matrix.cjs --check # exit 1 if the committed file is stale
24
+ */
25
+
26
+ const fs = require('fs');
27
+ const path = require('path');
28
+ const { ExitError, runMain } = require('./lib/cli-exit.cjs');
29
+
30
+ const ROOT = path.resolve(__dirname, '..');
31
+ const REGISTRY_PATH = path.join(ROOT, 'gsd-core', 'bin', 'lib', 'capability-registry.cjs');
32
+ const MATRIX_PATH = path.join(ROOT, 'docs', 'reference', 'capability-matrix.md');
33
+
34
+ /** Canonical loop extension points, in order (mirrors the phase loop). */
35
+ const LOOP_POINTS = [
36
+ 'discuss:pre', 'discuss:post',
37
+ 'plan:pre', 'plan:post',
38
+ 'execute:pre', 'execute:wave:pre', 'execute:wave:post', 'execute:post',
39
+ 'verify:pre', 'verify:post',
40
+ 'ship:pre', 'ship:post',
41
+ ];
42
+ const POINT_ORDER = new Map(LOOP_POINTS.map((p, i) => [p, i]));
43
+
44
+ /**
45
+ * Build a capId → { points:Set, kinds:Set } map from the registry's byLoopPoint
46
+ * index — the authoritative record of which loop points each capability registers
47
+ * into and with which hook kind (step / contribution / gate).
48
+ */
49
+ function extensionsByCapability(registry) {
50
+ const out = new Map();
51
+ const byPoint = registry.byLoopPoint || {};
52
+ const KIND = { steps: 'step', contributions: 'contribution', gates: 'gate' };
53
+ for (const point of Object.keys(byPoint)) {
54
+ const reg = byPoint[point] || {};
55
+ for (const arrKey of ['steps', 'contributions', 'gates']) {
56
+ for (const hook of reg[arrKey] || []) {
57
+ const capId = hook && hook.capId;
58
+ if (typeof capId !== 'string') continue;
59
+ let e = out.get(capId);
60
+ if (!e) { e = { points: new Set(), kinds: new Set() }; out.set(capId, e); }
61
+ e.points.add(point);
62
+ e.kinds.add(KIND[arrKey]);
63
+ }
64
+ }
65
+ }
66
+ return out;
67
+ }
68
+
69
+ function fmtPoints(set) {
70
+ if (!set || set.size === 0) return '—';
71
+ for (const p of set) {
72
+ // Surface a typo'd/unknown loop point at generation time rather than silently sorting it last.
73
+ // The registry validates point names at load, so this should never fire — but if it does, the
74
+ // generator (not a confused reader) is where it must be caught.
75
+ if (!POINT_ORDER.has(p)) {
76
+ process.stderr.write(`gen-capability-matrix: WARNING — unknown loop point "${p}" (not one of the ${LOOP_POINTS.length} canonical points)\n`);
77
+ }
78
+ }
79
+ return [...set]
80
+ .sort((a, b) => (POINT_ORDER.has(a) ? POINT_ORDER.get(a) : 99) - (POINT_ORDER.has(b) ? POINT_ORDER.get(b) : 99) || a.localeCompare(b))
81
+ .map((p) => '`' + p + '`')
82
+ .join(', ');
83
+ }
84
+
85
+ function fmtKinds(set) {
86
+ if (!set || set.size === 0) return '—';
87
+ const order = { step: 0, contribution: 1, gate: 2 };
88
+ return [...set].sort((a, b) => (order[a] ?? 9) - (order[b] ?? 9)).join(', ');
89
+ }
90
+
91
+ function fmtEngines(cap) {
92
+ const g = cap && cap.engines && cap.engines.gsd;
93
+ return typeof g === 'string' && g ? '`' + g + '`' : '—';
94
+ }
95
+
96
+ /** Render one capability table (rows sorted by id) for the given role. */
97
+ function renderTable(caps, role, extByCap) {
98
+ const rows = caps
99
+ .filter((c) => c.role === role)
100
+ .sort((a, b) => a.id.localeCompare(b.id))
101
+ .map((c) => {
102
+ const ext = extByCap.get(c.id) || { points: null, kinds: null };
103
+ return `| \`${c.id}\` | ${c.role} | ${c.tier || '—'} | ${fmtEngines(c)} | ${fmtPoints(ext.points)} | ${fmtKinds(ext.kinds)} | first-party |`;
104
+ });
105
+ return [
106
+ '| id | role | tier | engines.gsd | extension points | hook kinds | source |',
107
+ '|---|---|---|---|---|---|---|',
108
+ ...rows,
109
+ ].join('\n');
110
+ }
111
+
112
+ function buildMatrix(registry) {
113
+ const caps = Object.values(registry.capabilities || {});
114
+ const extByCap = extensionsByCapability(registry);
115
+ const featureTable = renderTable(caps, 'feature', extByCap);
116
+ const runtimeTable = renderTable(caps, 'runtime', extByCap);
117
+ const featureCount = caps.filter((c) => c.role === 'feature').length;
118
+ const runtimeCount = caps.filter((c) => c.role === 'runtime').length;
119
+
120
+ return `# Capability matrix reference
121
+
122
+ > **Generated file — do not edit by hand.**
123
+ > This matrix is generated from the capability registry by
124
+ > \`scripts/gen-capability-matrix.cjs\` and kept honest by a drift guard
125
+ > (\`tests/capability-matrix-sync.test.cjs\` runs \`--check\`). Any manual edit is
126
+ > overwritten on the next generation run. To change a capability's declared
127
+ > metadata, edit the corresponding \`capabilities/<id>/capability.json\` and run
128
+ > \`node scripts/gen-capability-matrix.cjs --write\`.
129
+
130
+ See also: [ADR-1244](../adr/1244-capability-ecosystem.md) —
131
+ [Capability manifest fields](#manifest-field-reference) —
132
+ [The capability trust model](../explanation/capability-trust-model.md)
133
+
134
+ ---
135
+
136
+ ## Column definitions
137
+
138
+ | Column | Description |
139
+ |---|---|
140
+ | **id** | Canonical capability identifier; unique across first- and third-party capabilities. Reserved prefixes: \`gsd-\`, \`gsd-core-\`, \`anthropic-\`. |
141
+ | **role** | \`feature\` — extends what the loop does; \`runtime\` — adapts GSD to a specific AI runtime/IDE. |
142
+ | **tier** | \`core\` — always active; \`standard\` — active when the runtime supports it; \`full\` — opt-in or runtime-specific. |
143
+ | **engines.gsd** | Semver RANGE expressing host-version compatibility. A hard gate at install and at load. \`—\` means the capability declares no range. |
144
+ | **extension points** | The loop points this capability registers hooks into (from the registry's \`byLoopPoint\` index). \`—\` means it registers none (typical for runtime capabilities, whose job is surface emission). |
145
+ | **hook kinds** | Which of \`step\`, \`contribution\`, \`gate\` the capability's hooks use. \`—\` means none. |
146
+ | **source** | \`first-party\` — ships with GSD Core; \`third-party\` — installed from an external source via \`gsd capability install\`. |
147
+
148
+ > **On versions.** This matrix intentionally omits a per-capability \`version\`
149
+ > column. First-party capabilities are versioned **in lockstep** with the GSD
150
+ > Core package (their \`capability.json\` \`version\` always equals the GSD release
151
+ > version), so a per-row version would simply repeat the package version and
152
+ > churn the committed file on every release. The stable host-compatibility
153
+ > signal — \`engines.gsd\` — is shown instead. A third-party capability's exact
154
+ > version is recorded in the per-runtime ledger (\`.gsd-capabilities.json\`) at
155
+ > install time.
156
+
157
+ ---
158
+
159
+ ## Native (first-party) capabilities
160
+
161
+ First-party capabilities are implicitly trusted: they ship as part of the GSD
162
+ Core package and are stamped with the package version at release (per
163
+ ADR-1244 D6). They are not subject to the consent or integrity-pin flow applied
164
+ to third-party capabilities.
165
+
166
+ ### Feature capabilities (role: feature) — ${featureCount}
167
+
168
+ Feature capabilities extend what the loop does — contributing research,
169
+ planning, execution, verification, or ship artefacts at the loop extension
170
+ points.
171
+
172
+ ${featureTable}
173
+
174
+ ### Runtime capabilities (role: runtime) — ${runtimeCount}
175
+
176
+ Runtime capabilities adapt GSD to a specific AI runtime or IDE — emitting
177
+ skills, agents, hooks configuration, and surface files for that host. They
178
+ typically register no loop hooks (their primary responsibility is surface
179
+ emission), so their extension-point and hook-kind cells are \`—\`.
180
+
181
+ ${runtimeTable}
182
+
183
+ ---
184
+
185
+ ## Third-party capabilities
186
+
187
+ This matrix is the **first-party catalogue**: it is generated from the committed
188
+ registry and therefore lists only the capabilities that ship with GSD Core.
189
+ Installed third-party capabilities are NOT written into this committed file. Once a
190
+ user installs one via \`gsd capability install <spec>\` it enters the **runtime
191
+ registry overlay** (ADR-1244 D2); the overlay-aware view of what is installed on a
192
+ given machine is \`gsd capability list\` (see the
193
+ [\`gsd capability\` command reference](gsd-capability-command.md)), which reports
194
+ first-party and installed third-party capabilities together using the same column
195
+ fields described below, with \`source\` = \`third-party\`.
196
+
197
+ ### Column values for third-party rows
198
+
199
+ | Column | Value |
200
+ |---|---|
201
+ | **id** | As declared in \`capability.json\`. Must not use reserved prefixes (\`gsd-\`, \`gsd-core-\`, \`anthropic-\`). |
202
+ | **role** | \`feature\` or \`runtime\`, as declared. |
203
+ | **tier** | \`core\`, \`standard\`, or \`full\`, as declared. |
204
+ | **engines.gsd** | Range from \`capability.json\`; verified at install and at each load. |
205
+ | **extension points** | The loop points the capability registers into, validated against the known 12 identifiers. |
206
+ | **hook kinds** | \`step\`, \`contribution\`, and/or \`gate\` as declared. Disclosed in the consent summary at install. |
207
+ | **source** | \`third-party\` |
208
+
209
+ ### Community registry
210
+
211
+ Whether GSD operates or advertises a central community registry of third-party
212
+ capabilities is **TBD/TBA** (PRD). The matrix mechanic and all manifest fields
213
+ ship regardless of that decision; URL/git/npm/tarball import does not depend on
214
+ a central registry.
215
+
216
+ ---
217
+
218
+ ## Manifest field reference
219
+
220
+ The fields below are defined in \`capability.json\` and govern how a capability
221
+ appears in this matrix. For the full schema, see
222
+ [ADR-1244 D1](../adr/1244-capability-ecosystem.md#d1--versioned-capability-manifest)
223
+ and the [capability manifest reference](capability-manifest.md).
224
+
225
+ | Field | Required | Type | Purpose |
226
+ |---|---|---|---|
227
+ | \`version\` | **Yes** | semver string | Capability version. The registry rejects manifests without it. |
228
+ | \`engines.gsd\` | Recommended | semver range | Host-version compatibility gate. Enforced at install and load. |
229
+ | \`compatVersions\` | No | object: cap-version → gsd-range | Graceful-downgrade table for sources that enumerate versions (git tags, registry, npm). |
230
+ | \`integrity\` | No | \`sha512-<base64>\` | SHA-512 digest of the fetched bundle. Verified before extraction when present; mismatch aborts. |
231
+ | \`provenance\` | No | \`{ sourceRepo, commit }\` | Source provenance; populated in CI for first-party/curated capabilities. |
232
+
233
+ ---
234
+
235
+ ## Related documents
236
+
237
+ - [ADR-1244 — Capability Ecosystem](../adr/1244-capability-ecosystem.md)
238
+ - [The capability trust model](../explanation/capability-trust-model.md) — why the trust rules are structured as they are
239
+ - [The phase loop](../explanation/the-phase-loop.md) — the 12 loop extension points in context
240
+ - [Capability manifest reference](capability-manifest.md) — the full \`capability.json\` schema
241
+ - [ADR-857](../adr/857-capability-system.md) — the original capability architecture (D7/D8 extended by ADR-1244)
242
+ `;
243
+ }
244
+
245
+ function loadRegistry() {
246
+ delete require.cache[require.resolve(REGISTRY_PATH)];
247
+ return require(REGISTRY_PATH);
248
+ }
249
+
250
+ /** Normalize CRLF→LF + ensure a single trailing newline, for cross-platform compare. */
251
+ function normalize(s) {
252
+ return s.replace(/\r\n/g, '\n').replace(/\n+$/, '\n');
253
+ }
254
+
255
+ function main() {
256
+ const flag = process.argv[2];
257
+ const registry = loadRegistry();
258
+ const content = buildMatrix(registry);
259
+
260
+ if (flag === '--check') {
261
+ let committed;
262
+ try {
263
+ committed = fs.readFileSync(MATRIX_PATH, 'utf8');
264
+ } catch {
265
+ throw new ExitError(1, `${path.relative(ROOT, MATRIX_PATH)} is missing. Run:\n node scripts/gen-capability-matrix.cjs --write`);
266
+ }
267
+ if (normalize(committed) !== normalize(content)) {
268
+ throw new ExitError(1, `${path.relative(ROOT, MATRIX_PATH)} is stale. Run:\n node scripts/gen-capability-matrix.cjs --write`);
269
+ }
270
+ console.log(`${path.relative(ROOT, MATRIX_PATH)} is up to date.`);
271
+ return;
272
+ }
273
+ if (flag === '--write') {
274
+ fs.mkdirSync(path.dirname(MATRIX_PATH), { recursive: true });
275
+ fs.writeFileSync(MATRIX_PATH, content, 'utf8');
276
+ console.log(`Wrote ${path.relative(ROOT, MATRIX_PATH)}`);
277
+ return;
278
+ }
279
+ process.stdout.write(content);
280
+ }
281
+
282
+ if (require.main === module) runMain(main);
283
+
284
+ module.exports = { buildMatrix, extensionsByCapability };