Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
324 changes: 61 additions & 263 deletions get-shit-done/bin/gsd-tools.cjs

Large diffs are not rendered by default.

118 changes: 118 additions & 0 deletions get-shit-done/bin/lib/command-aliases.generated.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
'use strict';

/**
* GENERATED FILE — state.*, verify.*, init.*, phase.*, phases.*, validate.*, and roadmap.* alias/subcommand metadata for CJS routing.
* Source: sdk/src/query/command-manifest.{state,verify,init,phase,phases,validate,roadmap}.ts
*/

const STATE_COMMAND_ALIASES = [
{ canonical: 'state.load', aliases: [], subcommand: 'load', mutation: false },
{ canonical: 'state.json', aliases: ['state json'], subcommand: 'json', mutation: false },
{ canonical: 'state.get', aliases: ['state get'], subcommand: 'get', mutation: false },
{ canonical: 'state.update', aliases: ['state update'], subcommand: 'update', mutation: true },
{ canonical: 'state.patch', aliases: ['state patch'], subcommand: 'patch', mutation: true },
{ canonical: 'state.begin-phase', aliases: ['state begin-phase'], subcommand: 'begin-phase', mutation: true },
{ canonical: 'state.advance-plan', aliases: ['state advance-plan'], subcommand: 'advance-plan', mutation: true },
{ canonical: 'state.record-metric', aliases: ['state record-metric'], subcommand: 'record-metric', mutation: true },
{ canonical: 'state.update-progress', aliases: ['state update-progress'], subcommand: 'update-progress', mutation: true },
{ canonical: 'state.add-decision', aliases: ['state add-decision'], subcommand: 'add-decision', mutation: true },
{ canonical: 'state.add-blocker', aliases: ['state add-blocker'], subcommand: 'add-blocker', mutation: true },
{ canonical: 'state.resolve-blocker', aliases: ['state resolve-blocker'], subcommand: 'resolve-blocker', mutation: true },
{ canonical: 'state.record-session', aliases: ['state record-session'], subcommand: 'record-session', mutation: true },
{ canonical: 'state.signal-waiting', aliases: ['state signal-waiting'], subcommand: 'signal-waiting', mutation: true },
{ canonical: 'state.signal-resume', aliases: ['state signal-resume'], subcommand: 'signal-resume', mutation: true },
{ canonical: 'state.planned-phase', aliases: ['state planned-phase'], subcommand: 'planned-phase', mutation: true },
{ canonical: 'state.validate', aliases: ['state validate'], subcommand: 'validate', mutation: false },
{ canonical: 'state.sync', aliases: ['state sync'], subcommand: 'sync', mutation: true },
{ canonical: 'state.prune', aliases: ['state prune'], subcommand: 'prune', mutation: true },
{ canonical: 'state.milestone-switch', aliases: ['state milestone-switch'], subcommand: 'milestone-switch', mutation: true },
{ canonical: 'state.add-roadmap-evolution', aliases: ['state add-roadmap-evolution'], subcommand: 'add-roadmap-evolution', mutation: true },
];

const VERIFY_COMMAND_ALIASES = [
{ canonical: 'verify.plan-structure', aliases: ['verify plan-structure'], subcommand: 'plan-structure', mutation: false },
{ canonical: 'verify.phase-completeness', aliases: ['verify phase-completeness'], subcommand: 'phase-completeness', mutation: false },
{ canonical: 'verify.references', aliases: ['verify references'], subcommand: 'references', mutation: false },
{ canonical: 'verify.commits', aliases: ['verify commits'], subcommand: 'commits', mutation: false },
{ canonical: 'verify.artifacts', aliases: ['verify artifacts'], subcommand: 'artifacts', mutation: false },
{ canonical: 'verify.key-links', aliases: ['verify key-links'], subcommand: 'key-links', mutation: false },
{ canonical: 'verify.schema-drift', aliases: ['verify schema-drift'], subcommand: 'schema-drift', mutation: false },
{ canonical: 'verify.codebase-drift', aliases: ['verify codebase-drift'], subcommand: 'codebase-drift', mutation: false },
];

