Skip to content

Commit 6c660bd

Browse files
committed
feat: add --json output to eval:inventory
1 parent b99c792 commit 6c660bd

4 files changed

Lines changed: 451 additions & 3 deletions

File tree

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
"docs:settings": "tsx ./scripts/generate-settings-doc.ts",
3434
"docs:keybindings": "tsx ./scripts/generate-keybindings-doc.ts",
3535
"eval:inventory": "tsx ./scripts/eval-inventory-cli.ts",
36+
"eval:inventory:json": "tsx ./scripts/eval-inventory-cli.ts --json",
3637
"build": "node scripts/build.js",
3738
"build-and-start": "npm run build && npm run start --",
3839
"build:vscode": "node scripts/build_vscode_companion.js",

scripts/eval-inventory-cli.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,18 @@
1010
* @fileoverview CLI entry point for the eval inventory command.
1111
*
1212
* Scans all eval source files, runs the static analyzer on each,
13-
* and prints a human-readable inventory report grouped by policy,
14-
* file, and suite.
13+
* and prints an inventory report grouped by policy, file, and suite.
1514
*
1615
* Usage:
1716
* npm run eval:inventory
17+
* npm run eval:inventory -- --json
1818
* npm run eval:inventory -- --root /path/to/repo
19+
* npm run eval:inventory -- --root /path/to/repo --json
1920
*/
2021

2122
import {
2223
collectInventory,
24+
formatInventoryJson,
2325
formatInventoryReport,
2426
} from './utils/eval-inventory.js';
2527

@@ -30,14 +32,18 @@ async function main() {
3032
? process.argv[rootFlagIndex + 1]
3133
: process.cwd();
3234

35+
const jsonMode = process.argv.includes('--json');
36+
3337
const result = await collectInventory(repoRoot);
3438

3539
if (result.totalFiles === 0) {
3640
console.error('No eval files found under evals/.');
3741
process.exit(1);
3842
}
3943

40-
console.log(formatInventoryReport(result));
44+
console.log(
45+
jsonMode ? formatInventoryJson(result) : formatInventoryReport(result),
46+
);
4147
}
4248

4349
main().catch((error) => {

0 commit comments

Comments
 (0)