@bastani/atomic 0.9.16-alpha.7 → 0.9.16-alpha.8

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 (207) hide show
  1. package/CHANGELOG.md +19 -0
  2. package/dist/builtin/intercom/CHANGELOG.md +6 -0
  3. package/dist/builtin/intercom/README.md +4 -4
  4. package/dist/builtin/intercom/broker/broker.ts +617 -22
  5. package/dist/builtin/intercom/broker/client-message-validation.ts +9 -0
  6. package/dist/builtin/intercom/broker/client.ts +200 -10
  7. package/dist/builtin/intercom/broker/pending-send-registry.ts +4 -0
  8. package/dist/builtin/intercom/broker/send-handler.ts +90 -36
  9. package/dist/builtin/intercom/broker/send-signature.ts +20 -8
  10. package/dist/builtin/intercom/group.ts +85 -0
  11. package/dist/builtin/intercom/index.bundle.mjs +680 -53
  12. package/dist/builtin/intercom/package.json +1 -1
  13. package/dist/builtin/intercom/session-target.ts +54 -0
  14. package/dist/builtin/intercom/skills/intercom/SKILL.md +18 -3
  15. package/dist/builtin/intercom/source-ownership.ts +31 -0
  16. package/dist/builtin/intercom/types.ts +115 -0
  17. package/dist/builtin/mcp/index.bundle.mjs +109 -35
  18. package/dist/builtin/mcp/package.json +1 -1
  19. package/dist/builtin/subagents/package.json +1 -1
  20. package/dist/builtin/subagents/src/extension/index.bundle.mjs +173 -51
  21. package/dist/builtin/web-access/index.bundle.mjs +109 -35
  22. package/dist/builtin/web-access/package.json +1 -1
  23. package/dist/builtin/workflows/CHANGELOG.md +15 -0
  24. package/dist/builtin/workflows/README.md +40 -37
  25. package/dist/builtin/workflows/builtin/adversarial-verification.js +13 -0
  26. package/dist/builtin/workflows/builtin/{shared-prompts.ts → chunk-0x6e303p.js} +133 -154
  27. package/dist/builtin/workflows/builtin/chunk-29wrp38a.js +199 -0
  28. package/dist/builtin/workflows/builtin/chunk-2dqb5s2q.js +602 -0
  29. package/dist/builtin/workflows/builtin/chunk-4febxsv4.js +264 -0
  30. package/dist/builtin/workflows/builtin/chunk-5n10x7j2.js +69730 -0
  31. package/dist/builtin/workflows/builtin/chunk-5wgwscd0.js +4 -0
  32. package/dist/builtin/workflows/builtin/chunk-6fqs7c01.js +155 -0
  33. package/dist/builtin/workflows/builtin/chunk-7430zyas.js +126 -0
  34. package/dist/builtin/workflows/builtin/chunk-7at6dnkr.js +33 -0
  35. package/dist/builtin/workflows/builtin/chunk-82ha8p41.js +175 -0
  36. package/dist/builtin/workflows/builtin/chunk-bfkmzv9h.js +156 -0
  37. package/dist/builtin/workflows/builtin/chunk-c53y8bdh.js +345 -0
  38. package/dist/builtin/workflows/builtin/chunk-cdtd3m3w.js +529 -0
  39. package/dist/builtin/workflows/builtin/chunk-cg9tmks0.js +206 -0
  40. package/dist/builtin/workflows/builtin/chunk-hdpj1dkw.js +2447 -0
  41. package/dist/builtin/workflows/builtin/chunk-hzzn6adg.js +221 -0
  42. package/dist/builtin/workflows/builtin/chunk-nqr34qp3.js +1061 -0
  43. package/dist/builtin/workflows/builtin/chunk-qwzvgxnq.js +404 -0
  44. package/dist/builtin/workflows/builtin/chunk-qx2ptjs3.js +215 -0
  45. package/dist/builtin/workflows/builtin/chunk-v04c5qmd.js +1207 -0
  46. package/dist/builtin/workflows/builtin/chunk-wpckd35c.js +12 -0
  47. package/dist/builtin/workflows/builtin/chunk-x2ghn0je.js +4110 -0
  48. package/dist/builtin/workflows/builtin/chunk-zf28603f.js +1080 -0
  49. package/dist/builtin/workflows/builtin/classify-and-act.js +12 -0
  50. package/dist/builtin/workflows/builtin/fan-out-and-synthesize.js +10 -0
  51. package/dist/builtin/workflows/builtin/generate-and-filter.js +12 -0
  52. package/dist/builtin/workflows/builtin/goal.js +16 -0
  53. package/dist/builtin/workflows/builtin/index.js +49 -0
  54. package/dist/builtin/workflows/builtin/loop-until-done.js +12 -0
  55. package/dist/builtin/workflows/builtin/open-claude-design.js +11 -0
  56. package/dist/builtin/workflows/builtin/ralph.js +16 -0
  57. package/dist/builtin/workflows/builtin/steering-context.d.ts +6 -0
  58. package/dist/builtin/workflows/builtin/steering-context.js +7 -0
  59. package/dist/builtin/workflows/builtin/tournament.js +13 -0
  60. package/dist/builtin/workflows/package.json +10 -7
  61. package/dist/builtin/workflows/src/authoring/typebox-defaults.d.ts +41 -0
  62. package/dist/builtin/workflows/src/extension/index.bundle.mjs +1228 -428
  63. package/dist/builtin/workflows/src/{index.bundle.mjs → index.js} +956 -427
  64. package/dist/builtin/workflows/src/shared/authoring-contract-stage.d.ts +403 -0
  65. package/dist/builtin/workflows/src/shared/authoring-contract-ui.d.ts +327 -0
  66. package/dist/builtin/workflows/src/shared/budget.d.ts +67 -0
  67. package/dist/builtin/workflows/src/shared/workflow-authoring-types.d.ts +60 -0
  68. package/dist/builtin/workflows/src/shared/workflow-heartbeat-contract.d.ts +21 -0
  69. package/dist/core/agent-session-custom-message-commit.d.ts.map +1 -1
  70. package/dist/core/agent-session-custom-message-commit.js +12 -5
  71. package/dist/core/agent-session-custom-message-commit.js.map +1 -1
  72. package/dist/core/agent-session-persistent-custom-messages.d.ts.map +1 -1
  73. package/dist/core/agent-session-persistent-custom-messages.js +2 -0
  74. package/dist/core/agent-session-persistent-custom-messages.js.map +1 -1
  75. package/dist/core/agent-session.d.ts.map +1 -1
  76. package/dist/core/agent-session.js +2 -1
  77. package/dist/core/agent-session.js.map +1 -1
  78. package/dist/core/auth-storage.d.ts +2 -0
  79. package/dist/core/auth-storage.d.ts.map +1 -1
  80. package/dist/core/auth-storage.js +4 -0
  81. package/dist/core/auth-storage.js.map +1 -1
  82. package/dist/core/builtin-install-layout.d.ts +1 -1
  83. package/dist/core/builtin-install-layout.d.ts.map +1 -1
  84. package/dist/core/builtin-install-layout.js +1 -1
  85. package/dist/core/builtin-install-layout.js.map +1 -1
  86. package/dist/core/codex-fast-mode.d.ts +10 -7
  87. package/dist/core/codex-fast-mode.d.ts.map +1 -1
  88. package/dist/core/codex-fast-mode.js +31 -13
  89. package/dist/core/codex-fast-mode.js.map +1 -1
  90. package/dist/core/extensions/context-types.d.ts +35 -0
  91. package/dist/core/extensions/context-types.d.ts.map +1 -1
  92. package/dist/core/extensions/context-types.js.map +1 -1
  93. package/dist/core/extensions/index.d.ts +1 -1
  94. package/dist/core/extensions/index.d.ts.map +1 -1
  95. package/dist/core/extensions/index.js.map +1 -1
  96. package/dist/core/extensions/loader-virtual-modules.d.ts.map +1 -1
  97. package/dist/core/extensions/loader-virtual-modules.js +6 -1
  98. package/dist/core/extensions/loader-virtual-modules.js.map +1 -1
  99. package/dist/core/model-runtime.d.ts +2 -0
  100. package/dist/core/model-runtime.d.ts.map +1 -1
  101. package/dist/core/model-runtime.js +4 -0
  102. package/dist/core/model-runtime.js.map +1 -1
  103. package/dist/core/runtime-credentials.d.ts +1 -0
  104. package/dist/core/runtime-credentials.d.ts.map +1 -1
  105. package/dist/core/runtime-credentials.js +8 -0
  106. package/dist/core/runtime-credentials.js.map +1 -1
  107. package/dist/core/sdk.d.ts.map +1 -1
  108. package/dist/core/sdk.js +5 -5
  109. package/dist/core/sdk.js.map +1 -1
  110. package/dist/core/session-manager-storage.d.ts +2 -0
  111. package/dist/core/session-manager-storage.d.ts.map +1 -1
  112. package/dist/core/session-manager-storage.js +4 -2
  113. package/dist/core/session-manager-storage.js.map +1 -1
  114. package/dist/core/slash-commands.js +1 -1
  115. package/dist/core/slash-commands.js.map +1 -1
  116. package/dist/core/workflow-stage-admission.d.ts +6 -1
  117. package/dist/core/workflow-stage-admission.d.ts.map +1 -1
  118. package/dist/core/workflow-stage-admission.js +8 -9
  119. package/dist/core/workflow-stage-admission.js.map +1 -1
  120. package/dist/index.d.ts +0 -1
  121. package/dist/modes/interactive/components/footer.d.ts.map +1 -1
  122. package/dist/modes/interactive/components/footer.js +1 -1
  123. package/dist/modes/interactive/components/footer.js.map +1 -1
  124. package/dist/modes/interactive/interactive-autocomplete.js +1 -1
  125. package/dist/modes/interactive/interactive-autocomplete.js.map +1 -1
  126. package/dist/modes/interactive/interactive-startup.js +1 -1
  127. package/dist/modes/interactive/interactive-startup.js.map +1 -1
  128. package/dist/modes/interactive-engine/isolated-runtime.d.ts +4 -0
  129. package/dist/modes/interactive-engine/isolated-runtime.d.ts.map +1 -1
  130. package/dist/modes/interactive-engine/isolated-runtime.js +69 -10
  131. package/dist/modes/interactive-engine/isolated-runtime.js.map +1 -1
  132. package/dist/modes/rpc/rpc-client-api.d.ts +18 -2
  133. package/dist/modes/rpc/rpc-client-api.d.ts.map +1 -1
  134. package/dist/modes/rpc/rpc-client-api.js +33 -5
  135. package/dist/modes/rpc/rpc-client-api.js.map +1 -1
  136. package/dist/modes/rpc/rpc-command-handler.d.ts.map +1 -1
  137. package/dist/modes/rpc/rpc-command-handler.js +8 -4
  138. package/dist/modes/rpc/rpc-command-handler.js.map +1 -1
  139. package/dist/modes/rpc/rpc-types.d.ts +13 -0
  140. package/dist/modes/rpc/rpc-types.d.ts.map +1 -1
  141. package/dist/modes/rpc/rpc-types.js.map +1 -1
  142. package/docs/intercom.md +15 -6
  143. package/docs/packages.md +2 -2
  144. package/docs/providers.md +8 -3
  145. package/docs/quickstart.md +2 -2
  146. package/docs/rpc.md +21 -4
  147. package/docs/settings.md +6 -4
  148. package/docs/subagents.md +1 -1
  149. package/docs/usage.md +1 -1
  150. package/docs/workflows.md +108 -239
  151. package/npm-shrinkwrap.json +32 -32
  152. package/package.json +9 -13
  153. package/dist/builtin/workflows/ambient.d.ts +0 -61
  154. package/dist/builtin/workflows/builtin/adversarial-verification-prompts.ts +0 -26
  155. package/dist/builtin/workflows/builtin/adversarial-verification-runner.ts +0 -391
  156. package/dist/builtin/workflows/builtin/adversarial-verification.ts +0 -34
  157. package/dist/builtin/workflows/builtin/classify-and-act-prompts.ts +0 -14
  158. package/dist/builtin/workflows/builtin/classify-and-act-runner.ts +0 -108
  159. package/dist/builtin/workflows/builtin/classify-and-act.ts +0 -40
  160. package/dist/builtin/workflows/builtin/fan-out-and-synthesize-prompts.ts +0 -14
  161. package/dist/builtin/workflows/builtin/fan-out-and-synthesize-runner.ts +0 -96
  162. package/dist/builtin/workflows/builtin/fan-out-and-synthesize.ts +0 -37
  163. package/dist/builtin/workflows/builtin/generate-and-filter-prompts.ts +0 -41
  164. package/dist/builtin/workflows/builtin/generate-and-filter-runner.ts +0 -90
  165. package/dist/builtin/workflows/builtin/generate-and-filter.ts +0 -31
  166. package/dist/builtin/workflows/builtin/goal-artifacts.ts +0 -64
  167. package/dist/builtin/workflows/builtin/goal-convergence.ts +0 -87
  168. package/dist/builtin/workflows/builtin/goal-ledger.ts +0 -139
  169. package/dist/builtin/workflows/builtin/goal-models.ts +0 -72
  170. package/dist/builtin/workflows/builtin/goal-orchestrator-prompts.ts +0 -94
  171. package/dist/builtin/workflows/builtin/goal-prompts.ts +0 -217
  172. package/dist/builtin/workflows/builtin/goal-reducer.ts +0 -176
  173. package/dist/builtin/workflows/builtin/goal-reports.ts +0 -76
  174. package/dist/builtin/workflows/builtin/goal-reverify.ts +0 -305
  175. package/dist/builtin/workflows/builtin/goal-review.ts +0 -139
  176. package/dist/builtin/workflows/builtin/goal-runner.ts +0 -504
  177. package/dist/builtin/workflows/builtin/goal-schemas.ts +0 -89
  178. package/dist/builtin/workflows/builtin/goal-types.ts +0 -164
  179. package/dist/builtin/workflows/builtin/goal.ts +0 -78
  180. package/dist/builtin/workflows/builtin/index.ts +0 -16
  181. package/dist/builtin/workflows/builtin/loop-until-done-prompts.ts +0 -87
  182. package/dist/builtin/workflows/builtin/loop-until-done-runner.ts +0 -282
  183. package/dist/builtin/workflows/builtin/loop-until-done.ts +0 -51
  184. package/dist/builtin/workflows/builtin/open-claude-design-live-protocol.ts +0 -305
  185. package/dist/builtin/workflows/builtin/open-claude-design-phases.ts +0 -337
  186. package/dist/builtin/workflows/builtin/open-claude-design-runner.ts +0 -347
  187. package/dist/builtin/workflows/builtin/open-claude-design-setup.ts +0 -313
  188. package/dist/builtin/workflows/builtin/open-claude-design-utils.ts +0 -311
  189. package/dist/builtin/workflows/builtin/open-claude-design.ts +0 -57
  190. package/dist/builtin/workflows/builtin/pattern-artifact-root.ts +0 -28
  191. package/dist/builtin/workflows/builtin/progress-scoring.ts +0 -230
  192. package/dist/builtin/workflows/builtin/ralph-core.ts +0 -449
  193. package/dist/builtin/workflows/builtin/ralph-forked-prompts.ts +0 -100
  194. package/dist/builtin/workflows/builtin/ralph-models.ts +0 -183
  195. package/dist/builtin/workflows/builtin/ralph-review-gate.ts +0 -103
  196. package/dist/builtin/workflows/builtin/ralph-reviewer-prompt.ts +0 -104
  197. package/dist/builtin/workflows/builtin/ralph-runner.ts +0 -459
  198. package/dist/builtin/workflows/builtin/ralph.ts +0 -82
  199. package/dist/builtin/workflows/builtin/review-convergence.ts +0 -229
  200. package/dist/builtin/workflows/builtin/selection-math.ts +0 -156
  201. package/dist/builtin/workflows/builtin/steering-context.ts +0 -51
  202. package/dist/builtin/workflows/builtin/tournament-prompts.ts +0 -70
  203. package/dist/builtin/workflows/builtin/tournament-runner.ts +0 -400
  204. package/dist/builtin/workflows/builtin/tournament.ts +0 -73
  205. package/dist/builtin/workflows/builtin/verification-criteria.ts +0 -330
  206. package/dist/builtin/workflows/builtin/verification-prompts.ts +0 -206
  207. package/dist/builtin/workflows/builtin/verification-usage.ts +0 -44
