auditor-lambda 0.3.41 → 0.6.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 (78) hide show
  1. package/dist/cli/dispatch.js +5 -1
  2. package/dist/cli/prompts.d.ts +19 -0
  3. package/dist/cli/prompts.js +95 -0
  4. package/dist/cli/steps.d.ts +1 -1
  5. package/dist/cli.js +398 -78
  6. package/dist/extractors/analyzers/css.d.ts +2 -0
  7. package/dist/extractors/analyzers/css.js +101 -0
  8. package/dist/extractors/analyzers/html.d.ts +2 -0
  9. package/dist/extractors/analyzers/html.js +92 -0
  10. package/dist/extractors/analyzers/merge.d.ts +14 -0
  11. package/dist/extractors/analyzers/merge.js +85 -0
  12. package/dist/extractors/analyzers/python.d.ts +2 -0
  13. package/dist/extractors/analyzers/python.js +104 -0
  14. package/dist/extractors/analyzers/registry.d.ts +33 -0
  15. package/dist/extractors/analyzers/registry.js +100 -0
  16. package/dist/extractors/analyzers/resourceUrl.d.ts +7 -0
  17. package/dist/extractors/analyzers/resourceUrl.js +25 -0
  18. package/dist/extractors/analyzers/sql.d.ts +2 -0
  19. package/dist/extractors/analyzers/sql.js +19 -0
  20. package/dist/extractors/analyzers/treeSitter.d.ts +34 -0
  21. package/dist/extractors/analyzers/treeSitter.js +111 -0
  22. package/dist/extractors/analyzers/types.d.ts +53 -0
  23. package/dist/extractors/analyzers/types.js +1 -0
  24. package/dist/extractors/analyzers/typescript.d.ts +2 -0
  25. package/dist/extractors/analyzers/typescript.js +257 -0
  26. package/dist/extractors/disposition.js +8 -1
  27. package/dist/extractors/graph.d.ts +1 -0
  28. package/dist/extractors/graph.js +167 -1
  29. package/dist/extractors/graphPythonImports.d.ts +15 -0
  30. package/dist/extractors/graphPythonImports.js +36 -0
  31. package/dist/extractors/pathPatterns.d.ts +6 -0
  32. package/dist/extractors/pathPatterns.js +8 -0
  33. package/dist/io/artifacts.d.ts +13 -1
  34. package/dist/io/artifacts.js +19 -3
  35. package/dist/mcp/server.js +3 -3
  36. package/dist/orchestrator/advance.d.ts +20 -0
  37. package/dist/orchestrator/advance.js +61 -2
  38. package/dist/orchestrator/dependencyMap.js +27 -0
  39. package/dist/orchestrator/edgeReasoning.d.ts +39 -0
  40. package/dist/orchestrator/edgeReasoning.js +125 -0
  41. package/dist/orchestrator/executors.js +11 -1
  42. package/dist/orchestrator/graphEnrichmentExecutor.d.ts +29 -0
  43. package/dist/orchestrator/graphEnrichmentExecutor.js +196 -0
  44. package/dist/orchestrator/internalExecutors.d.ts +10 -1
  45. package/dist/orchestrator/internalExecutors.js +89 -11
  46. package/dist/orchestrator/localCommands.js +6 -25
  47. package/dist/orchestrator/nextStep.js +2 -0
  48. package/dist/orchestrator/reviewPackets.d.ts +37 -4
  49. package/dist/orchestrator/reviewPackets.js +93 -46
  50. package/dist/orchestrator/runtimeValidation.js +4 -31
  51. package/dist/orchestrator/scope.d.ts +62 -0
  52. package/dist/orchestrator/scope.js +227 -0
  53. package/dist/orchestrator/state.js +2 -0
  54. package/dist/reporting/synthesis.d.ts +37 -2
  55. package/dist/reporting/synthesis.js +95 -16
  56. package/dist/reporting/synthesisNarrativePrompt.d.ts +7 -0
  57. package/dist/reporting/synthesisNarrativePrompt.js +60 -0
  58. package/dist/reporting/workBlocks.d.ts +2 -10
  59. package/dist/supervisor/operatorHandoff.d.ts +1 -1
  60. package/dist/supervisor/operatorHandoff.js +26 -16
  61. package/dist/supervisor/sessionConfig.d.ts +8 -1
  62. package/dist/supervisor/sessionConfig.js +22 -1
  63. package/dist/types/analyzerCapability.d.ts +16 -0
  64. package/dist/types/analyzerCapability.js +1 -0
  65. package/dist/types/auditScope.d.ts +43 -0
  66. package/dist/types/auditScope.js +14 -0
  67. package/dist/types/synthesisNarrative.d.ts +7 -0
  68. package/dist/types/synthesisNarrative.js +5 -0
  69. package/dist/types.d.ts +2 -19
  70. package/dist/validation/artifacts.js +9 -0
  71. package/dist/validation/sessionConfig.js +24 -1
  72. package/docs/contracts.md +10 -3
  73. package/package.json +4 -2
  74. package/schemas/analyzer_capability.schema.json +47 -0
  75. package/schemas/audit_findings.schema.json +141 -0
  76. package/schemas/finding.schema.json +2 -1
  77. package/schemas/graph_bundle.schema.json +5 -0
  78. package/schemas/scope.schema.json +46 -0
