@interf/compiler 0.3.3 → 0.4.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 (385) hide show
  1. package/README.md +137 -243
  2. package/builtin-workflows/interf/README.md +19 -0
  3. package/builtin-workflows/interf/compile/stages/shape/SKILL.md +28 -0
  4. package/builtin-workflows/interf/compile/stages/structure/SKILL.md +18 -0
  5. package/builtin-workflows/interf/compile/stages/summarize/SKILL.md +18 -0
  6. package/builtin-workflows/interf/improve/SKILL.md +18 -0
  7. package/builtin-workflows/interf/use/query/SKILL.md +28 -0
  8. package/builtin-workflows/interf/workflow.json +120 -0
  9. package/builtin-workflows/interf/workspace.schema.json +75 -0
  10. package/dist/bin.d.ts +0 -1
  11. package/dist/bin.js +0 -1
  12. package/dist/commands/compile-controller.d.ts +14 -0
  13. package/dist/commands/compile-controller.js +409 -0
  14. package/dist/commands/compile.d.ts +8 -9
  15. package/dist/commands/compile.js +151 -153
  16. package/dist/commands/create-workflow-wizard.d.ts +4 -2
  17. package/dist/commands/create-workflow-wizard.js +33 -31
  18. package/dist/commands/create.d.ts +0 -1
  19. package/dist/commands/create.js +16 -12
  20. package/dist/commands/default.d.ts +0 -1
  21. package/dist/commands/default.js +1 -2
  22. package/dist/commands/doctor.d.ts +0 -1
  23. package/dist/commands/doctor.js +7 -22
  24. package/dist/commands/executor-flow.d.ts +0 -1
  25. package/dist/commands/executor-flow.js +0 -1
  26. package/dist/commands/init.d.ts +0 -1
  27. package/dist/commands/init.js +72 -15
  28. package/dist/commands/list.d.ts +0 -1
  29. package/dist/commands/list.js +0 -1
  30. package/dist/commands/reset.d.ts +0 -1
  31. package/dist/commands/reset.js +0 -1
  32. package/dist/commands/source-config-wizard.d.ts +28 -7
  33. package/dist/commands/source-config-wizard.js +159 -63
  34. package/dist/commands/status.d.ts +0 -1
  35. package/dist/commands/status.js +0 -1
  36. package/dist/commands/test-flow.d.ts +20 -10
  37. package/dist/commands/test-flow.js +89 -23
  38. package/dist/commands/test.d.ts +0 -1
  39. package/dist/commands/test.js +36 -72
  40. package/dist/commands/verify.d.ts +0 -1
  41. package/dist/commands/verify.js +0 -1
  42. package/dist/commands/workspace-flow.d.ts +3 -3
  43. package/dist/commands/workspace-flow.js +30 -12
  44. package/dist/index.d.ts +5 -6
  45. package/dist/index.js +3 -4
  46. package/dist/lib/agent-args.d.ts +0 -1
  47. package/dist/lib/agent-args.js +0 -1
  48. package/dist/lib/agent-constants.d.ts +0 -1
  49. package/dist/lib/agent-constants.js +0 -1
  50. package/dist/lib/agent-detection.d.ts +0 -1
  51. package/dist/lib/agent-detection.js +0 -1
  52. package/dist/lib/agent-execution.d.ts +0 -1
  53. package/dist/lib/agent-execution.js +47 -12
  54. package/dist/lib/agent-logs.d.ts +0 -1
  55. package/dist/lib/agent-logs.js +0 -1
  56. package/dist/lib/agent-preflight.d.ts +0 -1
  57. package/dist/lib/agent-preflight.js +1 -2
  58. package/dist/lib/agent-render.d.ts +0 -1
  59. package/dist/lib/agent-render.js +0 -1
  60. package/dist/lib/agent-shells.d.ts +30 -3
  61. package/dist/lib/agent-shells.js +527 -63
  62. package/dist/lib/agent-status.d.ts +0 -1
  63. package/dist/lib/agent-status.js +0 -1
  64. package/dist/lib/agent-types.d.ts +0 -1
  65. package/dist/lib/agent-types.js +0 -1
  66. package/dist/lib/agents.d.ts +0 -9
  67. package/dist/lib/agents.js +0 -9
  68. package/dist/lib/chart-guidance.d.ts +1 -0
  69. package/dist/lib/chart-guidance.js +8 -0
  70. package/dist/lib/config.d.ts +0 -3
  71. package/dist/lib/config.js +0 -5
  72. package/dist/lib/discovery.d.ts +0 -1
  73. package/dist/lib/discovery.js +0 -1
  74. package/dist/lib/execution-profile.d.ts +0 -1
  75. package/dist/lib/execution-profile.js +0 -1
  76. package/dist/lib/executors.d.ts +0 -1
  77. package/dist/lib/executors.js +0 -1
  78. package/dist/lib/filesystem.d.ts +0 -1
  79. package/dist/lib/filesystem.js +0 -1
  80. package/dist/lib/interf-bootstrap.d.ts +0 -1
  81. package/dist/lib/interf-bootstrap.js +6 -2
  82. package/dist/lib/interf-detect.d.ts +2 -2
  83. package/dist/lib/interf-detect.js +25 -8
  84. package/dist/lib/interf-scaffold.d.ts +0 -1
  85. package/dist/lib/interf-scaffold.js +54 -21
  86. package/dist/lib/interf-workflow-package.d.ts +18 -1
  87. package/dist/lib/interf-workflow-package.js +164 -23
  88. package/dist/lib/interf.d.ts +1 -2
  89. package/dist/lib/interf.js +1 -2
  90. package/dist/lib/local-workflows.d.ts +10 -5
  91. package/dist/lib/local-workflows.js +208 -97
  92. package/dist/lib/logger.d.ts +0 -1
  93. package/dist/lib/logger.js +0 -1
  94. package/dist/lib/obsidian.d.ts +0 -1
  95. package/dist/lib/obsidian.js +0 -1
  96. package/dist/lib/parse.d.ts +0 -1
  97. package/dist/lib/parse.js +0 -1
  98. package/dist/lib/registry.d.ts +0 -1
  99. package/dist/lib/registry.js +0 -1
  100. package/dist/lib/runtime-acceptance.d.ts +0 -1
  101. package/dist/lib/runtime-acceptance.js +1 -2
  102. package/dist/lib/runtime-contracts.d.ts +0 -1
  103. package/dist/lib/runtime-contracts.js +14 -8
  104. package/dist/lib/runtime-paths.d.ts +0 -1
  105. package/dist/lib/runtime-paths.js +5 -10
  106. package/dist/lib/runtime-prompt.d.ts +0 -1
  107. package/dist/lib/runtime-prompt.js +8 -23
  108. package/dist/lib/runtime-reconcile.d.ts +0 -1
  109. package/dist/lib/runtime-reconcile.js +7 -3
  110. package/dist/lib/runtime-runs.d.ts +0 -1
  111. package/dist/lib/runtime-runs.js +4 -5
  112. package/dist/lib/runtime-types.d.ts +0 -1
  113. package/dist/lib/runtime-types.js +0 -1
  114. package/dist/lib/runtime.d.ts +0 -1
  115. package/dist/lib/runtime.js +0 -1
  116. package/dist/lib/schema.d.ts +356 -51
  117. package/dist/lib/schema.js +189 -54
  118. package/dist/lib/source-config.d.ts +17 -8
  119. package/dist/lib/source-config.js +125 -11
  120. package/dist/lib/state-artifacts.d.ts +0 -1
  121. package/dist/lib/state-artifacts.js +0 -1
  122. package/dist/lib/state-health.d.ts +0 -1
  123. package/dist/lib/state-health.js +2 -3
  124. package/dist/lib/state-io.d.ts +1 -1
  125. package/dist/lib/state-io.js +9 -10
  126. package/dist/lib/state-paths.d.ts +0 -1
  127. package/dist/lib/state-paths.js +5 -11
  128. package/dist/lib/state-view.d.ts +0 -1
  129. package/dist/lib/state-view.js +7 -8
  130. package/dist/lib/state.d.ts +0 -1
  131. package/dist/lib/state.js +0 -1
  132. package/dist/lib/summarize-plan.d.ts +0 -1
  133. package/dist/lib/summarize-plan.js +3 -3
  134. package/dist/lib/test-execution.d.ts +14 -0
  135. package/dist/lib/{benchmark-execution.js → test-execution.js} +122 -120
  136. package/dist/lib/test-matrices.d.ts +90 -0
  137. package/dist/lib/test-matrices.js +96 -0
  138. package/dist/lib/test-paths.d.ts +12 -0
  139. package/dist/lib/test-paths.js +44 -0
  140. package/dist/lib/test-profile-presets.d.ts +57 -0
  141. package/dist/lib/test-profile-presets.js +50 -0
  142. package/dist/lib/test-sandbox.d.ts +11 -0
  143. package/dist/lib/{benchmark-sandbox.js → test-sandbox.js} +18 -13
  144. package/dist/lib/test-specs.d.ts +7 -0
  145. package/dist/lib/test-specs.js +114 -0
  146. package/dist/lib/test-targets.d.ts +5 -0
  147. package/dist/lib/test-targets.js +38 -0
  148. package/dist/lib/test-types.d.ts +17 -0
  149. package/dist/lib/test-types.js +1 -0
  150. package/dist/lib/test.d.ts +4 -0
  151. package/dist/lib/test.js +3 -0
  152. package/dist/lib/user-config.d.ts +0 -1
  153. package/dist/lib/user-config.js +0 -1
  154. package/dist/lib/util.d.ts +0 -2
  155. package/dist/lib/util.js +0 -2
  156. package/dist/lib/validate-helpers.d.ts +0 -1
  157. package/dist/lib/validate-helpers.js +0 -1
  158. package/dist/lib/validate-workspace.d.ts +0 -1
  159. package/dist/lib/validate-workspace.js +34 -25
  160. package/dist/lib/validate.d.ts +0 -1
  161. package/dist/lib/validate.js +55 -9
  162. package/dist/lib/workflow-abi.d.ts +138 -0
  163. package/dist/lib/workflow-abi.js +181 -0
  164. package/dist/lib/workflow-definitions.d.ts +26 -5
  165. package/dist/lib/workflow-definitions.js +105 -168
  166. package/dist/lib/workflow-helpers.d.ts +1 -2
  167. package/dist/lib/workflow-helpers.js +32 -21
  168. package/dist/lib/workflow-improvement.d.ts +22 -0
  169. package/dist/lib/workflow-improvement.js +396 -0
  170. package/dist/lib/workflow-review-paths.d.ts +10 -0
  171. package/dist/lib/workflow-review-paths.js +27 -0
  172. package/dist/lib/workflow-stage-runner.d.ts +1 -1
  173. package/dist/lib/workflow-stage-runner.js +4 -1
  174. package/dist/lib/workflows.d.ts +1 -2
  175. package/dist/lib/workflows.js +1 -2
  176. package/dist/lib/workspace-compile.d.ts +0 -1
  177. package/dist/lib/workspace-compile.js +146 -109
  178. package/dist/lib/workspace-home.d.ts +5 -0
  179. package/dist/lib/workspace-home.js +32 -0
  180. package/dist/lib/workspace-layout.d.ts +2 -0
  181. package/dist/lib/workspace-layout.js +60 -0
  182. package/dist/lib/workspace-paths.d.ts +41 -0
  183. package/dist/lib/workspace-paths.js +107 -0
  184. package/dist/lib/workspace-raw.d.ts +20 -2
  185. package/dist/lib/workspace-raw.js +6 -8
  186. package/dist/lib/workspace-reset.d.ts +0 -1
  187. package/dist/lib/workspace-reset.js +27 -5
  188. package/dist/lib/workspace-schema.d.ts +1 -10
  189. package/dist/lib/workspace-schema.js +16 -74
  190. package/package.json +17 -16
  191. package/dist/bin.d.ts.map +0 -1
  192. package/dist/bin.js.map +0 -1
  193. package/dist/commands/compile.d.ts.map +0 -1
  194. package/dist/commands/compile.js.map +0 -1
  195. package/dist/commands/create-workflow-wizard.d.ts.map +0 -1
  196. package/dist/commands/create-workflow-wizard.js.map +0 -1
  197. package/dist/commands/create.d.ts.map +0 -1
  198. package/dist/commands/create.js.map +0 -1
  199. package/dist/commands/default.d.ts.map +0 -1
  200. package/dist/commands/default.js.map +0 -1
  201. package/dist/commands/doctor.d.ts.map +0 -1
  202. package/dist/commands/doctor.js.map +0 -1
  203. package/dist/commands/executor-flow.d.ts.map +0 -1
  204. package/dist/commands/executor-flow.js.map +0 -1
  205. package/dist/commands/init.d.ts.map +0 -1
  206. package/dist/commands/init.js.map +0 -1
  207. package/dist/commands/list.d.ts.map +0 -1
  208. package/dist/commands/list.js.map +0 -1
  209. package/dist/commands/reset.d.ts.map +0 -1
  210. package/dist/commands/reset.js.map +0 -1
  211. package/dist/commands/source-config-wizard.d.ts.map +0 -1
  212. package/dist/commands/source-config-wizard.js.map +0 -1
  213. package/dist/commands/status.d.ts.map +0 -1
  214. package/dist/commands/status.js.map +0 -1
  215. package/dist/commands/test-flow.d.ts.map +0 -1
  216. package/dist/commands/test-flow.js.map +0 -1
  217. package/dist/commands/test.d.ts.map +0 -1
  218. package/dist/commands/test.js.map +0 -1
  219. package/dist/commands/verify.d.ts.map +0 -1
  220. package/dist/commands/verify.js.map +0 -1
  221. package/dist/commands/workspace-flow.d.ts.map +0 -1
  222. package/dist/commands/workspace-flow.js.map +0 -1
  223. package/dist/index.d.ts.map +0 -1
  224. package/dist/index.js.map +0 -1
  225. package/dist/lib/agent-args.d.ts.map +0 -1
  226. package/dist/lib/agent-args.js.map +0 -1
  227. package/dist/lib/agent-constants.d.ts.map +0 -1
  228. package/dist/lib/agent-constants.js.map +0 -1
  229. package/dist/lib/agent-detection.d.ts.map +0 -1
  230. package/dist/lib/agent-detection.js.map +0 -1
  231. package/dist/lib/agent-execution.d.ts.map +0 -1
  232. package/dist/lib/agent-execution.js.map +0 -1
  233. package/dist/lib/agent-logs.d.ts.map +0 -1
  234. package/dist/lib/agent-logs.js.map +0 -1
  235. package/dist/lib/agent-preflight.d.ts.map +0 -1
  236. package/dist/lib/agent-preflight.js.map +0 -1
  237. package/dist/lib/agent-render.d.ts.map +0 -1
  238. package/dist/lib/agent-render.js.map +0 -1
  239. package/dist/lib/agent-shells.d.ts.map +0 -1
  240. package/dist/lib/agent-shells.js.map +0 -1
  241. package/dist/lib/agent-skills.d.ts +0 -21
  242. package/dist/lib/agent-skills.d.ts.map +0 -1
  243. package/dist/lib/agent-skills.js +0 -215
  244. package/dist/lib/agent-skills.js.map +0 -1
  245. package/dist/lib/agent-status.d.ts.map +0 -1
  246. package/dist/lib/agent-status.js.map +0 -1
  247. package/dist/lib/agent-types.d.ts.map +0 -1
  248. package/dist/lib/agent-types.js.map +0 -1
  249. package/dist/lib/agents.d.ts.map +0 -1
  250. package/dist/lib/agents.js.map +0 -1
  251. package/dist/lib/benchmark-execution.d.ts +0 -13
  252. package/dist/lib/benchmark-execution.d.ts.map +0 -1
  253. package/dist/lib/benchmark-execution.js.map +0 -1
  254. package/dist/lib/benchmark-paths.d.ts +0 -13
  255. package/dist/lib/benchmark-paths.d.ts.map +0 -1
  256. package/dist/lib/benchmark-paths.js +0 -44
  257. package/dist/lib/benchmark-paths.js.map +0 -1
  258. package/dist/lib/benchmark-sandbox.d.ts +0 -12
  259. package/dist/lib/benchmark-sandbox.d.ts.map +0 -1
  260. package/dist/lib/benchmark-sandbox.js.map +0 -1
  261. package/dist/lib/benchmark-specs.d.ts +0 -8
  262. package/dist/lib/benchmark-specs.d.ts.map +0 -1
  263. package/dist/lib/benchmark-specs.js +0 -115
  264. package/dist/lib/benchmark-specs.js.map +0 -1
  265. package/dist/lib/benchmark-targets.d.ts +0 -5
  266. package/dist/lib/benchmark-targets.d.ts.map +0 -1
  267. package/dist/lib/benchmark-targets.js +0 -38
  268. package/dist/lib/benchmark-targets.js.map +0 -1
  269. package/dist/lib/benchmark-types.d.ts +0 -18
  270. package/dist/lib/benchmark-types.d.ts.map +0 -1
  271. package/dist/lib/benchmark-types.js +0 -2
  272. package/dist/lib/benchmark-types.js.map +0 -1
  273. package/dist/lib/benchmark.d.ts +0 -5
  274. package/dist/lib/benchmark.d.ts.map +0 -1
  275. package/dist/lib/benchmark.js +0 -4
  276. package/dist/lib/benchmark.js.map +0 -1
  277. package/dist/lib/config.d.ts.map +0 -1
  278. package/dist/lib/config.js.map +0 -1
  279. package/dist/lib/discovery.d.ts.map +0 -1
  280. package/dist/lib/discovery.js.map +0 -1
  281. package/dist/lib/eval-packs.d.ts +0 -158
  282. package/dist/lib/eval-packs.d.ts.map +0 -1
  283. package/dist/lib/eval-packs.js +0 -149
  284. package/dist/lib/eval-packs.js.map +0 -1
  285. package/dist/lib/execution-profile.d.ts.map +0 -1
  286. package/dist/lib/execution-profile.js.map +0 -1
  287. package/dist/lib/executors.d.ts.map +0 -1
  288. package/dist/lib/executors.js.map +0 -1
  289. package/dist/lib/filesystem.d.ts.map +0 -1
  290. package/dist/lib/filesystem.js.map +0 -1
  291. package/dist/lib/interf-bootstrap.d.ts.map +0 -1
  292. package/dist/lib/interf-bootstrap.js.map +0 -1
  293. package/dist/lib/interf-detect.d.ts.map +0 -1
  294. package/dist/lib/interf-detect.js.map +0 -1
  295. package/dist/lib/interf-scaffold.d.ts.map +0 -1
  296. package/dist/lib/interf-scaffold.js.map +0 -1
  297. package/dist/lib/interf-workflow-package.d.ts.map +0 -1
  298. package/dist/lib/interf-workflow-package.js.map +0 -1
  299. package/dist/lib/interf.d.ts.map +0 -1
  300. package/dist/lib/interf.js.map +0 -1
  301. package/dist/lib/local-workflows.d.ts.map +0 -1
  302. package/dist/lib/local-workflows.js.map +0 -1
  303. package/dist/lib/logger.d.ts.map +0 -1
  304. package/dist/lib/logger.js.map +0 -1
  305. package/dist/lib/obsidian.d.ts.map +0 -1
  306. package/dist/lib/obsidian.js.map +0 -1
  307. package/dist/lib/parse.d.ts.map +0 -1
  308. package/dist/lib/parse.js.map +0 -1
  309. package/dist/lib/registry.d.ts.map +0 -1
  310. package/dist/lib/registry.js.map +0 -1
  311. package/dist/lib/runtime-acceptance.d.ts.map +0 -1
  312. package/dist/lib/runtime-acceptance.js.map +0 -1
  313. package/dist/lib/runtime-contracts.d.ts.map +0 -1
  314. package/dist/lib/runtime-contracts.js.map +0 -1
  315. package/dist/lib/runtime-paths.d.ts.map +0 -1
  316. package/dist/lib/runtime-paths.js.map +0 -1
  317. package/dist/lib/runtime-prompt.d.ts.map +0 -1
  318. package/dist/lib/runtime-prompt.js.map +0 -1
  319. package/dist/lib/runtime-reconcile.d.ts.map +0 -1
  320. package/dist/lib/runtime-reconcile.js.map +0 -1
  321. package/dist/lib/runtime-runs.d.ts.map +0 -1
  322. package/dist/lib/runtime-runs.js.map +0 -1
  323. package/dist/lib/runtime-types.d.ts.map +0 -1
  324. package/dist/lib/runtime-types.js.map +0 -1
  325. package/dist/lib/runtime.d.ts.map +0 -1
  326. package/dist/lib/runtime.js.map +0 -1
  327. package/dist/lib/schema.d.ts.map +0 -1
  328. package/dist/lib/schema.js.map +0 -1
  329. package/dist/lib/source-config.d.ts.map +0 -1
  330. package/dist/lib/source-config.js.map +0 -1
  331. package/dist/lib/state-artifacts.d.ts.map +0 -1
  332. package/dist/lib/state-artifacts.js.map +0 -1
  333. package/dist/lib/state-health.d.ts.map +0 -1
  334. package/dist/lib/state-health.js.map +0 -1
  335. package/dist/lib/state-io.d.ts.map +0 -1
  336. package/dist/lib/state-io.js.map +0 -1
  337. package/dist/lib/state-paths.d.ts.map +0 -1
  338. package/dist/lib/state-paths.js.map +0 -1
  339. package/dist/lib/state-view.d.ts.map +0 -1
  340. package/dist/lib/state-view.js.map +0 -1
  341. package/dist/lib/state.d.ts.map +0 -1
  342. package/dist/lib/state.js.map +0 -1
  343. package/dist/lib/summarize-plan.d.ts.map +0 -1
  344. package/dist/lib/summarize-plan.js.map +0 -1
  345. package/dist/lib/user-config.d.ts.map +0 -1
  346. package/dist/lib/user-config.js.map +0 -1
  347. package/dist/lib/util.d.ts.map +0 -1
  348. package/dist/lib/util.js.map +0 -1
  349. package/dist/lib/validate-helpers.d.ts.map +0 -1
  350. package/dist/lib/validate-helpers.js.map +0 -1
  351. package/dist/lib/validate-workspace.d.ts.map +0 -1
  352. package/dist/lib/validate-workspace.js.map +0 -1
  353. package/dist/lib/validate.d.ts.map +0 -1
  354. package/dist/lib/validate.js.map +0 -1
  355. package/dist/lib/workflow-definitions.d.ts.map +0 -1
  356. package/dist/lib/workflow-definitions.js.map +0 -1
  357. package/dist/lib/workflow-helpers.d.ts.map +0 -1
  358. package/dist/lib/workflow-helpers.js.map +0 -1
  359. package/dist/lib/workflow-stage-runner.d.ts.map +0 -1
  360. package/dist/lib/workflow-stage-runner.js.map +0 -1
  361. package/dist/lib/workflow-starter-docs.d.ts +0 -7
  362. package/dist/lib/workflow-starter-docs.d.ts.map +0 -1
  363. package/dist/lib/workflow-starter-docs.js +0 -3
  364. package/dist/lib/workflow-starter-docs.js.map +0 -1
  365. package/dist/lib/workflows.d.ts.map +0 -1
  366. package/dist/lib/workflows.js.map +0 -1
  367. package/dist/lib/workspace-compile.d.ts.map +0 -1
  368. package/dist/lib/workspace-compile.js.map +0 -1
  369. package/dist/lib/workspace-docs.d.ts +0 -3
  370. package/dist/lib/workspace-docs.d.ts.map +0 -1
  371. package/dist/lib/workspace-docs.js +0 -82
  372. package/dist/lib/workspace-docs.js.map +0 -1
  373. package/dist/lib/workspace-raw.d.ts.map +0 -1
  374. package/dist/lib/workspace-raw.js.map +0 -1
  375. package/dist/lib/workspace-reset.d.ts.map +0 -1
  376. package/dist/lib/workspace-reset.js.map +0 -1
  377. package/dist/lib/workspace-schema.d.ts.map +0 -1
  378. package/dist/lib/workspace-schema.js.map +0 -1
  379. package/skills/benchmark/SKILL.md +0 -122
  380. package/skills/workflow/create/SKILL.md +0 -141
  381. package/skills/workspace/shape/SKILL.md +0 -15
  382. package/skills/workspace/structure/SKILL.md +0 -15
  383. package/skills/workspace/summarize/SKILL.md +0 -15
  384. package/templates/workspace/README.md +0 -24
  385. package/templates/workspace/interfignore +0 -2
