feat(S-103): Test-drive and implement --debug diagnostic mode
This commit is contained in:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user