Skip to content

fix(pstack): run /statechart on native Windows and read TLC's \r\n line ends - #1292

Merged
poteto merged 3 commits into
mainfrom
pstack-statechart-windows-948e
Nov 19, 2026
Merged

poteto merged 3 commits into
mainfrom
pstack-statechart-windows-948e

Conversation

@poteto

@poteto poteto commented Nov 19, 2026

Copy link
Copy Markdown
Collaborator

Why

On native Windows, /statechart could not run: it spawned /bin/sh for its group kill and its janitor. Worse, TLC there ends lines with \r\n, including each @!@!@ENDMSG marker. The line readers split on \n only, so the marker regex failed and every later message nested inside the first. A spec with a broken rule stopped with "TLC exited 12 ... but its output names no rule that broke". A spec where every rule holds could exit 0 with a wrong reason in its report, or with raw @!@!@ markers in tlc.out.

What changed

  • One splitLines helper splits on \r?\n. linesOf, fileLines and outputLines, the readers of TLC's output and dump, use it.
  • No /bin/sh. killGroup moves to kill.ts: process.kill(-pid, "SIGKILL") on macOS and Linux, taskkill /t /f on Windows. The janitor is janitor.ts, run by the command's own runtime. On Windows neither the command nor the janitor kills the worker's tree after the worker exits, because Windows can reuse its pid. The command tells the janitor when the worker exits.
  • java and mise start with windowsHide, so the console-less worker opens no window for them. The worker gets TEMP and TMP beside TMPDIR. Java gets -Dstdout.encoding=UTF-8 and -Dstderr.encoding=UTF-8, because Windows ignores LC_ALL.
  • SKILL.md: on native Windows, run node --disable-warning=ExperimentalWarning <skill dir>/scripts/statechart.ts with the launcher's Node range, because the launcher is a POSIX shell script.
  • Two tests: FirstRule's TLC output with \r\n names the rule that breaks, and each corpus case replays with line ends as TLC prints them on Windows. Version 0.15.46, harness tree regenerated.

Scope

  • Every TLC and SANY text path in statechart goes through outputLines or fileLines. config.ts already treats \r as a line end.
  • I checked the rest of pstack/ for scripts that split tool output on \n only: watch-pr (github.ts, render.ts, cli.ts, policy.ts), bootstrap.ts, worktree-audit.sh and log.sh. None needs a change. watch-pr parses JSON and already splits first lines on /\r?\n/, bootstrap.ts trims, and the shell scripts read git output in a POSIX shell.

Tradeoffs

  • The janitor is now a Node, Bun or Deno process for the length of a check, not sh: more memory, same behavior.
  • Left alone: --out set to an existing empty folder on Windows, and mise installed only as a .cmd shim.

Blast Radius

The statechart run path on every OS. On macOS and Linux the group kill, the cleanup and the output stay the same.

Verification

I ran everything on macOS (Node 22.23, TLC 1.7.4, Temurin 25). Nothing ran on Windows, so every Windows claim above is inferred.

  • New tests: 34 of 34 fail on main and pass with this change.
  • Statechart suite as CI runs it (no TLC): main 269 pass, this branch 303 pass, 70 skipped on each. With real TLC: main 372 of 373, this branch 406 of 407. The one failure in every run, the launcher symlink test, fails the same way on main on macOS.
  • Real TLC made to print \r\n with -Dline.separator, each corpus case end to end: 8 of 33 on main, 33 of 33 here.
  • Real TLC, stopped by SIGTERM, SIGINT and SIGKILL, and run to the end: the same exit codes and messages as main, and no java process or temporary file left. A SIGKILL of the command with a fake java also cleans up under Node 22.23, Bun 1.3.9 and Deno 2.9.8.
  • generate-pstack-harness-trees.mjs --check, check-pstack-docs.mjs and validate-plugins.mjs pass.

Related: #1170

…ne ends

