aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/claude/phases.ts
diff options
context:
space:
mode:
authorClawd <ai@clawd.bot>2026-02-28 15:35:00 -0800
committerClawd <ai@clawd.bot>2026-02-28 15:35:00 -0800
commit0edd7235cd861ef77d4ceb37a594ae65df52624b (patch)
treec169d9bb1d0bda40198817e26c781101b1637730 /src/main/claude/phases.ts
parent5bd5da261732a1fce6a94ffa4d348dd6c80887cf (diff)
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)
Diffstat (limited to 'src/main/claude/phases.ts')
-rw-r--r--src/main/claude/phases.ts62
1 files changed, 43 insertions, 19 deletions
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 {
10 initialMessage: string; 10 initialMessage: string;
11} 11}
12 12
13// Get session-specific artifact path
14export function getSessionArtifactDir(sessionId: string): string {
15 return `.claude-flow/sessions/${sessionId}`;
16}
17
18export function getArtifactPath(phase: Phase, sessionId: string): string {
19 const dir = getSessionArtifactDir(sessionId);
20 const filename = phase === "research" ? "research.md" : "plan.md";
21 return `${dir}/${filename}`;
22}
23
13export const phaseConfigs: Record<Phase, PhaseConfig> = { 24export const phaseConfigs: Record<Phase, PhaseConfig> = {
14 research: { 25 research: {
15 permissionMode: "acceptEdits", 26 permissionMode: "acceptEdits",
@@ -19,18 +30,24 @@ export const phaseConfigs: Record<Phase, PhaseConfig> = {
19 systemPrompt: `You are in RESEARCH mode. Your ONLY job is to understand the codebase. 30 systemPrompt: `You are in RESEARCH mode. Your ONLY job is to understand the codebase.
20 31
21CRITICAL RULES: 32CRITICAL RULES:
221. You MUST write ALL findings to .claude-flow/research.md — this is your PRIMARY output 331. You MUST write ALL findings to the session research.md — this is your PRIMARY output
232. DO NOT just respond in chat. The document viewer shows research.md, so write there. 342. DO NOT just respond in chat. The document viewer shows research.md, so write there.
243. DO NOT suggest moving to planning or implementation 353. DO NOT suggest moving to planning or implementation
254. DO NOT ask "are you ready to implement?" or similar 364. DO NOT ask "are you ready to implement?" or similar
265. DO NOT modify any source code files 375. DO NOT modify any source code files
276. The user controls phase transitions via UI buttons — never prompt them about it 386. The user controls phase transitions via UI buttons — never prompt them about it
28 39
40CONTEXT:
41- Read CLAUDE.md in the project root (if it exists) for codebase overview
42- This file contains general architecture info shared across all sessions
43- If CLAUDE.md doesn't exist, create it with your initial findings
44
29WORKFLOW: 45WORKFLOW:
301. Ask what to research (if unclear) 461. Read CLAUDE.md (create if missing)
312. Read files thoroughly using Read, Glob, Grep 472. Ask what to research (if unclear)
323. Write structured findings to .claude-flow/research.md 483. Read files thoroughly using Read, Glob, Grep
334. Keep updating research.md as you learn more 494. Write findings to session research.md
505. Update CLAUDE.md with any new general insights
34 51
35FORMAT for research.md: 52FORMAT for research.md:
36\`\`\`markdown 53\`\`\`markdown
@@ -52,8 +69,6 @@ FORMAT for research.md:
52[Things that need clarification] 69[Things that need clarification]
53\`\`\` 70\`\`\`
54 71
55When the user adds annotations (// REVIEW:, // NOTE:, TODO:) to research.md and clicks Review, address each annotation and update the document.
56
57Remember: Your output goes in research.md, not chat. Chat is for clarifying questions only.`, 72Remember: Your output goes in research.md, not chat. Chat is for clarifying questions only.`,
58 }, 73 },
59 74
@@ -65,18 +80,19 @@ Remember: Your output goes in research.md, not chat. Chat is for clarifying ques
65 systemPrompt: `You are in PLANNING mode. Your ONLY job is to create an implementation plan. 80 systemPrompt: `You are in PLANNING mode. Your ONLY job is to create an implementation plan.
66 81
67CRITICAL RULES: 82CRITICAL RULES:
681. You MUST write the plan to .claude-flow/plan.md — this is your PRIMARY output 831. You MUST write the plan to session plan.md — this is your PRIMARY output
692. DO NOT just respond in chat. The document viewer shows plan.md, so write there. 842. DO NOT just respond in chat. The document viewer shows plan.md, so write there.
703. DO NOT implement anything — no code changes to source files 853. DO NOT implement anything — no code changes to source files
714. DO NOT ask "should I start implementing?" or similar 864. DO NOT ask "should I start implementing?" or similar
725. The user controls phase transitions via UI buttons — never prompt them about it 875. The user controls phase transitions via UI buttons — never prompt them about it
736. Base your plan on .claude-flow/research.md 886. Base your plan on the session research.md and CLAUDE.md
74 89
75WORKFLOW: 90WORKFLOW:
761. Read .claude-flow/research.md to understand the codebase 911. Read CLAUDE.md for codebase overview
772. Write a detailed plan to .claude-flow/plan.md 922. Read the session research.md to understand the specific task
783. Include specific code snippets showing proposed changes 933. Write a detailed plan to session plan.md
794. Make the plan detailed enough that implementation is mechanical 944. Include specific code snippets showing proposed changes
955. Make the plan detailed enough that implementation is mechanical
80 96
81FORMAT for plan.md: 97FORMAT for plan.md:
82\`\`\`markdown 98\`\`\`markdown
@@ -119,23 +135,31 @@ Remember: Your output goes in plan.md, not chat. Chat is for clarifying question
119 permissionMode: "acceptEdits", 135 permissionMode: "acceptEdits",
120 tools: ["Read", "Write", "Edit", "Bash", "Glob", "Grep"], 136 tools: ["Read", "Write", "Edit", "Bash", "Glob", "Grep"],
121 initialMessage: 137 initialMessage:
122 "Starting implementation. I'll follow the plan exactly and mark tasks complete as I go.", 138 "Starting implementation. I'll follow the plan exactly, commit as I go, and mark tasks complete.",
123 systemPrompt: `You are in IMPLEMENTATION mode. Execute the approved plan. 139 systemPrompt: `You are in IMPLEMENTATION mode. Execute the approved plan.
124 140
125CRITICAL RULES: 141CRITICAL RULES:
1261. Read .claude-flow/plan.md and follow it exactly 1421. Read session plan.md and follow it exactly
1272. Mark tasks complete in plan.md as you finish them: - [ ] → - [x] 1432. Mark tasks complete in plan.md as you finish them: - [ ] → - [x]
1283. DO NOT deviate from the plan without asking 1443. DO NOT deviate from the plan without asking
1294. Run tests/typecheck if available 1454. Run tests/typecheck if available
1305. Stop and ask if you encounter issues not covered by the plan 1465. Make git commits as you complete logical chunks of work
1476. Stop and ask if you encounter issues not covered by the plan
131 148
132WORKFLOW: 149WORKFLOW:
1331. Read .claude-flow/plan.md 1501. Read session plan.md
1342. Execute each task in order 1512. Execute each task in order
1353. Update plan.md to mark tasks complete 1523. Update plan.md to mark tasks complete
1364. Continue until all tasks are done 1534. Make git commits with clear messages as you finish chunks
1545. Continue until all tasks are done
155
156COMMIT GUIDELINES:
157- Commit after completing logical units of work
158- Use clear commit messages (e.g., "Add user authentication middleware")
159- Don't commit broken or incomplete code
160- Update CLAUDE.md if you discover important architecture info
137 161
138If something in the plan is unclear or problematic, ask before proceeding.`, 162When complete, summarize what was done and any follow-up tasks.`,
139 }, 163 },
140}; 164};
141 165