agentcache 0.4.2 → 0.5.0-beta.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.
Files changed (38) hide show
  1. package/README.md +282 -151
  2. package/dist/{chunk-T4COG3XD.js → chunk-R5I6WWSD.js} +31 -14
  3. package/dist/chunk-RXGW4Q3G.js +109 -0
  4. package/dist/chunk-XRJ6QW6N.js +92 -0
  5. package/dist/chunk-YKG6CDGT.js +1818 -0
  6. package/dist/chunk-YY7QXBG5.js +6610 -0
  7. package/dist/cli.js +2535 -292
  8. package/dist/device-id-RV7RO5RB.js +7 -0
  9. package/dist/ide-detector-ETGAVVXO.js +8 -0
  10. package/dist/mcp.d.ts +734 -2
  11. package/dist/mcp.js +1126 -446
  12. package/dist/{paths-5LZRKNYY.js → paths-NTZ2357O.js} +3 -2
  13. package/dist/postinstall.js +1 -65
  14. package/dist/setup-7JJPW3VG.js +48 -0
  15. package/docs/compatibility.md +152 -0
  16. package/docs/demo-script.md +121 -0
  17. package/docs/launch-copy.md +125 -0
  18. package/docs/privacy.md +173 -0
  19. package/docs/troubleshooting.md +209 -0
  20. package/package.json +32 -14
  21. package/dist/3-canonicalizer-HIN2F7SZ.js +0 -11
  22. package/dist/chunk-5UO7NJPQ.js +0 -71
  23. package/dist/chunk-CUBZRYS5.js +0 -580
  24. package/dist/chunk-GGAATZKM.js +0 -120
  25. package/dist/chunk-JUDLOBOC.js +0 -77
  26. package/dist/chunk-KFQGP6VL.js +0 -33
  27. package/dist/chunk-PSASDZQE.js +0 -490
  28. package/dist/chunk-SLRKWMSE.js +0 -202
  29. package/dist/chunk-T7BJPANN.js +0 -45
  30. package/dist/chunk-WTXSZBQE.js +0 -388
  31. package/dist/compile-all-PTWTZVP5.js +0 -495
  32. package/dist/ide-detector-5TRCR4F5.js +0 -7
  33. package/dist/pre-tool-use-A4AJHZOJ.js +0 -30
  34. package/dist/session-start-DGMGEAJU.js +0 -78
  35. package/dist/setup-CVG35TUZ.js +0 -51
  36. package/dist/sqlite-NM2BVHUY.js +0 -7
  37. package/dist/stop-WGGRX6TQ.js +0 -38
  38. package/dist/transcript-JWSGSDSF.js +0 -24
package/README.md CHANGED
@@ -1,172 +1,303 @@
1
1
  # AgentCache
2
2
 
3
- **Your codebase learns.** AgentCache compiles what your AI agents discover into a `SKILL.md` that every future session in any IDE, with any LLM — reads automatically.
3
+ > **Pick a coding session and continue it in another agent.**
4
+
5
+ **AgentCache 0.5.0-beta.2 is a same-machine public beta.** It keeps a local,
6
+ portable timeline for an explicitly selected coding session, then hands a
7
+ bounded checkpoint to another registered agent through MCP. There is no
8
+ Markdown handoff file to maintain and no silent choice of “latest” session.
9
+
10
+ The destination agent provider may receive the resume capsule when its agent
11
+ consumes a handoff. In the prescribed prompt-based flow, the handoff ID and
12
+ one-use token may also be sent to the destination provider. Treat the token as
13
+ a temporary bearer secret. “Local-first” describes AgentCache storage and
14
+ coordination; it does not change the network or retention behavior of Claude
15
+ Code, Codex, Cursor, or another hosted agent.
16
+
17
+ ## What it carries
18
+
19
+ AgentCache carries the useful state around a coding conversation: the goal,
20
+ explicit constraints, completed work, open work, blockers, decisions, rejected
21
+ approaches, next step, portable Git metadata, and a bounded slice of recent
22
+ events. It can keep multiple client legs in one timeline or create an explicit
23
+ fork with an independent child timeline.
24
+
25
+ It does not transplant a vendor's private conversation object, hidden
26
+ reasoning, system prompt, approval state, or complete tool output. It does not
27
+ intentionally carry credentials: known credential patterns and absolute local
28
+ paths are redacted, but arbitrary secrets may still appear. It does not replace
29
+ a client's own `/resume` command. Native transcript stores are treated as
30
+ read-only sources.
31
+
32
+ ## Five-minute quickstart
33
+
34
+ Prerequisites: Node.js 22 or newer, two supported clients installed on the same
35
+ machine, and the same canonical repository root open in both clients. Separate
36
+ clones and Git worktrees are isolated in this beta, even when their remotes
37
+ match.
38
+
39
+ 1. Install the pinned beta and run the explicit setup step.
40
+
41
+ ```bash
42
+ npm install -g agentcache@0.5.0-beta.2
43
+ agentcache setup
44
+ ```
45
+
46
+ Installation has no postinstall configuration hook. Setup is explicit:
47
+ `agentcache setup` detects installed clients and adds a client-bound MCP
48
+ entry using the exact active Node executable and installed AgentCache CLI.
49
+ This prevents an IDE's bundled Node from loading a native dependency built
50
+ for another Node version. Rerun setup after changing Node versions, global
51
+ npm prefixes, or AgentCache installations, then restart or reload clients.
52
+
53
+ 2. Check what AgentCache actually detected and what each adapter can do.
54
+
55
+ ```bash
56
+ agentcache doctor
57
+ agentcache adapter list --json
58
+ agentcache adapter doctor claude-code
59
+ agentcache adapter doctor codex
60
+ ```
61
+
62
+ The global `agentcache doctor` checks exact adapter-bound MCP registrations
63
+ and, after initialization, the v2 store. On a fresh setup before the first
64
+ session operation, an absent v2 store is normal: doctor reports the
65
+ informational message `will initialize on first session operation`. That is
66
+ not a failure. `adapter doctor` reports the capability evidence for one
67
+ client.
68
+
69
+ 3. In the source client, ask its AgentCache MCP server to open a portable
70
+ session for the current workspace, record the goal and relevant progress,
71
+ and create a checkpoint before you switch. Then, from that repository, list
72
+ the portable sessions.
73
+
74
+ ```bash
75
+ agentcache session list
76
+ ```
77
+
78
+ Listing also attempts bounded, read-only discovery for adapters whose native
79
+ history can prove the current workspace. A conversation opened through the
80
+ AgentCache MCP tools already appears as a portable session.
81
+
82
+ 4. Prepare a handoff with the interactive picker. The destination is always
83
+ explicit.
84
+
85
+ ```bash
86
+ agentcache session resume --to codex
87
+ ```
88
+
89
+ Search, select a numbered session, inspect it, then choose `continue` or
90
+ `fork`. Known branches appear in the list. The inspection view shows the
91
+ exact local workspace path, recovered objective, checkpoint Git state,
92
+ event count, and an approximate checkpoint-state JSON baseline. The final
93
+ resume capsule is larger because bounded recent events and its envelope are
94
+ added later. AgentCache then shows the exact public capsule that the
95
+ destination will receive. Choose `exclude` to remove numbered events from
96
+ this handoff's initial capsule and re-preview it, `confirm` to finish, or
97
+ `cancel` to delete the unconsumed handoff. Nothing is preselected and the
98
+ picker has no timeout. The one-time token is printed only after confirmation
99
+ and expires after ten minutes. These local inspection details are not added
100
+ to the JSON listing contract.
101
+
102
+ 5. Open the same repository in Codex and ask it to call AgentCache's
103
+ `session_resume` tool with that handoff ID and token. Ask it to restate the
104
+ goal and next step before continuing. The handoff is accepted only by the
105
+ chosen adapter in the chosen workspace.
106
+
107
+ For scripts, specify the session ID and request structured output:
4
108
 
5
109
  ```bash
6
- npm install -g agentcache
110
+ agentcache session resume ses_... --to codex --json
7
111
  ```
8
112
 
