pi-ca-leash 0.10.0 → 0.12.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.
Files changed (72) hide show
  1. package/README.md +91 -23
  2. package/RELEASE_NOTES.md +71 -0
  3. package/extensions/command-drivers.ts +4 -4
  4. package/extensions/index.ts +130 -24
  5. package/extensions/model-catalog.ts +40 -7
  6. package/extensions/peer-relay.ts +7 -9
  7. package/extensions/peer-ux.ts +4 -0
  8. package/extensions/prompts/peer-start-tool.md +1 -1
  9. package/extensions/prompts/runtime-models-tool.md +2 -2
  10. package/extensions/prompts/subagent-run-tool.md +1 -1
  11. package/extensions/prompts/team-spawn-tool.md +1 -1
  12. package/extensions/runtime-driver.ts +27 -6
  13. package/extensions/runtime-safety.ts +9 -1
  14. package/extensions/tool-inputs.ts +5 -4
  15. package/node_modules/@pi-claude-code-agent/intercom-bridge/dist/bridge.d.ts +6 -1
  16. package/node_modules/@pi-claude-code-agent/intercom-bridge/dist/bridge.js +99 -21
  17. package/node_modules/@pi-claude-code-agent/intercom-bridge/dist/bridge.js.map +1 -1
  18. package/node_modules/@pi-claude-code-agent/intercom-bridge/dist/index.d.ts +3 -1
  19. package/node_modules/@pi-claude-code-agent/intercom-bridge/dist/index.js +1 -0
  20. package/node_modules/@pi-claude-code-agent/intercom-bridge/dist/index.js.map +1 -1
  21. package/node_modules/@pi-claude-code-agent/intercom-bridge/dist/managed-peers.d.ts +30 -0
  22. package/node_modules/@pi-claude-code-agent/intercom-bridge/dist/managed-peers.js +74 -0
  23. package/node_modules/@pi-claude-code-agent/intercom-bridge/dist/managed-peers.js.map +1 -0
  24. package/node_modules/@pi-claude-code-agent/intercom-bridge/dist/persistence.d.ts +3 -0
  25. package/node_modules/@pi-claude-code-agent/intercom-bridge/dist/persistence.js +17 -1
  26. package/node_modules/@pi-claude-code-agent/intercom-bridge/dist/persistence.js.map +1 -1
  27. package/node_modules/@pi-claude-code-agent/intercom-bridge/dist/types.d.ts +7 -0
  28. package/node_modules/@pi-claude-code-agent/intercom-bridge/package.json +2 -2
  29. package/node_modules/@pi-claude-code-agent/runtime/dist/config.d.ts +26 -0
  30. package/node_modules/@pi-claude-code-agent/runtime/dist/config.js +104 -0
  31. package/node_modules/@pi-claude-code-agent/runtime/dist/config.js.map +1 -0
  32. package/node_modules/@pi-claude-code-agent/runtime/dist/driver-config.js +6 -1
  33. package/node_modules/@pi-claude-code-agent/runtime/dist/driver-config.js.map +1 -1
  34. package/node_modules/@pi-claude-code-agent/runtime/dist/drivers/claude-cli.d.ts +30 -0
  35. package/node_modules/@pi-claude-code-agent/runtime/dist/drivers/claude-cli.js +209 -0
  36. package/node_modules/@pi-claude-code-agent/runtime/dist/drivers/claude-cli.js.map +1 -0
  37. package/node_modules/@pi-claude-code-agent/runtime/dist/drivers/codex-cli.d.ts +1 -0
  38. package/node_modules/@pi-claude-code-agent/runtime/dist/drivers/codex-cli.js +7 -4
  39. package/node_modules/@pi-claude-code-agent/runtime/dist/drivers/codex-cli.js.map +1 -1
  40. package/node_modules/@pi-claude-code-agent/runtime/dist/drivers/pi-coding-agent.d.ts +34 -0
  41. package/node_modules/@pi-claude-code-agent/runtime/dist/drivers/pi-coding-agent.js +280 -0
  42. package/node_modules/@pi-claude-code-agent/runtime/dist/drivers/pi-coding-agent.js.map +1 -0
  43. package/node_modules/@pi-claude-code-agent/runtime/dist/index.d.ts +4 -0
  44. package/node_modules/@pi-claude-code-agent/runtime/dist/index.js +3 -0
  45. package/node_modules/@pi-claude-code-agent/runtime/dist/index.js.map +1 -1
  46. package/node_modules/@pi-claude-code-agent/runtime/dist/runtime.js +23 -2
  47. package/node_modules/@pi-claude-code-agent/runtime/dist/runtime.js.map +1 -1
  48. package/node_modules/@pi-claude-code-agent/runtime/dist/types.d.ts +2 -1
  49. package/node_modules/@pi-claude-code-agent/runtime/package.json +1 -1
  50. package/node_modules/@pi-claude-code-agent/subagents-backend/package.json +2 -2
  51. package/node_modules/@pi-claude-code-agent/teams-backend/package.json +3 -3
  52. package/package.json +27 -15
  53. package/AGENTS.md +0 -77
  54. package/ARCHITECTURE.md +0 -290
  55. package/CHANGELOG.md +0 -158
  56. package/DEVELOPMENT.md +0 -197
  57. package/KNOWN_LIMITS.md +0 -80
  58. package/extensions/backend-tool-actions.test.ts +0 -59
  59. package/extensions/command-drivers.test.ts +0 -37
  60. package/extensions/command-parity.test.ts +0 -560
  61. package/extensions/command-visibility.test.ts +0 -21
  62. package/extensions/llm-tools.test.ts +0 -537
  63. package/extensions/model-catalog.test.ts +0 -34
  64. package/extensions/peer-history.test.ts +0 -141
  65. package/extensions/peer-naming.test.ts +0 -25
  66. package/extensions/peer-relay.test.ts +0 -122
  67. package/extensions/peer-ux.test.ts +0 -239
  68. package/extensions/persistence.test.ts +0 -68
  69. package/extensions/runtime-driver.test.ts +0 -38
  70. package/extensions/runtime-safety.test.ts +0 -21
  71. package/extensions/support.test.ts +0 -144
  72. package/extensions/tool-inputs.test.ts +0 -45
