skild 0.11.0 → 0.11.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/dist/index.js +91 -36
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -2140,25 +2140,24 @@ function formatTargetSummary(platforms, scopes) {
|
|
|
2140
2140
|
const scopeLabel = scopes.length === ALL_SCOPES.length ? "all scopes" : scopes.length === 1 ? scopes[0] : `${scopes.length} scopes`;
|
|
2141
2141
|
return `${platformLabel}, ${scopeLabel}`;
|
|
2142
2142
|
}
|
|
2143
|
-
function
|
|
2143
|
+
function resolveScopeConstraint(options) {
|
|
2144
2144
|
const wantsLocal = Boolean(options.local);
|
|
2145
2145
|
const wantsGlobal = Boolean(options.global);
|
|
2146
|
-
if (wantsLocal && wantsGlobal) return
|
|
2147
|
-
if (wantsLocal) return
|
|
2148
|
-
if (wantsGlobal) return
|
|
2149
|
-
|
|
2150
|
-
|
|
2151
|
-
|
|
2152
|
-
|
|
2153
|
-
if (
|
|
2154
|
-
|
|
2155
|
-
|
|
2156
|
-
|
|
2157
|
-
function listInstalledPlatforms(scopes) {
|
|
2146
|
+
if (wantsLocal && wantsGlobal) return [...ALL_SCOPES];
|
|
2147
|
+
if (wantsLocal) return ["project"];
|
|
2148
|
+
if (wantsGlobal) return ["global"];
|
|
2149
|
+
return [...ALL_SCOPES];
|
|
2150
|
+
}
|
|
2151
|
+
function hasInstalledSkill(platform, scope, skillName) {
|
|
2152
|
+
const skills = listSkills3({ platform, scope });
|
|
2153
|
+
if (!skillName) return skills.length > 0;
|
|
2154
|
+
return skills.some((s) => s.name === skillName);
|
|
2155
|
+
}
|
|
2156
|
+
function listInstalledPlatforms(scopes, skillName) {
|
|
2158
2157
|
const installed = [];
|
|
2159
2158
|
for (const platform of PLATFORMS4) {
|
|
2160
2159
|
for (const scope of scopes) {
|
|
2161
|
-
if (
|
|
2160
|
+
if (hasInstalledSkill(platform, scope, skillName)) {
|
|
2162
2161
|
installed.push(platform);
|
|
2163
2162
|
break;
|
|
2164
2163
|
}
|
|
@@ -2166,11 +2165,53 @@ function listInstalledPlatforms(scopes) {
|
|
|
2166
2165
|
}
|
|
2167
2166
|
return installed;
|
|
2168
2167
|
}
|
|
2169
|
-
|
|
2170
|
-
const
|
|
2171
|
-
|
|
2172
|
-
|
|
2173
|
-
|
|
2168
|
+
function listAvailableScopes(platforms, skillName) {
|
|
2169
|
+
const scopes = [];
|
|
2170
|
+
for (const scope of ALL_SCOPES) {
|
|
2171
|
+
const hasAny = platforms.some((platform) => hasInstalledSkill(platform, scope, skillName));
|
|
2172
|
+
if (hasAny) scopes.push(scope);
|
|
2173
|
+
}
|
|
2174
|
+
return scopes;
|
|
2175
|
+
}
|
|
2176
|
+
async function resolveTargetSelection(options, interactive, skillName) {
|
|
2177
|
+
const scopeConstraint = resolveScopeConstraint(options);
|
|
2178
|
+
const wantsScopePrompt = !options.local && !options.global;
|
|
2179
|
+
let platforms = [];
|
|
2180
|
+
if (options.target) {
|
|
2181
|
+
platforms = [options.target];
|
|
2182
|
+
} else {
|
|
2183
|
+
const installedPlatforms = listInstalledPlatforms(scopeConstraint, skillName);
|
|
2184
|
+
if (installedPlatforms.length === 0) {
|
|
2185
|
+
console.log(chalk7.red("No installed platforms found."));
|
|
2186
|
+
process.exitCode = 1;
|
|
2187
|
+
return null;
|
|
2188
|
+
}
|
|
2189
|
+
if (interactive) {
|
|
2190
|
+
const selectedPlatforms = await promptPlatformsInteractive({
|
|
2191
|
+
defaultAll: true,
|
|
2192
|
+
platforms: installedPlatforms,
|
|
2193
|
+
installedPlatforms
|
|
2194
|
+
});
|
|
2195
|
+
if (!selectedPlatforms) {
|
|
2196
|
+
console.log(chalk7.red("No platforms selected."));
|
|
2197
|
+
process.exitCode = 1;
|
|
2198
|
+
return null;
|
|
2199
|
+
}
|
|
2200
|
+
platforms = selectedPlatforms;
|
|
2201
|
+
flushInteractiveUiNow();
|
|
2202
|
+
} else {
|
|
2203
|
+
platforms = installedPlatforms;
|
|
2204
|
+
}
|
|
2205
|
+
}
|
|
2206
|
+
let scopes = scopeConstraint;
|
|
2207
|
+
const availableScopes = listAvailableScopes(platforms, skillName);
|
|
2208
|
+
if (availableScopes.length === 0) {
|
|
2209
|
+
console.log(chalk7.red("No installed scopes found for selected platforms."));
|
|
2210
|
+
process.exitCode = 1;
|
|
2211
|
+
return null;
|
|
2212
|
+
}
|
|
2213
|
+
if (wantsScopePrompt && interactive) {
|
|
2214
|
+
const selectedScopes = await promptScopesInteractive({ defaultAll: true, scopes: availableScopes });
|
|
2174
2215
|
if (!selectedScopes) {
|
|
2175
2216
|
console.log(chalk7.red("No scopes selected."));
|
|
2176
2217
|
process.exitCode = 1;
|
|
@@ -2178,23 +2219,19 @@ async function resolveTargetSelection(options, interactive) {
|
|
|
2178
2219
|
}
|
|
2179
2220
|
scopes = selectedScopes;
|
|
2180
2221
|
flushInteractiveUiNow();
|
|
2181
|
-
}
|
|
2182
|
-
|
|
2183
|
-
|
|
2184
|
-
|
|
2185
|
-
|
|
2186
|
-
|
|
2187
|
-
defaultAll: true,
|
|
2188
|
-
platforms: [...PLATFORMS4],
|
|
2189
|
-
installedPlatforms
|
|
2190
|
-
});
|
|
2191
|
-
if (!selectedPlatforms) {
|
|
2192
|
-
console.log(chalk7.red("No platforms selected."));
|
|
2222
|
+
} else if (wantsScopePrompt && !interactive) {
|
|
2223
|
+
scopes = availableScopes;
|
|
2224
|
+
} else {
|
|
2225
|
+
const filtered = scopes.filter((scope) => availableScopes.includes(scope));
|
|
2226
|
+
if (filtered.length === 0) {
|
|
2227
|
+
console.log(chalk7.red("Selected scopes have no installed skills."));
|
|
2193
2228
|
process.exitCode = 1;
|
|
2194
2229
|
return null;
|
|
2195
2230
|
}
|
|
2196
|
-
|
|
2197
|
-
|
|
2231
|
+
scopes = filtered;
|
|
2232
|
+
if (!options.json && filtered.length < scopeConstraint.length) {
|
|
2233
|
+
console.log(chalk7.yellow("Note: some scopes were skipped because no installed skills were found."));
|
|
2234
|
+
}
|
|
2198
2235
|
}
|
|
2199
2236
|
return { platforms, scopes };
|
|
2200
2237
|
}
|
|
@@ -2204,14 +2241,19 @@ async function uninstall(skill, options = {}) {
|
|
|
2204
2241
|
const canonical = skill.trim();
|
|
2205
2242
|
const resolvedName = canonical.startsWith("@") && canonical.includes("/") ? canonicalNameToInstallDirName2(canonical) : canonical;
|
|
2206
2243
|
const interactive = Boolean(process.stdin.isTTY && process.stdout.isTTY);
|
|
2207
|
-
const selection = await resolveTargetSelection(options, interactive);
|
|
2244
|
+
const selection = await resolveTargetSelection(options, interactive, resolvedName);
|
|
2208
2245
|
if (!selection) return;
|
|
2209
2246
|
const { platforms, scopes } = selection;
|
|
2210
2247
|
const spinner = createSpinner(`Uninstalling ${chalk8.cyan(canonical)}...`);
|
|
2211
2248
|
const errors = [];
|
|
2249
|
+
const skipped = [];
|
|
2212
2250
|
try {
|
|
2213
2251
|
for (const scope of scopes) {
|
|
2214
2252
|
for (const platform of platforms) {
|
|
2253
|
+
if (!hasInstalledSkill(platform, scope, resolvedName)) {
|
|
2254
|
+
skipped.push({ platform, scope });
|
|
2255
|
+
continue;
|
|
2256
|
+
}
|
|
2215
2257
|
spinner.text = `Uninstalling ${chalk8.cyan(canonical)} from ${chalk8.dim(platform)} (${scope})...`;
|
|
2216
2258
|
try {
|
|
2217
2259
|
uninstallSkill(resolvedName, {
|
|
@@ -2229,6 +2271,10 @@ async function uninstall(skill, options = {}) {
|
|
|
2229
2271
|
const targetSummary = formatTargetSummary(platforms, scopes);
|
|
2230
2272
|
if (errors.length === 0) {
|
|
2231
2273
|
spinner.succeed(`Uninstalled ${chalk8.green(canonical)} \u2192 ${chalk8.dim(targetSummary)}.`);
|
|
2274
|
+
if (skipped.length > 0) {
|
|
2275
|
+
console.log(chalk8.dim(`
|
|
2276
|
+
Skipped ${skipped.length} target(s) with no installed skill.`));
|
|
2277
|
+
}
|
|
2232
2278
|
return;
|
|
2233
2279
|
}
|
|
2234
2280
|
spinner.fail(`Uninstalled ${chalk8.green(canonical)} with ${chalk8.red(errors.length.toString())} error(s) \u2192 ${chalk8.dim(targetSummary)}.`);
|
|
@@ -2259,15 +2305,20 @@ async function update(skill, options = {}) {
|
|
|
2259
2305
|
const label = skill ? skill : "all skills";
|
|
2260
2306
|
const resolvedName = skill && skill.trim().startsWith("@") && skill.includes("/") ? canonicalNameToInstallDirName3(skill.trim()) : skill;
|
|
2261
2307
|
const interactive = Boolean(process.stdin.isTTY && process.stdout.isTTY) && !options.json;
|
|
2262
|
-
const selection = await resolveTargetSelection(options, interactive);
|
|
2308
|
+
const selection = await resolveTargetSelection(options, interactive, resolvedName || void 0);
|
|
2263
2309
|
if (!selection) return;
|
|
2264
2310
|
const { platforms, scopes } = selection;
|
|
2265
2311
|
const spinner = createSpinner(`Updating ${chalk9.cyan(label)}...`);
|
|
2266
2312
|
const results = [];
|
|
2267
2313
|
const errors = [];
|
|
2314
|
+
const skipped = [];
|
|
2268
2315
|
try {
|
|
2269
2316
|
for (const scope of scopes) {
|
|
2270
2317
|
for (const platform of platforms) {
|
|
2318
|
+
if (resolvedName && !hasInstalledSkill(platform, scope, resolvedName)) {
|
|
2319
|
+
skipped.push({ platform, scope });
|
|
2320
|
+
continue;
|
|
2321
|
+
}
|
|
2271
2322
|
spinner.text = `Updating ${chalk9.cyan(label)} on ${chalk9.dim(platform)} (${scope})...`;
|
|
2272
2323
|
try {
|
|
2273
2324
|
const updated = await updateSkill(resolvedName, { platform, scope });
|
|
@@ -2282,7 +2333,7 @@ async function update(skill, options = {}) {
|
|
|
2282
2333
|
if (errors.length === 0 && platforms.length === 1 && scopes.length === 1) {
|
|
2283
2334
|
console.log(JSON.stringify(results, null, 2));
|
|
2284
2335
|
} else {
|
|
2285
|
-
console.log(JSON.stringify({ ok: errors.length === 0, platforms, scopes, results, errors }, null, 2));
|
|
2336
|
+
console.log(JSON.stringify({ ok: errors.length === 0, platforms, scopes, results, errors, skipped }, null, 2));
|
|
2286
2337
|
}
|
|
2287
2338
|
process.exitCode = errors.length ? 1 : 0;
|
|
2288
2339
|
return;
|
|
@@ -2290,6 +2341,10 @@ async function update(skill, options = {}) {
|
|
|
2290
2341
|
const targetSummary = formatTargetSummary(platforms, scopes);
|
|
2291
2342
|
if (errors.length === 0) {
|
|
2292
2343
|
spinner.succeed(`Updated ${chalk9.green(results.length.toString())} skill(s) \u2192 ${chalk9.dim(targetSummary)}.`);
|
|
2344
|
+
if (skipped.length > 0) {
|
|
2345
|
+
console.log(chalk9.dim(`
|
|
2346
|
+
Skipped ${skipped.length} target(s) with no installed skill.`));
|
|
2347
|
+
}
|
|
2293
2348
|
return;
|
|
2294
2349
|
}
|
|
2295
2350
|
spinner.fail(`Updated ${chalk9.green(results.length.toString())} skill(s) with ${chalk9.red(errors.length.toString())} error(s) \u2192 ${chalk9.dim(targetSummary)}.`);
|