@tduyng/pi-claude 0.0.2 → 0.0.4

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 (2) hide show
  1. package/README.md +53 -52
  2. package/package.json +2 -2
package/README.md CHANGED
@@ -1,25 +1,32 @@
1
- # pi-claude
1
+ # @tduyng/pi-claude
2
2
 
3
- Claude Pro/Max subscription models in Pi, through the official Claude Code CLI. Pi keeps its own system prompt, tools, approvals, compaction and session tree. Claude Code is only the authenticated model transport.
3
+ Claude Pro, Max, Team and Enterprise models inside pi, through the official Claude Code CLI. Pi keeps the system prompt, the tools, the approvals, compaction and the session tree. The CLI keeps authentication and billing.
4
4
 
5
- The provider id is `claude`, and model ids are the same ids Pi uses for Anthropic. `/model claude/claude-opus-5` and `anthropic/claude-opus-5` name the same model. The catalog comes from `@earendil-works/pi-ai`, so new Claude models appear when Pi updates, without editing this extension.
5
+ No token is copied and no API is called directly.
6
6
 
7
- ## Requirements
7
+ No tools, no prompt block, no schema, since this is only a provider. What it saves is the replay: one warm process means a normal turn writes only the new user message, so the prefix stays cached between turns.
8
8
 
9
- - Pi 1.4 or newer.
10
- - Claude Code 2.1.281 or newer on `PATH`.
11
- - A Claude Pro, Max, Team or Enterprise login: run `claude auth login`.
12
- - `PI_CLAUDE_BIN` only when the binary is not named `claude`.
9
+ ## One warm process per session
13
10
 
14
- This extension never reads `~/.claude/.credentials.json`, never copies OAuth tokens, and never talks to the Anthropic API directly. Authentication and billing stay with the Claude Code CLI.
11
+ `--input-format stream-json` keeps a process alive, and a normal turn writes only the new user message to stdin. A tool round parks the MCP calls, returns one pi assistant message with the tool calls, then the next provider call delivers the results into the same process. Nothing respawns, nothing is replayed, and the cached prefix survives.
15
12
 
16
- ## Install
13
+ The extension deliberately does not use `--resume`. Claude Code 2.1.69 changed how a resumed conversation rebuilds `messages[0]`, which invalidates the conversation cache on every turn. A live streaming process avoids that path entirely.
17
14
 
18
- ```sh
19
- pi install /path/to/extensions/pi-claude
20
- ```
15
+ An abort sends an `interrupt` control request instead of killing the process, so the process and its cache survive. An abort during tool execution keeps the parked calls, and pi's `Operation aborted` results resolve them on the next turn. An idle process lives 60 minutes, the length of the prompt cache.
16
+
17
+ When pi's history diverges from the live process, after editing an earlier message, changing the model, changing the tool set, or resuming a pi session after a restart, the extension replaces the process and replays the existing conversation once as a single user message. That turn is a cold cache, and later turns are warm again.
21
18
 
22
- For this repository the workspace already registers the extension in the root `package.json`.
19
+ ## Pi's tools are the only tools
20
+
21
+ The extension disables Claude Code's own system prompt, `CLAUDE.md`, rules, skills, slash commands, hooks, plugins, project MCP servers, auto memory, git snapshot, title generation and auto compaction with flags and environment variables. What is left is a model that reaches pi's tools.
22
+
23
+ | Pi | Claude Code |
24
+ | --- | --- |
25
+ | Pi system prompt | `--system-prompt-file`, replacing the default |
26
+ | Pi tools | MCP server `pi`, exposed as `mcp__pi__<tool>` |
27
+ | Pi tool execution | The MCP call parks until pi runs the tool, then the result resolves it |
28
+ | Pi compaction | `DISABLE_AUTO_COMPACT=1`, so pi decides when |
29
+ | Pi approvals | Every tool call returns to pi and runs there |
23
30
 
24
31
  ## Use
25
32
 
@@ -27,61 +34,55 @@ For this repository the workspace already registers the extension in the root `p
27
34
  pi --provider claude --model claude-opus-5
28
35
  ```
29
36
 
30
- Inside Pi:
37
+ Inside pi:
31
38
 
32
39
  ```text
33
40
  /model claude/claude-opus-5
34
41
  ```
35
42
 
36
- `/claude status` shows the binary, login, MCP port and live processes. `/claude models` lists every id. `/claude clear` closes the warm processes.
43
+ The provider id is `claude`, and model ids are the ones pi already uses for Anthropic: `claude/claude-opus-5` and `anthropic/claude-opus-5` name the same model. The catalog comes from `@earendil-works/pi-ai`, so new Claude models appear when pi updates, with no edit here.
37
44
 
38
- ## What it sends
45
+ | Command | Effect |
46
+ | --- | --- |
47
+ | `/claude status` | Binary, login, MCP port, live processes |
48
+ | `/claude models` | Every model id |
49
+ | `/claude clear` | Close the warm processes |
39
50
 
40
- | Pi | Claude Code |
41
- | ----------------- | ------------------------------------------------------------------------- |
42
- | Pi system prompt | `--system-prompt-file`, replaces the default prompt |
43
- | Pi tools | MCP server named `pi`, exposed as `mcp__pi__<tool>` |
44
- | Pi tool execution | MCP call parked until Pi runs the tool, then the result resolves the call |
45
- | Pi compaction | `DISABLE_AUTO_COMPACT=1`, Pi decides when to compact |
46
- | Pi approvals | every tool call returns to Pi and runs there |
51
+ ## Install
47
52
 
