auditor-lambda 0.1.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 (199) hide show
  1. package/README.md +173 -0
  2. package/audit-code-wrapper-lib.mjs +905 -0
  3. package/audit-code.mjs +13 -0
  4. package/dist/adapters/coverageSummary.d.ts +8 -0
  5. package/dist/adapters/coverageSummary.js +13 -0
  6. package/dist/adapters/eslint.d.ts +13 -0
  7. package/dist/adapters/eslint.js +21 -0
  8. package/dist/adapters/normalizeExternal.d.ts +12 -0
  9. package/dist/adapters/normalizeExternal.js +19 -0
  10. package/dist/adapters/npmAudit.d.ts +15 -0
  11. package/dist/adapters/npmAudit.js +12 -0
  12. package/dist/adapters/semgrep.d.ts +22 -0
  13. package/dist/adapters/semgrep.js +14 -0
  14. package/dist/cli.d.ts +1 -0
  15. package/dist/cli.js +724 -0
  16. package/dist/coverage.d.ts +11 -0
  17. package/dist/coverage.js +102 -0
  18. package/dist/extractors/bucketing.d.ts +7 -0
  19. package/dist/extractors/bucketing.js +72 -0
  20. package/dist/extractors/disposition.d.ts +4 -0
  21. package/dist/extractors/disposition.js +41 -0
  22. package/dist/extractors/fileInventory.d.ts +7 -0
  23. package/dist/extractors/fileInventory.js +44 -0
  24. package/dist/extractors/flows.d.ts +5 -0
  25. package/dist/extractors/flows.js +125 -0
  26. package/dist/extractors/fsIntake.d.ts +8 -0
  27. package/dist/extractors/fsIntake.js +66 -0
  28. package/dist/extractors/graph.d.ts +4 -0
  29. package/dist/extractors/graph.js +46 -0
  30. package/dist/extractors/ignore.d.ts +1 -0
  31. package/dist/extractors/ignore.js +17 -0
  32. package/dist/extractors/risk.d.ts +5 -0
  33. package/dist/extractors/risk.js +45 -0
  34. package/dist/extractors/surfaces.d.ts +4 -0
  35. package/dist/extractors/surfaces.js +40 -0
  36. package/dist/index.d.ts +1 -0
  37. package/dist/index.js +1 -0
  38. package/dist/io/artifacts.d.ts +38 -0
  39. package/dist/io/artifacts.js +100 -0
  40. package/dist/io/json.d.ts +8 -0
  41. package/dist/io/json.js +96 -0
  42. package/dist/io/runArtifacts.d.ts +14 -0
  43. package/dist/io/runArtifacts.js +37 -0
  44. package/dist/orchestrator/advance.d.ts +24 -0
  45. package/dist/orchestrator/advance.js +104 -0
  46. package/dist/orchestrator/artifactMetadata.d.ts +4 -0
  47. package/dist/orchestrator/artifactMetadata.js +111 -0
  48. package/dist/orchestrator/autoFixExecutor.d.ts +3 -0
  49. package/dist/orchestrator/autoFixExecutor.js +63 -0
  50. package/dist/orchestrator/chunking.d.ts +5 -0
  51. package/dist/orchestrator/chunking.js +13 -0
  52. package/dist/orchestrator/dependencyMap.d.ts +1 -0
  53. package/dist/orchestrator/dependencyMap.js +82 -0
  54. package/dist/orchestrator/executors.d.ts +6 -0
  55. package/dist/orchestrator/executors.js +52 -0
  56. package/dist/orchestrator/flowCoverage.d.ts +4 -0
  57. package/dist/orchestrator/flowCoverage.js +44 -0
  58. package/dist/orchestrator/flowPlanning.d.ts +3 -0
  59. package/dist/orchestrator/flowPlanning.js +42 -0
  60. package/dist/orchestrator/flowRequeue.d.ts +5 -0
  61. package/dist/orchestrator/flowRequeue.js +58 -0
  62. package/dist/orchestrator/internalExecutors.d.ts +16 -0
  63. package/dist/orchestrator/internalExecutors.js +212 -0
  64. package/dist/orchestrator/nextStep.d.ts +9 -0
  65. package/dist/orchestrator/nextStep.js +44 -0
  66. package/dist/orchestrator/planning.d.ts +4 -0
  67. package/dist/orchestrator/planning.js +62 -0
  68. package/dist/orchestrator/requeue.d.ts +3 -0
  69. package/dist/orchestrator/requeue.js +25 -0
  70. package/dist/orchestrator/requeueCommand.d.ts +10 -0
  71. package/dist/orchestrator/requeueCommand.js +27 -0
  72. package/dist/orchestrator/resultIngestion.d.ts +2 -0
  73. package/dist/orchestrator/resultIngestion.js +13 -0
  74. package/dist/orchestrator/runtimeValidation.d.ts +7 -0
  75. package/dist/orchestrator/runtimeValidation.js +103 -0
  76. package/dist/orchestrator/runtimeValidationUpdate.d.ts +2 -0
  77. package/dist/orchestrator/runtimeValidationUpdate.js +52 -0
  78. package/dist/orchestrator/staleness.d.ts +2 -0
  79. package/dist/orchestrator/staleness.js +83 -0
  80. package/dist/orchestrator/state.d.ts +3 -0
  81. package/dist/orchestrator/state.js +85 -0
  82. package/dist/orchestrator/syntaxResolutionExecutor.d.ts +3 -0
  83. package/dist/orchestrator/syntaxResolutionExecutor.js +99 -0
  84. package/dist/orchestrator/taskBuilder.d.ts +12 -0
  85. package/dist/orchestrator/taskBuilder.js +154 -0
  86. package/dist/orchestrator/unitBuilder.d.ts +3 -0
  87. package/dist/orchestrator/unitBuilder.js +145 -0
  88. package/dist/orchestrator.d.ts +6 -0
  89. package/dist/orchestrator.js +33 -0
  90. package/dist/prompts/renderWorkerPrompt.d.ts +2 -0
  91. package/dist/prompts/renderWorkerPrompt.js +19 -0
  92. package/dist/providers/claudeCodeProvider.d.ts +8 -0
  93. package/dist/providers/claudeCodeProvider.js +20 -0
  94. package/dist/providers/index.d.ts +7 -0
  95. package/dist/providers/index.js +77 -0
  96. package/dist/providers/localSubprocessProvider.d.ts +5 -0
  97. package/dist/providers/localSubprocessProvider.js +13 -0
  98. package/dist/providers/opencodeProvider.d.ts +8 -0
  99. package/dist/providers/opencodeProvider.js +15 -0
  100. package/dist/providers/spawnLoggedCommand.d.ts +2 -0
  101. package/dist/providers/spawnLoggedCommand.js +48 -0
  102. package/dist/providers/subprocessTemplateProvider.d.ts +8 -0
  103. package/dist/providers/subprocessTemplateProvider.js +41 -0
  104. package/dist/providers/types.d.ts +22 -0
  105. package/dist/providers/types.js +1 -0
  106. package/dist/providers/vscodeTaskProvider.d.ts +8 -0
  107. package/dist/providers/vscodeTaskProvider.js +14 -0
  108. package/dist/reporting/mergeFindings.d.ts +4 -0
  109. package/dist/reporting/mergeFindings.js +136 -0
  110. package/dist/reporting/rootCause.d.ts +11 -0
  111. package/dist/reporting/rootCause.js +69 -0
  112. package/dist/reporting/synthesis.d.ts +21 -0
  113. package/dist/reporting/synthesis.js +55 -0
  114. package/dist/supervisor/operatorHandoff.d.ts +37 -0
  115. package/dist/supervisor/operatorHandoff.js +144 -0
  116. package/dist/supervisor/runLedger.d.ts +3 -0
  117. package/dist/supervisor/runLedger.js +17 -0
  118. package/dist/supervisor/sessionConfig.d.ts +4 -0
  119. package/dist/supervisor/sessionConfig.js +26 -0
  120. package/dist/types/artifactMetadata.d.ts +8 -0
  121. package/dist/types/artifactMetadata.js +1 -0
  122. package/dist/types/auditState.d.ts +14 -0
  123. package/dist/types/auditState.js +1 -0
  124. package/dist/types/disposition.d.ts +9 -0
  125. package/dist/types/disposition.js +1 -0
  126. package/dist/types/externalAnalyzer.d.ts +16 -0
  127. package/dist/types/externalAnalyzer.js +1 -0
  128. package/dist/types/flowCoverage.d.ts +11 -0
  129. package/dist/types/flowCoverage.js +1 -0
  130. package/dist/types/flows.d.ts +11 -0
  131. package/dist/types/flows.js +1 -0
  132. package/dist/types/graph.d.ts +18 -0
  133. package/dist/types/graph.js +1 -0
  134. package/dist/types/risk.d.ts +9 -0
  135. package/dist/types/risk.js +1 -0
  136. package/dist/types/runLedger.d.ts +13 -0
  137. package/dist/types/runLedger.js +1 -0
  138. package/dist/types/runtimeValidation.d.ts +22 -0
  139. package/dist/types/runtimeValidation.js +1 -0
  140. package/dist/types/sessionConfig.d.ts +27 -0
  141. package/dist/types/sessionConfig.js +1 -0
  142. package/dist/types/surfaces.d.ts +11 -0
  143. package/dist/types/surfaces.js +1 -0
  144. package/dist/types/workerResult.d.ts +13 -0
  145. package/dist/types/workerResult.js +1 -0
  146. package/dist/types/workerSession.d.ts +13 -0
  147. package/dist/types/workerSession.js +1 -0
  148. package/dist/types.d.ts +104 -0
  149. package/dist/types.js +1 -0
  150. package/dist/validation/artifacts.d.ts +3 -0
  151. package/dist/validation/artifacts.js +191 -0
  152. package/dist/validation/basic.d.ts +5 -0
  153. package/dist/validation/basic.js +9 -0
  154. package/dist/validation/sessionConfig.d.ts +6 -0
  155. package/dist/validation/sessionConfig.js +139 -0
  156. package/docs/agent-integrations.md +237 -0
  157. package/docs/agent-roles.md +69 -0
  158. package/docs/architecture.md +90 -0
  159. package/docs/artifacts.md +69 -0
  160. package/docs/bootstrap-install.md +79 -0
  161. package/docs/contract.md +140 -0
  162. package/docs/github-copilot.md +50 -0
  163. package/docs/model-selection.md +86 -0
  164. package/docs/next-steps.md +161 -0
  165. package/docs/packaging.md +88 -0
  166. package/docs/pipeline.md +152 -0
  167. package/docs/product-direction.md +111 -0
  168. package/docs/production-launch-bar.md +83 -0
  169. package/docs/production-readiness.md +52 -0
  170. package/docs/repo-layout.md +30 -0
  171. package/docs/run-flow.md +49 -0
  172. package/docs/session-config.md +232 -0
  173. package/docs/supervisor.md +83 -0
  174. package/docs/usage.md +172 -0
  175. package/docs/windows-setup.md +146 -0
  176. package/package.json +56 -0
  177. package/schemas/audit-code-v1alpha1.schema.json +191 -0
  178. package/schemas/audit_result.schema.json +48 -0
  179. package/schemas/audit_state.schema.json +36 -0
  180. package/schemas/audit_task.schema.json +49 -0
  181. package/schemas/blind_spot_register.schema.json +40 -0
  182. package/schemas/coverage_matrix.schema.json +50 -0
  183. package/schemas/critical_flows.schema.json +38 -0
  184. package/schemas/external_analyzer_results.schema.json +31 -0
  185. package/schemas/file_disposition.schema.json +33 -0
  186. package/schemas/finding.schema.json +62 -0
  187. package/schemas/flow_coverage.schema.json +44 -0
  188. package/schemas/graph_bundle.schema.json +55 -0
  189. package/schemas/merged_findings.schema.json +14 -0
  190. package/schemas/repo_manifest.schema.json +37 -0
  191. package/schemas/risk_register.schema.json +30 -0
  192. package/schemas/root_cause_clusters.schema.json +31 -0
  193. package/schemas/runtime_validation_report.schema.json +34 -0
  194. package/schemas/runtime_validation_tasks.schema.json +36 -0
  195. package/schemas/surface_manifest.schema.json +32 -0
  196. package/schemas/synthesis_report.schema.json +61 -0
  197. package/schemas/unit_manifest.schema.json +36 -0
  198. package/skills/audit-code/SKILL.md +54 -0
  199. package/skills/audit-code/audit-code.prompt.md +66 -0
