@sublang/playbook 15.0.0 → 16.0.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 (81) hide show
  1. package/README.md +1 -1
  2. package/docs/embedding.md +9 -7
  3. package/package.json +3 -1
  4. package/reference/sdlc/branch.playbook/branch.fsm.d.ts +63 -33
  5. package/reference/sdlc/branch.playbook/branch.fsm.js +190 -108
  6. package/reference/sdlc/branch.playbook/branch.fsm.ts +269 -147
  7. package/reference/sdlc/branch.playbook/branch.gears.md +7 -17
  8. package/reference/sdlc/branch.playbook/branch.playbook.d.ts +12 -16
  9. package/reference/sdlc/branch.playbook/branch.playbook.js +112 -101
  10. package/reference/sdlc/branch.playbook/branch.playbook.ts +128 -171
  11. package/reference/sdlc/branch.playbook/branch.registry.d.ts +3 -2
  12. package/reference/sdlc/branch.playbook/branch.registry.ts +6 -2
  13. package/reference/sdlc/code.playbook/bin/repository-effects.js +54 -13
  14. package/reference/sdlc/code.playbook/code.fsm.d.ts +143 -90
  15. package/reference/sdlc/code.playbook/code.fsm.introspect.d.ts +8 -8
  16. package/reference/sdlc/code.playbook/code.fsm.introspect.ts +13 -13
  17. package/reference/sdlc/code.playbook/code.fsm.js +609 -649
  18. package/reference/sdlc/code.playbook/code.fsm.ts +890 -821
  19. package/reference/sdlc/code.playbook/code.gears.md +39 -29
  20. package/reference/sdlc/code.playbook/code.playbook.d.ts +13 -16
  21. package/reference/sdlc/code.playbook/code.playbook.js +166 -147
  22. package/reference/sdlc/code.playbook/code.playbook.ts +180 -229
  23. package/reference/sdlc/code.playbook/code.registry.d.ts +3 -2
  24. package/reference/sdlc/code.playbook/code.registry.ts +6 -2
  25. package/reference/sdlc/code.playbook/playbook-captain.d.ts +42 -0
  26. package/reference/sdlc/code.playbook/playbook-captain.js +829 -194
  27. package/reference/sdlc/code.playbook/playbook-captain.ts +1227 -220
  28. package/reference/sdlc/decide.md +1 -0
  29. package/reference/sdlc/decide.playbook/decide.fsm.d.ts +270 -154
  30. package/reference/sdlc/decide.playbook/decide.fsm.js +765 -732
  31. package/reference/sdlc/decide.playbook/decide.fsm.ts +1167 -945
  32. package/reference/sdlc/decide.playbook/decide.gears.md +28 -21
  33. package/reference/sdlc/decide.playbook/decide.playbook.d.ts +11 -67
  34. package/reference/sdlc/decide.playbook/decide.playbook.js +155 -3570
  35. package/reference/sdlc/decide.playbook/decide.playbook.ts +186 -5061
  36. package/reference/sdlc/decide.playbook/decide.registry.d.ts +8 -4
  37. package/reference/sdlc/decide.playbook/decide.registry.js +2 -2
  38. package/reference/sdlc/decide.playbook/decide.registry.ts +13 -6
  39. package/reference/sdlc/dev.playbook/dev.fsm.d.ts +113 -131
  40. package/reference/sdlc/dev.playbook/dev.fsm.js +517 -575
  41. package/reference/sdlc/dev.playbook/dev.fsm.ts +667 -787
  42. package/reference/sdlc/dev.playbook/dev.gears.md +52 -54
  43. package/reference/sdlc/dev.playbook/dev.playbook.d.ts +13 -10
  44. package/reference/sdlc/dev.playbook/dev.playbook.js +128 -120
  45. package/reference/sdlc/dev.playbook/dev.playbook.ts +143 -193
  46. package/reference/sdlc/dev.playbook/dev.registry.d.ts +3 -2
  47. package/reference/sdlc/dev.playbook/dev.registry.ts +6 -2
  48. package/reference/sdlc/pr.playbook/pr.fsm.d.ts +92 -85
  49. package/reference/sdlc/pr.playbook/pr.fsm.js +461 -518
  50. package/reference/sdlc/pr.playbook/pr.fsm.ts +533 -663
  51. package/reference/sdlc/pr.playbook/pr.gears.md +47 -63
  52. package/reference/sdlc/pr.playbook/pr.playbook.d.ts +13 -23
  53. package/reference/sdlc/pr.playbook/pr.playbook.js +118 -112
  54. package/reference/sdlc/pr.playbook/pr.playbook.ts +136 -190
  55. package/reference/sdlc/pr.playbook/pr.registry.d.ts +3 -2
  56. package/reference/sdlc/pr.playbook/pr.registry.ts +4 -2
  57. package/reference/sdlc/review.md +3 -3
  58. package/reference/sdlc/review.playbook/review.fsm.d.ts +150 -116
  59. package/reference/sdlc/review.playbook/review.fsm.js +479 -550
  60. package/reference/sdlc/review.playbook/review.fsm.ts +717 -662
  61. package/reference/sdlc/review.playbook/review.gears.md +32 -29
  62. package/reference/sdlc/review.playbook/review.playbook.d.ts +12 -12
  63. package/reference/sdlc/review.playbook/review.playbook.js +180 -155
  64. package/reference/sdlc/review.playbook/review.playbook.ts +190 -230
  65. package/reference/sdlc/review.playbook/review.registry.d.ts +6 -5
  66. package/reference/sdlc/review.playbook/review.registry.js +3 -3
  67. package/reference/sdlc/review.playbook/review.registry.ts +9 -5
  68. package/slc/gears2fsm.md +72 -3
  69. package/slc/link.md +50 -27
  70. package/slc/materialize-link.mjs +51 -13
  71. package/slc/optimize.md +4 -1
  72. package/slc/prefix-prompts.mjs +191 -0
  73. package/slc/prefix.md +203 -0
  74. package/slc/slc.pin-inputs.json +11 -1
  75. package/slc/text2gears.md +71 -11
  76. package/src/xstate-playbook-runtime.d.ts +82 -9
  77. package/src/xstate-playbook-runtime.js +1224 -283
  78. package/src/xstate-playbook-runtime.ts +1671 -338
  79. package/src/xstate-runtime.d.ts +3 -1
  80. package/src/xstate-runtime.js +9 -2
  81. package/src/xstate-runtime.ts +12 -2
@@ -1,11 +1,13 @@
1
+ import type { PlaybookCallResult } from '@sublang/playbook/runtime';
1
2
  export type JsonValue = null | boolean | number | string | readonly JsonValue[] | {
2
3
  readonly [key: string]: JsonValue;
3
4
  };
4
- export type PrStateId = 'openPullRequest' | 'waitForChecks' | 'fixChecks' | 'publishFix' | 'waitForChecksAfterFix' | 'mergePullRequest' | 'updateLocalDefault';
5
+ export type PrStateId = 'openPullRequest' | 'waitForChecks' | 'fixChecks' | 'publishFix' | 'waitForFixChecks' | 'mergePullRequest' | 'updateLocalDefault';
5
6
  export type PrSourceItem = 'PR-1' | 'PR-2' | 'PR-3' | 'PR-4' | 'PR-5' | 'PR-6' | 'PR-7';
6
- export type PrScriptStateId = 'waitForChecks' | 'publishFix' | 'waitForChecksAfterFix' | 'mergePullRequest' | 'updateLocalDefault';
7
- export type PrScriptSourceItem = 'PR-2' | 'PR-4' | 'PR-5' | 'PR-6' | 'PR-7';
8
- export type PrChildPlaybookId = 'code';
7
+ /** Working leaves a Boss reply may resume (scalar Boss-reply form). */
8
+ export type ResumableStateId = 'openPullRequest';
9
+ /** No parallel group: the playbook runs one delegated role at a time. */
10
+ export declare const concurrentRoleSets: readonly (readonly string[])[];
9
11
  export type PendingBossQuestion = {
10
12
  readonly questionId: 'openPullRequest';
11
13
  readonly resumeStateId: 'openPullRequest';
@@ -22,6 +24,7 @@ export type PlayerInput = {
22
24
  readonly sourceItem: 'PR-1';
23
25
  readonly prompt: string;
24
26
  readonly result: Readonly<Record<string, string>>;
27
+ /** `<caller-input>`: the complete caller input, relayed in quotes. */
25
28
  readonly callerInput: string;
26
29
  readonly pendingBossQuestion?: PendingBossQuestion;
27
30
  readonly bossReply?: string;
@@ -37,16 +40,13 @@ export type PlayerOutput = {
37
40
  readonly guard: 'needsBossReply';
38
41
  readonly question: string;
39
42
  };
40
- export type PlaybookInput = {
41
- readonly stateId: 'fixChecks';
42
- readonly sourceItem: 'PR-3';
43
- readonly playbookId: PrChildPlaybookId;
44
- readonly text: string;
45
- };
43
+ export type ScriptStateId = 'waitForChecks' | 'publishFix' | 'waitForFixChecks' | 'mergePullRequest' | 'updateLocalDefault';
46
44
  export type ScriptInput = {
47
- readonly stateId: PrScriptStateId;
48
- readonly sourceItem: PrScriptSourceItem;
45
+ readonly stateId: ScriptStateId;
46
+ readonly sourceItem: 'PR-2' | 'PR-4' | 'PR-5' | 'PR-6' | 'PR-7';
47
+ /** The script blockquote, with its runtime values bound as shell literals. */
49
48
  readonly command: string;
49
+ /** Zero-exit guard first, then the nonzero-exit guard. */
50
50
  readonly result: Readonly<Record<string, string>>;
51
51
  };
52
52
  export type ScriptOutput = {
@@ -77,68 +77,71 @@ export type ScriptOutput = {
77
77
  readonly guard: 'localDefaultNotUpdated';
78
78
  readonly exitStatus: number;
79
79
  };
80
+ export type PrChildPlaybookId = 'code';
81
+ export type PlaybookInput = {
82
+ readonly stateId: 'fixChecks';
83
+ readonly sourceItem?: 'PR-3';
84
+ readonly playbookId: PrChildPlaybookId;
85
+ readonly text: string;
86
+ };
87
+ /** The playbook actor resolves with the child's own machine output. */
88
+ export type PlaybookOutput = JsonValue | undefined;
80
89
  export type CompactError = {
81
90
  readonly name: string;
82
91
  readonly message: string;
83
92
  };
84
- /** Sanitized canonical child result relayed as PR's own failure outcome. */
85
- export type CompletedChildResult = {
86
- readonly playbookId: PrChildPlaybookId;
93
+ export type ErrorRecord = {
94
+ readonly name: string;
95
+ readonly message: string;
96
+ readonly stack?: string;
97
+ };
98
+ /** Sanitized canonical `code` result relayed by the `fix-failed` outcome. */
99
+ export type CompletedCodeResult = {
100
+ readonly playbookId: 'code';
87
101
  readonly status: 'ok';
88
102
  readonly output?: JsonValue;
89
103
  } | {
90
- readonly playbookId: PrChildPlaybookId;
104
+ readonly playbookId: 'code';
91
105
  readonly status: 'aborted' | 'error';
92
106
  readonly error: CompactError;
93
107
  };
108
+ /** Public `pr` output interface (workflow-contracts catalog). */
94
109
  export type PrPlaybookOutput = {
95
110
  readonly status: 'merged';
96
- /** The pull request number, exactly as Coder reported it. */
97
111
  readonly pullRequest: string;
98
- /** The pull request URL, exactly as Coder reported it. */
99
112
  readonly pullRequestUrl: string;
100
- /** Whether the local default branch was fast-forwarded to the merged head. */
101
113
  readonly localDefaultUpdated: boolean;
102
114
  } | {
103
115
  readonly status: 'not-merged';
104
116
  readonly reason: 'not-published';
105
- /** Coder's complete result carrying the reason. */
106
117
  readonly coderOutput: string;
107
118
  } | {
108
119
  readonly status: 'not-merged';
109
120
  readonly reason: 'fix-failed';
110
121
  readonly pullRequest: string;
111
122
  readonly pullRequestUrl: string;
112
- /** The relayed canonical `code` result that ended the one fix attempt. */
113
- readonly childResult: CompletedChildResult;
123
+ readonly childResult: CompletedCodeResult;
114
124
  } | {
115
125
  readonly status: 'not-merged';
116
126
  readonly reason: 'fix-not-published' | 'checks-failed';
117
127
  readonly pullRequest: string;
118
128
  readonly pullRequestUrl: string;
119
- }
120
- /**
121
- * The merge command exited nonzero. It ran, so whether GitHub merged the
122
- * pull request is unknown — script output never enters context — and the
123
- * result claims neither a merge nor its absence.
124
- */
125
- | {
129
+ } | {
126
130
  readonly status: 'merge-unconfirmed';
127
131
  readonly pullRequest: string;
128
132
  readonly pullRequestUrl: string;
129
133
  };
134
+ export type PrInput = Readonly<Record<string, never>>;
130
135
  export type PrCompletion = 'merged' | 'not-published' | 'fix-failed' | 'fix-not-published' | 'checks-failed' | 'merge-unconfirmed';
131
- /** The machine reads no input: the caller input arrives on `START_PR`. */
132
- export type PrInput = Readonly<Record<never, never>>;
133
136
  export type PrContext = {
134
137
  readonly callerInput?: string;
135
138
  readonly pullRequest?: string;
136
139
  readonly pullRequestUrl?: string;
137
- readonly completion?: PrCompletion;
138
- readonly localDefaultUpdated?: boolean;
139
140
  readonly coderOutput?: string;
140
- readonly childFailure?: CompletedChildResult;
141
- readonly lastError?: unknown;
141
+ readonly childResult?: CompletedCodeResult;
142
+ readonly localDefaultUpdated?: boolean;
143
+ readonly completion?: PrCompletion;
144
+ readonly lastError?: ErrorRecord;
142
145
  readonly pendingBossQuestion?: PendingBossQuestion;
143
146
  readonly bossReply?: string;
144
147
  };
@@ -150,8 +153,7 @@ export type PrEvent = {
150
153
  readonly answer: string;
151
154
  readonly questionId?: 'openPullRequest';
152
155
  };
153
- /** PR-3's composed child input: the caller input, the pull request, and the static coding request. */
154
- export declare function fixChecksCallText(context: PrContext): string;
156
+ export declare function authoredChildResult(error: unknown, expectedPlaybookId: string): PlaybookCallResult | undefined;
155
157
  export declare const prMachine: import("xstate").StateMachine<PrContext, {
156
158
  readonly type: "START_PR";
157
159
  readonly callerInput: string;
@@ -160,10 +162,10 @@ export declare const prMachine: import("xstate").StateMachine<PrContext, {
160
162
  readonly answer: string;
161
163
  readonly questionId?: "openPullRequest";
162
164
  }, {
163
- [x: string]: import("xstate").ActorRefFromLogic<import("xstate").PromiseActorLogic<JsonValue | undefined, PlaybookInput, import("xstate").EventObject>> | import("xstate").ActorRefFromLogic<import("xstate").PromiseActorLogic<PlayerOutput, PlayerInput, import("xstate").EventObject>> | import("xstate").ActorRefFromLogic<import("xstate").PromiseActorLogic<ScriptOutput, ScriptInput, import("xstate").EventObject>> | undefined;
165
+ [x: string]: import("xstate").ActorRefFromLogic<import("xstate").PromiseActorLogic<PlaybookOutput, PlaybookInput, import("xstate").EventObject>> | import("xstate").ActorRefFromLogic<import("xstate").PromiseActorLogic<PlayerOutput, PlayerInput, import("xstate").EventObject>> | import("xstate").ActorRefFromLogic<import("xstate").PromiseActorLogic<ScriptOutput, ScriptInput, import("xstate").EventObject>> | undefined;
164
166
  }, {
165
167
  src: "playbook";
166
- logic: import("xstate").PromiseActorLogic<JsonValue | undefined, PlaybookInput, import("xstate").EventObject>;
168
+ logic: import("xstate").PromiseActorLogic<PlaybookOutput, PlaybookInput, import("xstate").EventObject>;
167
169
  id: string | undefined;
168
170
  } | {
169
171
  src: "player";
@@ -183,68 +185,63 @@ export declare const prMachine: import("xstate").StateMachine<PrContext, {
183
185
  } | {
184
186
  type: "rememberActorError";
185
187
  params: import("xstate").NonReducibleUnknown;
186
- } | {
187
- type: "rememberPendingQuestion";
188
- params: import("xstate").NonReducibleUnknown;
189
188
  } | {
190
189
  type: "rememberBossReply";
191
190
  params: import("xstate").NonReducibleUnknown;
192
- } | {
193
- type: "rememberEmptyBossReplyError";
194
- params: import("xstate").NonReducibleUnknown;
195
191
  } | {
196
192
  type: "rememberMalformedPlayerOutput";
197
193
  params: import("xstate").NonReducibleUnknown;
198
194
  } | {
199
- type: "completeWithInsufficientCodeResult";
195
+ type: "clearBossReplyContext";
200
196
  params: import("xstate").NonReducibleUnknown;
201
197
  } | {
202
- type: "completeWithCodeFailure";
198
+ type: "setPendingBossQuestion";
203
199
  params: import("xstate").NonReducibleUnknown;
204
200
  } | {
205
201
  type: "startPr";
206
202
  params: import("xstate").NonReducibleUnknown;
207
203
  } | {
208
- type: "rememberPullRequest";
204
+ type: "rememberOpened";
209
205
  params: import("xstate").NonReducibleUnknown;
210
206
  } | {
211
207
  type: "completeNotPublished";
212
208
  params: import("xstate").NonReducibleUnknown;
209
+ } | {
210
+ type: "rememberEmptyBossReplyError";
211
+ params: import("xstate").NonReducibleUnknown;
212
+ } | {
213
+ type: "completeWithCodeFailure";
214
+ params: import("xstate").NonReducibleUnknown;
215
+ } | {
216
+ type: "completeWithInsufficientCodeResult";
217
+ params: import("xstate").NonReducibleUnknown;
213
218
  } | {
214
219
  type: "completeFixNotPublished";
215
220
  params: import("xstate").NonReducibleUnknown;
216
221
  } | {
217
- type: "completeChecksStillFailing";
222
+ type: "completeChecksFailed";
218
223
  params: import("xstate").NonReducibleUnknown;
219
224
  } | {
220
- type: "completeMergeRefused";
225
+ type: "completeMergeUnconfirmed";
221
226
  params: import("xstate").NonReducibleUnknown;
222
227
  } | {
223
- type: "completeMerged";
228
+ type: "completeMergedLocalUpdated";
224
229
  params: import("xstate").NonReducibleUnknown;
225
230
  } | {
226
- type: "completeMergedLocalBehind";
231
+ type: "completeMergedLocalNotUpdated";
227
232
  params: import("xstate").NonReducibleUnknown;
228
233
  } | {
229
234
  type: "rememberMalformedScriptOutput";
230
- params: {
231
- readonly sourceItem: PrScriptSourceItem;
232
- };
235
+ params: import("xstate").NonReducibleUnknown;
236
+ } | {
237
+ type: "rememberMalformedChildOutput";
238
+ params: import("xstate").NonReducibleUnknown;
233
239
  }, {
234
240
  type: "needsBossReply";
235
241
  params: unknown;
236
242
  } | {
237
243
  type: "emptyBossReply";
238
244
  params: unknown;
239
- } | {
240
- type: "authoredCodeFailure";
241
- params: unknown;
242
- } | {
243
- type: "checksPassed";
244
- params: unknown;
245
- } | {
246
- type: "checksFailed";
247
- params: unknown;
248
245
  } | {
249
246
  type: "fixPublished";
250
247
  params: unknown;
@@ -276,28 +273,38 @@ export declare const prMachine: import("xstate").StateMachine<PrContext, {
276
273
  type: "isCodeSuccess";
277
274
  params: unknown;
278
275
  } | {
279
- type: "resumesOpenPullRequest";
276
+ type: "isInsufficientCodeResult";
280
277
  params: unknown;
281
- }, never, "failed" | "ready" | "awaitBossReply" | "openPullRequest" | "waitForChecks" | "fixChecks" | "publishFix" | "waitForChecksAfterFix" | "mergePullRequest" | "updateLocalDefault" | "notPublished" | "fixNotPublished" | "checksStillFailing" | "merged" | "mergeRefused" | "mergedLocalBehind" | "fixFailed", string, Readonly<Record<never, never>>, {
278
+ } | {
279
+ type: "isAuthoredCodeFailure";
280
+ params: unknown;
281
+ } | {
282
+ type: "validStartPr";
283
+ params: unknown;
284
+ } | {
285
+ type: "waitForChecksPassed";
286
+ params: unknown;
287
+ } | {
288
+ type: "waitForChecksFailed";
289
+ params: unknown;
290
+ } | {
291
+ type: "waitForFixChecksPassed";
292
+ params: unknown;
293
+ }, never, "failed" | "ready" | "awaitBossReply" | "openPullRequest" | "waitForChecks" | "fixChecks" | "publishFix" | "waitForFixChecks" | "mergePullRequest" | "updateLocalDefault" | "notPublished" | "checksFailed" | "fixNotPublished" | "mergedLocalUpdated" | "mergedLocalNotUpdated" | "fixFailed" | "mergeUnconfirmed", string, Readonly<Record<string, never>>, {
282
294
  readonly status: "merged";
283
- /** The pull request number, exactly as Coder reported it. */
284
295
  readonly pullRequest: string;
285
- /** The pull request URL, exactly as Coder reported it. */
286
296
  readonly pullRequestUrl: string;
287
- /** Whether the local default branch was fast-forwarded to the merged head. */
288
297
  readonly localDefaultUpdated: boolean;
289
298
  } | {
290
299
  readonly status: "not-merged";
291
300
  readonly reason: "not-published";
292
- /** Coder's complete result carrying the reason. */
293
301
  readonly coderOutput: string;
294
302
  } | {
295
303
  readonly status: "not-merged";
296
304
  readonly reason: "fix-failed";
297
305
  readonly pullRequest: string;
298
306
  readonly pullRequestUrl: string;
299
- /** The relayed canonical `code` result that ended the one fix attempt. */
300
- readonly childResult: CompletedChildResult;
307
+ readonly childResult: CompletedCodeResult;
301
308
  } | {
302
309
  readonly status: "not-merged";
303
310
  readonly reason: "fix-not-published" | "checks-failed";
@@ -316,6 +323,9 @@ export declare const prMachine: import("xstate").StateMachine<PrContext, {
316
323
  readonly openPullRequest: {
317
324
  id: "openPullRequest";
318
325
  };
326
+ readonly awaitBossReply: {
327
+ id: "awaitBossReply";
328
+ };
319
329
  readonly waitForChecks: {
320
330
  id: "waitForChecks";
321
331
  };
@@ -325,8 +335,8 @@ export declare const prMachine: import("xstate").StateMachine<PrContext, {
325
335
  readonly publishFix: {
326
336
  id: "publishFix";
327
337
  };
328
- readonly waitForChecksAfterFix: {
329
- id: "waitForChecksAfterFix";
338
+ readonly waitForFixChecks: {
339
+ id: "waitForFixChecks";
330
340
  };
331
341
  readonly mergePullRequest: {
332
342
  id: "mergePullRequest";
@@ -334,17 +344,14 @@ export declare const prMachine: import("xstate").StateMachine<PrContext, {
334
344
  readonly updateLocalDefault: {
335
345
  id: "updateLocalDefault";
336
346
  };
337
- readonly awaitBossReply: {
338
- id: "awaitBossReply";
339
- };
340
347
  readonly failed: {
341
348
  id: "failed";
342
349
  };
343
- readonly merged: {
344
- id: "merged";
350
+ readonly mergedLocalUpdated: {
351
+ id: "mergedLocalUpdated";
345
352
  };
346
- readonly mergedLocalBehind: {
347
- id: "mergedLocalBehind";
353
+ readonly mergedLocalNotUpdated: {
354
+ id: "mergedLocalNotUpdated";
348
355
  };
349
356
  readonly notPublished: {
350
357
  id: "notPublished";
@@ -355,11 +362,11 @@ export declare const prMachine: import("xstate").StateMachine<PrContext, {
355
362
  readonly fixNotPublished: {
356
363
  id: "fixNotPublished";
357
364
  };
358
- readonly checksStillFailing: {
359
- id: "checksStillFailing";
365
+ readonly checksFailed: {
366
+ id: "checksFailed";
360
367
  };
361
- readonly mergeRefused: {
362
- id: "mergeRefused";
368
+ readonly mergeUnconfirmed: {
369
+ id: "mergeUnconfirmed";
363
370
  };
364
371
  };
365
372
  }>;