Skip to content
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@ opensessions/
│ │ │ │ ├── amp.ts
│ │ │ │ ├── claude-code.ts
│ │ │ │ ├── codex.ts
│ │ │ │ └── opencode.ts
│ │ │ │ ├── opencode.ts
│ │ │ │ ├── kilo.ts
│ │ │ │ └── pi.ts
│ │ │ ├── mux/ # Mux registry and detection helpers
│ │ │ ├── server/ # WebSocket server internals and launcher
│ │ │ ├── shared.ts # Shared types, constants, palette
Expand All @@ -38,7 +40,7 @@ opensessions/
│ │ ├── tmux/ # @opensessions/mux-tmux — tmux provider
│ │ └── zellij/ # @opensessions/mux-zellij — experimental zellij provider
│ └── tmux-sdk/ # @opensessions/tmux-sdk — lower-level tmux command wrapper
├── CONTRACTS.md # Agent integration guide (Amp, Claude Code, OpenCode, Aider)
├── CONTRACTS.md # Agent integration guide (Amp, Claude Code, OpenCode, Kilo, Aider, Pi)
├── turbo.json # Turborepo config
├── opensessions.tmux # Root TPM entrypoint
└── package.json # Bun workspace root
Expand All @@ -47,7 +49,7 @@ opensessions/
## Key Architecture Decisions

