auditor-lambda 0.7.0 → 0.9.0

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.
Files changed (125) hide show
  1. package/README.md +0 -21
  2. package/audit-code-wrapper-lib.mjs +149 -129
  3. package/dist/adapters/normalizeExternal.js +6 -3
  4. package/dist/cli/args.d.ts +0 -1
  5. package/dist/cli/args.js +0 -6
  6. package/dist/cli/auditStep.js +7 -1
  7. package/dist/cli/dispatch.js +3 -2
  8. package/dist/cli/lineIndex.js +4 -1
  9. package/dist/cli/mergeAndIngestCommand.d.ts +1 -0
  10. package/dist/cli/mergeAndIngestCommand.js +219 -0
  11. package/dist/cli/nextStepCommand.js +5 -1
  12. package/dist/cli/runToCompletion.d.ts +9 -0
  13. package/dist/cli/runToCompletion.js +655 -480
  14. package/dist/cli/statusCommand.d.ts +1 -0
  15. package/dist/cli/statusCommand.js +113 -0
  16. package/dist/cli/submitPacketCommand.d.ts +1 -0
  17. package/dist/cli/submitPacketCommand.js +155 -0
  18. package/dist/cli/workerResult.d.ts +1 -1
  19. package/dist/cli/workerRunCommand.d.ts +1 -0
  20. package/dist/cli/workerRunCommand.js +88 -0
  21. package/dist/cli.d.ts +0 -1
  22. package/dist/cli.js +14 -565
  23. package/dist/extractors/analyzers/sql.js +4 -1
  24. package/dist/extractors/analyzers/treeSitter.js +29 -15
  25. package/dist/extractors/analyzers/typescript.js +10 -8
  26. package/dist/extractors/designAssessment.js +43 -24
  27. package/dist/extractors/graph.js +151 -75
  28. package/dist/extractors/pathPatterns.js +17 -5
  29. package/dist/io/artifacts.d.ts +3 -1
  30. package/dist/io/artifacts.js +18 -2
  31. package/dist/io/runArtifactTypes.d.ts +18 -0
  32. package/dist/io/runArtifactTypes.js +1 -0
  33. package/dist/io/runArtifacts.d.ts +2 -18
  34. package/dist/io/runArtifacts.js +14 -3
  35. package/dist/mcp/server.js +9 -0
  36. package/dist/orchestrator/advance.js +38 -22
  37. package/dist/orchestrator/artifactFreshness.js +14 -4
  38. package/dist/orchestrator/autoFixExecutor.d.ts +2 -2
  39. package/dist/orchestrator/autoFixExecutor.js +26 -8
  40. package/dist/orchestrator/dependencyMap.d.ts +1 -1
  41. package/dist/orchestrator/dependencyMap.js +7 -1
  42. package/dist/orchestrator/executorResult.d.ts +12 -0
  43. package/dist/orchestrator/executorResult.js +1 -0
  44. package/dist/orchestrator/fileAnchors.js +14 -3
  45. package/dist/orchestrator/fileIntegrity.d.ts +1 -0
  46. package/dist/orchestrator/fileIntegrity.js +12 -3
  47. package/dist/orchestrator/flowCoverage.js +1 -0
  48. package/dist/orchestrator/flowRequeue.js +4 -1
  49. package/dist/orchestrator/graphEnrichmentExecutor.d.ts +1 -1
  50. package/dist/orchestrator/graphEnrichmentExecutor.js +3 -1
  51. package/dist/orchestrator/ingestionExecutors.d.ts +11 -0
  52. package/dist/orchestrator/ingestionExecutors.js +237 -0
  53. package/dist/orchestrator/intakeExecutors.d.ts +3 -0
  54. package/dist/orchestrator/intakeExecutors.js +25 -0
  55. package/dist/orchestrator/planningExecutors.d.ts +4 -0
  56. package/dist/orchestrator/planningExecutors.js +95 -0
  57. package/dist/orchestrator/reviewPacketGraph.d.ts +31 -0
  58. package/dist/orchestrator/reviewPacketGraph.js +691 -0
  59. package/dist/orchestrator/reviewPackets.d.ts +2 -15
  60. package/dist/orchestrator/reviewPackets.js +3 -685
  61. package/dist/orchestrator/runtimeCommand.d.ts +11 -0
  62. package/dist/orchestrator/runtimeCommand.js +71 -0
  63. package/dist/orchestrator/scope.js +1 -1
  64. package/dist/orchestrator/selectiveDeepening/conflict.d.ts +8 -0
  65. package/dist/orchestrator/selectiveDeepening/conflict.js +71 -0
  66. package/dist/orchestrator/selectiveDeepening/findingFollowup.d.ts +10 -0
  67. package/dist/orchestrator/selectiveDeepening/findingFollowup.js +52 -0
  68. package/dist/orchestrator/selectiveDeepening/highRiskClean.d.ts +7 -0
  69. package/dist/orchestrator/selectiveDeepening/highRiskClean.js +44 -0
  70. package/dist/orchestrator/selectiveDeepening/index.d.ts +18 -0
  71. package/dist/orchestrator/selectiveDeepening/index.js +128 -0
  72. package/dist/orchestrator/selectiveDeepening/lensVerification.d.ts +12 -0
  73. package/dist/orchestrator/selectiveDeepening/lensVerification.js +242 -0
  74. package/dist/orchestrator/selectiveDeepening/runtimeValidation.d.ts +13 -0
  75. package/dist/orchestrator/selectiveDeepening/runtimeValidation.js +57 -0
  76. package/dist/orchestrator/selectiveDeepening/shared.d.ts +45 -0
  77. package/dist/orchestrator/selectiveDeepening/shared.js +128 -0
  78. package/dist/orchestrator/selectiveDeepening/stewardFollowup.d.ts +6 -0
  79. package/dist/orchestrator/selectiveDeepening/stewardFollowup.js +72 -0
  80. package/dist/orchestrator/selectiveDeepening.d.ts +2 -20
  81. package/dist/orchestrator/selectiveDeepening.js +6 -760
  82. package/dist/orchestrator/staleness.js +3 -3
  83. package/dist/orchestrator/structureExecutors.d.ts +5 -0
  84. package/dist/orchestrator/structureExecutors.js +94 -0
  85. package/dist/orchestrator/syntaxResolutionExecutor.d.ts +1 -1
  86. package/dist/orchestrator/synthesisExecutors.d.ts +12 -0
  87. package/dist/orchestrator/synthesisExecutors.js +90 -0
  88. package/dist/orchestrator/taskBuilder.d.ts +2 -2
  89. package/dist/orchestrator/taskBuilder.js +101 -82
  90. package/dist/providers/index.d.ts +7 -0
  91. package/dist/providers/index.js +14 -95
  92. package/dist/quota/discoveredLimits.d.ts +1 -0
  93. package/dist/quota/discoveredLimits.js +7 -1
  94. package/dist/quota/index.d.ts +0 -2
  95. package/dist/quota/index.js +1 -2
  96. package/dist/reporting/workBlocks.js +7 -4
  97. package/dist/types/reviewPlanning.d.ts +23 -16
  98. package/dist/validation/auditResults.js +97 -95
  99. package/dist/validation/sessionConfig.d.ts +2 -2
  100. package/dist/validation/sessionConfig.js +14 -7
  101. package/docs/development.md +35 -139
  102. package/docs/history.md +26 -0
  103. package/docs/product.md +41 -108
  104. package/package.json +3 -2
  105. package/schemas/audit_findings.schema.json +6 -5
  106. package/schemas/critical_flows.schema.json +3 -2
  107. package/schemas/dispatch_quota.schema.json +3 -1
  108. package/schemas/external_analyzer_results.schema.json +2 -2
  109. package/schemas/graph_bundle.schema.json +1 -1
  110. package/schemas/repo_manifest.schema.json +1 -1
  111. package/schemas/review_packets.schema.json +1 -1
  112. package/schemas/step_contract.schema.json +80 -0
  113. package/scripts/postinstall.mjs +19 -2
  114. package/skills/audit-code/opencode-command-template.txt +3 -3
  115. package/dist/orchestrator/internalExecutors.d.ts +0 -34
  116. package/dist/orchestrator/internalExecutors.js +0 -581
  117. package/dist/providers/localSubprocessProvider.d.ts +0 -9
  118. package/dist/providers/localSubprocessProvider.js +0 -18
  119. package/dist/providers/subprocessTemplateProvider.d.ts +0 -8
  120. package/dist/providers/subprocessTemplateProvider.js +0 -59
  121. package/dist/providers/vscodeTaskProvider.d.ts +0 -7
  122. package/dist/providers/vscodeTaskProvider.js +0 -14
  123. package/dist/quota/probe.d.ts +0 -10
  124. package/dist/quota/probe.js +0 -18
  125. package/docs/handoff.md +0 -204
