From 0edd7235cd861ef77d4ceb37a594ae65df52624b Mon Sep 17 00:00:00 2001 From: Clawd Date: Sat, 28 Feb 2026 15:35:00 -0800 Subject: Add session-specific artifacts, CLAUDE.md, and git worktree support - Store artifacts in .claude-flow/sessions/{sessionId}/ - Each session now has isolated research.md and plan.md - Concurrent sessions no longer conflict - Add CLAUDE.md support for shared codebase documentation - Add git worktree creation on session start - Add git commit/status IPC handlers - Update all artifact APIs to be session-specific - Remove artifact clearing on new session (no longer needed) --- src/main/claude/phases.ts | 62 ++++++++++++++++++++++++++++++++--------------- 1 file changed, 43 insertions(+), 19 deletions(-) (limited to 'src/main/claude/phases.ts') diff --git a/src/main/claude/phases.ts b/src/main/claude/phases.ts index 2ea1ea8..6992047 100644 --- a/src/main/claude/phases.ts +++ b/src/main/claude/phases.ts @@ -10,6 +10,17 @@ export interface PhaseConfig { initialMessage: string; } +// Get session-specific artifact path +export function getSessionArtifactDir(sessionId: string): string { + return `.claude-flow/sessions/${sessionId}`; +} + +export function getArtifactPath(phase: Phase, sessionId: string): string { + const dir = getSessionArtifactDir(sessionId); + const filename = phase === "research" ? "research.md" : "plan.md"; + return `${dir}/${filename}`; +} + export const phaseConfigs: Record = { research: { permissionMode: "acceptEdits", @@ -19,18 +30,24 @@ export const phaseConfigs: Record = { systemPrompt: `You are in RESEARCH mode. Your ONLY job is to understand the codebase. CRITICAL RULES: -1. You MUST write ALL findings to .claude-flow/research.md — this is your PRIMARY output +1. You MUST write ALL findings to the session research.md — this is your PRIMARY output 2. DO NOT just respond in chat. The document viewer shows research.md, so write there. 3. DO NOT suggest moving to planning or implementation 4. DO NOT ask "are you ready to implement?" or similar 5. DO NOT modify any source code files 6. The user controls phase transitions via UI buttons — never prompt them about it +CONTEXT: +- Read CLAUDE.md in the project root (if it exists) for codebase overview +- This file contains general architecture info shared across all sessions +- If CLAUDE.md doesn't exist, create it with your initial findings + WORKFLOW: -1. Ask what to research (if unclear) -2. Read files thoroughly using Read, Glob, Grep -3. Write structured findings to .claude-flow/research.md -4. Keep updating research.md as you learn more +1. Read CLAUDE.md (create if missing) +2. Ask what to research (if unclear) +3. Read files thoroughly using Read, Glob, Grep +4. Write findings to session research.md +5. Update CLAUDE.md with any new general insights FORMAT for research.md: \`\`\`markdown @@ -52,8 +69,6 @@ FORMAT for research.md: [Things that need clarification] \`\`\` -When the user adds annotations (// REVIEW:, // NOTE:, TODO:) to research.md and clicks Review, address each annotation and update the document. - Remember: Your output goes in research.md, not chat. Chat is for clarifying questions only.`, }, @@ -65,18 +80,19 @@ Remember: Your output goes in research.md, not chat. Chat is for clarifying ques systemPrompt: `You are in PLANNING mode. Your ONLY job is to create an implementation plan. CRITICAL RULES: -1. You MUST write the plan to .claude-flow/plan.md — this is your PRIMARY output +1. You MUST write the plan to session plan.md — this is your PRIMARY output 2. DO NOT just respond in chat. The document viewer shows plan.md, so write there. 3. DO NOT implement anything — no code changes to source files 4. DO NOT ask "should I start implementing?" or similar 5. The user controls phase transitions via UI buttons — never prompt them about it -6. Base your plan on .claude-flow/research.md +6. Base your plan on the session research.md and CLAUDE.md WORKFLOW: -1. Read .claude-flow/research.md to understand the codebase -2. Write a detailed plan to .claude-flow/plan.md -3. Include specific code snippets showing proposed changes -4. Make the plan detailed enough that implementation is mechanical +1. Read CLAUDE.md for codebase overview +2. Read the session research.md to understand the specific task +3. Write a detailed plan to session plan.md +4. Include specific code snippets showing proposed changes +5. Make the plan detailed enough that implementation is mechanical FORMAT for plan.md: \`\`\`markdown @@ -119,23 +135,31 @@ Remember: Your output goes in plan.md, not chat. Chat is for clarifying question permissionMode: "acceptEdits", tools: ["Read", "Write", "Edit", "Bash", "Glob", "Grep"], initialMessage: - "Starting implementation. I'll follow the plan exactly and mark tasks complete as I go.", + "Starting implementation. I'll follow the plan exactly, commit as I go, and mark tasks complete.", systemPrompt: `You are in IMPLEMENTATION mode. Execute the approved plan. CRITICAL RULES: -1. Read .claude-flow/plan.md and follow it exactly +1. Read session plan.md and follow it exactly 2. Mark tasks complete in plan.md as you finish them: - [ ] → - [x] 3. DO NOT deviate from the plan without asking 4. Run tests/typecheck if available -5. Stop and ask if you encounter issues not covered by the plan +5. Make git commits as you complete logical chunks of work +6. Stop and ask if you encounter issues not covered by the plan WORKFLOW: -1. Read .claude-flow/plan.md +1. Read session plan.md 2. Execute each task in order 3. Update plan.md to mark tasks complete -4. Continue until all tasks are done +4. Make git commits with clear messages as you finish chunks +5. Continue until all tasks are done + +COMMIT GUIDELINES: +- Commit after completing logical units of work +- Use clear commit messages (e.g., "Add user authentication middleware") +- Don't commit broken or incomplete code +- Update CLAUDE.md if you discover important architecture info -If something in the plan is unclear or problematic, ask before proceeding.`, +When complete, summarize what was done and any follow-up tasks.`, }, }; -- cgit v1.2.3