* 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>
748 lines
19 KiB
JavaScript
748 lines
19 KiB
JavaScript
/**
|
|
* GSD Tools Tests - roadmap get-phase fallback to full ROADMAP.md
|
|
*
|
|
* Covers issue #1634: phases outside the current milestone slice should still
|
|
* resolve by falling back to the full ROADMAP.md content.
|
|
*/
|
|
|
|
const { test, describe, beforeEach, afterEach } = require('node:test');
|
|
const assert = require('node:assert/strict');
|
|
const fs = require('fs');
|
|
const path = require('path');
|
|
const { runGsdTools, createTempProject, cleanup } = require('./helpers.cjs');
|
|
|
|
/**
|
|
* Helper: write STATE.md with a milestone version so extractCurrentMilestone
|
|
* will slice the roadmap to only that milestone's section.
|
|
*/
|
|
function writeState(tmpDir, version) {
|
|
fs.writeFileSync(
|
|
path.join(tmpDir, '.planning', 'STATE.md'),
|
|
`---\nmilestone: ${version}\n---\n`
|
|
);
|
|
}
|
|
|
|
describe('roadmap get-phase fallback to full ROADMAP.md (#1634)', () => {
|
|
let tmpDir;
|
|
|
|
beforeEach(() => {
|
|
tmpDir = createTempProject();
|
|
});
|
|
|
|
afterEach(() => {
|
|
cleanup(tmpDir);
|
|
});
|
|
|
|
test('active milestone phase still resolves correctly', () => {
|
|
writeState(tmpDir, 'v1.0');
|
|
fs.writeFileSync(
|
|
path.join(tmpDir, '.planning', 'ROADMAP.md'),
|
|
`# Roadmap
|
|
|
|
## v1.0 Current Release
|
|
|
|
### Phase 1: Foundation
|
|
**Goal:** Set up project infrastructure
|
|
|
|
### Phase 2: API
|
|
**Goal:** Build REST API
|
|
|
|
## v2.0 Next Release
|
|
|
|
### Phase 3: Frontend
|
|
**Goal:** Build UI layer
|
|
`
|
|
);
|
|
|
|
const result = runGsdTools('roadmap get-phase 1', tmpDir);
|
|
assert.ok(result.success, `Command failed: ${result.error}`);
|
|
|
|
const output = JSON.parse(result.output);
|
|
assert.equal(output.found, true, 'active milestone phase should be found');
|
|
assert.equal(output.phase_number, '1');
|
|
assert.equal(output.phase_name, 'Foundation');
|
|
assert.equal(output.goal, 'Set up project infrastructure');
|
|
});
|
|
|
|
test('backlog phase outside current milestone resolves via fallback', () => {
|
|
writeState(tmpDir, 'v1.0');
|
|
fs.writeFileSync(
|
|
path.join(tmpDir, '.planning', 'ROADMAP.md'),
|
|
`# Roadmap
|
|
|
|
## v1.0 Current Release
|
|
|
|
### Phase 1: Foundation
|
|
**Goal:** Set up project infrastructure
|
|
|
|
## v2.0 Future Release
|
|
|
|
### Phase 999.60: Backlog Cleanup
|
|
**Goal:** Clean up technical debt from backlog
|
|
`
|
|
);
|
|
|
|
const result = runGsdTools('roadmap get-phase 999.60', tmpDir);
|
|
assert.ok(result.success, `Command failed: ${result.error}`);
|
|
|
|
const output = JSON.parse(result.output);
|
|
assert.equal(output.found, true, 'backlog phase should be found via fallback');
|
|
assert.equal(output.phase_number, '999.60');
|
|
assert.equal(output.phase_name, 'Backlog Cleanup');
|
|
assert.equal(output.goal, 'Clean up technical debt from backlog');
|
|
});
|
|
|
|
test('future planned milestone phase resolves via fallback', () => {
|
|
writeState(tmpDir, 'v1.0');
|
|
fs.writeFileSync(
|
|
path.join(tmpDir, '.planning', 'ROADMAP.md'),
|
|
`# Roadmap
|
|
|
|
## v1.0 Current Release
|
|
|
|
### Phase 1: Foundation
|
|
**Goal:** Set up project infrastructure
|
|
|
|
## v3.0 Planned Milestone
|
|
|
|
### Phase 1025: Advanced Analytics
|
|
**Goal:** Build analytics dashboard for enterprise customers
|
|
|
|
**Success Criteria** (what must be TRUE):
|
|
1. Dashboard renders in under 2s
|
|
2. Supports 10k concurrent users
|
|
`
|
|
);
|
|
|
|
const result = runGsdTools('roadmap get-phase 1025', tmpDir);
|
|
assert.ok(result.success, `Command failed: ${result.error}`);
|
|
|
|
const output = JSON.parse(result.output);
|
|
assert.equal(output.found, true, 'future milestone phase should be found via fallback');
|
|
assert.equal(output.phase_number, '1025');
|
|
assert.equal(output.phase_name, 'Advanced Analytics');
|
|
assert.equal(output.goal, 'Build analytics dashboard for enterprise customers');
|
|
assert.ok(Array.isArray(output.success_criteria), 'success_criteria should be extracted');
|
|
assert.equal(output.success_criteria.length, 2, 'should have 2 criteria');
|
|
});
|
|
|
|
test('truly missing phase still returns found: false', () => {
|
|
writeState(tmpDir, 'v1.0');
|
|
fs.writeFileSync(
|
|
path.join(tmpDir, '.planning', 'ROADMAP.md'),
|
|
`# Roadmap
|
|
|
|
## v1.0 Current Release
|
|
|
|
### Phase 1: Foundation
|
|
**Goal:** Set up project infrastructure
|
|
|
|
## v2.0 Future Release
|
|
|
|
### Phase 5: Mobile
|
|
**Goal:** Build mobile app
|
|
`
|
|
);
|
|
|
|
const result = runGsdTools('roadmap get-phase 9999', tmpDir);
|
|
assert.ok(result.success, `Command failed: ${result.error}`);
|
|
|
|
const output = JSON.parse(result.output);
|
|
assert.equal(output.found, false, 'truly missing phase should return found: false');
|
|
assert.equal(output.phase_number, '9999');
|
|
});
|
|
|
|
test('backlog checklist-only phase triggers malformed_roadmap via fallback', () => {
|
|
writeState(tmpDir, 'v1.0');
|
|
fs.writeFileSync(
|
|
path.join(tmpDir, '.planning', 'ROADMAP.md'),
|
|
`# Roadmap
|
|
|
|
## v1.0 Current Release
|
|
|
|
### Phase 1: Foundation
|
|
**Goal:** Set up project infrastructure
|
|
|
|
## v2.0 Backlog
|
|
|
|
- [ ] **Phase 50: Cleanup** - Remove old code
|
|
`
|
|
);
|
|
|
|
const result = runGsdTools('roadmap get-phase 50', tmpDir);
|
|
assert.ok(result.success, `Command failed: ${result.error}`);
|
|
|
|
const output = JSON.parse(result.output);
|
|
assert.equal(output.found, false, 'checklist-only phase should not be "found"');
|
|
assert.equal(output.error, 'malformed_roadmap', 'should identify malformed roadmap via fallback');
|
|
assert.ok(output.message.includes('missing'), 'should explain the issue');
|
|
});
|
|
|
|
test('checklist in milestone does not block full header match in wider roadmap', () => {
|
|
writeState(tmpDir, 'v1.0');
|
|
fs.writeFileSync(
|
|
path.join(tmpDir, '.planning', 'ROADMAP.md'),
|
|
`# Roadmap
|
|
|
|
## v1.0 Current Release
|
|
|
|
### Phase 1: Foundation
|
|
**Goal:** Set up project infrastructure
|
|
|
|
- [ ] **Phase 50: Cleanup** - referenced in checklist
|
|
|
|
## v2.0 Future Release
|
|
|
|
### Phase 50: Cleanup
|
|
**Goal:** Remove deprecated modules
|
|
`
|
|
);
|
|
|
|
const result = runGsdTools('roadmap get-phase 50', tmpDir);
|
|
assert.ok(result.success, `Command failed: ${result.error}`);
|
|
|
|
const output = JSON.parse(result.output);
|
|
assert.equal(output.found, true, 'full header in v2.0 should win over checklist in v1.0');
|
|
assert.equal(output.phase_name, 'Cleanup');
|
|
assert.equal(output.goal, 'Remove deprecated modules');
|
|
});
|
|
|
|
test('extractCurrentMilestone does not truncate on phase heading containing vX.Y (#2619)', () => {
|
|
// Regression: phase heading like "### Phase 12: v1.0 Tech-Debt Closure"
|
|
// was incorrectly treated as a milestone boundary because the greedy
|
|
// `.*v\d+\.\d+` subpattern in nextMilestonePattern matched it.
|
|
const core = require('../gsd-core/bin/lib/core.cjs');
|
|
writeState(tmpDir, 'v1.1');
|
|
const roadmap = `# Roadmap
|
|
|
|
## Phases
|
|
|
|
### 🚧 v1.1 Launch-Ready (In Progress)
|
|
|
|
### Phase 11: Structured Logging
|
|
**Goal:** Add structured logging
|
|
|
|
### Phase 12: v1.0 Tech-Debt Closure
|
|
**Goal:** Close out v1.0 debt
|
|
|
|
### Phase 19: Security Audit
|
|
**Goal:** Full security audit
|
|
`;
|
|
const slice = core.extractCurrentMilestone(roadmap, tmpDir);
|
|
assert.ok(
|
|
slice.includes('### Phase 12: v1.0 Tech-Debt Closure'),
|
|
'slice must include Phase 12 (it lives inside the active milestone)'
|
|
);
|
|
assert.ok(
|
|
slice.includes('### Phase 19: Security Audit'),
|
|
'slice must include Phase 19 (truncation at Phase 12 would hide it)'
|
|
);
|
|
});
|
|
|
|
test('extractCurrentMilestone handles PHASE/phase (case-insensitive) containing vX.Y (#2619 follow-up)', () => {
|
|
// CodeRabbit follow-up: the negative lookahead `(?!Phase\s+\S)` must be
|
|
// case-insensitive so PHASE/phase variants are also excluded.
|
|
const core = require('../gsd-core/bin/lib/core.cjs');
|
|
writeState(tmpDir, 'v1.1');
|
|
const roadmap = `# Roadmap
|
|
|
|
## Phases
|
|
|
|
### 🚧 v1.1 Launch-Ready (In Progress)
|
|
|
|
### PHASE 11: Structured Logging
|
|
**Goal:** Add structured logging
|
|
|
|
### phase 12: v1.0 Tech-Debt Closure
|
|
**Goal:** Close out v1.0 debt
|
|
|
|
### Phase 19: Security Audit
|
|
**Goal:** Full security audit
|
|
`;
|
|
const slice = core.extractCurrentMilestone(roadmap, tmpDir);
|
|
assert.ok(
|
|
slice.includes('### PHASE 11: Structured Logging'),
|
|
'slice must include PHASE 11 (uppercase)'
|
|
);
|
|
assert.ok(
|
|
slice.includes('### phase 12: v1.0 Tech-Debt Closure'),
|
|
'slice must include phase 12 (lowercase with vX.Y)'
|
|
);
|
|
assert.ok(
|
|
slice.includes('### Phase 19: Security Audit'),
|
|
'slice must include Phase 19 (truncation at phase 12 would hide it)'
|
|
);
|
|
});
|
|
|
|
test('section extraction from fallback includes correct content boundaries', () => {
|
|
writeState(tmpDir, 'v1.0');
|
|
fs.writeFileSync(
|
|
path.join(tmpDir, '.planning', 'ROADMAP.md'),
|
|
`# Roadmap
|
|
|
|
## v1.0 Current Release
|
|
|
|
### Phase 1: Foundation
|
|
**Goal:** Set up project infrastructure
|
|
|
|
## v2.0 Future Release
|
|
|
|
### Phase 10: Database
|
|
**Goal:** Schema design and migrations
|
|
|
|
This phase covers:
|
|
- Schema modeling
|
|
- Migration tooling
|
|
- Seed data
|
|
|
|
### Phase 11: Caching
|
|
**Goal:** Add Redis caching layer
|
|
`
|
|
);
|
|
|
|
const result = runGsdTools('roadmap get-phase 10', tmpDir);
|
|
assert.ok(result.success, `Command failed: ${result.error}`);
|
|
|
|
const output = JSON.parse(result.output);
|
|
assert.equal(output.found, true, 'phase 10 should be found via fallback');
|
|
assert.ok(output.section.includes('Schema modeling'), 'section includes description');
|
|
assert.ok(output.section.includes('Seed data'), 'section includes all bullets');
|
|
assert.ok(!output.section.includes('Phase 11'), 'section does not include next phase');
|
|
});
|
|
});
|
|
|
|
describe('extractCurrentMilestone — closed-sibling heading selection (#145)', () => {
|
|
let tmpDir;
|
|
const core = require('../gsd-core/bin/lib/core.cjs');
|
|
|
|
beforeEach(() => {
|
|
tmpDir = createTempProject();
|
|
});
|
|
|
|
afterEach(() => {
|
|
cleanup(tmpDir);
|
|
});
|
|
|
|
test('(1) first-match-skip: active sub-milestone selected over closed sibling', () => {
|
|
writeState(tmpDir, 'v8.0');
|
|
const roadmap = `# Project Roadmap
|
|
|
|
## v8.0 Overview — v8.0-F (CLOSED FAIL 2026-05-18)
|
|
|
|
This is the closed milestone body with some text.
|
|
|
|
### Phase 24: ARCHIVED
|
|
**Goal:** This phase is done and archived.
|
|
|
|
## v8.0-B Overview (STARTED 2026-05-18)
|
|
|
|
This is the active milestone body.
|
|
|
|
### Phase 31: EVAL
|
|
**Goal:** Evaluate the new system.
|
|
|
|
## v9.0 Future Milestone
|
|
|
|
### Phase 40: FUTURE
|
|
**Goal:** Future work.
|
|
`;
|
|
const slice = core.extractCurrentMilestone(roadmap, tmpDir);
|
|
assert.ok(
|
|
slice.includes('Phase 31: EVAL'),
|
|
'slice must include Phase 31: EVAL from the active v8.0-B section'
|
|
);
|
|
assert.ok(
|
|
slice.includes('v8.0-B Overview'),
|
|
'slice must include the v8.0-B heading'
|
|
);
|
|
assert.ok(
|
|
!slice.includes('Phase 24: ARCHIVED'),
|
|
'slice must NOT include Phase 24: ARCHIVED from the closed section'
|
|
);
|
|
assert.ok(
|
|
!slice.includes('closed milestone body'),
|
|
'preamble must NOT contain closed v8.0-F body text (preamble boundary fix)'
|
|
);
|
|
});
|
|
|
|
test('(2) double-closed-skip: third sibling (active) selected when first two are closed', () => {
|
|
writeState(tmpDir, 'v9.0');
|
|
const roadmap = `# Project Roadmap
|
|
|
|
## v9.0 Overview — v9.0 (CLOSED 2026-01-01)
|
|
|
|
Closed first sibling body text.
|
|
|
|
### Phase 1: OLD
|
|
**Goal:** Old closed phase.
|
|
|
|
## v9.0-A Overview (ARCHIVED 2026-03-01)
|
|
|
|
Archived second sibling body text.
|
|
|
|
### Phase 2: ALSO-OLD
|
|
**Goal:** Another archived phase.
|
|
|
|
## v9.0-C Overview (STARTED 2026-05-26)
|
|
|
|
Active sibling body text.
|
|
|
|
### Phase 5: GO
|
|
**Goal:** Active phase to work on.
|
|
|
|
## v10.0 Next Major
|
|
|
|
### Phase 99: FUTURE
|
|
**Goal:** Far future.
|
|
`;
|
|
const slice = core.extractCurrentMilestone(roadmap, tmpDir);
|
|
assert.ok(
|
|
slice.includes('Phase 5: GO'),
|
|
'slice must include Phase 5: GO from active v9.0-C'
|
|
);
|
|
assert.ok(
|
|
!slice.includes('Phase 1: OLD'),
|
|
'slice must NOT include closed Phase 1: OLD'
|
|
);
|
|
assert.ok(
|
|
!slice.includes('Phase 2: ALSO-OLD'),
|
|
'slice must NOT include archived Phase 2: ALSO-OLD'
|
|
);
|
|
});
|
|
|
|
test('(3) explicit sub-milestone resolution: exact version v8.0-B in STATE.md', () => {
|
|
writeState(tmpDir, 'v8.0-B');
|
|
const roadmap = `# Project Roadmap
|
|
|
|
## v8.0 Overview — v8.0-F (CLOSED FAIL 2026-05-18)
|
|
|
|
Closed milestone body.
|
|
|
|
### Phase 24: ARCHIVED
|
|
**Goal:** This phase is archived.
|
|
|
|
## v8.0-B Overview (STARTED 2026-05-18)
|
|
|
|
Active milestone body.
|
|
|
|
### Phase 31: EVAL
|
|
**Goal:** Evaluate the new system.
|
|
|
|
## v9.0 Future Milestone
|
|
|
|
### Phase 40: FUTURE
|
|
**Goal:** Future work.
|
|
`;
|
|
const slice = core.extractCurrentMilestone(roadmap, tmpDir);
|
|
assert.ok(
|
|
slice.includes('Phase 31: EVAL'),
|
|
'slice must include Phase 31: EVAL when STATE has exact v8.0-B version'
|
|
);
|
|
assert.ok(
|
|
slice.includes('v8.0-B Overview'),
|
|
'slice must include the v8.0-B heading'
|
|
);
|
|
});
|
|
|
|
test('(4) all-closed fallback: returns first match when all candidates are closed', () => {
|
|
writeState(tmpDir, 'v7.0');
|
|
const roadmap = `# Project Roadmap
|
|
|
|
## v7.0 Overview (CLOSED 2025-12-01)
|
|
|
|
First closed milestone body with unique text: alpha-unique-content.
|
|
|
|
### Phase 10: DONE
|
|
**Goal:** Completed phase.
|
|
|
|
## v7.0-A Overview (ARCHIVED 2025-12-15)
|
|
|
|
Second archived milestone body.
|
|
|
|
### Phase 11: ALSO-DONE
|
|
**Goal:** Another completed phase.
|
|
|
|
## v8.0 Next Milestone
|
|
|
|
### Phase 20: NEXT
|
|
**Goal:** Next milestone work.
|
|
`;
|
|
let result;
|
|
assert.doesNotThrow(() => {
|
|
result = core.extractCurrentMilestone(roadmap, tmpDir);
|
|
}, 'must not throw when all candidates are closed');
|
|
assert.ok(
|
|
result.includes('v7.0 Overview (CLOSED'),
|
|
'fallback must return content including the first (closed) heading'
|
|
);
|
|
assert.ok(
|
|
result.includes('alpha-unique-content'),
|
|
'fallback must include content from the first closed section'
|
|
);
|
|
});
|
|
|
|
test('(5) marker variants: emoji and text closed markers are all recognized', () => {
|
|
writeState(tmpDir, 'v6.0');
|
|
const roadmap = `# Project Roadmap
|
|
|
|
## ✅ v6.0 Foundation
|
|
|
|
Completed foundation body text.
|
|
|
|
### Phase 1: DONE-FOUNDATION
|
|
**Goal:** Foundation work.
|
|
|
|
## 🗄️ v6.0-B Storage
|
|
|
|
Archived storage body text.
|
|
|
|
### Phase 2: DONE-STORAGE
|
|
**Goal:** Storage work.
|
|
|
|
## v6.0-C Abandoned Experiment (FAILED)
|
|
|
|
Failed experiment body text.
|
|
|
|
### Phase 3: FAILED-EXPERIMENT
|
|
**Goal:** This failed.
|
|
|
|
## v6.0-D Overview (STARTED 2026-05-26)
|
|
|
|
Active body text.
|
|
|
|
### Phase 9: LIVE
|
|
**Goal:** Live active phase.
|
|
|
|
## v7.0 Next
|
|
|
|
### Phase 50: NEXT
|
|
**Goal:** Next milestone.
|
|
`;
|
|
const slice = core.extractCurrentMilestone(roadmap, tmpDir);
|
|
assert.ok(
|
|
slice.includes('Phase 9: LIVE'),
|
|
'slice must include Phase 9: LIVE from the active v6.0-D section'
|
|
);
|
|
assert.ok(
|
|
!slice.includes('Phase 1: DONE-FOUNDATION'),
|
|
'slice must NOT include content from ✅ closed section'
|
|
);
|
|
assert.ok(
|
|
!slice.includes('Phase 2: DONE-STORAGE'),
|
|
'slice must NOT include content from 🗄️ archived section'
|
|
);
|
|
assert.ok(
|
|
!slice.includes('Phase 3: FAILED-EXPERIMENT'),
|
|
'slice must NOT include content from FAILED section'
|
|
);
|
|
|
|
// Sub-case: ABANDONED heading is also skipped
|
|
writeState(tmpDir, 'v6.0');
|
|
const roadmap2 = `# Project Roadmap
|
|
|
|
## v6.0-X Abandoned Prototype (ABANDONED)
|
|
|
|
Abandoned body text.
|
|
|
|
### Phase 4: ABANDONED-PHASE
|
|
**Goal:** Abandoned work.
|
|
|
|
## v6.0-D Overview (STARTED 2026-05-26)
|
|
|
|
Active sub-case body.
|
|
|
|
### Phase 9: LIVE
|
|
**Goal:** The active phase.
|
|
`;
|
|
const slice2 = core.extractCurrentMilestone(roadmap2, tmpDir);
|
|
assert.ok(
|
|
slice2.includes('Phase 9: LIVE'),
|
|
'ABANDONED marker must be skipped and active section selected'
|
|
);
|
|
assert.ok(
|
|
!slice2.includes('Phase 4: ABANDONED-PHASE'),
|
|
'slice must NOT include content from ABANDONED section'
|
|
);
|
|
});
|
|
|
|
test('(6) single-milestone no-regression: behavior unchanged with one matching heading', () => {
|
|
writeState(tmpDir, 'v5.0');
|
|
const roadmap = `# Project Roadmap
|
|
|
|
## Roadmap v5.0: Solo
|
|
|
|
This is the only milestone.
|
|
|
|
### Phase 1: Only
|
|
**Goal:** The only phase in this roadmap.
|
|
|
|
## v6.0 Future
|
|
|
|
### Phase 2: FUTURE
|
|
**Goal:** Future work.
|
|
`;
|
|
const slice = core.extractCurrentMilestone(roadmap, tmpDir);
|
|
assert.ok(
|
|
slice.includes('Phase 1: Only'),
|
|
'slice must include Phase 1: Only when only one matching heading exists'
|
|
);
|
|
});
|
|
});
|
|
|
|
describe('extractCurrentMilestone — boundary / active-override hardening (#145 follow-up)', () => {
|
|
let tmpDir;
|
|
const core = require('../gsd-core/bin/lib/core.cjs');
|
|
|
|
beforeEach(() => {
|
|
tmpDir = createTempProject();
|
|
});
|
|
|
|
afterEach(() => {
|
|
cleanup(tmpDir);
|
|
});
|
|
|
|
test('(a) BOUNDARY: v2.0-B in STATE must not match v2.0-Beta heading', () => {
|
|
writeState(tmpDir, 'v2.0-B');
|
|
const roadmap = `# Project Roadmap
|
|
|
|
## v2.0-Beta Overview (STARTED)
|
|
|
|
Beta milestone body.
|
|
|
|
### Phase 1: BETA
|
|
**Goal:** Beta phase work.
|
|
|
|
## v2.0-B Overview (STARTED)
|
|
|
|
Real milestone body.
|
|
|
|
### Phase 2: REAL
|
|
**Goal:** Real phase work.
|
|
|
|
## v3.0 Future
|
|
|
|
### Phase 99: FUTURE
|
|
**Goal:** Future work.
|
|
`;
|
|
const slice = core.extractCurrentMilestone(roadmap, tmpDir);
|
|
assert.ok(
|
|
slice.includes('Phase 2: REAL'),
|
|
'slice must include Phase 2: REAL from the v2.0-B section'
|
|
);
|
|
assert.ok(
|
|
slice.includes('v2.0-B Overview'),
|
|
'slice must include the v2.0-B heading'
|
|
);
|
|
assert.ok(
|
|
!slice.includes('Phase 1: BETA'),
|
|
'slice must NOT include Phase 1: BETA from the v2.0-Beta section'
|
|
);
|
|
assert.ok(
|
|
!slice.includes('v2.0-Beta Overview'),
|
|
'slice must NOT include the v2.0-Beta heading'
|
|
);
|
|
});
|
|
|
|
test('(b) SHIPPED-skip: v3.0 state picks v3.0-B over v3.0-A (SHIPPED)', () => {
|
|
writeState(tmpDir, 'v3.0');
|
|
const roadmap = `# Project Roadmap
|
|
|
|
## v3.0 Overview — v3.0-A (SHIPPED)
|
|
|
|
Shipped milestone body.
|
|
|
|
### Phase 1: OLD
|
|
**Goal:** Old shipped phase.
|
|
|
|
## v3.0-B Overview (STARTED)
|
|
|
|
Active milestone body.
|
|
|
|
### Phase 2: NEW
|
|
**Goal:** New active phase.
|
|
|
|
## v4.0 Future
|
|
|
|
### Phase 99: FUTURE
|
|
**Goal:** Future work.
|
|
`;
|
|
const slice = core.extractCurrentMilestone(roadmap, tmpDir);
|
|
assert.ok(
|
|
slice.includes('Phase 2: NEW'),
|
|
'slice must include Phase 2: NEW from the active v3.0-B section'
|
|
);
|
|
assert.ok(
|
|
!slice.includes('Phase 1: OLD'),
|
|
'slice must NOT include Phase 1: OLD from the SHIPPED v3.0-A section'
|
|
);
|
|
});
|
|
|
|
test('(c) ACTIVE-OVERRIDE: heading with "Shipped" in name but STARTED marker is not closed', () => {
|
|
writeState(tmpDir, 'v4.0');
|
|
const roadmap = `# Project Roadmap
|
|
|
|
## v4.0-A Legacy (CLOSED)
|
|
|
|
Closed milestone body.
|
|
|
|
### Phase 1: GONE
|
|
**Goal:** Closed phase.
|
|
|
|
## v4.0-B Shipped logs pipeline (STARTED)
|
|
|
|
Active milestone body.
|
|
|
|
### Phase 2: LIVE
|
|
**Goal:** Active live phase.
|
|
|
|
## v5.0 Future
|
|
|
|
### Phase 99: FUTURE
|
|
**Goal:** Future work.
|
|
`;
|
|
const slice = core.extractCurrentMilestone(roadmap, tmpDir);
|
|
assert.ok(
|
|
slice.includes('Phase 2: LIVE'),
|
|
'slice must include Phase 2: LIVE — STARTED overrides "Shipped" in name'
|
|
);
|
|
assert.ok(
|
|
!slice.includes('Phase 1: GONE'),
|
|
'slice must NOT include Phase 1: GONE from the CLOSED v4.0-A section'
|
|
);
|
|
});
|
|
|
|
test('(d) FAIL-SAFE naming: FAIL-safe in heading name is not a closed marker', () => {
|
|
writeState(tmpDir, 'v5.0');
|
|
const roadmap = `# Project Roadmap
|
|
|
|
## v5.0-A Retired (ARCHIVED)
|
|
|
|
Archived milestone body.
|
|
|
|
### Phase 1: DEAD
|
|
**Goal:** Archived phase.
|
|
|
|
## v5.0-B FAIL-safe rollout (STARTED)
|
|
|
|
Active milestone body.
|
|
|
|
### Phase 2: GO
|
|
**Goal:** Active rollout phase.
|
|
|
|
## v6.0 Future
|
|
|
|
### Phase 99: FUTURE
|
|
**Goal:** Future work.
|
|
`;
|
|
const slice = core.extractCurrentMilestone(roadmap, tmpDir);
|
|
assert.ok(
|
|
slice.includes('Phase 2: GO'),
|
|
'slice must include Phase 2: GO — FAIL-safe must not be treated as a closed marker'
|
|
);
|
|
assert.ok(
|
|
!slice.includes('Phase 1: DEAD'),
|
|
'slice must NOT include Phase 1: DEAD from the ARCHIVED v5.0-A section'
|
|
);
|
|
});
|
|
});
|