@sublang/playbook 11.0.0 → 12.1.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 (49) hide show
  1. package/docs/cli.md +9 -6
  2. package/docs/configuration.md +15 -1
  3. package/docs/embedding.md +83 -1
  4. package/package.json +28 -3
  5. package/reference/sdlc/code.playbook/bin/repository-effects.js +501 -170
  6. package/reference/sdlc/code.playbook/bin/session-store.js +4 -1
  7. package/reference/sdlc/code.playbook/code.fsm.d.ts +22 -19
  8. package/reference/sdlc/code.playbook/code.fsm.js +116 -52
  9. package/reference/sdlc/code.playbook/code.fsm.ts +149 -64
  10. package/reference/sdlc/code.playbook/code.gears.md +40 -20
  11. package/reference/sdlc/code.playbook/code.playbook.js +23 -2
  12. package/reference/sdlc/code.playbook/code.playbook.ts +23 -2
  13. package/reference/sdlc/code.playbook/host-capabilities.d.ts +291 -0
  14. package/reference/sdlc/code.playbook/host-capabilities.js +40 -0
  15. package/reference/sdlc/code.playbook/playbook.config.template.yaml +18 -2
  16. package/reference/sdlc/decide.playbook/decide.fsm.d.ts +13 -6
  17. package/reference/sdlc/decide.playbook/decide.fsm.js +54 -27
  18. package/reference/sdlc/decide.playbook/decide.fsm.ts +68 -29
  19. package/reference/sdlc/decide.playbook/decide.gears.md +25 -19
  20. package/reference/sdlc/decide.playbook/decide.playbook.js +11 -3
  21. package/reference/sdlc/decide.playbook/decide.playbook.ts +11 -3
  22. package/reference/sdlc/decide.playbook/decide.registry.js +1 -1
  23. package/reference/sdlc/decide.playbook/decide.registry.ts +1 -1
  24. package/reference/sdlc/dev.md +52 -0
  25. package/reference/sdlc/dev.playbook/dev.fsm.d.ts +261 -0
  26. package/reference/sdlc/dev.playbook/dev.fsm.js +723 -0
  27. package/reference/sdlc/dev.playbook/dev.fsm.ts +988 -0
  28. package/reference/sdlc/dev.playbook/dev.gears.md +91 -0
  29. package/reference/sdlc/dev.playbook/dev.playbook.d.ts +21 -0
  30. package/reference/sdlc/dev.playbook/dev.playbook.js +143 -0
  31. package/reference/sdlc/dev.playbook/dev.playbook.ts +246 -0
  32. package/reference/sdlc/dev.playbook/dev.registry.d.ts +40 -0
  33. package/reference/sdlc/dev.playbook/dev.registry.js +64 -0
  34. package/reference/sdlc/dev.playbook/dev.registry.ts +120 -0
  35. package/reference/sdlc/review.playbook/review.fsm.d.ts +15 -2
  36. package/reference/sdlc/review.playbook/review.fsm.js +77 -27
  37. package/reference/sdlc/review.playbook/review.fsm.ts +96 -30
  38. package/reference/sdlc/review.playbook/review.gears.md +52 -26
  39. package/reference/sdlc/review.playbook/review.playbook.js +17 -7
  40. package/reference/sdlc/review.playbook/review.playbook.ts +17 -7
  41. package/reference/sdlc/review.playbook/review.registry.js +1 -1
  42. package/reference/sdlc/review.playbook/review.registry.ts +1 -1
  43. package/slc/gears2fsm.md +20 -0
  44. package/slc/link.md +28 -5
  45. package/slc/text2gears.md +21 -1
  46. package/src/xstate-playbook-runtime.js +5 -2
  47. package/src/xstate-playbook-runtime.ts +5 -2
  48. package/src/xstate-runtime.js +13 -1
  49. package/src/xstate-runtime.ts +13 -1
package/docs/cli.md CHANGED
@@ -105,8 +105,8 @@ its exit status or signal and exit `127` when it cannot be spawned
105
105
 
106
106
  The Boss pane starts at the Playbook Captain shell, where the session
107
107
  Captain runs for the whole session and sees every turn. Use `/code`,
108
- `/review`, or `/decide` followed by a task to select one of the bundled
109
- playbooks explicitly. A registered command resolves deterministically,
108
+ `/review`, `/decide`, or `/dev` followed by a task to select one of the
109
+ bundled playbooks explicitly. A registered command resolves deterministically,
110
110
  with no model call parsing it: at idle it starts that playbook, at its
111
111
  own leaf it delivers the rest of the line, an enabled command absent
112
112
  from the active path switches to it, and a bare command answers with
