ai-code-map 0.1.0-alpha.2 → 0.1.0-alpha.3

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/api.md CHANGED
@@ -29,10 +29,58 @@ one-sided coherent corruption; a rescan is required.
29
29
  - compares indexed sources, compiler-consumed files, project/toolchain-scoped typed resolution probes, observed directory listings and symlinks, consumed TypeScript libraries, configuration, and producer compatibility with current project state
30
30
  - `loadCodeMap(options?) -> Promise<CodeMap>`
31
31
  - loads persisted map from resolved output directory
32
+ - `buildProjectMap(map) -> ProjectMapView`
33
+ - projects a validated `CodeMap` into all indexed files, symbols, other endpoints, and grouped relations; does not mutate the input or check freshness
34
+ - returns `{ project, counts, files, symbols, endpoints, relations }`; nodes carry output-local `ref` values and original stable IDs
35
+ - symbol `file` points to a file ref; symbol `range` retains source coordinates
36
+ - relation groups contain `{ from, type, classification, targets: [{ ref, count }] }`; counts preserve all occurrence records, including heuristic and derived relations
37
+ - excludes source text, signatures, facts, and individual origin/confidence records; use the original map for that evidence
38
+ - `formatProjectMap(view) -> string`
39
+ - deterministic complete text with short references, stable symbol IDs, source lines, evidence classifications, and occurrence counts; no pagination or row limit
40
+ - the CLI `map` command checks freshness and reuses the validated map before calling these functions; missing/stale/invalid artifacts return exit code 2
32
41
  - `computeManifestIntegrityHash(manifest) -> string`
33
42
  - computes the canonical code-point-ordered manifest integrity hash used by persistence and tests
43
+ - `buildSourceContext(map, query, { root, maxLines?, maxChars?, seeds? }) -> Promise<ContextResult>`
44
+ - selects lexical matches (exact IDs/names take precedence), then expands one direct graph hop using the bounded `read` navigation rules
45
+ - for partial queries, ranks callable candidates using missing query words in their current source bodies and expands the strongest ties; inspects at most the 50 lexical candidates, with per-term occurrence counts capped at three
46
+ - skips reference-only class neighbors and counts them as omitted navigation; an explicitly selected class still expands normally
47
+ - includes up to four exact/framework-derived incoming file-level calls/references outside test files; a file of at most 80 lines is included in full, otherwise the mapped site has eight context lines on either side, within the shared budgets
48
+ - after primary source and file references, includes up to four outgoing exact/framework-derived dependencies of direct outgoing neighbors: functions or variables with bodies of at most 80 lines, calls before references; does not recurse or expand incoming callers
49
+ - defaults: 3 matches (1..5), 800 source lines (1..2000), 32,000 source characters including separators (256..64000)
50
+ - verifies paths, hashes and ranges for source-ranking candidates, selected symbols and file references; coalesces overlapping/adjacent source intervals
51
+ - returns `{ query, matches, moreMatches, selected, snippets, omitted, fileReferences, tests, omittedNavigation, usedLines, usedChars, limits }`
52
+ - `snippets` contain `{ file, startLine, endLine, source }`; `omitted` lists unread source ranges and symbol/file IDs excluded by the shared budget; file IDs are navigation targets, so read their printed source ranges directly
53
+ - test call sites are bounded navigation hints; omitted-navigation counts sum entries excluded by each seed's navigation limits, the shared test-site limit, and the small-dependency size/count limits
54
+ - the API validates selected source files; the CLI `context` also checks full map freshness before calling it
55
+ - `formatSourceContext(result) -> string`
56
+ - renders numbered source windows once per contiguous range, with bounded selection/test/omission metadata; metadata is additional to the source budgets
57
+ - `readSymbolSource(map, id, { root, limit?, offset? }) -> Promise<ReadSourceResult>`
58
+ - requires an exact stable ID; reads current source with two context lines per side
59
+ - `root` is the project root; `limit` defaults to 80 (integer 1..200); `offset` defaults to zero within that window
60
+ - returns `{ id, file, symbolRange, startLine, endLine, source, truncated, nextOffset?, navigation? }`
61
+ - at offset zero, `navigation` contains `{ links, tests, omittedLinks, omittedTests }`; continuation pages omit it
62
+ - each link has `{ direction, type, id, file, startLine, endLine, classification }`; exact and framework-derived internal neighbors only, deduplicated by direction and ID
63
+ - `tests` contains exact incoming call sites `{ file, line }` in `*.test.*`, `*.spec.*`, or `__tests__/` paths; this is a navigation hint, not a coverage claim
64
+ - limits navigation to eight links, four test sites, and fewer than 4,000 compact JSON characters; omission counts refer to eligible unique neighbors/sites excluded by these limits
65
+ - verifies source path containment and indexed file hash; rejects symbolic files, stale source, invalid offsets, and pages over 12,000 characters
66
+ - does not validate all project dependencies; use `checkFreshness` before navigation
34
67
  - `showSymbol(map, selector) -> ShowResult`
