@sublang/playbook 15.1.0 → 17.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 (102) hide show
  1. package/README.md +2 -0
  2. package/docs/cli.md +36 -18
  3. package/docs/configuration.md +7 -5
  4. package/docs/embedding.md +28 -7
  5. package/package.json +4 -4
  6. package/reference/sdlc/branch.playbook/branch.fsm.d.ts +63 -33
  7. package/reference/sdlc/branch.playbook/branch.fsm.js +190 -108
  8. package/reference/sdlc/branch.playbook/branch.fsm.ts +269 -147
  9. package/reference/sdlc/branch.playbook/branch.gears.md +7 -17
  10. package/reference/sdlc/branch.playbook/branch.playbook.d.ts +12 -16
  11. package/reference/sdlc/branch.playbook/branch.playbook.js +112 -101
  12. package/reference/sdlc/branch.playbook/branch.playbook.ts +128 -171
  13. package/reference/sdlc/branch.playbook/branch.registry.d.ts +3 -2
  14. package/reference/sdlc/branch.playbook/branch.registry.ts +6 -2
  15. package/reference/sdlc/captain.md +19 -10
  16. package/reference/sdlc/captain.playbook/captain.fsm.d.ts +6 -2
  17. package/reference/sdlc/captain.playbook/captain.fsm.js +19 -7
  18. package/reference/sdlc/captain.playbook/captain.fsm.ts +25 -10
  19. package/reference/sdlc/captain.playbook/captain.gears.md +16 -8
  20. package/reference/sdlc/captain.playbook/captain.playbook.d.ts +1 -1
  21. package/reference/sdlc/captain.playbook/captain.playbook.js +3 -2
  22. package/reference/sdlc/captain.playbook/captain.playbook.ts +4 -3
  23. package/reference/sdlc/code.playbook/bin/interactive-session.js +14 -1
  24. package/reference/sdlc/code.playbook/bin/portable-codec.js +3 -0
  25. package/reference/sdlc/code.playbook/bin/repository-effects.js +1 -0
  26. package/reference/sdlc/code.playbook/bin/run.js +128 -85
  27. package/reference/sdlc/code.playbook/bin/session-host.js +40 -8
  28. package/reference/sdlc/code.playbook/bin/session-store.js +162 -34
  29. package/reference/sdlc/code.playbook/code.fsm.d.ts +146 -93
  30. package/reference/sdlc/code.playbook/code.fsm.introspect.d.ts +8 -8
  31. package/reference/sdlc/code.playbook/code.fsm.introspect.ts +13 -13
  32. package/reference/sdlc/code.playbook/code.fsm.js +609 -649
  33. package/reference/sdlc/code.playbook/code.fsm.ts +890 -821
  34. package/reference/sdlc/code.playbook/code.gears.md +39 -29
  35. package/reference/sdlc/code.playbook/code.playbook.d.ts +13 -16
  36. package/reference/sdlc/code.playbook/code.playbook.js +166 -147
  37. package/reference/sdlc/code.playbook/code.playbook.ts +180 -229
  38. package/reference/sdlc/code.playbook/code.registry.d.ts +3 -2
  39. package/reference/sdlc/code.playbook/code.registry.ts +6 -2
  40. package/reference/sdlc/code.playbook/host-capabilities.d.ts +3 -0
  41. package/reference/sdlc/code.playbook/playbook-captain.d.ts +74 -2
  42. package/reference/sdlc/code.playbook/playbook-captain.js +1548 -468
  43. package/reference/sdlc/code.playbook/playbook-captain.ts +1993 -573
  44. package/reference/sdlc/code.playbook/session-host.d.ts +4 -1
  45. package/reference/sdlc/code.playbook/session-store.d.ts +17 -0
  46. package/reference/sdlc/code.playbook/session-store.js +1 -0
  47. package/reference/sdlc/decide.md +1 -0
  48. package/reference/sdlc/decide.playbook/decide.fsm.d.ts +273 -157
  49. package/reference/sdlc/decide.playbook/decide.fsm.js +765 -732
  50. package/reference/sdlc/decide.playbook/decide.fsm.ts +1167 -945
  51. package/reference/sdlc/decide.playbook/decide.gears.md +28 -21
  52. package/reference/sdlc/decide.playbook/decide.playbook.d.ts +11 -59
  53. package/reference/sdlc/decide.playbook/decide.playbook.js +155 -3696
  54. package/reference/sdlc/decide.playbook/decide.playbook.ts +186 -5244
  55. package/reference/sdlc/decide.playbook/decide.registry.d.ts +8 -4
  56. package/reference/sdlc/decide.playbook/decide.registry.js +2 -2
  57. package/reference/sdlc/decide.playbook/decide.registry.ts +13 -6
  58. package/reference/sdlc/dev.playbook/dev.fsm.d.ts +116 -134
  59. package/reference/sdlc/dev.playbook/dev.fsm.js +517 -575
  60. package/reference/sdlc/dev.playbook/dev.fsm.ts +667 -787
  61. package/reference/sdlc/dev.playbook/dev.gears.md +52 -54
  62. package/reference/sdlc/dev.playbook/dev.playbook.d.ts +13 -10
  63. package/reference/sdlc/dev.playbook/dev.playbook.js +128 -120
  64. package/reference/sdlc/dev.playbook/dev.playbook.ts +143 -193
  65. package/reference/sdlc/dev.playbook/dev.registry.d.ts +3 -2
  66. package/reference/sdlc/dev.playbook/dev.registry.ts +6 -2
  67. package/reference/sdlc/pr.playbook/pr.fsm.d.ts +95 -88
  68. package/reference/sdlc/pr.playbook/pr.fsm.js +461 -518
  69. package/reference/sdlc/pr.playbook/pr.fsm.ts +533 -663
  70. package/reference/sdlc/pr.playbook/pr.gears.md +47 -63
  71. package/reference/sdlc/pr.playbook/pr.playbook.d.ts +13 -23
  72. package/reference/sdlc/pr.playbook/pr.playbook.js +118 -112
  73. package/reference/sdlc/pr.playbook/pr.playbook.ts +136 -190
  74. package/reference/sdlc/pr.playbook/pr.registry.d.ts +3 -2
  75. package/reference/sdlc/pr.playbook/pr.registry.ts +4 -2
  76. package/reference/sdlc/review.md +3 -3
  77. package/reference/sdlc/review.playbook/review.fsm.d.ts +150 -116
  78. package/reference/sdlc/review.playbook/review.fsm.js +479 -550
  79. package/reference/sdlc/review.playbook/review.fsm.ts +717 -662
  80. package/reference/sdlc/review.playbook/review.gears.md +32 -29
  81. package/reference/sdlc/review.playbook/review.playbook.d.ts +12 -12
  82. package/reference/sdlc/review.playbook/review.playbook.js +180 -155
  83. package/reference/sdlc/review.playbook/review.playbook.ts +190 -230
  84. package/reference/sdlc/review.playbook/review.registry.d.ts +6 -5
  85. package/reference/sdlc/review.playbook/review.registry.js +3 -3
  86. package/reference/sdlc/review.playbook/review.registry.ts +9 -5
  87. package/slc/gears2fsm.md +77 -8
  88. package/slc/link.md +127 -60
  89. package/slc/materialize-link.mjs +51 -13
  90. package/slc/optimize.md +4 -1
  91. package/slc/prefix-prompts.mjs +29 -28
  92. package/slc/prefix.md +27 -24
  93. package/slc/slc.pin-inputs.json +11 -2
  94. package/slc/text2gears.md +71 -11
  95. package/src/runtime.d.ts +46 -2
  96. package/src/runtime.ts +42 -2
  97. package/src/xstate-playbook-runtime.d.ts +63 -23
  98. package/src/xstate-playbook-runtime.js +1637 -475
  99. package/src/xstate-playbook-runtime.ts +2105 -532
  100. package/src/xstate-runtime.d.ts +3 -4
  101. package/src/xstate-runtime.js +52 -0
  102. package/src/xstate-runtime.ts +59 -4
