infraweaver 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 (524) hide show
  1. package/LICENSE +661 -0
  2. package/README.md +244 -0
  3. package/dist/agents/claude.d.ts +113 -0
  4. package/dist/agents/claudePretoolGate.d.ts +137 -0
  5. package/dist/agents/dispatchMetrics.d.ts +77 -0
  6. package/dist/agents/gateServer.d.ts +7 -0
  7. package/dist/agents/index.d.ts +6 -0
  8. package/dist/agents/nativeFsDenies.d.ts +46 -0
  9. package/dist/agents/opencode.d.ts +284 -0
  10. package/dist/agents/opencodePlugin.d.ts +96 -0
  11. package/dist/agents/opencodeShared.d.ts +40 -0
  12. package/dist/agents/postRun.d.ts +126 -0
  13. package/dist/agents/reviewer.d.ts +41 -0
  14. package/dist/agents/sessionLabeler.d.ts +97 -0
  15. package/dist/agents/shared.d.ts +246 -0
  16. package/dist/agents/subagentModels.d.ts +19 -0
  17. package/dist/agents/tokenQuota.d.ts +118 -0
  18. package/dist/agents/writeGateSource.d.ts +22 -0
  19. package/dist/agents/writePolicy.d.ts +79 -0
  20. package/dist/brand.d.ts +67 -0
  21. package/dist/cli.mjs +247846 -0
  22. package/dist/external.d.ts +227 -0
  23. package/dist/i18n/scaffolding.d.ts +59 -0
  24. package/dist/index.d.ts +6 -0
  25. package/dist/index.js +247061 -0
  26. package/dist/internal/index.d.ts +18 -0
  27. package/dist/internal.js +2398 -0
  28. package/dist/lifecycle.d.ts +2 -0
  29. package/dist/main.d.ts +8 -0
  30. package/dist/mcp/arkConfig.d.ts +1 -0
  31. package/dist/mcp/assess.d.ts +157 -0
  32. package/dist/mcp/capabilityContext.d.ts +71 -0
  33. package/dist/mcp/changeSummary.d.ts +52 -0
  34. package/dist/mcp/checkSuite.d.ts +27 -0
  35. package/dist/mcp/checkout.d.ts +92 -0
  36. package/dist/mcp/comment.d.ts +127 -0
  37. package/dist/mcp/commitInfo.d.ts +11 -0
  38. package/dist/mcp/crosswalk.d.ts +178 -0
  39. package/dist/mcp/crosswalkDigest.d.ts +1 -0
  40. package/dist/mcp/cyberEssentials.d.ts +24 -0
  41. package/dist/mcp/dashboard.d.ts +125 -0
  42. package/dist/mcp/dependencies.d.ts +12 -0
  43. package/dist/mcp/frameworks.d.ts +74 -0
  44. package/dist/mcp/geminiSanitizer.d.ts +28 -0
  45. package/dist/mcp/git.d.ts +60 -0
  46. package/dist/mcp/guardrails.d.ts +222 -0
  47. package/dist/mcp/issue.d.ts +20 -0
  48. package/dist/mcp/issueComments.d.ts +11 -0
  49. package/dist/mcp/issueEvents.d.ts +11 -0
  50. package/dist/mcp/issueInfo.d.ts +11 -0
  51. package/dist/mcp/labels.d.ts +14 -0
  52. package/dist/mcp/localContext.d.ts +26 -0
  53. package/dist/mcp/moduleExtraction.d.ts +79 -0
  54. package/dist/mcp/moduleTests.d.ts +106 -0
  55. package/dist/mcp/modules.d.ts +198 -0
  56. package/dist/mcp/output.d.ts +16 -0
  57. package/dist/mcp/pathSafety.d.ts +14 -0
  58. package/dist/mcp/policy.d.ts +50 -0
  59. package/dist/mcp/pr.d.ts +64 -0
  60. package/dist/mcp/prInfo.d.ts +11 -0
  61. package/dist/mcp/providerSchema.d.ts +52 -0
  62. package/dist/mcp/review.d.ts +212 -0
  63. package/dist/mcp/reviewComments.d.ts +245 -0
  64. package/dist/mcp/roots.d.ts +60 -0
  65. package/dist/mcp/scope.d.ts +26 -0
  66. package/dist/mcp/selectMode.d.ts +20 -0
  67. package/dist/mcp/server.d.ts +61 -0
  68. package/dist/mcp/shared.d.ts +62 -0
  69. package/dist/mcp/shell.d.ts +58 -0
  70. package/dist/mcp/staleFix.d.ts +138 -0
  71. package/dist/mcp/terraform/azurePrices.d.ts +8 -0
  72. package/dist/mcp/terraform/baseline.d.ts +57 -0
  73. package/dist/mcp/terraform/concernResult.d.ts +38 -0
  74. package/dist/mcp/terraform/cost.d.ts +55 -0
  75. package/dist/mcp/terraform/cspm.d.ts +80 -0
  76. package/dist/mcp/terraform/currency.d.ts +110 -0
  77. package/dist/mcp/terraform/decisions.d.ts +178 -0
  78. package/dist/mcp/terraform/eidas.d.ts +100 -0
  79. package/dist/mcp/terraform/evidence.d.ts +343 -0
  80. package/dist/mcp/terraform/findings.d.ts +76 -0
  81. package/dist/mcp/terraform/fixMemory.d.ts +81 -0
  82. package/dist/mcp/terraform/governance.d.ts +56 -0
  83. package/dist/mcp/terraform/hcl.d.ts +115 -0
  84. package/dist/mcp/terraform/iacLanguages.d.ts +120 -0
  85. package/dist/mcp/terraform/idleFloor.d.ts +78 -0
  86. package/dist/mcp/terraform/keyless.d.ts +68 -0
  87. package/dist/mcp/terraform/moduleDocs.d.ts +56 -0
  88. package/dist/mcp/terraform/nativeRules.d.ts +38 -0
  89. package/dist/mcp/terraform/nativeScan.d.ts +11 -0
  90. package/dist/mcp/terraform/noiseProfile.d.ts +100 -0
  91. package/dist/mcp/terraform/normalization.d.ts +52 -0
  92. package/dist/mcp/terraform/oscal.d.ts +103 -0
  93. package/dist/mcp/terraform/packs/azurerm-3-4.d.ts +2 -0
  94. package/dist/mcp/terraform/packs/cloudflare-4-5.d.ts +2 -0
  95. package/dist/mcp/terraform/paths.d.ts +28 -0
  96. package/dist/mcp/terraform/plan.d.ts +157 -0
  97. package/dist/mcp/terraform/planDrift.d.ts +199 -0
  98. package/dist/mcp/terraform/policyAuthor.d.ts +191 -0
  99. package/dist/mcp/terraform/prowlerOcsf.d.ts +136 -0
  100. package/dist/mcp/terraform/refactor.d.ts +183 -0
  101. package/dist/mcp/terraform/registry.d.ts +108 -0
  102. package/dist/mcp/terraform/risk.d.ts +41 -0
  103. package/dist/mcp/terraform/scanSession.d.ts +116 -0
  104. package/dist/mcp/terraform/scannerCache.d.ts +15 -0
  105. package/dist/mcp/terraform/scannerEgress.d.ts +72 -0
  106. package/dist/mcp/terraform/scannerJson.d.ts +13 -0
  107. package/dist/mcp/terraform/scanners.d.ts +205 -0
  108. package/dist/mcp/terraform/signing.d.ts +61 -0
  109. package/dist/mcp/terraform/stateLocking.d.ts +18 -0
  110. package/dist/mcp/terraform/subprocess.d.ts +43 -0
  111. package/dist/mcp/terraform/suppressions.d.ts +90 -0
  112. package/dist/mcp/terraform/taxonomy.d.ts +39 -0
  113. package/dist/mcp/terraform/tfquery.d.ts +47 -0
  114. package/dist/mcp/terraform/toolchainIntegrity.d.ts +82 -0
  115. package/dist/mcp/terraform/tools/authorPolicy.d.ts +59 -0
  116. package/dist/mcp/terraform/tools/detectPlanDrift.d.ts +20 -0
  117. package/dist/mcp/terraform/tools/emitCost.d.ts +11 -0
  118. package/dist/mcp/terraform/tools/emitSarif.d.ts +14 -0
  119. package/dist/mcp/terraform/tools/fixMemory.d.ts +19 -0
  120. package/dist/mcp/terraform/tools/infracostDiff.d.ts +22 -0
  121. package/dist/mcp/terraform/tools/ingestExternalFindings.d.ts +21 -0
  122. package/dist/mcp/terraform/tools/moduleLookup.d.ts +14 -0
  123. package/dist/mcp/terraform/tools/moduleSearch.d.ts +23 -0
  124. package/dist/mcp/terraform/tools/plan.d.ts +59 -0
  125. package/dist/mcp/terraform/tools/providerUpgrade.d.ts +55 -0
  126. package/dist/mcp/terraform/tools/readFindings.d.ts +17 -0
  127. package/dist/mcp/terraform/tools/scan.d.ts +114 -0
  128. package/dist/mcp/terraform/tools/validate.d.ts +31 -0
  129. package/dist/mcp/terraform/tools/verifyRemediation.d.ts +31 -0
  130. package/dist/mcp/terraform/tools/versionCurrency.d.ts +5 -0
  131. package/dist/mcp/terraform/tools.d.ts +16 -0
  132. package/dist/mcp/terraform/transformPacks.d.ts +267 -0
  133. package/dist/mcp/terraform/types.d.ts +226 -0
  134. package/dist/mcp/terraform/verification.d.ts +81 -0
  135. package/dist/mcp/terraform/vex.d.ts +115 -0
  136. package/dist/mcp/terraform/writeOnly.d.ts +67 -0
  137. package/dist/mcp/terraform.d.ts +51 -0
  138. package/dist/mcp/terratest.d.ts +85 -0
  139. package/dist/mcp/untrustedContent.d.ts +76 -0
  140. package/dist/mcp/upload.d.ts +8 -0
  141. package/dist/models.d.ts +181 -0
  142. package/dist/modes/address-reviews.d.ts +2 -0
  143. package/dist/modes/assess.d.ts +2 -0
  144. package/dist/modes/build.d.ts +2 -0
  145. package/dist/modes/compliance-audit.d.ts +2 -0
  146. package/dist/modes/cost-optimization.d.ts +2 -0
  147. package/dist/modes/drift-detect.d.ts +2 -0
  148. package/dist/modes/fix.d.ts +2 -0
  149. package/dist/modes/incremental-review.d.ts +2 -0
  150. package/dist/modes/index.d.ts +24 -0
  151. package/dist/modes/modernize-deprecated.d.ts +2 -0
  152. package/dist/modes/plan.d.ts +2 -0
  153. package/dist/modes/policy-gate.d.ts +2 -0
  154. package/dist/modes/prFormats.d.ts +3 -0
  155. package/dist/modes/refactor.d.ts +2 -0
  156. package/dist/modes/refresh-remediation.d.ts +2 -0
  157. package/dist/modes/remediate-and-refactor.d.ts +2 -0
  158. package/dist/modes/remediate.d.ts +2 -0
  159. package/dist/modes/resolve-conflicts.d.ts +2 -0
  160. package/dist/modes/review.d.ts +2 -0
  161. package/dist/modes/summarize-pr.d.ts +2 -0
  162. package/dist/modes/task.d.ts +2 -0
  163. package/dist/modes/terraform-code-review.d.ts +2 -0
  164. package/dist/modes/types.d.ts +9 -0
  165. package/dist/modes/update-dependencies.d.ts +2 -0
  166. package/dist/prep/index.d.ts +7 -0
  167. package/dist/prep/installNodeDependencies.d.ts +2 -0
  168. package/dist/prep/installPythonDependencies.d.ts +2 -0
  169. package/dist/prep/types.d.ts +31 -0
  170. package/dist/reviewQuality.d.ts +107 -0
  171. package/dist/skills/terraform-best-practices/SKILL.md +379 -0
  172. package/dist/toolState.d.ts +123 -0
  173. package/dist/utils/activity.d.ts +40 -0
  174. package/dist/utils/agent.d.ts +47 -0
  175. package/dist/utils/agentHangReport.d.ts +38 -0
  176. package/dist/utils/annotations.d.ts +17 -0
  177. package/dist/utils/apiFetch.d.ts +11 -0
  178. package/dist/utils/apiKeys.d.ts +48 -0
  179. package/dist/utils/apiUrl.d.ts +28 -0
  180. package/dist/utils/assets.d.ts +8 -0
  181. package/dist/utils/baseRefConfig.d.ts +121 -0
  182. package/dist/utils/billingErrors.d.ts +85 -0
  183. package/dist/utils/body.d.ts +34 -0
  184. package/dist/utils/buildInfraweaverFooter.d.ts +29 -0
  185. package/dist/utils/byokFallback.d.ts +85 -0
  186. package/dist/utils/changeImpact.d.ts +101 -0
  187. package/dist/utils/claudeSubscription.d.ts +30 -0
  188. package/dist/utils/cli.d.ts +10 -0
  189. package/dist/utils/cloudClient.d.ts +33 -0
  190. package/dist/utils/cloudFetchCore.d.ts +42 -0
  191. package/dist/utils/cloudReport.d.ts +114 -0
  192. package/dist/utils/codexHome.d.ts +29 -0
  193. package/dist/utils/codexOAuth.d.ts +60 -0
  194. package/dist/utils/diffCoverage.d.ts +63 -0
  195. package/dist/utils/env.d.ts +46 -0
  196. package/dist/utils/errorReport.d.ts +17 -0
  197. package/dist/utils/exitHandler.d.ts +8 -0
  198. package/dist/utils/fixDoubleEscapedString.d.ts +1 -0
  199. package/dist/utils/gitAuth.d.ts +84 -0
  200. package/dist/utils/gitAuthServer.d.ts +24 -0
  201. package/dist/utils/github.d.ts +104 -0
  202. package/dist/utils/globals.d.ts +3 -0
  203. package/dist/utils/infraweaverConfig.d.ts +56 -0
  204. package/dist/utils/install.d.ts +37 -0
  205. package/dist/utils/instructions.d.ts +48 -0
  206. package/dist/utils/keylessOidc.d.ts +28 -0
  207. package/dist/utils/leapingComment.d.ts +11 -0
  208. package/dist/utils/learnings.d.ts +62 -0
  209. package/dist/utils/learningsTruncate.d.ts +25 -0
  210. package/dist/utils/lifecycle.d.ts +57 -0
  211. package/dist/utils/log.d.ts +111 -0
  212. package/dist/utils/modelResolver.d.ts +63 -0
  213. package/dist/utils/moduleFetch.d.ts +39 -0
  214. package/dist/utils/normalizeEnv.d.ts +30 -0
  215. package/dist/utils/openCodeModels.d.ts +11 -0
  216. package/dist/utils/openaiCompatible.d.ts +26 -0
  217. package/dist/utils/opentofuMcp.d.ts +50 -0
  218. package/dist/utils/overrides.d.ts +40 -0
  219. package/dist/utils/packageManager.d.ts +49 -0
  220. package/dist/utils/patchWorkflowRunFields.d.ts +29 -0
  221. package/dist/utils/payload.d.ts +249 -0
  222. package/dist/utils/prSummary.d.ts +61 -0
  223. package/dist/utils/presets.d.ts +36 -0
  224. package/dist/utils/progressComment.d.ts +146 -0
  225. package/dist/utils/providerErrors.d.ts +31 -0
  226. package/dist/utils/proxyModel.d.ts +76 -0
  227. package/dist/utils/rangeDiff.d.ts +51 -0
  228. package/dist/utils/redact.d.ts +33 -0
  229. package/dist/utils/registryAuth.d.ts +52 -0
  230. package/dist/utils/remediationCommand.d.ts +58 -0
  231. package/dist/utils/retry.d.ts +38 -0
  232. package/dist/utils/reviewCleanup.d.ts +14 -0
  233. package/dist/utils/run.d.ts +9 -0
  234. package/dist/utils/runContext.d.ts +112 -0
  235. package/dist/utils/runContextData.d.ts +42 -0
  236. package/dist/utils/runErrorRenderer.d.ts +64 -0
  237. package/dist/utils/runLifecycle.d.ts +89 -0
  238. package/dist/utils/runStartupLog.d.ts +15 -0
  239. package/dist/utils/secrets.d.ts +34 -0
  240. package/dist/utils/setup.d.ts +90 -0
  241. package/dist/utils/shell.d.ts +44 -0
  242. package/dist/utils/skills.d.ts +10 -0
  243. package/dist/utils/subprocess.d.ts +81 -0
  244. package/dist/utils/terraformMcp.d.ts +46 -0
  245. package/dist/utils/time.d.ts +15 -0
  246. package/dist/utils/timer.d.ts +23 -0
  247. package/dist/utils/todoTracking.d.ts +16 -0
  248. package/dist/utils/token.d.ts +52 -0
  249. package/dist/utils/toolLicensing.d.ts +56 -0
  250. package/dist/utils/toolSelection.d.ts +73 -0
  251. package/dist/utils/toon.d.ts +16 -0
  252. package/dist/utils/version.d.ts +2 -0
  253. package/dist/utils/versioning.d.ts +7 -0
  254. package/dist/utils/vertex.d.ts +16 -0
  255. package/dist/utils/workflow.d.ts +13 -0
  256. package/package.json +132 -0
  257. package/src/agents/claude.ts +1588 -0
  258. package/src/agents/claudePretoolGate.ts +286 -0
  259. package/src/agents/dispatchMetrics.ts +162 -0
  260. package/src/agents/gateServer.ts +178 -0
  261. package/src/agents/index.ts +10 -0
  262. package/src/agents/nativeFsDenies.ts +164 -0
  263. package/src/agents/opencode.ts +1600 -0
  264. package/src/agents/opencodePlugin.ts +304 -0
  265. package/src/agents/opencodeShared.ts +134 -0
  266. package/src/agents/postRun.ts +615 -0
  267. package/src/agents/reviewer.ts +134 -0
  268. package/src/agents/sessionLabeler.ts +185 -0
  269. package/src/agents/shared.ts +377 -0
  270. package/src/agents/subagentModels.ts +40 -0
  271. package/src/agents/tokenQuota.ts +203 -0
  272. package/src/agents/writeGateSource.ts +148 -0
  273. package/src/agents/writePolicy.ts +132 -0
  274. package/src/brand.ts +84 -0
  275. package/src/cli.ts +117 -0
  276. package/src/commands/gha.ts +188 -0
  277. package/src/commands/mcp.ts +126 -0
  278. package/src/commands/verifyEvidence.ts +100 -0
  279. package/src/entry.ts +7 -0
  280. package/src/entryPost.ts +109 -0
  281. package/src/external.ts +308 -0
  282. package/src/i18n/scaffolding.ts +191 -0
  283. package/src/index.ts +7 -0
  284. package/src/internal/index.ts +74 -0
  285. package/src/lifecycle.ts +2 -0
  286. package/src/main.ts +815 -0
  287. package/src/mcp/__fixtures__/infraweaver-scratch-pr-49-review-3485940013.json +110 -0
  288. package/src/mcp/__fixtures__/infraweaver-scratch-pr-64-review-3531000326.json +14 -0
  289. package/src/mcp/__fixtures__/infraweaver-test-repo-pr-1.diff.json +67 -0
  290. package/src/mcp/__snapshots__/checkout.test.ts.snap +109 -0
  291. package/src/mcp/__snapshots__/reviewComments.test.ts.snap +71 -0
  292. package/src/mcp/arkConfig.ts +7 -0
  293. package/src/mcp/assess.ts +723 -0
  294. package/src/mcp/capabilityContext.ts +80 -0
  295. package/src/mcp/changeSummary.ts +145 -0
  296. package/src/mcp/checkSuite.ts +261 -0
  297. package/src/mcp/checkout.ts +1015 -0
  298. package/src/mcp/comment.ts +683 -0
  299. package/src/mcp/commitInfo.ts +57 -0
  300. package/src/mcp/crosswalk.ts +1253 -0
  301. package/src/mcp/crosswalkDigest.ts +5 -0
  302. package/src/mcp/cyberEssentials.ts +60 -0
  303. package/src/mcp/dashboard.ts +232 -0
  304. package/src/mcp/dependencies.ts +190 -0
  305. package/src/mcp/frameworks.ts +236 -0
  306. package/src/mcp/geminiSanitizer.ts +212 -0
  307. package/src/mcp/git.ts +1116 -0
  308. package/src/mcp/guardrails.ts +771 -0
  309. package/src/mcp/issue.ts +74 -0
  310. package/src/mcp/issueComments.ts +48 -0
  311. package/src/mcp/issueEvents.ts +100 -0
  312. package/src/mcp/issueInfo.ts +72 -0
  313. package/src/mcp/labels.ts +35 -0
  314. package/src/mcp/localContext.ts +65 -0
  315. package/src/mcp/localServer.ts +217 -0
  316. package/src/mcp/moduleExtraction.ts +368 -0
  317. package/src/mcp/moduleTests.ts +421 -0
  318. package/src/mcp/modules.ts +752 -0
  319. package/src/mcp/output.ts +71 -0
  320. package/src/mcp/pathSafety.ts +28 -0
  321. package/src/mcp/policy.ts +226 -0
  322. package/src/mcp/pr.ts +238 -0
  323. package/src/mcp/prInfo.ts +91 -0
  324. package/src/mcp/providerSchema.ts +175 -0
  325. package/src/mcp/review.ts +1081 -0
  326. package/src/mcp/reviewComments.ts +1137 -0
  327. package/src/mcp/roots.ts +217 -0
  328. package/src/mcp/scope.ts +82 -0
  329. package/src/mcp/selectMode.ts +207 -0
  330. package/src/mcp/server.ts +498 -0
  331. package/src/mcp/shared.ts +120 -0
  332. package/src/mcp/shell.ts +631 -0
  333. package/src/mcp/staleFix.ts +557 -0
  334. package/src/mcp/terraform/__snapshots__/moduleDocs.test.ts.snap +40 -0
  335. package/src/mcp/terraform/azurePrices.ts +38 -0
  336. package/src/mcp/terraform/baseline.ts +172 -0
  337. package/src/mcp/terraform/concernResult.ts +111 -0
  338. package/src/mcp/terraform/cost.ts +175 -0
  339. package/src/mcp/terraform/cspm.ts +326 -0
  340. package/src/mcp/terraform/currency.ts +354 -0
  341. package/src/mcp/terraform/decisions.ts +590 -0
  342. package/src/mcp/terraform/eidas.ts +134 -0
  343. package/src/mcp/terraform/evidence.ts +771 -0
  344. package/src/mcp/terraform/findings.ts +383 -0
  345. package/src/mcp/terraform/fixMemory.ts +253 -0
  346. package/src/mcp/terraform/governance.ts +231 -0
  347. package/src/mcp/terraform/hcl.ts +273 -0
  348. package/src/mcp/terraform/iacLanguages.ts +431 -0
  349. package/src/mcp/terraform/idleFloor.ts +304 -0
  350. package/src/mcp/terraform/keyless.ts +123 -0
  351. package/src/mcp/terraform/moduleDocs.ts +303 -0
  352. package/src/mcp/terraform/nativeRules.ts +152 -0
  353. package/src/mcp/terraform/nativeScan.ts +67 -0
  354. package/src/mcp/terraform/noiseProfile.ts +183 -0
  355. package/src/mcp/terraform/normalization.ts +265 -0
  356. package/src/mcp/terraform/oscal.ts +283 -0
  357. package/src/mcp/terraform/packs/azurerm-3-4.ts +382 -0
  358. package/src/mcp/terraform/packs/cloudflare-4-5.ts +114 -0
  359. package/src/mcp/terraform/paths.ts +59 -0
  360. package/src/mcp/terraform/plan.ts +377 -0
  361. package/src/mcp/terraform/planDrift.ts +520 -0
  362. package/src/mcp/terraform/policyAuthor.ts +886 -0
  363. package/src/mcp/terraform/prowlerOcsf.ts +380 -0
  364. package/src/mcp/terraform/refactor.ts +879 -0
  365. package/src/mcp/terraform/registry.ts +317 -0
  366. package/src/mcp/terraform/risk.ts +99 -0
  367. package/src/mcp/terraform/scanSession.ts +242 -0
  368. package/src/mcp/terraform/scannerCache.ts +86 -0
  369. package/src/mcp/terraform/scannerEgress.ts +141 -0
  370. package/src/mcp/terraform/scannerJson.ts +22 -0
  371. package/src/mcp/terraform/scanners.ts +1134 -0
  372. package/src/mcp/terraform/signing.ts +151 -0
  373. package/src/mcp/terraform/stateLocking.ts +106 -0
  374. package/src/mcp/terraform/subprocess.ts +102 -0
  375. package/src/mcp/terraform/suppressions.ts +551 -0
  376. package/src/mcp/terraform/taxonomy.ts +0 -0
  377. package/src/mcp/terraform/tfquery.ts +159 -0
  378. package/src/mcp/terraform/toolchainIntegrity.ts +151 -0
  379. package/src/mcp/terraform/tools/authorPolicy.ts +185 -0
  380. package/src/mcp/terraform/tools/detectPlanDrift.ts +279 -0
  381. package/src/mcp/terraform/tools/emitCost.ts +130 -0
  382. package/src/mcp/terraform/tools/emitSarif.ts +108 -0
  383. package/src/mcp/terraform/tools/fixMemory.ts +82 -0
  384. package/src/mcp/terraform/tools/infracostDiff.ts +110 -0
  385. package/src/mcp/terraform/tools/ingestExternalFindings.ts +259 -0
  386. package/src/mcp/terraform/tools/moduleLookup.ts +86 -0
  387. package/src/mcp/terraform/tools/moduleSearch.ts +46 -0
  388. package/src/mcp/terraform/tools/plan.ts +384 -0
  389. package/src/mcp/terraform/tools/providerUpgrade.ts +217 -0
  390. package/src/mcp/terraform/tools/readFindings.ts +138 -0
  391. package/src/mcp/terraform/tools/scan.ts +303 -0
  392. package/src/mcp/terraform/tools/validate.ts +160 -0
  393. package/src/mcp/terraform/tools/verifyRemediation.ts +190 -0
  394. package/src/mcp/terraform/tools/versionCurrency.ts +64 -0
  395. package/src/mcp/terraform/tools.ts +62 -0
  396. package/src/mcp/terraform/transformPacks.ts +594 -0
  397. package/src/mcp/terraform/types.ts +382 -0
  398. package/src/mcp/terraform/verification.ts +150 -0
  399. package/src/mcp/terraform/vex.ts +367 -0
  400. package/src/mcp/terraform/writeOnly.ts +252 -0
  401. package/src/mcp/terraform.ts +52 -0
  402. package/src/mcp/terratest.ts +215 -0
  403. package/src/mcp/untrustedContent.ts +126 -0
  404. package/src/mcp/upload.ts +123 -0
  405. package/src/models.ts +753 -0
  406. package/src/modes/address-reviews.ts +35 -0
  407. package/src/modes/assess.ts +27 -0
  408. package/src/modes/build.ts +86 -0
  409. package/src/modes/compliance-audit.ts +25 -0
  410. package/src/modes/cost-optimization.ts +36 -0
  411. package/src/modes/drift-detect.ts +31 -0
  412. package/src/modes/fix.ts +29 -0
  413. package/src/modes/incremental-review.ts +103 -0
  414. package/src/modes/index.ts +94 -0
  415. package/src/modes/modernize-deprecated.ts +36 -0
  416. package/src/modes/plan.ts +21 -0
  417. package/src/modes/policy-gate.ts +27 -0
  418. package/src/modes/prFormats.ts +325 -0
  419. package/src/modes/refactor.ts +74 -0
  420. package/src/modes/refresh-remediation.ts +40 -0
  421. package/src/modes/remediate-and-refactor.ts +42 -0
  422. package/src/modes/remediate.ts +78 -0
  423. package/src/modes/resolve-conflicts.ts +32 -0
  424. package/src/modes/review.ts +135 -0
  425. package/src/modes/summarize-pr.ts +42 -0
  426. package/src/modes/task.ts +26 -0
  427. package/src/modes/terraform-code-review.ts +68 -0
  428. package/src/modes/types.ts +17 -0
  429. package/src/modes/update-dependencies.ts +44 -0
  430. package/src/prep/index.ts +96 -0
  431. package/src/prep/installNodeDependencies.ts +251 -0
  432. package/src/prep/installPythonDependencies.ts +235 -0
  433. package/src/prep/types.ts +38 -0
  434. package/src/reviewQuality.ts +237 -0
  435. package/src/runCli.ts +335 -0
  436. package/src/skills/terraform-best-practices/SKILL.md +379 -0
  437. package/src/toolState.ts +241 -0
  438. package/src/utils/activity.ts +210 -0
  439. package/src/utils/agent.ts +245 -0
  440. package/src/utils/agentHangReport.ts +180 -0
  441. package/src/utils/annotations.ts +56 -0
  442. package/src/utils/apiFetch.ts +19 -0
  443. package/src/utils/apiKeys.ts +305 -0
  444. package/src/utils/apiUrl.ts +42 -0
  445. package/src/utils/assets.ts +123 -0
  446. package/src/utils/baseRefConfig.ts +254 -0
  447. package/src/utils/billingErrors.ts +210 -0
  448. package/src/utils/body.ts +168 -0
  449. package/src/utils/buildInfraweaverFooter.ts +104 -0
  450. package/src/utils/byokFallback.ts +137 -0
  451. package/src/utils/changeImpact.ts +330 -0
  452. package/src/utils/claudeSubscription.ts +93 -0
  453. package/src/utils/cli.ts +36 -0
  454. package/src/utils/cloudClient.ts +57 -0
  455. package/src/utils/cloudFetchCore.ts +139 -0
  456. package/src/utils/cloudReport.ts +316 -0
  457. package/src/utils/codexHome.ts +204 -0
  458. package/src/utils/codexOAuth.ts +154 -0
  459. package/src/utils/codexRefreshDetect.ts +36 -0
  460. package/src/utils/diffCoverage.ts +404 -0
  461. package/src/utils/env.ts +84 -0
  462. package/src/utils/errorReport.ts +94 -0
  463. package/src/utils/exitHandler.ts +35 -0
  464. package/src/utils/fixDoubleEscapedString.ts +9 -0
  465. package/src/utils/ghaCore.ts +13 -0
  466. package/src/utils/gitAuth.ts +268 -0
  467. package/src/utils/gitAuthServer.ts +186 -0
  468. package/src/utils/github.ts +676 -0
  469. package/src/utils/globals.ts +9 -0
  470. package/src/utils/humanEditCapture.ts +198 -0
  471. package/src/utils/infraweaverConfig.ts +202 -0
  472. package/src/utils/install.ts +279 -0
  473. package/src/utils/instructions.ts +640 -0
  474. package/src/utils/keylessOidc.ts +47 -0
  475. package/src/utils/leapingComment.ts +20 -0
  476. package/src/utils/learnings.ts +145 -0
  477. package/src/utils/learningsTruncate.ts +42 -0
  478. package/src/utils/lifecycle.ts +198 -0
  479. package/src/utils/log.ts +452 -0
  480. package/src/utils/modelResolver.ts +105 -0
  481. package/src/utils/moduleFetch.ts +138 -0
  482. package/src/utils/normalizeEnv.ts +106 -0
  483. package/src/utils/openCodeModels.ts +86 -0
  484. package/src/utils/openaiCompatible.ts +52 -0
  485. package/src/utils/opentofuMcp.ts +61 -0
  486. package/src/utils/overrides.ts +100 -0
  487. package/src/utils/packageManager.ts +257 -0
  488. package/src/utils/patchWorkflowRunFields.ts +173 -0
  489. package/src/utils/payload.ts +1206 -0
  490. package/src/utils/prSummary.ts +148 -0
  491. package/src/utils/presets.ts +105 -0
  492. package/src/utils/progressComment.ts +266 -0
  493. package/src/utils/providerErrors.ts +189 -0
  494. package/src/utils/proxyModel.ts +239 -0
  495. package/src/utils/rangeDiff.ts +182 -0
  496. package/src/utils/redact.ts +86 -0
  497. package/src/utils/registryAuth.ts +115 -0
  498. package/src/utils/remediationCommand.ts +144 -0
  499. package/src/utils/retry.ts +180 -0
  500. package/src/utils/reviewCleanup.ts +116 -0
  501. package/src/utils/run.ts +100 -0
  502. package/src/utils/runContext.ts +276 -0
  503. package/src/utils/runContextData.ts +121 -0
  504. package/src/utils/runErrorRenderer.ts +282 -0
  505. package/src/utils/runFixture.ts +91 -0
  506. package/src/utils/runLifecycle.ts +360 -0
  507. package/src/utils/runStartupLog.ts +67 -0
  508. package/src/utils/secrets.ts +208 -0
  509. package/src/utils/setup.ts +368 -0
  510. package/src/utils/shell.ts +132 -0
  511. package/src/utils/skills.ts +67 -0
  512. package/src/utils/subprocess.ts +474 -0
  513. package/src/utils/terraformMcp.ts +99 -0
  514. package/src/utils/time.ts +59 -0
  515. package/src/utils/timer.ts +72 -0
  516. package/src/utils/todoTracking.ts +168 -0
  517. package/src/utils/token.ts +294 -0
  518. package/src/utils/toolLicensing.ts +152 -0
  519. package/src/utils/toolSelection.ts +239 -0
  520. package/src/utils/toon.ts +76 -0
  521. package/src/utils/version.ts +10 -0
  522. package/src/utils/versioning.ts +44 -0
  523. package/src/utils/vertex.ts +94 -0
  524. package/src/utils/workflow.ts +25 -0
