@keynv/cli 0.1.0-rc.14 → 0.1.0-rc.15

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,12 +1,12 @@
1
1
  #!/usr/bin/env node
2
2
  import { createRequire } from 'module';
3
- import { randomBytes } from 'crypto';
4
- import { readFileSync, writeFileSync, unlinkSync, existsSync, statSync, readdirSync, mkdirSync, rmSync } from 'fs';
3
+ import { createHash, randomBytes } from 'crypto';
4
+ import { readFileSync, writeFileSync, unlinkSync, existsSync, statSync, readdirSync, mkdirSync, rmSync, lstatSync } from 'fs';
5
5
  import { hostname, platform, homedir } from 'os';
6
6
  import * as nodePath from 'path';
7
7
  import { relative, join, isAbsolute, resolve, dirname, basename } from 'path';
8
8
  import { Entry } from '@napi-rs/keyring';
9
- import { styleText } from 'util';
9
+ import { styleText, stripVTControlCharacters } from 'util';
10
10
  import j2, { stdin, stdout } from 'process';
11
11
  import * as b from 'readline';
12
12
  import b__default, { createInterface } from 'readline';
@@ -20,11 +20,11 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
20
20
  var __getOwnPropNames = Object.getOwnPropertyNames;
21
21
  var __getProtoOf = Object.getPrototypeOf;
22
22
  var __hasOwnProp = Object.prototype.hasOwnProperty;
23
- var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
23
+ var __require = /* @__PURE__ */ ((x2) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x2, {
24
24
  get: (a, b2) => (typeof require !== "undefined" ? require : a)[b2]
25
- }) : x)(function(x) {
25
+ }) : x2)(function(x2) {
26
26
  if (typeof require !== "undefined") return require.apply(this, arguments);
27
- throw Error('Dynamic require of "' + x + '" is not supported');
27
+ throw Error('Dynamic require of "' + x2 + '" is not supported');
28
28
  });