9
- That's it. No config. No accounts. No sync server.
10
-
11
- ---
12
-
13
- ## The Problem
14
-
15
- You tell Claude "don't mock the database in integration tests." It forgets. You tell Cursor the same thing. You tell Codex. You repeat yourself across every IDE, every session, every project.
16
-
17
- Your agents are amnesiac. Your knowledge evaporates.
18
-
19
- ## What AgentCache Does
20
-
21
- After a few sessions, AgentCache produces a `SKILL.md` in your repo:
22
-
23
- ```markdown
24
- # Project Knowledge
25
-
26
- ## Rules
27
- - Never mock the database in integration tests we got burned when mocks passed but prod migration failed
28
- - Always use snake_case for database columns
29
- - Run type-check before committing
30
-
31
- ## Decisions
32
- - Using Drizzle ORM over Prisma for raw SQL escape hatches
33
- - PostgreSQL for all persistent state, Redis for ephemeral cache only
34
-
35
- ## Context
36
- - Migrating from REST to GraphQL, both coexist until Q3
37
- - Auth service rewrite driven by compliance (not tech debt)
38
- ```
39
-
40
- This file lives at `<repo>/.agentcache/skills/project-knowledge/SKILL.md`. It's auto-discovered by **38+ tools** that support the Agent Skills spec — no MCP connection required. Commit it. Every teammate gets your team's accumulated knowledge on clone.
41
-
42
- **The database is local. The output is git.**
43
-
44
- ## How It Works
45
-
46
- ```
47
- Session 1 (Claude Code) Session 2 (Cursor) Session 3 (Codex)
48
- │ │ │
49
- └───────────────────────────┴───────────────────────┘
50
-
51
- AgentCache (MCP Server)
52
-
53
- ┌───────────────┴───────────────┐
54
- │ │
55
- ~/.agentcache/ <repo>/.agentcache/
56
- agentcache.db skills/.../SKILL.md
57
- (local SQLite) (committed to git)
58
- ```
59
-
60
- 1. **Session starts** → agent calls `inject_context` → gets compiled rules, lessons, decisions
61
- 2. **During session** agent calls `compile_submit` as it learns things
62
- 3. **Session ends** knowledge compiles into the database
63
- 4. **Periodically** → database projects into `SKILL.md` for git distribution
64
-
65
- Knowledge compounds. One lesson stated once propagates to every future session across every IDE.
66
-
67
- ## Install
68
-
69
- ```bash
70
- npm install -g agentcache
71
- ```
72
-
73
- The install automatically:
74
- 1. Creates `~/.agentcache/agentcache.db`
75
- 2. Detects your IDEs (Claude Code, Cursor, Roo Code, Windsurf, Continue, Codex)
76
- 3. Registers as an MCP server in each — with auto-approve
77
- 4. Sets up Claude Code hooks for transcript recovery
78
- 5. Compiles your existing transcript history in the background
79
-
80
- **Zero config. Zero setup. Start a session and it's working.**
81
-
82
- ## Supported IDEs
83
-
84
- | IDE | MCP | Auto-Approve | Transcript Recovery |
85
- |-----|-----|-------------|-------------------|
86
- | Claude Code | ✓ | ✓ | Full (hooks + JSONL) |
87
- | Cursor | ✓ | ✓ | Full (agent transcripts) |
88
- | Roo Code (VS Code) | ✓ | ✓ | Full (task history) |
89
- | Codex | ✓ | ✓ | Full (session JSONL) |
90
- | Continue | ✓ | ✓ | Full (session JSON) |
91
- | Windsurf | ✓ | ✓ | Incremental only |
92
- | Goose | — | — | Full (SQLite) |
93
-
94
- All IDEs share the same knowledge database. A rule learned in Claude Code is injected in Cursor the next time you open it.
95
-
96
- ## Security Model
97
-
98
- AgentCache creates a feedback loop: agents write observations → observations compile → knowledge injects into future sessions. This is the product's value **and** its attack surface.
99
-
100
- **Quarantine gate**: Agent-submitted observations require confirmation across 2+ independent sessions before injection. A single prompt-injected `compile_submit` cannot poison your knowledge.
101
-
102
- **Human-only enforcement**: Policy rules (that block tool calls) can only be created via CLI. No MCP tool can create policy.
103
-
104
- **Scope gate**: Agent-submitted observations are always project-scoped. Global requires explicit human action.
105
-
106
- ### Security Modes
107
-
108
- ```json
109
- { "security": "auto" }
110
- ```
111
-
112
- | Mode | Behavior |
113
- |------|----------|
114
- | `auto` | Quarantine — new items inject after 2+ session confirmations |
115
- | `review` | Nothing injects until `agentcache review` approves it |
116
- | `locked` | `compile_submit` disabled. Human-triggered batch only |
117
-
118
- ## CLI
113
+ Non-interactive and JSON runs never open the picker; they fail if the session
114
+ ID is absent. They return the same bounded public capsule as `session_resume`;
115
+ pass one or more IDs to `--exclude-event <event-id...>` to omit known capsule
116
+ events. Exclusion is
117
+ not deletion or access control: it affects only this initial capsule, and a
118
+ same-workspace destination can still request those events with
119
+ `session_history`. See [the demo script](docs/demo-script.md) for a complete
120
+ Claude Code → Codex → Cursor fork walkthrough.
121
+
122
+ ## Resume and fork semantics
123
+
124
+ - `continue` adds a new client leg to the same portable session.
125
+ - `fork` creates a child session anchored to an immutable parent checkpoint;
126
+ later parent and child events remain independent.
127
+ - An active source writer blocks continuation unless the human explicitly
128
+ confirms takeover with `--confirm-active-source`; for parallel work, fork.
129
+ - A handoff is single-use, expires after ten minutes, and is bound to one
130
+ destination adapter, workspace, and exact prepared capsule.
131
+ - Interactive cancellation and prompt failures delete the unconsumed draft;
132
+ superseded drafts are deleted before an exclusion-adjusted capsule is made.
133
+ - A changed session head, wrong destination, wrong workspace, expired token, or
134
+ reused token is rejected rather than guessed around.
135
+ - Long history is marked partial and can be fetched in bounded pages with
136
+ `session history` or the MCP `session_history` tool.
137
+
138
+ ## Compatibility
139
+
140
+ The table below is generated as a documentation contract against the runtime
141
+ adapter registry. `experimental` means the parser or registration is covered by
142
+ fixtures but does not yet have dated live-client evidence. `unsupported` means
143
+ AgentCache will report the limitation instead of pretending the operation
144
+ works. Modes describe how the adapter capability is implemented.
145
+
146
+ <!-- runtime-capability-matrix:start -->
147
+ | Client | Adapter ID | Registration | History | Native resume | Append | Checkpoint | Fork | Launch |
148
+ |---|---|---|---|---|---|---|---|---|
149
+ | Claude Code | claude-code | experimental / mcp-cooperative | experimental / local-snapshot | unsupported / none | unsupported / none | unsupported / none | unsupported / none | unsupported / none |
150
+ | Cursor | cursor | experimental / mcp-cooperative | experimental / local-snapshot | unsupported / none | unsupported / none | unsupported / none | unsupported / none | unsupported / none |
151
+ | Roo Code | roo-code | experimental / mcp-cooperative | experimental / local-snapshot | unsupported / none | unsupported / none | unsupported / none | unsupported / none | unsupported / none |
152
+ | Windsurf | windsurf | experimental / mcp-cooperative | unsupported / none | unsupported / none | unsupported / none | unsupported / none | unsupported / none | unsupported / none |
153
+ | Continue | continue | experimental / mcp-cooperative | experimental / local-snapshot | unsupported / none | unsupported / none | unsupported / none | unsupported / none | unsupported / none |
154
+ | Codex | codex | experimental / mcp-cooperative | experimental / local-snapshot | unsupported / none | unsupported / none | unsupported / none | unsupported / none | unsupported / none |
155
+ | Goose | goose | experimental / mcp-cooperative | unsupported / none | unsupported / none | unsupported / none | unsupported / none | unsupported / none | unsupported / none |
156
+ <!-- runtime-capability-matrix:end -->
157
+
158
+ The `native resume`, `append`, `checkpoint`, `fork`, and `launch` columns are
159
+ client-native adapter capabilities. The beta's portable append, checkpoint,
160
+ resume, and fork operations are provided through AgentCache's shared MCP/CLI
161
+ session layer; they do not write those operations into vendor-owned histories.
162
+ Windsurf and Goose historical recovery are unsupported. Goose MCP registration
163
+ uses its documented 1.39 YAML schema but remains experimental.
164
+
165
+ For evidence, limitations, source formats, and how to read the matrix, see
166
+ [Compatibility](docs/compatibility.md). The live source of truth is:
119
167
 
