trellis 2.1.9 → 3.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 (164) hide show
  1. package/README.md +65 -796
  2. package/dist/cli/index.d.ts +3 -1
  3. package/dist/cli/index.d.ts.map +1 -1
  4. package/dist/cli/index.js +2948 -182
  5. package/dist/client/index.js +4 -4
  6. package/dist/context/heat-map-manager.d.ts +100 -0
  7. package/dist/context/heat-map-manager.d.ts.map +1 -0
  8. package/dist/context/manager.d.ts +16 -0
  9. package/dist/context/manager.d.ts.map +1 -0
  10. package/dist/context/types.d.ts +20 -0
  11. package/dist/context/types.d.ts.map +1 -0
  12. package/dist/core/agents/harness.d.ts +10 -1
  13. package/dist/core/agents/harness.d.ts.map +1 -1
  14. package/dist/core/agents/types.d.ts +18 -2
  15. package/dist/core/agents/types.d.ts.map +1 -1
  16. package/dist/core/computation/expr-evaluator.d.ts +52 -0
  17. package/dist/core/computation/expr-evaluator.d.ts.map +1 -0
  18. package/dist/core/index.js +93 -5
  19. package/dist/core/kernel/logic-middleware.d.ts +19 -0
  20. package/dist/core/kernel/logic-middleware.d.ts.map +1 -0
  21. package/dist/core/kernel/schema-middleware.d.ts +15 -0
  22. package/dist/core/kernel/schema-middleware.d.ts.map +1 -0
  23. package/dist/core/kernel/security-middleware.d.ts +24 -0
  24. package/dist/core/kernel/security-middleware.d.ts.map +1 -0
  25. package/dist/core/kernel/sync-provider.d.ts +59 -0
  26. package/dist/core/kernel/sync-provider.d.ts.map +1 -0
  27. package/dist/core/kernel/trellis-kernel.d.ts +55 -0
  28. package/dist/core/kernel/trellis-kernel.d.ts.map +1 -1
  29. package/dist/core/ontology/builtins.d.ts.map +1 -1
  30. package/dist/core/ontology/core-ontology.d.ts +20 -0
  31. package/dist/core/ontology/core-ontology.d.ts.map +1 -0
  32. package/dist/core/ontology/index.d.ts +3 -1
  33. package/dist/core/ontology/index.d.ts.map +1 -1
  34. package/dist/core/ontology/types.d.ts +138 -34
  35. package/dist/core/ontology/types.d.ts.map +1 -1
  36. package/dist/core/persist/backend.d.ts +2 -0
  37. package/dist/core/persist/backend.d.ts.map +1 -1
  38. package/dist/core/persist/better-sqlite-backend.d.ts +33 -0
  39. package/dist/core/persist/better-sqlite-backend.d.ts.map +1 -0
  40. package/dist/core/persist/sqlite-backend.d.ts +2 -0
  41. package/dist/core/persist/sqlite-backend.d.ts.map +1 -1
  42. package/dist/core/store/eav-store.d.ts +4 -0
  43. package/dist/core/store/eav-store.d.ts.map +1 -1
  44. package/dist/db/index.js +10 -8
  45. package/dist/{deploy-99j5dc9c.js → deploy-999q207z.js} +2 -1
  46. package/dist/engine.d.ts +3 -1
  47. package/dist/engine.d.ts.map +1 -1
  48. package/dist/evals/types.d.ts +29 -0
  49. package/dist/evals/types.d.ts.map +1 -0
  50. package/dist/{import-fyg5sgq4.js → import-s2b8e0ft.js} +2 -2
  51. package/dist/{index-3ejh8k6v.js → index-0q7wbasy.js} +18 -4
  52. package/dist/{index-7t92ej34.js → index-0zk3fx2s.js} +467 -7
  53. package/dist/{index-xr7rx360.js → index-6n5dcebj.js} +33 -0
  54. package/dist/{index-4beszbgg.js → index-7e27kvvj.js} +1 -1
  55. package/dist/index-bmyt7k8n.js +90 -0
  56. package/dist/{index-k5kf7sd0.js → index-hmdbnd4n.js} +1 -1
  57. package/dist/{index-czecrvvn.js → index-q31hfjja.js} +858 -48
  58. package/dist/{index-8fjwnztt.js → index-skhn0agf.js} +1 -1
  59. package/dist/{index-04sq3h27.js → index-w7ng765c.js} +3 -1
  60. package/dist/{index-hgd30epa.js → index-wt8rz4gn.js} +4 -21
  61. package/dist/{index-5p6zgspx.js → index-y3d71wzd.js} +1 -1
  62. package/dist/index-y6a4kj0p.js +43 -0
  63. package/dist/{index-5bhe57y9.js → index-yhwjgfvj.js} +16 -0
  64. package/dist/index.d.ts +2 -0
  65. package/dist/index.d.ts.map +1 -1
  66. package/dist/index.js +16 -6
  67. package/dist/llm/provider.d.ts +11 -0
  68. package/dist/llm/provider.d.ts.map +1 -0
  69. package/dist/llm/types.d.ts +74 -0
  70. package/dist/llm/types.d.ts.map +1 -0
  71. package/dist/mcp/index.d.ts +7 -1
  72. package/dist/mcp/index.d.ts.map +1 -1
  73. package/dist/orchestration/types.d.ts +22 -0
  74. package/dist/orchestration/types.d.ts.map +1 -0
  75. package/dist/plugins/agent-memory/graph-context-manager.d.ts +75 -0
  76. package/dist/plugins/agent-memory/graph-context-manager.d.ts.map +1 -0
  77. package/dist/plugins/agent-memory/index.d.ts +30 -0
  78. package/dist/plugins/agent-memory/index.d.ts.map +1 -0
  79. package/dist/plugins/agent-memory/ontology.d.ts +13 -0
  80. package/dist/plugins/agent-memory/ontology.d.ts.map +1 -0
  81. package/dist/plugins/agent-memory/plugin.d.ts +17 -0
  82. package/dist/plugins/agent-memory/plugin.d.ts.map +1 -0
  83. package/dist/plugins/brand/cache.d.ts +18 -0
  84. package/dist/plugins/brand/cache.d.ts.map +1 -0
  85. package/dist/plugins/brand/catalog-generator.d.ts +89 -0
  86. package/dist/plugins/brand/catalog-generator.d.ts.map +1 -0
  87. package/dist/plugins/brand/constraints.d.ts +55 -0
  88. package/dist/plugins/brand/constraints.d.ts.map +1 -0
  89. package/dist/plugins/brand/index.d.ts +44 -0
  90. package/dist/plugins/brand/index.d.ts.map +1 -0
  91. package/dist/plugins/brand/mcp-tools.d.ts +101 -0
  92. package/dist/plugins/brand/mcp-tools.d.ts.map +1 -0
  93. package/dist/plugins/brand/ontology.d.ts +13 -0
  94. package/dist/plugins/brand/ontology.d.ts.map +1 -0
  95. package/dist/plugins/brand/plugin.d.ts +21 -0
  96. package/dist/plugins/brand/plugin.d.ts.map +1 -0
  97. package/dist/plugins/brand/voice-tone.d.ts +24 -0
  98. package/dist/plugins/brand/voice-tone.d.ts.map +1 -0
  99. package/dist/plugins/idea-garden/api.d.ts +26 -0
  100. package/dist/plugins/idea-garden/api.d.ts.map +1 -0
  101. package/dist/plugins/idea-garden/index.d.ts +12 -0
  102. package/dist/plugins/idea-garden/index.d.ts.map +1 -0
  103. package/dist/plugins/idea-garden/plugin.d.ts +16 -0
  104. package/dist/plugins/idea-garden/plugin.d.ts.map +1 -0
  105. package/dist/plugins/idea-garden/types.d.ts +22 -0
  106. package/dist/plugins/idea-garden/types.d.ts.map +1 -0
  107. package/dist/plugins/plan-approval/index.d.ts +36 -0
  108. package/dist/plugins/plan-approval/index.d.ts.map +1 -0
  109. package/dist/plugins/plan-approval/ontology.d.ts +11 -0
  110. package/dist/plugins/plan-approval/ontology.d.ts.map +1 -0
  111. package/dist/plugins/plan-approval/plan-manager.d.ts +104 -0
  112. package/dist/plugins/plan-approval/plan-manager.d.ts.map +1 -0
  113. package/dist/plugins/plan-approval/plugin.d.ts +110 -0
  114. package/dist/plugins/plan-approval/plugin.d.ts.map +1 -0
  115. package/dist/plugins/proactive-watcher/index.d.ts +28 -0
  116. package/dist/plugins/proactive-watcher/index.d.ts.map +1 -0
  117. package/dist/plugins/proactive-watcher/ontology.d.ts +8 -0
  118. package/dist/plugins/proactive-watcher/ontology.d.ts.map +1 -0
  119. package/dist/plugins/proactive-watcher/plugin.d.ts +20 -0
  120. package/dist/plugins/proactive-watcher/plugin.d.ts.map +1 -0
  121. package/dist/plugins/proactive-watcher/watcher-manager.d.ts +36 -0
  122. package/dist/plugins/proactive-watcher/watcher-manager.d.ts.map +1 -0
  123. package/dist/plugins/sprite-tools/checkpoint-middleware.d.ts +43 -0
  124. package/dist/plugins/sprite-tools/checkpoint-middleware.d.ts.map +1 -0
  125. package/dist/plugins/sprite-tools/index.d.ts +40 -0
  126. package/dist/plugins/sprite-tools/index.d.ts.map +1 -0
  127. package/dist/plugins/sprite-tools/plugin.d.ts +69 -0
  128. package/dist/plugins/sprite-tools/plugin.d.ts.map +1 -0
  129. package/dist/react/index.js +4 -4
  130. package/dist/scaffold/index.d.ts +13 -0
  131. package/dist/scaffold/index.d.ts.map +1 -0
  132. package/dist/scaffold/infer.d.ts +42 -0
  133. package/dist/scaffold/infer.d.ts.map +1 -0
  134. package/dist/scaffold/profile.d.ts +51 -0
  135. package/dist/scaffold/profile.d.ts.map +1 -0
  136. package/dist/scaffold/seed.d.ts +27 -0
  137. package/dist/scaffold/seed.d.ts.map +1 -0
  138. package/dist/scaffold/write.d.ts +53 -0
  139. package/dist/scaffold/write.d.ts.map +1 -0
  140. package/dist/{sdk-sj8rp0m7.js → sdk-snn5gad3.js} +4 -4
  141. package/dist/server/deploy.d.ts.map +1 -1
  142. package/dist/server/index.d.ts +5 -3
  143. package/dist/server/index.d.ts.map +1 -1
  144. package/dist/server/index.js +37 -7
  145. package/dist/server/sprites.d.ts +26 -0
  146. package/dist/server/sprites.d.ts.map +1 -0
  147. package/dist/server/vm-config.d.ts +60 -0
  148. package/dist/server/vm-config.d.ts.map +1 -0
  149. package/dist/{server-3vkpnpbz.js → server-mrctdwzr.js} +2 -2
  150. package/dist/sprites-vc4qbrp1.js +16 -0
  151. package/dist/streaming/types.d.ts +43 -0
  152. package/dist/streaming/types.d.ts.map +1 -0
  153. package/dist/{tenancy-tjr7kk2v.js → tenancy-7d1g4ayp.js} +3 -3
  154. package/dist/ui/client.html +460 -664
  155. package/dist/ui/server.d.ts +6 -2
  156. package/dist/ui/server.d.ts.map +1 -1
  157. package/dist/vcs/decompose.d.ts.map +1 -1
  158. package/dist/vcs/index.js +2 -2
  159. package/dist/vcs/issue.d.ts.map +1 -1
  160. package/dist/vcs/types.d.ts +1 -0
  161. package/dist/vcs/types.d.ts.map +1 -1
  162. package/dist/vm-config-6xhsj6b3.js +22 -0
  163. package/package.json +14 -4
  164. /package/dist/{index-kbnht9p8.js → index-c9h37r6h.js} +0 -0
package/dist/cli/index.js CHANGED
@@ -2,14 +2,23 @@
2
2
  // @bun
