@sublang/playbook 0.9.0 → 1.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 (51) hide show
  1. package/README.md +190 -151
  2. package/package.json +50 -6
  3. package/reference/sdlc/captain.md +102 -0
  4. package/reference/sdlc/captain.playbook/captain.fsm.d.ts +227 -0
  5. package/reference/sdlc/captain.playbook/captain.fsm.js +628 -0
  6. package/reference/sdlc/captain.playbook/captain.fsm.ts +851 -0
  7. package/reference/sdlc/captain.playbook/captain.gears.md +60 -0
  8. package/reference/sdlc/captain.playbook/captain.playbook.d.ts +23 -0
  9. package/reference/sdlc/captain.playbook/captain.playbook.js +1053 -0
  10. package/reference/sdlc/captain.playbook/captain.playbook.ts +1144 -0
  11. package/reference/sdlc/code.playbook/bin/playbook.js +158 -12
  12. package/reference/sdlc/code.playbook/bin/run.js +999 -0
  13. package/reference/sdlc/code.playbook/code.fsm.d.ts +11 -4
  14. package/reference/sdlc/code.playbook/code.fsm.introspect.d.ts +2 -2
  15. package/reference/sdlc/code.playbook/code.fsm.introspect.js +1 -1
  16. package/reference/sdlc/code.playbook/code.fsm.introspect.ts +6 -6
  17. package/reference/sdlc/code.playbook/code.fsm.js +334 -102
  18. package/reference/sdlc/code.playbook/code.fsm.ts +467 -180
  19. package/reference/sdlc/code.playbook/code.gears.md +11 -10
  20. package/reference/sdlc/code.playbook/code.playbook.d.ts +16 -19
  21. package/reference/sdlc/code.playbook/code.playbook.js +199 -488
  22. package/reference/sdlc/code.playbook/code.playbook.ts +327 -566
  23. package/reference/sdlc/code.playbook/code.registry.d.ts +0 -3
  24. package/reference/sdlc/code.playbook/code.registry.js +0 -3
  25. package/reference/sdlc/code.playbook/code.registry.ts +0 -6
  26. package/reference/sdlc/code.playbook/playbook-captain.d.ts +9 -4
  27. package/reference/sdlc/code.playbook/playbook-captain.js +889 -210
  28. package/reference/sdlc/code.playbook/playbook-captain.ts +1136 -257
  29. package/reference/sdlc/code.playbook/playbook.config.template.yaml +21 -0
  30. package/reference/sdlc/discuss.playbook/discuss.fsm.d.ts +396 -0
  31. package/reference/sdlc/discuss.playbook/discuss.fsm.js +2066 -0
  32. package/reference/sdlc/discuss.playbook/discuss.fsm.ts +2464 -0
  33. package/reference/sdlc/discuss.playbook/discuss.gears.md +251 -0
  34. package/reference/sdlc/discuss.playbook/discuss.playbook.d.ts +113 -0
  35. package/reference/sdlc/discuss.playbook/discuss.playbook.js +1514 -0
  36. package/reference/sdlc/discuss.playbook/discuss.playbook.ts +1926 -0
  37. package/reference/sdlc/discuss.playbook/discuss.registry.d.ts +58 -0
  38. package/reference/sdlc/discuss.playbook/discuss.registry.js +97 -0
  39. package/reference/sdlc/discuss.playbook/discuss.registry.ts +153 -0
  40. package/slc/gears2fsm.md +557 -57
  41. package/slc/link.md +1165 -89
  42. package/slc/optimize.md +92 -0
  43. package/slc/text2gears.md +255 -7
  44. package/src/runtime.d.ts +146 -3
  45. package/src/runtime.ts +201 -2
  46. package/src/xstate-playbook-runtime.d.ts +201 -0
  47. package/src/xstate-playbook-runtime.js +2058 -0
  48. package/src/xstate-playbook-runtime.ts +2792 -0
  49. package/src/xstate-runtime.d.ts +95 -0
  50. package/src/xstate-runtime.js +1258 -0
  51. package/src/xstate-runtime.ts +1816 -0
