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

@@ -215,7 +215,7 @@ function setConfigValue(obj: Record<string, unknown>, dotPath: string, value: un
* @returns QueryResult matching gsd-tools `config-set` JSON: `{ updated, key, value, previousValue }`
* @throws GSDError with Validation if key is invalid or args missing
*/
export const configSet: QueryHandler = async (args, projectDir) => {
export const configSet: QueryHandler = async (args, projectDir, _workstream) => {
const keyPath = args[0];
const rawValue = args[1];
if (!keyPath) {
@@ -284,7 +284,7 @@ export const configSet: QueryHandler = async (args, projectDir) => {
* @returns QueryResult with { set: true, profile, agents }
* @throws GSDError with Validation if profile is invalid
*/
export const configSetModelProfile: QueryHandler = async (args, projectDir) => {
export const configSetModelProfile: QueryHandler = async (args, projectDir, _workstream) => {
const profileName = args[0];
if (!profileName) {
throw new GSDError(
@@ -346,7 +346,7 @@ export const configSetModelProfile: QueryHandler = async (args, projectDir) => {
* @param projectDir - Project root directory
* @returns QueryResult with { created: true, path } or { created: false, reason }
*/
export const configNewProject: QueryHandler = async (args, projectDir) => {
export const configNewProject: QueryHandler = async (args, projectDir, _workstream) => {
const paths = planningPaths(projectDir);
// Idempotent: don't overwrite existing config
@@ -472,7 +472,7 @@ export const configNewProject: QueryHandler = async (args, projectDir) => {
* @param projectDir - Project root directory
* @returns QueryResult with { ensured: true, section }
*/
export const configEnsureSection: QueryHandler = async (args, projectDir) => {
export const configEnsureSection: QueryHandler = async (args, projectDir, _workstream) => {
const sectionName = args[0];
if (!sectionName) {
throw new GSDError('Usage: config-ensure-section <section>', ErrorClassification.Validation);