@@ -0,0 +1,48 @@
1
+ /**
2
+ * Validate that the resolved model can actually be served by the chosen
3
+ * agent. For routing slugs (Bedrock / Vertex) the auth shape is multi-var
4
+ * (auth + region/location + model-id) and `opencode models` doesn't catch
5
+ * gaps in the latter two — keep dedicated setup validators. For the
6
+ * opencode path, the authoritative answer comes from OpenCode's own model
7
+ * introspection (`authorized` set captured in `openCodeModels.ts`). For
8
+ * the claude path, fall back to the static check (`ANTHROPIC_API_KEY` /
9
+ * `CLAUDE_CODE_OAUTH_TOKEN`).
10
+ */
11
+ export declare function validateAgentApiKey(params: {
12
+ agent: {
13
+ name: string;
14
+ };
15
+ model: string | undefined;
16
+ authorized: Set<string>;
17
+ owner: string;
18
+ name: string;
19
+ }): void;
20
+ /**
21
+ * Detect agent-runtime auth failures that should be reformatted as an actionable
22
+ * key-fix CTA before being shown to the user. Covers the shapes we see:
23
+ * - missing key (validateAgentApiKey throw): contains MISSING_KEY_MARKER
24
+ * - revoked / invalid key (Claude CLI 401 surfaced via api_error_status):
25
+ * "Invalid API key · Fix external API key" + similar provider variants
26
+ * - direct-Anthropic 401 (`Failed to authenticate. API Error: 401 ...
27
+ * {"type":"error","error":{"type":"authentication_error", ...
28
+ * "Invalid bearer token"}}`) emitted by the Claude CLI for revoked /
29
+ * mistyped / rotated `ANTHROPIC_API_KEY`. see #782.
30
+ */
31
+ export declare function isApiKeyAuthError(text: string): boolean;
32
+ /**
33
+ * A subscription/OAuth credential (Claude `CLAUDE_CODE_OAUTH_TOKEN`, Codex OAuth, or a
34
+ * short-lived Bedrock bearer) that has EXPIRED — distinct from a rejected/mistyped key.
35
+ * The fix is to refresh/re-mint the credential, not rotate an API key, so it gets its
36
+ * own CTA in {@link formatApiKeyErrorSummary}.
37
+ */
38
+ export declare function isOAuthCredentialExpiredError(text: string): boolean;
39
+ /**
40
+ * Friendly Markdown summary for both the missing-key and invalid-key cases.
41
+ * Used in the catch / result-failure paths in `main.ts` to overwrite the raw
42
+ * agent error before it's posted to the PR progress comment.
43
+ */
44
+ export declare function formatApiKeyErrorSummary(params: {
45
+ owner: string;
46
+ name: string;
47
+ raw: string;
48
+ }): string;
@@ -0,0 +1,28 @@
1
+ /**
2
+ * resolve the Infraweaver API base URL. validation (https enforcement, the
3
+ * bearer-credential host allowlist, API_ALLOWED_HOSTS) lives in
4
+ * cloudFetchCore.ts so the stdlib-only post hook enforces the same policy.
5
+ */
6
+ export declare function getApiUrl(): string;
7
+ /**
8
+ * Whether a real Infraweaver backend is configured.
9
+ *
10
+ * Standalone BYOK runs (the OSS default) leave `API_URL` unset — `getApiUrl`
11
+ * then falls back to the marketing host, which serves no API. The dormant
12
+ * open-core persistence seams (repo learnings, run-field PATCHes) must no-op
13
+ * in that case rather than POST into the void and surface the host's 404 as a
14
+ * CI warning. A real backend — the hosted SaaS, or local dev with
15
+ * `API_URL=http://localhost:3000` — sets `API_URL` explicitly.
16
+ */
17
+ export declare function isBackendConfigured(): boolean;
18
+ /**
19
+ * The OIDC audience the tokenless path requests via `core.getIDToken(...)`.
20
+ *
21
+ * The default `"infraweaver-api"` is NOT the security boundary (the GitHub App
22
+ * install-consent gate is — Cloud only mints for an owner that installed the App). It
23
+ * is defence-in-depth, and is operator-overridable per deployment: set
24
+ * `GITHUB_OIDC_AUDIENCE` on BOTH the Cloud (its `expectedOidcAudience()` reads the same
25
+ * var) AND the engine's Action job env. Both must agree or OIDC auth fails closed.
26
+ * Single-source so all three engine call sites can never drift from the Cloud default.
27
+ */
28
+ export declare function cloudOidcAudience(): string;
@@ -0,0 +1,8 @@
1
+ /**
2
+ * downloads any github-hosted image/video assets referenced in `markdown` to
3
+ * `<tmpdir>/assets` and rewrites the urls to the local file paths, so the agent can
4
+ * read screenshots directly instead of relying on remote (often short-lived, signed)
5
+ * urls. unique urls are downloaded once and every occurrence is rewritten. assets that
6
+ * fail to download are left untouched.
7
+ */
8
+ export declare function downloadAssetsInMarkdown(markdown: string, tmpdir: string, githubToken: string): Promise<string>;
@@ -0,0 +1,121 @@
1
+ /**
2
+ * Trust boundary for the repo-committed `.infraweaver.yml` on a PULL-REQUEST run.
3
+ *
4
+ * THE PROBLEM. `.infraweaver.yml` is read from the checked-out ref, which on a PR
5
+ * run is the PR's own head. Most of the run's shape is already out of reach —
6
+ * `push`, `shell`, `allow_replace` and the `*_instructions` are deliberately not
7
+ * file-readable, because "the run's shape belongs to the workflow that
8
+ * dispatches it" ([[infraweaverConfig]]). But several keys that ARE file-readable
9
+ * decide how strictly the run judges the code, and a PR that edits them is
10
+ * editing the gates that judge that same PR:
11
+ *
12
+ * allowed_paths / protected_paths → what the fix loop may write
13
+ * required_controls → which controls must be clean to pass
14
+ * severity_threshold → what counts as reportable at all
15
+ * autonomy_threshold → what escalates to a human
16
+ * tools_enabled → which scanners run
17
+ * scan_scope / iac_languages → how much of the tree is looked at
18
+ * suppressions → which findings are silenced outright
19
+ *
20
+ * None of these is an arbitrary-code-execution hole, and GitHub already defangs
21
+ * the fork case (read-only token, no secrets on `pull_request`). A workflow
22
+ * input also always wins over the file. But "the workflow author remembered to
23
+ * pin it" is not a control, and a same-repo PR silencing the finding that would
24
+ * have blocked it is a plausible, quiet failure.
25
+ *
26
+ * THE RULE. On a PR-triggered run these come from the BASE ref — the reviewed
27
+ * state of the branch being merged into. Everything else (prose language,
28
+ * grouping, the advisory module catalogue) still comes from the head, because
29
+ * none of it can weaken a verdict.
30
+ *
31
+ * This is the same principle as the shipped two-person SoD on waivers (§5.3): a
32
+ * suppression takes effect once someone other than its author has accepted it —
33
+ * here, by merging it. A PR that adds a waiver still SEES the finding it waives;
34
+ * the waiver applies from the next run on the merged base.
35
+ *
36
+ * HONEST DEGRADE. When the base ref can't be read (a shallow clone with no
37
+ * `origin/<base>`, a non-PR run, no git at all), the head value is used and the
38
+ * fact is stated for the run summary. Failing the run would turn a hardening
39
+ * measure into an outage on every shallow-checkout workflow; silently preferring
40
+ * the head with no record would be the dishonesty this codebase avoids
41
+ * everywhere else. So: use it, and say so.
42
+ *
43
+ * DIRECTION IS NOT INSPECTED. A PR that *tightens* a gate also defers to the
44
+ * base value — not because tightening is dangerous, but because "which value
45
+ * applies" must not depend on a per-key notion of stricter/looser that we would
46
+ * have to get right for every key forever. The new value takes effect on merge,
47
+ * which is when the reviewed state actually changes.
48
+ */
49
+ import { type InfraweaverFileValues } from "#app/utils/infraweaverConfig";
50
+ /**
51
+ * The file-readable keys that can weaken a verdict. Deliberately enumerated
52
+ * rather than derived by exclusion, and paired with
53
+ * {@link PRESENTATIONAL_CONFIG_KEYS} so that every key in
54
+ * `INFRAWEAVER_CONFIG_KEYS` is classified exactly once — `baseRefConfig.test.ts`
55
+ * asserts that partition, so a key added later cannot silently default to
56
+ * "PR-controllable".
57
+ */
58
+ export declare const GATE_RELEVANT_CONFIG_KEYS: readonly ["allowed_paths", "protected_paths", "required_controls", "severity_threshold", "autonomy_threshold", "tools_enabled", "scan_scope", "iac_languages"];
59
+ /**
60
+ * Keys a PR may set from its own head: none can hide a finding, relax a
61
+ * guardrail, or shrink what is scanned. `language` is prose only; `grouping` is
62
+ * presentation; `module_catalogue` is an advisory list the fixer may prefer
63
+ * from, never a gate.
64
+ */
65
+ export declare const PRESENTATIONAL_CONFIG_KEYS: readonly ["language", "grouping", "module_catalogue"];
66
+ /** What the base ref had to say about `.infraweaver.*`. */
67
+ export type BaseConfigSource =
68
+ /** the base ref itself could not be resolved (shallow clone, no git, non-PR). */
69
+ {
70
+ kind: "unavailable";
71
+ }
72
+ /** the base ref resolved and carries NO config file — so no file-level policy. */
73
+ | {
74
+ kind: "absent";
75
+ ref: string;
76
+ } | {
77
+ kind: "file";
78
+ ref: string;
79
+ raw: string;
80
+ format: "yaml" | "json";
81
+ };
82
+ /** Drop the base-ref read cache — tests only. */
83
+ export declare function resetBaseConfigCache(): void;
84
+ /**
85
+ * Read `.infraweaver.*` as it exists on the PR's base ref.
86
+ *
87
+ * The `absent` / `unavailable` distinction is load-bearing: "the base has no
88
+ * config" legitimately means *no file-level policy applies*, so a PR that ADDS
89
+ * one is correctly ignored. "We could not look" must never be read that way, or
90
+ * a shallow clone would silently drop a real policy.
91
+ */
92
+ export declare function readConfigAtBaseRef(cwdOrUndefined: string | undefined, baseRef: string | undefined): BaseConfigSource;
93
+ export interface BaseRefConfigResult {
94
+ /** the config to use, gate keys taken from the base ref where available. */
95
+ values: InfraweaverFileValues;
96
+ /** human-readable notes for the run log: what was overridden, or why not. */
97
+ notes: string[];
98
+ }
99
+ /**
100
+ * Layer the base ref's gate-relevant keys over the head's config. `headValues`
101
+ * is what `loadInfraweaverConfig` already read from the checked-out tree; on a
102
+ * non-PR run (or when the base can't be resolved) it comes back unchanged.
103
+ */
104
+ export declare function resolveConfigAcrossRefs(args: {
105
+ cwd: string | undefined;
106
+ headValues: InfraweaverFileValues;
107
+ /** the PR's base branch — `GITHUB_BASE_REF`; empty/undefined on a non-PR run. */
108
+ baseRef: string | undefined;
109
+ /** injectable for tests; defaults to the real git read. */
110
+ readBase?: (cwd: string | undefined, baseRef: string | undefined) => BaseConfigSource;
111
+ }): BaseRefConfigResult;
112
+ /**
113
+ * `resolveConfigAcrossRefs` + logging, for the one call site in `resolvePayload`.
114
+ * Notes are warnings, not info: a divergence belongs in the run summary rather
115
+ * than buried in debug output.
116
+ */
117
+ export declare function applyBaseRefConfigPolicy(args: {
118
+ cwd: string | undefined;
119
+ headValues: InfraweaverFileValues;
120
+ baseRef: string | undefined;
121
+ }): InfraweaverFileValues;
@@ -0,0 +1,85 @@
1
+ /**
2
+ * Billing-error classification + user-facing copy for `/api/proxy-token`
3
+ * failures and OpenRouter mid-run exhaustion. Two error classes (Billing vs.
4
+ * Transient) keep the framing honest: a card decline is *not* the same UX as
5
+ * a 503 from the proxy service. Both originate in `utils/proxy.ts` (mint
6
+ * failures) and `utils/runErrorRenderer.ts` (mid-run keylimit reclassify).
7
+ *
8
+ * Renderers return markdown bodies that are written into both the GitHub
9
+ * Actions job summary and the PR progress comment.
10
+ *
11
+ * Lives outside `main.ts` so adding a new error `code` branch is a one-file
12
+ * edit that does not retrigger the full LLM CI matrix (`action/main.ts` is
13
+ * in `action/test/coverage.ts::ALWAYS_RUN_ALL`).
14
+ */
15
+ /**
16
+ * Billing-layer error surfaced from `/api/proxy-token` as a 402. User-actionable
17
+ * — distinct from TransientError (503 / transient sync issue) so the job
18
+ * summary + PR comment can use affirmative "you need to do X" copy rather than
19
+ * the ambiguous "billing error" label that makes transient outages look like
20
+ * the user's fault.
21
+ *
22
+ * `code` is a server-side discriminator: `router_requires_card` (no card + no
23
+ * wallet balance on Router), or null for unclassified. `declineCode` is
24
+ * Stripe's more specific sub-reason on `card_declined` (e.g.
25
+ * `insufficient_funds`, `lost_card`). `needsReauthentication` is the 3DS case
26
+ * broken out for convenience.
27
+ */
28
+ export declare class BillingError extends Error {
29
+ code: string | null;
30
+ declineCode: string | null;
31
+ needsReauthentication: boolean;
32
+ constructor(message: string, opts?: {
33
+ code?: string | null;
34
+ declineCode?: string | null;
35
+ needsReauthentication?: boolean;
36
+ });
37
+ }
38
+ /**
39
+ * Transient service failures from `/api/proxy-token` (503: partial OpenRouter
40
+ * usage sync, DB flake, in-flight payment intent). Not the user's fault — the
41
+ * summary uses "temporarily unavailable" framing, and the non-zero exit lets
42
+ * GH Actions apply whatever retry policy the workflow has configured.
43
+ */
44
+ export declare class TransientError extends Error {
45
+ constructor(message: string);
46
+ }
47
+ /**
48
+ * Render a BillingError as user-facing markdown (shared between GH job summary
49
+ * and the PR progress comment). Goals:
50
+ *
51
+ * - quiet, not alarmist — bold first line instead of an `### ❌` H3, since
52
+ * the comment already has Infraweaver branding in the footer
53
+ * - actionable — every branch ends in a single CTA deep-linked to the
54
+ * correct section of the owner's console
55
+ * - honest — say what actually went wrong (card declined vs. balance
56
+ * empty vs. 3DS required), don't lump them under "billing error"
57
+ *
58
+ * Branches:
59
+ * - `router_requires_card`: user is on Router mode with no card AND no
60
+ * wallet balance (signup credit exhausted or not granted). Frame as
61
+ * "add a card to continue", link to `#model-access` where the Add
62
+ * Card flow lives.
63
+ * - `router_balance_exhausted`: user has a card on file but auto-reload is
64
+ * disabled and they've spent past their $5 overdraft buffer. Frame as
65
+ * "balance ran out" and surface both remediation paths (top up, or flip
66
+ * on auto-reload).
67
+ * - `router_keylimit_exhausted`: OpenRouter rejected mid-run because the
68
+ * per-run key budget was exhausted while the agent was working. The
69
+ * wallet is now negative; same remediation as `router_balance_exhausted`
70
+ * but framed for the after-the-fact case ("this run was cut short").
71
+ * - `needsReauthentication`: issuer requires 3DS on every off-session
72
+ * charge. Re-adding the card won't help — the only escape is a manual
73
+ * top-up where 3DS runs interactively in Stripe Checkout.
74
+ * - `declineCode` set: Stripe declined a real charge. Show the sub-code
75
+ * so support can act on it; tell the user we'll retry on next dispatch.
76
+ * - default: balance hit zero with no in-flight charge (auto-reload off
77
+ * or amount below threshold). Direct them to top up or enable auto-reload.
78
+ */
79
+ export declare function formatBillingErrorSummary(error: BillingError, owner: string): string;
80
+ /**
81
+ * Render a TransientError as user-facing markdown. Distinct framing from
82
+ * BillingError so the user doesn't read an alarm and assume their card
83
+ * failed — this branch is "our fault, retry shortly", not theirs.
84
+ */
85
+ export declare function formatTransientErrorSummary(error: TransientError, owner: string): string;
@@ -0,0 +1,34 @@
1
+ import type { PayloadEvent } from "#app/external";
2
+ import type { OctokitWithPlugins } from "#app/utils/github";
3
+ import type { RunContextData } from "#app/utils/runContextData";
4
+ interface ResolveBodyContext {
5
+ event: PayloadEvent;
6
+ octokit: OctokitWithPlugins;
7
+ repo: RunContextData["repo"];
8
+ tmpdir: string;
9
+ githubToken: string;
10
+ }
11
+ /**
12
+ * resolves the body of an event by fetching body_html and converting to markdown.
13
+ * only fetches body_html if the body contains images (to avoid unnecessary API calls).
14
+ * this ensures agents receive markdown with working signed image URLs instead of
15
+ * broken user-attachments URLs.
16
+ */
17
+ export declare function resolveBody(ctx: ResolveBodyContext): Promise<string | null>;
18
+ interface ResolveBodyAssetsContext {
19
+ body: string | null | undefined;
20
+ bodyHtml: string | null | undefined;
21
+ tmpdir: string;
22
+ githubToken: string;
23
+ }
24
+ /**
25
+ * downloads github-hosted image assets in a body to disk and rewrites the urls to local
26
+ * paths so the agent can read them. when the body has images and a rendered `bodyHtml`
27
+ * is supplied, the html is turndowned first: github only exposes attachments as signed,
28
+ * self-authenticating `*.githubusercontent.com` urls through body_html — the raw
29
+ * `github.com/user-attachments/...` urls in unrendered markdown 404 for the installation
30
+ * token. callers that fetch a body should request it with the `application/vnd.github.full+json`
31
+ * media type and pass `body_html` here.
32
+ */
33
+ export declare function resolveBodyAssets(ctx: ResolveBodyAssetsContext): Promise<string | null>;
34
+ export {};
@@ -0,0 +1,29 @@
1
+ import type { UserFacingLanguage } from "#app/utils/payload";
2
+ export declare const INFRAWEAVER_DIVIDER = "<!-- INFRAWEAVER_DIVIDER_DO_NOT_REMOVE_PLZ -->";
3
+ export interface BuildInfraweaverFooterParams {
4
+ /** add "via Infraweaver" link */
5
+ triggeredBy?: boolean;
6
+ /** arbitrary custom parts (e.g., action links) */
7
+ customParts?: string[] | undefined;
8
+ /** model slug from payload (e.g., "anthropic/claude-opus"). shown in footer as "Using `Model Name`" */
9
+ model?: string | undefined;
10
+ /**
11
+ * When the action engaged the BYOK fallback, this is the slug the user
12
+ * had configured (e.g. "anthropic/claude-opus") — the footer renders
13
+ * `Using <free model> (credentials for <configured> not configured)`
14
+ * so the substitution is visible in PR comments + reviews.
15
+ */
16
+ fallbackFrom?: string | undefined;
17
+ /** user-facing language for the fixed "Using" verb (default English); the
18
+ * model name + product attribution stay verbatim regardless. */
19
+ language?: UserFacingLanguage | undefined;
20
+ }
21
+ /**
22
+ * build a infraweaver footer with configurable parts
23
+ * order: action links (customParts) > model > attribution
24
+ */
25
+ export declare function buildInfraweaverFooter(params: BuildInfraweaverFooterParams): string;
26
+ /**
27
+ * strip any existing infraweaver footer from a comment body
28
+ */
29
+ export declare function stripExistingFooter(body: string): string;
@@ -0,0 +1,85 @@
1
+ import type { AgentId } from "#app/external";
2
+ /**
3
+ * Slug we fall back to when a BYOK-required model is configured but the
4
+ * runner has no provider key in env. Picked because it's free, stable, and
5
+ * currently served by OpenCode Zen without a key.
6
+ *
7
+ * The slug is intentionally hard-coded and not a config knob — the
8
+ * fallback is a safety net, not a user-facing preference, and adding a
9
+ * config surface here would just push the same "what to fall back to"
10
+ * decision into another setting that goes stale the same way.
11
+ */
12
+ export declare const FREE_FALLBACK_SLUG = "opencode/big-pickle";
13
+ /**
14
+ * Outcome of the BYOK model gate.
15
+ *
16
+ * - `use-resolved`: run the configured model as-is.
17
+ * - `fallback`: the runner has NO provider key for this model's provider,
18
+ * so swap to the free OpenCode slug — a genuine no-key safety net.
19
+ * - `unavailable`: a provider key IS present but the configured model is
20
+ * not one OpenCode can route with it. This is almost always a wrong or
21
+ * mistyped model id (or a key scoped to other models). We must NOT
22
+ * silently downgrade to the free model — that hides the misconfiguration
23
+ * and produces a free run the user didn't ask for (see PR #2). The caller
24
+ * fails loudly with the authorized-model list instead.
25
+ */
26
+ export type FallbackDecision = {
27
+ kind: "use-resolved";
28
+ } | {
29
+ kind: "fallback";
30
+ from: string;
31
+ to: string;
32
+ } | {
33
+ kind: "unavailable";
34
+ model: string;
35
+ };
36
+ /**
37
+ * Does the runner have a provider credential for `resolvedModel`'s provider?
38
+ *
39
+ * Uses the provider→envVars map in `models.ts` (provider-level, since a
40
+ * resolved specifier like `google/gemini-3.5-flash-lite` won't match a catalog
41
+ * model key and correctly falls through to the provider's env vars). A present
42
+ * key is what distinguishes the two not-authorized situations: key present =
43
+ * wrong/unavailable model id (fail loudly); no key = genuine BYOK gap (free
44
+ * fallback).
45
+ */
46
+ export declare function hasProviderKeyForModel(resolvedModel: string): boolean;
47
+ /**
48
+ * Decide whether to run the configured model, fall back to the free model, or
49
+ * fail because the model is unavailable to the present key.
50
+ *
51
+ * `authorized` is OpenCode's authoritative "what can I route right now"
52
+ * snapshot, captured after Codex auth.json is in place.
53
+ *
54
+ * Skip cases (always `use-resolved`, without consulting `authorized`):
55
+ * - No resolved model: auto-select handles it downstream.
56
+ * - Resolved model is the free fallback already.
57
+ * - Resolved model is a raw Bedrock / Vertex ID (no `/`): the routing
58
+ * validators (`validateBedrockSetup` / `validateVertexSetup`) cover
59
+ * auth + region/location/model-id; `opencode models` does not.
60
+ * - The selected agent is `claude`: the Claude Code harness brings its own
61
+ * auth and `resolveAgent` only returns it when that auth is present.
62
+ * `opencode models` can't see `CLAUDE_CODE_OAUTH_TOKEN`, so without this
63
+ * an OAuth-subscription run on an Anthropic model would land in
64
+ * `unavailable` (the token counts as a present provider key) and fail a
65
+ * run the claude harness serves fine. `validateAgentApiKey` still covers
66
+ * the claude path with its own Anthropic auth check.
67
+ */
68
+ export declare function selectFallbackModelIfNeeded(input: {
69
+ resolvedModel: string | undefined;
70
+ authorized: Set<string>;
71
+ /** whether a provider key for the resolved model's provider is present in env */
72
+ providerKeyPresent: boolean;
73
+ /** which agent harness `resolveAgent` picks for the resolved model */
74
+ agentName: AgentId;
75
+ }): FallbackDecision;
76
+ /**
77
+ * Loud, actionable error for the `unavailable` decision: a provider key is
78
+ * present but the configured model isn't one the key can serve. Lists the
79
+ * models OpenCode CAN route (same-provider first) so the user can copy a valid
80
+ * slug instead of getting a silent free downgrade.
81
+ */
82
+ export declare function buildUnavailableModelError(input: {
83
+ model: string;
84
+ authorized: Set<string>;
85
+ }): string;
@@ -0,0 +1,101 @@
1
+ /**
2
+ * Deterministic change-impact leads for Terraform review.
3
+ *
4
+ * On `checkout_pr` we hand the reviewer a supplemental, EXPLICITLY INCOMPLETE
5
+ * list of where the PR's changed HCL declarations are referenced elsewhere in
6
+ * the repo — the blast radius the raw diff alone doesn't show. It is a lead
7
+ * list, never a coverage source: an empty artifact is not evidence of no wider
8
+ * impact, and the authoritative diff read still governs the review.
9
+ *
10
+ * IaC-specific (vs. pullfrog's generic symbol grep): we extract only unambiguous
11
+ * HCL declarations from the diff and grep their canonical REFERENCE form, so the
12
+ * hits are real dependency edges rather than incidental identifier collisions:
13
+ * variable "x" → `var.x`
14
+ * output "x" → `module.<caller>.x` (regex; same-repo callers only)
15
+ * resource "t" "n" → `t.n`
16
+ * data "t" "n" → `data.t.n`
17
+ * module "x" → `module.x`
18
+ *
19
+ * All greps are word-bounded (`git grep -w`) so `var.env` doesn't match
20
+ * `var.environment` and `aws_s3_bucket.this` doesn't match `..._this_backup`.
21
+ *
22
+ * The whole thing is best-effort: any failure degrades to "no artifact", never
23
+ * a failed checkout.
24
+ */
25
+ export type ChangeKind = "added" | "removed";
26
+ export interface ChangeLocation {
27
+ path: string;
28
+ line: number;
29
+ kind: ChangeKind;
30
+ }
31
+ export interface ChangeImpactAtom {
32
+ /** the declaration kind, for the artifact heading. */
33
+ declaration: "variable" | "output" | "resource" | "data" | "module";
34
+ /** human label, e.g. `var.instance_type` or `aws_s3_bucket.this`. */
35
+ label: string;
36
+ /** the pattern grepped (word-bounded) across `*.tf` / `*.tfvars`; also the dedup key. */
37
+ ref: string;
38
+ /** when true, `ref` is a POSIX regex (`git grep -E`); otherwise a fixed string (`-F`). */
39
+ regex?: boolean;
40
+ /** where in the diff this declaration was touched (first added or removed). */
41
+ where: ChangeLocation;
42
+ }
43
+ export interface GrepHit {
44
+ path: string;
45
+ line: number;
46
+ text: string;
47
+ }
48
+ /** a changed file, as returned by the GitHub pulls.listFiles API. */
49
+ export interface ChangedFile {
50
+ filename: string;
51
+ patch?: string | undefined;
52
+ previous_filename?: string | undefined;
53
+ }
54
+ /**
55
+ * Walk each changed file's unified-diff patch, pulling out the HCL declarations
56
+ * that were added or removed and the set of added-line keys (so grep hits that
57
+ * land on the PR's own new lines can be excluded — impact means EXISTING code
58
+ * that references the changed thing).
59
+ */
60
+ export declare function extractTerraformAtoms(files: ChangedFile[]): {
61
+ atoms: ChangeImpactAtom[];
62
+ addedLines: Set<string>;
63
+ };
64
+ /**
65
+ * Render the artifact from already-collected grep hits. Pure: the caller
66
+ * supplies the reference hits per atom (via a real `git grep` at runtime, or a
67
+ * stub in tests). Bounded by MAX_REFS_PER_ATOM and MAX_BYTES.
68
+ */
69
+ export declare function renderChangeImpactArtifact(params: {
70
+ atoms: ChangeImpactAtom[];
71
+ hitsByRef: Map<string, GrepHit[]>;
72
+ addedLines: Set<string>;
73
+ baseSha: string;
74
+ headSha: string;
75
+ fileCount: number;
76
+ lookupError?: string | undefined;
77
+ }): {
78
+ content: string;
79
+ atomCount: number;
80
+ referenceCount: number;
81
+ };
82
+ /** parse `git grep -n` porcelain (`path:line:text`) into hits. */
83
+ export declare function parseGrepHits(output: string): GrepHit[];
84
+ /**
85
+ * Runtime entry point: extract the changed declarations, grep the checked-out
86
+ * head for pre-existing references to each, and write the artifact to tmpdir.
87
+ * Returns null when there's nothing worth writing (no TF declarations changed).
88
+ * Callers treat a thrown error as "no artifact" — this must never fail checkout.
89
+ */
90
+ export declare function createChangeImpactArtifact(params: {
91
+ files: ChangedFile[];
92
+ tmpdir: string;
93
+ pullNumber: number;
94
+ baseSha: string;
95
+ headSha: string;
96
+ }): {
97
+ path: string;
98
+ atomCount: number;
99
+ referenceCount: number;
100
+ bytes: number;
101
+ } | null;
@@ -0,0 +1,30 @@
1
+ export type SubscriptionPreflight = {
2
+ usable: true;
3
+ } | {
4
+ usable: false;
5
+ reason: string;
6
+ };
7
+ /**
8
+ * preflight a Claude subscription OAuth token (`CLAUDE_CODE_OAUTH_TOKEN`)
9
+ * with a 1-token Messages call, so the agent can fall back to
10
+ * `ANTHROPIC_API_KEY` when the subscription is exhausted or revoked instead
11
+ * of failing the whole run at its first model call. rides the same de-facto
12
+ * OAuth surface Claude Code itself uses: Bearer auth + the
13
+ * `claude-code-20250219,oauth-2025-04-20` betas + the identity system prompt.
14
+ *
15
+ * probes the run's own model when known — subscription limits can be
16
+ * per-model ("You've hit your Opus limit"), so a cheaper stand-in could pass
17
+ * preflight and still leave the run dead on arrival.
18
+ *
19
+ * fail-open by design: only 401 (revoked/expired token) and 429
20
+ * (session/weekly/per-model limit) mark the token unusable. network errors,
21
+ * 5xx, and request-shape drift (400) all keep today's subscription-first
22
+ * behavior, so the preflight can never fail a run that would have worked —
23
+ * the worst wrong answer is a run that bills the API key instead of the
24
+ * subscription.
25
+ */
26
+ export declare function preflightClaudeSubscription(params: {
27
+ token: string;
28
+ /** bare Anthropic model id the run will use (e.g. "claude-fable-5") */
29
+ model: string | undefined;
30
+ }): Promise<SubscriptionPreflight>;
@@ -0,0 +1,10 @@
1
+ /**
2
+ * CLI utilities
3
+ */
4
+ export { formatIndentedField, formatJsonValue, formatUsageSummary, log, writeSummary, } from "#app/utils/log";
5
+ /**
6
+ * Finds a CLI executable path by checking if it's installed globally
7
+ * @param name The name of the CLI executable to find
8
+ * @returns The path to the CLI executable, or null if not found
9
+ */
10
+ export declare function findCliPath(name: string): string | null;
@@ -0,0 +1,33 @@
1
+ /**
2
+ * Thin typed seam over `apiFetch` for the Infraweaver Cloud routes.
3
+ *
4
+ * Consumers previously hand-built each request: the `Authorization: Bearer`
5
+ * header (with `Authorization`/`authorization` casing drift), JSON serialization
6
+ * + content-type, and the timeout were re-inlined at every call site. This owns
7
+ * those three pieces once and returns the raw `Response`, so each caller keeps
8
+ * its own status/JSON/retry handling.
9
+ *
10
+ * The stdlib-only post hook (`entryPost.ts`) intentionally does NOT use this —
11
+ * it calls `cloudFetchCore` directly to stay free of node_modules imports.
12
+ */
13
+ /** The one home for the bearer header — the org JWT (`apiToken`), a GitHub App
14
+ * installation token, or an OIDC id-token, depending on the route. */
15
+ export declare function bearer(credential: string): {
16
+ Authorization: string;
17
+ };
18
+ export type CloudRequest = {
19
+ path: string;
20
+ method?: string | undefined;
21
+ /** bearer token for the `Authorization` header; omit for an unauthenticated call. */
22
+ credential?: string | undefined;
23
+ /** extra headers beyond `Authorization` (e.g. `X-GitHub-OIDC-Token`). */
24
+ headers?: Record<string, string> | undefined;
25
+ /** a JSON body — serialized here, with `content-type: application/json` set. */
26
+ json?: unknown;
27
+ /** a pre-serialized body (used when the body is not JSON). */
28
+ body?: string | undefined;
29
+ /** request timeout in ms; defaults to the shared cloud ceiling. */
30
+ timeoutMs?: number | undefined;
31
+ };
32
+ /** Issue an authenticated Cloud API request; returns the raw `Response`. */
33
+ export declare function cloudRequest(req: CloudRequest): Promise<Response>;
@@ -0,0 +1,42 @@
1
+ /**
2
+ * stdlib-only Infraweaver API fetch core (no node_modules) — shared by
3
+ * `apiFetch` (the main runtime wrapper) and `entryPost.ts` (the GHA `post:`
4
+ * hook, which runs directly from the action checkout without node_modules;
5
+ * see entryPost.stdlibOnly.test.ts). Owns everything the two callers
6
+ * previously kept in lockstep by hand: the default API host, the
7
+ * bearer-credential host allowlist, the Vercel bypass secret, and the
8
+ * default request timeout.
9
+ */
10
+ import { DEFAULT_API_URL } from "#app/brand";
11
+ export { DEFAULT_API_URL };
12
+ /**
13
+ * Ceiling for Cloud API calls that don't bring their own AbortSignal — a
14
+ * stalled backend must never hang the action (or its post hook) indefinitely.
15
+ * Callers with tighter or looser needs pass an explicit `signal`.
16
+ */
17
+ export declare const DEFAULT_CLOUD_TIMEOUT_MS = 30000;
18
+ /**
19
+ * resolve the Infraweaver API base URL.
20
+ *
21
+ * in the action: API_URL is not explicitly set, so this falls back to
22
+ * DEFAULT_API_URL. in local dev: API_URL=http://localhost:3000 (from .env).
23
+ *
24
+ * enforces https:// for non-local URLs to prevent cleartext credential
25
+ * transmission.
26
+ */
27
+ export declare function resolveApiUrl(): string;
28
+ export type CloudFetchOptions = {
29
+ path: string;
30
+ method?: string | undefined;
31
+ headers?: Record<string, string> | undefined;
32
+ body?: string | undefined;
33
+ signal?: AbortSignal | undefined;
34
+ };
35
+ /**
36
+ * fetch against the Infraweaver API with Vercel deployment protection bypass.
37
+ *
38
+ * adds the bypass secret as BOTH a query parameter and a header for maximum
39
+ * reliability. the server-side forwarding code uses query params, and the
40
+ * Vercel docs say both work, so we do both as belt-and-suspenders.
41
+ */
42
+ export declare function cloudFetch(options: CloudFetchOptions): Promise<Response>;