fix: honor workstream in verify-work init (#3386)
* fix: honor workstream in verify-work init * fix: define verify-work phase arg
This commit is contained in:
@@ -448,6 +448,30 @@ describe('initVerifyWork', () => {
|
||||
expect(data.project_root).toBe(tmpDir);
|
||||
});
|
||||
|
||||
it('resolves workstream-scoped phases when workstream is provided', async () => {
|
||||
const wsDir = join(tmpDir, '.planning', 'workstreams', 'delivery');
|
||||
await mkdir(join(wsDir, 'phases', '32-shipment-creation-tracking-numbers-print-forms'), { recursive: true });
|
||||
await writeFile(join(wsDir, 'ROADMAP.md'), [
|
||||
'# Roadmap',
|
||||
'',
|
||||
'## v1.0: Delivery',
|
||||
'',
|
||||
'### Phase 32: Shipment Creation Tracking Numbers Print Forms',
|
||||
'',
|
||||
'**Goal:** Ship orders.',
|
||||
'',
|
||||
].join('\n'));
|
||||
|
||||
const result = await initVerifyWork(['32'], tmpDir, 'delivery');
|
||||
const data = result.data as Record<string, unknown>;
|
||||
|
||||
expect(data.phase_found).toBe(true);
|
||||
expect(data.phase_number).toBe('32');
|
||||
expect(data.phase_dir).toBe(
|
||||
'.planning/workstreams/delivery/phases/32-shipment-creation-tracking-numbers-print-forms',
|
||||
);
|
||||
});
|
||||
|
||||
it('returns error when phase arg missing', async () => {
|
||||
const result = await initVerifyWork([], tmpDir);
|
||||
const data = result.data as Record<string, unknown>;
|
||||
|
||||
@@ -184,14 +184,15 @@ async function getPhaseInfoWithFallback(
|
||||
async function getPhaseInfoForVerifyWork(
|
||||
phase: string,
|
||||
projectDir: string,
|
||||
workstream?: string,
|
||||
): Promise<{ phaseInfo: Record<string, unknown> | null }> {
|
||||
const phaseResult = await findPhase([phase], projectDir);
|
||||
const phaseResult = await findPhase([phase], projectDir, workstream);
|
||||
let phaseInfo = phaseResult.data as Record<string, unknown> | null;
|
||||
if (phaseInfo && phaseInfo.found === false) {
|
||||
phaseInfo = null;
|
||||
}
|
||||
|
||||
const roadmapResult = await roadmapGetPhase([phase], projectDir);
|
||||
const roadmapResult = await roadmapGetPhase([phase], projectDir, workstream);
|
||||
const roadmapPhase = roadmapResult.data as Record<string, unknown> | null;
|
||||
|
||||
if (phaseInfo?.archived && roadmapPhase?.found) {
|
||||
@@ -205,9 +206,7 @@ async function getPhaseInfoForVerifyWork(
|
||||
directory: null,
|
||||
phase_number: roadmapPhase.phase_number,
|
||||
phase_name: phaseName,
|
||||
phase_slug: phaseName
|
||||
? phaseName.toLowerCase().replace(/[^a-z0-9]+/g, '-').replace(/^-+|-+$/g, '')
|
||||
: null,
|
||||
phase_slug: phaseName ? generateSlugInternal(phaseName) : null,
|
||||
plans: [],
|
||||
summaries: [],
|
||||
incomplete_plans: [],
|
||||
@@ -623,14 +622,14 @@ export const initResume: QueryHandler = async (_args, projectDir) => {
|
||||
* Init handler for verify-work workflow.
|
||||
* Port of cmdInitVerifyWork from init.cjs lines 538-586.
|
||||
*/
|
||||
export const initVerifyWork: QueryHandler = async (args, projectDir) => {
|
||||
export const initVerifyWork: QueryHandler = async (args, projectDir, workstream) => {
|
||||
const phase = args[0];
|
||||
if (!phase) {
|
||||
return { data: { error: 'phase required for init verify-work' } };
|
||||
}
|
||||
|
||||
const config = await loadConfig(projectDir);
|
||||
const { phaseInfo } = await getPhaseInfoForVerifyWork(phase, projectDir);
|
||||
const config = await loadConfig(projectDir, workstream);
|
||||
const { phaseInfo } = await getPhaseInfoForVerifyWork(phase, projectDir, workstream);
|
||||
|
||||
const configExists = existsSync(join(projectDir, '.planning', 'config.json'));
|
||||
const [plannerModel, checkerModel] = configExists
|
||||
|
||||
Reference in New Issue
Block a user