@sublang/playbook 7.0.0 → 9.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 (62) hide show
  1. package/README.md +20 -7
  2. package/docs/cli.md +88 -43
  3. package/docs/configuration.md +221 -119
  4. package/docs/embedding.md +78 -27
  5. package/package.json +4 -3
  6. package/reference/sdlc/captain.playbook/captain.playbook.js +16 -5
  7. package/reference/sdlc/captain.playbook/captain.playbook.ts +20 -6
  8. package/reference/sdlc/code.md +1 -1
  9. package/reference/sdlc/code.playbook/bin/interactive-session.js +816 -0
  10. package/reference/sdlc/code.playbook/bin/launch-config.js +1078 -116
  11. package/reference/sdlc/code.playbook/bin/playbook.js +489 -34
  12. package/reference/sdlc/code.playbook/bin/run.js +283 -298
  13. package/reference/sdlc/code.playbook/bin/session-store.js +818 -26
  14. package/reference/sdlc/code.playbook/code.fsm.d.ts +9 -6
  15. package/reference/sdlc/code.playbook/code.fsm.introspect.js +2 -2
  16. package/reference/sdlc/code.playbook/code.fsm.introspect.ts +2 -2
  17. package/reference/sdlc/code.playbook/code.fsm.js +18 -15
  18. package/reference/sdlc/code.playbook/code.fsm.ts +21 -21
  19. package/reference/sdlc/code.playbook/code.gears.md +1 -1
  20. package/reference/sdlc/code.playbook/code.playbook.d.ts +2 -1
  21. package/reference/sdlc/code.playbook/code.playbook.js +25 -15
  22. package/reference/sdlc/code.playbook/code.playbook.ts +34 -17
  23. package/reference/sdlc/code.playbook/code.registry.d.ts +5 -13
  24. package/reference/sdlc/code.playbook/code.registry.js +3 -10
  25. package/reference/sdlc/code.playbook/code.registry.ts +7 -32
  26. package/reference/sdlc/code.playbook/playbook-captain.d.ts +39 -14
  27. package/reference/sdlc/code.playbook/playbook-captain.js +1014 -299
  28. package/reference/sdlc/code.playbook/playbook-captain.ts +1450 -406
  29. package/reference/sdlc/code.playbook/playbook.config.template.yaml +41 -49
  30. package/reference/sdlc/decide.md +4 -4
  31. package/reference/sdlc/decide.playbook/decide.fsm.d.ts +10 -10
  32. package/reference/sdlc/decide.playbook/decide.fsm.js +21 -14
  33. package/reference/sdlc/decide.playbook/decide.fsm.ts +27 -23
  34. package/reference/sdlc/decide.playbook/decide.gears.md +3 -5
  35. package/reference/sdlc/decide.playbook/decide.playbook.d.ts +11 -13
  36. package/reference/sdlc/decide.playbook/decide.playbook.js +465 -246
  37. package/reference/sdlc/decide.playbook/decide.playbook.ts +623 -283
  38. package/reference/sdlc/decide.playbook/decide.registry.d.ts +5 -13
  39. package/reference/sdlc/decide.playbook/decide.registry.js +3 -9
  40. package/reference/sdlc/decide.playbook/decide.registry.ts +7 -31
  41. package/reference/sdlc/review.md +4 -5
  42. package/reference/sdlc/review.playbook/review.fsm.d.ts +9 -11
  43. package/reference/sdlc/review.playbook/review.fsm.js +30 -24
  44. package/reference/sdlc/review.playbook/review.fsm.ts +39 -35
  45. package/reference/sdlc/review.playbook/review.gears.md +6 -5
  46. package/reference/sdlc/review.playbook/review.playbook.d.ts +2 -1
  47. package/reference/sdlc/review.playbook/review.playbook.js +29 -23
  48. package/reference/sdlc/review.playbook/review.playbook.ts +38 -28
  49. package/reference/sdlc/review.playbook/review.registry.d.ts +5 -13
  50. package/reference/sdlc/review.playbook/review.registry.js +3 -16
  51. package/reference/sdlc/review.playbook/review.registry.ts +7 -38
  52. package/slc/gears2fsm.md +45 -24
  53. package/slc/link.md +297 -135
  54. package/slc/text2gears.md +19 -18
  55. package/src/runtime.d.ts +21 -16
  56. package/src/runtime.ts +20 -23
  57. package/src/xstate-playbook-runtime.d.ts +34 -20
  58. package/src/xstate-playbook-runtime.js +973 -400
  59. package/src/xstate-playbook-runtime.ts +1203 -457
  60. package/src/xstate-runtime.d.ts +17 -7
  61. package/src/xstate-runtime.js +198 -81
  62. package/src/xstate-runtime.ts +339 -112
