feat(sdk): add --ws flag for workstream-aware execution (#1884)

Add a --ws <name> CLI flag that routes all .planning/ paths to
.planning/workstreams/<name>/, enabling multi-workstream projects
without directory conflicts.

Changes:
- workstream-utils.ts: validateWorkstreamName() and relPlanningPath() helpers
- cli.ts: Parse --ws flag with input validation
- types.ts: Add workstream? to GSDOptions
- gsd-tools.ts: Inject --ws <name> into all gsd-tools.cjs invocations
- config.ts: Resolve workstream-aware config path with root fallback
- context-engine.ts: Constructor accepts workstream via positional param
- index.ts: GSD class propagates workstream to all subsystems
- ws-flag.test.ts: 22 tests covering all workstream functionality

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Tom Boucher
2026-04-11 09:33:34 -04:00
parent 72e789432e
commit 868e3d488f
8 changed files with 369 additions and 11 deletions

View File

@@ -25,6 +25,7 @@ import {
DEFAULT_TRUNCATION_OPTIONS,
type TruncationOptions,
} from './context-truncation.js';
import { relPlanningPath } from './workstream-utils.js';
// ─── File manifest per phase ─────────────────────────────────────────────────
@@ -77,8 +78,8 @@ export class ContextEngine {
private readonly logger?: GSDLogger;
private readonly truncation: TruncationOptions;
constructor(projectDir: string, logger?: GSDLogger, truncation?: Partial<TruncationOptions>) {
this.planningDir = join(projectDir, '.planning');
constructor(projectDir: string, logger?: GSDLogger, truncation?: Partial<TruncationOptions>, workstream?: string) {
this.planningDir = join(projectDir, relPlanningPath(workstream));
this.logger = logger;
this.truncation = { ...DEFAULT_TRUNCATION_OPTIONS, ...truncation };
}