pando-ai 0.2.1 → 0.2.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/README.md CHANGED
@@ -1,42 +1,168 @@
1
- # pandō CLI
1
+ # pandō — AI coding firewall
2
2
 
3
- `pando-ai` is the standalone CLI for `pandō`, a code indexing and semantic code editing engine exposed over MCP.
3
+ `pando-ai` is an **AI coding firewall** for Codex and Claude Code. It installs
4
+ supervised launchers so developers keep running `codex ...` and `claude ...`
5
+ normally while Pando applies local policy on each launch.
4
6
 
5
- `pandō` scans a repository, builds a structured index of code and symbols, and serves tools that let agents search code, follow references, inspect callers, and make targeted edits using syntax-aware operations instead of raw text matching.
7
+ Its jobs:
6
8
 
7
- For example, an MCP client can use `pandō` to find a function definition, list every caller across a large codebase, and then add a parameter with `change-signature`, updating the function and its call sites together.
9
+ 1. **Constrain tool use** install the project-scoped Pando MCP server, deny
10
+ native tools where supported, and deny non-Pando MCP tools by default.
11
+ 2. **Inspect tool traffic** — use Claude Code hooks on every Claude launch and
12
+ a local provider gateway where available to block off-policy tool calls and
13
+ tool results.
14
+ 3. **Keep code local by default** — run indexing, search, snapshots, and edits
15
+ locally; optional working-set memory is off unless explicitly enabled.
8
16
 
9
- `pando-ai` starts the same core indexing and tool runtime used by the VS Code extension, but runs headlessly for terminal agents and local MCP clients. We have tested it on codebases as large as Metabase and Visual Studio Code.
17
+ It is built on the same indexing + MCP engine as the Pandō VS Code extension.
10
18
 
11
19
  ## Install
12
20
 
13
21
  Requires Node.js `22.5.0` or newer.
14
22
 
15
- Run without installing globally:
16
-
17
23
  ```bash
18
- npx -y pando-ai --help
24
+ npx -y pando-ai
19
25
  ```
20
26
 
21
- Or install globally:
27
+ On a terminal this opens the **firewall console**: it detects whether `codex`
28
+ and `claude` are protected, offers to install supervised launchers for any that
29
+ aren't, and shows current status and policy. After installation you keep running
30
+ `codex` and `claude` normally — Pando supervises each launch.
31
+
32
+ ## How it works
33
+
34
+ Two choke points, one ruleset:
35
+
36
+ - **Launch shim** (`~/.pando/bin` ahead of the real tools on PATH) — supervises
37
+ every `codex`/`claude` invocation. It disables the agent's native tools where
38
+ supported, installs the Pando MCP server (root-scoped to your project), and
39
+ applies the MCP allow/deny policy via the agent's own launch flags.
40
+ - **Wire gateway** (a local reverse proxy speaking the OpenAI Responses API and
41
+ Anthropic Messages API) — sits inline on every supported request and forwards
42
+ it to the upstream you control, so traffic stays local. It blocks off-policy
43
+ tool definitions, tool calls, and tool results before they can cross the
44
+ provider boundary, and blocks off-policy tool calls on model responses before
45
+ the agent can execute them. When enabled, it runs the protocol-adapted
46
+ working-set memory engine ported from `pando-proxy`.
47
+ - **Memory manager** (`PANDO_GATEWAY_MEMORY=1`, off by default) — maintains a
48
+ per-session working set and archive recall path. The memory core is separate
49
+ from policy enforcement: policy decides which tools are allowed; memory
50
+ decides which prior context remains visible. OpenAI Responses and Anthropic
51
+ Messages use protocol adapters around the same core. The maintenance
52
+ classifier currently uses an OpenAI-compatible structured model backend.
53
+ - **Policy** (`~/.pando/policy.toml`, or a Pando DB table) — one allowlist plus a
54
+ default action. By default, native tools are denied and non-Pando MCP servers
55
+ are denied; Pando MCP is always allowed. See `[native_tools]`, `[other_mcp]`,
56
+ `[proxy]`, `[firewall]`.
57
+
58
+ ### Supported model APIs
59
+
60
+ The gateway supports the current agent-facing APIs used by the supervised
61
+ launchers:
62
+
63
+ - OpenAI/OpenAI-compatible Responses API: `/v1/responses`
64
+ - Anthropic Messages API: `/v1/messages`
65
+
66
+ Legacy completion APIs, including OpenAI chat/completions and Anthropic
67
+ `/v1/complete`, are intentionally unsupported.
68
+
69
+ ### Enforcement matrix (what is actually enforced)
70
+
71
+ | Capability | Claude Code | Codex |
72
+ | --- | --- | --- |
73
+ | Disable native tools | ✅ `--tools ""` (MCP stays available) + gateway/hook block | ⚠️ read-only sandbox + web search disabled + request/response gateway block |
74
+ | Install Pando MCP, root-scoped | ✅ `--mcp-config` | ✅ required `-c mcp_servers.pando.*` |
75
+ | `other_mcp: deny_all` | ✅ `--strict-mcp-config` (Pando only) + gateway/hook block | ✅ request/response gateway block |
76
+ | `other_mcp: allow_list` | ✅ strict config with Pando + named servers + gateway/hook block | ✅ request/response gateway block |
77
+ | `other_mcp: deny_list` | ✅ `--disallowedTools` removes denied names + gateway/hook block | ✅ request/response gateway block |
78
+ | Route traffic through local gateway | ✅ API-key/token/helper auth via `ANTHROPIC_BASE_URL`; hooks are always on | ✅ provider override |
79
+
80
+ - **Codex** has no documented strict-MCP switch and no exact `--tools ""`
81
+ equivalent, so launch-time stripping is best-effort. Pando marks its MCP
82
+ server required, disables Codex web search when native tools are denied,
83
+ strips off-policy tool definitions from `/v1/responses` requests, blocks
84
+ provider-bound off-policy tool call/result transcript items before they reach
85
+ the model provider, and blocks off-policy tool calls in model responses before
86
+ Codex can execute them.
87
+ - **Claude Code** always gets Pando hook settings for tool-call/tool-result
88
+ enforcement. API-key, auth-token, or Claude Code `apiKeyHelper` auth also
89
+ enables gateway mode through `ANTHROPIC_BASE_URL`. Subscription-only launches
90
+ use hooks-only fallback because Claude Code does not route subscription OAuth
91
+ through a custom gateway.
92
+ - **Claude Desktop general chat**: not part of the strong-enforcement claim;
93
+ transparent interception is not reliable there without app-level controls.
94
+
95
+ ### Claude Code gateway and hook modes
96
+
97
+ Claude Code tool enforcement is hook-based for every launch. Official Claude
98
+ Code gateway configuration uses `ANTHROPIC_BASE_URL` with
99
+ `ANTHROPIC_AUTH_TOKEN`, `ANTHROPIC_API_KEY`, or `apiKeyHelper`; those
100
+ credentials take precedence over subscription OAuth. When any of those
101
+ credentials are configured and `[proxy].claude = "enforce"`, Pando also routes
102
+ Claude through the local gateway for full-wire interception and optional memory.
103
+
104
+ Pando injects Claude hook settings on each launch:
105
+
106
+ - `PreToolUse` blocks off-policy tool calls before execution.
107
+ - `PostToolUse` replaces off-policy tool output with a Pando block message
108
+ before Claude can use it.
109
+ - `PostToolUseFailure` adds retry context; the tool has already failed, so this
110
+ hook is not treated as a hard enforcement boundary.
111
+ - `PostToolBatch` blocks the loop before the next model request if a serialized
112
+ off-policy tool result appears in the batch.
113
+
114
+ Hooks are the Claude tool firewall: they prevent Claude from using
115
+ non-Pando/off-policy tools and prevent their results from becoming usable model
116
+ context. Gateway mode is an additional full-wire layer for request/response
117
+ inspection, memory, and provider-bound enforcement; hooks still run when the
118
+ gateway is active.
119
+
120
+ ### Provider proxy toggle
121
+
122
+ Users can enable or disable the local provider proxy per supervised tool:
22
123
 
