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/AGENTS.md +26 -0
- package/CHANGELOG.md +22 -0
- package/README.md +141 -8
- package/dist/cli.js +806 -21
- package/dist/cli.js.map +1 -1
- package/dist/index.d.ts +173 -12
- package/dist/index.js +927 -263
- package/dist/index.js.map +1 -1
- package/docs/api.md +50 -1
- package/docs/backlog.md +1 -1
- package/docs/limitations.md +13 -1
- package/docs/post-alpha-roadmap.md +16 -0
- package/package.json +5 -2
- package/skills/ai-code-map/SKILL.md +39 -0
package/AGENTS.md
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
# Agent instructions
|
|
2
|
+
|
|
3
|
+
## Code navigation
|
|
4
|
+
|
|
5
|
+
- Use `ai-code-map` to locate relevant symbols when their source location is unknown.
|
|
6
|
+
- Run commands from the project root.
|
|
7
|
+
- Before using the map, run `pnpm exec ai-code-map check`.
|
|
8
|
+
- If the map is missing or stale (exit code 2), run
|
|
9
|
+
`pnpm exec ai-code-map scan`.
|
|
10
|
+
- Read the beginning of `.ai/code-map/overview.md` only when broader project
|
|
11
|
+
structure is needed. Skip it for a focused task with a known area of the code.
|
|
12
|
+
- Find symbols with `pnpm exec ai-code-map find 'search words'`.
|
|
13
|
+
- After `find` identifies a relevant symbol, use `pnpm exec ai-code-map read '<stable-id>'`.
|
|
14
|
+
This reads current source through the map, with two context lines and at most
|
|
15
|
+
80 source lines per call. Follow the printed continuation only if needed.
|
|
16
|
+
- Reuse IDs and source already returned. Do not repeat `find` for a known symbol
|
|
17
|
+
or read its entire file just to see that symbol. Expand to a specific dependency
|
|
18
|
+
only when an unresolved question requires it.
|
|
19
|
+
- Use `pnpm exec ai-code-map show '<stable-id>'` only to answer an unresolved
|
|
20
|
+
question about symbol relations. Use an ID returned by `find`; do not call
|
|
21
|
+
`show` merely to redisplay a symbol whose source location is already known.
|
|
22
|
+
- Do not load entire `manifest.json`, `symbols.jsonl`, or `relations.jsonl`
|
|
23
|
+
files into context. Select only the records relevant to the task.
|
|
24
|
+
- Source code is the source of truth. Check it before making changes.
|
|
25
|
+
- If the map does not help or a command fails, use regular search with `rg`.
|
|
26
|
+
- The map is optional for a simple edit in a known file.
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,27 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## Unreleased
|
|
4
|
+
|
|
5
|
+
## 2026-11-01
|
|
6
|
+
|
|
7
|
+
### 0.1.0-alpha.3
|
|
8
|
+
|
|
9
|
+
- Add bounded `context` / `buildSourceContext` packets with current source, direct symbol links, file-level references, and up to four small outgoing dependencies.
|
|
10
|
+
- Add a reproducible token benchmark with fixed budgets, raw usage accounting, and manual paired quality review; accept recursive map exclusions in search commands.
|
|
11
|
+
- Token savings remain experimental: the latest 12-attempt, three-project comparison saved 0.9% overall and failed two paired quality comparisons. This release does not claim savings above 10% or quality non-degradation.
|
|
12
|
+
|
|
13
|
+
- Add `map` to check freshness and return the complete structural graph in one call, with short references and grouped relation counts.
|
|
14
|
+
|
|
15
|
+
- Include bounded direct symbol links and test call sites on the first `read` page, with reusable IDs and omission counts.
|
|
16
|
+
|
|
17
|
+
- Add map-guided `read` / `readSymbolSource` with bounded source pages, freshness checks, and continuation; update and package agent navigation instructions and a reusable Codex skill.
|
|
18
|
+
|
|
19
|
+
- Improve multiword symbol search with common plural normalization, name-aware ranking, and explicitly labeled partial matches.
|
|
20
|
+
|
|
21
|
+
- Add compact text `show` with full source ranges, grouped relations, and explicit omission counts.
|
|
22
|
+
- Preserve verbose output through `show --full` and complete records through `show --json`.
|
|
23
|
+
- Add `find` / `findSymbols` for bounded symbol discovery and typo suggestions on failed `show` selectors.
|
|
24
|
+
|
|
3
25
|
## 2026-11-01
|
|
4
26
|
|
|
5
27
|
### 0.1.0-alpha.2
|
package/README.md
CHANGED
|
@@ -9,7 +9,7 @@ AI Code Map is a local, deterministic code understanding layer for TypeScript, J
|
|
|
9
9
|
- **Compiler-authoritative**: TypeScript compiler is the trusted semantic layer for symbols, references, imports, and types.
|
|
10
10
|
- **Evidence-backed facts**: relations carry a source range, analyzer, classification, and confidence; source code remains authoritative.
|
|
11
11
|
- **No network/telemetry by default**: no outbound upload is part of a standard scan.
|
|
12
|
-
- **Small CLI**: `init`, `scan`, `check`, `show`.
|
|
12
|
+
- **Small CLI**: `init`, `scan`, `check`, `find`, `show`.
|
|
13
13
|
|
|
14
14
|
## Quick start
|
|
15
15
|
|
|
@@ -18,17 +18,20 @@ pnpm install
|
|
|
18
18
|
pnpm exec ai-code-map init
|
|
19
19
|
pnpm exec ai-code-map scan
|
|
20
20
|
pnpm exec ai-code-map check
|
|
21
|
+
pnpm exec ai-code-map find "calculator"
|
|
21
22
|
pnpm exec ai-code-map show Calculator
|
|
22
23
|
```
|
|
23
24
|
|
|
24
25
|
### Exit codes
|
|
25
26
|
|
|
26
|
-
| Command | Success
|
|
27
|
-
| ------- |
|
|
28
|
-
| `init` | `0`
|
|
29
|
-
| `scan` | `0`
|
|
30
|
-
| `check` | `0` when current
|
|
31
|
-
| `
|
|
27
|
+
| Command | Success | Failure behavior |
|
|
28
|
+
| ------- | ------------------------- | ---------------------------------------------------------- |
|
|
29
|
+
| `init` | `0` | invalid configuration or environment errors -> `1` |
|
|
30
|
+
| `scan` | `0` | parser errors with `--strict` -> `3`, otherwise `0` |
|
|
31
|
+
| `check` | `0` when current | stale map -> `2`, missing map -> `2` |
|
|
32
|
+
| `map` | `0` when current | stale, missing, or invalid map -> `2`; other errors -> `1` |
|
|
33
|
+
| `show` | `0` | no match -> `1` |
|
|
34
|
+
| `find` | `0`, including no matches | invalid query or limit -> `1` |
|
|
32
35
|
|
|
33
36
|
## CLI command matrix
|
|
34
37
|
|
|
@@ -59,6 +62,38 @@ Compares the persisted `manifest.json` against current state and config:
|
|
|
59
62
|
|
|
60
63
|
Returns `Current` or `Stale` with machine-readable reasons and change lists.
|
|
61
64
|
|
|
65
|
+
### `ai-code-map map`
|
|
66
|
+
|
|
67
|
+
Prints the complete structural map in one call. It checks freshness internally;
|
|
68
|
+
no separate `check` call is needed. If the map is missing, stale, or invalid, it
|
|
69
|
+
returns exit code 2 without printing the graph. Run `scan` to rebuild it.
|
|
70
|
+
|
|
71
|
+
```bash
|
|
72
|
+
pnpm exec ai-code-map map
|
|
73
|
+
pnpm exec ai-code-map map --json
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
The output includes every indexed file and symbol, plus every relation endpoint.
|
|
77
|
+
Files, symbols, and other endpoints receive short references (`f1`, `s1`, `e1`)
|
|
78
|
+
used in the relation table. Symbols also show their stable IDs and source lines.
|
|
79
|
+
Use the stable ID with `read`; short references apply only to this output and may
|
|
80
|
+
change after a rescan.
|
|
81
|
+
|
|
82
|
+
Relations are grouped by source, type, and evidence classification. A target such
|
|
83
|
+
as `s2*3` represents three occurrence records. All classifications are retained,
|
|
84
|
+
including heuristic and derived links; these must not be interpreted as exact
|
|
85
|
+
calls. Source text, signatures, facts, and per-occurrence evidence are excluded.
|
|
86
|
+
Use `show --json` for detailed evidence and `read` for current source.
|
|
87
|
+
|
|
88
|
+
There is no pagination or silent row limit. The `End of map` marker confirms that
|
|
89
|
+
the CLI reached the end; a calling tool may still truncate a large response.
|
|
90
|
+
The whole map can exceed an agent's output or context limit. One call does not
|
|
91
|
+
guarantee fewer tokens than focused navigation. Redirect to a file when needed:
|
|
92
|
+
|
|
93
|
+
```bash
|
|
94
|
+
pnpm exec ai-code-map map > /tmp/project-map.txt
|
|
95
|
+
```
|
|
96
|
+
|
|
62
97
|
### `ai-code-map show <selector>`
|
|
63
98
|
|
|
64
99
|
Displays indexed symbol(s) by:
|
|
@@ -68,7 +103,105 @@ Displays indexed symbol(s) by:
|
|
|
68
103
|
- `path` or `path#name`
|
|
69
104
|
- exact symbol name
|
|
70
105
|
|
|
71
|
-
|
|
106
|
+
Default text is compact: up to five symbols, full source ranges, signatures capped at 240
|
|
107
|
+
characters, and up to 12 relation groups across the response. Repeated relations of the same
|
|
108
|
+
direction, type, and endpoint are grouped with occurrence counts. Internal links come first.
|
|
109
|
+
Heuristic/unresolved relations, derived inverse links, containment/export edges, and references
|
|
110
|
+
that duplicate a more specific relation are filtered. Each symbol reports shown/omitted groups
|
|
111
|
+
and filtered record counts. Documentation and facts are available in the full view.
|
|
112
|
+
|
|
113
|
+
- `--limit <1..50>` changes the total relation-group limit for compact text.
|
|
114
|
+
- `--full` preserves the previous verbose text view.
|
|
115
|
+
- `--json` preserves the complete `ShowResult`, including all relation evidence.
|
|
116
|
+
|
|
117
|
+
These are row and signature limits, not a token budget. A failed selector suggests up to five
|
|
118
|
+
indexed candidates; it never silently selects a different symbol.
|
|
119
|
+
|
|
120
|
+
### `ai-code-map find <query>`
|
|
121
|
+
|
|
122
|
+
Searches indexed symbol names and paths. Quote multiword queries, for example
|
|
123
|
+
`ai-code-map find "manager change"`. Exact names/IDs rank first, followed by prefix/substring,
|
|
124
|
+
word matches, and bounded typo matching. Word matching normalizes common English plurals
|
|
125
|
+
and favors matches in symbol names over paths. Whitespace-separated queries with at least three distinct words
|
|
126
|
+
can also return partial matches: at least two words and half the query must match, including
|
|
127
|
+
one word in the symbol name. These rank below full matches and typo hints. Partial results
|
|
128
|
+
show which normalized terms were unmatched. This is lexical search, not semantic search;
|
|
129
|
+
`read` is not treated as a synonym of `viewed`. For example, `notification mark read` can
|
|
130
|
+
find `markNotificationsAsViewed` through `notification` and `mark`.
|
|
131
|
+
|
|
132
|
+
Read the selected symbol with `ai-code-map read '<id>'`. Use `show` when symbol relations are needed.
|
|
133
|
+
|
|
134
|
+
Results include stable IDs usable by `show`, kinds, and full source ranges. The default is ten
|
|
135
|
+
matches; `--limit <1..50>` adjusts this. `--json` returns `{ query, total, truncated, matches }`.
|
|
136
|
+
No matches is a successful empty search. Use `rg` for source text or symbols outside the index.
|
|
137
|
+
|
|
138
|
+
### `ai-code-map context <query>`
|
|
139
|
+
|
|
140
|
+
Collects current source for a quoted lexical query or exact symbol ID and its direct
|
|
141
|
+
exact/framework-derived graph neighbors in one call. It checks freshness first;
|
|
142
|
+
missing or stale maps return exit code 2. No model, embeddings, or network is used.
|
|
143
|
+
|
|
144
|
+
The default selects up to three matches and favors behavior over partial type matches.
|
|
145
|
+
For partial queries, it checks missing query words in the current bodies of up to
|
|
146
|
+
50 lexical candidates. It expands the strongest callable matches when source
|
|
147
|
+
evidence distinguishes them. This lexical ranking does not infer intent or synonyms.
|
|
148
|
+
An exact name or ID takes precedence. Each selected match expands once using the
|
|
149
|
+
bounded navigation rules of `read`; reference-only class neighbors are counted as
|
|
150
|
+
omitted, so a namespace reference does not load every method. Explicit class
|
|
151
|
+
queries remain supported. Source windows include two context lines.
|
|
152
|
+
Up to four incoming file-level call/reference sites are also included, such as
|
|
153
|
+
route registrations outside any function. Files of at most 80 lines are read in
|
|
154
|
+
full; larger files use eight lines on each side of the mapped site. These windows
|
|
155
|
+
share the same budgets and source validation as symbol windows.
|
|
156
|
+
After those windows, remaining budget can include up to four small functions or
|
|
157
|
+
values referenced by direct outgoing neighbors. Their bodies must be at most 80
|
|
158
|
+
lines; calls take priority over references. This extra step does not recurse or
|
|
159
|
+
expand incoming callers, and cannot displace the primary source windows.
|
|
160
|
+
Overlapping and adjacent ranges in the same file are emitted together with original
|
|
161
|
+
line numbers. Shared budgets are 800 source lines and 32,000 source characters
|
|
162
|
+
(including line separators); headers and bounded metadata are additional.
|
|
163
|
+
|
|
164
|
+
Options: `--seeds <1..5>`, `--max-lines <1..2000>`, `--max-chars <256..64000>`,
|
|
165
|
+
`--json`. Partial lexical matches keep their unmatched terms. Omitted source ranges,
|
|
166
|
+
other search-match count, and omitted navigation entries are explicit. Test call
|
|
167
|
+
sites are hints, not proof of coverage. A packet is a bounded local neighborhood,
|
|
168
|
+
not a claim to contain every dependency or every fact needed for the task.
|
|
169
|
+
|
|
170
|
+
For example: `ai-code-map context 'notification mark read'`. Reuse the returned
|
|
171
|
+
source and read only a specific missing range or dependency next. The existing
|
|
172
|
+
`find`, `read`, and `show` commands remain available for narrower requests.
|
|
173
|
+
|
|
174
|
+
### `ai-code-map read <id>`
|
|
175
|
+
|
|
176
|
+
Reads current source using an exact stable ID returned by `find`. Includes two lines
|
|
177
|
+
of context on each side of the symbol. Output is numbered and limited to 80 source
|
|
178
|
+
lines by default; `--limit <1..200>` changes the page size. Long symbols provide an
|
|
179
|
+
explicit `--offset` continuation within the same window. Reuse what you have already
|
|
180
|
+
read; follow a continuation or another symbol only for an unresolved question.
|
|
181
|
+
|
|
182
|
+
The first page also lists up to eight direct symbol neighbors and four exact incoming
|
|
183
|
+
call sites in test paths (`*.test.*`, `*.spec.*`, or `__tests__/`). Neighbors include
|
|
184
|
+
reusable IDs, source ranges, direction, relation type, and evidence classification.
|
|
185
|
+
Repeated neighbors are merged. Heuristic and derived inverse relations, containment,
|
|
186
|
+
exports, and unresolved or external endpoints are excluded. Test paths are navigation
|
|
187
|
+
hints, not proof of test coverage. Missing entries do not prove that no tests exist.
|
|
188
|
+
The block stays below 4,000 compact JSON characters and reports eligible entries
|
|
189
|
+
omitted by its limits. Continuation pages do not repeat it. Use `show '<id>'` for
|
|
190
|
+
more relations when needed.
|
|
191
|
+
|
|
192
|
+
The file must be inside the project root, regular, and match its indexed hash.
|
|
193
|
+
Changed files require `scan` before reading. Source pages over 12,000 characters are
|
|
194
|
+
rejected: reduce `--limit`, or use targeted source search for an oversized single line.
|
|
195
|
+
`--json` includes source, range, truncation, continuation metadata, and first-page
|
|
196
|
+
`navigation`. Source is read
|
|
197
|
+
on demand and is not added to persisted map artifacts. Run `check` before navigation;
|
|
198
|
+
this command validates the selected source file, not every project dependency.
|
|
199
|
+
|
|
200
|
+
The packaged `AGENTS.md` describes this navigation workflow. A reusable Codex skill
|
|
201
|
+
is included at `skills/ai-code-map/SKILL.md`. Copy the `ai-code-map` folder to your
|
|
202
|
+
Codex skills directory and invoke `$ai-code-map`. It guides combined context retrieval,
|
|
203
|
+
relation lookups, and targeted fallback for unindexed tests; it also supports older
|
|
204
|
+
CLI versions without `read` by using the returned source ranges directly.
|
|
72
205
|
|
|
73
206
|
## Generated artifacts
|
|
74
207
|
|