@waynesutton/agent-memory 0.0.1-alpha.1
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/.claude/settings.json +9 -0
- package/.claude/settings.local.json +7 -0
- package/AGENTS.md +113 -0
- package/CLAUDE.md +79 -0
- package/README.md +1003 -0
- package/dist/cli/index.d.ts +3 -0
- package/dist/cli/index.d.ts.map +1 -0
- package/dist/cli/index.js +192 -0
- package/dist/cli/index.js.map +1 -0
- package/dist/cli/parsers/claude-code.d.ts +3 -0
- package/dist/cli/parsers/claude-code.d.ts.map +1 -0
- package/dist/cli/parsers/claude-code.js +75 -0
- package/dist/cli/parsers/claude-code.js.map +1 -0
- package/dist/cli/parsers/codex.d.ts +3 -0
- package/dist/cli/parsers/codex.d.ts.map +1 -0
- package/dist/cli/parsers/codex.js +42 -0
- package/dist/cli/parsers/codex.js.map +1 -0
- package/dist/cli/parsers/conductor.d.ts +3 -0
- package/dist/cli/parsers/conductor.d.ts.map +1 -0
- package/dist/cli/parsers/conductor.js +43 -0
- package/dist/cli/parsers/conductor.js.map +1 -0
- package/dist/cli/parsers/cursor.d.ts +3 -0
- package/dist/cli/parsers/cursor.d.ts.map +1 -0
- package/dist/cli/parsers/cursor.js +50 -0
- package/dist/cli/parsers/cursor.js.map +1 -0
- package/dist/cli/parsers/index.d.ts +12 -0
- package/dist/cli/parsers/index.d.ts.map +1 -0
- package/dist/cli/parsers/index.js +27 -0
- package/dist/cli/parsers/index.js.map +1 -0
- package/dist/cli/parsers/opencode.d.ts +3 -0
- package/dist/cli/parsers/opencode.d.ts.map +1 -0
- package/dist/cli/parsers/opencode.js +72 -0
- package/dist/cli/parsers/opencode.js.map +1 -0
- package/dist/cli/parsers/parsers.test.d.ts +2 -0
- package/dist/cli/parsers/parsers.test.d.ts.map +1 -0
- package/dist/cli/parsers/parsers.test.js +151 -0
- package/dist/cli/parsers/parsers.test.js.map +1 -0
- package/dist/cli/parsers/pi.d.ts +3 -0
- package/dist/cli/parsers/pi.d.ts.map +1 -0
- package/dist/cli/parsers/pi.js +43 -0
- package/dist/cli/parsers/pi.js.map +1 -0
- package/dist/cli/parsers/types.d.ts +25 -0
- package/dist/cli/parsers/types.d.ts.map +1 -0
- package/dist/cli/parsers/types.js +2 -0
- package/dist/cli/parsers/types.js.map +1 -0
- package/dist/cli/parsers/vscode-copilot.d.ts +3 -0
- package/dist/cli/parsers/vscode-copilot.d.ts.map +1 -0
- package/dist/cli/parsers/vscode-copilot.js +69 -0
- package/dist/cli/parsers/vscode-copilot.js.map +1 -0
- package/dist/cli/parsers/zed.d.ts +3 -0
- package/dist/cli/parsers/zed.d.ts.map +1 -0
- package/dist/cli/parsers/zed.js +43 -0
- package/dist/cli/parsers/zed.js.map +1 -0
- package/dist/cli/sync.d.ts +21 -0
- package/dist/cli/sync.d.ts.map +1 -0
- package/dist/cli/sync.js +78 -0
- package/dist/cli/sync.js.map +1 -0
- package/dist/cli/type-extractor.d.ts +25 -0
- package/dist/cli/type-extractor.d.ts.map +1 -0
- package/dist/cli/type-extractor.js +254 -0
- package/dist/cli/type-extractor.js.map +1 -0
- package/dist/cli/type-extractor.test.d.ts +2 -0
- package/dist/cli/type-extractor.test.d.ts.map +1 -0
- package/dist/cli/type-extractor.test.js +173 -0
- package/dist/cli/type-extractor.test.js.map +1 -0
- package/dist/client/http.d.ts +44 -0
- package/dist/client/http.d.ts.map +1 -0
- package/dist/client/http.js +311 -0
- package/dist/client/http.js.map +1 -0
- package/dist/client/index.d.ts +158 -0
- package/dist/client/index.d.ts.map +1 -0
- package/dist/client/index.js +256 -0
- package/dist/client/index.js.map +1 -0
- package/dist/component/_generated/api.d.ts +12 -0
- package/dist/component/_generated/api.d.ts.map +1 -0
- package/dist/component/_generated/api.js +13 -0
- package/dist/component/_generated/api.js.map +1 -0
- package/dist/component/_generated/dataModel.d.ts +18 -0
- package/dist/component/_generated/dataModel.d.ts.map +1 -0
- package/dist/component/_generated/dataModel.js +11 -0
- package/dist/component/_generated/dataModel.js.map +1 -0
- package/dist/component/_generated/server.d.ts +42 -0
- package/dist/component/_generated/server.d.ts.map +1 -0
- package/dist/component/_generated/server.js +39 -0
- package/dist/component/_generated/server.js.map +1 -0
- package/dist/component/actions.d.ts +42 -0
- package/dist/component/actions.d.ts.map +1 -0
- package/dist/component/actions.js +405 -0
- package/dist/component/actions.js.map +1 -0
- package/dist/component/apiKeyMutations.d.ts +29 -0
- package/dist/component/apiKeyMutations.d.ts.map +1 -0
- package/dist/component/apiKeyMutations.js +149 -0
- package/dist/component/apiKeyMutations.js.map +1 -0
- package/dist/component/apiKeyQueries.d.ts +37 -0
- package/dist/component/apiKeyQueries.d.ts.map +1 -0
- package/dist/component/apiKeyQueries.js +127 -0
- package/dist/component/apiKeyQueries.js.map +1 -0
- package/dist/component/checksum.d.ts +6 -0
- package/dist/component/checksum.d.ts.map +1 -0
- package/dist/component/checksum.js +14 -0
- package/dist/component/checksum.js.map +1 -0
- package/dist/component/checksum.test.d.ts +2 -0
- package/dist/component/checksum.test.d.ts.map +1 -0
- package/dist/component/checksum.test.js +27 -0
- package/dist/component/checksum.test.js.map +1 -0
- package/dist/component/convex.config.d.ts +3 -0
- package/dist/component/convex.config.d.ts.map +1 -0
- package/dist/component/convex.config.js +4 -0
- package/dist/component/convex.config.js.map +1 -0
- package/dist/component/cronActions.d.ts +3 -0
- package/dist/component/cronActions.d.ts.map +1 -0
- package/dist/component/cronActions.js +38 -0
- package/dist/component/cronActions.js.map +1 -0
- package/dist/component/cronQueries.d.ts +6 -0
- package/dist/component/cronQueries.d.ts.map +1 -0
- package/dist/component/cronQueries.js +38 -0
- package/dist/component/cronQueries.js.map +1 -0
- package/dist/component/crons.d.ts +3 -0
- package/dist/component/crons.d.ts.map +1 -0
- package/dist/component/crons.js +18 -0
- package/dist/component/crons.js.map +1 -0
- package/dist/component/format.d.ts +11 -0
- package/dist/component/format.d.ts.map +1 -0
- package/dist/component/format.js +175 -0
- package/dist/component/format.js.map +1 -0
- package/dist/component/format.test.d.ts +2 -0
- package/dist/component/format.test.d.ts.map +1 -0
- package/dist/component/format.test.js +118 -0
- package/dist/component/format.test.js.map +1 -0
- package/dist/component/mutations.d.ts +158 -0
- package/dist/component/mutations.d.ts.map +1 -0
- package/dist/component/mutations.js +745 -0
- package/dist/component/mutations.js.map +1 -0
- package/dist/component/queries.d.ts +94 -0
- package/dist/component/queries.d.ts.map +1 -0
- package/dist/component/queries.js +574 -0
- package/dist/component/queries.js.map +1 -0
- package/dist/component/schema.d.ts +278 -0
- package/dist/component/schema.d.ts.map +1 -0
- package/dist/component/schema.js +161 -0
- package/dist/component/schema.js.map +1 -0
- package/dist/mcp/server.d.ts +11 -0
- package/dist/mcp/server.d.ts.map +1 -0
- package/dist/mcp/server.js +571 -0
- package/dist/mcp/server.js.map +1 -0
- package/dist/shared.d.ts +126 -0
- package/dist/shared.d.ts.map +1 -0
- package/dist/shared.js +67 -0
- package/dist/shared.js.map +1 -0
- package/dist/test.d.ts +23 -0
- package/dist/test.d.ts.map +1 -0
- package/dist/test.js +21 -0
- package/dist/test.js.map +1 -0
- package/eslint.config.js +15 -0
- package/example/convex/convex.config.ts +7 -0
- package/example/convex/memory.ts +129 -0
- package/llms.md +175 -0
- package/llms.txt +126 -0
- package/package.json +80 -0
- package/prds/API-REFERENCE.md +935 -0
- package/prds/SETUP.md +682 -0
- package/src/cli/index.ts +254 -0
- package/src/cli/parsers/claude-code.ts +80 -0
- package/src/cli/parsers/codex.ts +45 -0
- package/src/cli/parsers/conductor.ts +47 -0
- package/src/cli/parsers/cursor.ts +55 -0
- package/src/cli/parsers/index.ts +30 -0
- package/src/cli/parsers/opencode.ts +84 -0
- package/src/cli/parsers/parsers.test.ts +201 -0
- package/src/cli/parsers/pi.ts +47 -0
- package/src/cli/parsers/types.ts +26 -0
- package/src/cli/parsers/vscode-copilot.ts +78 -0
- package/src/cli/parsers/zed.ts +47 -0
- package/src/cli/sync.ts +110 -0
- package/src/cli/type-extractor.test.ts +241 -0
- package/src/cli/type-extractor.ts +331 -0
- package/src/client/http.ts +415 -0
- package/src/client/index.ts +519 -0
- package/src/component/_generated/api.ts +14 -0
- package/src/component/_generated/dataModel.ts +20 -0
- package/src/component/_generated/server.ts +64 -0
- package/src/component/actions.ts +558 -0
- package/src/component/apiKeyMutations.ts +175 -0
- package/src/component/apiKeyQueries.ts +156 -0
- package/src/component/checksum.test.ts +31 -0
- package/src/component/checksum.ts +13 -0
- package/src/component/convex.config.ts +5 -0
- package/src/component/cronActions.ts +52 -0
- package/src/component/cronQueries.ts +42 -0
- package/src/component/crons.ts +34 -0
- package/src/component/format.test.ts +133 -0
- package/src/component/format.ts +232 -0
- package/src/component/mutations.ts +824 -0
- package/src/component/queries.ts +684 -0
- package/src/component/schema.ts +207 -0
- package/src/mcp/server.ts +695 -0
- package/src/shared.ts +251 -0
- package/src/test.ts +32 -0
- package/tsconfig.json +21 -0
- package/vitest.config.ts +8 -0
package/AGENTS.md
ADDED
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
# Agent Instructions — @waynesutton/agent-memory
|
|
2
|
+
|
|
3
|
+
## Project Overview
|
|
4
|
+
|
|
5
|
+
This is a Convex Component npm package (`@waynesutton/agent-memory`) that provides persistent, cloud-synced memory for AI coding agents. It is not a standalone app — it is installed into other Convex apps via `app.use(agentMemory)`.
|
|
6
|
+
|
|
7
|
+
## Tech Stack
|
|
8
|
+
|
|
9
|
+
- **Runtime:** Convex (serverless backend)
|
|
10
|
+
- **Language:** TypeScript (strict mode)
|
|
11
|
+
- **Build:** `tsc` (no bundler)
|
|
12
|
+
- **Test:** Vitest + convex-test
|
|
13
|
+
- **Package manager:** npm
|
|
14
|
+
|
|
15
|
+
## Project Structure
|
|
16
|
+
|
|
17
|
+
```
|
|
18
|
+
src/
|
|
19
|
+
├── component/ # Convex backend (defineComponent)
|
|
20
|
+
│ ├── schema.ts # 9 tables with validators and indexes
|
|
21
|
+
│ ├── mutations.ts # CRUD + batch + feedback + relations + history
|
|
22
|
+
│ ├── queries.ts # list, search, context bundle, history, feedback
|
|
23
|
+
│ ├── actions.ts # embeddings, semantic search, intelligent ingest
|
|
24
|
+
│ ├── apiKeyMutations.ts # API key create/revoke, rate limit
|
|
25
|
+
│ ├── apiKeyQueries.ts # API key validation
|
|
26
|
+
│ ├── crons.ts # Scheduled jobs (decay, cleanup)
|
|
27
|
+
│ ├── cronActions.ts # Internal actions for crons
|
|
28
|
+
│ ├── cronQueries.ts # Internal queries for crons
|
|
29
|
+
│ ├── format.ts # Memory -> tool-native file conversion
|
|
30
|
+
│ └── checksum.ts # FNV-1a hashing
|
|
31
|
+
├── client/
|
|
32
|
+
│ ├── index.ts # AgentMemory class (public API)
|
|
33
|
+
│ └── http.ts # MemoryHttpApi class (HTTP endpoints)
|
|
34
|
+
├── mcp/
|
|
35
|
+
│ └── server.ts # MCP server (14 tools)
|
|
36
|
+
├── cli/
|
|
37
|
+
│ ├── index.ts # CLI entry point
|
|
38
|
+
│ ├── sync.ts # Push/pull logic
|
|
39
|
+
│ └── parsers/ # 8 tool format parsers
|
|
40
|
+
├── shared.ts # Shared types and validators
|
|
41
|
+
└── test.ts # Test helper
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
## Development Commands
|
|
45
|
+
|
|
46
|
+
```bash
|
|
47
|
+
npm run build # tsc compile
|
|
48
|
+
npm run dev # tsc --watch
|
|
49
|
+
npm test # vitest run
|
|
50
|
+
npm run test:watch # vitest watch
|
|
51
|
+
npm run codegen # convex codegen for component
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
## Coding Conventions
|
|
55
|
+
|
|
56
|
+
### Convex Component Rules
|
|
57
|
+
|
|
58
|
+
1. **All public functions must have `args` and `returns` validators** — Convex components require explicit validators on every exported query, mutation, and action.
|
|
59
|
+
2. **No `ctx.auth`** — components cannot access the consuming app's auth. Identity is passed explicitly via `userId`, `agentId`, etc.
|
|
60
|
+
3. **No `process.env`** — components cannot read environment variables. Config values like API keys are passed as function arguments.
|
|
61
|
+
4. **IDs become strings at the boundary** — when the consuming app calls component functions, Convex `Id<"table">` values cross as strings. Cast with `as any` at boundaries.
|
|
62
|
+
5. **Use `(q: any)` for index queries** — TypeScript struggles with component-internal index types. Use `any` for `.withIndex()` callback parameters.
|
|
63
|
+
6. **Component tables are isolated** — the 9 tables live under the `agentMemory:` namespace, separate from the consuming app's tables.
|
|
64
|
+
|
|
65
|
+
### TypeScript
|
|
66
|
+
|
|
67
|
+
- Strict mode enabled
|
|
68
|
+
- Use `import type` for type-only imports
|
|
69
|
+
- Use `.js` extensions in import paths (ESM)
|
|
70
|
+
- Prefer `as const` for literal arrays used as validators
|
|
71
|
+
|
|
72
|
+
### Style
|
|
73
|
+
|
|
74
|
+
- Functions use explicit return types where validators require it
|
|
75
|
+
- Mutations that modify state always record history entries
|
|
76
|
+
- Checksums use FNV-1a (see `src/component/checksum.ts`)
|
|
77
|
+
- All timestamps are `Date.now()` (milliseconds)
|
|
78
|
+
|
|
79
|
+
## Key Patterns
|
|
80
|
+
|
|
81
|
+
### Adding a new query/mutation to the component
|
|
82
|
+
|
|
83
|
+
1. Add the function to `src/component/queries.ts` or `src/component/mutations.ts`
|
|
84
|
+
2. Include full `args` and `returns` validators
|
|
85
|
+
3. Add a wrapper method to `src/client/index.ts` (AgentMemory class)
|
|
86
|
+
4. If MCP-accessible, add a tool definition to `src/mcp/server.ts`
|
|
87
|
+
5. Update `src/shared.ts` if new types are needed
|
|
88
|
+
|
|
89
|
+
### The context bundle pattern
|
|
90
|
+
|
|
91
|
+
`getContextBundle` returns memories in 3 tiers:
|
|
92
|
+
- **pinned** — effective priority >= 0.8 (boosted by positive feedback)
|
|
93
|
+
- **relevant** — path-matched against `activePaths`
|
|
94
|
+
- **available** — everything else as summaries
|
|
95
|
+
|
|
96
|
+
Priority is computed by `getEffectivePriority()` which factors in `positiveCount` and `negativeCount`.
|
|
97
|
+
|
|
98
|
+
### The intelligent ingest pipeline
|
|
99
|
+
|
|
100
|
+
`actions.ingest` does: extract facts (LLM) -> search existing (full-text) -> decide per-fact (LLM) -> execute ADD/UPDATE/DELETE/SKIP.
|
|
101
|
+
|
|
102
|
+
## Testing
|
|
103
|
+
|
|
104
|
+
Tests use `convex-test` with Vitest. The component exports a test helper at `@waynesutton/agent-memory/test`.
|
|
105
|
+
|
|
106
|
+
## Documentation
|
|
107
|
+
|
|
108
|
+
- `README.md` — user-facing README
|
|
109
|
+
- `prds/API-REFERENCE.md` — complete API reference
|
|
110
|
+
- `prds/SETUP.md` — step-by-step setup guide
|
|
111
|
+
- `llms.txt` — concise reference for LLMs
|
|
112
|
+
- `llms.md` — detailed agent reference
|
|
113
|
+
- `CLAUDE.md` — Claude Code specific instructions
|
package/CLAUDE.md
ADDED
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
# CLAUDE.md — @waynesutton/agent-memory
|
|
2
|
+
|
|
3
|
+
## What This Project Is
|
|
4
|
+
|
|
5
|
+
A Convex Component npm package that provides persistent, cloud-synced memory for AI coding agents. Installed into Convex apps via `app.use(agentMemory)`. Not a standalone app.
|
|
6
|
+
|
|
7
|
+
## Build & Test
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npm run build # tsc
|
|
11
|
+
npm test # vitest run
|
|
12
|
+
npm run codegen # convex codegen --component-dir ./src/component
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## Key Files
|
|
16
|
+
|
|
17
|
+
- `src/component/schema.ts` — 9 tables (memories, embeddings, projects, syncLog, memoryHistory, memoryFeedback, memoryRelations, apiKeys, rateLimitTokens)
|
|
18
|
+
- `src/component/mutations.ts` — all write operations with history tracking
|
|
19
|
+
- `src/component/queries.ts` — all read operations
|
|
20
|
+
- `src/component/actions.ts` — embeddings, semantic search, intelligent ingest
|
|
21
|
+
- `src/component/apiKeyMutations.ts` — API key CRUD and rate limiting
|
|
22
|
+
- `src/component/apiKeyQueries.ts` — API key validation
|
|
23
|
+
- `src/client/index.ts` — `AgentMemory` class (the public API consumers use)
|
|
24
|
+
- `src/client/http.ts` — `MemoryHttpApi` class (read-only HTTP endpoints)
|
|
25
|
+
- `src/mcp/server.ts` — MCP server with 14 tools
|
|
26
|
+
- `src/shared.ts` — shared types and validators (used by both component and client)
|
|
27
|
+
- `src/component/crons.ts` — scheduled jobs (relevance decay, cleanup)
|
|
28
|
+
|
|
29
|
+
## Convex Component Rules (IMPORTANT)
|
|
30
|
+
|
|
31
|
+
These rules are non-negotiable when modifying this codebase:
|
|
32
|
+
|
|
33
|
+
1. **Every exported query/mutation/action must have `args` and `returns` validators.** This is a Convex component requirement. Missing validators will cause deployment failures.
|
|
34
|
+
|
|
35
|
+
2. **No `ctx.auth` inside `src/component/`.** Components don't have access to the consuming app's auth system. User identity is passed explicitly as string args (`userId`, `agentId`).
|
|
36
|
+
|
|
37
|
+
3. **No `process.env` inside `src/component/`.** Components run in an isolated environment. API keys and config must be passed as function arguments.
|
|
38
|
+
|
|
39
|
+
4. **IDs are strings at the component boundary.** When the consuming app calls component functions, `Id<"memories">` becomes `string`. Use `as any` or `as unknown as string` at boundaries.
|
|
40
|
+
|
|
41
|
+
5. **Use `(q: any)` in `.withIndex()` callbacks.** The generated types for component indexes don't resolve cleanly — use `any` for the query builder parameter.
|
|
42
|
+
|
|
43
|
+
6. **Import paths use `.js` extensions.** This is ESM. Write `import { foo } from "./bar.js"` not `"./bar"`.
|
|
44
|
+
|
|
45
|
+
7. **Mutations that change content must record history.** Every create/update/archive/restore writes to the `memoryHistory` table for audit trail.
|
|
46
|
+
|
|
47
|
+
## Code Style
|
|
48
|
+
|
|
49
|
+
- TypeScript strict mode
|
|
50
|
+
- No bundler — plain `tsc` output
|
|
51
|
+
- Prefer `as const` arrays for validator source-of-truth
|
|
52
|
+
- Timestamps are always `Date.now()` (milliseconds)
|
|
53
|
+
- Checksums use FNV-1a (`src/component/checksum.ts`)
|
|
54
|
+
- No unnecessary abstractions — three similar lines > premature helper
|
|
55
|
+
|
|
56
|
+
## Architecture Notes
|
|
57
|
+
|
|
58
|
+
- The `AgentMemory` class in `src/client/index.ts` wraps all component function calls. Consumers never call component functions directly in practice.
|
|
59
|
+
- The `MemoryHttpApi` class in `src/client/http.ts` generates `httpAction` handlers. It cannot create HTTP routes directly (Convex component limitation) — the consuming app mounts them.
|
|
60
|
+
- The MCP server (`src/mcp/server.ts`) runs as a local process using stdio, not as a Convex function. It uses `ConvexHttpClient` to talk to the backend.
|
|
61
|
+
- Cron jobs are defined in `src/component/crons.ts` and call internal actions/mutations. They run inside the component's isolated environment.
|
|
62
|
+
- The intelligent ingest pipeline (`actions.ingest`) calls an external LLM API from within a Convex action. It extracts facts, searches for overlap, and decides ADD/UPDATE/DELETE/SKIP per fact.
|
|
63
|
+
|
|
64
|
+
## When Adding Features
|
|
65
|
+
|
|
66
|
+
1. Start with the schema if new tables/fields are needed (`src/component/schema.ts`)
|
|
67
|
+
2. Add component functions (queries/mutations/actions in `src/component/`)
|
|
68
|
+
3. Add client wrapper methods (`src/client/index.ts`)
|
|
69
|
+
4. Add MCP tool if agent-accessible (`src/mcp/server.ts`)
|
|
70
|
+
5. Add types to `src/shared.ts` if needed
|
|
71
|
+
6. Update docs: `prds/API-REFERENCE.md`, `README.md`, `prds/SETUP.md`
|
|
72
|
+
7. Run `npm run build` to verify — zero TypeScript errors required
|
|
73
|
+
|
|
74
|
+
## Docs Location
|
|
75
|
+
|
|
76
|
+
User-facing docs are in `prds/` (not the project root):
|
|
77
|
+
- `README.md` — full README
|
|
78
|
+
- `prds/API-REFERENCE.md` — complete API reference
|
|
79
|
+
- `prds/SETUP.md` — setup guide with all integration paths (A through H)
|