@orquentra/codebuddy 0.0.0-stage → 2.4.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.
Files changed (82) hide show
  1. package/ARCHITECTURE.md +269 -0
  2. package/CLAUDE_CODEX.md +433 -0
  3. package/LICENSE +21 -0
  4. package/README.md +55 -2
  5. package/WORKFLOW.md +152 -0
  6. package/dist/chunk-3ZELDCR3.js +204 -0
  7. package/dist/chunk-3ZELDCR3.js.map +1 -0
  8. package/dist/chunk-5OWZVZSO.js +476 -0
  9. package/dist/chunk-5OWZVZSO.js.map +1 -0
  10. package/dist/chunk-DSN5CEHO.js +175 -0
  11. package/dist/chunk-DSN5CEHO.js.map +1 -0
  12. package/dist/chunk-GDJH7XJC.js +119 -0
  13. package/dist/chunk-GDJH7XJC.js.map +1 -0
  14. package/dist/chunk-IBMJYIEP.js +1578 -0
  15. package/dist/chunk-IBMJYIEP.js.map +1 -0
  16. package/dist/chunk-IE2OUO54.js +199 -0
  17. package/dist/chunk-IE2OUO54.js.map +1 -0
  18. package/dist/chunk-IHQM2ZDV.js +19 -0
  19. package/dist/chunk-IHQM2ZDV.js.map +1 -0
  20. package/dist/chunk-ITGRANYW.js +63 -0
  21. package/dist/chunk-ITGRANYW.js.map +1 -0
  22. package/dist/chunk-K63EOA4B.js +416 -0
  23. package/dist/chunk-K63EOA4B.js.map +1 -0
  24. package/dist/chunk-OLFCOR4U.js +8580 -0
  25. package/dist/chunk-OLFCOR4U.js.map +1 -0
  26. package/dist/chunk-PQK3GKZH.js +98 -0
  27. package/dist/chunk-PQK3GKZH.js.map +1 -0
  28. package/dist/chunk-PYLH4MH5.js +34 -0
  29. package/dist/chunk-PYLH4MH5.js.map +1 -0
  30. package/dist/chunk-PZ5AY32C.js +10 -0
  31. package/dist/chunk-PZ5AY32C.js.map +1 -0
  32. package/dist/chunk-TI5TQD6D.js +324 -0
  33. package/dist/chunk-TI5TQD6D.js.map +1 -0
  34. package/dist/chunk-WHZSVY2L.js +144 -0
  35. package/dist/chunk-WHZSVY2L.js.map +1 -0
  36. package/dist/cli/index.d.ts +1 -0
  37. package/dist/cli/index.js +15 -0
  38. package/dist/cli/index.js.map +1 -0
  39. package/dist/codebuddy-D2xJ6hFk.d.ts +841 -0
  40. package/dist/config-S2TULOMK.js +11 -0
  41. package/dist/config-S2TULOMK.js.map +1 -0
  42. package/dist/index.d.ts +2527 -0
  43. package/dist/index.js +116 -0
  44. package/dist/index.js.map +1 -0
  45. package/dist/langgraph/index.d.ts +53 -0
  46. package/dist/langgraph/index.js +143 -0
  47. package/dist/langgraph/index.js.map +1 -0
  48. package/dist/lean-command-D6TZJEFX.js +13 -0
  49. package/dist/lean-command-D6TZJEFX.js.map +1 -0
  50. package/dist/main-BFDVQHKO.js +4575 -0
  51. package/dist/main-BFDVQHKO.js.map +1 -0
  52. package/dist/memory-NIBFAMY4.js +57 -0
  53. package/dist/memory-NIBFAMY4.js.map +1 -0
  54. package/dist/pretool-command-MQQ2UNQM.js +10 -0
  55. package/dist/pretool-command-MQQ2UNQM.js.map +1 -0
  56. package/dist/rerank-Q7MIFNKA.js +60 -0
  57. package/dist/rerank-Q7MIFNKA.js.map +1 -0
  58. package/dist/summaries-TSE44KUQ.js +18 -0
  59. package/dist/summaries-TSE44KUQ.js.map +1 -0
  60. package/dist/zvec-F27AR357.js +23 -0
  61. package/dist/zvec-F27AR357.js.map +1 -0
  62. package/docker-compose.yml +20 -0
  63. package/examples/claude-code/README.md +67 -0
  64. package/examples/claude-desktop/README.md +54 -0
  65. package/examples/claude-desktop/claude_desktop_config.json +13 -0
  66. package/examples/langgraph-agent/README.md +32 -0
  67. package/examples/langgraph-agent/index.ts +71 -0
  68. package/examples/multi-agent-handoff/README.md +35 -0
  69. package/examples/multi-agent-handoff/index.ts +68 -0
  70. package/package.json +108 -4
  71. package/src/db/migrations/0000_cultured_satana.sql +144 -0
  72. package/src/db/migrations/0001_embedding_lease.sql +3 -0
  73. package/src/db/migrations/0002_embedding_lease_token.sql +1 -0
  74. package/src/db/migrations/0003_embedding_space.sql +9 -0
  75. package/src/db/migrations/0004_markdown_reconcile.sql +5 -0
  76. package/src/db/migrations/0005_fact_propositions.sql +1 -0
  77. package/src/db/migrations/meta/0000_snapshot.json +1169 -0
  78. package/src/db/migrations/meta/0002_snapshot.json +1181 -0
  79. package/src/db/migrations/meta/0003_snapshot.json +1214 -0
  80. package/src/db/migrations/meta/0004_snapshot.json +1225 -0
  81. package/src/db/migrations/meta/0005_snapshot.json +1231 -0
  82. package/src/db/migrations/meta/_journal.json +48 -0
