pi-profile-switch 0.1.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 VincentFF
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,106 @@
1
+ # pi-profile-switch
2
+
3
+ [English](README.md) | [中文](README.zh-CN.md)
4
+
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
+
7
+ Use a lean read-only profile for code review, a full-powered one for implementation, a minimal one for a quick question.
8
+
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
+
11
+ ## Install
12
+
13
+ ```bash
14
+ pi install npm:pi-profile-switch
15
+ ```
16
+
17
+ Requires [Pi](https://www.npmjs.com/package/@earendil-works/pi-coding-agent) (installed automatically as a peer dependency).
18
+
19
+ ## Quick start
20
+
21
+ ```bash
22
+ # Use the saved profile (or the built-in default)
23
+ pi
24
+
25
+ # Use a profile for this run only (not saved)
26
+ pi --profile review
27
+
28
+ # The explicit native baseline
29
+ pi --profile default
30
+ ```
31
+
32
+ Define profiles in `~/.pi/agent/profiles.json` (global) or `<project>/.pi/profiles.json` (project, trusted projects only):
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
+ ```
48
+
49
+ Profiles **reference** resources by name — they never copy them. Full schema with more examples: [`examples/profiles.json`](examples/profiles.json).
50
+
51
+ Existing `schemaVersion: 1` catalogs keep working: the `extensions` field is reported once and ignored, because extensions now load natively in every profile.
52
+
53
+ ## What a profile controls
54
+
55
+ | Field | Effect |
56
+ | --- | --- |
57
+ | `instructions` | Text appended to the system prompt every turn |
58
+ | `model` | Session-start model preset; an explicit `--model`/`--thinking` or a model recorded in the session wins |
59
+ | `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` | Runtime server allowlist published to `pi-mcp-adapter`; connection details stay in the adapter's own config |
61
+ | `tools` | Active tool set: declared names/globs become the active set; names that register later (MCP, extensions) are applied when they appear |
62
+
63
+ Anything a profile does not declare keeps Pi's native behavior, and `default` declares nothing.
64
+
65
+ ## Commands
66
+
67
+ In the TUI, the `/profile` command family manages everything in-session:
68
+
69
+ | Command | What it does |
70
+ | --- | --- |
71
+ | `/profile` | Interactive profile picker |
72
+ | `/profile list` / `/profile status` | Show profiles / active profile details |
73
+ | `/profile use <name>` | Switch instantly — same session, no reload |
74
+ | `/profile create\|edit\|delete\|duplicate` | Guided profile CRUD (TUI only) |
75
+ | `/profile customize` / `/profile reset` | Narrow the active profile for this session only |
76
+ | `/mcp enable\|disable <server>` | Toggle MCP servers in the active profile |
77
+
78
+ All commands work in non-interactive modes (`--mode rpc|print|json`); CRUD wizards are TUI-only.
79
+
80
+ ## Guarantees
81
+
82
+ - **Reference, never copy** — profiles point at resources you already own and maintain.
83
+ - **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
+ - **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; the next turn's prompt carries the new selection.
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.
98
+
99
+ ## Docs
100
+
101
+ - [Architecture](docs/architecture/overview.md) · [ADRs](docs/adr/) · [Glossary](CONTEXT.md) (Chinese)
102
+ - JSON Schema: [`schemas/profiles.schema.json`](schemas/profiles.schema.json)
103
+
104
+ ## License
105
+
106
+ MIT
@@ -0,0 +1,106 @@
1
+ # pi-profile-switch
2
+
3
+ [English](README.md) | [中文](README.zh-CN.md)
4
+
5
+ [Pi](https://github.com/badlogic/pi-mono) 的命名 profile 扩展。一个 profile 选择模型看到什么、会话使用哪些能力——skills、MCP server、tools、预制模型和附加指令——并在同一 Pi 进程内即时切换。
6
+
7
+ 代码评审用精简的只读 profile,实现需求用全量 profile,临时提问用最小 profile。
8
+
9
+ `pi-profile-switch` 是普通 Pi package(ADR-0007):像其他扩展一样安装,不改动 Pi 的配置目录,session、packages、项目信任和其他扩展全部保持原生。
10
+
11
+ ## 安装
12
+
13
+ ```bash
14
+ pi install npm:pi-profile-switch
15
+ ```
16
+
17
+ 依赖 [Pi](https://www.npmjs.com/package/@earendil-works/pi-coding-agent)(作为 peer dependency 自动安装)。
18
+
19
+ ## 快速上手
20
+
21
+ ```bash
22
+ # 使用已保存的 profile(不存在时用内建 default)
23
+ pi
24
+
25
+ # 仅本次启动使用指定 profile(不保存)
26
+ pi --profile review
27
+
28
+ # 显式的原生基线
29
+ pi --profile default
30
+ ```
31
+
32
+ 在 `~/.pi/agent/profiles.json`(全局)或 `<项目>/.pi/profiles.json`(项目级,仅限已信任项目)中定义 profile:
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
+ ```
48
+
49
+ Profile 只**引用**资源,从不复制资源。完整示例见 [`examples/profiles.json`](examples/profiles.json)。
50
+
51
+ 已有的 `schemaVersion: 1` catalog 继续可用:`extensions` 字段会被警告一次并忽略——extensions 现在在所有 profile 中原生加载。
52
+
53
+ ## Profile 控制的范围
54
+
55
+ | 字段 | 效果 |
56
+ | --- | --- |
57
+ | `instructions` | 每个 turn 追加到 system prompt 末尾 |
58
+ | `model` | 会话启动的模型预设;显式 `--model`/`--thinking` 或 session 历史中记录的模型优先 |
59
+ | `skills` | 模型在 prompt skills 列表中看到的内容;所有已安装 skill 仍保持加载,用户可用 `/skill:name` 手动调用 |
60
+ | `mcp` | 发布给 `pi-mcp-adapter` 的运行时 server allowlist;连接参数仍由 adapter 自己管理 |
61
+ | `tools` | 活动工具集:声明的名字/glob 成为活动集合;之后才注册的工具(MCP、扩展)在出现时补上 |
62
+
63
+ 未声明的字段保持 Pi 原生行为,`default` 什么都不声明。
64
+
65
+ ## 命令
66
+
67
+ 在 TUI 中,`/profile` 命令族完成所有会话内操作:
68
+
69
+ | 命令 | 作用 |
70
+ | --- | --- |
71
+ | `/profile` | 交互式选择 profile |
72
+ | `/profile list` / `/profile status` | 列出 profile / 查看活动 profile 详情 |
73
+ | `/profile use <name>` | 即时切换——同一 session,无 reload |
74
+ | `/profile create\|edit\|delete\|duplicate` | 向导式 profile 增删改(仅 TUI) |
75
+ | `/profile customize` / `/profile reset` | 仅本次会话收窄活动 profile |
76
+ | `/mcp enable\|disable <server>` | 在活动 profile 中开关 MCP server |
77
+
78
+ 非交互模式(`--mode rpc|print|json`)下命令同样生效;CRUD 向导仅 TUI 可用。
79
+
80
+ ## 保证
81
+
82
+ - **引用而非复制**——profile 指向你自己拥有和维护的资源。
83
+ - **Pi 原生**——配置目录就是 Pi 自己的目录,session、扩展配置、packages、context 文件和信任行为与原生 Pi 完全一致。
84
+ - **失败安全**——未信任的项目目录从不读取;激活失败时不应用任何设置并报出原因。
85
+ - **无 reload**——切换在原位重新应用运行时状态;下一个 turn 的 prompt 直接带上新选择。
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/` 目录;新版本不再创建它们。
98
+
99
+ ## 文档
100
+
101
+ - [架构设计](docs/architecture/overview.md) · [ADR](docs/adr/) · [术语表](CONTEXT.md)
102
+ - JSON Schema:[`schemas/profiles.schema.json`](schemas/profiles.schema.json)
103
+
104
+ ## 许可证
105
+
106
+ MIT
@@ -0,0 +1,38 @@
1
+ {
2
+ "schemaVersion": 2,
3
+ "profiles": {
4
+ "review": {
5
+ "label": "Code review",
6
+ "description": "Read-heavy review workflow",
7
+ "skills": [
8
+ "code-review",
9
+ "diagnosing-bugs"
10
+ ],
11
+ "mcp": [
12
+ "github"
13
+ ],
14
+ "tools": [
15
+ "read",
16
+ "grep",
17
+ "find",
18
+ "bash"
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"
30
+ ],
31
+ "model": {
32
+ "provider": "deepseek",
33
+ "id": "deepseek-v4-pro",
34
+ "thinkingLevel": "high"
35
+ }
36
+ }
37
+ }
38
+ }