@@ -51,6 +51,7 @@ When an IR is done, Captain shall prompt Coder:
51
51
  > Avoid implementation specifics.
52
52
  > Avoid redundant spec items.
53
53
  > Ensure @specs/map.md reflects the changes.
54
+
54
55
  ## Reviewer
55
56
 
56
57
  For each finding in a review round, Coder either addresses it with changes or challenges it with a rebuttal.
@@ -92,6 +93,8 @@ When Committer commits Initial Changes from a Boss coding intent involving chang
92
93
  When Committer commits Initial Changes from a Boss coding intent involving changes both in and outside @specs/user/, @specs/dev/, and @specs/test/, Captain shall relay the Boss's coding intent to Reviewer along with the following prompt:
93
94
  > Review the latest commit.
94
95
  > Refer to the commit message.
96
+ > Flag any issues or improvements (numbered; no duplication).
97
+ > Think thoroughly — don't just approve or reject.
95
98
  > Verify any affected spec items are:
96
99
  >
97
100
  > - Complete & coherent: sufficient for you to reimplement code.
@@ -100,8 +103,6 @@ When Committer commits Initial Changes from a Boss coding intent involving chang
100
103
  > - Well organized: spec packages are finely scoped, with high cohesion and low coupling.
101
104
  >
102
105
  > Flag anything missing, redundant, over-specified, or under-specified.
103
- > Flag any issues or improvements (numbered; no duplication).
104
- > Think thoroughly — don't just approve or reject.
105
106
  > For context discovery, @specs/map.md indexes all spec files and @specs/meta.md describes the spec format.
106
107
  > Verify @specs/map.md reflects the changes.
107
108
  > If the change is ready to commit or push, don't raise nitpicks.
@@ -142,6 +143,8 @@ When Committer commits Initial Changes from an IR task involving changes only ou
142
143
  When Committer commits Initial Changes from an IR task involving changes both in and outside @specs/user/, @specs/dev/, and @specs/test/, Captain shall relay the IR's task description to Reviewer along with the following prompt:
143
144
  > Review the latest commit.
144
145
  > Refer to the commit message.
146
+ > Flag any issues or improvements (numbered; no duplication).
147
+ > Think thoroughly — don't just approve or reject.
145
148
  > Verify any affected spec items are:
146
149
  >
147
150
  > - Complete & coherent: sufficient for you to reimplement code.
@@ -150,8 +153,6 @@ When Committer commits Initial Changes from an IR task involving changes both in
150
153
  > - Well organized: spec packages are finely scoped, with high cohesion and low coupling.
151
154
  >
152
155
  > Flag anything missing, redundant, over-specified, or under-specified.
153
- > Flag any issues or improvements (numbered; no duplication).
154
- > Think thoroughly — don't just approve or reject.
155
156
  > For context discovery, @specs/map.md indexes all spec files and @specs/meta.md describes the spec format.
156
157
  > Verify @specs/map.md reflects the changes.
157
158
  > If the change is ready to commit or push, don't raise nitpicks.
@@ -192,6 +193,8 @@ When Coder makes unreviewed changes (outside of any Initial Changes) involving c
192
193
  When Coder makes unreviewed changes (outside of any Initial Changes) involving changes both in and outside @specs/user/, @specs/dev/, and @specs/test/ without raising rebuttals, Captain shall prompt Reviewer to begin a review round:
193
194
  > Review the unstaged and untracked changes in the context of the staged changes.
194
195
  > Understand the intent.
196
+ > Flag any issues or improvements (numbered; no duplication).
197
+ > Think thoroughly — don't just approve or reject.
195
198
  > Verify any affected spec items are:
196
199
  >
197
200
  > - Complete & coherent: sufficient for you to reimplement code.
@@ -200,8 +203,6 @@ When Coder makes unreviewed changes (outside of any Initial Changes) involving c
200
203
  > - Well organized: spec packages are finely scoped, with high cohesion and low coupling.
201
204
  >
202
205
  > Flag anything missing, redundant, over-specified, or under-specified.