const INIT_COMMAND_ALIASES = [
{ canonical: 'init.execute-phase', aliases: ['init execute-phase'], subcommand: 'execute-phase', mutation: false },
{ canonical: 'init.plan-phase', aliases: ['init plan-phase'], subcommand: 'plan-phase', mutation: false },
{ canonical: 'init.new-project', aliases: ['init new-project'], subcommand: 'new-project', mutation: false },
{ canonical: 'init.new-milestone', aliases: ['init new-milestone'], subcommand: 'new-milestone', mutation: false },
{ canonical: 'init.quick', aliases: ['init quick'], subcommand: 'quick', mutation: false },
{ canonical: 'init.ingest-docs', aliases: ['init ingest-docs'], subcommand: 'ingest-docs', mutation: false },
{ canonical: 'init.resume', aliases: ['init resume'], subcommand: 'resume', mutation: false },
{ canonical: 'init.verify-work', aliases: ['init verify-work'], subcommand: 'verify-work', mutation: false },
{ canonical: 'init.phase-op', aliases: ['init phase-op'], subcommand: 'phase-op', mutation: false },
{ canonical: 'init.todos', aliases: ['init todos'], subcommand: 'todos', mutation: false },
{ canonical: 'init.milestone-op', aliases: ['init milestone-op'], subcommand: 'milestone-op', mutation: false },
{ canonical: 'init.map-codebase', aliases: ['init map-codebase'], subcommand: 'map-codebase', mutation: false },
{ canonical: 'init.progress', aliases: ['init progress'], subcommand: 'progress', mutation: false },
{ canonical: 'init.manager', aliases: ['init manager'], subcommand: 'manager', mutation: false },
{ canonical: 'init.new-workspace', aliases: ['init new-workspace'], subcommand: 'new-workspace', mutation: false },
{ canonical: 'init.list-workspaces', aliases: ['init list-workspaces'], subcommand: 'list-workspaces', mutation: false },
{ canonical: 'init.remove-workspace', aliases: ['init remove-workspace'], subcommand: 'remove-workspace', mutation: false },
];

const PHASE_COMMAND_ALIASES = [
{ canonical: 'phase.list-plans', aliases: ['phase list-plans'], subcommand: 'list-plans', mutation: false },
{ canonical: 'phase.list-artifacts', aliases: ['phase list-artifacts'], subcommand: 'list-artifacts', mutation: false },
{ canonical: 'phase.next-decimal', aliases: ['phase next-decimal'], subcommand: 'next-decimal', mutation: false },
{ canonical: 'phase.add', aliases: ['phase add'], subcommand: 'add', mutation: true },
{ canonical: 'phase.add-batch', aliases: ['phase add-batch'], subcommand: 'add-batch', mutation: true },
{ canonical: 'phase.insert', aliases: ['phase insert'], subcommand: 'insert', mutation: true },
{ canonical: 'phase.remove', aliases: ['phase remove'], subcommand: 'remove', mutation: true },
{ canonical: 'phase.complete', aliases: ['phase complete'], subcommand: 'complete', mutation: true },
{ canonical: 'phase.scaffold', aliases: ['phase scaffold'], subcommand: 'scaffold', mutation: true },
];

const PHASES_COMMAND_ALIASES = [
{ canonical: 'phases.list', aliases: ['phases list'], subcommand: 'list', mutation: false },
{ canonical: 'phases.clear', aliases: ['phases clear'], subcommand: 'clear', mutation: true },
{ canonical: 'phases.archive', aliases: ['phases archive'], subcommand: 'archive', mutation: true },
];

const VALIDATE_COMMAND_ALIASES = [
{ canonical: 'validate.consistency', aliases: ['validate consistency'], subcommand: 'consistency', mutation: false },
{ canonical: 'validate.health', aliases: ['validate health'], subcommand: 'health', mutation: false },
{ canonical: 'validate.agents', aliases: ['validate agents'], subcommand: 'agents', mutation: false },
{ canonical: 'validate.context', aliases: ['validate context'], subcommand: 'context', mutation: false },
];

