@pixelfactoryio/theway 0.10.0 → 0.12.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/theway.js CHANGED
@@ -1,5 +1,35 @@
1
1
  #!/usr/bin/env node
2
2
  import { createRequire } from "node:module";
3
+ var __create = Object.create;
4
+ var __getProtoOf = Object.getPrototypeOf;
5
+ var __defProp = Object.defineProperty;
6
+ var __getOwnPropNames = Object.getOwnPropertyNames;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ function __accessProp(key) {
9
+ return this[key];
10
+ }
11
+ var __toESMCache_node;
12
+ var __toESMCache_esm;
13
+ var __toESM = (mod, isNodeMode, target) => {
14
+ var canCache = mod != null && typeof mod === "object";
15
+ if (canCache) {
16
+ var cache = isNodeMode ? __toESMCache_node ??= new WeakMap : __toESMCache_esm ??= new WeakMap;
17
+ var cached = cache.get(mod);
18
+ if (cached)
19
+ return cached;
20
+ }
21
+ target = mod != null ? __create(__getProtoOf(mod)) : {};
22
+ const to = isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target;
23
+ for (let key of __getOwnPropNames(mod))
24
+ if (!__hasOwnProp.call(to, key))
25
+ __defProp(to, key, {
26
+ get: __accessProp.bind(mod, key),
27
+ enumerable: true
28
+ });
29
+ if (canCache)
30
+ cache.set(mod, to);
31
+ return to;
32
+ };
3
33
  var __commonJS = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
4
34
  var __require = /* @__PURE__ */ createRequire(import.meta.url);
5
35
 
@@ -6945,6 +6975,64 @@ var require_public_api = __commonJS((exports) => {
6945
6975
  exports.stringify = stringify;
6946
6976
  });
6947
6977
 
6978
+ // node_modules/sisteransi/src/index.js
6979
+ var require_src = __commonJS((exports, module) => {
6980
+ var ESC2 = "\x1B";
6981
+ var CSI2 = `${ESC2}[`;
6982
+ var beep = "\x07";
6983
+ var cursor = {
6984
+ to(x, y) {
6985
+ if (!y)
6986
+ return `${CSI2}${x + 1}G`;
6987
+ return `${CSI2}${y + 1};${x + 1}H`;
6988
+ },
6989
+ move(x, y) {
6990
+ let ret = "";
6991
+ if (x < 0)
6992
+ ret += `${CSI2}${-x}D`;
6993
+ else if (x > 0)
6994
+ ret += `${CSI2}${x}C`;
6995
+ if (y < 0)
6996
+ ret += `${CSI2}${-y}A`;
6997
+ else if (y > 0)
6998
+ ret += `${CSI2}${y}B`;
6999
+ return ret;
7000
+ },
7001
+ up: (count = 1) => `${CSI2}${count}A`,
7002
+ down: (count = 1) => `${CSI2}${count}B`,
7003
+ forward: (count = 1) => `${CSI2}${count}C`,
7004
+ backward: (count = 1) => `${CSI2}${count}D`,
7005
+ nextLine: (count = 1) => `${CSI2}E`.repeat(count),
7006
+ prevLine: (count = 1) => `${CSI2}F`.repeat(count),
7007
+ left: `${CSI2}G`,
7008
+ hide: `${CSI2}?25l`,
7009
+ show: `${CSI2}?25h`,
7010
+ save: `${ESC2}7`,
7011
+ restore: `${ESC2}8`
7012
+ };
7013
+ var scroll = {
7014
+ up: (count = 1) => `${CSI2}S`.repeat(count),
7015
+ down: (count = 1) => `${CSI2}T`.repeat(count)
7016
+ };
7017
+ var erase = {
7018
+ screen: `${CSI2}2J`,
7019
+ up: (count = 1) => `${CSI2}1J`.repeat(count),
7020
+ down: (count = 1) => `${CSI2}J`.repeat(count),
7021
+ line: `${CSI2}2K`,
7022
+ lineEnd: `${CSI2}K`,
7023
+ lineStart: `${CSI2}1K`,
7024
+ lines(count) {
7025
+ let clear = "";
7026
+ for (let i = 0;i < count; i++)
7027
+ clear += this.line + (i < count - 1 ? cursor.up() : "");
7028
+ if (count)
7029
+ clear += cursor.left;
7030
+ return clear;
7031
+ }
7032
+ };
7033
+ module.exports = { cursor, scroll, erase, beep };
7034
+ });
7035
+
6948
7036
  // node_modules/commander/lib/error.js
