open-pstack 0.0.0-stage → 0.9.150
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.
- package/LICENSE +22 -0
- package/LICENSE-cursor-team-kit +21 -0
- package/LICENSE-thermos +21 -0
- package/NOTICE-skills.md +13 -0
- package/NOTICE.md +62 -0
- package/bin/open-pstack.mjs +4 -0
- package/lib/bundle.mjs +42 -0
- package/lib/cli.mjs +211 -0
- package/lib/detect.mjs +28 -0
- package/lib/harnesses.mjs +136 -0
- package/lib/steps.mjs +93 -0
- package/package.json +30 -4
- package/plugin/.antigravity-plugin/plugin.json +8 -0
- package/plugin/.claude-plugin/icon.png +0 -0
- package/plugin/.claude-plugin/plugin.json +31 -0
- package/plugin/.codex-plugin/plugin.json +52 -0
- package/plugin/.github/plugin/plugin.json +15 -0
- package/plugin/.grok-plugin/plugin.json +9 -0
- package/plugin/.muse-plugin/plugin.json +381 -0
- package/plugin/LICENSE +22 -0
- package/plugin/README.md +27 -0
- package/plugin/agents/comment-sicko.md +34 -0
- package/plugin/agents/poteto-agent.md +8 -0
- package/plugin/agents/thermo-nuclear-code-quality-review-subagent.md +23 -0
- package/plugin/agents/thermo-nuclear-review-subagent.md +28 -0
- package/plugin/assets/pstack-icon.png +0 -0
- package/plugin/assets/pstack-icon.prompt.txt +8 -0
- package/plugin/grok/skills/pstack-routing/SKILL.md +8 -0
- package/plugin/hooks/agy-context.awk +9 -0
- package/plugin/hooks/codex-hooks.json +17 -0
- package/plugin/hooks/copilot-context.awk +44 -0
- package/plugin/hooks/copilot-hooks.json +29 -0
- package/plugin/hooks/hooks.json +16 -0
- package/plugin/hooks/json.awk +164 -0
- package/plugin/hooks/kimi-instructions.md +17 -0
- package/plugin/hooks/muse-context.awk +31 -0
- package/plugin/hooks/pre-tool-use.awk +152 -0
- package/plugin/hooks/pre-tool-use.sh +16 -0
- package/plugin/hooks/script-contracts.awk +53 -0
- package/plugin/hooks/session-start-agy.md +17 -0
- package/plugin/hooks/session-start-context.md +15 -0
- package/plugin/hooks/session-start-copilot-setup.md +1 -0
- package/plugin/hooks/session-start-copilot-sheet.md +1 -0
- package/plugin/hooks/session-start-copilot.md +3 -0
- package/plugin/hooks/session-start-minimax.md +17 -0
- package/plugin/hooks/session-start-muse-sheet.md +1 -0
- package/plugin/hooks/session-start-muse.md +17 -0
- package/plugin/hooks/session-start-opencode.md +17 -0
- package/plugin/hooks/session-start.ps1 +169 -0
- package/plugin/hooks/session-start.sh +107 -0
- package/plugin/hooks.json +10 -0
- package/plugin/models.json +60 -0
- package/plugin/omp/index.mjs +34 -0
- package/plugin/opencode/index.js +49 -0
- package/plugin/package.json +8 -0
- package/plugin/pi/agent-files.ts +117 -0
- package/plugin/pi/agent-text.ts +99 -0
- package/plugin/pi/agent-tools.ts +148 -0
- package/plugin/pi/agents.ts +510 -0
- package/plugin/pi/ask.ts +87 -0
- package/plugin/pi/child.ts +313 -0
- package/plugin/pi/config.ts +208 -0
- package/plugin/pi/hc-child.ts +210 -0
- package/plugin/pi/index.ts +45 -0
- package/plugin/pi/one-shot.ts +90 -0
- package/plugin/pi/path-skills.ts +54 -0
- package/plugin/pi/prompt.ts +39 -0
- package/plugin/pi/schedule.ts +254 -0
- package/plugin/pi/slash.ts +106 -0
- package/plugin/pi/sleep-wait.ts +76 -0
- package/plugin/pi/worktree.ts +87 -0
- package/plugin/skills/architect/SKILL.md +20 -0
- package/plugin/skills/arena/SKILL.md +66 -0
- package/plugin/skills/automate-me/SKILL.md +111 -0
- package/plugin/skills/babysit/SKILL.md +68 -0
- package/plugin/skills/benchmark-checklist/SKILL.md +38 -0
- package/plugin/skills/blast-radius/SKILL.md +49 -0
- package/plugin/skills/bro/SKILL.md +6 -0
- package/plugin/skills/correct/SKILL.md +31 -0
- package/plugin/skills/create-formal-verification-skill/SKILL.md +50 -0
- package/plugin/skills/create-verification-skill/SKILL.md +51 -0
- package/plugin/skills/create-verification-skill/references/feature-map-example/README.md +47 -0
- package/plugin/skills/create-verification-skill/references/feature-map-example/create-note.md +39 -0
- package/plugin/skills/create-verification-skill/references/feature-map-example/search.md +45 -0
- package/plugin/skills/deslop/SKILL.md +24 -0
- package/plugin/skills/figure-it-out/SKILL.md +51 -0
- package/plugin/skills/fix-ci/SKILL.md +29 -0
- package/plugin/skills/fix-merge-conflicts/SKILL.md +32 -0
- package/plugin/skills/get-pr-comments/SKILL.md +23 -0
- package/plugin/skills/how/SKILL.md +28 -0
- package/plugin/skills/in-your-own-words/SKILL.md +6 -0
- package/plugin/skills/interrogate/SKILL.md +48 -0
- package/plugin/skills/ketchup/SKILL.md +42 -0
- package/plugin/skills/ketchup-video/SKILL.md +28 -0
- package/plugin/skills/maintain-formal-verification-skill/SKILL.md +65 -0
- package/plugin/skills/maintain-verification-skill/SKILL.md +46 -0
- package/plugin/skills/make-pr-easy-to-review/SKILL.md +59 -0
- package/plugin/skills/no-comments/SKILL.md +45 -0
- package/plugin/skills/poteto-help/SKILL.md +148 -0
- package/plugin/skills/poteto-help/references/prompting.md +51 -0
- package/plugin/skills/poteto-help/references/recipes.md +51 -0
- package/plugin/skills/poteto-mode/SKILL.md +132 -0
- package/plugin/skills/poteto-mode/playbooks/authoring-a-skill.md +12 -0
- package/plugin/skills/poteto-mode/playbooks/autonomous-run.md +13 -0
- package/plugin/skills/poteto-mode/playbooks/autopilot-full.md +31 -0
- package/plugin/skills/poteto-mode/playbooks/autopilot-stack.md +8 -0
- package/plugin/skills/poteto-mode/playbooks/babysit.md +10 -0
- package/plugin/skills/poteto-mode/playbooks/bug-fix.md +32 -0
- package/plugin/skills/poteto-mode/playbooks/eval.md +25 -0
- package/plugin/skills/poteto-mode/playbooks/feature.md +21 -0
- package/plugin/skills/poteto-mode/playbooks/hillclimb.md +21 -0
- package/plugin/skills/poteto-mode/playbooks/investigation.md +14 -0
- package/plugin/skills/poteto-mode/playbooks/multi-phase-plan.md +13 -0
- package/plugin/skills/poteto-mode/playbooks/opening-a-pr.md +9 -0
- package/plugin/skills/poteto-mode/playbooks/pause-safely.md +11 -0
- package/plugin/skills/poteto-mode/playbooks/perf-issue.md +25 -0
- package/plugin/skills/poteto-mode/playbooks/prototype.md +14 -0
- package/plugin/skills/poteto-mode/playbooks/refactoring.md +18 -0
- package/plugin/skills/poteto-mode/playbooks/runtime-forensics.md +11 -0
- package/plugin/skills/poteto-mode/playbooks/session-pickup.md +11 -0
- package/plugin/skills/poteto-mode/playbooks/shipping.md +16 -0
- package/plugin/skills/poteto-mode/playbooks/trace-forensics.md +14 -0
- package/plugin/skills/poteto-mode/playbooks/visual-parity.md +11 -0
- package/plugin/skills/poteto-mode/playbooks/worktree-cleanup.md +12 -0
- package/plugin/skills/poteto-mode/references/agents/comment-sicko.md +34 -0
- package/plugin/skills/poteto-mode/references/agy-tools.md +100 -0
- package/plugin/skills/poteto-mode/references/bugbot-triage.md +142 -0
- package/plugin/skills/poteto-mode/references/cloud-session-pr-reads.md +29 -0
- package/plugin/skills/poteto-mode/references/codex-tools.md +110 -0
- package/plugin/skills/poteto-mode/references/copilot-tools.md +144 -0
- package/plugin/skills/poteto-mode/references/dsh-tools.md +51 -0
- package/plugin/skills/poteto-mode/references/grok.md +50 -0
- package/plugin/skills/poteto-mode/references/kimi-tools.md +40 -0
- package/plugin/skills/poteto-mode/references/licenses/LICENSE +22 -0
- package/plugin/skills/poteto-mode/references/licenses/LICENSE-cursor-team-kit +21 -0
- package/plugin/skills/poteto-mode/references/licenses/LICENSE-thermos +21 -0
- package/plugin/skills/poteto-mode/references/licenses/NOTICE.md +13 -0
- package/plugin/skills/poteto-mode/references/merge-safety.md +43 -0
- package/plugin/skills/poteto-mode/references/minimax-tools.md +93 -0
- package/plugin/skills/poteto-mode/references/muse-tools.md +105 -0
- package/plugin/skills/poteto-mode/references/omp-tools.md +45 -0
- package/plugin/skills/poteto-mode/references/opencode-tools.md +30 -0
- package/plugin/skills/poteto-mode/references/pi-tools.md +120 -0
- package/plugin/skills/poteto-mode/references/resume-storage.md +20 -0
- package/plugin/skills/poteto-mode/scripts/.prettierignore +19 -0
- package/plugin/skills/poteto-mode/scripts/.prettierrc.json +3 -0
- package/plugin/skills/poteto-mode/scripts/bootstrap.ts +71 -0
- package/plugin/skills/poteto-mode/scripts/bun.lock +67 -0
- package/plugin/skills/poteto-mode/scripts/check-playbooks.mjs +165 -0
- package/plugin/skills/poteto-mode/scripts/codex-session-effort.mjs +94 -0
- package/plugin/skills/poteto-mode/scripts/package.json +16 -0
- package/plugin/skills/poteto-mode/scripts/resume.mjs +139 -0
- package/plugin/skills/poteto-mode/scripts/tsconfig.json +14 -0
- package/plugin/skills/poteto-mode/scripts/watch-pr/check-suites.ts +203 -0
- package/plugin/skills/poteto-mode/scripts/watch-pr/cli.port.test.ts +88 -0
- package/plugin/skills/poteto-mode/scripts/watch-pr/cli.test.ts +383 -0
- package/plugin/skills/poteto-mode/scripts/watch-pr/cli.ts +283 -0
- package/plugin/skills/poteto-mode/scripts/watch-pr/deadline.ts +20 -0
- package/plugin/skills/poteto-mode/scripts/watch-pr/fakes.test-helper.ts +163 -0
- package/plugin/skills/poteto-mode/scripts/watch-pr/fresh-install.test.ts +35 -0
- package/plugin/skills/poteto-mode/scripts/watch-pr/github.port.test.ts +1119 -0
- package/plugin/skills/poteto-mode/scripts/watch-pr/github.test.ts +506 -0
- package/plugin/skills/poteto-mode/scripts/watch-pr/github.ts +979 -0
- package/plugin/skills/poteto-mode/scripts/watch-pr/head-checks.ts +37 -0
- package/plugin/skills/poteto-mode/scripts/watch-pr/integrity.test.ts +887 -0
- package/plugin/skills/poteto-mode/scripts/watch-pr/landing.ts +92 -0
- package/plugin/skills/poteto-mode/scripts/watch-pr/live-merge-safety.mjs +142 -0
- package/plugin/skills/poteto-mode/scripts/watch-pr/policy.port.test.ts +945 -0
- package/plugin/skills/poteto-mode/scripts/watch-pr/policy.test.ts +492 -0
- package/plugin/skills/poteto-mode/scripts/watch-pr/policy.ts +966 -0
- package/plugin/skills/poteto-mode/scripts/watch-pr/query-error.ts +36 -0
- package/plugin/skills/poteto-mode/scripts/watch-pr/render.ts +211 -0
- package/plugin/skills/poteto-mode/scripts/watch-pr/ship-pr +6 -0
- package/plugin/skills/poteto-mode/scripts/watch-pr/shipping-cli.test.ts +159 -0
- package/plugin/skills/poteto-mode/scripts/watch-pr/shipping-cli.ts +65 -0
- package/plugin/skills/poteto-mode/scripts/watch-pr/shipping.test-helper.ts +48 -0
- package/plugin/skills/poteto-mode/scripts/watch-pr/shipping.test.ts +360 -0
- package/plugin/skills/poteto-mode/scripts/watch-pr/shipping.ts +235 -0
- package/plugin/skills/poteto-mode/scripts/watch-pr/transport.test.ts +588 -0
- package/plugin/skills/poteto-mode/scripts/watch-pr/tsconfig.json +13 -0
- package/plugin/skills/poteto-mode/scripts/watch-pr/types.compile.ts +109 -0
- package/plugin/skills/poteto-mode/scripts/watch-pr/types.ts +502 -0
- package/plugin/skills/poteto-mode/scripts/watch-pr/watch-pr +6 -0
- package/plugin/skills/poteto-mode/scripts/watch-pr/workflow-runs.ts +217 -0
- package/plugin/skills/poteto-mode/scripts/watch-pr/wrapper.test.ts +20 -0
- package/plugin/skills/poteto-mode/scripts/worktree-audit.mjs +492 -0
- package/plugin/skills/poteto-mode/worker.md +11 -0
- package/plugin/skills/principle-attack-the-premise/SKILL.md +15 -0
- package/plugin/skills/principle-boundary-discipline/SKILL.md +11 -0
- package/plugin/skills/principle-build-the-lever/SKILL.md +15 -0
- package/plugin/skills/principle-encode-lessons-in-structure/SKILL.md +11 -0
- package/plugin/skills/principle-exhaust-the-design-space/SKILL.md +9 -0
- package/plugin/skills/principle-experience-first/SKILL.md +19 -0
- package/plugin/skills/principle-explain-the-number/SKILL.md +14 -0
- package/plugin/skills/principle-fix-root-causes/SKILL.md +14 -0
- package/plugin/skills/principle-foundational-thinking/SKILL.md +13 -0
- package/plugin/skills/principle-guard-the-context-window/SKILL.md +12 -0
- package/plugin/skills/principle-laziness-protocol/SKILL.md +10 -0
- package/plugin/skills/principle-make-operations-idempotent/SKILL.md +15 -0
- package/plugin/skills/principle-migrate-callers-then-delete-legacy-apis/SKILL.md +14 -0
- package/plugin/skills/principle-minimize-reader-load/SKILL.md +15 -0
- package/plugin/skills/principle-model-the-domain/SKILL.md +15 -0
- package/plugin/skills/principle-never-block-on-the-human/SKILL.md +15 -0
- package/plugin/skills/principle-outcome-oriented-execution/SKILL.md +21 -0
- package/plugin/skills/principle-prove-it-works/SKILL.md +17 -0
- package/plugin/skills/principle-redesign-from-first-principles/SKILL.md +16 -0
- package/plugin/skills/principle-separate-before-serializing-shared-state/SKILL.md +11 -0
- package/plugin/skills/principle-sequence-verifiable-units/SKILL.md +13 -0
- package/plugin/skills/principle-subtract-before-you-add/SKILL.md +18 -0
- package/plugin/skills/principle-test-behavior-not-implementation/SKILL.md +16 -0
- package/plugin/skills/principle-type-system-discipline/SKILL.md +15 -0
- package/plugin/skills/recall/SKILL.md +43 -0
- package/plugin/skills/reflect/SKILL.md +33 -0
- package/plugin/skills/reflect/scripts/claude-project-dir.mjs +121 -0
- package/plugin/skills/reflect/scripts/find-transcript.mjs +218 -0
- package/plugin/skills/setup-pstack/SKILL.md +104 -0
- package/plugin/skills/setup-pstack/copilot.md +88 -0
- package/plugin/skills/setup-pstack/references/runtimes.md +77 -0
- package/plugin/skills/setup-pstack/scripts/check-sheet.awk +10 -0
- package/plugin/skills/setup-pstack/scripts/check-sheet.sh +20 -0
- package/plugin/skills/setup-pstack/scripts/read-sheet.sh +24 -0
- package/plugin/skills/setup-pstack/scripts/sheet.awk +152 -0
- package/plugin/skills/sharpen/SKILL.md +15 -0
- package/plugin/skills/show-me-your-work/SKILL.md +89 -0
- package/plugin/skills/show-me-your-work/references/decision-log-template.tsv +1 -0
- package/plugin/skills/show-me-your-work/scripts/log.sh +58 -0
- package/plugin/skills/statechart/SKILL.md +81 -0
- package/plugin/skills/statechart/references/render.md +93 -0
- package/plugin/skills/statechart/scripts/backends/cfg.ts +33 -0
- package/plugin/skills/statechart/scripts/backends/mermaid.ts +249 -0
- package/plugin/skills/statechart/scripts/backends/plain-text.ts +72 -0
- package/plugin/skills/statechart/scripts/backends/report.ts +177 -0
- package/plugin/skills/statechart/scripts/bun.lock +17 -0
- package/plugin/skills/statechart/scripts/frontends/config.ts +276 -0
- package/plugin/skills/statechart/scripts/frontends/dot.ts +77 -0
- package/plugin/skills/statechart/scripts/frontends/marks.ts +93 -0
- package/plugin/skills/statechart/scripts/frontends/messages.ts +52 -0
- package/plugin/skills/statechart/scripts/frontends/spec.ts +114 -0
- package/plugin/skills/statechart/scripts/frontends/trace.ts +24 -0
- package/plugin/skills/statechart/scripts/frontends/value.ts +166 -0
- package/plugin/skills/statechart/scripts/frontends/verdict.ts +40 -0
- package/plugin/skills/statechart/scripts/frontends/view.ts +119 -0
- package/plugin/skills/statechart/scripts/ir.ts +547 -0
- package/plugin/skills/statechart/scripts/janitor.ts +13 -0
- package/plugin/skills/statechart/scripts/kill.ts +15 -0
- package/plugin/skills/statechart/scripts/package.json +11 -0
- package/plugin/skills/statechart/scripts/passes/annotate.ts +128 -0
- package/plugin/skills/statechart/scripts/passes/label.ts +269 -0
- package/plugin/skills/statechart/scripts/passes/lift.ts +85 -0
- package/plugin/skills/statechart/scripts/passes/loop-check.ts +68 -0
- package/plugin/skills/statechart/scripts/passes/paths.ts +60 -0
- package/plugin/skills/statechart/scripts/passes/reach.ts +135 -0
- package/plugin/skills/statechart/scripts/passes/region-check.ts +97 -0
- package/plugin/skills/statechart/scripts/passes/regions.ts +295 -0
- package/plugin/skills/statechart/scripts/pipeline.ts +76 -0
- package/plugin/skills/statechart/scripts/run.ts +545 -0
- package/plugin/skills/statechart/scripts/statechart +29 -0
- package/plugin/skills/statechart/scripts/statechart.ts +166 -0
- package/plugin/skills/statechart/scripts/test/ConfigOracle.java +63 -0
- package/plugin/skills/statechart/scripts/test/chart.test.ts +1253 -0
- package/plugin/skills/statechart/scripts/test/charts/Braces.mmd +7 -0
- package/plugin/skills/statechart/scripts/test/charts/Escapes.mmd +11 -0
- package/plugin/skills/statechart/scripts/test/charts/Phases.mmd +29 -0
- package/plugin/skills/statechart/scripts/test/child-env.test.ts +15 -0
- package/plugin/skills/statechart/scripts/test/cli.test.ts +1353 -0
- package/plugin/skills/statechart/scripts/test/config-fuzz.test.ts +263 -0
- package/plugin/skills/statechart/scripts/test/corpus/Counter/ChartRun.out +57 -0
- package/plugin/skills/statechart/scripts/test/corpus/Counter/Counter.cfg +3 -0
- package/plugin/skills/statechart/scripts/test/corpus/Counter/Counter.tla +10 -0
- package/plugin/skills/statechart/scripts/test/corpus/Counter/chart.mmd +9 -0
- package/plugin/skills/statechart/scripts/test/corpus/Counter/graph.dot +16 -0
- package/plugin/skills/statechart/scripts/test/corpus/Counter/report.md +7 -0
- package/plugin/skills/statechart/scripts/test/corpus/Counter/sany.out +2 -0
- package/plugin/skills/statechart/scripts/test/corpus/Counter/verdict-1.out +49 -0
- package/plugin/skills/statechart/scripts/test/corpus/CounterAction/ChartRun.out +60 -0
- package/plugin/skills/statechart/scripts/test/corpus/CounterAction/CounterAction.cfg +4 -0
- package/plugin/skills/statechart/scripts/test/corpus/CounterAction/CounterAction.tla +22 -0
- package/plugin/skills/statechart/scripts/test/corpus/CounterAction/chart.mmd +26 -0
- package/plugin/skills/statechart/scripts/test/corpus/CounterAction/graph.dot +19 -0
- package/plugin/skills/statechart/scripts/test/corpus/CounterAction/report.md +20 -0
- package/plugin/skills/statechart/scripts/test/corpus/CounterAction/sany.out +2 -0
- package/plugin/skills/statechart/scripts/test/corpus/CounterAction/verdict-1.exit +1 -0
- package/plugin/skills/statechart/scripts/test/corpus/CounterAction/verdict-1.out +56 -0
- package/plugin/skills/statechart/scripts/test/corpus/CounterAction/verdict-2.exit +1 -0
- package/plugin/skills/statechart/scripts/test/corpus/CounterAction/verdict-2.out +82 -0
- package/plugin/skills/statechart/scripts/test/corpus/CounterAction/verdict-3.out +57 -0
- package/plugin/skills/statechart/scripts/test/corpus/CounterDeadlock/ChartRun.out +59 -0
- package/plugin/skills/statechart/scripts/test/corpus/CounterDeadlock/CounterDeadlock.cfg +3 -0
- package/plugin/skills/statechart/scripts/test/corpus/CounterDeadlock/CounterDeadlock.tla +11 -0
- package/plugin/skills/statechart/scripts/test/corpus/CounterDeadlock/chart.mmd +22 -0
- package/plugin/skills/statechart/scripts/test/corpus/CounterDeadlock/graph.dot +16 -0
- package/plugin/skills/statechart/scripts/test/corpus/CounterDeadlock/report.md +17 -0
- package/plugin/skills/statechart/scripts/test/corpus/CounterDeadlock/sany.out +2 -0
- package/plugin/skills/statechart/scripts/test/corpus/CounterDeadlock/verdict-1.exit +1 -0
- package/plugin/skills/statechart/scripts/test/corpus/CounterDeadlock/verdict-1.out +56 -0
- package/plugin/skills/statechart/scripts/test/corpus/CounterDeadlock/verdict-2.exit +1 -0
- package/plugin/skills/statechart/scripts/test/corpus/CounterDeadlock/verdict-2.out +77 -0
- package/plugin/skills/statechart/scripts/test/corpus/CounterFan/ChartRun.out +69 -0
- package/plugin/skills/statechart/scripts/test/corpus/CounterFan/CounterFan.cfg +2 -0
- package/plugin/skills/statechart/scripts/test/corpus/CounterFan/CounterFan.tla +11 -0
- package/plugin/skills/statechart/scripts/test/corpus/CounterFan/chart.mmd +85 -0
- package/plugin/skills/statechart/scripts/test/corpus/CounterFan/graph.dot +70 -0
- package/plugin/skills/statechart/scripts/test/corpus/CounterFan/report.md +12 -0
- package/plugin/skills/statechart/scripts/test/corpus/CounterFan/sany.out +2 -0
- package/plugin/skills/statechart/scripts/test/corpus/CounterFan/verdict-1.exit +1 -0
- package/plugin/skills/statechart/scripts/test/corpus/CounterFan/verdict-1.out +67 -0
- package/plugin/skills/statechart/scripts/test/corpus/CounterFan/verdict-2.out +57 -0
- package/plugin/skills/statechart/scripts/test/corpus/CounterGuard/ChartRun.exit +1 -0
- package/plugin/skills/statechart/scripts/test/corpus/CounterGuard/ChartRun.out +85 -0
- package/plugin/skills/statechart/scripts/test/corpus/CounterGuard/CounterGuard.cfg +6 -0
- package/plugin/skills/statechart/scripts/test/corpus/CounterGuard/CounterGuard.tla +13 -0
- package/plugin/skills/statechart/scripts/test/corpus/CounterGuard/chart.mmd +5 -0
- package/plugin/skills/statechart/scripts/test/corpus/CounterGuard/graph.dot +10 -0
- package/plugin/skills/statechart/scripts/test/corpus/CounterGuard/report.md +31 -0
- package/plugin/skills/statechart/scripts/test/corpus/CounterGuard/sany.out +2 -0
- package/plugin/skills/statechart/scripts/test/corpus/CounterGuard/verdict-1.exit +1 -0
- package/plugin/skills/statechart/scripts/test/corpus/CounterGuard/verdict-1.out +64 -0
- package/plugin/skills/statechart/scripts/test/corpus/CounterGuard/verdict-2.exit +1 -0
- package/plugin/skills/statechart/scripts/test/corpus/CounterGuard/verdict-2.out +77 -0
- package/plugin/skills/statechart/scripts/test/corpus/CounterInitPast/ChartRun.out +55 -0
- package/plugin/skills/statechart/scripts/test/corpus/CounterInitPast/CounterInitPast.cfg +3 -0
- package/plugin/skills/statechart/scripts/test/corpus/CounterInitPast/CounterInitPast.tla +10 -0
- package/plugin/skills/statechart/scripts/test/corpus/CounterInitPast/chart.mmd +12 -0
- package/plugin/skills/statechart/scripts/test/corpus/CounterInitPast/graph.dot +6 -0
- package/plugin/skills/statechart/scripts/test/corpus/CounterInitPast/report.md +12 -0
- package/plugin/skills/statechart/scripts/test/corpus/CounterInitPast/sany.out +2 -0
- package/plugin/skills/statechart/scripts/test/corpus/CounterInitPast/verdict-1.exit +1 -0
- package/plugin/skills/statechart/scripts/test/corpus/CounterInitPast/verdict-1.out +33 -0
- package/plugin/skills/statechart/scripts/test/corpus/CounterInitPast/verdict-2.out +54 -0
- package/plugin/skills/statechart/scripts/test/corpus/CounterInitPastHolds/ChartRun.out +54 -0
- package/plugin/skills/statechart/scripts/test/corpus/CounterInitPastHolds/CounterInitPastHolds.cfg +3 -0
- package/plugin/skills/statechart/scripts/test/corpus/CounterInitPastHolds/CounterInitPastHolds.tla +10 -0
- package/plugin/skills/statechart/scripts/test/corpus/CounterInitPastHolds/chart.mmd +1 -0
- package/plugin/skills/statechart/scripts/test/corpus/CounterInitPastHolds/graph.dot +6 -0
- package/plugin/skills/statechart/scripts/test/corpus/CounterInitPastHolds/report.md +7 -0
- package/plugin/skills/statechart/scripts/test/corpus/CounterInitPastHolds/sany.out +2 -0
- package/plugin/skills/statechart/scripts/test/corpus/CounterInitPastHolds/verdict-1.out +46 -0
- package/plugin/skills/statechart/scripts/test/corpus/CounterInstance/ChartRun.out +59 -0
- package/plugin/skills/statechart/scripts/test/corpus/CounterInstance/CounterInstance.cfg +2 -0
- package/plugin/skills/statechart/scripts/test/corpus/CounterInstance/CounterInstance.tla +10 -0
- package/plugin/skills/statechart/scripts/test/corpus/CounterInstance/CounterSteps.tla +6 -0
- package/plugin/skills/statechart/scripts/test/corpus/CounterInstance/chart.mmd +17 -0
- package/plugin/skills/statechart/scripts/test/corpus/CounterInstance/graph.dot +15 -0
- package/plugin/skills/statechart/scripts/test/corpus/CounterInstance/report.md +14 -0
- package/plugin/skills/statechart/scripts/test/corpus/CounterInstance/sany.out +3 -0
- package/plugin/skills/statechart/scripts/test/corpus/CounterInstance/verdict-1.exit +1 -0
- package/plugin/skills/statechart/scripts/test/corpus/CounterInstance/verdict-1.out +78 -0
- package/plugin/skills/statechart/scripts/test/corpus/CounterJump/ChartRun.out +59 -0
- package/plugin/skills/statechart/scripts/test/corpus/CounterJump/CounterJump.cfg +3 -0
- package/plugin/skills/statechart/scripts/test/corpus/CounterJump/CounterJump.tla +19 -0
- package/plugin/skills/statechart/scripts/test/corpus/CounterJump/chart.mmd +26 -0
- package/plugin/skills/statechart/scripts/test/corpus/CounterJump/graph.dot +22 -0
- package/plugin/skills/statechart/scripts/test/corpus/CounterJump/report.md +12 -0
- package/plugin/skills/statechart/scripts/test/corpus/CounterJump/sany.out +2 -0
- package/plugin/skills/statechart/scripts/test/corpus/CounterJump/verdict-1.exit +1 -0
- package/plugin/skills/statechart/scripts/test/corpus/CounterJump/verdict-1.out +58 -0
- package/plugin/skills/statechart/scripts/test/corpus/CounterJump/verdict-2.out +57 -0
- package/plugin/skills/statechart/scripts/test/corpus/CounterLoop/ChartRun.out +57 -0
- package/plugin/skills/statechart/scripts/test/corpus/CounterLoop/CounterLoop.cfg +2 -0
- package/plugin/skills/statechart/scripts/test/corpus/CounterLoop/CounterLoop.tla +11 -0
- package/plugin/skills/statechart/scripts/test/corpus/CounterLoop/chart.mmd +17 -0
- package/plugin/skills/statechart/scripts/test/corpus/CounterLoop/graph.dot +15 -0
- package/plugin/skills/statechart/scripts/test/corpus/CounterLoop/report.md +14 -0
- package/plugin/skills/statechart/scripts/test/corpus/CounterLoop/sany.out +2 -0
- package/plugin/skills/statechart/scripts/test/corpus/CounterLoop/verdict-1.exit +1 -0
- package/plugin/skills/statechart/scripts/test/corpus/CounterLoop/verdict-1.out +76 -0
- package/plugin/skills/statechart/scripts/test/corpus/CounterOrder/ChartRun.out +59 -0
- package/plugin/skills/statechart/scripts/test/corpus/CounterOrder/CounterOrder.cfg +3 -0
- package/plugin/skills/statechart/scripts/test/corpus/CounterOrder/CounterOrder.tla +11 -0
- package/plugin/skills/statechart/scripts/test/corpus/CounterOrder/chart.mmd +19 -0
- package/plugin/skills/statechart/scripts/test/corpus/CounterOrder/graph.dot +10 -0
- package/plugin/skills/statechart/scripts/test/corpus/CounterOrder/report.md +15 -0
- package/plugin/skills/statechart/scripts/test/corpus/CounterOrder/sany.out +2 -0
- package/plugin/skills/statechart/scripts/test/corpus/CounterOrder/verdict-1.exit +1 -0
- package/plugin/skills/statechart/scripts/test/corpus/CounterOrder/verdict-1.out +56 -0
- package/plugin/skills/statechart/scripts/test/corpus/CounterOrder/verdict-2.exit +1 -0
- package/plugin/skills/statechart/scripts/test/corpus/CounterOrder/verdict-2.out +67 -0
- package/plugin/skills/statechart/scripts/test/corpus/CounterRules/ChartRun.out +62 -0
- package/plugin/skills/statechart/scripts/test/corpus/CounterRules/CounterRules.cfg +6 -0
- package/plugin/skills/statechart/scripts/test/corpus/CounterRules/CounterRules.tla +24 -0
- package/plugin/skills/statechart/scripts/test/corpus/CounterRules/Moves.tla +5 -0
- package/plugin/skills/statechart/scripts/test/corpus/CounterRules/chart.mmd +22 -0
- package/plugin/skills/statechart/scripts/test/corpus/CounterRules/graph.dot +10 -0
- package/plugin/skills/statechart/scripts/test/corpus/CounterRules/report.md +23 -0
- package/plugin/skills/statechart/scripts/test/corpus/CounterRules/sany.out +3 -0
- package/plugin/skills/statechart/scripts/test/corpus/CounterRules/verdict-1.exit +1 -0
- package/plugin/skills/statechart/scripts/test/corpus/CounterRules/verdict-1.out +58 -0
- package/plugin/skills/statechart/scripts/test/corpus/CounterRules/verdict-2.exit +1 -0
- package/plugin/skills/statechart/scripts/test/corpus/CounterRules/verdict-2.out +66 -0
- package/plugin/skills/statechart/scripts/test/corpus/CounterRules/verdict-3.exit +1 -0
- package/plugin/skills/statechart/scripts/test/corpus/CounterRules/verdict-3.out +74 -0
- package/plugin/skills/statechart/scripts/test/corpus/CounterRules/verdict-4.out +59 -0
- package/plugin/skills/statechart/scripts/test/corpus/CounterStart/ChartRun.out +58 -0
- package/plugin/skills/statechart/scripts/test/corpus/CounterStart/CounterStart.cfg +3 -0
- package/plugin/skills/statechart/scripts/test/corpus/CounterStart/CounterStart.tla +15 -0
- package/plugin/skills/statechart/scripts/test/corpus/CounterStart/chart.mmd +18 -0
- package/plugin/skills/statechart/scripts/test/corpus/CounterStart/graph.dot +13 -0
- package/plugin/skills/statechart/scripts/test/corpus/CounterStart/report.md +11 -0
- package/plugin/skills/statechart/scripts/test/corpus/CounterStart/sany.out +2 -0
- package/plugin/skills/statechart/scripts/test/corpus/CounterStart/verdict-1.exit +1 -0
- package/plugin/skills/statechart/scripts/test/corpus/CounterStart/verdict-1.out +33 -0
- package/plugin/skills/statechart/scripts/test/corpus/CounterStart/verdict-2.out +57 -0
- package/plugin/skills/statechart/scripts/test/corpus/CounterStop/ChartRun.out +57 -0
- package/plugin/skills/statechart/scripts/test/corpus/CounterStop/CounterStop.cfg +3 -0
- package/plugin/skills/statechart/scripts/test/corpus/CounterStop/CounterStop.tla +15 -0
- package/plugin/skills/statechart/scripts/test/corpus/CounterStop/chart.mmd +7 -0
- package/plugin/skills/statechart/scripts/test/corpus/CounterStop/graph.dot +13 -0
- package/plugin/skills/statechart/scripts/test/corpus/CounterStop/report.md +6 -0
- package/plugin/skills/statechart/scripts/test/corpus/CounterStop/sany.out +2 -0
- package/plugin/skills/statechart/scripts/test/corpus/CounterStop/verdict-1.out +49 -0
- package/plugin/skills/statechart/scripts/test/corpus/CounterTie/ChartRun.out +61 -0
- package/plugin/skills/statechart/scripts/test/corpus/CounterTie/CounterTie.cfg +4 -0
- package/plugin/skills/statechart/scripts/test/corpus/CounterTie/CounterTie.tla +14 -0
- package/plugin/skills/statechart/scripts/test/corpus/CounterTie/chart.mmd +30 -0
- package/plugin/skills/statechart/scripts/test/corpus/CounterTie/graph.dot +19 -0
- package/plugin/skills/statechart/scripts/test/corpus/CounterTie/report.md +27 -0
- package/plugin/skills/statechart/scripts/test/corpus/CounterTie/sany.out +2 -0
- package/plugin/skills/statechart/scripts/test/corpus/CounterTie/verdict-1.exit +1 -0
- package/plugin/skills/statechart/scripts/test/corpus/CounterTie/verdict-1.out +56 -0
- package/plugin/skills/statechart/scripts/test/corpus/CounterTie/verdict-2.exit +1 -0
- package/plugin/skills/statechart/scripts/test/corpus/CounterTie/verdict-2.out +64 -0
- package/plugin/skills/statechart/scripts/test/corpus/CounterTie/verdict-3.exit +1 -0
- package/plugin/skills/statechart/scripts/test/corpus/CounterTie/verdict-3.out +87 -0
- package/plugin/skills/statechart/scripts/test/corpus/CounterTie/verdict-4.out +57 -0
- package/plugin/skills/statechart/scripts/test/corpus/CounterTieInGraph/ChartRun.out +60 -0
- package/plugin/skills/statechart/scripts/test/corpus/CounterTieInGraph/CounterTieInGraph.cfg +3 -0
- package/plugin/skills/statechart/scripts/test/corpus/CounterTieInGraph/CounterTieInGraph.tla +12 -0
- package/plugin/skills/statechart/scripts/test/corpus/CounterTieInGraph/chart.mmd +23 -0
- package/plugin/skills/statechart/scripts/test/corpus/CounterTieInGraph/graph.dot +19 -0
- package/plugin/skills/statechart/scripts/test/corpus/CounterTieInGraph/report.md +11 -0
- package/plugin/skills/statechart/scripts/test/corpus/CounterTieInGraph/sany.out +2 -0
- package/plugin/skills/statechart/scripts/test/corpus/CounterTieInGraph/verdict-1.exit +1 -0
- package/plugin/skills/statechart/scripts/test/corpus/CounterTieInGraph/verdict-1.out +56 -0
- package/plugin/skills/statechart/scripts/test/corpus/CounterTieInGraph/verdict-2.out +57 -0
- package/plugin/skills/statechart/scripts/test/corpus/CounterView/ChartRun.out +61 -0
- package/plugin/skills/statechart/scripts/test/corpus/CounterView/CounterView.cfg +4 -0
- package/plugin/skills/statechart/scripts/test/corpus/CounterView/CounterView.tla +14 -0
- package/plugin/skills/statechart/scripts/test/corpus/CounterView/chart.mmd +23 -0
- package/plugin/skills/statechart/scripts/test/corpus/CounterView/graph.dot +19 -0
- package/plugin/skills/statechart/scripts/test/corpus/CounterView/report.md +27 -0
- package/plugin/skills/statechart/scripts/test/corpus/CounterView/sany.out +2 -0
- package/plugin/skills/statechart/scripts/test/corpus/CounterView/verdict-1.exit +1 -0
- package/plugin/skills/statechart/scripts/test/corpus/CounterView/verdict-1.out +56 -0
- package/plugin/skills/statechart/scripts/test/corpus/CounterView/verdict-2.exit +1 -0
- package/plugin/skills/statechart/scripts/test/corpus/CounterView/verdict-2.out +64 -0
- package/plugin/skills/statechart/scripts/test/corpus/CounterView/verdict-3.exit +1 -0
- package/plugin/skills/statechart/scripts/test/corpus/CounterView/verdict-3.out +87 -0
- package/plugin/skills/statechart/scripts/test/corpus/CounterView/verdict-4.out +57 -0
- package/plugin/skills/statechart/scripts/test/corpus/CounterView/view.mjs +1 -0
- package/plugin/skills/statechart/scripts/test/corpus/DieHard/ChartRun.out +59 -0
- package/plugin/skills/statechart/scripts/test/corpus/DieHard/DieHard.cfg +4 -0
- package/plugin/skills/statechart/scripts/test/corpus/DieHard/DieHard.tla +38 -0
- package/plugin/skills/statechart/scripts/test/corpus/DieHard/chart.mmd +92 -0
- package/plugin/skills/statechart/scripts/test/corpus/DieHard/graph.dot +126 -0
- package/plugin/skills/statechart/scripts/test/corpus/DieHard/report.md +17 -0
- package/plugin/skills/statechart/scripts/test/corpus/DieHard/sany.out +2 -0
- package/plugin/skills/statechart/scripts/test/corpus/DieHard/verdict-1.exit +1 -0
- package/plugin/skills/statechart/scripts/test/corpus/DieHard/verdict-1.out +91 -0
- package/plugin/skills/statechart/scripts/test/corpus/DieHard/verdict-2.out +57 -0
- package/plugin/skills/statechart/scripts/test/corpus/FirstRule/ChartRun.out +61 -0
- package/plugin/skills/statechart/scripts/test/corpus/FirstRule/FirstRule.cfg +6 -0
- package/plugin/skills/statechart/scripts/test/corpus/FirstRule/FirstRule.tla +11 -0
- package/plugin/skills/statechart/scripts/test/corpus/FirstRule/chart.mmd +22 -0
- package/plugin/skills/statechart/scripts/test/corpus/FirstRule/graph.dot +16 -0
- package/plugin/skills/statechart/scripts/test/corpus/FirstRule/report.md +25 -0
- package/plugin/skills/statechart/scripts/test/corpus/FirstRule/sany.out +2 -0
- package/plugin/skills/statechart/scripts/test/corpus/FirstRule/verdict-1.exit +1 -0
- package/plugin/skills/statechart/scripts/test/corpus/FirstRule/verdict-1.out +56 -0
- package/plugin/skills/statechart/scripts/test/corpus/FirstRule/verdict-2.exit +1 -0
- package/plugin/skills/statechart/scripts/test/corpus/FirstRule/verdict-2.out +64 -0
- package/plugin/skills/statechart/scripts/test/corpus/FirstRule/verdict-3.exit +1 -0
- package/plugin/skills/statechart/scripts/test/corpus/FirstRule/verdict-3.out +64 -0
- package/plugin/skills/statechart/scripts/test/corpus/FirstRule/verdict-4.exit +1 -0
- package/plugin/skills/statechart/scripts/test/corpus/FirstRule/verdict-4.out +77 -0
- package/plugin/skills/statechart/scripts/test/corpus/HiddenClock/ChartRun.out +57 -0
- package/plugin/skills/statechart/scripts/test/corpus/HiddenClock/HiddenClock.cfg +4 -0
- package/plugin/skills/statechart/scripts/test/corpus/HiddenClock/HiddenClock.tla +11 -0
- package/plugin/skills/statechart/scripts/test/corpus/HiddenClock/chart.mmd +13 -0
- package/plugin/skills/statechart/scripts/test/corpus/HiddenClock/graph.dot +12 -0
- package/plugin/skills/statechart/scripts/test/corpus/HiddenClock/report.md +11 -0
- package/plugin/skills/statechart/scripts/test/corpus/HiddenClock/sany.out +2 -0
- package/plugin/skills/statechart/scripts/test/corpus/HiddenClock/verdict-1.exit +1 -0
- package/plugin/skills/statechart/scripts/test/corpus/HiddenClock/verdict-1.out +72 -0
- package/plugin/skills/statechart/scripts/test/corpus/Login/ChartRun.out +57 -0
- package/plugin/skills/statechart/scripts/test/corpus/Login/Login.cfg +3 -0
- package/plugin/skills/statechart/scripts/test/corpus/Login/Login.tla +62 -0
- package/plugin/skills/statechart/scripts/test/corpus/Login/chart.mmd +28 -0
- package/plugin/skills/statechart/scripts/test/corpus/Login/graph.dot +40 -0
- package/plugin/skills/statechart/scripts/test/corpus/Login/report.md +7 -0
- package/plugin/skills/statechart/scripts/test/corpus/Login/sany.out +1 -0
- package/plugin/skills/statechart/scripts/test/corpus/Login/verdict-1.out +47 -0
- package/plugin/skills/statechart/scripts/test/corpus/Login/view.mjs +1 -0
- package/plugin/skills/statechart/scripts/test/corpus/LoginGuarded/ChartRun.out +57 -0
- package/plugin/skills/statechart/scripts/test/corpus/LoginGuarded/LoginGuarded.cfg +2 -0
- package/plugin/skills/statechart/scripts/test/corpus/LoginGuarded/LoginGuarded.tla +64 -0
- package/plugin/skills/statechart/scripts/test/corpus/LoginGuarded/chart.mmd +28 -0
- package/plugin/skills/statechart/scripts/test/corpus/LoginGuarded/graph.dot +37 -0
- package/plugin/skills/statechart/scripts/test/corpus/LoginGuarded/report.md +8 -0
- package/plugin/skills/statechart/scripts/test/corpus/LoginGuarded/sany.out +1 -0
- package/plugin/skills/statechart/scripts/test/corpus/LoginGuarded/verdict-1.out +47 -0
- package/plugin/skills/statechart/scripts/test/corpus/LoginGuarded/view.mjs +1 -0
- package/plugin/skills/statechart/scripts/test/corpus/LoginParallel/ChartRun.out +60 -0
- package/plugin/skills/statechart/scripts/test/corpus/LoginParallel/LoginParallel.cfg +3 -0
- package/plugin/skills/statechart/scripts/test/corpus/LoginParallel/LoginParallel.tla +64 -0
- package/plugin/skills/statechart/scripts/test/corpus/LoginParallel/chart.mmd +44 -0
- package/plugin/skills/statechart/scripts/test/corpus/LoginParallel/graph.dot +58 -0
- package/plugin/skills/statechart/scripts/test/corpus/LoginParallel/report.md +17 -0
- package/plugin/skills/statechart/scripts/test/corpus/LoginParallel/sany.out +1 -0
- package/plugin/skills/statechart/scripts/test/corpus/LoginParallel/verdict-1.exit +1 -0
- package/plugin/skills/statechart/scripts/test/corpus/LoginParallel/verdict-1.out +83 -0
- package/plugin/skills/statechart/scripts/test/corpus/LoginParallel/verdict-2.out +57 -0
- package/plugin/skills/statechart/scripts/test/corpus/LoginParallel/view.mjs +1 -0
- package/plugin/skills/statechart/scripts/test/corpus/MediaPlayer/ChartRun.out +60 -0
- package/plugin/skills/statechart/scripts/test/corpus/MediaPlayer/MediaPlayer.cfg +3 -0
- package/plugin/skills/statechart/scripts/test/corpus/MediaPlayer/MediaPlayer.tla +103 -0
- package/plugin/skills/statechart/scripts/test/corpus/MediaPlayer/chart.mmd +43 -0
- package/plugin/skills/statechart/scripts/test/corpus/MediaPlayer/graph.dot +93 -0
- package/plugin/skills/statechart/scripts/test/corpus/MediaPlayer/report.md +14 -0
- package/plugin/skills/statechart/scripts/test/corpus/MediaPlayer/sany.out +1 -0
- package/plugin/skills/statechart/scripts/test/corpus/MediaPlayer/verdict-1.exit +1 -0
- package/plugin/skills/statechart/scripts/test/corpus/MediaPlayer/verdict-1.out +59 -0
- package/plugin/skills/statechart/scripts/test/corpus/MediaPlayer/verdict-2.out +72 -0
- package/plugin/skills/statechart/scripts/test/corpus/MediaPlayer/view.mjs +3 -0
- package/plugin/skills/statechart/scripts/test/corpus/MediaPlayerFixed/ChartRun.out +57 -0
- package/plugin/skills/statechart/scripts/test/corpus/MediaPlayerFixed/MediaPlayerFixed.cfg +2 -0
- package/plugin/skills/statechart/scripts/test/corpus/MediaPlayerFixed/MediaPlayerFixed.tla +100 -0
- package/plugin/skills/statechart/scripts/test/corpus/MediaPlayerFixed/chart.mmd +31 -0
- package/plugin/skills/statechart/scripts/test/corpus/MediaPlayerFixed/graph.dot +85 -0
- package/plugin/skills/statechart/scripts/test/corpus/MediaPlayerFixed/report.md +9 -0
- package/plugin/skills/statechart/scripts/test/corpus/MediaPlayerFixed/sany.out +1 -0
- package/plugin/skills/statechart/scripts/test/corpus/MediaPlayerFixed/verdict-1.out +47 -0
- package/plugin/skills/statechart/scripts/test/corpus/MediaPlayerFixed/view.mjs +3 -0
- package/plugin/skills/statechart/scripts/test/corpus/MediaPlayerProps/ChartRun.out +59 -0
- package/plugin/skills/statechart/scripts/test/corpus/MediaPlayerProps/MediaPlayer.tla +103 -0
- package/plugin/skills/statechart/scripts/test/corpus/MediaPlayerProps/MediaPlayerProps.cfg +3 -0
- package/plugin/skills/statechart/scripts/test/corpus/MediaPlayerProps/MediaPlayerProps.tla +6 -0
- package/plugin/skills/statechart/scripts/test/corpus/MediaPlayerProps/chart.mmd +42 -0
- package/plugin/skills/statechart/scripts/test/corpus/MediaPlayerProps/graph.dot +93 -0
- package/plugin/skills/statechart/scripts/test/corpus/MediaPlayerProps/report.md +19 -0
- package/plugin/skills/statechart/scripts/test/corpus/MediaPlayerProps/sany.out +2 -0
- package/plugin/skills/statechart/scripts/test/corpus/MediaPlayerProps/verdict-1.exit +1 -0
- package/plugin/skills/statechart/scripts/test/corpus/MediaPlayerProps/verdict-1.out +61 -0
- package/plugin/skills/statechart/scripts/test/corpus/MediaPlayerProps/verdict-2.out +59 -0
- package/plugin/skills/statechart/scripts/test/corpus/MediaPlayerProps/verdict-3.out +61 -0
- package/plugin/skills/statechart/scripts/test/corpus/MediaPlayerProps/verdict-4.exit +1 -0
- package/plugin/skills/statechart/scripts/test/corpus/MediaPlayerProps/verdict-4.out +66 -0
- package/plugin/skills/statechart/scripts/test/corpus/MediaPlayerProps/verdict-5.exit +1 -0
- package/plugin/skills/statechart/scripts/test/corpus/MediaPlayerProps/verdict-5.out +58 -0
- package/plugin/skills/statechart/scripts/test/corpus/MediaPlayerProps/verdict-6.out +49 -0
- package/plugin/skills/statechart/scripts/test/corpus/MediaPlayerProps/view.mjs +3 -0
- package/plugin/skills/statechart/scripts/test/corpus/PickWorker/ChartRun.out +57 -0
- package/plugin/skills/statechart/scripts/test/corpus/PickWorker/PickWorker.cfg +6 -0
- package/plugin/skills/statechart/scripts/test/corpus/PickWorker/PickWorker.tla +11 -0
- package/plugin/skills/statechart/scripts/test/corpus/PickWorker/chart.mmd +5 -0
- package/plugin/skills/statechart/scripts/test/corpus/PickWorker/graph.dot +11 -0
- package/plugin/skills/statechart/scripts/test/corpus/PickWorker/report.md +7 -0
- package/plugin/skills/statechart/scripts/test/corpus/PickWorker/sany.out +5 -0
- package/plugin/skills/statechart/scripts/test/corpus/PickWorker/verdict-1.out +70 -0
- package/plugin/skills/statechart/scripts/test/corpus/Shadow/ChartRun.out +61 -0
- package/plugin/skills/statechart/scripts/test/corpus/Shadow/Shadow.cfg +4 -0
- package/plugin/skills/statechart/scripts/test/corpus/Shadow/Shadow.tla +11 -0
- package/plugin/skills/statechart/scripts/test/corpus/Shadow/ShadowLib.tla +6 -0
- package/plugin/skills/statechart/scripts/test/corpus/Shadow/ShadowSub.tla +3 -0
- package/plugin/skills/statechart/scripts/test/corpus/Shadow/chart.mmd +9 -0
- package/plugin/skills/statechart/scripts/test/corpus/Shadow/graph.dot +16 -0
- package/plugin/skills/statechart/scripts/test/corpus/Shadow/report.md +8 -0
- package/plugin/skills/statechart/scripts/test/corpus/Shadow/sany.out +4 -0
- package/plugin/skills/statechart/scripts/test/corpus/Shadow/verdict-1.out +65 -0
- package/plugin/skills/statechart/scripts/test/corpus/SpacedNames/ChartRun.out +59 -0
- package/plugin/skills/statechart/scripts/test/corpus/SpacedNames/SpacedNames.cfg +2 -0
- package/plugin/skills/statechart/scripts/test/corpus/SpacedNames/SpacedNames.tla +9 -0
- package/plugin/skills/statechart/scripts/test/corpus/SpacedNames/chart.mmd +23 -0
- package/plugin/skills/statechart/scripts/test/corpus/SpacedNames/graph.dot +17 -0
- package/plugin/skills/statechart/scripts/test/corpus/SpacedNames/report.md +15 -0
- package/plugin/skills/statechart/scripts/test/corpus/SpacedNames/sany.out +1 -0
- package/plugin/skills/statechart/scripts/test/corpus/SpacedNames/verdict-1.exit +1 -0
- package/plugin/skills/statechart/scripts/test/corpus/SpacedNames/verdict-1.out +65 -0
- package/plugin/skills/statechart/scripts/test/corpus/SpacedNames/verdict-2.exit +1 -0
- package/plugin/skills/statechart/scripts/test/corpus/SpacedNames/verdict-2.out +75 -0
- package/plugin/skills/statechart/scripts/test/corpus/TwoPhase/ChartRun.out +69 -0
- package/plugin/skills/statechart/scripts/test/corpus/TwoPhase/TwoPhase.cfg +3 -0
- package/plugin/skills/statechart/scripts/test/corpus/TwoPhase/TwoPhase.tla +75 -0
- package/plugin/skills/statechart/scripts/test/corpus/TwoPhase/chart.mmd +60 -0
- package/plugin/skills/statechart/scripts/test/corpus/TwoPhase/graph.dot +297 -0
- package/plugin/skills/statechart/scripts/test/corpus/TwoPhase/report.md +20 -0
- package/plugin/skills/statechart/scripts/test/corpus/TwoPhase/sany.out +1 -0
- package/plugin/skills/statechart/scripts/test/corpus/TwoPhase/verdict-1.exit +1 -0
- package/plugin/skills/statechart/scripts/test/corpus/TwoPhase/verdict-1.out +95 -0
- package/plugin/skills/statechart/scripts/test/corpus/TwoPhase/verdict-2.out +57 -0
- package/plugin/skills/statechart/scripts/test/corpus/TwoPhase/view.mjs +1 -0
- package/plugin/skills/statechart/scripts/test/corpus/TwoPhaseFixed/ChartRun.out +57 -0
- package/plugin/skills/statechart/scripts/test/corpus/TwoPhaseFixed/TwoPhaseFixed.cfg +3 -0
- package/plugin/skills/statechart/scripts/test/corpus/TwoPhaseFixed/TwoPhaseFixed.tla +75 -0
- package/plugin/skills/statechart/scripts/test/corpus/TwoPhaseFixed/chart.mmd +37 -0
- package/plugin/skills/statechart/scripts/test/corpus/TwoPhaseFixed/graph.dot +223 -0
- package/plugin/skills/statechart/scripts/test/corpus/TwoPhaseFixed/report.md +11 -0
- package/plugin/skills/statechart/scripts/test/corpus/TwoPhaseFixed/sany.out +1 -0
- package/plugin/skills/statechart/scripts/test/corpus/TwoPhaseFixed/verdict-1.out +47 -0
- package/plugin/skills/statechart/scripts/test/corpus/TwoPhaseFixed/view.mjs +1 -0
- package/plugin/skills/statechart/scripts/test/corpus/TypeGuard/ChartRun.exit +1 -0
- package/plugin/skills/statechart/scripts/test/corpus/TypeGuard/ChartRun.out +75 -0
- package/plugin/skills/statechart/scripts/test/corpus/TypeGuard/TypeGuard.cfg +5 -0
- package/plugin/skills/statechart/scripts/test/corpus/TypeGuard/TypeGuard.tla +11 -0
- package/plugin/skills/statechart/scripts/test/corpus/TypeGuard/chart.mmd +18 -0
- package/plugin/skills/statechart/scripts/test/corpus/TypeGuard/graph.dot +14 -0
- package/plugin/skills/statechart/scripts/test/corpus/TypeGuard/report.md +29 -0
- package/plugin/skills/statechart/scripts/test/corpus/TypeGuard/sany.out +2 -0
- package/plugin/skills/statechart/scripts/test/corpus/TypeGuard/verdict-1.exit +1 -0
- package/plugin/skills/statechart/scripts/test/corpus/TypeGuard/verdict-1.out +64 -0
- package/plugin/skills/statechart/scripts/test/corpus/TypeGuard/verdict-2.exit +1 -0
- package/plugin/skills/statechart/scripts/test/corpus/TypeGuard/verdict-2.out +75 -0
- package/plugin/skills/statechart/scripts/test/corpus/UserNoDeadlock/ChartRun.out +58 -0
- package/plugin/skills/statechart/scripts/test/corpus/UserNoDeadlock/UserNoDeadlock.cfg +2 -0
- package/plugin/skills/statechart/scripts/test/corpus/UserNoDeadlock/UserNoDeadlock.tla +8 -0
- package/plugin/skills/statechart/scripts/test/corpus/UserNoDeadlock/chart.mmd +22 -0
- package/plugin/skills/statechart/scripts/test/corpus/UserNoDeadlock/graph.dot +16 -0
- package/plugin/skills/statechart/scripts/test/corpus/UserNoDeadlock/report.md +15 -0
- package/plugin/skills/statechart/scripts/test/corpus/UserNoDeadlock/sany.out +2 -0
- package/plugin/skills/statechart/scripts/test/corpus/UserNoDeadlock/verdict-1.exit +1 -0
- package/plugin/skills/statechart/scripts/test/corpus/UserNoDeadlock/verdict-1.out +56 -0
- package/plugin/skills/statechart/scripts/test/corpus/UserNoDeadlock/verdict-2.exit +1 -0
- package/plugin/skills/statechart/scripts/test/corpus/UserNoDeadlock/verdict-2.out +77 -0
- package/plugin/skills/statechart/scripts/test/corpus.test.ts +453 -0
- package/plugin/skills/statechart/scripts/test/differential.test.ts +565 -0
- package/plugin/skills/statechart/scripts/test/drawn.ts +20 -0
- package/plugin/skills/statechart/scripts/test/grid/Grid.cfg +2 -0
- package/plugin/skills/statechart/scripts/test/grid/Grid.tla +9 -0
- package/plugin/skills/statechart/scripts/test/grid/sany.out +2 -0
- package/plugin/skills/statechart/scripts/test/java.ts +63 -0
- package/plugin/skills/statechart/scripts/test/labels.ts +648 -0
- package/plugin/skills/statechart/scripts/test/messages.test.ts +226 -0
- package/plugin/skills/statechart/scripts/test/pipeline.test.ts +270 -0
- package/plugin/skills/statechart/scripts/test/plain-tlc.test.ts +255 -0
- package/plugin/skills/statechart/scripts/test/render.test.ts +145 -0
- package/plugin/skills/statechart/scripts/test/tlc-out.test.ts +90 -0
- package/plugin/skills/statechart/scripts/test/tlc.ts +158 -0
- package/plugin/skills/statechart/scripts/tsconfig.json +11 -0
- package/plugin/skills/statechart/scripts/worker.ts +35 -0
- package/plugin/skills/swarm/SKILL.md +58 -0
- package/plugin/skills/tdd/SKILL.md +41 -0
- package/plugin/skills/teach/SKILL.md +28 -0
- package/plugin/skills/technical-writing/SKILL.md +69 -0
- package/plugin/skills/thermo-nuclear-code-quality-review/SKILL.md +201 -0
- package/plugin/skills/thermo-nuclear-review/SKILL.md +50 -0
- package/plugin/skills/thermos/SKILL.md +40 -0
- package/plugin/skills/typescript-best-practices/SKILL.md +32 -0
- package/plugin/skills/typescript-best-practices/references/patterns.md +328 -0
- package/plugin/skills/unslop/SKILL.md +39 -0
- package/plugin/skills/what-did-i-get-done/SKILL.md +31 -0
- package/plugin/skills/why/SKILL.md +16 -0
- package/README.md +0 -3
|
@@ -0,0 +1,510 @@
|
|
|
1
|
+
import { spawnSync } from "node:child_process";
|
|
2
|
+
import { randomBytes, randomUUID } from "node:crypto";
|
|
3
|
+
import { existsSync, mkdirSync, readdirSync, readFileSync, writeFileSync } from "node:fs";
|
|
4
|
+
import { dirname, join } from "node:path";
|
|
5
|
+
import type { ExtensionAPI, ExtensionContext, SessionEntry } from "@earendil-works/pi-coding-agent";
|
|
6
|
+
import { type Static, Type } from "typebox";
|
|
7
|
+
import { Value } from "typebox/value";
|
|
8
|
+
|
|
9
|
+
import { noticeOf, OUTPUT_CAP_BYTES, statusText, truncateUtf8 } from "./agent-text.ts";
|
|
10
|
+
import type { AgentParams } from "./agent-tools.ts";
|
|
11
|
+
import { type Activity, type AgentChild, alive, type ChildExit, PiChild, terminateGroup } from "./child.ts";
|
|
12
|
+
import { HcChild } from "./hc-child.ts";
|
|
13
|
+
import { loadAgentTypes } from "./agent-files.ts";
|
|
14
|
+
import { checkEffort, DEPTH_FLAG, GENERAL_PURPOSE, InvalidValueError, PSTACK_STATE_DIR, readSheet, resolveModel, type Settings } from "./config.ts";
|
|
15
|
+
import { ensureWorktree, planWorktree, settleWorktree, type Worktree, worktreeSchema } from "./worktree.ts";
|
|
16
|
+
|
|
17
|
+
const ENTRY_TYPE = "pstack-agents";
|
|
18
|
+
const STATUS_KEY = "pstack-agents";
|
|
19
|
+
// Claude Code lets agents nest three layers below the main session and withholds
|
|
20
|
+
// the Agent tool at the third.
|
|
21
|
+
const MAX_SPAWN_DEPTH = 3;
|
|
22
|
+
// Names the session a child's permission asks go to. @gotgenes/pi-permission-system
|
|
23
|
+
// relays them there while that session has a UI; without it a child answers them itself.
|
|
24
|
+
const PARENT_SESSION_ENV = "PI_SUBAGENT_PARENT_SESSION";
|
|
25
|
+
|
|
26
|
+
const endedStatus = Type.Union([Type.Literal("completed"), Type.Literal("failed"), Type.Literal("stopped")]);
|
|
27
|
+
type EndedStatus = Static<typeof endedStatus>;
|
|
28
|
+
|
|
29
|
+
// Fixed when the agent starts and reused by every launch of it, so a resume
|
|
30
|
+
// runs the same session, model, thinking, system prompt, and worktree.
|
|
31
|
+
const identitySchema = Type.Object({
|
|
32
|
+
id: Type.String(),
|
|
33
|
+
description: Type.String(),
|
|
34
|
+
subagentType: Type.String(),
|
|
35
|
+
model: Type.Optional(Type.String()),
|
|
36
|
+
thinking: Type.Optional(Type.String()),
|
|
37
|
+
readonly: Type.Optional(Type.Literal(true)),
|
|
38
|
+
// Pi's own rule for a session id (assertValidSessionId): a resume passes it
|
|
39
|
+
// to pi as an argument, so an empty or odd value must not load.
|
|
40
|
+
sessionId: Type.String({ pattern: "^[A-Za-z0-9](?:[A-Za-z0-9._-]*[A-Za-z0-9])?$" }),
|
|
41
|
+
sessionDir: Type.String(),
|
|
42
|
+
systemPromptFile: Type.Optional(Type.String()),
|
|
43
|
+
cwd: Type.String(),
|
|
44
|
+
worktree: Type.Optional(worktreeSchema),
|
|
45
|
+
startedAt: Type.String(),
|
|
46
|
+
});
|
|
47
|
+
const runningSchema = Type.Object({
|
|
48
|
+
agent: identitySchema,
|
|
49
|
+
status: Type.Literal("running"),
|
|
50
|
+
pid: Type.Optional(Type.Number()),
|
|
51
|
+
// When that pid started, as the system reports it. A pid can be reused; a
|
|
52
|
+
// pid with its start time names one process. Absent when it could not be
|
|
53
|
+
// read, and on a record an earlier version wrote.
|
|
54
|
+
pidStart: Type.Optional(Type.String()),
|
|
55
|
+
// The pi process that launched it. Only that process may reap it.
|
|
56
|
+
parentPid: Type.Number(),
|
|
57
|
+
host: Type.Optional(Type.Literal("hc")),
|
|
58
|
+
});
|
|
59
|
+
const endedSchema = Type.Object({
|
|
60
|
+
agent: identitySchema,
|
|
61
|
+
status: endedStatus,
|
|
62
|
+
pid: Type.Optional(Type.Number()),
|
|
63
|
+
exitCode: Type.Union([Type.Number(), Type.Null()]),
|
|
64
|
+
endedAt: Type.String(),
|
|
65
|
+
finalText: Type.String(),
|
|
66
|
+
outputFile: Type.Optional(Type.String()),
|
|
67
|
+
worktreeKept: Type.Optional(Type.Boolean()),
|
|
68
|
+
});
|
|
69
|
+
// Persisted as a session entry, last write per agent id wins.
|
|
70
|
+
const recordSchema = Type.Union([runningSchema, endedSchema]);
|
|
71
|
+
|
|
72
|
+
type AgentIdentity = Static<typeof identitySchema>;
|
|
73
|
+
type RunningRecord = Static<typeof runningSchema>;
|
|
74
|
+
export type EndedRecord = Static<typeof endedSchema>;
|
|
75
|
+
export type AgentRecord = Static<typeof recordSchema>;
|
|
76
|
+
|
|
77
|
+
interface Run {
|
|
78
|
+
child: AgentChild;
|
|
79
|
+
background: boolean;
|
|
80
|
+
// Set once the run is told to end: the exit code no longer decides the
|
|
81
|
+
// status. teardown means the session is going away, so no notice follows.
|
|
82
|
+
ending?: "stopped" | "teardown";
|
|
83
|
+
done: Promise<EndedRecord>;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
// A remote agent runs under the live pi process that restore left it to.
|
|
87
|
+
type LocalAgent = { kind: "local"; record: RunningRecord; run: Run };
|
|
88
|
+
// Unverified restores retry identity checks; interrupted ones await termination.
|
|
89
|
+
type AgentState = LocalAgent
|
|
90
|
+
| { kind: "remote"; record: RunningRecord }
|
|
91
|
+
| { kind: "unverified"; record: RunningRecord }
|
|
92
|
+
| { kind: "interrupted"; record: RunningRecord }
|
|
93
|
+
| { kind: "ended"; record: EndedRecord };
|
|
94
|
+
|
|
95
|
+
// How a run ended, from what its process left behind. A run that settled on a
|
|
96
|
+
// reply completed, whatever the exit code of the shutdown after it. Stderr
|
|
97
|
+
// diagnoses a failure; a stopped child's stderr is not its output (pi warns
|
|
98
|
+
// there on every first run of a --session-id).
|
|
99
|
+
function outcomeOf(exit: ChildExit, stopped: boolean): { status: EndedStatus; finalText: string } {
|
|
100
|
+
if (stopped) return { status: "stopped", finalText: exit.finalText || "(stopped before it replied)" };
|
|
101
|
+
if (exit.settled && exit.finalText && !exit.errorMessage) return { status: "completed", finalText: exit.finalText };
|
|
102
|
+
const diagnostics = exit.errorMessage || exit.stderr.trim();
|
|
103
|
+
const finalText = exit.finalText && diagnostics ? `${exit.finalText}\n\n${diagnostics}` : exit.finalText || diagnostics || "(no output)";
|
|
104
|
+
return { status: "failed", finalText };
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
// The text a record keeps: capped, with the full copy on disk when it was cut.
|
|
108
|
+
function saveOutput(identity: AgentIdentity, text: string): Pick<EndedRecord, "finalText" | "outputFile"> {
|
|
109
|
+
const capped = truncateUtf8(text, OUTPUT_CAP_BYTES);
|
|
110
|
+
if (capped === text) return { finalText: text };
|
|
111
|
+
const outputFile = join(identity.sessionDir, `${identity.id}.${Date.now()}.out.md`);
|
|
112
|
+
try {
|
|
113
|
+
writeFileSync(outputFile, text);
|
|
114
|
+
return { finalText: capped, outputFile };
|
|
115
|
+
} catch (e) {
|
|
116
|
+
return { finalText: `${capped}\n\n(full output not saved: ${(e as Error).message})` };
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
// Pi names the file <timestamp>_<session id>.jsonl, reopens it on a resume,
|
|
121
|
+
// and writes it only once the first message is in.
|
|
122
|
+
export function sessionFile({ sessionDir, sessionId }: AgentIdentity): string | undefined {
|
|
123
|
+
try {
|
|
124
|
+
const name = readdirSync(sessionDir).find((n) => n.endsWith(`_${sessionId}.jsonl`));
|
|
125
|
+
return name && join(sessionDir, name);
|
|
126
|
+
} catch {
|
|
127
|
+
return undefined;
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
function settle(worktree: Worktree): { kept: boolean; note: string } {
|
|
132
|
+
try {
|
|
133
|
+
return { kept: settleWorktree(worktree), note: "" };
|
|
134
|
+
} catch (e) {
|
|
135
|
+
return { kept: true, note: `\n\n(worktree cleanup failed: ${(e as Error).message})` };
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
function childArgs(identity: AgentIdentity, depth: number): string[] {
|
|
140
|
+
const args = ["--session-id", identity.sessionId, "--session-dir", identity.sessionDir];
|
|
141
|
+
if (identity.model) args.push("--model", identity.model);
|
|
142
|
+
if (identity.thinking) args.push("--thinking", identity.thinking);
|
|
143
|
+
if (identity.systemPromptFile) args.push("--append-system-prompt", identity.systemPromptFile);
|
|
144
|
+
// @gotgenes/pi-permission-system 42.0.0 names a forwarded ask's agent from this tag in the child's
|
|
145
|
+
// system prompt, and picks its per-agent permission policy by that name; without it the parent's
|
|
146
|
+
// dialog says "unknown".
|
|
147
|
+
args.push("--append-system-prompt", `<active_agent name="${identity.subagentType}" />`);
|
|
148
|
+
args.push(`--${DEPTH_FLAG}`, String(depth + 1));
|
|
149
|
+
const excluded = [...(identity.readonly ? ["edit", "write"] : []), ...(depth + 1 >= MAX_SPAWN_DEPTH ? ["agent"] : [])];
|
|
150
|
+
if (excluded.length) args.push("--exclude-tools", excluded.join(","));
|
|
151
|
+
return args;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
// What the system records about a live process, or undefined when it cannot
|
|
155
|
+
// say. Neither value is the process's to change, unlike its arguments: pi sets
|
|
156
|
+
// its title, and ps then shows that in their place. Linux keeps both in /proc,
|
|
157
|
+
// the start as clock ticks since boot. ps works its start time out from the
|
|
158
|
+
// wall clock there, so a clock change moves it, and ps is asked only where
|
|
159
|
+
// /proc is missing, with the locale and time zone pinned so the text is the
|
|
160
|
+
// same on every read.
|
|
161
|
+
function inspect(pid: number): { parentPid: number; start: string } | undefined {
|
|
162
|
+
let stat = "";
|
|
163
|
+
try {
|
|
164
|
+
stat = readFileSync(`/proc/${pid}/stat`, "utf8");
|
|
165
|
+
} catch {}
|
|
166
|
+
// State, parent pid, and 17 more fields up to the start time. They follow
|
|
167
|
+
// the command name, which is in parentheses and may hold any character.
|
|
168
|
+
const proc = /^ \S (\d+)(?: \S+){17} (\d+) /.exec(stat.slice(stat.lastIndexOf(")") + 1));
|
|
169
|
+
if (proc) return { parentPid: Number(proc[1]), start: proc[2] };
|
|
170
|
+
const ps = spawnSync("ps", ["-o", "ppid=", "-o", "lstart=", "-p", String(pid)], { encoding: "utf8", env: { ...process.env, LC_ALL: "C", TZ: "UTC" } });
|
|
171
|
+
const m = ps.status === 0 ? /^\s*(\d+)\s+(\S.*\S)\s*$/.exec(ps.stdout) : null;
|
|
172
|
+
return m ? { parentPid: Number(m[1]), start: m[2] } : undefined;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
// What became of the process a running record names:
|
|
176
|
+
// - kept: it is still a child of the live pi process that launched it;
|
|
177
|
+
// - orphan: it is the process the record was written for, its launcher gone;
|
|
178
|
+
// - unknown: a process is there, and nothing says whether it is the agent's;
|
|
179
|
+
// - gone: no process is there, or another one is.
|
|
180
|
+
type Fate = "kept" | "orphan" | "unknown" | "gone";
|
|
181
|
+
|
|
182
|
+
function fateOf(record: RunningRecord): Fate {
|
|
183
|
+
const { pid, pidStart, parentPid } = record;
|
|
184
|
+
if (pid === undefined || !alive(pid)) return "gone";
|
|
185
|
+
const info = inspect(pid);
|
|
186
|
+
if (info && pidStart !== undefined && info.start !== pidStart) return "gone";
|
|
187
|
+
// With no word from the system, two live pids keep the record: calling a
|
|
188
|
+
// live agent stopped would let a message start a second process on its session.
|
|
189
|
+
// An hc terminal's program is a child of herdr-core, not of the pi that launched it.
|
|
190
|
+
const launcherHasIt = info && record.host !== "hc" ? info.parentPid === parentPid : alive(parentPid);
|
|
191
|
+
if (parentPid !== process.pid && launcherHasIt) return "kept";
|
|
192
|
+
return info && info.start === pidStart ? "orphan" : "unknown";
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
// Stops an orphan, by its group so the bash command it has running goes too.
|
|
196
|
+
// No other fate is signalled: a pid that may have been reused is not ours to hit.
|
|
197
|
+
function reapOrphan(record: RunningRecord, killGraceMs: number): Promise<void> {
|
|
198
|
+
return record.pid === undefined ? Promise.resolve() : terminateGroup(record.pid, () => fateOf(record) === "orphan", killGraceMs);
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
const now = () => new Date().toISOString();
|
|
202
|
+
|
|
203
|
+
// A value the call left out came from the agent file, which the caller never
|
|
204
|
+
// saw, so an error over the value names that file.
|
|
205
|
+
function fromAgentFile<T>(file: string | undefined, passed: string | undefined, resolve: () => T): T {
|
|
206
|
+
try {
|
|
207
|
+
return resolve();
|
|
208
|
+
} catch (e) {
|
|
209
|
+
if (passed !== undefined || file === undefined || !(e instanceof InvalidValueError)) throw e;
|
|
210
|
+
throw new Error(`${file}: ${(e as Error).message}`);
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
export class AgentRunner {
|
|
215
|
+
private readonly agents = new Map<string, AgentState>();
|
|
216
|
+
// Set once the session tears its agents down; a launch after that would
|
|
217
|
+
// start a child nothing stops.
|
|
218
|
+
private closed = false;
|
|
219
|
+
// The footer of the top-level session only: a child's status would go to its
|
|
220
|
+
// parent's stdout, which the reader ignores.
|
|
221
|
+
private ui?: ExtensionContext["ui"];
|
|
222
|
+
private ownSessionId?: string;
|
|
223
|
+
private projectTrusted = false;
|
|
224
|
+
|
|
225
|
+
constructor(
|
|
226
|
+
private readonly pi: ExtensionAPI,
|
|
227
|
+
private readonly settings: Settings,
|
|
228
|
+
) {}
|
|
229
|
+
|
|
230
|
+
start(params: AgentParams, ctx: ExtensionContext): RunningRecord {
|
|
231
|
+
const type = params.subagent_type || GENERAL_PURPOSE;
|
|
232
|
+
const types = loadAgentTypes(this.settings);
|
|
233
|
+
const def = types.get(type);
|
|
234
|
+
if (!def) throw new Error(`Unknown subagent_type "${type}". Valid types: ${[...types.keys()].join(", ")}.`);
|
|
235
|
+
const parentModel = ctx.model ? `${ctx.model.provider}/${ctx.model.id}` : undefined;
|
|
236
|
+
const model = fromAgentFile(def.file, params.model, () => resolveModel(params.model ?? def.model, this.settings, readSheet(this.settings.agentDir, ctx.cwd), parentModel, ctx.modelRegistry));
|
|
237
|
+
// Claude Code subagents without an effort run at their definition's effort, else the session's.
|
|
238
|
+
const effort = params.effort ?? def.effort;
|
|
239
|
+
const thinking = effort === undefined ? this.pi.getThinkingLevel() : fromAgentFile(def.file, params.effort, () => checkEffort(effort, this.settings));
|
|
240
|
+
|
|
241
|
+
const id = `a${randomBytes(8).toString("hex")}`;
|
|
242
|
+
const state = join(this.settings.agentDir, PSTACK_STATE_DIR, ctx.sessionManager.getSessionId());
|
|
243
|
+
const sessionDir = join(state, "agents");
|
|
244
|
+
mkdirSync(sessionDir, { recursive: true });
|
|
245
|
+
const systemPromptFile = def.body ? join(state, "prompts", `${id}.md`) : undefined;
|
|
246
|
+
const worktree = params.isolation === "worktree" ? planWorktree(ctx.cwd, id) : undefined;
|
|
247
|
+
const identity: AgentIdentity = {
|
|
248
|
+
id,
|
|
249
|
+
description: params.description,
|
|
250
|
+
subagentType: type,
|
|
251
|
+
model,
|
|
252
|
+
thinking,
|
|
253
|
+
readonly: params.readonly || undefined,
|
|
254
|
+
sessionId: randomUUID(),
|
|
255
|
+
sessionDir,
|
|
256
|
+
systemPromptFile,
|
|
257
|
+
cwd: worktree?.path ?? ctx.cwd,
|
|
258
|
+
worktree,
|
|
259
|
+
startedAt: now(),
|
|
260
|
+
};
|
|
261
|
+
this.attachSession(ctx);
|
|
262
|
+
return this.launch(identity, params.prompt, params.run_in_background === true);
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
private launch(identity: AgentIdentity, prompt: string, background: boolean): RunningRecord {
|
|
266
|
+
if (this.closed) throw new Error("This session is shutting down; no agent can start.");
|
|
267
|
+
try {
|
|
268
|
+
// First, so a failure here leaves no worktree or branch behind.
|
|
269
|
+
this.ensureSystemPrompt(identity);
|
|
270
|
+
if (identity.worktree) ensureWorktree(identity.worktree);
|
|
271
|
+
} catch (e) {
|
|
272
|
+
// A resume that cannot launch leaves the agent's record as its last run ended.
|
|
273
|
+
if (!this.agents.has(identity.id)) {
|
|
274
|
+
const failed: EndedRecord = { agent: identity, status: "failed", exitCode: null, endedAt: now(), finalText: (e as Error).message };
|
|
275
|
+
this.agents.set(identity.id, { kind: "ended", record: failed });
|
|
276
|
+
this.persist(failed);
|
|
277
|
+
}
|
|
278
|
+
throw e;
|
|
279
|
+
}
|
|
280
|
+
const child = this.spawnChild(identity, prompt);
|
|
281
|
+
const pidStart = child.pid === undefined ? undefined : inspect(child.pid)?.start;
|
|
282
|
+
const record: RunningRecord = { agent: identity, status: "running", pid: child.pid, pidStart, parentPid: process.pid };
|
|
283
|
+
const run: Run = { child, background, done: child.exited.then((exit) => this.finish(identity, run, exit)) };
|
|
284
|
+
this.agents.set(identity.id, { kind: "local", record, run });
|
|
285
|
+
this.persist(record);
|
|
286
|
+
this.showStatus();
|
|
287
|
+
return record;
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
private spawnChild(identity: AgentIdentity, prompt: string): AgentChild {
|
|
291
|
+
const { command, args } = this.settings.pi;
|
|
292
|
+
const base = [...args, "--extension", join(this.settings.pluginRoot, "pi", "index.ts"), "--skill", join(this.settings.pluginRoot, "skills")];
|
|
293
|
+
const flags = childArgs(identity, this.settings.depth);
|
|
294
|
+
const env = { [PARENT_SESSION_ENV]: this.ownSessionId };
|
|
295
|
+
if (readSheet(this.settings.agentDir)?.hcHost && process.env.HC_TERMINAL_ID) {
|
|
296
|
+
// An interactive pi asks whether to trust the project before it reports any status; the parent already decided.
|
|
297
|
+
return new HcChild(identity.id, command, [...base, ...flags, this.projectTrusted ? "--approve" : "--no-approve"], {
|
|
298
|
+
cwd: identity.cwd,
|
|
299
|
+
env: { ...env, PI_CODING_AGENT_DIR: this.settings.agentDir },
|
|
300
|
+
envFile: join(identity.sessionDir, `${identity.id}.env`),
|
|
301
|
+
graceMs: this.settings.killGraceMs,
|
|
302
|
+
transcript: () => sessionFile(identity),
|
|
303
|
+
onStart: (pid) => this.track(identity.id, { host: "hc", pid, pidStart: inspect(pid)?.start }),
|
|
304
|
+
}, prompt);
|
|
305
|
+
}
|
|
306
|
+
return new PiChild(command, [...base, "--mode", "rpc", ...flags], { cwd: identity.cwd, env, exitGraceMs: this.settings.exitGraceMs, onActivity: () => this.showStatus() }, prompt);
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
private track(id: string, handle: Pick<RunningRecord, "host" | "pid" | "pidStart">): void {
|
|
310
|
+
const state = this.agents.get(id);
|
|
311
|
+
if (state?.kind !== "local") return;
|
|
312
|
+
Object.assign(state.record, handle);
|
|
313
|
+
this.persist(state.record);
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
// From session_start too: a reloaded session can resume an agent with
|
|
317
|
+
// send_message before any agent call.
|
|
318
|
+
attachSession(ctx: ExtensionContext): void {
|
|
319
|
+
this.ownSessionId = ctx.sessionManager.getSessionId();
|
|
320
|
+
this.projectTrusted = ctx.isProjectTrusted?.() ?? false;
|
|
321
|
+
if (ctx.hasUI && this.settings.depth === 0) this.ui = ctx.ui;
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
private showStatus(): void {
|
|
325
|
+
const running = this.locals().map(({ record, run }) => ({ id: record.agent.id, at: run.child.activity?.at ?? record.agent.startedAt, activity: run.child.activity }));
|
|
326
|
+
this.ui?.setStatus(STATUS_KEY, statusText(running));
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
// A running agent's live activity, which only a local one has.
|
|
330
|
+
activityOf(agent: AgentIdentity): Activity | undefined {
|
|
331
|
+
const state = this.agents.get(agent.id);
|
|
332
|
+
return state?.kind === "local" ? state.run.child.activity : undefined;
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
// Pi appends a path it cannot find as the prompt text itself.
|
|
336
|
+
private ensureSystemPrompt(identity: AgentIdentity): void {
|
|
337
|
+
const file = identity.systemPromptFile;
|
|
338
|
+
if (!file || existsSync(file)) return;
|
|
339
|
+
const body = loadAgentTypes(this.settings).get(identity.subagentType)?.body;
|
|
340
|
+
if (!body) throw new Error(`Agent ${identity.id} has lost its system prompt file, and its type "${identity.subagentType}" no longer provides one.`);
|
|
341
|
+
mkdirSync(dirname(file), { recursive: true });
|
|
342
|
+
writeFileSync(file, body, { mode: 0o600 });
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
private finish(identity: AgentIdentity, run: Run, exit: ChildExit): EndedRecord {
|
|
346
|
+
const { status, finalText } = outcomeOf(exit, run.ending !== undefined);
|
|
347
|
+
const worktree = identity.worktree && settle(identity.worktree);
|
|
348
|
+
const record: EndedRecord = {
|
|
349
|
+
agent: identity,
|
|
350
|
+
status,
|
|
351
|
+
pid: run.child.pid,
|
|
352
|
+
exitCode: exit.exitCode,
|
|
353
|
+
endedAt: now(),
|
|
354
|
+
worktreeKept: worktree?.kept,
|
|
355
|
+
...saveOutput(identity, finalText + (worktree?.note ?? "")),
|
|
356
|
+
};
|
|
357
|
+
this.agents.set(identity.id, { kind: "ended", record });
|
|
358
|
+
this.persist(record);
|
|
359
|
+
this.showStatus();
|
|
360
|
+
// The model that called stop_agent already has the result, so a stop's
|
|
361
|
+
// notice joins the context without starting another turn.
|
|
362
|
+
if (run.background && run.ending !== "teardown") {
|
|
363
|
+
this.pi.sendMessage(noticeOf(record, sessionFile(identity)), status !== "stopped" ? { triggerTurn: true, deliverAs: "steer" } : { triggerTurn: false });
|
|
364
|
+
}
|
|
365
|
+
return record;
|
|
366
|
+
}
|
|
367
|
+
|
|
368
|
+
// The end of the agent's run in flight, or its record when it has ended.
|
|
369
|
+
async wait(id: string): Promise<EndedRecord> {
|
|
370
|
+
const state = this.owned(id);
|
|
371
|
+
return state.kind === "local" ? state.run.done : state.record;
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
private locals(): LocalAgent[] {
|
|
375
|
+
return [...this.agents.values()].filter((state): state is LocalAgent => state.kind === "local");
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
get busy(): boolean {
|
|
379
|
+
return this.locals().length > 0;
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
// Resolves once the first running agent exits, at once when none is running.
|
|
383
|
+
async nextExit(): Promise<void> {
|
|
384
|
+
const locals = this.locals();
|
|
385
|
+
if (locals.length) await Promise.race(locals.map((state) => state.run.done));
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
private find(to: string): AgentState {
|
|
389
|
+
const byId = this.agents.get(to);
|
|
390
|
+
if (byId) return this.refreshRestored(byId);
|
|
391
|
+
const states = [...this.agents.values()];
|
|
392
|
+
const matches = states.filter((state) => state.record.agent.description === to);
|
|
393
|
+
if (matches.length === 1) return this.refreshRestored(matches[0]);
|
|
394
|
+
if (matches.length > 1) {
|
|
395
|
+
throw new Error(`"${to}" matches several agents (${matches.map((state) => state.record.agent.id).join(", ")}); pass an agentId.`);
|
|
396
|
+
}
|
|
397
|
+
const known = states.map(({ record }) => `${record.agent.id} (${record.agent.description})`);
|
|
398
|
+
throw new Error(`No agent "${to}". Known agents: ${known.join(", ") || "none"}.`);
|
|
399
|
+
}
|
|
400
|
+
|
|
401
|
+
// An agent this process can act on. One running under another pi process is
|
|
402
|
+
// not: only that process holds its stdin and can message or stop it.
|
|
403
|
+
private owned(to: string): Exclude<AgentState, { kind: "remote" | "unverified" | "interrupted" }> {
|
|
404
|
+
const state = this.find(to);
|
|
405
|
+
if (state.kind === "remote") {
|
|
406
|
+
throw new Error(`Agent ${state.record.agent.id} is running under another pi process (pid ${state.record.parentPid}); only that process can message or stop it.`);
|
|
407
|
+
}
|
|
408
|
+
if (state.kind === "unverified" || state.kind === "interrupted") {
|
|
409
|
+
throw new Error(`Agent ${state.record.agent.id}'s previous process (pid ${state.record.pid}) has not exited; it cannot resume or be stopped here until its exit is confirmed.`);
|
|
410
|
+
}
|
|
411
|
+
return state;
|
|
412
|
+
}
|
|
413
|
+
|
|
414
|
+
// A running agent takes the message as a steer, after its current tool calls.
|
|
415
|
+
// A finished one, or one that has settled and is exiting, resumes with it,
|
|
416
|
+
// including one that settled just before the steer reached it.
|
|
417
|
+
async send(to: string, message: string): Promise<{ record: AgentRecord; running: boolean }> {
|
|
418
|
+
const { id } = this.owned(to).record.agent;
|
|
419
|
+
// Another send may have launched a run while this one awaited, so the state
|
|
420
|
+
// is read again after every wait and the launch follows the last read.
|
|
421
|
+
for (let state = this.agents.get(id); state?.kind === "local"; state = this.agents.get(id)) {
|
|
422
|
+
const { run } = state;
|
|
423
|
+
const { response, taken } = await run.child.steer(message);
|
|
424
|
+
if (taken) return { record: this.find(id).record, running: true };
|
|
425
|
+
if (response && !response.success) throw new Error(`Agent ${id} did not take the message: ${response.error}`);
|
|
426
|
+
await run.done;
|
|
427
|
+
if (run.ending) throw new Error(`Agent ${id} was stopped before it read the message; it was not delivered.`);
|
|
428
|
+
}
|
|
429
|
+
return { record: this.launch(this.find(id).record.agent, message, true), running: false };
|
|
430
|
+
}
|
|
431
|
+
|
|
432
|
+
async stop(to: string, ending: NonNullable<Run["ending"]> = "stopped"): Promise<EndedRecord> {
|
|
433
|
+
const state = this.owned(to);
|
|
434
|
+
if (state.kind === "ended") return state.record;
|
|
435
|
+
const { run } = state;
|
|
436
|
+
if (run.ending !== "teardown") run.ending = ending;
|
|
437
|
+
run.child.end(this.settings.killGraceMs);
|
|
438
|
+
return run.done;
|
|
439
|
+
}
|
|
440
|
+
|
|
441
|
+
async stopAll(): Promise<void> {
|
|
442
|
+
this.closed = true;
|
|
443
|
+
await Promise.all(this.locals().map((state) => this.stop(state.record.agent.id, "teardown")));
|
|
444
|
+
this.ui?.setStatus(STATUS_KEY, undefined);
|
|
445
|
+
}
|
|
446
|
+
|
|
447
|
+
// For an exit that cannot wait: SIGTERM lets each child pi stop its own agents.
|
|
448
|
+
signalAll(): void {
|
|
449
|
+
this.closed = true;
|
|
450
|
+
for (const { run } of this.locals()) {
|
|
451
|
+
run.ending = "teardown";
|
|
452
|
+
run.child.signal("SIGTERM");
|
|
453
|
+
}
|
|
454
|
+
}
|
|
455
|
+
|
|
456
|
+
list(): AgentRecord[] {
|
|
457
|
+
return [...this.agents.values()].map((state) => this.refreshRestored(state).record);
|
|
458
|
+
}
|
|
459
|
+
|
|
460
|
+
private persist(record: AgentRecord): void {
|
|
461
|
+
this.pi.appendEntry(ENTRY_TYPE, record);
|
|
462
|
+
}
|
|
463
|
+
|
|
464
|
+
private refreshRestored(state: AgentState): AgentState {
|
|
465
|
+
if (state.kind === "local" || state.kind === "ended") return state;
|
|
466
|
+
const { record } = state;
|
|
467
|
+
const fate = fateOf(record);
|
|
468
|
+
if (fate === "kept" && state.kind === "remote") return state;
|
|
469
|
+
if (fate !== "gone") {
|
|
470
|
+
if (state.kind === "interrupted") return state;
|
|
471
|
+
const restored: AgentState = {
|
|
472
|
+
kind: fate === "orphan" ? "interrupted" : "unverified",
|
|
473
|
+
record,
|
|
474
|
+
};
|
|
475
|
+
this.agents.set(record.agent.id, restored);
|
|
476
|
+
if (restored.kind === "interrupted") {
|
|
477
|
+
void reapOrphan(record, this.settings.killGraceMs).then(() => {
|
|
478
|
+
if (this.agents.get(record.agent.id) === restored) {
|
|
479
|
+
this.agents.set(record.agent.id, { kind: "unverified", record });
|
|
480
|
+
}
|
|
481
|
+
});
|
|
482
|
+
}
|
|
483
|
+
return restored;
|
|
484
|
+
}
|
|
485
|
+
const stopped: EndedRecord = {
|
|
486
|
+
agent: record.agent,
|
|
487
|
+
status: "stopped",
|
|
488
|
+
pid: record.pid,
|
|
489
|
+
exitCode: null,
|
|
490
|
+
endedAt: now(),
|
|
491
|
+
finalText: "(interrupted: the session that started it ended)",
|
|
492
|
+
};
|
|
493
|
+
const ended: AgentState = { kind: "ended", record: stopped };
|
|
494
|
+
this.agents.set(record.agent.id, ended);
|
|
495
|
+
this.persist(stopped);
|
|
496
|
+
return ended;
|
|
497
|
+
}
|
|
498
|
+
|
|
499
|
+
// A restored process stays unavailable until its exit is confirmed. Only a
|
|
500
|
+
// process whose identity matches the record can be signalled.
|
|
501
|
+
restore(entries: readonly SessionEntry[]): void {
|
|
502
|
+
for (const entry of entries) {
|
|
503
|
+
if (entry.type !== "custom" || entry.customType !== ENTRY_TYPE || !Value.Check(recordSchema, entry.data)) continue;
|
|
504
|
+
const { id } = entry.data.agent;
|
|
505
|
+
if (this.agents.get(id)?.kind === "local") continue;
|
|
506
|
+
this.agents.set(id, entry.data.status === "running" ? { kind: "remote", record: entry.data } : { kind: "ended", record: entry.data });
|
|
507
|
+
}
|
|
508
|
+
for (const state of this.agents.values()) this.refreshRestored(state);
|
|
509
|
+
}
|
|
510
|
+
}
|
package/plugin/pi/ask.ts
ADDED
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import type { ExtensionAPI, ExtensionContext } from "@earendil-works/pi-coding-agent";
|
|
2
|
+
import { type Static, Type } from "typebox";
|
|
3
|
+
|
|
4
|
+
import type { OneShot } from "./one-shot.ts";
|
|
5
|
+
|
|
6
|
+
export const OTHER = "Other (type an answer)";
|
|
7
|
+
export const DONE = "Done";
|
|
8
|
+
|
|
9
|
+
const question = Type.Object(
|
|
10
|
+
{
|
|
11
|
+
question: Type.String({ description: "The complete question to ask the user" }),
|
|
12
|
+
header: Type.Optional(Type.String({ description: "Very short label for the question (max 12 chars)" })),
|
|
13
|
+
options: Type.Array(Type.Object({ label: Type.String(), description: Type.Optional(Type.String()) }), { minItems: 2, maxItems: 4 }),
|
|
14
|
+
multiSelect: Type.Optional(Type.Boolean({ description: "Allow more than one answer" })),
|
|
15
|
+
},
|
|
16
|
+
);
|
|
17
|
+
type Question = Static<typeof question>;
|
|
18
|
+
const questionParams = Type.Object({ questions: Type.Array(question, { minItems: 1, maxItems: 4 }) });
|
|
19
|
+
|
|
20
|
+
type Ui = ExtensionContext["ui"];
|
|
21
|
+
|
|
22
|
+
// undefined means the user dismissed the dialog.
|
|
23
|
+
async function ask(ui: Ui, q: Question, signal: AbortSignal | undefined): Promise<string | undefined> {
|
|
24
|
+
const title = q.header ? `${q.header}: ${q.question}` : q.question;
|
|
25
|
+
// Pi returns the displayed string, so number choices to distinguish them
|
|
26
|
+
// from controls and from other choices with the same rendered text.
|
|
27
|
+
const labels = new Map(q.options.map((o, i) => [`${i + 1}. ${o.label}${o.description ? ` - ${o.description}` : ""}`, o.label]));
|
|
28
|
+
// The label of a listed pick, or what the user types for OTHER.
|
|
29
|
+
const answer = (pick: string) => (pick === OTHER ? ui.input(title, "Your answer", { signal }) : labels.get(pick));
|
|
30
|
+
if (!q.multiSelect) {
|
|
31
|
+
const pick = await ui.select(title, [...labels.keys(), OTHER], { signal });
|
|
32
|
+
return pick === undefined ? undefined : answer(pick);
|
|
33
|
+
}
|
|
34
|
+
const picked = new Set<string>();
|
|
35
|
+
const chosen: string[] = [];
|
|
36
|
+
for (;;) {
|
|
37
|
+
const remaining = [...labels.keys()].filter((text) => !picked.has(text));
|
|
38
|
+
const pick = await ui.select(`${title} (one at a time; ${DONE} when finished)`, [...remaining, OTHER, DONE], { signal });
|
|
39
|
+
if (pick === undefined) return undefined;
|
|
40
|
+
if (pick === DONE) return chosen.join(", ");
|
|
41
|
+
const text = await answer(pick);
|
|
42
|
+
if (text === undefined) return undefined;
|
|
43
|
+
picked.add(pick);
|
|
44
|
+
chosen.push(text);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
// model-only exposure keeps the tool declared under codemode.mode "only".
|
|
49
|
+
export function registerAsk(pi: ExtensionAPI, oneShot: OneShot): void {
|
|
50
|
+
pi.registerTool({
|
|
51
|
+
name: "ask_user_question",
|
|
52
|
+
label: "Ask user",
|
|
53
|
+
exposure: "model-only",
|
|
54
|
+
description:
|
|
55
|
+
"Ask the user 1-4 structured questions, each with 2-4 options; the user can also type their own answer. Use it for genuine preference calls the user must make.",
|
|
56
|
+
parameters: questionParams,
|
|
57
|
+
executionMode: "sequential",
|
|
58
|
+
async execute(_id, params, signal, _onUpdate, ctx) {
|
|
59
|
+
// An rpc child reports a UI, but its parent cancels every dialog, so asking
|
|
60
|
+
// could only report a dismissal.
|
|
61
|
+
if (!ctx.hasUI || oneShot.exits(ctx)) {
|
|
62
|
+
throw new Error(
|
|
63
|
+
"ask_user_question needs an interactive UI, and this session has none. Ask the user in plain text instead and wait for the reply.",
|
|
64
|
+
);
|
|
65
|
+
}
|
|
66
|
+
const answers: { question: string; answer: string }[] = [];
|
|
67
|
+
for (const q of params.questions) {
|
|
68
|
+
const answer = await ask(ctx.ui, q, signal);
|
|
69
|
+
if (answer === undefined) break;
|
|
70
|
+
answers.push({ question: q.question, answer });
|
|
71
|
+
}
|
|
72
|
+
const dismissed = answers.length < params.questions.length;
|
|
73
|
+
const text = answers.map((a) => `"${a.question}"="${a.answer}"`).join(", ");
|
|
74
|
+
// Pi sends content to the model; details alone cannot preserve earlier answers.
|
|
75
|
+
const answered = answers.length ? `User has answered your questions: ${text}. ` : "";
|
|
76
|
+
const status = !dismissed
|
|
77
|
+
? "You can now continue with the user's answers in mind."
|
|
78
|
+
: answers.length
|
|
79
|
+
? "The user dismissed the remaining questions without answering."
|
|
80
|
+
: "The user dismissed the question without answering.";
|
|
81
|
+
return {
|
|
82
|
+
content: [{ type: "text", text: answered + status }],
|
|
83
|
+
details: { answers, dismissed },
|
|
84
|
+
};
|
|
85
|
+
},
|
|
86
|
+
});
|
|
87
|
+
}
|