TLC on Windows ends lines with \r\n, including each @!@!@Endmsg marker.
The line readers split on \n only, so the marker regex failed, every
later message nested inside the first, and a broken rule read as "TLC
exited 12, but its output names no rule that broke". The command also
spawned /bin/sh for its group kill and its janitor, which native
Windows does not have.

- One splitLines helper splits on \r?\n for linesOf, fileLines and
  outputLines.
- killGroup moves to kill.ts: process.kill(-pid) on macOS and Linux,
  taskkill /t /f on Windows. The janitor is janitor.ts, run by the
  command's own runtime. On Windows the command kills the worker's tree
  only while the worker runs, because Windows reuses pids.
- The worker gets TEMP and TMP beside TMPDIR. Java gets
  -Dstdout.encoding=UTF-8 and -Dstderr.encoding=UTF-8, because Windows
  ignores LC_ALL.
- SKILL.md: on native Windows, run node scripts/statechart.ts, because
  the launcher is a POSIX shell script.
- Tests: FirstRule's TLC output with \r\n names the rule that breaks,
  and each corpus case replays with line ends as TLC prints them on
  Windows.
- The command tells the janitor when the worker exits. On Windows the
  janitor then skips taskkill, since Windows can give that pid to
  another process, and still removes the folders. On macOS and Linux it
  kills the group as before.
- java and mise start with windowsHide, so the console-less worker does
  not open a window for them. Node ignores it elsewhere.
- SKILL.md gives the launcher's Node range, 22.18 to 22.x or 23.6 or
  later, and its --disable-warning=ExperimentalWarning flag.
@poteto
poteto merged commit 0b46ec3 into main Nov 19, 2026
1 check passed
caelaxie added a commit to pstack-ports/droid-pstack that referenced this pull request Nov 20, 2026
<!-- CURSOR_AGENT_PR_BODY_BEGIN -->
## Upstream

Ports pstack `0.15.46` from
[cursor/plugins@0b46ec399d55](cursor/plugins@0b46ec3),
three commits after the last ported pin
`2f87c854fe3e2fcda44ca86b46ede35aad3c46b7` (`0.15.43`).

