@phmotad/fire-code 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +379 -0
- package/dist/agents/BaseAgent.d.ts +32 -0
- package/dist/agents/BaseAgent.d.ts.map +1 -0
- package/dist/agents/BaseAgent.js +19 -0
- package/dist/agents/BaseAgent.js.map +1 -0
- package/dist/agents/CodeAgent.d.ts +7 -0
- package/dist/agents/CodeAgent.d.ts.map +1 -0
- package/dist/agents/CodeAgent.js +130 -0
- package/dist/agents/CodeAgent.js.map +1 -0
- package/dist/cli/commands/corpus.d.ts +20 -0
- package/dist/cli/commands/corpus.d.ts.map +1 -0
- package/dist/cli/commands/corpus.js +60 -0
- package/dist/cli/commands/corpus.js.map +1 -0
- package/dist/cli/commands/daemon.d.ts +5 -0
- package/dist/cli/commands/daemon.d.ts.map +1 -0
- package/dist/cli/commands/daemon.js +79 -0
- package/dist/cli/commands/daemon.js.map +1 -0
- package/dist/cli/commands/dev.d.ts +2 -0
- package/dist/cli/commands/dev.d.ts.map +1 -0
- package/dist/cli/commands/dev.js +20 -0
- package/dist/cli/commands/dev.js.map +1 -0
- package/dist/cli/commands/index-cmd.d.ts +6 -0
- package/dist/cli/commands/index-cmd.d.ts.map +1 -0
- package/dist/cli/commands/index-cmd.js +57 -0
- package/dist/cli/commands/index-cmd.js.map +1 -0
- package/dist/cli/commands/init.d.ts +2 -0
- package/dist/cli/commands/init.d.ts.map +1 -0
- package/dist/cli/commands/init.js +173 -0
- package/dist/cli/commands/init.js.map +1 -0
- package/dist/cli/commands/install.d.ts +8 -0
- package/dist/cli/commands/install.d.ts.map +1 -0
- package/dist/cli/commands/install.js +154 -0
- package/dist/cli/commands/install.js.map +1 -0
- package/dist/cli/commands/observe.d.ts +19 -0
- package/dist/cli/commands/observe.d.ts.map +1 -0
- package/dist/cli/commands/observe.js +86 -0
- package/dist/cli/commands/observe.js.map +1 -0
- package/dist/cli/index.d.ts +3 -0
- package/dist/cli/index.d.ts.map +1 -0
- package/dist/cli/index.js +162 -0
- package/dist/cli/index.js.map +1 -0
- package/dist/config/defaults.d.ts +3 -0
- package/dist/config/defaults.d.ts.map +1 -0
- package/dist/config/defaults.js +8 -0
- package/dist/config/defaults.js.map +1 -0
- package/dist/config/loader.d.ts +3 -0
- package/dist/config/loader.d.ts.map +1 -0
- package/dist/config/loader.js +96 -0
- package/dist/config/loader.js.map +1 -0
- package/dist/config/types.d.ts +436 -0
- package/dist/config/types.d.ts.map +1 -0
- package/dist/config/types.js +73 -0
- package/dist/config/types.js.map +1 -0
- package/dist/core/ExecutionEngine.d.ts +26 -0
- package/dist/core/ExecutionEngine.d.ts.map +1 -0
- package/dist/core/ExecutionEngine.js +102 -0
- package/dist/core/ExecutionEngine.js.map +1 -0
- package/dist/core/TaskRouter.d.ts +3 -0
- package/dist/core/TaskRouter.d.ts.map +1 -0
- package/dist/core/TaskRouter.js +29 -0
- package/dist/core/TaskRouter.js.map +1 -0
- package/dist/daemon/DaemonClient.d.ts +8 -0
- package/dist/daemon/DaemonClient.d.ts.map +1 -0
- package/dist/daemon/DaemonClient.js +61 -0
- package/dist/daemon/DaemonClient.js.map +1 -0
- package/dist/daemon/DaemonServer.d.ts +17 -0
- package/dist/daemon/DaemonServer.d.ts.map +1 -0
- package/dist/daemon/DaemonServer.js +235 -0
- package/dist/daemon/DaemonServer.js.map +1 -0
- package/dist/db/DatabaseManager.d.ts +79 -0
- package/dist/db/DatabaseManager.d.ts.map +1 -0
- package/dist/db/DatabaseManager.js +212 -0
- package/dist/db/DatabaseManager.js.map +1 -0
- package/dist/db/schema.d.ts +2 -0
- package/dist/db/schema.d.ts.map +1 -0
- package/dist/db/schema.js +127 -0
- package/dist/db/schema.js.map +1 -0
- package/dist/git/CommitFormatter.d.ts +19 -0
- package/dist/git/CommitFormatter.d.ts.map +1 -0
- package/dist/git/CommitFormatter.js +47 -0
- package/dist/git/CommitFormatter.js.map +1 -0
- package/dist/git/GitManager.d.ts +28 -0
- package/dist/git/GitManager.d.ts.map +1 -0
- package/dist/git/GitManager.js +147 -0
- package/dist/git/GitManager.js.map +1 -0
- package/dist/graph/GraphStore.d.ts +54 -0
- package/dist/graph/GraphStore.d.ts.map +1 -0
- package/dist/graph/GraphStore.js +3 -0
- package/dist/graph/GraphStore.js.map +1 -0
- package/dist/graph/InMemoryGraphStore.d.ts +16 -0
- package/dist/graph/InMemoryGraphStore.d.ts.map +1 -0
- package/dist/graph/InMemoryGraphStore.js +75 -0
- package/dist/graph/InMemoryGraphStore.js.map +1 -0
- package/dist/graph/SQLiteGraphStore.d.ts +31 -0
- package/dist/graph/SQLiteGraphStore.d.ts.map +1 -0
- package/dist/graph/SQLiteGraphStore.js +158 -0
- package/dist/graph/SQLiteGraphStore.js.map +1 -0
- package/dist/index.d.ts +16 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +32 -0
- package/dist/index.js.map +1 -0
- package/dist/indexing/ASTParser.d.ts +32 -0
- package/dist/indexing/ASTParser.d.ts.map +1 -0
- package/dist/indexing/ASTParser.js +185 -0
- package/dist/indexing/ASTParser.js.map +1 -0
- package/dist/indexing/EmbeddingGenerator.d.ts +15 -0
- package/dist/indexing/EmbeddingGenerator.d.ts.map +1 -0
- package/dist/indexing/EmbeddingGenerator.js +66 -0
- package/dist/indexing/EmbeddingGenerator.js.map +1 -0
- package/dist/indexing/FileScanner.d.ts +10 -0
- package/dist/indexing/FileScanner.d.ts.map +1 -0
- package/dist/indexing/FileScanner.js +58 -0
- package/dist/indexing/FileScanner.js.map +1 -0
- package/dist/indexing/GraphBuilder.d.ts +4 -0
- package/dist/indexing/GraphBuilder.d.ts.map +1 -0
- package/dist/indexing/GraphBuilder.js +51 -0
- package/dist/indexing/GraphBuilder.js.map +1 -0
- package/dist/indexing/Indexer.d.ts +13 -0
- package/dist/indexing/Indexer.d.ts.map +1 -0
- package/dist/indexing/Indexer.js +68 -0
- package/dist/indexing/Indexer.js.map +1 -0
- package/dist/mcp/server.d.ts +2 -0
- package/dist/mcp/server.d.ts.map +1 -0
- package/dist/mcp/server.js +155 -0
- package/dist/mcp/server.js.map +1 -0
- package/dist/mcp/tools/corpus_search.d.ts +14 -0
- package/dist/mcp/tools/corpus_search.d.ts.map +1 -0
- package/dist/mcp/tools/corpus_search.js +33 -0
- package/dist/mcp/tools/corpus_search.js.map +1 -0
- package/dist/mcp/tools/execute.d.ts +19 -0
- package/dist/mcp/tools/execute.d.ts.map +1 -0
- package/dist/mcp/tools/execute.js +38 -0
- package/dist/mcp/tools/execute.js.map +1 -0
- package/dist/mcp/tools/get_context.d.ts +17 -0
- package/dist/mcp/tools/get_context.d.ts.map +1 -0
- package/dist/mcp/tools/get_context.js +50 -0
- package/dist/mcp/tools/get_context.js.map +1 -0
- package/dist/mcp/tools/get_graph.d.ts +26 -0
- package/dist/mcp/tools/get_graph.d.ts.map +1 -0
- package/dist/mcp/tools/get_graph.js +68 -0
- package/dist/mcp/tools/get_graph.js.map +1 -0
- package/dist/mcp/tools/observations.d.ts +23 -0
- package/dist/mcp/tools/observations.d.ts.map +1 -0
- package/dist/mcp/tools/observations.js +72 -0
- package/dist/mcp/tools/observations.js.map +1 -0
- package/dist/mcp/tools/search_code.d.ts +14 -0
- package/dist/mcp/tools/search_code.d.ts.map +1 -0
- package/dist/mcp/tools/search_code.js +38 -0
- package/dist/mcp/tools/search_code.js.map +1 -0
- package/dist/mcp/tools/smart_outline.d.ts +14 -0
- package/dist/mcp/tools/smart_outline.d.ts.map +1 -0
- package/dist/mcp/tools/smart_outline.js +99 -0
- package/dist/mcp/tools/smart_outline.js.map +1 -0
- package/dist/mcp/tools/smart_search.d.ts +20 -0
- package/dist/mcp/tools/smart_search.d.ts.map +1 -0
- package/dist/mcp/tools/smart_search.js +131 -0
- package/dist/mcp/tools/smart_search.js.map +1 -0
- package/dist/memory/FallbackMemory.d.ts +9 -0
- package/dist/memory/FallbackMemory.d.ts.map +1 -0
- package/dist/memory/FallbackMemory.js +70 -0
- package/dist/memory/FallbackMemory.js.map +1 -0
- package/dist/memory/HybridMemory.d.ts +20 -0
- package/dist/memory/HybridMemory.d.ts.map +1 -0
- package/dist/memory/HybridMemory.js +74 -0
- package/dist/memory/HybridMemory.js.map +1 -0
- package/dist/providers/AgentSDKProvider.d.ts +13 -0
- package/dist/providers/AgentSDKProvider.d.ts.map +1 -0
- package/dist/providers/AgentSDKProvider.js +64 -0
- package/dist/providers/AgentSDKProvider.js.map +1 -0
- package/dist/providers/AnthropicProvider.d.ts +11 -0
- package/dist/providers/AnthropicProvider.d.ts.map +1 -0
- package/dist/providers/AnthropicProvider.js +61 -0
- package/dist/providers/AnthropicProvider.js.map +1 -0
- package/dist/providers/LLMProvider.d.ts +12 -0
- package/dist/providers/LLMProvider.d.ts.map +1 -0
- package/dist/providers/LLMProvider.js +3 -0
- package/dist/providers/LLMProvider.js.map +1 -0
- package/dist/providers/OllamaProvider.d.ts +11 -0
- package/dist/providers/OllamaProvider.d.ts.map +1 -0
- package/dist/providers/OllamaProvider.js +71 -0
- package/dist/providers/OllamaProvider.js.map +1 -0
- package/dist/providers/OpenAIProvider.d.ts +11 -0
- package/dist/providers/OpenAIProvider.d.ts.map +1 -0
- package/dist/providers/OpenAIProvider.js +63 -0
- package/dist/providers/OpenAIProvider.js.map +1 -0
- package/dist/providers/OpenRouterProvider.d.ts +12 -0
- package/dist/providers/OpenRouterProvider.d.ts.map +1 -0
- package/dist/providers/OpenRouterProvider.js +89 -0
- package/dist/providers/OpenRouterProvider.js.map +1 -0
- package/dist/providers/ProviderFactory.d.ts +4 -0
- package/dist/providers/ProviderFactory.d.ts.map +1 -0
- package/dist/providers/ProviderFactory.js +27 -0
- package/dist/providers/ProviderFactory.js.map +1 -0
- package/dist/services/CorpusService.d.ts +27 -0
- package/dist/services/CorpusService.d.ts.map +1 -0
- package/dist/services/CorpusService.js +142 -0
- package/dist/services/CorpusService.js.map +1 -0
- package/dist/services/ObservationService.d.ts +17 -0
- package/dist/services/ObservationService.d.ts.map +1 -0
- package/dist/services/ObservationService.js +101 -0
- package/dist/services/ObservationService.js.map +1 -0
- package/dist/services/SessionService.d.ts +10 -0
- package/dist/services/SessionService.d.ts.map +1 -0
- package/dist/services/SessionService.js +38 -0
- package/dist/services/SessionService.js.map +1 -0
- package/dist/services/SummarizationService.d.ts +8 -0
- package/dist/services/SummarizationService.d.ts.map +1 -0
- package/dist/services/SummarizationService.js +65 -0
- package/dist/services/SummarizationService.js.map +1 -0
- package/dist/utils/errors.d.ts +26 -0
- package/dist/utils/errors.d.ts.map +1 -0
- package/dist/utils/errors.js +72 -0
- package/dist/utils/errors.js.map +1 -0
- package/dist/utils/logger.d.ts +4 -0
- package/dist/utils/logger.d.ts.map +1 -0
- package/dist/utils/logger.js +16 -0
- package/dist/utils/logger.js.map +1 -0
- package/dist/utils/paths.d.ts +10 -0
- package/dist/utils/paths.d.ts.map +1 -0
- package/dist/utils/paths.js +43 -0
- package/dist/utils/paths.js.map +1 -0
- package/dist/utils/privacy.d.ts +5 -0
- package/dist/utils/privacy.d.ts.map +1 -0
- package/dist/utils/privacy.js +39 -0
- package/dist/utils/privacy.js.map +1 -0
- package/dist/utils/zodToJsonSchema.d.ts +23 -0
- package/dist/utils/zodToJsonSchema.d.ts.map +1 -0
- package/dist/utils/zodToJsonSchema.js +52 -0
- package/dist/utils/zodToJsonSchema.js.map +1 -0
- package/dist/vector/MemoryVectorStore.d.ts +16 -0
- package/dist/vector/MemoryVectorStore.d.ts.map +1 -0
- package/dist/vector/MemoryVectorStore.js +97 -0
- package/dist/vector/MemoryVectorStore.js.map +1 -0
- package/dist/vector/VectorStore.d.ts +19 -0
- package/dist/vector/VectorStore.d.ts.map +1 -0
- package/dist/vector/VectorStore.js +3 -0
- package/dist/vector/VectorStore.js.map +1 -0
- package/dist/vector/VectraVectorStore.d.ts +23 -0
- package/dist/vector/VectraVectorStore.d.ts.map +1 -0
- package/dist/vector/VectraVectorStore.js +93 -0
- package/dist/vector/VectraVectorStore.js.map +1 -0
- package/examples/firecode.config.example.ts +87 -0
- package/package.json +111 -0
- package/plugin/.claude-plugin/plugin.json +17 -0
- package/plugin/hooks/hooks.json +86 -0
- package/plugin/scripts/context-inject.js +208 -0
- package/plugin/scripts/smart-install.js +33 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 FireCode Contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,379 @@
|
|
|
1
|
+
<h1 align="center">
|
|
2
|
+
🔥 Fire Code
|
|
3
|
+
</h1>
|
|
4
|
+
|
|
5
|
+
<h4 align="center">Intelligent MCP execution engine for AI coding agents — persistent memory, context-aware, Git-traceable.</h4>
|
|
6
|
+
|
|
7
|
+
<p align="center">
|
|
8
|
+
<a href="LICENSE">
|
|
9
|
+
<img src="https://img.shields.io/badge/License-MIT-blue.svg" alt="License: MIT">
|
|
10
|
+
</a>
|
|
11
|
+
<img src="https://img.shields.io/badge/version-0.2.0-green.svg" alt="Version">
|
|
12
|
+
<img src="https://img.shields.io/badge/node-%3E%3D20.0.0-brightgreen.svg" alt="Node">
|
|
13
|
+
<img src="https://img.shields.io/badge/MCP-compatible-red.svg" alt="MCP">
|
|
14
|
+
<img src="https://img.shields.io/badge/Claude%20Code-plugin-orange.svg" alt="Claude Code Plugin">
|
|
15
|
+
</p>
|
|
16
|
+
|
|
17
|
+
<p align="center">
|
|
18
|
+
<a href="#quick-start">Quick Start</a> •
|
|
19
|
+
<a href="#how-it-works">How It Works</a> •
|
|
20
|
+
<a href="#mcp-tools">MCP Tools</a> •
|
|
21
|
+
<a href="#knowledge-corpus">Knowledge Corpus</a> •
|
|
22
|
+
<a href="#privacy">Privacy</a> •
|
|
23
|
+
<a href="#daemon">Daemon</a> •
|
|
24
|
+
<a href="#configuration">Configuration</a> •
|
|
25
|
+
<a href="#contributing">Contributing</a>
|
|
26
|
+
</p>
|
|
27
|
+
|
|
28
|
+
---
|
|
29
|
+
|
|
30
|
+
## What is Fire Code?
|
|
31
|
+
|
|
32
|
+
Fire Code is an open-source **Claude Code plugin** and **MCP server** that gives AI coding agents:
|
|
33
|
+
|
|
34
|
+
- 🧠 **Hybrid Memory** — vector search (semantic, HNSW via Vectra) + dependency graph (SQLite + graphology)
|
|
35
|
+
- 🔍 **Smart Code Search** — find symbols, functions, and patterns without reading every file
|
|
36
|
+
- 📚 **Knowledge Corpus** — feed architecture docs, ADRs, and decisions directly into agent context
|
|
37
|
+
- 🌿 **Git Traceability** — every AI-generated change gets its own branch and conventional commit
|
|
38
|
+
- 📊 **Structural Outline** — understand any file without loading it fully (token-efficient)
|
|
39
|
+
- 👁️ **Session Observations** — persistent log of what was built, fixed, and decided
|
|
40
|
+
- 🔒 **Privacy Tags** — mark sections of code/docs as private; they never reach the LLM
|
|
41
|
+
- ⚡ **Context-Aware Execution** — CodeAgent retrieves relevant context before writing code
|
|
42
|
+
- 🔁 **Auto Re-index** — hooks re-index changed files after every `Write`/`Edit` tool call
|
|
43
|
+
- 🖥️ **Web Daemon** — local HTTP server with dashboard, auto-started by hooks
|
|
44
|
+
|
|
45
|
+
---
|
|
46
|
+
|
|
47
|
+
## Quick Start
|
|
48
|
+
|
|
49
|
+
**Install as a Claude Code plugin (one command):**
|
|
50
|
+
|
|
51
|
+
```bash
|
|
52
|
+
npx fire-code install
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
Or for Cursor / Windsurf:
|
|
56
|
+
|
|
57
|
+
```bash
|
|
58
|
+
npx fire-code install --ide cursor
|
|
59
|
+
npx fire-code install --ide windsurf
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
**Index your project:**
|
|
63
|
+
|
|
64
|
+
```bash
|
|
65
|
+
cd your-project
|
|
66
|
+
npx fire-code index
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
**Build the knowledge corpus** (optional but recommended):
|
|
70
|
+
|
|
71
|
+
```bash
|
|
72
|
+
npx fire-code corpus build # indexes docs/, README.md, ADRs, etc.
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
**Restart Claude Code.** The MCP tools are now available in every session.
|
|
76
|
+
|
|
77
|
+
---
|
|
78
|
+
|
|
79
|
+
## How It Works
|
|
80
|
+
|
|
81
|
+
### Architecture
|
|
82
|
+
|
|
83
|
+
```
|
|
84
|
+
Claude Code (host)
|
|
85
|
+
├── Lifecycle Hooks
|
|
86
|
+
│ ├── SessionStart → start daemon, inject .firecode/bootstrap.log context
|
|
87
|
+
│ ├── PostToolUse → re-index changed files (Write/Edit)
|
|
88
|
+
│ └── Stop → reserved for summarization
|
|
89
|
+
│
|
|
90
|
+
├── Worker Daemon (port 37778)
|
|
91
|
+
│ ├── GET /health → liveness check
|
|
92
|
+
│ ├── GET / → web dashboard (dark theme)
|
|
93
|
+
│ ├── POST /index → trigger re-index
|
|
94
|
+
│ ├── GET /context → hybrid context retrieval
|
|
95
|
+
│ └── GET /observations → recent session log
|
|
96
|
+
│
|
|
97
|
+
└── MCP Server (stdio)
|
|
98
|
+
├── Tier 1 — Fast
|
|
99
|
+
│ ├── firecode.smart_search — symbol/content search (~50 tokens/result)
|
|
100
|
+
│ └── firecode.smart_outline — file structure (folded view)
|
|
101
|
+
├── Tier 2 — Memory
|
|
102
|
+
│ ├── firecode.get_context — hybrid vector + graph retrieval
|
|
103
|
+
│ ├── firecode.search_code — semantic similarity over embeddings
|
|
104
|
+
│ ├── firecode.get_graph — dependency relationships (BFS, dependants)
|
|
105
|
+
│ ├── firecode.observations — session history (what was built/fixed)
|
|
106
|
+
│ └── firecode.corpus_search — search architecture docs and decisions
|
|
107
|
+
└── Tier 3 — Execute
|
|
108
|
+
└── firecode.execute — full task execution with Git
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
### Storage (`.firecode/`)
|
|
112
|
+
|
|
113
|
+
```
|
|
114
|
+
.firecode/
|
|
115
|
+
firecode.db — SQLite: graph nodes/edges, observations, corpus, sessions
|
|
116
|
+
vectors.db — Vectra HNSW index (all-MiniLM-L6-v2 embeddings)
|
|
117
|
+
bootstrap.log — indexing stats, injected on SessionStart
|
|
118
|
+
daemon.pid — worker daemon PID (auto-managed)
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
### Recommended Workflow (token-efficient)
|
|
122
|
+
|
|
123
|
+
```
|
|
124
|
+
1. smart_search(query) → find files/symbols (~50 tokens/result)
|
|
125
|
+
2. smart_outline(file_path) → see all symbols folded (~20 tokens/symbol)
|
|
126
|
+
3. corpus_search(query) → check architecture decisions and docs
|
|
127
|
+
4. get_context(query) → semantic + graph context for the task
|
|
128
|
+
5. execute(task) → make changes with Git traceability
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
---
|
|
132
|
+
|
|
133
|
+
## MCP Tools
|
|
134
|
+
|
|
135
|
+
| Tool | Tier | Description |
|
|
136
|
+
|------|------|-------------|
|
|
137
|
+
| `firecode.smart_search` | 1 — Fast | Search symbols, file names, content across codebase |
|
|
138
|
+
| `firecode.smart_outline` | 1 — Fast | Structural outline of a file (functions, classes, types) |
|
|
139
|
+
| `firecode.get_context` | 2 — Memory | Hybrid retrieval: vector semantic + graph traversal |
|
|
140
|
+
| `firecode.search_code` | 2 — Memory | Semantic similarity search over indexed embeddings |
|
|
141
|
+
| `firecode.get_graph` | 2 — Memory | Query dependency graph: nodes, edges, BFS, dependants |
|
|
142
|
+
| `firecode.observations` | 2 — Memory | Session history: what was built, fixed, and decided |
|
|
143
|
+
| `firecode.corpus_search` | 2 — Memory | Full-text search over architecture docs and ADRs |
|
|
144
|
+
| `firecode.execute` | 3 — Execute | Full task: branch → context → CodeAgent → commit |
|
|
145
|
+
|
|
146
|
+
### `get_graph` — advanced queries
|
|
147
|
+
|
|
148
|
+
```typescript
|
|
149
|
+
// Find all transitive dependencies of auth.ts
|
|
150
|
+
get_graph({ neighbors: "src/auth.ts", depth: 3 })
|
|
151
|
+
|
|
152
|
+
// Find everything that depends on crypto.ts
|
|
153
|
+
get_graph({ dependants: "src/crypto.ts" })
|
|
154
|
+
|
|
155
|
+
// List all nodes of a type
|
|
156
|
+
get_graph({ type: "function" })
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
### Example session
|
|
160
|
+
|
|
161
|
+
```typescript
|
|
162
|
+
// Step 1: Find what exists
|
|
163
|
+
smart_search({ query: "validateEmail", path: "src" })
|
|
164
|
+
// → L5 export [function] validateEmail(email: string): boolean
|
|
165
|
+
|
|
166
|
+
// Step 2: Check architecture decisions
|
|
167
|
+
corpus_search({ query: "password hashing policy" })
|
|
168
|
+
// → architecture.md: "Passwords are hashed with SHA-256 + salt. Do not use MD5."
|
|
169
|
+
|
|
170
|
+
// Step 3: Get semantic context
|
|
171
|
+
get_context({ query: "add forgot password feature" })
|
|
172
|
+
// → Returns relevant functions + dependency chain
|
|
173
|
+
|
|
174
|
+
// Step 4: Execute with full traceability
|
|
175
|
+
execute({ task: "add forgot password feature", type: "feature" })
|
|
176
|
+
// → Creates branch firecode/feat/forgot-password
|
|
177
|
+
// → Runs CodeAgent with context
|
|
178
|
+
// → Commits: feat(auth): add forgot password feature
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
---
|
|
182
|
+
|
|
183
|
+
## Knowledge Corpus
|
|
184
|
+
|
|
185
|
+
The corpus lets you feed project knowledge (architecture notes, ADRs, onboarding docs) directly into agent context via `firecode.corpus_search`.
|
|
186
|
+
|
|
187
|
+
```bash
|
|
188
|
+
# Build from docs/ directory automatically
|
|
189
|
+
npx fire-code corpus build
|
|
190
|
+
|
|
191
|
+
# Add a single entry manually
|
|
192
|
+
npx fire-code corpus prime --title "Auth Policy" --content "Never store raw passwords..."
|
|
193
|
+
|
|
194
|
+
# Search the corpus
|
|
195
|
+
npx fire-code corpus query "password hashing"
|
|
196
|
+
```
|
|
197
|
+
|
|
198
|
+
**Supported file types:** `.md`, `.txt`, `.rst`, `.mdx`
|
|
199
|
+
|
|
200
|
+
**Chunking:** documents are split by heading and paragraph (max 1500 chars/chunk) for accurate retrieval.
|
|
201
|
+
|
|
202
|
+
---
|
|
203
|
+
|
|
204
|
+
## Privacy
|
|
205
|
+
|
|
206
|
+
Mark any content as private — it will never be indexed, embedded, or sent to an LLM.
|
|
207
|
+
|
|
208
|
+
### Inline tags
|
|
209
|
+
|
|
210
|
+
```typescript
|
|
211
|
+
// @private
|
|
212
|
+
const SECRET_KEY = process.env.SECRET_KEY;
|
|
213
|
+
|
|
214
|
+
// This is public context
|
|
215
|
+
export function validateEmail(email: string): boolean { ... }
|
|
216
|
+
|
|
217
|
+
<private>
|
|
218
|
+
Internal implementation note: we use a vendor-specific workaround here.
|
|
219
|
+
</private>
|
|
220
|
+
```
|
|
221
|
+
|
|
222
|
+
```markdown
|
|
223
|
+
# public heading
|
|
224
|
+
|
|
225
|
+
# private: internal architecture note that should not be in agent context
|
|
226
|
+
```
|
|
227
|
+
|
|
228
|
+
### File-level privacy
|
|
229
|
+
|
|
230
|
+
Files matching these patterns are **never indexed:**
|
|
231
|
+
|
|
232
|
+
```
|
|
233
|
+
.env, .env.*, *.pem, *.key, *.cert, secrets.*, credentials.*
|
|
234
|
+
```
|
|
235
|
+
|
|
236
|
+
---
|
|
237
|
+
|
|
238
|
+
## Daemon
|
|
239
|
+
|
|
240
|
+
The Fire Code daemon is a local HTTP server (port 37778) that stays alive between sessions for instant context access. It is automatically started by the `SessionStart` hook.
|
|
241
|
+
|
|
242
|
+
```bash
|
|
243
|
+
npx fire-code daemon start # start in background
|
|
244
|
+
npx fire-code daemon stop # stop
|
|
245
|
+
npx fire-code daemon status # show PID + health
|
|
246
|
+
|
|
247
|
+
# The web dashboard is available at:
|
|
248
|
+
open http://localhost:37778
|
|
249
|
+
```
|
|
250
|
+
|
|
251
|
+
The dashboard shows real-time project stats, recent observations, and allows triggering a re-index.
|
|
252
|
+
|
|
253
|
+
---
|
|
254
|
+
|
|
255
|
+
## Configuration
|
|
256
|
+
|
|
257
|
+
Create `firecode.config.ts` in your project root (or run `fire-code init`):
|
|
258
|
+
|
|
259
|
+
```typescript
|
|
260
|
+
import type { FireCodeConfig } from '@phmotad/fire-code';
|
|
261
|
+
|
|
262
|
+
export default {
|
|
263
|
+
project: {
|
|
264
|
+
name: 'my-project',
|
|
265
|
+
},
|
|
266
|
+
llm: {
|
|
267
|
+
provider: 'anthropic', // anthropic | openai | openrouter | ollama
|
|
268
|
+
model: 'claude-sonnet-4-6',
|
|
269
|
+
apiKey: process.env.ANTHROPIC_API_KEY,
|
|
270
|
+
},
|
|
271
|
+
git: {
|
|
272
|
+
branchStrategy: 'increment', // reuse | increment | fail
|
|
273
|
+
workingTree: 'stash', // stash | commit | fail | ignore
|
|
274
|
+
autoCommit: true,
|
|
275
|
+
},
|
|
276
|
+
indexing: {
|
|
277
|
+
mode: 'lazy',
|
|
278
|
+
include: ['**/*.ts', '**/*.tsx', '**/*.js'],
|
|
279
|
+
exclude: ['node_modules', 'dist', '.git'],
|
|
280
|
+
},
|
|
281
|
+
} satisfies FireCodeConfig;
|
|
282
|
+
```
|
|
283
|
+
|
|
284
|
+
### LLM Providers
|
|
285
|
+
|
|
286
|
+
| Provider | env var | Default model |
|
|
287
|
+
|----------|---------|---------------|
|
|
288
|
+
| `anthropic` | `ANTHROPIC_API_KEY` | `claude-sonnet-4-6` |
|
|
289
|
+
| `openai` | `OPENAI_API_KEY` | `gpt-4o` |
|
|
290
|
+
| `openrouter` | `OPENROUTER_API_KEY` | `deepseek/deepseek-coder` |
|
|
291
|
+
| `ollama` | _(none)_ | `codellama` |
|
|
292
|
+
|
|
293
|
+
---
|
|
294
|
+
|
|
295
|
+
## CLI Commands
|
|
296
|
+
|
|
297
|
+
```bash
|
|
298
|
+
# Setup
|
|
299
|
+
npx fire-code install # Install plugin (Claude Code, Cursor, Windsurf)
|
|
300
|
+
npx fire-code install --ide cursor
|
|
301
|
+
npx fire-code uninstall # Remove plugin from IDE configs
|
|
302
|
+
npx fire-code init # Interactive setup wizard
|
|
303
|
+
npx fire-code update # Update to latest version
|
|
304
|
+
|
|
305
|
+
# Indexing
|
|
306
|
+
npx fire-code index # Index project (lazy mode)
|
|
307
|
+
npx fire-code index --mode full # Full re-index
|
|
308
|
+
|
|
309
|
+
# Corpus
|
|
310
|
+
npx fire-code corpus build # Build corpus from docs/
|
|
311
|
+
npx fire-code corpus prime # Add a single entry manually
|
|
312
|
+
npx fire-code corpus query <q> # Search the corpus
|
|
313
|
+
|
|
314
|
+
# Daemon
|
|
315
|
+
npx fire-code daemon start # Start background daemon
|
|
316
|
+
npx fire-code daemon stop # Stop daemon
|
|
317
|
+
npx fire-code daemon status # Check daemon status
|
|
318
|
+
|
|
319
|
+
# MCP Server
|
|
320
|
+
npx fire-code dev # Start MCP server (stdio)
|
|
321
|
+
```
|
|
322
|
+
|
|
323
|
+
---
|
|
324
|
+
|
|
325
|
+
## Contributing
|
|
326
|
+
|
|
327
|
+
Contributions are welcome! Fire Code is MIT-licensed and fully open source.
|
|
328
|
+
|
|
329
|
+
```bash
|
|
330
|
+
git clone https://github.com/phmotad/fire-code
|
|
331
|
+
cd fire-code
|
|
332
|
+
npm install
|
|
333
|
+
npm run build
|
|
334
|
+
npm test
|
|
335
|
+
```
|
|
336
|
+
|
|
337
|
+
### Project Structure
|
|
338
|
+
|
|
339
|
+
```
|
|
340
|
+
src/
|
|
341
|
+
cli/ — CLI commands (init, dev, index, install, daemon, corpus, update)
|
|
342
|
+
mcp/ — MCP server + tools
|
|
343
|
+
core/ — ExecutionEngine, TaskRouter
|
|
344
|
+
agents/ — CodeAgent
|
|
345
|
+
memory/ — HybridMemory, FallbackMemory
|
|
346
|
+
vector/ — VectraVectorStore (HNSW, all-MiniLM-L6-v2)
|
|
347
|
+
graph/ — SQLiteGraphStore (graphology traversal + SQLite persistence)
|
|
348
|
+
indexing/ — FileScanner, ASTParser, EmbeddingGenerator
|
|
349
|
+
git/ — GitManager, CommitFormatter
|
|
350
|
+
providers/ — LLM providers (Anthropic, OpenAI, Ollama, OpenRouter)
|
|
351
|
+
config/ — Zod schema, loader, defaults
|
|
352
|
+
daemon/ — DaemonServer (Express, port 37778), DaemonClient
|
|
353
|
+
services/ — CorpusService, ObservationService
|
|
354
|
+
utils/ — privacy.ts, logger.ts, errors.ts, paths.ts
|
|
355
|
+
db/ — DatabaseManager (SQLite), schema
|
|
356
|
+
plugin/
|
|
357
|
+
hooks/ — hooks.json (lifecycle hooks)
|
|
358
|
+
scripts/ — hook runner scripts
|
|
359
|
+
```
|
|
360
|
+
|
|
361
|
+
### Running Tests
|
|
362
|
+
|
|
363
|
+
```bash
|
|
364
|
+
npm test # all tests (84 passing)
|
|
365
|
+
npm run test:unit # unit tests only
|
|
366
|
+
npm run test:coverage # with coverage report
|
|
367
|
+
```
|
|
368
|
+
|
|
369
|
+
---
|
|
370
|
+
|
|
371
|
+
## License
|
|
372
|
+
|
|
373
|
+
MIT © FireCode Contributors
|
|
374
|
+
|
|
375
|
+
---
|
|
376
|
+
|
|
377
|
+
<p align="center">
|
|
378
|
+
Built with ❤️ for the AI coding agent community.
|
|
379
|
+
</p>
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { LLMProvider } from '../providers/LLMProvider.js';
|
|
2
|
+
import type { HybridMemory } from '../memory/HybridMemory.js';
|
|
3
|
+
import type { FireCodeConfig } from '../config/types.js';
|
|
4
|
+
export interface AgentTask {
|
|
5
|
+
id: string;
|
|
6
|
+
description: string;
|
|
7
|
+
type: 'feature' | 'fix' | 'refactor' | 'docs';
|
|
8
|
+
mode?: 'safe' | 'aggressive';
|
|
9
|
+
context?: string;
|
|
10
|
+
}
|
|
11
|
+
export interface FileChange {
|
|
12
|
+
path: string;
|
|
13
|
+
content: string;
|
|
14
|
+
operation: 'create' | 'modify' | 'delete';
|
|
15
|
+
}
|
|
16
|
+
export interface AgentResult {
|
|
17
|
+
taskId: string;
|
|
18
|
+
success: boolean;
|
|
19
|
+
changes: FileChange[];
|
|
20
|
+
explanation: string;
|
|
21
|
+
durationMs: number;
|
|
22
|
+
error?: string;
|
|
23
|
+
}
|
|
24
|
+
export declare abstract class BaseAgent {
|
|
25
|
+
protected readonly provider: LLMProvider;
|
|
26
|
+
protected readonly memory: HybridMemory;
|
|
27
|
+
protected readonly config: FireCodeConfig;
|
|
28
|
+
constructor(provider: LLMProvider, memory: HybridMemory, config: FireCodeConfig);
|
|
29
|
+
abstract execute(task: AgentTask): Promise<AgentResult>;
|
|
30
|
+
protected log(msg: string, data?: Record<string, unknown>): void;
|
|
31
|
+
}
|
|
32
|
+
//# sourceMappingURL=BaseAgent.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BaseAgent.d.ts","sourceRoot":"","sources":["../../src/agents/BaseAgent.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK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-0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.BaseAgent = void 0;
|
|
4
|
+
const logger_js_1 = require("../utils/logger.js");
|
|
5
|
+
class BaseAgent {
|
|
6
|
+
provider;
|
|
7
|
+
memory;
|
|
8
|
+
config;
|
|
9
|
+
constructor(provider, memory, config) {
|
|
10
|
+
this.provider = provider;
|
|
11
|
+
this.memory = memory;
|
|
12
|
+
this.config = config;
|
|
13
|
+
}
|
|
14
|
+
log(msg, data) {
|
|
15
|
+
logger_js_1.logger.debug({ agent: this.constructor.name, ...data }, msg);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
exports.BaseAgent = BaseAgent;
|
|
19
|
+
//# sourceMappingURL=BaseAgent.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BaseAgent.js","sourceRoot":"","sources":["../../src/agents/BaseAgent.ts"],"names":[],"mappings":";;;AAGA,kDAA4C;AAyB5C,MAAsB,SAAS;IAER;IACA;IACA;IAHrB,YACqB,QAAqB,EACrB,MAAoB,EACpB,MAAsB;QAFtB,aAAQ,GAAR,QAAQ,CAAa;QACrB,WAAM,GAAN,MAAM,CAAc;QACpB,WAAM,GAAN,MAAM,CAAgB;IACxC,CAAC;IAIM,GAAG,CAAC,GAAW,EAAE,IAA8B;QACvD,kBAAM,CAAC,KAAK,CAAC,EAAE,KAAK,EAAE,IAAI,CAAC,WAAW,CAAC,IAAI,EAAE,GAAG,IAAI,EAAE,EAAE,GAAG,CAAC,CAAC;IAC/D,CAAC;CACF;AAZD,8BAYC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { BaseAgent, type AgentTask, type AgentResult } from './BaseAgent.js';
|
|
2
|
+
export declare class CodeAgent extends BaseAgent {
|
|
3
|
+
execute(task: AgentTask): Promise<AgentResult>;
|
|
4
|
+
private buildPrompt;
|
|
5
|
+
private applyChanges;
|
|
6
|
+
}
|
|
7
|
+
//# sourceMappingURL=CodeAgent.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CodeAgent.d.ts","sourceRoot":"","sources":["../../src/agents/CodeAgent.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,SAAS,EAAE,KAAK,SAAS,EAAE,KAAK,WAAW,EAAmB,MAAM,gBAAgB,CAAC;AA4C9F,qBAAa,SAAU,SAAQ,SAAS;IAChC,OAAO,CAAC,IAAI,EAAE,SAAS,GAAG,OAAO,CAAC,WAAW,CAAC;IA8CpD,OAAO,CAAC,WAAW;YAcL,YAAY;CA8B3B"}
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CodeAgent = void 0;
|
|
4
|
+
const fs_1 = require("fs");
|
|
5
|
+
const path_1 = require("path");
|
|
6
|
+
const BaseAgent_js_1 = require("./BaseAgent.js");
|
|
7
|
+
const errors_js_1 = require("../utils/errors.js");
|
|
8
|
+
const SYSTEM_PROMPT = `You are Fire Code, a deterministic code execution agent.
|
|
9
|
+
|
|
10
|
+
Your job is to implement the given task by modifying source files.
|
|
11
|
+
|
|
12
|
+
RULES:
|
|
13
|
+
- Always respond with ONLY a JSON object (no markdown, no explanation outside JSON)
|
|
14
|
+
- The JSON must have this exact shape:
|
|
15
|
+
{
|
|
16
|
+
"explanation": "brief description of what you did",
|
|
17
|
+
"changes": [
|
|
18
|
+
{
|
|
19
|
+
"path": "relative/path/to/file.ts",
|
|
20
|
+
"operation": "create" | "modify" | "delete",
|
|
21
|
+
"content": "full file content (empty string for delete)"
|
|
22
|
+
}
|
|
23
|
+
]
|
|
24
|
+
}
|
|
25
|
+
- For "modify": include the ENTIRE new file content
|
|
26
|
+
- For "create": include the full content of the new file
|
|
27
|
+
- For "delete": set content to ""
|
|
28
|
+
- Paths must be relative to the project root
|
|
29
|
+
- Follow existing code style and patterns from the context
|
|
30
|
+
- Never break existing functionality
|
|
31
|
+
- Be minimal: only change what's necessary`;
|
|
32
|
+
function parseAgentResponse(raw) {
|
|
33
|
+
const cleaned = raw.trim().replace(/^```json\s*/i, '').replace(/```\s*$/i, '').trim();
|
|
34
|
+
try {
|
|
35
|
+
const parsed = JSON.parse(cleaned);
|
|
36
|
+
if (!parsed.explanation || !Array.isArray(parsed.changes)) {
|
|
37
|
+
throw new errors_js_1.ExecutionError('Invalid agent response structure');
|
|
38
|
+
}
|
|
39
|
+
return parsed;
|
|
40
|
+
}
|
|
41
|
+
catch (err) {
|
|
42
|
+
if (err instanceof errors_js_1.ExecutionError)
|
|
43
|
+
throw err;
|
|
44
|
+
throw new errors_js_1.ExecutionError(`Failed to parse agent response as JSON: ${String(err)}`, {
|
|
45
|
+
raw: raw.slice(0, 500),
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
class CodeAgent extends BaseAgent_js_1.BaseAgent {
|
|
50
|
+
async execute(task) {
|
|
51
|
+
const start = Date.now();
|
|
52
|
+
this.log('Starting task execution', { taskId: task.id, type: task.type });
|
|
53
|
+
try {
|
|
54
|
+
// 1. Retrieve context from memory
|
|
55
|
+
const ctx = await this.memory.retrieve(task.description, { k: 6 });
|
|
56
|
+
this.log('Context retrieved', { vectorResults: ctx.vectorResults.length, graphNodes: ctx.graphResults.length });
|
|
57
|
+
// 2. Build prompt
|
|
58
|
+
const prompt = this.buildPrompt(task, ctx.combined);
|
|
59
|
+
// 3. Call LLM
|
|
60
|
+
const raw = await this.provider.complete(prompt, {
|
|
61
|
+
systemPrompt: SYSTEM_PROMPT,
|
|
62
|
+
maxTokens: this.config.llm.maxTokens,
|
|
63
|
+
temperature: this.config.llm.temperature,
|
|
64
|
+
});
|
|
65
|
+
// 4. Parse response
|
|
66
|
+
const { explanation, changes } = parseAgentResponse(raw);
|
|
67
|
+
// 5. Apply changes (if not dry-run)
|
|
68
|
+
if (!this.config.execution.dryRun) {
|
|
69
|
+
await this.applyChanges(changes);
|
|
70
|
+
}
|
|
71
|
+
return {
|
|
72
|
+
taskId: task.id,
|
|
73
|
+
success: true,
|
|
74
|
+
changes,
|
|
75
|
+
explanation,
|
|
76
|
+
durationMs: Date.now() - start,
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
catch (err) {
|
|
80
|
+
return {
|
|
81
|
+
taskId: task.id,
|
|
82
|
+
success: false,
|
|
83
|
+
changes: [],
|
|
84
|
+
explanation: '',
|
|
85
|
+
durationMs: Date.now() - start,
|
|
86
|
+
error: String(err),
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
buildPrompt(task, context) {
|
|
91
|
+
return `## Task
|
|
92
|
+
Type: ${task.type}
|
|
93
|
+
Description: ${task.description}
|
|
94
|
+
Mode: ${task.mode ?? this.config.execution.mode}
|
|
95
|
+
|
|
96
|
+
## Project Context
|
|
97
|
+
${context}
|
|
98
|
+
|
|
99
|
+
## Instructions
|
|
100
|
+
Implement the task described above. Follow the existing patterns from the context.
|
|
101
|
+
Return ONLY the JSON response as specified in your instructions.`;
|
|
102
|
+
}
|
|
103
|
+
async applyChanges(changes) {
|
|
104
|
+
const cwd = process.cwd();
|
|
105
|
+
for (const change of changes) {
|
|
106
|
+
const absPath = (0, path_1.join)(cwd, change.path);
|
|
107
|
+
if (change.operation === 'delete') {
|
|
108
|
+
// Don't actually delete — just log (safety: user can delete manually)
|
|
109
|
+
this.log('Skipping delete operation (safe mode)', { path: change.path });
|
|
110
|
+
continue;
|
|
111
|
+
}
|
|
112
|
+
const dir = (0, path_1.dirname)(absPath);
|
|
113
|
+
if (!(0, fs_1.existsSync)(dir)) {
|
|
114
|
+
(0, fs_1.mkdirSync)(dir, { recursive: true });
|
|
115
|
+
}
|
|
116
|
+
if (change.operation === 'modify' && this.config.execution.conflictStrategy === 'fail') {
|
|
117
|
+
if ((0, fs_1.existsSync)(absPath)) {
|
|
118
|
+
const existing = (0, fs_1.readFileSync)(absPath, 'utf8');
|
|
119
|
+
if (existing !== change.content) {
|
|
120
|
+
this.log('Applying modify', { path: change.path });
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
(0, fs_1.writeFileSync)(absPath, change.content, 'utf8');
|
|
125
|
+
this.log('Applied change', { path: change.path, operation: change.operation });
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
exports.CodeAgent = CodeAgent;
|
|
130
|
+
//# sourceMappingURL=CodeAgent.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CodeAgent.js","sourceRoot":"","sources":["../../src/agents/CodeAgent.ts"],"names":[],"mappings":";;;AAAA,2BAAwE;AACxE,+BAAqC;AACrC,iDAA8F;AAC9F,kDAAoD;AAEpD,MAAM,aAAa,GAAG;;;;;;;;;;;;;;;;;;;;;;;2CAuBqB,CAAC;AAE5C,SAAS,kBAAkB,CAAC,GAAW;IACrC,MAAM,OAAO,GAAG,GAAG,CAAC,IAAI,EAAE,CAAC,OAAO,CAAC,cAAc,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,UAAU,EAAE,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC;IACtF,IAAI,CAAC;QACH,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,CAAmD,CAAC;QACrF,IAAI,CAAC,MAAM,CAAC,WAAW,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,OAAO,CAAC,EAAE,CAAC;YAC1D,MAAM,IAAI,0BAAc,CAAC,kCAAkC,CAAC,CAAC;QAC/D,CAAC;QACD,OAAO,MAAM,CAAC;IAChB,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,IAAI,GAAG,YAAY,0BAAc;YAAE,MAAM,GAAG,CAAC;QAC7C,MAAM,IAAI,0BAAc,CAAC,2CAA2C,MAAM,CAAC,GAAG,CAAC,EAAE,EAAE;YACjF,GAAG,EAAE,GAAG,CAAC,KAAK,CA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AAC,EAAE,CAAC;gBACrB,IAAA,cAAS,EAAC,GAAG,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;YACtC,CAAC;YAED,IAAI,MAAM,CAAC,SAAS,KAAK,QAAQ,IAAI,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,gBAAgB,KAAK,MAAM,EAAE,CAAC;gBACvF,IAAI,IAAA,eAAU,EAAC,OAAO,CAAC,EAAE,CAAC;oBACxB,MAAM,QAAQ,GAAG,IAAA,iBAAY,EAAC,OAAO,EAAE,MAAM,CAAC,CAAC;oBAC/C,IAAI,QAAQ,KAAK,MAAM,CAAC,OAAO,EAAE,CAAC;wBAChC,IAAI,CAAC,GAAG,CAAC,iBAAiB,EAAE,EAAE,IAAI,EAAE,MAAM,CAAC,IAAI,EAAE,CAAC,CAAC;oBACrD,CAAC;gBACH,CAAC;YACH,CAAC;YAED,IAAA,kBAAa,EAAC,OAAO,EAAE,MAAM,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;YAC/C,IAAI,CAAC,GAAG,CAAC,gBAAgB,EAAE,EAAE,IAAI,EAAE,MAAM,CAAC,IAAI,EAAE,SAAS,EAAE,MAAM,CAAC,SAAS,EAAE,CAAC,CAAC;QACjF,CAAC;IACH,CAAC;CACF;AA3FD,8BA2FC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
interface CorpusBuildOptions {
|
|
2
|
+
cwd: string;
|
|
3
|
+
includeCode?: boolean;
|
|
4
|
+
}
|
|
5
|
+
interface CorpusQueryOptions {
|
|
6
|
+
cwd: string;
|
|
7
|
+
limit?: number;
|
|
8
|
+
}
|
|
9
|
+
interface CorpusPrimeOptions {
|
|
10
|
+
cwd: string;
|
|
11
|
+
title: string;
|
|
12
|
+
content: string;
|
|
13
|
+
tags?: string[];
|
|
14
|
+
private?: boolean;
|
|
15
|
+
}
|
|
16
|
+
export declare function corpusBuildCommand(opts: CorpusBuildOptions): Promise<void>;
|
|
17
|
+
export declare function corpusQueryCommand(query: string, opts: CorpusQueryOptions): Promise<void>;
|
|
18
|
+
export declare function corpusPrimeCommand(opts: CorpusPrimeOptions): Promise<void>;
|
|
19
|
+
export {};
|
|
20
|
+
//# sourceMappingURL=corpus.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"corpus.d.ts","sourceRoot":"","sources":["../../../src/cli/commands/corpus.ts"],"names":[],"mappings":"AAMA,UAAU,kBAAkB;IAAG,GAAG,EAAE,MAAM,CAAC;IAAC,WAAW,CAAC,EAAE,OAAO,CAAA;CAAE;AACnE,UAAU,kBAAkB;IAAG,GAAG,EAAE,MAAM,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAA;CAAE;AAC5D,UAAU,kBAAkB;IAAG,GAAG,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAC;IAAC,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;IAAC,OAAO,CAAC,EAAE,OAAO,CAAA;CAAE;AAEhH,wBAAsB,kBAAkB,CAAC,IAAI,EAAE,kBAAkB,GAAG,OAAO,CAAC,IAAI,CAAC,CAiBhF;AAED,wBAAsB,kBAAkB,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,kBAAkB,GAAG,OAAO,CAAC,IAAI,CAAC,CAoB/F;AAED,wBAAsB,kBAAkB,CAAC,IAAI,EAAE,kBAAkB,GAAG,OAAO,CAAC,IAAI,CAAC,CAUhF"}
|