loclaude 0.0.1-alpha.3 → 0.0.3

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.
Files changed (39) hide show
  1. package/CHANGELOG.md +21 -2
  2. package/README.md +152 -64
  3. package/package.json +25 -14
  4. package/libs/cli/CHANGELOG.md +0 -59
  5. package/libs/cli/LICENSE +0 -31
  6. package/libs/cli/README.md +0 -5
  7. package/libs/cli/dist/cac.d.ts +0 -6
  8. package/libs/cli/dist/cac.d.ts.map +0 -1
  9. package/libs/cli/dist/commands/config.d.ts +0 -6
  10. package/libs/cli/dist/commands/config.d.ts.map +0 -1
  11. package/libs/cli/dist/commands/docker.d.ts +0 -17
  12. package/libs/cli/dist/commands/docker.d.ts.map +0 -1
  13. package/libs/cli/dist/commands/doctor.d.ts +0 -9
  14. package/libs/cli/dist/commands/doctor.d.ts.map +0 -1
  15. package/libs/cli/dist/commands/index.d.ts +0 -6
  16. package/libs/cli/dist/commands/index.d.ts.map +0 -1
  17. package/libs/cli/dist/commands/init.d.ts +0 -11
  18. package/libs/cli/dist/commands/init.d.ts.map +0 -1
  19. package/libs/cli/dist/commands/models.d.ts +0 -9
  20. package/libs/cli/dist/commands/models.d.ts.map +0 -1
  21. package/libs/cli/dist/config.d.ts +0 -74
  22. package/libs/cli/dist/config.d.ts.map +0 -1
  23. package/libs/cli/dist/constants.d.ts +0 -12
  24. package/libs/cli/dist/constants.d.ts.map +0 -1
  25. package/libs/cli/dist/index.bun.js +0 -4268
  26. package/libs/cli/dist/index.bun.js.map +0 -55
  27. package/libs/cli/dist/index.d.ts +0 -2
  28. package/libs/cli/dist/index.d.ts.map +0 -1
  29. package/libs/cli/dist/index.js +0 -4271
  30. package/libs/cli/dist/index.js.map +0 -55
  31. package/libs/cli/dist/output.d.ts +0 -107
  32. package/libs/cli/dist/output.d.ts.map +0 -1
  33. package/libs/cli/dist/spawn.d.ts +0 -35
  34. package/libs/cli/dist/spawn.d.ts.map +0 -1
  35. package/libs/cli/dist/types.d.ts +0 -50
  36. package/libs/cli/dist/types.d.ts.map +0 -1
  37. package/libs/cli/dist/utils.d.ts +0 -32
  38. package/libs/cli/dist/utils.d.ts.map +0 -1
  39. package/libs/cli/package.json +0 -90