1. **Monorepo**: Turborepo + Bun workspaces, with `apps/` for runnable entrypoints and `packages/` for reusable libraries.
2. **Built-in agent watchers**: Core ships with `AmpAgentWatcher`, `ClaudeCodeAgentWatcher`, `CodexAgentWatcher`, and `OpenCodeAgentWatcher` that watch agent data directories directly. External agents integrate via the `AgentWatcher` plugin interface.
2. **Built-in agent watchers**: Core ships with `AmpAgentWatcher`, `ClaudeCodeAgentWatcher`, `CodexAgentWatcher`, `OpenCodeAgentWatcher`, `KiloAgentWatcher` and `PiAgentWatcher` that watch agent data directories directly. External agents integrate via the `AgentWatcher` plugin interface.
3. **Mux-agnostic**: `MuxProvider` interface abstracts all mux operations. `TmuxProvider` is the reference implementation.
4. **MuxProvider is SYNC**: All methods use `Bun.spawnSync` — matches the existing pattern and keeps the server simple.
5. **Auto-detect mux**: `detectMux()` checks `$TMUX`, `$ZELLIJ_SESSION_NAME` env vars. Config file override planned.
Expand Down Expand Up @@ -99,7 +101,7 @@ interface AgentWatcher {
- **Sync mux calls**: MuxProvider methods are synchronous. Don't make them async.
- **Preserve optimizations**: Batched tmux calls, 5s git cache with HEAD watchers, lightweight focus-only broadcasts.
- **Sidebar resize work**: Before changing sidebar spawning, width sync, tmux resize handling, or `sidebar-coordinator`, read `docs/explanation/sidebar-behavior.md` and preserve those invariants unless you update the doc in the same change.
- **Built-in watchers in runtime**: Amp, Claude Code, Codex, and OpenCode have built-in watchers in `packages/runtime/src/agents/watchers/`. Community agents use the `AgentWatcher` plugin interface.
- **Built-in watchers in runtime**: Amp, Claude Code, Codex, OpenCode, Kilo and Pi have built-in watchers in `packages/runtime/src/agents/watchers/`. Community agents use the `AgentWatcher` plugin interface.
- **OpenTUI Solid**: JSX needs `bunfig.toml` preload and `jsxImportSource: "@opentui/solid"` in tsconfig. Build needs `solidPlugin`.
- **Never call `process.exit()` directly in TUI**: Use `renderer.destroy()`.

Expand Down
16 changes: 15 additions & 1 deletion CONTRACTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ For end-user setup, start with the docs linked from [README.md](./README.md). Fo

## Built-In Watchers

opensessions currently registers four built-in watchers at server startup.
opensessions currently registers six built-in watchers at server startup.

### Amp

Expand Down Expand Up @@ -39,6 +39,20 @@ opensessions currently registers four built-in watchers at server startup.
- Polls every 3 seconds.
- Resolves mux sessions from the OpenCode session row's `directory` field.

### Kilo

- Polls `~/.local/share/kilo/kilo.db` or `$KILO_DB_PATH`.
- Uses `bun:sqlite` in read-only mode.
- Polls every 3 seconds.
- Resolves mux sessions from the Kilo session row's `directory` field.

### Pi

- Watches `~/.pi/agent/sessions/<encoded-path>/<timestamp>_<id>.jsonl`.
- Uses recursive `fs.watch` plus a 2 second polling pass.
- Skips stale transcript files older than 5 minutes.
- Resolves mux sessions from the `cwd` recorded on the `session` header entry.

## Agent Model

### `AgentStatus`
Expand Down
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ Then remove the `set -g @plugin 'Ataraxy-Labs/opensessions'` line from `~/.tmux.

## Today

- Live agent state across sessions for Amp, Claude Code, Codex, and OpenCode.
- Live agent state across sessions for Amp, Claude Code, Codex, OpenCode, Kilo and Pi.
- Per-thread unseen markers for `done`, `error`, and `interrupted` states.
- Session context in the UI: branch in the list, working directory in the detail panel, thread names, and detected localhost ports.
- Programmatic metadata API: agents and scripts push status, progress, and logs to the sidebar via HTTP.
Expand Down Expand Up @@ -145,6 +145,8 @@ For the full tmux workflow with keybindings, troubleshooting, and configuration
- Claude Code watcher reads JSONL transcripts in `~/.claude/projects/`.
- Codex watcher reads transcript JSONL files in `~/.codex/sessions/` or `$CODEX_HOME/sessions/` and resolves sessions from `turn_context.cwd`.
- OpenCode watcher polls the SQLite database in `~/.local/share/opencode/opencode.db`.
- Kilo watcher polls the SQLite database in `~/.local/share/kilo/kilo.db`.
- Pi watcher reads JSONL transcripts in `~/.pi/agent/sessions/`.
- Hidden sidebars are stashed in a tmux session named `_os_stash`, so they can come back without restarting the sidebar process.
- Clicking a detected port opens `http://localhost:<port>`.

Expand Down
2 changes: 2 additions & 0 deletions apps/server/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import {
ClaudeCodeAgentWatcher,
CodexAgentWatcher,
OpenCodeAgentWatcher,
KiloAgentWatcher,
PiAgentWatcher,
PluginLoader,
SERVER_HOST,
Expand Down Expand Up @@ -67,6 +68,7 @@ loader.registerWatcher(new AmpAgentWatcher());
loader.registerWatcher(new ClaudeCodeAgentWatcher());
loader.registerWatcher(new CodexAgentWatcher());
loader.registerWatcher(new OpenCodeAgentWatcher());
loader.registerWatcher(new KiloAgentWatcher());
loader.registerWatcher(new PiAgentWatcher());

const watchers = loader.getWatchers();
Expand Down
2 changes: 1 addition & 1 deletion docs/explanation/architecture.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ If no healthy server is listening on `127.0.0.1:7391`, `ensureServer()` launches
2. dynamically registers the built-in mux providers from `@opensessions/mux-tmux` and `@opensessions/mux-zellij`
3. loads local plugins and configured package plugins
4. resolves the primary mux provider
5. registers the built-in Amp, Claude Code, Codex, and OpenCode watchers
5. registers the built-in Amp, Claude Code, Codex, OpenCode, Kilo and Pi watchers
6. starts the WebSocket and HTTP control server

## State Assembly
Expand Down
1 change: 1 addition & 0 deletions docs/reference/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ All other tmux options fall back to the defaults shown in the table above.
| Variable | Used by | Notes |
| --- | --- | --- |
| `OPENCODE_DB_PATH` | OpenCode watcher | Overrides the default SQLite path |
| `KILO_DB_PATH` | Kilo watcher | Overrides the default SQLite path |
| `OPENSESSIONS_DIR` | tmux helper scripts and server | Helps helper scripts find the repo checkout |
| `OPENSESSIONS_HOST` | helper shell scripts | Script-level override only; the app runtime still uses `127.0.0.1` |
| `OPENSESSIONS_PORT` | helper shell scripts | Script-level override only; the app runtime still uses `7391` |
Expand Down
Loading