agentp 1.13.0 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CONTRIBUTING.md +80 -83
- package/README.md +135 -48
- package/bin/agentp +337 -75
- package/bin/ocmux +1075 -440
- package/docs/specification.md +12 -449
- package/docs/specification_v2.md +611 -0
- package/lib/ocmux.js +124 -173
- package/lib/opencode.js +563 -356
- package/lib/project-state.js +205 -0
- package/package.json +1 -1
package/CONTRIBUTING.md
CHANGED
|
@@ -2,9 +2,20 @@
|
|
|
2
2
|
|
|
3
3
|
## Introduction
|
|
4
4
|
|
|
5
|
-
agentp is a collection of three zero-dependency Node.js CLI tools that
|
|
5
|
+
agentp is a collection of three **zero-dependency** Node.js CLI tools that
|
|
6
|
+
extend [OpenCode](https://opencode.ai) v2:
|
|
6
7
|
|
|
7
|
-
|
|
8
|
+
- **`agentp`** — pipes prompt text into a running OpenCode session and streams the answer back to stdout.
|
|
9
|
+
- **`ocmux`** — manages per-project TUI windows in tmux (session picker, project switcher, create/rename/delete/annotate sessions) on top of a single **user-managed** OpenCode server.
|
|
10
|
+
- **`tgagentp`** — bridges a Telegram bot chat with OpenCode (multi-chat, multi-server, file sharing). *Experimental.*
|
|
11
|
+
|
|
12
|
+
The project aims to stay **zero npm dependencies** — everything uses only the
|
|
13
|
+
Node.js 18+ stdlib (`http`, `https`, `readline`, `url`, `child_process`, `fs`,
|
|
14
|
+
`path`, `crypto`, `os`). PRs introducing new dependencies will not be accepted
|
|
15
|
+
unless there is an exceptional justification.
|
|
16
|
+
|
|
17
|
+
**OpenCode v2 only.** OpenCode v1 support was removed in 2.0.0; there are no
|
|
18
|
+
legacy code paths. The HTTP client lives in `lib/opencode.js`.
|
|
8
19
|
|
|
9
20
|
## Development Setup
|
|
10
21
|
|
|
@@ -12,7 +23,8 @@ The project aims to stay **zero npm dependencies** — all tools use only the No
|
|
|
12
23
|
|
|
13
24
|
- Node.js >= 18
|
|
14
25
|
- npm (ships with Node.js)
|
|
15
|
-
- tmux (
|
|
26
|
+
- tmux (only needed for `ocmux` and `tgagentp`)
|
|
27
|
+
- an OpenCode v2 server for manual testing (`opencode serve`)
|
|
16
28
|
|
|
17
29
|
### Local Install
|
|
18
30
|
|
|
@@ -21,119 +33,104 @@ git clone <your-fork>
|
|
|
21
33
|
cd agentp
|
|
22
34
|
npm link # registers bin/agentp, bin/ocmux, bin/tgagentp globally
|
|
23
35
|
# or
|
|
24
|
-
npm install -g .
|
|
36
|
+
npm install -g .
|
|
25
37
|
```
|
|
26
38
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
### Code Map
|
|
39
|
+
## Code Map
|
|
30
40
|
|
|
31
41
|
```
|
|
32
42
|
agentp/
|
|
33
43
|
├── bin/
|
|
34
|
-
│ ├── agentp
|
|
35
|
-
│ ├── ocmux
|
|
36
|
-
│ └── tgagentp
|
|
44
|
+
│ ├── agentp — stdin-to-session pipe
|
|
45
|
+
│ ├── ocmux — project/TUI window manager + interactive pickers
|
|
46
|
+
│ └── tgagentp — Telegram bot bridge
|
|
37
47
|
├── lib/
|
|
38
|
-
│ ├── opencode.js
|
|
39
|
-
│
|
|
40
|
-
├──
|
|
41
|
-
│ ├──
|
|
42
|
-
│
|
|
48
|
+
│ ├── opencode.js — OpenCode v2 HTTP/SSE client (shared by all three)
|
|
49
|
+
│ ├── ocmux.js — tmux helpers (shared by ocmux + tgagentp)
|
|
50
|
+
│ ├── project-state.js — `.ocmux.json` v2 schema + per-session reminders
|
|
51
|
+
│ ├── tui-cmd.js — tmux send-keys passthrough (tgagentp)
|
|
52
|
+
│ ├── file-share.js — telegram-shared directory + upload/download
|
|
53
|
+
│ └── telegram-*.js — Telegram API + formatting helpers
|
|
54
|
+
├── tests/ — node:test suites (one per module)
|
|
43
55
|
├── docs/
|
|
44
|
-
│
|
|
45
|
-
|
|
46
|
-
├──
|
|
56
|
+
│ ├── specification.md — short pointer (superseded)
|
|
57
|
+
│ └── specification_v2.md — current architecture reference
|
|
58
|
+
├── AGENTS.md — agent/dev notes
|
|
59
|
+
├── CONTRIBUTING.md — this file
|
|
47
60
|
└── package.json
|
|
48
61
|
```
|
|
49
62
|
|
|
50
63
|
## Coding Standards
|
|
51
64
|
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
- **
|
|
56
|
-
|
|
57
|
-
-
|
|
58
|
-
- Single quotes for strings
|
|
59
|
-
- `const` over `let`; avoid `var`
|
|
60
|
-
- Arrow functions for callbacks and closures
|
|
65
|
+
- **CommonJS** (`require` / `module.exports`) — no ES modules.
|
|
66
|
+
- **2-space indentation**, single quotes, `const` over `let` (avoid `var`),
|
|
67
|
+
`async/await` over `.then()`.
|
|
68
|
+
- **Semicolons are used** in `bin/` and `lib/` — except `lib/tui-cmd.js`, which
|
|
69
|
+
is deliberately no-semicolons. Match the file you are editing.
|
|
70
|
+
- Comments are welcome and present throughout; keep them meaningful.
|
|
61
71
|
|
|
62
72
|
### Conventions
|
|
63
73
|
|
|
64
|
-
-
|
|
65
|
-
-
|
|
66
|
-
|
|
67
|
-
-
|
|
68
|
-
|
|
74
|
+
- **HTTP:** use `lib/opencode.js` helpers — never raw `http.request`.
|
|
75
|
+
- **tmux:** use `lib/ocmux.js` helpers (`_tmux` / exported wrappers) — never raw
|
|
76
|
+
`spawnSync`.
|
|
77
|
+
- **State:** `.ocmux.json` I/O goes through `lib/project-state.js`
|
|
78
|
+
(`readProjectState`, `writeProjectState`, `readAnnotations`, `writeAnnotation`,
|
|
79
|
+
atomic writes). Never hand-roll reads/writes.
|
|
80
|
+
- **Logging:** `tgagentp` uses `log.info`/`log.error`/`log.debug` (never bare
|
|
81
|
+
`console.log`). `agentp`/`ocmux` use `console.log` for CLI stdout (answers,
|
|
82
|
+
lists, `--version`) and `console.error` for diagnostics.
|
|
69
83
|
|
|
70
84
|
### Architecture Rules
|
|
71
85
|
|
|
72
|
-
1. **Zero npm dependencies.**
|
|
73
|
-
2. **`bin
|
|
74
|
-
3. **`bin/tgagentp
|
|
75
|
-
|
|
76
|
-
|
|
86
|
+
1. **Zero npm dependencies.** `package.json` `"dependencies"` must remain empty.
|
|
87
|
+
2. **`bin/` entry points stay thin**; business logic goes in `lib/`.
|
|
88
|
+
3. **`bin/tgagentp` is the largest file (~3000 lines).** Extract reusable logic
|
|
89
|
+
into `lib/` when adding features.
|
|
90
|
+
4. **Mockable externals.** All network/subprocess/filesystem access must be
|
|
91
|
+
interceptable (the existing test suites mock `http.request`,
|
|
92
|
+
`child_process.spawnSync`, and `fs.*`).
|
|
93
|
+
5. **Sessions created via the API have no model** and will not execute prompts
|
|
94
|
+
until one is set — always create them with `createSessionWithModel`.
|
|
77
95
|
|
|
78
96
|
## Running Tests
|
|
79
97
|
|
|
80
|
-
Tests use
|
|
98
|
+
Tests use the built-in `node:test` runner (no extra dependencies). Every
|
|
99
|
+
external interface is mocked, so the suite runs fully in-process and is safe to
|
|
100
|
+
run alongside a live OpenCode instance.
|
|
81
101
|
|
|
82
102
|
```bash
|
|
83
|
-
#
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
# Run a specific test file
|
|
87
|
-
node --test tests/opencode.test.js
|
|
103
|
+
npm test # all suites
|
|
104
|
+
node --test tests/opencode.test.js # one file
|
|
88
105
|
node --test tests/ocmux.test.js
|
|
89
|
-
|
|
90
|
-
# Run with verbose output
|
|
91
|
-
node --test tests/opencode.test.js | bunyan # or just grep for results
|
|
106
|
+
node --test tests/project-state.test.js
|
|
92
107
|
```
|
|
93
108
|
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
Tests are structured in phases (see `AGENTS.md` for the full plan):
|
|
99
|
-
|
|
100
|
-
| Phase | Module | Boundary Mocked |
|
|
101
|
-
|-------|--------|----------------|
|
|
102
|
-
| 1a | `lib/opencode.js` | `http.request` |
|
|
103
|
-
| 1b | `lib/ocmux.js` | `child_process.spawnSync`, `child_process.execSync`, `fs.*` |
|
|
104
|
-
|
|
105
|
-
Each test file uses `node:test`'s `mock` API in `before()`/`after()` hooks to install and tear down mocks. Tests within a describe block run serially (`concurrency: false`) when they share mocked state.
|
|
109
|
+
Mock boundaries are installed in `before()`/`after()` (opencode) or
|
|
110
|
+
`beforeEach()`/`afterEach()` (ocmux) hooks. Tests that share mocked state run
|
|
111
|
+
serially (`concurrency: false`).
|
|
106
112
|
|
|
107
113
|
### Adding Tests
|
|
108
114
|
|
|
109
|
-
1.
|
|
110
|
-
2. Use `describe
|
|
111
|
-
3.
|
|
112
|
-
4.
|
|
113
|
-
5. Run the full suite before submitting a PR
|
|
115
|
+
1. Add them to the matching `tests/<module>.test.js`.
|
|
116
|
+
2. Use `describe`/`it`/`before`/`after` from `node:test` and `node:assert`.
|
|
117
|
+
3. Mock every external boundary.
|
|
118
|
+
4. Run the full suite before opening a PR.
|
|
114
119
|
|
|
115
120
|
## Pull Request Process
|
|
116
121
|
|
|
117
|
-
1.
|
|
118
|
-
2.
|
|
119
|
-
3.
|
|
120
|
-
4.
|
|
121
|
-
-
|
|
122
|
-
- `docs/
|
|
123
|
-
-
|
|
124
|
-
- `
|
|
125
|
-
5.
|
|
126
|
-
6.
|
|
127
|
-
|
|
128
|
-
### Review Process
|
|
129
|
-
|
|
130
|
-
- Maintainers review within a few business days
|
|
131
|
-
- Focus areas: mock correctness, zero-dependency rule, architectural consistency
|
|
132
|
-
- Large changes may be asked to split into smaller PRs
|
|
133
|
-
- All PRs must pass the test suite before merging
|
|
122
|
+
1. Fork the repo and branch from `main`.
|
|
123
|
+
2. Follow the coding standards above.
|
|
124
|
+
3. Run `npm test` — all suites must pass.
|
|
125
|
+
4. Update documentation when user-facing behavior changes:
|
|
126
|
+
- `README.md` (usage/behavior),
|
|
127
|
+
- `docs/specification_v2.md` (architecture),
|
|
128
|
+
- `AGENTS.md` (test counts / non-obvious facts),
|
|
129
|
+
- `CHANGELOG.md` (with every release).
|
|
130
|
+
5. Commit with a descriptive message (`fix:`, `feat:`, `refactor:`, `docs:` …).
|
|
131
|
+
6. Open a PR against `main` with a summary and testing instructions.
|
|
134
132
|
|
|
135
133
|
## Getting Help
|
|
136
134
|
|
|
137
|
-
- Open
|
|
138
|
-
-
|
|
139
|
-
- For OpenCode-specific questions, refer to [opencode.ai](https://opencode.ai)
|
|
135
|
+
- Open a GitHub issue for bugs or feature requests.
|
|
136
|
+
- For OpenCode-specific questions, refer to [opencode.ai](https://opencode.ai).
|
package/README.md
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
This package provides three CLI tools:
|
|
9
9
|
|
|
10
10
|
- **`agentp`** — pipes prompt text into a running OpenCode server and streams the assistant final answer back to stdout
|
|
11
|
-
- **`ocmux`** — manages
|
|
11
|
+
- **`ocmux`** — manages project TUI windows in tmux on top of a single user-managed OpenCode server (session picker, project switcher, create/rename/delete/annotate sessions)
|
|
12
12
|
- **`tgagentp`** — bridges a Telegram bot chat with all running OpenCode servers (receives messages from Telegram, routes them to the active server, sends answers back). Supports slash commands for multi-server management, session switching, agent/model listing, including file sharing from the chat.
|
|
13
13
|
|
|
14
14
|
It is designed for prompt-driven workflows where you want to do things like:
|
|
@@ -41,14 +41,41 @@ npm link
|
|
|
41
41
|
## Requirements
|
|
42
42
|
|
|
43
43
|
- Node.js 18+
|
|
44
|
-
-
|
|
44
|
+
- **OpenCode v2** (`opencode serve`) — the server is user-managed; these tools only check it is reachable and complain otherwise.
|
|
45
|
+
- [tmux](https://github.com/tmux/tmux) when using `ocmux` (project TUI windows).
|
|
45
46
|
|
|
46
|
-
|
|
47
|
+
## Servers
|
|
48
|
+
|
|
49
|
+
The OpenCode server is **user-managed**: start it yourself (e.g. `opencode serve`).
|
|
50
|
+
`agentp` and `ocmux` only *check* that it is reachable and complain otherwise.
|
|
51
|
+
|
|
52
|
+
- Each project records the server it uses in `.ocmux.json` (`"server"`). If that
|
|
53
|
+
server is not reachable:
|
|
54
|
+
- `agentp` exits with `Error connecting to server: …`;
|
|
55
|
+
- `ocmux` exits with `OpenCode server not reachable at <url>.`
|
|
56
|
+
- **Point somewhere else for one command** (without touching any file):
|
|
57
|
+
|
|
58
|
+
```bash
|
|
59
|
+
cat prompt.txt | agentp --server http://127.0.0.1:4097
|
|
60
|
+
# or the positional form:
|
|
61
|
+
cat prompt.txt | agentp http://127.0.0.1:4097
|
|
62
|
+
```
|
|
47
63
|
|
|
48
|
-
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
64
|
+
- **Repoint an existing project** (e.g. the server moved to a new port/host) and
|
|
65
|
+
relaunch its TUI on the stored session:
|
|
66
|
+
|
|
67
|
+
```bash
|
|
68
|
+
ocmux serve --server http://127.0.0.1:4097 --force
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
Without `--force`, `ocmux serve` refuses when `.ocmux.json` already exists.
|
|
72
|
+
|
|
73
|
+
- **Remote or containerized servers** work too: pass any host reachable over
|
|
74
|
+
HTTP, e.g. a published Docker port (`--server http://192.168.1.50:4096`) or an
|
|
75
|
+
SSH tunnel. Auth uses `OPENCODE_SERVER_PASSWORD`/`OPENCODE_SERVER_USERNAME`.
|
|
76
|
+
The client speaks **HTTP only** (no `https://`). Note that `ocmux` launches the
|
|
77
|
+
*local* `opencode --server <url>` for the TUI, so use a local OpenCode version
|
|
78
|
+
compatible with the remote server.
|
|
52
79
|
|
|
53
80
|
## Usage
|
|
54
81
|
|
|
@@ -67,6 +94,7 @@ Options:
|
|
|
67
94
|
- `--getLast <n>`: retrieve last n assistant answers from session history
|
|
68
95
|
- `--session <name>`: target a specific session by name (exact or partial match)
|
|
69
96
|
- `--new`: create a new session with the given title (requires `--session`)
|
|
97
|
+
- `--server <url>`: use this OpenCode server instead of the one in `.ocmux.json` (e.g. `http://host:4096`)
|
|
70
98
|
- `--version`: show version
|
|
71
99
|
- `--help`: show help message
|
|
72
100
|
|
|
@@ -82,8 +110,8 @@ With `--tg`, errors if tgagentp is unavailable.
|
|
|
82
110
|
|
|
83
111
|
Arguments:
|
|
84
112
|
|
|
85
|
-
- `url`: OpenCode
|
|
86
|
-
-
|
|
113
|
+
- `url`: OpenCode server URL or port number (defaults to `4096`). Examples: `4096`, `http://localhost:4096`, `http://192.168.1.50:4096`
|
|
114
|
+
- Omit it and agentp resolves the project itself: the nearest `.ocmux.json` (upward from the working directory) supplies the server URL, the project directory, and the target session id. `agentp $(ocmux)` still works as an override, but is no longer needed.
|
|
87
115
|
|
|
88
116
|
## Examples
|
|
89
117
|
|
|
@@ -189,6 +217,7 @@ The ticket is `agentp_ticket` followed by a JSON object with these fields:
|
|
|
189
217
|
- `sessionId` — OpenCode session ID used by the deferred job.
|
|
190
218
|
- `elapsed` — seconds since `ctime`, included only when the ticket is re-printed (not on first print).
|
|
191
219
|
- `defer` — the timeout requested at submission, included only when it was > 0.
|
|
220
|
+
- `cancelled` — always present (defaults to `false`). Set it to `true` and pipe the ticket back to cancel the running job (see below).
|
|
192
221
|
|
|
193
222
|
Tickets are printed as pretty-printed (multi-line) JSON for easier reading and
|
|
194
223
|
editing; pass `--onlineTicket` to print them on a single line instead:
|
|
@@ -233,6 +262,27 @@ the ticket's own `defer` value as the timeout (default `0`):
|
|
|
233
262
|
- If the answer is ready, it is returned and the temp file is removed.
|
|
234
263
|
- If not, the ticket is re-printed with the elapsed time updated.
|
|
235
264
|
|
|
265
|
+
Cancel a running deferred job by flipping `cancelled` to `true` and piping the
|
|
266
|
+
ticket back (the equivalent of pressing `ESC` in the TUI window):
|
|
267
|
+
|
|
268
|
+
```bash
|
|
269
|
+
cat <<'EOF' | agentp --defer
|
|
270
|
+
agentp_ticket {
|
|
271
|
+
"ctime": "2026-08-03T14:30:00.000Z",
|
|
272
|
+
"path": "/tmp/agentp_deferred_...tmp",
|
|
273
|
+
"server": "http://localhost:4096",
|
|
274
|
+
"sessionId": "ses_abc123",
|
|
275
|
+
"cancelled": true
|
|
276
|
+
}
|
|
277
|
+
EOF
|
|
278
|
+
# 🚫 Prompt cancelled.
|
|
279
|
+
```
|
|
280
|
+
|
|
281
|
+
`agentp` interrupts the session's execution (`POST /api/session/:id/interrupt`),
|
|
282
|
+
discards the ticket and its queued follow-ups, and prints
|
|
283
|
+
`🚫 Prompt cancelled` (with `(or already finished)` when there was nothing left
|
|
284
|
+
to interrupt).
|
|
285
|
+
|
|
236
286
|
Works as a Vim/Neovim filter with deferred execution:
|
|
237
287
|
|
|
238
288
|
```vim
|
|
@@ -265,67 +315,89 @@ Useful to grab recent answers without sending a new prompt.
|
|
|
265
315
|
|
|
266
316
|
## ocmux
|
|
267
317
|
|
|
268
|
-
Manage
|
|
318
|
+
Manage **project TUI windows** in tmux on top of a single user-managed OpenCode
|
|
319
|
+
server. A project is a directory holding a `.ocmux.json` state file recording
|
|
320
|
+
the target session; an `Opencode` tmux session holds one window per project
|
|
321
|
+
(TUI only, pane 0).
|
|
269
322
|
|
|
270
323
|
```bash
|
|
271
324
|
ocmux [-l] [<subcommand>] [<directory>]
|
|
272
325
|
```
|
|
273
326
|
|
|
274
|
-
Without arguments
|
|
327
|
+
Without arguments (and with a TTY), opens an **interactive session picker** for
|
|
328
|
+
the project found upward from `<directory>` (default: `$PWD`):
|
|
275
329
|
|
|
276
|
-
|
|
330
|
+
- sessions are listed most-recently-viewed first
|
|
331
|
+
- `Enter`/`Space` switches (menu stays open) · `n` create (name input) ·
|
|
332
|
+
`r` rename (edit in place) · `R` set a reminder · `d` delete (confirm) ·
|
|
333
|
+
`a` switch agent · `m` switch model · `p` project switcher · `h` help ·
|
|
334
|
+
`q`/`Ctrl+C` quit
|
|
335
|
+
- switching updates `.ocmux.json` and relaunches the TUI on the chosen session
|
|
336
|
+
(`opencode --server <url> --session <id>`); silent on success
|
|
337
|
+
- new sessions inherit the model of the previously selected session (v2
|
|
338
|
+
sessions created via the API have no model and won't run a prompt until set)
|
|
277
339
|
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
- `--GIT` resolves `dir` to the nearest parent with a `.git` directory only; errors if none is found.
|
|
281
|
-
- `--print-logs` passes `--print-logs` to `opencode serve`, which prints server logs to stderr in the server tmux pane.
|
|
282
|
-
- **`kill [dir]`** — Kill the server found upward from `dir`. Removes its tmux window and state file.
|
|
283
|
-
- **`resurrect [--print-logs] [dir]`** — Recover a dead/crashed server: reads `.ocmux.json`, kills old tmux window, removes state file, then creates a fresh server + TUI in the same directory. Works even if no tmux window exists (stale state file).
|
|
284
|
-
- **`switch`** — Interactive session picker: an interactive menu of all running servers (columns: dirname, status, url, full path). Arrow keys or `j`/`k` move the selection; `Enter`/`Space` switches to the selected server's tmux window (the menu stays open, so you can hop between servers); `q` or `Ctrl+C` exits. The currently active server (queried live from tmux on every redraw) is highlighted across the full line width. Prints the URL of the last selected server on exit. Requires a TTY.
|
|
285
|
-
- **`list`** — List all running servers with their directories, URLs, and status.
|
|
340
|
+
Reminders (`R`) are stored in the `.ocmux.json` `annotations` map; `agentp`
|
|
341
|
+
prepends a session's reminder to every prompt sent to it.
|
|
286
342
|
|
|
287
|
-
|
|
343
|
+
Subcommands:
|
|
288
344
|
|
|
289
|
-
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
345
|
+
- **`serve [--server <url>] [--git|--GIT] [dir]`** — create a project TUI window
|
|
346
|
+
(checks the server is reachable first). Aliased as `new` for backwards
|
|
347
|
+
compatibility. `--git`/`--GIT` resolve `dir` to the nearest parent with a
|
|
348
|
+
`.git` entry / directory.
|
|
349
|
+
- **`session <id|title> [dir]`** — non-interactive session switch.
|
|
350
|
+
- **`list [-l]`** — list project windows (with `-l`, their server URL).
|
|
351
|
+
- **`model [ref]`** — switch the model of the selected session.
|
|
352
|
+
- **`kill [dir]`** — close the project's TUI window. **Keeps `.ocmux.json`**
|
|
353
|
+
(session memory; marks it `stopped`).
|
|
354
|
+
- **`resurrect [dir]`** — recreate the project window from its state file.
|
|
355
|
+
- **`migrate`** — rewrite legacy (v1-style) `.ocmux.json` files to the v2 schema.
|
|
356
|
+
|
|
357
|
+
The old `switch` subcommand is gone: press **`p`** inside the session picker to
|
|
358
|
+
open the (read-only) project switcher instead. `ocmux` never starts or stops the
|
|
359
|
+
OpenCode server — run `opencode serve` yourself (see [Versioning](#versioning)
|
|
360
|
+
for the pairing policy).
|
|
361
|
+
|
|
362
|
+
Options: `-l` · `--version` · `-h` · `--` (treat the next argument as a directory).
|
|
293
363
|
|
|
294
364
|
Notes:
|
|
295
365
|
|
|
296
|
-
- If `<directory>` is not a valid path, `ocmux`
|
|
297
|
-
|
|
298
|
-
-
|
|
299
|
-
|
|
300
|
-
### Requirements
|
|
301
|
-
|
|
302
|
-
- Node.js 18+
|
|
303
|
-
- [tmux](https://github.com/tmux/tmux) — session multiplexer
|
|
304
|
-
- `opencode` binary in PATH (the OpenCode CLI)
|
|
366
|
+
- If `<directory>` is not a valid path, `ocmux` matches it against the basenames
|
|
367
|
+
of existing project windows (exact unique match).
|
|
368
|
+
- If the server is password-protected (`OPENCODE_SERVER_PASSWORD`), both
|
|
369
|
+
`agentp` and `ocmux` send the required HTTP Basic Auth credentials.
|
|
305
370
|
|
|
306
371
|
### State file
|
|
307
372
|
|
|
308
|
-
|
|
373
|
+
`.ocmux.json` (in the project directory) stores `version`, `directory`,
|
|
374
|
+
`session`, and `server`. It is found by searching upward, like git. It is
|
|
375
|
+
gitignored — never commit it.
|
|
309
376
|
|
|
310
377
|
## How agentp Works
|
|
311
378
|
|
|
312
379
|
1. Reads all stdin into a single prompt string.
|
|
313
|
-
2.
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
the
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
380
|
+
2. Resolves the target from the nearest `.ocmux.json`: server URL, project
|
|
381
|
+
directory, and the stored session id (falls back to the most recently viewed
|
|
382
|
+
session in that directory, or creates one pinned to the directory).
|
|
383
|
+
3. Focuses the project's TUI window, prepends the session annotation (if any),
|
|
384
|
+
and sends the prompt via the v2 session API (`POST /api/session/:id/prompt`,
|
|
385
|
+
delivering to that session regardless of what the TUI shows).
|
|
386
|
+
4. Attaches to the SSE stream first so no events are missed, and streams text
|
|
387
|
+
until the session is quiescent after its terminal signal.
|
|
388
|
+
5. Prints the assistant answer to stdout (with `--qa`, a header with the project
|
|
389
|
+
path and session id/title before the prompt/answer rulers).
|
|
390
|
+
6. With `--tg` (or by default when `--qa` is given), forwards the answer to
|
|
391
|
+
Telegram via the agentp gateway. If tgagentp's [/record](#tgagentp) feature
|
|
392
|
+
was active, the gateway response includes the recorded conversation buffer,
|
|
393
|
+
which `--qa` prepends to stdout (use `--flush` to clear it).
|
|
325
394
|
|
|
326
395
|
Operational hint:
|
|
327
396
|
|
|
328
|
-
- You can keep a separate
|
|
397
|
+
- You can keep a separate TUI view open to see the full run context while
|
|
398
|
+
`agentp` is used from shell scripts or editor buffers:
|
|
399
|
+
`opencode --server '<url>' --session '<id>'` (or `--continue` for the last
|
|
400
|
+
session). `ocmux` manages these windows per project.
|
|
329
401
|
|
|
330
402
|
## tgagentp
|
|
331
403
|
|
|
@@ -446,6 +518,21 @@ Chat-to-server directory mappings are saved to `/tmp/tgagentp-connections.json`
|
|
|
446
518
|
| `TGAGENTP_DEBOUNCE_MS` | Optional. Debounce interval for queued-message notifications (default: `5000`). |
|
|
447
519
|
| `TGAGENTP_ROOT` | Optional. Root directory for `/serve` and `/new` commands (must be writable). |
|
|
448
520
|
|
|
521
|
+
## Versioning
|
|
522
|
+
|
|
523
|
+
The 1.x line was born with some internal inconsistency: early releases bumped
|
|
524
|
+
middle digits for small fixes, and `agentp`/`ocmux` were versioned independently
|
|
525
|
+
of the OpenCode they talked to. `2.0.0` marks a cleanup of that history — and a
|
|
526
|
+
single policy from now on:
|
|
527
|
+
|
|
528
|
+
> **agentp/ocmux/tgagentp share one version, and its major number is paired with
|
|
529
|
+
> the OpenCode major version they target.** OpenCode 2.x ⇒ this project lands in
|
|
530
|
+
> 2.x; if OpenCode ever ships a 3.0, a 3.x here targets it (the minor tracks
|
|
531
|
+
> features, the patch tracks fixes).
|
|
532
|
+
|
|
533
|
+
OpenCode v1 support was dropped in 2.0.0; the HTTP client (`lib/opencode.js`)
|
|
534
|
+
is v2-only and the tools assume `opencode serve` is user-managed.
|
|
535
|
+
|
|
449
536
|
## License
|
|
450
537
|
|
|
451
538
|
MIT
|