feat(S-103): Test-drive and implement --debug diagnostic mode

This commit is contained in:
2026-05-19 19:48:40 -05:00
parent 32964bf994
commit 94389df6f1
4 changed files with 183 additions and 5 deletions
+14 -3
View File
@@ -8,6 +8,7 @@ import {
type ClientName,
type ClientInfo,
type ExecResult,
type DebugInfo,
ClientNotFoundError,
} from "./types.js";
@@ -15,7 +16,8 @@ export interface CliDeps {
detectClients?: () => ClientInfo[];
executePrompt?: (
client: ClientName,
prompt: string
prompt: string,
options?: { timeoutMs?: number; debug?: boolean; onDebug?: (info: DebugInfo) => void }
) => Promise<ExecResult>;
resolveClient?: (
prompt: string,
@@ -60,6 +62,7 @@ export async function main(
});
const jsonMode = !args.text;
const debug = !!args.debug;
if (args.help) {
printHelp();
@@ -119,7 +122,11 @@ export async function main(
typeof args.timeout === "string" ? Number(args.timeout) : config.timeout;
try {
const result = await executePrompt(client, prompt, { timeoutMs });
const result = await executePrompt(client, prompt, {
timeoutMs,
debug,
onDebug: debug ? (info) => stderrWrite(JSON.stringify(info) + "\n") : undefined,
});
if (jsonMode) {
console.log(JSON.stringify(result, null, 2));
} else {
@@ -175,7 +182,11 @@ export async function main(
typeof args.timeout === "string" ? Number(args.timeout) : config.timeout;
try {
const result = await executePrompt(client, prompt, { timeoutMs });
const result = await executePrompt(client, prompt, {
timeoutMs,
debug,
onDebug: debug ? (info) => stderrWrite(JSON.stringify(info) + "\n") : undefined,
});
if (jsonMode) {
console.log(JSON.stringify(result, null, 2));
} else {