48
- Claude Code's own system prompt, `CLAUDE.md`, rules, skills, slash commands, hooks, plugins, project MCP servers, auto memory, git snapshot, title generation and auto compaction are disabled with flags and environment variables.
53
+ Requirements:
49
54
 
50
- ## Token and cache behavior
55
+ - Pi 1.4 or newer.
56
+ - Claude Code 2.1.281 or newer on `PATH`.
57
+ - A Claude Pro, Max, Team or Enterprise login: run `claude auth login`.
58
+ - `PI_CLAUDE_BIN` only when the binary is not named `claude`.
51
59
 
52
- One Claude Code process runs per Pi session with `--input-format stream-json`. A normal turn writes only the new user message to stdin. A tool round parks the MCP calls and returns one Pi assistant message with the tool calls, then the next provider call delivers the results into the same process. Nothing is respawned, nothing is replayed, and the prompt cache prefix stays intact.
60
+ ```sh
61
+ pi install npm:@tduyng/pi-claude
62
+ ```
53
63
 
54
- `--resume` is not used. Claude Code 2.1.69 changed how a resumed conversation rebuilds `messages[0]`, which invalidates the conversation cache on every turn. A live streaming process avoids that path completely.
64
+ Local checkout: `pi install /path/to/dotfiles/pi/agent/extensions/pi-claude`
55
65
 
56
- A Pi abort sends Claude Code an `interrupt` control request instead of killing it, so the process and its cache survive. An abort during tool execution keeps the parked calls, and Pi's `Operation aborted` results resolve them on the next turn. An idle process lives for 60 minutes, the length of the prompt cache.
66
+ The extension never reads `~/.claude/.credentials.json`, never copies OAuth tokens, and never talks to the Anthropic API directly.
57
67
 
58
- When Pi history diverges from the live process, for example after editing an earlier message, changing the model, changing the tool set or resuming a Pi session after a restart, the process is replaced and the existing Pi conversation is replayed once as a single user message. That one turn is a cold cache. Later turns are warm again.
68
+ ```sh
69
+ PI_CLAUDE_BIN=/home/you/.nix-profile/bin/claude pi
70
+ ```
59
71
 
60
- ## Limitations
72
+ ## Limits
61
73
 
62
- - Every request counts against the Claude subscription limits, exactly like Claude Code itself.
63
- - Anthropic may treat a third-party harness prompt differently from Claude Code own prompt. If a turn fails with a third-party or extra-usage message, the rejection is about the prompt shape, not the CLI transport.
64
- - One process per Pi session. Subagents with different prompts get their own process, up to eight alive at once.
65
- - A model change, a thinking level change or a tool set change rebuilds the session on the next turn.
66
- - Images in replayed history are attached to the replay message. New user images are sent normally.
67
- - Claude Code needs a model id it recognizes. New models may need a newer Claude Code than the one installed.
68
- - Claude Code caps MCP tool output and may move very large text to a file. Pi tools normally truncate before that cap.
69
- - Usage is reported from Claude Code stream events. Monetary cost is Pi's API-equivalent estimate, not the subscription bill.
74
+ - Every request counts against the subscription limits, exactly like the CLI itself.
70
75
 
71
- ## Configuration
76
+ - Anthropic may treat a third-party harness prompt differently from the CLI's own prompt. A turn failing with a third-party or extra-usage message is about the prompt shape, not the transport.
72
77
 
73
- | Variable | Meaning |
74
- | --------------- | ----------------------------------------- |
75
- | `PI_CLAUDE_BIN` | Claude Code executable. Default `claude`. |
78
+ - One process per pi session. Subagents with a different prompt get their own, up to eight alive at once.
76
79
 
77
- ```sh
78
- PI_CLAUDE_BIN=/home/you/.nix-profile/bin/claude pi
79
- ```
80
+ - A model change, a thinking level change or a tool set change rebuilds the session on the next turn.
80
81
 
81
- ## Tests
82
+ - Images in replayed history are attached to the replay message, and new user images are sent normally.
82
83
 
83
- ```sh
84
- bun run test -- extensions/pi-claude
85
- bun run typecheck
86
- bun run lint:anti-slop
87
- ```
84
+ - Claude Code needs a model id it recognizes, so a brand new model may need a newer CLI than the one installed.
85
+
86
+ - The CLI caps MCP tool output and may move very large text to a file. Pi tools normally truncate before that cap.
87
+
88
+ - Usage comes from the CLI's stream events. The monetary cost is pi's API-equivalent estimate, not the subscription bill.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@tduyng/pi-claude",
3
- "version": "0.0.2",
4
- "description": "Use Claude Pro/Max subscription models in Pi through the official Claude Code CLI, with Pi's own prompt and tools.",
3
+ "version": "0.0.4",
4
+ "description": "Claude Pro and Max models in Pi through the official Claude Code CLI: one warm streaming process, Pi's own prompt and tools, no credential copy.",
5
5
  "keywords": [
6
6
  "pi",
7
7
  "pi-package",