pi-profile-switch 0.3.1 → 0.4.2
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 +31 -36
- package/README.zh-CN.md +31 -36
- package/bin/pi-profile.js +11 -0
- package/bin/pi-profile.ts +65 -0
- package/bin/postinstall.d.ts +13 -0
- package/bin/postinstall.js +88 -0
- package/defaults/profiles.json +18 -0
- package/examples/profiles.json +31 -5
- package/extensions/pi-profile/index.ts +451 -0
- package/package.json +10 -13
- package/schemas/profiles.schema.json +22 -24
- package/src/extension-discovery.ts +347 -0
- package/src/json-file.ts +1 -21
- package/src/launcher/args.ts +57 -0
- package/src/launcher/discovery.ts +64 -0
- package/src/launcher/initial-profile.ts +179 -0
- package/src/launcher/model-check.ts +52 -0
- package/src/launcher/runtime-cleanup.ts +85 -0
- package/src/launcher/spawn.ts +82 -0
- package/src/mcp-config.ts +37 -153
- package/src/mcp-coordination.ts +29 -10
- package/src/profile-catalog-store.ts +31 -12
- package/src/profile-catalog.ts +45 -93
- package/src/profile-resolver.ts +239 -245
- package/src/project-trust.ts +82 -0
- package/src/runtime-state-store.ts +25 -41
- package/src/settings-generator.ts +541 -0
- package/src/skill-registry.ts +94 -0
- package/src/switching/apply-plan.ts +197 -0
- package/src/switching/customize.ts +62 -33
- package/src/switching/list-profiles.ts +9 -6
- package/src/switching/mcp-toggle.ts +14 -26
- package/src/switching/profile-crud.ts +31 -24
- package/src/switching/profile-wizard.ts +21 -49
- package/src/switching/status.ts +142 -72
- package/src/switching/switch-profile.ts +219 -0
- package/src/switching/tool-references.ts +40 -0
- package/src/workspace.ts +57 -0
- package/LICENSE +0 -21
- package/examples/profiles.example.json +0 -74
- package/extensions/pi-profile-switch/index.ts +0 -778
- package/src/adapter-presence.ts +0 -75
- package/src/default-profiles.ts +0 -59
- package/src/mcp-overlay-file.ts +0 -35
- package/src/mcp-overlay.ts +0 -122
- package/src/model-selection.ts +0 -64
- package/src/name-matching.ts +0 -50
- package/src/profile-badge.ts +0 -142
- package/src/profile-presets.ts +0 -61
- package/src/skill-selection.ts +0 -81
- package/src/startup-mcp-scope.ts +0 -271
- package/src/startup-selection.ts +0 -201
- package/src/switching/activate-profile.ts +0 -144
- package/src/switching/apply-profile.ts +0 -131
package/src/workspace.ts
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Workspace management for pi-profile-switch.
|
|
3
|
+
*
|
|
4
|
+
* Rooted at `~/.pi-profile-switch` (or `PI_PROFILE_SWITCH_DIR` override).
|
|
5
|
+
* Contains:
|
|
6
|
+
* - `profiles.json`: global profile definitions catalog
|
|
7
|
+
* - `instances/`: instance runtime directories for forked pi processes
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
import { existsSync } from "node:fs";
|
|
11
|
+
import { homedir } from "node:os";
|
|
12
|
+
import path from "node:path";
|
|
13
|
+
|
|
14
|
+
export function getProfileSwitchDir(): string {
|
|
15
|
+
const env = process.env.PI_PROFILE_SWITCH_DIR;
|
|
16
|
+
if (env && env.trim()) {
|
|
17
|
+
return path.resolve(env.trim());
|
|
18
|
+
}
|
|
19
|
+
return path.join(homedir(), ".pi-profile-switch");
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export function getGlobalProfilesPath(): string {
|
|
23
|
+
return path.join(getProfileSwitchDir(), "profiles.json");
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export function resolveGlobalProfilesPath(agentDir: string): string {
|
|
27
|
+
const preferred = getGlobalProfilesPath();
|
|
28
|
+
if (existsSync(preferred)) {
|
|
29
|
+
return preferred;
|
|
30
|
+
}
|
|
31
|
+
// Fallback for legacy ~/.pi/agent/profiles.json
|
|
32
|
+
const fallback = path.join(agentDir, "profiles.json");
|
|
33
|
+
if (existsSync(fallback)) {
|
|
34
|
+
return fallback;
|
|
35
|
+
}
|
|
36
|
+
return preferred;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export function getInstancesRootDir(): string {
|
|
40
|
+
return path.join(getProfileSwitchDir(), "instances");
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export function getGlobalStateDir(agentDir?: string): string {
|
|
44
|
+
const preferred = getProfileSwitchDir();
|
|
45
|
+
const preferredState = path.join(preferred, "pi-profile-state.json");
|
|
46
|
+
if (existsSync(preferredState)) {
|
|
47
|
+
return preferred;
|
|
48
|
+
}
|
|
49
|
+
if (agentDir) {
|
|
50
|
+
const fallbackState = path.join(agentDir, "pi-profile-state.json");
|
|
51
|
+
if (existsSync(fallbackState)) {
|
|
52
|
+
return agentDir;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
return agentDir ?? preferred;
|
|
56
|
+
}
|
|
57
|
+
|
package/LICENSE
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
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.
|
|
@@ -1,74 +0,0 @@
|
|
|
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
|
-
"mcps": [
|
|
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
|
-
"mcps": [
|
|
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
|
-
}
|