@yycholla/pi-dynamic-workflows 3.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (179) hide show
  1. package/LICENSE +22 -0
  2. package/README.md +325 -0
  3. package/assets/readme/hero.png +0 -0
  4. package/assets/readme/hero.svg +70 -0
  5. package/assets/readme/package-cover.png +0 -0
  6. package/assets/readme/package-cover.svg +66 -0
  7. package/assets/readme/workflow.png +0 -0
  8. package/assets/readme/workflow.svg +77 -0
  9. package/dist/accept-workflow-guidance.d.ts +14 -0
  10. package/dist/accept-workflow-guidance.js +53 -0
  11. package/dist/adversarial-review.d.ts +30 -0
  12. package/dist/adversarial-review.js +107 -0
  13. package/dist/agent-history.d.ts +20 -0
  14. package/dist/agent-history.js +122 -0
  15. package/dist/agent-registry.d.ts +83 -0
  16. package/dist/agent-registry.js +190 -0
  17. package/dist/agent.d.ts +364 -0
  18. package/dist/agent.js +714 -0
  19. package/dist/builtin-commands.d.ts +19 -0
  20. package/dist/builtin-commands.js +251 -0
  21. package/dist/builtin-workflows.d.ts +45 -0
  22. package/dist/builtin-workflows.js +121 -0
  23. package/dist/code-review.d.ts +26 -0
  24. package/dist/code-review.js +181 -0
  25. package/dist/config.d.ts +37 -0
  26. package/dist/config.js +44 -0
  27. package/dist/deep-research.d.ts +30 -0
  28. package/dist/deep-research.js +124 -0
  29. package/dist/display.d.ts +134 -0
  30. package/dist/display.js +248 -0
  31. package/dist/effort-command.d.ts +28 -0
  32. package/dist/effort-command.js +68 -0
  33. package/dist/enums.d.ts +69 -0
  34. package/dist/enums.js +78 -0
  35. package/dist/errors.d.ts +113 -0
  36. package/dist/errors.js +140 -0
  37. package/dist/extension-reload.d.ts +37 -0
  38. package/dist/extension-reload.js +78 -0
  39. package/dist/fs-persistence.d.ts +63 -0
  40. package/dist/fs-persistence.js +102 -0
  41. package/dist/index.d.ts +57 -0
  42. package/dist/index.js +35 -0
  43. package/dist/logger.d.ts +21 -0
  44. package/dist/logger.js +66 -0
  45. package/dist/model-routing.d.ts +30 -0
  46. package/dist/model-routing.js +50 -0
  47. package/dist/model-spec.d.ts +29 -0
  48. package/dist/model-spec.js +252 -0
  49. package/dist/model-tier-config.d.ts +133 -0
  50. package/dist/model-tier-config.js +249 -0
  51. package/dist/run-persistence.d.ts +180 -0
  52. package/dist/run-persistence.js +294 -0
  53. package/dist/saved-commands.d.ts +28 -0
  54. package/dist/saved-commands.js +100 -0
  55. package/dist/shared-store.d.ts +98 -0
  56. package/dist/shared-store.js +212 -0
  57. package/dist/structured-output.d.ts +19 -0
  58. package/dist/structured-output.js +30 -0
  59. package/dist/task-panel.d.ts +61 -0
  60. package/dist/task-panel.js +422 -0
  61. package/dist/usage-limit-scheduler.d.ts +145 -0
  62. package/dist/usage-limit-scheduler.js +368 -0
  63. package/dist/web-tools.d.ts +20 -0
  64. package/dist/web-tools.js +120 -0
  65. package/dist/workflow-authoring-coverage.d.ts +70 -0
  66. package/dist/workflow-authoring-coverage.js +421 -0
  67. package/dist/workflow-authoring-reference.d.ts +20 -0
  68. package/dist/workflow-authoring-reference.js +156 -0
  69. package/dist/workflow-capability-contract.d.ts +131 -0
  70. package/dist/workflow-capability-contract.js +604 -0
  71. package/dist/workflow-commands.d.ts +18 -0
  72. package/dist/workflow-commands.js +260 -0
  73. package/dist/workflow-comprehension.d.ts +133 -0
  74. package/dist/workflow-comprehension.js +1321 -0
  75. package/dist/workflow-context-measurement.d.ts +72 -0
  76. package/dist/workflow-context-measurement.js +213 -0
  77. package/dist/workflow-control-tool.d.ts +30 -0
  78. package/dist/workflow-control-tool.js +176 -0
  79. package/dist/workflow-delivery-choice.d.ts +20 -0
  80. package/dist/workflow-delivery-choice.js +48 -0
  81. package/dist/workflow-editor.d.ts +93 -0
  82. package/dist/workflow-editor.js +363 -0
  83. package/dist/workflow-manager.d.ts +492 -0
  84. package/dist/workflow-manager.js +1124 -0
  85. package/dist/workflow-paths.d.ts +22 -0
  86. package/dist/workflow-paths.js +46 -0
  87. package/dist/workflow-release-gate.d.ts +39 -0
  88. package/dist/workflow-release-gate.js +309 -0
  89. package/dist/workflow-saved.d.ts +38 -0
  90. package/dist/workflow-saved.js +126 -0
  91. package/dist/workflow-settings.d.ts +70 -0
  92. package/dist/workflow-settings.js +131 -0
  93. package/dist/workflow-tool.d.ts +71 -0
  94. package/dist/workflow-tool.js +367 -0
  95. package/dist/workflow-ui.d.ts +182 -0
  96. package/dist/workflow-ui.js +1587 -0
  97. package/dist/workflow.d.ts +333 -0
  98. package/dist/workflow.js +1151 -0
  99. package/dist/workflows-models-command.d.ts +31 -0
  100. package/dist/workflows-models-command.js +156 -0
  101. package/dist/worktree.d.ts +25 -0
  102. package/dist/worktree.js +61 -0
  103. package/extensions/workflow.ts +151 -0
  104. package/package.json +104 -0
  105. package/skills/workflow-authoring/SKILL.md +30 -0
  106. package/skills/workflow-authoring/examples/adversarial-verification.js +63 -0
  107. package/skills/workflow-authoring/examples/bounded-semantic-retry.js +56 -0
  108. package/skills/workflow-authoring/examples/classify-and-act.js +67 -0
  109. package/skills/workflow-authoring/examples/fan-out-and-synthesize.js +47 -0
  110. package/skills/workflow-authoring/examples/generate-and-filter.js +68 -0
  111. package/skills/workflow-authoring/examples/loop-until-done.js +68 -0
  112. package/skills/workflow-authoring/examples/phased-budgets.js +75 -0
  113. package/skills/workflow-authoring/examples/saved-nested-workflows.js +44 -0
  114. package/skills/workflow-authoring/examples/structured-output.js +37 -0
  115. package/skills/workflow-authoring/examples/tournament.js +81 -0
  116. package/skills/workflow-authoring/examples/validated-gate.js +63 -0
  117. package/skills/workflow-authoring/references/capabilities.md +41 -0
  118. package/skills/workflow-authoring/references/capability-details.md +357 -0
  119. package/skills/workflow-authoring/references/common-helpers.md +4 -0
  120. package/skills/workflow-authoring/references/debugging.md +27 -0
  121. package/skills/workflow-authoring/references/focused-recipes.md +11 -0
  122. package/skills/workflow-authoring/references/helpers.md +9 -0
  123. package/skills/workflow-authoring/references/lifecycle.md +33 -0
  124. package/skills/workflow-authoring/references/pattern-selection.md +15 -0
  125. package/skills/workflow-authoring/references/quality-helpers.md +8 -0
  126. package/skills/workflow-authoring/references/registry-ownership.md +15 -0
  127. package/skills/workflow-authoring/references/retry-helper.md +5 -0
  128. package/skills/workflow-authoring/references/review.md +43 -0
  129. package/skills/workflow-authoring/references/runtime.md +27 -0
  130. package/skills/workflow-authoring/references/specialized-helpers.md +19 -0
  131. package/skills/workflow-authoring/references/versions.md +13 -0
  132. package/skills/workflow-patterns/SKILL.md +51 -0
  133. package/src/accept-workflow-guidance.ts +71 -0
  134. package/src/adversarial-review.ts +120 -0
  135. package/src/agent-history.ts +157 -0
  136. package/src/agent-registry.ts +221 -0
  137. package/src/agent.ts +929 -0
  138. package/src/builtin-commands.ts +286 -0
  139. package/src/builtin-workflows.ts +155 -0
  140. package/src/code-review.ts +183 -0
  141. package/src/config.ts +55 -0
  142. package/src/deep-research.ts +135 -0
  143. package/src/display.ts +367 -0
  144. package/src/effort-command.ts +87 -0
  145. package/src/enums.ts +77 -0
  146. package/src/errors.ts +199 -0
  147. package/src/extension-reload.ts +100 -0
  148. package/src/fs-persistence.ts +124 -0
  149. package/src/index.ts +176 -0
  150. package/src/logger.ts +88 -0
  151. package/src/model-routing.ts +73 -0
  152. package/src/model-spec.ts +309 -0
  153. package/src/model-tier-config.ts +296 -0
  154. package/src/run-persistence.ts +484 -0
  155. package/src/saved-commands.ts +115 -0
  156. package/src/shared-store.ts +228 -0
  157. package/src/structured-output.ts +47 -0
  158. package/src/task-panel.ts +490 -0
  159. package/src/usage-limit-scheduler.ts +432 -0
  160. package/src/web-tools.ts +124 -0
  161. package/src/workflow-authoring-coverage.ts +486 -0
  162. package/src/workflow-authoring-reference.ts +186 -0
  163. package/src/workflow-capability-contract.ts +806 -0
  164. package/src/workflow-commands.ts +287 -0
  165. package/src/workflow-comprehension.ts +1673 -0
  166. package/src/workflow-context-measurement.ts +262 -0
  167. package/src/workflow-control-tool.ts +238 -0
  168. package/src/workflow-delivery-choice.ts +69 -0
  169. package/src/workflow-editor.ts +444 -0
  170. package/src/workflow-manager.ts +1405 -0
  171. package/src/workflow-paths.ts +63 -0
  172. package/src/workflow-release-gate.ts +529 -0
  173. package/src/workflow-saved.ts +180 -0
  174. package/src/workflow-settings.ts +194 -0
  175. package/src/workflow-tool.ts +464 -0
  176. package/src/workflow-ui.ts +1789 -0
  177. package/src/workflow.ts +1615 -0
  178. package/src/workflows-models-command.ts +211 -0
  179. package/src/worktree.ts +76 -0