@@ -3,7 +3,7 @@ import { existsSync } from "node:fs";
3
3
  import { isAbsolute, join, relative, resolve } from "node:path";
4
4
  import { isFileMissingError, readJsonFile, writeJsonFile } from "@audit-tools/shared";
5
5
  import { loadArtifactBundle } from "../io/artifacts.js";
6
- import { orderTasksForPacketReview, buildReviewPackets } from "../orchestrator/reviewPackets.js";
6
+ import { orderTasksForPacketReview, buildReviewPackets, sizeIndexFromManifest, } from "../orchestrator/reviewPackets.js";
7
7
  import { buildFileAnchorSummary } from "../orchestrator/fileAnchors.js";
8
8
  import { resolveFreshSessionProviderName } from "../providers/index.js";
9
9
  import { loadSessionConfig } from "../supervisor/sessionConfig.js";
@@ -166,6 +166,7 @@ export function buildPendingAuditTasks(bundle) {
166
166
  return orderTasksForPacketReview(pendingTasks, {
167
167
  graphBundle: bundle.graph_bundle,
168
168
  lineIndex,
169
+ sizeIndex: sizeIndexFromManifest(bundle.repo_manifest),
169
170
  });
170
171
  }
171
172
  export async function prepareDispatchArtifacts(params) {
@@ -205,13 +206,16 @@ export async function prepareDispatchArtifacts(params) {
205
206
  ? tasks.filter((task) => !priorResultTaskIds.has(task.task_id))
206
207
  : tasks;
207
208
  const lineIndex = Object.fromEntries(dispatchTasks.flatMap((task) => Object.entries(task.file_line_counts ?? {})));
209
+ const sizeIndex = sizeIndexFromManifest(bundle.repo_manifest);
208
210
  const orderedTasks = orderTasksForPacketReview(dispatchTasks, {
209
211
  graphBundle: bundle.graph_bundle,
210
212
  lineIndex,
213
+ sizeIndex,
211
214
  });
212
215
  const packets = buildReviewPackets(orderedTasks, {
213
216
  graphBundle: bundle.graph_bundle,
214
217
  lineIndex,
218
+ sizeIndex,
215
219
  });
216
220
  const tasksById = new Map(orderedTasks.map((task) => [task.task_id, task]));
217
221
  const resultPathByTaskId = new Map(orderedTasks.map((task) => [
@@ -1,4 +1,5 @@
1
1
  import type { ActiveReviewRun } from "../supervisor/operatorHandoff.js";
2
+ import type { AnalyzerPlanEntry } from "../extractors/analyzers/types.js";
2
3
  export declare function nextStepCommand(root: string, artifactsDir: string): string;
3
4
  export declare function mergeAndIngestCommand(artifactsDir: string, runId: string): string;
4
5
  export declare function renderDispatchReviewPrompt(params: {
@@ -14,5 +15,23 @@ export declare function renderSingleTaskFallbackStepPrompt(params: {
14
15
  singleTaskPromptPath: string;
15
16
  activeReviewRun: ActiveReviewRun;
16
17
  }): string;
18
+ export declare function renderEdgeReasoningStepPrompt(params: {
19
+ basePrompt: string;
20
+ resultsPath: string;
21
+ continueCommand: string;
22
+ contentHash: string;
23
+ }): string;
24
+ export declare function renderEdgeReasoningDispatchPrompt(params: {
25
+ promptPath: string;
26
+ resultsPath: string;
27
+ continueCommand: string;
28
+ contentHash: string;
29
+ candidateCount: number;
30
+ }): string;
17
31
  export declare function renderPresentReportPrompt(finalReportPath: string): string;
32
+ export declare function renderAnalyzerInstallPrompt(params: {
33
+ unresolved: AnalyzerPlanEntry[];
34
+ decisionsPath: string;
35
+ continueCommand: string;
36
+ }): string;
18
37
  export declare function renderBlockedStepPrompt(reason: string): string;
@@ -102,6 +102,62 @@ export function renderSingleTaskFallbackStepPrompt(params) {
102
102
  "",
103
103
  ].join("\n");
104
104
  }
105
+ export function renderEdgeReasoningStepPrompt(params) {
106
+ return [
107
+ params.basePrompt,
108
+ "",
109
+ "## Results path",
110
+ "",
111
+ 'Write the JSON object ({"rewrites":[{"from":"...","to":"...","kind":"...","reason":"..."}]}) to:',
112
+ "",
113
+ ` ${params.resultsPath}`,
114
+ "",
115
+ `Cache key (edge-set content hash): ${params.contentHash}.`,
116
+ "If you already produced rewrites for this exact key, you may reuse them instead of regenerating.",
117
+ "",
118
+ `Then run: ${params.continueCommand}`,
119
+ "",
120
+ "Read and follow only the new step prompt returned by that command.",
121
+ "",
122
+ ].join("\n");
123
+ }
124
+ export function renderEdgeReasoningDispatchPrompt(params) {
125
+ return [
126
+ "# audit-code edge reasoning (subagent dispatch)",
127
+ "",
128
+ `The dependency graph has ${params.candidateCount} low-confidence edge(s) whose`,
129
+ "machine-generated `reason` text can be clarified. This is a single, bounded,",
130
+ "optional pass: it only rewrites the `reason` string of those edges — it never",
131
+ "adds, removes, re-targets, or re-weights an edge.",
132
+ "",
133
+ "Dispatch exactly ONE subagent (via the `task` tool or equivalent). Hand it this",
134
+ "prompt file path; do not load the file into this orchestrator context:",
135
+ "",
136
+ ` ${params.promptPath}`,
137
+ "",
138
+ "Subagent prompt shape:",
139
+ "",
140
+ " Read and follow the edge-reasoning instructions in: <prompt path above>",
141
+ "",
142
+ 'The subagent must write its JSON result ({"rewrites":[...]}) to:',
143
+ "",
144
+ ` ${params.resultsPath}`,
145
+ "",
146
+ `Cache key (edge-set content hash): ${params.contentHash}.`,
147
+ "If you hold a cached result for this exact key from a previous run, you may write",
148
+ "it to the results path directly instead of dispatching a subagent.",
149
+ "",
150
+ "**File access pre-approval:** if your host supports per-subagent file access",
151
+ `restrictions, allow the subagent to read ${params.promptPath} and write ${params.resultsPath}.`,
152
+ "",
153
+ "After the subagent writes the result, run exactly:",
154
+ "",
155
+ ` ${params.continueCommand}`,
156
+ "",
157
+ "Read and follow only the new step prompt returned by that command.",
158
+ "",
159
+ ].join("\n");
160
+ }
105
161
  export function renderPresentReportPrompt(finalReportPath) {
106
162
  return [
107
163
  "# audit-code present report",
@@ -116,6 +172,45 @@ export function renderPresentReportPrompt(finalReportPath) {
116
172
  "",
117
173
  ].join("\n");
118
174
  }
175
+ export function renderAnalyzerInstallPrompt(params) {
176
+ const analyzerLines = params.unresolved.flatMap((entry) => [
177
+ `- **${entry.id}** — needs \`${entry.dependency ?? entry.id}\`; ${entry.supportedCount} in-scope file(s) would be analyzed.`,
178
+ ]);
179
+ const exampleObject = `{ ${params.unresolved
180
+ .map((entry) => `"${entry.id}": "ephemeral"`)
181
+ .join(", ")} }`;
182
+ return [
183
+ "# audit-code analyzer install",
184
+ "",
185
+ "The deterministic regex graph is built. These optional language analyzers can",
186
+ "produce a richer graph (real module resolution, inheritance, and a call graph),",
187
+ "but their compiler dependency is not installed in the audited repo:",
188
+ "",
189
+ ...analyzerLines,
190
+ "",
191
+ "Choose how to resolve each one and write a JSON object of `{ \"<analyzer-id>\": <setting> }`",
192
+ "to the decisions path below. Valid settings:",
193
+ "",
194
+ "- `ephemeral` — install into a shared, version-keyed cache (never touches this project); compile once, reuse across audits.",
195
+ "- `permanent` — same as `ephemeral` but a durable opt-in recorded in session config.",
196
+ "- `skip` — do not run this analyzer; keep the regex floor.",
197
+ "",
198
+ "Default if you are unsure or cannot install: choose `skip`. The audit proceeds either way.",
199
+ "",
200
+ "## Decisions path",
201
+ "",
202
+ "Write your choices to:",
203
+ "",
204
+ ` ${params.decisionsPath}`,
205
+ "",
206
+ `Example: ${exampleObject}`,
207
+ "",
208
+ `Then run: ${params.continueCommand}`,
209
+ "",
210
+ "Read and follow only the new step prompt returned by that command.",
211
+ "",
212
+ ].join("\n");
213
+ }
119
214
  export function renderBlockedStepPrompt(reason) {
120
215
  return [
121
216
  "# audit-code blocked",
@@ -1,7 +1,7 @@
1
1
  import type { StepStatus } from "@audit-tools/shared";
2
2
  import type { AccessDeclaration } from "../types/workerSession.js";
3
3
  export declare const STEP_CONTRACT_VERSION = "audit-code-step/v1alpha1";
4
- export type StepKind = "dispatch_review" | "single_task_fallback" | "design_review" | "present_report" | "blocked";
4
+ export type StepKind = "dispatch_review" | "single_task_fallback" | "design_review" | "analyzer_install" | "edge_reasoning" | "edge_reasoning_dispatch" | "synthesis_narrative" | "present_report" | "blocked";
5
5
  export interface StepArtifact {
6
6
  contract_version: typeof STEP_CONTRACT_VERSION;
7
7
  step_kind: StepKind;