dsh-pstack 0.1.0 → 0.2.0-beta.3
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 +2 -3
- package/README.md +174 -148
- package/README.zh.md +185 -0
- package/assets/logo.png +0 -0
- package/cordis.patch.yml +103 -14
- package/dist/host-contract-CUPSpeNk.d.mts +22 -0
- package/dist/index.d.mts +87 -14
- package/dist/index.mjs +370 -143
- package/dist/models.d.mts +44 -0
- package/dist/models.mjs +201 -0
- package/dist/paths-BT77khwm.mjs +48 -0
- package/dist/{LICENSE → pstack/LICENSE} +1 -2
- package/dist/pstack/README.md +291 -0
- package/{assets → dist/pstack}/agents/comment-sicko.md +1 -1
- package/dist/pstack/agents/poteto-agent.md +9 -0
- package/{assets → dist/pstack}/docs/guide/01-setup.md +11 -9
- package/dist/{assets → pstack}/docs/guide/02-poteto-mode.md +2 -2
- package/{assets → dist/pstack}/docs/guide/04-design.md +4 -4
- package/dist/{assets → pstack}/docs/guide/05-build-and-clean.md +3 -3
- package/dist/{assets → pstack}/docs/guide/06-verify-and-ship.md +11 -1
- package/{assets → dist/pstack}/docs/guide/07-overnight.md +10 -10
- package/dist/{assets → pstack}/docs/guide/09-make-it-yours.md +4 -4
- package/{assets → dist/pstack}/docs/guide/10-recipes-and-pitfalls.md +6 -4
- package/dist/pstack/docs/guide/images/design.jpg +0 -0
- package/dist/pstack/docs/guide/images/overnight.jpg +0 -0
- package/dist/pstack/docs/guide/images/recipes.jpg +0 -0
- package/dist/pstack/docs/guide/images/router.jpg +0 -0
- package/dist/pstack/docs/guide/images/understanding.jpg +0 -0
- package/dist/pstack/docs/guide/images/verification.jpg +0 -0
- package/dist/pstack/docs/harness/dsh.md +98 -0
- package/{assets → dist/pstack}/skills/architect/SKILL.md +5 -5
- package/dist/pstack/skills/arena/SKILL.md +50 -0
- package/{assets → dist/pstack}/skills/automate-me/SKILL.md +14 -13
- package/dist/{assets → pstack}/skills/benchmark-checklist/SKILL.md +1 -3
- package/dist/{assets → pstack}/skills/blast-radius/SKILL.md +1 -3
- package/{assets → dist/pstack}/skills/bro/SKILL.md +0 -2
- package/dist/{assets → pstack}/skills/correct/SKILL.md +1 -3
- package/{assets → dist/pstack}/skills/create-formal-verification-skill/SKILL.md +5 -3
- package/{assets → dist/pstack}/skills/create-verification-skill/SKILL.md +6 -6
- package/{assets → dist/pstack}/skills/figure-it-out/SKILL.md +4 -4
- package/dist/{assets → pstack}/skills/how/SKILL.md +4 -4
- package/{assets → dist/pstack}/skills/how/references/explainer-prompt.md +1 -1
- package/dist/pstack/skills/in-your-own-words/SKILL.md +7 -0
- package/dist/pstack/skills/interrogate/SKILL.md +33 -0
- package/{assets → dist/pstack}/skills/ketchup/SKILL.md +1 -3
- package/dist/pstack/skills/ketchup-video/SKILL.md +29 -0
- package/{assets → dist/pstack}/skills/maintain-formal-verification-skill/SKILL.md +2 -2
- package/dist/{assets → pstack}/skills/maintain-verification-skill/SKILL.md +3 -3
- package/dist/pstack/skills/make-bot-ui/SKILL.md +117 -0
- package/{assets → dist/pstack}/skills/no-comments/SKILL.md +4 -4
- package/{assets → dist/pstack}/skills/poteto-help/SKILL.md +21 -17
- package/dist/{assets → pstack}/skills/poteto-help/references/prompting.md +1 -1
- package/dist/{assets → pstack}/skills/poteto-help/references/recipes.md +3 -3
- package/{assets → dist/pstack}/skills/poteto-mode/SKILL.md +20 -21
- package/dist/{assets → pstack}/skills/poteto-mode/playbooks/authoring-a-skill.md +1 -1
- package/dist/{assets → pstack}/skills/poteto-mode/playbooks/autonomous-run.md +2 -2
- package/{assets → dist/pstack}/skills/poteto-mode/playbooks/autopilot-full.md +7 -7
- package/dist/pstack/skills/poteto-mode/playbooks/autopilot-stack.md +8 -0
- package/{assets → dist/pstack}/skills/poteto-mode/playbooks/babysit.md +3 -3
- package/{assets → dist/pstack}/skills/poteto-mode/playbooks/bug-fix.md +3 -3
- package/dist/{assets → pstack}/skills/poteto-mode/playbooks/eval.md +1 -1
- package/{assets → dist/pstack}/skills/poteto-mode/playbooks/feature.md +1 -1
- package/{assets → dist/pstack}/skills/poteto-mode/playbooks/hillclimb.md +1 -1
- package/{assets → dist/pstack}/skills/poteto-mode/playbooks/multi-phase-plan.md +13 -13
- package/dist/{assets → pstack}/skills/poteto-mode/playbooks/opening-a-pr.md +3 -3
- package/dist/pstack/skills/poteto-mode/playbooks/orchestrate.md +25 -0
- package/dist/{assets → pstack}/skills/poteto-mode/playbooks/perf-issue.md +2 -2
- package/{assets → dist/pstack}/skills/poteto-mode/playbooks/prototype.md +1 -1
- package/dist/{assets → pstack}/skills/poteto-mode/playbooks/refactoring.md +2 -2
- package/{assets → dist/pstack}/skills/poteto-mode/playbooks/runtime-forensics.md +1 -1
- package/{assets → dist/pstack}/skills/poteto-mode/playbooks/session-pickup.md +1 -1
- package/dist/{assets → pstack}/skills/poteto-mode/playbooks/shipping.md +2 -2
- package/{assets → dist/pstack}/skills/poteto-mode/playbooks/visual-parity.md +1 -1
- package/dist/{assets → pstack}/skills/poteto-mode/playbooks/worktree-cleanup.md +2 -2
- package/{assets → dist/pstack}/skills/poteto-mode/scripts/check-plan.mjs +83 -70
- package/dist/{assets/skills/poteto-mode/scripts/check-plan.test.ts → pstack/skills/poteto-mode/scripts/check-plan.test.mjs} +53 -21
- package/dist/pstack/skills/poteto-mode/scripts/expect.mjs +254 -0
- package/dist/pstack/skills/poteto-mode/scripts/support.mjs +93 -0
- package/dist/pstack/skills/poteto-mode/scripts/watch-pr/cli.mjs +123 -0
- package/dist/pstack/skills/poteto-mode/scripts/watch-pr/cli.test.mjs +217 -0
- package/dist/pstack/skills/poteto-mode/scripts/watch-pr/fakes.test-helper.mjs +119 -0
- package/dist/pstack/skills/poteto-mode/scripts/watch-pr/github.mjs +626 -0
- package/dist/pstack/skills/poteto-mode/scripts/watch-pr/github.test.mjs +521 -0
- package/dist/pstack/skills/poteto-mode/scripts/watch-pr/policy.mjs +657 -0
- package/dist/pstack/skills/poteto-mode/scripts/watch-pr/policy.test.mjs +523 -0
- package/dist/pstack/skills/poteto-mode/scripts/watch-pr/render.mjs +106 -0
- package/dist/pstack/skills/poteto-mode/scripts/watch-pr/types.mjs +9 -0
- package/dist/pstack/skills/poteto-mode/scripts/watch-pr/watch-pr.mjs +5 -0
- package/dist/pstack/skills/poteto-mode/scripts/worktree-audit.mjs +668 -0
- package/dist/pstack/skills/poteto-mode/scripts/worktree-audit.test.mjs +134 -0
- package/{assets → dist/pstack}/skills/principle-attack-the-premise/SKILL.md +1 -3
- package/{assets → dist/pstack}/skills/principle-boundary-discipline/SKILL.md +1 -3
- package/{assets → dist/pstack}/skills/principle-build-the-lever/SKILL.md +0 -3
- package/dist/pstack/skills/principle-encode-lessons-in-structure/SKILL.md +11 -0
- package/dist/pstack/skills/principle-exhaust-the-design-space/SKILL.md +9 -0
- package/{assets → dist/pstack}/skills/principle-experience-first/SKILL.md +1 -3
- package/dist/{assets → pstack}/skills/principle-explain-the-number/SKILL.md +3 -4
- package/dist/{assets → pstack}/skills/principle-fix-root-causes/SKILL.md +1 -3
- package/{assets → dist/pstack}/skills/principle-foundational-thinking/SKILL.md +0 -2
- package/dist/{assets → pstack}/skills/principle-guard-the-context-window/SKILL.md +0 -2
- package/dist/{assets → pstack}/skills/principle-laziness-protocol/SKILL.md +1 -3
- package/dist/{assets → pstack}/skills/principle-make-operations-idempotent/SKILL.md +1 -3
- package/dist/{assets → pstack}/skills/principle-migrate-callers-then-delete-legacy-apis/SKILL.md +1 -3
- package/{assets → dist/pstack}/skills/principle-minimize-reader-load/SKILL.md +1 -3
- package/{assets → dist/pstack}/skills/principle-model-the-domain/SKILL.md +1 -3
- package/{assets → dist/pstack}/skills/principle-never-block-on-the-human/SKILL.md +1 -3
- package/dist/{assets → pstack}/skills/principle-outcome-oriented-execution/SKILL.md +1 -3
- package/{assets → dist/pstack}/skills/principle-prove-it-works/SKILL.md +3 -3
- package/dist/{assets → pstack}/skills/principle-redesign-from-first-principles/SKILL.md +1 -3
- package/{assets → dist/pstack}/skills/principle-separate-before-serializing-shared-state/SKILL.md +1 -3
- package/dist/{assets → pstack}/skills/principle-sequence-verifiable-units/SKILL.md +1 -3
- package/dist/{assets → pstack}/skills/principle-subtract-before-you-add/SKILL.md +1 -3
- package/{assets → dist/pstack}/skills/principle-test-behavior-not-implementation/SKILL.md +1 -3
- package/{assets → dist/pstack}/skills/principle-type-system-discipline/SKILL.md +1 -3
- package/dist/{assets → pstack}/skills/recall/SKILL.md +4 -4
- package/dist/pstack/skills/reflect/SKILL.md +71 -0
- package/{assets → dist/pstack}/skills/reflect/references/divergent-reviewer.md +1 -1
- package/{assets → dist/pstack}/skills/reflect/references/judgment-reviewer.md +1 -1
- package/{assets → dist/pstack}/skills/reflect/references/synthesizer.md +3 -3
- package/dist/{assets → pstack}/skills/reflect/references/tooling-reviewer.md +1 -1
- package/dist/pstack/skills/setup-pstack/SKILL.md +80 -0
- package/{assets → dist/pstack}/skills/sharpen/SKILL.md +1 -3
- package/{assets → dist/pstack}/skills/show-me-your-work/SKILL.md +3 -3
- package/dist/pstack/skills/show-me-your-work/scripts/log.mjs +106 -0
- package/dist/pstack/skills/show-me-your-work/scripts/log.test.mjs +56 -0
- package/dist/pstack/skills/statechart/SKILL.md +82 -0
- package/dist/pstack/skills/statechart/references/render.md +93 -0
- package/dist/pstack/skills/statechart/scripts/backends/cfg.mjs +31 -0
- package/dist/pstack/skills/statechart/scripts/backends/mermaid.mjs +186 -0
- package/dist/pstack/skills/statechart/scripts/backends/plain-text.mjs +62 -0
- package/dist/pstack/skills/statechart/scripts/backends/report.mjs +84 -0
- package/dist/pstack/skills/statechart/scripts/frontends/config.mjs +268 -0
- package/dist/pstack/skills/statechart/scripts/frontends/dot.mjs +67 -0
- package/dist/pstack/skills/statechart/scripts/frontends/marks.mjs +94 -0
- package/dist/pstack/skills/statechart/scripts/frontends/messages.mjs +48 -0
- package/dist/pstack/skills/statechart/scripts/frontends/spec.mjs +101 -0
- package/dist/pstack/skills/statechart/scripts/frontends/trace.mjs +39 -0
- package/dist/pstack/skills/statechart/scripts/frontends/value.mjs +180 -0
- package/dist/pstack/skills/statechart/scripts/frontends/verdict.mjs +40 -0
- package/dist/pstack/skills/statechart/scripts/frontends/view.mjs +99 -0
- package/dist/pstack/skills/statechart/scripts/ir.mjs +277 -0
- package/dist/pstack/skills/statechart/scripts/passes/annotate.mjs +92 -0
- package/dist/pstack/skills/statechart/scripts/passes/label.mjs +210 -0
- package/dist/pstack/skills/statechart/scripts/passes/lift.mjs +84 -0
- package/dist/pstack/skills/statechart/scripts/passes/loop-check.mjs +47 -0
- package/dist/pstack/skills/statechart/scripts/passes/paths.mjs +72 -0
- package/dist/pstack/skills/statechart/scripts/passes/reach.mjs +135 -0
- package/dist/pstack/skills/statechart/scripts/passes/region-check.mjs +82 -0
- package/dist/pstack/skills/statechart/scripts/passes/regions.mjs +268 -0
- package/dist/pstack/skills/statechart/scripts/pipeline.mjs +72 -0
- package/dist/pstack/skills/statechart/scripts/run.mjs +440 -0
- package/dist/pstack/skills/statechart/scripts/statechart.mjs +155 -0
- package/dist/pstack/skills/statechart/scripts/statechart.test.mjs +198 -0
- package/dist/pstack/skills/statechart/scripts/worker.mjs +31 -0
- package/dist/pstack/skills/swarm/SKILL.md +43 -0
- package/{assets → dist/pstack}/skills/tdd/SKILL.md +1 -3
- package/{assets → dist/pstack}/skills/teach/SKILL.md +3 -3
- package/{assets → dist/pstack}/skills/technical-writing/SKILL.md +2 -2
- package/{assets → dist/pstack}/skills/typescript-best-practices/SKILL.md +1 -2
- package/{assets → dist/pstack}/skills/unslop/SKILL.md +0 -2
- package/dist/{assets → pstack}/skills/why/SKILL.md +9 -9
- package/dist/script.d.mts +91 -0
- package/dist/script.mjs +485 -0
- package/dist/skill.d.mts +38 -0
- package/dist/skill.mjs +183 -0
- package/dist/skills/authored/decision-audit/SKILL.md +99 -0
- package/dist/skills/authored/decision-audit/SKILL.zh.md +99 -0
- package/dist/skills/authored/decision-audit/references/recover-commit.md +17 -0
- package/dist/skills/authored/decision-audit/references/recover-commit.zh.md +17 -0
- package/dist/skills/authored/decision-write/SKILL.md +131 -0
- package/dist/skills/authored/decision-write/SKILL.zh.md +131 -0
- package/dist/skills/authored/decision-write/references/land.md +48 -0
- package/dist/skills/authored/decision-write/references/land.zh.md +48 -0
- package/dist/skills/authored/setup-project-docs/SKILL.md +58 -0
- package/dist/skills/authored/setup-project-docs/SKILL.zh.md +58 -0
- package/dist/skills/authored/setup-project-docs/references/decision-conventions.md +11 -0
- package/dist/skills/authored/setup-project-docs/references/decision-conventions.zh.md +11 -0
- package/dist/skills/vendored/retro/SKILL.md +44 -0
- package/dist/skills/vendored/retro/agents/openai.yaml +5 -0
- package/dist/skills/vendored/writing-for-agents/SKILL-MECHANICS.md +22 -0
- package/dist/skills/vendored/writing-for-agents/SKILL.md +81 -0
- package/dist/skills/vendored/writing-for-agents/agents/openai.yaml +3 -0
- package/dist/subagent.d.mts +175 -106
- package/dist/subagent.mjs +1012 -344
- package/locale/en.json +7 -0
- package/locale/zh.json +7 -0
- package/package.json +61 -50
- package/assets/agents/poteto-agent.md +0 -8
- package/assets/docs/guide/02-poteto-mode.md +0 -139
- package/assets/docs/guide/05-build-and-clean.md +0 -83
- package/assets/docs/guide/06-verify-and-ship.md +0 -152
- package/assets/docs/guide/09-make-it-yours.md +0 -100
- package/assets/docs/harness/dsh.md +0 -65
- package/assets/docs/pstack-models.example.md +0 -23
- package/assets/skills/arena/SKILL.md +0 -50
- package/assets/skills/benchmark-checklist/SKILL.md +0 -41
- package/assets/skills/blast-radius/SKILL.md +0 -52
- package/assets/skills/correct/SKILL.md +0 -34
- package/assets/skills/how/SKILL.md +0 -38
- package/assets/skills/in-your-own-words/SKILL.md +0 -9
- package/assets/skills/interrogate/SKILL.md +0 -69
- package/assets/skills/interrogate/references/code-quality-review.md +0 -47
- package/assets/skills/interrogate/references/lead-judgment.md +0 -39
- package/assets/skills/interrogate/references/reviewer-prompt.md +0 -62
- package/assets/skills/interrogate/references/rubric.md +0 -77
- package/assets/skills/maintain-verification-skill/SKILL.md +0 -41
- package/assets/skills/poteto-help/references/prompting.md +0 -51
- package/assets/skills/poteto-help/references/recipes.md +0 -51
- package/assets/skills/poteto-mode/playbooks/authoring-a-skill.md +0 -12
- package/assets/skills/poteto-mode/playbooks/autonomous-run.md +0 -13
- package/assets/skills/poteto-mode/playbooks/autopilot-stack.md +0 -12
- package/assets/skills/poteto-mode/playbooks/eval.md +0 -25
- package/assets/skills/poteto-mode/playbooks/opening-a-pr.md +0 -34
- package/assets/skills/poteto-mode/playbooks/orchestrate.md +0 -112
- package/assets/skills/poteto-mode/playbooks/perf-issue.md +0 -25
- package/assets/skills/poteto-mode/playbooks/refactoring.md +0 -16
- package/assets/skills/poteto-mode/playbooks/shipping.md +0 -12
- package/assets/skills/poteto-mode/playbooks/worktree-cleanup.md +0 -12
- package/assets/skills/poteto-mode/scripts/bootstrap.ts +0 -62
- package/assets/skills/poteto-mode/scripts/bun.lock +0 -67
- package/assets/skills/poteto-mode/scripts/check-plan.test.ts +0 -96
- package/assets/skills/poteto-mode/scripts/orch/orch.test.ts +0 -761
- package/assets/skills/poteto-mode/scripts/orch/orch.ts +0 -590
- package/assets/skills/poteto-mode/scripts/orch/store.ts +0 -1677
- package/assets/skills/poteto-mode/scripts/package.json +0 -16
- package/assets/skills/poteto-mode/scripts/watch-pr/cli.test.ts +0 -224
- package/assets/skills/poteto-mode/scripts/watch-pr/cli.ts +0 -223
- package/assets/skills/poteto-mode/scripts/watch-pr/fakes.test-helper.ts +0 -129
- package/assets/skills/poteto-mode/scripts/watch-pr/github.test.ts +0 -436
- package/assets/skills/poteto-mode/scripts/watch-pr/github.ts +0 -718
- package/assets/skills/poteto-mode/scripts/watch-pr/policy.test.ts +0 -420
- package/assets/skills/poteto-mode/scripts/watch-pr/policy.ts +0 -836
- package/assets/skills/poteto-mode/scripts/watch-pr/render.ts +0 -169
- package/assets/skills/poteto-mode/scripts/watch-pr/tsconfig.json +0 -13
- package/assets/skills/poteto-mode/scripts/watch-pr/types.compile.ts +0 -93
- package/assets/skills/poteto-mode/scripts/watch-pr/types.ts +0 -413
- package/assets/skills/poteto-mode/scripts/watch-pr/watch-pr +0 -6
- package/assets/skills/poteto-mode/scripts/worktree-audit.sh +0 -127
- package/assets/skills/principle-encode-lessons-in-structure/SKILL.md +0 -13
- package/assets/skills/principle-exhaust-the-design-space/SKILL.md +0 -11
- package/assets/skills/principle-explain-the-number/SKILL.md +0 -19
- package/assets/skills/principle-fix-root-causes/SKILL.md +0 -23
- package/assets/skills/principle-guard-the-context-window/SKILL.md +0 -14
- package/assets/skills/principle-laziness-protocol/SKILL.md +0 -12
- package/assets/skills/principle-make-operations-idempotent/SKILL.md +0 -24
- package/assets/skills/principle-migrate-callers-then-delete-legacy-apis/SKILL.md +0 -16
- package/assets/skills/principle-outcome-oriented-execution/SKILL.md +0 -23
- package/assets/skills/principle-redesign-from-first-principles/SKILL.md +0 -18
- package/assets/skills/principle-sequence-verifiable-units/SKILL.md +0 -19
- package/assets/skills/principle-subtract-before-you-add/SKILL.md +0 -20
- package/assets/skills/recall/SKILL.md +0 -37
- package/assets/skills/reflect/SKILL.md +0 -70
- package/assets/skills/reflect/references/tooling-reviewer.md +0 -48
- package/assets/skills/setup-pstack/SKILL.md +0 -76
- package/assets/skills/show-me-your-work/scripts/log.sh +0 -42
- package/assets/skills/swarm/SKILL.md +0 -41
- package/assets/skills/why/SKILL.md +0 -100
- package/dist/README.md +0 -159
- package/dist/assets/agents/comment-sicko.md +0 -32
- package/dist/assets/agents/poteto-agent.md +0 -8
- package/dist/assets/docs/guide/01-setup.md +0 -64
- package/dist/assets/docs/guide/03-understand.md +0 -79
- package/dist/assets/docs/guide/04-design.md +0 -133
- package/dist/assets/docs/guide/07-overnight.md +0 -122
- package/dist/assets/docs/guide/08-principles.md +0 -72
- package/dist/assets/docs/guide/10-recipes-and-pitfalls.md +0 -180
- package/dist/assets/docs/guide/README.md +0 -38
- package/dist/assets/docs/harness/dsh.md +0 -65
- package/dist/assets/docs/pstack-models.example.md +0 -23
- package/dist/assets/skills/architect/SKILL.md +0 -81
- package/dist/assets/skills/architect/references/design-red-flags.md +0 -57
- package/dist/assets/skills/architect/references/rationale-template.md +0 -35
- package/dist/assets/skills/architect/references/runner-prompt.md +0 -20
- package/dist/assets/skills/arena/SKILL.md +0 -50
- package/dist/assets/skills/automate-me/SKILL.md +0 -105
- package/dist/assets/skills/bro/SKILL.md +0 -9
- package/dist/assets/skills/create-formal-verification-skill/SKILL.md +0 -43
- package/dist/assets/skills/create-verification-skill/SKILL.md +0 -46
- package/dist/assets/skills/create-verification-skill/references/feature-map-example/README.md +0 -47
- package/dist/assets/skills/create-verification-skill/references/feature-map-example/create-note.md +0 -39
- package/dist/assets/skills/create-verification-skill/references/feature-map-example/search.md +0 -45
- package/dist/assets/skills/figure-it-out/SKILL.md +0 -54
- package/dist/assets/skills/how/references/explainer-prompt.md +0 -55
- package/dist/assets/skills/how/references/explorer-prompt.md +0 -35
- package/dist/assets/skills/in-your-own-words/SKILL.md +0 -9
- package/dist/assets/skills/interrogate/SKILL.md +0 -69
- package/dist/assets/skills/interrogate/references/code-quality-review.md +0 -47
- package/dist/assets/skills/interrogate/references/lead-judgment.md +0 -39
- package/dist/assets/skills/interrogate/references/reviewer-prompt.md +0 -62
- package/dist/assets/skills/interrogate/references/rubric.md +0 -77
- package/dist/assets/skills/ketchup/SKILL.md +0 -45
- package/dist/assets/skills/maintain-formal-verification-skill/SKILL.md +0 -60
- package/dist/assets/skills/no-comments/SKILL.md +0 -26
- package/dist/assets/skills/poteto-help/SKILL.md +0 -161
- package/dist/assets/skills/poteto-mode/SKILL.md +0 -153
- package/dist/assets/skills/poteto-mode/playbooks/autopilot-full.md +0 -25
- package/dist/assets/skills/poteto-mode/playbooks/autopilot-stack.md +0 -12
- package/dist/assets/skills/poteto-mode/playbooks/babysit.md +0 -23
- package/dist/assets/skills/poteto-mode/playbooks/bug-fix.md +0 -15
- package/dist/assets/skills/poteto-mode/playbooks/feature.md +0 -21
- package/dist/assets/skills/poteto-mode/playbooks/hillclimb.md +0 -21
- package/dist/assets/skills/poteto-mode/playbooks/investigation.md +0 -14
- package/dist/assets/skills/poteto-mode/playbooks/multi-phase-plan.md +0 -155
- package/dist/assets/skills/poteto-mode/playbooks/orchestrate.md +0 -112
- package/dist/assets/skills/poteto-mode/playbooks/pause-safely.md +0 -10
- package/dist/assets/skills/poteto-mode/playbooks/prototype.md +0 -14
- package/dist/assets/skills/poteto-mode/playbooks/runtime-forensics.md +0 -11
- package/dist/assets/skills/poteto-mode/playbooks/session-pickup.md +0 -11
- package/dist/assets/skills/poteto-mode/playbooks/trace-forensics.md +0 -14
- package/dist/assets/skills/poteto-mode/playbooks/visual-parity.md +0 -11
- package/dist/assets/skills/poteto-mode/references/bugbot-triage.md +0 -142
- package/dist/assets/skills/poteto-mode/scripts/bootstrap.ts +0 -62
- package/dist/assets/skills/poteto-mode/scripts/bun.lock +0 -67
- package/dist/assets/skills/poteto-mode/scripts/check-plan.mjs +0 -205
- package/dist/assets/skills/poteto-mode/scripts/orch/orch.test.ts +0 -761
- package/dist/assets/skills/poteto-mode/scripts/orch/orch.ts +0 -590
- package/dist/assets/skills/poteto-mode/scripts/orch/store.ts +0 -1677
- package/dist/assets/skills/poteto-mode/scripts/package.json +0 -16
- package/dist/assets/skills/poteto-mode/scripts/watch-pr/cli.test.ts +0 -224
- package/dist/assets/skills/poteto-mode/scripts/watch-pr/cli.ts +0 -223
- package/dist/assets/skills/poteto-mode/scripts/watch-pr/fakes.test-helper.ts +0 -129
- package/dist/assets/skills/poteto-mode/scripts/watch-pr/github.test.ts +0 -436
- package/dist/assets/skills/poteto-mode/scripts/watch-pr/github.ts +0 -718
- package/dist/assets/skills/poteto-mode/scripts/watch-pr/policy.test.ts +0 -420
- package/dist/assets/skills/poteto-mode/scripts/watch-pr/policy.ts +0 -836
- package/dist/assets/skills/poteto-mode/scripts/watch-pr/render.ts +0 -169
- package/dist/assets/skills/poteto-mode/scripts/watch-pr/tsconfig.json +0 -13
- package/dist/assets/skills/poteto-mode/scripts/watch-pr/types.compile.ts +0 -93
- package/dist/assets/skills/poteto-mode/scripts/watch-pr/types.ts +0 -413
- package/dist/assets/skills/poteto-mode/scripts/watch-pr/watch-pr +0 -6
- package/dist/assets/skills/poteto-mode/scripts/worktree-audit.sh +0 -127
- package/dist/assets/skills/principle-attack-the-premise/SKILL.md +0 -23
- package/dist/assets/skills/principle-boundary-discipline/SKILL.md +0 -36
- package/dist/assets/skills/principle-build-the-lever/SKILL.md +0 -26
- package/dist/assets/skills/principle-encode-lessons-in-structure/SKILL.md +0 -13
- package/dist/assets/skills/principle-exhaust-the-design-space/SKILL.md +0 -11
- package/dist/assets/skills/principle-experience-first/SKILL.md +0 -21
- package/dist/assets/skills/principle-foundational-thinking/SKILL.md +0 -23
- package/dist/assets/skills/principle-minimize-reader-load/SKILL.md +0 -20
- package/dist/assets/skills/principle-model-the-domain/SKILL.md +0 -26
- package/dist/assets/skills/principle-never-block-on-the-human/SKILL.md +0 -17
- package/dist/assets/skills/principle-prove-it-works/SKILL.md +0 -24
- package/dist/assets/skills/principle-separate-before-serializing-shared-state/SKILL.md +0 -18
- package/dist/assets/skills/principle-test-behavior-not-implementation/SKILL.md +0 -22
- package/dist/assets/skills/principle-type-system-discipline/SKILL.md +0 -15
- package/dist/assets/skills/reflect/SKILL.md +0 -70
- package/dist/assets/skills/reflect/references/divergent-reviewer.md +0 -38
- package/dist/assets/skills/reflect/references/judgment-reviewer.md +0 -37
- package/dist/assets/skills/reflect/references/synthesizer.md +0 -56
- package/dist/assets/skills/setup-pstack/SKILL.md +0 -76
- package/dist/assets/skills/sharpen/SKILL.md +0 -18
- package/dist/assets/skills/show-me-your-work/SKILL.md +0 -84
- package/dist/assets/skills/show-me-your-work/references/decision-log-template.tsv +0 -1
- package/dist/assets/skills/show-me-your-work/scripts/log.sh +0 -42
- package/dist/assets/skills/swarm/SKILL.md +0 -41
- package/dist/assets/skills/tdd/SKILL.md +0 -44
- package/dist/assets/skills/teach/SKILL.md +0 -23
- package/dist/assets/skills/technical-writing/SKILL.md +0 -108
- package/dist/assets/skills/typescript-best-practices/SKILL.md +0 -32
- package/dist/assets/skills/typescript-best-practices/references/patterns.md +0 -328
- package/dist/assets/skills/unslop/SKILL.md +0 -64
- package/dist/assets/skills/why/references/epistemics.md +0 -71
- package/dist/assets/skills/why/references/investigator-prompt.md +0 -84
- package/dist/assets/skills/why/references/source-playbook.md +0 -17
- package/dist/assets/skills/why/references/sources/code-archaeology.md +0 -51
- package/dist/assets/skills/why/references/sources/databricks.md +0 -70
- package/dist/assets/skills/why/references/sources/datadog.md +0 -97
- package/dist/assets/skills/why/references/sources/incident-postmortem.md +0 -5
- package/dist/assets/skills/why/references/sources/linear.md +0 -48
- package/dist/assets/skills/why/references/sources/notion.md +0 -55
- package/dist/assets/skills/why/references/sources/sentry.md +0 -66
- package/dist/assets/skills/why/references/sources/slack.md +0 -17
- package/dist/assets/skills/why/references/synthesizer-prompt.md +0 -129
- package/dist/cordis.patch.yml +0 -20
- package/dist/index.mjs.map +0 -1
- package/dist/paths-Bbai4CaT.mjs +0 -16
- package/dist/paths-Bbai4CaT.mjs.map +0 -1
- package/dist/subagent.mjs.map +0 -1
- /package/{assets → dist/pstack}/docs/guide/03-understand.md +0 -0
- /package/{assets → dist/pstack}/docs/guide/08-principles.md +0 -0
- /package/{assets → dist/pstack}/docs/guide/README.md +0 -0
- /package/{assets → dist/pstack}/skills/architect/references/design-red-flags.md +0 -0
- /package/{assets → dist/pstack}/skills/architect/references/rationale-template.md +0 -0
- /package/{assets → dist/pstack}/skills/architect/references/runner-prompt.md +0 -0
- /package/{assets → dist/pstack}/skills/create-verification-skill/references/feature-map-example/README.md +0 -0
- /package/{assets → dist/pstack}/skills/create-verification-skill/references/feature-map-example/create-note.md +0 -0
- /package/{assets → dist/pstack}/skills/create-verification-skill/references/feature-map-example/search.md +0 -0
- /package/{assets → dist/pstack}/skills/how/references/explorer-prompt.md +0 -0
- /package/{assets → dist/pstack}/skills/poteto-mode/playbooks/investigation.md +0 -0
- /package/{assets → dist/pstack}/skills/poteto-mode/playbooks/pause-safely.md +0 -0
- /package/{assets → dist/pstack}/skills/poteto-mode/playbooks/trace-forensics.md +0 -0
- /package/{assets → dist/pstack}/skills/poteto-mode/references/bugbot-triage.md +0 -0
- /package/{assets → dist/pstack}/skills/show-me-your-work/references/decision-log-template.tsv +0 -0
- /package/{assets → dist/pstack}/skills/typescript-best-practices/references/patterns.md +0 -0
- /package/{assets → dist/pstack}/skills/why/references/epistemics.md +0 -0
- /package/{assets → dist/pstack}/skills/why/references/investigator-prompt.md +0 -0
- /package/{assets → dist/pstack}/skills/why/references/source-playbook.md +0 -0
- /package/{assets → dist/pstack}/skills/why/references/sources/code-archaeology.md +0 -0
- /package/{assets → dist/pstack}/skills/why/references/sources/databricks.md +0 -0
- /package/{assets → dist/pstack}/skills/why/references/sources/datadog.md +0 -0
- /package/{assets → dist/pstack}/skills/why/references/sources/incident-postmortem.md +0 -0
- /package/{assets → dist/pstack}/skills/why/references/sources/linear.md +0 -0
- /package/{assets → dist/pstack}/skills/why/references/sources/notion.md +0 -0
- /package/{assets → dist/pstack}/skills/why/references/sources/sentry.md +0 -0
- /package/{assets → dist/pstack}/skills/why/references/sources/slack.md +0 -0
- /package/{assets → dist/pstack}/skills/why/references/synthesizer-prompt.md +0 -0
package/dist/script.mjs
ADDED
|
@@ -0,0 +1,485 @@
|
|
|
1
|
+
import { i as PORT_ROOT } from "./paths-BT77khwm.mjs";
|
|
2
|
+
import { isAbsolute, join, resolve } from "node:path";
|
|
3
|
+
import { spawn } from "node:child_process";
|
|
4
|
+
// src/internal/script-registry.ts
|
|
5
|
+
const SCRIPT_ENTRIES = [
|
|
6
|
+
{
|
|
7
|
+
id: "check-plan",
|
|
8
|
+
assetPath: "skills/poteto-mode/scripts/check-plan.mjs"
|
|
9
|
+
},
|
|
10
|
+
{
|
|
11
|
+
id: "watch-pr",
|
|
12
|
+
assetPath: "skills/poteto-mode/scripts/watch-pr/watch-pr.mjs"
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
id: "worktree-audit",
|
|
16
|
+
assetPath: "skills/poteto-mode/scripts/worktree-audit.mjs"
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
id: "log",
|
|
20
|
+
assetPath: "skills/show-me-your-work/scripts/log.mjs"
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
id: "statechart",
|
|
24
|
+
assetPath: "skills/statechart/scripts/statechart.mjs"
|
|
25
|
+
}
|
|
26
|
+
];
|
|
27
|
+
// src/script.ts
|
|
28
|
+
/**
|
|
29
|
+
* `pstack_script`: run a bundled pstack script through the Host's own runtime.
|
|
30
|
+
*
|
|
31
|
+
* The `id` is a closed enum over the shipped artefacts and resolves from this package,
|
|
32
|
+
* so a call cannot reach a script the package does not contain. It is not a shell: no
|
|
33
|
+
* `sh -c`, no glob expansion, no way to name another executable.
|
|
34
|
+
*
|
|
35
|
+
* The child is spawned with `process.execPath` — whichever binary runs this Host, Node or
|
|
36
|
+
* Electron — and `ELECTRON_RUN_AS_NODE=1` only under Electron. That makes the npm CLI and
|
|
37
|
+
* the Desktop build behave the same without `node` on `PATH`.
|
|
38
|
+
*/
|
|
39
|
+
/** Model-facing tool name. */
|
|
40
|
+
const TOOL_NAME = "pstack_script";
|
|
41
|
+
/** The shipped scripts this tool may run, in display order. */
|
|
42
|
+
const SCRIPT_IDS = SCRIPT_ENTRIES.map((entry) => entry.id);
|
|
43
|
+
const DEFAULT_TIMEOUT_MS = 12e4;
|
|
44
|
+
const MAX_TIMEOUT_MS = 6e5;
|
|
45
|
+
const DEFAULT_OUTPUT_LIMIT_BYTES = 65536;
|
|
46
|
+
/** Raised for an argument problem, before anything is spawned. */
|
|
47
|
+
var ScriptInputError = class extends Error {
|
|
48
|
+
constructor(message) {
|
|
49
|
+
super(message);
|
|
50
|
+
this.name = "ScriptInputError";
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
/** Raised when a shipped artefact is missing from this install. */
|
|
54
|
+
var ScriptMissingError = class extends Error {
|
|
55
|
+
constructor(message) {
|
|
56
|
+
super(message);
|
|
57
|
+
this.name = "ScriptMissingError";
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
/** Absolute path of one shipped artefact. */
|
|
61
|
+
function scriptPath(id) {
|
|
62
|
+
const entry = SCRIPT_ENTRIES.find((candidate) => candidate.id === id);
|
|
63
|
+
if (entry === void 0) throw new ScriptInputError(`unknown script id "${String(id)}"`);
|
|
64
|
+
return join(PORT_ROOT, ...entry.assetPath.split("/"));
|
|
65
|
+
}
|
|
66
|
+
/** The environment a child gets: the Electron selector, and otherwise the caller's. */
|
|
67
|
+
function scriptEnvironment(base = process.env, versions = process.versions) {
|
|
68
|
+
if (versions.electron === void 0) return { ...base };
|
|
69
|
+
return {
|
|
70
|
+
...base,
|
|
71
|
+
ELECTRON_RUN_AS_NODE: "1"
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
/** Validate the raw tool arguments. */
|
|
75
|
+
function parseScriptArgs(raw) {
|
|
76
|
+
if (raw === null || typeof raw !== "object" || Array.isArray(raw)) throw new ScriptInputError("arguments must be an object");
|
|
77
|
+
const record = raw;
|
|
78
|
+
for (const key of Object.keys(record)) if (![
|
|
79
|
+
"id",
|
|
80
|
+
"args",
|
|
81
|
+
"cwd",
|
|
82
|
+
"background",
|
|
83
|
+
"timeoutMs",
|
|
84
|
+
"outputLimitBytes"
|
|
85
|
+
].includes(key)) throw new ScriptInputError(`unknown argument "${key}"`);
|
|
86
|
+
const id = record["id"];
|
|
87
|
+
if (typeof id !== "string") throw new ScriptInputError("\"id\" must be a string");
|
|
88
|
+
if (!SCRIPT_IDS.includes(id)) throw new ScriptInputError(`"id" must be one of ${SCRIPT_IDS.join(", ")}; this tool runs bundled scripts only`);
|
|
89
|
+
const rawArgs = record["args"];
|
|
90
|
+
if (rawArgs !== void 0 && !Array.isArray(rawArgs)) throw new ScriptInputError("\"args\" must be an array of strings");
|
|
91
|
+
const args = [];
|
|
92
|
+
for (const value of rawArgs ?? []) {
|
|
93
|
+
if (typeof value !== "string") throw new ScriptInputError("\"args\" must contain only strings");
|
|
94
|
+
args.push(value);
|
|
95
|
+
}
|
|
96
|
+
const cwd = record["cwd"];
|
|
97
|
+
if (cwd !== void 0 && (typeof cwd !== "string" || cwd.trim() === "")) throw new ScriptInputError("\"cwd\" must be a non-empty string when present");
|
|
98
|
+
const background = record["background"] ?? false;
|
|
99
|
+
if (typeof background !== "boolean") throw new ScriptInputError("\"background\" must be a boolean");
|
|
100
|
+
const timeoutMs = record["timeoutMs"];
|
|
101
|
+
if (timeoutMs !== void 0) {
|
|
102
|
+
if (typeof timeoutMs !== "number" || !Number.isInteger(timeoutMs) || timeoutMs <= 0) throw new ScriptInputError("\"timeoutMs\" must be a positive integer");
|
|
103
|
+
if (timeoutMs > 6e5) throw new ScriptInputError(`"timeoutMs" must be at most ${MAX_TIMEOUT_MS}`);
|
|
104
|
+
}
|
|
105
|
+
const outputLimitBytes = record["outputLimitBytes"];
|
|
106
|
+
if (outputLimitBytes !== void 0) {
|
|
107
|
+
if (typeof outputLimitBytes !== "number" || !Number.isInteger(outputLimitBytes) || outputLimitBytes <= 0) throw new ScriptInputError("\"outputLimitBytes\" must be a positive integer");
|
|
108
|
+
}
|
|
109
|
+
return {
|
|
110
|
+
id,
|
|
111
|
+
args,
|
|
112
|
+
...cwd === void 0 ? {} : { cwd },
|
|
113
|
+
background,
|
|
114
|
+
...timeoutMs === void 0 ? {} : { timeoutMs },
|
|
115
|
+
...outputLimitBytes === void 0 ? {} : { outputLimitBytes }
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
/** Resolve the directory the child runs in, relative to the caller-established session directory. */
|
|
119
|
+
function resolveWorkingDirectory(requested, sessionCwd) {
|
|
120
|
+
if (requested === void 0) return sessionCwd;
|
|
121
|
+
if (isAbsolute(requested)) return resolve(requested);
|
|
122
|
+
return sessionCwd === void 0 ? resolve(requested) : resolve(join(sessionCwd, requested));
|
|
123
|
+
}
|
|
124
|
+
/** Run one script in the foreground. A nonzero exit, signal, timeout, and truncation are returned, not thrown. */
|
|
125
|
+
async function runForeground(args, options = {}) {
|
|
126
|
+
const path = scriptPath(args.id);
|
|
127
|
+
const started = Date.now();
|
|
128
|
+
const timeoutMs = args.timeoutMs ?? 12e4;
|
|
129
|
+
const limit = args.outputLimitBytes ?? 65536;
|
|
130
|
+
return await new Promise((resolve, reject) => {
|
|
131
|
+
const child = spawn(options.execPath ?? process.execPath, [path, ...args.args], {
|
|
132
|
+
cwd: args.cwd ?? options.cwd,
|
|
133
|
+
env: options.environment ?? scriptEnvironment(),
|
|
134
|
+
stdio: [
|
|
135
|
+
"ignore",
|
|
136
|
+
"pipe",
|
|
137
|
+
"pipe"
|
|
138
|
+
],
|
|
139
|
+
windowsHide: true,
|
|
140
|
+
signal: options.signal
|
|
141
|
+
});
|
|
142
|
+
let stdout = "";
|
|
143
|
+
let stderr = "";
|
|
144
|
+
let stdoutTruncated = false;
|
|
145
|
+
let stderrTruncated = false;
|
|
146
|
+
let timedOut = false;
|
|
147
|
+
const collect = (chunk, to) => {
|
|
148
|
+
const text = chunk.toString("utf8");
|
|
149
|
+
if (to === "out") {
|
|
150
|
+
if (stdout.length >= limit) {
|
|
151
|
+
stdoutTruncated = true;
|
|
152
|
+
return;
|
|
153
|
+
}
|
|
154
|
+
stdout += text.slice(0, limit - stdout.length);
|
|
155
|
+
if (stdout.length >= limit) stdoutTruncated = true;
|
|
156
|
+
return;
|
|
157
|
+
}
|
|
158
|
+
if (stderr.length >= limit) {
|
|
159
|
+
stderrTruncated = true;
|
|
160
|
+
return;
|
|
161
|
+
}
|
|
162
|
+
stderr += text.slice(0, limit - stderr.length);
|
|
163
|
+
if (stderr.length >= limit) stderrTruncated = true;
|
|
164
|
+
};
|
|
165
|
+
child.stdout?.on("data", (chunk) => collect(chunk, "out"));
|
|
166
|
+
child.stderr?.on("data", (chunk) => collect(chunk, "err"));
|
|
167
|
+
const timer = setTimeout(() => {
|
|
168
|
+
timedOut = true;
|
|
169
|
+
child.kill("SIGKILL");
|
|
170
|
+
}, timeoutMs);
|
|
171
|
+
child.once("error", (error) => {
|
|
172
|
+
clearTimeout(timer);
|
|
173
|
+
reject(error);
|
|
174
|
+
});
|
|
175
|
+
child.once("close", (code, signal) => {
|
|
176
|
+
clearTimeout(timer);
|
|
177
|
+
resolve({
|
|
178
|
+
kind: "foreground",
|
|
179
|
+
id: args.id,
|
|
180
|
+
exitCode: code ?? 1,
|
|
181
|
+
signal,
|
|
182
|
+
timedOut,
|
|
183
|
+
stdout,
|
|
184
|
+
stderr,
|
|
185
|
+
stdoutTruncated,
|
|
186
|
+
stderrTruncated,
|
|
187
|
+
durationMs: Date.now() - started
|
|
188
|
+
});
|
|
189
|
+
});
|
|
190
|
+
});
|
|
191
|
+
}
|
|
192
|
+
/** Start a script as a background job. `jobs` absent is a refusal with a reason. */
|
|
193
|
+
async function runBackground(args, options) {
|
|
194
|
+
const jobs = options.jobs;
|
|
195
|
+
if (jobs === void 0) throw new ScriptInputError("background: true needs the Host jobs service, and this composition has none. Run the call in the foreground (omit background), or ask the operator to mount a job controller.");
|
|
196
|
+
const path = scriptPath(args.id);
|
|
197
|
+
const execPath = options.execPath ?? process.execPath;
|
|
198
|
+
const environment = options.environment ?? scriptEnvironment();
|
|
199
|
+
const cwd = options.cwd;
|
|
200
|
+
let reportStarted;
|
|
201
|
+
const state = {
|
|
202
|
+
settled: false,
|
|
203
|
+
ran: false
|
|
204
|
+
};
|
|
205
|
+
const started = new Promise((settle) => {
|
|
206
|
+
reportStarted = (failure) => {
|
|
207
|
+
if (state.settled) return;
|
|
208
|
+
state.settled = true;
|
|
209
|
+
settle(failure);
|
|
210
|
+
};
|
|
211
|
+
});
|
|
212
|
+
const jobId = jobs.start({
|
|
213
|
+
kind: "bash",
|
|
214
|
+
label: `pstack_script ${args.id}`,
|
|
215
|
+
...options.caller === void 0 ? {} : { owner: options.caller },
|
|
216
|
+
outputLimitBytes: args.outputLimitBytes ?? 65536,
|
|
217
|
+
run: (job) => {
|
|
218
|
+
state.ran = true;
|
|
219
|
+
const settleStarted = reportStarted;
|
|
220
|
+
let child;
|
|
221
|
+
try {
|
|
222
|
+
child = spawn(execPath, [path, ...args.args], {
|
|
223
|
+
cwd,
|
|
224
|
+
env: environment,
|
|
225
|
+
stdio: [
|
|
226
|
+
"ignore",
|
|
227
|
+
"pipe",
|
|
228
|
+
"pipe"
|
|
229
|
+
],
|
|
230
|
+
windowsHide: true
|
|
231
|
+
});
|
|
232
|
+
} catch (error) {
|
|
233
|
+
settleStarted(error.code ?? "spawn-threw");
|
|
234
|
+
throw error;
|
|
235
|
+
}
|
|
236
|
+
child.stdout?.on("data", (chunk) => job.append(chunk.toString("utf8"), { channel: "stdout" }));
|
|
237
|
+
child.stderr?.on("data", (chunk) => job.append(chunk.toString("utf8"), { channel: "stderr" }));
|
|
238
|
+
child.once("spawn", () => settleStarted(null));
|
|
239
|
+
child.once("error", (error) => settleStarted(error.code ?? "spawn-failed"));
|
|
240
|
+
return {
|
|
241
|
+
cancel: (reason) => {
|
|
242
|
+
child.kill("SIGTERM");
|
|
243
|
+
if (reason !== void 0) job.updateProgress(`cancelling: ${reason}`);
|
|
244
|
+
},
|
|
245
|
+
done: new Promise((settle) => {
|
|
246
|
+
child.once("error", (error) => settle({
|
|
247
|
+
status: "failed",
|
|
248
|
+
detail: error.code ?? "spawn-failed"
|
|
249
|
+
}));
|
|
250
|
+
child.once("close", (code, signal) => {
|
|
251
|
+
if (signal !== null) settle({
|
|
252
|
+
status: "killed",
|
|
253
|
+
detail: `signal ${signal}`
|
|
254
|
+
});
|
|
255
|
+
else if (code === 0) settle({ status: "completed" });
|
|
256
|
+
else settle({
|
|
257
|
+
status: "failed",
|
|
258
|
+
detail: `exit code ${code ?? "unknown"}`
|
|
259
|
+
});
|
|
260
|
+
});
|
|
261
|
+
})
|
|
262
|
+
};
|
|
263
|
+
}
|
|
264
|
+
});
|
|
265
|
+
const failStart = (reason) => {
|
|
266
|
+
throw new ScriptMissingError(`background job ${jobId} failed to start (${reason}). Run the same script in the foreground to see its error.`);
|
|
267
|
+
};
|
|
268
|
+
if (!state.ran) {
|
|
269
|
+
const view = jobs.get(jobId, options.caller);
|
|
270
|
+
if (view.status === "failed") failStart("the job controller reported a failed start");
|
|
271
|
+
return {
|
|
272
|
+
kind: "background",
|
|
273
|
+
id: args.id,
|
|
274
|
+
jobId,
|
|
275
|
+
status: view.status
|
|
276
|
+
};
|
|
277
|
+
}
|
|
278
|
+
const startFailure = await started;
|
|
279
|
+
if (startFailure !== null) failStart(startFailure);
|
|
280
|
+
const view = jobs.get(jobId, options.caller);
|
|
281
|
+
if (view.status === "failed") failStart("the job controller reported a failed start");
|
|
282
|
+
return {
|
|
283
|
+
kind: "background",
|
|
284
|
+
id: args.id,
|
|
285
|
+
jobId,
|
|
286
|
+
status: view.status
|
|
287
|
+
};
|
|
288
|
+
}
|
|
289
|
+
/** Render one captured stream as a fence that the content cannot close early. */
|
|
290
|
+
function renderCapturedStream(text) {
|
|
291
|
+
if (text === "") return [];
|
|
292
|
+
const longestRun = Math.max(0, ...(text.match(/`+/g) ?? []).map((run) => run.length));
|
|
293
|
+
const fence = "`".repeat(Math.max(3, longestRun + 1));
|
|
294
|
+
return [
|
|
295
|
+
fence,
|
|
296
|
+
text.endsWith("\n") ? text.slice(0, -1) : text,
|
|
297
|
+
fence
|
|
298
|
+
];
|
|
299
|
+
}
|
|
300
|
+
/** Render one outcome for the model. */
|
|
301
|
+
function renderScriptOutcome(outcome) {
|
|
302
|
+
if (outcome.kind === "background") return [`started ${outcome.id} as background job ${outcome.jobId} (status: ${outcome.status}).`, "Read or stop it through the Host's job tools; this tool does not poll."].join("\n");
|
|
303
|
+
const lines = [`${outcome.id} exited with code ${outcome.exitCode}${outcome.signal === null ? "" : ` (signal ${outcome.signal})`}${outcome.timedOut ? ` after the timeout` : ""} in ${outcome.durationMs}ms`];
|
|
304
|
+
if (outcome.stdout !== "") lines.push("", "stdout (exact bytes):", ...renderCapturedStream(outcome.stdout));
|
|
305
|
+
if (outcome.stderr !== "") lines.push("", "stderr (exact bytes):", ...renderCapturedStream(outcome.stderr));
|
|
306
|
+
if (outcome.stdoutTruncated) lines.push("", "stdout was truncated at the output limit.");
|
|
307
|
+
if (outcome.stderrTruncated) lines.push("", "stderr was truncated at the output limit.");
|
|
308
|
+
if (outcome.exitCode !== 0 || outcome.signal !== null || outcome.timedOut) lines.push("", "This run failed. Read the output above; do not report success.");
|
|
309
|
+
return lines.join("\n");
|
|
310
|
+
}
|
|
311
|
+
const TOOL_DESCRIPTION = [
|
|
312
|
+
"Run one of the scripts bundled with pstack, using the Host's own Node runtime.",
|
|
313
|
+
"",
|
|
314
|
+
"Use this instead of a shell for the pstack scripts. It works in both deployments: the npm CLI and",
|
|
315
|
+
"the Desktop app, where `node` is not on PATH because the Desktop process is Electron.",
|
|
316
|
+
"",
|
|
317
|
+
"`id` selects a bundled script by name; only those names are accepted, so this is not a general",
|
|
318
|
+
"shell and takes no path or command string. `args` are passed to the script verbatim.",
|
|
319
|
+
"",
|
|
320
|
+
"The run starts in this session's directory, so a relative path in `args` lands inside the",
|
|
321
|
+
"workspace or worktree the session is using.",
|
|
322
|
+
"",
|
|
323
|
+
"**This tool does not go through command approval, and the Host's sandbox policy does not apply**",
|
|
324
|
+
"to it. It spawns a Node process directly instead of asking `ctx.shell` to run a command, which is",
|
|
325
|
+
"what keeps it working where no `node` is on PATH. The scripts are this package's own audited",
|
|
326
|
+
"artefacts and `id` cannot name anything else, but the consequence is real: unlike a bash call, no",
|
|
327
|
+
"approval prompt is shown and no filesystem policy is enforced on what the script writes. Say so",
|
|
328
|
+
"when a task depends on that difference.",
|
|
329
|
+
"",
|
|
330
|
+
"A nonzero exit, a signal, a timeout, and truncated output all come back in the result with the",
|
|
331
|
+
"captured output, so a failed run is visible rather than silent.",
|
|
332
|
+
"",
|
|
333
|
+
"Set `background: true` for a long run. That needs the Host jobs service; without it the call is",
|
|
334
|
+
"refused with a reason instead of hanging. Background runs return a job id and a settlement notice",
|
|
335
|
+
"arrives later — do not poll."
|
|
336
|
+
].join("\n");
|
|
337
|
+
function buildScriptParameters() {
|
|
338
|
+
return {
|
|
339
|
+
type: "object",
|
|
340
|
+
additionalProperties: false,
|
|
341
|
+
properties: {
|
|
342
|
+
id: {
|
|
343
|
+
type: "string",
|
|
344
|
+
enum: [...SCRIPT_IDS],
|
|
345
|
+
description: "Which bundled pstack script to run. Not a path: only these names are accepted."
|
|
346
|
+
},
|
|
347
|
+
args: {
|
|
348
|
+
type: "array",
|
|
349
|
+
items: { type: "string" },
|
|
350
|
+
description: "Arguments passed to the script verbatim, one array entry per argument."
|
|
351
|
+
},
|
|
352
|
+
cwd: {
|
|
353
|
+
type: "string",
|
|
354
|
+
description: "Working directory for the script. Relative paths resolve against this session's directory; an absolute path is used as-is. Omitted runs in this session's directory."
|
|
355
|
+
},
|
|
356
|
+
background: {
|
|
357
|
+
type: "boolean",
|
|
358
|
+
description: "Run as a Host background job and return its id. Requires the jobs service; a composition without it refuses the call."
|
|
359
|
+
},
|
|
360
|
+
timeoutMs: {
|
|
361
|
+
type: "integer",
|
|
362
|
+
description: `Foreground wall-clock limit; 1 or greater, and values below 1 are rejected. Defaults to ${DEFAULT_TIMEOUT_MS}; values above ${MAX_TIMEOUT_MS} are rejected.`
|
|
363
|
+
},
|
|
364
|
+
outputLimitBytes: {
|
|
365
|
+
type: "integer",
|
|
366
|
+
description: `Per-stream capture limit; 1 or greater, and values below 1 are rejected. Defaults to ${DEFAULT_OUTPUT_LIMIT_BYTES}.`
|
|
367
|
+
}
|
|
368
|
+
},
|
|
369
|
+
required: ["id"]
|
|
370
|
+
};
|
|
371
|
+
}
|
|
372
|
+
const OUTPUT_SCHEMA = { oneOf: [{
|
|
373
|
+
type: "object",
|
|
374
|
+
additionalProperties: false,
|
|
375
|
+
properties: {
|
|
376
|
+
kind: {
|
|
377
|
+
type: "string",
|
|
378
|
+
const: "foreground"
|
|
379
|
+
},
|
|
380
|
+
id: {
|
|
381
|
+
type: "string",
|
|
382
|
+
description: "Which bundled script ran."
|
|
383
|
+
},
|
|
384
|
+
exitCode: {
|
|
385
|
+
type: "integer",
|
|
386
|
+
description: "The child's exit code."
|
|
387
|
+
},
|
|
388
|
+
signal: {
|
|
389
|
+
oneOf: [{ type: "string" }, { type: "null" }],
|
|
390
|
+
description: "Terminating signal, or null when the script exited on its own."
|
|
391
|
+
},
|
|
392
|
+
timedOut: {
|
|
393
|
+
type: "boolean",
|
|
394
|
+
description: "True when this tool's own timeout killed the run."
|
|
395
|
+
},
|
|
396
|
+
stdout: { type: "string" },
|
|
397
|
+
stderr: { type: "string" },
|
|
398
|
+
stdoutTruncated: { type: "boolean" },
|
|
399
|
+
stderrTruncated: { type: "boolean" },
|
|
400
|
+
durationMs: { type: "integer" }
|
|
401
|
+
},
|
|
402
|
+
required: [
|
|
403
|
+
"kind",
|
|
404
|
+
"id",
|
|
405
|
+
"exitCode",
|
|
406
|
+
"signal",
|
|
407
|
+
"timedOut",
|
|
408
|
+
"stdout",
|
|
409
|
+
"stderr",
|
|
410
|
+
"stdoutTruncated",
|
|
411
|
+
"stderrTruncated",
|
|
412
|
+
"durationMs"
|
|
413
|
+
]
|
|
414
|
+
}, {
|
|
415
|
+
type: "object",
|
|
416
|
+
additionalProperties: false,
|
|
417
|
+
properties: {
|
|
418
|
+
kind: {
|
|
419
|
+
type: "string",
|
|
420
|
+
const: "background"
|
|
421
|
+
},
|
|
422
|
+
id: {
|
|
423
|
+
type: "string",
|
|
424
|
+
description: "Which bundled script started."
|
|
425
|
+
},
|
|
426
|
+
jobId: {
|
|
427
|
+
type: "string",
|
|
428
|
+
description: "The Host job id to read or stop."
|
|
429
|
+
},
|
|
430
|
+
status: {
|
|
431
|
+
type: "string",
|
|
432
|
+
description: "Job status when the call returned."
|
|
433
|
+
}
|
|
434
|
+
},
|
|
435
|
+
required: [
|
|
436
|
+
"kind",
|
|
437
|
+
"id",
|
|
438
|
+
"jobId",
|
|
439
|
+
"status"
|
|
440
|
+
]
|
|
441
|
+
}] };
|
|
442
|
+
/** Build the tool for one row. */
|
|
443
|
+
function createPstackScriptTool(host) {
|
|
444
|
+
return {
|
|
445
|
+
name: TOOL_NAME,
|
|
446
|
+
description: TOOL_DESCRIPTION,
|
|
447
|
+
parameters: buildScriptParameters(),
|
|
448
|
+
output: {
|
|
449
|
+
schema: OUTPUT_SCHEMA,
|
|
450
|
+
render: (_args, value) => [{
|
|
451
|
+
type: "text",
|
|
452
|
+
text: renderScriptOutcome(value)
|
|
453
|
+
}]
|
|
454
|
+
},
|
|
455
|
+
isConcurrencySafe: () => false,
|
|
456
|
+
timeoutMs: MAX_TIMEOUT_MS,
|
|
457
|
+
async execute(rawArgs, exec) {
|
|
458
|
+
const args = parseScriptArgs(rawArgs);
|
|
459
|
+
const sessionCwd = exec.agent === void 0 ? void 0 : await host.workingDirectory.ensure(exec.agent, exec.signal);
|
|
460
|
+
const cwd = resolveWorkingDirectory(args.cwd, sessionCwd);
|
|
461
|
+
if (args.background) return await runBackground(args, {
|
|
462
|
+
jobs: host.getJobs?.(),
|
|
463
|
+
...cwd === void 0 ? {} : { cwd },
|
|
464
|
+
...exec.agent === void 0 ? {} : { caller: exec.agent.id }
|
|
465
|
+
});
|
|
466
|
+
return await runForeground(args, {
|
|
467
|
+
signal: exec.signal,
|
|
468
|
+
...cwd === void 0 ? {} : { cwd }
|
|
469
|
+
});
|
|
470
|
+
}
|
|
471
|
+
};
|
|
472
|
+
}
|
|
473
|
+
/** Cordis row name, used by Loader diagnostics. */
|
|
474
|
+
const name = "pstack-script";
|
|
475
|
+
/** Hard dependencies: the tool registry and the session directory. `jobs` is optional and read per call. */
|
|
476
|
+
const inject = ["tools", "workingDirectory"];
|
|
477
|
+
/** Register `pstack_script` for this row. */
|
|
478
|
+
function apply(ctx) {
|
|
479
|
+
ctx.tools.register(createPstackScriptTool({
|
|
480
|
+
tools: ctx.tools,
|
|
481
|
+
workingDirectory: ctx.workingDirectory,
|
|
482
|
+
getJobs: () => ctx.get?.("jobs")
|
|
483
|
+
}));
|
|
484
|
+
}
|
|
485
|
+
export { DEFAULT_OUTPUT_LIMIT_BYTES, DEFAULT_TIMEOUT_MS, MAX_TIMEOUT_MS, OUTPUT_SCHEMA, SCRIPT_IDS, ScriptInputError, ScriptMissingError, TOOL_NAME, apply, buildScriptParameters, createPstackScriptTool, inject, name, parseScriptArgs, renderCapturedStream, renderScriptOutcome, resolveWorkingDirectory, runBackground, runForeground, scriptEnvironment, scriptPath };
|
package/dist/skill.d.mts
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { _ as ToolsHost, g as ToolDefinition, l as SkillDefinition, p as SkillResourceBase, t as Agent } from "./host-contract-CUPSpeNk.mjs";
|
|
2
|
+
/** Model-facing tool name. */
|
|
3
|
+
export declare const TOOL_NAME = "pstack_skill";
|
|
4
|
+
/** Cordis row name, used by Loader diagnostics. */
|
|
5
|
+
export declare const name = "pstack-skill";
|
|
6
|
+
/** The tool registry and the skill registry. */
|
|
7
|
+
export declare const inject: string[];
|
|
8
|
+
/** The slice of `ctx.skills` this tool reads. */
|
|
9
|
+
export interface SkillsHost {
|
|
10
|
+
get(name: string, options?: {
|
|
11
|
+
readonly cwd?: string;
|
|
12
|
+
readonly signal?: AbortSignal;
|
|
13
|
+
readonly scope?: Agent;
|
|
14
|
+
}): Promise<SkillDefinition | undefined>;
|
|
15
|
+
}
|
|
16
|
+
export interface PstackSkillHost {
|
|
17
|
+
readonly skills: SkillsHost;
|
|
18
|
+
readonly tools: ToolsHost;
|
|
19
|
+
}
|
|
20
|
+
export interface SkillResourceResult {
|
|
21
|
+
readonly path: string;
|
|
22
|
+
readonly content: string;
|
|
23
|
+
}
|
|
24
|
+
export interface LoadSkillResult {
|
|
25
|
+
readonly name: string;
|
|
26
|
+
readonly provider: string;
|
|
27
|
+
readonly resourceBase?: SkillResourceBase;
|
|
28
|
+
readonly content: string;
|
|
29
|
+
readonly resource?: SkillResourceResult;
|
|
30
|
+
}
|
|
31
|
+
/** Render one loaded skill in the canonical `<skill_content>` shape. */
|
|
32
|
+
export declare function renderLoadedSkill(result: LoadSkillResult): string;
|
|
33
|
+
/** Read one resource below a directory skill, refusing traversal and absolute paths. */
|
|
34
|
+
export declare function readSkillResource(definition: SkillDefinition, resource: string): Promise<SkillResourceResult>;
|
|
35
|
+
/** Build the tool definition. Exported so tests can drive `execute` directly. */
|
|
36
|
+
export declare function createPstackSkillTool(skills: SkillsHost): ToolDefinition;
|
|
37
|
+
/** Register `pstack_skill` on one row. */
|
|
38
|
+
export declare function apply(ctx: PstackSkillHost): void;
|