Skip to content

Commit 58849ba

Browse files
committed
fix(ai): write plan files to disk and fix Windows path check
Write plan files to disk via fs.writeFileSync so Claude can read them back later. Normalize backslashes for Windows path detection in the .claude/plans/ check.
1 parent 49477ed commit 58849ba

1 file changed

Lines changed: 17 additions & 11 deletions

File tree

src-node/claude-code-agent.js

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -586,27 +586,33 @@ async function _runQuery(requestId, prompt, projectPath, model, signal, locale,
586586
async (input) => {
587587
console.log("[Phoenix AI] Intercepted Write tool");
588588
// Capture plan content when writing to .claude/plans/
589-
// Don't open plan files in editor — shown in plan card UI
589+
// Plan files: capture content for plan card, write to disk
590+
// but don't open in editor
590591
const writePath = input.tool_input.file_path || "";
591-
if (writePath.includes("/.claude/plans/")) {
592+
const normalizedPath = writePath.replace(/\\/g, "/");
593+
if (normalizedPath.includes("/.claude/plans/")) {
592594
_lastPlanContent = input.tool_input.content || "";
593595
console.log("[Phoenix AI] Captured plan content:",
594596
_lastPlanContent.length + "ch");
597+
// Write to disk so Claude can read it back later
598+
try {
599+
const dir = path.dirname(writePath);
600+
if (!fs.existsSync(dir)) {
601+
fs.mkdirSync(dir, { recursive: true });
602+
}
603+
fs.writeFileSync(writePath, input.tool_input.content || "", "utf8");
604+
} catch (err) {
605+
console.warn("[Phoenix AI] Failed to write plan file:", err.message);
606+
}
607+
let planReason = "Plan file saved.";
595608
if (_queuedClarification) {
596-
return {
597-
hookSpecificOutput: {
598-
hookEventName: "PreToolUse",
599-
permissionDecision: "deny",
600-
permissionDecisionReason:
601-
"Plan file saved." + CLARIFICATION_HINT
602-
}
603-
};
609+
planReason += CLARIFICATION_HINT;
604610
}
605611
return {
606612
hookSpecificOutput: {
607613
hookEventName: "PreToolUse",
608614
permissionDecision: "deny",
609-
permissionDecisionReason: "Plan file saved."
615+
permissionDecisionReason: planReason
610616
}
611617
};
612618
}

0 commit comments

Comments
 (0)