Skip to content

feat(agent-host): Pi diff cards and LSP diagnostics - #199

Merged
deymosh merged 4 commits into
masterfrom
feat/pi-lsp-diagnostics
Nov 18, 2026
Merged

deymosh merged 4 commits into
masterfrom
feat/pi-lsp-diagnostics

Conversation

@deymosh

@deymosh deymosh commented Nov 18, 2026 •

Copy link
Copy Markdown
Owner

Summary

Pi gets two things every other agent's file changes already had or that Pi's own users get from oh-my-pi:

Diff cards. Pi's edit and write reached the phone as a tool row and a result line, never as a diff. The driver now adds the diff card when the call finishes (only then has the change been applied): an edit's lines come from the unified patch Pi returns in details.patch, with real context lines; a write shows the content it wrote. A failed change gets no card; a sub-agent's edit gets one under its parent's call. The unified-patch reader OpenCode's adapter had moved to sdk/transcript so both drivers share it.

LSP diagnostics. After a successful edit or write, the CodeDeck Pi extension has the project's language server check the file and appends its errors and warnings to the tool result: the model reads a type error it just made before its next step, and the phone shows it in the result.

Files Server Found in
TS/JS typescript-language-server for TypeScript ≤ 6; TypeScript 7's own tsc --lsp project node_modules; the former also PATH
Python basedpyright-langserver, else pyright-langserver .venv/venv, node_modules, PATH
Rust rust-analyzer (own check + cargo check) PATH

Nothing is installed. Design, after reading how oh-my-pi does it (packages/coding-agent/src/lsp/) and probing each real server: an LSP client inside the extension (Node built-ins only), one server per project and language kept for the session (idle-stopped after 10 min, killed with Pi), pull where offered, $/progress + a 300 ms quiet window, the push of a push-only server, a re-pull after a project load or workspace/diagnostic/refresh, pull and push merged one problem each. 10 s per check (30 s for the change that starts the server); what arrived by then is reported, marked unfinished. Changed file only, errors and warnings, at most 20. Servers get Pi's environment without the provider profile's token. CODEDECK_PI_LSP=off turns it off.

What the probes found that the code relies on (all in comments): TypeScript 7 ships no tsserver.js, so typescript-language-server refuses it — TS 7 is its own server; Pyright and typescript-language-server answer file:///C:/… as file:///c%3A/…, so documents are keyed by path; Pyright speaks the OS locale unless initialize says locale: "en"; rust-analyzer's pull is empty while it loads; rustup's rust-analyzer proxy without the component exits 1 (skipped, never retried that session).

Also: a /write <path> <content> scenario for the fake model.

Cost