package/README.md CHANGED
@@ -1,12 +1,17 @@
1
1
  # pi-ca-leash
2
2
 
3
+ > [!WARNING]
4
+ > **Claude Code auth caveat:** the default `claude-sdk` runtime path actively sends prompts and follow-up messages through `@anthropic-ai/claude-agent-sdk`, including resumed peer sessions. The optional `claude-cli` runtime path avoids that SDK package and shells out to `claude -p`, but it is still non-interactive Claude Code message sending. Anthropic's current Claude Code legal/authentication docs say OAuth subscription credentials are intended for ordinary Claude Code and native Anthropic app use, while developers building products or services with the Agent SDK should use API key authentication through Claude Console or a supported cloud provider. Do not use this extension to route Free, Pro, or Max subscription credentials on behalf of other users.
5
+ >
6
+ > Read-only/local features such as dashboard state, peer history browsing, local persistence, Git operations, and the experimental `codex-cli` runtime path are separate from Claude Agent SDK message sending.
7
+
3
8
  Harness-aware Claude Code and Codex CLI extension for pi.
4
9
 
5
10
  Claude Code and Codex CLI are more than model endpoints. They are coding harnesses with their own tool loops, session semantics, and increasingly harness-optimized models. `pi-ca-leash` treats them that way.
6
11
 
7
12
  Pi stays in the brain seat — like a human coordinating multiple coding agents. It can start long-lived workers, hand them scoped tasks, wait for results, inspect what they did, and decide what happens next.
8
13
 
9
- Claude is the default and most complete path today. Codex works too, but is still experimental and not parity-complete.
14
+ Claude is the default and most complete path today. `claude-cli` is available as an optional local CLI-backed Claude path. Codex works too, but is still experimental and not parity-complete.
10
15
 
11
16
  ## What it adds
12
17
 
@@ -14,6 +19,7 @@ After installation, pi gets:
14
19
  - named long-lived peers with `/peer start`, `/peer ask`, `/peer send`, `/peer history`, and `/peer stop`
15
20
  - a peer dashboard plus local attention state
16
21
  - LLM-callable peer tools such as `peer_start`, `peer_ask`, `peer_send`, `peer_history`, and `runtime_models`
