infraweaver 0.3.7 → 0.3.8

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 (175) hide show
  1. package/README.md +2 -2
  2. package/dist/agents/claude.d.ts +1 -1
  3. package/dist/agents/claudePretoolGate.d.ts +0 -36
  4. package/dist/agents/toolPlaneWatch.d.ts +31 -0
  5. package/dist/cli.mjs +31903 -18736
  6. package/dist/external.d.ts +2 -1
  7. package/dist/index.js +31987 -18749
  8. package/dist/internal.js +132 -52
  9. package/dist/mcp/baseBranch.d.ts +41 -0
  10. package/dist/mcp/changeSummary.d.ts +1 -1
  11. package/dist/mcp/findingAudit.d.ts +2 -0
  12. package/dist/mcp/guardrails.d.ts +38 -0
  13. package/dist/mcp/localContext.d.ts +1 -1
  14. package/dist/mcp/moduleExtraction.d.ts +5 -0
  15. package/dist/mcp/pr.d.ts +0 -31
  16. package/dist/mcp/reproveSuggestions.d.ts +27 -0
  17. package/dist/mcp/review.d.ts +126 -2
  18. package/dist/mcp/reviewCommentLimit.d.ts +17 -0
  19. package/dist/mcp/reviewComments.d.ts +9 -5
  20. package/dist/mcp/reviewDedup.d.ts +1 -0
  21. package/dist/mcp/reviewMarkers.d.ts +10 -0
  22. package/dist/mcp/reviewProvenance.d.ts +20 -6
  23. package/dist/mcp/shared.d.ts +15 -0
  24. package/dist/mcp/suggestionProver.d.ts +3 -2
  25. package/dist/mcp/terraform/checkovSeverities.d.ts +7 -0
  26. package/dist/mcp/terraform/consolidation.d.ts +26 -0
  27. package/dist/mcp/terraform/cost.d.ts +2 -2
  28. package/dist/mcp/terraform/currency.d.ts +11 -0
  29. package/dist/mcp/terraform/deltaSummary.d.ts +11 -1
  30. package/dist/mcp/terraform/emittedArtefacts.d.ts +11 -0
  31. package/dist/mcp/terraform/evidence.d.ts +10 -0
  32. package/dist/mcp/terraform/gateScan.d.ts +2 -16
  33. package/dist/mcp/terraform/hcl.d.ts +15 -0
  34. package/dist/mcp/terraform/initArtefacts.d.ts +21 -0
  35. package/dist/mcp/terraform/localModules.d.ts +29 -0
  36. package/dist/mcp/terraform/moduleFindings.d.ts +38 -0
  37. package/dist/mcp/terraform/refactor/attribution.d.ts +1 -1
  38. package/dist/mcp/terraform/refactor/equivalence.d.ts +7 -0
  39. package/dist/mcp/terraform/refactor/expressions.d.ts +62 -0
  40. package/dist/mcp/terraform/refactor/references.d.ts +15 -0
  41. package/dist/mcp/terraform/refactor/resources.d.ts +11 -0
  42. package/dist/mcp/terraform/refactor/substitution.d.ts +55 -37
  43. package/dist/mcp/terraform/scanDelta.d.ts +28 -0
  44. package/dist/mcp/terraform/scanSession.d.ts +13 -0
  45. package/dist/mcp/terraform/scanners.d.ts +67 -18
  46. package/dist/mcp/terraform/secretScan.d.ts +19 -0
  47. package/dist/mcp/terraform/standardsReport.d.ts +1 -1
  48. package/dist/mcp/terraform/tools/plan.d.ts +1 -1
  49. package/dist/mcp/terraform/tools/scan.d.ts +7 -7
  50. package/dist/mcp/terraform/tools/validate.d.ts +7 -2
  51. package/dist/mcp/terraform/tools/verifyRemediation.d.ts +1 -1
  52. package/dist/mcp/terraform/treeLayout.d.ts +57 -0
  53. package/dist/mcp/terraform/types.d.ts +1 -1
  54. package/dist/phases/applyPlan.d.ts +0 -2
  55. package/dist/toolState.d.ts +3 -0
  56. package/dist/utils/agent/codexOAuth.d.ts +1 -1
  57. package/dist/utils/cli.d.ts +1 -7
  58. package/dist/utils/cloud/cloudReport.d.ts +1 -1
  59. package/dist/utils/config/baseRefConfig.d.ts +1 -1
  60. package/dist/utils/config/infraweaverConfig.d.ts +1 -1
  61. package/dist/utils/config/payload.d.ts +5 -0
  62. package/dist/utils/markdownTable.d.ts +6 -0
  63. package/dist/utils/setup/toolLicensing.d.ts +1 -1
  64. package/dist/utils/unifiedDiff.d.ts +69 -0
  65. package/package.json +34 -28
  66. package/src/agents/claude.ts +48 -13
  67. package/src/agents/claudePretoolGate.ts +9 -17
  68. package/src/agents/sessionLabeler.ts +3 -3
  69. package/src/agents/toolPlaneWatch.ts +71 -0
  70. package/src/external.ts +3 -1
  71. package/src/mcp/assess.ts +8 -8
  72. package/src/mcp/baseBranch.ts +96 -0
  73. package/src/mcp/changeSummary.ts +10 -11
  74. package/src/mcp/checkSuite.ts +7 -10
  75. package/src/mcp/checkout.ts +13 -40
  76. package/src/mcp/crosswalk.ts +5 -0
  77. package/src/mcp/findingAudit.ts +1 -1
  78. package/src/mcp/git.ts +44 -2
  79. package/src/mcp/guardrails.ts +188 -36
  80. package/src/mcp/localContext.ts +2 -0
  81. package/src/mcp/localServer.ts +1 -0
  82. package/src/mcp/moduleExtraction.ts +17 -5
  83. package/src/mcp/moduleTests.ts +9 -2
  84. package/src/mcp/modules.ts +10 -7
  85. package/src/mcp/pr.ts +17 -65
  86. package/src/mcp/reproveSuggestions.ts +86 -0
  87. package/src/mcp/review.ts +249 -75
  88. package/src/mcp/reviewAnchor.ts +11 -23
  89. package/src/mcp/reviewCommentLimit.ts +79 -0
  90. package/src/mcp/reviewComments.ts +34 -81
  91. package/src/mcp/reviewDedup.ts +1 -1
  92. package/src/mcp/reviewMarkers.ts +25 -2
  93. package/src/mcp/reviewProvenance.ts +56 -21
  94. package/src/mcp/roots.ts +3 -2
  95. package/src/mcp/server.ts +2 -1
  96. package/src/mcp/shared.ts +40 -1
  97. package/src/mcp/shell.ts +27 -28
  98. package/src/mcp/suggestionProver.ts +8 -4
  99. package/src/mcp/terraform/checkovSeverities.ts +1156 -0
  100. package/src/mcp/terraform/concernResult.ts +2 -1
  101. package/src/mcp/terraform/consolidation.ts +232 -19
  102. package/src/mcp/terraform/cost.ts +16 -7
  103. package/src/mcp/terraform/cspm.ts +8 -4
  104. package/src/mcp/terraform/currency.ts +28 -12
  105. package/src/mcp/terraform/decisions.ts +1 -1
  106. package/src/mcp/terraform/deltaSummary.ts +50 -1
  107. package/src/mcp/terraform/emittedArtefacts.ts +63 -0
  108. package/src/mcp/terraform/evidence.ts +23 -3
  109. package/src/mcp/terraform/gateScan.ts +191 -128
  110. package/src/mcp/terraform/hcl.ts +27 -2
  111. package/src/mcp/terraform/idleFloor.ts +2 -1
  112. package/src/mcp/terraform/initArtefacts.ts +76 -0
  113. package/src/mcp/terraform/localModules.ts +112 -0
  114. package/src/mcp/terraform/moduleDocs.ts +2 -5
  115. package/src/mcp/terraform/moduleFindings.ts +102 -0
  116. package/src/mcp/terraform/moduleVersionConstraints.ts +1 -1
  117. package/src/mcp/terraform/planPairs.ts +2 -20
  118. package/src/mcp/terraform/policyGate.ts +0 -15
  119. package/src/mcp/terraform/refactor/attribution.ts +39 -5
  120. package/src/mcp/terraform/refactor/equivalence.ts +49 -10
  121. package/src/mcp/terraform/refactor/expressions.ts +323 -0
  122. package/src/mcp/terraform/refactor/references.ts +101 -0
  123. package/src/mcp/terraform/refactor/resources.ts +79 -7
  124. package/src/mcp/terraform/refactor/substitution.ts +852 -256
  125. package/src/mcp/terraform/scanDelta.ts +34 -0
  126. package/src/mcp/terraform/scanSession.ts +30 -0
  127. package/src/mcp/terraform/scannerCache.ts +4 -0
  128. package/src/mcp/terraform/scanners.ts +553 -233
  129. package/src/mcp/terraform/secretScan.ts +131 -0
  130. package/src/mcp/terraform/standardsReport.ts +14 -13
  131. package/src/mcp/terraform/tools/consolidationCandidates.ts +3 -0
  132. package/src/mcp/terraform/tools/emitEvidence.ts +13 -5
  133. package/src/mcp/terraform/tools/emitOscal.ts +3 -2
  134. package/src/mcp/terraform/tools/emitVex.ts +10 -4
  135. package/src/mcp/terraform/tools/equivalenceCheck.ts +139 -21
  136. package/src/mcp/terraform/tools/infracostDiff.ts +2 -2
  137. package/src/mcp/terraform/tools/plan.ts +30 -17
  138. package/src/mcp/terraform/tools/reviewScanDelta.ts +3 -0
  139. package/src/mcp/terraform/tools/scan.ts +5 -3
  140. package/src/mcp/terraform/tools/standardsReport.ts +1 -1
  141. package/src/mcp/terraform/tools/validate.ts +20 -5
  142. package/src/mcp/terraform/tools/verifyRemediation.ts +14 -7
  143. package/src/mcp/terraform/tools/versionCurrency.ts +3 -1
  144. package/src/mcp/terraform/treeLayout.ts +378 -0
  145. package/src/mcp/terraform/types.ts +4 -1
  146. package/src/mcp/terraform/versionRequirements.ts +11 -2
  147. package/src/modes/__snapshots__/assemblePrompt.test.ts.snap +2 -0
  148. package/src/modes/modernize-deprecated.ts +2 -2
  149. package/src/modes/refactor.ts +9 -9
  150. package/src/modes/remediate.ts +1 -1
  151. package/src/modes/terraform-code-review.ts +6 -3
  152. package/src/modes/update-dependencies.ts +6 -6
  153. package/src/phases/applyPlan.ts +33 -14
  154. package/src/phases/applySuggestions.ts +2 -2
  155. package/src/phases/runAgentWithWatchdogs.ts +2 -1
  156. package/src/toolState.ts +7 -0
  157. package/src/utils/agent/codexOAuth.ts +7 -7
  158. package/src/utils/agent/openCodeModels.ts +4 -6
  159. package/src/utils/cli.ts +1 -31
  160. package/src/utils/cloud/runContext.ts +1 -8
  161. package/src/utils/config/baseRefConfig.ts +6 -0
  162. package/src/utils/config/infraweaverConfig.ts +2 -0
  163. package/src/utils/config/payload.ts +41 -0
  164. package/src/utils/github/assets.ts +1 -6
  165. package/src/utils/github/github.ts +42 -150
  166. package/src/utils/github/token.ts +6 -11
  167. package/src/utils/log.ts +4 -5
  168. package/src/utils/markdownTable.ts +11 -0
  169. package/src/utils/prompt/changeImpact.ts +18 -26
  170. package/src/utils/prompt/instructions.ts +1 -1
  171. package/src/utils/prompt/promptDirectives.ts +1 -1
  172. package/src/utils/prompt/toolSelection.ts +11 -2
  173. package/src/utils/setup/toolLicensing.ts +7 -0
  174. package/src/utils/telemetry.ts +2 -1
  175. package/src/utils/unifiedDiff.ts +120 -0