120
168
  ```bash
121
- agentcache doctor # Diagnose installation
122
- agentcache status # Knowledge stats
123
- agentcache review # Approve/reject quarantined items
124
- agentcache promote <id> # Approve a single item
125
- agentcache add-rule "never force push" --enforce # Create policy (human-only)
126
- agentcache compile-all # Batch-compile all transcripts
127
- agentcache setup # Re-register with IDEs
128
- ```
129
-
130
- ## compile-all
131
-
132
- Processes all uncompiled transcripts from all IDEs using the first available LLM backend:
133
-
134
- 1. CLI tools: `claude`, `codex`, `gemini`, `copilot`, `aider`, `goose`
135
- 2. Ollama at `localhost:11434`
136
- 3. `ANTHROPIC_API_KEY` or `OPENAI_API_KEY`
137
-
138
- Runs automatically on install and when pending transcripts exceed 20.
139
-
140
- ## Data
141
-
169
+ agentcache adapter list --json
170
+ agentcache adapter doctor <adapter-id> --json
142
171
  ```
143
- ~/.agentcache/
144
- ├── agentcache.db # Knowledge database (SQLite + WAL)
145
- ├── config.json # Security mode
146
- └── compile-all.lock # Prevents concurrent compilation
147
172
 
148
- <repo>/.agentcache/
149
- └── skills/project-knowledge/SKILL.md # Git-committed team knowledge
173
+ ## Command reference
174
+
175
+ These are the public beta session-continuity commands. Options are abbreviated
176
+ here; use `agentcache <group> <command> --help` for the complete syntax.
177
+
178
+ <!-- beta-command-matrix:start -->
179
+ | Command | Purpose |
180
+ |---|---|
181
+ | `session list` | Discover and list sessions for the current workspace. |
182
+ | `session inspect` | Inspect one portable session. |
183
+ | `session resume` | Prepare an explicit one-use destination handoff. |
184
+ | `session append` | Append one human-authorized portable event. |
185
+ | `session checkpoint` | Create one human-authorized checkpoint. |
186
+ | `session fork` | Prepare an explicit fork from a checkpoint. |
187
+ | `session history` | Read a bounded page of portable history. |
188
+ | `handoff list` | List pending handoffs for the current workspace. |
189
+ | `handoff cancel` | Cancel one pending handoff. |
190
+ | `adapter list` | List supported runtime adapter definitions. |
191
+ | `adapter doctor` | Probe one adapter and show capability evidence. |
192
+ | `adapter register` | Register AgentCache with one detected client. |
193
+ | `adapter unregister` | Remove AgentCache-owned registration for one client. |
194
+ <!-- beta-command-matrix:end -->
195
+
196
+ The exact argument and option contract is checked against the real Commander
197
+ command objects. “Required options” must be present for Commander to invoke the
198
+ handler; angle brackets on an optional option mean that the option takes a
199
+ value, not that the option itself is mandatory.
200
+
201
+ <!-- cli-help-contract:start -->
202
+ | Command | Arguments | Required options | Optional options |
203
+ |---|---|---|---|
204
+ | `session list` | — | — | `--adapter <id>; --status <status>; --json` |
205
+ | `session inspect` | `<session-id>` | — | `--json` |
206
+ | `session resume` | `[session-id]` | `--to <adapter>` | `--checkpoint <id>; --fork; --confirm-active-source; --exclude-event <event-id...>; --json` |
207
+ | `session append` | `<session-id>` | `--kind <kind>` | `--text <text>; --stdin; --json` |
208
+ | `session checkpoint` | `<session-id>` | — | `--summary <text>; --summary-file <path>; --state-file <path>; --json` |
209
+ | `session fork` | `<session-id>` | `--from <checkpoint-id&#124;latest>; --to <adapter>` | `--title <title>; --exclude-event <event-id...>; --json` |
210
+ | `session history` | `<session-id>` | — | `--before <cursor>; --limit <number>; --json` |
211
+ | `handoff list` | — | — | `--json` |
212
+ | `handoff cancel` | `<handoff-id>` | — | `--json` |
213
+ | `adapter list` | — | — | `--json` |
214
+ | `adapter doctor` | `<adapter-id>` | — | `--json` |
215
+ | `adapter register` | `<adapter-id>` | — | — |
216
+ | `adapter unregister` | `<adapter-id>` | — | — |
217
+ <!-- cli-help-contract:end -->
218
+
219
+ `session append` requires exactly one of `--text` or `--stdin`. `session
220
+ checkpoint` accepts at most one of `--summary`, `--summary-file`, or
221
+ `--state-file`. A non-interactive or `--json` resume requires an explicit
222
+ session ID.
223
+
224
+ ## Data flow and safety boundary
225
+
226
+ ```text
227
+ read-only native history (when verified)
228
+ │ bounded read + normalization + redaction
229
+
230
+ ~/.agentcache/agentcache-v2.db
231
+ │ explicit checkpoint + one-use handoff
232
+
233
+ destination MCP session
234
+ │ hosted-client provider boundary
235
+
236
+ destination model
150
237
  ```