const ROADMAP_COMMAND_ALIASES = [
{ canonical: 'roadmap.analyze', aliases: ['roadmap analyze'], subcommand: 'analyze', mutation: false },
{ canonical: 'roadmap.get-phase', aliases: ['roadmap get-phase'], subcommand: 'get-phase', mutation: false },
{ canonical: 'roadmap.update-plan-progress', aliases: ['roadmap update-plan-progress'], subcommand: 'update-plan-progress', mutation: true },
{ canonical: 'roadmap.annotate-dependencies', aliases: ['roadmap annotate-dependencies'], subcommand: 'annotate-dependencies', mutation: true },
];

const STATE_SUBCOMMANDS = STATE_COMMAND_ALIASES.map((entry) => entry.subcommand);
const VERIFY_SUBCOMMANDS = VERIFY_COMMAND_ALIASES.map((entry) => entry.subcommand);
const INIT_SUBCOMMANDS = INIT_COMMAND_ALIASES.map((entry) => entry.subcommand);
const PHASE_SUBCOMMANDS = PHASE_COMMAND_ALIASES.map((entry) => entry.subcommand);
const PHASES_SUBCOMMANDS = PHASES_COMMAND_ALIASES.map((entry) => entry.subcommand);
const VALIDATE_SUBCOMMANDS = VALIDATE_COMMAND_ALIASES.map((entry) => entry.subcommand);
const ROADMAP_SUBCOMMANDS = ROADMAP_COMMAND_ALIASES.map((entry) => entry.subcommand);

module.exports = {
STATE_COMMAND_ALIASES,
VERIFY_COMMAND_ALIASES,
INIT_COMMAND_ALIASES,
PHASE_COMMAND_ALIASES,
PHASES_COMMAND_ALIASES,
VALIDATE_COMMAND_ALIASES,
ROADMAP_COMMAND_ALIASES,
STATE_SUBCOMMANDS,
VERIFY_SUBCOMMANDS,
INIT_SUBCOMMANDS,
PHASE_SUBCOMMANDS,
PHASES_SUBCOMMANDS,
VALIDATE_SUBCOMMANDS,
ROADMAP_SUBCOMMANDS,
};
68 changes: 68 additions & 0 deletions get-shit-done/bin/lib/init-command-router.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
'use strict';

function routeInitCommand({ init, args, cwd, raw, parseNamedArgs, error }) {
const workflow = args[1];
switch (workflow) {
case 'execute-phase': {
const { validate: epValidate, tdd: epTdd } = parseNamedArgs(args, [], ['validate', 'tdd']);
init.cmdInitExecutePhase(cwd, args[2], raw, { validate: epValidate, tdd: epTdd });
break;
}
case 'plan-phase': {
const { validate: ppValidate, tdd: ppTdd } = parseNamedArgs(args, [], ['validate', 'tdd']);
init.cmdInitPlanPhase(cwd, args[2], raw, { validate: ppValidate, tdd: ppTdd });
break;
}
case 'new-project':
init.cmdInitNewProject(cwd, raw);
break;
case 'new-milestone':
init.cmdInitNewMilestone(cwd, raw);
break;
case 'quick':
init.cmdInitQuick(cwd, args.slice(2).join(' '), raw);
break;
case 'ingest-docs':
init.cmdInitIngestDocs(cwd, raw);
break;
case 'resume':
init.cmdInitResume(cwd, raw);
break;
case 'verify-work':
init.cmdInitVerifyWork(cwd, args[2], raw);
break;
case 'phase-op':
init.cmdInitPhaseOp(cwd, args[2], raw);
break;
case 'todos':
init.cmdInitTodos(cwd, args[2], raw);
break;
case 'milestone-op':
init.cmdInitMilestoneOp(cwd, raw);
break;
case 'map-codebase':
init.cmdInitMapCodebase(cwd, raw);
break;
case 'progress':
init.cmdInitProgress(cwd, raw);
break;
case 'manager':
init.cmdInitManager(cwd, raw);
break;
case 'new-workspace':
init.cmdInitNewWorkspace(cwd, raw);
break;
case 'list-workspaces':
init.cmdInitListWorkspaces(cwd, raw);
break;
case 'remove-workspace':
init.cmdInitRemoveWorkspace(cwd, args[2], raw);
break;
default:
error(`Unknown init workflow: ${workflow}\nAvailable: execute-phase, plan-phase, new-project, new-milestone, quick, ingest-docs, resume, verify-work, phase-op, todos, milestone-op, map-codebase, progress, manager, new-workspace, list-workspaces, remove-workspace`);
}
}

