dsh-pstack 0.2.0-beta.1 → 0.2.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 (275) hide show
  1. package/LICENSE +2 -3
  2. package/README.md +148 -84
  3. package/README.zh.md +198 -0
  4. package/assets/pstack-config-entry.png +0 -0
  5. package/cordis.patch.yml +105 -27
  6. package/dist/client.mjs +2341 -0
  7. package/dist/client.mjs.map +1 -0
  8. package/dist/host-contract-CUPSpeNk.d.mts +22 -0
  9. package/dist/index.d.mts +49 -238
  10. package/dist/index.mjs +250 -123
  11. package/dist/models.d.mts +44 -0
  12. package/dist/models.mjs +201 -0
  13. package/dist/paths-BT77khwm.mjs +48 -0
  14. package/dist/pstack/LICENSE +21 -0
  15. package/dist/pstack/README.md +291 -0
  16. package/dist/pstack/agents/poteto-agent.md +9 -0
  17. package/{assets → dist/pstack}/docs/guide/01-setup.md +13 -11
  18. package/{assets → dist/pstack}/docs/guide/02-poteto-mode.md +4 -4
  19. package/{assets → dist/pstack}/docs/guide/04-design.md +4 -4
  20. package/{assets → dist/pstack}/docs/guide/05-build-and-clean.md +2 -2
  21. package/{assets → dist/pstack}/docs/guide/06-verify-and-ship.md +13 -3
  22. package/{assets → dist/pstack}/docs/guide/07-overnight.md +15 -13
  23. package/{assets → dist/pstack}/docs/guide/09-make-it-yours.md +6 -2
  24. package/{assets → dist/pstack}/docs/guide/10-recipes-and-pitfalls.md +7 -5
  25. package/{assets → dist/pstack}/docs/guide/README.md +1 -1
  26. package/dist/pstack/docs/harness/dsh.md +98 -0
  27. package/{assets → dist/pstack}/skills/architect/SKILL.md +12 -12
  28. package/dist/pstack/skills/arena/SKILL.md +50 -0
  29. package/{assets → dist/pstack}/skills/automate-me/SKILL.md +14 -14
  30. package/{assets → dist/pstack}/skills/benchmark-checklist/SKILL.md +1 -1
  31. package/{assets → dist/pstack}/skills/blast-radius/SKILL.md +4 -6
  32. package/{assets → dist/pstack}/skills/correct/SKILL.md +1 -1
  33. package/{assets → dist/pstack}/skills/create-formal-verification-skill/SKILL.md +4 -2
  34. package/{assets → dist/pstack}/skills/create-verification-skill/SKILL.md +5 -5
  35. package/dist/pstack/skills/figure-it-out/SKILL.md +54 -0
  36. package/dist/pstack/skills/how/SKILL.md +38 -0
  37. package/{assets → dist/pstack}/skills/in-your-own-words/SKILL.md +1 -1
  38. package/dist/pstack/skills/interrogate/SKILL.md +33 -0
  39. package/{assets → dist/pstack}/skills/ketchup/SKILL.md +3 -5
  40. package/dist/pstack/skills/ketchup-video/SKILL.md +29 -0
  41. package/{assets → dist/pstack}/skills/maintain-formal-verification-skill/SKILL.md +1 -1
  42. package/{assets → dist/pstack}/skills/maintain-verification-skill/SKILL.md +3 -3
  43. package/dist/pstack/skills/make-bot-ui/SKILL.md +117 -0
  44. package/dist/pstack/skills/no-comments/SKILL.md +26 -0
  45. package/{assets → dist/pstack}/skills/poteto-help/SKILL.md +34 -31
  46. package/{assets → dist/pstack}/skills/poteto-help/references/prompting.md +1 -1
  47. package/{assets → dist/pstack}/skills/poteto-help/references/recipes.md +3 -3
  48. package/{assets → dist/pstack}/skills/poteto-mode/SKILL.md +20 -19
  49. package/dist/pstack/skills/poteto-mode/playbooks/authoring-a-skill.md +12 -0
  50. package/dist/pstack/skills/poteto-mode/playbooks/autonomous-run.md +13 -0
  51. package/dist/pstack/skills/poteto-mode/playbooks/autopilot-full.md +25 -0
  52. package/dist/pstack/skills/poteto-mode/playbooks/autopilot-stack.md +8 -0
  53. package/{assets → dist/pstack}/skills/poteto-mode/playbooks/babysit.md +4 -4
  54. package/dist/pstack/skills/poteto-mode/playbooks/bug-fix.md +15 -0
  55. package/{assets → dist/pstack}/skills/poteto-mode/playbooks/eval.md +3 -3
  56. package/dist/pstack/skills/poteto-mode/playbooks/feature.md +21 -0
  57. package/{assets → dist/pstack}/skills/poteto-mode/playbooks/hillclimb.md +3 -3
  58. package/{assets → dist/pstack}/skills/poteto-mode/playbooks/investigation.md +2 -2
  59. package/{assets → dist/pstack}/skills/poteto-mode/playbooks/multi-phase-plan.md +23 -23
  60. package/{assets → dist/pstack}/skills/poteto-mode/playbooks/opening-a-pr.md +6 -6
  61. package/dist/pstack/skills/poteto-mode/playbooks/orchestrate.md +25 -0
  62. package/{assets → dist/pstack}/skills/poteto-mode/playbooks/pause-safely.md +2 -2
  63. package/dist/pstack/skills/poteto-mode/playbooks/perf-issue.md +25 -0
  64. package/{assets → dist/pstack}/skills/poteto-mode/playbooks/prototype.md +4 -4
  65. package/dist/pstack/skills/poteto-mode/playbooks/refactoring.md +16 -0
  66. package/dist/pstack/skills/poteto-mode/playbooks/runtime-forensics.md +11 -0
  67. package/dist/pstack/skills/poteto-mode/playbooks/session-pickup.md +11 -0
  68. package/{assets → dist/pstack}/skills/poteto-mode/playbooks/shipping.md +2 -2
  69. package/{assets → dist/pstack}/skills/poteto-mode/playbooks/trace-forensics.md +2 -2
  70. package/dist/pstack/skills/poteto-mode/playbooks/visual-parity.md +11 -0
  71. package/dist/pstack/skills/poteto-mode/playbooks/worktree-cleanup.md +12 -0
  72. package/{assets → dist/pstack}/skills/poteto-mode/scripts/check-plan.mjs +6 -8
  73. package/dist/pstack/skills/poteto-mode/scripts/check-plan.test.mjs +128 -0
  74. package/{assets/skills/poteto-mode/scripts/check-plan.test.mjs → dist/pstack/skills/poteto-mode/scripts/expect.mjs} +12 -101
  75. package/dist/pstack/skills/poteto-mode/scripts/support.mjs +93 -0
  76. package/dist/pstack/skills/poteto-mode/scripts/watch-pr/cli.mjs +123 -0
  77. package/dist/pstack/skills/poteto-mode/scripts/watch-pr/cli.test.mjs +217 -0
  78. package/dist/pstack/skills/poteto-mode/scripts/watch-pr/fakes.test-helper.mjs +119 -0
  79. package/dist/pstack/skills/poteto-mode/scripts/watch-pr/github.mjs +626 -0
  80. package/dist/pstack/skills/poteto-mode/scripts/watch-pr/github.test.mjs +521 -0
  81. package/dist/pstack/skills/poteto-mode/scripts/watch-pr/policy.mjs +657 -0
  82. package/dist/pstack/skills/poteto-mode/scripts/watch-pr/policy.test.mjs +523 -0
  83. package/dist/pstack/skills/poteto-mode/scripts/watch-pr/render.mjs +106 -0
  84. package/dist/pstack/skills/poteto-mode/scripts/watch-pr/types.mjs +9 -0
  85. package/dist/pstack/skills/poteto-mode/scripts/watch-pr/watch-pr.mjs +5 -0
  86. package/{assets → dist/pstack}/skills/poteto-mode/scripts/worktree-audit.mjs +15 -22
  87. package/dist/pstack/skills/poteto-mode/scripts/worktree-audit.test.mjs +134 -0
  88. package/{assets → dist/pstack}/skills/principle-attack-the-premise/SKILL.md +1 -1
  89. package/{assets → dist/pstack}/skills/principle-boundary-discipline/SKILL.md +1 -1
  90. package/{assets → dist/pstack}/skills/principle-encode-lessons-in-structure/SKILL.md +1 -1
  91. package/{assets → dist/pstack}/skills/principle-exhaust-the-design-space/SKILL.md +1 -1
  92. package/{assets → dist/pstack}/skills/principle-experience-first/SKILL.md +1 -1
  93. package/{assets → dist/pstack}/skills/principle-explain-the-number/SKILL.md +3 -2
  94. package/{assets → dist/pstack}/skills/principle-fix-root-causes/SKILL.md +1 -1
  95. package/{assets → dist/pstack}/skills/principle-laziness-protocol/SKILL.md +1 -1
  96. package/{assets → dist/pstack}/skills/principle-make-operations-idempotent/SKILL.md +1 -1
  97. package/{assets → dist/pstack}/skills/principle-migrate-callers-then-delete-legacy-apis/SKILL.md +1 -1
  98. package/{assets → dist/pstack}/skills/principle-minimize-reader-load/SKILL.md +1 -1
  99. package/{assets → dist/pstack}/skills/principle-model-the-domain/SKILL.md +1 -1
  100. package/{assets → dist/pstack}/skills/principle-never-block-on-the-human/SKILL.md +1 -1
  101. package/{assets → dist/pstack}/skills/principle-outcome-oriented-execution/SKILL.md +1 -1
  102. package/{assets → dist/pstack}/skills/principle-prove-it-works/SKILL.md +2 -2
  103. package/{assets → dist/pstack}/skills/principle-redesign-from-first-principles/SKILL.md +1 -1
  104. package/{assets → dist/pstack}/skills/principle-separate-before-serializing-shared-state/SKILL.md +1 -1
  105. package/{assets → dist/pstack}/skills/principle-sequence-verifiable-units/SKILL.md +1 -1
  106. package/{assets → dist/pstack}/skills/principle-subtract-before-you-add/SKILL.md +1 -1
  107. package/{assets → dist/pstack}/skills/principle-test-behavior-not-implementation/SKILL.md +1 -1
  108. package/{assets → dist/pstack}/skills/principle-type-system-discipline/SKILL.md +1 -1
  109. package/dist/pstack/skills/recall/SKILL.md +37 -0
  110. package/dist/pstack/skills/reflect/SKILL.md +71 -0
  111. package/{assets → dist/pstack}/skills/reflect/references/divergent-reviewer.md +4 -4
  112. package/{assets → dist/pstack}/skills/reflect/references/judgment-reviewer.md +2 -2
  113. package/{assets → dist/pstack}/skills/reflect/references/synthesizer.md +5 -5
  114. package/{assets → dist/pstack}/skills/reflect/references/tooling-reviewer.md +2 -2
  115. package/dist/pstack/skills/setup-pstack/SKILL.md +80 -0
  116. package/{assets → dist/pstack}/skills/sharpen/SKILL.md +1 -1
  117. package/{assets → dist/pstack}/skills/show-me-your-work/SKILL.md +8 -8
  118. package/{assets → dist/pstack}/skills/show-me-your-work/scripts/log.mjs +1 -3
  119. package/dist/pstack/skills/show-me-your-work/scripts/log.test.mjs +56 -0
  120. package/dist/pstack/skills/statechart/SKILL.md +82 -0
  121. package/dist/pstack/skills/statechart/references/render.md +93 -0
  122. package/dist/pstack/skills/statechart/scripts/backends/cfg.mjs +31 -0
  123. package/dist/pstack/skills/statechart/scripts/backends/mermaid.mjs +186 -0
  124. package/dist/pstack/skills/statechart/scripts/backends/plain-text.mjs +62 -0
  125. package/dist/pstack/skills/statechart/scripts/backends/report.mjs +84 -0
  126. package/dist/pstack/skills/statechart/scripts/frontends/config.mjs +268 -0
  127. package/dist/pstack/skills/statechart/scripts/frontends/dot.mjs +67 -0
  128. package/dist/pstack/skills/statechart/scripts/frontends/marks.mjs +94 -0
  129. package/dist/pstack/skills/statechart/scripts/frontends/messages.mjs +48 -0
  130. package/dist/pstack/skills/statechart/scripts/frontends/spec.mjs +101 -0
  131. package/dist/pstack/skills/statechart/scripts/frontends/trace.mjs +39 -0
  132. package/dist/pstack/skills/statechart/scripts/frontends/value.mjs +180 -0
  133. package/dist/pstack/skills/statechart/scripts/frontends/verdict.mjs +40 -0
  134. package/dist/pstack/skills/statechart/scripts/frontends/view.mjs +99 -0
  135. package/dist/pstack/skills/statechart/scripts/ir.mjs +277 -0
  136. package/dist/pstack/skills/statechart/scripts/passes/annotate.mjs +92 -0
  137. package/dist/pstack/skills/statechart/scripts/passes/label.mjs +210 -0
  138. package/dist/pstack/skills/statechart/scripts/passes/lift.mjs +84 -0
  139. package/dist/pstack/skills/statechart/scripts/passes/loop-check.mjs +47 -0
  140. package/dist/pstack/skills/statechart/scripts/passes/paths.mjs +72 -0
  141. package/dist/pstack/skills/statechart/scripts/passes/reach.mjs +135 -0
  142. package/dist/pstack/skills/statechart/scripts/passes/region-check.mjs +82 -0
  143. package/dist/pstack/skills/statechart/scripts/passes/regions.mjs +268 -0
  144. package/dist/pstack/skills/statechart/scripts/pipeline.mjs +72 -0
  145. package/dist/pstack/skills/statechart/scripts/run.mjs +440 -0
  146. package/dist/pstack/skills/statechart/scripts/statechart.mjs +155 -0
  147. package/dist/pstack/skills/statechart/scripts/statechart.test.mjs +198 -0
  148. package/dist/pstack/skills/statechart/scripts/worker.mjs +31 -0
  149. package/dist/pstack/skills/swarm/SKILL.md +43 -0
  150. package/{assets → dist/pstack}/skills/tdd/SKILL.md +1 -1
  151. package/{assets → dist/pstack}/skills/teach/SKILL.md +2 -2
  152. package/{assets → dist/pstack}/skills/technical-writing/SKILL.md +1 -1
  153. package/{assets → dist/pstack}/skills/typescript-best-practices/SKILL.md +3 -6
  154. package/{assets → dist/pstack}/skills/why/SKILL.md +8 -8
  155. package/dist/remote.d.mts +27 -0
  156. package/dist/remote.mjs +234 -0
  157. package/dist/role-config-NNn5r1JX.mjs +415 -0
  158. package/dist/role-manifest-C3fUzjLI.d.mts +19 -0
  159. package/dist/role-wire-DZwTn2wF.d.mts +55 -0
  160. package/dist/roles.d.mts +18 -0
  161. package/dist/roles.mjs +323 -0
  162. package/dist/script.d.mts +9 -111
  163. package/dist/script.mjs +32 -329
  164. package/dist/skill.d.mts +38 -0
  165. package/dist/skill.mjs +183 -0
  166. package/dist/skills/authored/decision-audit/SKILL.md +103 -0
  167. package/dist/skills/authored/decision-audit/SKILL.zh.md +103 -0
  168. package/dist/skills/authored/decision-audit/references/recover-commit.md +17 -0
  169. package/dist/skills/authored/decision-audit/references/recover-commit.zh.md +17 -0
  170. package/dist/skills/authored/decision-write/SKILL.md +133 -0
  171. package/dist/skills/authored/decision-write/SKILL.zh.md +133 -0
  172. package/dist/skills/authored/decision-write/references/land.md +48 -0
  173. package/dist/skills/authored/decision-write/references/land.zh.md +48 -0
  174. package/dist/skills/authored/decision-write/references/scope.md +16 -0
  175. package/dist/skills/authored/decision-write/references/scope.zh.md +16 -0
  176. package/dist/skills/authored/docs-drift/SKILL.md +120 -0
  177. package/dist/skills/authored/docs-drift/SKILL.zh.md +120 -0
  178. package/dist/skills/authored/setup-project-docs/SKILL.md +63 -0
  179. package/dist/skills/authored/setup-project-docs/SKILL.zh.md +63 -0
  180. package/dist/skills/authored/setup-project-docs/references/decision-conventions.md +13 -0
  181. package/dist/skills/authored/setup-project-docs/references/decision-conventions.zh.md +13 -0
  182. package/dist/skills/vendored/retro/SKILL.md +44 -0
  183. package/dist/skills/vendored/retro/agents/openai.yaml +5 -0
  184. package/dist/skills/vendored/writing-for-agents/SKILL-MECHANICS.md +22 -0
  185. package/dist/skills/vendored/writing-for-agents/SKILL.md +81 -0
  186. package/dist/skills/vendored/writing-for-agents/agents/openai.yaml +3 -0
  187. package/dist/subagent.d.mts +54 -206
  188. package/dist/subagent.mjs +258 -963
  189. package/locale/en.json +3 -2
  190. package/locale/zh.json +3 -2
  191. package/package.json +93 -66
  192. package/assets/agents/poteto-agent.md +0 -8
  193. package/assets/docs/harness/dsh.md +0 -60
  194. package/assets/docs/pstack-models.example.md +0 -54
  195. package/assets/skills/arena/SKILL.md +0 -50
  196. package/assets/skills/figure-it-out/SKILL.md +0 -54
  197. package/assets/skills/how/SKILL.md +0 -38
  198. package/assets/skills/interrogate/SKILL.md +0 -71
  199. package/assets/skills/interrogate/references/code-quality-review.md +0 -47
  200. package/assets/skills/interrogate/references/lead-judgment.md +0 -39
  201. package/assets/skills/interrogate/references/reviewer-prompt.md +0 -62
  202. package/assets/skills/interrogate/references/rubric.md +0 -77
  203. package/assets/skills/no-comments/SKILL.md +0 -26
  204. package/assets/skills/poteto-mode/playbooks/authoring-a-skill.md +0 -12
  205. package/assets/skills/poteto-mode/playbooks/autonomous-run.md +0 -15
  206. package/assets/skills/poteto-mode/playbooks/autopilot-full.md +0 -25
  207. package/assets/skills/poteto-mode/playbooks/autopilot-stack.md +0 -12
  208. package/assets/skills/poteto-mode/playbooks/bug-fix.md +0 -15
  209. package/assets/skills/poteto-mode/playbooks/feature.md +0 -21
  210. package/assets/skills/poteto-mode/playbooks/orchestrate.md +0 -112
  211. package/assets/skills/poteto-mode/playbooks/perf-issue.md +0 -25
  212. package/assets/skills/poteto-mode/playbooks/refactoring.md +0 -16
  213. package/assets/skills/poteto-mode/playbooks/runtime-forensics.md +0 -11
  214. package/assets/skills/poteto-mode/playbooks/session-pickup.md +0 -11
  215. package/assets/skills/poteto-mode/playbooks/visual-parity.md +0 -11
  216. package/assets/skills/poteto-mode/playbooks/worktree-cleanup.md +0 -20
  217. package/assets/skills/poteto-mode/scripts/orch/orch.mjs +0 -4282
  218. package/assets/skills/poteto-mode/scripts/orch/orch.test.mjs +0 -2042
  219. package/assets/skills/poteto-mode/scripts/watch-pr/cli.test.mjs +0 -5101
  220. package/assets/skills/poteto-mode/scripts/watch-pr/github.test.mjs +0 -1177
  221. package/assets/skills/poteto-mode/scripts/watch-pr/policy.test.mjs +0 -1441
  222. package/assets/skills/poteto-mode/scripts/watch-pr/watch-pr.mjs +0 -4601
  223. package/assets/skills/recall/SKILL.md +0 -37
  224. package/assets/skills/reflect/SKILL.md +0 -69
  225. package/assets/skills/setup-pstack/SKILL.md +0 -67
  226. package/assets/skills/swarm/SKILL.md +0 -43
  227. package/dist/frontmatter-BQX3ekwP.mjs +0 -229
  228. package/dist/frontmatter-BQX3ekwP.mjs.map +0 -1
  229. package/dist/history.d.mts +0 -429
  230. package/dist/history.mjs +0 -1129
  231. package/dist/history.mjs.map +0 -1
  232. package/dist/host-contract-o47JH_r8.d.mts +0 -527
  233. package/dist/index.mjs.map +0 -1
  234. package/dist/paths-D_JlVmBk.mjs +0 -42
  235. package/dist/paths-D_JlVmBk.mjs.map +0 -1
  236. package/dist/script.mjs.map +0 -1
  237. package/dist/subagent.mjs.map +0 -1
  238. /package/{static/icon.png → assets/logo.png} +0 -0
  239. /package/{assets → dist/pstack}/agents/comment-sicko.md +0 -0
  240. /package/{assets → dist/pstack}/docs/guide/03-understand.md +0 -0
  241. /package/{assets → dist/pstack}/docs/guide/08-principles.md +0 -0
  242. /package/{assets → dist/pstack}/docs/guide/images/design.jpg +0 -0
  243. /package/{assets → dist/pstack}/docs/guide/images/overnight.jpg +0 -0
  244. /package/{assets → dist/pstack}/docs/guide/images/recipes.jpg +0 -0
  245. /package/{assets → dist/pstack}/docs/guide/images/router.jpg +0 -0
  246. /package/{assets → dist/pstack}/docs/guide/images/understanding.jpg +0 -0
  247. /package/{assets → dist/pstack}/docs/guide/images/verification.jpg +0 -0
  248. /package/{assets → dist/pstack}/skills/architect/references/design-red-flags.md +0 -0
  249. /package/{assets → dist/pstack}/skills/architect/references/rationale-template.md +0 -0
  250. /package/{assets → dist/pstack}/skills/architect/references/runner-prompt.md +0 -0
  251. /package/{assets → dist/pstack}/skills/bro/SKILL.md +0 -0
  252. /package/{assets → dist/pstack}/skills/create-verification-skill/references/feature-map-example/README.md +0 -0
  253. /package/{assets → dist/pstack}/skills/create-verification-skill/references/feature-map-example/create-note.md +0 -0
  254. /package/{assets → dist/pstack}/skills/create-verification-skill/references/feature-map-example/search.md +0 -0
  255. /package/{assets → dist/pstack}/skills/how/references/explainer-prompt.md +0 -0
  256. /package/{assets → dist/pstack}/skills/how/references/explorer-prompt.md +0 -0
  257. /package/{assets → dist/pstack}/skills/poteto-mode/references/bugbot-triage.md +0 -0
  258. /package/{assets → dist/pstack}/skills/principle-build-the-lever/SKILL.md +0 -0
  259. /package/{assets → dist/pstack}/skills/principle-foundational-thinking/SKILL.md +0 -0
  260. /package/{assets → dist/pstack}/skills/principle-guard-the-context-window/SKILL.md +0 -0
  261. /package/{assets → dist/pstack}/skills/show-me-your-work/references/decision-log-template.tsv +0 -0
  262. /package/{assets → dist/pstack}/skills/typescript-best-practices/references/patterns.md +0 -0
  263. /package/{assets → dist/pstack}/skills/unslop/SKILL.md +0 -0
  264. /package/{assets → dist/pstack}/skills/why/references/epistemics.md +0 -0
  265. /package/{assets → dist/pstack}/skills/why/references/investigator-prompt.md +0 -0
  266. /package/{assets → dist/pstack}/skills/why/references/source-playbook.md +0 -0
  267. /package/{assets → dist/pstack}/skills/why/references/sources/code-archaeology.md +0 -0
  268. /package/{assets → dist/pstack}/skills/why/references/sources/databricks.md +0 -0
  269. /package/{assets → dist/pstack}/skills/why/references/sources/datadog.md +0 -0
  270. /package/{assets → dist/pstack}/skills/why/references/sources/incident-postmortem.md +0 -0
  271. /package/{assets → dist/pstack}/skills/why/references/sources/linear.md +0 -0
  272. /package/{assets → dist/pstack}/skills/why/references/sources/notion.md +0 -0
  273. /package/{assets → dist/pstack}/skills/why/references/sources/sentry.md +0 -0
  274. /package/{assets → dist/pstack}/skills/why/references/sources/slack.md +0 -0
  275. /package/{assets → dist/pstack}/skills/why/references/synthesizer-prompt.md +0 -0
