@sublang/playbook 13.1.0 → 13.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 (43) hide show
  1. package/README.md +7 -5
  2. package/docs/cli.md +28 -9
  3. package/docs/configuration.md +27 -14
  4. package/docs/embedding.md +1 -1
  5. package/package.json +40 -2
  6. package/reference/sdlc/branch.md +37 -0
  7. package/reference/sdlc/branch.playbook/branch.fsm.d.ts +169 -0
  8. package/reference/sdlc/branch.playbook/branch.fsm.js +325 -0
  9. package/reference/sdlc/branch.playbook/branch.fsm.ts +458 -0
  10. package/reference/sdlc/branch.playbook/branch.gears.md +44 -0
  11. package/reference/sdlc/branch.playbook/branch.playbook.d.ts +20 -0
  12. package/reference/sdlc/branch.playbook/branch.playbook.js +121 -0
  13. package/reference/sdlc/branch.playbook/branch.playbook.ts +217 -0
  14. package/reference/sdlc/branch.playbook/branch.registry.d.ts +40 -0
  15. package/reference/sdlc/branch.playbook/branch.registry.js +63 -0
  16. package/reference/sdlc/branch.playbook/branch.registry.ts +121 -0
  17. package/reference/sdlc/code.playbook/bin/session-host.js +13 -3
  18. package/reference/sdlc/code.playbook/playbook-captain.d.ts +26 -1
  19. package/reference/sdlc/code.playbook/playbook-captain.js +218 -6
  20. package/reference/sdlc/code.playbook/playbook-captain.ts +281 -6
  21. package/reference/sdlc/code.playbook/playbook.config.template.yaml +21 -8
  22. package/reference/sdlc/code.playbook/session-host.d.ts +26 -0
  23. package/reference/sdlc/dev.md +24 -3
  24. package/reference/sdlc/dev.playbook/dev.fsm.d.ts +100 -9
  25. package/reference/sdlc/dev.playbook/dev.fsm.js +235 -18
  26. package/reference/sdlc/dev.playbook/dev.fsm.ts +368 -24
  27. package/reference/sdlc/dev.playbook/dev.gears.md +45 -7
  28. package/reference/sdlc/dev.playbook/dev.playbook.js +13 -1
  29. package/reference/sdlc/dev.playbook/dev.playbook.ts +13 -1
  30. package/reference/sdlc/dev.playbook/dev.registry.d.ts +1 -1
  31. package/reference/sdlc/dev.playbook/dev.registry.js +7 -2
  32. package/reference/sdlc/dev.playbook/dev.registry.ts +7 -2
  33. package/reference/sdlc/pr.md +108 -0
  34. package/reference/sdlc/pr.playbook/pr.fsm.d.ts +352 -0
  35. package/reference/sdlc/pr.playbook/pr.fsm.js +902 -0
  36. package/reference/sdlc/pr.playbook/pr.fsm.ts +1251 -0
  37. package/reference/sdlc/pr.playbook/pr.gears.md +155 -0
  38. package/reference/sdlc/pr.playbook/pr.playbook.d.ts +27 -0
  39. package/reference/sdlc/pr.playbook/pr.playbook.js +133 -0
  40. package/reference/sdlc/pr.playbook/pr.playbook.ts +235 -0
  41. package/reference/sdlc/pr.playbook/pr.registry.d.ts +40 -0
  42. package/reference/sdlc/pr.playbook/pr.registry.js +68 -0
  43. package/reference/sdlc/pr.playbook/pr.registry.ts +124 -0