23
124
  ```bash
24
- npm install -g pando-ai
25
- pando-ai --help
125
+ pando-ai proxy status
126
+ pando-ai proxy enable claude
127
+ pando-ai proxy disable claude
128
+ pando-ai proxy enable codex
129
+ pando-ai proxy disable codex
130
+ ```
131
+
132
+ This writes the `[proxy]` section in `~/.pando/policy.toml`:
133
+
134
+ ```toml
135
+ [proxy]
136
+ codex = "enforce" # enforce | off
137
+ claude = "enforce" # enforce | off
26
138
  ```
27
139
 
28
- ## Usage
140
+ When Claude proxying is off, Pando uses hooks-only fallback for
141
+ tool-call/tool-result enforcement. When Codex proxying is off, Pando still
142
+ launches Codex with Pando MCP and best-effort local restrictions, but
143
+ provider-bound gateway enforcement is disabled.
144
+
145
+ ## Surfaces
29
146
 
30
147
  ```bash
31
- pando-ai [project-path]
32
- pando-ai --version
33
- pando-ai --help
148
+ pando-ai # firewall console (TTY): status + proactive install
149
+ pando-ai install # force a (re)install pass
150
+ pando-ai serve [path] # stdio MCP server for MCP clients
151
+ pando-ai serve-http # HTTP MCP server
152
+ pando-ai gateway # run the firewall gateway in the foreground (debug)
153
+ pando-ai proxy status|enable|disable [codex|claude]
154
+ pando-ai login|logout|whoami
155
+ pando-ai config set telemetry false
34
156
  ```
35
157
 
36
- ## Commands
158
+ `pando-ai launch codex|claude -- <args>` is the supervised launcher the shims
159
+ call; you don't run it directly.
160
+
161
+ ## MCP serve mode
37
162
 
38
- - `pando-ai [project-path]` starts the engine for the given path, or the current working directory.
39
- - `pando-ai config set telemetry false` disables usage telemetry.
163
+ When invoked without a TTY (e.g. spawned by an MCP client) `pando-ai` starts the
164
+ engine over stdio for the given path, or the current working directory, exactly
165
+ as before. `pando-ai config set telemetry false` disables usage telemetry.
40
166
 
41
167
  ## Transport behavior
42
168
 
@@ -47,29 +173,6 @@ pando-ai --help
47
173
 
48
174
  At startup, the CLI detects common MCP clients and prints a matching configuration snippet when possible.
49
175
 
50
- You can also install `pando-ai` manually as an MCP server:
51
-
52
- ```bash
53
- # Claude Code
54
- claude mcp add pando-ai -- npx -y pando-ai
55
-
56
- # Codex CLI
57
- codex mcp add pando-ai -- npx -y pando-ai
58
- ```
59
-
60
- Cursor uses `mcp.json` instead of an `add` command. Add this to `.cursor/mcp.json` in your project, or `~/.cursor/mcp.json` for a global install:
61
-
62
- ```json
63
- {
64
- "mcpServers": {
65
- "pando-ai": {
66
- "command": "npx",
67
- "args": ["-y", "pando-ai"]
68
- }
69
- }
70
- }
71
- ```
72
-
73
176
  Current detection targets:
74
177
 
75
178
  - Claude Code