@@ -41,6 +41,8 @@ export interface DeltaFinding {
41
41
  block?: string;
42
42
  /** an introduced finding whose resource may be an undeclared rename. */
43
43
  possiblyPreexisting?: true;
44
+ /** with `possiblyPreexisting`: the vanished resource it pairs with on the base. */
45
+ renamedFrom?: { address: string; file: string };
44
46
  }
45
47
 
46
48
  export interface ScanDelta {
@@ -302,9 +304,41 @@ function markPossibleRenames(
302
304
  if (!match) continue;
303
305
  used.add(match);
304
306
  finding.possiblyPreexisting = true;
307
+ finding.renamedFrom = { address: match.address as string, file: match.concern.location.file };
305
308
  }
306
309
  }
307
310
 
311
+ /** One resource that looks renamed (or moved to another directory) without a
312
+ * `moved` block, and how many introduced findings ride on it. */
313
+ export interface UndeclaredRename {
314
+ from: { address: string; dir: string };
315
+ to: { address: string; dir: string };
316
+ findings: number;
317
+ }
318
+
319
+ /**
320
+ * The possibly-pre-existing findings grouped by the rename behind them.
321
+ *
322
+ * Fifteen findings on one renamed bucket are one thing for the author to do —
323
+ * add a `moved` block — not fifteen, and without that block `terraform apply`
324
+ * destroys the old resource and creates the new one. So a verdict reads better
325
+ * naming the resource once than listing every rule it carries. Order follows
326
+ * the findings (which are sorted by location), so the output is stable.
327
+ */
328
+ export function undeclaredRenames(introduced: readonly DeltaFinding[]): UndeclaredRename[] {
329
+ const byPair = new Map<string, UndeclaredRename>();
330
+ for (const f of introduced) {
331
+ if (!f.possiblyPreexisting || !f.renamedFrom || f.address === null) continue;
332
+ const from = { address: f.renamedFrom.address, dir: dirOf(f.renamedFrom.file) };
333
+ const to = { address: f.address, dir: dirOf(f.concern.location.file) };
334
+ const key = `${from.dir}|${from.address}|${to.dir}|${to.address}`;
335
+ const seen = byPair.get(key);
336
+ if (seen) seen.findings++;
337
+ else byPair.set(key, { from, to, findings: 1 });
338
+ }
339
+ return [...byPair.values()];
340
+ }
341
+
308
342
  function byLocation(a: Concern, b: Concern): number {
309
343
  return (
310
344
  a.location.file.localeCompare(b.location.file) ||
@@ -71,6 +71,12 @@ export interface ScanSession {
71
71
  // by cloudReport to build the dashboard report. undefined until a scan ran;
72
72
  // [] means the scan came back clean.
73
73
  lastScanConcerns?: Concern[];
74
+ // every concern ANY concern source this run reported, by id. An id is
75
+ // line-pinned, so a re-scan after an edit reports the same finding under a
76
+ // new id and replaces lastScanConcerns; verify must still key the ids the
77
+ // agent took from the FIRST scan (`concernKeyOf`), or it falls back to
78
+ // matching ids exactly and calls every line-shifted finding resolved.
79
+ concernsById?: Map<string, Concern>;
74
80
  // the findings gate's concern set: scanned by the engine itself before the
75
81
  // agent starts, on the tree the run was invoked on, at the CONFIGURED
76
82
  // threshold and scope. read at end-of-run by finalizeSuccessRun for the
@@ -142,6 +148,10 @@ export interface ScanSession {
142
148
  // `forgotten` blind-spot list and every coverage gap — enters the SIGNED
143
149
  // bundle instead of dying as a run verdict. undefined until drift ran.
144
150
  lastDrift?: DriftEvidenceStatement | undefined;
151
+ // the compliance artefacts an emit tool wrote this run: absolute path → the
152
+ // git blob id of every version written. Read by the Terraform-only push
153
+ // guardrail, which lets exactly those bytes through (see emittedArtefacts.ts).
154
+ emittedArtefacts?: Record<string, string[]>;
145
155
  // absolute path of a SARIF file the agent wrote via terraform_emit_sarif.
146
156
  // set by that tool on a successful write. read by finalizeSuccessRun's
147
157
  // findings-output step so the end-of-run safety-net emit does NOT clobber an
@@ -261,6 +271,11 @@ export interface ScanSession {
261
271
  // between the two tools, and a stale pairing corroborates nothing. Addresses
262
272
  // and attribute NAMES only; the plan's values are never stored.
263
273
  lastPlanPairs?: { fingerprint: string; pairs: PairAnalysis };
274
+ // the `terraform validate` errors the run-start commit already has, as
275
+ // `file: message` keys. Computed once per base by terraform_equivalence_check,
276
+ // and only when the working tree fails validate — so it can tell an error the
277
+ // change introduced from one it inherited.
278
+ baselineValidateErrors?: { base: string; errors: string[] };
264
279
  // was the upgrade ALREADY detected when this plan ran? Set by
265
280
  // terraform_plan from whether `upgradeIntent` existed at that moment.
266
281
  //
@@ -318,6 +333,21 @@ export function scanSessionOf(toolState: { scanSession?: ScanSession }): ScanSes
318
333
  return toolState.scanSession;
319
334
  }
320
335
 
336
+ /** Publish a scan's reported concern set, and remember each concern for the
337
+ * rest of the run (see `concernsById`). */
338
+ export function recordScanConcerns(session: ScanSession, concerns: Concern[]): void {
339
+ session.lastScanConcerns = concerns;
340
+ recordConcernKeys(session, concerns);
341
+ }
342
+
343
+ /** Remember each concern for the rest of the run, so
344
+ * terraform_verify_remediation can key an id from ANY concern source — a
345
+ * findings file or an external report as much as a scan. */
346
+ export function recordConcernKeys(session: ScanSession, concerns: Concern[]): void {
347
+ session.concernsById ??= new Map();
348
+ for (const c of concerns) session.concernsById.set(c.id, c);
349
+ }
350
+
321
351
  /**
322
352
  * true once terraform_scan / read_findings captured a pre-fix baseline this
323
353
  * session. terraform_verify_remediation key-maps requested ids against the
@@ -131,6 +131,10 @@ function toolchainSignature(opts: RunScannersOptions): string {
131
131
  // the native repeated-literal rule keys its findings on this threshold, so
132
132
  // two scans differing only here produce different finding sets.
133
133
  repeatedLiteralThreshold: opts.repeatedLiteralThreshold ?? null,
134
+ // a scoped scan holds only some directories' findings, and the variable
135
+ // files decide which values trivy and checkov evaluate
136
+ scope: opts.scope ?? null,
137
+ varFiles: opts.varFiles ?? null,
134
138
  // egress policy changes both the subprocess env AND the outcome's
135
139
  // `egress_isolation` marker — a denied scan must not serve an open-scan
136
140
  // cache entry (or vice versa), else the run summary lies about isolation.