@sublang/playbook 0.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.
- package/LICENSE +201 -0
- package/README.md +181 -0
- package/bin/playbook-code.js +40 -0
- package/code.fsm.d.ts +86 -0
- package/code.fsm.introspect.d.ts +30 -0
- package/code.fsm.introspect.js +50 -0
- package/code.fsm.introspect.ts +129 -0
- package/code.fsm.js +1022 -0
- package/code.fsm.ts +1224 -0
- package/code.gears.md +250 -0
- package/code.playbook.d.ts +53 -0
- package/code.playbook.js +598 -0
- package/code.playbook.ts +743 -0
- package/code.tmux-play.d.ts +2 -0
- package/code.tmux-play.js +77 -0
- package/code.tmux-play.ts +110 -0
- package/package.json +77 -0
- package/tmux-play.config.yaml +33 -0
- package/tmux-play.production.config.yaml +21 -0
package/code.gears.md
ADDED
|
@@ -0,0 +1,250 @@
|
|
|
1
|
+
<!-- SPDX-License-Identifier: Apache-2.0 -->
|
|
2
|
+
<!-- SPDX-FileCopyrightText: 2026 SubLang International <https://sublang.ai> -->
|
|
3
|
+
|
|
4
|
+
# CODE: Coding Workflow
|
|
5
|
+
|
|
6
|
+
Players:
|
|
7
|
+
|
|
8
|
+
- Coder
|
|
9
|
+
- Reviewer
|
|
10
|
+
- Committer = Coder | Reviewer
|
|
11
|
+
|
|
12
|
+
## Coder
|
|
13
|
+
|
|
14
|
+
### CODE-1
|
|
15
|
+
|
|
16
|
+
When Boss gives a coding intent, Captain shall relay it to Coder along with the following prompt:
|
|
17
|
+
> Assess whether this can be completed in a single commit, following best practices.
|
|
18
|
+
> If yes, implement and test, updating both code and specs; otherwise, decompose into tasks as a new IR under @specs/iterations.
|
|
19
|
+
> Consult @specs/map.md for relevant context if needed; ensure it reflects the changes.
|
|
20
|
+
> Do not commit.
|
|
21
|
+
|
|
22
|
+
The resulting changes are Initial Changes.
|
|
23
|
+
|
|
24
|
+
### CODE-2
|
|
25
|
+
|
|
26
|
+
When Reviewer raises any findings, Captain shall relay them to Coder along with the following prompt:
|
|
27
|
+
> For each review item below for the above changes, challenge or accept it, with strong reasoning, solid evidence, and comprehensive thinking.
|
|
28
|
+
> Stage all current changes that belong in the repo before making any edits, and leave your edits unstaged/untracked.
|
|
29
|
+
|
|
30
|
+
### CODE-3
|
|
31
|
+
|
|
32
|
+
When a new IR or IR task passes review and is committed, Captain shall prompt Coder:
|
|
33
|
+
> Continue to implement IR-<#> if not all deliverables and tasks are done.
|
|
34
|
+
> Implement one task at a time (including corresponding tests if any).
|
|
35
|
+
> Stop after each task for review — do not commit yet.
|
|
36
|
+
> If relevant, mark progress in the IR.
|
|
37
|
+
|
|
38
|
+
The resulting changes are Initial Changes.
|
|
39
|
+
|
|
40
|
+
### CODE-4
|
|
41
|
+
|
|
42
|
+
When an IR is done, Captain shall prompt Coder:
|
|
43
|
+
> Read IR-<#> and corresponding commits.
|
|
44
|
+
> According to @specs/meta.md, add or update spec items to fully capture:
|
|
45
|
+
>
|
|
46
|
+
> - the user requirements in @specs/user,
|
|
47
|
+
> - the system behavior in @specs/dev, and
|
|
48
|
+
> - the integration/system test cases in @specs/test.
|
|
49
|
+
>
|
|
50
|
+
> The spec items should be the *minimal* set needed to reimplement code without the IR.
|
|
51
|
+
> The set should be complete and coherent.
|
|
52
|
+
> Avoid implementation specifics.
|
|
53
|
+
> Avoid redundant spec items.
|
|
54
|
+
> Consult @specs/map.md for relevant context and update it to reflect your changes.
|
|
55
|
+
|
|
56
|
+
## Reviewer
|
|
57
|
+
|
|
58
|
+
For each finding in a review round, Coder either addresses it with changes or challenges it with a rebuttal.
|
|
59
|
+
Any code change to address findings starts a new round of review, no matter if some findings are also rebutted.
|
|
60
|
+
Rounds continue until Reviewer raises no findings.
|
|
61
|
+
|
|
62
|
+
### CODE-5
|
|
63
|
+
|
|
64
|
+
When Committer commits Initial Changes from a Boss coding intent involving changes only in @specs/user/, @specs/dev/, or @specs/test/, Captain shall relay the Boss's coding intent to Reviewer along with the following prompt:
|
|
65
|
+
> Review the latest commit.
|
|
66
|
+
> Refer to the commit message.
|
|
67
|
+
> Verify any affected spec items are:
|
|
68
|
+
>
|
|
69
|
+
> - Complete & coherent: sufficient for you to reimplement code.
|
|
70
|
+
> - Right level: user requirements (in @specs/user) or behavior (in @specs/dev), not implementation specifics; integration/system testing (in @specs/test), not unit testing.
|
|
71
|
+
> - Minimal: essential and concise; every item earns its place; also check with other items.
|
|
72
|
+
>
|
|
73
|
+
> Flag anything missing, redundant, over-specified, or under-specified.
|
|
74
|
+
> Consult @specs/map.md for relevant context if needed; verify it reflects the changes.
|
|
75
|
+
> If the change is ready to commit or push, don't raise nitpicks.
|
|
76
|
+
|
|
77
|
+
### CODE-6
|
|
78
|
+
|
|
79
|
+
When Committer commits Initial Changes from a Boss coding intent involving changes only outside @specs/user/, @specs/dev/, and @specs/test/, Captain shall relay the Boss's coding intent to Reviewer along with the following prompt:
|
|
80
|
+
> Review the latest commit.
|
|
81
|
+
> Refer to the commit message.
|
|
82
|
+
> Flag any issues or improvements (numbered; no duplication).
|
|
83
|
+
> Think thoroughly — don't just approve or reject.
|
|
84
|
+
> Consult @specs/map.md for relevant context if needed; verify it reflects the changes.
|
|
85
|
+
> If the change is ready to commit or push, don't raise nitpicks.
|
|
86
|
+
|
|
87
|
+
### CODE-7
|
|
88
|
+
|
|
89
|
+
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:
|
|
90
|
+
> Review the latest commit.
|
|
91
|
+
> Refer to the commit message.
|
|
92
|
+
> Verify any affected spec items are:
|
|
93
|
+
>
|
|
94
|
+
> - Complete & coherent: sufficient for you to reimplement code.
|
|
95
|
+
> - Right level: user requirements (in @specs/user) or behavior (in @specs/dev), not implementation specifics; integration/system testing (in @specs/test), not unit testing.
|
|
96
|
+
> - Minimal: essential and concise; every item earns its place; also check with other items.
|
|
97
|
+
>
|
|
98
|
+
> Flag anything missing, redundant, over-specified, or under-specified.
|
|
99
|
+
> Flag any issues or improvements (numbered; no duplication).
|
|
100
|
+
> Think thoroughly — don't just approve or reject.
|
|
101
|
+
> Consult @specs/map.md for relevant context if needed; verify it reflects the changes.
|
|
102
|
+
> If the change is ready to commit or push, don't raise nitpicks.
|
|
103
|
+
|
|
104
|
+
### CODE-8
|
|
105
|
+
|
|
106
|
+
When Committer commits Initial Changes from an IR task involving changes only in @specs/user/, @specs/dev/, or @specs/test/, Captain shall relay the IR's task description to Reviewer along with the following prompt:
|
|
107
|
+
> Review the latest commit.
|
|
108
|
+
> Refer to the commit message.
|
|
109
|
+
> Verify any affected spec items are:
|
|
110
|
+
>
|
|
111
|
+
> - Complete & coherent: sufficient for you to reimplement code.
|
|
112
|
+
> - Right level: user requirements (in @specs/user) or behavior (in @specs/dev), not implementation specifics; integration/system testing (in @specs/test), not unit testing.
|
|
113
|
+
> - Minimal: essential and concise; every item earns its place; also check with other items.
|
|
114
|
+
>
|
|
115
|
+
> Flag anything missing, redundant, over-specified, or under-specified.
|
|
116
|
+
> Consult @specs/map.md for relevant context if needed; verify it reflects the changes.
|
|
117
|
+
> If the change is ready to commit or push, don't raise nitpicks.
|
|
118
|
+
|
|
119
|
+
### CODE-9
|
|
120
|
+
|
|
121
|
+
When Committer commits Initial Changes from an IR task involving changes only outside @specs/user/, @specs/dev/, and @specs/test/, Captain shall relay the IR's task description to Reviewer along with the following prompt:
|
|
122
|
+
> Review the latest commit.
|
|
123
|
+
> Refer to the commit message.
|
|
124
|
+
> Flag any issues or improvements (numbered; no duplication).
|
|
125
|
+
> Think thoroughly — don't just approve or reject.
|
|
126
|
+
> Consult @specs/map.md for relevant context if needed; verify it reflects the changes.
|
|
127
|
+
> If the change is ready to commit or push, don't raise nitpicks.
|
|
128
|
+
|
|
129
|
+
### CODE-10
|
|
130
|
+
|
|
131
|
+
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:
|
|
132
|
+
> Review the latest commit.
|
|
133
|
+
> Refer to the commit message.
|
|
134
|
+
> Verify any affected spec items are:
|
|
135
|
+
>
|
|
136
|
+
> - Complete & coherent: sufficient for you to reimplement code.
|
|
137
|
+
> - Right level: user requirements (in @specs/user) or behavior (in @specs/dev), not implementation specifics; integration/system testing (in @specs/test), not unit testing.
|
|
138
|
+
> - Minimal: essential and concise; every item earns its place; also check with other items.
|
|
139
|
+
>
|
|
140
|
+
> Flag anything missing, redundant, over-specified, or under-specified.
|
|
141
|
+
> Flag any issues or improvements (numbered; no duplication).
|
|
142
|
+
> Think thoroughly — don't just approve or reject.
|
|
143
|
+
> Consult @specs/map.md for relevant context if needed; verify it reflects the changes.
|
|
144
|
+
> If the change is ready to commit or push, don't raise nitpicks.
|
|
145
|
+
|
|
146
|
+
### CODE-11
|
|
147
|
+
|
|
148
|
+
When Coder makes unreviewed changes (outside of any Initial Changes) involving changes only in @specs/user/, @specs/dev/, or @specs/test/ without raising rebuttals, Captain shall prompt Reviewer to begin a review round:
|
|
149
|
+
> Review the unstaged/untracked changes.
|
|
150
|
+
> Understand the intent.
|
|
151
|
+
> Verify any affected spec items are:
|
|
152
|
+
>
|
|
153
|
+
> - Complete & coherent: sufficient for you to reimplement code.
|
|
154
|
+
> - Right level: user requirements (in @specs/user) or behavior (in @specs/dev), not implementation specifics; integration/system testing (in @specs/test), not unit testing.
|
|
155
|
+
> - Minimal: essential and concise; every item earns its place; also check with other items.
|
|
156
|
+
>
|
|
157
|
+
> Flag anything missing, redundant, over-specified, or under-specified.
|
|
158
|
+
> Consult @specs/map.md for relevant context if needed; verify it reflects the changes.
|
|
159
|
+
> If the change is ready to commit or push, don't raise nitpicks.
|
|
160
|
+
|
|
161
|
+
### CODE-12
|
|
162
|
+
|
|
163
|
+
When Coder makes unreviewed changes (outside of any Initial Changes) involving changes only outside @specs/user/, @specs/dev/, and @specs/test/ without raising rebuttals, Captain shall prompt Reviewer to begin a review round:
|
|
164
|
+
> Review the unstaged/untracked changes.
|
|
165
|
+
> Understand the intent.
|
|
166
|
+
> Flag any issues or improvements (numbered; no duplication).
|
|
167
|
+
> Think thoroughly — don't just approve or reject.
|
|
168
|
+
> Consult @specs/map.md for relevant context if needed; verify it reflects the changes.
|
|
169
|
+
> If the change is ready to commit or push, don't raise nitpicks.
|
|
170
|
+
|
|
171
|
+
### CODE-13
|
|
172
|
+
|
|
173
|
+
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:
|
|
174
|
+
> Review the unstaged/untracked changes.
|
|
175
|
+
> Understand the intent.
|
|
176
|
+
> Verify any affected spec items are:
|
|
177
|
+
>
|
|
178
|
+
> - Complete & coherent: sufficient for you to reimplement code.
|
|
179
|
+
> - Right level: user requirements (in @specs/user) or behavior (in @specs/dev), not implementation specifics; integration/system testing (in @specs/test), not unit testing.
|
|
180
|
+
> - Minimal: essential and concise; every item earns its place; also check with other items.
|
|
181
|
+
>
|
|
182
|
+
> Flag anything missing, redundant, over-specified, or under-specified.
|
|
183
|
+
> Flag any issues or improvements (numbered; no duplication).
|
|
184
|
+
> Think thoroughly — don't just approve or reject.
|
|
185
|
+
> Consult @specs/map.md for relevant context if needed; verify it reflects the changes.
|
|
186
|
+
> If the change is ready to commit or push, don't raise nitpicks.
|
|
187
|
+
|
|
188
|
+
### CODE-14
|
|
189
|
+
|
|
190
|
+
When Coder raises rebuttals without making code changes, Captain shall relay them to Reviewer along with the following prompt:
|
|
191
|
+
> For each rebuttal below, challenge or accept it, with strong reasoning, solid evidence, and comprehensive thinking.
|
|
192
|
+
|
|
193
|
+
### CODE-15
|
|
194
|
+
|
|
195
|
+
When Coder makes unreviewed changes (outside of any Initial Changes) involving changes only in @specs/user/, @specs/dev/, or @specs/test/ and also raises rebuttals, Captain shall prompt Reviewer to begin a review round and relay the rebuttals along with the following prompt:
|
|
196
|
+
> Review the unstaged/untracked changes.
|
|
197
|
+
> Understand the intent.
|
|
198
|
+
> Verify any affected spec items are:
|
|
199
|
+
>
|
|
200
|
+
> - Complete & coherent: sufficient for you to reimplement code.
|
|
201
|
+
> - Right level: user requirements (in @specs/user) or behavior (in @specs/dev), not implementation specifics; integration/system testing (in @specs/test), not unit testing.
|
|
202
|
+
> - Minimal: essential and concise; every item earns its place; also check with other items.
|
|
203
|
+
>
|
|
204
|
+
> Flag anything missing, redundant, over-specified, or under-specified.
|
|
205
|
+
> Consult @specs/map.md for relevant context if needed; verify it reflects the changes.
|
|
206
|
+
> If the change is ready to commit or push, don't raise nitpicks.
|
|
207
|
+
> For each rebuttal below, challenge or accept it, with strong reasoning, solid evidence, and comprehensive thinking.
|
|
208
|
+
|
|
209
|
+
### CODE-16
|
|
210
|
+
|
|
211
|
+
When Coder makes unreviewed changes (outside of any Initial Changes) involving changes only 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:
|
|
212
|
+
> Review the unstaged/untracked changes.
|
|
213
|
+
> Understand the intent.
|
|
214
|
+
> Flag any issues or improvements (numbered; no duplication).
|
|
215
|
+
> Think thoroughly — don't just approve or reject.
|
|
216
|
+
> Consult @specs/map.md for relevant context if needed; verify it reflects the changes.
|
|
217
|
+
> If the change is ready to commit or push, don't raise nitpicks.
|
|
218
|
+
> For each rebuttal below, challenge or accept it, with strong reasoning, solid evidence, and comprehensive thinking.
|
|
219
|
+
|
|
220
|
+
### CODE-17
|
|
221
|
+
|
|
222
|
+
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:
|
|
223
|
+
> Review the unstaged/untracked changes.
|
|
224
|
+
> Understand the intent.
|
|
225
|
+
> Verify any affected spec items are:
|
|
226
|
+
>
|
|
227
|
+
> - Complete & coherent: sufficient for you to reimplement code.
|
|
228
|
+
> - Right level: user requirements (in @specs/user) or behavior (in @specs/dev), not implementation specifics; integration/system testing (in @specs/test), not unit testing.
|
|
229
|
+
> - Minimal: essential and concise; every item earns its place; also check with other items.
|
|
230
|
+
>
|
|
231
|
+
> Flag anything missing, redundant, over-specified, or under-specified.
|
|
232
|
+
> Flag any issues or improvements (numbered; no duplication).
|
|
233
|
+
> Think thoroughly — don't just approve or reject.
|
|
234
|
+
> Consult @specs/map.md for relevant context if needed; verify it reflects the changes.
|
|
235
|
+
> If the change is ready to commit or push, don't raise nitpicks.
|
|
236
|
+
> For each rebuttal below, challenge or accept it, with strong reasoning, solid evidence, and comprehensive thinking.
|
|
237
|
+
|
|
238
|
+
## Committer
|
|
239
|
+
|
|
240
|
+
### CODE-18
|
|
241
|
+
|
|
242
|
+
When Coder makes any Initial Changes and Reviewer has not played since the last commit, Captain shall prompt Committer:
|
|
243
|
+
> Make a commit of the changes that belong in the repo, following @specs/dev/git.md (reread if necessary).
|
|
244
|
+
> Coder is <coder-llm>.
|
|
245
|
+
|
|
246
|
+
### CODE-19
|
|
247
|
+
|
|
248
|
+
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:
|
|
249
|
+
> Make a commit of the changes that belong in the repo, following @specs/dev/git.md (reread if necessary).
|
|
250
|
+
> Coder is <coder-llm>; Reviewer is <reviewer-llm>.
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { type CaptainInput, type CaptainOutput, type CodingEvent, type CodingInput } from './code.fsm.js';
|
|
2
|
+
export interface PlayerResult {
|
|
3
|
+
status: 'ok' | 'aborted' | 'error';
|
|
4
|
+
finalText?: string;
|
|
5
|
+
error?: string;
|
|
6
|
+
}
|
|
7
|
+
export interface PlaybookPorts {
|
|
8
|
+
callPlayer(playerId: string, prompt: string, signal: AbortSignal): Promise<PlayerResult>;
|
|
9
|
+
callJudge(prompt: string, signal: AbortSignal): Promise<string>;
|
|
10
|
+
emitStatus(message: string, data?: unknown): Promise<void>;
|
|
11
|
+
emitTelemetry(event: {
|
|
12
|
+
topic: string;
|
|
13
|
+
payload: unknown;
|
|
14
|
+
}): Promise<void>;
|
|
15
|
+
}
|
|
16
|
+
export interface PlaybookRuntime {
|
|
17
|
+
init(ports: PlaybookPorts): Promise<void>;
|
|
18
|
+
handleBossInput(turn: {
|
|
19
|
+
text: string;
|
|
20
|
+
signal: AbortSignal;
|
|
21
|
+
}): Promise<void>;
|
|
22
|
+
dispose(): Promise<void>;
|
|
23
|
+
}
|
|
24
|
+
export type CodePlaybookOptions = CodingInput;
|
|
25
|
+
declare function composePlayerPrompt(input: CaptainInput): string;
|
|
26
|
+
declare function resolvePlayerId(input: CaptainInput): string;
|
|
27
|
+
declare function adjudicate(input: CaptainInput, finalText: string, ports: PlaybookPorts, signal: AbortSignal): Promise<CaptainOutput>;
|
|
28
|
+
declare function classifyBossText(text: string, ports: PlaybookPorts, signal: AbortSignal): Promise<CodingEvent | undefined>;
|
|
29
|
+
declare function captainBridge(ports: PlaybookPorts, getActiveSignal?: () => AbortSignal | undefined): import("xstate").PromiseActorLogic<CaptainOutput, CaptainInput, import("xstate").EventObject>;
|
|
30
|
+
interface StateMetadata {
|
|
31
|
+
player: CaptainInput['player'];
|
|
32
|
+
sourceItem: string;
|
|
33
|
+
label: string;
|
|
34
|
+
}
|
|
35
|
+
declare function formatStateEntry(stateId: string): string;
|
|
36
|
+
declare function formatTransition(event: unknown): string | undefined;
|
|
37
|
+
declare function formatBossEcho(text: string, eventType?: string): string;
|
|
38
|
+
declare function formatRiders(context: Record<string, unknown>): string;
|
|
39
|
+
export declare const _internal: {
|
|
40
|
+
composePlayerPrompt: typeof composePlayerPrompt;
|
|
41
|
+
resolvePlayerId: typeof resolvePlayerId;
|
|
42
|
+
adjudicate: typeof adjudicate;
|
|
43
|
+
classifyBossText: typeof classifyBossText;
|
|
44
|
+
captainBridge: typeof captainBridge;
|
|
45
|
+
STATE_LABELS: Readonly<Record<string, string>>;
|
|
46
|
+
stateMetadata: ReadonlyMap<string, StateMetadata>;
|
|
47
|
+
formatStateEntry: typeof formatStateEntry;
|
|
48
|
+
formatTransition: typeof formatTransition;
|
|
49
|
+
formatBossEcho: typeof formatBossEcho;
|
|
50
|
+
formatRiders: typeof formatRiders;
|
|
51
|
+
};
|
|
52
|
+
export default function createPlaybookRuntime(options: CodePlaybookOptions): PlaybookRuntime;
|
|
53
|
+
export {};
|