@sublang/playbook 4.0.0 → 6.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 (73) hide show
  1. package/README.md +69 -122
  2. package/docs/assets/playbook-venn.svg +13 -0
  3. package/docs/cli.md +43 -26
  4. package/docs/configuration.md +63 -18
  5. package/docs/embedding.md +24 -16
  6. package/package.json +43 -22
  7. package/reference/sdlc/captain.md +70 -83
  8. package/reference/sdlc/captain.playbook/captain.fsm.d.ts +127 -142
  9. package/reference/sdlc/captain.playbook/captain.fsm.js +349 -470
  10. package/reference/sdlc/captain.playbook/captain.fsm.ts +535 -598
  11. package/reference/sdlc/captain.playbook/captain.gears.md +37 -41
  12. package/reference/sdlc/captain.playbook/captain.playbook.d.ts +90 -15
  13. package/reference/sdlc/captain.playbook/captain.playbook.js +466 -976
  14. package/reference/sdlc/captain.playbook/captain.playbook.ts +698 -1001
  15. package/reference/sdlc/code.md +55 -97
  16. package/reference/sdlc/code.playbook/code.fsm.d.ts +229 -94
  17. package/reference/sdlc/code.playbook/code.fsm.introspect.d.ts +26 -44
  18. package/reference/sdlc/code.playbook/code.fsm.introspect.js +61 -66
  19. package/reference/sdlc/code.playbook/code.fsm.introspect.ts +100 -149
  20. package/reference/sdlc/code.playbook/code.fsm.js +587 -1347
  21. package/reference/sdlc/code.playbook/code.fsm.ts +809 -1650
  22. package/reference/sdlc/code.playbook/code.gears.md +51 -263
  23. package/reference/sdlc/code.playbook/code.playbook.d.ts +8 -47
  24. package/reference/sdlc/code.playbook/code.playbook.js +69 -639
  25. package/reference/sdlc/code.playbook/code.playbook.ts +90 -850
  26. package/reference/sdlc/code.playbook/code.registry.d.ts +9 -25
  27. package/reference/sdlc/code.playbook/code.registry.js +20 -78
  28. package/reference/sdlc/code.playbook/code.registry.ts +58 -122
  29. package/reference/sdlc/code.playbook/playbook-captain.d.ts +2 -0
  30. package/reference/sdlc/code.playbook/playbook-captain.js +1877 -251
  31. package/reference/sdlc/code.playbook/playbook-captain.ts +2385 -352
  32. package/reference/sdlc/code.playbook/playbook.config.template.yaml +33 -22
  33. package/reference/sdlc/decide.md +54 -0
  34. package/reference/sdlc/decide.playbook/decide.fsm.d.ts +261 -0
  35. package/reference/sdlc/decide.playbook/decide.fsm.js +894 -0
  36. package/reference/sdlc/decide.playbook/decide.fsm.ts +1152 -0
  37. package/reference/sdlc/decide.playbook/decide.gears.md +88 -0
  38. package/reference/sdlc/decide.playbook/decide.playbook.d.ts +67 -0
  39. package/reference/sdlc/{discuss.playbook/discuss.playbook.js → decide.playbook/decide.playbook.js} +511 -370
  40. package/reference/sdlc/{discuss.playbook/discuss.playbook.ts → decide.playbook/decide.playbook.ts} +616 -451
  41. package/reference/sdlc/decide.playbook/decide.registry.d.ts +41 -0
  42. package/reference/sdlc/decide.playbook/decide.registry.js +60 -0
  43. package/reference/sdlc/decide.playbook/decide.registry.ts +125 -0
  44. package/reference/sdlc/review.md +81 -0
  45. package/reference/sdlc/review.playbook/review.fsm.d.ts +183 -0
  46. package/reference/sdlc/review.playbook/review.fsm.js +524 -0
  47. package/reference/sdlc/review.playbook/review.fsm.ts +652 -0
  48. package/reference/sdlc/review.playbook/review.gears.md +112 -0
  49. package/reference/sdlc/review.playbook/review.playbook.d.ts +12 -0
  50. package/reference/sdlc/review.playbook/review.playbook.js +112 -0
  51. package/reference/sdlc/review.playbook/review.playbook.ts +201 -0
  52. package/reference/sdlc/review.playbook/review.registry.d.ts +43 -0
  53. package/reference/sdlc/review.playbook/review.registry.js +73 -0
  54. package/reference/sdlc/review.playbook/review.registry.ts +138 -0
  55. package/slc/gears2fsm.md +67 -6
  56. package/slc/link.md +339 -25
  57. package/slc/text2gears.md +22 -2
  58. package/src/runtime.d.ts +36 -1
  59. package/src/runtime.ts +59 -0
  60. package/src/xstate-playbook-runtime.d.ts +96 -7
  61. package/src/xstate-playbook-runtime.js +1018 -49
  62. package/src/xstate-playbook-runtime.ts +1283 -59
  63. package/src/xstate-runtime.js +25 -0
  64. package/src/xstate-runtime.ts +51 -0
  65. package/reference/sdlc/discuss.md +0 -93
  66. package/reference/sdlc/discuss.playbook/discuss.fsm.d.ts +0 -396
  67. package/reference/sdlc/discuss.playbook/discuss.fsm.js +0 -2067
  68. package/reference/sdlc/discuss.playbook/discuss.fsm.ts +0 -2465
  69. package/reference/sdlc/discuss.playbook/discuss.gears.md +0 -258
  70. package/reference/sdlc/discuss.playbook/discuss.playbook.d.ts +0 -113
  71. package/reference/sdlc/discuss.playbook/discuss.registry.d.ts +0 -58
  72. package/reference/sdlc/discuss.playbook/discuss.registry.js +0 -97
  73. package/reference/sdlc/discuss.playbook/discuss.registry.ts +0 -153