29
29
  var __esm = (fn, res) => function __init() {
30
30
  return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
@@ -1057,14 +1057,20 @@ var require_lib = __commonJS({
1057
1057
  var VERSION, AGENT;
1058
1058
  var init_version = __esm({
1059
1059
  "src/version.ts"() {
1060
- VERSION = "0.1.0-rc.14" ;
1060
+ VERSION = "0.1.0-rc.15" ;
1061
1061
  AGENT = `keynv-cli/${VERSION}`;
1062
1062
  }
1063
1063
  });
1064
1064
 
1065
1065
  // ../../packages/core/dist/reference/types.js
1066
+ var ALIAS_LIMITS;
1066
1067
  var init_types = __esm({
1067
1068
  "../../packages/core/dist/reference/types.js"() {
1069
+ ALIAS_LIMITS = {
1070
+ project: { min: 1, max: 48 },
1071
+ environment: { min: 1, max: 24 },
1072
+ key: { min: 1, max: 64 }
1073
+ };
1068
1074
  }
1069
1075
  });
1070
1076
 
@@ -1096,10 +1102,10 @@ function parseAlias(input) {
1096
1102
  function findAliases(text, opts = {}) {
1097
1103
  if (typeof text !== "string" || text.length === 0)
1098
1104
  return [];
1099
- const re = opts.mode === "argv" ? ARGV_FIND_RE : TEXT_FIND_RE;
1100
- re.lastIndex = 0;
1105
+ const re2 = opts.mode === "argv" ? ARGV_FIND_RE : TEXT_FIND_RE;
1106
+ re2.lastIndex = 0;
1101
1107
  const matches = [];
1102
- for (const m of text.matchAll(re)) {
1108
+ for (const m of text.matchAll(re2)) {
1103
1109
  const literal = m[0];
1104
1110
  const start = m.index;
1105
1111
  if (start === void 0)
@@ -1128,6 +1134,25 @@ function findAliasesInArgv(argv2) {
1128
1134
  }
1129
1135
  return result;
1130
1136
  }
1137
+ function replaceAliases(text, resolve4, opts = {}) {
1138
+ if (typeof text !== "string" || text.length === 0)
1139
+ return text;
1140
+ const matches = findAliases(text, opts);
1141
+ if (matches.length === 0)
1142
+ return text;
1143
+ let out = text;
1144
+ for (let i = matches.length - 1; i >= 0; i--) {
1145
+ const m = matches[i];
1146
+ if (!m)
1147
+ continue;
1148
+ const replacement = resolve4(m);
1149
+ if (replacement.startsWith("@") && PROJECT_RE.test(replacement.slice(1).split(".")[0] ?? "")) {
1150
+ throw new Error(`replaceAliases: resolved value for ${m.literal} looks like an alias (${replacement}). Circular or misconfigured resolution detected.`);
1151
+ }
1152
+ out = out.slice(0, m.start) + replacement + out.slice(m.end);
1153
+ }
1154
+ return out;
1155
+ }
1131
1156
  function buildAlias(parts) {
1132
1157
  if (!PROJECT_RE.test(parts.project))
1133
1158
  return null;
@@ -1157,6 +1182,15 @@ var init_parser = __esm({
1157
1182
  });
1158
1183
 
1159
1184
  // ../../packages/core/dist/reference/index.js
1185
+ var reference_exports = {};
1186
+ __export(reference_exports, {
1187
+ ALIAS_LIMITS: () => ALIAS_LIMITS,
1188
+ buildAlias: () => buildAlias,
1189
+ findAliases: () => findAliases,
1190
+ findAliasesInArgv: () => findAliasesInArgv,
1191
+ parseAlias: () => parseAlias,
1192
+ replaceAliases: () => replaceAliases
1193
+ });
1160
1194
  var init_reference = __esm({
1161
1195
  "../../packages/core/dist/reference/index.js"() {
1162
1196
  init_types();
@@ -1673,7 +1707,7 @@ function addIssueToContext(ctx, issueData) {
1673
1707
  // then global override map
1674
1708
  overrideMap === en_default ? void 0 : en_default
1675
1709
  // then global default map
1676
- ].filter((x) => !!x)
1710
+ ].filter((x2) => !!x2)
1677
1711
  });
1678
1712
  ctx.common.issues.push(issue);
1679
1713
  }
@@ -1767,10 +1801,10 @@ var init_parseUtil = __esm({
1767
1801
  });
1768
1802
  DIRTY = (value) => ({ status: "dirty", value });
1769
1803
  OK = (value) => ({ status: "valid", value });
1770
- isAborted = (x) => x.status === "aborted";
1771
- isDirty = (x) => x.status === "dirty";
1772
- isValid = (x) => x.status === "valid";
1773
- isAsync = (x) => typeof Promise !== "undefined" && x instanceof Promise;
1804
+ isAborted = (x2) => x2.status === "aborted";
1805
+ isDirty = (x2) => x2.status === "dirty";
1806
+ isValid = (x2) => x2.status === "valid";
1807
+ isAsync = (x2) => typeof Promise !== "undefined" && x2 instanceof Promise;
1774
1808
  }
1775
1809
  });
1776
1810
 
@@ -4270,7 +4304,7 @@ var init_types4 = __esm({
4270
4304
  if (!schema)
4271
4305
  return null;
4272
4306
  return schema._parse(new ParseInputLazyPath(ctx, item, ctx.path, itemIndex));
4273
- }).filter((x) => !!x);
4307
+ }).filter((x2) => !!x2);
4274
4308
  if (ctx.common.async) {
4275
4309
  return Promise.all(items).then((results) => {
4276
4310
  return ParseStatus.mergeArray(status, results);
@@ -4523,7 +4557,7 @@ var init_types4 = __esm({
4523
4557
  return makeIssue({
4524
4558
  data: args,
4525
4559
  path: ctx.path,
4526
- errorMaps: [ctx.common.contextualErrorMap, ctx.schemaErrorMap, getErrorMap(), en_default].filter((x) => !!x),
4560
+ errorMaps: [ctx.common.contextualErrorMap, ctx.schemaErrorMap, getErrorMap(), en_default].filter((x2) => !!x2),
4527
4561
  issueData: {
4528
4562
  code: ZodIssueCode.invalid_arguments,
4529
4563
  argumentsError: error
@@ -4534,7 +4568,7 @@ var init_types4 = __esm({
4534
4568
  return makeIssue({
4535
4569
  data: returns,
4536
4570
  path: ctx.path,
4537
- errorMaps: [ctx.common.contextualErrorMap, ctx.schemaErrorMap, getErrorMap(), en_default].filter((x) => !!x),
4571
+ errorMaps: [ctx.common.contextualErrorMap, ctx.schemaErrorMap, getErrorMap(), en_default].filter((x2) => !!x2),
4538
4572
  issueData: {
4539
4573
  code: ZodIssueCode.invalid_return_type,
4540
4574
  returnTypeError: error
@@ -5389,7 +5423,7 @@ var init_payload_schemas = __esm({
5389
5423
  role = external_exports.enum(["lead", "developer", "reader"]);
5390
5424
  orgRole = external_exports.enum(["owner", "admin", "developer", "reader"]);
5391
5425
  email = external_exports.string().email();
5392
- version = external_exports.number().int().positive();
5426
+ version = external_exports.coerce.number().int().positive();
5393
5427
  empty = external_exports.object({}).strict();
5394
5428
  orgId = external_exports.string().min(1);
5395
5429
  ({
@@ -5437,10 +5471,12 @@ var init_payload_schemas = __esm({
5437
5471
  }).strict(),
5438
5472
  "secret.deleted": external_exports.object({ project_id: projectId, env, key }).strict(),
5439
5473
  "secret.test.invoked": external_exports.object({ alias, tester: external_exports.string(), ok: external_exports.boolean(), latency_ms: external_exports.number() }).strict(),
5474
+ "secret.test.denied": external_exports.object({ alias }).strict(),
5440
5475
  "approval.requested": external_exports.object({ alias }).strict(),
5441
5476
  "approval.granted": external_exports.object({ alias, granted_by: userId }).strict(),
5442
5477
  "approval.denied": external_exports.object({ alias, denied_by: userId }).strict(),
5443
- "kek.rotated": empty
5478
+ "org.created": external_exports.object({ org_id: orgId, name: external_exports.string().min(1) }).strict(),
5479
+ "org.updated": external_exports.object({ org_id: orgId, name: external_exports.string().min(1) }).strict()
5444
5480
  });
5445
5481
  }
5446
5482
  });
@@ -5472,15 +5508,16 @@ function entry() {
5472
5508
  return new Entry(SERVICE, KEY_ACCOUNT);
5473
5509
  }
5474
5510
  async function loadOrCreateKey() {
5511
+ if (process.env["KEYNV_DISABLE_KEYCHAIN"] === "1") {
5512
+ return loadOrCreateFileKey();
5513
+ }
5475
5514
  const e2 = entry();
5476
5515
  let stored;
5477
5516
  try {
5478
5517
  stored = e2.getPassword();
5479
- } catch (err) {
5480
- const message = err instanceof Error ? err.message : String(err);
5481
- throw new Error(
5482
- `keynv: OS keychain unavailable (${message}). Install libsecret on Linux, or set KEYNV_DISABLE_KEYCHAIN=1 to use a (less secure) file-based key store.`
5483
- );
5518
+ } catch {
5519
+ const message = process.env["KEYNV_DISABLE_KEYCHAIN"] ? "keynv: OS keychain unavailable. Set KEYNV_DISABLE_KEYCHAIN=1 to use a file-based key store (less secure)." : "keynv: OS keychain unavailable. Install libsecret on Linux, or set KEYNV_DISABLE_KEYCHAIN=1 to use a file-based key store (less secure).";
5520
+ throw new Error(message);
5484
5521
  }
5485
5522
  if (stored) {
5486
5523
  return new Uint8Array(Buffer.from(stored, "base64"));
@@ -5495,6 +5532,20 @@ async function loadOrCreateKey() {
5495
5532
  }
5496
5533
  return fresh;
5497
5534
  }
5535
+ function fileKeyPath() {
5536
+ return process.env["KEYNV_CREDENTIALS_KEY_FILE"] ?? join(homedir(), ".keynv", ".credentials-key");
5537
+ }
5538
+ async function loadOrCreateFileKey() {
5539
+ const path = fileKeyPath();
5540
+ if (existsSync(path)) {
5541
+ const raw = readFileSync(path, "utf8").trim();
5542
+ return new Uint8Array(Buffer.from(raw, "base64"));
5543
+ }
5544
+ const fresh = await crypto_exports.generateKey();
5545
+ if (!existsSync(dirname(path))) mkdirSync(dirname(path), { recursive: true, mode: 448 });
5546
+ writeFileSync(path, Buffer.from(fresh).toString("base64"), { mode: 384 });
5547
+ return fresh;
5548
+ }
5498
5549
  async function saveCredentialsBlob(plaintext) {
5499
5550
  const key2 = await loadOrCreateKey();
5500
5551
  const sealed = await crypto_exports.encryptSecret(Buffer.from(plaintext).toString("utf8"), key2);
@@ -5535,6 +5586,11 @@ function clearCredentialsFile() {
5535
5586
  if (existsSync(path)) rmSync(path, { force: true });
5536
5587
  const legacy = legacyPath();
5537
5588
  if (existsSync(legacy)) rmSync(legacy, { force: true });
5589
+ if (process.env["KEYNV_DISABLE_KEYCHAIN"] === "1") {
5590
+ const keyPath = fileKeyPath();
5591
+ if (existsSync(keyPath)) rmSync(keyPath, { force: true });
5592
+ return true;
5593
+ }
5538
5594
  try {
5539
5595
  entry().deletePassword();
5540
5596
  return true;
@@ -5769,8 +5825,7 @@ function handleExecError(stderr, err) {
5769
5825
  stderr.write(`keynv: ${err.message}
5770
5826
  `);
5771
5827
  } else {
5772
- stderr.write(`keynv: unexpected error
5773
- `);
5828
+ stderr.write("keynv: unexpected error\n");
5774
5829
  }
5775
5830
  return 1;
5776
5831
  }
@@ -5845,7 +5900,7 @@ function parseEnvFile(content, filename) {
5845
5900
  entries.push({
5846
5901
  name,
5847
5902
  value,
5848
- isAlias: parseAlias(value) !== null,
5903
+ isAlias: reference_exports.parseAlias(value) !== null,
5849
5904
  line: lineNo
5850
5905
  });
5851
5906
  }
@@ -5920,247 +5975,6 @@ var init_envFile = __esm({
5920
5975
  };
5921
5976
  }
5922
5977
  });
5923
- function findProjectRoot(startDir) {
5924
- const result = walkUp(startDir, (dir) => {
5925
- for (const marker of PROJECT_MARKERS) {
5926
- if (existsSync(join(dir, marker))) {
5927
- return { dir, marker };
5928
- }
5929
- }
5930
- if (existsSync(join(dir, GIT_MARKER))) {
5931
- return { dir, marker: GIT_MARKER };
5932
- }
5933
- return null;
5934
- });
5935
- if (!result) return null;
5936
- return buildRoot(result.dir, result.marker);
5937
- }
5938
- function buildRoot(dir, marker) {
5939
- let suggestedName = basename(dir);
5940
- let scripts = null;
5941
- let invalid = false;
5942
- if (marker === "package.json" || existsSync(join(dir, "package.json"))) {
5943
- try {
5944
- const pkg = JSON.parse(readFileSync(join(dir, "package.json"), "utf8"));
5945
- if (typeof pkg.name === "string" && pkg.name.length > 0) {
5946
- suggestedName = pkg.name.replace(/^@[^/]+\//, "");
5947
- }
5948
- if (pkg.scripts && typeof pkg.scripts === "object") {
5949
- scripts = Object.fromEntries(
5950
- Object.entries(pkg.scripts).filter(([, v2]) => typeof v2 === "string")
5951
- );
5952
- }
5953
- } catch {
5954
- invalid = true;
5955
- }
5956
- }
5957
- return {
5958
- path: dir,
5959
- suggestedName,
5960
- marker,
5961
- packageJsonScripts: scripts,
5962
- packageJsonInvalid: invalid
5963
- };
5964
- }
5965
- function findEnvFiles(rootDir) {
5966
- let entries;
5967
- try {
5968
- entries = readdirSync(rootDir);
5969
- } catch {
5970
- return [];
5971
- }
5972
- const hits = [];
5973
- for (const name of entries) {
5974
- if (!ENV_GLOB.test(name)) continue;
5975
- if (ENV_EXAMPLE.test(name)) continue;
5976
- if (name === KEYNV_ENV_BASENAME) continue;
5977
- const full = join(rootDir, name);
5978
- try {
5979
- if (!statSync(full).isFile()) continue;
5980
- } catch {
5981
- continue;
5982
- }
5983
- const suffixMatch = name.match(/^\.env\.(.+)$/);
5984
- const suffix = suffixMatch ? suffixMatch[1] : null;
5985
- hits.push({ path: full, name, suffix, suggestedEnv: suggestedEnvForSuffix(suffix) });
5986
- }
5987
- hits.sort((a, b2) => {
5988
- if (a.suffix === null) return -1;
5989
- if (b2.suffix === null) return 1;
5990
- return a.name.localeCompare(b2.name);
5991
- });
5992
- return hits;
5993
- }
5994
- function suggestedEnvForSuffix(suffix) {
5995
- if (suffix === null) return "dev";
5996
- switch (suffix) {
5997
- case "local":
5998
- case "development":
5999
- case "dev":
6000
- return "dev";
6001
- case "production":
6002
- case "prod":
6003
- return "prod";
6004
- case "staging":
6005
- case "stage":
6006
- return "staging";
6007
- case "test":
6008
- return "test";
6009
- case "preview":
6010
- return "preview";
6011
- default:
6012
- return suffix;
6013
- }
6014
- }
6015
- function hasExistingKeynvEnv(rootDir) {
6016
- return existsSync(join(rootDir, KEYNV_ENV_BASENAME));
6017
- }
6018
- var PROJECT_MARKERS, GIT_MARKER, ENV_GLOB, ENV_EXAMPLE, KEYNV_ENV_BASENAME;
6019
- var init_detect = __esm({
6020
- "src/init/detect.ts"() {
6021
- init_fs();
6022
- PROJECT_MARKERS = [
6023
- "package.json",
6024
- "pyproject.toml",
6025
- "Cargo.toml",
6026
- "go.mod",
6027
- "pnpm-workspace.yaml",
6028
- "deno.json",
6029
- "deno.jsonc",
6030
- "requirements.txt"
6031
- ];
6032
- GIT_MARKER = ".git";
6033
- ENV_GLOB = /^\.env(\.[A-Za-z0-9_-]+)?$/;
6034
- ENV_EXAMPLE = /^\.env\.(example|sample|template|dist|defaults)$/;
6035
- KEYNV_ENV_BASENAME = ".keynv.env";
6036
- }
6037
- });
6038
-
6039
- // src/init/heuristics.ts
6040
- function shannonEntropyBits(s) {
6041
- if (s.length === 0) return 0;
6042
- const counts = /* @__PURE__ */ new Map();
6043
- for (const ch of s) counts.set(ch, (counts.get(ch) ?? 0) + 1);
6044
- let h2 = 0;
6045
- for (const c2 of counts.values()) {
6046
- const p2 = c2 / s.length;
6047
- h2 -= p2 * Math.log2(p2);
6048
- }
6049
- return h2;
6050
- }
6051
- function nameMatchesLiteralPrefix(name) {
6052
- const upper = name.toUpperCase();
6053
- return NAME_LITERAL_PREFIX.some((p2) => upper.startsWith(p2));
6054
- }
6055
- function nameMatchesSecretSuffix(name) {
6056
- const upper = name.toUpperCase();
6057
- for (const { suffix, hint } of NAME_SECRET_SUFFIXES) {
6058
- if (upper.endsWith(suffix) || upper.endsWith(`_${suffix}`)) {
6059
- return { matched: true, hint };
6060
- }
6061
- }
6062
- return { matched: false, hint: "" };
6063
- }
6064
- function classifyEntry(name, value) {
6065
- const upper = name.toUpperCase();
6066
- if (NAME_FRAMEWORK_MANAGED.has(upper)) {
6067
- return { verdict: "skip", hint: "framework/shell-managed" };
6068
- }
6069
- if (NAME_LITERAL_EXACT.has(upper)) {
6070
- return { verdict: "literal", hint: "common config var" };
6071
- }
6072
- if (nameMatchesLiteralPrefix(name)) {
6073
- return { verdict: "literal", hint: "public env, build-time bundled" };
6074
- }
6075
- if (value.length === 0) {
6076
- return { verdict: "literal", hint: "empty" };
6077
- }
6078
- for (const { re, hint } of VALUE_PATTERNS) {
6079
- if (re.test(value)) return { verdict: "secret", hint };
6080
- }
6081
- const suffix = nameMatchesSecretSuffix(name);
6082
- if (suffix.matched) {
6083
- return { verdict: "secret", hint: suffix.hint };
6084
- }
6085
- if (NAME_DB_URL.test(name)) {
6086
- return { verdict: "secret", hint: "database URL" };
6087
- }
6088
- if (value.length >= 32) {
6089
- const bits = shannonEntropyBits(value);
6090
- if (bits >= 3.5) {
6091
- return { verdict: "secret", hint: `${value.length}-char random-looking string` };
6092
- }
6093
- }
6094
- return { verdict: "ambiguous", hint: "" };
6095
- }
6096
- function previewValue(value, max = 40) {
6097
- if (value.length === 0) return "(empty)";
6098
- if (value.length <= max) return value;
6099
- return `${value.slice(0, max - 1)}\u2026`;
6100
- }
6101
- var NAME_FRAMEWORK_MANAGED, NAME_LITERAL_EXACT, NAME_LITERAL_PREFIX, NAME_SECRET_SUFFIXES, NAME_DB_URL, VALUE_PATTERNS;
6102
- var init_heuristics = __esm({
6103
- "src/init/heuristics.ts"() {
6104
- NAME_FRAMEWORK_MANAGED = /* @__PURE__ */ new Set([
6105
- "NODE_ENV",
6106
- "PORT",
6107
- "HOST",
6108
- "HOSTNAME",
6109
- "PATH",
6110
- "HOME",
6111
- "USER",
6112
- "SHELL",
6113
- "PWD",
6114
- "CI"
6115
- ]);
6116
- NAME_LITERAL_EXACT = /* @__PURE__ */ new Set([
6117
- "DEBUG",
6118
- "LOG_LEVEL",
6119
- "LOGLEVEL",
6120
- "TZ",
6121
- "LANG",
6122
- "LC_ALL",
6123
- "NODE_OPTIONS",
6124
- "NPM_CONFIG_LOGLEVEL",
6125
- "TS_NODE_PROJECT"
6126
- ]);
6127
- NAME_LITERAL_PREFIX = ["NEXT_PUBLIC_", "VITE_", "REACT_APP_", "PUBLIC_", "EXPO_PUBLIC_"];
6128
- NAME_SECRET_SUFFIXES = [
6129
- { suffix: "PRIVATE_KEY", hint: "private key" },
6130
- { suffix: "API_KEY", hint: "API key" },
6131
- { suffix: "ACCESS_KEY", hint: "access key" },
6132
- { suffix: "SECRET_KEY", hint: "secret key" },
6133
- { suffix: "SECRET", hint: "secret" },
6134
- { suffix: "PASSWORD", hint: "password" },
6135
- { suffix: "PASSPHRASE", hint: "passphrase" },
6136
- { suffix: "TOKEN", hint: "token" },
6137
- { suffix: "KEY", hint: "key" },
6138
- { suffix: "CREDENTIALS", hint: "credentials" },
6139
- { suffix: "AUTH", hint: "auth" },
6140
- { suffix: "DSN", hint: "connection string" }
6141
- ];
6142
- NAME_DB_URL = /^(DATABASE|DB|POSTGRES|MYSQL|MONGO|REDIS)_URL$/i;
6143
- VALUE_PATTERNS = [
6144
- { re: /^sk-proj-/, hint: "OpenAI project key" },
6145
- { re: /^sk-[A-Za-z0-9]{20,}/, hint: "OpenAI key" },
6146
- { re: /^sk_live_/, hint: "Stripe live key" },
6147
- { re: /^sk_test_/, hint: "Stripe test key" },
6148
- { re: /^pk_live_/, hint: "Stripe publishable \u2014 often public, double-check" },
6149
- { re: /^xoxb-/, hint: "Slack bot token" },
6150
- { re: /^xoxp-/, hint: "Slack user token" },
6151
- { re: /^ghp_[A-Za-z0-9]{30,}/, hint: "GitHub personal access token" },
6152
- { re: /^github_pat_/, hint: "GitHub fine-grained PAT" },
6153
- { re: /^gho_/, hint: "GitHub OAuth token" },
6154
- { re: /^AKIA[0-9A-Z]{16}$/, hint: "AWS access key id" },
6155
- { re: /^ASIA[0-9A-Z]{16}$/, hint: "AWS temporary key id" },
6156
- { re: /^AIza[0-9A-Za-z_-]{35}$/, hint: "Google API key" },
6157
- { re: /^ya29\./, hint: "Google OAuth access token" },
6158
- { re: /^eyJ[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+$/, hint: "JWT" },
6159
- { re: /^-----BEGIN [A-Z ]+PRIVATE KEY-----/, hint: "PEM private key" },
6160
- { re: /^([a-z]+):\/\/[^@]+:[^@]+@/i, hint: "connection string with credentials" }
6161
- ];
6162
- }
6163
- });
6164
5978
  function aiContextBody() {
6165
5979
  return `## keynv (secrets)
6166
5980
 
@@ -6243,13 +6057,254 @@ ${block}
6243
6057
  return "appended";
6244
6058
  }
6245
6059
  var AGENTS_FILE_BASENAME, KEYNV_BLOCK_START, KEYNV_BLOCK_END;
6246
- var init_aiContext = __esm({
6247
- "src/init/aiContext.ts"() {
6060
+ var init_ai_context = __esm({
6061
+ "src/init/ai-context.ts"() {
6248
6062
  AGENTS_FILE_BASENAME = "AGENTS.md";
6249
6063
  KEYNV_BLOCK_START = "<!-- keynv:start -- generated by `keynv init`; safe to leave intact, will be refreshed on re-run -->";
6250
6064
  KEYNV_BLOCK_END = "<!-- keynv:end -->";
6251
6065
  }
6252
6066
  });
6067
+ function findProjectRoot(startDir) {
6068
+ const result = walkUp(startDir, (dir) => {
6069
+ for (const marker of PROJECT_MARKERS) {
6070
+ if (existsSync(join(dir, marker))) {
6071
+ return { dir, marker };
6072
+ }
6073
+ }
6074
+ if (existsSync(join(dir, GIT_MARKER))) {
6075
+ return { dir, marker: GIT_MARKER };
6076
+ }
6077
+ return null;
6078
+ });
6079
+ if (!result) return null;
6080
+ return buildRoot(result.dir, result.marker);
6081
+ }
6082
+ function buildRoot(dir, marker) {
6083
+ let suggestedName = basename(dir);
6084
+ let scripts = null;
6085
+ let invalid = false;
6086
+ if (marker === "package.json" || existsSync(join(dir, "package.json"))) {
6087
+ try {
6088
+ const pkg = JSON.parse(readFileSync(join(dir, "package.json"), "utf8"));
6089
+ if (typeof pkg.name === "string" && pkg.name.length > 0) {
6090
+ suggestedName = pkg.name.replace(/^@[^/]+\//, "");
6091
+ }
6092
+ if (pkg.scripts && typeof pkg.scripts === "object") {
6093
+ scripts = Object.fromEntries(
6094
+ Object.entries(pkg.scripts).filter(([, v2]) => typeof v2 === "string")
6095
+ );
6096
+ }
6097
+ } catch {
6098
+ invalid = true;
6099
+ }
6100
+ }
6101
+ return {
6102
+ path: dir,
6103
+ suggestedName,
6104
+ marker,
6105
+ packageJsonScripts: scripts,
6106
+ packageJsonInvalid: invalid
6107
+ };
6108
+ }
6109
+ function findEnvFiles(rootDir) {
6110
+ let entries;
6111
+ try {
6112
+ entries = readdirSync(rootDir);
6113
+ } catch {
6114
+ return [];
6115
+ }
6116
+ const hits = [];
6117
+ for (const name of entries) {
6118
+ if (!ENV_GLOB.test(name)) continue;
6119
+ if (ENV_EXAMPLE.test(name)) continue;
6120
+ if (name === KEYNV_ENV_BASENAME) continue;
6121
+ const full = join(rootDir, name);
6122
+ try {
6123
+ if (!statSync(full).isFile()) continue;
6124
+ } catch {
6125
+ continue;
6126
+ }
6127
+ const suffixMatch = name.match(/^\.env\.(.+)$/);
6128
+ const suffix = suffixMatch ? suffixMatch[1] : null;
6129
+ hits.push({ path: full, name, suffix, suggestedEnv: suggestedEnvForSuffix(suffix) });
6130
+ }
6131
+ hits.sort((a, b2) => {
6132
+ if (a.suffix === null) return -1;
6133
+ if (b2.suffix === null) return 1;
6134
+ return a.name.localeCompare(b2.name);
6135
+ });
6136
+ return hits;
6137
+ }
6138
+ function suggestedEnvForSuffix(suffix) {
6139
+ if (suffix === null) return "dev";
6140
+ switch (suffix) {
6141
+ case "local":
6142
+ case "development":
6143
+ case "dev":
6144
+ return "dev";
6145
+ case "production":
6146
+ case "prod":
6147
+ return "prod";
6148
+ case "staging":
6149
+ case "stage":
6150
+ return "staging";
6151
+ case "test":
6152
+ return "test";
6153
+ case "preview":
6154
+ return "preview";
6155
+ default:
6156
+ return suffix;
6157
+ }
6158
+ }
6159
+ function hasExistingKeynvEnv(rootDir) {
6160
+ return existsSync(join(rootDir, KEYNV_ENV_BASENAME));
6161
+ }
6162
+ var PROJECT_MARKERS, GIT_MARKER, ENV_GLOB, ENV_EXAMPLE, KEYNV_ENV_BASENAME;
6163
+ var init_detect = __esm({
6164
+ "src/init/detect.ts"() {
6165
+ init_fs();
6166
+ PROJECT_MARKERS = [
6167
+ "package.json",
6168
+ "pyproject.toml",
6169
+ "Cargo.toml",
6170
+ "go.mod",
6171
+ "pnpm-workspace.yaml",
6172
+ "deno.json",
6173
+ "deno.jsonc",
6174
+ "requirements.txt"
6175
+ ];
6176
+ GIT_MARKER = ".git";
6177
+ ENV_GLOB = /^\.env(\.[A-Za-z0-9_-]+)?$/;
6178
+ ENV_EXAMPLE = /^\.env\.(example|sample|template|dist|defaults)$/;
6179
+ KEYNV_ENV_BASENAME = ".keynv.env";
6180
+ }
6181
+ });
6182
+
6183
+ // src/init/heuristics.ts
6184
+ function shannonEntropyBits(s) {
6185
+ if (s.length === 0) return 0;
6186
+ const counts = /* @__PURE__ */ new Map();
6187
+ for (const ch of s) counts.set(ch, (counts.get(ch) ?? 0) + 1);
6188
+ let h2 = 0;
6189
+ for (const c2 of counts.values()) {
6190
+ const p2 = c2 / s.length;
6191
+ h2 -= p2 * Math.log2(p2);
6192
+ }
6193
+ return h2;
6194
+ }
6195
+ function nameMatchesLiteralPrefix(name) {
6196
+ const upper = name.toUpperCase();
6197
+ return NAME_LITERAL_PREFIX.some((p2) => upper.startsWith(p2));
6198
+ }
6199
+ function nameMatchesSecretSuffix(name) {
6200
+ const upper = name.toUpperCase();
6201
+ for (const { suffix, hint } of NAME_SECRET_SUFFIXES) {
6202
+ if (upper.endsWith(suffix) || upper.endsWith(`_${suffix}`)) {
6203
+ return { matched: true, hint };
6204
+ }
6205
+ }
6206
+ return { matched: false, hint: "" };
6207
+ }
6208
+ function classifyEntry(name, value) {
6209
+ const upper = name.toUpperCase();
6210
+ if (NAME_FRAMEWORK_MANAGED.has(upper)) {
6211
+ return { verdict: "skip", hint: "framework/shell-managed" };
6212
+ }
6213
+ if (NAME_LITERAL_EXACT.has(upper)) {
6214
+ return { verdict: "literal", hint: "common config var" };
6215
+ }
6216
+ if (nameMatchesLiteralPrefix(name)) {
6217
+ return { verdict: "literal", hint: "public env, build-time bundled" };
6218
+ }
6219
+ if (value.length === 0) {
6220
+ return { verdict: "literal", hint: "empty" };
6221
+ }
6222
+ for (const { re: re2, hint } of VALUE_PATTERNS) {
6223
+ if (re2.test(value)) return { verdict: "secret", hint };
6224
+ }
6225
+ const suffix = nameMatchesSecretSuffix(name);
6226
+ if (suffix.matched) {
6227
+ return { verdict: "secret", hint: suffix.hint };
6228
+ }
6229
+ if (NAME_DB_URL.test(name)) {
6230
+ return { verdict: "secret", hint: "database URL" };
6231
+ }
6232
+ if (value.length >= 32) {
6233
+ const bits = shannonEntropyBits(value);
6234
+ if (bits >= 3.5) {
6235
+ return { verdict: "secret", hint: `${value.length}-char random-looking string` };
6236
+ }
6237
+ }
6238
+ return { verdict: "ambiguous", hint: "" };
6239
+ }
6240
+ function previewValue(value, max = 40) {
6241
+ if (value.length === 0) return "(empty)";
6242
+ if (value.length <= max) return value;
6243
+ return `${value.slice(0, max - 1)}\u2026`;
6244
+ }
6245
+ var NAME_FRAMEWORK_MANAGED, NAME_LITERAL_EXACT, NAME_LITERAL_PREFIX, NAME_SECRET_SUFFIXES, NAME_DB_URL, VALUE_PATTERNS;
6246
+ var init_heuristics = __esm({
6247
+ "src/init/heuristics.ts"() {
6248
+ NAME_FRAMEWORK_MANAGED = /* @__PURE__ */ new Set([
6249
+ "NODE_ENV",
6250
+ "PORT",
6251
+ "HOST",
6252
+ "HOSTNAME",
6253
+ "PATH",
6254
+ "HOME",
6255
+ "USER",
6256
+ "SHELL",
6257
+ "PWD",
6258
+ "CI"
6259
+ ]);
6260
+ NAME_LITERAL_EXACT = /* @__PURE__ */ new Set([
6261
+ "DEBUG",
6262
+ "LOG_LEVEL",
6263
+ "LOGLEVEL",
6264
+ "TZ",
6265
+ "LANG",
6266
+ "LC_ALL",
6267
+ "NODE_OPTIONS",
6268
+ "NPM_CONFIG_LOGLEVEL",
6269
+ "TS_NODE_PROJECT"
6270
+ ]);
6271
+ NAME_LITERAL_PREFIX = ["NEXT_PUBLIC_", "VITE_", "REACT_APP_", "PUBLIC_", "EXPO_PUBLIC_"];
6272
+ NAME_SECRET_SUFFIXES = [
6273
+ { suffix: "PRIVATE_KEY", hint: "private key" },
6274
+ { suffix: "API_KEY", hint: "API key" },
6275
+ { suffix: "ACCESS_KEY", hint: "access key" },
6276
+ { suffix: "SECRET_KEY", hint: "secret key" },
6277
+ { suffix: "SECRET", hint: "secret" },
6278
+ { suffix: "PASSWORD", hint: "password" },
6279
+ { suffix: "PASSPHRASE", hint: "passphrase" },
6280
+ { suffix: "TOKEN", hint: "token" },
6281
+ { suffix: "KEY", hint: "key" },
6282
+ { suffix: "CREDENTIALS", hint: "credentials" },
6283
+ { suffix: "AUTH", hint: "auth" },
6284
+ { suffix: "DSN", hint: "connection string" }
6285
+ ];
6286
+ NAME_DB_URL = /^(DATABASE|DB|POSTGRES|MYSQL|MONGO|REDIS)_URL$/i;
6287
+ VALUE_PATTERNS = [
6288
+ { re: /^sk-proj-/, hint: "OpenAI project key" },
6289
+ { re: /^sk-[A-Za-z0-9]{20,}/, hint: "OpenAI key" },
6290
+ { re: /^sk_live_/, hint: "Stripe live key" },
6291
+ { re: /^sk_test_/, hint: "Stripe test key" },
6292
+ { re: /^pk_live_/, hint: "Stripe publishable \u2014 often public, double-check" },
6293
+ { re: /^xoxb-/, hint: "Slack bot token" },
6294
+ { re: /^xoxp-/, hint: "Slack user token" },
6295
+ { re: /^ghp_[A-Za-z0-9]{30,}/, hint: "GitHub personal access token" },
6296
+ { re: /^github_pat_/, hint: "GitHub fine-grained PAT" },
6297
+ { re: /^gho_/, hint: "GitHub OAuth token" },
6298
+ { re: /^AKIA[0-9A-Z]{16}$/, hint: "AWS access key id" },
6299
+ { re: /^ASIA[0-9A-Z]{16}$/, hint: "AWS temporary key id" },
6300
+ { re: /^AIza[0-9A-Za-z_-]{35}$/, hint: "Google API key" },
6301
+ { re: /^ya29\./, hint: "Google OAuth access token" },
6302
+ { re: /^eyJ[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+$/, hint: "JWT" },
6303
+ { re: /^-----BEGIN [A-Z ]+PRIVATE KEY-----/, hint: "PEM private key" },
6304
+ { re: /^([a-z]+):\/\/[^@]+:[^@]+@/i, hint: "connection string with credentials" }
6305
+ ];
6306
+ }
6307
+ });
6253
6308
 
6254
6309
  // ../../node_modules/.pnpm/fast-string-truncated-width@3.0.3/node_modules/fast-string-truncated-width/dist/utils.js
6255
6310
  var getCodePointsLength, isFullWidth, isWideNotCJKTNotEmoji;
@@ -6266,11 +6321,11 @@ var init_utils = __esm({
6266
6321
  return input.length - surrogatePairsNr;
6267
6322
  };
6268
6323
  })();
6269
- isFullWidth = (x) => {
6270
- return x === 12288 || x >= 65281 && x <= 65376 || x >= 65504 && x <= 65510;
6324
+ isFullWidth = (x2) => {
6325
+ return x2 === 12288 || x2 >= 65281 && x2 <= 65376 || x2 >= 65504 && x2 <= 65510;
6271
6326
  };
6272
- isWideNotCJKTNotEmoji = (x) => {
6273
- 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;
6327
+ isWideNotCJKTNotEmoji = (x2) => {
6328
+ return x2 === 8987 || x2 === 9001 || x2 >= 12272 && x2 <= 12287 || x2 >= 12289 && x2 <= 12350 || x2 >= 12441 && x2 <= 12543 || x2 >= 12549 && x2 <= 12591 || x2 >= 12593 && x2 <= 12686 || x2 >= 12688 && x2 <= 12771 || x2 >= 12783 && x2 <= 12830 || x2 >= 12832 && x2 <= 12871 || x2 >= 12880 && x2 <= 19903 || x2 >= 65040 && x2 <= 65049 || x2 >= 65072 && x2 <= 65106 || x2 >= 65108 && x2 <= 65126 || x2 >= 65128 && x2 <= 65131 || x2 >= 127488 && x2 <= 127490 || x2 >= 127504 && x2 <= 127547 || x2 >= 127552 && x2 <= 127560 || x2 >= 131072 && x2 <= 196605 || x2 >= 196608 && x2 <= 262141;
6274
6329
  };
6275
6330
  }
6276
6331
  });
@@ -6617,14 +6672,14 @@ var require_src = __commonJS({
6617
6672
  var CSI2 = `${ESC2}[`;
6618
6673
  var beep = "\x07";
6619
6674
  var cursor = {
6620
- to(x, y) {
6621
- if (!y) return `${CSI2}${x + 1}G`;
6622
- return `${CSI2}${y + 1};${x + 1}H`;
6675
+ to(x2, y) {
6676
+ if (!y) return `${CSI2}${x2 + 1}G`;
6677
+ return `${CSI2}${y + 1};${x2 + 1}H`;
6623
6678
  },
6624
- move(x, y) {
6679
+ move(x2, y) {
6625
6680
  let ret = "";
6626
- if (x < 0) ret += `${CSI2}${-x}D`;
6627
- else if (x > 0) ret += `${CSI2}${x}C`;
6681
+ if (x2 < 0) ret += `${CSI2}${-x2}D`;
6682
+ else if (x2 > 0) ret += `${CSI2}${x2}C`;
6628
6683
  if (y < 0) ret += `${CSI2}${-y}A`;
6629
6684
  else if (y > 0) ret += `${CSI2}${y}B`;
6630
6685
  return ret;
@@ -6669,6 +6724,39 @@ function d(r, t, s) {
6669
6724
  const e2 = r + t, i = Math.max(s.length - 1, 0), n = e2 < 0 ? i : e2 > i ? 0 : e2;
6670
6725
  return s[n].disabled ? d(n, t < 0 ? -1 : 1, s) : n;
6671
6726
  }
6727
+ function I(r, t, s, e2) {
6728
+ const i = e2.split(`
6729
+ `);
6730
+ let n = 0, o = r;
6731
+ for (const a of i) {
6732
+ if (o <= a.length) break;
6733
+ o -= a.length + 1, n++;
6734
+ }
6735
+ for (n = Math.max(0, Math.min(i.length - 1, n + s)), o = Math.min(o, i[n].length) + t; o < 0 && n > 0; ) n--, o += i[n].length + 1;
6736
+ for (; o > i[n].length && n < i.length - 1; ) o -= i[n].length + 1, n++;
6737
+ o = Math.max(0, Math.min(i[n].length, o));
6738
+ let u = 0;
6739
+ for (let a = 0; a < n; a++) u += i[a].length + 1;
6740
+ return u + o;
6741
+ }
6742
+ function j(r) {
6743
+ if (r.aliases !== void 0) {
6744
+ const t = r.aliases;
6745
+ for (const s in t) {
6746
+ if (!Object.hasOwn(t, s)) continue;
6747
+ const e2 = t[s];
6748
+ h.actions.has(e2) && (h.aliases.has(s) || h.aliases.set(s, e2));
6749
+ }
6750
+ }
6751
+ if (r.messages !== void 0) {
6752
+ const t = r.messages;
6753
+ t.cancel !== void 0 && (h.messages.cancel = t.cancel), t.error !== void 0 && (h.messages.error = t.error);
6754
+ }
6755
+ if (r.withGuide !== void 0 && (h.withGuide = r.withGuide !== false), r.date !== void 0) {
6756
+ const t = r.date;
6757
+ t.monthNames !== void 0 && (h.date.monthNames = [...t.monthNames]), t.messages !== void 0 && (t.messages.required !== void 0 && (h.date.messages.required = t.messages.required), t.messages.invalidMonth !== void 0 && (h.date.messages.invalidMonth = t.messages.invalidMonth), t.messages.invalidDay !== void 0 && (h.date.messages.invalidDay = t.messages.invalidDay), t.messages.afterMin !== void 0 && (h.date.messages.afterMin = t.messages.afterMin), t.messages.beforeMax !== void 0 && (h.date.messages.beforeMax = t.messages.beforeMax));
6758
+ }
6759
+ }
6672
6760
  function C(r, t) {
6673
6761
  if (typeof r == "string") return h.aliases.get(r) === t;
6674
6762
  for (const s of r) if (s !== void 0 && C(s, t)) return true;
@@ -6714,12 +6802,55 @@ function W(r, t, s, e2 = s, i) {
6714
6802
  const n = A(r ?? stdout);
6715
6803
  return wrapAnsi(t, n - s.length, { hard: true, trim: false }).split(`
6716
6804
  `).map((o, u) => {
6717
- const a = o;
6805
+ const a = i ? i(o, u) : o;
6718
6806
  return `${u === 0 ? e2 : s}${a}`;
6719
6807
  }).join(`
6720
6808
  `);
6721
6809
  }
6722
- var import_sisteransi, G, K, h, Y, k, A, L, p, X, nt, ot, ut, ht;
6810
+ function B(r, t) {
6811
+ if (r === void 0 || t.length === 0) return 0;
6812
+ const s = t.findIndex((e2) => e2.value === r);
6813
+ return s !== -1 ? s : 0;
6814
+ }
6815
+ function J(r, t) {
6816
+ return (t.label ?? String(t.value)).toLowerCase().includes(r.toLowerCase());
6817
+ }
6818
+ function H(r, t) {
6819
+ if (t) return r ? t : t[0];
6820
+ }
6821
+ function P(r) {
6822
+ return [...r].map((t) => Z[t]);
6823
+ }
6824
+ function tt(r) {
6825
+ const t = new Intl.DateTimeFormat(r, { year: "numeric", month: "2-digit", day: "2-digit" }).formatToParts(new Date(2e3, 0, 15)), s = [];
6826
+ let e2 = "/";
6827
+ for (const i of t) i.type === "literal" ? e2 = i.value.trim() || i.value : (i.type === "year" || i.type === "month" || i.type === "day") && s.push({ type: i.type, len: i.type === "year" ? 4 : 2 });
6828
+ return { segments: s, separator: e2 };
6829
+ }
6830
+ function U(r) {
6831
+ return Number.parseInt((r || "0").replace(/_/g, "0"), 10) || 0;
6832
+ }
6833
+ function x(r) {
6834
+ return { year: U(r.year), month: U(r.month), day: U(r.day) };
6835
+ }
6836
+ function $(r, t) {
6837
+ return new Date(r || 2001, t || 1, 0).getDate();
6838
+ }
6839
+ function F(r) {
6840
+ const { year: t, month: s, day: e2 } = x(r);
6841
+ if (!t || t < 0 || t > 9999 || !s || s < 1 || s > 12 || !e2 || e2 < 1) return;
6842
+ const i = new Date(Date.UTC(t, s - 1, e2));
6843
+ if (!(i.getUTCFullYear() !== t || i.getUTCMonth() !== s - 1 || i.getUTCDate() !== e2)) return { year: t, month: s, day: e2 };
6844
+ }
6845
+ function N(r) {
6846
+ const t = F(r);
6847
+ return t ? new Date(Date.UTC(t.year, t.month - 1, t.day)) : void 0;
6848
+ }
6849
+ function st(r, t, s, e2) {
6850
+ const i = s ? { year: s.getUTCFullYear(), month: s.getUTCMonth() + 1, day: s.getUTCDate() } : null, n = e2 ? { year: e2.getUTCFullYear(), month: e2.getUTCMonth() + 1, day: e2.getUTCDate() } : null;
6851
+ return r === "year" ? { min: i?.year ?? 1, max: n?.year ?? 9999 } : r === "month" ? { min: i && t.year === i.year ? i.month : 1, max: n && t.year === n.year ? n.month : 12 } : { min: i && t.year === i.year && t.month === i.month ? i.day : 1, max: n && t.year === n.year && t.month === n.month ? n.day : $(t.year, t.month) };
6852
+ }
6853
+ var import_sisteransi, G, K, h, Y, k, A, L, p, Q, X, Z, et, it, rt, nt, ot, ut, at, ht;
6723
6854
  var init_dist4 = __esm({
6724
6855
  "../../node_modules/.pnpm/@clack+core@1.3.0/node_modules/@clack/core/dist/index.mjs"() {
6725
6856
  init_main();
@@ -6856,6 +6987,69 @@ var init_dist4 = __esm({
6856
6987
  }
6857
6988
  }
6858
6989
  };
6990
+ Q = class extends p {
6991
+ filteredOptions;
6992
+ multiple;
6993
+ isNavigating = false;
6994
+ selectedValues = [];
6995
+ focusedValue;
6996
+ #s = 0;
6997
+ #r = "";
6998
+ #t;
6999
+ #n;
7000
+ #u;
7001
+ get cursor() {
7002
+ return this.#s;
7003
+ }
7004
+ get userInputWithCursor() {
7005
+ if (!this.userInput) return styleText(["inverse", "hidden"], "_");
7006
+ if (this._cursor >= this.userInput.length) return `${this.userInput}\u2588`;
7007
+ const t = this.userInput.slice(0, this._cursor), [s, ...e2] = this.userInput.slice(this._cursor);
7008
+ return `${t}${styleText("inverse", s)}${e2.join("")}`;
7009
+ }
7010
+ get options() {
7011
+ return typeof this.#n == "function" ? this.#n() : this.#n;
7012
+ }
7013
+ constructor(t) {
7014
+ super(t), this.#n = t.options, this.#u = t.placeholder;
7015
+ const s = this.options;
7016
+ this.filteredOptions = [...s], this.multiple = t.multiple === true, this.#t = typeof t.options == "function" ? t.filter : t.filter ?? J;
7017
+ let e2;
7018
+ if (t.initialValue && Array.isArray(t.initialValue) ? this.multiple ? e2 = t.initialValue : e2 = t.initialValue.slice(0, 1) : !this.multiple && this.options.length > 0 && (e2 = [this.options[0].value]), e2) for (const i of e2) {
7019
+ const n = s.findIndex((o) => o.value === i);
7020
+ n !== -1 && (this.toggleSelected(i), this.#s = n);
7021
+ }
7022
+ this.focusedValue = this.options[this.#s]?.value, this.on("key", (i, n) => this.#e(i, n)), this.on("userInput", (i) => this.#i(i));
7023
+ }
7024
+ _isActionKey(t, s) {
7025
+ return t === " " || this.multiple && this.isNavigating && s.name === "space" && t !== void 0 && t !== "";
7026
+ }
7027
+ #e(t, s) {
7028
+ const e2 = s.name === "up", i = s.name === "down", n = s.name === "return", o = this.userInput === "" || this.userInput === " ", u = this.#u, a = this.options, l = u !== void 0 && u !== "" && a.some((f) => !f.disabled && (this.#t ? this.#t(u, f) : true));
7029
+ if (s.name === "tab" && o && l) {
7030
+ this.userInput === " " && this._clearUserInput(), this._setUserInput(u, true), this.isNavigating = false;
7031
+ return;
7032
+ }
7033
+ e2 || i ? (this.#s = d(this.#s, e2 ? -1 : 1, this.filteredOptions), this.focusedValue = this.filteredOptions[this.#s]?.value, this.multiple || (this.selectedValues = [this.focusedValue]), this.isNavigating = true) : n ? this.value = H(this.multiple, this.selectedValues) : this.multiple ? this.focusedValue !== void 0 && (s.name === "tab" || this.isNavigating && s.name === "space") ? this.toggleSelected(this.focusedValue) : this.isNavigating = false : (this.focusedValue && (this.selectedValues = [this.focusedValue]), this.isNavigating = false);
7034
+ }
7035
+ deselectAll() {
7036
+ this.selectedValues = [];
7037
+ }
7038
+ toggleSelected(t) {
7039
+ this.filteredOptions.length !== 0 && (this.multiple ? this.selectedValues.includes(t) ? this.selectedValues = this.selectedValues.filter((s) => s !== t) : this.selectedValues = [...this.selectedValues, t] : this.selectedValues = [t]);
7040
+ }
7041
+ #i(t) {
7042
+ if (t !== this.#r) {
7043
+ this.#r = t;
7044
+ const s = this.options;
7045
+ t && this.#t ? this.filteredOptions = s.filter((n) => this.#t?.(t, n)) : this.filteredOptions = [...s];
7046
+ const e2 = B(this.focusedValue, this.filteredOptions);
7047
+ this.#s = d(e2, 0, this.filteredOptions);
7048
+ const i = this.filteredOptions[this.#s];
7049
+ i && !i.disabled ? this.focusedValue = i.value : this.focusedValue = void 0, this.multiple || (this.focusedValue !== void 0 ? this.toggleSelected(this.focusedValue) : this.deselectAll());
7050
+ }
7051
+ }
7052
+ };
6859
7053
  X = class extends p {
6860
7054
  get cursor() {
6861
7055
  return this.value ? 0 : 1;
@@ -6873,6 +7067,266 @@ var init_dist4 = __esm({
6873
7067
  });
6874
7068
  }
6875
7069
  };
7070
+ Z = { Y: { type: "year", len: 4 }, M: { type: "month", len: 2 }, D: { type: "day", len: 2 } };
7071
+ et = class extends p {
7072
+ #s;
7073
+ #r;
7074
+ #t;
7075
+ #n;
7076
+ #u;
7077
+ #e = { segmentIndex: 0, positionInSegment: 0 };
7078
+ #i = true;
7079
+ #o = null;
7080
+ inlineError = "";
7081
+ get segmentCursor() {
7082
+ return { ...this.#e };
7083
+ }
7084
+ get segmentValues() {
7085
+ return { ...this.#t };
7086
+ }
7087
+ get segments() {
7088
+ return this.#s;
7089
+ }
7090
+ get separator() {
7091
+ return this.#r;
7092
+ }
7093
+ get formattedValue() {
7094
+ return this.#c(this.#t);
7095
+ }
7096
+ #c(t) {
7097
+ return this.#s.map((s) => t[s.type]).join(this.#r);
7098
+ }
7099
+ #a() {
7100
+ this._setUserInput(this.#c(this.#t)), this._setValue(N(this.#t) ?? void 0);
7101
+ }
7102
+ constructor(t) {
7103
+ const s = t.format ? { segments: P(t.format), separator: t.separator ?? "/" } : tt(t.locale), e2 = t.separator ?? s.separator, i = t.format ? P(t.format) : s.segments, n = t.initialValue ?? t.defaultValue, o = n ? { year: String(n.getUTCFullYear()).padStart(4, "0"), month: String(n.getUTCMonth() + 1).padStart(2, "0"), day: String(n.getUTCDate()).padStart(2, "0") } : { year: "____", month: "__", day: "__" }, u = i.map((a) => o[a.type]).join(e2);
7104
+ super({ ...t, initialUserInput: u }, false), this.#s = i, this.#r = e2, this.#t = o, this.#n = t.minDate, this.#u = t.maxDate, this.#a(), this.on("cursor", (a) => this.#d(a)), this.on("key", (a, l) => this.#f(a, l)), this.on("finalize", () => this.#g(t));
7105
+ }
7106
+ #h() {
7107
+ const t = Math.max(0, Math.min(this.#e.segmentIndex, this.#s.length - 1)), s = this.#s[t];
7108
+ if (s) return this.#e.positionInSegment = Math.max(0, Math.min(this.#e.positionInSegment, s.len - 1)), { segment: s, index: t };
7109
+ }
7110
+ #l(t) {
7111
+ this.inlineError = "", this.#o = null;
7112
+ const s = this.#h();
7113
+ s && (this.#e.segmentIndex = Math.max(0, Math.min(this.#s.length - 1, s.index + t)), this.#e.positionInSegment = 0, this.#i = true);
7114
+ }
7115
+ #p(t) {
7116
+ const s = this.#h();
7117
+ if (!s) return;
7118
+ const { segment: e2 } = s, i = this.#t[e2.type], n = !i || i.replace(/_/g, "") === "", o = Number.parseInt((i || "0").replace(/_/g, "0"), 10) || 0, u = st(e2.type, x(this.#t), this.#n, this.#u);
7119
+ let a;
7120
+ n ? a = t === 1 ? u.min : u.max : a = Math.max(Math.min(u.max, o + t), u.min), this.#t = { ...this.#t, [e2.type]: a.toString().padStart(e2.len, "0") }, this.#i = true, this.#o = null, this.#a();
7121
+ }
7122
+ #d(t) {
7123
+ if (t) switch (t) {
7124
+ case "right":
7125
+ return this.#l(1);
7126
+ case "left":
7127
+ return this.#l(-1);
7128
+ case "up":
7129
+ return this.#p(1);
7130
+ case "down":
7131
+ return this.#p(-1);
7132
+ }
7133
+ }
7134
+ #f(t, s) {
7135
+ if (s?.name === "backspace" || s?.sequence === "\x7F" || s?.sequence === "\b" || t === "\x7F" || t === "\b") {
7136
+ this.inlineError = "";
7137
+ const e2 = this.#h();
7138
+ if (!e2) return;
7139
+ if (!this.#t[e2.segment.type].replace(/_/g, "")) {
7140
+ this.#l(-1);
7141
+ return;
7142
+ }
7143
+ this.#t[e2.segment.type] = "_".repeat(e2.segment.len), this.#i = true, this.#e.positionInSegment = 0, this.#a();
7144
+ return;
7145
+ }
7146
+ if (s?.name === "tab") {
7147
+ this.inlineError = "";
7148
+ const e2 = this.#h();
7149
+ if (!e2) return;
7150
+ const i = s.shift ? -1 : 1, n = e2.index + i;
7151
+ n >= 0 && n < this.#s.length && (this.#e.segmentIndex = n, this.#e.positionInSegment = 0, this.#i = true);
7152
+ return;
7153
+ }
7154
+ if (t && /^[0-9]$/.test(t)) {
7155
+ const e2 = this.#h();
7156
+ if (!e2) return;
7157
+ const { segment: i } = e2, n = !this.#t[i.type].replace(/_/g, "");
7158
+ if (this.#i && this.#o !== null && !n) {
7159
+ const m = this.#o + t, g = { ...this.#t, [i.type]: m }, _ = this.#m(g, i);
7160
+ if (_) {
7161
+ this.inlineError = _, this.#o = null, this.#i = false;
7162
+ return;
7163
+ }
7164
+ this.inlineError = "", this.#t[i.type] = m, this.#o = null, this.#i = false, this.#a(), e2.index < this.#s.length - 1 && (this.#e.segmentIndex = e2.index + 1, this.#e.positionInSegment = 0, this.#i = true);
7165
+ return;
7166
+ }
7167
+ this.#i && !n && (this.#t[i.type] = "_".repeat(i.len), this.#e.positionInSegment = 0), this.#i = false, this.#o = null;
7168
+ const o = this.#t[i.type], u = o.indexOf("_"), a = u >= 0 ? u : Math.min(this.#e.positionInSegment, i.len - 1);
7169
+ if (a < 0 || a >= i.len) return;
7170
+ let l = o.slice(0, a) + t + o.slice(a + 1), f = false;
7171
+ if (a === 0 && o === "__" && (i.type === "month" || i.type === "day")) {
7172
+ const m = Number.parseInt(t, 10);
7173
+ l = `0${t}`, f = m <= (i.type === "month" ? 1 : 2);
7174
+ }
7175
+ if (i.type === "year" && (l = (o.replace(/_/g, "") + t).padStart(i.len, "_")), !l.includes("_")) {
7176
+ const m = { ...this.#t, [i.type]: l }, g = this.#m(m, i);
7177
+ if (g) {
7178
+ this.inlineError = g;
7179
+ return;
7180
+ }
7181
+ }
7182
+ this.inlineError = "", this.#t[i.type] = l;
7183
+ const y = l.includes("_") ? void 0 : F(this.#t);
7184
+ if (y) {
7185
+ const { year: m, month: g } = y, _ = $(m, g);
7186
+ this.#t = { year: String(Math.max(0, Math.min(9999, m))).padStart(4, "0"), month: String(Math.max(1, Math.min(12, g))).padStart(2, "0"), day: String(Math.max(1, Math.min(_, y.day))).padStart(2, "0") };
7187
+ }
7188
+ this.#a();
7189
+ const T = l.indexOf("_");
7190
+ f ? (this.#i = true, this.#o = t) : T >= 0 ? this.#e.positionInSegment = T : u >= 0 && e2.index < this.#s.length - 1 ? (this.#e.segmentIndex = e2.index + 1, this.#e.positionInSegment = 0, this.#i = true) : this.#e.positionInSegment = Math.min(a + 1, i.len - 1);
7191
+ }
7192
+ }
7193
+ #m(t, s) {
7194
+ const { month: e2, day: i } = x(t);
7195
+ if (s.type === "month" && (e2 < 0 || e2 > 12)) return h.date.messages.invalidMonth;
7196
+ if (s.type === "day" && (i < 0 || i > 31)) return h.date.messages.invalidDay(31, "any month");
7197
+ }
7198
+ #g(t) {
7199
+ const { year: s, month: e2, day: i } = x(this.#t);
7200
+ if (s && e2 && i) {
7201
+ const n = $(s, e2);
7202
+ this.#t = { ...this.#t, day: String(Math.min(i, n)).padStart(2, "0") };
7203
+ }
7204
+ this.value = N(this.#t) ?? t.defaultValue ?? void 0;
7205
+ }
7206
+ };
7207
+ it = class extends p {
7208
+ options;
7209
+ cursor = 0;
7210
+ #s;
7211
+ getGroupItems(t) {
7212
+ return this.options.filter((s) => s.group === t);
7213
+ }
7214
+ isGroupSelected(t) {
7215
+ const s = this.getGroupItems(t), e2 = this.value;
7216
+ return e2 === void 0 ? false : s.every((i) => e2.includes(i.value));
7217
+ }
7218
+ toggleValue() {
7219
+ const t = this.options[this.cursor];
7220
+ if (this.value === void 0 && (this.value = []), t.group === true) {
7221
+ const s = t.value, e2 = this.getGroupItems(s);
7222
+ this.isGroupSelected(s) ? this.value = this.value.filter((i) => e2.findIndex((n) => n.value === i) === -1) : this.value = [...this.value, ...e2.map((i) => i.value)], this.value = Array.from(new Set(this.value));
7223
+ } else {
7224
+ const s = this.value.includes(t.value);
7225
+ this.value = s ? this.value.filter((e2) => e2 !== t.value) : [...this.value, t.value];
7226
+ }
7227
+ }
7228
+ constructor(t) {
7229
+ super(t, false);
7230
+ const { options: s } = t;
7231
+ this.#s = t.selectableGroups !== false, this.options = Object.entries(s).flatMap(([e2, i]) => [{ value: e2, group: true, label: e2 }, ...i.map((n) => ({ ...n, group: e2 }))]), this.value = [...t.initialValues ?? []], this.cursor = Math.max(this.options.findIndex(({ value: e2 }) => e2 === t.cursorAt), this.#s ? 0 : 1), this.on("cursor", (e2) => {
7232
+ switch (e2) {
7233
+ case "left":
7234
+ case "up": {
7235
+ this.cursor = this.cursor === 0 ? this.options.length - 1 : this.cursor - 1;
7236
+ const i = this.options[this.cursor]?.group === true;
7237
+ !this.#s && i && (this.cursor = this.cursor === 0 ? this.options.length - 1 : this.cursor - 1);
7238
+ break;
7239
+ }
7240
+ case "down":
7241
+ case "right": {
7242
+ this.cursor = this.cursor === this.options.length - 1 ? 0 : this.cursor + 1;
7243
+ const i = this.options[this.cursor]?.group === true;
7244
+ !this.#s && i && (this.cursor = this.cursor === this.options.length - 1 ? 0 : this.cursor + 1);
7245
+ break;
7246
+ }
7247
+ case "space":
7248
+ this.toggleValue();
7249
+ break;
7250
+ }
7251
+ });
7252
+ }
7253
+ };
7254
+ rt = class extends p {
7255
+ #s = false;
7256
+ #r;
7257
+ focused = "editor";
7258
+ get userInputWithCursor() {
7259
+ if (this.state === "submit") return this.userInput;
7260
+ const t = this.userInput;
7261
+ if (this.cursor >= t.length) return `${t}\u2588`;
7262
+ const s = t.slice(0, this.cursor), e2 = t[this.cursor], i = t.slice(this.cursor + 1);
7263
+ return e2 === `
7264
+ ` ? `${s}\u2588
7265
+ ${i}` : `${s}${styleText("inverse", e2)}${i}`;
7266
+ }
7267
+ get cursor() {
7268
+ return this._cursor;
7269
+ }
7270
+ #t(t) {
7271
+ if (this.userInput.length === 0) {
7272
+ this._setUserInput(t);
7273
+ return;
7274
+ }
7275
+ this._setUserInput(this.userInput.slice(0, this.cursor) + t + this.userInput.slice(this.cursor));
7276
+ }
7277
+ #n(t) {
7278
+ const s = this.value ?? "";
7279
+ switch (t) {
7280
+ case "up":
7281
+ this._cursor = I(this._cursor, 0, -1, s);
7282
+ return;
7283
+ case "down":
7284
+ this._cursor = I(this._cursor, 0, 1, s);
7285
+ return;
7286
+ case "left":
7287
+ this._cursor = I(this._cursor, -1, 0, s);
7288
+ return;
7289
+ case "right":
7290
+ this._cursor = I(this._cursor, 1, 0, s);
7291
+ return;
7292
+ }
7293
+ }
7294
+ _shouldSubmit(t, s) {
7295
+ if (this.#r) return this.focused === "submit" ? true : (this.#t(`
7296
+ `), this._cursor++, false);
7297
+ const e2 = this.#s;
7298
+ return this.#s = true, e2 ? (this.userInput[this.cursor - 1] === `
7299
+ ` && (this._setUserInput(this.userInput.slice(0, this.cursor - 1) + this.userInput.slice(this.cursor)), this._cursor--), true) : (this.#t(`
7300
+ `), this._cursor++, false);
7301
+ }
7302
+ constructor(t) {
7303
+ super(t, false), this.#r = t.showSubmit ?? false, this.on("key", (s, e2) => {
7304
+ if (e2?.name && h.actions.has(e2.name)) {
7305
+ this.#n(e2.name);
7306
+ return;
7307
+ }
7308
+ if (s === " " && this.#r) {
7309
+ this.focused = this.focused === "editor" ? "submit" : "editor";
7310
+ return;
7311
+ }
7312
+ if (e2?.name !== "return") {
7313
+ if (this.#s = false, e2?.name === "backspace" && this.cursor > 0) {
7314
+ this._setUserInput(this.userInput.slice(0, this.cursor - 1) + this.userInput.slice(this.cursor)), this._cursor--;
7315
+ return;
7316
+ }
7317
+ if (e2?.name === "delete" && this.cursor < this.userInput.length) {
7318
+ this._setUserInput(this.userInput.slice(0, this.cursor) + this.userInput.slice(this.cursor + 1));
7319
+ return;
7320
+ }
7321
+ s && (this.#r && this.focused === "submit" && (this.focused = "editor"), this.#t(s ?? ""), this._cursor++);
7322
+ }
7323
+ }), this.on("userInput", (s) => {
7324
+ this._setValue(s);
7325
+ }), this.on("finalize", () => {
7326
+ this.value || (this.value = t.defaultValue), this.value === void 0 && (this.value = "");
7327
+ });
7328
+ }
7329
+ };
6876
7330
  nt = class extends p {
6877
7331
  options;
6878
7332
  cursor = 0;
@@ -6970,6 +7424,21 @@ var init_dist4 = __esm({
6970
7424
  });
6971
7425
  }
6972
7426
  };
7427
+ at = class extends p {
7428
+ options;
7429
+ cursor = 0;
7430
+ constructor(t) {
7431
+ super(t, false), this.options = t.options;
7432
+ const s = t.caseSensitive === true, e2 = this.options.map(({ value: [i] }) => s ? i : i?.toLowerCase());
7433
+ this.cursor = Math.max(e2.indexOf(t.initialValue), 0), this.on("key", (i, n) => {
7434
+ if (!i) return;
7435
+ const o = s && n.shift ? i.toUpperCase() : i;
7436
+ if (!e2.includes(o)) return;
7437
+ const u = this.options.find(({ value: [a] }) => s ? a === o : a?.toLowerCase() === i);
7438
+ u && (this.value = u.value, this.state = "submit", this.emit("submit"));
7439
+ });
7440
+ }
7441
+ };
6973
7442
  ht = class extends p {
6974
7443
  get userInputWithCursor() {
6975
7444
  if (this.state === "submit") return this.userInput;
@@ -6991,10 +7460,130 @@ var init_dist4 = __esm({
6991
7460
  };
6992
7461
  }
6993
7462
  });
7463
+
7464
+ // ../../node_modules/.pnpm/@clack+prompts@1.3.0/node_modules/@clack/prompts/dist/index.mjs
7465
+ var dist_exports = {};
7466
+ __export(dist_exports, {
7467
+ S_BAR: () => $2,
7468
+ S_BAR_END: () => E2,
7469
+ S_BAR_END_RIGHT: () => Et,
7470
+ S_BAR_H: () => st2,
7471
+ S_BAR_START: () => lt,
7472
+ S_BAR_START_RIGHT: () => It,
7473
+ S_CHECKBOX_ACTIVE: () => et2,
7474
+ S_CHECKBOX_INACTIVE: () => J2,
7475
+ S_CHECKBOX_SELECTED: () => U2,
7476
+ S_CONNECT_LEFT: () => xt,
7477
+ S_CORNER_BOTTOM_LEFT: () => dt,
7478
+ S_CORNER_BOTTOM_RIGHT: () => $t,
7479
+ S_CORNER_TOP_LEFT: () => Ot,
7480
+ S_CORNER_TOP_RIGHT: () => ct,
7481
+ S_ERROR: () => gt,
7482
+ S_INFO: () => ht2,
7483
+ S_PASSWORD_MASK: () => Gt,
7484
+ S_RADIO_ACTIVE: () => z2,
7485
+ S_RADIO_INACTIVE: () => H2,
7486
+ S_STEP_ACTIVE: () => _t,
7487
+ S_STEP_CANCEL: () => ot2,
7488
+ S_STEP_ERROR: () => ut2,
7489
+ S_STEP_SUBMIT: () => F2,
7490
+ S_SUCCESS: () => pt,
7491
+ S_WARN: () => mt,
7492
+ autocomplete: () => At,
7493
+ autocompleteMultiselect: () => ie,
7494
+ box: () => oe,
7495
+ cancel: () => me,
7496
+ confirm: () => ue,
7497
+ date: () => le,
7498
+ group: () => he,
7499
+ groupMultiselect: () => pe,
7500
+ intro: () => ge,
7501
+ isCI: () => at2,
7502
+ isCancel: () => q,
7503
+ isTTY: () => Tt,
7504
+ limitOptions: () => Y2,
7505
+ log: () => R2,
7506
+ multiline: () => fe,
7507
+ multiselect: () => ve,
7508
+ note: () => Se,
7509
+ outro: () => ye,
7510
+ password: () => Ce,
7511
+ path: () => Te,
7512
+ progress: () => Ie,
7513
+ select: () => Ee,
7514
+ selectKey: () => Ge,
7515
+ settings: () => h,
7516
+ spinner: () => ft,
7517
+ stream: () => K2,
7518
+ symbol: () => M,
7519
+ symbolBar: () => yt,
7520
+ taskLog: () => Me,
7521
+ tasks: () => xe,
7522
+ text: () => Re,
7523
+ unicode: () => tt2,
7524
+ unicodeOr: () => w2,
7525
+ updateSettings: () => j
7526
+ });
6994
7527
  function te() {
6995
7528
  return j2.platform !== "win32" ? j2.env.TERM !== "linux" : !!j2.env.CI || !!j2.env.WT_SESSION || !!j2.env.TERMINUS_SUBLIME || j2.env.ConEmuTask === "{cmd::Cmder}" || j2.env.TERM_PROGRAM === "Terminus-Sublime" || j2.env.TERM_PROGRAM === "vscode" || j2.env.TERM === "xterm-256color" || j2.env.TERM === "alacritty" || j2.env.TERMINAL_EMULATOR === "JetBrains-JediTerm";
6996
7529
  }
6997
- var import_sisteransi2, tt, at2, w2, _t, ot2, ut2, F, lt, $, E2, z2, H, et2, U, J, Gt, st, ct, xt, $t, dt, ht2, pt, mt, gt, M, yt, ee, Y2, ue, he, R2, me, ge, ye, Q2, ve, we, be, Se, Ce, _e, ft, it2, Ee, Re;
7530
+ function Mt(t) {
7531
+ return t.label ?? String(t.value ?? "");
7532
+ }
7533
+ function Rt(t, r) {
7534
+ if (!t) return true;
7535
+ const s = (r.label ?? String(r.value ?? "")).toLowerCase(), i = (r.hint ?? "").toLowerCase(), u = String(r.value).toLowerCase(), n = t.toLowerCase();
7536
+ return s.includes(n) || i.includes(n) || u.includes(n);
7537
+ }
7538
+ function se(t, r) {
7539
+ const s = [];
7540
+ for (const i of r) t.includes(i.value) && s.push(i);
7541
+ return s;
7542
+ }
7543
+ function Pt(t, r, s, i) {
7544
+ let u = s, n = s;
7545
+ return i === "center" ? u = Math.floor((r - t) / 2) : i === "right" && (u = r - t - s), n = r - u - t, [u, n];
7546
+ }
7547
+ function ce(t, r) {
7548
+ const s = t.segmentValues, i = t.segmentCursor;
7549
+ if (r === "submit" || r === "cancel") return t.formattedValue;
7550
+ const u = styleText("gray", t.separator);
7551
+ return t.segments.map((n, o) => {
7552
+ const c2 = o === i.segmentIndex && !["submit", "cancel"].includes(r), a = de[n.type];
7553
+ return $e(s[n.type], { isActive: c2, label: a });
7554
+ }).join(u);
7555
+ }
7556
+ function $e(t, r) {
7557
+ const s = !t || t.replace(/_/g, "") === "";
7558
+ return r.isActive ? styleText("inverse", s ? r.label : t.replace(/_/g, " ")) : s ? styleText("dim", r.label) : t.replace(/_/g, styleText("dim", " "));
7559
+ }
7560
+ function Ie({ style: t = "heavy", max: r = 100, size: s = 40, ...i } = {}) {
7561
+ const u = ft(i);
7562
+ let n = 0, o = "";
7563
+ const c2 = Math.max(1, r), a = Math.max(1, s), l = (m) => {
7564
+ switch (m) {
7565
+ case "initial":
7566
+ case "active":
7567
+ return (g) => styleText("magenta", g);
7568
+ case "error":
7569
+ case "cancel":
7570
+ return (g) => styleText("red", g);
7571
+ case "submit":
7572
+ return (g) => styleText("green", g);
7573
+ default:
7574
+ return (g) => styleText("magenta", g);
7575
+ }
7576
+ }, d2 = (m, g) => {
7577
+ const S2 = Math.floor(n / c2 * a);
7578
+ return `${l(m)(Vt[t].repeat(S2))}${styleText("dim", Vt[t].repeat(a - S2))} ${g}`;
7579
+ }, y = (m = "") => {
7580
+ o = m, u.start(d2("initial", m));
7581
+ }, p2 = (m = 1, g) => {
7582
+ n = Math.min(c2, m + n), u.message(d2("active", g ?? o)), o = g ?? o;
7583
+ };
7584
+ return { start: y, stop: u.stop, cancel: u.cancel, error: u.error, clear: u.clear, advance: p2, isCancelled: u.isCancelled, message: (m) => p2(0, m) };
7585
+ }
7586
+ var import_sisteransi2, tt2, at2, Tt, w2, _t, ot2, ut2, F2, lt, $2, E2, It, Et, z2, H2, et2, U2, J2, Gt, st2, ct, xt, $t, dt, Ot, ht2, pt, mt, gt, M, yt, ee, Y2, At, ie, re, ne, ae, oe, ue, le, de, he, pe, R2, me, ge, ye, fe, Q2, ve, we, be, Se, Ce, Te, _e, ft, Vt, it2, Ee, Ge, jt, K2, xe, Oe, Me, Re;
6998
7587
  var init_dist5 = __esm({
6999
7588
  "../../node_modules/.pnpm/@clack+prompts@1.3.0/node_modules/@clack/prompts/dist/index.mjs"() {
7000
7589
  init_dist4();
@@ -7002,30 +7591,31 @@ var init_dist5 = __esm({
7002
7591
  init_main();
7003
7592
  init_dist3();
7004
7593
  import_sisteransi2 = __toESM(require_src());
7005
- tt = te();
7594
+ tt2 = te();
7006
7595
  at2 = () => process.env.CI === "true";
7007
- w2 = (t, r) => tt ? t : r;
7596
+ Tt = (t) => t.isTTY === true;
7597
+ w2 = (t, r) => tt2 ? t : r;
7008
7598
  _t = w2("\u25C6", "*");
7009
7599
  ot2 = w2("\u25A0", "x");
7010
7600
  ut2 = w2("\u25B2", "x");
7011
- F = w2("\u25C7", "o");
7601
+ F2 = w2("\u25C7", "o");
7012
7602
  lt = w2("\u250C", "T");
7013
- $ = w2("\u2502", "|");
7603
+ $2 = w2("\u2502", "|");
7014
7604
  E2 = w2("\u2514", "\u2014");
7015
- w2("\u2510", "T");
7016
- w2("\u2518", "\u2014");
7605
+ It = w2("\u2510", "T");
7606
+ Et = w2("\u2518", "\u2014");
7017
7607
  z2 = w2("\u25CF", ">");
7018
- H = w2("\u25CB", " ");
7608
+ H2 = w2("\u25CB", " ");
7019
7609
  et2 = w2("\u25FB", "[\u2022]");
7020
- U = w2("\u25FC", "[+]");
7021
- J = w2("\u25FB", "[ ]");
7610
+ U2 = w2("\u25FC", "[+]");
7611
+ J2 = w2("\u25FB", "[ ]");
7022
7612
  Gt = w2("\u25AA", "\u2022");
7023
- st = w2("\u2500", "-");
7613
+ st2 = w2("\u2500", "-");
7024
7614
  ct = w2("\u256E", "+");
7025
7615
  xt = w2("\u251C", "+");
7026
7616
  $t = w2("\u256F", "+");
7027
7617
  dt = w2("\u2570", "+");
7028
- w2("\u256D", "+");
7618
+ Ot = w2("\u256D", "+");
7029
7619
  ht2 = w2("\u25CF", "\u2022");
7030
7620
  pt = w2("\u25C6", "*");
7031
7621
  mt = w2("\u25B2", "!");
@@ -7040,20 +7630,20 @@ var init_dist5 = __esm({
7040
7630
  case "error":
7041
7631
  return styleText("yellow", ut2);
7042
7632
  case "submit":
7043
- return styleText("green", F);
7633
+ return styleText("green", F2);
7044
7634
  }
7045
7635
  };
7046
7636
  yt = (t) => {
7047
7637
  switch (t) {
7048
7638
  case "initial":
7049
7639
  case "active":
7050
- return styleText("cyan", $);
7640
+ return styleText("cyan", $2);
7051
7641
  case "cancel":
7052
- return styleText("red", $);
7642
+ return styleText("red", $2);
7053
7643
  case "error":
7054
- return styleText("yellow", $);
7644
+ return styleText("yellow", $2);
7055
7645
  case "submit":
7056
- return styleText("green", $);
7646
+ return styleText("green", $2);
7057
7647
  }
7058
7648
  };
7059
7649
  ee = (t, r, s, i, u) => {
@@ -7079,42 +7669,178 @@ var init_dist5 = __esm({
7079
7669
  h2.push(G2), f += G2.length;
7080
7670
  }
7081
7671
  if (f > d2) {
7082
- let b2 = 0, G2 = 0, x = f;
7083
- const A2 = t - v2, P = (N, D2) => ee(h2, x, N, D2, d2);
7084
- m ? ({ lineCount: x, removals: b2 } = P(0, A2), x > d2 && ({ lineCount: x, removals: G2 } = P(A2 + 1, h2.length))) : ({ lineCount: x, removals: G2 } = P(A2 + 1, h2.length), x > d2 && ({ lineCount: x, removals: b2 } = P(0, A2))), b2 > 0 && (m = true, h2.splice(0, b2)), G2 > 0 && (g = true, h2.splice(h2.length - G2, G2));
7672
+ let b2 = 0, G2 = 0, x2 = f;
7673
+ const A2 = t - v2, P2 = (N2, D2) => ee(h2, x2, N2, D2, d2);
7674
+ m ? ({ lineCount: x2, removals: b2 } = P2(0, A2), x2 > d2 && ({ lineCount: x2, removals: G2 } = P2(A2 + 1, h2.length))) : ({ lineCount: x2, removals: G2 } = P2(A2 + 1, h2.length), x2 > d2 && ({ lineCount: x2, removals: b2 } = P2(0, A2))), b2 > 0 && (m = true, h2.splice(0, b2)), G2 > 0 && (g = true, h2.splice(h2.length - G2, G2));
7085
7675
  }
7086
7676
  const C2 = [];
7087
7677
  m && C2.push(l);
7088
7678
  for (const b2 of h2) for (const G2 of b2) C2.push(G2);
7089
7679
  return g && C2.push(l), C2;
7090
7680
  };
7681
+ At = (t) => new Q({ options: t.options, initialValue: t.initialValue ? [t.initialValue] : void 0, initialUserInput: t.initialUserInput, placeholder: t.placeholder, filter: t.filter ?? ((r, s) => Rt(r, s)), signal: t.signal, input: t.input, output: t.output, validate: t.validate, render() {
7682
+ const r = t.withGuide ?? h.withGuide, s = r ? [`${styleText("gray", $2)}`, `${M(this.state)} ${t.message}`] : [`${M(this.state)} ${t.message}`], i = this.userInput, u = this.options, n = t.placeholder, o = i === "" && n !== void 0, c2 = (a, l) => {
7683
+ const d2 = Mt(a), y = a.hint && a.value === this.focusedValue ? styleText("dim", ` (${a.hint})`) : "";
7684
+ switch (l) {
7685
+ case "active":
7686
+ return `${styleText("green", z2)} ${d2}${y}`;
7687
+ case "inactive":
7688
+ return `${styleText("dim", H2)} ${styleText("dim", d2)}`;
7689
+ case "disabled":
7690
+ return `${styleText("gray", H2)} ${styleText(["strikethrough", "gray"], d2)}`;
7691
+ }
7692
+ };
7693
+ switch (this.state) {
7694
+ case "submit": {
7695
+ const a = se(this.selectedValues, u), l = a.length > 0 ? ` ${styleText("dim", a.map(Mt).join(", "))}` : "", d2 = r ? styleText("gray", $2) : "";
7696
+ return `${s.join(`
7697
+ `)}
7698
+ ${d2}${l}`;
7699
+ }
7700
+ case "cancel": {
7701
+ const a = i ? ` ${styleText(["strikethrough", "dim"], i)}` : "", l = r ? styleText("gray", $2) : "";
7702
+ return `${s.join(`
7703
+ `)}
7704
+ ${l}${a}`;
7705
+ }
7706
+ default: {
7707
+ const a = this.state === "error" ? "yellow" : "cyan", l = r ? `${styleText(a, $2)} ` : "", d2 = r ? styleText(a, E2) : "";
7708
+ let y = "";
7709
+ if (this.isNavigating || o) {
7710
+ const v2 = o ? n : i;
7711
+ y = v2 !== "" ? ` ${styleText("dim", v2)}` : "";
7712
+ } else y = ` ${this.userInputWithCursor}`;
7713
+ const p2 = this.filteredOptions.length !== u.length ? styleText("dim", ` (${this.filteredOptions.length} match${this.filteredOptions.length === 1 ? "" : "es"})`) : "", m = this.filteredOptions.length === 0 && i ? [`${l}${styleText("yellow", "No matches found")}`] : [], g = this.state === "error" ? [`${l}${styleText("yellow", this.error)}`] : [];
7714
+ r && s.push(`${l.trimEnd()}`), s.push(`${l}${styleText("dim", "Search:")}${y}${p2}`, ...m, ...g);
7715
+ const S2 = [`${styleText("dim", "\u2191/\u2193")} to select`, `${styleText("dim", "Enter:")} confirm`, `${styleText("dim", "Type:")} to search`], h2 = [`${l}${S2.join(" \u2022 ")}`, d2], f = this.filteredOptions.length === 0 ? [] : Y2({ cursor: this.cursor, options: this.filteredOptions, columnPadding: r ? 3 : 0, rowPadding: s.length + h2.length, style: (v2, T) => c2(v2, v2.disabled ? "disabled" : T ? "active" : "inactive"), maxItems: t.maxItems, output: t.output });
7716
+ return [...s, ...f.map((v2) => `${l}${v2}`), ...h2].join(`
7717
+ `);
7718
+ }
7719
+ }
7720
+ } }).prompt();
7721
+ ie = (t) => {
7722
+ const r = (i, u, n, o) => {
7723
+ const c2 = n.includes(i.value), a = i.label ?? String(i.value ?? ""), l = i.hint && o !== void 0 && i.value === o ? styleText("dim", ` (${i.hint})`) : "", d2 = c2 ? styleText("green", U2) : styleText("dim", J2);
7724
+ return i.disabled ? `${styleText("gray", J2)} ${styleText(["strikethrough", "gray"], a)}` : u ? `${d2} ${a}${l}` : `${d2} ${styleText("dim", a)}`;
7725
+ }, s = new Q({ options: t.options, multiple: true, placeholder: t.placeholder, filter: t.filter ?? ((i, u) => Rt(i, u)), validate: () => {
7726
+ if (t.required && s.selectedValues.length === 0) return "Please select at least one item";
7727
+ }, initialValue: t.initialValues, signal: t.signal, input: t.input, output: t.output, render() {
7728
+ const i = t.withGuide ?? h.withGuide, u = `${i ? `${styleText("gray", $2)}
7729
+ ` : ""}${M(this.state)} ${t.message}
7730
+ `, n = this.userInput, o = t.placeholder, c2 = n === "" && o !== void 0, a = this.isNavigating || c2 ? styleText("dim", c2 ? o : n) : this.userInputWithCursor, l = this.options, d2 = this.filteredOptions.length !== l.length ? styleText("dim", ` (${this.filteredOptions.length} match${this.filteredOptions.length === 1 ? "" : "es"})`) : "";
7731
+ switch (this.state) {
7732
+ case "submit":
7733
+ return `${u}${i ? `${styleText("gray", $2)} ` : ""}${styleText("dim", `${this.selectedValues.length} items selected`)}`;
7734
+ case "cancel":
7735
+ return `${u}${i ? `${styleText("gray", $2)} ` : ""}${styleText(["strikethrough", "dim"], n)}`;
7736
+ default: {
7737
+ const y = this.state === "error" ? "yellow" : "cyan", p2 = i ? `${styleText(y, $2)} ` : "", m = i ? styleText(y, E2) : "", g = [`${styleText("dim", "\u2191/\u2193")} to navigate`, `${styleText("dim", this.isNavigating ? "Space/Tab:" : "Tab:")} select`, `${styleText("dim", "Enter:")} confirm`, `${styleText("dim", "Type:")} to search`], S2 = this.filteredOptions.length === 0 && n ? [`${p2}${styleText("yellow", "No matches found")}`] : [], h2 = this.state === "error" ? [`${p2}${styleText("yellow", this.error)}`] : [], f = [...`${u}${i ? styleText(y, $2) : ""}`.split(`
7738
+ `), `${p2}${styleText("dim", "Search:")} ${a}${d2}`, ...S2, ...h2], v2 = [`${p2}${g.join(" \u2022 ")}`, m], T = Y2({ cursor: this.cursor, options: this.filteredOptions, style: (C2, b2) => r(C2, b2, this.selectedValues, this.focusedValue), maxItems: t.maxItems, output: t.output, rowPadding: f.length + v2.length });
7739
+ return [...f, ...T.map((C2) => `${p2}${C2}`), ...v2].join(`
7740
+ `);
7741
+ }
7742
+ }
7743
+ } });
7744
+ return s.prompt();
7745
+ };
7746
+ re = [Ot, ct, dt, $t];
7747
+ ne = [lt, It, E2, Et];
7748
+ ae = (t) => t;
7749
+ oe = (t = "", r = "", s) => {
7750
+ const i = s?.output ?? process.stdout, u = A(i), n = 2, o = s?.titlePadding ?? 1, c2 = s?.contentPadding ?? 2, a = s?.width === void 0 || s.width === "auto" ? 1 : Math.min(1, s.width), l = s?.withGuide ?? h.withGuide ? `${$2} ` : "", d2 = s?.formatBorder ?? ae, y = (s?.rounded ? re : ne).map(d2), p2 = d2(st2), m = d2($2), g = dist_default2(l), S2 = dist_default2(r), h2 = u - g;
7751
+ let f = Math.floor(u * a) - g;
7752
+ if (s?.width === "auto") {
7753
+ const P2 = t.split(`
7754
+ `);
7755
+ let N2 = S2 + o * 2;
7756
+ for (const rt2 of P2) {
7757
+ const W2 = dist_default2(rt2) + c2 * 2;
7758
+ W2 > N2 && (N2 = W2);
7759
+ }
7760
+ const D2 = N2 + n;
7761
+ D2 < f && (f = D2);
7762
+ }
7763
+ f % 2 !== 0 && (f < h2 ? f++ : f--);
7764
+ const v2 = f - n, T = v2 - o * 2, C2 = S2 > T ? `${r.slice(0, T - 3)}...` : r, [b2, G2] = Pt(dist_default2(C2), v2, o, s?.titleAlign), x2 = wrapAnsi(t, v2 - c2 * 2, { hard: true, trim: false });
7765
+ i.write(`${l}${y[0]}${p2.repeat(b2)}${C2}${p2.repeat(G2)}${y[1]}
7766
+ `);
7767
+ const A2 = x2.split(`
7768
+ `);
7769
+ for (const P2 of A2) {
7770
+ const [N2, D2] = Pt(dist_default2(P2), v2, c2, s?.contentAlign);
7771
+ i.write(`${l}${m}${" ".repeat(N2)}${P2}${" ".repeat(D2)}${m}
7772
+ `);
7773
+ }
7774
+ i.write(`${l}${y[2]}${p2.repeat(v2)}${y[3]}
7775
+ `);
7776
+ };
7091
7777
  ue = (t) => {
7092
7778
  const r = t.active ?? "Yes", s = t.inactive ?? "No";
7093
7779
  return new X({ active: r, inactive: s, signal: t.signal, input: t.input, output: t.output, initialValue: t.initialValue ?? true, render() {
7094
- const i = t.withGuide ?? h.withGuide, u = `${M(this.state)} `, n = i ? `${styleText("gray", $)} ` : "", o = W(t.output, t.message, n, u), c2 = `${i ? `${styleText("gray", $)}
7780
+ const i = t.withGuide ?? h.withGuide, u = `${M(this.state)} `, n = i ? `${styleText("gray", $2)} ` : "", o = W(t.output, t.message, n, u), c2 = `${i ? `${styleText("gray", $2)}
7095
7781
  ` : ""}${o}
7096
7782
  `, a = this.value ? r : s;
7097
7783
  switch (this.state) {
7098
7784
  case "submit": {
7099
- const l = i ? `${styleText("gray", $)} ` : "";
7785
+ const l = i ? `${styleText("gray", $2)} ` : "";
7100
7786
  return `${c2}${l}${styleText("dim", a)}`;
7101
7787
  }
7102
7788
  case "cancel": {
7103
- const l = i ? `${styleText("gray", $)} ` : "";
7789
+ const l = i ? `${styleText("gray", $2)} ` : "";
7104
7790
  return `${c2}${l}${styleText(["strikethrough", "dim"], a)}${i ? `
7105
- ${styleText("gray", $)}` : ""}`;
7791
+ ${styleText("gray", $2)}` : ""}`;
7106
7792
  }
7107
7793
  default: {
7108
- const l = i ? `${styleText("cyan", $)} ` : "", d2 = i ? styleText("cyan", E2) : "";
7109
- return `${c2}${l}${this.value ? `${styleText("green", z2)} ${r}` : `${styleText("dim", H)} ${styleText("dim", r)}`}${t.vertical ? i ? `
7110
- ${styleText("cyan", $)} ` : `
7111
- ` : ` ${styleText("dim", "/")} `}${this.value ? `${styleText("dim", H)} ${styleText("dim", s)}` : `${styleText("green", z2)} ${s}`}
7794
+ const l = i ? `${styleText("cyan", $2)} ` : "", d2 = i ? styleText("cyan", E2) : "";
7795
+ return `${c2}${l}${this.value ? `${styleText("green", z2)} ${r}` : `${styleText("dim", H2)} ${styleText("dim", r)}`}${t.vertical ? i ? `
7796
+ ${styleText("cyan", $2)} ` : `
7797
+ ` : ` ${styleText("dim", "/")} `}${this.value ? `${styleText("dim", H2)} ${styleText("dim", s)}` : `${styleText("green", z2)} ${s}`}
7112
7798
  ${d2}
7113
7799
  `;
7114
7800
  }
7115
7801
  }
7116
7802
  } }).prompt();
7117
7803
  };
7804
+ le = (t) => {
7805
+ const r = t.validate;
7806
+ return new et({ ...t, validate(s) {
7807
+ if (s === void 0) return t.defaultValue !== void 0 ? void 0 : r ? r(s) : h.date.messages.required;
7808
+ const i = (u) => u.toISOString().slice(0, 10);
7809
+ if (t.minDate && i(s) < i(t.minDate)) return h.date.messages.afterMin(t.minDate);
7810
+ if (t.maxDate && i(s) > i(t.maxDate)) return h.date.messages.beforeMax(t.maxDate);
7811
+ if (r) return r(s);
7812
+ }, render() {
7813
+ const s = (t?.withGuide ?? h.withGuide) !== false, i = `${`${s ? `${styleText("gray", $2)}
7814
+ ` : ""}${M(this.state)} `}${t.message}
7815
+ `, u = this.state !== "initial" ? this.state : "active", n = ce(this, u), o = this.value instanceof Date ? this.formattedValue : "";
7816
+ switch (this.state) {
7817
+ case "error": {
7818
+ const c2 = this.error ? ` ${styleText("yellow", this.error)}` : "", a = s ? `${styleText("yellow", $2)} ` : "", l = s ? styleText("yellow", E2) : "";
7819
+ return `${i.trim()}
7820
+ ${a}${n}
7821
+ ${l}${c2}
7822
+ `;
7823
+ }
7824
+ case "submit": {
7825
+ const c2 = o ? ` ${styleText("dim", o)}` : "", a = s ? styleText("gray", $2) : "";
7826
+ return `${i}${a}${c2}`;
7827
+ }
7828
+ case "cancel": {
7829
+ const c2 = o ? ` ${styleText(["strikethrough", "dim"], o)}` : "", a = s ? styleText("gray", $2) : "";
7830
+ return `${i}${a}${c2}${o.trim() ? `
7831
+ ${a}` : ""}`;
7832
+ }
7833
+ default: {
7834
+ const c2 = s ? `${styleText("cyan", $2)} ` : "", a = s ? styleText("cyan", E2) : "", l = s ? `${styleText("cyan", $2)} ` : "", d2 = this.inlineError ? `
7835
+ ${l}${styleText("yellow", this.inlineError)}` : "";
7836
+ return `${i}${c2}${n}${d2}
7837
+ ${a}
7838
+ `;
7839
+ }
7840
+ }
7841
+ } }).prompt();
7842
+ };
7843
+ de = { year: "yyyy", month: "mm", day: "dd" };
7118
7844
  he = async (t, r) => {
7119
7845
  const s = {}, i = Object.keys(t);
7120
7846
  for (const u of i) {
@@ -7129,7 +7855,74 @@ ${d2}
7129
7855
  }
7130
7856
  return s;
7131
7857
  };
7132
- R2 = { message: (t = [], { symbol: r = styleText("gray", $), secondarySymbol: s = styleText("gray", $), output: i = process.stdout, spacing: u = 1, withGuide: n } = {}) => {
7858
+ pe = (t) => {
7859
+ const { selectableGroups: r = true, groupSpacing: s = 0 } = t, i = (n, o, c2 = []) => {
7860
+ const a = n.label ?? String(n.value), l = typeof n.group == "string", d2 = l && (c2[c2.indexOf(n) + 1] ?? { group: true }), y = l && d2 && d2.group === true, p2 = l ? r ? `${y ? E2 : $2} ` : " " : "";
7861
+ let m = "";
7862
+ if (s > 0 && !l) {
7863
+ const S2 = `
7864
+ ${styleText("cyan", $2)}`;
7865
+ m = `${S2.repeat(s - 1)}${S2} `;
7866
+ }
7867
+ if (o === "active") return `${m}${styleText("dim", p2)}${styleText("cyan", et2)} ${a}${n.hint ? ` ${styleText("dim", `(${n.hint})`)}` : ""}`;
7868
+ if (o === "group-active") return `${m}${p2}${styleText("cyan", et2)} ${styleText("dim", a)}`;
7869
+ if (o === "group-active-selected") return `${m}${p2}${styleText("green", U2)} ${styleText("dim", a)}`;
7870
+ if (o === "selected") {
7871
+ const S2 = l || r ? styleText("green", U2) : "";
7872
+ return `${m}${styleText("dim", p2)}${S2} ${styleText("dim", a)}${n.hint ? ` ${styleText("dim", `(${n.hint})`)}` : ""}`;
7873
+ }
7874
+ if (o === "cancelled") return `${styleText(["strikethrough", "dim"], a)}`;
7875
+ if (o === "active-selected") return `${m}${styleText("dim", p2)}${styleText("green", U2)} ${a}${n.hint ? ` ${styleText("dim", `(${n.hint})`)}` : ""}`;
7876
+ if (o === "submitted") return `${styleText("dim", a)}`;
7877
+ const g = l || r ? styleText("dim", J2) : "";
7878
+ return `${m}${styleText("dim", p2)}${g} ${styleText("dim", a)}`;
7879
+ }, u = t.required ?? true;
7880
+ return new it({ options: t.options, signal: t.signal, input: t.input, output: t.output, initialValues: t.initialValues, required: u, cursorAt: t.cursorAt, selectableGroups: r, validate(n) {
7881
+ if (u && (n === void 0 || n.length === 0)) return `Please select at least one option.
7882
+ ${styleText("reset", styleText("dim", `Press ${styleText(["gray", "bgWhite", "inverse"], " space ")} to select, ${styleText("gray", styleText(["bgWhite", "inverse"], " enter "))} to submit`))}`;
7883
+ }, render() {
7884
+ const n = t.withGuide ?? h.withGuide, o = `${n ? `${styleText("gray", $2)}
7885
+ ` : ""}${M(this.state)} ${t.message}
7886
+ `, c2 = this.value ?? [];
7887
+ switch (this.state) {
7888
+ case "submit": {
7889
+ const a = this.options.filter(({ value: d2 }) => c2.includes(d2)).map((d2) => i(d2, "submitted")), l = a.length === 0 ? "" : ` ${a.join(styleText("dim", ", "))}`;
7890
+ return `${o}${n ? styleText("gray", $2) : ""}${l}`;
7891
+ }
7892
+ case "cancel": {
7893
+ const a = this.options.filter(({ value: l }) => c2.includes(l)).map((l) => i(l, "cancelled")).join(styleText("dim", ", "));
7894
+ return `${o}${n ? `${styleText("gray", $2)} ` : ""}${a.trim() ? `${a}${n ? `
7895
+ ${styleText("gray", $2)}` : ""}` : ""}`;
7896
+ }
7897
+ case "error": {
7898
+ const a = this.error.split(`
7899
+ `).map((l, d2) => d2 === 0 ? `${n ? `${styleText("yellow", E2)} ` : ""}${styleText("yellow", l)}` : ` ${l}`).join(`
7900
+ `);
7901
+ return `${o}${n ? `${styleText("yellow", $2)} ` : ""}${this.options.map((l, d2, y) => {
7902
+ const p2 = c2.includes(l.value) || l.group === true && this.isGroupSelected(`${l.value}`), m = d2 === this.cursor;
7903
+ return !m && typeof l.group == "string" && this.options[this.cursor].value === l.group ? i(l, p2 ? "group-active-selected" : "group-active", y) : m && p2 ? i(l, "active-selected", y) : p2 ? i(l, "selected", y) : i(l, m ? "active" : "inactive", y);
7904
+ }).join(`
7905
+ ${n ? `${styleText("yellow", $2)} ` : ""}`)}
7906
+ ${a}
7907
+ `;
7908
+ }
7909
+ default: {
7910
+ const a = this.options.map((d2, y, p2) => {
7911
+ const m = c2.includes(d2.value) || d2.group === true && this.isGroupSelected(`${d2.value}`), g = y === this.cursor, S2 = !g && typeof d2.group == "string" && this.options[this.cursor].value === d2.group;
7912
+ let h2 = "";
7913
+ return S2 ? h2 = i(d2, m ? "group-active-selected" : "group-active", p2) : g && m ? h2 = i(d2, "active-selected", p2) : m ? h2 = i(d2, "selected", p2) : h2 = i(d2, g ? "active" : "inactive", p2), `${y !== 0 && !h2.startsWith(`
7914
+ `) ? " " : ""}${h2}`;
7915
+ }).join(`
7916
+ ${n ? styleText("cyan", $2) : ""}`), l = a.startsWith(`
7917
+ `) ? "" : " ";
7918
+ return `${o}${n ? styleText("cyan", $2) : ""}${l}${a}
7919
+ ${n ? styleText("cyan", E2) : ""}
7920
+ `;
7921
+ }
7922
+ }
7923
+ } }).prompt();
7924
+ };
7925
+ R2 = { message: (t = [], { symbol: r = styleText("gray", $2), secondarySymbol: s = styleText("gray", $2), output: i = process.stdout, spacing: u = 1, withGuide: n } = {}) => {
7133
7926
  const o = [], c2 = n ?? h.withGuide, a = c2 ? s : "", l = c2 ? `${r} ` : "", d2 = c2 ? `${s} ` : "";
7134
7927
  for (let p2 = 0; p2 < u; p2++) o.push(a);
7135
7928
  const y = Array.isArray(t) ? t : t.split(`
@@ -7147,7 +7940,7 @@ ${d2}
7147
7940
  }, success: (t, r) => {
7148
7941
  R2.message(t, { ...r, symbol: styleText("green", pt) });
7149
7942
  }, step: (t, r) => {
7150
- R2.message(t, { ...r, symbol: styleText("green", F) });
7943
+ R2.message(t, { ...r, symbol: styleText("green", F2) });
7151
7944
  }, warn: (t, r) => {
7152
7945
  R2.message(t, { ...r, symbol: styleText("yellow", mt) });
7153
7946
  }, warning: (t, r) => {
@@ -7167,25 +7960,53 @@ ${d2}
7167
7960
  `);
7168
7961
  };
7169
7962
  ye = (t = "", r) => {
7170
- const s = r?.output ?? process.stdout, i = r?.withGuide ?? h.withGuide ? `${styleText("gray", $)}
7963
+ const s = r?.output ?? process.stdout, i = r?.withGuide ?? h.withGuide ? `${styleText("gray", $2)}
7171
7964
  ${styleText("gray", E2)} ` : "";
7172
7965
  s.write(`${i}${t}
7173
7966
 
7174
7967
  `);
7175
7968
  };
7969
+ fe = (t) => new rt({ validate: t.validate, placeholder: t.placeholder, defaultValue: t.defaultValue, initialValue: t.initialValue, showSubmit: t.showSubmit, output: t.output, signal: t.signal, input: t.input, render() {
7970
+ const r = t?.withGuide ?? h.withGuide, s = `${`${r ? `${styleText("gray", $2)}
7971
+ ` : ""}${M(this.state)} `}${t.message}
7972
+ `, i = t.placeholder ? styleText("inverse", t.placeholder[0]) + styleText("dim", t.placeholder.slice(1)) : styleText(["inverse", "hidden"], "_"), u = this.userInput ? this.userInputWithCursor : i, n = this.value ?? "", o = t.showSubmit ? `
7973
+ ${styleText(this.focused === "submit" ? "cyan" : "dim", "[ submit ]")}` : "";
7974
+ switch (this.state) {
7975
+ case "error": {
7976
+ const c2 = `${styleText("yellow", $2)} `, a = r ? W(t.output, u, c2, void 0) : u, l = styleText("yellow", E2);
7977
+ return `${s}${a}
7978
+ ${l} ${styleText("yellow", this.error)}${o}
7979
+ `;
7980
+ }
7981
+ case "submit": {
7982
+ const c2 = `${styleText("gray", $2)} `, a = r ? W(t.output, n, c2, void 0, (l) => styleText("dim", l)) : n ? styleText("dim", n) : "";
7983
+ return `${s}${a}`;
7984
+ }
7985
+ case "cancel": {
7986
+ const c2 = `${styleText("gray", $2)} `, a = r ? W(t.output, n, c2, void 0, (l) => styleText(["strikethrough", "dim"], l)) : n ? styleText(["strikethrough", "dim"], n) : "";
7987
+ return `${s}${a}`;
7988
+ }
7989
+ default: {
7990
+ const c2 = r ? `${styleText("cyan", $2)} ` : "", a = r ? styleText("cyan", E2) : "", l = r ? W(t.output, u, c2) : u;
7991
+ return `${s}${l}
7992
+ ${a}${o}
7993
+ `;
7994
+ }
7995
+ }
7996
+ } }).prompt();
7176
7997
  Q2 = (t, r) => t.split(`
7177
7998
  `).map((s) => r(s)).join(`
7178
7999
  `);
7179
8000
  ve = (t) => {
7180
8001
  const r = (i, u) => {
7181
8002
  const n = i.label ?? String(i.value);
7182
- return u === "disabled" ? `${styleText("gray", J)} ${Q2(n, (o) => styleText(["strikethrough", "gray"], o))}${i.hint ? ` ${styleText("dim", `(${i.hint ?? "disabled"})`)}` : ""}` : u === "active" ? `${styleText("cyan", et2)} ${n}${i.hint ? ` ${styleText("dim", `(${i.hint})`)}` : ""}` : u === "selected" ? `${styleText("green", U)} ${Q2(n, (o) => styleText("dim", o))}${i.hint ? ` ${styleText("dim", `(${i.hint})`)}` : ""}` : u === "cancelled" ? `${Q2(n, (o) => styleText(["strikethrough", "dim"], o))}` : u === "active-selected" ? `${styleText("green", U)} ${n}${i.hint ? ` ${styleText("dim", `(${i.hint})`)}` : ""}` : u === "submitted" ? `${Q2(n, (o) => styleText("dim", o))}` : `${styleText("dim", J)} ${Q2(n, (o) => styleText("dim", o))}`;
8003
+ return u === "disabled" ? `${styleText("gray", J2)} ${Q2(n, (o) => styleText(["strikethrough", "gray"], o))}${i.hint ? ` ${styleText("dim", `(${i.hint ?? "disabled"})`)}` : ""}` : u === "active" ? `${styleText("cyan", et2)} ${n}${i.hint ? ` ${styleText("dim", `(${i.hint})`)}` : ""}` : u === "selected" ? `${styleText("green", U2)} ${Q2(n, (o) => styleText("dim", o))}${i.hint ? ` ${styleText("dim", `(${i.hint})`)}` : ""}` : u === "cancelled" ? `${Q2(n, (o) => styleText(["strikethrough", "dim"], o))}` : u === "active-selected" ? `${styleText("green", U2)} ${n}${i.hint ? ` ${styleText("dim", `(${i.hint})`)}` : ""}` : u === "submitted" ? `${Q2(n, (o) => styleText("dim", o))}` : `${styleText("dim", J2)} ${Q2(n, (o) => styleText("dim", o))}`;
7183
8004
  }, s = t.required ?? true;
7184
8005
  return new nt({ options: t.options, signal: t.signal, input: t.input, output: t.output, initialValues: t.initialValues, required: s, cursorAt: t.cursorAt, validate(i) {
7185
8006
  if (s && (i === void 0 || i.length === 0)) return `Please select at least one option.
7186
8007
  ${styleText("reset", styleText("dim", `Press ${styleText(["gray", "bgWhite", "inverse"], " space ")} to select, ${styleText("gray", styleText("bgWhite", styleText("inverse", " enter ")))} to submit`))}`;
7187
8008
  }, render() {
7188
- const i = t.withGuide ?? h.withGuide, u = W(t.output, t.message, i ? `${yt(this.state)} ` : "", `${M(this.state)} `), n = `${i ? `${styleText("gray", $)}
8009
+ const i = t.withGuide ?? h.withGuide, u = W(t.output, t.message, i ? `${yt(this.state)} ` : "", `${M(this.state)} `), n = `${i ? `${styleText("gray", $2)}
7189
8010
  ` : ""}${u}
7190
8011
  `, o = this.value ?? [], c2 = (a, l) => {
7191
8012
  if (a.disabled) return r(a, "disabled");
@@ -7194,18 +8015,18 @@ ${styleText("reset", styleText("dim", `Press ${styleText(["gray", "bgWhite", "in
7194
8015
  };
7195
8016
  switch (this.state) {
7196
8017
  case "submit": {
7197
- const a = this.options.filter(({ value: d2 }) => o.includes(d2)).map((d2) => r(d2, "submitted")).join(styleText("dim", ", ")) || styleText("dim", "none"), l = W(t.output, a, i ? `${styleText("gray", $)} ` : "");
8018
+ const a = this.options.filter(({ value: d2 }) => o.includes(d2)).map((d2) => r(d2, "submitted")).join(styleText("dim", ", ")) || styleText("dim", "none"), l = W(t.output, a, i ? `${styleText("gray", $2)} ` : "");
7198
8019
  return `${n}${l}`;
7199
8020
  }
7200
8021
  case "cancel": {
7201
8022
  const a = this.options.filter(({ value: d2 }) => o.includes(d2)).map((d2) => r(d2, "cancelled")).join(styleText("dim", ", "));
7202
- if (a.trim() === "") return `${n}${styleText("gray", $)}`;
7203
- const l = W(t.output, a, i ? `${styleText("gray", $)} ` : "");
8023
+ if (a.trim() === "") return `${n}${styleText("gray", $2)}`;
8024
+ const l = W(t.output, a, i ? `${styleText("gray", $2)} ` : "");
7204
8025
  return `${n}${l}${i ? `
7205
- ${styleText("gray", $)}` : ""}`;
8026
+ ${styleText("gray", $2)}` : ""}`;
7206
8027
  }
7207
8028
  case "error": {
7208
- const a = i ? `${styleText("yellow", $)} ` : "", l = this.error.split(`
8029
+ const a = i ? `${styleText("yellow", $2)} ` : "", l = this.error.split(`
7209
8030
  `).map((p2, m) => m === 0 ? `${i ? `${styleText("yellow", E2)} ` : ""}${styleText("yellow", p2)}` : ` ${p2}`).join(`
7210
8031
  `), d2 = n.split(`
7211
8032
  `).length, y = l.split(`
@@ -7216,7 +8037,7 @@ ${l}
7216
8037
  `;
7217
8038
  }
7218
8039
  default: {
7219
- const a = i ? `${styleText("cyan", $)} ` : "", l = n.split(`
8040
+ const a = i ? `${styleText("cyan", $2)} ` : "", l = n.split(`
7220
8041
  `).length, d2 = i ? 2 : 1;
7221
8042
  return `${n}${a}${Y2({ output: t.output, options: this.options, cursor: this.cursor, maxItems: t.maxItems, columnPadding: a.length, rowPadding: l + d2, style: c2 }).join(`
7222
8043
  ${a}`)}
@@ -7237,97 +8058,120 @@ ${i ? styleText("cyan", E2) : ""}
7237
8058
  `).map(n), ""], c2 = dist_default2(r), a = Math.max(o.reduce((p2, m) => {
7238
8059
  const g = dist_default2(m);
7239
8060
  return g > p2 ? g : p2;
7240
- }, 0), c2) + 2, l = o.map((p2) => `${styleText("gray", $)} ${p2}${" ".repeat(a - dist_default2(p2))}${styleText("gray", $)}`).join(`
7241
- `), d2 = u ? `${styleText("gray", $)}
8061
+ }, 0), c2) + 2, l = o.map((p2) => `${styleText("gray", $2)} ${p2}${" ".repeat(a - dist_default2(p2))}${styleText("gray", $2)}`).join(`
8062
+ `), d2 = u ? `${styleText("gray", $2)}
7242
8063
  ` : "", y = u ? xt : dt;
7243
- i.write(`${d2}${styleText("green", F)} ${styleText("reset", r)} ${styleText("gray", st.repeat(Math.max(a - c2 - 1, 1)) + ct)}
8064
+ i.write(`${d2}${styleText("green", F2)} ${styleText("reset", r)} ${styleText("gray", st2.repeat(Math.max(a - c2 - 1, 1)) + ct)}
7244
8065
  ${l}
7245
- ${styleText("gray", y + st.repeat(a + 2) + $t)}
8066
+ ${styleText("gray", y + st2.repeat(a + 2) + $t)}
7246
8067
  `);
7247
8068
  };
7248
8069
  Ce = (t) => new ot({ validate: t.validate, mask: t.mask ?? Gt, signal: t.signal, input: t.input, output: t.output, render() {
7249
- const r = t.withGuide ?? h.withGuide, s = `${r ? `${styleText("gray", $)}
8070
+ const r = t.withGuide ?? h.withGuide, s = `${r ? `${styleText("gray", $2)}
7250
8071
  ` : ""}${M(this.state)} ${t.message}
7251
8072
  `, i = this.userInputWithCursor, u = this.masked;
7252
8073
  switch (this.state) {
7253
8074
  case "error": {
7254
- const n = r ? `${styleText("yellow", $)} ` : "", o = r ? `${styleText("yellow", E2)} ` : "", c2 = u ?? "";
8075
+ const n = r ? `${styleText("yellow", $2)} ` : "", o = r ? `${styleText("yellow", E2)} ` : "", c2 = u ?? "";
7255
8076
  return t.clearOnError && this.clear(), `${s.trim()}
7256
8077
  ${n}${c2}
7257
8078
  ${o}${styleText("yellow", this.error)}
7258
8079
  `;
7259
8080
  }
7260
8081
  case "submit": {
7261
- const n = r ? `${styleText("gray", $)} ` : "", o = u ? styleText("dim", u) : "";
8082
+ const n = r ? `${styleText("gray", $2)} ` : "", o = u ? styleText("dim", u) : "";
7262
8083
  return `${s}${n}${o}`;
7263
8084
  }
7264
8085
  case "cancel": {
7265
- const n = r ? `${styleText("gray", $)} ` : "", o = u ? styleText(["strikethrough", "dim"], u) : "";
8086
+ const n = r ? `${styleText("gray", $2)} ` : "", o = u ? styleText(["strikethrough", "dim"], u) : "";
7266
8087
  return `${s}${n}${o}${u && r ? `
7267
- ${styleText("gray", $)}` : ""}`;
8088
+ ${styleText("gray", $2)}` : ""}`;
7268
8089
  }
7269
8090
  default: {
7270
- const n = r ? `${styleText("cyan", $)} ` : "", o = r ? styleText("cyan", E2) : "";
8091
+ const n = r ? `${styleText("cyan", $2)} ` : "", o = r ? styleText("cyan", E2) : "";
7271
8092
  return `${s}${n}${i}
7272
8093
  ${o}
7273
8094
  `;
7274
8095
  }
7275
8096
  }
7276
8097
  } }).prompt();
8098
+ Te = (t) => {
8099
+ const r = t.validate;
8100
+ return At({ ...t, initialUserInput: t.initialValue ?? t.root ?? process.cwd(), maxItems: 5, validate(s) {
8101
+ if (!Array.isArray(s)) {
8102
+ if (!s) return "Please select a path";
8103
+ if (r) return r(s);
8104
+ }
8105
+ }, options() {
8106
+ const s = this.userInput;
8107
+ if (s === "") return [];
8108
+ try {
8109
+ let i;
8110
+ existsSync(s) ? lstatSync(s).isDirectory() && (!t.directory || s.endsWith("/")) ? i = s : i = dirname(s) : i = dirname(s);
8111
+ const u = s.length > 1 && s.endsWith("/") ? s.slice(0, -1) : s;
8112
+ return readdirSync(i).map((n) => {
8113
+ const o = join(i, n), c2 = lstatSync(o);
8114
+ return { name: n, path: o, isDirectory: c2.isDirectory() };
8115
+ }).filter(({ path: n, isDirectory: o }) => n.startsWith(u) && (o || !t.directory)).map((n) => ({ value: n.path }));
8116
+ } catch {
8117
+ return [];
8118
+ }
8119
+ } });
8120
+ };
7277
8121
  _e = (t) => styleText("magenta", t);
7278
- ft = ({ indicator: t = "dots", onCancel: r, output: s = process.stdout, cancelMessage: i, errorMessage: u, frames: n = tt ? ["\u25D2", "\u25D0", "\u25D3", "\u25D1"] : ["\u2022", "o", "O", "0"], delay: o = tt ? 80 : 120, signal: c2, ...a } = {}) => {
8122
+ ft = ({ indicator: t = "dots", onCancel: r, output: s = process.stdout, cancelMessage: i, errorMessage: u, frames: n = tt2 ? ["\u25D2", "\u25D0", "\u25D3", "\u25D1"] : ["\u2022", "o", "O", "0"], delay: o = tt2 ? 80 : 120, signal: c2, ...a } = {}) => {
7279
8123
  const l = at2();
7280
8124
  let d2, y, p2 = false, m = false, g = "", S2, h2 = performance.now();
7281
- const f = A(s), v2 = a?.styleFrame ?? _e, T = (I) => {
7282
- const V2 = I > 1 ? u ?? h.messages.error : i ?? h.messages.cancel;
7283
- m = I === 1, p2 && (W2(V2, I), m && typeof r == "function" && r());
8125
+ const f = A(s), v2 = a?.styleFrame ?? _e, T = (I2) => {
8126
+ const V2 = I2 > 1 ? u ?? h.messages.error : i ?? h.messages.cancel;
8127
+ m = I2 === 1, p2 && (W2(V2, I2), m && typeof r == "function" && r());
7284
8128
  }, C2 = () => T(2), b2 = () => T(1), G2 = () => {
7285
8129
  process.on("uncaughtExceptionMonitor", C2), process.on("unhandledRejection", C2), process.on("SIGINT", b2), process.on("SIGTERM", b2), process.on("exit", T), c2 && c2.addEventListener("abort", b2);
7286
- }, x = () => {
8130
+ }, x2 = () => {
7287
8131
  process.removeListener("uncaughtExceptionMonitor", C2), process.removeListener("unhandledRejection", C2), process.removeListener("SIGINT", b2), process.removeListener("SIGTERM", b2), process.removeListener("exit", T), c2 && c2.removeEventListener("abort", b2);
7288
8132
  }, A2 = () => {
7289
8133
  if (S2 === void 0) return;
7290
8134
  l && s.write(`
7291
8135
  `);
7292
- const I = wrapAnsi(S2, f, { hard: true, trim: false }).split(`
8136
+ const I2 = wrapAnsi(S2, f, { hard: true, trim: false }).split(`
7293
8137
  `);
7294
- I.length > 1 && s.write(import_sisteransi2.cursor.up(I.length - 1)), s.write(import_sisteransi2.cursor.to(0)), s.write(import_sisteransi2.erase.down());
7295
- }, P = (I) => I.replace(/\.+$/, ""), N = (I) => {
7296
- const V2 = (performance.now() - I) / 1e3, B = Math.floor(V2 / 60), L2 = Math.floor(V2 % 60);
7297
- return B > 0 ? `[${B}m ${L2}s]` : `[${L2}s]`;
7298
- }, D2 = a.withGuide ?? h.withGuide, rt2 = (I = "") => {
7299
- p2 = true, d2 = R({ output: s }), g = P(I), h2 = performance.now(), D2 && s.write(`${styleText("gray", $)}
8138
+ I2.length > 1 && s.write(import_sisteransi2.cursor.up(I2.length - 1)), s.write(import_sisteransi2.cursor.to(0)), s.write(import_sisteransi2.erase.down());
8139
+ }, P2 = (I2) => I2.replace(/\.+$/, ""), N2 = (I2) => {
8140
+ const V2 = (performance.now() - I2) / 1e3, B2 = Math.floor(V2 / 60), L2 = Math.floor(V2 % 60);
8141
+ return B2 > 0 ? `[${B2}m ${L2}s]` : `[${L2}s]`;
8142
+ }, D2 = a.withGuide ?? h.withGuide, rt2 = (I2 = "") => {
8143
+ p2 = true, d2 = R({ output: s }), g = P2(I2), h2 = performance.now(), D2 && s.write(`${styleText("gray", $2)}
7300
8144
  `);
7301
- let V2 = 0, B = 0;
8145
+ let V2 = 0, B2 = 0;
7302
8146
  G2(), y = setInterval(() => {
7303
8147
  if (l && g === S2) return;
7304
8148
  A2(), S2 = g;
7305
8149
  const L2 = v2(n[V2]);
7306
- let Z;
7307
- if (l) Z = `${L2} ${g}...`;
7308
- else if (t === "timer") Z = `${L2} ${g} ${N(h2)}`;
8150
+ let Z2;
8151
+ if (l) Z2 = `${L2} ${g}...`;
8152
+ else if (t === "timer") Z2 = `${L2} ${g} ${N2(h2)}`;
7309
8153
  else {
7310
- const kt = ".".repeat(Math.floor(B)).slice(0, 3);
7311
- Z = `${L2} ${g}${kt}`;
8154
+ const kt = ".".repeat(Math.floor(B2)).slice(0, 3);
8155
+ Z2 = `${L2} ${g}${kt}`;
7312
8156
  }
7313
- const Nt = wrapAnsi(Z, f, { hard: true, trim: false });
7314
- s.write(Nt), V2 = V2 + 1 < n.length ? V2 + 1 : 0, B = B < 4 ? B + 0.125 : 0;
8157
+ const Nt = wrapAnsi(Z2, f, { hard: true, trim: false });
8158
+ s.write(Nt), V2 = V2 + 1 < n.length ? V2 + 1 : 0, B2 = B2 < 4 ? B2 + 0.125 : 0;
7315
8159
  }, o);
7316
- }, W2 = (I = "", V2 = 0, B = false) => {
8160
+ }, W2 = (I2 = "", V2 = 0, B2 = false) => {
7317
8161
  if (!p2) return;
7318
8162
  p2 = false, clearInterval(y), A2();
7319
- const L2 = V2 === 0 ? styleText("green", F) : V2 === 1 ? styleText("red", ot2) : styleText("red", ut2);
7320
- g = I ?? g, B || (t === "timer" ? s.write(`${L2} ${g} ${N(h2)}
8163
+ const L2 = V2 === 0 ? styleText("green", F2) : V2 === 1 ? styleText("red", ot2) : styleText("red", ut2);
8164
+ g = I2 ?? g, B2 || (t === "timer" ? s.write(`${L2} ${g} ${N2(h2)}
7321
8165
  `) : s.write(`${L2} ${g}
7322
- `)), x(), d2();
8166
+ `)), x2(), d2();
7323
8167
  };
7324
- return { start: rt2, stop: (I = "") => W2(I, 0), message: (I = "") => {
7325
- g = P(I ?? g);
7326
- }, cancel: (I = "") => W2(I, 1), error: (I = "") => W2(I, 2), clear: () => W2("", 0, true), get isCancelled() {
8168
+ return { start: rt2, stop: (I2 = "") => W2(I2, 0), message: (I2 = "") => {
8169
+ g = P2(I2 ?? g);
8170
+ }, cancel: (I2 = "") => W2(I2, 1), error: (I2 = "") => W2(I2, 2), clear: () => W2("", 0, true), get isCancelled() {
7327
8171
  return m;
7328
8172
  } };
7329
8173
  };
7330
- ({ light: w2("\u2500", "-"), heavy: w2("\u2501", "="), block: w2("\u2588", "#") });
8174
+ Vt = { light: w2("\u2500", "-"), heavy: w2("\u2501", "="), block: w2("\u2588", "#") };
7331
8175
  it2 = (t, r) => t.includes(`
7332
8176
  `) ? t.split(`
7333
8177
  `).map((s) => r(s)).join(`
@@ -7337,7 +8181,7 @@ ${o}
7337
8181
  const u = s.label ?? String(s.value);
7338
8182
  switch (i) {
7339
8183
  case "disabled":
7340
- return `${styleText("gray", H)} ${it2(u, (n) => styleText("gray", n))}${s.hint ? ` ${styleText("dim", `(${s.hint ?? "disabled"})`)}` : ""}`;
8184
+ return `${styleText("gray", H2)} ${it2(u, (n) => styleText("gray", n))}${s.hint ? ` ${styleText("dim", `(${s.hint ?? "disabled"})`)}` : ""}`;
7341
8185
  case "selected":
7342
8186
  return `${it2(u, (n) => styleText("dim", n))}`;
7343
8187
  case "active":
@@ -7345,25 +8189,25 @@ ${o}
7345
8189
  case "cancelled":
7346
8190
  return `${it2(u, (n) => styleText(["strikethrough", "dim"], n))}`;
7347
8191
  default:
7348
- return `${styleText("dim", H)} ${it2(u, (n) => styleText("dim", n))}`;
8192
+ return `${styleText("dim", H2)} ${it2(u, (n) => styleText("dim", n))}`;
7349
8193
  }
7350
8194
  };
7351
8195
  return new ut({ options: t.options, signal: t.signal, input: t.input, output: t.output, initialValue: t.initialValue, render() {
7352
- const s = t.withGuide ?? h.withGuide, i = `${M(this.state)} `, u = `${yt(this.state)} `, n = W(t.output, t.message, u, i), o = `${s ? `${styleText("gray", $)}
8196
+ const s = t.withGuide ?? h.withGuide, i = `${M(this.state)} `, u = `${yt(this.state)} `, n = W(t.output, t.message, u, i), o = `${s ? `${styleText("gray", $2)}
7353
8197
  ` : ""}${n}
7354
8198
  `;
7355
8199
  switch (this.state) {
7356
8200
  case "submit": {
7357
- const c2 = s ? `${styleText("gray", $)} ` : "", a = W(t.output, r(this.options[this.cursor], "selected"), c2);
8201
+ const c2 = s ? `${styleText("gray", $2)} ` : "", a = W(t.output, r(this.options[this.cursor], "selected"), c2);
7358
8202
  return `${o}${a}`;
7359
8203
  }
7360
8204
  case "cancel": {
7361
- const c2 = s ? `${styleText("gray", $)} ` : "", a = W(t.output, r(this.options[this.cursor], "cancelled"), c2);
8205
+ const c2 = s ? `${styleText("gray", $2)} ` : "", a = W(t.output, r(this.options[this.cursor], "cancelled"), c2);
7362
8206
  return `${o}${a}${s ? `
7363
- ${styleText("gray", $)}` : ""}`;
8207
+ ${styleText("gray", $2)}` : ""}`;
7364
8208
  }
7365
8209
  default: {
7366
- const c2 = s ? `${styleText("cyan", $)} ` : "", a = s ? styleText("cyan", E2) : "", l = o.split(`
8210
+ const c2 = s ? `${styleText("cyan", $2)} ` : "", a = s ? styleText("cyan", E2) : "", l = o.split(`
7367
8211
  `).length, d2 = s ? 2 : 1;
7368
8212
  return `${o}${c2}${Y2({ output: t.output, cursor: this.cursor, options: this.options, maxItems: t.maxItems, columnPadding: c2.length, rowPadding: l + d2, style: (y, p2) => r(y, y.disabled ? "disabled" : p2 ? "active" : "inactive") }).join(`
7369
8213
  ${c2}`)}
@@ -7373,30 +8217,157 @@ ${a}
7373
8217
  }
7374
8218
  } }).prompt();
7375
8219
  };
7376
- `${styleText("gray", $)} `;
8220
+ Ge = (t) => {
8221
+ const r = (s, i = "inactive") => {
8222
+ const u = s.label ?? String(s.value);
8223
+ return i === "selected" ? `${styleText("dim", u)}` : i === "cancelled" ? `${styleText(["strikethrough", "dim"], u)}` : i === "active" ? `${styleText(["bgCyan", "gray"], ` ${s.value} `)} ${u}${s.hint ? ` ${styleText("dim", `(${s.hint})`)}` : ""}` : `${styleText(["gray", "bgWhite", "inverse"], ` ${s.value} `)} ${u}${s.hint ? ` ${styleText("dim", `(${s.hint})`)}` : ""}`;
8224
+ };
8225
+ return new at({ options: t.options, signal: t.signal, input: t.input, output: t.output, initialValue: t.initialValue, caseSensitive: t.caseSensitive, render() {
8226
+ const s = t.withGuide ?? h.withGuide, i = `${s ? `${styleText("gray", $2)}
8227
+ ` : ""}${M(this.state)} ${t.message}
8228
+ `;
8229
+ switch (this.state) {
8230
+ case "submit": {
8231
+ const u = s ? `${styleText("gray", $2)} ` : "", n = this.options.find((c2) => c2.value === this.value) ?? t.options[0], o = W(t.output, r(n, "selected"), u);
8232
+ return `${i}${o}`;
8233
+ }
8234
+ case "cancel": {
8235
+ const u = s ? `${styleText("gray", $2)} ` : "", n = W(t.output, r(this.options[0], "cancelled"), u);
8236
+ return `${i}${n}${s ? `
8237
+ ${styleText("gray", $2)}` : ""}`;
8238
+ }
8239
+ default: {
8240
+ const u = s ? `${styleText("cyan", $2)} ` : "", n = s ? styleText("cyan", E2) : "", o = this.options.map((c2, a) => W(t.output, r(c2, a === this.cursor ? "active" : "inactive"), u)).join(`
8241
+ `);
8242
+ return `${i}${o}
8243
+ ${n}
8244
+ `;
8245
+ }
8246
+ }
8247
+ } }).prompt();
8248
+ };
8249
+ jt = `${styleText("gray", $2)} `;
8250
+ K2 = { message: async (t, { symbol: r = styleText("gray", $2) } = {}) => {
8251
+ process.stdout.write(`${styleText("gray", $2)}
8252
+ ${r} `);
8253
+ let s = 3;
8254
+ for await (let i of t) {
8255
+ i = i.replace(/\n/g, `
8256
+ ${jt}`), i.includes(`
8257
+ `) && (s = 3 + stripVTControlCharacters(i.slice(i.lastIndexOf(`
8258
+ `))).length);
8259
+ const u = stripVTControlCharacters(i).length;
8260
+ s + u < process.stdout.columns ? (s += u, process.stdout.write(i)) : (process.stdout.write(`
8261
+ ${jt}${i.trimStart()}`), s = 3 + stripVTControlCharacters(i.trimStart()).length);
8262
+ }
8263
+ process.stdout.write(`
8264
+ `);
8265
+ }, info: (t) => K2.message(t, { symbol: styleText("blue", ht2) }), success: (t) => K2.message(t, { symbol: styleText("green", pt) }), step: (t) => K2.message(t, { symbol: styleText("green", F2) }), warn: (t) => K2.message(t, { symbol: styleText("yellow", mt) }), warning: (t) => K2.warn(t), error: (t) => K2.message(t, { symbol: styleText("red", gt) }) };
8266
+ xe = async (t, r) => {
8267
+ for (const s of t) {
8268
+ if (s.enabled === false) continue;
8269
+ const i = ft(r);
8270
+ i.start(s.title);
8271
+ const u = await s.task(i.message);
8272
+ i.stop(u || s.title);
8273
+ }
8274
+ };
8275
+ Oe = (t) => t.replace(/\x1b\[(?:\d+;)*\d*[ABCDEFGHfJKSTsu]|\x1b\[(s|u)/g, "");
8276
+ Me = (t) => {
8277
+ const r = t.output ?? process.stdout, s = A(r), i = styleText("gray", $2), u = t.spacing ?? 1, n = 3, o = t.retainLog === true, c2 = !at2() && Tt(r);
8278
+ r.write(`${i}
8279
+ `), r.write(`${styleText("green", F2)} ${t.title}
8280
+ `);
8281
+ for (let h2 = 0; h2 < u; h2++) r.write(`${i}
8282
+ `);
8283
+ const a = [{ value: "", full: "" }];
8284
+ let l = false;
8285
+ const d2 = (h2) => {
8286
+ if (a.length === 0) return;
8287
+ let f = 0;
8288
+ h2 && (f += u + 2);
8289
+ for (const v2 of a) {
8290
+ const { value: T, result: C2 } = v2;
8291
+ let b2 = C2?.message ?? T;
8292
+ if (b2.length === 0) continue;
8293
+ C2 === void 0 && v2.header !== void 0 && v2.header !== "" && (b2 += `
8294
+ ${v2.header}`);
8295
+ const G2 = b2.split(`
8296
+ `).reduce((x2, A2) => A2 === "" ? x2 + 1 : x2 + Math.ceil((A2.length + n) / s), 0);
8297
+ f += G2;
8298
+ }
8299
+ f > 0 && (f += 1, r.write(import_sisteransi2.erase.lines(f)));
8300
+ }, y = (h2, f, v2) => {
8301
+ const T = v2 ? `${h2.full}
8302
+ ${h2.value}` : h2.value;
8303
+ h2.header !== void 0 && h2.header !== "" && R2.message(h2.header.split(`
8304
+ `).map((C2) => styleText("bold", C2)), { output: r, secondarySymbol: i, symbol: i, spacing: 0 }), R2.message(T.split(`
8305
+ `).map((C2) => styleText("dim", C2)), { output: r, secondarySymbol: i, symbol: i, spacing: f ?? u });
8306
+ }, p2 = () => {
8307
+ for (const h2 of a) {
8308
+ const { header: f, value: v2, full: T } = h2;
8309
+ (f === void 0 || f.length === 0) && v2.length === 0 || y(h2, void 0, o === true && T.length > 0);
8310
+ }
8311
+ }, m = (h2, f, v2) => {
8312
+ if (d2(false), (v2?.raw !== true || !l) && h2.value !== "" && (h2.value += `
8313
+ `), h2.value += Oe(f), l = v2?.raw === true, t.limit !== void 0) {
8314
+ const T = h2.value.split(`
8315
+ `), C2 = T.length - t.limit;
8316
+ if (C2 > 0) {
8317
+ const b2 = T.splice(0, C2);
8318
+ o && (h2.full += (h2.full === "" ? "" : `
8319
+ `) + b2.join(`
8320
+ `));
8321
+ }
8322
+ h2.value = T.join(`
8323
+ `);
8324
+ }
8325
+ c2 && g();
8326
+ }, g = () => {
8327
+ for (const h2 of a) h2.result ? h2.result.status === "error" ? R2.error(h2.result.message, { output: r, secondarySymbol: i, spacing: 0 }) : R2.success(h2.result.message, { output: r, secondarySymbol: i, spacing: 0 }) : h2.value !== "" && y(h2, 0);
8328
+ }, S2 = (h2, f) => {
8329
+ d2(false), h2.result = f, c2 && g();
8330
+ };
8331
+ return { message(h2, f) {
8332
+ m(a[0], h2, f);
8333
+ }, group(h2) {
8334
+ const f = { header: h2, value: "", full: "" };
8335
+ return a.push(f), { message(v2, T) {
8336
+ m(f, v2, T);
8337
+ }, error(v2) {
8338
+ S2(f, { status: "error", message: v2 });
8339
+ }, success(v2) {
8340
+ S2(f, { status: "success", message: v2 });
8341
+ } };
8342
+ }, error(h2, f) {
8343
+ d2(true), R2.error(h2, { output: r, secondarySymbol: i, spacing: 1 }), f?.showLog !== false && p2(), a.splice(1, a.length - 1), a[0].value = "", a[0].full = "";
8344
+ }, success(h2, f) {
8345
+ d2(true), R2.success(h2, { output: r, secondarySymbol: i, spacing: 1 }), f?.showLog === true && p2(), a.splice(1, a.length - 1), a[0].value = "", a[0].full = "";
8346
+ } };
8347
+ };
7377
8348
  Re = (t) => new ht({ validate: t.validate, placeholder: t.placeholder, defaultValue: t.defaultValue, initialValue: t.initialValue, output: t.output, signal: t.signal, input: t.input, render() {
7378
- const r = t?.withGuide ?? h.withGuide, s = `${`${r ? `${styleText("gray", $)}
8349
+ const r = t?.withGuide ?? h.withGuide, s = `${`${r ? `${styleText("gray", $2)}
7379
8350
  ` : ""}${M(this.state)} `}${t.message}
7380
8351
  `, i = t.placeholder ? styleText("inverse", t.placeholder[0]) + styleText("dim", t.placeholder.slice(1)) : styleText(["inverse", "hidden"], "_"), u = this.userInput ? this.userInputWithCursor : i, n = this.value ?? "";
7381
8352
  switch (this.state) {
7382
8353
  case "error": {
7383
- const o = this.error ? ` ${styleText("yellow", this.error)}` : "", c2 = r ? `${styleText("yellow", $)} ` : "", a = r ? styleText("yellow", E2) : "";
8354
+ const o = this.error ? ` ${styleText("yellow", this.error)}` : "", c2 = r ? `${styleText("yellow", $2)} ` : "", a = r ? styleText("yellow", E2) : "";
7384
8355
  return `${s.trim()}
7385
8356
  ${c2}${u}
7386
8357
  ${a}${o}
7387
8358
  `;
7388
8359
  }
7389
8360
  case "submit": {
7390
- const o = n ? ` ${styleText("dim", n)}` : "", c2 = r ? styleText("gray", $) : "";
8361
+ const o = n ? ` ${styleText("dim", n)}` : "", c2 = r ? styleText("gray", $2) : "";
7391
8362
  return `${s}${c2}${o}`;
7392
8363
  }
7393
8364
  case "cancel": {
7394
- const o = n ? ` ${styleText(["strikethrough", "dim"], n)}` : "", c2 = r ? styleText("gray", $) : "";
8365
+ const o = n ? ` ${styleText(["strikethrough", "dim"], n)}` : "", c2 = r ? styleText("gray", $2) : "";
7395
8366
  return `${s}${c2}${o}${n.trim() ? `
7396
8367
  ${c2}` : ""}`;
7397
8368
  }
7398
8369
  default: {
7399
- const o = r ? `${styleText("cyan", $)} ` : "", c2 = r ? styleText("cyan", E2) : "";
8370
+ const o = r ? `${styleText("cyan", $2)} ` : "", c2 = r ? styleText("cyan", E2) : "";
7400
8371
  return `${s}${o}${u}
7401
8372
  ${c2}
7402
8373
  `;
@@ -7406,7 +8377,7 @@ ${c2}
7406
8377
  }
7407
8378
  });
7408
8379
 
7409
- // src/init/scriptWrap.ts
8380
+ // src/init/script-wrap.ts
7410
8381
  function analyzeScript(name, command) {
7411
8382
  const trimmed = command.trim();
7412
8383
  if (trimmed.startsWith("keynv ") || trimmed.startsWith("keynv ")) {
@@ -7511,8 +8482,8 @@ function applyWraps(original, selectedScriptNames) {
7511
8482
  return out;
7512
8483
  }
7513
8484
  var KEYNV_PREFIX, ENV_AWARE_TOOLS, NON_ENV_TOOLS;
7514
- var init_scriptWrap = __esm({
7515
- "src/init/scriptWrap.ts"() {
8485
+ var init_script_wrap = __esm({
8486
+ "src/init/script-wrap.ts"() {
7516
8487
  KEYNV_PREFIX = "keynv exec --";
7517
8488
  ENV_AWARE_TOOLS = /* @__PURE__ */ new Set([
7518
8489
  "node",
@@ -7797,7 +8768,7 @@ ${detail}`
7797
8768
  method: "POST",
7798
8769
  body: { env: env2, key: aliasKey, value: e2.value }
7799
8770
  });
7800
- const alias2 = buildAlias({
8771
+ const alias2 = reference_exports.buildAlias({
7801
8772
  project: projectChoice.name,
7802
8773
  environment: env2,
7803
8774
  key: aliasKey
@@ -8138,10 +9109,10 @@ var init_init = __esm({
8138
9109
  init_dist5();
8139
9110
  init_dist();
8140
9111
  init_envFile();
8141
- init_aiContext();
9112
+ init_ai_context();
8142
9113
  init_detect();
8143
9114
  init_heuristics();
8144
- init_scriptWrap();
9115
+ init_script_wrap();
8145
9116
  init_cancel();
8146
9117
  init_pickProject();
8147
9118
  }
@@ -8172,7 +9143,16 @@ async function errorMessage(res, fallback) {
8172
9143
  return fallback;
8173
9144
  }
8174
9145
  }
9146
+ function isSafeUrl(urlStr) {
9147
+ try {
9148
+ const parsed = new URL(urlStr);
9149
+ return parsed.protocol === "https:" || parsed.protocol === "http:";
9150
+ } catch {
9151
+ return false;
9152
+ }
9153
+ }
8175
9154
  function openBrowser(url) {
9155
+ if (!isSafeUrl(url)) return false;
8176
9156
  try {
8177
9157
  const os = platform();
8178
9158
  const command = os === "win32" ? "cmd" : os === "darwin" ? "open" : "xdg-open";
@@ -8358,7 +9338,7 @@ async function runSecretMenu(client, project, alias2) {
8358
9338
  ]
8359
9339
  })
8360
9340
  );
8361
- const parsed = parseAlias(alias2);
9341
+ const parsed = reference_exports.parseAlias(alias2);
8362
9342
  if (!parsed) {
8363
9343
  R2.warn(`unparseable alias: ${alias2}`);
8364
9344
  return;
@@ -8442,14 +9422,14 @@ async function promptNewSecret(client, project) {
8442
9422
  }
8443
9423
  }
8444
9424
  );
8445
- const built = buildAlias({ project: target.name, environment: env2, key: answers.key });
9425
+ const built = reference_exports.buildAlias({ project: target.name, environment: env2, key: answers.key });
8446
9426
  if (!built) return null;
8447
9427
  return { alias: built.literal, value: answers.value };
8448
9428
  }
8449
9429
  async function createSecretInteractive(client, project) {
8450
9430
  const built = await promptNewSecret(client, project);
8451
9431
  if (!built) return;
8452
- const parsed = parseAlias(built.alias);
9432
+ const parsed = reference_exports.parseAlias(built.alias);
8453
9433
  if (!parsed) {
8454
9434
  R2.warn("Invalid alias produced by form; aborting.");
8455
9435
  return;
@@ -14292,8 +15272,8 @@ var require_umd = __commonJS({
14292
15272
  if (this.unsigned) return this;
14293
15273
  return fromBits(this.low, this.high, true);
14294
15274
  };
14295
- LongPrototype.toBytes = function toBytes(le) {
14296
- return le ? this.toBytesLE() : this.toBytesBE();
15275
+ LongPrototype.toBytes = function toBytes(le2) {
15276
+ return le2 ? this.toBytesLE() : this.toBytesBE();
14297
15277
  };
14298
15278
  LongPrototype.toBytesLE = function toBytesLE() {
14299
15279
  var hi = this.high, lo = this.low;
@@ -14321,8 +15301,8 @@ var require_umd = __commonJS({
14321
15301
  lo & 255
14322
15302
  ];
14323
15303
  };
14324
- Long.fromBytes = function fromBytes(bytes, unsigned, le) {
14325
- return le ? Long.fromBytesLE(bytes, unsigned) : Long.fromBytesBE(bytes, unsigned);
15304
+ Long.fromBytes = function fromBytes(bytes, unsigned, le2) {
15305
+ return le2 ? Long.fromBytesLE(bytes, unsigned) : Long.fromBytesBE(bytes, unsigned);
14326
15306
  };
14327
15307
  Long.fromBytesLE = function fromBytesLE(bytes, unsigned) {
14328
15308
  return new Long(
@@ -18458,7 +19438,7 @@ var require_packet = __commonJS({
18458
19438
  let y = 0;
18459
19439
  let m = 0;
18460
19440
  let d2 = 0;
18461
- let H2 = 0;
19441
+ let H3 = 0;
18462
19442
  let M2 = 0;
18463
19443
  let S2 = 0;
18464
19444
  let ms = 0;
@@ -18468,20 +19448,20 @@ var require_packet = __commonJS({
18468
19448
  d2 = this.readInt8();
18469
19449
  }
18470
19450
  if (length > 6) {
18471
- H2 = this.readInt8();
19451
+ H3 = this.readInt8();
18472
19452
  M2 = this.readInt8();
18473
19453
  S2 = this.readInt8();
18474
19454
  }
18475
19455
  if (length > 10) {
18476
19456
  ms = this.readInt32() / 1e3;
18477
19457
  }
18478
- if (y + m + d2 + H2 + M2 + S2 + ms === 0) {
19458
+ if (y + m + d2 + H3 + M2 + S2 + ms === 0) {
18479
19459
  return INVALID_DATE;
18480
19460
  }
18481
19461
  if (timezone === "Z") {
18482
- return new Date(Date.UTC(y, m - 1, d2, H2, M2, S2, ms));
19462
+ return new Date(Date.UTC(y, m - 1, d2, H3, M2, S2, ms));
18483
19463
  }
18484
- return new Date(y, m - 1, d2, H2, M2, S2, ms);
19464
+ return new Date(y, m - 1, d2, H3, M2, S2, ms);
18485
19465
  }
18486
19466
  let str = this.readDateTimeString(6, "T", null);
18487
19467
  if (!str) {
@@ -18497,7 +19477,7 @@ var require_packet = __commonJS({
18497
19477
  let y = 0;
18498
19478
  let m = 0;
18499
19479
  let d2 = 0;
18500
- let H2 = 0;
19480
+ let H3 = 0;
18501
19481
  let M2 = 0;
18502
19482
  let S2 = 0;
18503
19483
  let ms = 0;
@@ -18509,11 +19489,11 @@ var require_packet = __commonJS({
18509
19489
  str = [leftPad(4, y), leftPad(2, m), leftPad(2, d2)].join("-");
18510
19490
  }
18511
19491
  if (length > 6) {
18512
- H2 = this.readInt8();
19492
+ H3 = this.readInt8();
18513
19493
  M2 = this.readInt8();
18514
19494
  S2 = this.readInt8();
18515
19495
  str += `${timeSep || " "}${[
18516
- leftPad(2, H2),
19496
+ leftPad(2, H3),
18517
19497
  leftPad(2, M2),
18518
19498
  leftPad(2, S2)
18519
19499
  ].join(":")}`;
@@ -18541,13 +19521,13 @@ var require_packet = __commonJS({
18541
19521
  }
18542
19522
  const sign = this.readInt8() ? -1 : 1;
18543
19523
  let d2 = 0;
18544
- let H2 = 0;
19524
+ let H3 = 0;
18545
19525
  let M2 = 0;
18546
19526
  let S2 = 0;
18547
19527
  let ms = 0;
18548
19528
  if (length > 6) {
18549
19529
  d2 = this.readInt32();
18550
- H2 = this.readInt8();
19530
+ H3 = this.readInt8();
18551
19531
  M2 = this.readInt8();
18552
19532
  S2 = this.readInt8();
18553
19533
  }
@@ -18555,14 +19535,14 @@ var require_packet = __commonJS({
18555
19535
  ms = this.readInt32();
18556
19536
  }
18557
19537
  if (convertTtoMs) {
18558
- H2 += d2 * 24;
18559
- M2 += H2 * 60;
19538
+ H3 += d2 * 24;
19539
+ M2 += H3 * 60;
18560
19540
  S2 += M2 * 60;
18561
19541
  ms += S2 * 1e3;
18562
19542
  ms *= sign;
18563
19543
  return ms;
18564
19544
  }
18565
- return (sign === -1 ? "-" : "") + [leftPad(2, d2 * 24 + H2), leftPad(2, M2), leftPad(2, S2)].join(":") + (ms ? `.${ms}`.replace(/0+$/, "") : "");
19545
+ return (sign === -1 ? "-" : "") + [leftPad(2, d2 * 24 + H3), leftPad(2, M2), leftPad(2, S2)].join(":") + (ms ? `.${ms}`.replace(/0+$/, "") : "");
18566
19546
  }
18567
19547
  readLengthCodedString(encoding) {
18568
19548
  const len = this.readLengthCodedNumber();
@@ -18700,7 +19680,7 @@ var require_packet = __commonJS({
18700
19680
  }
18701
19681
  const bufferLength = buffer.length;
18702
19682
  function parseGeometry() {
18703
- let x, y, i, j3, numPoints, numRings, num, line;
19683
+ let x2, y, i, j3, numPoints, numRings, num, line;
18704
19684
  let result = null;
18705
19685
  if (offset + 5 > bufferLength) {
18706
19686
  return null;
@@ -18714,11 +19694,11 @@ var require_packet = __commonJS({
18714
19694
  if (offset + 16 > bufferLength) {
18715
19695
  return null;
18716
19696
  }
18717
- x = byteOrder ? buffer.readDoubleLE(offset) : buffer.readDoubleBE(offset);
19697
+ x2 = byteOrder ? buffer.readDoubleLE(offset) : buffer.readDoubleBE(offset);
18718
19698
  offset += 8;
18719
19699
  y = byteOrder ? buffer.readDoubleLE(offset) : buffer.readDoubleBE(offset);
18720
19700
  offset += 8;
18721
- result = { x, y };
19701
+ result = { x: x2, y };
18722
19702
  break;
18723
19703
  case 2:
18724
19704
  if (offset + 4 > bufferLength) {
@@ -18734,11 +19714,11 @@ var require_packet = __commonJS({
18734
19714
  if (offset + 16 > bufferLength) {
18735
19715
  break;
18736
19716
  }
18737
- x = byteOrder ? buffer.readDoubleLE(offset) : buffer.readDoubleBE(offset);
19717
+ x2 = byteOrder ? buffer.readDoubleLE(offset) : buffer.readDoubleBE(offset);
18738
19718
  offset += 8;
18739
19719
  y = byteOrder ? buffer.readDoubleLE(offset) : buffer.readDoubleBE(offset);
18740
19720
  offset += 8;
18741
- result.push({ x, y });
19721
+ result.push({ x: x2, y });
18742
19722
  }
18743
19723
  break;
18744
19724
  case 3:
@@ -18762,11 +19742,11 @@ var require_packet = __commonJS({
18762
19742
  if (offset + 16 > bufferLength) {
18763
19743
  break;
18764
19744
  }
18765
- x = byteOrder ? buffer.readDoubleLE(offset) : buffer.readDoubleBE(offset);
19745
+ x2 = byteOrder ? buffer.readDoubleLE(offset) : buffer.readDoubleBE(offset);
18766
19746
  offset += 8;
18767
19747
  y = byteOrder ? buffer.readDoubleLE(offset) : buffer.readDoubleBE(offset);
18768
19748
  offset += 8;
18769
- line.push({ x, y });
19749
+ line.push({ x: x2, y });
18770
19750
  }
18771
19751
  result.push(line);
18772
19752
  }
@@ -31107,28 +32087,28 @@ var require_helper = __commonJS({
31107
32087
  var isValidEntry = module.exports.isValidEntry = function(entry2) {
31108
32088
  var rules = {
31109
32089
  // host
31110
- 0: function(x) {
31111
- return x.length > 0;
32090
+ 0: function(x2) {
32091
+ return x2.length > 0;
31112
32092
  },
31113
32093
  // port
31114
- 1: function(x) {
31115
- if (x === "*") {
32094
+ 1: function(x2) {
32095
+ if (x2 === "*") {
31116
32096
  return true;
31117
32097
  }
31118
- x = Number(x);
31119
- return isFinite(x) && x > 0 && x < 9007199254740992 && Math.floor(x) === x;
32098
+ x2 = Number(x2);
32099
+ return isFinite(x2) && x2 > 0 && x2 < 9007199254740992 && Math.floor(x2) === x2;
31120
32100
  },
31121
32101
  // database
31122
- 2: function(x) {
31123
- return x.length > 0;
32102
+ 2: function(x2) {
32103
+ return x2.length > 0;
31124
32104
  },
31125
32105
  // username
31126
- 3: function(x) {
31127
- return x.length > 0;
32106
+ 3: function(x2) {
32107
+ return x2.length > 0;
31128
32108
  },
31129
32109
  // password
31130
- 4: function(x) {
31131
- return x.length > 0;
32110
+ 4: function(x2) {
32111
+ return x2.length > 0;
31132
32112
  }
31133
32113
  };
31134
32114
  for (var idx = 0; idx < fieldNames.length; idx += 1) {
@@ -31156,8 +32136,8 @@ var require_lib6 = __commonJS({
31156
32136
  if (err || !helper.usePgPass(stat, file)) {
31157
32137
  return cb(void 0);
31158
32138
  }
31159
- var st2 = fs.createReadStream(file);
31160
- helper.getPassword(connInfo, st2, cb);
32139
+ var st3 = fs.createReadStream(file);
32140
+ helper.getPassword(connInfo, st3, cb);
31161
32141
  });
31162
32142
  };
31163
32143
  module.exports.warnTo = helper.warnTo;
@@ -37188,8 +38168,8 @@ var require_utils4 = __commonJS({
37188
38168
  }
37189
38169
  exports.wrapMultiResult = wrapMultiResult;
37190
38170
  function isInt(value) {
37191
- const x = parseFloat(value);
37192
- return !isNaN(value) && (x | 0) === x;
38171
+ const x2 = parseFloat(value);
38172
+ return !isNaN(value) && (x2 | 0) === x2;
37193
38173
  }
37194
38174
  exports.isInt = isInt;
37195
38175
  function packObject(array) {
@@ -37798,9 +38778,9 @@ var require_Command = __commonJS({
37798
38778
  this.length = 0;
37799
38779
  this.items = [];
37800
38780
  }
37801
- push(x) {
37802
- this.length += Buffer.byteLength(x);
37803
- this.items.push(x);
38781
+ push(x2) {
38782
+ this.length += Buffer.byteLength(x2);
38783
+ this.items.push(x2);
37804
38784
  }
37805
38785
  toBuffer() {
37806
38786
  const result = Buffer.allocUnsafe(this.length);
@@ -44033,11 +45013,11 @@ function formatMarkdownish(text, { format, paragraphs }) {
44033
45013
 
44034
45014
  `);
44035
45015
  }
44036
- text = text.replace(/(`+)((?:.|[\n])*?)\1/g, ($0, $1, $2) => {
44037
- return format.code($1 + $2 + $1);
45016
+ text = text.replace(/(`+)((?:.|[\n])*?)\1/g, ($0, $1, $22) => {
45017
+ return format.code($1 + $22 + $1);
44038
45018
  });
44039
- text = text.replace(/(\*\*)((?:.|[\n])*?)\1/g, ($0, $1, $2) => {
44040
- return format.bold($1 + $2 + $1);
45019
+ text = text.replace(/(\*\*)((?:.|[\n])*?)\1/g, ($0, $1, $22) => {
45020
+ return format.bold($1 + $22 + $1);
44041
45021
  });
44042
45022
  return text ? `${text}
44043
45023
  ` : ``;
@@ -44826,15 +45806,15 @@ init_envFile();
44826
45806
  init_dist();
44827
45807
  async function resolveAllAliases(client, argv2, extraStrings = []) {
44828
45808
  const seen = /* @__PURE__ */ new Map();
44829
- const argvScans = findAliasesInArgv(argv2);
45809
+ const argvScans = reference_exports.findAliasesInArgv(argv2);
44830
45810
  for (const { matches } of argvScans) {
44831
45811
  for (const m of matches) {
44832
45812
  seen.set(m.literal, m);
44833
45813
  }
44834
45814
  }
44835
45815
  for (const s of extraStrings) {
44836
- for (const m of findAliasesInArgv([s])) {
44837
- for (const x of m.matches) seen.set(x.literal, x);
45816
+ for (const m of reference_exports.findAliasesInArgv([s])) {
45817
+ for (const x2 of m.matches) seen.set(x2.literal, x2);
44838
45818
  }
44839
45819
  }
44840
45820
  if (seen.size === 0) return [];
@@ -44926,10 +45906,18 @@ var BUILTIN_PATTERNS = [
44926
45906
  name: "stripe-live-secret-key",
44927
45907
  regex: /\bsk_live_[A-Za-z0-9]{24,}\b/g
44928
45908
  },
45909
+ {
45910
+ name: "stripe-test-secret-key",
45911
+ regex: /\bsk_test_[A-Za-z0-9]{24,}\b/g
45912
+ },
44929
45913
  {
44930
45914
  name: "stripe-restricted-live-key",
44931
45915
  regex: /\brk_live_[A-Za-z0-9]{24,}\b/g
44932
45916
  },
45917
+ {
45918
+ name: "stripe-restricted-test-key",
45919
+ regex: /\brk_test_[A-Za-z0-9]{24,}\b/g
45920
+ },
44933
45921
  {
44934
45922
  // Negative lookahead skips Anthropic-prefixed keys so the more
44935
45923
  // specific anthropic-api-key pattern wins on those.
@@ -45025,7 +46013,9 @@ function defaultRender(name) {
45025
46013
  return `<REDACTED:${name}>`;
45026
46014
  }
45027
46015
  function preview(matched) {
45028
- return matched.length <= 8 ? matched : `${matched.slice(0, 4)}...`;
46016
+ if (matched.length <= 4)
46017
+ return "****";
46018
+ return `${matched.slice(0, 4)}...`;
45029
46019
  }
45030
46020
  function escapeRegExp(s) {
45031
46021
  return s.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
@@ -45056,8 +46046,8 @@ function redact(text, opts = {}) {
45056
46046
  for (const literal of opts.literals) {
45057
46047
  if (!literal)
45058
46048
  continue;
45059
- const re = new RegExp(escapeRegExp(literal), "g");
45060
- for (const m of text.matchAll(re)) {
46049
+ const re2 = new RegExp(escapeRegExp(literal), "g");
46050
+ for (const m of text.matchAll(re2)) {
45061
46051
  if (m.index === void 0)
45062
46052
  continue;
45063
46053
  raw.push({
@@ -45482,13 +46472,14 @@ spelled \`--from\` to avoid the collision.)
45482
46472
  const displayPath = relative(process.cwd(), envFileLoaded.path) || envFileLoaded.path;
45483
46473
  const parts = [];
45484
46474
  if (aliasEntries.length > 0) {
45485
- parts.push(aliasEntries.map((e2) => `${e2.name}=${e2.value}`).join(", ") + " (vault)");
46475
+ parts.push(`${aliasEntries.map((e2) => `${e2.name}=${e2.value}`).join(", ")} (vault)`);
45486
46476
  }
45487
46477
  if (plainEntries.length > 0) {
45488
- parts.push(plainEntries.map((e2) => e2.name).join(", ") + " (plain)");
46478
+ parts.push(`${plainEntries.map((e2) => e2.name).join(", ")} (plain)`);
45489
46479
  }
45490
46480
  this.context.stderr.write(
45491
- `keynv: loaded ${displayPath}` + (parts.length > 0 ? ` \u2014 ${parts.join("; ")}` : "") + "\n"
46481
+ `keynv: loaded ${displayPath}${parts.length > 0 ? ` \u2014 ${parts.join("; ")}` : ""}
46482
+ `
45492
46483
  );
45493
46484
  }
45494
46485
  const timeoutS = this.timeout ? Number.parseInt(this.timeout, 10) : void 0;
@@ -45531,9 +46522,9 @@ function signalNumber(sig) {
45531
46522
  init_dist();
45532
46523
  init_http();
45533
46524
  init_envFile();
46525
+ init_ai_context();
45534
46526
  init_detect();
45535
46527
  init_heuristics();
45536
- init_aiContext();
45537
46528
  init_init();
45538
46529
  init_cancel();
45539
46530
  init_tty();
@@ -45718,10 +46709,7 @@ any prompts.
45718
46709
  ["Preview without writing or uploading", "$0 init --dry-run"],
45719
46710
  ["Skip the package.json script-wrapping step", "$0 init --no-scripts"],
45720
46711
  ["Non-interactive (CI/CD)", "$0 init --env-file .env --project myproject --env dev"],
45721
- [
45722
- "Auto-scan & set up without prompts (CI/CD)",
45723
- "$0 init --yes"
45724
- ]
46712
+ ["Auto-scan & set up without prompts (CI/CD)", "$0 init --yes"]
45725
46713
  ]
45726
46714
  });
45727
46715
  dryRun = options_exports.Boolean("--dry-run", false, {
@@ -45860,9 +46848,7 @@ any prompts.
45860
46848
  async runAutoScan(client) {
45861
46849
  const root = findProjectRoot(process.cwd());
45862
46850
  if (!root) {
45863
- this.context.stderr.write(
45864
- "keynv: no project root found (no package.json, .git, etc.).\n"
45865
- );
46851
+ this.context.stderr.write("keynv: no project root found (no package.json, .git, etc.).\n");
45866
46852
  return 1;
45867
46853
  }
45868
46854
  const envFiles = findEnvFiles(root.path);
@@ -45908,14 +46894,23 @@ any prompts.
45908
46894
  } catch {
45909
46895
  const created = await client.request("/v1/projects", {
45910
46896
  method: "POST",
45911
- body: { name: projectName, environments: [{ name: envName, tier: "non-production", require_approval: false }] }
46897
+ body: {
46898
+ name: projectName,
46899
+ environments: [{ name: envName, tier: "non-production", require_approval: false }]
46900
+ }
45912
46901
  });
45913
46902
  projectId2 = created.id;
45914
46903
  this.context.stdout.write(`keynv: created project "${projectName}" (${projectId2}).
45915
46904
  `);
45916
46905
  }
45917
46906
  const secretsWithKeys = secrets.map((s) => ({ ...s, aliasKey: toAliasKey2(s.name) }));
45918
- const result = await this.uploadSecrets(client, projectId2, projectName, envName, secretsWithKeys);
46907
+ const result = await this.uploadSecrets(
46908
+ client,
46909
+ projectId2,
46910
+ projectName,
46911
+ envName,
46912
+ secretsWithKeys
46913
+ );
45919
46914
  if (result !== 0) return result;
45920
46915
  const aliasLines = secretsWithKeys.map((s) => `# ${s.name}
45921
46916
  ${s.name}=@${projectName}.${envName}.${s.aliasKey}`).join("\n");
@@ -45936,7 +46931,9 @@ ${aliasLines}
45936
46931
  this.context.stdout.write(`keynv: removed ${f.name} (secrets migrated to vault).
45937
46932
  `);
45938
46933
  }
45939
- this.context.stdout.write("keynv: done. Use `keynv exec` to run commands with resolved secrets.\n");
46934
+ this.context.stdout.write(
46935
+ "keynv: done. Use `keynv exec` to run commands with resolved secrets.\n"
46936
+ );
45940
46937
  return 0;
45941
46938
  }
45942
46939
  /**
@@ -45947,7 +46944,11 @@ ${aliasLines}
45947
46944
  let uploaded = 0;
45948
46945
  const failed = [];
45949
46946
  for (const s of secrets) {
45950
- const alias2 = buildAlias({ project: projectName, environment: envName, key: s.aliasKey });
46947
+ const alias2 = reference_exports.buildAlias({
46948
+ project: projectName,
46949
+ environment: envName,
46950
+ key: s.aliasKey
46951
+ });
45951
46952
  if (!alias2) {
45952
46953
  failed.push({ name: s.name, reason: `invalid alias key: ${s.aliasKey}` });
45953
46954
  continue;
@@ -46048,7 +47049,7 @@ var LoginCommand = class extends Command {
46048
47049
  token = options_exports.String("--token", { description: "CLI token for headless auth." });
46049
47050
  email = options_exports.String("--email", { description: "Email address." });
46050
47051
  password = options_exports.String("--password", {
46051
- description: "Password (use stdin to avoid argv leak)."
47052
+ description: "Password. WARNING: passing passwords via --password leaks them to process listings (ps). Use interactive prompt or pipe via stdin instead."
46052
47053
  });
46053
47054
  async execute() {
46054
47055
  const finalServerUrl = this.server ?? DEFAULT_SERVER_URL;
@@ -46080,7 +47081,15 @@ var LoginCommand = class extends Command {
46080
47081
  }
46081
47082
  }
46082
47083
  const email2 = this.email ?? await promptLine("email: ");
46083
- const password = this.password ?? await promptHidden("password: ");
47084
+ let password;
47085
+ if (this.password) {
47086
+ this.context.stderr.write(
47087
+ "keynv: WARNING: --password leaks credentials to process listings. Use interactive prompt or pipe via stdin instead.\n"
47088
+ );
47089
+ password = this.password;
47090
+ } else {
47091
+ password = await promptHidden("password: ");
47092
+ }
46084
47093
  let res;
46085
47094
  try {
46086
47095
  res = await fetch(new URL("/v1/auth/login", finalServerUrl).toString(), {
@@ -46471,7 +47480,7 @@ var SecretCreateCommand = class extends Command {
46471
47480
  throw err;
46472
47481
  }
46473
47482
  }
46474
- const parsed = parseAlias(alias2);
47483
+ const parsed = reference_exports.parseAlias(alias2);
46475
47484
  if (!parsed) {
46476
47485
  this.context.stderr.write(`keynv: invalid alias '${alias2}'.
46477
47486
  ${ALIAS_FORMAT_HINT}
@@ -46525,7 +47534,7 @@ var SecretGetCommand = class extends Command {
46525
47534
  }
46526
47535
  if (!alias2) return 1;
46527
47536
  }
46528
- const parsed = parseAlias(alias2);
47537
+ const parsed = reference_exports.parseAlias(alias2);
46529
47538
  if (!parsed) {
46530
47539
  this.context.stderr.write(`keynv: invalid alias '${alias2}'.
46531
47540
  ${ALIAS_FORMAT_HINT}
@@ -46579,7 +47588,7 @@ var SecretListCommand = class extends Command {
46579
47588
  }
46580
47589
  let resolvedProjectName = projectName;
46581
47590
  if (projectName.startsWith("@")) {
46582
- const parsed = parseAlias(projectName);
47591
+ const parsed = reference_exports.parseAlias(projectName);
46583
47592
  if (parsed) {
46584
47593
  resolvedProjectName = parsed.project;
46585
47594
  } else {
@@ -46631,7 +47640,7 @@ var SecretRotateCommand = class extends Command {
46631
47640
  }
46632
47641
  if (!alias2) return 1;
46633
47642
  }
46634
- const parsed = parseAlias(alias2);
47643
+ const parsed = reference_exports.parseAlias(alias2);
46635
47644
  if (!parsed) {
46636
47645
  this.context.stderr.write(`keynv: invalid alias '${alias2}'.
46637
47646
  ${ALIAS_FORMAT_HINT}
@@ -46667,6 +47676,7 @@ var SecretDeleteCommand = class extends Command {
46667
47676
  static paths = [["secret", "delete"]];
46668
47677
  static usage = Command.Usage({ description: "Soft-delete a secret." });
46669
47678
  alias = options_exports.String({ required: false });
47679
+ force = options_exports.Boolean("--force", false);
46670
47680
  async execute() {
46671
47681
  try {
46672
47682
  const client = new ApiClient();
@@ -46682,13 +47692,28 @@ var SecretDeleteCommand = class extends Command {
46682
47692
  }
46683
47693
  if (!alias2) return 1;
46684
47694
  }
46685
- const parsed = parseAlias(alias2);
47695
+ const parsed = reference_exports.parseAlias(alias2);
46686
47696
  if (!parsed) {
46687
47697
  this.context.stderr.write(`keynv: invalid alias '${alias2}'.
46688
47698
  ${ALIAS_FORMAT_HINT}
46689
47699
  `);
46690
47700
  return 1;
46691
47701
  }
47702
+ if (!this.force) {
47703
+ if (isInteractive()) {
47704
+ const { confirm } = await Promise.resolve().then(() => (init_dist5(), dist_exports));
47705
+ const ok = await confirm({
47706
+ message: `Delete secret ${parsed.literal}?`
47707
+ });
47708
+ if (!ok) {
47709
+ this.context.stderr.write("Cancelled.\n");
47710
+ return 130;
47711
+ }
47712
+ } else {
47713
+ this.context.stderr.write("keynv: refusing to delete without --force\n");
47714
+ return 2;
47715
+ }
47716
+ }
46692
47717
  const projectId2 = await resolveProjectId(client, parsed.project);
46693
47718
  await client.request(
46694
47719
  `/v1/projects/${projectId2}/secrets/${parsed.environment}/${parsed.key}`,
@@ -46765,7 +47790,7 @@ Non-interactive with --yes to skip prompts.
46765
47790
  ].join("\n");
46766
47791
  const { writeFileSync: writeFileSync5 } = await import('fs');
46767
47792
  writeFileSync5(outPath, `${contents}
46768
- `);
47793
+ `, { mode: 384 });
46769
47794
  this.context.stdout.write(`Wrote ${outPath}
46770
47795
 
46771
47796
  `);
@@ -46830,7 +47855,7 @@ services:
46830
47855
  volumes:
46831
47856
  keynv-data:
46832
47857
  `;
46833
- writeFileSync5("docker-compose.yml", composeContent);
47858
+ writeFileSync5("docker-compose.yml", composeContent, { mode: 384 });
46834
47859
  this.context.stdout.write(
46835
47860
  "\nWrote docker-compose.yml (update Litestream S3 config before deploying).\n"
46836
47861
  );
@@ -46844,6 +47869,60 @@ init_dist();
46844
47869
 
46845
47870
  // ../../packages/testers/dist/http.js
46846
47871
  init_zod();
47872
+
47873
+ // ../../packages/testers/dist/ssrf.js
47874
+ var PRIVATE_CIDRS = [
47875
+ /^0\./,
47876
+ /^10\./,
47877
+ /^127\./,
47878
+ /^169\.254\./,
47879
+ /^172\.(1[6-9]|2\d|3[01])\./,
47880
+ /^192\.0[0-2]\./,
47881
+ /^192\.168\./,
47882
+ /^198\.51\.100\./,
47883
+ /^203\.0\.113\./,
47884
+ /^224\./,
47885
+ /^240\./
47886
+ ];
47887
+ var BLOCKED_HOSTNAMES = /* @__PURE__ */ new Set([
47888
+ "localhost",
47889
+ "metadata.google.internal",
47890
+ "metadata.internal",
47891
+ "instance-data"
47892
+ ]);
47893
+ function isLoopbackAllowed() {
47894
+ return !!process.env["KEYNV_ALLOW_LOOPBACK_TESTERS"];
47895
+ }
47896
+ function isBlockedHost(host) {
47897
+ const lower = host.toLowerCase();
47898
+ if (BLOCKED_HOSTNAMES.has(lower)) {
47899
+ if (isLoopbackAllowed() && lower === "localhost")
47900
+ return false;
47901
+ return true;
47902
+ }
47903
+ if (lower === "0.0.0.0" || lower === "[::]" || lower === "[::1]")
47904
+ return !isLoopbackAllowed();
47905
+ for (const re2 of PRIVATE_CIDRS) {
47906
+ if (re2.test(lower)) {
47907
+ if (isLoopbackAllowed() && /^127\./.test(lower))
47908
+ return false;
47909
+ return true;
47910
+ }
47911
+ }
47912
+ return false;
47913
+ }
47914
+ function isBlockedUrl(urlStr) {
47915
+ try {
47916
+ const parsed = new URL(urlStr);
47917
+ if (parsed.protocol !== "http:" && parsed.protocol !== "https:")
47918
+ return true;
47919
+ return isBlockedHost(parsed.hostname);
47920
+ } catch {
47921
+ return true;
47922
+ }
47923
+ }
47924
+
47925
+ // ../../packages/testers/dist/http.js
46847
47926
  var Target = external_exports.object({
46848
47927
  url: external_exports.string().url(),
46849
47928
  method: external_exports.enum(["GET", "POST", "HEAD"]).default("GET"),
@@ -46862,6 +47941,13 @@ var httpTester = {
46862
47941
  type: "http",
46863
47942
  schema: Target,
46864
47943
  async test(secret, target) {
47944
+ if (isBlockedUrl(target.url)) {
47945
+ return {
47946
+ ok: false,
47947
+ latency_ms: 0,
47948
+ error: "Target URL is blocked (private/internal IP or metadata endpoint)."
47949
+ };
47950
+ }
46865
47951
  const start = Date.now();
46866
47952
  const headers = {};
46867
47953
  switch (target.auth) {
@@ -46915,12 +48001,20 @@ var Target2 = external_exports.object({
46915
48001
  host: external_exports.string().min(1),
46916
48002
  port: external_exports.coerce.number().int().min(1).max(65535).default(3306),
46917
48003
  database: external_exports.string().min(1).optional(),
46918
- user: external_exports.string().min(1)
48004
+ user: external_exports.string().min(1),
48005
+ ssl: external_exports.coerce.boolean().optional()
46919
48006
  });
46920
48007
  var mysqlTester = {
46921
48008
  type: "mysql",
46922
48009
  schema: Target2,
46923
48010
  async test(secret, target) {
48011
+ if (isBlockedHost(target.host)) {
48012
+ return {
48013
+ ok: false,
48014
+ latency_ms: 0,
48015
+ error: "Target host is blocked (private/internal IP or metadata endpoint)."
48016
+ };
48017
+ }
46924
48018
  const start = Date.now();
46925
48019
  const mysql = await Promise.resolve().then(() => __toESM(require_promise()));
46926
48020
  const conn = await mysql.createConnection({
@@ -46929,6 +48023,7 @@ var mysqlTester = {
46929
48023
  ...target.database ? { database: target.database } : {},
46930
48024
  user: target.user,
46931
48025
  password: secret.value,
48026
+ ...target.ssl !== false ? { ssl: {} } : {},
46932
48027
  connectTimeout: 5e3
46933
48028
  }).catch((err) => {
46934
48029
  return {
@@ -46968,6 +48063,13 @@ var postgresTester = {
46968
48063
  type: "postgres",
46969
48064
  schema: Target3,
46970
48065
  async test(secret, target) {
48066
+ if (isBlockedHost(target.host)) {
48067
+ return {
48068
+ ok: false,
48069
+ latency_ms: 0,
48070
+ error: "Target host is blocked (private/internal IP or metadata endpoint)."
48071
+ };
48072
+ }
46971
48073
  const start = Date.now();
46972
48074
  const { Client: Client2 } = await Promise.resolve().then(() => (init_esm(), esm_exports));
46973
48075
  const client = new Client2({
@@ -46976,7 +48078,7 @@ var postgresTester = {
46976
48078
  database: target.database,
46977
48079
  user: target.user,
46978
48080
  password: secret.value,
46979
- ssl: target.ssl ?? false,
48081
+ ssl: target.ssl ?? true,
46980
48082
  connectionTimeoutMillis: 5e3,
46981
48083
  statement_timeout: 5e3
46982
48084
  });
@@ -47015,6 +48117,13 @@ var redisTester = {
47015
48117
  type: "redis",
47016
48118
  schema: Target4,
47017
48119
  async test(secret, target) {
48120
+ if (isBlockedHost(target.host)) {
48121
+ return {
48122
+ ok: false,
48123
+ latency_ms: 0,
48124
+ error: "Target host is blocked (private/internal IP or metadata endpoint)."
48125
+ };
48126
+ }
47018
48127
  const start = Date.now();
47019
48128
  const { default: Redis } = await Promise.resolve().then(() => __toESM(require_built3()));
47020
48129
  const client = new Redis({
@@ -47058,12 +48167,25 @@ var Target5 = external_exports.object({
47058
48167
  * 'password' uses secret.value as a password; 'key' uses
47059
48168
  * secret.value as a PEM-encoded private key.
47060
48169
  */
47061
- auth: external_exports.enum(["password", "key"]).default("password")
48170
+ auth: external_exports.enum(["password", "key"]).default("password"),
48171
+ /**
48172
+ * Expected SHA-256 fingerprint of the server host public key
48173
+ * (base64, no padding). When set, the connection is rejected if
48174
+ * the key does not match — preventing MITM attacks.
48175
+ */
48176
+ host_key_sha256: external_exports.string().min(1).optional()
47062
48177
  });
47063
48178
  var sshTester = {
47064
48179
  type: "ssh",
47065
48180
  schema: Target5,
47066
48181
  async test(secret, target) {
48182
+ if (isBlockedHost(target.host)) {
48183
+ return {
48184
+ ok: false,
48185
+ latency_ms: 0,
48186
+ error: "Target host is blocked (private/internal IP or metadata endpoint)."
48187
+ };
48188
+ }
47067
48189
  const start = Date.now();
47068
48190
  const { Client: Client2 } = await import('ssh2');
47069
48191
  return new Promise((resolve4) => {
@@ -47102,13 +48224,30 @@ var sshTester = {
47102
48224
  settle({ ok: false, latency_ms: Date.now() - start, error: err.message });
47103
48225
  });
47104
48226
  try {
47105
- client.connect({
48227
+ const connectOpts = {
47106
48228
  host: target.host,
47107
48229
  port: target.port,
47108
48230
  username: target.user,
47109
- ...target.auth === "password" ? { password: secret.value } : { privateKey: secret.value },
47110
48231
  readyTimeout: 5e3
47111
- });
48232
+ };
48233
+ if (target.auth === "password") {
48234
+ connectOpts.password = secret.value;
48235
+ } else {
48236
+ connectOpts.privateKey = secret.value;
48237
+ }
48238
+ if (target.host_key_sha256) {
48239
+ const expected = target.host_key_sha256;
48240
+ connectOpts.hostVerifier = (key2) => {
48241
+ if (typeof key2 === "string") {
48242
+ return createHash("sha256").update(key2, "utf8").digest("base64").replace(/=+$/, "") === expected;
48243
+ }
48244
+ if (Buffer.isBuffer(key2)) {
48245
+ return createHash("sha256").update(key2).digest("base64").replace(/=+$/, "") === expected;
48246
+ }
48247
+ return false;
48248
+ };
48249
+ }
48250
+ client.connect(connectOpts);
47112
48251
  } catch (err) {
47113
48252
  settle({
47114
48253
  ok: false,
@@ -47121,6 +48260,8 @@ var sshTester = {
47121
48260
  };
47122
48261
 
47123
48262
  // ../../packages/testers/dist/types.js
48263
+ init_zod();
48264
+ external_exports.enum(["postgres", "mysql", "redis", "ssh", "http"]);
47124
48265
  var DEFAULT_TIMEOUT_MS = 5e3;
47125
48266
 
47126
48267
  // ../../packages/testers/dist/sanitize.js
@@ -47183,7 +48324,7 @@ function formatZodIssues(error) {
47183
48324
  }
47184
48325
 
47185
48326
  // ../../packages/testers/dist/index.js
47186
- var TESTERS = [
48327
+ var testers = [
47187
48328
  postgresTester,
47188
48329
  mysqlTester,
47189
48330
  redisTester,
@@ -47233,7 +48374,7 @@ the error message.
47233
48374
  description: "Override the default 5s timeout (in seconds)."
47234
48375
  });
47235
48376
  async execute() {
47236
- const parsedAlias = parseAlias(this.alias);
48377
+ const parsedAlias = reference_exports.parseAlias(this.alias);
47237
48378
  if (!parsedAlias) {
47238
48379
  this.context.stderr.write(`keynv: invalid alias '${this.alias}'
47239
48380
  `);
@@ -47241,12 +48382,12 @@ the error message.
47241
48382
  }
47242
48383
  if (!this.as) {
47243
48384
  this.context.stderr.write(
47244
- `keynv: --as is required (one of: ${TESTERS.map((t) => t.type).join(", ")})
48385
+ `keynv: --as is required (one of: ${testers.map((t) => t.type).join(", ")})
47245
48386
  `
47246
48387
  );
47247
48388
  return 2;
47248
48389
  }
47249
- const tester = TESTERS.find((t) => t.type === this.as);
48390
+ const tester = testers.find((t) => t.type === this.as);
47250
48391
  if (!tester) {
47251
48392
  this.context.stderr.write(`keynv: unknown tester '${this.as}'
47252
48393
  `);
@@ -47376,7 +48517,7 @@ if (argv.length === 0) {
47376
48517
  process.exit(0);
47377
48518
  }
47378
48519
  } else {
47379
- cli.runExit(argv).catch((err) => {
48520
+ cli.run(argv).then((code) => process.exit(code ?? 0)).catch((err) => {
47380
48521
  process.stderr.write(`${fmtError(err)}
47381
48522
  `);
47382
48523
  process.exit(1);