ai-code-map 0.0.0-stage → 0.1.0-alpha.2

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/CHANGELOG.md ADDED
@@ -0,0 +1,32 @@
1
+ # Changelog
2
+
3
+ ## 2026-11-01
4
+
5
+ ### 0.1.0-alpha.2
6
+
7
+ - Release compiler memory after each unit in default scans by using sequential workers.
8
+ - Avoid unused TypeScript JSDoc parsing while preserving JavaScript JSDoc type information.
9
+ - Preserve in-process behavior and full JSDoc for custom analyzers and semantic resolvers.
10
+ - Retain semantic closure, artifact validation, CWD independence, and unchanged-map reuse.
11
+ - Advance the semantic resolver version; maps from the previous version require a rescan.
12
+
13
+ ## 2026-08-06
14
+
15
+ ### 0.1.0
16
+
17
+ - Initial alpha implementation and documentation baseline.
18
+ - Added CLI commands: `init`, `scan`, `check`, `show`.
19
+ - Added deterministic persisted artifacts:
20
+ - `manifest.json`
21
+ - `project.json`
22
+ - `files.jsonl`
23
+ - `symbols.jsonl`
24
+ - `relations.jsonl`
25
+ - `diagnostics.json`
26
+ - `overview.md`
27
+ - Added core semantic analyzers:
28
+ - TypeScript/Node symbols and references
29
+ - React component/hook/component-relationship facts
30
+ - Added `ai-code-map check` freshness contract with added/modified/deleted/moved reporting.
31
+ - Added programmatic exports for scanning, loading maps, showing symbols, and constructing analyzers.
32
+ - Added CI pipeline and initial package-level documentation set.
@@ -0,0 +1,43 @@
1
+ # Contributing
2
+
3
+ Thank you for improving AI Code Map.
4
+
5
+ ## Development setup
6
+
7
+ Use `pnpm` for package management:
8
+
9
+ ```bash
10
+ pnpm install
11
+ ```
12
+
13
+ ## Typical workflow
14
+
15
+ 1. Create or update docs/tests/fixtures as needed.
16
+ 2. Keep outputs deterministic: stable ordering and stable JSON formatting.
17
+ 3. Run local checks:
18
+
19
+ ```bash
20
+ pnpm run lint
21
+ pnpm run typecheck
22
+ pnpm run test
23
+ pnpm run build
24
+ ```
25
+
26
+ ## Project principles
27
+
28
+ - Favor static analysis over runtime behavior.
29
+ - Preserve existing behavior and avoid broad rewrites.
30
+ - Keep source snippets out of persisted artifacts unless explicitly introduced and safe.
31
+ - Preserve determinism for existing tests and fixture outputs.
32
+
33
+ ## Documentation scope
34
+
35
+ This repository documents an alpha workflow first:
36
+
37
+ - commands: `init`, `scan`, `check`, `show`
38
+ - deterministic map artifacts
39
+ - TS/JS/React compiler-backed analysis
40
+
41
+ ## Working with existing changes
42
+
43
+ Do not revert unrelated user edits in this worktree. Keep changes narrowly scoped and preserve file ownership boundaries when multiple contributors are involved.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 ai-code-map contributors
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 CHANGED
@@ -1,3 +1,237 @@
1
- # Temporary Holding Version
1
+ # AI Code Map
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ AI Code Map is a local, deterministic code understanding layer for TypeScript, JavaScript, and React projects. It analyzes source files into stable symbols, relations, and diagnostics so AI coding agents can plan with a compact, trustworthy index before opening many files.
4
+
5
+ ## Key properties (alpha scope)
6
+
7
+ - **Local-only execution**: scanning reads project files and writes local artifacts; no LLM calls are used during analysis.
8
+ - **Deterministic by design**: identical inputs produce byte-identical artifacts.
9
+ - **Compiler-authoritative**: TypeScript compiler is the trusted semantic layer for symbols, references, imports, and types.
10
+ - **Evidence-backed facts**: relations carry a source range, analyzer, classification, and confidence; source code remains authoritative.
11
+ - **No network/telemetry by default**: no outbound upload is part of a standard scan.
12
+ - **Small CLI**: `init`, `scan`, `check`, `show`.
13
+
14
+ ## Quick start
15
+
16
+ ```bash
17
+ pnpm install
18
+ pnpm exec ai-code-map init
19
+ pnpm exec ai-code-map scan
20
+ pnpm exec ai-code-map check
21
+ pnpm exec ai-code-map show Calculator
22
+ ```
23
+
24
+ ### Exit codes
25
+
26
+ | Command | Success | Failure behavior |
27
+ | ------- | ---------------- | --------------------------------------------------- |
28
+ | `init` | `0` | invalid configuration or environment errors -> `1` |
29
+ | `scan` | `0` | parser errors with `--strict` -> `3`, otherwise `0` |
30
+ | `check` | `0` when current | stale map -> `2`, missing map -> `2` |
31
+ | `show` | `0` | no match -> `1` |
32
+
33
+ ## CLI command matrix
34
+
35
+ All commands share these options:
36
+
37
+ - `--root <path>`: project root to scan (defaults by searching up to nearest `package.json`)
38
+ - `--config <path>`: config path (absolute or relative to CWD)
39
+ - `--output <path>`: map output directory
40
+ - `--json`: machine-readable output where supported
41
+
42
+ ### `ai-code-map init`
43
+
44
+ Creates `.ai/code-map/config.json` (or `--output/config.json`) only if missing unless `--force` is set.
45
+
46
+ ### `ai-code-map scan`
47
+
48
+ Analyzes source files and writes map artifacts to output directory.
49
+
50
+ - `--strict`: exit code `3` if any diagnostic with `code === "parse-error"` has severity `error`.
51
+
52
+ ### `ai-code-map check`
53
+
54
+ Compares the persisted `manifest.json` against current state and config:
55
+
56
+ - source hash set changes (`added|modified|deleted|moved`)
57
+ - framework/schema/parser/analyzer/config version drift
58
+ - schema compatibility
59
+
60
+ Returns `Current` or `Stale` with machine-readable reasons and change lists.
61
+
62
+ ### `ai-code-map show <selector>`
63
+
64
+ Displays indexed symbol(s) by:
65
+
66
+ - exact stable ID
67
+ - shorthand `kind:name` (aliases: `component`, `hook`, `function`, `class`, `method`, `interface`, `type`, `variable`, `page`, `controller`, `module`)
68
+ - `path` or `path#name`
69
+ - exact symbol name
70
+
71
+ Shows symbol details plus inbound/outbound relation IDs and confidence.
72
+
73
+ ## Generated artifacts
74
+
75
+ The scanner writes these deterministic files under the output directory (default `.ai/code-map`):
76
+
77
+ - `overview.md` (human view)
78
+ - `manifest.json`
79
+ - `project.json`
80
+ - `files.jsonl`
81
+ - `symbols.jsonl`
82
+ - `relations.jsonl`
83
+ - `diagnostics.json`
84
+
85
+ `project.json` is a required companion artifact. Loading or reusing a map validates it together with
86
+ the manifest, JSONL records, diagnostics, and their cross-record ownership/count invariants.
87
+
88
+ See [`docs/artifacts.md`](./docs/artifacts.md) and [`docs/schema.md`](./docs/schema.md) for exact field-level formats.
89
+
90
+ ## Config
91
+
92
+ Configuration is read from `config.json` and validated via [`config.schema.json`](./config.schema.json). All paths are root-relative (POSIX) in persisted records.
93
+
94
+ Default include patterns:
95
+
96
+ ```json
97
+ {
98
+ "include": [
99
+ "src/**/*",
100
+ "app/**/*",
101
+ "pages/**/*",
102
+ "lib/**/*",
103
+ "server/**/*",
104
+ "*.{ts,tsx,js,jsx,mts,cts,mjs,cjs}"
105
+ ]
106
+ }
107
+ ```
108
+
109
+ Default exclusions:
110
+
111
+ ```json
112
+ [
113
+ "**/node_modules/**",
114
+ "**/.next/**",
115
+ "**/dist/**",
116
+ "**/build/**",
117
+ "**/coverage/**",
118
+ "**/.git/**",
119
+ "**/.ai/**",
120
+ "**/*.generated.*"
121
+ ]
122
+ ```
123
+
124
+ Full config fields are documented in [`docs/schema.md`](./docs/schema.md).
125
+
126
+ ## Programmatic API example
127
+
128
+ The programmatic surface is exported from the package root:
129
+
130
+ ```ts
131
+ import {
132
+ initProject,
133
+ scanProject,
134
+ loadCodeMap,
135
+ checkFreshness,
136
+ showSymbol,
137
+ createAnalyzer,
138
+ NextJsAnalyzer,
139
+ NestJsAnalyzer,
140
+ } from "ai-code-map";
141
+
142
+ const root = process.cwd();
143
+
144
+ await initProject({ root });
145
+ const scan = await scanProject({ root });
146
+ console.log(scan.counts, scan.changes, scan.criticalParseErrors);
147
+
148
+ const map = await loadCodeMap({ root });
149
+ const result = showSymbol(map, "component:UserList");
150
+ console.log(result.matches.map((entry) => entry.symbol.id));
151
+
152
+ const freshness = await checkFreshness({ root });
153
+ console.log(freshness.current ? "current" : "stale");
154
+
155
+ const analyzer = createAnalyzer({
156
+ analyzers: [new NextJsAnalyzer(), new NestJsAnalyzer()],
157
+ });
158
+ await analyzer.scan({ root });
159
+ ```
160
+
161
+ `createAnalyzer` returns a composable scan surface for custom analyzers and parser adapters.
162
+
163
+ ## Stability, evidence, confidence, and freshness
164
+
165
+ ### Stable IDs
166
+
167
+ - File IDs use `file:<posix-path>`
168
+ - Symbol IDs use stable, path-scoped IDs like `component:src/app/App.tsx#AppShell`
169
+ - Route and external IDs are explicit prefixes (`route:`, `external:`)
170
+
171
+ IDs are designed to survive unrelated edits when logical identity is unchanged.
172
+
173
+ ### Evidence and confidence
174
+
175
+ - Evidence includes parser-origin and file/line ranges in symbol relations.
176
+ - Relation origins classify evidence as `exact`, `framework-derived`, `heuristic`, or `derived` and identify the producing analyzer.
177
+ - Relation `confidence` is bounded to `[0, 1]`:
178
+ - `1` for compiler-exact resolution
179
+ - lower values when fallback inference is used
180
+
181
+ ### Freshness
182
+
183
+ Freshness compares:
184
+
185
+ - manifest/source hashes
186
+ - schema version
187
+ - analyzer and parser versions
188
+ - effective framework selection
189
+ - configuration hash including relevant project metadata
190
+
191
+ `ai-code-map check` reports actionable reasons and exact change buckets.
192
+
193
+ ## Known limitations
194
+
195
+ - CLI is intentionally alpha: only `init`, `scan`, `check`, and `show`.
196
+ - No source execution, no dynamic config loading, no project remote ingestion.
197
+ - `show` is a single-symbol query, not a full search/index query language.
198
+ - `Next.js` and `NestJS` analyzers are exported and available programmatically but are **experimental and default-off** in CLI because they are not in the default analyzer list.
199
+ - Tree-sitter/ast-grep is not enabled in production scans. A pinned ast-grep development spike and microbenchmark exist, while TS/JS/React analysis remains compiler-authoritative.
200
+ - Compiler-unit discovery, deterministic file ownership, project references, extended configs, and
201
+ bounded fallback analysis are implemented. Complex conditional package exports and references
202
+ outside the selected root remain bounded limitations.
203
+ - No planned Beta/Later capabilities are claimed by default.
204
+
205
+ ## AI-agent instructions (copy/paste)
206
+
207
+ Use this with your agent context:
208
+
209
+ ### English
210
+
211
+ Use the Code Map as a navigation index, not as a replacement for source. Start with `ai-code-map init` then `ai-code-map scan`; do not upload map output and do not read every `.ai/code-map` artifact automatically. For each change:
212
+
213
+ 1. Inspect symbols via `ai-code-map show <id|kind:name|name> --json`.
214
+ 2. Read only the files and symbols directly connected through relations.
215
+ 3. Keep decisions tied to map evidence and confidence; do not assume behavior beyond relation origin lines.
216
+ 4. Open and verify the authoritative source before editing.
217
+ 5. Before finalizing, run `ai-code-map check` to verify no stale output changes.
218
+
219
+ ### Русский
220
+
221
+ Используйте Code Map как навигационный индекс, а не замену исходному коду. Выполните `ai-code-map init`, затем `ai-code-map scan`; не отправляйте артефакты наружу и не читайте автоматически все файлы `.ai/code-map`. Для каждого изменения:
222
+
223
+ 1. Смотрите символы через `ai-code-map show <id|kind:name|name> --json`.
224
+ 2. Открывайте только файлы и связи, которые действительно относятся к выбранным символам.
225
+ 3. Проверяйте решения по доказательствам из артефактов и уровню `confidence`; не делайте предположений без этих данных.
226
+ 4. Перед изменением откройте и проверьте исходный код как главный источник истины.
227
+ 5. Перед завершением выполните `ai-code-map check`, чтобы убедиться, что карта актуальна.
228
+
229
+ Architecture decisions and deferred work are recorded in [`docs/architecture/ADR-0001-hybrid-syntax-and-semantics.md`](./docs/architecture/ADR-0001-hybrid-syntax-and-semantics.md) and [`docs/backlog.md`](./docs/backlog.md).
230
+
231
+ ## Contributing and security
232
+
233
+ See [`CONTRIBUTING.md`](./CONTRIBUTING.md) and [`SECURITY.md`](./SECURITY.md).
234
+
235
+ ## Changelog
236
+
237
+ See [`CHANGELOG.md`](./CHANGELOG.md).
package/SECURITY.md ADDED
@@ -0,0 +1,18 @@
1
+ # Security policy
2
+
3
+ AI Code Map is designed for local, static analysis and currently has no background telemetry or remote upload in alpha scanning flow.
4
+
5
+ ## Reporting issues
6
+
7
+ - Review public issues and avoid sharing repository secrets, `.env` values, or private source content.
8
+ - Report vulnerabilities by opening an advisory in the project security channel.
9
+ - For GitHub-based reporting:
10
+ `https://github.com/example/ai-code-map/security/advisories/new`
11
+
12
+ ## Security boundaries to preserve
13
+
14
+ - Do not execute scanned project code.
15
+ - Do not follow symlinks outside the resolved project root.
16
+ - Avoid resolving or serializing arbitrary runtime values.
17
+ - Keep path handling root-relative and normalized.
18
+ - Keep source code snippets minimized and only emit explicit, documented evidence fields.
@@ -0,0 +1,130 @@
1
+ {
2
+ "$defs": {
3
+ "__schema0": {
4
+ "const": 1,
5
+ "default": 1,
6
+ "type": "number"
7
+ },
8
+ "__schema1": {
9
+ "default": "../..",
10
+ "minLength": 1,
11
+ "type": "string"
12
+ },
13
+ "__schema10": {
14
+ "maximum": 64,
15
+ "minimum": 1,
16
+ "type": "integer"
17
+ },
18
+ "__schema2": {
19
+ "default": [
20
+ "src/**/*",
21
+ "app/**/*",
22
+ "pages/**/*",
23
+ "lib/**/*",
24
+ "server/**/*",
25
+ "*.{ts,tsx,js,jsx,mts,cts,mjs,cjs}"
26
+ ],
27
+ "items": {
28
+ "$ref": "#/$defs/__schema3"
29
+ },
30
+ "minItems": 1,
31
+ "type": "array"
32
+ },
33
+ "__schema3": {
34
+ "minLength": 1,
35
+ "type": "string"
36
+ },
37
+ "__schema4": {
38
+ "default": [
39
+ "**/node_modules/**",
40
+ "**/.next/**",
41
+ "**/dist/**",
42
+ "**/build/**",
43
+ "**/coverage/**",
44
+ "**/.git/**",
45
+ "**/.ai/**",
46
+ "**/*.generated.*"
47
+ ],
48
+ "items": {
49
+ "minLength": 1,
50
+ "type": "string"
51
+ },
52
+ "type": "array"
53
+ },
54
+ "__schema5": {
55
+ "minLength": 1,
56
+ "type": "string"
57
+ },
58
+ "__schema6": {
59
+ "default": [
60
+ "auto"
61
+ ],
62
+ "items": {
63
+ "$ref": "#/$defs/__schema7"
64
+ },
65
+ "minItems": 1,
66
+ "type": "array"
67
+ },
68
+ "__schema7": {
69
+ "anyOf": [
70
+ {
71
+ "enum": [
72
+ "typescript",
73
+ "node",
74
+ "react",
75
+ "nextjs",
76
+ "nestjs"
77
+ ],
78
+ "type": "string"
79
+ },
80
+ {
81
+ "const": "auto",
82
+ "type": "string"
83
+ }
84
+ ]
85
+ },
86
+ "__schema8": {
87
+ "default": ".ai/code-map",
88
+ "minLength": 1,
89
+ "type": "string"
90
+ },
91
+ "__schema9": {
92
+ "default": false,
93
+ "type": "boolean"
94
+ }
95
+ },
96
+ "$id": "urn:ai-code-map:config:1",
97
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
98
+ "additionalProperties": false,
99
+ "properties": {
100
+ "concurrency": {
101
+ "$ref": "#/$defs/__schema10"
102
+ },
103
+ "exclude": {
104
+ "$ref": "#/$defs/__schema4"
105
+ },
106
+ "frameworks": {
107
+ "$ref": "#/$defs/__schema6"
108
+ },
109
+ "include": {
110
+ "$ref": "#/$defs/__schema2"
111
+ },
112
+ "includePrivateSymbols": {
113
+ "$ref": "#/$defs/__schema9"
114
+ },
115
+ "output": {
116
+ "$ref": "#/$defs/__schema8"
117
+ },
118
+ "root": {
119
+ "$ref": "#/$defs/__schema1"
120
+ },
121
+ "tsconfig": {
122
+ "$ref": "#/$defs/__schema5"
123
+ },
124
+ "version": {
125
+ "$ref": "#/$defs/__schema0"
126
+ }
127
+ },
128
+ "title": "ai-code-map configuration",
129
+ "type": "object"
130
+ }
package/dist/cli.d.ts ADDED
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env node
2
+ declare function runCli(argv?: string[]): Promise<number>;
3
+
4
+ export { runCli };