feat: add human-readable CI log output for show_full_output mode
Replace raw JSON dumps with concise, scannable log lines when show_full_output is enabled. Adds an onMessage callback to the SDK runner that formats each message type into 1-2 line summaries with emoji prefixes, tool-specific parameter display, result correlation for parallel tool calls, and subagent progress tracking. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
1 parent
ec1a718b2e
commit
ed536bb8a3
5 files changed
+1074
-13
No files matched your search
@@ -136,6 +136,7 @@ function sanitizeSdkOutput(
|
||||
export async function runClaudeWithSdk(
|
||||
promptPath: string,
|
||||
{ sdkOptions, showFullOutput, hasJsonSchema }: ParsedSdkOptions,
|
||||
onMessage?: (message: SDKMessage) => void,
|
||||
): Promise<ClaudeRunResult> {
|
||||
// Create prompt configuration - may be a string or multi-block message
|
||||
const prompt = await createPromptConfig(promptPath, showFullOutput);
|
||||
@@ -161,9 +162,13 @@ export async function runClaudeWithSdk(
|
||||
for await (const message of query({ prompt, options: sdkOptions })) {
|
||||
messages.push(message);
|
||||
|
||||
const sanitized = sanitizeSdkOutput(message, showFullOutput);
|
||||
if (sanitized) {
|
||||
console.log(sanitized);
|
||||
if (onMessage) {
|
||||
onMessage(message);
|
||||
} else {
|
||||
const sanitized = sanitizeSdkOutput(message, showFullOutput);
|
||||
if (sanitized) {
|
||||
console.log(sanitized);
|
||||
}
|
||||
}
|
||||
|
||||
if (message.type === "result") {
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { runClaudeWithSdk } from "./run-claude-sdk";
|
||||
import type { ClaudeRunResult } from "./run-claude-sdk";
|
||||
import { parseSdkOptions } from "./parse-sdk-options";
|
||||
import type { SDKMessage } from "@anthropic-ai/claude-agent-sdk";
|
||||
|
||||
export type ClaudeOptions = {
|
||||
claudeArgs?: string;
|
||||
@@ -19,7 +20,8 @@ export type ClaudeOptions = {
|
||||
export async function runClaude(
|
||||
promptPath: string,
|
||||
options: ClaudeOptions,
|
||||
onMessage?: (message: SDKMessage) => void,
|
||||
): Promise<ClaudeRunResult> {
|
||||
const parsedOptions = parseSdkOptions(options);
|
||||
return runClaudeWithSdk(promptPath, parsedOptions);
|
||||
return runClaudeWithSdk(promptPath, parsedOptions, onMessage);
|
||||
}
|
||||
Reference in new issue
Block a user