22
+ - a supported programmatic managed-peer API for downstream orchestrators via `@pi-claude-code-agent/intercom-bridge`
17
23
  - optional local subagent-style runs and local persistent teammates behind advanced commands/tools
18
24
  - optional live intercom transport when the broker is reachable
19
25
 
@@ -58,17 +64,7 @@ Once peer mode is active, you can often ask for this in natural language instead
58
64
 
59
65
  ## Install
60
66
 
61
- For most users, if pi already works on your machine and `pi install` works, you do not need to think about Node directly. `pi install npm:pi-ca-leash` is usually enough.
62
-
63
- Requirements for normal use:
64
- - a working pi installation
65
- - at least one configured runtime:
66
- - Claude Code configured for Claude-backed execution, or
67
- - `codex` on `PATH` for experimental Codex-backed runtime checks
68
-
69
- Requirements for local development or source installs:
70
- - Node.js 18 or newer
71
- - npm
67
+ Read the Claude Code auth caveat at the top of this README before using a Claude-backed runtime path.
72
68
 
73
69
  Install from npm:
74
70
 
@@ -79,14 +75,20 @@ pi install npm:pi-ca-leash
79
75
  Pin an explicit version when needed:
80
76
 
81
77
  ```bash
82
- pi install npm:pi-ca-leash@0.10.0
78
+ pi install npm:pi-ca-leash@0.12.0
83
79
  ```
84
80
 
85
- Install from a pinned git release:
81
+ Local checkout install:
86
82
 
87
- ```bash
88
- pi install git:github.com/durandom/pi-ca-leash@v0.10.0
89
- ```
83
+ Requirements for normal use:
84
+ - a working pi installation
85
+ - at least one configured runtime:
86
+ - Claude Code configured for Claude-backed execution, or
87
+ - `codex` on `PATH` for experimental Codex-backed runtime checks
88
+
89
+ Requirements for local development or source installs:
90
+ - Node.js 18 or newer
91
+ - npm
90
92
 
91
93
  Try this checkout locally:
92
94
 
@@ -99,14 +101,60 @@ pi install /absolute/path/to/pi-ca-leash
99
101
 
100
102
  `npm install` runs the workspace build through `prepare`, so local development and git-based installs have package `dist/` files available.
101
103
 
102
- Use Codex as the default runtime driver for newly started peers:
104
+ Use another default runtime driver for newly started peers:
103
105
 
104
106
  ```bash
107
+ PI_CLAUDE_RUNTIME_DRIVER=claude-cli pi
105
108
  PI_CLAUDE_RUNTIME_DRIVER=codex-cli pi
106
109
  ```
107
110
 
108
111
  Persisted peers keep their recorded driver.
109
112
 
113
+ ## Configuration
114
+
115
+ Driver choice can be set per call, by environment, or by config file. Precedence is:
116
+
117
+ 1. explicit method/tool/command driver, such as `peer_start(..., driver: "claude-cli")` or `/peer start task | claude-cli`
118
+ 2. `PI_CLAUDE_RUNTIME_DRIVER`
119
+ 3. config file `defaultDriver`
120
+ 4. built-in default `claude-sdk`
121
+
122
+ Config files are JSON and are merged in this order:
123
+
124
+ 1. global XDG config: `$XDG_CONFIG_HOME/pi-ca-leash/config.json`, or `~/.config/pi-ca-leash/config.json`
125
+ 2. repository-local config: `.pi-ca-leash/config.json`
126
+ 3. explicit override path from `PI_CA_LEASH_CONFIG`
127
+
128
+ Example:
129
+
130
+ ```json
131
+ {
132
+ "defaultDriver": "claude-cli",
133
+ "drivers": {
134
+ "claude-cli": {
135
+ "executable": "/opt/homebrew/bin/claude",
136
+ "permissionMode": "bypassPermissions"
137
+ },
138
+ "codex-cli": {
139
+ "executable": "/opt/homebrew/bin/codex"
140
+ }
141
+ }
142
+ }
143
+ ```
144
+
145
+ `claude-cli` runs local Claude Code in print mode (`claude -p --output-format stream-json`) and resumes follow-up peer messages with `--resume <session-id>`. `claude-sdk` remains available and is still the default unless you choose another driver.
146
+
147
+ ## SDK Usage
148
+
149
+ This repo also ships reusable SDK packages for programmatic use:
150
+
151
+ - `@pi-claude-code-agent/runtime` for driver-backed sessions, status, events, transcripts, and normalized result usage
152
+ - `@pi-claude-code-agent/intercom-bridge` for named long-lived peers and managed-peer orchestration
153
+ - `@pi-claude-code-agent/subagents-backend` for persisted bounded local runs
154
+ - `@pi-claude-code-agent/teams-backend` for persistent local teammate records
155
+
156
+ Token usage is exposed as per-result-event data, not as an automatic session total. SDK consumers should sum selected `RuntimeEvent.type === "result"` events themselves when they need cumulative accounting. See `docs/token-usage-reporting.md` for the adapter/backend matrix and example SDK summing pattern.
157
+
110
158
  ## Try this first
