* refactor: tighten sdk-first architecture seams Refs #3312 * refactor: finish state document seam cleanup Refs #3312 * test: harden minimal install cleanup assertion * ci: support sdk-scoped package lock * fix(3316): restore root package-lock.json and align changeset pr ref Reverts dec57a83 ("ci: support sdk-scoped package lock") and restores the root package-lock.json that c249d34d deleted. The deletion was the wrong direction: - The root package.json declares its own runtime and dev deps (@anthropic-ai/claude-agent-sdk, ws, c8). Without a root lockfile, `npm install --no-package-lock` resolves whatever satisfies semver at install time — CI today and CI in six months can install different transitive trees, defeating reproducibility. - The lockfile has been part of every release on this repo (long history on main); removing it loses the npm audit / Dependabot target without compensating benefit. - The CI workaround pattern (cache-dependency-path: sdk/package-lock.json + `npm install --no-package-lock`) papered over the symptom rather than fix the cause. Also fix the changeset pr: from 3312 (issue) to 3316 (PR). CONTEXT.md flags this exact failure mode as a recurring CodeRabbit finding. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * fix: address coderabbit review findings * fix: close remaining coderabbit threads --------- Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
78 lines
2.7 KiB
JavaScript
78 lines
2.7 KiB
JavaScript
'use strict';
|
|
|
|
const { PHASE_SUBCOMMANDS } = require('./command-aliases.generated.cjs');
|
|
const { routeCjsCommandFamily } = require('./cjs-command-router-adapter.cjs');
|
|
|
|
function routePhaseCommand({ phase, args, cwd, raw, error }) {
|
|
routeCjsCommandFamily({
|
|
args,
|
|
subcommands: PHASE_SUBCOMMANDS,
|
|
unsupported: {
|
|
'list-plans': 'phase list-plans is SDK-only. Use: gsd-sdk query phase.list-plans ...',
|
|
'list-artifacts': 'phase list-artifacts is SDK-only. Use: gsd-sdk query phase.list-artifacts ...',
|
|
scaffold: 'phase scaffold is routed through the top-level scaffold command.',
|
|
},
|
|
error,
|
|
unknownMessage: (_subcommand, available) => `Unknown phase subcommand. Available: ${available.join(', ')}`,
|
|
handlers: {
|
|
'next-decimal': () => phase.cmdPhaseNextDecimal(cwd, args[2], raw),
|
|
add: () => {
|
|
let customId = null;
|
|
const descArgs = [];
|
|
for (let i = 2; i < args.length; i++) {
|
|
const token = args[i];
|
|
if (token === '--raw') {
|
|
continue;
|
|
}
|
|
if (token === '--id') {
|
|
const id = args[i + 1];
|
|
if (!id || id.startsWith('--')) {
|
|
error('--id requires a value');
|
|
}
|
|
customId = id;
|
|
i++;
|
|
} else if (token.startsWith('--')) {
|
|
error(`phase add does not support ${token}`);
|
|
} else {
|
|
descArgs.push(token);
|
|
}
|
|
}
|
|
phase.cmdPhaseAdd(cwd, descArgs.join(' '), raw, customId);
|
|
},
|
|
'add-batch': () => {
|
|
const descFlagIdx = args.indexOf('--descriptions');
|
|
let descriptions;
|
|
if (descFlagIdx !== -1) {
|
|
const rawDescriptions = args[descFlagIdx + 1];
|
|
if (!rawDescriptions || rawDescriptions.startsWith('--')) {
|
|
error('--descriptions must be a JSON array');
|
|
}
|
|
try {
|
|
descriptions = JSON.parse(rawDescriptions);
|
|
} catch {
|
|
error('--descriptions must be a JSON array');
|
|
}
|
|
if (!Array.isArray(descriptions)) {
|
|
error('--descriptions must be a JSON array');
|
|
}
|
|
} else {
|
|
descriptions = args.slice(2).filter(a => a !== '--raw');
|
|
}
|
|
phase.cmdPhaseAddBatch(cwd, descriptions, raw);
|
|
},
|
|
insert: () => {
|
|
if (args.includes('--dry-run')) {
|
|
error('phase insert does not support --dry-run');
|
|
}
|
|
phase.cmdPhaseInsert(cwd, args[2], args.slice(3).join(' '), raw);
|
|
},
|
|
remove: () => phase.cmdPhaseRemove(cwd, args[2], { force: args.includes('--force') }, raw),
|
|
complete: () => phase.cmdPhaseComplete(cwd, args[2], raw),
|
|
},
|
|
});
|
|
}
|
|
|
|
module.exports = {
|
|
routePhaseCommand,
|
|
};
|