@justjoshn/pi-pstack-v2 0.0.0-stage → 0.1.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 (575) hide show
  1. package/LICENSE +22 -0
  2. package/README.md +48 -2
  3. package/agents/ci-watcher.md +26 -0
  4. package/agents/comment-sicko.md +32 -0
  5. package/agents/poteto-agent.md +8 -0
  6. package/agents/thermo-nuclear-code-quality-review.md +23 -0
  7. package/docs/guide/01-setup.md +81 -0
  8. package/docs/guide/02-poteto-mode.md +137 -0
  9. package/docs/guide/03-understand.md +79 -0
  10. package/docs/guide/04-design.md +133 -0
  11. package/docs/guide/05-build-and-clean.md +83 -0
  12. package/docs/guide/06-verify-and-ship.md +162 -0
  13. package/docs/guide/07-overnight.md +121 -0
  14. package/docs/guide/08-principles.md +72 -0
  15. package/docs/guide/09-make-it-yours.md +100 -0
  16. package/docs/guide/10-recipes-and-pitfalls.md +182 -0
  17. package/docs/guide/README.md +38 -0
  18. package/docs/guide/images/design.jpg +0 -0
  19. package/docs/guide/images/overnight.jpg +0 -0
  20. package/docs/guide/images/recipes.jpg +0 -0
  21. package/docs/guide/images/router.jpg +0 -0
  22. package/docs/guide/images/understanding.jpg +0 -0
  23. package/docs/guide/images/verification.jpg +0 -0
  24. package/docs/pi-mechanisms.md +100 -0
  25. package/package.json +49 -4
  26. package/rules/no-inline-imports.md +8 -0
  27. package/rules/typescript-exhaustive-switch.md +6 -0
  28. package/skills/architect/SKILL.md +81 -0
  29. package/skills/architect/references/design-red-flags.md +57 -0
  30. package/skills/architect/references/rationale-template.md +35 -0
  31. package/skills/architect/references/runner-prompt.md +20 -0
  32. package/skills/arena/SKILL.md +48 -0
  33. package/skills/automate-me/SKILL.md +104 -0
  34. package/skills/benchmark-checklist/SKILL.md +39 -0
  35. package/skills/blast-radius/SKILL.md +50 -0
  36. package/skills/bro/SKILL.md +7 -0
  37. package/skills/check-compiler-errors/SKILL.md +23 -0
  38. package/skills/control-cli/SKILL.md +110 -0
  39. package/skills/control-ui/SKILL.md +109 -0
  40. package/skills/correct/SKILL.md +32 -0
  41. package/skills/create-formal-verification-skill/SKILL.md +43 -0
  42. package/skills/create-verification-skill/SKILL.md +44 -0
  43. package/skills/create-verification-skill/references/feature-map-example/README.md +47 -0
  44. package/skills/create-verification-skill/references/feature-map-example/create-note.md +39 -0
  45. package/skills/create-verification-skill/references/feature-map-example/search.md +45 -0
  46. package/skills/deslop/SKILL.md +22 -0
  47. package/skills/figure-it-out/SKILL.md +54 -0
  48. package/skills/fix-ci/SKILL.md +29 -0
  49. package/skills/fix-merge-conflicts/SKILL.md +32 -0
  50. package/skills/get-pr-comments/SKILL.md +23 -0
  51. package/skills/how/SKILL.md +21 -0
  52. package/skills/in-your-own-words/SKILL.md +7 -0
  53. package/skills/interrogate/SKILL.md +35 -0
  54. package/skills/ketchup/SKILL.md +43 -0
  55. package/skills/ketchup-video/SKILL.md +29 -0
  56. package/skills/loop-on-ci/SKILL.md +50 -0
  57. package/skills/maintain-formal-verification-skill/SKILL.md +58 -0
  58. package/skills/maintain-verification-skill/SKILL.md +39 -0
  59. package/skills/make-bot-ui/SKILL.md +98 -0
  60. package/skills/make-pr-easy-to-review/SKILL.md +59 -0
  61. package/skills/new-branch-and-pr/SKILL.md +29 -0
  62. package/skills/no-comments/SKILL.md +26 -0
  63. package/skills/poteto-help/SKILL.md +159 -0
  64. package/skills/poteto-help/references/prompting.md +51 -0
  65. package/skills/poteto-help/references/recipes.md +51 -0
  66. package/skills/poteto-mode/SKILL.md +151 -0
  67. package/skills/poteto-mode/playbooks/authoring-a-skill.md +12 -0
  68. package/skills/poteto-mode/playbooks/autonomous-run.md +13 -0
  69. package/skills/poteto-mode/playbooks/autopilot-full.md +25 -0
  70. package/skills/poteto-mode/playbooks/autopilot-stack.md +8 -0
  71. package/skills/poteto-mode/playbooks/babysit.md +23 -0
  72. package/skills/poteto-mode/playbooks/bug-fix.md +15 -0
  73. package/skills/poteto-mode/playbooks/eval.md +25 -0
  74. package/skills/poteto-mode/playbooks/feature.md +21 -0
  75. package/skills/poteto-mode/playbooks/hillclimb.md +21 -0
  76. package/skills/poteto-mode/playbooks/investigation.md +14 -0
  77. package/skills/poteto-mode/playbooks/multi-phase-plan.md +155 -0
  78. package/skills/poteto-mode/playbooks/opening-a-pr.md +32 -0
  79. package/skills/poteto-mode/playbooks/orchestrate.md +25 -0
  80. package/skills/poteto-mode/playbooks/pause-safely.md +10 -0
  81. package/skills/poteto-mode/playbooks/perf-issue.md +25 -0
  82. package/skills/poteto-mode/playbooks/prototype.md +14 -0
  83. package/skills/poteto-mode/playbooks/refactoring.md +16 -0
  84. package/skills/poteto-mode/playbooks/runtime-forensics.md +11 -0
  85. package/skills/poteto-mode/playbooks/session-pickup.md +11 -0
  86. package/skills/poteto-mode/playbooks/shipping.md +12 -0
  87. package/skills/poteto-mode/playbooks/trace-forensics.md +14 -0
  88. package/skills/poteto-mode/playbooks/visual-parity.md +11 -0
  89. package/skills/poteto-mode/playbooks/worktree-cleanup.md +12 -0
  90. package/skills/poteto-mode/references/bugbot-triage.md +142 -0
  91. package/skills/poteto-mode/scripts/bootstrap.ts +62 -0
  92. package/skills/poteto-mode/scripts/bun.lock +67 -0
  93. package/skills/poteto-mode/scripts/check-plan.mjs +205 -0
  94. package/skills/poteto-mode/scripts/check-plan.test.ts +110 -0
  95. package/skills/poteto-mode/scripts/package.json +16 -0
  96. package/skills/poteto-mode/scripts/watch-pr/cli.test.ts +224 -0
  97. package/skills/poteto-mode/scripts/watch-pr/cli.ts +223 -0
  98. package/skills/poteto-mode/scripts/watch-pr/fakes.test-helper.ts +129 -0
  99. package/skills/poteto-mode/scripts/watch-pr/github.test.ts +498 -0
  100. package/skills/poteto-mode/scripts/watch-pr/github.ts +726 -0
  101. package/skills/poteto-mode/scripts/watch-pr/policy.test.ts +482 -0
  102. package/skills/poteto-mode/scripts/watch-pr/policy.ts +842 -0
  103. package/skills/poteto-mode/scripts/watch-pr/render.ts +169 -0
  104. package/skills/poteto-mode/scripts/watch-pr/tsconfig.json +13 -0
  105. package/skills/poteto-mode/scripts/watch-pr/types.compile.ts +93 -0
  106. package/skills/poteto-mode/scripts/watch-pr/types.ts +414 -0
  107. package/skills/poteto-mode/scripts/watch-pr/watch-pr +6 -0
  108. package/skills/poteto-mode/scripts/worktree-audit.sh +146 -0
  109. package/skills/pr-review-canvas/SKILL.md +170 -0
  110. package/skills/pr-review-canvas/renderer.js +170 -0
  111. package/skills/pr-review-canvas/styles.css +96 -0
  112. package/skills/pr-review-canvas/template.html +18 -0
  113. package/skills/principle-attack-the-premise/SKILL.md +21 -0
  114. package/skills/principle-boundary-discipline/SKILL.md +34 -0
  115. package/skills/principle-build-the-lever/SKILL.md +23 -0
  116. package/skills/principle-encode-lessons-in-structure/SKILL.md +11 -0
  117. package/skills/principle-exhaust-the-design-space/SKILL.md +9 -0
  118. package/skills/principle-experience-first/SKILL.md +19 -0
  119. package/skills/principle-explain-the-number/SKILL.md +18 -0
  120. package/skills/principle-fix-root-causes/SKILL.md +21 -0
  121. package/skills/principle-foundational-thinking/SKILL.md +21 -0
  122. package/skills/principle-guard-the-context-window/SKILL.md +12 -0
  123. package/skills/principle-laziness-protocol/SKILL.md +10 -0
  124. package/skills/principle-make-operations-idempotent/SKILL.md +22 -0
  125. package/skills/principle-migrate-callers-then-delete-legacy-apis/SKILL.md +14 -0
  126. package/skills/principle-minimize-reader-load/SKILL.md +18 -0
  127. package/skills/principle-model-the-domain/SKILL.md +24 -0
  128. package/skills/principle-never-block-on-the-human/SKILL.md +15 -0
  129. package/skills/principle-outcome-oriented-execution/SKILL.md +21 -0
  130. package/skills/principle-prove-it-works/SKILL.md +22 -0
  131. package/skills/principle-redesign-from-first-principles/SKILL.md +16 -0
  132. package/skills/principle-separate-before-serializing-shared-state/SKILL.md +16 -0
  133. package/skills/principle-sequence-verifiable-units/SKILL.md +17 -0
  134. package/skills/principle-subtract-before-you-add/SKILL.md +18 -0
  135. package/skills/principle-test-behavior-not-implementation/SKILL.md +20 -0
  136. package/skills/principle-type-system-discipline/SKILL.md +13 -0
  137. package/skills/recall/SKILL.md +37 -0
  138. package/skills/reflect/SKILL.md +69 -0
  139. package/skills/reflect/references/divergent-reviewer.md +38 -0
  140. package/skills/reflect/references/judgment-reviewer.md +37 -0
  141. package/skills/reflect/references/synthesizer.md +56 -0
  142. package/skills/reflect/references/tooling-reviewer.md +48 -0
  143. package/skills/review-and-ship/SKILL.md +41 -0
  144. package/skills/run-smoke-tests/SKILL.md +42 -0
  145. package/skills/setup-pstack/SKILL.md +79 -0
  146. package/skills/sharpen/SKILL.md +16 -0
  147. package/skills/show-me-your-work/SKILL.md +82 -0
  148. package/skills/show-me-your-work/references/decision-log-template.tsv +1 -0
  149. package/skills/show-me-your-work/scripts/log.sh +42 -0
  150. package/skills/statechart/SKILL.md +82 -0
  151. package/skills/statechart/references/render.md +93 -0
  152. package/skills/statechart/scripts/backends/cfg.ts +33 -0
  153. package/skills/statechart/scripts/backends/mermaid.ts +249 -0
  154. package/skills/statechart/scripts/backends/plain-text.ts +72 -0
  155. package/skills/statechart/scripts/backends/report.ts +177 -0
  156. package/skills/statechart/scripts/frontends/config.ts +276 -0
  157. package/skills/statechart/scripts/frontends/dot.ts +74 -0
  158. package/skills/statechart/scripts/frontends/marks.ts +93 -0
  159. package/skills/statechart/scripts/frontends/messages.ts +52 -0
  160. package/skills/statechart/scripts/frontends/spec.ts +114 -0
  161. package/skills/statechart/scripts/frontends/trace.ts +24 -0
  162. package/skills/statechart/scripts/frontends/value.ts +166 -0
  163. package/skills/statechart/scripts/frontends/verdict.ts +40 -0
  164. package/skills/statechart/scripts/frontends/view.ts +119 -0
  165. package/skills/statechart/scripts/ir.ts +547 -0
  166. package/skills/statechart/scripts/package.json +11 -0
  167. package/skills/statechart/scripts/passes/annotate.ts +128 -0
  168. package/skills/statechart/scripts/passes/label.ts +269 -0
  169. package/skills/statechart/scripts/passes/lift.ts +85 -0
  170. package/skills/statechart/scripts/passes/loop-check.ts +68 -0
  171. package/skills/statechart/scripts/passes/paths.ts +60 -0
  172. package/skills/statechart/scripts/passes/reach.ts +135 -0
  173. package/skills/statechart/scripts/passes/region-check.ts +97 -0
  174. package/skills/statechart/scripts/passes/regions.ts +295 -0
  175. package/skills/statechart/scripts/pipeline.ts +76 -0
  176. package/skills/statechart/scripts/run.ts +506 -0
  177. package/skills/statechart/scripts/statechart +29 -0
  178. package/skills/statechart/scripts/statechart.ts +164 -0
  179. package/skills/statechart/scripts/test/ConfigOracle.java +63 -0
  180. package/skills/statechart/scripts/test/chart.test.ts +1253 -0
  181. package/skills/statechart/scripts/test/charts/Braces.mmd +7 -0
  182. package/skills/statechart/scripts/test/charts/Escapes.mmd +11 -0
  183. package/skills/statechart/scripts/test/charts/Phases.mmd +29 -0
  184. package/skills/statechart/scripts/test/cli.test.ts +1315 -0
  185. package/skills/statechart/scripts/test/config-fuzz.test.ts +263 -0
  186. package/skills/statechart/scripts/test/corpus/Counter/ChartRun.out +57 -0
  187. package/skills/statechart/scripts/test/corpus/Counter/Counter.cfg +3 -0
  188. package/skills/statechart/scripts/test/corpus/Counter/Counter.tla +10 -0
  189. package/skills/statechart/scripts/test/corpus/Counter/chart.mmd +9 -0
  190. package/skills/statechart/scripts/test/corpus/Counter/graph.dot +16 -0
  191. package/skills/statechart/scripts/test/corpus/Counter/report.md +7 -0
  192. package/skills/statechart/scripts/test/corpus/Counter/sany.out +2 -0
  193. package/skills/statechart/scripts/test/corpus/Counter/verdict-1.out +49 -0
  194. package/skills/statechart/scripts/test/corpus/CounterAction/ChartRun.out +60 -0
  195. package/skills/statechart/scripts/test/corpus/CounterAction/CounterAction.cfg +4 -0
  196. package/skills/statechart/scripts/test/corpus/CounterAction/CounterAction.tla +22 -0
  197. package/skills/statechart/scripts/test/corpus/CounterAction/chart.mmd +26 -0
  198. package/skills/statechart/scripts/test/corpus/CounterAction/graph.dot +19 -0
  199. package/skills/statechart/scripts/test/corpus/CounterAction/report.md +20 -0
  200. package/skills/statechart/scripts/test/corpus/CounterAction/sany.out +2 -0
  201. package/skills/statechart/scripts/test/corpus/CounterAction/verdict-1.exit +1 -0
  202. package/skills/statechart/scripts/test/corpus/CounterAction/verdict-1.out +56 -0
  203. package/skills/statechart/scripts/test/corpus/CounterAction/verdict-2.exit +1 -0
  204. package/skills/statechart/scripts/test/corpus/CounterAction/verdict-2.out +82 -0
  205. package/skills/statechart/scripts/test/corpus/CounterAction/verdict-3.out +57 -0
  206. package/skills/statechart/scripts/test/corpus/CounterDeadlock/ChartRun.out +59 -0
  207. package/skills/statechart/scripts/test/corpus/CounterDeadlock/CounterDeadlock.cfg +3 -0
  208. package/skills/statechart/scripts/test/corpus/CounterDeadlock/CounterDeadlock.tla +11 -0
  209. package/skills/statechart/scripts/test/corpus/CounterDeadlock/chart.mmd +22 -0
  210. package/skills/statechart/scripts/test/corpus/CounterDeadlock/graph.dot +16 -0
  211. package/skills/statechart/scripts/test/corpus/CounterDeadlock/report.md +17 -0
  212. package/skills/statechart/scripts/test/corpus/CounterDeadlock/sany.out +2 -0
  213. package/skills/statechart/scripts/test/corpus/CounterDeadlock/verdict-1.exit +1 -0
  214. package/skills/statechart/scripts/test/corpus/CounterDeadlock/verdict-1.out +56 -0
  215. package/skills/statechart/scripts/test/corpus/CounterDeadlock/verdict-2.exit +1 -0
  216. package/skills/statechart/scripts/test/corpus/CounterDeadlock/verdict-2.out +77 -0
  217. package/skills/statechart/scripts/test/corpus/CounterFan/ChartRun.out +69 -0
  218. package/skills/statechart/scripts/test/corpus/CounterFan/CounterFan.cfg +2 -0
  219. package/skills/statechart/scripts/test/corpus/CounterFan/CounterFan.tla +11 -0
  220. package/skills/statechart/scripts/test/corpus/CounterFan/chart.mmd +85 -0
  221. package/skills/statechart/scripts/test/corpus/CounterFan/graph.dot +70 -0
  222. package/skills/statechart/scripts/test/corpus/CounterFan/report.md +12 -0
  223. package/skills/statechart/scripts/test/corpus/CounterFan/sany.out +2 -0
  224. package/skills/statechart/scripts/test/corpus/CounterFan/verdict-1.exit +1 -0
  225. package/skills/statechart/scripts/test/corpus/CounterFan/verdict-1.out +67 -0
  226. package/skills/statechart/scripts/test/corpus/CounterFan/verdict-2.out +57 -0
  227. package/skills/statechart/scripts/test/corpus/CounterGuard/ChartRun.exit +1 -0
  228. package/skills/statechart/scripts/test/corpus/CounterGuard/ChartRun.out +85 -0
  229. package/skills/statechart/scripts/test/corpus/CounterGuard/CounterGuard.cfg +6 -0
  230. package/skills/statechart/scripts/test/corpus/CounterGuard/CounterGuard.tla +13 -0
  231. package/skills/statechart/scripts/test/corpus/CounterGuard/chart.mmd +5 -0
  232. package/skills/statechart/scripts/test/corpus/CounterGuard/graph.dot +10 -0
  233. package/skills/statechart/scripts/test/corpus/CounterGuard/report.md +31 -0
  234. package/skills/statechart/scripts/test/corpus/CounterGuard/sany.out +2 -0
  235. package/skills/statechart/scripts/test/corpus/CounterGuard/verdict-1.exit +1 -0
  236. package/skills/statechart/scripts/test/corpus/CounterGuard/verdict-1.out +64 -0
  237. package/skills/statechart/scripts/test/corpus/CounterGuard/verdict-2.exit +1 -0
  238. package/skills/statechart/scripts/test/corpus/CounterGuard/verdict-2.out +77 -0
  239. package/skills/statechart/scripts/test/corpus/CounterInitPast/ChartRun.out +55 -0
  240. package/skills/statechart/scripts/test/corpus/CounterInitPast/CounterInitPast.cfg +3 -0
  241. package/skills/statechart/scripts/test/corpus/CounterInitPast/CounterInitPast.tla +10 -0
  242. package/skills/statechart/scripts/test/corpus/CounterInitPast/chart.mmd +12 -0
  243. package/skills/statechart/scripts/test/corpus/CounterInitPast/graph.dot +6 -0
  244. package/skills/statechart/scripts/test/corpus/CounterInitPast/report.md +12 -0
  245. package/skills/statechart/scripts/test/corpus/CounterInitPast/sany.out +2 -0
  246. package/skills/statechart/scripts/test/corpus/CounterInitPast/verdict-1.exit +1 -0
  247. package/skills/statechart/scripts/test/corpus/CounterInitPast/verdict-1.out +33 -0
  248. package/skills/statechart/scripts/test/corpus/CounterInitPast/verdict-2.out +54 -0
  249. package/skills/statechart/scripts/test/corpus/CounterInitPastHolds/ChartRun.out +54 -0
  250. package/skills/statechart/scripts/test/corpus/CounterInitPastHolds/CounterInitPastHolds.cfg +3 -0
  251. package/skills/statechart/scripts/test/corpus/CounterInitPastHolds/CounterInitPastHolds.tla +10 -0
  252. package/skills/statechart/scripts/test/corpus/CounterInitPastHolds/chart.mmd +1 -0
  253. package/skills/statechart/scripts/test/corpus/CounterInitPastHolds/graph.dot +6 -0
  254. package/skills/statechart/scripts/test/corpus/CounterInitPastHolds/report.md +7 -0
  255. package/skills/statechart/scripts/test/corpus/CounterInitPastHolds/sany.out +2 -0
  256. package/skills/statechart/scripts/test/corpus/CounterInitPastHolds/verdict-1.out +46 -0
  257. package/skills/statechart/scripts/test/corpus/CounterInstance/ChartRun.out +59 -0
  258. package/skills/statechart/scripts/test/corpus/CounterInstance/CounterInstance.cfg +2 -0
  259. package/skills/statechart/scripts/test/corpus/CounterInstance/CounterInstance.tla +10 -0
  260. package/skills/statechart/scripts/test/corpus/CounterInstance/CounterSteps.tla +6 -0
  261. package/skills/statechart/scripts/test/corpus/CounterInstance/chart.mmd +17 -0
  262. package/skills/statechart/scripts/test/corpus/CounterInstance/graph.dot +15 -0
  263. package/skills/statechart/scripts/test/corpus/CounterInstance/report.md +14 -0
  264. package/skills/statechart/scripts/test/corpus/CounterInstance/sany.out +3 -0
  265. package/skills/statechart/scripts/test/corpus/CounterInstance/verdict-1.exit +1 -0
  266. package/skills/statechart/scripts/test/corpus/CounterInstance/verdict-1.out +78 -0
  267. package/skills/statechart/scripts/test/corpus/CounterJump/ChartRun.out +59 -0
  268. package/skills/statechart/scripts/test/corpus/CounterJump/CounterJump.cfg +3 -0
  269. package/skills/statechart/scripts/test/corpus/CounterJump/CounterJump.tla +19 -0
  270. package/skills/statechart/scripts/test/corpus/CounterJump/chart.mmd +26 -0
  271. package/skills/statechart/scripts/test/corpus/CounterJump/graph.dot +22 -0
  272. package/skills/statechart/scripts/test/corpus/CounterJump/report.md +12 -0
  273. package/skills/statechart/scripts/test/corpus/CounterJump/sany.out +2 -0
  274. package/skills/statechart/scripts/test/corpus/CounterJump/verdict-1.exit +1 -0
  275. package/skills/statechart/scripts/test/corpus/CounterJump/verdict-1.out +58 -0
  276. package/skills/statechart/scripts/test/corpus/CounterJump/verdict-2.out +57 -0
  277. package/skills/statechart/scripts/test/corpus/CounterLoop/ChartRun.out +57 -0
  278. package/skills/statechart/scripts/test/corpus/CounterLoop/CounterLoop.cfg +2 -0
  279. package/skills/statechart/scripts/test/corpus/CounterLoop/CounterLoop.tla +11 -0
  280. package/skills/statechart/scripts/test/corpus/CounterLoop/chart.mmd +17 -0
  281. package/skills/statechart/scripts/test/corpus/CounterLoop/graph.dot +15 -0
  282. package/skills/statechart/scripts/test/corpus/CounterLoop/report.md +14 -0
  283. package/skills/statechart/scripts/test/corpus/CounterLoop/sany.out +2 -0
  284. package/skills/statechart/scripts/test/corpus/CounterLoop/verdict-1.exit +1 -0
  285. package/skills/statechart/scripts/test/corpus/CounterLoop/verdict-1.out +76 -0
  286. package/skills/statechart/scripts/test/corpus/CounterOrder/ChartRun.out +59 -0
  287. package/skills/statechart/scripts/test/corpus/CounterOrder/CounterOrder.cfg +3 -0
  288. package/skills/statechart/scripts/test/corpus/CounterOrder/CounterOrder.tla +11 -0
  289. package/skills/statechart/scripts/test/corpus/CounterOrder/chart.mmd +19 -0
  290. package/skills/statechart/scripts/test/corpus/CounterOrder/graph.dot +10 -0
  291. package/skills/statechart/scripts/test/corpus/CounterOrder/report.md +15 -0
  292. package/skills/statechart/scripts/test/corpus/CounterOrder/sany.out +2 -0
  293. package/skills/statechart/scripts/test/corpus/CounterOrder/verdict-1.exit +1 -0
  294. package/skills/statechart/scripts/test/corpus/CounterOrder/verdict-1.out +56 -0
  295. package/skills/statechart/scripts/test/corpus/CounterOrder/verdict-2.exit +1 -0
  296. package/skills/statechart/scripts/test/corpus/CounterOrder/verdict-2.out +67 -0
  297. package/skills/statechart/scripts/test/corpus/CounterRules/ChartRun.out +62 -0
  298. package/skills/statechart/scripts/test/corpus/CounterRules/CounterRules.cfg +6 -0
  299. package/skills/statechart/scripts/test/corpus/CounterRules/CounterRules.tla +24 -0
  300. package/skills/statechart/scripts/test/corpus/CounterRules/Moves.tla +5 -0
  301. package/skills/statechart/scripts/test/corpus/CounterRules/chart.mmd +22 -0
  302. package/skills/statechart/scripts/test/corpus/CounterRules/graph.dot +10 -0
  303. package/skills/statechart/scripts/test/corpus/CounterRules/report.md +23 -0
  304. package/skills/statechart/scripts/test/corpus/CounterRules/sany.out +3 -0
  305. package/skills/statechart/scripts/test/corpus/CounterRules/verdict-1.exit +1 -0
  306. package/skills/statechart/scripts/test/corpus/CounterRules/verdict-1.out +58 -0
  307. package/skills/statechart/scripts/test/corpus/CounterRules/verdict-2.exit +1 -0
  308. package/skills/statechart/scripts/test/corpus/CounterRules/verdict-2.out +66 -0
  309. package/skills/statechart/scripts/test/corpus/CounterRules/verdict-3.exit +1 -0
  310. package/skills/statechart/scripts/test/corpus/CounterRules/verdict-3.out +74 -0
  311. package/skills/statechart/scripts/test/corpus/CounterRules/verdict-4.out +59 -0
  312. package/skills/statechart/scripts/test/corpus/CounterStart/ChartRun.out +58 -0
  313. package/skills/statechart/scripts/test/corpus/CounterStart/CounterStart.cfg +3 -0
  314. package/skills/statechart/scripts/test/corpus/CounterStart/CounterStart.tla +15 -0
  315. package/skills/statechart/scripts/test/corpus/CounterStart/chart.mmd +18 -0
  316. package/skills/statechart/scripts/test/corpus/CounterStart/graph.dot +13 -0
  317. package/skills/statechart/scripts/test/corpus/CounterStart/report.md +11 -0
  318. package/skills/statechart/scripts/test/corpus/CounterStart/sany.out +2 -0
  319. package/skills/statechart/scripts/test/corpus/CounterStart/verdict-1.exit +1 -0
  320. package/skills/statechart/scripts/test/corpus/CounterStart/verdict-1.out +33 -0
  321. package/skills/statechart/scripts/test/corpus/CounterStart/verdict-2.out +57 -0
  322. package/skills/statechart/scripts/test/corpus/CounterStop/ChartRun.out +57 -0
  323. package/skills/statechart/scripts/test/corpus/CounterStop/CounterStop.cfg +3 -0
  324. package/skills/statechart/scripts/test/corpus/CounterStop/CounterStop.tla +15 -0
  325. package/skills/statechart/scripts/test/corpus/CounterStop/chart.mmd +7 -0
  326. package/skills/statechart/scripts/test/corpus/CounterStop/graph.dot +13 -0
  327. package/skills/statechart/scripts/test/corpus/CounterStop/report.md +6 -0
  328. package/skills/statechart/scripts/test/corpus/CounterStop/sany.out +2 -0
  329. package/skills/statechart/scripts/test/corpus/CounterStop/verdict-1.out +49 -0
  330. package/skills/statechart/scripts/test/corpus/CounterTie/ChartRun.out +61 -0
  331. package/skills/statechart/scripts/test/corpus/CounterTie/CounterTie.cfg +4 -0
  332. package/skills/statechart/scripts/test/corpus/CounterTie/CounterTie.tla +14 -0
  333. package/skills/statechart/scripts/test/corpus/CounterTie/chart.mmd +30 -0
  334. package/skills/statechart/scripts/test/corpus/CounterTie/graph.dot +19 -0
  335. package/skills/statechart/scripts/test/corpus/CounterTie/report.md +27 -0
  336. package/skills/statechart/scripts/test/corpus/CounterTie/sany.out +2 -0
  337. package/skills/statechart/scripts/test/corpus/CounterTie/verdict-1.exit +1 -0
  338. package/skills/statechart/scripts/test/corpus/CounterTie/verdict-1.out +56 -0
  339. package/skills/statechart/scripts/test/corpus/CounterTie/verdict-2.exit +1 -0
  340. package/skills/statechart/scripts/test/corpus/CounterTie/verdict-2.out +64 -0
  341. package/skills/statechart/scripts/test/corpus/CounterTie/verdict-3.exit +1 -0
  342. package/skills/statechart/scripts/test/corpus/CounterTie/verdict-3.out +87 -0
  343. package/skills/statechart/scripts/test/corpus/CounterTie/verdict-4.out +57 -0
  344. package/skills/statechart/scripts/test/corpus/CounterTieInGraph/ChartRun.out +60 -0
  345. package/skills/statechart/scripts/test/corpus/CounterTieInGraph/CounterTieInGraph.cfg +3 -0
  346. package/skills/statechart/scripts/test/corpus/CounterTieInGraph/CounterTieInGraph.tla +12 -0
  347. package/skills/statechart/scripts/test/corpus/CounterTieInGraph/chart.mmd +23 -0
  348. package/skills/statechart/scripts/test/corpus/CounterTieInGraph/graph.dot +19 -0
  349. package/skills/statechart/scripts/test/corpus/CounterTieInGraph/report.md +11 -0
  350. package/skills/statechart/scripts/test/corpus/CounterTieInGraph/sany.out +2 -0
  351. package/skills/statechart/scripts/test/corpus/CounterTieInGraph/verdict-1.exit +1 -0
  352. package/skills/statechart/scripts/test/corpus/CounterTieInGraph/verdict-1.out +56 -0
  353. package/skills/statechart/scripts/test/corpus/CounterTieInGraph/verdict-2.out +57 -0
  354. package/skills/statechart/scripts/test/corpus/CounterView/ChartRun.out +61 -0
  355. package/skills/statechart/scripts/test/corpus/CounterView/CounterView.cfg +4 -0
  356. package/skills/statechart/scripts/test/corpus/CounterView/CounterView.tla +14 -0
  357. package/skills/statechart/scripts/test/corpus/CounterView/chart.mmd +23 -0
  358. package/skills/statechart/scripts/test/corpus/CounterView/graph.dot +19 -0
  359. package/skills/statechart/scripts/test/corpus/CounterView/report.md +27 -0
  360. package/skills/statechart/scripts/test/corpus/CounterView/sany.out +2 -0
  361. package/skills/statechart/scripts/test/corpus/CounterView/verdict-1.exit +1 -0
  362. package/skills/statechart/scripts/test/corpus/CounterView/verdict-1.out +56 -0
  363. package/skills/statechart/scripts/test/corpus/CounterView/verdict-2.exit +1 -0
  364. package/skills/statechart/scripts/test/corpus/CounterView/verdict-2.out +64 -0
  365. package/skills/statechart/scripts/test/corpus/CounterView/verdict-3.exit +1 -0
  366. package/skills/statechart/scripts/test/corpus/CounterView/verdict-3.out +87 -0
  367. package/skills/statechart/scripts/test/corpus/CounterView/verdict-4.out +57 -0
  368. package/skills/statechart/scripts/test/corpus/CounterView/view.mjs +1 -0
  369. package/skills/statechart/scripts/test/corpus/DieHard/ChartRun.out +59 -0
  370. package/skills/statechart/scripts/test/corpus/DieHard/DieHard.cfg +4 -0
  371. package/skills/statechart/scripts/test/corpus/DieHard/DieHard.tla +38 -0
  372. package/skills/statechart/scripts/test/corpus/DieHard/chart.mmd +92 -0
  373. package/skills/statechart/scripts/test/corpus/DieHard/graph.dot +126 -0
  374. package/skills/statechart/scripts/test/corpus/DieHard/report.md +17 -0
  375. package/skills/statechart/scripts/test/corpus/DieHard/sany.out +2 -0
  376. package/skills/statechart/scripts/test/corpus/DieHard/verdict-1.exit +1 -0
  377. package/skills/statechart/scripts/test/corpus/DieHard/verdict-1.out +91 -0
  378. package/skills/statechart/scripts/test/corpus/DieHard/verdict-2.out +57 -0
  379. package/skills/statechart/scripts/test/corpus/FirstRule/ChartRun.out +61 -0
  380. package/skills/statechart/scripts/test/corpus/FirstRule/FirstRule.cfg +6 -0
  381. package/skills/statechart/scripts/test/corpus/FirstRule/FirstRule.tla +11 -0
  382. package/skills/statechart/scripts/test/corpus/FirstRule/chart.mmd +22 -0
  383. package/skills/statechart/scripts/test/corpus/FirstRule/graph.dot +16 -0
  384. package/skills/statechart/scripts/test/corpus/FirstRule/report.md +25 -0
  385. package/skills/statechart/scripts/test/corpus/FirstRule/sany.out +2 -0
  386. package/skills/statechart/scripts/test/corpus/FirstRule/verdict-1.exit +1 -0
  387. package/skills/statechart/scripts/test/corpus/FirstRule/verdict-1.out +56 -0
  388. package/skills/statechart/scripts/test/corpus/FirstRule/verdict-2.exit +1 -0
  389. package/skills/statechart/scripts/test/corpus/FirstRule/verdict-2.out +64 -0
  390. package/skills/statechart/scripts/test/corpus/FirstRule/verdict-3.exit +1 -0
  391. package/skills/statechart/scripts/test/corpus/FirstRule/verdict-3.out +64 -0
  392. package/skills/statechart/scripts/test/corpus/FirstRule/verdict-4.exit +1 -0
  393. package/skills/statechart/scripts/test/corpus/FirstRule/verdict-4.out +77 -0
  394. package/skills/statechart/scripts/test/corpus/HiddenClock/ChartRun.out +57 -0
  395. package/skills/statechart/scripts/test/corpus/HiddenClock/HiddenClock.cfg +4 -0
  396. package/skills/statechart/scripts/test/corpus/HiddenClock/HiddenClock.tla +11 -0
  397. package/skills/statechart/scripts/test/corpus/HiddenClock/chart.mmd +13 -0
  398. package/skills/statechart/scripts/test/corpus/HiddenClock/graph.dot +12 -0
  399. package/skills/statechart/scripts/test/corpus/HiddenClock/report.md +11 -0
  400. package/skills/statechart/scripts/test/corpus/HiddenClock/sany.out +2 -0
  401. package/skills/statechart/scripts/test/corpus/HiddenClock/verdict-1.exit +1 -0
  402. package/skills/statechart/scripts/test/corpus/HiddenClock/verdict-1.out +72 -0
  403. package/skills/statechart/scripts/test/corpus/Login/ChartRun.out +57 -0
  404. package/skills/statechart/scripts/test/corpus/Login/Login.cfg +3 -0
  405. package/skills/statechart/scripts/test/corpus/Login/Login.tla +62 -0
  406. package/skills/statechart/scripts/test/corpus/Login/chart.mmd +28 -0
  407. package/skills/statechart/scripts/test/corpus/Login/graph.dot +40 -0
  408. package/skills/statechart/scripts/test/corpus/Login/report.md +7 -0
  409. package/skills/statechart/scripts/test/corpus/Login/sany.out +1 -0
  410. package/skills/statechart/scripts/test/corpus/Login/verdict-1.out +47 -0
  411. package/skills/statechart/scripts/test/corpus/Login/view.mjs +1 -0
  412. package/skills/statechart/scripts/test/corpus/LoginGuarded/ChartRun.out +57 -0
  413. package/skills/statechart/scripts/test/corpus/LoginGuarded/LoginGuarded.cfg +2 -0
  414. package/skills/statechart/scripts/test/corpus/LoginGuarded/LoginGuarded.tla +64 -0
  415. package/skills/statechart/scripts/test/corpus/LoginGuarded/chart.mmd +28 -0
  416. package/skills/statechart/scripts/test/corpus/LoginGuarded/graph.dot +37 -0
  417. package/skills/statechart/scripts/test/corpus/LoginGuarded/report.md +8 -0
  418. package/skills/statechart/scripts/test/corpus/LoginGuarded/sany.out +1 -0
  419. package/skills/statechart/scripts/test/corpus/LoginGuarded/verdict-1.out +47 -0
  420. package/skills/statechart/scripts/test/corpus/LoginGuarded/view.mjs +1 -0
  421. package/skills/statechart/scripts/test/corpus/LoginParallel/ChartRun.out +60 -0
  422. package/skills/statechart/scripts/test/corpus/LoginParallel/LoginParallel.cfg +3 -0
  423. package/skills/statechart/scripts/test/corpus/LoginParallel/LoginParallel.tla +64 -0
  424. package/skills/statechart/scripts/test/corpus/LoginParallel/chart.mmd +44 -0
  425. package/skills/statechart/scripts/test/corpus/LoginParallel/graph.dot +58 -0
  426. package/skills/statechart/scripts/test/corpus/LoginParallel/report.md +17 -0
  427. package/skills/statechart/scripts/test/corpus/LoginParallel/sany.out +1 -0
  428. package/skills/statechart/scripts/test/corpus/LoginParallel/verdict-1.exit +1 -0
  429. package/skills/statechart/scripts/test/corpus/LoginParallel/verdict-1.out +83 -0
  430. package/skills/statechart/scripts/test/corpus/LoginParallel/verdict-2.out +57 -0
  431. package/skills/statechart/scripts/test/corpus/LoginParallel/view.mjs +1 -0
  432. package/skills/statechart/scripts/test/corpus/MediaPlayer/ChartRun.out +60 -0
  433. package/skills/statechart/scripts/test/corpus/MediaPlayer/MediaPlayer.cfg +3 -0
  434. package/skills/statechart/scripts/test/corpus/MediaPlayer/MediaPlayer.tla +103 -0
  435. package/skills/statechart/scripts/test/corpus/MediaPlayer/chart.mmd +43 -0
  436. package/skills/statechart/scripts/test/corpus/MediaPlayer/graph.dot +93 -0
  437. package/skills/statechart/scripts/test/corpus/MediaPlayer/report.md +14 -0
  438. package/skills/statechart/scripts/test/corpus/MediaPlayer/sany.out +1 -0
  439. package/skills/statechart/scripts/test/corpus/MediaPlayer/verdict-1.exit +1 -0
  440. package/skills/statechart/scripts/test/corpus/MediaPlayer/verdict-1.out +59 -0
  441. package/skills/statechart/scripts/test/corpus/MediaPlayer/verdict-2.out +72 -0
  442. package/skills/statechart/scripts/test/corpus/MediaPlayer/view.mjs +3 -0
  443. package/skills/statechart/scripts/test/corpus/MediaPlayerFixed/ChartRun.out +57 -0
  444. package/skills/statechart/scripts/test/corpus/MediaPlayerFixed/MediaPlayerFixed.cfg +2 -0
  445. package/skills/statechart/scripts/test/corpus/MediaPlayerFixed/MediaPlayerFixed.tla +100 -0
  446. package/skills/statechart/scripts/test/corpus/MediaPlayerFixed/chart.mmd +31 -0
  447. package/skills/statechart/scripts/test/corpus/MediaPlayerFixed/graph.dot +85 -0
  448. package/skills/statechart/scripts/test/corpus/MediaPlayerFixed/report.md +9 -0
  449. package/skills/statechart/scripts/test/corpus/MediaPlayerFixed/sany.out +1 -0
  450. package/skills/statechart/scripts/test/corpus/MediaPlayerFixed/verdict-1.out +47 -0
  451. package/skills/statechart/scripts/test/corpus/MediaPlayerFixed/view.mjs +3 -0
  452. package/skills/statechart/scripts/test/corpus/MediaPlayerProps/ChartRun.out +59 -0
  453. package/skills/statechart/scripts/test/corpus/MediaPlayerProps/MediaPlayer.tla +103 -0
  454. package/skills/statechart/scripts/test/corpus/MediaPlayerProps/MediaPlayerProps.cfg +3 -0
  455. package/skills/statechart/scripts/test/corpus/MediaPlayerProps/MediaPlayerProps.tla +6 -0
  456. package/skills/statechart/scripts/test/corpus/MediaPlayerProps/chart.mmd +42 -0
  457. package/skills/statechart/scripts/test/corpus/MediaPlayerProps/graph.dot +93 -0
  458. package/skills/statechart/scripts/test/corpus/MediaPlayerProps/report.md +19 -0
  459. package/skills/statechart/scripts/test/corpus/MediaPlayerProps/sany.out +2 -0
  460. package/skills/statechart/scripts/test/corpus/MediaPlayerProps/verdict-1.exit +1 -0
  461. package/skills/statechart/scripts/test/corpus/MediaPlayerProps/verdict-1.out +61 -0
  462. package/skills/statechart/scripts/test/corpus/MediaPlayerProps/verdict-2.out +59 -0
  463. package/skills/statechart/scripts/test/corpus/MediaPlayerProps/verdict-3.out +61 -0
  464. package/skills/statechart/scripts/test/corpus/MediaPlayerProps/verdict-4.exit +1 -0
  465. package/skills/statechart/scripts/test/corpus/MediaPlayerProps/verdict-4.out +66 -0
  466. package/skills/statechart/scripts/test/corpus/MediaPlayerProps/verdict-5.exit +1 -0
  467. package/skills/statechart/scripts/test/corpus/MediaPlayerProps/verdict-5.out +58 -0
  468. package/skills/statechart/scripts/test/corpus/MediaPlayerProps/verdict-6.out +49 -0
  469. package/skills/statechart/scripts/test/corpus/MediaPlayerProps/view.mjs +3 -0
  470. package/skills/statechart/scripts/test/corpus/PickWorker/ChartRun.out +57 -0
  471. package/skills/statechart/scripts/test/corpus/PickWorker/PickWorker.cfg +6 -0
  472. package/skills/statechart/scripts/test/corpus/PickWorker/PickWorker.tla +11 -0
  473. package/skills/statechart/scripts/test/corpus/PickWorker/chart.mmd +5 -0
  474. package/skills/statechart/scripts/test/corpus/PickWorker/graph.dot +11 -0
  475. package/skills/statechart/scripts/test/corpus/PickWorker/report.md +7 -0
  476. package/skills/statechart/scripts/test/corpus/PickWorker/sany.out +5 -0
  477. package/skills/statechart/scripts/test/corpus/PickWorker/verdict-1.out +70 -0
  478. package/skills/statechart/scripts/test/corpus/Shadow/ChartRun.out +61 -0
  479. package/skills/statechart/scripts/test/corpus/Shadow/Shadow.cfg +4 -0
  480. package/skills/statechart/scripts/test/corpus/Shadow/Shadow.tla +11 -0
  481. package/skills/statechart/scripts/test/corpus/Shadow/ShadowLib.tla +6 -0
  482. package/skills/statechart/scripts/test/corpus/Shadow/ShadowSub.tla +3 -0
  483. package/skills/statechart/scripts/test/corpus/Shadow/chart.mmd +9 -0
  484. package/skills/statechart/scripts/test/corpus/Shadow/graph.dot +16 -0
  485. package/skills/statechart/scripts/test/corpus/Shadow/report.md +8 -0
  486. package/skills/statechart/scripts/test/corpus/Shadow/sany.out +4 -0
  487. package/skills/statechart/scripts/test/corpus/Shadow/verdict-1.out +65 -0
  488. package/skills/statechart/scripts/test/corpus/SpacedNames/ChartRun.out +59 -0
  489. package/skills/statechart/scripts/test/corpus/SpacedNames/SpacedNames.cfg +2 -0
  490. package/skills/statechart/scripts/test/corpus/SpacedNames/SpacedNames.tla +9 -0
  491. package/skills/statechart/scripts/test/corpus/SpacedNames/chart.mmd +23 -0
  492. package/skills/statechart/scripts/test/corpus/SpacedNames/graph.dot +17 -0
  493. package/skills/statechart/scripts/test/corpus/SpacedNames/report.md +15 -0
  494. package/skills/statechart/scripts/test/corpus/SpacedNames/sany.out +1 -0
  495. package/skills/statechart/scripts/test/corpus/SpacedNames/verdict-1.exit +1 -0
  496. package/skills/statechart/scripts/test/corpus/SpacedNames/verdict-1.out +65 -0
  497. package/skills/statechart/scripts/test/corpus/SpacedNames/verdict-2.exit +1 -0
  498. package/skills/statechart/scripts/test/corpus/SpacedNames/verdict-2.out +75 -0
  499. package/skills/statechart/scripts/test/corpus/TwoPhase/ChartRun.out +69 -0
  500. package/skills/statechart/scripts/test/corpus/TwoPhase/TwoPhase.cfg +3 -0
  501. package/skills/statechart/scripts/test/corpus/TwoPhase/TwoPhase.tla +75 -0
  502. package/skills/statechart/scripts/test/corpus/TwoPhase/chart.mmd +60 -0
  503. package/skills/statechart/scripts/test/corpus/TwoPhase/graph.dot +297 -0
  504. package/skills/statechart/scripts/test/corpus/TwoPhase/report.md +20 -0
  505. package/skills/statechart/scripts/test/corpus/TwoPhase/sany.out +1 -0
  506. package/skills/statechart/scripts/test/corpus/TwoPhase/verdict-1.exit +1 -0
  507. package/skills/statechart/scripts/test/corpus/TwoPhase/verdict-1.out +95 -0
  508. package/skills/statechart/scripts/test/corpus/TwoPhase/verdict-2.out +57 -0
  509. package/skills/statechart/scripts/test/corpus/TwoPhase/view.mjs +1 -0
  510. package/skills/statechart/scripts/test/corpus/TwoPhaseFixed/ChartRun.out +57 -0
  511. package/skills/statechart/scripts/test/corpus/TwoPhaseFixed/TwoPhaseFixed.cfg +3 -0
  512. package/skills/statechart/scripts/test/corpus/TwoPhaseFixed/TwoPhaseFixed.tla +75 -0
  513. package/skills/statechart/scripts/test/corpus/TwoPhaseFixed/chart.mmd +37 -0
  514. package/skills/statechart/scripts/test/corpus/TwoPhaseFixed/graph.dot +223 -0
  515. package/skills/statechart/scripts/test/corpus/TwoPhaseFixed/report.md +11 -0
  516. package/skills/statechart/scripts/test/corpus/TwoPhaseFixed/sany.out +1 -0
  517. package/skills/statechart/scripts/test/corpus/TwoPhaseFixed/verdict-1.out +47 -0
  518. package/skills/statechart/scripts/test/corpus/TwoPhaseFixed/view.mjs +1 -0
  519. package/skills/statechart/scripts/test/corpus/TypeGuard/ChartRun.exit +1 -0
  520. package/skills/statechart/scripts/test/corpus/TypeGuard/ChartRun.out +75 -0
  521. package/skills/statechart/scripts/test/corpus/TypeGuard/TypeGuard.cfg +5 -0
  522. package/skills/statechart/scripts/test/corpus/TypeGuard/TypeGuard.tla +11 -0
  523. package/skills/statechart/scripts/test/corpus/TypeGuard/chart.mmd +18 -0
  524. package/skills/statechart/scripts/test/corpus/TypeGuard/graph.dot +14 -0
  525. package/skills/statechart/scripts/test/corpus/TypeGuard/report.md +29 -0
  526. package/skills/statechart/scripts/test/corpus/TypeGuard/sany.out +2 -0
  527. package/skills/statechart/scripts/test/corpus/TypeGuard/verdict-1.exit +1 -0
  528. package/skills/statechart/scripts/test/corpus/TypeGuard/verdict-1.out +64 -0
  529. package/skills/statechart/scripts/test/corpus/TypeGuard/verdict-2.exit +1 -0
  530. package/skills/statechart/scripts/test/corpus/TypeGuard/verdict-2.out +75 -0
  531. package/skills/statechart/scripts/test/corpus/UserNoDeadlock/ChartRun.out +58 -0
  532. package/skills/statechart/scripts/test/corpus/UserNoDeadlock/UserNoDeadlock.cfg +2 -0
  533. package/skills/statechart/scripts/test/corpus/UserNoDeadlock/UserNoDeadlock.tla +8 -0
  534. package/skills/statechart/scripts/test/corpus/UserNoDeadlock/chart.mmd +22 -0
  535. package/skills/statechart/scripts/test/corpus/UserNoDeadlock/graph.dot +16 -0
  536. package/skills/statechart/scripts/test/corpus/UserNoDeadlock/report.md +15 -0
  537. package/skills/statechart/scripts/test/corpus/UserNoDeadlock/sany.out +2 -0
  538. package/skills/statechart/scripts/test/corpus/UserNoDeadlock/verdict-1.exit +1 -0
  539. package/skills/statechart/scripts/test/corpus/UserNoDeadlock/verdict-1.out +56 -0
  540. package/skills/statechart/scripts/test/corpus/UserNoDeadlock/verdict-2.exit +1 -0
  541. package/skills/statechart/scripts/test/corpus/UserNoDeadlock/verdict-2.out +77 -0
  542. package/skills/statechart/scripts/test/corpus.test.ts +441 -0
  543. package/skills/statechart/scripts/test/differential.test.ts +565 -0
  544. package/skills/statechart/scripts/test/drawn.ts +20 -0
  545. package/skills/statechart/scripts/test/grid/Grid.cfg +2 -0
  546. package/skills/statechart/scripts/test/grid/Grid.tla +9 -0
  547. package/skills/statechart/scripts/test/grid/sany.out +2 -0
  548. package/skills/statechart/scripts/test/java.ts +63 -0
  549. package/skills/statechart/scripts/test/labels.ts +648 -0
  550. package/skills/statechart/scripts/test/messages.test.ts +212 -0
  551. package/skills/statechart/scripts/test/pipeline.test.ts +270 -0
  552. package/skills/statechart/scripts/test/plain-tlc.test.ts +255 -0
  553. package/skills/statechart/scripts/test/render.test.ts +145 -0
  554. package/skills/statechart/scripts/test/tlc-out.test.ts +90 -0
  555. package/skills/statechart/scripts/test/tlc.ts +158 -0
  556. package/skills/statechart/scripts/tsconfig.json +11 -0
  557. package/skills/statechart/scripts/worker.ts +35 -0
  558. package/skills/swarm/SKILL.md +41 -0
  559. package/skills/tdd/SKILL.md +42 -0
  560. package/skills/teach/SKILL.md +23 -0
  561. package/skills/technical-writing/SKILL.md +106 -0
  562. package/skills/thermo-nuclear-code-quality-review/SKILL.md +192 -0
  563. package/skills/typescript-best-practices/SKILL.md +32 -0
  564. package/skills/typescript-best-practices/references/patterns.md +328 -0
  565. package/skills/unslop/SKILL.md +62 -0
  566. package/skills/verify-this/SKILL.md +74 -0
  567. package/skills/weekly-review/SKILL.md +32 -0
  568. package/skills/what-did-i-get-done/SKILL.md +31 -0
  569. package/skills/why/SKILL.md +9 -0
  570. package/skills/workflow-from-chats/SKILL.md +50 -0
  571. package/src/credentials.ts +156 -0
  572. package/src/index.ts +610 -0
  573. package/src/jobs.ts +379 -0
  574. package/src/sandbox.ts +229 -0
  575. package/src/sweep.ts +132 -0
