dsh-pstack 0.2.0-beta.1 → 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 +135 -84
- package/README.zh.md +185 -0
- package/cordis.patch.yml +97 -27
- package/dist/host-contract-CUPSpeNk.d.mts +22 -0
- package/dist/index.d.mts +49 -238
- package/dist/index.mjs +250 -123
- package/dist/models.d.mts +44 -0
- package/dist/models.mjs +201 -0
- package/dist/paths-BT77khwm.mjs +48 -0
- package/dist/pstack/LICENSE +21 -0
- package/dist/pstack/README.md +291 -0
- package/dist/pstack/agents/poteto-agent.md +9 -0
- package/{assets → dist/pstack}/docs/guide/01-setup.md +13 -11
- package/{assets → dist/pstack}/docs/guide/02-poteto-mode.md +4 -4
- package/{assets → dist/pstack}/docs/guide/04-design.md +4 -4
- package/{assets → dist/pstack}/docs/guide/05-build-and-clean.md +2 -2
- package/{assets → dist/pstack}/docs/guide/06-verify-and-ship.md +13 -3
- package/{assets → dist/pstack}/docs/guide/07-overnight.md +15 -13
- package/{assets → dist/pstack}/docs/guide/09-make-it-yours.md +6 -2
- package/{assets → dist/pstack}/docs/guide/10-recipes-and-pitfalls.md +7 -5
- package/{assets → dist/pstack}/docs/guide/README.md +1 -1
- package/dist/pstack/docs/harness/dsh.md +98 -0
- package/{assets → dist/pstack}/skills/architect/SKILL.md +12 -12
- package/dist/pstack/skills/arena/SKILL.md +50 -0
- package/{assets → dist/pstack}/skills/automate-me/SKILL.md +14 -14
- package/{assets → dist/pstack}/skills/benchmark-checklist/SKILL.md +1 -1
- package/{assets → dist/pstack}/skills/blast-radius/SKILL.md +4 -6
- package/{assets → dist/pstack}/skills/correct/SKILL.md +1 -1
- package/{assets → dist/pstack}/skills/create-formal-verification-skill/SKILL.md +4 -2
- package/{assets → dist/pstack}/skills/create-verification-skill/SKILL.md +5 -5
- package/dist/pstack/skills/figure-it-out/SKILL.md +54 -0
- package/dist/pstack/skills/how/SKILL.md +38 -0
- package/{assets → dist/pstack}/skills/in-your-own-words/SKILL.md +1 -1
- package/dist/pstack/skills/interrogate/SKILL.md +33 -0
- package/{assets → dist/pstack}/skills/ketchup/SKILL.md +3 -5
- package/dist/pstack/skills/ketchup-video/SKILL.md +29 -0
- package/{assets → dist/pstack}/skills/maintain-formal-verification-skill/SKILL.md +1 -1
- package/{assets → dist/pstack}/skills/maintain-verification-skill/SKILL.md +3 -3
- package/dist/pstack/skills/make-bot-ui/SKILL.md +117 -0
- package/dist/pstack/skills/no-comments/SKILL.md +26 -0
- package/{assets → dist/pstack}/skills/poteto-help/SKILL.md +34 -31
- package/{assets → dist/pstack}/skills/poteto-help/references/prompting.md +1 -1
- package/{assets → dist/pstack}/skills/poteto-help/references/recipes.md +3 -3
- package/{assets → dist/pstack}/skills/poteto-mode/SKILL.md +20 -19
- package/dist/pstack/skills/poteto-mode/playbooks/authoring-a-skill.md +12 -0
- package/dist/pstack/skills/poteto-mode/playbooks/autonomous-run.md +13 -0
- package/dist/pstack/skills/poteto-mode/playbooks/autopilot-full.md +25 -0
- package/dist/pstack/skills/poteto-mode/playbooks/autopilot-stack.md +8 -0
- package/{assets → dist/pstack}/skills/poteto-mode/playbooks/babysit.md +4 -4
- package/dist/pstack/skills/poteto-mode/playbooks/bug-fix.md +15 -0
- package/{assets → dist/pstack}/skills/poteto-mode/playbooks/eval.md +3 -3
- package/dist/pstack/skills/poteto-mode/playbooks/feature.md +21 -0
- package/{assets → dist/pstack}/skills/poteto-mode/playbooks/hillclimb.md +3 -3
- package/{assets → dist/pstack}/skills/poteto-mode/playbooks/investigation.md +2 -2
- package/{assets → dist/pstack}/skills/poteto-mode/playbooks/multi-phase-plan.md +23 -23
- package/{assets → dist/pstack}/skills/poteto-mode/playbooks/opening-a-pr.md +6 -6
- package/dist/pstack/skills/poteto-mode/playbooks/orchestrate.md +25 -0
- package/{assets → dist/pstack}/skills/poteto-mode/playbooks/pause-safely.md +2 -2
- package/dist/pstack/skills/poteto-mode/playbooks/perf-issue.md +25 -0
- package/{assets → dist/pstack}/skills/poteto-mode/playbooks/prototype.md +4 -4
- package/dist/pstack/skills/poteto-mode/playbooks/refactoring.md +16 -0
- package/dist/pstack/skills/poteto-mode/playbooks/runtime-forensics.md +11 -0
- package/dist/pstack/skills/poteto-mode/playbooks/session-pickup.md +11 -0
- package/{assets → dist/pstack}/skills/poteto-mode/playbooks/shipping.md +2 -2
- package/{assets → dist/pstack}/skills/poteto-mode/playbooks/trace-forensics.md +2 -2
- package/dist/pstack/skills/poteto-mode/playbooks/visual-parity.md +11 -0
- package/dist/pstack/skills/poteto-mode/playbooks/worktree-cleanup.md +12 -0
- package/{assets → dist/pstack}/skills/poteto-mode/scripts/check-plan.mjs +6 -8
- package/dist/pstack/skills/poteto-mode/scripts/check-plan.test.mjs +128 -0
- package/{assets/skills/poteto-mode/scripts/check-plan.test.mjs → dist/pstack/skills/poteto-mode/scripts/expect.mjs} +12 -101
- 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/{assets → dist/pstack}/skills/poteto-mode/scripts/worktree-audit.mjs +15 -22
- 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 -1
- package/{assets → dist/pstack}/skills/principle-boundary-discipline/SKILL.md +1 -1
- package/{assets → dist/pstack}/skills/principle-encode-lessons-in-structure/SKILL.md +1 -1
- package/{assets → dist/pstack}/skills/principle-exhaust-the-design-space/SKILL.md +1 -1
- package/{assets → dist/pstack}/skills/principle-experience-first/SKILL.md +1 -1
- package/{assets → dist/pstack}/skills/principle-explain-the-number/SKILL.md +3 -2
- package/{assets → dist/pstack}/skills/principle-fix-root-causes/SKILL.md +1 -1
- package/{assets → dist/pstack}/skills/principle-laziness-protocol/SKILL.md +1 -1
- package/{assets → dist/pstack}/skills/principle-make-operations-idempotent/SKILL.md +1 -1
- package/{assets → dist/pstack}/skills/principle-migrate-callers-then-delete-legacy-apis/SKILL.md +1 -1
- package/{assets → dist/pstack}/skills/principle-minimize-reader-load/SKILL.md +1 -1
- package/{assets → dist/pstack}/skills/principle-model-the-domain/SKILL.md +1 -1
- package/{assets → dist/pstack}/skills/principle-never-block-on-the-human/SKILL.md +1 -1
- package/{assets → dist/pstack}/skills/principle-outcome-oriented-execution/SKILL.md +1 -1
- package/{assets → dist/pstack}/skills/principle-prove-it-works/SKILL.md +2 -2
- package/{assets → dist/pstack}/skills/principle-redesign-from-first-principles/SKILL.md +1 -1
- package/{assets → dist/pstack}/skills/principle-separate-before-serializing-shared-state/SKILL.md +1 -1
- package/{assets → dist/pstack}/skills/principle-sequence-verifiable-units/SKILL.md +1 -1
- package/{assets → dist/pstack}/skills/principle-subtract-before-you-add/SKILL.md +1 -1
- package/{assets → dist/pstack}/skills/principle-test-behavior-not-implementation/SKILL.md +1 -1
- package/{assets → dist/pstack}/skills/principle-type-system-discipline/SKILL.md +1 -1
- package/dist/pstack/skills/recall/SKILL.md +37 -0
- package/dist/pstack/skills/reflect/SKILL.md +71 -0
- package/{assets → dist/pstack}/skills/reflect/references/divergent-reviewer.md +4 -4
- package/{assets → dist/pstack}/skills/reflect/references/judgment-reviewer.md +2 -2
- package/{assets → dist/pstack}/skills/reflect/references/synthesizer.md +5 -5
- package/{assets → dist/pstack}/skills/reflect/references/tooling-reviewer.md +2 -2
- package/dist/pstack/skills/setup-pstack/SKILL.md +80 -0
- package/{assets → dist/pstack}/skills/sharpen/SKILL.md +1 -1
- package/{assets → dist/pstack}/skills/show-me-your-work/SKILL.md +8 -8
- package/{assets → dist/pstack}/skills/show-me-your-work/scripts/log.mjs +1 -3
- 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 -1
- package/{assets → dist/pstack}/skills/teach/SKILL.md +2 -2
- package/{assets → dist/pstack}/skills/technical-writing/SKILL.md +1 -1
- package/{assets → dist/pstack}/skills/typescript-best-practices/SKILL.md +3 -6
- package/{assets → dist/pstack}/skills/why/SKILL.md +8 -8
- package/dist/script.d.mts +9 -111
- package/dist/script.mjs +32 -329
- 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 +56 -193
- package/dist/subagent.mjs +443 -741
- package/locale/en.json +3 -2
- package/locale/zh.json +3 -2
- package/package.json +63 -66
- package/assets/agents/poteto-agent.md +0 -8
- package/assets/docs/harness/dsh.md +0 -60
- package/assets/docs/pstack-models.example.md +0 -54
- package/assets/skills/arena/SKILL.md +0 -50
- package/assets/skills/figure-it-out/SKILL.md +0 -54
- package/assets/skills/how/SKILL.md +0 -38
- package/assets/skills/interrogate/SKILL.md +0 -71
- 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/no-comments/SKILL.md +0 -26
- package/assets/skills/poteto-mode/playbooks/authoring-a-skill.md +0 -12
- package/assets/skills/poteto-mode/playbooks/autonomous-run.md +0 -15
- package/assets/skills/poteto-mode/playbooks/autopilot-full.md +0 -25
- package/assets/skills/poteto-mode/playbooks/autopilot-stack.md +0 -12
- package/assets/skills/poteto-mode/playbooks/bug-fix.md +0 -15
- package/assets/skills/poteto-mode/playbooks/feature.md +0 -21
- 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/runtime-forensics.md +0 -11
- package/assets/skills/poteto-mode/playbooks/session-pickup.md +0 -11
- package/assets/skills/poteto-mode/playbooks/visual-parity.md +0 -11
- package/assets/skills/poteto-mode/playbooks/worktree-cleanup.md +0 -20
- package/assets/skills/poteto-mode/scripts/orch/orch.mjs +0 -4282
- package/assets/skills/poteto-mode/scripts/orch/orch.test.mjs +0 -2042
- package/assets/skills/poteto-mode/scripts/watch-pr/cli.test.mjs +0 -5101
- package/assets/skills/poteto-mode/scripts/watch-pr/github.test.mjs +0 -1177
- package/assets/skills/poteto-mode/scripts/watch-pr/policy.test.mjs +0 -1441
- package/assets/skills/poteto-mode/scripts/watch-pr/watch-pr.mjs +0 -4601
- package/assets/skills/recall/SKILL.md +0 -37
- package/assets/skills/reflect/SKILL.md +0 -69
- package/assets/skills/setup-pstack/SKILL.md +0 -67
- package/assets/skills/swarm/SKILL.md +0 -43
- package/dist/frontmatter-BQX3ekwP.mjs +0 -229
- package/dist/frontmatter-BQX3ekwP.mjs.map +0 -1
- package/dist/history.d.mts +0 -429
- package/dist/history.mjs +0 -1129
- package/dist/history.mjs.map +0 -1
- package/dist/host-contract-o47JH_r8.d.mts +0 -527
- package/dist/index.mjs.map +0 -1
- package/dist/paths-D_JlVmBk.mjs +0 -42
- package/dist/paths-D_JlVmBk.mjs.map +0 -1
- package/dist/script.mjs.map +0 -1
- package/dist/subagent.mjs.map +0 -1
- /package/{static/icon.png → assets/logo.png} +0 -0
- /package/{assets → dist/pstack}/agents/comment-sicko.md +0 -0
- /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/images/design.jpg +0 -0
- /package/{assets → dist/pstack}/docs/guide/images/overnight.jpg +0 -0
- /package/{assets → dist/pstack}/docs/guide/images/recipes.jpg +0 -0
- /package/{assets → dist/pstack}/docs/guide/images/router.jpg +0 -0
- /package/{assets → dist/pstack}/docs/guide/images/understanding.jpg +0 -0
- /package/{assets → dist/pstack}/docs/guide/images/verification.jpg +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/bro/SKILL.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/explainer-prompt.md +0 -0
- /package/{assets → dist/pstack}/skills/how/references/explorer-prompt.md +0 -0
- /package/{assets → dist/pstack}/skills/poteto-mode/references/bugbot-triage.md +0 -0
- /package/{assets → dist/pstack}/skills/principle-build-the-lever/SKILL.md +0 -0
- /package/{assets → dist/pstack}/skills/principle-foundational-thinking/SKILL.md +0 -0
- /package/{assets → dist/pstack}/skills/principle-guard-the-context-window/SKILL.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/unslop/SKILL.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
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
import { key, show } from "./ir.mjs";
|
|
2
|
+
import { plainText } from "./backends/plain-text.mjs";
|
|
3
|
+
import { compile } from "./pipeline.mjs";
|
|
4
|
+
import { readConfig } from "./frontends/config.mjs";
|
|
5
|
+
import { parseValue } from "./frontends/value.mjs";
|
|
6
|
+
import { readMessages } from "./frontends/messages.mjs";
|
|
7
|
+
import { readChecks } from "./frontends/spec.mjs";
|
|
8
|
+
import { checkView, json } from "./frontends/view.mjs";
|
|
9
|
+
import { chmodSync, mkdirSync, mkdtempSync, readFileSync, readdirSync, rmSync, writeFileSync } from "node:fs";
|
|
10
|
+
import { tmpdir } from "node:os";
|
|
11
|
+
import { join } from "node:path";
|
|
12
|
+
import { spawnSync } from "node:child_process";
|
|
13
|
+
import { test } from "node:test";
|
|
14
|
+
import { inspect } from "node:util";
|
|
15
|
+
import assert from "node:assert/strict";
|
|
16
|
+
// runtime/skills/statechart/scripts/statechart.test.ts
|
|
17
|
+
const invariant = {
|
|
18
|
+
kind: "invariant",
|
|
19
|
+
name: "Inv"
|
|
20
|
+
};
|
|
21
|
+
function graphWithBreak() {
|
|
22
|
+
return {
|
|
23
|
+
states: /* @__PURE__ */ new Map([["s0", {
|
|
24
|
+
vars: { x: 0 },
|
|
25
|
+
start: true,
|
|
26
|
+
breaks: []
|
|
27
|
+
}], ["s1", {
|
|
28
|
+
vars: { x: 1 },
|
|
29
|
+
start: false,
|
|
30
|
+
breaks: [invariant]
|
|
31
|
+
}]]),
|
|
32
|
+
steps: [{
|
|
33
|
+
from: "s0",
|
|
34
|
+
to: "s1",
|
|
35
|
+
action: "Next"
|
|
36
|
+
}]
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
function resultWithBreak() {
|
|
40
|
+
return {
|
|
41
|
+
spec: {
|
|
42
|
+
module: "Test",
|
|
43
|
+
folder: "/tmp",
|
|
44
|
+
variables: ["x"],
|
|
45
|
+
invariants: ["Inv"],
|
|
46
|
+
properties: [],
|
|
47
|
+
deadlock: false,
|
|
48
|
+
written: []
|
|
49
|
+
},
|
|
50
|
+
graph: graphWithBreak(),
|
|
51
|
+
paths: void 0,
|
|
52
|
+
rules: [{
|
|
53
|
+
rule: invariant,
|
|
54
|
+
outcome: "broken",
|
|
55
|
+
messages: ["Inv is violated"]
|
|
56
|
+
}],
|
|
57
|
+
properties: [],
|
|
58
|
+
exit: 1,
|
|
59
|
+
stop: void 0,
|
|
60
|
+
drawing: void 0,
|
|
61
|
+
states: {
|
|
62
|
+
distinct: 2,
|
|
63
|
+
initial: 1,
|
|
64
|
+
complete: true,
|
|
65
|
+
cut: false
|
|
66
|
+
},
|
|
67
|
+
messages: ["TLC finished"]
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
test("reads the TLA+ value grammar the skill documents", () => {
|
|
71
|
+
assert.deepEqual(json(parseValue("<<1, \"a\", <<>>>>")), {
|
|
72
|
+
1: 1,
|
|
73
|
+
2: "a",
|
|
74
|
+
3: {}
|
|
75
|
+
});
|
|
76
|
+
assert.deepEqual(json(parseValue("{r1, -2}")), ["r1", -2]);
|
|
77
|
+
assert.deepEqual(json(parseValue("-1..2")), [
|
|
78
|
+
-1,
|
|
79
|
+
0,
|
|
80
|
+
1,
|
|
81
|
+
2
|
|
82
|
+
]);
|
|
83
|
+
assert.deepEqual(json(parseValue("[ok |-> TRUE, msg |-> \"say \\\"hi\\\"\"]")), {
|
|
84
|
+
ok: true,
|
|
85
|
+
msg: "say \"hi\""
|
|
86
|
+
});
|
|
87
|
+
assert.throws(() => parseValue("1.."), /cannot read TLA\+ value/);
|
|
88
|
+
});
|
|
89
|
+
test("prints each value in TLA+ and compares by TLA+ equality", () => {
|
|
90
|
+
assert.equal(show(parseValue("<<0>>")), "<<0>>");
|
|
91
|
+
assert.equal(show(parseValue("[a |-> 1]")), "[a |-> 1]");
|
|
92
|
+
assert.equal(key(parseValue("1..3")), key(parseValue("{3, 1, 2, 2}")));
|
|
93
|
+
assert.notEqual(key(parseValue("\"A\"")), key(parseValue("A")));
|
|
94
|
+
});
|
|
95
|
+
test("reads a TLC config into the checks the report names", () => {
|
|
96
|
+
const config = readConfig({
|
|
97
|
+
file: "Min.cfg",
|
|
98
|
+
text: "INIT Init\nNEXT Next\nINVARIANT Inv\nPROPERTY Live\n"
|
|
99
|
+
});
|
|
100
|
+
assert.equal(config.init, "Init");
|
|
101
|
+
assert.equal(config.next, "Next");
|
|
102
|
+
assert.deepEqual(config.invariants, ["Inv"]);
|
|
103
|
+
assert.deepEqual(config.properties, ["Live"]);
|
|
104
|
+
const checks = readChecks({
|
|
105
|
+
configFile: "Min.cfg",
|
|
106
|
+
config
|
|
107
|
+
});
|
|
108
|
+
assert.equal(checks.deadlock, true);
|
|
109
|
+
});
|
|
110
|
+
test("prints TLC's -tool messages as plain text", () => {
|
|
111
|
+
const text = [
|
|
112
|
+
"@!@!@STARTMSG 2262:0 @!@!@",
|
|
113
|
+
"TLC2 Version 2.19",
|
|
114
|
+
"@!@!@ENDMSG 2262 @!@!@"
|
|
115
|
+
].join("\n");
|
|
116
|
+
assert.equal([...plainText(readMessages(text))].join(""), "TLC2 Version 2.19\n");
|
|
117
|
+
});
|
|
118
|
+
test("compiles a broken rule into report.md, chart.mmd, and tlc.out", () => {
|
|
119
|
+
const compiled = compile(resultWithBreak(), checkView({}, inspect));
|
|
120
|
+
assert.equal(compiled.exit, 1);
|
|
121
|
+
const report = compiled.report;
|
|
122
|
+
assert.match(report, /Inv/);
|
|
123
|
+
assert.match(report, /Next/);
|
|
124
|
+
const chart = [...compiled.files.get("chart.mmd") ?? []].join("");
|
|
125
|
+
assert.match(chart, /stateDiagram/);
|
|
126
|
+
assert.match(chart, /Next/);
|
|
127
|
+
assert.ok(compiled.files.has("report.md"));
|
|
128
|
+
assert.ok(compiled.files.has("tlc.out"));
|
|
129
|
+
});
|
|
130
|
+
test("the CLI rejects a missing spec with usage and exit 2", () => {
|
|
131
|
+
const here = import.meta.dirname;
|
|
132
|
+
const entry = join(here, import.meta.url.endsWith(".ts") ? "statechart.ts" : "statechart.mjs");
|
|
133
|
+
const result = spawnSync(process.execPath, [entry], { encoding: "utf8" });
|
|
134
|
+
assert.equal(result.status, 2);
|
|
135
|
+
assert.match(result.stderr, /Give one SPEC\.tla\./);
|
|
136
|
+
assert.match(result.stderr, /Usage: statechart SPEC\.tla/);
|
|
137
|
+
});
|
|
138
|
+
test("the CLI runs the worker against TLC and writes the report, chart, and tlc.out", () => {
|
|
139
|
+
const root = mkdtempSync(join(tmpdir(), "statechart-worker-"));
|
|
140
|
+
try {
|
|
141
|
+
const caseDir = join(root, "case");
|
|
142
|
+
mkdirSync(caseDir);
|
|
143
|
+
writeFileSync(join(caseDir, "Smoke.tla"), "---- MODULE Smoke ----\n====\n");
|
|
144
|
+
writeFileSync(join(caseDir, "Smoke.cfg"), "INIT Init\nNEXT Next\n");
|
|
145
|
+
const fakeJava = join(root, "fake-java.mjs");
|
|
146
|
+
writeFileSync(fakeJava, String.raw`#!/usr/bin/env node
|
|
147
|
+
import fs from "node:fs";
|
|
148
|
+
const args = process.argv.slice(2);
|
|
149
|
+
if (args.includes("tla2sany.xml.XMLExporter")) {
|
|
150
|
+
process.stdout.write('<modules><context><entry><UID>1</UID><OpDeclNode><uniquename>x</uniquename><kind>3</kind></OpDeclNode></entry><entry><UID>2</UID><ModuleNode><uniquename>Smoke</uniquename><OpDeclNodeRef><UID>1</UID></OpDeclNodeRef></ModuleNode></entry></context><RootModule>Smoke</RootModule></modules>');
|
|
151
|
+
process.exit(0);
|
|
152
|
+
}
|
|
153
|
+
const dump = args.indexOf("-dump");
|
|
154
|
+
if (dump !== -1) {
|
|
155
|
+
fs.writeFileSync(args[dump + 2] + ".dot", [
|
|
156
|
+
"strict digraph DiskGraph {",
|
|
157
|
+
'1 [label="/\\\\ x = 0",style = filled]',
|
|
158
|
+
'2 [label="/\\\\ x = 1"]',
|
|
159
|
+
'1 -> 2 [label="Next"];',
|
|
160
|
+
"}",
|
|
161
|
+
].join("\n"));
|
|
162
|
+
}
|
|
163
|
+
process.stdout.write("@!@!@STARTMSG 2199:0 @!@!@\n2 distinct states found.\n@!@!@ENDMSG 2199 @!@!@\n");
|
|
164
|
+
process.exit(0);
|
|
165
|
+
`);
|
|
166
|
+
chmodSync(fakeJava, 493);
|
|
167
|
+
const here = import.meta.dirname;
|
|
168
|
+
const entry = join(here, import.meta.url.endsWith(".ts") ? "statechart.ts" : "statechart.mjs");
|
|
169
|
+
const out = join(root, "out");
|
|
170
|
+
const result = spawnSync(process.execPath, [
|
|
171
|
+
entry,
|
|
172
|
+
join(caseDir, "Smoke.tla"),
|
|
173
|
+
"--out",
|
|
174
|
+
out
|
|
175
|
+
], {
|
|
176
|
+
encoding: "utf8",
|
|
177
|
+
env: {
|
|
178
|
+
...process.env,
|
|
179
|
+
JAVA: fakeJava,
|
|
180
|
+
TLA2TOOLS: "tla2tools.jar"
|
|
181
|
+
}
|
|
182
|
+
});
|
|
183
|
+
assert.equal(result.status, 0, result.stderr);
|
|
184
|
+
assert.deepEqual(readdirSync(out).sort(), [
|
|
185
|
+
"chart.mmd",
|
|
186
|
+
"report.md",
|
|
187
|
+
"tlc.out"
|
|
188
|
+
]);
|
|
189
|
+
assert.match(readFileSync(join(out, "report.md"), "utf8"), /# Smoke[\s\S]*NoDeadlock/);
|
|
190
|
+
assert.match(readFileSync(join(out, "chart.mmd"), "utf8"), /stateDiagram/);
|
|
191
|
+
} finally {
|
|
192
|
+
rmSync(root, {
|
|
193
|
+
recursive: true,
|
|
194
|
+
force: true
|
|
195
|
+
});
|
|
196
|
+
}
|
|
197
|
+
});
|
|
198
|
+
export {};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { compile } from "./pipeline.mjs";
|
|
2
|
+
import { check, messageOf } from "./run.mjs";
|
|
3
|
+
import { checkView } from "./frontends/view.mjs";
|
|
4
|
+
import fs from "node:fs";
|
|
5
|
+
import path from "node:path";
|
|
6
|
+
import { inspect } from "node:util";
|
|
7
|
+
import { pathToFileURL } from "node:url";
|
|
8
|
+
import { Buffer } from "node:buffer";
|
|
9
|
+
// runtime/skills/statechart/scripts/worker.ts
|
|
10
|
+
const [stage, specFile, configFile, viewFile] = process.argv.slice(2);
|
|
11
|
+
try {
|
|
12
|
+
const view = checkView(viewFile ? await import(pathToFileURL(path.resolve(viewFile)).href) : {}, inspect);
|
|
13
|
+
const { files, exit } = compile(await check(specFile, configFile), view);
|
|
14
|
+
const draft = path.join(stage, "draft");
|
|
15
|
+
fs.mkdirSync(draft);
|
|
16
|
+
for (const [name, parts] of files) {
|
|
17
|
+
const fd = fs.openSync(path.join(draft, name), "wx");
|
|
18
|
+
try {
|
|
19
|
+
for (const part of parts) fs.writeSync(fd, typeof part === "string" ? Buffer.from(part) : part);
|
|
20
|
+
fs.writeSync(fd, "\n");
|
|
21
|
+
} finally {
|
|
22
|
+
fs.closeSync(fd);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
fs.renameSync(draft, path.join(stage, "done"));
|
|
26
|
+
process.exit(exit);
|
|
27
|
+
} catch (error) {
|
|
28
|
+
console.error(messageOf(error));
|
|
29
|
+
process.exit(2);
|
|
30
|
+
}
|
|
31
|
+
export {};
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: swarm
|
|
3
|
+
description: "Fan out N parallel workers, drain them, and return one report. Use for /swarm, 'swarm this', or parallel coverage, races, gauntlets, and exploration."
|
|
4
|
+
disable-model-invocation: true
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# Swarm
|
|
8
|
+
|
|
9
|
+
In DeepSeek Harness, read [the DSH adapter](../../docs/harness/dsh.md) once per session before you follow this skill. It maps the Cursor names in pstack skills to DeepSeek Harness.
|
|
10
|
+
|
|
11
|
+
## Start
|
|
12
|
+
|
|
13
|
+
Open a todolist with one entry per phase before launching anything.
|
|
14
|
+
|
|
15
|
+
1. Frame
|
|
16
|
+
2. Fan out
|
|
17
|
+
3. Aggregate
|
|
18
|
+
4. Report
|
|
19
|
+
|
|
20
|
+
## Phase A: Frame
|
|
21
|
+
|
|
22
|
+
1. State the done predicate and the artifact or report the swarm must return.
|
|
23
|
+
2. Choose the shape. Partition into slices, race N workers on identical briefs, or mix both. For a race or mixed shape, declare `first pass`, `rank all`, or `best-of` before spawning.
|
|
24
|
+
3. Pick the worker model from the `swarm workers` line in `~/.cursor/rules/pstack-models.mdc`. If the rule or that line is missing, use `grok-4.7-xhigh-fast`. For `auto` or `inherit-parent`, omit `model` so the workers run on the parent model. If the Task tool rejects a slug, use the default and say so. If it rejects the default, use the closest valid slug of the same family from its error message. For a model race, name each arm's model up front. Pick each subagent's reasoning level and fast or standard speed for the job, per the Subagents section of the **poteto-mode** skill.
|
|
25
|
+
4. Give each worker its own writable output when it writes. When workers verify or measure commits, each brief names the exact SHAs. A measurement brief also names the method (sample count, what one sample is, order). The worker records both in its result.
|
|
26
|
+
|
|
27
|
+
## Phase B: Fan out
|
|
28
|
+
|
|
29
|
+
Spawn all N workers in one message with `subagent_type: generalPurpose`, `environment: "cloud"`, `run_in_background: true`, and the step 3 model, left unset for `auto` or `inherit-parent`. Use `environment: "local"` only when the worker needs access to something on the user's computer.
|
|
30
|
+
|
|
31
|
+
When a worker must start from a non-default pushed branch, pass `cloud_base_branch`.
|
|
32
|
+
|
|
33
|
+
Every brief stands alone. Include the goal, scope, exact slice or race arm, how to verify, and what to report. Reports use `PASS`, `ISSUES`, or `BLOCKED` with evidence. A worker that can prove a defect reports `ISSUES` and lists every issue it can prove, not only the first.
|
|
34
|
+
|
|
35
|
+
If a worker drops out, proceed with N-1 and note it.
|
|
36
|
+
|
|
37
|
+
## Phase C: Aggregate
|
|
38
|
+
|
|
39
|
+
Read the terminal results. Drop a result that does not record the SHAs and method its brief names, and respawn that worker once. After a second miss, record a gap. A gap does not count as a pass. For coverage, every required slice needs a result. For a race, apply the selection rule declared up front. Use first pass, rank all, or best-of. Do not paste raw worker dumps.
|
|
40
|
+
|
|
41
|
+
## Phase D: Report
|
|
42
|
+
|
|
43
|
+
Return one consolidated in-chat report with a result table, issue one-liners, gaps or dropouts, and the race rule when used.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: tdd
|
|
3
|
-
description: Use only when the user explicitly asks for TDD, a failing test, or a regression test, OR when the bug has an obvious cheap local test target. Skip when the test path is unclear, expensive, integration-heavy, or not requested.
|
|
3
|
+
description: "Use only when the user explicitly asks for TDD, a failing test, or a regression test, OR when the bug has an obvious cheap local test target. Skip when the test path is unclear, expensive, integration-heavy, or not requested."
|
|
4
4
|
disable-model-invocation: true
|
|
5
5
|
---
|
|
6
6
|
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: teach
|
|
3
|
-
description: Explain a body of work plainly so a person actually understands it. Runs the `how` and `why` skills and weaves what they find into one clear explanation. Use for 'teach me this', 'help me really understand X', 'explain this change or subsystem to me'.
|
|
3
|
+
description: "Explain a body of work plainly so a person actually understands it. Runs the `how` and `why` skills and weaves what they find into one clear explanation. Use for 'teach me this', 'help me really understand X', 'explain this change or subsystem to me'."
|
|
4
4
|
disable-model-invocation: true
|
|
5
5
|
---
|
|
6
6
|
|
|
7
7
|
# Teach
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
In DeepSeek Harness, read [the DSH adapter](../../docs/harness/dsh.md) once per session before you follow this skill. It maps the Cursor names in pstack skills to DeepSeek Harness.
|
|
10
10
|
|
|
11
11
|
**You explain what a thing is, how it works, and why it's built that way, in one plain account at the person's pace. The goal is that they understand it, not that you change anything.**
|
|
12
12
|
|
|
@@ -6,7 +6,7 @@ disable-model-invocation: true
|
|
|
6
6
|
|
|
7
7
|
# Technical writing
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
In DeepSeek Harness, read [the DSH adapter](../../docs/harness/dsh.md) once per session before you follow this skill. It maps the Cursor names in pstack skills to DeepSeek Harness.
|
|
10
10
|
|
|
11
11
|
Write so a tired engineer understands on the first read. Apply all four layers.
|
|
12
12
|
|
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: typescript-best-practices
|
|
3
3
|
description: TypeScript best practices. Use when reading or editing any .ts or .tsx file.
|
|
4
|
+
paths: ["**/*.ts", "**/*.tsx"]
|
|
4
5
|
disable-model-invocation: true
|
|
5
6
|
---
|
|
6
7
|
|
|
7
8
|
# TypeScript best practices
|
|
8
9
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
Apply `principle-type-system-discipline` first; read its `SKILL.md` at its absolute resource path.
|
|
10
|
+
Apply the **type-system-discipline** principle skill first.
|
|
12
11
|
|
|
13
12
|
| Rule | Summary |
|
|
14
13
|
|------|---------|
|
|
@@ -23,12 +22,10 @@ Apply `principle-type-system-discipline` first; read its `SKILL.md` at its absol
|
|
|
23
22
|
| Type guards | Must verify the claim. A lying guard is worse than `as` because the bug hides behind a name that says it's safe. Name them `isX` or `hasX`. |
|
|
24
23
|
| Exhaustiveness | Inline `const _exhaustive: never = x;` in default arms so the compiler errors when a new variant is added. |
|
|
25
24
|
| `satisfies` over `as` | Validates the value without widening literal types. |
|
|
26
|
-
| Boundary validation | Parse where data crosses in, into a named domain type. `Record<string, unknown>` (however spelled) stops at that parse. Trust types inside. See
|
|
25
|
+
| Boundary validation | Parse where data crosses in, into a named domain type. `Record<string, unknown>` (however spelled) stops at that parse. Trust types inside. See the **boundary-discipline** principle skill. |
|
|
27
26
|
| Schema-derived types | Reach for `Pick`/`Omit`/`Parameters`/`ReturnType`/`Awaited`/`typeof` before declaring a new interface. |
|
|
28
27
|
| Object args | Pass objects, not positional, so argument order is self-documenting. Skip on hot paths (per-frame render, tokenizers, parsers). |
|
|
29
28
|
| Real tests | Don't mock what you can run. Prefer the framework's real test primitives with leak/disposable checks, and verify UI in a running build. Mock only what you can't run locally. |
|
|
30
29
|
| Structured telemetry | Prefer structured logger diagnostics with enough context to debug from an id. No `console.log` in shipped code. |
|
|
31
30
|
|
|
32
31
|
Examples: `references/patterns.md`.
|
|
33
|
-
|
|
34
|
-
This skill is explicit-invocation only. DSH does not consume a `paths` glob, so opening a `.ts` or `.tsx` file does not attach it: load it by name when you want it applied.
|
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: why
|
|
3
|
-
description: Use for 'why does X work this way', 'why we picked Y', design rationale, regressions, postmortems, or data-backed thresholds. Discovers available MCPs and queries each evidence category (source control, issue tracker, long-form docs, real-time chat, infrastructure observability, error tracking, product analytics warehouse) in parallel, then returns a cited read on decisions and tradeoffs. Use how for runtime behavior.
|
|
3
|
+
description: "Use for 'why does X work this way', 'why we picked Y', design rationale, regressions, postmortems, or data-backed thresholds. Discovers available MCPs and queries each evidence category (source control, issue tracker, long-form docs, real-time chat, infrastructure observability, error tracking, product analytics warehouse) in parallel, then returns a cited read on decisions and tradeoffs. Use how for runtime behavior."
|
|
4
4
|
disable-model-invocation: true
|
|
5
5
|
---
|
|
6
6
|
|
|
7
7
|
# Why
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
In DeepSeek Harness, read [the DSH adapter](../../docs/harness/dsh.md) once per session before you follow this skill. It maps the Cursor names in pstack skills to DeepSeek Harness.
|
|
10
10
|
|
|
11
|
-
Investigate the motivation and intent behind code. The companion `how` skill answers what the code does and how it works
|
|
11
|
+
Investigate the motivation and intent behind code. The companion `how` skill answers what the code does and how it works. `why` answers what forces led to its shape.
|
|
12
12
|
|
|
13
|
-
Each spawn below names a role
|
|
13
|
+
Each spawn below names a role line in the `pstack-models.mdc` rule and a default. Set `model` to that line's value, or to the default if the rule or the line is missing. Leave `model` unset when the value is `auto` or `inherit-parent`. If the Task tool rejects a slug, use the default and say so. If it rejects the default, use the closest valid slug of the same family from its error message. Pick each subagent's reasoning level and fast or standard speed for the job, per the Subagents section of the **poteto-mode** skill.
|
|
14
14
|
|
|
15
|
-
Every spawn is `
|
|
15
|
+
Every spawn is `generalPurpose` with `readonly: false` (agent mode). **Do not use readonly/Ask mode.** It strips MCP access, which disables the MCP-backed investigators and the synthesizer's citation spot-checks. Investigators still shouldn't write anything.
|
|
16
16
|
|
|
17
17
|
## Operating Posture
|
|
18
18
|
|
|
@@ -34,7 +34,7 @@ Before spawning investigators, build the seed context inline: file paths and lin
|
|
|
34
34
|
|
|
35
35
|
### Discovery
|
|
36
36
|
|
|
37
|
-
Before spawning investigators, list the
|
|
37
|
+
Before spawning investigators, list the available MCPs from the Cursor environment. Use the available-tools map when present. Otherwise inspect the `mcps/` directory Cursor exposes for enabled MCP servers.
|
|
38
38
|
|
|
39
39
|
Map each available MCP to one evidence category:
|
|
40
40
|
|
|
@@ -48,7 +48,7 @@ Map each available MCP to one evidence category:
|
|
|
48
48
|
|
|
49
49
|
Source control is always available through git and `gh`. For the other six, classify using the MCP name, server instructions, tool names, and resource descriptors. If an MCP could fit more than one category, choose the one matching its primary evidence. Record ambiguous cases in the coverage map.
|
|
50
50
|
|
|
51
|
-
Spawn one investigator per category that has a matching MCP, all in
|
|
51
|
+
Spawn one investigator per category that has a matching MCP, all in a single message so they run concurrently, each owning exactly one tool or MCP. Don't ask one agent to cover multiple MCPs. `model`: the `why investigators` line, default `grok-4.7-xhigh-fast`.
|
|
52
52
|
|
|
53
53
|
Each investigator's prompt is `references/investigator-prompt.md` filled in, plus:
|
|
54
54
|
- the category playbook `references/sources/<source>.md` for the selected MCP, adapted from the examples in `references/source-playbook.md`
|
|
@@ -78,7 +78,7 @@ If your scope assessment suggests a single-commit trivial target where the PR de
|
|
|
78
78
|
|
|
79
79
|
## Step 4. Synthesize
|
|
80
80
|
|
|
81
|
-
Spawn one synthesizer
|
|
81
|
+
Spawn one synthesizer. `model`: the `why synthesizer` line, default `claude-opus-5-5-xhigh`. It gets:
|
|
82
82
|
1. The investigator findings, including any null results and any categories skipped with justification
|
|
83
83
|
2. The code anchor
|
|
84
84
|
3. The user's original question
|
package/dist/script.d.mts
CHANGED
|
@@ -1,15 +1,11 @@
|
|
|
1
|
-
import {
|
|
2
|
-
//#region src/script.d.ts
|
|
1
|
+
import { _ as ToolsHost, a as JobsHost, c as SessionId, g as ToolDefinition, i as JobId, o as JsonSchemaNode, v as WorkingDirectoryHost } from "./host-contract-CUPSpeNk.mjs";
|
|
3
2
|
/** Model-facing tool name. */
|
|
4
3
|
export declare const TOOL_NAME = "pstack_script";
|
|
5
4
|
/** The shipped scripts this tool may run, in display order. */
|
|
6
5
|
export declare const SCRIPT_IDS: string[];
|
|
7
6
|
export type ScriptId = (typeof SCRIPT_IDS)[number];
|
|
8
|
-
/** Default wall-clock limit for a foreground run. */
|
|
9
7
|
export declare const DEFAULT_TIMEOUT_MS = 120000;
|
|
10
|
-
/** Bounds a caller may set for one foreground run. */
|
|
11
8
|
export declare const MAX_TIMEOUT_MS = 600000;
|
|
12
|
-
/** Default cap on captured bytes per stream. */
|
|
13
9
|
export declare const DEFAULT_OUTPUT_LIMIT_BYTES: number;
|
|
14
10
|
/** Raised for an argument problem, before anything is spawned. */
|
|
15
11
|
export declare class ScriptInputError extends Error {
|
|
@@ -19,7 +15,6 @@ export declare class ScriptInputError extends Error {
|
|
|
19
15
|
export declare class ScriptMissingError extends Error {
|
|
20
16
|
constructor(message: string);
|
|
21
17
|
}
|
|
22
|
-
/** One parsed call. */
|
|
23
18
|
export interface ScriptArgs {
|
|
24
19
|
readonly id: ScriptId;
|
|
25
20
|
readonly args: readonly string[];
|
|
@@ -28,7 +23,6 @@ export interface ScriptArgs {
|
|
|
28
23
|
readonly timeoutMs?: number;
|
|
29
24
|
readonly outputLimitBytes?: number;
|
|
30
25
|
}
|
|
31
|
-
/** What a foreground run produced. */
|
|
32
26
|
export interface ScriptResult {
|
|
33
27
|
readonly kind: "foreground";
|
|
34
28
|
readonly id: ScriptId;
|
|
@@ -37,74 +31,35 @@ export interface ScriptResult {
|
|
|
37
31
|
readonly timedOut: boolean;
|
|
38
32
|
readonly stdout: string;
|
|
39
33
|
readonly stderr: string;
|
|
40
|
-
/** True when a stream was cut off at the limit. */
|
|
41
34
|
readonly stdoutTruncated: boolean;
|
|
42
35
|
readonly stderrTruncated: boolean;
|
|
43
36
|
readonly durationMs: number;
|
|
44
37
|
}
|
|
45
|
-
/** What a background run produced. */
|
|
46
38
|
export interface ScriptJobResult {
|
|
47
39
|
readonly kind: "background";
|
|
48
40
|
readonly id: ScriptId;
|
|
49
41
|
readonly jobId: JobId;
|
|
50
42
|
readonly status: string;
|
|
51
43
|
}
|
|
52
|
-
/** Either outcome, as the model sees it. */
|
|
53
44
|
export type ScriptOutcome = ScriptResult | ScriptJobResult;
|
|
54
45
|
/** Absolute path of one shipped artefact. */
|
|
55
46
|
export declare function scriptPath(id: ScriptId): string;
|
|
56
|
-
/**
|
|
57
|
-
* The environment a child gets.
|
|
58
|
-
*
|
|
59
|
-
* The one rule is the Electron selector. Under Electron, `process.execPath` is the
|
|
60
|
-
* Desktop binary, which starts a browser window unless `ELECTRON_RUN_AS_NODE=1` tells
|
|
61
|
-
* it to behave as Node. Under plain Node the variable is inert — Node ignores it —
|
|
62
|
-
* so setting it unconditionally would also work; it is conditional here so the
|
|
63
|
-
* environment of a normal run stays exactly the caller's, and the one code path that
|
|
64
|
-
* needs it is visible.
|
|
65
|
-
*/
|
|
47
|
+
/** The environment a child gets: the Electron selector, and otherwise the caller's. */
|
|
66
48
|
export declare function scriptEnvironment(base?: NodeJS.ProcessEnv, versions?: {
|
|
67
49
|
readonly electron?: string;
|
|
68
50
|
}): NodeJS.ProcessEnv;
|
|
69
51
|
/** Validate the raw tool arguments. */
|
|
70
52
|
export declare function parseScriptArgs(raw: unknown): ScriptArgs;
|
|
71
|
-
/**
|
|
72
|
-
* Resolve the directory the child runs in.
|
|
73
|
-
*
|
|
74
|
-
* The tool's `cwd` argument is documented as resolving against "this session's
|
|
75
|
-
* directory", so `sessionCwd` — the value `ctx.workingDirectory.ensure()` returns —
|
|
76
|
-
* is the base, not the Host process's working directory.
|
|
77
|
-
*
|
|
78
|
-
* - omitted -> the session directory
|
|
79
|
-
* - relative -> joined onto the session directory
|
|
80
|
-
* - absolute -> used as-is
|
|
81
|
-
*
|
|
82
|
-
* With no Session (a call outside an Agent) there is no session directory to
|
|
83
|
-
* anchor to; the argument is then passed through and `resolve` normalises it
|
|
84
|
-
* against the Host process, which is the only directory that exists.
|
|
85
|
-
*/
|
|
53
|
+
/** Resolve the directory the child runs in, relative to the caller-established session directory. */
|
|
86
54
|
export declare function resolveWorkingDirectory(requested: string | undefined, sessionCwd: string | undefined): string | undefined;
|
|
87
|
-
/**
|
|
88
|
-
* Run one script in the foreground.
|
|
89
|
-
*
|
|
90
|
-
* A nonzero exit, a signal, a timeout, and truncated output are all returned rather
|
|
91
|
-
* than raised: the caller needs to see what the script said before it failed, and an
|
|
92
|
-
* exception would discard the captured output.
|
|
93
|
-
*/
|
|
55
|
+
/** Run one script in the foreground. A nonzero exit, signal, timeout, and truncation are returned, not thrown. */
|
|
94
56
|
export declare function runForeground(args: ScriptArgs, options?: {
|
|
95
57
|
readonly execPath?: string;
|
|
96
58
|
readonly environment?: NodeJS.ProcessEnv;
|
|
97
|
-
/** Already resolved by the caller; see `resolveWorkingDirectory`. */
|
|
98
59
|
readonly cwd?: string;
|
|
99
60
|
readonly signal?: AbortSignal;
|
|
100
61
|
}): Promise<ScriptResult>;
|
|
101
|
-
/**
|
|
102
|
-
* Start a script as a background job.
|
|
103
|
-
*
|
|
104
|
-
* `jobs` is required and passing nothing is a refusal with a reason. A job whose
|
|
105
|
-
* output nobody can read would be worse than a failed call: the model would report a
|
|
106
|
-
* task as started and no notice would ever arrive.
|
|
107
|
-
*/
|
|
62
|
+
/** Start a script as a background job. `jobs` absent is a refusal with a reason. */
|
|
108
63
|
export declare function runBackground(args: ScriptArgs, options: {
|
|
109
64
|
readonly jobs?: JobsHost | undefined;
|
|
110
65
|
readonly caller?: SessionId;
|
|
@@ -112,82 +67,25 @@ export declare function runBackground(args: ScriptArgs, options: {
|
|
|
112
67
|
readonly environment?: NodeJS.ProcessEnv;
|
|
113
68
|
readonly cwd?: string;
|
|
114
69
|
}): Promise<ScriptJobResult>;
|
|
115
|
-
/**
|
|
116
|
-
* Render one captured stream as a fenced block, byte for byte.
|
|
117
|
-
*
|
|
118
|
-
* `trimEnd` used to run here, which is wrong for two reasons:
|
|
119
|
-
*
|
|
120
|
-
* - A stream of only whitespace passed the `!== ""` test and then rendered as an
|
|
121
|
-
* empty-looking `stdout:` line, so a reader concluded the script printed nothing.
|
|
122
|
-
* - `check-plan`'s contract includes exact line counts and blank-line separators, so
|
|
123
|
-
* a trimmed block is a different document — and the model reads this text as the
|
|
124
|
-
* script's output.
|
|
125
|
-
*
|
|
126
|
-
* A fence keeps every byte visible, including trailing blank lines. The fence is
|
|
127
|
-
* lengthened past the longest backtick run in the content so it can never be closed
|
|
128
|
-
* early by the content itself. Nothing inside is escaped or reinterpreted.
|
|
129
|
-
*/
|
|
70
|
+
/** Render one captured stream as a fence that the content cannot close early. */
|
|
130
71
|
export declare function renderCapturedStream(text: string): readonly string[];
|
|
131
72
|
/** Render one outcome for the model. */
|
|
132
73
|
export declare function renderScriptOutcome(outcome: ScriptOutcome): string;
|
|
133
|
-
/** The model-facing JSON Schema for `parameters`. */
|
|
134
74
|
export declare function buildScriptParameters(): Record<string, unknown>;
|
|
135
|
-
/**
|
|
136
|
-
* The declared shape of one outcome, exported so tests can validate real results.
|
|
137
|
-
*
|
|
138
|
-
* Split by `kind` instead of one flat object. The flat form could only require
|
|
139
|
-
* `kind` and `id`, so a foreground result that omitted `exitCode` was still
|
|
140
|
-
* "valid" and the schema proved nothing about the fields the model reads.
|
|
141
|
-
*
|
|
142
|
-
* `signal` is nullable because `child_process` reports `null` whenever the child
|
|
143
|
-
* exited on its own — that is every successful run. Declaring it `string` made
|
|
144
|
-
* the registry reject the tool's own normal output: `createSuccessResult()`
|
|
145
|
-
* validates before rendering, so **every** clean exit surfaced to the model as
|
|
146
|
-
* `tool "pstack_script" returned invalid output`.
|
|
147
|
-
*/
|
|
148
75
|
export declare const OUTPUT_SCHEMA: JsonSchemaNode;
|
|
149
76
|
/** The slices of the Cordis context this tool needs. */
|
|
150
77
|
export interface PstackScriptHost {
|
|
151
78
|
readonly tools: ToolsHost;
|
|
152
|
-
/** Resolves the Session's current directory; see `WorkingDirectoryHost`. */
|
|
153
79
|
readonly workingDirectory: WorkingDirectoryHost;
|
|
154
|
-
/**
|
|
155
|
-
* Optional, and read per call rather than snapshotted.
|
|
156
|
-
*
|
|
157
|
-
* A profile may mount a job controller after this row, so a value read once in
|
|
158
|
-
* `apply` would stay `undefined` forever. `ctx.get("jobs")` is rc.3's
|
|
159
|
-
* optional-service read: it returns `undefined` instead of throwing when the
|
|
160
|
-
* service is absent, which is why `jobs` is not declared in `inject`.
|
|
161
|
-
*/
|
|
162
80
|
readonly getJobs?: () => JobsHost | undefined;
|
|
163
81
|
}
|
|
164
82
|
/** Build the tool for one row. */
|
|
165
83
|
export declare function createPstackScriptTool(host: PstackScriptHost): ToolDefinition;
|
|
166
84
|
/** Cordis row name, used by Loader diagnostics. */
|
|
167
85
|
export declare const name = "pstack-script";
|
|
168
|
-
/**
|
|
169
|
-
* The hard dependencies.
|
|
170
|
-
*
|
|
171
|
-
* `tools` is the registry this row registers into; `workingDirectory` is what
|
|
172
|
-
* turns the tool's `cwd` argument and its omitted case into the Session's
|
|
173
|
-
* directory. Both are always present in a profile that has an Agent at all.
|
|
174
|
-
*
|
|
175
|
-
* `jobs` is deliberately absent: a composition without a job controller still
|
|
176
|
-
* registers the tool, and only `background: true` is refused. Declaring `jobs`
|
|
177
|
-
* here would keep the whole fiber inactive in every profile that has no job
|
|
178
|
-
* controller, which is most of them.
|
|
179
|
-
*/
|
|
86
|
+
/** Hard dependencies: the tool registry and the session directory. `jobs` is optional and read per call. */
|
|
180
87
|
export declare const inject: string[];
|
|
181
|
-
/**
|
|
182
|
-
* Register `pstack_script` for this row.
|
|
183
|
-
*
|
|
184
|
-
* `inject` is what makes `ctx.tools` readable at all: without it Cordis runs
|
|
185
|
-
* `apply` immediately and the service proxy throws
|
|
186
|
-
* `cannot get property "tools" without inject`, so the row would register nothing
|
|
187
|
-
* in any profile.
|
|
188
|
-
*/
|
|
88
|
+
/** Register `pstack_script` for this row. */
|
|
189
89
|
export declare function apply(ctx: PstackScriptHost & {
|
|
190
90
|
get?: (name: string) => JobsHost | undefined;
|
|
191
|
-
}): void;
|
|
192
|
-
//#endregion
|
|
193
|
-
//# sourceMappingURL=script.d.mts.map
|
|
91
|
+
}): void;
|