203
- > Flag any issues or improvements (numbered; no duplication).
204
- > Think thoroughly — don't just approve or reject.
205
206
  > For context discovery, @specs/map.md indexes all spec files and @specs/meta.md describes the spec format.
206
207
  > Verify @specs/map.md reflects the changes.
207
208
  > If the change is ready to commit or push, don't raise nitpicks.
@@ -250,6 +251,8 @@ When Coder makes unreviewed changes (outside of any Initial Changes) involving c
250
251
  When Coder makes unreviewed changes (outside of any Initial Changes) involving changes both in and outside @specs/user/, @specs/dev/, and @specs/test/ and also raises rebuttals, Captain shall prompt Reviewer to begin a review round and relay the rebuttals along with the following prompt:
251
252
  > Review the unstaged and untracked changes in the context of the staged changes.
252
253
  > Understand the intent.
254
+ > Flag any issues or improvements (numbered; no duplication).
255
+ > Think thoroughly — don't just approve or reject.
253
256
  > Verify any affected spec items are:
254
257
  >
255
258
  > - Complete & coherent: sufficient for you to reimplement code.
@@ -258,8 +261,6 @@ When Coder makes unreviewed changes (outside of any Initial Changes) involving c
258
261
  > - Well organized: spec packages are finely scoped, with high cohesion and low coupling.
259
262
  >
260
263
  > Flag anything missing, redundant, over-specified, or under-specified.
261
- > Flag any issues or improvements (numbered; no duplication).
262
- > Think thoroughly — don't just approve or reject.
263
264
  > For context discovery, @specs/map.md indexes all spec files and @specs/meta.md describes the spec format.
264
265
  > Verify @specs/map.md reflects the changes.
265
266
  > If the change is ready to commit or push, don't raise nitpicks.
@@ -272,7 +273,7 @@ When Coder makes unreviewed changes (outside of any Initial Changes) involving c
272
273
 
273
274
  When Coder makes any Initial Changes and Reviewer has not played since the last commit, Captain shall prompt Committer:
274
275
  > Make a commit of the changes that belong in the repo, following @specs/dev/git.md (reread if necessary).
275
- > Write concisely.
276
+ > Write the commit message concisely.
276
277
  > Coder is <coder-llm>.
277
278
  > Format the `Co-authored-by` `<model>` token as the conventional human form of the substituted id (e.g., `claude-opus-4-7` → `Claude-Opus-4.7`, `gpt-5.5` → `GPT-5.5`).
278
279
 
@@ -282,7 +283,7 @@ Result guard: `needsBossInput` — Committing requires additional Boss input or
282
283
 
283
284
  When Coder makes any Initial Changes and Reviewer has played since the last commit, or Reviewer raises no findings on uncommitted changes and Coder has played since the last commit, Captain shall prompt Committer:
284
285
  > Make a commit of the changes that belong in the repo, following @specs/dev/git.md (reread if necessary).
285
- > Write concisely.
286
+ > Write the commit message concisely.
286
287
  > Coder is <coder-llm>; Reviewer is <reviewer-llm>.
287
288
  > Format the `Co-authored-by` `<model>` token as the conventional human form of the substituted id (e.g., `claude-opus-4-7` → `Claude-Opus-4.7`, `gpt-5.5` → `GPT-5.5`).
288
289
 
