Skip to content

Add Pi bridge integration#363

Merged
mmprotest merged 7 commits into
mainfrom
mmprotest/implement-pi-integration-for-villani-code
May 29, 2026
Merged

Add Pi bridge integration#363
mmprotest merged 7 commits into
mainfrom
mmprotest/implement-pi-integration-for-villani-code

Conversation

@mmprotest

Copy link
Copy Markdown
Owner

Motivation

  • Provide a thin, first-class Pi integration so Pi can delegate runs to Villani without porting Villani runner logic into Pi.
  • Define a stable, minimal JSONL stdio protocol so external integrations (Pi) can start/observe/abort Villani runs and receive normalized operational events.

Description

  • Add a small JSON bridge protocol with typed dataclasses and parsing in villani_code/integrations/pi_bridge_protocol.py implementing ready, ping, run, and abort semantics.
  • Implement a threaded stdio bridge (PiBridge) in villani_code/integrations/pi_bridge.py that emits flushed JSONL events, spawns the existing Runner via _build_runner, maps internal runner events to normalized bridge events, detects changed files via git status, and propagates transcript path/verification results.
  • Expose a CLI entrypoint bridge --stdio in villani_code/cli.py that runs the stdio bridge so it can be launched as python -m villani_code.cli bridge --stdio (or via an executable).
  • Add a Pi extension scaffold under integrations/pi-villani/ (TypeScript) which registers a /villani command, launches the bridge subprocess using VILLANI_COMMAND, waits for ready, sends a run command, streams & renders normalized bridge events, supports aborts, and produces a final summary; protocol/types and a small process wrapper live in src/protocol.ts and src/process.ts.
  • Add tests tests/integrations/test_pi_bridge.py covering ping/pong, malformed JSON handling, unknown commands, mocked run success/failure, abort behavior, and event filtering; add documentation and a short design note for future Pi-backed model-proxy work (integrations/pi-villani/README.md and docs/pi-model-bridge.md).

Testing

  • Ran linters: ruff check villani_code/integrations tests/integrations/test_pi_bridge.py villani_code/cli.py and it passed.
  • Ran unit/integration tests: pytest -q tests/integrations/test_pi_bridge.py tests/test_packaging_surface.py tests/test_cli_headless_optional_tui.py and all tests passed (19 passed, 1 skipped in the broader run; bridge tests: 7 passed).
  • Built the Pi extension: cd integrations/pi-villani && npm install && npm run build and the TypeScript build succeeded.
  • Performed a manual smoke test: printf '{"type":"ping","id":"smoke"}\n' | python -m villani_code.cli bridge --stdio produced the expected ready and pong JSON lines.

Codex Task

@mmprotest mmprotest merged commit 72853dc into main May 29, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant