diff options
| author | Clawd <ai@clawd.bot> | 2026-02-28 15:26:21 -0800 |
|---|---|---|
| committer | Clawd <ai@clawd.bot> | 2026-02-28 15:26:21 -0800 |
| commit | 5bd5da261732a1fce6a94ffa4d348dd6c80887cf (patch) | |
| tree | 7893aea50ba0d37ceff3ecddef4abc8b8784b822 /dist/main/claude | |
| parent | 519d6b850e07a0387511a8f024dc394250b1a241 (diff) | |
Fix .gitignore: ignore dist/, .claude-flow/, and sync-conflict files
Remove accidentally committed build artifacts and working files.
Diffstat (limited to 'dist/main/claude')
| -rw-r--r-- | dist/main/claude/index.js | 109 | ||||
| -rw-r--r-- | dist/main/claude/phases.js | 147 |
2 files changed, 0 insertions, 256 deletions
diff --git a/dist/main/claude/index.js b/dist/main/claude/index.js deleted file mode 100644 index 42a9652..0000000 --- a/dist/main/claude/index.js +++ /dev/null | |||
| @@ -1,109 +0,0 @@ | |||
| 1 | "use strict"; | ||
| 2 | var __importDefault = (this && this.__importDefault) || function (mod) { | ||
| 3 | return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
| 4 | }; | ||
| 5 | Object.defineProperty(exports, "__esModule", { value: true }); | ||
| 6 | exports.sendMessage = sendMessage; | ||
| 7 | exports.interruptSession = interruptSession; | ||
| 8 | exports.triggerReview = triggerReview; | ||
| 9 | exports.advancePhase = advancePhase; | ||
| 10 | exports.readArtifact = readArtifact; | ||
| 11 | exports.writeArtifact = writeArtifact; | ||
| 12 | exports.getPhaseInitialMessage = getPhaseInitialMessage; | ||
| 13 | const claude_agent_sdk_1 = require("@anthropic-ai/claude-agent-sdk"); | ||
| 14 | const phases_1 = require("./phases"); | ||
| 15 | const projects_1 = require("../db/projects"); | ||
| 16 | const sessions_1 = require("../db/sessions"); | ||
| 17 | const node_fs_1 = __importDefault(require("node:fs")); | ||
| 18 | const node_path_1 = __importDefault(require("node:path")); | ||
| 19 | // Track active queries by session ID | ||
| 20 | const activeQueries = new Map(); | ||
| 21 | function ensureArtifactDir(projectPath) { | ||
| 22 | const dir = node_path_1.default.join(projectPath, ".claude-flow"); | ||
| 23 | if (!node_fs_1.default.existsSync(dir)) { | ||
| 24 | node_fs_1.default.mkdirSync(dir, { recursive: true }); | ||
| 25 | } | ||
| 26 | } | ||
| 27 | async function sendMessage({ session, message, onMessage, }) { | ||
| 28 | const project = (0, projects_1.getProject)(session.project_id); | ||
| 29 | if (!project) | ||
| 30 | throw new Error("Project not found"); | ||
| 31 | ensureArtifactDir(project.path); | ||
| 32 | const phaseConfig = (0, phases_1.getPhaseConfig)(session.phase, session.permission_mode); | ||
| 33 | const q = (0, claude_agent_sdk_1.query)({ | ||
| 34 | prompt: message, | ||
| 35 | options: { | ||
| 36 | cwd: project.path, | ||
| 37 | resume: session.claude_session_id ?? undefined, | ||
| 38 | tools: phaseConfig.tools, | ||
| 39 | permissionMode: phaseConfig.permissionMode, | ||
| 40 | systemPrompt: phaseConfig.systemPrompt, | ||
| 41 | }, | ||
| 42 | }); | ||
| 43 | activeQueries.set(session.id, q); | ||
| 44 | try { | ||
| 45 | for await (const msg of q) { | ||
| 46 | // Capture session ID from init message | ||
| 47 | if (msg.type === "system" && msg.subtype === "init") { | ||
| 48 | if (!session.claude_session_id) { | ||
| 49 | (0, sessions_1.updateSession)(session.id, { claude_session_id: msg.session_id }); | ||
| 50 | } | ||
| 51 | } | ||
| 52 | onMessage(msg); | ||
| 53 | } | ||
| 54 | } | ||
| 55 | finally { | ||
| 56 | activeQueries.delete(session.id); | ||
| 57 | } | ||
| 58 | } | ||
| 59 | function interruptSession(sessionId) { | ||
| 60 | const q = activeQueries.get(sessionId); | ||
| 61 | if (q) { | ||
| 62 | q.close(); | ||
| 63 | activeQueries.delete(sessionId); | ||
| 64 | } | ||
| 65 | } | ||
| 66 | /** | ||
| 67 | * Trigger a review: Claude reads the document and addresses user annotations | ||
| 68 | */ | ||
| 69 | async function triggerReview(session, onMessage) { | ||
| 70 | const docName = (0, phases_1.getArtifactFilename)(session.phase); | ||
| 71 | const message = `I've updated .claude-flow/${docName} with annotations. Read the file, find all my inline notes (marked with // REVIEW:, // NOTE:, TODO:, or similar), address each one, and update the document accordingly. Do not implement anything yet.`; | ||
| 72 | await sendMessage({ session, message, onMessage }); | ||
| 73 | } | ||
| 74 | /** | ||
| 75 | * Advance to the next phase | ||
| 76 | */ | ||
| 77 | function advancePhase(session) { | ||
| 78 | const nextPhase = (0, phases_1.getNextPhase)(session.phase); | ||
| 79 | if (nextPhase) { | ||
| 80 | (0, sessions_1.updateSession)(session.id, { phase: nextPhase }); | ||
| 81 | } | ||
| 82 | return nextPhase; | ||
| 83 | } | ||
| 84 | /** | ||
| 85 | * Read an artifact file from the project's .claude-flow directory | ||
| 86 | */ | ||
| 87 | function readArtifact(projectPath, filename) { | ||
| 88 | const filePath = node_path_1.default.join(projectPath, ".claude-flow", filename); | ||
| 89 | if (node_fs_1.default.existsSync(filePath)) { | ||
| 90 | return node_fs_1.default.readFileSync(filePath, "utf-8"); | ||
| 91 | } | ||
| 92 | return null; | ||
| 93 | } | ||
| 94 | /** | ||
| 95 | * Write an artifact file to the project's .claude-flow directory | ||
| 96 | */ | ||
| 97 | function writeArtifact(projectPath, filename, content) { | ||
| 98 | const dir = node_path_1.default.join(projectPath, ".claude-flow"); | ||
| 99 | if (!node_fs_1.default.existsSync(dir)) { | ||
| 100 | node_fs_1.default.mkdirSync(dir, { recursive: true }); | ||
| 101 | } | ||
| 102 | node_fs_1.default.writeFileSync(node_path_1.default.join(dir, filename), content, "utf-8"); | ||
| 103 | } | ||
| 104 | /** | ||
| 105 | * Get the initial message for a phase | ||
| 106 | */ | ||
| 107 | function getPhaseInitialMessage(phase) { | ||
| 108 | return (0, phases_1.getPhaseConfig)(phase).initialMessage; | ||
| 109 | } | ||
diff --git a/dist/main/claude/phases.js b/dist/main/claude/phases.js deleted file mode 100644 index 65ea46d..0000000 --- a/dist/main/claude/phases.js +++ /dev/null | |||
| @@ -1,147 +0,0 @@ | |||
| 1 | "use strict"; | ||
| 2 | Object.defineProperty(exports, "__esModule", { value: true }); | ||
| 3 | exports.phaseConfigs = void 0; | ||
| 4 | exports.getPhaseConfig = getPhaseConfig; | ||
| 5 | exports.getNextPhase = getNextPhase; | ||
| 6 | exports.getArtifactFilename = getArtifactFilename; | ||
| 7 | exports.phaseConfigs = { | ||
| 8 | research: { | ||
| 9 | permissionMode: "acceptEdits", | ||
| 10 | tools: ["Read", "Glob", "Grep", "Bash", "Write"], | ||
| 11 | initialMessage: "What areas of the codebase should I research? What are you trying to build?", | ||
| 12 | systemPrompt: `You are in RESEARCH mode. Your ONLY job is to understand the codebase. | ||
| 13 | |||
| 14 | CRITICAL RULES: | ||
| 15 | 1. You MUST write ALL findings to .claude-flow/research.md — this is your PRIMARY output | ||
| 16 | 2. DO NOT just respond in chat. The document viewer shows research.md, so write there. | ||
| 17 | 3. DO NOT suggest moving to planning or implementation | ||
| 18 | 4. DO NOT ask "are you ready to implement?" or similar | ||
| 19 | 5. DO NOT modify any source code files | ||
| 20 | 6. The user controls phase transitions via UI buttons — never prompt them about it | ||
| 21 | |||
| 22 | WORKFLOW: | ||
| 23 | 1. Ask what to research (if unclear) | ||
| 24 | 2. Read files thoroughly using Read, Glob, Grep | ||
| 25 | 3. Write structured findings to .claude-flow/research.md | ||
| 26 | 4. Keep updating research.md as you learn more | ||
| 27 | |||
| 28 | FORMAT for research.md: | ||
| 29 | \`\`\`markdown | ||
| 30 | # Research Findings | ||
| 31 | |||
| 32 | ## Overview | ||
| 33 | [High-level summary of what you found] | ||
| 34 | |||
| 35 | ## Architecture | ||
| 36 | [Key components, patterns, structure] | ||
| 37 | |||
| 38 | ## Relevant Files | ||
| 39 | [List of important files with descriptions] | ||
| 40 | |||
| 41 | ## Key Insights | ||
| 42 | [Important discoveries, patterns, potential issues] | ||
| 43 | |||
| 44 | ## Questions/Unknowns | ||
| 45 | [Things that need clarification] | ||
| 46 | \`\`\` | ||
| 47 | |||
| 48 | When the user adds annotations (// REVIEW:, // NOTE:, TODO:) to research.md and clicks Review, address each annotation and update the document. | ||
| 49 | |||
| 50 | Remember: Your output goes in research.md, not chat. Chat is for clarifying questions only.`, | ||
| 51 | }, | ||
| 52 | plan: { | ||
| 53 | permissionMode: "acceptEdits", | ||
| 54 | tools: ["Read", "Glob", "Grep", "Write"], | ||
| 55 | initialMessage: "I'll create a detailed implementation plan based on my research. Writing to plan.md...", | ||
| 56 | systemPrompt: `You are in PLANNING mode. Your ONLY job is to create an implementation plan. | ||
| 57 | |||
| 58 | CRITICAL RULES: | ||
| 59 | 1. You MUST write the plan to .claude-flow/plan.md — this is your PRIMARY output | ||
| 60 | 2. DO NOT just respond in chat. The document viewer shows plan.md, so write there. | ||
| 61 | 3. DO NOT implement anything — no code changes to source files | ||
| 62 | 4. DO NOT ask "should I start implementing?" or similar | ||
| 63 | 5. The user controls phase transitions via UI buttons — never prompt them about it | ||
| 64 | 6. Base your plan on .claude-flow/research.md | ||
| 65 | |||
| 66 | WORKFLOW: | ||
| 67 | 1. Read .claude-flow/research.md to understand the codebase | ||
| 68 | 2. Write a detailed plan to .claude-flow/plan.md | ||
| 69 | 3. Include specific code snippets showing proposed changes | ||
| 70 | 4. Make the plan detailed enough that implementation is mechanical | ||
| 71 | |||
| 72 | FORMAT for plan.md: | ||
| 73 | \`\`\`markdown | ||
| 74 | # Implementation Plan | ||
| 75 | |||
| 76 | ## Goal | ||
| 77 | [What we're building/changing] | ||
| 78 | |||
| 79 | ## Approach | ||
| 80 | [High-level strategy] | ||
| 81 | |||
| 82 | ## Changes | ||
| 83 | |||
| 84 | ### 1. [First change] | ||
| 85 | **File:** path/to/file.ts | ||
| 86 | **What:** [Description] | ||
| 87 | **Code:** | ||
| 88 | \\\`\\\`\\\`typescript | ||
| 89 | // Proposed code | ||
| 90 | \\\`\\\`\\\` | ||
| 91 | |||
| 92 | ### 2. [Second change] | ||
| 93 | ... | ||
| 94 | |||
| 95 | ## TODO | ||
| 96 | - [ ] Task 1 | ||
| 97 | - [ ] Task 2 | ||
| 98 | - [ ] Task 3 | ||
| 99 | |||
| 100 | ## Risks/Considerations | ||
| 101 | [Potential issues, edge cases] | ||
| 102 | \`\`\` | ||
| 103 | |||
| 104 | When the user adds annotations to plan.md and clicks Review, address each annotation and update the document. | ||
| 105 | |||
| 106 | Remember: Your output goes in plan.md, not chat. Chat is for clarifying questions only.`, | ||
| 107 | }, | ||
| 108 | implement: { | ||
| 109 | permissionMode: "acceptEdits", | ||
| 110 | tools: ["Read", "Write", "Edit", "Bash", "Glob", "Grep"], | ||
| 111 | initialMessage: "Starting implementation. I'll follow the plan exactly and mark tasks complete as I go.", | ||
| 112 | systemPrompt: `You are in IMPLEMENTATION mode. Execute the approved plan. | ||
| 113 | |||
| 114 | CRITICAL RULES: | ||
| 115 | 1. Read .claude-flow/plan.md and follow it exactly | ||
| 116 | 2. Mark tasks complete in plan.md as you finish them: - [ ] → - [x] | ||
| 117 | 3. DO NOT deviate from the plan without asking | ||
| 118 | 4. Run tests/typecheck if available | ||
| 119 | 5. Stop and ask if you encounter issues not covered by the plan | ||
| 120 | |||
| 121 | WORKFLOW: | ||
| 122 | 1. Read .claude-flow/plan.md | ||
| 123 | 2. Execute each task in order | ||
| 124 | 3. Update plan.md to mark tasks complete | ||
| 125 | 4. Continue until all tasks are done | ||
| 126 | |||
| 127 | If something in the plan is unclear or problematic, ask before proceeding.`, | ||
| 128 | }, | ||
| 129 | }; | ||
| 130 | function getPhaseConfig(phase, userPermissionMode) { | ||
| 131 | const config = { ...exports.phaseConfigs[phase] }; | ||
| 132 | if (phase === "implement" && userPermissionMode) { | ||
| 133 | config.permissionMode = userPermissionMode; | ||
| 134 | } | ||
| 135 | return config; | ||
| 136 | } | ||
| 137 | function getNextPhase(phase) { | ||
| 138 | const transitions = { | ||
| 139 | research: "plan", | ||
| 140 | plan: "implement", | ||
| 141 | implement: null, | ||
| 142 | }; | ||
| 143 | return transitions[phase]; | ||
| 144 | } | ||
| 145 | function getArtifactFilename(phase) { | ||
| 146 | return phase === "research" ? "research.md" : "plan.md"; | ||
| 147 | } | ||