package/README.md CHANGED
@@ -215,26 +215,6 @@ Optional backend config:
215
215
  - use `provider: "auto"` only when you want best-effort routing across installed backends
216
216
  - treat explicit provider bridges as compatibility fallback, not as the intended owner of semantic review
217
217
 
218
- ## Current Development Focus
219
-
220
- The next implementation work is tracked in:
221
-
222
- - `docs/product.md`
223
- - `docs/development.md`
224
- - `docs/handoff.md`
225
-
226
- The short version is:
227
-
228
- - keep the packet dispatch workflow verified in real host environments
229
- - make graph-informed packetization observable before adding more ecosystem-specific parsers
230
- - consolidate graph extraction and exercise generic ownership hints for analyzer-supplied module roots
231
- - add deterministic Python import, package, and test/source graph support as a core language path
232
- - use semantic/NLP-style affinity only as low-authority context unless deterministic graph evidence supports it
233
- - keep generated Codex, Claude Desktop, OpenCode, VS Code, and Antigravity guidance aligned with real host behavior
234
- - tighten the repo-local MCP-first bootstrap where host smoke tests expose friction
235
- - polish provider-assisted continuation and failure guidance
236
- - keep schema contracts and examples easy for workers and host integrations to validate
237
-
238
218
  ## Build And Test
