pi-profile-switch 0.13.0 → 0.13.1
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/package.json +1 -1
- package/src/settings-generator.ts +28 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pi-profile-switch",
|
|
3
|
-
"version": "0.13.
|
|
3
|
+
"version": "0.13.1",
|
|
4
4
|
"description": "Named profiles for Pi: reference skills, extensions, MCP servers, and tools per workflow, switched without restarting. Install: npm install -g pi-profile-switch (not pi install).",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"keywords": [
|
|
@@ -170,6 +170,29 @@ function homeAgentsSkillsDir(): string {
|
|
|
170
170
|
return path.join(process.env.HOME ?? homedir(), ".agents", "skills");
|
|
171
171
|
}
|
|
172
172
|
|
|
173
|
+
/** The user's own skill exclusions (`!pattern`, `-path`), carried into a
|
|
174
|
+
* named profile's generated settings. Relative entries resolve against the
|
|
175
|
+
* runtime dir, which mirrors the agent dir, so they pass through unchanged.
|
|
176
|
+
* An absolute (or `~`) `-path` under the agent dir is rewritten to its
|
|
177
|
+
* runtime mirror path: Pi matches `-` entries lexically. */
|
|
178
|
+
function userSkillExclusions(userSkills: unknown, agentDir: string, runtimeDir: string): string[] {
|
|
179
|
+
if (!Array.isArray(userSkills)) return [];
|
|
180
|
+
const exclusions: string[] = [];
|
|
181
|
+
for (const entry of userSkills) {
|
|
182
|
+
if (typeof entry !== "string") continue;
|
|
183
|
+
if (entry.startsWith("!")) {
|
|
184
|
+
exclusions.push(entry);
|
|
185
|
+
} else if (entry.startsWith("-")) {
|
|
186
|
+
const target = entry.slice(1);
|
|
187
|
+
const expanded = target === "~" || target.startsWith("~/") ? path.join(process.env.HOME ?? homedir(), target.slice(1)) : target;
|
|
188
|
+
const rel = path.isAbsolute(expanded) ? path.relative(agentDir, expanded) : undefined;
|
|
189
|
+
const underAgentDir = rel !== undefined && rel !== "" && !rel.startsWith("..") && !path.isAbsolute(rel);
|
|
190
|
+
exclusions.push(underAgentDir ? `-${path.join(runtimeDir, rel)}` : entry);
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
return exclusions;
|
|
194
|
+
}
|
|
195
|
+
|
|
173
196
|
function buildSelectionSettings(
|
|
174
197
|
plan: ActivationPlan,
|
|
175
198
|
userSettings: Record<string, unknown>,
|
|
@@ -213,6 +236,11 @@ function buildSelectionSettings(
|
|
|
213
236
|
skillEntries.push(`-${skill.filePath}`);
|
|
214
237
|
}
|
|
215
238
|
}
|
|
239
|
+
// Discovery already honored the user's own `!pattern` / `-path` skill
|
|
240
|
+
// exclusions, so the skills they hide never reach the loop above and get no
|
|
241
|
+
// `-` entry. Replacing the user's array would then drop those exclusions and
|
|
242
|
+
// let the instance's skills symlink and ~/.agents/skills reveal them.
|
|
243
|
+
skillEntries.push(...userSkillExclusions(userSettings.skills, agentDir, runtimeDir));
|
|
216
244
|
settings.skills = skillEntries;
|
|
217
245
|
|
|
218
246
|
// --- extensions ---
|