chore(cli): clean up step-ask nits from PR #156 review #158
@@ -409,7 +409,7 @@ step
|
|||||||
const stdout = await cmdStepAsk(storageRoot, stepHash as CasRef, {
|
const stdout = await cmdStepAsk(storageRoot, stepHash as CasRef, {
|
||||||
prompt: opts.prompt,
|
prompt: opts.prompt,
|
||||||
agentOverride: opts.agent ?? null,
|
agentOverride: opts.agent ?? null,
|
||||||
fork: opts.fork !== false,
|
fork: opts.fork,
|
||||||
});
|
});
|
||||||
process.stdout.write(stdout.endsWith("\n") ? stdout : `${stdout}\n`);
|
process.stdout.write(stdout.endsWith("\n") ? stdout : `${stdout}\n`);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -441,7 +441,7 @@ function spawnAskAgent(agent: AgentConfig, argv: string[], cwd: string): { stdou
|
|||||||
});
|
});
|
||||||
return { stdout };
|
return { stdout };
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
const err = e as NodeJS.ErrnoException & { stderr?: Buffer | string | null };
|
const err = e as NodeJS.ErrnoException & { stderr: Buffer | string | null };
|
||||||
if (err.code === "ENOENT") {
|
if (err.code === "ENOENT") {
|
||||||
fail(
|
fail(
|
||||||
`"${agent.command}" not found in PATH. Install it or check your PATH config. Run: which ${agent.command}`,
|
`"${agent.command}" not found in PATH. Install it or check your PATH config. Run: which ${agent.command}`,
|
||||||
@@ -458,10 +458,7 @@ function spawnAskAgent(agent: AgentConfig, argv: string[], cwd: string): { stdou
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function resolveAskWorkflow(
|
function resolveAskWorkflow(uwf: UwfStore, payload: StepNodePayload): WorkflowPayload | null {
|
||||||
uwf: UwfStore,
|
|
||||||
payload: StepNodePayload,
|
|
||||||
): Promise<WorkflowPayload | null> {
|
|
||||||
const startNode = uwf.store.cas.get(payload.start);
|
const startNode = uwf.store.cas.get(payload.start);
|
||||||
if (startNode === null) {
|
if (startNode === null) {
|
||||||
return null;
|
return null;
|
||||||
@@ -529,7 +526,7 @@ export async function cmdStepAsk(
|
|||||||
const detailRef = payload.detail;
|
const detailRef = payload.detail;
|
||||||
const { sessionId: sourceSessionId } = loadDetailNode(uwf.store.cas, detailRef);
|
const { sessionId: sourceSessionId } = loadDetailNode(uwf.store.cas, detailRef);
|
||||||
|
|
||||||
const workflow = await resolveAskWorkflow(uwf, payload);
|
const workflow = resolveAskWorkflow(uwf, payload);
|
||||||
const config = await loadWorkflowConfig(storageRoot);
|
const config = await loadWorkflowConfig(storageRoot);
|
||||||
const agent = resolveAskAgentConfig(
|
const agent = resolveAskAgentConfig(
|
||||||
config,
|
config,
|
||||||
@@ -553,18 +550,14 @@ export async function cmdStepAsk(
|
|||||||
cwd,
|
cwd,
|
||||||
);
|
);
|
||||||
const argv = ["--mode", "ask", "--session", askSessionId, "--prompt", options.prompt];
|
const argv = ["--mode", "ask", "--session", askSessionId, "--prompt", options.prompt];
|
||||||
if (detailRef !== null) {
|
argv.push("--detail", detailRef);
|
||||||
argv.push("--detail", detailRef);
|
|
||||||
}
|
|
||||||
const { stdout } = spawnAskAgent(agent, argv, cwd);
|
const { stdout } = spawnAskAgent(agent, argv, cwd);
|
||||||
return stdout;
|
return stdout;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Fallback path: ask without forking; inject detail ref for context.
|
// Fallback path: ask without forking; inject detail ref for context.
|
||||||
const argv = ["--mode", "ask", "--prompt", options.prompt];
|
const argv = ["--mode", "ask", "--prompt", options.prompt];
|
||||||
if (detailRef !== null) {
|
argv.push("--detail", detailRef);
|
||||||
argv.push("--detail", detailRef);
|
|
||||||
}
|
|
||||||
const { stdout } = spawnAskAgent(agent, argv, cwd);
|
const { stdout } = spawnAskAgent(agent, argv, cwd);
|
||||||
return stdout;
|
return stdout;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user