111
159
 
112
160
  Inside pi:
@@ -120,9 +168,10 @@ Inside pi:
120
168
  /peer dashboard advanced
121
169
  ```
122
170
 
123
- If you want Codex-backed peers, inspect the bundled Codex catalog first:
171
+ If you want driver-specific peers, inspect the bundled catalog first:
124
172
 
125
173
  ```text
174
+ /peer models claude-cli
126
175
  /peer models codex-cli
127
176
  ```
128
177
 
@@ -147,6 +196,10 @@ Primary slash-command surface:
147
196
  /peer init
148
197
  /peer dashboard
149
198
  /peer dashboard advanced
199
+ /peer dashboard hide
200
+ /peer dashboard show
201
+ /peer hide
202
+ /peer show
150
203
  /peer start <prompt>
151
204
  /peer start <prompt> | <driver> | <model>
152
205
  /peer start <name> | <prompt>
@@ -154,7 +207,7 @@ Primary slash-command surface:
154
207
  /peer ask <name> | <message>
155
208
  /peer send <name> | <message>
156
209
  /peer list
157
- /peer models [claude-sdk|codex-cli] [all|advanced|verbose]
210
+ /peer models [claude-sdk|claude-cli|codex-cli] [all|advanced|verbose]
158
211
  /peer history <name> [cursor] [limit]
159
212
  /peer interrupt <name>
160
213
  /peer stop <name>
@@ -202,7 +255,7 @@ PI_CA_LEASH_ENABLE_LEGACY_COMMANDS=1 PI_CLAUDE_ENABLE_ADVANCED_COMMANDS=1 pi
202
255
 
203
256
  ## Behavior
204
257
 
205
- The extension is lazy. Loading it registers commands and tools, but it does not start the Peers widget, background monitor, or intercom transport checks immediately. `/peer` with no args opens the dashboard and activates peer mode. `/peer init` also activates the peer workflow, adds the one-time orchestration guide to the main agent context, and shows the user a compact command cheat sheet as a user-only UI notification. The first actionable `/peer` command, such as `/peer models`, `/peer dashboard`, `/peer list`, or `/peer start`, also activates it and adds that agent guide once. `/peer help` and `/peer about` stay passive and show user-only UI notifications. `/peer about` reports the installed package version, package root, state root, default driver, and session mode.
258
+ The extension is lazy. Loading it registers commands and tools, but it does not start the Peers widget, background monitor, or intercom transport checks immediately. `/peer` with no args opens the dashboard and activates peer mode. `/peer init` also activates the peer workflow, adds the one-time orchestration guide to the main agent context, and shows the user a compact command cheat sheet as a user-only UI notification. The first actionable `/peer` command, such as `/peer models`, `/peer dashboard`, `/peer list`, or `/peer start`, also activates it and adds that agent guide once. `/peer help` and `/peer about` stay passive and show user-only UI notifications. `/peer about` reports the installed package version, package root, state root, default driver, and session mode. `/peer dashboard hide` (or `/peer hide`) clears the compact Peers widget for the current session without stopping peers or disabling completion relays; `/peer dashboard show` (or `/peer show`) restores it.
206
259
 
207
260
  Peers are asynchronous workers. The main agent should start a peer, continue useful work, and wait for the automatic peer completion, blocked, or failure relay. It should not poll `peer_list`, `peer_history`, or repeated `peer_ask` just to see whether the peer is done. When a peer returns, the main agent still owns verification, synthesis, and the final answer.
208
261
 
@@ -212,10 +265,24 @@ The extension keeps peer output quiet by default:
212
265
  - peer completion is relayed back as one wrapped follow-up turn with the latest visible peer message
213
266
  - detailed backend diagnostics live in `/peer dashboard advanced`
214
267
 
268
+ ## Managed peers for downstream orchestrators
269
+
270
+ If another extension wants workers that behave like normal `pi-ca-leash` peers, use the supported managed-peer surface from `@pi-claude-code-agent/intercom-bridge`:
271
+
272
+ - `PiCaLeashManagedPeerApi`
273
+ - `piCaLeashStateDir(...)`
274
+ - `piCaLeashRuntimeStorageDir(...)`
275
+ - `piCaLeashBridgeStorageDir(...)`
276
+
277
+ That API gives downstream orchestrators the normal peer lifecycle (`launch`, `attach`, `list`, `status`, `send`, `ask`, `interrupt`, `stop`, `reconcile`) while writing to the same `.pi-ca-leash/{runtime,bridge}` state used by the extension.
278
+
279
+ Result: managed peers created by another extension can show up in the live `/peer dashboard` and `peer_list` without requiring a pi restart. The normal dashboard shows a compact `managed:owner` badge, and the advanced dashboard expands full managed-peer metadata.
280
+
215
281
  Runtime driver notes:
216
282
  - `claude-sdk` is the default and most complete path
283
+ - `claude-cli` shells out to local `claude -p --output-format stream-json`; it avoids importing the Agent SDK package, but still uses Claude Code non-interactively
217
284
  - `codex-cli` is supported, but still experimental and not parity-complete
218
- - `PI_CLAUDE_RUNTIME_DRIVER=codex-cli` changes the default for newly started peers
285
+ - `PI_CLAUDE_RUNTIME_DRIVER=claude-cli` or `PI_CLAUDE_RUNTIME_DRIVER=codex-cli` changes the default for newly started peers
219
286
  - `/peer models` and LLM-callable `runtime_models` show a short recommended model list by default, including advisory use cases
220
287
  - `/peer models ... all` and `runtime_models(verbose: true)` expose the full bundled Lanista-derived model catalog
221
288
  - LLM-callable `peer_start`, `peer_ask`, and `peer_send` can pass explicit model ids
@@ -240,6 +307,7 @@ Useful docs that should remain current:
240
307
  - `ARCHITECTURE.md`
241
308
  - `KNOWN_LIMITS.md`
242
309
  - `CHANGELOG.md`
310
+ - `RELEASE_NOTES.md`
243
311
  - `DEVELOPMENT.md`
244
312
  - `AGENTS.md`
245
313
 
@@ -255,7 +323,7 @@ npm run smoke:last
255
323
  npm run smoke:manual
256
324
  ```