35
68
  - selectors: exact ID, `kind:name`, `path#name`, exact name/path
69
+ - returns all matching symbols and full relation records; no display filtering
70
+ - `formatShowResult(result, options?) -> string`
71
+ - compact by default: up to five symbols and 12 relation groups in total, with omission counts
72
+ - options: `{ full?: boolean, limit?: number }`; `limit` is an integer 1..50
73
+ - `{ full: true }` preserves the previous verbose text view
74
+ - `findSymbols(map, query, options?) -> SymbolSearchResult`
75
+ - searches indexed names and paths; returns stable IDs and source ranges
76
+ - options: `{ limit?: number }`, default 10, integer 1..50; invalid limits throw `RangeError`
77
+ - empty/whitespace query throws; no matches returns an empty array
78
+ - returns `{ query, total, truncated, matches: [{ id, name, kind, file, range, unmatchedTerms? }] }`
79
+ - deterministic lexical ranking and bounded typo hints; does not resolve guessed names as exact symbols
80
+ - word matching normalizes common English plurals and favors name matches over path matches
81
+ - whitespace-separated queries with at least three distinct normalized words may return partial matches after full matches and typo hints; at least two words and half the query must match, including a word in the symbol name
82
+ - only partial matches include `unmatchedTerms`, listing normalized query words absent from that symbol's name and path; this is lexical overlap, not semantic equivalence
83
+ - qualified file selectors remain restricted to that file; partial matching does not broaden them
36
84
 
37
85
  ## Analyzer constructors
38
86
 
@@ -68,7 +116,8 @@ The package exports major record/contract types including:
68
116
  - `CodeMap`, `CodeMapConfig`, `ManifestRecord`, `ProjectRecord`
69
117
  - `FileRecord`, `SymbolRecord`, `RelationRecord`, `DiagnosticRecord`
70
118
  - `CompilerUnitRecord`, `ProducerRecord`, `SemanticInputRecord`, `ArtifactIntegrityRecord`
71
- - `ScanResult`, `FreshnessResult`, `ShowResult`
119
+ - `ScanResult`, `FreshnessResult`, `ShowResult`, `ShowFormatOptions`
120
+ - `SymbolSearchResult`, `SymbolSearchOptions`, `SymbolSearchMatch`
72
121
  - `ScanOptions`, `LoadCodeMapOptions`, `AnalysisContext`
73
122
 
74
123
  ## Example
package/docs/backlog.md CHANGED
@@ -35,7 +35,7 @@
35
35
  ## Explicitly not core
36
36
 
37
37
  - LLMs, embeddings, API keys, network calls, or telemetry in deterministic map generation.
38
- - Natural-language CLI commands or `context "task" --budget`.
38
+ - Model-interpreted natural-language tasks. The bounded `context` command uses lexical matches and stored graph edges only.
39
39
  - Web UI, cloud service, billing, authentication, or deployment in this package.
40
40
  - ts-morph, dependency-cruiser, or react-docgen as authoritative analyzers.
41
41
  - Next.js private internals or NestJS runtime reflection.
@@ -2,7 +2,7 @@
2
2
 
3
3
  ## In-scope alpha
4
4
 
5
- - CLI commands are limited to `init`, `scan`, `check`, `show`.
5
+ - CLI commands are `init`, `scan`, `check`, `show`, `find`, `read`, `map`, and `context`.
6
6
  - `scan` output is static analysis only; no code execution.
7
7
  - No remote service, account linking, or telemetry is part of the alpha.
8
8
  - Framework analyzers included by default are TypeScript/Node and React only.
@@ -31,6 +31,18 @@
31
31
  - No watch/incremental compiler mode. Current default maps are validated and reused, but stale scans rebuild compiler state from scratch.
32
32
  - No multi-process Program reuse between scans.
33
33
 
34
+ ## Dependencies and scan exclusions
35
+
36
+ - Default source discovery excludes `**/node_modules/**`. Dependency files are not indexed as
37
+ project files or symbols.
38
+ - Source exclusion does not prohibit compiler reads. TypeScript still needs dependency declarations
39
+ and package metadata to resolve imports and types; consumed inputs participate in freshness checks.
40
+ - Keep installed dependencies inside the selected project root. Replacing `node_modules` with a
41
+ symlink to another checkout can cause unresolved imports because the bounded compiler host does
42
+ not follow dependency paths outside that root.
43
+ - The repository's `node_modules/` Git ignore rule already covers nested dependency directories.
44
+ Git ignore rules do not remove the compiler's need for dependency type information.
45
+
34
46
  ## Non-goals for this baseline
35
47
 
36
48
  - No task-planner reasoning is provided by the map itself.
@@ -287,6 +287,22 @@ Compare at least:
287
287
 
