fix(sdk): forward --ws workstream flag through query dispatch (#2546)

* fix(sdk): forward --ws workstream flag through query dispatch (closes #2524)

- cli.ts: pass args.ws as workstream to registry.dispatch()
- registry.ts: add workstream? param to dispatch(), thread to handler
- utils.ts: add optional workstream? to QueryHandler type signature
- helpers.ts: planningPaths() accepts workstream? and uses relPlanningPath()
- All ~26 query handlers updated to receive and pass workstream to planningPaths()
- Config/commit/intel handlers use _workstream (project-global, not scoped)
- Add failing-then-passing test: tests/bug-2524-sdk-query-ws-flag.test.cjs

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* fix(sdk): forward workstream to all downstream query helpers

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* fix(test): rewrite #2524 test as static source assertions — no sdk/dist build in CI

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

---------

Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Tom Boucher
2026-04-21 20:33:24 -04:00
committed by GitHub
parent 7bb6b6452a
commit 5676e2e4ef
31 changed files with 337 additions and 219 deletions

View File

@@ -52,11 +52,11 @@ async function verificationPassed(phaseDirAbs: string): Promise<boolean> {
}
}
export const routeNextAction: QueryHandler = async (_args, projectDir) => {
const planning = planningPaths(projectDir).planning;
export const routeNextAction: QueryHandler = async (_args, projectDir, workstream) => {
const planning = planningPaths(projectDir, workstream).planning;
const continueHere = existsSync(join(planning, '.continue-here.md'));
const sj = await stateJson([], projectDir);
const sj = await stateJson([], projectDir, workstream);
const sjd = sj.data as Record<string, unknown>;
if (sjd.error) {
return {
@@ -85,11 +85,11 @@ export const routeNextAction: QueryHandler = async (_args, projectDir) => {
const consecutiveCalls = readConsecutiveCallCount(planning);
const ra = await roadmapAnalyze([], projectDir);
const ra = await roadmapAnalyze([], projectDir, workstream);
const raData = ra.data as { phases?: Array<Record<string, unknown>> };
const phases = raData.phases ?? [];
const phasesDir = planningPaths(projectDir).phases;
const phasesDir = planningPaths(projectDir, workstream).phases;
let dirCount = 0;
try {
dirCount = readdirSync(phasesDir, { withFileTypes: true }).filter(e => e.isDirectory()).length;
@@ -97,7 +97,7 @@ export const routeNextAction: QueryHandler = async (_args, projectDir) => {
let unresolvedVerification = false;
if (currentPhase) {
const fp = await findPhase([currentPhase], projectDir);
const fp = await findPhase([currentPhase], projectDir, workstream);
const fd = fp.data as Record<string, unknown>;
if (fd.found && fd.directory) {
unresolvedVerification = await hasUnresolvedVerificationFails(
@@ -126,7 +126,7 @@ export const routeNextAction: QueryHandler = async (_args, projectDir) => {
uat_gaps: 0,
};
}
const fp = await findPhase([cp], projectDir);
const fp = await findPhase([cp], projectDir, workstream);
const d = fp.data as Record<string, unknown>;
const plans = (d.plans as string[]) ?? [];
const summaries = (d.summaries as string[]) ?? [];
@@ -212,7 +212,7 @@ export const routeNextAction: QueryHandler = async (_args, projectDir) => {
};
}
const fp = await findPhase([currentPhase], projectDir);
const fp = await findPhase([currentPhase], projectDir, workstream);
const pd = fp.data as Record<string, unknown>;
const found = Boolean(pd.found);
const cp = normalizePhaseName(currentPhase);