151
238
 
152
- No network calls. No telemetry. No accounts. Everything stays on your machine (except what you choose to commit).
153
-
154
- ## Principles
155
-
156
- - **Zero config** `npm install -g` is the only step
157
- - **Universal** MCP protocol, any IDE, any LLM
158
- - **Git-native output** SKILL.md is the distribution mechanism
159
- - **Secure by default** — quarantine gate, scope restrictions, human-only policy
160
- - **Anti-bloat** 30-day decay, budget caps, confidence promotion
161
-
162
- ## Contributing
239
+ AgentCache stores v2 session data locally with user-only filesystem
240
+ permissions. It rejects symbolic, special, or multiply linked database and
241
+ SQLite sidecar paths, uses bounded transcript reads, rejects transcript
242
+ symlinks, redacts known credential shapes and absolute local paths from
243
+ portable text, and labels resume data `untrusted_prior_session_context`.
244
+ Redaction is defense in depth, not a proof that arbitrary secrets cannot
245
+ appear; inspect sensitive sessions before handing them to another provider.
246
+
247
+ Setup does not add blanket AgentCache tool approvals. Registration updates are
248
+ atomic, back up an existing configuration before a material change, and leave
249
+ malformed or ambiguous configurations untouched. AgentCache does not mutate Git
250
+ or write generated context into a repository in the default beta path.
251
+
252
+ Read the complete [privacy and trust boundary](docs/privacy.md) before using the
253
+ beta with sensitive repositories.
254
+
255
+ ## Beta limits
256
+
257
+ - Same machine only. Cloud sync, accounts, teams, and cross-device continuation
258
+ are deferred.
259
+ - There is no native picker UI; the terminal picker is the control plane.
260
+ - Native client history formats can change. All current adapters are marked
261
+ experimental or unsupported until dated live-client verification exists.
262
+ - Windsurf and Goose can participate prospectively through MCP registration,
263
+ but their historical recovery is unsupported.
264
+ - AgentCache cannot carry hidden reasoning, private provider state, or tool
265
+ approvals between clients.
266
+ - A Markdown fallback is intentionally not generated when a destination is
267
+ unavailable; the pending handoff remains until it is consumed, cancelled, or
268
+ expires.
269
+
270
+ ## Legacy 0.4 data
271
+
272
+ Version 0.5 creates `~/.agentcache/agentcache-v2.db` beside the legacy
273
+ `~/.agentcache/agentcache.db`; it does not translate or mutate compiled v1
274
+ knowledge. Legacy v1 CLI commands are not registered in the beta: `compile-session`,
275
+ `discover`, `enforce`, `review`, `promote`, `add-rule`, `compile-all`, and
276
+ `status` are unavailable. Setup, installation, startup, session discovery, and
277
+ idle operation cannot invoke legacy compilation. Automatic `SKILL.md`
278
+ generation is not part of the beta path.
279
+
280
+ This preserves the original “your codebase learns” experiment without making
281
+ its legacy compiler the trust boundary for cross-agent continuation.
282
+
283
+ ## Operations and feedback
284
+
285
+ - [Troubleshooting, uninstall, and rollback](docs/troubleshooting.md)
286
+ - [Privacy and data flow](docs/privacy.md)
287
+ - [Compatibility details](docs/compatibility.md)
288
+ - [60–90 second demo](docs/demo-script.md)
289
+ - [Launch copy](docs/launch-copy.md)
290
+ - [Open a structured beta-feedback issue](https://github.com/raghav-a21ai/agentcache/issues/new?template=beta-feedback.yml)
291
+
292
+ ## Development
163
293
 
164
294
  ```bash
165
295
  git clone https://github.com/raghav-a21ai/agentcache
166
296
  cd agentcache
167
297
  npm install
298
+ npm run typecheck
168
299
  npm run build
169
- npm test # 205 tests
300
+ npm test
170
301
  ```
171
302
 
172
303
  ## License
@@ -5,27 +5,39 @@ import { homedir } from "os";
5
5
  import { createHash } from "crypto";
6
6
 
7
7
  // src/utils/git.ts
8
- import { execSync } from "child_process";
9
- function run(cmd, cwd) {
8
+ import { execFileSync } from "child_process";
9
+ import { realpathSync } from "fs";
10
+ import { isAbsolute, resolve } from "path";
11
+ function run(args, cwd) {
10
12
  try {
11
- return execSync(cmd, { cwd, encoding: "utf-8", timeout: 5e3, stdio: ["pipe", "pipe", "pipe"] }).trim();
13
+ return execFileSync("git", args, {
14
+ cwd,
15
+ encoding: "utf-8",
16
+ timeout: 5e3,
17
+ stdio: ["ignore", "pipe", "pipe"]
18
+ }).trim();
12
19
  } catch {
13
20
  return "";
14
21
  }
15
22
  }
16
- function getGitContext(projectRoot) {
17
- const empty = { branch: "", commit: "", recentCommits: [], modifiedFiles: [] };
18
- if (!run("git rev-parse --git-dir", projectRoot)) return empty;
19
- const branch = run("git rev-parse --abbrev-ref HEAD", projectRoot);
20
- const commit = run("git rev-parse --short HEAD", projectRoot);
21
- const recentCommits = run("git log --oneline -10", projectRoot).split("\n").filter(Boolean);
22
- const modifiedFiles = run("git diff --name-only HEAD~5 HEAD", projectRoot).split("\n").filter(Boolean);
23
- return { branch, commit, recentCommits, modifiedFiles };
24
- }
25
23
  function getGitRoot(cwd) {
26
- const root = run("git rev-parse --show-toplevel", cwd);
24
+ const root = run(["rev-parse", "--show-toplevel"], cwd);
27
25
  return root || null;
28
26
  }
27
+ function getGitRemote(cwd) {
28
+ const remote = run(["config", "--get", "remote.origin.url"], cwd);
29
+ return remote || null;
30
+ }
31
+ function getGitCommonDir(cwd) {
32
+ const commonDir = run(["rev-parse", "--git-common-dir"], cwd);
33
+ if (!commonDir) return null;
34
+ const absolute = isAbsolute(commonDir) ? commonDir : resolve(cwd, commonDir);
35
+ try {
36
+ return realpathSync.native(absolute);
37
+ } catch {
38
+ return null;
39
+ }
40
+ }
29
41
 
30
42
  // src/utils/paths.ts
31
43
  function getDataDir() {
@@ -34,6 +46,9 @@ function getDataDir() {
34
46
  function getDbPath() {
35
47
  return join(getDataDir(), "agentcache.db");
36
48
  }
49
+ function getSessionDbPath() {
50
+ return join(getDataDir(), "agentcache-v2.db");
51
+ }
37
52
  function isInitialized() {
38
53
  return existsSync(getDbPath());
39
54
  }
@@ -66,10 +81,12 @@ function getContinueSessionsDir() {
66
81
  }
67
82
 
68
83
  export {
69
- getGitContext,
70
84
  getGitRoot,
85
+ getGitRemote,
86
+ getGitCommonDir,
71
87
  getDataDir,
72
88
  getDbPath,
89
+ getSessionDbPath,
73
90
  isInitialized,
74
91
  migrateFromLegacy,
75
92
  findProjectRoot,
@@ -0,0 +1,109 @@
1
+ // src/utils/ide-detector.ts
2
+ import { existsSync } from "fs";
3
+ import { dirname, join, posix, win32 } from "path";
4
+ import { homedir } from "os";
5
+ function getRooConfigPath(home = homedir()) {
6
+ if (process.platform === "darwin") {
7
+ return join(home, "Library/Application Support/Code/User/globalStorage/rooveterinaryinc.roo-cline/settings/mcp_settings.json");
8
+ }
9
+ if (process.platform === "win32") {
10
+ return join(process.env.APPDATA || join(home, "AppData/Roaming"), "Code/User/globalStorage/rooveterinaryinc.roo-cline/settings/mcp_settings.json");
11
+ }
12
+ return join(home, ".config/Code/User/globalStorage/rooveterinaryinc.roo-cline/settings/mcp_settings.json");
13
+ }
14
+ function getWindsurfConfigPath(home = homedir()) {
15
+ return join(home, ".codeium", "windsurf", "mcp_config.json");
16
+ }
17
+ function getContinueConfigPath(home = homedir()) {
18
+ return join(home, ".continue", "mcpServers", "agentcache.json");
19
+ }
20
+ function getCodexConfigPath(home = homedir()) {
21
+ return join(home, ".codex", "config.toml");
22
+ }
23
+ function resolveGooseConfigPath(options = {}) {
24
+ const platform = options.platform ?? process.platform;
25
+ const env = options.env ?? process.env;
26
+ const home = options.home ?? homedir();
27
+ const path = platform === "win32" ? win32 : posix;
28
+ if (env.GOOSE_PATH_ROOT !== void 0) {
29
+ return path.join(env.GOOSE_PATH_ROOT, "config", "config.yaml");
30
+ }
31
+ if (platform !== "win32" && env.XDG_CONFIG_HOME && path.isAbsolute(env.XDG_CONFIG_HOME)) {
32
+ return path.join(env.XDG_CONFIG_HOME, "goose", "config.yaml");
33
+ }
34
+ if (platform === "win32") {
35
+ return path.join(
36
+ env.APPDATA || path.join(home, "AppData", "Roaming"),
37
+ "Block",
38
+ "goose",
39
+ "config",
40
+ "config.yaml"
41
+ );
42
+ }
43
+ return path.join(home, ".config", "goose", "config.yaml");
44
+ }
45
+ function detectInstalledIdes(homeDirectory = homedir()) {
46
+ const home = homeDirectory;
47
+ const legacyRooConfigPath = join(home, ".roo", "mcp.json");
48
+ const gooseConfigPath = resolveGooseConfigPath({ home });
49
+ return [
50
+ {
51
+ adapterId: "claude-code",
52
+ name: "Claude Code",
53
+ detected: existsSync(join(home, ".claude")),
54
+ mcpConfigPath: join(home, ".claude.json"),
55
+ mcpConfigFormat: "claude-settings"
56
+ },
57
+ {
58
+ adapterId: "cursor",
59
+ name: "Cursor",
60
+ detected: existsSync(join(home, ".cursor")),
61
+ mcpConfigPath: join(home, ".cursor", "mcp.json"),
62
+ mcpConfigFormat: "mcp-json"
63
+ },
64
+ {
65
+ adapterId: "roo-code",
66
+ name: "Roo Code",
67
+ detected: existsSync(getRooConfigPath(home)) || existsSync(legacyRooConfigPath),
68
+ mcpConfigPath: getRooConfigPath(home),
69
+ legacyMcpConfigPaths: [legacyRooConfigPath],
70
+ mcpConfigFormat: "mcp-json"
71
+ },
72
+ {
73
+ adapterId: "windsurf",
74
+ name: "Windsurf",
75
+ detected: existsSync(join(home, ".codeium", "windsurf")) || existsSync(join(home, ".windsurf")),
76
+ mcpConfigPath: getWindsurfConfigPath(home),
77
+ legacyMcpConfigPaths: [join(home, ".windsurf", "mcp.json")],
78
+ mcpConfigFormat: "mcp-json"
79
+ },
80
+ {
81
+ adapterId: "continue",
82
+ name: "Continue",
83
+ detected: existsSync(join(home, ".continue")),
84
+ mcpConfigPath: getContinueConfigPath(home),
85
+ legacyMcpConfigPaths: [join(home, ".continue", "mcp.json")],
86
+ mcpConfigFormat: "continue-dir"
87
+ },
88
+ {
89
+ adapterId: "codex",
90
+ name: "Codex",
91
+ detected: existsSync(join(home, ".codex")),
92
+ mcpConfigPath: getCodexConfigPath(home),
93
+ legacyMcpConfigPaths: [join(home, ".codex", "mcp.json")],
94
+ mcpConfigFormat: "codex-toml"
95
+ },
96
+ {
97
+ adapterId: "goose",
98
+ name: "Goose",
99
+ detected: existsSync(dirname(gooseConfigPath)),
100
+ mcpConfigPath: gooseConfigPath,
101
+ mcpConfigFormat: "goose-yaml"
102
+ }
103
+ ];
104
+ }
105
+
106
+ export {
107
+ resolveGooseConfigPath,
108
+ detectInstalledIdes
109
+ };