@orquentra/codebuddy 2.14.0 → 2.15.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 (93) hide show
  1. package/ARCHITECTURE.md +98 -0
  2. package/README.md +87 -6
  3. package/dist/{chunk-YNSTIMCF.js → chunk-4DTO2E4Y.js} +352 -157
  4. package/dist/chunk-4DTO2E4Y.js.map +1 -0
  5. package/dist/{chunk-CAEPHLHC.js → chunk-57642NGU.js} +2 -44
  6. package/dist/chunk-57642NGU.js.map +1 -0
  7. package/dist/chunk-6OQKL35B.js +55 -0
  8. package/dist/chunk-6OQKL35B.js.map +1 -0
  9. package/dist/{chunk-4DKYKDHI.js → chunk-7IPSDDO5.js} +5 -3
  10. package/dist/{chunk-4DKYKDHI.js.map → chunk-7IPSDDO5.js.map} +1 -1
  11. package/dist/chunk-7JPUMXFE.js +413 -0
  12. package/dist/chunk-7JPUMXFE.js.map +1 -0
  13. package/dist/{chunk-LRQNPYCK.js → chunk-AFXWCSQ4.js} +13 -7
  14. package/dist/chunk-AFXWCSQ4.js.map +1 -0
  15. package/dist/chunk-BNZDEU5K.js +368 -0
  16. package/dist/chunk-BNZDEU5K.js.map +1 -0
  17. package/dist/chunk-EMWGLKPR.js +45 -0
  18. package/dist/chunk-EMWGLKPR.js.map +1 -0
  19. package/dist/{chunk-YJPCS2GP.js → chunk-GNV4X67F.js} +59 -20
  20. package/dist/chunk-GNV4X67F.js.map +1 -0
  21. package/dist/{chunk-YWDH6DQ6.js → chunk-IM5RFEW4.js} +21 -19
  22. package/dist/{chunk-YWDH6DQ6.js.map → chunk-IM5RFEW4.js.map} +1 -1
  23. package/dist/chunk-K4XNTYV7.js +136 -0
  24. package/dist/chunk-K4XNTYV7.js.map +1 -0
  25. package/dist/{chunk-ESZXCZIN.js → chunk-MNSMW4MZ.js} +33 -5
  26. package/dist/chunk-MNSMW4MZ.js.map +1 -0
  27. package/dist/chunk-NNJSAYHY.js +372 -0
  28. package/dist/chunk-NNJSAYHY.js.map +1 -0
  29. package/dist/{chunk-XSNW6Y3X.js → chunk-OO7Q7XZF.js} +28 -24
  30. package/dist/chunk-OO7Q7XZF.js.map +1 -0
  31. package/dist/{chunk-L6BRYZ6G.js → chunk-PZ4EBFIA.js} +7 -7
  32. package/dist/{chunk-L6BRYZ6G.js.map → chunk-PZ4EBFIA.js.map} +1 -1
  33. package/dist/chunk-RGIVHKBH.js +156 -0
  34. package/dist/chunk-RGIVHKBH.js.map +1 -0
  35. package/dist/{chunk-LW75SKZR.js → chunk-RKF4HBBQ.js} +126 -18
  36. package/dist/chunk-RKF4HBBQ.js.map +1 -0
  37. package/dist/{chunk-7QMHIJBA.js → chunk-VBDM7HC5.js} +969 -968
  38. package/dist/chunk-VBDM7HC5.js.map +1 -0
  39. package/dist/chunk-VF7DKRIU.js +50 -0
  40. package/dist/chunk-VF7DKRIU.js.map +1 -0
  41. package/dist/{chunk-KNR2P2UY.js → chunk-Y4QQML24.js} +21 -6
  42. package/dist/chunk-Y4QQML24.js.map +1 -0
  43. package/dist/cli/index.js +4 -4
  44. package/dist/config-S2BDMT4B.js +15 -0
  45. package/dist/expand-TONFVT5D.js +98 -0
  46. package/dist/expand-TONFVT5D.js.map +1 -0
  47. package/dist/file-vectors-VREL75MA.js +19 -0
  48. package/dist/index-facts-MBJKBYA3.js +38 -0
  49. package/dist/index-pass-RP23G2CR.js +15 -0
  50. package/dist/index.js +24 -22
  51. package/dist/{install-EU35ERK5.js → install-MCJIJMFF.js} +11 -10
  52. package/dist/{lean-43ADYTBW.js → lean-CBHVW6JM.js} +8 -7
  53. package/dist/local-TH5XCLVJ.js +48 -0
  54. package/dist/local-llm-GZREB5DF.js +19 -0
  55. package/dist/local-llm-GZREB5DF.js.map +1 -0
  56. package/dist/{main-SFC5LV4E.js → main-QF6Z552J.js} +346 -140
  57. package/dist/main-QF6Z552J.js.map +1 -0
  58. package/dist/{memory-TGHVTBME.js → memory-LSZKSF53.js} +9 -6
  59. package/dist/{memory-TGHVTBME.js.map → memory-LSZKSF53.js.map} +1 -1
  60. package/dist/{operations-6Z6ZDVBP.js → operations-BPI633VN.js} +8 -7
  61. package/dist/operations-BPI633VN.js.map +1 -0
  62. package/dist/{rerank-IQAEWLQR.js → rerank-EPCTSEVP.js} +7 -4
  63. package/dist/{rerank-IQAEWLQR.js.map → rerank-EPCTSEVP.js.map} +1 -1
  64. package/dist/{runtime-W5AW32SD.js → runtime-W5ACTDFS.js} +9 -8
  65. package/dist/runtime-W5ACTDFS.js.map +1 -0
  66. package/dist/summaries-W2J5FCLG.js +32 -0
  67. package/dist/summaries-W2J5FCLG.js.map +1 -0
  68. package/dist/{zvec-24HLAFGN.js → zvec-LSA2IRAU.js} +13 -5
  69. package/dist/zvec-LSA2IRAU.js.map +1 -0
  70. package/package.json +3 -2
  71. package/dist/chunk-7QMHIJBA.js.map +0 -1
  72. package/dist/chunk-CAEPHLHC.js.map +0 -1
  73. package/dist/chunk-ESC4Y3L7.js +0 -204
  74. package/dist/chunk-ESC4Y3L7.js.map +0 -1
  75. package/dist/chunk-ESZXCZIN.js.map +0 -1
  76. package/dist/chunk-KNR2P2UY.js.map +0 -1
  77. package/dist/chunk-LRQNPYCK.js.map +0 -1
  78. package/dist/chunk-LW75SKZR.js.map +0 -1
  79. package/dist/chunk-SFMIMLXR.js +0 -63
  80. package/dist/chunk-SFMIMLXR.js.map +0 -1
  81. package/dist/chunk-XSNW6Y3X.js.map +0 -1
  82. package/dist/chunk-YJPCS2GP.js.map +0 -1
  83. package/dist/chunk-YNSTIMCF.js.map +0 -1
  84. package/dist/config-GEZFLXK6.js +0 -12
  85. package/dist/main-SFC5LV4E.js.map +0 -1
  86. package/dist/summaries-32PHOB6L.js +0 -20
  87. /package/dist/{config-GEZFLXK6.js.map → config-S2BDMT4B.js.map} +0 -0
  88. /package/dist/{install-EU35ERK5.js.map → file-vectors-VREL75MA.js.map} +0 -0
  89. /package/dist/{lean-43ADYTBW.js.map → index-facts-MBJKBYA3.js.map} +0 -0
  90. /package/dist/{operations-6Z6ZDVBP.js.map → index-pass-RP23G2CR.js.map} +0 -0
  91. /package/dist/{runtime-W5AW32SD.js.map → install-MCJIJMFF.js.map} +0 -0
  92. /package/dist/{summaries-32PHOB6L.js.map → lean-CBHVW6JM.js.map} +0 -0
  93. /package/dist/{zvec-24HLAFGN.js.map → local-TH5XCLVJ.js.map} +0 -0
