refactor(#189): retire generated cjs artifacts from bin/lib

This commit is contained in:
Tom Boucher
2026-05-25 09:54:50 -04:00
parent 5a6ff5f81f
commit 30c572e537
40 changed files with 635 additions and 984 deletions

View File

@@ -7,7 +7,7 @@
* I001 canonicalPlanStem.
*
* After the generator migration, all three helpers are sourced from
* validate.generated.cjs. If they diverge from validate.ts, these
* validate.cjs. If they diverge from validate.ts, these
* tests go RED.
*
* References:
@@ -62,7 +62,7 @@ function writeConfigJson(planningDir) {
// node .claude/get-shit-done/bin/gsd-tools.cjs validate health
// # Bug: emits W005 about 999.1-foo not following NN-name format
//
// verify.cjs must consume phaseDirNameRe from validate.generated.cjs so
// verify.cjs must consume phaseDirNameRe from validate.cjs so
// the regex /^\d{2,}(?:\.\d+)*-[\w-]+$/ is the single source of truth.
describe('Drift item W005 — phaseDirNameRe: 999.X-name dirs must not trigger W005', () => {
@@ -95,10 +95,10 @@ describe('Drift item W005 — phaseDirNameRe: 999.X-name dirs must not trigger W
`Expected zero W005 for 999.1-foo, got: ${JSON.stringify(w005)}`);
});
test('phaseDirNameRe is exported from validate.generated.cjs', () => {
const gen = require('../get-shit-done/bin/lib/validate.generated.cjs');
test('phaseDirNameRe is exported from validate.cjs', () => {
const gen = require('../get-shit-done/bin/lib/validate.cjs');
assert.ok(gen.phaseDirNameRe instanceof RegExp,
'validate.generated.cjs must export phaseDirNameRe as a RegExp');
'validate.cjs must export phaseDirNameRe as a RegExp');
const re = gen.phaseDirNameRe;
assert.ok(re.test('01-setup'), 'should accept 01-setup');
assert.ok(re.test('999-longphase'), 'should accept 999-longphase (3-digit prefix)');
@@ -110,7 +110,7 @@ describe('Drift item W005 — phaseDirNameRe: 999.X-name dirs must not trigger W
// ── Drift Item W006-archived: PHASE_TOKEN_FROM_DIR_RE / MILESTONE_ARCHIVE_DIR_RE ─
//
// forEachArchivedPhaseToken() in verify.cjs uses two inline regex constants.
// After migration both are sourced from validate.generated.cjs:
// After migration both are sourced from validate.cjs:
// PHASE_TOKEN_FROM_DIR_RE — extracts token from dir name like "64-auth-service"
// MILESTONE_ARCHIVE_DIR_RE — matches archive dirs like "v1.0-phases"
//
@@ -173,9 +173,9 @@ describe('Drift item W006-archived — MILESTONE_ARCHIVE_DIR_RE and PHASE_TOKEN_
});
test('MILESTONE_ARCHIVE_DIR_RE is exported and matches vN.N-phases dirs', () => {
const gen = require('../get-shit-done/bin/lib/validate.generated.cjs');
const gen = require('../get-shit-done/bin/lib/validate.cjs');
assert.ok(gen.MILESTONE_ARCHIVE_DIR_RE instanceof RegExp,
'validate.generated.cjs must export MILESTONE_ARCHIVE_DIR_RE');
'validate.cjs must export MILESTONE_ARCHIVE_DIR_RE');
const re = gen.MILESTONE_ARCHIVE_DIR_RE;
assert.ok(re.test('v1.0-phases'), 'should match v1.0-phases');
assert.ok(re.test('v1.10-phases'), 'should match v1.10-phases');
@@ -184,9 +184,9 @@ describe('Drift item W006-archived — MILESTONE_ARCHIVE_DIR_RE and PHASE_TOKEN_
});
test('PHASE_TOKEN_FROM_DIR_RE is exported and extracts phase tokens correctly', () => {
const gen = require('../get-shit-done/bin/lib/validate.generated.cjs');
const gen = require('../get-shit-done/bin/lib/validate.cjs');
assert.ok(gen.PHASE_TOKEN_FROM_DIR_RE instanceof RegExp,
'validate.generated.cjs must export PHASE_TOKEN_FROM_DIR_RE');
'validate.cjs must export PHASE_TOKEN_FROM_DIR_RE');
const re = gen.PHASE_TOKEN_FROM_DIR_RE;
assert.strictEqual(re.exec('64-auth-service')?.[1], '64');
assert.strictEqual(re.exec('03B-feature')?.[1], '03B');
@@ -199,7 +199,7 @@ describe('Drift item W006-archived — MILESTONE_ARCHIVE_DIR_RE and PHASE_TOKEN_
//
// validate.ts Check 7: canonicalPlanStem('68-01-scaffolding') → '68-01'
// verify.cjs had an inline copy. After migration, canonicalPlanStem is
// sourced from validate.generated.cjs.
// sourced from validate.cjs.
//
// Test: "68-01-scaffolding-PLAN.md" + "68-01-SUMMARY.md" → no I001
// Both stems canonicalize to "68-01" → match found → I001 suppressed.
@@ -238,10 +238,10 @@ describe('Drift item I001 — canonicalPlanStem: long PLAN stem matches short SU
`Expected zero I001, got: ${JSON.stringify(i001)}`);
});
test('canonicalPlanStem is exported from validate.generated.cjs', () => {
const gen = require('../get-shit-done/bin/lib/validate.generated.cjs');
test('canonicalPlanStem is exported from validate.cjs', () => {
const gen = require('../get-shit-done/bin/lib/validate.cjs');
assert.strictEqual(typeof gen.canonicalPlanStem, 'function',
'validate.generated.cjs must export canonicalPlanStem as a function');
'validate.cjs must export canonicalPlanStem as a function');
assert.strictEqual(gen.canonicalPlanStem('68-01-scaffolding'), '68-01');
assert.strictEqual(gen.canonicalPlanStem('68-01'), '68-01');
assert.strictEqual(gen.canonicalPlanStem('3A-01-feature'), '3A-01');

View File

@@ -1,5 +1,5 @@
/**
* Regression test for #3571: configuration.generated.cjs used the source
* Regression test for #3571: configuration.cjs used the source
* checkout sdk/shared path only, which breaks installed gsd-tools.cjs because
* runtime installs copy get-shit-done/ but not sdk/.
*/
@@ -15,7 +15,7 @@ const os = require('node:os');
const path = require('node:path');
const REPO_ROOT = path.join(__dirname, '..');
const CONFIGURATION_CJS = path.join(REPO_ROOT, 'get-shit-done', 'bin', 'lib', 'configuration.generated.cjs');
const CONFIGURATION_CJS = path.join(REPO_ROOT, 'get-shit-done', 'bin', 'lib', 'configuration.cjs');
const SDK_SHARED_DIR = path.join(REPO_ROOT, 'sdk', 'shared');
const { install } = require('../bin/install.js');
@@ -68,14 +68,14 @@ describe('bug #3571: configuration generated manifests resolve in install layout
fs.rmSync(tmpRoot, { recursive: true, force: true, maxRetries: 10, retryDelay: 100 });
});
test('co-located bin/shared manifests let configuration.generated.cjs load without sdk/shared', () => {
test('co-located bin/shared manifests let configuration.cjs load without sdk/shared', () => {
const gsdBinDir = path.join(tmpRoot, '.codex', 'get-shit-done', 'bin');
const gsdLibDir = path.join(gsdBinDir, 'lib');
const gsdSharedDir = path.join(gsdBinDir, 'shared');
fs.mkdirSync(gsdLibDir, { recursive: true });
fs.mkdirSync(gsdSharedDir, { recursive: true });
const installedCjs = path.join(gsdLibDir, 'configuration.generated.cjs');
const installedCjs = path.join(gsdLibDir, 'configuration.cjs');
fs.copyFileSync(CONFIGURATION_CJS, installedCjs);
fs.copyFileSync(
path.join(SDK_SHARED_DIR, 'config-defaults.manifest.json'),
@@ -90,7 +90,7 @@ describe('bug #3571: configuration generated manifests resolve in install layout
let mod;
assert.doesNotThrow(() => {
mod = require(installedCjs);
}, 'installed configuration.generated.cjs must not require ~/.codex/sdk/shared');
}, 'installed configuration.cjs must not require ~/.codex/sdk/shared');
assert.ok(mod.VALID_CONFIG_KEYS.has('workflow.plan_review_convergence'));
});
@@ -118,12 +118,12 @@ describe('bug #3571: configuration generated manifests resolve in install layout
'get-shit-done',
'bin',
'lib',
'configuration.generated.cjs'
'configuration.cjs'
);
delete require.cache[installedCjs];
assert.doesNotThrow(() => {
require(installedCjs);
}, 'post-install configuration.generated.cjs must load from co-located manifests');
}, 'post-install configuration.cjs must load from co-located manifests');
});
});

View File

@@ -1,7 +1,7 @@
'use strict';
/**
* Regression guard for issue #3251:
* 14 commands used in workflows must be present in command-aliases.generated.cjs.
* 14 commands used in workflows must be present in command-aliases.cjs.
*
* Asserts structurally by requiring the manifest and checking each canonical
* command appears in either the family arrays or the non-family array.
@@ -22,7 +22,7 @@ const COMMAND_ALIASES_FILE = path.join(
'get-shit-done',
'bin',
'lib',
'command-aliases.generated.cjs',
'command-aliases.cjs',
);
const GSD_TOOLS = path.join(REPO_ROOT, 'get-shit-done', 'bin', 'gsd-tools.cjs');
@@ -43,7 +43,7 @@ const MISSING_14 = [
'workstream.list',
];
describe('feat-3251: command-aliases.generated.cjs manifest coverage', () => {
describe('feat-3251: command-aliases.cjs manifest coverage', () => {
let manifest;
test('manifest file can be required without error', () => {
@@ -59,7 +59,7 @@ describe('feat-3251: command-aliases.generated.cjs manifest coverage', () => {
manifest = manifest ?? require(COMMAND_ALIASES_FILE);
assert.ok(
Array.isArray(manifest.NON_FAMILY_COMMAND_ALIASES),
'NON_FAMILY_COMMAND_ALIASES must be an exported array in command-aliases.generated.cjs',
'NON_FAMILY_COMMAND_ALIASES must be an exported array in command-aliases.cjs',
);
});

View File

@@ -26,7 +26,7 @@ const {
const {
CONFIG_DEFAULTS: CANONICAL_CONFIG_DEFAULTS,
} = require('../get-shit-done/bin/lib/configuration.generated.cjs');
} = require('../get-shit-done/bin/lib/configuration.cjs');
const {
makeStatusProject,

View File

@@ -14,7 +14,7 @@ const path = require('path');
const REPO_ROOT = path.join(__dirname, '..');
const REGISTRY_FILE = path.join(REPO_ROOT, 'sdk', 'src', 'query', 'registry-assembly.ts');
const COMMAND_ALIASES_FILE = path.join(REPO_ROOT, 'get-shit-done', 'bin', 'lib', 'command-aliases.generated.cjs');
const COMMAND_ALIASES_FILE = path.join(REPO_ROOT, 'get-shit-done', 'bin', 'lib', 'command-aliases.cjs');
// Prose tokens that repeatedly appear after `gsd-sdk query` in English
// documentation but aren't real command names.