Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,10 @@ The lines that follow identify each reference by file, line, column, kind, and s

In a Git checkout, run `npx code-inventory . --changed-since main` to see the declarations touched by tracked
source changes, their exports, and references grouped by caller or test file. Deleted files and removed base lines
appear separately. The query uses the current checkout, including staged and unstaged edits.
appear separately. Add `--format json` to consume one shortest call path per candidate test and changed declaration. The query uses the current checkout, including staged and unstaged edits.

Use `--workspace-entries` to trace npm workspace packages and identify which manifest selected each file.
Use `--next-routes` at a Next.js app root to trace exported HTTP handlers.

For convention-based entry points, use a quoted pattern such as `--entry-glob 'src/routes/**/+page.ts'`. Combine it with `--package-entries` to include a package’s public entry files.

Expand Down
29 changes: 23 additions & 6 deletions docs/reference.html
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,21 @@ <h2 id="cli">CLI options</h2>
declarations, including an enclosing declaration when the line also contains its own code. Reads include
callback arguments. Test references identify source sites and do not establish runtime coverage. Removed
lines use base coordinates. Deleted files and the old side of renames have no current declaration to query.
Use this option on its own with summary output.
Each candidate test has one shortest chain of resolved calls or constructions to the changed declaration.
Paths start at a site in a test file. An unexecuted helper in a test file may supply such a site. Use
summary or JSON output. The JSON report has kind <code>change-impact</code>, schemaVersion 1, baseTree,
snapshotId, diagnostics, changes and diff notes. Within each change, tests[].path lists located references
from the test toward the declaration.
</dd>
<dt><code>--workspace-entries</code></dt>
<dd>
Read the root and member manifests matched by the root npm workspaces array. Each entry origin lists the
manifest, field and analyzed file. Use --project for any required compiler output mapping.
</dd>
<dt><code>--next-routes</code></dt>
<dd>
Select route.js and route.ts files under app or src/app in the scan root, excluding private folders. Model
both module initialization and invocation of exported HTTP methods identified in each route file.
</dd>
<dt><code>--package-entries</code></dt>
<dd>
Expand Down Expand Up @@ -210,16 +224,19 @@ <h2>Consuming the 0.x API</h2>
<p>
The package root exports scan, usages, findings, reachability, packageEntries and entryPath. scan reads a
directory synchronously. The other queries operate on its inventory or reachability report, except
packageEntries(directory, inventory), which also reads the matching manifest and build configuration. Pass its
result to reachability. entryPath(report, symbolId) returns the ordered nodes of one shortest path, including
the selected file or invocation root and target, or null for an unreached ID. Select the ID with usages. Each
non-root node carries the edge kind and source location. summary, usageText and markdown render display text.
packageEntries(directory, inventory), which also reads the matching manifest and build configuration.
workspaceEntries(directory, inventory) returns manifest origins. nextRouteEntries(inventory) returns route
files and handler IDs. changeImpact(directory, base, inventory) queries Git against the current matching scan
and returns the structured change report. Pass the packageEntries result to reachability. entryPath(report,
symbolId) returns the ordered nodes of one shortest path, including the selected file or invocation root and
target, or null for an unreached ID. Select the ID with usages. Each non-root node carries the edge kind and
source location. summary, usageText and markdown render display text.
</p>
<h2 id="compatibility">Saved reports and 0.x upgrades</h2>
<p>
Use <code>--format json</code> for scripts. The packaged <a href="report-schema.json">JSON Schema</a> lists
the required properties, types, allowed values and nullable fields for each report. Summary, Markdown,
diagnostic messages and limitation text are for display. <code>--changed-since</code> produces a text summary.
diagnostic messages and limitation text are for display.
</p>
<dl>
<dt>Full inventory</dt>
Expand Down
167 changes: 166 additions & 1 deletion docs/report-schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
},
{
"$ref": "#/definitions/entryReport"
},
{
"$ref": "#/definitions/impactReport"
}
],
"definitions": {
Expand Down Expand Up @@ -444,7 +447,9 @@
},
"entrySymbols": {
"type": "array",
"items": { "type": "string" }
"items": {
"type": "string"
}
},
"reached": {
"type": "array",
Expand Down Expand Up @@ -506,6 +511,166 @@
"items": {
"type": "string"
}
},
"entryOrigins": {
"type": "array",
"items": {
"type": "object",
"required": ["file", "manifest", "field"],
"properties": {
"file": {
"type": "string"
},
"manifest": {
"type": "string"
},
"field": {
"type": "string"
}
}
}
}
}
},
"impactReport": {
"type": "object",
"required": [
"kind",
"schemaVersion",
"base",
"baseTree",
"snapshotId",
"completeness",
"diagnostics",
"notes",
"changes"
],
"properties": {
"kind": {
"const": "change-impact"
},
"schemaVersion": {
"const": 1
},
"base": {
"type": "string"
},
"baseTree": {
"type": "string"
},
"snapshotId": {
"type": "string"
},
"completeness": {
"enum": ["partial", "complete"]
},
"diagnostics": {
"type": "array",
"items": {
"$ref": "#/definitions/diagnostic"
}
},
"notes": {
"type": "array",
"items": {
"oneOf": [
{
"type": "object",
"required": ["kind", "file", "first", "last"],
"properties": {
"kind": {
"enum": ["removed-lines", "outside-declaration"]
},
"file": {
"type": "string"
},
"first": {
"type": "integer",
"minimum": 1
},
"last": {
"type": "integer",
"minimum": 1
}
}
},
{
"type": "object",
"required": ["kind", "file"],
"properties": {
"kind": {
"enum": ["deleted-file", "no-hunks"]
},
"file": {
"type": "string"
}
}
},
{
"type": "object",
"required": ["kind", "file", "reason"],
"properties": {
"kind": {
"const": "outside-scan"
},
"file": {
"type": "string"
},
"reason": {
"type": "string"
}
}
}
]
}
},
"changes": {
"type": "array",
"items": {
"type": "object",
"required": ["symbol", "references", "tests"],
"properties": {
"symbol": {
"$ref": "#/definitions/symbol"
},
"references": {
"type": "array",
"items": {
"$ref": "#/definitions/reference"
}
},
"tests": {
"type": "array",
"items": {
"type": "object",
"required": ["file", "path"],
"properties": {
"file": {
"type": "string"
},
"path": {
"type": "array",
"items": {
"allOf": [
{
"$ref": "#/definitions/reference"
},
{
"properties": {
"kind": {
"enum": ["call", "construct"]
}
}
}
]
},
"minItems": 1
}
}
}
}
}
}
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "code-inventory",
"version": "0.3.3",
"version": "0.4.0",
"license": "MIT",
"type": "module",
"description": "Static code inventory for JavaScript and TypeScript. Find symbol usages and trace paths from entry points.",
Expand Down
Loading