@@ -1,4271 +0,0 @@
1
- import { createRequire } from "node:module";
2
- var __create = Object.create;
3
- var __getProtoOf = Object.getPrototypeOf;
4
- var __defProp = Object.defineProperty;
5
- var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __hasOwnProp = Object.prototype.hasOwnProperty;
7
- var __toESM = (mod, isNodeMode, target) => {
8
- target = mod != null ? __create(__getProtoOf(mod)) : {};
9
- const to = isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target;
10
- for (let key of __getOwnPropNames(mod))
11
- if (!__hasOwnProp.call(to, key))
12
- __defProp(to, key, {
13
- get: () => mod[key],
14
- enumerable: true
15
- });
16
- return to;
17
- };
18
- var __commonJS = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
19
- var __require = /* @__PURE__ */ createRequire(import.meta.url);
20
-
21
- // ../../node_modules/.bun/cli-width@4.1.0/node_modules/cli-width/index.js
22
- var require_cli_width = __commonJS((exports, module) => {
23
- module.exports = cliWidth;
24
- function normalizeOpts(options) {
25
- const defaultOpts = {
26
- defaultWidth: 0,
27
- output: process.stdout,
28
- tty: __require("tty")
29
- };
30
- if (!options) {
31
- return defaultOpts;
32
- }
33
- Object.keys(defaultOpts).forEach(function(key) {
34
- if (!options[key]) {
35
- options[key] = defaultOpts[key];
36
- }
37
- });
38
- return options;
39
- }
40
- function cliWidth(options) {
41
- const opts = normalizeOpts(options);
42
- if (opts.output.getWindowSize) {
43
- return opts.output.getWindowSize()[0] || opts.defaultWidth;
44
- }
45
- if (opts.tty.getWindowSize) {
46
- return opts.tty.getWindowSize()[1] || opts.defaultWidth;
47
- }
48
- if (opts.output.columns) {
49
- return opts.output.columns;
50
- }
51
- if (process.env.CLI_WIDTH) {
52
- const width = parseInt(process.env.CLI_WIDTH, 10);
53
- if (!isNaN(width) && width !== 0) {
54
- return width;
55
- }
56
- }
57
- return opts.defaultWidth;
58
- }
59
- });
60
-
61
- // ../../node_modules/.bun/emoji-regex@10.6.0/node_modules/emoji-regex/index.js
62
- var require_emoji_regex = __commonJS((exports, module) => {
63
- module.exports = () => {
64
- return /[#*0-9]\uFE0F?\u20E3|[\xA9\xAE\u203C\u2049\u2122\u2139\u2194-\u2199\u21A9\u21AA\u231A\u231B\u2328\u23CF\u23ED-\u23EF\u23F1\u23F2\u23F8-\u23FA\u24C2\u25AA\u25AB\u25B6\u25C0\u25FB\u25FC\u25FE\u2600-\u2604\u260E\u2611\u2614\u2615\u2618\u2620\u2622\u2623\u2626\u262A\u262E\u262F\u2638-\u263A\u2640\u2642\u2648-\u2653\u265F\u2660\u2663\u2665\u2666\u2668\u267B\u267E\u267F\u2692\u2694-\u2697\u2699\u269B\u269C\u26A0\u26A7\u26AA\u26B0\u26B1\u26BD\u26BE\u26C4\u26C8\u26CF\u26D1\u26E9\u26F0-\u26F5\u26F7\u26F8\u26FA\u2702\u2708\u2709\u270F\u2712\u2714\u2716\u271D\u2721\u2733\u2734\u2744\u2747\u2757\u2763\u27A1\u2934\u2935\u2B05-\u2B07\u2B1B\u2B1C\u2B55\u3030\u303D\u3297\u3299]\uFE0F?|[\u261D\u270C\u270D](?:\uD83C[\uDFFB-\uDFFF]|\uFE0F)?|[\u270A\u270B](?:\uD83C[\uDFFB-\uDFFF])?|[\u23E9-\u23EC\u23F0\u23F3\u25FD\u2693\u26A1\u26AB\u26C5\u26CE\u26D4\u26EA\u26FD\u2705\u2728\u274C\u274E\u2753-\u2755\u2795-\u2797\u27B0\u27BF\u2B50]|\u26D3\uFE0F?(?:\u200D\uD83D\uDCA5)?|\u26F9(?:\uD83C[\uDFFB-\uDFFF]|\uFE0F)?(?:\u200D[\u2640\u2642]\uFE0F?)?|\u2764\uFE0F?(?:\u200D(?:\uD83D\uDD25|\uD83E\uDE79))?|\uD83C(?:[\uDC04\uDD70\uDD71\uDD7E\uDD7F\uDE02\uDE37\uDF21\uDF24-\uDF2C\uDF36\uDF7D\uDF96\uDF97\uDF99-\uDF9B\uDF9E\uDF9F\uDFCD\uDFCE\uDFD4-\uDFDF\uDFF5\uDFF7]\uFE0F?|[\uDF85\uDFC2\uDFC7](?:\uD83C[\uDFFB-\uDFFF])?|[\uDFC4\uDFCA](?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDFCB\uDFCC](?:\uD83C[\uDFFB-\uDFFF]|\uFE0F)?(?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDCCF\uDD8E\uDD91-\uDD9A\uDE01\uDE1A\uDE2F\uDE32-\uDE36\uDE38-\uDE3A\uDE50\uDE51\uDF00-\uDF20\uDF2D-\uDF35\uDF37-\uDF43\uDF45-\uDF4A\uDF4C-\uDF7C\uDF7E-\uDF84\uDF86-\uDF93\uDFA0-\uDFC1\uDFC5\uDFC6\uDFC8\uDFC9\uDFCF-\uDFD3\uDFE0-\uDFF0\uDFF8-\uDFFF]|\uDDE6\uD83C[\uDDE8-\uDDEC\uDDEE\uDDF1\uDDF2\uDDF4\uDDF6-\uDDFA\uDDFC\uDDFD\uDDFF]|\uDDE7\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEF\uDDF1-\uDDF4\uDDF6-\uDDF9\uDDFB\uDDFC\uDDFE\uDDFF]|\uDDE8\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDEE\uDDF0-\uDDF7\uDDFA-\uDDFF]|\uDDE9\uD83C[\uDDEA\uDDEC\uDDEF\uDDF0\uDDF2\uDDF4\uDDFF]|\uDDEA\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDED\uDDF7-\uDDFA]|\uDDEB\uD83C[\uDDEE-\uDDF0\uDDF2\uDDF4\uDDF7]|\uDDEC\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEE\uDDF1-\uDDF3\uDDF5-\uDDFA\uDDFC\uDDFE]|\uDDED\uD83C[\uDDF0\uDDF2\uDDF3\uDDF7\uDDF9\uDDFA]|\uDDEE\uD83C[\uDDE8-\uDDEA\uDDF1-\uDDF4\uDDF6-\uDDF9]|\uDDEF\uD83C[\uDDEA\uDDF2\uDDF4\uDDF5]|\uDDF0\uD83C[\uDDEA\uDDEC-\uDDEE\uDDF2\uDDF3\uDDF5\uDDF7\uDDFC\uDDFE\uDDFF]|\uDDF1\uD83C[\uDDE6-\uDDE8\uDDEE\uDDF0\uDDF7-\uDDFB\uDDFE]|\uDDF2\uD83C[\uDDE6\uDDE8-\uDDED\uDDF0-\uDDFF]|\uDDF3\uD83C[\uDDE6\uDDE8\uDDEA-\uDDEC\uDDEE\uDDF1\uDDF4\uDDF5\uDDF7\uDDFA\uDDFF]|\uDDF4\uD83C\uDDF2|\uDDF5\uD83C[\uDDE6\uDDEA-\uDDED\uDDF0-\uDDF3\uDDF7-\uDDF9\uDDFC\uDDFE]|\uDDF6\uD83C\uDDE6|\uDDF7\uD83C[\uDDEA\uDDF4\uDDF8\uDDFA\uDDFC]|\uDDF8\uD83C[\uDDE6-\uDDEA\uDDEC-\uDDF4\uDDF7-\uDDF9\uDDFB\uDDFD-\uDDFF]|\uDDF9\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDED\uDDEF-\uDDF4\uDDF7\uDDF9\uDDFB\uDDFC\uDDFF]|\uDDFA\uD83C[\uDDE6\uDDEC\uDDF2\uDDF3\uDDF8\uDDFE\uDDFF]|\uDDFB\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDEE\uDDF3\uDDFA]|\uDDFC\uD83C[\uDDEB\uDDF8]|\uDDFD\uD83C\uDDF0|\uDDFE\uD83C[\uDDEA\uDDF9]|\uDDFF\uD83C[\uDDE6\uDDF2\uDDFC]|\uDF44(?:\u200D\uD83D\uDFEB)?|\uDF4B(?:\u200D\uD83D\uDFE9)?|\uDFC3(?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D(?:[\u2640\u2642]\uFE0F?(?:\u200D\u27A1\uFE0F?)?|\u27A1\uFE0F?))?|\uDFF3\uFE0F?(?:\u200D(?:\u26A7\uFE0F?|\uD83C\uDF08))?|\uDFF4(?:\u200D\u2620\uFE0F?|\uDB40\uDC67\uDB40\uDC62\uDB40(?:\uDC65\uDB40\uDC6E\uDB40\uDC67|\uDC73\uDB40\uDC63\uDB40\uDC74|\uDC77\uDB40\uDC6C\uDB40\uDC73)\uDB40\uDC7F)?)|\uD83D(?:[\uDC3F\uDCFD\uDD49\uDD4A\uDD6F\uDD70\uDD73\uDD76-\uDD79\uDD87\uDD8A-\uDD8D\uDDA5\uDDA8\uDDB1\uDDB2\uDDBC\uDDC2-\uDDC4\uDDD1-\uDDD3\uDDDC-\uDDDE\uDDE1\uDDE3\uDDE8\uDDEF\uDDF3\uDDFA\uDECB\uDECD-\uDECF\uDEE0-\uDEE5\uDEE9\uDEF0\uDEF3]\uFE0F?|[\uDC42\uDC43\uDC46-\uDC50\uDC66\uDC67\uDC6B-\uDC6D\uDC72\uDC74-\uDC76\uDC78\uDC7C\uDC83\uDC85\uDC8F\uDC91\uDCAA\uDD7A\uDD95\uDD96\uDE4C\uDE4F\uDEC0\uDECC](?:\uD83C[\uDFFB-\uDFFF])?|[\uDC6E-\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4\uDEB5](?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDD74\uDD90](?:\uD83C[\uDFFB-\uDFFF]|\uFE0F)?|[\uDC00-\uDC07\uDC09-\uDC14\uDC16-\uDC25\uDC27-\uDC3A\uDC3C-\uDC3E\uDC40\uDC44\uDC45\uDC51-\uDC65\uDC6A\uDC79-\uDC7B\uDC7D-\uDC80\uDC84\uDC88-\uDC8E\uDC90\uDC92-\uDCA9\uDCAB-\uDCFC\uDCFF-\uDD3D\uDD4B-\uDD4E\uDD50-\uDD67\uDDA4\uDDFB-\uDE2D\uDE2F-\uDE34\uDE37-\uDE41\uDE43\uDE44\uDE48-\uDE4A\uDE80-\uDEA2\uDEA4-\uDEB3\uDEB7-\uDEBF\uDEC1-\uDEC5\uDED0-\uDED2\uDED5-\uDED8\uDEDC-\uDEDF\uDEEB\uDEEC\uDEF4-\uDEFC\uDFE0-\uDFEB\uDFF0]|\uDC08(?:\u200D\u2B1B)?|\uDC15(?:\u200D\uD83E\uDDBA)?|\uDC26(?:\u200D(?:\u2B1B|\uD83D\uDD25))?|\uDC3B(?:\u200D\u2744\uFE0F?)?|\uDC41\uFE0F?(?:\u200D\uD83D\uDDE8\uFE0F?)?|\uDC68(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDC68\uDC69]\u200D\uD83D(?:\uDC66(?:\u200D\uD83D\uDC66)?|\uDC67(?:\u200D\uD83D[\uDC66\uDC67])?)|[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC66(?:\u200D\uD83D\uDC66)?|\uDC67(?:\u200D\uD83D[\uDC66\uDC67])?)|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]))|\uD83C(?:\uDFFB(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC68\uD83C[\uDFFC-\uDFFF])|\uD83E(?:[\uDD1D\uDEEF]\u200D\uD83D\uDC68\uD83C[\uDFFC-\uDFFF]|[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3])))?|\uDFFC(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC68\uD83C[\uDFFB\uDFFD-\uDFFF])|\uD83E(?:[\uDD1D\uDEEF]\u200D\uD83D\uDC68\uD83C[\uDFFB\uDFFD-\uDFFF]|[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3])))?|\uDFFD(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC68\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])|\uD83E(?:[\uDD1D\uDEEF]\u200D\uD83D\uDC68\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF]|[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3])))?|\uDFFE(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC68\uD83C[\uDFFB-\uDFFD\uDFFF])|\uD83E(?:[\uDD1D\uDEEF]\u200D\uD83D\uDC68\uD83C[\uDFFB-\uDFFD\uDFFF]|[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3])))?|\uDFFF(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC68\uD83C[\uDFFB-\uDFFE])|\uD83E(?:[\uDD1D\uDEEF]\u200D\uD83D\uDC68\uD83C[\uDFFB-\uDFFE]|[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3])))?))?|\uDC69(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?[\uDC68\uDC69]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC66(?:\u200D\uD83D\uDC66)?|\uDC67(?:\u200D\uD83D[\uDC66\uDC67])?|\uDC69\u200D\uD83D(?:\uDC66(?:\u200D\uD83D\uDC66)?|\uDC67(?:\u200D\uD83D[\uDC66\uDC67])?))|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]))|\uD83C(?:\uDFFB(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC69\uD83C[\uDFFC-\uDFFF])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFC-\uDFFF]|\uDEEF\u200D\uD83D\uDC69\uD83C[\uDFFC-\uDFFF])))?|\uDFFC(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC69\uD83C[\uDFFB\uDFFD-\uDFFF])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFB\uDFFD-\uDFFF]|\uDEEF\u200D\uD83D\uDC69\uD83C[\uDFFB\uDFFD-\uDFFF])))?|\uDFFD(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC69\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF]|\uDEEF\u200D\uD83D\uDC69\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])))?|\uDFFE(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC69\uD83C[\uDFFB-\uDFFD\uDFFF])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFB-\uDFFD\uDFFF]|\uDEEF\u200D\uD83D\uDC69\uD83C[\uDFFB-\uDFFD\uDFFF])))?|\uDFFF(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC69\uD83C[\uDFFB-\uDFFE])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFB-\uDFFE]|\uDEEF\u200D\uD83D\uDC69\uD83C[\uDFFB-\uDFFE])))?))?|\uDD75(?:\uD83C[\uDFFB-\uDFFF]|\uFE0F)?(?:\u200D[\u2640\u2642]\uFE0F?)?|\uDE2E(?:\u200D\uD83D\uDCA8)?|\uDE35(?:\u200D\uD83D\uDCAB)?|\uDE36(?:\u200D\uD83C\uDF2B\uFE0F?)?|\uDE42(?:\u200D[\u2194\u2195]\uFE0F?)?|\uDEB6(?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D(?:[\u2640\u2642]\uFE0F?(?:\u200D\u27A1\uFE0F?)?|\u27A1\uFE0F?))?)|\uD83E(?:[\uDD0C\uDD0F\uDD18-\uDD1F\uDD30-\uDD34\uDD36\uDD77\uDDB5\uDDB6\uDDBB\uDDD2\uDDD3\uDDD5\uDEC3-\uDEC5\uDEF0\uDEF2-\uDEF8](?:\uD83C[\uDFFB-\uDFFF])?|[\uDD26\uDD35\uDD37-\uDD39\uDD3C-\uDD3E\uDDB8\uDDB9\uDDCD\uDDCF\uDDD4\uDDD6-\uDDDD](?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDDDE\uDDDF](?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDD0D\uDD0E\uDD10-\uDD17\uDD20-\uDD25\uDD27-\uDD2F\uDD3A\uDD3F-\uDD45\uDD47-\uDD76\uDD78-\uDDB4\uDDB7\uDDBA\uDDBC-\uDDCC\uDDD0\uDDE0-\uDDFF\uDE70-\uDE7C\uDE80-\uDE8A\uDE8E-\uDEC2\uDEC6\uDEC8\uDECD-\uDEDC\uDEDF-\uDEEA\uDEEF]|\uDDCE(?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D(?:[\u2640\u2642]\uFE0F?(?:\u200D\u27A1\uFE0F?)?|\u27A1\uFE0F?))?|\uDDD1(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3\uDE70]|\uDD1D\u200D\uD83E\uDDD1|\uDDD1\u200D\uD83E\uDDD2(?:\u200D\uD83E\uDDD2)?|\uDDD2(?:\u200D\uD83E\uDDD2)?))|\uD83C(?:\uDFFB(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFC-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83E\uDDD1\uD83C[\uDFFC-\uDFFF])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3\uDE70]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF]|\uDEEF\u200D\uD83E\uDDD1\uD83C[\uDFFC-\uDFFF])))?|\uDFFC(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFB\uDFFD-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83E\uDDD1\uD83C[\uDFFB\uDFFD-\uDFFF])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3\uDE70]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF]|\uDEEF\u200D\uD83E\uDDD1\uD83C[\uDFFB\uDFFD-\uDFFF])))?|\uDFFD(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83E\uDDD1\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3\uDE70]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF]|\uDEEF\u200D\uD83E\uDDD1\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])))?|\uDFFE(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFB-\uDFFD\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFD\uDFFF])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3\uDE70]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF]|\uDEEF\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFD\uDFFF])))?|\uDFFF(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFB-\uDFFE]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFE])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3\uDE70]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF]|\uDEEF\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFE])))?))?|\uDEF1(?:\uD83C(?:\uDFFB(?:\u200D\uD83E\uDEF2\uD83C[\uDFFC-\uDFFF])?|\uDFFC(?:\u200D\uD83E\uDEF2\uD83C[\uDFFB\uDFFD-\uDFFF])?|\uDFFD(?:\u200D\uD83E\uDEF2\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])?|\uDFFE(?:\u200D\uD83E\uDEF2\uD83C[\uDFFB-\uDFFD\uDFFF])?|\uDFFF(?:\u200D\uD83E\uDEF2\uD83C[\uDFFB-\uDFFE])?))?)/g;
65
- };
66
- });
67
-
68
- // ../../node_modules/.bun/mute-stream@3.0.0/node_modules/mute-stream/lib/index.js
69
- var require_lib = __commonJS((exports, module) => {
70
- var Stream = __require("stream");
71
-
72
- class MuteStream extends Stream {
73
- #isTTY = null;
74
- constructor(opts = {}) {
75
- super(opts);
76
- this.writable = this.readable = true;
77
- this.muted = false;
78
- this.on("pipe", this._onpipe);
79
- this.replace = opts.replace;
80
- this._prompt = opts.prompt || null;
81
- this._hadControl = false;
82
- }
83
- #destSrc(key, def) {
84
- if (this._dest) {
85
- return this._dest[key];
86
- }
87
- if (this._src) {
88
- return this._src[key];
89
- }
90
- return def;
91
- }
92
- #proxy(method, ...args) {
93
- if (typeof this._dest?.[method] === "function") {
94
- this._dest[method](...args);
95
- }
96
- if (typeof this._src?.[method] === "function") {
97
- this._src[method](...args);
98
- }
99
- }
100
- get isTTY() {
101
- if (this.#isTTY !== null) {
102
- return this.#isTTY;
103
- }
104
- return this.#destSrc("isTTY", false);
105
- }
106
- set isTTY(val) {
107
- this.#isTTY = val;
108
- }
109
- get rows() {
110
- return this.#destSrc("rows");
111
- }
112
- get columns() {
113
- return this.#destSrc("columns");
114
- }
115
- mute() {
116
- this.muted = true;
117
- }
118
- unmute() {
119
- this.muted = false;
120
- }
121
- _onpipe(src) {
122
- this._src = src;
123
- }
124
- pipe(dest, options) {
125
- this._dest = dest;
126
- return super.pipe(dest, options);
127
- }
128
- pause() {
129
- if (this._src) {
130
- return this._src.pause();
131
- }
132
- }
133
- resume() {
134
- if (this._src) {
135
- return this._src.resume();
136
- }
137
- }
138
- write(c) {
139
- if (this.muted) {
140
- if (!this.replace) {
141
- return true;
142
- }
143
- if (c.match(/^\u001b/)) {
144
- if (c.indexOf(this._prompt) === 0) {
145
- c = c.slice(this._prompt.length);
146
- c = c.replace(/./g, this.replace);
147
- c = this._prompt + c;
148
- }
149
- this._hadControl = true;
150
- return this.emit("data", c);
151
- } else {
152
- if (this._prompt && this._hadControl && c.indexOf(this._prompt) === 0) {
153
- this._hadControl = false;
154
- this.emit("data", this._prompt);
155
- c = c.slice(this._prompt.length);
156
- }
157
- c = c.toString().replace(/./g, this.replace);
158
- }
159
- }
160
- this.emit("data", c);
161
- }
162
- end(c) {
163
- if (this.muted) {
164
- if (c && this.replace) {
165
- c = c.toString().replace(/./g, this.replace);
166
- } else {
167
- c = null;
168
- }
169
- }
170
- if (c) {
171
- this.emit("data", c);
172
- }
173
- this.emit("end");
174
- }
175
- destroy(...args) {
176
- return this.#proxy("destroy", ...args);
177
- }
178
- destroySoon(...args) {
179
- return this.#proxy("destroySoon", ...args);
180
- }
181
- close(...args) {
182
- return this.#proxy("close", ...args);
183
- }
184
- }
185
- module.exports = MuteStream;
186
- });
187
-
188
- // ../../node_modules/.bun/bytes@3.1.2/node_modules/bytes/index.js
189
- var require_bytes = __commonJS((exports, module) => {
190
- /*!
191
- * bytes
192
- * Copyright(c) 2012-2014 TJ Holowaychuk
193
- * Copyright(c) 2015 Jed Watson
194
- * MIT Licensed
195
- */
196
- module.exports = bytes;
197
- module.exports.format = format;
198
- module.exports.parse = parse;
199
- var formatThousandsRegExp = /\B(?=(\d{3})+(?!\d))/g;
200
- var formatDecimalsRegExp = /(?:\.0*|(\.[^0]+)0+)$/;
201
- var map = {
202
- b: 1,
203
- kb: 1 << 10,
204
- mb: 1 << 20,
205
- gb: 1 << 30,
206
- tb: Math.pow(1024, 4),
207
- pb: Math.pow(1024, 5)
208
- };
209
- var parseRegExp = /^((-|\+)?(\d+(?:\.\d+)?)) *(kb|mb|gb|tb|pb)$/i;
210
- function bytes(value, options) {
211
- if (typeof value === "string") {
212
- return parse(value);
213
- }
214
- if (typeof value === "number") {
215
- return format(value, options);
216
- }
217
- return null;
218
- }
219
- function format(value, options) {
220
- if (!Number.isFinite(value)) {
221
- return null;
222
- }
223
- var mag = Math.abs(value);
224
- var thousandsSeparator = options && options.thousandsSeparator || "";
225
- var unitSeparator = options && options.unitSeparator || "";
226
- var decimalPlaces = options && options.decimalPlaces !== undefined ? options.decimalPlaces : 2;
227
- var fixedDecimals = Boolean(options && options.fixedDecimals);
228
- var unit = options && options.unit || "";
229
- if (!unit || !map[unit.toLowerCase()]) {
230
- if (mag >= map.pb) {
231
- unit = "PB";
232
- } else if (mag >= map.tb) {
233
- unit = "TB";
234
- } else if (mag >= map.gb) {
235
- unit = "GB";
236
- } else if (mag >= map.mb) {
237
- unit = "MB";
238
- } else if (mag >= map.kb) {
239
- unit = "KB";
240
- } else {
241
- unit = "B";
242
- }
243
- }
244
- var val = value / map[unit.toLowerCase()];
245
- var str = val.toFixed(decimalPlaces);
246
- if (!fixedDecimals) {
247
- str = str.replace(formatDecimalsRegExp, "$1");
248
- }
249
- if (thousandsSeparator) {
250
- str = str.split(".").map(function(s, i) {
251
- return i === 0 ? s.replace(formatThousandsRegExp, thousandsSeparator) : s;
252
- }).join(".");
253
- }
254
- return str + unitSeparator + unit;
255
- }
256
- function parse(val) {
257
- if (typeof val === "number" && !isNaN(val)) {
258
- return val;
259
- }
260
- if (typeof val !== "string") {
261
- return null;
262
- }
263
- var results = parseRegExp.exec(val);
264
- var floatValue;
265
- var unit = "b";
266
- if (!results) {
267
- floatValue = parseInt(val, 10);
268
- unit = "b";
269
- } else {
270
- floatValue = parseFloat(results[1]);
271
- unit = results[4].toLowerCase();
272
- }
273
- if (isNaN(floatValue)) {
274
- return null;
275
- }
276
- return Math.floor(map[unit] * floatValue);
277
- }
278
- });
279
-
280
- // ../../node_modules/.bun/picocolors@1.1.1/node_modules/picocolors/picocolors.js
281
- var require_picocolors = __commonJS((exports, module) => {
282
- var p = process || {};
283
- var argv = p.argv || [];
284
- var env = p.env || {};
285
- 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);
286
- var formatter = (open, close, replace = open) => (input) => {
287
- let string = "" + input, index = string.indexOf(close, open.length);
288
- return ~index ? open + replaceClose(string, close, replace, index) + close : open + string + close;
289
- };
290
- var replaceClose = (string, close, replace, index) => {
291
- let result = "", cursor = 0;
292
- do {
293
- result += string.substring(cursor, index) + replace;
294
- cursor = index + close.length;
295
- index = string.indexOf(close, cursor);
296
- } while (~index);
297
- return result + string.substring(cursor);
298
- };
299
- var createColors = (enabled = isColorSupported) => {
300
- let f = enabled ? formatter : () => String;
301
- return {
302
- isColorSupported: enabled,
303
- reset: f("\x1B[0m", "\x1B[0m"),
304
- bold: f("\x1B[1m", "\x1B[22m", "\x1B[22m\x1B[1m"),
305
- dim: f("\x1B[2m", "\x1B[22m", "\x1B[22m\x1B[2m"),
306
- italic: f("\x1B[3m", "\x1B[23m"),
307
- underline: f("\x1B[4m", "\x1B[24m"),
308
- inverse: f("\x1B[7m", "\x1B[27m"),
309
- hidden: f("\x1B[8m", "\x1B[28m"),
310
- strikethrough: f("\x1B[9m", "\x1B[29m"),
311
- black: f("\x1B[30m", "\x1B[39m"),
312
- red: f("\x1B[31m", "\x1B[39m"),
313
- green: f("\x1B[32m", "\x1B[39m"),
314
- yellow: f("\x1B[33m", "\x1B[39m"),
315
- blue: f("\x1B[34m", "\x1B[39m"),
316
- magenta: f("\x1B[35m", "\x1B[39m"),
317
- cyan: f("\x1B[36m", "\x1B[39m"),
318
- white: f("\x1B[37m", "\x1B[39m"),
319
- gray: f("\x1B[90m", "\x1B[39m"),
320
- bgBlack: f("\x1B[40m", "\x1B[49m"),
321
- bgRed: f("\x1B[41m", "\x1B[49m"),
322
- bgGreen: f("\x1B[42m", "\x1B[49m"),
323
- bgYellow: f("\x1B[43m", "\x1B[49m"),
324
- bgBlue: f("\x1B[44m", "\x1B[49m"),
325
- bgMagenta: f("\x1B[45m", "\x1B[49m"),
326
- bgCyan: f("\x1B[46m", "\x1B[49m"),
327
- bgWhite: f("\x1B[47m", "\x1B[49m"),
328
- blackBright: f("\x1B[90m", "\x1B[39m"),
329
- redBright: f("\x1B[91m", "\x1B[39m"),
330
- greenBright: f("\x1B[92m", "\x1B[39m"),
331
- yellowBright: f("\x1B[93m", "\x1B[39m"),
332
- blueBright: f("\x1B[94m", "\x1B[39m"),
333
- magentaBright: f("\x1B[95m", "\x1B[39m"),
334
- cyanBright: f("\x1B[96m", "\x1B[39m"),
335
- whiteBright: f("\x1B[97m", "\x1B[39m"),
336
- bgBlackBright: f("\x1B[100m", "\x1B[49m"),
337
- bgRedBright: f("\x1B[101m", "\x1B[49m"),
338
- bgGreenBright: f("\x1B[102m", "\x1B[49m"),
339
- bgYellowBright: f("\x1B[103m", "\x1B[49m"),
340
- bgBlueBright: f("\x1B[104m", "\x1B[49m"),
341
- bgMagentaBright: f("\x1B[105m", "\x1B[49m"),
342
- bgCyanBright: f("\x1B[106m", "\x1B[49m"),
343
- bgWhiteBright: f("\x1B[107m", "\x1B[49m")
344
- };
345
- };
346
- module.exports = createColors();
347
- module.exports.createColors = createColors;
348
- });
349
-
350
- // ../../node_modules/.bun/cac@6.7.14/node_modules/cac/dist/index.mjs
351
- import { EventEmitter } from "events";
352
- function toArr(any) {
353
- return any == null ? [] : Array.isArray(any) ? any : [any];
354
- }
355
- function toVal(out, key, val, opts) {
356
- var x, old = out[key], nxt = ~opts.string.indexOf(key) ? val == null || val === true ? "" : String(val) : typeof val === "boolean" ? val : ~opts.boolean.indexOf(key) ? val === "false" ? false : val === "true" || (out._.push((x = +val, x * 0 === 0) ? x : val), !!val) : (x = +val, x * 0 === 0) ? x : val;
357
- out[key] = old == null ? nxt : Array.isArray(old) ? old.concat(nxt) : [old, nxt];
358
- }
359
- function mri2(args, opts) {
360
- args = args || [];
361
- opts = opts || {};
362
- var k, arr, arg, name, val, out = { _: [] };
363
- var i = 0, j = 0, idx = 0, len = args.length;
364
- const alibi = opts.alias !== undefined;
365
- const strict = opts.unknown !== undefined;
366
- const defaults = opts.default !== undefined;
367
- opts.alias = opts.alias || {};
368
- opts.string = toArr(opts.string);
369
- opts.boolean = toArr(opts.boolean);
370
- if (alibi) {
371
- for (k in opts.alias) {
372
- arr = opts.alias[k] = toArr(opts.alias[k]);
373
- for (i = 0;i < arr.length; i++) {
374
- (opts.alias[arr[i]] = arr.concat(k)).splice(i, 1);
375
- }
376
- }
377
- }
378
- for (i = opts.boolean.length;i-- > 0; ) {
379
- arr = opts.alias[opts.boolean[i]] || [];
380
- for (j = arr.length;j-- > 0; )
381
- opts.boolean.push(arr[j]);
382
- }
383
- for (i = opts.string.length;i-- > 0; ) {
384
- arr = opts.alias[opts.string[i]] || [];
385
- for (j = arr.length;j-- > 0; )
386
- opts.string.push(arr[j]);
387
- }
388
- if (defaults) {
389
- for (k in opts.default) {
390
- name = typeof opts.default[k];
391
- arr = opts.alias[k] = opts.alias[k] || [];
392
- if (opts[name] !== undefined) {
393
- opts[name].push(k);
394
- for (i = 0;i < arr.length; i++) {
395
- opts[name].push(arr[i]);
396
- }
397
- }
398
- }
399
- }
400
- const keys = strict ? Object.keys(opts.alias) : [];
401
- for (i = 0;i < len; i++) {
402
- arg = args[i];
403
- if (arg === "--") {
404
- out._ = out._.concat(args.slice(++i));
405
- break;
406
- }
407
- for (j = 0;j < arg.length; j++) {
408
- if (arg.charCodeAt(j) !== 45)
409
- break;
410
- }
411
- if (j === 0) {
412
- out._.push(arg);
413
- } else if (arg.substring(j, j + 3) === "no-") {
414
- name = arg.substring(j + 3);
415
- if (strict && !~keys.indexOf(name)) {
416
- return opts.unknown(arg);
417
- }
418
- out[name] = false;
419
- } else {
420
- for (idx = j + 1;idx < arg.length; idx++) {
421
- if (arg.charCodeAt(idx) === 61)
422
- break;
423
- }
424
- name = arg.substring(j, idx);
425
- val = arg.substring(++idx) || (i + 1 === len || ("" + args[i + 1]).charCodeAt(0) === 45 || args[++i]);
426
- arr = j === 2 ? [name] : name;
427
- for (idx = 0;idx < arr.length; idx++) {
428
- name = arr[idx];
429
- if (strict && !~keys.indexOf(name))
430
- return opts.unknown("-".repeat(j) + name);
431
- toVal(out, name, idx + 1 < arr.length || val, opts);
432
- }
433
- }
434
- }
435
- if (defaults) {
436
- for (k in opts.default) {
437
- if (out[k] === undefined) {
438
- out[k] = opts.default[k];
439
- }
440
- }
441
- }
442
- if (alibi) {
443
- for (k in out) {
444
- arr = opts.alias[k] || [];
445
- while (arr.length > 0) {
446
- out[arr.shift()] = out[k];
447
- }
448
- }
449
- }
450
- return out;
451
- }
452
- var removeBrackets = (v) => v.replace(/[<[].+/, "").trim();
453
- var findAllBrackets = (v) => {
454
- const ANGLED_BRACKET_RE_GLOBAL = /<([^>]+)>/g;
455
- const SQUARE_BRACKET_RE_GLOBAL = /\[([^\]]+)\]/g;
456
- const res = [];
457
- const parse = (match) => {
458
- let variadic = false;
459
- let value = match[1];
460
- if (value.startsWith("...")) {
461
- value = value.slice(3);
462
- variadic = true;
463
- }
464
- return {
465
- required: match[0].startsWith("<"),
466
- value,
467
- variadic
468
- };
469
- };
470
- let angledMatch;
471
- while (angledMatch = ANGLED_BRACKET_RE_GLOBAL.exec(v)) {
472
- res.push(parse(angledMatch));
473
- }
474
- let squareMatch;
475
- while (squareMatch = SQUARE_BRACKET_RE_GLOBAL.exec(v)) {
476
- res.push(parse(squareMatch));
477
- }
478
- return res;
479
- };
480
- var getMriOptions = (options) => {
481
- const result = { alias: {}, boolean: [] };
482
- for (const [index, option] of options.entries()) {
483
- if (option.names.length > 1) {
484
- result.alias[option.names[0]] = option.names.slice(1);
485
- }
486
- if (option.isBoolean) {
487
- if (option.negated) {
488
- const hasStringTypeOption = options.some((o, i) => {
489
- return i !== index && o.names.some((name) => option.names.includes(name)) && typeof o.required === "boolean";
490
- });
491
- if (!hasStringTypeOption) {
492
- result.boolean.push(option.names[0]);
493
- }
494
- } else {
495
- result.boolean.push(option.names[0]);
496
- }
497
- }
498
- }
499
- return result;
500
- };
501
- var findLongest = (arr) => {
502
- return arr.sort((a, b) => {
503
- return a.length > b.length ? -1 : 1;
504
- })[0];
505
- };
506
- var padRight = (str, length) => {
507
- return str.length >= length ? str : `${str}${" ".repeat(length - str.length)}`;
508
- };
509
- var camelcase = (input) => {
510
- return input.replace(/([a-z])-([a-z])/g, (_, p1, p2) => {
511
- return p1 + p2.toUpperCase();
512
- });
513
- };
514
- var setDotProp = (obj, keys, val) => {
515
- let i = 0;
516
- let length = keys.length;
517
- let t = obj;
518
- let x;
519
- for (;i < length; ++i) {
520
- x = t[keys[i]];
521
- t = t[keys[i]] = i === length - 1 ? val : x != null ? x : !!~keys[i + 1].indexOf(".") || !(+keys[i + 1] > -1) ? {} : [];
522
- }
523
- };
524
- var setByType = (obj, transforms) => {
525
- for (const key of Object.keys(transforms)) {
526
- const transform = transforms[key];
527
- if (transform.shouldTransform) {
528
- obj[key] = Array.prototype.concat.call([], obj[key]);
529
- if (typeof transform.transformFunction === "function") {
530
- obj[key] = obj[key].map(transform.transformFunction);
531
- }
532
- }
533
- }
534
- };
535
- var getFileName = (input) => {
536
- const m = /([^\\\/]+)$/.exec(input);
537
- return m ? m[1] : "";
538
- };
539
- var camelcaseOptionName = (name) => {
540
- return name.split(".").map((v, i) => {
541
- return i === 0 ? camelcase(v) : v;
542
- }).join(".");
543
- };
544
-
545
- class CACError extends Error {
546
- constructor(message) {
547
- super(message);
548
- this.name = this.constructor.name;
549
- if (typeof Error.captureStackTrace === "function") {
550
- Error.captureStackTrace(this, this.constructor);
551
- } else {
552
- this.stack = new Error(message).stack;
553
- }
554
- }
555
- }
556
-
557
- class Option {
558
- constructor(rawName, description, config) {
559
- this.rawName = rawName;
560
- this.description = description;
561
- this.config = Object.assign({}, config);
562
- rawName = rawName.replace(/\.\*/g, "");
563
- this.negated = false;
564
- this.names = removeBrackets(rawName).split(",").map((v) => {
565
- let name = v.trim().replace(/^-{1,2}/, "");
566
- if (name.startsWith("no-")) {
567
- this.negated = true;
568
- name = name.replace(/^no-/, "");
569
- }
570
- return camelcaseOptionName(name);
571
- }).sort((a, b) => a.length > b.length ? 1 : -1);
572
- this.name = this.names[this.names.length - 1];
573
- if (this.negated && this.config.default == null) {
574
- this.config.default = true;
575
- }
576
- if (rawName.includes("<")) {
577
- this.required = true;
578
- } else if (rawName.includes("[")) {
579
- this.required = false;
580
- } else {
581
- this.isBoolean = true;
582
- }
583
- }
584
- }
585
- var processArgs = process.argv;
586
- var platformInfo = `${process.platform}-${process.arch} node-${process.version}`;
587
-
588
- class Command {
589
- constructor(rawName, description, config = {}, cli) {
590
- this.rawName = rawName;
591
- this.description = description;
592
- this.config = config;
593
- this.cli = cli;
594
- this.options = [];
595
- this.aliasNames = [];
596
- this.name = removeBrackets(rawName);
597
- this.args = findAllBrackets(rawName);
598
- this.examples = [];
599
- }
600
- usage(text) {
601
- this.usageText = text;
602
- return this;
603
- }
604
- allowUnknownOptions() {
605
- this.config.allowUnknownOptions = true;
606
- return this;
607
- }
608
- ignoreOptionDefaultValue() {
609
- this.config.ignoreOptionDefaultValue = true;
610
- return this;
611
- }
612
- version(version, customFlags = "-v, --version") {
613
- this.versionNumber = version;
614
- this.option(customFlags, "Display version number");
615
- return this;
616
- }
617
- example(example) {
618
- this.examples.push(example);
619
- return this;
620
- }
621
- option(rawName, description, config) {
622
- const option = new Option(rawName, description, config);
623
- this.options.push(option);
624
- return this;
625
- }
626
- alias(name) {
627
- this.aliasNames.push(name);
628
- return this;
629
- }
630
- action(callback) {
631
- this.commandAction = callback;
632
- return this;
633
- }
634
- isMatched(name) {
635
- return this.name === name || this.aliasNames.includes(name);
636
- }
637
- get isDefaultCommand() {
638
- return this.name === "" || this.aliasNames.includes("!");
639
- }
640
- get isGlobalCommand() {
641
- return this instanceof GlobalCommand;
642
- }
643
- hasOption(name) {
644
- name = name.split(".")[0];
645
- return this.options.find((option) => {
646
- return option.names.includes(name);
647
- });
648
- }
649
- outputHelp() {
650
- const { name, commands } = this.cli;
651
- const {
652
- versionNumber,
653
- options: globalOptions,
654
- helpCallback
655
- } = this.cli.globalCommand;
656
- let sections = [
657
- {
658
- body: `${name}${versionNumber ? `/${versionNumber}` : ""}`
659
- }
660
- ];
661
- sections.push({
662
- title: "Usage",
663
- body: ` $ ${name} ${this.usageText || this.rawName}`
664
- });
665
- const showCommands = (this.isGlobalCommand || this.isDefaultCommand) && commands.length > 0;
666
- if (showCommands) {
667
- const longestCommandName = findLongest(commands.map((command) => command.rawName));
668
- sections.push({
669
- title: "Commands",
670
- body: commands.map((command) => {
671
- return ` ${padRight(command.rawName, longestCommandName.length)} ${command.description}`;
672
- }).join(`
673
- `)
674
- });
675
- sections.push({
676
- title: `For more info, run any command with the \`--help\` flag`,
677
- body: commands.map((command) => ` $ ${name}${command.name === "" ? "" : ` ${command.name}`} --help`).join(`
678
- `)
679
- });
680
- }
681
- let options = this.isGlobalCommand ? globalOptions : [...this.options, ...globalOptions || []];
682
- if (!this.isGlobalCommand && !this.isDefaultCommand) {
683
- options = options.filter((option) => option.name !== "version");
684
- }
685
- if (options.length > 0) {
686
- const longestOptionName = findLongest(options.map((option) => option.rawName));
687
- sections.push({
688
- title: "Options",
689
- body: options.map((option) => {
690
- return ` ${padRight(option.rawName, longestOptionName.length)} ${option.description} ${option.config.default === undefined ? "" : `(default: ${option.config.default})`}`;
691
- }).join(`
692
- `)
693
- });
694
- }
695
- if (this.examples.length > 0) {
696
- sections.push({
697
- title: "Examples",
698
- body: this.examples.map((example) => {
699
- if (typeof example === "function") {
700
- return example(name);
701
- }
702
- return example;
703
- }).join(`
704
- `)
705
- });
706
- }
707
- if (helpCallback) {
708
- sections = helpCallback(sections) || sections;
709
- }
710
- console.log(sections.map((section) => {
711
- return section.title ? `${section.title}:
712
- ${section.body}` : section.body;
713
- }).join(`
714
-
715
- `));
716
- }
717
- outputVersion() {
718
- const { name } = this.cli;
719
- const { versionNumber } = this.cli.globalCommand;
720
- if (versionNumber) {
721
- console.log(`${name}/${versionNumber} ${platformInfo}`);
722
- }
723
- }
724
- checkRequiredArgs() {
725
- const minimalArgsCount = this.args.filter((arg) => arg.required).length;
726
- if (this.cli.args.length < minimalArgsCount) {
727
- throw new CACError(`missing required args for command \`${this.rawName}\``);
728
- }
729
- }
730
- checkUnknownOptions() {
731
- const { options, globalCommand } = this.cli;
732
- if (!this.config.allowUnknownOptions) {
733
- for (const name of Object.keys(options)) {
734
- if (name !== "--" && !this.hasOption(name) && !globalCommand.hasOption(name)) {
735
- throw new CACError(`Unknown option \`${name.length > 1 ? `--${name}` : `-${name}`}\``);
736
- }
737
- }
738
- }
739
- }
740
- checkOptionValue() {
741
- const { options: parsedOptions, globalCommand } = this.cli;
742
- const options = [...globalCommand.options, ...this.options];
743
- for (const option of options) {
744
- const value = parsedOptions[option.name.split(".")[0]];
745
- if (option.required) {
746
- const hasNegated = options.some((o) => o.negated && o.names.includes(option.name));
747
- if (value === true || value === false && !hasNegated) {
748
- throw new CACError(`option \`${option.rawName}\` value is missing`);
749
- }
750
- }
751
- }
752
- }
753
- }
754
-
755
- class GlobalCommand extends Command {
756
- constructor(cli) {
757
- super("@@global@@", "", {}, cli);
758
- }
759
- }
760
- var __assign = Object.assign;
761
-
762
- class CAC extends EventEmitter {
763
- constructor(name = "") {
764
- super();
765
- this.name = name;
766
- this.commands = [];
767
- this.rawArgs = [];
768
- this.args = [];
769
- this.options = {};
770
- this.globalCommand = new GlobalCommand(this);
771
- this.globalCommand.usage("<command> [options]");
772
- }
773
- usage(text) {
774
- this.globalCommand.usage(text);
775
- return this;
776
- }
777
- command(rawName, description, config) {
778
- const command = new Command(rawName, description || "", config, this);
779
- command.globalCommand = this.globalCommand;
780
- this.commands.push(command);
781
- return command;
782
- }
783
- option(rawName, description, config) {
784
- this.globalCommand.option(rawName, description, config);
785
- return this;
786
- }
787
- help(callback) {
788
- this.globalCommand.option("-h, --help", "Display this message");
789
- this.globalCommand.helpCallback = callback;
790
- this.showHelpOnExit = true;
791
- return this;
792
- }
793
- version(version, customFlags = "-v, --version") {
794
- this.globalCommand.version(version, customFlags);
795
- this.showVersionOnExit = true;
796
- return this;
797
- }
798
- example(example) {
799
- this.globalCommand.example(example);
800
- return this;
801
- }
802
- outputHelp() {
803
- if (this.matchedCommand) {
804
- this.matchedCommand.outputHelp();
805
- } else {
806
- this.globalCommand.outputHelp();
807
- }
808
- }
809
- outputVersion() {
810
- this.globalCommand.outputVersion();
811
- }
812
- setParsedInfo({ args, options }, matchedCommand, matchedCommandName) {
813
- this.args = args;
814
- this.options = options;
815
- if (matchedCommand) {
816
- this.matchedCommand = matchedCommand;
817
- }
818
- if (matchedCommandName) {
819
- this.matchedCommandName = matchedCommandName;
820
- }
821
- return this;
822
- }
823
- unsetMatchedCommand() {
824
- this.matchedCommand = undefined;
825
- this.matchedCommandName = undefined;
826
- }
827
- parse(argv = processArgs, {
828
- run = true
829
- } = {}) {
830
- this.rawArgs = argv;
831
- if (!this.name) {
832
- this.name = argv[1] ? getFileName(argv[1]) : "cli";
833
- }
834
- let shouldParse = true;
835
- for (const command of this.commands) {
836
- const parsed = this.mri(argv.slice(2), command);
837
- const commandName = parsed.args[0];
838
- if (command.isMatched(commandName)) {
839
- shouldParse = false;
840
- const parsedInfo = __assign(__assign({}, parsed), {
841
- args: parsed.args.slice(1)
842
- });
843
- this.setParsedInfo(parsedInfo, command, commandName);
844
- this.emit(`command:${commandName}`, command);
845
- }
846
- }
847
- if (shouldParse) {
848
- for (const command of this.commands) {
849
- if (command.name === "") {
850
- shouldParse = false;
851
- const parsed = this.mri(argv.slice(2), command);
852
- this.setParsedInfo(parsed, command);
853
- this.emit(`command:!`, command);
854
- }
855
- }
856
- }
857
- if (shouldParse) {
858
- const parsed = this.mri(argv.slice(2));
859
- this.setParsedInfo(parsed);
860
- }
861
- if (this.options.help && this.showHelpOnExit) {
862
- this.outputHelp();
863
- run = false;
864
- this.unsetMatchedCommand();
865
- }
866
- if (this.options.version && this.showVersionOnExit && this.matchedCommandName == null) {
867
- this.outputVersion();
868
- run = false;
869
- this.unsetMatchedCommand();
870
- }
871
- const parsedArgv = { args: this.args, options: this.options };
872
- if (run) {
873
- this.runMatchedCommand();
874
- }
875
- if (!this.matchedCommand && this.args[0]) {
876
- this.emit("command:*");
877
- }
878
- return parsedArgv;
879
- }
880
- mri(argv, command) {
881
- const cliOptions = [
882
- ...this.globalCommand.options,
883
- ...command ? command.options : []
884
- ];
885
- const mriOptions = getMriOptions(cliOptions);
886
- let argsAfterDoubleDashes = [];
887
- const doubleDashesIndex = argv.indexOf("--");
888
- if (doubleDashesIndex > -1) {
889
- argsAfterDoubleDashes = argv.slice(doubleDashesIndex + 1);
890
- argv = argv.slice(0, doubleDashesIndex);
891
- }
892
- let parsed = mri2(argv, mriOptions);
893
- parsed = Object.keys(parsed).reduce((res, name) => {
894
- return __assign(__assign({}, res), {
895
- [camelcaseOptionName(name)]: parsed[name]
896
- });
897
- }, { _: [] });
898
- const args = parsed._;
899
- const options = {
900
- "--": argsAfterDoubleDashes
901
- };
902
- const ignoreDefault = command && command.config.ignoreOptionDefaultValue ? command.config.ignoreOptionDefaultValue : this.globalCommand.config.ignoreOptionDefaultValue;
903
- let transforms = Object.create(null);
904
- for (const cliOption of cliOptions) {
905
- if (!ignoreDefault && cliOption.config.default !== undefined) {
906
- for (const name of cliOption.names) {
907
- options[name] = cliOption.config.default;
908
- }
909
- }
910
- if (Array.isArray(cliOption.config.type)) {
911
- if (transforms[cliOption.name] === undefined) {
912
- transforms[cliOption.name] = Object.create(null);
913
- transforms[cliOption.name]["shouldTransform"] = true;
914
- transforms[cliOption.name]["transformFunction"] = cliOption.config.type[0];
915
- }
916
- }
917
- }
918
- for (const key of Object.keys(parsed)) {
919
- if (key !== "_") {
920
- const keys = key.split(".");
921
- setDotProp(options, keys, parsed[key]);
922
- setByType(options, transforms);
923
- }
924
- }
925
- return {
926
- args,
927
- options
928
- };
929
- }
930
- runMatchedCommand() {
931
- const { args, options, matchedCommand: command } = this;
932
- if (!command || !command.commandAction)
933
- return;
934
- command.checkUnknownOptions();
935
- command.checkOptionValue();
936
- command.checkRequiredArgs();
937
- const actionArgs = [];
938
- command.args.forEach((arg, index) => {
939
- if (arg.variadic) {
940
- actionArgs.push(args.slice(index));
941
- } else {
942
- actionArgs.push(args[index]);
943
- }
944
- });
945
- actionArgs.push(options);
946
- return command.commandAction.apply(this, actionArgs);
947
- }
948
- }
949
- var cac = (name = "") => new CAC(name);
950
- var dist_default = cac;
951
-
952
- // lib/config.ts
953
- import { existsSync, readFileSync } from "fs";
954
- import { join } from "path";
955
- import { homedir } from "os";
956
- var DEFAULT_CONFIG = {
957
- ollama: {
958
- url: "http://localhost:11434",
959
- defaultModel: "qwen3-coder:30b"
960
- },
961
- docker: {
962
- composeFile: "./docker-compose.yml",
963
- gpu: true
964
- },
965
- claude: {
966
- extraArgs: []
967
- }
968
- };
969
- function getConfigPaths() {
970
- const paths = [];
971
- const projectConfig = join(process.cwd(), ".loclaude", "config.json");
972
- paths.push(projectConfig);
973
- const userConfig = join(homedir(), ".config", "loclaude", "config.json");
974
- paths.push(userConfig);
975
- return paths;
976
- }
977
- function findConfigFile() {
978
- for (const path of getConfigPaths()) {
979
- if (existsSync(path)) {
980
- return path;
981
- }
982
- }
983
- return null;
984
- }
985
- function loadConfigFile(path) {
986
- try {
987
- const content = readFileSync(path, "utf-8");
988
- return JSON.parse(content);
989
- } catch (error) {
990
- console.warn(`Warning: Failed to parse config file ${path}`);
991
- return null;
992
- }
993
- }
994
- function loadConfigFiles() {
995
- const paths = getConfigPaths();
996
- let merged = {};
997
- for (const path of paths.reverse()) {
998
- if (existsSync(path)) {
999
- const config = loadConfigFile(path);
1000
- if (config) {
1001
- merged = deepMerge(merged, config);
1002
- }
1003
- }
1004
- }
1005
- return merged;
1006
- }
1007
- function loadEnvConfig() {
1008
- const config = {};
1009
- if (process.env.OLLAMA_URL) {
1010
- config.ollama = config.ollama || {};
1011
- config.ollama.url = process.env.OLLAMA_URL;
1012
- }
1013
- if (process.env.OLLAMA_MODEL) {
1014
- config.ollama = config.ollama || {};
1015
- config.ollama.defaultModel = process.env.OLLAMA_MODEL;
1016
- }
1017
- if (process.env.LOCLAUDE_COMPOSE_FILE) {
1018
- config.docker = config.docker || {};
1019
- config.docker.composeFile = process.env.LOCLAUDE_COMPOSE_FILE;
1020
- }
1021
- if (process.env.LOCLAUDE_GPU !== undefined) {
1022
- config.docker = config.docker || {};
1023
- config.docker.gpu = process.env.LOCLAUDE_GPU !== "false" && process.env.LOCLAUDE_GPU !== "0";
1024
- }
1025
- return config;
1026
- }
1027
- function deepMerge(a, b) {
1028
- const result = { ...a };
1029
- for (const key in b) {
1030
- if (Object.prototype.hasOwnProperty.call(b, key)) {
1031
- const bValue = b[key];
1032
- const aValue = a[key];
1033
- if (bValue !== undefined && typeof bValue === "object" && !Array.isArray(bValue) && aValue !== undefined && typeof aValue === "object" && !Array.isArray(aValue)) {
1034
- result[key] = deepMerge(aValue, bValue);
1035
- } else if (bValue !== undefined) {
1036
- result[key] = bValue;
1037
- }
1038
- }
1039
- }
1040
- return result;
1041
- }
1042
- function mergeWithDefaults(partial) {
1043
- return {
1044
- ollama: {
1045
- ...DEFAULT_CONFIG.ollama,
1046
- ...partial.ollama
1047
- },
1048
- docker: {
1049
- ...DEFAULT_CONFIG.docker,
1050
- ...partial.docker
1051
- },
1052
- claude: {
1053
- ...DEFAULT_CONFIG.claude,
1054
- ...partial.claude
1055
- }
1056
- };
1057
- }
1058
- var cachedConfig = null;
1059
- function loadConfig() {
1060
- if (cachedConfig) {
1061
- return cachedConfig;
1062
- }
1063
- const fileConfig = loadConfigFiles();
1064
- const envConfig = loadEnvConfig();
1065
- const merged = deepMerge(fileConfig, envConfig);
1066
- cachedConfig = mergeWithDefaults(merged);
1067
- return cachedConfig;
1068
- }
1069
- function getActiveConfigPath() {
1070
- return findConfigFile();
1071
- }
1072
- function getConfigSearchPaths() {
1073
- return getConfigPaths();
1074
- }
1075
- function getOllamaUrl() {
1076
- return loadConfig().ollama.url;
1077
- }
1078
- function getDefaultModel() {
1079
- return loadConfig().ollama.defaultModel;
1080
- }
1081
- function getComposeFile() {
1082
- return loadConfig().docker.composeFile;
1083
- }
1084
- function getClaudeExtraArgs() {
1085
- return loadConfig().claude.extraArgs;
1086
- }
1087
-
1088
- // lib/constants.ts
1089
- var OLLAMA_URL = getOllamaUrl();
1090
- var DEFAULT_MODEL = getDefaultModel();
1091
-
1092
- // ../../node_modules/.bun/@inquirer+core@11.1.1+c195ea72dffa657e/node_modules/@inquirer/core/dist/lib/key.js
1093
- var isUpKey = (key, keybindings = []) => key.name === "up" || keybindings.includes("vim") && key.name === "k" || keybindings.includes("emacs") && key.ctrl && key.name === "p";
1094
- var isDownKey = (key, keybindings = []) => key.name === "down" || keybindings.includes("vim") && key.name === "j" || keybindings.includes("emacs") && key.ctrl && key.name === "n";
1095
- var isBackspaceKey = (key) => key.name === "backspace";
1096
- var isNumberKey = (key) => "1234567890".includes(key.name);
1097
- var isEnterKey = (key) => key.name === "enter" || key.name === "return";
1098
- // ../../node_modules/.bun/@inquirer+core@11.1.1+c195ea72dffa657e/node_modules/@inquirer/core/dist/lib/errors.js
1099
- class AbortPromptError extends Error {
1100
- name = "AbortPromptError";
1101
- message = "Prompt was aborted";
1102
- constructor(options) {
1103
- super();
1104
- this.cause = options?.cause;
1105
- }
1106
- }
1107
-
1108
- class CancelPromptError extends Error {
1109
- name = "CancelPromptError";
1110
- message = "Prompt was canceled";
1111
- }
1112
-
1113
- class ExitPromptError extends Error {
1114
- name = "ExitPromptError";
1115
- }
1116
-
1117
- class HookError extends Error {
1118
- name = "HookError";
1119
- }
1120
-
1121
- class ValidationError extends Error {
1122
- name = "ValidationError";
1123
- }
1124
- // ../../node_modules/.bun/@inquirer+core@11.1.1+c195ea72dffa657e/node_modules/@inquirer/core/dist/lib/use-state.js
1125
- import { AsyncResource as AsyncResource2 } from "node:async_hooks";
1126
-
1127
- // ../../node_modules/.bun/@inquirer+core@11.1.1+c195ea72dffa657e/node_modules/@inquirer/core/dist/lib/hook-engine.js
1128
- import { AsyncLocalStorage, AsyncResource } from "node:async_hooks";
1129
- var hookStorage = new AsyncLocalStorage;
1130
- function createStore(rl) {
1131
- const store = {
1132
- rl,
1133
- hooks: [],
1134
- hooksCleanup: [],
1135
- hooksEffect: [],
1136
- index: 0,
1137
- handleChange() {}
1138
- };
1139
- return store;
1140
- }
1141
- function withHooks(rl, cb) {
1142
- const store = createStore(rl);
1143
- return hookStorage.run(store, () => {
1144
- function cycle(render) {
1145
- store.handleChange = () => {
1146
- store.index = 0;
1147
- render();
1148
- };
1149
- store.handleChange();
1150
- }
1151
- return cb(cycle);
1152
- });
1153
- }
1154
- function getStore() {
1155
- const store = hookStorage.getStore();
1156
- if (!store) {
1157
- throw new HookError("[Inquirer] Hook functions can only be called from within a prompt");
1158
- }
1159
- return store;
1160
- }
1161
- function readline() {
1162
- return getStore().rl;
1163
- }
1164
- function withUpdates(fn) {
1165
- const wrapped = (...args) => {
1166
- const store = getStore();
1167
- let shouldUpdate = false;
1168
- const oldHandleChange = store.handleChange;
1169
- store.handleChange = () => {
1170
- shouldUpdate = true;
1171
- };
1172
- const returnValue = fn(...args);
1173
- if (shouldUpdate) {
1174
- oldHandleChange();
1175
- }
1176
- store.handleChange = oldHandleChange;
1177
- return returnValue;
1178
- };
1179
- return AsyncResource.bind(wrapped);
1180
- }
1181
- function withPointer(cb) {
1182
- const store = getStore();
1183
- const { index } = store;
1184
- const pointer = {
1185
- get() {
1186
- return store.hooks[index];
1187
- },
1188
- set(value) {
1189
- store.hooks[index] = value;
1190
- },
1191
- initialized: index in store.hooks
1192
- };
1193
- const returnValue = cb(pointer);
1194
- store.index++;
1195
- return returnValue;
1196
- }
1197
- function handleChange() {
1198
- getStore().handleChange();
1199
- }
1200
- var effectScheduler = {
1201
- queue(cb) {
1202
- const store = getStore();
1203
- const { index } = store;
1204
- store.hooksEffect.push(() => {
1205
- store.hooksCleanup[index]?.();
1206
- const cleanFn = cb(readline());
1207
- if (cleanFn != null && typeof cleanFn !== "function") {
1208
- throw new ValidationError("useEffect return value must be a cleanup function or nothing.");
1209
- }
1210
- store.hooksCleanup[index] = cleanFn;
1211
- });
1212
- },
1213
- run() {
1214
- const store = getStore();
1215
- withUpdates(() => {
1216
- store.hooksEffect.forEach((effect) => {
1217
- effect();
1218
- });
1219
- store.hooksEffect.length = 0;
1220
- })();
1221
- },
1222
- clearAll() {
1223
- const store = getStore();
1224
- store.hooksCleanup.forEach((cleanFn) => {
1225
- cleanFn?.();
1226
- });
1227
- store.hooksEffect.length = 0;
1228
- store.hooksCleanup.length = 0;
1229
- }
1230
- };
1231
-
1232
- // ../../node_modules/.bun/@inquirer+core@11.1.1+c195ea72dffa657e/node_modules/@inquirer/core/dist/lib/use-state.js
1233
- function useState(defaultValue) {
1234
- return withPointer((pointer) => {
1235
- const setState = AsyncResource2.bind(function setState(newValue) {
1236
- if (pointer.get() !== newValue) {
1237
- pointer.set(newValue);
1238
- handleChange();
1239
- }
1240
- });
1241
- if (pointer.initialized) {
1242
- return [pointer.get(), setState];
1243
- }
1244
- const value = typeof defaultValue === "function" ? defaultValue() : defaultValue;
1245
- pointer.set(value);
1246
- return [value, setState];
1247
- });
1248
- }
1249
-
1250
- // ../../node_modules/.bun/@inquirer+core@11.1.1+c195ea72dffa657e/node_modules/@inquirer/core/dist/lib/use-effect.js
1251
- function useEffect(cb, depArray) {
1252
- withPointer((pointer) => {
1253
- const oldDeps = pointer.get();
1254
- const hasChanged = !Array.isArray(oldDeps) || depArray.some((dep, i) => !Object.is(dep, oldDeps[i]));
1255
- if (hasChanged) {
1256
- effectScheduler.queue(cb);
1257
- }
1258
- pointer.set(depArray);
1259
- });
1260
- }
1261
-
1262
- // ../../node_modules/.bun/@inquirer+core@11.1.1+c195ea72dffa657e/node_modules/@inquirer/core/dist/lib/theme.js
1263
- import { styleText } from "node:util";
1264
-
1265
- // ../../node_modules/.bun/@inquirer+figures@2.0.3/node_modules/@inquirer/figures/dist/index.js
1266
- import process2 from "node:process";
1267
- function isUnicodeSupported() {
1268
- if (process2.platform !== "win32") {
1269
- return process2.env["TERM"] !== "linux";
1270
- }
1271
- return Boolean(process2.env["WT_SESSION"]) || Boolean(process2.env["TERMINUS_SUBLIME"]) || process2.env["ConEmuTask"] === "{cmd::Cmder}" || process2.env["TERM_PROGRAM"] === "Terminus-Sublime" || process2.env["TERM_PROGRAM"] === "vscode" || process2.env["TERM"] === "xterm-256color" || process2.env["TERM"] === "alacritty" || process2.env["TERMINAL_EMULATOR"] === "JetBrains-JediTerm";
1272
- }
1273
- var common = {
1274
- circleQuestionMark: "(?)",
1275
- questionMarkPrefix: "(?)",
1276
- square: "█",
1277
- squareDarkShade: "▓",
1278
- squareMediumShade: "▒",
1279
- squareLightShade: "░",
1280
- squareTop: "▀",
1281
- squareBottom: "▄",
1282
- squareLeft: "▌",
1283
- squareRight: "▐",
1284
- squareCenter: "■",
1285
- bullet: "●",
1286
- dot: "․",
1287
- ellipsis: "…",
1288
- pointerSmall: "›",
1289
- triangleUp: "▲",
1290
- triangleUpSmall: "▴",
1291
- triangleDown: "▼",
1292
- triangleDownSmall: "▾",
1293
- triangleLeftSmall: "◂",
1294
- triangleRightSmall: "▸",
1295
- home: "⌂",
1296
- heart: "♥",
1297
- musicNote: "♪",
1298
- musicNoteBeamed: "♫",
1299
- arrowUp: "↑",
1300
- arrowDown: "↓",
1301
- arrowLeft: "←",
1302
- arrowRight: "→",
1303
- arrowLeftRight: "↔",
1304
- arrowUpDown: "↕",
1305
- almostEqual: "≈",
1306
- notEqual: "≠",
1307
- lessOrEqual: "≤",
1308
- greaterOrEqual: "≥",
1309
- identical: "≡",
1310
- infinity: "∞",
1311
- subscriptZero: "₀",
1312
- subscriptOne: "₁",
1313
- subscriptTwo: "₂",
1314
- subscriptThree: "₃",
1315
- subscriptFour: "₄",
1316
- subscriptFive: "₅",
1317
- subscriptSix: "₆",
1318
- subscriptSeven: "₇",
1319
- subscriptEight: "₈",
1320
- subscriptNine: "₉",
1321
- oneHalf: "½",
1322
- oneThird: "⅓",
1323
- oneQuarter: "¼",
1324
- oneFifth: "⅕",
1325
- oneSixth: "⅙",
1326
- oneEighth: "⅛",
1327
- twoThirds: "⅔",
1328
- twoFifths: "⅖",
1329
- threeQuarters: "¾",
1330
- threeFifths: "⅗",
1331
- threeEighths: "⅜",
1332
- fourFifths: "⅘",
1333
- fiveSixths: "⅚",
1334
- fiveEighths: "⅝",
1335
- sevenEighths: "⅞",
1336
- line: "─",
1337
- lineBold: "━",
1338
- lineDouble: "═",
1339
- lineDashed0: "┄",
1340
- lineDashed1: "┅",
1341
- lineDashed2: "┈",
1342
- lineDashed3: "┉",
1343
- lineDashed4: "╌",
1344
- lineDashed5: "╍",
1345
- lineDashed6: "╴",
1346
- lineDashed7: "╶",
1347
- lineDashed8: "╸",
1348
- lineDashed9: "╺",
1349
- lineDashed10: "╼",
1350
- lineDashed11: "╾",
1351
- lineDashed12: "−",
1352
- lineDashed13: "–",
1353
- lineDashed14: "‐",
1354
- lineDashed15: "⁃",
1355
- lineVertical: "│",
1356
- lineVerticalBold: "┃",
1357
- lineVerticalDouble: "║",
1358
- lineVerticalDashed0: "┆",
1359
- lineVerticalDashed1: "┇",
1360
- lineVerticalDashed2: "┊",
1361
- lineVerticalDashed3: "┋",
1362
- lineVerticalDashed4: "╎",
1363
- lineVerticalDashed5: "╏",
1364
- lineVerticalDashed6: "╵",
1365
- lineVerticalDashed7: "╷",
1366
- lineVerticalDashed8: "╹",
1367
- lineVerticalDashed9: "╻",
1368
- lineVerticalDashed10: "╽",
1369
- lineVerticalDashed11: "╿",
1370
- lineDownLeft: "┐",
1371
- lineDownLeftArc: "╮",
1372
- lineDownBoldLeftBold: "┓",
1373
- lineDownBoldLeft: "┒",
1374
- lineDownLeftBold: "┑",
1375
- lineDownDoubleLeftDouble: "╗",
1376
- lineDownDoubleLeft: "╖",
1377
- lineDownLeftDouble: "╕",
1378
- lineDownRight: "┌",
1379
- lineDownRightArc: "╭",
1380
- lineDownBoldRightBold: "┏",
1381
- lineDownBoldRight: "┎",
1382
- lineDownRightBold: "┍",
1383
- lineDownDoubleRightDouble: "╔",
1384
- lineDownDoubleRight: "╓",
1385
- lineDownRightDouble: "╒",
1386
- lineUpLeft: "┘",
1387
- lineUpLeftArc: "╯",
1388
- lineUpBoldLeftBold: "┛",
1389
- lineUpBoldLeft: "┚",
1390
- lineUpLeftBold: "┙",
1391
- lineUpDoubleLeftDouble: "╝",
1392
- lineUpDoubleLeft: "╜",
1393
- lineUpLeftDouble: "╛",
1394
- lineUpRight: "└",
1395
- lineUpRightArc: "╰",
1396
- lineUpBoldRightBold: "┗",
1397
- lineUpBoldRight: "┖",
1398
- lineUpRightBold: "┕",
1399
- lineUpDoubleRightDouble: "╚",
1400
- lineUpDoubleRight: "╙",
1401
- lineUpRightDouble: "╘",
1402
- lineUpDownLeft: "┤",
1403
- lineUpBoldDownBoldLeftBold: "┫",
1404
- lineUpBoldDownBoldLeft: "┨",
1405
- lineUpDownLeftBold: "┥",
1406
- lineUpBoldDownLeftBold: "┩",
1407
- lineUpDownBoldLeftBold: "┪",
1408
- lineUpDownBoldLeft: "┧",
1409
- lineUpBoldDownLeft: "┦",
1410
- lineUpDoubleDownDoubleLeftDouble: "╣",
1411
- lineUpDoubleDownDoubleLeft: "╢",
1412
- lineUpDownLeftDouble: "╡",
1413
- lineUpDownRight: "├",
1414
- lineUpBoldDownBoldRightBold: "┣",
1415
- lineUpBoldDownBoldRight: "┠",
1416
- lineUpDownRightBold: "┝",
1417
- lineUpBoldDownRightBold: "┡",
1418
- lineUpDownBoldRightBold: "┢",
1419
- lineUpDownBoldRight: "┟",
1420
- lineUpBoldDownRight: "┞",
1421
- lineUpDoubleDownDoubleRightDouble: "╠",
1422
- lineUpDoubleDownDoubleRight: "╟",
1423
- lineUpDownRightDouble: "╞",
1424
- lineDownLeftRight: "┬",
1425
- lineDownBoldLeftBoldRightBold: "┳",
1426
- lineDownLeftBoldRightBold: "┯",
1427
- lineDownBoldLeftRight: "┰",
1428
- lineDownBoldLeftBoldRight: "┱",
1429
- lineDownBoldLeftRightBold: "┲",
1430
- lineDownLeftRightBold: "┮",
1431
- lineDownLeftBoldRight: "┭",
1432
- lineDownDoubleLeftDoubleRightDouble: "╦",
1433
- lineDownDoubleLeftRight: "╥",
1434
- lineDownLeftDoubleRightDouble: "╤",
1435
- lineUpLeftRight: "┴",
1436
- lineUpBoldLeftBoldRightBold: "┻",
1437
- lineUpLeftBoldRightBold: "┷",
1438
- lineUpBoldLeftRight: "┸",
1439
- lineUpBoldLeftBoldRight: "┹",
1440
- lineUpBoldLeftRightBold: "┺",
1441
- lineUpLeftRightBold: "┶",
1442
- lineUpLeftBoldRight: "┵",
1443
- lineUpDoubleLeftDoubleRightDouble: "╩",
1444
- lineUpDoubleLeftRight: "╨",
1445
- lineUpLeftDoubleRightDouble: "╧",
1446
- lineUpDownLeftRight: "┼",
1447
- lineUpBoldDownBoldLeftBoldRightBold: "╋",
1448
- lineUpDownBoldLeftBoldRightBold: "╈",
1449
- lineUpBoldDownLeftBoldRightBold: "╇",
1450
- lineUpBoldDownBoldLeftRightBold: "╊",
1451
- lineUpBoldDownBoldLeftBoldRight: "╉",
1452
- lineUpBoldDownLeftRight: "╀",
1453
- lineUpDownBoldLeftRight: "╁",
1454
- lineUpDownLeftBoldRight: "┽",
1455
- lineUpDownLeftRightBold: "┾",
1456
- lineUpBoldDownBoldLeftRight: "╂",
1457
- lineUpDownLeftBoldRightBold: "┿",
1458
- lineUpBoldDownLeftBoldRight: "╃",
1459
- lineUpBoldDownLeftRightBold: "╄",
1460
- lineUpDownBoldLeftBoldRight: "╅",
1461
- lineUpDownBoldLeftRightBold: "╆",
1462
- lineUpDoubleDownDoubleLeftDoubleRightDouble: "╬",
1463
- lineUpDoubleDownDoubleLeftRight: "╫",
1464
- lineUpDownLeftDoubleRightDouble: "╪",
1465
- lineCross: "╳",
1466
- lineBackslash: "╲",
1467
- lineSlash: "╱"
1468
- };
1469
- var specialMainSymbols = {
1470
- tick: "✔",
1471
- info: "ℹ",
1472
- warning: "⚠",
1473
- cross: "✘",
1474
- squareSmall: "◻",
1475
- squareSmallFilled: "◼",
1476
- circle: "◯",
1477
- circleFilled: "◉",
1478
- circleDotted: "◌",
1479
- circleDouble: "◎",
1480
- circleCircle: "ⓞ",
1481
- circleCross: "ⓧ",
1482
- circlePipe: "Ⓘ",
1483
- radioOn: "◉",
1484
- radioOff: "◯",
1485
- checkboxOn: "☒",
1486
- checkboxOff: "☐",
1487
- checkboxCircleOn: "ⓧ",
1488
- checkboxCircleOff: "Ⓘ",
1489
- pointer: "❯",
1490
- triangleUpOutline: "△",
1491
- triangleLeft: "◀",
1492
- triangleRight: "▶",
1493
- lozenge: "◆",
1494
- lozengeOutline: "◇",
1495
- hamburger: "☰",
1496
- smiley: "㋡",
1497
- mustache: "෴",
1498
- star: "★",
1499
- play: "▶",
1500
- nodejs: "⬢",
1501
- oneSeventh: "⅐",
1502
- oneNinth: "⅑",
1503
- oneTenth: "⅒"
1504
- };
1505
- var specialFallbackSymbols = {
1506
- tick: "√",
1507
- info: "i",
1508
- warning: "‼",
1509
- cross: "×",
1510
- squareSmall: "□",
1511
- squareSmallFilled: "■",
1512
- circle: "( )",
1513
- circleFilled: "(*)",
1514
- circleDotted: "( )",
1515
- circleDouble: "( )",
1516
- circleCircle: "(○)",
1517
- circleCross: "(×)",
1518
- circlePipe: "(│)",
1519
- radioOn: "(*)",
1520
- radioOff: "( )",
1521
- checkboxOn: "[×]",
1522
- checkboxOff: "[ ]",
1523
- checkboxCircleOn: "(×)",
1524
- checkboxCircleOff: "( )",
1525
- pointer: ">",
1526
- triangleUpOutline: "∆",
1527
- triangleLeft: "◄",
1528
- triangleRight: "►",
1529
- lozenge: "♦",
1530
- lozengeOutline: "◊",
1531
- hamburger: "≡",
1532
- smiley: "☺",
1533
- mustache: "┌─┐",
1534
- star: "✶",
1535
- play: "►",
1536
- nodejs: "♦",
1537
- oneSeventh: "1/7",
1538
- oneNinth: "1/9",
1539
- oneTenth: "1/10"
1540
- };
1541
- var mainSymbols = {
1542
- ...common,
1543
- ...specialMainSymbols
1544
- };
1545
- var fallbackSymbols = {
1546
- ...common,
1547
- ...specialFallbackSymbols
1548
- };
1549
- var shouldUseMain = isUnicodeSupported();
1550
- var figures = shouldUseMain ? mainSymbols : fallbackSymbols;
1551
- var dist_default2 = figures;
1552
- var replacements = Object.entries(specialMainSymbols);
1553
-
1554
- // ../../node_modules/.bun/@inquirer+core@11.1.1+c195ea72dffa657e/node_modules/@inquirer/core/dist/lib/theme.js
1555
- var defaultTheme = {
1556
- prefix: {
1557
- idle: styleText("blue", "?"),
1558
- done: styleText("green", dist_default2.tick)
1559
- },
1560
- spinner: {
1561
- interval: 80,
1562
- frames: ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"].map((frame) => styleText("yellow", frame))
1563
- },
1564
- style: {
1565
- answer: (text) => styleText("cyan", text),
1566
- message: (text) => styleText("bold", text),
1567
- error: (text) => styleText("red", `> ${text}`),
1568
- defaultAnswer: (text) => styleText("dim", `(${text})`),
1569
- help: (text) => styleText("dim", text),
1570
- highlight: (text) => styleText("cyan", text),
1571
- key: (text) => styleText("cyan", styleText("bold", `<${text}>`))
1572
- }
1573
- };
1574
-
1575
- // ../../node_modules/.bun/@inquirer+core@11.1.1+c195ea72dffa657e/node_modules/@inquirer/core/dist/lib/make-theme.js
1576
- function isPlainObject(value) {
1577
- if (typeof value !== "object" || value === null)
1578
- return false;
1579
- let proto = value;
1580
- while (Object.getPrototypeOf(proto) !== null) {
1581
- proto = Object.getPrototypeOf(proto);
1582
- }
1583
- return Object.getPrototypeOf(value) === proto;
1584
- }
1585
- function deepMerge2(...objects) {
1586
- const output = {};
1587
- for (const obj of objects) {
1588
- for (const [key, value] of Object.entries(obj)) {
1589
- const prevValue = output[key];
1590
- output[key] = isPlainObject(prevValue) && isPlainObject(value) ? deepMerge2(prevValue, value) : value;
1591
- }
1592
- }
1593
- return output;
1594
- }
1595
- function makeTheme(...themes) {
1596
- const themesToMerge = [
1597
- defaultTheme,
1598
- ...themes.filter((theme) => theme != null)
1599
- ];
1600
- return deepMerge2(...themesToMerge);
1601
- }
1602
-
1603
- // ../../node_modules/.bun/@inquirer+core@11.1.1+c195ea72dffa657e/node_modules/@inquirer/core/dist/lib/use-prefix.js
1604
- function usePrefix({ status = "idle", theme }) {
1605
- const [showLoader, setShowLoader] = useState(false);
1606
- const [tick, setTick] = useState(0);
1607
- const { prefix, spinner } = makeTheme(theme);
1608
- useEffect(() => {
1609
- if (status === "loading") {
1610
- let tickInterval;
1611
- let inc = -1;
1612
- const delayTimeout = setTimeout(() => {
1613
- setShowLoader(true);
1614
- tickInterval = setInterval(() => {
1615
- inc = inc + 1;
1616
- setTick(inc % spinner.frames.length);
1617
- }, spinner.interval);
1618
- }, 300);
1619
- return () => {
1620
- clearTimeout(delayTimeout);
1621
- clearInterval(tickInterval);
1622
- };
1623
- } else {
1624
- setShowLoader(false);
1625
- }
1626
- }, [status]);
1627
- if (showLoader) {
1628
- return spinner.frames[tick];
1629
- }
1630
- const iconName = status === "loading" ? "idle" : status;
1631
- return typeof prefix === "string" ? prefix : prefix[iconName] ?? prefix["idle"];
1632
- }
1633
- // ../../node_modules/.bun/@inquirer+core@11.1.1+c195ea72dffa657e/node_modules/@inquirer/core/dist/lib/use-memo.js
1634
- function useMemo(fn, dependencies) {
1635
- return withPointer((pointer) => {
1636
- const prev = pointer.get();
1637
- if (!prev || prev.dependencies.length !== dependencies.length || prev.dependencies.some((dep, i) => dep !== dependencies[i])) {
1638
- const value = fn();
1639
- pointer.set({ value, dependencies });
1640
- return value;
1641
- }
1642
- return prev.value;
1643
- });
1644
- }
1645
- // ../../node_modules/.bun/@inquirer+core@11.1.1+c195ea72dffa657e/node_modules/@inquirer/core/dist/lib/use-ref.js
1646
- function useRef(val) {
1647
- return useState({ current: val })[0];
1648
- }
1649
- // ../../node_modules/.bun/@inquirer+core@11.1.1+c195ea72dffa657e/node_modules/@inquirer/core/dist/lib/use-keypress.js
1650
- function useKeypress(userHandler) {
1651
- const signal = useRef(userHandler);
1652
- signal.current = userHandler;
1653
- useEffect((rl) => {
1654
- let ignore = false;
1655
- const handler = withUpdates((_input, event) => {
1656
- if (ignore)
1657
- return;
1658
- signal.current(event, rl);
1659
- });
1660
- rl.input.on("keypress", handler);
1661
- return () => {
1662
- ignore = true;
1663
- rl.input.removeListener("keypress", handler);
1664
- };
1665
- }, []);
1666
- }
1667
- // ../../node_modules/.bun/@inquirer+core@11.1.1+c195ea72dffa657e/node_modules/@inquirer/core/dist/lib/utils.js
1668
- var import_cli_width = __toESM(require_cli_width(), 1);
1669
-
1670
- // ../../node_modules/.bun/ansi-regex@6.2.2/node_modules/ansi-regex/index.js
1671
- function ansiRegex({ onlyFirst = false } = {}) {
1672
- const ST = "(?:\\u0007|\\u001B\\u005C|\\u009C)";
1673
- const osc = `(?:\\u001B\\][\\s\\S]*?${ST})`;
1674
- const csi = "[\\u001B\\u009B][[\\]()#;?]*(?:\\d{1,4}(?:[;:]\\d{0,4})*)?[\\dA-PR-TZcf-nq-uy=><~]";
1675
- const pattern = `${osc}|${csi}`;
1676
- return new RegExp(pattern, onlyFirst ? undefined : "g");
1677
- }
1678
-
1679
- // ../../node_modules/.bun/strip-ansi@7.1.2/node_modules/strip-ansi/index.js
1680
- var regex = ansiRegex();
1681
- function stripAnsi(string) {
1682
- if (typeof string !== "string") {
1683
- throw new TypeError(`Expected a \`string\`, got \`${typeof string}\``);
1684
- }
1685
- return string.replace(regex, "");
1686
- }
1687
-
1688
- // ../../node_modules/.bun/get-east-asian-width@1.4.0/node_modules/get-east-asian-width/lookup.js
1689
- function isAmbiguous(x) {
1690
- 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;
1691
- }
1692
- function isFullWidth(x) {
1693
- return x === 12288 || x >= 65281 && x <= 65376 || x >= 65504 && x <= 65510;
1694
- }
1695
- function isWide(x) {
1696
- 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 >= 9776 && x <= 9783 || x >= 9800 && x <= 9811 || x === 9855 || x >= 9866 && x <= 9871 || 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 <= 12773 || x >= 12783 && x <= 12830 || x >= 12832 && x <= 12871 || x >= 12880 && 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 <= 94198 || x >= 94208 && x <= 101589 || x >= 101631 && x <= 101662 || x >= 101760 && x <= 101874 || 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 >= 119552 && x <= 119638 || x >= 119648 && x <= 119670 || 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 <= 128728 || 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 <= 129674 || x >= 129678 && x <= 129734 || x === 129736 || x >= 129741 && x <= 129756 || x >= 129759 && x <= 129770 || x >= 129775 && x <= 129784 || x >= 131072 && x <= 196605 || x >= 196608 && x <= 262141;
1697
- }
1698
-
1699
- // ../../node_modules/.bun/get-east-asian-width@1.4.0/node_modules/get-east-asian-width/index.js
1700
- function validate(codePoint) {
1701
- if (!Number.isSafeInteger(codePoint)) {
1702
- throw new TypeError(`Expected a code point, got \`${typeof codePoint}\`.`);
1703
- }
1704
- }
1705
- function eastAsianWidth(codePoint, { ambiguousAsWide = false } = {}) {
1706
- validate(codePoint);
1707
- if (isFullWidth(codePoint) || isWide(codePoint) || ambiguousAsWide && isAmbiguous(codePoint)) {
1708
- return 2;
1709
- }
1710
- return 1;
1711
- }
1712
-
1713
- // ../../node_modules/.bun/string-width@7.2.0/node_modules/string-width/index.js
1714
- var import_emoji_regex = __toESM(require_emoji_regex(), 1);
1715
- var segmenter = new Intl.Segmenter;
1716
- var defaultIgnorableCodePointRegex = /^\p{Default_Ignorable_Code_Point}$/u;
1717
- function stringWidth(string, options = {}) {
1718
- if (typeof string !== "string" || string.length === 0) {
1719
- return 0;
1720
- }
1721
- const {
1722
- ambiguousIsNarrow = true,
1723
- countAnsiEscapeCodes = false
1724
- } = options;
1725
- if (!countAnsiEscapeCodes) {
1726
- string = stripAnsi(string);
1727
- }
1728
- if (string.length === 0) {
1729
- return 0;
1730
- }
1731
- let width = 0;
1732
- const eastAsianWidthOptions = { ambiguousAsWide: !ambiguousIsNarrow };
1733
- for (const { segment: character } of segmenter.segment(string)) {
1734
- const codePoint = character.codePointAt(0);
1735
- if (codePoint <= 31 || codePoint >= 127 && codePoint <= 159) {
1736
- continue;
1737
- }
1738
- if (codePoint >= 8203 && codePoint <= 8207 || codePoint === 65279) {
1739
- continue;
1740
- }
1741
- if (codePoint >= 768 && codePoint <= 879 || codePoint >= 6832 && codePoint <= 6911 || codePoint >= 7616 && codePoint <= 7679 || codePoint >= 8400 && codePoint <= 8447 || codePoint >= 65056 && codePoint <= 65071) {
1742
- continue;
1743
- }
1744
- if (codePoint >= 55296 && codePoint <= 57343) {
1745
- continue;
1746
- }
1747
- if (codePoint >= 65024 && codePoint <= 65039) {
1748
- continue;
1749
- }
1750
- if (defaultIgnorableCodePointRegex.test(character)) {
1751
- continue;
1752
- }
1753
- if (import_emoji_regex.default().test(character)) {
1754
- width += 2;
1755
- continue;
1756
- }
1757
- width += eastAsianWidth(codePoint, eastAsianWidthOptions);
1758
- }
1759
- return width;
1760
- }
1761
-
1762
- // ../../node_modules/.bun/ansi-styles@6.2.3/node_modules/ansi-styles/index.js
1763
- var ANSI_BACKGROUND_OFFSET = 10;
1764
- var wrapAnsi16 = (offset = 0) => (code) => `\x1B[${code + offset}m`;
1765
- var wrapAnsi256 = (offset = 0) => (code) => `\x1B[${38 + offset};5;${code}m`;
1766
- var wrapAnsi16m = (offset = 0) => (red, green, blue) => `\x1B[${38 + offset};2;${red};${green};${blue}m`;
1767
- var styles = {
1768
- modifier: {
1769
- reset: [0, 0],
1770
- bold: [1, 22],
1771
- dim: [2, 22],
1772
- italic: [3, 23],
1773
- underline: [4, 24],
1774
- overline: [53, 55],
1775
- inverse: [7, 27],
1776
- hidden: [8, 28],
1777
- strikethrough: [9, 29]
1778
- },
1779
- color: {
1780
- black: [30, 39],
1781
- red: [31, 39],
1782
- green: [32, 39],
1783
- yellow: [33, 39],
1784
- blue: [34, 39],
1785
- magenta: [35, 39],
1786
- cyan: [36, 39],
1787
- white: [37, 39],
1788
- blackBright: [90, 39],
1789
- gray: [90, 39],
1790
- grey: [90, 39],
1791
- redBright: [91, 39],
1792
- greenBright: [92, 39],
1793
- yellowBright: [93, 39],
1794
- blueBright: [94, 39],
1795
- magentaBright: [95, 39],
1796
- cyanBright: [96, 39],
1797
- whiteBright: [97, 39]
1798
- },
1799
- bgColor: {
1800
- bgBlack: [40, 49],
1801
- bgRed: [41, 49],
1802
- bgGreen: [42, 49],
1803
- bgYellow: [43, 49],
1804
- bgBlue: [44, 49],
1805
- bgMagenta: [45, 49],
1806
- bgCyan: [46, 49],
1807
- bgWhite: [47, 49],
1808
- bgBlackBright: [100, 49],
1809
- bgGray: [100, 49],
1810
- bgGrey: [100, 49],
1811
- bgRedBright: [101, 49],
1812
- bgGreenBright: [102, 49],
1813
- bgYellowBright: [103, 49],
1814
- bgBlueBright: [104, 49],
1815
- bgMagentaBright: [105, 49],
1816
- bgCyanBright: [106, 49],
1817
- bgWhiteBright: [107, 49]
1818
- }
1819
- };
1820
- var modifierNames = Object.keys(styles.modifier);
1821
- var foregroundColorNames = Object.keys(styles.color);
1822
- var backgroundColorNames = Object.keys(styles.bgColor);
1823
- var colorNames = [...foregroundColorNames, ...backgroundColorNames];
1824
- function assembleStyles() {
1825
- const codes = new Map;
1826
- for (const [groupName, group] of Object.entries(styles)) {
1827
- for (const [styleName, style] of Object.entries(group)) {
1828
- styles[styleName] = {
1829
- open: `\x1B[${style[0]}m`,
1830
- close: `\x1B[${style[1]}m`
1831
- };
1832
- group[styleName] = styles[styleName];
1833
- codes.set(style[0], style[1]);
1834
- }
1835
- Object.defineProperty(styles, groupName, {
1836
- value: group,
1837
- enumerable: false
1838
- });
1839
- }
1840
- Object.defineProperty(styles, "codes", {
1841
- value: codes,
1842
- enumerable: false
1843
- });
1844
- styles.color.close = "\x1B[39m";
1845
- styles.bgColor.close = "\x1B[49m";
1846
- styles.color.ansi = wrapAnsi16();
1847
- styles.color.ansi256 = wrapAnsi256();
1848
- styles.color.ansi16m = wrapAnsi16m();
1849
- styles.bgColor.ansi = wrapAnsi16(ANSI_BACKGROUND_OFFSET);
1850
- styles.bgColor.ansi256 = wrapAnsi256(ANSI_BACKGROUND_OFFSET);
1851
- styles.bgColor.ansi16m = wrapAnsi16m(ANSI_BACKGROUND_OFFSET);
1852
- Object.defineProperties(styles, {
1853
- rgbToAnsi256: {
1854
- value(red, green, blue) {
1855
- if (red === green && green === blue) {
1856
- if (red < 8) {
1857
- return 16;
1858
- }
1859
- if (red > 248) {
1860
- return 231;
1861
- }
1862
- return Math.round((red - 8) / 247 * 24) + 232;
1863
- }
1864
- return 16 + 36 * Math.round(red / 255 * 5) + 6 * Math.round(green / 255 * 5) + Math.round(blue / 255 * 5);
1865
- },
1866
- enumerable: false
1867
- },
1868
- hexToRgb: {
1869
- value(hex) {
1870
- const matches = /[a-f\d]{6}|[a-f\d]{3}/i.exec(hex.toString(16));
1871
- if (!matches) {
1872
- return [0, 0, 0];
1873
- }
1874
- let [colorString] = matches;
1875
- if (colorString.length === 3) {
1876
- colorString = [...colorString].map((character) => character + character).join("");
1877
- }
1878
- const integer = Number.parseInt(colorString, 16);
1879
- return [
1880
- integer >> 16 & 255,
1881
- integer >> 8 & 255,
1882
- integer & 255
1883
- ];
1884
- },
1885
- enumerable: false
1886
- },
1887
- hexToAnsi256: {
1888
- value: (hex) => styles.rgbToAnsi256(...styles.hexToRgb(hex)),
1889
- enumerable: false
1890
- },
1891
- ansi256ToAnsi: {
1892
- value(code) {
1893
- if (code < 8) {
1894
- return 30 + code;
1895
- }
1896
- if (code < 16) {
1897
- return 90 + (code - 8);
1898
- }
1899
- let red;
1900
- let green;
1901
- let blue;
1902
- if (code >= 232) {
1903
- red = ((code - 232) * 10 + 8) / 255;
1904
- green = red;
1905
- blue = red;
1906
- } else {
1907
- code -= 16;
1908
- const remainder = code % 36;
1909
- red = Math.floor(code / 36) / 5;
1910
- green = Math.floor(remainder / 6) / 5;
1911
- blue = remainder % 6 / 5;
1912
- }
1913
- const value = Math.max(red, green, blue) * 2;
1914
- if (value === 0) {
1915
- return 30;
1916
- }
1917
- let result = 30 + (Math.round(blue) << 2 | Math.round(green) << 1 | Math.round(red));
1918
- if (value === 2) {
1919
- result += 60;
1920
- }
1921
- return result;
1922
- },
1923
- enumerable: false
1924
- },
1925
- rgbToAnsi: {
1926
- value: (red, green, blue) => styles.ansi256ToAnsi(styles.rgbToAnsi256(red, green, blue)),
1927
- enumerable: false
1928
- },
1929
- hexToAnsi: {
1930
- value: (hex) => styles.ansi256ToAnsi(styles.hexToAnsi256(hex)),
1931
- enumerable: false
1932
- }
1933
- });
1934
- return styles;
1935
- }
1936
- var ansiStyles = assembleStyles();
1937
- var ansi_styles_default = ansiStyles;
1938
-
1939
- // ../../node_modules/.bun/wrap-ansi@9.0.2/node_modules/wrap-ansi/index.js
1940
- var ESCAPES = new Set([
1941
- "\x1B",
1942
- "›"
1943
- ]);
1944
- var END_CODE = 39;
1945
- var ANSI_ESCAPE_BELL = "\x07";
1946
- var ANSI_CSI = "[";
1947
- var ANSI_OSC = "]";
1948
- var ANSI_SGR_TERMINATOR = "m";
1949
- var ANSI_ESCAPE_LINK = `${ANSI_OSC}8;;`;
1950
- var wrapAnsiCode = (code) => `${ESCAPES.values().next().value}${ANSI_CSI}${code}${ANSI_SGR_TERMINATOR}`;
1951
- var wrapAnsiHyperlink = (url) => `${ESCAPES.values().next().value}${ANSI_ESCAPE_LINK}${url}${ANSI_ESCAPE_BELL}`;
1952
- var wordLengths = (string) => string.split(" ").map((character) => stringWidth(character));
1953
- var wrapWord = (rows, word, columns) => {
1954
- const characters = [...word];
1955
- let isInsideEscape = false;
1956
- let isInsideLinkEscape = false;
1957
- let visible = stringWidth(stripAnsi(rows.at(-1)));
1958
- for (const [index, character] of characters.entries()) {
1959
- const characterLength = stringWidth(character);
1960
- if (visible + characterLength <= columns) {
1961
- rows[rows.length - 1] += character;
1962
- } else {
1963
- rows.push(character);
1964
- visible = 0;
1965
- }
1966
- if (ESCAPES.has(character)) {
1967
- isInsideEscape = true;
1968
- const ansiEscapeLinkCandidate = characters.slice(index + 1, index + 1 + ANSI_ESCAPE_LINK.length).join("");
1969
- isInsideLinkEscape = ansiEscapeLinkCandidate === ANSI_ESCAPE_LINK;
1970
- }
1971
- if (isInsideEscape) {
1972
- if (isInsideLinkEscape) {
1973
- if (character === ANSI_ESCAPE_BELL) {
1974
- isInsideEscape = false;
1975
- isInsideLinkEscape = false;
1976
- }
1977
- } else if (character === ANSI_SGR_TERMINATOR) {
1978
- isInsideEscape = false;
1979
- }
1980
- continue;
1981
- }
1982
- visible += characterLength;
1983
- if (visible === columns && index < characters.length - 1) {
1984
- rows.push("");
1985
- visible = 0;
1986
- }
1987
- }
1988
- if (!visible && rows.at(-1).length > 0 && rows.length > 1) {
1989
- rows[rows.length - 2] += rows.pop();
1990
- }
1991
- };
1992
- var stringVisibleTrimSpacesRight = (string) => {
1993
- const words = string.split(" ");
1994
- let last = words.length;
1995
- while (last > 0) {
1996
- if (stringWidth(words[last - 1]) > 0) {
1997
- break;
1998
- }
1999
- last--;
2000
- }
2001
- if (last === words.length) {
2002
- return string;
2003
- }
2004
- return words.slice(0, last).join(" ") + words.slice(last).join("");
2005
- };
2006
- var exec = (string, columns, options = {}) => {
2007
- if (options.trim !== false && string.trim() === "") {
2008
- return "";
2009
- }
2010
- let returnValue = "";
2011
- let escapeCode;
2012
- let escapeUrl;
2013
- const lengths = wordLengths(string);
2014
- let rows = [""];
2015
- for (const [index, word] of string.split(" ").entries()) {
2016
- if (options.trim !== false) {
2017
- rows[rows.length - 1] = rows.at(-1).trimStart();
2018
- }
2019
- let rowLength = stringWidth(rows.at(-1));
2020
- if (index !== 0) {
2021
- if (rowLength >= columns && (options.wordWrap === false || options.trim === false)) {
2022
- rows.push("");
2023
- rowLength = 0;
2024
- }
2025
- if (rowLength > 0 || options.trim === false) {
2026
- rows[rows.length - 1] += " ";
2027
- rowLength++;
2028
- }
2029
- }
2030
- if (options.hard && lengths[index] > columns) {
2031
- const remainingColumns = columns - rowLength;
2032
- const breaksStartingThisLine = 1 + Math.floor((lengths[index] - remainingColumns - 1) / columns);
2033
- const breaksStartingNextLine = Math.floor((lengths[index] - 1) / columns);
2034
- if (breaksStartingNextLine < breaksStartingThisLine) {
2035
- rows.push("");
2036
- }
2037
- wrapWord(rows, word, columns);
2038
- continue;
2039
- }
2040
- if (rowLength + lengths[index] > columns && rowLength > 0 && lengths[index] > 0) {
2041
- if (options.wordWrap === false && rowLength < columns) {
2042
- wrapWord(rows, word, columns);
2043
- continue;
2044
- }
2045
- rows.push("");
2046
- }
2047
- if (rowLength + lengths[index] > columns && options.wordWrap === false) {
2048
- wrapWord(rows, word, columns);
2049
- continue;
2050
- }
2051
- rows[rows.length - 1] += word;
2052
- }
2053
- if (options.trim !== false) {
2054
- rows = rows.map((row) => stringVisibleTrimSpacesRight(row));
2055
- }
2056
- const preString = rows.join(`
2057
- `);
2058
- const pre = [...preString];
2059
- let preStringIndex = 0;
2060
- for (const [index, character] of pre.entries()) {
2061
- returnValue += character;
2062
- if (ESCAPES.has(character)) {
2063
- const { groups } = new RegExp(`(?:\\${ANSI_CSI}(?<code>\\d+)m|\\${ANSI_ESCAPE_LINK}(?<uri>.*)${ANSI_ESCAPE_BELL})`).exec(preString.slice(preStringIndex)) || { groups: {} };
2064
- if (groups.code !== undefined) {
2065
- const code2 = Number.parseFloat(groups.code);
2066
- escapeCode = code2 === END_CODE ? undefined : code2;
2067
- } else if (groups.uri !== undefined) {
2068
- escapeUrl = groups.uri.length === 0 ? undefined : groups.uri;
2069
- }
2070
- }
2071
- const code = ansi_styles_default.codes.get(Number(escapeCode));
2072
- if (pre[index + 1] === `
2073
- `) {
2074
- if (escapeUrl) {
2075
- returnValue += wrapAnsiHyperlink("");
2076
- }
2077
- if (escapeCode && code) {
2078
- returnValue += wrapAnsiCode(code);
2079
- }
2080
- } else if (character === `
2081
- `) {
2082
- if (escapeCode && code) {
2083
- returnValue += wrapAnsiCode(escapeCode);
2084
- }
2085
- if (escapeUrl) {
2086
- returnValue += wrapAnsiHyperlink(escapeUrl);
2087
- }
2088
- }
2089
- preStringIndex += character.length;
2090
- }
2091
- return returnValue;
2092
- };
2093
- function wrapAnsi(string, columns, options) {
2094
- return String(string).normalize().replaceAll(`\r
2095
- `, `
2096
- `).split(`
2097
- `).map((line) => exec(line, columns, options)).join(`
2098
- `);
2099
- }
2100
-
2101
- // ../../node_modules/.bun/@inquirer+core@11.1.1+c195ea72dffa657e/node_modules/@inquirer/core/dist/lib/utils.js
2102
- function breakLines(content, width) {
2103
- return content.split(`
2104
- `).flatMap((line) => wrapAnsi(line, width, { trim: false, hard: true }).split(`
2105
- `).map((str) => str.trimEnd())).join(`
2106
- `);
2107
- }
2108
- function readlineWidth() {
2109
- return import_cli_width.default({ defaultWidth: 80, output: readline().output });
2110
- }
2111
-
2112
- // ../../node_modules/.bun/@inquirer+core@11.1.1+c195ea72dffa657e/node_modules/@inquirer/core/dist/lib/pagination/use-pagination.js
2113
- function usePointerPosition({ active, renderedItems, pageSize, loop }) {
2114
- const state = useRef({
2115
- lastPointer: active,
2116
- lastActive: undefined
2117
- });
2118
- const { lastPointer, lastActive } = state.current;
2119
- const middle = Math.floor(pageSize / 2);
2120
- const renderedLength = renderedItems.reduce((acc, item) => acc + item.length, 0);
2121
- const defaultPointerPosition = renderedItems.slice(0, active).reduce((acc, item) => acc + item.length, 0);
2122
- let pointer = defaultPointerPosition;
2123
- if (renderedLength > pageSize) {
2124
- if (loop) {
2125
- pointer = lastPointer;
2126
- if (lastActive != null && lastActive < active && active - lastActive < pageSize) {
2127
- pointer = Math.min(middle, Math.abs(active - lastActive) === 1 ? Math.min(lastPointer + (renderedItems[lastActive]?.length ?? 0), Math.max(defaultPointerPosition, lastPointer)) : lastPointer + active - lastActive);
2128
- }
2129
- } else {
2130
- const spaceUnderActive = renderedItems.slice(active).reduce((acc, item) => acc + item.length, 0);
2131
- pointer = spaceUnderActive < pageSize - middle ? pageSize - spaceUnderActive : Math.min(defaultPointerPosition, middle);
2132
- }
2133
- }
2134
- state.current.lastPointer = pointer;
2135
- state.current.lastActive = active;
2136
- return pointer;
2137
- }
2138
- function usePagination({ items, active, renderItem, pageSize, loop = true }) {
2139
- const width = readlineWidth();
2140
- const bound = (num) => (num % items.length + items.length) % items.length;
2141
- const renderedItems = items.map((item, index) => {
2142
- if (item == null)
2143
- return [];
2144
- return breakLines(renderItem({ item, index, isActive: index === active }), width).split(`
2145
- `);
2146
- });
2147
- const renderedLength = renderedItems.reduce((acc, item) => acc + item.length, 0);
2148
- const renderItemAtIndex = (index) => renderedItems[index] ?? [];
2149
- const pointer = usePointerPosition({ active, renderedItems, pageSize, loop });
2150
- const activeItem = renderItemAtIndex(active).slice(0, pageSize);
2151
- const activeItemPosition = pointer + activeItem.length <= pageSize ? pointer : pageSize - activeItem.length;
2152
- const pageBuffer = Array.from({ length: pageSize });
2153
- pageBuffer.splice(activeItemPosition, activeItem.length, ...activeItem);
2154
- const itemVisited = new Set([active]);
2155
- let bufferPointer = activeItemPosition + activeItem.length;
2156
- let itemPointer = bound(active + 1);
2157
- while (bufferPointer < pageSize && !itemVisited.has(itemPointer) && (loop && renderedLength > pageSize ? itemPointer !== active : itemPointer > active)) {
2158
- const lines = renderItemAtIndex(itemPointer);
2159
- const linesToAdd = lines.slice(0, pageSize - bufferPointer);
2160
- pageBuffer.splice(bufferPointer, linesToAdd.length, ...linesToAdd);
2161
- itemVisited.add(itemPointer);
2162
- bufferPointer += linesToAdd.length;
2163
- itemPointer = bound(itemPointer + 1);
2164
- }
2165
- bufferPointer = activeItemPosition - 1;
2166
- itemPointer = bound(active - 1);
2167
- while (bufferPointer >= 0 && !itemVisited.has(itemPointer) && (loop && renderedLength > pageSize ? itemPointer !== active : itemPointer < active)) {
2168
- const lines = renderItemAtIndex(itemPointer);
2169
- const linesToAdd = lines.slice(Math.max(0, lines.length - bufferPointer - 1));
2170
- pageBuffer.splice(bufferPointer - linesToAdd.length + 1, linesToAdd.length, ...linesToAdd);
2171
- itemVisited.add(itemPointer);
2172
- bufferPointer -= linesToAdd.length;
2173
- itemPointer = bound(itemPointer - 1);
2174
- }
2175
- return pageBuffer.filter((line) => typeof line === "string").join(`
2176
- `);
2177
- }
2178
- // ../../node_modules/.bun/@inquirer+core@11.1.1+c195ea72dffa657e/node_modules/@inquirer/core/dist/lib/create-prompt.js
2179
- var import_mute_stream = __toESM(require_lib(), 1);
2180
- import * as readline2 from "node:readline";
2181
- import { AsyncResource as AsyncResource3 } from "node:async_hooks";
2182
-
2183
- // ../../node_modules/.bun/signal-exit@4.1.0/node_modules/signal-exit/dist/mjs/signals.js
2184
- var signals = [];
2185
- signals.push("SIGHUP", "SIGINT", "SIGTERM");
2186
- if (process.platform !== "win32") {
2187
- signals.push("SIGALRM", "SIGABRT", "SIGVTALRM", "SIGXCPU", "SIGXFSZ", "SIGUSR2", "SIGTRAP", "SIGSYS", "SIGQUIT", "SIGIOT");
2188
- }
2189
- if (process.platform === "linux") {
2190
- signals.push("SIGIO", "SIGPOLL", "SIGPWR", "SIGSTKFLT");
2191
- }
2192
-
2193
- // ../../node_modules/.bun/signal-exit@4.1.0/node_modules/signal-exit/dist/mjs/index.js
2194
- var processOk = (process3) => !!process3 && typeof process3 === "object" && typeof process3.removeListener === "function" && typeof process3.emit === "function" && typeof process3.reallyExit === "function" && typeof process3.listeners === "function" && typeof process3.kill === "function" && typeof process3.pid === "number" && typeof process3.on === "function";
2195
- var kExitEmitter = Symbol.for("signal-exit emitter");
2196
- var global = globalThis;
2197
- var ObjectDefineProperty = Object.defineProperty.bind(Object);
2198
-
2199
- class Emitter {
2200
- emitted = {
2201
- afterExit: false,
2202
- exit: false
2203
- };
2204
- listeners = {
2205
- afterExit: [],
2206
- exit: []
2207
- };
2208
- count = 0;
2209
- id = Math.random();
2210
- constructor() {
2211
- if (global[kExitEmitter]) {
2212
- return global[kExitEmitter];
2213
- }
2214
- ObjectDefineProperty(global, kExitEmitter, {
2215
- value: this,
2216
- writable: false,
2217
- enumerable: false,
2218
- configurable: false
2219
- });
2220
- }
2221
- on(ev, fn) {
2222
- this.listeners[ev].push(fn);
2223
- }
2224
- removeListener(ev, fn) {
2225
- const list = this.listeners[ev];
2226
- const i = list.indexOf(fn);
2227
- if (i === -1) {
2228
- return;
2229
- }
2230
- if (i === 0 && list.length === 1) {
2231
- list.length = 0;
2232
- } else {
2233
- list.splice(i, 1);
2234
- }
2235
- }
2236
- emit(ev, code, signal) {
2237
- if (this.emitted[ev]) {
2238
- return false;
2239
- }
2240
- this.emitted[ev] = true;
2241
- let ret = false;
2242
- for (const fn of this.listeners[ev]) {
2243
- ret = fn(code, signal) === true || ret;
2244
- }
2245
- if (ev === "exit") {
2246
- ret = this.emit("afterExit", code, signal) || ret;
2247
- }
2248
- return ret;
2249
- }
2250
- }
2251
-
2252
- class SignalExitBase {
2253
- }
2254
- var signalExitWrap = (handler) => {
2255
- return {
2256
- onExit(cb, opts) {
2257
- return handler.onExit(cb, opts);
2258
- },
2259
- load() {
2260
- return handler.load();
2261
- },
2262
- unload() {
2263
- return handler.unload();
2264
- }
2265
- };
2266
- };
2267
-
2268
- class SignalExitFallback extends SignalExitBase {
2269
- onExit() {
2270
- return () => {};
2271
- }
2272
- load() {}
2273
- unload() {}
2274
- }
2275
-
2276
- class SignalExit extends SignalExitBase {
2277
- #hupSig = process3.platform === "win32" ? "SIGINT" : "SIGHUP";
2278
- #emitter = new Emitter;
2279
- #process;
2280
- #originalProcessEmit;
2281
- #originalProcessReallyExit;
2282
- #sigListeners = {};
2283
- #loaded = false;
2284
- constructor(process3) {
2285
- super();
2286
- this.#process = process3;
2287
- this.#sigListeners = {};
2288
- for (const sig of signals) {
2289
- this.#sigListeners[sig] = () => {
2290
- const listeners = this.#process.listeners(sig);
2291
- let { count } = this.#emitter;
2292
- const p = process3;
2293
- if (typeof p.__signal_exit_emitter__ === "object" && typeof p.__signal_exit_emitter__.count === "number") {
2294
- count += p.__signal_exit_emitter__.count;
2295
- }
2296
- if (listeners.length === count) {
2297
- this.unload();
2298
- const ret = this.#emitter.emit("exit", null, sig);
2299
- const s = sig === "SIGHUP" ? this.#hupSig : sig;
2300
- if (!ret)
2301
- process3.kill(process3.pid, s);
2302
- }
2303
- };
2304
- }
2305
- this.#originalProcessReallyExit = process3.reallyExit;
2306
- this.#originalProcessEmit = process3.emit;
2307
- }
2308
- onExit(cb, opts) {
2309
- if (!processOk(this.#process)) {
2310
- return () => {};
2311
- }
2312
- if (this.#loaded === false) {
2313
- this.load();
2314
- }
2315
- const ev = opts?.alwaysLast ? "afterExit" : "exit";
2316
- this.#emitter.on(ev, cb);
2317
- return () => {
2318
- this.#emitter.removeListener(ev, cb);
2319
- if (this.#emitter.listeners["exit"].length === 0 && this.#emitter.listeners["afterExit"].length === 0) {
2320
- this.unload();
2321
- }
2322
- };
2323
- }
2324
- load() {
2325
- if (this.#loaded) {
2326
- return;
2327
- }
2328
- this.#loaded = true;
2329
- this.#emitter.count += 1;
2330
- for (const sig of signals) {
2331
- try {
2332
- const fn = this.#sigListeners[sig];
2333
- if (fn)
2334
- this.#process.on(sig, fn);
2335
- } catch (_) {}
2336
- }
2337
- this.#process.emit = (ev, ...a) => {
2338
- return this.#processEmit(ev, ...a);
2339
- };
2340
- this.#process.reallyExit = (code) => {
2341
- return this.#processReallyExit(code);
2342
- };
2343
- }
2344
- unload() {
2345
- if (!this.#loaded) {
2346
- return;
2347
- }
2348
- this.#loaded = false;
2349
- signals.forEach((sig) => {
2350
- const listener = this.#sigListeners[sig];
2351
- if (!listener) {
2352
- throw new Error("Listener not defined for signal: " + sig);
2353
- }
2354
- try {
2355
- this.#process.removeListener(sig, listener);
2356
- } catch (_) {}
2357
- });
2358
- this.#process.emit = this.#originalProcessEmit;
2359
- this.#process.reallyExit = this.#originalProcessReallyExit;
2360
- this.#emitter.count -= 1;
2361
- }
2362
- #processReallyExit(code) {
2363
- if (!processOk(this.#process)) {
2364
- return 0;
2365
- }
2366
- this.#process.exitCode = code || 0;
2367
- this.#emitter.emit("exit", this.#process.exitCode, null);
2368
- return this.#originalProcessReallyExit.call(this.#process, this.#process.exitCode);
2369
- }
2370
- #processEmit(ev, ...args) {
2371
- const og = this.#originalProcessEmit;
2372
- if (ev === "exit" && processOk(this.#process)) {
2373
- if (typeof args[0] === "number") {
2374
- this.#process.exitCode = args[0];
2375
- }
2376
- const ret = og.call(this.#process, ev, ...args);
2377
- this.#emitter.emit("exit", this.#process.exitCode, null);
2378
- return ret;
2379
- } else {
2380
- return og.call(this.#process, ev, ...args);
2381
- }
2382
- }
2383
- }
2384
- var process3 = globalThis.process;
2385
- var {
2386
- onExit,
2387
- load,
2388
- unload
2389
- } = signalExitWrap(processOk(process3) ? new SignalExit(process3) : new SignalExitFallback);
2390
-
2391
- // ../../node_modules/.bun/@inquirer+core@11.1.1+c195ea72dffa657e/node_modules/@inquirer/core/dist/lib/screen-manager.js
2392
- import { stripVTControlCharacters } from "node:util";
2393
-
2394
- // ../../node_modules/.bun/@inquirer+ansi@2.0.3/node_modules/@inquirer/ansi/dist/index.js
2395
- var ESC = "\x1B[";
2396
- var cursorLeft = ESC + "G";
2397
- var cursorHide = ESC + "?25l";
2398
- var cursorShow = ESC + "?25h";
2399
- var cursorUp = (rows = 1) => rows > 0 ? `${ESC}${rows}A` : "";
2400
- var cursorDown = (rows = 1) => rows > 0 ? `${ESC}${rows}B` : "";
2401
- var cursorTo = (x, y) => {
2402
- if (typeof y === "number" && !Number.isNaN(y)) {
2403
- return `${ESC}${y + 1};${x + 1}H`;
2404
- }
2405
- return `${ESC}${x + 1}G`;
2406
- };
2407
- var eraseLine = ESC + "2K";
2408
- var eraseLines = (lines) => lines > 0 ? (eraseLine + cursorUp(1)).repeat(lines - 1) + eraseLine + cursorLeft : "";
2409
-
2410
- // ../../node_modules/.bun/@inquirer+core@11.1.1+c195ea72dffa657e/node_modules/@inquirer/core/dist/lib/screen-manager.js
2411
- var height = (content) => content.split(`
2412
- `).length;
2413
- var lastLine = (content) => content.split(`
2414
- `).pop() ?? "";
2415
-
2416
- class ScreenManager {
2417
- height = 0;
2418
- extraLinesUnderPrompt = 0;
2419
- cursorPos;
2420
- rl;
2421
- constructor(rl) {
2422
- this.rl = rl;
2423
- this.cursorPos = rl.getCursorPos();
2424
- }
2425
- write(content) {
2426
- this.rl.output.unmute();
2427
- this.rl.output.write(content);
2428
- this.rl.output.mute();
2429
- }
2430
- render(content, bottomContent = "") {
2431
- const promptLine = lastLine(content);
2432
- const rawPromptLine = stripVTControlCharacters(promptLine);
2433
- let prompt = rawPromptLine;
2434
- if (this.rl.line.length > 0) {
2435
- prompt = prompt.slice(0, -this.rl.line.length);
2436
- }
2437
- this.rl.setPrompt(prompt);
2438
- this.cursorPos = this.rl.getCursorPos();
2439
- const width = readlineWidth();
2440
- content = breakLines(content, width);
2441
- bottomContent = breakLines(bottomContent, width);
2442
- if (rawPromptLine.length % width === 0) {
2443
- content += `
2444
- `;
2445
- }
2446
- let output = content + (bottomContent ? `
2447
- ` + bottomContent : "");
2448
- const promptLineUpDiff = Math.floor(rawPromptLine.length / width) - this.cursorPos.rows;
2449
- const bottomContentHeight = promptLineUpDiff + (bottomContent ? height(bottomContent) : 0);
2450
- if (bottomContentHeight > 0)
2451
- output += cursorUp(bottomContentHeight);
2452
- output += cursorTo(this.cursorPos.cols);
2453
- this.write(cursorDown(this.extraLinesUnderPrompt) + eraseLines(this.height) + output);
2454
- this.extraLinesUnderPrompt = bottomContentHeight;
2455
- this.height = height(output);
2456
- }
2457
- checkCursorPos() {
2458
- const cursorPos = this.rl.getCursorPos();
2459
- if (cursorPos.cols !== this.cursorPos.cols) {
2460
- this.write(cursorTo(cursorPos.cols));
2461
- this.cursorPos = cursorPos;
2462
- }
2463
- }
2464
- done({ clearContent }) {
2465
- this.rl.setPrompt("");
2466
- let output = cursorDown(this.extraLinesUnderPrompt);
2467
- output += clearContent ? eraseLines(this.height) : `
2468
- `;
2469
- output += cursorShow;
2470
- this.write(output);
2471
- this.rl.close();
2472
- }
2473
- }
2474
-
2475
- // ../../node_modules/.bun/@inquirer+core@11.1.1+c195ea72dffa657e/node_modules/@inquirer/core/dist/lib/promise-polyfill.js
2476
- class PromisePolyfill extends Promise {
2477
- static withResolver() {
2478
- let resolve;
2479
- let reject;
2480
- const promise = new Promise((res, rej) => {
2481
- resolve = res;
2482
- reject = rej;
2483
- });
2484
- return { promise, resolve, reject };
2485
- }
2486
- }
2487
-
2488
- // ../../node_modules/.bun/@inquirer+core@11.1.1+c195ea72dffa657e/node_modules/@inquirer/core/dist/lib/create-prompt.js
2489
- function getCallSites() {
2490
- const _prepareStackTrace = Error.prepareStackTrace;
2491
- let result = [];
2492
- try {
2493
- Error.prepareStackTrace = (_, callSites) => {
2494
- const callSitesWithoutCurrent = callSites.slice(1);
2495
- result = callSitesWithoutCurrent;
2496
- return callSitesWithoutCurrent;
2497
- };
2498
- new Error().stack;
2499
- } catch {
2500
- return result;
2501
- }
2502
- Error.prepareStackTrace = _prepareStackTrace;
2503
- return result;
2504
- }
2505
- function createPrompt(view) {
2506
- const callSites = getCallSites();
2507
- const prompt = (config, context = {}) => {
2508
- const { input = process.stdin, signal } = context;
2509
- const cleanups = new Set;
2510
- const output = new import_mute_stream.default;
2511
- output.pipe(context.output ?? process.stdout);
2512
- const rl = readline2.createInterface({
2513
- terminal: true,
2514
- input,
2515
- output
2516
- });
2517
- const screen = new ScreenManager(rl);
2518
- const { promise, resolve, reject } = PromisePolyfill.withResolver();
2519
- const cancel = () => reject(new CancelPromptError);
2520
- if (signal) {
2521
- const abort = () => reject(new AbortPromptError({ cause: signal.reason }));
2522
- if (signal.aborted) {
2523
- abort();
2524
- return Object.assign(promise, { cancel });
2525
- }
2526
- signal.addEventListener("abort", abort);
2527
- cleanups.add(() => signal.removeEventListener("abort", abort));
2528
- }
2529
- cleanups.add(onExit((code, signal2) => {
2530
- reject(new ExitPromptError(`User force closed the prompt with ${code} ${signal2}`));
2531
- }));
2532
- const sigint = () => reject(new ExitPromptError(`User force closed the prompt with SIGINT`));
2533
- rl.on("SIGINT", sigint);
2534
- cleanups.add(() => rl.removeListener("SIGINT", sigint));
2535
- const checkCursorPos = () => screen.checkCursorPos();
2536
- rl.input.on("keypress", checkCursorPos);
2537
- cleanups.add(() => rl.input.removeListener("keypress", checkCursorPos));
2538
- return withHooks(rl, (cycle) => {
2539
- const hooksCleanup = AsyncResource3.bind(() => effectScheduler.clearAll());
2540
- rl.on("close", hooksCleanup);
2541
- cleanups.add(() => rl.removeListener("close", hooksCleanup));
2542
- cycle(() => {
2543
- try {
2544
- const nextView = view(config, (value) => {
2545
- setImmediate(() => resolve(value));
2546
- });
2547
- if (nextView === undefined) {
2548
- const callerFilename = callSites[1]?.getFileName();
2549
- throw new Error(`Prompt functions must return a string.
2550
- at ${callerFilename}`);
2551
- }
2552
- const [content, bottomContent] = typeof nextView === "string" ? [nextView] : nextView;
2553
- screen.render(content, bottomContent);
2554
- effectScheduler.run();
2555
- } catch (error) {
2556
- reject(error);
2557
- }
2558
- });
2559
- return Object.assign(promise.then((answer) => {
2560
- effectScheduler.clearAll();
2561
- return answer;
2562
- }, (error) => {
2563
- effectScheduler.clearAll();
2564
- throw error;
2565
- }).finally(() => {
2566
- cleanups.forEach((cleanup) => cleanup());
2567
- screen.done({ clearContent: Boolean(context.clearPromptOnDone) });
2568
- output.end();
2569
- }).then(() => promise), { cancel });
2570
- });
2571
- };
2572
- return prompt;
2573
- }
2574
- // ../../node_modules/.bun/@inquirer+core@11.1.1+c195ea72dffa657e/node_modules/@inquirer/core/dist/lib/Separator.js
2575
- import { styleText as styleText2 } from "node:util";
2576
- class Separator {
2577
- separator = styleText2("dim", Array.from({ length: 15 }).join(dist_default2.line));
2578
- type = "separator";
2579
- constructor(separator) {
2580
- if (separator) {
2581
- this.separator = separator;
2582
- }
2583
- }
2584
- static isSeparator(choice) {
2585
- return Boolean(choice && typeof choice === "object" && "type" in choice && choice.type === "separator");
2586
- }
2587
- }
2588
- // ../../node_modules/.bun/@inquirer+select@5.0.4+c195ea72dffa657e/node_modules/@inquirer/select/dist/index.js
2589
- import { styleText as styleText3 } from "node:util";
2590
- var selectTheme = {
2591
- icon: { cursor: dist_default2.pointer },
2592
- style: {
2593
- disabled: (text) => styleText3("dim", `- ${text}`),
2594
- description: (text) => styleText3("cyan", text),
2595
- keysHelpTip: (keys) => keys.map(([key, action]) => `${styleText3("bold", key)} ${styleText3("dim", action)}`).join(styleText3("dim", " • "))
2596
- },
2597
- indexMode: "hidden",
2598
- keybindings: []
2599
- };
2600
- function isSelectable(item) {
2601
- return !Separator.isSeparator(item) && !item.disabled;
2602
- }
2603
- function normalizeChoices(choices) {
2604
- return choices.map((choice) => {
2605
- if (Separator.isSeparator(choice))
2606
- return choice;
2607
- if (typeof choice !== "object" || choice === null || !("value" in choice)) {
2608
- const name2 = String(choice);
2609
- return {
2610
- value: choice,
2611
- name: name2,
2612
- short: name2,
2613
- disabled: false
2614
- };
2615
- }
2616
- const name = choice.name ?? String(choice.value);
2617
- const normalizedChoice = {
2618
- value: choice.value,
2619
- name,
2620
- short: choice.short ?? name,
2621
- disabled: choice.disabled ?? false
2622
- };
2623
- if (choice.description) {
2624
- normalizedChoice.description = choice.description;
2625
- }
2626
- return normalizedChoice;
2627
- });
2628
- }
2629
- var dist_default3 = createPrompt((config, done) => {
2630
- const { loop = true, pageSize = 7 } = config;
2631
- const theme = makeTheme(selectTheme, config.theme);
2632
- const { keybindings } = theme;
2633
- const [status, setStatus] = useState("idle");
2634
- const prefix = usePrefix({ status, theme });
2635
- const searchTimeoutRef = useRef();
2636
- const searchEnabled = !keybindings.includes("vim");
2637
- const items = useMemo(() => normalizeChoices(config.choices), [config.choices]);
2638
- const bounds = useMemo(() => {
2639
- const first = items.findIndex(isSelectable);
2640
- const last = items.findLastIndex(isSelectable);
2641
- if (first === -1) {
2642
- throw new ValidationError("[select prompt] No selectable choices. All choices are disabled.");
2643
- }
2644
- return { first, last };
2645
- }, [items]);
2646
- const defaultItemIndex = useMemo(() => {
2647
- if (!("default" in config))
2648
- return -1;
2649
- return items.findIndex((item) => isSelectable(item) && item.value === config.default);
2650
- }, [config.default, items]);
2651
- const [active, setActive] = useState(defaultItemIndex === -1 ? bounds.first : defaultItemIndex);
2652
- const selectedChoice = items[active];
2653
- useKeypress((key, rl) => {
2654
- clearTimeout(searchTimeoutRef.current);
2655
- if (isEnterKey(key)) {
2656
- setStatus("done");
2657
- done(selectedChoice.value);
2658
- } else if (isUpKey(key, keybindings) || isDownKey(key, keybindings)) {
2659
- rl.clearLine(0);
2660
- if (loop || isUpKey(key, keybindings) && active !== bounds.first || isDownKey(key, keybindings) && active !== bounds.last) {
2661
- const offset = isUpKey(key, keybindings) ? -1 : 1;
2662
- let next = active;
2663
- do {
2664
- next = (next + offset + items.length) % items.length;
2665
- } while (!isSelectable(items[next]));
2666
- setActive(next);
2667
- }
2668
- } else if (isNumberKey(key) && !Number.isNaN(Number(rl.line))) {
2669
- const selectedIndex = Number(rl.line) - 1;
2670
- let selectableIndex = -1;
2671
- const position = items.findIndex((item2) => {
2672
- if (Separator.isSeparator(item2))
2673
- return false;
2674
- selectableIndex++;
2675
- return selectableIndex === selectedIndex;
2676
- });
2677
- const item = items[position];
2678
- if (item != null && isSelectable(item)) {
2679
- setActive(position);
2680
- }
2681
- searchTimeoutRef.current = setTimeout(() => {
2682
- rl.clearLine(0);
2683
- }, 700);
2684
- } else if (isBackspaceKey(key)) {
2685
- rl.clearLine(0);
2686
- } else if (searchEnabled) {
2687
- const searchTerm = rl.line.toLowerCase();
2688
- const matchIndex = items.findIndex((item) => {
2689
- if (Separator.isSeparator(item) || !isSelectable(item))
2690
- return false;
2691
- return item.name.toLowerCase().startsWith(searchTerm);
2692
- });
2693
- if (matchIndex !== -1) {
2694
- setActive(matchIndex);
2695
- }
2696
- searchTimeoutRef.current = setTimeout(() => {
2697
- rl.clearLine(0);
2698
- }, 700);
2699
- }
2700
- });
2701
- useEffect(() => () => {
2702
- clearTimeout(searchTimeoutRef.current);
2703
- }, []);
2704
- const message = theme.style.message(config.message, status);
2705
- const helpLine = theme.style.keysHelpTip([
2706
- ["↑↓", "navigate"],
2707
- ["⏎", "select"]
2708
- ]);
2709
- let separatorCount = 0;
2710
- const page = usePagination({
2711
- items,
2712
- active,
2713
- renderItem({ item, isActive, index }) {
2714
- if (Separator.isSeparator(item)) {
2715
- separatorCount++;
2716
- return ` ${item.separator}`;
2717
- }
2718
- const indexLabel = theme.indexMode === "number" ? `${index + 1 - separatorCount}. ` : "";
2719
- if (item.disabled) {
2720
- const disabledLabel = typeof item.disabled === "string" ? item.disabled : "(disabled)";
2721
- return theme.style.disabled(`${indexLabel}${item.name} ${disabledLabel}`);
2722
- }
2723
- const color = isActive ? theme.style.highlight : (x) => x;
2724
- const cursor = isActive ? theme.icon.cursor : ` `;
2725
- return color(`${cursor} ${indexLabel}${item.name}`);
2726
- },
2727
- pageSize,
2728
- loop
2729
- });
2730
- if (status === "done") {
2731
- return [prefix, message, theme.style.answer(selectedChoice.short)].filter(Boolean).join(" ");
2732
- }
2733
- const { description } = selectedChoice;
2734
- const lines = [
2735
- [prefix, message].filter(Boolean).join(" "),
2736
- page,
2737
- " ",
2738
- description ? theme.style.description(description) : "",
2739
- helpLine
2740
- ].filter(Boolean).join(`
2741
- `).trimEnd();
2742
- return `${lines}${cursorHide}`;
2743
- });
2744
- // lib/utils.ts
2745
- var import_bytes = __toESM(require_bytes(), 1);
2746
-
2747
- // lib/output.ts
2748
- var import_picocolors = __toESM(require_picocolors(), 1);
2749
- var brand = (text) => import_picocolors.default.cyan(import_picocolors.default.bold(text));
2750
- var success = (text) => `${import_picocolors.default.green("✓")} ${text}`;
2751
- var warn = (text) => `${import_picocolors.default.yellow("⚠")} ${text}`;
2752
- var error = (text) => `${import_picocolors.default.red("✗")} ${text}`;
2753
- var info = (text) => `${import_picocolors.default.cyan("ℹ")} ${text}`;
2754
- var dim = (text) => import_picocolors.default.dim(text);
2755
- var green = (text) => import_picocolors.default.green(text);
2756
- var yellow = (text) => import_picocolors.default.yellow(text);
2757
- var red = (text) => import_picocolors.default.red(text);
2758
- var cyan = (text) => import_picocolors.default.cyan(text);
2759
- var magenta = (text) => import_picocolors.default.magenta(text);
2760
- function header(text) {
2761
- console.log("");
2762
- console.log(brand(` ${text}`));
2763
- console.log(import_picocolors.default.dim(" " + "─".repeat(text.length + 2)));
2764
- }
2765
- function labelValue(label, value) {
2766
- console.log(` ${import_picocolors.default.dim(label + ":")} ${value}`);
2767
- }
2768
- function statusLine(status, name, message, extra) {
2769
- const icons = { ok: "✓", warning: "⚠", error: "✗" };
2770
- const colors = { ok: import_picocolors.default.green, warning: import_picocolors.default.yellow, error: import_picocolors.default.red };
2771
- let line = `${colors[status](icons[status])} ${name}: ${message}`;
2772
- if (extra) {
2773
- line += ` ${import_picocolors.default.dim(`(${extra})`)}`;
2774
- }
2775
- return line;
2776
- }
2777
- function tableRow(columns, widths) {
2778
- return columns.map((col, i) => {
2779
- const width = widths[i] || col.length;
2780
- return col.padEnd(width);
2781
- }).join(" ");
2782
- }
2783
- function tableHeader(columns, widths) {
2784
- const headerRow = tableRow(columns.map((c) => import_picocolors.default.bold(c)), widths);
2785
- const underlineRow = widths.map((w) => "─".repeat(w)).join(" ");
2786
- console.log(headerRow);
2787
- console.log(import_picocolors.default.dim(underlineRow));
2788
- }
2789
- function url(urlStr) {
2790
- return import_picocolors.default.underline(import_picocolors.default.cyan(urlStr));
2791
- }
2792
- function cmd(command) {
2793
- return import_picocolors.default.cyan(command);
2794
- }
2795
- function file(filePath) {
2796
- return import_picocolors.default.magenta(filePath);
2797
- }
2798
-
2799
- // lib/spawn.ts
2800
- async function spawn(cmd2, opts = {}) {
2801
- const command = cmd2[0];
2802
- const args = cmd2.slice(1);
2803
- if (command === undefined) {
2804
- throw new Error("No command provided");
2805
- }
2806
- if (typeof Bun !== "undefined") {
2807
- const proc = Bun.spawn(cmd2, {
2808
- env: opts.env ?? process.env,
2809
- cwd: opts.cwd ?? process.cwd(),
2810
- stdin: opts.stdin ?? "inherit",
2811
- stdout: opts.stdout ?? "inherit",
2812
- stderr: opts.stderr ?? "inherit"
2813
- });
2814
- return proc.exited;
2815
- } else {
2816
- const { spawn: nodeSpawn } = await import("child_process");
2817
- return new Promise((resolve) => {
2818
- const proc = nodeSpawn(command, args, {
2819
- env: opts.env,
2820
- cwd: opts.cwd,
2821
- stdio: [opts.stdin ?? "inherit", opts.stdout ?? "inherit", opts.stderr ?? "inherit"]
2822
- });
2823
- proc.on("close", (code) => resolve(code ?? 1));
2824
- });
2825
- }
2826
- }
2827
- async function spawnCapture(cmd2, opts = {}) {
2828
- const command = cmd2[0];
2829
- const args = cmd2.slice(1);
2830
- if (command === undefined) {
2831
- throw new Error("No command provided");
2832
- }
2833
- if (typeof Bun !== "undefined") {
2834
- const proc = Bun.spawn(cmd2, {
2835
- env: opts.env ?? process.env,
2836
- cwd: opts.cwd,
2837
- stdin: opts.stdin ?? "ignore",
2838
- stdout: "pipe",
2839
- stderr: "pipe"
2840
- });
2841
- const [stdout, stderr, exitCode] = await Promise.all([
2842
- new Response(proc.stdout).text(),
2843
- new Response(proc.stderr).text(),
2844
- proc.exited
2845
- ]);
2846
- return { exitCode, stdout, stderr };
2847
- } else {
2848
- const { spawn: nodeSpawn } = await import("child_process");
2849
- return new Promise((resolve) => {
2850
- const proc = nodeSpawn(command, args, {
2851
- env: opts.env,
2852
- cwd: opts.cwd,
2853
- stdio: ["ignore", "pipe", "pipe"]
2854
- });
2855
- let stdout = "";
2856
- let stderr = "";
2857
- proc.stdout?.on("data", (data) => {
2858
- stdout += data.toString();
2859
- });
2860
- proc.stderr?.on("data", (data) => {
2861
- stderr += data.toString();
2862
- });
2863
- proc.on("close", (code) => {
2864
- resolve({ exitCode: code ?? 1, stdout, stderr });
2865
- });
2866
- });
2867
- }
2868
- }
2869
- async function commandExists(cmd2) {
2870
- try {
2871
- const result = await spawnCapture(process.platform === "win32" ? ["where", cmd2] : ["which", cmd2]);
2872
- return result.exitCode === 0;
2873
- } catch {
2874
- return false;
2875
- }
2876
- }
2877
- async function getCommandVersion(cmd2) {
2878
- try {
2879
- const result = await spawnCapture([cmd2, "--version"]);
2880
- if (result.exitCode === 0 && result.stdout) {
2881
- return result.stdout.trim().split(`
2882
- `)[0] ?? null;
2883
- }
2884
- return null;
2885
- } catch {
2886
- return null;
2887
- }
2888
- }
2889
-
2890
- // lib/utils.ts
2891
- async function fetchOllamaModels() {
2892
- const ollamaUrl = getOllamaUrl();
2893
- const response = await fetch(`${ollamaUrl}/api/tags`);
2894
- if (!response.ok) {
2895
- throw new Error(`Failed to fetch models: ${response.statusText}`);
2896
- }
2897
- const data = await response.json();
2898
- return data.models ?? [];
2899
- }
2900
- async function fetchRunningModels() {
2901
- const ollamaUrl = getOllamaUrl();
2902
- try {
2903
- const response = await fetch(`${ollamaUrl}/api/ps`, {
2904
- signal: AbortSignal.timeout(5000)
2905
- });
2906
- if (!response.ok) {
2907
- return [];
2908
- }
2909
- const data = await response.json();
2910
- return data.models ?? [];
2911
- } catch (error2) {
2912
- return [];
2913
- }
2914
- }
2915
- async function isModelLoaded(modelName) {
2916
- const runningModels = await fetchRunningModels();
2917
- return runningModels.some((m) => m.model === modelName || m.name === modelName || m.model.startsWith(modelName + ":") || modelName.startsWith(m.model));
2918
- }
2919
- async function loadModel(modelName, keepAlive = "10m") {
2920
- const ollamaUrl = getOllamaUrl();
2921
- const response = await fetch(`${ollamaUrl}/api/generate`, {
2922
- method: "POST",
2923
- headers: {
2924
- "Content-Type": "application/json"
2925
- },
2926
- body: JSON.stringify({
2927
- model: modelName,
2928
- prompt: "",
2929
- stream: false,
2930
- keep_alive: keepAlive
2931
- })
2932
- });
2933
- if (!response.ok) {
2934
- throw new Error(`Failed to load model: ${response.statusText}`);
2935
- }
2936
- await response.json();
2937
- }
2938
- async function ensureModelLoaded(modelName) {
2939
- const isLoaded = await isModelLoaded(modelName);
2940
- if (isLoaded) {
2941
- console.log(dim(` Model ${magenta(modelName)} is already loaded`));
2942
- return;
2943
- }
2944
- console.log(info(`Loading model ${magenta(modelName)}...`));
2945
- console.log(dim(" This may take a moment on first run"));
2946
- try {
2947
- await loadModel(modelName, "10m");
2948
- console.log(success(`Model ${magenta(modelName)} loaded (keep_alive: 10m)`));
2949
- } catch (error2) {
2950
- console.log(warn(`Could not pre-load model (will load on first request)`));
2951
- console.log(dim(` ${error2 instanceof Error ? error2.message : "Unknown error"}`));
2952
- }
2953
- }
2954
- async function selectModelInteractively() {
2955
- const ollamaUrl = getOllamaUrl();
2956
- let models;
2957
- try {
2958
- models = await fetchOllamaModels();
2959
- } catch (error2) {
2960
- console.log(warn(`Could not connect to Ollama at ${ollamaUrl}`));
2961
- console.log(dim(" Make sure Ollama is running: loclaude docker-up"));
2962
- process.exit(1);
2963
- }
2964
- if (models.length === 0) {
2965
- console.log(warn("No models found in Ollama."));
2966
- console.log(dim(" Pull a model first: loclaude models-pull <model-name>"));
2967
- process.exit(1);
2968
- }
2969
- const runningModels = await fetchRunningModels();
2970
- const loadedModelNames = new Set(runningModels.map((m) => m.model));
2971
- const selected = await dist_default3({
2972
- message: "Select a model",
2973
- choices: models.map((model) => {
2974
- const isLoaded = loadedModelNames.has(model.name);
2975
- const loadedIndicator = isLoaded ? " [loaded]" : "";
2976
- return {
2977
- name: `${model.name} (${import_bytes.default(model.size)})${loadedIndicator}`,
2978
- value: model.name
2979
- };
2980
- })
2981
- });
2982
- return selected;
2983
- }
2984
- async function launchClaude(model, passthroughArgs) {
2985
- const ollamaUrl = getOllamaUrl();
2986
- const extraArgs = getClaudeExtraArgs();
2987
- console.log("");
2988
- console.log(cyan("Launching Claude Code with Ollama"));
2989
- console.log(dim(` Model: ${magenta(model)}`));
2990
- console.log(dim(` API: ${ollamaUrl}`));
2991
- console.log("");
2992
- await ensureModelLoaded(model);
2993
- console.log("");
2994
- const env = {
2995
- ...process.env,
2996
- ANTHROPIC_AUTH_TOKEN: "ollama",
2997
- ANTHROPIC_BASE_URL: ollamaUrl
2998
- };
2999
- const claudeArgs = ["claude", "--model", model, ...extraArgs, ...passthroughArgs];
3000
- const exitCode = await spawn(claudeArgs, { env });
3001
- process.exit(exitCode);
3002
- }
3003
-
3004
- // lib/commands/init.ts
3005
- import { existsSync as existsSync2, mkdirSync, writeFileSync, readFileSync as readFileSync2 } from "fs";
3006
- import { join as join2 } from "path";
3007
-
3008
- // lib/commands/doctor.ts
3009
- async function checkDocker() {
3010
- const exists = await commandExists("docker");
3011
- if (!exists) {
3012
- return {
3013
- name: "Docker",
3014
- status: "error",
3015
- message: "Not installed",
3016
- hint: "Install Docker: https://docs.docker.com/get-docker/"
3017
- };
3018
- }
3019
- const version = await getCommandVersion("docker");
3020
- return {
3021
- name: "Docker",
3022
- status: "ok",
3023
- message: "Installed",
3024
- version: version ?? undefined
3025
- };
3026
- }
3027
- async function checkDockerCompose() {
3028
- const result = await spawnCapture(["docker", "compose", "version"]);
3029
- if (result.exitCode === 0) {
3030
- const version = result.stdout?.trim().split(`
3031
- `)[0];
3032
- return {
3033
- name: "Docker Compose",
3034
- status: "ok",
3035
- message: "Installed (v2)",
3036
- version: version ?? undefined
3037
- };
3038
- }
3039
- const v1Exists = await commandExists("docker-compose");
3040
- if (v1Exists) {
3041
- const version = await getCommandVersion("docker-compose");
3042
- return {
3043
- name: "Docker Compose",
3044
- status: "warning",
3045
- message: "Using legacy v1",
3046
- version: version ?? undefined,
3047
- hint: "Consider upgrading to Docker Compose v2"
3048
- };
3049
- }
3050
- return {
3051
- name: "Docker Compose",
3052
- status: "error",
3053
- message: "Not installed",
3054
- hint: "Docker Compose is included with Docker Desktop, or install separately"
3055
- };
3056
- }
3057
- async function checkNvidiaSmi() {
3058
- const exists = await commandExists("nvidia-smi");
3059
- if (!exists) {
3060
- return {
3061
- name: "NVIDIA GPU",
3062
- status: "warning",
3063
- message: "nvidia-smi not found",
3064
- hint: "GPU support requires NVIDIA drivers. CPU-only mode will be used."
3065
- };
3066
- }
3067
- const result = await spawnCapture(["nvidia-smi", "--query-gpu=name", "--format=csv,noheader"]);
3068
- if (result.exitCode === 0 && result.stdout) {
3069
- const gpus = result.stdout.trim().split(`
3070
- `).filter(Boolean);
3071
- return {
3072
- name: "NVIDIA GPU",
3073
- status: "ok",
3074
- message: `${gpus.length} GPU(s) detected`,
3075
- version: gpus[0]
3076
- };
3077
- }
3078
- return {
3079
- name: "NVIDIA GPU",
3080
- status: "warning",
3081
- message: "nvidia-smi failed",
3082
- hint: "GPU may not be available. Check NVIDIA drivers."
3083
- };
3084
- }
3085
- async function checkNvidiaContainerToolkit() {
3086
- const result = await spawnCapture(["docker", "info", "--format", "{{.Runtimes}}"]);
3087
- if (result.exitCode === 0 && result.stdout?.includes("nvidia")) {
3088
- return {
3089
- name: "NVIDIA Container Toolkit",
3090
- status: "ok",
3091
- message: "nvidia runtime available"
3092
- };
3093
- }
3094
- return {
3095
- name: "NVIDIA Container Toolkit",
3096
- status: "warning",
3097
- message: "nvidia runtime not found",
3098
- hint: "Install: https://docs.nvidia.com/datacenter/cloud-native/container-toolkit/latest/install-guide.html"
3099
- };
3100
- }
3101
- async function checkClaude() {
3102
- const exists = await commandExists("claude");
3103
- if (!exists) {
3104
- return {
3105
- name: "Claude Code",
3106
- status: "error",
3107
- message: "Not installed",
3108
- hint: "Install: npm install -g @anthropic-ai/claude-code"
3109
- };
3110
- }
3111
- const version = await getCommandVersion("claude");
3112
- return {
3113
- name: "Claude Code",
3114
- status: "ok",
3115
- message: "Installed",
3116
- version: version ?? undefined
3117
- };
3118
- }
3119
- async function checkOllamaConnection() {
3120
- const ollamaUrl = getOllamaUrl();
3121
- try {
3122
- const response = await fetch(`${ollamaUrl}/api/tags`, {
3123
- signal: AbortSignal.timeout(5000)
3124
- });
3125
- if (response.ok) {
3126
- const data = await response.json();
3127
- const modelCount = data.models?.length ?? 0;
3128
- return {
3129
- name: "Ollama API",
3130
- status: "ok",
3131
- message: `Connected (${modelCount} model${modelCount === 1 ? "" : "s"})`,
3132
- version: ollamaUrl
3133
- };
3134
- }
3135
- return {
3136
- name: "Ollama API",
3137
- status: "warning",
3138
- message: `HTTP ${response.status}`,
3139
- hint: "Ollama may not be running. Try: loclaude docker-up"
3140
- };
3141
- } catch (error3) {
3142
- return {
3143
- name: "Ollama API",
3144
- status: "warning",
3145
- message: "Not reachable",
3146
- hint: `Cannot connect to ${ollamaUrl}. Start Ollama: loclaude docker-up`
3147
- };
3148
- }
3149
- }
3150
- function formatCheck(check) {
3151
- let line = statusLine(check.status, check.name, check.message, check.version);
3152
- if (check.hint) {
3153
- line += `
3154
- ${dim("→")} ${dim(check.hint)}`;
3155
- }
3156
- return line;
3157
- }
3158
- async function doctor() {
3159
- header("System Health Check");
3160
- console.log("");
3161
- const checks = await Promise.all([
3162
- checkDocker(),
3163
- checkDockerCompose(),
3164
- checkNvidiaSmi(),
3165
- checkNvidiaContainerToolkit(),
3166
- checkClaude(),
3167
- checkOllamaConnection()
3168
- ]);
3169
- for (const check of checks) {
3170
- console.log(formatCheck(check));
3171
- }
3172
- const errors2 = checks.filter((c) => c.status === "error");
3173
- const warnings = checks.filter((c) => c.status === "warning");
3174
- console.log("");
3175
- if (errors2.length > 0) {
3176
- console.log(red(`${errors2.length} error(s) found.`) + " Fix these before proceeding.");
3177
- process.exit(1);
3178
- } else if (warnings.length > 0) {
3179
- console.log(yellow(`${warnings.length} warning(s).`) + " loclaude may work with limited functionality.");
3180
- } else {
3181
- console.log(green("All checks passed!") + " Ready to use loclaude.");
3182
- }
3183
- }
3184
- async function hasNvidiaGpu() {
3185
- const exists = await commandExists("nvidia-smi");
3186
- if (!exists)
3187
- return false;
3188
- const result = await spawnCapture(["nvidia-smi", "--query-gpu=name", "--format=csv,noheader"]);
3189
- return result.exitCode === 0 && Boolean(result.stdout?.trim());
3190
- }
3191
-
3192
- // lib/commands/init.ts
3193
- var DOCKER_COMPOSE_TEMPLATE_GPU = `# =============================================================================
3194
- # LOCLAUDE DOCKER COMPOSE - GPU MODE
3195
- # =============================================================================
3196
- # This configuration runs Ollama with NVIDIA GPU acceleration for fast inference.
3197
- # Generated by: loclaude init
3198
- #
3199
- # Prerequisites:
3200
- # - NVIDIA GPU with CUDA support
3201
- # - NVIDIA drivers installed on host
3202
- # - NVIDIA Container Toolkit: https://docs.nvidia.com/datacenter/cloud-native/container-toolkit
3203
- #
3204
- # Quick test for GPU support:
3205
- # docker run --rm --gpus all nvidia/cuda:12.0-base nvidia-smi
3206
- #
3207
- # =============================================================================
3208
-
3209
- services:
3210
- # ===========================================================================
3211
- # OLLAMA - Local LLM Inference Server
3212
- # ===========================================================================
3213
- # Ollama provides the AI backend that Claude Code connects to.
3214
- # It runs large language models locally on your hardware.
3215
- #
3216
- # API Documentation: https://github.com/ollama/ollama/blob/main/docs/api.md
3217
- # Model Library: https://ollama.com/library
3218
- # ===========================================================================
3219
- ollama:
3220
- # Official Ollama image - 'latest' ensures newest features and model support
3221
- image: ollama/ollama:latest
3222
-
3223
- # Fixed container name for easy CLI access:
3224
- # docker exec ollama ollama list
3225
- # docker logs ollama
3226
- container_name: ollama
3227
-
3228
- # NVIDIA Container Runtime - Required for GPU access
3229
- # This makes CUDA libraries available inside the container
3230
- runtime: nvidia
3231
-
3232
- environment:
3233
- # ---------------------------------------------------------------------------
3234
- # GPU Configuration
3235
- # ---------------------------------------------------------------------------
3236
- # NVIDIA_VISIBLE_DEVICES: Which GPUs to expose to the container
3237
- # - 'all': Use all available GPUs (recommended for most setups)
3238
- # - '0': Use only GPU 0
3239
- # - '0,1': Use GPUs 0 and 1
3240
- - NVIDIA_VISIBLE_DEVICES=all
3241
-
3242
- # NVIDIA_DRIVER_CAPABILITIES: What GPU features to enable
3243
- # - 'compute': CUDA compute (required for inference)
3244
- # - 'utility': nvidia-smi and other tools
3245
- - NVIDIA_DRIVER_CAPABILITIES=compute,utility
3246
-
3247
- # ---------------------------------------------------------------------------
3248
- # Ollama Configuration (Optional)
3249
- # ---------------------------------------------------------------------------
3250
- # Uncomment these to customize Ollama behavior:
3251
-
3252
- # Maximum number of models loaded in memory simultaneously
3253
- # Lower this if you're running out of VRAM
3254
- # - OLLAMA_MAX_LOADED_MODELS=1
3255
-
3256
- # Maximum parallel inference requests per model
3257
- # Higher values use more VRAM but handle more concurrent requests
3258
- # - OLLAMA_NUM_PARALLEL=1
3259
-
3260
- # Enable debug logging for troubleshooting
3261
- # - OLLAMA_DEBUG=1
3262
-
3263
- # Custom model storage location (inside container)
3264
- # - OLLAMA_MODELS=/root/.ollama
3265
-
3266
- volumes:
3267
- # ---------------------------------------------------------------------------
3268
- # Model Storage
3269
- # ---------------------------------------------------------------------------
3270
- # Maps ./models on your host to /root/.ollama in the container
3271
- # This persists downloaded models across container restarts
3272
- #
3273
- # Disk space requirements (approximate):
3274
- # - 7B model: ~4GB
3275
- # - 13B model: ~8GB
3276
- # - 30B model: ~16GB
3277
- # - 70B model: ~40GB
3278
- - ./models:/root/.ollama
3279
-
3280
- ports:
3281
- # Ollama API port - access at http://localhost:11434
3282
- # Used by Claude Code and other Ollama clients
3283
- - "11434:11434"
3284
-
3285
- # Restart policy - keeps Ollama running unless manually stopped
3286
- restart: unless-stopped
3287
-
3288
- healthcheck:
3289
- # Verify Ollama is responsive by listing models
3290
- test: ["CMD", "ollama", "list"]
3291
- interval: 300s # Check every 5 minutes
3292
- timeout: 2s # Fail if no response in 2 seconds
3293
- retries: 3 # Mark unhealthy after 3 consecutive failures
3294
- start_period: 40s # Grace period for initial model loading
3295
-
3296
- deploy:
3297
- resources:
3298
- reservations:
3299
- devices:
3300
- # Request GPU access from Docker
3301
- - driver: nvidia
3302
- count: all # Use all available GPUs
3303
- capabilities: [gpu] # Request GPU compute capability
3304
-
3305
- # ===========================================================================
3306
- # OPEN WEBUI - Chat Interface (Optional)
3307
- # ===========================================================================
3308
- # Open WebUI provides a ChatGPT-like interface for your local models.
3309
- # Access at http://localhost:3000 after starting containers.
3310
- #
3311
- # Features:
3312
- # - Multi-model chat interface
3313
- # - Conversation history
3314
- # - Model management UI
3315
- # - RAG/document upload support
3316
- #
3317
- # Documentation: https://docs.openwebui.com/
3318
- # ===========================================================================
3319
- open-webui:
3320
- # CUDA-enabled image for GPU-accelerated features (embeddings, etc.)
3321
- # Change to :main if you don't need GPU features in the UI
3322
- image: ghcr.io/open-webui/open-webui:cuda
3323
-
3324
- container_name: open-webui
3325
-
3326
- ports:
3327
- # Web UI port - access at http://localhost:3000
3328
- - "3000:8080"
3329
-
3330
- environment:
3331
- # Tell Open WebUI where to find Ollama
3332
- # Uses Docker internal networking (service name as hostname)
3333
- - OLLAMA_BASE_URL=http://ollama:11434
3334
-
3335
- # Wait for Ollama to be ready before starting
3336
- depends_on:
3337
- - ollama
3338
-
3339
- restart: unless-stopped
3340
-
3341
- healthcheck:
3342
- test: ["CMD", "curl", "-f", "http://localhost:8080/health"]
3343
- interval: 30s
3344
- timeout: 10s
3345
- retries: 3
3346
- start_period: 60s
3347
-
3348
- volumes:
3349
- # Persistent storage for conversations, settings, and user data
3350
- - open-webui:/app/backend/data
3351
-
3352
- deploy:
3353
- resources:
3354
- reservations:
3355
- devices:
3356
- - driver: nvidia
3357
- count: all
3358
- capabilities: [gpu]
3359
-
3360
- # =============================================================================
3361
- # VOLUMES
3362
- # =============================================================================
3363
- # Named volumes for persistent data that survives container recreation
3364
- volumes:
3365
- open-webui:
3366
- # Open WebUI data: conversations, user settings, uploads
3367
- # Located at /var/lib/docker/volumes/open-webui/_data on host
3368
- `;
3369
- var DOCKER_COMPOSE_TEMPLATE_CPU = `# =============================================================================
3370
- # LOCLAUDE DOCKER COMPOSE - CPU MODE
3371
- # =============================================================================
3372
- # This configuration runs Ollama in CPU-only mode.
3373
- # Inference will be slower than GPU mode but works on any system.
3374
- # Generated by: loclaude init --no-gpu
3375
- #
3376
- # Performance notes:
3377
- # - 7B models: ~10-20 tokens/sec on modern CPUs
3378
- # - Larger models will be significantly slower
3379
- # - Consider using quantized models (Q4_K_M, Q5_K_M) for better performance
3380
- #
3381
- # Recommended CPU-optimized models:
3382
- # - llama3.2:3b (fast, good for simple tasks)
3383
- # - qwen2.5-coder:7b (coding tasks)
3384
- # - gemma2:9b (general purpose)
3385
- #
3386
- # =============================================================================
3387
-
3388
- services:
3389
- # ===========================================================================
3390
- # OLLAMA - Local LLM Inference Server (CPU Mode)
3391
- # ===========================================================================
3392
- # Ollama provides the AI backend that Claude Code connects to.
3393
- # Running in CPU mode - no GPU acceleration.
3394
- #
3395
- # API Documentation: https://github.com/ollama/ollama/blob/main/docs/api.md
3396
- # Model Library: https://ollama.com/library
3397
- # ===========================================================================
3398
- ollama:
3399
- # Official Ollama image - works for both CPU and GPU
3400
- image: ollama/ollama:latest
3401
-
3402
- # Fixed container name for easy CLI access
3403
- container_name: ollama
3404
-
3405
- # NOTE: No 'runtime: nvidia' - running in CPU mode
3406
-
3407
- environment:
3408
- # ---------------------------------------------------------------------------
3409
- # Ollama Configuration (Optional)
3410
- # ---------------------------------------------------------------------------
3411
- # Uncomment these to customize Ollama behavior:
3412
-
3413
- # Maximum number of models loaded in memory simultaneously
3414
- # CPU mode uses system RAM instead of VRAM
3415
- # - OLLAMA_MAX_LOADED_MODELS=1
3416
-
3417
- # Number of CPU threads to use (default: auto-detect)
3418
- # - OLLAMA_NUM_THREADS=8
3419
-
3420
- # Enable debug logging for troubleshooting
3421
- # - OLLAMA_DEBUG=1
3422
-
3423
- volumes:
3424
- # ---------------------------------------------------------------------------
3425
- # Model Storage
3426
- # ---------------------------------------------------------------------------
3427
- # Maps ./models on your host to /root/.ollama in the container
3428
- # This persists downloaded models across container restarts
3429
- - ./models:/root/.ollama
3430
-
3431
- ports:
3432
- # Ollama API port - access at http://localhost:11434
3433
- - "11434:11434"
3434
-
3435
- restart: unless-stopped
3436
-
3437
- healthcheck:
3438
- test: ["CMD", "ollama", "list"]
3439
- interval: 300s
3440
- timeout: 2s
3441
- retries: 3
3442
- start_period: 40s
3443
-
3444
- # CPU resource limits (optional - uncomment to constrain)
3445
- # deploy:
3446
- # resources:
3447
- # limits:
3448
- # cpus: '4' # Limit to 4 CPU cores
3449
- # memory: 16G # Limit to 16GB RAM
3450
- # reservations:
3451
- # cpus: '2' # Reserve at least 2 cores
3452
- # memory: 8G # Reserve at least 8GB RAM
3453
-
3454
- # ===========================================================================
3455
- # OPEN WEBUI - Chat Interface (Optional)
3456
- # ===========================================================================
3457
- # Open WebUI provides a ChatGPT-like interface for your local models.
3458
- # Access at http://localhost:3000 after starting containers.
3459
- #
3460
- # Documentation: https://docs.openwebui.com/
3461
- # ===========================================================================
3462
- open-webui:
3463
- # Standard image (no CUDA) - smaller download, CPU-only features
3464
- image: ghcr.io/open-webui/open-webui:main
3465
-
3466
- container_name: open-webui
3467
-
3468
- ports:
3469
- - "3000:8080"
3470
-
3471
- environment:
3472
- - OLLAMA_BASE_URL=http://ollama:11434
3473
-
3474
- depends_on:
3475
- - ollama
3476
-
3477
- restart: unless-stopped
3478
-
3479
- healthcheck:
3480
- test: ["CMD", "curl", "-f", "http://localhost:8080/health"]
3481
- interval: 30s
3482
- timeout: 10s
3483
- retries: 3
3484
- start_period: 60s
3485
-
3486
- volumes:
3487
- - open-webui:/app/backend/data
3488
-
3489
- # =============================================================================
3490
- # VOLUMES
3491
- # =============================================================================
3492
- volumes:
3493
- open-webui:
3494
- `;
3495
- function getConfigTemplate(gpu) {
3496
- return `{
3497
- "ollama": {
3498
- "url": "http://localhost:11434",
3499
- "defaultModel": "${gpu ? "qwen3-coder:30b" : "qwen2.5-coder:7b"}"
3500
- },
3501
- "docker": {
3502
- "composeFile": "./docker-compose.yml",
3503
- "gpu": ${gpu}
3504
- }
3505
- }
3506
- `;
3507
- }
3508
- var GITIGNORE_TEMPLATE = `# Ollama models (large binary files)
3509
- # These are downloaded by Ollama and can be re-pulled anytime
3510
- models/
3511
- `;
3512
- var MISE_TOML_TEMPLATE = `# =============================================================================
3513
- # MISE TASK RUNNER CONFIGURATION
3514
- # =============================================================================
3515
- # Mise is a task runner that provides convenient shortcuts for common operations.
3516
- # Run 'mise tasks' to see all available tasks.
3517
- #
3518
- # Documentation: https://mise.jdx.dev/
3519
- # Install: curl https://mise.jdx.dev/install.sh | sh
3520
- # =============================================================================
3521
-
3522
- [tasks]
3523
-
3524
- # =============================================================================
3525
- # Docker Management
3526
- # =============================================================================
3527
- # Commands for managing the Ollama and Open WebUI containers
3528
-
3529
- [tasks.up]
3530
- description = "Start Ollama and Open WebUI containers"
3531
- run = "loclaude docker-up"
3532
-
3533
- [tasks.down]
3534
- description = "Stop all containers"
3535
- run = "loclaude docker-down"
3536
-
3537
- [tasks.restart]
3538
- description = "Restart all containers"
3539
- run = "loclaude docker-restart"
3540
-
3541
- [tasks.status]
3542
- description = "Show container status"
3543
- run = "loclaude docker-status"
3544
-
3545
- [tasks.logs]
3546
- description = "Follow container logs"
3547
- run = "loclaude docker-logs --follow"
3548
-
3549
- # =============================================================================
3550
- # Model Management
3551
- # =============================================================================
3552
- # Commands for managing Ollama models (download, remove, list)
3553
-
3554
- [tasks.models]
3555
- description = "List installed models"
3556
- run = "loclaude models"
3557
-
3558
- [tasks.pull]
3559
- description = "Pull a model (usage: mise run pull <model-name>)"
3560
- run = "loclaude models-pull {{arg(name='model')}}"
3561
-
3562
- [tasks."pull:recommended"]
3563
- description = "Pull the recommended coding model"
3564
- run = "loclaude models-pull qwen3-coder:30b"
3565
-
3566
- # =============================================================================
3567
- # Claude Code
3568
- # =============================================================================
3569
- # Commands for running Claude Code with local Ollama
3570
-
3571
- [tasks.claude]
3572
- description = "Run Claude Code with local Ollama"
3573
- run = "loclaude run"
3574
-
3575
- [tasks."claude:model"]
3576
- description = "Run Claude with specific model (usage: mise run claude:model <model>)"
3577
- run = "loclaude run -m {{arg(name='model')}}"
3578
-
3579
- # =============================================================================
3580
- # Diagnostics
3581
- # =============================================================================
3582
- # Commands for checking system health and troubleshooting
3583
-
3584
- [tasks.doctor]
3585
- description = "Check system requirements"
3586
- run = "loclaude doctor"
3587
-
3588
- [tasks.gpu]
3589
- description = "Check GPU status (requires NVIDIA GPU)"
3590
- run = "docker exec ollama nvidia-smi"
3591
-
3592
- [tasks.config]
3593
- description = "Show current configuration"
3594
- run = "loclaude config"
3595
- `;
3596
- var README_TEMPLATE = `# Project Name
3597
-
3598
- > Powered by [loclaude](https://github.com/nicholasgalante1997/docker-ollama) - Run Claude Code with local Ollama LLMs
3599
-
3600
- ## Prerequisites
3601
-
3602
- - [Docker](https://docs.docker.com/get-docker/) with Docker Compose v2
3603
- - [mise](https://mise.jdx.dev/) task runner (recommended)
3604
- - [loclaude](https://www.npmjs.com/package/loclaude) CLI (\`npm install -g loclaude\`)
3605
-
3606
- ### For GPU Mode (Recommended)
3607
-
3608
- - [NVIDIA GPU](https://docs.nvidia.com/datacenter/cloud-native/container-toolkit/latest/install-guide.html) with CUDA support
3609
- - NVIDIA drivers installed on host
3610
- - [NVIDIA Container Toolkit](https://docs.nvidia.com/datacenter/cloud-native/container-toolkit/latest/install-guide.html)
3611
-
3612
- ## Quick Start
3613
-
3614
- \`\`\`bash
3615
- # Start the LLM backend (Ollama + Open WebUI)
3616
- mise run up
3617
-
3618
- # Pull a model (adjust based on your hardware)
3619
- mise run pull qwen3-coder:30b # GPU: 30B model (~16GB VRAM)
3620
- mise run pull qwen2.5-coder:7b # CPU: 7B model (faster)
3621
-
3622
- # Run Claude Code with local LLM
3623
- mise run claude
3624
- \`\`\`
3625
-
3626
- ## Available Commands
3627
-
3628
- Run \`mise tasks\` to see all available commands.
3629
-
3630
- | Command | Description |
3631
- |---------|-------------|
3632
- | \`mise run up\` | Start Ollama and Open WebUI containers |
3633
- | \`mise run down\` | Stop all containers |
3634
- | \`mise run status\` | Show container status |
3635
- | \`mise run logs\` | Follow container logs |
3636
- | \`mise run models\` | List installed models |
3637
- | \`mise run pull <model>\` | Pull a model from Ollama registry |
3638
- | \`mise run claude\` | Run Claude Code with model selection |
3639
- | \`mise run claude:model <model>\` | Run Claude with specific model |
3640
- | \`mise run doctor\` | Check system requirements |
3641
- | \`mise run gpu\` | Check GPU status |
3642
-
3643
- ## Service URLs
3644
-
3645
- | Service | URL | Description |
3646
- |---------|-----|-------------|
3647
- | Ollama API | http://localhost:11434 | LLM inference API |
3648
- | Open WebUI | http://localhost:3000 | Chat interface |
3649
-
3650
- ## Project Structure
3651
-
3652
- \`\`\`
3653
- .
3654
- ├── .claude/
3655
- │ └── CLAUDE.md # Claude Code project instructions
3656
- ├── .loclaude/
3657
- │ └── config.json # Loclaude configuration
3658
- ├── models/ # Ollama model storage (gitignored)
3659
- ├── docker-compose.yml # Container definitions
3660
- ├── mise.toml # Task runner configuration
3661
- └── README.md
3662
- \`\`\`
3663
-
3664
- ## Configuration
3665
-
3666
- ### Loclaude Config (\`.loclaude/config.json\`)
3667
-
3668
- \`\`\`json
3669
- {
3670
- "ollama": {
3671
- "url": "http://localhost:11434",
3672
- "defaultModel": "qwen3-coder:30b"
3673
- },
3674
- "docker": {
3675
- "composeFile": "./docker-compose.yml",
3676
- "gpu": true
3677
- }
3678
- }
3679
- \`\`\`
3680
-
3681
- ### Environment Variables
3682
-
3683
- | Variable | Description | Default |
3684
- |----------|-------------|---------|
3685
- | \`OLLAMA_URL\` | Ollama API endpoint | \`http://localhost:11434\` |
3686
- | \`OLLAMA_MODEL\` | Default model name | \`qwen3-coder:30b\` |
3687
- | \`LOCLAUDE_GPU\` | Enable GPU mode | \`true\` |
3688
-
3689
- ## Recommended Models
3690
-
3691
- ### For GPU (NVIDIA with 16GB+ VRAM)
3692
-
3693
- | Model | Size | Use Case |
3694
- |-------|------|----------|
3695
- | \`qwen3-coder:30b\` | ~16GB | Best coding performance |
3696
- | \`gpt-oss:20b\` | ~12GB | General purpose |
3697
- | \`glm-4.7:cloud\` | Cloud | No local storage needed |
3698
-
3699
- ### For CPU or Limited VRAM
3700
-
3701
- | Model | Size | Use Case |
3702
- |-------|------|----------|
3703
- | \`qwen2.5-coder:7b\` | ~4GB | Coding on CPU |
3704
- | \`llama3.2:3b\` | ~2GB | Fast, simple tasks |
3705
- | \`gemma2:9b\` | ~5GB | General purpose |
3706
-
3707
- ## Troubleshooting
3708
-
3709
- ### Check System Requirements
3710
-
3711
- \`\`\`bash
3712
- mise run doctor
3713
- \`\`\`
3714
-
3715
- ### View Container Logs
3716
-
3717
- \`\`\`bash
3718
- mise run logs
3719
- \`\`\`
3720
-
3721
- ### Restart Containers
3722
-
3723
- \`\`\`bash
3724
- mise run down && mise run up
3725
- \`\`\`
3726
-
3727
- ### GPU Not Detected
3728
-
3729
- 1. Verify NVIDIA drivers: \`nvidia-smi\`
3730
- 2. Check Docker GPU access: \`docker run --rm --gpus all nvidia/cuda:12.0-base nvidia-smi\`
3731
- 3. Install NVIDIA Container Toolkit if missing
3732
-
3733
- ## License
3734
-
3735
- MIT
3736
- `;
3737
- var CLAUDE_MD_TEMPLATE = `# Claude Code Instructions
3738
-
3739
- Project-specific instructions for Claude Code.
3740
-
3741
- ## Project Overview
3742
-
3743
- This project uses [loclaude](https://github.com/nicholasgalante1997/docker-ollama) to run Claude Code with local Ollama LLMs.
3744
-
3745
- ## Quick Reference
3746
-
3747
- \`\`\`bash
3748
- # Start the LLM backend
3749
- mise run up
3750
-
3751
- # Run Claude Code
3752
- mise run claude
3753
-
3754
- # Check system status
3755
- mise run doctor
3756
- \`\`\`
3757
-
3758
- ## Available Commands
3759
-
3760
- | Command | Description |
3761
- |---------|-------------|
3762
- | \`mise run up\` | Start Ollama + Open WebUI containers |
3763
- | \`mise run down\` | Stop containers |
3764
- | \`mise run claude\` | Run Claude Code with model selection |
3765
- | \`mise run models\` | List installed models |
3766
- | \`mise run pull <model>\` | Pull a new model |
3767
- | \`mise run doctor\` | Check prerequisites |
3768
-
3769
- ## Service URLs
3770
-
3771
- - **Ollama API:** http://localhost:11434
3772
- - **Open WebUI:** http://localhost:3000
3773
-
3774
- ## Configuration
3775
-
3776
- - **Docker:** \`docker-compose.yml\`
3777
- - **Loclaude:** \`.loclaude/config.json\`
3778
- - **Tasks:** \`mise.toml\`
3779
-
3780
- ## Conventions
3781
-
3782
- <!-- Add project-specific conventions here -->
3783
-
3784
- ## Do Not
3785
-
3786
- - Commit the \`models/\` directory (contains large model files)
3787
- `;
3788
- async function init(options = {}) {
3789
- const cwd = process.cwd();
3790
- const composePath = join2(cwd, "docker-compose.yml");
3791
- const configDir = join2(cwd, ".loclaude");
3792
- const configPath = join2(configDir, "config.json");
3793
- const modelsDir = join2(cwd, "models");
3794
- const gitignorePath = join2(cwd, ".gitignore");
3795
- const miseTomlPath = join2(cwd, "mise.toml");
3796
- const claudeDir = join2(cwd, ".claude");
3797
- const claudeMdPath = join2(claudeDir, "CLAUDE.md");
3798
- const readmePath = join2(cwd, "README.md");
3799
- header("Initializing loclaude project");
3800
- console.log("");
3801
- let gpuMode;
3802
- if (options.gpu === false) {
3803
- gpuMode = false;
3804
- console.log(info("CPU-only mode (--no-gpu)"));
3805
- } else if (options.gpu === true) {
3806
- gpuMode = true;
3807
- console.log(info("GPU mode enabled (--gpu)"));
3808
- } else {
3809
- console.log(dim(" Detecting GPU..."));
3810
- gpuMode = await hasNvidiaGpu();
3811
- if (gpuMode) {
3812
- console.log(success("NVIDIA GPU detected - using GPU mode"));
3813
- } else {
3814
- console.log(warn("No NVIDIA GPU detected - using CPU mode"));
3815
- console.log(dim(" Use --gpu to force GPU mode if you have an NVIDIA GPU"));
3816
- }
3817
- }
3818
- console.log("");
3819
- if (existsSync2(readmePath) && !options.force) {
3820
- console.log(warn(`${file("README.md")} already exists`));
3821
- } else {
3822
- writeFileSync(readmePath, README_TEMPLATE);
3823
- console.log(success(`Created ${file("README.md")}`));
3824
- }
3825
- if (existsSync2(composePath) && !options.force) {
3826
- console.log(warn(`${file("docker-compose.yml")} already exists`));
3827
- console.log(dim(" Use --force to overwrite"));
3828
- } else {
3829
- let composeContent = gpuMode ? DOCKER_COMPOSE_TEMPLATE_GPU : DOCKER_COMPOSE_TEMPLATE_CPU;
3830
- if (options.noWebui) {
3831
- composeContent = composeContent.replace(/\n # =+\n # OPEN WEBUI[\s\S]*?capabilities: \[gpu\]\n/m, `
3832
- `).replace(/\n # =+\n # OPEN WEBUI[\s\S]*?open-webui:\/app\/backend\/data\n/m, `
3833
- `).replace(/\nvolumes:\n open-webui:\n.*$/m, `
3834
- `);
3835
- }
3836
- writeFileSync(composePath, composeContent);
3837
- const modeLabel = gpuMode ? cyan("GPU") : cyan("CPU");
3838
- console.log(success(`Created ${file("docker-compose.yml")} (${modeLabel} mode)`));
3839
- }
3840
- if (existsSync2(miseTomlPath) && !options.force) {
3841
- console.log(warn(`${file("mise.toml")} already exists`));
3842
- } else {
3843
- writeFileSync(miseTomlPath, MISE_TOML_TEMPLATE);
3844
- console.log(success(`Created ${file("mise.toml")}`));
3845
- }
3846
- if (!existsSync2(claudeDir)) {
3847
- mkdirSync(claudeDir, { recursive: true });
3848
- }
3849
- if (existsSync2(claudeMdPath) && !options.force) {
3850
- console.log(warn(`${file(".claude/CLAUDE.md")} already exists`));
3851
- } else {
3852
- writeFileSync(claudeMdPath, CLAUDE_MD_TEMPLATE);
3853
- console.log(success(`Created ${file(".claude/CLAUDE.md")}`));
3854
- }
3855
- if (!existsSync2(configDir)) {
3856
- mkdirSync(configDir, { recursive: true });
3857
- console.log(success(`Created ${file(".loclaude/")} directory`));
3858
- }
3859
- if (existsSync2(configPath) && !options.force) {
3860
- console.log(warn(`${file(".loclaude/config.json")} already exists`));
3861
- } else {
3862
- writeFileSync(configPath, getConfigTemplate(gpuMode));
3863
- console.log(success(`Created ${file(".loclaude/config.json")}`));
3864
- }
3865
- if (!existsSync2(modelsDir)) {
3866
- mkdirSync(modelsDir, { recursive: true });
3867
- console.log(success(`Created ${file("models/")} directory`));
3868
- }
3869
- if (existsSync2(gitignorePath)) {
3870
- const existing = readFileSync2(gitignorePath, "utf-8");
3871
- if (!existing.includes("models/")) {
3872
- writeFileSync(gitignorePath, existing + `
3873
- ` + GITIGNORE_TEMPLATE);
3874
- console.log(success(`Updated ${file(".gitignore")}`));
3875
- }
3876
- } else {
3877
- writeFileSync(gitignorePath, GITIGNORE_TEMPLATE);
3878
- console.log(success(`Created ${file(".gitignore")}`));
3879
- }
3880
- const recommendedModel = gpuMode ? "qwen3-coder:30b" : "qwen2.5-coder:7b";
3881
- console.log("");
3882
- console.log(green("Project initialized!"));
3883
- console.log("");
3884
- console.log(cyan("Next steps:"));
3885
- console.log(` 1. Start containers: ${cmd("mise run up")}`);
3886
- console.log(` 2. Pull a model: ${cmd(`mise run pull ${recommendedModel}`)}`);
3887
- console.log(` 3. Run Claude: ${cmd("mise run claude")}`);
3888
- console.log("");
3889
- console.log(cyan("Service URLs:"));
3890
- console.log(` Ollama API: ${url("http://localhost:11434")}`);
3891
- if (!options.noWebui) {
3892
- console.log(` Open WebUI: ${url("http://localhost:3000")}`);
3893
- }
3894
- }
3895
- // lib/commands/config.ts
3896
- async function configShow() {
3897
- const config = loadConfig();
3898
- const activePath = getActiveConfigPath();
3899
- header("Current Configuration");
3900
- console.log("");
3901
- console.log(cyan("Ollama:"));
3902
- labelValue(" URL", config.ollama.url);
3903
- labelValue(" Default Model", magenta(config.ollama.defaultModel));
3904
- console.log("");
3905
- console.log(cyan("Docker:"));
3906
- labelValue(" Compose File", config.docker.composeFile);
3907
- labelValue(" GPU Mode", config.docker.gpu ? green("enabled") : dim("disabled"));
3908
- console.log("");
3909
- console.log(cyan("Claude:"));
3910
- if (config.claude.extraArgs.length > 0) {
3911
- labelValue(" Extra Args", config.claude.extraArgs.join(" "));
3912
- } else {
3913
- labelValue(" Extra Args", dim("none"));
3914
- }
3915
- console.log("");
3916
- console.log(dim("─".repeat(40)));
3917
- if (activePath) {
3918
- console.log(dim(`Loaded from: ${file(activePath)}`));
3919
- } else {
3920
- console.log(dim("Using default configuration (no config file found)"));
3921
- }
3922
- }
3923
- async function configPaths() {
3924
- const paths = getConfigSearchPaths();
3925
- const activePath = getActiveConfigPath();
3926
- header("Config Search Paths");
3927
- console.log("");
3928
- console.log(dim("Files are checked in priority order (first found wins):"));
3929
- console.log("");
3930
- for (let i = 0;i < paths.length; i++) {
3931
- const configPath = paths[i];
3932
- if (!configPath)
3933
- continue;
3934
- const isActive = configPath === activePath;
3935
- const num = `${i + 1}.`;
3936
- if (isActive) {
3937
- console.log(` ${num} ${file(configPath)} ${green("← active")}`);
3938
- } else {
3939
- console.log(` ${num} ${dim(configPath)}`);
3940
- }
3941
- }
3942
- console.log("");
3943
- if (!activePath) {
3944
- console.log(info("No config file found. Using defaults."));
3945
- console.log(dim(` Run ${cmd("loclaude init")} to create a project config.`));
3946
- }
3947
- }
3948
- // lib/commands/docker.ts
3949
- import { existsSync as existsSync3 } from "fs";
3950
- import path, { join as join3, isAbsolute } from "path";
3951
- import { fileURLToPath } from "url";
3952
- function findComposeFile() {
3953
- const configPath = getComposeFile();
3954
- if (configPath) {
3955
- const absolutePath = isAbsolute(configPath) ? configPath : join3(process.cwd(), configPath);
3956
- if (existsSync3(absolutePath)) {
3957
- return absolutePath;
3958
- }
3959
- }
3960
- let dir = process.cwd();
3961
- while (dir !== "/" && dir.startsWith(process.cwd())) {
3962
- const composePath = join3(dir, "docker-compose.yml");
3963
- if (existsSync3(composePath)) {
3964
- return composePath;
3965
- }
3966
- const dockerComposePath = join3(dir, "docker", "docker-compose.yml");
3967
- if (existsSync3(dockerComposePath)) {
3968
- return dockerComposePath;
3969
- }
3970
- dir = join3(dir, "..");
3971
- }
3972
- const backup = path.resolve(fileURLToPath(import.meta.url), "..", "docker", "docker-compose.yml");
3973
- if (existsSync3(backup)) {
3974
- return backup;
3975
- }
3976
- return null;
3977
- }
3978
- function getComposeCommand() {
3979
- return ["docker", "compose"];
3980
- }
3981
- async function runCompose(args, options = {}) {
3982
- const composeFile = options.file ?? findComposeFile();
3983
- if (!composeFile) {
3984
- console.log(error("No docker-compose.yml found"));
3985
- console.log(dim(` Run ${cmd("loclaude init")} to create one, or specify --file`));
3986
- return 1;
3987
- }
3988
- const cmd_args = [...getComposeCommand(), "-f", composeFile, ...args];
3989
- return spawn(cmd_args);
3990
- }
3991
- async function dockerUp(options = {}) {
3992
- const args = ["up"];
3993
- if (options.detach !== false) {
3994
- args.push("-d");
3995
- }
3996
- console.log(info("Starting containers..."));
3997
- console.log("");
3998
- const exitCode = await runCompose(args, options);
3999
- if (exitCode === 0) {
4000
- console.log("");
4001
- console.log(success("Containers started"));
4002
- console.log("");
4003
- console.log(cyan("Service URLs:"));
4004
- console.log(` Ollama API: ${url("http://localhost:11434")}`);
4005
- console.log(` Open WebUI: ${url("http://localhost:3000")}`);
4006
- }
4007
- process.exit(exitCode);
4008
- }
4009
- async function dockerDown(options = {}) {
4010
- console.log(info("Stopping containers..."));
4011
- console.log("");
4012
- const exitCode = await runCompose(["down"], options);
4013
- if (exitCode === 0) {
4014
- console.log("");
4015
- console.log(success("Containers stopped"));
4016
- }
4017
- process.exit(exitCode);
4018
- }
4019
- async function dockerStatus(options = {}) {
4020
- console.log(info("Container status:"));
4021
- console.log("");
4022
- const exitCode = await runCompose(["ps"], options);
4023
- process.exit(exitCode);
4024
- }
4025
- async function dockerLogs(options = {}) {
4026
- const args = ["logs"];
4027
- if (options.follow) {
4028
- args.push("-f");
4029
- }
4030
- if (options.service) {
4031
- args.push(options.service);
4032
- console.log(info(`Logs for ${cyan(options.service)}:`));
4033
- } else {
4034
- console.log(info("Container logs:"));
4035
- }
4036
- console.log("");
4037
- const exitCode = await runCompose(args, options);
4038
- process.exit(exitCode);
4039
- }
4040
- async function dockerRestart(options = {}) {
4041
- console.log(info("Restarting containers..."));
4042
- console.log("");
4043
- const exitCode = await runCompose(["restart"], options);
4044
- if (exitCode === 0) {
4045
- console.log("");
4046
- console.log(success("Containers restarted"));
4047
- }
4048
- process.exit(exitCode);
4049
- }
4050
- // lib/commands/models.ts
4051
- var import_bytes2 = __toESM(require_bytes(), 1);
4052
- async function fetchModels() {
4053
- const ollamaUrl = getOllamaUrl();
4054
- try {
4055
- const response = await fetch(`${ollamaUrl}/api/tags`, {
4056
- signal: AbortSignal.timeout(1e4)
4057
- });
4058
- if (!response.ok) {
4059
- throw new Error(`HTTP ${response.status}`);
4060
- }
4061
- const data = await response.json();
4062
- return data.models ?? [];
4063
- } catch (error3) {
4064
- if (error3 instanceof Error && error3.name === "TimeoutError") {
4065
- throw new Error(`Connection to Ollama timed out (${ollamaUrl})`);
4066
- }
4067
- throw error3;
4068
- }
4069
- }
4070
- async function isOllamaInDocker() {
4071
- const result = await spawnCapture(["docker", "ps", "--filter", "name=ollama", "--format", "{{.Names}}"]);
4072
- return result.exitCode === 0 && (result.stdout?.includes("ollama") ?? false);
4073
- }
4074
- async function runOllamaCommand(args) {
4075
- const inDocker = await isOllamaInDocker();
4076
- if (inDocker) {
4077
- return spawn(["docker", "exec", "-it", "ollama", "ollama", ...args]);
4078
- } else {
4079
- return spawn(["ollama", ...args]);
4080
- }
4081
- }
4082
- function formatSize(sizeBytes) {
4083
- const sizeStr = import_bytes2.default(sizeBytes) ?? "?";
4084
- const sizeNum = sizeBytes / (1024 * 1024 * 1024);
4085
- if (sizeNum > 20) {
4086
- return yellow(sizeStr);
4087
- } else if (sizeNum > 10) {
4088
- return cyan(sizeStr);
4089
- }
4090
- return dim(sizeStr);
4091
- }
4092
- async function modelsList() {
4093
- try {
4094
- const models = await fetchModels();
4095
- if (models.length === 0) {
4096
- header("Installed Models");
4097
- console.log("");
4098
- console.log(info("No models installed."));
4099
- console.log("");
4100
- console.log(`Pull a model with: ${cmd("loclaude models-pull <model-name>")}`);
4101
- console.log(`Example: ${cmd("loclaude models-pull llama3.2")}`);
4102
- return;
4103
- }
4104
- header("Installed Models");
4105
- console.log("");
4106
- const nameWidth = Math.max(...models.map((m) => m.name.length), "NAME".length);
4107
- const sizeWidth = 10;
4108
- const modifiedWidth = 20;
4109
- tableHeader(["NAME", "SIZE", "MODIFIED"], [nameWidth, sizeWidth, modifiedWidth]);
4110
- for (const model of models) {
4111
- const name = magenta(model.name.padEnd(nameWidth));
4112
- const size = formatSize(model.size).padStart(sizeWidth);
4113
- const modified = dim(formatRelativeTime(model.modified_at));
4114
- console.log(`${name} ${size} ${modified}`);
4115
- }
4116
- console.log("");
4117
- console.log(dim(`${models.length} model(s) installed`));
4118
- } catch (err) {
4119
- const ollamaUrl = getOllamaUrl();
4120
- console.log(error(`Could not connect to Ollama at ${ollamaUrl}`));
4121
- console.log(dim(` Make sure Ollama is running: ${cmd("loclaude docker-up")}`));
4122
- process.exit(1);
4123
- }
4124
- }
4125
- async function modelsPull(modelName) {
4126
- if (!modelName) {
4127
- console.log(error("Model name required"));
4128
- console.log(dim(`Usage: ${cmd("loclaude models-pull <model-name>")}`));
4129
- console.log(dim(`Example: ${cmd("loclaude models-pull llama3.2")}`));
4130
- process.exit(1);
4131
- }
4132
- console.log(info(`Pulling model: ${magenta(modelName)}`));
4133
- console.log("");
4134
- const exitCode = await runOllamaCommand(["pull", modelName]);
4135
- if (exitCode === 0) {
4136
- console.log("");
4137
- console.log(success(`Model '${magenta(modelName)}' pulled successfully`));
4138
- }
4139
- process.exit(exitCode);
4140
- }
4141
- async function modelsRm(modelName) {
4142
- if (!modelName) {
4143
- console.log(error("Model name required"));
4144
- console.log(dim(`Usage: ${cmd("loclaude models-rm <model-name>")}`));
4145
- process.exit(1);
4146
- }
4147
- console.log(info(`Removing model: ${magenta(modelName)}`));
4148
- console.log("");
4149
- const exitCode = await runOllamaCommand(["rm", modelName]);
4150
- if (exitCode === 0) {
4151
- console.log("");
4152
- console.log(success(`Model '${magenta(modelName)}' removed`));
4153
- }
4154
- process.exit(exitCode);
4155
- }
4156
- async function modelsShow(modelName) {
4157
- if (!modelName) {
4158
- console.log(error("Model name required"));
4159
- console.log(dim(`Usage: ${cmd("loclaude models-show <model-name>")}`));
4160
- process.exit(1);
4161
- }
4162
- console.log(info(`Model details: ${magenta(modelName)}`));
4163
- console.log("");
4164
- const exitCode = await runOllamaCommand(["show", modelName]);
4165
- process.exit(exitCode);
4166
- }
4167
- async function modelsRun(modelName) {
4168
- if (!modelName) {
4169
- console.log(error("Model name required"));
4170
- console.log(dim(`Usage: ${cmd("loclaude models-run <model-name>")}`));
4171
- process.exit(1);
4172
- }
4173
- console.log(info(`Running model: ${magenta(modelName)}`));
4174
- console.log("");
4175
- const exitCode = await runOllamaCommand(["run", modelName]);
4176
- process.exit(exitCode);
4177
- }
4178
- function formatRelativeTime(dateStr) {
4179
- const date = new Date(dateStr);
4180
- const now = new Date;
4181
- const diffMs = now.getTime() - date.getTime();
4182
- const diffSecs = Math.floor(diffMs / 1000);
4183
- const diffMins = Math.floor(diffSecs / 60);
4184
- const diffHours = Math.floor(diffMins / 60);
4185
- const diffDays = Math.floor(diffHours / 24);
4186
- const diffWeeks = Math.floor(diffDays / 7);
4187
- if (diffSecs < 60)
4188
- return "just now";
4189
- if (diffMins < 60)
4190
- return `${diffMins} minute${diffMins === 1 ? "" : "s"} ago`;
4191
- if (diffHours < 24)
4192
- return `${diffHours} hour${diffHours === 1 ? "" : "s"} ago`;
4193
- if (diffDays < 7)
4194
- return `${diffDays} day${diffDays === 1 ? "" : "s"} ago`;
4195
- if (diffWeeks < 4)
4196
- return `${diffWeeks} week${diffWeeks === 1 ? "" : "s"} ago`;
4197
- return date.toLocaleDateString();
4198
- }
4199
- // lib/cac.ts
4200
- var cli = dist_default("loclaude");
4201
- cli.command("run [...args]", "Run Claude Code with local Ollama", {
4202
- allowUnknownOptions: true
4203
- }).alias("x").option("-m, --model <name>", "Specify model to use").action(async (args, options) => {
4204
- let model;
4205
- if (options.model) {
4206
- model = options.model;
4207
- } else if (args.includes("--help") || args.includes("-h")) {
4208
- model = DEFAULT_MODEL;
4209
- } else {
4210
- model = await selectModelInteractively();
4211
- }
4212
- await launchClaude(model, args);
4213
- });
4214
- cli.command("init", "Initialize a new loclaude project").option("--force", "Overwrite existing files").option("--no-webui", "Skip Open WebUI in docker-compose").option("--gpu", "Force GPU mode (NVIDIA)").option("--no-gpu", "Force CPU-only mode").action(async (options) => {
4215
- await init(options);
4216
- });
4217
- cli.command("doctor", "Check system requirements and health").action(async () => {
4218
- await doctor();
4219
- });
4220
- cli.command("config", "Show current configuration").action(async () => {
4221
- await configShow();
4222
- });
4223
- cli.command("config-paths", "Show config file search paths").action(async () => {
4224
- await configPaths();
4225
- });
4226
- cli.command("docker-up", "Start Ollama and Open WebUI containers").option("-f, --file <path>", "Path to docker-compose.yml").option("--no-detach", "Run in foreground (don't detach)").action(async (options) => {
4227
- await dockerUp(options);
4228
- });
4229
- cli.command("docker-down", "Stop containers").option("-f, --file <path>", "Path to docker-compose.yml").action(async (options) => {
4230
- await dockerDown(options);
4231
- });
4232
- cli.command("docker-status", "Show container status").option("-f, --file <path>", "Path to docker-compose.yml").action(async (options) => {
4233
- await dockerStatus(options);
4234
- });
4235
- cli.command("docker-logs", "Show container logs").option("-f, --file <path>", "Path to docker-compose.yml").option("--follow", "Follow log output").option("-s, --service <name>", "Show logs for specific service").action(async (options) => {
4236
- await dockerLogs(options);
4237
- });
4238
- cli.command("docker-restart", "Restart containers").option("-f, --file <path>", "Path to docker-compose.yml").action(async (options) => {
4239
- await dockerRestart(options);
4240
- });
4241
- cli.command("models", "List installed Ollama models").action(async () => {
4242
- await modelsList();
4243
- });
4244
- cli.command("models-pull <name>", "Pull a model from Ollama registry").action(async (name) => {
4245
- await modelsPull(name);
4246
- });
4247
- cli.command("models-rm <name>", "Remove an installed model").action(async (name) => {
4248
- await modelsRm(name);
4249
- });
4250
- cli.command("models-show <name>", "Show model information").action(async (name) => {
4251
- await modelsShow(name);
4252
- });
4253
- cli.command("models-run <name>", "Run a model interactively").action(async (name) => {
4254
- await modelsRun(name);
4255
- });
4256
- cli.help();
4257
- cli.version("0.0.1-rc.1");
4258
- var help = () => cli.outputHelp();
4259
- var version = () => cli.outputVersion();
4260
- var run_cli = () => {
4261
- cli.parse();
4262
- };
4263
- export {
4264
- version,
4265
- run_cli,
4266
- help,
4267
- cli
4268
- };
4269
-
4270
- //# debugId=D27E5C5FE65A8CD164756E2164756E21
4271
- //# sourceMappingURL=index.js.map