fix(query): thread workstream through all query handlers

All 18+ query handlers accepted _workstream but never forwarded it to
planningPaths/loadConfig/getMilestoneInfo. Remove _ prefix and pass
workstream to all internal helper calls so --ws flag actually scopes
path resolution.

Affected handlers: initNewProject, initProgress, initManager, configGet,
configPath, configSet, configSetModelProfile, configNewProject,
configEnsureSection, validateHealth, commit, checkCommit, commitToSubrepo.

Also fixes validate.ts to use paths.* fields from planningPaths instead
of hardcoded join(projectDir, '.planning') paths.

Closes #2731
This commit is contained in:
Tom Boucher
2026-04-26 10:53:17 -04:00
parent f6cddc5b2f
commit 3a623b1117
5 changed files with 37 additions and 37 deletions

View File

@@ -93,8 +93,8 @@ function deriveStatusFromCheckbox(
*
* Port of cmdInitNewProject from init.cjs lines 296-399.
*/
export const initNewProject: QueryHandler = async (_args, projectDir, _workstream) => {
const config = await loadConfig(projectDir);
export const initNewProject: QueryHandler = async (_args, projectDir, workstream) => {
const config = await loadConfig(projectDir, workstream);
// Detect search API key availability from env vars and ~/.gsd/ files
const gsdHome = join(homedir(), '.gsd');
@@ -209,10 +209,10 @@ export const initNewProject: QueryHandler = async (_args, projectDir, _workstrea
*
* Port of cmdInitProgress from init.cjs lines 1139-1284.
*/
export const initProgress: QueryHandler = async (_args, projectDir, _workstream) => {
const config = await loadConfig(projectDir);
const milestone = await getMilestoneInfo(projectDir);
const paths = planningPaths(projectDir);
export const initProgress: QueryHandler = async (_args, projectDir, workstream) => {
const config = await loadConfig(projectDir, workstream);
const milestone = await getMilestoneInfo(projectDir, workstream);
const paths = planningPaths(projectDir, workstream);
const phases: Record<string, unknown>[] = [];
let currentPhase: Record<string, unknown> | null = null;
@@ -225,7 +225,7 @@ export const initProgress: QueryHandler = async (_args, projectDir, _workstream)
try {
const rawRoadmap = await readFile(paths.roadmap, 'utf-8');
const roadmapContent = await extractCurrentMilestone(rawRoadmap, projectDir);
const roadmapContent = await extractCurrentMilestone(rawRoadmap, projectDir, workstream);
const headingPattern = /#{2,4}\s*Phase\s+(\d+[A-Z]?(?:\.\d+)*)\s*:\s*([^\n]+)/gi;
let hm: RegExpExecArray | null;
while ((hm = headingPattern.exec(roadmapContent)) !== null) {
@@ -372,10 +372,10 @@ export const initProgress: QueryHandler = async (_args, projectDir, _workstream)
*
* Port of cmdInitManager from init.cjs lines 854-1137.
*/
export const initManager: QueryHandler = async (_args, projectDir, _workstream) => {
const config = await loadConfig(projectDir);
const milestone = await getMilestoneInfo(projectDir);
const paths = planningPaths(projectDir);
export const initManager: QueryHandler = async (_args, projectDir, workstream) => {
const config = await loadConfig(projectDir, workstream);
const milestone = await getMilestoneInfo(projectDir, workstream);
const paths = planningPaths(projectDir, workstream);
let rawContent: string;
try {
@@ -384,7 +384,7 @@ export const initManager: QueryHandler = async (_args, projectDir, _workstream)
return { data: { error: 'No ROADMAP.md found. Run /gsd-new-milestone first.' } };
}
const content = await extractCurrentMilestone(rawContent, projectDir);
const content = await extractCurrentMilestone(rawContent, projectDir, workstream);
// Pre-compute directory listing once
let phaseDirEntries: string[] = [];