llmnav 0.5.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 (68) hide show
  1. package/CHANGELOG.md +113 -0
  2. package/LICENSE +21 -0
  3. package/README.md +294 -0
  4. package/ROADMAP.md +71 -0
  5. package/bin/llmnav.js +16 -0
  6. package/docs/agent-integration.md +114 -0
  7. package/docs/api.md +290 -0
  8. package/docs/architecture.md +286 -0
  9. package/docs/benchmarking.md +164 -0
  10. package/docs/ci.md +196 -0
  11. package/docs/cli.md +233 -0
  12. package/docs/configuration.md +117 -0
  13. package/docs/editor-integration.md +29 -0
  14. package/docs/faq.md +59 -0
  15. package/docs/graph.md +92 -0
  16. package/docs/language-examples.md +130 -0
  17. package/docs/migration.md +130 -0
  18. package/docs/performance-v0.2.md +42 -0
  19. package/docs/provider-neutral-integration.md +66 -0
  20. package/docs/publishing.md +86 -0
  21. package/docs/quickstart.md +139 -0
  22. package/docs/research.md +31 -0
  23. package/docs/spec.md +424 -0
  24. package/examples/provider-neutral-host.d.mts +17 -0
  25. package/examples/provider-neutral-host.mjs +40 -0
  26. package/package.json +79 -0
  27. package/schema/config.schema.json +296 -0
  28. package/src/agent-protocol.js +117 -0
  29. package/src/agent-tools.js +61 -0
  30. package/src/agents.js +127 -0
  31. package/src/boundaries.js +50 -0
  32. package/src/changes.js +168 -0
  33. package/src/cli.js +459 -0
  34. package/src/config.js +305 -0
  35. package/src/contracts.js +70 -0
  36. package/src/declaration.js +334 -0
  37. package/src/doctor.js +124 -0
  38. package/src/editor.js +107 -0
  39. package/src/evaluation.js +67 -0
  40. package/src/files.js +81 -0
  41. package/src/formatter.js +23 -0
  42. package/src/generator.js +528 -0
  43. package/src/graph-input.js +157 -0
  44. package/src/graph.js +403 -0
  45. package/src/incremental.js +262 -0
  46. package/src/index.d.ts +673 -0
  47. package/src/index.js +115 -0
  48. package/src/initializer.js +137 -0
  49. package/src/inverted-index.js +350 -0
  50. package/src/parser.js +449 -0
  51. package/src/project.js +65 -0
  52. package/src/prompt-bundle.js +108 -0
  53. package/src/registry.js +107 -0
  54. package/src/sarif.js +70 -0
  55. package/src/search-shards.js +75 -0
  56. package/src/search.js +636 -0
  57. package/src/spec.d.ts +27 -0
  58. package/src/spec.js +237 -0
  59. package/src/tokenizer.js +37 -0
  60. package/src/transaction.js +557 -0
  61. package/src/util.js +256 -0
  62. package/src/validator.js +635 -0
  63. package/templates/file-card.txt +8 -0
  64. package/templates/lexicon.json +7 -0
  65. package/templates/line-card.txt +9 -0
  66. package/templates/module-card.txt +9 -0
  67. package/templates/queries.jsonl +1 -0
  68. package/templates/symbol-card.txt +10 -0