@@ -121,9 +121,11 @@ untouched
121
121
  ([[playbook-captain-1](https://github.com/sublang-ai/playbook/blob/main/specs/packages/playbook-captain.md#playbook-captain-1)],
122
122
  [[playbook-captain-2](https://github.com/sublang-ai/playbook/blob/main/specs/packages/playbook-captain.md#playbook-captain-2)]).
123
123
 
124
- The current CODE, REVIEW, and DECIDE workflows take their deterministic
124
+ The current CODE, REVIEW, DECIDE, and DEV workflows take their deterministic
125
125
  initial event from the selecting Boss turn. CODE and DECIDE then call REVIEW
126
- as a nested playbook. Local role names do not imply continuity: each frame
126
+ as a nested playbook, while DEV the repository-aware planner behind
127
+ `/dev` — analyzes a development request and itself calls CODE, or DECIDE and
128
+ then CODE, as nested playbooks. Local role names do not imply continuity: each frame
127
129
  uses the exact stable player IDs configured under its `roles` map. Equal IDs
128
130
  share one pane and provider conversation across nested and later root
129
131
  engagements; distinct IDs remain isolated even when their agent settings are
@@ -321,8 +323,9 @@ to present the `incomplete` status it receives
321
323
  For each governed player call, Playbook records a Git baseline before the call
322
324
  and a durable receipt afterward. CODE and DECIDE commit arms, and REVIEW's
323
325
  Coder commit arm, accept a commit only when the receipt proves exactly one
324
- descendant commit with no residual repository change; REVIEW's Reviewer calls
325
- and DECIDE's proposal calls require the repository to remain exact. The
326
+ descendant commit with no residual repository change; REVIEW's Reviewer calls,
327
+ DECIDE's proposal calls, and every DEV Analyst planning call require the
328
+ repository to remain exact. The
326
329
  player's prose, including any `Commit:` line, is presentation rather than
327
330
  proof.
328
331
 
@@ -84,6 +84,13 @@ players:
84
84
  permissions:
85
85
  mode: auto # protected auto mode for the Claude Reviewer
86
86
 
87
+ dev.analyst:
88
+ adapter: claude
89
+ model: claude-opus-5
90
+ effort: xhigh
91
+ permissions:
92
+ mode: auto # protected auto mode for the Claude Analyst
93
+
87
94
  playbooks:
88
95
  code:
89
96
  from: '@sublang/playbook/code/registry'
@@ -101,6 +108,11 @@ playbooks:
101
108
  roles:
102
109
  coder: dev.coder
103
110
  reviewer: dev.reviewer
111
+
112
+ dev:
113
+ from: '@sublang/playbook/dev/registry'
114
+ roles:
115
+ analyst: dev.analyst
104
116
  ```
105
117
 
106
118
  The current bundled workflows accept no workflow-specific options.
@@ -146,7 +158,9 @@ Two bindings that name the same player ID deliberately share one sequential
146
158
  provider conversation throughout the logical Captain session — across nested
147
159
  calls, returns, and later root engagements. CODE's and REVIEW's `coder` roles
148
160
  therefore share `dev.coder` in the starter, and DECIDE and its nested REVIEW
149
- share both starter players. Disposal of one playbook frame does not clear that
161
+ share both starter players. DEV's `analyst` instead binds the distinct
162
+ `dev.analyst` player, so planning context does not bleed into the shared
163
+ review conversation. Disposal of one playbook frame does not clear that
150
164
  session ledger.
151
165
 
152
166
  Two distinct player IDs stay isolated even when their agent blocks are
package/docs/embedding.md CHANGED
@@ -153,7 +153,9 @@ const playbookSessionId = randomUUID();
153
153
  // session lease and resolving the canonical Git worktree. Their authority
154
154
  // must name this playbook/session/working directory and their repository and
155
155
  // effect-ledger operations must stay live; never put them in configuration,
156
- // machine input, or a persisted snapshot.
156
+ // machine input, or a persisted snapshot. A host outside the CLI constructs
157
+ // the repository and effect-ledger members through the facade described in
158
+ // "Constructing worktree host capabilities" below.
157
159
  declare const hostCapabilities: ReviewPlaybookHostCapabilities;
158
160
 
159
161
  const runtime = createPlaybookRuntime({
@@ -220,6 +222,86 @@ capability functions never enter Boss-visible status text or configured
220
222
  options. Because trace observers do receive opaque resume tokens, persisted
221
223
  traces should be protected as sensitive data.
222
224
 
225
+ ## Constructing worktree host capabilities
226
+
227
+ A schema-3 artifact takes live `{ repository, effectLedger }` capabilities
228
+ beside its configured options. Rather than reimplementing the engine's
229
+ observation, claim, receipt, and ledger contract, construct them through the
230
+ narrow, semver-stable `@sublang/playbook/host-capabilities` facade. It is the
231
+ CLI host's own implementation, re-exported: every classification the engine
232
+ makes for `playbook run` is the one your host makes too.
233
+
234
+ ```ts
235
+ import {
236
+ createFailClosedHostCapabilities,
237
+ createWorktreeHostCapabilities,
238
+ } from '@sublang/playbook/host-capabilities';
239
+
240
+ declare const workdir: string;
241
+ declare const createPlaybookRuntime: (construction: {
242
+ configuredOptions: object;
243
+ hostCapabilities: object;
244
+ }) => unknown;
245
+
246
+ // One capability per playbook and Git worktree, constructed after the
247
+ // working directory is resolved and before the runtime is. The roles are the
248
+ // artifact's declared roles; an undeclared role is refused at boundary start.
249
+ const hostCapabilities = await createWorktreeHostCapabilities({
250
+ cwd: workdir,
251
+ playbookId: 'workflow',
252
+ requiredRoleIds: ['coder', 'reviewer'],
253
+ });
254
+ const runtime = createPlaybookRuntime({
255
+ configuredOptions: {},
256
+ hostCapabilities,
257
+ });
258
+
259
+ // An artifact declaring no governed player state needs no worktree at all:
260
+ // every repository operation and ledger write rejects, and the ledger stays
261
+ // empty.
262
+ const inert = createPlaybookRuntime({
263
+ configuredOptions: {},
264
+ hostCapabilities: createFailClosedHostCapabilities(),
265
+ });
266
+ ```
267
+
268
+ `createWorktreeHostCapabilities()` requires only that `cwd` exist and returns
269
+ exactly `repository: { identity, observe, runExclusive, runDeferred }` and
270
+ `effectLedger: { snapshot, writeAhead }`. The governed worktree is bound at
271
+ every governed call and observation rather than fixed at construction: it is
272
+ the canonical root of the nearest Git worktree containing `cwd`, or — when
273
+ there is none — `cwd` itself as the prospective root `{ worktree, gitDir:
274
+ worktree/.git }` that a later `git init` there binds unchanged. A directory
275
+ that is not a repository yet observes as the null (all-zero) HEAD over its
276
+ non-ignored content, exactly as `git init` would then see it, and an unborn
277
+ HEAD observes as the null OID too; so a workflow whose first step runs
278
+ `test -e .git || git init` in its working directory receives `unchanged`, and
279
+ its first root commit receives `one-descendant-commit` with that commit's OID.
280
+ `identity` is the binding at construction; each boundary records the binding
281
+ its baseline observed. The ledger is in memory and starts from the optional
282
+ `effectLedger` seed, so a host that wants durability keeps
283
+ `effectLedger.snapshot()` at its own boundaries and seeds the next
284
+ construction from it; each construction is one attempt over its seed.
285
+ `runExclusive` and `runDeferred` hold the same cross-process worktree claim the
286
+ CLI uses (process-local until the repository exists, since there is no `.git`
287
+ to publish it in), observe before and after the operation, apply the engine's
288
+ correction-budget `writeAhead` mid-completion, and bind, park, continue, and
289
+ restore deferred Boss questions with the engine's exact checkpoint semantics.
290
+ Overlapping calls on one worktree run one at a time, in no guaranteed order.
291
+ A write the ledger rejects after a boundary has started leaves the worktree
292
+ claim quarantined, exactly as it would under `playbook run`: treat that
293
+ rejection as terminal for the worktree in this process.
294
+
295
+ The module functions `observeGitRepository(cwd)`,
296
+ `captureRepositoryReceipt(baseline, { allowedDispositions })`, and
297
+ `classifyRepositoryReceipt(baseline, after, { allowedDispositions })` expose
298
+ the same observation and receipt classification for a host that inspects a
299
+ worktree outside a governed call. The declaration is self-contained — it
300
+ re-declares the ledger, receipt, observation, and question types of
301
+ `@sublang/playbook/runtime` name for name — and the facade carries no session
302
+ lease, session record, resume credential, catalog, or recovery member
303
+ ([[playbook-cli-87](https://github.com/sublang-ai/playbook/blob/main/specs/packages/playbook-cli.md#playbook-cli-87)]).
304
+
223
305
  ## Sharing the CLI session store
224
306
 
225
307
  An external host that needs the CLI's canonical session validation and
package/package.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "@sublang/playbook",
3
- "version": "11.0.0",
3
+ "version": "12.1.0",
4
4
  "type": "module",
5
- "description": "Composable XState v5 playbook runtime with compiled Captain, CODE, REVIEW, and DECIDE workflows driven by GEARS specs.",
5
+ "description": "Composable XState v5 playbook runtime with compiled Captain, CODE, REVIEW, DECIDE, and DEV workflows driven by GEARS specs.",
6
6
  "license": "Apache-2.0",
7
7
  "homepage": "https://github.com/sublang-ai/playbook#readme",
8
8
  "repository": {
@@ -45,6 +45,7 @@
45
45
  "reference/sdlc/code.md",
46
46
  "reference/sdlc/review.md",
47
47
  "reference/sdlc/decide.md",
48
+ "reference/sdlc/dev.md",
48
49
  "reference/sdlc/captain.playbook/captain.gears.md",
49
50
  "reference/sdlc/captain.playbook/captain.fsm.ts",
50
51
  "reference/sdlc/captain.playbook/captain.fsm.js",
@@ -69,6 +70,8 @@
69
70
  "reference/sdlc/code.playbook/playbook-captain.d.ts",
70
71
  "reference/sdlc/code.playbook/session-store.js",
71
72
  "reference/sdlc/code.playbook/session-store.d.ts",
73
+ "reference/sdlc/code.playbook/host-capabilities.js",
74
+ "reference/sdlc/code.playbook/host-capabilities.d.ts",
72
75
  "reference/sdlc/code.playbook/code.gears.md",
73
76
  "reference/sdlc/code.playbook/playbook.config.template.yaml",
74
77
  "reference/sdlc/code.playbook/bin/playbook.js",
@@ -100,6 +103,16 @@
100
103
  "reference/sdlc/decide.playbook/decide.registry.ts",
101
104
  "reference/sdlc/decide.playbook/decide.registry.js",
102
105
  "reference/sdlc/decide.playbook/decide.registry.d.ts",
106
+ "reference/sdlc/dev.playbook/dev.gears.md",
107
+ "reference/sdlc/dev.playbook/dev.fsm.ts",
108
+ "reference/sdlc/dev.playbook/dev.fsm.js",
109
+ "reference/sdlc/dev.playbook/dev.fsm.d.ts",
110
+ "reference/sdlc/dev.playbook/dev.playbook.ts",
111
+ "reference/sdlc/dev.playbook/dev.playbook.js",
112
+ "reference/sdlc/dev.playbook/dev.playbook.d.ts",
113
+ "reference/sdlc/dev.playbook/dev.registry.ts",
114
+ "reference/sdlc/dev.playbook/dev.registry.js",
115
+ "reference/sdlc/dev.playbook/dev.registry.d.ts",
103
116
  "docs"
104
117
  ],
105
118
  "bin": {
@@ -134,6 +147,10 @@
134
147
  "types": "./reference/sdlc/code.playbook/session-store.d.ts",
135
148
  "default": "./reference/sdlc/code.playbook/session-store.js"
136
149
  },
150
+ "./host-capabilities": {
151
+ "types": "./reference/sdlc/code.playbook/host-capabilities.d.ts",
152
+ "default": "./reference/sdlc/code.playbook/host-capabilities.js"
153
+ },
137
154
  "./slc/*": "./slc/*",
138
155
  "./review/playbook": {
139
156
  "types": "./reference/sdlc/review.playbook/review.playbook.d.ts",
@@ -150,6 +167,14 @@
150
167
  "./decide/registry": {
151
168
  "types": "./reference/sdlc/decide.playbook/decide.registry.d.ts",
152
169
  "default": "./reference/sdlc/decide.playbook/decide.registry.js"
170
+ },
171
+ "./dev/playbook": {
172
+ "types": "./reference/sdlc/dev.playbook/dev.playbook.d.ts",
173
+ "default": "./reference/sdlc/dev.playbook/dev.playbook.js"
174
+ },
175
+ "./dev/registry": {
176
+ "types": "./reference/sdlc/dev.playbook/dev.registry.d.ts",
177
+ "default": "./reference/sdlc/dev.playbook/dev.registry.js"
153
178
  }
154
179
  },
155
180
  "scripts": {
@@ -172,7 +197,7 @@
172
197
  "yaml": "^2.9.0"
173
198
  },
174
199
  "devDependencies": {
175
- "@anthropic-ai/claude-agent-sdk": "^0.3.221",
200
+ "@anthropic-ai/claude-agent-sdk": "^0.3.223",
176
201
  "@openai/codex-sdk": "^0.146.0",
177
202
  "@types/node": "^22.0.0",
178
203
  "typescript": "^5.8.0",