package/ARCHITECTURE.md CHANGED
@@ -113,6 +113,104 @@ Rationale:
113
113
 
114
114
  - better to return slightly stale ranking than block on Hugging Face cold starts or rate limits
115
115
 
116
+ ## Local LLM and Intent Cards (2.15)
117
+
118
+ **Runtime: node-llama-cpp.** The local small model (Qwen3-0.6B Q4_K_M by
119
+ default; Qwen3-1.7B as `better`; Qwen only) runs through
120
+ node-llama-cpp 3.22 (llama.cpp bindings). It was compared with Cactus on the
121
+ four criteria in the 2.15 brief:
122
+
123
+ | | node-llama-cpp 3.22.3 | Cactus |
124
+ |---|---|---|
125
+ | Install size | 41 MB package + one prebuilt binary (19 MB mac-arm64-metal, 33–34 MB x64) | npm ships `cactus-react-native` (152 MB, mobile) and `cactus-needle` (tool-calling model only) |
126
+ | Cold start (M-series, Qwen3-0.6B) | 441 ms load, measured | no Node server binding to measure |
127
+ | Tokens/s (M-series, Metal) | 100–200 tok/s measured; ~2 s per card incl. JSON grammar | n/a |
128
+ | Prebuilt targets | macOS arm64/x64, Linux x64/arm64, Windows x64 (+CUDA/Vulkan) | iOS/Android focus |
129
+
130
+ Cactus has no maintained Node.js binding for a desktop/server process, and its
131
+ Node package hosts only the Needle tool-calling model, which the brief excludes
132
+ (the job is plain English → code vocabulary, not tool selection). So
133
+ node-llama-cpp. It is not a package dependency: `codebuddy` (or
134
+ `codebuddy models add local-llm`) installs it with `npm -g` and downloads the pinned GGUF into
135
+ `~/.cache/codebuddy/models/gguf/`, checking size and sha256 before moving it
136
+ into place. Forcing `gpu: false` on macOS makes node-llama-cpp compile llama.cpp
137
+ from source (34 s first load), so the backend uses `gpu: "auto"` (Metal on Apple
138
+ Silicon, CPU elsewhere) with `threads` capped at cores − 1
139
+ (`CODEBUDDY_LLM_THREADS` overrides).
140
+
141
+ **Where it runs.** Generation happens on llama.cpp's native threads inside
142
+ `codebuddy serve` (background project sync) or `codebuddy index --cards`, never
143
+ on a request path except the bounded query expansion below. A single context
144
+ sequence serialises calls. Hooks and MCP tool calls touch
145
+ `.codebuddy/cache/foreground`; the card and fact passes wait (up to 15 s) while
146
+ it is fresher than 2 s. Output is constrained by a JSON-schema grammar with
147
+ `maxItems`/`maxLength` bounds (without them the 0.6B model writes paragraphs
148
+ until the token cap cuts the JSON), then validated with zod; invalid output is
149
+ retried once, then the file is skipped.
150
+
151
+ **Lifetime.** The model is loaded on demand and unloaded `IDLE_UNLOAD_MS`
152
+ (60 s) after its last generation; measured on Qwen3-0.6B, resident memory went
153
+ from 1,274 MB to 452 MB (the rest is the llama.cpp/Metal runtime, freed when
154
+ the process exits). `serve` frees it on shutdown, and the detached
155
+ `index --cards` that setup starts exits when its pass ends. Setup skips the
156
+ local model on machines under 4 GB RAM or with one core (`machineCanCard`) and
157
+ uses cloud Qwen there when a key is set.
158
+
159
+ **Model size.** The same four-file card test with the grammar bounds:
160
+ SmolLM2-135M Q4_K_M (105 MB) wrote `...` summaries and raw code lines as
161
+ symptoms; Gemma 3 270M Q4_K_M (253 MB) wrote one-word summaries and term lists
162
+ as symptoms; Qwen3-0.6B Q4_K_M (397 MB) wrote usable summaries and symptoms.
163
+ So CodeBuddy ships Qwen only. A machine below `machineCanCard` gets Qwen from
164
+ the cloud instead (BYOK: `qwen/qwen3.8-27b` on Groq or OpenRouter, sent with
165
+ `reasoning_effort: "none"`; `<think>` blocks are stripped), configured by
166
+ setup only when a provider key is already in the environment.
167
+
168
+ **Cards** extend the existing `llm-summaries.json` store (prompt version 2), so
169
+ the BYOK and local backends fill the same cache. Each card is used three ways:
170
+ a card vector per file in `file-vectors.json` (granite, next to the chunk
171
+ vectors), one Markdown file per source file in `.codebuddy/cache/cards/`, which
172
+ is its own zvec-grep workspace (English model `local/bge-small-en-v1.5`,
173
+ `--no-ignore`, so the project's ignore rules never hide it), and card terms and
174
+ symptoms in the content index at half weight.
175
+
176
+ **Agreement rule** (`context/discovery.ts`). 2.14 dropped every vector hit
177
+ outside the keyword set unless it shared task terms with the source and cleared
178
+ `zvec.minScore`. That deleted exactly the hits a reworded task needs. In 2.15 a
179
+ candidate is admitted when at least two signals put it in their top k (default
180
+ 5): zvec-grep (code and card workspaces fused), the source-chunk vector, the
181
+ card vector, and the old term-overlap rule as one more vote. Every ranking has
182
+ a top k even for an unrelated task, so a vector vote also needs its cosine at
183
+ or above a floor (`chunkFloor` 0.80, `cardFloor` 0.75). zg prints no
184
+ similarity, so its vote is rank-only, and two rank-only votes never agree.
185
+ Abstention returns nothing only when no candidate passes the rule and keyword
186
+ evidence is below the floor. Card text alone never admits a file; card
187
+ evidence counts when another signal agrees. The floors are uncalibrated
188
+ defaults. Tune them in `.codebuddy/config.json` under `discovery.agreement`
189
+ against the unrelated-task files (the 6 in the Litestar harness plus
190
+ `evals/unrelated-2.15.json`).
191
+
192
+ **Confidence.** Discovery returns `high` (anchor, exact identifier, CLI
193
+ command, or ≥ 3 votes counting a strong keyword match as two), `medium` (two),
194
+ or `low` (dense signals present but no returned file has two). `low` returns no
195
+ paths: the hook emits nothing, and `context_pack` adds a note telling the agent
196
+ to search normally. Without any dense signal the result is 2.14's keyword path
197
+ and is never suppressed.
198
+
199
+ **Expansion.** When a task found nothing confident and names no identifier,
200
+ discovery asks the warm local model for 5–8 code terms (≤ 800 ms in
201
+ `context_pack`, ≤ 300 ms in the hook) and ranks once more. Answers are cached
202
+ per normalised task in `.codebuddy/cache/expansions.json` (LRU, 200). The hook
203
+ process never has a warm model, so it only benefits from cached expansions.
204
+
205
+ **Index facts** (`llm/index-facts.ts`) are Markdown facts with
206
+ `createdByAgent: codebuddy-index`, `paths: [source]`,
207
+ `verification: ["source:Lline"]` and an `index:` idempotency key.
208
+ Manifest and CI facts are read deterministically. Prose facts come from the
209
+ model and must share words with the cited line and read as a statement.
210
+ Sensitive candidates are dropped. Re-extraction replaces only index facts
211
+ whose source hash changed. The cap is 40 per repository, and near-duplicates
212
+ (Jaccard ≥ 0.8) of any existing fact are skipped.
213
+
116
214
  ## Sharing Model
117
215
 
118
216
  Shares are references by default.
package/README.md CHANGED
@@ -1,11 +1,18 @@
1
- # CodeBuddy
1
+ # CodeBuddy by Orquentra
2
2
 
3
3
  Local-first project context and memory for AI coding agents.
4
4
 
5
+ Published by Orquentra as
6
+ [`@orquentra/codebuddy` on npm](https://www.npmjs.com/package/@orquentra/codebuddy).
7
+
5
8
  CodeBuddy helps agents find relevant code, understand project constraints, and
6
9
  remember decisions across sessions. It works through MCP with Claude Code,
7
10
  Codex, OpenCode, Hermes, and other compatible clients.
8
11
 
12
+ [npm package](https://www.npmjs.com/package/@orquentra/codebuddy) ·
13
+ [Documentation](https://github.com/Orquentra-Inc/CodeBuddy/blob/main/docs/guide.md) ·
14
+ [Source and issues](https://github.com/Orquentra-Inc/CodeBuddy)
15
+
9
16
  ## Install
10
17
 
11
18
  Requires Node.js 20 or later.
@@ -16,9 +23,12 @@ cd your-project
16
23
  codebuddy
17
24
  ```
18
25
 
19
- The setup wizard configures the project and agent integration. Project context
20
- works without a database; semantic memory recall optionally uses PostgreSQL
21
- with pgvector and a local Hugging Face embedding model (no token needed).
26
+ That one command sets everything up: PostgreSQL (the bundled Docker database
27
+ if none is running), the local embedding model (~90 MB), zvec-grep (installed
28
+ and indexed), the local Qwen model (~400 MB; cloud Qwen with a key you enter on
29
+ machines under 4 GB RAM), agent wiring for Claude and Codex, and a background
30
+ pass that builds file vectors, intent cards and project facts. Skip pieces with
31
+ `--no-local-llm`, `--no-graphify` or `--no-docker`.
22
32
 
23
33
  Run setup inside the project you want CodeBuddy to read. Claude Desktop
24
34
  registration saves that folder's absolute path, so restarting the desktop app
@@ -28,13 +38,27 @@ Older desktop registrations without a project path can be repaired by running
28
38
  `codebuddy claude install` from the initialized project folder, then restarting
29
39
  Claude Desktop.
30
40
 
41
+ ### Verify the package
42
+
43
+ The npm package name is **`@orquentra/codebuddy`**; the installed command is
44
+ **`codebuddy`**. Open the [npm package page](https://www.npmjs.com/package/@orquentra/codebuddy)
45
+ directly to find its published versions, or query the public registry:
46
+
47
+ ```bash
48
+ npm view @orquentra/codebuddy version --registry=https://registry.npmjs.org/
49
+ ```
50
+
51
+ Search engine results and AI summaries may lag behind npm releases. If an
52
+ installation fails, include the exact npm error and requested version in a
53
+ [GitHub issue](https://github.com/Orquentra-Inc/CodeBuddy/issues).
54
+
31
55
  ## What it does
32
56
 
33
57
  - **Task context:** relevant files, symbols, code excerpts, nearby dependencies,
34
58
  and covering tests within a token budget.
35
59
  - **Project memory:** decisions, rules, and handoffs stored as readable Markdown,
36
60
  recalled for relevant tasks by hybrid lexical + vector search
37
- ([how it works](docs/semantic-memory.md)).
61
+ ([how it works](https://github.com/Orquentra-Inc/CodeBuddy/blob/main/docs/semantic-memory.md)).
38
62
  - **Continuity:** a local journal of each session's goal, edits, checks and
39
63
  findings, re-injected after compaction and offered to the next session when
40
64
  a task was left unfinished. Native bridges cover Claude Code, Codex, OpenCode
@@ -50,6 +74,63 @@ Claude Desktop.
50
74
  - **Optional retrieval:** zvec semantic search, Graphify architecture maps, and
51
75
  a bring-your-own LLM layer.
52
76
 
77
+ ## Optional local LLM (2.15)
78
+
79
+ A small local model can write a plain-English **intent card** for every source
80
+ file, so a task worded nothing like the code (for example "the browser forgets
81
+ how long to wait before reconnecting") still finds the right file. `codebuddy`
82
+ / `codebuddy` installs it as part of setup (Qwen3-0.6B Q4_K_M, ~400 MB,
83
+ checksum-verified; skip with `--no-local-llm` or `CODEBUDDY_LOCAL_LLM=0`), and it
84
+ runs offline after that. To manage it by hand:
85
+
86
+ ```bash
87
+ codebuddy models add local-llm # Qwen3-0.6B Q4_K_M, ~400 MB, checksum-verified
88
+ codebuddy models add local-llm --size better # Qwen3-1.7B, ~1.1 GB
89
+ codebuddy models remove local-llm # back to keyword + vector discovery
90
+ ```
91
+
92
+ Setup also installs the runtime (`node-llama-cpp`, prebuilt for macOS, Linux
93
+ and Windows; `models add` asks first). CodeBuddy uses Qwen only. On a machine
94
+ under 4 GB of RAM or with one CPU core, setup uses Qwen in the cloud instead
95
+ (`qwen/qwen3.8-27b` on Groq, free-tier key; or OpenRouter). It uses
96
+ `GROQ_API_KEY` / `OPENROUTER_API_KEY` from the environment, or asks for a Groq
97
+ key (free at console.groq.com/keys) and saves it in `~/.codebuddy/global.json`
98
+ (mode 0600, never in the project). Bounded, redacted file heads and
99
+ signatures are then sent to that provider ([details](docs/llm-byok.md)). Skip
100
+ the prompt and keyword + vector discovery keep working.
101
+ The model runs inside `codebuddy serve` (not in Docker; Docker only hosts
102
+ PostgreSQL). It is unloaded 60 s after its last card and freed when the agent
103
+ closes `serve`, so it never keeps running in the background.
104
+
105
+ Qwen3-0.6B is the smallest model that wrote usable cards in our checks:
106
+ SmolLM2-135M (105 MB) returned placeholders and raw code lines, and Gemma 3
107
+ 270M returned keyword lists instead of descriptions, so neither ships.
108
+ Nothing leaves your machine, and without the model every feature falls back to
109
+ the 2.14 behaviour.
110
+
111
+ - **Intent cards:** a summary, 3–6 "symptoms" in bug-report wording, the code
112
+ terms to search for, and a line per main symbol. Written in the background by
113
+ `codebuddy serve` (or `codebuddy index --cards`) for new and changed source
114
+ files only; tests, docs, generated, vendored and secret-bearing files are
115
+ skipped. Cards feed a second vector per file, a zvec-grep card workspace, and
116
+ (down-weighted) the keyword index. Progress: `codebuddy models`, `codebuddy
117
+ storage`.
118
+ - **Agreement rule:** a file the keywords missed is admitted when two
119
+ independent signals agree (zvec-grep, source-chunk vectors, card vectors,
120
+ term overlap). When no returned file has two, CodeBuddy says so instead of
121
+ guessing: `context_pack` returns `confidence: "low"` with a note to search
122
+ normally, and the prompt hook stays silent.
123
+ - **Index facts:** up to 40 project facts drawn from `package.json`,
124
+ `pyproject.toml`, CI workflows, README / CONTRIBUTING / AGENTS.md /
125
+ CLAUDE.md and deprecation or release policies, each with its source line.
126
+ They are ordinary Markdown facts; `codebuddy memory list --origin index`
127
+ shows them and `codebuddy memory prune --origin index` removes them. Facts a
128
+ person or agent wrote are never replaced.
129
+
130
+ `codebuddy` also builds the zvec-grep index and enables it when `zg` 0.2.x
131
+ is installed, and `codebuddy serve` keeps a `zg server` running so the prompt
132
+ hook gets vector candidates within its deadline.
133
+
53
134
  ## What it costs
54
135
 
55
136
  Context is not free: tool schemas, the rules block and the injected context are
@@ -98,7 +179,7 @@ needs more detail. Inspect missing or truncated evidence before editing.
98
179
 
99
180
  ## Documentation
100
181
 
101
- - [Full guide and examples](https://github.com/Orquentra-Inc/CodeBuddy/blob/348bb7c/README.md)
182
+ - [Full guide and examples](https://github.com/Orquentra-Inc/CodeBuddy/blob/main/docs/guide.md)
102
183
  - [Telemetry and the admin panel](https://github.com/Orquentra-Inc/CodeBuddy/blob/main/docs/telemetry.md)
103
184
  - [Token budgets](https://github.com/Orquentra-Inc/CodeBuddy/blob/main/docs/token-budgets.md)
104
185
  - [Optional LLM setup](https://github.com/Orquentra-Inc/CodeBuddy/blob/main/docs/llm-byok.md)