@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
|
@@ -0,0 +1,208 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* Fire Code — context-inject.js
|
|
4
|
+
*
|
|
5
|
+
* Hook runner invoked by Claude Code lifecycle events:
|
|
6
|
+
* session-start → inject rich memory context (observations + summaries)
|
|
7
|
+
* session-init → ensure session is registered in SQLite
|
|
8
|
+
* pre-read → inject file-level observation history before Claude reads a file
|
|
9
|
+
* post-tool → capture tool call as observation, re-index if Write/Edit
|
|
10
|
+
* stop → trigger session summarization
|
|
11
|
+
* session-end → mark session as completed
|
|
12
|
+
*
|
|
13
|
+
* Reads hook data from:
|
|
14
|
+
* CLAUDE_TOOL_NAME, CLAUDE_TOOL_INPUT_JSON, CLAUDE_TOOL_RESULT_JSON,
|
|
15
|
+
* CLAUDE_CWD, CLAUDE_SESSION_ID (when available)
|
|
16
|
+
*
|
|
17
|
+
* Always outputs { continue: true } — never blocks Claude.
|
|
18
|
+
*/
|
|
19
|
+
'use strict';
|
|
20
|
+
|
|
21
|
+
const { execFileSync, execSync } = require('child_process');
|
|
22
|
+
const { existsSync, readFileSync } = require('fs');
|
|
23
|
+
const path = require('path');
|
|
24
|
+
|
|
25
|
+
const event = process.argv[2] || 'session-start';
|
|
26
|
+
const cwd = process.env.CLAUDE_CWD || process.env.PWD || process.cwd();
|
|
27
|
+
const sessionId = process.env.CLAUDE_SESSION_ID || `session-${Date.now()}`;
|
|
28
|
+
const toolName = process.env.CLAUDE_TOOL_NAME || '';
|
|
29
|
+
const toolInput = safeJson(process.env.CLAUDE_TOOL_INPUT_JSON);
|
|
30
|
+
const toolResult = safeJson(process.env.CLAUDE_TOOL_RESULT_JSON);
|
|
31
|
+
|
|
32
|
+
const firedotDir = path.join(cwd, '.firecode');
|
|
33
|
+
const bootstrapLog = path.join(firedotDir, 'bootstrap.log');
|
|
34
|
+
const dbPath = path.join(firedotDir, 'firecode.db');
|
|
35
|
+
|
|
36
|
+
function safeJson(str) {
|
|
37
|
+
if (!str) return null;
|
|
38
|
+
try { return JSON.parse(str); } catch { return null; }
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
function silentContinue(context) {
|
|
42
|
+
const out = { continue: true, suppressOutput: true };
|
|
43
|
+
if (context) out.context = context;
|
|
44
|
+
process.stdout.write(JSON.stringify(out) + '\n');
|
|
45
|
+
process.exit(0);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
function readBootstrapLog() {
|
|
49
|
+
try {
|
|
50
|
+
if (!existsSync(bootstrapLog)) return null;
|
|
51
|
+
return readFileSync(bootstrapLog, 'utf8').trim().split('\n').slice(-5).join('\n');
|
|
52
|
+
} catch { return null; }
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
function getProjectName() {
|
|
56
|
+
try {
|
|
57
|
+
const pkg = JSON.parse(readFileSync(path.join(cwd, 'package.json'), 'utf8'));
|
|
58
|
+
return pkg.name || path.basename(cwd);
|
|
59
|
+
} catch { return path.basename(cwd); }
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
const DAEMON_PORT = 37778;
|
|
63
|
+
|
|
64
|
+
function daemonFetch(path, body) {
|
|
65
|
+
try {
|
|
66
|
+
// Synchronous HTTP to daemon (Node.js doesn't have sync fetch, use execFileSync curl)
|
|
67
|
+
const url = `http://127.0.0.1:${DAEMON_PORT}${path}`;
|
|
68
|
+
if (body) {
|
|
69
|
+
const result = execSync(
|
|
70
|
+
`curl -s -X POST -H "Content-Type: application/json" -d ${JSON.stringify(JSON.stringify(body))} ${url}`,
|
|
71
|
+
{ timeout: 5_000, stdio: ['pipe', 'pipe', 'ignore'] }
|
|
72
|
+
);
|
|
73
|
+
return result ? JSON.parse(result.toString('utf8')) : null;
|
|
74
|
+
}
|
|
75
|
+
const result = execSync(`curl -s ${url}`, { timeout: 5_000, stdio: ['pipe', 'pipe', 'ignore'] });
|
|
76
|
+
return result ? JSON.parse(result.toString('utf8')) : null;
|
|
77
|
+
} catch { return null; }
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
function isDaemonAlive() {
|
|
81
|
+
const resp = daemonFetch('/health');
|
|
82
|
+
return resp && resp.ok === true;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
function runFireCode(args, input) {
|
|
86
|
+
try {
|
|
87
|
+
const opts = { cwd, stdio: ['pipe', 'pipe', 'ignore'], timeout: 25_000, shell: true };
|
|
88
|
+
const result = execSync(`npx fire-code ${args.join(' ')}`, opts);
|
|
89
|
+
return result ? result.toString('utf8').trim() : '';
|
|
90
|
+
} catch { return ''; }
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
function captureObservation() {
|
|
94
|
+
if (!toolName) return;
|
|
95
|
+
const writeTools = new Set(['Write', 'Edit', 'MultiEdit', 'Create']);
|
|
96
|
+
|
|
97
|
+
const payload = JSON.stringify({
|
|
98
|
+
event: 'observation',
|
|
99
|
+
tool: toolName,
|
|
100
|
+
input: toolInput,
|
|
101
|
+
result: toolResult,
|
|
102
|
+
sessionId,
|
|
103
|
+
cwd,
|
|
104
|
+
project: getProjectName(),
|
|
105
|
+
});
|
|
106
|
+
|
|
107
|
+
try {
|
|
108
|
+
// Fire-and-forget: capture observation via fire-code internal API
|
|
109
|
+
runFireCode(['observe', '--data', `'${payload.replace(/'/g, "'\\''")}'`]);
|
|
110
|
+
} catch { /* never block */ }
|
|
111
|
+
|
|
112
|
+
// Re-index changed files
|
|
113
|
+
if (writeTools.has(toolName)) {
|
|
114
|
+
try {
|
|
115
|
+
execSync(`npx fire-code index --mode=lazy --cwd "${cwd}"`, {
|
|
116
|
+
stdio: 'ignore', timeout: 25_000, shell: true,
|
|
117
|
+
});
|
|
118
|
+
} catch { /* never block */ }
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
try {
|
|
123
|
+
switch (event) {
|
|
124
|
+
case 'session-start': {
|
|
125
|
+
const project = getProjectName();
|
|
126
|
+
const logLines = readBootstrapLog();
|
|
127
|
+
const contextParts = [];
|
|
128
|
+
|
|
129
|
+
if (logLines) {
|
|
130
|
+
contextParts.push(`[Fire Code] Project index loaded for **${project}**:\n${logLines}`);
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
// Try daemon first (warm model, faster); fallback to CLI
|
|
134
|
+
if (existsSync(dbPath)) {
|
|
135
|
+
let memContext = '';
|
|
136
|
+
if (isDaemonAlive()) {
|
|
137
|
+
const resp = daemonFetch('/observations', null);
|
|
138
|
+
if (resp && resp.results && resp.results.length > 0) {
|
|
139
|
+
memContext = resp.results.slice(0, 8).map(o => `• [${o.type}] ${o.summary}`).join('\n');
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
if (!memContext) memContext = runFireCode(['context', '--cwd', cwd, '--limit', '8']);
|
|
143
|
+
if (memContext) contextParts.push(memContext);
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
if (contextParts.length > 0) {
|
|
147
|
+
contextParts.push('\nUse `firecode.get_context`, `firecode.smart_search`, `firecode.corpus_search`, or `firecode.observations` to query project memory.');
|
|
148
|
+
silentContinue(contextParts.join('\n\n'));
|
|
149
|
+
} else {
|
|
150
|
+
silentContinue();
|
|
151
|
+
}
|
|
152
|
+
break;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
case 'session-init': {
|
|
156
|
+
// Start daemon if not running (background, non-blocking)
|
|
157
|
+
if (existsSync(dbPath) && !isDaemonAlive()) {
|
|
158
|
+
try {
|
|
159
|
+
execSync(`npx fire-code daemon start --cwd "${cwd}"`, {
|
|
160
|
+
stdio: 'ignore', timeout: 10_000, shell: true,
|
|
161
|
+
});
|
|
162
|
+
} catch { /* best-effort */ }
|
|
163
|
+
}
|
|
164
|
+
// Ensure session is registered (idempotent)
|
|
165
|
+
runFireCode(['session', 'start', '--cwd', cwd, '--id', sessionId]);
|
|
166
|
+
silentContinue();
|
|
167
|
+
break;
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
case 'pre-read': {
|
|
171
|
+
// Inject file-level observation history before Claude reads a file
|
|
172
|
+
const filePath = toolInput?.file_path || toolInput?.path;
|
|
173
|
+
if (!filePath || !existsSync(dbPath)) { silentContinue(); break; }
|
|
174
|
+
|
|
175
|
+
const fileContext = runFireCode(['context', '--file', filePath, '--cwd', cwd]);
|
|
176
|
+
if (fileContext) {
|
|
177
|
+
silentContinue(`[Fire Code] History for \`${path.basename(filePath)}\`:\n${fileContext}`);
|
|
178
|
+
} else {
|
|
179
|
+
silentContinue();
|
|
180
|
+
}
|
|
181
|
+
break;
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
case 'post-tool': {
|
|
185
|
+
captureObservation();
|
|
186
|
+
silentContinue();
|
|
187
|
+
break;
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
case 'stop': {
|
|
191
|
+
// Trigger summarization of the current session
|
|
192
|
+
runFireCode(['session', 'summarize', '--cwd', cwd, '--id', sessionId]);
|
|
193
|
+
silentContinue();
|
|
194
|
+
break;
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
case 'session-end': {
|
|
198
|
+
runFireCode(['session', 'end', '--cwd', cwd, '--id', sessionId]);
|
|
199
|
+
silentContinue();
|
|
200
|
+
break;
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
default:
|
|
204
|
+
silentContinue();
|
|
205
|
+
}
|
|
206
|
+
} catch {
|
|
207
|
+
silentContinue();
|
|
208
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* Fire Code — smart-install.js
|
|
4
|
+
* Runs on Setup/SessionStart: ensures Node >= 20 and fire-code is available.
|
|
5
|
+
* Exits silently with continue=true so Claude Code is never blocked.
|
|
6
|
+
*/
|
|
7
|
+
'use strict';
|
|
8
|
+
|
|
9
|
+
const { execSync } = require('child_process');
|
|
10
|
+
|
|
11
|
+
function silentExit() {
|
|
12
|
+
process.stdout.write(JSON.stringify({ continue: true, suppressOutput: true }) + '\n');
|
|
13
|
+
process.exit(0);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
try {
|
|
17
|
+
const major = parseInt(process.versions.node.split('.')[0], 10);
|
|
18
|
+
if (major < 20) {
|
|
19
|
+
process.stderr.write('[fire-code] Node >= 20 required. Current: ' + process.versions.node + '\n');
|
|
20
|
+
silentExit();
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
// Check if fire-code is accessible
|
|
24
|
+
try {
|
|
25
|
+
execSync('npx fire-code --version', { stdio: 'ignore', timeout: 10_000 });
|
|
26
|
+
} catch {
|
|
27
|
+
process.stderr.write('[fire-code] Warning: fire-code not found in PATH. Run: npx fire-code install\n');
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
silentExit();
|
|
31
|
+
} catch {
|
|
32
|
+
silentExit();
|
|
33
|
+
}
|