288
288
  Use the same model, instructions, tool access, repository revision, and context ceiling. Randomize task order where practical and keep evaluators blind to the arm.
289
289
 
290
+ ### Pilot setup lessons (2026-11-01)
291
+
292
+ - Check CLI/model compatibility before collecting task results. Codex CLI `0.135.0` rejected
293
+ `gpt-6-astra`; the pilot used CLI `0.166.0` in a temporary directory without changing the global
294
+ installation. Preserve the selected model when repairing the runner.
295
+ - Use physical dependency copies inside each temporary project root, preserving internal package
296
+ symlinks. An external `node_modules` symlink increased unresolved-import diagnostics and invalidated
297
+ the initial setup. After replacing it, all six map companion artifacts matched the reference
298
+ byte for byte. Source discovery must still exclude dependency files.
299
+ - Fix tasks, scoring criteria, repeats, and a stopping budget before measured runs. Record failed
300
+ setup attempts separately; do not hide their overhead or mix them with valid A/B results. Keep
301
+ the original deadline when repairing the environment.
302
+ - Record actual input, cached-input, and output usage. Cached input is a subset of input, not an
303
+ additional token count. Report map construction separately when using prebuilt maps.
304
+ - Keep private source excerpts and raw agent logs out of public benchmark reports.
305
+
290
306
  ### Primary metrics
291
307
 
292
308
  - input and output tokens measured by the actual model/tokenizer;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ai-code-map",
3
- "version": "0.1.0-alpha.2",
3
+ "version": "0.1.0-alpha.3",
4
4
  "description": "Local, deterministic semantic code maps for AI coding agents",
5
5
  "type": "module",
6
6
  "sideEffects": false,
@@ -39,6 +39,8 @@
39
39
  "docs",
40
40
  "examples",
41
41
  "README.md",
42
+ "AGENTS.md",
43
+ "skills",
42
44
  "LICENSE",
43
45
  "CONTRIBUTING.md",
44
46
  "SECURITY.md",
@@ -74,6 +76,7 @@
74
76
  "schema:generate": "node --import tsx scripts/generate-schemas.ts",
75
77
  "schema:check": "node --import tsx scripts/generate-schemas.ts --check",
76
78
  "benchmark": "node --import tsx scripts/benchmark-parsers.ts",
77
- "benchmark:real-world": "node --import tsx scripts/benchmark-real-world.ts"
79
+ "benchmark:real-world": "node --import tsx scripts/benchmark-real-world.ts",
80
+ "benchmark:tokens": "node --import tsx scripts/benchmark-tokens.ts"
78
81
  }
79
82
  }
@@ -0,0 +1,39 @@
1
+ ---
2
+ name: ai-code-map
3
+ description: Use when tracing TypeScript or JavaScript behavior in a project indexed by ai-code-map, or when the user requests map-guided navigation.
4
+ ---
5
+
6
+ # Retrieve source through the map
7
+
8
+ Run from the source project root with its installed CLI. Do not install or upgrade
9
+ it just to navigate. Source establishes behavior; graph relations are navigation
10
+ hints, and missing edges do not prove absence.
11
+
12
+ For an unknown flow, start with `ai-code-map context 'action subject words'`.
13
+ Include the action as well as the subject, for example `notification mark read`.
14
+ This command checks freshness and returns matching
15
+ source plus direct neighbors, merging ranges under one shared budget. A separate
16
+ `check` or overview is unnecessary before it. Partial matches name unmatched words;
17
+ judge relevance from the returned source.
18
+
19
+ Use that packet to answer or identify a specific missing fact. Reuse its source.
20
+ Read a printed omitted range only if it matters. For one dependency outside the
21
+ packet, use `read '<stable-id>'` or its bounded source range. If its ID and source
22
+ location are unknown, use `find 'qualified symbol name'` first. Do not use another
23
+ `context` call merely to read a helper: it also expands callers and neighbors.
24
+ Batch independent
25
+ reads; combine needed ranges in the same file. Avoid traversing every neighbor or
26
+ splitting one useful file window into many tiny symbol reads.
27
+
28
+ Use targeted `rg` for file-level facts such as route registration, configuration
29
+ and test discovery, or for a failed/irrelevant lookup. Discover paths with
30
+ `rg --files -g 'pattern'` before reading them. Use
31
+ `show '<id>'` only for an unresolved relation question. Do not dump the complete
32
+ map for an ordinary source task. Stop when the requested claims have evidence.
33
+ In the answer, connect each requested entry point to its inputs, state changes,
34
+ error path and caller effects. Keep navigation-status commentary brief.
35
+
36
+ If `context` is unavailable, check freshness once, then use `find` and `read` or
37
+ bounded source ranges. If stale, scan only when writing generated artifacts is
38
+ allowed; otherwise use source search. Cite original file and line numbers.
39
+ Do not claim token savings without a measured comparison.