agentcache 0.3.0 → 0.3.2
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/README.md +120 -31
- package/dist/{chunk-IER56P6A.js → chunk-OXHITHDC.js} +98 -3
- package/dist/{chunk-TE6DBLJ5.js → chunk-QVQJPJGX.js} +1 -1
- package/dist/{chunk-WHP4Z32Z.js → chunk-S4GSIEKL.js} +3 -1
- package/dist/{chunk-RXBTPJVW.js → chunk-VFE4SDMO.js} +1 -1
- package/dist/{chunk-MMSMDJ4O.js → chunk-ZVDODLZ7.js} +3 -0
- package/dist/cli.js +8 -8
- package/dist/{compile-all-RWCAU7MO.js → compile-all-XQBGUI3F.js} +8 -6
- package/dist/mcp.js +5 -5
- package/dist/{paths-LOLEIMI5.js → paths-ULP2T4HZ.js} +1 -1
- package/dist/postinstall.js +3 -3
- package/dist/{pre-tool-use-OWWS54XG.js → pre-tool-use-UBJFRHCW.js} +2 -2
- package/dist/{session-start-YSRUGD5N.js → session-start-SUR6FXRD.js} +3 -3
- package/dist/{setup-5APZETPV.js → setup-TVNRAAK3.js} +2 -2
- package/dist/{sqlite-AUND6HGQ.js → sqlite-MP6SRBBQ.js} +1 -1
- package/dist/{stop-6SROS34Q.js → stop-HFZZ2LFA.js} +3 -3
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -27,33 +27,43 @@ No `init`. No `setup`. No config. No second command. The install itself:
|
|
|
27
27
|
2. Detects installed IDEs (Claude Code, Cursor, Roo Code, Windsurf, Continue, Codex)
|
|
28
28
|
3. Registers itself as an MCP server in each
|
|
29
29
|
4. Sets up Claude Code hooks for automatic transcript recovery
|
|
30
|
+
5. Spawns `compile-all` in background — compiles your entire transcript history from all IDEs immediately
|
|
30
31
|
|
|
31
32
|
## How It Works
|
|
32
33
|
|
|
33
34
|
```
|
|
34
|
-
|
|
35
|
-
│
|
|
36
|
-
│
|
|
37
|
-
│ ┌──────────┐ ┌──────────┐ ┌──────────┐ ┌──────────┐
|
|
38
|
-
│ │ Claude │ │ Cursor │ │ Roo │ │ Codex │ ...
|
|
39
|
-
│ │ Code │ │ │ │ Code │ │ │
|
|
40
|
-
│ └────┬─────┘ └────┬─────┘ └────┬─────┘ └────┬─────┘
|
|
41
|
-
│ │
|
|
42
|
-
│
|
|
43
|
-
│ │
|
|
44
|
-
│ MCP Protocol (stdio)
|
|
45
|
-
│ │
|
|
46
|
-
│ ┌────────────┴────────────┐
|
|
47
|
-
│ │ AgentCache MCP Server
|
|
48
|
-
│ │ (agentcache serve) │
|
|
49
|
-
│
|
|
50
|
-
│
|
|
51
|
-
│
|
|
52
|
-
│
|
|
53
|
-
│
|
|
54
|
-
│
|
|
55
|
-
│
|
|
56
|
-
|
|
35
|
+
┌────────────────────────────────────────────────────────────────────────┐
|
|
36
|
+
│ Your Machine │
|
|
37
|
+
│ │
|
|
38
|
+
│ ┌──────────┐ ┌──────────┐ ┌──────────┐ ┌──────────┐ │
|
|
39
|
+
│ │ Claude │ │ Cursor │ │ Roo │ │ Codex │ ... │
|
|
40
|
+
│ │ Code │ │ │ │ Code │ │ │ │
|
|
41
|
+
│ └────┬─────┘ └────┬─────┘ └────┬─────┘ └────┬─────┘ │
|
|
42
|
+
│ │ │ │ │ │
|
|
43
|
+
│ └─────────────┴─────────────┴─────────────┘ │
|
|
44
|
+
│ │ │
|
|
45
|
+
│ MCP Protocol (stdio) │
|
|
46
|
+
│ │ │
|
|
47
|
+
│ ┌────────────┴────────────┐ ┌────────────────────┐ │
|
|
48
|
+
│ │ AgentCache MCP Server │ │ agentcache │ │
|
|
49
|
+
│ │ (agentcache serve) │ │ compile-all │ │
|
|
50
|
+
│ │ │ │ (standalone CLI) │ │
|
|
51
|
+
│ │ spawns compile-all ────┼────▶│ │ │
|
|
52
|
+
│ │ when pending > 20 │ │ Uses: claude, │ │
|
|
53
|
+
│ └────────────┬────────────┘ │ codex, gemini, │ │
|
|
54
|
+
│ │ │ ollama, API keys │ │
|
|
55
|
+
│ │ └─────────┬──────────┘ │
|
|
56
|
+
│ │ │ │
|
|
57
|
+
│ ┌─────────┴────────────────────────────┘ │
|
|
58
|
+
│ │ │
|
|
59
|
+
│ ▼ │
|
|
60
|
+
│ ┌────────────────────┐ │
|
|
61
|
+
│ │ ~/.agentcache/ │ │
|
|
62
|
+
│ │ agentcache.db │ │
|
|
63
|
+
│ │ compile-all.lock │ │
|
|
64
|
+
│ │ (SQLite + WAL) │ │
|
|
65
|
+
│ └────────────────────┘ │
|
|
66
|
+
└────────────────────────────────────────────────────────────────────────┘
|
|
57
67
|
```
|
|
58
68
|
|
|
59
69
|
### The Cycle
|
|
@@ -92,9 +102,33 @@ AgentCache exposes 8 tools via the Model Context Protocol (prefixed as `mcp--age
|
|
|
92
102
|
|
|
93
103
|
```bash
|
|
94
104
|
agentcache status # Show knowledge stats for current project
|
|
105
|
+
agentcache compile-all # Batch-compile all unprocessed transcripts
|
|
95
106
|
agentcache setup # Re-register with IDEs (only if postinstall failed)
|
|
96
107
|
```
|
|
97
108
|
|
|
109
|
+
### `compile-all` — Standalone Batch Compilation
|
|
110
|
+
|
|
111
|
+
Processes all pending transcripts across every IDE without depending on MCP pipes or active sessions. Runs independently in a terminal.
|
|
112
|
+
|
|
113
|
+
```bash
|
|
114
|
+
agentcache compile-all
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
**LLM backend detection** (first available wins):
|
|
118
|
+
1. CLI tools with stored auth: `claude`, `codex`, `gemini`, `copilot`, `aider`, `goose`
|
|
119
|
+
2. Ollama running locally (`localhost:11434`)
|
|
120
|
+
3. `ANTHROPIC_API_KEY` environment variable
|
|
121
|
+
4. `OPENAI_API_KEY` environment variable
|
|
122
|
+
|
|
123
|
+
No API keys needed if you have any coding CLI installed — it uses their stored authentication.
|
|
124
|
+
|
|
125
|
+
**Automatic triggers:**
|
|
126
|
+
- Runs as a background process after `npm install -g agentcache` (clears initial backlog)
|
|
127
|
+
- Spawned by the MCP server when pending transcripts exceed 20 (ongoing janitor)
|
|
128
|
+
- Lockfile (`~/.agentcache/compile-all.lock`) prevents concurrent runs
|
|
129
|
+
|
|
130
|
+
**Transcript sources:** Claude Code, Continue, Codex, Roo Code, Goose
|
|
131
|
+
|
|
98
132
|
Internal commands (called by hooks automatically, never by users):
|
|
99
133
|
```bash
|
|
100
134
|
agentcache serve # MCP server (IDEs spawn this)
|
|
@@ -119,9 +153,10 @@ One database per developer (`~/.agentcache/agentcache.db`), not per project. Rul
|
|
|
119
153
|
|
|
120
154
|
### Resilient to Abrupt Exits
|
|
121
155
|
|
|
122
|
-
Sessions can end without warning (crash, ctrl-c, network drop). AgentCache handles this through:
|
|
156
|
+
Sessions can end without warning (crash, ctrl-c, network drop, MCP pipe death). AgentCache handles this through:
|
|
123
157
|
- **Incremental submission** — observations are saved as they happen, not batched at the end
|
|
124
|
-
- **Transcript recovery** —
|
|
158
|
+
- **Transcript recovery** — transcripts persist on disk across 5 IDEs (Claude Code, Continue, Codex, Roo Code, Goose) and are compiled by `compile-all`
|
|
159
|
+
- **Pipe-independent compilation** — `compile-all` runs as a standalone process, not through MCP stdio pipes that can break during long operations
|
|
125
160
|
- **Pending queue in SQLite** — concurrent access is safe, nothing lost to race conditions
|
|
126
161
|
|
|
127
162
|
### Anti-Bloat
|
|
@@ -138,22 +173,70 @@ AgentCache prevents knowledge from growing unbounded:
|
|
|
138
173
|
|-----|-----|-------------|--------------------|----|
|
|
139
174
|
| Claude Code | Yes | Yes (automatic) | Full (JSONL) | Stop, SessionStart, PreToolUse |
|
|
140
175
|
| Cursor | Yes | Yes (automatic) | Incremental only | — |
|
|
141
|
-
| Roo Code | Yes | Yes (automatic) |
|
|
176
|
+
| Roo Code | Yes | Yes (automatic) | Full (JSON via compile-all) | — |
|
|
142
177
|
| Windsurf | Yes | Yes (automatic) | Incremental only | — |
|
|
143
178
|
| Continue | Yes | Yes (automatic) | Full (JSON) | — |
|
|
144
|
-
| Codex | Yes | Yes (automatic) |
|
|
179
|
+
| Codex | Yes | Yes (automatic) | Full (JSONL via compile-all) | — |
|
|
180
|
+
| Goose | — | — | Full (SQLite via compile-all) | — |
|
|
145
181
|
|
|
146
182
|
All IDEs are fully auto-approved at install time — no manual steps required.
|
|
147
183
|
|
|
148
184
|
"Incremental only" means if the agent submits observations during the session, they're saved. If the session terminates before any submission, those observations are lost (no transcript access).
|
|
149
185
|
|
|
186
|
+
"via compile-all" means `agentcache compile-all` discovers and processes these transcripts in batch, independent of any active MCP session.
|
|
187
|
+
|
|
188
|
+
## Skill Output (Agent Skills Spec)
|
|
189
|
+
|
|
190
|
+
Compiled knowledge is automatically projected to SKILL.md files — the [Agent Skills open standard](https://agentskills.io) supported by 38+ tools (Claude Code, Cursor, Codex, Gemini CLI, Copilot, Roo Code, and more).
|
|
191
|
+
|
|
192
|
+
```
|
|
193
|
+
~/.agentcache/skills/developer-knowledge/SKILL.md # Global: rules + lessons
|
|
194
|
+
<repo>/.agentcache/skills/project-knowledge/SKILL.md # Project: decisions + context
|
|
195
|
+
```
|
|
196
|
+
|
|
197
|
+
**Global skill** (`~/.agentcache/skills/`) — your developer identity. Rules and lessons learned across all projects. Auto-discovered by any Agent Skills-compatible tool without MCP.
|
|
198
|
+
|
|
199
|
+
**Project skill** (`<repo>/.agentcache/skills/`) — project-specific decisions, context, and rules. Git-trackable. Team members get it on clone. **This is team knowledge sharing without a sync server — just git.**
|
|
200
|
+
|
|
201
|
+
Skills auto-refresh on every compilation. Each file stays under 5,000 tokens (Agent Skills budget limit). High-confidence items appear first.
|
|
202
|
+
|
|
203
|
+
Example output:
|
|
204
|
+
```markdown
|
|
205
|
+
---
|
|
206
|
+
name: project-knowledge
|
|
207
|
+
description: "Project-specific decisions, rules, context, and lessons — compiled automatically from coding sessions by AgentCache"
|
|
208
|
+
---
|
|
209
|
+
|
|
210
|
+
## Rules
|
|
211
|
+
|
|
212
|
+
Follow these without exception:
|
|
213
|
+
|
|
214
|
+
- Always use path aliases in imports
|
|
215
|
+
- Never commit .env files [ENFORCED]
|
|
216
|
+
|
|
217
|
+
## Decisions
|
|
218
|
+
|
|
219
|
+
Architectural choices in effect — do not contradict:
|
|
220
|
+
|
|
221
|
+
- Using Drizzle ORM over Prisma for raw SQL escape hatches
|
|
222
|
+
- PostgreSQL for all persistent state, Redis for ephemeral cache only
|
|
223
|
+
|
|
224
|
+
## Current Context
|
|
225
|
+
|
|
226
|
+
Active project state (may be temporal):
|
|
227
|
+
|
|
228
|
+
- Migrating from REST to GraphQL, both coexist until Q3
|
|
229
|
+
```
|
|
230
|
+
|
|
150
231
|
## Data Storage
|
|
151
232
|
|
|
152
|
-
All data lives in `~/.agentcache
|
|
233
|
+
All data lives in `~/.agentcache/` (SQLite with WAL mode for concurrent access).
|
|
153
234
|
|
|
154
235
|
```
|
|
155
236
|
~/.agentcache/
|
|
156
|
-
|
|
237
|
+
├── agentcache.db # Knowledge, observations, sessions, pending queue
|
|
238
|
+
├── compile-all.lock # Prevents concurrent compilation
|
|
239
|
+
└── skills/developer-knowledge/SKILL.md # Global skill (auto-generated)
|
|
157
240
|
```
|
|
158
241
|
|
|
159
242
|
No data leaves your machine. No network calls. No telemetry. No accounts.
|
|
@@ -176,7 +259,13 @@ Extract → Normalize → Canonicalize → Cluster → Detect Contradictions →
|
|
|
176
259
|
- authority: AUTO/USER
|
|
177
260
|
```
|
|
178
261
|
|
|
179
|
-
|
|
262
|
+
**Two compilation paths:**
|
|
263
|
+
- **In-session** — the agent in your IDE processes extraction prompts via MCP tools (no separate LLM calls needed)
|
|
264
|
+
- **Batch (`compile-all`)** — runs independently using any available LLM CLI or API, processes the full backlog without depending on active sessions
|
|
265
|
+
|
|
266
|
+
**Two output formats:**
|
|
267
|
+
- **MCP injection** — structured context served to agents at session start via `inject_context`
|
|
268
|
+
- **SKILL.md files** — Agent Skills spec-compliant files auto-discovered by 38+ tools without MCP
|
|
180
269
|
|
|
181
270
|
## Project Identity
|
|
182
271
|
|
|
@@ -197,7 +286,7 @@ Projects are identified by a hash of their full filesystem path, not just the fo
|
|
|
197
286
|
| Windsurf | Supported |
|
|
198
287
|
| Continue | Supported |
|
|
199
288
|
| Codex | Supported |
|
|
200
|
-
| Goose (
|
|
289
|
+
| Goose | Supported (transcript recovery via SQLite) |
|
|
201
290
|
| Aider | Coming soon |
|
|
202
291
|
| GitHub Copilot | Coming soon |
|
|
203
292
|
| Zed AI | Coming soon |
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
getDataDir,
|
|
3
3
|
getGitContext
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-S4GSIEKL.js";
|
|
5
5
|
|
|
6
6
|
// src/knowledge/passes/3-canonicalizer.ts
|
|
7
7
|
import { createHash } from "crypto";
|
|
@@ -428,6 +428,97 @@ function formatItems(items) {
|
|
|
428
428
|
}).join("\n") + "\n";
|
|
429
429
|
}
|
|
430
430
|
|
|
431
|
+
// src/knowledge/passes/7b-skill-projector.ts
|
|
432
|
+
import { mkdirSync as mkdirSync2, writeFileSync as writeFileSync2 } from "fs";
|
|
433
|
+
import { join } from "path";
|
|
434
|
+
import { homedir } from "os";
|
|
435
|
+
var MAX_SKILL_TOKENS = 5e3;
|
|
436
|
+
var AVG_CHARS_PER_TOKEN = 4;
|
|
437
|
+
var MAX_SKILL_CHARS = MAX_SKILL_TOKENS * AVG_CHARS_PER_TOKEN;
|
|
438
|
+
function projectToSkills(items, projectRoot) {
|
|
439
|
+
const active = items.filter((i) => i.status === "active");
|
|
440
|
+
const globalItems = active.filter((i) => i.scope === "global");
|
|
441
|
+
const projectItems = active.filter((i) => i.scope === "project");
|
|
442
|
+
writeGlobalSkill(globalItems);
|
|
443
|
+
writeProjectSkill(projectItems, projectRoot);
|
|
444
|
+
}
|
|
445
|
+
function writeGlobalSkill(items) {
|
|
446
|
+
const skillDir = join(homedir(), ".agentcache", "skills", "developer-knowledge");
|
|
447
|
+
mkdirSync2(skillDir, { recursive: true });
|
|
448
|
+
const rules = items.filter((i) => i.type === "rule").sort(byConfidence);
|
|
449
|
+
const lessons = items.filter((i) => i.type === "lesson").sort(byConfidence);
|
|
450
|
+
const body = buildSkillBody(rules, lessons, [], []);
|
|
451
|
+
const content = buildSkillFile(
|
|
452
|
+
"developer-knowledge",
|
|
453
|
+
"Engineering rules and lessons learned across all projects \u2014 compiled automatically from coding sessions by AgentCache",
|
|
454
|
+
body
|
|
455
|
+
);
|
|
456
|
+
writeFileSync2(join(skillDir, "SKILL.md"), truncateToLimit(content), "utf-8");
|
|
457
|
+
}
|
|
458
|
+
function writeProjectSkill(items, projectRoot) {
|
|
459
|
+
if (!projectRoot || projectRoot === process.cwd()) return;
|
|
460
|
+
if (items.length === 0) return;
|
|
461
|
+
const skillDir = join(projectRoot, ".agentcache", "skills", "project-knowledge");
|
|
462
|
+
mkdirSync2(skillDir, { recursive: true });
|
|
463
|
+
const rules = items.filter((i) => i.type === "rule").sort(byConfidence);
|
|
464
|
+
const lessons = items.filter((i) => i.type === "lesson").sort(byConfidence);
|
|
465
|
+
const decisions = items.filter((i) => i.type === "decision").sort(byConfidence);
|
|
466
|
+
const context = items.filter((i) => i.type === "context").sort((a, b) => b.lastSeenAt - a.lastSeenAt);
|
|
467
|
+
const body = buildSkillBody(rules, lessons, decisions, context);
|
|
468
|
+
const content = buildSkillFile(
|
|
469
|
+
"project-knowledge",
|
|
470
|
+
"Project-specific decisions, rules, context, and lessons \u2014 compiled automatically from coding sessions by AgentCache",
|
|
471
|
+
body
|
|
472
|
+
);
|
|
473
|
+
writeFileSync2(join(skillDir, "SKILL.md"), truncateToLimit(content), "utf-8");
|
|
474
|
+
}
|
|
475
|
+
function buildSkillFile(name, description, body) {
|
|
476
|
+
return `---
|
|
477
|
+
name: ${name}
|
|
478
|
+
description: "${description}"
|
|
479
|
+
---
|
|
480
|
+
|
|
481
|
+
${body}`;
|
|
482
|
+
}
|
|
483
|
+
function buildSkillBody(rules, lessons, decisions, context) {
|
|
484
|
+
let out = "";
|
|
485
|
+
if (rules.length > 0) {
|
|
486
|
+
out += "## Rules\n\nFollow these without exception:\n\n";
|
|
487
|
+
out += rules.map((r) => `- ${r.content}${enforceTag(r)}`).join("\n") + "\n\n";
|
|
488
|
+
}
|
|
489
|
+
if (lessons.length > 0) {
|
|
490
|
+
out += "## Lessons\n\nPitfalls learned from past sessions:\n\n";
|
|
491
|
+
out += lessons.map((l) => `- ${l.content}`).join("\n") + "\n\n";
|
|
492
|
+
}
|
|
493
|
+
if (decisions.length > 0) {
|
|
494
|
+
out += "## Decisions\n\nArchitectural choices in effect \u2014 do not contradict:\n\n";
|
|
495
|
+
out += decisions.map((d) => `- ${d.content}`).join("\n") + "\n\n";
|
|
496
|
+
}
|
|
497
|
+
if (context.length > 0) {
|
|
498
|
+
out += "## Current Context\n\nActive project state (may be temporal):\n\n";
|
|
499
|
+
out += context.map((c) => `- ${c.content}`).join("\n") + "\n\n";
|
|
500
|
+
}
|
|
501
|
+
return out.trimEnd() + "\n";
|
|
502
|
+
}
|
|
503
|
+
function enforceTag(item) {
|
|
504
|
+
return item.enforce ? " [ENFORCED]" : "";
|
|
505
|
+
}
|
|
506
|
+
function byConfidence(a, b) {
|
|
507
|
+
const order = { high: 3, medium: 2, low: 1 };
|
|
508
|
+
return (order[b.confidence] || 0) - (order[a.confidence] || 0);
|
|
509
|
+
}
|
|
510
|
+
function truncateToLimit(content) {
|
|
511
|
+
if (content.length <= MAX_SKILL_CHARS) return content;
|
|
512
|
+
const lines = content.split("\n");
|
|
513
|
+
let result = "";
|
|
514
|
+
for (const line of lines) {
|
|
515
|
+
if ((result + line + "\n").length > MAX_SKILL_CHARS - 50) break;
|
|
516
|
+
result += line + "\n";
|
|
517
|
+
}
|
|
518
|
+
result += "\n<!-- Truncated to stay within 5000 token skill budget -->\n";
|
|
519
|
+
return result;
|
|
520
|
+
}
|
|
521
|
+
|
|
431
522
|
// src/knowledge/compiler.ts
|
|
432
523
|
var COMPILER_VERSION = "0.1.0";
|
|
433
524
|
function startCompile(events, sessionId, project, projectRoot, repo, transcriptPath) {
|
|
@@ -472,7 +563,9 @@ function processExtraction(repo, responseText, sessionId, project, projectRoot)
|
|
|
472
563
|
repo.saveObservations(normalized);
|
|
473
564
|
if (canonicalized.needsClustering.length === 0) {
|
|
474
565
|
saveCompileRun(repo, sessionId, project, normalized.length, canonicalized.autoReinforced.length, 0, 0, 0, 0, 0, Date.now());
|
|
475
|
-
|
|
566
|
+
const activeItems = repo.getKnowledgeItems(project, { status: "active" });
|
|
567
|
+
projectToMarkdown(activeItems, getDataDir(), COMPILER_VERSION);
|
|
568
|
+
projectToSkills(activeItems, projectRoot);
|
|
476
569
|
return {
|
|
477
570
|
status: "complete",
|
|
478
571
|
diagnostics: formatDiagnostics(normalized.length, canonicalized.autoReinforced.length, 0, 0, 0, 0, 0, project, sessionId)
|
|
@@ -539,7 +632,9 @@ function processClustering(repo, responseText, sessionId, project, projectRoot)
|
|
|
539
632
|
}
|
|
540
633
|
const totalObs = sessionObs.length;
|
|
541
634
|
saveCompileRun(repo, sessionId, project, totalObs, 0, compiled.created.length, compiled.reinforced.length, compiled.superseded.length, compiled.deprecated.length, compiled.ignored, startedAt);
|
|
542
|
-
|
|
635
|
+
const activeItems = repo.getKnowledgeItems(project, { status: "active" });
|
|
636
|
+
projectToMarkdown(activeItems, getDataDir(), COMPILER_VERSION);
|
|
637
|
+
projectToSkills(activeItems, projectRoot);
|
|
543
638
|
return {
|
|
544
639
|
status: "complete",
|
|
545
640
|
diagnostics: formatDiagnostics(totalObs, 0, compiled.created.length, compiled.reinforced.length, compiled.superseded.length, compiled.deprecated.length, compiled.ignored, project, sessionId)
|
|
@@ -8,12 +8,14 @@ import { createHash } from "crypto";
|
|
|
8
8
|
import { execSync } from "child_process";
|
|
9
9
|
function run(cmd, cwd) {
|
|
10
10
|
try {
|
|
11
|
-
return execSync(cmd, { cwd, encoding: "utf-8", timeout: 5e3 }).trim();
|
|
11
|
+
return execSync(cmd, { cwd, encoding: "utf-8", timeout: 5e3, stdio: ["pipe", "pipe", "pipe"] }).trim();
|
|
12
12
|
} catch {
|
|
13
13
|
return "";
|
|
14
14
|
}
|
|
15
15
|
}
|
|
16
16
|
function getGitContext(projectRoot) {
|
|
17
|
+
const empty = { branch: "", commit: "", recentCommits: [], modifiedFiles: [] };
|
|
18
|
+
if (!run("git rev-parse --git-dir", projectRoot)) return empty;
|
|
17
19
|
const branch = run("git rev-parse --abbrev-ref HEAD", projectRoot);
|
|
18
20
|
const commit = run("git rev-parse --short HEAD", projectRoot);
|
|
19
21
|
const recentCommits = run("git log --oneline -10", projectRoot).split("\n").filter(Boolean);
|
|
@@ -128,6 +128,9 @@ var SqliteKnowledgeRepository = class {
|
|
|
128
128
|
if (!row) return null;
|
|
129
129
|
return this.mapSession(row);
|
|
130
130
|
}
|
|
131
|
+
updateSessionTranscriptPath(sessionId, transcriptPath) {
|
|
132
|
+
this.db.prepare("UPDATE sessions SET transcript_path = ? WHERE id = ?").run(transcriptPath, sessionId);
|
|
133
|
+
}
|
|
131
134
|
getCompiledTranscriptPaths(project) {
|
|
132
135
|
const rows = this.db.prepare("SELECT transcript_path FROM sessions WHERE project = ? AND transcript_path != ''").all(project);
|
|
133
136
|
return rows.map((r) => r.transcript_path);
|
package/dist/cli.js
CHANGED
|
@@ -3,9 +3,9 @@
|
|
|
3
3
|
// src/cli.ts
|
|
4
4
|
import { Command } from "commander";
|
|
5
5
|
var program = new Command();
|
|
6
|
-
program.name("agentcache").description("Engineering Knowledge Compiler \u2014 universal, zero-config").version("0.3.
|
|
6
|
+
program.name("agentcache").description("Engineering Knowledge Compiler \u2014 universal, zero-config").version("0.3.1");
|
|
7
7
|
program.command("setup").description("Detect IDEs and register AgentCache (runs automatically on install)").action(async () => {
|
|
8
|
-
const { runSetup } = await import("./setup-
|
|
8
|
+
const { runSetup } = await import("./setup-TVNRAAK3.js");
|
|
9
9
|
await runSetup();
|
|
10
10
|
});
|
|
11
11
|
program.command("serve").description("Start AgentCache MCP server (spawned by IDEs automatically)").action(async () => {
|
|
@@ -13,7 +13,7 @@ program.command("serve").description("Start AgentCache MCP server (spawned by ID
|
|
|
13
13
|
await startMcpServer();
|
|
14
14
|
});
|
|
15
15
|
program.command("compile-session").description("Stop hook: queue transcript for compilation").action(async () => {
|
|
16
|
-
const { handleStop } = await import("./stop-
|
|
16
|
+
const { handleStop } = await import("./stop-HFZZ2LFA.js");
|
|
17
17
|
let payload;
|
|
18
18
|
try {
|
|
19
19
|
let data = "";
|
|
@@ -28,11 +28,11 @@ program.command("compile-session").description("Stop hook: queue transcript for
|
|
|
28
28
|
await handleStop(payload);
|
|
29
29
|
});
|
|
30
30
|
program.command("discover").description("SessionStart hook: discover uncompiled transcripts").action(async () => {
|
|
31
|
-
const { handleSessionStart } = await import("./session-start-
|
|
31
|
+
const { handleSessionStart } = await import("./session-start-SUR6FXRD.js");
|
|
32
32
|
await handleSessionStart();
|
|
33
33
|
});
|
|
34
34
|
program.command("enforce").description("PreToolUse hook: policy enforcement").action(async () => {
|
|
35
|
-
const { handlePreToolUse } = await import("./pre-tool-use-
|
|
35
|
+
const { handlePreToolUse } = await import("./pre-tool-use-UBJFRHCW.js");
|
|
36
36
|
let data = "";
|
|
37
37
|
for await (const chunk of process.stdin) {
|
|
38
38
|
data += chunk;
|
|
@@ -46,16 +46,16 @@ program.command("enforce").description("PreToolUse hook: policy enforcement").ac
|
|
|
46
46
|
}
|
|
47
47
|
});
|
|
48
48
|
program.command("compile-all").description("Batch-compile all unprocessed transcripts using an available LLM CLI").action(async () => {
|
|
49
|
-
const { runCompileAll } = await import("./compile-all-
|
|
49
|
+
const { runCompileAll } = await import("./compile-all-XQBGUI3F.js");
|
|
50
50
|
await runCompileAll();
|
|
51
51
|
});
|
|
52
52
|
program.command("status").description("Show AgentCache knowledge stats").action(async () => {
|
|
53
|
-
const { getDbPath, isInitialized, findProjectRoot, getProjectId, getProjectDisplayName } = await import("./paths-
|
|
53
|
+
const { getDbPath, isInitialized, findProjectRoot, getProjectId, getProjectDisplayName } = await import("./paths-ULP2T4HZ.js");
|
|
54
54
|
if (!isInitialized()) {
|
|
55
55
|
console.log("AgentCache not initialized. Run: agentcache setup");
|
|
56
56
|
return;
|
|
57
57
|
}
|
|
58
|
-
const { SqliteKnowledgeRepository } = await import("./sqlite-
|
|
58
|
+
const { SqliteKnowledgeRepository } = await import("./sqlite-MP6SRBBQ.js");
|
|
59
59
|
const repo = new SqliteKnowledgeRepository(getDbPath());
|
|
60
60
|
const projectRoot = findProjectRoot();
|
|
61
61
|
const project = getProjectId(projectRoot);
|
|
@@ -2,11 +2,11 @@ import {
|
|
|
2
2
|
processClustering,
|
|
3
3
|
processExtraction,
|
|
4
4
|
startCompile
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-OXHITHDC.js";
|
|
6
6
|
import {
|
|
7
7
|
acquireLock,
|
|
8
8
|
releaseLock
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-VFE4SDMO.js";
|
|
10
10
|
import {
|
|
11
11
|
findAllClaudeTranscripts,
|
|
12
12
|
findAllCodexTranscripts,
|
|
@@ -14,15 +14,15 @@ import {
|
|
|
14
14
|
findAllRooCodeTranscripts,
|
|
15
15
|
getGooseDbPath,
|
|
16
16
|
parseTranscript
|
|
17
|
-
} from "./chunk-
|
|
17
|
+
} from "./chunk-QVQJPJGX.js";
|
|
18
18
|
import {
|
|
19
19
|
getDbPath,
|
|
20
20
|
getProjectId,
|
|
21
21
|
isInitialized
|
|
22
|
-
} from "./chunk-
|
|
22
|
+
} from "./chunk-S4GSIEKL.js";
|
|
23
23
|
import {
|
|
24
24
|
SqliteKnowledgeRepository
|
|
25
|
-
} from "./chunk-
|
|
25
|
+
} from "./chunk-ZVDODLZ7.js";
|
|
26
26
|
import {
|
|
27
27
|
__esm,
|
|
28
28
|
__export,
|
|
@@ -317,16 +317,18 @@ function processOneTranscript(repo, path, project, projectRoot, backend) {
|
|
|
317
317
|
const events = parseTranscript(path);
|
|
318
318
|
if (events.length < 3) return { created: 0, reinforced: 0, skipped: true };
|
|
319
319
|
const sessionId = `sess_${randomUUID().slice(0, 8)}`;
|
|
320
|
-
const state = startCompile(events, sessionId, project, projectRoot, repo
|
|
320
|
+
const state = startCompile(events, sessionId, project, projectRoot, repo);
|
|
321
321
|
const extractionResponse = backend.invoke(state.prompt);
|
|
322
322
|
if (!extractionResponse) return { created: 0, reinforced: 0, skipped: true };
|
|
323
323
|
const extractResult = processExtraction(repo, extractionResponse, sessionId, project, projectRoot);
|
|
324
324
|
if (extractResult.status === "complete") {
|
|
325
|
+
repo.updateSessionTranscriptPath(sessionId, path);
|
|
325
326
|
return { created: 0, reinforced: 0, skipped: false };
|
|
326
327
|
}
|
|
327
328
|
const clusterResponse = backend.invoke(extractResult.clusteringPrompt);
|
|
328
329
|
if (!clusterResponse) return { created: 0, reinforced: 0, skipped: true };
|
|
329
330
|
const clusterResult = processClustering(repo, clusterResponse, sessionId, project, projectRoot);
|
|
331
|
+
repo.updateSessionTranscriptPath(sessionId, path);
|
|
330
332
|
const diag = clusterResult.diagnostics;
|
|
331
333
|
const createdMatch = diag.match(/(\d+) new knowledge/);
|
|
332
334
|
const reinforcedMatch = diag.match(/(\d+) reinforced/);
|
package/dist/mcp.js
CHANGED
|
@@ -6,22 +6,22 @@ import {
|
|
|
6
6
|
processClustering,
|
|
7
7
|
processExtraction,
|
|
8
8
|
startCompile
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-OXHITHDC.js";
|
|
10
10
|
import {
|
|
11
11
|
spawnCompileAll
|
|
12
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-VFE4SDMO.js";
|
|
13
13
|
import {
|
|
14
14
|
parseTranscript
|
|
15
|
-
} from "./chunk-
|
|
15
|
+
} from "./chunk-QVQJPJGX.js";
|
|
16
16
|
import {
|
|
17
17
|
findProjectRoot,
|
|
18
18
|
getDbPath,
|
|
19
19
|
getProjectId,
|
|
20
20
|
isInitialized
|
|
21
|
-
} from "./chunk-
|
|
21
|
+
} from "./chunk-S4GSIEKL.js";
|
|
22
22
|
import {
|
|
23
23
|
SqliteKnowledgeRepository
|
|
24
|
-
} from "./chunk-
|
|
24
|
+
} from "./chunk-ZVDODLZ7.js";
|
|
25
25
|
import "./chunk-KFQGP6VL.js";
|
|
26
26
|
|
|
27
27
|
// src/mcp.ts
|
package/dist/postinstall.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
spawnCompileAll
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-VFE4SDMO.js";
|
|
4
4
|
import {
|
|
5
5
|
detectInstalledIdes,
|
|
6
6
|
registerClaudeHooks,
|
|
@@ -10,10 +10,10 @@ import {
|
|
|
10
10
|
getDataDir,
|
|
11
11
|
getDbPath,
|
|
12
12
|
migrateFromLegacy
|
|
13
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-S4GSIEKL.js";
|
|
14
14
|
import {
|
|
15
15
|
SqliteKnowledgeRepository
|
|
16
|
-
} from "./chunk-
|
|
16
|
+
} from "./chunk-ZVDODLZ7.js";
|
|
17
17
|
import "./chunk-KFQGP6VL.js";
|
|
18
18
|
|
|
19
19
|
// src/postinstall.ts
|
|
@@ -6,10 +6,10 @@ import {
|
|
|
6
6
|
getDbPath,
|
|
7
7
|
getProjectId,
|
|
8
8
|
isInitialized
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-S4GSIEKL.js";
|
|
10
10
|
import {
|
|
11
11
|
SqliteKnowledgeRepository
|
|
12
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-ZVDODLZ7.js";
|
|
13
13
|
import "./chunk-KFQGP6VL.js";
|
|
14
14
|
|
|
15
15
|
// src/hooks/pre-tool-use.ts
|
|
@@ -3,15 +3,15 @@ import {
|
|
|
3
3
|
findAllCodexTranscripts,
|
|
4
4
|
findAllContinueTranscripts,
|
|
5
5
|
findAllRooCodeTranscripts
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-QVQJPJGX.js";
|
|
7
7
|
import {
|
|
8
8
|
getDbPath,
|
|
9
9
|
getProjectId,
|
|
10
10
|
isInitialized
|
|
11
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-S4GSIEKL.js";
|
|
12
12
|
import {
|
|
13
13
|
SqliteKnowledgeRepository
|
|
14
|
-
} from "./chunk-
|
|
14
|
+
} from "./chunk-ZVDODLZ7.js";
|
|
15
15
|
import "./chunk-KFQGP6VL.js";
|
|
16
16
|
|
|
17
17
|
// src/hooks/session-start.ts
|
|
@@ -7,10 +7,10 @@ import {
|
|
|
7
7
|
getDataDir,
|
|
8
8
|
getDbPath,
|
|
9
9
|
migrateFromLegacy
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-S4GSIEKL.js";
|
|
11
11
|
import {
|
|
12
12
|
SqliteKnowledgeRepository
|
|
13
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-ZVDODLZ7.js";
|
|
14
14
|
import "./chunk-KFQGP6VL.js";
|
|
15
15
|
|
|
16
16
|
// src/setup.ts
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import {
|
|
2
2
|
findLatestTranscript
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-QVQJPJGX.js";
|
|
4
4
|
import {
|
|
5
5
|
findProjectRoot,
|
|
6
6
|
getDbPath,
|
|
7
7
|
getProjectId,
|
|
8
8
|
isInitialized
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-S4GSIEKL.js";
|
|
10
10
|
import {
|
|
11
11
|
SqliteKnowledgeRepository
|
|
12
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-ZVDODLZ7.js";
|
|
13
13
|
import "./chunk-KFQGP6VL.js";
|
|
14
14
|
|
|
15
15
|
// src/hooks/stop.ts
|