module.exports = {
routeInitCommand,
};
49 changes: 49 additions & 0 deletions get-shit-done/bin/lib/phase-command-router.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
'use strict';

const { PHASE_SUBCOMMANDS } = require('./command-aliases.generated.cjs');

function routePhaseCommand({ phase, args, cwd, raw, error }) {
const subcommand = args[1];

if (subcommand === 'next-decimal') {
phase.cmdPhaseNextDecimal(cwd, args[2], raw);
} else if (subcommand === 'add') {
let customId = null;
const descArgs = [];
for (let i = 2; i < args.length; i++) {
if (args[i] === '--id' && i + 1 < args.length) {
customId = args[i + 1];
i++;
} else {
descArgs.push(args[i]);
}
}
phase.cmdPhaseAdd(cwd, descArgs.join(' '), raw, customId);
} else if (subcommand === 'add-batch') {
const descFlagIdx = args.indexOf('--descriptions');
let descriptions;
if (descFlagIdx !== -1 && args[descFlagIdx + 1]) {
try {
descriptions = JSON.parse(args[descFlagIdx + 1]);
} catch {
error('--descriptions must be a JSON array');
}
} else {
descriptions = args.slice(2).filter(a => a !== '--raw');
}
phase.cmdPhaseAddBatch(cwd, descriptions, raw);
} else if (subcommand === 'insert') {
phase.cmdPhaseInsert(cwd, args[2], args.slice(3).join(' '), raw);
} else if (subcommand === 'remove') {
const forceFlag = args.includes('--force');
phase.cmdPhaseRemove(cwd, args[2], { force: forceFlag }, raw);
} else if (subcommand === 'complete') {
phase.cmdPhaseComplete(cwd, args[2], raw);
} else {
error(`Unknown phase subcommand. Available: ${PHASE_SUBCOMMANDS.filter((s) => s !== 'list-plans' && s !== 'list-artifacts' && s !== 'scaffold').join(', ')}`);
}
}

module.exports = {
routePhaseCommand,
};
30 changes: 30 additions & 0 deletions get-shit-done/bin/lib/phases-command-router.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
'use strict';

