@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.
- package/README.md +2 -0
- package/docs/cli.md +36 -18
- package/docs/configuration.md +7 -5
- package/docs/embedding.md +28 -7
- package/package.json +4 -4
- package/reference/sdlc/branch.playbook/branch.fsm.d.ts +63 -33
- package/reference/sdlc/branch.playbook/branch.fsm.js +190 -108
- package/reference/sdlc/branch.playbook/branch.fsm.ts +269 -147
- package/reference/sdlc/branch.playbook/branch.gears.md +7 -17
- package/reference/sdlc/branch.playbook/branch.playbook.d.ts +12 -16
- package/reference/sdlc/branch.playbook/branch.playbook.js +112 -101
- package/reference/sdlc/branch.playbook/branch.playbook.ts +128 -171
- package/reference/sdlc/branch.playbook/branch.registry.d.ts +3 -2
- package/reference/sdlc/branch.playbook/branch.registry.ts +6 -2
- package/reference/sdlc/captain.md +19 -10
- package/reference/sdlc/captain.playbook/captain.fsm.d.ts +6 -2
- package/reference/sdlc/captain.playbook/captain.fsm.js +19 -7
- package/reference/sdlc/captain.playbook/captain.fsm.ts +25 -10
- package/reference/sdlc/captain.playbook/captain.gears.md +16 -8
- package/reference/sdlc/captain.playbook/captain.playbook.d.ts +1 -1
- package/reference/sdlc/captain.playbook/captain.playbook.js +3 -2
- package/reference/sdlc/captain.playbook/captain.playbook.ts +4 -3
- package/reference/sdlc/code.playbook/bin/interactive-session.js +14 -1
- package/reference/sdlc/code.playbook/bin/portable-codec.js +3 -0
- package/reference/sdlc/code.playbook/bin/repository-effects.js +1 -0
- package/reference/sdlc/code.playbook/bin/run.js +128 -85
- package/reference/sdlc/code.playbook/bin/session-host.js +40 -8
- package/reference/sdlc/code.playbook/bin/session-store.js +162 -34
- package/reference/sdlc/code.playbook/code.fsm.d.ts +146 -93
- package/reference/sdlc/code.playbook/code.fsm.introspect.d.ts +8 -8
- package/reference/sdlc/code.playbook/code.fsm.introspect.ts +13 -13
- package/reference/sdlc/code.playbook/code.fsm.js +609 -649
- package/reference/sdlc/code.playbook/code.fsm.ts +890 -821
- package/reference/sdlc/code.playbook/code.gears.md +39 -29
- package/reference/sdlc/code.playbook/code.playbook.d.ts +13 -16
- package/reference/sdlc/code.playbook/code.playbook.js +166 -147
- package/reference/sdlc/code.playbook/code.playbook.ts +180 -229
- package/reference/sdlc/code.playbook/code.registry.d.ts +3 -2
- package/reference/sdlc/code.playbook/code.registry.ts +6 -2
- package/reference/sdlc/code.playbook/host-capabilities.d.ts +3 -0
- package/reference/sdlc/code.playbook/playbook-captain.d.ts +74 -2
- package/reference/sdlc/code.playbook/playbook-captain.js +1548 -468
- package/reference/sdlc/code.playbook/playbook-captain.ts +1993 -573
- package/reference/sdlc/code.playbook/session-host.d.ts +4 -1
- package/reference/sdlc/code.playbook/session-store.d.ts +17 -0
- package/reference/sdlc/code.playbook/session-store.js +1 -0
- package/reference/sdlc/decide.md +1 -0
- package/reference/sdlc/decide.playbook/decide.fsm.d.ts +273 -157
- package/reference/sdlc/decide.playbook/decide.fsm.js +765 -732
- package/reference/sdlc/decide.playbook/decide.fsm.ts +1167 -945
- package/reference/sdlc/decide.playbook/decide.gears.md +28 -21
- package/reference/sdlc/decide.playbook/decide.playbook.d.ts +11 -59
- package/reference/sdlc/decide.playbook/decide.playbook.js +155 -3696
- package/reference/sdlc/decide.playbook/decide.playbook.ts +186 -5244
- package/reference/sdlc/decide.playbook/decide.registry.d.ts +8 -4
- package/reference/sdlc/decide.playbook/decide.registry.js +2 -2
- package/reference/sdlc/decide.playbook/decide.registry.ts +13 -6
- package/reference/sdlc/dev.playbook/dev.fsm.d.ts +116 -134
- package/reference/sdlc/dev.playbook/dev.fsm.js +517 -575
- package/reference/sdlc/dev.playbook/dev.fsm.ts +667 -787
- package/reference/sdlc/dev.playbook/dev.gears.md +52 -54
- package/reference/sdlc/dev.playbook/dev.playbook.d.ts +13 -10
- package/reference/sdlc/dev.playbook/dev.playbook.js +128 -120
- package/reference/sdlc/dev.playbook/dev.playbook.ts +143 -193
- package/reference/sdlc/dev.playbook/dev.registry.d.ts +3 -2
- package/reference/sdlc/dev.playbook/dev.registry.ts +6 -2
- package/reference/sdlc/pr.playbook/pr.fsm.d.ts +95 -88
- package/reference/sdlc/pr.playbook/pr.fsm.js +461 -518
- package/reference/sdlc/pr.playbook/pr.fsm.ts +533 -663
- package/reference/sdlc/pr.playbook/pr.gears.md +47 -63
- package/reference/sdlc/pr.playbook/pr.playbook.d.ts +13 -23
- package/reference/sdlc/pr.playbook/pr.playbook.js +118 -112
- package/reference/sdlc/pr.playbook/pr.playbook.ts +136 -190
- package/reference/sdlc/pr.playbook/pr.registry.d.ts +3 -2
- package/reference/sdlc/pr.playbook/pr.registry.ts +4 -2
- package/reference/sdlc/review.md +3 -3
- package/reference/sdlc/review.playbook/review.fsm.d.ts +150 -116
- package/reference/sdlc/review.playbook/review.fsm.js +479 -550
- package/reference/sdlc/review.playbook/review.fsm.ts +717 -662
- package/reference/sdlc/review.playbook/review.gears.md +32 -29
- package/reference/sdlc/review.playbook/review.playbook.d.ts +12 -12
- package/reference/sdlc/review.playbook/review.playbook.js +180 -155
- package/reference/sdlc/review.playbook/review.playbook.ts +190 -230
- package/reference/sdlc/review.playbook/review.registry.d.ts +6 -5
- package/reference/sdlc/review.playbook/review.registry.js +3 -3
- package/reference/sdlc/review.playbook/review.registry.ts +9 -5
- package/slc/gears2fsm.md +77 -8
- package/slc/link.md +127 -60
- package/slc/materialize-link.mjs +51 -13
- package/slc/optimize.md +4 -1
- package/slc/prefix-prompts.mjs +29 -28
- package/slc/prefix.md +27 -24
- package/slc/slc.pin-inputs.json +11 -2
- package/slc/text2gears.md +71 -11
- package/src/runtime.d.ts +46 -2
- package/src/runtime.ts +42 -2
- package/src/xstate-playbook-runtime.d.ts +63 -23
- package/src/xstate-playbook-runtime.js +1637 -475
- package/src/xstate-playbook-runtime.ts +2105 -532
- package/src/xstate-runtime.d.ts +3 -4
- package/src/xstate-runtime.js +52 -0
- package/src/xstate-runtime.ts +59 -4
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
<!-- SPDX-License-Identifier: Apache-2.0 -->
|
|
2
2
|
<!-- SPDX-FileCopyrightText: 2026 SubLang International <https://sublang.ai> -->
|
|
3
3
|
|
|
4
|
-
#
|
|
4
|
+
# Code
|
|
5
5
|
|
|
6
6
|
Roles:
|
|
7
7
|
|
|
@@ -11,11 +11,12 @@ Roles:
|
|
|
11
11
|
|
|
12
12
|
### CODE-1
|
|
13
13
|
|
|
14
|
-
|
|
14
|
+
Each phase ends with exactly one new Coder commit owned by `code`, and no existing commit is rewritten.
|
|
15
|
+
Captain uses the repository-effect receipt as the authoritative identity of the phase's new commit.
|
|
16
|
+
When the request may continue an existing IR that it does not identify unambiguously, Coder asks Boss before changing files, and Boss's answer resumes this same phase.
|
|
17
|
+
|
|
18
|
+
When the first coding phase begins for the caller's coding request and any relevant context, Captain shall prompt Coder:
|
|
15
19
|
|
|
16
|
-
> > Original request: <caller-input>
|
|
17
|
-
> > Run results: <run-results>
|
|
18
|
-
>
|
|
19
20
|
> First determine whether the coding request starts a new coding intent or continues an existing IR with unfinished work.
|
|
20
21
|
> If the request may continue an existing IR but does not identify it unambiguously, ask Boss before changing files.
|
|
21
22
|
>
|
|
@@ -37,36 +38,39 @@ When the first coding phase begins, Captain shall prompt Coder:
|
|
|
37
38
|
> Make the commit message explain concisely what changed and why, including relevant verification.
|
|
38
39
|
> Identify every new commit you make.
|
|
39
40
|
> Credit every AI that contributed to this commit: Coder <coder-llm>.
|
|
41
|
+
>
|
|
42
|
+
> > Original request: <caller-input>
|
|
43
|
+
> > Run results: <run-results>
|
|
40
44
|
|
|
41
45
|
Results:
|
|
42
|
-
- `directCommit`: Coder completed
|
|
43
|
-
- `irCommit`: Coder
|
|
44
|
-
- `moreTasks`: Coder continued an existing IR,
|
|
45
|
-
- `finalTask`: Coder continued an existing IR
|
|
46
|
+
- `directCommit`: Coder completed the new coding intent as one direct implementation phase and made its one new commit; Coder's result affirmatively supports this outcome, and no fixed presentation format of the reply is required. Output shall include `coderOutput: <verbatim final text>` and `latestCommit: <commit identity>`.
|
|
47
|
+
- `irCommit`: Coder decomposed the new coding intent into a new IR, implemented no IR task, and made its one new commit; Coder's result affirmatively supports this outcome, and no fixed presentation format of the reply is required. Output shall include `coderOutput: <verbatim final text>`, `latestCommit: <commit identity>`, and `irNumber` identifying the created IR.
|
|
48
|
+
- `moreTasks`: Coder continued an existing IR, implemented exactly its next unfinished task, made its one new commit, and at least one IR task remains unfinished; Coder's result affirmatively supports this outcome, and no fixed presentation format of the reply is required. Output shall include `coderOutput: <verbatim final text>`, `latestCommit: <commit identity>`, `irNumber` identifying the continued IR, and `irTask` naming the implemented task.
|
|
49
|
+
- `finalTask`: Coder continued an existing IR, implemented its final unfinished task, and made its one new commit; Coder's result affirmatively supports this outcome, and no fixed presentation format of the reply is required. Output shall include `coderOutput: <verbatim final text>`, `latestCommit: <commit identity>`, `irNumber` identifying the continued IR, and `irTask` naming the implemented task.
|
|
46
50
|
|
|
47
51
|
### CODE-2
|
|
48
52
|
|
|
49
|
-
|
|
53
|
+
Captain waits until `review` passes with no unsettled findings; playbook `review` owns every review round and every review-fix commit, and no existing commit is rewritten.
|
|
54
|
+
|
|
55
|
+
When a direct implementation or new-IR phase ends with its one new `code`-owned commit, Captain shall call playbook `review`:
|
|
50
56
|
|
|
51
57
|
> > Original intent: <caller-input>
|
|
52
58
|
> > Review scope: the commit <code-commit> from this coding phase and its resulting repository state.
|
|
53
59
|
> > Coder output: <coder-output>
|
|
54
60
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
- Any other nested-call error parks `code` as failed and retains the control-plane error.
|
|
61
|
+
A nested `review` passes the phase only when its result applies to that supplied review scope, returns the exact evaluated repository revision, and affirmatively establishes that no unsettled findings remain.
|
|
62
|
+
When `review` passes a direct implementation phase, `code` is complete and returns to its caller the exact last `code`-owned commit, the exact final evaluated repository revision, and the fact that every phase's review passed with no unsettled findings.
|
|
63
|
+
When `review` passes a new-IR phase, Captain continues with the next unfinished IR-task phase.
|
|
64
|
+
When `review` returns an authored abort or failure, or a terminal result that does not establish that the supplied scope was evaluated with no unsettled findings, `code` starts no further phase and reports the failure and the last `code`-owned commit to its caller.
|
|
65
|
+
When the nested `review` call fails outside that authored result contract, `code` parks as failed and retains the control-plane error instead of reporting an authored review outcome.
|
|
61
66
|
|
|
62
67
|
### CODE-3
|
|
63
68
|
|
|
69
|
+
Each phase ends with exactly one new Coder commit owned by `code`, and no existing commit is rewritten.
|
|
70
|
+
Captain uses the repository-effect receipt as the authoritative identity of the phase's new commit.
|
|
71
|
+
|
|
64
72
|
When a later IR-task phase begins, Captain shall prompt Coder:
|
|
65
73
|
|
|
66
|
-
> > Original request: <caller-input>
|
|
67
|
-
> > IR number: <ir-number>
|
|
68
|
-
> > Run results: <run-results>
|
|
69
|
-
>
|
|
70
74
|
> Read the identified IR and implement exactly its next unfinished task, including corresponding tests or specs if any.
|
|
71
75
|
> Do not implement a later task in this phase.
|
|
72
76
|
> Mark the IR's progress and deliverables when relevant.
|
|
@@ -78,23 +82,29 @@ When a later IR-task phase begins, Captain shall prompt Coder:
|
|
|
78
82
|
> Make the commit message explain concisely what changed and why, including relevant verification.
|
|
79
83
|
> Identify every new commit you make.
|
|
80
84
|
> Credit every AI that contributed to this commit: Coder <coder-llm>.
|
|
85
|
+
>
|
|
86
|
+
> > Original request: <caller-input>
|
|
87
|
+
> > IR number: <ir-number>
|
|
88
|
+
> > Run results: <run-results>
|
|
81
89
|
|
|
82
90
|
Results:
|
|
83
|
-
- `moreTasks`: Coder
|
|
84
|
-
- `finalTask`: Coder
|
|
91
|
+
- `moreTasks`: Coder implemented exactly the IR's next unfinished task, made its one new commit, and at least one IR task remains unfinished; Coder's result affirmatively supports this outcome, and no fixed presentation format of the reply is required. Output shall include `coderOutput: <verbatim final text>`, `latestCommit: <commit identity>`, `irNumber` identifying the IR, and `irTask` naming the implemented task.
|
|
92
|
+
- `finalTask`: Coder implemented the IR's final unfinished task and made its one new commit; Coder's result affirmatively supports this outcome, and no fixed presentation format of the reply is required. Output shall include `coderOutput: <verbatim final text>`, `latestCommit: <commit identity>`, `irNumber` identifying the IR, and `irTask` naming the implemented task.
|
|
85
93
|
|
|
86
94
|
### CODE-4
|
|
87
95
|
|
|
88
|
-
|
|
96
|
+
Captain waits until `review` passes with no unsettled findings; playbook `review` owns every review round and every review-fix commit, and no existing commit is rewritten.
|
|
97
|
+
|
|
98
|
+
When an IR-task phase, including the first phase for an existing IR, ends with its one new `code`-owned commit, Captain shall call playbook `review`:
|
|
89
99
|
|
|
90
100
|
> > Original intent: <caller-input>
|
|
91
101
|
> > Review scope: the commit <code-commit> from this coding phase and its resulting repository state.
|
|
92
102
|
> > Coder output: <coder-output>
|
|
103
|
+
>
|
|
93
104
|
> > Current IR task: <ir-task>
|
|
94
105
|
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
- Any other nested-call error parks `code` as failed and retains the control-plane error.
|
|
106
|
+
A nested `review` passes the phase only when its result applies to that supplied review scope, returns the exact evaluated repository revision, and affirmatively establishes that no unsettled findings remain.
|
|
107
|
+
When `review` passes a nonfinal IR-task phase, Captain continues with the next unfinished IR-task phase.
|
|
108
|
+
When `review` passes the final IR-task phase, `code` is complete and returns to its caller the exact last `code`-owned commit, the exact final evaluated repository revision, and the fact that every phase's review passed with no unsettled findings.
|
|
109
|
+
When `review` returns an authored abort or failure, or a terminal result that does not establish that the supplied scope was evaluated with no unsettled findings, `code` starts no further phase and reports the failure and the last `code`-owned commit to its caller.
|
|
110
|
+
When the nested `review` call fails outside that authored result contract, `code` parks as failed and retains the control-plane error instead of reporting an authored review outcome.
|
|
@@ -1,20 +1,17 @@
|
|
|
1
|
-
import { type
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
export type
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
* runtime text. The generic composer preserves the marker itself; CODE's
|
|
11
|
-
* override additionally keeps a multiline value inside that quote.
|
|
12
|
-
*/
|
|
13
|
-
declare function composePlayerPrompt(input: PlayerInput, promptIdentity: XStatePromptIdentity, resuming?: boolean): string;
|
|
1
|
+
import { type XStatePromptIdentity, type PlaybookPlayerInput, type XStatePlaybookRuntimeConstruction, type XStatePlaybookRuntimeFactory } from '@sublang/playbook/xstate-runtime';
|
|
2
|
+
export type { PlayerResult, PlayerCallOptions, PlayerSessionStore, CaptainResult, CaptainCallOptions, JsonValue, NormalizedError, PlaybookCallRequest, PlaybookCallResult, PlaybookCallStart, PlaybookStateValue, PlaybookState, PlaybookPendingCall, PlaybookRunResult, PlaybookRuntime, PlaybookRuntimeFactory, PlaybookRuntimeSnapshot, PlaybookSession, PlaybookPorts, PlaybookTraceEvent, PlaybookTraceType, PlaybookControlReceipt, PlaybookControlView, } from '@sublang/playbook/runtime';
|
|
3
|
+
export interface PlaybookRuntimeOptions {
|
|
4
|
+
readonly "runResults"?: string;
|
|
5
|
+
}
|
|
6
|
+
export type PlaybookHostCapabilities = XStatePlaybookRuntimeConstruction<PlaybookRuntimeOptions, {
|
|
7
|
+
readonly authority: object;
|
|
8
|
+
}>['hostCapabilities'];
|
|
9
|
+
export declare function validateOptions(value: unknown): PlaybookRuntimeOptions;
|
|
14
10
|
export declare const _internal: {
|
|
15
|
-
composePlayerPrompt:
|
|
16
|
-
|
|
11
|
+
composePlayerPrompt: (input: PlaybookPlayerInput, promptIdentity: XStatePromptIdentity, resuming?: boolean) => string;
|
|
12
|
+
RESUMABLE_STATE_IDS: ReadonlySet<string>;
|
|
17
13
|
UNFINISHED_FINAL_STATE_IDS: ReadonlySet<string>;
|
|
14
|
+
VERBATIM_PAYLOAD_FIELDS: ReadonlySet<string>;
|
|
18
15
|
};
|
|
19
|
-
declare const createPlaybookRuntime: XStatePlaybookRuntimeFactory<XStatePlaybookRuntimeConstruction<
|
|
16
|
+
declare const createPlaybookRuntime: XStatePlaybookRuntimeFactory<XStatePlaybookRuntimeConstruction<PlaybookRuntimeOptions, PlaybookHostCapabilities>, 3>;
|
|
20
17
|
export default createPlaybookRuntime;
|
|
@@ -1,177 +1,196 @@
|
|
|
1
1
|
// SPDX-License-Identifier: Apache-2.0
|
|
2
2
|
// SPDX-FileCopyrightText: 2026 SubLang International <https://sublang.ai>
|
|
3
|
-
//
|
|
4
|
-
//
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
const
|
|
17
|
-
|
|
18
|
-
|
|
3
|
+
// Generated by slc/materialize-link.mjs; governed by the complete slc/link.md.
|
|
4
|
+
// FSM: "./code.fsm.js"; export: codeMachine; strategies: shared defaults with labelled string relays and nested actors.
|
|
5
|
+
import { codeMachine as machine } from "./code.fsm.js";
|
|
6
|
+
import { createXStatePlaybookRuntime, snapshotJsonValue, composePlayerContinuation, } from '@sublang/playbook/xstate-runtime';
|
|
7
|
+
const OPTION_SCHEMA = {
|
|
8
|
+
"runResults": {
|
|
9
|
+
"type": "string",
|
|
10
|
+
"required": false
|
|
11
|
+
}
|
|
12
|
+
};
|
|
13
|
+
const INPUT_MAPPING = {
|
|
14
|
+
"runResults": "runResults"
|
|
15
|
+
};
|
|
16
|
+
const RESUMABLE_STATE_IDS = new Set([
|
|
17
|
+
"firstPhase",
|
|
18
|
+
"irTaskPhase"
|
|
19
19
|
]);
|
|
20
20
|
const UNFINISHED_FINAL_STATE_IDS = new Set([
|
|
21
|
-
|
|
21
|
+
"reviewFailed"
|
|
22
22
|
]);
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
23
|
+
const VERBATIM_PAYLOAD_FIELDS = new Set([
|
|
24
|
+
"coderOutput"
|
|
25
|
+
]);
|
|
26
|
+
export function validateOptions(value) {
|
|
27
|
+
const captured = snapshotJsonValue(value === undefined ? {} : value, "CODE runtime options");
|
|
28
|
+
if (captured === null || typeof captured !== 'object' || Array.isArray(captured)) {
|
|
29
|
+
throw new TypeError("CODE runtime options must be an object");
|
|
30
|
+
}
|
|
31
|
+
const fields = captured;
|
|
32
|
+
for (const key of Object.keys(captured)) {
|
|
33
|
+
if (!Object.hasOwn(OPTION_SCHEMA, key))
|
|
34
|
+
throw new TypeError("CODE runtime options." + key + ' is not declared');
|
|
29
35
|
}
|
|
30
|
-
const
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
36
|
+
for (const [key, schema] of Object.entries(OPTION_SCHEMA)) {
|
|
37
|
+
if (!Object.hasOwn(captured, key)) {
|
|
38
|
+
if (schema.required)
|
|
39
|
+
throw new TypeError("CODE runtime options." + key + ' is required');
|
|
34
40
|
}
|
|
35
|
-
if (typeof
|
|
36
|
-
throw new TypeError(
|
|
41
|
+
else if (typeof fields[key] !== schema.type || (schema.type === 'number' && !Number.isFinite(fields[key]))) {
|
|
42
|
+
throw new TypeError("CODE runtime options." + key + ' must be a ' + schema.type);
|
|
37
43
|
}
|
|
38
44
|
}
|
|
39
45
|
return captured;
|
|
40
46
|
}
|
|
41
|
-
function
|
|
42
|
-
if (token === '#')
|
|
43
|
-
return 'irNumber';
|
|
44
|
-
return token.replace(/-([A-Za-z0-9_$])/g, (_match, next) => next.toUpperCase());
|
|
45
|
-
}
|
|
46
|
-
function quoteContinuation(value) {
|
|
47
|
-
return value.replaceAll('\n', '\n> ');
|
|
48
|
-
}
|
|
49
|
-
/**
|
|
50
|
-
* Preserve authored Markdown quote markers around every line of relayed
|
|
51
|
-
* runtime text. The generic composer preserves the marker itself; CODE's
|
|
52
|
-
* override additionally keeps a multiline value inside that quote.
|
|
53
|
-
*/
|
|
54
|
-
function composePlayerPrompt(input, promptIdentity, resuming = false) {
|
|
47
|
+
function renderPlayerPrompt(input, promptIdentity, resuming = false) {
|
|
55
48
|
const fields = input;
|
|
56
|
-
const
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
const
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
if (
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
49
|
+
const mapping = {};
|
|
50
|
+
const identities = { "coder-llm": "coder" };
|
|
51
|
+
const omitted = new Set(["> Run results: <run-results>"]);
|
|
52
|
+
const fieldFor = (token) => Object.hasOwn(mapping, token) ? mapping[token] : (token === '#' ? 'irNumber' : token.replace(/-([A-Za-z0-9_$])/g, (_match, next) => next.toUpperCase()));
|
|
53
|
+
const parts = input.prompt.split(/(\r?\n)/);
|
|
54
|
+
let body = '';
|
|
55
|
+
for (let index = 0; index < parts.length; index += 2) {
|
|
56
|
+
const line = parts[index];
|
|
57
|
+
if (omitted.has(line)) {
|
|
58
|
+
const token = /<(#|[A-Za-z_$][A-Za-z0-9_$-]*)>$/.exec(line)[1];
|
|
59
|
+
if (fields[fieldFor(token)] === '')
|
|
60
|
+
continue;
|
|
61
|
+
}
|
|
62
|
+
body += line.replace(/<(#|[A-Za-z_$][A-Za-z0-9_$-]*)>/g, (match, token) => {
|
|
63
|
+
const value = Object.hasOwn(identities, token) ? promptIdentity(identities[token]) : fields[fieldFor(token)];
|
|
64
|
+
if (typeof value !== 'string')
|
|
65
|
+
return match;
|
|
66
|
+
return line.startsWith('> ') ? value.replace(/\r?\n/g, (ending) => ending + '> ') : value;
|
|
67
|
+
}) + (parts[index + 1] ?? '');
|
|
68
|
+
}
|
|
70
69
|
return composePlayerContinuation(input, body, resuming);
|
|
71
70
|
}
|
|
72
|
-
|
|
73
|
-
composePlayerPrompt,
|
|
74
|
-
VERBATIM_PAYLOAD_FIELDS,
|
|
75
|
-
UNFINISHED_FINAL_STATE_IDS,
|
|
76
|
-
};
|
|
71
|
+
const composePlayerPrompt = (input, promptIdentity, resuming) => renderPlayerPrompt(input, promptIdentity, resuming);
|
|
77
72
|
const runtimeSpec = {
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
snapshotOptions: snapshotCodeOptions,
|
|
85
|
-
entryEvent: {
|
|
86
|
-
type: 'START_CODE',
|
|
87
|
-
textField: 'callerInput',
|
|
88
|
-
// `startCoding` copies the entry text here, so the failure-state retry
|
|
89
|
-
// reads it back from the persisted machine snapshot and survives a
|
|
90
|
-
// continued session (DR-034).
|
|
91
|
-
contextField: 'callerInput',
|
|
92
|
-
},
|
|
93
|
-
roleStates: {
|
|
94
|
-
runFirstPhase: {
|
|
95
|
-
role: 'coder',
|
|
96
|
-
label: 'Coder is running the first coding phase: a direct implementation, a new intent record, or an existing intent-record task.',
|
|
73
|
+
composePlayerPrompt,
|
|
74
|
+
...{
|
|
75
|
+
"label": "CODE",
|
|
76
|
+
"compat": {
|
|
77
|
+
"artifactSchema": 3,
|
|
78
|
+
"runtimeAbi": 1
|
|
97
79
|
},
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
80
|
+
"entryEvent": {
|
|
81
|
+
"type": "START_CODE",
|
|
82
|
+
"textField": "callerInput",
|
|
83
|
+
"contextField": "callerInput"
|
|
101
84
|
},
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
85
|
+
"bossEvents": [],
|
|
86
|
+
"roleStates": {
|
|
87
|
+
"firstPhase": {
|
|
88
|
+
"role": "coder",
|
|
89
|
+
"label": "Coder runs the first coding phase: a direct implementation, a new IR, or the next task of an existing IR."
|
|
90
|
+
},
|
|
91
|
+
"irTaskPhase": {
|
|
92
|
+
"role": "coder",
|
|
93
|
+
"label": "Coder implements the identified IR's next unfinished task."
|
|
94
|
+
}
|
|
95
|
+
},
|
|
96
|
+
"outcomeAuthority": {
|
|
97
|
+
"governedPlayerStates": {
|
|
98
|
+
"firstPhase": {
|
|
99
|
+
"directCommit": {
|
|
100
|
+
"fields": {
|
|
101
|
+
"coderOutput": "presentation",
|
|
102
|
+
"latestCommit": "effect"
|
|
103
|
+
},
|
|
104
|
+
"repositoryDisposition": "one-descendant-commit"
|
|
110
105
|
},
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
106
|
+
"irCommit": {
|
|
107
|
+
"fields": {
|
|
108
|
+
"coderOutput": "presentation",
|
|
109
|
+
"latestCommit": "effect",
|
|
110
|
+
"irNumber": "semantic"
|
|
111
|
+
},
|
|
112
|
+
"repositoryDisposition": "one-descendant-commit"
|
|
118
113
|
},
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
114
|
+
"moreTasks": {
|
|
115
|
+
"fields": {
|
|
116
|
+
"coderOutput": "presentation",
|
|
117
|
+
"latestCommit": "effect",
|
|
118
|
+
"irNumber": "semantic",
|
|
119
|
+
"irTask": "semantic"
|
|
120
|
+
},
|
|
121
|
+
"repositoryDisposition": "one-descendant-commit"
|
|
127
122
|
},
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
123
|
+
"finalTask": {
|
|
124
|
+
"fields": {
|
|
125
|
+
"coderOutput": "presentation",
|
|
126
|
+
"latestCommit": "effect",
|
|
127
|
+
"irNumber": "semantic",
|
|
128
|
+
"irTask": "semantic"
|
|
129
|
+
},
|
|
130
|
+
"repositoryDisposition": "one-descendant-commit"
|
|
136
131
|
},
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
132
|
+
"needsBossReply": {
|
|
133
|
+
"fields": {
|
|
134
|
+
"question": "presentation"
|
|
135
|
+
},
|
|
136
|
+
"repositoryDisposition": "deferred"
|
|
137
|
+
}
|
|
142
138
|
},
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
139
|
+
"irTaskPhase": {
|
|
140
|
+
"moreTasks": {
|
|
141
|
+
"fields": {
|
|
142
|
+
"coderOutput": "presentation",
|
|
143
|
+
"latestCommit": "effect",
|
|
144
|
+
"irNumber": "semantic",
|
|
145
|
+
"irTask": "semantic"
|
|
146
|
+
},
|
|
147
|
+
"repositoryDisposition": "one-descendant-commit"
|
|
151
148
|
},
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
149
|
+
"finalTask": {
|
|
150
|
+
"fields": {
|
|
151
|
+
"coderOutput": "presentation",
|
|
152
|
+
"latestCommit": "effect",
|
|
153
|
+
"irNumber": "semantic",
|
|
154
|
+
"irTask": "semantic"
|
|
155
|
+
},
|
|
156
|
+
"repositoryDisposition": "one-descendant-commit"
|
|
160
157
|
},
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
158
|
+
"needsBossReply": {
|
|
159
|
+
"fields": {
|
|
160
|
+
"question": "presentation"
|
|
161
|
+
},
|
|
162
|
+
"repositoryDisposition": "deferred"
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
}
|
|
168
166
|
},
|
|
167
|
+
"placeholderFields": {},
|
|
168
|
+
"transitionEventFields": [
|
|
169
|
+
"callerInput",
|
|
170
|
+
"runResults",
|
|
171
|
+
"targetId",
|
|
172
|
+
"answer",
|
|
173
|
+
"questionId"
|
|
174
|
+
],
|
|
175
|
+
"controlContextFields": [
|
|
176
|
+
"phaseOutcome",
|
|
177
|
+
"irNumber",
|
|
178
|
+
"codeCommit",
|
|
179
|
+
"evaluatedRevision"
|
|
180
|
+
]
|
|
169
181
|
},
|
|
170
|
-
|
|
182
|
+
snapshotOptions: validateOptions,
|
|
183
|
+
machineInput: (options) => Object.fromEntries(Object.entries(INPUT_MAPPING).filter(([, key]) => options[key] !== undefined)
|
|
184
|
+
.map(([field, key]) => [field, options[key]])),
|
|
171
185
|
verbatimPayloadFields: VERBATIM_PAYLOAD_FIELDS,
|
|
172
|
-
|
|
186
|
+
resumableStateIds: RESUMABLE_STATE_IDS,
|
|
173
187
|
unfinishedFinalStateIds: UNFINISHED_FINAL_STATE_IDS,
|
|
174
|
-
transitionEventFields: ['callerInput', 'answer', 'questionId'],
|
|
175
188
|
};
|
|
176
|
-
const
|
|
189
|
+
export const _internal = {
|
|
190
|
+
composePlayerPrompt,
|
|
191
|
+
RESUMABLE_STATE_IDS,
|
|
192
|
+
UNFINISHED_FINAL_STATE_IDS,
|
|
193
|
+
VERBATIM_PAYLOAD_FIELDS,
|
|
194
|
+
};
|
|
195
|
+
const createPlaybookRuntime = createXStatePlaybookRuntime(machine, runtimeSpec);
|
|
177
196
|
export default createPlaybookRuntime;
|