From ae648db38a3ed3d4c8dec8b296b0d88cf81c77c3 Mon Sep 17 00:00:00 2001 From: krumm2012 <2154703+krumm2012@users.noreply.github.com> Date: Wed, 25 Nov 2026 16:39:11 +0800 Subject: [PATCH 1/4] feat(pstack): backport Cursor workflows and register GPT-6.2 --- .../verify-open-pstack/features/registry.json | 2 +- NOTICE.md | 2 + README.md | 1 + UPSTREAM.md | 10 ++++ docs/reference.md | 3 +- .../poteto-mode/references/model-catalog.md | 22 +++---- .../scripts/runner/registry.test.ts | 10 ++-- .../scripts/runner/registry/models.ts | 20 ++++--- plugins/pstack/skills/reframe/SKILL.md | 16 +++++ plugins/pstack/skills/sharpen/SKILL.md | 2 +- plugins/pstack/skills/statechart/SKILL.md | 2 +- .../statechart/scripts/frontends/dot.ts | 5 +- .../skills/statechart/scripts/janitor.ts | 13 ++++ .../pstack/skills/statechart/scripts/kill.ts | 15 +++++ .../pstack/skills/statechart/scripts/run.ts | 59 ++++++++++++------- .../skills/statechart/scripts/statechart.ts | 27 +++++---- 16 files changed, 149 insertions(+), 60 deletions(-) create mode 100644 plugins/pstack/skills/reframe/SKILL.md create mode 100644 plugins/pstack/skills/statechart/scripts/janitor.ts create mode 100644 plugins/pstack/skills/statechart/scripts/kill.ts diff --git a/.claude/skills/verify-open-pstack/features/registry.json b/.claude/skills/verify-open-pstack/features/registry.json index 4e13683e..317adb70 100644 --- a/.claude/skills/verify-open-pstack/features/registry.json +++ b/.claude/skills/verify-open-pstack/features/registry.json @@ -15,7 +15,7 @@ "principle-redesign-from-first-principles", "principle-separate-before-serializing-shared-state", "principle-sequence-verifiable-units", "principle-subtract-before-you-add", "principle-test-behavior-not-implementation", "principle-type-system-discipline", - "recall", "reflect", "setup-pstack", "sharpen", "show-me-your-work", "statechart", "swarm", "tdd", "teach", + "recall", "reflect", "reframe", "setup-pstack", "sharpen", "show-me-your-work", "statechart", "swarm", "tdd", "teach", "technical-writing", "thermo-nuclear-code-quality-review", "typescript-best-practices", "unslop", "what-did-i-get-done", "why" ], diff --git a/NOTICE.md b/NOTICE.md index c6f7b90f..65599911 100644 --- a/NOTICE.md +++ b/NOTICE.md @@ -26,6 +26,8 @@ This plugin is a port of upstream MIT-licensed work. All upstream copyright noti | `plugins/pstack/skills/` (0.15.21 to 0.15.25 changes: the `in-your-own-words` and `sharpen` skills, per-spawn effort in poteto-mode and the routed skills, one full swarm per PR in the autopilots and the multi-phase plan, the Graphite-free `orch` frontier, the `watch-pr` owner-approval gate, Origin PRs in `worktree-audit.sh`, `ketchup` visuals and length, restated principles, and prompt cuts), `plugins/pstack/agents/poteto-agent.md`, `README-UPSTREAM.md` | [cursor/plugins/pstack @ 99743e9](https://github.com/cursor/plugins/tree/99743e9c151c8537cbbf1f98bb38f34ef3368453/pstack) | (c) 2026 Lauren Tan | MIT | [LICENSE](LICENSE) | | `plugins/pstack/skills/` (0.15.26 to 0.15.29 changes: the `create-formal-verification-skill` and `maintain-formal-verification-skill` skills, setup's verification offers, `poteto-help` routing and recipes, the `sharpen` rewrite, `ketchup` waiting items, and the `typescript-best-practices` brand guard), `README-UPSTREAM.md` | [cursor/plugins/pstack @ 88d4751](https://github.com/cursor/plugins/tree/88d47514b82e7c44f00f2b2a72ff6dd12158038c/pstack) | (c) 2026 Lauren Tan | MIT | [LICENSE](LICENSE) | | `plugins/pstack/skills/` (0.15.30 to 0.15.36 changes: the `statechart` and `ketchup-video` skills, run-based `interrogate` adversaries, the agentic Orchestrate playbook, Autopilot-stack without the merge, the different-provider arena judge, reflect copies outside the plugin cache, goal restatement, explain the number before measuring, and `watch-pr`, `check-plan` and `worktree-audit.sh` fixes), `README-UPSTREAM.md` | [cursor/plugins/pstack @ 2776ddd](https://github.com/cursor/plugins/tree/2776ddd2355d6d6c8747d3964600f28daf62f049/pstack) | (c) 2026 Lauren Tan | MIT | [LICENSE](LICENSE) | +| `plugins/pstack/skills/reframe/SKILL.md` and `plugins/pstack/skills/sharpen/SKILL.md` (selected from pstack 0.15.48) | [cursor/plugins/pstack @ 9e278fe](https://github.com/cursor/plugins/tree/9e278fe4d4ecd8bfe98b1b79bf4be662efb338cc/pstack) | (c) 2026 Lauren Tan | MIT | [LICENSE](LICENSE) | +| `plugins/pstack/skills/statechart/` (Windows process handling and CRLF parsing) | [cursor/plugins/pstack @ 0b46ec3](https://github.com/cursor/plugins/tree/0b46ec399d55f2829e88822998f53b84944837d3/pstack/skills/statechart) | (c) 2026 Lauren Tan | MIT | [LICENSE](LICENSE) | ## What changed in the port diff --git a/README.md b/README.md index ac51439c..f8bd6b8b 100644 --- a/README.md +++ b/README.md @@ -137,6 +137,7 @@ That is the main workflow. The other skills are there when poteto-mode needs the | `poteto-help` | You want to know which skill, playbook, or principle fits a question. | | `in-your-own-words` | You want the agent to restate your goal and the problem before it starts. | | `sharpen` | You want a prompt rewritten deeper, not bigger, before you send it. It returns the rewritten prompt and does not do the task. | +| `reframe` | You want to clarify what you're building and rewrite the description with verified terms from your field and related fields. | Plugin skills include `pstack:` in their name. In Claude Code, invoke a native skill such as `/pstack:architect`. In Codex, ask for the skill, such as `Use pstack:architect for this design.` See the [technical reference](docs/reference.md) for the full list. diff --git a/UPSTREAM.md b/UPSTREAM.md index 452a93e1..2101ebf0 100644 --- a/UPSTREAM.md +++ b/UPSTREAM.md @@ -14,6 +14,16 @@ open-pstack tracks [Cursor's pstack](https://github.com/cursor/plugins/tree/main The table above is the current Cursor sync point. Open Pstack 1.17.0 imported this 0.15.36 sync, and 1.18.0 to 1.21.0 keep it. `README-UPSTREAM.md` preserves the upstream pstack README verbatim. `CHANGES.md` and `NOTICE.md` describe the adaptations and provenance. +## Selected backports after the sync point + +| Cursor source | Ported behavior | +| --- | --- | +| [#1324](https://github.com/cursor/plugins/pull/1324), [#1326](https://github.com/cursor/plugins/pull/1326) | Add the explicit `/reframe` skill with source checks and two or three interpretations of ambiguous requests. | +| [#1236](https://github.com/cursor/plugins/pull/1236) | Ask `/sharpen` to propose an experiment for choices an experiment can settle. | +| [#1292](https://github.com/cursor/plugins/pull/1292) | Port the `/statechart` Windows process handling, CRLF parsing, and the earlier SANY error reporting needed by those paths. Keep the port's strict exit code type. | + +The cross-harness skill routing and the full-tree sync point remain at the recorded baseline. Cursor's shared worker and model-default rewrite is outside this backport. + ## Upstream-only exclusions - Commits `799151d` and `6fecddb` add and relocate `make-bot-ui`, and `a968159` renames it after its folder. It depends on Cursor routines, webhook events, and UI primitives that Claude Code and Codex do not share. `a968159`'s other hunk names `poteto-mode` after its folder, which the port's `poteto-mode/SKILL.md` already does. diff --git a/docs/reference.md b/docs/reference.md index a6af5699..11698de8 100644 --- a/docs/reference.md +++ b/docs/reference.md @@ -175,7 +175,8 @@ The table uses the short upstream names. Claude Code exposes each native skill w | `/ketchup-video` | the `/ketchup` catch-up as a short subtitled video of slides (typed only) | | `/poteto-help` | find the skill, playbook, or principle for a question about pstack (typed only) | | `/in-your-own-words` | play back your goal and the problem before work starts (typed only) | -| `/sharpen` | rewrite a prompt deeper, not bigger, before you send it; returns the rewritten prompt and does not do the task (typed only) | +| `/sharpen` | rewrite a prompt with better evidence and propose experiments for choices they can settle (typed only) | +| `/reframe` | identify the terms for your problem, check examples, and rewrite the original request. For ambiguous requests, compare two or three interpretations (typed only) | ## Subagents diff --git a/plugins/pstack/skills/poteto-mode/references/model-catalog.md b/plugins/pstack/skills/poteto-mode/references/model-catalog.md index 5857bcaf..db8ea97d 100644 --- a/plugins/pstack/skills/poteto-mode/references/model-catalog.md +++ b/plugins/pstack/skills/poteto-mode/references/model-catalog.md @@ -9,11 +9,11 @@ Model and provider facts for [`provider-dispatch.md`](provider-dispatch.md), whi | Family | Label | Provider | Model | Default effort | Selectable efforts | Claude-native agents | Status | Upstream pstack choice | | --- | --- | --- | --- | --- | --- | --- | --- | --- | | fable | Fable | claude | fable | max | low medium high xhigh max | `pstack-fable-` | optional | - | -| sol | GPT-6.1 Sol | codex | gpt-6.1-sol | max | low medium high xhigh max ultra | - | default | gpt-5.6-sol-max | +| sol | GPT-6.2 Sol | codex | gpt-6.2-sol | max | low medium high xhigh max ultra | - | default | gpt-5.6-sol-max | | grok | Grok 4.7 | grok | grok-4.7 | xhigh | low medium high xhigh max | - | default | grok-4.7-xhigh-fast | | opus | Opus | claude | opus | max | low medium high xhigh max | `pstack-opus-` | default | opus | | luna | GPT-6 Luna | codex | gpt-6-luna | max | low medium high xhigh max | - | optional | - | -| astra | GPT-6 Astra | codex | gpt-6-astra | max | low medium high xhigh max ultra | - | optional | - | +| astra | GPT-6.2 Astra | codex | gpt-6.2-astra | max | low medium high xhigh max ultra | - | optional | - | | sonnet | Sonnet | claude | sonnet | max | low medium high xhigh max | `pstack-sonnet-` | optional | - | | opus-5-5 | Opus 5.5 | claude | claude-opus-5-5 | max | low medium high xhigh max | `pstack-opus-5-5-` | optional | claude-opus-5-5-xhigh | | haiku-5-5 | Haiku 5.5 | claude | claude-haiku-5-5 | max | low medium high xhigh max | `pstack-haiku-5-5-` | optional | - | @@ -50,8 +50,10 @@ Effort in the model ID: for these families the effort selects the CLI model, and | Provider | Kept model | Family | Current model | Selectable efforts | | --- | --- | --- | --- | --- | -| codex | gpt-5.6-sol | sol | gpt-6.1-sol | low medium high xhigh max ultra | +| codex | gpt-5.6-sol | sol | gpt-6.2-sol | low medium high xhigh max ultra | +| codex | gpt-6.1-sol | sol | gpt-6.2-sol | low medium high xhigh max ultra | | grok | grok-4.6 | grok | grok-4.7 | low medium high xhigh max | +| codex | gpt-6-astra | astra | gpt-6.2-astra | low medium high xhigh max ultra | Rolling aliases: @@ -244,18 +246,18 @@ The complete first-run sheet. A sheet that lacks a role uses that role's line he Provider-qualified per-role choices. Read the installed pstack provider-dispatch reference before dispatching a configured role. Every documented role remains present. `inherit-parent` and `auto` use the parent model natively and still count as one panel lane. feature, refactoring: grok:grok-4.7@xhigh -bug-fix: codex:gpt-6.1-sol@max -perf-issue: codex:gpt-6.1-sol@max -hillclimb: codex:gpt-6.1-sol@max +bug-fix: codex:gpt-6.2-sol@max +perf-issue: codex:gpt-6.2-sol@max +hillclimb: codex:gpt-6.2-sol@max judgment and prose: claude:opus@max hardest tasks: claude:opus@max how explorer: grok:grok-4.7@xhigh how explainer: claude:opus@max why investigators, synthesizer: inherit-parent reflect tooling, judgment, divergent, synthesizer: inherit-parent -arena runners: claude:opus@max, codex:gpt-6.1-sol@max, grok:grok-4.7@xhigh -arena cross-judge pool: claude:opus@max, codex:gpt-6.1-sol@max, grok:grok-4.7@xhigh +arena runners: claude:opus@max, codex:gpt-6.2-sol@max, grok:grok-4.7@xhigh +arena cross-judge pool: claude:opus@max, codex:gpt-6.2-sol@max, grok:grok-4.7@xhigh swarm workers: grok:grok-4.7@xhigh -architect runners: claude:opus@max, codex:gpt-6.1-sol@max, grok:grok-4.7@xhigh -interrogate reviewers: claude:opus@max, codex:gpt-6.1-sol@max, grok:grok-4.7@xhigh +architect runners: claude:opus@max, codex:gpt-6.2-sol@max, grok:grok-4.7@xhigh +interrogate reviewers: claude:opus@max, codex:gpt-6.2-sol@max, grok:grok-4.7@xhigh ``` diff --git a/plugins/pstack/skills/poteto-mode/scripts/runner/registry.test.ts b/plugins/pstack/skills/poteto-mode/scripts/runner/registry.test.ts index 857b3072..347eb01c 100644 --- a/plugins/pstack/skills/poteto-mode/scripts/runner/registry.test.ts +++ b/plugins/pstack/skills/poteto-mode/scripts/runner/registry.test.ts @@ -113,7 +113,7 @@ describe("registry data", () => { .map((entry) => [entry.name, entry.rolling!.revisionPrefix])) .toEqual([["fable", "claude-fable-"], ["opus", "claude-opus-"], ["sonnet", "claude-sonnet-"]]); expect(REGISTRY.families.filter((entry) => entry.provider === "codex").map((entry) => [entry.name, entry.model])) - .toEqual([["sol", "gpt-6.1-sol"], ["luna", "gpt-6-luna"], ["astra", "gpt-6-astra"]]); + .toEqual([["sol", "gpt-6.2-sol"], ["luna", "gpt-6-luna"], ["astra", "gpt-6.2-astra"]]); expect(REGISTRY.families.filter((entry) => effortsOf(entry).includes("ultra")).map((entry) => entry.name)).toEqual(["sol", "astra"]); }); @@ -495,12 +495,12 @@ describe("resolveLane", () => { .toThrow("effort ultra is not offered for claude:sonnet"); }); - it("resolves Astra at max by default and passes ultra to Codex", () => { - const astra = resolveLane(request({ parent: "claude", provider: "codex", model: "gpt-6-astra" })); + it("resolves GPT-6.2 Astra at max by default and passes ultra to Codex", () => { + const astra = resolveLane(request({ parent: "claude", provider: "codex", model: "gpt-6.2-astra" })); expect([astra.family?.name, astra.effort]).toEqual(["astra", "max"]); - const ultra = resolveLane(request({ parent: "claude", provider: "codex", model: "gpt-6-astra", effort: "ultra" })); + const ultra = resolveLane(request({ parent: "claude", provider: "codex", model: "gpt-6.2-astra", effort: "ultra" })); expect(ultra.adapter.launch.argv(ultra, { sharedGitDir: null, providerSidecar: null })) - .toEqual(expect.arrayContaining(["gpt-6-astra", 'model_reasoning_effort="ultra"'])); + .toEqual(expect.arrayContaining(["gpt-6.2-astra", 'model_reasoning_effort="ultra"'])); }); it("maps each Devin effort to its CLI model ID and keeps the descriptor's model for the receipt", () => { diff --git a/plugins/pstack/skills/poteto-mode/scripts/runner/registry/models.ts b/plugins/pstack/skills/poteto-mode/scripts/runner/registry/models.ts index 7550be7c..2b60b0ff 100644 --- a/plugins/pstack/skills/poteto-mode/scripts/runner/registry/models.ts +++ b/plugins/pstack/skills/poteto-mode/scripts/runner/registry/models.ts @@ -16,13 +16,16 @@ export const FAMILIES = [ }), family({ name: "sol", - label: "GPT-6.1 Sol", + label: "GPT-6.2 Sol", provider: "codex", - model: "gpt-6.1-sol", - efforts: UP_TO_ULTRA, // `codex debug models`, Codex CLI 0.159.0 + model: "gpt-6.2-sol", + efforts: UP_TO_ULTRA, defaultEffort: "max", upstream: "gpt-5.6-sol-max", - predecessors: [{ model: "gpt-5.6-sol", efforts: UP_TO_ULTRA }], + predecessors: [ + { model: "gpt-5.6-sol", efforts: UP_TO_ULTRA }, + { model: "gpt-6.1-sol", efforts: UP_TO_ULTRA }, + ], }), family({ name: "grok", @@ -55,12 +58,13 @@ export const FAMILIES = [ }), family({ name: "astra", - label: "GPT-6 Astra", + label: "GPT-6.2 Astra", provider: "codex", - model: "gpt-6-astra", - efforts: UP_TO_ULTRA, // `codex debug models`, Codex CLI 0.164.0 + model: "gpt-6.2-astra", + efforts: UP_TO_ULTRA, defaultEffort: "max", upstream: null, + predecessors: [{ model: "gpt-6-astra", efforts: UP_TO_ULTRA }], }), family({ name: "sonnet", @@ -219,4 +223,6 @@ export const RELEASED_PAIRS = [ { pair: "cursor:gemini-3.7-flash", family: "gemini-3.7-flash" }, { pair: "claude:claude-haiku-5-5", family: "haiku-5-5" }, { pair: "codex:gpt-6-astra", family: "astra" }, + { pair: "codex:gpt-6.2-sol", family: "sol" }, + { pair: "codex:gpt-6.2-astra", family: "astra" }, ] as const satisfies readonly ReleasedPair[]; diff --git a/plugins/pstack/skills/reframe/SKILL.md b/plugins/pstack/skills/reframe/SKILL.md new file mode 100644 index 00000000..57a21985 --- /dev/null +++ b/plugins/pstack/skills/reframe/SKILL.md @@ -0,0 +1,16 @@ +--- +name: reframe +description: "Teach the expert words for what the operator is building, borrow words from neighboring fields that solved the same problem, then rewrite their description with them. Use for /reframe." +disable-model-invocation: true +--- + +Teach the operator the expert words for what they are building. Start from their own files, code and description, not a summary. + +If their description could name more than one problem, first list the two or three problems it could be, each with the one term that names it and the sign that would tell it apart from the others. Then teach the words for the most likely one and say why you picked it. + +1. Give 8 to 12 terms, ranked by how much each would change what gets built. For each, give the word and its meaning in one plain sentence, the part of their description it names, one real project, paper or system that uses it that way, with a link, and what it lets them ask an agent for. +2. Pick 2 or 3 neighboring fields that solved the same shape of problem under other names. For each, say what carries over, where the analogy breaks, and which terms come back. +3. Name what they didn't mention but should care about. +4. Rewrite their description with the new words. + +Open every link and confirm it uses the term that way. Cut any citation you can't confirm. No padding. diff --git a/plugins/pstack/skills/sharpen/SKILL.md b/plugins/pstack/skills/sharpen/SKILL.md index 5b4a7b10..2a03402b 100644 --- a/plugins/pstack/skills/sharpen/SKILL.md +++ b/plugins/pstack/skills/sharpen/SKILL.md @@ -13,4 +13,4 @@ I want a deeper version of this task, not a bigger one. Before rewriting it, do Then rewrite my prompt to ask for exactly that. -Leave choices that are mine to make open instead of deciding them. +Have the rewritten prompt ask the agent to prototype any choice an experiment can settle and recommend an option based on what it observed. Leave product or preference choices that no experiment can settle for me to make. diff --git a/plugins/pstack/skills/statechart/SKILL.md b/plugins/pstack/skills/statechart/SKILL.md index f5a64a8d..18d653a8 100644 --- a/plugins/pstack/skills/statechart/SKILL.md +++ b/plugins/pstack/skills/statechart/SKILL.md @@ -16,7 +16,7 @@ Work in a scratch folder outside the repo. Write a TLA+ spec and its config. The /scripts/statechart SPEC.tla [--config FILE] [--view FILE] [--out DIR] ``` -`scripts/statechart.ts` is TypeScript, so run it with a runtime that can execute TypeScript. +`scripts/statechart.ts` is TypeScript, so run it with a runtime that can execute TypeScript. `scripts/statechart` is a POSIX shell script that picks one. On native Windows, run `node --disable-warning=ExperimentalWarning /scripts/statechart.ts` with Node 22.18 to 22.x, or Node 23.6 or later. The first run installs TLC and Java with mise and needs the network. diff --git a/plugins/pstack/skills/statechart/scripts/frontends/dot.ts b/plugins/pstack/skills/statechart/scripts/frontends/dot.ts index 003dfc89..09d5481e 100644 --- a/plugins/pstack/skills/statechart/scripts/frontends/dot.ts +++ b/plugins/pstack/skills/statechart/scripts/frontends/dot.ts @@ -35,7 +35,10 @@ export const parseState = (label: string, parsed = new Map; -export const linesOf = (input: Lines) => (typeof input === "string" ? input.split("\n") : input); +export const splitLines = (text: string) => + (text.endsWith("\r") ? text.slice(0, -1) : text).split(/\r?\n/); + +export const linesOf = (input: Lines) => (typeof input === "string" ? splitLines(input) : input); export function parseDot(input: Lines): Graph { const states = new Map(); diff --git a/plugins/pstack/skills/statechart/scripts/janitor.ts b/plugins/pstack/skills/statechart/scripts/janitor.ts new file mode 100644 index 00000000..5e69fb31 --- /dev/null +++ b/plugins/pstack/skills/statechart/scripts/janitor.ts @@ -0,0 +1,13 @@ +import fs from "node:fs"; +import { finished } from "node:stream/promises"; +import { killGroup } from "./kill.ts"; + +const [pid, ...dirs] = process.argv.slice(2); + +let input = ""; +process.stdin.setEncoding("utf8").on("data", (chunk: string) => (input += chunk)); +await finished(process.stdin).catch(() => {}); +const running = !input.includes("exited"); +const groupOutlivesWorker = process.platform !== "win32"; +if (running || groupOutlivesWorker) await killGroup(Number(pid)); +for (const dir of dirs) fs.rmSync(dir, { recursive: true, force: true }); diff --git a/plugins/pstack/skills/statechart/scripts/kill.ts b/plugins/pstack/skills/statechart/scripts/kill.ts new file mode 100644 index 00000000..014d7c35 --- /dev/null +++ b/plugins/pstack/skills/statechart/scripts/kill.ts @@ -0,0 +1,15 @@ +import { spawn } from "node:child_process"; + +export const killGroup = (pid: number) => + new Promise((resolve) => { + if (process.platform === "win32") { + spawn("taskkill", ["/pid", String(pid), "/t", "/f"], { stdio: "ignore" }) + .on("error", () => resolve()) + .on("exit", () => resolve()); + return; + } + try { + process.kill(-pid, "SIGKILL"); + } catch {} + resolve(); + }); diff --git a/plugins/pstack/skills/statechart/scripts/run.ts b/plugins/pstack/skills/statechart/scripts/run.ts index d23a88c2..c0bdaf7d 100644 --- a/plugins/pstack/skills/statechart/scripts/run.ts +++ b/plugins/pstack/skills/statechart/scripts/run.ts @@ -8,7 +8,7 @@ import { inspect } from "node:util"; import { boundRun, chartRun, configText } from "./backends/cfg.ts"; import { plainText } from "./backends/plain-text.ts"; import { readConfig } from "./frontends/config.ts"; -import { parseDot } from "./frontends/dot.ts"; +import { parseDot, splitLines } from "./frontends/dot.ts"; import { readCounterexample, readMarks } from "./frontends/marks.ts"; import { readMessages } from "./frontends/messages.ts"; import { initialOnlyProperties, readChecks, readSany, readSpec } from "./frontends/spec.ts"; @@ -55,10 +55,10 @@ export function* fileLines(file: string) { kept = end; continue; } - yield* buf.toString("utf8", 0, cut).split("\n"); + yield* splitLines(buf.toString("utf8", 0, cut)); kept = buf.copy(buf, 0, cut + 1, end); } - yield buf.toString("utf8", 0, kept); + yield* splitLines(buf.toString("utf8", 0, kept)); } finally { fs.closeSync(fd); } @@ -68,6 +68,7 @@ const TLC_TOOL = "http:tla2tools[url=https://github.com/tlaplus/tlaplus/releases/download/v1.7.4/tla2tools.jar,checksum=sha256:936a262061c914694dfd669a543be24573c45d5aa0ff20a8b96b23d01e050e88]@1.7.4"; const JAVA_TOOL = "java@temurin-25"; export const PINNED_FLAGS = ["-workers", "1", "-fp", "0", "-lncheck", "final"]; +const SANY_ERRORS = /^\*\*\* ?(?:Errors|Abort messages|Parse Error)/m; type ChildResult = { status: number | null; @@ -81,7 +82,7 @@ const runChild = (file: string, args: string[], options: { cwd: string; env: Nod execFile( file, args, - { encoding: "utf8", maxBuffer: 1 << 30, ...options }, + { encoding: "utf8", maxBuffer: 1 << 30, windowsHide: true, ...options }, (error, stdout, stderr) => resolve({ status: error ? (typeof error.code === "number" ? error.code : null) : 0, @@ -92,14 +93,6 @@ const runChild = (file: string, args: string[], options: { cwd: string; env: Nod ); }); -export const killGroup = (pid: number) => - new Promise((resolve) => - spawn("/bin/sh", ["-c", 'kill -s KILL -- "-$1"', "sh", String(pid)], { stdio: "ignore" }).on( - "exit", - resolve, - ), - ); - export const messageOf = (error: unknown) => typeof error === "object" && error !== null && @@ -141,10 +134,10 @@ function* outputLines(output: Output) { rest = buf; continue; } - yield* utf8.decode(buf.subarray(0, cut)).split("\n"); + yield* splitLines(utf8.decode(buf.subarray(0, cut))); rest = buf.subarray(cut + 1); } - yield utf8.decode(rest); + yield* splitLines(utf8.decode(rest)); } const messagesOf = (output: Output): Iterable => ({ @@ -169,7 +162,7 @@ const runToFiles = ( for (const f of files) fds.push(fs.openSync(f, "w")); let child: ChildProcess; try { - child = spawn(file, args, { ...options, stdio: ["ignore", ...fds] }); + child = spawn(file, args, { ...options, stdio: ["ignore", ...fds], windowsHide: true }); } finally { for (const fd of fds) fs.closeSync(fd); } @@ -227,6 +220,12 @@ const tail = (r: FileResult) => { return kept.join("").trim().split("\n").slice(-30).join("\n"); }; +const firstLines = (text: string) => { + const lines = text.trim().split("\n"); + if (lines.length > 40) lines.splice(40, Infinity, `... ${lines.length - 40} more lines`); + return lines.join("\n"); +}; + const stopOf = (r: FileResult): Stop => { const errors: Part[] = []; for (const m of r.error ? [] : messagesOf(r.output)) @@ -238,9 +237,14 @@ const stopOf = (r: FileResult): Stop => { ) errors.push(m); if (!errors.length) return { status: r.status, message: tail(r) }; - const lines = [...plainText(errors)].join("").trim().split("\n"); - if (lines.length > 40) lines.splice(40, Infinity, `... ${lines.length - 40} more lines`); - return { status: r.status, message: lines.join("\n") }; + return { status: r.status, message: firstLines([...plainText(errors)].join("")) }; +}; + +const sanyErrors = (r: FileResult) => { + if (r.error) return undefined; + const text = [...plainText(messagesOf(r.output))].join(""); + const at = text.search(SANY_ERRORS); + return at === -1 ? undefined : firstLines(text.slice(at)); }; const names = (rules: Rule[], kind: Rule["kind"]) => { @@ -286,6 +290,8 @@ export async function check(specFile: string, configFile: string): Promise {}); const exited = new Promise((resolve) => - worker.on("exit", (code) => resolve(code ?? 2)), + worker.on("exit", (code) => { + toJanitor?.write("exited\n"); + resolve(code ?? 2); + }), ); await Promise.race([stopped, exited]); - await killGroup(worker.pid as number); + const running = worker.exitCode === null && worker.signalCode === null; + const groupOutlivesWorker = process.platform !== "win32"; + if (worker.pid !== undefined && (running || groupOutlivesWorker)) await killGroup(worker.pid); const verdict = await exited; if (stop) { console.error(`${stop} stopped the check, so the command wrote nothing.`); From 7d6c9c1fd996e148d84e26089abd5afce69c34b2 Mon Sep 17 00:00:00 2001 From: krumm2012 <2154703+krumm2012@users.noreply.github.com> Date: Wed, 25 Nov 2026 17:15:07 +0800 Subject: [PATCH 2/4] chore(pstack): bump backport package to 1.21.1 --- .claude-plugin/marketplace.json | 2 +- CHANGES.md | 8 ++++++++ README.md | 2 +- UPSTREAM.md | 4 ++-- docs/reference.md | 2 +- plugins/pstack/.claude-plugin/plugin.json | 2 +- plugins/pstack/.codex-plugin/plugin.json | 2 +- plugins/pstack/.grok-plugin/plugin.json | 2 +- 8 files changed, 16 insertions(+), 8 deletions(-) diff --git a/.claude-plugin/marketplace.json b/.claude-plugin/marketplace.json index f526c3fb..c552e790 100644 --- a/.claude-plugin/marketplace.json +++ b/.claude-plugin/marketplace.json @@ -9,7 +9,7 @@ "name": "pstack", "source": "./plugins/pstack", "description": "if you want to go fast, go deep first. pstack helps you write less, but higher quality code. rigorous agent workflows you can parallelize with confidence.", - "version": "1.21.0", + "version": "1.21.1", "author": { "name": "Lauren Tan (original)" }, diff --git a/CHANGES.md b/CHANGES.md index 4fb27e08..f91d7da8 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -3,6 +3,14 @@ Open Pstack lands on green: Mergify merges a ready PR to main once verify and exact-head live-gate pass and no review thread is unresolved, and a workflow resolves Unfret's own threads. A PR that touches `.github/` or the Mergify config also waits for Unfret, and workflow changes require operator queueing. This port applies the Cursor → Claude Code substitutions in skill bodies. Earlier drafts left them flagged; this revision resolves them. A later pass added a Codex build that shares the same skills; see [Codex port](#codex-port) below. +## 1.21.1 adds selected Cursor backports + +- `/reframe` compares plausible interpretations of ambiguous requests, identifies observable signals, and rewrites the request using verified terminology. +- `/sharpen` asks for experiments to resolve choices that can be tested. `/statechart` handles Windows process cleanup and CRLF in TLC output. +- The model catalog registers GPT‑6.2 Sol and Astra and retains the previous model IDs for compatibility. + +See [UPSTREAM.md](UPSTREAM.md#selected-backports-after-the-sync-point) for the source commits. + ## 1.21.0 adds Grok as a parent harness Open Pstack 1.21.0 keeps the Cursor pstack 0.15.36 sync. Default roles and panels are unchanged. diff --git a/README.md b/README.md index f8bd6b8b..1b906b26 100644 --- a/README.md +++ b/README.md @@ -174,7 +174,7 @@ This repository also keeps: ## Staying close to Lauren's pstack -Open Pstack 1.21.0 tracks pstack 0.15.36 at Cursor commit [`2776ddd2355d6d6c8747d3964600f28daf62f049`](https://github.com/cursor/plugins/commit/2776ddd2355d6d6c8747d3964600f28daf62f049). +Open Pstack 1.21.1 keeps the pstack 0.15.36 sync at Cursor commit [`2776ddd2355d6d6c8747d3964600f28daf62f049`](https://github.com/cursor/plugins/commit/2776ddd2355d6d6c8747d3964600f28daf62f049) and includes the [selected backports documented in UPSTREAM.md](UPSTREAM.md#selected-backports-after-the-sync-point). The two projects have separate version numbers. The pstack version identifies Lauren's upstream content. The Open Pstack version identifies the Claude Code and Codex package built from it. diff --git a/UPSTREAM.md b/UPSTREAM.md index 2101ebf0..3fe230a1 100644 --- a/UPSTREAM.md +++ b/UPSTREAM.md @@ -10,9 +10,9 @@ open-pstack tracks [Cursor's pstack](https://github.com/cursor/plugins/tree/main | Path | `pstack/` | | Commit | `2776ddd2355d6d6c8747d3964600f28daf62f049` | | Upstream version | `0.15.36` | -| open-pstack version | `1.21.0` | +| open-pstack version | `1.21.1` | -The table above is the current Cursor sync point. Open Pstack 1.17.0 imported this 0.15.36 sync, and 1.18.0 to 1.21.0 keep it. `README-UPSTREAM.md` preserves the upstream pstack README verbatim. `CHANGES.md` and `NOTICE.md` describe the adaptations and provenance. +The table above is the current Cursor sync point. Open Pstack 1.17.0 imported this 0.15.36 sync, and 1.18.0 to 1.21.1 keep it. `README-UPSTREAM.md` preserves the upstream pstack README verbatim. `CHANGES.md` and `NOTICE.md` describe the adaptations and provenance. ## Selected backports after the sync point diff --git a/docs/reference.md b/docs/reference.md index 11698de8..5bf19197 100644 --- a/docs/reference.md +++ b/docs/reference.md @@ -2,7 +2,7 @@ This page contains the full skill, dependency, runtime, and porting reference. For the plain-English introduction and quick start, see the [main README](../README.md). -[Poteto](https://x.com/poteto)'s [pstack](https://github.com/cursor/plugins/tree/main/pstack), adapted to run in Claude Code, Codex, T3 Code and Grok without Cursor. One shared skill tree serves all four harnesses, and in T3 Code the Claude Code or Codex runtime loads it; lanes on other providers' models, including Grok and seven more providers, run through the bundled runner. Version 1.21.0 is synced to Cursor pstack v0.15.36 at `2776ddd2355d6d6c8747d3964600f28daf62f049`. See [UPSTREAM.md](../UPSTREAM.md) for the exact sync contract. +[Poteto](https://x.com/poteto)'s [pstack](https://github.com/cursor/plugins/tree/main/pstack), adapted to run in Claude Code, Codex, T3 Code and Grok without Cursor. One shared skill tree serves all four harnesses. In T3 Code the Claude Code or Codex runtime loads it. External provider lanes run through the bundled runner. Version 1.21.1 keeps Cursor pstack 0.15.36 at `2776ddd2355d6d6c8747d3964600f28daf62f049` as its full sync point. See [UPSTREAM.md](../UPSTREAM.md) for the selected backports. Original by Lauren Tan. This distribution builds on Michael Denyer's [pstack-claude](https://github.com/michael-denyer/pstack-claude) port and retains its history and MIT attribution. It imports seven MIT-licensed skills from [cursor-team-kit](https://github.com/cursor/plugins/tree/main/cursor-team-kit): `deslop`, `thermo-nuclear-code-quality-review`, `make-pr-easy-to-review`, `fix-ci`, `fix-merge-conflicts`, `get-pr-comments`, `what-did-i-get-done`. diff --git a/plugins/pstack/.claude-plugin/plugin.json b/plugins/pstack/.claude-plugin/plugin.json index 0bdf329d..f21556c0 100644 --- a/plugins/pstack/.claude-plugin/plugin.json +++ b/plugins/pstack/.claude-plugin/plugin.json @@ -1,7 +1,7 @@ { "name": "pstack", "displayName": "pstack", - "version": "1.21.0", + "version": "1.21.1", "description": "if you want to go fast, go deep first. pstack helps you write less, but higher quality code. rigorous agent workflows you can parallelize with confidence. Ported from cursor/plugins/pstack for Claude Code and Codex.", "author": { "name": "Lauren Tan" diff --git a/plugins/pstack/.codex-plugin/plugin.json b/plugins/pstack/.codex-plugin/plugin.json index 77972f6e..686a3d73 100644 --- a/plugins/pstack/.codex-plugin/plugin.json +++ b/plugins/pstack/.codex-plugin/plugin.json @@ -1,6 +1,6 @@ { "name": "pstack", - "version": "1.21.0", + "version": "1.21.1", "description": "if you want to go fast, go deep first. pstack helps you write less, but higher quality code. rigorous agent workflows you can parallelize with confidence. Codex port of the Claude Code plugin; skills are shared, tool names resolve via skills/poteto-mode/references/codex-tools.md.", "author": { "name": "Lauren Tan" diff --git a/plugins/pstack/.grok-plugin/plugin.json b/plugins/pstack/.grok-plugin/plugin.json index 917675d0..2978254d 100644 --- a/plugins/pstack/.grok-plugin/plugin.json +++ b/plugins/pstack/.grok-plugin/plugin.json @@ -1,7 +1,7 @@ { "name": "pstack", "displayName": "pstack", - "version": "1.21.0", + "version": "1.21.1", "description": "if you want to go fast, go deep first. pstack helps you write less, but higher quality code. rigorous agent workflows you can parallelize with confidence. Grok build of the Claude Code plugin; skills are shared, tool names resolve via skills/poteto-mode/references/codex-tools.md.", "author": { "name": "Lauren Tan" From 03ed251fbe92bcdbf35111d51739a6d60d2b8d7b Mon Sep 17 00:00:00 2001 From: krumm2012 <2154703+krumm2012@users.noreply.github.com> Date: Mon, 30 Nov 2026 20:34:19 +0800 Subject: [PATCH 3/4] feat(statechart): port Lean 4 proofs from Cursor pstack 0.15.49 --- CHANGES.md | 1 + NOTICE.md | 1 + README-UPSTREAM.md | 18 +- README.md | 2 +- UPSTREAM.md | 5 +- docs/reference.md | 4 +- plugins/pstack/skills/poteto-help/SKILL.md | 2 +- plugins/pstack/skills/statechart/SKILL.md | 96 +- .../skills/statechart/references/render.md | 146 +- .../statechart/scripts/backends/mermaid.ts | 58 +- .../statechart/scripts/lean/Extract.lean | 1466 +++++++++++++++++ .../scripts/lean/backends/lemma-chart.ts | 273 +++ .../scripts/lean/backends/mermaid.ts | 178 ++ .../scripts/lean/backends/proof-chart.ts | 511 ++++++ .../scripts/lean/backends/report.ts | 266 +++ .../scripts/lean/frontends/facts.ts | 276 ++++ .../statechart/scripts/lean/frontends/view.ts | 202 +++ .../skills/statechart/scripts/lean/ir.ts | 533 ++++++ .../scripts/lean/passes/attribute.ts | 167 ++ .../statechart/scripts/lean/passes/blocks.ts | 37 + .../statechart/scripts/lean/passes/budget.ts | 179 ++ .../statechart/scripts/lean/passes/check.ts | 86 + .../scripts/lean/passes/contract.ts | 163 ++ .../statechart/scripts/lean/passes/fold.ts | 227 +++ .../statechart/scripts/lean/passes/inline.ts | 99 ++ .../statechart/scripts/lean/passes/mark.ts | 455 +++++ .../statechart/scripts/lean/passes/reduce.ts | 60 + .../statechart/scripts/lean/passes/trust.ts | 107 ++ .../scripts/lean/passes/view-lemmas.ts | 161 ++ .../statechart/scripts/lean/pipeline.ts | 144 ++ .../skills/statechart/scripts/lean/run.ts | 431 +++++ .../statechart/scripts/lean/toolchain.ts | 72 + .../skills/statechart/scripts/statechart.ts | 130 +- .../skills/statechart/scripts/worker.ts | 59 +- 34 files changed, 6525 insertions(+), 90 deletions(-) create mode 100644 plugins/pstack/skills/statechart/scripts/lean/Extract.lean create mode 100644 plugins/pstack/skills/statechart/scripts/lean/backends/lemma-chart.ts create mode 100644 plugins/pstack/skills/statechart/scripts/lean/backends/mermaid.ts create mode 100644 plugins/pstack/skills/statechart/scripts/lean/backends/proof-chart.ts create mode 100644 plugins/pstack/skills/statechart/scripts/lean/backends/report.ts create mode 100644 plugins/pstack/skills/statechart/scripts/lean/frontends/facts.ts create mode 100644 plugins/pstack/skills/statechart/scripts/lean/frontends/view.ts create mode 100644 plugins/pstack/skills/statechart/scripts/lean/ir.ts create mode 100644 plugins/pstack/skills/statechart/scripts/lean/passes/attribute.ts create mode 100644 plugins/pstack/skills/statechart/scripts/lean/passes/blocks.ts create mode 100644 plugins/pstack/skills/statechart/scripts/lean/passes/budget.ts create mode 100644 plugins/pstack/skills/statechart/scripts/lean/passes/check.ts create mode 100644 plugins/pstack/skills/statechart/scripts/lean/passes/contract.ts create mode 100644 plugins/pstack/skills/statechart/scripts/lean/passes/fold.ts create mode 100644 plugins/pstack/skills/statechart/scripts/lean/passes/inline.ts create mode 100644 plugins/pstack/skills/statechart/scripts/lean/passes/mark.ts create mode 100644 plugins/pstack/skills/statechart/scripts/lean/passes/reduce.ts create mode 100644 plugins/pstack/skills/statechart/scripts/lean/passes/trust.ts create mode 100644 plugins/pstack/skills/statechart/scripts/lean/passes/view-lemmas.ts create mode 100644 plugins/pstack/skills/statechart/scripts/lean/pipeline.ts create mode 100644 plugins/pstack/skills/statechart/scripts/lean/run.ts create mode 100644 plugins/pstack/skills/statechart/scripts/lean/toolchain.ts diff --git a/CHANGES.md b/CHANGES.md index f91d7da8..72064678 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -7,6 +7,7 @@ This port applies the Cursor → Claude Code substitutions in skill bodies. Earl - `/reframe` compares plausible interpretations of ambiguous requests, identifies observable signals, and rewrites the request using verified terminology. - `/sharpen` asks for experiments to resolve choices that can be tested. `/statechart` handles Windows process cleanup and CRLF in TLC output. +- `/statechart` adds Lean 4 proof compilation from Cursor pstack 0.15.49. It renders lemma dependencies and proof steps and reports gaps, native computation, and custom axioms. - The model catalog registers GPT‑6.2 Sol and Astra and retains the previous model IDs for compatibility. See [UPSTREAM.md](UPSTREAM.md#selected-backports-after-the-sync-point) for the source commits. diff --git a/NOTICE.md b/NOTICE.md index 65599911..5cc91be0 100644 --- a/NOTICE.md +++ b/NOTICE.md @@ -28,6 +28,7 @@ This plugin is a port of upstream MIT-licensed work. All upstream copyright noti | `plugins/pstack/skills/` (0.15.30 to 0.15.36 changes: the `statechart` and `ketchup-video` skills, run-based `interrogate` adversaries, the agentic Orchestrate playbook, Autopilot-stack without the merge, the different-provider arena judge, reflect copies outside the plugin cache, goal restatement, explain the number before measuring, and `watch-pr`, `check-plan` and `worktree-audit.sh` fixes), `README-UPSTREAM.md` | [cursor/plugins/pstack @ 2776ddd](https://github.com/cursor/plugins/tree/2776ddd2355d6d6c8747d3964600f28daf62f049/pstack) | (c) 2026 Lauren Tan | MIT | [LICENSE](LICENSE) | | `plugins/pstack/skills/reframe/SKILL.md` and `plugins/pstack/skills/sharpen/SKILL.md` (selected from pstack 0.15.48) | [cursor/plugins/pstack @ 9e278fe](https://github.com/cursor/plugins/tree/9e278fe4d4ecd8bfe98b1b79bf4be662efb338cc/pstack) | (c) 2026 Lauren Tan | MIT | [LICENSE](LICENSE) | | `plugins/pstack/skills/statechart/` (Windows process handling and CRLF parsing) | [cursor/plugins/pstack @ 0b46ec3](https://github.com/cursor/plugins/tree/0b46ec399d55f2829e88822998f53b84944837d3/pstack/skills/statechart) | (c) 2026 Lauren Tan | MIT | [LICENSE](LICENSE) | +| `plugins/pstack/skills/statechart/` (Lean 4 proof compiler and shared CLI updates), `README-UPSTREAM.md` | [cursor/plugins/pstack @ 4d5593e](https://github.com/cursor/plugins/tree/4d5593ed7f5d978ab643800443aad3d8c131d289/pstack) | (c) 2026 Lauren Tan | MIT | [LICENSE](LICENSE) | ## What changed in the port diff --git a/README-UPSTREAM.md b/README-UPSTREAM.md index bb613a10..cbf5488c 100644 --- a/README-UPSTREAM.md +++ b/README-UPSTREAM.md @@ -40,7 +40,7 @@ two steps: new here? the [pstack guide](./docs/guide/README.md) walks you through a first real task, from setup and prompting through verification and overnight runs. stuck, or unsure which skill fits? ask [`/poteto-help`](./skills/poteto-help/SKILL.md). -that's it. the other skills are situational, and the mode skill uses them for you as needed. out of the box the mode splits work by model strength: code delegates (feature, refactoring, bug fix, perf, hillclimb) go to grok, while the hardest changes, prose, and judgment go to opus 5.5. the default panel is opus 5.5 / grok. [`/setup-pstack`](./skills/setup-pstack/SKILL.md) changes any of it. +that's it. the other skills are situational, and the mode skill uses them for you as needed. out of the box, code delegates (feature, refactoring, bug fix, perf, hillclimb), prose, and judgment go to opus 5.5 at xhigh, and no role runs above xhigh. outside a review panel, fable 5.2 runs only when you name it or after two opus 5.5 runs of the same brief fail. the default panel is fable 5.2 / opus 5.5 / gemini 4 neon. [`/setup-pstack`](./skills/setup-pstack/SKILL.md) changes any of it. ## usage @@ -50,7 +50,7 @@ pick `/poteto-mode` from the `/` menu before you type your task, so cursor attac ### just use [`/poteto-mode`](./skills/poteto-mode/SKILL.md) -this skill is the main shortcut. i use it whenever i need the agent to do rigorous engineering work. it comes with twenty-three playbooks: +this skill is the main shortcut. i use it whenever i need the agent to do rigorous engineering work. it comes with twenty-two playbooks: ``` /poteto-mode this pr has a subtle bug where the scroll drifts every 750ms even when idle. repro @@ -63,7 +63,7 @@ morning. ```
-the twenty-three playbooks +the twenty-two playbooks | playbook | for | |---|---| @@ -82,7 +82,6 @@ morning. | [babysit](./skills/poteto-mode/playbooks/babysit.md) | drive a pr or a stack to merge-ready: conflicts, review threads, ci. | | [shipping](./skills/poteto-mode/playbooks/shipping.md) | independently verify a green stack, then land the contiguous verified run bottom-up through github by default or origin when available. | | [autonomous run](./skills/poteto-mode/playbooks/autonomous-run.md) | drive a long task to completion without stopping. | -| [orchestrate](./skills/poteto-mode/playbooks/orchestrate.md) | a standing project handed to one coordinator chat: multi-day, many stacked prs, fleets of subagents. | | [autopilot-full](./skills/poteto-mode/playbooks/autopilot-full.md) | run independent prs to merged with one owner per pr. a swarm verifies each code-ready head, and every later change to the patch gets a fresh check. | | [autopilot-stack](./skills/poteto-mode/playbooks/autopilot-stack.md) | autopilot-full without the merge. build and verify prs for the operator to review and land, stacking a pr only on a pr it builds on. | | [session pickup](./skills/poteto-mode/playbooks/session-pickup.md) | resume or take over a prior agent's in-flight work. | @@ -109,7 +108,7 @@ to keep [`/poteto-mode`](./skills/poteto-mode/SKILL.md) on across turns, pick it ## skills -[`/poteto-mode`](./skills/poteto-mode/SKILL.md) runs most of these for you when a step needs them (`how`, `why`, `architect`, `arena`, `swarm`, `interrogate`, `unslop`, `no-comments`, `technical-writing`, `tdd`, and the principles). the table below is for when you want one directly: +[`/poteto-mode`](./skills/poteto-mode/SKILL.md) runs most of these for you when a step needs them (`why`, `architect`, `arena`, `swarm`, `interrogate`, `unslop`, `no-comments`, `technical-writing`, `tdd`, and the principles). the table below is for when you want one directly: ``` /how do we cancel runs? do we have an n+1 when we look up every run to cancel? @@ -127,9 +126,10 @@ to keep [`/poteto-mode`](./skills/poteto-mode/SKILL.md) on across turns, pick it | [`/poteto-mode`](./skills/poteto-mode/SKILL.md) | default entry point for any non-trivial task. | | [`/poteto-help`](./skills/poteto-help/SKILL.md) | you're new to pstack, or unsure which skill, playbook, or principle fits. finds out what you're trying to do, answers that part, and hands you a prompt to type. runs only when you type `/poteto-help`. | | [`/in-your-own-words`](./skills/in-your-own-words/SKILL.md) | you want the agent to play back your goal and the problem before it starts. runs only when you type `/in-your-own-words`. | -| [`/sharpen`](./skills/sharpen/SKILL.md) | you want a prompt made deeper, not bigger, before you send it: what a top professional would do that you didn't ask for, the raw material they'd start from, their methods and tools, and an outside check that the result is right. hands back the rewritten prompt and leaves your choices open. doesn't do the task. runs only when you type `/sharpen`. | +| [`/sharpen`](./skills/sharpen/SKILL.md) | you want a prompt made deeper, not bigger, before you send it: what a top professional would do that you didn't ask for, the raw material they'd start from, their methods and tools, and an outside check that the result is right. hands back the rewritten prompt, which asks the agent to prototype any choice an experiment can settle and leaves product and preference choices to you. doesn't do the task. runs only when you type `/sharpen`. | +| [`/reframe`](./skills/reframe/SKILL.md) | you can't name what you're building, so you can't ask an agent for it clearly. starts from your files and your own words. if they could describe more than one problem, it lists the two or three it could be, with the sign that tells each apart, and picks the likeliest. then it gives 8 to 12 expert terms ranked by how much they'd change what you build, each tied to the part of your description it names and to a real project whose link it checked. borrows terms from 2 or 3 neighboring fields that solved the same problem under other names, says where each analogy breaks, then rewrites your description with the new words. runs only when you type `/reframe`. | | [`/how`](./skills/how/SKILL.md) | you want a walkthrough of how a subsystem works. | -| [`/why`](./skills/why/SKILL.md) | you want to know why something was built this way. discovers available MCPs at run time and queries each evidence category in parallel (source control, issue tracker, long-form docs, real-time chat, infra observability, error tracking, analytics warehouse). | +| [`/why`](./skills/why/SKILL.md) | you want to know why something was built this way. answers from the record, not the code: the commits and pr discussions that introduced it and each later change, and other sources when that trail is thin. cites what the authors wrote, marks its own inferences, and says what the record does not answer. | | [`/recall`](./skills/recall/SKILL.md) | you're starting or resuming work and want your recent context on a topic rebuilt from your own chat history and the shared record, handed back as a tight current-state brief. | | [`/ketchup`](./skills/ketchup/SKILL.md) | you want what changed in this chat since your last message, in plain words and small visuals, with every item waiting on you listed and decidable from the reply alone, even when that makes the reply long. | | [`/ketchup-video`](./skills/ketchup-video/SKILL.md) | you want the `/ketchup` catch-up as a short subtitled video of slides, with the calls waiting on you as text under it. | @@ -154,7 +154,7 @@ to keep [`/poteto-mode`](./skills/poteto-mode/SKILL.md) on across turns, pick it | [`/maintain-verification-skill`](./skills/maintain-verification-skill/SKILL.md) | your verify skill's feature map has drifted from the app. source wave + one live pass, at most one PR of proven corrections. | | [`/create-formal-verification-skill`](./skills/create-formal-verification-skill/SKILL.md) | tests can't reach the case that breaks a race, retry, state machine, parser, or unsafe code. verifies one property with the tool that fits and generates a project-local skill to recheck it on every change. | | [`/maintain-formal-verification-skill`](./skills/maintain-formal-verification-skill/SKILL.md) | code your formal verification covers has changed since it was last checked. updates the model, harness, or properties to match the code, reruns, and says whether each failure is drift in the verification or a bug in the code. | -| [`/statechart`](./skills/statechart/SKILL.md) | someone who owns the behavior needs to see it, not read a spec. checks a tla+ model, draws what the user sees as a mermaid statechart, marks each state that breaks a rule, and gives the shortest path to each one. | +| [`/statechart`](./skills/statechart/SKILL.md) | someone who owns the behavior or proof needs to see it, not read a spec. checks a tla+ model or a lean 4 proof, draws it as mermaid, marks each rule break or unproven gap, and gives the shortest path to each one. | | [`/unslop`](./skills/unslop/SKILL.md) | you're cleaning up writing. removes AI tells. | | [`/bro`](./skills/bro/SKILL.md) | you want the last message restated in plain human language, no jargon. | | [`/technical-writing`](./skills/technical-writing/SKILL.md) | layered doc standard (Diátaxis + Google developer style + STE + Global English) for docs, RFCs, readmes, PR descriptions, commit messages. | @@ -278,7 +278,7 @@ type [`/automate-me`](./skills/automate-me/SKILL.md). it mines your recent trans models are configurable too. type [`/setup-pstack`](./skills/setup-pstack/SKILL.md). it detects the models you have access to and writes a small always-applied rule mapping each role (code, judgment, the review panels) to a model. every skill reads it and falls back to sensible defaults when the rule is absent, so you override only what you want. -when a default changes, a rule written before the change still pins the old default. delete those role lines, or delete the file, then run `/setup-pstack` again. a rerun keeps any role whose model differs from the default. +when a default changes, a rule written before the change still pins the old default until you run `/setup-pstack` again. that run replaces the old defaults it recognizes and keeps any other role whose model differs from the default. to drop a pin it does not recognize, delete that role's line or the file first. ## automations diff --git a/README.md b/README.md index 1b906b26..8a44f270 100644 --- a/README.md +++ b/README.md @@ -174,7 +174,7 @@ This repository also keeps: ## Staying close to Lauren's pstack -Open Pstack 1.21.1 keeps the pstack 0.15.36 sync at Cursor commit [`2776ddd2355d6d6c8747d3964600f28daf62f049`](https://github.com/cursor/plugins/commit/2776ddd2355d6d6c8747d3964600f28daf62f049) and includes the [selected backports documented in UPSTREAM.md](UPSTREAM.md#selected-backports-after-the-sync-point). +Open Pstack 1.21.1 keeps the pstack 0.15.36 sync at Cursor commit [`2776ddd2355d6d6c8747d3964600f28daf62f049`](https://github.com/cursor/plugins/commit/2776ddd2355d6d6c8747d3964600f28daf62f049) and includes Lean 4 proof compilation from Cursor pstack 0.15.49 among the [selected backports documented in UPSTREAM.md](UPSTREAM.md#selected-backports-after-the-sync-point). The two projects have separate version numbers. The pstack version identifies Lauren's upstream content. The Open Pstack version identifies the Claude Code and Codex package built from it. diff --git a/UPSTREAM.md b/UPSTREAM.md index 3fe230a1..3bfda031 100644 --- a/UPSTREAM.md +++ b/UPSTREAM.md @@ -12,7 +12,7 @@ open-pstack tracks [Cursor's pstack](https://github.com/cursor/plugins/tree/main | Upstream version | `0.15.36` | | open-pstack version | `1.21.1` | -The table above is the current Cursor sync point. Open Pstack 1.17.0 imported this 0.15.36 sync, and 1.18.0 to 1.21.1 keep it. `README-UPSTREAM.md` preserves the upstream pstack README verbatim. `CHANGES.md` and `NOTICE.md` describe the adaptations and provenance. +The table above is the current Cursor sync point. Open Pstack 1.17.0 imported this 0.15.36 sync, and 1.18.0 to 1.21.1 keep it. `README-UPSTREAM.md` preserves the upstream pstack 0.15.49 README verbatim. `CHANGES.md` and `NOTICE.md` describe the adaptations and provenance. ## Selected backports after the sync point @@ -21,8 +21,9 @@ The table above is the current Cursor sync point. Open Pstack 1.17.0 imported th | [#1324](https://github.com/cursor/plugins/pull/1324), [#1326](https://github.com/cursor/plugins/pull/1326) | Add the explicit `/reframe` skill with source checks and two or three interpretations of ambiguous requests. | | [#1236](https://github.com/cursor/plugins/pull/1236) | Ask `/sharpen` to propose an experiment for choices an experiment can settle. | | [#1292](https://github.com/cursor/plugins/pull/1292) | Port the `/statechart` Windows process handling, CRLF parsing, and the earlier SANY error reporting needed by those paths. Keep the port's strict exit code type. | +| [#1366](https://github.com/cursor/plugins/pull/1366) | Port Lean 4 proof compilation, the shared TLA+/Lean launcher, Mermaid rendering, and the statechart help entry from Cursor pstack 0.15.49 at `4d5593ed7f5d978ab643800443aad3d8c131d289`. Retain strict TypeScript checking and run the upstream test corpus separately. | -The cross-harness skill routing and the full-tree sync point remain at the recorded baseline. Cursor's shared worker and model-default rewrite is outside this backport. +The full-tree sync point remains at the recorded baseline. This backport retains Open Pstack's cross-harness workflow instructions and configured model routing. The Cursor workflow rewrites in [#1236](https://github.com/cursor/plugins/pull/1236) and [#1249](https://github.com/cursor/plugins/pull/1249), and the Cursor Gemini defaults in [#1283](https://github.com/cursor/plugins/pull/1283) and [#1284](https://github.com/cursor/plugins/pull/1284), remain outside its scope. ## Upstream-only exclusions diff --git a/docs/reference.md b/docs/reference.md index 5bf19197..5d845986 100644 --- a/docs/reference.md +++ b/docs/reference.md @@ -119,7 +119,7 @@ Not declared as deps, but referenced in skill bodies: - **`run`, `verify`, `loop`** — Claude Code CLI built-ins (ship with the binary, always available). - **`gh` (GitHub CLI).** This is the default forge for every stack playbook and a system-level requirement of the standalone `babysit` skill. Install it with [`brew install gh`](https://cli.github.com) and authenticate with `gh auth login`. If Origin's `origin` CLI is installed and can resolve the repository, the stack playbooks use it instead. No playbook requires Graphite (`gt`). - **`bun`** — runs the vendored `skills/poteto-mode/scripts/` tooling (`watch-pr`, `runner`) and the port-authored `resolve-codex-transcript` launcher. Install via [`brew install oven-sh/bun/bun`](https://bun.sh). `bootstrap.ts` installs dependencies for `watch-pr`; the runner uses only Bun and Node built-ins, so it launches directly without an install/re-exec layer. -- **`mise`** — `statechart` installs TLC and Java with mise on its first run, which needs the network and writable mise state. Its launcher runs on Node 22.18 to 22.x, Node 23.6 or later, Bun 1.1.5 or later, or Deno 2.0 or later. +- **`mise`** — `statechart` installs TLC and Java with mise for TLA+ checks. For Lean proofs it uses Lean 4.34.1 from `LEAN_SYSROOT` or `PATH`, or installs the pinned toolchain with mise. These installations need the network and writable mise state. The launcher runs on Node 22.18 to 22.x, Node 23.6 or later, Bun 1.1.5 or later, or Deno 2.0 or later. - **`git` 2.25 or later** — the runner asks `git rev-parse --git-common-dir` for a linked worktree's shared git directory, and `worktree-audit.sh` reads `git worktree list --porcelain`. Ubuntu 20.04 LTS ships 2.25; older git is unsupported. - **Bash on Windows** — the SessionStart hook runs through `hooks/run-hook.cmd`, which looks for Git for Windows' `bash.exe` in its standard system-wide and per-user locations, then for a `bash` on `PATH` (MSYS2, Cygwin). Without one, the hook exits 0 and skips the pstack startup context, as the superpowers wrapper it comes from does. Install [Git for Windows](https://git-scm.com/download/win) to get the context. In Codex, the hook starts `C:\Windows\System32\cmd.exe` by full path, because one command must work in both PowerShell and cmd. A Windows installed outside `C:\Windows` does not run the hook. - **macOS, Linux or WSL2 for Claude writer lanes** — Claude Code's sandbox does not run on native Windows, so a Claude writer lane needs one of these hosts. @@ -160,7 +160,7 @@ The table uses the short upstream names. Claude Code exposes each native skill w | `/maintain-verification-skill` | re-sync a drifted verification skill and its feature map | | `/create-formal-verification-skill` | generate a project-local skill that formally verifies a race, invariant, or other property tests rarely reach | | `/maintain-formal-verification-skill` | bring a formal verification back in line after the code it covers changed, and say whether each failure is drift or a bug (typed only) | -| `/statechart` | check a TLA+ model and draw it as a Mermaid statechart, with the shortest path to each state that breaks a rule (typed only) | +| `/statechart` | check a TLA+ model or Lean 4 proof and draw Mermaid charts showing paths to rule violations or proof gaps (typed only) | | `/deslop` | deslop a diff before commit | | `/babysit` | monitor an open PR, fix CI/comments, keep it merge-ready | | `/thermo-nuclear-code-quality-review` | extremely strict maintainability audit | diff --git a/plugins/pstack/skills/poteto-help/SKILL.md b/plugins/pstack/skills/poteto-help/SKILL.md index d2c3d0a6..12c136b3 100644 --- a/plugins/pstack/skills/poteto-help/SKILL.md +++ b/plugins/pstack/skills/poteto-help/SKILL.md @@ -87,7 +87,7 @@ The default answer is `/poteto-mode`, which runs most of the others when its ste | Bring a verification skill and its feature map back in line with the app | [`/maintain-verification-skill`](../maintain-verification-skill/SKILL.md) | | Formally verify a race, invariant, or other property that tests rarely reach | [`/create-formal-verification-skill`](../create-formal-verification-skill/SKILL.md) | | Bring a formal verification back in line after the code it covers changed, and learn whether a failure is drift or a bug | [`/maintain-formal-verification-skill`](../maintain-formal-verification-skill/SKILL.md) | -| Show a PM or designer what the user sees as a chart checked by a TLA+ model, with the shortest path to each state that breaks a rule | [`/statechart`](../statechart/SKILL.md) | +| Show a TLA+ model or a Lean 4 proof as Mermaid charts, with the shortest path to each rule break or unproven gap | [`/statechart`](../statechart/SKILL.md) | | Vet a performance number before reporting or acting on it | [`/benchmark-checklist`](../benchmark-checklist/SKILL.md) | | Run a large or cross-cutting change, or one to review after stepping away | [`/figure-it-out`](../figure-it-out/SKILL.md) | | Keep a decision log during a run, and review it afterward | [`/show-me-your-work`](../show-me-your-work/SKILL.md) | diff --git a/plugins/pstack/skills/statechart/SKILL.md b/plugins/pstack/skills/statechart/SKILL.md index 18d653a8..dbc7446a 100644 --- a/plugins/pstack/skills/statechart/SKILL.md +++ b/plugins/pstack/skills/statechart/SKILL.md @@ -1,46 +1,68 @@ --- name: statechart -description: "Check a TLA+ model of a system that moves between states, such as a product flow, a protocol, or a service, and draw it as a Mermaid statechart. The report gives the shortest path to each state that breaks a rule. Use for /statechart, or to show a bug as a path through states." +description: "Check a TLA+ model or a Lean 4 proof and draw it as Mermaid. For TLA+, checks rules with TLC and shows shortest bug paths. For Lean 4, draws lemma dependencies and proof trees in plain English, flagging unproven gaps, failing steps, native code, and custom axioms. Use for /statechart." disable-model-invocation: true --- # Statechart -The chart shows how a system moves between states, in the words of the person who reads it. That person, the reader, decides whether the behavior is right. +The chart shows how a TLA+ system moves between states or how a Lean 4 theorem is proved, in the words of the operator who must decide whether the behavior or proof is right. ## Run +`scripts/statechart.ts` is TypeScript, so run it with a runtime that executes TypeScript. `scripts/statechart` is a POSIX shell script that picks Node 22.18 to 22.x, Node 23.6 or later, Bun 1.1.5 or later, or Deno 2.0 or later. On native Windows, run `node --disable-warning=ExperimentalWarning /scripts/statechart.ts` with Node 22.18 to 22.x, or Node 23.6 or later. + +The CLI auto-dispatches on the first positional argument. + +### TLA+ models + Work in a scratch folder outside the repo. Write a TLA+ spec and its config. Then run: ```sh /scripts/statechart SPEC.tla [--config FILE] [--view FILE] [--out DIR] ``` -`scripts/statechart.ts` is TypeScript, so run it with a runtime that can execute TypeScript. `scripts/statechart` is a POSIX shell script that picks one. On native Windows, run `node --disable-warning=ExperimentalWarning /scripts/statechart.ts` with Node 22.18 to 22.x, or Node 23.6 or later. +The first TLA+ run installs TLC and Java with mise and needs the network. `--tactics` applies only to `.lean` files and exits 2 on `.tla` inputs. + +### Lean 4 proofs + +Run against any `.lean` file pinned to Lean `v4.34.1` (or a standalone `.lean` file with no `lean-toolchain`): + +```sh +/scripts/statechart FILE.lean THEOREM [--view FILE] [--tactics] [--out DIR] +``` + +- `THEOREM` accepts a full declaration name or a unique dotted suffix in `FILE.lean`. Unsafe declarations and non-theorem definitions exit 2. +- Pass `--out` to a scratch folder outside the repo so generated charts stay out of your checkout. Without `--out`, the output goes to `-proof` beside `FILE.lean`. The folder must be new or empty. +- `--view FILE` applies a plain-English view module to `lemmas.mmd` and `proof.mmd`. +- `--tactics` adds raw Lean tactic lines back inside `proof.mmd` boxes for Lean authors. Without it, boxes show claims, new local assumptions, invoked lemmas, and proof outcomes, while `report.md` keeps the full hypotheses and tactic scripts. +- `--config` applies only to TLA+ specs and exits 2 on `.lean` inputs. +- Toolchain lookup checks `LEAN_SYSROOT`, then `lean` and `lake` on `PATH` from the package root, then a pinned `mise` `http:lean` install for `v4.34.1`. Every resolved binary must report `v4.34.1`; any other pin or binary version exits 2. +- Interactive runs call `lake setup-file` in place, which writes the gitignored `.lake/` folder and may create `lake-manifest.json` if the package has none. Tests copy packages into temporary folders so the checkout stays clean. -The first run installs TLC and Java with mise and needs the network. +## TLA+ workflow -## Write the spec +### Write the spec -- Write each rule that the reader agrees to as an INVARIANT. A rule can be about a screen, a result, a stored value, or a message. If the model has no variable for a rule, add the variable. Never weaken a rule to make it hold. +- Write each rule that the operator agrees to as an INVARIANT. A rule can be about a screen, a result, a stored value, or a message. If the model has no variable for a rule, add the variable. Never weaken a rule to make it hold. - Write `Next` as a disjunction of the actions, such as `YouPressPlay \/ YouPressStop`. If you do not, TLC names every step `Next`. - A state with no step out breaks `NoDeadlock`, also when it is a correct end state. When an INVARIANT or a PROPERTY already has that name, the rule is `CHECK_DEADLOCK`. Add to `Next` an action that is true only in the end states and changes nothing, such as `Done == phase \in {"paid", "failed"} /\ UNCHANGED vars`, and give it a label in `step()`. -## Pick the chart +### Pick the TLA+ chart -You do the work that needs judgment: the words on each state and arrow, the phases and their colors, the title, and the report to the reader. Put your work in a view module, and give it with `--view`. +You do the work that needs judgment: the words on each state and arrow, the phases and their colors, the title, and the report to the operator. Put your work in a view module, and give it with `--view`. -To show the reader's words, the view exports `state(vars)`. The value that `state()` returns picks the form: +To show the operator's words, the view exports `state(vars)`. The value that `state()` returns picks the form: - A string gives a flat chart: `export const state = (v) => (v.paid ? "Paid" : "Paying");` - An array gives parent states: `export const state = (v) => v.main.split(".");` - An object gives one parallel region for each key: `export const state = (v) => ({ Playback: v.playback, Volume: v.volume });` -Label each state with what the reader can see or cares about, such as "Paying" or "Lease held, write pending". Keep variable names out of labels. In `vars`, a TLA+ sequence is an object with keys from 1, so `v.pc[1]` is `pc[1]`. A set is an array. +Label each state with what the operator can see or cares about, such as "Paying" or "Lease held, write pending". Keep variable names out of labels. In `vars`, a TLA+ sequence is an object with keys from 1, so `v.pc[1]` is `pc[1]`. A set is an array. -The view can also export `step(action, from, to)`. It gets the TLC action name and the values before and after the step, and it returns the label of the arrow. Write each step label as the user sees it happen, such as "you press play" or "the connect fails". Do not name the code or the TLA+ action. Two actions that end the same in the chart get the same label, so that they share one arrow. +The view can also export `step(action, from, to)`. It gets the TLC action name and the values before and after the step, and it returns the label of the arrow. Write each step label as the operator sees it happen, such as "you press play" or "the connect fails". Do not name the code or the TLA+ action. Two actions that end the same in the chart get the same label, so that they share one arrow. -When a step can occur only in some conditions, end its label with the condition in brackets, in the reader's words, such as `you press play [while the file loads]`. In a regions chart, the command writes the condition on the other regions on the arrow, in the words of their labels, such as `[when Offline]`. Your brackets replace it, and two arrows from one state can then look the same. So in a regions chart, do not write brackets for a condition on another region. When a value that no label shows decides where a step goes, name the result in the label, such as "the roster read fails". +When a step can occur only in some conditions, end its label with the condition in brackets, in the operator's words, such as `you press play [while the file loads]`. In a regions chart, the command writes the condition on the other regions on the arrow, in the words of their labels, such as `[when Offline]`. Your brackets replace it, and two arrows from one state can then look the same. So in a regions chart, do not write brackets for a condition on another region. When a value that no label shows decides where a step goes, name the result in the label, such as "the roster read fails". The view can also export these: @@ -48,18 +70,18 @@ The view can also export these: - `colors` gives each group name a color class. - `title` is a string that the chart shows at the top. -The command calls `state()` and `group()` at most once for each model state, and `step()` at most once for each step. The chart and the report both use those answers. So make each function depend only on its arguments. +The command calls `state()` and `group()` at most once for each model state, and `step()` at most once for each step. The chart and the report both use those answers. Make each function depend only on its arguments. -The chart does not draw a step that stays in one label. Split a label when the reader must see such a step. +The chart does not draw a step that stays in one label. Split a label when the operator must see such a step. -Aim for about 20 arrows or fewer, because a busier chart is hard to read. First return coarser labels from `state()`. Give one label to values that act the same, and leave out a detail that the reader does not need, such as a call in flight whose return changes nothing. Keep each state of a bug path, and keep each mark. When a merge changes a `breaks` state to `mayBreak`, it hides where a rule breaks. Do not merge two states that break different rules, because the reader then cannot see which rule breaks where. If the chart is still too busy, return `null` from `step()` for the steps that the reader does not need, such as a reset that every state has, or a step whose arrow repeats what other arrows show. Obey these rules when you hide steps: +Aim for about 20 arrows or fewer, because a busier chart is hard to read. First return coarser labels from `state()`. Give one label to values that act the same, and leave out a detail that the operator does not need, such as a call in flight whose return changes nothing. Keep each state of a bug path, and keep each mark. When a merge changes a `breaks` state to `mayBreak`, it hides where a rule breaks. Do not merge two states that break different rules, because the operator then cannot see which rule breaks where. If the chart is still too busy, return `null` from `step()` for the steps that the operator does not need, such as a reset that every state has, or a step whose arrow repeats what other arrows show. Obey these rules when you hide steps: - Keep each chart state reachable by arrows from a start state. - Keep at least one arrow out of each chart state that has a step out in the model. - Hide all the steps of an arrow, or none of them. When you hide only some, its condition gets narrower. - In the hand-off, say which steps the chart hides. -## Read the report +### Read the TLA+ report - In the chart, a state that breaks a rule has the class `breaks`. When only some model states behind it break the rule, it has the class `mayBreak`. The Legend names the rules of each mark. When two rules break, it names both on one mark, so say in the hand-off which state breaks which rule. In a regions chart, a state gets a mark when each combination of region states that includes it can break a rule. When a combination can break a rule and none of its states has a mark, each state in that combination gets a mark. - TLC goes past a state that breaks a rule, so the chart shows the states after a bug. @@ -69,14 +91,48 @@ Aim for about 20 arrows or fewer, because a busier chart is hard to read. First - The command checks the rules with TLC on the config as written, with one worker. When a rule breaks, the command removes that rule and runs TLC again, until no rule breaks. After the first break, each run stops at 100,000 distinct states, so that a large model does not run without end. When a run reaches that bound or stops on an error, the report lists the rules that it did not check under "Rules not checked", and the chart does not mark them. A rule that is not checked can hold or break. To check it, remove the rules that break from the config, or make the model smaller. The bound adds a module that changes TLC's order of the variables, so for a property TLC can find a different counterexample than a run without the bound. - `tlc.out` is what TLC printed on the config as written. When the chart does not show the bug path of a rule that breaks, `tlc-RULE.out` is what TLC printed for the run that found it. When TLC repeats its first warning, plain TLC prints it twice, but `tlc.out` shows it once, because TLC leaves the second copy out of the output that this command reads. That happens only when Java runs with `-XX:+UseParallelGC`, since otherwise TLC's first warning is its advice to pass that flag, which it prints once. +## Lean 4 workflow + +One command elaborates `FILE.lean` once and writes up to four files into `--out`: + +- `lemmas.mmd`: Angle 1 theorem dependency flowchart (`flowchart TD`), capped at 60 nodes. By default, each lemma leads with its docstring summary (clipped on word or clause boundaries) above its short name, and the legend notes `Arrows mean uses`. Solid edges cross compiler auxiliaries only. Dotted `via def` edges cross user definitions, opaques, or inductives. Thick edges trace shortest unproven paths. +- `proof.mmd`: Angle 2 proof tree (`flowchart TD`), written when the theorem has tactic steps and capped at 40 blocks. By default, boxes omit type and binder preambles, omit raw tactic scripts, translate standard Lean case tags (`mp`, `mpr`, `inl`, `inr`, `zero`, `succ`, `nil`, `cons`, `true`, `false`) into plain English, strip repeated parent prefixes like `mp.` from nested splits, and show claims, new local assumptions, invoked lemmas, and outcomes (`Proven`, `Unproven gap (sorry)`, `Failing step`, `Depends on unproven gap`). Pass `--tactics` to show raw tactic lines inside boxes. +- `report.md`: Audit verdict, shortest unproven paths, full axiom list, untruncated hypotheses, goals, and tactic scripts per block, lemma statements, and Lean diagnostics scoped to the target theorem. +- `facts.json`: Versioned JSON (`format: 1`) written by `scripts/lean/Extract.lean`. + +### Write a Lean `--view` for non-math readers + +For an operator who is not a Lean author, lead with the plain-English `lemmas.mmd` chart and treat `proof.mmd` as an optional drill-down. Put plain-English titles, claim summaries, group names, and branch descriptions in a `--view FILE` module: + +- `title`: a string, or `{ lemmas?: string, proof?: string }`. +- `lemma(info)`: returns a plain-English string, `{ label, group?, hide? }`, `null` (to hide a clean low-level plumbing lemma), or `undefined`. +- `group(info)`: returns a plain-English subgraph title (replacing raw module names), `null`, or `undefined`. +- `branch(info)`: returns a plain-English string or `{ label, detail? }` for a proof-tree node. `info` carries stable `id` (`"root"`, `"root.0"`, ...), `goal`, `newHyps`, `tactics`, `lemmas`, `status`, `caseTag`, `rawCaseTag`, `depth`, `isRoot`, `isLeaf`, and `times`. When `times > 1` folds branches with different goals, `info.goal` is `""` and `info.newHyps` is empty. +- `caseLabel(tag, info)`: returns a plain-English edge label for a split branch, or `undefined`. + +Soundness rules enforced by the compiler: + +- A view can never hide the target theorem, any node with `sorry`, any node with a failing step, any custom axiom, any native computation node, or any lemma that depends on an unproven gap or axiom. Attempting to hide one exits 2. +- A view can never change trust classes or turn an unproven branch green. Status classes, red or amber shapes, thick edges, and trust badges always come from Lean facts. +- When a view hides a clean supporting lemma, the compiler bridges transitive dependency edges across it, preserves all axioms so `checkAxioms` still agrees with `Lean.collectAxioms`, and notes the hidden count in both the chart legend and `report.md`. Say in the hand-off which supporting lemmas the view hides. + +### Exit codes and trust boundary + +- Exit `0`: closed proof resting on `propext`, `Classical.choice`, and `Quot.sound` at most. +- Exit `1`: audit finding (`sorry`, failing step in the target theorem, open goal, unchecked native code such as `native_decide` or `Lean.ofReduceBool`, or a custom axiom). +- Exit `2`: invalid arguments, bad `--view` export or soundness violation, unsupported Lean pin, `module`-header file, missing or ambiguous theorem, or a hard invariant failure (`checkAxioms` or `checkTree`). +- Exit `130` or `143`: `SIGINT` or `SIGTERM` stopped the run, killed the worker process group, and wrote nothing. + +Because tactic extraction elaborates package code, Lean charts explain proofs and do not replace a standalone build or axiom verification gate. + ## Show the chart -Show `chart.mmd` to the user as a `mermaid` code block. The chart has a budget of 500 states, counted by TLC on the config as written. Above that, the chart draws only the paths to the rules that break, and when no rule breaks, the command writes no `chart.mmd`. It still checks each rule, and the report gives the state count and each bug path. To see the whole graph, make the model smaller. +Show `chart.mmd` (for TLA+) or `lemmas.mmd` (leading for non-math readers) and `proof.mmd` (for Lean 4) to the operator as `mermaid` code blocks. For TLA+, the chart has a budget of 500 states, counted by TLC on the config as written. Above that, the chart draws only the paths to the rules that break, and when no rule breaks, the command writes no `chart.mmd`. It still checks each rule, and the report gives the state count and each bug path. To see the whole graph, make the model smaller. -Render charts with Pele. When the user asks for an image, or a chart is too large to read as text, follow `references/render.md`. Do not use a different renderer unless the user asks for it. +Render charts with Pele. When the operator asks for an image, or a chart is too large to read as text, follow `references/render.md`. Do not use a different renderer unless the operator asks for it. ## Hand off -Give each chart and its Mermaid text to the person who must decide. Add one line for each bug: the rule, the reader's sentence for that rule, and the path as the report numbers it. Say what the model leaves out. Give the command that makes the files again, with a new `--out` folder. +Give each chart and its Mermaid text to the operator who must decide. For TLA+, add one line for each bug: the rule, the operator's sentence for that rule, and the path as the report numbers it. Say what the model leaves out. For Lean 4, lead with the plain-English lemma chart, include `proof.mmd` as an optional drill-down, list each unproven path and exit verdict from `report.md`, and note any supporting lemmas hidden by `--view`. Give the command that makes the files again, with a new `--out` folder. -When the model describes code, replay each bug path against the real code, as a test or a live repro, one step for each action. If a bug does not occur, think that the model is wrong until you show that it is not. +When a TLA+ model describes code, replay each bug path against the real code, as a test or a live repro, one step for each action. If a bug does not occur, treat the model as wrong until you show that it is not. diff --git a/plugins/pstack/skills/statechart/references/render.md b/plugins/pstack/skills/statechart/references/render.md index 5ef0519d..aaa98d6c 100644 --- a/plugins/pstack/skills/statechart/references/render.md +++ b/plugins/pstack/skills/statechart/references/render.md @@ -1,14 +1,18 @@ # Render a chart -Render each `.mmd` file that you show with the npm package `pele@1.9.0`, and give the user the SVG. Install Pele once, outside the repo. Write each SVG next to its `.mmd` file, with the same name. The API is at https://pele.run/api. Pass `{ limit: 1_000_000, outputLimit: 8_000_000, maxEdges: 10_000 }` as the options of `render`. Pele's defaults are smaller than a chart of 500 states can be. When Pele throws a `PeleError`, show the user the Mermaid text and the error. +Render each `.mmd` file that you show with the npm package `pele@1.9.0`, and give the operator the SVG. Install Pele once, outside the repo. Write each SVG next to its `.mmd` file, with the same name. The API is at https://pele.run/api. Pass `{ limit: 1_000_000, outputLimit: 8_000_000, maxEdges: 10_000 }` as the options of `render`. Pele's defaults are smaller than a chart of 500 states can be. When Pele throws a `PeleError`, show the operator the Mermaid text and the error. ## Colors -Pele ignores Mermaid `theme` and `themeVariables`. Set its `--pele-*` CSS variables on `.pele`. https://pele.run/theming lists them. The command gives each state the color class of its group, such as `class sN teal`. It marks each bad state with `class sN breaks` or `class sN mayBreak`, each state on the shortest path to a bug with `class sN bugPath`, and each state that a PROPERTY counterexample repeats forever with `class sN repeats`. Pele puts these classes on the state's node. Color the classes with CSS. +Pele ignores Mermaid `theme` and `themeVariables`. Set its `--pele-*` CSS variables on `.pele`. https://pele.run/theming lists them. -The `.mmd` file has a `classDef` line for `breaks` and for `mayBreak`, so that any Mermaid viewer shows the bug marks. It has no `classDef` for the group colors, `bugPath`, or `repeats`. Pele writes each `classDef` color as a `style` attribute on the node, and a `style` attribute wins over a normal CSS rule. So the rules for the marks below use `!important`. Without it, a dark theme keeps the light mark colors. A bug mark sets the fill and the text, and `bugPath` and `repeats` set the border. Put the mark rules after the group colors, so that a mark shows over the group color. +For TLA+ statecharts (`stateDiagram-v2`), the command gives each state the color class of its group, such as `class sN teal`. It marks each bad state with `class sN breaks` or `class sN mayBreak`, each state on the shortest path to a bug with `class sN bugPath`, and each state that a PROPERTY counterexample repeats forever with `class sN repeats`. The `.mmd` file has a `classDef` line for `breaks` and for `mayBreak`, and none for the group colors, `bugPath`, or `repeats`. -These colors are suggestions. They are the colors of the old skill. Put them in a `