package/CHANGELOG.md ADDED
@@ -0,0 +1,113 @@
1
+ # Changelog
2
+
3
+ All notable changes to this project are documented here.
4
+
5
+ The npm package follows Semantic Versioning. The `llmnav/N` source protocol is versioned independently.
6
+
7
+ ## [Unreleased]
8
+
9
+ ## [0.5.1] — 2026-08-09
10
+
11
+ ### Added
12
+
13
+ * Added canonical-source `generate --full` verification for CI, release, and doctor gates.
14
+ * Added repository-scoped generation locking, transaction owner checks, and atomic cache, registry, and stable-order recovery.
15
+ * Added reusable project navigation snapshots with explicit refresh for long-lived provider-neutral hosts.
16
+ * Added runtime-to-declaration export parity coverage.
17
+
18
+ ### Fixed
19
+
20
+ * Normalized foreign path separators, encoded SARIF artifact URIs, and blocked cache and staging path escapes.
21
+ * Corrected JavaScript import extraction and regex-body scanning, Python declaration body hashing, and Rust lifetime parsing.
22
+ * Invalidated pre-fix file-state accelerators so corrected declaration and import data is rebuilt from source.
23
+ * Preserved multi-target replacement ambiguity and detected cycles hidden in replacement branches.
24
+ * Synchronized public TypeScript declarations with runtime return values and graph-aware options.
25
+ * Normalized the npm executable path so current npm clients publish the `llmnav` binary without metadata correction.
26
+
27
+ ## [0.5.0] — 2026-08-09
28
+
29
+ ### Added
30
+
31
+ * Added stable provider-neutral agent tool schemas and a bounded operation dispatcher for query, show, context, and check.
32
+ * Added deterministic prompt-prefix bundles with explicit package, repository, and module cache partitions.
33
+ * Added deterministic zero-based editor diagnostics and a generated VS Code task integration.
34
+ * Added a runnable typed provider-neutral host example that binds repository authority outside tool input.
35
+
36
+ ## [0.4.0] — 2026-08-09
37
+
38
+ ### Added
39
+
40
+ * Added strict repository-local imports for generated definition and reference indexes with `LNV014` diagnostics.
41
+ * Added deterministic qualified repository graphs with source-card, local-import, and generated-index edge provenance and confidence.
42
+ * Added confidence-weighted graph ranking and context packing bounded by depth, token budget, and edge count.
43
+ * Added exact qualified and ambiguity-safe workspace semantic ID resolution with external definition rendering.
44
+ * Added content-addressed graph partitions with safe incremental invalidation and byte-equivalent full rebuilds.
45
+
46
+ ## [0.3.0] — 2026-08-09
47
+
48
+ ### Added
49
+
50
+ * Added deterministic exported API and effective configuration fingerprints with `LNV009` drift diagnostics.
51
+ * Added TypeScript and Go declaration enrichment, declaration-level body hashes, and generated route, event, schema, migration, and command boundaries.
52
+ * Added deterministic affected-boundary reports with modules, relations, and reverse semantic dependents.
53
+ * Added deterministic SARIF 2.1.0 diagnostic serialization and `llmnav check --format sarif`.
54
+ * Added opt-in deterministic card-range search shards with manifest hashes and transactional stale-shard removal.
55
+
56
+ ### Changed
57
+
58
+ * Replaced the remaining Korean documentation examples with English equivalents.
59
+
60
+ ### Removed
61
+
62
+ * Removed the Korean README so the project maintains one canonical English README.
63
+
64
+ ## [0.2.0] — 2026-08-09
65
+
66
+ ### Added
67
+
68
+ * Deterministic compact `search-index.json` containing a sorted token dictionary, normalized phrase documents, and ordinal posting lists with sparse field vectors.
69
+ * Card-level inverted-index updates keyed by deterministic search-document hashes.
70
+ * Deterministic `file-state.json` for file-level incremental parsing and card reuse.
71
+ * Volatile stat hints under `.llmnav/state/` to skip reading byte-identical files during no-op generation.
72
+ * Transactional cache generation through staged writes, manifest verification, directory replacement, rollback, and crash recovery.
73
+ * Automatic recovery before `query`, `generate`, and `doctor` read or replace generated cache data.
74
+ * Retry handling for Windows-style `EACCES`, `EBUSY`, `EEXIST`, `ENOTEMPTY`, and `EPERM` rename and removal failures.
75
+ * Machine-readable `changedCards`, `affectedCatalogs`, incremental metrics, and transaction state in `generate --json` output.
76
+ * Large synthetic fixture regression tests for ranking equality, query speed, index size, RSS, and heap use.
77
+ * Failure-injection tests before journaling, after moving the old cache, and after installing an uncommitted cache.
78
+ * Fresh-process query and regeneration benchmark harness with raw JSON and Markdown reports.
79
+ * npm tarball installation smoke test that initializes, generates, queries, validates, and diagnoses a clean project.
80
+ * Public ESM exports and TypeScript declarations for the v0.2 indexing and transaction APIs.
81
+
82
+ ### Changed
83
+
84
+ * `llmnav generate` now performs incremental scanning by default and commits cache changes transactionally.
85
+ * `llmnav query` uses the generated inverted index and no longer tokenizes every card for every query.
86
+ * `llmnav doctor` validates search-index compatibility, file-state compatibility, manifest hashes, and interrupted transactions.
87
+ * Generated artifacts use locale-independent key and path ordering.
88
+ * `.llmnav/.gitignore` now excludes volatile stat hints and transaction work directories.
89
+ * CI runs the complete suite on Linux and Windows with Node.js 22 and 24, and runs the packed-package smoke test on Node.js 22.
90
+
91
+ ### Compatibility
92
+
93
+ * The source grammar remains `llmnav/1`.
94
+ * `.llmnav/cache/index.json` remains schemaVersion 1 and retains its v0.1 fields.
95
+ * Existing v0.1 commands and default text output remain compatible.
96
+ * `search-index.json` and `file-state.json` are additive generated artifacts. A missing, malformed, corrupted, or incompatible search index is rebuilt in memory from `index.json`.
97
+
98
+ ## [0.1.0] — 2026-08-09
99
+
100
+ ### Added
101
+
102
+ * Initial `llmnav/1` source comment specification.
103
+ * Zero-runtime-dependency Node.js CLI.
104
+ * `init`, `check`, `format`, `generate`, `query`, `show`, `context`, `eval`, `doctor`, and `spec` commands.
105
+ * Stable semantic ID registry and append-only catalog ordering.
106
+ * Deterministic repository and module catalogs.
107
+ * Multilingual aliases and CJK n-gram retrieval.
108
+ * Search regression metrics and CI gates.
109
+ * Managed instructions for AGENTS.md, Claude Code, GitHub Copilot, and Cursor.
110
+ * JavaScript programmatic API and TypeScript declarations.
111
+ * Data-loss-resistant formatting that refuses malformed or unknown metadata.
112
+ * Strict configuration, registry-state, path-boundary, and CLI option validation.
113
+ * Redirect-aware bounded context and monorepo root discovery.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 제로디
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,294 @@
1
+ # LLMNav
2
+
3
+ LLMNav is a deterministic semantic navigation layer for LLM coding agents.
4
+
5
+ It adds compact, stable metadata to a small number of architectural and behavioral boundaries, compiles that metadata into repository catalogs and a persistent inverted index, and gives agents a fast path from task language to the code that matters.
6
+
7
+ LLMNav is not a documentation generator, an embedding database, or a reason to annotate every function. It is a zero-runtime-dependency Node.js CLI and ESM library for reducing broad repository scans, irrelevant context, stale hand-written links, repeated card tokenization, and avoidable cache invalidation.
8
+
9
+ ## What v0.5 provides
10
+
11
+ * The backward-compatible `llmnav/1` source comment specification
12
+ * A parser and data-loss-resistant canonical formatter
13
+ * Semantic lint rules with stable diagnostic codes
14
+ * A schemaVersion 1 `index.json` compatible with v0.1 consumers
15
+ * A deterministic persistent inverted index that reuses unchanged card tokenization
16
+ * File and card-level incremental indexing
17
+ * Repository-locked transactional cache generation with rollback and interrupted-run recovery
18
+ * Machine-readable changed-card, affected-boundary, and affected-catalog output
19
+ * Exported API and effective configuration contract fingerprints
20
+ * TypeScript and Go declaration enrichment with declaration-level body hashes
21
+ * Generated route, event, schema, migration, and command boundaries
22
+ * SARIF 2.1.0 diagnostic output
23
+ * Optional deterministic card-range search shards for very large repositories
24
+ * Strict repository-local imports for generated definition and reference indexes
25
+ * Deterministic qualified repository graphs with edge provenance and confidence
26
+ * Confidence-aware graph ranking and context packing bounded by depth, tokens, and edges
27
+ * Exact qualified and ambiguity-safe workspace semantic ID resolution
28
+ * Content-addressed incremental graph partitions with safe invalidation
29
+ * A runnable provider-neutral host adapter with a reusable project snapshot and typed package export
30
+ * Repository and module catalogs designed for prompt-prefix reuse
31
+ * Multilingual alias routing and CJK n-gram retrieval
32
+ * Search regression tests with Recall@1, Recall@5, and MRR
33
+ * Managed instructions for AGENTS.md, Claude Code, GitHub Copilot, and Cursor
34
+ * Linux and Windows CI gates plus npm pack installation smoke tests
35
+
36
+ The package supports Node.js 22 or newer, uses ESM, performs no network requests, and has no runtime dependencies.
37
+
38
+ ## Install
39
+
40
+ ```sh
41
+ npm install --save-dev llmnav
42
+ npx llmnav init --agents all --package-scripts
43
+ ```
44
+
45
+ Initialization is explicit. LLMNav never edits a consumer repository from an npm `postinstall` script. Use `--agents none` when only the machine-readable control directory is desired.
46
+
47
+ ## Add the first card
48
+
49
+ ```ts
50
+ /* llmnav/1 symbol
51
+ id=auth.session.rotate
52
+ role=Rotate one refresh-token family atomically and reject replayed tokens.
53
+ search=refresh token|token rotation|token family|replay detection
54
+ invariant=At most one live refresh token exists per family.
55
+ invariant=Replay revokes the entire token family.
56
+ effect=db.write(session_tokens)|event.emit(auth.session.revoked)
57
+ risk=auth|concurrency
58
+ rel=policy>auth.session.lifecycle
59
+ rel=test>auth.session.rotate.contract
60
+ stability=contract
61
+ */
62
+
63
+ export async function rotateSession(
64
+ input: RotateSessionInput,
65
+ ): Promise<RotateSessionResult> {
66
+ // implementation
67
+ }
68
+ ```
69
+
70
+ The ID describes a durable capability, not a file path or current function name. It survives moves and renames.
71
+
72
+ ## Generate and search
73
+
74
+ ```sh
75
+ npx llmnav format
76
+ npx llmnav check
77
+ npx llmnav generate
78
+ npx llmnav query "replayed refresh token should revoke the family" --top 5
79
+ npx llmnav show auth.session.rotate
80
+ npx llmnav context auth.session.rotate --depth 1 --budget 2500
81
+ ```
82
+
83
+ The generated inverted index stores a deterministic token dictionary, compact posting lists, and normalized phrase documents. A query tokenizes only the task text; it does not tokenize every card again. If `search-index.json` is missing or incompatible, the library rebuilds it in memory from the compatible schemaVersion 1 `index.json`.
84
+
85
+ ## Incremental and transactional generation
86
+
87
+ The first generation parses every source file and indexes every card. Later runs compare persisted file state and volatile stat hints.
88
+
89
+ ```text
90
+ unchanged stat fingerprint → reuse parsed file without reading it
91
+ changed stat, same SHA-256 → reuse parsed file after one content read
92
+ changed content → parse that file and retokenize changed cards only
93
+ deleted file → remove its cards and postings
94
+ ```
95
+
96
+ All generated cache artifacts are completed and verified in a staging directory before the live cache is replaced. Registry additions and stable-order updates participate in the same recoverable transaction, so rollback cannot leave control state ahead of the cache. If writing, verification, rename, or the process itself fails, the previous generation state remains available or is restored before the next query or generation.
97
+
98
+ One repository-scoped generation lock serializes the complete source-to-cache operation. Readers wait for an active writer and recover only abandoned journals, so they cannot roll back a live generation. Windows transient rename failures such as `EPERM`, `EBUSY`, `EACCES`, `EEXIST`, and `ENOTEMPTY` are retried. CI executes the transaction and interruption suite on `windows-latest` as well as Linux.
99
+
100
+ ## Machine-readable change output
101
+
102
+ ```sh
103
+ npx llmnav generate --json
104
+ ```
105
+
106
+ The JSON response preserves the v0.1 fields and adds stable records for changed cards, affected boundaries, affected catalogs, file reuse, card retokenization, and transaction recovery.
107
+
108
+ ```json
109
+ {
110
+ "changedCards": [
111
+ {
112
+ "id": "auth.session.rotate",
113
+ "change": "modified",
114
+ "dimensions": ["semantic"]
115
+ }
116
+ ],
117
+ "affectedBoundaries": [
118
+ {
119
+ "id": "auth.session.rotate",
120
+ "modules": ["auth.session"],
121
+ "boundaries": [{ "kind": "route", "confidence": "high", "evidence": ["path"] }]
122
+ }
123
+ ],
124
+ "affectedCatalogs": [
125
+ {
126
+ "file": ".llmnav/cache/modules/auth.session.txt",
127
+ "kind": "module",
128
+ "id": "auth.session"
129
+ }
130
+ ]
131
+ }
132
+ ```
133
+
134
+ Locations and hashes are included in the complete records. Array ordering and generated JSON key ordering are deterministic.
135
+
136
+ ## The core separation
137
+
138
+ | Layer | Examples | Owner | Storage |
139
+ | --- | --- | --- | --- |
140
+ | Stable meaning | role, invariant, domain search phrases, effects, risks, semantic relations | human or coding agent | source comment |
141
+ | Generated structure | path, declaration, language, visibility, boundaries, imports, fingerprints, hashes | LLMNav | generated cache |
142
+ | Task state | branch, diff, test output, current request | agent harness | never stored in a card |
143
+
144
+ Paths, line numbers, commit hashes, callers, imports, and signatures are forbidden in source cards. They change too often and are more accurately generated.
145
+
146
+ ## Comment styles
147
+
148
+ C-style block comments work in TypeScript, JavaScript, Go, Rust, Java, C, C++, C#, Swift, Dart, PHP, Svelte, Astro, and Vue files.
149
+
150
+ ```go
151
+ /* llmnav/1 module
152
+ id=auth.session
153
+ role=Own refresh-token issuance, rotation, replay detection, and revocation.
154
+ owns=refresh-token family|session revocation
155
+ excludes=access-token signing|user profile storage
156
+ search=session lifecycle|token family|session revocation
157
+ invariant=One token family has at most one live refresh token.
158
+ stability=architecture
159
+ */
160
+ ```
161
+
162
+ Line-comment cards require an explicit terminator and work with `//`, `#`, and `--`. HTML comments are supported for markup-oriented files.
163
+
164
+ ## Commands
165
+
166
+ | Command | Purpose |
167
+ | --- | --- |
168
+ | `llmnav init` | Create configuration, registry, schemas, agent instructions, and the initial cache |
169
+ | `llmnav check` | Validate cards, relations, coverage rules, and registry state |
170
+ | `llmnav format` | Rewrite safe cards into canonical order and spacing |
171
+ | `llmnav generate` | Incrementally compile and transactionally commit generated artifacts |
172
+ | `llmnav index` | Alias for `generate` |
173
+ | `llmnav query` | Rank cards through the persistent inverted index |
174
+ | `llmnav show` | Resolve one active or redirected semantic ID |
175
+ | `llmnav context` | Build a bounded context bundle around one ID |
176
+ | `llmnav eval` | Run repository-specific search regression queries |
177
+ | `llmnav doctor` | Verify installation, cache integrity, transaction recovery, and drift |
178
+ | `llmnav spec` | Print source-spec vocabularies and key order |
179
+ | `llmnav tools` | Print stable provider-neutral agent tool schemas |
180
+ | `llmnav bundle` | Inspect the generated prompt-prefix cache partitions |
181
+ | `llmnav editor` | Print a deterministic editor task integration |
182
+
183
+ See [docs/cli.md](docs/cli.md) for every option and exit code.
184
+
185
+ ## Generated layout
186
+
187
+ ```text
188
+ .llmnav/
189
+ AGENT_INSTRUCTIONS.md
190
+ config.json
191
+ ids.jsonl
192
+ lexicon.json
193
+ order.lock
194
+ schema/
195
+ config.schema.json
196
+ eval/
197
+ queries.jsonl
198
+ state/ # volatile, ignored
199
+ stat-hints.json
200
+ cache/ # deterministic, commit this
201
+ index.json # v0.1-compatible schemaVersion 1
202
+ cards.jsonl
203
+ search-index.json # compact token dictionary, phrases, and postings
204
+ file-state.json # deterministic parsed-file state
205
+ graph.json # qualified nodes and provenance-aware edges
206
+ graph-state.json # disposable content-addressed graph partitions
207
+ prompt-prefix.json # explicit package, repository, and module cache partitions
208
+ repo-core.txt
209
+ agent-context.md
210
+ manifest.json
211
+ modules/
212
+ auth.session.txt
213
+ billing.credit.txt
214
+ ```
215
+
216
+ `.llmnav/.transactions/`, `.llmnav/generation-transaction.json`, and `.llmnav/generation.lock` may exist only while a cache transaction is active or incomplete. They are ignored; abandoned state is recovered automatically after lock ownership is checked. Generated structure is never written back into source comments.
217
+
218
+ `order.lock` is append-only under normal development. New IDs are appended rather than inserted into a globally re-sorted catalog, preserving larger prompt prefixes as the repository grows.
219
+
220
+ ## Multilingual task language
221
+
222
+ Keep source cards in one repository language. Map product wording, local language, abbreviations, and retired names in `.llmnav/lexicon.json`.
223
+
224
+ ```json
225
+ {
226
+ "version": 1,
227
+ "aliases": {
228
+ "session renewal": "auth.session.rotate",
229
+ "token replay attack": "auth.session.rotate",
230
+ "credit reservation": "billing.credit.reserve"
231
+ }
232
+ }
233
+ ```
234
+
235
+ ## Search regression gates
236
+
237
+ Add real task descriptions to `.llmnav/eval/queries.jsonl` and run `npx llmnav eval`. The default gates are Recall@1 at 0.75 and Recall@5 at 0.90. Large synthetic accuracy, speed, and memory regression tests are also part of this repository's test suite.
238
+
239
+ The measured v0.2 benchmark report is in [docs/performance-v0.2.md](docs/performance-v0.2.md). It records the exact fixture, environment, fresh-process query timing, incremental and forced-full regeneration timing, memory, and byte-equivalence checks. The report does not present estimates as measurements.
240
+
241
+ ## Recommended adoption boundary
242
+
243
+ Annotate architectural modules, public entry points, authentication and payment boundaries, privacy boundaries, migrations, orchestration code with multiple external effects, high fan-in symbols, and code with non-obvious invariants.
244
+
245
+ Do not annotate trivial getters, generated files, obvious wrappers, every test function, or every private helper. LLMNav becomes worse when keyword-heavy comments cover the whole repository.
246
+
247
+ ## Current implementation boundary
248
+
249
+ Version 0.5 adds stable provider-neutral agent tools, trusted-root operation dispatch, explicit prompt-prefix cache partitions, deterministic editor diagnostics, a VS Code task integration, and a runnable typed host example to the repository graph and incremental navigation layers.
250
+
251
+ LLMNav does not discover sibling repositories automatically and does not ship an MCP server, embedding database, hosted service, SCIP generator, or complete language-aware call graph. External tools may export the documented compact graph-input schema. Generated structure never writes derived edges into source cards.
252
+
253
+ ## Documentation
254
+
255
+ * [Quick start](docs/quickstart.md)
256
+ * [Normative `llmnav/1` specification](docs/spec.md)
257
+ * [CLI reference](docs/cli.md)
258
+ * [Configuration reference](docs/configuration.md)
259
+ * [Programmatic API](docs/api.md)
260
+ * [Architecture and cache design](docs/architecture.md)
261
+ * [Repository graph](docs/graph.md)
262
+ * [Agent integration](docs/agent-integration.md)
263
+ * [Editor integration](docs/editor-integration.md)
264
+ * [Provider-neutral host integration](docs/provider-neutral-integration.md)
265
+ * [CI and enforcement](docs/ci.md)
266
+ * [Gradual migration](docs/migration.md)
267
+ * [Language examples](docs/language-examples.md)
268
+ * [Benchmarking methodology](docs/benchmarking.md)
269
+ * [Measured v0.2 performance](docs/performance-v0.2.md)
270
+ * [Research basis](docs/research.md)
271
+ * [Publishing checklist](docs/publishing.md)
272
+ * [FAQ](docs/faq.md)
273
+
274
+ ## Development
275
+
276
+ ```sh
277
+ npm ci
278
+ npm test
279
+ npm run test:coverage
280
+ npm run lint
281
+ npm run check
282
+ npm run smoke:pack
283
+ npm run benchmark:v0.2
284
+ ```
285
+
286
+ The project uses the Node.js standard library and built-in test runner. There is no build step and no production dependency tree to audit.
287
+
288
+ ## Status
289
+
290
+ LLMNav is an experimental protocol and a usable v0.5 CLI. The source format remains `llmnav/1`; npm package changes and source-grammar changes are versioned independently.
291
+
292
+ ## License
293
+
294
+ MIT
package/ROADMAP.md ADDED
@@ -0,0 +1,71 @@
1
+ # Roadmap
2
+
3
+ ## 0.1 — semantic foundation
4
+
5
+ Implemented:
6
+
7
+ * `llmnav/1` parser and formatter
8
+ * semantic validation and stable diagnostics
9
+ * persistent ID registry and append-only catalog order
10
+ * deterministic JSON, JSONL, repository, and module catalogs
11
+ * local multilingual lexical retrieval
12
+ * bounded semantic relation context
13
+ * search regression evaluation
14
+ * agent instruction adapters
15
+ * zero-runtime-dependency npm CLI
16
+
17
+ ## 0.2 — deterministic incremental core
18
+
19
+ Implemented:
20
+
21
+ * persistent deterministic inverted index
22
+ * no per-query card retokenization
23
+ * file-level parsed-state reuse
24
+ * card-level posting-list updates
25
+ * transactionally staged cache generation
26
+ * rollback and interrupted-process recovery
27
+ * Windows transient rename and removal retries plus a mandatory Windows CI matrix
28
+ * changed-card and affected-catalog JSON output
29
+ * large fixture accuracy, speed, and memory regression gates
30
+ * fresh-process query and regeneration benchmark reports
31
+ * npm pack installation smoke test
32
+ * v0.1 index-schema and `llmnav/1` source compatibility
33
+
34
+ ## 0.3 — stronger local structure
35
+
36
+ Implemented:
37
+
38
+ * exported API and configuration contract fingerprints
39
+ * route, event, schema, migration, and command-boundary detection
40
+ * language-aware TypeScript and Go declaration enrichers
41
+ * selective body hashes at declaration granularity
42
+ * richer affected-boundary reports
43
+ * SARIF diagnostic output
44
+ * sharded generated search artifacts for very large monorepos
45
+
46
+ ## 0.4 — repository graphs
47
+
48
+ Implemented:
49
+
50
+ * optional import of generated definition and reference indexes
51
+ * edge provenance and confidence
52
+ * graph-aware ranking and bounded context packing
53
+ * workspace and cross-repository semantic ID resolution
54
+ * incremental graph invalidation
55
+
56
+ ## 0.5 — agent protocol integrations
57
+
58
+ Implemented:
59
+
60
+ * stable tool-schema adapters over existing query, show, context, and check operations
61
+ * prompt-prefix bundle generation with explicit cache partitions
62
+ * editor integrations and diagnostics
63
+ * provider-neutral integration examples
64
+
65
+ ## 1.0 criteria
66
+
67
+ The source grammar and generated formats will be declared stable only after use across multiple TypeScript, Go, Rust, Python, and mixed-language repositories. A 1.0 release requires migration tooling, documented compatibility guarantees, benchmark fixtures with published methodology, sustained Windows and Linux verification, and no unresolved high-severity parser or transaction ambiguity.
68
+
69
+ ## Non-goals
70
+
71
+ LLMNav will not become a general documentation generator, a source-of-truth call graph maintained by comments, an autonomous code modification service, a hosted source-ingestion platform, or a mandatory embedding database.
package/bin/llmnav.js ADDED
@@ -0,0 +1,16 @@
1
+ #!/usr/bin/env node
2
+
3
+ import { runCli } from "../src/cli.js";
4
+
5
+ try {
6
+ const exitCode = await runCli(process.argv.slice(2));
7
+ process.exitCode = exitCode;
8
+ } catch (error) {
9
+ const message = error instanceof Error
10
+ ? process.env.LLMNAV_DEBUG
11
+ ? error.stack ?? error.message
12
+ : error.message
13
+ : String(error);
14
+ console.error(`llmnav: ${message}`);
15
+ process.exitCode = Number.isInteger(error?.exitCode) ? error.exitCode : 1;
16
+ }
@@ -0,0 +1,114 @@
1
+ # Agent integration
2
+
3
+ ## Explicit initialization
4
+
5
+ Installing an npm package must not unexpectedly edit the host repository. LLMNav therefore performs no `postinstall` mutation.
6
+
7
+ Run the integration step explicitly:
8
+
9
+ ```sh
10
+ npx llmnav init --agents all
11
+ ```
12
+
13
+ The command writes one managed navigation protocol to the selected instruction files and always writes the canonical copy at `.llmnav/AGENT_INSTRUCTIONS.md`.
14
+
15
+ ## Supported adapters
16
+
17
+ | Adapter | File |
18
+ | --- | --- |
19
+ | `agents` | `AGENTS.md` |
20
+ | `claude` | `CLAUDE.md` |
21
+ | `copilot` | `.github/copilot-instructions.md` |
22
+ | `cursor` | `.cursor/rules/llmnav.mdc` |
23
+
24
+ The adapters contain the same operational rules so agents do not develop vendor-specific navigation behavior.
25
+
26
+ Each Markdown adapter uses managed markers:
27
+
28
+ ```md
29
+ <!-- llmnav:start -->
30
+ ...
31
+ <!-- llmnav:end -->
32
+ ```
33
+
34
+ Re-running initialization replaces the managed block and preserves unrelated repository instructions.
35
+
36
+ ## Protocol installed for agents
37
+
38
+ The generated instruction tells an agent to:
39
+
40
+ 1. Run `npm exec -- llmnav query "<task>" --top 5` before broad grep or directory scans.
41
+ 2. Resolve a selected card with `npm exec -- llmnav show <id>`.
42
+ 3. Use `npm exec -- llmnav context <id>` only when related semantic context is necessary.
43
+ 4. Treat generated paths and signatures as volatile.
44
+ 5. Keep IDs stable across moves and renames.
45
+ 6. Update semantic fields only when meaning changes.
46
+ 7. Never hand-maintain call, import, reference, implementation, export, or override relations.
47
+ 8. Run format, check, and generation after semantic changes.
48
+ 9. Fall back to broad search when no credible card is returned.
49
+
50
+ When a host supports structured tool calls, `llmnav tools --json` returns four stable provider-neutral definitions in fixed order: `llmnav_query`, `llmnav_show`, `llmnav_context`, and `llmnav_check`. The schemas reject unknown fields and omit the repository root so the trusted host binds scope outside model-generated input.
51
+
52
+ The protocol does not order an agent to trust a card over source code. It uses the card to choose what source to inspect.
53
+
54
+ ## Package runners
55
+
56
+ Generated instructions use `npm exec -- llmnav` so a local dev dependency works without a global installation. Equivalent package-manager runners include:
57
+
58
+ ```sh
59
+ npx llmnav query "task"
60
+ npm exec -- llmnav query "task"
61
+ pnpm exec llmnav query "task"
62
+ bunx llmnav query "task"
63
+ ```
64
+
65
+ A project may replace command examples in its surrounding instructions, but re-running initialization restores the managed npm runner. The package has no install hook and `npm exec` resolves the already installed local binary.
66
+
67
+ ## Prompt-cache placement
68
+
69
+ An agent harness that controls model input should use this order:
70
+
71
+ ```text
72
+ stable tool definitions
73
+ stable agent protocol
74
+ .llmnav/cache/repo-core.txt
75
+ cache breakpoint
76
+ selected .llmnav/cache/modules/<module>.txt
77
+ cache breakpoint
78
+ user task
79
+ branch and diff state
80
+ query results
81
+ selected source bodies
82
+ test and tool output
83
+ ```
84
+
85
+ The first two layers change rarely. The task and source bodies change frequently and belong after cache breakpoints.
86
+
87
+ Generation writes this ordering and the exact content into `.llmnav/cache/prompt-prefix.json`. Each partition records package, repository, or module cache scope, a content hash, an estimated token count, and an explicit boundary-after hint. `llmnav bundle` verifies the artifact against `manifest.json` before displaying it.
88
+
89
+ The host selects only the modules relevant to the current task, preserves the declared base order, and appends volatile task, diff, source, and tool-result context after the selected partitions. LLMNav deliberately leaves provider-specific cache-control syntax to the host.
90
+
91
+ ## Tool wrappers
92
+
93
+ LLMNav v0.5 does not ship an MCP server. A wrapper can pass `getAgentToolDefinitions()` to its provider SDK and route calls through `executeAgentOperation(root, name, input)`.
94
+
95
+ Suggested contract:
96
+
97
+ ```json
98
+ {
99
+ "schemaVersion": 1,
100
+ "operations": ["llmnav_query", "llmnav_show", "llmnav_context", "llmnav_check"]
101
+ }
102
+ ```
103
+
104
+ Every execution returns the same schemaVersion 1 envelope with `operation`, `ok`, `data`, and `error`. Expected validation and not-found failures use stable `LNVAP` codes. Keep the definition and operation order stable across sessions so provider prompt caches can reuse the tool prefix.
105
+
106
+ See [Provider-neutral host integration](provider-neutral-integration.md) for the packaged typed adapter and complete host-boundary examples.
107
+
108
+ ## Failure behavior
109
+
110
+ An agent should not stop when a repository is partially annotated.
111
+
112
+ When `query` returns no credible result, the correct fallback is normal symbol search, grep, or language-server navigation. After completing the task, the agent may propose a new card only when the missed boundary satisfies the repository's annotation policy.
113
+
114
+ Search failure alone is not permission to annotate every function sharing a keyword.