@iamem/amem 0.1.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.
Files changed (104) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +534 -0
  3. package/dist/activity.d.ts +27 -0
  4. package/dist/activity.js +202 -0
  5. package/dist/api/routes.d.ts +31 -0
  6. package/dist/api/routes.js +1345 -0
  7. package/dist/attest.d.ts +52 -0
  8. package/dist/attest.js +192 -0
  9. package/dist/backup-schedule.d.ts +25 -0
  10. package/dist/backup-schedule.js +216 -0
  11. package/dist/capture.d.ts +34 -0
  12. package/dist/capture.js +257 -0
  13. package/dist/cli.d.ts +2 -0
  14. package/dist/cli.js +1007 -0
  15. package/dist/context.d.ts +46 -0
  16. package/dist/context.js +334 -0
  17. package/dist/crypto.d.ts +39 -0
  18. package/dist/crypto.js +166 -0
  19. package/dist/db.d.ts +192 -0
  20. package/dist/db.js +666 -0
  21. package/dist/draft-quality.d.ts +19 -0
  22. package/dist/draft-quality.js +85 -0
  23. package/dist/embed.d.ts +76 -0
  24. package/dist/embed.js +331 -0
  25. package/dist/estimate.d.ts +32 -0
  26. package/dist/estimate.js +69 -0
  27. package/dist/freshness.d.ts +15 -0
  28. package/dist/freshness.js +93 -0
  29. package/dist/hook.d.ts +16 -0
  30. package/dist/hook.js +177 -0
  31. package/dist/hygiene-schedule.d.ts +28 -0
  32. package/dist/hygiene-schedule.js +221 -0
  33. package/dist/hygiene.d.ts +61 -0
  34. package/dist/hygiene.js +196 -0
  35. package/dist/install/claude.d.ts +6 -0
  36. package/dist/install/claude.js +69 -0
  37. package/dist/install/cursor.d.ts +7 -0
  38. package/dist/install/cursor.js +80 -0
  39. package/dist/install/hosts.d.ts +21 -0
  40. package/dist/install/hosts.js +186 -0
  41. package/dist/install/skills.d.ts +8 -0
  42. package/dist/install/skills.js +67 -0
  43. package/dist/it-pack.d.ts +20 -0
  44. package/dist/it-pack.js +84 -0
  45. package/dist/kinds.d.ts +18 -0
  46. package/dist/kinds.js +106 -0
  47. package/dist/license.d.ts +48 -0
  48. package/dist/license.js +172 -0
  49. package/dist/mcp.d.ts +40 -0
  50. package/dist/mcp.js +435 -0
  51. package/dist/paths.d.ts +11 -0
  52. package/dist/paths.js +55 -0
  53. package/dist/personal.d.ts +7 -0
  54. package/dist/personal.js +44 -0
  55. package/dist/platforms.d.ts +11 -0
  56. package/dist/platforms.js +32 -0
  57. package/dist/policy.d.ts +46 -0
  58. package/dist/policy.js +254 -0
  59. package/dist/prefs.d.ts +6 -0
  60. package/dist/prefs.js +11 -0
  61. package/dist/proposal.d.ts +90 -0
  62. package/dist/proposal.js +376 -0
  63. package/dist/publish.d.ts +28 -0
  64. package/dist/publish.js +57 -0
  65. package/dist/remember-contract.d.ts +23 -0
  66. package/dist/remember-contract.js +117 -0
  67. package/dist/repo-identity.d.ts +15 -0
  68. package/dist/repo-identity.js +82 -0
  69. package/dist/rules-sync.d.ts +7 -0
  70. package/dist/rules-sync.js +47 -0
  71. package/dist/savings-export.d.ts +49 -0
  72. package/dist/savings-export.js +141 -0
  73. package/dist/scan.d.ts +16 -0
  74. package/dist/scan.js +109 -0
  75. package/dist/search.d.ts +25 -0
  76. package/dist/search.js +150 -0
  77. package/dist/service.d.ts +20 -0
  78. package/dist/service.js +254 -0
  79. package/dist/shop.d.ts +9 -0
  80. package/dist/shop.js +15 -0
  81. package/dist/ui/server.d.ts +21 -0
  82. package/dist/ui/server.js +268 -0
  83. package/dist/vault.d.ts +25 -0
  84. package/dist/vault.js +42 -0
  85. package/dist/workspace-setup.d.ts +8 -0
  86. package/dist/workspace-setup.js +55 -0
  87. package/docs/agent-install-prompt.md +41 -0
  88. package/docs/backlog.md +59 -0
  89. package/docs/enterprise-endpoint.md +98 -0
  90. package/docs/license.md +54 -0
  91. package/docs/npm-release.md +38 -0
  92. package/docs/remember-contract.md +42 -0
  93. package/package.json +64 -0
  94. package/scripts/mdm-offboard.sh +14 -0
  95. package/skills/amem-bootstrap/SKILL.md +83 -0
  96. package/skills/amem-update-working-memory/SKILL.md +54 -0
  97. package/templates/cursor-rule.mdc +23 -0
  98. package/templates/mdm/co.amem.managed.plist +33 -0
  99. package/templates/policy.deny-default.toml +20 -0
  100. package/templates/policy.example.toml +22 -0
  101. package/ui-static/app.js +3966 -0
  102. package/ui-static/index.html +178 -0
  103. package/ui-static/orbit.js +389 -0
  104. package/ui-static/styles.css +2411 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 amem 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,534 @@
