* 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>
206 lines
8.4 KiB
JavaScript
206 lines
8.4 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-ultraplan-phase [BETA] Tests
|
|
*
|
|
* Structural assertions for the ultraplan-phase command and workflow files.
|
|
* This command offloads GSD plan phase to Claude Code's ultraplan cloud infrastructure.
|
|
*/
|
|
|
|
'use strict';
|
|
|
|
const { describe, test } = require('node:test');
|
|
const assert = require('node:assert/strict');
|
|
const fs = require('fs');
|
|
const path = require('path');
|
|
|
|
const CMD_PATH = path.join(__dirname, '..', 'commands', 'gsd', 'ultraplan-phase.md');
|
|
const WF_PATH = path.join(__dirname, '..', 'get-shit-done', 'workflows', 'ultraplan-phase.md');
|
|
|
|
// ─── File Existence ────────────────────────────────────────────────────────────
|
|
|
|
describe('ultraplan-phase file existence', () => {
|
|
test('command file exists', () => {
|
|
assert.ok(fs.existsSync(CMD_PATH), 'commands/gsd/ultraplan-phase.md should exist');
|
|
});
|
|
|
|
test('workflow file exists', () => {
|
|
assert.ok(fs.existsSync(WF_PATH), 'get-shit-done/workflows/ultraplan-phase.md should exist');
|
|
});
|
|
});
|
|
|
|
// ─── Command Frontmatter ───────────────────────────────────────────────────────
|
|
|
|
describe('ultraplan-phase command frontmatter', () => {
|
|
const content = fs.readFileSync(CMD_PATH, 'utf-8');
|
|
|
|
test('has correct name field', () => {
|
|
assert.match(content, /^name:\s*gsd:ultraplan-phase$/m);
|
|
});
|
|
|
|
test('description marks feature as BETA', () => {
|
|
assert.match(content, /^description:.*\[BETA\]/m);
|
|
});
|
|
|
|
test('has argument-hint', () => {
|
|
assert.match(content, /^argument-hint:/m);
|
|
});
|
|
});
|
|
|
|
// ─── Command References ────────────────────────────────────────────────────────
|
|
|
|
describe('ultraplan-phase command references', () => {
|
|
const content = fs.readFileSync(CMD_PATH, 'utf-8');
|
|
|
|
test('references the ultraplan-phase workflow', () => {
|
|
assert.ok(
|
|
content.includes('@~/.claude/get-shit-done/workflows/ultraplan-phase.md'),
|
|
'command should reference ultraplan-phase workflow'
|
|
);
|
|
});
|
|
|
|
test('references ui-brand', () => {
|
|
assert.ok(content.includes('ui-brand'), 'command should reference ui-brand');
|
|
});
|
|
});
|
|
|
|
// ─── Workflow: Beta Marker ─────────────────────────────────────────────────────
|
|
|
|
describe('ultraplan-phase workflow beta marker', () => {
|
|
const content = fs.readFileSync(WF_PATH, 'utf-8');
|
|
|
|
test('workflow displays a BETA warning', () => {
|
|
assert.ok(content.includes('BETA') || content.includes('beta'), 'workflow should display a BETA warning');
|
|
});
|
|
|
|
test('workflow notes ultraplan is in research preview', () => {
|
|
assert.ok(content.includes('research preview') || content.includes('preview'), 'workflow should note ultraplan is in research preview');
|
|
});
|
|
});
|
|
|
|
// ─── Workflow: Runtime Gate ────────────────────────────────────────────────────
|
|
|
|
describe('ultraplan-phase workflow runtime gate', () => {
|
|
const content = fs.readFileSync(WF_PATH, 'utf-8');
|
|
|
|
test('checks Claude Code runtime markers instead of version env var', () => {
|
|
assert.ok(
|
|
content.includes('CLAUDECODE') || content.includes('CLAUDE_CODE_ENTRYPOINT'),
|
|
'workflow must gate on Claude Code runtime marker env vars'
|
|
);
|
|
assert.ok(
|
|
!content.includes('CLAUDE_CODE_VERSION'),
|
|
'workflow must not gate on CLAUDE_CODE_VERSION'
|
|
);
|
|
});
|
|
|
|
test('error message references /gsd-plan-phase as local alternative', () => {
|
|
assert.ok(
|
|
content.includes('gsd:plan-phase') || content.includes('gsd-plan-phase'),
|
|
'error message should direct users to /gsd-plan-phase as the local alternative'
|
|
);
|
|
});
|
|
});
|
|
|
|
// ─── Workflow: Initialization ──────────────────────────────────────────────────
|
|
|
|
describe('ultraplan-phase workflow initialization', () => {
|
|
const content = fs.readFileSync(WF_PATH, 'utf-8');
|
|
|
|
test('loads GSD phase context via gsd-sdk query init.plan-phase', () => {
|
|
// After #3797 architectural fix, callsites use gsd_run
|
|
assert.ok(
|
|
content.includes('gsd_run query init.plan-phase'),
|
|
'workflow must load phase context via gsd_run query init.plan-phase',
|
|
);
|
|
});
|
|
|
|
test('handles missing .planning directory', () => {
|
|
assert.ok(
|
|
content.includes('gsd-new-project') || content.includes('/gsd-new-project') || content.includes('gsd:new-project'),
|
|
'workflow should direct user to /gsd-new-project when .planning is missing'
|
|
);
|
|
});
|
|
});
|
|
|
|
// ─── Workflow: Ultraplan Prompt ────────────────────────────────────────────────
|
|
|
|
describe('ultraplan-phase workflow prompt construction', () => {
|
|
const content = fs.readFileSync(WF_PATH, 'utf-8');
|
|
|
|
test('includes phase scope from ROADMAP in ultraplan prompt', () => {
|
|
assert.ok(
|
|
content.includes('ROADMAP') || content.includes('phase scope') || content.includes('phase_name'),
|
|
'workflow should include phase scope from ROADMAP.md in the ultraplan prompt'
|
|
);
|
|
});
|
|
|
|
test('includes REQUIREMENTS context in ultraplan prompt', () => {
|
|
assert.ok(content.includes('REQUIREMENTS'), 'workflow should include requirements context in the ultraplan prompt');
|
|
});
|
|
|
|
test('includes existing RESEARCH when available', () => {
|
|
assert.ok(
|
|
content.includes('RESEARCH') || content.includes('research_path'),
|
|
'workflow should include existing research in the ultraplan prompt'
|
|
);
|
|
});
|
|
});
|
|
|
|
// ─── Workflow: Ultraplan Trigger ───────────────────────────────────────────────
|
|
|
|
describe('ultraplan-phase workflow ultraplan trigger', () => {
|
|
const content = fs.readFileSync(WF_PATH, 'utf-8');
|
|
|
|
test('triggers /ultraplan command', () => {
|
|
assert.ok(content.includes('/ultraplan'), 'workflow must trigger /ultraplan');
|
|
});
|
|
});
|
|
|
|
// ─── Workflow: Return Path Instructions ───────────────────────────────────────
|
|
|
|
describe('ultraplan-phase workflow return path', () => {
|
|
const content = fs.readFileSync(WF_PATH, 'utf-8');
|
|
|
|
test('instructs user to choose Cancel to save plan to file', () => {
|
|
assert.ok(content.includes('Cancel'), 'workflow must instruct user to choose Cancel to save the plan to a file');
|
|
});
|
|
|
|
test('directs user to run /gsd-import --from after ultraplan completes', () => {
|
|
assert.ok(content.includes('gsd-import') || content.includes('gsd:import'), 'workflow must direct user to run /gsd:import --from with the saved file path');
|
|
});
|
|
|
|
test('mentions the --from flag for gsd-import', () => {
|
|
assert.ok(content.includes('--from'), 'workflow should reference /gsd-import --from <file-path>');
|
|
});
|
|
|
|
test('return-path instructions appear before the /ultraplan trigger', () => {
|
|
const ultraplanTriggerIndex = content.indexOf('/ultraplan');
|
|
const importIndex = content.indexOf('gsd-import');
|
|
assert.ok(
|
|
importIndex < ultraplanTriggerIndex,
|
|
'return-path instructions (gsd-import) must appear before /ultraplan trigger so they are visible in scroll-back'
|
|
);
|
|
});
|
|
});
|
|
|
|
// ─── Workflow: Isolation from Core Pipeline ────────────────────────────────────
|
|
|
|
describe('ultraplan-phase workflow isolation', () => {
|
|
const content = fs.readFileSync(WF_PATH, 'utf-8');
|
|
|
|
test('does NOT directly write PLAN.md files', () => {
|
|
assert.ok(
|
|
!content.includes('write PLAN.md') && !content.includes('Write(\'.planning'),
|
|
'workflow must NOT directly write PLAN.md — delegates to /gsd-import --from'
|
|
);
|
|
});
|
|
|
|
test('does NOT reference ultrareview', () => {
|
|
assert.ok(!content.includes('ultrareview'), 'workflow must not reference ultrareview');
|
|
});
|
|
});
|