@zew1me/pi-skills-patch 0.0.0-stage → 0.1.1-alpha.162
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 +11 -2
- package/dist/ATTRIBUTION.md +330 -0
- package/dist/LICENSE +21 -0
- package/dist/patches/pi-1.0.3/baseline.absent +2 -0
- package/dist/patches/pi-1.0.3/baseline.sha256 +8 -0
- package/dist/patches/pi-1.0.3/patched.sha256 +10 -0
- package/dist/patches/pi-1.0.3/pre-expansion-patched.sha256 +10 -0
- package/dist/patches/pi-1.0.3/pre-expansion-upgrade.patch +339 -0
- package/dist/patches/pi-1.0.3/skills.patch +1132 -0
- package/dist/patches/pi-1.1.0/baseline.absent +2 -0
- package/dist/patches/pi-1.1.0/baseline.sha256 +8 -0
- package/dist/patches/pi-1.1.0/patched.sha256 +10 -0
- package/dist/patches/pi-1.1.0/pre-expansion-patched.sha256 +10 -0
- package/dist/patches/pi-1.1.0/pre-expansion-upgrade.patch +339 -0
- package/dist/patches/pi-1.1.0/skills.patch +1138 -0
- package/dist/patches/pi-1.3.0/baseline.absent +2 -0
- package/dist/patches/pi-1.3.0/baseline.sha256 +8 -0
- package/dist/patches/pi-1.3.0/patched.sha256 +10 -0
- package/dist/patches/pi-1.3.0/pre-expansion-patched.sha256 +10 -0
- package/dist/patches/pi-1.3.0/pre-expansion-upgrade.patch +339 -0
- package/dist/patches/pi-1.3.0/skills.patch +1138 -0
- package/dist/patches/pi-1.4.0/baseline.absent +2 -0
- package/dist/patches/pi-1.4.0/baseline.sha256 +8 -0
- package/dist/patches/pi-1.4.0/patched.sha256 +10 -0
- package/dist/patches/pi-1.4.0/skills.patch +1138 -0
- package/dist/patches/pi-1.5.2/baseline.absent +2 -0
- package/dist/patches/pi-1.5.2/baseline.sha256 +8 -0
- package/dist/patches/pi-1.5.2/patched.sha256 +10 -0
- package/dist/patches/pi-1.5.2/skills.patch +1138 -0
- package/dist/patches/pi-1.6.0/baseline.absent +2 -0
- package/dist/patches/pi-1.6.0/baseline.sha256 +8 -0
- package/dist/patches/pi-1.6.0/patched.sha256 +10 -0
- package/dist/patches/pi-1.6.0/skills.patch +1138 -0
- package/dist/scripts/install-extensions.sh +454 -0
- package/package.json +31 -4
|
@@ -0,0 +1,339 @@
|
|
|
1
|
+
diff --git a/dist/core/skill-management-core.js b/dist/core/skill-management-core.js
|
|
2
|
+
index 2fd4257..0b4ae56 100644
|
|
3
|
+
--- a/dist/core/skill-management-core.js
|
|
4
|
+
+++ b/dist/core/skill-management-core.js
|
|
5
|
+
@@ -160,7 +160,118 @@ export function configLocation(env, scope, cwd, agentDir) {
|
|
6
|
+
return {};
|
|
7
|
+
}
|
|
8
|
+
export function looksLikePath(value) {
|
|
9
|
+
- return value.includes("/") || value.includes("\\") || value.startsWith(".") || value.startsWith("~");
|
|
10
|
+
+ return (value.includes("/") ||
|
|
11
|
+
+ value.includes("\\") ||
|
|
12
|
+
+ value.startsWith(".") ||
|
|
13
|
+
+ value.startsWith("~") ||
|
|
14
|
+
+ value.startsWith("$"));
|
|
15
|
+
+}
|
|
16
|
+
+const environmentVariableReference = /\$(?:\{([A-Za-z_]\w*)\}|([A-Za-z_]\w*))/g;
|
|
17
|
+
+/**
|
|
18
|
+
+ * Expands `$NAME` and `${NAME}` references in a skill path.
|
|
19
|
+
+ *
|
|
20
|
+
+ * `/skills` arguments never pass through a shell, so without this a path such as `$HOME/skills/x` would be
|
|
21
|
+
+ * resolved against the working directory. An unset variable is left as written rather than removed: a path
|
|
22
|
+
+ * that genuinely contains `$` still resolves, and callers can name the variable when the path does not exist.
|
|
23
|
+
+ */
|
|
24
|
+
+export function expandEnvironmentVariables(env, input) {
|
|
25
|
+
+ const unset = [];
|
|
26
|
+
+ const value = input.replace(environmentVariableReference, (reference, braced, bare) => {
|
|
27
|
+
+ const name = braced ?? bare ?? "";
|
|
28
|
+
+ const expanded = env.environmentVariable(name);
|
|
29
|
+
+ if (expanded !== undefined)
|
|
30
|
+
+ return expanded;
|
|
31
|
+
+ if (!unset.includes(name))
|
|
32
|
+
+ unset.push(name);
|
|
33
|
+
+ return reference;
|
|
34
|
+
+ });
|
|
35
|
+
+ return { value, unset };
|
|
36
|
+
+}
|
|
37
|
+
+/** Resolves a path-like skill source to the absolute path it names, expanding variables and `~`. */
|
|
38
|
+
+function resolveSkillPath(env, source, cwd) {
|
|
39
|
+
+ return env.resolvePath(expandEnvironmentVariables(env, source).value, cwd, { trim: true });
|
|
40
|
+
+}
|
|
41
|
+
+/** True for a path that does not depend on the directory it is read from: absolute, `~`, or a `file:` URL. */
|
|
42
|
+
+function isAnchoredPath(env, value) {
|
|
43
|
+
+ return env.path.isAbsolute(value) || value === "~" || value.startsWith("~/") || value.startsWith("file:");
|
|
44
|
+
+}
|
|
45
|
+
+/** The checkout root for `cwd`; relative repository entries resolve against it. */
|
|
46
|
+
+function findRepoRoot(env, cwd) {
|
|
47
|
+
+ return git(env, cwd, ["rev-parse", "--show-toplevel"]);
|
|
48
|
+
+}
|
|
49
|
+
+/** `path` relative to `root` with `/` separators, comparing real paths, or undefined when it lies outside. */
|
|
50
|
+
+function pathInside(env, root, path) {
|
|
51
|
+
+ const real = (value) => (env.fs.existsSync(value) ? env.fs.realpathSync(value) : value);
|
|
52
|
+
+ const relative = env.path.relative(real(root), real(path));
|
|
53
|
+
+ if (relative === ".." || relative.startsWith(`..${env.path.sep}`) || env.path.isAbsolute(relative))
|
|
54
|
+
+ return undefined;
|
|
55
|
+
+ return relative.split(env.path.sep).join("/");
|
|
56
|
+
+}
|
|
57
|
+
+/**
|
|
58
|
+
+ * Chooses how an added path is written to configuration.
|
|
59
|
+
+ *
|
|
60
|
+
+ * Repository entries are shared by every checkout with the same remote, so a path inside the current checkout
|
|
61
|
+
+ * is stored relative to its root. Otherwise a `~` or `$NAME` spelling that resolves now is kept as typed, so it
|
|
62
|
+
+ * is expanded each time skills load rather than frozen at add time, and any other path is stored absolute,
|
|
63
|
+
+ * under `~` when it is in the home directory.
|
|
64
|
+
+ */
|
|
65
|
+
+function persistedForm(env, source, resolvedPath, context) {
|
|
66
|
+
+ const repoRelative = context.scope === "repo" && context.repoRoot !== undefined
|
|
67
|
+
+ ? pathInside(env, context.repoRoot, resolvedPath)
|
|
68
|
+
+ : undefined;
|
|
69
|
+
+ if (repoRelative !== undefined) {
|
|
70
|
+
+ return repoRelative === "" ? "." : looksLikePath(repoRelative) ? repoRelative : `./${repoRelative}`;
|
|
71
|
+
+ }
|
|
72
|
+
+ const typed = source.trim();
|
|
73
|
+
+ if (isPortableSpelling(env, typed))
|
|
74
|
+
+ return typed;
|
|
75
|
+
+ const home = pathInside(env, env.homedir(), resolvedPath);
|
|
76
|
+
+ return home === undefined ? resolvedPath : home === "" ? "~" : `~/${home}`;
|
|
77
|
+
+}
|
|
78
|
+
+/** Variables naming a working directory: a path spelled with them means the directory it named at add time. */
|
|
79
|
+
+const directoryVariables = new Set(["PWD", "OLDPWD"]);
|
|
80
|
+
+function referencesDirectoryVariable(typed) {
|
|
81
|
+
+ return [...typed.matchAll(environmentVariableReference)].some((match) => directoryVariables.has(match[1] ?? match[2] ?? ""));
|
|
82
|
+
+}
|
|
83
|
+
+/** True for a `~` or `$NAME` path that resolves the same way from any directory in the current environment. */
|
|
84
|
+
+function isPortableSpelling(env, typed) {
|
|
85
|
+
+ const spelled = typed === "~" || typed.startsWith("~/") || typed.search(environmentVariableReference) !== -1;
|
|
86
|
+
+ if (!spelled || !looksLikePath(typed) || referencesDirectoryVariable(typed))
|
|
87
|
+
+ return false;
|
|
88
|
+
+ const { value, unset } = expandEnvironmentVariables(env, typed);
|
|
89
|
+
+ return unset.length === 0 && isAnchoredPath(env, value.trim());
|
|
90
|
+
+}
|
|
91
|
+
+function unsetVariableHint(env, source) {
|
|
92
|
+
+ const { unset } = expandEnvironmentVariables(env, source);
|
|
93
|
+
+ if (unset.length === 0)
|
|
94
|
+
+ return undefined;
|
|
95
|
+
+ const names = unset.map((name) => `$${name}`).join(", ");
|
|
96
|
+
+ return `environment variable ${names} ${unset.length === 1 ? "is" : "are"} not set`;
|
|
97
|
+
+}
|
|
98
|
+
+function skillNotFoundMessage(env, source) {
|
|
99
|
+
+ const hint = looksLikePath(source) ? unsetVariableHint(env, source) : undefined;
|
|
100
|
+
+ return `Skill not found in the catalog or at an existing path: ${source}${hint ? ` (${hint})` : ""}`;
|
|
101
|
+
+}
|
|
102
|
+
+/** Explains why a persisted path entry could not be found, beyond its simply not existing. */
|
|
103
|
+
+function unresolvedEntryHint(env, source, scope) {
|
|
104
|
+
+ if (!looksLikePath(source))
|
|
105
|
+
+ return undefined;
|
|
106
|
+
+ const unset = unsetVariableHint(env, source);
|
|
107
|
+
+ if (unset !== undefined)
|
|
108
|
+
+ return unset;
|
|
109
|
+
+ if (isAnchoredPath(env, expandEnvironmentVariables(env, source).value.trim()))
|
|
110
|
+
+ return undefined;
|
|
111
|
+
+ return scope === "repo"
|
|
112
|
+
+ ? "relative repository paths resolve against the root of the current checkout"
|
|
113
|
+
+ : "relative paths resolve against the working directory; remove it, then add it again to store its absolute path";
|
|
114
|
+
+}
|
|
115
|
+
+function unresolvedSkillDiagnostic(env, entry) {
|
|
116
|
+
+ const hint = unresolvedEntryHint(env, entry.source, entry.scope);
|
|
117
|
+
+ return {
|
|
118
|
+
+ type: "warning",
|
|
119
|
+
+ message: `Active skill could not be resolved${hint ? `: ${hint}` : ""}`,
|
|
120
|
+
+ path: entry.source,
|
|
121
|
+
+ };
|
|
122
|
+
}
|
|
123
|
+
/** True when `path` exists and Pi's own loader finds at least one skill in it. */
|
|
124
|
+
function containsSkills(env, path, options) {
|
|
125
|
+
@@ -175,36 +286,46 @@ function containsSkills(env, path, options) {
|
|
126
|
+
return skills.length > 0;
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
- * Normalizes an entry already persisted in a configuration file.
|
|
130
|
+
+ * Normalizes an entry already persisted in a configuration file, for comparison.
|
|
131
|
+
*
|
|
132
|
+
* User input is normalized before it is stored, so a stored bare value is a catalog name and is compared
|
|
133
|
+
* literally. Resolving it against whatever happens to exist in the current directory would let an unrelated
|
|
134
|
+
- * local folder make a catalog-name entry match, or block, a path entry.
|
|
135
|
+
+ * local folder make a catalog-name entry match, or block, a path entry. A path entry compares by the real path
|
|
136
|
+
+ * it names, so `~/x`, `$HOME/x`, and a repository-relative `x` all match the same absolute path.
|
|
137
|
+
*/
|
|
138
|
+
-function normalizePersistedSource(env, source, options) {
|
|
139
|
+
+function normalizePersistedSource(env, source, context) {
|
|
140
|
+
if (!source)
|
|
141
|
+
return undefined;
|
|
142
|
+
- return looksLikePath(source) ? env.resolvePath(source, options.cwd, { trim: true }) : source;
|
|
143
|
+
+ if (!looksLikePath(source))
|
|
144
|
+
+ return source;
|
|
145
|
+
+ const value = expandEnvironmentVariables(env, source).value.trim();
|
|
146
|
+
+ const path = context.scope === "repo" && context.repoRoot !== undefined && !isAnchoredPath(env, value)
|
|
147
|
+
+ ? env.path.resolve(context.repoRoot, value)
|
|
148
|
+
+ : env.resolvePath(value, context.cwd, { trim: true });
|
|
149
|
+
+ return env.fs.existsSync(path) ? env.fs.realpathSync(path) : path;
|
|
150
|
+
}
|
|
151
|
+
export function updatePersistedSkill(env, action, source, scope, options) {
|
|
152
|
+
const location = configLocation(env, scope, options.cwd, options.agentDir);
|
|
153
|
+
const path = location.path;
|
|
154
|
+
if (path === undefined)
|
|
155
|
+
throw new Error(`Scope ${scope} has no persisted configuration.`);
|
|
156
|
+
+ const context = {
|
|
157
|
+
+ cwd: options.cwd,
|
|
158
|
+
+ scope,
|
|
159
|
+
+ repoRoot: scope === "repo" ? findRepoRoot(env, options.cwd) : undefined,
|
|
160
|
+
+ };
|
|
161
|
+
+ const key = normalizePersistedSource(env, source, context);
|
|
162
|
+
+ const matches = (entry) => normalizePersistedSource(env, sourceOf(entry), context) === key;
|
|
163
|
+
return withSkillConfigLock(env, path, () => {
|
|
164
|
+
const config = readJson(env, path);
|
|
165
|
+
const existing = location.key === undefined ? config : config[location.key];
|
|
166
|
+
const target = location.key === undefined ? config : isObjectRecord(existing) ? existing : {};
|
|
167
|
+
const enabled = enabledEntries(target);
|
|
168
|
+
- const matched = enabled.some((entry) => normalizePersistedSource(env, sourceOf(entry), options) === source);
|
|
169
|
+
+ const matched = enabled.some(matches);
|
|
170
|
+
if (action === "remove" && !matched)
|
|
171
|
+
return false;
|
|
172
|
+
target.enabled =
|
|
173
|
+
- action === "add"
|
|
174
|
+
- ? matched
|
|
175
|
+
- ? enabled
|
|
176
|
+
- : [...enabled, source]
|
|
177
|
+
- : enabled.filter((entry) => normalizePersistedSource(env, sourceOf(entry), options) !== source);
|
|
178
|
+
+ action === "add" ? (matched ? enabled : [...enabled, source]) : enabled.filter((entry) => !matches(entry));
|
|
179
|
+
if (location.key !== undefined)
|
|
180
|
+
config[location.key] = target;
|
|
181
|
+
writeJson(env, path, config);
|
|
182
|
+
@@ -307,10 +428,11 @@ export async function getSkillCatalog(env, { cwd, agentDir, settingsManager, res
|
|
183
|
+
return [...found.values()].sort((a, b) => a.name.localeCompare(b.name));
|
|
184
|
+
}
|
|
185
|
+
async function resolveSkillSource(env, source, options) {
|
|
186
|
+
- const resolvedPath = env.resolvePath(source, options.cwd, { trim: true });
|
|
187
|
+
if (looksLikePath(source)) {
|
|
188
|
+
+ const resolvedPath = resolveSkillPath(env, source, options.cwd);
|
|
189
|
+
return { normalized: resolvedPath, resolved: env.fs.existsSync(resolvedPath) ? resolvedPath : undefined };
|
|
190
|
+
}
|
|
191
|
+
+ const resolvedPath = env.resolvePath(source, options.cwd, { trim: true });
|
|
192
|
+
// Build the catalog once, then use it both to prefer catalog names over same-named local folders and to
|
|
193
|
+
// resolve the selected skill. A bare local folder is retained as a path only when no catalog entry wins.
|
|
194
|
+
const catalog = await getSkillCatalog(env, options);
|
|
195
|
+
@@ -360,6 +482,16 @@ async function runCatalogCommand(env, command, rest, surface, options) {
|
|
196
|
+
: [query ? "No matching skills." : "No catalog skills found."],
|
|
197
|
+
};
|
|
198
|
+
}
|
|
199
|
+
+/** What `add` writes for a resolved source: a catalog name as is, a path in its {@link persistedForm}. */
|
|
200
|
+
+function persistedAddForm(env, source, target, scope, cwd) {
|
|
201
|
+
+ if (!looksLikePath(source) && target === source)
|
|
202
|
+
+ return source;
|
|
203
|
+
+ return persistedForm(env, source, target, {
|
|
204
|
+
+ cwd,
|
|
205
|
+
+ scope,
|
|
206
|
+
+ repoRoot: scope === "repo" ? findRepoRoot(env, cwd) : undefined,
|
|
207
|
+
+ });
|
|
208
|
+
+}
|
|
209
|
+
async function runMutationCommand(env, command, rest, surface, options) {
|
|
210
|
+
const scopeList = `--global|--repo${options.allowSession ? "|--session" : ""}`;
|
|
211
|
+
const source = rest.find((arg) => !arg.startsWith("--"));
|
|
212
|
+
@@ -374,18 +506,18 @@ async function runMutationCommand(env, command, rest, surface, options) {
|
|
213
|
+
const resolution = command === "add" ? await resolveSkillSource(env, source, options) : undefined;
|
|
214
|
+
const target = command === "remove"
|
|
215
|
+
? looksLikePath(source)
|
|
216
|
+
- ? env.resolvePath(source, options.cwd, { trim: true })
|
|
217
|
+
+ ? resolveSkillPath(env, source, options.cwd)
|
|
218
|
+
: source
|
|
219
|
+
: resolution?.normalized;
|
|
220
|
+
if (!target)
|
|
221
|
+
throw new Error(`Skill source is invalid: ${source}`);
|
|
222
|
+
if (command === "add" && !resolution?.resolved) {
|
|
223
|
+
- throw new Error(`Skill not found in the catalog or at an existing path: ${source}`);
|
|
224
|
+
+ throw new Error(skillNotFoundMessage(env, source));
|
|
225
|
+
}
|
|
226
|
+
if (scope === "session")
|
|
227
|
+
return { exitCode: 0, lines: [], session: { action: command, source: target } };
|
|
228
|
+
const updated = command === "add"
|
|
229
|
+
- ? updatePersistedSkill(env, command, target, scope, options)
|
|
230
|
+
+ ? updatePersistedSkill(env, command, persistedAddForm(env, source, target, scope, options.cwd), scope, options)
|
|
231
|
+
: removePersistedSkill(env, source, target, scope, options);
|
|
232
|
+
if (!updated)
|
|
233
|
+
throw new Error(`Skill is not enabled for ${scope} scope: ${source}`);
|
|
234
|
+
@@ -412,9 +544,13 @@ export async function runSkillsCommand(env, args, options) {
|
|
235
|
+
/**
|
|
236
|
+
* Resolves the skills that are explicitly active for this session into concrete paths.
|
|
237
|
+
*
|
|
238
|
+
- * Entries are either paths, which must exist, or catalog names, which are looked up by name. The catalog is
|
|
239
|
+
- * built at most once per call: every caller resolves a whole entry list in one pass, so a longer-lived cache
|
|
240
|
+
- * would only need invalidating without ever being reused.
|
|
241
|
+
+ * Entries are either paths, which must exist, or catalog names, which are looked up by name. Path entries
|
|
242
|
+
+ * are expanded here, each time skills load, rather than when they are added: `~` and `$NAME` take the current
|
|
243
|
+
+ * environment, and a relative repository entry resolves against the root of the current checkout. The loader
|
|
244
|
+
+ * keeps the result until its next reload (`/reload`, `/skills reload`, or the reload `/skills add` and
|
|
245
|
+
+ * `/skills remove` trigger), which is what makes this a once-per-session expansion. The catalog is built at
|
|
246
|
+
+ * most once per call: every caller resolves a whole entry list in one pass, so a longer-lived cache would only
|
|
247
|
+
+ * need invalidating without ever being reused.
|
|
248
|
+
*/
|
|
249
|
+
export async function resolveActiveSkillPaths(env, context) {
|
|
250
|
+
const { cwd, agentDir, settingsManager, resolvedSkillResources, resolveResourcePath } = context;
|
|
251
|
+
@@ -435,22 +571,30 @@ export async function resolveActiveSkillPaths(env, context) {
|
|
252
|
+
})).map((skill) => [skill.name, skill.filePath]));
|
|
253
|
+
return catalogPathsByName.get(name);
|
|
254
|
+
};
|
|
255
|
+
+ let repoRoot;
|
|
256
|
+
+ const entryPath = (entry) => {
|
|
257
|
+
+ const value = expandEnvironmentVariables(env, entry.source).value.trim();
|
|
258
|
+
+ if (entry.scope === "repo" && !isAnchoredPath(env, value)) {
|
|
259
|
+
+ repoRoot ??= { value: findRepoRoot(env, cwd) };
|
|
260
|
+
+ if (repoRoot.value !== undefined)
|
|
261
|
+
+ return env.path.resolve(repoRoot.value, value);
|
|
262
|
+
+ }
|
|
263
|
+
+ return resolveResourcePath(value);
|
|
264
|
+
+ };
|
|
265
|
+
for (const entry of entries) {
|
|
266
|
+
- const source = sourceOf(entry);
|
|
267
|
+
- if (!source)
|
|
268
|
+
+ if (!looksLikePath(entry.source)) {
|
|
269
|
+
+ const resolved = await findCatalogSkillPath(entry.source);
|
|
270
|
+
+ if (resolved)
|
|
271
|
+
+ paths.push(resolved);
|
|
272
|
+
+ else
|
|
273
|
+
+ diagnostics.push(unresolvedSkillDiagnostic(env, entry));
|
|
274
|
+
continue;
|
|
275
|
+
- const normalized = looksLikePath(source) ? resolveResourcePath(source) : source;
|
|
276
|
+
- const resolved = looksLikePath(source)
|
|
277
|
+
- ? env.fs.existsSync(normalized)
|
|
278
|
+
- ? normalized
|
|
279
|
+
- : undefined
|
|
280
|
+
- : await findCatalogSkillPath(normalized);
|
|
281
|
+
- if (resolved) {
|
|
282
|
+
- paths.push(resolved);
|
|
283
|
+
- }
|
|
284
|
+
- else {
|
|
285
|
+
- diagnostics.push({ type: "warning", message: "Active skill could not be resolved", path: source });
|
|
286
|
+
}
|
|
287
|
+
+ const path = entryPath(entry);
|
|
288
|
+
+ if (env.fs.existsSync(path))
|
|
289
|
+
+ paths.push(path);
|
|
290
|
+
+ else
|
|
291
|
+
+ diagnostics.push(unresolvedSkillDiagnostic(env, entry));
|
|
292
|
+
}
|
|
293
|
+
return { paths, diagnostics };
|
|
294
|
+
}
|
|
295
|
+
@@ -464,7 +608,7 @@ export async function resolveActiveSkillPaths(env, context) {
|
|
296
|
+
export async function resolveSkillEntryPath(env, context, source) {
|
|
297
|
+
const { cwd, agentDir, settingsManager, resolvedSkillResources, resolveResourcePath } = context;
|
|
298
|
+
if (looksLikePath(source)) {
|
|
299
|
+
- const normalized = resolveResourcePath(source);
|
|
300
|
+
+ const normalized = resolveResourcePath(expandEnvironmentVariables(env, source).value);
|
|
301
|
+
return { normalized, resolved: env.fs.existsSync(normalized) ? normalized : undefined };
|
|
302
|
+
}
|
|
303
|
+
const catalog = await getSkillCatalog(env, {
|
|
304
|
+
@@ -500,7 +644,9 @@ async function applySessionSkillChange(env, session, context) {
|
|
305
|
+
}
|
|
306
|
+
// Removal must not resolve packages. Recover bare names from the already-enabled paths, and compare explicit
|
|
307
|
+
// paths after applying the same resolution used by the resource loader.
|
|
308
|
+
- const normalized = looksLikePath(session.source) ? resolveResourcePath(session.source) : session.source;
|
|
309
|
+
+ const normalized = looksLikePath(session.source)
|
|
310
|
+
+ ? resolveResourcePath(expandEnvironmentVariables(env, session.source).value)
|
|
311
|
+
+ : session.source;
|
|
312
|
+
const skillPaths = looksLikePath(session.source)
|
|
313
|
+
? []
|
|
314
|
+
: env
|
|
315
|
+
diff --git a/dist/core/skill-management.js b/dist/core/skill-management.js
|
|
316
|
+
index 3d18e7d..8b712ef 100644
|
|
317
|
+
--- a/dist/core/skill-management.js
|
|
318
|
+
+++ b/dist/core/skill-management.js
|
|
319
|
+
@@ -28,6 +28,7 @@ const env = {
|
|
320
|
+
fs: { existsSync, mkdirSync, readFileSync, realpathSync, renameSync, writeFileSync },
|
|
321
|
+
path: { dirname, isAbsolute, join, relative, resolve, sep },
|
|
322
|
+
homedir,
|
|
323
|
+
+ environmentVariable: (name) => process.env[name],
|
|
324
|
+
execFileSync,
|
|
325
|
+
processId: () => process.pid,
|
|
326
|
+
lockSync: (directory, options) => lockfile.lockSync(directory, options),
|
|
327
|
+
diff --git a/docs/skills.md b/docs/skills.md
|
|
328
|
+
index a6adcc6..2a17b24 100644
|
|
329
|
+
--- a/docs/skills.md
|
|
330
|
+
+++ b/docs/skills.md
|
|
331
|
+
@@ -130,6 +130,8 @@ pi skills remove browser-testing-with-devtools --repo
|
|
332
|
+
|
|
333
|
+
`--session` is interactive-only and lasts until the session ends. `--global` and `--repo` persist to their respective JSON configuration. `list` and `search` show catalog skills. `pi skills active` shows the configured global and repository entries; `/skills active` also shows session entries.
|
|
334
|
+
|
|
335
|
+
+Path arguments may use `~`, `$NAME`, or `${NAME}`; `/skills` expands them itself because its arguments never pass through a shell. With `--repo`, a path inside the current checkout is stored relative to the repository root, so the entry works in every clone and worktree with the same remote. Otherwise `add` keeps a `~` or `$NAME` spelling as typed and stores any other path as an absolute path, under `~` when it is in your home directory. Stored paths are expanded whenever Pi loads skills: at startup, after `/skills add` or `/skills remove`, and on `/reload` or `/skills reload`. Other relative entries resolve against the repository root in `repo-skills.json` and against the working directory in `skills.json`, so prefer absolute, `~`, or `$NAME` paths in `skills.json`.
|
|
336
|
+
+
|
|
337
|
+
Use `--no-skills` to suppress global and repository active skills; explicit `--skill` paths still load.
|
|
338
|
+
|
|
339
|
+
## Write portable frontmatter
|