No wire change. A diff card is one more diff entry per file change (capped at 200 lines like the other agents'). Diagnostics add at most 20 lines to an edit's result, only when there are errors or warnings. On the machine: one language-server process per project and language while in use; rust-analyzer runs cargo check on each change.

Verification

  • ./codedeck check --changed: green.
  • piLsp.test.ts: server choice, the text the model reads, each server's behaviour through one shared fake whose modes state what each real server was seen doing, a server that cannot start, the deadline, the token stripped, the hook. Proven by breaking the URI keying, the token stripping, the re-pull and the give-up once each.
  • piFakeModel.test.ts: the real Pi writes a TypeScript error; the real typescript-language-server (now a pinned devDependency) reports TS2322 in the result and the diff card shows. Fails with the hook removed.
  • Live, live-probe with --fake-model through the built host: TypeScript 7 (tsc --lsp), basedpyright, and rust-analyzer (cold 13 s including cargo check's borrow error E0505; warm < 1 s), each with its diff card.

What review changed

A bug hunt found five real issues, each fixed in the LSP commit with a test that fails without the fix: a server frame whose body is not an object threw inside Pi's process; a server still initializing was not stopped when Pi exited, and a .cmd shim's server survived a close (the tree is killed now); a stopped turn still waited up to 30 s for a starting server; a late push for the previous change could end the wait for this one (servers that push versions without $/progress); the project key was case-sensitive on Windows. CI's first run also showed the fake-model test's cleanup racing the server's exit on Windows (EBUSY): the cleanup retries.

Not in this PR

Diagnostics for other languages (a Pi package can add them); errors the change causes in other files.

🤖 Generated with Claude Code

deymosh and others added 4 commits November 18, 2026 00:25
Pi's edit and write calls reached the phone as a tool row and a result
line only, while every other agent's file change also shows its diff.
The driver now adds the diff card when the call finishes (only then has
the change been applied): an edit's lines come from the unified patch Pi
returns in its result details, with real context lines; a write returns
no details, so its card is the written content, every line an addition.
A failed change gets no card. A sub-agent's edits get theirs under the
parent's call, the patch carried in its progress event.

The unified-patch reader OpenCode's adapter had moves to sdk/transcript
so both drivers use it.

Co-Authored-By: Claude Code <[email protected]>
The fake model had no way to make an agent change a file, which is what
a diff card and post-edit diagnostics hang off. `/write <path> <content>`
calls the request's own `write` tool with `{path, content}` (Pi's
arguments, the only writer it was run against), a literal `\n` in the
content being a line break.

Co-Authored-By: Claude Code <[email protected]>
After a successful `edit` or `write`, the CodeDeck Pi extension has the
project's language server check the file and appends its errors and
warnings to the tool result, so the model sees a type error it just made
in the same turn, and the phone shows it as part of the result.

Servers, only ones already on the machine (project-local first, then
PATH; nothing is installed):
- TypeScript/JavaScript: typescript-language-server for a TypeScript
  that ships tsserver.js (up to 6.x), TypeScript 7's own `tsc --lsp`
  otherwise; a Node package runs with Pi's Node, an npm .cmd shim on
  PATH through a shell.
- Python: basedpyright or Pyright, from the project's virtualenv, its
  node_modules, or PATH.
- Rust: rust-analyzer from PATH (its own check, then cargo check's).

How each server delivers diagnostics and when it is done differs, so the
client follows what each did when run against the real binary: pull
where the server offers it, wait out `$/progress` and a quiet window,
wait for the push of a push-only server, re-pull after a project load or
a `workspace/diagnostic/refresh`, and merge pull and push one problem
each. Documents are keyed by path, since servers answer in VS Code's URI
spelling (`file:///c%3A/...`). One server per project and language, kept
for the session, stopped after ten idle minutes and when Pi exits; a
server that cannot start is not retried for that project. A check waits
at most 10 s (30 s for the change that starts the server); whatever has
arrived by then is reported, marked unfinished. Only the changed file,
errors and warnings, at most 20. Servers get Pi's environment without the
provider profile's token. `CODEDECK_PI_LSP=off` turns it off. A general
sub-agent's changes are checked too.

Tests: piLsp.test.ts drives each server's behaviour through a shared fake
(fakeLanguageServer.mjs, whose modes state what each real server was
seen doing); the Pi fake-model test writes a TypeScript error through
the real Pi and the real typescript-language-server, now a pinned
devDependency, and checks the result and the diff card.

Co-Authored-By: Claude Code <[email protected]>
PI.md says what a file change shows (the patch Pi applied, or the
written content), and has a Diagnostics section: which servers check
which files and where each is looked for, what makes a project's root,
how long a check waits cold and warm, what is reported, that a server
runs the project's build tooling without a profile's token, and the
CODEDECK_PI_LSP=off switch. "No LSP diagnostics" leaves the list of what
Pi does not have.

Co-Authored-By: Claude Code <[email protected]>
@deymosh
deymosh force-pushed the feat/pi-lsp-diagnostics branch from 597cf38 to fed7fe3 Compare November 18, 2026 09:28
@deymosh
deymosh merged commit 2c2dd3c into master Nov 18, 2026
6 checks passed
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