@opengsd/gsd-core 1.7.0-rc.6 → 1.8.0
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.
- package/.claude-plugin/marketplace.json +1 -1
- package/.claude-plugin/plugin.json +1 -1
- package/.opencode/plugins/gsd-core.js +14 -0
- package/README.md +2 -0
- package/agents/gsd-debug-session-manager.md +42 -4
- package/agents/gsd-debugger.md +87 -29
- package/agents/gsd-executor.md +31 -3
- package/agents/gsd-planner.md +29 -36
- package/agents/gsd-security-auditor.md +13 -15
- package/agents/gsd-verifier.md +2 -2
- package/bin/install.js +1157 -84
- package/commands/gsd/ai-integration-phase.md +1 -1
- package/commands/gsd/mempalace-capture.md +31 -1
- package/commands/gsd/new-milestone.md +1 -1
- package/commands/gsd/plan-phase.md +5 -3
- package/commands/gsd/plan-review-convergence.md +3 -2
- package/commands/gsd/surface.md +6 -6
- package/gsd-core/bin/gsd-tools.cjs +1866 -2434
- package/gsd-core/bin/lib/adapter-imperative.cjs +8 -1
- package/gsd-core/bin/lib/agent-command-router.cjs +20 -5
- package/gsd-core/bin/lib/api-coverage.cjs +341 -49
- package/gsd-core/bin/lib/audit.cjs +7 -6
- package/gsd-core/bin/lib/broken-windows.cjs +716 -0
- package/gsd-core/bin/lib/capability-command-router.cjs +733 -0
- package/gsd-core/bin/lib/capability-registry.cjs +157 -88
- package/gsd-core/bin/lib/capability-writer.cjs +6 -1
- package/gsd-core/bin/lib/check-command-router.cjs +129 -26
- package/gsd-core/bin/lib/claude-orchestration-command-router.cjs +115 -27
- package/gsd-core/bin/lib/claude-orchestration.cjs +84 -9
- package/gsd-core/bin/lib/clock.cjs +19 -0
- package/gsd-core/bin/lib/command-aliases.cjs +14 -0
- package/gsd-core/bin/lib/commands.cjs +129 -13
- package/gsd-core/bin/lib/config-loader.cjs +20 -4
- package/gsd-core/bin/lib/config.cjs +81 -18
- package/gsd-core/bin/lib/core-utils.cjs +14 -3
- package/gsd-core/bin/lib/decisions.cjs +32 -8
- package/gsd-core/bin/lib/docs.cjs +6 -0
- package/gsd-core/bin/lib/drift.cjs +4 -4
- package/gsd-core/bin/lib/external-descriptor-trust.cjs +14 -2
- package/gsd-core/bin/lib/frontmatter.cjs +22 -0
- package/gsd-core/bin/lib/gap-checker.cjs +17 -2
- package/gsd-core/bin/lib/gsd2-import.cjs +2 -1
- package/gsd-core/bin/lib/init.cjs +138 -60
- package/gsd-core/bin/lib/install-engine.cjs +301 -25
- package/gsd-core/bin/lib/install-profiles.cjs +239 -1
- package/gsd-core/bin/lib/installer-migration-authoring.cjs +2 -1
- package/gsd-core/bin/lib/installer-migrations/005-opencode-baseline-commands-dir.cjs +146 -0
- package/gsd-core/bin/lib/installer-migrations/006-pi-extension-cjs-to-js.cjs +91 -0
- package/gsd-core/bin/lib/installer-migrations.cjs +45 -6
- package/gsd-core/bin/lib/markdown-sectionizer.cjs +449 -0
- package/gsd-core/bin/lib/markdown-table.cjs +698 -0
- package/gsd-core/bin/lib/milestone.cjs +463 -43
- package/gsd-core/bin/lib/model-catalog.cjs +19 -4
- package/gsd-core/bin/lib/model-resolver.cjs +189 -7
- package/gsd-core/bin/lib/onboard-projection.cjs +11 -8
- package/gsd-core/bin/lib/phase-command-router.cjs +50 -2
- package/gsd-core/bin/lib/phase-id.cjs +26 -4
- package/gsd-core/bin/lib/phase-lifecycle.cjs +62 -36
- package/gsd-core/bin/lib/phase-locator.cjs +23 -2
- package/gsd-core/bin/lib/phase.cjs +636 -72
- package/gsd-core/bin/lib/plan-scan.cjs +73 -2
- package/gsd-core/bin/lib/roadmap-parser.cjs +225 -17
- package/gsd-core/bin/lib/roadmap.cjs +113 -52
- package/gsd-core/bin/lib/runtime-artifact-conversion.cjs +14 -7
- package/gsd-core/bin/lib/runtime-artifact-install-plan.cjs +3 -2
- package/gsd-core/bin/lib/runtime-artifact-layout.cjs +24 -9
- package/gsd-core/bin/lib/runtime-hooks-surface.cjs +41 -17
- package/gsd-core/bin/lib/schema-detect.cjs +2 -1
- package/gsd-core/bin/lib/security.cjs +1 -1
- package/gsd-core/bin/lib/shell-command-projection.cjs +61 -25
- package/gsd-core/bin/lib/smart-entry.cjs +73 -7
- package/gsd-core/bin/lib/state-document.cjs +7 -4
- package/gsd-core/bin/lib/state-transition.cjs +122 -46
- package/gsd-core/bin/lib/state.cjs +456 -137
- package/gsd-core/bin/lib/surface.cjs +53 -11
- package/gsd-core/bin/lib/template.cjs +2 -1
- package/gsd-core/bin/lib/uat.cjs +474 -13
- package/gsd-core/bin/lib/ui-safety-gate.cjs +23 -1
- package/gsd-core/bin/lib/validate.cjs +12 -8
- package/gsd-core/bin/lib/verification.cjs +112 -17
- package/gsd-core/bin/lib/verify.cjs +224 -25
- package/gsd-core/bin/lib/workstream.cjs +3 -2
- package/gsd-core/bin/lib/worktree-safety.cjs +1 -1
- package/gsd-core/bin/lib/write-set.cjs +38 -0
- package/gsd-core/bin/shared/config-schema.manifest.json +5 -2
- package/gsd-core/references/api-coverage.md +37 -7
- package/gsd-core/references/checkpoints.md +13 -1
- package/gsd-core/references/common-bug-patterns.md +13 -0
- package/gsd-core/references/debugger-bug-taxonomy.md +111 -0
- package/gsd-core/references/debugger-fix-acceptance.md +157 -0
- package/gsd-core/references/debugger-philosophy.md +1 -0
- package/gsd-core/references/debugger-prevention.md +98 -0
- package/gsd-core/references/debugger-rca-branching.md +98 -0
- package/gsd-core/references/debugger-repro-hardening.md +130 -0
- package/gsd-core/references/debugger-sbfl.md +110 -0
- package/gsd-core/references/debugger-semantic-recall.md +81 -0
- package/gsd-core/references/execute-phase-quota-recovery.md +55 -0
- package/gsd-core/references/execute-phase-requirement-revert.md +8 -0
- package/gsd-core/references/execute-phase-response-language.md +7 -0
- package/gsd-core/references/planner-antipatterns.md +6 -0
- package/gsd-core/references/planner-mvp-mode.md +12 -13
- package/gsd-core/references/planner-preconditions.md +156 -0
- package/gsd-core/references/planner-reversibility.md +132 -0
- package/gsd-core/references/reviewer-instances.md +9 -7
- package/gsd-core/references/skeleton-template.md +1 -1
- package/gsd-core/references/thinking-models-planning.md +3 -1
- package/gsd-core/templates/DEBUG.md +5 -3
- package/gsd-core/workflows/add-phase.md +2 -0
- package/gsd-core/workflows/add-tests.md +4 -2
- package/gsd-core/workflows/add-todo.md +32 -1
- package/gsd-core/workflows/ai-integration-phase.md +4 -2
- package/gsd-core/workflows/audit-fix.md +2 -2
- package/gsd-core/workflows/check-todos.md +3 -1
- package/gsd-core/workflows/cleanup.md +7 -1
- package/gsd-core/workflows/code-review.md +17 -5
- package/gsd-core/workflows/complete-milestone.md +3 -0
- package/gsd-core/workflows/debug.md +27 -5
- package/gsd-core/workflows/diagnose-issues.md +1 -1
- package/gsd-core/workflows/discovery-phase.md +7 -0
- package/gsd-core/workflows/discuss-phase/templates/context.md +16 -2
- package/gsd-core/workflows/discuss-phase-assumptions.md +3 -0
- package/gsd-core/workflows/do.md +7 -1
- package/gsd-core/workflows/docs-update.md +1 -0
- package/gsd-core/workflows/eval-review.md +3 -0
- package/gsd-core/workflows/execute-phase/steps/post-merge-gate.md +4 -4
- package/gsd-core/workflows/execute-phase/steps/regression-gate.md +2 -2
- package/gsd-core/workflows/execute-phase.md +30 -37
- package/gsd-core/workflows/execute-plan.md +15 -4
- package/gsd-core/workflows/fast.md +8 -22
- package/gsd-core/workflows/graduation.md +3 -0
- package/gsd-core/workflows/health.md +7 -1
- package/gsd-core/workflows/help/modes/full.md +6 -2
- package/gsd-core/workflows/import.md +8 -2
- package/gsd-core/workflows/inbox.md +7 -0
- package/gsd-core/workflows/ingest-docs.md +15 -10
- package/gsd-core/workflows/manager.md +3 -1
- package/gsd-core/workflows/map-codebase.md +4 -4
- package/gsd-core/workflows/mvp-phase.md +3 -0
- package/gsd-core/workflows/new-milestone.md +69 -21
- package/gsd-core/workflows/new-project.md +17 -15
- package/gsd-core/workflows/new-workspace.md +3 -1
- package/gsd-core/workflows/onboard.md +3 -0
- package/gsd-core/workflows/plan-phase.md +14 -5
- package/gsd-core/workflows/plan-review-convergence.md +48 -3
- package/gsd-core/workflows/plant-seed.md +3 -0
- package/gsd-core/workflows/profile-user.md +7 -1
- package/gsd-core/workflows/progress.md +33 -5
- package/gsd-core/workflows/quick.md +21 -7
- package/gsd-core/workflows/remove-workspace.md +3 -0
- package/gsd-core/workflows/review.md +123 -68
- package/gsd-core/workflows/scan.md +1 -1
- package/gsd-core/workflows/secure-phase.md +4 -1
- package/gsd-core/workflows/settings-integrations.md +3 -0
- package/gsd-core/workflows/settings.md +3 -0
- package/gsd-core/workflows/ship.md +58 -5
- package/gsd-core/workflows/sketch.md +3 -0
- package/gsd-core/workflows/smart-entry.md +3 -0
- package/gsd-core/workflows/spec-phase.md +1 -1
- package/gsd-core/workflows/spike.md +7 -1
- package/gsd-core/workflows/transition.md +1 -1
- package/gsd-core/workflows/ui-phase.md +3 -1
- package/gsd-core/workflows/ui-review.md +3 -0
- package/gsd-core/workflows/undo.md +7 -0
- package/gsd-core/workflows/update.md +2 -0
- package/gsd-core/workflows/validate-phase.md +3 -0
- package/gsd-core/workflows/verify-phase.md +2 -2
- package/gsd-core/workflows/verify-work.md +7 -3
- package/hooks/dist/gsd-context-monitor.js +27 -9
- package/hooks/dist/gsd-statusline.js +252 -17
- package/hooks/gsd-context-monitor.js +27 -9
- package/hooks/gsd-statusline.js +252 -17
- package/package.json +8 -4
- package/pi/gsd.cjs +8 -2
- package/scripts/changeset/lint.cjs +1 -0
- package/scripts/changeset/parse.cjs +26 -0
- package/scripts/check-glossary-refs.cjs +220 -0
- package/scripts/ci-rebase-check.cjs +48 -4
- package/scripts/ci-test-scope.cjs +39 -1
- package/scripts/gen-adr-index.cjs +526 -0
- package/scripts/gen-golden-install-parity-zcode.cjs +35 -45
- package/scripts/gen-install-tree-fixtures.cjs +75 -0
- package/scripts/gen-test-timings.cjs +201 -0
- package/scripts/lint-allow-test-rule-refs.allowlist.json +0 -1
- package/scripts/lint-portable-timeout.cjs +140 -0
- package/scripts/lint-table-schema-drift.cjs +157 -0
- package/scripts/lint-test-file-count.allowlist.json +1 -0
- package/scripts/release-tarball-smoke.cjs +18 -11
- package/scripts/run-tests.cjs +420 -58
- package/skills/gsd-ai-integration-phase/SKILL.md +1 -1
- package/skills/gsd-mempalace-capture/SKILL.md +31 -1
- package/skills/gsd-new-milestone/SKILL.md +1 -1
- package/skills/gsd-plan-phase/SKILL.md +5 -3
- package/skills/gsd-plan-review-convergence/SKILL.md +3 -2
- package/skills/gsd-surface/SKILL.md +6 -6
- package/vscode/package.json +1 -1
|
@@ -0,0 +1,220 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Verifies the machine-checkable claims in CONTEXT.md against the shipped
|
|
6
|
+
* tree, so the glossary cannot silently re-rot the way the ADR index did
|
|
7
|
+
* before scripts/gen-adr-index.cjs (#2340).
|
|
8
|
+
*
|
|
9
|
+
* Unlike gen-adr-index.cjs this gate has NO `--write` — CONTEXT.md's prose is
|
|
10
|
+
* hand-authored, not a derived artifact this tool can regenerate. It only
|
|
11
|
+
* verifies.
|
|
12
|
+
*
|
|
13
|
+
* Two checks:
|
|
14
|
+
*
|
|
15
|
+
* A. File references resolve. Every backticked token in CONTEXT.md that
|
|
16
|
+
* looks like a file path — and whose path is inside a TRACKED_PREFIXES
|
|
17
|
+
* directory (or is one of the two named exact files) — must exist on
|
|
18
|
+
* disk. Everything else (generated bin/lib/*.cjs, `.planning/` runtime
|
|
19
|
+
* artifacts, `~/`- or `/`-rooted paths, bare filenames, example data
|
|
20
|
+
* shapes like `capability.json`) is deliberately ignored: asserting
|
|
21
|
+
* those would false-fail a clean checkout, which is the exact trap this
|
|
22
|
+
* gate exists to avoid falling into itself.
|
|
23
|
+
*
|
|
24
|
+
* B. `allRuntimes` enum parity. CONTEXT.md documents the runtime enum's
|
|
25
|
+
* count and member list in prose (e.g. "Runtime enum: `allRuntimes` (17
|
|
26
|
+
* values: claude, ...)"). This is compared against the real
|
|
27
|
+
* `allRuntimes` array literal in bin/install.js — both the count and the
|
|
28
|
+
* member set — so adding/removing a runtime without updating the prose
|
|
29
|
+
* is caught.
|
|
30
|
+
*
|
|
31
|
+
* Usage:
|
|
32
|
+
* node scripts/check-glossary-refs.cjs # print findings to stdout
|
|
33
|
+
* node scripts/check-glossary-refs.cjs --check # exit 1 on any finding
|
|
34
|
+
*/
|
|
35
|
+
|
|
36
|
+
const fs = require('node:fs');
|
|
37
|
+
const path = require('node:path');
|
|
38
|
+
|
|
39
|
+
const { ExitError, runMain } = require('./lib/cli-exit.cjs');
|
|
40
|
+
|
|
41
|
+
const ROOT = path.resolve(__dirname, '..');
|
|
42
|
+
const CONTEXT_PATH = path.join(ROOT, 'CONTEXT.md');
|
|
43
|
+
const INSTALL_JS_PATH = path.join(ROOT, 'bin', 'install.js');
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Directory prefixes this gate can verify against the shipped tree. A token
|
|
47
|
+
* outside these — most importantly `gsd-core/bin/lib/**`, which is generated
|
|
48
|
+
* and gitignored — is not a claim this gate can check, so it is skipped
|
|
49
|
+
* rather than asserted.
|
|
50
|
+
*/
|
|
51
|
+
const TRACKED_PREFIXES = [
|
|
52
|
+
'src/',
|
|
53
|
+
'tests/',
|
|
54
|
+
'scripts/',
|
|
55
|
+
'docs/',
|
|
56
|
+
'gsd-core/references/',
|
|
57
|
+
'gsd-core/workflows/',
|
|
58
|
+
'gsd-core/templates/',
|
|
59
|
+
'gsd-core/contexts/',
|
|
60
|
+
'.github/',
|
|
61
|
+
'eslint-rules/',
|
|
62
|
+
];
|
|
63
|
+
|
|
64
|
+
/** The only bare (no-prefix-match) tokens this gate checks by exact name. */
|
|
65
|
+
const TRACKED_EXACT = new Set(['bin/install.js', 'package.json']);
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Shape a backticked token must have to even be considered a path candidate:
|
|
69
|
+
* one or more `/`-separated segments of word/dot/dash characters, with an
|
|
70
|
+
* optional trailing `:<line>` suffix. Anything else inside backticks (CLI
|
|
71
|
+
* invocations with spaces, function signatures with parens/commas, bare
|
|
72
|
+
* identifiers, env vars) is prose, not a path reference.
|
|
73
|
+
*/
|
|
74
|
+
const PATH_TOKEN_RE = /^[\w.-]+(?:\/[\w.-]+)*(?::\d+)?$/;
|
|
75
|
+
|
|
76
|
+
/** Whether `token` (line-suffix already stripped) is one this gate checks. */
|
|
77
|
+
function isTracked(token) {
|
|
78
|
+
return TRACKED_EXACT.has(token) || TRACKED_PREFIXES.some((prefix) => token.startsWith(prefix));
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* True if joining `token` to ROOT stays inside ROOT. `PATH_TOKEN_RE` admits `.`
|
|
83
|
+
* inside a segment, so a token like `src/../../../etc/passwd` matches and (via
|
|
84
|
+
* the `src/` prefix) reads as "tracked" — `path.join(ROOT, token)` would then
|
|
85
|
+
* normalize to an out-of-tree absolute path and `fs.existsSync` would probe it,
|
|
86
|
+
* turning a doc lint into a filesystem-existence oracle on the CI host. A
|
|
87
|
+
* CONTEXT.md reference is always a plain in-repo path, so a `..` escape is never
|
|
88
|
+
* legitimate: confine to ROOT and drop anything that climbs out.
|
|
89
|
+
*/
|
|
90
|
+
function isWithinRoot(token) {
|
|
91
|
+
const resolved = path.resolve(ROOT, token);
|
|
92
|
+
return resolved === ROOT || resolved.startsWith(ROOT + path.sep);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* Every distinct, trackable file-path token referenced in `text`, with any
|
|
97
|
+
* trailing `:<line>` suffix stripped.
|
|
98
|
+
*/
|
|
99
|
+
function extractTrackedRefs(text) {
|
|
100
|
+
const tokens = new Set();
|
|
101
|
+
const re = /`([^`]+)`/g;
|
|
102
|
+
let m;
|
|
103
|
+
while ((m = re.exec(text)) !== null) {
|
|
104
|
+
const raw = m[1];
|
|
105
|
+
if (!PATH_TOKEN_RE.test(raw)) continue;
|
|
106
|
+
const token = raw.replace(/:\d+$/, '');
|
|
107
|
+
if (!isTracked(token)) continue;
|
|
108
|
+
if (!isWithinRoot(token)) continue;
|
|
109
|
+
tokens.add(token);
|
|
110
|
+
}
|
|
111
|
+
return tokens;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
/** Check A: every tracked reference must resolve on disk. */
|
|
115
|
+
function checkFileRefs(contextText) {
|
|
116
|
+
const tokens = [...extractTrackedRefs(contextText)].sort();
|
|
117
|
+
const findings = [];
|
|
118
|
+
for (const token of tokens) {
|
|
119
|
+
if (!fs.existsSync(path.join(ROOT, token))) {
|
|
120
|
+
findings.push(`CONTEXT.md references \`${token}\` which does not exist in the repo.`);
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
return { findings, checked: tokens.length };
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
/** The glossary's own claim: `Runtime enum: `allRuntimes` (N values: a, b, c)`. */
|
|
127
|
+
const ALLRUNTIMES_CLAIM_RE = /Runtime enum:\s*`allRuntimes`\s*\((\d+)\s*values:\s*([^)]*)\)/;
|
|
128
|
+
|
|
129
|
+
function parseClaimedRuntimes(contextText) {
|
|
130
|
+
const m = contextText.match(ALLRUNTIMES_CLAIM_RE);
|
|
131
|
+
if (!m) return null;
|
|
132
|
+
return {
|
|
133
|
+
count: Number(m[1]),
|
|
134
|
+
members: m[2]
|
|
135
|
+
.split(',')
|
|
136
|
+
.map((s) => s.trim())
|
|
137
|
+
.filter(Boolean),
|
|
138
|
+
};
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
/** The real `allRuntimes = [...]` array literal in bin/install.js. */
|
|
142
|
+
const ALLRUNTIMES_ARRAY_RE = /allRuntimes\s*=\s*\[([^\]]*)\]/;
|
|
143
|
+
|
|
144
|
+
function parseRealRuntimes(installJsText) {
|
|
145
|
+
const m = installJsText.match(ALLRUNTIMES_ARRAY_RE);
|
|
146
|
+
if (!m) return null;
|
|
147
|
+
return [...m[1].matchAll(/'([^']+)'/g)].map((mm) => mm[1]);
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
/** Check B: CONTEXT.md's prose count + member set must match bin/install.js. */
|
|
151
|
+
function checkAllRuntimesParity(contextText, installJsText) {
|
|
152
|
+
const claimed = parseClaimedRuntimes(contextText);
|
|
153
|
+
if (!claimed) {
|
|
154
|
+
return [
|
|
155
|
+
'CONTEXT.md is missing the `allRuntimes` enum-count sentence ' +
|
|
156
|
+
'("Runtime enum: `allRuntimes` (N values: ...)") that this gate checks against bin/install.js.',
|
|
157
|
+
];
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
const real = parseRealRuntimes(installJsText);
|
|
161
|
+
if (!real) {
|
|
162
|
+
return ['bin/install.js does not contain a parseable `allRuntimes = [...]` array literal.'];
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
const findings = [];
|
|
166
|
+
if (claimed.count !== real.length) {
|
|
167
|
+
findings.push(
|
|
168
|
+
`CONTEXT.md's allRuntimes enum-count sentence claims ${claimed.count} values but bin/install.js's ` +
|
|
169
|
+
`allRuntimes array has ${real.length}.`,
|
|
170
|
+
);
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
const claimedSet = new Set(claimed.members);
|
|
174
|
+
const realSet = new Set(real);
|
|
175
|
+
const missingFromProse = real.filter((r) => !claimedSet.has(r)).sort();
|
|
176
|
+
const noLongerReal = claimed.members.filter((c) => !realSet.has(c)).sort();
|
|
177
|
+
if (missingFromProse.length > 0 || noLongerReal.length > 0) {
|
|
178
|
+
const parts = [];
|
|
179
|
+
if (missingFromProse.length > 0) parts.push(`missing from CONTEXT.md's list: ${missingFromProse.join(', ')}`);
|
|
180
|
+
if (noLongerReal.length > 0) parts.push(`no longer in bin/install.js's allRuntimes: ${noLongerReal.join(', ')}`);
|
|
181
|
+
findings.push(`CONTEXT.md's allRuntimes member list has drifted from bin/install.js (${parts.join('; ')}).`);
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
return findings;
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
function main() {
|
|
188
|
+
const [, , flag] = process.argv;
|
|
189
|
+
|
|
190
|
+
const contextText = fs.readFileSync(CONTEXT_PATH, 'utf8');
|
|
191
|
+
const installJsText = fs.readFileSync(INSTALL_JS_PATH, 'utf8');
|
|
192
|
+
|
|
193
|
+
const fileRefs = checkFileRefs(contextText);
|
|
194
|
+
const runtimeFindings = checkAllRuntimesParity(contextText, installJsText);
|
|
195
|
+
const findings = [...fileRefs.findings, ...runtimeFindings];
|
|
196
|
+
|
|
197
|
+
if (flag === '--check') {
|
|
198
|
+
if (findings.length > 0) {
|
|
199
|
+
process.stderr.write(`CONTEXT.md glossary has ${findings.length} drift finding(s).\n\n`);
|
|
200
|
+
for (const f of findings) process.stderr.write(` ✗ ${f}\n`);
|
|
201
|
+
process.stderr.write('\n');
|
|
202
|
+
throw new ExitError(1);
|
|
203
|
+
}
|
|
204
|
+
process.stdout.write(
|
|
205
|
+
`CONTEXT.md glossary references are current (${fileRefs.checked} refs checked, allRuntimes parity ok).\n`,
|
|
206
|
+
);
|
|
207
|
+
return;
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
if (findings.length === 0) {
|
|
211
|
+
process.stdout.write(
|
|
212
|
+
`CONTEXT.md glossary references are current (${fileRefs.checked} refs checked, allRuntimes parity ok).\n`,
|
|
213
|
+
);
|
|
214
|
+
} else {
|
|
215
|
+
process.stdout.write(`CONTEXT.md glossary has ${findings.length} drift finding(s):\n\n`);
|
|
216
|
+
for (const f of findings) process.stdout.write(` ✗ ${f}\n`);
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
runMain(main);
|
|
@@ -8,6 +8,22 @@
|
|
|
8
8
|
// GITHUB_BASE_REF — PR base branch name (set by GitHub Actions on pull_request events)
|
|
9
9
|
// GITHUB_REPOSITORY — owner/repo (set by GitHub Actions)
|
|
10
10
|
//
|
|
11
|
+
// Optional:
|
|
12
|
+
// CI_REBASE_BASE_SHA — pin the merge to one exact base commit (#2472).
|
|
13
|
+
//
|
|
14
|
+
// Why the pin matters. Every job of a run executes this step independently, at
|
|
15
|
+
// whatever wall-clock moment it gets there — and Windows/macOS installs skew
|
|
16
|
+
// that by minutes across a 12-job matrix. Merging the moving `origin/<branch>`
|
|
17
|
+
// ref means that if the base advances mid-run, different jobs merge different
|
|
18
|
+
// trees. That was survivable when jobs only had to agree on pass/fail, but the
|
|
19
|
+
// sharded lane makes them agree on a PARTITION: each shard job computes the
|
|
20
|
+
// whole split and keeps its own slice, so jobs working from different trees can
|
|
21
|
+
// place a file in two shards or in none. Each job still looks internally
|
|
22
|
+
// consistent, so nothing errors — a test silently never runs and CI stays
|
|
23
|
+
// green. Pinning every job to `github.event.pull_request.base.sha`, which is
|
|
24
|
+
// fixed for the life of the run, removes the divergence at its source rather
|
|
25
|
+
// than detecting it after the fact.
|
|
26
|
+
//
|
|
11
27
|
// Exit 0 = merged cleanly (or merge was a no-op).
|
|
12
28
|
// Exit 1 = merge conflict or fetch failure.
|
|
13
29
|
|
|
@@ -35,6 +51,28 @@ function runOrThrow(cmd, args, label) {
|
|
|
35
51
|
const token = process.env.GITHUB_TOKEN || '';
|
|
36
52
|
const baseBranch = process.env.GITHUB_BASE_REF || 'main';
|
|
37
53
|
const repo = process.env.GITHUB_REPOSITORY || '';
|
|
54
|
+
// Resolve what to fetch and what to merge, pinned together so they can never
|
|
55
|
+
// disagree. Pure and exported so the pin contract is testable without spawning
|
|
56
|
+
// git: env in, refs out.
|
|
57
|
+
//
|
|
58
|
+
// Only a full 40-hex sha is accepted. Anything else — empty on push/dispatch
|
|
59
|
+
// events, or a malformed/injected value — falls back to the branch ref,
|
|
60
|
+
// preserving the pre-#2472 behavior rather than handing an arbitrary string to
|
|
61
|
+
// `git fetch` as a refspec.
|
|
62
|
+
function resolveBaseRefs(env = process.env, fallbackBranch = 'main') {
|
|
63
|
+
const branch = env.GITHUB_BASE_REF || fallbackBranch;
|
|
64
|
+
const raw = env.CI_REBASE_BASE_SHA || '';
|
|
65
|
+
const sha = /^[0-9a-f]{40}$/.test(raw) ? raw : null;
|
|
66
|
+
return {
|
|
67
|
+
branch,
|
|
68
|
+
sha,
|
|
69
|
+
pinned: sha !== null,
|
|
70
|
+
fetchRef: sha || branch,
|
|
71
|
+
mergeRef: sha || `origin/${branch}`,
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
const { fetchRef, mergeRef } = resolveBaseRefs(process.env, 'main');
|
|
38
76
|
|
|
39
77
|
function main() {
|
|
40
78
|
// Configure git identity (needed for merge commit).
|
|
@@ -52,12 +90,12 @@ function main() {
|
|
|
52
90
|
|
|
53
91
|
// Fetch base branch with retry.
|
|
54
92
|
for (let attempt = 1; attempt <= 3; attempt++) {
|
|
55
|
-
const result = run('git', ['fetch', 'origin',
|
|
93
|
+
const result = run('git', ['fetch', 'origin', fetchRef]);
|
|
56
94
|
if (result) {
|
|
57
95
|
break;
|
|
58
96
|
}
|
|
59
97
|
if (attempt === 3) {
|
|
60
|
-
throw new ExitError(1, `::error::git fetch origin ${
|
|
98
|
+
throw new ExitError(1, `::error::git fetch origin ${fetchRef} failed after 3 attempts.`);
|
|
61
99
|
}
|
|
62
100
|
// Wait before retry: attempt * 4 seconds.
|
|
63
101
|
const waitMs = attempt * 4000;
|
|
@@ -67,7 +105,7 @@ function main() {
|
|
|
67
105
|
|
|
68
106
|
// Attempt merge.
|
|
69
107
|
try {
|
|
70
|
-
execFileSync('git', ['merge', '--no-edit', '--no-ff',
|
|
108
|
+
execFileSync('git', ['merge', '--no-edit', '--no-ff', mergeRef], { stdio: 'inherit' });
|
|
71
109
|
} catch (e) {
|
|
72
110
|
process.stderr.write(
|
|
73
111
|
`::error::This PR cannot cleanly merge origin/${baseBranch}. Rebase your branch onto current ${baseBranch} and push again.\n`
|
|
@@ -83,4 +121,10 @@ function main() {
|
|
|
83
121
|
}
|
|
84
122
|
}
|
|
85
123
|
|
|
86
|
-
|
|
124
|
+
// Only run when invoked as the CI step. Guarded so a test can require this
|
|
125
|
+
// module for resolveBaseRefs without firing git fetch/merge as a side effect.
|
|
126
|
+
if (require.main === module) {
|
|
127
|
+
runMain(main);
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
module.exports = { resolveBaseRefs };
|
|
@@ -145,6 +145,37 @@ const RULES = [
|
|
|
145
145
|
'tests/golden-install-parity.test.cjs', // any src/installer change can alter emitted install artifacts → re-verify golden install parity (drift guard)
|
|
146
146
|
],
|
|
147
147
|
},
|
|
148
|
+
{
|
|
149
|
+
name: 'shipped install content (golden-parity drift guard, #2267)',
|
|
150
|
+
// Every source file the installer EMITS into a runtime layout is captured by
|
|
151
|
+
// golden-install-parity + the install-tree snapshot. A source edit here that
|
|
152
|
+
// changes emitted output MUST re-verify the fixtures — otherwise stale golden
|
|
153
|
+
// fixtures merge silently (#2266: a hooks/gsd-statusline.js edit changed
|
|
154
|
+
// installed output but no rule selected golden-parity, so stale fixtures
|
|
155
|
+
// shipped to next undetected). Union semantics: this ADDS the parity guard on
|
|
156
|
+
// top of each path's existing content-specific tests. Targeted lane only (the
|
|
157
|
+
// golden test skips win32 by design), no fullMatrix.
|
|
158
|
+
// NOTE: intentionally NOT a blanket 'gsd-core/' prefix, for two reasons:
|
|
159
|
+
// (1) gsd-core/bin/** is tsc-compiled runtime output — EXCLUDED_PREFIXES-
|
|
160
|
+
// excluded from both manifests, and already covered by the 'installer and
|
|
161
|
+
// package layout' rule (path.startsWith('gsd-core/bin/')) — so matching it
|
|
162
|
+
// here would be pure noise; and
|
|
163
|
+
// (2) enumerating only the installer-shipped content subtrees preserves the
|
|
164
|
+
// bug-408 unit-fallback contract: a gsd-core/ path that is NOT shipped
|
|
165
|
+
// verbatim (the bug-408 test uses gsd-core/src/some-util.js) must still
|
|
166
|
+
// fall back to ['unit'] when no rule matches.
|
|
167
|
+
// Listed: the four gsd-core content subtrees the installer ships verbatim
|
|
168
|
+
// (contexts, references, templates, workflows) + bin/shared/*.json data files.
|
|
169
|
+
// Verify against Object.keys(golden fixture) grouped by gsd-core/<subdir>.
|
|
170
|
+
match: path =>
|
|
171
|
+
['hooks/', 'commands/', 'agents/', 'skills/', 'gsd-core/workflows/', 'gsd-core/templates/', 'gsd-core/references/', 'gsd-core/contexts/', 'scripts/changeset/', 'scripts/lib/'].some(p => path.startsWith(p)) ||
|
|
172
|
+
(path.startsWith('gsd-core/bin/shared/') && path.endsWith('.json')) ||
|
|
173
|
+
['scripts/fix-slash-commands.cjs', 'scripts/gen-capability-registry.cjs', 'scripts/gen-loop-host-contract.cjs'].includes(path),
|
|
174
|
+
tests: [
|
|
175
|
+
'tests/golden-install-parity.test.cjs',
|
|
176
|
+
'tests/golden-install-tree.test.cjs',
|
|
177
|
+
],
|
|
178
|
+
},
|
|
148
179
|
{
|
|
149
180
|
name: 'hooks',
|
|
150
181
|
match: path => path.startsWith('hooks/'),
|
|
@@ -364,8 +395,15 @@ function classify(files) {
|
|
|
364
395
|
for (const file of files) {
|
|
365
396
|
// Determine if this file is product/pipeline code.
|
|
366
397
|
// docs/ and root-level .md files are intentionally excluded.
|
|
398
|
+
// 'skills/' is shipped agent-skill content installed into every runtime by
|
|
399
|
+
// the installer (see the 'shipped install content' RULES entry below) — it
|
|
400
|
+
// must be product code, or a skills/-only change silently gets
|
|
401
|
+
// code_changed=false and skips the ENTIRE CI matrix, not merely golden-parity
|
|
402
|
+
// (found while verifying the #2267 golden-parity rule against skills/**: the
|
|
403
|
+
// rule fired in `reasons` but classify()'s codeChanged gate zeroed out every
|
|
404
|
+
// targeted test because 'skills/' was absent from this list).
|
|
367
405
|
if (
|
|
368
|
-
['bin/', 'src/', 'gsd-core/', 'agents/', 'commands/', 'hooks/', 'tests/', 'scripts/', 'eslint-rules/'].some(p => file.startsWith(p)) ||
|
|
406
|
+
['bin/', 'src/', 'gsd-core/', 'agents/', 'commands/', 'hooks/', 'skills/', 'tests/', 'scripts/', 'eslint-rules/'].some(p => file.startsWith(p)) ||
|
|
369
407
|
file === 'package.json' || file === 'package-lock.json' ||
|
|
370
408
|
(file.startsWith('tsconfig') && file.endsWith('.json')) ||
|
|
371
409
|
file.startsWith('.github/rulesets/')
|