@caupulican/pi-adaptative 0.90.11 → 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 (291) hide show
  1. package/CHANGELOG.md +46 -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 +44 -11
  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/extension-session-scope.d.ts +17 -0
  69. package/dist/core/extensions/extension-session-scope.d.ts.map +1 -0
  70. package/dist/core/extensions/extension-session-scope.js +135 -0
  71. package/dist/core/extensions/extension-session-scope.js.map +1 -0
  72. package/dist/core/extensions/index.d.ts +1 -0
  73. package/dist/core/extensions/index.d.ts.map +1 -1
  74. package/dist/core/extensions/index.js +1 -0
  75. package/dist/core/extensions/index.js.map +1 -1
  76. package/dist/core/extensions/runner.d.ts.map +1 -1
  77. package/dist/core/extensions/runner.js +1 -0
  78. package/dist/core/extensions/runner.js.map +1 -1
  79. package/dist/core/extensions/wrapper.d.ts +2 -1
  80. package/dist/core/extensions/wrapper.d.ts.map +1 -1
  81. package/dist/core/extensions/wrapper.js +10 -4
  82. package/dist/core/extensions/wrapper.js.map +1 -1
  83. package/dist/core/foreground-terminal-handoff-controller.d.ts +0 -1
  84. package/dist/core/foreground-terminal-handoff-controller.d.ts.map +1 -1
  85. package/dist/core/foreground-terminal-handoff-controller.js +1 -2
  86. package/dist/core/foreground-terminal-handoff-controller.js.map +1 -1
  87. package/dist/core/goals/goal-continuation-controller.d.ts +7 -1
  88. package/dist/core/goals/goal-continuation-controller.d.ts.map +1 -1
  89. package/dist/core/goals/goal-continuation-controller.js +16 -0
  90. package/dist/core/goals/goal-continuation-controller.js.map +1 -1
  91. package/dist/core/goals/goal-runtime-snapshot.d.ts +3 -0
  92. package/dist/core/goals/goal-runtime-snapshot.d.ts.map +1 -1
  93. package/dist/core/goals/goal-runtime-snapshot.js +8 -1
  94. package/dist/core/goals/goal-runtime-snapshot.js.map +1 -1
  95. package/dist/core/goals/goal-session-controller.d.ts +2 -0
  96. package/dist/core/goals/goal-session-controller.d.ts.map +1 -1
  97. package/dist/core/goals/goal-session-controller.js +1 -0
  98. package/dist/core/goals/goal-session-controller.js.map +1 -1
  99. package/dist/core/goals/goal-tool-core.d.ts +18 -0
  100. package/dist/core/goals/goal-tool-core.d.ts.map +1 -1
  101. package/dist/core/goals/goal-tool-core.js +62 -0
  102. package/dist/core/goals/goal-tool-core.js.map +1 -1
  103. package/dist/core/goals/natural-language-goal.d.ts.map +1 -1
  104. package/dist/core/goals/natural-language-goal.js +4 -2
  105. package/dist/core/goals/natural-language-goal.js.map +1 -1
  106. package/dist/core/human-input-controller.d.ts +3 -34
  107. package/dist/core/human-input-controller.d.ts.map +1 -1
  108. package/dist/core/human-input-controller.js +3 -161
  109. package/dist/core/human-input-controller.js.map +1 -1
  110. package/dist/core/keybindings.d.ts +5 -0
  111. package/dist/core/keybindings.d.ts.map +1 -1
  112. package/dist/core/keybindings.js +2 -0
  113. package/dist/core/keybindings.js.map +1 -1
  114. package/dist/core/learning/reflection-turn-analysis.d.ts.map +1 -1
  115. package/dist/core/learning/reflection-turn-analysis.js +10 -1
  116. package/dist/core/learning/reflection-turn-analysis.js.map +1 -1
  117. package/dist/core/memory/providers/file-store.d.ts.map +1 -1
  118. package/dist/core/memory/providers/file-store.js +4 -0
  119. package/dist/core/memory/providers/file-store.js.map +1 -1
  120. package/dist/core/memory-controller.d.ts +3 -0
  121. package/dist/core/memory-controller.d.ts.map +1 -1
  122. package/dist/core/memory-controller.js +18 -0
  123. package/dist/core/memory-controller.js.map +1 -1
  124. package/dist/core/model-capability.d.ts.map +1 -1
  125. package/dist/core/model-capability.js +1 -0
  126. package/dist/core/model-capability.js.map +1 -1
  127. package/dist/core/orchestration/work-state-projection.d.ts +4 -0
  128. package/dist/core/orchestration/work-state-projection.d.ts.map +1 -1
  129. package/dist/core/orchestration/work-state-projection.js +11 -0
  130. package/dist/core/orchestration/work-state-projection.js.map +1 -1
  131. package/dist/core/pipelines/context.d.ts +6 -0
  132. package/dist/core/pipelines/context.d.ts.map +1 -0
  133. package/dist/core/pipelines/context.js +102 -0
  134. package/dist/core/pipelines/context.js.map +1 -0
  135. package/dist/core/pipelines/discover.d.ts +11 -0
  136. package/dist/core/pipelines/discover.d.ts.map +1 -0
  137. package/dist/core/pipelines/discover.js +147 -0
  138. package/dist/core/pipelines/discover.js.map +1 -0
  139. package/dist/core/pipelines/increment.d.ts +24 -0
  140. package/dist/core/pipelines/increment.d.ts.map +1 -0
  141. package/dist/core/pipelines/increment.js +121 -0
  142. package/dist/core/pipelines/increment.js.map +1 -0
  143. package/dist/core/pipelines/index.d.ts +8 -0
  144. package/dist/core/pipelines/index.d.ts.map +1 -0
  145. package/dist/core/pipelines/index.js +8 -0
  146. package/dist/core/pipelines/index.js.map +1 -0
  147. package/dist/core/pipelines/parse-contract.d.ts +10 -0
  148. package/dist/core/pipelines/parse-contract.d.ts.map +1 -0
  149. package/dist/core/pipelines/parse-contract.js +105 -0
  150. package/dist/core/pipelines/parse-contract.js.map +1 -0
  151. package/dist/core/pipelines/run-state.d.ts +26 -0
  152. package/dist/core/pipelines/run-state.d.ts.map +1 -0
  153. package/dist/core/pipelines/run-state.js +135 -0
  154. package/dist/core/pipelines/run-state.js.map +1 -0
  155. package/dist/core/pipelines/session-pipeline-run.d.ts +6 -0
  156. package/dist/core/pipelines/session-pipeline-run.d.ts.map +1 -0
  157. package/dist/core/pipelines/session-pipeline-run.js +18 -0
  158. package/dist/core/pipelines/session-pipeline-run.js.map +1 -0
  159. package/dist/core/pipelines/types.d.ts +91 -0
  160. package/dist/core/pipelines/types.d.ts.map +1 -0
  161. package/dist/core/pipelines/types.js +44 -0
  162. package/dist/core/pipelines/types.js.map +1 -0
  163. package/dist/core/reflection-controller.d.ts +2 -0
  164. package/dist/core/reflection-controller.d.ts.map +1 -1
  165. package/dist/core/reflection-controller.js +53 -30
  166. package/dist/core/reflection-controller.js.map +1 -1
  167. package/dist/core/resource-loader.d.ts +21 -0
  168. package/dist/core/resource-loader.d.ts.map +1 -1
  169. package/dist/core/resource-loader.js +45 -18
  170. package/dist/core/resource-loader.js.map +1 -1
  171. package/dist/core/runtime-builder.d.ts +3 -0
  172. package/dist/core/runtime-builder.d.ts.map +1 -1
  173. package/dist/core/runtime-builder.js +49 -1
  174. package/dist/core/runtime-builder.js.map +1 -1
  175. package/dist/core/sdk.d.ts.map +1 -1
  176. package/dist/core/sdk.js +3 -0
  177. package/dist/core/sdk.js.map +1 -1
  178. package/dist/core/session-role.d.ts.map +1 -1
  179. package/dist/core/session-role.js +2 -0
  180. package/dist/core/session-role.js.map +1 -1
  181. package/dist/core/settings-manager.d.ts +12 -0
  182. package/dist/core/settings-manager.d.ts.map +1 -1
  183. package/dist/core/settings-manager.js +43 -9
  184. package/dist/core/settings-manager.js.map +1 -1
  185. package/dist/core/system-prompt-builder.js +1 -1
  186. package/dist/core/system-prompt-builder.js.map +1 -1
  187. package/dist/core/system-prompt.d.ts +1 -1
  188. package/dist/core/system-prompt.d.ts.map +1 -1
  189. package/dist/core/system-prompt.js +30 -22
  190. package/dist/core/system-prompt.js.map +1 -1
  191. package/dist/core/tasks/task-projection.d.ts +2 -0
  192. package/dist/core/tasks/task-projection.d.ts.map +1 -1
  193. package/dist/core/tasks/task-projection.js +1 -0
  194. package/dist/core/tasks/task-projection.js.map +1 -1
  195. package/dist/core/tasks/task-state.d.ts +1 -1
  196. package/dist/core/tasks/task-state.d.ts.map +1 -1
  197. package/dist/core/tasks/task-state.js +10 -3
  198. package/dist/core/tasks/task-state.js.map +1 -1
  199. package/dist/core/tools/bash.d.ts.map +1 -1
  200. package/dist/core/tools/bash.js +11 -3
  201. package/dist/core/tools/bash.js.map +1 -1
  202. package/dist/core/tools/delegate.d.ts.map +1 -1
  203. package/dist/core/tools/delegate.js +9 -3
  204. package/dist/core/tools/delegate.js.map +1 -1
  205. package/dist/core/tools/edit.d.ts.map +1 -1
  206. package/dist/core/tools/edit.js +47 -5
  207. package/dist/core/tools/edit.js.map +1 -1
  208. package/dist/core/tools/goal.d.ts +16 -1
  209. package/dist/core/tools/goal.d.ts.map +1 -1
  210. package/dist/core/tools/goal.js +14 -2
  211. package/dist/core/tools/goal.js.map +1 -1
  212. package/dist/core/tools/index.d.ts +1 -1
  213. package/dist/core/tools/index.d.ts.map +1 -1
  214. package/dist/core/tools/index.js +1 -1
  215. package/dist/core/tools/index.js.map +1 -1
  216. package/dist/core/tools/output-accumulator.d.ts +5 -0
  217. package/dist/core/tools/output-accumulator.d.ts.map +1 -1
  218. package/dist/core/tools/output-accumulator.js +33 -2
  219. package/dist/core/tools/output-accumulator.js.map +1 -1
  220. package/dist/core/tools/pipeline.d.ts +35 -0
  221. package/dist/core/tools/pipeline.d.ts.map +1 -0
  222. package/dist/core/tools/pipeline.js +203 -0
  223. package/dist/core/tools/pipeline.js.map +1 -0
  224. package/dist/core/tools/skill-audit.d.ts.map +1 -1
  225. package/dist/core/tools/skill-audit.js +2 -1
  226. package/dist/core/tools/skill-audit.js.map +1 -1
  227. package/dist/core/tools/skill.d.ts.map +1 -1
  228. package/dist/core/tools/skill.js +2 -1
  229. package/dist/core/tools/skill.js.map +1 -1
  230. package/dist/core/tools/skillify.d.ts.map +1 -1
  231. package/dist/core/tools/skillify.js +3 -1
  232. package/dist/core/tools/skillify.js.map +1 -1
  233. package/dist/core/tools/task-steps.d.ts +1 -1
  234. package/dist/core/tools/task-steps.d.ts.map +1 -1
  235. package/dist/core/tools/task-steps.js +9 -0
  236. package/dist/core/tools/task-steps.js.map +1 -1
  237. package/dist/core/tools/tool-task.d.ts.map +1 -1
  238. package/dist/core/tools/tool-task.js +5 -1
  239. package/dist/core/tools/tool-task.js.map +1 -1
  240. package/dist/core/tools/write.d.ts.map +1 -1
  241. package/dist/core/tools/write.js +1 -0
  242. package/dist/core/tools/write.js.map +1 -1
  243. package/dist/index.d.ts +1 -1
  244. package/dist/index.d.ts.map +1 -1
  245. package/dist/index.js +1 -1
  246. package/dist/index.js.map +1 -1
  247. package/dist/modes/interactive/components/settings-selector.d.ts +3 -0
  248. package/dist/modes/interactive/components/settings-selector.d.ts.map +1 -1
  249. package/dist/modes/interactive/components/settings-selector.js +66 -0
  250. package/dist/modes/interactive/components/settings-selector.js.map +1 -1
  251. package/dist/modes/interactive/components/skill-invocation-message.js +1 -1
  252. package/dist/modes/interactive/components/skill-invocation-message.js.map +1 -1
  253. package/dist/modes/interactive/components/tool-execution.d.ts +6 -1
  254. package/dist/modes/interactive/components/tool-execution.d.ts.map +1 -1
  255. package/dist/modes/interactive/components/tool-execution.js +20 -1
  256. package/dist/modes/interactive/components/tool-execution.js.map +1 -1
  257. package/dist/modes/interactive/components/tool-group.d.ts +4 -0
  258. package/dist/modes/interactive/components/tool-group.d.ts.map +1 -1
  259. package/dist/modes/interactive/components/tool-group.js +96 -7
  260. package/dist/modes/interactive/components/tool-group.js.map +1 -1
  261. package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
  262. package/dist/modes/interactive/interactive-mode.js +8 -10
  263. package/dist/modes/interactive/interactive-mode.js.map +1 -1
  264. package/dist/modes/interactive/key-handlers.d.ts +1 -0
  265. package/dist/modes/interactive/key-handlers.d.ts.map +1 -1
  266. package/dist/modes/interactive/key-handlers.js +2 -1
  267. package/dist/modes/interactive/key-handlers.js.map +1 -1
  268. package/dist/modes/interactive/settings-selector-flow.d.ts.map +1 -1
  269. package/dist/modes/interactive/settings-selector-flow.js +12 -0
  270. package/dist/modes/interactive/settings-selector-flow.js.map +1 -1
  271. package/docs/extensions.md +8 -5
  272. package/docs/harness-architecture.md +3 -4
  273. package/docs/keybindings.md +3 -2
  274. package/docs/quickstart.md +4 -4
  275. package/docs/sdk.md +3 -1
  276. package/docs/settings.md +16 -2
  277. package/docs/task-steps.md +1 -0
  278. package/docs/usage.md +6 -7
  279. package/docs/worker-profiles.md +1 -1
  280. package/docs/worktree-sync.md +1 -1
  281. package/examples/extensions/custom-provider-anthropic/package-lock.json +2 -2
  282. package/examples/extensions/custom-provider-anthropic/package.json +1 -1
  283. package/examples/extensions/custom-provider-gitlab-duo/package.json +1 -1
  284. package/examples/extensions/minimal-mode.ts +1 -1
  285. package/examples/extensions/sandbox/package-lock.json +2 -2
  286. package/examples/extensions/sandbox/package.json +1 -1
  287. package/examples/extensions/with-deps/package-lock.json +2 -2
  288. package/examples/extensions/with-deps/package.json +1 -1
  289. package/examples/sdk/07-context-files.ts +5 -2
  290. package/npm-shrinkwrap.json +12 -12
  291. package/package.json +4 -4
