@vanillagreen/pi-claude-bridge 4.0.0 → 4.0.1

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 CHANGED
@@ -1,118 +1,65 @@
1
- # pi-claude-bridge
1
+ # @vanillagreen/pi-claude-bridge
2
2
 
3
- Works with OAuth subscription, no API key, no errors.
3
+ A Pi provider that uses a logged-in Claude Code account through the Claude Agent SDK. You keep Pi's terminal interface and tools while Claude Code handles model requests.
4
4
 
5
- ![Claude bridge demo response](https://raw.githubusercontent.com/vanillagreencom/kendex/main/pi-extensions/pi-claude-bridge/assets/bridge-demo.png)
6
- ![Pi Claude settings panel](https://raw.githubusercontent.com/vanillagreencom/kendex/main/pi-extensions/pi-claude-bridge/assets/settings-panel.png)
7
-
8
- Run Claude Code as the `pi-claude` Pi provider while keeping Pi's tools and TUI.
9
-
10
- Forked from [`elidickinson/pi-claude-bridge`](https://github.com/elidickinson/pi-claude-bridge). This fork removes the AskClaude tool and adds opt-in forwarding for Pi prompt context.
11
-
12
- ## Highlights
13
-
14
- - `pi-claude/claude-fable-5`, Opus 5, Opus 4.8, Opus 4.7, Opus 4.6, Sonnet 5, Sonnet 4.6, and Haiku in `/model`. `/model opus` selects Opus 5; older Opus releases stay selectable by full ID.
15
- - Pi tool calls run on Pi; Claude Code handles reasoning.
16
- - Tool-use turns block until Pi-delivered tool results reach Claude Code, including persistent subagent panes.
17
- - Parallel conversations and subagents keep independent request, abort, tool-loop, and Claude-session state.
18
- - Session continuity across normal turns, `/compact`, tree navigation, abort recovery, and account-profile changes.
19
- - Optional companion integration for usage-aware subscription account rotation without copying the bridge engine.
20
- - Thinking-level forwarding with summarized Opus thinking display.
21
- - Optional Claude effort overrides (`xhigh` → `max` for Opus 4.8).
22
- - MCP isolation and Claude cloud-MCP suppression to keep tokens lean.
23
- - Optional access to your Claude account's connectors — Gmail, Calendar, Drive, Slack, Jira, Confluence — read-only by default.
24
- - Opt-in forwarding of `APPEND_SYSTEM.md` and recognized Pi prompt hooks.
5
+ ![Claude bridge demo response](https://raw.githubusercontent.com/vanillagreencom/kendex/main/pi-extensions/pi-claude-bridge/assets/bridge-demo.png) ![Pi Claude settings panel](https://raw.githubusercontent.com/vanillagreencom/kendex/main/pi-extensions/pi-claude-bridge/assets/settings-panel.png)
25
6
 
26
7
  ## Install
27
8
 
28
- Requires pi ≥ 0.81 (bridge 2.x registers through pi's native provider API, so pi shows the Claude models only while a Claude account is actually connected). On older pi, install `@vanillagreen/pi-claude-bridge@1.x` instead.
29
-
30
- Via [npm](https://www.npmjs.com/package/@vanillagreen/pi-claude-bridge):
9
+ - npm: `pi install npm:@vanillagreen/pi-claude-bridge`.
10
+ - kendex: add the declaration below to the project's `kendex.toml`, or to `~/.config/kendex/kendex.toml` for user scope. Run `kendex update-pi`.
31
11
 
32
- ```bash
33
- pi install npm:@vanillagreen/pi-claude-bridge
12
+ ```toml
13
+ [pi-extensions."@vanillagreen/pi-claude-bridge"]
14
+ source = "kendex"
34
15
  ```
35
16
 
36
- Via [kendex](https://github.com/vanillagreencom/kendex):
17
+ Restart Pi after installation. Use `kendex update-pi --check` to preview the installation. A Claude Code login is required. Make `claude` available on `PATH` or set its executable path below.
37
18
 
38
- ```bash
39
- cargo install --git https://github.com/vanillagreencom/kendex.git kendex
40
- kendex add vanillagreencom/kendex --pi-extension pi-claude-bridge --harness pi -y
41
- ```
19
+ Fable 5.1 requires [Claude Code 2.1.255 or later](https://code.claude.com/docs/en/model-config#work-with-fable). This includes any executable chosen through `pathToClaudeCodeExecutable` or found on `PATH`, which takes precedence over the SDK's bundled CLI. Account access and usage-credit requirements still apply.
42
20
 
43
- Restart Pi after installation.
21
+ ## Features
44
22
 
45
- ## Prompt context
23
+ - Select Claude models from Pi's model menu.
24
+ - Run Pi tool calls during Claude conversations.
25
+ - Resume the Claude conversation across Pi turns.
26
+ - Configure model effort and forwarded prompt context.
27
+ - Optionally use the Claude account's connectors.
46
28
 
47
- Default behavior matches upstream: append your context file plus Pi's skills block to Claude Code's `claude_code` preset prompt. The context file is the nearest one found walking up from the working directory, falling back to `<PI_CODING_AGENT_DIR>/AGENTS.md`. Within each directory the bridge follows Pi's own order — `AGENTS.override.md`, then `AGENTS.md`, then `AGENTS.MD` — so an `AGENTS.override.md` replaces `AGENTS.md` in the same directory, exactly as it does for Pi itself. `CLAUDE.md` is deliberately not forwarded: Claude Code already loads it natively, so forwarding it would apply the same context twice.
29
+ ## How it works
48
30
 
49
- Extra Pi context is off by default. Enable per item in the extension manager when you want Claude Code to see prompt blocks that other Pi extensions add to your session. Forwarded blocks are wrapped in explicit XML tags so Pi 0.75+ project-context boundaries do not bleed into adjacent sections.
31
+ You select a pi-claude model in Pi. Select **Claude Fable 5.1** (`pi-claude/claude-fable-5-1`) for Fable. The bridge starts or resumes Claude Code through the Agent SDK. It sends the prompt and makes Pi's tools available to Claude Code. Tool calls return to Pi for execution, then their results return to Claude Code. Pi displays the response and saves the Claude session identifier.
50
32
 
51
33
  ## Settings
52
34
 
53
- Open `/extensions:settings`; settings appear under the **Pi Claude** tab. Project settings in `.pi/settings.json` apply only after Pi marks the workspace trusted; before trust, kendex Pi extensions read user/global settings only. The bridge also reads `claude-bridge.json` (`~/.pi/agent/claude-bridge.json`, and `.pi/claude-bridge.json` in a trusted project). Settings the bridge takes from one of those files are shown with the file that supplies them, so the editor reports the value the bridge resolves rather than the default. Changing the setting in the editor writes Pi settings, which take precedence over `claude-bridge.json`.
54
-
55
- | Group | Setting | What it does |
56
- | --- | --- | --- |
57
- | General | Enable Pi Claude provider | Register `pi-claude/*` models. Reload required. |
58
- | Base prompt | Forward AGENTS.md + skills | Append the nearest context file (`AGENTS.override.md`, `AGENTS.md`, or `AGENTS.MD`) and Pi's skills block. |
59
- | Pi prompt context | Forward APPEND_SYSTEM.md | Forward project/global `APPEND_SYSTEM.md` content. |
60
- | Pi prompt hooks | Forward project agents hook | Forward `pi-agents-tmux` Project Agents/Subagents list. |
61
- | Pi prompt hooks | Forward task panel hook | Forward `pi-task-panel` workflow reminders. |
62
- | Pi prompt hooks | Forward caveman hook | Forward `pi-caveman` response-style directives. |
63
- | Claude Code | Strict MCP config | Block filesystem MCP auto-loads; Pi owns tools. |
64
- | Claude Code | Fast mode | Enable Claude Code fast mode for bridge requests when the selected model and account support it. |
65
- | Claude Code | Force Claude effort | Override Pi's thinking-level mapping for every Pi Claude request. `none` keeps Pi's selected level; `max` sends Claude Code `--effort max`. |
66
- | Claude Code | Model effort overrides | JSON object mapping model IDs to Claude Code efforts, e.g. `{"claude-opus-4-8":"max"}`. Per-model entries beat the global force setting. |
67
- | Claude Code | Claude executable path | Explicit `claude` binary path; empty auto-detects. |
68
-
69
- Pi 0.80.6 and newer expose native `max` thinking. Fable 5, Opus 5, and Sonnet 5 bridge metadata forward both `xhigh` and `max`; the generic bridge fallback also maps `max` directly. **Force Claude effort** and **Model effort overrides** remain available when one bridge model needs a different fixed effort — for example `{"claude-opus-4-8":"max"}` to force only Opus 4.8. Keys may be bare model IDs (`claude-opus-4-8`), `pi-claude/<id>`, or `*` for all bridge models. Values are `low`, `medium`, `high`, `xhigh`, or `max`.
70
-
71
- ### Connectors
72
-
73
- Turn this on and the model can use whatever your Claude account already has connected — the same connectors you use in the Claude app, now inside Pi:
35
+ The settings editor writes project values to `.pi/settings.json`. The default user file is `~/.pi/agent/settings.json`. `PI_CODING_AGENT_DIR` changes the user directory. Package values are stored under `kendex.extensionManager.config["@vanillagreen/pi-claude-bridge"]`.
74
36
 
75
- **Gmail** (search mail, read threads and messages), **Google Calendar** (check calendars and events), **Google Drive** (find and read files), **Slack** (search and read channels, threads, canvases, and people), **Jira and Confluence** (search and read issues, pages, and spaces). Anything else on the account (Figma, org-specific connectors) works the same way nothing to configure per connector.
37
+ Open `/extensions:settings`; settings appear under the **Pi Claude** tab, and `/pi-claude` opens the same tab. Project settings in `.pi/settings.json` apply only after Pi marks the workspace trusted. The bridge also reads `claude-bridge.json` in `~/.pi/agent` and in a trusted project's `.pi/`; a value taken from one of those files is shown with the file that supplies it, and editing it in the panel writes Pi settings, which win.
76
38
 
77
- Sessions are **read-only** by default: the model can look things up, but cannot send, post, or change anything unless you explicitly turn writes on. Search/read/fetch/list tools stay available while mutating tools are denied, fail-closed across every connector on the account.
39
+ - `enabled`: register the `pi-claude/*` models; reload required.
40
+ - `appendSystemPrompt`: the context file and skills block described above.
41
+ - `includeAppendSystemPromptMd`, `includeProjectAgentsHook`, `includeTaskPanelHook`, `includeCavemanHook`: forward `APPEND_SYSTEM.md` and the prompt blocks of `pi-agents-tmux`, `pi-task-panel` and `pi-caveman`.
42
+ - `strictMcpConfig`, `fastMode`, `pathToClaudeCodeExecutable`: how the Claude Code subprocess is launched.
43
+ - `forceEffort`, `modelEffortOverrides`: pin a Claude effort for every request or per model. Override keys are bare ids (`claude-opus-4-8`), `pi-claude/<id>` or `*`; values are `low`, `medium`, `high`, `xhigh` or `max`; a per-model entry beats the global force.
78
44
 
79
- Connector tools run inside Claude Code rather than in Pi, so Pi shows the model's answer but no tool card for the lookup itself. Each lookup is still recorded in the session file as a `claude-bridge-connector-call` entry — the tool name, whether it succeeded, and how many bytes came back, never the contents. So "did it really look that up?" has an answer even though nothing is drawn in the transcript.
45
+ Environment variables:
80
46
 
81
- `/pi-claude:connectors` lists the Claude account's installed claude.ai connectors by asking the account, not the model, so the answer is complete by construction.
47
+ - `CLAUDE_BRIDGE_STREAM_IDLE_TIMEOUT`: how long a turn may stay silent before its first output; bare numbers are seconds, `ms`, `s` and `m` suffixes are accepted, `0` disables.
48
+ - `CLAUDE_BRIDGE_DEBUG=1`: write the bridge log, the integrity diagnostics and per-query Claude Code CLI logs under the Pi agent directory; `CLAUDE_BRIDGE_DEBUG_PATH` and `CLAUDE_BRIDGE_DIAG_PATH` move the two log files. Nothing is written to disk without it.
49
+ - `CLAUDE_BRIDGE_ISOLATED=1`: for embedding hosts that own every config directory; the bridge then reads nothing from the working directory or home. Details in [DEVELOPMENT.md](DEVELOPMENT.md).
82
50
 
83
- Extension-manager settings use flat package-scoped keys under `kendex.extensionManager.config["@vanillagreen/pi-claude-bridge"]` in `settings.json`. Legacy `claude-bridge.json` configuration nests these options under `provider` (prompt-context flags under `promptContext`); the flat keys are accepted there too. Environment variables work with either format. Connectors remain off by default so Pi owns tool execution.
51
+ Tool-result integrity problems always surface as a Pi error notification plus a metadata-only `claude-bridge-integrity` entry in the Pi session file, so a lost tool result can be analysed from the session alone.
84
52
 
85
- | Extension-manager key | Env var | Values | Default | What it does |
86
- | --- | --- | --- | --- | --- |
87
- | `enableConnectors` | `CLAUDE_BRIDGE_ENABLE_CONNECTORS` | `true`/`false` | off | Expose the account's connectors to the model (env OR config enables). |
88
- | `connectorWriteMode` | `CLAUDE_BRIDGE_CONNECTOR_WRITE` | `deny`/`allow` | `deny` | When connectors are enabled, whether their WRITE tools are exposed. |
53
+ Maintainer notes, the embedding and account-router contracts, and the test suites are in [DEVELOPMENT.md](DEVELOPMENT.md).
89
54
 
90
- For both, the env var wins over config. `connectorWriteMode` only matters when connectors are enabled. Any value other than exactly `allow` is treated as `deny` (fail-closed); set `allow` only for a one-shot write-executor session that has already obtained explicit user approval — never for an interactive connector chat.
91
-
92
- > **User scope + env only.** These two keys are resolved from user-scope configuration (`<PI_CODING_AGENT_DIR>/settings.json`, `<PI_CODING_AGENT_DIR>/claude-bridge.json`) and the env vars — never from a project's checked-in `.pi/settings.json` or `.pi/claude-bridge.json`, even when the project is trusted for ordinary options. Connectors expose live account data (mail, calendar, files), so a repo you clone must not be able to switch them on or un-gate their writes just by being the cwd.
93
-
94
- Connectors mode also makes the child Claude Code resolve its filesystem settings (with them off, the child runs fully isolated). Only **user-scope** settings are loaded; project/local scope (a checkout's `.claude/settings.json`) is deliberately excluded. Setting `provider.settingSources` in bridge config still overrides this verbatim, but listing `"project"`/`"local"` there reopens that surface — only do it for checkouts you trust.
95
-
96
- ### Fable 5 and Opus 5 caveat
97
-
98
- The bridge registers `pi-claude/claude-fable-5`, `pi-claude/claude-opus-5`, `pi-claude/claude-sonnet-5`, and `pi-claude/claude-opus-4-8` even when Pi's Anthropic model registry has not shipped those entries yet. Fable 5 and Opus 5 both run classifiers that can decline a turn, so for each of them the bridge asks Claude Code to use Opus 4.8 as the availability fallback and preserves Claude Code's content-safety fallback events so Pi labels rerouted turns as Opus 4.8. Content-safety fallback still depends on Claude Code's own Fable 5 support; use Claude Code 2.1.170 or newer, and set `ANTHROPIC_DEFAULT_FABLE_MODEL` / `ANTHROPIC_DEFAULT_OPUS_MODEL` yourself when routing provider-specific model IDs through Bedrock, Vertex, or Foundry.
99
-
100
- ## Multiple subscription profiles
101
-
102
- An optional companion extension can provide account profiles through the bridge's versioned account-router integration. For each fresh Claude request, the bridge launches the Agent SDK subprocess with the selected profile's `CLAUDE_CONFIG_DIR`; Claude session files, connector inventory, and resume IDs remain account-scoped. When an account reports a rejected rate limit (or another classified pre-output failure), the bridge rebuilds the Claude session from Pi history under the next profile and retries the prompt — but never once text, thinking, a Pi tool call, or a child-executed connector call has begun, so a request cannot duplicate tool side effects on another account. The companion owns profile metadata, utilization ranking, and cooldown persistence; the bridge remains the SDK/stream/session engine.
103
-
104
- ## Account usage and rate limits
105
-
106
- Extra Usage is owned by Claude's account settings. The bridge neither changes that setting nor blocks Claude Code's native account behavior — if the account has Extra Usage enabled on claude.ai, the child Claude Code uses it normally. If Claude rejects a request because the current allowance is exhausted, a managed account router treats it as a model-scoped limit and can try another account.
107
-
108
- When Claude Code reports a rate-limit reset time, the bridge shows one clear `[rate-limit]` warning with timezone context and avoids repeating the same error line. If `pi-qol` is installed, it can use the reset time to resume later. Allowed-warning rate-limit events are filtered before user notification: the bridge shows a neutral warning at 80%+ utilization instead of claiming an unverified `% used` value. Check Claude Code `/usage` for exact allowed-warning utilization.
55
+ ## Prompt context
109
56
 
110
- If Claude Code accepts a turn but produces no visible output, the bridge returns a retryable assistant error with a backoff hint instead of leaving Pi stuck waiting. Tune the first-output timeout with `CLAUDE_BRIDGE_STREAM_IDLE_TIMEOUT` (bare numbers are seconds; suffixes `ms`, `s`, and `m` are accepted). Default: `90s`; set `0` to disable.
57
+ The bridge sends the nearest context file and Pi's skills list with the prompt. It checks `AGENTS.override.md`, `AGENTS.md` and `AGENTS.MD` while walking up from the working directory. Claude Code loads its own CLAUDE.md files. Use the prompt settings above to forward other Pi extension instructions.
111
58
 
112
- ## Debugging
59
+ ## Connectors
113
60
 
114
- Set `CLAUDE_BRIDGE_DEBUG=1` to write bridge logs to `<agent dir>/claude-bridge.log` and per-query Claude Code CLI logs under `<agent dir>/cc-cli-logs/`, where `<agent dir>` is `PI_CODING_AGENT_DIR` when set, else `~/.pi/agent`. Override the exact files with `CLAUDE_BRIDGE_DEBUG_PATH` / `CLAUDE_BRIDGE_DIAG_PATH`. Startup failures include the resolved Claude executable and working directory, which makes missing binaries and wrong launch directories easier to fix.
61
+ Connectors are disabled by default. Set `enableConnectors` in user settings, user `claude-bridge.json`, or the `CLAUDE_BRIDGE_ENABLE_CONNECTORS` environment variable. Project settings cannot enable them.
115
62
 
116
- Tool-result integrity problems always surface as a Pi error notification plus a `claude-bridge-integrity` custom entry in the pi session transcript (compact metadata only never tool output), so lost or mismatched tool output stays analyzable from the session file alone. The on-disk diagnostic file (`<agent dir>/claude-bridge-diag.log`) is written only with `CLAUDE_BRIDGE_DEBUG=1` — like every other bridge disk log, it is opt-in.
63
+ Connector access is read-only unless `connectorWriteMode` is exactly `allow`. Set `CLAUDE_BRIDGE_CONNECTOR_WRITE=allow` only for a dedicated process running an approved write. Keep it out of persistent settings. Use `/pi-claude:connectors` to list the account's connectors.
117
64
 
118
- Embedding hosts, contributor-facing stream/tool-result/startup diagnostics, and the host-side connector APIs are documented in [`DEVELOPMENT.md`](./DEVELOPMENT.md).
65
+ With connectors enabled, Claude Code loads user settings. An explicit `provider.settingSources` list in `claude-bridge.json` changes that selection. Including project or local settings lets those files affect the subprocess.