diff --git a/.qoder-plugin/plugin.json b/.qoder-plugin/plugin.json index dfa9d0d..842cf5c 100644 --- a/.qoder-plugin/plugin.json +++ b/.qoder-plugin/plugin.json @@ -1,7 +1,7 @@ { "name": "pstack", "displayName": "pstack", - "version": "0.15.43", + "version": "0.15.46", "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.", "author": { "name": "Lauren Tan" diff --git a/COMPATIBILITY.md b/COMPATIBILITY.md index 19b4da8..a4bd92c 100644 --- a/COMPATIBILITY.md +++ b/COMPATIBILITY.md @@ -1,6 +1,6 @@ # Qoder compatibility -pstack 0.15.43 runs on Qoder. The core poteto-mode workflow is compatible. This file records what is verified, what needs setup, and what is out of scope. +pstack 0.15.46 runs on Qoder. The core poteto-mode workflow is compatible. This file records what is verified, what needs setup, and what is out of scope. ## Verified compatible @@ -21,6 +21,8 @@ Qoder's exact bugbot login and marker are unverified. Detection covers any host Run `/setup-pstack` to write `~/.qoder/rules/pstack-models.md` and the model-pinning profiles under `~/.qoder/agents/`. The rule carries a `# defaults: 3` line and a `# budget` line. Budgets are `large` (`xhigh`), `medium` (`high`), and `small` (`medium`). No role runs above `xhigh`. +Upstream 0.15.44 and 0.15.45 moved the Cursor Gemini panel seat from `gemini-4-carbon-high` to `gemini-4-neon-high`, then to `gemini-4-neon-xhigh`, and added migration rules for those slugs. This port's second panel seat is `Fast`, already at `high`. That seat does not follow the Gemini effort change. Those slugs and their migration rules are not written into the defaults, the skills, or the setup-pstack rule. Panel defaults stay `Ultimate high` and `Fast high`. + A rule without the `# defaults: 3` line is from an older setup. On the next run, a line whose role is not in the current shape is dropped. That includes the retired roles `hardest tasks`, `architect runners`, `reflect tooling`, `reflect judgment, divergent, synthesizer`, `how explorer`, `why investigators`, and `why synthesizer`. A `# budget: unlimited` line becomes `large`, because no role runs above `xhigh`. An `arena cross-judge pool` that is exactly one `Ultimate` entry and one `Fast` entry takes the current default list. If the rule also has no `# defaults: 2` line, a `Fast` value at any effort in `feature, refactoring`, `bug-fix`, `perf-issue`, `hillclimb`, or `swarm workers` takes that role's default, and a panel list that is exactly one `Ultimate` entry and one `Fast` entry takes that role's default list. In any other list from that older rule, each `Fast` entry becomes `Ultimate high`. Every other value stays as the user's choice. Until you run setup, roles use the documented auto fallback: `Explore` for read-only work and `poteto-agent` for write work. The fallback works. The pinned-model path stays inactive until setup runs. ## Transcript layout diff --git a/README.md b/README.md index d5f63b7..f60c58a 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,8 @@ # pstack -Qoder port of [pstack](https://github.com/cursor/plugins/tree/2f87c854fe3e2fcda44ca86b46ede35aad3c46b7/pstack) (`0.15.43`) by [Lauren Tan (poteto)](https://x.com/poteto). +Qoder port of [pstack](https://github.com/cursor/plugins/tree/0b46ec399d55f2829e88822998f53b84944837d3/pstack) (`0.15.46`) by [Lauren Tan (poteto)](https://x.com/poteto). -See the [upstream pstack README](https://github.com/cursor/plugins/blob/2f87c854fe3e2fcda44ca86b46ede35aad3c46b7/pstack/README.md) and the [guide](./docs/guide/README.md) for usage and documentation. +See the [upstream pstack README](https://github.com/cursor/plugins/blob/0b46ec399d55f2829e88822998f53b84944837d3/pstack/README.md) and the [guide](./docs/guide/README.md) for usage and documentation. i'm [poteto](https://x.com/poteto). i'm not a president or ceo, but i've worked with millions of lines of code at Meta, Netflix, and Cursor. i'm also on the react core team where i help build and maintain react compiler. diff --git a/skills/statechart/SKILL.md b/skills/statechart/SKILL.md index f5a64a8..18d653a 100644 --- a/skills/statechart/SKILL.md +++ b/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/skills/statechart/scripts/frontends/dot.ts b/skills/statechart/scripts/frontends/dot.ts index 003dfc8..09d5481 100644 --- a/skills/statechart/scripts/frontends/dot.ts +++ b/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/skills/statechart/scripts/janitor.ts b/skills/statechart/scripts/janitor.ts new file mode 100644 index 0000000..5e69fb3 --- /dev/null +++ b/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/skills/statechart/scripts/kill.ts b/skills/statechart/scripts/kill.ts new file mode 100644 index 0000000..014d7c3 --- /dev/null +++ b/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/skills/statechart/scripts/run.ts b/skills/statechart/scripts/run.ts index 017684f..45e13dc 100644 --- a/skills/statechart/scripts/run.ts +++ b/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); } @@ -82,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, @@ -93,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 && @@ -142,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 => ({ @@ -170,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); } @@ -298,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.`); diff --git a/skills/statechart/scripts/test/cli.test.ts b/skills/statechart/scripts/test/cli.test.ts index 11f06a6..ee80722 100644 --- a/skills/statechart/scripts/test/cli.test.ts +++ b/skills/statechart/scripts/test/cli.test.ts @@ -102,6 +102,35 @@ for (const name of fs.readdirSync(corpus)) { }); } +function asTlcPrintsOnWindows(text: string) { + const lines = text.split("\n"); + let depth = 0; + for (let i = 0; i < lines.length - 1; i++) { + if (/@!@!@STARTMSG \d+:\d+ @!@!@$/.test(lines[i])) depth++; + else if (/^@!@!@ENDMSG \d+ @!@!@$/.test(lines[i])) depth--; + if (!depth) lines[i] += "\r"; + } + return lines.join("\n"); +} + +for (const name of fs.readdirSync(corpus)) { + test(`${name} writes the committed chart and report from TLC's output with Windows line ends`, () => { + const dir = copyCase(name, (d) => { + for (const f of fs.readdirSync(d)) + if (f.endsWith(".out")) + fs.writeFileSync(path.join(d, f), asTlcPrintsOnWindows(read(path.join(d, f)))); + }); + const r = run(dir); + assert.equal(r.stderr, ""); + const first = path.join(dir, "verdict-1.exit"); + const plain = fs.existsSync(first) ? Number(read(first)) : 0; + assert.equal(r.status, plain === 0 ? 0 : [11, 12, 13].includes(plain) ? 1 : 2); + assert.equal(r.report, read(path.join(corpus, name, "report.md"))); + assert.equal(read(path.join(r.out, "chart.mmd")), read(path.join(corpus, name, "chart.mmd"))); + for (const f of r.files) assert.doesNotMatch(read(path.join(r.out, f)), /\r|@!@!@/, f); + }); +} + const launcher = path.join(here, "../statechart"); const launcherTools = () => { diff --git a/skills/statechart/scripts/test/messages.test.ts b/skills/statechart/scripts/test/messages.test.ts index 61af006..4e0d3c3 100644 --- a/skills/statechart/scripts/test/messages.test.ts +++ b/skills/statechart/scripts/test/messages.test.ts @@ -1,13 +1,27 @@ import assert from "node:assert/strict"; +import fs from "node:fs"; +import path from "node:path"; import { test } from "node:test"; +import { fileURLToPath } from "node:url"; import { plainText, runtime } from "../backends/plain-text.ts"; import { readMessages } from "../frontends/messages.ts"; +import { readVerdict } from "../frontends/verdict.ts"; + +const here = path.dirname(fileURLToPath(import.meta.url)); const tool = (code: number, level: number, ...lines: string[]) => [`@!@!@STARTMSG ${code}:${level} @!@!@`, ...lines, `@!@!@ENDMSG ${code} @!@!@`].join("\n"); const plain = (text: string) => [...plainText(readMessages(text))].join(""); +test("TLC output with Windows line ends names the rule that breaks and prints as with Unix ones", () => { + const unix = fs.readFileSync(path.join(here, "corpus", "FirstRule", "verdict-1.out"), "utf8"); + const windows = unix.replaceAll("\n", "\r\n"); + assert.deepEqual(readVerdict(readMessages(windows)).broke, { kind: "invariant", name: "NotOne" }); + assert.deepEqual(readVerdict(readMessages(windows)), readVerdict(readMessages(unix))); + assert.equal(plain(windows), plain(unix)); +}); + test("TLC's -tool output prints as plain TLC prints it", () => { const text = [ tool(2262, 0, "TLC2 Version 2.19 of 08 August 2024 (rev: 5a47802)"),