@@ -1,31 +1,58 @@
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 CodeStateId = 'runFirstPhase' | 'reviewFirstCommit' | 'runIrTask' | 'reviewIrTask';
5
+ /** Canonical lowercase local id of the source role Coder. */
6
+ export type CodeRole = 'coder';
7
+ /** One role-id array per parallel group; CODE declares no parallel group. */
8
+ export declare const concurrentRoleSets: readonly (readonly CodeRole[])[];
9
+ /** Delegated-player working leaves (CODE-1, CODE-3). */
10
+ export type WorkingStateId = 'firstPhase' | 'irTaskPhase';
11
+ /** Working leaves that may suspend for, and resume from, a Boss reply. */
12
+ export type ResumableStateId = WorkingStateId;
13
+ /** Root `BOSS_INTERRUPT` targets. */
14
+ export type JumpableStateId = WorkingStateId;
15
+ /** Nested `review` call states (CODE-2, CODE-4). */
16
+ export type ReviewStateId = 'reviewNewIntentPhase' | 'reviewIrTaskPhase';
5
17
  export type CodeSourceItem = 'CODE-1' | 'CODE-2' | 'CODE-3' | 'CODE-4';
6
- export type CodePhase = 'direct' | 'ir-created' | 'ir-task-more' | 'ir-task-final';
7
- export type PendingBossQuestion = {
8
- readonly questionId: 'runFirstPhase' | 'runIrTask';
9
- readonly resumeStateId: 'runFirstPhase' | 'runIrTask';
18
+ /** The accepted phase outcome whose `review` call decides the next step. */
19
+ export type PhaseOutcome = 'directCommit' | 'irCommit' | 'moreTasks' | 'finalTask';
20
+ /** The literal nested-call target shared by both call states and guards. */
21
+ declare const REVIEW_PLAYBOOK_ID = "review";
22
+ export interface PendingBossQuestion {
23
+ readonly questionId: ResumableStateId;
24
+ readonly resumeStateId: ResumableStateId;
10
25
  readonly sourceItem: 'CODE-1' | 'CODE-3';
11
26
  readonly asker: {
12
27
  readonly kind: 'role';
13
- readonly roleId: 'coder';
28
+ readonly roleId: CodeRole;
14
29
  };
15
30
  readonly question: string;
16
- };
17
- export type PlayerInput = {
18
- readonly stateId: 'runFirstPhase' | 'runIrTask';
19
- readonly role: 'coder';
20
- readonly sourceItem: 'CODE-1' | 'CODE-3';
31
+ }
32
+ interface PlayerInputBase {
33
+ readonly role: CodeRole;
34
+ /** The source item's full final prompt, verbatim. */
21
35
  readonly prompt: string;
36
+ /** This state's local result contract: guard name → description. */
22
37
  readonly result: Readonly<Record<string, string>>;
23
- readonly callerInput: string;
38
+ /** `<caller-input>`: the caller's complete coding request. */
39
+ readonly callerInput?: string;
40
+ /** `<run-results>`: relevant run results; empty when none were supplied. */
24
41
  readonly runResults: string;
25
- readonly irNumber?: string;
26
42
  readonly pendingBossQuestion?: PendingBossQuestion;
27
43
  readonly bossReply?: string;
28
- };
44
+ }
45
+ export interface FirstPhasePlayerInput extends PlayerInputBase {
46
+ readonly stateId: 'firstPhase';
47
+ readonly sourceItem: 'CODE-1';
48
+ }
49
+ export interface IrTaskPhasePlayerInput extends PlayerInputBase {
50
+ readonly stateId: 'irTaskPhase';
51
+ readonly sourceItem: 'CODE-3';
52
+ /** `<ir-number>`: the IR whose next unfinished task this phase implements. */
53
+ readonly irNumber?: string;
54
+ }
55
+ export type PlayerInput = FirstPhasePlayerInput | IrTaskPhasePlayerInput;
29
56
  export type PlayerOutput = {
30
57
  readonly guard: 'directCommit';
31
58
  readonly coderOutput: string;
@@ -51,82 +78,116 @@ export type PlayerOutput = {
51
78
  readonly guard: 'needsBossReply';
52
79
  readonly question: string;
53
80
  };
54
- export type PlaybookInput = {
55
- readonly stateId: 'reviewFirstCommit' | 'reviewIrTask';
81
+ export interface PlaybookInput {
82
+ readonly stateId: ReviewStateId;
56
83
  readonly sourceItem: 'CODE-2' | 'CODE-4';
57
- readonly playbookId: 'review';
84
+ readonly playbookId: typeof REVIEW_PLAYBOOK_ID;
58
85
  readonly text: string;
59
- };
60
- export type ReviewOutput = {
86
+ }
87
+ /** A successful call yields the child's own JSON-safe machine output. */
88
+ export type PlaybookOutput = JsonValue | undefined;
89
+ /** Public output interface of the packaged builtin `review`. */
90
+ export interface ReviewPassOutput {
61
91
  readonly noUnsettledFindings: true;
62
- /**
63
- * Exact repository revision at which the review scope was evaluated:
64
- * the last review-fix commit when one landed, otherwise the clean
65
- * round's receipt-observed HEAD (DR-045). Always present.
66
- */
67
92
  readonly evaluatedRevision: string;
68
- };
69
- export type CompactError = {
93
+ }
94
+ export interface CompactError {
70
95
  readonly name: string;
71
96
  readonly message: string;
97
+ }
98
+ export interface ErrorRecord {
99
+ readonly name: string;
100
+ readonly message: string;
101
+ readonly stack?: string;
102
+ }
103
+ /** Sanitized completed-result evidence of the `review` call that ended CODE. */
104
+ export type CompletedReviewResult = {
105
+ readonly playbookId: typeof REVIEW_PLAYBOOK_ID;
106
+ readonly status: 'ok';
107
+ readonly output?: JsonValue;
108
+ } | {
109
+ readonly playbookId: typeof REVIEW_PLAYBOOK_ID;
110
+ readonly status: 'aborted' | 'error';
111
+ readonly error: CompactError;
72
112
  };
73
- export type CodePlaybookOutput = {
113
+ /** Public output interface of the packaged builtin `code`. */
114
+ export type CodeOutput = {
74
115
  readonly status: 'complete';
75
- /** Exact identity of the last CODE-owned commit. */
76
116
  readonly lastCodeCommit: string;
77
- /** Exact repository revision the final passing review evaluated. */
78
117
  readonly finalEvaluatedRevision: string;
79
- /** Every phase's review passed with no unsettled findings. */
80
118
  readonly allReviewsPassed: true;
81
119
  } | {
82
120
  readonly status: 'review-failed';
83
- /** Exact identity of the last CODE-owned commit. */
84
121
  readonly lastCodeCommit: string;
85
122
  readonly error: CompactError;
86
123
  };
87
- export type CodingInput = {
124
+ export interface CodeInput {
125
+ /** Optional seed for `<run-results>`; `START_CODE` may supply its own. */
88
126
  readonly runResults?: string;
89
- };
90
- export type CodingContext = {
127
+ }
128
+ export interface CodeContext {
129
+ /** `<run-results>`: relevant run results relayed to every phase. */
91
130
  readonly runResults: string;
131
+ /** `<caller-input>`: the caller's coding request and relevant context. */
92
132
  readonly callerInput?: string;
133
+ /** `<code-commit>`: the accepted `latestCommit` of the latest phase. */
134
+ readonly codeCommit?: string;
135
+ /** `<coder-output>`: Coder's verbatim final text for the latest phase. */
93
136
  readonly coderOutput?: string;
94
- readonly latestCommit?: string;
137
+ /** `<ir-number>`: the created or continued IR. */
95
138
  readonly irNumber?: string;
139
+ /** `<ir-task>`: the IR task the latest IR-task phase implemented. */
96
140
  readonly irTask?: string;
141
+ /** The accepted outcome of the phase under review. */
142
+ readonly phaseOutcome?: PhaseOutcome;
143
+ /** Revision evaluated by the latest passing review. */
97
144
  readonly evaluatedRevision?: string;
98
- readonly phase?: CodePhase;
99
- readonly completion?: 'complete' | 'review-failed';
145
+ /** Compact failure CODE reports when review did not pass a phase. */
100
146
  readonly reviewError?: CompactError;
101
- readonly lastError?: unknown;
147
+ /** Sanitized evidence of the review result that ended CODE. */
148
+ readonly reviewEvidence?: CompletedReviewResult;
149
+ readonly lastError?: ErrorRecord;
102
150
  readonly pendingBossQuestion?: PendingBossQuestion;
103
151
  readonly bossReply?: string;
104
- };
105
- export type CodingEvent = {
152
+ }
153
+ export type CodeEvent = {
106
154
  readonly type: 'START_CODE';
107
155
  readonly callerInput: string;
156
+ readonly runResults?: string;
157
+ } | {
158
+ readonly type: 'BOSS_INTERRUPT';
159
+ readonly targetId: JumpableStateId;
108
160
  } | {
109
161
  readonly type: 'BOSS_REPLY';
110
162
  readonly answer: string;
111
- readonly questionId?: 'runFirstPhase' | 'runIrTask';
163
+ readonly questionId?: ResumableStateId;
112
164
  };
113
- export declare const codingMachine: import("xstate").StateMachine<CodingContext, {
165
+ /**
166
+ * Recognizes an authored rejected child result: an aborted or error call, or
167
+ * a child that completed at its own authored failure terminal.
168
+ */
169
+ export declare function authoredChildResult(error: unknown, expectedPlaybookId: string): PlaybookCallResult | undefined;
170
+ export declare const codeMachine: import("xstate").StateMachine<CodeContext, {
114
171
  readonly type: "START_CODE";
115
172
  readonly callerInput: string;
173
+ readonly runResults?: string;
174
+ } | {
175
+ readonly type: "BOSS_INTERRUPT";
176
+ readonly targetId: JumpableStateId;
116
177
  } | {
117
178
  readonly type: "BOSS_REPLY";
118
179
  readonly answer: string;
119
- readonly questionId?: "runFirstPhase" | "runIrTask";
180
+ readonly questionId?: ResumableStateId;
120
181
  }, {
121
- [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>> | undefined;
182
+ [x: string]: import("xstate").ActorRefFromLogic<import("xstate").PromiseActorLogic<PlayerOutput, PlayerInput, import("xstate").EventObject>> | import("xstate").ActorRefFromLogic<import("xstate").PromiseActorLogic<PlaybookOutput, PlaybookInput, import("xstate").EventObject>> | undefined;
122
183
  }, {
123
- src: "playbook";
124
- logic: import("xstate").PromiseActorLogic<JsonValue | undefined, PlaybookInput, import("xstate").EventObject>;
125
- id: string | undefined;
126
- } | {
127
184
  src: "player";
128
185
  logic: import("xstate").PromiseActorLogic<PlayerOutput, PlayerInput, import("xstate").EventObject>;
129
186
  id: string | undefined;
187
+ } | {
188
+ src: "playbook";
189
+ logic: import("xstate").PromiseActorLogic<PlaybookOutput, PlaybookInput, import("xstate").EventObject>;
190
+ id: string | undefined;
130
191
  }, {
131
192
  type: "playbook.acceptedOutcome";
132
193
  params: {
@@ -138,91 +199,83 @@ export declare const codingMachine: import("xstate").StateMachine<CodingContext,
138
199
  type: "rememberActorError";
139
200
  params: import("xstate").NonReducibleUnknown;
140
201
  } | {
141
- type: "startCoding";
202
+ type: "resetForInterrupt";
142
203
  params: import("xstate").NonReducibleUnknown;
143
204
  } | {
144
- type: "rememberDirectCommit";
145
- params: import("xstate").NonReducibleUnknown;
146
- } | {
147
- type: "rememberIrCommit";
205
+ type: "rememberBossReply";
148
206
  params: import("xstate").NonReducibleUnknown;
149
207
  } | {
150
- type: "rememberMoreTasks";
208
+ type: "rememberMalformedPlayerOutput";
151
209
  params: import("xstate").NonReducibleUnknown;
152
210
  } | {
153
- type: "rememberFinalTask";
211
+ type: "clearBossReplyContext";
154
212
  params: import("xstate").NonReducibleUnknown;
155
213
  } | {
156
- type: "rememberPendingQuestion";
214
+ type: "rememberAuthoredReviewFailure";
157
215
  params: import("xstate").NonReducibleUnknown;
158
216
  } | {
159
- type: "rememberBossReply";
217
+ type: "startCode";
160
218
  params: import("xstate").NonReducibleUnknown;
161
219
  } | {
162
- type: "rememberEmptyBossReplyError";
220
+ type: "rememberPhaseCommit";
163
221
  params: import("xstate").NonReducibleUnknown;
164
222
  } | {
165
- type: "completeSuccessfully";
166
- params: import("xstate").NonReducibleUnknown;
223
+ type: "setPendingBossQuestion";
224
+ params: {
225
+ readonly resumeStateId: ResumableStateId;
226
+ };
167
227
  } | {
168
- type: "completeWithReviewFailure";
228
+ type: "rememberReviewPass";
169
229
  params: import("xstate").NonReducibleUnknown;
170
230
  } | {
171
- type: "completeWithInvalidReviewOutput";
231
+ type: "rememberReviewNotPassed";
172
232
  params: import("xstate").NonReducibleUnknown;
173
233
  } | {
174
- type: "rememberMalformedPlayerOutput";
234
+ type: "rememberMalformedBossReply";
175
235
  params: import("xstate").NonReducibleUnknown;
176
236
  }, {
177
- type: "needsBossReply";
237
+ type: "acceptDirectCommit";
178
238
  params: unknown;
179
239
  } | {
180
- type: "isDirectCommit";
240
+ type: "acceptIrCommit";
181
241
  params: unknown;
182
242
  } | {
183
- type: "isIrCommit";
243
+ type: "acceptMoreTasks";
184
244
  params: unknown;
185
245
  } | {
186
- type: "isMoreTasks";
187
- params: unknown;
188
- } | {
189
- type: "isFinalTask";
246
+ type: "acceptFinalTask";
190
247
  params: unknown;
191
248
  } | {
192
249
  type: "authoredReviewFailure";
193
250
  params: unknown;
194
251
  } | {
195
- type: "reviewApprovedDirect";
252
+ type: "needsBossReplyWithQuestion";
196
253
  params: unknown;
197
254
  } | {
198
- type: "reviewApprovedIrCreated";
255
+ type: "validStartCode";
199
256
  params: unknown;
200
257
  } | {
201
- type: "reviewApprovedMoreTasks";
258
+ type: "emptyBossReply";
202
259
  params: unknown;
203
260
  } | {
204
- type: "reviewApprovedFinalTask";
261
+ type: "reviewPassedDirect";
205
262
  params: unknown;
206
263
  } | {
207
- type: "emptyBossReply";
264
+ type: "reviewPassedNewIr";
208
265
  params: unknown;
209
266
  } | {
210
- type: "resumesFirstPhase";
267
+ type: "reviewPassedNonfinalTask";
211
268
  params: unknown;
212
269
  } | {
213
- type: "resumesIrTask";
270
+ type: "reviewPassedFinalTask";
214
271
  params: unknown;
215
- }, never, "done" | "failed" | "ready" | "awaitBossReply" | "runFirstPhase" | "reviewFirstCommit" | "runIrTask" | "reviewIrTask" | "reportedReviewFailure", string, CodingInput, {
272
+ }, never, "done" | "failed" | "ready" | "awaitBossReply" | "firstPhase" | "irTaskPhase" | "reviewNewIntentPhase" | "reviewIrTaskPhase" | "reviewFailed", string, CodeInput, {
216
273
  readonly status: "complete";
217
- /** Exact identity of the last CODE-owned commit. */
218
274
  readonly lastCodeCommit: string;
219
- /** Exact repository revision the final passing review evaluated. */
220
275
  readonly finalEvaluatedRevision: string;
221
- /** Every phase's review passed with no unsettled findings. */
222
276
  readonly allReviewsPassed: true;
223
277
  } | {
224
278
  readonly status: "review-failed";
225
- /** Exact identity of the last CODE-owned commit. */
226
279
  readonly lastCodeCommit: string;
227
280
  readonly error: CompactError;
228
281
  }, import("xstate").EventObject, import("xstate").MetaObject, {
@@ -231,17 +284,17 @@ export declare const codingMachine: import("xstate").StateMachine<CodingContext,
231
284
  readonly ready: {
232
285
  id: "ready";
233
286
  };
234
- readonly runFirstPhase: {
235
- id: "runFirstPhase";
287
+ readonly firstPhase: {
288
+ id: "firstPhase";
236
289
  };
237
- readonly reviewFirstCommit: {
238
- id: "reviewFirstCommit";
290
+ readonly reviewNewIntentPhase: {
291
+ id: "reviewNewIntentPhase";
239
292
  };
240
- readonly runIrTask: {
241
- id: "runIrTask";
293
+ readonly irTaskPhase: {
294
+ id: "irTaskPhase";
242
295
  };
243
- readonly reviewIrTask: {
244
- id: "reviewIrTask";
296
+ readonly reviewIrTaskPhase: {
297
+ id: "reviewIrTaskPhase";
245
298
  };
246
299
  readonly awaitBossReply: {
247
300
  id: "awaitBossReply";
@@ -249,12 +302,12 @@ export declare const codingMachine: import("xstate").StateMachine<CodingContext,
249
302
  readonly failed: {
250
303
  id: "failed";
251
304
  };
252
- readonly reportedReviewFailure: {
253
- id: "reportedReviewFailure";
305
+ readonly reviewFailed: {
306
+ id: "reviewFailed";
254
307
  };
255
308
  readonly done: {
256
309
  id: "done";
257
310
  };
258
311
  };
259
312
  }>;
260
- export default codingMachine;
313
+ export default codeMachine;
@@ -1,6 +1,6 @@
1
- import type { CodingContext, PlaybookInput, PlayerInput, codingMachine } from './code.fsm.js';
1
+ import type { CodeContext, PlaybookInput, PlayerInput, codeMachine } from './code.fsm.js';
2
2
  export type TransitionGuard = (args: {
3
- context: CodingContext;
3
+ context: CodeContext;
4
4
  event: unknown;
5
5
  }) => boolean;
6
6
  export interface InvokingTransition {
@@ -12,24 +12,24 @@ export interface InvokingTransition {
12
12
  export interface PlayerStateInfo {
13
13
  readonly stateId: string;
14
14
  readonly sourceItem: string;
15
- readonly getInput: (context: CodingContext) => PlayerInput;
15
+ readonly getInput: (context: CodeContext) => PlayerInput;
16
16
  readonly transitions: readonly InvokingTransition[];
17
17
  }
18
18
  export interface NestedPlaybookStateInfo {
19
19
  readonly stateId: string;
20
20
  readonly sourceItem: string;
21
- readonly getInput: (context: CodingContext) => PlaybookInput;
21
+ readonly getInput: (context: CodeContext) => PlaybookInput;
22
22
  readonly transitions: readonly InvokingTransition[];
23
23
  }
24
24
  export interface AwaitBossReplyInfo {
25
25
  readonly stateId: 'awaitBossReply';
26
26
  readonly bossReplyTransitions: readonly InvokingTransition[];
27
27
  }
28
- export declare function enumeratePlayerStates(machine: typeof codingMachine): readonly PlayerStateInfo[];
28
+ export declare function enumeratePlayerStates(machine: typeof codeMachine): readonly PlayerStateInfo[];
29
29
  export declare const enumerateCaptainStates: typeof enumeratePlayerStates;
30
- export declare function enumerateNestedPlaybookStates(machine: typeof codingMachine): readonly NestedPlaybookStateInfo[];
31
- export declare function enumerateAwaitBossReply(machine: typeof codingMachine): AwaitBossReplyInfo;
32
- export declare function enumerateRootEvents(machine: typeof codingMachine): {
30
+ export declare function enumerateNestedPlaybookStates(machine: typeof codeMachine): readonly NestedPlaybookStateInfo[];
31
+ export declare function enumerateAwaitBossReply(machine: typeof codeMachine): AwaitBossReplyInfo;
32
+ export declare function enumerateRootEvents(machine: typeof codeMachine): {
33
33
  readonly startCode: {
34
34
  readonly target: string;
35
35
  };
@@ -2,14 +2,14 @@
2
2
  // SPDX-FileCopyrightText: 2026 SubLang International <https://sublang.ai>
3
3
 
4
4
  import type {
5
- CodingContext,
5
+ CodeContext,
6
6
  PlaybookInput,
7
7
  PlayerInput,
8
- codingMachine,
8
+ codeMachine,
9
9
  } from './code.fsm.js';
10
10
 
11
11
  export type TransitionGuard = (args: {
12
- context: CodingContext;
12
+ context: CodeContext;
13
13
  event: unknown;
14
14
  }) => boolean;
15
15
 
@@ -23,14 +23,14 @@ export interface InvokingTransition {
23
23
  export interface PlayerStateInfo {
24
24
  readonly stateId: string;
25
25
  readonly sourceItem: string;
26
- readonly getInput: (context: CodingContext) => PlayerInput;
26
+ readonly getInput: (context: CodeContext) => PlayerInput;
27
27
  readonly transitions: readonly InvokingTransition[];
28
28
  }
29
29
 
30
30
  export interface NestedPlaybookStateInfo {
31
31
  readonly stateId: string;
32
32
  readonly sourceItem: string;
33
- readonly getInput: (context: CodingContext) => PlaybookInput;
33
+ readonly getInput: (context: CodeContext) => PlaybookInput;
34
34
  readonly transitions: readonly InvokingTransition[];
35
35
  }
36
36
 
@@ -41,7 +41,7 @@ export interface AwaitBossReplyInfo {
41
41
 
42
42
  type RawInvoke = {
43
43
  src?: unknown;
44
- input?: (args: { context: CodingContext }) => PlayerInput | PlaybookInput;
44
+ input?: (args: { context: CodeContext }) => PlayerInput | PlaybookInput;
45
45
  onDone?: unknown;
46
46
  };
47
47
 
@@ -60,7 +60,7 @@ type RawConfig = {
60
60
  states?: Readonly<Record<string, RawState>>;
61
61
  };
62
62
 
63
- function rawConfig(machine: typeof codingMachine): RawConfig {
63
+ function rawConfig(machine: typeof codeMachine): RawConfig {
64
64
  return (machine as unknown as { config: RawConfig }).config;
65
65
  }
66
66
 
@@ -84,13 +84,13 @@ function transitions(value: unknown): readonly InvokingTransition[] {
84
84
  }
85
85
 
86
86
  export function enumeratePlayerStates(
87
- machine: typeof codingMachine,
87
+ machine: typeof codeMachine,
88
88
  ): readonly PlayerStateInfo[] {
89
89
  const states = rawConfig(machine).states ?? {};
90
90
  return Object.entries(states).flatMap(([stateId, state]) => {
91
91
  const invoke = state.invoke;
92
92
  if (invoke?.src !== 'player' || invoke.input === undefined) return [];
93
- const getInput = (context: CodingContext): PlayerInput =>
93
+ const getInput = (context: CodeContext): PlayerInput =>
94
94
  invoke.input?.({ context }) as PlayerInput;
95
95
  const input = getInput({ runResults: '' });
96
96
  return [
@@ -108,13 +108,13 @@ export function enumeratePlayerStates(
108
108
  export const enumerateCaptainStates = enumeratePlayerStates;
109
109
 
110
110
  export function enumerateNestedPlaybookStates(
111
- machine: typeof codingMachine,
111
+ machine: typeof codeMachine,
112
112
  ): readonly NestedPlaybookStateInfo[] {
113
113
  const states = rawConfig(machine).states ?? {};
114
114
  return Object.entries(states).flatMap(([stateId, state]) => {
115
115
  const invoke = state.invoke;
116
116
  if (invoke?.src !== 'playbook' || invoke.input === undefined) return [];
117
- const getInput = (context: CodingContext): PlaybookInput =>
117
+ const getInput = (context: CodeContext): PlaybookInput =>
118
118
  invoke.input?.({ context }) as PlaybookInput;
119
119
  const input = getInput({ runResults: '' });
120
120
  return [
@@ -129,7 +129,7 @@ export function enumerateNestedPlaybookStates(
129
129
  }
130
130
 
131
131
  export function enumerateAwaitBossReply(
132
- machine: typeof codingMachine,
132
+ machine: typeof codeMachine,
133
133
  ): AwaitBossReplyInfo {
134
134
  const on = rawConfig(machine).states?.awaitBossReply?.on ?? {};
135
135
  return {
@@ -138,7 +138,7 @@ export function enumerateAwaitBossReply(
138
138
  };
139
139
  }
140
140
 
141
- export function enumerateRootEvents(machine: typeof codingMachine): {
141
+ export function enumerateRootEvents(machine: typeof codeMachine): {
142
142
  readonly startCode: { readonly target: string };
143
143
  } {
144
144
  const on = rawConfig(machine).states?.ready?.on ?? {};