@macintacos/caret 1.1.0 → 1.1.1

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/cli.js CHANGED
@@ -223,6 +223,11 @@ var init_install = __esm(() => {
223
223
  init_json_file();
224
224
  });
225
225
 
226
+ // src/lib/compare.ts
227
+ function compareCodeUnits(a, b) {
228
+ return a < b ? -1 : a > b ? 1 : 0;
229
+ }
230
+
226
231
  // src/lib/skill-doc.ts
227
232
  import { readFile as readFile2, realpath, stat } from "fs/promises";
228
233
  import { join as join2, sep } from "path";
@@ -358,7 +363,7 @@ async function enabledPlugins(cwd) {
358
363
  continue;
359
364
  out.push([key.split("@")[0] ?? key, installPath]);
360
365
  }
361
- return out.sort(([a], [b]) => a < b ? -1 : a > b ? 1 : 0);
366
+ return out.sort(([a], [b]) => compareCodeUnits(a, b));
362
367
  }
363
368
  async function readClaudeSkills(cwd) {
364
369
  const [user, project, plugins] = await Promise.all([
@@ -462,7 +467,7 @@ function toHookOutput2(input) {
462
467
  }
463
468
  var init_feedback2 = () => {};
464
469
 
465
- // node_modules/.bun/smol-toml@1.8.0/node_modules/smol-toml/dist/date.js
470
+ // node_modules/smol-toml/dist/date.js
466
471
  var DATE_TIME_RE, TomlDate;
467
472
  var init_date = __esm(() => {
468
473
  /*!
@@ -584,7 +589,7 @@ var init_date = __esm(() => {
584
589
  };
585
590
  });
586
591
 
587
- // node_modules/.bun/smol-toml@1.8.0/node_modules/smol-toml/dist/error.js
592
+ // node_modules/smol-toml/dist/error.js
588
593
  function getLineColFromPtr(string, ptr) {
589
594
  let lines = string.slice(0, ptr).split(/\r\n|\n|\r/g);
590
595
  return [lines.length, lines.pop().length + 1];
@@ -656,7 +661,7 @@ ${codeblock}`, options);
656
661
  };
657
662
  });
658
663
 
659
- // node_modules/.bun/smol-toml@1.8.0/node_modules/smol-toml/dist/util.js
664
+ // node_modules/smol-toml/dist/util.js
660
665
  function indexOfNewline(str, start = 0) {
661
666
  let idx = str.indexOf(`
662
667
  `, start);
@@ -742,7 +747,7 @@ var init_util = __esm(() => {
742
747
  */
743
748
  });
744
749
 
745
- // node_modules/.bun/smol-toml@1.8.0/node_modules/smol-toml/dist/primitive.js
750
+ // node_modules/smol-toml/dist/primitive.js
746
751
  function parseString(ctx) {
747
752
  let start = ctx.p;
748
753
  let c = ctx.s.charCodeAt(ctx.p++);
@@ -923,7 +928,7 @@ var init_primitive = __esm(() => {
923
928
  LEADING_ZERO = /^[+-]?0[0-9_]/;
924
929
  });
925
930
 
926
- // node_modules/.bun/smol-toml@1.8.0/node_modules/smol-toml/dist/extract.js
931
+ // node_modules/smol-toml/dist/extract.js
927
932
  function extractValue(ctx, end, integersAsBigInt) {
928
933
  let ptr = ctx.p;
929
934
  let c = ctx.s.charCodeAt(ptr);
@@ -988,7 +993,7 @@ var init_extract = __esm(() => {
988
993
  */
989
994
  });
990
995
 
991
- // node_modules/.bun/smol-toml@1.8.0/node_modules/smol-toml/dist/struct.js
996
+ // node_modules/smol-toml/dist/struct.js
992
997
  function parseKey(ctx, end = "=") {
993
998
  let start = ctx.p;
994
999
  let dot = start - 1;
@@ -1164,7 +1169,7 @@ var init_struct = __esm(() => {
1164
1169
  KEY_PART_RE = /^[a-zA-Z0-9-_]+[ \t]*$/;
1165
1170
  });
1166
1171
 
1167
- // node_modules/.bun/smol-toml@1.8.0/node_modules/smol-toml/dist/parse.js
1172
+ // node_modules/smol-toml/dist/parse.js
1168
1173
  function peekTable(key, table, meta, type) {
1169
1174
  let t = table;
1170
1175
  let m = meta;
@@ -1312,7 +1317,7 @@ var init_parse = __esm(() => {
1312
1317
  */
1313
1318
  });
1314
1319
 
1315
- // node_modules/.bun/smol-toml@1.8.0/node_modules/smol-toml/dist/stringify.js
1320
+ // node_modules/smol-toml/dist/stringify.js
1316
1321
  var init_stringify = __esm(() => {
1317
1322
  /*!
1318
1323
  * Copyright (c) Squirrel Chat et al., All rights reserved.
@@ -1343,7 +1348,7 @@ var init_stringify = __esm(() => {
1343
1348
  */
1344
1349
  });
1345
1350
 
1346
- // node_modules/.bun/smol-toml@1.8.0/node_modules/smol-toml/dist/index.js
1351
+ // node_modules/smol-toml/dist/index.js
1347
1352
  var init_dist = __esm(() => {
1348
1353
  init_parse();
1349
1354
  init_stringify();
@@ -1479,7 +1484,7 @@ function fatalDenyLine(reason) {
1479
1484
  }
1480
1485
  var init_feedback3 = () => {};
1481
1486
 
1482
- // node_modules/.bun/jsonc-parser@3.3.1/node_modules/jsonc-parser/lib/esm/impl/scanner.js
1487
+ // node_modules/jsonc-parser/lib/esm/impl/scanner.js
1483
1488
  function createScanner(text, ignoreTrivia = false) {
1484
1489
  const len = text.length;
1485
1490
  let pos = 0, value = "", tokenOffset = 0, token = 16, lineNumber = 0, lineStartOffset = 0, tokenLineStartOffset = 0, prevTokenLineStartOffset = 0, scanError = 0;
@@ -1896,7 +1901,7 @@ var init_scanner = __esm(() => {
1896
1901
  })(CharacterCodes || (CharacterCodes = {}));
1897
1902
  });
1898
1903
 
1899
- // node_modules/.bun/jsonc-parser@3.3.1/node_modules/jsonc-parser/lib/esm/impl/string-intern.js
1904
+ // node_modules/jsonc-parser/lib/esm/impl/string-intern.js
1900
1905
  var cachedSpaces, maxCachedValues = 200, cachedBreakLinesWithSpaces, supportedEols;
1901
1906
  var init_string_intern = __esm(() => {
1902
1907
  cachedSpaces = new Array(20).fill(0).map((_, index) => {
@@ -1935,7 +1940,7 @@ var init_string_intern = __esm(() => {
1935
1940
  `];
1936
1941
  });
1937
1942
 
1938
- // node_modules/.bun/jsonc-parser@3.3.1/node_modules/jsonc-parser/lib/esm/impl/format.js
1943
+ // node_modules/jsonc-parser/lib/esm/impl/format.js
1939
1944
  function format(documentText, range, options) {
1940
1945
  let initialIndentLevel;
1941
1946
  let formatText;
@@ -2179,7 +2184,7 @@ var init_format = __esm(() => {
2179
2184
  init_string_intern();
2180
2185
  });
2181
2186
 
2182
- // node_modules/.bun/jsonc-parser@3.3.1/node_modules/jsonc-parser/lib/esm/impl/parser.js
2187
+ // node_modules/jsonc-parser/lib/esm/impl/parser.js
2183
2188
  function parse2(text, errors = [], options = ParseOptions.DEFAULT) {
2184
2189
  let currentProperty = null;
2185
2190
  let currentParent = [];
@@ -2594,7 +2599,7 @@ var init_parser = __esm(() => {
2594
2599
  })(ParseOptions || (ParseOptions = {}));
2595
2600
  });
2596
2601
 
2597
- // node_modules/.bun/jsonc-parser@3.3.1/node_modules/jsonc-parser/lib/esm/impl/edit.js
2602
+ // node_modules/jsonc-parser/lib/esm/impl/edit.js
2598
2603
  function setProperty(text, originalPath, value, options) {
2599
2604
  const path = originalPath.slice();
2600
2605
  const errors = [];
@@ -2742,7 +2747,7 @@ var init_edit = __esm(() => {
2742
2747
  init_parser();
2743
2748
  });
2744
2749
 
2745
- // node_modules/.bun/jsonc-parser@3.3.1/node_modules/jsonc-parser/lib/esm/main.js
2750
+ // node_modules/jsonc-parser/lib/esm/main.js
2746
2751
  function modify(text, path, value, options) {
2747
2752
  return setProperty(text, path, value, options);
2748
2753
  }
@@ -2873,8 +2878,8 @@ function opencodeCachePackagesDir() {
2873
2878
  const xdg = process.env.XDG_CACHE_HOME?.trim();
2874
2879
  return join5(xdg || join5(homedir3(), ".cache"), "opencode", "packages");
2875
2880
  }
2876
- function opencodeCachePackageDir(pkg = CARET_PACKAGE) {
2877
- return join5(opencodeCachePackagesDir(), pkg);
2881
+ function opencodeCachePackageDir(specifier = CARET_PACKAGE) {
2882
+ return join5(opencodeCachePackagesDir(), specifier);
2878
2883
  }
2879
2884
  function existingOpencodeCachePackageDirs(pkg = CARET_PACKAGE) {
2880
2885
  const bare = opencodeCachePackageDir(pkg);
@@ -2965,6 +2970,32 @@ var init_config_plugin = __esm(() => {
2965
2970
  FORMATTING = { insertSpaces: true, tabSize: 2 };
2966
2971
  });
2967
2972
 
2973
+ // src/adapters/opencode/entries.ts
2974
+ import { existsSync as existsSync2, readFileSync as readFileSync3 } from "fs";
2975
+ import { join as join6 } from "path";
2976
+ function isCaretCheckout(dir) {
2977
+ return existsSync2(join6(dir, "opencode", "caret.plugin.ts"));
2978
+ }
2979
+ function caretEntries(text, isCheckout) {
2980
+ return pluginEntries(text).filter((entry) => {
2981
+ const path = localSpecifierPath(entry);
2982
+ return path === undefined ? splitPluginSpecifier(entry).pkg === CARET_PACKAGE : isCheckout(path);
2983
+ });
2984
+ }
2985
+ function readCaretEntry(configFile) {
2986
+ return findPluginEntry(readConfigText(configFile), CARET_PACKAGE);
2987
+ }
2988
+ function readLoadedCaretEntry(configFile) {
2989
+ return caretEntries(readConfigText(configFile), isCaretCheckout)[0] ?? null;
2990
+ }
2991
+ function readConfigText(path) {
2992
+ return existsSync2(path) ? readFileSync3(path, "utf-8") : null;
2993
+ }
2994
+ var init_entries = __esm(() => {
2995
+ init_config_plugin();
2996
+ init_paths2();
2997
+ });
2998
+
2968
2999
  // src/lib/semver.ts
2969
3000
  function parseVersionTriple(v) {
2970
3001
  const m = v.trim().replace(/^v/, "").match(/^(\d+)\.(\d+)\.(\d+)/);
@@ -2984,7 +3015,7 @@ function isNewer(latest, current) {
2984
3015
  return a2 > b2;
2985
3016
  }
2986
3017
 
2987
- // node_modules/.bun/zod@4.5.4/node_modules/zod/v4/core/util.js
3018
+ // node_modules/zod/v4/core/util.js
2988
3019
  function getEnumValues(entries) {
2989
3020
  const numericValues = Object.values(entries).filter((v) => typeof v === "number");
2990
3021
  const values = Object.entries(entries).filter(([k, _]) => numericValues.indexOf(+k) === -1).map(([_, v]) => v);
@@ -3523,7 +3554,7 @@ var init_util2 = __esm(() => {
3523
3554
  };
3524
3555
  });
3525
3556
 
3526
- // node_modules/.bun/zod@4.5.4/node_modules/zod/v4/core/core.js
3557
+ // node_modules/zod/v4/core/core.js
3527
3558
  function newError(Definition) {
3528
3559
  const E = _E;
3529
3560
  if (E) {
@@ -3645,7 +3676,7 @@ var init_core = __esm(() => {
3645
3676
  globalConfig = globalThis.__zod_globalConfig;
3646
3677
  });
3647
3678
 
3648
- // node_modules/.bun/zod@4.5.4/node_modules/zod/v4/core/errors.js
3679
+ // node_modules/zod/v4/core/errors.js
3649
3680
  function _getMessage() {
3650
3681
  const internals = this._zod;
3651
3682
  internals.message ?? (internals.message = JSON.stringify(internals.def, jsonStringifyReplacer, 2));
@@ -3768,7 +3799,7 @@ var init_errors = __esm(() => {
3768
3799
  });
3769
3800
  });
3770
3801
 
3771
- // node_modules/.bun/zod@4.5.4/node_modules/zod/v4/core/parse.js
3802
+ // node_modules/zod/v4/core/parse.js
3772
3803
  function finalizeParams(callee, params) {
3773
3804
  return { callee: params?.callee ?? callee, Err: params?.Err };
3774
3805
  }
@@ -3867,7 +3898,7 @@ var init_parse2 = __esm(() => {
3867
3898
  safeParseAsync = /* @__PURE__ */ _safeParseAsync($ZodRealError);
3868
3899
  });
3869
3900
 
3870
- // node_modules/.bun/zod@4.5.4/node_modules/zod/v4/core/regexes.js
3901
+ // node_modules/zod/v4/core/regexes.js
3871
3902
  function nanoidOfLength(length) {
3872
3903
  return new RegExp(`^[a-zA-Z0-9_-]{${length}}$`);
3873
3904
  }
@@ -3929,7 +3960,7 @@ var init_regexes = __esm(() => {
3929
3960
  uppercase = /^[^a-z]*$/;
3930
3961
  });
3931
3962
 
3932
- // node_modules/.bun/zod@4.5.4/node_modules/zod/v4/core/checks.js
3963
+ // node_modules/zod/v4/core/checks.js
3933
3964
  var $ZodCheck, _whenHasLength = (payload) => {
3934
3965
  const val = payload.value;
3935
3966
  return !nullish(val) && val.length !== undefined;
@@ -4321,7 +4352,7 @@ var init_checks = __esm(() => {
4321
4352
  });
4322
4353
  });
4323
4354
 
4324
- // node_modules/.bun/zod@4.5.4/node_modules/zod/v4/core/doc.js
4355
+ // node_modules/zod/v4/core/doc.js
4325
4356
  class Doc {
4326
4357
  constructor(args = [], closed = {}) {
4327
4358
  this.content = [];
@@ -4360,7 +4391,7 @@ ${content.join(`
4360
4391
  }
4361
4392
  }
4362
4393
 
4363
- // node_modules/.bun/zod@4.5.4/node_modules/zod/v4/core/versions.js
4394
+ // node_modules/zod/v4/core/versions.js
4364
4395
  var version;
4365
4396
  var init_versions = __esm(() => {
4366
4397
  version = {
@@ -4370,7 +4401,7 @@ var init_versions = __esm(() => {
4370
4401
  };
4371
4402
  });
4372
4403
 
4373
- // node_modules/.bun/zod@4.5.4/node_modules/zod/v4/core/schemas.js
4404
+ // node_modules/zod/v4/core/schemas.js
4374
4405
  function standardProps(inst) {
4375
4406
  return {
4376
4407
  validate: (value) => {
@@ -5998,7 +6029,7 @@ var init_schemas = __esm(() => {
5998
6029
  });
5999
6030
  });
6000
6031
 
6001
- // node_modules/.bun/zod@4.5.4/node_modules/zod/v4/core/memoizer.js
6032
+ // node_modules/zod/v4/core/memoizer.js
6002
6033
  function cloneIssues(issues) {
6003
6034
  return issues.map((iss) => iss.path ? { ...iss, path: iss.path.slice() } : { ...iss });
6004
6035
  }
@@ -6233,7 +6264,7 @@ var init_memoizer = __esm(() => {
6233
6264
  };
6234
6265
  });
6235
6266
 
6236
- // node_modules/.bun/zod@4.5.4/node_modules/zod/v4/locales/en.js
6267
+ // node_modules/zod/v4/locales/en.js
6237
6268
  function en_default() {
6238
6269
  return {
6239
6270
  localeError: error()
@@ -6357,10 +6388,10 @@ var init_en = __esm(() => {
6357
6388
  init_util2();
6358
6389
  });
6359
6390
 
6360
- // node_modules/.bun/zod@4.5.4/node_modules/zod/v4/locales/index.js
6391
+ // node_modules/zod/v4/locales/index.js
6361
6392
  var init_locales = () => {};
6362
6393
 
6363
- // node_modules/.bun/zod@4.5.4/node_modules/zod/v4/core/registries.js
6394
+ // node_modules/zod/v4/core/registries.js
6364
6395
  class $ZodRegistry {
6365
6396
  constructor() {
6366
6397
  this._map = new WeakMap;
@@ -6410,7 +6441,7 @@ var init_registries = __esm(() => {
6410
6441
  globalRegistry = globalThis.__zod_globalRegistry;
6411
6442
  });
6412
6443
 
6413
- // node_modules/.bun/zod@4.5.4/node_modules/zod/v4/core/compile.js
6444
+ // node_modules/zod/v4/core/compile.js
6414
6445
  var INVALID, FALLBACK_FLAG, WHEN_DEFAULTED_CHECKS, PATTERN_IS_COMPLETE;
6415
6446
  var init_compile = __esm(() => {
6416
6447
  INVALID = Symbol.for("zod.compile.invalid");
@@ -6451,7 +6482,7 @@ var init_compile = __esm(() => {
6451
6482
  ]);
6452
6483
  });
6453
6484
 
6454
- // node_modules/.bun/zod@4.5.4/node_modules/zod/v4/core/api.js
6485
+ // node_modules/zod/v4/core/api.js
6455
6486
  function _string(Class, params) {
6456
6487
  return new Class({
6457
6488
  type: "string",
@@ -6959,7 +6990,7 @@ var init_api = __esm(() => {
6959
6990
  init_util2();
6960
6991
  });
6961
6992
 
6962
- // node_modules/.bun/zod@4.5.4/node_modules/zod/v4/core/to-json-schema.js
6993
+ // node_modules/zod/v4/core/to-json-schema.js
6963
6994
  function assignProps(target, ...sources) {
6964
6995
  for (const source of sources) {
6965
6996
  for (const key of Reflect.ownKeys(source)) {
@@ -7487,7 +7518,7 @@ var init_to_json_schema = __esm(() => {
7487
7518
  UNION_KEYS = ["oneOf", "anyOf"];
7488
7519
  });
7489
7520
 
7490
- // node_modules/.bun/zod@4.5.4/node_modules/zod/v4/core/json-schema-processors.js
7521
+ // node_modules/zod/v4/core/json-schema-processors.js
7491
7522
  function inputOptin(schema) {
7492
7523
  const def = schema._zod.def;
7493
7524
  if (def.type === "pipe" && def.in._zod.traits.has("$ZodTransform")) {
@@ -8108,10 +8139,10 @@ var init_json_schema_processors = __esm(() => {
8108
8139
  };
8109
8140
  });
8110
8141
 
8111
- // node_modules/.bun/zod@4.5.4/node_modules/zod/v4/core/json-schema.js
8142
+ // node_modules/zod/v4/core/json-schema.js
8112
8143
  var init_json_schema = () => {};
8113
8144
 
8114
- // node_modules/.bun/zod@4.5.4/node_modules/zod/v4/core/index.js
8145
+ // node_modules/zod/v4/core/index.js
8115
8146
  var init_core2 = __esm(() => {
8116
8147
  init_util2();
8117
8148
  init_regexes();
@@ -8130,12 +8161,12 @@ var init_core2 = __esm(() => {
8130
8161
  init_to_json_schema();
8131
8162
  });
8132
8163
 
8133
- // node_modules/.bun/zod@4.5.4/node_modules/zod/v4/classic/checks.js
8164
+ // node_modules/zod/v4/classic/checks.js
8134
8165
  var init_checks2 = __esm(() => {
8135
8166
  init_core2();
8136
8167
  });
8137
8168
 
8138
- // node_modules/.bun/zod@4.5.4/node_modules/zod/v4/classic/errors.js
8169
+ // node_modules/zod/v4/classic/errors.js
8139
8170
  function _lazyMethod(proto, key, make) {
8140
8171
  Object.defineProperty(proto, key, {
8141
8172
  configurable: true,
@@ -8185,7 +8216,7 @@ var init_errors2 = __esm(() => {
8185
8216
  });
8186
8217
  });
8187
8218
 
8188
- // node_modules/.bun/zod@4.5.4/node_modules/zod/v4/classic/parse.js
8219
+ // node_modules/zod/v4/classic/parse.js
8189
8220
  var parse6, parseAsync2, safeParse2, safeParseAsync2, encode, decode, encodeAsync, decodeAsync, safeEncode, safeDecode, safeEncodeAsync, safeDecodeAsync;
8190
8221
  var init_parse3 = __esm(() => {
8191
8222
  init_core2();
@@ -8204,7 +8235,7 @@ var init_parse3 = __esm(() => {
8204
8235
  safeDecodeAsync = /* @__PURE__ */ _safeDecodeAsync(ZodRealError);
8205
8236
  });
8206
8237
 
8207
- // node_modules/.bun/zod@4.5.4/node_modules/zod/v4/classic/schemas.js
8238
+ // node_modules/zod/v4/classic/schemas.js
8208
8239
  function _ensureDefaultLocale() {
8209
8240
  if (!globalConfig.localeError)
8210
8241
  config(en_default());
@@ -9183,13 +9214,13 @@ var init_schemas2 = __esm(() => {
9183
9214
  });
9184
9215
  });
9185
9216
 
9186
- // node_modules/.bun/zod@4.5.4/node_modules/zod/v4/classic/compat.js
9217
+ // node_modules/zod/v4/classic/compat.js
9187
9218
  var ZodFirstPartyTypeKind;
9188
9219
  var init_compat = __esm(() => {
9189
9220
  (function(ZodFirstPartyTypeKind) {})(ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {}));
9190
9221
  });
9191
9222
 
9192
- // node_modules/.bun/zod@4.5.4/node_modules/zod/v4/classic/iso.js
9223
+ // node_modules/zod/v4/classic/iso.js
9193
9224
  function datetime2(params) {
9194
9225
  return _isoDateTime(ZodISODateTime, params);
9195
9226
  }
@@ -9198,7 +9229,7 @@ var init_iso = __esm(() => {
9198
9229
  init_schemas2();
9199
9230
  });
9200
9231
 
9201
- // node_modules/.bun/zod@4.5.4/node_modules/zod/v4/classic/coerce.js
9232
+ // node_modules/zod/v4/classic/coerce.js
9202
9233
  var exports_coerce = {};
9203
9234
  __export(exports_coerce, {
9204
9235
  bigint: () => bigint2,
@@ -9227,7 +9258,7 @@ var init_coerce = __esm(() => {
9227
9258
  init_schemas2();
9228
9259
  });
9229
9260
 
9230
- // node_modules/.bun/zod@4.5.4/node_modules/zod/v4/classic/external.js
9261
+ // node_modules/zod/v4/classic/external.js
9231
9262
  var init_external = __esm(() => {
9232
9263
  init_core2();
9233
9264
  init_locales();
@@ -9240,7 +9271,7 @@ var init_external = __esm(() => {
9240
9271
  init_compat();
9241
9272
  });
9242
9273
 
9243
- // node_modules/.bun/zod@4.5.4/node_modules/zod/index.js
9274
+ // node_modules/zod/index.js
9244
9275
  var init_zod = __esm(() => {
9245
9276
  init_external();
9246
9277
  init_external();
@@ -9251,7 +9282,7 @@ var package_default;
9251
9282
  var init_package = __esm(() => {
9252
9283
  package_default = {
9253
9284
  name: "@macintacos/caret",
9254
- version: "1.1.0",
9285
+ version: "1.1.1",
9255
9286
  license: "MIT",
9256
9287
  type: "module",
9257
9288
  description: "A Claude Code plugin that replaces the terminal plan-approval prompt with a local web UI for inline review, annotation, and approval.",
@@ -9413,8 +9444,8 @@ var init_upstream = __esm(() => {
9413
9444
  });
9414
9445
 
9415
9446
  // src/adapters/opencode/upgrade.ts
9416
- import { existsSync as existsSync2, readFileSync as readFileSync3, rmSync } from "fs";
9417
- import { join as join6 } from "path";
9447
+ import { existsSync as existsSync3, rmSync } from "fs";
9448
+ import { join as join7 } from "path";
9418
9449
  function upgradeVerdict(input) {
9419
9450
  const { entry, cached, published } = input;
9420
9451
  if (published === null) {
@@ -9473,33 +9504,32 @@ function upgradeCheck(verdict) {
9473
9504
  }
9474
9505
  }
9475
9506
  async function readUpgradeVerdict(deps) {
9507
+ const entry = readCaretEntry(deps.configFile);
9476
9508
  return upgradeVerdict({
9477
- entry: findPluginEntry(readConfigText(deps.configFile), CARET_PACKAGE),
9478
- cached: readCachedCaretVersion((deps.cacheDirs ?? existingOpencodeCachePackageDirs)()),
9509
+ entry,
9510
+ cached: readEntryCachedVersion(entry, deps.cacheDir),
9479
9511
  published: await (deps.published ?? publishedCaretVersion)()
9480
9512
  });
9481
9513
  }
9482
9514
  function hasCaretPluginEntry(configFile) {
9483
- return findPluginEntry(readConfigText(configFile), CARET_PACKAGE) !== null;
9515
+ return readCaretEntry(configFile) !== null;
9484
9516
  }
9485
- function readConfigText(path) {
9486
- return existsSync2(path) ? readFileSync3(path, "utf-8") : null;
9517
+ function readEntryCachedVersion(entry, cacheDir = opencodeCachePackageDir) {
9518
+ return entry === null ? null : readCachedCaretVersion(cacheDir(entry));
9487
9519
  }
9488
- function readCachedCaretVersion(dirs = existingOpencodeCachePackageDirs()) {
9489
- for (const d of dirs) {
9490
- try {
9491
- const deps = JSON.parse(readFileSync3(join6(d, "package.json"), "utf-8")).dependencies;
9492
- const v = deps?.[CARET_PACKAGE];
9493
- if (typeof v === "string" && v.length > 0)
9494
- return v;
9495
- } catch {}
9520
+ function readCachedCaretVersion(dir) {
9521
+ const installed = readJsonFileSync(join7(dir, "node_modules", CARET_PACKAGE, "package.json"));
9522
+ if (typeof installed?.version === "string" && installed.version.length > 0) {
9523
+ return installed.version;
9496
9524
  }
9497
- return null;
9525
+ const shim = readJsonFileSync(join7(dir, "package.json"));
9526
+ const requested = shim?.dependencies?.[CARET_PACKAGE];
9527
+ return typeof requested === "string" && requested.length > 0 ? requested : null;
9498
9528
  }
9499
9529
  function clearCachedCaret(dirs = existingOpencodeCachePackageDirs()) {
9500
9530
  const cleared = [];
9501
9531
  for (const d of dirs) {
9502
- if (!existsSync2(d))
9532
+ if (!existsSync3(d))
9503
9533
  continue;
9504
9534
  rmSync(d, { recursive: true, force: true });
9505
9535
  cleared.push(d);
@@ -9508,19 +9538,32 @@ function clearCachedCaret(dirs = existingOpencodeCachePackageDirs()) {
9508
9538
  }
9509
9539
  var init_upgrade = __esm(() => {
9510
9540
  init_config_plugin();
9541
+ init_entries();
9511
9542
  init_paths2();
9543
+ init_json_file();
9512
9544
  init_upstream();
9513
9545
  });
9514
9546
 
9515
9547
  // src/adapters/opencode/install.ts
9516
- import { existsSync as existsSync3, readFileSync as readFileSync4 } from "fs";
9517
- import { join as join7 } from "path";
9548
+ import { existsSync as existsSync4, readFileSync as readFileSync4 } from "fs";
9549
+ import { join as join8 } from "path";
9518
9550
  function readOpencodeInstallState() {
9519
9551
  const dir = opencodeConfigDir();
9520
- if (!existsSync3(dir)) {
9552
+ if (!existsSync4(dir)) {
9521
9553
  return { pluginVersion: "unknown", pluginEnabled: "unknown", hookInUserSettings: "unknown" };
9522
9554
  }
9523
- const version = readCachedCaretVersion(existingOpencodeCachePackageDirs()) ?? "unknown";
9555
+ let entry;
9556
+ try {
9557
+ entry = readLoadedCaretEntry(resolveConfigFile(dir));
9558
+ } catch {
9559
+ return {
9560
+ pluginVersion: "unknown",
9561
+ pluginEnabled: "unknown",
9562
+ hookInUserSettings: readCaretInPluginArray(dir)
9563
+ };
9564
+ }
9565
+ const cached = readEntryCachedVersion(entry);
9566
+ const version = cached !== null && parseVersionTriple(cached) !== null ? cached : "unknown";
9524
9567
  return {
9525
9568
  pluginVersion: version,
9526
9569
  pluginEnabled: version !== "unknown",
@@ -9530,27 +9573,27 @@ function readOpencodeInstallState() {
9530
9573
  function readCaretInPluginArray(dir) {
9531
9574
  let sawConfig = false;
9532
9575
  for (const name of CONFIG_FILENAMES) {
9533
- const path = join7(dir, name);
9534
- if (!existsSync3(path))
9576
+ const path = join8(dir, name);
9577
+ if (!existsSync4(path))
9535
9578
  continue;
9536
- let cfg;
9579
+ let text;
9537
9580
  try {
9538
- cfg = parse3(readFileSync4(path, "utf-8"));
9581
+ text = readFileSync4(path, "utf-8");
9539
9582
  } catch {
9540
9583
  continue;
9541
9584
  }
9585
+ const cfg = parse3(text);
9542
9586
  if (cfg === undefined || cfg === null)
9543
9587
  continue;
9544
9588
  sawConfig = true;
9545
- const arr = cfg.plugin;
9546
- if (Array.isArray(arr) && arr.some((e) => typeof e === "string" && e.includes("caret"))) {
9589
+ if (caretEntries(text, isCaretCheckout).length > 0)
9547
9590
  return true;
9548
- }
9549
9591
  }
9550
9592
  return sawConfig ? false : "unknown";
9551
9593
  }
9552
9594
  var init_install3 = __esm(() => {
9553
9595
  init_main();
9596
+ init_entries();
9554
9597
  init_paths2();
9555
9598
  init_upgrade();
9556
9599
  });
@@ -9739,7 +9782,7 @@ var init_constants = __esm(() => {
9739
9782
  });
9740
9783
 
9741
9784
  // src/config/paths.ts
9742
- import { chmodSync, existsSync as existsSync4, mkdirSync, renameSync } from "fs";
9785
+ import { chmodSync, existsSync as existsSync5, mkdirSync, renameSync } from "fs";
9743
9786
  import { homedir as homedir4 } from "os";
9744
9787
  function xdgDir(envVar, fallback) {
9745
9788
  const base = process.env[envVar] || `${homedir4()}/${fallback}`;
@@ -9766,6 +9809,9 @@ function launcherPath() {
9766
9809
  function launcherRecordDir() {
9767
9810
  return `${stateDir()}/launcher`;
9768
9811
  }
9812
+ function ownedRootsDir() {
9813
+ return `${stateDir()}/roots`;
9814
+ }
9769
9815
  function launcherBunFile() {
9770
9816
  return `${launcherRecordDir()}/bun-path`;
9771
9817
  }
@@ -9822,7 +9868,7 @@ function ensureLogsDir() {
9822
9868
  for (const name of ["caret.log", "daemon.log"]) {
9823
9869
  const from = `${stateDir()}/${name}`;
9824
9870
  const to = `${logsDir()}/${name}`;
9825
- if (!existsSync4(from) || existsSync4(to))
9871
+ if (!existsSync5(from) || existsSync5(to))
9826
9872
  continue;
9827
9873
  try {
9828
9874
  renameSync(from, to);
@@ -9834,7 +9880,7 @@ var init_paths3 = () => {};
9834
9880
 
9835
9881
  // src/ui/assets.ts
9836
9882
  import { readdirSync as readdirSync2 } from "fs";
9837
- import { dirname as dirname2, join as join8, relative } from "path";
9883
+ import { dirname as dirname2, join as join9, relative } from "path";
9838
9884
  import { fileURLToPath } from "url";
9839
9885
  function fromPathMap(map) {
9840
9886
  const paths = Object.keys(map).sort();
@@ -9850,7 +9896,7 @@ function walkDist(distDir) {
9850
9896
  const found = [];
9851
9897
  const walk = (dir) => {
9852
9898
  for (const ent of readdirSync2(dir, { withFileTypes: true })) {
9853
- const full = join8(dir, ent.name);
9899
+ const full = join9(dir, ent.name);
9854
9900
  if (ent.isDirectory())
9855
9901
  walk(full);
9856
9902
  else if (ent.isFile())
@@ -9888,7 +9934,7 @@ async function loadUiAssets() {
9888
9934
  if (fromDist)
9889
9935
  return fromDist;
9890
9936
  }
9891
- const besideDist = join8(dirname2(process.execPath), "ui");
9937
+ const besideDist = join9(dirname2(process.execPath), "ui");
9892
9938
  return assetsFromDist(besideDist);
9893
9939
  }
9894
9940
  var init_assets = () => {};
@@ -9975,7 +10021,7 @@ var init_build_id = __esm(() => {
9975
10021
  IDENTITY = { service: "caret", version: VERSION };
9976
10022
  });
9977
10023
 
9978
- // node_modules/.bun/pino-std-serializers@7.1.0/node_modules/pino-std-serializers/lib/err-helpers.js
10024
+ // node_modules/pino-std-serializers/lib/err-helpers.js
9979
10025
  var require_err_helpers = __commonJS(function(exports, module) {
9980
10026
  var isErrorLike = (err) => {
9981
10027
  return err && typeof err.message === "string";
@@ -10034,7 +10080,7 @@ caused by: ` + _stackWithCauses(cause, seen);
10034
10080
  };
10035
10081
  });
10036
10082
 
10037
- // node_modules/.bun/pino-std-serializers@7.1.0/node_modules/pino-std-serializers/lib/err-proto.js
10083
+ // node_modules/pino-std-serializers/lib/err-proto.js
10038
10084
  var require_err_proto = __commonJS(function(exports, module) {
10039
10085
  var seen = Symbol("circular-ref-tag");
10040
10086
  var rawSymbol = Symbol("pino-raw-err-ref");
@@ -10082,7 +10128,7 @@ var require_err_proto = __commonJS(function(exports, module) {
10082
10128
  };
10083
10129
  });
10084
10130
 
10085
- // node_modules/.bun/pino-std-serializers@7.1.0/node_modules/pino-std-serializers/lib/err.js
10131
+ // node_modules/pino-std-serializers/lib/err.js
10086
10132
  var require_err = __commonJS(function(exports, module) {
10087
10133
  module.exports = errSerializer;
10088
10134
  var { messageWithCauses, stackWithCauses, isErrorLike } = require_err_helpers();
@@ -10119,7 +10165,7 @@ var require_err = __commonJS(function(exports, module) {
10119
10165
  }
10120
10166
  });
10121
10167
 
10122
- // node_modules/.bun/pino-std-serializers@7.1.0/node_modules/pino-std-serializers/lib/err-with-cause.js
10168
+ // node_modules/pino-std-serializers/lib/err-with-cause.js
10123
10169
  var require_err_with_cause = __commonJS(function(exports, module) {
10124
10170
  module.exports = errWithCauseSerializer;
10125
10171
  var { isErrorLike } = require_err_helpers();
@@ -10159,7 +10205,7 @@ var require_err_with_cause = __commonJS(function(exports, module) {
10159
10205
  }
10160
10206
  });
10161
10207
 
10162
- // node_modules/.bun/pino-std-serializers@7.1.0/node_modules/pino-std-serializers/lib/req.js
10208
+ // node_modules/pino-std-serializers/lib/req.js
10163
10209
  var require_req = __commonJS(function(exports, module) {
10164
10210
  module.exports = {
10165
10211
  mapHttpRequest,
@@ -10251,7 +10297,7 @@ var require_req = __commonJS(function(exports, module) {
10251
10297
  }
10252
10298
  });
10253
10299
 
10254
- // node_modules/.bun/pino-std-serializers@7.1.0/node_modules/pino-std-serializers/lib/res.js
10300
+ // node_modules/pino-std-serializers/lib/res.js
10255
10301
  var require_res = __commonJS(function(exports, module) {
10256
10302
  module.exports = {
10257
10303
  mapHttpResponse,
@@ -10297,7 +10343,7 @@ var require_res = __commonJS(function(exports, module) {
10297
10343
  }
10298
10344
  });
10299
10345
 
10300
- // node_modules/.bun/pino-std-serializers@7.1.0/node_modules/pino-std-serializers/index.js
10346
+ // node_modules/pino-std-serializers/index.js
10301
10347
  var require_pino_std_serializers = __commonJS(function(exports, module) {
10302
10348
  var errSerializer = require_err();
10303
10349
  var errWithCauseSerializer = require_err_with_cause();
@@ -10334,7 +10380,7 @@ var require_pino_std_serializers = __commonJS(function(exports, module) {
10334
10380
  };
10335
10381
  });
10336
10382
 
10337
- // node_modules/.bun/pino@10.3.1/node_modules/pino/lib/caller.js
10383
+ // node_modules/pino/lib/caller.js
10338
10384
  var require_caller = __commonJS(function(exports, module) {
10339
10385
  function noOpPrepareStackTrace(_, stack) {
10340
10386
  return stack;
@@ -10359,7 +10405,7 @@ var require_caller = __commonJS(function(exports, module) {
10359
10405
  };
10360
10406
  });
10361
10407
 
10362
- // node_modules/.bun/@pinojs+redact@0.4.0/node_modules/@pinojs/redact/index.js
10408
+ // node_modules/@pinojs/redact/index.js
10363
10409
  var require_redact = __commonJS(function(exports, module) {
10364
10410
  function deepClone(obj) {
10365
10411
  if (obj === null || typeof obj !== "object") {
@@ -10793,7 +10839,7 @@ var require_redact = __commonJS(function(exports, module) {
10793
10839
  module.exports = slowRedact;
10794
10840
  });
10795
10841
 
10796
- // node_modules/.bun/pino@10.3.1/node_modules/pino/lib/symbols.js
10842
+ // node_modules/pino/lib/symbols.js
10797
10843
  var require_symbols = __commonJS(function(exports, module) {
10798
10844
  var setLevelSym = Symbol("pino.setLevel");
10799
10845
  var getLevelSym = Symbol("pino.getLevel");
@@ -10861,7 +10907,7 @@ var require_symbols = __commonJS(function(exports, module) {
10861
10907
  };
10862
10908
  });
10863
10909
 
10864
- // node_modules/.bun/pino@10.3.1/node_modules/pino/lib/redaction.js
10910
+ // node_modules/pino/lib/redaction.js
10865
10911
  var require_redaction = __commonJS(function(exports, module) {
10866
10912
  var Redact = require_redact();
10867
10913
  var { redactFmtSym, wildcardFirstSym } = require_symbols();
@@ -10941,7 +10987,7 @@ var require_redaction = __commonJS(function(exports, module) {
10941
10987
  module.exports = redaction;
10942
10988
  });
10943
10989
 
10944
- // node_modules/.bun/pino@10.3.1/node_modules/pino/lib/time.js
10990
+ // node_modules/pino/lib/time.js
10945
10991
  var require_time = __commonJS(function(exports, module) {
10946
10992
  var nullTime = () => "";
10947
10993
  var epochTime = () => `,"time":${Date.now()}`;
@@ -10969,7 +11015,7 @@ var require_time = __commonJS(function(exports, module) {
10969
11015
  module.exports = { nullTime, epochTime, unixTime, isoTime, isoTimeNano };
10970
11016
  });
10971
11017
 
10972
- // node_modules/.bun/quick-format-unescaped@4.0.4/node_modules/quick-format-unescaped/index.js
11018
+ // node_modules/quick-format-unescaped/index.js
10973
11019
  var require_quick_format_unescaped = __commonJS(function(exports, module) {
10974
11020
  function tryStringify(o) {
10975
11021
  try {
@@ -11087,7 +11133,7 @@ var require_quick_format_unescaped = __commonJS(function(exports, module) {
11087
11133
  }
11088
11134
  });
11089
11135
 
11090
- // node_modules/.bun/atomic-sleep@1.0.0/node_modules/atomic-sleep/index.js
11136
+ // node_modules/atomic-sleep/index.js
11091
11137
  var require_atomic_sleep = __commonJS(function(exports, module) {
11092
11138
  if (typeof SharedArrayBuffer !== "undefined" && typeof Atomics !== "undefined") {
11093
11139
  let sleep = function(ms) {
@@ -11118,7 +11164,7 @@ var require_atomic_sleep = __commonJS(function(exports, module) {
11118
11164
  }
11119
11165
  });
11120
11166
 
11121
- // node_modules/.bun/sonic-boom@4.2.1/node_modules/sonic-boom/index.js
11167
+ // node_modules/sonic-boom/index.js
11122
11168
  var require_sonic_boom = __commonJS(function(exports, module) {
11123
11169
  var fs = __require("fs");
11124
11170
  var EventEmitter = __require("events");
@@ -11703,7 +11749,7 @@ var require_sonic_boom = __commonJS(function(exports, module) {
11703
11749
  module.exports = SonicBoom;
11704
11750
  });
11705
11751
 
11706
- // node_modules/.bun/on-exit-leak-free@2.1.2/node_modules/on-exit-leak-free/index.js
11752
+ // node_modules/on-exit-leak-free/index.js
11707
11753
  var require_on_exit_leak_free = __commonJS(function(exports, module) {
11708
11754
  var refs = {
11709
11755
  exit: [],
@@ -11794,7 +11840,7 @@ var require_on_exit_leak_free = __commonJS(function(exports, module) {
11794
11840
  };
11795
11841
  });
11796
11842
 
11797
- // node_modules/.bun/thread-stream@4.2.0/node_modules/thread-stream/package.json
11843
+ // node_modules/thread-stream/package.json
11798
11844
  var require_package = __commonJS(function(exports, module) {
11799
11845
  module.exports = {
11800
11846
  name: "thread-stream",
@@ -11848,7 +11894,7 @@ var require_package = __commonJS(function(exports, module) {
11848
11894
  };
11849
11895
  });
11850
11896
 
11851
- // node_modules/.bun/thread-stream@4.2.0/node_modules/thread-stream/lib/wait.js
11897
+ // node_modules/thread-stream/lib/wait.js
11852
11898
  var require_wait = __commonJS(function(exports, module) {
11853
11899
  var WAIT_MS = 1e4;
11854
11900
  function wait(state, index, expected, timeout, done) {
@@ -11904,7 +11950,7 @@ var require_wait = __commonJS(function(exports, module) {
11904
11950
  module.exports = { wait, waitDiff };
11905
11951
  });
11906
11952
 
11907
- // node_modules/.bun/thread-stream@4.2.0/node_modules/thread-stream/lib/indexes.js
11953
+ // node_modules/thread-stream/lib/indexes.js
11908
11954
  var require_indexes = __commonJS(function(exports, module) {
11909
11955
  var SEQ_INDEX = 2;
11910
11956
  var WRITE_INDEX = 4;
@@ -11916,9 +11962,9 @@ var require_indexes = __commonJS(function(exports, module) {
11916
11962
  };
11917
11963
  });
11918
11964
 
11919
- // node_modules/.bun/thread-stream@4.2.0/node_modules/thread-stream/index.js
11965
+ // node_modules/thread-stream/index.js
11920
11966
  var require_thread_stream = __commonJS(function(exports, module) {
11921
- var __dirname = "/Users/juliantorres/GitLocal/Play/caret/node_modules/.bun/thread-stream@4.2.0/node_modules/thread-stream";
11967
+ var __dirname = "/home/runner/work/caret/caret/node_modules/thread-stream";
11922
11968
  var { version } = require_package();
11923
11969
  var { EventEmitter } = __require("events");
11924
11970
  var { Worker } = __require("worker_threads");
@@ -12432,9 +12478,9 @@ var require_thread_stream = __commonJS(function(exports, module) {
12432
12478
  module.exports = ThreadStream;
12433
12479
  });
12434
12480
 
12435
- // node_modules/.bun/pino@10.3.1/node_modules/pino/lib/transport.js
12481
+ // node_modules/pino/lib/transport.js
12436
12482
  var require_transport = __commonJS(function(exports, module) {
12437
- var __dirname = "/Users/juliantorres/GitLocal/Play/caret/node_modules/.bun/pino@10.3.1/node_modules/pino/lib";
12483
+ var __dirname = "/home/runner/work/caret/caret/node_modules/pino/lib";
12438
12484
  var { createRequire } = __require("module");
12439
12485
  var { existsSync } = __require("fs");
12440
12486
  var getCallers = require_caller();
@@ -12652,7 +12698,7 @@ var require_transport = __commonJS(function(exports, module) {
12652
12698
  module.exports = transport;
12653
12699
  });
12654
12700
 
12655
- // node_modules/.bun/pino@10.3.1/node_modules/pino/lib/tools.js
12701
+ // node_modules/pino/lib/tools.js
12656
12702
  var require_tools = __commonJS(function(exports, module) {
12657
12703
  var diagChan = __require("diagnostics_channel");
12658
12704
  var format = require_quick_format_unescaped();
@@ -12982,7 +13028,7 @@ var require_tools = __commonJS(function(exports, module) {
12982
13028
  };
12983
13029
  });
12984
13030
 
12985
- // node_modules/.bun/pino@10.3.1/node_modules/pino/lib/constants.js
13031
+ // node_modules/pino/lib/constants.js
12986
13032
  var require_constants = __commonJS(function(exports, module) {
12987
13033
  var DEFAULT_LEVELS = {
12988
13034
  trace: 10,
@@ -13002,7 +13048,7 @@ var require_constants = __commonJS(function(exports, module) {
13002
13048
  };
13003
13049
  });
13004
13050
 
13005
- // node_modules/.bun/pino@10.3.1/node_modules/pino/lib/levels.js
13051
+ // node_modules/pino/lib/levels.js
13006
13052
  var require_levels = __commonJS(function(exports, module) {
13007
13053
  var {
13008
13054
  lsCacheSym,
@@ -13170,12 +13216,12 @@ var require_levels = __commonJS(function(exports, module) {
13170
13216
  };
13171
13217
  });
13172
13218
 
13173
- // node_modules/.bun/pino@10.3.1/node_modules/pino/lib/meta.js
13219
+ // node_modules/pino/lib/meta.js
13174
13220
  var require_meta = __commonJS(function(exports, module) {
13175
13221
  module.exports = { version: "10.3.1" };
13176
13222
  });
13177
13223
 
13178
- // node_modules/.bun/pino@10.3.1/node_modules/pino/lib/proto.js
13224
+ // node_modules/pino/lib/proto.js
13179
13225
  var require_proto = __commonJS(function(exports, module) {
13180
13226
  var { EventEmitter } = __require("events");
13181
13227
  var {
@@ -13392,7 +13438,7 @@ var require_proto = __commonJS(function(exports, module) {
13392
13438
  }
13393
13439
  });
13394
13440
 
13395
- // node_modules/.bun/safe-stable-stringify@2.5.0/node_modules/safe-stable-stringify/index.js
13441
+ // node_modules/safe-stable-stringify/index.js
13396
13442
  var require_safe_stable_stringify = __commonJS(function(exports, module) {
13397
13443
  var { hasOwnProperty } = Object.prototype;
13398
13444
  var stringify = configure();
@@ -13975,7 +14021,7 @@ ${originalIndentation}`;
13975
14021
  }
13976
14022
  });
13977
14023
 
13978
- // node_modules/.bun/pino@10.3.1/node_modules/pino/lib/multistream.js
14024
+ // node_modules/pino/lib/multistream.js
13979
14025
  var require_multistream = __commonJS(function(exports, module) {
13980
14026
  var metadata = Symbol.for("pino.metadata");
13981
14027
  var { DEFAULT_LEVELS } = require_constants();
@@ -14140,7 +14186,7 @@ var require_multistream = __commonJS(function(exports, module) {
14140
14186
  module.exports = multistream;
14141
14187
  });
14142
14188
 
14143
- // node_modules/.bun/pino@10.3.1/node_modules/pino/pino.js
14189
+ // node_modules/pino/pino.js
14144
14190
  var require_pino = __commonJS(function(exports, module) {
14145
14191
  var os = __require("os");
14146
14192
  var stdSerializers = require_pino_std_serializers();
@@ -15017,15 +15063,16 @@ import {
15017
15063
  accessSync,
15018
15064
  chmodSync as chmodSync2,
15019
15065
  constants,
15020
- existsSync as existsSync6,
15066
+ existsSync as existsSync7,
15021
15067
  linkSync,
15022
15068
  openSync as openSync2,
15023
15069
  readFileSync as readFileSync8,
15024
15070
  renameSync as renameSync2,
15071
+ statSync as statSync3,
15025
15072
  unlinkSync as unlinkSync2,
15026
15073
  writeFileSync as writeFileSync3
15027
15074
  } from "fs";
15028
- import { join as join9, normalize } from "path";
15075
+ import { join as join10, normalize } from "path";
15029
15076
  function isAddrInUse(e) {
15030
15077
  if (e && typeof e === "object" && "code" in e) {
15031
15078
  return e.code === "EADDRINUSE";
@@ -15320,17 +15367,30 @@ async function backoff(attempt) {
15320
15367
  await Bun.sleep(backoffFloorMs(attempt) + Math.floor(Math.random() * 150));
15321
15368
  }
15322
15369
  function isLauncherPinned() {
15370
+ const pin = readPinnedRoot();
15371
+ return pin !== null && isRunnableRoot(pin);
15372
+ }
15373
+ function readPinnedRoot() {
15323
15374
  try {
15324
15375
  const text = readFileSync8(launcherPinnedRootFile(), "utf8");
15325
15376
  const nl = text.indexOf(`
15326
15377
  `);
15327
15378
  if (nl < 0)
15328
- return false;
15329
- const root = text.slice(0, nl).trim();
15330
- if (!root)
15331
- return false;
15332
- accessSync(join9(root, "bin", "caret"), constants.X_OK);
15333
- return true;
15379
+ return null;
15380
+ return text.slice(0, nl).trim() || null;
15381
+ } catch {
15382
+ return null;
15383
+ }
15384
+ }
15385
+ function isRunnableRoot(root) {
15386
+ try {
15387
+ accessSync(join10(root, "bin", "caret"), constants.X_OK);
15388
+ try {
15389
+ accessSync(join10(root, "bin", "caret-native"), constants.X_OK);
15390
+ return true;
15391
+ } catch {
15392
+ return statSync3(join10(root, "ui", "dist", "index.html")).isFile();
15393
+ }
15334
15394
  } catch {
15335
15395
  return false;
15336
15396
  }
@@ -15338,7 +15398,7 @@ function isLauncherPinned() {
15338
15398
  async function prodEnsureDeps(s, service, reserveMs) {
15339
15399
  const world = stateDir();
15340
15400
  return {
15341
- service: existsSync6(launcherServiceFile()) ? service() : undefined,
15401
+ service: existsSync7(launcherServiceFile()) ? service() : undefined,
15342
15402
  pinned: isLauncherPinned(),
15343
15403
  baseUrl: `http://localhost:${getPort(s)}`,
15344
15404
  currentBuild: await currentBuildId(),
@@ -15372,7 +15432,7 @@ var init_lifecycle = __esm(() => {
15372
15432
  SUPERVISOR_WINDOW_MS = Array.from({ length: PROD_MAX_ATTEMPTS }, (_, attempt) => backoffFloorMs(attempt)).reduce((sum, ms) => sum + ms, 0);
15373
15433
  });
15374
15434
 
15375
- // node_modules/.bun/fast-string-truncated-width@3.0.3/node_modules/fast-string-truncated-width/dist/utils.js
15435
+ // node_modules/fast-string-truncated-width/dist/utils.js
15376
15436
  var getCodePointsLength, isFullWidth = (x) => {
15377
15437
  return x === 12288 || x >= 65281 && x <= 65376 || x >= 65504 && x <= 65510;
15378
15438
  }, isWideNotCJKTNotEmoji = (x) => {
@@ -15392,7 +15452,7 @@ var init_utils = __esm(() => {
15392
15452
  })();
15393
15453
  });
15394
15454
 
15395
- // node_modules/.bun/fast-string-truncated-width@3.0.3/node_modules/fast-string-truncated-width/dist/index.js
15455
+ // node_modules/fast-string-truncated-width/dist/index.js
15396
15456
  var ANSI_RE, CONTROL_RE2, CJKT_WIDE_RE, TAB_RE, EMOJI_RE, LATIN_RE, MODIFIER_RE, NO_TRUNCATION, getStringTruncatedWidth = (input, truncationOptions = {}, widthOptions = {}) => {
15397
15457
  const LIMIT = truncationOptions.limit ?? Infinity;
15398
15458
  const ELLIPSIS = truncationOptions.ellipsis ?? "";
@@ -15494,7 +15554,7 @@ var init_dist2 = __esm(() => {
15494
15554
  dist_default = getStringTruncatedWidth;
15495
15555
  });
15496
15556
 
15497
- // node_modules/.bun/fast-string-width@3.0.2/node_modules/fast-string-width/dist/index.js
15557
+ // node_modules/fast-string-width/dist/index.js
15498
15558
  var NO_TRUNCATION2, fastStringWidth = (input, options = {}) => {
15499
15559
  return dist_default(input, NO_TRUNCATION2, options).width;
15500
15560
  }, dist_default2;
@@ -15508,7 +15568,7 @@ var init_dist3 = __esm(() => {
15508
15568
  dist_default2 = fastStringWidth;
15509
15569
  });
15510
15570
 
15511
- // node_modules/.bun/fast-wrap-ansi@0.2.2/node_modules/fast-wrap-ansi/lib/main.js
15571
+ // node_modules/fast-wrap-ansi/lib/main.js
15512
15572
  function wrapAnsi(string, columns, options) {
15513
15573
  return String(string).normalize().split(CRLF_OR_LF).map((line) => exec(line, columns, options)).join(`
15514
15574
  `);
@@ -15711,7 +15771,7 @@ var init_main2 = __esm(() => {
15711
15771
  CRLF_OR_LF = /\r?\n/;
15712
15772
  });
15713
15773
 
15714
- // node_modules/.bun/sisteransi@1.0.5/node_modules/sisteransi/src/index.js
15774
+ // node_modules/sisteransi/src/index.js
15715
15775
  var require_src = __commonJS(function(exports, module) {
15716
15776
  var ESC = "\x1B";
15717
15777
  var CSI = `${ESC}[`;
@@ -15769,7 +15829,7 @@ var require_src = __commonJS(function(exports, module) {
15769
15829
  module.exports = { cursor, scroll, erase, beep };
15770
15830
  });
15771
15831
 
15772
- // node_modules/.bun/@clack+core@1.4.3/node_modules/@clack/core/dist/index.mjs
15832
+ // node_modules/@clack/core/dist/index.mjs
15773
15833
  import { styleText } from "util";
15774
15834
  import { stdout, stdin } from "process";
15775
15835
  import * as l from "readline";
@@ -16687,7 +16747,7 @@ ${i}` : `${s}${styleText("inverse", r)}${i}`;
16687
16747
  };
16688
16748
  });
16689
16749
 
16690
- // node_modules/.bun/@clack+prompts@1.7.0/node_modules/@clack/prompts/dist/index.mjs
16750
+ // node_modules/@clack/prompts/dist/index.mjs
16691
16751
  var exports_dist = {};
16692
16752
  __export(exports_dist, {
16693
16753
  MULTISELECT_INSTRUCTIONS: () => MULTISELECT_INSTRUCTIONS,
@@ -16755,8 +16815,8 @@ __export(exports_dist, {
16755
16815
  });
16756
16816
  import { styleText as styleText2, stripVTControlCharacters } from "util";
16757
16817
  import process$1 from "process";
16758
- import { existsSync as existsSync10, lstatSync, readdirSync as readdirSync4 } from "fs";
16759
- import { dirname as dirname8, join as join15 } from "path";
16818
+ import { existsSync as existsSync11, lstatSync, readdirSync as readdirSync4 } from "fs";
16819
+ import { dirname as dirname8, join as join16 } from "path";
16760
16820
  function isUnicodeSupported() {
16761
16821
  if (process$1.platform !== "win32") {
16762
16822
  return process$1.env.TERM !== "linux";
@@ -17467,10 +17527,10 @@ ${n}
17467
17527
  return [];
17468
17528
  try {
17469
17529
  let i;
17470
- existsSync10(t) ? lstatSync(t).isDirectory() && (!e.directory || t.endsWith("/")) ? i = t : i = dirname8(t) : i = dirname8(t);
17530
+ existsSync11(t) ? lstatSync(t).isDirectory() && (!e.directory || t.endsWith("/")) ? i = t : i = dirname8(t) : i = dirname8(t);
17471
17531
  const c = t.length > 1 && t.endsWith("/") ? t.slice(0, -1) : t;
17472
17532
  return readdirSync4(i).map((r) => {
17473
- const n = join15(i, r), m = lstatSync(n);
17533
+ const n = join16(i, r), m = lstatSync(n);
17474
17534
  return {
17475
17535
  name: r,
17476
17536
  path: n,
@@ -18068,7 +18128,7 @@ var PLAN_TITLE_INSTRUCTION = "Start the plan with a single `# <title>` heading t
18068
18128
  });
18069
18129
  var init_review_bridge = () => {};
18070
18130
 
18071
- // node_modules/.bun/zod@4.5.4/node_modules/zod/v3/helpers/util.js
18131
+ // node_modules/zod/v3/helpers/util.js
18072
18132
  var util, objectUtil, ZodParsedType, getParsedType = (data) => {
18073
18133
  const t = typeof data;
18074
18134
  switch (t) {
@@ -18199,7 +18259,7 @@ var init_util3 = __esm(() => {
18199
18259
  ]);
18200
18260
  });
18201
18261
 
18202
- // node_modules/.bun/zod@4.5.4/node_modules/zod/v3/ZodError.js
18262
+ // node_modules/zod/v3/ZodError.js
18203
18263
  var ZodIssueCode, ZodError;
18204
18264
  var init_ZodError = __esm(() => {
18205
18265
  init_util3();
@@ -18332,7 +18392,7 @@ var init_ZodError = __esm(() => {
18332
18392
  };
18333
18393
  });
18334
18394
 
18335
- // node_modules/.bun/zod@4.5.4/node_modules/zod/v3/locales/en.js
18395
+ // node_modules/zod/v3/locales/en.js
18336
18396
  var errorMap = (issue, _ctx) => {
18337
18397
  let message;
18338
18398
  switch (issue.code) {
@@ -18439,7 +18499,7 @@ var init_en2 = __esm(() => {
18439
18499
  en_default2 = errorMap;
18440
18500
  });
18441
18501
 
18442
- // node_modules/.bun/zod@4.5.4/node_modules/zod/v3/errors.js
18502
+ // node_modules/zod/v3/errors.js
18443
18503
  function getErrorMap() {
18444
18504
  return overrideErrorMap;
18445
18505
  }
@@ -18449,7 +18509,7 @@ var init_errors3 = __esm(() => {
18449
18509
  overrideErrorMap = en_default2;
18450
18510
  });
18451
18511
 
18452
- // node_modules/.bun/zod@4.5.4/node_modules/zod/v3/helpers/parseUtil.js
18512
+ // node_modules/zod/v3/helpers/parseUtil.js
18453
18513
  function addIssueToContext(ctx, issueData) {
18454
18514
  const overrideMap = getErrorMap();
18455
18515
  const issue = makeIssue({
@@ -18553,10 +18613,10 @@ var init_parseUtil = __esm(() => {
18553
18613
  });
18554
18614
  });
18555
18615
 
18556
- // node_modules/.bun/zod@4.5.4/node_modules/zod/v3/helpers/typeAliases.js
18616
+ // node_modules/zod/v3/helpers/typeAliases.js
18557
18617
  var init_typeAliases = () => {};
18558
18618
 
18559
- // node_modules/.bun/zod@4.5.4/node_modules/zod/v3/helpers/errorUtil.js
18619
+ // node_modules/zod/v3/helpers/errorUtil.js
18560
18620
  var errorUtil;
18561
18621
  var init_errorUtil = __esm(() => {
18562
18622
  (function(errorUtil) {
@@ -18565,7 +18625,7 @@ var init_errorUtil = __esm(() => {
18565
18625
  })(errorUtil || (errorUtil = {}));
18566
18626
  });
18567
18627
 
18568
- // node_modules/.bun/zod@4.5.4/node_modules/zod/v3/types.js
18628
+ // node_modules/zod/v3/types.js
18569
18629
  class ParseInputLazyPath {
18570
18630
  constructor(parent, value, path, key) {
18571
18631
  this._cachedPath = [];
@@ -21880,7 +21940,7 @@ var init_types = __esm(() => {
21880
21940
  pipelineType = ZodPipeline.create;
21881
21941
  });
21882
21942
 
21883
- // node_modules/.bun/zod@4.5.4/node_modules/zod/v3/external.js
21943
+ // node_modules/zod/v3/external.js
21884
21944
  var init_external2 = __esm(() => {
21885
21945
  init_errors3();
21886
21946
  init_parseUtil();
@@ -21890,17 +21950,17 @@ var init_external2 = __esm(() => {
21890
21950
  init_ZodError();
21891
21951
  });
21892
21952
 
21893
- // node_modules/.bun/zod@4.5.4/node_modules/zod/v3/index.js
21953
+ // node_modules/zod/v3/index.js
21894
21954
  var init_v3 = __esm(() => {
21895
21955
  init_external2();
21896
21956
  });
21897
21957
 
21898
- // node_modules/.bun/zod@4.5.4/node_modules/zod/v4/mini/parse.js
21958
+ // node_modules/zod/v4/mini/parse.js
21899
21959
  var init_parse4 = __esm(() => {
21900
21960
  init_core2();
21901
21961
  });
21902
21962
 
21903
- // node_modules/.bun/zod@4.5.4/node_modules/zod/v4/mini/schemas.js
21963
+ // node_modules/zod/v4/mini/schemas.js
21904
21964
  function object2(shape, params) {
21905
21965
  const def = {
21906
21966
  type: "object",
@@ -21970,16 +22030,16 @@ var init_schemas3 = __esm(() => {
21970
22030
  });
21971
22031
  });
21972
22032
 
21973
- // node_modules/.bun/zod@4.5.4/node_modules/zod/v4/mini/checks.js
22033
+ // node_modules/zod/v4/mini/checks.js
21974
22034
  var init_checks3 = () => {};
21975
22035
 
21976
- // node_modules/.bun/zod@4.5.4/node_modules/zod/v4/mini/iso.js
22036
+ // node_modules/zod/v4/mini/iso.js
21977
22037
  var init_iso2 = () => {};
21978
22038
 
21979
- // node_modules/.bun/zod@4.5.4/node_modules/zod/v4/mini/coerce.js
22039
+ // node_modules/zod/v4/mini/coerce.js
21980
22040
  var init_coerce2 = () => {};
21981
22041
 
21982
- // node_modules/.bun/zod@4.5.4/node_modules/zod/v4/mini/external.js
22042
+ // node_modules/zod/v4/mini/external.js
21983
22043
  var init_external3 = __esm(() => {
21984
22044
  init_core2();
21985
22045
  init_json_schema_processors();
@@ -21991,12 +22051,12 @@ var init_external3 = __esm(() => {
21991
22051
  init_checks3();
21992
22052
  });
21993
22053
 
21994
- // node_modules/.bun/zod@4.5.4/node_modules/zod/v4-mini/index.js
22054
+ // node_modules/zod/v4-mini/index.js
21995
22055
  var init_v4_mini = __esm(() => {
21996
22056
  init_external3();
21997
22057
  });
21998
22058
 
21999
- // node_modules/.bun/@modelcontextprotocol+sdk@1.30.0/node_modules/@modelcontextprotocol/sdk/dist/esm/server/zod-compat.js
22059
+ // node_modules/@modelcontextprotocol/sdk/dist/esm/server/zod-compat.js
22000
22060
  function isZ4Schema(s) {
22001
22061
  const schema = s;
22002
22062
  return !!schema._zod;
@@ -22161,17 +22221,17 @@ var init_zod_compat = __esm(() => {
22161
22221
  init_v4_mini();
22162
22222
  });
22163
22223
 
22164
- // node_modules/.bun/zod@4.5.4/node_modules/zod/v4/classic/index.js
22224
+ // node_modules/zod/v4/classic/index.js
22165
22225
  var init_classic = __esm(() => {
22166
22226
  init_external();
22167
22227
  });
22168
22228
 
22169
- // node_modules/.bun/zod@4.5.4/node_modules/zod/v4/index.js
22229
+ // node_modules/zod/v4/index.js
22170
22230
  var init_v4 = __esm(() => {
22171
22231
  init_classic();
22172
22232
  });
22173
22233
 
22174
- // node_modules/.bun/@modelcontextprotocol+sdk@1.30.0/node_modules/@modelcontextprotocol/sdk/dist/esm/types.js
22234
+ // node_modules/@modelcontextprotocol/sdk/dist/esm/types.js
22175
22235
  function assertCompleteRequestPrompt(request) {
22176
22236
  if (request.params.ref.type !== "ref/prompt") {
22177
22237
  throw new TypeError(`Expected CompleteRequestPrompt, but got ${request.params.ref.type}`);
@@ -23009,12 +23069,12 @@ var init_types2 = __esm(() => {
23009
23069
  };
23010
23070
  });
23011
23071
 
23012
- // node_modules/.bun/@modelcontextprotocol+sdk@1.30.0/node_modules/@modelcontextprotocol/sdk/dist/esm/experimental/tasks/interfaces.js
23072
+ // node_modules/@modelcontextprotocol/sdk/dist/esm/experimental/tasks/interfaces.js
23013
23073
  function isTerminal2(status) {
23014
23074
  return status === "completed" || status === "failed" || status === "cancelled";
23015
23075
  }
23016
23076
 
23017
- // node_modules/.bun/zod-to-json-schema@3.25.2+ab3ed8e9421bfd7b/node_modules/zod-to-json-schema/dist/esm/Options.js
23077
+ // node_modules/zod-to-json-schema/dist/esm/Options.js
23018
23078
  var ignoreOverride, defaultOptions, getDefaultOptions = (options) => typeof options === "string" ? {
23019
23079
  ...defaultOptions,
23020
23080
  name: options
@@ -23050,7 +23110,7 @@ var init_Options = __esm(() => {
23050
23110
  };
23051
23111
  });
23052
23112
 
23053
- // node_modules/.bun/zod-to-json-schema@3.25.2+ab3ed8e9421bfd7b/node_modules/zod-to-json-schema/dist/esm/Refs.js
23113
+ // node_modules/zod-to-json-schema/dist/esm/Refs.js
23054
23114
  var getRefs = (options) => {
23055
23115
  const _options = getDefaultOptions(options);
23056
23116
  const currentPath = _options.name !== undefined ? [..._options.basePath, _options.definitionPath, _options.name] : _options.basePath;
@@ -23073,7 +23133,7 @@ var init_Refs = __esm(() => {
23073
23133
  init_Options();
23074
23134
  });
23075
23135
 
23076
- // node_modules/.bun/zod-to-json-schema@3.25.2+ab3ed8e9421bfd7b/node_modules/zod-to-json-schema/dist/esm/errorMessages.js
23136
+ // node_modules/zod-to-json-schema/dist/esm/errorMessages.js
23077
23137
  function addErrorMessage(res, key, errorMessage, refs) {
23078
23138
  if (!refs?.errorMessages)
23079
23139
  return;
@@ -23089,7 +23149,7 @@ function setResponseValueAndErrors(res, key, value, errorMessage, refs) {
23089
23149
  addErrorMessage(res, key, errorMessage, refs);
23090
23150
  }
23091
23151
 
23092
- // node_modules/.bun/zod-to-json-schema@3.25.2+ab3ed8e9421bfd7b/node_modules/zod-to-json-schema/dist/esm/getRelativePath.js
23152
+ // node_modules/zod-to-json-schema/dist/esm/getRelativePath.js
23093
23153
  var getRelativePath = (pathA, pathB) => {
23094
23154
  let i = 0;
23095
23155
  for (;i < pathA.length && i < pathB.length; i++) {
@@ -23099,7 +23159,7 @@ var getRelativePath = (pathA, pathB) => {
23099
23159
  return [(pathA.length - i).toString(), ...pathB.slice(i)].join("/");
23100
23160
  };
23101
23161
 
23102
- // node_modules/.bun/zod-to-json-schema@3.25.2+ab3ed8e9421bfd7b/node_modules/zod-to-json-schema/dist/esm/parsers/any.js
23162
+ // node_modules/zod-to-json-schema/dist/esm/parsers/any.js
23103
23163
  function parseAnyDef(refs) {
23104
23164
  if (refs.target !== "openAi") {
23105
23165
  return {};
@@ -23116,7 +23176,7 @@ function parseAnyDef(refs) {
23116
23176
  }
23117
23177
  var init_any = () => {};
23118
23178
 
23119
- // node_modules/.bun/zod-to-json-schema@3.25.2+ab3ed8e9421bfd7b/node_modules/zod-to-json-schema/dist/esm/parsers/array.js
23179
+ // node_modules/zod-to-json-schema/dist/esm/parsers/array.js
23120
23180
  function parseArrayDef(def, refs) {
23121
23181
  const res = {
23122
23182
  type: "array"
@@ -23144,7 +23204,7 @@ var init_array = __esm(() => {
23144
23204
  init_parseDef();
23145
23205
  });
23146
23206
 
23147
- // node_modules/.bun/zod-to-json-schema@3.25.2+ab3ed8e9421bfd7b/node_modules/zod-to-json-schema/dist/esm/parsers/bigint.js
23207
+ // node_modules/zod-to-json-schema/dist/esm/parsers/bigint.js
23148
23208
  function parseBigintDef(def, refs) {
23149
23209
  const res = {
23150
23210
  type: "integer",
@@ -23191,14 +23251,14 @@ function parseBigintDef(def, refs) {
23191
23251
  }
23192
23252
  var init_bigint = () => {};
23193
23253
 
23194
- // node_modules/.bun/zod-to-json-schema@3.25.2+ab3ed8e9421bfd7b/node_modules/zod-to-json-schema/dist/esm/parsers/boolean.js
23254
+ // node_modules/zod-to-json-schema/dist/esm/parsers/boolean.js
23195
23255
  function parseBooleanDef() {
23196
23256
  return {
23197
23257
  type: "boolean"
23198
23258
  };
23199
23259
  }
23200
23260
 
23201
- // node_modules/.bun/zod-to-json-schema@3.25.2+ab3ed8e9421bfd7b/node_modules/zod-to-json-schema/dist/esm/parsers/branded.js
23261
+ // node_modules/zod-to-json-schema/dist/esm/parsers/branded.js
23202
23262
  function parseBrandedDef(_def, refs) {
23203
23263
  return parseDef(_def.type._def, refs);
23204
23264
  }
@@ -23206,7 +23266,7 @@ var init_branded = __esm(() => {
23206
23266
  init_parseDef();
23207
23267
  });
23208
23268
 
23209
- // node_modules/.bun/zod-to-json-schema@3.25.2+ab3ed8e9421bfd7b/node_modules/zod-to-json-schema/dist/esm/parsers/catch.js
23269
+ // node_modules/zod-to-json-schema/dist/esm/parsers/catch.js
23210
23270
  var parseCatchDef = (def, refs) => {
23211
23271
  return parseDef(def.innerType._def, refs);
23212
23272
  };
@@ -23214,7 +23274,7 @@ var init_catch = __esm(() => {
23214
23274
  init_parseDef();
23215
23275
  });
23216
23276
 
23217
- // node_modules/.bun/zod-to-json-schema@3.25.2+ab3ed8e9421bfd7b/node_modules/zod-to-json-schema/dist/esm/parsers/date.js
23277
+ // node_modules/zod-to-json-schema/dist/esm/parsers/date.js
23218
23278
  function parseDateDef(def, refs, overrideDateStrategy) {
23219
23279
  const strategy = overrideDateStrategy ?? refs.dateStrategy;
23220
23280
  if (Array.isArray(strategy)) {
@@ -23260,7 +23320,7 @@ var integerDateParser = (def, refs) => {
23260
23320
  };
23261
23321
  var init_date2 = () => {};
23262
23322
 
23263
- // node_modules/.bun/zod-to-json-schema@3.25.2+ab3ed8e9421bfd7b/node_modules/zod-to-json-schema/dist/esm/parsers/default.js
23323
+ // node_modules/zod-to-json-schema/dist/esm/parsers/default.js
23264
23324
  function parseDefaultDef(_def, refs) {
23265
23325
  return {
23266
23326
  ...parseDef(_def.innerType._def, refs),
@@ -23271,7 +23331,7 @@ var init_default = __esm(() => {
23271
23331
  init_parseDef();
23272
23332
  });
23273
23333
 
23274
- // node_modules/.bun/zod-to-json-schema@3.25.2+ab3ed8e9421bfd7b/node_modules/zod-to-json-schema/dist/esm/parsers/effects.js
23334
+ // node_modules/zod-to-json-schema/dist/esm/parsers/effects.js
23275
23335
  function parseEffectsDef(_def, refs) {
23276
23336
  return refs.effectStrategy === "input" ? parseDef(_def.schema._def, refs) : parseAnyDef(refs);
23277
23337
  }
@@ -23280,7 +23340,7 @@ var init_effects = __esm(() => {
23280
23340
  init_any();
23281
23341
  });
23282
23342
 
23283
- // node_modules/.bun/zod-to-json-schema@3.25.2+ab3ed8e9421bfd7b/node_modules/zod-to-json-schema/dist/esm/parsers/enum.js
23343
+ // node_modules/zod-to-json-schema/dist/esm/parsers/enum.js
23284
23344
  function parseEnumDef(def) {
23285
23345
  return {
23286
23346
  type: "string",
@@ -23288,7 +23348,7 @@ function parseEnumDef(def) {
23288
23348
  };
23289
23349
  }
23290
23350
 
23291
- // node_modules/.bun/zod-to-json-schema@3.25.2+ab3ed8e9421bfd7b/node_modules/zod-to-json-schema/dist/esm/parsers/intersection.js
23351
+ // node_modules/zod-to-json-schema/dist/esm/parsers/intersection.js
23292
23352
  function parseIntersectionDef(def, refs) {
23293
23353
  const allOf = [
23294
23354
  parseDef(def.left._def, {
@@ -23333,7 +23393,7 @@ var init_intersection = __esm(() => {
23333
23393
  init_parseDef();
23334
23394
  });
23335
23395
 
23336
- // node_modules/.bun/zod-to-json-schema@3.25.2+ab3ed8e9421bfd7b/node_modules/zod-to-json-schema/dist/esm/parsers/literal.js
23396
+ // node_modules/zod-to-json-schema/dist/esm/parsers/literal.js
23337
23397
  function parseLiteralDef(def, refs) {
23338
23398
  const parsedType = typeof def.value;
23339
23399
  if (parsedType !== "bigint" && parsedType !== "number" && parsedType !== "boolean" && parsedType !== "string") {
@@ -23353,7 +23413,7 @@ function parseLiteralDef(def, refs) {
23353
23413
  };
23354
23414
  }
23355
23415
 
23356
- // node_modules/.bun/zod-to-json-schema@3.25.2+ab3ed8e9421bfd7b/node_modules/zod-to-json-schema/dist/esm/parsers/string.js
23416
+ // node_modules/zod-to-json-schema/dist/esm/parsers/string.js
23357
23417
  function parseStringDef(def, refs) {
23358
23418
  const res = {
23359
23419
  type: "string"
@@ -23652,7 +23712,7 @@ var init_string = __esm(() => {
23652
23712
  ALPHA_NUMERIC = new Set("ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789");
23653
23713
  });
23654
23714
 
23655
- // node_modules/.bun/zod-to-json-schema@3.25.2+ab3ed8e9421bfd7b/node_modules/zod-to-json-schema/dist/esm/parsers/record.js
23715
+ // node_modules/zod-to-json-schema/dist/esm/parsers/record.js
23656
23716
  function parseRecordDef(def, refs) {
23657
23717
  if (refs.target === "openAi") {
23658
23718
  console.warn("Warning: OpenAI may not support records in schemas! Try an array of key-value pairs instead.");
@@ -23711,7 +23771,7 @@ var init_record = __esm(() => {
23711
23771
  init_any();
23712
23772
  });
23713
23773
 
23714
- // node_modules/.bun/zod-to-json-schema@3.25.2+ab3ed8e9421bfd7b/node_modules/zod-to-json-schema/dist/esm/parsers/map.js
23774
+ // node_modules/zod-to-json-schema/dist/esm/parsers/map.js
23715
23775
  function parseMapDef(def, refs) {
23716
23776
  if (refs.mapStrategy === "record") {
23717
23777
  return parseRecordDef(def, refs);
@@ -23741,7 +23801,7 @@ var init_map = __esm(() => {
23741
23801
  init_any();
23742
23802
  });
23743
23803
 
23744
- // node_modules/.bun/zod-to-json-schema@3.25.2+ab3ed8e9421bfd7b/node_modules/zod-to-json-schema/dist/esm/parsers/nativeEnum.js
23804
+ // node_modules/zod-to-json-schema/dist/esm/parsers/nativeEnum.js
23745
23805
  function parseNativeEnumDef(def) {
23746
23806
  const object = def.values;
23747
23807
  const actualKeys = Object.keys(def.values).filter((key) => {
@@ -23755,7 +23815,7 @@ function parseNativeEnumDef(def) {
23755
23815
  };
23756
23816
  }
23757
23817
 
23758
- // node_modules/.bun/zod-to-json-schema@3.25.2+ab3ed8e9421bfd7b/node_modules/zod-to-json-schema/dist/esm/parsers/never.js
23818
+ // node_modules/zod-to-json-schema/dist/esm/parsers/never.js
23759
23819
  function parseNeverDef(refs) {
23760
23820
  return refs.target === "openAi" ? undefined : {
23761
23821
  not: parseAnyDef({
@@ -23768,7 +23828,7 @@ var init_never = __esm(() => {
23768
23828
  init_any();
23769
23829
  });
23770
23830
 
23771
- // node_modules/.bun/zod-to-json-schema@3.25.2+ab3ed8e9421bfd7b/node_modules/zod-to-json-schema/dist/esm/parsers/null.js
23831
+ // node_modules/zod-to-json-schema/dist/esm/parsers/null.js
23772
23832
  function parseNullDef(refs) {
23773
23833
  return refs.target === "openApi3" ? {
23774
23834
  enum: ["null"],
@@ -23778,7 +23838,7 @@ function parseNullDef(refs) {
23778
23838
  };
23779
23839
  }
23780
23840
 
23781
- // node_modules/.bun/zod-to-json-schema@3.25.2+ab3ed8e9421bfd7b/node_modules/zod-to-json-schema/dist/esm/parsers/union.js
23841
+ // node_modules/zod-to-json-schema/dist/esm/parsers/union.js
23782
23842
  function parseUnionDef(def, refs) {
23783
23843
  if (refs.target === "openApi3")
23784
23844
  return asAnyOf(def, refs);
@@ -23849,7 +23909,7 @@ var init_union = __esm(() => {
23849
23909
  };
23850
23910
  });
23851
23911
 
23852
- // node_modules/.bun/zod-to-json-schema@3.25.2+ab3ed8e9421bfd7b/node_modules/zod-to-json-schema/dist/esm/parsers/nullable.js
23912
+ // node_modules/zod-to-json-schema/dist/esm/parsers/nullable.js
23853
23913
  function parseNullableDef(def, refs) {
23854
23914
  if (["ZodString", "ZodNumber", "ZodBigInt", "ZodBoolean", "ZodNull"].includes(def.innerType._def.typeName) && (!def.innerType._def.checks || !def.innerType._def.checks.length)) {
23855
23915
  if (refs.target === "openApi3") {
@@ -23885,7 +23945,7 @@ var init_nullable = __esm(() => {
23885
23945
  init_union();
23886
23946
  });
23887
23947
 
23888
- // node_modules/.bun/zod-to-json-schema@3.25.2+ab3ed8e9421bfd7b/node_modules/zod-to-json-schema/dist/esm/parsers/number.js
23948
+ // node_modules/zod-to-json-schema/dist/esm/parsers/number.js
23889
23949
  function parseNumberDef(def, refs) {
23890
23950
  const res = {
23891
23951
  type: "number"
@@ -23935,7 +23995,7 @@ function parseNumberDef(def, refs) {
23935
23995
  }
23936
23996
  var init_number = () => {};
23937
23997
 
23938
- // node_modules/.bun/zod-to-json-schema@3.25.2+ab3ed8e9421bfd7b/node_modules/zod-to-json-schema/dist/esm/parsers/object.js
23998
+ // node_modules/zod-to-json-schema/dist/esm/parsers/object.js
23939
23999
  function parseObjectDef(def, refs) {
23940
24000
  const forceOptionalIntoNullable = refs.target === "openAi";
23941
24001
  const result = {
@@ -24008,7 +24068,7 @@ var init_object = __esm(() => {
24008
24068
  init_parseDef();
24009
24069
  });
24010
24070
 
24011
- // node_modules/.bun/zod-to-json-schema@3.25.2+ab3ed8e9421bfd7b/node_modules/zod-to-json-schema/dist/esm/parsers/optional.js
24071
+ // node_modules/zod-to-json-schema/dist/esm/parsers/optional.js
24012
24072
  var parseOptionalDef = (def, refs) => {
24013
24073
  if (refs.currentPath.toString() === refs.propertyPath?.toString()) {
24014
24074
  return parseDef(def.innerType._def, refs);
@@ -24031,7 +24091,7 @@ var init_optional = __esm(() => {
24031
24091
  init_any();
24032
24092
  });
24033
24093
 
24034
- // node_modules/.bun/zod-to-json-schema@3.25.2+ab3ed8e9421bfd7b/node_modules/zod-to-json-schema/dist/esm/parsers/pipeline.js
24094
+ // node_modules/zod-to-json-schema/dist/esm/parsers/pipeline.js
24035
24095
  var parsePipelineDef = (def, refs) => {
24036
24096
  if (refs.pipeStrategy === "input") {
24037
24097
  return parseDef(def.in._def, refs);
@@ -24054,7 +24114,7 @@ var init_pipeline = __esm(() => {
24054
24114
  init_parseDef();
24055
24115
  });
24056
24116
 
24057
- // node_modules/.bun/zod-to-json-schema@3.25.2+ab3ed8e9421bfd7b/node_modules/zod-to-json-schema/dist/esm/parsers/promise.js
24117
+ // node_modules/zod-to-json-schema/dist/esm/parsers/promise.js
24058
24118
  function parsePromiseDef(def, refs) {
24059
24119
  return parseDef(def.type._def, refs);
24060
24120
  }
@@ -24062,7 +24122,7 @@ var init_promise = __esm(() => {
24062
24122
  init_parseDef();
24063
24123
  });
24064
24124
 
24065
- // node_modules/.bun/zod-to-json-schema@3.25.2+ab3ed8e9421bfd7b/node_modules/zod-to-json-schema/dist/esm/parsers/set.js
24125
+ // node_modules/zod-to-json-schema/dist/esm/parsers/set.js
24066
24126
  function parseSetDef(def, refs) {
24067
24127
  const items = parseDef(def.valueType._def, {
24068
24128
  ...refs,
@@ -24085,7 +24145,7 @@ var init_set = __esm(() => {
24085
24145
  init_parseDef();
24086
24146
  });
24087
24147
 
24088
- // node_modules/.bun/zod-to-json-schema@3.25.2+ab3ed8e9421bfd7b/node_modules/zod-to-json-schema/dist/esm/parsers/tuple.js
24148
+ // node_modules/zod-to-json-schema/dist/esm/parsers/tuple.js
24089
24149
  function parseTupleDef(def, refs) {
24090
24150
  if (def.rest) {
24091
24151
  return {
@@ -24116,7 +24176,7 @@ var init_tuple = __esm(() => {
24116
24176
  init_parseDef();
24117
24177
  });
24118
24178
 
24119
- // node_modules/.bun/zod-to-json-schema@3.25.2+ab3ed8e9421bfd7b/node_modules/zod-to-json-schema/dist/esm/parsers/undefined.js
24179
+ // node_modules/zod-to-json-schema/dist/esm/parsers/undefined.js
24120
24180
  function parseUndefinedDef(refs) {
24121
24181
  return {
24122
24182
  not: parseAnyDef(refs)
@@ -24126,7 +24186,7 @@ var init_undefined = __esm(() => {
24126
24186
  init_any();
24127
24187
  });
24128
24188
 
24129
- // node_modules/.bun/zod-to-json-schema@3.25.2+ab3ed8e9421bfd7b/node_modules/zod-to-json-schema/dist/esm/parsers/unknown.js
24189
+ // node_modules/zod-to-json-schema/dist/esm/parsers/unknown.js
24130
24190
  function parseUnknownDef(refs) {
24131
24191
  return parseAnyDef(refs);
24132
24192
  }
@@ -24134,7 +24194,7 @@ var init_unknown = __esm(() => {
24134
24194
  init_any();
24135
24195
  });
24136
24196
 
24137
- // node_modules/.bun/zod-to-json-schema@3.25.2+ab3ed8e9421bfd7b/node_modules/zod-to-json-schema/dist/esm/parsers/readonly.js
24197
+ // node_modules/zod-to-json-schema/dist/esm/parsers/readonly.js
24138
24198
  var parseReadonlyDef = (def, refs) => {
24139
24199
  return parseDef(def.innerType._def, refs);
24140
24200
  };
@@ -24142,7 +24202,7 @@ var init_readonly = __esm(() => {
24142
24202
  init_parseDef();
24143
24203
  });
24144
24204
 
24145
- // node_modules/.bun/zod-to-json-schema@3.25.2+ab3ed8e9421bfd7b/node_modules/zod-to-json-schema/dist/esm/selectParser.js
24205
+ // node_modules/zod-to-json-schema/dist/esm/selectParser.js
24146
24206
  var selectParser = (def, typeName, refs) => {
24147
24207
  switch (typeName) {
24148
24208
  case ZodFirstPartyTypeKind2.ZodString:
@@ -24248,7 +24308,7 @@ var init_selectParser = __esm(() => {
24248
24308
  init_readonly();
24249
24309
  });
24250
24310
 
24251
- // node_modules/.bun/zod-to-json-schema@3.25.2+ab3ed8e9421bfd7b/node_modules/zod-to-json-schema/dist/esm/parseDef.js
24311
+ // node_modules/zod-to-json-schema/dist/esm/parseDef.js
24252
24312
  function parseDef(def, refs, forceResolution = false) {
24253
24313
  const seenItem = refs.seen.get(def);
24254
24314
  if (refs.override) {
@@ -24308,10 +24368,10 @@ var init_parseDef = __esm(() => {
24308
24368
  init_any();
24309
24369
  });
24310
24370
 
24311
- // node_modules/.bun/zod-to-json-schema@3.25.2+ab3ed8e9421bfd7b/node_modules/zod-to-json-schema/dist/esm/parseTypes.js
24371
+ // node_modules/zod-to-json-schema/dist/esm/parseTypes.js
24312
24372
  var init_parseTypes = () => {};
24313
24373
 
24314
- // node_modules/.bun/zod-to-json-schema@3.25.2+ab3ed8e9421bfd7b/node_modules/zod-to-json-schema/dist/esm/zodToJsonSchema.js
24374
+ // node_modules/zod-to-json-schema/dist/esm/zodToJsonSchema.js
24315
24375
  var zodToJsonSchema = (schema, options) => {
24316
24376
  const refs = getRefs(options);
24317
24377
  let definitions = typeof options === "object" && options.definitions ? Object.entries(options.definitions).reduce((acc, [name, schema]) => ({
@@ -24377,7 +24437,7 @@ var init_zodToJsonSchema = __esm(() => {
24377
24437
  init_any();
24378
24438
  });
24379
24439
 
24380
- // node_modules/.bun/zod-to-json-schema@3.25.2+ab3ed8e9421bfd7b/node_modules/zod-to-json-schema/dist/esm/index.js
24440
+ // node_modules/zod-to-json-schema/dist/esm/index.js
24381
24441
  var init_esm = __esm(() => {
24382
24442
  init_zodToJsonSchema();
24383
24443
  init_Options();
@@ -24413,7 +24473,7 @@ var init_esm = __esm(() => {
24413
24473
  init_zodToJsonSchema();
24414
24474
  });
24415
24475
 
24416
- // node_modules/.bun/@modelcontextprotocol+sdk@1.30.0/node_modules/@modelcontextprotocol/sdk/dist/esm/server/zod-json-schema-compat.js
24476
+ // node_modules/@modelcontextprotocol/sdk/dist/esm/server/zod-json-schema-compat.js
24417
24477
  function mapMiniTarget(t) {
24418
24478
  if (!t)
24419
24479
  return "draft-7";
@@ -24460,7 +24520,7 @@ var init_zod_json_schema_compat = __esm(() => {
24460
24520
  init_esm();
24461
24521
  });
24462
24522
 
24463
- // node_modules/.bun/@modelcontextprotocol+sdk@1.30.0/node_modules/@modelcontextprotocol/sdk/dist/esm/shared/protocol.js
24523
+ // node_modules/@modelcontextprotocol/sdk/dist/esm/shared/protocol.js
24464
24524
  class Protocol {
24465
24525
  constructor(_options) {
24466
24526
  this._options = _options;
@@ -25305,7 +25365,7 @@ var init_protocol = __esm(() => {
25305
25365
  init_zod_json_schema_compat();
25306
25366
  });
25307
25367
 
25308
- // node_modules/.bun/ajv@8.20.0/node_modules/ajv/dist/compile/codegen/code.js
25368
+ // node_modules/ajv/dist/compile/codegen/code.js
25309
25369
  var require_code = __commonJS(function(exports) {
25310
25370
  Object.defineProperty(exports, "__esModule", { value: true });
25311
25371
  exports.regexpCode = exports.getEsmExportName = exports.getProperty = exports.safeStringify = exports.stringify = exports.strConcat = exports.addCodeArg = exports.str = exports._ = exports.nil = exports._Code = exports.Name = exports.IDENTIFIER = exports._CodeOrName = undefined;
@@ -25459,7 +25519,7 @@ var require_code = __commonJS(function(exports) {
25459
25519
  exports.regexpCode = regexpCode;
25460
25520
  });
25461
25521
 
25462
- // node_modules/.bun/ajv@8.20.0/node_modules/ajv/dist/compile/codegen/scope.js
25522
+ // node_modules/ajv/dist/compile/codegen/scope.js
25463
25523
  var require_scope = __commonJS(function(exports) {
25464
25524
  Object.defineProperty(exports, "__esModule", { value: true });
25465
25525
  exports.ValueScope = exports.ValueScopeName = exports.Scope = exports.varKinds = exports.UsedValueState = undefined;
@@ -25605,7 +25665,7 @@ var require_scope = __commonJS(function(exports) {
25605
25665
  exports.ValueScope = ValueScope;
25606
25666
  });
25607
25667
 
25608
- // node_modules/.bun/ajv@8.20.0/node_modules/ajv/dist/compile/codegen/index.js
25668
+ // node_modules/ajv/dist/compile/codegen/index.js
25609
25669
  var require_codegen = __commonJS(function(exports) {
25610
25670
  Object.defineProperty(exports, "__esModule", { value: true });
25611
25671
  exports.or = exports.and = exports.not = exports.CodeGen = exports.operators = exports.varKinds = exports.ValueScopeName = exports.ValueScope = exports.Scope = exports.Name = exports.regexpCode = exports.stringify = exports.getProperty = exports.nil = exports.strConcat = exports.str = exports._ = undefined;
@@ -26315,7 +26375,7 @@ var require_codegen = __commonJS(function(exports) {
26315
26375
  }
26316
26376
  });
26317
26377
 
26318
- // node_modules/.bun/ajv@8.20.0/node_modules/ajv/dist/compile/util.js
26378
+ // node_modules/ajv/dist/compile/util.js
26319
26379
  var require_util = __commonJS(function(exports) {
26320
26380
  Object.defineProperty(exports, "__esModule", { value: true });
26321
26381
  exports.checkStrictMode = exports.getErrorPath = exports.Type = exports.useFunc = exports.setEvaluated = exports.evaluatedPropsToName = exports.mergeEvaluated = exports.eachItem = exports.unescapeJsonPointer = exports.escapeJsonPointer = exports.escapeFragment = exports.unescapeFragment = exports.schemaRefOrVal = exports.schemaHasRulesButRef = exports.schemaHasRules = exports.checkUnknownRules = exports.alwaysValidSchema = exports.toHash = undefined;
@@ -26479,7 +26539,7 @@ var require_util = __commonJS(function(exports) {
26479
26539
  exports.checkStrictMode = checkStrictMode;
26480
26540
  });
26481
26541
 
26482
- // node_modules/.bun/ajv@8.20.0/node_modules/ajv/dist/compile/names.js
26542
+ // node_modules/ajv/dist/compile/names.js
26483
26543
  var require_names = __commonJS(function(exports) {
26484
26544
  Object.defineProperty(exports, "__esModule", { value: true });
26485
26545
  var codegen_1 = require_codegen();
@@ -26504,7 +26564,7 @@ var require_names = __commonJS(function(exports) {
26504
26564
  exports.default = names;
26505
26565
  });
26506
26566
 
26507
- // node_modules/.bun/ajv@8.20.0/node_modules/ajv/dist/compile/errors.js
26567
+ // node_modules/ajv/dist/compile/errors.js
26508
26568
  var require_errors = __commonJS(function(exports) {
26509
26569
  Object.defineProperty(exports, "__esModule", { value: true });
26510
26570
  exports.extendErrors = exports.resetErrorsCount = exports.reportExtraError = exports.reportError = exports.keyword$DataError = exports.keywordError = undefined;
@@ -26622,7 +26682,7 @@ var require_errors = __commonJS(function(exports) {
26622
26682
  }
26623
26683
  });
26624
26684
 
26625
- // node_modules/.bun/ajv@8.20.0/node_modules/ajv/dist/compile/validate/boolSchema.js
26685
+ // node_modules/ajv/dist/compile/validate/boolSchema.js
26626
26686
  var require_boolSchema = __commonJS(function(exports) {
26627
26687
  Object.defineProperty(exports, "__esModule", { value: true });
26628
26688
  exports.boolOrEmptySchema = exports.topBoolOrEmptySchema = undefined;
@@ -26670,7 +26730,7 @@ var require_boolSchema = __commonJS(function(exports) {
26670
26730
  }
26671
26731
  });
26672
26732
 
26673
- // node_modules/.bun/ajv@8.20.0/node_modules/ajv/dist/compile/rules.js
26733
+ // node_modules/ajv/dist/compile/rules.js
26674
26734
  var require_rules = __commonJS(function(exports) {
26675
26735
  Object.defineProperty(exports, "__esModule", { value: true });
26676
26736
  exports.getRules = exports.isJSONType = undefined;
@@ -26698,7 +26758,7 @@ var require_rules = __commonJS(function(exports) {
26698
26758
  exports.getRules = getRules;
26699
26759
  });
26700
26760
 
26701
- // node_modules/.bun/ajv@8.20.0/node_modules/ajv/dist/compile/validate/applicability.js
26761
+ // node_modules/ajv/dist/compile/validate/applicability.js
26702
26762
  var require_applicability = __commonJS(function(exports) {
26703
26763
  Object.defineProperty(exports, "__esModule", { value: true });
26704
26764
  exports.shouldUseRule = exports.shouldUseGroup = exports.schemaHasRulesForType = undefined;
@@ -26718,7 +26778,7 @@ var require_applicability = __commonJS(function(exports) {
26718
26778
  exports.shouldUseRule = shouldUseRule;
26719
26779
  });
26720
26780
 
26721
- // node_modules/.bun/ajv@8.20.0/node_modules/ajv/dist/compile/validate/dataType.js
26781
+ // node_modules/ajv/dist/compile/validate/dataType.js
26722
26782
  var require_dataType = __commonJS(function(exports) {
26723
26783
  Object.defineProperty(exports, "__esModule", { value: true });
26724
26784
  exports.reportTypeError = exports.checkDataTypes = exports.checkDataType = exports.coerceAndCheckDataType = exports.getJSONTypes = exports.getSchemaTypes = exports.DataType = undefined;
@@ -26899,7 +26959,7 @@ var require_dataType = __commonJS(function(exports) {
26899
26959
  }
26900
26960
  });
26901
26961
 
26902
- // node_modules/.bun/ajv@8.20.0/node_modules/ajv/dist/compile/validate/defaults.js
26962
+ // node_modules/ajv/dist/compile/validate/defaults.js
26903
26963
  var require_defaults = __commonJS(function(exports) {
26904
26964
  Object.defineProperty(exports, "__esModule", { value: true });
26905
26965
  exports.assignDefaults = undefined;
@@ -26933,7 +26993,7 @@ var require_defaults = __commonJS(function(exports) {
26933
26993
  }
26934
26994
  });
26935
26995
 
26936
- // node_modules/.bun/ajv@8.20.0/node_modules/ajv/dist/vocabularies/code.js
26996
+ // node_modules/ajv/dist/vocabularies/code.js
26937
26997
  var require_code2 = __commonJS(function(exports) {
26938
26998
  Object.defineProperty(exports, "__esModule", { value: true });
26939
26999
  exports.validateUnion = exports.validateArray = exports.usePattern = exports.callValidateCode = exports.schemaProperties = exports.allSchemaProperties = exports.noPropertyInData = exports.propertyInData = exports.isOwnProperty = exports.hasPropFunc = exports.reportMissingProp = exports.checkMissingProp = exports.checkReportMissingProp = undefined;
@@ -27062,7 +27122,7 @@ var require_code2 = __commonJS(function(exports) {
27062
27122
  exports.validateUnion = validateUnion;
27063
27123
  });
27064
27124
 
27065
- // node_modules/.bun/ajv@8.20.0/node_modules/ajv/dist/compile/validate/keyword.js
27125
+ // node_modules/ajv/dist/compile/validate/keyword.js
27066
27126
  var require_keyword = __commonJS(function(exports) {
27067
27127
  Object.defineProperty(exports, "__esModule", { value: true });
27068
27128
  exports.validateKeywordUsage = exports.validSchemaType = exports.funcKeywordCode = exports.macroKeywordCode = undefined;
@@ -27177,7 +27237,7 @@ var require_keyword = __commonJS(function(exports) {
27177
27237
  exports.validateKeywordUsage = validateKeywordUsage;
27178
27238
  });
27179
27239
 
27180
- // node_modules/.bun/ajv@8.20.0/node_modules/ajv/dist/compile/validate/subschema.js
27240
+ // node_modules/ajv/dist/compile/validate/subschema.js
27181
27241
  var require_subschema = __commonJS(function(exports) {
27182
27242
  Object.defineProperty(exports, "__esModule", { value: true });
27183
27243
  exports.extendSubschemaMode = exports.extendSubschemaData = exports.getSubschema = undefined;
@@ -27257,7 +27317,7 @@ var require_subschema = __commonJS(function(exports) {
27257
27317
  exports.extendSubschemaMode = extendSubschemaMode;
27258
27318
  });
27259
27319
 
27260
- // node_modules/.bun/fast-deep-equal@3.1.3/node_modules/fast-deep-equal/index.js
27320
+ // node_modules/fast-deep-equal/index.js
27261
27321
  var require_fast_deep_equal = __commonJS(function(exports, module) {
27262
27322
  module.exports = function equal(a, b) {
27263
27323
  if (a === b)
@@ -27299,7 +27359,7 @@ var require_fast_deep_equal = __commonJS(function(exports, module) {
27299
27359
  };
27300
27360
  });
27301
27361
 
27302
- // node_modules/.bun/json-schema-traverse@1.0.0/node_modules/json-schema-traverse/index.js
27362
+ // node_modules/json-schema-traverse/index.js
27303
27363
  var require_json_schema_traverse = __commonJS(function(exports, module) {
27304
27364
  var traverse = module.exports = function(schema, opts, cb) {
27305
27365
  if (typeof opts == "function") {
@@ -27382,7 +27442,7 @@ var require_json_schema_traverse = __commonJS(function(exports, module) {
27382
27442
  }
27383
27443
  });
27384
27444
 
27385
- // node_modules/.bun/ajv@8.20.0/node_modules/ajv/dist/compile/resolve.js
27445
+ // node_modules/ajv/dist/compile/resolve.js
27386
27446
  var require_resolve = __commonJS(function(exports) {
27387
27447
  Object.defineProperty(exports, "__esModule", { value: true });
27388
27448
  exports.getSchemaRefs = exports.resolveUrl = exports.normalizeId = exports._getFullPath = exports.getFullPath = exports.inlineRef = undefined;
@@ -27535,7 +27595,7 @@ var require_resolve = __commonJS(function(exports) {
27535
27595
  exports.getSchemaRefs = getSchemaRefs;
27536
27596
  });
27537
27597
 
27538
- // node_modules/.bun/ajv@8.20.0/node_modules/ajv/dist/compile/validate/index.js
27598
+ // node_modules/ajv/dist/compile/validate/index.js
27539
27599
  var require_validate = __commonJS(function(exports) {
27540
27600
  Object.defineProperty(exports, "__esModule", { value: true });
27541
27601
  exports.getData = exports.KeywordCxt = exports.validateFunctionCode = undefined;
@@ -28040,7 +28100,7 @@ var require_validate = __commonJS(function(exports) {
28040
28100
  exports.getData = getData;
28041
28101
  });
28042
28102
 
28043
- // node_modules/.bun/ajv@8.20.0/node_modules/ajv/dist/runtime/validation_error.js
28103
+ // node_modules/ajv/dist/runtime/validation_error.js
28044
28104
  var require_validation_error = __commonJS(function(exports) {
28045
28105
  Object.defineProperty(exports, "__esModule", { value: true });
28046
28106
 
@@ -28054,7 +28114,7 @@ var require_validation_error = __commonJS(function(exports) {
28054
28114
  exports.default = ValidationError;
28055
28115
  });
28056
28116
 
28057
- // node_modules/.bun/ajv@8.20.0/node_modules/ajv/dist/compile/ref_error.js
28117
+ // node_modules/ajv/dist/compile/ref_error.js
28058
28118
  var require_ref_error = __commonJS(function(exports) {
28059
28119
  Object.defineProperty(exports, "__esModule", { value: true });
28060
28120
  var resolve_1 = require_resolve();
@@ -28069,7 +28129,7 @@ var require_ref_error = __commonJS(function(exports) {
28069
28129
  exports.default = MissingRefError;
28070
28130
  });
28071
28131
 
28072
- // node_modules/.bun/ajv@8.20.0/node_modules/ajv/dist/compile/index.js
28132
+ // node_modules/ajv/dist/compile/index.js
28073
28133
  var require_compile = __commonJS(function(exports) {
28074
28134
  Object.defineProperty(exports, "__esModule", { value: true });
28075
28135
  exports.resolveSchema = exports.getCompilingSchema = exports.resolveRef = exports.compileSchema = exports.SchemaEnv = undefined;
@@ -28290,7 +28350,7 @@ var require_compile = __commonJS(function(exports) {
28290
28350
  }
28291
28351
  });
28292
28352
 
28293
- // node_modules/.bun/ajv@8.20.0/node_modules/ajv/dist/refs/data.json
28353
+ // node_modules/ajv/dist/refs/data.json
28294
28354
  var require_data = __commonJS(function(exports, module) {
28295
28355
  module.exports = {
28296
28356
  $id: "https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#",
@@ -28307,7 +28367,7 @@ var require_data = __commonJS(function(exports, module) {
28307
28367
  };
28308
28368
  });
28309
28369
 
28310
- // node_modules/.bun/fast-uri@3.1.7/node_modules/fast-uri/lib/utils.js
28370
+ // node_modules/fast-uri/lib/utils.js
28311
28371
  var require_utils = __commonJS(function(exports, module) {
28312
28372
  var isUUID = RegExp.prototype.test.bind(/^[\da-f]{8}-[\da-f]{4}-[\da-f]{4}-[\da-f]{4}-[\da-f]{12}$/iu);
28313
28373
  var isIPv4 = RegExp.prototype.test.bind(/^(?:(?:25[0-5]|2[0-4]\d|1\d{2}|[1-9]\d|\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d{2}|[1-9]\d|\d)$/u);
@@ -28824,7 +28884,7 @@ var require_utils = __commonJS(function(exports, module) {
28824
28884
  };
28825
28885
  });
28826
28886
 
28827
- // node_modules/.bun/fast-uri@3.1.7/node_modules/fast-uri/lib/schemes.js
28887
+ // node_modules/fast-uri/lib/schemes.js
28828
28888
  var require_schemes = __commonJS(function(exports, module) {
28829
28889
  var { isUUID } = require_utils();
28830
28890
  var URN_REG = /^([\da-z][\d\-a-z]{0,31}):((?:[\w!$'()*+,\-./:;=@]|%[\da-f]{2})+)$/iu;
@@ -28999,7 +29059,7 @@ var require_schemes = __commonJS(function(exports, module) {
28999
29059
  };
29000
29060
  });
29001
29061
 
29002
- // node_modules/.bun/fast-uri@3.1.7/node_modules/fast-uri/index.js
29062
+ // node_modules/fast-uri/index.js
29003
29063
  var require_fast_uri = __commonJS(function(exports, module) {
29004
29064
  var { normalizeIPv6, removeDotSegments, recomposeAuthority, normalizePercentEncoding, normalizePathEncoding, serializePathEncoding, normalizeQueryFragmentEncoding, encodeQuery, encodeFragment, reescapeHostDelimiters, isIPv4, nonSimpleDomain } = require_utils();
29005
29065
  var { SCHEMES, getSchemeHandler } = require_schemes();
@@ -29401,7 +29461,7 @@ var require_fast_uri = __commonJS(function(exports, module) {
29401
29461
  module.exports.fastUri = fastUri;
29402
29462
  });
29403
29463
 
29404
- // node_modules/.bun/ajv@8.20.0/node_modules/ajv/dist/runtime/uri.js
29464
+ // node_modules/ajv/dist/runtime/uri.js
29405
29465
  var require_uri = __commonJS(function(exports) {
29406
29466
  Object.defineProperty(exports, "__esModule", { value: true });
29407
29467
  var uri = require_fast_uri();
@@ -29409,7 +29469,7 @@ var require_uri = __commonJS(function(exports) {
29409
29469
  exports.default = uri;
29410
29470
  });
29411
29471
 
29412
- // node_modules/.bun/ajv@8.20.0/node_modules/ajv/dist/core.js
29472
+ // node_modules/ajv/dist/core.js
29413
29473
  var require_core = __commonJS(function(exports) {
29414
29474
  Object.defineProperty(exports, "__esModule", { value: true });
29415
29475
  exports.CodeGen = exports.Name = exports.nil = exports.stringify = exports.str = exports._ = exports.KeywordCxt = undefined;
@@ -30002,7 +30062,7 @@ var require_core = __commonJS(function(exports) {
30002
30062
  }
30003
30063
  });
30004
30064
 
30005
- // node_modules/.bun/ajv@8.20.0/node_modules/ajv/dist/vocabularies/core/id.js
30065
+ // node_modules/ajv/dist/vocabularies/core/id.js
30006
30066
  var require_id = __commonJS(function(exports) {
30007
30067
  Object.defineProperty(exports, "__esModule", { value: true });
30008
30068
  var def = {
@@ -30014,7 +30074,7 @@ var require_id = __commonJS(function(exports) {
30014
30074
  exports.default = def;
30015
30075
  });
30016
30076
 
30017
- // node_modules/.bun/ajv@8.20.0/node_modules/ajv/dist/vocabularies/core/ref.js
30077
+ // node_modules/ajv/dist/vocabularies/core/ref.js
30018
30078
  var require_ref = __commonJS(function(exports) {
30019
30079
  Object.defineProperty(exports, "__esModule", { value: true });
30020
30080
  exports.callRef = exports.getValidate = undefined;
@@ -30133,7 +30193,7 @@ var require_ref = __commonJS(function(exports) {
30133
30193
  exports.default = def;
30134
30194
  });
30135
30195
 
30136
- // node_modules/.bun/ajv@8.20.0/node_modules/ajv/dist/vocabularies/core/index.js
30196
+ // node_modules/ajv/dist/vocabularies/core/index.js
30137
30197
  var require_core2 = __commonJS(function(exports) {
30138
30198
  Object.defineProperty(exports, "__esModule", { value: true });
30139
30199
  var id_1 = require_id();
@@ -30151,7 +30211,7 @@ var require_core2 = __commonJS(function(exports) {
30151
30211
  exports.default = core;
30152
30212
  });
30153
30213
 
30154
- // node_modules/.bun/ajv@8.20.0/node_modules/ajv/dist/vocabularies/validation/limitNumber.js
30214
+ // node_modules/ajv/dist/vocabularies/validation/limitNumber.js
30155
30215
  var require_limitNumber = __commonJS(function(exports) {
30156
30216
  Object.defineProperty(exports, "__esModule", { value: true });
30157
30217
  var codegen_1 = require_codegen();
@@ -30180,7 +30240,7 @@ var require_limitNumber = __commonJS(function(exports) {
30180
30240
  exports.default = def;
30181
30241
  });
30182
30242
 
30183
- // node_modules/.bun/ajv@8.20.0/node_modules/ajv/dist/vocabularies/validation/multipleOf.js
30243
+ // node_modules/ajv/dist/vocabularies/validation/multipleOf.js
30184
30244
  var require_multipleOf = __commonJS(function(exports) {
30185
30245
  Object.defineProperty(exports, "__esModule", { value: true });
30186
30246
  var codegen_1 = require_codegen();
@@ -30205,7 +30265,7 @@ var require_multipleOf = __commonJS(function(exports) {
30205
30265
  exports.default = def;
30206
30266
  });
30207
30267
 
30208
- // node_modules/.bun/ajv@8.20.0/node_modules/ajv/dist/runtime/ucs2length.js
30268
+ // node_modules/ajv/dist/runtime/ucs2length.js
30209
30269
  var require_ucs2length = __commonJS(function(exports) {
30210
30270
  Object.defineProperty(exports, "__esModule", { value: true });
30211
30271
  function ucs2length(str) {
@@ -30228,7 +30288,7 @@ var require_ucs2length = __commonJS(function(exports) {
30228
30288
  ucs2length.code = 'require("ajv/dist/runtime/ucs2length").default';
30229
30289
  });
30230
30290
 
30231
- // node_modules/.bun/ajv@8.20.0/node_modules/ajv/dist/vocabularies/validation/limitLength.js
30291
+ // node_modules/ajv/dist/vocabularies/validation/limitLength.js
30232
30292
  var require_limitLength = __commonJS(function(exports) {
30233
30293
  Object.defineProperty(exports, "__esModule", { value: true });
30234
30294
  var codegen_1 = require_codegen();
@@ -30257,7 +30317,7 @@ var require_limitLength = __commonJS(function(exports) {
30257
30317
  exports.default = def;
30258
30318
  });
30259
30319
 
30260
- // node_modules/.bun/ajv@8.20.0/node_modules/ajv/dist/vocabularies/validation/pattern.js
30320
+ // node_modules/ajv/dist/vocabularies/validation/pattern.js
30261
30321
  var require_pattern = __commonJS(function(exports) {
30262
30322
  Object.defineProperty(exports, "__esModule", { value: true });
30263
30323
  var code_1 = require_code2();
@@ -30291,7 +30351,7 @@ var require_pattern = __commonJS(function(exports) {
30291
30351
  exports.default = def;
30292
30352
  });
30293
30353
 
30294
- // node_modules/.bun/ajv@8.20.0/node_modules/ajv/dist/vocabularies/validation/limitProperties.js
30354
+ // node_modules/ajv/dist/vocabularies/validation/limitProperties.js
30295
30355
  var require_limitProperties = __commonJS(function(exports) {
30296
30356
  Object.defineProperty(exports, "__esModule", { value: true });
30297
30357
  var codegen_1 = require_codegen();
@@ -30317,7 +30377,7 @@ var require_limitProperties = __commonJS(function(exports) {
30317
30377
  exports.default = def;
30318
30378
  });
30319
30379
 
30320
- // node_modules/.bun/ajv@8.20.0/node_modules/ajv/dist/vocabularies/validation/required.js
30380
+ // node_modules/ajv/dist/vocabularies/validation/required.js
30321
30381
  var require_required = __commonJS(function(exports) {
30322
30382
  Object.defineProperty(exports, "__esModule", { value: true });
30323
30383
  var code_1 = require_code2();
@@ -30396,7 +30456,7 @@ var require_required = __commonJS(function(exports) {
30396
30456
  exports.default = def;
30397
30457
  });
30398
30458
 
30399
- // node_modules/.bun/ajv@8.20.0/node_modules/ajv/dist/vocabularies/validation/limitItems.js
30459
+ // node_modules/ajv/dist/vocabularies/validation/limitItems.js
30400
30460
  var require_limitItems = __commonJS(function(exports) {
30401
30461
  Object.defineProperty(exports, "__esModule", { value: true });
30402
30462
  var codegen_1 = require_codegen();
@@ -30422,7 +30482,7 @@ var require_limitItems = __commonJS(function(exports) {
30422
30482
  exports.default = def;
30423
30483
  });
30424
30484
 
30425
- // node_modules/.bun/ajv@8.20.0/node_modules/ajv/dist/runtime/equal.js
30485
+ // node_modules/ajv/dist/runtime/equal.js
30426
30486
  var require_equal = __commonJS(function(exports) {
30427
30487
  Object.defineProperty(exports, "__esModule", { value: true });
30428
30488
  var equal = require_fast_deep_equal();
@@ -30430,7 +30490,7 @@ var require_equal = __commonJS(function(exports) {
30430
30490
  exports.default = equal;
30431
30491
  });
30432
30492
 
30433
- // node_modules/.bun/ajv@8.20.0/node_modules/ajv/dist/vocabularies/validation/uniqueItems.js
30493
+ // node_modules/ajv/dist/vocabularies/validation/uniqueItems.js
30434
30494
  var require_uniqueItems = __commonJS(function(exports) {
30435
30495
  Object.defineProperty(exports, "__esModule", { value: true });
30436
30496
  var dataType_1 = require_dataType();
@@ -30494,7 +30554,7 @@ var require_uniqueItems = __commonJS(function(exports) {
30494
30554
  exports.default = def;
30495
30555
  });
30496
30556
 
30497
- // node_modules/.bun/ajv@8.20.0/node_modules/ajv/dist/vocabularies/validation/const.js
30557
+ // node_modules/ajv/dist/vocabularies/validation/const.js
30498
30558
  var require_const = __commonJS(function(exports) {
30499
30559
  Object.defineProperty(exports, "__esModule", { value: true });
30500
30560
  var codegen_1 = require_codegen();
@@ -30520,7 +30580,7 @@ var require_const = __commonJS(function(exports) {
30520
30580
  exports.default = def;
30521
30581
  });
30522
30582
 
30523
- // node_modules/.bun/ajv@8.20.0/node_modules/ajv/dist/vocabularies/validation/enum.js
30583
+ // node_modules/ajv/dist/vocabularies/validation/enum.js
30524
30584
  var require_enum = __commonJS(function(exports) {
30525
30585
  Object.defineProperty(exports, "__esModule", { value: true });
30526
30586
  var codegen_1 = require_codegen();
@@ -30566,7 +30626,7 @@ var require_enum = __commonJS(function(exports) {
30566
30626
  exports.default = def;
30567
30627
  });
30568
30628
 
30569
- // node_modules/.bun/ajv@8.20.0/node_modules/ajv/dist/vocabularies/validation/index.js
30629
+ // node_modules/ajv/dist/vocabularies/validation/index.js
30570
30630
  var require_validation = __commonJS(function(exports) {
30571
30631
  Object.defineProperty(exports, "__esModule", { value: true });
30572
30632
  var limitNumber_1 = require_limitNumber();
@@ -30596,7 +30656,7 @@ var require_validation = __commonJS(function(exports) {
30596
30656
  exports.default = validation;
30597
30657
  });
30598
30658
 
30599
- // node_modules/.bun/ajv@8.20.0/node_modules/ajv/dist/vocabularies/applicator/additionalItems.js
30659
+ // node_modules/ajv/dist/vocabularies/applicator/additionalItems.js
30600
30660
  var require_additionalItems = __commonJS(function(exports) {
30601
30661
  Object.defineProperty(exports, "__esModule", { value: true });
30602
30662
  exports.validateAdditionalItems = undefined;
@@ -30646,7 +30706,7 @@ var require_additionalItems = __commonJS(function(exports) {
30646
30706
  exports.default = def;
30647
30707
  });
30648
30708
 
30649
- // node_modules/.bun/ajv@8.20.0/node_modules/ajv/dist/vocabularies/applicator/items.js
30709
+ // node_modules/ajv/dist/vocabularies/applicator/items.js
30650
30710
  var require_items = __commonJS(function(exports) {
30651
30711
  Object.defineProperty(exports, "__esModule", { value: true });
30652
30712
  exports.validateTuple = undefined;
@@ -30700,7 +30760,7 @@ var require_items = __commonJS(function(exports) {
30700
30760
  exports.default = def;
30701
30761
  });
30702
30762
 
30703
- // node_modules/.bun/ajv@8.20.0/node_modules/ajv/dist/vocabularies/applicator/prefixItems.js
30763
+ // node_modules/ajv/dist/vocabularies/applicator/prefixItems.js
30704
30764
  var require_prefixItems = __commonJS(function(exports) {
30705
30765
  Object.defineProperty(exports, "__esModule", { value: true });
30706
30766
  var items_1 = require_items();
@@ -30714,7 +30774,7 @@ var require_prefixItems = __commonJS(function(exports) {
30714
30774
  exports.default = def;
30715
30775
  });
30716
30776
 
30717
- // node_modules/.bun/ajv@8.20.0/node_modules/ajv/dist/vocabularies/applicator/items2020.js
30777
+ // node_modules/ajv/dist/vocabularies/applicator/items2020.js
30718
30778
  var require_items2020 = __commonJS(function(exports) {
30719
30779
  Object.defineProperty(exports, "__esModule", { value: true });
30720
30780
  var codegen_1 = require_codegen();
@@ -30746,7 +30806,7 @@ var require_items2020 = __commonJS(function(exports) {
30746
30806
  exports.default = def;
30747
30807
  });
30748
30808
 
30749
- // node_modules/.bun/ajv@8.20.0/node_modules/ajv/dist/vocabularies/applicator/contains.js
30809
+ // node_modules/ajv/dist/vocabularies/applicator/contains.js
30750
30810
  var require_contains = __commonJS(function(exports) {
30751
30811
  Object.defineProperty(exports, "__esModule", { value: true });
30752
30812
  var codegen_1 = require_codegen();
@@ -30837,7 +30897,7 @@ var require_contains = __commonJS(function(exports) {
30837
30897
  exports.default = def;
30838
30898
  });
30839
30899
 
30840
- // node_modules/.bun/ajv@8.20.0/node_modules/ajv/dist/vocabularies/applicator/dependencies.js
30900
+ // node_modules/ajv/dist/vocabularies/applicator/dependencies.js
30841
30901
  var require_dependencies = __commonJS(function(exports) {
30842
30902
  Object.defineProperty(exports, "__esModule", { value: true });
30843
30903
  exports.validateSchemaDeps = exports.validatePropertyDeps = exports.error = undefined;
@@ -30922,7 +30982,7 @@ var require_dependencies = __commonJS(function(exports) {
30922
30982
  exports.default = def;
30923
30983
  });
30924
30984
 
30925
- // node_modules/.bun/ajv@8.20.0/node_modules/ajv/dist/vocabularies/applicator/propertyNames.js
30985
+ // node_modules/ajv/dist/vocabularies/applicator/propertyNames.js
30926
30986
  var require_propertyNames = __commonJS(function(exports) {
30927
30987
  Object.defineProperty(exports, "__esModule", { value: true });
30928
30988
  var codegen_1 = require_codegen();
@@ -30962,7 +31022,7 @@ var require_propertyNames = __commonJS(function(exports) {
30962
31022
  exports.default = def;
30963
31023
  });
30964
31024
 
30965
- // node_modules/.bun/ajv@8.20.0/node_modules/ajv/dist/vocabularies/applicator/additionalProperties.js
31025
+ // node_modules/ajv/dist/vocabularies/applicator/additionalProperties.js
30966
31026
  var require_additionalProperties = __commonJS(function(exports) {
30967
31027
  Object.defineProperty(exports, "__esModule", { value: true });
30968
31028
  var code_1 = require_code2();
@@ -31065,7 +31125,7 @@ var require_additionalProperties = __commonJS(function(exports) {
31065
31125
  exports.default = def;
31066
31126
  });
31067
31127
 
31068
- // node_modules/.bun/ajv@8.20.0/node_modules/ajv/dist/vocabularies/applicator/properties.js
31128
+ // node_modules/ajv/dist/vocabularies/applicator/properties.js
31069
31129
  var require_properties = __commonJS(function(exports) {
31070
31130
  Object.defineProperty(exports, "__esModule", { value: true });
31071
31131
  var validate_1 = require_validate();
@@ -31120,7 +31180,7 @@ var require_properties = __commonJS(function(exports) {
31120
31180
  exports.default = def;
31121
31181
  });
31122
31182
 
31123
- // node_modules/.bun/ajv@8.20.0/node_modules/ajv/dist/vocabularies/applicator/patternProperties.js
31183
+ // node_modules/ajv/dist/vocabularies/applicator/patternProperties.js
31124
31184
  var require_patternProperties = __commonJS(function(exports) {
31125
31185
  Object.defineProperty(exports, "__esModule", { value: true });
31126
31186
  var code_1 = require_code2();
@@ -31191,7 +31251,7 @@ var require_patternProperties = __commonJS(function(exports) {
31191
31251
  exports.default = def;
31192
31252
  });
31193
31253
 
31194
- // node_modules/.bun/ajv@8.20.0/node_modules/ajv/dist/vocabularies/applicator/not.js
31254
+ // node_modules/ajv/dist/vocabularies/applicator/not.js
31195
31255
  var require_not = __commonJS(function(exports) {
31196
31256
  Object.defineProperty(exports, "__esModule", { value: true });
31197
31257
  var util_1 = require_util();
@@ -31219,7 +31279,7 @@ var require_not = __commonJS(function(exports) {
31219
31279
  exports.default = def;
31220
31280
  });
31221
31281
 
31222
- // node_modules/.bun/ajv@8.20.0/node_modules/ajv/dist/vocabularies/applicator/anyOf.js
31282
+ // node_modules/ajv/dist/vocabularies/applicator/anyOf.js
31223
31283
  var require_anyOf = __commonJS(function(exports) {
31224
31284
  Object.defineProperty(exports, "__esModule", { value: true });
31225
31285
  var code_1 = require_code2();
@@ -31233,7 +31293,7 @@ var require_anyOf = __commonJS(function(exports) {
31233
31293
  exports.default = def;
31234
31294
  });
31235
31295
 
31236
- // node_modules/.bun/ajv@8.20.0/node_modules/ajv/dist/vocabularies/applicator/oneOf.js
31296
+ // node_modules/ajv/dist/vocabularies/applicator/oneOf.js
31237
31297
  var require_oneOf = __commonJS(function(exports) {
31238
31298
  Object.defineProperty(exports, "__esModule", { value: true });
31239
31299
  var codegen_1 = require_codegen();
@@ -31288,7 +31348,7 @@ var require_oneOf = __commonJS(function(exports) {
31288
31348
  exports.default = def;
31289
31349
  });
31290
31350
 
31291
- // node_modules/.bun/ajv@8.20.0/node_modules/ajv/dist/vocabularies/applicator/allOf.js
31351
+ // node_modules/ajv/dist/vocabularies/applicator/allOf.js
31292
31352
  var require_allOf = __commonJS(function(exports) {
31293
31353
  Object.defineProperty(exports, "__esModule", { value: true });
31294
31354
  var util_1 = require_util();
@@ -31312,7 +31372,7 @@ var require_allOf = __commonJS(function(exports) {
31312
31372
  exports.default = def;
31313
31373
  });
31314
31374
 
31315
- // node_modules/.bun/ajv@8.20.0/node_modules/ajv/dist/vocabularies/applicator/if.js
31375
+ // node_modules/ajv/dist/vocabularies/applicator/if.js
31316
31376
  var require_if = __commonJS(function(exports) {
31317
31377
  Object.defineProperty(exports, "__esModule", { value: true });
31318
31378
  var codegen_1 = require_codegen();
@@ -31378,7 +31438,7 @@ var require_if = __commonJS(function(exports) {
31378
31438
  exports.default = def;
31379
31439
  });
31380
31440
 
31381
- // node_modules/.bun/ajv@8.20.0/node_modules/ajv/dist/vocabularies/applicator/thenElse.js
31441
+ // node_modules/ajv/dist/vocabularies/applicator/thenElse.js
31382
31442
  var require_thenElse = __commonJS(function(exports) {
31383
31443
  Object.defineProperty(exports, "__esModule", { value: true });
31384
31444
  var util_1 = require_util();
@@ -31393,7 +31453,7 @@ var require_thenElse = __commonJS(function(exports) {
31393
31453
  exports.default = def;
31394
31454
  });
31395
31455
 
31396
- // node_modules/.bun/ajv@8.20.0/node_modules/ajv/dist/vocabularies/applicator/index.js
31456
+ // node_modules/ajv/dist/vocabularies/applicator/index.js
31397
31457
  var require_applicator = __commonJS(function(exports) {
31398
31458
  Object.defineProperty(exports, "__esModule", { value: true });
31399
31459
  var additionalItems_1 = require_additionalItems();
@@ -31436,7 +31496,7 @@ var require_applicator = __commonJS(function(exports) {
31436
31496
  exports.default = getApplicator;
31437
31497
  });
31438
31498
 
31439
- // node_modules/.bun/ajv@8.20.0/node_modules/ajv/dist/vocabularies/format/format.js
31499
+ // node_modules/ajv/dist/vocabularies/format/format.js
31440
31500
  var require_format = __commonJS(function(exports) {
31441
31501
  Object.defineProperty(exports, "__esModule", { value: true });
31442
31502
  var codegen_1 = require_codegen();
@@ -31523,7 +31583,7 @@ var require_format = __commonJS(function(exports) {
31523
31583
  exports.default = def;
31524
31584
  });
31525
31585
 
31526
- // node_modules/.bun/ajv@8.20.0/node_modules/ajv/dist/vocabularies/format/index.js
31586
+ // node_modules/ajv/dist/vocabularies/format/index.js
31527
31587
  var require_format2 = __commonJS(function(exports) {
31528
31588
  Object.defineProperty(exports, "__esModule", { value: true });
31529
31589
  var format_1 = require_format();
@@ -31531,7 +31591,7 @@ var require_format2 = __commonJS(function(exports) {
31531
31591
  exports.default = format;
31532
31592
  });
31533
31593
 
31534
- // node_modules/.bun/ajv@8.20.0/node_modules/ajv/dist/vocabularies/metadata.js
31594
+ // node_modules/ajv/dist/vocabularies/metadata.js
31535
31595
  var require_metadata = __commonJS(function(exports) {
31536
31596
  Object.defineProperty(exports, "__esModule", { value: true });
31537
31597
  exports.contentVocabulary = exports.metadataVocabulary = undefined;
@@ -31551,7 +31611,7 @@ var require_metadata = __commonJS(function(exports) {
31551
31611
  ];
31552
31612
  });
31553
31613
 
31554
- // node_modules/.bun/ajv@8.20.0/node_modules/ajv/dist/vocabularies/draft7.js
31614
+ // node_modules/ajv/dist/vocabularies/draft7.js
31555
31615
  var require_draft7 = __commonJS(function(exports) {
31556
31616
  Object.defineProperty(exports, "__esModule", { value: true });
31557
31617
  var core_1 = require_core2();
@@ -31570,7 +31630,7 @@ var require_draft7 = __commonJS(function(exports) {
31570
31630
  exports.default = draft7Vocabularies;
31571
31631
  });
31572
31632
 
31573
- // node_modules/.bun/ajv@8.20.0/node_modules/ajv/dist/vocabularies/discriminator/types.js
31633
+ // node_modules/ajv/dist/vocabularies/discriminator/types.js
31574
31634
  var require_types = __commonJS(function(exports) {
31575
31635
  Object.defineProperty(exports, "__esModule", { value: true });
31576
31636
  exports.DiscrError = undefined;
@@ -31581,7 +31641,7 @@ var require_types = __commonJS(function(exports) {
31581
31641
  })(DiscrError || (exports.DiscrError = DiscrError = {}));
31582
31642
  });
31583
31643
 
31584
- // node_modules/.bun/ajv@8.20.0/node_modules/ajv/dist/vocabularies/discriminator/index.js
31644
+ // node_modules/ajv/dist/vocabularies/discriminator/index.js
31585
31645
  var require_discriminator = __commonJS(function(exports) {
31586
31646
  Object.defineProperty(exports, "__esModule", { value: true });
31587
31647
  var codegen_1 = require_codegen();
@@ -31683,7 +31743,7 @@ var require_discriminator = __commonJS(function(exports) {
31683
31743
  exports.default = def;
31684
31744
  });
31685
31745
 
31686
- // node_modules/.bun/ajv@8.20.0/node_modules/ajv/dist/refs/json-schema-draft-07.json
31746
+ // node_modules/ajv/dist/refs/json-schema-draft-07.json
31687
31747
  var require_json_schema_draft_07 = __commonJS(function(exports, module) {
31688
31748
  module.exports = {
31689
31749
  $schema: "http://json-schema.org/draft-07/schema#",
@@ -31838,7 +31898,7 @@ var require_json_schema_draft_07 = __commonJS(function(exports, module) {
31838
31898
  };
31839
31899
  });
31840
31900
 
31841
- // node_modules/.bun/ajv@8.20.0/node_modules/ajv/dist/ajv.js
31901
+ // node_modules/ajv/dist/ajv.js
31842
31902
  var require_ajv = __commonJS(function(exports, module) {
31843
31903
  Object.defineProperty(exports, "__esModule", { value: true });
31844
31904
  exports.MissingRefError = exports.ValidationError = exports.CodeGen = exports.Name = exports.nil = exports.stringify = exports.str = exports._ = exports.KeywordCxt = exports.Ajv = undefined;
@@ -31906,7 +31966,7 @@ var require_ajv = __commonJS(function(exports, module) {
31906
31966
  } });
31907
31967
  });
31908
31968
 
31909
- // node_modules/.bun/ajv-formats@3.0.1/node_modules/ajv-formats/dist/formats.js
31969
+ // node_modules/ajv-formats/dist/formats.js
31910
31970
  var require_formats = __commonJS(function(exports) {
31911
31971
  Object.defineProperty(exports, "__esModule", { value: true });
31912
31972
  exports.formatNames = exports.fastFormats = exports.fullFormats = undefined;
@@ -32083,7 +32143,7 @@ var require_formats = __commonJS(function(exports) {
32083
32143
  }
32084
32144
  });
32085
32145
 
32086
- // node_modules/.bun/ajv-formats@3.0.1/node_modules/ajv-formats/dist/limit.js
32146
+ // node_modules/ajv-formats/dist/limit.js
32087
32147
  var require_limit = __commonJS(function(exports) {
32088
32148
  Object.defineProperty(exports, "__esModule", { value: true });
32089
32149
  exports.formatLimitDefinition = undefined;
@@ -32152,7 +32212,7 @@ var require_limit = __commonJS(function(exports) {
32152
32212
  exports.default = formatLimitPlugin;
32153
32213
  });
32154
32214
 
32155
- // node_modules/.bun/ajv-formats@3.0.1/node_modules/ajv-formats/dist/index.js
32215
+ // node_modules/ajv-formats/dist/index.js
32156
32216
  var require_dist = __commonJS(function(exports, module) {
32157
32217
  Object.defineProperty(exports, "__esModule", { value: true });
32158
32218
  var formats_1 = require_formats();
@@ -32191,7 +32251,7 @@ var require_dist = __commonJS(function(exports, module) {
32191
32251
  exports.default = formatsPlugin;
32192
32252
  });
32193
32253
 
32194
- // node_modules/.bun/@modelcontextprotocol+sdk@1.30.0/node_modules/@modelcontextprotocol/sdk/dist/esm/validation/ajv-provider.js
32254
+ // node_modules/@modelcontextprotocol/sdk/dist/esm/validation/ajv-provider.js
32195
32255
  function createDefaultAjvInstance() {
32196
32256
  const ajv = new import_ajv.default({
32197
32257
  strict: false,
@@ -32234,7 +32294,7 @@ var init_ajv_provider = __esm(() => {
32234
32294
  import_ajv_formats = __toESM(require_dist(), 1);
32235
32295
  });
32236
32296
 
32237
- // node_modules/.bun/@modelcontextprotocol+sdk@1.30.0/node_modules/@modelcontextprotocol/sdk/dist/esm/experimental/tasks/server.js
32297
+ // node_modules/@modelcontextprotocol/sdk/dist/esm/experimental/tasks/server.js
32238
32298
  class ExperimentalServerTasks {
32239
32299
  constructor(_server) {
32240
32300
  this._server = _server;
@@ -32315,7 +32375,7 @@ var init_server = __esm(() => {
32315
32375
  init_types2();
32316
32376
  });
32317
32377
 
32318
- // node_modules/.bun/@modelcontextprotocol+sdk@1.30.0/node_modules/@modelcontextprotocol/sdk/dist/esm/experimental/tasks/helpers.js
32378
+ // node_modules/@modelcontextprotocol/sdk/dist/esm/experimental/tasks/helpers.js
32319
32379
  function assertToolsCallTaskCapability(requests, method, entityName) {
32320
32380
  if (!requests) {
32321
32381
  throw new Error(`${entityName} does not support task creation (required for ${method})`);
@@ -32350,7 +32410,7 @@ function assertClientRequestTaskCapability(requests, method, entityName) {
32350
32410
  }
32351
32411
  }
32352
32412
 
32353
- // node_modules/.bun/@modelcontextprotocol+sdk@1.30.0/node_modules/@modelcontextprotocol/sdk/dist/esm/server/index.js
32413
+ // node_modules/@modelcontextprotocol/sdk/dist/esm/server/index.js
32354
32414
  var Server;
32355
32415
  var init_server2 = __esm(() => {
32356
32416
  init_protocol();
@@ -32682,7 +32742,7 @@ var init_server2 = __esm(() => {
32682
32742
  };
32683
32743
  });
32684
32744
 
32685
- // node_modules/.bun/@modelcontextprotocol+sdk@1.30.0/node_modules/@modelcontextprotocol/sdk/dist/esm/server/completable.js
32745
+ // node_modules/@modelcontextprotocol/sdk/dist/esm/server/completable.js
32686
32746
  function isCompletable(schema) {
32687
32747
  return !!schema && typeof schema === "object" && COMPLETABLE_SYMBOL in schema;
32688
32748
  }
@@ -32697,7 +32757,7 @@ var init_completable = __esm(() => {
32697
32757
  McpZodTypeKind["Completable"] = "McpCompletable";
32698
32758
  })(McpZodTypeKind || (McpZodTypeKind = {}));
32699
32759
  });
32700
- // node_modules/.bun/@modelcontextprotocol+sdk@1.30.0/node_modules/@modelcontextprotocol/sdk/dist/esm/shared/toolNameValidation.js
32760
+ // node_modules/@modelcontextprotocol/sdk/dist/esm/shared/toolNameValidation.js
32701
32761
  function validateToolName(name) {
32702
32762
  const warnings = [];
32703
32763
  if (name.length === 0) {
@@ -32758,7 +32818,7 @@ var init_toolNameValidation = __esm(() => {
32758
32818
  TOOL_NAME_REGEX = /^[A-Za-z0-9._-]{1,128}$/;
32759
32819
  });
32760
32820
 
32761
- // node_modules/.bun/@modelcontextprotocol+sdk@1.30.0/node_modules/@modelcontextprotocol/sdk/dist/esm/experimental/tasks/mcp-server.js
32821
+ // node_modules/@modelcontextprotocol/sdk/dist/esm/experimental/tasks/mcp-server.js
32762
32822
  class ExperimentalMcpServerTasks {
32763
32823
  constructor(_mcpServer) {
32764
32824
  this._mcpServer = _mcpServer;
@@ -32773,7 +32833,7 @@ class ExperimentalMcpServerTasks {
32773
32833
  }
32774
32834
  }
32775
32835
 
32776
- // node_modules/.bun/@modelcontextprotocol+sdk@1.30.0/node_modules/@modelcontextprotocol/sdk/dist/esm/server/mcp.js
32836
+ // node_modules/@modelcontextprotocol/sdk/dist/esm/server/mcp.js
32777
32837
  class McpServer {
32778
32838
  constructor(serverInfo, options) {
32779
32839
  this._registeredResources = {};
@@ -33509,7 +33569,7 @@ var init_mcp = __esm(() => {
33509
33569
  };
33510
33570
  });
33511
33571
 
33512
- // node_modules/.bun/@modelcontextprotocol+sdk@1.30.0/node_modules/@modelcontextprotocol/sdk/dist/esm/shared/stdio.js
33572
+ // node_modules/@modelcontextprotocol/sdk/dist/esm/shared/stdio.js
33513
33573
  class ReadBuffer {
33514
33574
  constructor(options) {
33515
33575
  this._maxBufferSize = options?.maxBufferSize ?? STDIO_DEFAULT_MAX_BUFFER_SIZE;
@@ -33552,7 +33612,7 @@ var init_stdio = __esm(() => {
33552
33612
  STDIO_DEFAULT_MAX_BUFFER_SIZE = 10 * 1024 * 1024;
33553
33613
  });
33554
33614
 
33555
- // node_modules/.bun/@modelcontextprotocol+sdk@1.30.0/node_modules/@modelcontextprotocol/sdk/dist/esm/server/stdio.js
33615
+ // node_modules/@modelcontextprotocol/sdk/dist/esm/server/stdio.js
33556
33616
  import process4 from "process";
33557
33617
 
33558
33618
  class StdioServerTransport {
@@ -33697,7 +33757,7 @@ init_adapters();
33697
33757
  init_adapters();
33698
33758
  init_boot();
33699
33759
  import { randomUUID } from "crypto";
33700
- import { existsSync as existsSync9 } from "fs";
33760
+ import { existsSync as existsSync10 } from "fs";
33701
33761
 
33702
33762
  // src/config/config-write.ts
33703
33763
  init_dist();
@@ -33960,7 +34020,7 @@ function sourceGit(args) {
33960
34020
  // src/daemon/diagnostics.ts
33961
34021
  init_settings();
33962
34022
  init_core3();
33963
- import { existsSync as existsSync5 } from "fs";
34023
+ import { existsSync as existsSync6 } from "fs";
33964
34024
  function systemInfo() {
33965
34025
  return { platform: process.platform, arch: process.arch, runtime: `bun ${Bun.version}` };
33966
34026
  }
@@ -33973,7 +34033,7 @@ function prodDiagnosticsDeps(boot) {
33973
34033
  system: systemInfo,
33974
34034
  settings: boot.settings,
33975
34035
  configPath: boot.configPath,
33976
- configExists: () => existsSync5(boot.configPath),
34036
+ configExists: () => existsSync6(boot.configPath),
33977
34037
  envOverrides
33978
34038
  };
33979
34039
  }
@@ -34244,13 +34304,13 @@ init_log();
34244
34304
 
34245
34305
  // src/plan/directory.ts
34246
34306
  import { readdir as readdir4 } from "fs/promises";
34247
- import { join as join11, relative as relative3, sep as sep4 } from "path";
34307
+ import { join as join12, relative as relative3, sep as sep4 } from "path";
34248
34308
 
34249
34309
  // src/plan/excerpt.ts
34250
34310
  init_constants();
34251
34311
  import { readFileSync as readFileSync9 } from "fs";
34252
34312
  import { readdir as readdir3, realpath as realpath3, stat as stat3 } from "fs/promises";
34253
- import { extname, isAbsolute, join as join10, relative as relative2, resolve, sep as sep3 } from "path";
34313
+ import { extname, isAbsolute, join as join11, relative as relative2, resolve, sep as sep3 } from "path";
34254
34314
  var EXCERPT_HEAD_LINES = 60;
34255
34315
  var MAX_EXCERPT_BYTES = 10 * 1024 * 1024;
34256
34316
  var MAX_SCAN_ENTRIES = 5000;
@@ -34341,9 +34401,9 @@ async function basenameSearch(cwdReal, name) {
34341
34401
  return null;
34342
34402
  if (entry.isFile()) {
34343
34403
  if (entry.name === name)
34344
- return join10(currentDir, entry.name);
34404
+ return join11(currentDir, entry.name);
34345
34405
  } else if (entry.isDirectory() && !SKIP_DIRS.has(entry.name) && !entry.name.startsWith(".")) {
34346
- queue.push(join10(currentDir, entry.name));
34406
+ queue.push(join11(currentDir, entry.name));
34347
34407
  }
34348
34408
  }
34349
34409
  }
@@ -34440,7 +34500,7 @@ var MAX_DIR_DEPTH = 10;
34440
34500
  function byKindThenName(a, b) {
34441
34501
  if (a.kind !== b.kind)
34442
34502
  return a.kind === "directory" ? -1 : 1;
34443
- return a.name < b.name ? -1 : a.name > b.name ? 1 : 0;
34503
+ return compareCodeUnits(a.name, b.name);
34444
34504
  }
34445
34505
  function entryFor(name, kind) {
34446
34506
  if (kind === "file")
@@ -34475,7 +34535,7 @@ async function listDirectory(cwd, root, path) {
34475
34535
  else if (d.isSymbolicLink())
34476
34536
  links.push(d);
34477
34537
  }
34478
- const targets = await Promise.all(links.map((d) => resolveInCwd(cwd, join11(target.path, d.name))));
34538
+ const targets = await Promise.all(links.map((d) => resolveInCwd(cwd, join12(target.path, d.name))));
34479
34539
  targets.forEach((hit, i) => {
34480
34540
  const link = links[i];
34481
34541
  if (hit !== null && link !== undefined)
@@ -34492,7 +34552,7 @@ async function listDirectory(cwd, root, path) {
34492
34552
 
34493
34553
  // src/plan/file-search.ts
34494
34554
  import { readdir as readdir5 } from "fs/promises";
34495
- import { isAbsolute as isAbsolute2, join as join12 } from "path";
34555
+ import { isAbsolute as isAbsolute2, join as join13 } from "path";
34496
34556
  var SEARCH_BUDGET = { dirents: 20000, results: 50 };
34497
34557
  var MAX_SEARCH_QUERY_CHARS = 128;
34498
34558
  function subsequence(haystack, needle) {
@@ -34540,7 +34600,7 @@ async function searchFiles(cwd, query, budget = SEARCH_BUDGET) {
34540
34600
  const rel = queue.shift();
34541
34601
  let dirents;
34542
34602
  try {
34543
- dirents = await readdir5(join12(cwdReal, rel), { withFileTypes: true });
34603
+ dirents = await readdir5(join13(cwdReal, rel), { withFileTypes: true });
34544
34604
  } catch {
34545
34605
  continue;
34546
34606
  }
@@ -34615,7 +34675,7 @@ function createDecisions(log = noopLogger) {
34615
34675
  // src/review/threading.ts
34616
34676
  import { randomBytes } from "crypto";
34617
34677
 
34618
- // node_modules/.bun/marked@18.0.11/node_modules/marked/lib/marked.esm.js
34678
+ // node_modules/marked/lib/marked.esm.js
34619
34679
  function A() {
34620
34680
  return { async: false, breaks: false, extensions: null, gfm: true, hooks: null, pedantic: false, renderer: null, silent: false, tokenizer: null, walkTokens: null };
34621
34681
  }
@@ -35995,9 +36055,9 @@ var un = x.lex;
35995
36055
  init_log();
35996
36056
 
35997
36057
  // src/plan/canonical-file.ts
35998
- import { appendFileSync, existsSync as existsSync7, readFileSync as readFileSync10, statSync as statSync3, writeFileSync as writeFileSync4 } from "fs";
36058
+ import { appendFileSync, existsSync as existsSync8, readFileSync as readFileSync10, statSync as statSync4, writeFileSync as writeFileSync4 } from "fs";
35999
36059
  function isPlanFile(path) {
36000
- return path.endsWith(".md") && existsSync7(path) && statSync3(path).isFile();
36060
+ return path.endsWith(".md") && existsSync8(path) && statSync4(path).isFile();
36001
36061
  }
36002
36062
  function readPlanFile(path) {
36003
36063
  try {
@@ -36040,10 +36100,10 @@ init_log();
36040
36100
  // src/plan/rumdl.ts
36041
36101
  init_paths3();
36042
36102
  import { createHash as createHash2 } from "crypto";
36043
- import { chmodSync as chmodSync3, existsSync as existsSync8, mkdirSync as mkdirSync2, renameSync as renameSync3, writeFileSync as writeFileSync5 } from "fs";
36103
+ import { chmodSync as chmodSync3, existsSync as existsSync9, mkdirSync as mkdirSync2, renameSync as renameSync3, writeFileSync as writeFileSync5 } from "fs";
36044
36104
  import { mkdtemp, rm as rm3 } from "fs/promises";
36045
36105
  import { tmpdir } from "os";
36046
- import { dirname as dirname5, join as join13 } from "path";
36106
+ import { dirname as dirname5, join as join14 } from "path";
36047
36107
  var RUMDL_VERSION = "0.2.73";
36048
36108
  var ASSETS = {
36049
36109
  "darwin-arm64": {
@@ -36086,15 +36146,15 @@ async function downloadRumdl(binPath, asset, fetchImpl = fetch) {
36086
36146
  if (actual !== asset.sha256) {
36087
36147
  throw new Error(`rumdl: checksum mismatch for ${asset.url} (expected ${asset.sha256}, got ${actual})`);
36088
36148
  }
36089
- const work = await mkdtemp(join13(tmpdir(), "caret-rumdl-"));
36149
+ const work = await mkdtemp(join14(tmpdir(), "caret-rumdl-"));
36090
36150
  try {
36091
- const archive = join13(work, "rumdl.tar.gz");
36151
+ const archive = join14(work, "rumdl.tar.gz");
36092
36152
  await Bun.write(archive, bytes);
36093
36153
  const tar = Bun.spawn(["tar", "-xzf", archive, "-C", work], { stderr: "pipe" });
36094
36154
  if (await tar.exited !== 0)
36095
36155
  throw new Error(`rumdl: failed to extract ${asset.url}`);
36096
- const extracted = join13(work, "rumdl");
36097
- if (!existsSync8(extracted))
36156
+ const extracted = join14(work, "rumdl");
36157
+ if (!existsSync9(extracted))
36098
36158
  throw new Error(`rumdl: binary not found in ${asset.url}`);
36099
36159
  mkdirSync2(dirname5(binPath), { recursive: true });
36100
36160
  const tmp = `${binPath}.${process.pid}.tmp`;
@@ -36108,7 +36168,7 @@ async function downloadRumdl(binPath, asset, fetchImpl = fetch) {
36108
36168
  }
36109
36169
  var installPinnedRumdl = (binPath) => downloadRumdl(binPath, rumdlAsset());
36110
36170
  async function installedVersion(bin) {
36111
- if (!existsSync8(bin))
36171
+ if (!existsSync9(bin))
36112
36172
  return null;
36113
36173
  try {
36114
36174
  const proc = Bun.spawn([bin, "--version"], { stdout: "pipe", stderr: "ignore" });
@@ -36301,7 +36361,7 @@ function serviceEnvironment(env) {
36301
36361
  return environment;
36302
36362
  }
36303
36363
  function sortedEnvironment(env) {
36304
- return Object.entries(env).sort(([a], [b]) => a < b ? -1 : a > b ? 1 : 0);
36364
+ return Object.entries(env).sort(([a], [b]) => compareCodeUnits(a, b));
36305
36365
  }
36306
36366
 
36307
36367
  // src/ui/log-bridge.ts
@@ -36405,7 +36465,11 @@ function matchIdRoute(path) {
36405
36465
  const m = path.match(ID_ROUTE_RE);
36406
36466
  if (!m)
36407
36467
  return null;
36408
- return { id: decodeURIComponent(m[1]), sub: m[2] };
36468
+ try {
36469
+ return { id: decodeURIComponent(m[1]), sub: m[2] };
36470
+ } catch {
36471
+ return null;
36472
+ }
36409
36473
  }
36410
36474
  function ifNoneMatchHit(header, etag) {
36411
36475
  if (!header)
@@ -36542,15 +36606,15 @@ function createServer(opts) {
36542
36606
  const cacheControl = path.startsWith("/assets/") ? ASSET_CACHE_CONTROL : INDEX_CACHE_CONTROL;
36543
36607
  return assetResponse(req, file, cacheControl);
36544
36608
  }
36545
- async function handleCreateReview(req, routed) {
36609
+ async function handleCreateReview(req, bindRequestLog) {
36546
36610
  if (liveness.isDraining()) {
36547
36611
  log.warn("drain", "review refused: draining");
36548
36612
  return new Response("draining", { status: 503 });
36549
36613
  }
36550
36614
  const body = await parseBody(req, PlanInputSchema);
36551
- if (body.sessionId)
36552
- routed.log = log.child({ sessionId: body.sessionId });
36553
- const routing = await routePlan(body, store, routed.log);
36615
+ const reqLog = body.sessionId ? log.child({ sessionId: body.sessionId }) : log;
36616
+ bindRequestLog(reqLog);
36617
+ const routing = await routePlan(body, store, reqLog);
36554
36618
  for (const staleId of routing.expired)
36555
36619
  clearDecision(staleId);
36556
36620
  if (routing.action === "append")
@@ -36838,8 +36902,7 @@ function createServer(opts) {
36838
36902
  cfg.markPaneRead(existing.cmux);
36839
36903
  return new Response(null, { status: 204 });
36840
36904
  }
36841
- async function dispatch(req, routed) {
36842
- const { method, path, route } = routed;
36905
+ async function dispatch(req, { method, path, route }, bindRequestLog) {
36843
36906
  const readsUi = method === "GET" || method === "HEAD";
36844
36907
  if (method === "GET" && path === "/api/health")
36845
36908
  return handleHealth();
@@ -36854,7 +36917,7 @@ function createServer(opts) {
36854
36917
  if (readsUi && (path === "/" || path === INDEX_PATH))
36855
36918
  return handleIndex(req);
36856
36919
  if (method === "POST" && path === "/api/reviews")
36857
- return handleCreateReview(req, routed);
36920
+ return handleCreateReview(req, bindRequestLog);
36858
36921
  if (method === "POST" && path === "/api/logs")
36859
36922
  return handleLogs(req);
36860
36923
  if (method === "POST" && path === "/api/ui/gone")
@@ -36900,7 +36963,7 @@ function createServer(opts) {
36900
36963
  }
36901
36964
  async function handle(req, self) {
36902
36965
  const end = liveness.begin(req.method);
36903
- let routed;
36966
+ let failureLog = log;
36904
36967
  try {
36905
36968
  const port = self.port ?? -1;
36906
36969
  if (isForeignHost(req, port)) {
@@ -36914,11 +36977,14 @@ function createServer(opts) {
36914
36977
  }
36915
36978
  const idRoute = matchIdRoute(path);
36916
36979
  const route = idRoute && { ...idRoute, log: log.child({ reviewId: idRoute.id }) };
36917
- routed = { method, path, route, log: route?.log ?? log };
36918
- return await dispatch(req, routed);
36980
+ if (route)
36981
+ failureLog = route.log;
36982
+ return await dispatch(req, { method, path, route }, (ownerLog) => {
36983
+ failureLog = ownerLog;
36984
+ });
36919
36985
  } catch (err) {
36920
36986
  try {
36921
- (routed?.log ?? log).error("request", "request-failed", err);
36987
+ failureLog.error("request", "request-failed", err);
36922
36988
  } catch {}
36923
36989
  return new Response("internal error", { status: 500 });
36924
36990
  } finally {
@@ -37116,7 +37182,7 @@ init_upstream();
37116
37182
  // src/review/store.ts
37117
37183
  init_paths3();
37118
37184
  import { readdir as readdir6, readFile as readFile5, stat as stat4 } from "fs/promises";
37119
- import { join as join14 } from "path";
37185
+ import { join as join15 } from "path";
37120
37186
  init_json_file();
37121
37187
  init_log();
37122
37188
  var STALE_AFTER_MS = 7 * 24 * 60 * 60 * 1000;
@@ -37126,7 +37192,7 @@ function createStore(dir, log = noopLogger) {
37126
37192
  function persist(review) {
37127
37193
  return writes.run(review.id, async () => {
37128
37194
  ensureStateDir(dir);
37129
- await writeFileAtomic(join14(dir, `${review.id}.json`), JSON.stringify(review, null, 2), {
37195
+ await writeFileAtomic(join15(dir, `${review.id}.json`), JSON.stringify(review, null, 2), {
37130
37196
  mode: 384
37131
37197
  });
37132
37198
  log.debug("store", `review persisted: ${shortId(review.id)}`, { reviewId: review.id });
@@ -37174,7 +37240,7 @@ function createStore(dir, log = noopLogger) {
37174
37240
  return review;
37175
37241
  },
37176
37242
  async persisted(id) {
37177
- return await readJsonFile(join14(dir, `${id}.json`)) ?? undefined;
37243
+ return await readJsonFile(join15(dir, `${id}.json`)) ?? undefined;
37178
37244
  },
37179
37245
  size() {
37180
37246
  return reviews.size;
@@ -37207,7 +37273,7 @@ function createStore(dir, log = noopLogger) {
37207
37273
  for (const file of files) {
37208
37274
  if (!file.endsWith(".json"))
37209
37275
  continue;
37210
- const path = join14(dir, file);
37276
+ const path = join15(dir, file);
37211
37277
  try {
37212
37278
  if ((await stat4(path)).mtimeMs < now - STALE_AFTER_MS)
37213
37279
  continue;
@@ -37234,7 +37300,7 @@ async function runDaemon(opts) {
37234
37300
  const log = createDaemonLogger(() => svc.current().logging.level, undefined, () => svc.current().logging.redact, { maxSize: () => logMaxSize(svc.current()), keep: () => logKeep(svc.current()) });
37235
37301
  const cfg = configFile();
37236
37302
  const boot = svc.current();
37237
- log.info("settings", existsSync9(cfg) ? `settings: reading ${cfg}` : `settings: no config at ${cfg}; using defaults`, { settings: boot });
37303
+ log.info("settings", existsSync10(cfg) ? `settings: reading ${cfg}` : `settings: no config at ${cfg}; using defaults`, { settings: boot });
37238
37304
  await migratePrefsFile({
37239
37305
  prefs: prefsFile(),
37240
37306
  config: cfg,
@@ -37378,7 +37444,7 @@ async function runDaemon(opts) {
37378
37444
  init_adapters();
37379
37445
  init_paths2();
37380
37446
  init_upgrade();
37381
- import { existsSync as existsSync11 } from "fs";
37447
+ import { existsSync as existsSync12 } from "fs";
37382
37448
  import { release } from "os";
37383
37449
 
37384
37450
  // src/commands/install/ui.ts
@@ -37450,23 +37516,330 @@ async function createInstallUI(opts = {}) {
37450
37516
  };
37451
37517
  }
37452
37518
 
37519
+ // src/service/index.ts
37520
+ var SERVICE_LABELS = {
37521
+ darwin: LAUNCHD_LABEL,
37522
+ linux: SYSTEMD_UNIT
37523
+ };
37524
+ function servicePlatform(platform = process.platform) {
37525
+ if (platform !== "darwin" && platform !== "linux") {
37526
+ throw new Error(`caret service: unsupported platform ${platform} (darwin/linux only)`);
37527
+ }
37528
+ return platform;
37529
+ }
37530
+
37531
+ // src/service/launchd-manager.ts
37532
+ init_log();
37533
+ import { mkdirSync as mkdirSync3, rmSync as rmSync2, writeFileSync as writeFileSync8 } from "fs";
37534
+ import { homedir as homedir6 } from "os";
37535
+ import { join as join17 } from "path";
37536
+
37537
+ // src/service/launchd.ts
37538
+ var EXIT_TIMEOUT_SEC = 20;
37539
+ function escapeXml(value) {
37540
+ return value.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;");
37541
+ }
37542
+ function stringEntry(key, value, indent) {
37543
+ return `${indent}<key>${escapeXml(key)}</key>
37544
+ ${indent}<string>${escapeXml(value)}</string>`;
37545
+ }
37546
+ function buildLaunchdPlist(cfg) {
37547
+ const args = [cfg.launcherPath, ...SERVICE_ARGS].map((arg) => ` <string>${escapeXml(arg)}</string>`).join(`
37548
+ `);
37549
+ const environment = sortedEnvironment(cfg.environment).map(([key, value]) => stringEntry(key, value, " ")).join(`
37550
+ `);
37551
+ return `<?xml version="1.0" encoding="UTF-8"?>
37552
+ <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
37553
+ <plist version="1.0">
37554
+ <dict>
37555
+ ${stringEntry("Label", cfg.label, " ")}
37556
+ <key>ProgramArguments</key>
37557
+ <array>
37558
+ ${args}
37559
+ </array>
37560
+ <key>RunAtLoad</key>
37561
+ <true/>
37562
+ <key>KeepAlive</key>
37563
+ <true/>
37564
+ <key>ExitTimeOut</key>
37565
+ <integer>${EXIT_TIMEOUT_SEC}</integer>
37566
+ ${stringEntry("WorkingDirectory", cfg.workingDirectory, " ")}
37567
+ <key>EnvironmentVariables</key>
37568
+ <dict>
37569
+ ${environment}
37570
+ </dict>
37571
+ </dict>
37572
+ </plist>
37573
+ `;
37574
+ }
37575
+
37576
+ // src/service/run.ts
37577
+ async function runCommand(argv) {
37578
+ let proc;
37579
+ try {
37580
+ proc = Bun.spawn(argv, { stdout: "pipe", stderr: "pipe" });
37581
+ } catch (err) {
37582
+ return { code: 127, stdout: "", stderr: errorMessage(err) };
37583
+ }
37584
+ const [stdout, stderr, code] = await Promise.all([
37585
+ new Response(proc.stdout).text(),
37586
+ new Response(proc.stderr).text(),
37587
+ proc.exited
37588
+ ]);
37589
+ return { code, stdout, stderr };
37590
+ }
37591
+ function commandError(tool, verb, result) {
37592
+ return new Error(`caret service: ${tool} ${verb} failed (${result.code}): ${result.stderr.trim()}`);
37593
+ }
37594
+
37595
+ // src/service/unit-file.ts
37596
+ import { readFileSync as readFileSync11 } from "fs";
37597
+ function unitUnchanged(path, text) {
37598
+ try {
37599
+ return readFileSync11(path, "utf-8") === text;
37600
+ } catch {
37601
+ return false;
37602
+ }
37603
+ }
37604
+
37605
+ // src/service/launchd-manager.ts
37606
+ var spawnLaunchctl = (args) => runCommand(["launchctl", ...args]);
37607
+ var RUNNING = [/^\s*state\s*=\s*running\b/m, /^\s*pid\s*=\s*\d+/m];
37608
+ var DISABLED2 = new RegExp(`"${LAUNCHD_LABEL.replace(/\./g, "\\.")}"\\s*=>\\s*(?:true|disabled)\\b`);
37609
+ var launchctlError = (action, result) => commandError("launchctl", action, result);
37610
+ function createLaunchdManager(deps = {}) {
37611
+ const launchAgentsDir = deps.launchAgentsDir ?? join17(homedir6(), "Library", "LaunchAgents");
37612
+ const launchctl = deps.launchctl ?? spawnLaunchctl;
37613
+ const uid = deps.uid ?? process.getuid?.();
37614
+ if (uid === undefined)
37615
+ throw new Error("caret service: launchd needs a POSIX uid");
37616
+ const domain = `gui/${uid}`;
37617
+ const target = `${domain}/${LAUNCHD_LABEL}`;
37618
+ const plistPath = join17(launchAgentsDir, `${LAUNCHD_LABEL}.plist`);
37619
+ async function readStatus() {
37620
+ const [printed, printDisabled] = await Promise.all([
37621
+ launchctl(["print", target]),
37622
+ launchctl(["print-disabled", domain])
37623
+ ]);
37624
+ const installed = printed.code === 0;
37625
+ const disabled = DISABLED2.test(printDisabled.stdout);
37626
+ return {
37627
+ installed,
37628
+ running: installed && RUNNING.some((pattern) => pattern.test(printed.stdout)),
37629
+ disabled,
37630
+ keepsAlive: installed && !disabled
37631
+ };
37632
+ }
37633
+ return {
37634
+ async install(cfg) {
37635
+ if (cfg.label !== LAUNCHD_LABEL) {
37636
+ throw new Error(`caret service: plist label ${cfg.label} is not ${LAUNCHD_LABEL}`);
37637
+ }
37638
+ const text = buildLaunchdPlist(cfg);
37639
+ if (unitUnchanged(plistPath, text)) {
37640
+ const current = await readStatus();
37641
+ if (current.installed && current.running) {
37642
+ logDebug("service", "launchd agent unchanged; install skipped");
37643
+ return;
37644
+ }
37645
+ }
37646
+ mkdirSync3(launchAgentsDir, { recursive: true });
37647
+ writeFileSync8(plistPath, text);
37648
+ await launchctl(["bootout", target]);
37649
+ const bootstrapped = await launchctl(["bootstrap", domain, plistPath]);
37650
+ if (bootstrapped.code !== 0)
37651
+ throw launchctlError("bootstrap", bootstrapped);
37652
+ },
37653
+ async uninstall() {
37654
+ await launchctl(["bootout", target]);
37655
+ rmSync2(plistPath, { force: true });
37656
+ },
37657
+ status: readStatus,
37658
+ async restart() {
37659
+ const kicked = await launchctl(["kickstart", "-k", target]);
37660
+ if (kicked.code !== 0)
37661
+ throw launchctlError("kickstart", kicked);
37662
+ }
37663
+ };
37664
+ }
37665
+
37666
+ // src/service/systemd-manager.ts
37667
+ init_log();
37668
+ import { mkdirSync as mkdirSync4, rmSync as rmSync3, writeFileSync as writeFileSync9 } from "fs";
37669
+ import { homedir as homedir7 } from "os";
37670
+ import { join as join18 } from "path";
37671
+
37672
+ // src/service/systemd.ts
37673
+ var START_LIMIT_INTERVAL_SEC = 60;
37674
+ var START_LIMIT_BURST = 5;
37675
+ var RESTART_DELAY_SEC = 5;
37676
+ function unitValue(value) {
37677
+ return value.replace(/%/g, "%%");
37678
+ }
37679
+ function quote(value) {
37680
+ const escaped = unitValue(value).replace(/[\\"]/g, (c) => `\\${c}`).replace(/\n/g, "\\n");
37681
+ return `"${escaped}"`;
37682
+ }
37683
+ function execArg(value) {
37684
+ return quote(value).replace(/\$/g, "$$$$");
37685
+ }
37686
+ function buildSystemdUnit(cfg) {
37687
+ const execStart = [cfg.launcherPath, ...SERVICE_ARGS].map(execArg).join(" ");
37688
+ const environment = sortedEnvironment(cfg.environment).map(([key, value]) => `Environment=${quote(`${key}=${value}`)}`).join(`
37689
+ `);
37690
+ return `[Unit]
37691
+ Description=caret review daemon
37692
+ After=default.target
37693
+ StartLimitIntervalSec=${START_LIMIT_INTERVAL_SEC}
37694
+ StartLimitBurst=${START_LIMIT_BURST}
37695
+
37696
+ [Service]
37697
+ Type=simple
37698
+ ExecStart=${execStart}
37699
+ WorkingDirectory=${unitValue(cfg.workingDirectory)}
37700
+ Restart=always
37701
+ RestartSec=${RESTART_DELAY_SEC}
37702
+ RestartPreventExitStatus=${cfg.terminalExitStatus}
37703
+ ${environment}
37704
+
37705
+ [Install]
37706
+ WantedBy=default.target
37707
+ `;
37708
+ }
37709
+
37710
+ // src/service/systemd-manager.ts
37711
+ function createSystemdManager(deps = {}) {
37712
+ const configHome = process.env.XDG_CONFIG_HOME || join18(homedir7(), ".config");
37713
+ const unitDir = deps.unitDir ?? join18(configHome, "systemd", "user");
37714
+ const run = deps.run ?? runCommand;
37715
+ const unitPath = join18(unitDir, SYSTEMD_UNIT);
37716
+ const systemctl = (...args) => run(["systemctl", "--user", ...args]);
37717
+ async function probeSystemd() {
37718
+ const shown = await systemctl("show-environment");
37719
+ if (shown.code === 0)
37720
+ return;
37721
+ return `caret service: no systemd user session (${shown.code}): ${shown.stderr.trim()}`;
37722
+ }
37723
+ async function readEnablement() {
37724
+ const [active, enabled] = await Promise.all([
37725
+ systemctl("is-active", SYSTEMD_UNIT),
37726
+ systemctl("is-enabled", SYSTEMD_UNIT)
37727
+ ]);
37728
+ const enablement = enabled.stdout.trim();
37729
+ const activity = active.stdout.trim();
37730
+ const installed = enablement !== "" && enablement !== "not-found";
37731
+ const disabled = enablement === "disabled" || enablement.startsWith("masked");
37732
+ return {
37733
+ installed,
37734
+ running: activity === "active",
37735
+ disabled,
37736
+ keepsAlive: installed && !disabled && activity !== "inactive" && activity !== "failed"
37737
+ };
37738
+ }
37739
+ async function readStatus() {
37740
+ const unsupported = await probeSystemd();
37741
+ if (unsupported) {
37742
+ return { installed: false, running: false, disabled: false, keepsAlive: false, unsupported };
37743
+ }
37744
+ return readEnablement();
37745
+ }
37746
+ async function enableLinger() {
37747
+ const lingering = await run(["loginctl", "enable-linger"]);
37748
+ if (lingering.code !== 0) {
37749
+ logWarn("service", "lingering not enabled; caret stops at logout", {
37750
+ code: lingering.code,
37751
+ stderr: lingering.stderr.trim()
37752
+ });
37753
+ }
37754
+ }
37755
+ return {
37756
+ async install(cfg) {
37757
+ if (cfg.label !== SYSTEMD_UNIT) {
37758
+ throw new Error(`caret service: unit label ${cfg.label} is not ${SYSTEMD_UNIT}`);
37759
+ }
37760
+ const unsupported = await probeSystemd();
37761
+ if (unsupported)
37762
+ throw new Error(unsupported);
37763
+ const text = buildSystemdUnit(cfg);
37764
+ if (unitUnchanged(unitPath, text)) {
37765
+ const current = await readEnablement();
37766
+ if (current.installed && current.running && !current.disabled) {
37767
+ await enableLinger();
37768
+ logDebug("service", "systemd unit unchanged; install skipped");
37769
+ return;
37770
+ }
37771
+ }
37772
+ mkdirSync4(unitDir, { recursive: true });
37773
+ try {
37774
+ writeFileSync9(unitPath, text);
37775
+ const reloaded = await systemctl("daemon-reload");
37776
+ if (reloaded.code !== 0)
37777
+ throw commandError("systemctl", "daemon-reload", reloaded);
37778
+ const enabled = await systemctl("enable", SYSTEMD_UNIT);
37779
+ if (enabled.code !== 0)
37780
+ throw commandError("systemctl", "enable", enabled);
37781
+ await systemctl("reset-failed", SYSTEMD_UNIT);
37782
+ const restarted = await systemctl("restart", SYSTEMD_UNIT);
37783
+ if (restarted.code !== 0)
37784
+ throw commandError("systemctl", "restart", restarted);
37785
+ } catch (err) {
37786
+ rmSync3(unitPath, { force: true });
37787
+ throw err;
37788
+ }
37789
+ await enableLinger();
37790
+ },
37791
+ async uninstall() {
37792
+ await systemctl("disable", "--now", SYSTEMD_UNIT);
37793
+ rmSync3(unitPath, { force: true });
37794
+ await systemctl("daemon-reload");
37795
+ },
37796
+ status: readStatus,
37797
+ async restart() {
37798
+ const restarted = await systemctl("restart", SYSTEMD_UNIT);
37799
+ if (restarted.code !== 0)
37800
+ throw commandError("systemctl", "restart", restarted);
37801
+ }
37802
+ };
37803
+ }
37804
+
37805
+ // src/commands/service-target.ts
37806
+ var SURFACES = {
37807
+ darwin: {
37808
+ visibleIn: "System Settings \u203A Login Items",
37809
+ optOutSurface: "`launchctl disable`",
37810
+ visibleToggleCaveat: "Skip the System Settings switch: caret can't read it.\n`caret install --uninstall` removes caret entirely."
37811
+ },
37812
+ linux: {
37813
+ visibleIn: "`systemctl --user`",
37814
+ optOutSurface: "`systemctl --user`"
37815
+ }
37816
+ };
37817
+ function prodService() {
37818
+ const platform = servicePlatform();
37819
+ return {
37820
+ manager: platform === "darwin" ? createLaunchdManager() : createSystemdManager(),
37821
+ label: SERVICE_LABELS[platform],
37822
+ ...SURFACES[platform]
37823
+ };
37824
+ }
37825
+
37453
37826
  // src/commands/doctor.ts
37454
37827
  init_paths3();
37455
37828
  init_settings();
37456
37829
  init_lifecycle();
37457
37830
 
37458
37831
  // src/doctor/bundle.ts
37459
- import { readdirSync as readdirSync5, readFileSync as readFileSync11 } from "fs";
37460
- import { basename as basename3, join as join16 } from "path";
37832
+ import { readdirSync as readdirSync5, readFileSync as readFileSync12 } from "fs";
37833
+ import { basename as basename3, join as join19 } from "path";
37461
37834
  function stamp2(now) {
37462
37835
  return now.toISOString().replace(/[-:.]/g, "");
37463
37836
  }
37464
37837
  function bundlePath(stateDir, now) {
37465
- return join16(stateDir, `doctor-${stamp2(now)}.zip`);
37838
+ return join19(stateDir, `doctor-${stamp2(now)}.zip`);
37466
37839
  }
37467
37840
  function member(path, name) {
37468
37841
  try {
37469
- return { name, data: readFileSync11(path) };
37842
+ return { name, data: readFileSync12(path) };
37470
37843
  } catch {
37471
37844
  return null;
37472
37845
  }
@@ -37480,7 +37853,7 @@ function entriesFor(deps) {
37480
37853
  } catch {
37481
37854
  reviews = [];
37482
37855
  }
37483
- const records = reviews.slice(0, MAX_REVIEW_MEMBERS).map((f) => member(join16(deps.reviewsDir, f), `reviews/${f}`));
37856
+ const records = reviews.slice(0, MAX_REVIEW_MEMBERS).map((f) => member(join19(deps.reviewsDir, f), `reviews/${f}`));
37484
37857
  return [...logs, ...records].filter((e) => e !== null);
37485
37858
  }
37486
37859
  async function runBundle(opts, deps) {
@@ -37505,8 +37878,8 @@ init_paths3();
37505
37878
  init_json_file();
37506
37879
  init_log();
37507
37880
  init_node();
37508
- import { readdirSync as readdirSync6, statSync as statSync4 } from "fs";
37509
- import { basename as basename4, join as join17 } from "path";
37881
+ import { readdirSync as readdirSync6, statSync as statSync5 } from "fs";
37882
+ import { basename as basename4, join as join20 } from "path";
37510
37883
  var CARET_BIN = "caret-native";
37511
37884
  var ERROR_RECORD_FIELDS = ["time", "source", "step", "code", "reviewId", "sessionId"];
37512
37885
  async function safe(build) {
@@ -37581,18 +37954,35 @@ function buildSettings(deps) {
37581
37954
  effectiveHeartbeatMs: e.heartbeatMs
37582
37955
  };
37583
37956
  }
37584
- function buildDaemon(deps, health) {
37957
+ async function buildDaemon(deps, health) {
37585
37958
  const serviceInstalled = deps.serviceInstalled();
37586
- if (!health)
37587
- return { reachable: false, serviceInstalled };
37588
- return {
37959
+ const published = health?.service === "caret" && !health.isDev && health.version !== undefined;
37960
+ const [supervisorVerdict, npmLatest] = await Promise.all([
37961
+ serviceInstalled ? readServiceKeptAlive(deps) : undefined,
37962
+ published ? deps.publishedVersion() : undefined
37963
+ ]);
37964
+ const optional = {
37965
+ ...health?.isDev !== undefined && { isDev: health.isDev },
37966
+ ...supervisorVerdict,
37967
+ ...npmLatest !== undefined && { npmLatest }
37968
+ };
37969
+ return health ? {
37589
37970
  reachable: true,
37590
37971
  serviceInstalled,
37591
37972
  service: health.service,
37592
37973
  daemonVersion: health.version,
37593
37974
  build: health.build,
37594
- commit: health.commit
37595
- };
37975
+ commit: health.commit,
37976
+ ...optional
37977
+ } : { reachable: false, serviceInstalled, ...optional };
37978
+ }
37979
+ async function readServiceKeptAlive(deps) {
37980
+ try {
37981
+ const status = await deps.serviceStatus();
37982
+ return status.unsupported === undefined ? { serviceKeptAlive: status.keepsAlive } : { serviceStatusError: status.unsupported };
37983
+ } catch (e) {
37984
+ return { serviceStatusError: errorMessage(e) };
37985
+ }
37596
37986
  }
37597
37987
  function buildLockAndPort(deps, health) {
37598
37988
  const portServesCaret = health?.service === "caret";
@@ -37676,7 +38066,7 @@ function tallyReviews(records) {
37676
38066
  }
37677
38067
  var FAILURES_CAP = 50;
37678
38068
  function groupFailures(records, generatedAt) {
37679
- const recent = records.filter((r) => inErrorWindow(r.time, generatedAt)).sort((a, b) => compareTimes(a.time ?? "", b.time ?? ""));
38069
+ const recent = records.filter((r) => inErrorWindow(r.time, generatedAt)).sort((a, b) => compareCodeUnits(a.time ?? "", b.time ?? ""));
37680
38070
  const newest = recent.slice(-FAILURES_CAP);
37681
38071
  const groups = new Map;
37682
38072
  const ungrouped = [];
@@ -37699,9 +38089,6 @@ function groupFailures(records, generatedAt) {
37699
38089
  ungrouped
37700
38090
  };
37701
38091
  }
37702
- function compareTimes(a, b) {
37703
- return a < b ? -1 : a > b ? 1 : 0;
37704
- }
37705
38092
  var HEADER_KEYS = new Set(["schema", "version", "generatedAt", "checks"]);
37706
38093
  var STATUS_GLYPH = { pass: "\u2713", fail: "\u2717", unknown: "?" };
37707
38094
  var STATUS_COLOR = { pass: "\x1B[32m", fail: "\x1B[31m", unknown: "\x1B[33m" };
@@ -37804,7 +38191,7 @@ function listReviewFiles() {
37804
38191
  continue;
37805
38192
  if (out.length >= 5000)
37806
38193
  break;
37807
- const raw = readJsonFileSync(join17(dir, file));
38194
+ const raw = readJsonFileSync(join20(dir, file));
37808
38195
  if (raw && typeof raw.id === "string" && typeof raw.status === "string") {
37809
38196
  out.push({ id: raw.id, status: raw.status });
37810
38197
  }
@@ -37815,7 +38202,7 @@ var TAIL_BYTES = 256 * 1024;
37815
38202
  async function logStats(path) {
37816
38203
  let size;
37817
38204
  try {
37818
- size = statSync4(path).size;
38205
+ size = statSync5(path).size;
37819
38206
  } catch {
37820
38207
  return { path, exists: false, size: 0, errors: 0, warns: 0 };
37821
38208
  }
@@ -37834,7 +38221,7 @@ async function readTail(path, size) {
37834
38221
  async function logErrorRecords(path) {
37835
38222
  let size;
37836
38223
  try {
37837
- size = statSync4(path).size;
38224
+ size = statSync5(path).size;
37838
38225
  } catch {
37839
38226
  return [];
37840
38227
  }
@@ -37902,17 +38289,27 @@ function undecided(id, title, section) {
37902
38289
  reason: `the ${section} section could not be collected`
37903
38290
  };
37904
38291
  }
38292
+ var SERVICE_REMEDY = "run `caret install --refresh` \u2014 or check the service is not disabled \u2014 then read logs/daemon-stderr.log";
37905
38293
  function daemonReachable(report) {
37906
38294
  const daemon = present(report.daemon);
37907
38295
  if (daemon === undefined)
37908
38296
  return undecided("daemon-reachable", "Daemon", "daemon");
38297
+ if (daemon.serviceInstalled && daemon.serviceKeptAlive === false) {
38298
+ return {
38299
+ id: "daemon-reachable",
38300
+ title: "Daemon",
38301
+ status: "fail",
38302
+ detail: "a caret service is recorded for this install, but the supervisor is not keeping it alive (not loaded, turned off, or parked after failing)",
38303
+ remedy: SERVICE_REMEDY
38304
+ };
38305
+ }
37909
38306
  if (daemon.serviceInstalled && !daemon.reachable) {
37910
38307
  return {
37911
38308
  id: "daemon-reachable",
37912
38309
  title: "Daemon",
37913
38310
  status: "fail",
37914
38311
  detail: "a caret service is recorded for this install, but /api/health did not answer",
37915
- remedy: "run `caret install --refresh` \u2014 or check the service is not disabled \u2014 then read logs/daemon-stderr.log"
38312
+ remedy: SERVICE_REMEDY
37916
38313
  };
37917
38314
  }
37918
38315
  if (daemon.reachable && daemon.service !== "caret") {
@@ -37931,6 +38328,48 @@ function daemonReachable(report) {
37931
38328
  detail: daemon.reachable ? "answering on the effective port" : "not running"
37932
38329
  };
37933
38330
  }
38331
+ function daemonVersion(report) {
38332
+ const id = "daemon-version";
38333
+ const title = "Daemon version";
38334
+ const daemon = present(report.daemon);
38335
+ if (daemon === undefined)
38336
+ return undecided(id, title, "daemon");
38337
+ const v = daemon.daemonVersion;
38338
+ if (!daemon.reachable || daemon.service !== "caret") {
38339
+ return { id, title, status: "pass", detail: "no caret daemon is running" };
38340
+ }
38341
+ if (v === undefined) {
38342
+ return { id, title, status: "pass", detail: "the running caret did not report a version" };
38343
+ }
38344
+ if (daemon.isDev) {
38345
+ return {
38346
+ id,
38347
+ title,
38348
+ status: "pass",
38349
+ detail: `${v}, a development build \u2014 not compared with npm`
38350
+ };
38351
+ }
38352
+ const latest = daemon.npmLatest;
38353
+ if (latest == null) {
38354
+ return {
38355
+ id,
38356
+ title,
38357
+ status: "unknown",
38358
+ detail: v,
38359
+ reason: "npm's latest caret version could not be read"
38360
+ };
38361
+ }
38362
+ if (isNewer(latest, v)) {
38363
+ return {
38364
+ id,
38365
+ title,
38366
+ status: "fail",
38367
+ detail: `the running daemon is ${v}; npm's latest is ${latest}`,
38368
+ remedy: "run `caret install --refresh` to cycle the service onto the published caret"
38369
+ };
38370
+ }
38371
+ return { id, title, status: "pass", detail: v };
38372
+ }
37934
38373
  function daemonLock2(report) {
37935
38374
  const lock = present(report.lockAndPort);
37936
38375
  if (lock === undefined)
@@ -38019,6 +38458,7 @@ function logErrors(report) {
38019
38458
  function runChecks(report, adapterChecks = []) {
38020
38459
  return [
38021
38460
  daemonReachable(report),
38461
+ daemonVersion(report),
38022
38462
  daemonLock2(report),
38023
38463
  agentInstall(report),
38024
38464
  logErrors(report),
@@ -38027,7 +38467,7 @@ function runChecks(report, adapterChecks = []) {
38027
38467
  }
38028
38468
 
38029
38469
  // src/doctor/zip.ts
38030
- import { closeSync as closeSync2, openSync as openSync3, rmSync as rmSync2, writeSync } from "fs";
38470
+ import { closeSync as closeSync2, openSync as openSync3, rmSync as rmSync4, writeSync } from "fs";
38031
38471
  import { crc32 } from "zlib";
38032
38472
  var LOCAL_SIG = 67324752;
38033
38473
  var CENTRAL_SIG = 33639248;
@@ -38125,7 +38565,7 @@ function writeZip(path, entries, now) {
38125
38565
  }
38126
38566
  put(eocd(records.length, offset - directoryStart, directoryStart));
38127
38567
  } catch (e) {
38128
- rmSync2(path, { force: true });
38568
+ rmSync4(path, { force: true });
38129
38569
  throw e;
38130
38570
  } finally {
38131
38571
  closeSync2(fd);
@@ -38134,6 +38574,7 @@ function writeZip(path, entries, now) {
38134
38574
 
38135
38575
  // src/commands/doctor.ts
38136
38576
  init_build_id();
38577
+ init_upstream();
38137
38578
  function prodDoctorDeps(s) {
38138
38579
  return {
38139
38580
  now: () => new Date,
@@ -38146,7 +38587,7 @@ function prodDoctorDeps(s) {
38146
38587
  }),
38147
38588
  settings: () => s,
38148
38589
  configPath: configFile(),
38149
- configExists: () => existsSync11(configFile()),
38590
+ configExists: () => existsSync12(configFile()),
38150
38591
  effective: () => ({
38151
38592
  port: getPort(s),
38152
38593
  idleMs: idleMs(s),
@@ -38155,7 +38596,9 @@ function prodDoctorDeps(s) {
38155
38596
  }),
38156
38597
  baseUrl: `http://localhost:${getPort(s)}`,
38157
38598
  health: httpHealth,
38158
- serviceInstalled: () => existsSync11(launcherServiceFile()),
38599
+ serviceInstalled: () => existsSync12(launcherServiceFile()),
38600
+ serviceStatus: async () => prodService().manager.status(),
38601
+ publishedVersion: () => publishedCaretVersion(),
38159
38602
  readLock: readDaemonLock,
38160
38603
  readBootMarker,
38161
38604
  isPidAlive,
@@ -38237,42 +38680,46 @@ async function runDoctorSubcommand(opts) {
38237
38680
  }
38238
38681
  }
38239
38682
 
38683
+ // src/commands/install/claude.ts
38684
+ import { resolve as resolve3 } from "path";
38685
+
38240
38686
  // src/commands/install/local.ts
38241
38687
  import {
38242
38688
  accessSync as accessSync2,
38243
38689
  constants as constants2,
38244
38690
  existsSync as existsSync13,
38245
- mkdirSync as mkdirSync3,
38246
- rmSync as rmSync3,
38247
- statSync as statSync5,
38691
+ mkdirSync as mkdirSync5,
38692
+ rmSync as rmSync5,
38693
+ statSync as statSync6,
38248
38694
  symlinkSync,
38249
- writeFileSync as writeFileSync8
38695
+ writeFileSync as writeFileSync10
38250
38696
  } from "fs";
38251
- import { join as join19, resolve as resolve2 } from "path";
38697
+ import { join as join22, resolve as resolve2 } from "path";
38252
38698
 
38253
38699
  // src/adapters/opencode/packaging.ts
38254
- import { existsSync as existsSync12, readdirSync as readdirSync7, readFileSync as readFileSync12 } from "fs";
38255
- import { dirname as dirname9, join as join18 } from "path";
38700
+ init_entries();
38701
+ import { readdirSync as readdirSync7, readFileSync as readFileSync13 } from "fs";
38702
+ import { dirname as dirname9, join as join21 } from "path";
38256
38703
  function resolveCaretRoot() {
38257
38704
  const candidates = [];
38258
38705
  const script = process.argv[1];
38259
38706
  if (script)
38260
- candidates.push(join18(dirname9(script), ".."));
38261
- candidates.push(join18(dirname9(process.execPath), ".."));
38707
+ candidates.push(join21(dirname9(script), ".."));
38708
+ candidates.push(join21(dirname9(process.execPath), ".."));
38262
38709
  for (const root of candidates) {
38263
- if (existsSync12(join18(root, "opencode", "caret.plugin.ts")))
38710
+ if (isCaretCheckout(root))
38264
38711
  return root;
38265
38712
  }
38266
38713
  throw new Error(`caret OpenCode packaging not found (no opencode/caret.plugin.ts under: ${candidates.join(", ") || "(none)"}). The OpenCode plugin source must ship with caret.`);
38267
38714
  }
38268
38715
  var DEMO_TEMPLATE = "templates/demo.md";
38269
38716
  function loadOpencodePackaging(root = resolveCaretRoot()) {
38270
- const binPath = join18(root, "bin", "caret");
38271
- const demoTemplate = readFileSync12(join18(root, DEMO_TEMPLATE), "utf-8");
38272
- const commandsDir = join18(root, "opencode", "commands");
38717
+ const binPath = join21(root, "bin", "caret");
38718
+ const demoTemplate = readFileSync13(join21(root, DEMO_TEMPLATE), "utf-8");
38719
+ const commandsDir = join21(root, "opencode", "commands");
38273
38720
  let commands = [];
38274
38721
  try {
38275
- commands = readdirSync7(commandsDir).filter((f) => f.endsWith(".md")).sort().map((f) => ({ name: f, contents: readFileSync12(join18(commandsDir, f), "utf-8") }));
38722
+ commands = readdirSync7(commandsDir).filter((f) => f.endsWith(".md")).sort().map((f) => ({ name: f, contents: readFileSync13(join21(commandsDir, f), "utf-8") }));
38276
38723
  } catch {
38277
38724
  commands = [];
38278
38725
  }
@@ -38282,17 +38729,17 @@ function loadOpencodePackaging(root = resolveCaretRoot()) {
38282
38729
  // src/commands/install/local.ts
38283
38730
  init_paths3();
38284
38731
  function devMarketplaceDir() {
38285
- return join19(stateDir(), "dev-marketplace");
38732
+ return join22(stateDir(), "dev-marketplace");
38286
38733
  }
38287
38734
  function resolveLocalCheckout(opts = {}, deps = {}) {
38288
38735
  const repoDir = resolve2(caretRoot(deps));
38289
- if (!existsSync13(join19(repoDir, ".claude-plugin", "marketplace.json"))) {
38736
+ if (!existsSync13(join22(repoDir, ".claude-plugin", "marketplace.json"))) {
38290
38737
  throw new Error(`--from-local must run from a caret checkout (no .claude-plugin/marketplace.json at ${repoDir}). A published caret installs with a plain \`caret install\`.`);
38291
38738
  }
38292
38739
  if (opts.requireArtifacts !== false) {
38293
38740
  const missing = [
38294
- isExecutable(join19(repoDir, "bin", "caret-native")) ? null : "bin/caret-native",
38295
- isDirectory(join19(repoDir, "bin", "ui")) ? null : "bin/ui"
38741
+ isExecutable(join22(repoDir, "bin", "caret-native")) ? null : "bin/caret-native",
38742
+ isDirectory(join22(repoDir, "bin", "ui")) ? null : "bin/ui"
38296
38743
  ].filter((m) => m !== null);
38297
38744
  if (missing.length > 0) {
38298
38745
  throw new Error(`--from-local reuses the build artifacts bin/caret-native + bin/ui, and ${repoDir} is missing ${missing.join(" + ")} \u2014 run \`mise run build\` first.`);
@@ -38310,10 +38757,10 @@ function caretRoot(deps) {
38310
38757
  }
38311
38758
  }
38312
38759
  function writeDevMarketplace(repoDir, outDir) {
38313
- rmSync3(outDir, { recursive: true, force: true });
38314
- mkdirSync3(join19(outDir, ".claude-plugin"), { recursive: true });
38315
- symlinkSync(resolve2(repoDir), join19(outDir, "caret"));
38316
- writeFileSync8(join19(outDir, ".claude-plugin", "marketplace.json"), `${JSON.stringify({
38760
+ rmSync5(outDir, { recursive: true, force: true });
38761
+ mkdirSync5(join22(outDir, ".claude-plugin"), { recursive: true });
38762
+ symlinkSync(resolve2(repoDir), join22(outDir, "caret"));
38763
+ writeFileSync10(join22(outDir, ".claude-plugin", "marketplace.json"), `${JSON.stringify({
38317
38764
  name: "caret",
38318
38765
  description: "Local caret dev build (generated by caret install --from-local).",
38319
38766
  owner: { name: "macintacos" },
@@ -38324,20 +38771,20 @@ function writeDevMarketplace(repoDir, outDir) {
38324
38771
  async function prewarmLocalBuild(repoDir, deps = {}) {
38325
38772
  const spawn = deps.spawn ?? runCaptured;
38326
38773
  try {
38327
- await spawn([join19(repoDir, "bin", "caret-native"), "prewarm"]);
38774
+ await spawn([join22(repoDir, "bin", "caret-native"), "prewarm"]);
38328
38775
  } catch {}
38329
38776
  }
38330
38777
  function isExecutable(path) {
38331
38778
  try {
38332
38779
  accessSync2(path, constants2.X_OK);
38333
- return statSync5(path).isFile();
38780
+ return statSync6(path).isFile();
38334
38781
  } catch {
38335
38782
  return false;
38336
38783
  }
38337
38784
  }
38338
38785
  function isDirectory(path) {
38339
38786
  try {
38340
- return statSync5(path).isDirectory();
38787
+ return statSync6(path).isDirectory();
38341
38788
  } catch {
38342
38789
  return false;
38343
38790
  }
@@ -38392,6 +38839,38 @@ function parsePluginVersion(stdout, id) {
38392
38839
  return null;
38393
38840
  }
38394
38841
  }
38842
+ function readCaretMarketplace(stdout) {
38843
+ try {
38844
+ const parsed = JSON.parse(stdout);
38845
+ if (!Array.isArray(parsed))
38846
+ return { kind: "unreadable" };
38847
+ const entry = parsed.find((m) => typeof m === "object" && m !== null && ("name" in m) && m.name === MARKETPLACE_NAME);
38848
+ if (!entry)
38849
+ return { kind: "absent" };
38850
+ const location = entry.repo ?? entry.path ?? entry.url;
38851
+ if (typeof entry.source !== "string" || typeof location !== "string") {
38852
+ return { kind: "unreadable" };
38853
+ }
38854
+ return { kind: "registered", source: entry.source, location };
38855
+ } catch {
38856
+ return { kind: "unreadable" };
38857
+ }
38858
+ }
38859
+ function isPublished(marketplace) {
38860
+ return marketplace.kind === "registered" && marketplace.source === "github" && marketplace.location === MARKETPLACE_SOURCE;
38861
+ }
38862
+ function settledAsRegistered(marketplace) {
38863
+ return marketplace.kind === "unreadable" || isPublished(marketplace);
38864
+ }
38865
+ function registrationWarning(add, after, handBack) {
38866
+ if (settledAsRegistered(after))
38867
+ return null;
38868
+ const why = add?.ok === false ? ` (${add.detail})` : "";
38869
+ if (after.kind === "registered") {
38870
+ return `Claude Code's caret marketplace is ${after.location}, not ${MARKETPLACE_SOURCE}${why}, so the plugin update below reads from it. Run \`claude plugin marketplace remove caret\` and re-run \`caret install\`, or point \`extraKnownMarketplaces.caret\` at ${MARKETPLACE_SOURCE} where your Claude settings are managed.`;
38871
+ }
38872
+ return handBack ? `Could not register ${MARKETPLACE_SOURCE}${why}. Re-run \`caret install\` to retry, or run \`mise run build --install\` to go back to the local build.` : `Could not register ${MARKETPLACE_SOURCE}${why}.`;
38873
+ }
38395
38874
  function updateLine(before, after, updated) {
38396
38875
  if (!updated) {
38397
38876
  return before ? `caret ${before} in Claude Code \u2014 the update did not land` : "Could not ask Claude Code for the latest caret";
@@ -38402,7 +38881,12 @@ function updateLine(before, after, updated) {
38402
38881
  return `caret ${after} in Claude Code \u2014 already current`;
38403
38882
  return `caret ${before} \u2192 ${after} in Claude Code \u2014 restart to apply`;
38404
38883
  }
38405
- function phases(uninstall, local, writeDev) {
38884
+ function phases({
38885
+ uninstall,
38886
+ local,
38887
+ writeDev,
38888
+ handBack
38889
+ }) {
38406
38890
  if (uninstall) {
38407
38891
  return [
38408
38892
  {
@@ -38438,12 +38922,33 @@ function phases(uninstall, local, writeDev) {
38438
38922
  ];
38439
38923
  }
38440
38924
  return [
38925
+ ...handBack ? [
38926
+ {
38927
+ label: "Handing the caret marketplace back from the local build",
38928
+ done: ([removed]) => removed?.ok ? "Handed the caret marketplace back from the local build" : "Could not hand the caret marketplace back from the local build",
38929
+ warn: ([removed]) => removed?.ok === false ? `\`claude plugin marketplace remove caret\`: ${removed.detail}` : null,
38930
+ commands: [
38931
+ {
38932
+ args: ["plugin", "marketplace", "remove", MARKETPLACE_NAME],
38933
+ fatal: false,
38934
+ when: "caret's local dev marketplace is registered"
38935
+ }
38936
+ ]
38937
+ }
38938
+ ] : [],
38441
38939
  {
38442
38940
  label: "Registering the caret marketplace",
38443
- done: `Registered the caret marketplace (${MARKETPLACE_SOURCE})`,
38941
+ done: ([, , listed]) => {
38942
+ const after = readCaretMarketplace(listed?.stdout ?? "");
38943
+ if (settledAsRegistered(after))
38944
+ return `Registered the caret marketplace (${MARKETPLACE_SOURCE})`;
38945
+ return after.kind === "registered" ? `Claude Code's caret marketplace is ${after.location}, not ${MARKETPLACE_SOURCE}` : "Could not register the caret marketplace";
38946
+ },
38947
+ warn: ([add, , listed]) => registrationWarning(add, readCaretMarketplace(listed?.stdout ?? ""), handBack),
38444
38948
  commands: [
38445
38949
  { args: ["plugin", "marketplace", "add", MARKETPLACE_SOURCE], fatal: false },
38446
- { args: ["plugin", "marketplace", "update", MARKETPLACE_NAME], fatal: false }
38950
+ { args: ["plugin", "marketplace", "update", MARKETPLACE_NAME], fatal: false },
38951
+ { args: ["plugin", "marketplace", "list", "--json"], fatal: false }
38447
38952
  ]
38448
38953
  },
38449
38954
  {
@@ -38476,16 +38981,27 @@ class PhaseFailure extends Error {
38476
38981
  this.missing = missing;
38477
38982
  }
38478
38983
  }
38984
+ async function registeredAtDevDir(run, devDir = devMarketplaceDir) {
38985
+ const marketplace = readCaretMarketplace((await run(["plugin", "marketplace", "list", "--json"])).stdout);
38986
+ return marketplace.kind === "registered" && marketplace.source === "directory" && resolve3(marketplace.location) === resolve3(devDir());
38987
+ }
38479
38988
  async function runInstallClaudeTarget(opts, deps = {}) {
38480
38989
  const run = deps.claude ?? claudeCli;
38481
38990
  const ui = deps.ui ?? silentUI;
38482
38991
  const local = opts.uninstall ? undefined : opts.local;
38483
- const plan = phases(opts.uninstall, local, deps.writeDevMarketplace ?? writeDevMarketplace);
38992
+ const published = !opts.uninstall && !local;
38993
+ const handBack = published && (opts.dryRun || await registeredAtDevDir(run, deps.devMarketplaceDir));
38994
+ const plan = phases({
38995
+ uninstall: opts.uninstall,
38996
+ local,
38997
+ writeDev: deps.writeDevMarketplace ?? writeDevMarketplace,
38998
+ handBack
38999
+ });
38484
39000
  if (opts.dryRun) {
38485
39001
  const lines = plan.flatMap((p) => [
38486
39002
  ...local && p.before ? [`write the dev marketplace at ${local.marketplaceDir}`] : [],
38487
39003
  ...p.commands.flatMap((c) => [
38488
- `claude ${c.args.join(" ")}`,
39004
+ `${c.when ? `(if ${c.when}) ` : ""}claude ${c.args.join(" ")}`,
38489
39005
  ...c.fallback ? [` (on failure) claude ${c.fallback.join(" ")}`] : []
38490
39006
  ])
38491
39007
  ]);
@@ -38534,11 +39050,11 @@ async function runInstallClaudeTarget(opts, deps = {}) {
38534
39050
 
38535
39051
  // src/commands/install/opencode.ts
38536
39052
  init_config_plugin();
38537
- import { existsSync as existsSync16, writeFileSync as writeFileSync10 } from "fs";
38538
- import { basename as basename5, join as join20 } from "path";
39053
+ import { writeFileSync as writeFileSync12 } from "fs";
39054
+ import { basename as basename5, join as join23 } from "path";
38539
39055
 
38540
39056
  // src/adapters/opencode/deploy.ts
38541
- import { existsSync as existsSync14, mkdirSync as mkdirSync4, rmSync as rmSync4, writeFileSync as writeFileSync9 } from "fs";
39057
+ import { existsSync as existsSync14, mkdirSync as mkdirSync6, rmSync as rmSync6, writeFileSync as writeFileSync11 } from "fs";
38542
39058
  import { dirname as dirname10 } from "path";
38543
39059
  function renderPlugin(source, opts) {
38544
39060
  return source.replaceAll("__CARET_VERSION__", () => opts.version).replaceAll("__CARET_BIN__", () => opts.binPath).replaceAll("__CARET_DEMO_TEMPLATE__", () => opts.demoTemplate);
@@ -38547,8 +39063,8 @@ function deployFiles(files, opts) {
38547
39063
  const paths = [];
38548
39064
  for (const f of files) {
38549
39065
  if (!opts.dryRun) {
38550
- mkdirSync4(dirname10(f.path), { recursive: true });
38551
- writeFileSync9(f.path, f.contents);
39066
+ mkdirSync6(dirname10(f.path), { recursive: true });
39067
+ writeFileSync11(f.path, f.contents);
38552
39068
  }
38553
39069
  paths.push(f.path);
38554
39070
  }
@@ -38560,13 +39076,14 @@ function removeFiles(targets, opts) {
38560
39076
  if (!existsSync14(p))
38561
39077
  continue;
38562
39078
  if (!opts.dryRun)
38563
- rmSync4(p, { force: true });
39079
+ rmSync6(p, { force: true });
38564
39080
  paths.push(p);
38565
39081
  }
38566
39082
  return { paths, dryRun: opts.dryRun };
38567
39083
  }
38568
39084
 
38569
39085
  // src/commands/install/opencode.ts
39086
+ init_entries();
38570
39087
  init_paths2();
38571
39088
  init_upgrade();
38572
39089
 
@@ -38643,15 +39160,6 @@ async function promptUpgrade(verdict, clack) {
38643
39160
 
38644
39161
  // src/commands/install/opencode.ts
38645
39162
  init_build_id();
38646
- function isCaretCheckout(dir) {
38647
- return existsSync16(join20(dir, "opencode", "caret.plugin.ts"));
38648
- }
38649
- function caretEntries(text, isCheckout) {
38650
- return pluginEntries(text).filter((entry) => {
38651
- const path = localSpecifierPath(entry);
38652
- return path === undefined ? splitPluginSpecifier(entry).pkg === CARET_PACKAGE : isCheckout(path);
38653
- });
38654
- }
38655
39163
  function sameEntryForm(entry, specifier) {
38656
39164
  const entryIsLocal = isLocalPluginSpecifier(entry);
38657
39165
  if (entryIsLocal !== isLocalPluginSpecifier(specifier))
@@ -38670,7 +39178,7 @@ async function runInstallOpencodeTarget(opts, deps = {}) {
38670
39178
  const ui = deps.ui ?? silentUI;
38671
39179
  const isCheckout = deps.isCheckout ?? isCaretCheckout;
38672
39180
  const configFile = resolveConfigFile(dir);
38673
- const commandPaths = pkg.commands.map((c) => join20(commandDir(dir), namespacedCommandFilename(c.name)));
39181
+ const commandPaths = pkg.commands.map((c) => join23(commandDir(dir), namespacedCommandFilename(c.name)));
38674
39182
  const legacy = existingLegacyInstallFiles(dir);
38675
39183
  const specifier = opts.local ? localPluginSpecifier(opts.local.repoDir) : CARET_PACKAGE;
38676
39184
  if (opts.dryRun) {
@@ -38693,7 +39201,7 @@ async function runInstallOpencodeTarget(opts, deps = {}) {
38693
39201
  await upgradeStep(configFile, opts, deps, ui);
38694
39202
  await sweepLegacy(legacy, dir, ui);
38695
39203
  const files = pkg.commands.map((c) => ({
38696
- path: join20(commandDir(dir), namespacedCommandFilename(c.name)),
39204
+ path: join23(commandDir(dir), namespacedCommandFilename(c.name)),
38697
39205
  contents: renderPlugin(c.contents, {
38698
39206
  version: VERSION,
38699
39207
  binPath: pkg.binPath,
@@ -38715,7 +39223,7 @@ function previewLine(verdict) {
38715
39223
  return verdict.kind === "unknown" ? `${line} (${verdict.reason})` : line;
38716
39224
  }
38717
39225
  async function readVerdict(configFile, deps) {
38718
- return readUpgradeVerdict({ configFile, cacheDirs: deps.cacheDirs, published: deps.published });
39226
+ return readUpgradeVerdict({ configFile, cacheDir: deps.cacheDir, published: deps.published });
38719
39227
  }
38720
39228
  async function upgradeStep(configFile, opts, deps, ui) {
38721
39229
  const verdict = await ui.step("Checking OpenCode's caret version", () => readVerdict(configFile, deps), upgradeVerdictLine);
@@ -38746,26 +39254,101 @@ function editConfig(path, transform) {
38746
39254
  const next = transform(existing);
38747
39255
  if (next === null || next === existing)
38748
39256
  return [];
38749
- writeFileSync10(path, next);
39257
+ writeFileSync12(path, next);
38750
39258
  return [path];
38751
39259
  }
38752
39260
 
38753
39261
  // src/commands/install/launcher.ts
38754
- import { chmodSync as chmodSync4, copyFileSync, existsSync as existsSync17, renameSync as renameSync5, rmSync as rmSync5, writeFileSync as writeFileSync11 } from "fs";
38755
- import { dirname as dirname11, join as join21 } from "path";
39262
+ init_zod();
39263
+ init_paths();
39264
+ import {
39265
+ chmodSync as chmodSync4,
39266
+ copyFileSync,
39267
+ cpSync,
39268
+ existsSync as existsSync16,
39269
+ mkdirSync as mkdirSync7,
39270
+ mkdtempSync,
39271
+ readdirSync as readdirSync8,
39272
+ readFileSync as readFileSync14,
39273
+ renameSync as renameSync5,
39274
+ rmSync as rmSync7,
39275
+ statSync as statSync7,
39276
+ writeFileSync as writeFileSync13
39277
+ } from "fs";
39278
+ import { basename as basename6, dirname as dirname11, join as join24 } from "path";
39279
+ init_paths2();
38756
39280
  init_paths3();
39281
+ init_lifecycle();
38757
39282
  init_build_id();
39283
+ init_json_file();
39284
+ var PackageFiles = object({ files: array(string2()) });
39285
+ function publishedRoot(kind = buildKind(), root = resolveCaretRoot) {
39286
+ if (kind !== "bundle")
39287
+ return;
39288
+ const dir = root();
39289
+ return existsSync16(join24(dir, "src", "cli.ts")) ? undefined : { root: dir, version: VERSION };
39290
+ }
39291
+ function stageOwnedRoot(from) {
39292
+ if (!isRunnableRoot(from.root))
39293
+ return;
39294
+ const dest = join24(ownedRootsDir(), from.version);
39295
+ if (isRunnableRoot(dest))
39296
+ return;
39297
+ const parsed = PackageFiles.safeParse(readJsonFileSync(join24(from.root, "package.json")));
39298
+ if (!parsed.success)
39299
+ return;
39300
+ ensureStateDir(ownedRootsDir());
39301
+ const tmp = mkdtempSync(join24(ownedRootsDir(), `.${from.version}.`));
39302
+ try {
39303
+ for (const entry of [...parsed.data.files, "package.json"]) {
39304
+ const src = join24(from.root, entry);
39305
+ if (!existsSync16(src))
39306
+ continue;
39307
+ const target = join24(tmp, entry);
39308
+ mkdirSync7(dirname11(target), { recursive: true });
39309
+ cpSync(src, target, { recursive: true });
39310
+ }
39311
+ if (!isRunnableRoot(tmp))
39312
+ return;
39313
+ rmSync7(dest, { recursive: true, force: true });
39314
+ renameSync5(tmp, dest);
39315
+ } finally {
39316
+ rmSync7(tmp, { recursive: true, force: true });
39317
+ }
39318
+ }
39319
+ function pruneOwnedRoots() {
39320
+ let entries;
39321
+ try {
39322
+ entries = readdirSync8(ownedRootsDir());
39323
+ } catch {
39324
+ return;
39325
+ }
39326
+ const keep = pickLauncherRoot(null, listDirs(ownedRootsDir()).map((dir) => ({ dir, owned: true })))?.root;
39327
+ for (const name of entries) {
39328
+ const path = join24(ownedRootsDir(), name);
39329
+ if (path === keep)
39330
+ continue;
39331
+ try {
39332
+ rmSync7(path, { recursive: true, force: true });
39333
+ } catch {}
39334
+ }
39335
+ }
38758
39336
  function installLauncher(deps = {}) {
38759
- const source = (deps.source ?? (() => join21(resolveCaretRoot(), "bin", "caret-launcher")))();
39337
+ const source = (deps.source ?? (() => join24(resolveCaretRoot(), "bin", "caret-launcher")))();
39338
+ if (deps.pinnedRoot === undefined) {
39339
+ const owned = (deps.ownedRoot ?? publishedRoot)();
39340
+ if (owned)
39341
+ stageOwnedRoot(owned);
39342
+ }
38760
39343
  ensureStateDir(dirname11(launcherPath()));
38761
39344
  const tmp = `${launcherPath()}.${process.pid}.tmp`;
38762
39345
  copyFileSync(source, tmp);
38763
39346
  chmodSync4(tmp, 493);
38764
39347
  renameSync5(tmp, launcherPath());
38765
39348
  const bunPath = deps.bunPath ?? (buildKind() === "binary" ? undefined : process.execPath);
38766
- const unpinned = deps.pinnedRoot === undefined && existsSync17(launcherPinnedRootFile());
39349
+ const unpinned = deps.pinnedRoot === undefined && existsSync16(launcherPinnedRootFile());
38767
39350
  if (unpinned)
38768
- rmSync5(launcherPinnedRootFile(), { force: true });
39351
+ rmSync7(launcherPinnedRootFile(), { force: true });
38769
39352
  if (bunPath === undefined && deps.serviceLabel === undefined && deps.pinnedRoot === undefined) {
38770
39353
  return { unpinned };
38771
39354
  }
@@ -38779,12 +39362,74 @@ function installLauncher(deps = {}) {
38779
39362
  return { unpinned };
38780
39363
  }
38781
39364
  function writeRecord(path, value) {
38782
- writeFileSync11(path, `${value}
39365
+ writeFileSync13(path, `${value}
38783
39366
  `, { mode: 384 });
38784
39367
  }
38785
39368
  function uninstallLauncher() {
38786
- rmSync5(dirname11(launcherPath()), { recursive: true, force: true });
38787
- rmSync5(launcherRecordDir(), { recursive: true, force: true });
39369
+ rmSync7(dirname11(launcherPath()), { recursive: true, force: true });
39370
+ rmSync7(launcherRecordDir(), { recursive: true, force: true });
39371
+ rmSync7(ownedRootsDir(), { recursive: true, force: true });
39372
+ }
39373
+ function listDirs(dir) {
39374
+ let names;
39375
+ try {
39376
+ names = readdirSync8(dir);
39377
+ } catch {
39378
+ return [];
39379
+ }
39380
+ return names.filter((n) => !n.startsWith(".")).sort().map((n) => join24(dir, n)).filter(isDir);
39381
+ }
39382
+ function isDir(path) {
39383
+ try {
39384
+ return statSync7(path).isDirectory();
39385
+ } catch {
39386
+ return false;
39387
+ }
39388
+ }
39389
+ function launcherCandidateDirs() {
39390
+ const opencode = listDirs(dirname11(opencodeCachePackageDir())).filter((d) => basename6(d).startsWith("caret")).map((d) => join24(d, "node_modules", "@macintacos", "caret")).filter(isDir);
39391
+ return [
39392
+ ...[
39393
+ ...listDirs(join24(claudeConfigDir(), "plugins", "cache", "caret", "caret")),
39394
+ ...opencode
39395
+ ].map((dir) => ({ dir, owned: false })),
39396
+ ...listDirs(ownedRootsDir()).map((dir) => ({ dir, owned: true }))
39397
+ ];
39398
+ }
39399
+ function manifestVersion(root) {
39400
+ try {
39401
+ const text = readFileSync14(join24(root, "package.json"), "utf8");
39402
+ return text.match(/^[^\S\n]*"version"[^\S\n]*:[^\S\n]*"([^"\n]*)"/m)?.[1];
39403
+ } catch {
39404
+ return;
39405
+ }
39406
+ }
39407
+ function pickLauncherRoot(pin, candidates) {
39408
+ if (pin !== null && isRunnableRoot(pin)) {
39409
+ return { root: pin, version: manifestVersion(pin) || "unknown" };
39410
+ }
39411
+ const lines = [];
39412
+ for (const { dir, owned } of candidates) {
39413
+ if (!isRunnableRoot(dir))
39414
+ continue;
39415
+ const version = manifestVersion(dir);
39416
+ if (!version)
39417
+ continue;
39418
+ const key = version.split(".").slice(0, 3).map((f) => Number.parseInt(f, 10) || 0);
39419
+ lines.push({ line: `${version} ${owned ? 0 : 1} ${dir}`, key, root: { root: dir, version } });
39420
+ }
39421
+ lines.sort((a, b) => {
39422
+ for (let i = 0;i < 3; i++) {
39423
+ const d = (a.key[i] ?? 0) - (b.key[i] ?? 0);
39424
+ if (d !== 0)
39425
+ return d;
39426
+ }
39427
+ return a.line < b.line ? -1 : a.line > b.line ? 1 : 0;
39428
+ });
39429
+ return lines.at(-1)?.root ?? null;
39430
+ }
39431
+ function prodLauncherRoot() {
39432
+ return pickLauncherRoot(readPinnedRoot(), launcherCandidateDirs());
38788
39433
  }
38789
39434
 
38790
39435
  // src/commands/install/service.ts
@@ -38792,6 +39437,67 @@ init_constants();
38792
39437
  init_paths3();
38793
39438
  init_settings();
38794
39439
  init_lifecycle();
39440
+ init_build_id();
39441
+ function prodServiceWatch() {
39442
+ return { version: VERSION, health: httpHealth, sleep: Bun.sleep };
39443
+ }
39444
+ var SETTLE_POLL_MS = 500;
39445
+ var SETTLE_WINDOW_MS = 30000;
39446
+ var SETTLE_ATTEMPTS = SETTLE_WINDOW_MS / SETTLE_POLL_MS;
39447
+ function classify(health, installerVersion, replaced) {
39448
+ if (health?.service !== "caret")
39449
+ return { kind: "silent" };
39450
+ const answeringVersion = health.version;
39451
+ if (replaced !== undefined && health.instanceId === replaced) {
39452
+ return { kind: "replaced", version: answeringVersion };
39453
+ }
39454
+ if ((health.supervised ?? health.resident) !== true)
39455
+ return { kind: "unsupervised", version: answeringVersion };
39456
+ if (answeringVersion === undefined)
39457
+ return { kind: "silent" };
39458
+ return isNewer(installerVersion, answeringVersion) ? { kind: "stale", version: answeringVersion } : { kind: "ready", version: answeringVersion };
39459
+ }
39460
+ async function awaitServed(baseUrl, watch, replaced) {
39461
+ let served = { kind: "silent" };
39462
+ for (let attempt = 0;attempt < SETTLE_ATTEMPTS; attempt++) {
39463
+ served = classify(await watch.health(baseUrl), watch.version, replaced);
39464
+ if (served.kind === "ready")
39465
+ return served;
39466
+ await watch.sleep(SETTLE_POLL_MS);
39467
+ }
39468
+ return served;
39469
+ }
39470
+ function servedWarning(served, installerVersion, cycled) {
39471
+ const log = `Read ${daemonStderrLogFile()}; caret still starts on demand.`;
39472
+ const at = (v) => v === undefined ? "" : ` (caret ${v})`;
39473
+ switch (served.kind) {
39474
+ case "ready":
39475
+ return null;
39476
+ case "stale":
39477
+ return [
39478
+ `The caret service is serving caret ${served.version}, not ${installerVersion}.`,
39479
+ cycled ? undefined : "Run `caret install --refresh` to cycle it.",
39480
+ `If it persists, read ${daemonStderrLogFile()}.`
39481
+ ].filter(Boolean).join(`
39482
+ `);
39483
+ case "replaced":
39484
+ return `The daemon the restart replaced${at(served.version)} is still answering.
39485
+ ${log}`;
39486
+ case "unsupervised":
39487
+ return `A caret the service did not start${at(served.version)} holds the port.
39488
+ The service takes over once it exits.`;
39489
+ case "silent":
39490
+ return `No caret daemon answered within ${SETTLE_WINDOW_MS / 1000} seconds.
39491
+ ${log}`;
39492
+ }
39493
+ }
39494
+ async function settleService(baseUrl, watch, replaced, cycled, ui) {
39495
+ const served = await ui.step("Waiting for the caret service", () => awaitServed(baseUrl, watch, replaced), (s) => s.kind === "ready" ? `caret ${s.version} answered` : "The caret service is not up yet");
39496
+ const warning = servedWarning(served, watch.version, cycled);
39497
+ if (warning !== null)
39498
+ ui.warn(warning);
39499
+ return warning === null;
39500
+ }
38795
39501
  async function withService(deps, ui, body) {
38796
39502
  if (deps.service === undefined)
38797
39503
  return;
@@ -38815,7 +39521,9 @@ async function uninstallService(opts, deps, ui) {
38815
39521
  }
38816
39522
  var SERVE_COMMAND = "bunx --no-cache @macintacos/caret@latest serve";
38817
39523
  async function reconcileService(opts, deps, ui) {
38818
- const reviewUrl = `http://${VANITY_HOST}:${getPort(loadSettings())}`;
39524
+ const port = getPort(loadSettings());
39525
+ const reviewUrl = `http://${VANITY_HOST}:${port}`;
39526
+ const baseUrl = `http://localhost:${port}`;
38819
39527
  if (opts.choice === "run-yourself")
38820
39528
  return runYourself({ ...opts, reviewUrl }, deps, ui);
38821
39529
  await withService(deps, ui, async (target) => {
@@ -38848,10 +39556,24 @@ async function reconcileService(opts, deps, ui) {
38848
39556
  environment: serviceEnvironment(process.env),
38849
39557
  terminalExitStatus: SERVICE_TERMINAL_EXIT_STATUS
38850
39558
  });
38851
- if (opts.refresh || opts.pinnedRoot !== undefined || unpinned)
39559
+ const nextRoot = predictLauncherRoot(deps);
39560
+ if (nextRoot === null) {
39561
+ ui.warn("No runnable caret was found for the caret service to start \u2014 run `caret install` again once an agent has installed caret.");
39562
+ return;
39563
+ }
39564
+ const cycles = opts.refresh || opts.pinnedRoot !== undefined || unpinned;
39565
+ const { watch } = deps;
39566
+ const replaced = cycles && watch ? (await watch.health(baseUrl))?.instanceId : undefined;
39567
+ if (cycles)
38852
39568
  await manager.restart();
39569
+ const settled = !watch || await settleService(baseUrl, watch, replaced, cycles, ui);
39570
+ if (cycles)
39571
+ pruneOwnedRoots();
39572
+ if (!settled)
39573
+ return;
38853
39574
  const announcement = [
38854
39575
  `The review UI now stays up at ${reviewUrl}`,
39576
+ cycles && nextRoot && `It starts caret ${nextRoot.version} from ${nextRoot.root}.`,
38855
39577
  `It's listed in ${visibleIn}.`,
38856
39578
  `To turn it off, run \`caret install\` and answer "I'll run it myself".`,
38857
39579
  visibleToggleCaveat
@@ -38860,6 +39582,13 @@ async function reconcileService(opts, deps, ui) {
38860
39582
  `));
38861
39583
  });
38862
39584
  }
39585
+ function predictLauncherRoot(deps) {
39586
+ try {
39587
+ return deps.launcherRoot?.();
39588
+ } catch {
39589
+ return;
39590
+ }
39591
+ }
38863
39592
  async function runYourself(opts, deps, ui) {
38864
39593
  const removed = await withService(deps, ui, async ({ manager }) => {
38865
39594
  const status = await manager.status();
@@ -39016,313 +39745,6 @@ async function selectServiceChoice(opts, deps, ui) {
39016
39745
  return choice;
39017
39746
  }
39018
39747
 
39019
- // src/service/index.ts
39020
- var SERVICE_LABELS = {
39021
- darwin: LAUNCHD_LABEL,
39022
- linux: SYSTEMD_UNIT
39023
- };
39024
- function servicePlatform(platform = process.platform) {
39025
- if (platform !== "darwin" && platform !== "linux") {
39026
- throw new Error(`caret service: unsupported platform ${platform} (darwin/linux only)`);
39027
- }
39028
- return platform;
39029
- }
39030
-
39031
- // src/service/launchd-manager.ts
39032
- init_log();
39033
- import { mkdirSync as mkdirSync5, rmSync as rmSync6, writeFileSync as writeFileSync12 } from "fs";
39034
- import { homedir as homedir6 } from "os";
39035
- import { join as join22 } from "path";
39036
-
39037
- // src/service/launchd.ts
39038
- var EXIT_TIMEOUT_SEC = 20;
39039
- function escapeXml(value) {
39040
- return value.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;");
39041
- }
39042
- function stringEntry(key, value, indent) {
39043
- return `${indent}<key>${escapeXml(key)}</key>
39044
- ${indent}<string>${escapeXml(value)}</string>`;
39045
- }
39046
- function buildLaunchdPlist(cfg) {
39047
- const args = [cfg.launcherPath, ...SERVICE_ARGS].map((arg) => ` <string>${escapeXml(arg)}</string>`).join(`
39048
- `);
39049
- const environment = sortedEnvironment(cfg.environment).map(([key, value]) => stringEntry(key, value, " ")).join(`
39050
- `);
39051
- return `<?xml version="1.0" encoding="UTF-8"?>
39052
- <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
39053
- <plist version="1.0">
39054
- <dict>
39055
- ${stringEntry("Label", cfg.label, " ")}
39056
- <key>ProgramArguments</key>
39057
- <array>
39058
- ${args}
39059
- </array>
39060
- <key>RunAtLoad</key>
39061
- <true/>
39062
- <key>KeepAlive</key>
39063
- <true/>
39064
- <key>ExitTimeOut</key>
39065
- <integer>${EXIT_TIMEOUT_SEC}</integer>
39066
- ${stringEntry("WorkingDirectory", cfg.workingDirectory, " ")}
39067
- <key>EnvironmentVariables</key>
39068
- <dict>
39069
- ${environment}
39070
- </dict>
39071
- </dict>
39072
- </plist>
39073
- `;
39074
- }
39075
-
39076
- // src/service/run.ts
39077
- async function runCommand(argv) {
39078
- let proc;
39079
- try {
39080
- proc = Bun.spawn(argv, { stdout: "pipe", stderr: "pipe" });
39081
- } catch (err) {
39082
- return { code: 127, stdout: "", stderr: errorMessage(err) };
39083
- }
39084
- const [stdout, stderr, code] = await Promise.all([
39085
- new Response(proc.stdout).text(),
39086
- new Response(proc.stderr).text(),
39087
- proc.exited
39088
- ]);
39089
- return { code, stdout, stderr };
39090
- }
39091
- function commandError(tool, verb, result) {
39092
- return new Error(`caret service: ${tool} ${verb} failed (${result.code}): ${result.stderr.trim()}`);
39093
- }
39094
-
39095
- // src/service/unit-file.ts
39096
- import { readFileSync as readFileSync13 } from "fs";
39097
- function unitUnchanged(path, text) {
39098
- try {
39099
- return readFileSync13(path, "utf-8") === text;
39100
- } catch {
39101
- return false;
39102
- }
39103
- }
39104
-
39105
- // src/service/launchd-manager.ts
39106
- var spawnLaunchctl = (args) => runCommand(["launchctl", ...args]);
39107
- var RUNNING = [/^\s*state\s*=\s*running\b/m, /^\s*pid\s*=\s*\d+/m];
39108
- var DISABLED2 = new RegExp(`"${LAUNCHD_LABEL.replace(/\./g, "\\.")}"\\s*=>\\s*(?:true|disabled)\\b`);
39109
- var launchctlError = (action, result) => commandError("launchctl", action, result);
39110
- function createLaunchdManager(deps = {}) {
39111
- const launchAgentsDir = deps.launchAgentsDir ?? join22(homedir6(), "Library", "LaunchAgents");
39112
- const launchctl = deps.launchctl ?? spawnLaunchctl;
39113
- const uid = deps.uid ?? process.getuid?.();
39114
- if (uid === undefined)
39115
- throw new Error("caret service: launchd needs a POSIX uid");
39116
- const domain = `gui/${uid}`;
39117
- const target = `${domain}/${LAUNCHD_LABEL}`;
39118
- const plistPath = join22(launchAgentsDir, `${LAUNCHD_LABEL}.plist`);
39119
- async function readStatus() {
39120
- const [printed, printDisabled] = await Promise.all([
39121
- launchctl(["print", target]),
39122
- launchctl(["print-disabled", domain])
39123
- ]);
39124
- const installed = printed.code === 0;
39125
- const disabled = DISABLED2.test(printDisabled.stdout);
39126
- return {
39127
- installed,
39128
- running: installed && RUNNING.some((pattern) => pattern.test(printed.stdout)),
39129
- disabled,
39130
- keepsAlive: installed && !disabled
39131
- };
39132
- }
39133
- return {
39134
- async install(cfg) {
39135
- if (cfg.label !== LAUNCHD_LABEL) {
39136
- throw new Error(`caret service: plist label ${cfg.label} is not ${LAUNCHD_LABEL}`);
39137
- }
39138
- const text = buildLaunchdPlist(cfg);
39139
- if (unitUnchanged(plistPath, text)) {
39140
- const current = await readStatus();
39141
- if (current.installed && current.running) {
39142
- logDebug("service", "launchd agent unchanged; install skipped");
39143
- return;
39144
- }
39145
- }
39146
- mkdirSync5(launchAgentsDir, { recursive: true });
39147
- writeFileSync12(plistPath, text);
39148
- await launchctl(["bootout", target]);
39149
- const bootstrapped = await launchctl(["bootstrap", domain, plistPath]);
39150
- if (bootstrapped.code !== 0)
39151
- throw launchctlError("bootstrap", bootstrapped);
39152
- },
39153
- async uninstall() {
39154
- await launchctl(["bootout", target]);
39155
- rmSync6(plistPath, { force: true });
39156
- },
39157
- status: readStatus,
39158
- async restart() {
39159
- const kicked = await launchctl(["kickstart", "-k", target]);
39160
- if (kicked.code !== 0)
39161
- throw launchctlError("kickstart", kicked);
39162
- }
39163
- };
39164
- }
39165
-
39166
- // src/service/systemd-manager.ts
39167
- init_log();
39168
- import { mkdirSync as mkdirSync6, rmSync as rmSync7, writeFileSync as writeFileSync13 } from "fs";
39169
- import { homedir as homedir7 } from "os";
39170
- import { join as join23 } from "path";
39171
-
39172
- // src/service/systemd.ts
39173
- var START_LIMIT_INTERVAL_SEC = 60;
39174
- var START_LIMIT_BURST = 5;
39175
- var RESTART_DELAY_SEC = 5;
39176
- function unitValue(value) {
39177
- return value.replace(/%/g, "%%");
39178
- }
39179
- function quote(value) {
39180
- const escaped = unitValue(value).replace(/[\\"]/g, (c) => `\\${c}`).replace(/\n/g, "\\n");
39181
- return `"${escaped}"`;
39182
- }
39183
- function execArg(value) {
39184
- return quote(value).replace(/\$/g, "$$$$");
39185
- }
39186
- function buildSystemdUnit(cfg) {
39187
- const execStart = [cfg.launcherPath, ...SERVICE_ARGS].map(execArg).join(" ");
39188
- const environment = sortedEnvironment(cfg.environment).map(([key, value]) => `Environment=${quote(`${key}=${value}`)}`).join(`
39189
- `);
39190
- return `[Unit]
39191
- Description=caret review daemon
39192
- After=default.target
39193
- StartLimitIntervalSec=${START_LIMIT_INTERVAL_SEC}
39194
- StartLimitBurst=${START_LIMIT_BURST}
39195
-
39196
- [Service]
39197
- Type=simple
39198
- ExecStart=${execStart}
39199
- WorkingDirectory=${unitValue(cfg.workingDirectory)}
39200
- Restart=always
39201
- RestartSec=${RESTART_DELAY_SEC}
39202
- RestartPreventExitStatus=${cfg.terminalExitStatus}
39203
- ${environment}
39204
-
39205
- [Install]
39206
- WantedBy=default.target
39207
- `;
39208
- }
39209
-
39210
- // src/service/systemd-manager.ts
39211
- function createSystemdManager(deps = {}) {
39212
- const configHome = process.env.XDG_CONFIG_HOME || join23(homedir7(), ".config");
39213
- const unitDir = deps.unitDir ?? join23(configHome, "systemd", "user");
39214
- const run = deps.run ?? runCommand;
39215
- const unitPath = join23(unitDir, SYSTEMD_UNIT);
39216
- const systemctl = (...args) => run(["systemctl", "--user", ...args]);
39217
- async function probeSystemd() {
39218
- const shown = await systemctl("show-environment");
39219
- if (shown.code === 0)
39220
- return;
39221
- return `caret service: no systemd user session (${shown.code}): ${shown.stderr.trim()}`;
39222
- }
39223
- async function readEnablement() {
39224
- const [active, enabled] = await Promise.all([
39225
- systemctl("is-active", SYSTEMD_UNIT),
39226
- systemctl("is-enabled", SYSTEMD_UNIT)
39227
- ]);
39228
- const enablement = enabled.stdout.trim();
39229
- const activity = active.stdout.trim();
39230
- const installed = enablement !== "" && enablement !== "not-found";
39231
- const disabled = enablement === "disabled" || enablement.startsWith("masked");
39232
- return {
39233
- installed,
39234
- running: activity === "active",
39235
- disabled,
39236
- keepsAlive: installed && !disabled && activity !== "inactive" && activity !== "failed"
39237
- };
39238
- }
39239
- async function readStatus() {
39240
- const unsupported = await probeSystemd();
39241
- if (unsupported) {
39242
- return { installed: false, running: false, disabled: false, keepsAlive: false, unsupported };
39243
- }
39244
- return readEnablement();
39245
- }
39246
- async function enableLinger() {
39247
- const lingering = await run(["loginctl", "enable-linger"]);
39248
- if (lingering.code !== 0) {
39249
- logWarn("service", "lingering not enabled; caret stops at logout", {
39250
- code: lingering.code,
39251
- stderr: lingering.stderr.trim()
39252
- });
39253
- }
39254
- }
39255
- return {
39256
- async install(cfg) {
39257
- if (cfg.label !== SYSTEMD_UNIT) {
39258
- throw new Error(`caret service: unit label ${cfg.label} is not ${SYSTEMD_UNIT}`);
39259
- }
39260
- const unsupported = await probeSystemd();
39261
- if (unsupported)
39262
- throw new Error(unsupported);
39263
- const text = buildSystemdUnit(cfg);
39264
- if (unitUnchanged(unitPath, text)) {
39265
- const current = await readEnablement();
39266
- if (current.installed && current.running && !current.disabled) {
39267
- await enableLinger();
39268
- logDebug("service", "systemd unit unchanged; install skipped");
39269
- return;
39270
- }
39271
- }
39272
- mkdirSync6(unitDir, { recursive: true });
39273
- try {
39274
- writeFileSync13(unitPath, text);
39275
- const reloaded = await systemctl("daemon-reload");
39276
- if (reloaded.code !== 0)
39277
- throw commandError("systemctl", "daemon-reload", reloaded);
39278
- const enabled = await systemctl("enable", SYSTEMD_UNIT);
39279
- if (enabled.code !== 0)
39280
- throw commandError("systemctl", "enable", enabled);
39281
- await systemctl("reset-failed", SYSTEMD_UNIT);
39282
- const restarted = await systemctl("restart", SYSTEMD_UNIT);
39283
- if (restarted.code !== 0)
39284
- throw commandError("systemctl", "restart", restarted);
39285
- } catch (err) {
39286
- rmSync7(unitPath, { force: true });
39287
- throw err;
39288
- }
39289
- await enableLinger();
39290
- },
39291
- async uninstall() {
39292
- await systemctl("disable", "--now", SYSTEMD_UNIT);
39293
- rmSync7(unitPath, { force: true });
39294
- await systemctl("daemon-reload");
39295
- },
39296
- status: readStatus,
39297
- async restart() {
39298
- const restarted = await systemctl("restart", SYSTEMD_UNIT);
39299
- if (restarted.code !== 0)
39300
- throw commandError("systemctl", "restart", restarted);
39301
- }
39302
- };
39303
- }
39304
-
39305
- // src/commands/service-target.ts
39306
- var SURFACES = {
39307
- darwin: {
39308
- visibleIn: "System Settings \u203A Login Items",
39309
- optOutSurface: "`launchctl disable`",
39310
- visibleToggleCaveat: "Skip the System Settings switch: caret can't read it.\n`caret install --uninstall` removes caret entirely."
39311
- },
39312
- linux: {
39313
- visibleIn: "`systemctl --user`",
39314
- optOutSurface: "`systemctl --user`"
39315
- }
39316
- };
39317
- function prodService() {
39318
- const platform = servicePlatform();
39319
- return {
39320
- manager: platform === "darwin" ? createLaunchdManager() : createSystemdManager(),
39321
- label: SERVICE_LABELS[platform],
39322
- ...SURFACES[platform]
39323
- };
39324
- }
39325
-
39326
39748
  // src/commands/prewarm.ts
39327
39749
  init_settings();
39328
39750
  init_lifecycle();
@@ -39506,24 +39928,24 @@ async function runReview(parsed, deps) {
39506
39928
  // src/review/reconcile.ts
39507
39929
  init_log();
39508
39930
  async function runReconcile(parsed, deps) {
39509
- const ctx = {};
39931
+ setLogContext({});
39510
39932
  try {
39511
39933
  if ("error" in parsed)
39512
39934
  throw parsed.error;
39513
39935
  const input = parsed.input;
39514
- ctx.sessionId = input.sessionId;
39936
+ setLogContext({ sessionId: input.sessionId });
39515
39937
  if (!input.sessionId)
39516
39938
  return;
39517
39939
  const match = (await deps.listReviews()).find((r) => r.sessionId === input.sessionId);
39518
39940
  if (!match) {
39519
- logDebug("reconcile", "no pending review for session; nothing to reconcile", { ...ctx });
39941
+ logDebug("reconcile", "no pending review for session; nothing to reconcile");
39520
39942
  return;
39521
39943
  }
39522
- ctx.reviewId = match.id;
39944
+ setLogContext({ sessionId: input.sessionId, reviewId: match.id });
39523
39945
  await deps.resolveReview(match.id);
39524
- logInfo("reconcile", "terminal approval reconciled", { ...ctx });
39946
+ logInfo("reconcile", "terminal approval reconciled");
39525
39947
  } catch (err) {
39526
- logDebug("reconcile", "reconcile skipped", { ...ctx, err: String(err) });
39948
+ logDebug("reconcile", "reconcile skipped", { err: String(err) });
39527
39949
  }
39528
39950
  }
39529
39951
 
@@ -39719,7 +40141,7 @@ init_paths3();
39719
40141
  init_build_id();
39720
40142
  init_log();
39721
40143
 
39722
- // node_modules/.bun/commander@15.0.0/node_modules/commander/lib/error.js
40144
+ // node_modules/commander/lib/error.js
39723
40145
  class CommanderError extends Error {
39724
40146
  constructor(exitCode, code, message) {
39725
40147
  super(message);
@@ -39739,7 +40161,7 @@ class InvalidArgumentError extends CommanderError {
39739
40161
  }
39740
40162
  }
39741
40163
 
39742
- // node_modules/.bun/commander@15.0.0/node_modules/commander/lib/argument.js
40164
+ // node_modules/commander/lib/argument.js
39743
40165
  class Argument {
39744
40166
  constructor(name, description) {
39745
40167
  this.description = description || "";
@@ -39813,7 +40235,7 @@ function humanReadableArgName(arg) {
39813
40235
  return arg.required ? "<" + nameOutput + ">" : "[" + nameOutput + "]";
39814
40236
  }
39815
40237
 
39816
- // node_modules/.bun/commander@15.0.0/node_modules/commander/lib/command.js
40238
+ // node_modules/commander/lib/command.js
39817
40239
  import { EventEmitter } from "events";
39818
40240
  import childProcess from "child_process";
39819
40241
  import path2 from "path";
@@ -39821,7 +40243,7 @@ import fs from "fs";
39821
40243
  import process3 from "process";
39822
40244
  import { stripVTControlCharacters as stripVTControlCharacters3 } from "util";
39823
40245
 
39824
- // node_modules/.bun/commander@15.0.0/node_modules/commander/lib/help.js
40246
+ // node_modules/commander/lib/help.js
39825
40247
  import { stripVTControlCharacters as stripVTControlCharacters2 } from "util";
39826
40248
 
39827
40249
  class Help {
@@ -40170,7 +40592,7 @@ ${itemIndentStr}`);
40170
40592
  }
40171
40593
  }
40172
40594
 
40173
- // node_modules/.bun/commander@15.0.0/node_modules/commander/lib/option.js
40595
+ // node_modules/commander/lib/option.js
40174
40596
  class Option {
40175
40597
  constructor(flags, description) {
40176
40598
  this.flags = flags;
@@ -40348,7 +40770,7 @@ function splitOptionFlags(flags) {
40348
40770
  return { shortFlag, longFlag };
40349
40771
  }
40350
40772
 
40351
- // node_modules/.bun/commander@15.0.0/node_modules/commander/lib/suggestSimilar.js
40773
+ // node_modules/commander/lib/suggestSimilar.js
40352
40774
  var maxDistance = 3;
40353
40775
  function editDistance(a, b) {
40354
40776
  if (Math.abs(a.length - b.length) > maxDistance)
@@ -40418,7 +40840,7 @@ function suggestSimilar(word, candidates) {
40418
40840
  return "";
40419
40841
  }
40420
40842
 
40421
- // node_modules/.bun/commander@15.0.0/node_modules/commander/lib/command.js
40843
+ // node_modules/commander/lib/command.js
40422
40844
  class Command extends EventEmitter {
40423
40845
  constructor(name) {
40424
40846
  super();
@@ -41760,7 +42182,7 @@ function useColor() {
41760
42182
  return;
41761
42183
  }
41762
42184
 
41763
- // node_modules/.bun/commander@15.0.0/node_modules/commander/index.js
42185
+ // node_modules/commander/index.js
41764
42186
  var program = new Command;
41765
42187
  // src/lib/program.ts
41766
42188
  function createProgram(name, description) {
@@ -41788,13 +42210,17 @@ function buildProgram() {
41788
42210
  bundle: opts.bundle ?? false,
41789
42211
  yes: opts.yes ?? false
41790
42212
  }));
41791
- program.command("install").description("install caret into a coding agent, plus the rumdl plan formatter, and choose whether the review UI runs as a service").option("--uninstall", "remove caret from every agent on this machine, and its service, instead of installing").option("--dry-run", "print what would change without writing").option("--refresh", "take the published caret in every target without asking \u2014 clears OpenCode's cached copy, or bumps a pinned entry (Claude Code always takes an update) \u2014 and cycles caret's service onto it").option("--from-local", "dev loop: install the built caret checkout this binary runs from, then hand it the daemon").action(async (opts) => {
42213
+ program.command("install").description("install caret into a coding agent, plus the rumdl plan formatter, and choose whether the review UI runs as a service").option("--uninstall", "remove caret from every agent on this machine, and its service, instead of installing").option("--dry-run", "print what would change without writing").option("--refresh", "take the published caret in every target without asking \u2014 clears OpenCode's cached copy, or bumps a pinned entry (Claude Code always takes an update) \u2014 and cycles caret's service onto the newest caret installed, this one included").option("--from-local", "dev loop: install the built caret checkout this binary runs from, then hand it the daemon").action(async (opts) => {
41792
42214
  const outcome = await runInstallSubcommand({
41793
42215
  uninstall: opts.uninstall ?? false,
41794
42216
  dryRun: opts.dryRun ?? false,
41795
42217
  refresh: opts.refresh ?? false,
41796
42218
  fromLocal: opts.fromLocal ?? false
41797
- }, { service: prodService });
42219
+ }, {
42220
+ service: prodService,
42221
+ watch: prodServiceWatch(),
42222
+ launcherRoot: prodLauncherRoot
42223
+ });
41798
42224
  process.exitCode = installExitCode(outcome);
41799
42225
  });
41800
42226
  return program;