pi-profile-switch 0.1.0 → 0.3.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.
- package/README.md +10 -36
- package/README.zh-CN.md +10 -36
- package/examples/profiles.example.json +74 -0
- package/examples/profiles.json +6 -28
- package/extensions/pi-profile-switch/index.ts +213 -18
- package/package.json +1 -1
- package/schemas/profiles.schema.json +2 -8
- package/src/adapter-presence.ts +75 -0
- package/src/json-file.ts +20 -0
- package/src/mcp-config.ts +153 -34
- package/src/mcp-overlay-file.ts +35 -0
- package/src/mcp-overlay.ts +122 -0
- package/src/profile-badge.ts +142 -0
- package/src/profile-catalog-store.ts +4 -5
- package/src/profile-catalog.ts +17 -43
- package/src/profile-presets.ts +61 -0
- package/src/profile-resolver.ts +51 -18
- package/src/runtime-state-store.ts +13 -0
- package/src/startup-mcp-scope.ts +262 -0
- package/src/startup-selection.ts +1 -4
- package/src/switching/activate-profile.ts +8 -6
- package/src/switching/list-profiles.ts +8 -11
- package/src/switching/profile-wizard.ts +39 -6
package/README.md
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
Named profiles for [Pi](https://github.com/badlogic/pi-mono). A profile selects what the model sees and which capabilities the session uses — skills, MCP servers, tools, a model preset, and extra instructions — switchable in the same Pi process.
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
A shipped `read-only` preset covers the read-and-report workflow; other workflows you write yourself — a profile can narrow the tool set, hide skills, pin a model, or add instructions.
|
|
8
8
|
|
|
9
9
|
`pi-profile-switch` is a plain Pi package (ADR-0007). It installs like any other extension, leaves Pi's configuration directory untouched, and keeps sessions, packages, project trust, and every other installed extension native.
|
|
10
10
|
|
|
@@ -23,32 +23,17 @@ Requires [Pi](https://www.npmjs.com/package/@earendil-works/pi-coding-agent) (in
|
|
|
23
23
|
pi
|
|
24
24
|
|
|
25
25
|
# Use a profile for this run only (not saved)
|
|
26
|
-
pi --profile
|
|
26
|
+
pi --profile read-only
|
|
27
27
|
|
|
28
28
|
# The explicit native baseline
|
|
29
29
|
pi --profile default
|
|
30
30
|
```
|
|
31
31
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
```json
|
|
35
|
-
{
|
|
36
|
-
"schemaVersion": 2,
|
|
37
|
-
"profiles": {
|
|
38
|
-
"review": {
|
|
39
|
-
"label": "Code review",
|
|
40
|
-
"skills": ["code-review"],
|
|
41
|
-
"mcp": ["github"],
|
|
42
|
-
"tools": ["read", "grep", "find", "bash"],
|
|
43
|
-
"instructions": "Review only; do not modify files."
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
```
|
|
32
|
+
Create profiles with `/profile create`, which writes `~/.pi/agent/profiles.json` (global) or `<project>/.pi/profiles.json` (project, trusted projects only). The wizard offers the shipped `read-only` preset — Pi's built-in tools only, no skills, MCP servers, or model assumed — or a blank definition.
|
|
48
33
|
|
|
49
|
-
Profiles **reference** resources by name — they never copy them.
|
|
34
|
+
A preset is a one-time copy into your catalog: it is not tracked, so a package update never changes a profile you already created. Profiles **reference** resources by name — they never copy them. [`examples/profiles.example.json`](examples/profiles.example.json) is a complete catalog with several profiles covering every field; replace its resource names with ones you own.
|
|
50
35
|
|
|
51
|
-
|
|
36
|
+
`schemaVersion` is 1 and is the only accepted value. A profile cannot select extensions: they load natively in every profile, so manage them with `pi install`.
|
|
52
37
|
|
|
53
38
|
## What a profile controls
|
|
54
39
|
|
|
@@ -57,7 +42,7 @@ Existing `schemaVersion: 1` catalogs keep working: the `extensions` field is rep
|
|
|
57
42
|
| `instructions` | Text appended to the system prompt every turn |
|
|
58
43
|
| `model` | Session-start model preset; an explicit `--model`/`--thinking` or a model recorded in the session wins |
|
|
59
44
|
| `skills` | What the model sees in the prompt's skills list. Every installed skill stays loaded and callable by the user through `/skill:name` |
|
|
60
|
-
| `mcp` |
|
|
45
|
+
| `mcp` | Which MCP servers the session exposes: the profile's allowlist is written into the adapter's own config (`~/.pi/agent/mcp.json`), disabling every other server. Servers you keep in that file move to `mcp.user.json`; connection details stay in your config, never in the profile |
|
|
61
46
|
| `tools` | Active tool set: declared names/globs become the active set; names that register later (MCP, extensions) are applied when they appear |
|
|
62
47
|
|
|
63
48
|
Anything a profile does not declare keeps Pi's native behavior, and `default` declares nothing.
|
|
@@ -70,11 +55,13 @@ In the TUI, the `/profile` command family manages everything in-session:
|
|
|
70
55
|
| --- | --- |
|
|
71
56
|
| `/profile` | Interactive profile picker |
|
|
72
57
|
| `/profile list` / `/profile status` | Show profiles / active profile details |
|
|
73
|
-
| `/profile use <name>` | Switch
|
|
58
|
+
| `/profile use <name>` | Switch in place — same session; when the MCP selection changes, the runtime reloads automatically to re-apply it |
|
|
74
59
|
| `/profile create\|edit\|delete\|duplicate` | Guided profile CRUD (TUI only) |
|
|
75
60
|
| `/profile customize` / `/profile reset` | Narrow the active profile for this session only |
|
|
76
61
|
| `/mcp enable\|disable <server>` | Toggle MCP servers in the active profile |
|
|
77
62
|
|
|
63
|
+
While a non-`default` profile is active, the footer shows `profile: <name>`, with `*` appended when a session-only overlay is in effect. `default` shows no badge, so an unprofiled session keeps Pi's native footer.
|
|
64
|
+
|
|
78
65
|
All commands work in non-interactive modes (`--mode rpc|print|json`); CRUD wizards are TUI-only.
|
|
79
66
|
|
|
80
67
|
## Guarantees
|
|
@@ -82,24 +69,11 @@ All commands work in non-interactive modes (`--mode rpc|print|json`); CRUD wizar
|
|
|
82
69
|
- **Reference, never copy** — profiles point at resources you already own and maintain.
|
|
83
70
|
- **Pi-native** — the configuration directory is Pi's own, so sessions, extension config, packages, context files, and trust behave exactly as they do in plain Pi.
|
|
84
71
|
- **Fail safe** — untrusted project directories are never read; a failed activation applies nothing and reports the cause.
|
|
85
|
-
- **No reload** — switching re-applies runtime state in place
|
|
86
|
-
|
|
87
|
-
## Migrating from the launcher
|
|
88
|
-
|
|
89
|
-
```bash
|
|
90
|
-
pi-profile review # before
|
|
91
|
-
pi --profile review # after
|
|
92
|
-
|
|
93
|
-
pi-profile review -- --mode rpc # before
|
|
94
|
-
pi --profile review --mode rpc # after
|
|
95
|
-
```
|
|
96
|
-
|
|
97
|
-
`/profile reload` and the `/profile resource` commands are gone: skills are read on demand and catalogs are re-read on every use, so there is nothing to reload. Remove leftover `~/.pi/agent/pi-profile/runtime/` directories; the extension no longer creates them.
|
|
72
|
+
- **No manual reload** — switching re-applies runtime state in place and the next turn's prompt carries the new selection. Only a change to the MCP selection rebuilds the runtime, automatically, in the same session.
|
|
98
73
|
|
|
99
74
|
## Docs
|
|
100
75
|
|
|
101
76
|
- [Architecture](docs/architecture/overview.md) · [ADRs](docs/adr/) · [Glossary](CONTEXT.md) (Chinese)
|
|
102
|
-
- JSON Schema: [`schemas/profiles.schema.json`](schemas/profiles.schema.json)
|
|
103
77
|
|
|
104
78
|
## License
|
|
105
79
|
|
package/README.zh-CN.md
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
[Pi](https://github.com/badlogic/pi-mono) 的命名 profile 扩展。一个 profile 选择模型看到什么、会话使用哪些能力——skills、MCP server、tools、预制模型和附加指令——并在同一 Pi 进程内即时切换。
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
随包提供一个 `read-only` 预设覆盖「读代码 + 报告」的工作流;其余工作流由你自己定义——profile 可以收窄工具集、隐藏 skill、固定模型或附加指令。
|
|
8
8
|
|
|
9
9
|
`pi-profile-switch` 是普通 Pi package(ADR-0007):像其他扩展一样安装,不改动 Pi 的配置目录,session、packages、项目信任和其他扩展全部保持原生。
|
|
10
10
|
|
|
@@ -23,32 +23,17 @@ pi install npm:pi-profile-switch
|
|
|
23
23
|
pi
|
|
24
24
|
|
|
25
25
|
# 仅本次启动使用指定 profile(不保存)
|
|
26
|
-
pi --profile
|
|
26
|
+
pi --profile read-only
|
|
27
27
|
|
|
28
28
|
# 显式的原生基线
|
|
29
29
|
pi --profile default
|
|
30
30
|
```
|
|
31
31
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
```json
|
|
35
|
-
{
|
|
36
|
-
"schemaVersion": 2,
|
|
37
|
-
"profiles": {
|
|
38
|
-
"review": {
|
|
39
|
-
"label": "Code review",
|
|
40
|
-
"skills": ["code-review"],
|
|
41
|
-
"mcp": ["github"],
|
|
42
|
-
"tools": ["read", "grep", "find", "bash"],
|
|
43
|
-
"instructions": "Review only; do not modify files."
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
```
|
|
32
|
+
用 `/profile create` 创建 profile,写入 `~/.pi/agent/profiles.json`(全局)或 `<项目>/.pi/profiles.json`(项目级,仅限已信任项目)。向导提供随包的 `read-only` 预设——只用 Pi 内建工具,不假设任何 skill、MCP server 或模型——也可以从空定义开始。
|
|
48
33
|
|
|
49
|
-
Profile
|
|
34
|
+
预设只被复制一次:它不被跟踪,包升级不会改动你已经创建的 profile。Profile 只**引用**资源,从不复制资源。[`examples/profiles.example.json`](examples/profiles.example.json) 是覆盖全部字段的完整 catalog,示例中的资源名请替换成你本机已有的名字。
|
|
50
35
|
|
|
51
|
-
|
|
36
|
+
`schemaVersion` 为 1,也是唯一接受的值。Profile 不选择 extension:extensions 在所有 profile 中原生加载,请用 `pi install` 管理。
|
|
52
37
|
|
|
53
38
|
## Profile 控制的范围
|
|
54
39
|
|
|
@@ -57,7 +42,7 @@ Profile 只**引用**资源,从不复制资源。完整示例见 [`examples/pr
|
|
|
57
42
|
| `instructions` | 每个 turn 追加到 system prompt 末尾 |
|
|
58
43
|
| `model` | 会话启动的模型预设;显式 `--model`/`--thinking` 或 session 历史中记录的模型优先 |
|
|
59
44
|
| `skills` | 模型在 prompt skills 列表中看到的内容;所有已安装 skill 仍保持加载,用户可用 `/skill:name` 手动调用 |
|
|
60
|
-
| `mcp` |
|
|
45
|
+
| `mcp` | 本次会话暴露哪些 MCP server:白名单写入 adapter 自己的配置(`~/.pi/agent/mcp.json`),其余 server 一律标为 disabled。你原本放在该文件里的 server 会迁移到 `mcp.user.json`;连接参数只在你自己的配置里,从不进入 profile |
|
|
61
46
|
| `tools` | 活动工具集:声明的名字/glob 成为活动集合;之后才注册的工具(MCP、扩展)在出现时补上 |
|
|
62
47
|
|
|
63
48
|
未声明的字段保持 Pi 原生行为,`default` 什么都不声明。
|
|
@@ -70,11 +55,13 @@ Profile 只**引用**资源,从不复制资源。完整示例见 [`examples/pr
|
|
|
70
55
|
| --- | --- |
|
|
71
56
|
| `/profile` | 交互式选择 profile |
|
|
72
57
|
| `/profile list` / `/profile status` | 列出 profile / 查看活动 profile 详情 |
|
|
73
|
-
| `/profile use <name>` |
|
|
58
|
+
| `/profile use <name>` | 原位切换——同一 session;当 MCP 选择发生变化时会自动 reload 以重新应用 |
|
|
74
59
|
| `/profile create\|edit\|delete\|duplicate` | 向导式 profile 增删改(仅 TUI) |
|
|
75
60
|
| `/profile customize` / `/profile reset` | 仅本次会话收窄活动 profile |
|
|
76
61
|
| `/mcp enable\|disable <server>` | 在活动 profile 中开关 MCP server |
|
|
77
62
|
|
|
63
|
+
活动 profile 不是 `default` 时,footer 显示 `profile: <name>`;本次会话的 overlay 生效时追加 `*`。`default` 不显示 badge,未使用 profile 的会话保持 Pi 原生 footer。
|
|
64
|
+
|
|
78
65
|
非交互模式(`--mode rpc|print|json`)下命令同样生效;CRUD 向导仅 TUI 可用。
|
|
79
66
|
|
|
80
67
|
## 保证
|
|
@@ -82,24 +69,11 @@ Profile 只**引用**资源,从不复制资源。完整示例见 [`examples/pr
|
|
|
82
69
|
- **引用而非复制**——profile 指向你自己拥有和维护的资源。
|
|
83
70
|
- **Pi 原生**——配置目录就是 Pi 自己的目录,session、扩展配置、packages、context 文件和信任行为与原生 Pi 完全一致。
|
|
84
71
|
- **失败安全**——未信任的项目目录从不读取;激活失败时不应用任何设置并报出原因。
|
|
85
|
-
-
|
|
86
|
-
|
|
87
|
-
## 从 launcher 迁移
|
|
88
|
-
|
|
89
|
-
```bash
|
|
90
|
-
pi-profile review # 旧
|
|
91
|
-
pi --profile review # 新
|
|
92
|
-
|
|
93
|
-
pi-profile review -- --mode rpc # 旧
|
|
94
|
-
pi --profile review --mode rpc # 新
|
|
95
|
-
```
|
|
96
|
-
|
|
97
|
-
`/profile reload` 与 `/profile resource` 命令已移除:skill 内容按需读取、catalog 每次使用重新读取,没有需要 reload 的缓存。删除遗留的 `~/.pi/agent/pi-profile/runtime/` 目录;新版本不再创建它们。
|
|
72
|
+
- **无需手动 reload**——切换在原位重新应用运行时状态,下一个 turn 的 prompt 直接带上新选择;只有 MCP 选择变化时才会自动重建运行时(同一 session)
|
|
98
73
|
|
|
99
74
|
## 文档
|
|
100
75
|
|
|
101
76
|
- [架构设计](docs/architecture/overview.md) · [ADR](docs/adr/) · [术语表](CONTEXT.md)
|
|
102
|
-
- JSON Schema:[`schemas/profiles.schema.json`](schemas/profiles.schema.json)
|
|
103
77
|
|
|
104
78
|
## 许可证
|
|
105
79
|
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
{
|
|
2
|
+
"schemaVersion": 1,
|
|
3
|
+
"profiles": {
|
|
4
|
+
"read-only": {
|
|
5
|
+
"label": "Read-only",
|
|
6
|
+
"description": "Read-only session; no skills or MCP servers assumed — add your own.",
|
|
7
|
+
"tools": [
|
|
8
|
+
"read",
|
|
9
|
+
"grep",
|
|
10
|
+
"find",
|
|
11
|
+
"ls"
|
|
12
|
+
],
|
|
13
|
+
"instructions": "Read-only session: inspect and report; never create, edit, rename, or delete files.\nIf a change is needed, describe it in your reply instead of applying it.\nDo not run commands that modify state (installs, formatters, commits, pushes, network writes).\nPrefer an available skill or MCP tool when it fits the request; otherwise use the tools you have.\nGround claims in evidence: cite file:line and separate verified facts from inferences.\nReply in English."
|
|
14
|
+
},
|
|
15
|
+
"review": {
|
|
16
|
+
"label": "Code review",
|
|
17
|
+
"description": "Review a diff or a branch: read the change, report findings, modify nothing.",
|
|
18
|
+
"skills": [
|
|
19
|
+
"code-review",
|
|
20
|
+
"git-*"
|
|
21
|
+
],
|
|
22
|
+
"mcp": [
|
|
23
|
+
"github"
|
|
24
|
+
],
|
|
25
|
+
"tools": [
|
|
26
|
+
"read",
|
|
27
|
+
"grep",
|
|
28
|
+
"find",
|
|
29
|
+
"ls",
|
|
30
|
+
"bash"
|
|
31
|
+
],
|
|
32
|
+
"model": {
|
|
33
|
+
"provider": "anthropic",
|
|
34
|
+
"id": "claude-sonnet-4-5",
|
|
35
|
+
"thinkingLevel": "high"
|
|
36
|
+
},
|
|
37
|
+
"instructions": "Review only: read the change under review, then report findings with file:line evidence.\nNever edit tracked files, commit, or push; describe the required fix instead.\nSeparate verified behavior from suspected issues."
|
|
38
|
+
},
|
|
39
|
+
"plan": {
|
|
40
|
+
"label": "Plan",
|
|
41
|
+
"description": "Research a change and write the plan; no edits, no implementation.",
|
|
42
|
+
"skills": [],
|
|
43
|
+
"tools": [
|
|
44
|
+
"read",
|
|
45
|
+
"grep",
|
|
46
|
+
"find",
|
|
47
|
+
"ls",
|
|
48
|
+
"bash"
|
|
49
|
+
],
|
|
50
|
+
"instructions": "Planning session: research the code first, then write the plan in your reply.\nDo not create, edit, rename, or delete files."
|
|
51
|
+
},
|
|
52
|
+
"implement": {
|
|
53
|
+
"label": "Implement",
|
|
54
|
+
"description": "Full tool access for implementing a change end to end.",
|
|
55
|
+
"skills": [
|
|
56
|
+
"git-commit",
|
|
57
|
+
"test-*"
|
|
58
|
+
],
|
|
59
|
+
"mcp": [
|
|
60
|
+
"github"
|
|
61
|
+
],
|
|
62
|
+
"tools": [
|
|
63
|
+
"read",
|
|
64
|
+
"grep",
|
|
65
|
+
"find",
|
|
66
|
+
"ls",
|
|
67
|
+
"bash",
|
|
68
|
+
"edit",
|
|
69
|
+
"write"
|
|
70
|
+
],
|
|
71
|
+
"instructions": "Implement the requested change: read before writing, keep the diff minimal.\nRun the tests that cover your change and report the exact commands."
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
}
|
package/examples/profiles.json
CHANGED
|
@@ -1,38 +1,16 @@
|
|
|
1
1
|
{
|
|
2
|
-
"schemaVersion":
|
|
2
|
+
"schemaVersion": 1,
|
|
3
3
|
"profiles": {
|
|
4
|
-
"
|
|
5
|
-
"label": "
|
|
6
|
-
"description": "Read-
|
|
7
|
-
"skills": [
|
|
8
|
-
"code-review",
|
|
9
|
-
"diagnosing-bugs"
|
|
10
|
-
],
|
|
11
|
-
"mcp": [
|
|
12
|
-
"github"
|
|
13
|
-
],
|
|
4
|
+
"read-only": {
|
|
5
|
+
"label": "Read-only",
|
|
6
|
+
"description": "Read-only session; no skills or MCP servers assumed — add your own.",
|
|
14
7
|
"tools": [
|
|
15
8
|
"read",
|
|
16
9
|
"grep",
|
|
17
10
|
"find",
|
|
18
|
-
"
|
|
19
|
-
],
|
|
20
|
-
"instructions": "Review only; do not modify files."
|
|
21
|
-
},
|
|
22
|
-
"impl": {
|
|
23
|
-
"label": "Implementation",
|
|
24
|
-
"skills": [
|
|
25
|
-
"tdd"
|
|
26
|
-
],
|
|
27
|
-
"mcp": [
|
|
28
|
-
"github",
|
|
29
|
-
"linear"
|
|
11
|
+
"ls"
|
|
30
12
|
],
|
|
31
|
-
"
|
|
32
|
-
"provider": "deepseek",
|
|
33
|
-
"id": "deepseek-v4-pro",
|
|
34
|
-
"thinkingLevel": "high"
|
|
35
|
-
}
|
|
13
|
+
"instructions": "Read-only session: inspect and report; never create, edit, rename, or delete files.\nIf a change is needed, describe it in your reply instead of applying it.\nDo not run commands that modify state (installs, formatters, commits, pushes, network writes).\nPrefer an available skill or MCP tool when it fits the request; otherwise use the tools you have.\nGround claims in evidence: cite file:line and separate verified facts from inferences.\nReply in English."
|
|
36
14
|
}
|
|
37
15
|
}
|
|
38
16
|
}
|