How bioshazard/just-pi works
Purpose and entry points
just-pi is a browser-native coding sandbox: users configure an OpenRouter key/model, prompt a Pi-based coding agent, run shell commands, and persist a workspace entirely in browser storage. Vite boots the React application from index.html through src/main.tsx, with src/App.tsx composing the IDE experience.
UI shell and interaction surfaces
The React shell provides setup, prompting, review, and file-workspace modes, including responsive mobile navigation. src/App.tsx owns top-level state and integration; src/AssistantCommandBar.tsx accepts either prompts or !-prefixed shell commands; src/AssistantReviewPane.tsx renders command and agent activity for review.
Agent-session boundary
src/agent-session.ts is the browser-side Pi agent runtime boundary. It assembles the agent loop, model/provider access, system context, tool surface, and streamed session events. src/agent-session-ui.ts adapts those events/state for the React layer, separating agent execution concerns from presentation.
Workspace persistence and tool consistency
src/opfs.ts implements the Origin Private File System workspace abstraction. Agent tools and interactive shell operations must act through this shared filesystem layer so edits persist across refreshes and both execution paths observe the same files. If present in that workspace, AGENTS.md contributes additional instructions to the agent prompt.
Command execution and attachments
src/shell.ts integrates just-bash with the OPFS-backed workspace, enabling ! command-bar requests to execute against the same file state used by the agent. src/assistant-attachments.ts handles attachment/context preparation for assistant requests, forming the boundary between UI-provided artifacts and agent inputs.
Runtime, external service, and deployment
The client runs fully in a modern browser with OPFS support; no server runtime is indicated. OpenRouter is the external model API, with user-supplied BYOK credentials read from browser localStorage, not embedded in the build. React and Vite provide the UI/build runtime (src/main.tsx, vite.config.ts), while GitHub Pages deployment is automated by .github/workflows/deploy-pages.yml.
Main entry points: agent-session.ts Pi agent session · App.tsx IDE shell · AssistantCommandBar.tsx Assistant command bar · index.html HTML entry
Components 15
React IDE
- React bootstrap
src/main.tsx - IDE shell · Owns top-level modes, state, and integrations.
src/App.tsx - Assistant command bar · Routes prompts and !-prefixed commands.
src/AssistantCommandBar.tsx - Review pane · Shows command and agent activity.
src/AssistantReviewPane.tsx
Agent & execution
- Agent UI adapter · Separates agent execution state from React presentation.
src/agent-session-ui.ts - Attachment preparation · Prepares UI artifacts and context for requests.
src/assistant-attachments.ts - Pi agent session · Builds the agent loop, tools, context, provider access, and streamed events.
src/agent-session.ts - Interactive shell · Executes command-bar shell requests against the workspace.
src/shell.ts
Browser persistence
- OPFS workspace · Shared persistent files; AGENTS.md can extend agent instructions.
src/opfs.ts - BYOK credentials · Stores user-supplied OpenRouter key and model.
Build & delivery
- HTML entry
index.html - Vite build
vite.config.ts - GitHub Pages deploy
.github/workflows/deploy-pages.yml
Other components
- Modern browser · Hosts the entire sandbox with OPFS support.
- OpenRouter
Connections 19
- Modern browser → HTML entry: loads
- HTML entry → React bootstrap: boots
- React bootstrap → IDE shell: renders
- IDE shell → Assistant command bar: hosts
- IDE shell → Review pane: hosts
- IDE shell → Agent UI adapter: binds
- Assistant command bar → Attachment preparation: prompt context
- Attachment preparation → Pi agent session: agent inputs
- Assistant command bar → Interactive shell: ! commands
- Agent UI adapter → Pi agent session: adapts events
- Pi agent session → Review pane: streams activity
- Pi agent session → OPFS workspace: agent tools use
- Interactive shell → OPFS workspace: reads and writes
- Pi agent session → BYOK credentials: reads key/model
- Pi agent session → OpenRouter: model requests
- Vite build → HTML entry: builds
- GitHub Pages deploy → Vite build: deploys build
- Modern browser → OPFS workspace: persists workspace
- Modern browser → BYOK credentials: stores settings