A tour of the repository
Three packages, two seams between them, and how to find the file that does a thing.
Say you want to change what happens when you press Send. You could start by searching the whole checkout. It’s quicker to decide which part of the send you mean. The button lives in one package, the request in another, and the rules for accepting the message in a third.
In this chapter
- Find your way from the root to the three packages
- Follow the two interfaces a browser action crosses
- Pick a source file and a test for the behavior you’re tracing
Start with the three packages
packages/- Conversation rules
core/src/- Runtime and message rules
index.tsStart atcreateRuntime()for startup andsubmit()for a send. - Shared shapes and helpers
contracts.tsLook here forConversationSnapshotormessageLimit. - Turns saved state into views
view.ts
- Runtime and policy tests
test/
- HTTP and host adapters
server/src/- Starts the server
main.ts - Defines the routes
app.tsLook here for HTTP validation and the call into the runtime. - Reads operator settings
config.ts - Opens locations and routes tool calls
workspace-locations.ts - Shared tool definitions for Bash and Git clone
project-tool-definitions.ts - Runs isolated Docker tools
project-shell.ts - Optional host tools for Exa search and Jina Reader
public-web.ts
- Routes, startup and tools
test/
- Svelte browser client
web/src/- Mounts the app
main.ts - The chat workspace
App.svelteThis is where a send starts and where the selected chat’s view arrives from its event stream. - Components and client helpers
lib/- The Settings → Workspace panel
DeveloperWorkspace.svelte - Location options, remembered projects and Docker shell hint
workspace-choice.ts
- Client behavior tests
test/
- Bundled profiles
agents/ - Pi Durable’s generation retry patch
patches/ - Operator guides and decisions
docs/ - Deployment examples
deploy/- Caddy and systemd files
linux/
- Code to read or adapt
examples/tools/- A host tool example
clock.mjs
- Project utilities
scripts/- Enables or disables UI extensions
ui-extension.mjs
- Across package boundaries
tests/- Browser flows
browser/ - Process-death recovery
recovery.test.ts - Stream updates and reconnects
sse-delta.test.ts
- Example operator settings
config.example.toml - Commands for the whole checkout
package.json - Packages and dependency pins
pnpm-workspace.yaml - Shared TypeScript settings
tsconfig.base.json
- Conversation rules
- Runtime and message rulesStart at
createRuntime()for startup andsubmit()for a send. - Shared shapes and helpersLook here for
ConversationSnapshotormessageLimit. - Turns saved state into views
view.ts
- Runtime and policy tests
test/
- HTTP and host adapters
- Starts the server
main.ts - Defines the routesLook here for HTTP validation and the call into the runtime.
- Reads operator settings
config.ts - Opens locations and routes tool calls
workspace-locations.ts - Shared tool definitions for Bash and Git clone
project-tool-definitions.ts - Runs isolated Docker tools
project-shell.ts - Optional host tools for Exa search and Jina Reader
public-web.ts
- Routes, startup and tools
test/
- Svelte browser client
- Mounts the app
main.ts - The chat workspaceThis is where a send starts and where the selected chat’s view arrives from its event stream.
- Components and client helpers
- The Settings → Workspace panel
DeveloperWorkspace.svelte - Location options, remembered projects and Docker shell hint
workspace-choice.ts
- Client behavior tests
test/
- Bundled profiles
agents/ - Pi Durable’s generation retry patch
patches/ - Operator guides and decisions
docs/ - Deployment examples
- Caddy and systemd files
linux/
- Code to read or adapt
- A host tool example
clock.mjs
- Project utilities
- Enables or disables UI extensions
ui-extension.mjs
- Across package boundaries
- Browser flows
browser/ - Process-death recovery
recovery.test.ts - Stream updates and reconnects
sse-delta.test.ts
- Example operator settings
config.example.toml - Commands for the whole checkout
package.json - Packages and dependency pins
pnpm-workspace.yaml - Shared TypeScript settings
tsconfig.base.json
Open packages/web/src/App.svelte if the thing you’re looking for is on the page. The browser starts from main.ts, which mounts that component. Inside App.svelte, you can follow a send from the draft through the request. Look for select() in the same file to see how the client watches a chat and applies its updates. Smaller pieces, such as the model picker, live in src/lib/. Open DeveloperWorkspace.svelte there for the Workspace tab in Settings. App.svelte DeveloperWorkspace.svelte
Open packages/server/src/main.ts if the question is what Pipal starts with. It reads the settings and profiles, sets up the available tools, and gives the runtime to Hono. Move to app.ts to see what the browser can ask the server to do. For project tools, follow loadWorkspaceLocations() to see how the host opens a locationThe place a chat uses for project tools, either the Pipal host, an account reached over SSH, or a Docker project. and routes a call. For Docker, follow command execution into project-shell.ts. main.ts workspace-locations.ts
Open packages/core/src/index.ts if the question is whether a message should be accepted. Core applies the rules for the conversation and uses Pi Durable to keep its state. Core also has tools of its own. For instance, the read-only workspace tools are in workspace.ts. Start with the name the assistant sees and trace it to the code that runs it. index.ts workspace.ts
Two files at the root are worth keeping open as you read. pnpm-workspace.yaml tells pnpm where the packages are. package.json tells you what commands run across them. Start with the root manifest when you want to find out what pnpm build builds or what pnpm test runs. package.json
A send crosses two interfaces
- Pipal packages
- packages/web
The browser sends HTTP requests and reads an event stream. It imports shared definitions and helpers from core.
- packages/server
Hono translates HTTP requests into calls on the object returned by
createRuntime(). - packages/core
Core owns the conversation rules. The server calls it directly as TypeScript in the same process.
- packages/web
- packages/web → packages/server · HTTP and event stream
- packages/server → packages/core · Direct function calls
packages/server
Hono translates HTTP requests into calls on the object returned by createRuntime().
Talks to
Press Send and the browser posts the message as JSON, a text format for the fields it sends. Hono reads that request and calls runtime.submit(). The response is a receipt with HTTP 202. The browser gets the conversation and reply on a separate event streamAn open HTTP response that carries updates from the server to the browser., which it watches as long as the chat is selected. app.ts App.svelte
The first Send from a new draft takes an extra step. The browser posts the draft settings to /api/v1/conversations. Core creates the chat and pins its location and any project binding. The browser starts watching the chat if it’s still selected, and posts the message to /api/v1/conversations/:id/messages. Follow one message traces both requests and the saved reply. App.svelte index.ts
Both ends need to agree on what a conversation update looks like. That agreement is the contractThe agreed shape of the data that two parts of Pipal send to each other.. Look in packages/core/src/contracts.ts for the shared TypeScript types, limits, and helpers. For example, sharing the message length limit lets the browser check what you typed against the same number core enforces. contracts.ts
Say you change the message limit. Sharing the number lets the browser give you immediate feedback. Core still checks the request when it arrives. A direct API caller can skip the browser check, and attached text files count toward the same limit in both places. App.svelte index.ts
Deep diveWhere the in-process interface starts
main.ts imports createRuntime from @pipal/core, whose root export points at src/index.ts. The runtime returns operations such as submit, history, and watch. PipalRuntime derives its type from that return value. Hono receives it through the app options and calls it directly. A change to how submit decides whether to take an input belongs in core. A change to how that outcome is represented over HTTP belongs at the route and its error handling. package.json main.ts index.ts
api.post('/conversations/:id/messages', async c => { const { text, requestId, attachmentIds, textFiles } = await body(c, message); const files = attachmentIds?.length ? { ids: attachmentIds, prepare: (vision: boolean) => uploads.prepare(attachmentIds, vision) } : undefined; return c.json(await runtime.submit(c.req.param('id'), text, requestId, files, textFiles), 202);});The browser’s apiPath() prefixes routes with the build’s base URL and api/v1/. App.svelte imports types and executable helpers from @pipal/core/contracts. ChatGPTLogin.svelte imports a separate helper to parse the sign-in redirect. The runtime stays in the server process. api.ts App.svelte ChatGPTLogin.svelte
Find the file by the question you have
| I want to find… | Open… |
|---|---|
| A route accepting a request | packages/server/src/app.ts |
| A rule for accepting a message | packages/core/src/index.ts, at admission() |
| The shape of a conversation update | packages/core/src/contracts.ts, at ConversationSnapshot |
| The chat screen | packages/web/src/App.svelte |
| The Bash tool for a Docker project | packages/server/src/project-shell.ts |
| Developer’s optional Exa search and Jina Reader tools | packages/server/src/public-web.ts |
| A server default | packages/server/src/config.ts |
If you want to change what Chat or a specialist is asked to do, open agents/. Each profile file begins with settings and continues with the instructions. The runtime loads these files on startup, which is why a change there needs a restart. Guides on how to operate the project live in docs/, and the files for the Linux deployment live in deploy/linux/. main.ts
Find a test that crosses the same boundary
Look in a package’s test/ directory if you’re changing one piece. For example, packages/server/test/app.test.ts sends requests to the app and checks what the browser would get back. The root tests/ directory covers work that crosses boundaries, including recovery after a process dies. Look in tests/browser/ for cases that drive the page itself. Changing Pipal covers running the checks. app.test.ts recovery.test.ts
Deep diveHow the tests choose what to exercise
The app test subscribes to a conversation, sends a message, waits for the run to start, closes the stream, and opens a fresh one. It asserts that the accepted user message and assistant reply are both in the result. The recovery suite starts a separate process and stops it during work. Its replacement opens the saved store and verifies the recovered result. These test different boundaries even though both start with a send. app.test.ts recovery.test.ts
The root script runs Vitest for pnpm test and Playwright for pnpm test:e2e. Package checks type-check the source without producing a server build; the root check also covers the shared tests. That gives you distinct places to look for a type mismatch, a route regression, or a browser flow. package.json tsconfig.base.json
The workspace tree also holds tests for behaviors that do not need a browser. Core’s package tests can exercise runtime decisions directly, and the separate stream suite checks the versioned updates that cross the HTTP boundary. Before adding a browser case, check whether the behavior lives at one of those smaller boundaries. runtime.test.ts sse-delta.test.ts
The TypeScript configuration supports the same split. The shared compiler settings allow explicit TypeScript extensions and set noEmit, so a type check does not create a second copy of the server sources. The web package builds the files that the browser actually loads. tsconfig.base.json package.json
The checkout tells you where to read. Where do the conversation, the model, and a file the assistant edits actually live? Where everything lives and runs moves from the source tree to the machines.
Recap
- Web owns the screen, server owns HTTP, and core owns conversation rules.
- The browser uses HTTP and an event stream. Hono calls the runtime directly.
- Use the question you have to pick the file, then find a test at the same boundary.
- You want to change how the message route reads a request. Where do you start?
- app.ts in server
- App.svelte in web
- agents/chat.md
Answer and explanation
app.ts in server
The Hono route reads the request and hands the input to core.
- You want to check whether a busy chat can accept another message. Which code decides?
- The sidebar
- Core’s admission rules
- The Caddy configuration
Answer and explanation
Core’s admission rules
Core applies the conversation rules. Hono carries the result back to the browser.
- Where would you look for a test that kills Pipal during a reply?
- The profile folder
- The server manifest
- tests/recovery.test.ts
Answer and explanation
tests/recovery.test.ts
The recovery suite kills a child process and opens the same store in a fresh process.
You want to change how the message route reads a request. Where do you start?
You want to check whether a busy chat can accept another message. Which code decides?
Where would you look for a test that kills Pipal during a reply?