@@ -0,0 +1,28 @@
1
+ # Manual Query Loop
2
+
3
+ This file is the editable authoring source for the generated native local `interf-query` skill.
4
+
5
+ Default loop:
6
+ 1. Read `home.md` first.
7
+ 2. Browse `knowledge/` before `raw/`.
8
+ 3. Use `summaries/` for source-grounded evidence.
9
+ 4. Use `raw/` for direct quotes, verification, exact table lookups, and chart-derived values.
10
+
11
+ Answering rule:
12
+ - do not modify files under `raw/`
13
+ - when a number is chart-derived, say that explicitly
14
+ - if the compiled layer already contains a bounded chart-derived read for the exact metric and year the user asked about, answer from that compiled read first
15
+ - use `raw/` to confirm the source page, metric family, or provenance, not to replace a good compiled bounded read with a second incompatible range
16
+ - when the compiled layer preserves a bounded chart-derived range, keep that bounded range in the answer instead of collapsing it to a midpoint or pseudo-exact single value
17
+ - match the granularity of the visible axis labels or bands and do not invent finer precision than the chart supports
18
+ - when reading charts, verify you are on the correct metric family and year before answering
19
+ - keep historical annual charts separate from current-quarter snapshots, sector splits, or nearby lookalike panels
20
+ - when a chart-derived value is approximate, use a bounded range instead of a pseudo-exact number.
21
+ - keep the answer inside the visible tick band unless the chart supports a tighter bound.
22
+ - use an upper-half or lower-half band only when the mark clearly sits there.
23
+ - if a mark touches or nearly touches a labeled gridline, anchor the answer at that gridline or the immediately adjacent half-band.
24
+ - do not widen a chart-derived range across multiple visible bands unless the chart genuinely supports that uncertainty.
25
+ - if multiple compiled notes mention the same chart read, keep the answer consistent with the most focused workspace note rather than synthesizing a new midpoint or shifted band
26
+ - when the compiled layer is insufficient, verify in `raw/` and then answer
27
+
28
+ You can edit this file to bias manual question-answering behavior for this workspace.
@@ -0,0 +1,120 @@
1
+ {
2
+ "id": "interf",
3
+ "type": "workspace",
4
+ "compiler_api": {
5
+ "kind": "workspace",
6
+ "version": 1
7
+ },
8
+ "label": "Interf Compiler (Recommended)",
9
+ "hint": "Interf Compiler's default methodology: summarize source-grounded evidence, structure the cross-file layer, then shape the final workspace around its focus and saved truth checks.",
10
+ "stages": [
11
+ {
12
+ "id": "summarize",
13
+ "label": "Summarize",
14
+ "description": "Turn source files into per-file summaries.",
15
+ "contract_type": "workspace-file-evidence",
16
+ "skill_dir": "summarize",
17
+ "reads": [
18
+ "raw",
19
+ "runtime"
20
+ ],
21
+ "writes": [
22
+ "summaries"
23
+ ],
24
+ "acceptance": {
25
+ "artifacts_exist": [
26
+ ".interf/runtime/inventory.json"
27
+ ],
28
+ "state_truthy": [
29
+ "last_summarize",
30
+ "inventory_complete"
31
+ ],
32
+ "state_at_least_counts": {
33
+ "summarized": "expected_summary_total"
34
+ }
35
+ }
36
+ },
37
+ {
38
+ "id": "structure",
39
+ "label": "Structure",
40
+ "description": "Build the cross-file knowledge structure from the summaries.",
41
+ "contract_type": "workspace-knowledge-structure",
42
+ "skill_dir": "structure",
43
+ "reads": [
44
+ "summaries",
45
+ "runtime"
46
+ ],
47
+ "writes": [
48
+ "knowledge-entities",
49
+ "knowledge-claims",
50
+ "knowledge-indexes"
51
+ ],
52
+ "acceptance": {
53
+ "artifacts_exist": [
54
+ "knowledge/indexes"
55
+ ],
56
+ "state_truthy": [
57
+ "last_structure",
58
+ "inventory_complete"
59
+ ],
60
+ "state_at_least_counts": {
61
+ "structured": "summary_total"
62
+ }
63
+ }
64
+ },
65
+ {
66
+ "id": "shape",
67
+ "label": "Shape",
68
+ "description": "Shape the final workspace around the saved focus and truth checks.",
69
+ "contract_type": "workspace-query-shape",
70
+ "skill_dir": "shape",
71
+ "reads": [
72
+ "raw",
73
+ "summaries",
74
+ "knowledge-entities",
75
+ "knowledge-claims",
76
+ "knowledge-indexes",
77
+ "runtime"
78
+ ],
79
+ "writes": [
80
+ "knowledge-indexes",
81
+ "home"
82
+ ],
83
+ "acceptance": {
84
+ "artifacts_exist": [
85
+ "home.md"
86
+ ],
87
+ "state_truthy": [
88
+ "last_shape",
89
+ "inventory_complete"
90
+ ],
91
+ "state_at_least_counts": {
92
+ "shaped": "summary_total",
93
+ "compiled": "summary_total"
94
+ }
95
+ }
96
+ }
97
+ ],
98
+ "stage_policy_notes": {
99
+ "summarize": [
100
+ "Favor conservative, source-grounded summaries that preserve evidence tiers and leave broader synthesis for later stages.",
101
+ "For large reports or decks, capture scope, headline evidence, and chart/table routing in one light pass.",
102
+ "As soon as one report summary can state scope, headline metrics, and chart/table routing, stop reading and write the summary batch plus runtime artifacts immediately.",
103
+ "Keep scratch extraction commands single-purpose and non-destructive."
104
+ ],
105
+ "structure": [
106
+ "Bias structure toward canonical entities, claims, timelines, and stable indexes.",
107
+ "Use taxonomy and ontology only as means to improve retrieval, navigation, and evidence tracking.",
108
+ "For small datasets, prefer a minimal stable substrate over exhaustive graph sprawl.",
109
+ "When you add wikilinks, target real workspace notes by exact basename or explicit relative path. Do not invent title-style links unless that exact title is also a declared note label or alias.",
110
+ "For summary references, prefer explicit links like `[[summaries/<file-stem>]]` or plain code paths. For knowledge notes, prefer the final filename stem under `knowledge/`."
111
+ ],
112
+ "shape": [
113
+ "Use the workspace focus and saved truth checks to bias the final workspace toward the job it should be especially good at.",
114
+ "Do not copy expected answers into the final workspace just because the checks imply them.",
115
+ "If a saved truth check depends on chart-derived or table-derived values, verify the needed evidence in `raw/` while shaping and write focused notes that preserve bounded values plus provenance.",
116
+ "Prefer better routing, prioritization, and focused navigation over speculative synthesis.",
117
+ "Any wikilinks you add to `home.md` or indexes must resolve to real workspace note basenames or explicit relative paths."
118
+ ]
119
+ }
120
+ }
@@ -0,0 +1,75 @@
1
+ {
2
+ "kind": "workspace-schema",
3
+ "version": 1,
4
+ "target_type": "workspace",
5
+ "label": "Interf Compiler (Recommended) workspace schema",
6
+ "zones": [
7
+ {
8
+ "id": "raw",
9
+ "path": "raw",
10
+ "kind": "directory",
11
+ "required": true,
12
+ "owned_by": [],
13
+ "description": "Workspace-local raw snapshot copied from the dataset for direct evidence and verification."
14
+ },
15
+ {
16
+ "id": "summaries",
17
+ "path": "summaries",
18
+ "kind": "directory",
19
+ "required": true,
20
+ "owned_by": [
21
+ "summarize"
22
+ ],
23
+ "description": "Per-file evidence notes produced by file-evidence stages."
24
+ },
25
+ {
26
+ "id": "knowledge-entities",
27
+ "path": "knowledge/entities",
28
+ "kind": "directory",
29
+ "required": true,
30
+ "owned_by": [
31
+ "structure"
32
+ ],
33
+ "description": "Canonical entity notes produced by knowledge-structure stages."
34
+ },
35
+ {
36
+ "id": "knowledge-claims",
37
+ "path": "knowledge/claims",
38
+ "kind": "directory",
39
+ "required": true,
40
+ "owned_by": [
41
+ "structure"
42
+ ],
43
+ "description": "Claim notes produced by knowledge-structure stages."
44
+ },
45
+ {
46
+ "id": "knowledge-indexes",
47
+ "path": "knowledge/indexes",
48
+ "kind": "directory",
49
+ "required": true,
50
+ "owned_by": [
51
+ "structure",
52
+ "shape"
53
+ ],
54
+ "description": "Retrieval indexes and navigation notes produced by structure and shape stages."
55
+ },
56
+ {
57
+ "id": "home",
58
+ "path": "home.md",
59
+ "kind": "file",
60
+ "required": true,
61
+ "owned_by": [
62
+ "shape"
63
+ ],
64
+ "description": "Primary entrypoint note for agents using the compiled workspace."
65
+ },
66
+ {
67
+ "id": "runtime",
68
+ "path": ".interf/runtime",
69
+ "kind": "runtime",
70
+ "required": true,
71
+ "owned_by": [],
72
+ "description": "CLI-owned runtime state, health, stage contracts, and proof artifacts."
73
+ }
74
+ ]
75
+ }
package/dist/bin.d.ts CHANGED
@@ -1,3 +1,2 @@
1
1
  #!/usr/bin/env node