/**
* Manifest-backed phases subcommand router.
* Keeps gsd-tools.cjs thin while preserving current CJS semantics:
* - list
* - clear
*/
function routePhasesCommand({ phase, milestone, args, cwd, raw, error }) {
const subcommand = args[1];

if (subcommand === 'list') {
const typeIndex = args.indexOf('--type');
const phaseIndex = args.indexOf('--phase');
const options = {
type: typeIndex !== -1 ? args[typeIndex + 1] : null,
phase: phaseIndex !== -1 ? args[phaseIndex + 1] : null,
includeArchived: args.includes('--include-archived'),
};
phase.cmdPhasesList(cwd, options, raw);
} else if (subcommand === 'clear') {
milestone.cmdPhasesClear(cwd, raw, args.slice(2));
} else {
error('Unknown phases subcommand. Available: list, clear');
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

phases.archive is missing from the CJS router.

This router only recognizes list and clear, but the migrated phases family also registers archive in sdk/src/query/index.ts Lines 459-463. gsd-tools phases archive ... will fall into the unknown-subcommand path even though the manifest-backed SDK treats it as supported.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@get-shit-done/bin/lib/phases-command-router.cjs` around lines 12 - 24, The
router only handles 'list' and 'clear' so 'archive' falls through; add an
else-if branch for subcommand === 'archive' that calls the archive handler on
the same object used for list (e.g. phase.cmdPhasesArchive) with the same
arguments pattern (cwd, raw and any remaining args as appropriate—likely
args.slice(2) or the options pattern used for list), so that 'phases archive' is
routed to phase.cmdPhasesArchive instead of hitting the unknown-subcommand
error.

}
}

module.exports = {
routePhasesCommand,
};
23 changes: 23 additions & 0 deletions get-shit-done/bin/lib/roadmap-command-router.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
'use strict';

const { ROADMAP_SUBCOMMANDS } = require('./command-aliases.generated.cjs');

function routeRoadmapCommand({ roadmap, args, cwd, raw, error }) {
const subcommand = args[1];

if (subcommand === 'get-phase') {
roadmap.cmdRoadmapGetPhase(cwd, args[2], raw);
} else if (subcommand === 'analyze') {
roadmap.cmdRoadmapAnalyze(cwd, raw);
} else if (subcommand === 'update-plan-progress') {
roadmap.cmdRoadmapUpdatePlanProgress(cwd, args[2], raw);
} else if (subcommand === 'annotate-dependencies') {
roadmap.cmdRoadmapAnnotateDependencies(cwd, args[2], raw);
} else {
error(`Unknown roadmap subcommand. Available: ${ROADMAP_SUBCOMMANDS.join(', ')}`);
}
}

module.exports = {
routeRoadmapCommand,
};
79 changes: 79 additions & 0 deletions get-shit-done/bin/lib/state-command-router.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
'use strict';

const { STATE_SUBCOMMANDS } = require('./command-aliases.generated.cjs');

/**
* Manifest-backed state subcommand router.
* Keeps gsd-tools.cjs thin while preserving existing command semantics.
*/
function routeStateCommand({ state, args, cwd, raw, parseNamedArgs, error }) {
const subcommand = args[1];

if (subcommand === 'json') {
state.cmdStateJson(cwd, raw);
} else if (subcommand === 'update') {
state.cmdStateUpdate(cwd, args[2], args[3]);
} else if (subcommand === 'get') {
state.cmdStateGet(cwd, args[2], raw);
Comment on lines +16 to +17
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🔴 Critical | ⚡ Quick win

state.get looks like a runtime crash path.

Line 17 calls state.cmdStateGet(...), but the provided get-shit-done/bin/lib/state.cjs export list does not include cmdStateGet. If gsd-tools.cjs passes that module through, state get will throw instead of dispatching.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@get-shit-done/bin/lib/state-command-router.cjs` around lines 16 - 17, The
router calls state.cmdStateGet which isn't exported from the state module and
will crash at runtime; fix by either exporting the handler named cmdStateGet
from the state module (add cmdStateGet to the module's export list and ensure
the function exists) or change the router to call the actual exported symbol
(e.g., state.get or state.cmdGet) that implements the "get" behavior so the name
used in the call matches an exported function.

} else if (subcommand === 'patch') {
const patches = {};
for (let i = 2; i < args.length; i += 2) {
const key = args[i].replace(/^--/, '');
const value = args[i + 1];
if (key && value !== undefined) {
patches[key] = value;
}
}
state.cmdStatePatch(cwd, patches, raw);
} else if (subcommand === 'advance-plan') {
state.cmdStateAdvancePlan(cwd, raw);
} else if (subcommand === 'record-metric') {
const { phase: p, plan, duration, tasks, files } = parseNamedArgs(args, ['phase', 'plan', 'duration', 'tasks', 'files']);
state.cmdStateRecordMetric(cwd, { phase: p, plan, duration, tasks, files }, raw);
} else if (subcommand === 'update-progress') {
state.cmdStateUpdateProgress(cwd, raw);
} else if (subcommand === 'add-decision') {
const { phase: p, summary, 'summary-file': summary_file, rationale, 'rationale-file': rationale_file } = parseNamedArgs(args, ['phase', 'summary', 'summary-file', 'rationale', 'rationale-file']);
state.cmdStateAddDecision(cwd, { phase: p, summary, summary_file, rationale: rationale || '', rationale_file }, raw);
} else if (subcommand === 'add-blocker') {
const { text, 'text-file': text_file } = parseNamedArgs(args, ['text', 'text-file']);
state.cmdStateAddBlocker(cwd, { text, text_file }, raw);
} else if (subcommand === 'resolve-blocker') {
state.cmdStateResolveBlocker(cwd, parseNamedArgs(args, ['text']).text, raw);
} else if (subcommand === 'record-session') {
const { 'stopped-at': stopped_at, 'resume-file': resume_file } = parseNamedArgs(args, ['stopped-at', 'resume-file']);
state.cmdStateRecordSession(cwd, { stopped_at, resume_file: resume_file || 'None' }, raw);
} else if (subcommand === 'begin-phase') {
const { phase: p, name, plans } = parseNamedArgs(args, ['phase', 'name', 'plans']);
state.cmdStateBeginPhase(cwd, p, name, plans !== null ? parseInt(plans, 10) : null, raw);
} else if (subcommand === 'signal-waiting') {
const { type, question, options, phase: p } = parseNamedArgs(args, ['type', 'question', 'options', 'phase']);
state.cmdSignalWaiting(cwd, type, question, options, p, raw);
} else if (subcommand === 'signal-resume') {
state.cmdSignalResume(cwd, raw);
} else if (subcommand === 'planned-phase') {
const { phase: p, plans } = parseNamedArgs(args, ['phase', 'name', 'plans']);
state.cmdStatePlannedPhase(cwd, p, plans !== null ? parseInt(plans, 10) : null, raw);
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Outdated
} else if (subcommand === 'validate') {
state.cmdStateValidate(cwd, raw);
} else if (subcommand === 'sync') {
const { verify } = parseNamedArgs(args, [], ['verify']);
state.cmdStateSync(cwd, { verify }, raw);
} else if (subcommand === 'prune') {
const { 'keep-recent': keepRecent, 'dry-run': dryRun } = parseNamedArgs(args, ['keep-recent'], ['dry-run']);
state.cmdStatePrune(cwd, { keepRecent: keepRecent || '3', dryRun: !!dryRun }, raw);
} else if (subcommand === 'complete-phase') {
state.cmdStateCompletePhase(cwd, raw);
} else if (subcommand === 'milestone-switch') {
const { milestone, name } = parseNamedArgs(args, ['milestone', 'name']);
state.cmdStateMilestoneSwitch(cwd, milestone, name, raw);
} else if (subcommand === undefined || subcommand === 'load') {
state.cmdStateLoad(cwd, raw);
} else {
error(`Unknown state subcommand: "${subcommand}". Available: ${['load', ...STATE_SUBCOMMANDS.filter((s) => s !== 'load')].join(', ')}`);
}
Comment on lines +75 to +85
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

state.add-roadmap-evolution is advertised but unreachable here.

The generated STATE_SUBCOMMANDS set already includes add-roadmap-evolution, and the SDK registry wires state.add-roadmap-evolution, but this router falls straight to the unknown-subcommand branch. That breaks the manifest-backed parity this PR is introducing.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@get-shit-done/bin/lib/state-command-router.cjs` around lines 67 - 74, The
router fails to handle the advertised "add-roadmap-evolution" subcommand,
falling through to the unknown-subcommand error; add a branch for subcommand ===
'add-roadmap-evolution' (alongside the existing 'milestone-switch' and 'load'
branches) and invoke the matching SDK handler (e.g., call
state.cmdStateAddRoadmapEvolution with the appropriate parsed args or raw
input), or parse required named args via parseNamedArgs and forward them to
state.cmdStateAddRoadmapEvolution(cwd, ...); ensure the subcommand string
matches the entry in STATE_SUBCOMMANDS so manifest-backed parity is restored.

}

module.exports = {
routeStateCommand,
};
Loading
Loading