@@ -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,UAA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zB,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,SA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BAAmB,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
+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,YAAY,KAAK,QAAQ;QACvC,OAAO,MAAM,CAAC,cAAc,KAAK,QAAQ;QACzC,OAAO,MAAM,CAAC,OAAO,KAAK,QAAQ;QAClC,OAAO,MAAM,CAAC,cAAc,KAAK,QAAQ;QACzC,CAAC,MAAM,CAAC,MAAM,KAAK,QAAQ,IAAI,MAAM,CAAC,MAAM,KAAK,WAAW,IAAI,MAAM,CAAC,MAAM,KAAK,WAAW,CAAC;QAC9F,OAAO,MAAM,CAAC,SAAS,KAAK,QAAQ;QACpC,OAAO,MAAM,CAAC,SAAS,KAAK,QAAQ;QACpC,CAAC,MAAM,CAAC,MAAM,KAAK,SAAS,IAAI,OAAO,MAAM,CAAC,MAAM,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;A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AO,CAAC,mBAAmB,CAAK;IAEhC,YAAY,IAAI,EAAE,wBAAwB,EAEzC;IAED,yHAAyH;IACzH,gBAAgB,CAAC,QAAQ,EAAE,YAAY,EAAE,EAAE,kBAAkB,EAAE,MAAM,GAAG,sBAAsB,CAyB7F;IAED,OAAO,CAAC,mBAAmB;IAgB3B,OAAO,CAAC,gBAAgB;IAoDxB,eAAe,IAAI,IAAI,CAItB;IAEK,iBAAiB,IAAI,OAAO,CAAC,IAAI,CAAC,CAEvC;IAED;;;;;;;;;;;;;OAaG;IACG,qBAAqB,CAAC,IAAI,EAAE,yBAAyB,GAAG,OAAO,CAAC,wBAAwB,CAAC,CAyO9F;IAED;;;;;;;;OAQG;IACG,iBAAiB,CAAC,KAAK,EAAE;QAC9B,OAAO,EAAE,aAAa,CAAC;QACvB,cAAc,EAAE,MAAM,CAAC;QACvB,KAAK,CAAC,EAAE,KAAK,CAAC,GAAG,CAAC,CAAC;QACnB,aAAa,CAAC,EAAE,aAAa,CAAC;QAC9B,MAAM,CAAC,EAAE,WAAW,CAAC;QACrB,8FAA8F;QAC9F,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,kGAAkG;QAClG,6BAA6B,CAAC,EAAE,OAAO,CAAC;KACxC,GAAG,OAAO,CAAC,gBAAgB,GAAG,IAAI,CAAC,CAsMnC;IAED,uBAAuB,IAAI,mBAAmB,EAAE,CAE/C;IAED;;;;;OAKG;IACG,qBAAqB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC;QAAE,EAAE,EAAE,OAAO,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC,CAoErF;IAED;;;;;;OAMG;YACW,qBAAqB;IA6DnC;;;;;;;;;OASG;IACH,OAAO,CAAC,2BAA2B;IA8BnC;;;;;OAKG;IACH,OAAO,CAAC,uBAAuB;CAwB/B"}
@@ -432,40 +432,59 @@ export class ReflectionController {
432
432
  }