239
219
 
240
220
  ```bash
@@ -253,6 +233,5 @@ For GitHub Actions publication and npm Trusted Publishing setup, see `docs/relea
253
233
  - `docs/contracts.md`
254
234
  - `docs/release.md`
255
235
  - `docs/development.md`
256
- - `docs/handoff.md`
257
236
  - `docs/history.md`
258
237
  - `skills/audit-code/SKILL.md`
@@ -1268,14 +1268,11 @@ async function createStoredZipBuffer(sourceDir) {
1268
1268
  return Buffer.concat([...localParts, centralDirectory, endOfCentralDirectory]);
1269
1269
  }
1270
1270
 
1271
- async function buildClaudeDesktopBundle(root, results) {
1272
- const bundleRoot = join(root, '.audit-code', 'install', 'claude-desktop', 'bundle');
1273
- const serverRoot = join(bundleRoot, 'server');
1274
- const manifestPath = join(bundleRoot, 'manifest.json');
1275
- const serverEntrypointPath = join(serverRoot, 'index.js');
1276
- const dxtPath = join(root, '.audit-code', 'install', 'claude-desktop', 'auditor-lambda.dxt');
1277
- const mcpbPath = join(root, '.audit-code', 'install', 'claude-desktop', 'auditor-lambda.mcpb');
1278
-
1271
+ // Copy the auditor's dist + schemas + skills + wrapper entrypoints (and, best
1272
+ // effort, the resolved @audit-tools/shared dist) into the Claude Desktop bundle
1273
+ // tree. Returns whether the bundle directory already existed (for the
1274
+ // created/updated result marker).
1275
+ async function copyClaudeDesktopBundleFiles(bundleRoot, serverRoot) {
1279
1276
  const bundleExisted = await fileExists(bundleRoot);
1280
1277
  await mkdir(serverRoot, { recursive: true });
1281
1278
  await cp(distEntry.replace(/dist[\\/]index\.js$/, 'dist'), join(bundleRoot, 'dist'), { recursive: true, force: true });
@@ -1300,9 +1297,13 @@ async function buildClaudeDesktopBundle(root, results) {
1300
1297
  // @audit-tools/shared not resolvable — bundle will use runtime resolution
1301
1298
  }
1302
1299
 
1303
- results.push({ path: bundleRoot, mode: bundleExisted ? 'updated' : 'created' });
1300
+ return { bundleExisted };
1301
+ }
1304
1302
 
1305
- const serverEntry = [
1303
+ // Source for the bundle's server/index.js shim: it spawns the bundled
1304
+ // audit-code.mjs in MCP mode against the user-configured repo root.
1305
+ function renderClaudeDesktopServerEntry() {
1306
+ return [
1306
1307
  "import { spawn } from 'node:child_process';",
1307
1308
  "import { dirname, join } from 'node:path';",
1308
1309
  "import { fileURLToPath } from 'node:url';",
@@ -1328,10 +1329,12 @@ async function buildClaudeDesktopBundle(root, results) {
1328
1329
  '});',
1329
1330
  '',
1330
1331
  ].join('\n');
1332
+ }
1331
1333
 
1332
- results.push(await writeGeneratedMarkdown(serverEntrypointPath, serverEntry));
1333
-
1334
- const manifest = {
1334
+ // The DXT/MCPB manifest.json describing the bundled node MCP server and its
1335
+ // Claude Desktop user-config inputs.
1336
+ function buildClaudeDesktopManifest() {
1337
+ return {
1335
1338
  manifest_version: '0.3',
1336
1339
  name: 'auditor-lambda',
1337
1340
  display_name: 'Auditor Lambda',
@@ -1386,8 +1389,26 @@ async function buildClaudeDesktopBundle(root, results) {
1386
1389
  },
1387
1390
  },
1388
1391
  };
1392
+ }
1393
+
1394
+ // Orchestrates the Claude Desktop bundle: copy files, write the server shim and
1395
+ // manifest, then zip into the .dxt / .mcpb archives. Pushes each generated file
1396
+ // into `results`.
1397
+ async function buildClaudeDesktopBundle(root, results) {
1398
+ const bundleRoot = join(root, '.audit-code', 'install', 'claude-desktop', 'bundle');
1399
+ const serverRoot = join(bundleRoot, 'server');
1400
+ const manifestPath = join(bundleRoot, 'manifest.json');
1401
+ const serverEntrypointPath = join(serverRoot, 'index.js');
1402
+ const dxtPath = join(root, '.audit-code', 'install', 'claude-desktop', 'auditor-lambda.dxt');
1403
+ const mcpbPath = join(root, '.audit-code', 'install', 'claude-desktop', 'auditor-lambda.mcpb');
1389
1404
 
1390
- results.push(await writeGeneratedJson(manifestPath, manifest));
1405
+ const { bundleExisted } = await copyClaudeDesktopBundleFiles(bundleRoot, serverRoot);
1406
+ results.push({ path: bundleRoot, mode: bundleExisted ? 'updated' : 'created' });
1407
+
1408
+ results.push(
1409
+ await writeGeneratedMarkdown(serverEntrypointPath, renderClaudeDesktopServerEntry()),
1410
+ );
1411
+ results.push(await writeGeneratedJson(manifestPath, buildClaudeDesktopManifest()));
1391
1412
 
1392
1413
  const archive = await createStoredZipBuffer(bundleRoot);
1393
1414
  results.push(await writeGeneratedBinary(dxtPath, archive));
@@ -2509,21 +2530,15 @@ async function ensureBootstrap(argv) {
2509
2530
  return payload;
2510
2531
  }
2511
2532
 
2512
- async function installBootstrap(argv, options = {}) {
2513
- const host = (getFlag(argv, '--host') ?? DEFAULT_INSTALL_HOST).toLowerCase();
2514
- const root = resolve(getFlag(argv, '--root') ?? '.');
2515
- await assertDirectoryExists(root, 'Target repository root');
2516
- const profile = getInstallProfile(host);
2517
- const promptSource = await readFile(promptAssetPath, 'utf8');
2518
- const skillSource = (await readFile(skillAssetPath, 'utf8')).replace(/\r\n/g, '\n');
2519
- const { body: promptBody } = splitFrontmatter(promptSource);
2533
+ // Compute the full asset-path map for an install profile. Each per-host path is
2534
+ // gated on its profile flag (null when the host is not part of this profile).
2535
+ function buildInstallAssetPaths(root, profile) {
2520
2536
  const installedPromptPath = join(root, '.audit-code', 'install', INSTALLED_PROMPT_FILENAME);
2521
- const legacyInstalledPromptPath = join(root, '.audit-code', 'install', 'audit-code.prompt.md');
2522
2537
  const installedSkillPath = join(root, '.audit-code', 'install', 'SKILL.md');
2523
2538
  const installGuidePath = join(root, '.audit-code', 'install', INSTALL_GUIDE_FILENAME);
2524
2539
  const installManifestPath = join(root, '.audit-code', 'install', INSTALL_MANIFEST_FILENAME);
2525
2540
  const mcpLauncherPath = join(root, '.audit-code', 'install', MCP_LAUNCHER_FILENAME);
2526
- const assetPaths = {
2541
+ return {
2527
2542
  installedPromptPath,
2528
2543
  installedSkillPath,
2529
2544
  installGuidePath,
@@ -2579,144 +2594,149 @@ async function installBootstrap(argv, options = {}) {
2579
2594
  ? join(root, '.agent', 'skills', 'audit-code', 'SKILL.md')
2580
2595
  : null,
2581
2596
  };
2597
+ }
2582
2598
 
2599
+ // Always-written core assets (installed prompt + skill, shared MCP launcher,
2600
+ // AGENTS/copilot compatibility directive blocks) plus legacy-surface cleanup.
2601
+ async function writeCoreInstallAssets(root, assetPaths, promptSource, skillSource) {
2583
2602
  const results = [];
2603
+ const legacyInstalledPromptPath = join(root, '.audit-code', 'install', 'audit-code.prompt.md');
2584
2604
  if (await fileExists(legacyInstalledPromptPath)) {
2585
2605
  await unlink(legacyInstalledPromptPath).catch(() => {});
2586
2606
  }
2607
+ results.push(await writeGeneratedMarkdown(assetPaths.installedPromptPath, promptSource));
2608
+ results.push(await writeGeneratedMarkdown(assetPaths.installedSkillPath, skillSource));
2587
2609
  results.push(
2588
- await writeGeneratedMarkdown(
2589
- installedPromptPath,
2590
- promptSource,
2591
- ),
2592
- );
2593
- results.push(await writeGeneratedMarkdown(installedSkillPath, skillSource));
2594
-
2595
- results.push(
2596
- await writeGeneratedMarkdown(mcpLauncherPath, renderSharedMcpLauncher(repoRoot)),
2610
+ await writeGeneratedMarkdown(assetPaths.mcpLauncherPath, renderSharedMcpLauncher(repoRoot)),
2597
2611
  );
2598
2612
 
2599
2613
  const compatibilityBlockTargets = [
2600
2614
  assetPaths.agentsInstructionsPath,
2601
2615
  assetPaths.copilotInstructionsPath,
2602
2616
  ].filter(Boolean);
2603
-
2604
2617
  for (const targetPath of compatibilityBlockTargets) {
2605
2618
  results.push(
2606
2619
  await writeManagedMarkdown(
2607
2620
  targetPath,
2608
2621
  buildInstallDirective(
2609
- relative(dirname(targetPath), installedPromptPath) || `./.audit-code/install/${INSTALLED_PROMPT_FILENAME}`,
2622
+ relative(dirname(targetPath), assetPaths.installedPromptPath) || `./.audit-code/install/${INSTALLED_PROMPT_FILENAME}`,
2610
2623
  ),
2611
2624
  ),
2612
2625
  );
2613
2626
  }
2614
2627
 
2615
2628
  results.push(...await removeLegacyAuditCodeSurfaceFiles(root));
2629
+ return results;
2630
+ }
2616
2631
 
2617
- if (profile.writeCodex) {
2618
- results.push(
2619
- await writeGeneratedMarkdown(
2620
- assetPaths.codexSkillPath,
2621
- skillSource,
2622
- ),
2623
- );
2624
- results.push(
2625
- await writeGeneratedMarkdown(
2626
- assetPaths.codexPromptPath,
2627
- promptSource,
2628
- ),
2629
- );
2630
- results.push(
2631
- await writeGeneratedMarkdown(
2632
- assetPaths.codexMcpSetupPath,
2633
- renderCodexMcpSetupGuide(root),
2634
- ),
2635
- );
2636
- results.push(
2637
- await writeGeneratedMarkdown(
2638
- assetPaths.codexAutomationRecipePath,
2639
- renderCodexAutomationRecipe(),
2632
+ async function writeCodexAssets(assetPaths, promptSource, skillSource, root) {
2633
+ return [
2634
+ await writeGeneratedMarkdown(assetPaths.codexSkillPath, skillSource),
2635
+ await writeGeneratedMarkdown(assetPaths.codexPromptPath, promptSource),
2636
+ await writeGeneratedMarkdown(assetPaths.codexMcpSetupPath, renderCodexMcpSetupGuide(root)),
2637
+ await writeGeneratedMarkdown(assetPaths.codexAutomationRecipePath, renderCodexAutomationRecipe()),
2638
+ ];
2639
+ }
2640
+
2641
+ // Builds the Claude Desktop DXT/MCPB bundle (mutating assetPaths with the
2642
+ // produced bundle paths) and writes the project template + remote connector.
2643
+ async function writeClaudeDesktopAssets(assetPaths, root) {
2644
+ const results = [];
2645
+ const claudeDesktopBundle = await buildClaudeDesktopBundle(root, results);
2646
+ assetPaths.claudeDesktopDxtPath = claudeDesktopBundle.dxtPath;
2647
+ assetPaths.claudeDesktopMcpbPath = claudeDesktopBundle.mcpbPath;
2648
+ results.push(
2649
+ await writeGeneratedMarkdown(
2650
+ assetPaths.claudeDesktopProjectTemplatePath,
2651
+ renderClaudeDesktopProjectTemplate(),
2652
+ ),
2653
+ );
2654
+ results.push(
2655
+ await writeGeneratedJson(
2656
+ assetPaths.claudeDesktopRemoteConnectorPath,
2657
+ JSON.parse(renderClaudeDesktopRemoteConnectorTemplate()),
2658
+ ),
2659
+ );
2660
+ return results;
2661
+ }
2662
+
2663
+ async function writeOpenCodeAssets(assetPaths, root) {
2664
+ return [
2665
+ await writeMergedGeneratedJson(
2666
+ assetPaths.opencodeConfigPath,
2667
+ 'OpenCode project config',
2668
+ (existing) => buildMergedOpenCodeProjectConfig(existing, root),
2669
+ ),
2670
+ ];
2671
+ }
2672
+
2673
+ async function writeVSCodeAssets(assetPaths, promptBody) {
2674
+ return [
2675
+ await writeGeneratedMarkdown(
2676
+ assetPaths.vscodePromptPath,
2677
+ renderPromptFile(
2678
+ {
2679
+ name: 'audit-code',
2680
+ description: 'Autonomous local loop code auditing',
2681
+ agent: 'auditor',
2682
+ },
2683
+ promptBody,
2640
2684
  ),
2641
- );
2642
- }
2685
+ ),
2686
+ await writeGeneratedMarkdown(assetPaths.vscodeAgentPath, renderVSCodeAgentFile()),
2687
+ await writeMergedGeneratedJson(
2688
+ assetPaths.vscodeMcpConfigPath,
2689
+ 'VS Code MCP config',
2690
+ buildMergedVSCodeMcpConfig,
2691
+ ),
2692
+ ];
2693
+ }
2694
+
2695
+ async function writeAntigravityAssets(assetPaths, promptBody, skillSource, root) {
2696
+ return [
2697
+ await writeGeneratedMarkdown(
2698
+ assetPaths.antigravityPlanningGuidePath,
2699
+ renderAntigravityPlanningGuide(root),
2700
+ ),
2701
+ await writeGeneratedMarkdown(assetPaths.geminiCommandPath, renderGeminiCommandToml(promptBody)),
2702
+ await writeGeneratedMarkdown(assetPaths.antigravitySkillPath, skillSource),
2703
+ ];
2704
+ }
2705
+
2706
+ async function installBootstrap(argv, options = {}) {
2707
+ const host = (getFlag(argv, '--host') ?? DEFAULT_INSTALL_HOST).toLowerCase();
2708
+ const root = resolve(getFlag(argv, '--root') ?? '.');
2709
+ await assertDirectoryExists(root, 'Target repository root');
2710
+ const profile = getInstallProfile(host);
2711
+ const promptSource = await readFile(promptAssetPath, 'utf8');
2712
+ const skillSource = (await readFile(skillAssetPath, 'utf8')).replace(/\r\n/g, '\n');
2713
+ const { body: promptBody } = splitFrontmatter(promptSource);
2714
+ const assetPaths = buildInstallAssetPaths(root, profile);
2715
+ const {
2716
+ installedPromptPath,
2717
+ installedSkillPath,
2718
+ installGuidePath,
2719
+ installManifestPath,
2720
+ mcpLauncherPath,
2721
+ } = assetPaths;
2643
2722
 
2723
+ const results = [];
2724
+ results.push(...await writeCoreInstallAssets(root, assetPaths, promptSource, skillSource));
2725
+
2726
+ if (profile.writeCodex) {
2727
+ results.push(...await writeCodexAssets(assetPaths, promptSource, skillSource, root));
2728
+ }
2644
2729
  if (profile.writeClaudeDesktop) {
2645
- const claudeDesktopBundle = await buildClaudeDesktopBundle(root, results);
2646
- assetPaths.claudeDesktopDxtPath = claudeDesktopBundle.dxtPath;
2647
- assetPaths.claudeDesktopMcpbPath = claudeDesktopBundle.mcpbPath;
2648
- results.push(
2649
- await writeGeneratedMarkdown(
2650
- assetPaths.claudeDesktopProjectTemplatePath,
2651
- renderClaudeDesktopProjectTemplate(),
2652
- ),
2653
- );
2654
- results.push(
2655
- await writeGeneratedJson(
2656
- assetPaths.claudeDesktopRemoteConnectorPath,
2657
- JSON.parse(renderClaudeDesktopRemoteConnectorTemplate()),
2658
- ),
2659
- );
2730
+ results.push(...await writeClaudeDesktopAssets(assetPaths, root));
2660
2731
  }
2661
-
2662
2732
  if (profile.writeOpenCode) {
2663
- results.push(
2664
- await writeMergedGeneratedJson(
2665
- assetPaths.opencodeConfigPath,
2666
- 'OpenCode project config',
2667
- (existing) => buildMergedOpenCodeProjectConfig(existing, root),
2668
- ),
2669
- );
2733
+ results.push(...await writeOpenCodeAssets(assetPaths, root));
2670
2734
  }
2671
-
2672
2735
  if (profile.writeVSCode) {
2673
- results.push(
2674
- await writeGeneratedMarkdown(
2675
- assetPaths.vscodePromptPath,
2676
- renderPromptFile(
2677
- {
2678
- name: 'audit-code',
2679
- description: 'Autonomous local loop code auditing',
2680
- agent: 'auditor',
2681
- },
2682
- promptBody,
2683
- ),
2684
- ),
2685
- );
2686
- results.push(
2687
- await writeGeneratedMarkdown(
2688
- assetPaths.vscodeAgentPath,
2689
- renderVSCodeAgentFile(),
2690
- ),
2691
- );
2692
- results.push(
2693
- await writeMergedGeneratedJson(
2694
- assetPaths.vscodeMcpConfigPath,
2695
- 'VS Code MCP config',
2696
- buildMergedVSCodeMcpConfig,
2697
- ),
2698
- );
2736
+ results.push(...await writeVSCodeAssets(assetPaths, promptBody));
2699
2737
  }
2700
-
2701
2738
  if (profile.writeAntigravity) {
2702
- results.push(
2703
- await writeGeneratedMarkdown(
2704
- assetPaths.antigravityPlanningGuidePath,
2705
- renderAntigravityPlanningGuide(root),
2706
- ),
2707
- );
2708
- results.push(
2709
- await writeGeneratedMarkdown(
2710
- assetPaths.geminiCommandPath,
2711
- renderGeminiCommandToml(promptBody),
2712
- ),
2713
- );
2714
- results.push(
2715
- await writeGeneratedMarkdown(
2716
- assetPaths.antigravitySkillPath,
2717
- skillSource,
2718
- ),
2719
- );
2739
+ results.push(...await writeAntigravityAssets(assetPaths, promptBody, skillSource, root));
2720
2740
  }
2721
2741
 
2722
2742
  const hostGuidance = buildHostCatalog({
@@ -1,10 +1,13 @@
1
1
  export function normalizeGenericExternalResults(tool, items) {
2
+ const valid = items.filter((item) => item.path && item.summary);
3
+ const dropped = items.length - valid.length;
4
+ if (dropped > 0) {
5
+ process.stderr.write(`[audit-code] normalizeExternal: dropped ${dropped}/${items.length} ${tool} finding(s) missing path or summary\n`);
6
+ }
2
7
  return {
3
8
  tool,
4
9
  generated_at: new Date().toISOString(),
5
- results: items
6
- .filter((item) => item.path && item.summary)
7
- .map((item, index) => ({
10
+ results: valid.map((item, index) => ({
8
11
  id: item.id ?? `${tool}-${index + 1}`,
9
12
  category: item.category ?? "unknown",
10
13
  severity: item.severity ?? "unknown",
@@ -51,7 +51,6 @@ export declare function getTimeoutMs(argv: string[], sessionConfig: SessionConfi
51
51
  export declare function getExplicitProvider(argv: string[]): string | undefined;
52
52
  export declare function getHostModel(argv: string[]): string | null;
53
53
  export declare function getHostMaxActiveSubagents(argv: string[]): number | null;
54
- export declare function getQuotaProbeMode(argv: string[], sessionConfig: SessionConfig): "auto" | "never" | "force";
55
54
  export declare function resolveRunProviderName(argv: string[], sessionConfig: SessionConfig): string;
56
55
  export declare function chunkArray<T>(arr: T[], size: number): T[][];
57
56
  export declare function getUiMode(argv: string[], fallback?: UiMode): UiMode;
package/dist/cli/args.js CHANGED
@@ -185,12 +185,6 @@ export function getHostModel(argv) {
185
185
  export function getHostMaxActiveSubagents(argv) {
186
186
  return parsePositiveIntegerFlag(argv, "--host-max-active-subagents") ?? null;
187
187
  }
188
- export function getQuotaProbeMode(argv, sessionConfig) {
189
- const raw = getFlag(argv, "--quota-probe") ?? sessionConfig.quota?.probe ?? "auto";
190
- if (raw === "auto" || raw === "never" || raw === "force")
191
- return raw;
192
- return "auto";
193
- }
194
188
  export function resolveRunProviderName(argv, sessionConfig) {
195
189
  return resolveFreshSessionProviderName(getExplicitProvider(argv), sessionConfig);
196
190
  }
@@ -84,7 +84,13 @@ export async function runAuditStep(options) {
84
84
  opentoken: options.opentoken,
85
85
  runLogger,
86
86
  });
87
- await writeCoreArtifacts(options.artifactsDir, result.updated_bundle);
87
+ // Prune: result.updated_bundle is the full accumulated bundle, so an artifact
88
+ // an executor cleared to `undefined` must be removed from disk (not left to
89
+ // reload as a stale "present" artifact). Safe only because this is the
90
+ // authoritative per-step persist.
91
+ await writeCoreArtifacts(options.artifactsDir, result.updated_bundle, {
92
+ prune: true,
93
+ });
88
94
  const archivedPendingResults = await maybeArchiveLegacyPendingResults(options.auditResultsPath);
89
95
  if (archivedPendingResults) {
90
96
  result.progress_summary +=
@@ -1,7 +1,7 @@
1
1
  import { mkdir, readFile, writeFile } from "node:fs/promises";
2
2
  import { existsSync } from "node:fs";
3
3
  import { isAbsolute, join, relative, resolve } from "node:path";
4
- import { isFileMissingError, readJsonFile, writeJsonFile } from "@audit-tools/shared";
4
+ import { isFileMissingError, readJsonFile, writeJsonFile, DEFAULT_EMPIRICAL_HALF_LIFE_HOURS, } from "@audit-tools/shared";
5
5
  import { buildQuotaSource } from "@audit-tools/shared/quota/compositeQuotaSource";
6
6
  import { loadArtifactBundle } from "../io/artifacts.js";
7
7
  import { orderTasksForPacketReview, buildReviewPackets, sizeIndexFromManifest, } from "../orchestrator/reviewPackets.js";
@@ -480,7 +480,8 @@ export async function prepareDispatchArtifacts(params) {
480
480
  ?? null;
481
481
  const dispatchCachedLimits = await lookupDiscoveredLimits(quotaProviderKey).catch(() => null);
482
482
  const discoveredLimits = mergeDiscoveredLimits(providerLimits, dispatchCachedLimits);
483
- const halfLifeHours = sessionConfig.quota?.empirical_half_life_hours ?? 24;
483
+ const halfLifeHours = sessionConfig.quota?.empirical_half_life_hours ??
484
+ DEFAULT_EMPIRICAL_HALF_LIFE_HOURS;
484
485
  const quotaSource = buildQuotaSource({ halfLifeHours });
485
486
  const quotaSourceSnapshot = await quotaSource.queryCurrentUsage(quotaProviderKey).catch(() => null);
486
487
  const waveSchedule = scheduleWave({
@@ -3,9 +3,12 @@ import { countLines } from "./args.js";
3
3
  // Line-count helpers extracted from cli.ts. Pure functions over the repo
4
4
  // manifest / task file paths — used to annotate audit tasks with per-file line
5
5
  // counts and to build line indexes for prompt rendering.
6
+ // How many files to read concurrently when counting lines, bounding open file
7
+ // descriptors so a large repo manifest does not exhaust the fd limit.
8
+ const LINE_COUNT_BATCH_SIZE = 25;
6
9
  export async function buildLineIndex(root, repoManifest) {
7
10
  const entries = [];
8
- const batchSize = 25;
11
+ const batchSize = LINE_COUNT_BATCH_SIZE;
9
12
  for (let i = 0; i < repoManifest.files.length; i += batchSize) {
10
13
  const batch = repoManifest.files.slice(i, i + batchSize);
11
14
  const results = await Promise.all(batch.map(async (file) => {
@@ -0,0 +1 @@
1
+ export declare function cmdMergeAndIngest(argv: string[]): Promise<void>;