257
325
 
258
- For the full developer workflow, smoke-command reference, artifact/debugging guide, and manual release checklist, see [`DEVELOPMENT.md`](./DEVELOPMENT.md).
326
+ For the full developer workflow, smoke-command reference, artifact/debugging guide, and manual release checklist, see [`DEVELOPMENT.md`](https://github.com/durandom/pi-ca-leash/blob/main/DEVELOPMENT.md).
259
327
 
260
328
  ## Persistence
261
329
 
@@ -0,0 +1,71 @@
1
+ # Release Notes
2
+
3
+ ## Unreleased
4
+
5
+ This release adds a second Claude-backed runtime path while keeping the existing Agent SDK path intact.
6
+
7
+ ### Claude CLI runtime
8
+
9
+ - Added `claude-cli`, an optional runtime driver that runs local Claude Code through `claude -p --output-format stream-json`.
10
+ - Follow-up peer messages resume the same Claude Code session with `--resume <session-id>`.
11
+ - `claude-cli` shares the existing Anthropic model catalog and alias handling used by `claude-sdk`.
12
+ - `claude-sdk` remains available and stays the built-in default.
13
+
14
+ Use it per peer:
15
+
16
+ ```text
17
+ /peer start reviewer | Review this repo briefly. | claude-cli
18
+ ```
19
+
20
+ Or as the default for new peers:
21
+
22
+ ```bash
23
+ PI_CLAUDE_RUNTIME_DRIVER=claude-cli pi
24
+ ```
25
+
26
+ ### Configuration
27
+
28
+ Driver defaults and executable overrides can now come from config files as well as environment variables and method/tool parameters.
29
+
30
+ Precedence:
31
+
32
+ 1. explicit method, tool, or command driver
33
+ 2. `PI_CLAUDE_RUNTIME_DRIVER`
34
+ 3. config file `defaultDriver`
35
+ 4. built-in default `claude-sdk`
36
+
37
+ Config files are merged in this order:
38
+
39
+ 1. `$XDG_CONFIG_HOME/pi-ca-leash/config.json` or `~/.config/pi-ca-leash/config.json`
40
+ 2. `.pi-ca-leash/config.json` in the repository
41
+ 3. `PI_CA_LEASH_CONFIG`
42
+
43
+ Example:
44
+
45
+ ```json
46
+ {
47
+ "defaultDriver": "claude-cli",
48
+ "drivers": {
49
+ "claude-cli": {
50
+ "executable": "/opt/homebrew/bin/claude",
51
+ "permissionMode": "bypassPermissions"
52
+ },
53
+ "codex-cli": {
54
+ "executable": "/opt/homebrew/bin/codex"
55
+ }
56
+ }
57
+ }
58
+ ```
59
+
60
+ ### Codex CLI permissions
61
+
62
+ - `codex-cli` now maps `permissionMode: "bypassPermissions"` to Codex's unsandboxed automation flag for fresh and resumed peer runs.
63
+ - Other accepted Codex permission modes keep the existing `--full-auto` behavior.
64
+
65
+ ### Auth Caveat
66
+
67
+ The top-level README warning now distinguishes the two Claude-backed paths:
68
+
69
+ - `claude-sdk` sends messages through `@anthropic-ai/claude-agent-sdk`.
70
+ - `claude-cli` avoids importing that SDK package and shells out to `claude -p`.
71
+ - Both are still non-interactive Claude Code message-sending paths, so users must understand their authentication mode and applicable Anthropic terms before using them.
@@ -61,7 +61,7 @@ export function parsePeerStartCommandInput(args: string): ParsedPeerStartCommand
61
61
  }