@@ -1,28 +1,24 @@
1
- import { type CaptainInput, type CaptainOutput, type CodingEvent, type CodingInput } from './code.fsm.js';
2
- import type { PlaybookPorts, PlaybookRuntime, PlayerResult } from '@sublang/playbook/runtime';
3
- export type { PlayerResult, PlaybookPorts, PlaybookRuntime };
1
+ import { normalizeErrorCompact, normalizeErrorFull, type PlaybookPlayerInput, type RuntimeBoundaryCalls } from '../../../src/xstate-runtime.js';
2
+ import { type PlayerInput, type PlayerOutput, type CodingEvent, type CodingInput } from './code.fsm.js';
3
+ import type { CaptainCallOptions, CaptainResult, JsonValue, NormalizedError, PlayerCallOptions, PlaybookCallRequest, PlaybookCallResult, PlaybookCallStart, PlaybookPendingCall, PlaybookRunResult, PlaybookRuntimeSnapshot, PlaybookSession, PlaybookState, PlaybookStateValue, PlaybookTraceEvent, PlaybookTraceType, PlaybookPorts, PlaybookRuntime, PlaybookRuntimeFactory, PlayerResult } from '@sublang/playbook/runtime';
4
+ export type { CaptainCallOptions, CaptainResult, JsonValue, NormalizedError, PlayerCallOptions, PlaybookCallRequest, PlaybookCallResult, PlaybookCallStart, PlaybookPendingCall, PlaybookRunResult, PlayerResult, PlaybookPorts, PlaybookSession, PlaybookState, PlaybookStateValue, PlaybookTraceEvent, PlaybookTraceType, PlaybookRuntime, PlaybookRuntimeFactory, PlaybookRuntimeSnapshot, };
4
5
  export type CodePlaybookOptions = CodingInput;
5
- declare function normalizeErrorCompact(err: unknown): {
6
- name: string;
7
- message: string;
8
- } | undefined;
9
- declare function normalizeErrorFull(err: unknown): {
10
- name: string;
11
- message: string;
12
- stack?: string;
13
- } | undefined;
14
6
  declare function normalizeEventForTelemetry(event: unknown): unknown;
15
- declare function composePlayerPrompt(input: CaptainInput): string;
16
- declare function resolvePlayerId(input: CaptainInput): string;
17
- declare function adjudicate(input: CaptainInput, finalText: string, ports: PlaybookPorts, signal: AbortSignal): Promise<CaptainOutput>;
18
- declare function classifyBossText(text: string, ports: PlaybookPorts, signal: AbortSignal, snapshotOrState?: unknown): Promise<CodingEvent | undefined>;
19
- declare function captainBridge(ports: PlaybookPorts, getActiveSignal?: () => AbortSignal | undefined): import("xstate").PromiseActorLogic<CaptainOutput, CaptainInput, import("xstate").EventObject>;
7
+ declare function composePlayerPrompt(input: PlayerInput): string;
8
+ declare function resolvePlayerId(input: PlayerInput): string;
9
+ declare function adjudicate(input: PlayerInput, finalText: string, ports: PlaybookPorts, signal: AbortSignal, boundary?: RuntimeBoundaryCalls): Promise<PlayerOutput>;
10
+ declare function classifyBossText(text: string, ports: PlaybookPorts, signal: AbortSignal, snapshotOrState?: unknown, boundary?: RuntimeBoundaryCalls): Promise<CodingEvent | undefined>;
11
+ declare function captainBridge(ports: PlaybookPorts, getActiveSignal?: () => AbortSignal | undefined, boundary?: RuntimeBoundaryCalls, onControlPlaneError?: (error: unknown) => void): import("xstate").PromiseActorLogic<import("../../../src/xstate-playbook-runtime.js").PlaybookActorOutput, PlaybookPlayerInput>;
20
12
  interface StateMetadata {
21
- player: CaptainInput['player'];
13
+ player: PlayerInput['player'];
22
14
  sourceItem: string;
23
15
  label: string;
24
16
  }
17
+ type BossReplyQuestionId = NonNullable<Extract<CodingEvent, {
18
+ type: 'BOSS_REPLY';
19
+ }>['questionId']>;
25
20
  interface PendingBossQuestionForStatus {
21
+ questionId: BossReplyQuestionId;
26
22
  resumeStateId: string;
27
23
  sourceItem: string;
28
24
  player: string;
@@ -55,4 +51,5 @@ export declare const _internal: {
55
51
  normalizeEventForTelemetry: typeof normalizeEventForTelemetry;
56
52
  VERBATIM_PAYLOAD_FIELDS: ReadonlySet<string>;
57
53
  };
58
- export default function createPlaybookRuntime(options: CodePlaybookOptions): PlaybookRuntime;
54
+ declare const createPlaybookRuntime: PlaybookRuntimeFactory<CodePlaybookOptions>;
55
+ export default createPlaybookRuntime;