2
2
  export {};
3
- //# sourceMappingURL=bin.d.ts.map
package/dist/bin.js CHANGED
@@ -27,4 +27,3 @@ yargs(hideBin(process.argv))
27
27
  .help()
28
28
  .version()
29
29
  .parse();
30
- //# sourceMappingURL=bin.js.map
@@ -0,0 +1,14 @@
1
+ import type { WorkflowExecutionProfile, WorkflowExecutor } from "../lib/executors.js";
2
+ import type { SourceWorkspaceConfig } from "../lib/schema.js";
3
+ import type { StageShellRetentionMode } from "../lib/workflows.js";
4
+ export declare function runConfiguredWorkspaceCompile(options: {
5
+ executor: WorkflowExecutor;
6
+ testExecutor?: WorkflowExecutor | null;
7
+ workspacePath: string;
8
+ sourcePath: string;
9
+ workspaceConfig: SourceWorkspaceConfig | null;
10
+ executionProfile?: WorkflowExecutionProfile;
11
+ maxAttemptsOverride: number | null;
12
+ maxLoopsOverride: number | null;
13
+ preserveStageShells?: StageShellRetentionMode;
14
+ }): Promise<boolean>;
@@ -0,0 +1,409 @@
1
+ import { cpSync, existsSync, mkdirSync, mkdtempSync, rmSync } from "node:fs";
2
+ import { tmpdir } from "node:os";
3
+ import { dirname, join } from "node:path";
4
+ import chalk from "chalk";
5
+ import { readInterfConfig } from "../lib/interf.js";
6
+ import { resetWorkspaceGeneratedState } from "../lib/workspace-reset.js";
7
+ import { formatActiveWorkspaceWorkflowStageStep, resolveWorkspaceWorkflowFromConfig, } from "../lib/workflow-definitions.js";
8
+ import { resolveWorkspaceCompileMaxAttempts, resolveWorkspaceCompileMaxLoops, } from "../lib/source-config.js";
9
+ import { runWorkflowImprovementLoop } from "../lib/workflow-improvement.js";
10
+ import { stageExecutionShellsRoot, workflowPackagePathForWorkspace, } from "../lib/workspace-paths.js";
11
+ import { compileWorkspaceWithReporter } from "./workspace-flow.js";
12
+ import { printSavedTestOutcome, questionPassRate, runSavedWorkspaceTest, } from "./test-flow.js";
13
+ function printCompileFailure(workspacePath, failedStage) {
14
+ const workflowId = resolveWorkspaceWorkflowFromConfig(readInterfConfig(workspacePath));
15
+ const failedStageLabel = formatActiveWorkspaceWorkflowStageStep(workspacePath, workflowId, failedStage ?? "compile");
16
+ console.log(chalk.red(` ${failedStageLabel} failed.`));
17
+ }
18
+ function testScore(outcome) {
19
+ return (outcome.result.passedCases * 1000) + outcome.result.passedChecks;
20
+ }
21
+ const BEST_VARIATION_RESTORE_PATHS = [
22
+ "AGENTS.md",
23
+ "CLAUDE.md",
24
+ "home.md",
25
+ "summaries",
26
+ "knowledge",
27
+ ".claude",
28
+ ".codex",
29
+ ".agents",
30
+ ".cursor",
31
+ ".obsidian",
32
+ ".interf/interf.json",
33
+ ".interf/workflow",
34
+ ".interf/runtime/state.json",
35
+ ".interf/runtime/health.json",
36
+ ".interf/runtime/view-spec.json",
37
+ ".interf/runtime/inventory.json",
38
+ ".interf/runtime/run.json",
39
+ ".interf/runtime/raw-snapshot.json",
40
+ ".interf/runtime/stage-contract.json",
41
+ ".interf/runtime/summarize-targets.json",
42
+ ];
43
+ function copyRelativePathIfPresent(sourceRoot, targetRoot, relativePath) {
44
+ const sourcePath = join(sourceRoot, relativePath);
45
+ if (!existsSync(sourcePath))
46
+ return;
47
+ const targetPath = join(targetRoot, relativePath);
48
+ mkdirSync(dirname(targetPath), { recursive: true });
49
+ cpSync(sourcePath, targetPath, {
50
+ recursive: true,
51
+ force: true,
52
+ errorOnExist: false,
53
+ });
54
+ }
55
+ function snapshotWorkspaceBestState(workspacePath) {
56
+ const snapshotRoot = mkdtempSync(join(tmpdir(), "interf-compile-attempt-"));
57
+ const snapshotPath = join(snapshotRoot, "workspace");
58
+ for (const relativePath of BEST_VARIATION_RESTORE_PATHS) {
59
+ copyRelativePathIfPresent(workspacePath, snapshotPath, relativePath);
60
+ }
61
+ return snapshotPath;
62
+ }
63
+ function restoreWorkspaceBestState(snapshotPath, workspacePath) {
64
+ for (const relativePath of BEST_VARIATION_RESTORE_PATHS) {
65
+ rmSync(join(workspacePath, relativePath), { recursive: true, force: true });
66
+ copyRelativePathIfPresent(snapshotPath, workspacePath, relativePath);
67
+ }
68
+ }
69
+ async function runWorkflowVariation(options) {
70
+ let bestOutcome = null;
71
+ let bestSnapshotPath = null;
72
+ let bestAttempt = 0;
73
+ let attemptsRun = 0;
74
+ try {
75
+ for (let attempt = 1; attempt <= options.maxAttempts; attempt += 1) {
76
+ attemptsRun = attempt;
77
+ if (attempt > 1 || (attempt === 1 && options.resetBeforeFirstAttempt)) {
78
+ console.log();
79
+ const resetTarget = attempt > 1
80
+ ? `attempt ${attempt}/${options.maxAttempts}`
81
+ : options.variationLabel;
82
+ console.log(chalk.dim(` Resetting generated workspace state before ${resetTarget}...`));
83
+ resetWorkspaceGeneratedState(options.workspacePath, "compile");
84
+ }
85
+ const result = await compileWorkspaceWithReporter(options.executor, options.workspacePath, {
86
+ heading: options.maxAttempts > 1
87
+ ? `Building compiled workspace (${options.variationLabel}, attempt ${attempt}/${options.maxAttempts})...`
88
+ : `Building compiled workspace (${options.variationLabel})...`,
89
+ successMessage: options.maxAttempts > 1
90
+ ? `Compiled workspace ready for ${options.variationLabel}, attempt ${attempt}.`
91
+ : `Compiled workspace ready for ${options.variationLabel}.`,
92
+ preserveStageShells: options.preserveStageShells,
93
+ });
94
+ if (!result.ok) {
95
+ printCompileFailure(options.workspacePath, result.failedStage);
96
+ printStageShellReviewHint(options.workspacePath, options.preserveStageShells);
97
+ if (attempt < options.maxAttempts) {
98
+ console.log(chalk.yellow(` ${options.variationLabel} attempt ${attempt}/${options.maxAttempts} failed. Retrying with a fresh compile.`));
99
+ continue;
100
+ }
101
+ return {
102
+ passed: false,
103
+ attemptsRun,
104
+ failedStage: result.failedStage,
105
+ bestOutcome,
106
+ bestSnapshotPath,
107
+ bestAttempt,
108
+ fatalError: null,
109
+ };
110
+ }
111
+ const outcome = await runSavedWorkspaceTest({
112
+ sourcePath: options.sourcePath,
113
+ workspaceConfig: options.workspaceConfig,
114
+ executor: options.testExecutor,
115
+ executionProfile: options.executionProfile,
116
+ workspacePath: options.workspacePath,
117
+ preserveSandboxes: options.preserveStageShells === "always" ? "always" : "on-failure",
118
+ });
119
+ if (!outcome) {
120
+ return {
121
+ passed: false,
122
+ attemptsRun,
123
+ failedStage: null,
124
+ bestOutcome,
125
+ bestSnapshotPath,
126
+ bestAttempt,
127
+ fatalError: "Could not run the saved workspace test after compile.",
128
+ };
129
+ }
130
+ console.log();
131
+ printSavedTestOutcome(`${options.variationLabel} · attempt ${attempt}/${options.maxAttempts}`, outcome);
132
+ if (!bestOutcome || testScore(outcome) > testScore(bestOutcome)) {
133
+ if (bestSnapshotPath) {
134
+ rmSync(bestSnapshotPath, { recursive: true, force: true });
135
+ }
136
+ bestOutcome = outcome;
137
+ bestSnapshotPath = snapshotWorkspaceBestState(options.workspacePath);
138
+ bestAttempt = attempt;
139
+ }
140
+ if (outcome.result.ok) {
141
+ console.log();
142
+ console.log(chalk.green(` Workspace passed on ${options.variationLabel}, attempt ${attempt}/${options.maxAttempts}.`));
143
+ printStageShellReviewHint(options.workspacePath, options.preserveStageShells);
144
+ return {
145
+ passed: true,
146
+ attemptsRun,
147
+ failedStage: null,
148
+ bestOutcome,
149
+ bestSnapshotPath,
150
+ bestAttempt,
151
+ fatalError: null,
152
+ };
153
+ }
154
+ if (attempt < options.maxAttempts) {
155
+ console.log();
156
+ console.log(chalk.yellow(` ${options.variationLabel} attempt ${attempt}/${options.maxAttempts} did not pass. Retrying with the same workflow.`));
157
+ }
158
+ }
159
+ return {
160
+ passed: false,
161
+ attemptsRun,
162
+ failedStage: null,
163
+ bestOutcome,
164
+ bestSnapshotPath,
165
+ bestAttempt,
166
+ fatalError: null,
167
+ };
168
+ }
169
+ catch (error) {
170
+ return {
171
+ passed: false,
172
+ attemptsRun,
173
+ failedStage: null,
174
+ bestOutcome,
175
+ bestSnapshotPath,
176
+ bestAttempt,
177
+ fatalError: error instanceof Error ? error.message : String(error),
178
+ };
179
+ }
180
+ }
181
+ function summarizeWorkflowVariation(options) {
182
+ const passedQuestions = options.result.bestOutcome?.result.passedCases ?? 0;
183
+ const totalQuestions = options.result.bestOutcome?.result.totalCases ?? options.defaultTotalQuestions;
184
+ const summary = options.result.passed
185
+ ? `Passed ${passedQuestions}/${totalQuestions} truth checks.`
186
+ : options.result.bestOutcome
187
+ ? `Best result: ${passedQuestions}/${totalQuestions} truth checks passed.`
188
+ : options.result.failedStage
189
+ ? `Compile failed at stage ${options.result.failedStage} before any test result.`
190
+ : "Workflow variation did not produce a passing result.";
191
+ return {
192
+ variation: options.variation,
193
+ kind: options.kind,
194
+ attempts_run: Math.max(1, options.result.attemptsRun),
195
+ passed: options.result.passed,
196
+ passed_questions: passedQuestions,
197
+ total_questions: totalQuestions,
198
+ ...(options.result.failedStage ? { failed_stage: options.result.failedStage } : {}),
199
+ ...(options.result.bestOutcome ? { test_run_path: options.result.bestOutcome.runPath } : {}),
200
+ ...(options.result.bestOutcome?.result.sandbox_path
201
+ ? { test_sandbox_path: options.result.bestOutcome.result.sandbox_path }
202
+ : {}),
203
+ summary,
204
+ };
205
+ }
206
+ function printStageShellReviewHint(workspacePath, preserveStageShells) {
207
+ const reviewRoot = stageExecutionShellsRoot(workspacePath);
208
+ if (preserveStageShells === "always") {
209
+ console.log(chalk.dim(` Preserved stage shells: ${reviewRoot}`));
210
+ return;
211
+ }
212
+ console.log(chalk.dim(` Failed stage shells remain under: ${reviewRoot}`));
213
+ }
214
+ function formatVariationQuestionSummary(summary) {
215
+ return `${summary.passed_questions}/${summary.total_questions}`;
216
+ }
217
+ function printWorkflowVariationSummary(summaries) {
218
+ if (summaries.length === 0)
219
+ return;
220
+ console.log();
221
+ console.log(chalk.bold(" Workflow variation summary"));
222
+ console.log();
223
+ console.log(" | Variation | Kind | Truth checks | Result |");
224
+ console.log(" | --- | --- | --- | --- |");
225
+ for (const summary of summaries) {
226
+ console.log(` | ${summary.variation} | ${summary.kind} | \`${formatVariationQuestionSummary(summary)}\` | ${summary.passed ? "pass" : "fail"} |`);
227
+ }
228
+ }
229
+ function printWorkspaceLocalWorkflowOwnership(workspacePath, bestVariation) {
230
+ if (bestVariation <= 1)
231
+ return;
232
+ console.log();
233
+ console.log(chalk.dim(` Best workflow variation now lives in: ${workflowPackagePathForWorkspace(workspacePath)}`));
234
+ console.log(chalk.dim(" Source-folder workflow selection was not changed automatically."));
235
+ console.log(chalk.dim(" Recompiling this existing workspace reuses that workspace-local workflow draft."));
236
+ }
237
+ export async function runConfiguredWorkspaceCompile(options) {
238
+ const preserveStageShells = options.preserveStageShells ?? "on-failure";
239
+ const configuredMaxAttempts = resolveWorkspaceCompileMaxAttempts(options.workspaceConfig ?? { max_attempts: undefined }, options.maxAttemptsOverride);
240
+ const maxLoops = resolveWorkspaceCompileMaxLoops(options.workspaceConfig ?? { max_loops: undefined }, options.maxLoopsOverride);
241
+ const maxAttempts = configuredMaxAttempts ?? (maxLoops != null ? 1 : null);
242
+ const loopEnabled = maxAttempts != null;
243
+ const checks = options.workspaceConfig?.checks ?? [];
244
+ if (loopEnabled && checks.length === 0) {
245
+ console.log(chalk.yellow(" Retry and self-improving modes need saved truth checks. Building once without those loops."));
246
+ }
247
+ else if (loopEnabled) {
248
+ if (maxAttempts > 1) {
249
+ console.log(chalk.dim(` Retry mode: up to ${maxAttempts} compile attempts.`));
250
+ console.log(chalk.dim(" Interf Compiler will rerun the same workflow variation, test the workspace, and stop early if it passes."));
251
+ }
252
+ else {
253
+ console.log(chalk.dim(" Compile mode: 1 attempt per workflow variation."));
254
+ }
255
+ if (maxLoops != null) {
256
+ console.log(chalk.dim(` Self-improving loops: up to ${maxLoops} workflow edits after retries fail.`));
257
+ console.log(chalk.dim(" Interf Compiler will review failed runs, edit the workflow package, and test new workflow variations."));
258
+ }
259
+ }
260
+ if (!loopEnabled || checks.length === 0) {
261
+ const result = await compileWorkspaceWithReporter(options.executor, options.workspacePath, {
262
+ preserveStageShells,
263
+ });
264
+ if (!result.ok) {
265
+ process.exitCode = 1;
266
+ printCompileFailure(options.workspacePath, result.failedStage);
267
+ printStageShellReviewHint(options.workspacePath, preserveStageShells);
268
+ return false;
269
+ }
270
+ printStageShellReviewHint(options.workspacePath, preserveStageShells);
271
+ return true;
272
+ }
273
+ let bestOutcome = null;
274
+ let bestSnapshotPath = null;
275
+ let bestAttempt = 0;
276
+ let bestVariation = 0;
277
+ const previousVariations = [];
278
+ const improvementRunId = `${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 8)}`;
279
+ try {
280
+ const workspaceConfig = options.workspaceConfig ?? {
281
+ name: readInterfConfig(options.workspacePath)?.name ?? "workspace",
282
+ checks: [],
283
+ };
284
+ const adoptVariationBest = (variation, result) => {
285
+ if (result.bestOutcome && result.bestSnapshotPath && (!bestOutcome || testScore(result.bestOutcome) > testScore(bestOutcome))) {
286
+ if (bestSnapshotPath) {
287
+ rmSync(bestSnapshotPath, { recursive: true, force: true });
288
+ }
289
+ bestOutcome = result.bestOutcome;
290
+ bestSnapshotPath = result.bestSnapshotPath;
291
+ bestAttempt = result.bestAttempt;
292
+ bestVariation = variation;
293
+ result.bestSnapshotPath = null;
294
+ }
295
+ if (result.bestSnapshotPath) {
296
+ rmSync(result.bestSnapshotPath, { recursive: true, force: true });
297
+ result.bestSnapshotPath = null;
298
+ }
299
+ };
300
+ const baseline = await runWorkflowVariation({
301
+ executor: options.executor,
302
+ testExecutor: options.testExecutor,
303
+ workspacePath: options.workspacePath,
304
+ sourcePath: options.sourcePath,
305
+ workspaceConfig,
306
+ executionProfile: options.executionProfile,
307
+ preserveStageShells,
308
+ maxAttempts,
309
+ variationLabel: "baseline workflow",
310
+ });
311
+ if (baseline.fatalError) {
312
+ process.exitCode = 1;
313
+ console.log(chalk.red(` ${baseline.fatalError}`));
314
+ return false;
315
+ }
316
+ adoptVariationBest(1, baseline);
317
+ previousVariations.push(summarizeWorkflowVariation({
318
+ variation: 1,
319
+ kind: "baseline",
320
+ result: baseline,
321
+ defaultTotalQuestions: checks.length,
322
+ }));
323
+ if (baseline.passed) {
324
+ printWorkflowVariationSummary(previousVariations);
325
+ return true;
326
+ }
327
+ if (maxLoops != null) {
328
+ for (let loopIndex = 1; loopIndex <= maxLoops; loopIndex += 1) {
329
+ console.log();
330
+ console.log(chalk.dim(` Self-improving loop ${loopIndex}/${maxLoops}: reviewing failed runs and editing the workflow.`));
331
+ const improvement = await runWorkflowImprovementLoop({
332
+ executor: options.executor,
333
+ workspacePath: options.workspacePath,
334
+ workflowId: resolveWorkspaceWorkflowFromConfig(readInterfConfig(options.workspacePath)),
335
+ workspaceConfig,
336
+ runId: improvementRunId,
337
+ loopIndex,
338
+ maxLoops,
339
+ maxAttempts,
340
+ previousVariations,
341
+ });
342
+ console.log(chalk.dim(` Workflow improvement shell: ${improvement.shellPath}`));
343
+ if (improvement.status === "executor-failed") {
344
+ process.exitCode = 1;
345
+ console.log(chalk.red(` ${improvement.summary}`));
346
+ break;
347
+ }
348
+ if (improvement.status !== "updated") {
349
+ console.log(chalk.yellow(` ${improvement.summary}`));
350
+ continue;
351
+ }
352
+ const variation = await runWorkflowVariation({
353
+ executor: options.executor,
354
+ testExecutor: options.testExecutor,
355
+ workspacePath: options.workspacePath,
356
+ sourcePath: options.sourcePath,
357
+ workspaceConfig,
358
+ executionProfile: options.executionProfile,
359
+ preserveStageShells,
360
+ maxAttempts,
361
+ variationLabel: `workflow variation ${loopIndex + 1}`,
362
+ resetBeforeFirstAttempt: true,
363
+ });
364
+ if (variation.fatalError) {
365
+ process.exitCode = 1;
366
+ console.log(chalk.red(` ${variation.fatalError}`));
367
+ return false;
368
+ }
369
+ adoptVariationBest(loopIndex + 1, variation);
370
+ previousVariations.push(summarizeWorkflowVariation({
371
+ variation: loopIndex + 1,
372
+ kind: "edited",
373
+ result: variation,
374
+ defaultTotalQuestions: checks.length,
375
+ }));
376
+ if (variation.passed) {
377
+ printWorkflowVariationSummary(previousVariations);
378
+ printWorkspaceLocalWorkflowOwnership(options.workspacePath, bestVariation);
379
+ return true;
380
+ }
381
+ }
382
+ }
383
+ if (bestSnapshotPath && bestVariation > 0) {
384
+ restoreWorkspaceBestState(bestSnapshotPath, options.workspacePath);
385
+ console.log();
386
+ console.log(chalk.dim(` Restored the best-performing compiled workspace from variation ${bestVariation}, attempt ${bestAttempt}.`));
387
+ }
388
+ process.exitCode = 1;
389
+ console.log();
390
+ printWorkflowVariationSummary(previousVariations);
391
+ printWorkspaceLocalWorkflowOwnership(options.workspacePath, bestVariation);
392
+ if (maxLoops != null) {
393
+ console.log(chalk.red(` Workspace did not pass after ${maxAttempts} attempt${maxAttempts === 1 ? "" : "s"} per variation and ${maxLoops} workflow-improvement loop${maxLoops === 1 ? "" : "s"}.`));
394
+ }
395
+ else {
396
+ console.log(chalk.red(` Workspace did not pass within ${maxAttempts} attempt${maxAttempts === 1 ? "" : "s"}.`));
397
+ }
398
+ if (bestOutcome) {
399
+ console.log(chalk.dim(` Best attempt truth-check pass rate: ${questionPassRate(bestOutcome)}%.`));
400
+ }
401
+ printStageShellReviewHint(options.workspacePath, preserveStageShells);
402
+ return false;
403
+ }
404
+ finally {
405
+ if (bestSnapshotPath) {
406
+ rmSync(bestSnapshotPath, { recursive: true, force: true });
407
+ }
408
+ }
409
+ }