@itsflower/cli 0.1.4 → 0.1.6

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/main.js CHANGED
@@ -1,86 +1,1782 @@
1
- #!/usr/bin/env node
1
+ var __create = Object.create;
2
+ var __getProtoOf = Object.getPrototypeOf;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ function __accessProp(key) {
7
+ return this[key];
8
+ }
9
+ var __toESMCache_node;
10
+ var __toESMCache_esm;
11
+ var __toESM = (mod, isNodeMode, target) => {
12
+ var canCache = mod != null && typeof mod === "object";
13
+ if (canCache) {
14
+ var cache = isNodeMode ? __toESMCache_node ??= new WeakMap : __toESMCache_esm ??= new WeakMap;
15
+ var cached = cache.get(mod);
16
+ if (cached)
17
+ return cached;
18
+ }
19
+ target = mod != null ? __create(__getProtoOf(mod)) : {};
20
+ const to = isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target;
21
+ for (let key of __getOwnPropNames(mod))
22
+ if (!__hasOwnProp.call(to, key))
23
+ __defProp(to, key, {
24
+ get: __accessProp.bind(mod, key),
25
+ enumerable: true
26
+ });
27
+ if (canCache)
28
+ cache.set(mod, to);
29
+ return to;
30
+ };
31
+ var __commonJS = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
32
+ var __returnValue = (v) => v;
33
+ function __exportSetter(name, newValue) {
34
+ this[name] = __returnValue.bind(null, newValue);
35
+ }
36
+ var __export = (target, all) => {
37
+ for (var name in all)
38
+ __defProp(target, name, {
39
+ get: all[name],
40
+ enumerable: true,
41
+ configurable: true,
42
+ set: __exportSetter.bind(all, name)
43
+ });
44
+ };
45
+ var __esm = (fn, res) => () => (fn && (res = fn(fn = 0)), res);
2
46
 