62
62
  const driver = parseRuntimeDriverName(parts[2]);
63
63
  if (!driver) {
64
- throw new Error("driver must be claude-sdk or codex-cli when using a driver-aware peer start form");
64
+ throw new Error("driver must be claude-sdk, claude-cli, or codex-cli when using a driver-aware peer start form");
65
65
  }
66
66
  return {
67
67
  name: parts[0],
@@ -72,7 +72,7 @@ export function parsePeerStartCommandInput(args: string): ParsedPeerStartCommand
72
72
  }
73
73
  const driver = parseRuntimeDriverName(parts[2]);
74
74
  if (!driver) {
75
- throw new Error("driver must be claude-sdk or codex-cli when using <name> | <prompt> | <driver> | <model>");
75
+ throw new Error("driver must be claude-sdk, claude-cli, or codex-cli when using <name> | <prompt> | <driver> | <model>");
76
76
  }
77
77
  return {
78
78
  name: parts[0],
@@ -94,7 +94,7 @@ export function parseSubagentRunCommandInput(args: string): ParsedSubagentRunCom
94
94
  }
95
95
  const driver = parseRuntimeDriverName(parts[0]);
96
96
  if (!driver) {
97
- throw new Error("driver must be claude-sdk or codex-cli when using <driver> | <task>");
97
+ throw new Error("driver must be claude-sdk, claude-cli, or codex-cli when using <driver> | <task>");
98
98
  }
99
99
  return {
100
100
  driver,
@@ -116,7 +116,7 @@ export function parseTeamSpawnCommandInput(args: string): ParsedTeamSpawnCommand
116
116
  }
117
117
  const driver = parseRuntimeDriverName(maybeDriver);
118
118
  if (!driver) {
119
- throw new Error("driver must be claude-sdk or codex-cli when using <name> | <prompt> | <driver>");
119
+ throw new Error("driver must be claude-sdk, claude-cli, or codex-cli when using <name> | <prompt> | <driver>");
120
120
  }
121
121
  return {
122
122
  name: name ?? "",