@runtypelabs/cli 2.17.0 → 2.19.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 (3) hide show
  1. package/README.md +28 -1
  2. package/dist/index.js +1993 -721
  3. package/package.json +7 -5
package/README.md CHANGED
@@ -211,7 +211,7 @@ milestones:
211
211
  EOF
212
212
  ```
213
213
 
214
- **Search order**: Exact path → `.runtype/marathons/playbooks/<name>.yaml|yml|json` (repo) → `~/.runtype/marathons/playbooks/<name>.yaml|yml|json` (user).
214
+ **Search order**: Exact path → `.runtype/marathons/playbooks/<name>.yaml|yml|json|ts|mts` (repo) → `~/.runtype/marathons/playbooks/<name>.yaml|yml|json|ts|mts` (user).
215
215
 
216
216
  **Completion criteria types**:
217
217
 
@@ -248,6 +248,33 @@ milestones:
248
248
  | `requireVerification` | `boolean` | Require verification before `TASK_COMPLETE`. |
249
249
  | `outputRoot` | `string` | For creation tasks: confine writes to this directory (e.g. `"public/"`). |
250
250
 
251
+ #### TypeScript playbooks
252
+
253
+ Playbooks can also be TypeScript modules (`.ts`/`.mts`), loaded at runtime via jiti — no build step or special Node version required. Every behavior slot (`instructions`, `completionCriteria`, `recovery`, `intercept`, ...) then accepts a plain function in addition to inline data and hook references:
254
+
255
+ ```ts
256
+ // .runtype/marathons/playbooks/my-task.ts
257
+ import { definePlaybook, type RunTaskStateSlice } from '@runtypelabs/sdk'
258
+
259
+ export default definePlaybook({
260
+ name: 'my-task',
261
+ stallPolicy: { nudgeAfter: 1, stopAfter: 4 },
262
+ milestones: [
263
+ {
264
+ name: 'build',
265
+ instructions: (state: RunTaskStateSlice) => `Build it. Plan: ${state.planPath}`,
266
+ recovery: (state) =>
267
+ `You went ${state.consecutiveEmptySessions ?? 0} sessions without a tool call. Write a file now.`,
268
+ canAcceptCompletion: true,
269
+ },
270
+ ],
271
+ })
272
+ ```
273
+
274
+ `definePlaybook` (from `@runtypelabs/sdk`, install as a devDependency for editor types) is optional sugar — a plain object export with the same shape works without the package installed. To register named hooks (reusable from YAML playbooks too), export a factory instead: `export default ({ registerWorkflowHook }) => ({ ... })`. A complete example lives at [`examples/playbooks/release-notes.ts`](./examples/playbooks/release-notes.ts).
275
+
276
+ **Hook references**: any slot can reference a registered behavior by name instead of carrying data — `builtin:*` names expose the default workflow's behaviors (e.g. `instructions: builtin:research-instructions`, `completionCriteria: { type: builtin:research-complete }`), and YAML playbooks can load custom hooks from JS modules listed under `plugins:` (paths relative to the playbook file). See the comments in [`examples/playbooks/design-library.yaml`](./examples/playbooks/design-library.yaml).
277
+
251
278
  #### Marathon Anatomy
252
279
 
253
280
  ```