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

@@ -17,8 +17,8 @@ import {
import type { QueryHandler } from './utils.js';
/** Resolve `.planning/phases/<dir>` for a phase token, or null. */
async function resolvePhaseDir(phase: string, projectDir: string): Promise<string | null> {
const phasesDir = planningPaths(projectDir).phases;
async function resolvePhaseDir(phase: string, projectDir: string, workstream?: string): Promise<string | null> {
const phasesDir = planningPaths(projectDir, workstream).phases;
const normalized = normalizePhaseName(phase);
try {
const entries = await readdir(phasesDir, { withFileTypes: true });
@@ -40,7 +40,7 @@ type ArtifactType = 'context' | 'summary' | 'verification' | 'research';
*
* Args: `<phase>` `--type` `<context|summary|verification|research>`
*/
export const phaseListArtifacts: QueryHandler = async (args, projectDir) => {
export const phaseListArtifacts: QueryHandler = async (args, projectDir, workstream) => {
if (!args[0]) {
throw new GSDError('phase required', ErrorClassification.Validation);
}
@@ -56,7 +56,7 @@ export const phaseListArtifacts: QueryHandler = async (args, projectDir) => {
}
const artifactType = rawType as ArtifactType;
const phaseDir = await resolvePhaseDir(phase, projectDir);
const phaseDir = await resolvePhaseDir(phase, projectDir, workstream);
if (!phaseDir) {
return { data: { phase: normalizePhaseName(phase), type: artifactType, artifacts: [], error: 'Phase not found' } };
}
@@ -93,7 +93,7 @@ export const phaseListArtifacts: QueryHandler = async (args, projectDir) => {
*
* Args: `<phase>` [`--with-schema` `<yamlKey>`]
*/
export const phaseListPlans: QueryHandler = async (args, projectDir) => {
export const phaseListPlans: QueryHandler = async (args, projectDir, workstream) => {
if (!args[0]) {
throw new GSDError('phase required', ErrorClassification.Validation);
}
@@ -108,7 +108,7 @@ export const phaseListPlans: QueryHandler = async (args, projectDir) => {
const phase = args[0];
const normalized = normalizePhaseName(phase);
const phaseDir = await resolvePhaseDir(phase, projectDir);
const phaseDir = await resolvePhaseDir(phase, projectDir, workstream);
if (!phaseDir) {
return {
data: {