pi-code 0.2.3 → 0.2.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.
- package/README.md +4 -1
- package/extensions/mcp.ts +13 -18
- package/extensions/subagent/agents.ts +0 -10
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -41,7 +41,8 @@ One `pi install` and everything below loads on the next start. `pi list` shows w
|
|
|
41
41
|
| Hooks | `.claude/settings.json` hooks on pi lifecycle events | `hooks.ts` |
|
|
42
42
|
| Output styles | `.claude/output-styles` + active `outputStyle`, `/output-style` switcher | `output-styles.ts` |
|
|
43
43
|
| CLAUDE.md `@imports` | resolves `@path` imports pi's native loader skips | `context-imports.ts` |
|
|
44
|
-
| MCP servers | `~/.claude.json`, `~/.pi/agent/mcp.json
|
|
44
|
+
| MCP servers | user `~/.claude.json`, `~/.pi/agent/mcp.json` (loaded on session start); project `.mcp.json`, `.pi/mcp.json` (only once the project is approved); stdio, HTTP, SSE | `mcp.ts` |
|
|
45
|
+
| Project trust | prompts before loading project config (MCP servers, hooks, agents) that pi would otherwise trust silently | `project-approval.ts` |
|
|
45
46
|
| Subagents / Task | `~/.claude/agents` and `~/.pi/agent/agents`, plus project `.claude/agents` and `.pi/agents`; background runs | `subagent/` |
|
|
46
47
|
| Plan mode | `plan_mode_complete` tool, exact tool snapshot/restore | `plan-mode/` |
|
|
47
48
|
| Todo list | persistent overlay, status machine, compaction-safe | `todo.ts` |
|
|
@@ -54,6 +55,8 @@ One `pi install` and everything below loads on the next start. `pi list` shows w
|
|
|
54
55
|
|
|
55
56
|
`CLAUDE.md` itself needs no extension: pi loads `CLAUDE.md` / `AGENTS.md` context files natively (global + walking cwd to root). `context-imports.ts` only adds the `@import` resolution pi's loader lacks, appending the imported files without re-injecting the base.
|
|
56
57
|
|
|
58
|
+
`output-guard.ts` and `web-transport.ts` are shared internals (context-budget truncation, DNS-pinned fetch) with no feature of their own; the tools above use them.
|
|
59
|
+
|
|
57
60
|
Vendored bases (`question`, `notify`, `status-line`) come from pi's MIT example extensions (see [LICENSE](LICENSE)).
|
|
58
61
|
|
|
59
62
|
## Development
|
package/extensions/mcp.ts
CHANGED
|
@@ -1,16 +1,20 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* MCP Adapter Extension
|
|
3
3
|
*
|
|
4
|
-
* Connects MCP (Model Context Protocol) servers
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
* (streamable with SSE fallback)
|
|
4
|
+
* Connects MCP (Model Context Protocol) servers and registers their tools in pi
|
|
5
|
+
* as `<server>_<tool>`. Connects on `session_start`, not from the factory (pi runs
|
|
6
|
+
* the factory for invocations that never start a session); per-server timeout,
|
|
7
|
+
* failures skip with a notice; stdio and HTTP (streamable with SSE fallback)
|
|
8
|
+
* transports; /mcp shows status.
|
|
8
9
|
*
|
|
9
|
-
* Reads Claude Code's MCP config too.
|
|
10
|
-
* ~/.pi/agent/mcp.json
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
10
|
+
* Reads Claude Code's MCP config too. User config (~/.claude.json,
|
|
11
|
+
* ~/.pi/agent/mcp.json) is the user's own and loads on the first session. Project
|
|
12
|
+
* config (.mcp.json, .pi/mcp.json) can run arbitrary commands on connect, so it
|
|
13
|
+
* loads only once the project is approved (see project-approval). The two scopes
|
|
14
|
+
* are loaded separately, not merged; user config connects first, so a project
|
|
15
|
+
* server cannot take the name of a user server that connected.
|
|
16
|
+
* Values support ${VAR} interpolation, and a stdio server receives only the SDK's
|
|
17
|
+
* default environment plus its own `env` block, not the whole process environment.
|
|
14
18
|
*/
|
|
15
19
|
|
|
16
20
|
import * as fs from 'node:fs'
|
|
@@ -66,15 +70,6 @@ export function projectConfigPaths(cwd: string): string[] {
|
|
|
66
70
|
return [path.join(cwd, '.mcp.json'), path.join(cwd, '.pi', 'mcp.json')]
|
|
67
71
|
}
|
|
68
72
|
|
|
69
|
-
/** All config files, later winning: user first, then project. */
|
|
70
|
-
export function configPaths(cwd: string, home: string): string[] {
|
|
71
|
-
return [...userConfigPaths(home), ...projectConfigPaths(cwd)]
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
export function loadConfig(cwd: string): Record<string, ServerConfig> {
|
|
75
|
-
return loadConfigFrom(configPaths(cwd, os.homedir()))
|
|
76
|
-
}
|
|
77
|
-
|
|
78
73
|
export function loadConfigFrom(files: string[]): Record<string, ServerConfig> {
|
|
79
74
|
const servers: Record<string, ServerConfig> = {}
|
|
80
75
|
for (const file of files) {
|
|
@@ -159,13 +159,3 @@ export function discoverAgents(cwd: string, scope: AgentScope): AgentDiscoveryRe
|
|
|
159
159
|
const agentMap = buildAgentMap(userAgents, projectAgents, scope)
|
|
160
160
|
return { agents: Array.from(agentMap.values()), projectAgentsDir: projectPiDir }
|
|
161
161
|
}
|
|
162
|
-
|
|
163
|
-
export function formatAgentList(agents: AgentConfig[], maxItems: number): { text: string; remaining: number } {
|
|
164
|
-
if (agents.length === 0) return { text: 'none', remaining: 0 }
|
|
165
|
-
const listed = agents.slice(0, maxItems)
|
|
166
|
-
const remaining = agents.length - listed.length
|
|
167
|
-
return {
|
|
168
|
-
text: listed.map((a) => `${a.name} (${a.source}): ${a.description}`).join('; '),
|
|
169
|
-
remaining,
|
|
170
|
-
}
|
|
171
|
-
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pi-code",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.4",
|
|
4
4
|
"description": "Claude Code experience for the pi coding agent: reads your .claude config (rules, commands, skills, hooks, output styles, MCP servers, agents) and adds todo, checkpoints, memory, web, and subagents",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"pi-package"
|