* chore: rename npm package + bin to @opengsd/gsd-core (functional) - package.json: name @opengsd/get-shit-done-redux → @opengsd/gsd-core, bin key get-shit-done-redux → gsd-core, repository/homepage/bugs URLs - package-lock.json: regenerated (npm install --package-lock-only) - tests/**, scripts/**, bin/**, .github/**, agents/**, commands/**, get-shit-done/bin/**, get-shit-done/workflows/**: applied the 4-rule replacement (scoped npm ref, GitHub repo path, bin/clone invocations) per #505 single-source refactor Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> * docs: sweep live references to @opengsd/gsd-core Update all live documentation (README.md + translations, docs/**, CONTRIBUTING.md, VERSIONING.md, SECURITY.md, CONTEXT.md, docs/CANARY.md) to reflect the renamed package and repository. Rules applied: - @opengsd/get-shit-done-redux → @opengsd/gsd-core (scoped npm name) - open-gsd/get-shit-done-redux → open-gsd/gsd-core (GitHub repo) - GSD-redux/get-shit-done-redux → open-gsd/gsd-core (stale badge org) - bare bin/clone refs → gsd-core CHANGELOG.md, docs/adr/**, docs/RELEASE-*.md, docs/research/**, and .changeset/** are preserved byte-identical. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> * fix: add negative lookbehind to slash-command regex in bug-2954 test The extractSlashReferences regex matched /gsd-core inside npm package URLs (@opengsd/gsd-core), producing a false /gsd:core command reference. Adding a negative lookbehind (?<![a-z]) excludes matches preceded by a letter, so only standalone /gsd-<cmd> and /gsd:<cmd> tokens are found. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> * chore(#518): add changeset for package rename Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> * test(#518): update package-identity expectations to the renamed coordinates The rebase regenerated the seam to @opengsd/gsd-core (bin gsd-core, repo open-gsd/gsd-core). The #498 seam tests assert deriveIdentity against the REAL package.json, so their expected literals must follow the rename. The drift-lint unit test is left as-is — its SEAM is a self-consistent fixture and its stale-literal detection cases would shift if altered; the live-repo scan in it already passes. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
181 lines
7.1 KiB
JavaScript
181 lines
7.1 KiB
JavaScript
// allow-test-rule: source-text-is-the-product
|
|
// Workflow .md / agent .md / command .md / reference .md files — their text
|
|
// IS what the runtime loads. Testing text content tests the deployed contract.
|
|
// Per CONTRIBUTING.md exception matrix.
|
|
'use strict';
|
|
|
|
|
|
process.env.GSD_TEST_MODE = '1';
|
|
|
|
/**
|
|
* Bug #2954: keep `help.md` and the live `commands/gsd/*` slash surface
|
|
* in lockstep. Two regression tests:
|
|
*
|
|
* 1. help.md must not advertise any /gsd[-:]<name> that has no shipped
|
|
* slash command. (Caught the original #2954 regression: #2824 deleted
|
|
* 31 stubs without updating help.md.)
|
|
*
|
|
* 2. Every shipped /gsd[-:]<name> command must appear in help.md. (Caught
|
|
* the inverse: a command lands without docs, so users never discover it.)
|
|
*
|
|
* The shipped slash name is parsed from frontmatter `name:` (which can be
|
|
* either `gsd:foo` or `gsd-foo` — Claude Code surfaces both as `/gsd-foo`),
|
|
* NOT from the filename, because some files (e.g. `ns-context.md`) ship a
|
|
* different slash name (`gsd-context`) than their filename suggests.
|
|
*
|
|
* Also covers `do.md`, the dispatcher invoked at runtime by
|
|
* `/gsd:progress --do`: any `/gsd[-:]<name>` token in its routing table must
|
|
* resolve to a live command, otherwise the dispatcher emits "Unknown command".
|
|
*/
|
|
|
|
const { test, describe } = require('node:test');
|
|
const assert = require('node:assert/strict');
|
|
const fs = require('node:fs');
|
|
const path = require('node:path');
|
|
|
|
const ROOT = path.join(__dirname, '..');
|
|
const COMMANDS_DIR = path.join(ROOT, 'commands', 'gsd');
|
|
// After #3039, the canonical command reference is the `--full` mode file.
|
|
// `workflows/help.md` is now a small dispatcher; the bidirectional parity
|
|
// invariant lives with the comprehensive reference body.
|
|
const HELP_MD = path.join(ROOT, 'get-shit-done', 'workflows', 'help', 'modes', 'full.md');
|
|
const DO_MD = path.join(ROOT, 'get-shit-done', 'workflows', 'do.md');
|
|
|
|
function parseFrontmatter(content) {
|
|
const match = content.match(/^---\r?\n([\s\S]*?)\r?\n---/);
|
|
if (!match) return null;
|
|
const fields = {};
|
|
for (const line of match[1].split(/\r?\n/)) {
|
|
const fieldMatch = line.match(/^([a-zA-Z0-9_-]+):\s*(.*)$/);
|
|
if (!fieldMatch) continue;
|
|
const value = fieldMatch[2].trim().replace(/^["']|["']$/g, '');
|
|
fields[fieldMatch[1]] = value;
|
|
}
|
|
return fields;
|
|
}
|
|
|
|
/**
|
|
* Returns the set of slash-base-names actually shipped under commands/gsd/.
|
|
* A "slash-base-name" is the part after `/gsd-` — e.g. for frontmatter
|
|
* `name: gsd:foo` or `name: gsd-foo`, the slash-base-name is `foo`.
|
|
*/
|
|
function listShippedSlashBaseNames() {
|
|
const names = new Set();
|
|
for (const entry of fs.readdirSync(COMMANDS_DIR, { withFileTypes: true })) {
|
|
if (!entry.isFile() || !entry.name.endsWith('.md')) continue;
|
|
const content = fs.readFileSync(path.join(COMMANDS_DIR, entry.name), 'utf8');
|
|
const fm = parseFrontmatter(content);
|
|
if (!fm || !fm.name) continue;
|
|
const fmName = fm.name;
|
|
let base = null;
|
|
if (fmName.startsWith('gsd:')) base = fmName.slice(4);
|
|
else if (fmName.startsWith('gsd-')) base = fmName.slice(4);
|
|
if (base && /^[a-z][a-z0-9-]*$/.test(base)) names.add(base);
|
|
}
|
|
return names;
|
|
}
|
|
|
|
function extractSlashReferences(contents) {
|
|
const names = new Set();
|
|
// Negative lookbehind: must not be preceded by a letter (avoids matching npm scope
|
|
// paths like @opengsd/gsd-core where `/gsd-` appears inside a package URL).
|
|
const tokenRe = /(?<![a-z])\/gsd[:-]([a-z][a-z0-9-]*)/g;
|
|
let match;
|
|
while ((match = tokenRe.exec(contents)) !== null) {
|
|
names.add(match[1]);
|
|
}
|
|
return names;
|
|
}
|
|
|
|
/**
|
|
* For every shipped command with an `argument-hint:` frontmatter entry,
|
|
* collect the `--flag` tokens it advertises. Returns a Map<slashBaseName,
|
|
* Set<flagName>>. Flags are recorded without their leading `--`.
|
|
*/
|
|
function listShippedFlagsByCommand() {
|
|
const out = new Map();
|
|
for (const entry of fs.readdirSync(COMMANDS_DIR, { withFileTypes: true })) {
|
|
if (!entry.isFile() || !entry.name.endsWith('.md')) continue;
|
|
const content = fs.readFileSync(path.join(COMMANDS_DIR, entry.name), 'utf8');
|
|
const fm = parseFrontmatter(content);
|
|
if (!fm || !fm.name || !fm['argument-hint']) continue;
|
|
const fmName = fm.name;
|
|
let base = null;
|
|
if (fmName.startsWith('gsd:')) base = fmName.slice(4);
|
|
else if (fmName.startsWith('gsd-')) base = fmName.slice(4);
|
|
if (!base || !/^[a-z][a-z0-9-]*$/.test(base)) continue;
|
|
const flags = new Set();
|
|
for (const m of fm['argument-hint'].matchAll(/--([a-z][a-z0-9-]*)/g)) {
|
|
flags.add(m[1]);
|
|
}
|
|
if (flags.size) out.set(base, flags);
|
|
}
|
|
return out;
|
|
}
|
|
|
|
describe('Bug #2954: help.md ↔ commands/gsd/ bidirectional parity', () => {
|
|
test('every /gsd[-:]<name> referenced in help.md is a shipped command', () => {
|
|
const helpContents = fs.readFileSync(HELP_MD, 'utf8');
|
|
const referenced = extractSlashReferences(helpContents);
|
|
const shipped = listShippedSlashBaseNames();
|
|
const dangling = [...referenced].filter((n) => !shipped.has(n)).sort();
|
|
assert.deepEqual(
|
|
dangling,
|
|
[],
|
|
`help.md advertises /gsd[-:]<name> commands that are not shipped: ${dangling.join(', ')}`,
|
|
);
|
|
});
|
|
|
|
test('every shipped /gsd[-:]<name> command is documented in help.md', () => {
|
|
const helpContents = fs.readFileSync(HELP_MD, 'utf8');
|
|
const referenced = extractSlashReferences(helpContents);
|
|
const shipped = listShippedSlashBaseNames();
|
|
const undocumented = [...shipped].filter((n) => !referenced.has(n)).sort();
|
|
assert.deepEqual(
|
|
undocumented,
|
|
[],
|
|
`commands shipped under commands/gsd/ with no /gsd[-:]<name> reference in help.md: ${undocumented.join(', ')}`,
|
|
);
|
|
});
|
|
|
|
test('every /gsd[-:]<name> in do.md (live dispatcher) is a shipped command', () => {
|
|
const doContents = fs.readFileSync(DO_MD, 'utf8');
|
|
const referenced = extractSlashReferences(doContents);
|
|
const shipped = listShippedSlashBaseNames();
|
|
const dangling = [...referenced].filter((n) => !shipped.has(n)).sort();
|
|
assert.deepEqual(
|
|
dangling,
|
|
[],
|
|
`do.md routing table references /gsd[-:]<name> that is not shipped: ${dangling.join(', ')}`,
|
|
);
|
|
});
|
|
|
|
test('every --flag in a command\'s argument-hint appears in help.md', () => {
|
|
const helpContents = fs.readFileSync(HELP_MD, 'utf8');
|
|
const flagsByCommand = listShippedFlagsByCommand();
|
|
const gaps = [];
|
|
for (const [command, flags] of flagsByCommand) {
|
|
for (const flag of flags) {
|
|
// Accept `/gsd-<command> --<flag>` (precise) OR a bare `--<flag>` token
|
|
// anywhere in help.md (good enough for shared flags like `--force` that
|
|
// appear under multiple commands' descriptions).
|
|
const preciseDash = `/gsd-${command} --${flag}`;
|
|
const preciseColon = `/gsd:${command} --${flag}`;
|
|
const flagToken = `--${flag}`;
|
|
if (
|
|
!helpContents.includes(preciseDash) &&
|
|
!helpContents.includes(preciseColon) &&
|
|
!helpContents.includes(flagToken)
|
|
) {
|
|
gaps.push(`/gsd:${command} --${flag}`);
|
|
}
|
|
}
|
|
}
|
|
assert.deepEqual(
|
|
gaps.sort(),
|
|
[],
|
|
`commands ship --flag(s) in argument-hint that are absent from help.md: ${gaps.join(', ')}`,
|
|
);
|
|
});
|
|
});
|