mirror of
https://github.com/anthropics/claude-code-action.git
synced 2026-01-22 22:44:13 +08:00
Fix SDK path: add settingSources and default system prompt (#726)
Two fixes for the Agent SDK path (USE_AGENT_SDK=true):
1. Add settingSources to load filesystem settings
- Without this, CLI-installed plugins aren't available to the SDK
- Also needed to load CLAUDE.md files from the project
2. Default systemPrompt to claude_code preset
- Without an explicit systemPrompt, the SDK would use no system prompt
- Now defaults to { type: "preset", preset: "claude_code" } to match CLI behavior
Also adds logging of SDK options (excluding env) for debugging.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-authored-by: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -101,7 +101,7 @@ export function parseSdkOptions(options: ClaudeOptions): ParsedSdkOptions {
|
|||||||
env.GITHUB_ACTION_INPUTS = process.env.INPUT_ACTION_INPUTS_PRESENT;
|
env.GITHUB_ACTION_INPUTS = process.env.INPUT_ACTION_INPUTS_PRESENT;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Build system prompt option
|
// Build system prompt option - default to claude_code preset
|
||||||
let systemPrompt: SdkOptions["systemPrompt"];
|
let systemPrompt: SdkOptions["systemPrompt"];
|
||||||
if (options.systemPrompt) {
|
if (options.systemPrompt) {
|
||||||
systemPrompt = options.systemPrompt;
|
systemPrompt = options.systemPrompt;
|
||||||
@@ -111,6 +111,12 @@ export function parseSdkOptions(options: ClaudeOptions): ParsedSdkOptions {
|
|||||||
preset: "claude_code",
|
preset: "claude_code",
|
||||||
append: options.appendSystemPrompt,
|
append: options.appendSystemPrompt,
|
||||||
};
|
};
|
||||||
|
} else {
|
||||||
|
// Default to claude_code preset when no custom prompt is specified
|
||||||
|
systemPrompt = {
|
||||||
|
type: "preset",
|
||||||
|
preset: "claude_code",
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
// Build SDK options - use merged tools from both direct options and claudeArgs
|
// Build SDK options - use merged tools from both direct options and claudeArgs
|
||||||
@@ -130,6 +136,9 @@ export function parseSdkOptions(options: ClaudeOptions): ParsedSdkOptions {
|
|||||||
// Note: allowedTools and disallowedTools have been removed from extraArgs to prevent duplicates
|
// Note: allowedTools and disallowedTools have been removed from extraArgs to prevent duplicates
|
||||||
extraArgs,
|
extraArgs,
|
||||||
env,
|
env,
|
||||||
|
|
||||||
|
// Load settings from all sources to pick up CLI-installed plugins, CLAUDE.md, etc.
|
||||||
|
settingSources: ["user", "project", "local"],
|
||||||
};
|
};
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
|||||||
@@ -75,6 +75,9 @@ export async function runClaudeWithSdk(
|
|||||||
}
|
}
|
||||||
|
|
||||||
console.log(`Running Claude with prompt from file: ${promptPath}`);
|
console.log(`Running Claude with prompt from file: ${promptPath}`);
|
||||||
|
// Log SDK options without env (which could contain sensitive data)
|
||||||
|
const { env, ...optionsToLog } = sdkOptions;
|
||||||
|
console.log("SDK options:", JSON.stringify(optionsToLog, null, 2));
|
||||||
|
|
||||||
const messages: SDKMessage[] = [];
|
const messages: SDKMessage[] = [];
|
||||||
let resultMessage: SDKResultMessage | undefined;
|
let resultMessage: SDKResultMessage | undefined;
|
||||||
|
|||||||
Reference in New Issue
Block a user