@fodx/codelens 1.0.0 → 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/docs/routing.md CHANGED
@@ -1,34 +1,39 @@
1
1
  # Agent Routing Instructions — CodeLens
2
2
 
3
3
  > Inject this block into your agent's system prompt / rules so it routes code
4
- > discovery through the codelens tools instead of raw grep/find/read.
4
+ > discovery through the codelens tools instead of bulk grep/find/read.
5
5
 
6
6
  ## When to use codelens tools
7
7
 
8
- **For codebase discovery, do NOT start with `grep`/`find`/`read`.** Use the
9
- codelens tools first:
8
+ Prefer the codelens tools for code **discovery** they keep the context window
9
+ lean and are branch-scoped. They are guidance, not an absolute mandate: use the
10
+ right tool for the job.
10
11
 
11
- 1. Call `cl_current` to confirm the index is ready for the current branch.
12
- - If `status` is `missing`, call `cl_refresh` to build the index.
13
- 2. Use `cl_search` to find relevant files/symbols by intent (2–4 specific terms).
14
- 3. Use `cl_related` to expand graph neighbors (tests, callers, imports).
15
- 4. Use `cl_expand` to read the exact current file content for a chosen target
16
- (it reads from disk — never stale).
17
- 5. Save working context with `cl_save` and reload it with `cl_load` across
18
- compaction / long sessions.
12
+ 0. Call `cl_current` to confirm the index is ready; if `status` is `missing`,
13
+ call `cl_refresh` to build it.
19
14
 
20
- ## When raw reads are still allowed
15
+ Prefer codelens when:
16
+ - you don't know the exact name/string (semantic or conceptual search via `cl_search`)
17
+ - you need relationships — importers, tests, callers (`cl_related`) — or a
18
+ per-file outline / repo map (`cl_map`)
19
+ - the repo is large or unfamiliar, or you'd otherwise grep + read many files
20
+ - branch-scoped correctness matters (results won't leak across branches)
21
21
 
22
- - Before **editing** a file: read the exact target file with your normal read
23
- tool (or `cl_expand`) so you have the current bytes.
24
- - When **verifying** exact code, logs, or user-supplied paths.
25
- - When `cl_search` explicitly cannot answer (e.g. the index is empty and the
26
- repo is not a git repo).
27
- - When the user explicitly asks for raw command output.
22
+ Then use `cl_expand` to read the exact current content of a chosen target (it
23
+ reads from disk — never stale), and `cl_save`/`cl_load` to persist working
24
+ context across compaction.
28
25
 
29
- Do **not** ban raw reads outright they are correct for editing and
30
- verification. The routing is about **discovery**: prefer indexed context over
31
- bulk file dumps to keep your context window lean.
26
+ ## When raw grep/find/read is fine (or better)
27
+
28
+ - you already know an exact string/symbol/path
29
+ - you're reading or **editing** a single known file (use `cl_expand` or a raw read)
30
+ - the repo is tiny or familiar
31
+ - you're **verifying** exact code, logs, or user-supplied paths
32
+ - the user explicitly asks for raw command output
33
+
34
+ The routing is about **discovery**, not a ban on raw reads. Don't force codelens
35
+ for a known exact lookup; don't fall back to bulk grep when you don't know what
36
+ you're looking for.
32
37
 
33
38
  ## Branch safety
34
39
 
@@ -51,6 +56,7 @@ recent edits may not yet be reflected — call `cl_refresh` or re-query.
51
56
  | `cl_refresh` | build/update the current branch index |
52
57
  | `cl_search` | hybrid ranked search → compact handles |
53
58
  | `cl_related` | graph neighbors (imports/tests/callers) |
59
+ | `cl_map` | per-file symbol outline (repo map) |
54
60
  | `cl_expand` | exact current file content by path/range |
55
61
  | `cl_save` / `cl_load` | persist + reload working context |
56
62
  | `cl_stats` | index counts |
package/docs/tools.md CHANGED
@@ -14,14 +14,21 @@ JSON-serialized text content.
14
14
  - **Use**: build/update the current branch index.
15
15
 
16
16
  ## cl_search
17
- - **Input**: `{ query: string, limit?: number=5, cursor?: string }`
18
- - **Returns**: `{ indexId, results:[{handle,path,startLine,endLine,score,snippet,why}], nextCursor, freshness, pendingFiles }`
17
+ - **Input**: `{ query: string, limit?: number=5, cursor?: string, contentType?: "code"|"prose", related?: boolean, snippet?: "none"|"headline"|"compact"|"full" }`
18
+ - **Returns**: `{ indexId, results:[{handle,path,startLine,endLine,score,snippet,why}], nextCursor, freshness, pendingFiles, related? }`
19
19
  - **Use**: intent-level code discovery.
20
+ - **`snippet` (preview verbosity)**: default is signature-first `headline` (richer `compact` for the top ~3 results), which keeps payloads small. `none` returns path+lines only (fetch with `cl_expand`); `compact`/`full` return larger code windows. Explicitly setting `snippet` applies that mode to all results.
21
+ - **`why` signals**: `fts|symbol|exact|graph|path|code` (exact = exact symbol-name match; path = query term in the file path). Ranking is deterministic with a stable tie-break.
20
22
 
21
23
  ## cl_related
22
24
  - **Input**: `{ path: string, types?: string[], depth?: number=2, direction?: "out"|"in"|"both" }`
23
25
  - **Returns**: `{ indexId, results:[{handle,path,edgeType,hops,confidence}] }`
24
- - **Edge types**: `imports|imported_by|tests|calls|references|defines|exports|belongs_to`
26
+ - **Edge types**: `imports|imported_by|tests|calls|references|defines|exports|belongs_to` (TS/JS populate `calls`/`references` and resolve dynamic `import()`).
27
+
28
+ ## cl_map
29
+ - **Input**: `{ path?: string, limit?: number=50, all?: boolean }`
30
+ - **Returns**: `{ indexId, files:[{path, symbols:[{name,kind,signature,startLine,endLine,exported}]}], fileCount, truncated }`
31
+ - **Use**: outline / repo-map for orientation — per-file symbol signatures from the index (no file re-read). Defaults to exported symbols; pass `all:true` for everything. File-capped (default 50, max 200) with a `truncated` flag.
25
32
 
26
33
  ## cl_expand
27
34
  - **Input**: `{ path?: string, handle?: string, startLine?: number, endLine?: number, budget?: number=4000 }`
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fodx/codelens",
3
- "version": "1.0.0",
3
+ "version": "1.2.0",
4
4
  "description": "Local, branch-aware code search & relation graph. SQLite FTS5 + tree-sitter symbols + source-graph edges, exposed as an MCP server and CLI. No chat LLM required.",
5
5
  "license": "MIT",
6
6
  "type": "module",