@@ -31,9 +31,9 @@
31
31
  // deterministic entry mapping, the controller captain-call
32
32
  // strategy with its single corrective re-ask (CAPPLAY-18),
33
33
  // controller-port submission, and status formatting.
34
- // Compat: spec.compat = { artifactSchema: 1, runtimeAbi: 1 }
34
+ // Compat: spec.compat = { artifactSchema: 2, runtimeAbi: 1 }
35
35
  // (DR-022; checked at construction by the loading engine).
36
- import { createXStatePlaybookRuntime, defaultComposeCaptainPrompt, normalizeError, normalizeErrorCompact, parseJudgeJson, snapshotJsonValue, RUNTIME_ABI, } from '../../../src/xstate-runtime.js';
36
+ import { createXStatePlaybookRuntime, defaultComposeCaptainPrompt, normalizeError, normalizeErrorCompact, parseJudgeJson, snapshotJsonValue, } from '../../../src/xstate-runtime.js';
37
37
  import { captainMachine, } from './captain.fsm.js';
38
38
  function assertNonEmptyString(value, label) {
39
39
  if (typeof value !== 'string' || value.trim().length === 0) {
@@ -516,11 +516,15 @@ export const _internal = {
516
516
  // describe/apply control surface — lives in @sublang/playbook/xstate-runtime.
517
517
  const runtimeSpec = {
518
518
  label: 'CAPTAIN',
519
- compat: { artifactSchema: 1, runtimeAbi: RUNTIME_ABI },
519
+ // DR-022 / slc/link.md: the declaration carries the value current at link
520
+ // time — a literal, never the loading engine's RUNTIME_ABI self-report,
521
+ // which would follow whatever engine loads the module and make the
522
+ // factory's skew check compare that engine with itself.
523
+ compat: { artifactSchema: 2, runtimeAbi: 1 },
520
524
  snapshotOptions: snapshotCaptainOptions,
521
525
  machineInput: (options) => ({ enabledPlaybooks: options.enabledPlaybooks }),
522
526
  classifyBossText: (text, ports, signal, snapshotOrState, boundary, options) => classifyControllerTurn(text, ports, signal, snapshotOrState, boundary, options),
523
- playerStates: {},
527
+ roleStates: {},
524
528
  classificationStatus: () => undefined,
525
529
  captainStrategy: controllerCaptainStrategy,
526
530
  // CAPPLAY-10 / PBRT-52: the Captain's own ControlView context projection —
@@ -543,8 +547,15 @@ const runtimeSpec = {
543
547
  ],
544
548
  statusesForState,
545
549
  };
546
- const createCaptainPlaybookRuntime = createXStatePlaybookRuntime(captainMachine, runtimeSpec);
550
+ // DR-022's compat check fails fast at factory construction. The Captain is
551
+ // statically imported by the shell and both CLI front ends, so constructing
552
+ // here at module evaluation would turn a future compat mismatch into an
553
+ // uncaught ESM-load error that takes even `--help` down; constructing on
554
+ // the first runtime request keeps the failure inside the caught
555
+ // host-construction boundary that owes the Boss a setup diagnostic.
556
+ let createCaptainPlaybookRuntime;
547
557
  export function createPlaybookRuntime(options) {
558
+ createCaptainPlaybookRuntime ??= createXStatePlaybookRuntime(captainMachine, runtimeSpec);
548
559
  return createCaptainPlaybookRuntime(options);
549
560
  }
550
561
  const factory = createPlaybookRuntime;
@@ -31,7 +31,7 @@
31
31
  // deterministic entry mapping, the controller captain-call
32
32
  // strategy with its single corrective re-ask (CAPPLAY-18),
33
33
  // controller-port submission, and status formatting.
34
- // Compat: spec.compat = { artifactSchema: 1, runtimeAbi: 1 }
34
+ // Compat: spec.compat = { artifactSchema: 2, runtimeAbi: 1 }
35
35
  // (DR-022; checked at construction by the loading engine).
36
36
 
37
37
  import {
@@ -41,7 +41,6 @@ import {
41
41
  normalizeErrorCompact,
42
42
  parseJudgeJson,
43
43
  snapshotJsonValue,
44
- RUNTIME_ABI,
45
44
  type PlaybookActorOutput,
46
45
  type PlaybookCaptainInput,
47
46
  type ScheduledStatus,
@@ -798,7 +797,11 @@ export const _internal = {
798
797
  // describe/apply control surface — lives in @sublang/playbook/xstate-runtime.
799
798
  const runtimeSpec: XStatePlaybookRuntimeSpec<ValidatedCaptainOptions> = {
800
799
  label: 'CAPTAIN',
801
- compat: { artifactSchema: 1, runtimeAbi: RUNTIME_ABI },
800
+ // DR-022 / slc/link.md: the declaration carries the value current at link
801
+ // time — a literal, never the loading engine's RUNTIME_ABI self-report,
802
+ // which would follow whatever engine loads the module and make the
803
+ // factory's skew check compare that engine with itself.
804
+ compat: { artifactSchema: 2, runtimeAbi: 1 },
802
805
  snapshotOptions: snapshotCaptainOptions,
803
806
  machineInput: (options) => ({ enabledPlaybooks: options.enabledPlaybooks }),
804
807
  classifyBossText: (text, ports, signal, snapshotOrState, boundary, options) =>
@@ -810,7 +813,7 @@ const runtimeSpec: XStatePlaybookRuntimeSpec<ValidatedCaptainOptions> = {
810
813
  boundary,
811
814
  options,
812
815
  ) as Promise<import('xstate').EventObject | undefined>,
813
- playerStates: {},
816
+ roleStates: {},
814
817
  classificationStatus: () => undefined,
815
818
  captainStrategy: controllerCaptainStrategy,
816
819
  // CAPPLAY-10 / PBRT-52: the Captain's own ControlView context projection —
@@ -834,12 +837,23 @@ const runtimeSpec: XStatePlaybookRuntimeSpec<ValidatedCaptainOptions> = {
834
837
  statusesForState,
835
838
  };
836
839
 
837
- const createCaptainPlaybookRuntime: PlaybookRuntimeFactory<ValidatedCaptainOptions> =
838
- createXStatePlaybookRuntime(captainMachine, runtimeSpec);
840
+ // DR-022's compat check fails fast at factory construction. The Captain is
841
+ // statically imported by the shell and both CLI front ends, so constructing
842
+ // here at module evaluation would turn a future compat mismatch into an
843
+ // uncaught ESM-load error that takes even `--help` down; constructing on
844
+ // the first runtime request keeps the failure inside the caught
845
+ // host-construction boundary that owes the Boss a setup diagnostic.
846
+ let createCaptainPlaybookRuntime:
847
+ | PlaybookRuntimeFactory<ValidatedCaptainOptions>
848
+ | undefined;
839
849
 
840
850
  export function createPlaybookRuntime(
841
851
  options: PlaybookRuntimeOptions,
842
852
  ): PlaybookRuntime {
853
+ createCaptainPlaybookRuntime ??= createXStatePlaybookRuntime(
854
+ captainMachine,
855
+ runtimeSpec,
856
+ );
843
857
  return createCaptainPlaybookRuntime(options);
844
858
  }
845
859
 
@@ -4,7 +4,7 @@
4
4
 
5
5
  # Code
6
6
 
7
- Players:
7
+ Roles:
8
8
 
9
9
  - Coder
10
10