auditor-lambda 0.1.0 → 0.2.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.
Files changed (58) hide show
  1. package/README.md +2 -1
  2. package/audit-code-wrapper-lib.mjs +458 -380
  3. package/dist/cli.js +258 -11
  4. package/dist/coverage.d.ts +0 -1
  5. package/dist/coverage.js +3 -34
  6. package/dist/extractors/fileInventory.js +2 -0
  7. package/dist/io/artifacts.js +2 -1
  8. package/dist/orchestrator/advance.js +70 -52
  9. package/dist/orchestrator/flowCoverage.js +2 -1
  10. package/dist/orchestrator/flowPlanning.d.ts +1 -1
  11. package/dist/orchestrator/flowPlanning.js +21 -28
  12. package/dist/orchestrator/internalExecutors.js +0 -1
  13. package/dist/orchestrator/taskBuilder.d.ts +7 -2
  14. package/dist/orchestrator/taskBuilder.js +55 -47
  15. package/dist/prompts/renderWorkerPrompt.js +32 -0
  16. package/dist/providers/claudeCodeProvider.js +6 -0
  17. package/dist/providers/index.js +5 -2
  18. package/dist/providers/opencodeProvider.js +6 -1
  19. package/dist/providers/types.d.ts +1 -0
  20. package/dist/reporting/mergeFindings.js +0 -7
  21. package/dist/reporting/rootCause.d.ts +0 -1
  22. package/dist/reporting/rootCause.js +0 -6
  23. package/dist/reporting/synthesis.js +18 -0
  24. package/dist/supervisor/runLedger.js +6 -2
  25. package/dist/types/sessionConfig.d.ts +8 -0
  26. package/dist/types/workerSession.d.ts +2 -0
  27. package/dist/types.d.ts +1 -2
  28. package/dist/validation/auditResults.d.ts +11 -0
  29. package/dist/validation/auditResults.js +118 -0
  30. package/dist/validation/sessionConfig.js +15 -1
  31. package/docs/agent-integrations.md +61 -56
  32. package/docs/agent-roles.md +69 -69
  33. package/docs/architecture.md +90 -90
  34. package/docs/artifacts.md +69 -69
  35. package/docs/bootstrap-install.md +1 -1
  36. package/docs/model-selection.md +86 -86
  37. package/docs/next-steps.md +11 -9
  38. package/docs/packaging.md +3 -3
  39. package/docs/pipeline.md +152 -152
  40. package/docs/production-readiness.md +6 -5
  41. package/docs/repo-layout.md +18 -18
  42. package/docs/run-flow.md +5 -5
  43. package/docs/session-config.md +216 -210
  44. package/docs/supervisor.md +70 -70
  45. package/docs/windows-setup.md +139 -139
  46. package/package.json +56 -56
  47. package/schemas/audit-code-v1alpha1.schema.json +76 -76
  48. package/schemas/audit_result.schema.json +48 -48
  49. package/schemas/audit_task.schema.json +49 -49
  50. package/schemas/coverage_matrix.schema.json +0 -15
  51. package/schemas/file_disposition.schema.json +33 -33
  52. package/schemas/finding.schema.json +58 -62
  53. package/schemas/flow_coverage.schema.json +44 -44
  54. package/schemas/root_cause_clusters.schema.json +0 -4
  55. package/schemas/runtime_validation_report.schema.json +34 -34
  56. package/schemas/synthesis_report.schema.json +61 -61
  57. package/skills/audit-code/SKILL.md +37 -37
  58. package/skills/audit-code/audit-code.prompt.md +56 -54
package/docs/run-flow.md CHANGED
@@ -9,11 +9,11 @@ This document describes the backend execution flow that supports that conversati
9
9
  1. Build or import a repository manifest.
10
10
  2. Build audit units from the repository manifest.
11
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.
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
17
  9. Build requeue tasks for missing lenses or uncovered ranges.
18
18
  10. Repeat until coverage rules are satisfied.
19
19
  11. Synthesize findings into merged outputs.
@@ -5,11 +5,11 @@ This file only applies to the backend fallback CLI.
5
5
  The canonical `/audit-code` conversation route should not require users to touch it.
6
6
 
7
7
  Backend provider configuration lives at:
8
-
9
- ```text
10
- .audit-artifacts/session-config.json
11
- ```
12
-
8
+
9
+ ```text
10
+ .audit-artifacts/session-config.json
11
+ ```
12
+
13
13
  This file is optional.
14
14
 
15
15
  If it does not exist, the backend defaults to its built-in behavior.
