acpx 0.1.3 → 0.1.5
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/README.md +105 -6
- package/dist/cli.d.ts +32 -1
- package/dist/cli.js +3591 -798
- package/package.json +1 -1
- package/skills/acpx/SKILL.md +72 -5
package/README.md
CHANGED
|
@@ -9,14 +9,25 @@ One command surface for Codex, Claude, Gemini, OpenCode, Pi, or custom ACP serve
|
|
|
9
9
|
- **Persistent sessions**: multi-turn conversations that survive across invocations, scoped per repo
|
|
10
10
|
- **Named sessions**: run parallel workstreams in the same repo (`-s backend`, `-s frontend`)
|
|
11
11
|
- **Prompt queueing**: submit prompts while one is already running, they execute in order
|
|
12
|
+
- **Cooperative cancel command**: `cancel` sends ACP `session/cancel` via queue IPC without tearing down session state
|
|
12
13
|
- **Soft-close lifecycle**: close sessions without deleting history from disk
|
|
13
14
|
- **Queue owner TTL**: keep queue owners alive briefly for follow-up prompts (`--ttl`)
|
|
14
15
|
- **Fire-and-forget**: `--no-wait` queues a prompt and returns immediately
|
|
16
|
+
- **Graceful cancel**: `Ctrl+C` sends ACP `session/cancel` before force-kill fallback
|
|
17
|
+
- **Session controls**: `set-mode` and `set <key> <value>` for `session/set_mode` and `session/set_config_option`
|
|
18
|
+
- **Crash reconnect**: dead agent processes are detected and sessions are reloaded automatically
|
|
19
|
+
- **Prompt from file/stdin**: `--file <path>` or piped stdin for prompt content
|
|
20
|
+
- **Config files**: global + project JSON config with `acpx config show|init`
|
|
21
|
+
- **Session inspect/history**: `sessions show` and `sessions history --limit <n>`
|
|
22
|
+
- **Local status checks**: `status` reports running/dead/no-session, pid, uptime, last prompt
|
|
23
|
+
- **Client methods**: stable `fs/*` and `terminal/*` handlers with permission controls and cwd sandboxing
|
|
24
|
+
- **Auth handshake**: stable `authenticate` support via env/config credentials
|
|
15
25
|
- **Structured output**: typed ACP messages (thinking, tool calls, diffs) instead of ANSI scraping
|
|
16
26
|
- **Any ACP agent**: built-in registry + `--agent` escape hatch for custom servers
|
|
17
27
|
- **One-shot mode**: `exec` for stateless fire-and-forget tasks
|
|
18
28
|
|
|
19
29
|
```bash
|
|
30
|
+
$ acpx codex sessions new
|
|
20
31
|
$ acpx codex "find the flaky test and fix it"
|
|
21
32
|
|
|
22
33
|
[thinking] Investigating test suite for flaky failures
|
|
@@ -44,13 +55,50 @@ reading stale state from the previous run.
|
|
|
44
55
|
[done] end_turn
|
|
45
56
|
```
|
|
46
57
|
|
|
58
|
+
## Quick setup — tell your agent about acpx
|
|
59
|
+
|
|
60
|
+
Copy the block below and paste it into your OpenClaw, Pi, Claude Code, or similar agent harness. It will install acpx, read the skill reference, and know how to use ACP for all future coding agent tasks.
|
|
61
|
+
|
|
62
|
+
```text
|
|
63
|
+
I want you to use acpx to run coding agents over the Agent Client Protocol
|
|
64
|
+
(ACP) instead of scraping PTY sessions. Please do the following:
|
|
65
|
+
|
|
66
|
+
1. Install acpx (global is recommended for frequent use, but npx works fine too):
|
|
67
|
+
npm install -g acpx@latest
|
|
68
|
+
|
|
69
|
+
Or, run without installing:
|
|
70
|
+
npx acpx@latest
|
|
71
|
+
|
|
72
|
+
2. Install the acpx skill so you have the full reference available:
|
|
73
|
+
acpx --skill export acpx | npx skillflag install
|
|
74
|
+
|
|
75
|
+
3. Read the acpx skill reference so you know every command, flag, and
|
|
76
|
+
workflow pattern:
|
|
77
|
+
https://raw.githubusercontent.com/janitrai/acpx/main/skills/acpx/SKILL.md
|
|
78
|
+
|
|
79
|
+
4. If you need the full CLI reference with all options and examples:
|
|
80
|
+
https://raw.githubusercontent.com/janitrai/acpx/main/docs/CLI.md
|
|
81
|
+
|
|
82
|
+
From now on, when you need to delegate work to a coding agent, use acpx
|
|
83
|
+
instead of spawning raw terminal sessions. For example:
|
|
84
|
+
acpx codex "fix the failing tests"
|
|
85
|
+
acpx claude "refactor the auth module"
|
|
86
|
+
acpx codex exec "one-shot: summarize this repo"
|
|
87
|
+
```
|
|
88
|
+
|
|
47
89
|
## Install
|
|
48
90
|
|
|
49
91
|
```bash
|
|
50
|
-
npm
|
|
92
|
+
npm install -g acpx@latest
|
|
51
93
|
```
|
|
52
94
|
|
|
53
|
-
|
|
95
|
+
Or run without installing:
|
|
96
|
+
|
|
97
|
+
```bash
|
|
98
|
+
npx acpx@latest codex "fix the tests"
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
Session state lives in `~/.acpx/` either way. Global install is a little faster, but `npx acpx@latest` works fine.
|
|
54
102
|
|
|
55
103
|
## Agent prerequisites
|
|
56
104
|
|
|
@@ -67,21 +115,36 @@ The only prerequisite is the underlying coding agent you want to use:
|
|
|
67
115
|
## Usage examples
|
|
68
116
|
|
|
69
117
|
```bash
|
|
70
|
-
acpx codex
|
|
118
|
+
acpx codex sessions new # create a session (explicit) for this project dir
|
|
119
|
+
acpx codex 'fix the tests' # implicit prompt (routes via directory-walk)
|
|
71
120
|
acpx codex prompt 'fix the tests' # explicit prompt subcommand
|
|
121
|
+
echo 'fix flaky tests' | acpx codex # prompt from stdin
|
|
122
|
+
acpx codex --file prompt.md # prompt from file
|
|
123
|
+
acpx codex --file - "extra context" # explicit stdin + appended args
|
|
72
124
|
acpx codex --no-wait 'draft test migration plan' # enqueue without waiting if session is busy
|
|
125
|
+
acpx codex cancel # cooperative cancel of in-flight prompt
|
|
126
|
+
acpx codex set-mode plan # session/set_mode
|
|
127
|
+
acpx codex set approval_policy conservative # session/set_config_option
|
|
73
128
|
acpx exec 'summarize this repo' # default agent shortcut (codex)
|
|
74
129
|
acpx codex exec 'what does this repo do?' # one-shot, no saved session
|
|
75
130
|
|
|
76
|
-
acpx codex
|
|
131
|
+
acpx codex sessions new --name api # create named session
|
|
132
|
+
acpx codex -s api 'implement cursor pagination' # prompt in named session
|
|
133
|
+
acpx codex sessions new --name docs # create another named session
|
|
77
134
|
acpx codex -s docs 'rewrite API docs' # parallel work in another named session
|
|
78
135
|
|
|
79
136
|
acpx codex sessions # list sessions for codex command
|
|
80
137
|
acpx codex sessions list # explicit list
|
|
138
|
+
acpx codex sessions show # inspect cwd session metadata
|
|
139
|
+
acpx codex sessions history # show recent turn history
|
|
81
140
|
acpx codex sessions new # create fresh cwd-scoped default session
|
|
82
141
|
acpx codex sessions new --name api # create fresh named session
|
|
83
142
|
acpx codex sessions close # close cwd-scoped default session
|
|
84
143
|
acpx codex sessions close api # close cwd-scoped named session
|
|
144
|
+
acpx codex status # local process status for current session
|
|
145
|
+
|
|
146
|
+
acpx config show # show resolved config (global + project)
|
|
147
|
+
acpx config init # create ~/.acpx/config.json template
|
|
85
148
|
|
|
86
149
|
acpx claude 'refactor auth middleware' # built-in claude agent
|
|
87
150
|
acpx gemini 'add startup logging' # built-in gemini agent
|
|
@@ -119,6 +182,35 @@ acpx --ttl 30 codex 'keep queue owner alive for quick follow-ups'
|
|
|
119
182
|
acpx --verbose codex 'debug why adapter startup is failing'
|
|
120
183
|
```
|
|
121
184
|
|
|
185
|
+
## Configuration files
|
|
186
|
+
|
|
187
|
+
`acpx` reads config in this order (later wins):
|
|
188
|
+
|
|
189
|
+
1. global: `~/.acpx/config.json`
|
|
190
|
+
2. project: `<cwd>/.acpxrc.json`
|
|
191
|
+
|
|
192
|
+
CLI flags always win over config values.
|
|
193
|
+
|
|
194
|
+
Supported keys:
|
|
195
|
+
|
|
196
|
+
```json
|
|
197
|
+
{
|
|
198
|
+
"defaultAgent": "codex",
|
|
199
|
+
"defaultPermissions": "approve-all",
|
|
200
|
+
"ttl": 300,
|
|
201
|
+
"timeout": null,
|
|
202
|
+
"format": "text",
|
|
203
|
+
"agents": {
|
|
204
|
+
"my-custom": { "command": "./bin/my-acp-server" }
|
|
205
|
+
},
|
|
206
|
+
"auth": {
|
|
207
|
+
"my_auth_method_id": "credential-value"
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
```
|
|
211
|
+
|
|
212
|
+
Use `acpx config show` to inspect the resolved result and `acpx config init` to create the global template.
|
|
213
|
+
|
|
122
214
|
## Output formats
|
|
123
215
|
|
|
124
216
|
```bash
|
|
@@ -153,16 +245,23 @@ acpx --agent ./my-custom-acp-server 'do something'
|
|
|
153
245
|
|
|
154
246
|
## Session behavior
|
|
155
247
|
|
|
156
|
-
- Prompt commands
|
|
157
|
-
-
|
|
248
|
+
- Prompt commands require an existing saved session record (created via `sessions new`).
|
|
249
|
+
- Prompts route by walking up from `cwd` (or `--cwd`) to the nearest git root (inclusive) and selecting the nearest active session matching `(agent command, dir, optional name)`.
|
|
250
|
+
- If no git root is found, prompts only match an exact `cwd` session (no parent-directory walk).
|
|
251
|
+
- `-s <name>` selects a parallel named session during that directory walk.
|
|
158
252
|
- `sessions new [--name <name>]` creates a fresh session for that scope and soft-closes the prior one.
|
|
159
253
|
- `sessions close [name]` soft-closes the session: queue owner/processes are terminated, record is kept with `closed: true`.
|
|
160
254
|
- Auto-resume for cwd scope skips sessions marked closed.
|
|
161
255
|
- 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
256
|
- Queue owners use an idle TTL (default 300s). `--ttl <seconds>` overrides it; `--ttl 0` keeps owners alive indefinitely.
|
|
163
257
|
- `--no-wait` submits to that queue and returns immediately.
|
|
258
|
+
- `cancel` sends cooperative `session/cancel` to the running queue owner process and returns success when no prompt is running (`nothing to cancel`).
|
|
259
|
+
- `set-mode` and `set` route through queue-owner IPC when active, otherwise they reconnect directly to apply `session/set_mode` and `session/set_config_option`.
|
|
164
260
|
- `exec` is always one-shot and does not reuse saved sessions.
|
|
165
261
|
- Session metadata is stored under `~/.acpx/sessions/`.
|
|
262
|
+
- Each successful prompt appends lightweight turn history previews (`role`, `timestamp`, `textPreview`) to session metadata.
|
|
263
|
+
- `Ctrl+C` during a running turn sends ACP `session/cancel` and waits briefly for `stopReason=cancelled` before force-killing if needed.
|
|
264
|
+
- If a saved session pid is dead on the next prompt, `acpx` respawns the agent, attempts `session/load`, and transparently falls back to `session/new` if loading fails.
|
|
166
265
|
|
|
167
266
|
## Full CLI reference
|
|
168
267
|
|
package/dist/cli.d.ts
CHANGED
|
@@ -1,5 +1,36 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
+
import { AgentCapabilities } from '@agentclientprotocol/sdk';
|
|
3
|
+
|
|
4
|
+
type SessionHistoryRole = "user" | "assistant";
|
|
5
|
+
type SessionHistoryEntry = {
|
|
6
|
+
role: SessionHistoryRole;
|
|
7
|
+
timestamp: string;
|
|
8
|
+
textPreview: string;
|
|
9
|
+
};
|
|
10
|
+
type SessionRecord = {
|
|
11
|
+
id: string;
|
|
12
|
+
sessionId: string;
|
|
13
|
+
agentCommand: string;
|
|
14
|
+
cwd: string;
|
|
15
|
+
name?: string;
|
|
16
|
+
createdAt: string;
|
|
17
|
+
lastUsedAt: string;
|
|
18
|
+
closed?: boolean;
|
|
19
|
+
closedAt?: string;
|
|
20
|
+
pid?: number;
|
|
21
|
+
agentStartedAt?: string;
|
|
22
|
+
lastPromptAt?: string;
|
|
23
|
+
lastAgentExitCode?: number | null;
|
|
24
|
+
lastAgentExitSignal?: NodeJS.Signals | null;
|
|
25
|
+
lastAgentExitAt?: string;
|
|
26
|
+
lastAgentDisconnectReason?: string;
|
|
27
|
+
turnHistory?: SessionHistoryEntry[];
|
|
28
|
+
protocolVersion?: number;
|
|
29
|
+
agentCapabilities?: AgentCapabilities;
|
|
30
|
+
};
|
|
31
|
+
|
|
2
32
|
declare function parseTtlSeconds(value: string): number;
|
|
33
|
+
declare function formatPromptSessionBannerLine(record: SessionRecord, currentCwd: string): string;
|
|
3
34
|
declare function main(argv?: string[]): Promise<void>;
|
|
4
35
|
|
|
5
|
-
export { main, parseTtlSeconds };
|
|
36
|
+
export { formatPromptSessionBannerLine, main, parseTtlSeconds };
|