package/src/index.ts ADDED
@@ -0,0 +1,610 @@
1
+ import { execFileSync } from 'node:child_process';
2
+ import { existsSync, lstatSync, mkdirSync, readdirSync, readFileSync, realpathSync, rmSync, writeFileSync } from 'node:fs';
3
+ import { basename, dirname, isAbsolute, join, relative, resolve, sep } from 'node:path';
4
+ import { fileURLToPath } from 'node:url';
5
+
6
+ import { type ExtensionAPI, type ExtensionContext, getAgentDir, parseFrontmatter, stripFrontmatter } from '@earendil-works/pi-coding-agent';
7
+ import { Type } from 'typebox';
8
+ import { commandProviders, jobAgentDir, makeJobAgentDir, syncTokens } from './credentials.ts';
9
+ import { brokeredSession, claimWake, excerpt, exitPath, type Job, type JobSpec, launch, launchBrokered, list, newJobId, outputPath, read, readSpec, request, resultsDir, settleBrokered, stop, tail, tmuxSocket } from './jobs.ts';
10
+ import { JOB_DIR_ENV, SANDBOX_ENV, type SandboxPolicy, sandboxed, TOP_DIR_ENV } from './sandbox.ts';
11
+ import { codePaths, PI_CODE } from './sweep.ts';
12
+
13
+ const packageRoot = resolve(dirname(fileURLToPath(import.meta.url)), '..');
14
+ const AGENTS = ['poteto-agent', 'comment-sicko', 'ci-watcher', 'thermo-nuclear-code-quality-review'] as const;
15
+ const THINKING = ['off', 'minimal', 'low', 'medium', 'high', 'xhigh', 'max'] as const;
16
+ const POLL_MS = 2000;
17
+ const REPORT_LIMIT = 20000;
18
+ // A report's first lines hold its verdict, so they are kept ahead of the end when a report is cut.
19
+ const REPORT_HEAD = 4000;
20
+
21
+ export const modelsFile = (agentDir: string): string => join(agentDir, 'pstack-v2-models.md');
22
+ const insideJob = (): boolean => process.env[SANDBOX_ENV] === '1';
23
+ // As in Cursor, the root and the workers it starts may start workers, and a worker started by another worker may not.
24
+ const startedByWorker = (): boolean => insideJob() && process.env[JOB_DIR_ENV] !== process.env[TOP_DIR_ENV];
25
+ const topJobsRoot = (): string => join(getAgentDir(), 'pstack-v2', 'jobs');
26
+ // A sandboxed worker can write only inside its own job directory's `nested/`, so the jobs it starts live there.
27
+ const jobsRoot = (env: NodeJS.ProcessEnv = process.env): string => {
28
+ const parent = env[JOB_DIR_ENV];
29
+ return env[SANDBOX_ENV] === '1' && parent ? join(parent, 'nested') : topJobsRoot();
30
+ };
31
+ // A plain string enum, which every provider accepts, typed for TypeBox inference.
32
+ const stringEnum = <T extends readonly string[]>(values: T, description?: string) => Type.Unsafe<T[number]>({ type: 'string', enum: [...values], ...(description ? { description } : {}) });
33
+ const text = (value: string) => ({ content: [{ type: 'text' as const, text: value }], details: undefined });
34
+
35
+ const agentRoles = AGENTS.map((name) => `${name}: ${parseFrontmatter<{ description?: string }>(readFileSync(join(packageRoot, 'agents', `${name}.md`), 'utf8')).frontmatter.description ?? ''}`);
36
+ const skillsHint = `pstack skills, including ones hidden from the skill list, live at ${join(packageRoot, 'skills')}/<name>/SKILL.md. When a skill says to run another skill, read that file and follow it.`;
37
+ const SANDBOX_NOTE = 'You run in the pstack sandbox. The shared /tmp and user caches are read-only, so keep temp files in $TMPDIR, your own temp directory.';
38
+ const flagValue = (command: string[], flag: string): string | undefined => (command.includes(flag) ? command[command.indexOf(flag) + 1] : undefined);
39
+ const rules = ['no-inline-imports', 'typescript-exhaustive-switch'].map((name) => stripFrontmatter(readFileSync(join(packageRoot, 'rules', `${name}.md`), 'utf8')).replace(/^#.*\n+/, ''));
40
+
41
+ function git(cwd: string, args: string[]): string {
42
+ return execFileSync('git', ['-C', cwd, ...args], { encoding: 'utf8', stdio: ['ignore', 'pipe', 'pipe'] }).trim();
43
+ }
44
+
45
+ function gitPath(cwd: string, flag: '--git-common-dir' | '--show-toplevel' | '--absolute-git-dir'): string | undefined {
46
+ try {
47
+ return resolve(cwd, git(cwd, ['rev-parse', flag]));
48
+ } catch {
49
+ return undefined;
50
+ }
51
+ }
52
+
53
+ /** A job may only work inside the session's project, so the model cannot widen its own sandbox by naming another directory. */
54
+ function projectPath(ctx: ExtensionContext, path: string | undefined): string {
55
+ const root = realpathSync(gitPath(ctx.cwd, '--show-toplevel') ?? ctx.cwd);
56
+ const target = realpathSync(path === undefined ? ctx.cwd : resolve(ctx.cwd, path));
57
+ if (!within(target, [root])) throw new Error(`cwd must be inside this project (${root}), got ${target}. To work on another branch, pass worktree and the job gets its own checkout.`);
58
+ return target;
59
+ }
60
+
61
+ /**
62
+ * Paths an unsandboxed process later executes from: git hooks and config, and Pi's project extensions and settings. Git
63
+ * finds those through `.git`, and in a linked worktree through its `commondir` and `gitdir` files, so each of those is
64
+ * protected too. A job that could repoint any of them would make the next `git commit` run its own hooks unsandboxed.
65
+ */
66
+ function protectedPaths(cwd: string, common: string | undefined): { protect: string[]; lock: string[]; gitDirs: string[] } {
67
+ // Every .pi directory and .git entry already in the checkout, at any depth, since Pi and git find them anywhere.
68
+ const found = codePaths([cwd]);
69
+ const piDirs = [...new Set([join(cwd, '.pi'), ...found.filter((path) => basename(dirname(path)) === '.pi').map(dirname)])];
70
+ const pi = piDirs.flatMap((dir) => PI_CODE.map((name) => join(dir, name)));
71
+ // The checkout's own .git is its git directory, which the job may write. Any other is a repository git would run hooks from.
72
+ const pointers = found.filter((path) => basename(path) === '.git' && path !== join(cwd, '.git'));
73
+ let protect = [...pi, ...pointers];
74
+ let lock: string[] = [];
75
+ if (common) {
76
+ const own = gitPath(cwd, '--absolute-git-dir') ?? common;
77
+ const worktree = own === common ? [] : [join(cwd, '.git'), ...['commondir', 'gitdir', 'config.worktree'].map((name) => join(own, name))];
78
+ let hooksPath: string[] = [];
79
+ try {
80
+ const configured = git(cwd, ['config', '--get', 'core.hooksPath']);
81
+ if (configured) hooksPath = [resolve(gitPath(cwd, '--show-toplevel') ?? cwd, configured)];
82
+ } catch {
83
+ // No custom hooks path.
84
+ }
85
+ protect = [...protect, join(common, 'hooks'), join(common, 'config'), join(common, 'config.worktree'), join(common, 'info'), ...worktree, ...hooksPath];
86
+ lock = [join(cwd, '.git'), own, common];
87
+ }
88
+ // A directory above a protected path could be renamed away and replaced, so each existing one up to the checkout is locked.
89
+ const ancestors = protect.flatMap((path) => {
90
+ const chain: string[] = [];
91
+ for (let dir = dirname(path); within(dir, [cwd]) && dir !== cwd; dir = dirname(dir)) if (existsSync(dir)) chain.push(dir);
92
+ return chain;
93
+ });
94
+ return { protect, lock: [...new Set([...lock, ...ancestors])], gitDirs: common ? [common] : [] };
95
+ }
96
+
97
+ /** Adds the worktree and returns whether it created the branch, so a failed start can remove it. */
98
+ function addWorktree(cwd: string, path: string, branch: string, base: string | undefined): boolean {
99
+ if (branch.startsWith('-') || base?.startsWith('-')) throw new Error('worktree and base cannot start with "-".');
100
+ let exists = true;
101
+ try {
102
+ git(cwd, ['rev-parse', '--verify', '--quiet', `refs/heads/${branch}`]);
103
+ } catch {
104
+ exists = false;
105
+ }
106
+ git(cwd, exists ? ['worktree', 'add', path, branch] : ['worktree', 'add', '-b', branch, path, base ?? 'HEAD']);
107
+ return !exists;
108
+ }
109
+
110
+ function report(job: Job): string {
111
+ const state = job.status.state === 'exited' ? `exited with code ${job.status.code}` : 'was lost (its tmux session ended without an exit code)';
112
+ const output = outputPath(job.spec.out);
113
+ const body = job.spec.kind === 'pi' ? excerpt(output, REPORT_HEAD, REPORT_LIMIT - REPORT_HEAD) : tail(output, 60);
114
+ // A worker that fails at startup, such as on a bad model or credential, says why only on stderr.
115
+ const failed = job.status.state !== 'exited' || job.status.code !== 0 || !body.trim();
116
+ const errors = failed ? tail(join(job.spec.out, 'stderr.log'), 40).trim() : '';
117
+ return [`tmux job ${job.spec.name} (${job.spec.id}) ${state}. Full output: ${output}`, job.spec.wake ?? '', `<output>\n${body.trim()}\n</output>`, errors ? `<stderr>\n${errors}\n</stderr>` : ''].filter(Boolean).join('\n\n');
118
+ }
119
+
120
+ function describe(job: Job): string {
121
+ const state = job.status.state === 'exited' ? `exited ${job.status.code}` : job.status.state;
122
+ return `${job.spec.id} ${job.spec.kind} ${state} ${job.spec.name}\n follow: tail -f ${outputPath(job.spec.out)}`;
123
+ }
124
+
125
+ function resolveModel(ctx: ExtensionContext, model: string | undefined): string | undefined {
126
+ if (model === undefined) return ctx.model ? `${ctx.model.provider}/${ctx.model.id}` : undefined;
127
+ const slash = model.indexOf('/');
128
+ if (slash < 1 || !ctx.modelRegistry.find(model.slice(0, slash), model.slice(slash + 1))) {
129
+ throw new Error(`Unknown model "${model}". Pass provider/id exactly as \`pi --list-models\` prints it, or omit model to use the parent's model.`);
130
+ }
131
+ return model;
132
+ }
133
+
134
+ /** Resolves symlinks in the longest existing prefix, so a path that does not exist yet still compares by where it would land. */
135
+ function landing(path: string): string {
136
+ const absolute = resolve(path);
137
+ if (existsSync(absolute)) return realpathSync(absolute);
138
+ const parent = dirname(absolute);
139
+ return parent === absolute ? absolute : join(landing(parent), relative(parent, absolute));
140
+ }
141
+
142
+ const within = (path: string, roots: string[]): boolean =>
143
+ roots.some((root) => {
144
+ const inside = relative(landing(root), landing(path));
145
+ return inside !== '..' && !inside.startsWith(`..${sep}`) && !isAbsolute(inside);
146
+ });
147
+
148
+ // A sandboxed worker asks the root Pi to launch for it on every platform, so nested jobs get the same sandbox everywhere
149
+ // and no job needs a tmux server of its own. macOS could not apply a second Seatbelt profile anyway.
150
+ const brokering = (): boolean => insideJob();
151
+
152
+ /** Starts a job under its own sandbox, or writes it as a request for the root Pi when this process cannot. */
153
+ function start(root: string, spec: JobSpec, files: Record<string, string> = {}, resolved: Record<string, string> = {}): Job {
154
+ const jobDir = join(root, spec.id);
155
+ // A job started from inside another uses its top-level job's agent directory, which that start already created.
156
+ const top = insideJob() ? (process.env[TOP_DIR_ENV] ?? jobDir) : jobDir;
157
+ if (!insideJob()) makeJobAgentDir(getAgentDir(), jobAgentDir(jobDir), resolved);
158
+ // Every job gets a private temp directory, since the shared ones hold code unsandboxed programs load, and writes
159
+ // credentials only to its top-level job's copy.
160
+ const policy: SandboxPolicy = { ...spec.policy, jobDir, credentials: jobAgentDir(top), writable: [...new Set([...spec.policy.writable, join(jobDir, 'tmp')])] };
161
+ // A writable path that holds Pi's agent directory would let the job rewrite Pi's own code and settings.
162
+ const holder = policy.writable.find((path) => within(policy.agentDir, [path]));
163
+ if (holder) throw new Error(`pstack will not let a job write ${holder}, because it contains Pi's agent directory ${policy.agentDir}. Run Pi from a project directory.`);
164
+ spec = { ...spec, sweep: sweepFor(policy) };
165
+ policy.checkouts = spec.sweep.roots;
166
+ // bubblewrap binds only paths that exist, so the private temp directory exists before the sandbox is built.
167
+ mkdirSync(join(jobDir, 'tmp'), { recursive: true });
168
+ if (brokering()) return request(root, { ...spec, policy }, files);
169
+ return launch(root, { ...spec, policy, argv: sandboxed(spec.command, policy) }, files);
170
+ }
171
+
172
+ /** The checkouts a job may write, and the protected paths in them, which its wrapper sweeps after it for code that appeared. */
173
+ const sweepFor = (policy: SandboxPolicy): JobSpec['sweep'] => ({
174
+ // A job's own session, nested, temp, and agent directories live under Pi's agent directory. A worktree does too, and is a checkout.
175
+ roots: policy.writable.filter((path) => (basename(path) === 'worktree' || !within(path, [policy.agentDir])) && !within(path, policy.gitDirs)),
176
+ protect: policy.protect.filter((path) => within(path, policy.writable)),
177
+ });
178
+
179
+ const readGrant = (out: string): string[] => {
180
+ try {
181
+ const grant: unknown = JSON.parse(readFileSync(join(out, 'granted.json'), 'utf8'));
182
+ return isStrings(grant) ? grant : [];
183
+ } catch {
184
+ return [];
185
+ }
186
+ };
187
+
188
+ const isStrings = (value: unknown): value is string[] => Array.isArray(value) && value.every((item) => typeof item === 'string');
189
+
190
+ const tmuxKill = (socket: string, session: string): void => {
191
+ try {
192
+ execFileSync('tmux', ['-S', socket, 'kill-session', '-t', `=${session}`], { stdio: 'ignore' });
193
+ } catch {
194
+ // Already gone.
195
+ }
196
+ };
197
+
198
+ function hasSession(socket: string, session: string): boolean {
199
+ try {
200
+ execFileSync('tmux', ['-S', socket, 'has-session', '-t', `=${session}`], { stdio: 'ignore' });
201
+ return true;
202
+ } catch {
203
+ return false;
204
+ }
205
+ }
206
+
207
+ /**
208
+ * Launches the requests that sandboxed workers under one of this session's jobs wrote. A request may write only inside
209
+ * what the root granted the top-level job, so no worker can hand a descendant more than it was given. The root only
210
+ * reads from the request directory, which a worker controls, and writes results under the top-level job.
211
+ */
212
+ export function serveRequests(top: Job, socket: string, nested: string, requesterDone: boolean, depth = 0, grant: string[] = top.spec.policy.writable): void {
213
+ // A worker could link its nested directory back up its own tree, so only real directories are followed, and not far.
214
+ if (depth > 8 || !existsSync(nested) || !lstatSync(nested).isDirectory()) return;
215
+ for (const name of readdirSync(nested)) {
216
+ try {
217
+ const dir = join(nested, name);
218
+ // A worker could link an entry back up its own tree, so only real directories are followed.
219
+ if (!lstatSync(dir).isDirectory()) continue;
220
+ const spec = readSpec(dir);
221
+ const policy = spec?.policy;
222
+ // A worker writes these files, so anything malformed is skipped instead of stopping every other request.
223
+ if (!spec || !policy || (spec.kind !== 'pi' && spec.kind !== 'command') || typeof spec.cwd !== 'string' || !isStrings(spec.command) || spec.command.length === 0) continue;
224
+ if (!isStrings(policy.writable) || !isStrings(policy.protect) || !isStrings(policy.lock) || !isStrings(policy.gitDirs)) continue;
225
+ const out = resultsDir(top.dir, dir);
226
+ const stopped = existsSync(join(dir, 'stop'));
227
+ const done = existsSync(exitPath(out)) || stopped;
228
+ // A request's own requests may write only what the root granted it, recorded where no worker can write.
229
+ const own = readGrant(out);
230
+ serveRequests(top, socket, join(dir, 'nested'), requesterDone || done, depth + 1, own);
231
+ if (!spec.brokered || existsSync(exitPath(out))) continue;
232
+ const session = brokeredSession(dir);
233
+ if (existsSync(join(out, 'launched'))) {
234
+ if (requesterDone || stopped) tmuxKill(socket, session);
235
+ else if (!hasSession(socket, session)) settleBrokered(out, 137, 'pstack lost this job: its tmux session ended without an exit code.');
236
+ continue;
237
+ }
238
+ if (requesterDone || stopped) continue;
239
+ if (spec.kind === 'pi' && depth > 0) {
240
+ settleBrokered(out, 126, 'pstack refused to start this Pi worker. A worker started by another worker cannot start workers of its own.');
241
+ continue;
242
+ }
243
+ const writable = policy.writable.map(landing);
244
+ const refused = [...writable.filter((path) => !within(path, grant)), ...(within(spec.cwd, [top.spec.cwd, ...grant]) ? [] : [`cwd ${spec.cwd}`])];
245
+ if (refused.length) {
246
+ settleBrokered(out, 126, `pstack refused to launch this job. It asked to write outside what the job that requested it may write: ${refused.join(', ')}`);
247
+ continue;
248
+ }
249
+ // The sandbox is built from the paths just validated, so swapping a link afterwards changes nothing.
250
+ const granted: SandboxPolicy = {
251
+ writable,
252
+ protect: [...policy.protect, ...top.spec.policy.protect],
253
+ lock: [...policy.lock, ...top.spec.policy.lock],
254
+ gitDirs: [...policy.gitDirs, ...top.spec.policy.gitDirs],
255
+ checkouts: [],
256
+ credentials: jobAgentDir(top.dir),
257
+ agentDir: getAgentDir(),
258
+ jobDir: dir,
259
+ };
260
+ granted.checkouts = sweepFor(granted).roots;
261
+ mkdirSync(out, { recursive: true });
262
+ writeFileSync(join(out, 'granted.json'), JSON.stringify(writable));
263
+ launchBrokered(top.dir, dir, spec, sweepFor(granted), sandboxed(spec.command, granted), socket);
264
+ } catch {
265
+ // One request failing must not stop the others.
266
+ }
267
+ }
268
+ }
269
+
270
+ export default function pstack(pi: ExtensionAPI) {
271
+ let watcher: ReturnType<typeof setInterval> | undefined;
272
+ const stoppedSeries = new Set<string>();
273
+ // Jobs a tmux_jobs wait call is blocking on. Their report goes back as that call's result, not as a wake.
274
+ const awaited = new Set<string>();
275
+
276
+ // Reports a finished job whose wake was just claimed, restarting it first when it is a heartbeat that exited cleanly.
277
+ const finish = (job: Job): string => {
278
+ if (!job.spec.repeat) return report(job);
279
+ // A heartbeat repeats only while it exits cleanly, so a failing command cannot wake the session in a tight loop.
280
+ if (job.status.state !== 'exited' || job.status.code !== 0) return `${report(job)}\n\nThis heartbeat did not exit cleanly, so it was not restarted.`;
281
+ try {
282
+ if (stoppedSeries.has(job.spec.series)) return report(job);
283
+ // The next run gets its own temp directory in place of this one's.
284
+ const policy = { ...job.spec.policy, writable: job.spec.policy.writable.filter((path) => path !== join(job.dir, 'tmp')) };
285
+ start(jobsRoot(), { ...job.spec, policy, id: newJobId(job.spec.name), brokered: false, createdAt: new Date().toISOString() });
286
+ return report(job);
287
+ } catch (error) {
288
+ return `${report(job)}\n\nThis heartbeat could not be restarted: ${error instanceof Error ? error.message : String(error)}`;
289
+ }
290
+ };
291
+
292
+ const deliverFinished = (ctx: ExtensionContext): void => {
293
+ const jobs = list(jobsRoot(), ctx.sessionManager.getSessionId());
294
+ for (const job of jobs) {
295
+ if (job.spec.wake === null || job.status.state === 'running' || awaited.has(job.spec.id) || !claimWake(job)) continue;
296
+ pi.sendMessage({ customType: 'pstack-job', content: finish(job), display: true }, { triggerTurn: true, deliverAs: 'steer' });
297
+ }
298
+ if (ctx.hasUI) {
299
+ const running = jobs.filter((job) => job.status.state === 'running').length;
300
+ ctx.ui.setStatus('pstack', running ? `tmux jobs: ${running} running` : undefined);
301
+ }
302
+ };
303
+
304
+ const interactive = (ctx: ExtensionContext): boolean => ctx.mode === 'tui' || ctx.mode === 'rpc';
305
+
306
+ const serve = (ctx: ExtensionContext): void => {
307
+ if (brokering()) return;
308
+ const owner = ctx.sessionManager.getSessionId();
309
+ for (const top of list(jobsRoot(), owner)) if (top.spec.kind === 'pi') serveRequests(top, tmuxSocket(owner), join(top.dir, 'nested'), top.status.state !== 'running');
310
+ };
311
+
312
+ // Carries refreshed OAuth tokens between your credentials and each top-level job's copy, once more after the job ends.
313
+ const syncCredentials = (ctx: ExtensionContext): void => {
314
+ if (insideJob()) return;
315
+ for (const job of list(jobsRoot(), ctx.sessionManager.getSessionId())) {
316
+ const copy = jobAgentDir(job.dir);
317
+ if (!existsSync(join(copy, 'auth.json')) || existsSync(join(job.dir, 'tokens-synced'))) continue;
318
+ if (syncTokens(getAgentDir(), copy) && job.status.state !== 'running') writeFileSync(join(job.dir, 'tokens-synced'), '');
319
+ }
320
+ };
321
+
322
+ // Each step runs on its own, so one failing does not stop the others.
323
+ const tick = (ctx: ExtensionContext): void => {
324
+ for (const step of [() => syncCredentials(ctx), () => serve(ctx), () => interactive(ctx) && deliverFinished(ctx)]) {
325
+ try {
326
+ step();
327
+ } catch (error) {
328
+ if (ctx.hasUI) ctx.ui.notify(`pstack job watcher: ${error instanceof Error ? error.message : String(error)}`, 'error');
329
+ }
330
+ }
331
+ };
332
+
333
+ pi.on('session_start', async (_event, ctx) => {
334
+ clearInterval(watcher);
335
+ watcher = setInterval(() => tick(ctx), POLL_MS);
336
+ });
337
+
338
+ pi.on('session_shutdown', async (_event, ctx) => {
339
+ clearInterval(watcher);
340
+ watcher = undefined;
341
+ // A print-mode worker's leftover jobs, such as a dev server it never stopped, end with it.
342
+ if (interactive(ctx)) return;
343
+ try {
344
+ execFileSync('tmux', ['-S', tmuxSocket(ctx.sessionManager.getSessionId()), 'kill-server'], { stdio: 'ignore' });
345
+ } catch {
346
+ // It started no jobs.
347
+ }
348
+ });
349
+
350
+ // A print-mode run would exit while its jobs still run, so it waits for them and continues with their reports.
351
+ pi.on('agent_before_settle', async (event, ctx) => {
352
+ if (interactive(ctx)) return;
353
+ const owner = ctx.sessionManager.getSessionId();
354
+ const pending = () => list(jobsRoot(), owner).filter((job) => job.spec.wake !== null && !job.spec.repeat && !existsSync(join(job.dir, 'woken')));
355
+ if (pending().length === 0) return;
356
+ while (pending().some((job) => job.status.state === 'running')) await new Promise((done) => setTimeout(done, POLL_MS));
357
+ syncCredentials(ctx);
358
+ const finished = pending().filter(claimWake);
359
+ return {
360
+ entries: [...event.entries, ...finished.map((job) => ({ type: 'custom_message' as const, customType: 'pstack-job', content: finish(job), display: true }))],
361
+ continue: true,
362
+ };
363
+ });
364
+
365
+ pi.on('before_agent_start', async (event, ctx) => {
366
+ const options = event.systemPromptOptions;
367
+ for (const rule of [...rules, skillsHint]) if (!options.promptGuidelines.includes(rule)) options.promptGuidelines.push(rule);
368
+ const transcript = ctx.sessionManager.getSessionFile();
369
+ if (transcript)
370
+ options.sections['pstack-session'] =
371
+ `This session's transcript is ${transcript}. A worker's Pi agent directory is its job's own, so it cannot find this file by itself. Put the path in any brief that asks a worker to read the transcript.`;
372
+ if (insideJob()) options.sections['pstack-sandbox'] = SANDBOX_NOTE;
373
+ const models = modelsFile(getAgentDir());
374
+ if (existsSync(models)) options.sections['pstack-models'] = `Role lines from ${models}, written by /skill:setup-pstack:\n${readFileSync(models, 'utf8').trim()}`;
375
+ });
376
+
377
+ if (!startedByWorker()) {
378
+ pi.registerTool({
379
+ name: 'pi_spawn',
380
+ label: 'Spawn Pi',
381
+ description:
382
+ 'Start a separate Pi process in its own tmux session, inside a Seatbelt (macOS) or bubblewrap (Linux) sandbox, with a standalone brief. It runs in parallel and does not see this conversation. When it exits you are woken with its final report. Each call starts one fresh instance; to start several, call pi_spawn several times in one message. A Pi it starts can start workers too, and those workers cannot.',
383
+ promptSnippet: 'Start a parallel Pi instance in tmux with a standalone brief, then get woken with its report',
384
+ promptGuidelines: [
385
+ 'Use pi_spawn wherever a pstack skill says to spawn a worker, delegate, explorer, reviewer, or Pi instance. Pi has no subagents.',
386
+ 'Write each pi_spawn brief so it stands alone. The spawned Pi sees only the brief, never this conversation.',
387
+ ],
388
+ parameters: Type.Object({
389
+ name: Type.String({ description: 'Short label for the job, such as "explorer-auth" or "runner-2".' }),
390
+ brief: Type.String({ description: 'The complete standalone prompt for the spawned Pi.' }),
391
+ agent: Type.Optional(stringEnum(AGENTS, `Role instructions from pstack agents/<agent>.md, appended to the spawned system prompt. Roles:\n${agentRoles.join('\n')}`)),
392
+ model: Type.Optional(Type.String({ description: 'provider/id as `pi --list-models` prints it. Omit to use this session model.' })),
393
+ thinking: Type.Optional(stringEnum(THINKING, 'Thinking level. Omit to use the model default.')),
394
+ readonly: Type.Optional(Type.Boolean({ description: 'Deny writes to the project and remove the edit and write tools. Temp directories stay writable. Default false.' })),
395
+ worktree: Type.Optional(Type.String({ description: 'Branch for a new git worktree the spawned Pi works in, created from base. Writes are confined to that worktree.' })),
396
+ base: Type.Optional(Type.String({ description: "Ref the new worktree branch starts from. Default is this session's current HEAD, not the repository's default branch, so pass the default branch to start from it." })),
397
+ cwd: Type.Optional(Type.String({ description: 'Working directory inside this project when no worktree is requested. Default this session cwd.' })),
398
+ resume: Type.Optional(Type.String({ description: 'Job id of a finished pi_spawn job whose session the brief continues. Use only when that session holds state too costly to move.' })),
399
+ wake: Type.Optional(Type.Boolean({ description: 'Wake this session with the report when the job exits. Default true.' })),
400
+ }),
401
+ async execute(_id, params, _signal, _update, ctx) {
402
+ const root = jobsRoot();
403
+ const id = newJobId(params.name);
404
+ const dir = join(root, id);
405
+ const owner = ctx.sessionManager.getSessionId();
406
+ const prior = params.resume === undefined ? undefined : read(root, params.resume, owner);
407
+ if (params.resume !== undefined && (prior === undefined || prior.spec.kind !== 'pi' || prior.status.state === 'running')) {
408
+ throw new Error(`resume needs a finished pi_spawn job id from this session, got "${params.resume}".`);
409
+ }
410
+ if (params.resume !== undefined && params.worktree !== undefined) throw new Error('resume continues in the earlier job checkout, so it cannot take a worktree.');
411
+ // A resumed worker keeps the model, thinking level, role, and readonly it started with unless the call says otherwise.
412
+ const earlier = prior?.spec.command ?? [];
413
+ const model = resolveModel(ctx, params.model ?? flagValue(earlier, '--model'));
414
+ const thinking = params.thinking ?? flagValue(earlier, '--thinking');
415
+ const priorRole = flagValue(earlier, '--append-system-prompt') && prior ? join(prior.dir, 'agent.md') : undefined;
416
+ // Refreshing the worker's credentials now, under Pi's lock, means a worker rarely has to refresh one itself.
417
+ const provider = model?.slice(0, model.indexOf('/'));
418
+ const chosen = model && provider ? ctx.modelRegistry.find(provider, model.slice(model.indexOf('/') + 1)) : undefined;
419
+ if (chosen) await ctx.modelRegistry.getApiKeyAndHeaders(chosen).catch(() => undefined);
420
+ // A job's credentials copy holds no commands, so the worker's own provider gets its command resolved here, once.
421
+ const resolved: Record<string, string> = {};
422
+ if (provider && !insideJob() && commandProviders(getAgentDir()).includes(provider)) {
423
+ const key = await ctx.modelRegistry.getApiKeyForProvider(provider).catch(() => undefined);
424
+ if (key) resolved[provider] = key;
425
+ }
426
+ const base = prior?.spec.cwd ?? projectPath(ctx, params.cwd);
427
+ const readonly = params.readonly ?? earlier.includes('--exclude-tools');
428
+ // The job directory itself stays read-only to the worker, so it cannot rewrite its own spec or exit code.
429
+ const sessionDir = (prior && flagValue(earlier, '--session-dir')) || join(dir, 'session');
430
+ const writable = [sessionDir, join(dir, 'nested')];
431
+ let createdBranch = false;
432
+ try {
433
+ for (const path of writable) mkdirSync(path, { recursive: true });
434
+ const cwd = params.worktree !== undefined && prior === undefined ? join(dir, 'worktree') : base;
435
+ if (cwd !== base && params.worktree !== undefined) createdBranch = addWorktree(base, cwd, params.worktree, params.base);
436
+ const common = gitPath(cwd, '--git-common-dir');
437
+ if (!readonly) writable.push(cwd, ...(common ? [common] : []));
438
+ const guarded = protectedPaths(cwd, common);
439
+ const piCommand = process.argv[1] && isAbsolute(process.argv[1]) ? [process.execPath, process.argv[1]] : ['pi'];
440
+ const argv = [
441
+ ...piCommand,
442
+ '-p',
443
+ '--session-dir',
444
+ sessionDir,
445
+ ...(prior ? ['--continue'] : []),
446
+ ...(model ? ['--model', model] : []),
447
+ ...(thinking ? ['--thinking', thinking] : []),
448
+ ...(params.agent || priorRole ? ['--append-system-prompt', join(dir, 'agent.md')] : []),
449
+ ...(readonly ? ['--exclude-tools', 'edit,write'] : []),
450
+ ctx.isProjectTrusted() ? '--approve' : '--no-approve',
451
+ `@${join(dir, 'brief.md')}`,
452
+ ];
453
+ const files: Record<string, string> = { 'brief.md': params.brief };
454
+ if (params.agent) files['agent.md'] = stripFrontmatter(readFileSync(join(packageRoot, 'agents', `${params.agent}.md`), 'utf8'));
455
+ else if (priorRole) files['agent.md'] = readFileSync(priorRole, 'utf8');
456
+ const spec: JobSpec = {
457
+ id,
458
+ name: params.name,
459
+ kind: 'pi',
460
+ cwd,
461
+ argv: [],
462
+ command: argv,
463
+ policy: { writable, protect: guarded.protect, lock: guarded.lock, gitDirs: guarded.gitDirs, checkouts: [], credentials: '', agentDir: getAgentDir(), jobDir: dir },
464
+ brokered: false,
465
+ owner,
466
+ wake: params.wake === false ? null : 'Review this report against the brief and inspect the artifacts it names before you rely on it.',
467
+ repeat: false,
468
+ series: id,
469
+ socket: brokering() ? '' : tmuxSocket(owner),
470
+ sweep: { roots: [], protect: [] },
471
+ out: dir,
472
+ createdAt: new Date().toISOString(),
473
+ };
474
+ const job = start(root, spec, files, resolved);
475
+ return text(`Started ${describe(job)}\n cwd: ${cwd}${spec.wake ? '\nYou will be woken with its report when it exits. Keep working or end your turn.' : ''}`);
476
+ } catch (error) {
477
+ rmSync(dir, { recursive: true, force: true });
478
+ if (params.worktree !== undefined && gitPath(base, '--git-common-dir')) {
479
+ git(base, ['worktree', 'prune']);
480
+ if (createdBranch) git(base, ['branch', '-D', params.worktree]);
481
+ }
482
+ throw error;
483
+ }
484
+ },
485
+ });
486
+ }
487
+
488
+ pi.registerTool({
489
+ name: 'tmux_run',
490
+ label: 'Run in tmux',
491
+ description:
492
+ 'Run a shell command in its own tmux session, inside the pstack sandbox, instead of a background shell. Use it for watchers, dev servers, long builds, and heartbeat timers. With wake set, you are woken with that message and the output tail when the command exits. With repeat, the command restarts each time it exits cleanly, so `sleep 3600` plus a wake message is an hourly tick. The shared /tmp is read-only to the command, so it keeps temp files in $TMPDIR, its own temp directory.',
493
+ promptSnippet: 'Run a long-lived or watched command in tmux and get woken when it exits',
494
+ promptGuidelines: ['Use tmux_run for any command that would otherwise run in the background. Never background a command with &, nohup, setsid, or disown.'],
495
+ parameters: Type.Object({
496
+ name: Type.String({ description: 'Short label, such as "watch-pr-123" or "dev-server".' }),
497
+ command: Type.String({ description: 'Shell command, run with bash -c.' }),
498
+ cwd: Type.Optional(Type.String({ description: 'Working directory inside this project. Default this session cwd. The command may write only here, in its git directory, and in temp directories.' })),
499
+ wake: Type.Optional(Type.String({ description: 'Message to wake this session with when the command exits. Omit for a server you will stop yourself.' })),
500
+ repeat: Type.Optional(Type.Boolean({ description: 'Restart the command after each clean exit and wake each time. Requires wake. Stop it with tmux_jobs stop.' })),
501
+ }),
502
+ async execute(_id, params, _signal, _update, ctx) {
503
+ if (params.repeat && params.wake === undefined) throw new Error('repeat needs a wake message, or nothing would ever notice the ticks.');
504
+ const root = jobsRoot();
505
+ const id = newJobId(params.name);
506
+ const owner = ctx.sessionManager.getSessionId();
507
+ const cwd = projectPath(ctx, params.cwd);
508
+ const common = gitPath(cwd, '--git-common-dir');
509
+ const guarded = protectedPaths(cwd, common);
510
+ const policy = { writable: [cwd, ...(common ? [common] : [])], protect: guarded.protect, lock: guarded.lock, gitDirs: guarded.gitDirs, checkouts: [], credentials: '', agentDir: getAgentDir(), jobDir: join(root, id) };
511
+ const spec: JobSpec = {
512
+ id,
513
+ name: params.name,
514
+ kind: 'command',
515
+ cwd,
516
+ argv: [],
517
+ command: ['bash', '-c', params.command],
518
+ policy,
519
+ brokered: false,
520
+ owner,
521
+ wake: params.wake ?? null,
522
+ repeat: params.repeat ?? false,
523
+ series: id,
524
+ socket: brokering() ? '' : tmuxSocket(owner),
525
+ sweep: { roots: [], protect: [] },
526
+ out: join(root, id),
527
+ createdAt: new Date().toISOString(),
528
+ };
529
+ try {
530
+ return text(`Started ${describe(start(root, spec))}`);
531
+ } catch (error) {
532
+ rmSync(join(root, id), { recursive: true, force: true });
533
+ throw error;
534
+ }
535
+ },
536
+ });
537
+
538
+ pi.registerTool({
539
+ name: 'tmux_jobs',
540
+ label: 'tmux jobs',
541
+ description:
542
+ "Inspect or control this session's pi_spawn and tmux_run jobs. list shows every job with its state and a command to follow its output. output prints the last lines of one job. wait blocks until the named jobs (default all running) exit or the timeout passes, then returns their reports. stop ends jobs, and every later run of a repeating one, and suppresses their wake.",
543
+ parameters: Type.Object({
544
+ action: stringEnum(['list', 'output', 'wait', 'stop'] as const),
545
+ ids: Type.Optional(Type.Array(Type.String(), { description: 'Job ids. Required for output and stop.' })),
546
+ lines: Type.Optional(Type.Number({ description: 'Lines for output. Default 80.' })),
547
+ timeout_seconds: Type.Optional(Type.Number({ description: 'Longest wait. Default 1800.' })),
548
+ }),
549
+ async execute(_id, params, signal, update, ctx) {
550
+ const root = jobsRoot();
551
+ const owner = ctx.sessionManager.getSessionId();
552
+ const named = (): Job[] => {
553
+ if (!params.ids?.length) throw new Error(`${params.action} needs ids.`);
554
+ return params.ids.map((id) => {
555
+ const job = read(root, id, owner);
556
+ if (!job) throw new Error(`No job ${id} in this session.`);
557
+ return job;
558
+ });
559
+ };
560
+ switch (params.action) {
561
+ case 'list': {
562
+ const jobs = list(root, owner);
563
+ return text(jobs.length ? jobs.map(describe).join('\n') : 'No jobs in this session.');
564
+ }
565
+ case 'output':
566
+ return text(
567
+ named()
568
+ .map((job) => `${describe(job)}\n${tail(outputPath(job.spec.out), params.lines ?? 80)}`)
569
+ .join('\n\n'),
570
+ );
571
+ case 'stop': {
572
+ const series = new Set(named().map((job) => job.spec.series));
573
+ // Recorded before stopping, so a run that finishes meanwhile is not restarted into a run this stop misses.
574
+ for (const id of series) stoppedSeries.add(id);
575
+ // Every run in the series, finished ones included, so a run that just exited is not restarted after the stop.
576
+ const jobs = list(root, owner).filter((job) => series.has(job.spec.series));
577
+ await Promise.all(jobs.map(stop));
578
+ return text(`Stopped ${jobs.map((job) => job.spec.id).join(', ')}.`);
579
+ }
580
+ case 'wait': {
581
+ const ids = params.ids?.length
582
+ ? params.ids
583
+ : list(root, owner)
584
+ // A heartbeat never stops on its own, so waiting on everything leaves heartbeats out.
585
+ .filter((job) => job.status.state === 'running' && !job.spec.repeat)
586
+ .map((job) => job.spec.id);
587
+ const deadline = Date.now() + (params.timeout_seconds ?? 1800) * 1000;
588
+ const current = () => ids.map((id) => read(root, id, owner)).filter((job): job is Job => job !== undefined);
589
+ for (const id of ids) awaited.add(id);
590
+ try {
591
+ while (current().some((job) => job.status.state === 'running') && Date.now() < deadline && !signal?.aborted) {
592
+ update?.(text(`Waiting on ${current().filter((job) => job.status.state === 'running').length} job(s)...`));
593
+ await new Promise((done) => setTimeout(done, POLL_MS));
594
+ }
595
+ const jobs = current();
596
+ // A job whose wake the watcher already delivered is reported plainly, without restarting a heartbeat twice.
597
+ const reports = jobs.map((job) => (job.status.state === 'running' ? `${describe(job)}\n still running` : claimWake(job) ? finish(job) : report(job)));
598
+ return text(reports.join('\n\n') || 'No jobs to wait on.');
599
+ } finally {
600
+ for (const id of ids) awaited.delete(id);
601
+ }
602
+ }
603
+ default: {
604
+ const unreachable: never = params.action;
605
+ throw new Error(`Unknown action ${String(unreachable)}`);
606
+ }
607
+ }
608
+ },
609
+ });
610
+ }