@@ -1,164 +0,0 @@
1
- import type { ReviewConvergenceSummary } from "./review-convergence.js";
2
- import type { ReverifyAuditEntry } from "./goal-reverify.js";
3
- import type { ConvergenceEntry } from "./goal-convergence.js";
4
-
5
- export const DEFAULT_MAX_TURNS = 10;
6
- // Goal Runner runs three independent reviewer personas; two approvals form a majority.
7
- export const DEFAULT_REVIEW_QUORUM = 2;
8
- export const DEFAULT_BLOCKER_THRESHOLD = 3;
9
- export const LEDGER_FILENAME = "goal-ledger.json";
10
-
11
- export type GoalStatus = "active" | "complete" | "blocked" | "needs_human";
12
- export type ReviewGateDecisionValue = "complete" | "continue" | "blocked";
13
-
14
- export type WorkReceipt = {
15
- readonly turn: number;
16
- readonly stage: string;
17
- readonly artifact_path: string;
18
- readonly summary: string;
19
- };
20
-
21
- export type ObjectiveAlignment =
22
- | "required_by_objective"
23
- | "consistent_with_objective"
24
- | "beyond_objective"
25
- | "contradicts_objective";
26
-
27
- export type RequirementTraceability = {
28
- readonly requirement: string;
29
- readonly status: "proven" | "contradicted" | "missing" | "unverified";
30
- readonly evidence: string;
31
- };
32
-
33
- export type ReviewFinding = {
34
- readonly title: string;
35
- readonly body: string;
36
- readonly confidence_score: number;
37
- readonly objective_alignment: ObjectiveAlignment;
38
- readonly priority?: number | null;
39
- readonly code_location: {
40
- readonly absolute_file_path: string;
41
- readonly line_range: {
42
- readonly start: number;
43
- readonly end: number;
44
- };
45
- };
46
- };
47
-
48
- export type ReviewerError = {
49
- readonly kind:
50
- | "validation_unavailable"
51
- | "dependency_unavailable"
52
- | "tool_failure"
53
- | "reviewer_failure";
54
- readonly message: string;
55
- readonly attempted_recovery: string;
56
- };
57
-
58
- export type ReviewDecision = {
59
- readonly findings: readonly ReviewFinding[];
60
- readonly criterion_scores?: readonly { readonly criterion_id: string; readonly score: number }[];
61
- readonly overall_correctness: "patch is correct" | "patch is incorrect";
62
- readonly overall_explanation: string;
63
- readonly overall_confidence_score: number;
64
- readonly goal_oracle_satisfied: boolean;
65
- readonly requirements_traceability: readonly RequirementTraceability[];
66
- readonly receipt_assessment: string;
67
- readonly verification_remaining: string;
68
- readonly stop_review_loop: boolean;
69
- readonly reviewer_error?: ReviewerError | null;
70
- };
71
-
72
- export type ReviewRecord = ReviewDecision & {
73
- readonly decision: ReviewGateDecisionValue;
74
- readonly evidence: readonly string[];
75
- readonly gaps: readonly string[];
76
- readonly blocker: string | null;
77
- readonly confidence_score: number;
78
- readonly explanation: string;
79
- readonly turn: number;
80
- readonly reviewer: string;
81
- readonly artifact_path: string;
82
- readonly parsed: boolean;
83
- readonly approved: boolean;
84
- readonly parse_diagnostics: readonly string[];
85
- readonly convergence_decision: ReviewConvergenceSummary;
86
- };
87
-
88
- export type BlockerObservation = {
89
- readonly turn: number;
90
- readonly blocker: string;
91
- readonly reviewers: readonly string[];
92
- };
93
-
94
- export type ReducerDecision = ReviewConvergenceSummary & {
95
- readonly turn: number;
96
- readonly decision: "complete" | "continue" | "blocked" | "needs_human";
97
- readonly reason: string;
98
- readonly complete_votes: number;
99
- readonly review_quorum: number;
100
- readonly blocker?: string;
101
- };
102
-
103
- export type GoalLifecycleEvent = {
104
- readonly turn: number;
105
- readonly event:
106
- | "created"
107
- | "work_turn_started"
108
- | "receipt_recorded"
109
- | "reviews_recorded"
110
- | "status_decided";
111
- readonly status: GoalStatus;
112
- readonly at: string;
113
- readonly summary: string;
114
- };
115
-
116
- export type GoalLedger = {
117
- readonly goal_id: string;
118
- readonly objective: string;
119
- readonly acceptance_criteria: string;
120
- status: GoalStatus;
121
- turns: number;
122
- readonly created_at: string;
123
- updated_at: string;
124
- receipts: WorkReceipt[];
125
- reviews: ReviewRecord[];
126
- blockers: BlockerObservation[];
127
- decisions: ReducerDecision[];
128
- lifecycle: GoalLifecycleEvent[];
129
- /** V9 audit records; the original findings remain in `reviews`. */
130
- reverification?: ReverifyAuditEntry<ReviewFinding>[];
131
- convergence?: ConvergenceEntry[];
132
- };
133
-
134
- export type ReducerOutcome = {
135
- readonly status: GoalStatus;
136
- readonly decision: ReducerDecision;
137
- readonly blockerObservation?: BlockerObservation;
138
- };
139
-
140
- export type GoalWorkflowInputs = {
141
- readonly objective: string;
142
- readonly acceptance_criteria?: string;
143
- readonly max_turns: number;
144
- readonly base_branch: string;
145
- readonly git_worktree_dir: string;
146
- readonly create_pr: boolean;
147
- };
148
-
149
- export type GoalWorkflowOutputs = {
150
- readonly result?: string;
151
- readonly status?: GoalStatus;
152
- readonly approved?: boolean;
153
- readonly goal_id?: string;
154
- readonly objective?: string;
155
- readonly acceptance_criteria?: string;
156
- readonly ledger_path?: string;
157
- readonly turns_completed?: number;
158
- readonly iterations_completed?: number;
159
- readonly receipts?: WorkReceipt[];
160
- readonly remaining_work?: string;
161
- readonly review_report?: string;
162
- readonly review_report_path?: string;
163
- readonly pr_report?: string;
164
- };
@@ -1,78 +0,0 @@
1
- /**
2
- * Builtin workflow: goal
3
- *
4
- * Goal Runner workflow: persist an objective ledger, run bounded orchestrator
5
- * turns, gate completion through independent reviewers, and let plain TypeScript
6
- * reduce the final state.
7
- */
8
-
9
- import { Type } from "typebox";
10
- import { workflow } from "../src/authoring/workflow.js";
11
- import { withSteeringPropagationContext } from "./steering-context.js";
12
- import { runGoalWorkflow } from "./goal-runner.js";
13
- import { DEFAULT_MAX_TURNS } from "./goal-types.js";
14
-
15
- export default workflow({
16
- name: "goal",
17
- description: "Goal Runner workflow with bounded sub-agent orchestration turns, immutable acceptance criteria, ledger artifacts, parallel reviewers, and reducer-gated completion. When launching follow-up goal runs from review findings, pass the ORIGINAL task text as acceptance_criteria so deltas cannot drift from the literal contract. If the task includes submitting a pull request (or MR/review), remove that final action from the objective text and set create_pr=true instead when preparing the workflow inputs.",
18
- // The 15-minute default, stated rather than inherited: this is a per-workflow
19
- // product decision, so a future change to the global default must not silently
20
- // re-cadence a long autonomous run.
21
- heartbeatIntervalMinutes: 15,
22
- inputs: {
23
- objective: Type.String({ description: "The objective or delta for this Goal Runner workflow run. Do not include PR/MR submission instructions here; strip them from the task text and request them via create_pr=true instead." }),
24
- acceptance_criteria: Type.Optional(Type.String({ description: "Original immutable task contract this run must remain consistent with. Defaults to objective. Orchestrators launching follow-up runs from reviewer findings should pass the ORIGINAL task text here." })),
25
- max_turns: Type.Number({
26
- default: DEFAULT_MAX_TURNS,
27
- description: "Maximum orchestrator/review turns before Goal Runner stops as needs_human.",
28
- }),
29
- base_branch: Type.String({
30
- default: "origin/main",
31
- description: "Optional branch reviewers compare the current code delta against (default origin/main).",
32
- }),
33
- git_worktree_dir: Type.String({
34
- default: "",
35
- description:
36
- "Optional Git worktree path. Leave at the default unless the user explicitly requested worktree isolation — stages never create git worktrees on their own. Must start inside a Git repo; absolute paths are used as-is, relative paths resolve from the repo root, existing Git worktrees from the invoking repository are reused/shared as-is, and missing paths are created from base_branch.",
37
- }),
38
- create_pr: Type.Boolean({
39
- default: false,
40
- description:
41
- "Whether to run the final pull-request creation stage after reviewer/reducer approval. Defaults to false; prompt text alone does not opt in. If the task asks to submit a PR/MR/review, remove that from the objective text and set this to true — only the final stage then attempts provider-appropriate PR/MR/review creation after Goal completes."
42
- }),
43
- },
44
- outputs: {
45
- result: Type.Optional(Type.String({ description: "Final report with objective, status, receipts, turns, and remaining work." })),
46
- status: Type.Optional(Type.Union(
47
- [Type.Literal("complete"), Type.Literal("blocked"), Type.Literal("needs_human"), Type.Literal("active")],
48
- { description: "Final reducer status: complete, blocked, needs_human, or active if externally interrupted." },
49
- )),
50
- approved: Type.Optional(Type.Boolean({ description: "Whether the reducer reached complete." })),
51
- goal_id: Type.Optional(Type.String({ description: "Per-run goal identifier stored in the ledger." })),
52
- objective: Type.Optional(Type.String({ description: "Raw goal objective used by the run." })),
53
- acceptance_criteria: Type.Optional(Type.String({ description: "Immutable acceptance criteria used by the run." })),
54
- ledger_path: Type.Optional(Type.String({ description: "Durable run-scoped path to goal-ledger.json with receipts, reviewer decisions, blockers, and lifecycle events." })),
55
- turns_completed: Type.Optional(Type.Number({ description: "Orchestrator/review turns completed." })),
56
- iterations_completed: Type.Optional(Type.Number({ description: "Orchestrator/review turns completed, retained for status summaries." })),
57
- receipts: Type.Optional(Type.Array(Type.Object({
58
- turn: Type.Number(),
59
- stage: Type.String(),
60
- artifact_path: Type.String(),
61
- summary: Type.String(),
62
- }), { description: "Ledger receipt summaries and orchestrator artifact paths." })),
63
- remaining_work: Type.Optional(Type.String({ description: "Remaining gaps or blockers when incomplete, or none." })),
64
- review_report: Type.Optional(Type.String({ description: "Compact report pointing to the latest reviewer decision artifacts used by the reducer." })),
65
- review_report_path: Type.Optional(Type.String({ description: "JSON artifact path for the latest reviewer decision round." })),
66
- pr_report: Type.Optional(Type.String({ description: "Pull-request report emitted only when create_pr=true, Goal reaches complete, and the final pull-request stage runs." })),
67
- },
68
- worktreeFromInputs: {
69
- gitWorktreeDir: "git_worktree_dir",
70
- baseBranch: "base_branch",
71
- },
72
- run: async (ctx) => {
73
- const workflowCtx = withSteeringPropagationContext(ctx);
74
- const workflowStartCwd = workflowCtx.cwd ?? process.cwd();
75
- const createPr = workflowCtx.inputs.create_pr === true;
76
- return await runGoalWorkflow(workflowCtx, { createPr, workflowStartCwd });
77
- },
78
- });
@@ -1,16 +0,0 @@
1
- /**
2
- * Builtin workflows manifest.
3
- * Re-exported for consumers that want to enumerate or register builtins
4
- * programmatically. Atomic discovers these via the `pi.builtin`
5
- * package metadata pointing at this directory.
6
- */
7
-
8
- export { default as adversarialVerification } from "./adversarial-verification.js";
9
- export { default as classifyAndAct } from "./classify-and-act.js";
10
- export { default as fanOutAndSynthesize } from "./fan-out-and-synthesize.js";
11
- export { default as generateAndFilter } from "./generate-and-filter.js";
12
- export { default as goal } from "./goal.js";
13
- export { default as openClaudeDesign } from "./open-claude-design.js";
14
- export { default as loopUntilDone } from "./loop-until-done.js";
15
- export { default as ralph } from "./ralph.js";
16
- export { default as tournament } from "./tournament.js";
@@ -1,87 +0,0 @@
1
- type PromptSection = readonly [tag: string, content: string];
2
-
3
- const GROUNDED_REPORTING = "Before reporting progress, audit each claim against a tool result from this session. Report only work you can point to evidence for; say so explicitly when something is unverified.";
4
- const READABLE_REPORT = "Lead with the outcome. Keep facts, decisions, caveats, and next steps; drop background and repetition. Use complete, readable sentences rather than compressed fragments.";
5
-
6
- function taggedPrompt(sections: readonly PromptSection[]): string {
7
- return sections
8
- .map(([tag, content]) => `<${tag}>\n${content.trim()}\n</${tag}>`)
9
- .join("\n\n");
10
- }
11
-
12
- export function renderIterationPrompt(options: {
13
- readonly task: string;
14
- readonly iteration: number;
15
- readonly maxIterations: number;
16
- readonly ledgerPath: string;
17
- }): string {
18
- return taggedPrompt([
19
- ["progress_ledger", `Read ${options.ledgerPath} first. It is the durable source of truth for attempted work, findings, failures, validation evidence, and remaining work.`],
20
- ["role", "You are the active worker in a bounded evidence-driven completion loop."],
21
- ["iteration", `${options.iteration} of ${options.maxIterations}`],
22
- ["success_criteria", "This iteration makes measurable progress or supplies decisive evidence that the explicit objective is complete."],
23
- ["requirements", [
24
- "Select the highest-value unfinished item supported by the ledger and current state.",
25
- "Perform concrete work; do not merely restate the objective or ledger.",
26
- "Avoid repeating failed approaches unless new evidence justifies the retry.",
27
- "Run the strongest practical validation for the work completed in this iteration.",
28
- "Report exactly what changed, evidence gathered, failures encountered, and what remains.",
29
- GROUNDED_REPORTING,
30
- ].join("\n")],
31
- ["stop_rules", "End this iteration after delivering measurable progress, or after evidence shows the objective is complete."],
32
- ["output_format", `Markdown with Work performed, Changes, Validation evidence, New findings, Failures, and Remaining work. ${READABLE_REPORT}`],
33
- ["objective", options.task],
34
- ]);
35
- }
36
-
37
- export function renderEvaluationPrompt(options: {
38
- readonly task: string;
39
- readonly iteration: number;
40
- readonly ledgerPath: string;
41
- readonly iterationPath: string;
42
- }): string {
43
- return taggedPrompt([
44
- ["artifacts", [
45
- `Durable progress ledger: ${options.ledgerPath}`,
46
- `Current iteration artifact: ${options.iterationPath}`,
47
- "Read both files before deciding.",
48
- ].join("\n")],
49
- ["role", "You are an independent completion evaluator. Judge evidence, not the worker's confidence."],
50
- ["stop_condition", [
51
- "Set done=true only when the objective is fully satisfied and current validation evidence proves it.",
52
- "Set done=false when any required behavior, validation, cleanup, or evidence remains missing or uncertain.",
53
- "Do not invent requirements beyond the objective.",
54
- ].join("\n")],
55
- ["evidence_rules", [
56
- "List concrete validation evidence supporting the decision, including commands and observed output; cite file:line where applicable.",
57
- "Record new findings and failures distinctly.",
58
- "When incomplete, state actionable remaining work for the next iteration.",
59
- GROUNDED_REPORTING,
60
- ].join("\n")],
61
- ["success_criteria", `The iteration ${options.iteration} decision is reproducible from cited artifact evidence.`],
62
- ["output_format", `Return only the required structured decision with done, summary, new_findings, failures, validation_evidence, and remaining_work. ${READABLE_REPORT}`],
63
- ["objective", options.task],
64
- ]);
65
- }
66
-
67
- export function renderCompletionPrompt(options: {
68
- readonly task: string;
69
- readonly ledgerPath: string;
70
- readonly iterationPath: string;
71
- }): string {
72
- return taggedPrompt([
73
- ["artifacts", `Read the complete ledger at ${options.ledgerPath} and final iteration artifact at ${options.iterationPath}.`],
74
- ["role", "You are the final completion reporter."],
75
- ["requirements", [
76
- "Summarize the delivered outcome without adding unsupported claims.",
77
- "Cite the validation evidence that satisfied the stop condition.",
78
- "List artifact paths needed to audit the work.",
79
- "Report residual risks even when no work remains.",
80
- GROUNDED_REPORTING,
81
- ].join("\n")],
82
- ["success_criteria", "The final report is evidence-backed and independently auditable from the ledger."],
83
- ["stop_rules", "Stop after accounting for the outcome, supporting evidence, audit artifacts, residual risks, and any remaining work."],
84
- ["output_format", `Markdown with Outcome, Evidence, Artifacts, Residual risks, and Remaining work (None). ${READABLE_REPORT}`],
85
- ["objective", options.task],
86
- ]);
87
- }
@@ -1,282 +0,0 @@
1
- import { mkdir, writeFile } from "node:fs/promises";
2
- import { join } from "node:path";
3
- import { Type } from "typebox";
4
- import type {
5
- WorkflowRunContext,
6
- WorkflowSerializableObject,
7
- WorkflowSerializableValue,
8
- WorkflowTaskResult,
9
- } from "../src/shared/types.js";
10
- import { classify_trend, score_progress, type Trend } from "./progress-scoring.js";
11
- import {
12
- renderCompletionPrompt,
13
- renderEvaluationPrompt,
14
- renderIterationPrompt,
15
- } from "./loop-until-done-prompts.js";
16
- import { stableArtifactRoot } from "./pattern-artifact-root.js";
17
-
18
- const PROGRESS_DISCLAIMER = "Progress scores are a monitoring signal; VOC separation +0.079; never authoritative.";
19
-
20
- const evaluationSchema = Type.Object({
21
- done: Type.Boolean(),
22
- summary: Type.String(),
23
- new_findings: Type.Array(Type.String()),
24
- failures: Type.Array(Type.String()),
25
- validation_evidence: Type.Array(Type.String()),
26
- remaining_work: Type.String(),
27
- }, { additionalProperties: false });
28
-
29
- type LoopInputs = {
30
- readonly prompt: string;
31
- readonly max_iterations: number;
32
- readonly progress_scoring?: boolean;
33
- readonly progress_repeats?: number;
34
- } & Record<string, WorkflowSerializableValue>;
35
-
36
- type Evaluation = {
37
- readonly done: boolean;
38
- readonly summary: string;
39
- readonly newFindings: readonly string[];
40
- readonly failures: readonly string[];
41
- readonly validationEvidence: readonly string[];
42
- readonly remainingWork: string;
43
- };
44
- type LedgerProgress = {
45
- readonly score: number;
46
- readonly perRepeat: (number | null)[][];
47
- readonly trend: Trend;
48
- readonly window: number;
49
- };
50
- type LedgerEntry = {
51
- readonly iteration: number;
52
- readonly artifact_path: string;
53
- readonly evaluation_artifact_path: string;
54
- readonly summary: string;
55
- readonly findings: readonly string[];
56
- readonly failures: readonly string[];
57
- readonly validation_evidence: readonly string[];
58
- readonly done: boolean;
59
- readonly remaining_work: string;
60
- readonly progress?: LedgerProgress;
61
- };
62
-
63
- function progressCurve(entries: readonly LedgerEntry[]): number[] {
64
- return entries.flatMap((entry) => (entry.progress === undefined ? [] : [entry.progress.score]));
65
- }
66
-
67
- function progressReport(entries: readonly LedgerEntry[]): { curve: number[]; trend: Trend } {
68
- const curve = progressCurve(entries);
69
- return { curve, trend: classify_trend(curve).trend };
70
- }
71
-
72
- function formatProgressReport(report: { curve: readonly number[]; trend: Trend }): string {
73
- return [
74
- `Progress curve: ${JSON.stringify(report.curve)}`,
75
- `Final trend: ${report.trend}`,
76
- PROGRESS_DISCLAIMER,
77
- ].join("\n");
78
- }
79
-
80
- function repeatCount(input: LoopInputs): number {
81
- const repeats = input.progress_repeats;
82
- return typeof repeats === "number" && Number.isInteger(repeats) && repeats > 0 ? repeats : 1;
83
- }
84
-
85
- async function scoreIteration(
86
- ctx: WorkflowRunContext<LoopInputs>,
87
- task: string,
88
- entries: readonly LedgerEntry[],
89
- repeats: number,
90
- ): Promise<LedgerProgress | undefined> {
91
- try {
92
- const curve = await score_progress(ctx, {
93
- problem: task,
94
- steps: entries.map((entry) => entry.summary),
95
- checkpoints: [entries.length],
96
- repeats,
97
- });
98
- const score = curve.scores[0];
99
- if (score === null || score === undefined) return undefined;
100
- const trend = classify_trend([...progressCurve(entries), score]);
101
- return {
102
- score,
103
- perRepeat: curve.perRepeat,
104
- trend: trend.trend,
105
- window: trend.evidence.window,
106
- };
107
- } catch {
108
- return undefined;
109
- }
110
- }
111
- function serializableObject(
112
- value: WorkflowSerializableValue | undefined,
113
- ): WorkflowSerializableObject | undefined {
114
- if (value === null || Array.isArray(value) || typeof value !== "object") return undefined;
115
- return value as WorkflowSerializableObject;
116
- }
117
-
118
- function stringArray(value: WorkflowSerializableValue | undefined): readonly string[] | undefined {
119
- return Array.isArray(value) && value.every((item) => typeof item === "string")
120
- ? value
121
- : undefined;
122
- }
123
-
124
- function evaluationFrom(result: WorkflowTaskResult): Evaluation {
125
- const value = serializableObject(result.structured);
126
- if (value === undefined) {
127
- throw new Error(`loop-until-done: evaluator ${result.stageName} did not return a structured decision`);
128
- }
129
- const done = value.done;
130
- const summary = value.summary;
131
- const newFindings = stringArray(value.new_findings);
132
- const failures = stringArray(value.failures);
133
- const validationEvidence = stringArray(value.validation_evidence);
134
- const remainingWork = value.remaining_work;
135
- if (typeof done !== "boolean" || typeof summary !== "string" ||
136
- newFindings === undefined || failures === undefined || validationEvidence === undefined ||
137
- typeof remainingWork !== "string") {
138
- throw new Error(`loop-until-done: evaluator ${result.stageName} returned an invalid decision`);
139
- }
140
- return { done, summary, newFindings, failures, validationEvidence, remainingWork };
141
- }
142
-
143
- async function writeLedger(
144
- path: string,
145
- task: string,
146
- maxIterations: number,
147
- status: string,
148
- entries: readonly LedgerEntry[],
149
- ): Promise<void> {
150
- const report = progressReport(entries);
151
- await writeFile(path, `${JSON.stringify({
152
- task,
153
- max_iterations: maxIterations,
154
- status,
155
- iterations_completed: entries.length,
156
- entries,
157
- progress_curve: report.curve,
158
- final_trend: report.trend,
159
- progress_disclaimer: PROGRESS_DISCLAIMER,
160
- }, null, 2)}\n`);
161
- }
162
-
163
- export async function runLoopUntilDone(ctx: WorkflowRunContext<LoopInputs>) {
164
- const artifactDir = await stableArtifactRoot(ctx, "loop-until-done");
165
- const iterationsDir = join(artifactDir, "iterations");
166
- const evaluationsDir = join(artifactDir, "evaluations");
167
- await mkdir(iterationsDir, { recursive: true });
168
- await mkdir(evaluationsDir, { recursive: true });
169
- const ledgerPath = join(artifactDir, "progress-ledger.json");
170
- const entries: LedgerEntry[] = [];
171
- const iterationArtifactPaths: string[] = [];
172
- const evaluationArtifactPaths: string[] = [];
173
- await writeLedger(ledgerPath, ctx.inputs.prompt, ctx.inputs.max_iterations, "active", entries);
174
-
175
- for (let iteration = 1; iteration <= ctx.inputs.max_iterations; iteration += 1) {
176
- const iterationPath = join(iterationsDir, `iteration-${iteration}.md`);
177
- const evaluationPath = join(evaluationsDir, `evaluation-${iteration}.json`);
178
- iterationArtifactPaths.push(iterationPath);
179
- evaluationArtifactPaths.push(evaluationPath);
180
- await ctx.task(`iteration-${iteration}`, {
181
- prompt: renderIterationPrompt({
182
- task: ctx.inputs.prompt,
183
- iteration,
184
- maxIterations: ctx.inputs.max_iterations,
185
- ledgerPath,
186
- }),
187
- context: "fresh",
188
- reads: [ledgerPath, ...(iteration > 1 ? [iterationArtifactPaths[iteration - 2]!] : [])],
189
- output: iterationPath,
190
- outputMode: "file-only",
191
- });
192
- const evaluator = await ctx.task(`evaluate-${iteration}`, {
193
- prompt: renderEvaluationPrompt({
194
- task: ctx.inputs.prompt,
195
- iteration,
196
- ledgerPath,
197
- iterationPath,
198
- }),
199
- context: "fresh",
200
- reads: [ledgerPath, iterationPath],
201
- schema: evaluationSchema,
202
- });
203
- const decision = evaluationFrom(evaluator);
204
- // Evaluation reports are declared workflow outputs consumed as data: the
205
- // runner persists the structured decision itself so evaluation-N.json
206
- // stays schema-shaped JSON rather than stage prose.
207
- await writeFile(evaluationPath, `${JSON.stringify(evaluator.structured, null, 2)}\n`);
208
- const entry: LedgerEntry = {
209
- iteration,
210
- artifact_path: iterationPath,
211
- evaluation_artifact_path: evaluationPath,
212
- summary: decision.summary,
213
- findings: decision.newFindings,
214
- failures: decision.failures,
215
- validation_evidence: decision.validationEvidence,
216
- done: decision.done,
217
- remaining_work: decision.remainingWork,
218
- };
219
- entries.push(entry);
220
- if (ctx.inputs.progress_scoring !== false) {
221
- const progress = await scoreIteration(ctx, ctx.inputs.prompt, entries, repeatCount(ctx.inputs));
222
- if (progress !== undefined) entries[entries.length - 1] = { ...entry, progress };
223
- }
224
- await writeLedger(
225
- ledgerPath,
226
- ctx.inputs.prompt,
227
- ctx.inputs.max_iterations,
228
- decision.done ? "complete" : "active",
229
- entries,
230
- );
231
- if (decision.done) {
232
- const report = progressReport(entries);
233
- const resultPath = join(artifactDir, "result.md");
234
- const final = await ctx.task("completion-summary", {
235
- prompt: renderCompletionPrompt({ task: ctx.inputs.prompt, ledgerPath, iterationPath }),
236
- context: "fresh",
237
- reads: [ledgerPath, iterationPath],
238
- output: resultPath,
239
- // Keep the completion report out of the caller's context window;
240
- // `result_path` below carries it for callers that want the contents.
241
- outputMode: "file-only",
242
- });
243
- const result = `${final.text ? `${final.text.trimEnd()}\n\n` : ""}${formatProgressReport(report)}\n`;
244
- return {
245
- result,
246
- status: "complete" as const,
247
- iterations_completed: iteration,
248
- ledger_path: ledgerPath,
249
- iteration_artifact_paths: iterationArtifactPaths,
250
- evaluation_artifact_paths: evaluationArtifactPaths,
251
- result_path: resultPath,
252
- remaining_work: "",
253
- artifact_dir: artifactDir,
254
- progress_curve: report.curve,
255
- final_trend: report.trend,
256
- progress_disclaimer: PROGRESS_DISCLAIMER,
257
- };
258
- }
259
- }
260
-
261
- const last = entries.at(-1)!;
262
- const report = progressReport(entries);
263
- await writeLedger(ledgerPath, ctx.inputs.prompt, ctx.inputs.max_iterations, "failed", entries);
264
- const result = [
265
- `Iteration limit exhausted after ${ctx.inputs.max_iterations} iterations. Inspect ${ledgerPath}.`,
266
- formatProgressReport(report),
267
- ].join("\n\n");
268
- return {
269
- result,
270
- status: "failed" as const,
271
- iterations_completed: ctx.inputs.max_iterations,
272
- ledger_path: ledgerPath,
273
- iteration_artifact_paths: iterationArtifactPaths,
274
- evaluation_artifact_paths: evaluationArtifactPaths,
275
- result_path: ledgerPath,
276
- remaining_work: last.remaining_work,
277
- artifact_dir: artifactDir,
278
- progress_curve: report.curve,
279
- final_trend: report.trend,
280
- progress_disclaimer: PROGRESS_DISCLAIMER,
281
- };
282
- }
@@ -1,51 +0,0 @@
1
- import { Type } from "typebox";
2
- import { workflow } from "../src/authoring/workflow.js";
3
- import { withSteeringPropagationContext } from "./steering-context.js";
4
- import { runLoopUntilDone } from "./loop-until-done-runner.js";
5
-
6
- export default workflow({
7
- name: "loop-until-done",
8
- description: "Repeat evidence-producing work and independent completion evaluation against a durable ledger until done or an inspectable iteration-limit failure.",
9
- // The 15-minute default, stated rather than inherited: this is a per-workflow
10
- // product decision, so a future change to the global default must not silently
11
- // re-cadence a long autonomous run.
12
- heartbeatIntervalMinutes: 15,
13
- inputs: {
14
- prompt: Type.String({ description: "Objective whose explicit completion condition controls the bounded loop." }),
15
- max_iterations: Type.Integer({
16
- minimum: 1,
17
- maximum: 20,
18
- default: 5,
19
- description: "Maximum work/evaluation iterations before returning an inspectable failed status (1-20).",
20
- }),
21
- progress_scoring: Type.Boolean({
22
- default: true,
23
- description: "Enable advisory progress scoring after each completed iteration.",
24
- }),
25
- progress_repeats: Type.Integer({
26
- minimum: 1,
27
- default: 1,
28
- description: "Number of advisory progress-scoring repeats per iteration.",
29
- }),
30
- },
31
- outputs: {
32
- result: Type.String({ description: "Compact reference to the evidence-backed completion report, or the deterministic exhaustion report; read `result_path` for the full report." }),
33
- status: Type.Union([Type.Literal("complete"), Type.Literal("failed")], {
34
- description: "Complete when evidence satisfies the stop condition; failed when max_iterations is exhausted.",
35
- }),
36
- iterations_completed: Type.Integer({ description: "Number of completed work/evaluation iterations." }),
37
- ledger_path: Type.String({ description: "Path to the durable JSON progress ledger." }),
38
- iteration_artifact_paths: Type.Array(Type.String(), { description: "Ordered paths to per-iteration work artifacts." }),
39
- evaluation_artifact_paths: Type.Array(Type.String(), { description: "Ordered paths to structured evaluation artifacts." }),
40
- result_path: Type.String({ description: "Path to the final report, or the ledger on exhausted failure." }),
41
- remaining_work: Type.String({ description: "Actionable remaining work; empty only after proven completion." }),
42
- artifact_dir: Type.String({ description: "Run-specific directory containing loop artifacts." }),
43
- progress_curve: Type.Array(Type.Number(), { description: "Advisory progress scores in iteration order." }),
44
- final_trend: Type.Union(
45
- [Type.Literal("rising"), Type.Literal("flat"), Type.Literal("regressing")],
46
- { description: "Final advisory trend classification; never a stop decision." },
47
- ),
48
- progress_disclaimer: Type.String({ description: "Calibration disclaimer for the advisory progress signal." }),
49
- },
50
- run: async (ctx) => await runLoopUntilDone(withSteeringPropagationContext(ctx)),
51
- });