@localskills/cli 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/dist/index.js +2399 -0
- package/package.json +31 -0
package/dist/index.js
ADDED
|
@@ -0,0 +1,2399 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __require = /* @__PURE__ */ ((x3) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x3, {
|
|
9
|
+
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
|
10
|
+
}) : x3)(function(x3) {
|
|
11
|
+
if (typeof require !== "undefined") return require.apply(this, arguments);
|
|
12
|
+
throw Error('Dynamic require of "' + x3 + '" is not supported');
|
|
13
|
+
});
|
|
14
|
+
var __commonJS = (cb, mod) => function __require2() {
|
|
15
|
+
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
16
|
+
};
|
|
17
|
+
var __copyProps = (to, from, except, desc) => {
|
|
18
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
19
|
+
for (let key of __getOwnPropNames(from))
|
|
20
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
21
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
22
|
+
}
|
|
23
|
+
return to;
|
|
24
|
+
};
|
|
25
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
26
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
27
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
28
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
29
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
30
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
31
|
+
mod
|
|
32
|
+
));
|
|
33
|
+
|
|
34
|
+
// ../../node_modules/.pnpm/picocolors@1.1.1/node_modules/picocolors/picocolors.js
|
|
35
|
+
var require_picocolors = __commonJS({
|
|
36
|
+
"../../node_modules/.pnpm/picocolors@1.1.1/node_modules/picocolors/picocolors.js"(exports, module) {
|
|
37
|
+
"use strict";
|
|
38
|
+
var p = process || {};
|
|
39
|
+
var argv = p.argv || [];
|
|
40
|
+
var env = p.env || {};
|
|
41
|
+
var isColorSupported = !(!!env.NO_COLOR || argv.includes("--no-color")) && (!!env.FORCE_COLOR || argv.includes("--color") || p.platform === "win32" || (p.stdout || {}).isTTY && env.TERM !== "dumb" || !!env.CI);
|
|
42
|
+
var formatter = (open, close, replace = open) => (input) => {
|
|
43
|
+
let string = "" + input, index = string.indexOf(close, open.length);
|
|
44
|
+
return ~index ? open + replaceClose(string, close, replace, index) + close : open + string + close;
|
|
45
|
+
};
|
|
46
|
+
var replaceClose = (string, close, replace, index) => {
|
|
47
|
+
let result = "", cursor = 0;
|
|
48
|
+
do {
|
|
49
|
+
result += string.substring(cursor, index) + replace;
|
|
50
|
+
cursor = index + close.length;
|
|
51
|
+
index = string.indexOf(close, cursor);
|
|
52
|
+
} while (~index);
|
|
53
|
+
return result + string.substring(cursor);
|
|
54
|
+
};
|
|
55
|
+
var createColors = (enabled = isColorSupported) => {
|
|
56
|
+
let f = enabled ? formatter : () => String;
|
|
57
|
+
return {
|
|
58
|
+
isColorSupported: enabled,
|
|
59
|
+
reset: f("\x1B[0m", "\x1B[0m"),
|
|
60
|
+
bold: f("\x1B[1m", "\x1B[22m", "\x1B[22m\x1B[1m"),
|
|
61
|
+
dim: f("\x1B[2m", "\x1B[22m", "\x1B[22m\x1B[2m"),
|
|
62
|
+
italic: f("\x1B[3m", "\x1B[23m"),
|
|
63
|
+
underline: f("\x1B[4m", "\x1B[24m"),
|
|
64
|
+
inverse: f("\x1B[7m", "\x1B[27m"),
|
|
65
|
+
hidden: f("\x1B[8m", "\x1B[28m"),
|
|
66
|
+
strikethrough: f("\x1B[9m", "\x1B[29m"),
|
|
67
|
+
black: f("\x1B[30m", "\x1B[39m"),
|
|
68
|
+
red: f("\x1B[31m", "\x1B[39m"),
|
|
69
|
+
green: f("\x1B[32m", "\x1B[39m"),
|
|
70
|
+
yellow: f("\x1B[33m", "\x1B[39m"),
|
|
71
|
+
blue: f("\x1B[34m", "\x1B[39m"),
|
|
72
|
+
magenta: f("\x1B[35m", "\x1B[39m"),
|
|
73
|
+
cyan: f("\x1B[36m", "\x1B[39m"),
|
|
74
|
+
white: f("\x1B[37m", "\x1B[39m"),
|
|
75
|
+
gray: f("\x1B[90m", "\x1B[39m"),
|
|
76
|
+
bgBlack: f("\x1B[40m", "\x1B[49m"),
|
|
77
|
+
bgRed: f("\x1B[41m", "\x1B[49m"),
|
|
78
|
+
bgGreen: f("\x1B[42m", "\x1B[49m"),
|
|
79
|
+
bgYellow: f("\x1B[43m", "\x1B[49m"),
|
|
80
|
+
bgBlue: f("\x1B[44m", "\x1B[49m"),
|
|
81
|
+
bgMagenta: f("\x1B[45m", "\x1B[49m"),
|
|
82
|
+
bgCyan: f("\x1B[46m", "\x1B[49m"),
|
|
83
|
+
bgWhite: f("\x1B[47m", "\x1B[49m"),
|
|
84
|
+
blackBright: f("\x1B[90m", "\x1B[39m"),
|
|
85
|
+
redBright: f("\x1B[91m", "\x1B[39m"),
|
|
86
|
+
greenBright: f("\x1B[92m", "\x1B[39m"),
|
|
87
|
+
yellowBright: f("\x1B[93m", "\x1B[39m"),
|
|
88
|
+
blueBright: f("\x1B[94m", "\x1B[39m"),
|
|
89
|
+
magentaBright: f("\x1B[95m", "\x1B[39m"),
|
|
90
|
+
cyanBright: f("\x1B[96m", "\x1B[39m"),
|
|
91
|
+
whiteBright: f("\x1B[97m", "\x1B[39m"),
|
|
92
|
+
bgBlackBright: f("\x1B[100m", "\x1B[49m"),
|
|
93
|
+
bgRedBright: f("\x1B[101m", "\x1B[49m"),
|
|
94
|
+
bgGreenBright: f("\x1B[102m", "\x1B[49m"),
|
|
95
|
+
bgYellowBright: f("\x1B[103m", "\x1B[49m"),
|
|
96
|
+
bgBlueBright: f("\x1B[104m", "\x1B[49m"),
|
|
97
|
+
bgMagentaBright: f("\x1B[105m", "\x1B[49m"),
|
|
98
|
+
bgCyanBright: f("\x1B[106m", "\x1B[49m"),
|
|
99
|
+
bgWhiteBright: f("\x1B[107m", "\x1B[49m")
|
|
100
|
+
};
|
|
101
|
+
};
|
|
102
|
+
module.exports = createColors();
|
|
103
|
+
module.exports.createColors = createColors;
|
|
104
|
+
}
|
|
105
|
+
});
|
|
106
|
+
|
|
107
|
+
// ../../node_modules/.pnpm/sisteransi@1.0.5/node_modules/sisteransi/src/index.js
|
|
108
|
+
var require_src = __commonJS({
|
|
109
|
+
"../../node_modules/.pnpm/sisteransi@1.0.5/node_modules/sisteransi/src/index.js"(exports, module) {
|
|
110
|
+
"use strict";
|
|
111
|
+
var ESC = "\x1B";
|
|
112
|
+
var CSI = `${ESC}[`;
|
|
113
|
+
var beep = "\x07";
|
|
114
|
+
var cursor = {
|
|
115
|
+
to(x3, y2) {
|
|
116
|
+
if (!y2) return `${CSI}${x3 + 1}G`;
|
|
117
|
+
return `${CSI}${y2 + 1};${x3 + 1}H`;
|
|
118
|
+
},
|
|
119
|
+
move(x3, y2) {
|
|
120
|
+
let ret = "";
|
|
121
|
+
if (x3 < 0) ret += `${CSI}${-x3}D`;
|
|
122
|
+
else if (x3 > 0) ret += `${CSI}${x3}C`;
|
|
123
|
+
if (y2 < 0) ret += `${CSI}${-y2}A`;
|
|
124
|
+
else if (y2 > 0) ret += `${CSI}${y2}B`;
|
|
125
|
+
return ret;
|
|
126
|
+
},
|
|
127
|
+
up: (count = 1) => `${CSI}${count}A`,
|
|
128
|
+
down: (count = 1) => `${CSI}${count}B`,
|
|
129
|
+
forward: (count = 1) => `${CSI}${count}C`,
|
|
130
|
+
backward: (count = 1) => `${CSI}${count}D`,
|
|
131
|
+
nextLine: (count = 1) => `${CSI}E`.repeat(count),
|
|
132
|
+
prevLine: (count = 1) => `${CSI}F`.repeat(count),
|
|
133
|
+
left: `${CSI}G`,
|
|
134
|
+
hide: `${CSI}?25l`,
|
|
135
|
+
show: `${CSI}?25h`,
|
|
136
|
+
save: `${ESC}7`,
|
|
137
|
+
restore: `${ESC}8`
|
|
138
|
+
};
|
|
139
|
+
var scroll = {
|
|
140
|
+
up: (count = 1) => `${CSI}S`.repeat(count),
|
|
141
|
+
down: (count = 1) => `${CSI}T`.repeat(count)
|
|
142
|
+
};
|
|
143
|
+
var erase = {
|
|
144
|
+
screen: `${CSI}2J`,
|
|
145
|
+
up: (count = 1) => `${CSI}1J`.repeat(count),
|
|
146
|
+
down: (count = 1) => `${CSI}J`.repeat(count),
|
|
147
|
+
line: `${CSI}2K`,
|
|
148
|
+
lineEnd: `${CSI}K`,
|
|
149
|
+
lineStart: `${CSI}1K`,
|
|
150
|
+
lines(count) {
|
|
151
|
+
let clear = "";
|
|
152
|
+
for (let i = 0; i < count; i++)
|
|
153
|
+
clear += this.line + (i < count - 1 ? cursor.up() : "");
|
|
154
|
+
if (count)
|
|
155
|
+
clear += cursor.left;
|
|
156
|
+
return clear;
|
|
157
|
+
}
|
|
158
|
+
};
|
|
159
|
+
module.exports = { cursor, scroll, erase, beep };
|
|
160
|
+
}
|
|
161
|
+
});
|
|
162
|
+
|
|
163
|
+
// src/index.ts
|
|
164
|
+
import { Command as Command6 } from "commander";
|
|
165
|
+
|
|
166
|
+
// src/commands/auth.ts
|
|
167
|
+
import { Command } from "commander";
|
|
168
|
+
|
|
169
|
+
// src/lib/config.ts
|
|
170
|
+
import { readFileSync, writeFileSync, mkdirSync, existsSync } from "fs";
|
|
171
|
+
import { join } from "path";
|
|
172
|
+
import { homedir } from "os";
|
|
173
|
+
var CONFIG_DIR = join(homedir(), ".localskills");
|
|
174
|
+
var CONFIG_PATH = join(CONFIG_DIR, "config.json");
|
|
175
|
+
var DEFAULT_CONFIG = {
|
|
176
|
+
config_version: 2,
|
|
177
|
+
api_url: "https://localskills.sh",
|
|
178
|
+
token: null,
|
|
179
|
+
installed_skills: {},
|
|
180
|
+
defaults: {
|
|
181
|
+
scope: "project",
|
|
182
|
+
method: "symlink"
|
|
183
|
+
}
|
|
184
|
+
};
|
|
185
|
+
function loadConfig() {
|
|
186
|
+
if (!existsSync(CONFIG_PATH)) {
|
|
187
|
+
return { ...DEFAULT_CONFIG, installed_skills: {} };
|
|
188
|
+
}
|
|
189
|
+
try {
|
|
190
|
+
const raw = JSON.parse(readFileSync(CONFIG_PATH, "utf-8"));
|
|
191
|
+
if (!raw.config_version || raw.config_version < 2) {
|
|
192
|
+
return migrateV1toV2(raw);
|
|
193
|
+
}
|
|
194
|
+
return { ...DEFAULT_CONFIG, ...raw };
|
|
195
|
+
} catch {
|
|
196
|
+
return { ...DEFAULT_CONFIG, installed_skills: {} };
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
function saveConfig(config) {
|
|
200
|
+
mkdirSync(CONFIG_DIR, { recursive: true });
|
|
201
|
+
writeFileSync(CONFIG_PATH, JSON.stringify(config, null, 2) + "\n");
|
|
202
|
+
}
|
|
203
|
+
function migrateV1toV2(v1) {
|
|
204
|
+
const v2 = {
|
|
205
|
+
config_version: 2,
|
|
206
|
+
api_url: v1.api_url || DEFAULT_CONFIG.api_url,
|
|
207
|
+
token: v1.token,
|
|
208
|
+
installed_skills: {},
|
|
209
|
+
defaults: {
|
|
210
|
+
scope: "project",
|
|
211
|
+
method: "symlink"
|
|
212
|
+
}
|
|
213
|
+
};
|
|
214
|
+
for (const [key, skill] of Object.entries(v1.installed_skills || {})) {
|
|
215
|
+
const isGlobal = skill.path.startsWith(homedir());
|
|
216
|
+
v2.installed_skills[key] = {
|
|
217
|
+
slug: skill.slug,
|
|
218
|
+
name: skill.slug,
|
|
219
|
+
hash: skill.hash,
|
|
220
|
+
version: 0,
|
|
221
|
+
cachedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
222
|
+
installations: [
|
|
223
|
+
{
|
|
224
|
+
platform: skill.target,
|
|
225
|
+
scope: isGlobal ? "global" : "project",
|
|
226
|
+
method: "copy",
|
|
227
|
+
path: skill.path,
|
|
228
|
+
installedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
229
|
+
}
|
|
230
|
+
]
|
|
231
|
+
};
|
|
232
|
+
}
|
|
233
|
+
saveConfig(v2);
|
|
234
|
+
return v2;
|
|
235
|
+
}
|
|
236
|
+
function getToken() {
|
|
237
|
+
return loadConfig().token;
|
|
238
|
+
}
|
|
239
|
+
function setToken(token) {
|
|
240
|
+
const config = loadConfig();
|
|
241
|
+
config.token = token;
|
|
242
|
+
saveConfig(config);
|
|
243
|
+
}
|
|
244
|
+
function clearToken() {
|
|
245
|
+
const config = loadConfig();
|
|
246
|
+
config.token = null;
|
|
247
|
+
saveConfig(config);
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
// src/lib/api-client.ts
|
|
251
|
+
var ApiClient = class {
|
|
252
|
+
baseUrl;
|
|
253
|
+
token;
|
|
254
|
+
constructor() {
|
|
255
|
+
const config = loadConfig();
|
|
256
|
+
this.baseUrl = config.api_url;
|
|
257
|
+
this.token = config.token;
|
|
258
|
+
}
|
|
259
|
+
headers() {
|
|
260
|
+
const h = {
|
|
261
|
+
"Content-Type": "application/json"
|
|
262
|
+
};
|
|
263
|
+
if (this.token) {
|
|
264
|
+
h["Authorization"] = `Bearer ${this.token}`;
|
|
265
|
+
}
|
|
266
|
+
return h;
|
|
267
|
+
}
|
|
268
|
+
async get(path) {
|
|
269
|
+
const res = await fetch(`${this.baseUrl}${path}`, {
|
|
270
|
+
headers: this.headers()
|
|
271
|
+
});
|
|
272
|
+
return res.json();
|
|
273
|
+
}
|
|
274
|
+
async post(path, body) {
|
|
275
|
+
const res = await fetch(`${this.baseUrl}${path}`, {
|
|
276
|
+
method: "POST",
|
|
277
|
+
headers: this.headers(),
|
|
278
|
+
body: body ? JSON.stringify(body) : void 0
|
|
279
|
+
});
|
|
280
|
+
return res.json();
|
|
281
|
+
}
|
|
282
|
+
async put(path, body) {
|
|
283
|
+
const res = await fetch(`${this.baseUrl}${path}`, {
|
|
284
|
+
method: "PUT",
|
|
285
|
+
headers: this.headers(),
|
|
286
|
+
body: JSON.stringify(body)
|
|
287
|
+
});
|
|
288
|
+
return res.json();
|
|
289
|
+
}
|
|
290
|
+
async delete(path) {
|
|
291
|
+
const res = await fetch(`${this.baseUrl}${path}`, {
|
|
292
|
+
method: "DELETE",
|
|
293
|
+
headers: this.headers()
|
|
294
|
+
});
|
|
295
|
+
return res.json();
|
|
296
|
+
}
|
|
297
|
+
async getRaw(path) {
|
|
298
|
+
return fetch(`${this.baseUrl}${path}`, {
|
|
299
|
+
headers: this.headers()
|
|
300
|
+
});
|
|
301
|
+
}
|
|
302
|
+
isAuthenticated() {
|
|
303
|
+
return this.token !== null;
|
|
304
|
+
}
|
|
305
|
+
};
|
|
306
|
+
|
|
307
|
+
// src/commands/auth.ts
|
|
308
|
+
var loginCommand = new Command("login").description("Log in to localskills.sh").action(async () => {
|
|
309
|
+
const client = new ApiClient();
|
|
310
|
+
console.log("Opening browser for authentication...");
|
|
311
|
+
console.log("Visit: https://localskills.sh/api/cli/auth to authorize this device\n");
|
|
312
|
+
const readline = await import("readline");
|
|
313
|
+
const rl = readline.createInterface({
|
|
314
|
+
input: process.stdin,
|
|
315
|
+
output: process.stdout
|
|
316
|
+
});
|
|
317
|
+
const token = await new Promise((resolve3) => {
|
|
318
|
+
rl.question("Paste your API token: ", (answer) => {
|
|
319
|
+
rl.close();
|
|
320
|
+
resolve3(answer.trim());
|
|
321
|
+
});
|
|
322
|
+
});
|
|
323
|
+
if (!token) {
|
|
324
|
+
console.error("No token provided. Login cancelled.");
|
|
325
|
+
process.exit(1);
|
|
326
|
+
}
|
|
327
|
+
setToken(token);
|
|
328
|
+
console.log("Logged in successfully!");
|
|
329
|
+
});
|
|
330
|
+
var logoutCommand = new Command("logout").description("Log out of localskills.sh").action(() => {
|
|
331
|
+
clearToken();
|
|
332
|
+
console.log("Logged out.");
|
|
333
|
+
});
|
|
334
|
+
var whoamiCommand = new Command("whoami").description("Show current user info").action(async () => {
|
|
335
|
+
const token = getToken();
|
|
336
|
+
if (!token) {
|
|
337
|
+
console.log("Not logged in. Run `localskills login` to authenticate.");
|
|
338
|
+
process.exit(1);
|
|
339
|
+
return;
|
|
340
|
+
}
|
|
341
|
+
console.log("Authenticated with token:", token.slice(0, 8) + "...");
|
|
342
|
+
});
|
|
343
|
+
|
|
344
|
+
// src/commands/install.ts
|
|
345
|
+
import { Command as Command2 } from "commander";
|
|
346
|
+
|
|
347
|
+
// ../../node_modules/.pnpm/@clack+core@1.0.1/node_modules/@clack/core/dist/index.mjs
|
|
348
|
+
var import_sisteransi = __toESM(require_src(), 1);
|
|
349
|
+
import { stdout as R, stdin as q } from "process";
|
|
350
|
+
import * as k from "readline";
|
|
351
|
+
import ot from "readline";
|
|
352
|
+
import { ReadStream as J } from "tty";
|
|
353
|
+
function B(t, e2, s) {
|
|
354
|
+
if (!s.some((u) => !u.disabled)) return t;
|
|
355
|
+
const i = t + e2, r = Math.max(s.length - 1, 0), n = i < 0 ? r : i > r ? 0 : i;
|
|
356
|
+
return s[n].disabled ? B(n, e2 < 0 ? -1 : 1, s) : n;
|
|
357
|
+
}
|
|
358
|
+
var at = (t) => t === 161 || t === 164 || t === 167 || t === 168 || t === 170 || t === 173 || t === 174 || t >= 176 && t <= 180 || t >= 182 && t <= 186 || t >= 188 && t <= 191 || t === 198 || t === 208 || t === 215 || t === 216 || t >= 222 && t <= 225 || t === 230 || t >= 232 && t <= 234 || t === 236 || t === 237 || t === 240 || t === 242 || t === 243 || t >= 247 && t <= 250 || t === 252 || t === 254 || t === 257 || t === 273 || t === 275 || t === 283 || t === 294 || t === 295 || t === 299 || t >= 305 && t <= 307 || t === 312 || t >= 319 && t <= 322 || t === 324 || t >= 328 && t <= 331 || t === 333 || t === 338 || t === 339 || t === 358 || t === 359 || t === 363 || t === 462 || t === 464 || t === 466 || t === 468 || t === 470 || t === 472 || t === 474 || t === 476 || t === 593 || t === 609 || t === 708 || t === 711 || t >= 713 && t <= 715 || t === 717 || t === 720 || t >= 728 && t <= 731 || t === 733 || t === 735 || t >= 768 && t <= 879 || t >= 913 && t <= 929 || t >= 931 && t <= 937 || t >= 945 && t <= 961 || t >= 963 && t <= 969 || t === 1025 || t >= 1040 && t <= 1103 || t === 1105 || t === 8208 || t >= 8211 && t <= 8214 || t === 8216 || t === 8217 || t === 8220 || t === 8221 || t >= 8224 && t <= 8226 || t >= 8228 && t <= 8231 || t === 8240 || t === 8242 || t === 8243 || t === 8245 || t === 8251 || t === 8254 || t === 8308 || t === 8319 || t >= 8321 && t <= 8324 || t === 8364 || t === 8451 || t === 8453 || t === 8457 || t === 8467 || t === 8470 || t === 8481 || t === 8482 || t === 8486 || t === 8491 || t === 8531 || t === 8532 || t >= 8539 && t <= 8542 || t >= 8544 && t <= 8555 || t >= 8560 && t <= 8569 || t === 8585 || t >= 8592 && t <= 8601 || t === 8632 || t === 8633 || t === 8658 || t === 8660 || t === 8679 || t === 8704 || t === 8706 || t === 8707 || t === 8711 || t === 8712 || t === 8715 || t === 8719 || t === 8721 || t === 8725 || t === 8730 || t >= 8733 && t <= 8736 || t === 8739 || t === 8741 || t >= 8743 && t <= 8748 || t === 8750 || t >= 8756 && t <= 8759 || t === 8764 || t === 8765 || t === 8776 || t === 8780 || t === 8786 || t === 8800 || t === 8801 || t >= 8804 && t <= 8807 || t === 8810 || t === 8811 || t === 8814 || t === 8815 || t === 8834 || t === 8835 || t === 8838 || t === 8839 || t === 8853 || t === 8857 || t === 8869 || t === 8895 || t === 8978 || t >= 9312 && t <= 9449 || t >= 9451 && t <= 9547 || t >= 9552 && t <= 9587 || t >= 9600 && t <= 9615 || t >= 9618 && t <= 9621 || t === 9632 || t === 9633 || t >= 9635 && t <= 9641 || t === 9650 || t === 9651 || t === 9654 || t === 9655 || t === 9660 || t === 9661 || t === 9664 || t === 9665 || t >= 9670 && t <= 9672 || t === 9675 || t >= 9678 && t <= 9681 || t >= 9698 && t <= 9701 || t === 9711 || t === 9733 || t === 9734 || t === 9737 || t === 9742 || t === 9743 || t === 9756 || t === 9758 || t === 9792 || t === 9794 || t === 9824 || t === 9825 || t >= 9827 && t <= 9829 || t >= 9831 && t <= 9834 || t === 9836 || t === 9837 || t === 9839 || t === 9886 || t === 9887 || t === 9919 || t >= 9926 && t <= 9933 || t >= 9935 && t <= 9939 || t >= 9941 && t <= 9953 || t === 9955 || t === 9960 || t === 9961 || t >= 9963 && t <= 9969 || t === 9972 || t >= 9974 && t <= 9977 || t === 9979 || t === 9980 || t === 9982 || t === 9983 || t === 10045 || t >= 10102 && t <= 10111 || t >= 11094 && t <= 11097 || t >= 12872 && t <= 12879 || t >= 57344 && t <= 63743 || t >= 65024 && t <= 65039 || t === 65533 || t >= 127232 && t <= 127242 || t >= 127248 && t <= 127277 || t >= 127280 && t <= 127337 || t >= 127344 && t <= 127373 || t === 127375 || t === 127376 || t >= 127387 && t <= 127404 || t >= 917760 && t <= 917999 || t >= 983040 && t <= 1048573 || t >= 1048576 && t <= 1114109;
|
|
359
|
+
var lt = (t) => t === 12288 || t >= 65281 && t <= 65376 || t >= 65504 && t <= 65510;
|
|
360
|
+
var ht = (t) => t >= 4352 && t <= 4447 || t === 8986 || t === 8987 || t === 9001 || t === 9002 || t >= 9193 && t <= 9196 || t === 9200 || t === 9203 || t === 9725 || t === 9726 || t === 9748 || t === 9749 || t >= 9800 && t <= 9811 || t === 9855 || t === 9875 || t === 9889 || t === 9898 || t === 9899 || t === 9917 || t === 9918 || t === 9924 || t === 9925 || t === 9934 || t === 9940 || t === 9962 || t === 9970 || t === 9971 || t === 9973 || t === 9978 || t === 9981 || t === 9989 || t === 9994 || t === 9995 || t === 10024 || t === 10060 || t === 10062 || t >= 10067 && t <= 10069 || t === 10071 || t >= 10133 && t <= 10135 || t === 10160 || t === 10175 || t === 11035 || t === 11036 || t === 11088 || t === 11093 || t >= 11904 && t <= 11929 || t >= 11931 && t <= 12019 || t >= 12032 && t <= 12245 || t >= 12272 && t <= 12287 || t >= 12289 && t <= 12350 || t >= 12353 && t <= 12438 || t >= 12441 && t <= 12543 || t >= 12549 && t <= 12591 || t >= 12593 && t <= 12686 || t >= 12688 && t <= 12771 || t >= 12783 && t <= 12830 || t >= 12832 && t <= 12871 || t >= 12880 && t <= 19903 || t >= 19968 && t <= 42124 || t >= 42128 && t <= 42182 || t >= 43360 && t <= 43388 || t >= 44032 && t <= 55203 || t >= 63744 && t <= 64255 || t >= 65040 && t <= 65049 || t >= 65072 && t <= 65106 || t >= 65108 && t <= 65126 || t >= 65128 && t <= 65131 || t >= 94176 && t <= 94180 || t === 94192 || t === 94193 || t >= 94208 && t <= 100343 || t >= 100352 && t <= 101589 || t >= 101632 && t <= 101640 || t >= 110576 && t <= 110579 || t >= 110581 && t <= 110587 || t === 110589 || t === 110590 || t >= 110592 && t <= 110882 || t === 110898 || t >= 110928 && t <= 110930 || t === 110933 || t >= 110948 && t <= 110951 || t >= 110960 && t <= 111355 || t === 126980 || t === 127183 || t === 127374 || t >= 127377 && t <= 127386 || t >= 127488 && t <= 127490 || t >= 127504 && t <= 127547 || t >= 127552 && t <= 127560 || t === 127568 || t === 127569 || t >= 127584 && t <= 127589 || t >= 127744 && t <= 127776 || t >= 127789 && t <= 127797 || t >= 127799 && t <= 127868 || t >= 127870 && t <= 127891 || t >= 127904 && t <= 127946 || t >= 127951 && t <= 127955 || t >= 127968 && t <= 127984 || t === 127988 || t >= 127992 && t <= 128062 || t === 128064 || t >= 128066 && t <= 128252 || t >= 128255 && t <= 128317 || t >= 128331 && t <= 128334 || t >= 128336 && t <= 128359 || t === 128378 || t === 128405 || t === 128406 || t === 128420 || t >= 128507 && t <= 128591 || t >= 128640 && t <= 128709 || t === 128716 || t >= 128720 && t <= 128722 || t >= 128725 && t <= 128727 || t >= 128732 && t <= 128735 || t === 128747 || t === 128748 || t >= 128756 && t <= 128764 || t >= 128992 && t <= 129003 || t === 129008 || t >= 129292 && t <= 129338 || t >= 129340 && t <= 129349 || t >= 129351 && t <= 129535 || t >= 129648 && t <= 129660 || t >= 129664 && t <= 129672 || t >= 129680 && t <= 129725 || t >= 129727 && t <= 129733 || t >= 129742 && t <= 129755 || t >= 129760 && t <= 129768 || t >= 129776 && t <= 129784 || t >= 131072 && t <= 196605 || t >= 196608 && t <= 262141;
|
|
361
|
+
var O = /[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]/y;
|
|
362
|
+
var y = /[\x00-\x08\x0A-\x1F\x7F-\x9F]{1,1000}/y;
|
|
363
|
+
var L = /\t{1,1000}/y;
|
|
364
|
+
var P = new RegExp("[\\u{1F1E6}-\\u{1F1FF}]{2}|\\u{1F3F4}[\\u{E0061}-\\u{E007A}]{2}[\\u{E0030}-\\u{E0039}\\u{E0061}-\\u{E007A}]{1,3}\\u{E007F}|(?:\\p{Emoji}\\uFE0F\\u20E3?|\\p{Emoji_Modifier_Base}\\p{Emoji_Modifier}?|\\p{Emoji_Presentation})(?:\\u200D(?:\\p{Emoji_Modifier_Base}\\p{Emoji_Modifier}?|\\p{Emoji_Presentation}|\\p{Emoji}\\uFE0F\\u20E3?))*", "yu");
|
|
365
|
+
var M = /(?:[\x20-\x7E\xA0-\xFF](?!\uFE0F)){1,1000}/y;
|
|
366
|
+
var ct = new RegExp("\\p{M}+", "gu");
|
|
367
|
+
var ft = { limit: 1 / 0, ellipsis: "" };
|
|
368
|
+
var X = (t, e2 = {}, s = {}) => {
|
|
369
|
+
const i = e2.limit ?? 1 / 0, r = e2.ellipsis ?? "", n = e2?.ellipsisWidth ?? (r ? X(r, ft, s).width : 0), u = s.ansiWidth ?? 0, a = s.controlWidth ?? 0, l = s.tabWidth ?? 8, E = s.ambiguousWidth ?? 1, g = s.emojiWidth ?? 2, m = s.fullWidthWidth ?? 2, A = s.regularWidth ?? 1, V2 = s.wideWidth ?? 2;
|
|
370
|
+
let h = 0, o = 0, p = t.length, v = 0, F = false, d2 = p, b = Math.max(0, i - n), C2 = 0, w = 0, c = 0, f = 0;
|
|
371
|
+
t: for (; ; ) {
|
|
372
|
+
if (w > C2 || o >= p && o > h) {
|
|
373
|
+
const ut2 = t.slice(C2, w) || t.slice(h, o);
|
|
374
|
+
v = 0;
|
|
375
|
+
for (const Y of ut2.replaceAll(ct, "")) {
|
|
376
|
+
const $ = Y.codePointAt(0) || 0;
|
|
377
|
+
if (lt($) ? f = m : ht($) ? f = V2 : E !== A && at($) ? f = E : f = A, c + f > b && (d2 = Math.min(d2, Math.max(C2, h) + v)), c + f > i) {
|
|
378
|
+
F = true;
|
|
379
|
+
break t;
|
|
380
|
+
}
|
|
381
|
+
v += Y.length, c += f;
|
|
382
|
+
}
|
|
383
|
+
C2 = w = 0;
|
|
384
|
+
}
|
|
385
|
+
if (o >= p) break;
|
|
386
|
+
if (M.lastIndex = o, M.test(t)) {
|
|
387
|
+
if (v = M.lastIndex - o, f = v * A, c + f > b && (d2 = Math.min(d2, o + Math.floor((b - c) / A))), c + f > i) {
|
|
388
|
+
F = true;
|
|
389
|
+
break;
|
|
390
|
+
}
|
|
391
|
+
c += f, C2 = h, w = o, o = h = M.lastIndex;
|
|
392
|
+
continue;
|
|
393
|
+
}
|
|
394
|
+
if (O.lastIndex = o, O.test(t)) {
|
|
395
|
+
if (c + u > b && (d2 = Math.min(d2, o)), c + u > i) {
|
|
396
|
+
F = true;
|
|
397
|
+
break;
|
|
398
|
+
}
|
|
399
|
+
c += u, C2 = h, w = o, o = h = O.lastIndex;
|
|
400
|
+
continue;
|
|
401
|
+
}
|
|
402
|
+
if (y.lastIndex = o, y.test(t)) {
|
|
403
|
+
if (v = y.lastIndex - o, f = v * a, c + f > b && (d2 = Math.min(d2, o + Math.floor((b - c) / a))), c + f > i) {
|
|
404
|
+
F = true;
|
|
405
|
+
break;
|
|
406
|
+
}
|
|
407
|
+
c += f, C2 = h, w = o, o = h = y.lastIndex;
|
|
408
|
+
continue;
|
|
409
|
+
}
|
|
410
|
+
if (L.lastIndex = o, L.test(t)) {
|
|
411
|
+
if (v = L.lastIndex - o, f = v * l, c + f > b && (d2 = Math.min(d2, o + Math.floor((b - c) / l))), c + f > i) {
|
|
412
|
+
F = true;
|
|
413
|
+
break;
|
|
414
|
+
}
|
|
415
|
+
c += f, C2 = h, w = o, o = h = L.lastIndex;
|
|
416
|
+
continue;
|
|
417
|
+
}
|
|
418
|
+
if (P.lastIndex = o, P.test(t)) {
|
|
419
|
+
if (c + g > b && (d2 = Math.min(d2, o)), c + g > i) {
|
|
420
|
+
F = true;
|
|
421
|
+
break;
|
|
422
|
+
}
|
|
423
|
+
c += g, C2 = h, w = o, o = h = P.lastIndex;
|
|
424
|
+
continue;
|
|
425
|
+
}
|
|
426
|
+
o += 1;
|
|
427
|
+
}
|
|
428
|
+
return { width: F ? b : c, index: F ? d2 : p, truncated: F, ellipsed: F && i >= n };
|
|
429
|
+
};
|
|
430
|
+
var pt = { limit: 1 / 0, ellipsis: "", ellipsisWidth: 0 };
|
|
431
|
+
var S = (t, e2 = {}) => X(t, pt, e2).width;
|
|
432
|
+
var W = "\x1B";
|
|
433
|
+
var Z = "\x9B";
|
|
434
|
+
var Ft = 39;
|
|
435
|
+
var j = "\x07";
|
|
436
|
+
var Q = "[";
|
|
437
|
+
var dt = "]";
|
|
438
|
+
var tt = "m";
|
|
439
|
+
var U = `${dt}8;;`;
|
|
440
|
+
var et = new RegExp(`(?:\\${Q}(?<code>\\d+)m|\\${U}(?<uri>.*)${j})`, "y");
|
|
441
|
+
var mt = (t) => {
|
|
442
|
+
if (t >= 30 && t <= 37 || t >= 90 && t <= 97) return 39;
|
|
443
|
+
if (t >= 40 && t <= 47 || t >= 100 && t <= 107) return 49;
|
|
444
|
+
if (t === 1 || t === 2) return 22;
|
|
445
|
+
if (t === 3) return 23;
|
|
446
|
+
if (t === 4) return 24;
|
|
447
|
+
if (t === 7) return 27;
|
|
448
|
+
if (t === 8) return 28;
|
|
449
|
+
if (t === 9) return 29;
|
|
450
|
+
if (t === 0) return 0;
|
|
451
|
+
};
|
|
452
|
+
var st = (t) => `${W}${Q}${t}${tt}`;
|
|
453
|
+
var it = (t) => `${W}${U}${t}${j}`;
|
|
454
|
+
var gt = (t) => t.map((e2) => S(e2));
|
|
455
|
+
var G = (t, e2, s) => {
|
|
456
|
+
const i = e2[Symbol.iterator]();
|
|
457
|
+
let r = false, n = false, u = t.at(-1), a = u === void 0 ? 0 : S(u), l = i.next(), E = i.next(), g = 0;
|
|
458
|
+
for (; !l.done; ) {
|
|
459
|
+
const m = l.value, A = S(m);
|
|
460
|
+
a + A <= s ? t[t.length - 1] += m : (t.push(m), a = 0), (m === W || m === Z) && (r = true, n = e2.startsWith(U, g + 1)), r ? n ? m === j && (r = false, n = false) : m === tt && (r = false) : (a += A, a === s && !E.done && (t.push(""), a = 0)), l = E, E = i.next(), g += m.length;
|
|
461
|
+
}
|
|
462
|
+
u = t.at(-1), !a && u !== void 0 && u.length > 0 && t.length > 1 && (t[t.length - 2] += t.pop());
|
|
463
|
+
};
|
|
464
|
+
var vt = (t) => {
|
|
465
|
+
const e2 = t.split(" ");
|
|
466
|
+
let s = e2.length;
|
|
467
|
+
for (; s > 0 && !(S(e2[s - 1]) > 0); ) s--;
|
|
468
|
+
return s === e2.length ? t : e2.slice(0, s).join(" ") + e2.slice(s).join("");
|
|
469
|
+
};
|
|
470
|
+
var Et = (t, e2, s = {}) => {
|
|
471
|
+
if (s.trim !== false && t.trim() === "") return "";
|
|
472
|
+
let i = "", r, n;
|
|
473
|
+
const u = t.split(" "), a = gt(u);
|
|
474
|
+
let l = [""];
|
|
475
|
+
for (const [h, o] of u.entries()) {
|
|
476
|
+
s.trim !== false && (l[l.length - 1] = (l.at(-1) ?? "").trimStart());
|
|
477
|
+
let p = S(l.at(-1) ?? "");
|
|
478
|
+
if (h !== 0 && (p >= e2 && (s.wordWrap === false || s.trim === false) && (l.push(""), p = 0), (p > 0 || s.trim === false) && (l[l.length - 1] += " ", p++)), s.hard && a[h] > e2) {
|
|
479
|
+
const v = e2 - p, F = 1 + Math.floor((a[h] - v - 1) / e2);
|
|
480
|
+
Math.floor((a[h] - 1) / e2) < F && l.push(""), G(l, o, e2);
|
|
481
|
+
continue;
|
|
482
|
+
}
|
|
483
|
+
if (p + a[h] > e2 && p > 0 && a[h] > 0) {
|
|
484
|
+
if (s.wordWrap === false && p < e2) {
|
|
485
|
+
G(l, o, e2);
|
|
486
|
+
continue;
|
|
487
|
+
}
|
|
488
|
+
l.push("");
|
|
489
|
+
}
|
|
490
|
+
if (p + a[h] > e2 && s.wordWrap === false) {
|
|
491
|
+
G(l, o, e2);
|
|
492
|
+
continue;
|
|
493
|
+
}
|
|
494
|
+
l[l.length - 1] += o;
|
|
495
|
+
}
|
|
496
|
+
s.trim !== false && (l = l.map((h) => vt(h)));
|
|
497
|
+
const E = l.join(`
|
|
498
|
+
`), g = E[Symbol.iterator]();
|
|
499
|
+
let m = g.next(), A = g.next(), V2 = 0;
|
|
500
|
+
for (; !m.done; ) {
|
|
501
|
+
const h = m.value, o = A.value;
|
|
502
|
+
if (i += h, h === W || h === Z) {
|
|
503
|
+
et.lastIndex = V2 + 1;
|
|
504
|
+
const F = et.exec(E)?.groups;
|
|
505
|
+
if (F?.code !== void 0) {
|
|
506
|
+
const d2 = Number.parseFloat(F.code);
|
|
507
|
+
r = d2 === Ft ? void 0 : d2;
|
|
508
|
+
} else F?.uri !== void 0 && (n = F.uri.length === 0 ? void 0 : F.uri);
|
|
509
|
+
}
|
|
510
|
+
const p = r ? mt(r) : void 0;
|
|
511
|
+
o === `
|
|
512
|
+
` ? (n && (i += it("")), r && p && (i += st(p))) : h === `
|
|
513
|
+
` && (r && p && (i += st(r)), n && (i += it(n))), V2 += h.length, m = A, A = g.next();
|
|
514
|
+
}
|
|
515
|
+
return i;
|
|
516
|
+
};
|
|
517
|
+
function K(t, e2, s) {
|
|
518
|
+
return String(t).normalize().replaceAll(`\r
|
|
519
|
+
`, `
|
|
520
|
+
`).split(`
|
|
521
|
+
`).map((i) => Et(i, e2, s)).join(`
|
|
522
|
+
`);
|
|
523
|
+
}
|
|
524
|
+
var At = ["up", "down", "left", "right", "space", "enter", "cancel"];
|
|
525
|
+
var _ = { actions: new Set(At), aliases: /* @__PURE__ */ new Map([["k", "up"], ["j", "down"], ["h", "left"], ["l", "right"], ["", "cancel"], ["escape", "cancel"]]), messages: { cancel: "Canceled", error: "Something went wrong" }, withGuide: true };
|
|
526
|
+
function H(t, e2) {
|
|
527
|
+
if (typeof t == "string") return _.aliases.get(t) === e2;
|
|
528
|
+
for (const s of t) if (s !== void 0 && H(s, e2)) return true;
|
|
529
|
+
return false;
|
|
530
|
+
}
|
|
531
|
+
function _t(t, e2) {
|
|
532
|
+
if (t === e2) return;
|
|
533
|
+
const s = t.split(`
|
|
534
|
+
`), i = e2.split(`
|
|
535
|
+
`), r = Math.max(s.length, i.length), n = [];
|
|
536
|
+
for (let u = 0; u < r; u++) s[u] !== i[u] && n.push(u);
|
|
537
|
+
return { lines: n, numLinesBefore: s.length, numLinesAfter: i.length, numLines: r };
|
|
538
|
+
}
|
|
539
|
+
var bt = globalThis.process.platform.startsWith("win");
|
|
540
|
+
var z = /* @__PURE__ */ Symbol("clack:cancel");
|
|
541
|
+
function Ct(t) {
|
|
542
|
+
return t === z;
|
|
543
|
+
}
|
|
544
|
+
function T(t, e2) {
|
|
545
|
+
const s = t;
|
|
546
|
+
s.isTTY && s.setRawMode(e2);
|
|
547
|
+
}
|
|
548
|
+
function Bt({ input: t = q, output: e2 = R, overwrite: s = true, hideCursor: i = true } = {}) {
|
|
549
|
+
const r = k.createInterface({ input: t, output: e2, prompt: "", tabSize: 1 });
|
|
550
|
+
k.emitKeypressEvents(t, r), t instanceof J && t.isTTY && t.setRawMode(true);
|
|
551
|
+
const n = (u, { name: a, sequence: l }) => {
|
|
552
|
+
const E = String(u);
|
|
553
|
+
if (H([E, a, l], "cancel")) {
|
|
554
|
+
i && e2.write(import_sisteransi.cursor.show), process.exit(0);
|
|
555
|
+
return;
|
|
556
|
+
}
|
|
557
|
+
if (!s) return;
|
|
558
|
+
const g = a === "return" ? 0 : -1, m = a === "return" ? -1 : 0;
|
|
559
|
+
k.moveCursor(e2, g, m, () => {
|
|
560
|
+
k.clearLine(e2, 1, () => {
|
|
561
|
+
t.once("keypress", n);
|
|
562
|
+
});
|
|
563
|
+
});
|
|
564
|
+
};
|
|
565
|
+
return i && e2.write(import_sisteransi.cursor.hide), t.once("keypress", n), () => {
|
|
566
|
+
t.off("keypress", n), i && e2.write(import_sisteransi.cursor.show), t instanceof J && t.isTTY && !bt && t.setRawMode(false), r.terminal = false, r.close();
|
|
567
|
+
};
|
|
568
|
+
}
|
|
569
|
+
var rt = (t) => "columns" in t && typeof t.columns == "number" ? t.columns : 80;
|
|
570
|
+
var nt = (t) => "rows" in t && typeof t.rows == "number" ? t.rows : 20;
|
|
571
|
+
function xt(t, e2, s, i = s) {
|
|
572
|
+
const r = rt(t ?? R);
|
|
573
|
+
return K(e2, r - s.length, { hard: true, trim: false }).split(`
|
|
574
|
+
`).map((n, u) => `${u === 0 ? i : s}${n}`).join(`
|
|
575
|
+
`);
|
|
576
|
+
}
|
|
577
|
+
var x = class {
|
|
578
|
+
input;
|
|
579
|
+
output;
|
|
580
|
+
_abortSignal;
|
|
581
|
+
rl;
|
|
582
|
+
opts;
|
|
583
|
+
_render;
|
|
584
|
+
_track = false;
|
|
585
|
+
_prevFrame = "";
|
|
586
|
+
_subscribers = /* @__PURE__ */ new Map();
|
|
587
|
+
_cursor = 0;
|
|
588
|
+
state = "initial";
|
|
589
|
+
error = "";
|
|
590
|
+
value;
|
|
591
|
+
userInput = "";
|
|
592
|
+
constructor(e2, s = true) {
|
|
593
|
+
const { input: i = q, output: r = R, render: n, signal: u, ...a } = e2;
|
|
594
|
+
this.opts = a, this.onKeypress = this.onKeypress.bind(this), this.close = this.close.bind(this), this.render = this.render.bind(this), this._render = n.bind(this), this._track = s, this._abortSignal = u, this.input = i, this.output = r;
|
|
595
|
+
}
|
|
596
|
+
unsubscribe() {
|
|
597
|
+
this._subscribers.clear();
|
|
598
|
+
}
|
|
599
|
+
setSubscriber(e2, s) {
|
|
600
|
+
const i = this._subscribers.get(e2) ?? [];
|
|
601
|
+
i.push(s), this._subscribers.set(e2, i);
|
|
602
|
+
}
|
|
603
|
+
on(e2, s) {
|
|
604
|
+
this.setSubscriber(e2, { cb: s });
|
|
605
|
+
}
|
|
606
|
+
once(e2, s) {
|
|
607
|
+
this.setSubscriber(e2, { cb: s, once: true });
|
|
608
|
+
}
|
|
609
|
+
emit(e2, ...s) {
|
|
610
|
+
const i = this._subscribers.get(e2) ?? [], r = [];
|
|
611
|
+
for (const n of i) n.cb(...s), n.once && r.push(() => i.splice(i.indexOf(n), 1));
|
|
612
|
+
for (const n of r) n();
|
|
613
|
+
}
|
|
614
|
+
prompt() {
|
|
615
|
+
return new Promise((e2) => {
|
|
616
|
+
if (this._abortSignal) {
|
|
617
|
+
if (this._abortSignal.aborted) return this.state = "cancel", this.close(), e2(z);
|
|
618
|
+
this._abortSignal.addEventListener("abort", () => {
|
|
619
|
+
this.state = "cancel", this.close();
|
|
620
|
+
}, { once: true });
|
|
621
|
+
}
|
|
622
|
+
this.rl = ot.createInterface({ input: this.input, tabSize: 2, prompt: "", escapeCodeTimeout: 50, terminal: true }), this.rl.prompt(), this.opts.initialUserInput !== void 0 && this._setUserInput(this.opts.initialUserInput, true), this.input.on("keypress", this.onKeypress), T(this.input, true), this.output.on("resize", this.render), this.render(), this.once("submit", () => {
|
|
623
|
+
this.output.write(import_sisteransi.cursor.show), this.output.off("resize", this.render), T(this.input, false), e2(this.value);
|
|
624
|
+
}), this.once("cancel", () => {
|
|
625
|
+
this.output.write(import_sisteransi.cursor.show), this.output.off("resize", this.render), T(this.input, false), e2(z);
|
|
626
|
+
});
|
|
627
|
+
});
|
|
628
|
+
}
|
|
629
|
+
_isActionKey(e2, s) {
|
|
630
|
+
return e2 === " ";
|
|
631
|
+
}
|
|
632
|
+
_setValue(e2) {
|
|
633
|
+
this.value = e2, this.emit("value", this.value);
|
|
634
|
+
}
|
|
635
|
+
_setUserInput(e2, s) {
|
|
636
|
+
this.userInput = e2 ?? "", this.emit("userInput", this.userInput), s && this._track && this.rl && (this.rl.write(this.userInput), this._cursor = this.rl.cursor);
|
|
637
|
+
}
|
|
638
|
+
_clearUserInput() {
|
|
639
|
+
this.rl?.write(null, { ctrl: true, name: "u" }), this._setUserInput("");
|
|
640
|
+
}
|
|
641
|
+
onKeypress(e2, s) {
|
|
642
|
+
if (this._track && s.name !== "return" && (s.name && this._isActionKey(e2, s) && this.rl?.write(null, { ctrl: true, name: "h" }), this._cursor = this.rl?.cursor ?? 0, this._setUserInput(this.rl?.line)), this.state === "error" && (this.state = "active"), s?.name && (!this._track && _.aliases.has(s.name) && this.emit("cursor", _.aliases.get(s.name)), _.actions.has(s.name) && this.emit("cursor", s.name)), e2 && (e2.toLowerCase() === "y" || e2.toLowerCase() === "n") && this.emit("confirm", e2.toLowerCase() === "y"), this.emit("key", e2?.toLowerCase(), s), s?.name === "return") {
|
|
643
|
+
if (this.opts.validate) {
|
|
644
|
+
const i = this.opts.validate(this.value);
|
|
645
|
+
i && (this.error = i instanceof Error ? i.message : i, this.state = "error", this.rl?.write(this.userInput));
|
|
646
|
+
}
|
|
647
|
+
this.state !== "error" && (this.state = "submit");
|
|
648
|
+
}
|
|
649
|
+
H([e2, s?.name, s?.sequence], "cancel") && (this.state = "cancel"), (this.state === "submit" || this.state === "cancel") && this.emit("finalize"), this.render(), (this.state === "submit" || this.state === "cancel") && this.close();
|
|
650
|
+
}
|
|
651
|
+
close() {
|
|
652
|
+
this.input.unpipe(), this.input.removeListener("keypress", this.onKeypress), this.output.write(`
|
|
653
|
+
`), T(this.input, false), this.rl?.close(), this.rl = void 0, this.emit(`${this.state}`, this.value), this.unsubscribe();
|
|
654
|
+
}
|
|
655
|
+
restoreCursor() {
|
|
656
|
+
const e2 = K(this._prevFrame, process.stdout.columns, { hard: true, trim: false }).split(`
|
|
657
|
+
`).length - 1;
|
|
658
|
+
this.output.write(import_sisteransi.cursor.move(-999, e2 * -1));
|
|
659
|
+
}
|
|
660
|
+
render() {
|
|
661
|
+
const e2 = K(this._render(this) ?? "", process.stdout.columns, { hard: true, trim: false });
|
|
662
|
+
if (e2 !== this._prevFrame) {
|
|
663
|
+
if (this.state === "initial") this.output.write(import_sisteransi.cursor.hide);
|
|
664
|
+
else {
|
|
665
|
+
const s = _t(this._prevFrame, e2), i = nt(this.output);
|
|
666
|
+
if (this.restoreCursor(), s) {
|
|
667
|
+
const r = Math.max(0, s.numLinesAfter - i), n = Math.max(0, s.numLinesBefore - i);
|
|
668
|
+
let u = s.lines.find((a) => a >= r);
|
|
669
|
+
if (u === void 0) {
|
|
670
|
+
this._prevFrame = e2;
|
|
671
|
+
return;
|
|
672
|
+
}
|
|
673
|
+
if (s.lines.length === 1) {
|
|
674
|
+
this.output.write(import_sisteransi.cursor.move(0, u - n)), this.output.write(import_sisteransi.erase.lines(1));
|
|
675
|
+
const a = e2.split(`
|
|
676
|
+
`);
|
|
677
|
+
this.output.write(a[u]), this._prevFrame = e2, this.output.write(import_sisteransi.cursor.move(0, a.length - u - 1));
|
|
678
|
+
return;
|
|
679
|
+
} else if (s.lines.length > 1) {
|
|
680
|
+
if (r < n) u = r;
|
|
681
|
+
else {
|
|
682
|
+
const l = u - n;
|
|
683
|
+
l > 0 && this.output.write(import_sisteransi.cursor.move(0, l));
|
|
684
|
+
}
|
|
685
|
+
this.output.write(import_sisteransi.erase.down());
|
|
686
|
+
const a = e2.split(`
|
|
687
|
+
`).slice(u);
|
|
688
|
+
this.output.write(a.join(`
|
|
689
|
+
`)), this._prevFrame = e2;
|
|
690
|
+
return;
|
|
691
|
+
}
|
|
692
|
+
}
|
|
693
|
+
this.output.write(import_sisteransi.erase.down());
|
|
694
|
+
}
|
|
695
|
+
this.output.write(e2), this.state === "initial" && (this.state = "active"), this._prevFrame = e2;
|
|
696
|
+
}
|
|
697
|
+
}
|
|
698
|
+
};
|
|
699
|
+
var Lt = class extends x {
|
|
700
|
+
options;
|
|
701
|
+
cursor = 0;
|
|
702
|
+
get _value() {
|
|
703
|
+
return this.options[this.cursor].value;
|
|
704
|
+
}
|
|
705
|
+
get _enabledOptions() {
|
|
706
|
+
return this.options.filter((e2) => e2.disabled !== true);
|
|
707
|
+
}
|
|
708
|
+
toggleAll() {
|
|
709
|
+
const e2 = this._enabledOptions, s = this.value !== void 0 && this.value.length === e2.length;
|
|
710
|
+
this.value = s ? [] : e2.map((i) => i.value);
|
|
711
|
+
}
|
|
712
|
+
toggleInvert() {
|
|
713
|
+
const e2 = this.value;
|
|
714
|
+
if (!e2) return;
|
|
715
|
+
const s = this._enabledOptions.filter((i) => !e2.includes(i.value));
|
|
716
|
+
this.value = s.map((i) => i.value);
|
|
717
|
+
}
|
|
718
|
+
toggleValue() {
|
|
719
|
+
this.value === void 0 && (this.value = []);
|
|
720
|
+
const e2 = this.value.includes(this._value);
|
|
721
|
+
this.value = e2 ? this.value.filter((s) => s !== this._value) : [...this.value, this._value];
|
|
722
|
+
}
|
|
723
|
+
constructor(e2) {
|
|
724
|
+
super(e2, false), this.options = e2.options, this.value = [...e2.initialValues ?? []];
|
|
725
|
+
const s = Math.max(this.options.findIndex(({ value: i }) => i === e2.cursorAt), 0);
|
|
726
|
+
this.cursor = this.options[s].disabled ? B(s, 1, this.options) : s, this.on("key", (i) => {
|
|
727
|
+
i === "a" && this.toggleAll(), i === "i" && this.toggleInvert();
|
|
728
|
+
}), this.on("cursor", (i) => {
|
|
729
|
+
switch (i) {
|
|
730
|
+
case "left":
|
|
731
|
+
case "up":
|
|
732
|
+
this.cursor = B(this.cursor, -1, this.options);
|
|
733
|
+
break;
|
|
734
|
+
case "down":
|
|
735
|
+
case "right":
|
|
736
|
+
this.cursor = B(this.cursor, 1, this.options);
|
|
737
|
+
break;
|
|
738
|
+
case "space":
|
|
739
|
+
this.toggleValue();
|
|
740
|
+
break;
|
|
741
|
+
}
|
|
742
|
+
});
|
|
743
|
+
}
|
|
744
|
+
};
|
|
745
|
+
var Wt = class extends x {
|
|
746
|
+
options;
|
|
747
|
+
cursor = 0;
|
|
748
|
+
get _selectedValue() {
|
|
749
|
+
return this.options[this.cursor];
|
|
750
|
+
}
|
|
751
|
+
changeValue() {
|
|
752
|
+
this.value = this._selectedValue.value;
|
|
753
|
+
}
|
|
754
|
+
constructor(e2) {
|
|
755
|
+
super(e2, false), this.options = e2.options;
|
|
756
|
+
const s = this.options.findIndex(({ value: r }) => r === e2.initialValue), i = s === -1 ? 0 : s;
|
|
757
|
+
this.cursor = this.options[i].disabled ? B(i, 1, this.options) : i, this.changeValue(), this.on("cursor", (r) => {
|
|
758
|
+
switch (r) {
|
|
759
|
+
case "left":
|
|
760
|
+
case "up":
|
|
761
|
+
this.cursor = B(this.cursor, -1, this.options);
|
|
762
|
+
break;
|
|
763
|
+
case "down":
|
|
764
|
+
case "right":
|
|
765
|
+
this.cursor = B(this.cursor, 1, this.options);
|
|
766
|
+
break;
|
|
767
|
+
}
|
|
768
|
+
this.changeValue();
|
|
769
|
+
});
|
|
770
|
+
}
|
|
771
|
+
};
|
|
772
|
+
|
|
773
|
+
// ../../node_modules/.pnpm/@clack+prompts@1.0.1/node_modules/@clack/prompts/dist/index.mjs
|
|
774
|
+
var import_picocolors = __toESM(require_picocolors(), 1);
|
|
775
|
+
var import_sisteransi2 = __toESM(require_src(), 1);
|
|
776
|
+
import N2 from "process";
|
|
777
|
+
import { readdirSync as de, existsSync as $e, lstatSync as xt2 } from "fs";
|
|
778
|
+
import { dirname as _t2, join as he } from "path";
|
|
779
|
+
import { stripVTControlCharacters as ut } from "util";
|
|
780
|
+
function me() {
|
|
781
|
+
return N2.platform !== "win32" ? N2.env.TERM !== "linux" : !!N2.env.CI || !!N2.env.WT_SESSION || !!N2.env.TERMINUS_SUBLIME || N2.env.ConEmuTask === "{cmd::Cmder}" || N2.env.TERM_PROGRAM === "Terminus-Sublime" || N2.env.TERM_PROGRAM === "vscode" || N2.env.TERM === "xterm-256color" || N2.env.TERM === "alacritty" || N2.env.TERMINAL_EMULATOR === "JetBrains-JediTerm";
|
|
782
|
+
}
|
|
783
|
+
var et2 = me();
|
|
784
|
+
var ct2 = () => process.env.CI === "true";
|
|
785
|
+
var C = (t, r) => et2 ? t : r;
|
|
786
|
+
var Rt = C("\u25C6", "*");
|
|
787
|
+
var dt2 = C("\u25A0", "x");
|
|
788
|
+
var $t2 = C("\u25B2", "x");
|
|
789
|
+
var V = C("\u25C7", "o");
|
|
790
|
+
var ht2 = C("\u250C", "T");
|
|
791
|
+
var d = C("\u2502", "|");
|
|
792
|
+
var x2 = C("\u2514", "\u2014");
|
|
793
|
+
var Ot = C("\u2510", "T");
|
|
794
|
+
var Pt = C("\u2518", "\u2014");
|
|
795
|
+
var Q2 = C("\u25CF", ">");
|
|
796
|
+
var H2 = C("\u25CB", " ");
|
|
797
|
+
var st2 = C("\u25FB", "[\u2022]");
|
|
798
|
+
var U2 = C("\u25FC", "[+]");
|
|
799
|
+
var q2 = C("\u25FB", "[ ]");
|
|
800
|
+
var Nt = C("\u25AA", "\u2022");
|
|
801
|
+
var rt2 = C("\u2500", "-");
|
|
802
|
+
var mt2 = C("\u256E", "+");
|
|
803
|
+
var Wt2 = C("\u251C", "+");
|
|
804
|
+
var pt2 = C("\u256F", "+");
|
|
805
|
+
var gt2 = C("\u2570", "+");
|
|
806
|
+
var Lt2 = C("\u256D", "+");
|
|
807
|
+
var ft2 = C("\u25CF", "\u2022");
|
|
808
|
+
var Ft2 = C("\u25C6", "*");
|
|
809
|
+
var yt2 = C("\u25B2", "!");
|
|
810
|
+
var Et2 = C("\u25A0", "x");
|
|
811
|
+
var W2 = (t) => {
|
|
812
|
+
switch (t) {
|
|
813
|
+
case "initial":
|
|
814
|
+
case "active":
|
|
815
|
+
return import_picocolors.default.cyan(Rt);
|
|
816
|
+
case "cancel":
|
|
817
|
+
return import_picocolors.default.red(dt2);
|
|
818
|
+
case "error":
|
|
819
|
+
return import_picocolors.default.yellow($t2);
|
|
820
|
+
case "submit":
|
|
821
|
+
return import_picocolors.default.green(V);
|
|
822
|
+
}
|
|
823
|
+
};
|
|
824
|
+
var vt2 = (t) => {
|
|
825
|
+
switch (t) {
|
|
826
|
+
case "initial":
|
|
827
|
+
case "active":
|
|
828
|
+
return import_picocolors.default.cyan(d);
|
|
829
|
+
case "cancel":
|
|
830
|
+
return import_picocolors.default.red(d);
|
|
831
|
+
case "error":
|
|
832
|
+
return import_picocolors.default.yellow(d);
|
|
833
|
+
case "submit":
|
|
834
|
+
return import_picocolors.default.green(d);
|
|
835
|
+
}
|
|
836
|
+
};
|
|
837
|
+
var pe = (t) => t === 161 || t === 164 || t === 167 || t === 168 || t === 170 || t === 173 || t === 174 || t >= 176 && t <= 180 || t >= 182 && t <= 186 || t >= 188 && t <= 191 || t === 198 || t === 208 || t === 215 || t === 216 || t >= 222 && t <= 225 || t === 230 || t >= 232 && t <= 234 || t === 236 || t === 237 || t === 240 || t === 242 || t === 243 || t >= 247 && t <= 250 || t === 252 || t === 254 || t === 257 || t === 273 || t === 275 || t === 283 || t === 294 || t === 295 || t === 299 || t >= 305 && t <= 307 || t === 312 || t >= 319 && t <= 322 || t === 324 || t >= 328 && t <= 331 || t === 333 || t === 338 || t === 339 || t === 358 || t === 359 || t === 363 || t === 462 || t === 464 || t === 466 || t === 468 || t === 470 || t === 472 || t === 474 || t === 476 || t === 593 || t === 609 || t === 708 || t === 711 || t >= 713 && t <= 715 || t === 717 || t === 720 || t >= 728 && t <= 731 || t === 733 || t === 735 || t >= 768 && t <= 879 || t >= 913 && t <= 929 || t >= 931 && t <= 937 || t >= 945 && t <= 961 || t >= 963 && t <= 969 || t === 1025 || t >= 1040 && t <= 1103 || t === 1105 || t === 8208 || t >= 8211 && t <= 8214 || t === 8216 || t === 8217 || t === 8220 || t === 8221 || t >= 8224 && t <= 8226 || t >= 8228 && t <= 8231 || t === 8240 || t === 8242 || t === 8243 || t === 8245 || t === 8251 || t === 8254 || t === 8308 || t === 8319 || t >= 8321 && t <= 8324 || t === 8364 || t === 8451 || t === 8453 || t === 8457 || t === 8467 || t === 8470 || t === 8481 || t === 8482 || t === 8486 || t === 8491 || t === 8531 || t === 8532 || t >= 8539 && t <= 8542 || t >= 8544 && t <= 8555 || t >= 8560 && t <= 8569 || t === 8585 || t >= 8592 && t <= 8601 || t === 8632 || t === 8633 || t === 8658 || t === 8660 || t === 8679 || t === 8704 || t === 8706 || t === 8707 || t === 8711 || t === 8712 || t === 8715 || t === 8719 || t === 8721 || t === 8725 || t === 8730 || t >= 8733 && t <= 8736 || t === 8739 || t === 8741 || t >= 8743 && t <= 8748 || t === 8750 || t >= 8756 && t <= 8759 || t === 8764 || t === 8765 || t === 8776 || t === 8780 || t === 8786 || t === 8800 || t === 8801 || t >= 8804 && t <= 8807 || t === 8810 || t === 8811 || t === 8814 || t === 8815 || t === 8834 || t === 8835 || t === 8838 || t === 8839 || t === 8853 || t === 8857 || t === 8869 || t === 8895 || t === 8978 || t >= 9312 && t <= 9449 || t >= 9451 && t <= 9547 || t >= 9552 && t <= 9587 || t >= 9600 && t <= 9615 || t >= 9618 && t <= 9621 || t === 9632 || t === 9633 || t >= 9635 && t <= 9641 || t === 9650 || t === 9651 || t === 9654 || t === 9655 || t === 9660 || t === 9661 || t === 9664 || t === 9665 || t >= 9670 && t <= 9672 || t === 9675 || t >= 9678 && t <= 9681 || t >= 9698 && t <= 9701 || t === 9711 || t === 9733 || t === 9734 || t === 9737 || t === 9742 || t === 9743 || t === 9756 || t === 9758 || t === 9792 || t === 9794 || t === 9824 || t === 9825 || t >= 9827 && t <= 9829 || t >= 9831 && t <= 9834 || t === 9836 || t === 9837 || t === 9839 || t === 9886 || t === 9887 || t === 9919 || t >= 9926 && t <= 9933 || t >= 9935 && t <= 9939 || t >= 9941 && t <= 9953 || t === 9955 || t === 9960 || t === 9961 || t >= 9963 && t <= 9969 || t === 9972 || t >= 9974 && t <= 9977 || t === 9979 || t === 9980 || t === 9982 || t === 9983 || t === 10045 || t >= 10102 && t <= 10111 || t >= 11094 && t <= 11097 || t >= 12872 && t <= 12879 || t >= 57344 && t <= 63743 || t >= 65024 && t <= 65039 || t === 65533 || t >= 127232 && t <= 127242 || t >= 127248 && t <= 127277 || t >= 127280 && t <= 127337 || t >= 127344 && t <= 127373 || t === 127375 || t === 127376 || t >= 127387 && t <= 127404 || t >= 917760 && t <= 917999 || t >= 983040 && t <= 1048573 || t >= 1048576 && t <= 1114109;
|
|
838
|
+
var ge = (t) => t === 12288 || t >= 65281 && t <= 65376 || t >= 65504 && t <= 65510;
|
|
839
|
+
var fe = (t) => t >= 4352 && t <= 4447 || t === 8986 || t === 8987 || t === 9001 || t === 9002 || t >= 9193 && t <= 9196 || t === 9200 || t === 9203 || t === 9725 || t === 9726 || t === 9748 || t === 9749 || t >= 9800 && t <= 9811 || t === 9855 || t === 9875 || t === 9889 || t === 9898 || t === 9899 || t === 9917 || t === 9918 || t === 9924 || t === 9925 || t === 9934 || t === 9940 || t === 9962 || t === 9970 || t === 9971 || t === 9973 || t === 9978 || t === 9981 || t === 9989 || t === 9994 || t === 9995 || t === 10024 || t === 10060 || t === 10062 || t >= 10067 && t <= 10069 || t === 10071 || t >= 10133 && t <= 10135 || t === 10160 || t === 10175 || t === 11035 || t === 11036 || t === 11088 || t === 11093 || t >= 11904 && t <= 11929 || t >= 11931 && t <= 12019 || t >= 12032 && t <= 12245 || t >= 12272 && t <= 12287 || t >= 12289 && t <= 12350 || t >= 12353 && t <= 12438 || t >= 12441 && t <= 12543 || t >= 12549 && t <= 12591 || t >= 12593 && t <= 12686 || t >= 12688 && t <= 12771 || t >= 12783 && t <= 12830 || t >= 12832 && t <= 12871 || t >= 12880 && t <= 19903 || t >= 19968 && t <= 42124 || t >= 42128 && t <= 42182 || t >= 43360 && t <= 43388 || t >= 44032 && t <= 55203 || t >= 63744 && t <= 64255 || t >= 65040 && t <= 65049 || t >= 65072 && t <= 65106 || t >= 65108 && t <= 65126 || t >= 65128 && t <= 65131 || t >= 94176 && t <= 94180 || t === 94192 || t === 94193 || t >= 94208 && t <= 100343 || t >= 100352 && t <= 101589 || t >= 101632 && t <= 101640 || t >= 110576 && t <= 110579 || t >= 110581 && t <= 110587 || t === 110589 || t === 110590 || t >= 110592 && t <= 110882 || t === 110898 || t >= 110928 && t <= 110930 || t === 110933 || t >= 110948 && t <= 110951 || t >= 110960 && t <= 111355 || t === 126980 || t === 127183 || t === 127374 || t >= 127377 && t <= 127386 || t >= 127488 && t <= 127490 || t >= 127504 && t <= 127547 || t >= 127552 && t <= 127560 || t === 127568 || t === 127569 || t >= 127584 && t <= 127589 || t >= 127744 && t <= 127776 || t >= 127789 && t <= 127797 || t >= 127799 && t <= 127868 || t >= 127870 && t <= 127891 || t >= 127904 && t <= 127946 || t >= 127951 && t <= 127955 || t >= 127968 && t <= 127984 || t === 127988 || t >= 127992 && t <= 128062 || t === 128064 || t >= 128066 && t <= 128252 || t >= 128255 && t <= 128317 || t >= 128331 && t <= 128334 || t >= 128336 && t <= 128359 || t === 128378 || t === 128405 || t === 128406 || t === 128420 || t >= 128507 && t <= 128591 || t >= 128640 && t <= 128709 || t === 128716 || t >= 128720 && t <= 128722 || t >= 128725 && t <= 128727 || t >= 128732 && t <= 128735 || t === 128747 || t === 128748 || t >= 128756 && t <= 128764 || t >= 128992 && t <= 129003 || t === 129008 || t >= 129292 && t <= 129338 || t >= 129340 && t <= 129349 || t >= 129351 && t <= 129535 || t >= 129648 && t <= 129660 || t >= 129664 && t <= 129672 || t >= 129680 && t <= 129725 || t >= 129727 && t <= 129733 || t >= 129742 && t <= 129755 || t >= 129760 && t <= 129768 || t >= 129776 && t <= 129784 || t >= 131072 && t <= 196605 || t >= 196608 && t <= 262141;
|
|
840
|
+
var At2 = /[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]/y;
|
|
841
|
+
var it2 = /[\x00-\x08\x0A-\x1F\x7F-\x9F]{1,1000}/y;
|
|
842
|
+
var nt2 = /\t{1,1000}/y;
|
|
843
|
+
var wt = new RegExp("[\\u{1F1E6}-\\u{1F1FF}]{2}|\\u{1F3F4}[\\u{E0061}-\\u{E007A}]{2}[\\u{E0030}-\\u{E0039}\\u{E0061}-\\u{E007A}]{1,3}\\u{E007F}|(?:\\p{Emoji}\\uFE0F\\u20E3?|\\p{Emoji_Modifier_Base}\\p{Emoji_Modifier}?|\\p{Emoji_Presentation})(?:\\u200D(?:\\p{Emoji_Modifier_Base}\\p{Emoji_Modifier}?|\\p{Emoji_Presentation}|\\p{Emoji}\\uFE0F\\u20E3?))*", "yu");
|
|
844
|
+
var at2 = /(?:[\x20-\x7E\xA0-\xFF](?!\uFE0F)){1,1000}/y;
|
|
845
|
+
var Fe = new RegExp("\\p{M}+", "gu");
|
|
846
|
+
var ye = { limit: 1 / 0, ellipsis: "" };
|
|
847
|
+
var jt = (t, r = {}, s = {}) => {
|
|
848
|
+
const i = r.limit ?? 1 / 0, a = r.ellipsis ?? "", o = r?.ellipsisWidth ?? (a ? jt(a, ye, s).width : 0), u = s.ansiWidth ?? 0, l = s.controlWidth ?? 0, n = s.tabWidth ?? 8, c = s.ambiguousWidth ?? 1, g = s.emojiWidth ?? 2, F = s.fullWidthWidth ?? 2, p = s.regularWidth ?? 1, E = s.wideWidth ?? 2;
|
|
849
|
+
let $ = 0, m = 0, h = t.length, y2 = 0, f = false, v = h, S2 = Math.max(0, i - o), I2 = 0, B2 = 0, A = 0, w = 0;
|
|
850
|
+
t: for (; ; ) {
|
|
851
|
+
if (B2 > I2 || m >= h && m > $) {
|
|
852
|
+
const _2 = t.slice(I2, B2) || t.slice($, m);
|
|
853
|
+
y2 = 0;
|
|
854
|
+
for (const D of _2.replaceAll(Fe, "")) {
|
|
855
|
+
const T2 = D.codePointAt(0) || 0;
|
|
856
|
+
if (ge(T2) ? w = F : fe(T2) ? w = E : c !== p && pe(T2) ? w = c : w = p, A + w > S2 && (v = Math.min(v, Math.max(I2, $) + y2)), A + w > i) {
|
|
857
|
+
f = true;
|
|
858
|
+
break t;
|
|
859
|
+
}
|
|
860
|
+
y2 += D.length, A += w;
|
|
861
|
+
}
|
|
862
|
+
I2 = B2 = 0;
|
|
863
|
+
}
|
|
864
|
+
if (m >= h) break;
|
|
865
|
+
if (at2.lastIndex = m, at2.test(t)) {
|
|
866
|
+
if (y2 = at2.lastIndex - m, w = y2 * p, A + w > S2 && (v = Math.min(v, m + Math.floor((S2 - A) / p))), A + w > i) {
|
|
867
|
+
f = true;
|
|
868
|
+
break;
|
|
869
|
+
}
|
|
870
|
+
A += w, I2 = $, B2 = m, m = $ = at2.lastIndex;
|
|
871
|
+
continue;
|
|
872
|
+
}
|
|
873
|
+
if (At2.lastIndex = m, At2.test(t)) {
|
|
874
|
+
if (A + u > S2 && (v = Math.min(v, m)), A + u > i) {
|
|
875
|
+
f = true;
|
|
876
|
+
break;
|
|
877
|
+
}
|
|
878
|
+
A += u, I2 = $, B2 = m, m = $ = At2.lastIndex;
|
|
879
|
+
continue;
|
|
880
|
+
}
|
|
881
|
+
if (it2.lastIndex = m, it2.test(t)) {
|
|
882
|
+
if (y2 = it2.lastIndex - m, w = y2 * l, A + w > S2 && (v = Math.min(v, m + Math.floor((S2 - A) / l))), A + w > i) {
|
|
883
|
+
f = true;
|
|
884
|
+
break;
|
|
885
|
+
}
|
|
886
|
+
A += w, I2 = $, B2 = m, m = $ = it2.lastIndex;
|
|
887
|
+
continue;
|
|
888
|
+
}
|
|
889
|
+
if (nt2.lastIndex = m, nt2.test(t)) {
|
|
890
|
+
if (y2 = nt2.lastIndex - m, w = y2 * n, A + w > S2 && (v = Math.min(v, m + Math.floor((S2 - A) / n))), A + w > i) {
|
|
891
|
+
f = true;
|
|
892
|
+
break;
|
|
893
|
+
}
|
|
894
|
+
A += w, I2 = $, B2 = m, m = $ = nt2.lastIndex;
|
|
895
|
+
continue;
|
|
896
|
+
}
|
|
897
|
+
if (wt.lastIndex = m, wt.test(t)) {
|
|
898
|
+
if (A + g > S2 && (v = Math.min(v, m)), A + g > i) {
|
|
899
|
+
f = true;
|
|
900
|
+
break;
|
|
901
|
+
}
|
|
902
|
+
A += g, I2 = $, B2 = m, m = $ = wt.lastIndex;
|
|
903
|
+
continue;
|
|
904
|
+
}
|
|
905
|
+
m += 1;
|
|
906
|
+
}
|
|
907
|
+
return { width: f ? S2 : A, index: f ? v : h, truncated: f, ellipsed: f && i >= o };
|
|
908
|
+
};
|
|
909
|
+
var Ee = { limit: 1 / 0, ellipsis: "", ellipsisWidth: 0 };
|
|
910
|
+
var M2 = (t, r = {}) => jt(t, Ee, r).width;
|
|
911
|
+
var ot2 = "\x1B";
|
|
912
|
+
var Gt = "\x9B";
|
|
913
|
+
var ve = 39;
|
|
914
|
+
var Ct2 = "\x07";
|
|
915
|
+
var kt2 = "[";
|
|
916
|
+
var Ae = "]";
|
|
917
|
+
var Vt2 = "m";
|
|
918
|
+
var St = `${Ae}8;;`;
|
|
919
|
+
var Ht = new RegExp(`(?:\\${kt2}(?<code>\\d+)m|\\${St}(?<uri>.*)${Ct2})`, "y");
|
|
920
|
+
var we = (t) => {
|
|
921
|
+
if (t >= 30 && t <= 37 || t >= 90 && t <= 97) return 39;
|
|
922
|
+
if (t >= 40 && t <= 47 || t >= 100 && t <= 107) return 49;
|
|
923
|
+
if (t === 1 || t === 2) return 22;
|
|
924
|
+
if (t === 3) return 23;
|
|
925
|
+
if (t === 4) return 24;
|
|
926
|
+
if (t === 7) return 27;
|
|
927
|
+
if (t === 8) return 28;
|
|
928
|
+
if (t === 9) return 29;
|
|
929
|
+
if (t === 0) return 0;
|
|
930
|
+
};
|
|
931
|
+
var Ut = (t) => `${ot2}${kt2}${t}${Vt2}`;
|
|
932
|
+
var Kt = (t) => `${ot2}${St}${t}${Ct2}`;
|
|
933
|
+
var Ce = (t) => t.map((r) => M2(r));
|
|
934
|
+
var It2 = (t, r, s) => {
|
|
935
|
+
const i = r[Symbol.iterator]();
|
|
936
|
+
let a = false, o = false, u = t.at(-1), l = u === void 0 ? 0 : M2(u), n = i.next(), c = i.next(), g = 0;
|
|
937
|
+
for (; !n.done; ) {
|
|
938
|
+
const F = n.value, p = M2(F);
|
|
939
|
+
l + p <= s ? t[t.length - 1] += F : (t.push(F), l = 0), (F === ot2 || F === Gt) && (a = true, o = r.startsWith(St, g + 1)), a ? o ? F === Ct2 && (a = false, o = false) : F === Vt2 && (a = false) : (l += p, l === s && !c.done && (t.push(""), l = 0)), n = c, c = i.next(), g += F.length;
|
|
940
|
+
}
|
|
941
|
+
u = t.at(-1), !l && u !== void 0 && u.length > 0 && t.length > 1 && (t[t.length - 2] += t.pop());
|
|
942
|
+
};
|
|
943
|
+
var Se = (t) => {
|
|
944
|
+
const r = t.split(" ");
|
|
945
|
+
let s = r.length;
|
|
946
|
+
for (; s > 0 && !(M2(r[s - 1]) > 0); ) s--;
|
|
947
|
+
return s === r.length ? t : r.slice(0, s).join(" ") + r.slice(s).join("");
|
|
948
|
+
};
|
|
949
|
+
var Ie = (t, r, s = {}) => {
|
|
950
|
+
if (s.trim !== false && t.trim() === "") return "";
|
|
951
|
+
let i = "", a, o;
|
|
952
|
+
const u = t.split(" "), l = Ce(u);
|
|
953
|
+
let n = [""];
|
|
954
|
+
for (const [$, m] of u.entries()) {
|
|
955
|
+
s.trim !== false && (n[n.length - 1] = (n.at(-1) ?? "").trimStart());
|
|
956
|
+
let h = M2(n.at(-1) ?? "");
|
|
957
|
+
if ($ !== 0 && (h >= r && (s.wordWrap === false || s.trim === false) && (n.push(""), h = 0), (h > 0 || s.trim === false) && (n[n.length - 1] += " ", h++)), s.hard && l[$] > r) {
|
|
958
|
+
const y2 = r - h, f = 1 + Math.floor((l[$] - y2 - 1) / r);
|
|
959
|
+
Math.floor((l[$] - 1) / r) < f && n.push(""), It2(n, m, r);
|
|
960
|
+
continue;
|
|
961
|
+
}
|
|
962
|
+
if (h + l[$] > r && h > 0 && l[$] > 0) {
|
|
963
|
+
if (s.wordWrap === false && h < r) {
|
|
964
|
+
It2(n, m, r);
|
|
965
|
+
continue;
|
|
966
|
+
}
|
|
967
|
+
n.push("");
|
|
968
|
+
}
|
|
969
|
+
if (h + l[$] > r && s.wordWrap === false) {
|
|
970
|
+
It2(n, m, r);
|
|
971
|
+
continue;
|
|
972
|
+
}
|
|
973
|
+
n[n.length - 1] += m;
|
|
974
|
+
}
|
|
975
|
+
s.trim !== false && (n = n.map(($) => Se($)));
|
|
976
|
+
const c = n.join(`
|
|
977
|
+
`), g = c[Symbol.iterator]();
|
|
978
|
+
let F = g.next(), p = g.next(), E = 0;
|
|
979
|
+
for (; !F.done; ) {
|
|
980
|
+
const $ = F.value, m = p.value;
|
|
981
|
+
if (i += $, $ === ot2 || $ === Gt) {
|
|
982
|
+
Ht.lastIndex = E + 1;
|
|
983
|
+
const f = Ht.exec(c)?.groups;
|
|
984
|
+
if (f?.code !== void 0) {
|
|
985
|
+
const v = Number.parseFloat(f.code);
|
|
986
|
+
a = v === ve ? void 0 : v;
|
|
987
|
+
} else f?.uri !== void 0 && (o = f.uri.length === 0 ? void 0 : f.uri);
|
|
988
|
+
}
|
|
989
|
+
const h = a ? we(a) : void 0;
|
|
990
|
+
m === `
|
|
991
|
+
` ? (o && (i += Kt("")), a && h && (i += Ut(h))) : $ === `
|
|
992
|
+
` && (a && h && (i += Ut(a)), o && (i += Kt(o))), E += $.length, F = p, p = g.next();
|
|
993
|
+
}
|
|
994
|
+
return i;
|
|
995
|
+
};
|
|
996
|
+
function J2(t, r, s) {
|
|
997
|
+
return String(t).normalize().replaceAll(`\r
|
|
998
|
+
`, `
|
|
999
|
+
`).split(`
|
|
1000
|
+
`).map((i) => Ie(i, r, s)).join(`
|
|
1001
|
+
`);
|
|
1002
|
+
}
|
|
1003
|
+
var be = (t, r, s, i, a) => {
|
|
1004
|
+
let o = r, u = 0;
|
|
1005
|
+
for (let l = s; l < i; l++) {
|
|
1006
|
+
const n = t[l];
|
|
1007
|
+
if (o = o - n.length, u++, o <= a) break;
|
|
1008
|
+
}
|
|
1009
|
+
return { lineCount: o, removals: u };
|
|
1010
|
+
};
|
|
1011
|
+
var X2 = (t) => {
|
|
1012
|
+
const { cursor: r, options: s, style: i } = t, a = t.output ?? process.stdout, o = rt(a), u = t.columnPadding ?? 0, l = t.rowPadding ?? 4, n = o - u, c = nt(a), g = import_picocolors.default.dim("..."), F = t.maxItems ?? Number.POSITIVE_INFINITY, p = Math.max(c - l, 0), E = Math.max(Math.min(F, p), 5);
|
|
1013
|
+
let $ = 0;
|
|
1014
|
+
r >= E - 3 && ($ = Math.max(Math.min(r - E + 3, s.length - E), 0));
|
|
1015
|
+
let m = E < s.length && $ > 0, h = E < s.length && $ + E < s.length;
|
|
1016
|
+
const y2 = Math.min($ + E, s.length), f = [];
|
|
1017
|
+
let v = 0;
|
|
1018
|
+
m && v++, h && v++;
|
|
1019
|
+
const S2 = $ + (m ? 1 : 0), I2 = y2 - (h ? 1 : 0);
|
|
1020
|
+
for (let A = S2; A < I2; A++) {
|
|
1021
|
+
const w = J2(i(s[A], A === r), n, { hard: true, trim: false }).split(`
|
|
1022
|
+
`);
|
|
1023
|
+
f.push(w), v += w.length;
|
|
1024
|
+
}
|
|
1025
|
+
if (v > p) {
|
|
1026
|
+
let A = 0, w = 0, _2 = v;
|
|
1027
|
+
const D = r - S2, T2 = (Y, L2) => be(f, _2, Y, L2, p);
|
|
1028
|
+
m ? ({ lineCount: _2, removals: A } = T2(0, D), _2 > p && ({ lineCount: _2, removals: w } = T2(D + 1, f.length))) : ({ lineCount: _2, removals: w } = T2(D + 1, f.length), _2 > p && ({ lineCount: _2, removals: A } = T2(0, D))), A > 0 && (m = true, f.splice(0, A)), w > 0 && (h = true, f.splice(f.length - w, w));
|
|
1029
|
+
}
|
|
1030
|
+
const B2 = [];
|
|
1031
|
+
m && B2.push(g);
|
|
1032
|
+
for (const A of f) for (const w of A) B2.push(w);
|
|
1033
|
+
return h && B2.push(g), B2;
|
|
1034
|
+
};
|
|
1035
|
+
var R2 = { message: (t = [], { symbol: r = import_picocolors.default.gray(d), secondarySymbol: s = import_picocolors.default.gray(d), output: i = process.stdout, spacing: a = 1, withGuide: o } = {}) => {
|
|
1036
|
+
const u = [], l = o ?? _.withGuide, n = l ? s : "", c = l ? `${r} ` : "", g = l ? `${s} ` : "";
|
|
1037
|
+
for (let p = 0; p < a; p++) u.push(n);
|
|
1038
|
+
const F = Array.isArray(t) ? t : t.split(`
|
|
1039
|
+
`);
|
|
1040
|
+
if (F.length > 0) {
|
|
1041
|
+
const [p, ...E] = F;
|
|
1042
|
+
p.length > 0 ? u.push(`${c}${p}`) : u.push(l ? r : "");
|
|
1043
|
+
for (const $ of E) $.length > 0 ? u.push(`${g}${$}`) : u.push(l ? s : "");
|
|
1044
|
+
}
|
|
1045
|
+
i.write(`${u.join(`
|
|
1046
|
+
`)}
|
|
1047
|
+
`);
|
|
1048
|
+
}, info: (t, r) => {
|
|
1049
|
+
R2.message(t, { ...r, symbol: import_picocolors.default.blue(ft2) });
|
|
1050
|
+
}, success: (t, r) => {
|
|
1051
|
+
R2.message(t, { ...r, symbol: import_picocolors.default.green(Ft2) });
|
|
1052
|
+
}, step: (t, r) => {
|
|
1053
|
+
R2.message(t, { ...r, symbol: import_picocolors.default.green(V) });
|
|
1054
|
+
}, warn: (t, r) => {
|
|
1055
|
+
R2.message(t, { ...r, symbol: import_picocolors.default.yellow(yt2) });
|
|
1056
|
+
}, warning: (t, r) => {
|
|
1057
|
+
R2.warn(t, r);
|
|
1058
|
+
}, error: (t, r) => {
|
|
1059
|
+
R2.message(t, { ...r, symbol: import_picocolors.default.red(Et2) });
|
|
1060
|
+
} };
|
|
1061
|
+
var Ne = (t = "", r) => {
|
|
1062
|
+
(r?.output ?? process.stdout).write(`${import_picocolors.default.gray(x2)} ${import_picocolors.default.red(t)}
|
|
1063
|
+
|
|
1064
|
+
`);
|
|
1065
|
+
};
|
|
1066
|
+
var We = (t = "", r) => {
|
|
1067
|
+
(r?.output ?? process.stdout).write(`${import_picocolors.default.gray(ht2)} ${t}
|
|
1068
|
+
`);
|
|
1069
|
+
};
|
|
1070
|
+
var Le = (t = "", r) => {
|
|
1071
|
+
(r?.output ?? process.stdout).write(`${import_picocolors.default.gray(d)}
|
|
1072
|
+
${import_picocolors.default.gray(x2)} ${t}
|
|
1073
|
+
|
|
1074
|
+
`);
|
|
1075
|
+
};
|
|
1076
|
+
var Z2 = (t, r) => t.split(`
|
|
1077
|
+
`).map((s) => r(s)).join(`
|
|
1078
|
+
`);
|
|
1079
|
+
var je = (t) => {
|
|
1080
|
+
const r = (i, a) => {
|
|
1081
|
+
const o = i.label ?? String(i.value);
|
|
1082
|
+
return a === "disabled" ? `${import_picocolors.default.gray(q2)} ${Z2(o, (u) => import_picocolors.default.strikethrough(import_picocolors.default.gray(u)))}${i.hint ? ` ${import_picocolors.default.dim(`(${i.hint ?? "disabled"})`)}` : ""}` : a === "active" ? `${import_picocolors.default.cyan(st2)} ${o}${i.hint ? ` ${import_picocolors.default.dim(`(${i.hint})`)}` : ""}` : a === "selected" ? `${import_picocolors.default.green(U2)} ${Z2(o, import_picocolors.default.dim)}${i.hint ? ` ${import_picocolors.default.dim(`(${i.hint})`)}` : ""}` : a === "cancelled" ? `${Z2(o, (u) => import_picocolors.default.strikethrough(import_picocolors.default.dim(u)))}` : a === "active-selected" ? `${import_picocolors.default.green(U2)} ${o}${i.hint ? ` ${import_picocolors.default.dim(`(${i.hint})`)}` : ""}` : a === "submitted" ? `${Z2(o, import_picocolors.default.dim)}` : `${import_picocolors.default.dim(q2)} ${Z2(o, import_picocolors.default.dim)}`;
|
|
1083
|
+
}, s = t.required ?? true;
|
|
1084
|
+
return new Lt({ options: t.options, signal: t.signal, input: t.input, output: t.output, initialValues: t.initialValues, required: s, cursorAt: t.cursorAt, validate(i) {
|
|
1085
|
+
if (s && (i === void 0 || i.length === 0)) return `Please select at least one option.
|
|
1086
|
+
${import_picocolors.default.reset(import_picocolors.default.dim(`Press ${import_picocolors.default.gray(import_picocolors.default.bgWhite(import_picocolors.default.inverse(" space ")))} to select, ${import_picocolors.default.gray(import_picocolors.default.bgWhite(import_picocolors.default.inverse(" enter ")))} to submit`))}`;
|
|
1087
|
+
}, render() {
|
|
1088
|
+
const i = xt(t.output, t.message, `${vt2(this.state)} `, `${W2(this.state)} `), a = `${import_picocolors.default.gray(d)}
|
|
1089
|
+
${i}
|
|
1090
|
+
`, o = this.value ?? [], u = (l, n) => {
|
|
1091
|
+
if (l.disabled) return r(l, "disabled");
|
|
1092
|
+
const c = o.includes(l.value);
|
|
1093
|
+
return n && c ? r(l, "active-selected") : c ? r(l, "selected") : r(l, n ? "active" : "inactive");
|
|
1094
|
+
};
|
|
1095
|
+
switch (this.state) {
|
|
1096
|
+
case "submit": {
|
|
1097
|
+
const l = this.options.filter(({ value: c }) => o.includes(c)).map((c) => r(c, "submitted")).join(import_picocolors.default.dim(", ")) || import_picocolors.default.dim("none"), n = xt(t.output, l, `${import_picocolors.default.gray(d)} `);
|
|
1098
|
+
return `${a}${n}`;
|
|
1099
|
+
}
|
|
1100
|
+
case "cancel": {
|
|
1101
|
+
const l = this.options.filter(({ value: c }) => o.includes(c)).map((c) => r(c, "cancelled")).join(import_picocolors.default.dim(", "));
|
|
1102
|
+
if (l.trim() === "") return `${a}${import_picocolors.default.gray(d)}`;
|
|
1103
|
+
const n = xt(t.output, l, `${import_picocolors.default.gray(d)} `);
|
|
1104
|
+
return `${a}${n}
|
|
1105
|
+
${import_picocolors.default.gray(d)}`;
|
|
1106
|
+
}
|
|
1107
|
+
case "error": {
|
|
1108
|
+
const l = `${import_picocolors.default.yellow(d)} `, n = this.error.split(`
|
|
1109
|
+
`).map((F, p) => p === 0 ? `${import_picocolors.default.yellow(x2)} ${import_picocolors.default.yellow(F)}` : ` ${F}`).join(`
|
|
1110
|
+
`), c = a.split(`
|
|
1111
|
+
`).length, g = n.split(`
|
|
1112
|
+
`).length + 1;
|
|
1113
|
+
return `${a}${l}${X2({ output: t.output, options: this.options, cursor: this.cursor, maxItems: t.maxItems, columnPadding: l.length, rowPadding: c + g, style: u }).join(`
|
|
1114
|
+
${l}`)}
|
|
1115
|
+
${n}
|
|
1116
|
+
`;
|
|
1117
|
+
}
|
|
1118
|
+
default: {
|
|
1119
|
+
const l = `${import_picocolors.default.cyan(d)} `, n = a.split(`
|
|
1120
|
+
`).length;
|
|
1121
|
+
return `${a}${l}${X2({ output: t.output, options: this.options, cursor: this.cursor, maxItems: t.maxItems, columnPadding: l.length, rowPadding: n + 2, style: u }).join(`
|
|
1122
|
+
${l}`)}
|
|
1123
|
+
${import_picocolors.default.cyan(x2)}
|
|
1124
|
+
`;
|
|
1125
|
+
}
|
|
1126
|
+
}
|
|
1127
|
+
} }).prompt();
|
|
1128
|
+
};
|
|
1129
|
+
var Ke = import_picocolors.default.magenta;
|
|
1130
|
+
var bt2 = ({ indicator: t = "dots", onCancel: r, output: s = process.stdout, cancelMessage: i, errorMessage: a, frames: o = et2 ? ["\u25D2", "\u25D0", "\u25D3", "\u25D1"] : ["\u2022", "o", "O", "0"], delay: u = et2 ? 80 : 120, signal: l, ...n } = {}) => {
|
|
1131
|
+
const c = ct2();
|
|
1132
|
+
let g, F, p = false, E = false, $ = "", m, h = performance.now();
|
|
1133
|
+
const y2 = rt(s), f = n?.styleFrame ?? Ke, v = (b) => {
|
|
1134
|
+
const O2 = b > 1 ? a ?? _.messages.error : i ?? _.messages.cancel;
|
|
1135
|
+
E = b === 1, p && (L2(O2, b), E && typeof r == "function" && r());
|
|
1136
|
+
}, S2 = () => v(2), I2 = () => v(1), B2 = () => {
|
|
1137
|
+
process.on("uncaughtExceptionMonitor", S2), process.on("unhandledRejection", S2), process.on("SIGINT", I2), process.on("SIGTERM", I2), process.on("exit", v), l && l.addEventListener("abort", I2);
|
|
1138
|
+
}, A = () => {
|
|
1139
|
+
process.removeListener("uncaughtExceptionMonitor", S2), process.removeListener("unhandledRejection", S2), process.removeListener("SIGINT", I2), process.removeListener("SIGTERM", I2), process.removeListener("exit", v), l && l.removeEventListener("abort", I2);
|
|
1140
|
+
}, w = () => {
|
|
1141
|
+
if (m === void 0) return;
|
|
1142
|
+
c && s.write(`
|
|
1143
|
+
`);
|
|
1144
|
+
const b = J2(m, y2, { hard: true, trim: false }).split(`
|
|
1145
|
+
`);
|
|
1146
|
+
b.length > 1 && s.write(import_sisteransi2.cursor.up(b.length - 1)), s.write(import_sisteransi2.cursor.to(0)), s.write(import_sisteransi2.erase.down());
|
|
1147
|
+
}, _2 = (b) => b.replace(/\.+$/, ""), D = (b) => {
|
|
1148
|
+
const O2 = (performance.now() - b) / 1e3, j2 = Math.floor(O2 / 60), G2 = Math.floor(O2 % 60);
|
|
1149
|
+
return j2 > 0 ? `[${j2}m ${G2}s]` : `[${G2}s]`;
|
|
1150
|
+
}, T2 = n.withGuide ?? _.withGuide, Y = (b = "") => {
|
|
1151
|
+
p = true, g = Bt({ output: s }), $ = _2(b), h = performance.now(), T2 && s.write(`${import_picocolors.default.gray(d)}
|
|
1152
|
+
`);
|
|
1153
|
+
let O2 = 0, j2 = 0;
|
|
1154
|
+
B2(), F = setInterval(() => {
|
|
1155
|
+
if (c && $ === m) return;
|
|
1156
|
+
w(), m = $;
|
|
1157
|
+
const G2 = f(o[O2]);
|
|
1158
|
+
let tt2;
|
|
1159
|
+
if (c) tt2 = `${G2} ${$}...`;
|
|
1160
|
+
else if (t === "timer") tt2 = `${G2} ${$} ${D(h)}`;
|
|
1161
|
+
else {
|
|
1162
|
+
const te = ".".repeat(Math.floor(j2)).slice(0, 3);
|
|
1163
|
+
tt2 = `${G2} ${$}${te}`;
|
|
1164
|
+
}
|
|
1165
|
+
const Zt = J2(tt2, y2, { hard: true, trim: false });
|
|
1166
|
+
s.write(Zt), O2 = O2 + 1 < o.length ? O2 + 1 : 0, j2 = j2 < 4 ? j2 + 0.125 : 0;
|
|
1167
|
+
}, u);
|
|
1168
|
+
}, L2 = (b = "", O2 = 0, j2 = false) => {
|
|
1169
|
+
if (!p) return;
|
|
1170
|
+
p = false, clearInterval(F), w();
|
|
1171
|
+
const G2 = O2 === 0 ? import_picocolors.default.green(V) : O2 === 1 ? import_picocolors.default.red(dt2) : import_picocolors.default.red($t2);
|
|
1172
|
+
$ = b ?? $, j2 || (t === "timer" ? s.write(`${G2} ${$} ${D(h)}
|
|
1173
|
+
`) : s.write(`${G2} ${$}
|
|
1174
|
+
`)), A(), g();
|
|
1175
|
+
};
|
|
1176
|
+
return { start: Y, stop: (b = "") => L2(b, 0), message: (b = "") => {
|
|
1177
|
+
$ = _2(b ?? $);
|
|
1178
|
+
}, cancel: (b = "") => L2(b, 1), error: (b = "") => L2(b, 2), clear: () => L2("", 0, true), get isCancelled() {
|
|
1179
|
+
return E;
|
|
1180
|
+
} };
|
|
1181
|
+
};
|
|
1182
|
+
var zt = { light: C("\u2500", "-"), heavy: C("\u2501", "="), block: C("\u2588", "#") };
|
|
1183
|
+
var lt2 = (t, r) => t.includes(`
|
|
1184
|
+
`) ? t.split(`
|
|
1185
|
+
`).map((s) => r(s)).join(`
|
|
1186
|
+
`) : r(t);
|
|
1187
|
+
var Je = (t) => {
|
|
1188
|
+
const r = (s, i) => {
|
|
1189
|
+
const a = s.label ?? String(s.value);
|
|
1190
|
+
switch (i) {
|
|
1191
|
+
case "disabled":
|
|
1192
|
+
return `${import_picocolors.default.gray(H2)} ${lt2(a, import_picocolors.default.gray)}${s.hint ? ` ${import_picocolors.default.dim(`(${s.hint ?? "disabled"})`)}` : ""}`;
|
|
1193
|
+
case "selected":
|
|
1194
|
+
return `${lt2(a, import_picocolors.default.dim)}`;
|
|
1195
|
+
case "active":
|
|
1196
|
+
return `${import_picocolors.default.green(Q2)} ${a}${s.hint ? ` ${import_picocolors.default.dim(`(${s.hint})`)}` : ""}`;
|
|
1197
|
+
case "cancelled":
|
|
1198
|
+
return `${lt2(a, (o) => import_picocolors.default.strikethrough(import_picocolors.default.dim(o)))}`;
|
|
1199
|
+
default:
|
|
1200
|
+
return `${import_picocolors.default.dim(H2)} ${lt2(a, import_picocolors.default.dim)}`;
|
|
1201
|
+
}
|
|
1202
|
+
};
|
|
1203
|
+
return new Wt({ options: t.options, signal: t.signal, input: t.input, output: t.output, initialValue: t.initialValue, render() {
|
|
1204
|
+
const s = t.withGuide ?? _.withGuide, i = `${W2(this.state)} `, a = `${vt2(this.state)} `, o = xt(t.output, t.message, a, i), u = `${s ? `${import_picocolors.default.gray(d)}
|
|
1205
|
+
` : ""}${o}
|
|
1206
|
+
`;
|
|
1207
|
+
switch (this.state) {
|
|
1208
|
+
case "submit": {
|
|
1209
|
+
const l = s ? `${import_picocolors.default.gray(d)} ` : "", n = xt(t.output, r(this.options[this.cursor], "selected"), l);
|
|
1210
|
+
return `${u}${n}`;
|
|
1211
|
+
}
|
|
1212
|
+
case "cancel": {
|
|
1213
|
+
const l = s ? `${import_picocolors.default.gray(d)} ` : "", n = xt(t.output, r(this.options[this.cursor], "cancelled"), l);
|
|
1214
|
+
return `${u}${n}${s ? `
|
|
1215
|
+
${import_picocolors.default.gray(d)}` : ""}`;
|
|
1216
|
+
}
|
|
1217
|
+
default: {
|
|
1218
|
+
const l = s ? `${import_picocolors.default.cyan(d)} ` : "", n = s ? import_picocolors.default.cyan(x2) : "", c = u.split(`
|
|
1219
|
+
`).length, g = s ? 2 : 1;
|
|
1220
|
+
return `${u}${l}${X2({ output: t.output, cursor: this.cursor, options: this.options, maxItems: t.maxItems, columnPadding: l.length, rowPadding: c + g, style: (F, p) => r(F, F.disabled ? "disabled" : p ? "active" : "inactive") }).join(`
|
|
1221
|
+
${l}`)}
|
|
1222
|
+
${n}
|
|
1223
|
+
`;
|
|
1224
|
+
}
|
|
1225
|
+
}
|
|
1226
|
+
} }).prompt();
|
|
1227
|
+
};
|
|
1228
|
+
var Qt = `${import_picocolors.default.gray(d)} `;
|
|
1229
|
+
|
|
1230
|
+
// src/lib/cache.ts
|
|
1231
|
+
import {
|
|
1232
|
+
existsSync as existsSync11,
|
|
1233
|
+
mkdirSync as mkdirSync10,
|
|
1234
|
+
readFileSync as readFileSync4,
|
|
1235
|
+
readdirSync,
|
|
1236
|
+
writeFileSync as writeFileSync9,
|
|
1237
|
+
rmSync as rmSync4
|
|
1238
|
+
} from "fs";
|
|
1239
|
+
import { join as join10, resolve as resolve2 } from "path";
|
|
1240
|
+
import { homedir as homedir7 } from "os";
|
|
1241
|
+
|
|
1242
|
+
// src/lib/installers/cursor.ts
|
|
1243
|
+
import { existsSync as existsSync3, mkdirSync as mkdirSync3, writeFileSync as writeFileSync2, unlinkSync as unlinkSync2 } from "fs";
|
|
1244
|
+
import { join as join2 } from "path";
|
|
1245
|
+
import { homedir as homedir2 } from "os";
|
|
1246
|
+
|
|
1247
|
+
// src/lib/content-transform.ts
|
|
1248
|
+
function yamlEscape(value) {
|
|
1249
|
+
if (value.includes(":") || value.includes("#") || value.includes('"') || value.includes("'") || value.startsWith("{") || value.startsWith("[")) {
|
|
1250
|
+
return `"${value.replace(/\\/g, "\\\\").replace(/"/g, '\\"')}"`;
|
|
1251
|
+
}
|
|
1252
|
+
return value;
|
|
1253
|
+
}
|
|
1254
|
+
function toCursorMDC(content, skill) {
|
|
1255
|
+
return [
|
|
1256
|
+
"---",
|
|
1257
|
+
`description: ${yamlEscape(skill.description || skill.name)}`,
|
|
1258
|
+
"globs:",
|
|
1259
|
+
"alwaysApply: true",
|
|
1260
|
+
"---",
|
|
1261
|
+
"",
|
|
1262
|
+
content
|
|
1263
|
+
].join("\n");
|
|
1264
|
+
}
|
|
1265
|
+
function toClaudeMD(content, skill) {
|
|
1266
|
+
return [
|
|
1267
|
+
"---",
|
|
1268
|
+
`name: ${yamlEscape(skill.name)}`,
|
|
1269
|
+
`description: ${yamlEscape(skill.description || skill.name)}`,
|
|
1270
|
+
"---",
|
|
1271
|
+
"",
|
|
1272
|
+
content
|
|
1273
|
+
].join("\n");
|
|
1274
|
+
}
|
|
1275
|
+
function toPlainMD(content) {
|
|
1276
|
+
return content;
|
|
1277
|
+
}
|
|
1278
|
+
|
|
1279
|
+
// src/lib/symlink.ts
|
|
1280
|
+
import {
|
|
1281
|
+
symlinkSync,
|
|
1282
|
+
readlinkSync,
|
|
1283
|
+
unlinkSync,
|
|
1284
|
+
lstatSync,
|
|
1285
|
+
existsSync as existsSync2,
|
|
1286
|
+
mkdirSync as mkdirSync2,
|
|
1287
|
+
rmSync
|
|
1288
|
+
} from "fs";
|
|
1289
|
+
import { dirname, resolve } from "path";
|
|
1290
|
+
function createSymlink(targetPath, linkPath) {
|
|
1291
|
+
const absTarget = resolve(targetPath);
|
|
1292
|
+
const absLink = resolve(linkPath);
|
|
1293
|
+
mkdirSync2(dirname(absLink), { recursive: true });
|
|
1294
|
+
if (existsSync2(absLink) || isSymlink(absLink)) {
|
|
1295
|
+
rmSync(absLink, { recursive: true, force: true });
|
|
1296
|
+
}
|
|
1297
|
+
symlinkSync(absTarget, absLink);
|
|
1298
|
+
}
|
|
1299
|
+
function removeSymlink(linkPath) {
|
|
1300
|
+
try {
|
|
1301
|
+
const stat = lstatSync(linkPath);
|
|
1302
|
+
if (stat.isSymbolicLink()) {
|
|
1303
|
+
unlinkSync(linkPath);
|
|
1304
|
+
return true;
|
|
1305
|
+
}
|
|
1306
|
+
return false;
|
|
1307
|
+
} catch {
|
|
1308
|
+
return false;
|
|
1309
|
+
}
|
|
1310
|
+
}
|
|
1311
|
+
function isSymlink(path) {
|
|
1312
|
+
try {
|
|
1313
|
+
return lstatSync(path).isSymbolicLink();
|
|
1314
|
+
} catch {
|
|
1315
|
+
return false;
|
|
1316
|
+
}
|
|
1317
|
+
}
|
|
1318
|
+
|
|
1319
|
+
// src/lib/installers/cursor.ts
|
|
1320
|
+
var descriptor = {
|
|
1321
|
+
id: "cursor",
|
|
1322
|
+
name: "Cursor",
|
|
1323
|
+
supportsGlobal: true,
|
|
1324
|
+
supportsProject: true,
|
|
1325
|
+
fileStrategy: "directory",
|
|
1326
|
+
fileExtension: ".mdc"
|
|
1327
|
+
};
|
|
1328
|
+
function detect(projectDir) {
|
|
1329
|
+
const home = homedir2();
|
|
1330
|
+
const cwd = projectDir || process.cwd();
|
|
1331
|
+
return {
|
|
1332
|
+
global: existsSync3(join2(home, ".cursor")),
|
|
1333
|
+
project: existsSync3(join2(cwd, ".cursor"))
|
|
1334
|
+
};
|
|
1335
|
+
}
|
|
1336
|
+
function resolvePath(slug, scope, projectDir) {
|
|
1337
|
+
const safeName = slug.replace(/\//g, "-");
|
|
1338
|
+
if (scope === "global") {
|
|
1339
|
+
return join2(homedir2(), ".cursor", "rules", `${safeName}.mdc`);
|
|
1340
|
+
}
|
|
1341
|
+
const dir = projectDir || process.cwd();
|
|
1342
|
+
return join2(dir, ".cursor", "rules", `${safeName}.mdc`);
|
|
1343
|
+
}
|
|
1344
|
+
function transformContent(content, skill) {
|
|
1345
|
+
return toCursorMDC(content, skill);
|
|
1346
|
+
}
|
|
1347
|
+
function install(opts) {
|
|
1348
|
+
const targetPath = resolvePath(opts.slug, opts.scope, opts.projectDir);
|
|
1349
|
+
if (opts.method === "symlink") {
|
|
1350
|
+
createSymlink(opts.cachePath, targetPath);
|
|
1351
|
+
} else {
|
|
1352
|
+
mkdirSync3(join2(targetPath, ".."), { recursive: true });
|
|
1353
|
+
writeFileSync2(targetPath, opts.content);
|
|
1354
|
+
}
|
|
1355
|
+
return targetPath;
|
|
1356
|
+
}
|
|
1357
|
+
function uninstall(installation, _slug) {
|
|
1358
|
+
if (installation.method === "symlink") {
|
|
1359
|
+
removeSymlink(installation.path);
|
|
1360
|
+
} else if (existsSync3(installation.path)) {
|
|
1361
|
+
unlinkSync2(installation.path);
|
|
1362
|
+
}
|
|
1363
|
+
}
|
|
1364
|
+
function defaultMethod() {
|
|
1365
|
+
return "symlink";
|
|
1366
|
+
}
|
|
1367
|
+
var cursorAdapter = {
|
|
1368
|
+
descriptor,
|
|
1369
|
+
detect,
|
|
1370
|
+
resolvePath,
|
|
1371
|
+
transformContent,
|
|
1372
|
+
install,
|
|
1373
|
+
uninstall,
|
|
1374
|
+
defaultMethod
|
|
1375
|
+
};
|
|
1376
|
+
|
|
1377
|
+
// src/lib/installers/claude.ts
|
|
1378
|
+
import { existsSync as existsSync4, mkdirSync as mkdirSync4, writeFileSync as writeFileSync3, unlinkSync as unlinkSync3, rmSync as rmSync3 } from "fs";
|
|
1379
|
+
import { join as join3 } from "path";
|
|
1380
|
+
import { homedir as homedir3 } from "os";
|
|
1381
|
+
var descriptor2 = {
|
|
1382
|
+
id: "claude",
|
|
1383
|
+
name: "Claude Code",
|
|
1384
|
+
supportsGlobal: true,
|
|
1385
|
+
supportsProject: true,
|
|
1386
|
+
fileStrategy: "directory",
|
|
1387
|
+
fileExtension: ".md"
|
|
1388
|
+
};
|
|
1389
|
+
function detect2(projectDir) {
|
|
1390
|
+
const home = homedir3();
|
|
1391
|
+
const cwd = projectDir || process.cwd();
|
|
1392
|
+
return {
|
|
1393
|
+
global: existsSync4(join3(home, ".claude")),
|
|
1394
|
+
project: existsSync4(join3(cwd, ".claude"))
|
|
1395
|
+
};
|
|
1396
|
+
}
|
|
1397
|
+
function resolvePath2(slug, scope, projectDir) {
|
|
1398
|
+
const safeName = slug.replace(/\//g, "-");
|
|
1399
|
+
if (scope === "global") {
|
|
1400
|
+
return join3(homedir3(), ".claude", "skills", safeName, "SKILL.md");
|
|
1401
|
+
}
|
|
1402
|
+
const dir = projectDir || process.cwd();
|
|
1403
|
+
return join3(dir, ".claude", "skills", safeName, "SKILL.md");
|
|
1404
|
+
}
|
|
1405
|
+
function transformContent2(content, skill) {
|
|
1406
|
+
return toClaudeMD(content, skill);
|
|
1407
|
+
}
|
|
1408
|
+
function install2(opts) {
|
|
1409
|
+
const targetPath = resolvePath2(opts.slug, opts.scope, opts.projectDir);
|
|
1410
|
+
const targetDir = join3(targetPath, "..");
|
|
1411
|
+
if (opts.method === "symlink") {
|
|
1412
|
+
createSymlink(opts.cachePath, targetPath);
|
|
1413
|
+
} else {
|
|
1414
|
+
mkdirSync4(targetDir, { recursive: true });
|
|
1415
|
+
writeFileSync3(targetPath, opts.content);
|
|
1416
|
+
}
|
|
1417
|
+
return targetPath;
|
|
1418
|
+
}
|
|
1419
|
+
function uninstall2(installation, _slug) {
|
|
1420
|
+
if (installation.method === "symlink") {
|
|
1421
|
+
removeSymlink(installation.path);
|
|
1422
|
+
} else if (existsSync4(installation.path)) {
|
|
1423
|
+
unlinkSync3(installation.path);
|
|
1424
|
+
}
|
|
1425
|
+
const parentDir = join3(installation.path, "..");
|
|
1426
|
+
try {
|
|
1427
|
+
const { readdirSync: readdirSync2 } = __require("fs");
|
|
1428
|
+
if (existsSync4(parentDir) && readdirSync2(parentDir).length === 0) {
|
|
1429
|
+
rmSync3(parentDir, { recursive: true });
|
|
1430
|
+
}
|
|
1431
|
+
} catch {
|
|
1432
|
+
}
|
|
1433
|
+
}
|
|
1434
|
+
function defaultMethod2() {
|
|
1435
|
+
return "symlink";
|
|
1436
|
+
}
|
|
1437
|
+
var claudeAdapter = {
|
|
1438
|
+
descriptor: descriptor2,
|
|
1439
|
+
detect: detect2,
|
|
1440
|
+
resolvePath: resolvePath2,
|
|
1441
|
+
transformContent: transformContent2,
|
|
1442
|
+
install: install2,
|
|
1443
|
+
uninstall: uninstall2,
|
|
1444
|
+
defaultMethod: defaultMethod2
|
|
1445
|
+
};
|
|
1446
|
+
|
|
1447
|
+
// src/lib/installers/codex.ts
|
|
1448
|
+
import { join as join4 } from "path";
|
|
1449
|
+
import { homedir as homedir4 } from "os";
|
|
1450
|
+
import { execSync } from "child_process";
|
|
1451
|
+
|
|
1452
|
+
// src/lib/marked-sections.ts
|
|
1453
|
+
import { existsSync as existsSync5, readFileSync as readFileSync2, writeFileSync as writeFileSync4, mkdirSync as mkdirSync5 } from "fs";
|
|
1454
|
+
import { dirname as dirname2 } from "path";
|
|
1455
|
+
var START_MARKER = (slug) => `<!-- localskills:start:${slug} -->`;
|
|
1456
|
+
var END_MARKER = (slug) => `<!-- localskills:end:${slug} -->`;
|
|
1457
|
+
function upsertSection(filePath, slug, content) {
|
|
1458
|
+
mkdirSync5(dirname2(filePath), { recursive: true });
|
|
1459
|
+
let existing = "";
|
|
1460
|
+
if (existsSync5(filePath)) {
|
|
1461
|
+
existing = readFileSync2(filePath, "utf-8");
|
|
1462
|
+
}
|
|
1463
|
+
const start = START_MARKER(slug);
|
|
1464
|
+
const end = END_MARKER(slug);
|
|
1465
|
+
const section = `${start}
|
|
1466
|
+
${content}
|
|
1467
|
+
${end}`;
|
|
1468
|
+
const startIdx = existing.indexOf(start);
|
|
1469
|
+
const endIdx = existing.indexOf(end);
|
|
1470
|
+
let result;
|
|
1471
|
+
if (startIdx !== -1 && endIdx !== -1) {
|
|
1472
|
+
result = existing.slice(0, startIdx) + section + existing.slice(endIdx + end.length);
|
|
1473
|
+
} else {
|
|
1474
|
+
const separator = existing.length > 0 && !existing.endsWith("\n\n") ? "\n\n" : "";
|
|
1475
|
+
result = existing + separator + section + "\n";
|
|
1476
|
+
}
|
|
1477
|
+
writeFileSync4(filePath, result);
|
|
1478
|
+
}
|
|
1479
|
+
function removeSection(filePath, slug) {
|
|
1480
|
+
if (!existsSync5(filePath)) return false;
|
|
1481
|
+
const existing = readFileSync2(filePath, "utf-8");
|
|
1482
|
+
const start = START_MARKER(slug);
|
|
1483
|
+
const end = END_MARKER(slug);
|
|
1484
|
+
const startIdx = existing.indexOf(start);
|
|
1485
|
+
const endIdx = existing.indexOf(end);
|
|
1486
|
+
if (startIdx === -1 || endIdx === -1) return false;
|
|
1487
|
+
let before = existing.slice(0, startIdx);
|
|
1488
|
+
let after = existing.slice(endIdx + end.length);
|
|
1489
|
+
while (before.endsWith("\n\n")) before = before.slice(0, -1);
|
|
1490
|
+
while (after.startsWith("\n\n")) after = after.slice(1);
|
|
1491
|
+
const result = (before + after).trim();
|
|
1492
|
+
writeFileSync4(filePath, result ? result + "\n" : "");
|
|
1493
|
+
return true;
|
|
1494
|
+
}
|
|
1495
|
+
|
|
1496
|
+
// src/lib/installers/codex.ts
|
|
1497
|
+
var descriptor3 = {
|
|
1498
|
+
id: "codex",
|
|
1499
|
+
name: "Codex CLI",
|
|
1500
|
+
supportsGlobal: true,
|
|
1501
|
+
supportsProject: true,
|
|
1502
|
+
fileStrategy: "single-file",
|
|
1503
|
+
fileExtension: ".md"
|
|
1504
|
+
};
|
|
1505
|
+
function detect3() {
|
|
1506
|
+
let hasCommand = false;
|
|
1507
|
+
try {
|
|
1508
|
+
execSync("which codex", { stdio: "ignore" });
|
|
1509
|
+
hasCommand = true;
|
|
1510
|
+
} catch {
|
|
1511
|
+
}
|
|
1512
|
+
return { global: hasCommand, project: hasCommand };
|
|
1513
|
+
}
|
|
1514
|
+
function resolvePath3(slug, scope, projectDir) {
|
|
1515
|
+
if (scope === "global") {
|
|
1516
|
+
return join4(homedir4(), ".codex", "AGENTS.md");
|
|
1517
|
+
}
|
|
1518
|
+
return join4(projectDir || process.cwd(), "AGENTS.md");
|
|
1519
|
+
}
|
|
1520
|
+
function transformContent3(content) {
|
|
1521
|
+
return toPlainMD(content);
|
|
1522
|
+
}
|
|
1523
|
+
function install3(opts) {
|
|
1524
|
+
const filePath = resolvePath3(opts.slug, opts.scope, opts.projectDir);
|
|
1525
|
+
upsertSection(filePath, opts.slug, `## ${opts.slug}
|
|
1526
|
+
|
|
1527
|
+
${opts.content}`);
|
|
1528
|
+
return filePath;
|
|
1529
|
+
}
|
|
1530
|
+
function uninstall3(installation, slug) {
|
|
1531
|
+
removeSection(installation.path, slug);
|
|
1532
|
+
}
|
|
1533
|
+
function defaultMethod3() {
|
|
1534
|
+
return "section";
|
|
1535
|
+
}
|
|
1536
|
+
var codexAdapter = {
|
|
1537
|
+
descriptor: descriptor3,
|
|
1538
|
+
detect: detect3,
|
|
1539
|
+
resolvePath: resolvePath3,
|
|
1540
|
+
transformContent: transformContent3,
|
|
1541
|
+
install: install3,
|
|
1542
|
+
uninstall: uninstall3,
|
|
1543
|
+
defaultMethod: defaultMethod3
|
|
1544
|
+
};
|
|
1545
|
+
|
|
1546
|
+
// src/lib/installers/windsurf.ts
|
|
1547
|
+
import { existsSync as existsSync6, mkdirSync as mkdirSync6, writeFileSync as writeFileSync5, unlinkSync as unlinkSync4 } from "fs";
|
|
1548
|
+
import { join as join5 } from "path";
|
|
1549
|
+
import { homedir as homedir5 } from "os";
|
|
1550
|
+
var descriptor4 = {
|
|
1551
|
+
id: "windsurf",
|
|
1552
|
+
name: "Windsurf",
|
|
1553
|
+
supportsGlobal: true,
|
|
1554
|
+
supportsProject: true,
|
|
1555
|
+
fileStrategy: "directory",
|
|
1556
|
+
// project is directory, global is single-file (hybrid)
|
|
1557
|
+
fileExtension: ".md"
|
|
1558
|
+
};
|
|
1559
|
+
function detect4(projectDir) {
|
|
1560
|
+
const home = homedir5();
|
|
1561
|
+
const cwd = projectDir || process.cwd();
|
|
1562
|
+
return {
|
|
1563
|
+
global: existsSync6(join5(home, ".codeium")),
|
|
1564
|
+
project: existsSync6(join5(cwd, ".windsurf"))
|
|
1565
|
+
};
|
|
1566
|
+
}
|
|
1567
|
+
function resolvePath4(slug, scope, projectDir) {
|
|
1568
|
+
const safeName = slug.replace(/\//g, "-");
|
|
1569
|
+
if (scope === "global") {
|
|
1570
|
+
return join5(homedir5(), ".codeium", "windsurf", "memories", "global_rules.md");
|
|
1571
|
+
}
|
|
1572
|
+
return join5(projectDir || process.cwd(), ".windsurf", "rules", `${safeName}.md`);
|
|
1573
|
+
}
|
|
1574
|
+
function transformContent4(content) {
|
|
1575
|
+
return toPlainMD(content);
|
|
1576
|
+
}
|
|
1577
|
+
function install4(opts) {
|
|
1578
|
+
const targetPath = resolvePath4(opts.slug, opts.scope, opts.projectDir);
|
|
1579
|
+
if (opts.scope === "global") {
|
|
1580
|
+
upsertSection(targetPath, opts.slug, `## ${opts.slug}
|
|
1581
|
+
|
|
1582
|
+
${opts.content}`);
|
|
1583
|
+
} else if (opts.method === "symlink") {
|
|
1584
|
+
createSymlink(opts.cachePath, targetPath);
|
|
1585
|
+
} else {
|
|
1586
|
+
mkdirSync6(join5(targetPath, ".."), { recursive: true });
|
|
1587
|
+
writeFileSync5(targetPath, opts.content);
|
|
1588
|
+
}
|
|
1589
|
+
return targetPath;
|
|
1590
|
+
}
|
|
1591
|
+
function uninstall4(installation, slug) {
|
|
1592
|
+
if (installation.method === "section") {
|
|
1593
|
+
removeSection(installation.path, slug);
|
|
1594
|
+
} else if (installation.method === "symlink") {
|
|
1595
|
+
removeSymlink(installation.path);
|
|
1596
|
+
} else if (existsSync6(installation.path)) {
|
|
1597
|
+
unlinkSync4(installation.path);
|
|
1598
|
+
}
|
|
1599
|
+
}
|
|
1600
|
+
function defaultMethod4(scope) {
|
|
1601
|
+
return scope === "global" ? "section" : "symlink";
|
|
1602
|
+
}
|
|
1603
|
+
var windsurfAdapter = {
|
|
1604
|
+
descriptor: descriptor4,
|
|
1605
|
+
detect: detect4,
|
|
1606
|
+
resolvePath: resolvePath4,
|
|
1607
|
+
transformContent: transformContent4,
|
|
1608
|
+
install: install4,
|
|
1609
|
+
uninstall: uninstall4,
|
|
1610
|
+
defaultMethod: defaultMethod4
|
|
1611
|
+
};
|
|
1612
|
+
|
|
1613
|
+
// src/lib/installers/cline.ts
|
|
1614
|
+
import { existsSync as existsSync7, mkdirSync as mkdirSync7, writeFileSync as writeFileSync6, unlinkSync as unlinkSync5 } from "fs";
|
|
1615
|
+
import { join as join6 } from "path";
|
|
1616
|
+
var descriptor5 = {
|
|
1617
|
+
id: "cline",
|
|
1618
|
+
name: "Cline",
|
|
1619
|
+
supportsGlobal: false,
|
|
1620
|
+
supportsProject: true,
|
|
1621
|
+
fileStrategy: "directory",
|
|
1622
|
+
fileExtension: ".md"
|
|
1623
|
+
};
|
|
1624
|
+
function detect5(projectDir) {
|
|
1625
|
+
const cwd = projectDir || process.cwd();
|
|
1626
|
+
return {
|
|
1627
|
+
global: false,
|
|
1628
|
+
project: existsSync7(join6(cwd, ".clinerules"))
|
|
1629
|
+
};
|
|
1630
|
+
}
|
|
1631
|
+
function resolvePath5(slug, scope, projectDir) {
|
|
1632
|
+
if (scope === "global") {
|
|
1633
|
+
throw new Error("Cline does not support global installation");
|
|
1634
|
+
}
|
|
1635
|
+
const safeName = slug.replace(/\//g, "-");
|
|
1636
|
+
return join6(projectDir || process.cwd(), ".clinerules", `${safeName}.md`);
|
|
1637
|
+
}
|
|
1638
|
+
function transformContent5(content) {
|
|
1639
|
+
return toPlainMD(content);
|
|
1640
|
+
}
|
|
1641
|
+
function install5(opts) {
|
|
1642
|
+
const targetPath = resolvePath5(opts.slug, opts.scope, opts.projectDir);
|
|
1643
|
+
if (opts.method === "symlink") {
|
|
1644
|
+
createSymlink(opts.cachePath, targetPath);
|
|
1645
|
+
} else {
|
|
1646
|
+
mkdirSync7(join6(targetPath, ".."), { recursive: true });
|
|
1647
|
+
writeFileSync6(targetPath, opts.content);
|
|
1648
|
+
}
|
|
1649
|
+
return targetPath;
|
|
1650
|
+
}
|
|
1651
|
+
function uninstall5(installation, _slug) {
|
|
1652
|
+
if (installation.method === "symlink") {
|
|
1653
|
+
removeSymlink(installation.path);
|
|
1654
|
+
} else if (existsSync7(installation.path)) {
|
|
1655
|
+
unlinkSync5(installation.path);
|
|
1656
|
+
}
|
|
1657
|
+
}
|
|
1658
|
+
function defaultMethod5() {
|
|
1659
|
+
return "symlink";
|
|
1660
|
+
}
|
|
1661
|
+
var clineAdapter = {
|
|
1662
|
+
descriptor: descriptor5,
|
|
1663
|
+
detect: detect5,
|
|
1664
|
+
resolvePath: resolvePath5,
|
|
1665
|
+
transformContent: transformContent5,
|
|
1666
|
+
install: install5,
|
|
1667
|
+
uninstall: uninstall5,
|
|
1668
|
+
defaultMethod: defaultMethod5
|
|
1669
|
+
};
|
|
1670
|
+
|
|
1671
|
+
// src/lib/installers/copilot.ts
|
|
1672
|
+
import { existsSync as existsSync8 } from "fs";
|
|
1673
|
+
import { join as join7 } from "path";
|
|
1674
|
+
var descriptor6 = {
|
|
1675
|
+
id: "copilot",
|
|
1676
|
+
name: "GitHub Copilot",
|
|
1677
|
+
supportsGlobal: false,
|
|
1678
|
+
supportsProject: true,
|
|
1679
|
+
fileStrategy: "single-file",
|
|
1680
|
+
fileExtension: ".md"
|
|
1681
|
+
};
|
|
1682
|
+
function detect6(projectDir) {
|
|
1683
|
+
const cwd = projectDir || process.cwd();
|
|
1684
|
+
return {
|
|
1685
|
+
global: false,
|
|
1686
|
+
project: existsSync8(join7(cwd, ".github"))
|
|
1687
|
+
};
|
|
1688
|
+
}
|
|
1689
|
+
function resolvePath6(slug, scope, projectDir) {
|
|
1690
|
+
if (scope === "global") {
|
|
1691
|
+
throw new Error("GitHub Copilot does not support global installation");
|
|
1692
|
+
}
|
|
1693
|
+
return join7(projectDir || process.cwd(), ".github", "copilot-instructions.md");
|
|
1694
|
+
}
|
|
1695
|
+
function transformContent6(content) {
|
|
1696
|
+
return toPlainMD(content);
|
|
1697
|
+
}
|
|
1698
|
+
function install6(opts) {
|
|
1699
|
+
const filePath = resolvePath6(opts.slug, opts.scope, opts.projectDir);
|
|
1700
|
+
upsertSection(filePath, opts.slug, `## ${opts.slug}
|
|
1701
|
+
|
|
1702
|
+
${opts.content}`);
|
|
1703
|
+
return filePath;
|
|
1704
|
+
}
|
|
1705
|
+
function uninstall6(installation, slug) {
|
|
1706
|
+
removeSection(installation.path, slug);
|
|
1707
|
+
}
|
|
1708
|
+
function defaultMethod6() {
|
|
1709
|
+
return "section";
|
|
1710
|
+
}
|
|
1711
|
+
var copilotAdapter = {
|
|
1712
|
+
descriptor: descriptor6,
|
|
1713
|
+
detect: detect6,
|
|
1714
|
+
resolvePath: resolvePath6,
|
|
1715
|
+
transformContent: transformContent6,
|
|
1716
|
+
install: install6,
|
|
1717
|
+
uninstall: uninstall6,
|
|
1718
|
+
defaultMethod: defaultMethod6
|
|
1719
|
+
};
|
|
1720
|
+
|
|
1721
|
+
// src/lib/installers/opencode.ts
|
|
1722
|
+
import { existsSync as existsSync9, mkdirSync as mkdirSync8, writeFileSync as writeFileSync7, unlinkSync as unlinkSync6 } from "fs";
|
|
1723
|
+
import { join as join8 } from "path";
|
|
1724
|
+
import { homedir as homedir6 } from "os";
|
|
1725
|
+
import { execSync as execSync2 } from "child_process";
|
|
1726
|
+
var descriptor7 = {
|
|
1727
|
+
id: "opencode",
|
|
1728
|
+
name: "OpenCode",
|
|
1729
|
+
supportsGlobal: true,
|
|
1730
|
+
supportsProject: true,
|
|
1731
|
+
fileStrategy: "directory",
|
|
1732
|
+
fileExtension: ".md"
|
|
1733
|
+
};
|
|
1734
|
+
function detect7(projectDir) {
|
|
1735
|
+
const cwd = projectDir || process.cwd();
|
|
1736
|
+
let hasCommand = false;
|
|
1737
|
+
try {
|
|
1738
|
+
execSync2("which opencode", { stdio: "ignore" });
|
|
1739
|
+
hasCommand = true;
|
|
1740
|
+
} catch {
|
|
1741
|
+
}
|
|
1742
|
+
return {
|
|
1743
|
+
global: hasCommand,
|
|
1744
|
+
project: hasCommand || existsSync9(join8(cwd, ".opencode"))
|
|
1745
|
+
};
|
|
1746
|
+
}
|
|
1747
|
+
function resolvePath7(slug, scope, projectDir) {
|
|
1748
|
+
const safeName = slug.replace(/\//g, "-");
|
|
1749
|
+
if (scope === "global") {
|
|
1750
|
+
return join8(homedir6(), ".config", "opencode", "rules", `${safeName}.md`);
|
|
1751
|
+
}
|
|
1752
|
+
return join8(projectDir || process.cwd(), ".opencode", "rules", `${safeName}.md`);
|
|
1753
|
+
}
|
|
1754
|
+
function transformContent7(content) {
|
|
1755
|
+
return toPlainMD(content);
|
|
1756
|
+
}
|
|
1757
|
+
function install7(opts) {
|
|
1758
|
+
const targetPath = resolvePath7(opts.slug, opts.scope, opts.projectDir);
|
|
1759
|
+
if (opts.method === "symlink") {
|
|
1760
|
+
createSymlink(opts.cachePath, targetPath);
|
|
1761
|
+
} else {
|
|
1762
|
+
mkdirSync8(join8(targetPath, ".."), { recursive: true });
|
|
1763
|
+
writeFileSync7(targetPath, opts.content);
|
|
1764
|
+
}
|
|
1765
|
+
return targetPath;
|
|
1766
|
+
}
|
|
1767
|
+
function uninstall7(installation, _slug) {
|
|
1768
|
+
if (installation.method === "symlink") {
|
|
1769
|
+
removeSymlink(installation.path);
|
|
1770
|
+
} else if (existsSync9(installation.path)) {
|
|
1771
|
+
unlinkSync6(installation.path);
|
|
1772
|
+
}
|
|
1773
|
+
}
|
|
1774
|
+
function defaultMethod7() {
|
|
1775
|
+
return "symlink";
|
|
1776
|
+
}
|
|
1777
|
+
var opencodeAdapter = {
|
|
1778
|
+
descriptor: descriptor7,
|
|
1779
|
+
detect: detect7,
|
|
1780
|
+
resolvePath: resolvePath7,
|
|
1781
|
+
transformContent: transformContent7,
|
|
1782
|
+
install: install7,
|
|
1783
|
+
uninstall: uninstall7,
|
|
1784
|
+
defaultMethod: defaultMethod7
|
|
1785
|
+
};
|
|
1786
|
+
|
|
1787
|
+
// src/lib/installers/aider.ts
|
|
1788
|
+
import { existsSync as existsSync10, mkdirSync as mkdirSync9, writeFileSync as writeFileSync8, unlinkSync as unlinkSync7, readFileSync as readFileSync3 } from "fs";
|
|
1789
|
+
import { join as join9 } from "path";
|
|
1790
|
+
import { execSync as execSync3 } from "child_process";
|
|
1791
|
+
var descriptor8 = {
|
|
1792
|
+
id: "aider",
|
|
1793
|
+
name: "Aider",
|
|
1794
|
+
supportsGlobal: false,
|
|
1795
|
+
supportsProject: true,
|
|
1796
|
+
fileStrategy: "directory",
|
|
1797
|
+
fileExtension: ".md"
|
|
1798
|
+
};
|
|
1799
|
+
function detect8() {
|
|
1800
|
+
let hasCommand = false;
|
|
1801
|
+
try {
|
|
1802
|
+
execSync3("which aider", { stdio: "ignore" });
|
|
1803
|
+
hasCommand = true;
|
|
1804
|
+
} catch {
|
|
1805
|
+
}
|
|
1806
|
+
return { global: false, project: hasCommand };
|
|
1807
|
+
}
|
|
1808
|
+
function resolvePath8(slug, scope, projectDir) {
|
|
1809
|
+
if (scope === "global") {
|
|
1810
|
+
throw new Error("Aider does not support global installation");
|
|
1811
|
+
}
|
|
1812
|
+
const safeName = slug.replace(/\//g, "-");
|
|
1813
|
+
return join9(projectDir || process.cwd(), ".aider", "skills", `${safeName}.md`);
|
|
1814
|
+
}
|
|
1815
|
+
function transformContent8(content) {
|
|
1816
|
+
return toPlainMD(content);
|
|
1817
|
+
}
|
|
1818
|
+
function addAiderRead(projectDir, relativePath) {
|
|
1819
|
+
const configPath = join9(projectDir, ".aider.conf.yml");
|
|
1820
|
+
let content = "";
|
|
1821
|
+
if (existsSync10(configPath)) {
|
|
1822
|
+
content = readFileSync3(configPath, "utf-8");
|
|
1823
|
+
}
|
|
1824
|
+
if (content.includes(relativePath)) return;
|
|
1825
|
+
const readLine = `read: ${relativePath}`;
|
|
1826
|
+
if (content.includes("read:")) {
|
|
1827
|
+
content = content.trimEnd() + "\n" + readLine + "\n";
|
|
1828
|
+
} else {
|
|
1829
|
+
content = content.trimEnd() + (content ? "\n" : "") + readLine + "\n";
|
|
1830
|
+
}
|
|
1831
|
+
writeFileSync8(configPath, content);
|
|
1832
|
+
}
|
|
1833
|
+
function removeAiderRead(projectDir, relativePath) {
|
|
1834
|
+
const configPath = join9(projectDir, ".aider.conf.yml");
|
|
1835
|
+
if (!existsSync10(configPath)) return;
|
|
1836
|
+
let content = readFileSync3(configPath, "utf-8");
|
|
1837
|
+
const lines = content.split("\n");
|
|
1838
|
+
const filtered = lines.filter((line) => !line.includes(relativePath));
|
|
1839
|
+
writeFileSync8(configPath, filtered.join("\n"));
|
|
1840
|
+
}
|
|
1841
|
+
function install8(opts) {
|
|
1842
|
+
const targetPath = resolvePath8(opts.slug, opts.scope, opts.projectDir);
|
|
1843
|
+
const projectDir = opts.projectDir || process.cwd();
|
|
1844
|
+
if (opts.method === "symlink") {
|
|
1845
|
+
createSymlink(opts.cachePath, targetPath);
|
|
1846
|
+
} else {
|
|
1847
|
+
mkdirSync9(join9(targetPath, ".."), { recursive: true });
|
|
1848
|
+
writeFileSync8(targetPath, opts.content);
|
|
1849
|
+
}
|
|
1850
|
+
const safeName = opts.slug.replace(/\//g, "-");
|
|
1851
|
+
const relativePath = `.aider/skills/${safeName}.md`;
|
|
1852
|
+
addAiderRead(projectDir, relativePath);
|
|
1853
|
+
return targetPath;
|
|
1854
|
+
}
|
|
1855
|
+
function uninstall8(installation, slug) {
|
|
1856
|
+
if (installation.method === "symlink") {
|
|
1857
|
+
removeSymlink(installation.path);
|
|
1858
|
+
} else if (existsSync10(installation.path)) {
|
|
1859
|
+
unlinkSync7(installation.path);
|
|
1860
|
+
}
|
|
1861
|
+
const projectDir = installation.projectDir || process.cwd();
|
|
1862
|
+
const safeName = slug.replace(/\//g, "-");
|
|
1863
|
+
const relativePath = `.aider/skills/${safeName}.md`;
|
|
1864
|
+
removeAiderRead(projectDir, relativePath);
|
|
1865
|
+
}
|
|
1866
|
+
function defaultMethod8() {
|
|
1867
|
+
return "symlink";
|
|
1868
|
+
}
|
|
1869
|
+
var aiderAdapter = {
|
|
1870
|
+
descriptor: descriptor8,
|
|
1871
|
+
detect: detect8,
|
|
1872
|
+
resolvePath: resolvePath8,
|
|
1873
|
+
transformContent: transformContent8,
|
|
1874
|
+
install: install8,
|
|
1875
|
+
uninstall: uninstall8,
|
|
1876
|
+
defaultMethod: defaultMethod8
|
|
1877
|
+
};
|
|
1878
|
+
|
|
1879
|
+
// src/lib/platform-registry.ts
|
|
1880
|
+
var adapters = /* @__PURE__ */ new Map([
|
|
1881
|
+
["cursor", cursorAdapter],
|
|
1882
|
+
["claude", claudeAdapter],
|
|
1883
|
+
["codex", codexAdapter],
|
|
1884
|
+
["windsurf", windsurfAdapter],
|
|
1885
|
+
["cline", clineAdapter],
|
|
1886
|
+
["copilot", copilotAdapter],
|
|
1887
|
+
["opencode", opencodeAdapter],
|
|
1888
|
+
["aider", aiderAdapter]
|
|
1889
|
+
]);
|
|
1890
|
+
function getAdapter(id) {
|
|
1891
|
+
const adapter = adapters.get(id);
|
|
1892
|
+
if (!adapter) throw new Error(`Unknown platform: ${id}`);
|
|
1893
|
+
return adapter;
|
|
1894
|
+
}
|
|
1895
|
+
function getAllAdapters() {
|
|
1896
|
+
return [...adapters.values()];
|
|
1897
|
+
}
|
|
1898
|
+
|
|
1899
|
+
// src/lib/cache.ts
|
|
1900
|
+
var CACHE_DIR = join10(homedir7(), ".localskills", "cache");
|
|
1901
|
+
function slugToDir(slug) {
|
|
1902
|
+
if (slug.includes("..") || slug.includes("\0")) {
|
|
1903
|
+
throw new Error("Invalid slug: contains forbidden characters");
|
|
1904
|
+
}
|
|
1905
|
+
return slug.replace(/\//g, "--");
|
|
1906
|
+
}
|
|
1907
|
+
function getCacheDir(slug) {
|
|
1908
|
+
const dir = resolve2(join10(CACHE_DIR, slugToDir(slug)));
|
|
1909
|
+
if (!dir.startsWith(resolve2(CACHE_DIR) + "/") && dir !== resolve2(CACHE_DIR)) {
|
|
1910
|
+
throw new Error("Invalid slug: path traversal detected");
|
|
1911
|
+
}
|
|
1912
|
+
return dir;
|
|
1913
|
+
}
|
|
1914
|
+
function store(slug, content, skill, version) {
|
|
1915
|
+
const dir = getCacheDir(slug);
|
|
1916
|
+
mkdirSync10(dir, { recursive: true });
|
|
1917
|
+
writeFileSync9(join10(dir, "raw.md"), content);
|
|
1918
|
+
const meta = {
|
|
1919
|
+
hash: skill.contentHash,
|
|
1920
|
+
version,
|
|
1921
|
+
name: skill.name,
|
|
1922
|
+
description: skill.description,
|
|
1923
|
+
fetchedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
1924
|
+
};
|
|
1925
|
+
writeFileSync9(join10(dir, "meta.json"), JSON.stringify(meta, null, 2) + "\n");
|
|
1926
|
+
clearPlatformFiles(slug);
|
|
1927
|
+
}
|
|
1928
|
+
function getPlatformFile(slug, platform, skill) {
|
|
1929
|
+
const dir = getCacheDir(slug);
|
|
1930
|
+
const adapter = getAdapter(platform);
|
|
1931
|
+
const raw = getRawContent(slug);
|
|
1932
|
+
if (!raw) throw new Error(`No cached content for ${slug}`);
|
|
1933
|
+
const transformed = adapter.transformContent(raw, skill);
|
|
1934
|
+
if (platform === "claude") {
|
|
1935
|
+
const claudeDir = join10(dir, "claude");
|
|
1936
|
+
mkdirSync10(claudeDir, { recursive: true });
|
|
1937
|
+
const filePath2 = join10(claudeDir, "SKILL.md");
|
|
1938
|
+
writeFileSync9(filePath2, transformed);
|
|
1939
|
+
return filePath2;
|
|
1940
|
+
}
|
|
1941
|
+
const ext = adapter.descriptor.fileExtension;
|
|
1942
|
+
const filePath = join10(dir, `${platform}${ext}`);
|
|
1943
|
+
writeFileSync9(filePath, transformed);
|
|
1944
|
+
return filePath;
|
|
1945
|
+
}
|
|
1946
|
+
function getRawContent(slug) {
|
|
1947
|
+
const filePath = join10(getCacheDir(slug), "raw.md");
|
|
1948
|
+
if (!existsSync11(filePath)) return null;
|
|
1949
|
+
return readFileSync4(filePath, "utf-8");
|
|
1950
|
+
}
|
|
1951
|
+
function purge(slug) {
|
|
1952
|
+
const dir = getCacheDir(slug);
|
|
1953
|
+
if (existsSync11(dir)) {
|
|
1954
|
+
rmSync4(dir, { recursive: true, force: true });
|
|
1955
|
+
}
|
|
1956
|
+
}
|
|
1957
|
+
function clearPlatformFiles(slug) {
|
|
1958
|
+
const dir = getCacheDir(slug);
|
|
1959
|
+
if (!existsSync11(dir)) return;
|
|
1960
|
+
const keep = /* @__PURE__ */ new Set(["raw.md", "meta.json"]);
|
|
1961
|
+
for (const entry of readdirSync(dir, { withFileTypes: true })) {
|
|
1962
|
+
if (!keep.has(entry.name)) {
|
|
1963
|
+
rmSync4(join10(dir, entry.name), { recursive: true, force: true });
|
|
1964
|
+
}
|
|
1965
|
+
}
|
|
1966
|
+
}
|
|
1967
|
+
|
|
1968
|
+
// src/lib/detect.ts
|
|
1969
|
+
import { existsSync as existsSync12 } from "fs";
|
|
1970
|
+
import { execFileSync } from "child_process";
|
|
1971
|
+
import { homedir as homedir8 } from "os";
|
|
1972
|
+
import { join as join11 } from "path";
|
|
1973
|
+
function commandExists(cmd) {
|
|
1974
|
+
try {
|
|
1975
|
+
execFileSync("which", [cmd], { stdio: "ignore" });
|
|
1976
|
+
return true;
|
|
1977
|
+
} catch {
|
|
1978
|
+
return false;
|
|
1979
|
+
}
|
|
1980
|
+
}
|
|
1981
|
+
function detectInstalledPlatforms(projectDir) {
|
|
1982
|
+
const detected = [];
|
|
1983
|
+
const home = homedir8();
|
|
1984
|
+
const cwd = projectDir || process.cwd();
|
|
1985
|
+
if (existsSync12(join11(home, ".cursor")) || existsSync12(join11(cwd, ".cursor")))
|
|
1986
|
+
detected.push("cursor");
|
|
1987
|
+
if (existsSync12(join11(home, ".claude")) || commandExists("claude"))
|
|
1988
|
+
detected.push("claude");
|
|
1989
|
+
if (commandExists("codex")) detected.push("codex");
|
|
1990
|
+
if (existsSync12(join11(home, ".codeium")) || existsSync12(join11(cwd, ".windsurf")))
|
|
1991
|
+
detected.push("windsurf");
|
|
1992
|
+
if (existsSync12(join11(cwd, ".clinerules"))) detected.push("cline");
|
|
1993
|
+
if (existsSync12(join11(cwd, ".github"))) detected.push("copilot");
|
|
1994
|
+
if (commandExists("opencode") || existsSync12(join11(cwd, ".opencode")))
|
|
1995
|
+
detected.push("opencode");
|
|
1996
|
+
if (commandExists("aider")) detected.push("aider");
|
|
1997
|
+
return detected;
|
|
1998
|
+
}
|
|
1999
|
+
|
|
2000
|
+
// src/lib/interactive.ts
|
|
2001
|
+
async function interactiveInstall(availableSkills, detectedPlatforms) {
|
|
2002
|
+
We("localskills install");
|
|
2003
|
+
const slug = await Je({
|
|
2004
|
+
message: "Which skill would you like to install?",
|
|
2005
|
+
options: availableSkills.map((s) => ({
|
|
2006
|
+
value: s.slug,
|
|
2007
|
+
label: s.name,
|
|
2008
|
+
hint: truncate(s.description, 60)
|
|
2009
|
+
}))
|
|
2010
|
+
});
|
|
2011
|
+
if (Ct(slug)) {
|
|
2012
|
+
Ne("Cancelled.");
|
|
2013
|
+
process.exit(0);
|
|
2014
|
+
}
|
|
2015
|
+
const rest = await interactiveTargets(detectedPlatforms);
|
|
2016
|
+
return { slug, ...rest };
|
|
2017
|
+
}
|
|
2018
|
+
async function interactiveTargets(detectedPlatforms) {
|
|
2019
|
+
const allAdapters = getAllAdapters();
|
|
2020
|
+
const platforms = await je({
|
|
2021
|
+
message: "Which platforms should receive this skill?",
|
|
2022
|
+
options: allAdapters.map((a) => ({
|
|
2023
|
+
value: a.descriptor.id,
|
|
2024
|
+
label: a.descriptor.name,
|
|
2025
|
+
hint: detectedPlatforms.includes(a.descriptor.id) ? "detected" : void 0
|
|
2026
|
+
})),
|
|
2027
|
+
initialValues: detectedPlatforms.length > 0 ? detectedPlatforms : void 0,
|
|
2028
|
+
required: true
|
|
2029
|
+
});
|
|
2030
|
+
if (Ct(platforms)) {
|
|
2031
|
+
Ne("Cancelled.");
|
|
2032
|
+
process.exit(0);
|
|
2033
|
+
}
|
|
2034
|
+
const scope = await Je({
|
|
2035
|
+
message: "Install scope?",
|
|
2036
|
+
options: [
|
|
2037
|
+
{
|
|
2038
|
+
value: "project",
|
|
2039
|
+
label: "Project",
|
|
2040
|
+
hint: `Install in current directory`
|
|
2041
|
+
},
|
|
2042
|
+
{
|
|
2043
|
+
value: "global",
|
|
2044
|
+
label: "Global",
|
|
2045
|
+
hint: "Install in home directory"
|
|
2046
|
+
}
|
|
2047
|
+
],
|
|
2048
|
+
initialValue: "project"
|
|
2049
|
+
});
|
|
2050
|
+
if (Ct(scope)) {
|
|
2051
|
+
Ne("Cancelled.");
|
|
2052
|
+
process.exit(0);
|
|
2053
|
+
}
|
|
2054
|
+
const method = await Je({
|
|
2055
|
+
message: "Install method?",
|
|
2056
|
+
options: [
|
|
2057
|
+
{
|
|
2058
|
+
value: "symlink",
|
|
2059
|
+
label: "Symlink",
|
|
2060
|
+
hint: "Link from cache (recommended)"
|
|
2061
|
+
},
|
|
2062
|
+
{
|
|
2063
|
+
value: "copy",
|
|
2064
|
+
label: "Copy",
|
|
2065
|
+
hint: "Copy file (standalone)"
|
|
2066
|
+
}
|
|
2067
|
+
],
|
|
2068
|
+
initialValue: "symlink"
|
|
2069
|
+
});
|
|
2070
|
+
if (Ct(method)) {
|
|
2071
|
+
Ne("Cancelled.");
|
|
2072
|
+
process.exit(0);
|
|
2073
|
+
}
|
|
2074
|
+
return {
|
|
2075
|
+
platforms,
|
|
2076
|
+
scope,
|
|
2077
|
+
method
|
|
2078
|
+
};
|
|
2079
|
+
}
|
|
2080
|
+
async function interactiveUninstall(installedSlugs) {
|
|
2081
|
+
We("localskills uninstall");
|
|
2082
|
+
const slug = await Je({
|
|
2083
|
+
message: "Which skill would you like to uninstall?",
|
|
2084
|
+
options: installedSlugs.map((s) => ({
|
|
2085
|
+
value: s,
|
|
2086
|
+
label: s
|
|
2087
|
+
}))
|
|
2088
|
+
});
|
|
2089
|
+
if (Ct(slug)) {
|
|
2090
|
+
Ne("Cancelled.");
|
|
2091
|
+
process.exit(0);
|
|
2092
|
+
}
|
|
2093
|
+
return slug;
|
|
2094
|
+
}
|
|
2095
|
+
function truncate(str, max) {
|
|
2096
|
+
if (str.length <= max) return str;
|
|
2097
|
+
return str.slice(0, max - 1) + "\u2026";
|
|
2098
|
+
}
|
|
2099
|
+
|
|
2100
|
+
// src/commands/install.ts
|
|
2101
|
+
var ALL_PLATFORMS = [
|
|
2102
|
+
"cursor",
|
|
2103
|
+
"claude",
|
|
2104
|
+
"codex",
|
|
2105
|
+
"windsurf",
|
|
2106
|
+
"cline",
|
|
2107
|
+
"copilot",
|
|
2108
|
+
"opencode",
|
|
2109
|
+
"aider"
|
|
2110
|
+
];
|
|
2111
|
+
function parsePlatforms(raw) {
|
|
2112
|
+
if (!raw || raw.length === 0) return null;
|
|
2113
|
+
const platforms = [];
|
|
2114
|
+
for (const item of raw) {
|
|
2115
|
+
for (const t of item.split(",")) {
|
|
2116
|
+
const trimmed = t.trim().toLowerCase();
|
|
2117
|
+
if (ALL_PLATFORMS.includes(trimmed)) {
|
|
2118
|
+
platforms.push(trimmed);
|
|
2119
|
+
} else {
|
|
2120
|
+
console.error(`Unknown platform: ${trimmed}`);
|
|
2121
|
+
console.error(`Available: ${ALL_PLATFORMS.join(", ")}`);
|
|
2122
|
+
process.exit(1);
|
|
2123
|
+
return null;
|
|
2124
|
+
}
|
|
2125
|
+
}
|
|
2126
|
+
}
|
|
2127
|
+
return platforms;
|
|
2128
|
+
}
|
|
2129
|
+
var installCommand = new Command2("install").description("Install a skill locally").argument("[slug]", "Skill slug (omit for interactive search)").option("-t, --target <targets...>", "Target platforms (cursor, claude, codex, ...)").option("-g, --global", "Install globally").option("-p, --project [dir]", "Install in project directory").option("--symlink", "Use symlink (default)").option("--copy", "Copy instead of symlink").action(
|
|
2130
|
+
async (slugArg, opts) => {
|
|
2131
|
+
const client = new ApiClient();
|
|
2132
|
+
const config = loadConfig();
|
|
2133
|
+
const detectedPlatforms = detectInstalledPlatforms();
|
|
2134
|
+
let slug;
|
|
2135
|
+
let platforms;
|
|
2136
|
+
let scope;
|
|
2137
|
+
let method;
|
|
2138
|
+
let projectDir;
|
|
2139
|
+
if (typeof opts.project === "string") {
|
|
2140
|
+
projectDir = opts.project;
|
|
2141
|
+
}
|
|
2142
|
+
const explicitPlatforms = parsePlatforms(opts.target);
|
|
2143
|
+
const explicitScope = opts.global ? "global" : opts.project !== void 0 ? "project" : null;
|
|
2144
|
+
const explicitMethod = opts.copy ? "copy" : opts.symlink ? "symlink" : null;
|
|
2145
|
+
if (!slugArg) {
|
|
2146
|
+
if (!client.isAuthenticated()) {
|
|
2147
|
+
console.error("Not authenticated. Run `localskills login` first.");
|
|
2148
|
+
process.exit(1);
|
|
2149
|
+
}
|
|
2150
|
+
const spinner2 = bt2();
|
|
2151
|
+
spinner2.start("Fetching available skills...");
|
|
2152
|
+
const res2 = await client.get("/api/skills");
|
|
2153
|
+
spinner2.stop("Fetched skills.");
|
|
2154
|
+
if (!res2.success || !res2.data || res2.data.length === 0) {
|
|
2155
|
+
console.error("No skills available.");
|
|
2156
|
+
process.exit(1);
|
|
2157
|
+
return;
|
|
2158
|
+
}
|
|
2159
|
+
const answers = await interactiveInstall(res2.data, detectedPlatforms);
|
|
2160
|
+
slug = answers.slug;
|
|
2161
|
+
platforms = answers.platforms;
|
|
2162
|
+
scope = answers.scope;
|
|
2163
|
+
method = answers.method;
|
|
2164
|
+
} else {
|
|
2165
|
+
slug = slugArg;
|
|
2166
|
+
if (explicitPlatforms && explicitScope && explicitMethod) {
|
|
2167
|
+
platforms = explicitPlatforms;
|
|
2168
|
+
scope = explicitScope;
|
|
2169
|
+
method = explicitMethod;
|
|
2170
|
+
} else {
|
|
2171
|
+
We(`localskills install ${slug}`);
|
|
2172
|
+
const answers = await interactiveTargets(detectedPlatforms);
|
|
2173
|
+
platforms = explicitPlatforms || answers.platforms;
|
|
2174
|
+
scope = explicitScope || answers.scope;
|
|
2175
|
+
method = explicitMethod || answers.method;
|
|
2176
|
+
}
|
|
2177
|
+
}
|
|
2178
|
+
const spinner = bt2();
|
|
2179
|
+
spinner.start(`Fetching ${slug}...`);
|
|
2180
|
+
const res = await client.get(
|
|
2181
|
+
`/api/skills/${encodeURIComponent(slug)}/content`
|
|
2182
|
+
);
|
|
2183
|
+
if (!res.success || !res.data) {
|
|
2184
|
+
spinner.stop(`Failed: ${res.error || "Skill not found"}`);
|
|
2185
|
+
process.exit(1);
|
|
2186
|
+
return;
|
|
2187
|
+
}
|
|
2188
|
+
const { skill, content, version } = res.data;
|
|
2189
|
+
spinner.stop(`Fetched ${skill.name} v${version}`);
|
|
2190
|
+
store(slug, content, skill, version);
|
|
2191
|
+
const installations = [];
|
|
2192
|
+
const results = [];
|
|
2193
|
+
for (const platformId of platforms) {
|
|
2194
|
+
const adapter = getAdapter(platformId);
|
|
2195
|
+
const desc = adapter.descriptor;
|
|
2196
|
+
if (scope === "global" && !desc.supportsGlobal) {
|
|
2197
|
+
R2.warn(`${desc.name} does not support global installation \u2014 skipping.`);
|
|
2198
|
+
continue;
|
|
2199
|
+
}
|
|
2200
|
+
if (scope === "project" && !desc.supportsProject) {
|
|
2201
|
+
R2.warn(`${desc.name} does not support project installation \u2014 skipping.`);
|
|
2202
|
+
continue;
|
|
2203
|
+
}
|
|
2204
|
+
const actualMethod = adapter.defaultMethod(scope) === "section" ? "section" : method;
|
|
2205
|
+
const cachePath = getPlatformFile(slug, platformId, skill);
|
|
2206
|
+
const transformed = adapter.transformContent(content, skill);
|
|
2207
|
+
const installedPath = adapter.install({
|
|
2208
|
+
slug,
|
|
2209
|
+
content: transformed,
|
|
2210
|
+
scope,
|
|
2211
|
+
method: actualMethod,
|
|
2212
|
+
cachePath,
|
|
2213
|
+
projectDir
|
|
2214
|
+
});
|
|
2215
|
+
const installation = {
|
|
2216
|
+
platform: platformId,
|
|
2217
|
+
scope,
|
|
2218
|
+
method: actualMethod,
|
|
2219
|
+
path: installedPath,
|
|
2220
|
+
projectDir,
|
|
2221
|
+
installedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
2222
|
+
};
|
|
2223
|
+
installations.push(installation);
|
|
2224
|
+
const methodLabel = actualMethod === "symlink" ? "symlinked" : actualMethod === "section" ? "section" : "copied";
|
|
2225
|
+
results.push(`${desc.name} \u2192 ${installedPath} (${methodLabel})`);
|
|
2226
|
+
}
|
|
2227
|
+
const existing = config.installed_skills[slug];
|
|
2228
|
+
const skillRecord = {
|
|
2229
|
+
slug,
|
|
2230
|
+
name: skill.name,
|
|
2231
|
+
hash: skill.contentHash,
|
|
2232
|
+
version,
|
|
2233
|
+
cachedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
2234
|
+
installations: existing ? [...existing.installations, ...installations] : installations
|
|
2235
|
+
};
|
|
2236
|
+
config.installed_skills[slug] = skillRecord;
|
|
2237
|
+
saveConfig(config);
|
|
2238
|
+
for (const r of results) {
|
|
2239
|
+
R2.success(r);
|
|
2240
|
+
}
|
|
2241
|
+
Le(`Done! Installed to ${installations.length} target(s).`);
|
|
2242
|
+
}
|
|
2243
|
+
);
|
|
2244
|
+
|
|
2245
|
+
// src/commands/uninstall.ts
|
|
2246
|
+
import { Command as Command3 } from "commander";
|
|
2247
|
+
var uninstallCommand = new Command3("uninstall").description("Uninstall a skill").argument("[slug]", "Skill slug (omit for interactive selection)").option("--purge", "Also remove from cache").action(async (slugArg, opts) => {
|
|
2248
|
+
const config = loadConfig();
|
|
2249
|
+
const installedSlugs = Object.keys(config.installed_skills);
|
|
2250
|
+
if (installedSlugs.length === 0) {
|
|
2251
|
+
console.log("No installed skills.");
|
|
2252
|
+
return;
|
|
2253
|
+
}
|
|
2254
|
+
let slug;
|
|
2255
|
+
if (slugArg) {
|
|
2256
|
+
slug = slugArg;
|
|
2257
|
+
} else {
|
|
2258
|
+
slug = await interactiveUninstall(installedSlugs);
|
|
2259
|
+
}
|
|
2260
|
+
const installed = config.installed_skills[slug];
|
|
2261
|
+
if (!installed) {
|
|
2262
|
+
console.error(`Skill "${slug}" is not installed.`);
|
|
2263
|
+
process.exit(1);
|
|
2264
|
+
return;
|
|
2265
|
+
}
|
|
2266
|
+
We(`localskills uninstall ${slug}`);
|
|
2267
|
+
let removed = 0;
|
|
2268
|
+
for (const installation of installed.installations) {
|
|
2269
|
+
try {
|
|
2270
|
+
const adapter = getAdapter(installation.platform);
|
|
2271
|
+
adapter.uninstall(installation, slug);
|
|
2272
|
+
R2.success(
|
|
2273
|
+
`${adapter.descriptor.name} \u2192 removed from ${installation.path}`
|
|
2274
|
+
);
|
|
2275
|
+
removed++;
|
|
2276
|
+
} catch (err) {
|
|
2277
|
+
R2.warn(
|
|
2278
|
+
`${installation.platform} \u2014 failed to remove: ${err instanceof Error ? err.message : String(err)}`
|
|
2279
|
+
);
|
|
2280
|
+
}
|
|
2281
|
+
}
|
|
2282
|
+
delete config.installed_skills[slug];
|
|
2283
|
+
saveConfig(config);
|
|
2284
|
+
if (opts?.purge) {
|
|
2285
|
+
purge(slug);
|
|
2286
|
+
R2.info("Cache purged.");
|
|
2287
|
+
}
|
|
2288
|
+
Le(
|
|
2289
|
+
`Uninstalled ${slug} from ${removed} target(s).`
|
|
2290
|
+
);
|
|
2291
|
+
});
|
|
2292
|
+
|
|
2293
|
+
// src/commands/list.ts
|
|
2294
|
+
import { Command as Command4 } from "commander";
|
|
2295
|
+
var listCommand = new Command4("list").description("List available skills").option("--public", "Show public skills only").action(async (opts) => {
|
|
2296
|
+
const client = new ApiClient();
|
|
2297
|
+
const path = opts.public ? "/api/skills?visibility=public" : "/api/skills";
|
|
2298
|
+
const res = await client.get(path);
|
|
2299
|
+
if (!res.success || !res.data) {
|
|
2300
|
+
console.error(`Error: ${res.error || "Failed to fetch skills"}`);
|
|
2301
|
+
process.exit(1);
|
|
2302
|
+
return;
|
|
2303
|
+
}
|
|
2304
|
+
if (res.data.length === 0) {
|
|
2305
|
+
console.log("No skills found.");
|
|
2306
|
+
return;
|
|
2307
|
+
}
|
|
2308
|
+
console.log("Available skills:\n");
|
|
2309
|
+
for (const skill of res.data) {
|
|
2310
|
+
const vis = skill.visibility === "public" ? "" : ` [${skill.visibility}]`;
|
|
2311
|
+
console.log(` ${skill.slug}${vis} \u2014 ${skill.description || skill.name}`);
|
|
2312
|
+
}
|
|
2313
|
+
console.log(`
|
|
2314
|
+
${res.data.length} skill(s) found.`);
|
|
2315
|
+
});
|
|
2316
|
+
|
|
2317
|
+
// src/commands/pull.ts
|
|
2318
|
+
import { Command as Command5 } from "commander";
|
|
2319
|
+
var pullCommand = new Command5("pull").description("Pull latest versions of all installed skills").argument("[slug]", "Pull a specific skill (omit for all)").action(async (slugArg) => {
|
|
2320
|
+
const config = loadConfig();
|
|
2321
|
+
const slugs = slugArg ? [slugArg] : Object.keys(config.installed_skills);
|
|
2322
|
+
if (slugs.length === 0) {
|
|
2323
|
+
console.log("No installed skills. Use `localskills install` first.");
|
|
2324
|
+
return;
|
|
2325
|
+
}
|
|
2326
|
+
const client = new ApiClient();
|
|
2327
|
+
We("localskills pull");
|
|
2328
|
+
const spinner = bt2();
|
|
2329
|
+
let updated = 0;
|
|
2330
|
+
let skipped = 0;
|
|
2331
|
+
for (const slug of slugs) {
|
|
2332
|
+
const installed = config.installed_skills[slug];
|
|
2333
|
+
if (!installed) {
|
|
2334
|
+
R2.warn(`${slug} \u2014 not found in config, skipping.`);
|
|
2335
|
+
continue;
|
|
2336
|
+
}
|
|
2337
|
+
spinner.start(`Checking ${slug}...`);
|
|
2338
|
+
const res = await client.get(
|
|
2339
|
+
`/api/skills/${encodeURIComponent(slug)}/content`
|
|
2340
|
+
);
|
|
2341
|
+
if (!res.success || !res.data) {
|
|
2342
|
+
spinner.stop(`${slug} \u2014 failed: ${res.error || "not found"}`);
|
|
2343
|
+
continue;
|
|
2344
|
+
}
|
|
2345
|
+
const { skill, content, version } = res.data;
|
|
2346
|
+
if (skill.contentHash === installed.hash) {
|
|
2347
|
+
spinner.stop(`${slug} \u2014 up to date`);
|
|
2348
|
+
skipped++;
|
|
2349
|
+
continue;
|
|
2350
|
+
}
|
|
2351
|
+
store(slug, content, skill, version);
|
|
2352
|
+
for (const installation of installed.installations) {
|
|
2353
|
+
if (installation.method === "symlink") {
|
|
2354
|
+
getPlatformFile(slug, installation.platform, skill);
|
|
2355
|
+
continue;
|
|
2356
|
+
}
|
|
2357
|
+
const adapter = getAdapter(installation.platform);
|
|
2358
|
+
const transformed = adapter.transformContent(content, skill);
|
|
2359
|
+
if (installation.method === "section") {
|
|
2360
|
+
upsertSection(
|
|
2361
|
+
installation.path,
|
|
2362
|
+
slug,
|
|
2363
|
+
`## ${slug}
|
|
2364
|
+
|
|
2365
|
+
${transformed}`
|
|
2366
|
+
);
|
|
2367
|
+
} else {
|
|
2368
|
+
const cachePath = getPlatformFile(slug, installation.platform, skill);
|
|
2369
|
+
adapter.install({
|
|
2370
|
+
slug,
|
|
2371
|
+
content: transformed,
|
|
2372
|
+
scope: installation.scope,
|
|
2373
|
+
method: "copy",
|
|
2374
|
+
cachePath,
|
|
2375
|
+
projectDir: installation.projectDir
|
|
2376
|
+
});
|
|
2377
|
+
}
|
|
2378
|
+
}
|
|
2379
|
+
installed.hash = skill.contentHash;
|
|
2380
|
+
installed.version = version;
|
|
2381
|
+
installed.cachedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
2382
|
+
updated++;
|
|
2383
|
+
spinner.stop(`${slug} \u2014 updated to v${version}`);
|
|
2384
|
+
}
|
|
2385
|
+
saveConfig(config);
|
|
2386
|
+
Le(`Pull complete. ${updated} updated, ${skipped} up to date.`);
|
|
2387
|
+
});
|
|
2388
|
+
|
|
2389
|
+
// src/index.ts
|
|
2390
|
+
var program = new Command6();
|
|
2391
|
+
program.name("localskills").description("Install and manage agent skills from localskills.sh").version("0.1.0");
|
|
2392
|
+
program.addCommand(loginCommand);
|
|
2393
|
+
program.addCommand(logoutCommand);
|
|
2394
|
+
program.addCommand(whoamiCommand);
|
|
2395
|
+
program.addCommand(installCommand);
|
|
2396
|
+
program.addCommand(uninstallCommand);
|
|
2397
|
+
program.addCommand(listCommand);
|
|
2398
|
+
program.addCommand(pullCommand);
|
|
2399
|
+
program.parse();
|