@ipul-labs/forge 1.16.8 → 1.17.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 (280) hide show
  1. package/README.md +39 -21
  2. package/lib/bin/cli/analyze.d.ts +9 -0
  3. package/lib/bin/cli/analyze.d.ts.map +1 -0
  4. package/lib/bin/cli/analyze.js +491 -0
  5. package/lib/bin/cli/analyze.js.map +1 -0
  6. package/lib/bin/cli/apply.d.ts +2 -0
  7. package/lib/bin/cli/apply.d.ts.map +1 -0
  8. package/lib/bin/cli/apply.js +262 -0
  9. package/lib/bin/cli/apply.js.map +1 -0
  10. package/lib/bin/cli/cifix.d.ts +2 -0
  11. package/lib/bin/cli/cifix.d.ts.map +1 -0
  12. package/lib/bin/cli/cifix.js +310 -0
  13. package/lib/bin/cli/cifix.js.map +1 -0
  14. package/lib/bin/cli/close.d.ts +2 -0
  15. package/lib/bin/cli/close.d.ts.map +1 -0
  16. package/lib/bin/cli/close.js +113 -0
  17. package/lib/bin/cli/close.js.map +1 -0
  18. package/lib/bin/cli/createIssue.d.ts +2 -0
  19. package/lib/bin/cli/createIssue.d.ts.map +1 -0
  20. package/lib/bin/cli/createIssue.js +108 -0
  21. package/lib/bin/cli/createIssue.js.map +1 -0
  22. package/lib/bin/cli/doctor.d.ts +2 -0
  23. package/lib/bin/cli/doctor.d.ts.map +1 -0
  24. package/lib/bin/cli/doctor.js +145 -0
  25. package/lib/bin/cli/doctor.js.map +1 -0
  26. package/lib/bin/cli/init.d.ts +4 -0
  27. package/lib/bin/cli/init.d.ts.map +1 -0
  28. package/lib/bin/cli/init.js +288 -0
  29. package/lib/bin/cli/init.js.map +1 -0
  30. package/lib/bin/cli/ink.d.ts +23 -0
  31. package/lib/bin/cli/ink.d.ts.map +1 -0
  32. package/{bin → lib/bin}/cli/ink.js +18 -19
  33. package/lib/bin/cli/ink.js.map +1 -0
  34. package/lib/bin/cli/issue.d.ts +2 -0
  35. package/lib/bin/cli/issue.d.ts.map +1 -0
  36. package/lib/bin/cli/issue.js +114 -0
  37. package/lib/bin/cli/issue.js.map +1 -0
  38. package/lib/bin/cli/issues.d.ts +2 -0
  39. package/lib/bin/cli/issues.d.ts.map +1 -0
  40. package/lib/bin/cli/issues.js +149 -0
  41. package/lib/bin/cli/issues.js.map +1 -0
  42. package/lib/bin/cli/merge.d.ts +2 -0
  43. package/lib/bin/cli/merge.d.ts.map +1 -0
  44. package/lib/bin/cli/merge.js +162 -0
  45. package/lib/bin/cli/merge.js.map +1 -0
  46. package/lib/bin/cli/refine.d.ts +2 -0
  47. package/lib/bin/cli/refine.d.ts.map +1 -0
  48. package/lib/bin/cli/refine.js +249 -0
  49. package/lib/bin/cli/refine.js.map +1 -0
  50. package/lib/bin/cli/repl.d.ts +2 -0
  51. package/lib/bin/cli/repl.d.ts.map +1 -0
  52. package/lib/bin/cli/repl.js +309 -0
  53. package/lib/bin/cli/repl.js.map +1 -0
  54. package/lib/bin/cli/repos.d.ts +2 -0
  55. package/lib/bin/cli/repos.d.ts.map +1 -0
  56. package/lib/bin/cli/repos.js +86 -0
  57. package/lib/bin/cli/repos.js.map +1 -0
  58. package/lib/bin/cli/resolution.d.ts +2 -0
  59. package/lib/bin/cli/resolution.d.ts.map +1 -0
  60. package/lib/bin/cli/resolution.js +139 -0
  61. package/lib/bin/cli/resolution.js.map +1 -0
  62. package/lib/bin/cli/serverClient.d.ts +26 -0
  63. package/lib/bin/cli/serverClient.d.ts.map +1 -0
  64. package/lib/bin/cli/serverClient.js +111 -0
  65. package/lib/bin/cli/serverClient.js.map +1 -0
  66. package/lib/bin/cli/session.d.ts +8 -0
  67. package/lib/bin/cli/session.d.ts.map +1 -0
  68. package/lib/bin/cli/session.js +212 -0
  69. package/lib/bin/cli/session.js.map +1 -0
  70. package/lib/bin/cli/sessionStore.d.ts +69 -0
  71. package/lib/bin/cli/sessionStore.d.ts.map +1 -0
  72. package/lib/bin/cli/sessionStore.js +196 -0
  73. package/lib/bin/cli/sessionStore.js.map +1 -0
  74. package/lib/bin/cli/ship.d.ts +33 -0
  75. package/lib/bin/cli/ship.d.ts.map +1 -0
  76. package/lib/bin/cli/ship.js +737 -0
  77. package/lib/bin/cli/ship.js.map +1 -0
  78. package/lib/bin/cli/types.d.ts +59 -0
  79. package/lib/bin/cli/types.d.ts.map +1 -0
  80. package/lib/bin/cli/types.js +2 -0
  81. package/lib/bin/cli/types.js.map +1 -0
  82. package/lib/bin/cli/update.d.ts +2 -0
  83. package/lib/bin/cli/update.d.ts.map +1 -0
  84. package/lib/bin/cli/update.js +87 -0
  85. package/lib/bin/cli/update.js.map +1 -0
  86. package/lib/bin/cli/utils.d.ts +43 -0
  87. package/lib/bin/cli/utils.d.ts.map +1 -0
  88. package/lib/bin/cli/utils.js +171 -0
  89. package/lib/bin/cli/utils.js.map +1 -0
  90. package/lib/bin/cli/validate.d.ts +2 -0
  91. package/lib/bin/cli/validate.d.ts.map +1 -0
  92. package/lib/bin/cli/validate.js +283 -0
  93. package/lib/bin/cli/validate.js.map +1 -0
  94. package/lib/bin/cli/watch.d.ts +5 -0
  95. package/lib/bin/cli/watch.d.ts.map +1 -0
  96. package/lib/bin/cli/watch.js +263 -0
  97. package/lib/bin/cli/watch.js.map +1 -0
  98. package/lib/bin/forge-agent.d.ts +3 -0
  99. package/lib/bin/forge-agent.d.ts.map +1 -0
  100. package/{bin → lib/bin}/forge-agent.js +104 -105
  101. package/lib/bin/forge-agent.js.map +1 -0
  102. package/lib/server/forge/core/ForgeAgent.d.ts +260 -0
  103. package/lib/server/forge/core/ForgeAgent.d.ts.map +1 -0
  104. package/lib/server/forge/core/ForgeAgent.js +995 -0
  105. package/lib/server/forge/core/ForgeAgent.js.map +1 -0
  106. package/lib/server/forge/core/agentClient.d.ts +39 -0
  107. package/lib/server/forge/core/agentClient.d.ts.map +1 -0
  108. package/{server → lib/server}/forge/core/agentClient.js +7 -12
  109. package/lib/server/forge/core/agentClient.js.map +1 -0
  110. package/lib/server/forge/core/branchName.d.ts +20 -0
  111. package/lib/server/forge/core/branchName.d.ts.map +1 -0
  112. package/lib/server/forge/core/branchName.js +39 -0
  113. package/lib/server/forge/core/branchName.js.map +1 -0
  114. package/lib/server/forge/core/claudeClient.d.ts +60 -0
  115. package/lib/server/forge/core/claudeClient.d.ts.map +1 -0
  116. package/lib/server/forge/core/claudeClient.js +347 -0
  117. package/lib/server/forge/core/claudeClient.js.map +1 -0
  118. package/lib/server/forge/core/configStore.d.ts +76 -0
  119. package/lib/server/forge/core/configStore.d.ts.map +1 -0
  120. package/lib/server/forge/core/configStore.js +213 -0
  121. package/lib/server/forge/core/configStore.js.map +1 -0
  122. package/lib/server/forge/core/gitlabClient.d.ts +144 -0
  123. package/lib/server/forge/core/gitlabClient.d.ts.map +1 -0
  124. package/{server → lib/server}/forge/core/gitlabClient.js +98 -180
  125. package/lib/server/forge/core/gitlabClient.js.map +1 -0
  126. package/lib/server/forge/core/jobs.d.ts +67 -0
  127. package/lib/server/forge/core/jobs.d.ts.map +1 -0
  128. package/lib/server/forge/core/jobs.js +185 -0
  129. package/lib/server/forge/core/jobs.js.map +1 -0
  130. package/lib/server/forge/core/k8s.d.ts +18 -0
  131. package/lib/server/forge/core/k8s.d.ts.map +1 -0
  132. package/lib/server/forge/core/k8s.js +49 -0
  133. package/lib/server/forge/core/k8s.js.map +1 -0
  134. package/lib/server/forge/core/localRepo.d.ts +36 -0
  135. package/lib/server/forge/core/localRepo.d.ts.map +1 -0
  136. package/lib/server/forge/core/localRepo.js +165 -0
  137. package/lib/server/forge/core/localRepo.js.map +1 -0
  138. package/lib/server/forge/core/openclawClient.d.ts +61 -0
  139. package/lib/server/forge/core/openclawClient.d.ts.map +1 -0
  140. package/lib/server/forge/core/openclawClient.js +111 -0
  141. package/lib/server/forge/core/openclawClient.js.map +1 -0
  142. package/lib/server/forge/core/prompts.d.ts +96 -0
  143. package/lib/server/forge/core/prompts.d.ts.map +1 -0
  144. package/lib/server/forge/core/prompts.js +450 -0
  145. package/lib/server/forge/core/prompts.js.map +1 -0
  146. package/lib/server/forge/core/providers/azuredevops.d.ts +134 -0
  147. package/lib/server/forge/core/providers/azuredevops.d.ts.map +1 -0
  148. package/lib/server/forge/core/providers/azuredevops.js +360 -0
  149. package/lib/server/forge/core/providers/azuredevops.js.map +1 -0
  150. package/lib/server/forge/core/providers/base.d.ts +114 -0
  151. package/lib/server/forge/core/providers/base.d.ts.map +1 -0
  152. package/lib/server/forge/core/providers/base.js +98 -0
  153. package/lib/server/forge/core/providers/base.js.map +1 -0
  154. package/lib/server/forge/core/providers/github.d.ts +133 -0
  155. package/lib/server/forge/core/providers/github.d.ts.map +1 -0
  156. package/lib/server/forge/core/providers/github.js +307 -0
  157. package/lib/server/forge/core/providers/github.js.map +1 -0
  158. package/lib/server/forge/core/providers/gitlab.d.ts +144 -0
  159. package/lib/server/forge/core/providers/gitlab.d.ts.map +1 -0
  160. package/lib/server/forge/core/providers/gitlab.js +407 -0
  161. package/lib/server/forge/core/providers/gitlab.js.map +1 -0
  162. package/lib/server/forge/core/providers/index.d.ts +21 -0
  163. package/lib/server/forge/core/providers/index.d.ts.map +1 -0
  164. package/lib/server/forge/core/providers/index.js +43 -0
  165. package/lib/server/forge/core/providers/index.js.map +1 -0
  166. package/lib/server/forge/core/providers/types.d.ts +80 -0
  167. package/lib/server/forge/core/providers/types.d.ts.map +1 -0
  168. package/lib/server/forge/core/providers/types.js +2 -0
  169. package/lib/server/forge/core/providers/types.js.map +1 -0
  170. package/lib/server/forge/core/quotaClient.d.ts +48 -0
  171. package/lib/server/forge/core/quotaClient.d.ts.map +1 -0
  172. package/lib/server/forge/core/quotaClient.js +88 -0
  173. package/lib/server/forge/core/quotaClient.js.map +1 -0
  174. package/lib/server/forge/core/types.d.ts +160 -0
  175. package/lib/server/forge/core/types.d.ts.map +1 -0
  176. package/lib/server/forge/core/types.js +2 -0
  177. package/lib/server/forge/core/types.js.map +1 -0
  178. package/lib/server/forge/core/validator/attribute.d.ts +31 -0
  179. package/lib/server/forge/core/validator/attribute.d.ts.map +1 -0
  180. package/lib/server/forge/core/validator/attribute.js +82 -0
  181. package/lib/server/forge/core/validator/attribute.js.map +1 -0
  182. package/lib/server/forge/core/validator/clone.d.ts +14 -0
  183. package/lib/server/forge/core/validator/clone.d.ts.map +1 -0
  184. package/lib/server/forge/core/validator/clone.js +99 -0
  185. package/lib/server/forge/core/validator/clone.js.map +1 -0
  186. package/lib/server/forge/core/validator/cmd.d.ts +23 -0
  187. package/lib/server/forge/core/validator/cmd.d.ts.map +1 -0
  188. package/lib/server/forge/core/validator/cmd.js +87 -0
  189. package/lib/server/forge/core/validator/cmd.js.map +1 -0
  190. package/lib/server/forge/core/validator/fs.d.ts +5 -0
  191. package/lib/server/forge/core/validator/fs.d.ts.map +1 -0
  192. package/{server → lib/server}/forge/core/validator/fs.js +8 -3
  193. package/lib/server/forge/core/validator/fs.js.map +1 -0
  194. package/lib/server/forge/core/validator/overlay.d.ts +13 -0
  195. package/lib/server/forge/core/validator/overlay.d.ts.map +1 -0
  196. package/lib/server/forge/core/validator/overlay.js +53 -0
  197. package/lib/server/forge/core/validator/overlay.js.map +1 -0
  198. package/lib/server/forge/core/validator/projectType.d.ts +20 -0
  199. package/lib/server/forge/core/validator/projectType.d.ts.map +1 -0
  200. package/lib/server/forge/core/validator/projectType.js +94 -0
  201. package/lib/server/forge/core/validator/projectType.js.map +1 -0
  202. package/lib/server/forge/core/validator/runners/go.d.ts +21 -0
  203. package/lib/server/forge/core/validator/runners/go.d.ts.map +1 -0
  204. package/lib/server/forge/core/validator/runners/go.js +99 -0
  205. package/lib/server/forge/core/validator/runners/go.js.map +1 -0
  206. package/lib/server/forge/core/validator/runners/node.d.ts +12 -0
  207. package/lib/server/forge/core/validator/runners/node.d.ts.map +1 -0
  208. package/lib/server/forge/core/validator/runners/node.js +75 -0
  209. package/lib/server/forge/core/validator/runners/node.js.map +1 -0
  210. package/lib/server/forge/core/validator/tdd.d.ts +30 -0
  211. package/lib/server/forge/core/validator/tdd.d.ts.map +1 -0
  212. package/lib/server/forge/core/validator/tdd.js +96 -0
  213. package/lib/server/forge/core/validator/tdd.js.map +1 -0
  214. package/lib/server/forge/core/validator.d.ts +58 -0
  215. package/lib/server/forge/core/validator.d.ts.map +1 -0
  216. package/lib/server/forge/core/validator.js +150 -0
  217. package/lib/server/forge/core/validator.js.map +1 -0
  218. package/lib/server/forge/routes.d.ts +22 -0
  219. package/lib/server/forge/routes.d.ts.map +1 -0
  220. package/lib/server/forge/routes.js +984 -0
  221. package/lib/server/forge/routes.js.map +1 -0
  222. package/lib/server.d.ts +2 -0
  223. package/lib/server.d.ts.map +1 -0
  224. package/lib/server.js +52 -0
  225. package/lib/server.js.map +1 -0
  226. package/lib/shared/events.d.ts +12 -0
  227. package/lib/shared/events.d.ts.map +1 -0
  228. package/lib/shared/events.js +12 -0
  229. package/lib/shared/events.js.map +1 -0
  230. package/package.json +15 -13
  231. package/scripts/fix-shebang.cjs +10 -0
  232. package/bin/cli/analyze.js +0 -516
  233. package/bin/cli/apply.js +0 -264
  234. package/bin/cli/cifix.js +0 -300
  235. package/bin/cli/close.js +0 -125
  236. package/bin/cli/createIssue.js +0 -112
  237. package/bin/cli/doctor.js +0 -161
  238. package/bin/cli/init.js +0 -306
  239. package/bin/cli/issue.js +0 -116
  240. package/bin/cli/issues.js +0 -155
  241. package/bin/cli/merge.js +0 -175
  242. package/bin/cli/refine.js +0 -253
  243. package/bin/cli/repl.js +0 -301
  244. package/bin/cli/repos.js +0 -91
  245. package/bin/cli/resolution.js +0 -126
  246. package/bin/cli/session.js +0 -230
  247. package/bin/cli/sessionStore.js +0 -211
  248. package/bin/cli/ship.js +0 -762
  249. package/bin/cli/update.js +0 -95
  250. package/bin/cli/utils.js +0 -145
  251. package/bin/cli/validate.js +0 -280
  252. package/bin/cli/watch.js +0 -274
  253. package/server/forge/core/ForgeAgent.js +0 -1179
  254. package/server/forge/core/ForgeAgent.test.js +0 -179
  255. package/server/forge/core/branchName.js +0 -41
  256. package/server/forge/core/claudeClient.js +0 -378
  257. package/server/forge/core/configStore.js +0 -229
  258. package/server/forge/core/configStore.test.js +0 -89
  259. package/server/forge/core/jobs.js +0 -180
  260. package/server/forge/core/k8s.js +0 -54
  261. package/server/forge/core/localRepo.js +0 -163
  262. package/server/forge/core/openclawClient.js +0 -125
  263. package/server/forge/core/prompts.js +0 -483
  264. package/server/forge/core/prompts.test.js +0 -219
  265. package/server/forge/core/providers/azuredevops.js +0 -409
  266. package/server/forge/core/providers/base.js +0 -208
  267. package/server/forge/core/providers/github.js +0 -348
  268. package/server/forge/core/providers/gitlab.js +0 -529
  269. package/server/forge/core/providers/index.js +0 -47
  270. package/server/forge/core/quotaClient.js +0 -101
  271. package/server/forge/core/validator/attribute.js +0 -84
  272. package/server/forge/core/validator/clone.js +0 -116
  273. package/server/forge/core/validator/cmd.js +0 -98
  274. package/server/forge/core/validator/overlay.js +0 -52
  275. package/server/forge/core/validator/projectType.js +0 -87
  276. package/server/forge/core/validator/runners/go.js +0 -107
  277. package/server/forge/core/validator/runners/node.js +0 -84
  278. package/server/forge/core/validator/tdd.js +0 -105
  279. package/server/forge/core/validator.js +0 -167
  280. package/server/forge/routes.js +0 -1027