3
- // src/main.ts
4
- import { defineCommand, runMain } from "citty";
5
- import { access, mkdir, readdir, readFile, writeFile } from "fs/promises";
6
- import { dirname, join, resolve } from "path";
7
- import { homedir } from "os";
8
- import { fileURLToPath } from "url";
9
- var __dirname = dirname(fileURLToPath(import.meta.url));
10
- async function exists(path) {
47
+ // ../../node_modules/.bun/citty@0.2.2/node_modules/citty/dist/_chunks/libs/scule.mjs
48
+ function isUppercase(char = "") {
49
+ if (NUMBER_CHAR_RE.test(char))
50
+ return;
51
+ return char !== char.toLowerCase();
52
+ }
53
+ function splitByCase(str, separators) {
54
+ const splitters = separators ?? STR_SPLITTERS;
55
+ const parts = [];
56
+ if (!str || typeof str !== "string")
57
+ return parts;
58
+ let buff = "";
59
+ let previousUpper;
60
+ let previousSplitter;
61
+ for (const char of str) {
62
+ const isSplitter = splitters.includes(char);
63
+ if (isSplitter === true) {
64
+ parts.push(buff);
65
+ buff = "";
66
+ previousUpper = undefined;
67
+ continue;
68
+ }
69
+ const isUpper = isUppercase(char);
70
+ if (previousSplitter === false) {
71
+ if (previousUpper === false && isUpper === true) {
72
+ parts.push(buff);
73
+ buff = char;
74
+ previousUpper = isUpper;
75
+ continue;
76
+ }
77
+ if (previousUpper === true && isUpper === false && buff.length > 1) {
78
+ const lastChar = buff.at(-1);
79
+ parts.push(buff.slice(0, Math.max(0, buff.length - 1)));
80
+ buff = lastChar + char;
81
+ previousUpper = isUpper;
82
+ continue;
83
+ }
84
+ }
85
+ buff += char;
86
+ previousUpper = isUpper;
87
+ previousSplitter = isSplitter;
88
+ }
89
+ parts.push(buff);
90
+ return parts;
91
+ }
92
+ function upperFirst(str) {
93
+ return str ? str[0].toUpperCase() + str.slice(1) : "";
94
+ }
95
+ function lowerFirst(str) {
96
+ return str ? str[0].toLowerCase() + str.slice(1) : "";
97
+ }
98
+ function pascalCase(str, opts) {
99
+ return str ? (Array.isArray(str) ? str : splitByCase(str)).map((p) => upperFirst(opts?.normalize ? p.toLowerCase() : p)).join("") : "";
100
+ }
101
+ function camelCase(str, opts) {
102
+ return lowerFirst(pascalCase(str || "", opts));
103
+ }
104
+ function kebabCase(str, joiner) {
105
+ return str ? (Array.isArray(str) ? str : splitByCase(str)).map((p) => p.toLowerCase()).join(joiner ?? "-") : "";
106
+ }
107
+ function snakeCase(str) {
108
+ return kebabCase(str || "", "_");
109
+ }
110
+ var NUMBER_CHAR_RE, STR_SPLITTERS;
111
+ var init_scule = __esm(() => {
112
+ NUMBER_CHAR_RE = /\d/;
113
+ STR_SPLITTERS = [
114
+ "-",
115
+ "_",
116
+ "/",
117
+ "."
118
+ ];
119
+ });
120
+
121
+ // ../../node_modules/.bun/citty@0.2.2/node_modules/citty/dist/index.mjs
122
+ import { parseArgs as parseArgs$1 } from "node:util";
123
+ function toArray(val) {
124
+ if (Array.isArray(val))
125
+ return val;
126
+ return val === undefined ? [] : [val];
127
+ }
128
+ function formatLineColumns(lines, linePrefix = "") {
129
+ const maxLength = [];
130
+ for (const line of lines)
131
+ for (const [i, element] of line.entries())
132
+ maxLength[i] = Math.max(maxLength[i] || 0, element.length);
133
+ return lines.map((l) => l.map((c, i) => linePrefix + c[i === 0 ? "padStart" : "padEnd"](maxLength[i])).join(" ")).join(`
134
+ `);
135
+ }
136
+ function resolveValue(input) {
137
+ return typeof input === "function" ? input() : input;
138
+ }
139
+ function parseRawArgs(args = [], opts = {}) {
140
+ const booleans = new Set(opts.boolean || []);
141
+ const strings = new Set(opts.string || []);
142
+ const aliasMap = opts.alias || {};
143
+ const defaults = opts.default || {};
144
+ const aliasToMain = /* @__PURE__ */ new Map;
145
+ const mainToAliases = /* @__PURE__ */ new Map;
146
+ for (const [key, value] of Object.entries(aliasMap)) {
147
+ const targets = value;
148
+ for (const target of targets) {
149
+ aliasToMain.set(key, target);
150
+ if (!mainToAliases.has(target))
151
+ mainToAliases.set(target, []);
152
+ mainToAliases.get(target).push(key);
153
+ aliasToMain.set(target, key);
154
+ if (!mainToAliases.has(key))
155
+ mainToAliases.set(key, []);
156
+ mainToAliases.get(key).push(target);
157
+ }
158
+ }
159
+ const options = {};
160
+ function getType(name) {
161
+ if (booleans.has(name))
162
+ return "boolean";
163
+ const aliases = mainToAliases.get(name) || [];
164
+ for (const alias of aliases)
165
+ if (booleans.has(alias))
166
+ return "boolean";
167
+ return "string";
168
+ }
169
+ function isStringType(name) {
170
+ if (strings.has(name))
171
+ return true;
172
+ const aliases = mainToAliases.get(name) || [];
173
+ for (const alias of aliases)
174
+ if (strings.has(alias))
175
+ return true;
176
+ return false;
177
+ }
178
+ const allOptions = new Set([
179
+ ...booleans,
180
+ ...strings,
181
+ ...Object.keys(aliasMap),
182
+ ...Object.values(aliasMap).flat(),
183
+ ...Object.keys(defaults)
184
+ ]);
185
+ for (const name of allOptions)
186
+ if (!options[name])
187
+ options[name] = {
188
+ type: getType(name),
189
+ default: defaults[name]
190
+ };
191
+ for (const [alias, main] of aliasToMain.entries())
192
+ if (alias.length === 1 && options[main] && !options[main].short)
193
+ options[main].short = alias;
194
+ const processedArgs = [];
195
+ const negatedFlags = {};
196
+ for (let i = 0;i < args.length; i++) {
197
+ const arg = args[i];
198
+ if (arg === "--") {
199
+ processedArgs.push(...args.slice(i));
200
+ break;
201
+ }
202
+ if (arg.startsWith("--no-")) {
203
+ const flagName = arg.slice(5);
204
+ negatedFlags[flagName] = true;
205
+ continue;
206
+ }
207
+ processedArgs.push(arg);
208
+ }
209
+ let parsed;
11
210
  try {
12
- await access(path);
13
- return true;
211
+ parsed = parseArgs$1({
212
+ args: processedArgs,
213
+ options: Object.keys(options).length > 0 ? options : undefined,
214
+ allowPositionals: true,
215
+ strict: false
216
+ });
14
217
  } catch {
15
- return false;
218
+ parsed = {
219
+ values: {},
220
+ positionals: processedArgs
221
+ };
222
+ }
223
+ const out = { _: [] };
224
+ out._ = parsed.positionals;
225
+ for (const [key, value] of Object.entries(parsed.values)) {
226
+ let coerced = value;
227
+ if (getType(key) === "boolean" && typeof value === "string")
228
+ coerced = value !== "false";
229
+ else if (isStringType(key) && typeof value === "boolean")
230
+ coerced = "";
231
+ out[key] = coerced;
232
+ }
233
+ for (const [name] of Object.entries(negatedFlags)) {
234
+ out[name] = false;
235
+ const mainName = aliasToMain.get(name);
236
+ if (mainName)
237
+ out[mainName] = false;
238
+ const aliases = mainToAliases.get(name);
239
+ if (aliases)
240
+ for (const alias of aliases)
241
+ out[alias] = false;
242
+ }
243
+ for (const [alias, main] of aliasToMain.entries()) {
244
+ if (out[alias] !== undefined && out[main] === undefined)
245
+ out[main] = out[alias];
246
+ if (out[main] !== undefined && out[alias] === undefined)
247
+ out[alias] = out[main];
248
+ if (out[alias] !== out[main] && defaults[main] === out[main])
249
+ out[main] = out[alias];
250
+ }
251
+ return out;
252
+ }
253
+ function parseArgs(rawArgs, argsDef) {
254
+ const parseOptions = {
255
+ boolean: [],
256
+ string: [],
257
+ alias: {},
258
+ default: {}
259
+ };
260
+ const args = resolveArgs(argsDef);
261
+ for (const arg of args) {
262
+ if (arg.type === "positional")
263
+ continue;
264
+ if (arg.type === "string" || arg.type === "enum")
265
+ parseOptions.string.push(arg.name);
266
+ else if (arg.type === "boolean")
267
+ parseOptions.boolean.push(arg.name);
268
+ if (arg.default !== undefined)
269
+ parseOptions.default[arg.name] = arg.default;
270
+ if (arg.alias)
271
+ parseOptions.alias[arg.name] = arg.alias;
272
+ const camelName = camelCase(arg.name);
273
+ const kebabName = kebabCase(arg.name);
274
+ if (camelName !== arg.name || kebabName !== arg.name) {
275
+ const existingAliases = toArray(parseOptions.alias[arg.name] || []);
276
+ if (camelName !== arg.name && !existingAliases.includes(camelName))
277
+ existingAliases.push(camelName);
278
+ if (kebabName !== arg.name && !existingAliases.includes(kebabName))
279
+ existingAliases.push(kebabName);
280
+ if (existingAliases.length > 0)
281
+ parseOptions.alias[arg.name] = existingAliases;
282
+ }
283
+ }
284
+ const parsed = parseRawArgs(rawArgs, parseOptions);
285
+ const [...positionalArguments] = parsed._;
286
+ const parsedArgsProxy = new Proxy(parsed, { get(target, prop) {
287
+ return target[prop] ?? target[camelCase(prop)] ?? target[kebabCase(prop)];
288
+ } });
289
+ for (const [, arg] of args.entries())
290
+ if (arg.type === "positional") {
291
+ const nextPositionalArgument = positionalArguments.shift();
292
+ if (nextPositionalArgument !== undefined)
293
+ parsedArgsProxy[arg.name] = nextPositionalArgument;
294
+ else if (arg.default === undefined && arg.required !== false)
295
+ throw new CLIError(`Missing required positional argument: ${arg.name.toUpperCase()}`, "EARG");
296
+ else
297
+ parsedArgsProxy[arg.name] = arg.default;
298
+ } else if (arg.type === "enum") {
299
+ const argument = parsedArgsProxy[arg.name];
300
+ const options = arg.options || [];
301
+ if (argument !== undefined && options.length > 0 && !options.includes(argument))
302
+ throw new CLIError(`Invalid value for argument: ${cyan(`--${arg.name}`)} (${cyan(argument)}). Expected one of: ${options.map((o) => cyan(o)).join(", ")}.`, "EARG");
303
+ } else if (arg.required && parsedArgsProxy[arg.name] === undefined)
304
+ throw new CLIError(`Missing required argument: --${arg.name}`, "EARG");
305
+ return parsedArgsProxy;
306
+ }
307
+ function resolveArgs(argsDef) {
308
+ const args = [];
309
+ for (const [name, argDef] of Object.entries(argsDef || {}))
310
+ args.push({
311
+ ...argDef,
312
+ name,
313
+ alias: toArray(argDef.alias)
314
+ });
315
+ return args;
316
+ }
317
+ async function resolvePlugins(plugins) {
318
+ return Promise.all(plugins.map((p) => resolveValue(p)));
319
+ }
320
+ function defineCommand(def) {
321
+ return def;
322
+ }
323
+ async function runCommand(cmd, opts) {
324
+ const cmdArgs = await resolveValue(cmd.args || {});
325
+ const parsedArgs = parseArgs(opts.rawArgs, cmdArgs);
326
+ const context = {
327
+ rawArgs: opts.rawArgs,
328
+ args: parsedArgs,
329
+ data: opts.data,
330
+ cmd
331
+ };
332
+ const plugins = await resolvePlugins(cmd.plugins ?? []);
333
+ let result;
334
+ let runError;
335
+ try {
336
+ for (const plugin of plugins)
337
+ await plugin.setup?.(context);
338
+ if (typeof cmd.setup === "function")
339
+ await cmd.setup(context);
340
+ const subCommands = await resolveValue(cmd.subCommands);
341
+ if (subCommands && Object.keys(subCommands).length > 0) {
342
+ const subCommandArgIndex = findSubCommandIndex(opts.rawArgs, cmdArgs);
343
+ const explicitName = opts.rawArgs[subCommandArgIndex];
344
+ if (explicitName) {
345
+ const subCommand = await _findSubCommand(subCommands, explicitName);
346
+ if (!subCommand)
347
+ throw new CLIError(`Unknown command ${cyan(explicitName)}`, "E_UNKNOWN_COMMAND");
348
+ await runCommand(subCommand, { rawArgs: opts.rawArgs.slice(subCommandArgIndex + 1) });
349
+ } else {
350
+ const defaultSubCommand = await resolveValue(cmd.default);
351
+ if (defaultSubCommand) {
352
+ if (cmd.run)
353
+ throw new CLIError(`Cannot specify both 'run' and 'default' on the same command.`, "E_DEFAULT_CONFLICT");
354
+ const subCommand = await _findSubCommand(subCommands, defaultSubCommand);
355
+ if (!subCommand)
356
+ throw new CLIError(`Default sub command ${cyan(defaultSubCommand)} not found in subCommands.`, "E_UNKNOWN_COMMAND");
357
+ await runCommand(subCommand, { rawArgs: opts.rawArgs });
358
+ } else if (!cmd.run)
359
+ throw new CLIError(`No command specified.`, "E_NO_COMMAND");
360
+ }
361
+ }
362
+ if (typeof cmd.run === "function")
363
+ result = await cmd.run(context);
364
+ } catch (error) {
365
+ runError = error;
366
+ }
367
+ const cleanupErrors = [];
368
+ if (typeof cmd.cleanup === "function")
369
+ try {
370
+ await cmd.cleanup(context);
371
+ } catch (error) {
372
+ cleanupErrors.push(error);
373
+ }
374
+ for (const plugin of [...plugins].reverse())
375
+ try {
376
+ await plugin.cleanup?.(context);
377
+ } catch (error) {
378
+ cleanupErrors.push(error);
379
+ }
380
+ if (runError)
381
+ throw runError;
382
+ if (cleanupErrors.length === 1)
383
+ throw cleanupErrors[0];
384
+ if (cleanupErrors.length > 1)
385
+ throw new Error("Multiple cleanup errors", { cause: cleanupErrors });
386
+ return { result };
387
+ }
388
+ async function resolveSubCommand(cmd, rawArgs, parent) {
389
+ const subCommands = await resolveValue(cmd.subCommands);
390
+ if (subCommands && Object.keys(subCommands).length > 0) {
391
+ const subCommandArgIndex = findSubCommandIndex(rawArgs, await resolveValue(cmd.args || {}));
392
+ const subCommandName = rawArgs[subCommandArgIndex];
393
+ const subCommand = await _findSubCommand(subCommands, subCommandName);
394
+ if (subCommand)
395
+ return resolveSubCommand(subCommand, rawArgs.slice(subCommandArgIndex + 1), cmd);
396
+ }
397
+ return [cmd, parent];
398
+ }
399
+ async function _findSubCommand(subCommands, name) {
400
+ if (name in subCommands)
401
+ return resolveValue(subCommands[name]);
402
+ for (const sub of Object.values(subCommands)) {
403
+ const resolved = await resolveValue(sub);
404
+ const meta = await resolveValue(resolved?.meta);
405
+ if (meta?.alias) {
406
+ if (toArray(meta.alias).includes(name))
407
+ return resolved;
408
+ }
409
+ }
410
+ }
411
+ function findSubCommandIndex(rawArgs, argsDef) {
412
+ for (let i = 0;i < rawArgs.length; i++) {
413
+ const arg = rawArgs[i];
414
+ if (arg === "--")
415
+ return -1;
416
+ if (arg.startsWith("-")) {
417
+ if (!arg.includes("=") && _isValueFlag(arg, argsDef))
418
+ i++;
419
+ continue;
420
+ }
421
+ return i;
422
+ }
423
+ return -1;
424
+ }
425
+ function _isValueFlag(flag, argsDef) {
426
+ const name = flag.replace(/^-{1,2}/, "");
427
+ const normalized = camelCase(name);
428
+ for (const [key, def] of Object.entries(argsDef)) {
429
+ if (def.type !== "string" && def.type !== "enum")
430
+ continue;
431
+ if (normalized === camelCase(key))
432
+ return true;
433
+ if ((Array.isArray(def.alias) ? def.alias : def.alias ? [def.alias] : []).includes(name))
434
+ return true;
16
435
  }
436
+ return false;
17
437
  }
18
- async function copyDirRecursive(src, dest) {
19
- await mkdir(dest, { recursive: true });
20
- const entries = await readdir(src, { withFileTypes: true });
21
- const copied = [];
22
- for (const entry of entries) {
23
- const srcPath = join(src, entry.name);
24
- const destPath = join(dest, entry.name);
25
- if (entry.isDirectory()) {
26
- copied.push(...await copyDirRecursive(srcPath, destPath));
438
+ async function showUsage(cmd, parent) {
439
+ try {
440
+ console.log(await renderUsage(cmd, parent) + `
441
+ `);
442
+ } catch (error) {
443
+ console.error(error);
444
+ }
445
+ }
446
+ async function renderUsage(cmd, parent) {
447
+ const cmdMeta = await resolveValue(cmd.meta || {});
448
+ const cmdArgs = resolveArgs(await resolveValue(cmd.args || {}));
449
+ const parentMeta = await resolveValue(parent?.meta || {});
450
+ const commandName = `${parentMeta.name ? `${parentMeta.name} ` : ""}` + (cmdMeta.name || process.argv[1]);
451
+ const argLines = [];
452
+ const posLines = [];
453
+ const commandsLines = [];
454
+ const usageLine = [];
455
+ for (const arg of cmdArgs)
456
+ if (arg.type === "positional") {
457
+ const name = arg.name.toUpperCase();
458
+ const isRequired = arg.required !== false && arg.default === undefined;
459
+ posLines.push([cyan(name + renderValueHint(arg)), renderDescription(arg, isRequired)]);
460
+ usageLine.push(isRequired ? `<${name}>` : `[${name}]`);
27
461
  } else {
28
- await writeFile(destPath, await readFile(srcPath));
29
- copied.push(destPath);
462
+ const isRequired = arg.required === true && arg.default === undefined;
463
+ const argStr = [...(arg.alias || []).map((a) => `-${a}`), `--${arg.name}`].join(", ") + renderValueHint(arg);
464
+ argLines.push([cyan(argStr), renderDescription(arg, isRequired)]);
465
+ if (arg.type === "boolean" && (arg.default === true || arg.negativeDescription) && !negativePrefixRe.test(arg.name)) {
466
+ const negativeArgStr = [...(arg.alias || []).map((a) => `--no-${a}`), `--no-${arg.name}`].join(", ");
467
+ argLines.push([cyan(negativeArgStr), [arg.negativeDescription, isRequired ? gray("(Required)") : ""].filter(Boolean).join(" ")]);
468
+ }
469
+ if (isRequired)
470
+ usageLine.push(`--${arg.name}` + renderValueHint(arg));
471
+ }
472
+ if (cmd.subCommands) {
473
+ const commandNames = [];
474
+ const subCommands = await resolveValue(cmd.subCommands);
475
+ for (const [name, sub] of Object.entries(subCommands)) {
476
+ const meta = await resolveValue((await resolveValue(sub))?.meta);
477
+ if (meta?.hidden)
478
+ continue;
479
+ const aliases = toArray(meta?.alias);
480
+ const label = [name, ...aliases].join(", ");
481
+ commandsLines.push([cyan(label), meta?.description || ""]);
482
+ commandNames.push(name, ...aliases);
30
483
  }
484
+ usageLine.push(commandNames.join("|"));
31
485
  }
32
- return copied;
486
+ const usageLines = [];
487
+ const version = cmdMeta.version || parentMeta.version;
488
+ usageLines.push(gray(`${cmdMeta.description} (${commandName + (version ? ` v${version}` : "")})`), "");
489
+ const hasOptions = argLines.length > 0 || posLines.length > 0;
490
+ usageLines.push(`${underline(bold("USAGE"))} ${cyan(`${commandName}${hasOptions ? " [OPTIONS]" : ""} ${usageLine.join(" ")}`)}`, "");
491
+ if (posLines.length > 0) {
492
+ usageLines.push(underline(bold("ARGUMENTS")), "");
493
+ usageLines.push(formatLineColumns(posLines, " "));
494
+ usageLines.push("");
495
+ }
496
+ if (argLines.length > 0) {
497
+ usageLines.push(underline(bold("OPTIONS")), "");
498
+ usageLines.push(formatLineColumns(argLines, " "));
499
+ usageLines.push("");
500
+ }
501
+ if (commandsLines.length > 0) {
502
+ usageLines.push(underline(bold("COMMANDS")), "");
503
+ usageLines.push(formatLineColumns(commandsLines, " "));
504
+ usageLines.push("", `Use ${cyan(`${commandName} <command> --help`)} for more information about a command.`);
505
+ }
506
+ return usageLines.filter((l) => typeof l === "string").join(`
507
+ `);
33
508
  }
34
- var init = defineCommand({
35
- meta: {
36
- name: "init",
37
- description: "Initialize flower in your project"
38
- },
39
- run: async () => {
40
- const templatesDir = resolve(__dirname, "../templates");
41
- const destDir = resolve(process.cwd(), ".flower/templates");
42
- await mkdir(destDir, { recursive: true });
43
- const files = await readdir(templatesDir);
44
- for (const file of files) {
45
- const src = join(templatesDir, file);
46
- const dest = join(destDir, file);
47
- await writeFile(dest, await readFile(src));
48
- }
49
- console.log(`Copied ${files.length} templates to ${destDir}`);
50
- for (const file of files) {
51
- console.log(` - ${file}`);
52
- }
53
- const crushConfigDir = resolve(homedir(), ".config/crush");
54
- const skillSrc = resolve(__dirname, "../skills/flower");
55
- const skillDest = resolve(crushConfigDir, "skills/flower");
56
- const skillExisted = await exists(skillDest);
57
- await copyDirRecursive(skillSrc, skillDest);
58
- if (skillExisted) {
59
- console.log("Updated existing skill: flower");
509
+ function renderValueHint(arg) {
510
+ const valueHint = arg.valueHint ? `=<${arg.valueHint}>` : "";
511
+ const fallbackValueHint = valueHint || `=<${snakeCase(arg.name)}>`;
512
+ if (!arg.type || arg.type === "positional" || arg.type === "boolean")
513
+ return valueHint;
514
+ if (arg.type === "enum" && arg.options?.length)
515
+ return `=<${arg.options.join("|")}>`;
516
+ return fallbackValueHint;
517
+ }
518
+ function renderDescription(arg, required) {
519
+ const requiredHint = required ? gray("(Required)") : "";
520
+ const defaultHint = arg.default === undefined ? "" : gray(`(Default: ${arg.default})`);
521
+ return [
522
+ arg.description,
523
+ requiredHint,
524
+ defaultHint
525
+ ].filter(Boolean).join(" ");
526
+ }
527
+ async function runMain(cmd, opts = {}) {
528
+ const rawArgs = opts.rawArgs || process.argv.slice(2);
529
+ const showUsage$1 = opts.showUsage || showUsage;
530
+ try {
531
+ const builtinFlags = await _resolveBuiltinFlags(cmd);
532
+ if (builtinFlags.help.length > 0 && rawArgs.some((arg) => builtinFlags.help.includes(arg))) {
533
+ await showUsage$1(...await resolveSubCommand(cmd, rawArgs));
534
+ process.exit(0);
535
+ } else if (rawArgs.length === 1 && builtinFlags.version.includes(rawArgs[0])) {
536
+ const meta = typeof cmd.meta === "function" ? await cmd.meta() : await cmd.meta;
537
+ if (!meta?.version)
538
+ throw new CLIError("No version specified", "E_NO_VERSION");
539
+ console.log(meta.version);
540
+ } else
541
+ await runCommand(cmd, { rawArgs });
542
+ } catch (error) {
543
+ if (error instanceof CLIError) {
544
+ await showUsage$1(...await resolveSubCommand(cmd, rawArgs));
545
+ console.error(error.message);
546
+ } else
547
+ console.error(error, `
548
+ `);
549
+ process.exit(1);
550
+ }
551
+ }
552
+ async function _resolveBuiltinFlags(cmd) {
553
+ const argsDef = await resolveValue(cmd.args || {});
554
+ const userNames = /* @__PURE__ */ new Set;
555
+ const userAliases = /* @__PURE__ */ new Set;
556
+ for (const [name, def] of Object.entries(argsDef)) {
557
+ userNames.add(name);
558
+ for (const alias of toArray(def.alias))
559
+ userAliases.add(alias);
560
+ }
561
+ return {
562
+ help: _getBuiltinFlags("help", "h", userNames, userAliases),
563
+ version: _getBuiltinFlags("version", "v", userNames, userAliases)
564
+ };
565
+ }
566
+ function _getBuiltinFlags(long, short, userNames, userAliases) {
567
+ if (userNames.has(long) || userAliases.has(long))
568
+ return [];
569
+ if (userNames.has(short) || userAliases.has(short))
570
+ return [`--${long}`];
571
+ return [`--${long}`, `-${short}`];
572
+ }
573
+ var CLIError, noColor, _c = (c, r = 39) => (t) => noColor ? t : `\x1B[${c}m${t}\x1B[${r}m`, bold, cyan, gray, underline, negativePrefixRe;
574
+ var init_dist = __esm(() => {
575
+ init_scule();
576
+ CLIError = class extends Error {
577
+ code;
578
+ constructor(message, code) {
579
+ super(message);
580
+ this.name = "CLIError";
581
+ this.code = code;
582
+ }
583
+ };
584
+ noColor = /* @__PURE__ */ (() => {
585
+ const env = globalThis.process?.env ?? {};
586
+ return env.NO_COLOR === "1" || env.TERM === "dumb" || env.TEST || env.CI;
587
+ })();
588
+ bold = /* @__PURE__ */ _c(1, 22);
589
+ cyan = /* @__PURE__ */ _c(36);
590
+ gray = /* @__PURE__ */ _c(90);
591
+ underline = /* @__PURE__ */ _c(4, 24);
592
+ negativePrefixRe = /^no[-A-Z]/;
593
+ });
594
+
595
+ // ../../node_modules/.bun/fast-string-truncated-width@1.2.1/node_modules/fast-string-truncated-width/dist/utils.js
596
+ var isAmbiguous = (x) => {
597
+ return x === 161 || x === 164 || x === 167 || x === 168 || x === 170 || x === 173 || x === 174 || x >= 176 && x <= 180 || x >= 182 && x <= 186 || x >= 188 && x <= 191 || x === 198 || x === 208 || x === 215 || x === 216 || x >= 222 && x <= 225 || x === 230 || x >= 232 && x <= 234 || x === 236 || x === 237 || x === 240 || x === 242 || x === 243 || x >= 247 && x <= 250 || x === 252 || x === 254 || x === 257 || x === 273 || x === 275 || x === 283 || x === 294 || x === 295 || x === 299 || x >= 305 && x <= 307 || x === 312 || x >= 319 && x <= 322 || x === 324 || x >= 328 && x <= 331 || x === 333 || x === 338 || x === 339 || x === 358 || x === 359 || x === 363 || x === 462 || x === 464 || x === 466 || x === 468 || x === 470 || x === 472 || x === 474 || x === 476 || x === 593 || x === 609 || x === 708 || x === 711 || x >= 713 && x <= 715 || x === 717 || x === 720 || x >= 728 && x <= 731 || x === 733 || x === 735 || x >= 768 && x <= 879 || x >= 913 && x <= 929 || x >= 931 && x <= 937 || x >= 945 && x <= 961 || x >= 963 && x <= 969 || x === 1025 || x >= 1040 && x <= 1103 || x === 1105 || x === 8208 || x >= 8211 && x <= 8214 || x === 8216 || x === 8217 || x === 8220 || x === 8221 || x >= 8224 && x <= 8226 || x >= 8228 && x <= 8231 || x === 8240 || x === 8242 || x === 8243 || x === 8245 || x === 8251 || x === 8254 || x === 8308 || x === 8319 || x >= 8321 && x <= 8324 || x === 8364 || x === 8451 || x === 8453 || x === 8457 || x === 8467 || x === 8470 || x === 8481 || x === 8482 || x === 8486 || x === 8491 || x === 8531 || x === 8532 || x >= 8539 && x <= 8542 || x >= 8544 && x <= 8555 || x >= 8560 && x <= 8569 || x === 8585 || x >= 8592 && x <= 8601 || x === 8632 || x === 8633 || x === 8658 || x === 8660 || x === 8679 || x === 8704 || x === 8706 || x === 8707 || x === 8711 || x === 8712 || x === 8715 || x === 8719 || x === 8721 || x === 8725 || x === 8730 || x >= 8733 && x <= 8736 || x === 8739 || x === 8741 || x >= 8743 && x <= 8748 || x === 8750 || x >= 8756 && x <= 8759 || x === 8764 || x === 8765 || x === 8776 || x === 8780 || x === 8786 || x === 8800 || x === 8801 || x >= 8804 && x <= 8807 || x === 8810 || x === 8811 || x === 8814 || x === 8815 || x === 8834 || x === 8835 || x === 8838 || x === 8839 || x === 8853 || x === 8857 || x === 8869 || x === 8895 || x === 8978 || x >= 9312 && x <= 9449 || x >= 9451 && x <= 9547 || x >= 9552 && x <= 9587 || x >= 9600 && x <= 9615 || x >= 9618 && x <= 9621 || x === 9632 || x === 9633 || x >= 9635 && x <= 9641 || x === 9650 || x === 9651 || x === 9654 || x === 9655 || x === 9660 || x === 9661 || x === 9664 || x === 9665 || x >= 9670 && x <= 9672 || x === 9675 || x >= 9678 && x <= 9681 || x >= 9698 && x <= 9701 || x === 9711 || x === 9733 || x === 9734 || x === 9737 || x === 9742 || x === 9743 || x === 9756 || x === 9758 || x === 9792 || x === 9794 || x === 9824 || x === 9825 || x >= 9827 && x <= 9829 || x >= 9831 && x <= 9834 || x === 9836 || x === 9837 || x === 9839 || x === 9886 || x === 9887 || x === 9919 || x >= 9926 && x <= 9933 || x >= 9935 && x <= 9939 || x >= 9941 && x <= 9953 || x === 9955 || x === 9960 || x === 9961 || x >= 9963 && x <= 9969 || x === 9972 || x >= 9974 && x <= 9977 || x === 9979 || x === 9980 || x === 9982 || x === 9983 || x === 10045 || x >= 10102 && x <= 10111 || x >= 11094 && x <= 11097 || x >= 12872 && x <= 12879 || x >= 57344 && x <= 63743 || x >= 65024 && x <= 65039 || x === 65533 || x >= 127232 && x <= 127242 || x >= 127248 && x <= 127277 || x >= 127280 && x <= 127337 || x >= 127344 && x <= 127373 || x === 127375 || x === 127376 || x >= 127387 && x <= 127404 || x >= 917760 && x <= 917999 || x >= 983040 && x <= 1048573 || x >= 1048576 && x <= 1114109;
598
+ }, isFullWidth = (x) => {
599
+ return x === 12288 || x >= 65281 && x <= 65376 || x >= 65504 && x <= 65510;
600
+ }, isWide = (x) => {
601
+ return x >= 4352 && x <= 4447 || x === 8986 || x === 8987 || x === 9001 || x === 9002 || x >= 9193 && x <= 9196 || x === 9200 || x === 9203 || x === 9725 || x === 9726 || x === 9748 || x === 9749 || x >= 9800 && x <= 9811 || x === 9855 || x === 9875 || x === 9889 || x === 9898 || x === 9899 || x === 9917 || x === 9918 || x === 9924 || x === 9925 || x === 9934 || x === 9940 || x === 9962 || x === 9970 || x === 9971 || x === 9973 || x === 9978 || x === 9981 || x === 9989 || x === 9994 || x === 9995 || x === 10024 || x === 10060 || x === 10062 || x >= 10067 && x <= 10069 || x === 10071 || x >= 10133 && x <= 10135 || x === 10160 || x === 10175 || x === 11035 || x === 11036 || x === 11088 || x === 11093 || x >= 11904 && x <= 11929 || x >= 11931 && x <= 12019 || x >= 12032 && x <= 12245 || x >= 12272 && x <= 12287 || x >= 12289 && x <= 12350 || x >= 12353 && x <= 12438 || x >= 12441 && x <= 12543 || x >= 12549 && x <= 12591 || x >= 12593 && x <= 12686 || x >= 12688 && x <= 12771 || x >= 12783 && x <= 12830 || x >= 12832 && x <= 12871 || x >= 12880 && x <= 19903 || x >= 19968 && x <= 42124 || x >= 42128 && x <= 42182 || x >= 43360 && x <= 43388 || x >= 44032 && x <= 55203 || x >= 63744 && x <= 64255 || x >= 65040 && x <= 65049 || x >= 65072 && x <= 65106 || x >= 65108 && x <= 65126 || x >= 65128 && x <= 65131 || x >= 94176 && x <= 94180 || x === 94192 || x === 94193 || x >= 94208 && x <= 100343 || x >= 100352 && x <= 101589 || x >= 101632 && x <= 101640 || x >= 110576 && x <= 110579 || x >= 110581 && x <= 110587 || x === 110589 || x === 110590 || x >= 110592 && x <= 110882 || x === 110898 || x >= 110928 && x <= 110930 || x === 110933 || x >= 110948 && x <= 110951 || x >= 110960 && x <= 111355 || x === 126980 || x === 127183 || x === 127374 || x >= 127377 && x <= 127386 || x >= 127488 && x <= 127490 || x >= 127504 && x <= 127547 || x >= 127552 && x <= 127560 || x === 127568 || x === 127569 || x >= 127584 && x <= 127589 || x >= 127744 && x <= 127776 || x >= 127789 && x <= 127797 || x >= 127799 && x <= 127868 || x >= 127870 && x <= 127891 || x >= 127904 && x <= 127946 || x >= 127951 && x <= 127955 || x >= 127968 && x <= 127984 || x === 127988 || x >= 127992 && x <= 128062 || x === 128064 || x >= 128066 && x <= 128252 || x >= 128255 && x <= 128317 || x >= 128331 && x <= 128334 || x >= 128336 && x <= 128359 || x === 128378 || x === 128405 || x === 128406 || x === 128420 || x >= 128507 && x <= 128591 || x >= 128640 && x <= 128709 || x === 128716 || x >= 128720 && x <= 128722 || x >= 128725 && x <= 128727 || x >= 128732 && x <= 128735 || x === 128747 || x === 128748 || x >= 128756 && x <= 128764 || x >= 128992 && x <= 129003 || x === 129008 || x >= 129292 && x <= 129338 || x >= 129340 && x <= 129349 || x >= 129351 && x <= 129535 || x >= 129648 && x <= 129660 || x >= 129664 && x <= 129672 || x >= 129680 && x <= 129725 || x >= 129727 && x <= 129733 || x >= 129742 && x <= 129755 || x >= 129760 && x <= 129768 || x >= 129776 && x <= 129784 || x >= 131072 && x <= 196605 || x >= 196608 && x <= 262141;
602
+ };
603
+ var init_utils = () => {};
604
+
605
+ // ../../node_modules/.bun/fast-string-truncated-width@1.2.1/node_modules/fast-string-truncated-width/dist/index.js
606
+ var ANSI_RE, CONTROL_RE, TAB_RE, EMOJI_RE, LATIN_RE, MODIFIER_RE, NO_TRUNCATION, getStringTruncatedWidth = (input, truncationOptions = {}, widthOptions = {}) => {
607
+ const LIMIT = truncationOptions.limit ?? Infinity;
608
+ const ELLIPSIS = truncationOptions.ellipsis ?? "";
609
+ const ELLIPSIS_WIDTH = truncationOptions?.ellipsisWidth ?? (ELLIPSIS ? getStringTruncatedWidth(ELLIPSIS, NO_TRUNCATION, widthOptions).width : 0);
610
+ const ANSI_WIDTH = widthOptions.ansiWidth ?? 0;
611
+ const CONTROL_WIDTH = widthOptions.controlWidth ?? 0;
612
+ const TAB_WIDTH = widthOptions.tabWidth ?? 8;
613
+ const AMBIGUOUS_WIDTH = widthOptions.ambiguousWidth ?? 1;
614
+ const EMOJI_WIDTH = widthOptions.emojiWidth ?? 2;
615
+ const FULL_WIDTH_WIDTH = widthOptions.fullWidthWidth ?? 2;
616
+ const REGULAR_WIDTH = widthOptions.regularWidth ?? 1;
617
+ const WIDE_WIDTH = widthOptions.wideWidth ?? 2;
618
+ let indexPrev = 0;
619
+ let index = 0;
620
+ let length = input.length;
621
+ let lengthExtra = 0;
622
+ let truncationEnabled = false;
623
+ let truncationIndex = length;
624
+ let truncationLimit = Math.max(0, LIMIT - ELLIPSIS_WIDTH);
625
+ let unmatchedStart = 0;
626
+ let unmatchedEnd = 0;
627
+ let width = 0;
628
+ let widthExtra = 0;
629
+ outer:
630
+ while (true) {
631
+ if (unmatchedEnd > unmatchedStart || index >= length && index > indexPrev) {
632
+ const unmatched = input.slice(unmatchedStart, unmatchedEnd) || input.slice(indexPrev, index);
633
+ lengthExtra = 0;
634
+ for (const char of unmatched.replaceAll(MODIFIER_RE, "")) {
635
+ const codePoint = char.codePointAt(0) || 0;
636
+ if (isFullWidth(codePoint)) {
637
+ widthExtra = FULL_WIDTH_WIDTH;
638
+ } else if (isWide(codePoint)) {
639
+ widthExtra = WIDE_WIDTH;
640
+ } else if (AMBIGUOUS_WIDTH !== REGULAR_WIDTH && isAmbiguous(codePoint)) {
641
+ widthExtra = AMBIGUOUS_WIDTH;
642
+ } else {
643
+ widthExtra = REGULAR_WIDTH;
644
+ }
645
+ if (width + widthExtra > truncationLimit) {
646
+ truncationIndex = Math.min(truncationIndex, Math.max(unmatchedStart, indexPrev) + lengthExtra);
647
+ }
648
+ if (width + widthExtra > LIMIT) {
649
+ truncationEnabled = true;
650
+ break outer;
651
+ }
652
+ lengthExtra += char.length;
653
+ width += widthExtra;
654
+ }
655
+ unmatchedStart = unmatchedEnd = 0;
656
+ }
657
+ if (index >= length)
658
+ break;
659
+ LATIN_RE.lastIndex = index;
660
+ if (LATIN_RE.test(input)) {
661
+ lengthExtra = LATIN_RE.lastIndex - index;
662
+ widthExtra = lengthExtra * REGULAR_WIDTH;
663
+ if (width + widthExtra > truncationLimit) {
664
+ truncationIndex = Math.min(truncationIndex, index + Math.floor((truncationLimit - width) / REGULAR_WIDTH));
665
+ }
666
+ if (width + widthExtra > LIMIT) {
667
+ truncationEnabled = true;
668
+ break;
669
+ }
670
+ width += widthExtra;
671
+ unmatchedStart = indexPrev;
672
+ unmatchedEnd = index;
673
+ index = indexPrev = LATIN_RE.lastIndex;
674
+ continue;
675
+ }
676
+ ANSI_RE.lastIndex = index;
677
+ if (ANSI_RE.test(input)) {
678
+ if (width + ANSI_WIDTH > truncationLimit) {
679
+ truncationIndex = Math.min(truncationIndex, index);
680
+ }
681
+ if (width + ANSI_WIDTH > LIMIT) {
682
+ truncationEnabled = true;
683
+ break;
684
+ }
685
+ width += ANSI_WIDTH;
686
+ unmatchedStart = indexPrev;
687
+ unmatchedEnd = index;
688
+ index = indexPrev = ANSI_RE.lastIndex;
689
+ continue;
690
+ }
691
+ CONTROL_RE.lastIndex = index;
692
+ if (CONTROL_RE.test(input)) {
693
+ lengthExtra = CONTROL_RE.lastIndex - index;
694
+ widthExtra = lengthExtra * CONTROL_WIDTH;
695
+ if (width + widthExtra > truncationLimit) {
696
+ truncationIndex = Math.min(truncationIndex, index + Math.floor((truncationLimit - width) / CONTROL_WIDTH));
697
+ }
698
+ if (width + widthExtra > LIMIT) {
699
+ truncationEnabled = true;
700
+ break;
701
+ }
702
+ width += widthExtra;
703
+ unmatchedStart = indexPrev;
704
+ unmatchedEnd = index;
705
+ index = indexPrev = CONTROL_RE.lastIndex;
706
+ continue;
707
+ }
708
+ TAB_RE.lastIndex = index;
709
+ if (TAB_RE.test(input)) {
710
+ lengthExtra = TAB_RE.lastIndex - index;
711
+ widthExtra = lengthExtra * TAB_WIDTH;
712
+ if (width + widthExtra > truncationLimit) {
713
+ truncationIndex = Math.min(truncationIndex, index + Math.floor((truncationLimit - width) / TAB_WIDTH));
714
+ }
715
+ if (width + widthExtra > LIMIT) {
716
+ truncationEnabled = true;
717
+ break;
718
+ }
719
+ width += widthExtra;
720
+ unmatchedStart = indexPrev;
721
+ unmatchedEnd = index;
722
+ index = indexPrev = TAB_RE.lastIndex;
723
+ continue;
724
+ }
725
+ EMOJI_RE.lastIndex = index;
726
+ if (EMOJI_RE.test(input)) {
727
+ if (width + EMOJI_WIDTH > truncationLimit) {
728
+ truncationIndex = Math.min(truncationIndex, index);
729
+ }
730
+ if (width + EMOJI_WIDTH > LIMIT) {
731
+ truncationEnabled = true;
732
+ break;
733
+ }
734
+ width += EMOJI_WIDTH;
735
+ unmatchedStart = indexPrev;
736
+ unmatchedEnd = index;
737
+ index = indexPrev = EMOJI_RE.lastIndex;
738
+ continue;
739
+ }
740
+ index += 1;
741
+ }
742
+ return {
743
+ width: truncationEnabled ? truncationLimit : width,
744
+ index: truncationEnabled ? truncationIndex : length,
745
+ truncated: truncationEnabled,
746
+ ellipsed: truncationEnabled && LIMIT >= ELLIPSIS_WIDTH
747
+ };
748
+ }, dist_default;
749
+ var init_dist2 = __esm(() => {
750
+ init_utils();
751
+ ANSI_RE = /[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]/y;
752
+ CONTROL_RE = /[\x00-\x08\x0A-\x1F\x7F-\x9F]{1,1000}/y;
753
+ TAB_RE = /\t{1,1000}/y;
754
+ EMOJI_RE = /[\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;
755
+ LATIN_RE = /(?:[\x20-\x7E\xA0-\xFF](?!\uFE0F)){1,1000}/y;
756
+ MODIFIER_RE = /\p{M}+/gu;
757
+ NO_TRUNCATION = { limit: Infinity, ellipsis: "" };
758
+ dist_default = getStringTruncatedWidth;
759
+ });
760
+
761
+ // ../../node_modules/.bun/fast-string-width@1.1.0/node_modules/fast-string-width/dist/index.js
762
+ var NO_TRUNCATION2, fastStringWidth = (input, options = {}) => {
763
+ return dist_default(input, NO_TRUNCATION2, options).width;
764
+ }, dist_default2;
765
+ var init_dist3 = __esm(() => {
766
+ init_dist2();
767
+ NO_TRUNCATION2 = {
768
+ limit: Infinity,
769
+ ellipsis: "",
770
+ ellipsisWidth: 0
771
+ };
772
+ dist_default2 = fastStringWidth;
773
+ });
774
+
775
+ // ../../node_modules/.bun/fast-wrap-ansi@0.1.6/node_modules/fast-wrap-ansi/lib/main.js
776
+ function wrapAnsi(string, columns, options) {
777
+ return String(string).normalize().split(CRLF_OR_LF).map((line) => exec(line, columns, options)).join(`
778
+ `);
779
+ }
780
+ var ESC = "\x1B", CSI = "›", END_CODE = 39, ANSI_ESCAPE_BELL = "\x07", ANSI_CSI = "[", ANSI_OSC = "]", ANSI_SGR_TERMINATOR = "m", ANSI_ESCAPE_LINK, GROUP_REGEX, getClosingCode = (openingCode) => {
781
+ if (openingCode >= 30 && openingCode <= 37)
782
+ return 39;
783
+ if (openingCode >= 90 && openingCode <= 97)
784
+ return 39;
785
+ if (openingCode >= 40 && openingCode <= 47)
786
+ return 49;
787
+ if (openingCode >= 100 && openingCode <= 107)
788
+ return 49;
789
+ if (openingCode === 1 || openingCode === 2)
790
+ return 22;
791
+ if (openingCode === 3)
792
+ return 23;
793
+ if (openingCode === 4)
794
+ return 24;
795
+ if (openingCode === 7)
796
+ return 27;
797
+ if (openingCode === 8)
798
+ return 28;
799
+ if (openingCode === 9)
800
+ return 29;
801
+ if (openingCode === 0)
802
+ return 0;
803
+ return;
804
+ }, wrapAnsiCode = (code) => `${ESC}${ANSI_CSI}${code}${ANSI_SGR_TERMINATOR}`, wrapAnsiHyperlink = (url) => `${ESC}${ANSI_ESCAPE_LINK}${url}${ANSI_ESCAPE_BELL}`, wrapWord = (rows, word, columns) => {
805
+ const characters = word[Symbol.iterator]();
806
+ let isInsideEscape = false;
807
+ let isInsideLinkEscape = false;
808
+ let lastRow = rows.at(-1);
809
+ let visible = lastRow === undefined ? 0 : dist_default2(lastRow);
810
+ let currentCharacter = characters.next();
811
+ let nextCharacter = characters.next();
812
+ let rawCharacterIndex = 0;
813
+ while (!currentCharacter.done) {
814
+ const character = currentCharacter.value;
815
+ const characterLength = dist_default2(character);
816
+ if (visible + characterLength <= columns) {
817
+ rows[rows.length - 1] += character;
60
818
  } else {
61
- console.log("Installed skill: flower");
62
- }
63
- const cmdSrc = resolve(__dirname, "../commands/flower.md");
64
- const cmdDest = resolve(crushConfigDir, "commands/flower.md");
65
- const cmdExisted = await exists(cmdDest);
66
- await mkdir(resolve(crushConfigDir, "commands"), { recursive: true });
67
- await writeFile(cmdDest, await readFile(cmdSrc));
68
- if (cmdExisted) {
69
- console.log("Updated existing command: flower");
819
+ rows.push(character);
820
+ visible = 0;
821
+ }
822
+ if (character === ESC || character === CSI) {
823
+ isInsideEscape = true;
824
+ isInsideLinkEscape = word.startsWith(ANSI_ESCAPE_LINK, rawCharacterIndex + 1);
825
+ }
826
+ if (isInsideEscape) {
827
+ if (isInsideLinkEscape) {
828
+ if (character === ANSI_ESCAPE_BELL) {
829
+ isInsideEscape = false;
830
+ isInsideLinkEscape = false;
831
+ }
832
+ } else if (character === ANSI_SGR_TERMINATOR) {
833
+ isInsideEscape = false;
834
+ }
70
835
  } else {
71
- console.log("Installed command: flower");
836
+ visible += characterLength;
837
+ if (visible === columns && !nextCharacter.done) {
838
+ rows.push("");
839
+ visible = 0;
840
+ }
841
+ }
842
+ currentCharacter = nextCharacter;
843
+ nextCharacter = characters.next();
844
+ rawCharacterIndex += character.length;
845
+ }
846
+ lastRow = rows.at(-1);
847
+ if (!visible && lastRow !== undefined && lastRow.length && rows.length > 1) {
848
+ rows[rows.length - 2] += rows.pop();
849
+ }
850
+ }, stringVisibleTrimSpacesRight = (string) => {
851
+ const words = string.split(" ");
852
+ let last = words.length;
853
+ while (last) {
854
+ if (dist_default2(words[last - 1])) {
855
+ break;
856
+ }
857
+ last--;
858
+ }
859
+ if (last === words.length) {
860
+ return string;
861
+ }
862
+ return words.slice(0, last).join(" ") + words.slice(last).join("");
863
+ }, exec = (string, columns, options = {}) => {
864
+ if (options.trim !== false && string.trim() === "") {
865
+ return "";
866
+ }
867
+ let returnValue = "";
868
+ let escapeCode;
869
+ let escapeUrl;
870
+ const words = string.split(" ");
871
+ let rows = [""];
872
+ let rowLength = 0;
873
+ for (let index = 0;index < words.length; index++) {
874
+ const word = words[index];
875
+ if (options.trim !== false) {
876
+ const row = rows.at(-1) ?? "";
877
+ const trimmed = row.trimStart();
878
+ if (row.length !== trimmed.length) {
879
+ rows[rows.length - 1] = trimmed;
880
+ rowLength = dist_default2(trimmed);
881
+ }
882
+ }
883
+ if (index !== 0) {
884
+ if (rowLength >= columns && (options.wordWrap === false || options.trim === false)) {
885
+ rows.push("");
886
+ rowLength = 0;
887
+ }
888
+ if (rowLength || options.trim === false) {
889
+ rows[rows.length - 1] += " ";
890
+ rowLength++;
891
+ }
892
+ }
893
+ const wordLength = dist_default2(word);
894
+ if (options.hard && wordLength > columns) {
895
+ const remainingColumns = columns - rowLength;
896
+ const breaksStartingThisLine = 1 + Math.floor((wordLength - remainingColumns - 1) / columns);
897
+ const breaksStartingNextLine = Math.floor((wordLength - 1) / columns);
898
+ if (breaksStartingNextLine < breaksStartingThisLine) {
899
+ rows.push("");
900
+ }
901
+ wrapWord(rows, word, columns);
902
+ rowLength = dist_default2(rows.at(-1) ?? "");
903
+ continue;
904
+ }
905
+ if (rowLength + wordLength > columns && rowLength && wordLength) {
906
+ if (options.wordWrap === false && rowLength < columns) {
907
+ wrapWord(rows, word, columns);
908
+ rowLength = dist_default2(rows.at(-1) ?? "");
909
+ continue;
910
+ }
911
+ rows.push("");
912
+ rowLength = 0;
913
+ }
914
+ if (rowLength + wordLength > columns && options.wordWrap === false) {
915
+ wrapWord(rows, word, columns);
916
+ rowLength = dist_default2(rows.at(-1) ?? "");
917
+ continue;
918
+ }
919
+ rows[rows.length - 1] += word;
920
+ rowLength += wordLength;
921
+ }
922
+ if (options.trim !== false) {
923
+ rows = rows.map((row) => stringVisibleTrimSpacesRight(row));
924
+ }
925
+ const preString = rows.join(`
926
+ `);
927
+ let inSurrogate = false;
928
+ for (let i = 0;i < preString.length; i++) {
929
+ const character = preString[i];
930
+ returnValue += character;
931
+ if (!inSurrogate) {
932
+ inSurrogate = character >= "\uD800" && character <= "\uDBFF";
933
+ } else {
934
+ continue;
935
+ }
936
+ if (character === ESC || character === CSI) {
937
+ GROUP_REGEX.lastIndex = i + 1;
938
+ const groupsResult = GROUP_REGEX.exec(preString);
939
+ const groups = groupsResult?.groups;
940
+ if (groups?.code !== undefined) {
941
+ const code = Number.parseFloat(groups.code);
942
+ escapeCode = code === END_CODE ? undefined : code;
943
+ } else if (groups?.uri !== undefined) {
944
+ escapeUrl = groups.uri.length === 0 ? undefined : groups.uri;
945
+ }
946
+ }
947
+ if (preString[i + 1] === `
948
+ `) {
949
+ if (escapeUrl) {
950
+ returnValue += wrapAnsiHyperlink("");
951
+ }
952
+ const closingCode = escapeCode ? getClosingCode(escapeCode) : undefined;
953
+ if (escapeCode && closingCode) {
954
+ returnValue += wrapAnsiCode(closingCode);
955
+ }
956
+ } else if (character === `
957
+ `) {
958
+ if (escapeCode && getClosingCode(escapeCode)) {
959
+ returnValue += wrapAnsiCode(escapeCode);
960
+ }
961
+ if (escapeUrl) {
962
+ returnValue += wrapAnsiHyperlink(escapeUrl);
963
+ }
964
+ }
965
+ }
966
+ return returnValue;
967
+ }, CRLF_OR_LF;
968
+ var init_main = __esm(() => {
969
+ init_dist3();
970
+ ANSI_ESCAPE_LINK = `${ANSI_OSC}8;;`;
971
+ GROUP_REGEX = new RegExp(`(?:\\${ANSI_CSI}(?<code>\\d+)m|\\${ANSI_ESCAPE_LINK}(?<uri>.*)${ANSI_ESCAPE_BELL})`, "y");
972
+ CRLF_OR_LF = /\r?\n/;
973
+ });
974
+
975
+ // ../../node_modules/.bun/sisteransi@1.0.5/node_modules/sisteransi/src/index.js
976
+ var require_src = __commonJS((exports, module) => {
977
+ var ESC2 = "\x1B";
978
+ var CSI2 = `${ESC2}[`;
979
+ var beep = "\x07";
980
+ var cursor = {
981
+ to(x, y) {
982
+ if (!y)
983
+ return `${CSI2}${x + 1}G`;
984
+ return `${CSI2}${y + 1};${x + 1}H`;
985
+ },
986
+ move(x, y) {
987
+ let ret = "";
988
+ if (x < 0)
989
+ ret += `${CSI2}${-x}D`;
990
+ else if (x > 0)
991
+ ret += `${CSI2}${x}C`;
992
+ if (y < 0)
993
+ ret += `${CSI2}${-y}A`;
994
+ else if (y > 0)
995
+ ret += `${CSI2}${y}B`;
996
+ return ret;
997
+ },
998
+ up: (count = 1) => `${CSI2}${count}A`,
999
+ down: (count = 1) => `${CSI2}${count}B`,
1000
+ forward: (count = 1) => `${CSI2}${count}C`,
1001
+ backward: (count = 1) => `${CSI2}${count}D`,
1002
+ nextLine: (count = 1) => `${CSI2}E`.repeat(count),
1003
+ prevLine: (count = 1) => `${CSI2}F`.repeat(count),
1004
+ left: `${CSI2}G`,
1005
+ hide: `${CSI2}?25l`,
1006
+ show: `${CSI2}?25h`,
1007
+ save: `${ESC2}7`,
1008
+ restore: `${ESC2}8`
1009
+ };
1010
+ var scroll = {
1011
+ up: (count = 1) => `${CSI2}S`.repeat(count),
1012
+ down: (count = 1) => `${CSI2}T`.repeat(count)
1013
+ };
1014
+ var erase = {
1015
+ screen: `${CSI2}2J`,
1016
+ up: (count = 1) => `${CSI2}1J`.repeat(count),
1017
+ down: (count = 1) => `${CSI2}J`.repeat(count),
1018
+ line: `${CSI2}2K`,
1019
+ lineEnd: `${CSI2}K`,
1020
+ lineStart: `${CSI2}1K`,
1021
+ lines(count) {
1022
+ let clear = "";
1023
+ for (let i = 0;i < count; i++)
1024
+ clear += this.line + (i < count - 1 ? cursor.up() : "");
1025
+ if (count)
1026
+ clear += cursor.left;
1027
+ return clear;
1028
+ }
1029
+ };
1030
+ module.exports = { cursor, scroll, erase, beep };
1031
+ });
1032
+
1033
+ // ../../node_modules/.bun/@clack+core@1.2.0/node_modules/@clack/core/dist/index.mjs
1034
+ import { styleText as y } from "node:util";
1035
+ import { stdout as S, stdin as $ } from "node:process";
1036
+ import P from "node:readline";
1037
+ function d(r, t, e) {
1038
+ if (!e.some((o) => !o.disabled))
1039
+ return r;
1040
+ const s = r + t, i = Math.max(e.length - 1, 0), n = s < 0 ? i : s > i ? 0 : s;
1041
+ return e[n].disabled ? d(n, t < 0 ? -1 : 1, e) : n;
1042
+ }
1043
+ function V(r, t) {
1044
+ if (typeof r == "string")
1045
+ return u.aliases.get(r) === t;
1046
+ for (const e of r)
1047
+ if (e !== undefined && V(e, t))
1048
+ return true;
1049
+ return false;
1050
+ }
1051
+ function j(r, t) {
1052
+ if (r === t)
1053
+ return;
1054
+ const e = r.split(`
1055
+ `), s = t.split(`
1056
+ `), i = Math.max(e.length, s.length), n = [];
1057
+ for (let o = 0;o < i; o++)
1058
+ e[o] !== s[o] && n.push(o);
1059
+ return { lines: n, numLinesBefore: e.length, numLinesAfter: s.length, numLines: i };
1060
+ }
1061
+ function q(r) {
1062
+ return r === C;
1063
+ }
1064
+ function w(r, t) {
1065
+ const e = r;
1066
+ e.isTTY && e.setRawMode(t);
1067
+ }
1068
+ function W(r, t) {
1069
+ if (r === undefined || t.length === 0)
1070
+ return 0;
1071
+ const e = t.findIndex((s) => s.value === r);
1072
+ return e !== -1 ? e : 0;
1073
+ }
1074
+ function B(r, t) {
1075
+ return (t.label ?? String(t.value)).toLowerCase().includes(r.toLowerCase());
1076
+ }
1077
+ function J(r, t) {
1078
+ if (t)
1079
+ return r ? t : t[0];
1080
+ }
1081
+ function L(r) {
1082
+ return [...r].map((t) => X[t]);
1083
+ }
1084
+ function Z(r) {
1085
+ const t = new Intl.DateTimeFormat(r, { year: "numeric", month: "2-digit", day: "2-digit" }).formatToParts(new Date(2000, 0, 15)), e = [];
1086
+ let s = "/";
1087
+ for (const i of t)
1088
+ i.type === "literal" ? s = i.value.trim() || i.value : (i.type === "year" || i.type === "month" || i.type === "day") && e.push({ type: i.type, len: i.type === "year" ? 4 : 2 });
1089
+ return { segments: e, separator: s };
1090
+ }
1091
+ function k(r) {
1092
+ return Number.parseInt((r || "0").replace(/_/g, "0"), 10) || 0;
1093
+ }
1094
+ function I(r) {
1095
+ return { year: k(r.year), month: k(r.month), day: k(r.day) };
1096
+ }
1097
+ function T(r, t) {
1098
+ return new Date(r || 2001, t || 1, 0).getDate();
1099
+ }
1100
+ function F(r) {
1101
+ const { year: t, month: e, day: s } = I(r);
1102
+ if (!t || t < 0 || t > 9999 || !e || e < 1 || e > 12 || !s || s < 1)
1103
+ return;
1104
+ const i = new Date(Date.UTC(t, e - 1, s));
1105
+ if (!(i.getUTCFullYear() !== t || i.getUTCMonth() !== e - 1 || i.getUTCDate() !== s))
1106
+ return { year: t, month: e, day: s };
1107
+ }
1108
+ function N(r) {
1109
+ const t = F(r);
1110
+ return t ? new Date(Date.UTC(t.year, t.month - 1, t.day)) : undefined;
1111
+ }
1112
+ function tt(r, t, e, s) {
1113
+ const i = e ? { year: e.getUTCFullYear(), month: e.getUTCMonth() + 1, day: e.getUTCDate() } : null, n = s ? { year: s.getUTCFullYear(), month: s.getUTCMonth() + 1, day: s.getUTCDate() } : null;
1114
+ return r === "year" ? { min: i?.year ?? 1, max: n?.year ?? 9999 } : r === "month" ? { min: i && t.year === i.year ? i.month : 1, max: n && t.year === n.year ? n.month : 12 } : { min: i && t.year === i.year && t.month === i.month ? i.day : 1, max: n && t.year === n.year && t.month === n.month ? n.day : T(t.year, t.month) };
1115
+ }
1116
+ var import_sisteransi, E, G, u, Y, C, A = (r) => ("rows" in r) && typeof r.rows == "number" ? r.rows : 20, p = class {
1117
+ input;
1118
+ output;
1119
+ _abortSignal;
1120
+ rl;
1121
+ opts;
1122
+ _render;
1123
+ _track = false;
1124
+ _prevFrame = "";
1125
+ _subscribers = new Map;
1126
+ _cursor = 0;
1127
+ state = "initial";
1128
+ error = "";
1129
+ value;
1130
+ userInput = "";
1131
+ constructor(t, e = true) {
1132
+ const { input: s = $, output: i = S, render: n, signal: o, ...a } = t;
1133
+ 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 = e, this._abortSignal = o, this.input = s, this.output = i;
1134
+ }
1135
+ unsubscribe() {
1136
+ this._subscribers.clear();
1137
+ }
1138
+ setSubscriber(t, e) {
1139
+ const s = this._subscribers.get(t) ?? [];
1140
+ s.push(e), this._subscribers.set(t, s);
1141
+ }
1142
+ on(t, e) {
1143
+ this.setSubscriber(t, { cb: e });
1144
+ }
1145
+ once(t, e) {
1146
+ this.setSubscriber(t, { cb: e, once: true });
1147
+ }
1148
+ emit(t, ...e) {
1149
+ const s = this._subscribers.get(t) ?? [], i = [];
1150
+ for (const n of s)
1151
+ n.cb(...e), n.once && i.push(() => s.splice(s.indexOf(n), 1));
1152
+ for (const n of i)
1153
+ n();
1154
+ }
1155
+ prompt() {
1156
+ return new Promise((t) => {
1157
+ if (this._abortSignal) {
1158
+ if (this._abortSignal.aborted)
1159
+ return this.state = "cancel", this.close(), t(C);
1160
+ this._abortSignal.addEventListener("abort", () => {
1161
+ this.state = "cancel", this.close();
1162
+ }, { once: true });
1163
+ }
1164
+ this.rl = P.createInterface({ input: this.input, tabSize: 2, prompt: "", escapeCodeTimeout: 50, terminal: true }), this.rl.prompt(), this.opts.initialUserInput !== undefined && this._setUserInput(this.opts.initialUserInput, true), this.input.on("keypress", this.onKeypress), w(this.input, true), this.output.on("resize", this.render), this.render(), this.once("submit", () => {
1165
+ this.output.write(import_sisteransi.cursor.show), this.output.off("resize", this.render), w(this.input, false), t(this.value);
1166
+ }), this.once("cancel", () => {
1167
+ this.output.write(import_sisteransi.cursor.show), this.output.off("resize", this.render), w(this.input, false), t(C);
1168
+ });
1169
+ });
1170
+ }
1171
+ _isActionKey(t, e) {
1172
+ return t === "\t";
1173
+ }
1174
+ _setValue(t) {
1175
+ this.value = t, this.emit("value", this.value);
1176
+ }
1177
+ _setUserInput(t, e) {
1178
+ this.userInput = t ?? "", this.emit("userInput", this.userInput), e && this._track && this.rl && (this.rl.write(this.userInput), this._cursor = this.rl.cursor);
1179
+ }
1180
+ _clearUserInput() {
1181
+ this.rl?.write(null, { ctrl: true, name: "u" }), this._setUserInput("");
1182
+ }
1183
+ onKeypress(t, e) {
1184
+ if (this._track && e.name !== "return" && (e.name && this._isActionKey(t, e) && 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"), e?.name && (!this._track && u.aliases.has(e.name) && this.emit("cursor", u.aliases.get(e.name)), u.actions.has(e.name) && this.emit("cursor", e.name)), t && (t.toLowerCase() === "y" || t.toLowerCase() === "n") && this.emit("confirm", t.toLowerCase() === "y"), this.emit("key", t?.toLowerCase(), e), e?.name === "return") {
1185
+ if (this.opts.validate) {
1186
+ const s = this.opts.validate(this.value);
1187
+ s && (this.error = s instanceof Error ? s.message : s, this.state = "error", this.rl?.write(this.userInput));
1188
+ }
1189
+ this.state !== "error" && (this.state = "submit");
1190
+ }
1191
+ V([t, e?.name, e?.sequence], "cancel") && (this.state = "cancel"), (this.state === "submit" || this.state === "cancel") && this.emit("finalize"), this.render(), (this.state === "submit" || this.state === "cancel") && this.close();
1192
+ }
1193
+ close() {
1194
+ this.input.unpipe(), this.input.removeListener("keypress", this.onKeypress), this.output.write(`
1195
+ `), w(this.input, false), this.rl?.close(), this.rl = undefined, this.emit(`${this.state}`, this.value), this.unsubscribe();
1196
+ }
1197
+ restoreCursor() {
1198
+ const t = wrapAnsi(this._prevFrame, process.stdout.columns, { hard: true, trim: false }).split(`
1199
+ `).length - 1;
1200
+ this.output.write(import_sisteransi.cursor.move(-999, t * -1));
1201
+ }
1202
+ render() {
1203
+ const t = wrapAnsi(this._render(this) ?? "", process.stdout.columns, { hard: true, trim: false });
1204
+ if (t !== this._prevFrame) {
1205
+ if (this.state === "initial")
1206
+ this.output.write(import_sisteransi.cursor.hide);
1207
+ else {
1208
+ const e = j(this._prevFrame, t), s = A(this.output);
1209
+ if (this.restoreCursor(), e) {
1210
+ const i = Math.max(0, e.numLinesAfter - s), n = Math.max(0, e.numLinesBefore - s);
1211
+ let o = e.lines.find((a) => a >= i);
1212
+ if (o === undefined) {
1213
+ this._prevFrame = t;
1214
+ return;
1215
+ }
1216
+ if (e.lines.length === 1) {
1217
+ this.output.write(import_sisteransi.cursor.move(0, o - n)), this.output.write(import_sisteransi.erase.lines(1));
1218
+ const a = t.split(`
1219
+ `);
1220
+ this.output.write(a[o]), this._prevFrame = t, this.output.write(import_sisteransi.cursor.move(0, a.length - o - 1));
1221
+ return;
1222
+ } else if (e.lines.length > 1) {
1223
+ if (i < n)
1224
+ o = i;
1225
+ else {
1226
+ const h = o - n;
1227
+ h > 0 && this.output.write(import_sisteransi.cursor.move(0, h));
1228
+ }
1229
+ this.output.write(import_sisteransi.erase.down());
1230
+ const a = t.split(`
1231
+ `).slice(o);
1232
+ this.output.write(a.join(`
1233
+ `)), this._prevFrame = t;
1234
+ return;
1235
+ }
1236
+ }
1237
+ this.output.write(import_sisteransi.erase.down());
1238
+ }
1239
+ this.output.write(t), this.state === "initial" && (this.state = "active"), this._prevFrame = t;
1240
+ }
1241
+ }
1242
+ }, H, X, et, st, at;
1243
+ var init_dist4 = __esm(() => {
1244
+ init_main();
1245
+ import_sisteransi = __toESM(require_src(), 1);
1246
+ E = ["up", "down", "left", "right", "space", "enter", "cancel"];
1247
+ G = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"];
1248
+ u = { actions: new Set(E), aliases: new Map([["k", "up"], ["j", "down"], ["h", "left"], ["l", "right"], ["\x03", "cancel"], ["escape", "cancel"]]), messages: { cancel: "Canceled", error: "Something went wrong" }, withGuide: true, date: { monthNames: [...G], messages: { required: "Please enter a valid date", invalidMonth: "There are only 12 months in a year", invalidDay: (r, t) => `There are only ${r} days in ${t}`, afterMin: (r) => `Date must be on or after ${r.toISOString().slice(0, 10)}`, beforeMax: (r) => `Date must be on or before ${r.toISOString().slice(0, 10)}` } } };
1249
+ Y = globalThis.process.platform.startsWith("win");
1250
+ C = Symbol("clack:cancel");
1251
+ H = class extends p {
1252
+ filteredOptions;
1253
+ multiple;
1254
+ isNavigating = false;
1255
+ selectedValues = [];
1256
+ focusedValue;
1257
+ #e = 0;
1258
+ #o = "";
1259
+ #t;
1260
+ #n;
1261
+ #a;
1262
+ get cursor() {
1263
+ return this.#e;
1264
+ }
1265
+ get userInputWithCursor() {
1266
+ if (!this.userInput)
1267
+ return y(["inverse", "hidden"], "_");
1268
+ if (this._cursor >= this.userInput.length)
1269
+ return `${this.userInput}█`;
1270
+ const t = this.userInput.slice(0, this._cursor), [e, ...s] = this.userInput.slice(this._cursor);
1271
+ return `${t}${y("inverse", e)}${s.join("")}`;
1272
+ }
1273
+ get options() {
1274
+ return typeof this.#n == "function" ? this.#n() : this.#n;
1275
+ }
1276
+ constructor(t) {
1277
+ super(t), this.#n = t.options, this.#a = t.placeholder;
1278
+ const e = this.options;
1279
+ this.filteredOptions = [...e], this.multiple = t.multiple === true, this.#t = typeof t.options == "function" ? t.filter : t.filter ?? B;
1280
+ let s;
1281
+ if (t.initialValue && Array.isArray(t.initialValue) ? this.multiple ? s = t.initialValue : s = t.initialValue.slice(0, 1) : !this.multiple && this.options.length > 0 && (s = [this.options[0].value]), s)
1282
+ for (const i of s) {
1283
+ const n = e.findIndex((o) => o.value === i);
1284
+ n !== -1 && (this.toggleSelected(i), this.#e = n);
1285
+ }
1286
+ this.focusedValue = this.options[this.#e]?.value, this.on("key", (i, n) => this.#s(i, n)), this.on("userInput", (i) => this.#i(i));
1287
+ }
1288
+ _isActionKey(t, e) {
1289
+ return t === "\t" || this.multiple && this.isNavigating && e.name === "space" && t !== undefined && t !== "";
1290
+ }
1291
+ #s(t, e) {
1292
+ const s = e.name === "up", i = e.name === "down", n = e.name === "return", o = this.userInput === "" || this.userInput === "\t", a = this.#a, h = this.options, l = a !== undefined && a !== "" && h.some((f) => !f.disabled && (this.#t ? this.#t(a, f) : true));
1293
+ if (e.name === "tab" && o && l) {
1294
+ this.userInput === "\t" && this._clearUserInput(), this._setUserInput(a, true), this.isNavigating = false;
1295
+ return;
1296
+ }
1297
+ s || i ? (this.#e = d(this.#e, s ? -1 : 1, this.filteredOptions), this.focusedValue = this.filteredOptions[this.#e]?.value, this.multiple || (this.selectedValues = [this.focusedValue]), this.isNavigating = true) : n ? this.value = J(this.multiple, this.selectedValues) : this.multiple ? this.focusedValue !== undefined && (e.name === "tab" || this.isNavigating && e.name === "space") ? this.toggleSelected(this.focusedValue) : this.isNavigating = false : (this.focusedValue && (this.selectedValues = [this.focusedValue]), this.isNavigating = false);
1298
+ }
1299
+ deselectAll() {
1300
+ this.selectedValues = [];
1301
+ }
1302
+ toggleSelected(t) {
1303
+ this.filteredOptions.length !== 0 && (this.multiple ? this.selectedValues.includes(t) ? this.selectedValues = this.selectedValues.filter((e) => e !== t) : this.selectedValues = [...this.selectedValues, t] : this.selectedValues = [t]);
1304
+ }
1305
+ #i(t) {
1306
+ if (t !== this.#o) {
1307
+ this.#o = t;
1308
+ const e = this.options;
1309
+ t && this.#t ? this.filteredOptions = e.filter((n) => this.#t?.(t, n)) : this.filteredOptions = [...e];
1310
+ const s = W(this.focusedValue, this.filteredOptions);
1311
+ this.#e = d(s, 0, this.filteredOptions);
1312
+ const i = this.filteredOptions[this.#e];
1313
+ i && !i.disabled ? this.focusedValue = i.value : this.focusedValue = undefined, this.multiple || (this.focusedValue !== undefined ? this.toggleSelected(this.focusedValue) : this.deselectAll());
1314
+ }
1315
+ }
1316
+ };
1317
+ X = { Y: { type: "year", len: 4 }, M: { type: "month", len: 2 }, D: { type: "day", len: 2 } };
1318
+ et = class et extends p {
1319
+ #e;
1320
+ #o;
1321
+ #t;
1322
+ #n;
1323
+ #a;
1324
+ #s = { segmentIndex: 0, positionInSegment: 0 };
1325
+ #i = true;
1326
+ #r = null;
1327
+ inlineError = "";
1328
+ get segmentCursor() {
1329
+ return { ...this.#s };
1330
+ }
1331
+ get segmentValues() {
1332
+ return { ...this.#t };
1333
+ }
1334
+ get segments() {
1335
+ return this.#e;
1336
+ }
1337
+ get separator() {
1338
+ return this.#o;
1339
+ }
1340
+ get formattedValue() {
1341
+ return this.#c(this.#t);
72
1342
  }
73
- console.log("Done!");
1343
+ #c(t) {
1344
+ return this.#e.map((e) => t[e.type]).join(this.#o);
1345
+ }
1346
+ #h() {
1347
+ this._setUserInput(this.#c(this.#t)), this._setValue(N(this.#t) ?? undefined);
1348
+ }
1349
+ constructor(t) {
1350
+ const e = t.format ? { segments: L(t.format), separator: t.separator ?? "/" } : Z(t.locale), s = t.separator ?? e.separator, i = t.format ? L(t.format) : e.segments, n = t.initialValue ?? t.defaultValue, o = n ? { year: String(n.getUTCFullYear()).padStart(4, "0"), month: String(n.getUTCMonth() + 1).padStart(2, "0"), day: String(n.getUTCDate()).padStart(2, "0") } : { year: "____", month: "__", day: "__" }, a = i.map((h) => o[h.type]).join(s);
1351
+ super({ ...t, initialUserInput: a }, false), this.#e = i, this.#o = s, this.#t = o, this.#n = t.minDate, this.#a = t.maxDate, this.#h(), this.on("cursor", (h) => this.#d(h)), this.on("key", (h, l) => this.#f(h, l)), this.on("finalize", () => this.#g(t));
1352
+ }
1353
+ #u() {
1354
+ const t = Math.max(0, Math.min(this.#s.segmentIndex, this.#e.length - 1)), e = this.#e[t];
1355
+ if (e)
1356
+ return this.#s.positionInSegment = Math.max(0, Math.min(this.#s.positionInSegment, e.len - 1)), { segment: e, index: t };
1357
+ }
1358
+ #l(t) {
1359
+ this.inlineError = "", this.#r = null;
1360
+ const e = this.#u();
1361
+ e && (this.#s.segmentIndex = Math.max(0, Math.min(this.#e.length - 1, e.index + t)), this.#s.positionInSegment = 0, this.#i = true);
1362
+ }
1363
+ #p(t) {
1364
+ const e = this.#u();
1365
+ if (!e)
1366
+ return;
1367
+ const { segment: s } = e, i = this.#t[s.type], n = !i || i.replace(/_/g, "") === "", o = Number.parseInt((i || "0").replace(/_/g, "0"), 10) || 0, a = tt(s.type, I(this.#t), this.#n, this.#a);
1368
+ let h;
1369
+ n ? h = t === 1 ? a.min : a.max : h = Math.max(Math.min(a.max, o + t), a.min), this.#t = { ...this.#t, [s.type]: h.toString().padStart(s.len, "0") }, this.#i = true, this.#r = null, this.#h();
1370
+ }
1371
+ #d(t) {
1372
+ if (t)
1373
+ switch (t) {
1374
+ case "right":
1375
+ return this.#l(1);
1376
+ case "left":
1377
+ return this.#l(-1);
1378
+ case "up":
1379
+ return this.#p(1);
1380
+ case "down":
1381
+ return this.#p(-1);
1382
+ }
1383
+ }
1384
+ #f(t, e) {
1385
+ if (e?.name === "backspace" || e?.sequence === "" || e?.sequence === "\b" || t === "" || t === "\b") {
1386
+ this.inlineError = "";
1387
+ const s = this.#u();
1388
+ if (!s)
1389
+ return;
1390
+ if (!this.#t[s.segment.type].replace(/_/g, "")) {
1391
+ this.#l(-1);
1392
+ return;
1393
+ }
1394
+ this.#t[s.segment.type] = "_".repeat(s.segment.len), this.#i = true, this.#s.positionInSegment = 0, this.#h();
1395
+ return;
1396
+ }
1397
+ if (e?.name === "tab") {
1398
+ this.inlineError = "";
1399
+ const s = this.#u();
1400
+ if (!s)
1401
+ return;
1402
+ const i = e.shift ? -1 : 1, n = s.index + i;
1403
+ n >= 0 && n < this.#e.length && (this.#s.segmentIndex = n, this.#s.positionInSegment = 0, this.#i = true);
1404
+ return;
1405
+ }
1406
+ if (t && /^[0-9]$/.test(t)) {
1407
+ const s = this.#u();
1408
+ if (!s)
1409
+ return;
1410
+ const { segment: i } = s, n = !this.#t[i.type].replace(/_/g, "");
1411
+ if (this.#i && this.#r !== null && !n) {
1412
+ const m = this.#r + t, g = { ...this.#t, [i.type]: m }, b = this.#m(g, i);
1413
+ if (b) {
1414
+ this.inlineError = b, this.#r = null, this.#i = false;
1415
+ return;
1416
+ }
1417
+ this.inlineError = "", this.#t[i.type] = m, this.#r = null, this.#i = false, this.#h(), s.index < this.#e.length - 1 && (this.#s.segmentIndex = s.index + 1, this.#s.positionInSegment = 0, this.#i = true);
1418
+ return;
1419
+ }
1420
+ this.#i && !n && (this.#t[i.type] = "_".repeat(i.len), this.#s.positionInSegment = 0), this.#i = false, this.#r = null;
1421
+ const o = this.#t[i.type], a = o.indexOf("_"), h = a >= 0 ? a : Math.min(this.#s.positionInSegment, i.len - 1);
1422
+ if (h < 0 || h >= i.len)
1423
+ return;
1424
+ let l = o.slice(0, h) + t + o.slice(h + 1), f = false;
1425
+ if (h === 0 && o === "__" && (i.type === "month" || i.type === "day")) {
1426
+ const m = Number.parseInt(t, 10);
1427
+ l = `0${t}`, f = m <= (i.type === "month" ? 1 : 2);
1428
+ }
1429
+ if (i.type === "year" && (l = (o.replace(/_/g, "") + t).padStart(i.len, "_")), !l.includes("_")) {
1430
+ const m = { ...this.#t, [i.type]: l }, g = this.#m(m, i);
1431
+ if (g) {
1432
+ this.inlineError = g;
1433
+ return;
1434
+ }
1435
+ }
1436
+ this.inlineError = "", this.#t[i.type] = l;
1437
+ const v = l.includes("_") ? undefined : F(this.#t);
1438
+ if (v) {
1439
+ const { year: m, month: g } = v, b = T(m, g);
1440
+ this.#t = { year: String(Math.max(0, Math.min(9999, m))).padStart(4, "0"), month: String(Math.max(1, Math.min(12, g))).padStart(2, "0"), day: String(Math.max(1, Math.min(b, v.day))).padStart(2, "0") };
1441
+ }
1442
+ this.#h();
1443
+ const U = l.indexOf("_");
1444
+ f ? (this.#i = true, this.#r = t) : U >= 0 ? this.#s.positionInSegment = U : a >= 0 && s.index < this.#e.length - 1 ? (this.#s.segmentIndex = s.index + 1, this.#s.positionInSegment = 0, this.#i = true) : this.#s.positionInSegment = Math.min(h + 1, i.len - 1);
1445
+ }
1446
+ }
1447
+ #m(t, e) {
1448
+ const { month: s, day: i } = I(t);
1449
+ if (e.type === "month" && (s < 0 || s > 12))
1450
+ return u.date.messages.invalidMonth;
1451
+ if (e.type === "day" && (i < 0 || i > 31))
1452
+ return u.date.messages.invalidDay(31, "any month");
1453
+ }
1454
+ #g(t) {
1455
+ const { year: e, month: s, day: i } = I(this.#t);
1456
+ if (e && s && i) {
1457
+ const n = T(e, s);
1458
+ this.#t = { ...this.#t, day: String(Math.min(i, n)).padStart(2, "0") };
1459
+ }
1460
+ this.value = N(this.#t) ?? t.defaultValue ?? undefined;
1461
+ }
1462
+ };
1463
+ st = class st extends p {
1464
+ options;
1465
+ cursor = 0;
1466
+ #e;
1467
+ getGroupItems(t) {
1468
+ return this.options.filter((e) => e.group === t);
1469
+ }
1470
+ isGroupSelected(t) {
1471
+ const e = this.getGroupItems(t), s = this.value;
1472
+ return s === undefined ? false : e.every((i) => s.includes(i.value));
1473
+ }
1474
+ toggleValue() {
1475
+ const t = this.options[this.cursor];
1476
+ if (this.value === undefined && (this.value = []), t.group === true) {
1477
+ const e = t.value, s = this.getGroupItems(e);
1478
+ this.isGroupSelected(e) ? this.value = this.value.filter((i) => s.findIndex((n) => n.value === i) === -1) : this.value = [...this.value, ...s.map((i) => i.value)], this.value = Array.from(new Set(this.value));
1479
+ } else {
1480
+ const e = this.value.includes(t.value);
1481
+ this.value = e ? this.value.filter((s) => s !== t.value) : [...this.value, t.value];
1482
+ }
1483
+ }
1484
+ constructor(t) {
1485
+ super(t, false);
1486
+ const { options: e } = t;
1487
+ this.#e = t.selectableGroups !== false, this.options = Object.entries(e).flatMap(([s, i]) => [{ value: s, group: true, label: s }, ...i.map((n) => ({ ...n, group: s }))]), this.value = [...t.initialValues ?? []], this.cursor = Math.max(this.options.findIndex(({ value: s }) => s === t.cursorAt), this.#e ? 0 : 1), this.on("cursor", (s) => {
1488
+ switch (s) {
1489
+ case "left":
1490
+ case "up": {
1491
+ this.cursor = this.cursor === 0 ? this.options.length - 1 : this.cursor - 1;
1492
+ const i = this.options[this.cursor]?.group === true;
1493
+ !this.#e && i && (this.cursor = this.cursor === 0 ? this.options.length - 1 : this.cursor - 1);
1494
+ break;
1495
+ }
1496
+ case "down":
1497
+ case "right": {
1498
+ this.cursor = this.cursor === this.options.length - 1 ? 0 : this.cursor + 1;
1499
+ const i = this.options[this.cursor]?.group === true;
1500
+ !this.#e && i && (this.cursor = this.cursor === this.options.length - 1 ? 0 : this.cursor + 1);
1501
+ break;
1502
+ }
1503
+ case "space":
1504
+ this.toggleValue();
1505
+ break;
1506
+ }
1507
+ });
1508
+ }
1509
+ };
1510
+ at = class at extends p {
1511
+ get userInputWithCursor() {
1512
+ if (this.state === "submit")
1513
+ return this.userInput;
1514
+ const t = this.userInput;
1515
+ if (this.cursor >= t.length)
1516
+ return `${this.userInput}█`;
1517
+ const e = t.slice(0, this.cursor), [s, ...i] = t.slice(this.cursor);
1518
+ return `${e}${y("inverse", s)}${i.join("")}`;
1519
+ }
1520
+ get cursor() {
1521
+ return this._cursor;
1522
+ }
1523
+ constructor(t) {
1524
+ super({ ...t, initialUserInput: t.initialUserInput ?? t.initialValue }), this.on("userInput", (e) => {
1525
+ this._setValue(e);
1526
+ }), this.on("finalize", () => {
1527
+ this.value || (this.value = t.defaultValue), this.value === undefined && (this.value = "");
1528
+ });
1529
+ }
1530
+ };
1531
+ });
1532
+
1533
+ // ../../node_modules/.bun/@clack+prompts@1.2.0/node_modules/@clack/prompts/dist/index.mjs
1534
+ import { styleText as t, stripVTControlCharacters as ne } from "node:util";
1535
+ import P2 from "node:process";
1536
+ function Ze() {
1537
+ return P2.platform !== "win32" ? P2.env.TERM !== "linux" : !!P2.env.CI || !!P2.env.WT_SESSION || !!P2.env.TERMINUS_SUBLIME || P2.env.ConEmuTask === "{cmd::Cmder}" || P2.env.TERM_PROGRAM === "Terminus-Sublime" || P2.env.TERM_PROGRAM === "vscode" || P2.env.TERM === "xterm-256color" || P2.env.TERM === "alacritty" || P2.env.TERMINAL_EMULATOR === "JetBrains-JediTerm";
1538
+ }
1539
+ var import_sisteransi2, ee, w2 = (e, i) => ee ? e : i, _e, oe, ue, F2, le, d2, E2, Ie, Ee, z2, H2, te, U, J2, xe, se, ce, Ge, $e, de, Oe, he, pe, me, ge, V2 = (e) => {
1540
+ switch (e) {
1541
+ case "initial":
1542
+ case "active":
1543
+ return t("cyan", _e);
1544
+ case "cancel":
1545
+ return t("red", oe);
1546
+ case "error":
1547
+ return t("yellow", ue);
1548
+ case "submit":
1549
+ return t("green", F2);
74
1550
  }
1551
+ }, pt = (e = "", i) => {
1552
+ const s = i?.output ?? process.stdout, r = i?.withGuide ?? u.withGuide ? `${t("gray", E2)} ` : "";
1553
+ s.write(`${r}${t("red", e)}
1554
+
1555
+ `);
1556
+ }, mt = (e = "", i) => {
1557
+ const s = i?.output ?? process.stdout, r = i?.withGuide ?? u.withGuide ? `${t("gray", le)} ` : "";
1558
+ s.write(`${r}${e}
1559
+ `);
1560
+ }, gt = (e = "", i) => {
1561
+ const s = i?.output ?? process.stdout, r = i?.withGuide ?? u.withGuide ? `${t("gray", d2)}
1562
+ ${t("gray", E2)} ` : "";
1563
+ s.write(`${r}${e}
1564
+
1565
+ `);
1566
+ }, Ve, je, Ot = (e) => new at({ validate: e.validate, placeholder: e.placeholder, defaultValue: e.defaultValue, initialValue: e.initialValue, output: e.output, signal: e.signal, input: e.input, render() {
1567
+ const i = e?.withGuide ?? u.withGuide, s = `${`${i ? `${t("gray", d2)}
1568
+ ` : ""}${V2(this.state)} `}${e.message}
1569
+ `, r = e.placeholder ? t("inverse", e.placeholder[0]) + t("dim", e.placeholder.slice(1)) : t(["inverse", "hidden"], "_"), u2 = this.userInput ? this.userInputWithCursor : r, n = this.value ?? "";
1570
+ switch (this.state) {
1571
+ case "error": {
1572
+ const o = this.error ? ` ${t("yellow", this.error)}` : "", c2 = i ? `${t("yellow", d2)} ` : "", a = i ? t("yellow", E2) : "";
1573
+ return `${s.trim()}
1574
+ ${c2}${u2}
1575
+ ${a}${o}
1576
+ `;
1577
+ }
1578
+ case "submit": {
1579
+ const o = n ? ` ${t("dim", n)}` : "", c2 = i ? t("gray", d2) : "";
1580
+ return `${s}${c2}${o}`;
1581
+ }
1582
+ case "cancel": {
1583
+ const o = n ? ` ${t(["strikethrough", "dim"], n)}` : "", c2 = i ? t("gray", d2) : "";
1584
+ return `${s}${c2}${o}${n.trim() ? `
1585
+ ${c2}` : ""}`;
1586
+ }
1587
+ default: {
1588
+ const o = i ? `${t("cyan", d2)} ` : "", c2 = i ? t("cyan", E2) : "";
1589
+ return `${s}${o}${u2}
1590
+ ${c2}
1591
+ `;
1592
+ }
1593
+ }
1594
+ } }).prompt();
1595
+ var init_dist5 = __esm(() => {
1596
+ init_dist4();
1597
+ init_dist4();
1598
+ init_main();
1599
+ init_dist3();
1600
+ import_sisteransi2 = __toESM(require_src(), 1);
1601
+ ee = Ze();
1602
+ _e = w2("◆", "*");
1603
+ oe = w2("■", "x");
1604
+ ue = w2("▲", "x");
1605
+ F2 = w2("◇", "o");
1606
+ le = w2("┌", "T");
1607
+ d2 = w2("│", "|");
1608
+ E2 = w2("└", "—");
1609
+ Ie = w2("┐", "T");
1610
+ Ee = w2("┘", "—");
1611
+ z2 = w2("●", ">");
1612
+ H2 = w2("○", " ");
1613
+ te = w2("◻", "[•]");
1614
+ U = w2("◼", "[+]");
1615
+ J2 = w2("◻", "[ ]");
1616
+ xe = w2("▪", "•");
1617
+ se = w2("─", "-");
1618
+ ce = w2("╮", "+");
1619
+ Ge = w2("├", "+");
1620
+ $e = w2("╯", "+");
1621
+ de = w2("╰", "+");
1622
+ Oe = w2("╭", "+");
1623
+ he = w2("●", "•");
1624
+ pe = w2("◆", "*");
1625
+ me = w2("▲", "!");
1626
+ ge = w2("■", "x");
1627
+ Ve = { light: w2("─", "-"), heavy: w2("━", "="), block: w2("█", "#") };
1628
+ je = `${t("gray", d2)} `;
1629
+ });
1630
+
1631
+ // package.json
1632
+ var package_default;
1633
+ var init_package = __esm(() => {
1634
+ package_default = {
1635
+ name: "@itsflower/cli",
1636
+ version: "0.1.5",
1637
+ bin: {
1638
+ flower: "./dist/main.ts"
1639
+ },
1640
+ files: [
1641
+ "dist"
1642
+ ],
1643
+ type: "module",
1644
+ main: "./dist/main.ts",
1645
+ types: "./dist/main.d.ts",
1646
+ exports: {
1647
+ ".": {
1648
+ types: "./dist/main.d.ts",
1649
+ import: "./dist/main.ts"
1650
+ }
1651
+ },
1652
+ scripts: {
1653
+ build: "bun build ./src/main.ts --outdir ./dist --target node",
1654
+ dev: "bun run ./src/main.ts",
1655
+ typecheck: "tsc --noEmit"
1656
+ },
1657
+ dependencies: {
1658
+ "@clack/prompts": "^1.2.0",
1659
+ citty: "^0.2.2"
1660
+ },
1661
+ devDependencies: {
1662
+ "@types/bun": "^1.3.12",
1663
+ typescript: "^6.0.2"
1664
+ }
1665
+ };
75
1666
  });
1667
+
1668
+ // src/utils/prompts.ts
1669
+ function handleCancel(value) {
1670
+ if (q(value)) {
1671
+ pt("Operation cancelled");
1672
+ process.exit(0);
1673
+ }
1674
+ return false;
1675
+ }
1676
+ var init_prompts = __esm(() => {
1677
+ init_dist5();
1678
+ });
1679
+
1680
+ // src/commands/hello.ts
1681
+ var exports_hello = {};
1682
+ __export(exports_hello, {
1683
+ default: () => hello_default
1684
+ });
1685
+ var hello_default;
1686
+ var init_hello = __esm(() => {
1687
+ init_dist();
1688
+ init_dist5();
1689
+ init_prompts();
1690
+ hello_default = defineCommand({
1691
+ meta: {
1692
+ name: "hello",
1693
+ description: "Say hello to someone"
1694
+ },
1695
+ args: {
1696
+ name: {
1697
+ type: "positional",
1698
+ description: "Name to greet",
1699
+ required: false
1700
+ },
1701
+ formal: {
1702
+ type: "boolean",
1703
+ description: "Use formal greeting",
1704
+ alias: "f"
1705
+ }
1706
+ },
1707
+ async run({ args }) {
1708
+ mt("hello");
1709
+ let name = args.name;
1710
+ if (!name) {
1711
+ const result = await Ot({
1712
+ message: "Who would you like to greet?",
1713
+ placeholder: "World"
1714
+ });
1715
+ if (handleCancel(result)) {
1716
+ return;
1717
+ }
1718
+ name = result || "World";
1719
+ }
1720
+ const greeting = args.formal ? "Good day" : "Hello";
1721
+ gt(`${greeting}, ${name}!`);
1722
+ }
1723
+ });
1724
+ });
1725
+
1726
+ // src/commands/version.ts
1727
+ var exports_version = {};
1728
+ __export(exports_version, {
1729
+ default: () => version_default
1730
+ });
1731
+ var version_default;
1732
+ var init_version = __esm(() => {
1733
+ init_dist();
1734
+ init_package();
1735
+ version_default = defineCommand({
1736
+ meta: {
1737
+ name: "version",
1738
+ description: "Display the current version"
1739
+ },
1740
+ run() {
1741
+ console.log(`${package_default.name}@${package_default.version}`);
1742
+ }
1743
+ });
1744
+ });
1745
+
1746
+ // src/main.ts
1747
+ init_dist();
1748
+ init_dist5();
1749
+ init_package();
1750
+
1751
+ // src/commands/index.ts
1752
+ var commands_default = {
1753
+ hello: () => Promise.resolve().then(() => (init_hello(), exports_hello)).then((m) => m.default),
1754
+ version: () => Promise.resolve().then(() => (init_version(), exports_version)).then((m) => m.default)
1755
+ };
1756
+
1757
+ // src/main.ts
76
1758
  var main = defineCommand({
77
1759
  meta: {
78
- name: "flower",
79
- version: "0.1.4",
80
- description: "\u{1F338} flower CLI"
1760
+ name: package_default.name,
1761
+ version: package_default.version,
1762
+ description: "flower - \uD83C\uDF38 Scaffold structured development workflows in your project"
1763
+ },
1764
+ args: {
1765
+ verbose: {
1766
+ type: "boolean",
1767
+ description: "Enable verbose output",
1768
+ alias: "v"
1769
+ }
1770
+ },
1771
+ subCommands: commands_default,
1772
+ setup: ({ args }) => {
1773
+ if (args.verbose) {
1774
+ Bun.env.VERBOSE = "true";
1775
+ }
81
1776
  },
82
- subCommands: {
83
- init
1777
+ run: () => {
1778
+ mt("flower");
1779
+ gt("Use `flower --help` to see available commands");
84
1780
  }
85
1781
  });
86
1782
  runMain(main);