fix: graceful fallback when AGENTS.md is missing in claude-local adapter
The codex-local and cursor-local adapters already wrap the instructionsFilePath read in try/catch, logging a warning and continuing without instructions. The claude-local adapter was missing this handling, causing ENOENT crashes when the instructions file doesn't exist. Fixes #529 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -341,13 +341,22 @@ export async function execute(ctx: AdapterExecutionContext): Promise<AdapterExec
|
|||||||
// When instructionsFilePath is configured, create a combined temp file that
|
// When instructionsFilePath is configured, create a combined temp file that
|
||||||
// includes both the file content and the path directive, so we only need
|
// includes both the file content and the path directive, so we only need
|
||||||
// --append-system-prompt-file (Claude CLI forbids using both flags together).
|
// --append-system-prompt-file (Claude CLI forbids using both flags together).
|
||||||
let effectiveInstructionsFilePath = instructionsFilePath;
|
let effectiveInstructionsFilePath: string | undefined = instructionsFilePath;
|
||||||
if (instructionsFilePath) {
|
if (instructionsFilePath) {
|
||||||
const instructionsContent = await fs.readFile(instructionsFilePath, "utf-8");
|
try {
|
||||||
const pathDirective = `\nThe above agent instructions were loaded from ${instructionsFilePath}. Resolve any relative file references from ${instructionsFileDir}.`;
|
const instructionsContent = await fs.readFile(instructionsFilePath, "utf-8");
|
||||||
const combinedPath = path.join(skillsDir, "agent-instructions.md");
|
const pathDirective = `\nThe above agent instructions were loaded from ${instructionsFilePath}. Resolve any relative file references from ${instructionsFileDir}.`;
|
||||||
await fs.writeFile(combinedPath, instructionsContent + pathDirective, "utf-8");
|
const combinedPath = path.join(skillsDir, "agent-instructions.md");
|
||||||
effectiveInstructionsFilePath = combinedPath;
|
await fs.writeFile(combinedPath, instructionsContent + pathDirective, "utf-8");
|
||||||
|
effectiveInstructionsFilePath = combinedPath;
|
||||||
|
} catch (err) {
|
||||||
|
const reason = err instanceof Error ? err.message : String(err);
|
||||||
|
await onLog(
|
||||||
|
"stderr",
|
||||||
|
`[paperclip] Warning: could not read agent instructions file "${instructionsFilePath}": ${reason}\n`,
|
||||||
|
);
|
||||||
|
effectiveInstructionsFilePath = undefined;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const runtimeSessionParams = parseObject(runtime.sessionParams);
|
const runtimeSessionParams = parseObject(runtime.sessionParams);
|
||||||
|
|||||||
Reference in New Issue
Block a user