@@ -20,213 +20,219 @@ You can also check it explicitly with:
20
20
  ```bash
21
21
  audit-code validate
22
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
-
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
76
  ### `local-subprocess`
77
77
 
78
78
  No extra config is required.
79
79
 
80
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
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
+ When audit-task review is pending, the generated provider prompt now asks Claude Code to write structured `AuditResult[]` output and then run the bounded worker command so the same `audit-code` invocation can keep advancing.
101
+
102
+ ### `opencode`
103
+
104
+ ```json
105
+ {
106
+ "provider": "opencode",
107
+ "ui_mode": "visible",
108
+ "opencode": {
109
+ "command": "opencode",
110
+ "extra_args": []
111
+ }
112
+ }
113
+ ```
114
+
115
+ Fields:
116
+
117
+ - `command`: optional override for the OpenCode executable
118
+ - `extra_args`: optional additional arguments for `opencode run ...`
119
+
120
+ When audit-task review is pending, the generated provider prompt now asks OpenCode to write structured `AuditResult[]` output and then run the bounded worker command so the same `audit-code` invocation can keep advancing.
121
+
122
+ ### `subprocess_template`
123
+
124
+ ```json
125
+ {
126
+ "provider": "subprocess-template",
127
+ "ui_mode": "visible",
128
+ "subprocess_template": {
129
+ "command_template": ["bash", "-lc", "{workerCommandShell}"],
130
+ "env": {}
131
+ }
132
+ }
133
+ ```
134
+
135
+ Fields:
136
+
137
+ - `command_template`: required command array
138
+ - `env`: optional environment-variable overlay
139
+
140
+ When you use this bridge for provider-assisted review, the launched process should write structured audit results to `task.audit_results_path` and then execute `task.worker_command`.
141
+
142
+ ### `vscode_task`
143
+
144
+ ```json
145
+ {
146
+ "provider": "vscode-task",
147
+ "ui_mode": "visible",
148
+ "vscode_task": {
149
+ "command_template": ["bash", "-lc", "{workerCommandShell}"],
150
+ "env": {}
151
+ }
152
+ }
153
+ ```
154
+
155
+ 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.
156
+
157
+ ## Template placeholders
158
+
159
+ `subprocess-template` and `vscode-task` support these placeholders inside each `command_template` entry:
160
+
161
+ - `{repoRoot}`
162
+ - `{runId}`
163
+ - `{obligationId}`
164
+ - `{promptPath}`
165
+ - `{taskPath}`
166
+ - `{resultPath}`
167
+ - `{stdoutPath}`
168
+ - `{stderrPath}`
169
+ - `{workerCommandShell}`
170
+ - `{workerCommandJson}`
171
+ - `{uiMode}`
172
+ - `{timeoutMs}`
173
+
174
+ ### Placeholder guidance
175
+
176
+ - Use `{workerCommandShell}` when your launcher can execute a fully rendered shell command directly.
177
+ - Use `{workerCommandJson}` when your launcher wants the worker command as structured data.
178
+ - Use `{promptPath}` and `{taskPath}` when an external tool should read the generated worker instructions instead of directly executing the worker command.
179
+
180
+ ## Suggested starting points
181
+
182
+ ### Safest default
183
+
184
+ ```json
185
+ {
186
+ "provider": "local-subprocess"
187
+ }
188
+ ```
189
+
190
+ ### Best-effort automatic routing
191
+
192
+ ```json
193
+ {
194
+ "provider": "auto",
195
+ "ui_mode": "visible"
196
+ }
197
+ ```
198
+
199
+ ### Delegate worker runs into Claude Code
200
+
201
+ ```json
202
+ {
203
+ "provider": "claude-code",
204
+ "ui_mode": "visible"
205
+ }
206
+ ```
207
+
208
+ ### Delegate worker runs into OpenCode
209
+
210
+ ```json
211
+ {
212
+ "provider": "opencode",
213
+ "ui_mode": "visible"
214
+ }
215
+ ```
216
+
217
+ ### Use a generic bash launcher bridge
218
+
219
+ ```json
220
+ {
221
+ "provider": "subprocess-template",
222
+ "ui_mode": "visible",
223
+ "subprocess_template": {
224
+ "command_template": ["bash", "-lc", "{workerCommandShell}"]
225
+ }
226
+ }
227
+ ```
228
+
229
+ ## Antigravity note
230
+
231
+ A dedicated Antigravity adapter is not currently shipped.
232
+
233
+ Until one exists, the practical options are:
234
+
235
+ - run `audit-code` from an Antigravity terminal with `local-subprocess`
236
+ - use `provider: "auto"` when you want best-effort routing without forcing a specific backend
237
+ - use `subprocess-template` with a launcher that Antigravity can reliably invoke
238
+ - treat the conversation-level `/audit-code` contract as primary and the backend CLI as fallback
@@ -7,77 +7,77 @@ The primary product contract is `/audit-code` in conversation.
7
7
  Everything here is fallback and implementation detail guidance for the repo-local backend surface.
8
8
 
9
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
-
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
76
  - `docs/session-config.md`
77
77
  - `docs/agent-integrations.md`
78
78
  - `docs/model-selection.md`
79
79
  - `docs/windows-setup.md`
80
-
81
- ## Note
82
-
83
- Provider adapters are backend integrations, not the primary product concept.
80
+
81
+ ## Note
82
+
83
+ Provider adapters are backend integrations, not the primary product concept.