@@ -0,0 +1,94 @@
1
+ import { EC, memo } from "../ir.mjs";
2
+ import { BRACKET, isSpace, parseValue, tokenEnd, unreadable } from "./value.mjs";
3
+ import { actionOf, messageState } from "./messages.mjs";
4
+ // runtime/skills/statechart/scripts/frontends/marks.ts
5
+ const markTexts = (chunk, top, inner) => {
6
+ if (top.length !== 2) return void 0;
7
+ const [a, b] = top;
8
+ const open = chunk.indexOf("<<", a);
9
+ const close = chunk.lastIndexOf(">>", b);
10
+ const end = chunk.trimEnd().length - 2;
11
+ if (open < 0 || chunk.slice(a + 1, open).trim() || chunk.slice(close + 2, b).trim()) return void 0;
12
+ if (!chunk.startsWith(">>", end)) return void 0;
13
+ const cuts = [open + 1];
14
+ for (const k of inner) if (k > open && k < close) cuts.push(k);
15
+ cuts.push(close);
16
+ const texts = [];
17
+ for (let k = 1; k < cuts.length; k++) texts.push(chunk.slice(cuts[k - 1] + 1, cuts[k]));
18
+ return {
19
+ values: texts,
20
+ rules: chunk.slice(b + 1, end)
21
+ };
22
+ };
23
+ const ruleNames = (v) => {
24
+ if (typeof v !== "object" || v.kind !== "set") return void 0;
25
+ const names = [];
26
+ for (const m of v.members) {
27
+ if (typeof m !== "string") return void 0;
28
+ names.push(m);
29
+ }
30
+ return names;
31
+ };
32
+ function* readMarks(messages, tag) {
33
+ const read = memo(parseValue);
34
+ const start = `"${tag}",`;
35
+ let chunk = "";
36
+ let depth = 0;
37
+ let top = [];
38
+ let inner = [];
39
+ for (const line of messages) {
40
+ if (typeof line !== "string") continue;
41
+ if (!chunk) {
42
+ if (!line.startsWith("<<") || !line.slice(2).trimStart().startsWith(start)) continue;
43
+ depth = 0;
44
+ top = [];
45
+ inner = [];
46
+ }
47
+ const base = chunk.length;
48
+ chunk += line + "\n";
49
+ let i = 0;
50
+ let last = 0;
51
+ while (i < line.length) {
52
+ const c = line.charCodeAt(i);
53
+ if (isSpace(c)) {
54
+ i++;
55
+ continue;
56
+ }
57
+ const j = tokenEnd(line, i);
58
+ if (j === -1) throw unreadable(line + "\n", last);
59
+ if (c === 44 && depth === 1) top.push(base + i);
60
+ else if (c === 44 && depth === 2) inner.push(base + i);
61
+ depth += BRACKET[c];
62
+ i = last = j;
63
+ }
64
+ if (depth > 0) continue;
65
+ const texts = markTexts(chunk, top, inner);
66
+ const values = [];
67
+ if (texts) for (const v of texts.values) values.push(read(v));
68
+ const broken = texts && ruleNames(read(texts.rules));
69
+ if (!broken) throw new Error(`TLC printed a mark that the command cannot read:\n${chunk.slice(0, 2e3)}`);
70
+ chunk = "";
71
+ yield {
72
+ values,
73
+ broken
74
+ };
75
+ }
76
+ if (chunk) throw new Error(`TLC's output ends inside a marked state, so the command cannot tell which rules it breaks:\n${chunk.slice(0, 2e3)}`);
77
+ }
78
+ function readCounterexample(messages) {
79
+ const trace = [];
80
+ for (const m of messages) {
81
+ if (typeof m === "string") continue;
82
+ const action = m.code === EC.TLC_STATE_PRINT2 ? actionOf(m) : void 0;
83
+ if (action !== void 0) trace.push({
84
+ action,
85
+ vars: messageState(m)
86
+ });
87
+ else if (m.code === EC.TLC_INVARIANT_VIOLATED_INITIAL || m.code === EC.TLC_PROPERTY_VIOLATED_INITIAL) trace.push({
88
+ action: "",
89
+ vars: messageState(m)
90
+ });
91
+ }
92
+ return trace;
93
+ }
94
+ export { readCounterexample, readMarks };
@@ -0,0 +1,48 @@
1
+ import { linesOf, parseState } from "./dot.mjs";
2
+ // runtime/skills/statechart/scripts/frontends/messages.ts
3
+ const START = /@!@!@STARTMSG (\d+):(\d+) @!@!@$/;
4
+ const END = /^@!@!@ENDMSG \d+ @!@!@$/;
5
+ const isCutMarker = (lastLine) => lastLine.startsWith("@!@!@");
6
+ function cutMessage(open) {
7
+ for (let i = open.length - 1; i > 0 && !open[i].body.length; i--) open[i - 1].body.pop();
8
+ return open[0]?.body.length ? open[0] : void 0;
9
+ }
10
+ function* readMessages(tlcOut) {
11
+ const lines = linesOf(tlcOut)[Symbol.iterator]();
12
+ const open = [];
13
+ try {
14
+ for (let next = lines.next(); !next.done;) {
15
+ const line = next.value;
16
+ next = lines.next();
17
+ if (next.done && (!line || isCutMarker(line))) break;
18
+ const start = START.exec(line);
19
+ if (start) {
20
+ const message = {
21
+ code: Number(start[1]),
22
+ level: Number(start[2]),
23
+ body: []
24
+ };
25
+ if (start.index) message.beforeMarker = line.slice(0, start.index);
26
+ open.at(-1)?.body.push(message);
27
+ open.push(message);
28
+ } else if (END.test(line)) {
29
+ const done = open.pop();
30
+ if (done && !open.length) yield done;
31
+ } else if (open.length) open[open.length - 1].body.push(line);
32
+ else yield line;
33
+ }
34
+ } finally {
35
+ lines.return?.();
36
+ }
37
+ const cut = cutMessage(open);
38
+ if (cut) yield cut;
39
+ }
40
+ const textOf = ({ body }) => body.filter((part) => typeof part === "string").join("\n");
41
+ const actionOf = (m) => /^\d+: (?:Back to state: )?<([^\s>]+)/.exec(textOf(m))?.[1];
42
+ const messageState = (m) => {
43
+ const lines = textOf(m).split("\n");
44
+ const body = [];
45
+ for (let i = 1; i < lines.length && lines[i].trim(); i++) body.push(lines[i]);
46
+ return parseState(body.join("\n"));
47
+ };
48
+ export { actionOf, messageState, readMessages, textOf };
@@ -0,0 +1,101 @@
1
+ import { NAME } from "./config.mjs";
2
+ // runtime/skills/statechart/scripts/frontends/spec.ts
3
+ function readChecks({ configFile, config }) {
4
+ const refuse = (words) => /* @__PURE__ */ new Error(`TLC refuses the config ${configFile}. ${words}`);
5
+ if (config.spec && (config.init || config.next)) throw refuse("The configuration file cannot specify both INIT/NEXT and SPECIFICATION fields.");
6
+ if (!config.spec && !config.init) throw refuse("The configuration file did not specify the initial state predicate.");
7
+ const written = [];
8
+ for (const s of config.sections) if (![
9
+ "INVARIANT",
10
+ "PROPERTY",
11
+ "CHECK_DEADLOCK"
12
+ ].includes(s.key)) written.push(s);
13
+ return {
14
+ invariants: config.invariants,
15
+ properties: config.properties,
16
+ deadlock: config.checkDeadlock !== false,
17
+ written
18
+ };
19
+ }
20
+ const ENTITIES = {
21
+ amp: "&",
22
+ apos: "'",
23
+ gt: ">",
24
+ lt: "<",
25
+ quot: "\""
26
+ };
27
+ const decode = (text) => text.replace(/&(#x?)?(\w+);/g, (_, number, name) => number ? String.fromCodePoint(Number.parseInt(name, number === "#x" ? 16 : 10)) : ENTITIES[name]);
28
+ function parseXml(xml) {
29
+ const document = {
30
+ tag: "",
31
+ text: "",
32
+ children: []
33
+ };
34
+ const open = [document];
35
+ for (const [, close, tag, empty, text] of xml.matchAll(/<(\/?)([^\s/>?!]+)[^>]*?(\/?)>|<[?!][^>]*>|([^<]+)/g)) {
36
+ const parent = open[open.length - 1];
37
+ if (text !== void 0) parent.text += decode(text);
38
+ else if (close) open.pop();
39
+ else if (tag) {
40
+ const node = {
41
+ tag,
42
+ text: "",
43
+ children: []
44
+ };
45
+ parent.children.push(node);
46
+ if (!empty) open.push(node);
47
+ }
48
+ }
49
+ return document;
50
+ }
51
+ const child = (node, tag) => node?.children.find((c) => c.tag === tag);
52
+ const textOf = (node, tag) => child(node, tag)?.text ?? "";
53
+ const VARIABLE_KIND = "3";
54
+ function readSany(xml) {
55
+ const modules = child(parseXml(xml), "modules");
56
+ const symbols = /* @__PURE__ */ new Map();
57
+ for (const entry of child(modules, "context")?.children ?? []) symbols.set(textOf(entry, "UID"), entry.children[1]);
58
+ const root = textOf(modules, "RootModule");
59
+ let module;
60
+ for (const node of symbols.values()) if (node.tag === "ModuleNode" && textOf(node, "uniquename") === root) module = node;
61
+ const definitions = /* @__PURE__ */ new Map();
62
+ const variables = [];
63
+ for (const ref of module?.children ?? []) {
64
+ if (ref.tag !== "OpDeclNodeRef" && ref.tag !== "UserDefinedOpKindRef") continue;
65
+ const uid = textOf(ref, "UID");
66
+ const node = symbols.get(uid);
67
+ if (!node) continue;
68
+ const name = textOf(node, "uniquename");
69
+ definitions.set(name, node);
70
+ if (node.tag === "OpDeclNode" && textOf(node, "kind") === VARIABLE_KIND) variables.push({
71
+ uid: Number(uid),
72
+ name
73
+ });
74
+ }
75
+ variables.sort((a, b) => a.uid - b.uid);
76
+ return {
77
+ variables: variables.map((v) => v.name),
78
+ definitions
79
+ };
80
+ }
81
+ function readSpec({ module, sany, checks }) {
82
+ return {
83
+ module,
84
+ variables: sany.variables,
85
+ ...checks
86
+ };
87
+ }
88
+ const STATE_LEVEL = 1;
89
+ function initialOnlyProperties({ definitions }, { written, properties }) {
90
+ const replaced = /* @__PURE__ */ new Map();
91
+ for (const s of written) if (s.key === "CONSTANT") {
92
+ for (let i = 1; i + 1 < s.tokens.length; i++) if (s.tokens[i] === "<-" && NAME.test(s.tokens[i + 1])) replaced.set(s.tokens[i - 1], s.tokens[i + 1]);
93
+ }
94
+ const names = /* @__PURE__ */ new Set();
95
+ for (const name of properties) {
96
+ const definition = definitions.get(replaced.get(name) ?? name);
97
+ if (definition && Number(textOf(definition, "level")) <= STATE_LEVEL) names.add(name);
98
+ }
99
+ return names;
100
+ }
101
+ export { initialOnlyProperties, readChecks, readSany, readSpec };
@@ -0,0 +1,39 @@
1
+ import { EC } from "../ir.mjs";
2
+ import { actionOf, messageState, textOf } from "./messages.mjs";
3
+ // runtime/skills/statechart/scripts/frontends/trace.ts
4
+ function readTrace(messages) {
5
+ const seq = [];
6
+ for (const m of messages) {
7
+ if (typeof m === "string") continue;
8
+ if (m.code === EC.TLC_STATE_PRINT3) return {
9
+ seq,
10
+ loop: seq.length - 1
11
+ };
12
+ const back = m.code === EC.TLC_BACK_TO_STATE && /^(\d+): Back to state: /.exec(textOf(m));
13
+ if (back) {
14
+ const loop = Number(back[1]) - 1;
15
+ seq.push({
16
+ action: actionOf(m) ?? "",
17
+ vars: seq[loop]?.vars
18
+ });
19
+ return {
20
+ seq,
21
+ loop
22
+ };
23
+ }
24
+ const action = m.code === EC.TLC_STATE_PRINT2 ? actionOf(m) : void 0;
25
+ if (action !== void 0) seq.push({
26
+ action,
27
+ vars: messageState(m)
28
+ });
29
+ else if (m.code === EC.TLC_INVARIANT_VIOLATED_INITIAL || m.code === EC.TLC_PROPERTY_VIOLATED_INITIAL) seq.push({
30
+ action: "",
31
+ vars: messageState(m)
32
+ });
33
+ }
34
+ return {
35
+ seq,
36
+ loop: void 0
37
+ };
38
+ }
39
+ export { readTrace };
@@ -0,0 +1,180 @@
1
+ // runtime/skills/statechart/scripts/frontends/value.ts
2
+ const BRACKET = /* @__PURE__ */ new Int8Array(128);
3
+ for (const c of "<{[(") BRACKET[c.charCodeAt(0)] = 1;
4
+ for (const c of ">}])") BRACKET[c.charCodeAt(0)] = -1;
5
+ const PUNCT = /* @__PURE__ */ new Map([
6
+ [60, "<<"],
7
+ [62, ">>"],
8
+ [124, "|->"],
9
+ [58, ":>"],
10
+ [64, "@@"],
11
+ [46, ".."]
12
+ ]);
13
+ const SPACE = /\s/;
14
+ const isSpace = (c) => c === 32 || c >= 9 && c <= 13 || c > 127 && SPACE.test(String.fromCharCode(c));
15
+ const isDigit = (c) => c >= 48 && c <= 57;
16
+ const isWord = (c) => isDigit(c) || c >= 65 && c <= 90 || c >= 97 && c <= 122 || c === 95;
17
+ const isLineEnd = (c) => c === 10 || c === 13 || c === 8232 || c === 8233;
18
+ const tokenEnd = (s, i) => {
19
+ const c = s.charCodeAt(i);
20
+ if (c === 34) {
21
+ for (let j = i + 1; j < s.length; j++) {
22
+ const d = s.charCodeAt(j);
23
+ if (d === 34) return j + 1;
24
+ if (d === 92 && (++j >= s.length || isLineEnd(s.charCodeAt(j)))) return -1;
25
+ }
26
+ return -1;
27
+ }
28
+ const punct = PUNCT.get(c);
29
+ if (punct) return s.startsWith(punct, i) ? i + punct.length : -1;
30
+ if (BRACKET[c] || c === 44) return i + 1;
31
+ let j = i + 1;
32
+ if (c === 45 || isDigit(c)) {
33
+ while (isDigit(s.charCodeAt(j))) j++;
34
+ return c === 45 && j === i + 1 ? -1 : j;
35
+ }
36
+ if (!isWord(c)) return -1;
37
+ while (isWord(s.charCodeAt(j))) j++;
38
+ return j;
39
+ };
40
+ const unreadable = (text, pos) => /* @__PURE__ */ new Error(`cannot read TLA+ value at "${text.slice(pos, pos + 20)}"`);
41
+ const INT = /^-?\d+$/;
42
+ const NAME = /^\w*[A-Za-z]\w*$/;
43
+ const UNESCAPED = {
44
+ "\"": "\"",
45
+ "\\": "\\",
46
+ n: "\n",
47
+ t: " ",
48
+ r: "\r",
49
+ f: "\f"
50
+ };
51
+ const models = /* @__PURE__ */ new Map();
52
+ const model = (name) => {
53
+ let v = models.get(name);
54
+ if (v === void 0) models.set(name, v = {
55
+ kind: "model",
56
+ name
57
+ });
58
+ return v;
59
+ };
60
+ function parseValue(text) {
61
+ const tokens = [];
62
+ const starts = [];
63
+ for (let pos = 0;;) {
64
+ while (pos < text.length && isSpace(text.charCodeAt(pos))) pos++;
65
+ if (pos === text.length) break;
66
+ const end = tokenEnd(text, pos);
67
+ if (end === -1) throw unreadable(text, pos);
68
+ tokens.push(text.slice(pos, end));
69
+ starts.push(pos);
70
+ pos = end;
71
+ }
72
+ let i = 0;
73
+ const fail = () => {
74
+ throw unreadable(text, i < starts.length ? starts[Math.max(i - 1, 0)] : text.length);
75
+ };
76
+ const next = () => i < tokens.length ? tokens[i++] : fail();
77
+ const eat = (t) => {
78
+ if (next() !== t) fail();
79
+ };
80
+ const items = (close, item) => {
81
+ const out = [];
82
+ if (tokens[i] === close) {
83
+ i++;
84
+ return out;
85
+ }
86
+ for (;;) {
87
+ out.push(item());
88
+ const t = next();
89
+ if (t === close) return out;
90
+ if (t !== ",") fail();
91
+ }
92
+ };
93
+ const string = (t) => {
94
+ let s = "";
95
+ for (let j = 1, from = 1;;) {
96
+ const k = t.indexOf("\\", j);
97
+ if (k === -1 || k >= t.length - 1) return s + t.slice(from, -1);
98
+ const c = UNESCAPED[t[k + 1]];
99
+ if (c === void 0) fail();
100
+ s += t.slice(from, k) + c;
101
+ j = from = k + 2;
102
+ }
103
+ };
104
+ const value = () => {
105
+ const t = next();
106
+ switch (t) {
107
+ case "TRUE": return true;
108
+ case "FALSE": return false;
109
+ case "{": return {
110
+ kind: "set",
111
+ members: items("}", value)
112
+ };
113
+ case "<<": {
114
+ const values = items(">>", value);
115
+ const keys = [];
116
+ for (let k = 1; k <= values.length; k++) keys.push(k);
117
+ return {
118
+ kind: "function",
119
+ printedAs: "tuple",
120
+ keys,
121
+ values
122
+ };
123
+ }
124
+ case "[": {
125
+ const keys = [];
126
+ const values = [];
127
+ items("]", () => {
128
+ const name = next();
129
+ if (!NAME.test(name)) fail();
130
+ eat("|->");
131
+ keys.push(name);
132
+ values.push(value());
133
+ });
134
+ return {
135
+ kind: "function",
136
+ printedAs: "record",
137
+ keys,
138
+ values
139
+ };
140
+ }
141
+ case "(": {
142
+ const keys = [];
143
+ const values = [];
144
+ do {
145
+ keys.push(value());
146
+ eat(":>");
147
+ values.push(value());
148
+ } while (next() === "@@");
149
+ if (tokens[i - 1] !== ")") fail();
150
+ return {
151
+ kind: "function",
152
+ printedAs: "pairs",
153
+ keys,
154
+ values
155
+ };
156
+ }
157
+ }
158
+ if (t.charCodeAt(0) === 34) return string(t);
159
+ if (INT.test(t)) {
160
+ if (tokens[i] !== "..") return Number(t);
161
+ i++;
162
+ const hi = next();
163
+ if (!INT.test(hi)) fail();
164
+ return {
165
+ kind: "interval",
166
+ lo: Number(t),
167
+ hi: Number(hi)
168
+ };
169
+ }
170
+ if (NAME.test(t)) return model(t);
171
+ return fail();
172
+ };
173
+ const out = value();
174
+ if (i < tokens.length) {
175
+ i++;
176
+ fail();
177
+ }
178
+ return out;
179
+ }
180
+ export { BRACKET, isSpace, parseValue, tokenEnd, unreadable };
@@ -0,0 +1,40 @@
1
+ import { EC } from "../ir.mjs";
2
+ import { textOf } from "./messages.mjs";
3
+ // runtime/skills/statechart/scripts/frontends/verdict.ts
4
+ const NAMED = /* @__PURE__ */ new Map([
5
+ [EC.TLC_INVARIANT_VIOLATED_INITIAL, ["invariant", /^Invariant (.+) is violated by the initial/]],
6
+ [EC.TLC_INVARIANT_VIOLATED_BEHAVIOR, ["invariant", /^Invariant (.+) is violated\.$/m]],
7
+ [EC.TLC_PROPERTY_VIOLATED_INITIAL, ["property", /^Property (.+) is violated by the initial/]],
8
+ [EC.TLC_ACTION_PROPERTY_VIOLATED_BEHAVIOR, ["property", /^Action property (.+) is violated\.$/m]]
9
+ ]);
10
+ const DISTINCT = /* @__PURE__ */ new Map([
11
+ [EC.TLC_INIT_GENERATED1, /(\d+) distinct states? generated/],
12
+ [EC.TLC_INIT_GENERATED2, /with (\d+) of them distinct/],
13
+ [EC.TLC_STATS, /(\d+) distinct states found/]
14
+ ]);
15
+ function readVerdict(messages) {
16
+ let broke;
17
+ let distinct = 0;
18
+ let initial = 0;
19
+ for (const m of messages) {
20
+ if (typeof m === "string") continue;
21
+ const count = DISTINCT.get(m.code)?.exec(textOf(m));
22
+ if (count) distinct = Math.max(distinct, Number(count[1]));
23
+ if (m.code === EC.TLC_INIT_GENERATED1 || m.code === EC.TLC_INIT_GENERATED2) initial = Number(/(\d+) (?:distinct )?states? generated/.exec(textOf(m))?.[1] ?? 0);
24
+ if (broke) continue;
25
+ if (m.code === EC.TLC_DEADLOCK_REACHED) broke = { kind: "deadlock" };
26
+ else if (m.code === EC.TLC_TEMPORAL_PROPERTY_VIOLATED) broke = { kind: "temporal" };
27
+ const named = NAMED.get(m.code);
28
+ const name = named?.[1].exec(textOf(m))?.[1];
29
+ if (named && name) broke = {
30
+ kind: named[0],
31
+ name
32
+ };
33
+ }
34
+ return {
35
+ broke,
36
+ distinct,
37
+ initial
38
+ };
39
+ }
40
+ export { readVerdict };
@@ -0,0 +1,99 @@
1
+ import { checked, list } from "../ir.mjs";
2
+ // runtime/skills/statechart/scripts/frontends/view.ts
3
+ const projected = /* @__PURE__ */ new WeakMap();
4
+ const json = (v) => {
5
+ if (typeof v !== "object") return v;
6
+ if (v.kind === "model") return v.name;
7
+ let j = projected.get(v);
8
+ if (j === void 0) {
9
+ if (v.kind === "interval") {
10
+ const members = [];
11
+ for (let k = v.lo; k <= v.hi; k++) members.push(k);
12
+ j = members;
13
+ } else if (v.kind === "set") {
14
+ const members = [];
15
+ for (const m of v.members) members.push(json(m));
16
+ j = members;
17
+ } else {
18
+ const fields = [];
19
+ for (let i = 0; i < v.keys.length; i++) {
20
+ const k = json(v.keys[i]);
21
+ fields.push([typeof k === "object" ? JSON.stringify(k) : String(k), json(v.values[i])]);
22
+ }
23
+ j = Object.fromEntries(fields);
24
+ }
25
+ projected.set(v, j);
26
+ }
27
+ return j;
28
+ };
29
+ const projectedVars = /* @__PURE__ */ new WeakMap();
30
+ const jsonVars = (vars) => {
31
+ let j = projectedVars.get(vars);
32
+ if (j === void 0) {
33
+ const fields = [];
34
+ for (const [name, v] of Object.entries(vars)) fields.push([name, json(v)]);
35
+ j = Object.fromEntries(fields);
36
+ projectedVars.set(vars, j);
37
+ }
38
+ return j;
39
+ };
40
+ const THEME_COLORS = [
41
+ "blue",
42
+ "orange",
43
+ "purple",
44
+ "yellow",
45
+ "teal",
46
+ "tan",
47
+ "pink"
48
+ ];
49
+ const isFunction = (v) => typeof v === "function";
50
+ const isPlainObject = (v) => {
51
+ if (typeof v !== "object" || v === null) return false;
52
+ const proto = Object.getPrototypeOf(v);
53
+ return proto === Object.prototype || proto === null;
54
+ };
55
+ const isString = (v) => typeof v === "string";
56
+ const VIEW_EXPORTS = [
57
+ "state",
58
+ "step",
59
+ "group",
60
+ "colors",
61
+ "title"
62
+ ];
63
+ function checkView(view, inspect) {
64
+ const literal = (v) => typeof v === "string" ? JSON.stringify(v) : inspect(v, { breakLength: Infinity });
65
+ const extra = [];
66
+ for (const name of Object.keys(view)) if (!VIEW_EXPORTS.includes(name)) extra.push(name);
67
+ if (extra.length) throw new Error(`The view exports ${list(extra)}, which the command does not read. Export only ${list(VIEW_EXPORTS)}.`);
68
+ const wrong = [];
69
+ const pick = (name, kind, fits) => {
70
+ const v = view[name];
71
+ if (v === void 0 || fits(v)) return v;
72
+ wrong.push(`${name} must be ${kind}`);
73
+ };
74
+ const state = pick("state", "a function", isFunction);
75
+ const step = pick("step", "a function", isFunction);
76
+ const group = pick("group", "a function", isFunction);
77
+ const exported = pick("colors", "a plain object", isPlainObject);
78
+ const title = pick("title", "a string", isString);
79
+ if (wrong.length) throw new Error(`The view's ${list(wrong)}.`);
80
+ if (group !== void 0 && exported === void 0) throw new Error("The view exports group() but no colors. Give each group a color in colors.");
81
+ const colors = Object.create(null);
82
+ const bad = [];
83
+ for (const [name, color] of Object.entries(exported ?? {})) if (typeof color === "string" && THEME_COLORS.includes(color)) colors[name] = color;
84
+ else bad.push(`${JSON.stringify(name)} the color ${literal(color)}`);
85
+ if (bad.length) throw new Error(`The view's colors give ${list(bad)}. Give each group ${list(THEME_COLORS, "or")}.`);
86
+ return {
87
+ state: state && ((vars) => state(jsonVars(vars))),
88
+ step: step && ((action, from, to) => step(action, jsonVars(from), jsonVars(to))),
89
+ group: group && ((vars) => {
90
+ const g = group(jsonVars(vars));
91
+ if (g !== void 0 && !Object.hasOwn(colors, typeof g === "symbol" ? g : String(g))) throw new Error(`The view's group() returned ${literal(g)}, which colors does not name. Give each group a color in colors.`);
92
+ return g;
93
+ }),
94
+ colors,
95
+ title,
96
+ [checked]: true
97
+ };
98
+ }
99
+ export { checkView, json };