1
+ # amem
2
+
3
+ **Personal agent memory that stays on your machine.**
4
+
5
+ Coding agents forget between sessions. They re-grep the same tree, re-learn the same constraints, and burn tokens rediscovering decisions you already paid for once.
6
+
7
+ **amem** gives Cursor, Claude Code, and other local hosts a private, searchable memory of durable facts about *your* repos — what owns what, which files matter, what broke last time — so the next session starts oriented instead of cold.
8
+
9
+ ```bash
10
+ amem context "sync auth startup"
11
+ ```
12
+
13
+ ```markdown
14
+ # Agent Memory Context
15
+
16
+ ## Best Claims
17
+ ### claim.sync_auth_mode_startup
18
+ Kind: `constraint`
19
+ Why: `keyword+8`, `fts+18.0`, `embed+6.3`, `kind:constraint`, `fresh`
20
+
21
+ The sync service checks auth mode during startup before enabling Drive sync.
22
+ Anchors: `src/background/sync-service.ts`
23
+ ```
24
+
25
+ Nothing is uploaded. Nothing is written into your product git history. Memory lives under `~/.amem/` on your laptop only.
26
+
27
+ ---
28
+
29
+ ## Why amem exists
30
+
31
+ | Without amem | With amem |
32
+ | --- | --- |
33
+ | Agent explores broadly every session | Agent queries memory first, then verifies the right files |
34
+ | Decisions live in chat scrollback | Decisions become structured claims with file anchors |
35
+ | Team sharing pressure on “AI context” docs | Explicitly **personal** — your prompts and learnings stay local |
36
+ | Flat `AGENTS.md` that goes stale | Small graph: components → flows → claims, updated via proposals |
37
+
38
+ amem is **not** shared company wikiware and **not** a cloud RAG product. It is a local tool for individual developers who want agents that remember *their* work.
39
+
40
+ ---
41
+
42
+ ## Privacy (non-negotiable)
43
+
44
+ | Piece | Location | Shared? |
45
+ | --- | --- | --- |
46
+ | The amem tool (this repo) | GitHub / npm | Yes — installable |
47
+ | Your memory database | `~/.amem/graph.db` (or `.enc` when locked) | **No** |
48
+ | Cursor project rule | `.cursor/rules/amem.mdc` in the product repo | Safe to commit — **guidance only**, no memory contents |
49
+ | Exports / backups you create | Wherever you write them | **Keep private** — do not commit |
50
+
51
+ Guarantees:
52
+
53
+ - `~/.amem` is created with mode `0700`
54
+ - Local UI binds to `127.0.0.1` only
55
+ - No telemetry, no managed sync, no “share with org” mode
56
+ - Agents are instructed to store **repo facts**, not proprietary prompting strategy
57
+ - Optional AES-256-GCM lock and encrypted local backups — still no cloud
58
+
59
+ ---
60
+
61
+ ## Requirements
62
+
63
+ - **Node.js 20+** (native `better-sqlite3`)
64
+ - **git** (repo identity uses remote URL / root path)
65
+
66
+ ---
67
+
68
+ ## Install the tool
69
+
70
+ ```bash
71
+ npx @iamem/amem setup # Node 20+ — installs the `amem` CLI
72
+ # or
73
+ npm i -g @iamem/amem && amem setup
74
+ ```
75
+
76
+ From a clone while developing:
77
+
78
+ ```bash
79
+ git clone https://github.com/sslugic/amem.git
80
+ cd amem
81
+ npm install
82
+ npm link
83
+ amem setup
84
+ ```
85
+
86
+ See [docs/npm-release.md](docs/npm-release.md). CI runs `npm test` and `npm run pack:check`. `better-sqlite3` uses its own prebuilds — no extra native step on common macOS/Linux + Node 20/22.
87
+
88
+ If `npm install` fails compiling native code, install Xcode CLT (macOS) or `build-essential` (Linux) and retry, or use a Node 20/22 official binary that matches the prebuild matrix.
89
+
90
+ ### Quick paths
91
+
92
+ ```bash
93
+ # Cursor or Claude Code in a git repo
94
+ amem init --platform cursor # or: claude
95
+
96
+ # Other hosts (thin installers, same local DB)
97
+ amem init --platform windsurf|continue|aider|zed
98
+
99
+ # Cross-repo “how I work” prefs (blended into project context)
100
+ amem init --personal
101
+ # or: amem setup --personal
102
+ ```
103
+
104
+ ### Encrypt-at-rest + local backups
105
+
106
+ ```bash
107
+ amem lock --passphrase '…' # or AMEM_PASSPHRASE
108
+ amem unlock --passphrase '…'
109
+ amem backup --passphrase '…' # ~/.amem/backups by default
110
+ amem backup schedule # daily local timer (no cloud)
111
+ amem backup unschedule
112
+ ```
113
+
114
+ While locked, set `AMEM_PASSPHRASE` (or unlock) before any command that opens the DB.
115
+
116
+ ### License SKU + local embeddings
117
+
118
+ Free includes the hashing embedder (no download). Pro/IT can switch to a **local n-gram model** or an **external local command** (stdin text → JSON vector). Still no cloud embed API.
119
+
120
+ ```bash
121
+ amem license apply --file ~/Downloads/amem-license.json # after checkout on getamem.com
122
+ amem embed use ngram
123
+ amem embed reindex
124
+ amem restore --file ~/.amem/backups/amem-….db.enc
125
+ amem hygiene
126
+ amem rules sync
127
+ amem it-pack --out ~/.amem/it-pack
128
+ amem doctor --attest # IT tier adds a vault/host SKU packet
129
+ ```
130
+
131
+ See [docs/license.md](docs/license.md). Only vendor-signed license files unlock Pro/IT (verified offline). Nothing is uploaded.
132
+
133
+ Checkout + email delivery is a **separate** seller process (`npm run shop`) that is not published with the CLI. It can whitelist Mailtrap and Stripe names from another project’s `.env` — see [shop/README.md](shop/README.md).
134
+
135
+ ---
136
+
137
+ ## First-time setup (recommended)
138
+
139
+ ```bash
140
+ amem ui
141
+ ```
142
+
143
+ That opens `http://127.0.0.1:7843` on the **Setup** tab. It scans your home folder for git repos (skips `Library`, `node_modules`, `Downloads`, and similar noise). Check the ones you want, pick clients (Cursor, Claude Code, Windsurf, Continue, Aider, Zed, …), then **Start tracking selected**. Each pick is bound in `~/.amem` and gets the matching installer when available.
144
+
145
+ The header has a **Personal** switcher (cross-repo prefs) and **Lock / backup** chrome — lock status, last backup, and a daily local schedule. Memory shows the same lock/backup chips. The Setup tab includes a copyable **remember contract** for any MCP host (`amem recipe`).
146
+
147
+ Optional: check **Start amem ui when this computer logs in** so the localhost server comes back after a reboot:
148
+
149
+ ```bash
150
+ amem service install # macOS LaunchAgent, Linux systemd --user, or Windows Startup
151
+ amem service status
152
+ amem service uninstall
153
+ ```
154
+
155
+ Tabs after setup:
156
+
157
+ 1. **Setup** — scan/select repos, platforms, login auto-start, bootstrap proposal
158
+ 2. **Memory** — facts by file, scored drafts (approve / replace older / dismiss / reject noisy), edit/pin/delete, search, recent hits/misses
159
+ 3. **Stats** — estimated tokens saved per LLM, plus JSON / markdown / PDF export (proxies, not a bill)
160
+
161
+ Server-only (no browser open):
162
+
163
+ ```bash
164
+ amem ui --port 7843 --no-open
165
+ ```
166
+
167
+ To scan extra folders (or only a subset), set `AMEM_SCAN_ROOTS` to a colon-separated list of directories.
168
+
169
+ ### CLI alternative (no UI)
170
+
171
+ ```bash
172
+ cd ~/path/to/your-real-project
173
+ amem init --platform cursor # or: --platform claude
174
+ amem doctor
175
+ amem status
176
+ ```
177
+
178
+ To wire both agents to the same local memory, run `init` once per platform (or select both in the UI).
179
+
180
+ ---
181
+
182
+ ## Day-to-day loop
183
+
184
+ ### 1. Query before exploring
185
+
186
+ ```bash
187
+ amem context "billing webhook retry"
188
+ ```
189
+
190
+ Or let the agent do it — Cursor gets an always-on project rule; Claude gets hook guidance. Both install the skills:
191
+
192
+ - `amem-bootstrap` — seed baseline memory
193
+ - `amem-update-working-memory` — save durable learnings after a session
194
+
195
+ Hooks also inject context on session start / prompt submit, store conversation notes, queue **session-end drafts**, and can queue **miss→learn** drafts after empty context lookups when the agent later cites real files. Approve drafts in **Memory** (or allow low-risk kinds via policy `auto_apply_kinds`).
196
+
197
+ ### 2. Work as usual
198
+
199
+ Treat memory as a **map**, not source of truth. Read the anchored files before you change them. Prefer claims marked fresh; verify **stale** ones (anchored files changed after the claim).
200
+
201
+ ### 3. Save what should survive
202
+
203
+ Ask the agent to run `amem-update-working-memory`, approve Memory drafts, or apply a proposal yourself:
204
+
205
+ ```bash
206
+ amem propose validate /tmp/memory.json
207
+ amem propose diff /tmp/memory.json
208
+ amem propose apply /tmp/memory.json
209
+ ```
210
+
211
+ ### 4. Optional agent one-shot install
212
+
213
+ From inside the product repo, paste [docs/agent-install-prompt.md](docs/agent-install-prompt.md) into Cursor or Claude Code and let it run setup for you.
214
+
215
+ ---
216
+
217
+ ## What gets stored
218
+
219
+ Memory is a small local graph in SQLite:
220
+
221
+ | Object | Meaning |
222
+ | --- | --- |
223
+ | **Component** | A subsystem / module (`component.api`) |
224
+ | **Flow** | How work moves (`flow.checkout`) |
225
+ | **Claim** | A durable fact with file anchors (may be `active` or `superseded`; optional pin) |
226
+ | **Edge** | Links (claim → flow → component); `kind: "supersedes"` archives the target claim |
227
+ | **Draft** | Pending session / miss→learn proposals waiting for Memory approve |
228
+ | **Usage event** | Each `amem context` hit + token estimate |
229
+
230
+ Claims are the retrieval unit. Ranking combines:
231
+
232
+ - **SQLite FTS5** (Porter stemming) + keyword score
233
+ - On-device **hashing embeddings** (no model download)
234
+ - Pin boost, kind weights (`constraint` / `gotcha` > `session`), freshness
235
+ - Optional **personal** prefs claims blended into project context
236
+
237
+ Each injected claim includes a **Why:** line. Stale claims (anchors changed after `updated_at`) are down-ranked.
238
+
239
+ Example claim:
240
+
241
+ ```json
242
+ {
243
+ "id": "claim.webhook_idempotency",
244
+ "kind": "constraint",
245
+ "text": "Stripe webhooks must be idempotent on event.id before mutating invoices.",
246
+ "code_anchors": ["src/webhooks/stripe.ts"],
247
+ "supersedes": ["claim.webhook_old_rule"]
248
+ }
249
+ ```
250
+
251
+ `supersedes` (or an edge with `kind: "supersedes"`) marks older claim ids as archived so they leave retrieval.
252
+
253
+ ---
254
+
255
+ ## Token savings (estimates)
256
+
257
+ Every `amem context` logs a usage event. The UI **Stats** tab breaks this down by platform (`cursor`, `claude`, …).
258
+
259
+ Automatic estimate:
260
+
261
+ ```text
262
+ estimated_avoided = max(0, anchors×4000 + claims×200 − packet_tokens)
263
+ ```
264
+
265
+ This is a **proxy** for exploration avoided — not your Cursor/Anthropic bill. Money uses the same token proxy at **$3 per 1M input tokens** (Sonnet-class input). Cursor included usage and output tokens are not billed this way, so treat `$` as an order-of-magnitude estimate.
266
+
267
+ Time saved is a separate proxy: each returned file anchor is treated as ~1.2s of tool round-trip the agent did not have to make. Local lookup duration is measured (SQLite on localhost). **Hit rate** is keyword matches on `amem context` — not Cursor/model API calls (those still happen). A **miss** means no stored fact matched the query; newest facts may still be injected as a weak fallback, and the agent still talks to the model.
268
+
269
+ Stats also shows a **monthly projection**: last 7 days of calls (or fewer if you just started), scaled to 30 days. Still a proxy, not a bill.
270
+
271
+ If you later know a better number:
272
+
273
+ ```bash
274
+ amem usage report --platform cursor --saved 12000
275
+ # or attach to a specific event:
276
+ amem usage report --event-id usage_… --saved 12000
277
+ ```
278
+
279
+ ---
280
+
281
+ ## LLM clients (beyond git repos)
282
+
283
+ amem can bind a **named workspace** that is not a git checkout — for Luna Client or any tool that talks to Cursor/Claude/other models.
284
+
285
+ ```bash
286
+ amem init --workspace my-app
287
+ # seeds starter facts and runs a context check automatically
288
+ ```
289
+
290
+ Attach any LLM client yourself (HTTP or MCP). Keep `amem ui` running for HTTP. From the client, **before** each model call:
291
+
292
+ ```js
293
+ const res = await fetch("http://127.0.0.1:7843/api/context", {
294
+ method: "POST",
295
+ headers: { "Content-Type": "application/json" },
296
+ body: JSON.stringify({
297
+ workspace: "my-app",
298
+ query: userMessage,
299
+ platform: "app",
300
+ sessionId,
301
+ }),
302
+ });
303
+ const { markdown } = await res.json();
304
+ // prepend markdown to the prompt / tool result so the model skips a large retrieve
305
+ ```
306
+
307
+ After a durable outcome:
308
+
309
+ ```js
310
+ await fetch("http://127.0.0.1:7843/api/remember", {
311
+ method: "POST",
312
+ headers: { "Content-Type": "application/json" },
313
+ body: JSON.stringify({
314
+ workspace: "my-app",
315
+ text: takeaway,
316
+ kind: "session",
317
+ anchors: ["my-app"],
318
+ }),
319
+ });
320
+ ```
321
+
322
+ MCP config (any MCP host):
323
+
324
+ Keep `amem ui` running (or `amem service install` so it starts at login). GUI apps often cannot find `amem` on `PATH`, which shows up as “live tool discovery failed” / MCP `error` — not a sign-in prompt. Prefer HTTP:
325
+
326
+ ```json
327
+ {
328
+ "mcpServers": {
329
+ "amem": {
330
+ "url": "http://127.0.0.1:7843/mcp?workspace=my-app"
331
+ }
332
+ }
333
+ }
334
+ ```
335
+
336
+ Stdio also works if the host can spawn the binary. Print a config with absolute paths:
337
+
338
+ ```bash
339
+ amem mcp --print-config --workspace my-app
340
+ ```
341
+
342
+ Same localhost DB as git-repo memory. The UI switcher groups **Git repos** and **Workspaces**. Rename a workspace's display name anytime — the MCP slug (`workspace=luna-ai`) and stored claims stay on the same id.
343
+
344
+ ```bash
345
+ amem rename "Luna Client" --workspace luna-ai
346
+ ```
347
+
348
+ MCP tools (stdio or HTTP):
349
+
350
+ | Tool | When to use |
351
+ | --- | --- |
352
+ | `amem_context` | Ranked memory packet for the current question |
353
+ | `amem_remember` | Store a durable fact after an outcome |
354
+ | `amem_recipe` | Generic read-then-write contract (any MCP host) |
355
+ | `amem_repos` | What is monitored (git repos + named workspaces) |
356
+ | `amem_stats` | Lookup time, estimated tokens/ms saved, hit rate |
357
+ | `amem_graph` | Claims / components / flows stored for a workspace or repo |
358
+ | `amem_status` | Binding + counts; omit workspace for a machine-wide overview |
359
+
360
+ ---
361
+
362
+ ## Command reference
363
+
364
+ ```text
365
+ amem setup [--personal] [--platform <host>]
366
+ amem init --platform cursor|claude|windsurf|continue|aider|zed
367
+ amem init --workspace <name> [--path <dir>] [--platform …]
368
+ amem init --personal
369
+ amem rename "<display name>" --workspace <slug>
370
+ amem status [--workspace <name>]
371
+ amem doctor [--attest] [--json]
372
+ amem context "<query>" [--workspace <name>] [--platform …]
373
+ amem remember "<text>" [--workspace <name>] [--kind …] [--anchor <path>]
374
+ amem recipe [--json]
375
+ amem mcp [--print-config] [--workspace <name>]
376
+ amem propose validate|diff|apply <file.json>
377
+ amem export [--out <file.json>]
378
+ amem wipe --yes
379
+ amem wipe --all --yes
380
+ amem lock|unlock --passphrase <secret>
381
+ amem backup [--out <dir>] [--passphrase <secret>] [--label <name>]
382
+ amem backup schedule [--out <dir>] [--hour <0-23>]
383
+ amem backup unschedule
384
+ amem session touch --platform cursor|claude [--session-id <id>]
385
+ amem hook
386
+ amem usage report --saved <n> [--platform …] [--event-id …]
387
+ amem usage export [--format json|md|pdf] [--days 30] [--scope current|all] [--out <file>]
388
+ amem license status|apply|activate|clear|issue|keys
389
+ amem embed status|use hash|use ngram|reindex
390
+ amem ui [--port 7843] [--no-open]
391
+ amem service install|uninstall|status
392
+ ```
393
+
394
+ | Command | Purpose |
395
+ | --- | --- |
396
+ | `setup` | One-shot personal workspace + optional host install |
397
+ | `init` | Bind a git repo, named workspace, personal prefs, or host |
398
+ | `rename` | Change a workspace display name; MCP slug and memory stay bound |
399
+ | `context` | Retrieve a Markdown packet; log usage |
400
+ | `remember` | Store one local fact |
401
+ | `mcp` | Stdio MCP tools; HTTP MCP at `http://127.0.0.1:7843/mcp` while UI runs |
402
+ | `propose diff` | Preview claim/component/flow changes before apply |
403
+ | `propose apply` | Upsert structured memory locally |
404
+ | `lock` / `unlock` | Optional AES-256-GCM encrypt-at-rest for `graph.db` |
405
+ | `backup` | Local snapshot (optionally encrypted); `schedule` for daily timer |
406
+ | `ui` | Setup wizard + Memory + Stats on localhost |
407
+ | `service` | Login item so `amem ui` starts after reboot |
408
+ | `doctor --attest` | Privacy/policy attestation for IT tickets |
409
+ | `export` / `wipe` | Personal backup or delete (still local) |
410
+ | `wipe --all --yes` | Offboard: wipe every repo and remove `~/.amem` |
411
+
412
+ ---
413
+
414
+ ## What install puts where
415
+
416
+ ### Cursor
417
+
418
+ | Artifact | Path |
419
+ | --- | --- |
420
+ | Skills | `~/.cursor/skills/amem-*` |
421
+ | Project rule | `.cursor/rules/amem.mdc` (in the product repo) |
422
+ | Hooks | `~/.cursor/hooks.json` |
423
+
424
+ Reload Cursor if skills/rules do not appear immediately.
425
+
426
+ ### Claude Code
427
+
428
+ | Artifact | Path |
429
+ | --- | --- |
430
+ | Skills | `~/.claude/skills/amem-*` |
431
+ | Hooks | `~/.claude/settings.json` (`UserPromptSubmit` / `Stop` / related → full `amem hook`) |
432
+
433
+ ### Other hosts
434
+
435
+ | Host | What amem writes |
436
+ | --- | --- |
437
+ | Windsurf | `~/.codeium/windsurf/mcp_config.json` MCP entry |
438
+ | Continue | `~/.continue/config.json` MCP servers |
439
+ | Aider | `.aider.amem.md` CLI hints in the repo |
440
+ | Zed | `settings.json` `context_servers` / HTTP hint |
441
+
442
+ ---
443
+
444
+ ## Develop amem itself
445
+
446
+ ```bash
447
+ cd amem
448
+ npm install
449
+ npm run build
450
+ npm run test # unit + integration + CLI e2e (node:test)
451
+ npm run smoke # end-to-end CLI/API smoke
452
+ npm run test:all # both
453
+ npm link
454
+ ```
455
+
456
+ Layout:
457
+
458
+ ```text
459
+ src/ CLI, SQLite, policy, attest, installers, localhost API
460
+ ui-static/ Setup / Memory / Stats UI
461
+ skills/ Agent skill markdown
462
+ templates/ Cursor rule + example enterprise policy
463
+ docs/ Agent install prompt + IT endpoint runbook + backlog
464
+ test/ Comprehensive node:test suite
465
+ scripts/ Smoke tests + MDM offboard helper
466
+ ```
467
+
468
+ Override the memory home for tests:
469
+
470
+ ```bash
471
+ AMEM_HOME=/tmp/amem-test amem status
472
+ ```
473
+
474
+ ---
475
+
476
+ ## Enterprise endpoint (IT-managed)
477
+
478
+ amem is still **personal memory on the laptop** — not a shared wiki or cloud RAG.
479
+ IT / DevEx can govern the **fleet**: approved install, policy, attestation, offboarding.
480
+
481
+ | Control | Mechanism |
482
+ | --- | --- |
483
+ | Policy | `/etc/amem/policy.toml` (system) overrides `~/.amem/policy.toml`; or `AMEM_POLICY_PATH` |
484
+ | Attestation | `amem doctor --attest` / `--json` (also `GET /api/attest` on local UI) |
485
+ | Secret hygiene | Builtin deny patterns + policy `deny_claim_patterns` on propose |
486
+ | Export lock | `allow_export = false` |
487
+ | Platform / repo allowlists | `allowed_platforms`, `allowed_remote_hosts` |
488
+ | Auto-apply drafts | `auto_apply_kinds` (empty = never; still local) |
489
+ | Offboarding | `amem wipe --all --yes` or [scripts/mdm-offboard.sh](scripts/mdm-offboard.sh) |
490
+
491
+ Hard guarantees (not configurable away):
492
+
493
+ - No telemetry
494
+ - UI binds to loopback only (`127.0.0.1`)
495
+ - Memory stays under `~/.amem` (mode `0700`)
496
+
497
+ ### IT quick start
498
+
499
+ ```bash
500
+ # 1) Pin / install amem on the endpoint (internal npm, pkg, or npm link)
501
+ # 2) Deploy policy (root-owned on managed machines)
502
+ sudo mkdir -p /etc/amem
503
+ sudo cp templates/policy.example.toml /etc/amem/policy.toml
504
+
505
+ # 3) Verify for security review
506
+ amem doctor --attest --json
507
+
508
+ # 4) On offboard / laptop return
509
+ amem wipe --all --yes
510
+ # or: scripts/mdm-offboard.sh
511
+ ```
512
+
513
+ Example policy: [templates/policy.example.toml](templates/policy.example.toml)
514
+ Full IT runbook: [docs/enterprise-endpoint.md](docs/enterprise-endpoint.md)
515
+
516
+ Suggested rollout: small DevEx pilot → MDM package + policy → signed builds/SBOM if procurement asks. Shared org memory is intentionally out of scope.
517
+
518
+ ---
519
+
520
+ ## Non-goals
521
+
522
+ - Company-shared or synced memory
523
+ - Cloud hosted “team brain”
524
+ - Exact provider billing integration
525
+ - Cloud/remote embedding APIs (local FTS5 + on-device hashing embeddings only)
526
+ - Writing memory contents into product git history
527
+
528
+ Upcoming ideas (not scheduled): see [docs/backlog.md](docs/backlog.md).
529
+
530
+ ---
531
+
532
+ ## License
533
+
534
+ MIT — see [LICENSE](LICENSE).
@@ -0,0 +1,27 @@
1
+ import type { SessionRow, UsageEventRow } from "./db.js";
2
+ export type ActivityNode = {
3
+ id: string;
4
+ type: "amem" | "llm" | "server" | "session" | "local_hit" | "server_trip";
5
+ label: string;
6
+ detail: Record<string, unknown>;
7
+ };
8
+ export type ActivityLink = {
9
+ from: string;
10
+ to: string;
11
+ kind: string;
12
+ };
13
+ export type EventSpeed = {
14
+ kind: "local_hit" | "server_trip";
15
+ estimatedMsSaved: number;
16
+ localMs: number | null;
17
+ anchorsCount: number;
18
+ claimsCount: number;
19
+ };
20
+ export declare function speedForEvent(e: UsageEventRow): EventSpeed;
21
+ export declare function buildActivityGraph(input: {
22
+ events: UsageEventRow[];
23
+ sessions: SessionRow[];
24
+ }): {
25
+ nodes: ActivityNode[];
26
+ links: ActivityLink[];
27
+ };