@@ -0,0 +1,269 @@
1
+ # Architecture
2
+
3
+ ## Storage Model
4
+
5
+ CodeBuddy uses a dual-write transition model:
6
+
7
+ - facts and summaries are written to PostgreSQL and Markdown
8
+ - files live under `.codebuddy/memory/facts/` and
9
+ `.codebuddy/memory/summaries/`
10
+ - PostgreSQL remains the active query/index layer
11
+ - `codebuddy reindex --full` can recreate fact, summary, and pending embedding
12
+ records from those files
13
+ - reindex is a reconciliation, not an append: rows are upserted by file ID with
14
+ the file's content, confidence, `sourceDeleted`, `supersededBy` and
15
+ `createdAt`; changed content gets a fresh pending embedding; a deleted file
16
+ deletes its row. Malformed or conflicting files are reported per file
17
+ (`failures[]`) and never abort the run or count as deletions. A running MCP
18
+ server re-imports on startup, after `context_after_turn`, and whenever a
19
+ managed file under `.codebuddy/memory/{facts,summaries}/` changes
20
+ - ownership rule: only rows a reindex has imported from Markdown
21
+ (`file_backed = true`, set per namespace) are deleted when their file is
22
+ gone. Rows that predate migration `0003` or were never mirrored to a file
23
+ (e.g. snapshot shares) are left alone; once their file is seen by a reindex
24
+ they become file-backed. `source_interaction_id` is historical provenance,
25
+ not a foreign key, so facts re-import after the interactions are lost
26
+
27
+ The files use versioned YAML front matter, atomic temporary-file writes,
28
+ `fsync`, and rename. Repository-root validation rejects traversal and
29
+ symlinked memory paths.
30
+
31
+ The following data remains database-only:
32
+
33
+ - raw interactions
34
+ - share tombstones (live reference grants are mirrored in the source fact's `sharedWith`)
35
+ - audit logs
36
+ - model diagnostics
37
+ - generated embedding vectors
38
+
39
+ `codebuddy migrate to-files` is a non-writing preview. `--write` exports
40
+ missing files but never truncates database tables or overwrites conflicts.
41
+ Same-ID/different-content conflicts are reported with SHA-256 checksums.
42
+
43
+ ## Concurrency Model
44
+
45
+ `remember` uses Postgres advisory locks keyed by `(namespace, session_id)` so concurrent writers for the same session do not race.
46
+
47
+ Write idempotency rules:
48
+
49
+ - callers may pass `idempotencyKey`
50
+ - when omitted, CodeBuddy computes `sha256(namespace + session_id + content)`
51
+ - `content_hash` exists on both `interactions` and `facts`
52
+ - both tables enforce unique `(namespace_id, content_hash)`
53
+
54
+ Transaction rules:
55
+
56
+ - `remember` stores the interaction and the matching `embeddings` row with `status=pending` in one transaction
57
+ - embedding generation happens outside the transaction
58
+ - `share` is a single transaction across share records and audit inserts
59
+ - `forget` performs cascade behavior inside one transaction
60
+
61
+ ## Embedding Pipeline
62
+
63
+ Embeddings are asynchronous and run in an in-process worker.
64
+
65
+ Embedding record lifecycle:
66
+
67
+ - `pending`
68
+ - `ready`
69
+ - `failed`
70
+
71
+ Operational fields:
72
+
73
+ - `attempts`
74
+ - `last_error`
75
+
76
+ Embedding retrieval partitions rows by a canonical `(model, revision, schema,
77
+ dimensions)` identity. Query embeddings retain this identity; both SQL candidate
78
+ selection (before its limit) and the planner enforce an exact match before cosine
79
+ scoring. A provider fallback writes its own partition and cannot score against the
80
+ primary model's vectors. Missing compatible rows use the recency/summary fallback.
81
+ Providers must return finite vectors with consistent dimensions and batch size.
82
+
83
+ Provider adapters may supply `revision` and `schema` on embedding responses. These
84
+ identify the actual deployed revision and preprocessing contract; custom adapters
85
+ should use an immutable revision for pinned deployments. Omitted metadata uses
86
+ `unversioned` / `provider-v1`. The hosted Hugging Face adapter identifies its schema
87
+ as `hf-feature-extraction-v1` and uses `unversioned` unless deployment metadata is
88
+ configured; the HF SDK does not expose revision pinning. A remote update behind an
89
+ unversioned deployment cannot be detected locally, so changing a deployment requires
90
+ changing its revision/schema identity and rebuilding the derived index.
91
+
92
+ Migration `0003_embedding_space` requeues all legacy vectors with unknown space
93
+ metadata, including failed jobs and jobs with stale leases. It preserves owners and
94
+ model IDs, resets attempts/leases, and lets workers regenerate the appropriate
95
+ partition. Recency/summary fallback remains available while this rebuild completes.
96
+ No model space is inferred from vector dimensions.
97
+
98
+ Recall candidate selection:
99
+
100
+ - pgvector ranks every ready vector in the namespace that matches the query's
101
+ exact embedding space (source-deleted and superseded facts excluded), then the candidate
102
+ limit (default 256) applies; only IDs and scores are returned for hydration
103
+ - `stats.candidateCoverage` reports compatible ready vectors, candidates, and
104
+ hydrated rows; `stats.fallbackReason` says why vector search was skipped
105
+
106
+ Recall behavior when embeddings are not ready or the provider fails:
107
+
108
+ - use recency and summary-based recall, plus lexical matches over durable
109
+ facts from every session in the namespace
110
+ - skip pending vectors instead of blocking the caller
111
+
112
+ Rationale:
113
+
114
+ - better to return slightly stale ranking than block on Hugging Face cold starts or rate limits
115
+
116
+ ## Sharing Model
117
+
118
+ Shares are references by default.
119
+
120
+ Modes:
121
+
122
+ - `reference`
123
+ - `snapshot`
124
+
125
+ Ownership: only the configured namespace can share its own facts (`from` must be
126
+ the configured namespace). Repeating a share is idempotent.
127
+
128
+ Reference mode:
129
+
130
+ - target namespace points to the live source fact; `recall` in the target resolves
131
+ live references alongside its own embeddings (even when it has none of its own)
132
+ - source updates propagate
133
+ - deleting the source fact, or revoking with `unshare`, removes it from target recall
134
+ - durable form: the source fact's Markdown front matter lists `sharedWith: [namespace]`;
135
+ `reindex` of the source project restores the share rows
136
+
137
+ Snapshot mode:
138
+
139
+ - target namespace receives a copy, owned by the target
140
+ - the copy is written as a fact file (`predicate: snapshot_of`) into the target
141
+ project's own store, given explicitly as `targetProjectRoot` (MCP `to_project_root`),
142
+ whose configured namespace must match the target; it is never written under the
143
+ source project
144
+ - later source changes do not propagate
145
+ - source deletion does not delete the snapshot; the target's `reindex` rebuilds it after
146
+ database loss
147
+
148
+ ASCII model:
149
+
150
+ ```text
151
+ reference:
152
+ source fact A -----> shared reference in target
153
+ update A -----> visible in target
154
+ delete A -----> target reference tombstoned (also on unshare)
155
+
156
+ snapshot:
157
+ source fact A -----> copied fact B in target
158
+ update A -----> no change to B
159
+ delete A -----> B remains
160
+ ```
161
+
162
+ ## Conflicts
163
+
164
+ Facts are compared by an explicit `propositionKey` (fact front matter, mirrored
165
+ to the `facts.proposition_key` column), never by rendered text. Facts sharing a
166
+ key are rival assertions of one single-valued claim (for example
167
+ `database.primary.engine`); facts without a key are multi-valued and are never
168
+ grouped, so identical surface text cannot collapse distinct claims and
169
+ different wording cannot hide a contradiction.
170
+
171
+ Supported recall modes:
172
+
173
+ - `all` (default): keep every rival assertion
174
+ - `latest`: keep the newest assertion per key (then confidence, then id)
175
+ - `highest_confidence`: keep the most confident assertion per key (then recency, then id)
176
+
177
+ Superseded (`supersededBy`) and source-deleted facts are excluded before
178
+ resolution. Each recalled fact message carries `fact` provenance (subject,
179
+ predicate, object, key, confidence, createdAt, createdByAgent). When a key had
180
+ rivals, `fact.conflict` lists the candidate ids and sets `unresolved: true` if
181
+ differing objects remain undecided (any disagreement in `all`, an exact
182
+ time/confidence tie otherwise); the system prompt then names those keys. The
183
+ downstream agent reconciles unresolved contradictions. Reindex carries the
184
+ file's confidence, timestamp, `sourceDeleted`, `supersededBy` and key into the
185
+ database.
186
+
187
+ Explicit decision capture can now include `supersedes fact_<id>`. The older
188
+ fact remains on disk for audit history but is marked `supersededBy` and omitted
189
+ from current automatic context. Incident-resolution capture similarly links to
190
+ an unresolved incident on the same changed paths and sets `resolvedBy` instead
191
+ of creating a duplicate incident.
192
+
193
+ ## MCP Surface
194
+
195
+ The current MCP server intentionally ships tools only.
196
+
197
+ Deferred:
198
+
199
+ - resources such as `codebuddy://namespace/<name>/facts`
200
+ - prompts
201
+
202
+ Rationale:
203
+
204
+ - tools are enough for first release workflows
205
+ - resources and prompts add another compatibility surface and are deferred deliberately, not forgotten
206
+
207
+ ## Caching
208
+
209
+ The background index maintains `.codebuddy/cache/architecture.json` as a
210
+ versioned, rebuildable import-graph cache. Content hashes from `index.json`
211
+ identify changed modules. When the source-file set is stable, only changed
212
+ modules are reparsed and unchanged nodes/edges are reused; additions, removals,
213
+ and renames trigger a correctness-first graph rebuild. Context retrieval shares
214
+ one index snapshot across graph and symbol stages. Missing, corrupt,
215
+ or incompatible caches fall back to rebuilding and never become source of
216
+ truth.
217
+
218
+ `CodeBuddyNode` supports recall caching with:
219
+
220
+ ```ts
221
+ new CodeBuddyNode({ memory, mode: "recall", cacheTtlSeconds: 30 })
222
+ ```
223
+
224
+ Default cache:
225
+
226
+ - 30 seconds
227
+ - keyed by `(namespace, sessionId, query)`
228
+
229
+ This is especially useful in cyclic LangGraph flows that would otherwise repeat identical recall calls.
230
+
231
+ ## Logging
232
+
233
+ Use `pino` for structured logs.
234
+
235
+ Rules:
236
+
237
+ - MCP stdio server logs JSON to stderr
238
+ - CLI uses `pino-pretty` when attached to a TTY
239
+ - CLI falls back to JSON logs when not attached to a TTY
240
+ - logs must redact secrets such as `HF_TOKEN`
241
+ - LangSmith should capture the same structured fields where tracing is enabled
242
+
243
+ ## Privacy
244
+
245
+ - facts and summaries are plaintext Markdown
246
+ - conversations, shares, telemetry, and indexes are plaintext in PostgreSQL
247
+ - project owners decide whether `.codebuddy/memory/` is committed or ignored
248
+ - encryption at rest is a deployment responsibility, not an app-layer feature
249
+ - automatic PII detection is planned but not shipped
250
+ - later releases may add sensitivity metadata and redaction workflows
251
+
252
+ ## Forget Semantics
253
+
254
+ `forget(interactionId)`:
255
+
256
+ - hard-deletes the interaction
257
+ - hard-deletes its embedding
258
+ - tombstones extracted facts with `source_deleted: true`
259
+
260
+ `forget(factId)`:
261
+
262
+ - hard-deletes the fact
263
+ - hard-deletes its embedding
264
+ - tombstones referenced facts in other namespaces unless they were shared as snapshots
265
+
266
+ Audit requirements:
267
+
268
+ - `model_calls` records provider calls only
269
+ - persist forget, share, and write audit events in `audit_log`
@@ -0,0 +1,433 @@
1
+ # Claude Code And Codex Setup
2
+
3
+ This guide shows how to use CodeBuddy with Claude Code and Codex using the
4
+ project's local PostgreSQL database and optional local Graphify architecture
5
+ context.
6
+
7
+ ## Requirements
8
+
9
+ - Node.js 20+
10
+ - PostgreSQL 16 + pgvector
11
+ - npm
12
+ - Optional: Docker, if you explicitly choose the bundled database fallback
13
+
14
+ ## Install CodeBuddy
15
+
16
+ Install the package globally:
17
+
18
+ ```bash
19
+ npm install -g @orquentra/codebuddy
20
+ ```
21
+
22
+ Check the CLI:
23
+
24
+ ```bash
25
+ codebuddy --help
26
+ ```
27
+
28
+ ## Start PostgreSQL With Docker
29
+
30
+ CodeBuddy ships with a Docker Compose file that runs PostgreSQL 16 with `pgvector`.
31
+
32
+ Start the bundled database:
33
+
34
+ ```bash
35
+ codebuddy postgres up
36
+ ```
37
+
38
+ Check status:
39
+
40
+ ```bash
41
+ codebuddy postgres status
42
+ ```
43
+
44
+ The default database URL is:
45
+
46
+ ```text
47
+ postgres://codebuddy:codebuddy@localhost:5432/codebuddy
48
+ ```
49
+
50
+ You can also use raw Docker Compose from a local clone of this repository:
51
+
52
+ ```bash
53
+ docker compose up -d
54
+ docker compose ps
55
+ ```
56
+
57
+ View logs:
58
+
59
+ ```bash
60
+ docker compose logs postgres
61
+ docker compose logs -f postgres
62
+ ```
63
+
64
+ Open a PostgreSQL shell:
65
+
66
+ ```bash
67
+ docker exec -it codebuddy-postgres psql -U codebuddy -d codebuddy
68
+ ```
69
+
70
+ Inside `psql`, verify `pgvector`:
71
+
72
+ ```sql
73
+ SELECT extname FROM pg_extension WHERE extname = 'vector';
74
+ ```
75
+
76
+ Exit:
77
+
78
+ ```sql
79
+ \q
80
+ ```
81
+
82
+ Stop the database while preserving data:
83
+
84
+ ```bash
85
+ codebuddy postgres down
86
+ ```
87
+
88
+ or:
89
+
90
+ ```bash
91
+ docker compose down
92
+ ```
93
+
94
+ Reset the local database by deleting the Docker volume:
95
+
96
+ ```bash
97
+ docker compose down
98
+ docker volume ls | grep codebuddy
99
+ docker volume rm <codebuddy-volume-name>
100
+ docker compose up -d
101
+ ```
102
+
103
+ Before resetting the volume, export any older database-only facts and
104
+ summaries:
105
+
106
+ ```bash
107
+ codebuddy migrate to-files
108
+ codebuddy migrate to-files --write
109
+ ```
110
+
111
+ After resetting the volume:
112
+
113
+ ```bash
114
+ codebuddy migrate
115
+ codebuddy reindex --full
116
+ ```
117
+
118
+ Facts and summaries can be restored from `.codebuddy/memory/`. Raw
119
+ interactions, shares, audit logs, and model diagnostics remain database-only
120
+ and are lost with the volume.
121
+
122
+ ## Memory Privacy
123
+
124
+ Markdown memory is plaintext. Inspect it before committing:
125
+
126
+ ```bash
127
+ find .codebuddy/memory -type f -maxdepth 3
128
+ ```
129
+
130
+ To keep all project memory private, add this to the project `.gitignore`:
131
+
132
+ ```gitignore
133
+ .codebuddy/memory/
134
+ ```
135
+
136
+ Do not place API tokens, passwords, private keys, or unredacted personal data
137
+ in committed memory files.
138
+
139
+ ## Initialize CodeBuddy
140
+
141
+ The shortest path is to open a project folder and run:
142
+
143
+ ```bash
144
+ codebuddy
145
+ ```
146
+
147
+ The setup asks whether to enable Graphify. Choose **yes** to install/detect
148
+ Graphify, register both local MCP servers in `.mcp.json`, and enable Graphify
149
+ architecture input. Choose **no** to register only CodeBuddy; its own local
150
+ index and MCP context tools work the same way.
151
+
152
+ Both choices also create `.codebuddy/config.json`, validate the local Postgres
153
+ connection, apply migrations, install `CLAUDE.md` and `AGENTS.md` workflow
154
+ instructions, and register Claude/Codex MCP entries. Credentials stay in the
155
+ private CodeBuddy config, not in `.mcp.json`.
156
+
157
+ When Graphify is enabled, setup builds the graph automatically. To refresh it
158
+ after repository changes, run:
159
+
160
+ ```bash
161
+ codebuddy graphify index
162
+ ```
163
+
164
+ That creates or updates `graphify-out/graph.json`; CodeBuddy consumes it
165
+ automatically for architecture context. `codebuddy serve` also prepares a
166
+ missing or invalid graph before starting.
167
+
168
+ Run the setup wizard:
169
+
170
+ ```bash
171
+ codebuddy init
172
+ ```
173
+
174
+ The legacy wizard asks for:
175
+
176
+ - Optional Hugging Face token
177
+ - PostgreSQL URL
178
+ - default namespace
179
+ - whether to register with Claude Desktop
180
+
181
+ For local Docker PostgreSQL, use:
182
+
183
+ ```text
184
+ postgres://codebuddy:codebuddy@localhost:5432/codebuddy
185
+ ```
186
+
187
+ Run migrations manually if needed:
188
+
189
+ ```bash
190
+ codebuddy migrate
191
+ ```
192
+
193
+ Check health:
194
+
195
+ ```bash
196
+ codebuddy doctor
197
+ ```
198
+
199
+ Skip live model checks:
200
+
201
+ ```bash
202
+ codebuddy doctor --skip-model-check
203
+ ```
204
+
205
+ ## One-Command Project Setup
206
+
207
+ For each project, run:
208
+
209
+ ```bash
210
+ cd /path/to/your-project
211
+ codebuddy use
212
+ ```
213
+
214
+ This command:
215
+
216
+ - derives the namespace from the project folder
217
+ - reuses saved Hugging Face and database settings
218
+ - validates local PostgreSQL; Docker is only used with `codebuddy use --docker`
219
+ - applies migrations
220
+ - registers Claude Desktop
221
+ - registers Codex
222
+ - asks whether to enable Graphify and writes the project MCP config
223
+ - installs managed `CLAUDE.md` and `AGENTS.md` instructions
224
+
225
+ Use a custom namespace:
226
+
227
+ ```bash
228
+ codebuddy use my-project
229
+ ```
230
+
231
+ Use a custom PostgreSQL URL:
232
+
233
+ ```bash
234
+ codebuddy use --postgres-url "postgres://user:password@host:5432/database"
235
+ ```
236
+
237
+ Skip Claude Desktop registration:
238
+
239
+ ```bash
240
+ codebuddy use --skip-claude
241
+ ```
242
+
243
+ Skip Codex registration:
244
+
245
+ ```bash
246
+ codebuddy use --skip-codex
247
+ ```
248
+
249
+ ## Claude Code Setup
250
+
251
+ Claude Code reads MCP servers from a project `.mcp.json` file.
252
+
253
+ In your project:
254
+
255
+ ```bash
256
+ cd /path/to/your-project
257
+ ```
258
+
259
+ Create `.mcp.json`:
260
+
261
+ ```json
262
+ {
263
+ "mcpServers": {
264
+ "codebuddy": {
265
+ "command": "codebuddy",
266
+ "args": ["serve"],
267
+ "env": {
268
+ "DATABASE_URL": "postgres://codebuddy:codebuddy@localhost:5432/codebuddy",
269
+ "HF_TOKEN": "hf_your_token",
270
+ "CODEBUDDY_NAMESPACE": "your-project"
271
+ }
272
+ }
273
+ }
274
+ }
275
+ ```
276
+
277
+ Replace:
278
+
279
+ - `hf_your_token` with your Hugging Face token
280
+ - `your-project` with your namespace
281
+
282
+ Restart Claude Code after creating or editing `.mcp.json`.
283
+
284
+ Test from Claude Code by asking:
285
+
286
+ ```text
287
+ Remember that this project uses CodeBuddy for MCP memory.
288
+ ```
289
+
290
+ Then ask:
291
+
292
+ ```text
293
+ Recall what you know about this project.
294
+ ```
295
+
296
+ ## Codex Setup
297
+
298
+ The easiest Codex setup is:
299
+
300
+ ```bash
301
+ cd /path/to/your-project
302
+ codebuddy use
303
+ ```
304
+
305
+ Then restart Codex.
306
+
307
+ Check Codex entries:
308
+
309
+ ```bash
310
+ codebuddy codex list
311
+ ```
312
+
313
+ Install a Codex entry manually:
314
+
315
+ ```bash
316
+ codebuddy codex install --namespace your-project
317
+ ```
318
+
319
+ Remove a Codex entry:
320
+
321
+ ```bash
322
+ codebuddy codex remove codebuddy-your-project
323
+ ```
324
+
325
+ CodeBuddy writes Codex MCP configuration to:
326
+
327
+ ```text
328
+ ~/.codex/config.toml
329
+ ```
330
+
331
+ The generated entry looks like:
332
+
333
+ ```toml
334
+ [mcp_servers."codebuddy-your-project"]
335
+ command = "codebuddy"
336
+ args = ["serve"]
337
+
338
+ [mcp_servers."codebuddy-your-project".env]
339
+ CODEBUDDY_NAMESPACE = "your-project"
340
+ DATABASE_URL = "postgres://codebuddy:codebuddy@localhost:5432/codebuddy"
341
+ HF_TOKEN = "hf_your_token"
342
+ ```
343
+
344
+ Restart Codex after installing or changing an MCP entry.
345
+
346
+ ## Useful CLI Commands
347
+
348
+ List namespaces:
349
+
350
+ ```bash
351
+ codebuddy namespaces
352
+ ```
353
+
354
+ Inspect a namespace:
355
+
356
+ ```bash
357
+ codebuddy inspect your-project
358
+ ```
359
+
360
+ List facts:
361
+
362
+ ```bash
363
+ codebuddy list-facts
364
+ ```
365
+
366
+ Export a namespace:
367
+
368
+ ```bash
369
+ codebuddy export your-project > codebuddy-memory.json
370
+ ```
371
+
372
+ Show storage and usage stats:
373
+
374
+ ```bash
375
+ codebuddy stats
376
+ ```
377
+
378
+ Delete old memories:
379
+
380
+ ```bash
381
+ codebuddy prune --older-than 30d
382
+ ```
383
+
384
+ ## Troubleshooting
385
+
386
+ If PostgreSQL is not reachable:
387
+
388
+ ```bash
389
+ codebuddy postgres up
390
+ codebuddy doctor --skip-model-check
391
+ ```
392
+
393
+ If Docker is not running, start Docker first, then run:
394
+
395
+ ```bash
396
+ codebuddy postgres up
397
+ ```
398
+
399
+ If port `5432` is already in use:
400
+
401
+ ```bash
402
+ lsof -i :5432
403
+ ```
404
+
405
+ Stop the conflicting service or use another PostgreSQL URL.
406
+
407
+ If migrations are missing:
408
+
409
+ ```bash
410
+ codebuddy migrate
411
+ ```
412
+
413
+ If Claude Code does not show CodeBuddy tools:
414
+
415
+ - confirm `.mcp.json` is in the project root
416
+ - confirm `HF_TOKEN`, `DATABASE_URL`, and `CODEBUDDY_NAMESPACE`
417
+ - restart Claude Code
418
+
419
+ If Codex does not show CodeBuddy tools:
420
+
421
+ ```bash
422
+ codebuddy codex list
423
+ ```
424
+
425
+ Then restart Codex.
426
+
427
+ If model checks fail because a Hugging Face model is cold, gated, or rate-limited, run:
428
+
429
+ ```bash
430
+ codebuddy doctor --skip-model-check
431
+ ```
432
+
433
+ Database and MCP setup can still be valid even when live Hugging Face diagnostics are temporarily unavailable.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Orquentra Inc
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.