@sublang/playbook 0.5.0 → 0.7.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.
@@ -0,0 +1,85 @@
1
+ <!-- SPDX-License-Identifier: Apache-2.0 -->
2
+ <!-- SPDX-FileCopyrightText: 2026 SubLang International <https://sublang.ai> -->
3
+
4
+ # Text-to-GEARS Transformation
5
+
6
+ First phase of a playbook (a state-machine agent orchestrating other agents).
7
+ Transforms a user's procedure description into normative GEARS [[1]] spec items.
8
+
9
+ - Source: free-form natural-language description.
10
+ - Target: a package of GEARS spec items.
11
+
12
+ The second phase (spec items → state machine) is out of scope.
13
+
14
+ ## Formats
15
+
16
+ | Role | Format | Extension |
17
+ | --- | --- | --- |
18
+ | source | text | .md |
19
+ | target | gears | .md |
20
+
21
+ ## Players
22
+
23
+ Players name AI agents and the user.
24
+
25
+ Two default players:
26
+
27
+ - Boss: the human user
28
+ - Captain: the coordinating agent
29
+
30
+ Source may declare additional players in an opening `Players:` section.
31
+ A player may alias other players with `=` and `|`; Boss picks one at runtime.
32
+ E.g.:
33
+
34
+ - Coder
35
+ - Reviewer
36
+ - Committer = Coder | Reviewer
37
+
38
+ Capitalize English player names (e.g., `Writer`); quote non-English names (e.g., `作者`) when needed to distinguish from prose.
39
+
40
+ ## Behaviors
41
+
42
+ Each spec item names a condition, the player to prompt, and the prompt itself.
43
+ Prompts shall be blockquoted, one point per line.
44
+
45
+ E.g.:
46
+
47
+ ```markdown
48
+ ### CODE-10
49
+
50
+ When Reviewer is about to review any change, Captain shall prompt Reviewer:
51
+ > Flag any issues or improvements (numbered; no duplication).
52
+ > Think thoroughly — don't just approve or reject.
53
+ > If the change is ready to commit or push, don't raise nitpicks.
54
+ > Do not edit files or commit; report findings only.
55
+ ```
56
+
57
+ Target should be written in the same language as Source.
58
+
59
+ ## Composition
60
+
61
+ Source snippets may overlap or duplicate.
62
+ When composing them into a spec item, text2gears shall deduplicate identical prompt lines.
63
+
64
+ Each spec item addresses one state behavior and carries its full final prompt (the static part).
65
+ Cross-item duplication is acceptable: spec items are compiled artifacts; Source is what users maintain.
66
+
67
+ Test: a human shall be able to simulate a run by copying any single item's prompt verbatim — no cross-item composition needed.
68
+
69
+ ### Placeholders vs literals
70
+
71
+ Use `<placeholder>` for dynamic values in blockquoted prompts.
72
+ Everything else inside a blockquote is static text, not an example; examples belong in surrounding prose.
73
+
74
+ ### Split by content discriminator
75
+
76
+ Partition items by every variable that determines prompt content — including accumulated state when the trigger alone doesn't.
77
+
78
+ ### Prune dead disjuncts
79
+
80
+ Drop disjunctive branches incompatible with the rest of an item's condition or prompt.
81
+ Dead branches mislead readers and downstream phases.
82
+
83
+ ## References
84
+
85
+ [1]: [GEARS syntax](/specs/meta.md#item-syntax)
@@ -0,0 +1,23 @@
1
+ export interface PlayerResult {
2
+ status: 'ok' | 'aborted' | 'error';
3
+ finalText?: string;
4
+ error?: string;
5
+ }
6
+ export interface PlaybookPorts {
7
+ callPlayer(playerId: string, prompt: string, signal: AbortSignal): Promise<PlayerResult>;
8
+ callJudge(prompt: string, signal: AbortSignal): Promise<string>;
9
+ emitStatus(message: string, data?: unknown): Promise<void>;
10
+ emitTelemetry(event: {
11
+ topic: string;
12
+ payload: unknown;
13
+ }): Promise<void>;
14
+ }
15
+ export interface PlaybookRuntime {
16
+ init(ports: PlaybookPorts): Promise<void>;
17
+ handleBossInput(turn: {
18
+ text: string;
19
+ signal: AbortSignal;
20
+ }): Promise<void>;
21
+ dispose(): Promise<void>;
22
+ }
23
+ export type PlaybookRuntimeFactory<Options = unknown> = (options: Options) => PlaybookRuntime;
package/src/runtime.js ADDED
@@ -0,0 +1,10 @@
1
+ // SPDX-License-Identifier: Apache-2.0
2
+ // SPDX-FileCopyrightText: 2026 SubLang International <https://sublang.ai>
3
+ //
4
+ // Public runtime contract for @sublang/playbook — the type-only single
5
+ // source for the PlaybookPorts / PlaybookRuntime contract authored in
6
+ // slc/link.md. It imports no CODE or FSM types, so the dependency runs
7
+ // one way: linked playbook runtimes (e.g. code.playbook.ts) import and
8
+ // re-export these names rather than redefining them
9
+ // (PBRT-5, PBRT-34, DR-004 Addendum A4).
10
+ export {};
package/src/runtime.ts ADDED
@@ -0,0 +1,36 @@
1
+ // SPDX-License-Identifier: Apache-2.0
2
+ // SPDX-FileCopyrightText: 2026 SubLang International <https://sublang.ai>
3
+ //
4
+ // Public runtime contract for @sublang/playbook — the type-only single
5
+ // source for the PlaybookPorts / PlaybookRuntime contract authored in
6
+ // slc/link.md. It imports no CODE or FSM types, so the dependency runs
7
+ // one way: linked playbook runtimes (e.g. code.playbook.ts) import and
8
+ // re-export these names rather than redefining them
9
+ // (PBRT-5, PBRT-34, DR-004 Addendum A4).
10
+
11
+ export interface PlayerResult {
12
+ status: 'ok' | 'aborted' | 'error';
13
+ finalText?: string;
14
+ error?: string;
15
+ }
16
+
17
+ export interface PlaybookPorts {
18
+ callPlayer(
19
+ playerId: string,
20
+ prompt: string,
21
+ signal: AbortSignal,
22
+ ): Promise<PlayerResult>;
23
+ callJudge(prompt: string, signal: AbortSignal): Promise<string>;
24
+ emitStatus(message: string, data?: unknown): Promise<void>;
25
+ emitTelemetry(event: { topic: string; payload: unknown }): Promise<void>;
26
+ }
27
+
28
+ export interface PlaybookRuntime {
29
+ init(ports: PlaybookPorts): Promise<void>;
30
+ handleBossInput(turn: { text: string; signal: AbortSignal }): Promise<void>;
31
+ dispose(): Promise<void>;
32
+ }
33
+
34
+ export type PlaybookRuntimeFactory<Options = unknown> = (
35
+ options: Options,
36
+ ) => PlaybookRuntime;