@@ -0,0 +1,88 @@
1
+ <!-- SPDX-License-Identifier: Apache-2.0 -->
2
+ <!-- SPDX-FileCopyrightText: 2026 SubLang International <https://sublang.ai> -->
3
+
4
+ # Decide
5
+
6
+ ## Players
7
+
8
+ - Boss: the human user (default)
9
+ - Captain: the coordinating agent (default)
10
+ - Coder
11
+ - Reviewer
12
+
13
+ ## Independent proposals
14
+
15
+ The caller supplies a topic as `callerTopic`.
16
+ Coder and Reviewer receive the complete topic concurrently and independently.
17
+ Neither player receives the other player's proposal before both proposals finish and Coder commits Coder's own proposal.
18
+ A Boss interrupt during the parallel proposal pair restarts the complete pair with the new `callerTopic`.
19
+
20
+ ### DECIDE-1
21
+
22
+ Parallel group: independent-proposals
23
+
24
+ When the caller gives a topic, Captain shall relay the complete topic to Coder in quotes and prompt Coder:
25
+
26
+ > > <caller-topic>
27
+ >
28
+ > Assess whether the topic is better expressed as a few spec items under @specs/packages/ or requires one or more DRs under @specs/decisions/.
29
+ > Propose your design.
30
+ > Keep your proposal coherent, focused, and concise.
31
+ > Consult @specs/map.md for relevant context and @specs/meta.md for spec requirements, if needed.
32
+ > Do not change any files.
33
+
34
+ Results:
35
+ - `proposed`: Coder completed an independent proposal. Output shall include `coderProposal: <verbatim final text>`.
36
+
37
+ ### DECIDE-2
38
+
39
+ Parallel group: independent-proposals
40
+
41
+ When the caller gives a topic, Captain shall relay the complete topic to Reviewer in quotes and prompt Reviewer:
42
+
43
+ > > <caller-topic>
44
+ >
45
+ > Assess whether the topic is better expressed as a few spec items under @specs/packages/ or requires one or more DRs under @specs/decisions/.
46
+ > Propose your design.
47
+ > Keep your proposal coherent, focused, and concise.
48
+ > Consult @specs/map.md for relevant context and @specs/meta.md for spec requirements, if needed.
49
+ > Do not change any files.
50
+
51
+ Results:
52
+ - `proposed`: Reviewer completed an independent proposal. Output shall include `reviewerProposal: <verbatim final text>`.
53
+
54
+ ## Commit Coder's proposal
55
+
56
+ ### DECIDE-3
57
+
58
+ When both independent proposals are complete, Captain shall prompt Coder:
59
+
60
+ > Turn your proposal into the necessary spec items or DRs.
61
+ > Follow @specs/meta.md and update @specs/map.md when needed.
62
+ > Do not inspect or incorporate Reviewer's proposal before this commit.
63
+ > Do not change code or implement the proposal.
64
+ >
65
+ > Commit the result as one new commit, following @specs/packages/git.md.
66
+ > Make the commit message explain concisely what changed and why.
67
+ > Report it as exactly one final-response line beginning `Commit: `, followed only by the exact commit identity.
68
+ > Coder is <coder-llm>; format the model token in conventional human form.
69
+
70
+ Results:
71
+ - `committed`: Coder committed Coder's proposal. Output shall include `coderOutput: <verbatim final text>` and `latestCommit: <commit identity>`.
72
+
73
+ ## Review
74
+
75
+ ### DECIDE-4
76
+
77
+ When Coder commits, Captain shall call playbook `review`:
78
+
79
+ > Review the latest commit as a spec-design change against the initial intent.
80
+ > Compare it with your independent proposal and take the best of both.
81
+ > Make your suggestions.
82
+ >
83
+ > Initial intent: <caller-topic>.
84
+ > Coder's independent proposal: <coder-proposal>.
85
+
86
+ The successful child output is DECIDE's terminal output.
87
+ An authored child abort, failure, or invalid approval terminates with the failure and `latestCommit` reported to the caller.
88
+ Any other nested-call error parks `decide` as failed and retains the control-plane error.
@@ -0,0 +1,67 @@
1
+ import { type PlayerInput, type PlayerOutput, type DecideEvent, type DecideInput, type PendingBossQuestion } from './decide.fsm.js';
2
+ import type { CaptainCallOptions, CaptainResult, JsonValue, NormalizedError, PlayerCallOptions, PlayerResult, PlayerSessionStore, PlaybookCallRequest, PlaybookCallResult, PlaybookCallStart, PlaybookControlAction, PlaybookControlReceipt, PlaybookControlView, PlaybookPendingCall, PlaybookPorts, PlaybookRunResult, PlaybookRuntime, PlaybookRuntimeFactory, PlaybookRuntimeSnapshot, PlaybookSession, PlaybookState, PlaybookStateValue, PlaybookTraceEvent, PlaybookTraceType } from '@sublang/playbook/runtime';
3
+ export type { CaptainCallOptions, CaptainResult, JsonValue, NormalizedError, PlayerCallOptions, PlayerResult, PlayerSessionStore, PlaybookCallRequest, PlaybookCallResult, PlaybookCallStart, PlaybookControlAction, PlaybookControlReceipt, PlaybookControlView, PlaybookPendingCall, PlaybookPorts, PlaybookRunResult, PlaybookRuntime, PlaybookRuntimeFactory, PlaybookRuntimeSnapshot, PlaybookSession, PlaybookState, PlaybookStateValue, PlaybookTraceEvent, PlaybookTraceType, };
4
+ type PlayerName = 'Coder' | 'Reviewer';
5
+ export interface PlaybookRuntimeOptions extends DecideInput {
6
+ playerBinding?: Partial<Record<PlayerName, string>>;
7
+ }
8
+ declare function composePlayerPrompt(input: PlayerInput): string;
9
+ declare function resolvePlayerId(input: PlayerInput, binding: Record<PlayerName, string>): string;
10
+ declare function requiredFieldsFor(description: string): string[];
11
+ declare function extractJson(raw: string): Record<string, unknown> | null;
12
+ declare function buildClassifierPrompt(text: string, ctx: {
13
+ state: PlaybookState;
14
+ pendingQuestions: readonly PendingBossQuestion[];
15
+ }): string;
16
+ declare function parseClassification(raw: string, text: string, pendingQuestionIds?: readonly string[]): DecideEvent | {
17
+ type: 'NO_ACTION';
18
+ } | null;
19
+ declare function buildAdjudicatorPrompt(input: PlayerInput, playerOutput: string): string;
20
+ declare function parseAdjudication(raw: string, input: PlayerInput, finalText: string): PlayerOutput;
21
+ declare function combineSignals(a: AbortSignal | undefined, b: AbortSignal | undefined): AbortSignal;
22
+ declare function normalizeErrorCompact(err: unknown): {
23
+ name: string;
24
+ message: string;
25
+ } | undefined;
26
+ declare function normalizeErrorFull(err: unknown): {
27
+ name: string;
28
+ message: string;
29
+ stack?: string;
30
+ } | undefined;
31
+ declare function pendingQuestionsFromContext(context: Record<string, unknown>): PendingBossQuestion[];
32
+ export declare const createPlaybookRuntime: PlaybookRuntimeFactory<PlaybookRuntimeOptions>;
33
+ export declare const _internal: {
34
+ composePlayerPrompt: typeof composePlayerPrompt;
35
+ resolvePlayerId: typeof resolvePlayerId;
36
+ requiredFieldsFor: typeof requiredFieldsFor;
37
+ extractJson: typeof extractJson;
38
+ buildClassifierPrompt: typeof buildClassifierPrompt;
39
+ parseClassification: typeof parseClassification;
40
+ buildAdjudicatorPrompt: typeof buildAdjudicatorPrompt;
41
+ parseAdjudication: typeof parseAdjudication;
42
+ combineSignals: typeof combineSignals;
43
+ pendingQuestionsFromContext: typeof pendingQuestionsFromContext;
44
+ normalizeErrorCompact: typeof normalizeErrorCompact;
45
+ normalizeErrorFull: typeof normalizeErrorFull;
46
+ DEFAULT_PLAYER_BINDING: Readonly<Record<PlayerName, string>>;
47
+ STATE_DESCRIPTIONS: Readonly<Record<string, string>>;
48
+ PLAYER_STATES: readonly [{
49
+ readonly stateId: "askCoderProposal";
50
+ readonly player: "Coder";
51
+ readonly sourceItem: "DECIDE-1";
52
+ }, {
53
+ readonly stateId: "askReviewerProposal";
54
+ readonly player: "Reviewer";
55
+ readonly sourceItem: "DECIDE-2";
56
+ }, {
57
+ readonly stateId: "commitCoderProposal";
58
+ readonly player: "Coder";
59
+ readonly sourceItem: "DECIDE-3";
60
+ }];
61
+ PLAYER_STATE_IDS: ReadonlySet<string>;
62
+ VERBATIM_PAYLOAD_FIELDS: ReadonlySet<string>;
63
+ BOSS_INTERRUPT_TARGETS: readonly ["independentProposals"];
64
+ CONTINUATION_PREAMBLE: string;
65
+ TELEMETRY_TOPIC: string;
66
+ };
67
+ export default createPlaybookRuntime;