433
433
  const explicitUserMemoryWrite = input.explicitUserMemoryInstruction === true &&
434
434
  (write.kind === "memory_add" || write.kind === "memory_replace");
435
- const decision = explicitUserMemoryWrite
436
- ? {
435
+ // Additive skill promotion is the skill counterpart of a memory fact: a repeatable
436
+ // procedure should land as a loadable SKILL.md (overlap audit still holds the write).
437
+ // An owner who enabled auto-apply and omitted "skill" from the allow-list keeps that ceiling.
438
+ const ownerExcludedSkillLayer = policy.enabled && policy.autoApplyEnabled && !policy.allowedAutoApplyLayers.includes("skill");
439
+ const additiveSkillPromotion = write.kind === "promote_skill" && !ownerExcludedSkillLayer;
440
+ let decision;
441
+ if (explicitUserMemoryWrite) {
442
+ decision = {
437
443
  kind: "apply",
438
444
  reasonCode: "explicit_user_memory_instruction",
439
445
  confidence: 100,
440
446
  summary: proposal.summary,
441
447
  requiresApproval: false,
442
- }
443
- : policy.enabled
444
- ? evaluateLearningDecision({
445
- proposal,
446
- confidence: policy.reflectionSourceConfidence,
447
- observations,
448
- // A replace/remove supersedes an existing durable fact — the reflection engine's
449
- // confront-before-write conflict signal — so it routes through approval instead of
450
- // silently overwriting prior memory. Additive writes contradict nothing.
451
- contradictions: contradictionsForReflectionWrite(write),
452
- settings: {
453
- enabled: true,
454
- autoApplyEnabled: policy.autoApplyEnabled,
455
- confidenceThreshold: policy.confidenceThreshold,
456
- minObservations: policy.minObservations,
457
- allowedAutoApplyLayers: policy.allowedAutoApplyLayers,
458
- requireRollbackPlan: policy.requireRollbackPlan,
459
- autoApplySupersessions: policy.autoApplySupersessions,
460
- },
461
- })
462
- : {
463
- kind: "apply",
464
- reasonCode: "learning_policy_disabled_legacy_apply",
465
- confidence: 0,
466
- summary: proposal.summary,
467
- requiresApproval: false,
468
- };
448
+ };
449
+ }
450
+ else if (additiveSkillPromotion) {
451
+ decision = {
452
+ kind: "apply",
453
+ reasonCode: "additive_skill_promotion",
454
+ confidence: policy.reflectionSourceConfidence,
455
+ summary: proposal.summary,
456
+ requiresApproval: false,
457
+ };
458
+ }
459
+ else if (policy.enabled) {
460
+ decision = evaluateLearningDecision({
461
+ proposal,
462
+ confidence: policy.reflectionSourceConfidence,
463
+ observations,
464
+ // A replace/remove supersedes an existing durable fact — the reflection engine's
465
+ // confront-before-write conflict signal — so it routes through approval instead of
466
+ // silently overwriting prior memory. Additive writes contradict nothing.
467
+ contradictions: contradictionsForReflectionWrite(write),
468
+ settings: {
469
+ enabled: true,
470
+ autoApplyEnabled: policy.autoApplyEnabled,
471
+ confidenceThreshold: policy.confidenceThreshold,
472
+ minObservations: policy.minObservations,
473
+ allowedAutoApplyLayers: policy.allowedAutoApplyLayers,
474
+ requireRollbackPlan: policy.requireRollbackPlan,
475
+ autoApplySupersessions: policy.autoApplySupersessions,
476
+ },
477
+ });
478
+ }
479
+ else {
480
+ decision = {
481
+ kind: "apply",
482
+ reasonCode: "learning_policy_disabled_legacy_apply",
483
+ confidence: 0,
484
+ summary: proposal.summary,
485
+ requiresApproval: false,
486
+ };
487
+ }
469
488
  this.deps.saveLearningDecisionSnapshot(decision);
470
489
  // G3: learning-gate outcome. Codes/numbers only — never the proposal summary/memory text.
471
490
  this.deps.emitAutonomyTelemetry({
@@ -607,6 +626,7 @@ export class ReflectionController {
607
626
  if (!this.deps.archivePromotedSkill(rollback.target)) {
608
627
  return { ok: false, reason: "skill_archive_failed" };
609
628
  }
629
+ this.deps.refreshLiveSkills?.();
610
630
  break;
611
631
  }
612
632
  }
@@ -634,7 +654,10 @@ export class ReflectionController {
634
654
  // R7 memory-to-behavior: a recurring procedure is compiled into an executable skill file rather
635
655
  // than stored as a flat fact. Written under the agent skills dir so it loads like any user skill.
636
656
  if (write.kind === "promote_skill") {
637
- return this._promoteReflectionSkill(write.name, write.description, write.body);
657
+ const promoted = this._promoteReflectionSkill(write.name, write.description, write.body);
658
+ if (promoted)
659
+ this.deps.refreshLiveSkills?.();
660
+ return promoted;
638
661
  }
639
662
  const memTool = this.deps
640
663
  .getMemoryManager()