code-inventory 0.3.0 → 0.3.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.
package/README.md CHANGED
@@ -47,6 +47,8 @@ To review what an external caller can reach by invoking a handler, use `--entry-
47
47
 
48
48
  Repeat `--entry` to combine entry points or `--project` to select multiple configs. Output files must be new. Use `--strict` when a partial result should set exit code 2. The CLI still produces the report.
49
49
 
50
+ For scripts that save JSON, see the [0.x report compatibility rules](docs/reference.html#compatibility) and [CLI exit codes](docs/reference.html#exit-codes).
51
+
50
52
  Check diagnostics before interpreting counts. Call sites measure source occurrences. Runtime dispatch, callbacks, and external consumers can introduce paths the scanner cannot see. Review declarations with no known path before considering removal.
51
53
 
52
54
  ## Use the library
@@ -28,9 +28,11 @@
28
28
  <strong>On this page</strong>
29
29
  <nav aria-label="On this page">
30
30
  <a href="#cli">CLI options</a>
31
+ <a href="#exit-codes">Exit codes</a>
31
32
  <a href="#projects">Project selection</a>
32
33
  <a href="#counts">Counts and findings</a>
33
34
  <a href="#snapshot">JSON snapshot</a>
35
+ <a href="#compatibility">Saved reports and upgrades</a>
34
36
  <a href="#boundaries">Analysis limits</a>
35
37
  </nav>
36
38
  </aside>
@@ -104,13 +106,28 @@
104
106
  <dt><code>--output new-file</code></dt>
105
107
  <dd>Write the result to a new file. An existing path produces an error.</dd>
106
108
  <dt><code>--strict</code></dt>
107
- <dd>
108
- Write the report and exit with code 2 for a partial scan. A successful scan otherwise exits with 0. Invalid
109
- arguments and filesystem errors exit with 1.
110
- </dd>
109
+ <dd>Signal a partial scan after writing its report. See <a href="#exit-codes">exit codes</a>.</dd>
111
110
  <dt><code>-h</code>, <code>--help</code></dt>
112
111
  <dd>Print usage and exit.</dd>
113
112
  </dl>
113
+ <h2 id="exit-codes">Exit codes</h2>
114
+ <dl>
115
+ <dt><code>0</code> · Success</dt>
116
+ <dd>
117
+ The CLI printed help or produced the requested report. Without <code>--strict</code>, both complete and
118
+ partial scans succeed. Check the JSON <code>completeness</code> field when the distinction matters.
119
+ </dd>
120
+ <dt><code>1</code> · Command failed</dt>
121
+ <dd>
122
+ An invalid option, failed query, or read or write error sends an explanation to stderr. Stop before
123
+ consuming output. In particular, an existing <code>--output</code> file may be from an earlier run.
124
+ </dd>
125
+ <dt><code>2</code> · Strict scan produced a partial report</dt>
126
+ <dd>
127
+ Read the report from stdout or the new file named by <code>--output</code>. Inspect its diagnostics before
128
+ using the results. A complete scan with <code>--strict</code> exits with 0.
129
+ </dd>
130
+ </dl>
114
131
  <h2 id="projects">Project selection</h2>
115
132
  <pre><code>node dist/cli.js . --project tsconfig.build.json --exclude '**/generated/**' --test 'qa/**'</code></pre>
116
133
  <p>
@@ -198,14 +215,52 @@
198
215
  the selected file or invocation root and target, or null for an unreached ID. Select the ID with usages. Each
199
216
  non-root node carries the edge kind and source location. summary, usageText and markdown render display text.
200
217
  </p>
218
+ <h2 id="compatibility">Saved reports and 0.x upgrades</h2>
219
+ <p>
220
+ Use <code>--format json</code> for scripts. The packaged <a href="report-schema.json">JSON Schema</a> lists
221
+ the required properties, types, allowed values and nullable fields for each report. Summary, Markdown,
222
+ diagnostic messages and limitation text are for display. <code>--changed-since</code> produces a text summary.
223
+ </p>
224
+ <dl>
225
+ <dt>Full inventory</dt>
226
+ <dd>
227
+ Require <code>schemaVersion === 1</code> for the layout above. Save the full inventory to run new
228
+ <code>usages</code> or <code>reachability</code> queries later. Use <code>analyzer.version</code> and
229
+ <code>analyzer.compilerVersion</code> to identify the producer.
230
+ </dd>
231
+ <dt>Symbol query</dt>
232
+ <dd>
233
+ Require <code>schemaVersion === 1</code> and read <code>usage.symbol</code>,
234
+ <code>usage.references</code> and <code>usage.counts</code>. The CLI puts snapshot-wide diagnostics
235
+ alongside <code>usage</code>.
236
+ </dd>
237
+ <dt>Entry query</dt>
238
+ <dd>
239
+ In 0.3.0 this report has no <code>schemaVersion</code>. Validate it against the schema’s
240
+ <code>entryReport</code> definition. File roots appear in <code>entries</code>. The optional
241
+ <code>entrySymbols</code> lists explicitly invoked declarations. Use <code>reached</code> to reconstruct
242
+ paths and <code>declarations</code> to look up reachability status.
243
+ </dd>
244
+ </dl>
245
+ <p>
246
+ All three shapes carry <code>snapshotId</code>, <code>completeness</code> and <code>diagnostics</code>. Keep
247
+ the matching inventory or its producer metadata with a saved query. Treat IDs as opaque and join records only
248
+ within the same snapshot. A fresh scan with an improved resolver can produce different IDs, counts, paths or
249
+ diagnostics for the same source.
250
+ </p>
251
+ <p>
252
+ Within schema version 1, readers can rely on required fields and their documented meanings. Producers may add
253
+ optional fields and diagnostic codes. Ignore unfamiliar properties, handle unfamiliar codes, and allow
254
+ optional fields such as <code>files[].project</code> to be absent. A required field with a nullable type, such
255
+ as <code>references[].callerId</code>, is present even when its value is <code>null</code>.
256
+ </p>
201
257
  <p>
202
- The <a href="report-schema.json">JSON Schema</a> describes all three CLI report shapes. For persisted data
203
- check schemaVersion before reading a full inventory or symbol response. The entry response has the
204
- Reachability shape in the shipped TypeScript declarations. In 0.1.0 it has no schemaVersion. Keep analyzer and
205
- compiler versions from the full snapshot alongside query results. Use snapshot-local IDs for joins. Accept
206
- additional fields and unknown diagnostic codes. Compare counts across upgrades against source examples;
207
- changes in resolution can change a result even when its shape stays compatible. Keep the generating version
208
- for older snapshots. During 0.x the format and API can change.
258
+ During 0.x, a change that invalidates existing reports or breaks a reader following these rules belongs in a
259
+ new minor release with migration instructions. An incompatible JSON shape also needs a new schema version,
260
+ including an explicit version on a replacement for the unversioned entry report. A change to the documented
261
+ exit codes is likewise a breaking CLI change. Before moving to another minor release, validate a saved report
262
+ with the target schema and replay a representative query. For an unsupported version, retain the original
263
+ report and use its generating release until you migrate.
209
264
  </p>
210
265
  <p>
211
266
  TS-prefixed codes are compiler diagnostics. unresolved-module and dynamic-module identify missing module
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "code-inventory",
3
- "version": "0.3.0",
3
+ "version": "0.3.1",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "description": "Static code inventory for JavaScript and TypeScript. Find symbol usages and trace paths from entry points.",
@@ -52,10 +52,10 @@
52
52
  "typescript": "npm:@typescript/typescript6@6.0.2"
53
53
  },
54
54
  "devDependencies": {
55
- "@types/node": "26.6.6",
55
+ "@types/node": "26.6.11",
56
56
  "eslint": "10.15.0",
57
57
  "prettier": "3.10.1",
58
- "typescript-eslint": "8.73.0",
59
- "vitest": "5.1.1"
58
+ "typescript-eslint": "8.74.0",
59
+ "vitest": "5.1.2"
60
60
  }
61
61
  }