- [cursor/plugins#1283](cursor/plugins#1283)
`e58dd0436005` chore(pstack): route the Gemini seat to Gemini 4 Neon
- [cursor/plugins#1284](cursor/plugins#1284)
`dd24b6707267` chore(pstack): run the Gemini panel seat at
gemini-4-neon-xhigh
- [cursor/plugins#1292](cursor/plugins#1292)
`0b46ec399d55` fix(pstack): run /statechart on native Windows and read
TLC's \r\n line ends

Version is `0.15.46` in `plugin.json`, `.factory-plugin/plugin.json`,
and the README header. Homepage and repository stay
`https://github.com/pstack-ports/droid-pstack`.

## What landed

- Statechart Windows and CRLF behavior from #1292, copied verbatim into
`skills/statechart/`:
- `SKILL.md` names the POSIX `scripts/statechart` launcher and the
native Windows `node --disable-warning=ExperimentalWarning` command
(Node 22.18 to 22.x, or Node 23.6 or later).
- `scripts/frontends/dot.ts` adds `splitLines` (split on `\r?\n`) and
`linesOf` uses it.
- New `scripts/janitor.ts` and `scripts/kill.ts`. Group kill no longer
goes through `/bin/sh`. `killGroup` uses `taskkill /t /f` on Windows and
`process.kill(-pid, "SIGKILL")` elsewhere.
- `scripts/statechart.ts` starts the janitor with the current Node
runtime, sets `TEMP` and `TMP` next to `TMPDIR`, and skips killing a
Windows process group after the worker has already exited (a reused pid
stays up).
- `scripts/run.ts` reads file and child output with `splitLines`, sets
`windowsHide` on TLC spawns, and passes `-Dstdout.encoding=UTF-8` and
`-Dstderr.encoding=UTF-8`.
- Tests replay the corpus and the FirstRule verdict with Windows line
ends (`scripts/test/cli.test.ts`, `scripts/test/messages.test.ts`).
- These script files matched upstream at `2f87c854` before this port, so
the new copies match upstream at `0b46ec399d55`.
`skills/statechart/scripts/package.json` keeps
`@droid-skill/statechart`.

## Left alone

- #1283 and #1284 only swap Cursor Gemini slugs (`gemini-4-carbon-high`
to `gemini-4-neon-xhigh`, and the README panel line from "gemini 4
carbon" to "gemini 4 neon") in arena, poteto-mode, setup-pstack, the
upstream README, and `docs/harness/claude-code.md`. This port has no
Gemini seat. `skills/arena/SKILL.md`, `skills/poteto-mode/SKILL.md`, and
`skills/setup-pstack/SKILL.md` already drop `gemini-*` entries and were
not overwritten. The README panel sentence stays "the default panel is
fable 5.2 / opus 5.5". None of those files named `gemini-4-carbon-high`
or "gemini 4 carbon", so the Neon migration paragraph was not copied.
- `docs/harness/claude-code.md` is not in this repo and was not added.
No `.cursor-plugin/` directory and no `.cursor/skills/` paths.

## Checks

`node scripts/validate-plugin.mjs` passed. `npm test` in
`skills/statechart/scripts` (`node --disable-warning=ExperimentalWarning
--test test/*.test.ts`): 374 tests, 304 pass, 0 fail, 70 skipped (the
skipped test needs `TLA2TOOLS`). The new Windows line-end cases passed,
including the FirstRule verdict replay.

<!-- CURSOR_AGENT_PR_BODY_END -->

<div><a
href="https://cursor.com/agents/bc-42c67aad-f622-5420-9d4a-fdd1161493b1?cursor_ref=pr_footer&cursor_cta=open_in_web"><picture><source
media="(prefers-color-scheme: dark)"
srcset="https://cursor.com/assets/images/open-in-web-dark.png"><source
media="(prefers-color-scheme: light)"
srcset="https://cursor.com/assets/images/open-in-web-light.png"><img
alt="Open in Web" width="114" height="28"
src="https://cursor.com/assets/images/open-in-web-dark.png"></picture></a>&nbsp;<a
href="https://cursor.com/background-agent?bcId=bc-42c67aad-f622-5420-9d4a-fdd1161493b1&cursor_ref=pr_footer&cursor_cta=open_in_cursor"><picture><source
media="(prefers-color-scheme: dark)"
srcset="https://cursor.com/assets/images/open-in-cursor-dark.png"><source
media="(prefers-color-scheme: light)"
srcset="https://cursor.com/assets/images/open-in-cursor-light.png"><img
alt="Open in Cursor" width="131" height="28"
src="https://cursor.com/assets/images/open-in-cursor-dark.png"></picture></a>&nbsp;</div>

Co-authored-by: Cursor Agent <cursoragent@cursor.com>
Co-authored-by: Kaitian Xie <caelaxie@users.noreply.github.com>
caelaxie added a commit to pstack-ports/agy-pstack that referenced this pull request Nov 20, 2026
…74)

<!-- CURSOR_AGENT_PR_BODY_BEGIN -->
## Summary

Ports upstream pstack `0.15.46` at
`0b46ec399d55f2829e88822998f53b84944837d3` into this Antigravity port.
The previous pin was `0.15.43` at
`2f87c854fe3e2fcda44ca86b46ede35aad3c46b7`.

Upstream pstack commits in range:

- [#1283](cursor/plugins#1283) and
[#1284](cursor/plugins#1284) retarget Cursor's
Gemini panel seat to `gemini-4-neon-xhigh`. Those Cursor slug changes
are not imported. This port maps setup-pstack, arena, poteto-mode, and
the README to Antigravity tiers (`pro`, `flash`, `flash_lite`,
`inherit`) and writes `~/.gemini/config/rules/pstack-models.md`. The
default panel stays pro / flash.
- [#1292](cursor/plugins#1292) is ported onto
the existing statechart files: `/statechart` runs on native Windows
(`janitor.ts`, `kill.ts`) and reads TLC output that uses `\r\n` line
ends. The statechart skill gains the upstream Windows Node invocation
sentence. Existing Antigravity wording stays.

`docs/harness/` is not added. deslop, control-cli, and control-ui are
untouched. Version bump is only in `.antigravity-plugin/plugin.json`
(`0.15.46`). README pins are `0.15.46` /
`0b46ec399d55f2829e88822998f53b84944837d3`.

## Harness proof

Head `b5acb4b9a8605aa7b69252bc1def75e049326ac7`.

Installed agy `1.5.13` from
`https://storage.googleapis.com/antigravity-public/antigravity-cli/1.5.13-5999302598852608/linux-x64/cli_linux_x64.tar.gz`.
Manifest version `1.5.13` matches. sha512:

```
014b37387703acab1f47cd532c8bb60167a6a3537b0f9891de03f1b1ffa9614307bc83c4b2f7551273b0877d722716b0cd9e26782f6b2a50705db4f05e18c68f  cli_linux_x64.tar.gz
```

`sha512sum -c` printed `OK`. `agy --version` printed `1.5.13`.

### main (`a96658a5fef674d26ba623124a51af61c3f91003`, plugin 0.15.43)

agy 1.5.13 already validates and installs 0.15.43. No compatibility fix.

```
$ agy plugin validate --strict .
Validating pstack (.antigravity-plugin/plugin.json)
  skills 61 · agents 2 · rules 1 · hooks 0 · mcpServers 0 · sidecars 0
✔ Validation passed

$ agy plugin install .
  [ok]    pstack
          ✔ skills      : 61 installed
          ✔ agents      : 2 installed (comment-sicko, poteto-agent)
          ✔ rules       : 1 installed (typescript-best-practices)

$ agy plugin list
- pstack (enabled, 0.15.43)
    Components: 61 skills, 2 agents, 1 rule
```

`agy plugin install https://github.com/pstack-ports/agy-pstack` and `agy
plugin install https://github.com/pstack-ports/agy-pstack/tree/main`
both installed enabled pstack 0.15.43. `agy plugin validate --strict` on
both URLs passed. `agy plugin install main` is rejected (`install target
must be a directory or <plugin>@<marketplace>`).

Shell syntax: `worktree-audit.sh` and `show-me-your-work/scripts/log.sh`
both `bash -n` clean. poteto-mode scripts: typecheck clean, 54 pass, 0
fail. statechart: 340 tests, 270 pass, 0 fail, 70 skipped (TLC corpus
runs skip without `TLA2TOOLS`).

### this branch

```
$ agy plugin validate --strict .
Validating pstack (.antigravity-plugin/plugin.json)
  skills 61 · agents 2 · rules 1 · hooks 0 · mcpServers 0 · sidecars 0
✔ Validation passed

$ agy plugin install .
  [ok]    pstack  (enabled, 0.15.46)
          ✔ skills      : 61 installed
          ✔ agents      : 2 installed (comment-sicko, poteto-agent)
          ✔ rules       : 1 installed (typescript-best-practices)

$ agy plugin install https://github.com/pstack-ports/agy-pstack/tree/cursor/port-pstack-0.15.46-c0f5
Cloning plugin from https://github.com/pstack-ports/agy-pstack.git...
  [ok]    pstack
          Installed to ~/.gemini/config/plugins/pstack

$ agy plugin list
- pstack (enabled, 0.15.46)
    Components: 61 skills, 2 agents, 1 rule

$ git -C "$AGY_HOME/.gemini/config/plugins/pstack" rev-parse HEAD
b5acb4b
```

Installed setup-pstack, arena, and poteto-mode still name
`~/.gemini/config/rules/pstack-models.md` and the pro / flash tiers.
They do not contain `gemini-4-neon`. The installed statechart skill
includes the Windows Node invocation sentence. README line 42 still says
the default panel is pro / flash.

poteto-mode scripts: 54 pass, 0 fail. statechart: 374 tests, 304 pass, 0
fail, 70 skipped (same TLC skip).

A live `agy --print` turn stopped at `Authentication required` (Google
login). This environment has no Antigravity account, so live skill
invocation was not run and is not counted as a pass.

<!-- CURSOR_AGENT_PR_BODY_END -->

<div><a
href="https://cursor.com/agents/bc-c284e11d-df02-56ed-a766-84d84aa3c0f5?cursor_ref=pr_footer&cursor_cta=open_in_web"><picture><source
media="(prefers-color-scheme: dark)"
srcset="https://cursor.com/assets/images/open-in-web-dark.png"><source
media="(prefers-color-scheme: light)"
srcset="https://cursor.com/assets/images/open-in-web-light.png"><img
alt="Open in Web" width="114" height="28"
src="https://cursor.com/assets/images/open-in-web-dark.png"></picture></a>&nbsp;<a
href="https://cursor.com/background-agent?bcId=bc-c284e11d-df02-56ed-a766-84d84aa3c0f5&cursor_ref=pr_footer&cursor_cta=open_in_cursor"><picture><source
media="(prefers-color-scheme: dark)"
srcset="https://cursor.com/assets/images/open-in-cursor-dark.png"><source
media="(prefers-color-scheme: light)"
srcset="https://cursor.com/assets/images/open-in-cursor-light.png"><img
alt="Open in Cursor" width="131" height="28"
src="https://cursor.com/assets/images/open-in-cursor-dark.png"></picture></a>&nbsp;</div>

Co-authored-by: Cursor Agent <cursoragent@cursor.com>
Co-authored-by: Kaitian Xie <caelaxie@users.noreply.github.com>
mstephenholl added a commit to mstephenholl/pstack-claude-codex that referenced this pull request Nov 20, 2026
Closes #48.

## Why

The fork is three pstack commits behind cursor/plugins. The daily sync
stopped on a `setup-pstack` conflict and opened #48. This is the manual
merge from `pstack/port/merge-upstream.py`, at cursor/plugins@aaeb0ea3.

## What changed

- **cursor#1283, cursor#1284.** `arena` and `poteto-mode` name `gemini-4-neon-xhigh`
as the default Gemini panel seat, in place of `gemini-4-carbon-high`.
- **cursor#1292.** `statechart` runs on native Windows and reads TLC's `\r\n`
line ends. It adds `janitor.ts`, `kill.ts`, and Windows line-end tests.
The scripts match upstream byte for byte.
- **`setup-pstack` conflict.** Keeps the port's version, which runs
`pstack configure`. Upstream's change migrates Gemini slugs in
`~/.cursor/rules/pstack-models.mdc`. Neither Codex nor Claude Code runs
Gemini, and `configure` never writes a Gemini entry.
- **`pstack-harness`.** Its Models section listed `gemini-4-carbon-high`
as a Cursor slug that skills name. After this merge no skill names it,
so the line names `gemini-4-neon-xhigh`.
- **Not ported.** #48 lists three Cursor-term lines in `arena` and
`poteto-mode`. They use `pstack-models.mdc` and `Task`, which the
harness already maps, and `check.py` confirms it. The new `Node 22.18`
line in `statechart` is already in the Requirements in
`pstack/README.md`.

## Blast radius

Skill text only, plus upstream's `statechart` scripts. No change to
`pstack configure`, `install.sh`, or `pstack-models.md`.

## Verification

- `check.py`: 0 problems, 0 warnings across 56 pstack skills and 3
team-kit skills.
- Port unit tests: 268 pass.
- `install_test.sh`: passes with bash 5.2, linking 59 skills and 2
agents.
- `statechart` tests, per file, under bun 1.4.2 with `node` linked to
bun and a 60-second timeout. The 34 tests this merge adds pass: 33
Windows line-end cases in `cli.test.ts` and 1 in `messages.test.ts`. The
same 11 tests fail before and after the merge. They need Node 22 or a
real TLC, and this machine has neither. Upstream's CI does not run these
tests.
- Smoke test: not run, for the reason in #39. It loads skills from the
installed release. After the release, run `pstack update`, then
`smoke.py --only arena,interrogate,poteto-mode`.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant