acpx 0.1.0 → 0.1.3

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/LICENSE CHANGED
@@ -1,15 +1,21 @@
1
- Apache License
2
- Version 2.0, January 2004
3
- http://www.apache.org/licenses/
1
+ MIT License
4
2
 
5
- Licensed under the Apache License, Version 2.0 (the "License");
6
- you may not use this file except in compliance with the License.
7
- You may obtain a copy of the License at
3
+ Copyright (c) 2026 Janitr AI
8
4
 
9
- http://www.apache.org/licenses/LICENSE-2.0
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
10
11
 
11
- Unless required by applicable law or agreed to in writing, software
12
- distributed under the License is distributed on an "AS IS" BASIS,
13
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
- See the License for the specific language governing permissions and
15
- limitations under the License.
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,102 +1,173 @@
1
1
  # acpx
2
2
 
3
- Headless CLI client for the [Agent Client Protocol (ACP)](https://agentclientprotocol.com) — talk to coding agents from the command line.
3
+ Your agents love acpx! 🤖❤️ They hate having to scrape characters from a PTY session 😤
4
+
5
+ `acpx` is a headless CLI client for the [Agent Client Protocol (ACP)](https://agentclientprotocol.com), so AI agents and orchestrators can talk to coding agents over a structured protocol instead of PTY scraping.
6
+
7
+ One command surface for Codex, Claude, Gemini, OpenCode, Pi, or custom ACP servers. Built for agent-to-agent communication over the command line.
8
+
9
+ - **Persistent sessions**: multi-turn conversations that survive across invocations, scoped per repo
10
+ - **Named sessions**: run parallel workstreams in the same repo (`-s backend`, `-s frontend`)
11
+ - **Prompt queueing**: submit prompts while one is already running, they execute in order
12
+ - **Soft-close lifecycle**: close sessions without deleting history from disk
13
+ - **Queue owner TTL**: keep queue owners alive briefly for follow-up prompts (`--ttl`)
14
+ - **Fire-and-forget**: `--no-wait` queues a prompt and returns immediately
15
+ - **Structured output**: typed ACP messages (thinking, tool calls, diffs) instead of ANSI scraping
16
+ - **Any ACP agent**: built-in registry + `--agent` escape hatch for custom servers
17
+ - **One-shot mode**: `exec` for stateless fire-and-forget tasks
4
18
 
5
19
  ```bash
6
- # One-shot: run a prompt against Codex, stream output, exit when done
7
- acpx run --agent codex-acp --cwd ./my-project "Refactor the auth module"
8
-
9
- # Multi-turn: create a session, send messages
10
- acpx session create --agent codex-acp --cwd ./my-project
11
- acpx session send <id> "Refactor the auth module"
12
- acpx session send <id> "Now add tests"
13
- acpx session close <id>
14
- ```
20
+ $ acpx codex "find the flaky test and fix it"
21
+
22
+ [thinking] Investigating test suite for flaky failures
23
+
24
+ [tool] Run npm test -- --reporter=verbose (running)
25
+ [tool] Run npm test -- --reporter=verbose (completed)
26
+ output:
27
+ auth.login (0.8s)
28
+ ✗ checkout.submit (timed out after 5000ms)
29
+ ✓ cart.add (0.3s)
15
30
 
16
- ## Why?
31
+ [thinking] Found it — checkout.submit has a race condition in the async setup
17
32
 
18
- ACP adapters exist for every major coding agent ([Codex](https://github.com/zed-industries/codex-acp), [Claude Code](https://github.com/zed-industries/claude-code-acp), [Gemini CLI](https://github.com/google-gemini/gemini-cli), etc.) but every ACP client is a GUI app or editor plugin.
33
+ [tool] Edit src/checkout.test.ts (completed)
34
+ output:
35
+ Success. Updated 1 file.
19
36
 
20
- `acpx` is the missing piece: a simple CLI that lets **agents talk to agents** (or humans script agents) over structured ACP instead of scraping terminal output.
37
+ [tool] Run npm test -- checkout.submit (completed)
38
+ output:
39
+ ✓ checkout.submit (0.4s)
40
+
41
+ Fixed: added `await` to the setup hook in checkout.submit. The test was
42
+ reading stale state from the previous run.
43
+
44
+ [done] end_turn
45
+ ```
21
46
 
22
47
  ## Install
23
48
 
24
49
  ```bash
25
- npm install -g acpx
26
- # or
27
- npx acpx run --agent codex-acp "Hello"
50
+ npm i -g acpx
28
51
  ```
29
52
 
30
- ### Prerequisites
53
+ `acpx` manages persistent sessions, so prefer a global install. Avoid `npx acpx ...` for normal use.
31
54
 
32
- You need an ACP-compatible agent installed:
55
+ ## Agent prerequisites
33
56
 
34
- ```bash
35
- # Codex
36
- npm install -g @zed-industries/codex-acp
37
-
38
- # Claude Code
39
- npm install -g @zed-industries/claude-code-acp
57
+ `acpx` auto-downloads ACP adapters with `npx` on first use. You do not need to install adapter packages manually.
40
58
 
41
- # Gemini CLI (native ACP support)
42
- npm install -g @google/gemini-cli
43
- ```
59
+ The only prerequisite is the underlying coding agent you want to use:
44
60
 
45
- ## Usage
61
+ - `acpx codex` -> Codex CLI: https://codex.openai.com
62
+ - `acpx claude` -> Claude Code: https://claude.ai/code
63
+ - `acpx gemini` -> Gemini CLI: https://github.com/google/gemini-cli
64
+ - `acpx opencode` -> OpenCode: https://opencode.ai
65
+ - `acpx pi` -> Pi Coding Agent: https://github.com/mariozechner/pi
46
66
 
47
- ### One-shot (`run`)
67
+ ## Usage examples
48
68
 
49
69
  ```bash
50
- # Simple prompt
51
- acpx run --agent codex-acp --cwd /repo "Fix the failing tests"
70
+ acpx codex 'fix the tests' # implicit prompt (persistent session)
71
+ acpx codex prompt 'fix the tests' # explicit prompt subcommand
72
+ acpx codex --no-wait 'draft test migration plan' # enqueue without waiting if session is busy
73
+ acpx exec 'summarize this repo' # default agent shortcut (codex)
74
+ acpx codex exec 'what does this repo do?' # one-shot, no saved session
75
+
76
+ acpx codex -s api 'implement cursor pagination' # named session
77
+ acpx codex -s docs 'rewrite API docs' # parallel work in another named session
78
+
79
+ acpx codex sessions # list sessions for codex command
80
+ acpx codex sessions list # explicit list
81
+ acpx codex sessions new # create fresh cwd-scoped default session
82
+ acpx codex sessions new --name api # create fresh named session
83
+ acpx codex sessions close # close cwd-scoped default session
84
+ acpx codex sessions close api # close cwd-scoped named session
85
+
86
+ acpx claude 'refactor auth middleware' # built-in claude agent
87
+ acpx gemini 'add startup logging' # built-in gemini agent
88
+
89
+ acpx my-agent 'review this patch' # unknown name -> raw command
90
+ acpx --agent './bin/dev-acp --profile ci' 'run checks' # --agent escape hatch
91
+ ```
52
92
 
53
- # Auto-approve all tool calls
54
- acpx run --agent codex-acp --cwd /repo --approve-all "Build a REST API"
93
+ ## Practical scenarios
55
94
 
56
- # JSON output for programmatic use
57
- acpx run --agent codex-acp --cwd /repo --format json "Add logging"
95
+ ```bash
96
+ # Review a PR in a dedicated session and auto-approve permissions
97
+ acpx --cwd ~/repos/shop --approve-all codex -s pr-842 \
98
+ 'Review PR #842 for regressions and propose a minimal fix'
58
99
 
59
- # Pipe prompt from stdin
60
- echo "Refactor to async/await" | acpx run --agent codex-acp --cwd /repo
100
+ # Keep parallel streams for the same repo
101
+ acpx codex -s bugfix 'isolate flaky checkout test'
102
+ acpx codex -s release 'draft release notes from recent commits'
61
103
  ```
62
104
 
63
- ### Multi-turn sessions
105
+ ## Global options in practice
64
106
 
65
107
  ```bash
66
- # Create session
67
- acpx session create --agent codex-acp --cwd /repo
68
- # abc123
108
+ acpx --approve-all codex 'apply the patch and run tests'
109
+ acpx --approve-reads codex 'inspect repo structure and suggest plan' # default mode
110
+ acpx --deny-all codex 'explain what you can do without tool access'
111
+
112
+ acpx --cwd ~/repos/backend codex 'review recent auth changes'
113
+ acpx --format text codex 'summarize your findings'
114
+ acpx --format json codex exec 'review changed files'
115
+ acpx --format quiet codex 'final recommendation only'
116
+
117
+ acpx --timeout 90 codex 'investigate intermittent test timeout'
118
+ acpx --ttl 30 codex 'keep queue owner alive for quick follow-ups'
119
+ acpx --verbose codex 'debug why adapter startup is failing'
120
+ ```
69
121
 
70
- # Send messages (streams results, exits on completion)
71
- acpx session send abc123 "Refactor the auth module"
72
- acpx session send abc123 "Now add tests for it"
122
+ ## Output formats
73
123
 
74
- # List sessions
75
- acpx session list
124
+ ```bash
125
+ # text (default): human-readable stream with tool updates
126
+ acpx codex 'review this PR'
127
+
128
+ # json: NDJSON events, useful for automation
129
+ acpx --format json codex exec 'review this PR' \
130
+ | jq -r 'select(.type=="tool_call") | [.status, .title] | @tsv'
76
131
 
77
- # Close when done
78
- acpx session close abc123
132
+ # quiet: final assistant text only
133
+ acpx --format quiet codex 'give me a 3-line summary'
79
134
  ```
80
135
 
81
- ### Output formats
136
+ ## Built-in agents and custom servers
82
137
 
83
- | Format | Flag | Description |
84
- |--------|------|-------------|
85
- | text | `--format text` | Human-readable streaming (default) |
86
- | json | `--format json` | Structured ndjson for machines |
87
- | quiet | `--format quiet` | Final text output only |
138
+ Built-ins:
88
139
 
89
- ## How it works
140
+ | Agent | Adapter | Wraps |
141
+ | ---------- | ---------------------------------------------------------------------- | ----------------------------------------------------- |
142
+ | `codex` | [codex-acp](https://github.com/zed-industries/codex-acp) | [Codex CLI](https://codex.openai.com) |
143
+ | `claude` | [claude-agent-acp](https://github.com/zed-industries/claude-agent-acp) | [Claude Code](https://claude.ai/code) |
144
+ | `gemini` | native | [Gemini CLI](https://github.com/google/gemini-cli) |
145
+ | `opencode` | native | [OpenCode](https://opencode.ai) |
146
+ | `pi` | [pi-acp](https://github.com/svkozak/pi-acp) | [Pi Coding Agent](https://github.com/mariozechner/pi) |
90
147
 
148
+ Use `--agent` as an escape hatch for custom ACP servers:
149
+
150
+ ```bash
151
+ acpx --agent ./my-custom-acp-server 'do something'
91
152
  ```
92
- ┌─────────┐ stdio/ndjson ┌──────────────┐ wraps ┌─────────┐
93
- │ acpx │ ◄──────────────────► │ ACP adapter │ ◄───────────► │ Agent │
94
- │ (client) │ ACP protocol │ (codex-acp) │ │ (Codex) │
95
- └─────────┘ └──────────────┘ └─────────┘
96
- ```
97
153
 
98
- acpx spawns the ACP adapter as a child process, communicates over the ACP protocol (JSON-RPC over stdio), and translates structured events (tool calls, text, permissions) into CLI output.
154
+ ## Session behavior
155
+
156
+ - Prompt commands use saved sessions scoped to `(agent command, cwd, optional name)`.
157
+ - `-s <name>` creates/selects a parallel named session in the same repo.
158
+ - `sessions new [--name <name>]` creates a fresh session for that scope and soft-closes the prior one.
159
+ - `sessions close [name]` soft-closes the session: queue owner/processes are terminated, record is kept with `closed: true`.
160
+ - Auto-resume for cwd scope skips sessions marked closed.
161
+ - Prompt submissions are queue-aware per session. If a prompt is already running, new prompts are queued and drained by the running `acpx` process.
162
+ - Queue owners use an idle TTL (default 300s). `--ttl <seconds>` overrides it; `--ttl 0` keeps owners alive indefinitely.
163
+ - `--no-wait` submits to that queue and returns immediately.
164
+ - `exec` is always one-shot and does not reuse saved sessions.
165
+ - Session metadata is stored under `~/.acpx/sessions/`.
166
+
167
+ ## Full CLI reference
168
+
169
+ See `docs/CLI.md`.
99
170
 
100
171
  ## License
101
172
 
102
- Apache-2.0
173
+ MIT
package/dist/cli.d.ts CHANGED
@@ -1 +1,5 @@
1
1
  #!/usr/bin/env node
2
+ declare function parseTtlSeconds(value: string): number;
3
+ declare function main(argv?: string[]): Promise<void>;
4
+
5
+ export { main, parseTtlSeconds };