3
3
  import {
4
4
  TrellisVcsEngine,
5
- init_engine
6
- } from "../index-czecrvvn.js";
5
+ hasProfile,
6
+ inferProjectContext,
7
+ init_engine,
8
+ loadProfile,
9
+ promptForProfile,
10
+ saveProfile,
11
+ seedContext,
12
+ updateProfile,
13
+ writeAgentScaffold,
14
+ writeIdeScaffold
15
+ } from "../index-q31hfjja.js";
7
16
  import {
8
17
  OntologyRegistry,
9
18
  builtinOntologies,
10
19
  validateStore
11
- } from "../index-04sq3h27.js";
12
- import"../index-3ejh8k6v.js";
20
+ } from "../index-w7ng765c.js";
21
+ import"../index-0q7wbasy.js";
13
22
  import {
14
23
  VectorStore,
15
24
  buildRAGContext,
@@ -38,8 +47,8 @@ import {
38
47
  import {
39
48
  SqliteKernelBackend,
40
49
  TrellisKernel
41
- } from "../index-7t92ej34.js";
42
- import"../index-5bhe57y9.js";
50
+ } from "../index-0zk3fx2s.js";
51
+ import"../index-yhwjgfvj.js";
43
52
  import {
44
53
  QueryEngine
45
54
  } from "../index-yp88he8n.js";
@@ -102,7 +111,7 @@ var require_argument = __commonJS((exports) => {
102
111
  this._name = name;
103
112
  break;
104
113
  }
105
- if (this._name.endsWith("...")) {
114
+ if (this._name.length > 3 && this._name.slice(-3) === "...") {
106
115
  this.variadic = true;
107
116
  this._name = this._name.slice(0, -3);
108
117
  }
@@ -110,12 +119,11 @@ var require_argument = __commonJS((exports) => {
110
119
  name() {
111
120
  return this._name;
112
121
  }
113
- _collectValue(value, previous) {
122
+ _concatValue(value, previous) {
114
123
  if (previous === this.defaultValue || !Array.isArray(previous)) {
115
124
  return [value];
116
125
  }
117
- previous.push(value);
118
- return previous;
126
+ return previous.concat(value);
119
127
  }
120
128
  default(value, description) {
121
129
  this.defaultValue = value;
@@ -133,7 +141,7 @@ var require_argument = __commonJS((exports) => {
133
141
  throw new InvalidArgumentError(`Allowed choices are ${this.argChoices.join(", ")}.`);
134
142
  }
135
143
  if (this.variadic) {
136
- return this._collectValue(arg, previous);
144
+ return this._concatValue(arg, previous);
137
145
  }
138
146
  return arg;
139
147
  };
@@ -298,11 +306,7 @@ var require_help = __commonJS((exports) => {
298
306
  extraInfo.push(`env: ${option.envVar}`);
299
307
  }
300
308
  if (extraInfo.length > 0) {
301
- const extraDescription = `(${extraInfo.join(", ")})`;
302
- if (option.description) {
303
- return `${option.description} ${extraDescription}`;
304
- }
305
- return extraDescription;
309
+ return `${option.description} (${extraInfo.join(", ")})`;
306
310
  }
307
311
  return option.description;
308
312
  }
@@ -323,27 +327,6 @@ var require_help = __commonJS((exports) => {
323
327
  }
324
328
  return argument.description;
325
329
  }
326
- formatItemList(heading, items, helper) {
327
- if (items.length === 0)
328
- return [];
329
- return [helper.styleTitle(heading), ...items, ""];
330
- }
331
- groupItems(unsortedItems, visibleItems, getGroup) {
332
- const result = new Map;
333
- unsortedItems.forEach((item) => {
334
- const group = getGroup(item);
335
- if (!result.has(group))
336
- result.set(group, []);
337
- });
338
- visibleItems.forEach((item) => {
339
- const group = getGroup(item);
340
- if (!result.has(group)) {
341
- result.set(group, []);
342
- }
343
- result.get(group).push(item);
344
- });
345
- return result;
346
- }
347
330
  formatHelp(cmd, helper) {
348
331
  const termWidth = helper.padWidth(cmd, helper);
349
332
  const helpWidth = helper.helpWidth ?? 80;
@@ -364,27 +347,45 @@ var require_help = __commonJS((exports) => {
364
347
  const argumentList = helper.visibleArguments(cmd).map((argument) => {
365
348
  return callFormatItem(helper.styleArgumentTerm(helper.argumentTerm(argument)), helper.styleArgumentDescription(helper.argumentDescription(argument)));
366
349
  });
367
- output = output.concat(this.formatItemList("Arguments:", argumentList, helper));
368
- const optionGroups = this.groupItems(cmd.options, helper.visibleOptions(cmd), (option) => option.helpGroupHeading ?? "Options:");
369
- optionGroups.forEach((options, group) => {
370
- const optionList = options.map((option) => {
371
- return callFormatItem(helper.styleOptionTerm(helper.optionTerm(option)), helper.styleOptionDescription(helper.optionDescription(option)));
372
- });
373
- output = output.concat(this.formatItemList(group, optionList, helper));
350
+ if (argumentList.length > 0) {
351
+ output = output.concat([
352
+ helper.styleTitle("Arguments:"),
353
+ ...argumentList,
354
+ ""
355
+ ]);
356
+ }
357
+ const optionList = helper.visibleOptions(cmd).map((option) => {
358
+ return callFormatItem(helper.styleOptionTerm(helper.optionTerm(option)), helper.styleOptionDescription(helper.optionDescription(option)));
374
359
  });
360
+ if (optionList.length > 0) {
361
+ output = output.concat([
362
+ helper.styleTitle("Options:"),
363
+ ...optionList,
364
+ ""
365
+ ]);
366
+ }
375
367
  if (helper.showGlobalOptions) {
376
368
  const globalOptionList = helper.visibleGlobalOptions(cmd).map((option) => {
377
369
  return callFormatItem(helper.styleOptionTerm(helper.optionTerm(option)), helper.styleOptionDescription(helper.optionDescription(option)));
378
370
  });
379
- output = output.concat(this.formatItemList("Global Options:", globalOptionList, helper));
371
+ if (globalOptionList.length > 0) {
372
+ output = output.concat([
373
+ helper.styleTitle("Global Options:"),
374
+ ...globalOptionList,
375
+ ""
376
+ ]);
377
+ }
380
378
  }
381
- const commandGroups = this.groupItems(cmd.commands, helper.visibleCommands(cmd), (sub) => sub.helpGroup() || "Commands:");
382
- commandGroups.forEach((commands, group) => {
383
- const commandList = commands.map((sub) => {
384
- return callFormatItem(helper.styleSubcommandTerm(helper.subcommandTerm(sub)), helper.styleSubcommandDescription(helper.subcommandDescription(sub)));
385
- });
386
- output = output.concat(this.formatItemList(group, commandList, helper));
379
+ const commandList = helper.visibleCommands(cmd).map((cmd2) => {
380
+ return callFormatItem(helper.styleSubcommandTerm(helper.subcommandTerm(cmd2)), helper.styleSubcommandDescription(helper.subcommandDescription(cmd2)));
387
381
  });
382
+ if (commandList.length > 0) {
383
+ output = output.concat([
384
+ helper.styleTitle("Commands:"),
385
+ ...commandList,
386
+ ""
387
+ ]);
388
+ }
388
389
  return output.join(`
389
390
  `);
390
391
  }
@@ -541,7 +542,6 @@ var require_option = __commonJS((exports) => {
541
542
  this.argChoices = undefined;
542
543
  this.conflictsWith = [];
543
544
  this.implied = undefined;
544
- this.helpGroupHeading = undefined;
545
545
  }
546
546
  default(value, description) {
547
547
  this.defaultValue = value;
@@ -580,12 +580,11 @@ var require_option = __commonJS((exports) => {
580
580
  this.hidden = !!hide;
581
581
  return this;
582
582
  }
583
- _collectValue(value, previous) {
583
+ _concatValue(value, previous) {
584
584
  if (previous === this.defaultValue || !Array.isArray(previous)) {
585
585
  return [value];
586
586
  }
587
- previous.push(value);
588
- return previous;
587
+ return previous.concat(value);
589
588
  }
590
589
  choices(values) {
591
590
  this.argChoices = values.slice();
@@ -594,7 +593,7 @@ var require_option = __commonJS((exports) => {
594
593
  throw new InvalidArgumentError(`Allowed choices are ${this.argChoices.join(", ")}.`);
595
594
  }
596
595
  if (this.variadic) {
597
- return this._collectValue(arg, previous);
596
+ return this._concatValue(arg, previous);
598
597
  }
599
598
  return arg;
600
599
  };
@@ -612,10 +611,6 @@ var require_option = __commonJS((exports) => {
612
611
  }
613
612
  return camelcase(this.name());
614
613
  }
615
- helpGroup(heading) {
616
- this.helpGroupHeading = heading;
617
- return this;
618
- }
619
614
  is(arg) {
620
615
  return this.short === arg || this.long === arg;
621
616
  }
@@ -833,9 +828,6 @@ var require_command = __commonJS((exports) => {
833
828
  this._addImplicitHelpCommand = undefined;
834
829
  this._helpCommand = undefined;
835
830
  this._helpConfiguration = {};
836
- this._helpGroupHeading = undefined;
837
- this._defaultCommandGroup = undefined;
838
- this._defaultOptionGroup = undefined;
839
831
  }
840
832
  copyInheritedSettings(sourceCommand) {
841
833
  this._outputConfiguration = sourceCommand._outputConfiguration;
@@ -900,10 +892,7 @@ var require_command = __commonJS((exports) => {
900
892
  configureOutput(configuration) {
901
893
  if (configuration === undefined)
902
894
  return this._outputConfiguration;
903
- this._outputConfiguration = {
904
- ...this._outputConfiguration,
905
- ...configuration
906
- };
895
+ Object.assign(this._outputConfiguration, configuration);
907
896
  return this;
908
897
  }
909
898
  showHelpAfterError(displayHelp = true) {
@@ -934,12 +923,12 @@ var require_command = __commonJS((exports) => {
934
923
  createArgument(name, description) {
935
924
  return new Argument(name, description);
936
925
  }
937
- argument(name, description, parseArg, defaultValue) {
926
+ argument(name, description, fn, defaultValue) {
938
927
  const argument = this.createArgument(name, description);
939
- if (typeof parseArg === "function") {
940
- argument.default(defaultValue).argParser(parseArg);
928
+ if (typeof fn === "function") {
929
+ argument.default(defaultValue).argParser(fn);
941
930
  } else {
942
- argument.default(parseArg);
931
+ argument.default(fn);
943
932
  }
944
933
  this.addArgument(argument);
945
934
  return this;
@@ -952,7 +941,7 @@ var require_command = __commonJS((exports) => {
952
941
  }
953
942
  addArgument(argument) {
954
943
  const previousArgument = this.registeredArguments.slice(-1)[0];
955
- if (previousArgument?.variadic) {
944
+ if (previousArgument && previousArgument.variadic) {
956
945
  throw new Error(`only the last argument can be variadic '${previousArgument.name()}'`);
957
946
  }
958
947
  if (argument.required && argument.defaultValue !== undefined && argument.parseArg === undefined) {
@@ -964,13 +953,10 @@ var require_command = __commonJS((exports) => {
964
953
  helpCommand(enableOrNameAndArgs, description) {
965
954
  if (typeof enableOrNameAndArgs === "boolean") {
966
955
  this._addImplicitHelpCommand = enableOrNameAndArgs;
967
- if (enableOrNameAndArgs && this._defaultCommandGroup) {
968
- this._initCommandGroup(this._getHelpCommand());
969
- }
970
956
  return this;
971
957
  }
972
- const nameAndArgs = enableOrNameAndArgs ?? "help [command]";
973
- const [, helpName, helpArgs] = nameAndArgs.match(/([^ ]+) *(.*)/);
958
+ enableOrNameAndArgs = enableOrNameAndArgs ?? "help [command]";
959
+ const [, helpName, helpArgs] = enableOrNameAndArgs.match(/([^ ]+) *(.*)/);
974
960
  const helpDescription = description ?? "display help for command";
975
961
  const helpCommand = this.createCommand(helpName);
976
962
  helpCommand.helpOption(false);
@@ -980,8 +966,6 @@ var require_command = __commonJS((exports) => {
980
966
  helpCommand.description(helpDescription);
981
967
  this._addImplicitHelpCommand = true;
982
968
  this._helpCommand = helpCommand;
983
- if (enableOrNameAndArgs || description)
984
- this._initCommandGroup(helpCommand);
985
969
  return this;
986
970
  }
987
971
  addHelpCommand(helpCommand, deprecatedDescription) {
@@ -991,7 +975,6 @@ var require_command = __commonJS((exports) => {
991
975
  }
992
976
  this._addImplicitHelpCommand = true;
993
977
  this._helpCommand = helpCommand;
994
- this._initCommandGroup(helpCommand);
995
978
  return this;
996
979
  }
997
980
  _getHelpCommand() {
@@ -1071,7 +1054,6 @@ Expecting one of '${allowedValues.join("', '")}'`);
1071
1054
  throw new Error(`Cannot add option '${option.flags}'${this._name && ` to command '${this._name}'`} due to conflicting flag '${matchingFlag}'
1072
1055
  - already used by option '${matchingOption.flags}'`);
1073
1056
  }
1074
- this._initOptionGroup(option);
1075
1057
  this.options.push(option);
1076
1058
  }
1077
1059
  _registerCommand(command) {
@@ -1084,7 +1066,6 @@ Expecting one of '${allowedValues.join("', '")}'`);
1084
1066
  const newCmd = knownBy(command).join("|");
1085
1067
  throw new Error(`cannot add command '${newCmd}' as already have command '${existingCmd}'`);
1086
1068
  }
1087
- this._initCommandGroup(command);
1088
1069
  this.commands.push(command);
1089
1070
  }
1090
1071
  addOption(option) {
@@ -1107,7 +1088,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
1107
1088
  if (val !== null && option.parseArg) {
1108
1089
  val = this._callParseArg(option, val, oldValue, invalidValueMessage);
1109
1090
  } else if (val !== null && option.variadic) {
1110
- val = option._collectValue(val, oldValue);
1091
+ val = option._concatValue(val, oldValue);
1111
1092
  }
1112
1093
  if (val == null) {
1113
1094
  if (option.negate) {
@@ -1482,7 +1463,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
1482
1463
  this.processedArgs = processedArgs;
1483
1464
  }
1484
1465
  _chainOrCall(promise, fn) {
1485
- if (promise?.then && typeof promise.then === "function") {
1466
+ if (promise && promise.then && typeof promise.then === "function") {
1486
1467
  return promise.then(() => fn());
1487
1468
  }
1488
1469
  return fn();
@@ -1559,7 +1540,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
1559
1540
  promiseChain = this._chainOrCallHooks(promiseChain, "postAction");
1560
1541
  return promiseChain;
1561
1542
  }
1562
- if (this.parent?.listenerCount(commandEvent)) {
1543
+ if (this.parent && this.parent.listenerCount(commandEvent)) {
1563
1544
  checkForUnknownOptions();
1564
1545
  this._processArguments();
1565
1546
  this.parent.emit(commandEvent, operands, unknown);
@@ -1621,31 +1602,24 @@ Expecting one of '${allowedValues.join("', '")}'`);
1621
1602
  cmd._checkForConflictingLocalOptions();
1622
1603
  });
1623
1604
  }
1624
- parseOptions(args) {
1605
+ parseOptions(argv) {
1625
1606
  const operands = [];
1626
1607
  const unknown = [];
1627
1608
  let dest = operands;
1609
+ const args = argv.slice();
1628
1610
  function maybeOption(arg) {
1629
1611
  return arg.length > 1 && arg[0] === "-";
1630
1612
  }
1631
- const negativeNumberArg = (arg) => {
1632
- if (!/^-(\d+|\d*\.\d+)(e[+-]?\d+)?$/.test(arg))
1633
- return false;
1634
- return !this._getCommandAndAncestors().some((cmd) => cmd.options.map((opt) => opt.short).some((short) => /^-\d$/.test(short)));
1635
- };
1636
1613
  let activeVariadicOption = null;
1637
- let activeGroup = null;
1638
- let i = 0;
1639
- while (i < args.length || activeGroup) {
1640
- const arg = activeGroup ?? args[i++];
1641
- activeGroup = null;
1614
+ while (args.length) {
1615
+ const arg = args.shift();
1642
1616
  if (arg === "--") {
1643
1617
  if (dest === unknown)
1644
1618
  dest.push(arg);
1645
- dest.push(...args.slice(i));
1619
+ dest.push(...args);
1646
1620
  break;
1647
1621
  }
1648
- if (activeVariadicOption && (!maybeOption(arg) || negativeNumberArg(arg))) {
1622
+ if (activeVariadicOption && !maybeOption(arg)) {
1649
1623
  this.emit(`option:${activeVariadicOption.name()}`, arg);
1650
1624
  continue;
1651
1625
  }
@@ -1654,14 +1628,14 @@ Expecting one of '${allowedValues.join("', '")}'`);
1654
1628
  const option = this._findOption(arg);
1655
1629
  if (option) {
1656
1630
  if (option.required) {
1657
- const value = args[i++];
1631
+ const value = args.shift();
1658
1632
  if (value === undefined)
1659
1633
  this.optionMissingArgument(option);
1660
1634
  this.emit(`option:${option.name()}`, value);
1661
1635
  } else if (option.optional) {
1662
1636
  let value = null;
1663
- if (i < args.length && (!maybeOption(args[i]) || negativeNumberArg(args[i]))) {
1664
- value = args[i++];
1637
+ if (args.length > 0 && !maybeOption(args[0])) {
1638
+ value = args.shift();
1665
1639
  }
1666
1640
  this.emit(`option:${option.name()}`, value);
1667
1641
  } else {
@@ -1678,7 +1652,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
1678
1652
  this.emit(`option:${option.name()}`, arg.slice(2));
1679
1653
  } else {
1680
1654
  this.emit(`option:${option.name()}`);
1681
- activeGroup = `-${arg.slice(2)}`;
1655
+ args.unshift(`-${arg.slice(2)}`);
1682
1656
  }
1683
1657
  continue;
1684
1658
  }
@@ -1691,24 +1665,31 @@ Expecting one of '${allowedValues.join("', '")}'`);
1691
1665
  continue;
1692
1666
  }
1693
1667
  }
1694
- if (dest === operands && maybeOption(arg) && !(this.commands.length === 0 && negativeNumberArg(arg))) {
1668
+ if (maybeOption(arg)) {
1695
1669
  dest = unknown;
1696
1670
  }
1697
1671
  if ((this._enablePositionalOptions || this._passThroughOptions) && operands.length === 0 && unknown.length === 0) {
1698
1672
  if (this._findCommand(arg)) {
1699
1673
  operands.push(arg);
1700
- unknown.push(...args.slice(i));
1674
+ if (args.length > 0)
1675
+ unknown.push(...args);
1701
1676
  break;
1702
1677
  } else if (this._getHelpCommand() && arg === this._getHelpCommand().name()) {
1703
- operands.push(arg, ...args.slice(i));
1678
+ operands.push(arg);
1679
+ if (args.length > 0)
1680
+ operands.push(...args);
1704
1681
  break;
1705
1682
  } else if (this._defaultCommandName) {
1706
- unknown.push(arg, ...args.slice(i));
1683
+ unknown.push(arg);
1684
+ if (args.length > 0)
1685
+ unknown.push(...args);
1707
1686
  break;
1708
1687
  }
1709
1688
  }
1710
1689
  if (this._passThroughOptions) {
1711
- dest.push(arg, ...args.slice(i));
1690
+ dest.push(arg);
1691
+ if (args.length > 0)
1692
+ dest.push(...args);
1712
1693
  break;
1713
1694
  }
1714
1695
  dest.push(arg);
@@ -1919,32 +1900,6 @@ Expecting one of '${allowedValues.join("', '")}'`);
1919
1900
  this._name = str;
1920
1901
  return this;
1921
1902
  }
1922
- helpGroup(heading) {
1923
- if (heading === undefined)
1924
- return this._helpGroupHeading ?? "";
1925
- this._helpGroupHeading = heading;
1926
- return this;
1927
- }
1928
- commandsGroup(heading) {
1929
- if (heading === undefined)
1930
- return this._defaultCommandGroup ?? "";
1931
- this._defaultCommandGroup = heading;
1932
- return this;
1933
- }
1934
- optionsGroup(heading) {
1935
- if (heading === undefined)
1936
- return this._defaultOptionGroup ?? "";
1937
- this._defaultOptionGroup = heading;
1938
- return this;
1939
- }
1940
- _initOptionGroup(option) {
1941
- if (this._defaultOptionGroup && !option.helpGroupHeading)
1942
- option.helpGroup(this._defaultOptionGroup);
1943
- }
1944
- _initCommandGroup(cmd) {
1945
- if (this._defaultCommandGroup && !cmd.helpGroup())
1946
- cmd.helpGroup(this._defaultCommandGroup);
1947
- }
1948
1903
  nameFromFilename(filename) {
1949
1904
  this._name = path.basename(filename, path.extname(filename));
1950
1905
  return this;
@@ -2021,19 +1976,15 @@ Expecting one of '${allowedValues.join("', '")}'`);
2021
1976
  helpOption(flags, description) {
2022
1977
  if (typeof flags === "boolean") {
2023
1978
  if (flags) {
2024
- if (this._helpOption === null)
2025
- this._helpOption = undefined;
2026
- if (this._defaultOptionGroup) {
2027
- this._initOptionGroup(this._getHelpOption());
2028
- }
1979
+ this._helpOption = this._helpOption ?? undefined;
2029
1980
  } else {
2030
1981
  this._helpOption = null;
2031
1982
  }
2032
1983
  return this;
2033
1984
  }
2034
- this._helpOption = this.createOption(flags ?? "-h, --help", description ?? "display help for command");
2035
- if (flags || description)
2036
- this._initOptionGroup(this._helpOption);
1985
+ flags = flags ?? "-h, --help";
1986
+ description = description ?? "display help for command";
1987
+ this._helpOption = this.createOption(flags, description);
2037
1988
  return this;
2038
1989
  }
2039
1990
  _getHelpOption() {
@@ -2044,7 +1995,6 @@ Expecting one of '${allowedValues.join("', '")}'`);
2044
1995
  }
2045
1996
  addHelpOption(option) {
2046
1997
  this._helpOption = option;
2047
- this._initOptionGroup(option);
2048
1998
  return this;
2049
1999
  }
2050
2000
  help(contextOptions) {
@@ -2145,6 +2095,166 @@ var require_commander = __commonJS((exports) => {
2145
2095
  exports.InvalidOptionArgumentError = InvalidArgumentError;
2146
2096
  });
2147
2097
 
2098
+ // node_modules/cli-width/index.js
2099
+ var require_cli_width = __commonJS((exports, module) => {
2100
+ module.exports = cliWidth;
2101
+ function normalizeOpts(options) {
2102
+ const defaultOpts = {
2103
+ defaultWidth: 0,
2104
+ output: process.stdout,
2105
+ tty: __require("tty")
2106
+ };
2107
+ if (!options) {
2108
+ return defaultOpts;
2109
+ }
2110
+ Object.keys(defaultOpts).forEach(function(key) {
2111
+ if (!options[key]) {
2112
+ options[key] = defaultOpts[key];
2113
+ }
2114
+ });
2115
+ return options;
2116
+ }
2117
+ function cliWidth(options) {
2118
+ const opts = normalizeOpts(options);
2119
+ if (opts.output.getWindowSize) {
2120
+ return opts.output.getWindowSize()[0] || opts.defaultWidth;
2121
+ }
2122
+ if (opts.tty.getWindowSize) {
2123
+ return opts.tty.getWindowSize()[1] || opts.defaultWidth;
2124
+ }
2125
+ if (opts.output.columns) {
2126
+ return opts.output.columns;
2127
+ }
2128
+ if (process.env.CLI_WIDTH) {
2129
+ const width = parseInt(process.env.CLI_WIDTH, 10);
2130
+ if (!isNaN(width) && width !== 0) {
2131
+ return width;
2132
+ }
2133
+ }
2134
+ return opts.defaultWidth;
2135
+ }
2136
+ });
2137
+
2138
+ // node_modules/mute-stream/lib/index.js
2139
+ var require_lib = __commonJS((exports, module) => {
2140
+ var Stream = __require("stream");
2141
+
2142
+ class MuteStream extends Stream {
2143
+ #isTTY = null;
2144
+ constructor(opts = {}) {
2145
+ super(opts);
2146
+ this.writable = this.readable = true;
2147
+ this.muted = false;
2148
+ this.on("pipe", this._onpipe);
2149
+ this.replace = opts.replace;
2150
+ this._prompt = opts.prompt || null;
2151
+ this._hadControl = false;
2152
+ }
2153
+ #destSrc(key, def) {
2154
+ if (this._dest) {
2155
+ return this._dest[key];
2156
+ }
2157
+ if (this._src) {
2158
+ return this._src[key];
2159
+ }
2160
+ return def;
2161
+ }
2162
+ #proxy(method, ...args) {
2163
+ if (typeof this._dest?.[method] === "function") {
2164
+ this._dest[method](...args);
2165
+ }
2166
+ if (typeof this._src?.[method] === "function") {
2167
+ this._src[method](...args);
2168
+ }
2169
+ }
2170
+ get isTTY() {
2171
+ if (this.#isTTY !== null) {
2172
+ return this.#isTTY;
2173
+ }
2174
+ return this.#destSrc("isTTY", false);
2175
+ }
2176
+ set isTTY(val) {
2177
+ this.#isTTY = val;
2178
+ }
2179
+ get rows() {
2180
+ return this.#destSrc("rows");
2181
+ }
2182
+ get columns() {
2183
+ return this.#destSrc("columns");
2184
+ }
2185
+ mute() {
2186
+ this.muted = true;
2187
+ }
2188
+ unmute() {
2189
+ this.muted = false;
2190
+ }
2191
+ _onpipe(src) {
2192
+ this._src = src;
2193
+ }
2194
+ pipe(dest, options) {
2195
+ this._dest = dest;
2196
+ return super.pipe(dest, options);
2197
+ }
2198
+ pause() {
2199
+ if (this._src) {
2200
+ return this._src.pause();
2201
+ }
2202
+ }
2203
+ resume() {
2204
+ if (this._src) {
2205
+ return this._src.resume();
2206
+ }
2207
+ }
2208
+ write(c) {
2209
+ if (this.muted) {
2210
+ if (!this.replace) {
2211
+ return true;
2212
+ }
2213
+ if (c.match(/^\u001b/)) {
2214
+ if (c.indexOf(this._prompt) === 0) {
2215
+ c = c.slice(this._prompt.length);
2216
+ c = c.replace(/./g, this.replace);
2217
+ c = this._prompt + c;
2218
+ }
2219
+ this._hadControl = true;
2220
+ return this.emit("data", c);
2221
+ } else {
2222
+ if (this._prompt && this._hadControl && c.indexOf(this._prompt) === 0) {
2223
+ this._hadControl = false;
2224
+ this.emit("data", this._prompt);
2225
+ c = c.slice(this._prompt.length);
2226
+ }
2227
+ c = c.toString().replace(/./g, this.replace);
2228
+ }
2229
+ }
2230
+ this.emit("data", c);
2231
+ }
2232
+ end(c) {
2233
+ if (this.muted) {
2234
+ if (c && this.replace) {
2235
+ c = c.toString().replace(/./g, this.replace);
2236
+ } else {
2237
+ c = null;
2238
+ }
2239
+ }
2240
+ if (c) {
2241
+ this.emit("data", c);
2242
+ }
2243
+ this.emit("end");
2244
+ }
2245
+ destroy(...args) {
2246
+ return this.#proxy("destroy", ...args);
2247
+ }
2248
+ destroySoon(...args) {
2249
+ return this.#proxy("destroySoon", ...args);
2250
+ }
2251
+ close(...args) {
2252
+ return this.#proxy("close", ...args);
2253
+ }
2254
+ }
2255
+ module.exports = MuteStream;
2256
+ });
2257
+
2148
2258
  // src/sync/reconciler.ts
2149
2259
  var exports_reconciler = {};
2150
2260
  __export(exports_reconciler, {
@@ -2438,6 +2548,142 @@ function buildGraph(engine) {
2438
2548
  } catch {}
2439
2549
  return { nodes, edges };
2440
2550
  }
2551
+ function buildTimeline(engine) {
2552
+ const ops = engine.getOps();
2553
+ const branches = engine.listBranches();
2554
+ const milestones = engine.listMilestones();
2555
+ const checkpoints = engine.listCheckpoints();
2556
+ const opSummaries = ops.map((op, index) => ({
2557
+ index,
2558
+ hash: op.hash?.slice(0, 24) ?? "",
2559
+ kind: op.kind,
2560
+ timestamp: op.timestamp,
2561
+ agentId: op.agentId,
2562
+ filePath: op.vcs?.filePath,
2563
+ branchName: op.vcs?.branchName,
2564
+ message: op.vcs?.message
2565
+ }));
2566
+ const milestoneMarkers = milestones.map((m) => {
2567
+ const toIdx = ops.findIndex((o) => o.hash === m.toOpHash);
2568
+ return {
2569
+ id: m.id,
2570
+ message: m.message,
2571
+ createdAt: m.createdAt,
2572
+ atOpIndex: toIdx >= 0 ? toIdx : ops.length - 1,
2573
+ affectedFiles: m.affectedFiles?.length ?? 0
2574
+ };
2575
+ });
2576
+ const checkpointMarkers = checkpoints.map((c) => {
2577
+ const atIdx = ops.findIndex((o) => o.hash === c.atOpHash);
2578
+ return {
2579
+ id: c.id,
2580
+ trigger: c.trigger,
2581
+ createdAt: c.createdAt,
2582
+ atOpIndex: atIdx >= 0 ? atIdx : ops.length - 1
2583
+ };
2584
+ });
2585
+ return {
2586
+ ops: opSummaries,
2587
+ branches: branches.map((b) => ({
2588
+ name: b.name,
2589
+ isCurrent: b.isCurrent,
2590
+ createdAt: b.createdAt
2591
+ })),
2592
+ milestones: milestoneMarkers,
2593
+ checkpoints: checkpointMarkers,
2594
+ totalOps: ops.length
2595
+ };
2596
+ }
2597
+ function buildStoreOverview(engine) {
2598
+ const store = engine.getStore();
2599
+ const stats = store.getStats();
2600
+ const catalog = store.getCatalog();
2601
+ const typeFacts = store.getFactsByAttribute("type");
2602
+ const entityTypes = {};
2603
+ const entityList = [];
2604
+ for (const fact of typeFacts) {
2605
+ const typeName = String(fact.v);
2606
+ entityTypes[typeName] = (entityTypes[typeName] ?? 0) + 1;
2607
+ const entityFacts = store.getFactsByEntity(fact.e);
2608
+ entityList.push({
2609
+ id: fact.e,
2610
+ type: typeName,
2611
+ factCount: entityFacts.length
2612
+ });
2613
+ }
2614
+ return {
2615
+ stats: {
2616
+ totalFacts: stats.totalFacts,
2617
+ totalLinks: stats.totalLinks,
2618
+ uniqueEntities: stats.uniqueEntities,
2619
+ uniqueAttributes: stats.uniqueAttributes
2620
+ },
2621
+ catalog: catalog.map((c) => ({
2622
+ attribute: c.attribute,
2623
+ type: c.type,
2624
+ cardinality: c.cardinality,
2625
+ distinctCount: c.distinctCount,
2626
+ examples: c.examples.slice(0, 3)
2627
+ })),
2628
+ entityTypes,
2629
+ entities: entityList.slice(0, 500)
2630
+ };
2631
+ }
2632
+ function buildEntityDetail(engine, entityId) {
2633
+ const store = engine.getStore();
2634
+ const facts = store.getFactsByEntity(entityId);
2635
+ if (facts.length === 0)
2636
+ return null;
2637
+ const typeFact = facts.find((f) => f.a === "type");
2638
+ const links = store.getLinksByEntity(entityId);
2639
+ return {
2640
+ id: entityId,
2641
+ type: typeFact?.v ?? "unknown",
2642
+ facts: facts.map((f) => ({ a: f.a, v: f.v })),
2643
+ links: links.map((l) => ({
2644
+ a: l.a,
2645
+ source: l.e1,
2646
+ target: l.e2,
2647
+ direction: l.e1 === entityId ? "outgoing" : "incoming"
2648
+ }))
2649
+ };
2650
+ }
2651
+ function buildSystemInfo(engine) {
2652
+ const status = engine.status();
2653
+ const store = engine.getStore();
2654
+ const stats = store.getStats();
2655
+ const embeddingsAvailable = existsSync5(join5(engine.getRootPath(), ".trellis", "embeddings.db"));
2656
+ const blobStoreAvailable = engine.getBlobStore() !== null;
2657
+ return {
2658
+ engine: {
2659
+ rootPath: engine.getRootPath(),
2660
+ branch: status.branch,
2661
+ totalOps: status.totalOps,
2662
+ trackedFiles: status.trackedFiles,
2663
+ lastOpAt: status.lastOp?.timestamp ?? null
2664
+ },
2665
+ store: {
2666
+ totalFacts: stats.totalFacts,
2667
+ totalLinks: stats.totalLinks,
2668
+ uniqueEntities: stats.uniqueEntities,
2669
+ uniqueAttributes: stats.uniqueAttributes
2670
+ },
2671
+ features: {
2672
+ embeddings: embeddingsAvailable,
2673
+ blobStore: blobStoreAvailable
2674
+ },
2675
+ parsers: [
2676
+ "typescript",
2677
+ "javascript",
2678
+ "python",
2679
+ "go",
2680
+ "rust",
2681
+ "ruby",
2682
+ "java",
2683
+ "csharp"
2684
+ ]
2685
+ };
2686
+ }
2441
2687
  function getNodeDetail(engine, nodeId) {
2442
2688
  const [type, ...rest] = nodeId.split(":");
2443
2689
  const id = rest.join(":");
@@ -2486,7 +2732,27 @@ function getNodeDetail(engine, nodeId) {
2486
2732
  async function startUIServer(opts) {
2487
2733
  const engine = new TrellisVcsEngine({ rootPath: opts.rootPath });
2488
2734
  engine.open();
2489
- const clientHtml = readFileSync3(join5(dirname4(new URL(import.meta.url).pathname), "client.html"), "utf-8");
2735
+ function findClientHtml() {
2736
+ const here = dirname4(process.argv[1]);
2737
+ const candidates = [
2738
+ join5(here, "client.html"),
2739
+ join5(here, "..", "ui", "client.html"),
2740
+ join5(here, "ui", "client.html")
2741
+ ];
2742
+ let dir = here;
2743
+ for (let i = 0;i < 5; i++) {
2744
+ candidates.push(join5(dir, "dist", "ui", "client.html"));
2745
+ candidates.push(join5(dir, "ui", "client.html"));
2746
+ dir = dirname4(dir);
2747
+ }
2748
+ for (const p of candidates) {
2749
+ if (existsSync5(p))
2750
+ return p;
2751
+ }
2752
+ throw new Error(`Could not find client.html. Searched from: ${here}
2753
+ Try reinstalling the package or running \`bun run build\`.`);
2754
+ }
2755
+ const clientHtml = readFileSync3(findClientHtml(), "utf-8");
2490
2756
  let embeddingManager = null;
2491
2757
  function getEmbeddingManager() {
2492
2758
  if (!embeddingManager) {
@@ -2518,6 +2784,26 @@ async function startUIServer(opts) {
2518
2784
  const graph = buildGraph(engine);
2519
2785
  return Response.json(graph, { headers });
2520
2786
  }
2787
+ if (path === "/api/timeline") {
2788
+ const timeline = buildTimeline(engine);
2789
+ return Response.json(timeline, { headers });
2790
+ }
2791
+ if (path === "/api/store") {
2792
+ const overview = buildStoreOverview(engine);
2793
+ return Response.json(overview, { headers });
2794
+ }
2795
+ if (path.startsWith("/api/store/entity/")) {
2796
+ const entityId = decodeURIComponent(path.slice("/api/store/entity/".length));
2797
+ const detail = buildEntityDetail(engine, entityId);
2798
+ if (!detail) {
2799
+ return Response.json({ error: "Entity not found" }, { status: 404, headers });
2800
+ }
2801
+ return Response.json(detail, { headers });
2802
+ }
2803
+ if (path === "/api/system") {
2804
+ const info = buildSystemInfo(engine);
2805
+ return Response.json(info, { headers });
2806
+ }
2521
2807
  if (path === "/api/search") {
2522
2808
  const query = url.searchParams.get("q");
2523
2809
  if (!query) {
@@ -2600,7 +2886,7 @@ var {
2600
2886
  Help
2601
2887
  } = import__.default;
2602
2888
 
2603
- // node_modules/chalk/source/vendor/ansi-styles/index.js
2889
+ // ../trellis-client/node_modules/.pnpm/chalk@5.6.2/node_modules/chalk/source/vendor/ansi-styles/index.js
2604
2890
  var ANSI_BACKGROUND_OFFSET = 10;
2605
2891
  var wrapAnsi16 = (offset = 0) => (code) => `\x1B[${code + offset}m`;
2606
2892
  var wrapAnsi256 = (offset = 0) => (code) => `\x1B[${38 + offset};5;${code}m`;
@@ -2777,7 +3063,7 @@ function assembleStyles() {
2777
3063
  var ansiStyles = assembleStyles();
2778
3064
  var ansi_styles_default = ansiStyles;
2779
3065
 
2780
- // node_modules/chalk/source/vendor/supports-color/index.js
3066
+ // ../trellis-client/node_modules/.pnpm/chalk@5.6.2/node_modules/chalk/source/vendor/supports-color/index.js
2781
3067
  import process2 from "process";
2782
3068
  import os from "os";
2783
3069
  import tty from "tty";
@@ -2909,7 +3195,7 @@ var supportsColor = {
2909
3195
  };
2910
3196
  var supports_color_default = supportsColor;
2911
3197
 
2912
- // node_modules/chalk/source/utilities.js
3198
+ // ../trellis-client/node_modules/.pnpm/chalk@5.6.2/node_modules/chalk/source/utilities.js
2913
3199
  function stringReplaceAll(string, substring, replacer) {
2914
3200
  let index = string.indexOf(substring);
2915
3201
  if (index === -1) {
@@ -2942,7 +3228,7 @@ function stringEncaseCRLFWithFirstIndex(string, prefix, postfix, index) {
2942
3228
  return returnValue;
2943
3229
  }
2944
3230
 
2945
- // node_modules/chalk/source/index.js
3231
+ // ../trellis-client/node_modules/.pnpm/chalk@5.6.2/node_modules/chalk/source/index.js
2946
3232
  var { stdout: stdoutColor, stderr: stderrColor } = supports_color_default;
2947
3233
  var GENERATOR = Symbol("GENERATOR");
2948
3234
  var STYLER = Symbol("STYLER");
@@ -3077,21 +3363,1799 @@ var applyStyle = (self, string) => {
3077
3363
  styler = styler.parent;
3078
3364
  }
3079
3365
  }
3080
- const lfIndex = string.indexOf(`
3081
- `);
3082
- if (lfIndex !== -1) {
3083
- string = stringEncaseCRLFWithFirstIndex(string, closeAll, openAll, lfIndex);
3366
+ const lfIndex = string.indexOf(`
3367
+ `);
3368
+ if (lfIndex !== -1) {
3369
+ string = stringEncaseCRLFWithFirstIndex(string, closeAll, openAll, lfIndex);
3370
+ }
3371
+ return openAll + string + closeAll;
3372
+ };
3373
+ Object.defineProperties(createChalk.prototype, styles2);
3374
+ var chalk = createChalk();
3375
+ var chalkStderr = createChalk({ level: stderrColor ? stderrColor.level : 0 });
3376
+ var source_default = chalk;
3377
+
3378
+ // src/cli/index.ts
3379
+ import { resolve, join as join6 } from "path";
3380
+
3381
+ // node_modules/@inquirer/core/dist/lib/key.js
3382
+ var isUpKey = (key, keybindings = []) => key.name === "up" || keybindings.includes("vim") && key.name === "k" || keybindings.includes("emacs") && key.ctrl && key.name === "p";
3383
+ var isDownKey = (key, keybindings = []) => key.name === "down" || keybindings.includes("vim") && key.name === "j" || keybindings.includes("emacs") && key.ctrl && key.name === "n";
3384
+ var isSpaceKey = (key) => key.name === "space";
3385
+ var isBackspaceKey = (key) => key.name === "backspace";
3386
+ var isNumberKey = (key) => "1234567890".includes(key.name);
3387
+ var isEnterKey = (key) => key.name === "enter" || key.name === "return";
3388
+ // node_modules/@inquirer/core/dist/lib/errors.js
3389
+ class AbortPromptError extends Error {
3390
+ name = "AbortPromptError";
3391
+ message = "Prompt was aborted";
3392
+ constructor(options) {
3393
+ super();
3394
+ this.cause = options?.cause;
3395
+ }
3396
+ }
3397
+
3398
+ class CancelPromptError extends Error {
3399
+ name = "CancelPromptError";
3400
+ message = "Prompt was canceled";
3401
+ }
3402
+
3403
+ class ExitPromptError extends Error {
3404
+ name = "ExitPromptError";
3405
+ }
3406
+
3407
+ class HookError extends Error {
3408
+ name = "HookError";
3409
+ }
3410
+
3411
+ class ValidationError extends Error {
3412
+ name = "ValidationError";
3413
+ }
3414
+ // node_modules/@inquirer/core/dist/lib/use-state.js
3415
+ import { AsyncResource as AsyncResource2 } from "async_hooks";
3416
+
3417
+ // node_modules/@inquirer/core/dist/lib/hook-engine.js
3418
+ import { AsyncLocalStorage, AsyncResource } from "async_hooks";
3419
+ var hookStorage = new AsyncLocalStorage;
3420
+ function createStore(rl) {
3421
+ const store = {
3422
+ rl,
3423
+ hooks: [],
3424
+ hooksCleanup: [],
3425
+ hooksEffect: [],
3426
+ index: 0,
3427
+ handleChange() {}
3428
+ };
3429
+ return store;
3430
+ }
3431
+ function withHooks(rl, cb) {
3432
+ const store = createStore(rl);
3433
+ return hookStorage.run(store, () => {
3434
+ function cycle(render) {
3435
+ store.handleChange = () => {
3436
+ store.index = 0;
3437
+ render();
3438
+ };
3439
+ store.handleChange();
3440
+ }
3441
+ return cb(cycle);
3442
+ });
3443
+ }
3444
+ function getStore() {
3445
+ const store = hookStorage.getStore();
3446
+ if (!store) {
3447
+ throw new HookError("[Inquirer] Hook functions can only be called from within a prompt");
3448
+ }
3449
+ return store;
3450
+ }
3451
+ function readline() {
3452
+ return getStore().rl;
3453
+ }
3454
+ function withUpdates(fn) {
3455
+ const wrapped = (...args) => {
3456
+ const store = getStore();
3457
+ let shouldUpdate = false;
3458
+ const oldHandleChange = store.handleChange;
3459
+ store.handleChange = () => {
3460
+ shouldUpdate = true;
3461
+ };
3462
+ const returnValue = fn(...args);
3463
+ if (shouldUpdate) {
3464
+ oldHandleChange();
3465
+ }
3466
+ store.handleChange = oldHandleChange;
3467
+ return returnValue;
3468
+ };
3469
+ return AsyncResource.bind(wrapped);
3470
+ }
3471
+ function withPointer(cb) {
3472
+ const store = getStore();
3473
+ const { index } = store;
3474
+ const pointer = {
3475
+ get() {
3476
+ return store.hooks[index];
3477
+ },
3478
+ set(value) {
3479
+ store.hooks[index] = value;
3480
+ },
3481
+ initialized: index in store.hooks
3482
+ };
3483
+ const returnValue = cb(pointer);
3484
+ store.index++;
3485
+ return returnValue;
3486
+ }
3487
+ function handleChange() {
3488
+ getStore().handleChange();
3489
+ }
3490
+ var effectScheduler = {
3491
+ queue(cb) {
3492
+ const store = getStore();
3493
+ const { index } = store;
3494
+ store.hooksEffect.push(() => {
3495
+ store.hooksCleanup[index]?.();
3496
+ const cleanFn = cb(readline());
3497
+ if (cleanFn != null && typeof cleanFn !== "function") {
3498
+ throw new ValidationError("useEffect return value must be a cleanup function or nothing.");
3499
+ }
3500
+ store.hooksCleanup[index] = cleanFn;
3501
+ });
3502
+ },
3503
+ run() {
3504
+ const store = getStore();
3505
+ withUpdates(() => {
3506
+ store.hooksEffect.forEach((effect) => {
3507
+ effect();
3508
+ });
3509
+ store.hooksEffect.length = 0;
3510
+ })();
3511
+ },
3512
+ clearAll() {
3513
+ const store = getStore();
3514
+ store.hooksCleanup.forEach((cleanFn) => {
3515
+ cleanFn?.();
3516
+ });
3517
+ store.hooksEffect.length = 0;
3518
+ store.hooksCleanup.length = 0;
3519
+ }
3520
+ };
3521
+
3522
+ // node_modules/@inquirer/core/dist/lib/use-state.js
3523
+ function useState(defaultValue) {
3524
+ return withPointer((pointer) => {
3525
+ const setState = AsyncResource2.bind(function setState2(newValue) {
3526
+ if (pointer.get() !== newValue) {
3527
+ pointer.set(newValue);
3528
+ handleChange();
3529
+ }
3530
+ });
3531
+ if (pointer.initialized) {
3532
+ return [pointer.get(), setState];
3533
+ }
3534
+ const value = typeof defaultValue === "function" ? defaultValue() : defaultValue;
3535
+ pointer.set(value);
3536
+ return [value, setState];
3537
+ });
3538
+ }
3539
+
3540
+ // node_modules/@inquirer/core/dist/lib/use-effect.js
3541
+ function useEffect(cb, depArray) {
3542
+ withPointer((pointer) => {
3543
+ const oldDeps = pointer.get();
3544
+ const hasChanged = !Array.isArray(oldDeps) || depArray.some((dep, i) => !Object.is(dep, oldDeps[i]));
3545
+ if (hasChanged) {
3546
+ effectScheduler.queue(cb);
3547
+ }
3548
+ pointer.set(depArray);
3549
+ });
3550
+ }
3551
+
3552
+ // node_modules/@inquirer/core/dist/lib/theme.js
3553
+ import { styleText } from "util";
3554
+
3555
+ // node_modules/@inquirer/figures/dist/index.js
3556
+ import process3 from "process";
3557
+ function isUnicodeSupported() {
3558
+ if (process3.platform !== "win32") {
3559
+ return process3.env["TERM"] !== "linux";
3560
+ }
3561
+ return Boolean(process3.env["WT_SESSION"]) || Boolean(process3.env["TERMINUS_SUBLIME"]) || process3.env["ConEmuTask"] === "{cmd::Cmder}" || process3.env["TERM_PROGRAM"] === "Terminus-Sublime" || process3.env["TERM_PROGRAM"] === "vscode" || process3.env["TERM"] === "xterm-256color" || process3.env["TERM"] === "alacritty" || process3.env["TERMINAL_EMULATOR"] === "JetBrains-JediTerm";
3562
+ }
3563
+ var common = {
3564
+ circleQuestionMark: "(?)",
3565
+ questionMarkPrefix: "(?)",
3566
+ square: "\u2588",
3567
+ squareDarkShade: "\u2593",
3568
+ squareMediumShade: "\u2592",
3569
+ squareLightShade: "\u2591",
3570
+ squareTop: "\u2580",
3571
+ squareBottom: "\u2584",
3572
+ squareLeft: "\u258C",
3573
+ squareRight: "\u2590",
3574
+ squareCenter: "\u25A0",
3575
+ bullet: "\u25CF",
3576
+ dot: "\u2024",
3577
+ ellipsis: "\u2026",
3578
+ pointerSmall: "\u203A",
3579
+ triangleUp: "\u25B2",
3580
+ triangleUpSmall: "\u25B4",
3581
+ triangleDown: "\u25BC",
3582
+ triangleDownSmall: "\u25BE",
3583
+ triangleLeftSmall: "\u25C2",
3584
+ triangleRightSmall: "\u25B8",
3585
+ home: "\u2302",
3586
+ heart: "\u2665",
3587
+ musicNote: "\u266A",
3588
+ musicNoteBeamed: "\u266B",
3589
+ arrowUp: "\u2191",
3590
+ arrowDown: "\u2193",
3591
+ arrowLeft: "\u2190",
3592
+ arrowRight: "\u2192",
3593
+ arrowLeftRight: "\u2194",
3594
+ arrowUpDown: "\u2195",
3595
+ almostEqual: "\u2248",
3596
+ notEqual: "\u2260",
3597
+ lessOrEqual: "\u2264",
3598
+ greaterOrEqual: "\u2265",
3599
+ identical: "\u2261",
3600
+ infinity: "\u221E",
3601
+ subscriptZero: "\u2080",
3602
+ subscriptOne: "\u2081",
3603
+ subscriptTwo: "\u2082",
3604
+ subscriptThree: "\u2083",
3605
+ subscriptFour: "\u2084",
3606
+ subscriptFive: "\u2085",
3607
+ subscriptSix: "\u2086",
3608
+ subscriptSeven: "\u2087",
3609
+ subscriptEight: "\u2088",
3610
+ subscriptNine: "\u2089",
3611
+ oneHalf: "\xBD",
3612
+ oneThird: "\u2153",
3613
+ oneQuarter: "\xBC",
3614
+ oneFifth: "\u2155",
3615
+ oneSixth: "\u2159",
3616
+ oneEighth: "\u215B",
3617
+ twoThirds: "\u2154",
3618
+ twoFifths: "\u2156",
3619
+ threeQuarters: "\xBE",
3620
+ threeFifths: "\u2157",
3621
+ threeEighths: "\u215C",
3622
+ fourFifths: "\u2158",
3623
+ fiveSixths: "\u215A",
3624
+ fiveEighths: "\u215D",
3625
+ sevenEighths: "\u215E",
3626
+ line: "\u2500",
3627
+ lineBold: "\u2501",
3628
+ lineDouble: "\u2550",
3629
+ lineDashed0: "\u2504",
3630
+ lineDashed1: "\u2505",
3631
+ lineDashed2: "\u2508",
3632
+ lineDashed3: "\u2509",
3633
+ lineDashed4: "\u254C",
3634
+ lineDashed5: "\u254D",
3635
+ lineDashed6: "\u2574",
3636
+ lineDashed7: "\u2576",
3637
+ lineDashed8: "\u2578",
3638
+ lineDashed9: "\u257A",
3639
+ lineDashed10: "\u257C",
3640
+ lineDashed11: "\u257E",
3641
+ lineDashed12: "\u2212",
3642
+ lineDashed13: "\u2013",
3643
+ lineDashed14: "\u2010",
3644
+ lineDashed15: "\u2043",
3645
+ lineVertical: "\u2502",
3646
+ lineVerticalBold: "\u2503",
3647
+ lineVerticalDouble: "\u2551",
3648
+ lineVerticalDashed0: "\u2506",
3649
+ lineVerticalDashed1: "\u2507",
3650
+ lineVerticalDashed2: "\u250A",
3651
+ lineVerticalDashed3: "\u250B",
3652
+ lineVerticalDashed4: "\u254E",
3653
+ lineVerticalDashed5: "\u254F",
3654
+ lineVerticalDashed6: "\u2575",
3655
+ lineVerticalDashed7: "\u2577",
3656
+ lineVerticalDashed8: "\u2579",
3657
+ lineVerticalDashed9: "\u257B",
3658
+ lineVerticalDashed10: "\u257D",
3659
+ lineVerticalDashed11: "\u257F",
3660
+ lineDownLeft: "\u2510",
3661
+ lineDownLeftArc: "\u256E",
3662
+ lineDownBoldLeftBold: "\u2513",
3663
+ lineDownBoldLeft: "\u2512",
3664
+ lineDownLeftBold: "\u2511",
3665
+ lineDownDoubleLeftDouble: "\u2557",
3666
+ lineDownDoubleLeft: "\u2556",
3667
+ lineDownLeftDouble: "\u2555",
3668
+ lineDownRight: "\u250C",
3669
+ lineDownRightArc: "\u256D",
3670
+ lineDownBoldRightBold: "\u250F",
3671
+ lineDownBoldRight: "\u250E",
3672
+ lineDownRightBold: "\u250D",
3673
+ lineDownDoubleRightDouble: "\u2554",
3674
+ lineDownDoubleRight: "\u2553",
3675
+ lineDownRightDouble: "\u2552",
3676
+ lineUpLeft: "\u2518",
3677
+ lineUpLeftArc: "\u256F",
3678
+ lineUpBoldLeftBold: "\u251B",
3679
+ lineUpBoldLeft: "\u251A",
3680
+ lineUpLeftBold: "\u2519",
3681
+ lineUpDoubleLeftDouble: "\u255D",
3682
+ lineUpDoubleLeft: "\u255C",
3683
+ lineUpLeftDouble: "\u255B",
3684
+ lineUpRight: "\u2514",
3685
+ lineUpRightArc: "\u2570",
3686
+ lineUpBoldRightBold: "\u2517",
3687
+ lineUpBoldRight: "\u2516",
3688
+ lineUpRightBold: "\u2515",
3689
+ lineUpDoubleRightDouble: "\u255A",
3690
+ lineUpDoubleRight: "\u2559",
3691
+ lineUpRightDouble: "\u2558",
3692
+ lineUpDownLeft: "\u2524",
3693
+ lineUpBoldDownBoldLeftBold: "\u252B",
3694
+ lineUpBoldDownBoldLeft: "\u2528",
3695
+ lineUpDownLeftBold: "\u2525",
3696
+ lineUpBoldDownLeftBold: "\u2529",
3697
+ lineUpDownBoldLeftBold: "\u252A",
3698
+ lineUpDownBoldLeft: "\u2527",
3699
+ lineUpBoldDownLeft: "\u2526",
3700
+ lineUpDoubleDownDoubleLeftDouble: "\u2563",
3701
+ lineUpDoubleDownDoubleLeft: "\u2562",
3702
+ lineUpDownLeftDouble: "\u2561",
3703
+ lineUpDownRight: "\u251C",
3704
+ lineUpBoldDownBoldRightBold: "\u2523",
3705
+ lineUpBoldDownBoldRight: "\u2520",
3706
+ lineUpDownRightBold: "\u251D",
3707
+ lineUpBoldDownRightBold: "\u2521",
3708
+ lineUpDownBoldRightBold: "\u2522",
3709
+ lineUpDownBoldRight: "\u251F",
3710
+ lineUpBoldDownRight: "\u251E",
3711
+ lineUpDoubleDownDoubleRightDouble: "\u2560",
3712
+ lineUpDoubleDownDoubleRight: "\u255F",
3713
+ lineUpDownRightDouble: "\u255E",
3714
+ lineDownLeftRight: "\u252C",
3715
+ lineDownBoldLeftBoldRightBold: "\u2533",
3716
+ lineDownLeftBoldRightBold: "\u252F",
3717
+ lineDownBoldLeftRight: "\u2530",
3718
+ lineDownBoldLeftBoldRight: "\u2531",
3719
+ lineDownBoldLeftRightBold: "\u2532",
3720
+ lineDownLeftRightBold: "\u252E",
3721
+ lineDownLeftBoldRight: "\u252D",
3722
+ lineDownDoubleLeftDoubleRightDouble: "\u2566",
3723
+ lineDownDoubleLeftRight: "\u2565",
3724
+ lineDownLeftDoubleRightDouble: "\u2564",
3725
+ lineUpLeftRight: "\u2534",
3726
+ lineUpBoldLeftBoldRightBold: "\u253B",
3727
+ lineUpLeftBoldRightBold: "\u2537",
3728
+ lineUpBoldLeftRight: "\u2538",
3729
+ lineUpBoldLeftBoldRight: "\u2539",
3730
+ lineUpBoldLeftRightBold: "\u253A",
3731
+ lineUpLeftRightBold: "\u2536",
3732
+ lineUpLeftBoldRight: "\u2535",
3733
+ lineUpDoubleLeftDoubleRightDouble: "\u2569",
3734
+ lineUpDoubleLeftRight: "\u2568",
3735
+ lineUpLeftDoubleRightDouble: "\u2567",
3736
+ lineUpDownLeftRight: "\u253C",
3737
+ lineUpBoldDownBoldLeftBoldRightBold: "\u254B",
3738
+ lineUpDownBoldLeftBoldRightBold: "\u2548",
3739
+ lineUpBoldDownLeftBoldRightBold: "\u2547",
3740
+ lineUpBoldDownBoldLeftRightBold: "\u254A",
3741
+ lineUpBoldDownBoldLeftBoldRight: "\u2549",
3742
+ lineUpBoldDownLeftRight: "\u2540",
3743
+ lineUpDownBoldLeftRight: "\u2541",
3744
+ lineUpDownLeftBoldRight: "\u253D",
3745
+ lineUpDownLeftRightBold: "\u253E",
3746
+ lineUpBoldDownBoldLeftRight: "\u2542",
3747
+ lineUpDownLeftBoldRightBold: "\u253F",
3748
+ lineUpBoldDownLeftBoldRight: "\u2543",
3749
+ lineUpBoldDownLeftRightBold: "\u2544",
3750
+ lineUpDownBoldLeftBoldRight: "\u2545",
3751
+ lineUpDownBoldLeftRightBold: "\u2546",
3752
+ lineUpDoubleDownDoubleLeftDoubleRightDouble: "\u256C",
3753
+ lineUpDoubleDownDoubleLeftRight: "\u256B",
3754
+ lineUpDownLeftDoubleRightDouble: "\u256A",
3755
+ lineCross: "\u2573",
3756
+ lineBackslash: "\u2572",
3757
+ lineSlash: "\u2571"
3758
+ };
3759
+ var specialMainSymbols = {
3760
+ tick: "\u2714",
3761
+ info: "\u2139",
3762
+ warning: "\u26A0",
3763
+ cross: "\u2718",
3764
+ squareSmall: "\u25FB",
3765
+ squareSmallFilled: "\u25FC",
3766
+ circle: "\u25EF",
3767
+ circleFilled: "\u25C9",
3768
+ circleDotted: "\u25CC",
3769
+ circleDouble: "\u25CE",
3770
+ circleCircle: "\u24DE",
3771
+ circleCross: "\u24E7",
3772
+ circlePipe: "\u24BE",
3773
+ radioOn: "\u25C9",
3774
+ radioOff: "\u25EF",
3775
+ checkboxOn: "\u2612",
3776
+ checkboxOff: "\u2610",
3777
+ checkboxCircleOn: "\u24E7",
3778
+ checkboxCircleOff: "\u24BE",
3779
+ pointer: "\u276F",
3780
+ triangleUpOutline: "\u25B3",
3781
+ triangleLeft: "\u25C0",
3782
+ triangleRight: "\u25B6",
3783
+ lozenge: "\u25C6",
3784
+ lozengeOutline: "\u25C7",
3785
+ hamburger: "\u2630",
3786
+ smiley: "\u32E1",
3787
+ mustache: "\u0DF4",
3788
+ star: "\u2605",
3789
+ play: "\u25B6",
3790
+ nodejs: "\u2B22",
3791
+ oneSeventh: "\u2150",
3792
+ oneNinth: "\u2151",
3793
+ oneTenth: "\u2152"
3794
+ };
3795
+ var specialFallbackSymbols = {
3796
+ tick: "\u221A",
3797
+ info: "i",
3798
+ warning: "\u203C",
3799
+ cross: "\xD7",
3800
+ squareSmall: "\u25A1",
3801
+ squareSmallFilled: "\u25A0",
3802
+ circle: "( )",
3803
+ circleFilled: "(*)",
3804
+ circleDotted: "( )",
3805
+ circleDouble: "( )",
3806
+ circleCircle: "(\u25CB)",
3807
+ circleCross: "(\xD7)",
3808
+ circlePipe: "(\u2502)",
3809
+ radioOn: "(*)",
3810
+ radioOff: "( )",
3811
+ checkboxOn: "[\xD7]",
3812
+ checkboxOff: "[ ]",
3813
+ checkboxCircleOn: "(\xD7)",
3814
+ checkboxCircleOff: "( )",
3815
+ pointer: ">",
3816
+ triangleUpOutline: "\u2206",
3817
+ triangleLeft: "\u25C4",
3818
+ triangleRight: "\u25BA",
3819
+ lozenge: "\u2666",
3820
+ lozengeOutline: "\u25CA",
3821
+ hamburger: "\u2261",
3822
+ smiley: "\u263A",
3823
+ mustache: "\u250C\u2500\u2510",
3824
+ star: "\u2736",
3825
+ play: "\u25BA",
3826
+ nodejs: "\u2666",
3827
+ oneSeventh: "1/7",
3828
+ oneNinth: "1/9",
3829
+ oneTenth: "1/10"
3830
+ };
3831
+ var mainSymbols = {
3832
+ ...common,
3833
+ ...specialMainSymbols
3834
+ };
3835
+ var fallbackSymbols = {
3836
+ ...common,
3837
+ ...specialFallbackSymbols
3838
+ };
3839
+ var shouldUseMain = isUnicodeSupported();
3840
+ var figures = shouldUseMain ? mainSymbols : fallbackSymbols;
3841
+ var dist_default = figures;
3842
+ var replacements = Object.entries(specialMainSymbols);
3843
+
3844
+ // node_modules/@inquirer/core/dist/lib/theme.js
3845
+ var defaultTheme = {
3846
+ prefix: {
3847
+ idle: styleText("blue", "?"),
3848
+ done: styleText("green", dist_default.tick)
3849
+ },
3850
+ spinner: {
3851
+ interval: 80,
3852
+ frames: ["\u280B", "\u2819", "\u2839", "\u2838", "\u283C", "\u2834", "\u2826", "\u2827", "\u2807", "\u280F"].map((frame) => styleText("yellow", frame))
3853
+ },
3854
+ style: {
3855
+ answer: (text) => styleText("cyan", text),
3856
+ message: (text) => styleText("bold", text),
3857
+ error: (text) => styleText("red", `> ${text}`),
3858
+ defaultAnswer: (text) => styleText("dim", `(${text})`),
3859
+ help: (text) => styleText("dim", text),
3860
+ highlight: (text) => styleText("cyan", text),
3861
+ key: (text) => styleText("cyan", styleText("bold", `<${text}>`))
3862
+ }
3863
+ };
3864
+
3865
+ // node_modules/@inquirer/core/dist/lib/make-theme.js
3866
+ function isPlainObject(value) {
3867
+ if (typeof value !== "object" || value === null)
3868
+ return false;
3869
+ let proto2 = value;
3870
+ while (Object.getPrototypeOf(proto2) !== null) {
3871
+ proto2 = Object.getPrototypeOf(proto2);
3872
+ }
3873
+ return Object.getPrototypeOf(value) === proto2;
3874
+ }
3875
+ function deepMerge(...objects) {
3876
+ const output = {};
3877
+ for (const obj of objects) {
3878
+ for (const [key, value] of Object.entries(obj)) {
3879
+ const prevValue = output[key];
3880
+ output[key] = isPlainObject(prevValue) && isPlainObject(value) ? deepMerge(prevValue, value) : value;
3881
+ }
3882
+ }
3883
+ return output;
3884
+ }
3885
+ function makeTheme(...themes) {
3886
+ const themesToMerge = [
3887
+ defaultTheme,
3888
+ ...themes.filter((theme) => theme != null)
3889
+ ];
3890
+ return deepMerge(...themesToMerge);
3891
+ }
3892
+
3893
+ // node_modules/@inquirer/core/dist/lib/use-prefix.js
3894
+ function usePrefix({ status = "idle", theme }) {
3895
+ const [showLoader, setShowLoader] = useState(false);
3896
+ const [tick, setTick] = useState(0);
3897
+ const { prefix, spinner } = makeTheme(theme);
3898
+ useEffect(() => {
3899
+ if (status === "loading") {
3900
+ let tickInterval;
3901
+ let inc = -1;
3902
+ const delayTimeout = setTimeout(() => {
3903
+ setShowLoader(true);
3904
+ tickInterval = setInterval(() => {
3905
+ inc = inc + 1;
3906
+ setTick(inc % spinner.frames.length);
3907
+ }, spinner.interval);
3908
+ }, 300);
3909
+ return () => {
3910
+ clearTimeout(delayTimeout);
3911
+ clearInterval(tickInterval);
3912
+ };
3913
+ } else {
3914
+ setShowLoader(false);
3915
+ }
3916
+ }, [status]);
3917
+ if (showLoader) {
3918
+ return spinner.frames[tick];
3919
+ }
3920
+ const iconName = status === "loading" ? "idle" : status;
3921
+ return typeof prefix === "string" ? prefix : prefix[iconName] ?? prefix["idle"];
3922
+ }
3923
+ // node_modules/@inquirer/core/dist/lib/use-memo.js
3924
+ function useMemo(fn, dependencies) {
3925
+ return withPointer((pointer) => {
3926
+ const prev = pointer.get();
3927
+ if (!prev || prev.dependencies.length !== dependencies.length || prev.dependencies.some((dep, i) => dep !== dependencies[i])) {
3928
+ const value = fn();
3929
+ pointer.set({ value, dependencies });
3930
+ return value;
3931
+ }
3932
+ return prev.value;
3933
+ });
3934
+ }
3935
+ // node_modules/@inquirer/core/dist/lib/use-ref.js
3936
+ function useRef(val) {
3937
+ return useState({ current: val })[0];
3938
+ }
3939
+ // node_modules/@inquirer/core/dist/lib/use-keypress.js
3940
+ function useKeypress(userHandler) {
3941
+ const signal = useRef(userHandler);
3942
+ signal.current = userHandler;
3943
+ useEffect((rl) => {
3944
+ let ignore = false;
3945
+ const handler = withUpdates((_input, event) => {
3946
+ if (ignore)
3947
+ return;
3948
+ signal.current(event, rl);
3949
+ });
3950
+ rl.input.on("keypress", handler);
3951
+ return () => {
3952
+ ignore = true;
3953
+ rl.input.removeListener("keypress", handler);
3954
+ };
3955
+ }, []);
3956
+ }
3957
+ // node_modules/@inquirer/core/dist/lib/utils.js
3958
+ var import_cli_width = __toESM(require_cli_width(), 1);
3959
+
3960
+ // node_modules/fast-string-truncated-width/dist/utils.js
3961
+ var getCodePointsLength = (() => {
3962
+ const SURROGATE_PAIR_RE = /[\uD800-\uDBFF][\uDC00-\uDFFF]/g;
3963
+ return (input) => {
3964
+ let surrogatePairsNr = 0;
3965
+ SURROGATE_PAIR_RE.lastIndex = 0;
3966
+ while (SURROGATE_PAIR_RE.test(input)) {
3967
+ surrogatePairsNr += 1;
3968
+ }
3969
+ return input.length - surrogatePairsNr;
3970
+ };
3971
+ })();
3972
+ var isFullWidth = (x) => {
3973
+ return x === 12288 || x >= 65281 && x <= 65376 || x >= 65504 && x <= 65510;
3974
+ };
3975
+ var isWideNotCJKTNotEmoji = (x) => {
3976
+ return x === 8987 || x === 9001 || x >= 12272 && x <= 12287 || x >= 12289 && x <= 12350 || x >= 12441 && x <= 12543 || x >= 12549 && x <= 12591 || x >= 12593 && x <= 12686 || x >= 12688 && x <= 12771 || x >= 12783 && x <= 12830 || x >= 12832 && x <= 12871 || x >= 12880 && x <= 19903 || x >= 65040 && x <= 65049 || x >= 65072 && x <= 65106 || x >= 65108 && x <= 65126 || x >= 65128 && x <= 65131 || x >= 127488 && x <= 127490 || x >= 127504 && x <= 127547 || x >= 127552 && x <= 127560 || x >= 131072 && x <= 196605 || x >= 196608 && x <= 262141;
3977
+ };
3978
+
3979
+ // node_modules/fast-string-truncated-width/dist/index.js
3980
+ var ANSI_RE = /[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]|\u001b\]8;[^;]*;.*?(?:\u0007|\u001b\u005c)/y;
3981
+ var CONTROL_RE = /[\x00-\x08\x0A-\x1F\x7F-\x9F]{1,1000}/y;
3982
+ var CJKT_WIDE_RE = /(?:(?![\uFF61-\uFF9F\uFF00-\uFFEF])[\p{Script=Han}\p{Script=Hiragana}\p{Script=Katakana}\p{Script=Hangul}\p{Script=Tangut}]){1,1000}/yu;
3983
+ var TAB_RE = /\t{1,1000}/y;
3984
+ var EMOJI_RE = /[\u{1F1E6}-\u{1F1FF}]{2}|\u{1F3F4}[\u{E0061}-\u{E007A}]{2}[\u{E0030}-\u{E0039}\u{E0061}-\u{E007A}]{1,3}\u{E007F}|(?:\p{Emoji}\uFE0F\u20E3?|\p{Emoji_Modifier_Base}\p{Emoji_Modifier}?|\p{Emoji_Presentation})(?:\u200D(?:\p{Emoji_Modifier_Base}\p{Emoji_Modifier}?|\p{Emoji_Presentation}|\p{Emoji}\uFE0F\u20E3?))*/yu;
3985
+ var LATIN_RE = /(?:[\x20-\x7E\xA0-\xFF](?!\uFE0F)){1,1000}/y;
3986
+ var MODIFIER_RE = /\p{M}+/gu;
3987
+ var NO_TRUNCATION = { limit: Infinity, ellipsis: "" };
3988
+ var getStringTruncatedWidth = (input, truncationOptions = {}, widthOptions = {}) => {
3989
+ const LIMIT = truncationOptions.limit ?? Infinity;
3990
+ const ELLIPSIS = truncationOptions.ellipsis ?? "";
3991
+ const ELLIPSIS_WIDTH = truncationOptions?.ellipsisWidth ?? (ELLIPSIS ? getStringTruncatedWidth(ELLIPSIS, NO_TRUNCATION, widthOptions).width : 0);
3992
+ const ANSI_WIDTH = 0;
3993
+ const CONTROL_WIDTH = widthOptions.controlWidth ?? 0;
3994
+ const TAB_WIDTH = widthOptions.tabWidth ?? 8;
3995
+ const EMOJI_WIDTH = widthOptions.emojiWidth ?? 2;
3996
+ const FULL_WIDTH_WIDTH = 2;
3997
+ const REGULAR_WIDTH = widthOptions.regularWidth ?? 1;
3998
+ const WIDE_WIDTH = widthOptions.wideWidth ?? FULL_WIDTH_WIDTH;
3999
+ const PARSE_BLOCKS = [
4000
+ [LATIN_RE, REGULAR_WIDTH],
4001
+ [ANSI_RE, ANSI_WIDTH],
4002
+ [CONTROL_RE, CONTROL_WIDTH],
4003
+ [TAB_RE, TAB_WIDTH],
4004
+ [EMOJI_RE, EMOJI_WIDTH],
4005
+ [CJKT_WIDE_RE, WIDE_WIDTH]
4006
+ ];
4007
+ let indexPrev = 0;
4008
+ let index = 0;
4009
+ let length = input.length;
4010
+ let lengthExtra = 0;
4011
+ let truncationEnabled = false;
4012
+ let truncationIndex = length;
4013
+ let truncationLimit = Math.max(0, LIMIT - ELLIPSIS_WIDTH);
4014
+ let unmatchedStart = 0;
4015
+ let unmatchedEnd = 0;
4016
+ let width = 0;
4017
+ let widthExtra = 0;
4018
+ outer:
4019
+ while (true) {
4020
+ if (unmatchedEnd > unmatchedStart || index >= length && index > indexPrev) {
4021
+ const unmatched = input.slice(unmatchedStart, unmatchedEnd) || input.slice(indexPrev, index);
4022
+ lengthExtra = 0;
4023
+ for (const char of unmatched.replaceAll(MODIFIER_RE, "")) {
4024
+ const codePoint = char.codePointAt(0) || 0;
4025
+ if (isFullWidth(codePoint)) {
4026
+ widthExtra = FULL_WIDTH_WIDTH;
4027
+ } else if (isWideNotCJKTNotEmoji(codePoint)) {
4028
+ widthExtra = WIDE_WIDTH;
4029
+ } else {
4030
+ widthExtra = REGULAR_WIDTH;
4031
+ }
4032
+ if (width + widthExtra > truncationLimit) {
4033
+ truncationIndex = Math.min(truncationIndex, Math.max(unmatchedStart, indexPrev) + lengthExtra);
4034
+ }
4035
+ if (width + widthExtra > LIMIT) {
4036
+ truncationEnabled = true;
4037
+ break outer;
4038
+ }
4039
+ lengthExtra += char.length;
4040
+ width += widthExtra;
4041
+ }
4042
+ unmatchedStart = unmatchedEnd = 0;
4043
+ }
4044
+ if (index >= length) {
4045
+ break outer;
4046
+ }
4047
+ for (let i = 0, l = PARSE_BLOCKS.length;i < l; i++) {
4048
+ const [BLOCK_RE, BLOCK_WIDTH] = PARSE_BLOCKS[i];
4049
+ BLOCK_RE.lastIndex = index;
4050
+ if (BLOCK_RE.test(input)) {
4051
+ lengthExtra = BLOCK_RE === CJKT_WIDE_RE ? getCodePointsLength(input.slice(index, BLOCK_RE.lastIndex)) : BLOCK_RE === EMOJI_RE ? 1 : BLOCK_RE.lastIndex - index;
4052
+ widthExtra = lengthExtra * BLOCK_WIDTH;
4053
+ if (width + widthExtra > truncationLimit) {
4054
+ truncationIndex = Math.min(truncationIndex, index + Math.floor((truncationLimit - width) / BLOCK_WIDTH));
4055
+ }
4056
+ if (width + widthExtra > LIMIT) {
4057
+ truncationEnabled = true;
4058
+ break outer;
4059
+ }
4060
+ width += widthExtra;
4061
+ unmatchedStart = indexPrev;
4062
+ unmatchedEnd = index;
4063
+ index = indexPrev = BLOCK_RE.lastIndex;
4064
+ continue outer;
4065
+ }
4066
+ }
4067
+ index += 1;
4068
+ }
4069
+ return {
4070
+ width: truncationEnabled ? truncationLimit : width,
4071
+ index: truncationEnabled ? truncationIndex : length,
4072
+ truncated: truncationEnabled,
4073
+ ellipsed: truncationEnabled && LIMIT >= ELLIPSIS_WIDTH
4074
+ };
4075
+ };
4076
+ var dist_default2 = getStringTruncatedWidth;
4077
+
4078
+ // node_modules/fast-string-width/dist/index.js
4079
+ var NO_TRUNCATION2 = {
4080
+ limit: Infinity,
4081
+ ellipsis: "",
4082
+ ellipsisWidth: 0
4083
+ };
4084
+ var fastStringWidth = (input, options = {}) => {
4085
+ return dist_default2(input, NO_TRUNCATION2, options).width;
4086
+ };
4087
+ var dist_default3 = fastStringWidth;
4088
+
4089
+ // node_modules/fast-wrap-ansi/lib/main.js
4090
+ var ESC = "\x1B";
4091
+ var CSI = "\x9B";
4092
+ var END_CODE = 39;
4093
+ var ANSI_ESCAPE_BELL = "\x07";
4094
+ var ANSI_CSI = "[";
4095
+ var ANSI_OSC = "]";
4096
+ var ANSI_SGR_TERMINATOR = "m";
4097
+ var ANSI_ESCAPE_LINK = `${ANSI_OSC}8;;`;
4098
+ var GROUP_REGEX = new RegExp(`(?:\\${ANSI_CSI}(?<code>\\d+)m|\\${ANSI_ESCAPE_LINK}(?<uri>.*)${ANSI_ESCAPE_BELL})`, "y");
4099
+ var getClosingCode = (openingCode) => {
4100
+ if (openingCode >= 30 && openingCode <= 37)
4101
+ return 39;
4102
+ if (openingCode >= 90 && openingCode <= 97)
4103
+ return 39;
4104
+ if (openingCode >= 40 && openingCode <= 47)
4105
+ return 49;
4106
+ if (openingCode >= 100 && openingCode <= 107)
4107
+ return 49;
4108
+ if (openingCode === 1 || openingCode === 2)
4109
+ return 22;
4110
+ if (openingCode === 3)
4111
+ return 23;
4112
+ if (openingCode === 4)
4113
+ return 24;
4114
+ if (openingCode === 7)
4115
+ return 27;
4116
+ if (openingCode === 8)
4117
+ return 28;
4118
+ if (openingCode === 9)
4119
+ return 29;
4120
+ if (openingCode === 0)
4121
+ return 0;
4122
+ return;
4123
+ };
4124
+ var wrapAnsiCode = (code) => `${ESC}${ANSI_CSI}${code}${ANSI_SGR_TERMINATOR}`;
4125
+ var wrapAnsiHyperlink = (url) => `${ESC}${ANSI_ESCAPE_LINK}${url}${ANSI_ESCAPE_BELL}`;
4126
+ var wrapWord = (rows, word, columns) => {
4127
+ const characters = word[Symbol.iterator]();
4128
+ let isInsideEscape = false;
4129
+ let isInsideLinkEscape = false;
4130
+ let lastRow = rows.at(-1);
4131
+ let visible = lastRow === undefined ? 0 : dist_default3(lastRow);
4132
+ let currentCharacter = characters.next();
4133
+ let nextCharacter = characters.next();
4134
+ let rawCharacterIndex = 0;
4135
+ while (!currentCharacter.done) {
4136
+ const character = currentCharacter.value;
4137
+ const characterLength = dist_default3(character);
4138
+ if (visible + characterLength <= columns) {
4139
+ rows[rows.length - 1] += character;
4140
+ } else {
4141
+ rows.push(character);
4142
+ visible = 0;
4143
+ }
4144
+ if (character === ESC || character === CSI) {
4145
+ isInsideEscape = true;
4146
+ isInsideLinkEscape = word.startsWith(ANSI_ESCAPE_LINK, rawCharacterIndex + 1);
4147
+ }
4148
+ if (isInsideEscape) {
4149
+ if (isInsideLinkEscape) {
4150
+ if (character === ANSI_ESCAPE_BELL) {
4151
+ isInsideEscape = false;
4152
+ isInsideLinkEscape = false;
4153
+ }
4154
+ } else if (character === ANSI_SGR_TERMINATOR) {
4155
+ isInsideEscape = false;
4156
+ }
4157
+ } else {
4158
+ visible += characterLength;
4159
+ if (visible === columns && !nextCharacter.done) {
4160
+ rows.push("");
4161
+ visible = 0;
4162
+ }
4163
+ }
4164
+ currentCharacter = nextCharacter;
4165
+ nextCharacter = characters.next();
4166
+ rawCharacterIndex += character.length;
4167
+ }
4168
+ lastRow = rows.at(-1);
4169
+ if (!visible && lastRow !== undefined && lastRow.length && rows.length > 1) {
4170
+ rows[rows.length - 2] += rows.pop();
4171
+ }
4172
+ };
4173
+ var stringVisibleTrimSpacesRight = (string) => {
4174
+ const words = string.split(" ");
4175
+ let last = words.length;
4176
+ while (last) {
4177
+ if (dist_default3(words[last - 1])) {
4178
+ break;
4179
+ }
4180
+ last--;
4181
+ }
4182
+ if (last === words.length) {
4183
+ return string;
4184
+ }
4185
+ return words.slice(0, last).join(" ") + words.slice(last).join("");
4186
+ };
4187
+ var exec = (string, columns, options = {}) => {
4188
+ if (options.trim !== false && string.trim() === "") {
4189
+ return "";
4190
+ }
4191
+ let returnValue = "";
4192
+ let escapeCode;
4193
+ let escapeUrl;
4194
+ const words = string.split(" ");
4195
+ let rows = [""];
4196
+ let rowLength = 0;
4197
+ for (let index = 0;index < words.length; index++) {
4198
+ const word = words[index];
4199
+ if (options.trim !== false) {
4200
+ const row = rows.at(-1) ?? "";
4201
+ const trimmed = row.trimStart();
4202
+ if (row.length !== trimmed.length) {
4203
+ rows[rows.length - 1] = trimmed;
4204
+ rowLength = dist_default3(trimmed);
4205
+ }
4206
+ }
4207
+ if (index !== 0) {
4208
+ if (rowLength >= columns && (options.wordWrap === false || options.trim === false)) {
4209
+ rows.push("");
4210
+ rowLength = 0;
4211
+ }
4212
+ if (rowLength || options.trim === false) {
4213
+ rows[rows.length - 1] += " ";
4214
+ rowLength++;
4215
+ }
4216
+ }
4217
+ const wordLength = dist_default3(word);
4218
+ if (options.hard && wordLength > columns) {
4219
+ const remainingColumns = columns - rowLength;
4220
+ const breaksStartingThisLine = 1 + Math.floor((wordLength - remainingColumns - 1) / columns);
4221
+ const breaksStartingNextLine = Math.floor((wordLength - 1) / columns);
4222
+ if (breaksStartingNextLine < breaksStartingThisLine) {
4223
+ rows.push("");
4224
+ }
4225
+ wrapWord(rows, word, columns);
4226
+ rowLength = dist_default3(rows.at(-1) ?? "");
4227
+ continue;
4228
+ }
4229
+ if (rowLength + wordLength > columns && rowLength && wordLength) {
4230
+ if (options.wordWrap === false && rowLength < columns) {
4231
+ wrapWord(rows, word, columns);
4232
+ rowLength = dist_default3(rows.at(-1) ?? "");
4233
+ continue;
4234
+ }
4235
+ rows.push("");
4236
+ rowLength = 0;
4237
+ }
4238
+ if (rowLength + wordLength > columns && options.wordWrap === false) {
4239
+ wrapWord(rows, word, columns);
4240
+ rowLength = dist_default3(rows.at(-1) ?? "");
4241
+ continue;
4242
+ }
4243
+ rows[rows.length - 1] += word;
4244
+ rowLength += wordLength;
4245
+ }
4246
+ if (options.trim !== false) {
4247
+ rows = rows.map((row) => stringVisibleTrimSpacesRight(row));
4248
+ }
4249
+ const preString = rows.join(`
4250
+ `);
4251
+ let inSurrogate = false;
4252
+ for (let i = 0;i < preString.length; i++) {
4253
+ const character = preString[i];
4254
+ returnValue += character;
4255
+ if (!inSurrogate) {
4256
+ inSurrogate = character >= "\uD800" && character <= "\uDBFF";
4257
+ if (inSurrogate) {
4258
+ continue;
4259
+ }
4260
+ } else {
4261
+ inSurrogate = false;
4262
+ }
4263
+ if (character === ESC || character === CSI) {
4264
+ GROUP_REGEX.lastIndex = i + 1;
4265
+ const groupsResult = GROUP_REGEX.exec(preString);
4266
+ const groups = groupsResult?.groups;
4267
+ if (groups?.code !== undefined) {
4268
+ const code = Number.parseFloat(groups.code);
4269
+ escapeCode = code === END_CODE ? undefined : code;
4270
+ } else if (groups?.uri !== undefined) {
4271
+ escapeUrl = groups.uri.length === 0 ? undefined : groups.uri;
4272
+ }
4273
+ }
4274
+ if (preString[i + 1] === `
4275
+ `) {
4276
+ if (escapeUrl) {
4277
+ returnValue += wrapAnsiHyperlink("");
4278
+ }
4279
+ const closingCode = escapeCode ? getClosingCode(escapeCode) : undefined;
4280
+ if (escapeCode && closingCode) {
4281
+ returnValue += wrapAnsiCode(closingCode);
4282
+ }
4283
+ } else if (character === `
4284
+ `) {
4285
+ if (escapeCode && getClosingCode(escapeCode)) {
4286
+ returnValue += wrapAnsiCode(escapeCode);
4287
+ }
4288
+ if (escapeUrl) {
4289
+ returnValue += wrapAnsiHyperlink(escapeUrl);
4290
+ }
4291
+ }
4292
+ }
4293
+ return returnValue;
4294
+ };
4295
+ var CRLF_OR_LF = /\r?\n/;
4296
+ function wrapAnsi(string, columns, options) {
4297
+ return String(string).normalize().split(CRLF_OR_LF).map((line) => exec(line, columns, options)).join(`
4298
+ `);
4299
+ }
4300
+
4301
+ // node_modules/@inquirer/core/dist/lib/utils.js
4302
+ function breakLines(content, width) {
4303
+ return content.split(`
4304
+ `).flatMap((line) => wrapAnsi(line, width, { trim: false, hard: true }).split(`
4305
+ `).map((str) => str.trimEnd())).join(`
4306
+ `);
4307
+ }
4308
+ function readlineWidth() {
4309
+ return import_cli_width.default({ defaultWidth: 80, output: readline().output });
4310
+ }
4311
+
4312
+ // node_modules/@inquirer/core/dist/lib/pagination/use-pagination.js
4313
+ function usePointerPosition({ active, renderedItems, pageSize, loop }) {
4314
+ const state = useRef({
4315
+ lastPointer: active,
4316
+ lastActive: undefined
4317
+ });
4318
+ const { lastPointer, lastActive } = state.current;
4319
+ const middle = Math.floor(pageSize / 2);
4320
+ const renderedLength = renderedItems.reduce((acc, item) => acc + item.length, 0);
4321
+ const defaultPointerPosition = renderedItems.slice(0, active).reduce((acc, item) => acc + item.length, 0);
4322
+ let pointer = defaultPointerPosition;
4323
+ if (renderedLength > pageSize) {
4324
+ if (loop) {
4325
+ pointer = lastPointer;
4326
+ if (lastActive != null && lastActive < active && active - lastActive < pageSize) {
4327
+ pointer = Math.min(middle, Math.abs(active - lastActive) === 1 ? Math.min(lastPointer + (renderedItems[lastActive]?.length ?? 0), Math.max(defaultPointerPosition, lastPointer)) : lastPointer + active - lastActive);
4328
+ }
4329
+ } else {
4330
+ const spaceUnderActive = renderedItems.slice(active).reduce((acc, item) => acc + item.length, 0);
4331
+ pointer = spaceUnderActive < pageSize - middle ? pageSize - spaceUnderActive : Math.min(defaultPointerPosition, middle);
4332
+ }
4333
+ }
4334
+ state.current.lastPointer = pointer;
4335
+ state.current.lastActive = active;
4336
+ return pointer;
4337
+ }
4338
+ function usePagination({ items, active, renderItem, pageSize, loop = true }) {
4339
+ const width = readlineWidth();
4340
+ const bound = (num) => (num % items.length + items.length) % items.length;
4341
+ const renderedItems = items.map((item, index) => {
4342
+ if (item == null)
4343
+ return [];
4344
+ return breakLines(renderItem({ item, index, isActive: index === active }), width).split(`
4345
+ `);
4346
+ });
4347
+ const renderedLength = renderedItems.reduce((acc, item) => acc + item.length, 0);
4348
+ const renderItemAtIndex = (index) => renderedItems[index] ?? [];
4349
+ const pointer = usePointerPosition({ active, renderedItems, pageSize, loop });
4350
+ const activeItem = renderItemAtIndex(active).slice(0, pageSize);
4351
+ const activeItemPosition = pointer + activeItem.length <= pageSize ? pointer : pageSize - activeItem.length;
4352
+ const pageBuffer = Array.from({ length: pageSize });
4353
+ pageBuffer.splice(activeItemPosition, activeItem.length, ...activeItem);
4354
+ const itemVisited = new Set([active]);
4355
+ let bufferPointer = activeItemPosition + activeItem.length;
4356
+ let itemPointer = bound(active + 1);
4357
+ while (bufferPointer < pageSize && !itemVisited.has(itemPointer) && (loop && renderedLength > pageSize ? itemPointer !== active : itemPointer > active)) {
4358
+ const lines = renderItemAtIndex(itemPointer);
4359
+ const linesToAdd = lines.slice(0, pageSize - bufferPointer);
4360
+ pageBuffer.splice(bufferPointer, linesToAdd.length, ...linesToAdd);
4361
+ itemVisited.add(itemPointer);
4362
+ bufferPointer += linesToAdd.length;
4363
+ itemPointer = bound(itemPointer + 1);
4364
+ }
4365
+ bufferPointer = activeItemPosition - 1;
4366
+ itemPointer = bound(active - 1);
4367
+ while (bufferPointer >= 0 && !itemVisited.has(itemPointer) && (loop && renderedLength > pageSize ? itemPointer !== active : itemPointer < active)) {
4368
+ const lines = renderItemAtIndex(itemPointer);
4369
+ const linesToAdd = lines.slice(Math.max(0, lines.length - bufferPointer - 1));
4370
+ pageBuffer.splice(bufferPointer - linesToAdd.length + 1, linesToAdd.length, ...linesToAdd);
4371
+ itemVisited.add(itemPointer);
4372
+ bufferPointer -= linesToAdd.length;
4373
+ itemPointer = bound(itemPointer - 1);
4374
+ }
4375
+ return pageBuffer.filter((line) => typeof line === "string").join(`
4376
+ `);
4377
+ }
4378
+ // node_modules/@inquirer/core/dist/lib/create-prompt.js
4379
+ var import_mute_stream = __toESM(require_lib(), 1);
4380
+ import * as readline2 from "readline";
4381
+ import { AsyncResource as AsyncResource3 } from "async_hooks";
4382
+
4383
+ // node_modules/signal-exit/dist/mjs/signals.js
4384
+ var signals = [];
4385
+ signals.push("SIGHUP", "SIGINT", "SIGTERM");
4386
+ if (process.platform !== "win32") {
4387
+ signals.push("SIGALRM", "SIGABRT", "SIGVTALRM", "SIGXCPU", "SIGXFSZ", "SIGUSR2", "SIGTRAP", "SIGSYS", "SIGQUIT", "SIGIOT");
4388
+ }
4389
+ if (process.platform === "linux") {
4390
+ signals.push("SIGIO", "SIGPOLL", "SIGPWR", "SIGSTKFLT");
4391
+ }
4392
+
4393
+ // node_modules/signal-exit/dist/mjs/index.js
4394
+ var processOk = (process4) => !!process4 && typeof process4 === "object" && typeof process4.removeListener === "function" && typeof process4.emit === "function" && typeof process4.reallyExit === "function" && typeof process4.listeners === "function" && typeof process4.kill === "function" && typeof process4.pid === "number" && typeof process4.on === "function";
4395
+ var kExitEmitter = Symbol.for("signal-exit emitter");
4396
+ var global = globalThis;
4397
+ var ObjectDefineProperty = Object.defineProperty.bind(Object);
4398
+
4399
+ class Emitter {
4400
+ emitted = {
4401
+ afterExit: false,
4402
+ exit: false
4403
+ };
4404
+ listeners = {
4405
+ afterExit: [],
4406
+ exit: []
4407
+ };
4408
+ count = 0;
4409
+ id = Math.random();
4410
+ constructor() {
4411
+ if (global[kExitEmitter]) {
4412
+ return global[kExitEmitter];
4413
+ }
4414
+ ObjectDefineProperty(global, kExitEmitter, {
4415
+ value: this,
4416
+ writable: false,
4417
+ enumerable: false,
4418
+ configurable: false
4419
+ });
4420
+ }
4421
+ on(ev, fn) {
4422
+ this.listeners[ev].push(fn);
4423
+ }
4424
+ removeListener(ev, fn) {
4425
+ const list = this.listeners[ev];
4426
+ const i = list.indexOf(fn);
4427
+ if (i === -1) {
4428
+ return;
4429
+ }
4430
+ if (i === 0 && list.length === 1) {
4431
+ list.length = 0;
4432
+ } else {
4433
+ list.splice(i, 1);
4434
+ }
4435
+ }
4436
+ emit(ev, code, signal) {
4437
+ if (this.emitted[ev]) {
4438
+ return false;
4439
+ }
4440
+ this.emitted[ev] = true;
4441
+ let ret = false;
4442
+ for (const fn of this.listeners[ev]) {
4443
+ ret = fn(code, signal) === true || ret;
4444
+ }
4445
+ if (ev === "exit") {
4446
+ ret = this.emit("afterExit", code, signal) || ret;
4447
+ }
4448
+ return ret;
4449
+ }
4450
+ }
4451
+
4452
+ class SignalExitBase {
4453
+ }
4454
+ var signalExitWrap = (handler) => {
4455
+ return {
4456
+ onExit(cb, opts) {
4457
+ return handler.onExit(cb, opts);
4458
+ },
4459
+ load() {
4460
+ return handler.load();
4461
+ },
4462
+ unload() {
4463
+ return handler.unload();
4464
+ }
4465
+ };
4466
+ };
4467
+
4468
+ class SignalExitFallback extends SignalExitBase {
4469
+ onExit() {
4470
+ return () => {};
4471
+ }
4472
+ load() {}
4473
+ unload() {}
4474
+ }
4475
+
4476
+ class SignalExit extends SignalExitBase {
4477
+ #hupSig = process4.platform === "win32" ? "SIGINT" : "SIGHUP";
4478
+ #emitter = new Emitter;
4479
+ #process;
4480
+ #originalProcessEmit;
4481
+ #originalProcessReallyExit;
4482
+ #sigListeners = {};
4483
+ #loaded = false;
4484
+ constructor(process4) {
4485
+ super();
4486
+ this.#process = process4;
4487
+ this.#sigListeners = {};
4488
+ for (const sig of signals) {
4489
+ this.#sigListeners[sig] = () => {
4490
+ const listeners = this.#process.listeners(sig);
4491
+ let { count } = this.#emitter;
4492
+ const p = process4;
4493
+ if (typeof p.__signal_exit_emitter__ === "object" && typeof p.__signal_exit_emitter__.count === "number") {
4494
+ count += p.__signal_exit_emitter__.count;
4495
+ }
4496
+ if (listeners.length === count) {
4497
+ this.unload();
4498
+ const ret = this.#emitter.emit("exit", null, sig);
4499
+ const s = sig === "SIGHUP" ? this.#hupSig : sig;
4500
+ if (!ret)
4501
+ process4.kill(process4.pid, s);
4502
+ }
4503
+ };
4504
+ }
4505
+ this.#originalProcessReallyExit = process4.reallyExit;
4506
+ this.#originalProcessEmit = process4.emit;
4507
+ }
4508
+ onExit(cb, opts) {
4509
+ if (!processOk(this.#process)) {
4510
+ return () => {};
4511
+ }
4512
+ if (this.#loaded === false) {
4513
+ this.load();
4514
+ }
4515
+ const ev = opts?.alwaysLast ? "afterExit" : "exit";
4516
+ this.#emitter.on(ev, cb);
4517
+ return () => {
4518
+ this.#emitter.removeListener(ev, cb);
4519
+ if (this.#emitter.listeners["exit"].length === 0 && this.#emitter.listeners["afterExit"].length === 0) {
4520
+ this.unload();
4521
+ }
4522
+ };
4523
+ }
4524
+ load() {
4525
+ if (this.#loaded) {
4526
+ return;
4527
+ }
4528
+ this.#loaded = true;
4529
+ this.#emitter.count += 1;
4530
+ for (const sig of signals) {
4531
+ try {
4532
+ const fn = this.#sigListeners[sig];
4533
+ if (fn)
4534
+ this.#process.on(sig, fn);
4535
+ } catch (_) {}
4536
+ }
4537
+ this.#process.emit = (ev, ...a) => {
4538
+ return this.#processEmit(ev, ...a);
4539
+ };
4540
+ this.#process.reallyExit = (code) => {
4541
+ return this.#processReallyExit(code);
4542
+ };
4543
+ }
4544
+ unload() {
4545
+ if (!this.#loaded) {
4546
+ return;
4547
+ }
4548
+ this.#loaded = false;
4549
+ signals.forEach((sig) => {
4550
+ const listener = this.#sigListeners[sig];
4551
+ if (!listener) {
4552
+ throw new Error("Listener not defined for signal: " + sig);
4553
+ }
4554
+ try {
4555
+ this.#process.removeListener(sig, listener);
4556
+ } catch (_) {}
4557
+ });
4558
+ this.#process.emit = this.#originalProcessEmit;
4559
+ this.#process.reallyExit = this.#originalProcessReallyExit;
4560
+ this.#emitter.count -= 1;
4561
+ }
4562
+ #processReallyExit(code) {
4563
+ if (!processOk(this.#process)) {
4564
+ return 0;
4565
+ }
4566
+ this.#process.exitCode = code || 0;
4567
+ this.#emitter.emit("exit", this.#process.exitCode, null);
4568
+ return this.#originalProcessReallyExit.call(this.#process, this.#process.exitCode);
4569
+ }
4570
+ #processEmit(ev, ...args) {
4571
+ const og = this.#originalProcessEmit;
4572
+ if (ev === "exit" && processOk(this.#process)) {
4573
+ if (typeof args[0] === "number") {
4574
+ this.#process.exitCode = args[0];
4575
+ }
4576
+ const ret = og.call(this.#process, ev, ...args);
4577
+ this.#emitter.emit("exit", this.#process.exitCode, null);
4578
+ return ret;
4579
+ } else {
4580
+ return og.call(this.#process, ev, ...args);
4581
+ }
4582
+ }
4583
+ }
4584
+ var process4 = globalThis.process;
4585
+ var {
4586
+ onExit,
4587
+ load,
4588
+ unload
4589
+ } = signalExitWrap(processOk(process4) ? new SignalExit(process4) : new SignalExitFallback);
4590
+
4591
+ // node_modules/@inquirer/core/dist/lib/screen-manager.js
4592
+ import { stripVTControlCharacters } from "util";
4593
+
4594
+ // node_modules/@inquirer/ansi/dist/index.js
4595
+ var ESC2 = "\x1B[";
4596
+ var cursorLeft = ESC2 + "G";
4597
+ var cursorHide = ESC2 + "?25l";
4598
+ var cursorShow = ESC2 + "?25h";
4599
+ var cursorUp = (rows = 1) => rows > 0 ? `${ESC2}${rows}A` : "";
4600
+ var cursorDown = (rows = 1) => rows > 0 ? `${ESC2}${rows}B` : "";
4601
+ var cursorTo = (x, y) => {
4602
+ if (typeof y === "number" && !Number.isNaN(y)) {
4603
+ return `${ESC2}${y + 1};${x + 1}H`;
4604
+ }
4605
+ return `${ESC2}${x + 1}G`;
4606
+ };
4607
+ var eraseLine = ESC2 + "2K";
4608
+ var eraseLines = (lines) => lines > 0 ? (eraseLine + cursorUp(1)).repeat(lines - 1) + eraseLine + cursorLeft : "";
4609
+
4610
+ // node_modules/@inquirer/core/dist/lib/screen-manager.js
4611
+ var height = (content) => content.split(`
4612
+ `).length;
4613
+ var lastLine = (content) => content.split(`
4614
+ `).pop() ?? "";
4615
+
4616
+ class ScreenManager {
4617
+ height = 0;
4618
+ extraLinesUnderPrompt = 0;
4619
+ cursorPos;
4620
+ rl;
4621
+ constructor(rl) {
4622
+ this.rl = rl;
4623
+ this.cursorPos = rl.getCursorPos();
4624
+ }
4625
+ write(content) {
4626
+ this.rl.output.unmute();
4627
+ this.rl.output.write(content);
4628
+ this.rl.output.mute();
4629
+ }
4630
+ render(content, bottomContent = "") {
4631
+ const promptLine = lastLine(content);
4632
+ const rawPromptLine = stripVTControlCharacters(promptLine);
4633
+ let prompt = rawPromptLine;
4634
+ if (this.rl.line.length > 0) {
4635
+ prompt = prompt.slice(0, -this.rl.line.length);
4636
+ }
4637
+ this.rl.setPrompt(prompt);
4638
+ this.cursorPos = this.rl.getCursorPos();
4639
+ const width = readlineWidth();
4640
+ content = breakLines(content, width);
4641
+ bottomContent = breakLines(bottomContent, width);
4642
+ if (rawPromptLine.length % width === 0) {
4643
+ content += `
4644
+ `;
4645
+ }
4646
+ let output = content + (bottomContent ? `
4647
+ ` + bottomContent : "");
4648
+ const promptLineUpDiff = Math.floor(rawPromptLine.length / width) - this.cursorPos.rows;
4649
+ const bottomContentHeight = promptLineUpDiff + (bottomContent ? height(bottomContent) : 0);
4650
+ if (bottomContentHeight > 0)
4651
+ output += cursorUp(bottomContentHeight);
4652
+ output += cursorTo(this.cursorPos.cols);
4653
+ this.write(cursorDown(this.extraLinesUnderPrompt) + eraseLines(this.height) + output);
4654
+ this.extraLinesUnderPrompt = bottomContentHeight;
4655
+ this.height = height(output);
4656
+ }
4657
+ checkCursorPos() {
4658
+ const cursorPos = this.rl.getCursorPos();
4659
+ if (cursorPos.cols !== this.cursorPos.cols) {
4660
+ this.write(cursorTo(cursorPos.cols));
4661
+ this.cursorPos = cursorPos;
4662
+ }
4663
+ }
4664
+ done({ clearContent }) {
4665
+ this.rl.setPrompt("");
4666
+ let output = cursorDown(this.extraLinesUnderPrompt);
4667
+ output += clearContent ? eraseLines(this.height) : `
4668
+ `;
4669
+ output += cursorShow;
4670
+ this.write(output);
4671
+ this.rl.close();
4672
+ }
4673
+ }
4674
+
4675
+ // node_modules/@inquirer/core/dist/lib/promise-polyfill.js
4676
+ class PromisePolyfill extends Promise {
4677
+ static withResolver() {
4678
+ let resolve;
4679
+ let reject;
4680
+ const promise = new Promise((res, rej) => {
4681
+ resolve = res;
4682
+ reject = rej;
4683
+ });
4684
+ return { promise, resolve, reject };
4685
+ }
4686
+ }
4687
+
4688
+ // node_modules/@inquirer/core/dist/lib/create-prompt.js
4689
+ var nativeSetImmediate = globalThis.setImmediate;
4690
+ function getCallSites() {
4691
+ const _prepareStackTrace = Error.prepareStackTrace;
4692
+ let result = [];
4693
+ try {
4694
+ Error.prepareStackTrace = (_, callSites) => {
4695
+ const callSitesWithoutCurrent = callSites.slice(1);
4696
+ result = callSitesWithoutCurrent;
4697
+ return callSitesWithoutCurrent;
4698
+ };
4699
+ new Error().stack;
4700
+ } catch {
4701
+ return result;
4702
+ }
4703
+ Error.prepareStackTrace = _prepareStackTrace;
4704
+ return result;
4705
+ }
4706
+ function createPrompt(view) {
4707
+ const callSites = getCallSites();
4708
+ const prompt = (config, context = {}) => {
4709
+ const { input = process.stdin, signal } = context;
4710
+ const cleanups = new Set;
4711
+ const output = new import_mute_stream.default;
4712
+ output.pipe(context.output ?? process.stdout);
4713
+ output.mute();
4714
+ const rl = readline2.createInterface({
4715
+ terminal: true,
4716
+ input,
4717
+ output
4718
+ });
4719
+ const screen = new ScreenManager(rl);
4720
+ const { promise, resolve, reject } = PromisePolyfill.withResolver();
4721
+ const cancel = () => reject(new CancelPromptError);
4722
+ if (signal) {
4723
+ const abort = () => reject(new AbortPromptError({ cause: signal.reason }));
4724
+ if (signal.aborted) {
4725
+ abort();
4726
+ return Object.assign(promise, { cancel });
4727
+ }
4728
+ signal.addEventListener("abort", abort);
4729
+ cleanups.add(() => signal.removeEventListener("abort", abort));
4730
+ }
4731
+ cleanups.add(onExit((code, signal2) => {
4732
+ reject(new ExitPromptError(`User force closed the prompt with ${code} ${signal2}`));
4733
+ }));
4734
+ const sigint = () => reject(new ExitPromptError(`User force closed the prompt with SIGINT`));
4735
+ rl.on("SIGINT", sigint);
4736
+ cleanups.add(() => rl.removeListener("SIGINT", sigint));
4737
+ return withHooks(rl, (cycle) => {
4738
+ const hooksCleanup = AsyncResource3.bind(() => effectScheduler.clearAll());
4739
+ rl.on("close", hooksCleanup);
4740
+ cleanups.add(() => rl.removeListener("close", hooksCleanup));
4741
+ const startCycle = () => {
4742
+ const checkCursorPos = () => screen.checkCursorPos();
4743
+ rl.input.on("keypress", checkCursorPos);
4744
+ cleanups.add(() => rl.input.removeListener("keypress", checkCursorPos));
4745
+ cycle(() => {
4746
+ try {
4747
+ const nextView = view(config, (value) => {
4748
+ setImmediate(() => resolve(value));
4749
+ });
4750
+ if (nextView === undefined) {
4751
+ const callerFilename = callSites[1]?.getFileName();
4752
+ throw new Error(`Prompt functions must return a string.
4753
+ at ${callerFilename}`);
4754
+ }
4755
+ const [content, bottomContent] = typeof nextView === "string" ? [nextView] : nextView;
4756
+ screen.render(content, bottomContent);
4757
+ effectScheduler.run();
4758
+ } catch (error) {
4759
+ reject(error);
4760
+ }
4761
+ });
4762
+ };
4763
+ if ("readableFlowing" in input) {
4764
+ nativeSetImmediate(startCycle);
4765
+ } else {
4766
+ startCycle();
4767
+ }
4768
+ return Object.assign(promise.then((answer) => {
4769
+ effectScheduler.clearAll();
4770
+ return answer;
4771
+ }, (error) => {
4772
+ effectScheduler.clearAll();
4773
+ throw error;
4774
+ }).finally(() => {
4775
+ cleanups.forEach((cleanup) => cleanup());
4776
+ screen.done({ clearContent: Boolean(context.clearPromptOnDone) });
4777
+ output.end();
4778
+ }).then(() => promise), { cancel });
4779
+ });
4780
+ };
4781
+ return prompt;
4782
+ }
4783
+ // node_modules/@inquirer/core/dist/lib/Separator.js
4784
+ import { styleText as styleText2 } from "util";
4785
+ class Separator {
4786
+ separator = styleText2("dim", Array.from({ length: 15 }).join(dist_default.line));
4787
+ type = "separator";
4788
+ constructor(separator) {
4789
+ if (separator) {
4790
+ this.separator = separator;
4791
+ }
4792
+ }
4793
+ static isSeparator(choice) {
4794
+ return Boolean(choice && typeof choice === "object" && "type" in choice && choice.type === "separator");
3084
4795
  }
3085
- return openAll + string + closeAll;
4796
+ }
4797
+ // node_modules/@inquirer/checkbox/dist/index.js
4798
+ import { styleText as styleText3 } from "util";
4799
+ var checkboxTheme = {
4800
+ icon: {
4801
+ checked: styleText3("green", dist_default.circleFilled),
4802
+ unchecked: dist_default.circle,
4803
+ cursor: dist_default.pointer,
4804
+ disabledChecked: styleText3("green", dist_default.circleDouble),
4805
+ disabledUnchecked: "-"
4806
+ },
4807
+ style: {
4808
+ disabled: (text) => styleText3("dim", text),
4809
+ renderSelectedChoices: (selectedChoices) => selectedChoices.map((choice) => choice.short).join(", "),
4810
+ description: (text) => styleText3("cyan", text),
4811
+ keysHelpTip: (keys) => keys.map(([key, action]) => `${styleText3("bold", key)} ${styleText3("dim", action)}`).join(styleText3("dim", " \u2022 "))
4812
+ },
4813
+ i18n: { disabledError: "This option is disabled and cannot be toggled." },
4814
+ keybindings: []
3086
4815
  };
3087
- Object.defineProperties(createChalk.prototype, styles2);
3088
- var chalk = createChalk();
3089
- var chalkStderr = createChalk({ level: stderrColor ? stderrColor.level : 0 });
3090
- var source_default = chalk;
3091
-
4816
+ function isSelectable(item) {
4817
+ return !Separator.isSeparator(item) && !item.disabled;
4818
+ }
4819
+ function isNavigable(item) {
4820
+ return !Separator.isSeparator(item);
4821
+ }
4822
+ function isChecked(item) {
4823
+ return !Separator.isSeparator(item) && item.checked;
4824
+ }
4825
+ function toggle(item) {
4826
+ return isSelectable(item) ? { ...item, checked: !item.checked } : item;
4827
+ }
4828
+ function check(checked) {
4829
+ return function(item) {
4830
+ return isSelectable(item) ? { ...item, checked } : item;
4831
+ };
4832
+ }
4833
+ function normalizeChoices(choices) {
4834
+ return choices.map((choice) => {
4835
+ if (Separator.isSeparator(choice))
4836
+ return choice;
4837
+ if (typeof choice === "string") {
4838
+ return {
4839
+ value: choice,
4840
+ name: choice,
4841
+ short: choice,
4842
+ checkedName: choice,
4843
+ disabled: false,
4844
+ checked: false
4845
+ };
4846
+ }
4847
+ const name = choice.name ?? String(choice.value);
4848
+ const normalizedChoice = {
4849
+ value: choice.value,
4850
+ name,
4851
+ short: choice.short ?? name,
4852
+ checkedName: choice.checkedName ?? name,
4853
+ disabled: choice.disabled ?? false,
4854
+ checked: choice.checked ?? false
4855
+ };
4856
+ if (choice.description) {
4857
+ normalizedChoice.description = choice.description;
4858
+ }
4859
+ return normalizedChoice;
4860
+ });
4861
+ }
4862
+ var dist_default4 = createPrompt((config, done) => {
4863
+ const { pageSize = 7, loop = true, required, validate = () => true } = config;
4864
+ const shortcuts = { all: "a", invert: "i", ...config.shortcuts };
4865
+ const theme = makeTheme(checkboxTheme, config.theme);
4866
+ const { keybindings } = theme;
4867
+ const [status, setStatus] = useState("idle");
4868
+ const prefix = usePrefix({ status, theme });
4869
+ const [items, setItems] = useState(normalizeChoices(config.choices));
4870
+ const bounds = useMemo(() => {
4871
+ const first = items.findIndex(isNavigable);
4872
+ const last = items.findLastIndex(isNavigable);
4873
+ if (first === -1) {
4874
+ throw new ValidationError("[checkbox prompt] No selectable choices. All choices are disabled.");
4875
+ }
4876
+ return { first, last };
4877
+ }, [items]);
4878
+ const [active, setActive] = useState(bounds.first);
4879
+ const [errorMsg, setError] = useState();
4880
+ useKeypress(async (key) => {
4881
+ if (isEnterKey(key)) {
4882
+ const selection = items.filter(isChecked);
4883
+ const isValid = await validate([...selection]);
4884
+ if (required && !selection.length) {
4885
+ setError("At least one choice must be selected");
4886
+ } else if (isValid === true) {
4887
+ setStatus("done");
4888
+ done(selection.map((choice) => choice.value));
4889
+ } else {
4890
+ setError(isValid || "You must select a valid value");
4891
+ }
4892
+ } else if (isUpKey(key, keybindings) || isDownKey(key, keybindings)) {
4893
+ if (errorMsg) {
4894
+ setError(undefined);
4895
+ }
4896
+ if (loop || isUpKey(key, keybindings) && active !== bounds.first || isDownKey(key, keybindings) && active !== bounds.last) {
4897
+ const offset = isUpKey(key, keybindings) ? -1 : 1;
4898
+ let next = active;
4899
+ do {
4900
+ next = (next + offset + items.length) % items.length;
4901
+ } while (!isNavigable(items[next]));
4902
+ setActive(next);
4903
+ }
4904
+ } else if (isSpaceKey(key)) {
4905
+ const activeItem = items[active];
4906
+ if (activeItem && !Separator.isSeparator(activeItem)) {
4907
+ if (activeItem.disabled) {
4908
+ setError(theme.i18n.disabledError);
4909
+ } else {
4910
+ setError(undefined);
4911
+ setItems(items.map((choice, i) => i === active ? toggle(choice) : choice));
4912
+ }
4913
+ }
4914
+ } else if (key.name === shortcuts.all) {
4915
+ const selectAll = items.some((choice) => isSelectable(choice) && !choice.checked);
4916
+ setItems(items.map(check(selectAll)));
4917
+ } else if (key.name === shortcuts.invert) {
4918
+ setItems(items.map(toggle));
4919
+ } else if (isNumberKey(key)) {
4920
+ const selectedIndex = Number(key.name) - 1;
4921
+ let selectableIndex = -1;
4922
+ const position = items.findIndex((item) => {
4923
+ if (Separator.isSeparator(item))
4924
+ return false;
4925
+ selectableIndex++;
4926
+ return selectableIndex === selectedIndex;
4927
+ });
4928
+ const selectedItem = items[position];
4929
+ if (selectedItem && isSelectable(selectedItem)) {
4930
+ setActive(position);
4931
+ setItems(items.map((choice, i) => i === position ? toggle(choice) : choice));
4932
+ }
4933
+ }
4934
+ });
4935
+ const message = theme.style.message(config.message, status);
4936
+ let description;
4937
+ const page = usePagination({
4938
+ items,
4939
+ active,
4940
+ renderItem({ item, isActive }) {
4941
+ if (Separator.isSeparator(item)) {
4942
+ return ` ${item.separator}`;
4943
+ }
4944
+ const cursor = isActive ? theme.icon.cursor : " ";
4945
+ if (item.disabled) {
4946
+ const disabledLabel = typeof item.disabled === "string" ? item.disabled : "(disabled)";
4947
+ const checkbox2 = item.checked ? theme.icon.disabledChecked : theme.icon.disabledUnchecked;
4948
+ return theme.style.disabled(`${cursor}${checkbox2} ${item.name} ${disabledLabel}`);
4949
+ }
4950
+ if (isActive) {
4951
+ description = item.description;
4952
+ }
4953
+ const checkbox = item.checked ? theme.icon.checked : theme.icon.unchecked;
4954
+ const name = item.checked ? item.checkedName : item.name;
4955
+ const color = isActive ? theme.style.highlight : (x) => x;
4956
+ return color(`${cursor}${checkbox} ${name}`);
4957
+ },
4958
+ pageSize,
4959
+ loop
4960
+ });
4961
+ if (status === "done") {
4962
+ const selection = items.filter(isChecked);
4963
+ const answer = theme.style.answer(theme.style.renderSelectedChoices(selection, items));
4964
+ return [prefix, message, answer].filter(Boolean).join(" ");
4965
+ }
4966
+ const keys = [
4967
+ ["\u2191\u2193", "navigate"],
4968
+ ["space", "select"]
4969
+ ];
4970
+ if (shortcuts.all)
4971
+ keys.push([shortcuts.all, "all"]);
4972
+ if (shortcuts.invert)
4973
+ keys.push([shortcuts.invert, "invert"]);
4974
+ keys.push(["\u23CE", "submit"]);
4975
+ const helpLine = theme.style.keysHelpTip(keys);
4976
+ const lines = [
4977
+ [prefix, message].filter(Boolean).join(" "),
4978
+ page,
4979
+ " ",
4980
+ description ? theme.style.description(description) : "",
4981
+ errorMsg ? theme.style.error(errorMsg) : "",
4982
+ helpLine
4983
+ ].filter(Boolean).join(`
4984
+ `).trimEnd();
4985
+ return `${lines}${cursorHide}`;
4986
+ });
4987
+ // node_modules/@inquirer/select/dist/index.js
4988
+ import { styleText as styleText4 } from "util";
4989
+ var selectTheme = {
4990
+ icon: { cursor: dist_default.pointer },
4991
+ style: {
4992
+ disabled: (text) => styleText4("dim", text),
4993
+ description: (text) => styleText4("cyan", text),
4994
+ keysHelpTip: (keys) => keys.map(([key, action]) => `${styleText4("bold", key)} ${styleText4("dim", action)}`).join(styleText4("dim", " \u2022 "))
4995
+ },
4996
+ i18n: { disabledError: "This option is disabled and cannot be selected." },
4997
+ indexMode: "hidden",
4998
+ keybindings: []
4999
+ };
5000
+ function isSelectable2(item) {
5001
+ return !Separator.isSeparator(item) && !item.disabled;
5002
+ }
5003
+ function isNavigable2(item) {
5004
+ return !Separator.isSeparator(item);
5005
+ }
5006
+ function normalizeChoices2(choices) {
5007
+ return choices.map((choice) => {
5008
+ if (Separator.isSeparator(choice))
5009
+ return choice;
5010
+ if (typeof choice !== "object" || choice === null || !("value" in choice)) {
5011
+ const name2 = String(choice);
5012
+ return {
5013
+ value: choice,
5014
+ name: name2,
5015
+ short: name2,
5016
+ disabled: false
5017
+ };
5018
+ }
5019
+ const name = choice.name ?? String(choice.value);
5020
+ const normalizedChoice = {
5021
+ value: choice.value,
5022
+ name,
5023
+ short: choice.short ?? name,
5024
+ disabled: choice.disabled ?? false
5025
+ };
5026
+ if (choice.description) {
5027
+ normalizedChoice.description = choice.description;
5028
+ }
5029
+ return normalizedChoice;
5030
+ });
5031
+ }
5032
+ var dist_default5 = createPrompt((config, done) => {
5033
+ const { loop = true, pageSize = 7 } = config;
5034
+ const theme = makeTheme(selectTheme, config.theme);
5035
+ const { keybindings } = theme;
5036
+ const [status, setStatus] = useState("idle");
5037
+ const prefix = usePrefix({ status, theme });
5038
+ const searchTimeoutRef = useRef();
5039
+ const searchEnabled = !keybindings.includes("vim");
5040
+ const items = useMemo(() => normalizeChoices2(config.choices), [config.choices]);
5041
+ const bounds = useMemo(() => {
5042
+ const first = items.findIndex(isNavigable2);
5043
+ const last = items.findLastIndex(isNavigable2);
5044
+ if (first === -1) {
5045
+ throw new ValidationError("[select prompt] No selectable choices. All choices are disabled.");
5046
+ }
5047
+ return { first, last };
5048
+ }, [items]);
5049
+ const defaultItemIndex = useMemo(() => {
5050
+ if (!("default" in config))
5051
+ return -1;
5052
+ return items.findIndex((item) => isSelectable2(item) && item.value === config.default);
5053
+ }, [config.default, items]);
5054
+ const [active, setActive] = useState(defaultItemIndex === -1 ? bounds.first : defaultItemIndex);
5055
+ const selectedChoice = items[active];
5056
+ const [errorMsg, setError] = useState();
5057
+ useKeypress((key, rl) => {
5058
+ clearTimeout(searchTimeoutRef.current);
5059
+ if (errorMsg) {
5060
+ setError(undefined);
5061
+ }
5062
+ if (isEnterKey(key)) {
5063
+ if (selectedChoice.disabled) {
5064
+ setError(theme.i18n.disabledError);
5065
+ } else {
5066
+ setStatus("done");
5067
+ done(selectedChoice.value);
5068
+ }
5069
+ } else if (isUpKey(key, keybindings) || isDownKey(key, keybindings)) {
5070
+ rl.clearLine(0);
5071
+ if (loop || isUpKey(key, keybindings) && active !== bounds.first || isDownKey(key, keybindings) && active !== bounds.last) {
5072
+ const offset = isUpKey(key, keybindings) ? -1 : 1;
5073
+ let next = active;
5074
+ do {
5075
+ next = (next + offset + items.length) % items.length;
5076
+ } while (!isNavigable2(items[next]));
5077
+ setActive(next);
5078
+ }
5079
+ } else if (isNumberKey(key) && !Number.isNaN(Number(rl.line))) {
5080
+ const selectedIndex = Number(rl.line) - 1;
5081
+ let selectableIndex = -1;
5082
+ const position = items.findIndex((item2) => {
5083
+ if (Separator.isSeparator(item2))
5084
+ return false;
5085
+ selectableIndex++;
5086
+ return selectableIndex === selectedIndex;
5087
+ });
5088
+ const item = items[position];
5089
+ if (item != null && isSelectable2(item)) {
5090
+ setActive(position);
5091
+ }
5092
+ searchTimeoutRef.current = setTimeout(() => {
5093
+ rl.clearLine(0);
5094
+ }, 700);
5095
+ } else if (isBackspaceKey(key)) {
5096
+ rl.clearLine(0);
5097
+ } else if (searchEnabled) {
5098
+ const searchTerm = rl.line.toLowerCase();
5099
+ const matchIndex = items.findIndex((item) => {
5100
+ if (Separator.isSeparator(item) || !isSelectable2(item))
5101
+ return false;
5102
+ return item.name.toLowerCase().startsWith(searchTerm);
5103
+ });
5104
+ if (matchIndex !== -1) {
5105
+ setActive(matchIndex);
5106
+ }
5107
+ searchTimeoutRef.current = setTimeout(() => {
5108
+ rl.clearLine(0);
5109
+ }, 700);
5110
+ }
5111
+ });
5112
+ useEffect(() => () => {
5113
+ clearTimeout(searchTimeoutRef.current);
5114
+ }, []);
5115
+ const message = theme.style.message(config.message, status);
5116
+ const helpLine = theme.style.keysHelpTip([
5117
+ ["\u2191\u2193", "navigate"],
5118
+ ["\u23CE", "select"]
5119
+ ]);
5120
+ let separatorCount = 0;
5121
+ const page = usePagination({
5122
+ items,
5123
+ active,
5124
+ renderItem({ item, isActive, index }) {
5125
+ if (Separator.isSeparator(item)) {
5126
+ separatorCount++;
5127
+ return ` ${item.separator}`;
5128
+ }
5129
+ const cursor = isActive ? theme.icon.cursor : " ";
5130
+ const indexLabel = theme.indexMode === "number" ? `${index + 1 - separatorCount}. ` : "";
5131
+ if (item.disabled) {
5132
+ const disabledLabel = typeof item.disabled === "string" ? item.disabled : "(disabled)";
5133
+ const disabledCursor = isActive ? theme.icon.cursor : "-";
5134
+ return theme.style.disabled(`${disabledCursor} ${indexLabel}${item.name} ${disabledLabel}`);
5135
+ }
5136
+ const color = isActive ? theme.style.highlight : (x) => x;
5137
+ return color(`${cursor} ${indexLabel}${item.name}`);
5138
+ },
5139
+ pageSize,
5140
+ loop
5141
+ });
5142
+ if (status === "done") {
5143
+ return [prefix, message, theme.style.answer(selectedChoice.short)].filter(Boolean).join(" ");
5144
+ }
5145
+ const { description } = selectedChoice;
5146
+ const lines = [
5147
+ [prefix, message].filter(Boolean).join(" "),
5148
+ page,
5149
+ " ",
5150
+ description ? theme.style.description(description) : "",
5151
+ errorMsg ? theme.style.error(errorMsg) : "",
5152
+ helpLine
5153
+ ].filter(Boolean).join(`
5154
+ `).trimEnd();
5155
+ return `${lines}${cursorHide}`;
5156
+ });
3092
5157
  // src/cli/index.ts
3093
5158
  init_engine();
3094
- import { resolve, join as join6 } from "path";
3095
5159
  init_auto_embed();
3096
5160
  init_store();
3097
5161
  init_model();
@@ -3652,12 +5716,155 @@ function requireRepo(rootPath) {
3652
5716
  process.exit(1);
3653
5717
  }
3654
5718
  }
3655
- program2.command("init").description("Initialize a new TrellisVCS repository in the current directory").option("-p, --path <path>", "Path to initialize", ".").action(async (opts) => {
5719
+ program2.command("init").description("Initialize a new TrellisVCS repository in the current directory").option("-p, --path <path>", "Path to initialize", ".").option("--ides <ides...>", "IDEs to scaffold for (cursor, windsurf, claude, copilot, codex, gemini)").option("--framework <framework>", "Project framework (react, vue, svelte, next, nuxt, remotion, expo, bun, node, cli, library, animation, games, none)", "none").option("--footprint <footprint>", "Workspace footprint (minimal, standard, full)", "standard").option("--no-interactive", "Skip interactive prompts").action(async (opts) => {
3656
5720
  const rootPath = resolve(opts.path);
5721
+ const isInteractive = process.stdout.isTTY && !process.argv.includes("--no-interactive");
3657
5722
  if (TrellisVcsEngine.isRepo(rootPath)) {
3658
- console.log(source_default.yellow("Already a TrellisVCS repository."));
5723
+ console.log(source_default.yellow("Already a Trellis workspace."));
3659
5724
  return;
3660
5725
  }
5726
+ if (!hasProfile()) {
5727
+ const trellisDir = join6(rootPath, ".trellis");
5728
+ const identity = hasIdentity(trellisDir) ? loadIdentity(trellisDir) : null;
5729
+ if (isInteractive) {
5730
+ console.log(source_default.cyan(`
5731
+ Welcome to Trellis! Let's get you set up.`));
5732
+ const newProfile = await promptForProfile({
5733
+ name: identity?.displayName
5734
+ });
5735
+ saveProfile(newProfile);
5736
+ console.log(source_default.green(` \u2713 Profile saved to ~/.trellis/profile.json
5737
+ `));
5738
+ } else {
5739
+ updateProfile({ name: identity?.displayName || "Unknown" });
5740
+ }
5741
+ }
5742
+ const preInfer = await inferProjectContext(rootPath);
5743
+ const detectedFramework = preInfer.framework;
5744
+ let selectedIdes = opts.ides || [];
5745
+ let footprint = opts.footprint || "standard";
5746
+ let framework = opts.framework || detectedFramework || "none";
5747
+ let plugins = opts.plugins || [];
5748
+ if (!isInteractive && framework === "none" && detectedFramework) {
5749
+ framework = detectedFramework;
5750
+ }
5751
+ if (!isInteractive && selectedIdes.length === 0) {
5752
+ selectedIdes = ["cursor"];
5753
+ }
5754
+ if (isInteractive) {
5755
+ console.log(source_default.cyan(`
5756
+ Configuring workspace...`));
5757
+ const frameworkChoices = [
5758
+ { name: "React", value: "react" },
5759
+ { name: "Vue", value: "vue" },
5760
+ { name: "Svelte", value: "svelte" },
5761
+ { name: "Next.js", value: "next" },
5762
+ { name: "Nuxt", value: "nuxt" },
5763
+ { name: "Remotion", value: "remotion" },
5764
+ { name: "Expo / React Native", value: "expo" },
5765
+ { name: "Bun runtime", value: "bun" },
5766
+ { name: "Node.js server", value: "node" },
5767
+ { name: "CLI tool", value: "cli" },
5768
+ { name: "Library / Package", value: "library" },
5769
+ { name: "Animation studio", value: "animation" },
5770
+ { name: "Games", value: "games" },
5771
+ { name: "None / Vanilla", value: "none" }
5772
+ ];
5773
+ framework = await dist_default5({
5774
+ message: detectedFramework ? `What type of project are you building? (detected: ${detectedFramework})` : "What type of project are you building?",
5775
+ choices: frameworkChoices,
5776
+ default: opts.framework || detectedFramework || "none"
5777
+ });
5778
+ const ideChoices = [
5779
+ {
5780
+ name: "Cursor",
5781
+ value: "cursor",
5782
+ checked: selectedIdes.includes("cursor") || selectedIdes.length === 0
5783
+ },
5784
+ {
5785
+ name: "Windsurf",
5786
+ value: "windsurf",
5787
+ checked: selectedIdes.includes("windsurf")
5788
+ },
5789
+ {
5790
+ name: "Claude Desktop",
5791
+ value: "claude",
5792
+ checked: selectedIdes.includes("claude")
5793
+ },
5794
+ {
5795
+ name: "VS Code Copilot",
5796
+ value: "copilot",
5797
+ checked: selectedIdes.includes("copilot")
5798
+ },
5799
+ {
5800
+ name: "Google Gemini (Code Assist)",
5801
+ value: "gemini",
5802
+ checked: selectedIdes.includes("gemini")
5803
+ },
5804
+ {
5805
+ name: "OpenAI Codex",
5806
+ value: "codex",
5807
+ checked: selectedIdes.includes("codex")
5808
+ }
5809
+ ];
5810
+ selectedIdes = await dist_default4({
5811
+ message: "Which IDEs/agents do you want to scaffold for?",
5812
+ choices: ideChoices
5813
+ });
5814
+ footprint = await dist_default5({
5815
+ message: "How minimal do you want your workspace?",
5816
+ choices: [
5817
+ { name: "Minimal (just agent rules)", value: "minimal" },
5818
+ { name: "Standard (includes skills + workflows)", value: "standard" },
5819
+ { name: "Full (kitchen sink)", value: "full" }
5820
+ ],
5821
+ default: footprint
5822
+ });
5823
+ plugins = await dist_default4({
5824
+ message: "Select features:",
5825
+ choices: [
5826
+ {
5827
+ name: "Sub-projects (monorepo, workspaces)",
5828
+ value: "sub-projects",
5829
+ checked: plugins.includes("sub-projects")
5830
+ },
5831
+ { name: "P2P Sync", value: "p2p", checked: plugins.includes("p2p") },
5832
+ {
5833
+ name: "MCP Server",
5834
+ value: "mcp",
5835
+ checked: plugins.includes("mcp")
5836
+ },
5837
+ {
5838
+ name: "UI Components",
5839
+ value: "ui-components",
5840
+ checked: plugins.includes("ui-components")
5841
+ },
5842
+ {
5843
+ name: "Media Pipelines",
5844
+ value: "media-pipelines",
5845
+ checked: plugins.includes("media-pipelines")
5846
+ },
5847
+ {
5848
+ name: "Brand System",
5849
+ value: "brand-system",
5850
+ checked: plugins.includes("brand-system")
5851
+ },
5852
+ {
5853
+ name: "Agent Memory",
5854
+ value: "agent-memory",
5855
+ checked: plugins.includes("agent-memory")
5856
+ },
5857
+ {
5858
+ name: "Workflows",
5859
+ value: "workflows",
5860
+ checked: plugins.includes("workflows") || footprint !== "minimal"
5861
+ }
5862
+ ]
5863
+ });
5864
+ if (plugins.includes("sub-projects") && !plugins.includes("workflows")) {
5865
+ plugins.push("workflows");
5866
+ }
5867
+ }
3661
5868
  const engine = new TrellisVcsEngine({ rootPath });
3662
5869
  let renderedProgress = false;
3663
5870
  const result = await engine.initRepo({
@@ -3667,7 +5874,7 @@ program2.command("init").description("Initialize a new TrellisVCS repository in
3667
5874
  process.stdout.write("\r\x1B[2K");
3668
5875
  return;
3669
5876
  }
3670
- const label = progress.phase === "discovering" ? "Discovering\u2026" : progress.phase === "hashing" ? "Hashing\u2026" : "Scanning\u2026";
5877
+ const label = progress.phase === "discovering" ? "Discovering\u2026" : progress.phase === "hashing" ? "Hashing\u2026" : progress.phase === "scaffolding" ? "Scaffolding\u2026" : "Scanning\u2026";
3671
5878
  process.stdout.write(`\r\x1B[2K ${source_default.dim(label)} ${progress.message}`);
3672
5879
  }
3673
5880
  });
@@ -3675,12 +5882,40 @@ program2.command("init").description("Initialize a new TrellisVCS repository in
3675
5882
  process.stdout.write(`
3676
5883
  `);
3677
5884
  }
5885
+ if (selectedIdes && selectedIdes.length > 0) {
5886
+ for (const selectedIde of selectedIdes) {
5887
+ console.log(source_default.dim(` Scaffolding ${selectedIde} dotfolder...`));
5888
+ writeIdeScaffold(rootPath, {
5889
+ ide: selectedIde,
5890
+ footprint,
5891
+ framework,
5892
+ plugins,
5893
+ rootPath,
5894
+ context: result.context,
5895
+ profile: loadProfile()
5896
+ });
5897
+ }
5898
+ }
3678
5899
  console.log(source_default.green("\u2713 Initialized Trellis repository"));
3679
- console.log(` ${source_default.dim("Path:")} ${rootPath}`);
3680
- console.log(` ${source_default.dim("Ops:")} ${result.opsCreated} initial operations scanned`);
3681
- console.log(` ${source_default.dim("Config:")} .trellis/config.json`);
3682
- console.log(` ${source_default.dim("Op log:")} .trellis/ops.json`);
3683
- console.log(` ${source_default.dim("Graph DB:")} .trellis/graph.db`);
5900
+ console.log(` ${source_default.dim("Path:")} ${rootPath}`);
5901
+ console.log(` ${source_default.dim("Ops:")} ${result.opsCreated} initial operations scanned`);
5902
+ console.log(` ${source_default.dim("Config:")} .trellis/config.json`);
5903
+ console.log(` ${source_default.dim("Op log:")} .trellis/ops.json`);
5904
+ console.log(` ${source_default.dim("Graph DB:")} .trellis/graph.db`);
5905
+ console.log(` ${source_default.dim("Agent context:")} .trellis/agents/AGENTS.md`);
5906
+ if (selectedIdes.length > 0) {
5907
+ const ideFolders = selectedIdes.map((id) => {
5908
+ const ide = id;
5909
+ return ide === "cursor" ? ".cursor" : ide === "windsurf" ? ".windsurf" : ide === "claude" ? ".claude" : ide === "codex" ? ".codex" : ide === "gemini" ? ".gemini" : ".github/copilot";
5910
+ });
5911
+ console.log(` ${source_default.dim("IDE rules:")} ${ideFolders.join(", ")}`);
5912
+ }
5913
+ if (result.context.domain) {
5914
+ console.log(` ${source_default.dim("Domain:")} ${source_default.cyan(result.context.domain)} ${source_default.dim("(inferred)")}`);
5915
+ }
5916
+ if (result.context.ecosystem && result.context.ecosystem !== "unknown") {
5917
+ console.log(` ${source_default.dim("Ecosystem:")} ${result.context.ecosystem}`);
5918
+ }
3684
5919
  console.log();
3685
5920
  console.log(source_default.bold("Next steps:"));
3686
5921
  console.log();
@@ -3690,9 +5925,30 @@ program2.command("init").description("Initialize a new TrellisVCS repository in
3690
5925
  console.log(` ${source_default.cyan("trellis milestone")} Create narrative checkpoints`);
3691
5926
  console.log(` ${source_default.cyan("trellis garden")} Discover abandoned work`);
3692
5927
  console.log(` ${source_default.cyan("trellis issue")} Create and track issues`);
5928
+ if (result.context.confidence !== "high") {
5929
+ console.log(` ${source_default.cyan("trellis season")} Enrich project context for agents`);
5930
+ }
3693
5931
  console.log();
3694
5932
  console.log(source_default.dim("The causal stream is now active. Every file change will be tracked."));
3695
5933
  });
5934
+ program2.command("seed").description("Refresh agent context files with current project state").option("-p, --path <path>", "Repository path", ".").option("--ide <ide>", "IDE to update (cursor, windsurf, claude, copilot)", "none").option("-f, --force", "Force rewrite even if files do not exist", false).action(async (opts) => {
5935
+ const rootPath = resolve(opts.path);
5936
+ requireRepo(rootPath);
5937
+ const ide = opts.ide || "none";
5938
+ const force = opts.force || false;
5939
+ console.log(source_default.dim("Seeding agent context..."));
5940
+ const result = await seedContext({ rootPath, ide, force });
5941
+ if (result.success) {
5942
+ console.log(source_default.green("\u2713 Context seeded"));
5943
+ console.log(` ${source_default.dim("Files updated:")} ${result.filesUpdated.length}`);
5944
+ for (const f of result.filesUpdated) {
5945
+ console.log(` ${source_default.dim("-")} ${f}`);
5946
+ }
5947
+ console.log(` ${source_default.dim("Timestamp:")} ${result.timestamp}`);
5948
+ } else {
5949
+ console.log(source_default.red("\u2717 Failed to seed context"));
5950
+ }
5951
+ });
3696
5952
  program2.command("repair").description("Attempt to repair a corrupted .trellis/ops.json file").option("-p, --path <path>", "Repository path", ".").action((opts) => {
3697
5953
  const rootPath = resolve(opts.path);
3698
5954
  requireRepo(rootPath);
@@ -5060,9 +7316,9 @@ program2.command("ui").description("Launch the interactive graph explorer in you
5060
7316
  console.log(source_default.dim(` Press Ctrl+C to stop
5061
7317
  `));
5062
7318
  if (opts.open !== false) {
5063
- const { exec } = __require("child_process");
7319
+ const { exec: exec2 } = __require("child_process");
5064
7320
  const cmd = process.platform === "darwin" ? "open" : process.platform === "win32" ? "start" : "xdg-open";
5065
- exec(`${cmd} ${url}`);
7321
+ exec2(`${cmd} ${url}`);
5066
7322
  }
5067
7323
  process.on("SIGINT", () => {
5068
7324
  server.stop();
@@ -5436,8 +7692,8 @@ program2.command("repl").description("Interactive EQL-S query shell").option("-p
5436
7692
  console.log(source_default.dim('Type EQL-S queries or "find ?e where attr = value" shorthand.'));
5437
7693
  console.log(source_default.dim(`Type .exit to quit, .help for help.
5438
7694
  `));
5439
- const readline = await import("readline");
5440
- const rl = readline.createInterface({
7695
+ const readline3 = await import("readline");
7696
+ const rl = readline3.createInterface({
5441
7697
  input: process.stdin,
5442
7698
  output: process.stdout,
5443
7699
  prompt: source_default.green("eql> ")
@@ -5760,8 +8016,8 @@ db.command("init").description("Initialize a new Trellis DB in the current direc
5760
8016
  });
5761
8017
  db.command("serve").description("Start the Trellis DB HTTP + WebSocket server").option("-p, --port <port>", "Override port from config").option("--config-dir <dir>", "Directory containing .trellis-db.json", ".").action(async (opts) => {
5762
8018
  const { readConfig } = await import("../config-8hczw0rs.js");
5763
- const { TenantPool } = await import("../tenancy-tjr7kk2v.js");
5764
- const { startServer } = await import("../server-3vkpnpbz.js");
8019
+ const { TenantPool } = await import("../tenancy-7d1g4ayp.js");
8020
+ const { startServer } = await import("../server-mrctdwzr.js");
5765
8021
  const config = readConfig(opts.configDir);
5766
8022
  if (!config) {
5767
8023
  console.error(source_default.red("No .trellis-db.json found. Run `trellis db init` first."));
@@ -5782,7 +8038,7 @@ db.command("serve").description("Start the Trellis DB HTTP + WebSocket server").
5782
8038
  }
5783
8039
  });
5784
8040
  db.command("create <type> [json]").description("Create an entity (json can be a JSON string or @file.json)").option("--config-dir <dir>", "Config directory", ".").option("--tenant <id>", "Tenant ID").action(async (type, jsonArg, opts) => {
5785
- const { TrellisDb } = await import("../sdk-sj8rp0m7.js");
8041
+ const { TrellisDb } = await import("../sdk-snn5gad3.js");
5786
8042
  const db2 = TrellisDb.fromConfig(opts.configDir);
5787
8043
  let attributes = {};
5788
8044
  if (jsonArg) {
@@ -5795,7 +8051,7 @@ db.command("create <type> [json]").description("Create an entity (json can be a
5795
8051
  db2.close();
5796
8052
  });
5797
8053
  db.command("read <id>").description("Read an entity by ID").option("--config-dir <dir>", "Config directory", ".").action(async (id, opts) => {
5798
- const { TrellisDb } = await import("../sdk-sj8rp0m7.js");
8054
+ const { TrellisDb } = await import("../sdk-snn5gad3.js");
5799
8055
  const db2 = TrellisDb.fromConfig(opts.configDir);
5800
8056
  const entity = await db2.read(id);
5801
8057
  if (!entity) {
@@ -5806,7 +8062,7 @@ db.command("read <id>").description("Read an entity by ID").option("--config-dir
5806
8062
  db2.close();
5807
8063
  });
5808
8064
  db.command("update <id> <json>").description("Update entity attributes (JSON string or @file.json)").option("--config-dir <dir>", "Config directory", ".").action(async (id, jsonArg, opts) => {
5809
- const { TrellisDb } = await import("../sdk-sj8rp0m7.js");
8065
+ const { TrellisDb } = await import("../sdk-snn5gad3.js");
5810
8066
  const db2 = TrellisDb.fromConfig(opts.configDir);
5811
8067
  const { readFileSync: readFileSync4 } = await import("fs");
5812
8068
  const raw = jsonArg.startsWith("@") ? readFileSync4(jsonArg.slice(1), "utf8") : jsonArg;
@@ -5815,14 +8071,14 @@ db.command("update <id> <json>").description("Update entity attributes (JSON str
5815
8071
  db2.close();
5816
8072
  });
5817
8073
  db.command("delete <id>").description("Delete an entity by ID").option("--config-dir <dir>", "Config directory", ".").action(async (id, opts) => {
5818
- const { TrellisDb } = await import("../sdk-sj8rp0m7.js");
8074
+ const { TrellisDb } = await import("../sdk-snn5gad3.js");
5819
8075
  const db2 = TrellisDb.fromConfig(opts.configDir);
5820
8076
  await db2.delete(id);
5821
8077
  console.log(source_default.green(`\u2713 Deleted: ${source_default.bold(id)}`));
5822
8078
  db2.close();
5823
8079
  });
5824
8080
  db.command("list").description("List entities").option("--type <type>", "Filter by entity type").option("--limit <n>", "Max results", "50").option("--offset <n>", "Offset", "0").option("--config-dir <dir>", "Config directory", ".").action(async (opts) => {
5825
- const { TrellisDb } = await import("../sdk-sj8rp0m7.js");
8081
+ const { TrellisDb } = await import("../sdk-snn5gad3.js");
5826
8082
  const db2 = TrellisDb.fromConfig(opts.configDir);
5827
8083
  const result = await db2.list(opts.type, {
5828
8084
  limit: parseInt(opts.limit),
@@ -5832,7 +8088,7 @@ db.command("list").description("List entities").option("--type <type>", "Filter
5832
8088
  db2.close();
5833
8089
  });
5834
8090
  db.command("query <eql>").description("Run an EQL-S query").option("--config-dir <dir>", "Config directory", ".").action(async (eql, opts) => {
5835
- const { TrellisDb } = await import("../sdk-sj8rp0m7.js");
8091
+ const { TrellisDb } = await import("../sdk-snn5gad3.js");
5836
8092
  const db2 = TrellisDb.fromConfig(opts.configDir);
5837
8093
  const result = await db2.query(eql);
5838
8094
  console.log(JSON.stringify(result.bindings, null, 2));
@@ -5842,7 +8098,7 @@ db.command("query <eql>").description("Run an EQL-S query").option("--config-dir
5842
8098
  db.command("upload <file>").description("Upload a file to the blob store").option("--config-dir <dir>", "Config directory", ".").option("--type <mime>", "MIME type (auto-detected if omitted)").action(async (filePath, opts) => {
5843
8099
  const { readFileSync: readFileSync4 } = await import("fs");
5844
8100
  const { extname } = await import("path");
5845
- const { TrellisDb } = await import("../sdk-sj8rp0m7.js");
8101
+ const { TrellisDb } = await import("../sdk-snn5gad3.js");
5846
8102
  const mimeMap = {
5847
8103
  ".png": "image/png",
5848
8104
  ".jpg": "image/jpeg",
@@ -5863,8 +8119,8 @@ db.command("upload <file>").description("Upload a file to the blob store").optio
5863
8119
  });
5864
8120
  db.command("import <file>").description("Import data from CSV, JSON, NDJSON, or Parquet").requiredOption("--type <type>", "Entity type to assign to each record").option("--id-field <field>", "Field to use as entity ID").option("--limit <n>", "Max rows to import").option("--config-dir <dir>", "Config directory", ".").option("--tenant <id>", "Tenant ID").action(async (filePath, opts) => {
5865
8121
  const { readConfig } = await import("../config-8hczw0rs.js");
5866
- const { TenantPool } = await import("../tenancy-tjr7kk2v.js");
5867
- const { importFile } = await import("../import-fyg5sgq4.js");
8122
+ const { TenantPool } = await import("../tenancy-7d1g4ayp.js");
8123
+ const { importFile } = await import("../import-s2b8e0ft.js");
5868
8124
  const config = readConfig(opts.configDir);
5869
8125
  if (!config?.dbPath) {
5870
8126
  console.error(source_default.red("No .trellis-db.json found. Run `trellis db init` first."));
@@ -5889,7 +8145,7 @@ db.command("import <file>").description("Import data from CSV, JSON, NDJSON, or
5889
8145
  pool.closeAll();
5890
8146
  });
5891
8147
  db.command("deploy").description("Deploy Trellis DB to a Sprites cloud environment").requiredOption("--name <name>", "Sprite name (becomes <name>.sprites.app)").option("--key <key>", "API key for the deployed server (auto-generated if omitted)").option("--jwt-secret <secret>", "JWT secret (auto-generated if omitted)").option("--port <port>", "Port to run on inside Sprite", "3000").option("--config-dir <dir>", "Config directory", ".").action(async (opts) => {
5892
- const { deploy } = await import("../deploy-99j5dc9c.js");
8148
+ const { deploy } = await import("../deploy-999q207z.js");
5893
8149
  const { readConfig } = await import("../config-8hczw0rs.js");
5894
8150
  const config = readConfig(opts.configDir);
5895
8151
  console.log(source_default.bold(`Deploying to Sprites: ${opts.name}...`));
@@ -5916,4 +8172,514 @@ db.command("deploy").description("Deploy Trellis DB to a Sprites cloud environme
5916
8172
  process.exit(1);
5917
8173
  }
5918
8174
  });
8175
+ var vmProgram = new Command("vm");
8176
+ vmProgram.description("Manage Sprites VMs").option("-s, --sprite <name>", "Sprite name to operate on");
8177
+ async function getSpriteName(spriteOption) {
8178
+ if (spriteOption)
8179
+ return spriteOption;
8180
+ const { getActiveSprite } = await import("../vm-config-6xhsj6b3.js");
8181
+ const active = getActiveSprite();
8182
+ if (active)
8183
+ return active;
8184
+ throw new Error("No sprite specified. Use --sprite <name> or set an active sprite with `trellis vm use <name>`");
8185
+ }
8186
+ vmProgram.command("create <name>").description("Create a new Sprite and deploy Trellis DB").option("-k, --api-key <key>", "API key (auto-generated if omitted)").option("-p, --port <port>", "Port (default: 3000)", "3000").action(async (name, cmdOpts) => {
8187
+ const { runSpriteCmd, assertSpriteCli } = await import("../sprites-vc4qbrp1.js");
8188
+ const { trackSprite } = await import("../vm-config-6xhsj6b3.js");
8189
+ const { deploy } = await import("../deploy-999q207z.js");
8190
+ try {
8191
+ await assertSpriteCli();
8192
+ console.log(`Creating Sprite: ${name}...`);
8193
+ await runSpriteCmd(["exec", "--sprite", name, "echo", "Sprite created"]);
8194
+ console.log(`Deploying Trellis DB to ${name}...`);
8195
+ const result = await deploy({
8196
+ name,
8197
+ apiKey: cmdOpts.apiKey,
8198
+ port: parseInt(cmdOpts.port),
8199
+ onProgress: (msg) => console.log(source_default.dim(` ${msg}`))
8200
+ });
8201
+ trackSprite(name, {
8202
+ url: result.url,
8203
+ hasTrellis: true,
8204
+ apiKey: result.apiKey
8205
+ });
8206
+ console.log("");
8207
+ console.log(source_default.green(`\u2713 Sprite ${name} created and Trellis DB deployed`));
8208
+ console.log(source_default.dim(` URL: ${result.url}`));
8209
+ console.log(source_default.dim(` Key: ${result.apiKey}`));
8210
+ console.log("");
8211
+ } catch (err) {
8212
+ console.error(source_default.red(`Failed: ${err.message}`));
8213
+ process.exit(1);
8214
+ }
8215
+ });
8216
+ vmProgram.command("list").description("List all tracked Sprites").action(async () => {
8217
+ const { loadVmConfig } = await import("../vm-config-6xhsj6b3.js");
8218
+ const config = loadVmConfig();
8219
+ const sprites = config.sprites;
8220
+ if (Object.keys(sprites).length === 0) {
8221
+ console.log("No Sprites tracked. Use `trellis vm create <name>` to create one.");
8222
+ return;
8223
+ }
8224
+ console.log("Tracked Sprites:");
8225
+ for (const [name, sprite] of Object.entries(sprites)) {
8226
+ const activeMarker = config.activeSprite === name ? source_default.green("*") : " ";
8227
+ const trellisStatus = sprite.hasTrellis ? source_default.green("\u2713 Trellis") : source_default.dim("\u25CB No Trellis");
8228
+ console.log(`${activeMarker} ${name} ${trellisStatus}`);
8229
+ console.log(` URL: ${sprite.url}`);
8230
+ if (sprite.lastCheckpoint) {
8231
+ console.log(` Last Checkpoint: ${sprite.lastCheckpoint}`);
8232
+ }
8233
+ console.log();
8234
+ }
8235
+ });
8236
+ vmProgram.command("use <name>").description("Set the active Sprite").action(async (name) => {
8237
+ const { runSpriteCmd, assertSpriteCli } = await import("../sprites-vc4qbrp1.js");
8238
+ const { setActiveSprite } = await import("../vm-config-6xhsj6b3.js");
8239
+ try {
8240
+ await assertSpriteCli();
8241
+ try {
8242
+ await runSpriteCmd(["list"]);
8243
+ } catch {
8244
+ throw new Error(`Sprite ${name} does not exist`);
8245
+ }
8246
+ setActiveSprite(name);
8247
+ console.log(source_default.green(`\u2713 Active Sprite set to: ${name}`));
8248
+ } catch (err) {
8249
+ console.error(source_default.red(`Failed: ${err.message}`));
8250
+ process.exit(1);
8251
+ }
8252
+ });
8253
+ vmProgram.command("destroy <name>").description("Destroy a Sprite").action(async (name) => {
8254
+ const { runSpriteCmd, assertSpriteCli } = await import("../sprites-vc4qbrp1.js");
8255
+ const { untrackSprite } = await import("../vm-config-6xhsj6b3.js");
8256
+ try {
8257
+ await assertSpriteCli();
8258
+ const { createInterface: createInterface2 } = await import("readline");
8259
+ const rl = createInterface2({
8260
+ input: process.stdin,
8261
+ output: process.stdout
8262
+ });
8263
+ const answer = await new Promise((resolve2) => {
8264
+ rl.question(`Destroy Sprite "${name}"? Cannot be undone. (y/N) `, (a) => {
8265
+ rl.close();
8266
+ resolve2(a.trim().toLowerCase());
8267
+ });
8268
+ });
8269
+ if (answer !== "y" && answer !== "yes") {
8270
+ console.log("Cancelled.");
8271
+ return;
8272
+ }
8273
+ await runSpriteCmd(["destroy", "-s", name, "-y"]);
8274
+ untrackSprite(name);
8275
+ console.log(source_default.green(`\u2713 Sprite ${name} destroyed`));
8276
+ } catch (err) {
8277
+ console.error(source_default.red(`Failed: ${err.message}`));
8278
+ process.exit(1);
8279
+ }
8280
+ });
8281
+ vmProgram.command("exec <command...>").description("Execute a command on the active Sprite").action(async (command) => {
8282
+ const { runSpriteInteractive, assertSpriteCli } = await import("../sprites-vc4qbrp1.js");
8283
+ try {
8284
+ const spriteName = await getSpriteName(vmProgram.opts().sprite);
8285
+ console.log(`Executing on ${spriteName}: ${command.join(" ")}`);
8286
+ await runSpriteInteractive(["exec", "--sprite", spriteName, ...command]);
8287
+ } catch (err) {
8288
+ console.error(source_default.red(`Failed: ${err.message}`));
8289
+ process.exit(1);
8290
+ }
8291
+ });
8292
+ vmProgram.command("console").description("Open an interactive console on the active Sprite").action(async () => {
8293
+ const { runSpriteInteractive, assertSpriteCli } = await import("../sprites-vc4qbrp1.js");
8294
+ try {
8295
+ const spriteName = await getSpriteName(vmProgram.opts().sprite);
8296
+ console.log(`Opening console on ${spriteName}...`);
8297
+ await runSpriteInteractive(["console", "--sprite", spriteName]);
8298
+ } catch (err) {
8299
+ console.error(source_default.red(`Failed: ${err.message}`));
8300
+ process.exit(1);
8301
+ }
8302
+ });
8303
+ vmProgram.command("sessions").description("Manage Sprite sessions").argument("<action>", "Action: list, attach, or kill").argument("[sessionId]", "Session ID (required for attach/kill)").action(async (action, sessionId) => {
8304
+ const { runSpriteCmd, runSpriteInteractive, assertSpriteCli } = await import("../sprites-vc4qbrp1.js");
8305
+ try {
8306
+ const spriteName = await getSpriteName(vmProgram.opts().sprite);
8307
+ switch (action) {
8308
+ case "list":
8309
+ await runSpriteCmd(["sessions", "list", "--sprite", spriteName]);
8310
+ break;
8311
+ case "attach":
8312
+ if (!sessionId)
8313
+ throw new Error("Session ID required for attach");
8314
+ await runSpriteInteractive([
8315
+ "sessions",
8316
+ "attach",
8317
+ "--sprite",
8318
+ spriteName,
8319
+ sessionId
8320
+ ]);
8321
+ break;
8322
+ case "kill":
8323
+ if (!sessionId)
8324
+ throw new Error("Session ID required for kill");
8325
+ await runSpriteCmd([
8326
+ "sessions",
8327
+ "kill",
8328
+ "--sprite",
8329
+ spriteName,
8330
+ sessionId
8331
+ ]);
8332
+ console.log(source_default.green(`\u2713 Killed session ${sessionId}`));
8333
+ break;
8334
+ default:
8335
+ throw new Error(`Invalid action: ${action}`);
8336
+ }
8337
+ } catch (err) {
8338
+ console.error(source_default.red(`Failed: ${err.message}`));
8339
+ process.exit(1);
8340
+ }
8341
+ });
8342
+ vmProgram.command("url").description("Get or update the URL for the active Sprite").option("--public", "Get public URL (default)").option("--private", "Get private URL").option("--update-auth", "Update authentication").action(async (cmdOpts) => {
8343
+ const { runSpriteCmd, assertSpriteCli } = await import("../sprites-vc4qbrp1.js");
8344
+ try {
8345
+ const spriteName = await getSpriteName(vmProgram.opts().sprite);
8346
+ if (cmdOpts.updateAuth) {
8347
+ await runSpriteCmd(["url", "update", "--auth", "--sprite", spriteName]);
8348
+ console.log(source_default.green(`\u2713 Updated authentication for ${spriteName}`));
8349
+ } else {
8350
+ const urlType = cmdOpts.private ? "private" : "public";
8351
+ const url = await runSpriteCmd([
8352
+ "url",
8353
+ urlType,
8354
+ "--sprite",
8355
+ spriteName
8356
+ ]);
8357
+ console.log(url.trim());
8358
+ }
8359
+ } catch (err) {
8360
+ console.error(source_default.red(`Failed: ${err.message}`));
8361
+ process.exit(1);
8362
+ }
8363
+ });
8364
+ vmProgram.command("proxy <ports...>").description("Proxy local ports to the active Sprite").action(async (ports) => {
8365
+ const { runSpriteInteractive, assertSpriteCli } = await import("../sprites-vc4qbrp1.js");
8366
+ try {
8367
+ const spriteName = await getSpriteName(vmProgram.opts().sprite);
8368
+ console.log(`Proxying ports ${ports.join(", ")} to ${spriteName}...`);
8369
+ await runSpriteInteractive(["proxy", "--sprite", spriteName, ...ports]);
8370
+ } catch (err) {
8371
+ console.error(source_default.red(`Failed: ${err.message}`));
8372
+ process.exit(1);
8373
+ }
8374
+ });
8375
+ vmProgram.command("checkpoint").description("Manage Sprite checkpoints").argument("<action>", "Action: create, list, or restore").option("-m, --milestone <msg>", "Message for linked milestone (create only)").option("-c, --checkpoint <id>", "Checkpoint ID (restore only)").action(async (action, cmdOpts) => {
8376
+ const { runSpriteCmd, assertSpriteCli } = await import("../sprites-vc4qbrp1.js");
8377
+ const { loadVmConfig, trackSprite } = await import("../vm-config-6xhsj6b3.js");
8378
+ try {
8379
+ const spriteName = await getSpriteName(vmProgram.opts().sprite);
8380
+ switch (action) {
8381
+ case "create":
8382
+ console.log(`Creating checkpoint for ${spriteName}...`);
8383
+ const output = await runSpriteCmd([
8384
+ "checkpoint",
8385
+ "create",
8386
+ "--sprite",
8387
+ spriteName
8388
+ ]);
8389
+ const match = output.match(/checkpoint-(\S+)\s+created/);
8390
+ const checkpointId = match ? match[1] : null;
8391
+ let milestoneId;
8392
+ if (cmdOpts.milestone) {
8393
+ milestoneId = `milestone-${Date.now()}`;
8394
+ console.log(`Would create milestone: ${cmdOpts.milestone}`);
8395
+ }
8396
+ const config = loadVmConfig();
8397
+ const spriteConfig = config.sprites[spriteName];
8398
+ trackSprite(spriteName, {
8399
+ ...spriteConfig,
8400
+ lastCheckpoint: checkpointId ?? undefined,
8401
+ linkedMilestone: milestoneId
8402
+ });
8403
+ console.log(source_default.green(`\u2713 Checkpoint: ${checkpointId || "unknown"}`));
8404
+ break;
8405
+ case "list":
8406
+ await runSpriteCmd(["checkpoint", "list", "--sprite", spriteName]);
8407
+ break;
8408
+ case "restore":
8409
+ if (!cmdOpts.checkpoint)
8410
+ throw new Error("Checkpoint ID required: --checkpoint <id>");
8411
+ await runSpriteCmd([
8412
+ "checkpoint",
8413
+ "restore",
8414
+ "--sprite",
8415
+ spriteName,
8416
+ cmdOpts.checkpoint
8417
+ ]);
8418
+ console.log(source_default.green(`\u2713 Restored: ${cmdOpts.checkpoint}`));
8419
+ break;
8420
+ default:
8421
+ throw new Error(`Invalid action: ${action}`);
8422
+ }
8423
+ } catch (err) {
8424
+ console.error(source_default.red(`Failed: ${err.message}`));
8425
+ process.exit(1);
8426
+ }
8427
+ });
8428
+ vmProgram.command("cp <src> <dest>").description("Copy files (use :prefix for remote paths)").action(async (src, dest) => {
8429
+ const { runSpriteCmd, runSpriteCopy, assertSpriteCli } = await import("../sprites-vc4qbrp1.js");
8430
+ try {
8431
+ const spriteName = await getSpriteName(vmProgram.opts().sprite);
8432
+ const isToSprite = !src.startsWith(":") && dest.startsWith(":");
8433
+ const isFromSprite = src.startsWith(":") && !dest.startsWith(":");
8434
+ if (isToSprite) {
8435
+ await runSpriteCopy(src, spriteName, dest.slice(1));
8436
+ console.log(source_default.green(`\u2713 Copied ${src} to ${spriteName}:${dest.slice(1)}`));
8437
+ } else if (isFromSprite) {
8438
+ await runSpriteCopy(src.slice(1), spriteName, dest);
8439
+ console.log(source_default.green(`\u2713 Copied ${spriteName}:${src.slice(1)} to ${dest}`));
8440
+ } else {
8441
+ await runSpriteCmd(["cp", src, dest]);
8442
+ console.log(source_default.green(`\u2713 Copied ${src} to ${dest}`));
8443
+ }
8444
+ } catch (err) {
8445
+ console.error(source_default.red(`Failed: ${err.message}`));
8446
+ process.exit(1);
8447
+ }
8448
+ });
8449
+ vmProgram.command("status").description("Show detailed status of the active Sprite").action(async () => {
8450
+ const { runSpriteCmd, assertSpriteCli } = await import("../sprites-vc4qbrp1.js");
8451
+ const { loadVmConfig } = await import("../vm-config-6xhsj6b3.js");
8452
+ try {
8453
+ const spriteName = await getSpriteName(vmProgram.opts().sprite);
8454
+ const config = loadVmConfig();
8455
+ const spriteConfig = config.sprites[spriteName];
8456
+ if (!spriteConfig) {
8457
+ console.log(source_default.red(`Sprite ${spriteName} not in config`));
8458
+ return;
8459
+ }
8460
+ console.log(`Status for: ${source_default.cyan(spriteName)}`);
8461
+ console.log(` Active: ${config.activeSprite === spriteName ? source_default.green("yes") : source_default.dim("no")}`);
8462
+ console.log(` URL: ${spriteConfig.url}`);
8463
+ console.log(` Trellis: ${spriteConfig.hasTrellis ? source_default.green("yes") : source_default.dim("no")}`);
8464
+ if (spriteConfig.hasTrellis) {
8465
+ console.log(` API Key: ${spriteConfig.apiKey ?? source_default.dim("not available")}`);
8466
+ }
8467
+ if (spriteConfig.lastCheckpoint) {
8468
+ console.log(` Checkpoint: ${spriteConfig.lastCheckpoint}`);
8469
+ }
8470
+ } catch (err) {
8471
+ console.error(source_default.red(`Failed: ${err.message}`));
8472
+ process.exit(1);
8473
+ }
8474
+ });
8475
+ vmProgram.command("code [name]").description("Create Sprite, deploy Trellis, open in browser").action(async (nameOpt) => {
8476
+ const { runSpriteCmd, assertSpriteCli } = await import("../sprites-vc4qbrp1.js");
8477
+ const { loadVmConfig, trackSprite, getActiveSprite } = await import("../vm-config-6xhsj6b3.js");
8478
+ const { deploy } = await import("../deploy-999q207z.js");
8479
+ const openUrl = (url) => {
8480
+ if (process.platform === "darwin") {
8481
+ Bun.spawn(["open", url], { stdio: "ignore" });
8482
+ } else if (process.platform === "linux") {
8483
+ Bun.spawn(["xdg-open", url], { stdio: "ignore" });
8484
+ } else {
8485
+ console.log(url);
8486
+ }
8487
+ };
8488
+ try {
8489
+ await assertSpriteCli();
8490
+ const spriteName = nameOpt || getActiveSprite();
8491
+ if (!spriteName) {
8492
+ throw new Error("No sprite name and no active sprite. Use `trellis vm use <name>` first.");
8493
+ }
8494
+ try {
8495
+ await runSpriteCmd(["list"]);
8496
+ } catch {
8497
+ console.log(`Creating ${spriteName}...`);
8498
+ await runSpriteCmd(["exec", "--sprite", spriteName, "echo", "created"]);
8499
+ }
8500
+ const config = loadVmConfig();
8501
+ const spriteConfig = config.sprites[spriteName];
8502
+ if (!spriteConfig?.hasTrellis) {
8503
+ console.log(`Deploying Trellis to ${spriteName}...`);
8504
+ const result = await deploy({
8505
+ name: spriteName,
8506
+ onProgress: (msg) => console.log(source_default.dim(` ${msg}`))
8507
+ });
8508
+ trackSprite(spriteName, {
8509
+ url: result.url,
8510
+ hasTrellis: true,
8511
+ apiKey: result.apiKey
8512
+ });
8513
+ console.log(source_default.green(`\u2713 Deployed`));
8514
+ }
8515
+ const url = spriteConfig?.url || `https://${spriteName}.sprites.app`;
8516
+ console.log(`Opening ${url}...`);
8517
+ openUrl(url);
8518
+ } catch (err) {
8519
+ console.error(source_default.red(`Failed: ${err.message}`));
8520
+ process.exit(1);
8521
+ }
8522
+ });
8523
+ program2.addCommand(vmProgram);
8524
+ program2.command("season").description("Enrich project context for agents \u2014 interactive Q&A").option("-p, --path <path>", "Repository path", ".").option("--reset", "Re-run even if previously configured").action(async (opts) => {
8525
+ const rootPath = resolve(opts.path);
8526
+ requireRepo(rootPath);
8527
+ const { createInterface: createInterface2 } = await import("readline");
8528
+ const rl = createInterface2({
8529
+ input: process.stdin,
8530
+ output: process.stdout
8531
+ });
8532
+ const ask = (q) => new Promise((r) => rl.question(q, (a) => r(a.trim())));
8533
+ const context = await inferProjectContext(rootPath);
8534
+ console.log(source_default.bold(`
8535
+ Trellis Season \u2014 let's enrich your project context
8536
+ `));
8537
+ console.log(source_default.dim(` Current domain: ${context.domain ?? "(none)"}`));
8538
+ console.log(source_default.dim(` Current ecosystem: ${context.ecosystem ?? "(none)"}
8539
+ `));
8540
+ const domain = await ask(` What domain does this project serve? [${context.domain ?? ""}]: `);
8541
+ const description = await ask(` One-sentence description: [${context.description ?? ""}]: `);
8542
+ const toolsRaw = await ask(" Key tools or frameworks (comma-separated): ");
8543
+ const ontologiesRaw = await ask(" Domain ontologies to register (comma-separated, or skip): ");
8544
+ rl.close();
8545
+ const updatedContext = {
8546
+ ...context,
8547
+ domain: domain || context.domain,
8548
+ description: description || context.description
8549
+ };
8550
+ const profile = loadProfile();
8551
+ writeAgentScaffold(rootPath, { profile, context: updatedContext });
8552
+ const agentContextPath = join6(rootPath, ".trellis", "agents", "agent-context.json");
8553
+ try {
8554
+ const { readFileSync: readFileSync4, writeFileSync: writeFileSync3 } = await import("fs");
8555
+ const existing = JSON.parse(readFileSync4(agentContextPath, "utf-8"));
8556
+ existing.domain = updatedContext.domain;
8557
+ if (toolsRaw) {
8558
+ existing.tools = toolsRaw.split(",").map((s) => s.trim()).filter(Boolean);
8559
+ }
8560
+ if (ontologiesRaw) {
8561
+ existing.ontologies = ontologiesRaw.split(",").map((s) => s.trim()).filter(Boolean);
8562
+ }
8563
+ existing.generatedAt = new Date().toISOString();
8564
+ existing.confidence = "high";
8565
+ writeFileSync3(agentContextPath, JSON.stringify(existing, null, 2));
8566
+ } catch {}
8567
+ console.log();
8568
+ console.log(source_default.green("\u2713 Project context updated"));
8569
+ console.log(` ${source_default.dim("AGENTS.md:")} .trellis/agents/AGENTS.md`);
8570
+ console.log(` ${source_default.dim("Agent config:")} .trellis/agents/agent-context.json`);
8571
+ if (updatedContext.domain) {
8572
+ console.log(` ${source_default.dim("Domain:")} ${source_default.cyan(updatedContext.domain)}`);
8573
+ }
8574
+ console.log();
8575
+ });
8576
+ program2.command("code").alias("ide").description('Launch OpenCode in "Harness" mode, bridged to this Trellis repository').option("-p, --path <path>", "Repository path", ".").option("-m, --model <model>", "OpenCode model to use").option("-w, --web", "Launch MCP server in HTTP mode for web client access").option("--mcp-port <port>", "MCP HTTP server port (default: 3333)", "3333").action(async (opts) => {
8577
+ const { resolve: resolve2, dirname: dirname6, join: join7 } = await import("path");
8578
+ const { existsSync: existsSync6 } = await import("fs");
8579
+ const { spawn } = await import("child_process");
8580
+ const rootPath = resolve2(opts.path);
8581
+ if (!TrellisVcsEngine.isRepo(rootPath)) {
8582
+ console.log(source_default.dim("Not a Trellis workspace \u2014 initializing\u2026"));
8583
+ const engine = new TrellisVcsEngine({ rootPath });
8584
+ await engine.initRepo();
8585
+ console.log(source_default.green("\u2713 Initialized Trellis repository"));
8586
+ }
8587
+ function findOpencode() {
8588
+ const here = dirname6(process.argv[1]);
8589
+ const candidates = [
8590
+ join7(here, "..", "node_modules", ".bin", "opencode"),
8591
+ join7(here, "..", "..", "node_modules", ".bin", "opencode")
8592
+ ];
8593
+ let dir = here;
8594
+ for (let i = 0;i < 5; i++) {
8595
+ const p = join7(dir, "node_modules", ".bin", "opencode");
8596
+ if (existsSync6(p))
8597
+ return p;
8598
+ dir = dirname6(dir);
8599
+ }
8600
+ for (const p of candidates) {
8601
+ if (existsSync6(p))
8602
+ return p;
8603
+ }
8604
+ return null;
8605
+ }
8606
+ function findMcpServer() {
8607
+ const here = dirname6(process.argv[1]);
8608
+ const candidates = [
8609
+ join7(here, "..", "..", "src", "mcp", "index.ts"),
8610
+ join7(here, "..", "src", "mcp", "index.ts"),
8611
+ join7(here, "..", "..", "..", "src", "mcp", "index.ts"),
8612
+ join7(here, "..", "mcp", "index.js"),
8613
+ join7(here, "..", "mcp", "index.ts"),
8614
+ join7(here, "mcp", "index.ts")
8615
+ ];
8616
+ for (const p of candidates) {
8617
+ if (existsSync6(p))
8618
+ return p;
8619
+ }
8620
+ return null;
8621
+ }
8622
+ const opencode = findOpencode();
8623
+ if (!opencode) {
8624
+ console.error(source_default.red("OpenCode not found. Try running `bun install` or `npm install -g opencode-ai`."));
8625
+ process.exit(1);
8626
+ }
8627
+ const mcp = findMcpServer();
8628
+ if (!mcp) {
8629
+ console.error(source_default.red("Trellis MCP server not found."));
8630
+ process.exit(1);
8631
+ }
8632
+ const mcpPort = parseInt(opts.mcpPort, 10) || 3333;
8633
+ const mcpUrl = `http://localhost:${mcpPort}`;
8634
+ console.log(source_default.green(`\u26A1 Spinning up Trellis Agentic Harness...`));
8635
+ console.log(source_default.dim(` Root: ${rootPath}`));
8636
+ console.log(source_default.dim(` MCP: ${mcp}`));
8637
+ console.log(source_default.dim(` Agent: OpenCode`));
8638
+ if (opts.web) {
8639
+ console.log(source_default.dim(` Web: ${mcpUrl}`));
8640
+ }
8641
+ console.log("");
8642
+ const args = [rootPath];
8643
+ if (opts.model) {
8644
+ args.push("--model", opts.model);
8645
+ }
8646
+ const mcpServers = {
8647
+ mcpServers: {
8648
+ "trellis-vcs": {
8649
+ command: "bun",
8650
+ args: opts.web ? [
8651
+ "run",
8652
+ mcp,
8653
+ "--quiet",
8654
+ "--path",
8655
+ rootPath,
8656
+ "--http",
8657
+ "--port",
8658
+ String(mcpPort)
8659
+ ] : ["run", mcp, "--quiet", "--path", rootPath]
8660
+ }
8661
+ }
8662
+ };
8663
+ const child = spawn(opencode, args, {
8664
+ stdio: "inherit",
8665
+ env: {
8666
+ ...process.env,
8667
+ OPENCODE_MCP_CONFIG: JSON.stringify(mcpServers),
8668
+ OPENCODE_THEME: "everforest",
8669
+ OPENCODE_ACCENT_COLOR: "#a7c080",
8670
+ OPENCODE_HEADER_TEXT: "\uD83C\uDF3F trellis harness",
8671
+ OPENCODE_BRAND_LOGO: "trellis"
8672
+ }
8673
+ });
8674
+ child.on("exit", (code) => {
8675
+ if (code === 0) {
8676
+ console.log(source_default.green(`
8677
+ \u2713 Agentic session complete.`));
8678
+ } else {
8679
+ console.log(source_default.yellow(`
8680
+ \u26A0 Agent session exited with code ${code}`));
8681
+ }
8682
+ process.exit(code ?? 0);
8683
+ });
8684
+ });
5919
8685
  program2.parse();