@@ -0,0 +1,124 @@
1
+ // SPDX-License-Identifier: Apache-2.0
2
+ // SPDX-FileCopyrightText: 2026 SubLang International <https://sublang.ai>
3
+
4
+ import createPlaybookRuntime, {
5
+ type PrPlaybookHostCapabilities,
6
+ type PlaybookRuntime,
7
+ } from './pr.playbook.js';
8
+
9
+ export interface PlaybookSummaryPolicy {
10
+ stateCountLabels: Readonly<Record<string, string>>;
11
+ copyPasteGuardNames: readonly string[];
12
+ savedCountsLine(
13
+ counts: { interruptions: number; copyPastes: number },
14
+ rounds: number,
15
+ ): string;
16
+ }
17
+
18
+ export type PrOptions = Readonly<Record<string, never>>;
19
+
20
+ export interface PrPlaybookRegistryEntry {
21
+ id: 'pr';
22
+ command: 'pr';
23
+ intent: string;
24
+ artifactSchema: 3;
25
+ runtimeProfile: {
26
+ readonly kind: 'shared-factory';
27
+ readonly compat: {
28
+ readonly artifactSchema: 3;
29
+ readonly runtimeAbi: number;
30
+ };
31
+ };
32
+ requiredRoleIds: readonly ['coder'];
33
+ concurrentRoleSets: readonly [];
34
+ summaryPolicy: PlaybookSummaryPolicy;
35
+ validateOptions(optionSlice: unknown): PrOptions;
36
+ createRuntime(
37
+ options: PrOptions,
38
+ hostCapabilities: PrPlaybookHostCapabilities,
39
+ ): PlaybookRuntime;
40
+ }
41
+
42
+ // CODE owns and labels the rounds of the one fix it may make. PR's suspended
43
+ // call state only delegates to that child and must not double-count its
44
+ // rounds; its script states run no agent at all. Only the Coder publication
45
+ // round is PR's own.
46
+ export const prStateCountLabels = {
47
+ openPullRequest: 'publication round',
48
+ } as const;
49
+
50
+ export const prCopyPasteGuardNames = ['opened'] as const;
51
+
52
+ function countNoun(
53
+ count: number,
54
+ singular: string,
55
+ plural = `${singular}s`,
56
+ ): string {
57
+ return `${count} ${count === 1 ? singular : plural}`;
58
+ }
59
+
60
+ export function prSavedCountsLine(
61
+ counts: { interruptions: number; copyPastes: number },
62
+ rounds: number,
63
+ ): string {
64
+ return [
65
+ 'Saved you',
66
+ countNoun(counts.interruptions, 'interruption'),
67
+ 'and',
68
+ countNoun(counts.copyPastes, 'copy-paste'),
69
+ 'across',
70
+ countNoun(rounds, 'round'),
71
+ 'of delivery.',
72
+ ].join(' ');
73
+ }
74
+
75
+ export const prSummaryPolicy: PlaybookSummaryPolicy = {
76
+ stateCountLabels: prStateCountLabels,
77
+ copyPasteGuardNames: prCopyPasteGuardNames,
78
+ savedCountsLine: prSavedCountsLine,
79
+ };
80
+
81
+ export function validatePrOptions(optionSlice: unknown): PrOptions {
82
+ if (optionSlice === undefined) return Object.freeze({});
83
+ if (
84
+ optionSlice === null ||
85
+ typeof optionSlice !== 'object' ||
86
+ Array.isArray(optionSlice)
87
+ ) {
88
+ throw new Error('captain.options.playbooks.pr.options must be an object');
89
+ }
90
+ const keys = Object.keys(optionSlice);
91
+ if (keys.length > 0) {
92
+ throw new Error(
93
+ `Unknown config field captain.options.playbooks.pr.options.${keys[0]}`,
94
+ );
95
+ }
96
+ return Object.freeze({});
97
+ }
98
+
99
+ export const prPlaybookRegistryEntry: PrPlaybookRegistryEntry = {
100
+ id: 'pr',
101
+ command: 'pr',
102
+ intent:
103
+ 'publish a reviewed branch as a pull request, wait for its checks, fix red checks once through code, and merge it',
104
+ artifactSchema: 3,
105
+ runtimeProfile: Object.freeze({
106
+ kind: 'shared-factory',
107
+ compat: createPlaybookRuntime.compat,
108
+ }),
109
+ requiredRoleIds: ['coder'],
110
+ concurrentRoleSets: [],
111
+ summaryPolicy: prSummaryPolicy,
112
+ validateOptions: validatePrOptions,
113
+ createRuntime(options, hostCapabilities) {
114
+ // The five script states run `gh` and `git` in the repository the host
115
+ // governs: the linked `cwd` option is composed here from the host's
116
+ // authority working directory (DR-040 §2), never from configuration.
117
+ return createPlaybookRuntime({
118
+ configuredOptions: { ...options, cwd: hostCapabilities.authority.cwd },
119
+ hostCapabilities,
120
+ });
121
+ },
122
+ };
123
+
124
+ export default prPlaybookRegistryEntry;