@@ -0,0 +1,83 @@
1
+ # Production Launch Bar
2
+
3
+ This document defines the minimum bar this repository should meet before a version is described as production-ready.
4
+
5
+ It is intentionally narrower than the broader product roadmap in `docs/next-steps.md`.
6
+
7
+ ## Supported product surfaces
8
+
9
+ The current product surfaces are:
10
+
11
+ 1. `/audit-code` in conversation as the canonical user-facing route
12
+ 2. `audit-code prompt-path` as the stable way to locate the packaged prompt asset
13
+ 3. `audit-code install` as the preferred repo-local bootstrap installer
14
+ 4. `audit-code` as the repo-local backend fallback wrapper
15
+
16
+ Anything below `dist/index.js` remains a backend or development interface rather than the primary end-user contract.
17
+
18
+ ## Supported backend expectations
19
+
20
+ ### Node and package runtime
21
+
22
+ - Node `>=20` is the minimum supported runtime from `package.json`
23
+ - packaged installs must include:
24
+ - `audit-code`
25
+ - `audit-code-wrapper-lib.mjs`
26
+ - `skills/audit-code/audit-code.prompt.md`
27
+ - `schemas/audit-code-v1alpha1.schema.json`
28
+ - the checked-in `dist/` output is part of the shipped runtime contract for installed usage
29
+
30
+ ### Backend providers
31
+
32
+ - `local-subprocess` is the safest default fallback and must keep working without extra provider setup
33
+ - `claude-code`, `opencode`, `subprocess-template`, and `vscode-task` are supported backend adapters when configured correctly
34
+ - `provider: "auto"` is best-effort routing, not a stronger support guarantee than the underlying resolved provider
35
+
36
+ ### Host surfaces
37
+
38
+ - ChatGPT-style project conversations are the intended `/audit-code` product surface
39
+ - VS Code / GitHub Copilot, OpenCode, and Claude Code repositories are supported through `audit-code install`
40
+ - editor integrations that import `skills/audit-code/audit-code.prompt.md` are supported as prompt-based integrations
41
+ - no editor-specific native install surface should be called production-ready until it has explicit documentation and a repeatable verification path
42
+
43
+ ## Required verification before calling a release production-ready
44
+
45
+ Run this from the repository root:
46
+
47
+ ```bash
48
+ npm ci
49
+ npm run verify:release
50
+ ```
51
+
52
+ `npm run verify:release` is the in-repo minimum release gate. It currently covers:
53
+
54
+ - TypeScript typecheck
55
+ - full automated test suite
56
+ - linked-install `audit-code` smoke coverage
57
+ - packaged-install `audit-code` smoke coverage
58
+ - tarball contract verification for required shipped assets and runtime entrypoints
59
+ - packaged and linked verification of the bootstrap install path
60
+
61
+ In addition to the in-repo gate, production readiness still requires these external checks:
62
+
63
+ 1. confirm npm package-name ownership and intended publish target
64
+ 2. confirm `NPM_TOKEN` availability for the publish workflow
65
+ 3. run a real pre-release or dry-run publish from the release path you intend to use
66
+
67
+ ## Operator validation expectations
68
+
69
+ Before treating the backend fallback as healthy for a repository, `audit-code validate` should pass with zero issues.
70
+
71
+ That validation now covers:
72
+
73
+ - artifact-bundle consistency
74
+ - `session-config.json` shape
75
+ - explicit provider readiness for configured external CLIs
76
+
77
+ ## Current residual risk
78
+
79
+ This repository has a clear backend release gate, but it still should not be called fully production-ready until:
80
+
81
+ 1. hosts without a verified repo-local slash-command surface still have a comparably low-friction bootstrap path
82
+ 2. interactive continuation is smoother when assisted review must continue through a provider
83
+ 3. external publish operations are proven end to end
@@ -0,0 +1,52 @@
1
+ # Production Readiness
2
+
3
+ ## Verdict
4
+
5
+ As of April 17, 2026, this repository is not yet ready for a public production launch.
6
+
7
+ It is in good shape for a controlled alpha or beta release:
8
+
9
+ - TypeScript build passes
10
+ - automated test suite passes
11
+ - linked-install smoke coverage passes
12
+ - packaged-install smoke coverage passes
13
+ - packaged tarball contract verification passes
14
+ - malformed config and corrupted artifact handling are explicit
15
+ - blocked fallback runs now emit structured operator handoff guidance
16
+ - supported repo-local hosts now share a bootstrap install path via `audit-code install`
17
+
18
+ ## Why It Is Not Yet Production-Ready
19
+
20
+ The biggest remaining gaps are product and release-operational, not core wrapper correctness:
21
+
22
+ 1. npm publication is not fully proven end to end.
23
+ The repo has publish automation, but package-name ownership and registry credentials still need to be confirmed outside the codebase.
24
+ 2. The primary conversation-first product still has setup friction on hosts without a verified repo-local slash-command surface.
25
+ VS Code / Copilot, OpenCode, and Claude Code now share a bootstrap path, but Claude Desktop, Antigravity, and other hosts still need more work.
26
+ 3. Assisted-review continuation is still only partially solved.
27
+ The fallback wrapper now explains blocked states much better, but the smoothest path is still missing when an interactive provider should continue the review directly.
28
+
29
+ The explicit launch bar is now documented in `docs/production-launch-bar.md`, and the in-repo release gate is codified as `npm run verify:release`.
30
+
31
+ ## Required Next Steps
32
+
33
+ 1. Confirm release operations externally.
34
+ Validate npm package-name availability and ownership for `auditor-lambda`, confirm `NPM_TOKEN` access in GitHub Actions, and run a real pre-release or dry-run publish from the release workflow path.
35
+ 2. Extend bootstrap coverage beyond the currently automated hosts.
36
+ Keep `audit-code install` stable for VS Code / Copilot, OpenCode, and Claude Code, and close the remaining friction gap for hosts that still lack a verified repo-local install surface.
37
+ 3. Improve interactive continuation.
38
+ When an interactive provider is configured, continue through provider-assisted review with less operator handoff and less manual evidence re-import.
39
+
40
+ ## Nice-To-Have Follow-On Work
41
+
42
+ - expand host-specific setup guides once the first native integration lands
43
+ - keep release smoke coverage and contract tests fast enough to stay in the publish gate
44
+ - keep `docs/production-launch-bar.md` aligned with the real verification and support surface
45
+ - preserve the packaged prompt asset and `audit-code prompt-path` as hard compatibility guarantees
46
+
47
+ ## Related Docs
48
+
49
+ - `docs/next-steps.md`
50
+ - `docs/packaging.md`
51
+ - `docs/agent-integrations.md`
52
+ - `docs/production-launch-bar.md`
@@ -0,0 +1,30 @@
1
+ # Repository layout
2
+
3
+ ## Top-level purpose
4
+
5
+ - `docs/`: architecture, pipeline, layout, and design notes
6
+ - `schemas/`: JSON schemas for stable intermediate artifacts
7
+ - `skills/audit-code/`: portable prompt assets and skill-facing product instructions
8
+ - `src/`: implementation code for extraction, orchestration, coverage, and reporting
9
+ - `examples/`: example artifacts demonstrating expected shapes
10
+ - `.audit-artifacts/`: runtime-generated local artifact bundle for fallback wrapper runs; do not commit it
11
+ - `dist/`: checked-in compiled runtime output used by the packaged entrypoint
12
+ - `docs/next-steps.md`: current roadmap and next implementation notes
13
+ - `docs/production-launch-bar.md`: explicit minimum launch criteria and release verification bar
14
+ - `docs/production-readiness.md`: current production-readiness verdict and launch blockers
15
+
16
+ ## Near-term code layout
17
+
18
+ - `src/extractors/`: deterministic collectors and heuristic classifiers
19
+ - `src/orchestrator/`: task construction, chunking, pass logic, and requeue support
20
+ - `src/coverage/` or `src/coverage.ts`: coverage accounting helpers
21
+ - `src/reporting/`: result merging and remediation views
22
+ - `src/types.ts`: shared TypeScript interfaces mirroring the JSON schemas as closely as practical
23
+
24
+ ## Skill portability rule
25
+
26
+ The repo should be usable even when the host environment changes. For that reason:
27
+
28
+ - prompts should remain plain markdown
29
+ - artifacts should remain plain JSON
30
+ - orchestration logic should not depend on one editor or one agent runtime
@@ -0,0 +1,49 @@
1
+ # Run flow
2
+
3
+ The canonical product route is `/audit-code` in conversation.
4
+
5
+ This document describes the backend execution flow that supports that conversational route and the repo-local fallback wrapper.
6
+
7
+ ## Current backend execution path
8
+
9
+ 1. Build or import a repository manifest.
10
+ 2. Build audit units from the repository manifest.
11
+ 3. Initialize a coverage matrix from the file list.
12
+ 4. Apply unit-to-file coverage requirements.
13
+ 5. Build initial audit tasks.
14
+ 6. Dispatch those tasks to LLM agents or other runtimes.
15
+ 7. Ingest structured audit results.
16
+ 8. Apply reviewed ranges and completed lenses to the coverage matrix.
17
+ 9. Build requeue tasks for missing lenses or uncovered ranges.
18
+ 10. Repeat until coverage rules are satisfied.
19
+ 11. Synthesize findings into merged outputs.
20
+
21
+ ## Current backend capability
22
+
23
+ The current TypeScript implementation already covers:
24
+
25
+ - repo intake and ignore handling
26
+ - structure and planning artifact generation
27
+ - reviewed-range ingestion from audit results
28
+ - runtime validation update ingestion
29
+ - synthesis and completion tracking
30
+ - backend provider handoff for interactive or assisted review
31
+
32
+ ## Product interpretation
33
+
34
+ - the conversation route should hide this state machine behind `/audit-code`
35
+ - the repo-local `audit-code` wrapper is fallback infrastructure for operators and local harnesses
36
+ - provider adapters and artifact plumbing are backend details, not the primary product story
37
+ - when fallback execution blocks, the wrapper should still leave behind explicit operator handoff files and suggested evidence-import paths
38
+
39
+ ## Next backend implementation steps
40
+
41
+ The next backend-focused work should support the conversation route more directly by:
42
+
43
+ - reducing operator friction when the backend reaches a blocked handoff
44
+ - improving continuation when interactive providers are configured
45
+ - keeping evidence import and runtime-update handoff paths explicit and easier to follow
46
+
47
+ Broader product priorities are tracked in:
48
+
49
+ - `docs/next-steps.md`
@@ -0,0 +1,232 @@
1
+ # session-config
2
+
3
+ This file only applies to the backend fallback CLI.
4
+
5
+ The canonical `/audit-code` conversation route should not require users to touch it.
6
+
7
+ Backend provider configuration lives at:
8
+
9
+ ```text
10
+ .audit-artifacts/session-config.json
11
+ ```
12
+
13
+ This file is optional.
14
+
15
+ If it does not exist, the backend defaults to its built-in behavior.
16
+
17
+ If it exists but contains invalid values, the backend now fails loudly before starting worker runs.
18
+ You can also check it explicitly with:
19
+
20
+ ```bash
21
+ audit-code validate
22
+ ```
23
+
24
+ ## Supported fields
25
+
26
+ ```json
27
+ {
28
+ "provider": "local-subprocess",
29
+ "timeout_ms": 1800000,
30
+ "ui_mode": "headless"
31
+ }
32
+ ```
33
+
34
+ ### `provider`
35
+
36
+ Supported values:
37
+
38
+ - `auto`
39
+ - `local-subprocess`
40
+ - `subprocess-template`
41
+ - `claude-code`
42
+ - `opencode`
43
+ - `vscode-task`
44
+
45
+ ### `timeout_ms`
46
+
47
+ Worker-run timeout in milliseconds.
48
+
49
+ ### `ui_mode`
50
+
51
+ Supported values:
52
+
53
+ - `headless`
54
+ - `visible`
55
+
56
+ Use `visible` when you want stdout and stderr mirrored into the current terminal while the provider runs.
57
+
58
+ ## Auto provider mode
59
+
60
+ `auto` is an explicit opt-in mode.
61
+
62
+ If `provider` is omitted entirely, the backend still defaults to `local-subprocess`.
63
+
64
+ When `provider` is set to `auto`, resolution works like this:
65
+
66
+ 1. use `vscode-task` when running under VS Code and a `vscode_task.command_template` is configured
67
+ 2. otherwise use `subprocess-template` when `subprocess_template.command_template` is configured
68
+ 3. otherwise use `claude-code` when Claude Code is available and preferred by config or when it is the only detected external CLI
69
+ 4. otherwise use `opencode` when OpenCode is available and preferred by config or when it is the only detected external CLI
70
+ 5. otherwise fall back to `local-subprocess`
71
+
72
+ This keeps the current default stable while still allowing best-effort cross-editor/provider routing when you explicitly want it.
73
+
74
+ ## Provider-specific sections
75
+
76
+ ### `local-subprocess`
77
+
78
+ No extra config is required.
79
+
80
+ This mode covers deterministic worker runs locally and stops in a terminal blocked state once the remaining work requires imported audit results or an interactive provider.
81
+
82
+ ### `claude_code`
83
+
84
+ ```json
85
+ {
86
+ "provider": "claude-code",
87
+ "ui_mode": "visible",
88
+ "claude_code": {
89
+ "command": "claude",
90
+ "extra_args": []
91
+ }
92
+ }
93
+ ```
94
+
95
+ Fields:
96
+
97
+ - `command`: optional override for the Claude Code executable
98
+ - `extra_args`: optional extra arguments appended before the built-in permission-skipping flag
99
+
100
+ ### `opencode`
101
+
102
+ ```json
103
+ {
104
+ "provider": "opencode",
105
+ "ui_mode": "visible",
106
+ "opencode": {
107
+ "command": "opencode",
108
+ "extra_args": []
109
+ }
110
+ }
111
+ ```
112
+
113
+ Fields:
114
+
115
+ - `command`: optional override for the OpenCode executable
116
+ - `extra_args`: optional additional arguments for `opencode run ...`
117
+
118
+ ### `subprocess_template`
119
+
120
+ ```json
121
+ {
122
+ "provider": "subprocess-template",
123
+ "ui_mode": "visible",
124
+ "subprocess_template": {
125
+ "command_template": ["bash", "-lc", "{workerCommandShell}"],
126
+ "env": {}
127
+ }
128
+ }
129
+ ```
130
+
131
+ Fields:
132
+
133
+ - `command_template`: required command array
134
+ - `env`: optional environment-variable overlay
135
+
136
+ ### `vscode_task`
137
+
138
+ ```json
139
+ {
140
+ "provider": "vscode-task",
141
+ "ui_mode": "visible",
142
+ "vscode_task": {
143
+ "command_template": ["bash", "-lc", "{workerCommandShell}"],
144
+ "env": {}
145
+ }
146
+ }
147
+ ```
148
+
149
+ This adapter is intentionally thin. It uses the same template expansion model as `subprocess-template`, but is named separately so the operator intent is explicit.
150
+
151
+ ## Template placeholders
152
+
153
+ `subprocess-template` and `vscode-task` support these placeholders inside each `command_template` entry:
154
+
155
+ - `{repoRoot}`
156
+ - `{runId}`
157
+ - `{obligationId}`
158
+ - `{promptPath}`
159
+ - `{taskPath}`
160
+ - `{resultPath}`
161
+ - `{stdoutPath}`
162
+ - `{stderrPath}`
163
+ - `{workerCommandShell}`
164
+ - `{workerCommandJson}`
165
+ - `{uiMode}`
166
+ - `{timeoutMs}`
167
+
168
+ ### Placeholder guidance
169
+
170
+ - Use `{workerCommandShell}` when your launcher can execute a fully rendered shell command directly.
171
+ - Use `{workerCommandJson}` when your launcher wants the worker command as structured data.
172
+ - Use `{promptPath}` and `{taskPath}` when an external tool should read the generated worker instructions instead of directly executing the worker command.
173
+
174
+ ## Suggested starting points
175
+
176
+ ### Safest default
177
+
178
+ ```json
179
+ {
180
+ "provider": "local-subprocess"
181
+ }
182
+ ```
183
+
184
+ ### Best-effort automatic routing
185
+
186
+ ```json
187
+ {
188
+ "provider": "auto",
189
+ "ui_mode": "visible"
190
+ }
191
+ ```
192
+
193
+ ### Delegate worker runs into Claude Code
194
+
195
+ ```json
196
+ {
197
+ "provider": "claude-code",
198
+ "ui_mode": "visible"
199
+ }
200
+ ```
201
+
202
+ ### Delegate worker runs into OpenCode
203
+
204
+ ```json
205
+ {
206
+ "provider": "opencode",
207
+ "ui_mode": "visible"
208
+ }
209
+ ```
210
+
211
+ ### Use a generic bash launcher bridge
212
+
213
+ ```json
214
+ {
215
+ "provider": "subprocess-template",
216
+ "ui_mode": "visible",
217
+ "subprocess_template": {
218
+ "command_template": ["bash", "-lc", "{workerCommandShell}"]
219
+ }
220
+ }
221
+ ```
222
+
223
+ ## Antigravity note
224
+
225
+ A dedicated Antigravity adapter is not currently shipped.
226
+
227
+ Until one exists, the practical options are:
228
+
229
+ - run `audit-code` from an Antigravity terminal with `local-subprocess`
230
+ - use `provider: "auto"` when you want best-effort routing without forcing a specific backend
231
+ - use `subprocess-template` with a launcher that Antigravity can reliably invoke
232
+ - treat the conversation-level `/audit-code` contract as primary and the backend CLI as fallback
@@ -0,0 +1,83 @@
1
+ # supervisor and provider adapters
2
+
3
+ This document describes backend infrastructure.
4
+
5
+ The primary product contract is `/audit-code` in conversation.
6
+
7
+ Everything here is fallback and implementation detail guidance for the repo-local backend surface.
8
+
9
+ ## Repo-local backend surface
10
+
11
+ From the target repository root:
12
+
13
+ ```bash
14
+ audit-code
15
+ ```
16
+
17
+ Debug one-step mode:
18
+
19
+ ```bash
20
+ audit-code --single-step
21
+ ```
22
+
23
+ Explicit root override:
24
+
25
+ ```bash
26
+ audit-code --root /path/to/repo
27
+ ```
28
+
29
+ ## Provider mode summary
30
+
31
+ If provider is omitted entirely, the backend defaults to the safest mode:
32
+
33
+ ```json
34
+ {
35
+ "provider": "local-subprocess"
36
+ }
37
+ ```
38
+
39
+ If you want best-effort routing across available or configured backends, opt into:
40
+
41
+ ```json
42
+ {
43
+ "provider": "auto",
44
+ "ui_mode": "visible"
45
+ }
46
+ ```
47
+
48
+ Explicit backend selection remains available:
49
+
50
+ ```bash
51
+ audit-code --provider local-subprocess
52
+ audit-code --provider claude-code
53
+ audit-code --provider opencode
54
+ audit-code --provider subprocess-template
55
+ audit-code --provider vscode-task
56
+ ```
57
+
58
+ ## Auto resolution rule
59
+
60
+ When `provider` is set to `auto`, the backend resolves in this order:
61
+
62
+ 1. `vscode-task` when running under VS Code and a `vscode_task.command_template` is configured
63
+ 2. `subprocess-template` when a generic template bridge is configured
64
+ 3. `claude-code` when Claude Code is available and preferred by config or when it is the only detected external CLI
65
+ 4. `opencode` when OpenCode is available and preferred by config or when it is the only detected external CLI
66
+ 5. `local-subprocess` otherwise
67
+
68
+ ## Session config
69
+
70
+ Optional backend config file:
71
+
72
+ `.audit-artifacts/session-config.json`
73
+
74
+ See:
75
+
76
+ - `docs/session-config.md`
77
+ - `docs/agent-integrations.md`
78
+ - `docs/model-selection.md`
79
+ - `docs/windows-setup.md`
80
+
81
+ ## Note
82
+
83
+ Provider adapters are backend integrations, not the primary product concept.
package/docs/usage.md ADDED
@@ -0,0 +1,172 @@
1
+ # Backend CLI Usage
2
+
3
+ This document covers the backend fallback CLI and low-level development entrypoints.
4
+
5
+ The primary product remains `/audit-code` in conversation.
6
+
7
+ ## Stable installed helpers
8
+
9
+ Bootstrap the supported repo-local `/audit-code` surfaces for the current repository:
10
+
11
+ ```bash
12
+ audit-code install
13
+ ```
14
+
15
+ Locate the canonical prompt asset shipped with the package:
16
+
17
+ ```bash
18
+ audit-code prompt-path
19
+ ```
20
+
21
+ Run the repo-local backend fallback from the target repository root:
22
+
23
+ ```bash
24
+ audit-code
25
+ ```
26
+
27
+ Validate the current fallback artifact bundle:
28
+
29
+ ```bash
30
+ audit-code validate
31
+ ```
32
+
33
+ This reports artifact issues, `session-config.json` issues, and explicit provider readiness issues in one machine-readable response.
34
+
35
+ Pass additional evidence back into the same fallback wrapper when needed:
36
+
37
+ ```bash
38
+ audit-code --results /path/to/audit_results.json
39
+ audit-code --updates /path/to/runtime_validation_update.json
40
+ audit-code --external-analyzer-results /path/to/external_analyzer_results.json
41
+ ```
42
+
43
+ Each wrapper run also refreshes:
44
+
45
+ - `.audit-artifacts/operator-handoff.json`
46
+ - `.audit-artifacts/operator-handoff.md`
47
+
48
+ Use those companion files when you want a stable summary of pending obligations, suggested import paths, and session-config guidance for interactive-provider continuation.
49
+
50
+ ## Low-level development entrypoints
51
+
52
+ These `dist/index.js` commands are backend and development interfaces.
53
+
54
+ They are useful for debugging, smoke coverage, and harness-level integration work.
55
+
56
+ ## Sample run
57
+
58
+ ```bash
59
+ npm run build
60
+ node dist/index.js sample-run --artifacts-dir .artifacts
61
+ ```
62
+
63
+ ## Advance the backend state machine
64
+
65
+ ```bash
66
+ node dist/index.js advance-audit --root /path/to/repo --artifacts-dir .artifacts
67
+ ```
68
+
69
+ Optional inputs for the same bounded step:
70
+
71
+ ```bash
72
+ node dist/index.js advance-audit --root /path/to/repo --artifacts-dir .artifacts --results /path/to/audit_results.json
73
+ node dist/index.js advance-audit --root /path/to/repo --artifacts-dir .artifacts --updates /path/to/runtime_validation_update.json
74
+ node dist/index.js advance-audit --root /path/to/repo --artifacts-dir .artifacts --external-analyzer-results /path/to/external_analyzer_results.json
75
+ ```
76
+
77
+ ## Import normalized external analyzer results
78
+
79
+ ```bash
80
+ node dist/index.js import-external-analyzer --root /path/to/repo --artifacts-dir .artifacts --external-analyzer-results /path/to/external_analyzer_results.json
81
+ ```
82
+
83
+ This writes:
84
+
85
+ - `external_analyzer_results.json`
86
+ - refreshed `audit_state.json`
87
+
88
+ ## Real repository intake
89
+
90
+ ```bash
91
+ node dist/index.js intake --root /path/to/repo --artifacts-dir .artifacts
92
+ ```
93
+
94
+ This writes:
95
+
96
+ - `repo_manifest.json`
97
+ - `file_disposition.json`
98
+
99
+ ## Planning helper
100
+
101
+ ```bash
102
+ node dist/index.js plan --root /path/to/repo --artifacts-dir .artifacts
103
+ ```
104
+
105
+ This command is a backend helper, not a stable end-user planning pipeline.
106
+
107
+ It invokes the current bounded advance logic and reports the next backend step.
108
+
109
+ ## Ingest audit results
110
+
111
+ ```bash
112
+ node dist/index.js ingest-results --artifacts-dir .artifacts --results /path/to/audit_results.json
113
+ ```
114
+
115
+ This updates:
116
+
117
+ - `coverage_matrix.json`
118
+ - `flow_coverage.json`
119
+ - `runtime_validation_tasks.json`
120
+ - `runtime_validation_report.json`
121
+ - `audit_results.jsonl`
122
+ - `requeue_tasks.json`
123
+ - `synthesis_report.json`
124
+
125
+ ## Update runtime validation report with real evidence
126
+
127
+ Prepare a JSON file shaped like `examples/runtime_validation_update.example.json`, then run:
128
+
129
+ ```bash
130
+ node dist/index.js update-runtime-validation --artifacts-dir .artifacts --updates /path/to/runtime_validation_update.json
131
+ ```
132
+
133
+ This merges the updates into:
134
+
135
+ - `runtime_validation_report.json`
136
+ - `synthesis_report.json`
137
+
138
+ ## Validate artifacts
139
+
140
+ ```bash
141
+ node dist/index.js validate --artifacts-dir .artifacts
142
+ ```
143
+
144
+ This checks artifact shape, cross-artifact consistency, backend session-config validity, and explicit provider readiness.
145
+
146
+ It is intended for backend operators and automation, not for the normal conversation route.
147
+
148
+ ## Requeue helper
149
+
150
+ ```bash
151
+ node dist/index.js requeue --artifacts-dir .artifacts
152
+ ```
153
+
154
+ This command currently reports the current requeue task count from the existing artifact bundle.
155
+
156
+ Treat it as an inspection helper rather than a stable artifact-building command.
157
+
158
+ ## Synthesize findings
159
+
160
+ ```bash
161
+ node dist/index.js synthesize --artifacts-dir .artifacts --results /path/to/audit_results.json
162
+ ```
163
+
164
+ This writes:
165
+
166
+ - `merged_findings.json`
167
+ - `root_cause_clusters.json`
168
+ - `synthesis_report.json`
169
+
170
+ ## Ignore file
171
+
172
+ Create a `.auditorignore` file at repository root to add extra ignored paths, one per line.