@caupulican/pi-adaptative 0.90.12 → 0.91.2

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 (278) hide show
  1. package/CHANGELOG.md +39 -0
  2. package/README.md +8 -10
  3. package/dist/bundled-resources/skills/icm-architect/LICENSE +21 -0
  4. package/dist/bundled-resources/skills/icm-architect/SKILL.md +112 -0
  5. package/dist/bundled-resources/skills/icm-architect/assets/templates/CLAUDE.md +27 -0
  6. package/dist/bundled-resources/skills/icm-architect/assets/templates/CONTEXT.md +14 -0
  7. package/dist/bundled-resources/skills/icm-architect/assets/templates/node.md +29 -0
  8. package/dist/bundled-resources/skills/icm-architect/assets/templates/object.md +43 -0
  9. package/dist/bundled-resources/skills/icm-architect/assets/templates/process.md +38 -0
  10. package/dist/bundled-resources/skills/icm-architect/assets/templates/questionnaire.md +9 -0
  11. package/dist/bundled-resources/skills/icm-architect/assets/templates/schema.md +24 -0
  12. package/dist/bundled-resources/skills/icm-architect/assets/templates/stage-CONTEXT.md +21 -0
  13. package/dist/bundled-resources/skills/icm-architect/references/core.md +92 -0
  14. package/dist/bundled-resources/skills/icm-architect/references/forms.md +182 -0
  15. package/dist/bundled-resources/skills/icm-architect/references/system-map.md +122 -0
  16. package/dist/cli/args.d.ts.map +1 -1
  17. package/dist/cli/args.js +2 -1
  18. package/dist/cli/args.js.map +1 -1
  19. package/dist/core/agent-paths.d.ts +2 -2
  20. package/dist/core/agent-paths.d.ts.map +1 -1
  21. package/dist/core/agent-paths.js +1 -0
  22. package/dist/core/agent-paths.js.map +1 -1
  23. package/dist/core/agent-session.d.ts +12 -0
  24. package/dist/core/agent-session.d.ts.map +1 -1
  25. package/dist/core/agent-session.js +40 -10
  26. package/dist/core/agent-session.js.map +1 -1
  27. package/dist/core/autonomy/lane-tool-surface.d.ts.map +1 -1
  28. package/dist/core/autonomy/lane-tool-surface.js +2 -0
  29. package/dist/core/autonomy/lane-tool-surface.js.map +1 -1
  30. package/dist/core/background-tool-task-controller.d.ts +9 -0
  31. package/dist/core/background-tool-task-controller.d.ts.map +1 -1
  32. package/dist/core/background-tool-task-controller.js +23 -0
  33. package/dist/core/background-tool-task-controller.js.map +1 -1
  34. package/dist/core/bash-executor.js +3 -3
  35. package/dist/core/bash-executor.js.map +1 -1
  36. package/dist/core/context/local-graph-memory-provider.d.ts +9 -0
  37. package/dist/core/context/local-graph-memory-provider.d.ts.map +1 -0
  38. package/dist/core/context/local-graph-memory-provider.js +122 -0
  39. package/dist/core/context/local-graph-memory-provider.js.map +1 -0
  40. package/dist/core/context/tool-output-packer.d.ts +2 -2
  41. package/dist/core/context/tool-output-packer.d.ts.map +1 -1
  42. package/dist/core/context/tool-output-packer.js +3 -3
  43. package/dist/core/context/tool-output-packer.js.map +1 -1
  44. package/dist/core/context-gc.d.ts.map +1 -1
  45. package/dist/core/context-gc.js +2 -0
  46. package/dist/core/context-gc.js.map +1 -1
  47. package/dist/core/default-tool-surface.d.ts.map +1 -1
  48. package/dist/core/default-tool-surface.js +5 -0
  49. package/dist/core/default-tool-surface.js.map +1 -1
  50. package/dist/core/delegation/worker-agent-control-coordinator.d.ts +1 -0
  51. package/dist/core/delegation/worker-agent-control-coordinator.d.ts.map +1 -1
  52. package/dist/core/delegation/worker-agent-control-coordinator.js +16 -8
  53. package/dist/core/delegation/worker-agent-control-coordinator.js.map +1 -1
  54. package/dist/core/delegation/worker-agent-control.d.ts +2 -0
  55. package/dist/core/delegation/worker-agent-control.d.ts.map +1 -1
  56. package/dist/core/delegation/worker-agent-control.js.map +1 -1
  57. package/dist/core/delegation/worker-context-inheritance-policy.d.ts +3 -3
  58. package/dist/core/delegation/worker-context-inheritance-policy.js +4 -4
  59. package/dist/core/delegation/worker-context-inheritance-policy.js.map +1 -1
  60. package/dist/core/delegation/worker-delegation-controller.d.ts +1 -5
  61. package/dist/core/delegation/worker-delegation-controller.d.ts.map +1 -1
  62. package/dist/core/delegation/worker-delegation-controller.js +19 -9
  63. package/dist/core/delegation/worker-delegation-controller.js.map +1 -1
  64. package/dist/core/delegation/worker-tree-budget-coordinator.d.ts +2 -0
  65. package/dist/core/delegation/worker-tree-budget-coordinator.d.ts.map +1 -1
  66. package/dist/core/delegation/worker-tree-budget-coordinator.js +6 -0
  67. package/dist/core/delegation/worker-tree-budget-coordinator.js.map +1 -1
  68. package/dist/core/extensions/runner.d.ts.map +1 -1
  69. package/dist/core/extensions/runner.js +1 -0
  70. package/dist/core/extensions/runner.js.map +1 -1
  71. package/dist/core/foreground-terminal-handoff-controller.d.ts +0 -1
  72. package/dist/core/foreground-terminal-handoff-controller.d.ts.map +1 -1
  73. package/dist/core/foreground-terminal-handoff-controller.js +1 -2
  74. package/dist/core/foreground-terminal-handoff-controller.js.map +1 -1
  75. package/dist/core/goals/goal-continuation-controller.d.ts +7 -1
  76. package/dist/core/goals/goal-continuation-controller.d.ts.map +1 -1
  77. package/dist/core/goals/goal-continuation-controller.js +16 -0
  78. package/dist/core/goals/goal-continuation-controller.js.map +1 -1
  79. package/dist/core/goals/goal-runtime-snapshot.d.ts +3 -0
  80. package/dist/core/goals/goal-runtime-snapshot.d.ts.map +1 -1
  81. package/dist/core/goals/goal-runtime-snapshot.js +8 -1
  82. package/dist/core/goals/goal-runtime-snapshot.js.map +1 -1
  83. package/dist/core/goals/goal-session-controller.d.ts +2 -0
  84. package/dist/core/goals/goal-session-controller.d.ts.map +1 -1
  85. package/dist/core/goals/goal-session-controller.js +1 -0
  86. package/dist/core/goals/goal-session-controller.js.map +1 -1
  87. package/dist/core/goals/goal-tool-core.d.ts +18 -0
  88. package/dist/core/goals/goal-tool-core.d.ts.map +1 -1
  89. package/dist/core/goals/goal-tool-core.js +62 -0
  90. package/dist/core/goals/goal-tool-core.js.map +1 -1
  91. package/dist/core/goals/natural-language-goal.d.ts.map +1 -1
  92. package/dist/core/goals/natural-language-goal.js +4 -2
  93. package/dist/core/goals/natural-language-goal.js.map +1 -1
  94. package/dist/core/human-input-controller.d.ts +3 -34
  95. package/dist/core/human-input-controller.d.ts.map +1 -1
  96. package/dist/core/human-input-controller.js +3 -161
  97. package/dist/core/human-input-controller.js.map +1 -1
  98. package/dist/core/keybindings.d.ts +5 -0
  99. package/dist/core/keybindings.d.ts.map +1 -1
  100. package/dist/core/keybindings.js +2 -0
  101. package/dist/core/keybindings.js.map +1 -1
  102. package/dist/core/learning/reflection-turn-analysis.d.ts.map +1 -1
  103. package/dist/core/learning/reflection-turn-analysis.js +10 -1
  104. package/dist/core/learning/reflection-turn-analysis.js.map +1 -1
  105. package/dist/core/memory/providers/file-store.d.ts.map +1 -1
  106. package/dist/core/memory/providers/file-store.js +4 -0
  107. package/dist/core/memory/providers/file-store.js.map +1 -1
  108. package/dist/core/memory-controller.d.ts +3 -0
  109. package/dist/core/memory-controller.d.ts.map +1 -1
  110. package/dist/core/memory-controller.js +18 -0
  111. package/dist/core/memory-controller.js.map +1 -1
  112. package/dist/core/model-capability.d.ts.map +1 -1
  113. package/dist/core/model-capability.js +1 -0
  114. package/dist/core/model-capability.js.map +1 -1
  115. package/dist/core/orchestration/work-state-projection.d.ts +4 -0
  116. package/dist/core/orchestration/work-state-projection.d.ts.map +1 -1
  117. package/dist/core/orchestration/work-state-projection.js +11 -0
  118. package/dist/core/orchestration/work-state-projection.js.map +1 -1
  119. package/dist/core/pipelines/context.d.ts +6 -0
  120. package/dist/core/pipelines/context.d.ts.map +1 -0
  121. package/dist/core/pipelines/context.js +102 -0
  122. package/dist/core/pipelines/context.js.map +1 -0
  123. package/dist/core/pipelines/discover.d.ts +11 -0
  124. package/dist/core/pipelines/discover.d.ts.map +1 -0
  125. package/dist/core/pipelines/discover.js +147 -0
  126. package/dist/core/pipelines/discover.js.map +1 -0
  127. package/dist/core/pipelines/increment.d.ts +24 -0
  128. package/dist/core/pipelines/increment.d.ts.map +1 -0
  129. package/dist/core/pipelines/increment.js +121 -0
  130. package/dist/core/pipelines/increment.js.map +1 -0
  131. package/dist/core/pipelines/index.d.ts +8 -0
  132. package/dist/core/pipelines/index.d.ts.map +1 -0
  133. package/dist/core/pipelines/index.js +8 -0
  134. package/dist/core/pipelines/index.js.map +1 -0
  135. package/dist/core/pipelines/parse-contract.d.ts +10 -0
  136. package/dist/core/pipelines/parse-contract.d.ts.map +1 -0
  137. package/dist/core/pipelines/parse-contract.js +105 -0
  138. package/dist/core/pipelines/parse-contract.js.map +1 -0
  139. package/dist/core/pipelines/run-state.d.ts +26 -0
  140. package/dist/core/pipelines/run-state.d.ts.map +1 -0
  141. package/dist/core/pipelines/run-state.js +135 -0
  142. package/dist/core/pipelines/run-state.js.map +1 -0
  143. package/dist/core/pipelines/session-pipeline-run.d.ts +6 -0
  144. package/dist/core/pipelines/session-pipeline-run.d.ts.map +1 -0
  145. package/dist/core/pipelines/session-pipeline-run.js +18 -0
  146. package/dist/core/pipelines/session-pipeline-run.js.map +1 -0
  147. package/dist/core/pipelines/types.d.ts +91 -0
  148. package/dist/core/pipelines/types.d.ts.map +1 -0
  149. package/dist/core/pipelines/types.js +44 -0
  150. package/dist/core/pipelines/types.js.map +1 -0
  151. package/dist/core/reflection-controller.d.ts +2 -0
  152. package/dist/core/reflection-controller.d.ts.map +1 -1
  153. package/dist/core/reflection-controller.js +53 -30
  154. package/dist/core/reflection-controller.js.map +1 -1
  155. package/dist/core/resource-loader.d.ts +21 -0
  156. package/dist/core/resource-loader.d.ts.map +1 -1
  157. package/dist/core/resource-loader.js +45 -18
  158. package/dist/core/resource-loader.js.map +1 -1
  159. package/dist/core/runtime-builder.d.ts +3 -0
  160. package/dist/core/runtime-builder.d.ts.map +1 -1
  161. package/dist/core/runtime-builder.js +49 -1
  162. package/dist/core/runtime-builder.js.map +1 -1
  163. package/dist/core/sdk.d.ts.map +1 -1
  164. package/dist/core/sdk.js +3 -0
  165. package/dist/core/sdk.js.map +1 -1
  166. package/dist/core/session-role.d.ts.map +1 -1
  167. package/dist/core/session-role.js +2 -0
  168. package/dist/core/session-role.js.map +1 -1
  169. package/dist/core/settings-manager.d.ts +12 -0
  170. package/dist/core/settings-manager.d.ts.map +1 -1
  171. package/dist/core/settings-manager.js +43 -9
  172. package/dist/core/settings-manager.js.map +1 -1
  173. package/dist/core/system-prompt-builder.js +1 -1
  174. package/dist/core/system-prompt-builder.js.map +1 -1
  175. package/dist/core/system-prompt.d.ts +1 -1
  176. package/dist/core/system-prompt.d.ts.map +1 -1
  177. package/dist/core/system-prompt.js +30 -22
  178. package/dist/core/system-prompt.js.map +1 -1
  179. package/dist/core/tasks/task-projection.d.ts +2 -0
  180. package/dist/core/tasks/task-projection.d.ts.map +1 -1
  181. package/dist/core/tasks/task-projection.js +1 -0
  182. package/dist/core/tasks/task-projection.js.map +1 -1
  183. package/dist/core/tasks/task-state.d.ts.map +1 -1
  184. package/dist/core/tasks/task-state.js +6 -1
  185. package/dist/core/tasks/task-state.js.map +1 -1
  186. package/dist/core/tools/bash.d.ts.map +1 -1
  187. package/dist/core/tools/bash.js +11 -3
  188. package/dist/core/tools/bash.js.map +1 -1
  189. package/dist/core/tools/delegate.d.ts.map +1 -1
  190. package/dist/core/tools/delegate.js +9 -3
  191. package/dist/core/tools/delegate.js.map +1 -1
  192. package/dist/core/tools/edit.d.ts.map +1 -1
  193. package/dist/core/tools/edit.js +47 -5
  194. package/dist/core/tools/edit.js.map +1 -1
  195. package/dist/core/tools/goal.d.ts +16 -1
  196. package/dist/core/tools/goal.d.ts.map +1 -1
  197. package/dist/core/tools/goal.js +14 -2
  198. package/dist/core/tools/goal.js.map +1 -1
  199. package/dist/core/tools/index.d.ts +1 -1
  200. package/dist/core/tools/index.d.ts.map +1 -1
  201. package/dist/core/tools/index.js +1 -1
  202. package/dist/core/tools/index.js.map +1 -1
  203. package/dist/core/tools/output-accumulator.d.ts +5 -0
  204. package/dist/core/tools/output-accumulator.d.ts.map +1 -1
  205. package/dist/core/tools/output-accumulator.js +33 -2
  206. package/dist/core/tools/output-accumulator.js.map +1 -1
  207. package/dist/core/tools/pipeline.d.ts +35 -0
  208. package/dist/core/tools/pipeline.d.ts.map +1 -0
  209. package/dist/core/tools/pipeline.js +203 -0
  210. package/dist/core/tools/pipeline.js.map +1 -0
  211. package/dist/core/tools/skill-audit.d.ts.map +1 -1
  212. package/dist/core/tools/skill-audit.js +2 -1
  213. package/dist/core/tools/skill-audit.js.map +1 -1
  214. package/dist/core/tools/skill.d.ts.map +1 -1
  215. package/dist/core/tools/skill.js +2 -1
  216. package/dist/core/tools/skill.js.map +1 -1
  217. package/dist/core/tools/skillify.d.ts.map +1 -1
  218. package/dist/core/tools/skillify.js +3 -1
  219. package/dist/core/tools/skillify.js.map +1 -1
  220. package/dist/core/tools/task-steps.d.ts +1 -1
  221. package/dist/core/tools/task-steps.d.ts.map +1 -1
  222. package/dist/core/tools/task-steps.js +9 -0
  223. package/dist/core/tools/task-steps.js.map +1 -1
  224. package/dist/core/tools/tool-task.d.ts.map +1 -1
  225. package/dist/core/tools/tool-task.js +5 -1
  226. package/dist/core/tools/tool-task.js.map +1 -1
  227. package/dist/core/tools/write.d.ts.map +1 -1
  228. package/dist/core/tools/write.js +1 -0
  229. package/dist/core/tools/write.js.map +1 -1
  230. package/dist/index.d.ts +1 -1
  231. package/dist/index.d.ts.map +1 -1
  232. package/dist/index.js +1 -1
  233. package/dist/index.js.map +1 -1
  234. package/dist/modes/interactive/components/settings-selector.d.ts +3 -0
  235. package/dist/modes/interactive/components/settings-selector.d.ts.map +1 -1
  236. package/dist/modes/interactive/components/settings-selector.js +66 -0
  237. package/dist/modes/interactive/components/settings-selector.js.map +1 -1
  238. package/dist/modes/interactive/components/skill-invocation-message.js +1 -1
  239. package/dist/modes/interactive/components/skill-invocation-message.js.map +1 -1
  240. package/dist/modes/interactive/components/tool-execution.d.ts +6 -1
  241. package/dist/modes/interactive/components/tool-execution.d.ts.map +1 -1
  242. package/dist/modes/interactive/components/tool-execution.js +20 -1
  243. package/dist/modes/interactive/components/tool-execution.js.map +1 -1
  244. package/dist/modes/interactive/components/tool-group.d.ts +4 -0
  245. package/dist/modes/interactive/components/tool-group.d.ts.map +1 -1
  246. package/dist/modes/interactive/components/tool-group.js +96 -7
  247. package/dist/modes/interactive/components/tool-group.js.map +1 -1
  248. package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
  249. package/dist/modes/interactive/interactive-mode.js +8 -10
  250. package/dist/modes/interactive/interactive-mode.js.map +1 -1
  251. package/dist/modes/interactive/key-handlers.d.ts +1 -0
  252. package/dist/modes/interactive/key-handlers.d.ts.map +1 -1
  253. package/dist/modes/interactive/key-handlers.js +2 -1
  254. package/dist/modes/interactive/key-handlers.js.map +1 -1
  255. package/dist/modes/interactive/settings-selector-flow.d.ts.map +1 -1
  256. package/dist/modes/interactive/settings-selector-flow.js +12 -0
  257. package/dist/modes/interactive/settings-selector-flow.js.map +1 -1
  258. package/docs/extensions.md +7 -5
  259. package/docs/harness-architecture.md +3 -4
  260. package/docs/keybindings.md +3 -2
  261. package/docs/quickstart.md +4 -4
  262. package/docs/sdk.md +3 -1
  263. package/docs/settings.md +16 -2
  264. package/docs/task-steps.md +1 -0
  265. package/docs/usage.md +6 -7
  266. package/docs/worker-profiles.md +1 -1
  267. package/docs/worktree-sync.md +1 -1
  268. package/examples/extensions/custom-provider-anthropic/package-lock.json +2 -2
  269. package/examples/extensions/custom-provider-anthropic/package.json +1 -1
  270. package/examples/extensions/custom-provider-gitlab-duo/package.json +1 -1
  271. package/examples/extensions/minimal-mode.ts +1 -1
  272. package/examples/extensions/sandbox/package-lock.json +2 -2
  273. package/examples/extensions/sandbox/package.json +1 -1
  274. package/examples/extensions/with-deps/package-lock.json +2 -2
  275. package/examples/extensions/with-deps/package.json +1 -1
  276. package/examples/sdk/07-context-files.ts +5 -2
  277. package/npm-shrinkwrap.json +12 -12
  278. package/package.json +4 -4
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/core/pipelines/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,oBAAoB,EACpB,oBAAoB,EACpB,2BAA2B,EAC3B,qBAAqB,GACrB,MAAM,cAAc,CAAC;AACtB,OAAO,EACN,2BAA2B,EAC3B,sBAAsB,EACtB,sBAAsB,EACtB,sBAAsB,EACtB,mBAAmB,GACnB,MAAM,eAAe,CAAC;AACvB,OAAO,EACN,kBAAkB,EAClB,gBAAgB,EAChB,mBAAmB,EACnB,oBAAoB,EACpB,sBAAsB,GAEtB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,kBAAkB,EAAE,yBAAyB,EAAE,MAAM,qBAAqB,CAAC;AACpF,OAAO,EACN,qBAAqB,EACrB,qBAAqB,EACrB,sBAAsB,EACtB,mBAAmB,EACnB,kBAAkB,EAClB,eAAe,EACf,eAAe,EACf,eAAe,EACf,cAAc,EACd,gBAAgB,GAChB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EACN,yBAAyB,EACzB,gCAAgC,EAChC,4BAA4B,GAC5B,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAEN,gBAAgB,EAEhB,aAAa,EACb,mBAAmB,EACnB,uBAAuB,EACvB,wBAAwB,EACxB,wBAAwB,GAOxB,MAAM,YAAY,CAAC","sourcesContent":["export {\n\tassembleStageContext,\n\tcurrentPipelineStage,\n\tformatActivePipelineContext,\n\tformatPipelineContext,\n} from \"./context.ts\";\nexport {\n\tdiscoverPipelineDefinitions,\n\tfindPipelineDefinition,\n\tloadPipelineDefinition,\n\tprojectPipelineRunsDir,\n\tprojectPipelinesDir,\n} from \"./discover.ts\";\nexport {\n\tabandonPipelineRun,\n\tadvanceTaskSteps,\n\tcurrentOpenTaskStep,\n\tincrementPipelineRun,\n\tPipelineIncrementError,\n\ttype PipelineIncrementJoin,\n} from \"./increment.ts\";\nexport { parseStageContract, parseWorkspaceFrontmatter } from \"./parse-contract.ts\";\nexport {\n\tcreatePipelineRunRoot,\n\tfindActivePipelineRun,\n\tinstantiatePipelineRun,\n\tloadPipelineRunById,\n\tpersistPipelineRun,\n\treadPipelineRun,\n\tscanPipelineRun,\n\tscanStageOutput,\n\tstageOutputDir,\n\twritePipelineRun,\n} from \"./run-state.ts\";\nexport {\n\tappendPipelineRunSnapshot,\n\tdecodePipelineRunSnapshotPayload,\n\tgetLatestPipelineRunSnapshot,\n} from \"./session-pipeline-run.ts\";\nexport {\n\ttype AssembledStageContext,\n\tclonePipelineRun,\n\ttype IncrementResult,\n\tisPipelineRun,\n\tisPipelineRunActive,\n\tPIPELINE_CONTEXT_MARKER,\n\tPIPELINE_RUN_CUSTOM_TYPE,\n\tPIPELINE_STAGE_FOLDER_RE,\n\ttype PipelineDefinition,\n\ttype PipelineForm,\n\ttype PipelineRun,\n\ttype PipelineStage,\n\ttype StageContract,\n\ttype StageScan,\n} from \"./types.ts\";\n"]}
@@ -0,0 +1,10 @@
1
+ import { type PipelineForm, type StageContract } from "./types.ts";
2
+ export interface ParsedWorkspaceContract {
3
+ name?: string;
4
+ description?: string;
5
+ form: PipelineForm;
6
+ body: string;
7
+ }
8
+ export declare function parseWorkspaceFrontmatter(content: string): ParsedWorkspaceContract;
9
+ export declare function parseStageContract(content: string): StageContract;
10
+ //# sourceMappingURL=parse-contract.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"parse-contract.d.ts","sourceRoot":"","sources":["../../../src/core/pipelines/parse-contract.ts"],"names":[],"mappings":"AAEA,OAAO,EAIN,KAAK,YAAY,EAEjB,KAAK,aAAa,EAClB,MAAM,YAAY,CAAC;AAWpB,MAAM,WAAW,uBAAuB;IACvC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,IAAI,EAAE,YAAY,CAAC;IACnB,IAAI,EAAE,MAAM,CAAC;CACb;AAkCD,wBAAgB,yBAAyB,CAAC,OAAO,EAAE,MAAM,GAAG,uBAAuB,CAWlF;AAED,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,MAAM,GAAG,aAAa,CA2CjE"}
@@ -0,0 +1,105 @@
1
+ import { parseFrontmatter } from "../../utils/frontmatter.js";
2
+ import { isPlainRecord } from "../util/value-guards.js";
3
+ import { MAX_CONTRACT_PROCESS_CHARS, MAX_HUMAN_CHECK_CHARS, MAX_PIPELINE_NAME_LENGTH, } from "./types.js";
4
+ const FORMS = [
5
+ "pipeline",
6
+ "umbrella",
7
+ "record-library",
8
+ "knowledge-bundle",
9
+ "context-map",
10
+ "system-map",
11
+ ];
12
+ function section(body, heading) {
13
+ const pattern = new RegExp(`^##\\s+${heading}\\s*$`, "im");
14
+ const start = body.search(pattern);
15
+ if (start === -1)
16
+ return "";
17
+ const after = body.slice(start).split("\n").slice(1);
18
+ const lines = [];
19
+ for (const line of after) {
20
+ if (/^##\s+/.test(line))
21
+ break;
22
+ lines.push(line);
23
+ }
24
+ return lines.join("\n").trim();
25
+ }
26
+ function listLines(text) {
27
+ const items = [];
28
+ for (const raw of text.split("\n")) {
29
+ const match = raw.match(/^\s*(?:[-*]|\d+\.)\s+(.+)$/);
30
+ if (match)
31
+ items.push(match[1].trim());
32
+ }
33
+ return items;
34
+ }
35
+ function classifyInput(line) {
36
+ const working = line.match(/^(?:Working(?:\s+\(this run\))?|4|Layer\s*4)\s*:\s*(.+)$/i);
37
+ if (working)
38
+ return { kind: "working", path: working[1].trim() };
39
+ const reference = line.match(/^(?:Reference(?:\s+\(every run\))?|3|Layer\s*3)\s*:\s*(.+)$/i);
40
+ if (reference)
41
+ return { kind: "reference", path: reference[1].trim() };
42
+ const numbered = line.match(/^([34])\s*:\s*(.+)$/);
43
+ if (numbered)
44
+ return { kind: numbered[1] === "3" ? "reference" : "working", path: numbered[2].trim() };
45
+ return undefined;
46
+ }
47
+ export function parseWorkspaceFrontmatter(content) {
48
+ const parsed = parseFrontmatter(content);
49
+ const fm = isPlainRecord(parsed.frontmatter) ? parsed.frontmatter : {};
50
+ const name = typeof fm.name === "string" ? fm.name.trim() : undefined;
51
+ const description = typeof fm.description === "string" ? fm.description.trim() : undefined;
52
+ const formRaw = typeof fm.form === "string" ? fm.form.trim() : "pipeline";
53
+ const form = FORMS.includes(formRaw) ? formRaw : "pipeline";
54
+ if (name && name.length > MAX_PIPELINE_NAME_LENGTH) {
55
+ throw new Error(`Pipeline name exceeds ${MAX_PIPELINE_NAME_LENGTH} characters.`);
56
+ }
57
+ return { name, description, form, body: parsed.body };
58
+ }
59
+ export function parseStageContract(content) {
60
+ const { body } = parseFrontmatter(content);
61
+ const titleLine = body.split("\n").find((line) => line.startsWith("# ")) ?? "";
62
+ const title = titleLine.replace(/^#\s+/, "").trim();
63
+ const oneJobMatch = body.match(/^One job:\s*(.+)$/im);
64
+ const inputsSection = section(body, "Inputs");
65
+ const processSection = section(body, "Process");
66
+ const outputsSection = section(body, "Outputs");
67
+ const humanSection = section(body, "Human check");
68
+ const doNot = [];
69
+ const inputs = [];
70
+ for (const raw of inputsSection.split("\n")) {
71
+ const trimmed = raw.trim();
72
+ if (!trimmed)
73
+ continue;
74
+ const doNotLine = trimmed.match(/^do not load:?\s*(.+)$/i);
75
+ if (doNotLine) {
76
+ doNot.push(doNotLine[1].trim());
77
+ continue;
78
+ }
79
+ const listed = trimmed.match(/^(?:[-*]|\d+\.)\s+(.+)$/);
80
+ const line = listed ? listed[1].trim() : trimmed;
81
+ if (/^do not load/i.test(line)) {
82
+ doNot.push(line.replace(/^do not load:?\s*/i, "").trim());
83
+ continue;
84
+ }
85
+ const input = classifyInput(line);
86
+ if (input)
87
+ inputs.push(input);
88
+ }
89
+ const process = listLines(processSection);
90
+ if (process.join("\n").length > MAX_CONTRACT_PROCESS_CHARS) {
91
+ throw new Error(`Stage process exceeds ${MAX_CONTRACT_PROCESS_CHARS} characters.`);
92
+ }
93
+ const outputs = listLines(outputsSection).map((line) => line.replace(/\s*→\s*output\/?\s*$/i, "").trim());
94
+ const humanCheck = humanSection.slice(0, MAX_HUMAN_CHECK_CHARS);
95
+ return {
96
+ title,
97
+ oneJob: (oneJobMatch?.[1] ?? "").trim(),
98
+ inputs,
99
+ doNotLoad: doNot,
100
+ process,
101
+ outputs,
102
+ humanCheck,
103
+ };
104
+ }
105
+ //# sourceMappingURL=parse-contract.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"parse-contract.js","sourceRoot":"","sources":["../../../src/core/pipelines/parse-contract.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AAC9D,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AACxD,OAAO,EACN,0BAA0B,EAC1B,qBAAqB,EACrB,wBAAwB,GAIxB,MAAM,YAAY,CAAC;AAEpB,MAAM,KAAK,GAA4B;IACtC,UAAU;IACV,UAAU;IACV,gBAAgB;IAChB,kBAAkB;IAClB,aAAa;IACb,YAAY;CACZ,CAAC;AASF,SAAS,OAAO,CAAC,IAAY,EAAE,OAAe;IAC7C,MAAM,OAAO,GAAG,IAAI,MAAM,CAAC,UAAU,OAAO,OAAO,EAAE,IAAI,CAAC,CAAC;IAC3D,MAAM,KAAK,GAAG,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;IACnC,IAAI,KAAK,KAAK,CAAC,CAAC;QAAE,OAAO,EAAE,CAAC;IAC5B,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IACrD,MAAM,KAAK,GAAa,EAAE,CAAC;IAC3B,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QAC1B,IAAI,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC;YAAE,MAAM;QAC/B,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAClB,CAAC;IACD,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,CAAC;AAChC,CAAC;AAED,SAAS,SAAS,CAAC,IAAY;IAC9B,MAAM,KAAK,GAAa,EAAE,CAAC;IAC3B,KAAK,MAAM,GAAG,IAAI,IAAI,CAAC,KAAK,CAA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AAO,GAAG,SAAS,CAAC,cAAc,CAAC,CAAC;IAC1C,IAAI,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,MAAM,GAAG,0BAA0B,EAAE,CAAC;QAC5D,MAAM,IAAI,KAAK,CAAC,yBAAyB,0BAA0B,cAAc,CAAC,CAAC;IACpF,CAAC;IACD,MAAM,OAAO,GAAG,SAAS,CAAC,cAAc,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC,uBAAuB,EAAE,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC;IAC1G,MAAM,UAAU,GAAG,YAAY,CAAC,KAAK,CAAC,CAAC,EAAE,qBAAqB,CAAC,CAAC;IAChE,OAAO;QACN,KAAK;QACL,MAAM,EAAE,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE;QACvC,MAAM;QACN,SAAS,EAAE,KAAK;QAChB,OAAO;QACP,OAAO;QACP,UAAU;KACV,CAAC;AACH,CAAC","sourcesContent":["import { parseFrontmatter } from \"../../utils/frontmatter.ts\";\nimport { isPlainRecord } from \"../util/value-guards.ts\";\nimport {\n\tMAX_CONTRACT_PROCESS_CHARS,\n\tMAX_HUMAN_CHECK_CHARS,\n\tMAX_PIPELINE_NAME_LENGTH,\n\ttype PipelineForm,\n\ttype PipelineInputRef,\n\ttype StageContract,\n} from \"./types.ts\";\n\nconst FORMS: readonly PipelineForm[] = [\n\t\"pipeline\",\n\t\"umbrella\",\n\t\"record-library\",\n\t\"knowledge-bundle\",\n\t\"context-map\",\n\t\"system-map\",\n];\n\nexport interface ParsedWorkspaceContract {\n\tname?: string;\n\tdescription?: string;\n\tform: PipelineForm;\n\tbody: string;\n}\n\nfunction section(body: string, heading: string): string {\n\tconst pattern = new RegExp(`^##\\\\s+${heading}\\\\s*$`, \"im\");\n\tconst start = body.search(pattern);\n\tif (start === -1) return \"\";\n\tconst after = body.slice(start).split(\"\\n\").slice(1);\n\tconst lines: string[] = [];\n\tfor (const line of after) {\n\t\tif (/^##\\s+/.test(line)) break;\n\t\tlines.push(line);\n\t}\n\treturn lines.join(\"\\n\").trim();\n}\n\nfunction listLines(text: string): string[] {\n\tconst items: string[] = [];\n\tfor (const raw of text.split(\"\\n\")) {\n\t\tconst match = raw.match(/^\\s*(?:[-*]|\\d+\\.)\\s+(.+)$/);\n\t\tif (match) items.push(match[1].trim());\n\t}\n\treturn items;\n}\n\nfunction classifyInput(line: string): PipelineInputRef | undefined {\n\tconst working = line.match(/^(?:Working(?:\\s+\\(this run\\))?|4|Layer\\s*4)\\s*:\\s*(.+)$/i);\n\tif (working) return { kind: \"working\", path: working[1].trim() };\n\tconst reference = line.match(/^(?:Reference(?:\\s+\\(every run\\))?|3|Layer\\s*3)\\s*:\\s*(.+)$/i);\n\tif (reference) return { kind: \"reference\", path: reference[1].trim() };\n\tconst numbered = line.match(/^([34])\\s*:\\s*(.+)$/);\n\tif (numbered) return { kind: numbered[1] === \"3\" ? \"reference\" : \"working\", path: numbered[2].trim() };\n\treturn undefined;\n}\n\nexport function parseWorkspaceFrontmatter(content: string): ParsedWorkspaceContract {\n\tconst parsed = parseFrontmatter<Record<string, unknown>>(content);\n\tconst fm = isPlainRecord(parsed.frontmatter) ? parsed.frontmatter : {};\n\tconst name = typeof fm.name === \"string\" ? fm.name.trim() : undefined;\n\tconst description = typeof fm.description === \"string\" ? fm.description.trim() : undefined;\n\tconst formRaw = typeof fm.form === \"string\" ? fm.form.trim() : \"pipeline\";\n\tconst form = FORMS.includes(formRaw as PipelineForm) ? (formRaw as PipelineForm) : \"pipeline\";\n\tif (name && name.length > MAX_PIPELINE_NAME_LENGTH) {\n\t\tthrow new Error(`Pipeline name exceeds ${MAX_PIPELINE_NAME_LENGTH} characters.`);\n\t}\n\treturn { name, description, form, body: parsed.body };\n}\n\nexport function parseStageContract(content: string): StageContract {\n\tconst { body } = parseFrontmatter(content);\n\tconst titleLine = body.split(\"\\n\").find((line) => line.startsWith(\"# \")) ?? \"\";\n\tconst title = titleLine.replace(/^#\\s+/, \"\").trim();\n\tconst oneJobMatch = body.match(/^One job:\\s*(.+)$/im);\n\tconst inputsSection = section(body, \"Inputs\");\n\tconst processSection = section(body, \"Process\");\n\tconst outputsSection = section(body, \"Outputs\");\n\tconst humanSection = section(body, \"Human check\");\n\tconst doNot: string[] = [];\n\tconst inputs: PipelineInputRef[] = [];\n\tfor (const raw of inputsSection.split(\"\\n\")) {\n\t\tconst trimmed = raw.trim();\n\t\tif (!trimmed) continue;\n\t\tconst doNotLine = trimmed.match(/^do not load:?\\s*(.+)$/i);\n\t\tif (doNotLine) {\n\t\t\tdoNot.push(doNotLine[1].trim());\n\t\t\tcontinue;\n\t\t}\n\t\tconst listed = trimmed.match(/^(?:[-*]|\\d+\\.)\\s+(.+)$/);\n\t\tconst line = listed ? listed[1].trim() : trimmed;\n\t\tif (/^do not load/i.test(line)) {\n\t\t\tdoNot.push(line.replace(/^do not load:?\\s*/i, \"\").trim());\n\t\t\tcontinue;\n\t\t}\n\t\tconst input = classifyInput(line);\n\t\tif (input) inputs.push(input);\n\t}\n\tconst process = listLines(processSection);\n\tif (process.join(\"\\n\").length > MAX_CONTRACT_PROCESS_CHARS) {\n\t\tthrow new Error(`Stage process exceeds ${MAX_CONTRACT_PROCESS_CHARS} characters.`);\n\t}\n\tconst outputs = listLines(outputsSection).map((line) => line.replace(/\\s*→\\s*output\\/?\\s*$/i, \"\").trim());\n\tconst humanCheck = humanSection.slice(0, MAX_HUMAN_CHECK_CHARS);\n\treturn {\n\t\ttitle,\n\t\toneJob: (oneJobMatch?.[1] ?? \"\").trim(),\n\t\tinputs,\n\t\tdoNotLoad: doNot,\n\t\tprocess,\n\t\toutputs,\n\t\thumanCheck,\n\t};\n}\n"]}
@@ -0,0 +1,26 @@
1
+ import { type PipelineDefinition, type PipelineRun, type PipelineStage, type StageDiskStatus, type StageScan } from "./types.ts";
2
+ export declare const RUN_MANIFEST_NAME = "run.json";
3
+ export declare function scanStageOutput(outputDir: string): {
4
+ status: StageDiskStatus;
5
+ outputFiles: string[];
6
+ };
7
+ export declare function stageOutputDir(runRoot: string, stage: PipelineStage): string;
8
+ export declare function scanPipelineRun(definition: PipelineDefinition, run: PipelineRun): readonly StageScan[];
9
+ export declare function runManifestPath(runRoot: string): string;
10
+ export declare function parsePipelineRun(value: unknown): PipelineRun | undefined;
11
+ export declare function readPipelineRun(runRoot: string): PipelineRun | undefined;
12
+ export declare function writePipelineRun(run: PipelineRun): void;
13
+ export declare function createPipelineRunRoot(cwd: string, runId: string): string;
14
+ export declare function instantiatePipelineRun(args: {
15
+ definition: PipelineDefinition;
16
+ runId: string;
17
+ runRoot: string;
18
+ goalId?: string;
19
+ now: string;
20
+ }): PipelineRun;
21
+ export declare function persistPipelineRun(run: PipelineRun, now: string): PipelineRun;
22
+ export declare function findActivePipelineRun(cwd: string): PipelineRun | undefined;
23
+ export declare function loadPipelineRunById(cwd: string, runId: string): PipelineRun | undefined;
24
+ export declare function decodePipelineRunPayload(data: unknown): PipelineRun | undefined;
25
+ export declare function pipelineRunParentDir(runRoot: string): string;
26
+ //# sourceMappingURL=run-state.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"run-state.d.ts","sourceRoot":"","sources":["../../../src/core/pipelines/run-state.ts"],"names":[],"mappings":"AAKA,OAAO,EAGN,KAAK,kBAAkB,EACvB,KAAK,WAAW,EAChB,KAAK,aAAa,EAClB,KAAK,eAAe,EACpB,KAAK,SAAS,EACd,MAAM,YAAY,CAAC;AAEpB,eAAO,MAAM,iBAAiB,aAAa,CAAC;AAM5C,wBAAgB,eAAe,CAAC,SAAS,EAAE,MAAM,GAAG;IAAE,MAAM,EAAE,eAAe,CAAC;IAAC,WAAW,EAAE,MAAM,EAAE,CAAA;CAAE,CAiBrG;AAED,wBAAgB,cAAc,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,aAAa,GAAG,MAAM,CAE5E;AAED,wBAAgB,eAAe,CAAC,UAAU,EAAE,kBAAkB,EAAE,GAAG,EAAE,WAAW,GAAG,SAAS,SAAS,EAAE,CAKtG;AAED,wBAAgB,eAAe,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAEvD;AAED,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,OAAO,GAAG,WAAW,GAAG,SAAS,CAGxE;AAED,wBAAgB,eAAe,CAAC,OAAO,EAAE,MAAM,GAAG,WAAW,GAAG,SAAS,CASxE;AAED,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,WAAW,GAAG,IAAI,CAGvD;AAED,wBAAgB,qBAAqB,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,CAExE;AAED,wBAAgB,sBAAsB,CAAC,IAAI,EAAE;IAC5C,UAAU,EAAE,kBAAkB,CAAC;IAC/B,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,GAAG,EAAE,MAAM,CAAC;CACZ,GAAG,WAAW,CAqBd;AAED,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,WAAW,EAAE,GAAG,EAAE,MAAM,GAAG,WAAW,CAI7E;AAED,wBAAgB,qBAAqB,CAAC,GAAG,EAAE,MAAM,GAAG,WAAW,GAAG,SAAS,CAc1E;AAED,wBAAgB,mBAAmB,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,WAAW,GAAG,SAAS,CAOvF;AAED,wBAAgB,wBAAwB,CAAC,IAAI,EAAE,OAAO,GAAG,WAAW,GAAG,SAAS,CAI/E;AAED,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAE5D"}
@@ -0,0 +1,135 @@
1
+ import { existsSync, mkdirSync, readdirSync, readFileSync, statSync } from "node:fs";
2
+ import { dirname, join } from "node:path";
3
+ import { writeFileAtomicSync } from "../util/atomic-file.js";
4
+ import { isPlainRecord } from "../util/value-guards.js";
5
+ import { projectPipelineRunsDir } from "./discover.js";
6
+ import { clonePipelineRun, isPipelineRun, } from "./types.js";
7
+ export const RUN_MANIFEST_NAME = "run.json";
8
+ function isRealOutputFile(name) {
9
+ return name !== ".gitkeep" && name !== ".DS_Store" && !name.startsWith(".");
10
+ }
11
+ export function scanStageOutput(outputDir) {
12
+ if (!existsSync(outputDir))
13
+ return { status: "empty", outputFiles: [] };
14
+ try {
15
+ const outputFiles = readdirSync(outputDir)
16
+ .filter((name) => {
17
+ if (!isRealOutputFile(name))
18
+ return false;
19
+ try {
20
+ return statSync(join(outputDir, name)).isFile();
21
+ }
22
+ catch {
23
+ return false;
24
+ }
25
+ })
26
+ .sort();
27
+ return { status: outputFiles.length > 0 ? "complete" : "empty", outputFiles };
28
+ }
29
+ catch {
30
+ return { status: "empty", outputFiles: [] };
31
+ }
32
+ }
33
+ export function stageOutputDir(runRoot, stage) {
34
+ return join(runRoot, stage.folderName, "output");
35
+ }
36
+ export function scanPipelineRun(definition, run) {
37
+ return definition.stages.map((stage) => {
38
+ const scanned = scanStageOutput(stageOutputDir(run.runRoot, stage));
39
+ return { stageId: stage.id, status: scanned.status, outputFiles: scanned.outputFiles };
40
+ });
41
+ }
42
+ export function runManifestPath(runRoot) {
43
+ return join(runRoot, RUN_MANIFEST_NAME);
44
+ }
45
+ export function parsePipelineRun(value) {
46
+ if (!isPipelineRun(value))
47
+ return undefined;
48
+ return clonePipelineRun(value);
49
+ }
50
+ export function readPipelineRun(runRoot) {
51
+ try {
52
+ const parsed = JSON.parse(readFileSync(runManifestPath(runRoot), "utf8"));
53
+ const run = parsePipelineRun(parsed);
54
+ if (!run || run.runRoot !== runRoot)
55
+ return undefined;
56
+ return run;
57
+ }
58
+ catch {
59
+ return undefined;
60
+ }
61
+ }
62
+ export function writePipelineRun(run) {
63
+ mkdirSync(run.runRoot, { recursive: true });
64
+ writeFileAtomicSync(runManifestPath(run.runRoot), `${JSON.stringify(run, null, 2)}\n`);
65
+ }
66
+ export function createPipelineRunRoot(cwd, runId) {
67
+ return join(projectPipelineRunsDir(cwd), runId);
68
+ }
69
+ export function instantiatePipelineRun(args) {
70
+ const first = args.definition.stages[0];
71
+ if (!first)
72
+ throw new Error("Pipeline definition has no stages.");
73
+ for (const stage of args.definition.stages) {
74
+ mkdirSync(stageOutputDir(args.runRoot, stage), { recursive: true });
75
+ }
76
+ const run = {
77
+ version: 1,
78
+ revision: 1,
79
+ runId: args.runId,
80
+ pipelineName: args.definition.name,
81
+ definitionPath: args.definition.rootDir,
82
+ runRoot: args.runRoot,
83
+ currentStageId: first.id,
84
+ status: "active",
85
+ goalId: args.goalId,
86
+ createdAt: args.now,
87
+ updatedAt: args.now,
88
+ };
89
+ writePipelineRun(run);
90
+ return run;
91
+ }
92
+ export function persistPipelineRun(run, now) {
93
+ const next = { ...run, revision: run.revision + 1, updatedAt: now };
94
+ writePipelineRun(next);
95
+ return next;
96
+ }
97
+ export function findActivePipelineRun(cwd) {
98
+ const root = projectPipelineRunsDir(cwd);
99
+ if (!existsSync(root))
100
+ return undefined;
101
+ let latest;
102
+ try {
103
+ for (const name of readdirSync(root)) {
104
+ const run = readPipelineRun(join(root, name));
105
+ if (!run || run.status !== "active")
106
+ continue;
107
+ if (!latest || run.updatedAt > latest.updatedAt)
108
+ latest = run;
109
+ }
110
+ }
111
+ catch {
112
+ return latest;
113
+ }
114
+ return latest;
115
+ }
116
+ export function loadPipelineRunById(cwd, runId) {
117
+ const trimmed = runId.trim();
118
+ if (!trimmed)
119
+ return undefined;
120
+ const fromDisk = readPipelineRun(join(projectPipelineRunsDir(cwd), trimmed));
121
+ if (fromDisk)
122
+ return fromDisk;
123
+ const active = findActivePipelineRun(cwd);
124
+ return active?.runId === trimmed ? active : undefined;
125
+ }
126
+ export function decodePipelineRunPayload(data) {
127
+ if (!isPlainRecord(data))
128
+ return undefined;
129
+ const value = data.run ?? data;
130
+ return parsePipelineRun(value);
131
+ }
132
+ export function pipelineRunParentDir(runRoot) {
133
+ return dirname(runRoot);
134
+ }
135
+ //# sourceMappingURL=run-state.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"run-state.js","sourceRoot":"","sources":["../../../src/core/pipelines/run-state.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,WAAW,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AACrF,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAC7D,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AACxD,OAAO,EAAE,sBAAsB,EAAE,MAAM,eAAe,CAAC;AACvD,OAAO,EACN,gBAAgB,EAChB,aAAa,GAMb,MAAM,YAAY,CAAC;AAEpB,MAAM,CAAC,MAAM,iBAAiB,GAAG,UAAU,CAAC;AAE5C,SAAS,gBAAgB,CAAC,IAAY;IACrC,OAAO,IAAI,KAAK,UAAU,IAAI,IAAI,KAAK,WAAW,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC;AAC7E,CAAC;AAED,MAAM,UAAU,eAAe,CAAC,SAAiB;IAChD,IAAI,CAAC,UAAU,CAAC,SAAS,CAAC;QAAE,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,WAAW,EAAE,EAAE,EAAE,CAAC;IACxE,IAAI,CAAC;QACJ,MAAM,WAAW,GAAG,WAAW,CAAC,SAAS,CAAC;aACxC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE;YAChB,IAAI,CAAC,gBAAgB,CAAC,IAAI,CAAC;gBAAE,OAAO,KAAK,CAAC;YAC1C,IAAI,CAAC;gBACJ,OAAO,QAAQ,CAAC,IAAI,CAAC,SAAS,EAAE,IAAI,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC;YACjD,CAAC;YAAC,MAAM,CAAC;gBACR,OAAO,KAAK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,MAAM,CAAC;AACf,CAAC;AAED,MAAM,UAAU,mBAAmB,CAAC,GAAW,EAAE,KAAa;IAC7D,MAAM,OAAO,GAAG,KAAK,CAAC,IAAI,EAAE,CAAC;IAC7B,IAAI,CAAC,OAAO;QAAE,OAAO,SAAS,CAAC;IAC/B,MAAM,QAAQ,GAAG,eAAe,CAAC,IAAI,CAAC,sBAAsB,CAAC,GAAG,CAAC,EAAE,OAAO,CAAC,CAAC,CAAC;IAC7E,IAAI,QAAQ;QAAE,OAAO,QAAQ,CAAC;IAC9B,MAAM,MAAM,GAAG,qBAAqB,CAAC,GAAG,CAAC,CAAC;IAC1C,OAAO,MAAM,EAAE,KAAK,KAAK,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS,CAAC;AACvD,CAAC;AAED,MAAM,UAAU,wBAAwB,CAAC,IAAa;IACrD,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC;QAAE,OAAO,SAAS,CAAC;IAC3C,MAAM,KAAK,GAAG,IAAI,CAAC,GAAG,IAAI,IAAI,CAAC;IAC/B,OAAO,gBAAgB,CAAC,KAAK,CAAC,CAAC;AAChC,CAAC;AAED,MAAM,UAAU,oBAAoB,CAAC,OAAe;IACnD,OAAO,OAAO,CAAC,OAAO,CAAC,CAAC;AACzB,CAAC","sourcesContent":["import { existsSync, mkdirSync, readdirSync, readFileSync, statSync } from \"node:fs\";\nimport { dirname, join } from \"node:path\";\nimport { writeFileAtomicSync } from \"../util/atomic-file.ts\";\nimport { isPlainRecord } from \"../util/value-guards.ts\";\nimport { projectPipelineRunsDir } from \"./discover.ts\";\nimport {\n\tclonePipelineRun,\n\tisPipelineRun,\n\ttype PipelineDefinition,\n\ttype PipelineRun,\n\ttype PipelineStage,\n\ttype StageDiskStatus,\n\ttype StageScan,\n} from \"./types.ts\";\n\nexport const RUN_MANIFEST_NAME = \"run.json\";\n\nfunction isRealOutputFile(name: string): boolean {\n\treturn name !== \".gitkeep\" && name !== \".DS_Store\" && !name.startsWith(\".\");\n}\n\nexport function scanStageOutput(outputDir: string): { status: StageDiskStatus; outputFiles: string[] } {\n\tif (!existsSync(outputDir)) return { status: \"empty\", outputFiles: [] };\n\ttry {\n\t\tconst outputFiles = readdirSync(outputDir)\n\t\t\t.filter((name) => {\n\t\t\t\tif (!isRealOutputFile(name)) return false;\n\t\t\t\ttry {\n\t\t\t\t\treturn statSync(join(outputDir, name)).isFile();\n\t\t\t\t} catch {\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t})\n\t\t\t.sort();\n\t\treturn { status: outputFiles.length > 0 ? \"complete\" : \"empty\", outputFiles };\n\t} catch {\n\t\treturn { status: \"empty\", outputFiles: [] };\n\t}\n}\n\nexport function stageOutputDir(runRoot: string, stage: PipelineStage): string {\n\treturn join(runRoot, stage.folderName, \"output\");\n}\n\nexport function scanPipelineRun(definition: PipelineDefinition, run: PipelineRun): readonly StageScan[] {\n\treturn definition.stages.map((stage) => {\n\t\tconst scanned = scanStageOutput(stageOutputDir(run.runRoot, stage));\n\t\treturn { stageId: stage.id, status: scanned.status, outputFiles: scanned.outputFiles };\n\t});\n}\n\nexport function runManifestPath(runRoot: string): string {\n\treturn join(runRoot, RUN_MANIFEST_NAME);\n}\n\nexport function parsePipelineRun(value: unknown): PipelineRun | undefined {\n\tif (!isPipelineRun(value)) return undefined;\n\treturn clonePipelineRun(value);\n}\n\nexport function readPipelineRun(runRoot: string): PipelineRun | undefined {\n\ttry {\n\t\tconst parsed: unknown = JSON.parse(readFileSync(runManifestPath(runRoot), \"utf8\"));\n\t\tconst run = parsePipelineRun(parsed);\n\t\tif (!run || run.runRoot !== runRoot) return undefined;\n\t\treturn run;\n\t} catch {\n\t\treturn undefined;\n\t}\n}\n\nexport function writePipelineRun(run: PipelineRun): void {\n\tmkdirSync(run.runRoot, { recursive: true });\n\twriteFileAtomicSync(runManifestPath(run.runRoot), `${JSON.stringify(run, null, 2)}\\n`);\n}\n\nexport function createPipelineRunRoot(cwd: string, runId: string): string {\n\treturn join(projectPipelineRunsDir(cwd), runId);\n}\n\nexport function instantiatePipelineRun(args: {\n\tdefinition: PipelineDefinition;\n\trunId: string;\n\trunRoot: string;\n\tgoalId?: string;\n\tnow: string;\n}): PipelineRun {\n\tconst first = args.definition.stages[0];\n\tif (!first) throw new Error(\"Pipeline definition has no stages.\");\n\tfor (const stage of args.definition.stages) {\n\t\tmkdirSync(stageOutputDir(args.runRoot, stage), { recursive: true });\n\t}\n\tconst run: PipelineRun = {\n\t\tversion: 1,\n\t\trevision: 1,\n\t\trunId: args.runId,\n\t\tpipelineName: args.definition.name,\n\t\tdefinitionPath: args.definition.rootDir,\n\t\trunRoot: args.runRoot,\n\t\tcurrentStageId: first.id,\n\t\tstatus: \"active\",\n\t\tgoalId: args.goalId,\n\t\tcreatedAt: args.now,\n\t\tupdatedAt: args.now,\n\t};\n\twritePipelineRun(run);\n\treturn run;\n}\n\nexport function persistPipelineRun(run: PipelineRun, now: string): PipelineRun {\n\tconst next = { ...run, revision: run.revision + 1, updatedAt: now };\n\twritePipelineRun(next);\n\treturn next;\n}\n\nexport function findActivePipelineRun(cwd: string): PipelineRun | undefined {\n\tconst root = projectPipelineRunsDir(cwd);\n\tif (!existsSync(root)) return undefined;\n\tlet latest: PipelineRun | undefined;\n\ttry {\n\t\tfor (const name of readdirSync(root)) {\n\t\t\tconst run = readPipelineRun(join(root, name));\n\t\t\tif (!run || run.status !== \"active\") continue;\n\t\t\tif (!latest || run.updatedAt > latest.updatedAt) latest = run;\n\t\t}\n\t} catch {\n\t\treturn latest;\n\t}\n\treturn latest;\n}\n\nexport function loadPipelineRunById(cwd: string, runId: string): PipelineRun | undefined {\n\tconst trimmed = runId.trim();\n\tif (!trimmed) return undefined;\n\tconst fromDisk = readPipelineRun(join(projectPipelineRunsDir(cwd), trimmed));\n\tif (fromDisk) return fromDisk;\n\tconst active = findActivePipelineRun(cwd);\n\treturn active?.runId === trimmed ? active : undefined;\n}\n\nexport function decodePipelineRunPayload(data: unknown): PipelineRun | undefined {\n\tif (!isPlainRecord(data)) return undefined;\n\tconst value = data.run ?? data;\n\treturn parsePipelineRun(value);\n}\n\nexport function pipelineRunParentDir(runRoot: string): string {\n\treturn dirname(runRoot);\n}\n"]}
@@ -0,0 +1,6 @@
1
+ import type { SessionManager } from "@caupulican/pi-agent-core/node";
2
+ import { type PipelineRun } from "./types.ts";
3
+ export declare function appendPipelineRunSnapshot(sessionManager: Pick<SessionManager, "appendCustomEntry">, run: PipelineRun): string;
4
+ export declare function decodePipelineRunSnapshotPayload(data: unknown): PipelineRun | undefined;
5
+ export declare function getLatestPipelineRunSnapshot(sessionManager: Pick<SessionManager, "getLatestCustomEntryOnBranch">): PipelineRun | undefined;
6
+ //# sourceMappingURL=session-pipeline-run.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"session-pipeline-run.d.ts","sourceRoot":"","sources":["../../../src/core/pipelines/session-pipeline-run.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAC;AAOrE,OAAO,EAA6D,KAAK,WAAW,EAAE,MAAM,YAAY,CAAC;AASzG,wBAAgB,yBAAyB,CACxC,cAAc,EAAE,IAAI,CAAC,cAAc,EAAE,mBAAmB,CAAC,EACzD,GAAG,EAAE,WAAW,GACd,MAAM,CAER;AAED,wBAAgB,gCAAgC,CAAC,IAAI,EAAE,OAAO,GAAG,WAAW,GAAG,SAAS,CAEvF;AAED,wBAAgB,4BAA4B,CAC3C,cAAc,EAAE,IAAI,CAAC,cAAc,EAAE,8BAA8B,CAAC,GAClE,WAAW,GAAG,SAAS,CAEzB"}
@@ -0,0 +1,18 @@
1
+ import { appendSessionSnapshot, decodeSessionSnapshotPayload, getLatestSessionSnapshotOnBranch, } from "../session-snapshot.js";
2
+ import { clonePipelineRun, isPipelineRun, PIPELINE_RUN_CUSTOM_TYPE } from "./types.js";
3
+ const PIPELINE_RUN_SNAPSHOT_CODEC = {
4
+ customType: PIPELINE_RUN_CUSTOM_TYPE,
5
+ valueKey: "run",
6
+ isValue: isPipelineRun,
7
+ clone: clonePipelineRun,
8
+ };
9
+ export function appendPipelineRunSnapshot(sessionManager, run) {
10
+ return appendSessionSnapshot(sessionManager, PIPELINE_RUN_SNAPSHOT_CODEC, run);
11
+ }
12
+ export function decodePipelineRunSnapshotPayload(data) {
13
+ return decodeSessionSnapshotPayload(data, PIPELINE_RUN_SNAPSHOT_CODEC);
14
+ }
15
+ export function getLatestPipelineRunSnapshot(sessionManager) {
16
+ return getLatestSessionSnapshotOnBranch(sessionManager, PIPELINE_RUN_SNAPSHOT_CODEC);
17
+ }
18
+ //# sourceMappingURL=session-pipeline-run.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"session-pipeline-run.js","sourceRoot":"","sources":["../../../src/core/pipelines/session-pipeline-run.ts"],"names":[],"mappings":"AACA,OAAO,EACN,qBAAqB,EACrB,4BAA4B,EAC5B,gCAAgC,GAEhC,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,gBAAgB,EAAE,aAAa,EAAE,wBAAwB,EAAoB,MAAM,YAAY,CAAC;AAEzG,MAAM,2BAA2B,GAA6C;IAC7E,UAAU,EAAE,wBAAwB;IACpC,QAAQ,EAAE,KAAK;IACf,OAAO,EAAE,aAAa;IACtB,KAAK,EAAE,gBAAgB;CACvB,CAAC;AAEF,MAAM,UAAU,yBAAyB,CACxC,cAAyD,EACzD,GAAgB;IAEhB,OAAO,qBAAqB,CAAC,cAAc,EAAE,2BAA2B,EAAE,GAAG,CAAC,CAAC;AAChF,CAAC;AAED,MAAM,UAAU,gCAAgC,CAAC,IAAa;IAC7D,OAAO,4BAA4B,CAAC,IAAI,EAAE,2BAA2B,CAAC,CAAC;AACxE,CAAC;AAED,MAAM,UAAU,4BAA4B,CAC3C,cAAoE;IAEpE,OAAO,gCAAgC,CAAC,cAAc,EAAE,2BAA2B,CAAC,CAAC;AACtF,CAAC","sourcesContent":["import type { SessionManager } from \"@caupulican/pi-agent-core/node\";\nimport {\n\tappendSessionSnapshot,\n\tdecodeSessionSnapshotPayload,\n\tgetLatestSessionSnapshotOnBranch,\n\ttype SessionSnapshotCodec,\n} from \"../session-snapshot.ts\";\nimport { clonePipelineRun, isPipelineRun, PIPELINE_RUN_CUSTOM_TYPE, type PipelineRun } from \"./types.ts\";\n\nconst PIPELINE_RUN_SNAPSHOT_CODEC: SessionSnapshotCodec<PipelineRun, \"run\"> = {\n\tcustomType: PIPELINE_RUN_CUSTOM_TYPE,\n\tvalueKey: \"run\",\n\tisValue: isPipelineRun,\n\tclone: clonePipelineRun,\n};\n\nexport function appendPipelineRunSnapshot(\n\tsessionManager: Pick<SessionManager, \"appendCustomEntry\">,\n\trun: PipelineRun,\n): string {\n\treturn appendSessionSnapshot(sessionManager, PIPELINE_RUN_SNAPSHOT_CODEC, run);\n}\n\nexport function decodePipelineRunSnapshotPayload(data: unknown): PipelineRun | undefined {\n\treturn decodeSessionSnapshotPayload(data, PIPELINE_RUN_SNAPSHOT_CODEC);\n}\n\nexport function getLatestPipelineRunSnapshot(\n\tsessionManager: Pick<SessionManager, \"getLatestCustomEntryOnBranch\">,\n): PipelineRun | undefined {\n\treturn getLatestSessionSnapshotOnBranch(sessionManager, PIPELINE_RUN_SNAPSHOT_CODEC);\n}\n"]}
@@ -0,0 +1,91 @@
1
+ /** ICM pipeline form: numbered stages, factory vs product, status from files. */
2
+ export declare const PIPELINE_STAGE_FOLDER_RE: RegExp;
3
+ export declare const MAX_PIPELINE_STAGES = 32;
4
+ export declare const MAX_PIPELINE_NAME_LENGTH = 64;
5
+ export declare const MAX_CONTRACT_PROCESS_CHARS = 4000;
6
+ export declare const MAX_HUMAN_CHECK_CHARS = 1000;
7
+ export declare const MAX_STAGE_CONTEXT_CHARS = 8000;
8
+ export declare const MAX_LAYER_FILE_CHARS = 4000;
9
+ export type PipelineForm = "pipeline" | "umbrella" | "record-library" | "knowledge-bundle" | "context-map" | "system-map";
10
+ export type ContextLayer = 0 | 1 | 2 | 3 | 4;
11
+ export type InputKind = "working" | "reference";
12
+ export interface PipelineInputRef {
13
+ kind: InputKind;
14
+ path: string;
15
+ }
16
+ export interface StageContract {
17
+ title: string;
18
+ oneJob: string;
19
+ inputs: readonly PipelineInputRef[];
20
+ doNotLoad: readonly string[];
21
+ process: readonly string[];
22
+ outputs: readonly string[];
23
+ humanCheck: string;
24
+ }
25
+ export interface PipelineStage {
26
+ id: string;
27
+ ordinal: number;
28
+ slug: string;
29
+ folderName: string;
30
+ contractPath: string;
31
+ outputDir: string;
32
+ contract: StageContract;
33
+ }
34
+ export type StageDiskStatus = "empty" | "complete";
35
+ export interface PipelineDefinition {
36
+ name: string;
37
+ description: string;
38
+ form: PipelineForm;
39
+ rootDir: string;
40
+ entryFile: string;
41
+ routingPath: string;
42
+ factoryDir: string;
43
+ stagesDir: string;
44
+ stages: readonly PipelineStage[];
45
+ }
46
+ export type PipelineRunStatus = "active" | "completed" | "abandoned";
47
+ export interface PipelineRun {
48
+ version: 1;
49
+ revision: number;
50
+ runId: string;
51
+ pipelineName: string;
52
+ definitionPath: string;
53
+ runRoot: string;
54
+ currentStageId: string;
55
+ status: PipelineRunStatus;
56
+ goalId?: string;
57
+ createdAt: string;
58
+ updatedAt: string;
59
+ }
60
+ export interface StageScan {
61
+ stageId: string;
62
+ status: StageDiskStatus;
63
+ outputFiles: readonly string[];
64
+ }
65
+ export interface IncrementResult {
66
+ surface: "pipeline" | "task_steps" | "goal";
67
+ from?: string;
68
+ to?: string;
69
+ completed: boolean;
70
+ detail: string;
71
+ }
72
+ export interface AssembledLayer {
73
+ layer: ContextLayer;
74
+ path: string;
75
+ label: string;
76
+ text: string;
77
+ truncated: boolean;
78
+ }
79
+ export interface AssembledStageContext {
80
+ stageId: string;
81
+ layers: readonly AssembledLayer[];
82
+ text: string;
83
+ tokenEstimate: number;
84
+ }
85
+ export declare const PIPELINE_RUN_CUSTOM_TYPE = "pipeline_run";
86
+ export declare const PIPELINE_CONTEXT_MARKER = "<pipeline_context";
87
+ export declare function isPipelineForm(value: unknown): value is PipelineForm;
88
+ export declare function isPipelineRun(value: unknown): value is PipelineRun;
89
+ export declare function clonePipelineRun(run: PipelineRun): PipelineRun;
90
+ export declare function isPipelineRunActive(run: Pick<PipelineRun, "status">): boolean;
91
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/core/pipelines/types.ts"],"names":[],"mappings":"AAAA,iFAAiF;AAEjF,eAAO,MAAM,wBAAwB,QAAwC,CAAC;AAC9E,eAAO,MAAM,mBAAmB,KAAK,CAAC;AACtC,eAAO,MAAM,wBAAwB,KAAK,CAAC;AAC3C,eAAO,MAAM,0BAA0B,OAAQ,CAAC;AAChD,eAAO,MAAM,qBAAqB,OAAQ,CAAC;AAC3C,eAAO,MAAM,uBAAuB,OAAQ,CAAC;AAC7C,eAAO,MAAM,oBAAoB,OAAQ,CAAC;AAE1C,MAAM,MAAM,YAAY,GACrB,UAAU,GACV,UAAU,GACV,gBAAgB,GAChB,kBAAkB,GAClB,aAAa,GACb,YAAY,CAAC;AAEhB,MAAM,MAAM,YAAY,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;AAE7C,MAAM,MAAM,SAAS,GAAG,SAAS,GAAG,WAAW,CAAC;AAEhD,MAAM,WAAW,gBAAgB;IAChC,IAAI,EAAE,SAAS,CAAC;IAChB,IAAI,EAAE,MAAM,CAAC;CACb;AAED,MAAM,WAAW,aAAa;IAC7B,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,SAAS,gBAAgB,EAAE,CAAC;IACpC,SAAS,EAAE,SAAS,MAAM,EAAE,CAAC;IAC7B,OAAO,EAAE,SAAS,MAAM,EAAE,CAAC;IAC3B,OAAO,EAAE,SAAS,MAAM,EAAE,CAAC;IAC3B,UAAU,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,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G,MAAM,CAAC;IAC5C,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,SAAS,EAAE,OAAO,CAAC;IACnB,MAAM,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,cAAc;IAC9B,KAAK,EAAE,YAAY,CAAC;IACpB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,OAAO,CAAC;CACnB;AAED,MAAM,WAAW,qBAAqB;IACrC,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,SAAS,cAAc,EAAE,CAAC;IAClC,IAAI,EAAE,MAAM,CAAC;IACb,aAAa,EAAE,MAAM,CAAC;CACtB;AAED,eAAO,MAAM,wBAAwB,iBAAiB,CAAC;AACvD,eAAO,MAAM,uBAAuB,sBAAsB,CAAC;AAE3D,wBAAgB,cAAc,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,YAAY,CASpE;AAED,wBAAgB,aAAa,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,WAAW,CAmBlE;AAED,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,WAAW,GAAG,WAAW,CAE9D;AAED,wBAAgB,mBAAmB,CAAC,GAAG,EAAE,IAAI,CAAC,WAAW,EAAE,QAAQ,CAAC,GAAG,OAAO,CAE7E"}
@@ -0,0 +1,44 @@
1
+ /** ICM pipeline form: numbered stages, factory vs product, status from files. */
2
+ export const PIPELINE_STAGE_FOLDER_RE = /^(\d{2})_([a-z0-9][a-z0-9-]{0,62})$/;
3
+ export const MAX_PIPELINE_STAGES = 32;
4
+ export const MAX_PIPELINE_NAME_LENGTH = 64;
5
+ export const MAX_CONTRACT_PROCESS_CHARS = 4_000;
6
+ export const MAX_HUMAN_CHECK_CHARS = 1_000;
7
+ export const MAX_STAGE_CONTEXT_CHARS = 8_000;
8
+ export const MAX_LAYER_FILE_CHARS = 4_000;
9
+ export const PIPELINE_RUN_CUSTOM_TYPE = "pipeline_run";
10
+ export const PIPELINE_CONTEXT_MARKER = "<pipeline_context";
11
+ export function isPipelineForm(value) {
12
+ return (value === "pipeline" ||
13
+ value === "umbrella" ||
14
+ value === "record-library" ||
15
+ value === "knowledge-bundle" ||
16
+ value === "context-map" ||
17
+ value === "system-map");
18
+ }
19
+ export function isPipelineRun(value) {
20
+ if (typeof value !== "object" || value === null)
21
+ return false;
22
+ const record = value;
23
+ return (record.version === 1 &&
24
+ typeof record.revision === "number" &&
25
+ Number.isInteger(record.revision) &&
26
+ record.revision >= 0 &&
27
+ typeof record.runId === "string" &&
28
+ record.runId.length > 0 &&
29
+ typeof record.pipelineName === "string" &&
30
+ typeof record.definitionPath === "string" &&
31
+ typeof record.runRoot === "string" &&
32
+ typeof record.currentStageId === "string" &&
33
+ (record.status === "active" || record.status === "completed" || record.status === "abandoned") &&
34
+ typeof record.createdAt === "string" &&
35
+ typeof record.updatedAt === "string" &&
36
+ (record.goalId === undefined || typeof record.goalId === "string"));
37
+ }
38
+ export function clonePipelineRun(run) {
39
+ return { ...run };
40
+ }
41
+ export function isPipelineRunActive(run) {
42
+ return run.status === "active";
43
+ }
44
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/core/pipelines/types.ts"],"names":[],"mappings":"AAAA,iFAAiF;AAEjF,MAAM,CAAC,MAAM,wBAAwB,GAAG,qCAAqC,CAAC;AAC9E,MAAM,CAAC,MAAM,mBAAmB,GAAG,EAAE,CAAC;AACtC,MAAM,CAAC,MAAM,wBAAwB,GAAG,EAAE,CAAC;AAC3C,MAAM,CAAC,MAAM,0BAA0B,GAAG,KAAK,CAAC;AAChD,MAAM,CAAC,MAAM,qBAAqB,GAAG,KAAK,CAAC;AAC3C,MAAM,CAAC,MAAM,uBAAuB,GAAG,KAAK,CAAC;AAC7C,MAAM,CAAC,MAAM,oBAAoB,GAA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M,KAAK,QAAQ,CAAC,CAClE,CAAC;AACH,CAAC;AAED,MAAM,UAAU,gBAAgB,CAAC,GAAgB;IAChD,OAAO,EAAE,GAAG,GAAG,EAAE,CAAC;AACnB,CAAC;AAED,MAAM,UAAU,mBAAmB,CAAC,GAAgC;IACnE,OAAO,GAAG,CAAC,MAAM,KAAK,QAAQ,CAAC;AAChC,CAAC","sourcesContent":["/** ICM pipeline form: numbered stages, factory vs product, status from files. */\n\nexport const PIPELINE_STAGE_FOLDER_RE = /^(\\d{2})_([a-z0-9][a-z0-9-]{0,62})$/;\nexport const MAX_PIPELINE_STAGES = 32;\nexport const MAX_PIPELINE_NAME_LENGTH = 64;\nexport const MAX_CONTRACT_PROCESS_CHARS = 4_000;\nexport const MAX_HUMAN_CHECK_CHARS = 1_000;\nexport const MAX_STAGE_CONTEXT_CHARS = 8_000;\nexport const MAX_LAYER_FILE_CHARS = 4_000;\n\nexport type PipelineForm =\n\t| \"pipeline\"\n\t| \"umbrella\"\n\t| \"record-library\"\n\t| \"knowledge-bundle\"\n\t| \"context-map\"\n\t| \"system-map\";\n\nexport type ContextLayer = 0 | 1 | 2 | 3 | 4;\n\nexport type InputKind = \"working\" | \"reference\";\n\nexport interface PipelineInputRef {\n\tkind: InputKind;\n\tpath: string;\n}\n\nexport interface StageContract {\n\ttitle: string;\n\toneJob: string;\n\tinputs: readonly PipelineInputRef[];\n\tdoNotLoad: readonly string[];\n\tprocess: readonly string[];\n\toutputs: readonly string[];\n\thumanCheck: string;\n}\n\nexport interface PipelineStage {\n\tid: string;\n\tordinal: number;\n\tslug: string;\n\tfolderName: string;\n\tcontractPath: string;\n\toutputDir: string;\n\tcontract: StageContract;\n}\n\nexport type StageDiskStatus = \"empty\" | \"complete\";\n\nexport interface PipelineDefinition {\n\tname: string;\n\tdescription: string;\n\tform: PipelineForm;\n\trootDir: string;\n\tentryFile: string;\n\troutingPath: string;\n\tfactoryDir: string;\n\tstagesDir: string;\n\tstages: readonly PipelineStage[];\n}\n\nexport type PipelineRunStatus = \"active\" | \"completed\" | \"abandoned\";\n\nexport interface PipelineRun {\n\tversion: 1;\n\trevision: number;\n\trunId: string;\n\tpipelineName: string;\n\tdefinitionPath: string;\n\trunRoot: string;\n\tcurrentStageId: string;\n\tstatus: PipelineRunStatus;\n\tgoalId?: string;\n\tcreatedAt: string;\n\tupdatedAt: string;\n}\n\nexport interface StageScan {\n\tstageId: string;\n\tstatus: StageDiskStatus;\n\toutputFiles: readonly string[];\n}\n\nexport interface IncrementResult {\n\tsurface: \"pipeline\" | \"task_steps\" | \"goal\";\n\tfrom?: string;\n\tto?: string;\n\tcompleted: boolean;\n\tdetail: string;\n}\n\nexport interface AssembledLayer {\n\tlayer: ContextLayer;\n\tpath: string;\n\tlabel: string;\n\ttext: string;\n\ttruncated: boolean;\n}\n\nexport interface AssembledStageContext {\n\tstageId: string;\n\tlayers: readonly AssembledLayer[];\n\ttext: string;\n\ttokenEstimate: number;\n}\n\nexport const PIPELINE_RUN_CUSTOM_TYPE = \"pipeline_run\";\nexport const PIPELINE_CONTEXT_MARKER = \"<pipeline_context\";\n\nexport function isPipelineForm(value: unknown): value is PipelineForm {\n\treturn (\n\t\tvalue === \"pipeline\" ||\n\t\tvalue === \"umbrella\" ||\n\t\tvalue === \"record-library\" ||\n\t\tvalue === \"knowledge-bundle\" ||\n\t\tvalue === \"context-map\" ||\n\t\tvalue === \"system-map\"\n\t);\n}\n\nexport function isPipelineRun(value: unknown): value is PipelineRun {\n\tif (typeof value !== \"object\" || value === null) return false;\n\tconst record = value as Record<string, unknown>;\n\treturn (\n\t\trecord.version === 1 &&\n\t\ttypeof record.revision === \"number\" &&\n\t\tNumber.isInteger(record.revision) &&\n\t\trecord.revision >= 0 &&\n\t\ttypeof record.runId === \"string\" &&\n\t\trecord.runId.length > 0 &&\n\t\ttypeof record.pipelineName === \"string\" &&\n\t\ttypeof record.definitionPath === \"string\" &&\n\t\ttypeof record.runRoot === \"string\" &&\n\t\ttypeof record.currentStageId === \"string\" &&\n\t\t(record.status === \"active\" || record.status === \"completed\" || record.status === \"abandoned\") &&\n\t\ttypeof record.createdAt === \"string\" &&\n\t\ttypeof record.updatedAt === \"string\" &&\n\t\t(record.goalId === undefined || typeof record.goalId === \"string\")\n\t);\n}\n\nexport function clonePipelineRun(run: PipelineRun): PipelineRun {\n\treturn { ...run };\n}\n\nexport function isPipelineRunActive(run: Pick<PipelineRun, \"status\">): boolean {\n\treturn run.status === \"active\";\n}\n"]}
@@ -47,6 +47,8 @@ export interface ReflectionControllerDeps {
47
47
  getReflectionSignal(): AbortSignal;
48
48
  /** Archive a promoted skill (rollback of a `promote_skill` write). */
49
49
  archivePromotedSkill(name: string): boolean;
50
+ /** Make a just-written or archived skill visible to this session's skill vault. */
51
+ refreshLiveSkills?(): void;
50
52
  /** G3/G8 autonomy telemetry sink for learning-gate outcomes and approval requests. */
51
53
  emitAutonomyTelemetry(event: AutonomyTelemetryEvent): void;
52
54
  /** Account the reflection pass's token spend into the cost roll-up (idempotent on reportId). */
@@ -1 +1 @@
1
- {"version":3,"file":"reflection-controller.d.ts","sourceRoot":"","sources":["../../src/core/reflection-controller.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAKH,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,iCAAiC,CAAC;AAE7D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,mCAAmC,CAAC;AACxE,OAAO,KAAK,EAAiC,YAAY,EAAE,aAAa,EAAE,MAAM,iCAAiC,CAAC;AAElH,OAAO,KAAK,EACX,GAAG,EAGH,KAAK,EACL,mBAAmB,EAEnB,KAAK,EACL,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAGN,KAAK,yBAAyB,EAC9B,KAAK,wBAAwB,EAC7B,MAAM,8BAA8B,CAAC;AACtC,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAChE,OAAO,EAAkC,KAAK,sBAAsB,EAAE,MAAM,gCAAgC,CAAC;AAC7G,OA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