@@ -0,0 +1,357 @@
1
+ <!-- GENERATED from WORKFLOW_CAPABILITY_CONTRACT; do not edit by hand. -->
2
+ # Exhaustive workflow capability facts
3
+
4
+ Contract format: `1.0.0`<br>
5
+ Contract content / skill / extension: `3.3.0`
6
+
7
+ Every exact fact below is projected from the installed extension's capability contract. Explanatory judgment belongs in the hand-written references next to this file.
8
+
9
+ <a id="agent"></a>
10
+ ## agent
11
+
12
+ - Classification: `runtime-global`
13
+ - Support: `supported`
14
+ - Signature: `agent(prompt, options?) => Promise<string \| structured value \| null>`
15
+ - Option shape: `agent-options`
16
+ - `label`: string (optional; default: derived from phase and call count)
17
+ - `phase`: string (optional; default: current phase)
18
+ - `schema`: plain JSON Schema (optional)
19
+ - `model`: string (optional; highest-priority exact model selector)
20
+ - `tier`: string (optional; configured route name; dynamic reference: model-routes)
21
+ - `isolation`: "worktree" (optional)
22
+ - `agentType`: string (optional; must come from provided context; dynamic reference: agent-types)
23
+ - `timeoutMs`: number | null (optional; default: run timeout; null disables)
24
+ - `retries`: number (optional; default: run retry count; finite values are floored and clamped to 0..3)
25
+ - Constraint: recoverable failures return null after retries; nonrecoverable failures throw
26
+ - Constraint: schema noncompliance after bounded structured-output repair is nonrecoverable and bypasses agent retries
27
+ - Constraint: per-agent retries override invocation retries; retries are floored and clamped to 0..3
28
+ - Constraint: resume replays only the longest unchanged prefix; the first miss and every later call execute live
29
+ - Constraint: selector priority is explicit model > agentType model > tier > phase model > metadata model > implicit medium > session default
30
+ - Constraint: if the selected model or route is unavailable, execution falls directly to the session default rather than trying lower-priority selectors
31
+ - Constraint: worktree isolation is best-effort; failure logs that isolation was ignored and continues without an isolated working directory
32
+
33
+ <a id="parallel"></a>
34
+ ## parallel
35
+
36
+ - Classification: `runtime-global`
37
+ - Support: `supported`
38
+ - Signature: `parallel(thunks) => Promise<Array<unknown \| null>>`
39
+ - Constraint: requires functions rather than promises
40
+ - Constraint: result order matches input order
41
+ - Constraint: recoverable thunk failures become null; nonrecoverable failures throw
42
+
43
+ <a id="pipeline"></a>
44
+ ## pipeline
45
+
46
+ - Classification: `runtime-global`
47
+ - Support: `supported`
48
+ - Signature: `pipeline(items, ...stages) => Promise<Array<unknown \| null>>`
49
+ - Constraint: items run concurrently while stages per item run sequentially
50
+ - Constraint: each stage receives previousValue, originalItem, and zero-based index
51
+ - Constraint: a null stage result is passed to the next stage; authors must guard missing coverage explicitly
52
+ - Constraint: recoverable stage failures become null; nonrecoverable failures throw
53
+
54
+ <a id="workflow"></a>
55
+ ## workflow
56
+
57
+ - Classification: `runtime-global`
58
+ - Support: `supported`
59
+ - Signature: `workflow(savedName, childArgs?) => Promise<unknown>`
60
+ - Constraint: one nested level
61
+ - Constraint: shares limiter, counters, token accounting, and store
62
+ - Constraint: nested workflows do not reuse the parent resume journal
63
+
64
+ <a id="verify"></a>
65
+ ## verify
66
+
67
+ - Classification: `runtime-global`
68
+ - Support: `supported`
69
+ - Signature: `verify(item: unknown, options?: { reviewers?: number; threshold?: number; lens?: string \| string[] }) => Promise<{ real: boolean; realCount: number; total: number; votes: Array<{ real: boolean; reason?: string }> }>`
70
+ - Option shape: `verify-options`
71
+ - `reviewers`: number (optional; default: 2; authors should provide a finite integer; runtime clamps below 1)
72
+ - `threshold`: number (optional; default: 0.5)
73
+ - `lens`: string | string[] (optional)
74
+ - Constraint: reviewer failures are omitted; successful votes form the denominator in realCount / total
75
+ - Constraint: threshold comparison is inclusive and real is false when no reviewer succeeds
76
+ - Constraint: multiple lenses cycle across reviewers
77
+
78
+ <a id="judgepanel"></a>
79
+ ## judgePanel
80
+
81
+ - Classification: `runtime-global`
82
+ - Support: `supported`
83
+ - Signature: `judgePanel(attempts: unknown[], options?: { judges?: number; rubric?: string }) => Promise<{ index: number; attempt: unknown; score: number; judgments: Array<{ score: number; reason?: string }> } \| undefined>`
84
+ - Option shape: `judge-panel-options`
85
+ - `judges`: number (optional; default: 3; authors should provide a finite integer; runtime clamps below 1)
86
+ - `rubric`: string (optional; default: "overall quality and correctness")
87
+ - Constraint: failed judgments are omitted and each candidate score averages successful judgments only
88
+ - Constraint: a candidate with no successful judgments scores 0
89
+ - Constraint: highest mean score wins with stable input index as the tie-break; empty input returns undefined
90
+
91
+ <a id="loopuntildry"></a>
92
+ ## loopUntilDry
93
+
94
+ - Classification: `runtime-global`
95
+ - Support: `supported`
96
+ - Signature: `loopUntilDry(options: { round: (roundIndex: number) => unknown[] \| Promise<unknown[]>; key?: (item: unknown) => string; consecutiveEmpty?: number; maxRounds?: number }) => Promise<unknown[]>`
97
+ - Option shape: `loop-until-dry-options`
98
+ - `round`: (roundIndex: number) => unknown[] | Promise<unknown[]> (required)
99
+ - `key`: (item: unknown) => string (optional; default: JSON.stringify)
100
+ - `consecutiveEmpty`: number (optional; default: 2; authors should provide a finite integer; runtime clamps below 1)
101
+ - `maxRounds`: number (optional; default: 50; authors should provide a finite positive integer)
102
+ - Constraint: roundIndex is zero-based; null, non-array, or duplicate-only round results count as empty
103
+ - Constraint: token-budget or agent-limit capacity exhaustion returns the accumulated partial array instead of throwing
104
+ - Constraint: the returned array does not report whether termination came from dryness, maxRounds, or capacity exhaustion
105
+ - Constraint: authors must retain failed-round identity and truthful termination state outside the helper
106
+
107
+ <a id="completenesscheck"></a>
108
+ ## completenessCheck
109
+
110
+ - Classification: `runtime-global`
111
+ - Support: `supported`
112
+ - Signature: `completenessCheck(taskArgs: unknown, results: unknown) => Promise<{ complete: boolean; missing?: string[] } \| null>`
113
+ - Constraint: only the first 4,000 characters of serialized result evidence are sent to the critic
114
+ - Constraint: missing is optional and recoverable critic failure returns null
115
+ - Constraint: large evidence sets must be chunked or summarized before relying on the advisory verdict
116
+
117
+ <a id="retry"></a>
118
+ ## retry
119
+
120
+ - Classification: `runtime-global`
121
+ - Support: `supported`
122
+ - Signature: `retry(thunk: (attempt: number) => unknown \| Promise<unknown>, options?: { attempts?: number; until?: (result: unknown) => boolean }) => Promise<unknown>`
123
+ - Option shape: `retry-options`
124
+ - `attempts`: number (optional; default: 3; authors must provide a finite integer; runtime clamps values below 1 to 1)
125
+ - `until`: (result: unknown) => boolean (optional; default: accept first result when omitted; must be synchronous; use gate for asynchronous validation)
126
+ - Constraint: attempt is zero-based and attempts counts total thunk calls
127
+ - Constraint: until is synchronous; returning a Promise is truthy and accepts the first result
128
+ - Constraint: omitting until accepts the first result regardless of attempts
129
+ - Constraint: stops when until(result) is true; exhaustion returns only the last result without attempt metadata
130
+ - Constraint: authors must supply a finite attempts bound when overriding the default
131
+
132
+ <a id="gate"></a>
133
+ ## gate
134
+
135
+ - Classification: `runtime-global`
136
+ - Support: `supported`
137
+ - Signature: `gate(thunk: (feedback: string \| undefined, attempt: number) => unknown \| Promise<unknown>, validator: (value: unknown) => { ok: boolean; feedback?: string } \| Promise<{ ok: boolean; feedback?: string }>, options?: { attempts?: number }) => Promise<{ ok: boolean; value: unknown; attempts: number }>`
138
+ - Option shape: `gate-options`
139
+ - `attempts`: number (optional; default: 3; authors must provide a finite integer; runtime clamps values below 1 to 1)
140
+ - Constraint: feedback is undefined on the first thunk call and then receives the previous validator feedback string
141
+ - Constraint: attempt is zero-based for the thunk while the returned attempts count is one-based
142
+ - Constraint: a value is accepted when the validator returns an object with a truthy ok property; a bare boolean is not accepted
143
+ - Constraint: exhaustion returns ok false with the last value and the bounded attempts count
144
+ - Constraint: authors must supply a finite attempts bound when overriding the default
145
+
146
+ <a id="checkpoint"></a>
147
+ ## checkpoint
148
+
149
+ - Classification: `runtime-global`
150
+ - Support: `supported`
151
+ - Signature: `checkpoint(prompt, options?) => Promise<unknown>`
152
+ - Option shape: `checkpoint-options`
153
+ - `default`: unknown (optional; default: true when no UI and omitted)
154
+ - `headless`: "default" | "abort" (optional; default: "default")
155
+ - `kind`: "confirm" | "input" | "select" (optional; default: "confirm")
156
+ - `choices`: string[] (optional)
157
+ - `timeoutMs`: number (optional)
158
+ - Constraint: foreground confirm and headless behavior are implemented; input/select/timeout are declared-only
159
+ - Constraint: consumes one agent slot and no tokens
160
+ - Constraint: journaled answers replay only within an unchanged resume prefix
161
+
162
+ <a id="log"></a>
163
+ ## log
164
+
165
+ - Classification: `runtime-global`
166
+ - Support: `supported`
167
+ - Signature: `log(message) => void`
168
+
169
+ <a id="phase"></a>
170
+ ## phase
171
+
172
+ - Classification: `runtime-global`
173
+ - Support: `supported`
174
+ - Signature: `phase(title, options?) => void`
175
+ - Option shape: `phase-options`
176
+ - `budget`: number (optional; positive soft pre-call token gate)
177
+ - Constraint: phase budgets are soft pre-call gates
178
+
179
+ <a id="args"></a>
180
+ ## args
181
+
182
+ - Classification: `runtime-global`
183
+ - Support: `supported`
184
+ - Signature: `args: unknown`
185
+
186
+ <a id="cwd"></a>
187
+ ## cwd
188
+
189
+ - Classification: `runtime-global`
190
+ - Support: `supported`
191
+ - Signature: `cwd: string`
192
+
193
+ <a id="process"></a>
194
+ ## process
195
+
196
+ - Classification: `runtime-global`
197
+ - Support: `supported`
198
+ - Signature: `process: { cwd(): string }`
199
+
200
+ <a id="budget"></a>
201
+ ## budget
202
+
203
+ - Classification: `runtime-global`
204
+ - Support: `supported`
205
+ - Signature: `budget: { total, spent(), remaining() }`
206
+ - Constraint: frozen view over shared soft token accounting
207
+ - Constraint: spend accrues after agents finish, so in-flight work can overshoot
208
+ - Constraint: nested workflows share the same accounting
209
+
210
+ <a id="console"></a>
211
+ ## console
212
+
213
+ - Classification: `runtime-global`
214
+ - Support: `compatibility`
215
+ - Signature: `console: { log, info, warn, error }`
216
+ - Constraint: new workflows should use log()
217
+
218
+ <a id="tool-input-script"></a>
219
+ ## script
220
+
221
+ - Classification: `workflow-tool-input`
222
+ - Support: `supported`
223
+ - Signature: `script?: string`
224
+ - Constraint: required raw JavaScript workflow source unless `name` is given
225
+
226
+ <a id="tool-input-name"></a>
227
+ ## name
228
+
229
+ - Classification: `workflow-tool-input`
230
+ - Support: `supported`
231
+ - Signature: `name?: string`
232
+ - Constraint: resolves a project/user saved workflow first, then one of the 5 built-in patterns
233
+ - Constraint: mutually exclusive with resumeFromRunId
234
+
235
+ <a id="tool-input-args"></a>
236
+ ## args
237
+
238
+ - Classification: `workflow-tool-input`
239
+ - Support: `supported`
240
+ - Signature: `args?: unknown`
241
+
242
+ <a id="tool-input-background"></a>
243
+ ## background
244
+
245
+ - Classification: `workflow-tool-input`
246
+ - Support: `supported`
247
+ - Signature: `background?: boolean = true`
248
+ - Constraint: background workflows are headless; use background false when checkpoint must show foreground confirmation
249
+
250
+ <a id="tool-input-maxagents"></a>
251
+ ## maxAgents
252
+
253
+ - Classification: `workflow-tool-input`
254
+ - Support: `supported`
255
+ - Signature: `maxAgents?: number = 1000`
256
+ - Constraint: default, not a hard product maximum
257
+
258
+ <a id="tool-input-concurrency"></a>
259
+ ## concurrency
260
+
261
+ - Classification: `workflow-tool-input`
262
+ - Support: `supported`
263
+ - Signature: `concurrency?: number`
264
+ - Constraint: runtime clamps to 1..16
265
+
266
+ <a id="tool-input-agentretries"></a>
267
+ ## agentRetries
268
+
269
+ - Classification: `workflow-tool-input`
270
+ - Support: `supported`
271
+ - Signature: `agentRetries?: number = configured value or 0`
272
+ - Constraint: floored and clamped to 0..3
273
+
274
+ <a id="tool-input-agenttimeoutms"></a>
275
+ ## agentTimeoutMs
276
+
277
+ - Classification: `workflow-tool-input`
278
+ - Support: `supported`
279
+ - Signature: `agentTimeoutMs?: number = configured default or unbounded`
280
+
281
+ <a id="tool-input-tokenbudget"></a>
282
+ ## tokenBudget
283
+
284
+ - Classification: `workflow-tool-input`
285
+ - Support: `supported`
286
+ - Signature: `tokenBudget?: number = configured default or unlimited`
287
+ - Constraint: soft pre-call gate; in-flight work can overshoot
288
+
289
+ <a id="tool-input-resumefromrunid"></a>
290
+ ## resumeFromRunId
291
+
292
+ - Classification: `workflow-tool-input`
293
+ - Support: `supported`
294
+ - Signature: `resumeFromRunId?: string`
295
+ - Constraint: resumes a prior incomplete run with an edited script
296
+ - Constraint: unchanged positional agent calls replay from cache until the first changed or inserted call
297
+ - Constraint: always runs in the background
298
+
299
+ <a id="metadata"></a>
300
+ ## export const meta
301
+
302
+ - Classification: `script-contract`
303
+ - Support: `supported`
304
+ - Signature: `export const meta = { name: string, description: string, phases?: Array<{ title: string; detail?: string; model?: string }>, model?: string }`
305
+ - Constraint: must be the first statement
306
+ - Constraint: name and description must be nonblank strings
307
+ - Constraint: metadata must use literal values; expressions such as string concatenation and template interpolation are rejected
308
+ - Constraint: the meta declaration is the only legal export because the remaining body executes inside an async function
309
+
310
+ <a id="return-value"></a>
311
+ ## workflow return value
312
+
313
+ - Classification: `script-contract`
314
+ - Support: `supported`
315
+ - Signature: `return JSON-serializable data`
316
+ - Constraint: do not return functions, promises, cyclic objects, BigInt, or runtime handles
317
+
318
+ <a id="determinism"></a>
319
+ ## deterministic script execution
320
+
321
+ - Classification: `script-contract`
322
+ - Support: `supported`
323
+ - Signature: —
324
+ - Constraint: Date.now(), Math.random(), and no-argument new Date() are unavailable
325
+ - Constraint: pass timestamps and randomness through args
326
+
327
+ <a id="compatibility"></a>
328
+ ## whole-script Markdown fence stripping
329
+
330
+ - Classification: `compatibility-behavior`
331
+ - Support: `compatibility`
332
+ - Signature: —
333
+ - Constraint: accepted for compatibility but not recommended
334
+
335
+ <a id="model-routes"></a>
336
+ ## model routes
337
+
338
+ - Classification: `dynamic-reference`
339
+ - Support: `supported`
340
+ - Signature: —
341
+ - Constraint: live values must not be copied into static contract data
342
+ - Dynamic reference owner: `model-tier-config`
343
+ - Item shape: `{ name: string; description?: string }`
344
+ - Future lookup connection: `loadModelTierConfig`
345
+ - Live values are intentionally absent from this static reference.
346
+
347
+ <a id="agent-types"></a>
348
+ ## agent types
349
+
350
+ - Classification: `dynamic-reference`
351
+ - Support: `supported`
352
+ - Signature: —
353
+ - Constraint: live values must not be copied into static contract data
354
+ - Dynamic reference owner: `agent-registry`
355
+ - Item shape: `{ name: string; description?: string }`
356
+ - Future lookup connection: `loadAgentRegistry`
357
+ - Live values are intentionally absent from this static reference.
@@ -0,0 +1,4 @@
1
+ # Common helper index
2
+
3
+ - Read [quality helpers](quality-helpers.md) for `verify()` or `judgePanel()`.
4
+ - Read the [retry helper](retry-helper.md) for `retry()`.
@@ -0,0 +1,27 @@
1
+ # Workflow debugging map
2
+
3
+ Start from the symptom, then reproduce through the real workflow runtime with deterministic fake agents.
4
+
5
+ | Symptom | Likely authoring cause | Check |
6
+ | --- | --- | --- |
7
+ | Parser says metadata is missing | `export const meta` is not the first statement or is nonliteral | [runtime](runtime.md#script-envelope) |
8
+ | `parallel()` rejects input | Promises were passed instead of thunks | [runtime](runtime.md#topology) |
9
+ | Synthesis starts early | Fan-out was not awaited as one complete result set | [pattern selection](pattern-selection.md#fan-out-and-synthesize) |
10
+ | Coverage silently disappears | `null` results were filtered before IDs were ledgered | [lifecycle](lifecycle.md#retry-and-recoverable-failure) |
11
+ | Wrong model is used | A higher-priority selector overrides the expected route | [registry ownership](registry-ownership.md#priority) |
12
+ | Unknown `agentType` log | A live registry name was guessed or is unavailable | [registry ownership](registry-ownership.md#agent-types) |
13
+ | Budget exceeds the number shown | The budget is a soft pre-call gate and work was in flight | [lifecycle](lifecycle.md#bounds-and-budget) |
14
+ | Later calls rerun on resume | An earlier call missed or changed, ending the replayable prefix | [lifecycle](lifecycle.md#resume) |
15
+ | Nested workflow fails | Nesting exceeded one level or shared limits were exhausted | [lifecycle](lifecycle.md#nesting-and-shared-state) |
16
+ | Checkpoint does not show a form | Input/select/timeout behavior is declared-only | [lifecycle](lifecycle.md#checkpoints) |
17
+ | Returned result cannot cross boundary | It contains a function, promise, cycle, `BigInt`, or runtime object | [lifecycle](lifecycle.md#serialization) |
18
+ | `Date.now()`/randomness is rejected | Resume requires deterministic call structure | [lifecycle](lifecycle.md#resume) |
19
+
20
+ ## Debugging procedure
21
+
22
+ 1. Reduce to the smallest script that preserves metadata, labels, work IDs, and the failing topology.
23
+ 2. Replace provider calls with deterministic, schema-aware fake agents.
24
+ 3. Record call order, labels, phases, prompts, results, and `null` entries.
25
+ 4. When the failure turns on a disputed signature or default, compare it with the compact [capability index](capabilities.md); follow its exhaustive-facts pointer only when needed.
26
+ 5. Separate runtime defects from unsupported authoring assumptions and compatibility-only behavior.
27
+ 6. Fix only the demonstrated authoring issue; do not rely on known out-of-scope gaps in nested persistence, resume accounting, checkpoint forms/timeouts, metadata validation, or budget overshoot.
@@ -0,0 +1,11 @@
1
+ # Focused recipes
2
+
3
+ Read only the recipe matching the concern. Change task prompts, schemas, bounds, and context-supplied inputs; preserve the listed contract.
4
+
5
+ | Concern | Preserve when adapting | Tested recipe |
6
+ | --- | --- | --- |
7
+ | Phased budgets | Phase and run budgets are soft pre-call gates; active work can overshoot. Report shared spend and bound calls independently. | [Phased budgets](../examples/phased-budgets.js) |
8
+ | Saved workflows | Use a context-supplied name, await jobs sequentially, nest one level, and treat shared limits, counters, tokens, limiter, and store as parent capacity. | [Saved nested workflows](../examples/saved-nested-workflows.js) |
9
+ | Semantic retry | Separate it from recoverable runtime retries. Use a new unique label per bounded attempt and return the attempt ledger plus exhausted outcome. | [Bounded semantic retry](../examples/bounded-semantic-retry.js) |
10
+ | Validator feedback | Follow the exact `gate()` callbacks in [specialized helpers](specialized-helpers.md). Return the gate outcome and attempt ledger so feedback and exhaustion remain visible. | [Validated gate](../examples/validated-gate.js) |
11
+ | Structured fields | Pass a small plain JSON Schema before reading fields. Ledger recoverable `null`; treat exhausted schema repair as a nonrecoverable failure. | [Structured output](../examples/structured-output.js) |
@@ -0,0 +1,9 @@
1
+ # Helper reference index
2
+
3
+ Use a helper only when it expresses the task's policy. Preserve candidate or work identity outside helper results that may omit failed agents.
4
+
5
+ - Read [quality helpers](quality-helpers.md) for `verify()` or `judgePanel()`.
6
+ - Read the [retry helper](retry-helper.md) for `retry()`.
7
+ - Read [specialized helpers](specialized-helpers.md) for `completenessCheck()`, `loopUntilDry()`, `gate()`, or `checkpoint()`.
8
+
9
+ Runtime agent retries repeat recoverable execution failures; helper attempts are new semantic calls. Bound both layers and ledger exhaustion.
@@ -0,0 +1,33 @@
1
+ # Lifecycle, limits, and resume
2
+
3
+ ## Bounds and budget
4
+
5
+ Set finite bounds that match the work: `maxAgents`, `concurrency`, `agentRetries`, `agentTimeoutMs`, and `tokenBudget` at invocation time; loop and semantic-retry bounds inside the script. An omitted `agentTimeoutMs` uses the configured `defaultAgentTimeoutMs` and is otherwise unbounded. An omitted `tokenBudget` uses the configured `defaultTokenBudget` and is otherwise unlimited.
6
+
7
+ Enter a phase budget with `phase("Name", { budget: N })`; phase metadata does not carry budgets. `N` is a token allowance, not a call or round count: size it for the intended agent work instead of copying a small iteration limit. Token and phase budgets are soft pre-call gates. Spend lands after agents finish, so concurrent work can overshoot. A phase budget gates later calls in that phase; it neither reserves tokens nor cancels active calls. `budget.spent()` and `budget.remaining()` include nested work.
8
+
9
+ ## Checkpoints
10
+
11
+ A checkpoint consumes an agent slot but no tokens. A workflow invocation is backgrounded by default, and background workflows are headless: they cannot display checkpoint confirmation. Use `background: false` when a checkpoint must reach the foreground host confirmation interface. Without a UI, a checkpoint returns the declared default (or `true` when omitted) unless `headless: "abort"` is selected. Confirm is implemented. Input, select, and timeout fields are declared for compatibility/future behavior but are not authoring promises.
12
+
13
+ Checkpoint answers are journaled and can replay during an unchanged resume prefix. Do not describe checkpoints as guaranteed arbitrary forms or as remote steering.
14
+
15
+ ## Retry and recoverable failure
16
+
17
+ Recoverable execution failures retry according to the per-agent option or invocation-time tool input, then return `null`. Nonrecoverable failures throw without becoming `null`. The logical `retry()` combinator is separate: it performs new agent calls and returns its last result when exhausted unless the script records and handles that outcome.
18
+
19
+ Always retain `{ id, status, result }` or an equivalent ledger for each intended work unit. Filtering `null` before recording identity turns an execution failure into invisible missing coverage.
20
+
21
+ ## Resume
22
+
23
+ Resume replays only the longest unchanged prefix of journaled calls. Once one call is new, changed, or unusable, that call and all later calls execute live. Stable lexical call ordering, prompts, labels, routing options, and inputs therefore matter. Retry chains can cascade after an upstream miss. Nested workflows do not reuse the parent's resume journal.
24
+
25
+ The runtime blocks common accidental nondeterminism, but this is not a security boundary. Pass timestamps, randomness, and external decisions through `args`.
26
+
27
+ ## Nesting and shared state
28
+
29
+ `workflow(savedName, childArgs)` runs sequentially inline, allows one nested level, and shares limiter, counters, token accounting, and shared store with the parent. It is not independent capacity. Use only a saved-workflow name provided by context; do not guess registry entries or pass raw scripts as a new authoring pattern even where compatibility behavior accepts them.
30
+
31
+ ## Serialization
32
+
33
+ The workflow's explicit return value crosses the tool boundary. Keep it JSON-serializable and preserve coverage ledgers in the returned data. Structured agent schemas must be plain JSON Schema. Schema success guarantees the downstream field shape expected by JavaScript; without a schema, treat output as text or `null`.
@@ -0,0 +1,15 @@
1
+ # Pattern selection
2
+
3
+ Choose from data dependencies, then read only the matching example. JavaScript owns enumeration, identity, ordering, deduplication, bounds, stopping, brackets, and failure ledgers. Agents own semantic work.
4
+
5
+ <a id="fan-out-and-synthesize"></a>
6
+ | Dependency shape | Pattern | Preserve when adapting | Example |
7
+ | --- | --- | --- | --- |
8
+ | Heterogeneous items need different handling | Classify and act | Finish all classification before routed action; ledger classification and action failures by item ID | [Adapt](../examples/classify-and-act.js) |
9
+ | Independent work needs whole-set judgment | Fan out and synthesize | Pass thunks; await the full set; give synthesis every intended ID, including `null` | [Adapt](../examples/fan-out-and-synthesize.js) |
10
+ | Claims need skeptical checks | Adversarial verification | Use separate producer and skeptic calls; start skepticism after production; ledger both failures | [Adapt](../examples/adversarial-verification.js) |
11
+ | Exploration should diverge before one rubric | Generate and filter | Finish generation; deterministically deduplicate and bound candidates before filter calls | [Adapt](../examples/generate-and-filter.js) |
12
+ | Pairwise comparison beats absolute scoring | Tournament | Let JavaScript run the bounded bracket and byes; agents compare one pair; ledger match failures | [Adapt](../examples/tournament.js) |
13
+ | Work cardinality is unknown | Loop until done | Deduplicate by stable key; count only successful empty rounds as dry; cap rounds; retain failed rounds | [Adapt](../examples/loop-until-done.js) |
14
+
15
+ For every pattern, validate and bound input before fan-out, use stable IDs and unique labels, preserve missing coverage, and return plain JSON data. Combine patterns only when the task has both dependency shapes. Direct work needs no orchestration.
@@ -0,0 +1,8 @@
1
+ # Verify and judge
2
+
3
+ Keep work IDs outside helper results that may omit failed agents.
4
+
5
+ | Call | Contract |
6
+ | --- | --- |
7
+ | `verify(item, { reviewers: number, threshold: number, lens: string | string[] })` | Defaults: 2 reviewers, inclusive `0.5`, one lens or a cycled array. Returns `{ real, realCount, total, votes }`. Failed reviewers are omitted; successful votes are the denominator; zero survivors means `real: false`. |
8
+ | `judgePanel(attempts, { judges: number, rubric: string })` | Defaults: 3 judges and `"overall quality and correctness"`. Failed judgments are omitted. Returns the highest mean `{ index, attempt, score, judgments }`; input order wins ties; empty input returns `undefined`. |
@@ -0,0 +1,15 @@
1
+ # Dynamic registry ownership
2
+
3
+ Model routes and agent types are dynamic references. Their shape and owner are documented, but available names depend on active user/project configuration and are intentionally absent from static skill files.
4
+
5
+ ## Model routes
6
+
7
+ The model-tier configuration owns route names. Standard routes are `small`, `medium`, and `big`; use another route only when its name and purpose are supplied in context. A route is selected with `tier`. An exact user-requested model is selected with `model`.
8
+
9
+ ## Agent types
10
+
11
+ The agent registry owns agent-type names and their bound instructions, tools, model, and isolation policy. Use `agentType` only when context supplies both its name and purpose. Do not infer an agent type from a role-like label.
12
+
13
+ ## Priority
14
+
15
+ Routing priority is explicit `model` > `agentType` model > `tier` > phase model > metadata model > implicit `medium` > session default. Higher priority means selection, not "try this then fall back to the next selector." If the selected model or route is unavailable, execution falls directly to the session default; it does not try lower-priority selectors. Avoid specifying competing selectors unless deliberately overriding a lower-priority default.
@@ -0,0 +1,5 @@
1
+ # Retry
2
+
3
+ `retry(thunk, { attempts, until })` takes exactly these 2 arguments; `until` belongs in the options object. It calls `thunk(attempt)` with a zero-based index and defaults to 3 attempts. `until` is synchronous—a Promise or omitted predicate accepts the first result. Exhaustion returns only the last result, so keep an attempt ledger.
4
+
5
+ Always `await retry()`. A thunk containing `await` must be `async`; await `agent()` before adding its resolved value to the ledger. Runtime retries repeat recoverable execution failures; helper attempts are new semantic calls. Bound both layers and ledger exhaustion.
@@ -0,0 +1,43 @@
1
+ # Workflow review checklist
2
+
3
+ Review author-visible behavior, not formatting preferences. When behavior depends on a quality or control combinator, consult only its exact [quality](quality-helpers.md) or [specialized](specialized-helpers.md) helper contract before correcting the script.
4
+
5
+ ## Envelope and contract
6
+
7
+ - Is literal `export const meta` the first statement, with a short unique name and useful description?
8
+ - Are only used phases declared, and does each named phase begin at the intended boundary?
9
+ - Does the script call at least one agent and explicitly return JSON-serializable data?
10
+ - Are imports and nondeterministic APIs absent?
11
+
12
+ ## Topology and identity
13
+
14
+ - Does topology match dependencies: thunks for independent parallel work, stages for per-item pipelines, barriers before whole-set synthesis?
15
+ - Is cardinality bounded before fan-out?
16
+ - Is every agent label short and unique?
17
+ - Are stable work-unit IDs retained beside ordered results?
18
+ - Are failed/null identities recorded before any filtering?
19
+
20
+ ## Data and routing
21
+
22
+ - Does JavaScript consume structured fields only after a small plain JSON Schema guarantees them?
23
+ - Does synthesis receive complete coverage and failure ledgers?
24
+ - Are `model`, `tier`, and `agentType` used according to selector priority?
25
+ - Did every nonstandard route or agent type come from context with a name and purpose?
26
+
27
+ ## Lifecycle
28
+
29
+ - Are runtime retries and semantic retries separately bounded?
30
+ - Are loops, agents, concurrency, timeout, and token spend bounded appropriately?
31
+ - Are budget claims honest about soft gates and in-flight overshoot?
32
+ - Are checkpoints limited to implemented confirmation/headless behavior?
33
+ - Does nesting stay one level and account for shared limits/store?
34
+ - Would lexical call order remain stable under resume?
35
+
36
+ ## Compatibility and publication
37
+
38
+ - Does new code use `log()` rather than compatibility-only `console`?
39
+ - Is compatibility behavior clearly distinguished from supported authoring behavior and VM substrate?
40
+ - Do package, skill, and generated contract versions match?
41
+ - Do all relative links resolve within the publishable package?
42
+
43
+ Use [lifecycle](lifecycle.md) for lifecycle reasoning. Open the compact [capability index](capabilities.md) only when the review turns on a disputed signature, default, support boundary, or installed version; follow its exhaustive-facts pointer only when the index is insufficient.
@@ -0,0 +1,27 @@
1
+ # Runtime authoring
2
+
3
+ Use this page for routine scripts. Open the generated capability index only when a signature, default, support boundary, or installed-version fact is missing here.
4
+
5
+ ## Script envelope
6
+
7
+ Start with the only legal export: `export const meta = { name, description, phases?: [{ title, detail?, model? }] }`. Values are nonblank literals; declare only used phases and call `phase()` before each phase's work. The remaining body already runs inside an async function: write helpers as ordinary declarations; `export default` and other exports are invalid. Return the result explicitly.
8
+
9
+ The runtime supplies `agent`, `parallel`, `pipeline`, `workflow`, quality/control helpers, `phase`, `log`, `args`, `cwd`, restricted `process.cwd()`, and `budget`. Imports, `require()`, filesystem modules, `Date.now()`, `Math.random()`, and no-argument `new Date()` are unavailable. The Node VM realm is implementation substrate, not a security boundary or public API.
10
+
11
+ ## Topology
12
+
13
+ - `parallel()` takes thunks, runs independent work, and preserves input order. Await the whole array before whole-set synthesis.
14
+ - `pipeline()` runs stages sequentially per item while items proceed concurrently. Each stage receives `(previousValue, originalItem, index)` and forwards `null` to the next stage, so guard missing coverage first.
15
+ - `workflow(name, childArgs?)` runs a context-supplied saved workflow. Nesting is one level and shares limits, counters, tokens, and store.
16
+
17
+ ## Data and failure
18
+
19
+ Call `agent(prompt, { label, schema? })`; it returns text, a schema-validated value, or recoverable `null`. Nonrecoverable limit, validation, and budget failures throw. Record each intended work ID before filtering. A `null` means missing coverage, never a negative finding.
20
+
21
+ When JavaScript reads fields, pass a small plain JSON Schema. Schema noncompliance after repair throws and bypasses agent retries. Catch it only to return an explicit incomplete outcome without reading missing fields. Return objects, arrays, strings, numbers, booleans, and `null`—not functions, promises, cycles, `BigInt`, or runtime handles.
22
+
23
+ ## Routing and support
24
+
25
+ Selector priority is explicit `model` > `agentType` model > `tier` > phase model > metadata model > implicit `medium` > session default. An unavailable selected route falls directly to the session default. Use exact `model`, nonstandard `tier`, or `agentType` only when context supplies its name and purpose. Worktree isolation is best-effort. See [registry ownership](registry-ownership.md).
26
+
27
+ Generated entries marked `supported` are authoring API. `console` and whole-script Markdown fences are compatibility-only. VM realm facilities are internal. Active model routes and agent types are dynamic. Use `log()` in new scripts.
@@ -0,0 +1,19 @@
1
+ # Specialized helpers
2
+
3
+ Preserve candidate or work identity outside helper results that may omit failed agents.
4
+
5
+ ## Quality
6
+
7
+ | Helper | Authoring contract |
8
+ | --- | --- |
9
+ | `completenessCheck(args, results)` | Returns `{ complete, missing? }` or recoverable `null`. The critic sees only the first 4,000 serialized characters, so chunk or summarize larger evidence. Treat the verdict as advisory. |
10
+ | `loopUntilDry({ round, key, consecutiveEmpty, maxRounds })` | `round(index)` is zero-based. Defaults: `JSON.stringify` key, two dry rounds, 50 rounds. Null, non-array, and duplicate-only rounds are dry. Token-budget or agent-limit exhaustion returns the partial array without a termination reason; keep failed-round identity and stopping state outside the helper. |
11
+
12
+ ## Control
13
+
14
+ | Helper | Authoring contract |
15
+ | --- | --- |
16
+ | `gate(thunk, validator, { attempts })` | Calls `thunk(feedback, attempt)` with initial `undefined` feedback and a zero-based attempt. `validator(value)` returns `{ ok, feedback? }`, synchronously or asynchronously; a bare boolean is not accepted. Three attempts by default. Returns `{ ok, value, attempts }`, including the last value on exhaustion. See [validated gate](../examples/validated-gate.js). |
17
+ | `checkpoint(prompt, options?)` | Journals a human/default decision. Only foreground confirm and documented headless behavior work; input, select, and timeout are declared-only. |
18
+
19
+ Always `await gate()`. A thunk containing `await` must itself be declared `async`; await `agent()` before adding its resolved value to a ledger. Runtime agent retries repeat recoverable execution failures; helper attempts are new semantic calls. Bound both layers and ledger exhaustion.
@@ -0,0 +1,13 @@
1
+ # Version compatibility
2
+
3
+ The installed package, capability-contract content, and this skill must describe the same extension version. Read the version line generated at the top of [capabilities](capabilities.md); the skill's frontmatter version and package version must match it.
4
+
5
+ `present-at` means a capability is confirmed in the recorded version. It is an honest baseline, not a claim about the first historical release that introduced the capability. The contract format has its own version because descriptor shape can evolve separately from extension content.
6
+
7
+ When copying a workflow between installations:
8
+
9
+ 1. Check the destination's generated version and exact capability facts.
10
+ 2. Re-check every supported global, option, and constraint used by the script.
11
+ 3. Treat compatibility entries as preservation aids, not portable recommendations.
12
+ 4. Re-resolve dynamic model routes and agent types from destination context; static docs intentionally contain no live entries.
13
+ 5. Prefer runtime behavior when prose and execution disagree, and report the documentation mismatch rather than changing behavior during an authoring fix.