@@ -0,0 +1,58 @@
1
+ /**
2
+ * server/forge/core/validator.ts
3
+ *
4
+ * Pre-flight runner. Auto-attributes each proposed change to the repo whose
5
+ * working tree actually contains that file, then runs the right toolchain
6
+ * (Node npm scripts vs Go go-tool commands) on each repo with at least one
7
+ * attributed change.
8
+ *
9
+ * Composition:
10
+ *
11
+ * validator/cmd.js — child-process + step-event helpers
12
+ * validator/clone.js — cache + git clone management
13
+ * validator/attribute.js — file-existence-based repo auto-detection
14
+ * validator/overlay.js — overlay changes + readback after format
15
+ * validator/projectType.js — per-repo type resolution (config + auto-detect)
16
+ * validator/runners/node.js — npm ci + format/lint/typecheck/test
17
+ * validator/runners/go.js — go mod + go fmt/vet/build/test
18
+ *
19
+ * Scope (v1):
20
+ * - Validates only repos that actually own at least one change (1, both, or
21
+ * none — never a phantom block from a misrouted attribution).
22
+ * - GitLab HTTPS clone using GITLAB_TOKEN. GitHub / Azure DevOps raise a
23
+ * clear "not supported yet" error.
24
+ * - Step names per runner: format/lint/typecheck/test (Node) or
25
+ * fmt/vet/build/test (Go). Missing scripts (Node) are silently skipped.
26
+ */
27
+ import type { ForgeChange, ForgeEvent } from "./types.ts";
28
+ import type { StepResult } from "./validator/cmd.ts";
29
+ interface AnalysisInput {
30
+ changes: ForgeChange[];
31
+ repos?: string[];
32
+ issue?: {
33
+ iid: number;
34
+ title?: string;
35
+ };
36
+ mrTitle?: string;
37
+ }
38
+ /**
39
+ * @param {{ changes: Array<{repo?: string, file: string, action: string, proposed: string}>, repos?: string[], issue?: { iid: number } }} analysis
40
+ * @param {(event: object) => void} onEvent
41
+ */
42
+ export declare function validate(analysis: AnalysisInput, onEvent?: (event: ForgeEvent) => void): Promise<{
43
+ repo: string;
44
+ branchName: string;
45
+ results: Record<string, StepResult> | {
46
+ [k: string]: Record<string, StepResult>;
47
+ };
48
+ allPassed: boolean;
49
+ perRepo: {
50
+ repo: string;
51
+ branchName: string;
52
+ projectType: string;
53
+ results: Record<string, StepResult>;
54
+ allPassed: boolean;
55
+ }[];
56
+ }>;
57
+ export {};
58
+ //# sourceMappingURL=validator.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validator.d.ts","sourceRoot":"","sources":["../../../../server/forge/core/validator.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAIH,OAAO,KAAK,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAG1D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAmBrD,UAAU,aAAa;IACtB,OAAO,EAAE,WAAW,EAAE,CAAC;IACvB,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;IACjB,KAAK,CAAC,EAAE;QAAE,GAAG,EAAE,MAAM,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;IACxC,OAAO,CAAC,EAAE,MAAM,CAAC;CACjB;AAsDD;;;GAGG;AACH,wBAAsB,QAAQ,CAAC,QAAQ,EAAE,aAAa,EAAE,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,UAAU,KAAK,IAAI;;;;;;;;;;;;;;GAqE5F"}
@@ -0,0 +1,150 @@
1
+ /**
2
+ * server/forge/core/validator.ts
3
+ *
4
+ * Pre-flight runner. Auto-attributes each proposed change to the repo whose
5
+ * working tree actually contains that file, then runs the right toolchain
6
+ * (Node npm scripts vs Go go-tool commands) on each repo with at least one
7
+ * attributed change.
8
+ *
9
+ * Composition:
10
+ *
11
+ * validator/cmd.js — child-process + step-event helpers
12
+ * validator/clone.js — cache + git clone management
13
+ * validator/attribute.js — file-existence-based repo auto-detection
14
+ * validator/overlay.js — overlay changes + readback after format
15
+ * validator/projectType.js — per-repo type resolution (config + auto-detect)
16
+ * validator/runners/node.js — npm ci + format/lint/typecheck/test
17
+ * validator/runners/go.js — go mod + go fmt/vet/build/test
18
+ *
19
+ * Scope (v1):
20
+ * - Validates only repos that actually own at least one change (1, both, or
21
+ * none — never a phantom block from a misrouted attribution).
22
+ * - GitLab HTTPS clone using GITLAB_TOKEN. GitHub / Azure DevOps raise a
23
+ * clear "not supported yet" error.
24
+ * - Step names per runner: format/lint/typecheck/test (Node) or
25
+ * fmt/vet/build/test (Go). Missing scripts (Node) are silently skipped.
26
+ */
27
+ import { branchNameFor } from "./branchName.js";
28
+ import * as configStore from "./configStore.js";
29
+ import { attributeChanges } from "./validator/attribute.js";
30
+ import { ensureClone } from "./validator/clone.js";
31
+ import { overlayChanges } from "./validator/overlay.js";
32
+ import { resolveProjectType } from "./validator/projectType.js";
33
+ import * as goRunner from "./validator/runners/go.js";
34
+ import * as nodeRunner from "./validator/runners/node.js";
35
+ const RUNNERS = {
36
+ go: { run: goRunner.runGoRepo, stepOrder: goRunner.STEP_ORDER, fixableSteps: goRunner.FIXABLE_STEPS },
37
+ node: { run: nodeRunner.runNodeRepo, stepOrder: nodeRunner.STEP_ORDER, fixableSteps: nodeRunner.FIXABLE_STEPS },
38
+ };
39
+ async function validateRepo(repo, changes, branchName, emit) {
40
+ // Stamp every downstream event with the current repo so the frontend can
41
+ // route progress/log/step_result rows into the right per-repo block.
42
+ const repoEmit = (e) => emit({ ...e, repo });
43
+ const fileList = changes.map((c) => c.file).join(", ");
44
+ repoEmit({
45
+ type: "log",
46
+ message: `Validating ${changes.length} change(s) for ${repo} on ${branchName} — ${fileList}`,
47
+ });
48
+ // Idempotent — the candidate-clone phase already populated the cache, so
49
+ // this is essentially a fetch/reset that completes quickly and gives the
50
+ // UI its `clone` step events.
51
+ const dir = await ensureClone(repo, branchName, repoEmit);
52
+ const projectType = await resolveProjectType(repo, dir, changes);
53
+ const runner = RUNNERS[projectType] ?? RUNNERS.node;
54
+ // Send the runner's step contract up front so the UI can render rows in
55
+ // the runner's natural order (e.g. fmt/vet/build/test for Go) and gate
56
+ // the "Fix with AI" button on the right step keys.
57
+ repoEmit({
58
+ type: "repo_started",
59
+ projectType,
60
+ stepOrder: runner.stepOrder,
61
+ fixableSteps: runner.fixableSteps,
62
+ });
63
+ await overlayChanges(dir, changes, repoEmit);
64
+ const results = await runner.run(dir, changes, repoEmit);
65
+ const allPassed = Object.values(results).every((r) => r.passed);
66
+ repoEmit({
67
+ type: "repo_result",
68
+ projectType,
69
+ allPassed,
70
+ checkedAt: new Date().toISOString(),
71
+ });
72
+ return { repo, branchName, projectType, results, allPassed };
73
+ }
74
+ function resolveCandidates(analysis) {
75
+ const fromAnalysis = analysis.repos ?? [];
76
+ if (fromAnalysis.length)
77
+ return fromAnalysis;
78
+ const fromChange = analysis.changes?.[0]?.repo;
79
+ if (fromChange)
80
+ return [fromChange];
81
+ const primary = configStore.getPrimaryProject();
82
+ return primary ? [primary] : [];
83
+ }
84
+ /**
85
+ * @param {{ changes: Array<{repo?: string, file: string, action: string, proposed: string}>, repos?: string[], issue?: { iid: number } }} analysis
86
+ * @param {(event: object) => void} onEvent
87
+ */
88
+ export async function validate(analysis, onEvent) {
89
+ const emit = onEvent ?? (() => { });
90
+ try {
91
+ const candidates = resolveCandidates(analysis);
92
+ if (!candidates.length)
93
+ throw new Error("No repos to validate against.");
94
+ const branchName = analysis.issue?.iid
95
+ ? branchNameFor(analysis.issue.iid, analysis)
96
+ : "forge/workspace";
97
+ // Step 1: attribute each change by querying the SCM API for file
98
+ // existence. No clones yet — we only clone repos we'll actually
99
+ // validate. The model's `c.repo` is advisory; we trust the API.
100
+ const { byRepo, unattributed } = await attributeChanges(analysis.changes, candidates, emit);
101
+ if (unattributed.length) {
102
+ for (const c of unattributed) {
103
+ emit({
104
+ type: "log",
105
+ message: `Dropping ${c.file} (${c.action}): not found in ${candidates.join(" or ")}.`,
106
+ });
107
+ }
108
+ }
109
+ if (!byRepo.size) {
110
+ throw new Error(`No proposed changes match files in ${candidates.join(" or ")}. ` +
111
+ `The file paths in the proposal don't exist in those repos — likely a wrong path.`);
112
+ }
113
+ // Step 3: order chosen repos by the analysis's repos[] (primary first).
114
+ const ordered = candidates.filter((r) => byRepo.has(r));
115
+ emit({
116
+ type: "log",
117
+ message: `Plan: ${ordered.length} repo(s): ${ordered.map((r) => { const changes = byRepo.get(r) ?? []; return `${r} (${changes.length} change${changes.length === 1 ? "" : "s"})`; }).join(", ")}`,
118
+ });
119
+ const perRepo = [];
120
+ for (const repo of ordered) {
121
+ perRepo.push(await validateRepo(repo, byRepo.get(repo), branchName, emit));
122
+ }
123
+ const allPassed = perRepo.length > 0 && perRepo.every((r) => r.allPassed);
124
+ const repoLabel = perRepo.length === 1
125
+ ? perRepo[0].repo
126
+ : perRepo.map((r) => r.repo).join(", ");
127
+ // Single-repo runs keep the original flat `results` shape; multi-repo
128
+ // runs nest by repo so older single-repo consumers still see something
129
+ // sensible at `results.<step>` for their own repo.
130
+ const results = perRepo.length === 1
131
+ ? perRepo[0].results
132
+ : Object.fromEntries(perRepo.map((r) => [r.repo, r.results]));
133
+ emit({
134
+ type: "result",
135
+ data: {
136
+ repo: repoLabel,
137
+ branchName,
138
+ results,
139
+ allPassed,
140
+ checkedAt: new Date().toISOString(),
141
+ },
142
+ });
143
+ return { repo: repoLabel, branchName, results, allPassed, perRepo };
144
+ }
145
+ catch (err) {
146
+ emit({ type: "error", message: (err instanceof Error ? err.message : null) ?? "Validation failed" });
147
+ throw err;
148
+ }
149
+ }
150
+ //# sourceMappingURL=validator.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validator.js","sourceRoot":"","sources":["../../../../server/forge/core/validator.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,KAAK,WAAW,MAAM,kBAAkB,CAAC;AAEhD,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAC5D,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAEnD,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AACxD,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAChE,OAAO,KAAK,QAAQ,MAAM,2BAA2B,CAAC;AACtD,OAAO,KAAK,UAAU,MAAM,6BAA6B,CAAC;AAU1D,MAAM,OAAO,GAA2B;IACvC,EAAE,EAAE,EAAE,GAAG,EAAE,QAAQ,CAAC,SAAS,EAAE,SAAS,EAAE,QAAQ,CAAC,UAAU,EAAE,YAAY,EAAE,QAAQ,CAAC,aAAa,EAAE;IACrG,IAAI,EAAE,EAAE,GAAG,EAAE,UAAU,CAAC,WAAW,EAAE,SAAS,EAAE,UAAU,CAAC,UAAU,EAAE,YAAY,EAAE,UAAU,CAAC,aAAa,EAAE;CAC/G,CAAC;AASF,KAAK,UAAU,YAAY,CAAC,IAAY,EAAE,OAAsB,EAAE,UAAkB,EAAE,IAAiC;IACtH,yEAAyE;IAC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YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,mBAAmB,EAAE,CAAC,CAAC;QACrG,MAAM,GAAG,CAAC;IACX,CAAC;AACF,CAAC"}
@@ -0,0 +1,22 @@
1
+ /**
2
+ * server/forge/routes.js
3
+ *
4
+ * Express router for /api/forge/*.
5
+ *
6
+ * Required env vars:
7
+ * FORGE_TOKEN — dashboard password
8
+ *
9
+ * Project + token resolved via configStore (Settings UI) with env-var fallbacks.
10
+ *
11
+ * Multi-repo support
12
+ * ──────────────────
13
+ * Every endpoint accepts an optional `repo` param (primary, where the issue
14
+ * lives) and `secondaryRepos` param (additional repos that can participate in
15
+ * a full-stack fix). `secondaryRepos` may be sent as a comma-separated string
16
+ * in the query string, or as a JSON array in a POST body.
17
+ */
18
+ declare const router: import("express-serve-static-core").Router;
19
+ declare function broadcast(event: Record<string, unknown>): void;
20
+ export { broadcast };
21
+ export default router;
22
+ //# sourceMappingURL=routes.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"routes.d.ts","sourceRoot":"","sources":["../../../server/forge/routes.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAiBH,QAAA,MAAM,MAAM,4CAAW,CAAC;AA0hCxB,iBAAS,SAAS,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAKvD;AAoBD,OAAO,EAAE,SAAS,EAAE,CAAC;AACrB,eAAe,MAAM,CAAC"}