* refactor(#455): implement typed surfaces to retire grep tests Production surfaces added: - hooks/managed-hooks-registry.cjs: new CJS module exporting MANAGED_HOOKS as a typed array; gsd-check-update-worker.js now requires it instead of declaring an inline array - bin/install.js: elevate inline gsdHooks to module-level GSD_UNINSTALL_HOOKS, export it alongside runtimeMap/allRuntimes (already exported) - scripts/build-hooks.js: export HOOKS_TO_COPY; guard build() behind require.main===module so tests can require the file without triggering a build - get-shit-done/bin/lib/init.cjs: add --json mode to agent-skills command, emitting typed IR { agent_type, block, skills_count } for test assertions - get-shit-done/bin/gsd-tools.cjs: wire --json flag for agent-skills dispatch Category-B source-grep migrations: - tests/managed-hooks.test.cjs: require MANAGED_HOOKS from registry, drop fs.readFileSync+regex - tests/orphaned-hooks.test.cjs: require MANAGED_HOOKS+HOOKS_TO_COPY as typed exports - tests/hooks-opt-in.test.cjs: replace gsdHooks regex-parse with GSD_UNINSTALL_HOOKS import - tests/install-minimal-hooks.test.cjs: replace gsdHooks regex-parse with GSD_UNINSTALL_HOOKS - tests/copilot-install.test.cjs: replace src.includes() checks with typed assertions on runtimeMap, allRuntimes, parseRuntimeInput, buildRuntimePromptText - tests/agent-skills.test.cjs: migrate to --json typed IR assertions pending-migration-to-typed-ir token cleared (87 of 87 files): - 78 files already had source-text-is-the-product; removed duplicate token - 5 files already used typed assertions; reclassified or annotated - 4 files required individual reclassification to source-text-is-the-product or architectural-invariant Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> * fix(#455): update workflow-guard test to typed GSD_UNINSTALL_HOOKS import; isolate HOME in runtime-launcher (D) test Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> * fix(#455): guard install.js main() behind require.main===module so the typed export is require-safe Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> * docs(#455): document --json typed surfaces for agent-skills, progress, validate context Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> * docs(#455): add changeset fragment for new --json surfaces Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> * fix(#455): complete grep migration for files flagged by lint-tests The branch commit 4e630d99 stripped `allow-test-rule: pending-migration-to-typed-ir` from ~80 test files without replacing their assertions or adding the correct exemption annotation. The files were NOT source-grep tests — they read .md workflow/agent/command/reference files (source-text-is-the-product) or hook source files for structural invariants (structural-regression-guard). No assertion logic was changed; only the correct allow-test-rule annotation was added to each file per CONTRIBUTING.md exception matrix. 73 files: `source-text-is-the-product` — workflow/agent/command/reference .md 7 files: `structural-regression-guard` — hook .js / bin/install.js structural checks Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> --------- Co-authored-by: CI Rebase Check <ci@gsd-redux> Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
155 lines
6.2 KiB
JavaScript
155 lines
6.2 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.
|
|
|
|
/**
|
|
* GSD Tools Tests - discuss-phase power user mode
|
|
*
|
|
* Validates that the --power flag workflow documentation is present and
|
|
* correctly describes the bulk question generation/answering flow.
|
|
*
|
|
* Closes: #1513
|
|
*/
|
|
|
|
const { test, describe } = require('node:test');
|
|
const assert = require('node:assert/strict');
|
|
const fs = require('fs');
|
|
const path = require('path');
|
|
|
|
describe('discuss-phase power user mode (#1513)', () => {
|
|
const commandPath = path.join(__dirname, '..', 'commands', 'gsd', 'discuss-phase.md');
|
|
const workflowPath = path.join(__dirname, '..', 'get-shit-done', 'workflows', 'discuss-phase.md');
|
|
const powerWorkflowPath = path.join(__dirname, '..', 'get-shit-done', 'workflows', 'discuss-phase-power.md');
|
|
|
|
describe('command file (discuss-phase.md)', () => {
|
|
test('mentions --power flag in argument-hint or description', () => {
|
|
const content = fs.readFileSync(commandPath, 'utf8');
|
|
assert.ok(
|
|
content.includes('--power'),
|
|
'commands/gsd/discuss-phase.md should document the --power flag'
|
|
);
|
|
});
|
|
|
|
test('references the power workflow file', () => {
|
|
const content = fs.readFileSync(commandPath, 'utf8');
|
|
assert.ok(
|
|
content.includes('discuss-phase-power'),
|
|
'command file should reference discuss-phase-power workflow'
|
|
);
|
|
});
|
|
});
|
|
|
|
describe('main workflow file (discuss-phase.md)', () => {
|
|
test('has power_user_mode section or references discuss-phase-power.md', () => {
|
|
// After #2551, the power dispatch lives in discuss-phase/modes/power.md and
|
|
// the parent references it via the dispatch table.
|
|
const parentContent = fs.readFileSync(workflowPath, 'utf8');
|
|
const powerModePath = path.join(__dirname, '..', 'get-shit-done', 'workflows', 'discuss-phase', 'modes', 'power.md');
|
|
const powerMode = fs.existsSync(powerModePath) ? fs.readFileSync(powerModePath, 'utf8') : '';
|
|
const content = parentContent + '\n' + powerMode;
|
|
const hasPowerSection = content.includes('power_user_mode') || content.includes('power user mode') || content.includes('modes/power.md');
|
|
const hasReference = content.includes('discuss-phase-power');
|
|
assert.ok(
|
|
hasPowerSection || hasReference,
|
|
'discuss-phase.md (or modes/power.md after #2551) should have power_user_mode section or reference discuss-phase-power.md'
|
|
);
|
|
});
|
|
|
|
test('describes --power flag routing', () => {
|
|
const content = fs.readFileSync(workflowPath, 'utf8');
|
|
assert.ok(
|
|
content.includes('--power'),
|
|
'discuss-phase.md should describe --power flag handling'
|
|
);
|
|
});
|
|
});
|
|
|
|
describe('power workflow file (discuss-phase-power.md)', () => {
|
|
test('file exists', () => {
|
|
assert.ok(
|
|
fs.existsSync(powerWorkflowPath),
|
|
'get-shit-done/workflows/discuss-phase-power.md should exist'
|
|
);
|
|
});
|
|
|
|
test('describes the generate step', () => {
|
|
const content = fs.readFileSync(powerWorkflowPath, 'utf8');
|
|
assert.ok(
|
|
content.includes('generate') || content.includes('Generate'),
|
|
'power workflow should describe generating questions'
|
|
);
|
|
});
|
|
|
|
test('describes the wait/notify step', () => {
|
|
const content = fs.readFileSync(powerWorkflowPath, 'utf8');
|
|
const hasWait = content.includes('wait') || content.includes('Wait');
|
|
const hasNotify = content.includes('notify') || content.includes('Notify') || content.includes('notif');
|
|
assert.ok(
|
|
hasWait || hasNotify,
|
|
'power workflow should describe the wait/notify step after generating files'
|
|
);
|
|
});
|
|
|
|
test('describes the refresh step', () => {
|
|
const content = fs.readFileSync(powerWorkflowPath, 'utf8');
|
|
assert.ok(
|
|
content.includes('refresh') || content.includes('Refresh'),
|
|
'power workflow should describe the refresh step for processing answers'
|
|
);
|
|
});
|
|
|
|
test('describes the finalize step', () => {
|
|
const content = fs.readFileSync(powerWorkflowPath, 'utf8');
|
|
assert.ok(
|
|
content.includes('finalize') || content.includes('Finalize'),
|
|
'power workflow should describe the finalize step for generating CONTEXT.md'
|
|
);
|
|
});
|
|
|
|
test('QUESTIONS.json structure has required fields', () => {
|
|
const content = fs.readFileSync(powerWorkflowPath, 'utf8');
|
|
assert.ok(content.includes('QUESTIONS.json'), 'should mention QUESTIONS.json file');
|
|
assert.ok(content.includes('"phase"'), 'JSON structure should include phase field');
|
|
assert.ok(content.includes('"stats"'), 'JSON structure should include stats field');
|
|
assert.ok(content.includes('"sections"'), 'JSON structure should include sections field');
|
|
assert.ok(
|
|
content.includes('"id"') && content.includes('"title"'),
|
|
'JSON structure should include question id and title fields'
|
|
);
|
|
assert.ok(
|
|
content.includes('"options"'),
|
|
'JSON structure should include options array'
|
|
);
|
|
assert.ok(
|
|
content.includes('"answer"'),
|
|
'JSON structure should include answer field'
|
|
);
|
|
assert.ok(
|
|
content.includes('"status"'),
|
|
'JSON structure should include status field'
|
|
);
|
|
});
|
|
|
|
test('describes HTML generation step', () => {
|
|
const content = fs.readFileSync(powerWorkflowPath, 'utf8');
|
|
assert.ok(
|
|
content.includes('QUESTIONS.html') || content.includes('.html'),
|
|
'power workflow should describe generating the HTML companion file'
|
|
);
|
|
assert.ok(
|
|
content.includes('HTML') || content.includes('html'),
|
|
'power workflow should mention HTML output'
|
|
);
|
|
});
|
|
|
|
test('QUESTIONS.json file naming uses padded phase number', () => {
|
|
const content = fs.readFileSync(powerWorkflowPath, 'utf8');
|
|
assert.ok(
|
|
content.includes('padded_phase') || content.includes('{padded_phase}') || content.includes('QUESTIONS.json'),
|
|
'power workflow should describe file naming with padded phase number'
|
|
);
|
|
});
|
|
});
|
|
});
|