6949
7037
  class CommanderError extends Error {
6950
7038
  constructor(exitCode, code, message) {
@@ -9507,15 +9595,29 @@ function copyShipped(src, home) {
9507
9595
  }
9508
9596
  writeManifest(home, manifest);
9509
9597
  }
9510
- function init(src, home) {
9598
+ function enableStandards(text, enabled) {
9599
+ const lines = text.split(`
9600
+ `);
9601
+ for (let i = 0;i < lines.length - 1; i++) {
9602
+ if (lines[i + 1] !== " enabled: false")
9603
+ continue;
9604
+ if (enabled.some((key) => lines[i] === ` ${key}:`))
9605
+ lines[i + 1] = " enabled: true";
9606
+ }
9607
+ return lines.join(`
9608
+ `);
9609
+ }
9610
+ function init(src, home, enabled = []) {
9511
9611
  try {
9512
9612
  mkdirSync2(home, { recursive: true });
9513
9613
  copyFileSync(`${src}/config.yaml`, `${home}/config.default.yaml`);
9514
9614
  if (existsSync2(`${home}/config.yaml`)) {
9515
9615
  process.stdout.write(`Kept existing config.yaml (shipped defaults: config.default.yaml)
9516
9616
  `);
9517
- } else {
9617
+ } else if (enabled.length === 0) {
9518
9618
  copyFileSync(`${src}/config.yaml`, `${home}/config.yaml`);
9619
+ } else {
9620
+ writeFileSync(`${home}/config.yaml`, enableStandards(readFileSync5(`${src}/config.yaml`, "utf-8"), enabled));
9519
9621
  }
9520
9622
  migrateDataStandards(src, home);
9521
9623
  copyShipped(src, home);
@@ -9555,12 +9657,15 @@ function standardsOf(home, project) {
9555
9657
  const shipped = readManifest(home) ?? {};
9556
9658
  const out = [];
9557
9659
  for (const name of mdFiles(globalDir)) {
9558
- if (CORE.includes(name) || projectNames.includes(name))
9660
+ if (CORE.includes(name))
9559
9661
  continue;
9560
9662
  const optIn = OPT_IN.includes(name);
9561
9663
  if (!optIn && ((`standards/${name}` in shipped) || name.endsWith(".default.md")))
9562
9664
  continue;
9563
- out.push({ path: join4(globalDir, name), key: keyOf(name), optIn });
9665
+ const global = { path: join4(globalDir, name), key: keyOf(name), optIn };
9666
+ if (projectNames.includes(name))
9667
+ global.shadowedBy = join4(projectDir, name);
9668
+ out.push(global);
9564
9669
  }
9565
9670
  for (const name of projectNames)
9566
9671
  out.push({ path: join4(projectDir, name), key: keyOf(name), optIn: false });
@@ -9592,7 +9697,7 @@ var RULE_TEXT = {
9592
9697
  boolean: "true or false",
9593
9698
  "non-negative": "a non-negative integer",
9594
9699
  positive: "a positive integer",
9595
- model: "opus or sonnet"
9700
+ model: "opus, sonnet or haiku"
9596
9701
  };
9597
9702
  var isLeaf = (node) => typeof node.rule === "string";
9598
9703
  function valid(rule, v) {
@@ -9604,7 +9709,7 @@ function valid(rule, v) {
9604
9709
  case "positive":
9605
9710
  return typeof v === "number" && Number.isInteger(v) && v >= 1;
9606
9711
  case "model":
9607
- return v === "opus" || v === "sonnet";
9712
+ return v === "opus" || v === "sonnet" || v === "haiku";
9608
9713
  }
9609
9714
  }
9610
9715
  function defaults(schema) {
@@ -9718,10 +9823,7 @@ import { join as join5 } from "node:path";
9718
9823
  // src/core/standards.ts
9719
9824
  import { readFileSync as readFileSync7 } from "node:fs";
9720
9825
  var PHASES = ["engineering", "develop", "document"];
9721
- var USER_PHASES = ["engineering", "develop"];
9722
- var OPT_IN_PHASES = ["engineering", "document"];
9723
9826
  var isPhase = (v) => PHASES.includes(v);
9724
- var isUserPhase = (v) => USER_PHASES.includes(v);
9725
9827
  function parseList(first, rest) {
9726
9828
  let values;
9727
9829
  if (first !== "") {
@@ -9738,7 +9840,7 @@ function parseList(first, rest) {
9738
9840
  values.push((item[1] ?? "").trim());
9739
9841
  }
9740
9842
  }
9741
- if (values.length === 0 || !values.every(isUserPhase))
9843
+ if (values.length === 0 || !values.every(isPhase))
9742
9844
  return null;
9743
9845
  return values;
9744
9846
  }
@@ -9754,19 +9856,19 @@ function phasesOf(path2) {
9754
9856
  const lines = text.split(`
9755
9857
  `).map((l) => l.replace(/\s+$/, ""));
9756
9858
  if (lines[0] !== "---")
9757
- return USER_PHASES;
9859
+ return PHASES;
9758
9860
  const close = lines.indexOf("---", 1);
9759
9861
  if (close === -1)
9760
- return USER_PHASES;
9862
+ return PHASES;
9761
9863
  const front = lines.slice(1, close);
9762
9864
  const at = front.findIndex((l) => /^applies_to:/.test(l));
9763
9865
  if (at === -1)
9764
- return USER_PHASES;
9866
+ return PHASES;
9765
9867
  const phases = parseList((front[at] ?? "").slice("applies_to:".length).trim(), front.slice(at + 1));
9766
9868
  if (phases === null) {
9767
- process.stderr.write(`theway: warning: ${path2}: applies_to must list engineering and/or develop; applied to both
9869
+ process.stderr.write(`theway: warning: ${path2}: applies_to must list engineering, develop and/or document; skipped
9768
9870
  `);
9769
- return USER_PHASES;
9871
+ return [];
9770
9872
  }
9771
9873
  return phases;
9772
9874
  }
@@ -9780,7 +9882,16 @@ function checkPhase(phase) {
9780
9882
  return false;
9781
9883
  }
9782
9884
  function selectStandards(loaded, phase) {
9783
- return loaded.standards.filter((s) => enabled(loaded.config, s.key)).filter((s) => s.optIn ? OPT_IN_PHASES.includes(phase) : phase !== "document" && phasesOf(s.path).includes(phase)).map((s) => s.path);
9885
+ const phases = new Map;
9886
+ const of = (path2) => {
9887
+ let known = phases.get(path2);
9888
+ if (known === undefined) {
9889
+ known = phasesOf(path2);
9890
+ phases.set(path2, known);
9891
+ }
9892
+ return known;
9893
+ };
9894
+ return loaded.standards.filter((s) => enabled(loaded.config, s.key)).filter((s) => of(s.path).includes(phase) && (s.shadowedBy === undefined || !of(s.shadowedBy).includes(phase))).map((s) => s.path);
9784
9895
  }
9785
9896
  function cmdStandards(project, phase) {
9786
9897
  if (invalidSegments([["project", project]]))
@@ -9957,8 +10068,1415 @@ import {
9957
10068
  writeFileSync as writeFileSync2
9958
10069
  } from "node:fs";
9959
10070
  import { homedir as homedir2 } from "node:os";
9960
- import { delimiter, dirname, join as join7, resolve as resolve3, sep } from "node:path";
10071
+ import { delimiter, dirname, isAbsolute, join as join7, resolve as resolve3, sep } from "node:path";
9961
10072
  import { fileURLToPath } from "node:url";
10073
+
10074
+ // node_modules/@clack/core/dist/index.mjs
10075
+ import { styleText } from "node:util";
10076
+ import { stdout, stdin } from "node:process";
10077
+ import l__default from "node:readline";
10078
+
10079
+ // node_modules/fast-string-truncated-width/dist/utils.js
10080
+ var getCodePointsLength = (() => {
10081
+ const SURROGATE_PAIR_RE = /[\uD800-\uDBFF][\uDC00-\uDFFF]/g;
10082
+ return (input) => {
10083
+ let surrogatePairsNr = 0;
10084
+ SURROGATE_PAIR_RE.lastIndex = 0;
10085
+ while (SURROGATE_PAIR_RE.test(input)) {
10086
+ surrogatePairsNr += 1;
10087
+ }
10088
+ return input.length - surrogatePairsNr;
10089
+ };
10090
+ })();
10091
+ var isFullWidth = (x) => {
10092
+ return x === 12288 || x >= 65281 && x <= 65376 || x >= 65504 && x <= 65510;
10093
+ };
10094
+ var isWideNotCJKTNotEmoji = (x) => {
10095
+ 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;
10096
+ };
10097
+
10098
+ // node_modules/fast-string-truncated-width/dist/index.js
10099
+ var ANSI_RE = /[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]|\u001b\]8;[^;]*;.*?(?:\u0007|\u001b\u005c)/y;
10100
+ var CONTROL_RE = /[\x00-\x08\x0A-\x1F\x7F-\x9F]{1,1000}/y;
10101
+ 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;
10102
+ var TAB_RE = /\t{1,1000}/y;
10103
+ 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;
10104
+ var LATIN_RE = /(?:[\x20-\x7E\xA0-\xFF](?!\uFE0F)){1,1000}/y;
10105
+ var MODIFIER_RE = /\p{M}+/gu;
10106
+ var NO_TRUNCATION = { limit: Infinity, ellipsis: "" };
10107
+ var getStringTruncatedWidth = (input, truncationOptions = {}, widthOptions = {}) => {
10108
+ const LIMIT = truncationOptions.limit ?? Infinity;
10109
+ const ELLIPSIS = truncationOptions.ellipsis ?? "";
10110
+ const ELLIPSIS_WIDTH = truncationOptions?.ellipsisWidth ?? (ELLIPSIS ? getStringTruncatedWidth(ELLIPSIS, NO_TRUNCATION, widthOptions).width : 0);
10111
+ const ANSI_WIDTH = 0;
10112
+ const CONTROL_WIDTH = widthOptions.controlWidth ?? 0;
10113
+ const TAB_WIDTH = widthOptions.tabWidth ?? 8;
10114
+ const EMOJI_WIDTH = widthOptions.emojiWidth ?? 2;
10115
+ const FULL_WIDTH_WIDTH = 2;
10116
+ const REGULAR_WIDTH = widthOptions.regularWidth ?? 1;
10117
+ const WIDE_WIDTH = widthOptions.wideWidth ?? FULL_WIDTH_WIDTH;
10118
+ const PARSE_BLOCKS = [
10119
+ [LATIN_RE, REGULAR_WIDTH],
10120
+ [ANSI_RE, ANSI_WIDTH],
10121
+ [CONTROL_RE, CONTROL_WIDTH],
10122
+ [TAB_RE, TAB_WIDTH],
10123
+ [EMOJI_RE, EMOJI_WIDTH],
10124
+ [CJKT_WIDE_RE, WIDE_WIDTH]
10125
+ ];
10126
+ let indexPrev = 0;
10127
+ let index = 0;
10128
+ let length = input.length;
10129
+ let lengthExtra = 0;
10130
+ let truncationEnabled = false;
10131
+ let truncationIndex = length;
10132
+ let truncationLimit = Math.max(0, LIMIT - ELLIPSIS_WIDTH);
10133
+ let unmatchedStart = 0;
10134
+ let unmatchedEnd = 0;
10135
+ let width = 0;
10136
+ let widthExtra = 0;
10137
+ outer:
10138
+ while (true) {
10139
+ if (unmatchedEnd > unmatchedStart || index >= length && index > indexPrev) {
10140
+ const unmatched = input.slice(unmatchedStart, unmatchedEnd) || input.slice(indexPrev, index);
10141
+ lengthExtra = 0;
10142
+ for (const char of unmatched.replaceAll(MODIFIER_RE, "")) {
10143
+ const codePoint = char.codePointAt(0) || 0;
10144
+ if (isFullWidth(codePoint)) {
10145
+ widthExtra = FULL_WIDTH_WIDTH;
10146
+ } else if (isWideNotCJKTNotEmoji(codePoint)) {
10147
+ widthExtra = WIDE_WIDTH;
10148
+ } else {
10149
+ widthExtra = REGULAR_WIDTH;
10150
+ }
10151
+ if (width + widthExtra > truncationLimit) {
10152
+ truncationIndex = Math.min(truncationIndex, Math.max(unmatchedStart, indexPrev) + lengthExtra);
10153
+ }
10154
+ if (width + widthExtra > LIMIT) {
10155
+ truncationEnabled = true;
10156
+ break outer;
10157
+ }
10158
+ lengthExtra += char.length;
10159
+ width += widthExtra;
10160
+ }
10161
+ unmatchedStart = unmatchedEnd = 0;
10162
+ }
10163
+ if (index >= length) {
10164
+ break outer;
10165
+ }
10166
+ for (let i = 0, l = PARSE_BLOCKS.length;i < l; i++) {
10167
+ const [BLOCK_RE, BLOCK_WIDTH] = PARSE_BLOCKS[i];
10168
+ BLOCK_RE.lastIndex = index;
10169
+ if (BLOCK_RE.test(input)) {
10170
+ lengthExtra = BLOCK_RE === CJKT_WIDE_RE ? getCodePointsLength(input.slice(index, BLOCK_RE.lastIndex)) : BLOCK_RE === EMOJI_RE ? 1 : BLOCK_RE.lastIndex - index;
10171
+ widthExtra = lengthExtra * BLOCK_WIDTH;
10172
+ if (width + widthExtra > truncationLimit) {
10173
+ truncationIndex = Math.min(truncationIndex, index + Math.floor((truncationLimit - width) / BLOCK_WIDTH));
10174
+ }
10175
+ if (width + widthExtra > LIMIT) {
10176
+ truncationEnabled = true;
10177
+ break outer;
10178
+ }
10179
+ width += widthExtra;
10180
+ unmatchedStart = indexPrev;
10181
+ unmatchedEnd = index;
10182
+ index = indexPrev = BLOCK_RE.lastIndex;
10183
+ continue outer;
10184
+ }
10185
+ }
10186
+ index += 1;
10187
+ }
10188
+ return {
10189
+ width: truncationEnabled ? truncationLimit : width,
10190
+ index: truncationEnabled ? truncationIndex : length,
10191
+ truncated: truncationEnabled,
10192
+ ellipsed: truncationEnabled && LIMIT >= ELLIPSIS_WIDTH
10193
+ };
10194
+ };
10195
+ var dist_default = getStringTruncatedWidth;
10196
+
10197
+ // node_modules/fast-string-width/dist/index.js
10198
+ var NO_TRUNCATION2 = {
10199
+ limit: Infinity,
10200
+ ellipsis: "",
10201
+ ellipsisWidth: 0
10202
+ };
10203
+ var fastStringWidth = (input, options = {}) => {
10204
+ return dist_default(input, NO_TRUNCATION2, options).width;
10205
+ };
10206
+ var dist_default2 = fastStringWidth;
10207
+
10208
+ // node_modules/fast-wrap-ansi/lib/main.js
10209
+ var ESC = "\x1B";
10210
+ var CSI = "›";
10211
+ var END_CODE = 39;
10212
+ var ANSI_ESCAPE_BELL = "\x07";
10213
+ var ANSI_CSI = "[";
10214
+ var ANSI_OSC = "]";
10215
+ var ANSI_SGR_TERMINATOR = "m";
10216
+ var ANSI_ESCAPE_LINK = `${ANSI_OSC}8;;`;
10217
+ var GROUP_REGEX = new RegExp(`(?:\\${ANSI_CSI}(?<code>\\d+)m|\\${ANSI_ESCAPE_LINK}(?<uri>.*)${ANSI_ESCAPE_BELL})`, "y");
10218
+ var getClosingCode = (openingCode) => {
10219
+ if (openingCode >= 30 && openingCode <= 37)
10220
+ return 39;
10221
+ if (openingCode >= 90 && openingCode <= 97)
10222
+ return 39;
10223
+ if (openingCode >= 40 && openingCode <= 47)
10224
+ return 49;
10225
+ if (openingCode >= 100 && openingCode <= 107)
10226
+ return 49;
10227
+ if (openingCode === 1 || openingCode === 2)
10228
+ return 22;
10229
+ if (openingCode === 3)
10230
+ return 23;
10231
+ if (openingCode === 4)
10232
+ return 24;
10233
+ if (openingCode === 7)
10234
+ return 27;
10235
+ if (openingCode === 8)
10236
+ return 28;
10237
+ if (openingCode === 9)
10238
+ return 29;
10239
+ if (openingCode === 0)
10240
+ return 0;
10241
+ return;
10242
+ };
10243
+ var wrapAnsiCode = (code) => `${ESC}${ANSI_CSI}${code}${ANSI_SGR_TERMINATOR}`;
10244
+ var wrapAnsiHyperlink = (url) => `${ESC}${ANSI_ESCAPE_LINK}${url}${ANSI_ESCAPE_BELL}`;
10245
+ var wrapWord = (rows, word, columns) => {
10246
+ const characters = word[Symbol.iterator]();
10247
+ let isInsideEscape = false;
10248
+ let isInsideLinkEscape = false;
10249
+ let lastRow = rows.at(-1);
10250
+ let visible = lastRow === undefined ? 0 : dist_default2(lastRow);
10251
+ let currentCharacter = characters.next();
10252
+ let nextCharacter = characters.next();
10253
+ let rawCharacterIndex = 0;
10254
+ while (!currentCharacter.done) {
10255
+ const character = currentCharacter.value;
10256
+ const characterLength = dist_default2(character);
10257
+ if (visible + characterLength <= columns) {
10258
+ rows[rows.length - 1] += character;
10259
+ } else {
10260
+ rows.push(character);
10261
+ visible = 0;
10262
+ }
10263
+ if (character === ESC || character === CSI) {
10264
+ isInsideEscape = true;
10265
+ isInsideLinkEscape = word.startsWith(ANSI_ESCAPE_LINK, rawCharacterIndex + 1);
10266
+ }
10267
+ if (isInsideEscape) {
10268
+ if (isInsideLinkEscape) {
10269
+ if (character === ANSI_ESCAPE_BELL) {
10270
+ isInsideEscape = false;
10271
+ isInsideLinkEscape = false;
10272
+ }
10273
+ } else if (character === ANSI_SGR_TERMINATOR) {
10274
+ isInsideEscape = false;
10275
+ }
10276
+ } else {
10277
+ visible += characterLength;
10278
+ if (visible === columns && !nextCharacter.done) {
10279
+ rows.push("");
10280
+ visible = 0;
10281
+ }
10282
+ }
10283
+ currentCharacter = nextCharacter;
10284
+ nextCharacter = characters.next();
10285
+ rawCharacterIndex += character.length;
10286
+ }
10287
+ lastRow = rows.at(-1);
10288
+ if (!visible && lastRow !== undefined && lastRow.length && rows.length > 1) {
10289
+ rows[rows.length - 2] += rows.pop();
10290
+ }
10291
+ };
10292
+ var stringVisibleTrimSpacesRight = (string) => {
10293
+ const words = string.split(" ");
10294
+ let last2 = words.length;
10295
+ while (last2) {
10296
+ if (dist_default2(words[last2 - 1])) {
10297
+ break;
10298
+ }
10299
+ last2--;
10300
+ }
10301
+ if (last2 === words.length) {
10302
+ return string;
10303
+ }
10304
+ return words.slice(0, last2).join(" ") + words.slice(last2).join("");
10305
+ };
10306
+ var exec = (string, columns, options = {}) => {
10307
+ if (options.trim !== false && string.trim() === "") {
10308
+ return "";
10309
+ }
10310
+ let returnValue = "";
10311
+ let escapeCode;
10312
+ let escapeUrl;
10313
+ const words = string.split(" ");
10314
+ let rows = [""];
10315
+ let rowLength = 0;
10316
+ for (let index = 0;index < words.length; index++) {
10317
+ const word = words[index];
10318
+ if (options.trim !== false) {
10319
+ const row = rows.at(-1) ?? "";
10320
+ const trimmed = row.trimStart();
10321
+ if (row.length !== trimmed.length) {
10322
+ rows[rows.length - 1] = trimmed;
10323
+ rowLength = dist_default2(trimmed);
10324
+ }
10325
+ }
10326
+ if (index !== 0) {
10327
+ if (rowLength >= columns && (options.wordWrap === false || options.trim === false)) {
10328
+ rows.push("");
10329
+ rowLength = 0;
10330
+ }
10331
+ if (rowLength || options.trim === false) {
10332
+ rows[rows.length - 1] += " ";
10333
+ rowLength++;
10334
+ }
10335
+ }
10336
+ const wordLength = dist_default2(word);
10337
+ if (options.hard && wordLength > columns) {
10338
+ const remainingColumns = columns - rowLength;
10339
+ const breaksStartingThisLine = 1 + Math.floor((wordLength - remainingColumns - 1) / columns);
10340
+ const breaksStartingNextLine = Math.floor((wordLength - 1) / columns);
10341
+ if (breaksStartingNextLine < breaksStartingThisLine) {
10342
+ rows.push("");
10343
+ }
10344
+ wrapWord(rows, word, columns);
10345
+ rowLength = dist_default2(rows.at(-1) ?? "");
10346
+ continue;
10347
+ }
10348
+ if (rowLength + wordLength > columns && rowLength && wordLength) {
10349
+ if (options.wordWrap === false && rowLength < columns) {
10350
+ wrapWord(rows, word, columns);
10351
+ rowLength = dist_default2(rows.at(-1) ?? "");
10352
+ continue;
10353
+ }
10354
+ rows.push("");
10355
+ rowLength = 0;
10356
+ }
10357
+ if (rowLength + wordLength > columns && options.wordWrap === false) {
10358
+ wrapWord(rows, word, columns);
10359
+ rowLength = dist_default2(rows.at(-1) ?? "");
10360
+ continue;
10361
+ }
10362
+ rows[rows.length - 1] += word;
10363
+ rowLength += wordLength;
10364
+ }
10365
+ if (options.trim !== false) {
10366
+ rows = rows.map((row) => stringVisibleTrimSpacesRight(row));
10367
+ }
10368
+ const preString = rows.join(`
10369
+ `);
10370
+ let inSurrogate = false;
10371
+ for (let i = 0;i < preString.length; i++) {
10372
+ const character = preString[i];
10373
+ returnValue += character;
10374
+ if (!inSurrogate) {
10375
+ inSurrogate = character >= "\uD800" && character <= "\uDBFF";
10376
+ if (inSurrogate) {
10377
+ continue;
10378
+ }
10379
+ } else {
10380
+ inSurrogate = false;
10381
+ }
10382
+ if (character === ESC || character === CSI) {
10383
+ GROUP_REGEX.lastIndex = i + 1;
10384
+ const groupsResult = GROUP_REGEX.exec(preString);
10385
+ const groups = groupsResult?.groups;
10386
+ if (groups?.code !== undefined) {
10387
+ const code = Number.parseFloat(groups.code);
10388
+ escapeCode = code === END_CODE ? undefined : code;
10389
+ } else if (groups?.uri !== undefined) {
10390
+ escapeUrl = groups.uri.length === 0 ? undefined : groups.uri;
10391
+ }
10392
+ }
10393
+ if (preString[i + 1] === `
10394
+ `) {
10395
+ if (escapeUrl) {
10396
+ returnValue += wrapAnsiHyperlink("");
10397
+ }
10398
+ const closingCode = escapeCode ? getClosingCode(escapeCode) : undefined;
10399
+ if (escapeCode && closingCode) {
10400
+ returnValue += wrapAnsiCode(closingCode);
10401
+ }
10402
+ } else if (character === `
10403
+ `) {
10404
+ if (escapeCode && getClosingCode(escapeCode)) {
10405
+ returnValue += wrapAnsiCode(escapeCode);
10406
+ }
10407
+ if (escapeUrl) {
10408
+ returnValue += wrapAnsiHyperlink(escapeUrl);
10409
+ }
10410
+ }
10411
+ }
10412
+ return returnValue;
10413
+ };
10414
+ var CRLF_OR_LF = /\r?\n/;
10415
+ function wrapAnsi(string, columns, options) {
10416
+ return String(string).normalize().split(CRLF_OR_LF).map((line) => exec(line, columns, options)).join(`
10417
+ `);
10418
+ }
10419
+
10420
+ // node_modules/@clack/core/dist/index.mjs
10421
+ var import_sisteransi = __toESM(require_src(), 1);
10422
+ function findCursor(s, o, l) {
10423
+ if (!l.some((r) => !r.disabled))
10424
+ return s;
10425
+ const t = s + o, n = Math.max(l.length - 1, 0), e = t < 0 ? n : t > n ? 0 : t;
10426
+ return l[e]?.disabled ? findCursor(e, o < 0 ? -1 : 1, l) : e;
10427
+ }
10428
+ function findTextCursor(s, o, l, i) {
10429
+ const t = i.split(`
10430
+ `);
10431
+ let n = 0, e = s;
10432
+ for (const r of t) {
10433
+ if (e <= r.length)
10434
+ break;
10435
+ e -= r.length + 1, n++;
10436
+ }
10437
+ for (n = Math.max(0, Math.min(t.length - 1, n + l)), e = Math.min(e, t[n].length) + o;e < 0 && n > 0; )
10438
+ n--, e += t[n].length + 1;
10439
+ for (;e > t[n].length && n < t.length - 1; )
10440
+ e -= t[n].length + 1, n++;
10441
+ e = Math.max(0, Math.min(t[n].length, e));
10442
+ let h = 0;
10443
+ for (let r = 0;r < n; r++)
10444
+ h += t[r].length + 1;
10445
+ return h + e;
10446
+ }
10447
+ var a$1 = ["up", "down", "left", "right", "space", "enter", "cancel"];
10448
+ var t = [
10449
+ "January",
10450
+ "February",
10451
+ "March",
10452
+ "April",
10453
+ "May",
10454
+ "June",
10455
+ "July",
10456
+ "August",
10457
+ "September",
10458
+ "October",
10459
+ "November",
10460
+ "December"
10461
+ ];
10462
+ var settings = {
10463
+ actions: new Set(a$1),
10464
+ aliases: /* @__PURE__ */ new Map([
10465
+ ["k", "up"],
10466
+ ["j", "down"],
10467
+ ["h", "left"],
10468
+ ["l", "right"],
10469
+ ["\x03", "cancel"],
10470
+ ["escape", "cancel"]
10471
+ ]),
10472
+ messages: {
10473
+ cancel: "Canceled",
10474
+ error: "Something went wrong"
10475
+ },
10476
+ withGuide: true,
10477
+ accessible: undefined,
10478
+ date: {
10479
+ monthNames: [...t],
10480
+ messages: {
10481
+ required: "Please enter a valid date",
10482
+ invalidMonth: "There are only 12 months in a year",
10483
+ invalidDay: (n, e) => `There are only ${n} days in ${e}`,
10484
+ afterMin: (n) => `Date must be on or after ${n.toISOString().slice(0, 10)}`,
10485
+ beforeMax: (n) => `Date must be on or before ${n.toISOString().slice(0, 10)}`
10486
+ }
10487
+ }
10488
+ };
10489
+ function isAccessible(n) {
10490
+ if (n !== undefined)
10491
+ return n;
10492
+ if (settings.accessible !== undefined)
10493
+ return settings.accessible;
10494
+ const e = process.env.ACCESSIBLE;
10495
+ return e !== undefined && e !== "" && e !== "0" && e !== "false";
10496
+ }
10497
+ function isActionKey(n, e) {
10498
+ if (typeof n == "string")
10499
+ return settings.aliases.get(n) === e;
10500
+ for (const s of n)
10501
+ if (s !== undefined && isActionKey(s, e))
10502
+ return true;
10503
+ return false;
10504
+ }
10505
+ function diffLines(i, s) {
10506
+ if (i === s)
10507
+ return;
10508
+ const e = i.split(`
10509
+ `), t2 = s.split(`
10510
+ `), r = Math.max(e.length, t2.length), f = [];
10511
+ for (let n = 0;n < r; n++)
10512
+ e[n] !== t2[n] && f.push(n);
10513
+ return {
10514
+ lines: f,
10515
+ numLinesBefore: e.length,
10516
+ numLinesAfter: t2.length,
10517
+ numLines: r
10518
+ };
10519
+ }
10520
+ var R = globalThis.process.platform.startsWith("win");
10521
+ var CANCEL_SYMBOL = Symbol("clack:cancel");
10522
+ function isCancel(e) {
10523
+ return e === CANCEL_SYMBOL;
10524
+ }
10525
+ function setRawMode(e, r) {
10526
+ const o = e;
10527
+ o.isTTY && o.setRawMode(r);
10528
+ }
10529
+ var getColumns = (e) => ("columns" in e) && typeof e.columns == "number" ? e.columns : 80;
10530
+ var getRows = (e) => ("rows" in e) && typeof e.rows == "number" ? e.rows : 20;
10531
+ function wrapTextWithPrefix(e, r, o, n = o, s = o, t2) {
10532
+ const f = getColumns(e ?? stdout);
10533
+ return wrapAnsi(r, f - o.length, {
10534
+ hard: true,
10535
+ trim: false
10536
+ }).split(`
10537
+ `).map((c, i, m) => {
10538
+ const d = t2 ? t2(c, i) : c;
10539
+ return i === 0 ? `${n}${d}` : i === m.length - 1 ? `${s}${d}` : `${o}${d}`;
10540
+ }).join(`
10541
+ `);
10542
+ }
10543
+ function runValidation(e, a) {
10544
+ if ("~standard" in e) {
10545
+ const n = e["~standard"].validate(a);
10546
+ return n instanceof Promise ? n.then((r) => r.issues?.at(0)?.message) : n.issues?.at(0)?.message;
10547
+ }
10548
+ return e(a);
10549
+ }
10550
+
10551
+ class y {
10552
+ input;
10553
+ output;
10554
+ _abortSignal;
10555
+ rl;
10556
+ opts;
10557
+ _render;
10558
+ _track = false;
10559
+ _prevFrame = "";
10560
+ _subscribers = /* @__PURE__ */ new Map;
10561
+ _cursor = 0;
10562
+ state = "initial";
10563
+ error = "";
10564
+ value;
10565
+ userInput = "";
10566
+ get accessible() {
10567
+ return isAccessible(this.opts.accessible);
10568
+ }
10569
+ constructor(t2, e = true) {
10570
+ const { input: i = stdin, output: s = stdout, render: r, signal: n, ...o } = t2;
10571
+ this.opts = o, this.onKeypress = this.onKeypress.bind(this), this.close = this.close.bind(this), this.render = this.render.bind(this), this._render = r.bind(this), this._track = e, this._abortSignal = n, this.input = i, this.output = s;
10572
+ }
10573
+ unsubscribe() {
10574
+ this._subscribers.clear();
10575
+ }
10576
+ setSubscriber(t2, e) {
10577
+ const i = this._subscribers.get(t2) ?? [];
10578
+ i.push(e), this._subscribers.set(t2, i);
10579
+ }
10580
+ on(t2, e) {
10581
+ this.setSubscriber(t2, { cb: e });
10582
+ }
10583
+ once(t2, e) {
10584
+ this.setSubscriber(t2, { cb: e, once: true });
10585
+ }
10586
+ emit(t2, ...e) {
10587
+ const i = this._subscribers.get(t2) ?? [], s = [];
10588
+ for (const r of i)
10589
+ r.cb(...e), r.once && s.push(() => i.splice(i.indexOf(r), 1));
10590
+ for (const r of s)
10591
+ r();
10592
+ }
10593
+ prompt() {
10594
+ return new Promise((t2) => {
10595
+ if (this._abortSignal) {
10596
+ if (this._abortSignal.aborted)
10597
+ return this.state = "cancel", this.close(), t2(CANCEL_SYMBOL);
10598
+ this._abortSignal.addEventListener("abort", () => {
10599
+ this.state = "cancel", this.close();
10600
+ }, { once: true });
10601
+ }
10602
+ this.rl = l__default.createInterface({
10603
+ input: this.input,
10604
+ tabSize: 2,
10605
+ prompt: "",
10606
+ escapeCodeTimeout: 50,
10607
+ terminal: true
10608
+ }), this.rl.prompt(), this.opts.initialUserInput !== undefined && this._setUserInput(this.opts.initialUserInput, true), this.input.on("keypress", this.onKeypress), setRawMode(this.input, true), this.output.on("resize", this.render), this.render(), this.once("submit", () => {
10609
+ this.output.write(import_sisteransi.cursor.show), this.output.off("resize", this.render), setRawMode(this.input, false), t2(this.value);
10610
+ }), this.once("cancel", () => {
10611
+ this.output.write(import_sisteransi.cursor.show), this.output.off("resize", this.render), setRawMode(this.input, false), t2(CANCEL_SYMBOL);
10612
+ });
10613
+ });
10614
+ }
10615
+ _isActionKey(t2, e) {
10616
+ return t2 === "\t";
10617
+ }
10618
+ _shouldSubmit(t2, e) {
10619
+ return true;
10620
+ }
10621
+ _setValue(t2) {
10622
+ this.value = t2, this.emit("value", this.value);
10623
+ }
10624
+ _setUserInput(t2, e) {
10625
+ this.userInput = t2 ?? "", this.emit("userInput", this.userInput), e && this._track && this.rl && (this.rl.write(this.userInput), this._cursor = this.rl.cursor);
10626
+ }
10627
+ _clearUserInput() {
10628
+ this.rl?.write(null, { ctrl: true, name: "u" }), this._setUserInput("");
10629
+ }
10630
+ async onKeypress(t2, e) {
10631
+ if (this.state !== "validating") {
10632
+ if (this._track && e.name !== "return" && (e.name && this._isActionKey(t2, e) && this.rl?.write(null, { ctrl: true, name: "h" }), this._cursor = this.rl?.cursor ?? 0, this._setUserInput(this.rl?.line)), this.state === "error" && (this.state = "active"), e?.name && (!this._track && settings.aliases.has(e.name) && this.emit("cursor", settings.aliases.get(e.name)), settings.actions.has(e.name) && this.emit("cursor", e.name)), t2 && (t2.toLowerCase() === "y" || t2.toLowerCase() === "n") && this.emit("confirm", t2.toLowerCase() === "y"), this.emit("key", t2, e), e?.name === "return" && this._shouldSubmit(t2, e)) {
10633
+ if (this.opts.validate) {
10634
+ const i = runValidation(this.opts.validate, this.value);
10635
+ let s;
10636
+ i instanceof Promise ? (this.state = "validating", this.render(), s = await i) : s = i, s && (this.error = s instanceof Error ? s.message : s, this.state = "error", this.rl?.write(this.userInput));
10637
+ }
10638
+ this.state !== "error" && (this.state = "submit");
10639
+ }
10640
+ isActionKey([t2, e?.name, e?.sequence], "cancel") && (this.state = "cancel"), (this.state === "submit" || this.state === "cancel") && this.emit("finalize"), this.render(), (this.state === "submit" || this.state === "cancel") && this.close();
10641
+ }
10642
+ }
10643
+ close() {
10644
+ this.input.unpipe(), this.input.removeListener("keypress", this.onKeypress), this.output.write(`
10645
+ `), setRawMode(this.input, false), this.rl?.close(), this.rl = undefined, this.emit(`${this.state}`, this.value), this.unsubscribe();
10646
+ }
10647
+ restoreCursor() {
10648
+ const t2 = wrapAnsi(this._prevFrame, process.stdout.columns, { hard: true, trim: false }).split(`
10649
+ `).length - 1;
10650
+ this.output.write(import_sisteransi.cursor.move(-999, t2 * -1));
10651
+ }
10652
+ render() {
10653
+ const t2 = wrapAnsi(this._render(this) ?? "", process.stdout.columns, {
10654
+ hard: true,
10655
+ trim: false
10656
+ });
10657
+ if (t2 !== this._prevFrame) {
10658
+ if (this.state === "initial")
10659
+ this.output.write(import_sisteransi.cursor.hide);
10660
+ else {
10661
+ const e = diffLines(this._prevFrame, t2), i = getRows(this.output);
10662
+ if (this.restoreCursor(), e) {
10663
+ const s = Math.max(0, e.numLinesAfter - i), r = Math.max(0, e.numLinesBefore - i);
10664
+ let n = e.lines.find((o) => o >= s);
10665
+ if (n === undefined) {
10666
+ this._prevFrame = t2;
10667
+ return;
10668
+ }
10669
+ if (e.lines.length === 1) {
10670
+ this.output.write(import_sisteransi.cursor.move(0, n - r)), this.output.write(import_sisteransi.erase.lines(1));
10671
+ const o = t2.split(`
10672
+ `);
10673
+ this.output.write(o[n]), this._prevFrame = t2, this.output.write(import_sisteransi.cursor.move(0, o.length - n - 1));
10674
+ return;
10675
+ } else if (e.lines.length > 1) {
10676
+ if (s < r)
10677
+ n = s;
10678
+ else {
10679
+ const h = n - r;
10680
+ h > 0 && this.output.write(import_sisteransi.cursor.move(0, h));
10681
+ }
10682
+ this.output.write(import_sisteransi.erase.down());
10683
+ const f = t2.split(`
10684
+ `).slice(n);
10685
+ this.output.write(f.join(`
10686
+ `)), this._prevFrame = t2;
10687
+ return;
10688
+ }
10689
+ }
10690
+ this.output.write(import_sisteransi.erase.down());
10691
+ }
10692
+ this.output.write(t2), this.state === "initial" && (this.state = "active"), this._prevFrame = t2;
10693
+ }
10694
+ }
10695
+ }
10696
+ function p$1(l, e) {
10697
+ if (l === undefined || e.length === 0)
10698
+ return 0;
10699
+ const i = e.findIndex((s) => s.value === l);
10700
+ return i !== -1 ? i : 0;
10701
+ }
10702
+ function m(l, e) {
10703
+ return (e.label ?? String(e.value)).toLowerCase().includes(l.toLowerCase());
10704
+ }
10705
+ function g(l, e) {
10706
+ if (e)
10707
+ return l ? e : e[0];
10708
+ }
10709
+ var T$1 = class T extends y {
10710
+ filteredOptions;
10711
+ multiple;
10712
+ isNavigating = false;
10713
+ selectedValues = [];
10714
+ focusedValue;
10715
+ #e = 0;
10716
+ #s = "";
10717
+ #t;
10718
+ #i;
10719
+ #n;
10720
+ #l;
10721
+ get cursor() {
10722
+ return this.#e;
10723
+ }
10724
+ get userInputWithCursor() {
10725
+ if (!this.userInput)
10726
+ return styleText(["inverse", "hidden"], "_");
10727
+ if (this._cursor >= this.userInput.length)
10728
+ return `${this.userInput}█`;
10729
+ const e = this.userInput.slice(0, this.cursor), t2 = this.userInput.slice(this.cursor, this.cursor + 1), i = this.userInput.slice(this.cursor + 1);
10730
+ return `${e}${styleText("inverse", t2)}${i}`;
10731
+ }
10732
+ get options() {
10733
+ return typeof this.#i == "function" ? this.#i() : this.#i;
10734
+ }
10735
+ constructor(e) {
10736
+ super(e), this.#i = e.options, this.#n = e.placeholder, this.#l = e.completeOnTab === true;
10737
+ const t2 = this.options;
10738
+ this.filteredOptions = [...t2], this.multiple = e.multiple === true, this.#t = typeof e.options == "function" ? e.filter : e.filter ?? m;
10739
+ let i;
10740
+ if (e.initialValue && Array.isArray(e.initialValue) ? this.multiple ? i = e.initialValue : i = e.initialValue.slice(0, 1) : !this.multiple && this.options.length > 0 && (i = [this.options[0]?.value]), i)
10741
+ for (const s of i) {
10742
+ const n = t2.findIndex((r) => r.value === s);
10743
+ n !== -1 && (this.toggleSelected(s), this.#e = n);
10744
+ }
10745
+ this.focusedValue = this.options[this.#e]?.value, this.on("key", (s, n) => this.#u(s, n)), this.on("userInput", (s) => this.#o(s));
10746
+ }
10747
+ _isActionKey(e, t2) {
10748
+ return e === "\t" || this.multiple && this.isNavigating && t2.name === "space" && e !== undefined && e !== "";
10749
+ }
10750
+ #u(e, t2) {
10751
+ const i = t2.name === "up", s = t2.name === "down", n = t2.name === "return", r = this.userInput === "" || this.userInput === "\t", u = this.#n, d = this.options, c = u !== undefined && u !== "" && d.some((o) => !o.disabled && (this.#t ? this.#t(u, o) : true));
10752
+ if (t2.name === "tab" && r && c) {
10753
+ this.userInput === "\t" && this._clearUserInput(), this._setUserInput(u, true), this.isNavigating = false;
10754
+ return;
10755
+ }
10756
+ if (t2.name === "tab" && this.#l && !this.multiple && this.focusedValue !== undefined) {
10757
+ const o = String(this.focusedValue);
10758
+ this._clearUserInput(), this._setUserInput(o, true), this.isNavigating = false;
10759
+ return;
10760
+ }
10761
+ i || s ? (this.#e = findCursor(this.#e, i ? -1 : 1, this.filteredOptions), this.focusedValue = this.filteredOptions[this.#e]?.value, this.multiple || (this.selectedValues = [this.focusedValue]), this.isNavigating = true) : n ? this.value = g(this.multiple, this.selectedValues) : this.multiple ? this.focusedValue !== undefined && (t2.name === "tab" || this.isNavigating && t2.name === "space") ? this.toggleSelected(this.focusedValue) : this.isNavigating = false : (this.focusedValue && (this.selectedValues = [this.focusedValue]), this.isNavigating = false);
10762
+ }
10763
+ deselectAll() {
10764
+ this.selectedValues = [];
10765
+ }
10766
+ toggleSelected(e) {
10767
+ this.filteredOptions.length !== 0 && (this.multiple ? this.selectedValues.includes(e) ? this.selectedValues = this.selectedValues.filter((t2) => t2 !== e) : this.selectedValues = [...this.selectedValues, e] : this.selectedValues = [e]);
10768
+ }
10769
+ #o(e) {
10770
+ if (e !== this.#s) {
10771
+ this.#s = e;
10772
+ const t2 = this.options;
10773
+ e && this.#t ? this.filteredOptions = t2.filter((n) => this.#t?.(e, n)) : this.filteredOptions = [...t2];
10774
+ const i = p$1(this.focusedValue, this.filteredOptions);
10775
+ this.#e = findCursor(i, 0, this.filteredOptions);
10776
+ const s = this.filteredOptions[this.#e];
10777
+ s && !s.disabled ? this.focusedValue = s.value : this.focusedValue = undefined, this.multiple || (this.focusedValue !== undefined ? this.toggleSelected(this.focusedValue) : this.deselectAll());
10778
+ }
10779
+ }
10780
+ };
10781
+ var _ = {
10782
+ Y: { type: "year", len: 4 },
10783
+ M: { type: "month", len: 2 },
10784
+ D: { type: "day", len: 2 }
10785
+ };
10786
+ function M(r) {
10787
+ return [...r].map((t2) => _[t2]);
10788
+ }
10789
+ function P(r) {
10790
+ const i = new Intl.DateTimeFormat(r, {
10791
+ year: "numeric",
10792
+ month: "2-digit",
10793
+ day: "2-digit"
10794
+ }).formatToParts(new Date(2000, 0, 15)), s = [];
10795
+ let n = "/";
10796
+ for (const e of i)
10797
+ e.type === "literal" ? n = e.value.trim() || e.value : (e.type === "year" || e.type === "month" || e.type === "day") && s.push({ type: e.type, len: e.type === "year" ? 4 : 2 });
10798
+ return { segments: s, separator: n };
10799
+ }
10800
+ function p(r) {
10801
+ return Number.parseInt((r || "0").replace(/_/g, "0"), 10) || 0;
10802
+ }
10803
+ function f(r) {
10804
+ return {
10805
+ year: p(r.year),
10806
+ month: p(r.month),
10807
+ day: p(r.day)
10808
+ };
10809
+ }
10810
+ function c(r, t2) {
10811
+ return new Date(r || 2001, t2 || 1, 0).getDate();
10812
+ }
10813
+ function b(r) {
10814
+ const { year: t2, month: i, day: s } = f(r);
10815
+ if (!t2 || t2 < 0 || t2 > 9999 || !i || i < 1 || i > 12 || !s || s < 1)
10816
+ return;
10817
+ const n = new Date(Date.UTC(t2, i - 1, s));
10818
+ if (!(n.getUTCFullYear() !== t2 || n.getUTCMonth() !== i - 1 || n.getUTCDate() !== s))
10819
+ return { year: t2, month: i, day: s };
10820
+ }
10821
+ function C(r) {
10822
+ const t2 = b(r);
10823
+ return t2 ? new Date(Date.UTC(t2.year, t2.month - 1, t2.day)) : undefined;
10824
+ }
10825
+ function T2(r, t2, i, s) {
10826
+ const n = i ? {
10827
+ year: i.getUTCFullYear(),
10828
+ month: i.getUTCMonth() + 1,
10829
+ day: i.getUTCDate()
10830
+ } : null, e = s ? {
10831
+ year: s.getUTCFullYear(),
10832
+ month: s.getUTCMonth() + 1,
10833
+ day: s.getUTCDate()
10834
+ } : null;
10835
+ return r === "year" ? { min: n?.year ?? 1, max: e?.year ?? 9999 } : r === "month" ? {
10836
+ min: n && t2.year === n.year ? n.month : 1,
10837
+ max: e && t2.year === e.year ? e.month : 12
10838
+ } : {
10839
+ min: n && t2.year === n.year && t2.month === n.month ? n.day : 1,
10840
+ max: e && t2.year === e.year && t2.month === e.month ? e.day : c(t2.year, t2.month)
10841
+ };
10842
+ }
10843
+
10844
+ class U extends y {
10845
+ #i;
10846
+ #o;
10847
+ #t;
10848
+ #h;
10849
+ #u;
10850
+ #e = { segmentIndex: 0, positionInSegment: 0 };
10851
+ #n = true;
10852
+ #s = null;
10853
+ inlineError = "";
10854
+ get segmentCursor() {
10855
+ return { ...this.#e };
10856
+ }
10857
+ get segmentValues() {
10858
+ return { ...this.#t };
10859
+ }
10860
+ get segments() {
10861
+ return this.#i;
10862
+ }
10863
+ get separator() {
10864
+ return this.#o;
10865
+ }
10866
+ get formattedValue() {
10867
+ return this.#l(this.#t);
10868
+ }
10869
+ #l(t2) {
10870
+ return this.#i.map((i) => t2[i.type]).join(this.#o);
10871
+ }
10872
+ #r() {
10873
+ this._setUserInput(this.#l(this.#t)), this._setValue(C(this.#t) ?? undefined);
10874
+ }
10875
+ constructor(t2) {
10876
+ const i = t2.format ? { segments: M(t2.format), separator: t2.separator ?? "/" } : P(t2.locale), s = t2.separator ?? i.separator, n = t2.format ? M(t2.format) : i.segments, e = t2.initialValue ?? t2.defaultValue, m2 = e ? {
10877
+ year: String(e.getUTCFullYear()).padStart(4, "0"),
10878
+ month: String(e.getUTCMonth() + 1).padStart(2, "0"),
10879
+ day: String(e.getUTCDate()).padStart(2, "0")
10880
+ } : { year: "____", month: "__", day: "__" }, o = n.map((a) => m2[a.type]).join(s);
10881
+ super({ ...t2, initialUserInput: o }, false), this.#i = n, this.#o = s, this.#t = m2, this.#h = t2.minDate, this.#u = t2.maxDate, this.#r(), this.on("cursor", (a) => this.#f(a)), this.on("key", (a, u) => this.#y(a, u)), this.on("finalize", () => this.#p(t2));
10882
+ }
10883
+ #a() {
10884
+ const t2 = Math.max(0, Math.min(this.#e.segmentIndex, this.#i.length - 1)), i = this.#i[t2];
10885
+ if (i)
10886
+ return this.#e.positionInSegment = Math.max(0, Math.min(this.#e.positionInSegment, i.len - 1)), { segment: i, index: t2 };
10887
+ }
10888
+ #m(t2) {
10889
+ this.inlineError = "", this.#s = null;
10890
+ const i = this.#a();
10891
+ i && (this.#e.segmentIndex = Math.max(0, Math.min(this.#i.length - 1, i.index + t2)), this.#e.positionInSegment = 0, this.#n = true);
10892
+ }
10893
+ #d(t2) {
10894
+ const i = this.#a();
10895
+ if (!i)
10896
+ return;
10897
+ const { segment: s } = i, n = this.#t[s.type], e = !n || n.replace(/_/g, "") === "", m2 = Number.parseInt((n || "0").replace(/_/g, "0"), 10) || 0, o = T2(s.type, f(this.#t), this.#h, this.#u);
10898
+ let a;
10899
+ e ? a = t2 === 1 ? o.min : o.max : a = Math.max(Math.min(o.max, m2 + t2), o.min), this.#t = {
10900
+ ...this.#t,
10901
+ [s.type]: a.toString().padStart(s.len, "0")
10902
+ }, this.#n = true, this.#s = null, this.#r();
10903
+ }
10904
+ #f(t2) {
10905
+ if (t2)
10906
+ switch (t2) {
10907
+ case "right":
10908
+ return this.#m(1);
10909
+ case "left":
10910
+ return this.#m(-1);
10911
+ case "up":
10912
+ return this.#d(1);
10913
+ case "down":
10914
+ return this.#d(-1);
10915
+ }
10916
+ }
10917
+ #y(t2, i) {
10918
+ if (i?.name === "backspace" || i?.sequence === "" || i?.sequence === "\b" || t2 === "" || t2 === "\b") {
10919
+ this.inlineError = "";
10920
+ const n = this.#a();
10921
+ if (!n)
10922
+ return;
10923
+ if (!this.#t[n.segment.type].replace(/_/g, "")) {
10924
+ this.#m(-1);
10925
+ return;
10926
+ }
10927
+ this.#t[n.segment.type] = "_".repeat(n.segment.len), this.#n = true, this.#e.positionInSegment = 0, this.#r();
10928
+ return;
10929
+ }
10930
+ if (i?.name === "tab") {
10931
+ this.inlineError = "";
10932
+ const n = this.#a();
10933
+ if (!n)
10934
+ return;
10935
+ const e = i.shift ? -1 : 1, m2 = n.index + e;
10936
+ m2 >= 0 && m2 < this.#i.length && (this.#e.segmentIndex = m2, this.#e.positionInSegment = 0, this.#n = true);
10937
+ return;
10938
+ }
10939
+ if (t2 && /^[0-9]$/.test(t2)) {
10940
+ const n = this.#a();
10941
+ if (!n)
10942
+ return;
10943
+ const { segment: e } = n, m2 = !this.#t[e.type].replace(/_/g, "");
10944
+ if (this.#n && this.#s !== null && !m2) {
10945
+ const h = this.#s + t2, d = { ...this.#t, [e.type]: h }, g2 = this.#g(d, e);
10946
+ if (g2) {
10947
+ this.inlineError = g2, this.#s = null, this.#n = false;
10948
+ return;
10949
+ }
10950
+ this.inlineError = "", this.#t[e.type] = h, this.#s = null, this.#n = false, this.#r(), n.index < this.#i.length - 1 && (this.#e.segmentIndex = n.index + 1, this.#e.positionInSegment = 0, this.#n = true);
10951
+ return;
10952
+ }
10953
+ this.#n && !m2 && (this.#t[e.type] = "_".repeat(e.len), this.#e.positionInSegment = 0), this.#n = false, this.#s = null;
10954
+ const o = this.#t[e.type], a = o.indexOf("_"), u = a >= 0 ? a : Math.min(this.#e.positionInSegment, e.len - 1);
10955
+ if (u < 0 || u >= e.len)
10956
+ return;
10957
+ let l = o.slice(0, u) + t2 + o.slice(u + 1), D = false;
10958
+ if (u === 0 && o === "__" && (e.type === "month" || e.type === "day")) {
10959
+ const h = Number.parseInt(t2, 10);
10960
+ l = `0${t2}`, D = h <= (e.type === "month" ? 1 : 2);
10961
+ }
10962
+ if (e.type === "year" && (l = (o.replace(/_/g, "") + t2).padStart(e.len, "_")), !l.includes("_")) {
10963
+ const h = { ...this.#t, [e.type]: l }, d = this.#g(h, e);
10964
+ if (d) {
10965
+ this.inlineError = d;
10966
+ return;
10967
+ }
10968
+ }
10969
+ this.inlineError = "", this.#t[e.type] = l;
10970
+ const y2 = l.includes("_") ? undefined : b(this.#t);
10971
+ if (y2) {
10972
+ const { year: h, month: d } = y2, g2 = c(h, d);
10973
+ this.#t = {
10974
+ year: String(Math.max(0, Math.min(9999, h))).padStart(4, "0"),
10975
+ month: String(Math.max(1, Math.min(12, d))).padStart(2, "0"),
10976
+ day: String(Math.max(1, Math.min(g2, y2.day))).padStart(2, "0")
10977
+ };
10978
+ }
10979
+ this.#r();
10980
+ const S = l.indexOf("_");
10981
+ D ? (this.#n = true, this.#s = t2) : S >= 0 ? this.#e.positionInSegment = S : a >= 0 && n.index < this.#i.length - 1 ? (this.#e.segmentIndex = n.index + 1, this.#e.positionInSegment = 0, this.#n = true) : this.#e.positionInSegment = Math.min(u + 1, e.len - 1);
10982
+ }
10983
+ }
10984
+ #g(t2, i) {
10985
+ const { month: s, day: n } = f(t2);
10986
+ if (i.type === "month" && (s < 0 || s > 12))
10987
+ return settings.date.messages.invalidMonth;
10988
+ if (i.type === "day" && (n < 0 || n > 31))
10989
+ return settings.date.messages.invalidDay(31, "any month");
10990
+ }
10991
+ #p(t2) {
10992
+ const { year: i, month: s, day: n } = f(this.#t);
10993
+ if (i && s && n) {
10994
+ const e = c(i, s);
10995
+ this.#t = {
10996
+ ...this.#t,
10997
+ day: String(Math.min(n, e)).padStart(2, "0")
10998
+ };
10999
+ }
11000
+ this.value = C(this.#t) ?? t2.defaultValue ?? undefined;
11001
+ }
11002
+ }
11003
+ var u$2 = class u extends y {
11004
+ options;
11005
+ cursor = 0;
11006
+ #t;
11007
+ getGroupItems(t2) {
11008
+ return this.options.filter((r) => r.group === t2);
11009
+ }
11010
+ isGroupSelected(t2) {
11011
+ const r = this.getGroupItems(t2), e = this.value;
11012
+ return e === undefined ? false : r.every((s) => e.includes(s.value));
11013
+ }
11014
+ toggleValue() {
11015
+ const t2 = this.options[this.cursor];
11016
+ if (t2 !== undefined)
11017
+ if (this.value === undefined && (this.value = []), t2.group === true) {
11018
+ const r = t2.value, e = this.getGroupItems(r);
11019
+ this.isGroupSelected(r) ? this.value = this.value.filter((s) => e.findIndex((i) => i.value === s) === -1) : this.value = [...this.value, ...e.map((s) => s.value)], this.value = Array.from(new Set(this.value));
11020
+ } else {
11021
+ const r = this.value.includes(t2.value);
11022
+ this.value = r ? this.value.filter((e) => e !== t2.value) : [...this.value, t2.value];
11023
+ }
11024
+ }
11025
+ constructor(t2) {
11026
+ super(t2, false);
11027
+ const { options: r } = t2;
11028
+ this.#t = t2.selectableGroups !== false, this.options = Object.entries(r).flatMap(([e, s]) => [
11029
+ { value: e, group: true, label: e },
11030
+ ...s.map((i) => ({ ...i, group: e }))
11031
+ ]), this.value = [...t2.initialValues ?? []], this.cursor = Math.max(this.options.findIndex(({ value: e }) => e === t2.cursorAt), this.#t ? 0 : 1), this.on("cursor", (e) => {
11032
+ switch (e) {
11033
+ case "left":
11034
+ case "up": {
11035
+ this.cursor = this.cursor === 0 ? this.options.length - 1 : this.cursor - 1;
11036
+ const s = this.options[this.cursor]?.group === true;
11037
+ !this.#t && s && (this.cursor = this.cursor === 0 ? this.options.length - 1 : this.cursor - 1);
11038
+ break;
11039
+ }
11040
+ case "down":
11041
+ case "right": {
11042
+ this.cursor = this.cursor === this.options.length - 1 ? 0 : this.cursor + 1;
11043
+ const s = this.options[this.cursor]?.group === true;
11044
+ !this.#t && s && (this.cursor = this.cursor === this.options.length - 1 ? 0 : this.cursor + 1);
11045
+ break;
11046
+ }
11047
+ case "space":
11048
+ this.toggleValue();
11049
+ break;
11050
+ }
11051
+ });
11052
+ }
11053
+ };
11054
+ var o = /* @__PURE__ */ new Set(["up", "down", "left", "right"]);
11055
+
11056
+ class h extends y {
11057
+ #t = false;
11058
+ #s;
11059
+ focused = "editor";
11060
+ get userInputWithCursor() {
11061
+ if (this.state === "submit")
11062
+ return this.userInput;
11063
+ const t2 = this.userInput;
11064
+ if (this.cursor >= t2.length)
11065
+ return `${t2}█`;
11066
+ const s = t2.slice(0, this.cursor), r = t2.slice(this.cursor, this.cursor + 1), i = t2.slice(this.cursor + 1);
11067
+ return r === `
11068
+ ` ? `${s}█
11069
+ ${i}` : `${s}${styleText("inverse", r)}${i}`;
11070
+ }
11071
+ get cursor() {
11072
+ return this._cursor;
11073
+ }
11074
+ #r(t2) {
11075
+ if (this.userInput.length === 0) {
11076
+ this._setUserInput(t2);
11077
+ return;
11078
+ }
11079
+ this._setUserInput(this.userInput.slice(0, this.cursor) + t2 + this.userInput.slice(this.cursor));
11080
+ }
11081
+ #i(t2) {
11082
+ const s = this.value ?? "";
11083
+ switch (t2) {
11084
+ case "up":
11085
+ this._cursor = findTextCursor(this._cursor, 0, -1, s);
11086
+ return;
11087
+ case "down":
11088
+ this._cursor = findTextCursor(this._cursor, 0, 1, s);
11089
+ return;
11090
+ case "left":
11091
+ this._cursor = findTextCursor(this._cursor, -1, 0, s);
11092
+ return;
11093
+ case "right":
11094
+ this._cursor = findTextCursor(this._cursor, 1, 0, s);
11095
+ return;
11096
+ }
11097
+ }
11098
+ _shouldSubmit(t2, s) {
11099
+ if (this.#s)
11100
+ return this.focused === "submit" ? true : (this.#r(`
11101
+ `), this._cursor++, false);
11102
+ const r = this.#t;
11103
+ return this.#t = true, r && this.cursor === this.userInput.length ? (this.userInput[this.cursor - 1] === `
11104
+ ` && (this._setUserInput(this.userInput.slice(0, this.cursor - 1) + this.userInput.slice(this.cursor)), this._cursor--), true) : (this.#r(`
11105
+ `), this._cursor++, false);
11106
+ }
11107
+ constructor(t2) {
11108
+ const s = t2.initialUserInput ?? t2.initialValue;
11109
+ super({
11110
+ ...t2,
11111
+ initialUserInput: s
11112
+ }, false), s !== undefined && (this._cursor = s.length), this.#s = t2.showSubmit ?? false, this.on("key", (r, i) => {
11113
+ if (i?.name && o.has(i.name)) {
11114
+ this.#t = false, this.#i(i.name);
11115
+ return;
11116
+ }
11117
+ if (r === "\t" && this.#s) {
11118
+ this.focused = this.focused === "editor" ? "submit" : "editor";
11119
+ return;
11120
+ }
11121
+ if (i?.name !== "return") {
11122
+ if (this.#t = false, i?.name === "backspace" && this.cursor > 0) {
11123
+ this._setUserInput(this.userInput.slice(0, this.cursor - 1) + this.userInput.slice(this.cursor)), this._cursor--;
11124
+ return;
11125
+ }
11126
+ if (i?.name === "delete" && this.cursor < this.userInput.length) {
11127
+ this._setUserInput(this.userInput.slice(0, this.cursor) + this.userInput.slice(this.cursor + 1));
11128
+ return;
11129
+ }
11130
+ r && (this.#s && this.focused === "submit" && (this.focused = "editor"), this.#r(r ?? ""), this._cursor++);
11131
+ }
11132
+ }), this.on("userInput", (r) => {
11133
+ this._setValue(r);
11134
+ }), this.on("finalize", () => {
11135
+ this.value || (this.value = t2.defaultValue), this.value === undefined && (this.value = "");
11136
+ });
11137
+ }
11138
+ }
11139
+
11140
+ class a extends y {
11141
+ options;
11142
+ cursor = 0;
11143
+ get _value() {
11144
+ return this.options[this.cursor]?.value;
11145
+ }
11146
+ get _enabledOptions() {
11147
+ return this.options.filter((e) => e.disabled !== true);
11148
+ }
11149
+ toggleAll() {
11150
+ const e = this._enabledOptions, i = this.value !== undefined && this.value.length === e.length;
11151
+ this.value = i ? [] : e.map((t2) => t2.value);
11152
+ }
11153
+ toggleInvert() {
11154
+ const e = this.value;
11155
+ if (!e)
11156
+ return;
11157
+ const i = this._enabledOptions.filter((t2) => !e.includes(t2.value));
11158
+ this.value = i.map((t2) => t2.value);
11159
+ }
11160
+ toggleValue() {
11161
+ this.value === undefined && (this.value = []);
11162
+ const e = this.value.includes(this._value);
11163
+ this.value = e ? this.value.filter((i) => i !== this._value) : [...this.value, this._value];
11164
+ }
11165
+ constructor(e) {
11166
+ super(e, false), this.options = e.options, this.value = [...e.initialValues ?? []];
11167
+ const i = Math.max(this.options.findIndex(({ value: t2 }) => t2 === e.cursorAt), 0);
11168
+ this.cursor = this.options[i]?.disabled ? findCursor(i, 1, this.options) : i, this.on("key", (t2, l) => {
11169
+ l.name === "a" && this.toggleAll(), l.name === "i" && this.toggleInvert();
11170
+ }), this.on("cursor", (t2) => {
11171
+ switch (t2) {
11172
+ case "left":
11173
+ case "up":
11174
+ this.cursor = findCursor(this.cursor, -1, this.options);
11175
+ break;
11176
+ case "down":
11177
+ case "right":
11178
+ this.cursor = findCursor(this.cursor, 1, this.options);
11179
+ break;
11180
+ case "space":
11181
+ this.toggleValue();
11182
+ break;
11183
+ }
11184
+ });
11185
+ }
11186
+ }
11187
+ class n extends y {
11188
+ get userInputWithCursor() {
11189
+ if (this.state === "submit")
11190
+ return this.userInput;
11191
+ const t2 = this.userInput;
11192
+ if (this.cursor >= t2.length)
11193
+ return `${this.userInput}█`;
11194
+ const r = t2.slice(0, this.cursor), s = t2.slice(this.cursor, this.cursor + 1), e = t2.slice(this.cursor + 1);
11195
+ return `${r}${styleText("inverse", s)}${e}`;
11196
+ }
11197
+ get cursor() {
11198
+ return this._cursor;
11199
+ }
11200
+ constructor(t2) {
11201
+ super({
11202
+ ...t2,
11203
+ initialUserInput: t2.initialUserInput ?? t2.initialValue
11204
+ }), this.on("userInput", (r) => {
11205
+ this._setValue(r);
11206
+ }), this.on("finalize", () => {
11207
+ this.value || (this.value = t2.defaultValue), this.value === undefined && (this.value = "");
11208
+ });
11209
+ }
11210
+ }
11211
+
11212
+ // node_modules/@clack/prompts/dist/index.mjs
11213
+ import { styleText as styleText2, stripVTControlCharacters as stripVTControlCharacters3 } from "node:util";
11214
+ import process$1 from "node:process";
11215
+ var import_sisteransi2 = __toESM(require_src(), 1);
11216
+ function isUnicodeSupported() {
11217
+ if (process$1.platform !== "win32") {
11218
+ return process$1.env.TERM !== "linux";
11219
+ }
11220
+ return Boolean(process$1.env.CI) || Boolean(process$1.env.WT_SESSION) || Boolean(process$1.env.TERMINUS_SUBLIME) || process$1.env.ConEmuTask === "{cmd::Cmder}" || process$1.env.TERM_PROGRAM === "Terminus-Sublime" || process$1.env.TERM_PROGRAM === "vscode" || process$1.env.TERM === "xterm-256color" || process$1.env.TERM === "alacritty" || process$1.env.TERMINAL_EMULATOR === "JetBrains-JediTerm";
11221
+ }
11222
+ var unicode = isUnicodeSupported();
11223
+ var unicodeOr = (o2, e) => unicode ? o2 : e;
11224
+ var S_STEP_ACTIVE = unicodeOr("◆", "*");
11225
+ var S_STEP_CANCEL = unicodeOr("■", "x");
11226
+ var S_STEP_ERROR = unicodeOr("▲", "x");
11227
+ var S_STEP_SUBMIT = unicodeOr("◇", "o");
11228
+ var S_BAR_START = unicodeOr("┌", "T");
11229
+ var S_BAR = unicodeOr("│", "|");
11230
+ var S_BAR_END = unicodeOr("└", "—");
11231
+ var S_BAR_START_RIGHT = unicodeOr("┐", "T");
11232
+ var S_BAR_END_RIGHT = unicodeOr("┘", "—");
11233
+ var S_RADIO_ACTIVE = unicodeOr("●", ">");
11234
+ var S_RADIO_INACTIVE = unicodeOr("○", " ");
11235
+ var S_CHECKBOX_ACTIVE = unicodeOr("◻", "[•]");
11236
+ var S_CHECKBOX_SELECTED = unicodeOr("◼", "[+]");
11237
+ var S_CHECKBOX_INACTIVE = unicodeOr("◻", "[ ]");
11238
+ var S_PASSWORD_MASK = unicodeOr("▪", "•");
11239
+ var S_BAR_H = unicodeOr("─", "-");
11240
+ var S_CORNER_TOP_RIGHT = unicodeOr("╮", "+");
11241
+ var S_CONNECT_LEFT = unicodeOr("├", "+");
11242
+ var S_CORNER_BOTTOM_RIGHT = unicodeOr("╯", "+");
11243
+ var S_CORNER_BOTTOM_LEFT = unicodeOr("╰", "+");
11244
+ var S_CORNER_TOP_LEFT = unicodeOr("╭", "+");
11245
+ var S_INFO = unicodeOr("●", "•");
11246
+ var S_SUCCESS = unicodeOr("◆", "*");
11247
+ var S_WARN = unicodeOr("▲", "!");
11248
+ var S_ERROR = unicodeOr("■", "x");
11249
+ var symbol = (o2) => {
11250
+ switch (o2) {
11251
+ case "initial":
11252
+ case "active":
11253
+ return styleText2("cyan", S_STEP_ACTIVE);
11254
+ case "cancel":
11255
+ return styleText2("red", S_STEP_CANCEL);
11256
+ case "error":
11257
+ return styleText2("yellow", S_STEP_ERROR);
11258
+ case "submit":
11259
+ return styleText2("green", S_STEP_SUBMIT);
11260
+ case "validating":
11261
+ return styleText2("dim", S_STEP_ACTIVE);
11262
+ }
11263
+ };
11264
+ var symbolBar = (o2) => {
11265
+ switch (o2) {
11266
+ case "initial":
11267
+ case "active":
11268
+ return styleText2("cyan", S_BAR);
11269
+ case "cancel":
11270
+ return styleText2("red", S_BAR);
11271
+ case "error":
11272
+ return styleText2("yellow", S_BAR);
11273
+ case "submit":
11274
+ return styleText2("green", S_BAR);
11275
+ }
11276
+ };
11277
+ function formatInstructionFooter(o2, e) {
11278
+ const r2 = [`${e ? `${styleText2("cyan", S_BAR)} ` : ""}${o2.join(" • ")}`];
11279
+ return e && r2.push(styleText2("cyan", S_BAR_END)), r2;
11280
+ }
11281
+ var I = (l, e, w, p2, b2, C2 = false) => {
11282
+ let r2 = e, O = 0;
11283
+ if (C2)
11284
+ for (let i = p2 - 1;i >= w; i--) {
11285
+ const m2 = l[i];
11286
+ if (m2 && (r2 -= m2.length), O++, r2 <= b2)
11287
+ break;
11288
+ }
11289
+ else
11290
+ for (let i = w;i < p2; i++) {
11291
+ const m2 = l[i];
11292
+ if (m2 && (r2 -= m2.length), O++, r2 <= b2)
11293
+ break;
11294
+ }
11295
+ return { lineCount: r2, removals: O };
11296
+ };
11297
+ var limitOptions = ({
11298
+ cursor: l,
11299
+ options: e,
11300
+ style: w,
11301
+ output: p2 = process.stdout,
11302
+ maxItems: b2 = Number.POSITIVE_INFINITY,
11303
+ columnPadding: C2 = 0,
11304
+ rowPadding: r2 = 4
11305
+ }) => {
11306
+ const i = getColumns(p2) - C2, m2 = getRows(p2), M2 = styleText2("dim", "..."), v = Math.max(m2 - r2, 0), a2 = Math.max(Math.min(b2, v), 5);
11307
+ let f2 = 0;
11308
+ l >= a2 - 3 && (f2 = Math.max(Math.min(l - a2 + 3, e.length - a2), 0));
11309
+ let d = a2 < e.length && f2 > 0, c2 = a2 < e.length && f2 + a2 < e.length;
11310
+ const W = Math.min(f2 + a2, e.length), s = [];
11311
+ let g2 = 0;
11312
+ d && g2++, c2 && g2++;
11313
+ const T3 = f2 + (d ? 1 : 0), y2 = W - (c2 ? 1 : 0);
11314
+ for (let t2 = T3;t2 < y2; t2++) {
11315
+ const n2 = e[t2], o2 = n2 ? w(n2, t2 === l) : "", h2 = wrapAnsi(o2, i, {
11316
+ hard: true,
11317
+ trim: false
11318
+ }).split(`
11319
+ `);
11320
+ s.push(h2), g2 += h2.length;
11321
+ }
11322
+ if (g2 > v) {
11323
+ let t2 = 0, n2 = 0, o2 = g2;
11324
+ const h2 = l - T3;
11325
+ let u3 = v;
11326
+ const L = () => I(s, o2, 0, h2, u3), E = () => I(s, o2, h2 + 1, s.length, u3, true);
11327
+ d ? ({ lineCount: o2, removals: t2 } = L(), o2 > u3 && (c2 || (u3 -= 1), { lineCount: o2, removals: n2 } = E())) : (c2 || (u3 -= 1), { lineCount: o2, removals: n2 } = E(), o2 > u3 && (u3 -= 1, { lineCount: o2, removals: t2 } = L())), t2 > 0 && (d = true, s.splice(0, t2)), n2 > 0 && (c2 = true, s.splice(s.length - n2, n2));
11328
+ }
11329
+ const x = [];
11330
+ d && x.push(M2);
11331
+ for (const t2 of s)
11332
+ for (const n2 of t2)
11333
+ x.push(n2);
11334
+ return c2 && x.push(M2), x;
11335
+ };
11336
+ var MULTISELECT_INSTRUCTIONS = [
11337
+ `${styleText2("dim", "↑/↓")} to navigate`,
11338
+ `${styleText2("dim", "Space:")} select`,
11339
+ `${styleText2("dim", "Enter:")} confirm`
11340
+ ];
11341
+ var m2 = (i, u3) => i.split(`
11342
+ `).map((d) => u3(d)).join(`
11343
+ `);
11344
+ var multiselect = (i) => {
11345
+ const u3 = (t2, a2) => {
11346
+ const r2 = t2.label ?? String(t2.value);
11347
+ return a2 === "disabled" ? `${styleText2("gray", S_CHECKBOX_INACTIVE)} ${m2(r2, (o2) => styleText2(["strikethrough", "gray"], o2))}${t2.hint ? ` ${styleText2("dim", `(${t2.hint ?? "disabled"})`)}` : ""}` : a2 === "active" ? `${styleText2("cyan", S_CHECKBOX_ACTIVE)} ${r2}${t2.hint ? ` ${styleText2("dim", `(${t2.hint})`)}` : ""}` : a2 === "selected" ? `${styleText2("green", S_CHECKBOX_SELECTED)} ${m2(r2, (o2) => styleText2("dim", o2))}${t2.hint ? ` ${styleText2("dim", `(${t2.hint})`)}` : ""}` : a2 === "cancelled" ? `${m2(r2, (o2) => styleText2(["strikethrough", "dim"], o2))}` : a2 === "active-selected" ? `${styleText2("green", S_CHECKBOX_SELECTED)} ${r2}${t2.hint ? ` ${styleText2("dim", `(${t2.hint})`)}` : ""}` : a2 === "submitted" ? `${m2(r2, (o2) => styleText2("dim", o2))}` : `${styleText2("dim", S_CHECKBOX_INACTIVE)} ${m2(r2, (o2) => styleText2("dim", o2))}`;
11348
+ }, d = i.required ?? true, x = i.showInstructions ?? true;
11349
+ return new a({
11350
+ options: i.options,
11351
+ signal: i.signal,
11352
+ input: i.input,
11353
+ output: i.output,
11354
+ initialValues: i.initialValues,
11355
+ required: d,
11356
+ cursorAt: i.cursorAt,
11357
+ validate(t2) {
11358
+ if (d && (t2 === undefined || t2.length === 0))
11359
+ return `Please select at least one option.
11360
+ ${styleText2("reset", styleText2("dim", `Press ${styleText2(["gray", "bgWhite", "inverse"], " space ")} to select, ${styleText2("gray", styleText2("bgWhite", styleText2("inverse", " enter ")))} to submit`))}`;
11361
+ },
11362
+ render() {
11363
+ const t2 = i.withGuide ?? settings.withGuide, a2 = wrapTextWithPrefix(i.output, i.message, t2 ? `${symbolBar(this.state)} ` : "", `${symbol(this.state)} `), r2 = `${t2 ? `${styleText2("gray", S_BAR)}
11364
+ ` : ""}${a2}
11365
+ `, o2 = this.value ?? [], g2 = (n2, l) => {
11366
+ if (n2.disabled)
11367
+ return u3(n2, "disabled");
11368
+ const s = o2.includes(n2.value);
11369
+ return l && s ? u3(n2, "active-selected") : s ? u3(n2, "selected") : u3(n2, l ? "active" : "inactive");
11370
+ };
11371
+ switch (this.state) {
11372
+ case "submit": {
11373
+ const n2 = this.options.filter(({ value: s }) => o2.includes(s)).map((s) => u3(s, "submitted")).join(styleText2("dim", ", ")) || styleText2("dim", "none"), l = wrapTextWithPrefix(i.output, n2, t2 ? `${styleText2("gray", S_BAR)} ` : "");
11374
+ return `${r2}${l}`;
11375
+ }
11376
+ case "cancel": {
11377
+ const n2 = this.options.filter(({ value: s }) => o2.includes(s)).map((s) => u3(s, "cancelled")).join(styleText2("dim", ", "));
11378
+ if (n2.trim() === "")
11379
+ return `${r2}${styleText2("gray", S_BAR)}`;
11380
+ const l = wrapTextWithPrefix(i.output, n2, t2 ? `${styleText2("gray", S_BAR)} ` : "");
11381
+ return `${r2}${l}${t2 ? `
11382
+ ${styleText2("gray", S_BAR)}` : ""}`;
11383
+ }
11384
+ case "error": {
11385
+ const n2 = t2 ? `${styleText2("yellow", S_BAR)} ` : "", l = this.error.split(`
11386
+ `).map(($, v) => v === 0 ? `${t2 ? `${styleText2("yellow", S_BAR_END)} ` : ""}${styleText2("yellow", $)}` : ` ${$}`).join(`
11387
+ `), s = r2.split(`
11388
+ `).length, h2 = l.split(`
11389
+ `).length + 1;
11390
+ return `${r2}${n2}${limitOptions({
11391
+ output: i.output,
11392
+ options: this.options,
11393
+ cursor: this.cursor,
11394
+ maxItems: i.maxItems,
11395
+ columnPadding: n2.length,
11396
+ rowPadding: s + h2,
11397
+ style: g2
11398
+ }).join(`
11399
+ ${n2}`)}
11400
+ ${l}
11401
+ `;
11402
+ }
11403
+ default: {
11404
+ const n2 = t2 ? `${styleText2("cyan", S_BAR)} ` : "", l = r2.split(`
11405
+ `).length, s = x ? formatInstructionFooter(MULTISELECT_INSTRUCTIONS, t2) : t2 ? [styleText2("cyan", S_BAR_END)] : [], h2 = s.join(`
11406
+ `), $ = s.length + 1;
11407
+ return `${r2}${n2}${limitOptions({
11408
+ output: i.output,
11409
+ options: this.options,
11410
+ cursor: this.cursor,
11411
+ maxItems: i.maxItems,
11412
+ columnPadding: n2.length,
11413
+ rowPadding: l + $,
11414
+ style: g2
11415
+ }).join(`
11416
+ ${n2}`)}
11417
+ ${h2}
11418
+ `;
11419
+ }
11420
+ }
11421
+ }
11422
+ }).prompt();
11423
+ };
11424
+ var u3 = {
11425
+ light: unicodeOr("─", "-"),
11426
+ heavy: unicodeOr("━", "="),
11427
+ block: unicodeOr("█", "#")
11428
+ };
11429
+ var SELECT_INSTRUCTIONS = [
11430
+ `${styleText2("dim", "↑/↓")} to navigate`,
11431
+ `${styleText2("dim", "Enter:")} confirm`
11432
+ ];
11433
+ var i = `${styleText2("gray", S_BAR)} `;
11434
+ var text = (t2) => new n({
11435
+ validate: t2.validate,
11436
+ placeholder: t2.placeholder,
11437
+ defaultValue: t2.defaultValue,
11438
+ initialValue: t2.initialValue,
11439
+ output: t2.output,
11440
+ signal: t2.signal,
11441
+ input: t2.input,
11442
+ render() {
11443
+ const r2 = t2?.withGuide ?? settings.withGuide, l = `${`${r2 ? `${styleText2("gray", S_BAR)}
11444
+ ` : ""}${symbol(this.state)} `}${t2.message}
11445
+ `, d = t2.placeholder && t2.placeholder.length > 0 ? styleText2("inverse", t2.placeholder[0]) + styleText2("dim", t2.placeholder.slice(1)) : styleText2(["inverse", "hidden"], "_"), o2 = this.userInput ? this.userInputWithCursor : d, s = this.value ?? "";
11446
+ switch (this.state) {
11447
+ case "validating": {
11448
+ const n2 = r2 ? `${styleText2("cyan", S_BAR)} ` : "", i2 = r2 ? styleText2("cyan", S_BAR_END) : "", c2 = styleText2("dim", o2), $ = styleText2("dim", "Validating...");
11449
+ return `${l}${n2}${c2}
11450
+ ${i2} ${$}
11451
+ `;
11452
+ }
11453
+ case "error": {
11454
+ const n2 = this.error ? ` ${styleText2("yellow", this.error)}` : "", i2 = r2 ? `${styleText2("yellow", S_BAR)} ` : "", c2 = r2 ? styleText2("yellow", S_BAR_END) : "";
11455
+ return `${l.trim()}
11456
+ ${i2}${o2}
11457
+ ${c2}${n2}
11458
+ `;
11459
+ }
11460
+ case "submit": {
11461
+ const n2 = s ? `${r2 ? " " : ""}${styleText2("dim", s)}` : "", i2 = r2 ? styleText2("gray", S_BAR) : "";
11462
+ return `${l}${i2}${n2}`;
11463
+ }
11464
+ case "cancel": {
11465
+ const n2 = s ? ` ${styleText2(["strikethrough", "dim"], s)}` : "", i2 = r2 ? styleText2("gray", S_BAR) : "";
11466
+ return `${l}${i2}${n2}${s.trim() ? `
11467
+ ${i2}` : ""}`;
11468
+ }
11469
+ default: {
11470
+ const n2 = r2 ? `${styleText2("cyan", S_BAR)} ` : "", i2 = r2 ? styleText2("cyan", S_BAR_END) : "";
11471
+ return `${l}${n2}${o2}
11472
+ ${i2}
11473
+ `;
11474
+ }
11475
+ }
11476
+ }
11477
+ }).prompt();
11478
+
11479
+ // src/install.ts
9962
11480
  var self = fileURLToPath(import.meta.url);
9963
11481
  var pkgRoot = dirname(dirname(self));
9964
11482
  var plugin = join7(pkgRoot, "plugin");
@@ -10053,12 +11571,12 @@ function settingsTarget(path2) {
10053
11571
  function unwritableSettings(path2, reason) {
10054
11572
  return fail(`theway: cannot write ${path2}: ${reason}; nothing was changed`);
10055
11573
  }
10056
- function writeSettings(target, settings) {
11574
+ function writeSettings(target, settings2) {
10057
11575
  mkdirSync3(dirname(target), { recursive: true });
10058
11576
  const mode = existsSync3(target) ? statSync3(target).mode & 511 : 384;
10059
11577
  const tmp = `${target}.tmp-${process.pid}`;
10060
11578
  try {
10061
- writeFileSync2(tmp, `${JSON.stringify(settings, null, 2)}
11579
+ writeFileSync2(tmp, `${JSON.stringify(settings2, null, 2)}
10062
11580
  `, { mode });
10063
11581
  chmodSync(tmp, mode);
10064
11582
  renameSync3(tmp, target);
@@ -10101,14 +11619,14 @@ function legacyText(path2, match) {
10101
11619
  }
10102
11620
  }
10103
11621
  function removeLegacyBin(home) {
10104
- for (const h of new Set([defaultHome(), resolve3(home)])) {
10105
- const bin = join7(h, "bin");
10106
- if (legacyText(join7(bin, "theway"), (t) => t.startsWith(`#!/bin/sh
10107
- exec node `) && t.endsWith(`theway.js' "$@"
11622
+ for (const h2 of new Set([defaultHome(), resolve3(home)])) {
11623
+ const bin = join7(h2, "bin");
11624
+ if (legacyText(join7(bin, "theway"), (t2) => t2.startsWith(`#!/bin/sh
11625
+ exec node `) && t2.endsWith(`theway.js' "$@"
10108
11626
  `))) {
10109
11627
  rmSync2(join7(bin, "theway"), { force: true });
10110
11628
  }
10111
- if (legacyText(join7(bin, "theway.js"), (t) => t.startsWith(`#!/usr/bin/env node
11629
+ if (legacyText(join7(bin, "theway.js"), (t2) => t2.startsWith(`#!/usr/bin/env node
10112
11630
  `))) {
10113
11631
  rmSync2(join7(bin, "theway.js"), { force: true });
10114
11632
  }
@@ -10140,8 +11658,8 @@ function isThewayBinary(path2) {
10140
11658
  if (!isFile(path2))
10141
11659
  return false;
10142
11660
  try {
10143
- const text = readFileSync8(path2, "utf-8");
10144
- return text.startsWith("#!/usr/bin/env node") && text.includes(BINARY_MARKER);
11661
+ const text2 = readFileSync8(path2, "utf-8");
11662
+ return text2.startsWith("#!/usr/bin/env node") && text2.includes(BINARY_MARKER);
10145
11663
  } catch {
10146
11664
  return false;
10147
11665
  }
@@ -10209,30 +11727,137 @@ function checkPath(dir, binary) {
10209
11727
  `);
10210
11728
  }
10211
11729
  }
10212
- function install() {
11730
+ var OPT_IN_HINTS = {
11731
+ core_principles: "Architecture philosophy (simplicity, security, pragmatic technology)",
11732
+ sre: "SRE operational excellence (reliability, observability, automation)",
11733
+ web_development: "Frontend, API and backend standards with web performance targets",
11734
+ quality: "Testing, deployment, monitoring and security expectations"
11735
+ };
11736
+ var CANCELLED = "theway: install cancelled; nothing was changed";
11737
+ function expandHome(value) {
11738
+ const v = value.trim();
11739
+ if (v === "")
11740
+ return { error: "must not be empty" };
11741
+ if (v === "~")
11742
+ return homedir2();
11743
+ if (v.startsWith("~/"))
11744
+ return resolve3(homedir2(), v.slice(2));
11745
+ if (isAbsolute(v))
11746
+ return resolve3(v);
11747
+ return { error: "must be an absolute path or start with ~/" };
11748
+ }
11749
+ function parseStandards(value) {
11750
+ if (value === "none")
11751
+ return [];
11752
+ const elements = value.split(",");
11753
+ const unknownError = (element) => ({
11754
+ error: `theway: unknown standard '${element}' in --standards; valid: ${OPT_IN_KEYS.join(", ")}, or none`
11755
+ });
11756
+ const unknown = elements.find((e) => e !== "none" && !OPT_IN_KEYS.includes(e));
11757
+ if (unknown !== undefined)
11758
+ return unknownError(unknown);
11759
+ if (!elements.includes("none"))
11760
+ return elements;
11761
+ if (elements.some((e) => e !== "none")) {
11762
+ return { error: "theway: --standards none cannot be combined with other standards" };
11763
+ }
11764
+ return unknownError("none");
11765
+ }
11766
+ function interactive() {
11767
+ return process.stdin.isTTY === true && process.stdout.isTTY === true;
11768
+ }
11769
+ async function askHome() {
11770
+ const answer = await text({
11771
+ message: "Where should theway keep its data?",
11772
+ placeholder: "~/.theway",
11773
+ defaultValue: "~/.theway",
11774
+ validate: (value) => {
11775
+ if (value === undefined || value.trim() === "")
11776
+ return;
11777
+ const home2 = expandHome(value);
11778
+ if (typeof home2 !== "string")
11779
+ return home2.error;
11780
+ const reason = unsafeHomeReason(home2, home2 !== resolve3(defaultHome()));
11781
+ return reason !== "" ? `refusing ${home2}: ${reason}` : undefined;
11782
+ }
11783
+ });
11784
+ if (isCancel(answer))
11785
+ return null;
11786
+ const home = expandHome(answer.trim() === "" ? "~/.theway" : answer);
11787
+ return typeof home === "string" ? home : null;
11788
+ }
11789
+ async function askStandards() {
11790
+ const answer = await multiselect({
11791
+ message: "Enable opt-in standards",
11792
+ options: OPT_IN_KEYS.map((key) => ({ value: key, label: key, hint: OPT_IN_HINTS[key] })),
11793
+ required: false
11794
+ });
11795
+ return isCancel(answer) ? null : answer;
11796
+ }
11797
+ async function install(opts) {
10213
11798
  if (!existsSync3(join7(plugin, ".claude-plugin"))) {
10214
11799
  return fail("theway: run `npx --yes @pixelfactoryio/theway@latest install` to install or update theway");
10215
11800
  }
11801
+ let enabled2 = [];
11802
+ if (opts.standards !== undefined) {
11803
+ const parsed = parseStandards(opts.standards);
11804
+ if (!Array.isArray(parsed))
11805
+ return fail(parsed.error);
11806
+ enabled2 = parsed;
11807
+ }
10216
11808
  const cHome = claudeHome();
10217
- const tHome = resolveHome().home;
11809
+ let tHome;
11810
+ if (opts.home !== undefined) {
11811
+ const home = expandHome(opts.home);
11812
+ if (typeof home !== "string")
11813
+ return fail(`theway: invalid --home '${opts.home}': ${home.error}; nothing was changed`);
11814
+ const env = process.env.THEWAY_HOME ?? "";
11815
+ if (env !== "" && resolve3(env) !== home) {
11816
+ return fail(`theway: --home ${home} and THEWAY_HOME ${resolve3(env)} differ; unset THEWAY_HOME or drop --home; nothing was changed`);
11817
+ }
11818
+ tHome = home;
11819
+ } else {
11820
+ const found = resolveHome();
11821
+ const neverInstalled = found.source === "default" && !existsSync3(join7(defaultHome(), "config.yaml"));
11822
+ if (neverInstalled && interactive()) {
11823
+ const home = await askHome();
11824
+ if (home === null)
11825
+ return fail(CANCELLED);
11826
+ tHome = home;
11827
+ } else {
11828
+ tHome = found.home;
11829
+ }
11830
+ }
10218
11831
  const previous = recordedHome();
10219
11832
  const custom = tHome !== resolve3(defaultHome());
10220
11833
  const dir = installDir();
10221
11834
  const settingsPath = join7(cHome, "settings.json");
10222
11835
  const unsafe = unsafeHomeReason(tHome, custom);
10223
11836
  if (unsafe !== "") {
10224
- return fail(`theway: refusing data home ${resolve3(tHome)}: ${unsafe}; set THEWAY_HOME to a dedicated folder`);
11837
+ return fail(`theway: refusing data home ${resolve3(tHome)}: ${unsafe}; set THEWAY_HOME or --home to a dedicated folder`);
10225
11838
  }
10226
11839
  const resolved = settingsTarget(settingsPath);
10227
11840
  if ("error" in resolved)
10228
11841
  return unwritableSettings(settingsPath, resolved.error);
10229
- const settings = readSettings(resolved.target);
10230
- if (settings === null)
11842
+ const settings2 = readSettings(resolved.target);
11843
+ if (settings2 === null)
10231
11844
  return invalidSettings(settingsPath);
10232
11845
  const target = join7(dir, "theway");
10233
11846
  if (occupied(target) && !isThewayBinary(target)) {
10234
11847
  return fail(`theway: ${target} exists and is not a theway binary; nothing was changed. Remove it, or set THEWAY_INSTALL_DIR to another folder`);
10235
11848
  }
11849
+ const config = join7(resolve3(tHome), "config.yaml");
11850
+ const firstInstall = !existsSync3(config);
11851
+ if (opts.standards !== undefined && !firstInstall) {
11852
+ return fail(`theway: --standards applies only to a first install; ${config} exists, so set standards.<key>.enabled there instead; nothing was changed`);
11853
+ }
11854
+ const asked = firstInstall && opts.standards === undefined && interactive();
11855
+ if (asked) {
11856
+ const chosen = await askStandards();
11857
+ if (chosen === null)
11858
+ return fail(CANCELLED);
11859
+ enabled2 = chosen;
11860
+ }
10236
11861
  const dest = copyPlugin(cHome);
10237
11862
  let binary;
10238
11863
  try {
@@ -10241,29 +11866,33 @@ function install() {
10241
11866
  } catch (e) {
10242
11867
  return fail(`theway: ${e.message}`);
10243
11868
  }
10244
- const status = init(join7(plugin, "home"), tHome);
11869
+ const status = init(join7(plugin, "home"), tHome, enabled2);
10245
11870
  if (status !== 0)
10246
11871
  return status;
11872
+ if (firstInstall && opts.standards === undefined && !asked) {
11873
+ process.stdout.write(`Opt-in standards are off (${OPT_IN_KEYS.join(", ")}): set standards.<key>.enabled: true in ${config} to enable one
11874
+ `);
11875
+ }
10247
11876
  try {
10248
11877
  writePointer(tHome, custom);
10249
11878
  } catch (e) {
10250
11879
  return fail(`theway: ${e.message}`);
10251
11880
  }
10252
- const perms = settings.permissions ?? {};
11881
+ const perms = settings2.permissions ?? {};
10253
11882
  const allow = perms.allow ?? [];
10254
11883
  const current = rules(tHome);
10255
11884
  const stale = [
10256
11885
  ...legacyRules(tHome),
10257
11886
  editRule(tHome),
10258
11887
  editRule(previous),
10259
- ...homeRules(previous).filter((r) => !current.includes(r))
11888
+ ...homeRules(previous).filter((r2) => !current.includes(r2))
10260
11889
  ];
10261
- const kept = allow.filter((r) => !(typeof r === "string" && stale.includes(r)));
10262
- const missing = current.filter((r) => !kept.includes(r));
11890
+ const kept = allow.filter((r2) => !(typeof r2 === "string" && stale.includes(r2)));
11891
+ const missing = current.filter((r2) => !kept.includes(r2));
10263
11892
  if (missing.length > 0 || kept.length !== allow.length) {
10264
- settings.permissions = { ...perms, allow: [...kept, ...missing] };
11893
+ settings2.permissions = { ...perms, allow: [...kept, ...missing] };
10265
11894
  mkdirSync3(cHome, { recursive: true });
10266
- writeSettings(resolved.target, settings);
11895
+ writeSettings(resolved.target, settings2);
10267
11896
  }
10268
11897
  checkPath(dir, binary);
10269
11898
  const version = JSON.parse(readFileSync8(join7(pkgRoot, "package.json"), "utf-8")).version;
@@ -10291,16 +11920,16 @@ function uninstall() {
10291
11920
  rmSync2(pointerPath(), { force: true });
10292
11921
  removeIfEmpty2(dirname(pointerPath()));
10293
11922
  if (existsSync3(settingsPath)) {
10294
- const settings = readSettings(settingsFile);
10295
- if (settings === null)
11923
+ const settings2 = readSettings(settingsFile);
11924
+ if (settings2 === null)
10296
11925
  return invalidSettings(settingsPath);
10297
- const allow = settings.permissions?.allow;
11926
+ const allow = settings2.permissions?.allow;
10298
11927
  if (Array.isArray(allow)) {
10299
- const drop = homes.flatMap((h) => [...rules(h), ...legacyRules(h), editRule(h)]);
10300
- const kept = allow.filter((r) => !(typeof r === "string" && drop.includes(r)));
11928
+ const drop = homes.flatMap((h2) => [...rules(h2), ...legacyRules(h2), editRule(h2)]);
11929
+ const kept = allow.filter((r2) => !(typeof r2 === "string" && drop.includes(r2)));
10301
11930
  if (kept.length !== allow.length) {
10302
- settings.permissions = { ...settings.permissions, allow: kept };
10303
- writeSettings(settingsFile, settings);
11931
+ settings2.permissions = { ...settings2.permissions, allow: kept };
11932
+ writeSettings(settingsFile, settings2);
10304
11933
  }
10305
11934
  }
10306
11935
  }
@@ -10326,17 +11955,17 @@ var exit = (code) => {
10326
11955
  };
10327
11956
  function buildProgram() {
10328
11957
  const program2 = new Command("theway");
10329
- program2.command("install").action(() => exit(install()));
11958
+ program2.command("install").option("--home <path>", "", nonEmpty).option("--standards <keys>").action(async (o2) => exit(await install({ home: o2.home, standards: o2.standards })));
10330
11959
  program2.command("uninstall").action(() => exit(uninstall()));
10331
11960
  program2.command("list").argument("<project>", "", nonEmpty).action((project) => exit(cmdList(project)));
10332
- program2.command("archive").argument("<project>", "", nonEmpty).argument("<change-id>", "", nonEmpty).option("--force").action((project, change, o) => exit(cmdArchive(project, change, o.force === true)));
10333
- program2.command("path").argument("[project]").argument("[change-id]").option("--verbose").action((project, change, o) => exit(cmdPath(project, change, o.verbose === true)));
11961
+ program2.command("archive").argument("<project>", "", nonEmpty).argument("<change-id>", "", nonEmpty).option("--force").action((project, change, o2) => exit(cmdArchive(project, change, o2.force === true)));
11962
+ program2.command("path").argument("[project]").argument("[change-id]").option("--verbose").action((project, change, o2) => exit(cmdPath(project, change, o2.verbose === true)));
10334
11963
  program2.command("config").argument("<project>").action((project) => exit(cmdConfig(project)));
10335
11964
  program2.command("standards").argument("<project>").argument("<phase>").action((project, phase) => exit(cmdStandards(project, phase)));
10336
11965
  program2.command("context").argument("<project>").argument("<phase>").argument("[change-id]").action((project, phase, change) => exit(cmdContext(project, phase, change)));
10337
11966
  program2.command("authority").action(() => exit(cmdAuthority()));
10338
- program2.command("next-id").argument("<project>").argument("<series-id>").option("--count <n>", "", positive, 1).action((project, series, o) => exit(cmdNextId(project, series, o.count)));
10339
- program2.command("validate-id").argument("<id>").option("--series").action((id, o) => exit(cmdValidateId(id, o.series === true)));
11967
+ program2.command("next-id").argument("<project>").argument("<series-id>").option("--count <n>", "", positive, 1).action((project, series, o2) => exit(cmdNextId(project, series, o2.count)));
11968
+ program2.command("validate-id").argument("<id>").option("--series").action((id, o2) => exit(cmdValidateId(id, o2.series === true)));
10340
11969
  return program2;
10341
11970
  }
10342
11971
 
@@ -10347,4 +11976,4 @@ if (major < 22 || major === 22 && minor < 12) {
10347
11976
  `);
10348
11977
  process.exit(1);
10349
11978
  }
10350
- buildProgram().parse();
11979
+ buildProgram().parseAsync();