@chosengeneration/light-code 0.156.0 → 0.158.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/dist/cli.cjs +1325 -670
  2. package/dist/server.cjs +1271 -616
  3. package/package.json +1 -1
package/dist/server.cjs CHANGED
@@ -494,14 +494,14 @@ var require_util = __commonJS({
494
494
  }
495
495
  const port = url2.port != null ? url2.port : url2.protocol === "https:" ? 443 : 80;
496
496
  let origin = url2.origin != null ? url2.origin : `${url2.protocol}//${url2.hostname}:${port}`;
497
- let path62 = url2.path != null ? url2.path : `${url2.pathname || ""}${url2.search || ""}`;
497
+ let path63 = url2.path != null ? url2.path : `${url2.pathname || ""}${url2.search || ""}`;
498
498
  if (origin.endsWith("/")) {
499
499
  origin = origin.substring(0, origin.length - 1);
500
500
  }
501
- if (path62 && !path62.startsWith("/")) {
502
- path62 = `/${path62}`;
501
+ if (path63 && !path63.startsWith("/")) {
502
+ path63 = `/${path63}`;
503
503
  }
504
- url2 = new URL(origin + path62);
504
+ url2 = new URL(origin + path63);
505
505
  }
506
506
  return url2;
507
507
  }
@@ -2115,20 +2115,20 @@ var require_parseParams = __commonJS({
2115
2115
  var require_basename = __commonJS({
2116
2116
  "../../node_modules/.pnpm/@fastify+busboy@2.1.1/node_modules/@fastify/busboy/lib/utils/basename.js"(exports2, module2) {
2117
2117
  "use strict";
2118
- module2.exports = function basename(path62) {
2119
- if (typeof path62 !== "string") {
2118
+ module2.exports = function basename(path63) {
2119
+ if (typeof path63 !== "string") {
2120
2120
  return "";
2121
2121
  }
2122
- for (var i = path62.length - 1; i >= 0; --i) {
2123
- switch (path62.charCodeAt(i)) {
2122
+ for (var i = path63.length - 1; i >= 0; --i) {
2123
+ switch (path63.charCodeAt(i)) {
2124
2124
  case 47:
2125
2125
  // '/'
2126
2126
  case 92:
2127
- path62 = path62.slice(i + 1);
2128
- return path62 === ".." || path62 === "." ? "" : path62;
2127
+ path63 = path63.slice(i + 1);
2128
+ return path63 === ".." || path63 === "." ? "" : path63;
2129
2129
  }
2130
2130
  }
2131
- return path62 === ".." || path62 === "." ? "" : path62;
2131
+ return path63 === ".." || path63 === "." ? "" : path63;
2132
2132
  };
2133
2133
  }
2134
2134
  });
@@ -5158,7 +5158,7 @@ var require_request = __commonJS({
5158
5158
  }
5159
5159
  var Request = class _Request {
5160
5160
  constructor(origin, {
5161
- path: path62,
5161
+ path: path63,
5162
5162
  method,
5163
5163
  body,
5164
5164
  headers,
@@ -5172,11 +5172,11 @@ var require_request = __commonJS({
5172
5172
  throwOnError,
5173
5173
  expectContinue
5174
5174
  }, handler) {
5175
- if (typeof path62 !== "string") {
5175
+ if (typeof path63 !== "string") {
5176
5176
  throw new InvalidArgumentError("path must be a string");
5177
- } else if (path62[0] !== "/" && !(path62.startsWith("http://") || path62.startsWith("https://")) && method !== "CONNECT") {
5177
+ } else if (path63[0] !== "/" && !(path63.startsWith("http://") || path63.startsWith("https://")) && method !== "CONNECT") {
5178
5178
  throw new InvalidArgumentError("path must be an absolute URL or start with a slash");
5179
- } else if (invalidPathRegex.exec(path62) !== null) {
5179
+ } else if (invalidPathRegex.exec(path63) !== null) {
5180
5180
  throw new InvalidArgumentError("invalid request path");
5181
5181
  }
5182
5182
  if (typeof method !== "string") {
@@ -5239,7 +5239,7 @@ var require_request = __commonJS({
5239
5239
  this.completed = false;
5240
5240
  this.aborted = false;
5241
5241
  this.upgrade = upgrade || null;
5242
- this.path = query ? util.buildURL(path62, query) : path62;
5242
+ this.path = query ? util.buildURL(path63, query) : path63;
5243
5243
  this.origin = origin;
5244
5244
  this.idempotent = idempotent == null ? method === "HEAD" || method === "GET" : idempotent;
5245
5245
  this.blocking = blocking == null ? false : blocking;
@@ -6247,9 +6247,9 @@ var require_RedirectHandler = __commonJS({
6247
6247
  return this.handler.onHeaders(statusCode, headers, resume, statusText);
6248
6248
  }
6249
6249
  const { origin, pathname, search } = util.parseURL(new URL(this.location, this.opts.origin && new URL(this.opts.path, this.opts.origin)));
6250
- const path62 = search ? `${pathname}${search}` : pathname;
6250
+ const path63 = search ? `${pathname}${search}` : pathname;
6251
6251
  this.opts.headers = cleanRequestHeaders(this.opts.headers, statusCode === 303, this.opts.origin !== origin);
6252
- this.opts.path = path62;
6252
+ this.opts.path = path63;
6253
6253
  this.opts.origin = origin;
6254
6254
  this.opts.maxRedirections = 0;
6255
6255
  this.opts.query = null;
@@ -7489,7 +7489,7 @@ var require_client = __commonJS({
7489
7489
  writeH2(client, client[kHTTP2Session], request);
7490
7490
  return;
7491
7491
  }
7492
- const { body, method, path: path62, host, upgrade, headers, blocking, reset } = request;
7492
+ const { body, method, path: path63, host, upgrade, headers, blocking, reset } = request;
7493
7493
  const expectsPayload = method === "PUT" || method === "POST" || method === "PATCH";
7494
7494
  if (body && typeof body.read === "function") {
7495
7495
  body.read(0);
@@ -7539,7 +7539,7 @@ var require_client = __commonJS({
7539
7539
  if (blocking) {
7540
7540
  socket[kBlocking] = true;
7541
7541
  }
7542
- let header2 = `${method} ${path62} HTTP/1.1\r
7542
+ let header2 = `${method} ${path63} HTTP/1.1\r
7543
7543
  `;
7544
7544
  if (typeof host === "string") {
7545
7545
  header2 += `host: ${host}\r
@@ -7602,7 +7602,7 @@ upgrade: ${upgrade}\r
7602
7602
  return true;
7603
7603
  }
7604
7604
  function writeH2(client, session, request) {
7605
- const { body, method, path: path62, host, upgrade, expectContinue, signal, headers: reqHeaders } = request;
7605
+ const { body, method, path: path63, host, upgrade, expectContinue, signal, headers: reqHeaders } = request;
7606
7606
  let headers;
7607
7607
  if (typeof reqHeaders === "string") headers = Request[kHTTP2CopyHeaders](reqHeaders.trim());
7608
7608
  else headers = reqHeaders;
@@ -7645,7 +7645,7 @@ upgrade: ${upgrade}\r
7645
7645
  });
7646
7646
  return true;
7647
7647
  }
7648
- headers[HTTP2_HEADER_PATH] = path62;
7648
+ headers[HTTP2_HEADER_PATH] = path63;
7649
7649
  headers[HTTP2_HEADER_SCHEME] = "https";
7650
7650
  const expectsPayload = method === "PUT" || method === "POST" || method === "PATCH";
7651
7651
  if (body && typeof body.read === "function") {
@@ -9885,20 +9885,20 @@ var require_mock_utils = __commonJS({
9885
9885
  }
9886
9886
  return true;
9887
9887
  }
9888
- function safeUrl(path62) {
9889
- if (typeof path62 !== "string") {
9890
- return path62;
9888
+ function safeUrl(path63) {
9889
+ if (typeof path63 !== "string") {
9890
+ return path63;
9891
9891
  }
9892
- const pathSegments = path62.split("?");
9892
+ const pathSegments = path63.split("?");
9893
9893
  if (pathSegments.length !== 2) {
9894
- return path62;
9894
+ return path63;
9895
9895
  }
9896
9896
  const qp = new URLSearchParams(pathSegments.pop());
9897
9897
  qp.sort();
9898
9898
  return [...pathSegments, qp.toString()].join("?");
9899
9899
  }
9900
- function matchKey(mockDispatch2, { path: path62, method, body, headers }) {
9901
- const pathMatch = matchValue(mockDispatch2.path, path62);
9900
+ function matchKey(mockDispatch2, { path: path63, method, body, headers }) {
9901
+ const pathMatch = matchValue(mockDispatch2.path, path63);
9902
9902
  const methodMatch = matchValue(mockDispatch2.method, method);
9903
9903
  const bodyMatch = typeof mockDispatch2.body !== "undefined" ? matchValue(mockDispatch2.body, body) : true;
9904
9904
  const headersMatch = matchHeaders(mockDispatch2, headers);
@@ -9916,7 +9916,7 @@ var require_mock_utils = __commonJS({
9916
9916
  function getMockDispatch(mockDispatches, key2) {
9917
9917
  const basePath = key2.query ? buildURL(key2.path, key2.query) : key2.path;
9918
9918
  const resolvedPath = typeof basePath === "string" ? safeUrl(basePath) : basePath;
9919
- let matchedMockDispatches = mockDispatches.filter(({ consumed }) => !consumed).filter(({ path: path62 }) => matchValue(safeUrl(path62), resolvedPath));
9919
+ let matchedMockDispatches = mockDispatches.filter(({ consumed }) => !consumed).filter(({ path: path63 }) => matchValue(safeUrl(path63), resolvedPath));
9920
9920
  if (matchedMockDispatches.length === 0) {
9921
9921
  throw new MockNotMatchedError(`Mock dispatch not matched for path '${resolvedPath}'`);
9922
9922
  }
@@ -9953,9 +9953,9 @@ var require_mock_utils = __commonJS({
9953
9953
  }
9954
9954
  }
9955
9955
  function buildKey(opts) {
9956
- const { path: path62, method, body, headers, query } = opts;
9956
+ const { path: path63, method, body, headers, query } = opts;
9957
9957
  return {
9958
- path: path62,
9958
+ path: path63,
9959
9959
  method,
9960
9960
  body,
9961
9961
  headers,
@@ -10404,10 +10404,10 @@ var require_pending_interceptors_formatter = __commonJS({
10404
10404
  }
10405
10405
  format(pendingInterceptors) {
10406
10406
  const withPrettyHeaders = pendingInterceptors.map(
10407
- ({ method, path: path62, data: { statusCode }, persist, times, timesInvoked, origin }) => ({
10407
+ ({ method, path: path63, data: { statusCode }, persist, times, timesInvoked, origin }) => ({
10408
10408
  Method: method,
10409
10409
  Origin: origin,
10410
- Path: path62,
10410
+ Path: path63,
10411
10411
  "Status code": statusCode,
10412
10412
  Persistent: persist ? "\u2705" : "\u274C",
10413
10413
  Invocations: timesInvoked,
@@ -15027,8 +15027,8 @@ var require_util6 = __commonJS({
15027
15027
  }
15028
15028
  }
15029
15029
  }
15030
- function validateCookiePath(path62) {
15031
- for (const char of path62) {
15030
+ function validateCookiePath(path63) {
15031
+ for (const char of path63) {
15032
15032
  const code = char.charCodeAt(0);
15033
15033
  if (code < 33 || char === ";") {
15034
15034
  throw new Error("Invalid cookie path");
@@ -16708,11 +16708,11 @@ var require_undici = __commonJS({
16708
16708
  if (typeof opts.path !== "string") {
16709
16709
  throw new InvalidArgumentError("invalid opts.path");
16710
16710
  }
16711
- let path62 = opts.path;
16711
+ let path63 = opts.path;
16712
16712
  if (!opts.path.startsWith("/")) {
16713
- path62 = `/${path62}`;
16713
+ path63 = `/${path63}`;
16714
16714
  }
16715
- url2 = new URL(util.parseOrigin(url2).origin + path62);
16715
+ url2 = new URL(util.parseOrigin(url2).origin + path63);
16716
16716
  } else {
16717
16717
  if (!opts) {
16718
16718
  opts = typeof url2 === "object" ? url2 : {};
@@ -19983,8 +19983,8 @@ var require_utils2 = __commonJS({
19983
19983
  }
19984
19984
  return ind;
19985
19985
  }
19986
- function removeDotSegments(path62) {
19987
- let input = path62;
19986
+ function removeDotSegments(path63) {
19987
+ let input = path63;
19988
19988
  const output = [];
19989
19989
  let nextSlash = -1;
19990
19990
  let len = 0;
@@ -20236,8 +20236,8 @@ var require_schemes = __commonJS({
20236
20236
  wsComponent.secure = void 0;
20237
20237
  }
20238
20238
  if (wsComponent.resourceName) {
20239
- const [path62, query] = wsComponent.resourceName.split("?");
20240
- wsComponent.path = path62 && path62 !== "/" ? path62 : void 0;
20239
+ const [path63, query] = wsComponent.resourceName.split("?");
20240
+ wsComponent.path = path63 && path63 !== "/" ? path63 : void 0;
20241
20241
  wsComponent.query = query;
20242
20242
  wsComponent.resourceName = void 0;
20243
20243
  }
@@ -23636,12 +23636,12 @@ var require_dist = __commonJS({
23636
23636
  throw new Error(`Unknown format "${name}"`);
23637
23637
  return f;
23638
23638
  };
23639
- function addFormats(ajv, list2, fs42, exportName) {
23639
+ function addFormats(ajv, list2, fs43, exportName) {
23640
23640
  var _a3;
23641
23641
  var _b;
23642
23642
  (_a3 = (_b = ajv.opts.code).formats) !== null && _a3 !== void 0 ? _a3 : _b.formats = (0, codegen_1._)`require("ajv-formats/dist/formats").${exportName}`;
23643
23643
  for (const f of list2)
23644
- ajv.addFormat(f, fs42[f]);
23644
+ ajv.addFormat(f, fs43[f]);
23645
23645
  }
23646
23646
  module2.exports = exports2 = formatsPlugin;
23647
23647
  Object.defineProperty(exports2, "__esModule", { value: true });
@@ -23654,8 +23654,8 @@ var require_windows = __commonJS({
23654
23654
  "../../node_modules/.pnpm/isexe@2.0.0/node_modules/isexe/windows.js"(exports2, module2) {
23655
23655
  module2.exports = isexe;
23656
23656
  isexe.sync = sync;
23657
- var fs42 = require("fs");
23658
- function checkPathExt(path62, options) {
23657
+ var fs43 = require("fs");
23658
+ function checkPathExt(path63, options) {
23659
23659
  var pathext = options.pathExt !== void 0 ? options.pathExt : process.env.PATHEXT;
23660
23660
  if (!pathext) {
23661
23661
  return true;
@@ -23666,25 +23666,25 @@ var require_windows = __commonJS({
23666
23666
  }
23667
23667
  for (var i = 0; i < pathext.length; i++) {
23668
23668
  var p = pathext[i].toLowerCase();
23669
- if (p && path62.substr(-p.length).toLowerCase() === p) {
23669
+ if (p && path63.substr(-p.length).toLowerCase() === p) {
23670
23670
  return true;
23671
23671
  }
23672
23672
  }
23673
23673
  return false;
23674
23674
  }
23675
- function checkStat(stat, path62, options) {
23675
+ function checkStat(stat, path63, options) {
23676
23676
  if (!stat.isSymbolicLink() && !stat.isFile()) {
23677
23677
  return false;
23678
23678
  }
23679
- return checkPathExt(path62, options);
23679
+ return checkPathExt(path63, options);
23680
23680
  }
23681
- function isexe(path62, options, cb) {
23682
- fs42.stat(path62, function(er, stat) {
23683
- cb(er, er ? false : checkStat(stat, path62, options));
23681
+ function isexe(path63, options, cb) {
23682
+ fs43.stat(path63, function(er, stat) {
23683
+ cb(er, er ? false : checkStat(stat, path63, options));
23684
23684
  });
23685
23685
  }
23686
- function sync(path62, options) {
23687
- return checkStat(fs42.statSync(path62), path62, options);
23686
+ function sync(path63, options) {
23687
+ return checkStat(fs43.statSync(path63), path63, options);
23688
23688
  }
23689
23689
  }
23690
23690
  });
@@ -23694,14 +23694,14 @@ var require_mode = __commonJS({
23694
23694
  "../../node_modules/.pnpm/isexe@2.0.0/node_modules/isexe/mode.js"(exports2, module2) {
23695
23695
  module2.exports = isexe;
23696
23696
  isexe.sync = sync;
23697
- var fs42 = require("fs");
23698
- function isexe(path62, options, cb) {
23699
- fs42.stat(path62, function(er, stat) {
23697
+ var fs43 = require("fs");
23698
+ function isexe(path63, options, cb) {
23699
+ fs43.stat(path63, function(er, stat) {
23700
23700
  cb(er, er ? false : checkStat(stat, options));
23701
23701
  });
23702
23702
  }
23703
- function sync(path62, options) {
23704
- return checkStat(fs42.statSync(path62), options);
23703
+ function sync(path63, options) {
23704
+ return checkStat(fs43.statSync(path63), options);
23705
23705
  }
23706
23706
  function checkStat(stat, options) {
23707
23707
  return stat.isFile() && checkMode(stat, options);
@@ -23725,7 +23725,7 @@ var require_mode = __commonJS({
23725
23725
  // ../../node_modules/.pnpm/isexe@2.0.0/node_modules/isexe/index.js
23726
23726
  var require_isexe = __commonJS({
23727
23727
  "../../node_modules/.pnpm/isexe@2.0.0/node_modules/isexe/index.js"(exports2, module2) {
23728
- var fs42 = require("fs");
23728
+ var fs43 = require("fs");
23729
23729
  var core;
23730
23730
  if (process.platform === "win32" || global.TESTING_WINDOWS) {
23731
23731
  core = require_windows();
@@ -23734,7 +23734,7 @@ var require_isexe = __commonJS({
23734
23734
  }
23735
23735
  module2.exports = isexe;
23736
23736
  isexe.sync = sync;
23737
- function isexe(path62, options, cb) {
23737
+ function isexe(path63, options, cb) {
23738
23738
  if (typeof options === "function") {
23739
23739
  cb = options;
23740
23740
  options = {};
@@ -23744,7 +23744,7 @@ var require_isexe = __commonJS({
23744
23744
  throw new TypeError("callback not provided");
23745
23745
  }
23746
23746
  return new Promise(function(resolve, reject2) {
23747
- isexe(path62, options || {}, function(er, is) {
23747
+ isexe(path63, options || {}, function(er, is) {
23748
23748
  if (er) {
23749
23749
  reject2(er);
23750
23750
  } else {
@@ -23753,7 +23753,7 @@ var require_isexe = __commonJS({
23753
23753
  });
23754
23754
  });
23755
23755
  }
23756
- core(path62, options || {}, function(er, is) {
23756
+ core(path63, options || {}, function(er, is) {
23757
23757
  if (er) {
23758
23758
  if (er.code === "EACCES" || options && options.ignoreErrors) {
23759
23759
  er = null;
@@ -23763,9 +23763,9 @@ var require_isexe = __commonJS({
23763
23763
  cb(er, is);
23764
23764
  });
23765
23765
  }
23766
- function sync(path62, options) {
23766
+ function sync(path63, options) {
23767
23767
  try {
23768
- return core.sync(path62, options || {});
23768
+ return core.sync(path63, options || {});
23769
23769
  } catch (er) {
23770
23770
  if (options && options.ignoreErrors || er.code === "EACCES") {
23771
23771
  return false;
@@ -23781,7 +23781,7 @@ var require_isexe = __commonJS({
23781
23781
  var require_which = __commonJS({
23782
23782
  "../../node_modules/.pnpm/which@2.0.2/node_modules/which/which.js"(exports2, module2) {
23783
23783
  var isWindows = process.platform === "win32" || process.env.OSTYPE === "cygwin" || process.env.OSTYPE === "msys";
23784
- var path62 = require("path");
23784
+ var path63 = require("path");
23785
23785
  var COLON = isWindows ? ";" : ":";
23786
23786
  var isexe = require_isexe();
23787
23787
  var getNotFoundError = (cmd) => Object.assign(new Error(`not found: ${cmd}`), { code: "ENOENT" });
@@ -23819,7 +23819,7 @@ var require_which = __commonJS({
23819
23819
  return opt.all && found2.length ? resolve(found2) : reject2(getNotFoundError(cmd));
23820
23820
  const ppRaw = pathEnv[i];
23821
23821
  const pathPart = /^".*"$/.test(ppRaw) ? ppRaw.slice(1, -1) : ppRaw;
23822
- const pCmd = path62.join(pathPart, cmd);
23822
+ const pCmd = path63.join(pathPart, cmd);
23823
23823
  const p = !pathPart && /^\.[\\\/]/.test(cmd) ? cmd.slice(0, 2) + pCmd : pCmd;
23824
23824
  resolve(subStep(p, i, 0));
23825
23825
  });
@@ -23846,7 +23846,7 @@ var require_which = __commonJS({
23846
23846
  for (let i = 0; i < pathEnv.length; i++) {
23847
23847
  const ppRaw = pathEnv[i];
23848
23848
  const pathPart = /^".*"$/.test(ppRaw) ? ppRaw.slice(1, -1) : ppRaw;
23849
- const pCmd = path62.join(pathPart, cmd);
23849
+ const pCmd = path63.join(pathPart, cmd);
23850
23850
  const p = !pathPart && /^\.[\\\/]/.test(cmd) ? cmd.slice(0, 2) + pCmd : pCmd;
23851
23851
  for (let j = 0; j < pathExt.length; j++) {
23852
23852
  const cur = p + pathExt[j];
@@ -23894,7 +23894,7 @@ var require_path_key = __commonJS({
23894
23894
  var require_resolveCommand = __commonJS({
23895
23895
  "../../node_modules/.pnpm/cross-spawn@7.0.6/node_modules/cross-spawn/lib/util/resolveCommand.js"(exports2, module2) {
23896
23896
  "use strict";
23897
- var path62 = require("path");
23897
+ var path63 = require("path");
23898
23898
  var which = require_which();
23899
23899
  var getPathKey = require_path_key();
23900
23900
  function resolveCommandAttempt(parsed, withoutPathExt) {
@@ -23912,7 +23912,7 @@ var require_resolveCommand = __commonJS({
23912
23912
  try {
23913
23913
  resolved = which.sync(parsed.command, {
23914
23914
  path: env2[getPathKey({ env: env2 })],
23915
- pathExt: withoutPathExt ? path62.delimiter : void 0
23915
+ pathExt: withoutPathExt ? path63.delimiter : void 0
23916
23916
  });
23917
23917
  } catch (e) {
23918
23918
  } finally {
@@ -23921,7 +23921,7 @@ var require_resolveCommand = __commonJS({
23921
23921
  }
23922
23922
  }
23923
23923
  if (resolved) {
23924
- resolved = path62.resolve(hasCustomCwd ? parsed.options.cwd : "", resolved);
23924
+ resolved = path63.resolve(hasCustomCwd ? parsed.options.cwd : "", resolved);
23925
23925
  }
23926
23926
  return resolved;
23927
23927
  }
@@ -23975,8 +23975,8 @@ var require_shebang_command = __commonJS({
23975
23975
  if (!match) {
23976
23976
  return null;
23977
23977
  }
23978
- const [path62, argument] = match[0].replace(/#! ?/, "").split(" ");
23979
- const binary = path62.split("/").pop();
23978
+ const [path63, argument] = match[0].replace(/#! ?/, "").split(" ");
23979
+ const binary = path63.split("/").pop();
23980
23980
  if (binary === "env") {
23981
23981
  return argument;
23982
23982
  }
@@ -23989,16 +23989,16 @@ var require_shebang_command = __commonJS({
23989
23989
  var require_readShebang = __commonJS({
23990
23990
  "../../node_modules/.pnpm/cross-spawn@7.0.6/node_modules/cross-spawn/lib/util/readShebang.js"(exports2, module2) {
23991
23991
  "use strict";
23992
- var fs42 = require("fs");
23992
+ var fs43 = require("fs");
23993
23993
  var shebangCommand = require_shebang_command();
23994
23994
  function readShebang(command) {
23995
23995
  const size = 150;
23996
23996
  const buffer = Buffer.alloc(size);
23997
23997
  let fd;
23998
23998
  try {
23999
- fd = fs42.openSync(command, "r");
24000
- fs42.readSync(fd, buffer, 0, size, 0);
24001
- fs42.closeSync(fd);
23999
+ fd = fs43.openSync(command, "r");
24000
+ fs43.readSync(fd, buffer, 0, size, 0);
24001
+ fs43.closeSync(fd);
24002
24002
  } catch (e) {
24003
24003
  }
24004
24004
  return shebangCommand(buffer.toString());
@@ -24011,7 +24011,7 @@ var require_readShebang = __commonJS({
24011
24011
  var require_parse2 = __commonJS({
24012
24012
  "../../node_modules/.pnpm/cross-spawn@7.0.6/node_modules/cross-spawn/lib/parse.js"(exports2, module2) {
24013
24013
  "use strict";
24014
- var path62 = require("path");
24014
+ var path63 = require("path");
24015
24015
  var resolveCommand = require_resolveCommand();
24016
24016
  var escape4 = require_escape();
24017
24017
  var readShebang = require_readShebang();
@@ -24036,7 +24036,7 @@ var require_parse2 = __commonJS({
24036
24036
  const needsShell = !isExecutableRegExp.test(commandFile);
24037
24037
  if (parsed.options.forceShell || needsShell) {
24038
24038
  const needsDoubleEscapeMetaChars = isCmdShimRegExp.test(commandFile);
24039
- parsed.command = path62.normalize(parsed.command);
24039
+ parsed.command = path63.normalize(parsed.command);
24040
24040
  parsed.command = escape4.command(parsed.command);
24041
24041
  parsed.args = parsed.args.map((arg) => escape4.argument(arg, needsDoubleEscapeMetaChars));
24042
24042
  const shellCommand = [parsed.command].concat(parsed.args).join(" ");
@@ -24257,10 +24257,10 @@ __export(server_exports, {
24257
24257
  startServer: () => startServer
24258
24258
  });
24259
24259
  module.exports = __toCommonJS(server_exports);
24260
- var import_promises35 = __toESM(require("node:fs/promises"), 1);
24261
- var import_node_fs15 = require("node:fs");
24260
+ var import_promises36 = __toESM(require("node:fs/promises"), 1);
24261
+ var import_node_fs16 = require("node:fs");
24262
24262
  var import_node_http = require("node:http");
24263
- var import_node_path62 = __toESM(require("node:path"), 1);
24263
+ var import_node_path63 = __toESM(require("node:path"), 1);
24264
24264
 
24265
24265
  // ../../packages/core/dist/platform/http.js
24266
24266
  var import_node_crypto = require("node:crypto");
@@ -25421,10 +25421,10 @@ function mergeDefs(...defs) {
25421
25421
  function cloneDef(schema8) {
25422
25422
  return mergeDefs(schema8._zod.def);
25423
25423
  }
25424
- function getElementAtPath(obj, path62) {
25425
- if (!path62)
25424
+ function getElementAtPath(obj, path63) {
25425
+ if (!path63)
25426
25426
  return obj;
25427
- return path62.reduce((acc, key2) => acc?.[key2], obj);
25427
+ return path63.reduce((acc, key2) => acc?.[key2], obj);
25428
25428
  }
25429
25429
  function promiseAllObject(promisesObj) {
25430
25430
  const keys = Object.keys(promisesObj);
@@ -25833,11 +25833,11 @@ function explicitlyAborted(x, startIndex = 0) {
25833
25833
  }
25834
25834
  return false;
25835
25835
  }
25836
- function prefixIssues(path62, issues) {
25836
+ function prefixIssues(path63, issues) {
25837
25837
  return issues.map((iss) => {
25838
25838
  var _a3;
25839
25839
  (_a3 = iss).path ?? (_a3.path = []);
25840
- iss.path.unshift(path62);
25840
+ iss.path.unshift(path63);
25841
25841
  return iss;
25842
25842
  });
25843
25843
  }
@@ -25984,16 +25984,16 @@ function flattenError(error51, mapper = (issue2) => issue2.message) {
25984
25984
  }
25985
25985
  function formatError(error51, mapper = (issue2) => issue2.message) {
25986
25986
  const fieldErrors = { _errors: [] };
25987
- const processError = (error52, path62 = []) => {
25987
+ const processError = (error52, path63 = []) => {
25988
25988
  for (const issue2 of error52.issues) {
25989
25989
  if (issue2.code === "invalid_union" && issue2.errors.length) {
25990
- issue2.errors.map((issues) => processError({ issues }, [...path62, ...issue2.path]));
25990
+ issue2.errors.map((issues) => processError({ issues }, [...path63, ...issue2.path]));
25991
25991
  } else if (issue2.code === "invalid_key") {
25992
- processError({ issues: issue2.issues }, [...path62, ...issue2.path]);
25992
+ processError({ issues: issue2.issues }, [...path63, ...issue2.path]);
25993
25993
  } else if (issue2.code === "invalid_element") {
25994
- processError({ issues: issue2.issues }, [...path62, ...issue2.path]);
25994
+ processError({ issues: issue2.issues }, [...path63, ...issue2.path]);
25995
25995
  } else {
25996
- const fullpath = [...path62, ...issue2.path];
25996
+ const fullpath = [...path63, ...issue2.path];
25997
25997
  if (fullpath.length === 0) {
25998
25998
  fieldErrors._errors.push(mapper(issue2));
25999
25999
  } else {
@@ -26020,17 +26020,17 @@ function formatError(error51, mapper = (issue2) => issue2.message) {
26020
26020
  }
26021
26021
  function treeifyError(error51, mapper = (issue2) => issue2.message) {
26022
26022
  const result = { errors: [] };
26023
- const processError = (error52, path62 = []) => {
26023
+ const processError = (error52, path63 = []) => {
26024
26024
  var _a3, _b;
26025
26025
  for (const issue2 of error52.issues) {
26026
26026
  if (issue2.code === "invalid_union" && issue2.errors.length) {
26027
- issue2.errors.map((issues) => processError({ issues }, [...path62, ...issue2.path]));
26027
+ issue2.errors.map((issues) => processError({ issues }, [...path63, ...issue2.path]));
26028
26028
  } else if (issue2.code === "invalid_key") {
26029
- processError({ issues: issue2.issues }, [...path62, ...issue2.path]);
26029
+ processError({ issues: issue2.issues }, [...path63, ...issue2.path]);
26030
26030
  } else if (issue2.code === "invalid_element") {
26031
- processError({ issues: issue2.issues }, [...path62, ...issue2.path]);
26031
+ processError({ issues: issue2.issues }, [...path63, ...issue2.path]);
26032
26032
  } else {
26033
- const fullpath = [...path62, ...issue2.path];
26033
+ const fullpath = [...path63, ...issue2.path];
26034
26034
  if (fullpath.length === 0) {
26035
26035
  result.errors.push(mapper(issue2));
26036
26036
  continue;
@@ -26062,8 +26062,8 @@ function treeifyError(error51, mapper = (issue2) => issue2.message) {
26062
26062
  }
26063
26063
  function toDotPath(_path) {
26064
26064
  const segs = [];
26065
- const path62 = _path.map((seg) => typeof seg === "object" ? seg.key : seg);
26066
- for (const seg of path62) {
26065
+ const path63 = _path.map((seg) => typeof seg === "object" ? seg.key : seg);
26066
+ for (const seg of path63) {
26067
26067
  if (typeof seg === "number")
26068
26068
  segs.push(`[${seg}]`);
26069
26069
  else if (typeof seg === "symbol")
@@ -38755,13 +38755,13 @@ function resolveRef(ref, ctx) {
38755
38755
  if (!ref.startsWith("#")) {
38756
38756
  throw new Error("External $ref is not supported, only local refs (#/...) are allowed");
38757
38757
  }
38758
- const path62 = ref.slice(1).split("/").filter(Boolean);
38759
- if (path62.length === 0) {
38758
+ const path63 = ref.slice(1).split("/").filter(Boolean);
38759
+ if (path63.length === 0) {
38760
38760
  return ctx.rootSchema;
38761
38761
  }
38762
38762
  const defsKey = ctx.version === "draft-2020-12" ? "$defs" : "definitions";
38763
- if (path62[0] === defsKey) {
38764
- const key2 = path62[1];
38763
+ if (path63[0] === defsKey) {
38764
+ const key2 = path63[1];
38765
38765
  if (!key2 || !ctx.defs[key2]) {
38766
38766
  throw new Error(`Reference not found: ${ref}`);
38767
38767
  }
@@ -40670,6 +40670,17 @@ var configSchema = external_exports.object({
40670
40670
  * committed there, everyone's brought back. Uses the Bitbucket connection and its token.
40671
40671
  * **User-scope only**: it chooses where this person's skills and tools are sent.
40672
40672
  */
40673
+ /**
40674
+ * Branch folders - several branches of one repository open at once (git worktrees, git/worktrees.ts).
40675
+ * `folder`: where they go (default beside the repository, `<repo>.worktrees`); `setupCommand`: run once in a
40676
+ * new one (`pnpm install`); `copyFiles`: untracked files copied from the main checkout (`.env`).
40677
+ * **User-scope only** - the command runs on this machine - and per project.
40678
+ */
40679
+ branches: external_exports.object({
40680
+ folder: external_exports.string(),
40681
+ setupCommand: external_exports.string(),
40682
+ copyFiles: external_exports.array(external_exports.string())
40683
+ }).partial(),
40673
40684
  teamRepo: external_exports.object({
40674
40685
  enabled: external_exports.boolean(),
40675
40686
  project: external_exports.string().min(1),
@@ -41478,6 +41489,8 @@ var USER_SCOPE_ONLY_KEYS = [
41478
41489
  "skills",
41479
41490
  // Where this person's skills and tools are committed: a repository able to set it would send them elsewhere.
41480
41491
  "teamRepo",
41492
+ // A command run in every new branch folder: a repository able to set it would run a program of its choosing.
41493
+ "branches",
41481
41494
  // Which skills go to the team pool: a repository able to set it could publish skills the user
41482
41495
  // chose to keep to themselves.
41483
41496
  "teamSkills",
@@ -41560,7 +41573,9 @@ var OVERRIDABLE_KEYS = [
41560
41573
  /** One repository on a slow share needs longer than another on local disk. */
41561
41574
  "tools",
41562
41575
  /** What this project is called. A project name that did not vary by project would be no name. */
41563
- "project"
41576
+ "project",
41577
+ /** Branch folders: one project's setup is pnpm install, another's uv sync. */
41578
+ "branches"
41564
41579
  ];
41565
41580
  function workspaceOverrideKey(workspaceRoot) {
41566
41581
  const resolved = import_node_path3.default.resolve(workspaceRoot);
@@ -44085,8 +44100,8 @@ var SUPERSEDED_MARKER = "[Superseded: this file was read again later in the conv
44085
44100
  function readFilePath(argumentsJson) {
44086
44101
  try {
44087
44102
  const parsed = JSON.parse(argumentsJson.length > 0 ? argumentsJson : "{}");
44088
- const path62 = parsed.path;
44089
- return typeof path62 === "string" && path62.length > 0 ? path62 : void 0;
44103
+ const path63 = parsed.path;
44104
+ return typeof path63 === "string" && path63.length > 0 ? path63 : void 0;
44090
44105
  } catch {
44091
44106
  return void 0;
44092
44107
  }
@@ -44099,8 +44114,8 @@ function dropSupersededReads(messages) {
44099
44114
  for (const toolCall of message4.toolCalls ?? []) {
44100
44115
  if (toolCall.name !== "read_file")
44101
44116
  continue;
44102
- const path62 = readFilePath(toolCall.arguments);
44103
- if (path62 === void 0)
44117
+ const path63 = readFilePath(toolCall.arguments);
44118
+ if (path63 === void 0)
44104
44119
  continue;
44105
44120
  keyByCallId.set(toolCall.id, toolCall.arguments);
44106
44121
  }
@@ -46401,6 +46416,7 @@ var ALWAYS_ASK_TOOLS = /* @__PURE__ */ new Set([
46401
46416
  // Shared CI under the user's name: starting or stopping a build, and replaying one with a local
46402
46417
  // Jenkinsfile, which runs whatever that file says with the job's credentials.
46403
46418
  "jenkins_start_build",
46419
+ "jenkins_write_job",
46404
46420
  "jenkins_stop_build",
46405
46421
  "jenkins_try_jenkinsfile",
46406
46422
  // Production schedules: an event (force-start, kill, hold, ice, status) or a changed definition.
@@ -46949,13 +46965,13 @@ var OpenSearchClient = class {
46949
46965
  * `_bulk`, `_delete_by_query`, index creation — is refused here rather than merely
46950
46966
  * unused, so no future edit or crafted argument can turn a read client into a writer.
46951
46967
  */
46952
- async request(path62, options = {}) {
46968
+ async request(path63, options = {}) {
46953
46969
  const method = options.method ?? "GET";
46954
- const isSearchPost = method === "POST" && /\/_search(\?|$)/.test(path62);
46970
+ const isSearchPost = method === "POST" && /\/_search(\?|$)/.test(path63);
46955
46971
  if (method !== "GET" && !isSearchPost) {
46956
- throw new OpenSearchError(`Refusing ${method} ${path62}: this client is read-only. Indexing goes through the indexer, which the user starts from Settings.`);
46972
+ throw new OpenSearchError(`Refusing ${method} ${path63}: this client is read-only. Indexing goes through the indexer, which the user starts from Settings.`);
46957
46973
  }
46958
- const url2 = `${this.base}${path62}`;
46974
+ const url2 = `${this.base}${path63}`;
46959
46975
  const request = {
46960
46976
  method,
46961
46977
  headers: this.headers()
@@ -47122,11 +47138,11 @@ function collectFields(properties, prefix, out) {
47122
47138
  return;
47123
47139
  for (const [name, raw] of Object.entries(properties)) {
47124
47140
  const field2 = raw;
47125
- const path62 = prefix.length > 0 ? `${prefix}.${name}` : name;
47141
+ const path63 = prefix.length > 0 ? `${prefix}.${name}` : name;
47126
47142
  if (typeof field2.type === "string")
47127
- out[path62] = field2.type;
47143
+ out[path63] = field2.type;
47128
47144
  if (field2.properties !== void 0)
47129
- collectFields(field2.properties, path62, out);
47145
+ collectFields(field2.properties, path63, out);
47130
47146
  }
47131
47147
  }
47132
47148
  function describeStatus(status2, url2, body) {
@@ -47145,23 +47161,23 @@ function describeStatus(status2, url2, body) {
47145
47161
  var TEXT_TYPES = /* @__PURE__ */ new Set(["text", "match_only_text", "search_as_you_type", "wildcard"]);
47146
47162
  var KEYWORD_TYPES = /* @__PURE__ */ new Set(["keyword", "constant_keyword"]);
47147
47163
  var NOISE_FIELDS = /* @__PURE__ */ new Set(["@version", "ecs", "tags", "stream", "input", "agent", "host", "event"]);
47148
- function leafName(path62) {
47149
- const parts = path62.split(".");
47150
- return parts[parts.length - 1] ?? path62;
47164
+ function leafName(path63) {
47165
+ const parts = path63.split(".");
47166
+ return parts[parts.length - 1] ?? path63;
47151
47167
  }
47152
47168
  function selectQueryFields(mapping, limit = 25) {
47153
47169
  const text2 = [];
47154
47170
  const keyword = [];
47155
- for (const [path62, type] of Object.entries(mapping)) {
47156
- if (NOISE_FIELDS.has(leafName(path62)) || NOISE_FIELDS.has(path62.split(".")[0] ?? ""))
47171
+ for (const [path63, type] of Object.entries(mapping)) {
47172
+ if (NOISE_FIELDS.has(leafName(path63)) || NOISE_FIELDS.has(path63.split(".")[0] ?? ""))
47157
47173
  continue;
47158
47174
  if (TEXT_TYPES.has(type)) {
47159
- text2.push(path62);
47175
+ text2.push(path63);
47160
47176
  } else if (KEYWORD_TYPES.has(type)) {
47161
- const parent = path62.replace(/\.keyword$/, "");
47162
- if (path62.endsWith(".keyword") && TEXT_TYPES.has(mapping[parent] ?? ""))
47177
+ const parent = path63.replace(/\.keyword$/, "");
47178
+ if (path63.endsWith(".keyword") && TEXT_TYPES.has(mapping[parent] ?? ""))
47163
47179
  continue;
47164
- keyword.push(path62);
47180
+ keyword.push(path63);
47165
47181
  }
47166
47182
  }
47167
47183
  const byDepth = (a, b) => a.split(".").length - b.split(".").length || a.localeCompare(b);
@@ -47303,8 +47319,8 @@ var OpenSearchIndexWriter = class {
47303
47319
  }
47304
47320
  return headers;
47305
47321
  }
47306
- async request(path62, method, body, signal) {
47307
- const url2 = `${this.connection.url.replace(/\/+$/, "")}${path62}`;
47322
+ async request(path63, method, body, signal) {
47323
+ const url2 = `${this.connection.url.replace(/\/+$/, "")}${path63}`;
47308
47324
  const request = { method, headers: this.headers() };
47309
47325
  if (body !== void 0) {
47310
47326
  if (typeof body === "string") {
@@ -47518,13 +47534,13 @@ var OpenSearchIndexWriter = class {
47518
47534
  for (const hit of hits) {
47519
47535
  const source = hit._source ?? {};
47520
47536
  const vector = source.vector;
47521
- const path62 = source.path;
47522
- if (typeof path62 !== "string" || !Array.isArray(vector))
47537
+ const path63 = source.path;
47538
+ if (typeof path63 !== "string" || !Array.isArray(vector))
47523
47539
  continue;
47524
47540
  documents.push({
47525
47541
  id: hit._id ?? "",
47526
47542
  text: typeof source.text === "string" ? source.text : "",
47527
- path: path62,
47543
+ path: path63,
47528
47544
  startLine: typeof source.startLine === "number" ? source.startLine : 1,
47529
47545
  endLine: typeof source.endLine === "number" ? source.endLine : 1,
47530
47546
  vector
@@ -47598,8 +47614,8 @@ var RestTransport = class {
47598
47614
  * threw would push every caller into catching and re-inspecting an error to find out
47599
47615
  * whether it was really an error. `expectOk` is there for the cases that are.
47600
47616
  */
47601
- async send(path62, method, body, signal) {
47602
- const url2 = `${this.connection.url.replace(/\/+$/, "")}${path62}`;
47617
+ async send(path63, method, body, signal) {
47618
+ const url2 = `${this.connection.url.replace(/\/+$/, "")}${path63}`;
47603
47619
  const request = { method, headers: this.headers() };
47604
47620
  if (body !== void 0)
47605
47621
  request.body = JSON.stringify(body);
@@ -47625,11 +47641,11 @@ var RestTransport = class {
47625
47641
  return { status: response.status, body: parsed };
47626
47642
  }
47627
47643
  /** Sends, and throws unless the status is 2xx. */
47628
- async expectOk(path62, method, body, signal) {
47629
- const result = await this.send(path62, method, body, signal);
47644
+ async expectOk(path63, method, body, signal) {
47645
+ const result = await this.send(path63, method, body, signal);
47630
47646
  if (result.status < 200 || result.status >= 300) {
47631
47647
  const detail = typeof result.body === "string" ? result.body : JSON.stringify(result.body ?? "");
47632
- throw new VectorStoreError(`${method} ${path62} on ${this.label} returned HTTP ${String(result.status)}. ${detail.slice(0, 300)}`, result.status);
47648
+ throw new VectorStoreError(`${method} ${path63} on ${this.label} returned HTTP ${String(result.status)}. ${detail.slice(0, 300)}`, result.status);
47633
47649
  }
47634
47650
  return result.body;
47635
47651
  }
@@ -47737,10 +47753,10 @@ var ChromaSearcher = class extends ChromaBase {
47737
47753
  const matches = [];
47738
47754
  for (let index = 0; index < ids.length; index++) {
47739
47755
  const metadata = metadatas[index] ?? {};
47740
- const path62 = typeof metadata.path === "string" ? metadata.path : void 0;
47741
- if (path62 === void 0)
47756
+ const path63 = typeof metadata.path === "string" ? metadata.path : void 0;
47757
+ if (path63 === void 0)
47742
47758
  continue;
47743
- if (prefix !== void 0 && prefix.length > 0 && !path62.startsWith(prefix))
47759
+ if (prefix !== void 0 && prefix.length > 0 && !path63.startsWith(prefix))
47744
47760
  continue;
47745
47761
  if (projectHere && typeof metadata.project === "string" && !options.project?.names.includes(metadata.project))
47746
47762
  continue;
@@ -47754,7 +47770,7 @@ var ChromaSearcher = class extends ChromaBase {
47754
47770
  */
47755
47771
  score: typeof distance === "number" ? 1 / (1 + Math.max(0, distance)) : 0,
47756
47772
  text: documents[index] ?? (typeof metadata.text === "string" ? metadata.text : ""),
47757
- path: path62
47773
+ path: path63
47758
47774
  };
47759
47775
  if (typeof metadata.startLine === "number")
47760
47776
  match.startLine = metadata.startLine;
@@ -47865,13 +47881,13 @@ var ChromaIndexWriter = class extends ChromaBase {
47865
47881
  for (let index = 0; index < ids.length; index++) {
47866
47882
  const metadata = result.metadatas?.[index] ?? {};
47867
47883
  const vector = result.embeddings?.[index];
47868
- const path62 = typeof metadata.path === "string" ? metadata.path : void 0;
47869
- if (path62 === void 0 || !Array.isArray(vector))
47884
+ const path63 = typeof metadata.path === "string" ? metadata.path : void 0;
47885
+ if (path63 === void 0 || !Array.isArray(vector))
47870
47886
  continue;
47871
47887
  documents.push({
47872
47888
  id: ids[index] ?? "",
47873
47889
  text: result.documents?.[index] ?? "",
47874
- path: path62,
47890
+ path: path63,
47875
47891
  startLine: typeof metadata.startLine === "number" ? metadata.startLine : 1,
47876
47892
  endLine: typeof metadata.endLine === "number" ? metadata.endLine : 1,
47877
47893
  vector
@@ -47888,9 +47904,9 @@ var ChromaIndexWriter = class extends ChromaBase {
47888
47904
  const result = await this.rest.expectOk(`${this.base}/collections/${found2.id}/get`, "POST", { include: ["metadatas"], limit }, options.signal);
47889
47905
  const paths = /* @__PURE__ */ new Set();
47890
47906
  for (const metadata of result.metadatas ?? []) {
47891
- const path62 = metadata?.path;
47892
- if (typeof path62 === "string")
47893
- paths.add(path62);
47907
+ const path63 = metadata?.path;
47908
+ if (typeof path63 === "string")
47909
+ paths.add(path63);
47894
47910
  }
47895
47911
  return [...paths];
47896
47912
  }
@@ -47917,14 +47933,14 @@ var MARKER_ID = "5f6d2a41-0000-5000-8000-6c69676874c0";
47917
47933
  var MARKER_MARK = "light-code";
47918
47934
  function toMatch(point) {
47919
47935
  const payload = point.payload ?? {};
47920
- const path62 = typeof payload.path === "string" ? payload.path : void 0;
47921
- if (path62 === void 0)
47936
+ const path63 = typeof payload.path === "string" ? payload.path : void 0;
47937
+ if (path63 === void 0)
47922
47938
  return void 0;
47923
47939
  const match = {
47924
47940
  id: typeof payload.chunkId === "string" ? payload.chunkId : point.id,
47925
47941
  score: typeof point.score === "number" ? point.score : 0,
47926
47942
  text: typeof payload.text === "string" ? payload.text : "",
47927
- path: path62
47943
+ path: path63
47928
47944
  };
47929
47945
  if (typeof payload.startLine === "number")
47930
47946
  match.startLine = payload.startLine;
@@ -48118,13 +48134,13 @@ var QdrantIndexWriter = class extends QdrantBase {
48118
48134
  const documents = [];
48119
48135
  for (const point of result.body.result?.points ?? []) {
48120
48136
  const payload = point.payload ?? {};
48121
- const path62 = typeof payload.path === "string" ? payload.path : void 0;
48122
- if (path62 === void 0 || !Array.isArray(point.vector))
48137
+ const path63 = typeof payload.path === "string" ? payload.path : void 0;
48138
+ if (path63 === void 0 || !Array.isArray(point.vector))
48123
48139
  continue;
48124
48140
  documents.push({
48125
48141
  id: typeof payload.chunkId === "string" ? payload.chunkId : point.id,
48126
48142
  text: typeof payload.text === "string" ? payload.text : "",
48127
- path: path62,
48143
+ path: path63,
48128
48144
  startLine: typeof payload.startLine === "number" ? payload.startLine : 1,
48129
48145
  endLine: typeof payload.endLine === "number" ? payload.endLine : 1,
48130
48146
  vector: point.vector
@@ -48151,9 +48167,9 @@ var QdrantIndexWriter = class extends QdrantBase {
48151
48167
  throw new VectorStoreError(`Could not list "${collection}" (HTTP ${String(result.status)}).`, result.status);
48152
48168
  }
48153
48169
  for (const point of result.body.result?.points ?? []) {
48154
- const path62 = point.payload?.path;
48155
- if (typeof path62 === "string")
48156
- paths.add(path62);
48170
+ const path63 = point.payload?.path;
48171
+ if (typeof path63 === "string")
48172
+ paths.add(path63);
48157
48173
  }
48158
48174
  offset = result.body.result?.next_page_offset;
48159
48175
  if (offset === void 0 || offset === null)
@@ -48687,8 +48703,8 @@ function teamSkillDocument(skill, body, vector, attribution) {
48687
48703
  vector
48688
48704
  };
48689
48705
  }
48690
- function nameFromPath(path62) {
48691
- return path62.startsWith("skill:") ? path62.slice("skill:".length) : path62;
48706
+ function nameFromPath(path63) {
48707
+ return path63.startsWith("skill:") ? path63.slice("skill:".length) : path63;
48692
48708
  }
48693
48709
  function toHit(match, self) {
48694
48710
  return {
@@ -51774,8 +51790,8 @@ function createMailCoverageTool(options) {
51774
51790
  }
51775
51791
  };
51776
51792
  }
51777
- function normaliseFolder(path62) {
51778
- return path62.toLowerCase().replace(/[\\/]+/g, "\\");
51793
+ function normaliseFolder(path63) {
51794
+ return path63.toLowerCase().replace(/[\\/]+/g, "\\");
51779
51795
  }
51780
51796
  function haystackOf(record2) {
51781
51797
  return `${record2.subject}
@@ -52271,7 +52287,7 @@ async function refreshMail(options) {
52271
52287
  const limit = options.batchLimit ?? 2e3;
52272
52288
  const previewChars = options.previewChars ?? 400;
52273
52289
  const sinceMs = Date.now() - options.days * 24 * 60 * 60 * 1e3;
52274
- const harvested = await options.harvest(options.folders.map((path62) => ({ path: path62, sinceMs })), { limit, previewChars });
52290
+ const harvested = await options.harvest(options.folders.map((path63) => ({ path: path63, sinceMs })), { limit, previewChars });
52275
52291
  const fetched = harvested.messages.map(toRecord);
52276
52292
  if (fetched.length === 0) {
52277
52293
  return { added: 0, more: false, total: known.length, embedded: 0, backfilled: 0, complete: [] };
@@ -52312,9 +52328,9 @@ async function syncMail(options) {
52312
52328
  const backfillDone = await options.store.loadBackfillState();
52313
52329
  const limit = options.batchLimit ?? 500;
52314
52330
  const previewChars = options.previewChars ?? 400;
52315
- const forwardRequests = options.folders.map((path62) => {
52316
- const mark = marks.get(path62);
52317
- return mark === void 0 ? { path: path62 } : { path: path62, sinceMs: mark.newest - 1e3 };
52331
+ const forwardRequests = options.folders.map((path63) => {
52332
+ const mark = marks.get(path63);
52333
+ return mark === void 0 ? { path: path63 } : { path: path63, sinceMs: mark.newest - 1e3 };
52318
52334
  });
52319
52335
  const forward = await options.harvest(forwardRequests, { limit, previewChars });
52320
52336
  let candidates = forward.messages.map(toRecord);
@@ -52323,15 +52339,15 @@ async function syncMail(options) {
52323
52339
  let more = forward.truncated;
52324
52340
  const remaining = limit - candidates.length;
52325
52341
  const floor = options.retentionMonths === void 0 ? void 0 : monthsBefore(options.now ?? Date.now(), options.retentionMonths);
52326
- const outstanding = options.folders.filter((path62) => marks.has(path62) && backfillDone[path62] !== true);
52327
- const atFloor = floor === void 0 ? [] : outstanding.filter((path62) => marks.get(path62).oldest <= floor);
52328
- const behind = outstanding.filter((path62) => !atFloor.includes(path62));
52342
+ const outstanding = options.folders.filter((path63) => marks.has(path63) && backfillDone[path63] !== true);
52343
+ const atFloor = floor === void 0 ? [] : outstanding.filter((path63) => marks.get(path63).oldest <= floor);
52344
+ const behind = outstanding.filter((path63) => !atFloor.includes(path63));
52329
52345
  completed.push(...atFloor);
52330
52346
  if (remaining > 0 && behind.length > 0 && options.signal?.aborted !== true) {
52331
- const backRequests = behind.map((path62) => ({
52332
- path: path62,
52347
+ const backRequests = behind.map((path63) => ({
52348
+ path: path63,
52333
52349
  // Strictly older, so the oldest held message is not fetched again every pass.
52334
- beforeMs: marks.get(path62).oldest,
52350
+ beforeMs: marks.get(path63).oldest,
52335
52351
  // And no older than retention wants. The harvest ANDs the two into one window.
52336
52352
  ...floor === void 0 ? {} : { sinceMs: floor }
52337
52353
  }));
@@ -52339,9 +52355,9 @@ async function syncMail(options) {
52339
52355
  backfilled = backward.messages.length;
52340
52356
  candidates = [...candidates, ...backward.messages.map(toRecord)];
52341
52357
  const returnedFor = new Set(backward.messages.map((message4) => message4.folder));
52342
- for (const path62 of behind) {
52343
- if (!returnedFor.has(path62))
52344
- completed.push(path62);
52358
+ for (const path63 of behind) {
52359
+ if (!returnedFor.has(path63))
52360
+ completed.push(path63);
52345
52361
  }
52346
52362
  if (backward.truncated || backfilled > 0)
52347
52363
  more = true;
@@ -52349,7 +52365,7 @@ async function syncMail(options) {
52349
52365
  if (completed.length > 0) {
52350
52366
  await options.store.saveBackfillState({
52351
52367
  ...backfillDone,
52352
- ...Object.fromEntries(completed.map((path62) => [path62, true]))
52368
+ ...Object.fromEntries(completed.map((path63) => [path63, true]))
52353
52369
  });
52354
52370
  }
52355
52371
  const fresh = withoutKnown(candidates, known);
@@ -52502,6 +52518,7 @@ var NEVER_AVAILABLE_TO_SCHEDULES = [
52502
52518
  "install_python_packages",
52503
52519
  // CI actions nobody would see happen: a build started, aborted, or replayed with a changed script.
52504
52520
  "jenkins_start_build",
52521
+ "jenkins_write_job",
52505
52522
  "jenkins_stop_build",
52506
52523
  "jenkins_try_jenkinsfile",
52507
52524
  // A production scheduler changed with nobody watching.
@@ -52683,14 +52700,14 @@ function formatBytes(size) {
52683
52700
  return `${(size / (1 << 10)).toFixed(1)}KB`;
52684
52701
  return `${String(size)}B`;
52685
52702
  }
52686
- async function readTail(fs42, path62, size, count3) {
52703
+ async function readTail(fs43, path63, size, count3) {
52687
52704
  let span = Math.min(size, CHUNK);
52688
52705
  let text2;
52689
52706
  let start;
52690
52707
  for (; ; ) {
52691
52708
  start = Math.max(0, size - span);
52692
52709
  const decoder2 = new import_node_string_decoder.StringDecoder("utf8");
52693
- text2 = decoder2.write(await fs42.readBytesSlice(path62, start, size)) + decoder2.end();
52710
+ text2 = decoder2.write(await fs43.readBytesSlice(path63, start, size)) + decoder2.end();
52694
52711
  const enough = text2.split("\n").length > count3;
52695
52712
  if (enough || start === 0 || span >= size)
52696
52713
  break;
@@ -52708,7 +52725,7 @@ async function readTail(fs42, path62, size, count3) {
52708
52725
  hasMoreAfter: false
52709
52726
  };
52710
52727
  }
52711
- async function readLineWindow(fs42, path62, size, from, count3) {
52728
+ async function readLineWindow(fs43, path63, size, from, count3) {
52712
52729
  const decoder2 = new import_node_string_decoder.StringDecoder("utf8");
52713
52730
  const lines2 = [];
52714
52731
  let pending = "";
@@ -52723,7 +52740,7 @@ async function readLineWindow(fs42, path62, size, from, count3) {
52723
52740
  };
52724
52741
  scan: while (position < size) {
52725
52742
  const end = Math.min(size, position + CHUNK);
52726
- pending += decoder2.write(await fs42.readBytesSlice(path62, position, end));
52743
+ pending += decoder2.write(await fs43.readBytesSlice(path63, position, end));
52727
52744
  position = end;
52728
52745
  const parts = pending.split(/\r\n|\r|\n/);
52729
52746
  pending = parts.pop() ?? "";
@@ -52746,13 +52763,13 @@ async function readLineWindow(fs42, path62, size, from, count3) {
52746
52763
  hasMoreAfter: !reachedEnd || lineNumber > from + lines2.length
52747
52764
  };
52748
52765
  }
52749
- async function countLines(fs42, path62, size) {
52766
+ async function countLines(fs43, path63, size) {
52750
52767
  let newlines = 0;
52751
52768
  let position = 0;
52752
52769
  let lastByte = -1;
52753
52770
  while (position < size) {
52754
52771
  const end = Math.min(size, position + CHUNK);
52755
- const buffer = await fs42.readBytesSlice(path62, position, end);
52772
+ const buffer = await fs43.readBytesSlice(path63, position, end);
52756
52773
  for (const byte of buffer)
52757
52774
  if (byte === 10)
52758
52775
  newlines += 1;
@@ -60083,13 +60100,13 @@ function appendSkillImages(body, images) {
60083
60100
  const trimmed = body.replace(/\s+$/, "");
60084
60101
  return [trimmed, "", "## Images", "", ...missing.map(renderSkillImage)].join("\n");
60085
60102
  }
60086
- async function listSkillImages(skillFilePath, fs42) {
60103
+ async function listSkillImages(skillFilePath, fs43) {
60087
60104
  const asPosix = skillFilePath.split(String.fromCharCode(92)).join("/");
60088
60105
  if (!asPosix.toLowerCase().endsWith("/skill.md"))
60089
60106
  return [];
60090
60107
  const dir = `${skillFilePath.slice(0, skillFilePath.length - "SKILL.md".length)}${SKILL_IMAGE_DIR}`;
60091
60108
  try {
60092
- const entries = await fs42.readdir(dir);
60109
+ const entries = await fs43.readdir(dir);
60093
60110
  return entries.filter((entry) => !entry.isDirectory && skillImageType(entry.name) !== void 0).map((entry) => entry.name).sort();
60094
60111
  } catch {
60095
60112
  return [];
@@ -60139,12 +60156,12 @@ function skillFilesDir(skillFilePath) {
60139
60156
  return void 0;
60140
60157
  return `${skillFilePath.slice(0, skillFilePath.length - "SKILL.md".length)}${SKILL_FILE_DIR}`;
60141
60158
  }
60142
- async function listSkillFiles(skillFilePath, fs42) {
60159
+ async function listSkillFiles(skillFilePath, fs43) {
60143
60160
  const dir = skillFilesDir(skillFilePath);
60144
60161
  if (dir === void 0)
60145
60162
  return [];
60146
60163
  try {
60147
- const entries = await fs42.readdir(dir);
60164
+ const entries = await fs43.readdir(dir);
60148
60165
  return entries.filter((entry) => !entry.isDirectory).map((entry) => entry.name).sort();
60149
60166
  } catch {
60150
60167
  return [];
@@ -60776,13 +60793,13 @@ function buildExport(config2, selected) {
60776
60793
  if (has(config2, key2))
60777
60794
  exported[key2] = config2[key2];
60778
60795
  }
60779
- for (const path62 of section.strip ?? [])
60780
- stripPath(exported, path62);
60796
+ for (const path63 of section.strip ?? [])
60797
+ stripPath(exported, path63);
60781
60798
  }
60782
60799
  return exported;
60783
60800
  }
60784
- function stripPath(target, path62) {
60785
- const [head, ...rest] = path62.split(".");
60801
+ function stripPath(target, path63) {
60802
+ const [head, ...rest] = path63.split(".");
60786
60803
  if (head === void 0)
60787
60804
  return;
60788
60805
  const value = target[head];
@@ -60810,14 +60827,14 @@ function applyImport(existing, imported, selected) {
60810
60827
  else
60811
60828
  delete merged[key2];
60812
60829
  }
60813
- for (const path62 of section.strip ?? []) {
60814
- carryPath(existing, merged, path62);
60830
+ for (const path63 of section.strip ?? []) {
60831
+ carryPath(existing, merged, path63);
60815
60832
  }
60816
60833
  }
60817
60834
  return merged;
60818
60835
  }
60819
- function carryPath(from, to, path62) {
60820
- const [head, ...rest] = path62.split(".");
60836
+ function carryPath(from, to, path63) {
60837
+ const [head, ...rest] = path63.split(".");
60821
60838
  if (head === void 0)
60822
60839
  return;
60823
60840
  const source = from[head];
@@ -63299,9 +63316,9 @@ function gatewayFromSettings(input, stored) {
63299
63316
  }
63300
63317
 
63301
63318
  // ../../packages/core/dist/host/bridge.js
63302
- var import_node_fs10 = require("node:fs");
63303
- var import_node_child_process14 = require("node:child_process");
63304
- var import_promises28 = __toESM(require("node:fs/promises"), 1);
63319
+ var import_node_fs11 = require("node:fs");
63320
+ var import_node_child_process15 = require("node:child_process");
63321
+ var import_promises29 = __toESM(require("node:fs/promises"), 1);
63305
63322
 
63306
63323
  // ../../packages/core/dist/jupyter/spec.js
63307
63324
  var jupyterHubSpecSchema = external_exports.object({
@@ -63827,7 +63844,7 @@ function ignoreDecision(rules, relative, isDirectory2, initial) {
63827
63844
  }
63828
63845
  return ignored;
63829
63846
  }
63830
- async function repositoryWideRules(fs42, root, globalIgnoreFile) {
63847
+ async function repositoryWideRules(fs43, root, globalIgnoreFile) {
63831
63848
  const sources = [
63832
63849
  globalIgnoreFile ?? import_node_path29.default.join(process.env["XDG_CONFIG_HOME"] ?? import_node_path29.default.join(import_node_os4.default.homedir(), ".config"), "git", "ignore"),
63833
63850
  import_node_path29.default.join(root, ".git", "info", "exclude")
@@ -63835,16 +63852,16 @@ async function repositoryWideRules(fs42, root, globalIgnoreFile) {
63835
63852
  const rules = [];
63836
63853
  for (const source of sources) {
63837
63854
  try {
63838
- rules.push(...parseIgnoreFile(await fs42.readFile(source), ""));
63855
+ rules.push(...parseIgnoreFile(await fs43.readFile(source), ""));
63839
63856
  } catch {
63840
63857
  }
63841
63858
  }
63842
63859
  return rules;
63843
63860
  }
63844
- async function walkFiles(fs42, root, options) {
63861
+ async function walkFiles(fs43, root, options) {
63845
63862
  const maxFiles = options.maxFiles ?? DEFAULT_MAX_FILES;
63846
63863
  const files = [];
63847
- const baseRules = options.includeIgnored ? [] : await repositoryWideRules(fs42, root, options.globalIgnoreFile);
63864
+ const baseRules = options.includeIgnored ? [] : await repositoryWideRules(fs43, root, options.globalIgnoreFile);
63848
63865
  const pending = [{ relative: "", rules: baseRules }];
63849
63866
  while (pending.length > 0) {
63850
63867
  if (options.signal?.aborted === true)
@@ -63853,14 +63870,14 @@ async function walkFiles(fs42, root, options) {
63853
63870
  const absolute = relative.length > 0 ? import_node_path29.default.join(root, ...relative.split("/")) : root;
63854
63871
  let entries;
63855
63872
  try {
63856
- entries = await fs42.readdir(absolute);
63873
+ entries = await fs43.readdir(absolute);
63857
63874
  } catch {
63858
63875
  continue;
63859
63876
  }
63860
63877
  let rules = inherited;
63861
63878
  if (!options.includeIgnored && entries.some((entry) => entry.name === ".gitignore" && !entry.isDirectory)) {
63862
63879
  try {
63863
- const text2 = await fs42.readFile(import_node_path29.default.join(absolute, ".gitignore"));
63880
+ const text2 = await fs43.readFile(import_node_path29.default.join(absolute, ".gitignore"));
63864
63881
  rules = [...inherited, ...parseIgnoreFile(text2, relative)];
63865
63882
  } catch {
63866
63883
  }
@@ -63922,12 +63939,12 @@ function fileFilter(filePattern) {
63922
63939
  const regex = globToRegExp(glob.startsWith("/") ? glob.slice(1) : glob, anchored);
63923
63940
  return (relative) => regex.test(relative) !== exclude;
63924
63941
  }
63925
- async function searchFiles(fs42, root, options) {
63942
+ async function searchFiles(fs43, root, options) {
63926
63943
  const regex = compilePattern(options.pattern);
63927
63944
  const admits = fileFilter(options.filePattern);
63928
63945
  const context = options.contextLines ?? 2;
63929
63946
  const maxOutput = options.maxOutputChars ?? DEFAULT_MAX_OUTPUT;
63930
- const { files, truncated: walkTruncated } = await walkFiles(fs42, root, options);
63947
+ const { files, truncated: walkTruncated } = await walkFiles(fs43, root, options);
63931
63948
  const separator = process.platform === "win32" ? "\\" : "/";
63932
63949
  const chunks = [];
63933
63950
  let size = 0;
@@ -63940,10 +63957,10 @@ async function searchFiles(fs42, root, options) {
63940
63957
  const absolute = import_node_path29.default.join(root, ...relative.split("/"));
63941
63958
  let bytes;
63942
63959
  try {
63943
- const stat = await fs42.stat(absolute);
63960
+ const stat = await fs43.stat(absolute);
63944
63961
  if (stat.size > MAX_FILE_BYTES)
63945
63962
  continue;
63946
- bytes = await fs42.readBytes(absolute);
63963
+ bytes = await fs43.readBytes(absolute);
63947
63964
  } catch {
63948
63965
  continue;
63949
63966
  }
@@ -65882,8 +65899,8 @@ function pick2(hubs, name) {
65882
65899
 
65883
65900
  // ../../packages/core/dist/host/bridge.js
65884
65901
  var import_node_os6 = __toESM(require("node:os"), 1);
65885
- var import_node_fs11 = require("node:fs");
65886
- var import_node_path51 = __toESM(require("node:path"), 1);
65902
+ var import_node_fs12 = require("node:fs");
65903
+ var import_node_path52 = __toESM(require("node:path"), 1);
65887
65904
 
65888
65905
  // ../../packages/core/dist/modes/autoGuidance.js
65889
65906
  function idiomsFor(environment) {
@@ -67747,8 +67764,8 @@ var ChangeLedger = class {
67747
67764
  this.chat = chat;
67748
67765
  }
67749
67766
  /** Best effort: a ledger that cannot be written must never fail an edit that happened. */
67750
- record(path62) {
67751
- const line = JSON.stringify({ chat: this.chat, path: normalizeForComparison(path62), at: Date.now() });
67767
+ record(path63) {
67768
+ const line = JSON.stringify({ chat: this.chat, path: normalizeForComparison(path63), at: Date.now() });
67752
67769
  void (0, import_promises23.appendFile)(this.file, `${line}
67753
67770
  `).catch(() => void 0);
67754
67771
  }
@@ -72095,10 +72112,10 @@ function isSafeSegment(value) {
72095
72112
  function isSafeTagName(name) {
72096
72113
  return /^[A-Za-z0-9._/-]+$/.test(name) && !name.startsWith("-") && !name.startsWith("/") && !name.endsWith("/") && !name.endsWith(".") && !name.endsWith(".lock") && !name.includes("..") && !name.includes("//") && !name.split("/").some((part) => part.startsWith("."));
72097
72114
  }
72098
- function encodeRepoPath(path62) {
72099
- const segments = path62.replace(/\\/g, "/").split("/").filter((segment) => segment.length > 0);
72115
+ function encodeRepoPath(path63) {
72116
+ const segments = path63.replace(/\\/g, "/").split("/").filter((segment) => segment.length > 0);
72100
72117
  if (segments.length === 0 || segments.some((segment) => segment === ".." || segment === ".")) {
72101
- throw new AtlassianError(`"${path62}" is not a file path inside the repository.`);
72118
+ throw new AtlassianError(`"${path63}" is not a file path inside the repository.`);
72102
72119
  }
72103
72120
  return segments.map(encodeURIComponent).join("/");
72104
72121
  }
@@ -72183,24 +72200,24 @@ var BitbucketClient = class {
72183
72200
  * redirect was followed, the login page came back, and the file "could not be read" although
72184
72201
  * pull requests on the same repository could. `browse` is REST, so it authenticates like those.
72185
72202
  */
72186
- async file(repo, path62, ref, signal) {
72187
- const target = encodeRepoPath(path62);
72203
+ async file(repo, path63, ref, signal) {
72204
+ const target = encodeRepoPath(path63);
72188
72205
  const lines2 = [];
72189
72206
  let start = 0;
72190
72207
  for (let page = 0; page < MAX_FILE_PAGES; page += 1) {
72191
72208
  const query = new URLSearchParams({ start: String(start), limit: String(FILE_PAGE_LINES) });
72192
72209
  if (ref !== void 0 && ref.length > 0)
72193
72210
  query.set("at", ref);
72194
- const body = await this.rest.json(`reading ${path62}`, `${this.repoPath(repo)}/browse/${target}?${query.toString()}`, { method: "GET" }, signal);
72211
+ const body = await this.rest.json(`reading ${path63}`, `${this.repoPath(repo)}/browse/${target}?${query.toString()}`, { method: "GET" }, signal);
72195
72212
  if (body.children !== void 0) {
72196
72213
  const names = (body.children.values ?? []).map((child) => {
72197
72214
  const name = child.path?.toString ?? child.path?.name ?? "?";
72198
72215
  return child.type === "DIRECTORY" ? `${name}/` : name;
72199
72216
  });
72200
- throw new AtlassianError(`${path62} is a folder, not a file. It holds: ${names.join(", ") || "nothing"}.`);
72217
+ throw new AtlassianError(`${path63} is a folder, not a file. It holds: ${names.join(", ") || "nothing"}.`);
72201
72218
  }
72202
72219
  if (body.binary === true)
72203
- throw new AtlassianError(`${path62} is a binary file, so there is no text to read.`);
72220
+ throw new AtlassianError(`${path63} is a binary file, so there is no text to read.`);
72204
72221
  for (const line of body.lines ?? [])
72205
72222
  lines2.push(line.text ?? "");
72206
72223
  if (body.isLastPage !== false || body.nextPageStart === void 0 || body.nextPageStart <= start)
@@ -72290,9 +72307,9 @@ var BitbucketClient = class {
72290
72307
  return out;
72291
72308
  }
72292
72309
  /** A file's bytes at `at`, or undefined when it is not there. */
72293
- async readBytes(repo, path62, at, signal) {
72310
+ async readBytes(repo, path63, at, signal) {
72294
72311
  try {
72295
- return await this.rest.bytes(`reading ${path62}`, `${this.repoPath(repo)}/raw/${encodeRepoPath(path62)}?${new URLSearchParams({ at }).toString()}`, signal);
72312
+ return await this.rest.bytes(`reading ${path63}`, `${this.repoPath(repo)}/raw/${encodeRepoPath(path63)}?${new URLSearchParams({ at }).toString()}`, signal);
72296
72313
  } catch (error51) {
72297
72314
  if (error51 instanceof AtlassianError && error51.status === 404)
72298
72315
  return void 0;
@@ -72597,6 +72614,253 @@ The merge succeeded, but tag ${params3.tag} was not created: ${error51 instanceo
72597
72614
  };
72598
72615
  }
72599
72616
 
72617
+ // ../../packages/core/dist/atlassian/jenkinsConfig.js
72618
+ var TAGS = {
72619
+ string: "hudson.model.StringParameterDefinition",
72620
+ text: "hudson.model.TextParameterDefinition",
72621
+ boolean: "hudson.model.BooleanParameterDefinition",
72622
+ choice: "hudson.model.ChoiceParameterDefinition"
72623
+ };
72624
+ function escapeXml(text2) {
72625
+ return text2.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;");
72626
+ }
72627
+ function unescapeXml(text2) {
72628
+ return text2.replace(/&lt;/g, "<").replace(/&gt;/g, ">").replace(/&quot;/g, '"').replace(/&apos;/g, "'").replace(/&amp;/g, "&");
72629
+ }
72630
+ function children(xml, from, to) {
72631
+ const out = [];
72632
+ const tag = /<(\/?)([A-Za-z_][\w.\-:$]*)([^>]*?)(\/?)>|<!--[\s\S]*?-->|<\?[\s\S]*?\?>|<!\[CDATA\[[\s\S]*?\]\]>/g;
72633
+ tag.lastIndex = from;
72634
+ let depth = 0;
72635
+ let open;
72636
+ for (let match = tag.exec(xml); match !== null && match.index < to; match = tag.exec(xml)) {
72637
+ if (match[2] === void 0)
72638
+ continue;
72639
+ const closing = match[1] === "/";
72640
+ const selfClosing = match[4] === "/";
72641
+ const end = match.index + match[0].length;
72642
+ if (closing) {
72643
+ depth -= 1;
72644
+ if (depth === 0 && open !== void 0) {
72645
+ out.push({ tag: open.tag, start: open.start, innerStart: open.innerStart, innerEnd: match.index, end });
72646
+ open = void 0;
72647
+ }
72648
+ } else if (selfClosing) {
72649
+ if (depth === 0)
72650
+ out.push({ tag: match[2], start: match.index, innerStart: end, innerEnd: end, end });
72651
+ } else {
72652
+ if (depth === 0)
72653
+ open = { tag: match[2], start: match.index, innerStart: end };
72654
+ depth += 1;
72655
+ }
72656
+ }
72657
+ return out;
72658
+ }
72659
+ function rootOf(xml) {
72660
+ const root = children(xml, 0, xml.length)[0];
72661
+ if (root === void 0)
72662
+ throw new Error("The job configuration is not XML Jenkins would accept (no root element).");
72663
+ return root;
72664
+ }
72665
+ function childNamed(xml, parent, tag) {
72666
+ return children(xml, parent.innerStart, parent.innerEnd).find((child) => child.tag === tag);
72667
+ }
72668
+ function textOf(xml, parent, tag) {
72669
+ const child = childNamed(xml, parent, tag);
72670
+ return child === void 0 ? void 0 : unescapeXml(xml.slice(child.innerStart, child.innerEnd).trim());
72671
+ }
72672
+ function lineIndent(xml, at) {
72673
+ const lineStart = xml.lastIndexOf("\n", at - 1) + 1;
72674
+ return /^[ \t]*/.exec(xml.slice(lineStart, at))?.[0] ?? "";
72675
+ }
72676
+ function parseParameter(xml, element) {
72677
+ const type = Object.entries(TAGS).find(([, tag]) => tag === element.tag)?.[0] ?? void 0;
72678
+ const choicesElement = childNamed(xml, element, "choices");
72679
+ const choices = choicesElement === void 0 ? void 0 : [...xml.slice(choicesElement.innerStart, choicesElement.innerEnd).matchAll(/<string>([\s\S]*?)<\/string>/g)].map((match) => unescapeXml(match[1] ?? ""));
72680
+ const description = textOf(xml, element, "description");
72681
+ const defaultValue = textOf(xml, element, "defaultValue");
72682
+ return {
72683
+ element,
72684
+ name: textOf(xml, element, "name") ?? "",
72685
+ ...type !== void 0 ? { type } : {},
72686
+ ...description !== void 0 ? { description } : {},
72687
+ ...defaultValue !== void 0 ? { default: defaultValue } : {},
72688
+ ...choices !== void 0 ? { choices } : {}
72689
+ };
72690
+ }
72691
+ function renderParameter(input, indent2) {
72692
+ const inner = `${indent2} `;
72693
+ const lines2 = [`${indent2}<${TAGS[input.type]}>`, `${inner}<name>${escapeXml(input.name)}</name>`, `${inner}<description>${escapeXml(input.description ?? "")}</description>`];
72694
+ if (input.type === "choice") {
72695
+ const choices = [...input.choices ?? []];
72696
+ if (choices.length === 0)
72697
+ throw new Error(`The choice parameter "${input.name}" needs at least one choice.`);
72698
+ if (input.default !== void 0) {
72699
+ const at = choices.indexOf(input.default);
72700
+ if (at < 0)
72701
+ throw new Error(`The default "${input.default}" is not one of the choices of "${input.name}" (${choices.join(", ")}).`);
72702
+ choices.splice(at, 1);
72703
+ choices.unshift(input.default);
72704
+ }
72705
+ lines2.push(`${inner}<choices class="java.util.Arrays$ArrayList">`, `${inner} <a class="string-array">`);
72706
+ for (const choice of choices)
72707
+ lines2.push(`${inner} <string>${escapeXml(choice)}</string>`);
72708
+ lines2.push(`${inner} </a>`, `${inner}</choices>`);
72709
+ } else if (input.type === "boolean") {
72710
+ lines2.push(`${inner}<defaultValue>${input.default === "true" ? "true" : "false"}</defaultValue>`);
72711
+ } else {
72712
+ lines2.push(`${inner}<defaultValue>${escapeXml(input.default ?? "")}</defaultValue>`);
72713
+ if (input.type === "string")
72714
+ lines2.push(`${inner}<trim>false</trim>`);
72715
+ }
72716
+ lines2.push(`${indent2}</${TAGS[input.type]}>`);
72717
+ return lines2.join("\n");
72718
+ }
72719
+ function jobParameters(xml) {
72720
+ const definitions = findDefinitions(xml);
72721
+ if (definitions === void 0)
72722
+ return [];
72723
+ return children(xml, definitions.innerStart, definitions.innerEnd).map((element) => {
72724
+ const parsed = parseParameter(xml, element);
72725
+ return {
72726
+ name: parsed.name,
72727
+ type: parsed.type ?? element.tag,
72728
+ ...parsed.default !== void 0 ? { default: parsed.default } : {},
72729
+ ...parsed.choices !== void 0 ? { choices: parsed.choices } : {}
72730
+ };
72731
+ });
72732
+ }
72733
+ function findDefinitions(xml) {
72734
+ const root = rootOf(xml);
72735
+ const properties = childNamed(xml, root, "properties");
72736
+ if (properties === void 0)
72737
+ return void 0;
72738
+ const property = childNamed(xml, properties, "hudson.model.ParametersDefinitionProperty");
72739
+ if (property === void 0)
72740
+ return void 0;
72741
+ return childNamed(xml, property, "parameterDefinitions");
72742
+ }
72743
+ function ensureDefinitions(xml) {
72744
+ const found2 = findDefinitions(xml);
72745
+ if (found2 !== void 0 && found2.innerStart === found2.innerEnd && xml.slice(found2.start, found2.end).endsWith("/>")) {
72746
+ const indent3 = lineIndent(xml, found2.start);
72747
+ return xml.slice(0, found2.start) + `<parameterDefinitions>
72748
+ ${indent3}</parameterDefinitions>` + xml.slice(found2.end);
72749
+ }
72750
+ if (found2 !== void 0)
72751
+ return xml;
72752
+ const root = rootOf(xml);
72753
+ const properties = childNamed(xml, root, "properties");
72754
+ const block2 = (indent3) => [`${indent3}<hudson.model.ParametersDefinitionProperty>`, `${indent3} <parameterDefinitions>`, `${indent3} </parameterDefinitions>`, `${indent3}</hudson.model.ParametersDefinitionProperty>`].join("\n");
72755
+ if (properties === void 0) {
72756
+ const indent3 = " ";
72757
+ const insert = `${indent3}<properties>
72758
+ ${block2(`${indent3} `)}
72759
+ ${indent3}</properties>
72760
+ `;
72761
+ return xml.slice(0, root.innerEnd) + insert + xml.slice(root.innerEnd);
72762
+ }
72763
+ const indent2 = lineIndent(xml, properties.start);
72764
+ if (properties.innerStart === properties.innerEnd && xml.slice(properties.start, properties.end).endsWith("/>")) {
72765
+ const replacement = `<properties>
72766
+ ${block2(`${indent2} `)}
72767
+ ${indent2}</properties>`;
72768
+ return xml.slice(0, properties.start) + replacement + xml.slice(properties.end);
72769
+ }
72770
+ const existing = childNamed(xml, properties, "hudson.model.ParametersDefinitionProperty");
72771
+ if (existing !== void 0) {
72772
+ const inner = `${lineIndent(xml, existing.start)} `;
72773
+ const list2 = `
72774
+ ${inner}<parameterDefinitions>
72775
+ ${inner}</parameterDefinitions>
72776
+ ${lineIndent(xml, existing.start)}`;
72777
+ if (existing.innerStart === existing.innerEnd) {
72778
+ const tag = "hudson.model.ParametersDefinitionProperty";
72779
+ return xml.slice(0, existing.start) + `<${tag}>${list2}</${tag}>` + xml.slice(existing.end);
72780
+ }
72781
+ return xml.slice(0, existing.innerStart) + list2 + xml.slice(existing.innerStart);
72782
+ }
72783
+ return xml.slice(0, properties.innerStart) + `
72784
+ ${block2(`${indent2} `)}` + xml.slice(properties.innerStart);
72785
+ }
72786
+ function applyJobChanges(original, changes) {
72787
+ let xml = original;
72788
+ const notes = [];
72789
+ for (const edit of changes.edits ?? []) {
72790
+ if (edit.find.length === 0)
72791
+ throw new Error("An edit has nothing to find.");
72792
+ const first = xml.indexOf(edit.find);
72793
+ if (first < 0)
72794
+ throw new Error(`Not found in the job configuration, so nothing was changed: ${JSON.stringify(edit.find.slice(0, 120))}`);
72795
+ if (xml.indexOf(edit.find, first + edit.find.length) >= 0) {
72796
+ throw new Error(`Found more than once in the job configuration - include more around it so it is unique: ${JSON.stringify(edit.find.slice(0, 120))}`);
72797
+ }
72798
+ xml = xml.slice(0, first) + edit.replace + xml.slice(first + edit.find.length);
72799
+ notes.push("edited the configuration text");
72800
+ }
72801
+ if (changes.description !== void 0) {
72802
+ const root = rootOf(xml);
72803
+ const description = childNamed(xml, root, "description");
72804
+ const value = escapeXml(changes.description);
72805
+ if (description === void 0) {
72806
+ xml = xml.slice(0, root.innerStart) + `
72807
+ <description>${value}</description>` + xml.slice(root.innerStart);
72808
+ } else {
72809
+ xml = xml.slice(0, description.start) + `<description>${value}</description>` + xml.slice(description.end);
72810
+ }
72811
+ notes.push("set the description");
72812
+ }
72813
+ const remove = changes.parameters?.remove ?? [];
72814
+ const set2 = changes.parameters?.set ?? [];
72815
+ if (remove.length > 0 || set2.length > 0) {
72816
+ xml = ensureDefinitions(xml);
72817
+ for (const name of remove) {
72818
+ const definitions = findDefinitions(xml);
72819
+ const found2 = definitions === void 0 ? void 0 : children(xml, definitions.innerStart, definitions.innerEnd).find((element) => parseParameter(xml, element).name === name);
72820
+ if (found2 === void 0)
72821
+ throw new Error(`The job has no parameter "${name}" to remove.`);
72822
+ const lineStart = xml.lastIndexOf("\n", found2.start - 1);
72823
+ xml = xml.slice(0, lineStart >= 0 ? lineStart : found2.start) + xml.slice(found2.end);
72824
+ notes.push(`removed parameter ${name}`);
72825
+ }
72826
+ for (const input of set2) {
72827
+ if (input.name.trim().length === 0)
72828
+ throw new Error("A parameter needs a name.");
72829
+ const definitions = findDefinitions(xml);
72830
+ if (definitions === void 0)
72831
+ throw new Error("Could not find where the job keeps its parameters.");
72832
+ const existingElement = children(xml, definitions.innerStart, definitions.innerEnd).find((element) => parseParameter(xml, element).name === input.name);
72833
+ const existing = existingElement === void 0 ? void 0 : parseParameter(xml, existingElement);
72834
+ if (existing !== void 0 && existing.type === void 0 && input.type === void 0) {
72835
+ throw new Error(`The parameter "${input.name}" is of a kind this tool does not rewrite (${existing.element.tag}). Give a type to replace it, or change it with edits.`);
72836
+ }
72837
+ const type = input.type ?? existing?.type ?? "string";
72838
+ const defaultValue = input.default !== void 0 ? String(input.default) : existing?.default ?? (type === "choice" ? existing?.choices?.[0] : void 0);
72839
+ const merged = {
72840
+ name: input.name,
72841
+ type,
72842
+ description: input.description ?? existing?.description,
72843
+ default: defaultValue,
72844
+ choices: input.choices ?? existing?.choices
72845
+ };
72846
+ if (existingElement !== void 0) {
72847
+ const rendered = renderParameter(merged, lineIndent(xml, existingElement.start));
72848
+ xml = xml.slice(0, existingElement.start) + rendered.trimStart() + xml.slice(existingElement.end);
72849
+ notes.push(`changed parameter ${input.name}`);
72850
+ } else {
72851
+ const indent2 = `${lineIndent(xml, definitions.start)} `;
72852
+ const closeIndent = lineIndent(xml, definitions.innerEnd);
72853
+ const before = xml.slice(0, definitions.innerEnd).replace(/[ \t]*$/, "");
72854
+ const glue = before.endsWith("\n") ? "" : "\n";
72855
+ xml = `${before}${glue}${renderParameter(merged, indent2)}
72856
+ ${closeIndent}${xml.slice(definitions.innerEnd)}`;
72857
+ notes.push(`added parameter ${input.name}`);
72858
+ }
72859
+ }
72860
+ }
72861
+ return { xml, notes };
72862
+ }
72863
+
72600
72864
  // ../../packages/core/dist/atlassian/jenkins.js
72601
72865
  function jobPath(job, base) {
72602
72866
  let text2 = job.trim();
@@ -72844,11 +73108,13 @@ ${text2.slice(-2e4)}`);
72844
73108
  * current Jenkins; an older or stricter one answers 403 mentioning the crumb, and gets one retry.
72845
73109
  */
72846
73110
  async post(doing, pathAndQuery, form, signal) {
72847
- const body = new URLSearchParams(form).toString();
73111
+ return this.postBody(doing, pathAndQuery, new URLSearchParams(form).toString(), "application/x-www-form-urlencoded", signal);
73112
+ }
73113
+ async postBody(doing, pathAndQuery, body, contentType2, signal) {
72848
73114
  const send2 = () => this.rest.send(doing, pathAndQuery, {
72849
73115
  method: "POST",
72850
73116
  headers: {
72851
- "Content-Type": "application/x-www-form-urlencoded",
73117
+ "Content-Type": contentType2,
72852
73118
  ...this.crumb !== void 0 ? { [this.crumb.field]: this.crumb.value } : {}
72853
73119
  },
72854
73120
  body
@@ -72867,8 +73133,8 @@ ${text2.slice(-2e4)}`);
72867
73133
  }
72868
73134
  /** Queues a build, then follows the queue item briefly to learn its number. */
72869
73135
  async startBuild(job, parameters, signal) {
72870
- const path62 = jobPath(job, this.base);
72871
- const response = await this.post(`starting ${job}`, parameters !== void 0 && Object.keys(parameters).length > 0 ? `${path62}/buildWithParameters` : `${path62}/build`, parameters ?? {}, signal);
73136
+ const path63 = jobPath(job, this.base);
73137
+ const response = await this.post(`starting ${job}`, parameters !== void 0 && Object.keys(parameters).length > 0 ? `${path63}/buildWithParameters` : `${path63}/build`, parameters ?? {}, signal);
72872
73138
  const location = response.headers["location"];
72873
73139
  const queueId = location === void 0 ? void 0 : /\/queue\/item\/(\d+)/.exec(location)?.[1];
72874
73140
  if (queueId === void 0)
@@ -72888,6 +73154,33 @@ ${text2.slice(-2e4)}`);
72888
73154
  async stopBuild(job, build2, signal) {
72889
73155
  await this.post(`stopping ${job} #${String(build2)}`, `${jobPath(job, this.base)}/${buildRef(build2)}/stop`, {}, signal);
72890
73156
  }
73157
+ /** A job's config.xml, as Jenkins holds it now. */
73158
+ async configXml(job, signal) {
73159
+ return this.rest.text(`reading the configuration of ${job}`, `${jobPath(job, this.base)}/config.xml`, signal);
73160
+ }
73161
+ /** Whether a job (or folder) of this name exists. */
73162
+ async exists(job, signal) {
73163
+ try {
73164
+ await this.rest.json(`looking for ${job}`, `${jobPath(job, this.base)}/api/json?tree=name`, { method: "GET" }, signal);
73165
+ return true;
73166
+ } catch (error51) {
73167
+ if (error51 instanceof AtlassianError && error51.status === 404)
73168
+ return false;
73169
+ throw error51;
73170
+ }
73171
+ }
73172
+ /** Creates a job from a whole config.xml, in the folder its name gives (`folder/sub/new-job`). */
73173
+ async createJob(job, xml, signal) {
73174
+ const path63 = jobPath(job, this.base);
73175
+ const cut = path63.lastIndexOf("/job/");
73176
+ const parent = path63.slice(0, cut);
73177
+ const name = decodeURIComponent(path63.slice(cut + "/job/".length));
73178
+ await this.postBody(`creating ${job}`, `${parent}/createItem?${new URLSearchParams({ name }).toString()}`, xml, "application/xml", signal);
73179
+ }
73180
+ /** Replaces a job's config.xml. */
73181
+ async saveConfig(job, xml, signal) {
73182
+ await this.postBody(`saving the configuration of ${job}`, `${jobPath(job, this.base)}/config.xml`, xml, "application/xml", signal);
73183
+ }
72891
73184
  /** The declarative linter. Read-only on the server; answers in plain text. */
72892
73185
  async validateJenkinsfile(text2, signal) {
72893
73186
  const response = await this.post("validating a Jenkinsfile", "/pipeline-model-converter/validate", { jenkinsfile: text2 }, signal);
@@ -73194,14 +73487,14 @@ ${client.base}${jobPath(job, client.base)}/${buildRef(params3.build)}/`
73194
73487
  };
73195
73488
  return tool;
73196
73489
  }
73197
- async function readJenkinsfile(path62, context) {
73198
- const resolved = await resolveToolPath(context, path62);
73490
+ async function readJenkinsfile(path63, context) {
73491
+ const resolved = await resolveToolPath(context, path63);
73199
73492
  if (!resolved.ok)
73200
73493
  return { ok: false, message: resolved.message };
73201
73494
  try {
73202
73495
  return { ok: true, text: await context.fs.readFile(resolved.realPath), realPath: resolved.realPath };
73203
73496
  } catch (error51) {
73204
- return { ok: false, message: `Could not read ${path62}: ${error51 instanceof Error ? error51.message : String(error51)}` };
73497
+ return { ok: false, message: `Could not read ${path63}: ${error51 instanceof Error ? error51.message : String(error51)}` };
73205
73498
  }
73206
73499
  }
73207
73500
  var checkSchema = external_exports.object({
@@ -73331,6 +73624,111 @@ ${log.slice(-6e3)}`);
73331
73624
  return tail === void 0 ? "" : `End of the log:
73332
73625
  ${tail.text}`;
73333
73626
  }
73627
+ var parameterInput = external_exports.object({
73628
+ name: external_exports.string().min(1),
73629
+ type: external_exports.enum(["string", "text", "boolean", "choice"]).optional().describe("Default string for a new parameter; an existing one keeps its type."),
73630
+ description: external_exports.string().optional(),
73631
+ default: external_exports.union([external_exports.string(), external_exports.boolean()]).optional().describe("The default value; for a choice, which choice comes first."),
73632
+ choices: external_exports.array(external_exports.string()).optional().describe("For a choice parameter: every choice.")
73633
+ });
73634
+ function createJenkinsWriteJobTool(options) {
73635
+ const schema8 = external_exports.object({
73636
+ action: external_exports.enum(["create", "copy", "update"]).describe(`create: a new job from a whole config (or an existing job's config given as from). copy: a new job copied from "from", optionally changed. update: change an existing job.`),
73637
+ job: external_exports.string().describe("The job to create (copy, create) or change (update), as folder/name. For create and copy it must not exist yet."),
73638
+ from: external_exports.string().optional().describe("copy: the existing job to copy, as folder/name or its URL."),
73639
+ config: external_exports.string().optional().describe("create: the whole config.xml. Prefer copy from a similar job - a config written from scratch is easy to get subtly wrong."),
73640
+ parameters: external_exports.object({
73641
+ set: external_exports.array(parameterInput).optional().describe("Add these parameters, or change those of the same name."),
73642
+ remove: external_exports.array(external_exports.string()).optional().describe("Parameter names to remove.")
73643
+ }).optional(),
73644
+ description: external_exports.string().optional().describe("The job's description."),
73645
+ edits: external_exports.array(external_exports.object({ find: external_exports.string().min(1), replace: external_exports.string() })).optional().describe("Exact text changes to the config.xml - for anything else (script path, branch, schedule, agent label). Each find must occur exactly once; read the job with jenkins_job and include enough around it to be unique.")
73646
+ });
73647
+ const shown2 = /* @__PURE__ */ new Map();
73648
+ const keyOf = (params3) => JSON.stringify(params3);
73649
+ const plan2 = async (client, params3) => {
73650
+ const target = params3.job.trim();
73651
+ jobPath(target, client.base);
73652
+ const changes = {
73653
+ ...params3.parameters !== void 0 ? { parameters: params3.parameters } : {},
73654
+ ...params3.description !== void 0 ? { description: params3.description } : {},
73655
+ ...params3.edits !== void 0 ? { edits: params3.edits } : {}
73656
+ };
73657
+ if (params3.action === "update") {
73658
+ const before = await client.configXml(target);
73659
+ const changed2 = applyJobChanges(before, changes);
73660
+ if (changed2.xml === before)
73661
+ throw new AtlassianError("Nothing would change: give parameters, a description or edits.");
73662
+ return { before, after: changed2.xml, notes: changed2.notes, target };
73663
+ }
73664
+ if (await client.exists(target)) {
73665
+ throw new AtlassianError(`"${target}" already exists. Use action update to change it, or pick another name - a job is never replaced by creating or copying over it.`);
73666
+ }
73667
+ if (params3.action === "copy") {
73668
+ if (params3.from === void 0 || params3.from.trim().length === 0)
73669
+ throw new AtlassianError('copy needs "from": the job to copy.');
73670
+ const source = await client.configXml(params3.from.trim());
73671
+ const changed2 = applyJobChanges(source, changes);
73672
+ return { before: source, after: changed2.xml, notes: [`copied from ${params3.from.trim()}`, ...changed2.notes], target };
73673
+ }
73674
+ if (params3.config === void 0 || params3.config.trim().length === 0) {
73675
+ throw new AtlassianError('create needs "config", the whole config.xml - or use copy from a similar job.');
73676
+ }
73677
+ const changed = applyJobChanges(params3.config, changes);
73678
+ return { before: "", after: changed.xml, notes: ["a new job", ...changed.notes], target };
73679
+ };
73680
+ const tool = {
73681
+ name: "jenkins_write_job",
73682
+ group: "command",
73683
+ description: `Create a Jenkins job, copy an existing job into a new one, or change a job's configuration - most often its parameters (add, change default/choices/description, remove), and anything else by exact text edits of its config.xml. To make a job "like X but with new parameters", use copy with from: X and parameters.set. Never deletes a job and never replaces an existing one by creating over it. Always shown to the user first as a diff of the configuration Jenkins will be sent; it cannot be set to always allow.`,
73684
+ parametersSchema: schema8,
73685
+ async preview(params3) {
73686
+ try {
73687
+ const client = await options.client();
73688
+ const result = await plan2(client, params3);
73689
+ shown2.set(keyOf(params3), { before: result.before, after: result.after });
73690
+ const parameters = jobParameters(result.after);
73691
+ return {
73692
+ kind: "diff",
73693
+ path: `${client.base}${jobPath(result.target, client.base)}/config.xml`,
73694
+ before: result.before,
73695
+ after: result.after,
73696
+ note: [
73697
+ `${params3.action === "update" ? "Change" : "Create"} Jenkins job ${result.target}: ${result.notes.join(", ")}`,
73698
+ parameters.length > 0 ? `Parameters after: ${parameters.map((each) => `${each.name} (${each.type}${each.default !== void 0 ? ` = ${each.default}` : ""})`).join(", ")}` : "No parameters"
73699
+ ].join(" \xB7 ")
73700
+ };
73701
+ } catch (error51) {
73702
+ return { kind: "text", text: `${error51 instanceof Error ? error51.message : String(error51)} - this will be refused.` };
73703
+ }
73704
+ },
73705
+ async execute(params3) {
73706
+ try {
73707
+ const client = await options.client();
73708
+ const approved = shown2.get(keyOf(params3));
73709
+ const now = await plan2(client, params3);
73710
+ if (approved !== void 0 && approved.before !== now.before) {
73711
+ return {
73712
+ content: `${params3.action === "update" ? params3.job : params3.from ?? params3.job} changed on Jenkins after this was shown, so nothing was saved. Ask again to see the change against the current configuration.`,
73713
+ isError: true
73714
+ };
73715
+ }
73716
+ const xml = approved?.after ?? now.after;
73717
+ if (params3.action === "update")
73718
+ await client.saveConfig(now.target, xml);
73719
+ else
73720
+ await client.createJob(now.target, xml);
73721
+ shown2.delete(keyOf(params3));
73722
+ const link = `${client.base}${jobPath(now.target, client.base)}/`;
73723
+ return { content: `${params3.action === "update" ? "Saved" : "Created"} ${now.target}: ${now.notes.join(", ")}.
73724
+ Link: ${link}` };
73725
+ } catch (error51) {
73726
+ return errorResult2(error51);
73727
+ }
73728
+ }
73729
+ };
73730
+ return tool;
73731
+ }
73334
73732
  function createJenkinsTools(options) {
73335
73733
  return [
73336
73734
  createJenkinsFindJobsTool(options),
@@ -73341,7 +73739,8 @@ function createJenkinsTools(options) {
73341
73739
  createJenkinsStartBuildTool(options),
73342
73740
  createJenkinsStopBuildTool(options),
73343
73741
  createJenkinsCheckJenkinsfileTool(options),
73344
- createJenkinsTryJenkinsfileTool(options)
73742
+ createJenkinsTryJenkinsfileTool(options),
73743
+ createJenkinsWriteJobTool(options)
73345
73744
  ];
73346
73745
  }
73347
73746
 
@@ -73668,8 +74067,8 @@ var AutosysClient = class {
73668
74067
  async runInfo(pattern, signal) {
73669
74068
  if (!isAutosysName(pattern, true))
73670
74069
  throw new AtlassianError(`"${pattern}" is not a job name or pattern.`);
73671
- const path62 = pattern.includes("*") ? fill(this.paths.runInfo, { pattern }) : fill(this.paths.jobRunInfo, { job: pattern });
73672
- return asList(await this.rest.json(`reading the status of ${pattern}`, path62, { method: "GET" }, signal)).map(toRun);
74070
+ const path63 = pattern.includes("*") ? fill(this.paths.runInfo, { pattern }) : fill(this.paths.jobRunInfo, { job: pattern });
74071
+ return asList(await this.rest.json(`reading the status of ${pattern}`, path63, { method: "GET" }, signal)).map(toRun);
73673
74072
  }
73674
74073
  /** A job's log, or undefined when this server has no log endpoint (404). */
73675
74074
  async log(name, runNum, type, signal) {
@@ -73695,9 +74094,9 @@ var AutosysClient = class {
73695
74094
  * Something this server may not offer at the documented address: undefined for a 404, so a tool can
73696
74095
  * say which setting (`autosys.paths`) points elsewhere, rather than reporting "found nothing".
73697
74096
  */
73698
- async optional(doing, path62, signal) {
74097
+ async optional(doing, path63, signal) {
73699
74098
  try {
73700
- return asList(await this.rest.json(doing, path62, { method: "GET" }, signal));
74099
+ return asList(await this.rest.json(doing, path63, { method: "GET" }, signal));
73701
74100
  } catch (error51) {
73702
74101
  if (error51 instanceof AtlassianError && error51.status === 404)
73703
74102
  return void 0;
@@ -74681,10 +75080,121 @@ function toolsForAccess(tools, readOnly, label) {
74681
75080
  return tools.filter((tool) => tool.group === "read").map((tool) => ({ ...tool, description: tool.description + note }));
74682
75081
  }
74683
75082
 
74684
- // ../../packages/core/dist/teamrepo/sync.js
74685
- var import_node_crypto15 = require("node:crypto");
75083
+ // ../../packages/core/dist/git/worktrees.js
75084
+ var import_node_child_process13 = require("node:child_process");
75085
+ var import_node_fs7 = require("node:fs");
74686
75086
  var import_promises25 = __toESM(require("node:fs/promises"), 1);
74687
75087
  var import_node_path45 = __toESM(require("node:path"), 1);
75088
+ var GitError = class extends Error {
75089
+ };
75090
+ function git(args, cwd) {
75091
+ return new Promise((resolve, reject2) => {
75092
+ (0, import_node_child_process13.execFile)("git", [...args], { cwd, maxBuffer: 16 * 1024 * 1024, windowsHide: true }, (error51, stdout, stderr) => {
75093
+ if (error51 !== null) {
75094
+ if (typeof error51.code !== "number") {
75095
+ reject2(new GitError("git could not be started - is it installed and on PATH?"));
75096
+ return;
75097
+ }
75098
+ reject2(new GitError((stderr || stdout || error51.message).trim()));
75099
+ return;
75100
+ }
75101
+ resolve(stdout);
75102
+ });
75103
+ });
75104
+ }
75105
+ function mainCheckoutOf(folder) {
75106
+ try {
75107
+ const dotGit = import_node_path45.default.join(folder, ".git");
75108
+ if (!(0, import_node_fs7.existsSync)(dotGit) || (0, import_node_fs7.statSync)(dotGit).isDirectory())
75109
+ return void 0;
75110
+ const match = /^gitdir:\s*(.+)\s*$/m.exec((0, import_node_fs7.readFileSync)(dotGit, "utf8"));
75111
+ if (match?.[1] === void 0)
75112
+ return void 0;
75113
+ const gitDir = import_node_path45.default.resolve(folder, match[1].trim());
75114
+ const common = import_node_path45.default.resolve(gitDir, (0, import_node_fs7.readFileSync)(import_node_path45.default.join(gitDir, "commondir"), "utf8").trim());
75115
+ return import_node_path45.default.basename(common) === ".git" ? import_node_path45.default.dirname(common) : void 0;
75116
+ } catch {
75117
+ return void 0;
75118
+ }
75119
+ }
75120
+ function currentBranchOf(folder) {
75121
+ try {
75122
+ const dotGit = import_node_path45.default.join(folder, ".git");
75123
+ let gitDir = dotGit;
75124
+ if (!(0, import_node_fs7.statSync)(dotGit).isDirectory()) {
75125
+ const match = /^gitdir:\s*(.+)\s*$/m.exec((0, import_node_fs7.readFileSync)(dotGit, "utf8"));
75126
+ if (match?.[1] === void 0)
75127
+ return void 0;
75128
+ gitDir = import_node_path45.default.resolve(folder, match[1].trim());
75129
+ }
75130
+ const head = (0, import_node_fs7.readFileSync)(import_node_path45.default.join(gitDir, "HEAD"), "utf8").trim();
75131
+ return head.startsWith("ref: refs/heads/") ? head.slice("ref: refs/heads/".length) : void 0;
75132
+ } catch {
75133
+ return void 0;
75134
+ }
75135
+ }
75136
+ async function listWorktrees(folder) {
75137
+ const out = await git(["worktree", "list", "--porcelain"], folder);
75138
+ const worktrees = [];
75139
+ let current;
75140
+ const flush = () => {
75141
+ if (current?.path !== void 0)
75142
+ worktrees.push({ path: current.path, main: worktrees.length === 0, ...current });
75143
+ current = void 0;
75144
+ };
75145
+ for (const line of out.split(/\r?\n/)) {
75146
+ if (line.startsWith("worktree ")) {
75147
+ flush();
75148
+ current = { path: import_node_path45.default.normalize(line.slice("worktree ".length)) };
75149
+ } else if (current !== void 0 && line.startsWith("branch ")) {
75150
+ current.branch = line.slice("branch ".length).replace(/^refs\/heads\//, "");
75151
+ } else if (current !== void 0 && line.startsWith("HEAD ")) {
75152
+ current.head = line.slice("HEAD ".length);
75153
+ } else if (current !== void 0 && line.startsWith("prunable")) {
75154
+ current.missing = true;
75155
+ }
75156
+ }
75157
+ flush();
75158
+ return worktrees.map((each, index) => ({ ...each, main: index === 0 }));
75159
+ }
75160
+ function setupMarkerFor(folder) {
75161
+ try {
75162
+ const match = /^gitdir:\s*(.+)\s*$/m.exec((0, import_node_fs7.readFileSync)(import_node_path45.default.join(folder, ".git"), "utf8"));
75163
+ return match?.[1] === void 0 ? void 0 : import_node_path45.default.join(import_node_path45.default.resolve(folder, match[1].trim()), "light-code-setup-pending");
75164
+ } catch {
75165
+ return void 0;
75166
+ }
75167
+ }
75168
+ async function copySetupFiles(mainCheckout, folder, names) {
75169
+ const copied = [];
75170
+ const skipped = [];
75171
+ for (const name of names) {
75172
+ const from = import_node_path45.default.resolve(mainCheckout, name);
75173
+ const to = import_node_path45.default.resolve(folder, name);
75174
+ const inside = (root, target) => {
75175
+ const relative = import_node_path45.default.relative(root, target);
75176
+ return relative.length > 0 && !relative.startsWith("..") && !import_node_path45.default.isAbsolute(relative);
75177
+ };
75178
+ if (!inside(mainCheckout, from) || !inside(folder, to)) {
75179
+ skipped.push(`${name} (outside the checkout)`);
75180
+ continue;
75181
+ }
75182
+ try {
75183
+ await import_promises25.default.mkdir(import_node_path45.default.dirname(to), { recursive: true });
75184
+ await import_promises25.default.copyFile(from, to, import_node_fs7.constants.COPYFILE_EXCL);
75185
+ copied.push(name);
75186
+ } catch (error51) {
75187
+ const code = error51.code;
75188
+ skipped.push(`${name} (${code === "EEXIST" ? "already there" : code === "ENOENT" ? "not in the main checkout" : String(code)})`);
75189
+ }
75190
+ }
75191
+ return { copied, skipped };
75192
+ }
75193
+
75194
+ // ../../packages/core/dist/teamrepo/sync.js
75195
+ var import_node_crypto15 = require("node:crypto");
75196
+ var import_promises26 = __toESM(require("node:fs/promises"), 1);
75197
+ var import_node_path46 = __toESM(require("node:path"), 1);
74688
75198
  var TOMBSTONE_PREFIX = "LIGHT-CODE-DELETED:";
74689
75199
  function tombstoneText(who, when3) {
74690
75200
  return `${TOMBSTONE_PREFIX} removed for the team by ${who} on ${when3.toISOString().slice(0, 10)}. Light Code no longer loads this file; writing a new one of the same name brings it back.
@@ -74733,7 +75243,7 @@ function classifyRepoPath(folder, repoPath) {
74733
75243
  }
74734
75244
  async function readState(file2, mirrorFile) {
74735
75245
  try {
74736
- const parsed = JSON.parse(await import_promises25.default.readFile(file2, "utf8"));
75246
+ const parsed = JSON.parse(await import_promises26.default.readFile(file2, "utf8"));
74737
75247
  const head = parsed.head !== void 0 ? { head: parsed.head } : {};
74738
75248
  if (parsed.version === 2) {
74739
75249
  return { version: 2, files: parsed.files ?? {}, pushed: parsed.pushed ?? {}, ...head, ...parsed.released !== void 0 ? { released: parsed.released } : {} };
@@ -74745,7 +75255,7 @@ async function readState(file2, mirrorFile) {
74745
75255
  const local = mirrorFile(repoPath);
74746
75256
  if (local === void 0)
74747
75257
  continue;
74748
- const bytes = await import_promises25.default.readFile(local).catch(() => void 0);
75258
+ const bytes = await import_promises26.default.readFile(local).catch(() => void 0);
74749
75259
  if (bytes === void 0 || rawHash(bytes) !== entry.hash)
74750
75260
  continue;
74751
75261
  files[repoPath] = { commit: entry.commit, hash: contentHash(bytes) };
@@ -74759,9 +75269,9 @@ async function readState(file2, mirrorFile) {
74759
75269
  return { version: 2, files: {}, pushed: {} };
74760
75270
  }
74761
75271
  async function writeWhole2(file2, bytes) {
74762
- await import_promises25.default.mkdir(import_node_path45.default.dirname(file2), { recursive: true });
75272
+ await import_promises26.default.mkdir(import_node_path46.default.dirname(file2), { recursive: true });
74763
75273
  const temp = `${file2}.${process.pid.toString(36)}${Math.random().toString(36).slice(2)}.tmp`;
74764
- await import_promises25.default.writeFile(temp, bytes);
75274
+ await import_promises26.default.writeFile(temp, bytes);
74765
75275
  await replaceFile(temp, file2);
74766
75276
  }
74767
75277
  async function localFiles(dir, kind) {
@@ -74771,7 +75281,7 @@ async function localFiles(dir, kind) {
74771
75281
  const walk = async (folder, prefix) => {
74772
75282
  let entries;
74773
75283
  try {
74774
- entries = await import_promises25.default.readdir(folder, { withFileTypes: true });
75284
+ entries = await import_promises26.default.readdir(folder, { withFileTypes: true });
74775
75285
  } catch {
74776
75286
  return;
74777
75287
  }
@@ -74781,9 +75291,9 @@ async function localFiles(dir, kind) {
74781
75291
  const relative = prefix.length > 0 ? `${prefix}/${entry.name}` : entry.name;
74782
75292
  if (entry.isDirectory()) {
74783
75293
  if (kind === "skills")
74784
- await walk(import_node_path45.default.join(folder, entry.name), relative);
75294
+ await walk(import_node_path46.default.join(folder, entry.name), relative);
74785
75295
  } else if (entry.isFile() && (kind === "skills" || entry.name.endsWith(".py"))) {
74786
- out.push({ relative, file: import_node_path45.default.join(folder, entry.name) });
75296
+ out.push({ relative, file: import_node_path46.default.join(folder, entry.name) });
74787
75297
  }
74788
75298
  }
74789
75299
  };
@@ -74792,7 +75302,7 @@ async function localFiles(dir, kind) {
74792
75302
  }
74793
75303
  async function syncTeamRepo(options) {
74794
75304
  const { api, branch, folder } = options;
74795
- const mirrorFile = (kind, relative) => import_node_path45.default.join(options.mirror[kind], ...relative.split("/"));
75305
+ const mirrorFile = (kind, relative) => import_node_path46.default.join(options.mirror[kind], ...relative.split("/"));
74796
75306
  const state = await readState(options.stateFile, (repoPath) => {
74797
75307
  const target = classifyRepoPath(folder, repoPath);
74798
75308
  return target === void 0 ? void 0 : mirrorFile(target.kind, target.relative);
@@ -74809,7 +75319,7 @@ async function syncTeamRepo(options) {
74809
75319
  if (gone !== void 0) {
74810
75320
  const was = classifyRepoPath(folder, gone);
74811
75321
  if (was !== void 0) {
74812
- await import_promises25.default.rm(mirrorFile(was.kind, was.relative), { force: true });
75322
+ await import_promises26.default.rm(mirrorFile(was.kind, was.relative), { force: true });
74813
75323
  delete state.files[gone];
74814
75324
  report.removed.push(gone);
74815
75325
  }
@@ -74827,7 +75337,7 @@ async function syncTeamRepo(options) {
74827
75337
  if (isTombstone(bytes)) {
74828
75338
  state.files[change.path] = { commit: head, hash: fetched, deleted: true };
74829
75339
  if (before?.deleted !== true) {
74830
- await import_promises25.default.rm(mirrorFile(target.kind, target.relative), { force: true });
75340
+ await import_promises26.default.rm(mirrorFile(target.kind, target.relative), { force: true });
74831
75341
  report.removed.push(change.path);
74832
75342
  }
74833
75343
  continue;
@@ -74843,7 +75353,7 @@ async function syncTeamRepo(options) {
74843
75353
  if (options.push !== false) {
74844
75354
  const locals = [];
74845
75355
  for (const kind of ["skills", "tools"]) {
74846
- for (const dir of new Set(options.local[kind].filter((entry) => entry !== void 0).map((entry) => import_node_path45.default.resolve(entry)))) {
75356
+ for (const dir of new Set(options.local[kind].filter((entry) => entry !== void 0).map((entry) => import_node_path46.default.resolve(entry)))) {
74847
75357
  locals.push(...(await localFiles(dir, kind)).map((entry) => ({ ...entry, kind })));
74848
75358
  }
74849
75359
  }
@@ -74852,7 +75362,7 @@ async function syncTeamRepo(options) {
74852
75362
  for (const entry of locals) {
74853
75363
  const repoPath = repoPathFor(folder, entry.kind, entry.relative);
74854
75364
  present2.add(repoPath);
74855
- const bytes = new Uint8Array(await import_promises25.default.readFile(entry.file));
75365
+ const bytes = new Uint8Array(await import_promises26.default.readFile(entry.file));
74856
75366
  const mine = hash2(bytes);
74857
75367
  const earlier = chosen.get(repoPath);
74858
75368
  if (earlier !== void 0) {
@@ -74868,9 +75378,9 @@ async function syncTeamRepo(options) {
74868
75378
  const known = state.files[repoPath];
74869
75379
  if (known?.deleted === true && state.pushed[repoPath] !== known.hash) {
74870
75380
  if (mine === state.pushed[repoPath]) {
74871
- const inside = (options.removable ?? []).some((dir) => entry.file.toLowerCase().startsWith(import_node_path45.default.resolve(dir).toLowerCase() + import_node_path45.default.sep));
75381
+ const inside = (options.removable ?? []).some((dir) => entry.file.toLowerCase().startsWith(import_node_path46.default.resolve(dir).toLowerCase() + import_node_path46.default.sep));
74872
75382
  if (inside) {
74873
- await import_promises25.default.rm(entry.file, { force: true });
75383
+ await import_promises26.default.rm(entry.file, { force: true });
74874
75384
  state.pushed[repoPath] = known.hash;
74875
75385
  report.removed.push(`${repoPath} (copy on this computer)`);
74876
75386
  } else {
@@ -74979,16 +75489,16 @@ async function checkCoverage(options) {
74979
75489
  const { folder } = options;
74980
75490
  const state = await readState(options.stateFile, (repoPath) => {
74981
75491
  const target = classifyRepoPath(folder, repoPath);
74982
- return target === void 0 ? void 0 : import_node_path45.default.join(options.mirror[target.kind], ...target.relative.split("/"));
75492
+ return target === void 0 ? void 0 : import_node_path46.default.join(options.mirror[target.kind], ...target.relative.split("/"));
74983
75493
  });
74984
75494
  const covered = { skills: 0, tools: 0 };
74985
75495
  const problems = [];
74986
75496
  const repoPaths = [];
74987
75497
  for (const kind of ["skills", "tools"]) {
74988
- for (const dir of new Set(options.dirs[kind].map((entry) => import_node_path45.default.resolve(entry)))) {
75498
+ for (const dir of new Set(options.dirs[kind].map((entry) => import_node_path46.default.resolve(entry)))) {
74989
75499
  for (const entry of await localFiles(dir, kind)) {
74990
75500
  const repoPath = repoPathFor(folder, kind, entry.relative);
74991
- const mine = hash2(new Uint8Array(await import_promises25.default.readFile(entry.file)));
75501
+ const mine = hash2(new Uint8Array(await import_promises26.default.readFile(entry.file)));
74992
75502
  const known = state.files[repoPath];
74993
75503
  if (known?.deleted === true)
74994
75504
  continue;
@@ -75008,7 +75518,7 @@ async function checkCoverage(options) {
75008
75518
  async function releaseFromRecord(stateFile, repoPaths) {
75009
75519
  let parsed;
75010
75520
  try {
75011
- parsed = JSON.parse(await import_promises25.default.readFile(stateFile, "utf8"));
75521
+ parsed = JSON.parse(await import_promises26.default.readFile(stateFile, "utf8"));
75012
75522
  } catch {
75013
75523
  return;
75014
75524
  }
@@ -75019,7 +75529,7 @@ async function tombstoneInRepo(options) {
75019
75529
  const { folder } = options;
75020
75530
  const mirrorFile = (repoPath) => {
75021
75531
  const target = classifyRepoPath(folder, repoPath);
75022
- return target === void 0 ? void 0 : import_node_path45.default.join(options.mirror[target.kind], ...target.relative.split("/"));
75532
+ return target === void 0 ? void 0 : import_node_path46.default.join(options.mirror[target.kind], ...target.relative.split("/"));
75023
75533
  };
75024
75534
  const state = await readState(options.stateFile, mirrorFile);
75025
75535
  const bytes = new TextEncoder().encode(tombstoneText(options.who, options.now ?? /* @__PURE__ */ new Date()));
@@ -75043,7 +75553,7 @@ async function tombstoneInRepo(options) {
75043
75553
  state.pushed[repoPath] = marker;
75044
75554
  const local = mirrorFile(repoPath);
75045
75555
  if (local !== void 0)
75046
- await import_promises25.default.rm(local, { force: true });
75556
+ await import_promises26.default.rm(local, { force: true });
75047
75557
  done.push(repoPath);
75048
75558
  } catch (error51) {
75049
75559
  const status2 = error51.status;
@@ -76240,8 +76750,8 @@ function parseInline(source) {
76240
76750
  out.push({ kind: "code", text: (match[2] ?? "").replace(/^ (.*) $/, "$1") });
76241
76751
  } else if (match[4] !== void 0) {
76242
76752
  const href = match[4];
76243
- const children = parseInline(match[3] ?? "");
76244
- out.push(isSafeHref(href) ? { kind: "link", href, children } : { kind: "text", text: match[0] });
76753
+ const children2 = parseInline(match[3] ?? "");
76754
+ out.push(isSafeHref(href) ? { kind: "link", href, children: children2 } : { kind: "text", text: match[0] });
76245
76755
  } else if (match[5] !== void 0) {
76246
76756
  out.push({ kind: "strong", children: parseInline(match[6] ?? "") });
76247
76757
  } else if (match[7] !== void 0) {
@@ -76642,7 +77152,7 @@ function message2(error51) {
76642
77152
  }
76643
77153
  function filesIn(params3) {
76644
77154
  return [
76645
- ...(params3.attachments ?? []).map((path62) => ({ path: path62, inline: false })),
77155
+ ...(params3.attachments ?? []).map((path63) => ({ path: path63, inline: false })),
76646
77156
  ...(params3.inlineImages ?? []).map((image) => ({ path: image.path, inline: true }))
76647
77157
  ];
76648
77158
  }
@@ -77323,19 +77833,19 @@ var WebviewApprovalGate = class {
77323
77833
  };
77324
77834
 
77325
77835
  // ../../packages/core/dist/platform/node/filesystem.js
77326
- var import_promises26 = __toESM(require("node:fs/promises"), 1);
77836
+ var import_promises27 = __toESM(require("node:fs/promises"), 1);
77327
77837
  var NodeFileSystem = class {
77328
- async readFile(path62) {
77329
- return import_promises26.default.readFile(path62, "utf8");
77838
+ async readFile(path63) {
77839
+ return import_promises27.default.readFile(path63, "utf8");
77330
77840
  }
77331
- async readBytes(path62) {
77332
- return import_promises26.default.readFile(path62);
77841
+ async readBytes(path63) {
77842
+ return import_promises27.default.readFile(path63);
77333
77843
  }
77334
- async readBytesSlice(path62, start, end) {
77844
+ async readBytesSlice(path63, start, end) {
77335
77845
  const length = Math.max(0, end - start);
77336
77846
  if (length === 0)
77337
77847
  return Buffer.alloc(0);
77338
- const handle = await import_promises26.default.open(path62, "r");
77848
+ const handle = await import_promises27.default.open(path63, "r");
77339
77849
  try {
77340
77850
  const buffer = Buffer.alloc(length);
77341
77851
  const { bytesRead } = await handle.read(buffer, 0, length, start);
@@ -77344,18 +77854,18 @@ var NodeFileSystem = class {
77344
77854
  await handle.close();
77345
77855
  }
77346
77856
  }
77347
- async writeFile(path62, contents) {
77348
- await import_promises26.default.writeFile(path62, contents, "utf8");
77857
+ async writeFile(path63, contents) {
77858
+ await import_promises27.default.writeFile(path63, contents, "utf8");
77349
77859
  }
77350
77860
  /** The counterpart of `readBytes`, and deliberately as bare as `writeFile` beside it. */
77351
- async writeBytes(path62, contents) {
77352
- await import_promises26.default.writeFile(path62, contents);
77861
+ async writeBytes(path63, contents) {
77862
+ await import_promises27.default.writeFile(path63, contents);
77353
77863
  }
77354
77864
  async rename(from, to) {
77355
77865
  await replaceFile(from, to);
77356
77866
  }
77357
- async stat(path62) {
77358
- const stat = await import_promises26.default.lstat(path62);
77867
+ async stat(path63) {
77868
+ const stat = await import_promises27.default.lstat(path63);
77359
77869
  return {
77360
77870
  size: stat.size,
77361
77871
  mtimeMs: stat.mtimeMs,
@@ -77364,8 +77874,8 @@ var NodeFileSystem = class {
77364
77874
  isSymbolicLink: stat.isSymbolicLink()
77365
77875
  };
77366
77876
  }
77367
- async readdir(path62) {
77368
- const entries = await import_promises26.default.readdir(path62, { withFileTypes: true });
77877
+ async readdir(path63) {
77878
+ const entries = await import_promises27.default.readdir(path63, { withFileTypes: true });
77369
77879
  return entries.map((entry) => ({
77370
77880
  name: entry.name,
77371
77881
  isFile: entry.isFile(),
@@ -77373,21 +77883,21 @@ var NodeFileSystem = class {
77373
77883
  isSymbolicLink: entry.isSymbolicLink()
77374
77884
  }));
77375
77885
  }
77376
- async exists(path62) {
77886
+ async exists(path63) {
77377
77887
  try {
77378
- await import_promises26.default.access(path62);
77888
+ await import_promises27.default.access(path63);
77379
77889
  return true;
77380
77890
  } catch {
77381
77891
  return false;
77382
77892
  }
77383
77893
  }
77384
- async mkdir(path62) {
77385
- await import_promises26.default.mkdir(path62, { recursive: true });
77894
+ async mkdir(path63) {
77895
+ await import_promises27.default.mkdir(path63, { recursive: true });
77386
77896
  }
77387
77897
  };
77388
77898
 
77389
77899
  // ../../packages/core/dist/config/project.js
77390
- var import_node_path46 = __toESM(require("node:path"), 1);
77900
+ var import_node_path47 = __toESM(require("node:path"), 1);
77391
77901
  function configuredProjectName(config2) {
77392
77902
  const name = config2?.project?.name?.trim();
77393
77903
  return name !== void 0 && name.length > 0 ? name : void 0;
@@ -77396,7 +77906,7 @@ function projectName(config2, workspaceRoot) {
77396
77906
  const configured = configuredProjectName(config2);
77397
77907
  if (configured !== void 0)
77398
77908
  return configured;
77399
- return workspaceRoot === void 0 ? void 0 : import_node_path46.default.basename(import_node_path46.default.resolve(workspaceRoot));
77909
+ return workspaceRoot === void 0 ? void 0 : import_node_path47.default.basename(import_node_path47.default.resolve(workspaceRoot));
77400
77910
  }
77401
77911
  function projectSlug(name) {
77402
77912
  if (name === void 0)
@@ -77406,8 +77916,8 @@ function projectSlug(name) {
77406
77916
  }
77407
77917
 
77408
77918
  // ../../packages/core/dist/rag/renameIndexes.js
77409
- var import_node_path47 = __toESM(require("node:path"), 1);
77410
- var import_node_fs7 = require("node:fs");
77919
+ var import_node_path48 = __toESM(require("node:path"), 1);
77920
+ var import_node_fs8 = require("node:fs");
77411
77921
  function planIndexRenames(names) {
77412
77922
  const plans = [];
77413
77923
  for (const kind of ["codebase", "docs", "skills"]) {
@@ -77459,7 +77969,7 @@ async function copyIndex(options) {
77459
77969
  async function copyBookkeeping(directory, from, to, storeId) {
77460
77970
  let entries;
77461
77971
  try {
77462
- entries = await import_node_fs7.promises.readdir(directory);
77972
+ entries = await import_node_fs8.promises.readdir(directory);
77463
77973
  } catch {
77464
77974
  return [];
77465
77975
  }
@@ -77470,7 +77980,7 @@ async function copyBookkeeping(directory, from, to, storeId) {
77470
77980
  continue;
77471
77981
  const target = `${to}@${storeId}.${entry.slice(prefix.length)}`;
77472
77982
  try {
77473
- await import_node_fs7.promises.copyFile(import_node_path47.default.join(directory, entry), import_node_path47.default.join(directory, target), import_node_fs7.constants.COPYFILE_EXCL);
77983
+ await import_node_fs8.promises.copyFile(import_node_path48.default.join(directory, entry), import_node_path48.default.join(directory, target), import_node_fs8.constants.COPYFILE_EXCL);
77474
77984
  copied.push(target);
77475
77985
  } catch {
77476
77986
  }
@@ -77479,7 +77989,7 @@ async function copyBookkeeping(directory, from, to, storeId) {
77479
77989
  }
77480
77990
 
77481
77991
  // ../../packages/core/dist/platform/node/terminal.js
77482
- var import_node_child_process13 = require("node:child_process");
77992
+ var import_node_child_process14 = require("node:child_process");
77483
77993
  var NodeTerminalProcess = class {
77484
77994
  child;
77485
77995
  dataListeners = [];
@@ -77509,7 +78019,7 @@ var NodeTerminalProcess = class {
77509
78019
  return;
77510
78020
  if (process.platform === "win32") {
77511
78021
  await new Promise((resolve) => {
77512
- (0, import_node_child_process13.execFile)("taskkill", ["/PID", String(pid), "/T", "/F"], () => resolve());
78022
+ (0, import_node_child_process14.execFile)("taskkill", ["/PID", String(pid), "/T", "/F"], () => resolve());
77513
78023
  });
77514
78024
  return;
77515
78025
  }
@@ -77544,7 +78054,7 @@ var NodeTerminal = class {
77544
78054
  }
77545
78055
  run(command, options = {}) {
77546
78056
  const chosen = this.shell?.trim();
77547
- const child = (0, import_node_child_process13.spawn)(command, {
78057
+ const child = (0, import_node_child_process14.spawn)(command, {
77548
78058
  cwd: options.cwd,
77549
78059
  env: options.env ? { ...process.env, ...options.env } : process.env,
77550
78060
  // `true` is Node's own default shell, which is what has always run. A string names one.
@@ -77556,8 +78066,8 @@ var NodeTerminal = class {
77556
78066
  };
77557
78067
 
77558
78068
  // ../../packages/core/dist/platform/node/taskStore.js
77559
- var import_promises27 = __toESM(require("node:fs/promises"), 1);
77560
- var import_node_path48 = __toESM(require("node:path"), 1);
78069
+ var import_promises28 = __toESM(require("node:fs/promises"), 1);
78070
+ var import_node_path49 = __toESM(require("node:path"), 1);
77561
78071
 
77562
78072
  // ../../packages/core/dist/history/types.js
77563
78073
  function taskSummary(task) {
@@ -77580,7 +78090,7 @@ var JsonTaskStore = class {
77580
78090
  constructor(globalStoragePath, truncationStore, logger) {
77581
78091
  this.truncationStore = truncationStore;
77582
78092
  this.logger = logger;
77583
- this.directory = import_node_path48.default.join(globalStoragePath, "tasks");
78093
+ this.directory = import_node_path49.default.join(globalStoragePath, "tasks");
77584
78094
  }
77585
78095
  async list(workspaceRoot) {
77586
78096
  const index = await this.readIndex();
@@ -77596,7 +78106,7 @@ var JsonTaskStore = class {
77596
78106
  if (!isValidId(id))
77597
78107
  return void 0;
77598
78108
  try {
77599
- const raw = await import_promises27.default.readFile(this.fileFor(id), "utf8");
78109
+ const raw = await import_promises28.default.readFile(this.fileFor(id), "utf8");
77600
78110
  return parseTask(raw);
77601
78111
  } catch (error51) {
77602
78112
  if (error51.code !== "ENOENT") {
@@ -77608,10 +78118,10 @@ var JsonTaskStore = class {
77608
78118
  async save(task) {
77609
78119
  if (!isValidId(task.id))
77610
78120
  throw new Error(`Refusing to save a task with an unexpected id: ${task.id}`);
77611
- await import_promises27.default.mkdir(this.directory, { recursive: true });
78121
+ await import_promises28.default.mkdir(this.directory, { recursive: true });
77612
78122
  const target = this.fileFor(task.id);
77613
78123
  const temporary = `${target}.tmp`;
77614
- await import_promises27.default.writeFile(temporary, JSON.stringify(task, null, 2), "utf8");
78124
+ await import_promises28.default.writeFile(temporary, JSON.stringify(task, null, 2), "utf8");
77615
78125
  await replaceFile(temporary, target);
77616
78126
  const index = await this.readIndex();
77617
78127
  const entry = { ...taskSummary(task), workspaceRoot: task.workspaceRoot };
@@ -77624,16 +78134,16 @@ var JsonTaskStore = class {
77624
78134
  if (task !== void 0 && task.resultHandles.length > 0) {
77625
78135
  await this.truncationStore.deleteMany(task.resultHandles);
77626
78136
  }
77627
- await import_promises27.default.rm(this.fileFor(id), { force: true });
78137
+ await import_promises28.default.rm(this.fileFor(id), { force: true });
77628
78138
  const index = await this.readIndex();
77629
78139
  await this.writeIndex(index.filter((entry) => entry.id !== id));
77630
78140
  }
77631
78141
  fileFor(id) {
77632
- return import_node_path48.default.join(this.directory, `${id}.json`);
78142
+ return import_node_path49.default.join(this.directory, `${id}.json`);
77633
78143
  }
77634
78144
  async readIndex() {
77635
78145
  try {
77636
- const raw = await import_promises27.default.readFile(import_node_path48.default.join(this.directory, INDEX_FILE), "utf8");
78146
+ const raw = await import_promises28.default.readFile(import_node_path49.default.join(this.directory, INDEX_FILE), "utf8");
77637
78147
  const parsed = JSON.parse(raw);
77638
78148
  if (Array.isArray(parsed))
77639
78149
  return parsed.filter(isIndexEntry);
@@ -77650,7 +78160,7 @@ var JsonTaskStore = class {
77650
78160
  async rebuildIndex() {
77651
78161
  let names;
77652
78162
  try {
77653
- names = await import_promises27.default.readdir(this.directory);
78163
+ names = await import_promises28.default.readdir(this.directory);
77654
78164
  } catch {
77655
78165
  return [];
77656
78166
  }
@@ -77667,10 +78177,10 @@ var JsonTaskStore = class {
77667
78177
  return entries;
77668
78178
  }
77669
78179
  async writeIndex(entries) {
77670
- await import_promises27.default.mkdir(this.directory, { recursive: true });
77671
- const target = import_node_path48.default.join(this.directory, INDEX_FILE);
78180
+ await import_promises28.default.mkdir(this.directory, { recursive: true });
78181
+ const target = import_node_path49.default.join(this.directory, INDEX_FILE);
77672
78182
  const temporary = `${target}.tmp`;
77673
- await import_promises27.default.writeFile(temporary, JSON.stringify(entries, null, 2), "utf8");
78183
+ await import_promises28.default.writeFile(temporary, JSON.stringify(entries, null, 2), "utf8");
77674
78184
  await replaceFile(temporary, target);
77675
78185
  }
77676
78186
  };
@@ -77699,8 +78209,8 @@ function parseTask(raw) {
77699
78209
  }
77700
78210
 
77701
78211
  // ../../packages/core/dist/usage/store.js
77702
- var import_node_fs8 = require("node:fs");
77703
- var import_node_path49 = __toESM(require("node:path"), 1);
78212
+ var import_node_fs9 = require("node:fs");
78213
+ var import_node_path50 = __toESM(require("node:path"), 1);
77704
78214
 
77705
78215
  // ../../packages/core/dist/s3/keys.js
77706
78216
  function normalisePrefix(prefix) {
@@ -77833,7 +78343,7 @@ var FolderShardStore = class {
77833
78343
  await this.ask({ action: "write", user: shardSegment(shard.user), day: shard.day, instance: shard.instance, events });
77834
78344
  return;
77835
78345
  }
77836
- await this.writeAtomically(import_node_path49.default.join(this.root, shardSegment(shard.user), `${shard.day}__${shard.instance}.jsonl`), shardText(events));
78346
+ await this.writeAtomically(import_node_path50.default.join(this.root, shardSegment(shard.user), `${shard.day}__${shard.instance}.jsonl`), shardText(events));
77837
78347
  }
77838
78348
  async read(fromDay, toDay) {
77839
78349
  this.lastProblems = [];
@@ -77853,8 +78363,8 @@ var FolderShardStore = class {
77853
78363
  }
77854
78364
  const files = await this.listFiles();
77855
78365
  const wanted = selectShards(files, fromDay, toDay);
77856
- const texts = await pooled(wanted, 8, (file2) => import_node_fs8.promises.readFile(import_node_path49.default.join(this.root, file2.user, file2.name), "utf8").catch((error51) => {
77857
- this.lastProblems.push(`${import_node_path49.default.join(this.root, file2.user, file2.name)}: ${error51 instanceof Error ? error51.message : String(error51)}`);
78366
+ const texts = await pooled(wanted, 8, (file2) => import_node_fs9.promises.readFile(import_node_path50.default.join(this.root, file2.user, file2.name), "utf8").catch((error51) => {
78367
+ this.lastProblems.push(`${import_node_path50.default.join(this.root, file2.user, file2.name)}: ${error51 instanceof Error ? error51.message : String(error51)}`);
77858
78368
  return "";
77859
78369
  }));
77860
78370
  return texts.flatMap(parseUsageLines);
@@ -77863,7 +78373,7 @@ var FolderShardStore = class {
77863
78373
  async listFiles() {
77864
78374
  let users;
77865
78375
  try {
77866
- users = (await import_node_fs8.promises.readdir(this.root, { withFileTypes: true })).filter((entry) => entry.isDirectory() && entry.name !== "_profiles").map((entry) => entry.name);
78376
+ users = (await import_node_fs9.promises.readdir(this.root, { withFileTypes: true })).filter((entry) => entry.isDirectory() && entry.name !== "_profiles").map((entry) => entry.name);
77867
78377
  } catch (error51) {
77868
78378
  if (error51.code === "ENOENT")
77869
78379
  return [];
@@ -77871,10 +78381,10 @@ var FolderShardStore = class {
77871
78381
  }
77872
78382
  const files = [];
77873
78383
  for (const user of users) {
77874
- const folder = import_node_path49.default.join(this.root, user);
78384
+ const folder = import_node_path50.default.join(this.root, user);
77875
78385
  let names;
77876
78386
  try {
77877
- names = await import_node_fs8.promises.readdir(folder);
78387
+ names = await import_node_fs9.promises.readdir(folder);
77878
78388
  } catch (error51) {
77879
78389
  names = [];
77880
78390
  this.lastProblems.push(`${folder}: ${error51 instanceof Error ? error51.message : String(error51)}`);
@@ -77890,7 +78400,7 @@ var FolderShardStore = class {
77890
78400
  }
77891
78401
  async readShard(shard) {
77892
78402
  try {
77893
- return parseUsageLines(await import_node_fs8.promises.readFile(import_node_path49.default.join(this.root, shardSegment(shard.user), shardFileName(shard)), "utf8"));
78403
+ return parseUsageLines(await import_node_fs9.promises.readFile(import_node_path50.default.join(this.root, shardSegment(shard.user), shardFileName(shard)), "utf8"));
77894
78404
  } catch (error51) {
77895
78405
  if (error51.code === "ENOENT")
77896
78406
  return void 0;
@@ -77898,10 +78408,10 @@ var FolderShardStore = class {
77898
78408
  }
77899
78409
  }
77900
78410
  async putMonth(shard, events) {
77901
- await this.writeAtomically(import_node_path49.default.join(this.root, shardSegment(shard.user), shardFileName(shard)), shardText(events));
78411
+ await this.writeAtomically(import_node_path50.default.join(this.root, shardSegment(shard.user), shardFileName(shard)), shardText(events));
77902
78412
  }
77903
78413
  async removeShard(shard) {
77904
- await import_node_fs8.promises.rm(import_node_path49.default.join(this.root, shardSegment(shard.user), shardFileName(shard)), { force: true });
78414
+ await import_node_fs9.promises.rm(import_node_path50.default.join(this.root, shardSegment(shard.user), shardFileName(shard)), { force: true });
77905
78415
  }
77906
78416
  async putProfile(user, profile) {
77907
78417
  this.profilesFromRead = void 0;
@@ -77909,7 +78419,7 @@ var FolderShardStore = class {
77909
78419
  await this.ask({ action: "writeProfile", user: shardSegment(user), profile: cleanProfile(profile) });
77910
78420
  return;
77911
78421
  }
77912
- await this.writeAtomically(import_node_path49.default.join(this.root, "_profiles", `${shardSegment(user)}.json`), JSON.stringify(cleanProfile(profile)));
78422
+ await this.writeAtomically(import_node_path50.default.join(this.root, "_profiles", `${shardSegment(user)}.json`), JSON.stringify(cleanProfile(profile)));
77913
78423
  }
77914
78424
  async readProfiles() {
77915
78425
  if (this.profilesFromRead !== void 0)
@@ -77918,13 +78428,13 @@ var FolderShardStore = class {
77918
78428
  await this.read("9999-12-31", "9999-12-31");
77919
78429
  return this.profilesFromRead ?? {};
77920
78430
  }
77921
- const folder = import_node_path49.default.join(this.root, "_profiles");
78431
+ const folder = import_node_path50.default.join(this.root, "_profiles");
77922
78432
  const profiles = {};
77923
- for (const name of await import_node_fs8.promises.readdir(folder).catch(() => [])) {
78433
+ for (const name of await import_node_fs9.promises.readdir(folder).catch(() => [])) {
77924
78434
  if (!name.endsWith(".json"))
77925
78435
  continue;
77926
78436
  try {
77927
- profiles[name.slice(0, -5)] = cleanProfile(JSON.parse(await import_node_fs8.promises.readFile(import_node_path49.default.join(folder, name), "utf8")));
78437
+ profiles[name.slice(0, -5)] = cleanProfile(JSON.parse(await import_node_fs9.promises.readFile(import_node_path50.default.join(folder, name), "utf8")));
77928
78438
  } catch {
77929
78439
  }
77930
78440
  }
@@ -78672,8 +79182,8 @@ function usageCollectionOn(config2, choice) {
78672
79182
  }
78673
79183
 
78674
79184
  // ../../packages/core/dist/usage/backfill.js
78675
- var import_node_fs9 = require("node:fs");
78676
- var import_node_path50 = __toESM(require("node:path"), 1);
79185
+ var import_node_fs10 = require("node:fs");
79186
+ var import_node_path51 = __toESM(require("node:path"), 1);
78677
79187
  function comparablePath(value) {
78678
79188
  return value.replace(/\\/g, "/").replace(/\/+$/, "").toLowerCase();
78679
79189
  }
@@ -78683,7 +79193,7 @@ function eventsFromTask(task, context) {
78683
79193
  return [];
78684
79194
  const created = typeof task.createdAt === "number" && task.createdAt <= updated ? task.createdAt : updated;
78685
79195
  const root = typeof task.workspaceRoot === "string" ? task.workspaceRoot : void 0;
78686
- const project = root !== void 0 && context.workspaceRoot !== void 0 && comparablePath(root) === comparablePath(context.workspaceRoot) ? context.project : root !== void 0 ? import_node_path50.default.basename(root.replace(/\\/g, "/")) : void 0;
79196
+ const project = root !== void 0 && context.workspaceRoot !== void 0 && comparablePath(root) === comparablePath(context.workspaceRoot) ? context.project : root !== void 0 ? import_node_path51.default.basename(root.replace(/\\/g, "/")) : void 0;
78687
79197
  const skillsByPath = new Map(context.skills.map((skill) => [comparablePath(skill.filePath), skill]));
78688
79198
  const skip = new Set(context.skip);
78689
79199
  const calls = [];
@@ -78720,7 +79230,7 @@ function eventsFromTask(task, context) {
78720
79230
  let skill;
78721
79231
  if (call.name === "read_file" && typeof call.args["path"] === "string") {
78722
79232
  const requested2 = call.args["path"];
78723
- const absolute = import_node_path50.default.isAbsolute(requested2) || /^[A-Za-z]:[\\/]/.test(requested2) || root === void 0 ? requested2 : import_node_path50.default.join(root, requested2);
79233
+ const absolute = import_node_path51.default.isAbsolute(requested2) || /^[A-Za-z]:[\\/]/.test(requested2) || root === void 0 ? requested2 : import_node_path51.default.join(root, requested2);
78724
79234
  skill = skillsByPath.get(comparablePath(absolute));
78725
79235
  }
78726
79236
  if (call.name === "use_skill_file" && typeof call.args["skill"] === "string") {
@@ -78757,7 +79267,7 @@ async function backfillFromTasks(tasksDir, context, helper) {
78757
79267
  }
78758
79268
  let names;
78759
79269
  try {
78760
- names = (await import_node_fs9.promises.readdir(tasksDir)).filter((name) => name.endsWith(".json") && name !== "index.json");
79270
+ names = (await import_node_fs10.promises.readdir(tasksDir)).filter((name) => name.endsWith(".json") && name !== "index.json");
78761
79271
  } catch {
78762
79272
  return { events: [], tasks: 0, unreadable: 0, via: "node" };
78763
79273
  }
@@ -78765,7 +79275,7 @@ async function backfillFromTasks(tasksDir, context, helper) {
78765
79275
  let unreadable = 0;
78766
79276
  for (const name of names) {
78767
79277
  try {
78768
- events.push(...eventsFromTask(JSON.parse(await import_node_fs9.promises.readFile(import_node_path50.default.join(tasksDir, name), "utf8")), context));
79278
+ events.push(...eventsFromTask(JSON.parse(await import_node_fs10.promises.readFile(import_node_path51.default.join(tasksDir, name), "utf8")), context));
78769
79279
  } catch {
78770
79280
  unreadable++;
78771
79281
  }
@@ -78773,24 +79283,24 @@ async function backfillFromTasks(tasksDir, context, helper) {
78773
79283
  return { events, tasks: names.length, unreadable, via: "node" };
78774
79284
  }
78775
79285
  async function backfillOnce(options) {
78776
- const doneFile = import_node_path50.default.join(options.usageDir, "backfill.json");
79286
+ const doneFile = import_node_path51.default.join(options.usageDir, "backfill.json");
78777
79287
  for (const file2 of [doneFile, ...options.legacyDoneFile !== void 0 ? [options.legacyDoneFile] : []]) {
78778
- if (await import_node_fs9.promises.stat(file2).then(() => true, () => false))
79288
+ if (await import_node_fs10.promises.stat(file2).then(() => true, () => false))
78779
79289
  return { ran: false };
78780
79290
  }
78781
- await import_node_fs9.promises.mkdir(options.usageDir, { recursive: true });
78782
- const startFile = import_node_path50.default.join(options.usageDir, "backfill-start.json");
79291
+ await import_node_fs10.promises.mkdir(options.usageDir, { recursive: true });
79292
+ const startFile = import_node_path51.default.join(options.usageDir, "backfill-start.json");
78783
79293
  let before;
78784
79294
  try {
78785
79295
  before = (options.now ?? Date.now)();
78786
- await import_node_fs9.promises.writeFile(startFile, JSON.stringify({ before }), { encoding: "utf8", flag: "wx" });
79296
+ await import_node_fs10.promises.writeFile(startFile, JSON.stringify({ before }), { encoding: "utf8", flag: "wx" });
78787
79297
  } catch (error51) {
78788
79298
  if (error51.code !== "EEXIST")
78789
79299
  throw error51;
78790
79300
  let claimed;
78791
79301
  for (let attempt = 0; attempt < 40 && claimed === void 0; attempt++) {
78792
79302
  try {
78793
- const parsed = JSON.parse(await import_node_fs9.promises.readFile(startFile, "utf8"));
79303
+ const parsed = JSON.parse(await import_node_fs10.promises.readFile(startFile, "utf8"));
78794
79304
  if (typeof parsed.before === "number")
78795
79305
  claimed = parsed.before;
78796
79306
  } catch {
@@ -79172,10 +79682,12 @@ var SCHEDULE_TICK_MS = 15e3;
79172
79682
  var STUCK_RUN_MS = 30 * 6e4;
79173
79683
  function wireChatBridge(services) {
79174
79684
  const { transport, secrets, ui, workspaceRoot, storageDir } = services;
79685
+ const projectRoot = workspaceRoot !== void 0 ? mainCheckoutOf(workspaceRoot) ?? workspaceRoot : void 0;
79686
+ const workspaceBranch = workspaceRoot !== void 0 ? currentBranchOf(workspaceRoot) : void 0;
79175
79687
  const machineApprovals = services.machineApprovalsFile !== void 0 ? new FileMachineApprovals(services.machineApprovalsFile) : void 0;
79176
79688
  const mirrorRoot = services.mirrorRoot ?? storageDir;
79177
- const personalSkillsDir = services.personalDir !== void 0 ? import_node_path51.default.join(services.personalDir, "skills") : void 0;
79178
- const personalToolsDir = services.personalDir !== void 0 ? import_node_path51.default.join(services.personalDir, "tools") : void 0;
79689
+ const personalSkillsDir = services.personalDir !== void 0 ? import_node_path52.default.join(services.personalDir, "skills") : void 0;
79690
+ const personalToolsDir = services.personalDir !== void 0 ? import_node_path52.default.join(services.personalDir, "tools") : void 0;
79179
79691
  const logger = new Logger({ level: "debug", sink: services.logSink });
79180
79692
  let fastFsOps;
79181
79693
  if (services.fastFs !== void 0) {
@@ -79184,20 +79696,20 @@ function wireChatBridge(services) {
79184
79696
  logger.info(`Rust helper ${services.fastFs ?? ""}: ${answer === void 0 ? "did not answer; its tools are off" : `version ${answer.version ?? "unknown"}, ${String(answer.ops.size)} operations`}`);
79185
79697
  });
79186
79698
  }
79187
- const configManager = new ConfigManager(services.configStore, services.workspaceRoot);
79699
+ const configManager = new ConfigManager(services.configStore, projectRoot);
79188
79700
  const httpClient = services.httpClient ?? new FetchHttpClient({ useEnvProxy: true });
79189
79701
  const conversation = new Conversation(workspaceRoot !== void 0 ? buildSystemPrompt(workspaceRoot) : void 0);
79190
79702
  let cachedSecretValues = [];
79191
79703
  const droppedFilesRoot2 = droppedFilesRoot();
79192
79704
  const mailAttachmentsRoot2 = mailAttachmentsRoot();
79193
- const droppedFilesDir = import_node_path51.default.join(droppedFilesRoot2, (0, import_node_crypto16.randomUUID)().slice(0, 8));
79194
- const truncationStore = new RecordingTruncationStore(new DiskTruncationStore(import_node_path51.default.join(storageDir, "tool-results"), () => cachedSecretValues));
79705
+ const droppedFilesDir = import_node_path52.default.join(droppedFilesRoot2, (0, import_node_crypto16.randomUUID)().slice(0, 8));
79706
+ const truncationStore = new RecordingTruncationStore(new DiskTruncationStore(import_node_path52.default.join(storageDir, "tool-results"), () => cachedSecretValues));
79195
79707
  const taskStore = new JsonTaskStore(storageDir, truncationStore, logger);
79196
79708
  const manifestsRoot = services.codebaseDir ?? storageDir;
79197
- const codebaseInstructionsFile = codebaseInstructionsPath({ codebaseDir: services.codebaseDir, storageDir, workspaceRoot });
79709
+ const codebaseInstructionsFile = codebaseInstructionsPath({ codebaseDir: services.codebaseDir, storageDir, workspaceRoot: projectRoot });
79198
79710
  if (services.codebaseDir !== void 0) {
79199
- const shared = import_node_path51.default.join(services.codebaseDir, "index-manifests");
79200
- void import_promises28.default.access(shared).catch(() => import_promises28.default.cp(import_node_path51.default.join(storageDir, "index-manifests"), shared, { recursive: true, errorOnExist: false, force: false })).catch(() => void 0);
79711
+ const shared = import_node_path52.default.join(services.codebaseDir, "index-manifests");
79712
+ void import_promises29.default.access(shared).catch(() => import_promises29.default.cp(import_node_path52.default.join(storageDir, "index-manifests"), shared, { recursive: true, errorOnExist: false, force: false })).catch(() => void 0);
79201
79713
  }
79202
79714
  const python = new PythonManager({
79203
79715
  workspaceRoot,
@@ -79325,7 +79837,7 @@ ${preview.text}` } : {}
79325
79837
  void postDatasetStatus();
79326
79838
  }
79327
79839
  });
79328
- const defaultSkillsDir = workspaceRoot !== void 0 ? import_node_path51.default.join(workspaceRoot, ".lightcode", "skills") : void 0;
79840
+ const defaultSkillsDir = workspaceRoot !== void 0 ? import_node_path52.default.join(workspaceRoot, ".lightcode", "skills") : void 0;
79329
79841
  let skillsDir = defaultSkillsDir;
79330
79842
  let localSkillsDir = defaultSkillsDir;
79331
79843
  let extraSkillDirs = [];
@@ -79348,9 +79860,9 @@ ${preview.text}` } : {}
79348
79860
  const trimmed = entry.trim();
79349
79861
  if (trimmed.length === 0)
79350
79862
  return void 0;
79351
- if (import_node_path51.default.isAbsolute(trimmed))
79352
- return import_node_path51.default.resolve(trimmed);
79353
- return workspaceRoot === void 0 ? void 0 : import_node_path51.default.resolve(workspaceRoot, trimmed);
79863
+ if (import_node_path52.default.isAbsolute(trimmed))
79864
+ return import_node_path52.default.resolve(trimmed);
79865
+ return workspaceRoot === void 0 ? void 0 : import_node_path52.default.resolve(workspaceRoot, trimmed);
79354
79866
  }
79355
79867
  function skillSearchPath() {
79356
79868
  return [skillsDir, ...extraSkillDirs].filter((dir) => dir !== void 0);
@@ -79382,12 +79894,12 @@ ${preview.text}` } : {}
79382
79894
  function watchSkillFolders() {
79383
79895
  stopWatchingSkills();
79384
79896
  const dirs = skillSearchPath();
79385
- for (const dir of [...dirs, ...dirs.map((entry) => import_node_path51.default.dirname(entry))]) {
79897
+ for (const dir of [...dirs, ...dirs.map((entry) => import_node_path52.default.dirname(entry))]) {
79386
79898
  try {
79387
79899
  skillWatchers.push(
79388
79900
  // Recursive, because a skill may be a folder with SKILL.md inside — a non-recursive
79389
79901
  // watch sees the folder appear and then never hears about the file written into it.
79390
- (0, import_node_fs10.watch)(dir, { recursive: true }, () => {
79902
+ (0, import_node_fs11.watch)(dir, { recursive: true }, () => {
79391
79903
  if (skillWatchTimer !== void 0)
79392
79904
  clearTimeout(skillWatchTimer);
79393
79905
  skillWatchTimer = setTimeout(() => {
@@ -79410,12 +79922,12 @@ ${preview.text}` } : {}
79410
79922
  // instruction on the wire twice.
79411
79923
  skills: await Promise.all(skills.map(async (skill) => {
79412
79924
  const readdir = async (dir) => {
79413
- const entries = await import_promises28.default.readdir(dir, { withFileTypes: true });
79925
+ const entries = await import_promises29.default.readdir(dir, { withFileTypes: true });
79414
79926
  return entries.map((entry) => ({ name: entry.name, isDirectory: entry.isDirectory() }));
79415
79927
  };
79416
79928
  const images = await listSkillImages(skill.filePath, { readdir });
79417
79929
  const files = await listSkillFiles(skill.filePath, { readdir });
79418
- const placeholders = findPlaceholders(await import_promises28.default.readFile(skill.filePath, "utf8").catch(() => ""));
79930
+ const placeholders = findPlaceholders(await import_promises29.default.readFile(skill.filePath, "utf8").catch(() => ""));
79419
79931
  return {
79420
79932
  name: skill.name,
79421
79933
  description: skill.description,
@@ -79459,7 +79971,7 @@ ${preview.text}` } : {}
79459
79971
  await openInPanelEditor(filePath);
79460
79972
  return;
79461
79973
  }
79462
- const real = await confineToAny(import_node_path51.default.resolve(filePath), roots);
79974
+ const real = await confineToAny(import_node_path52.default.resolve(filePath), roots);
79463
79975
  await ui.openFile?.(real);
79464
79976
  } catch (error51) {
79465
79977
  post({ type: "error", message: error51 instanceof Error ? error51.message : String(error51) });
@@ -79470,9 +79982,9 @@ ${preview.text}` } : {}
79470
79982
  python.toolsDirectory(),
79471
79983
  ...skillsDir === void 0 ? [] : [skillsDir],
79472
79984
  ...extraSkillDirs.filter((dir) => dir !== void 0),
79473
- import_node_path51.default.join(storageDir, "reports"),
79985
+ import_node_path52.default.join(storageDir, "reports"),
79474
79986
  // Its own folder: nothing else lives there.
79475
- ...codebaseInstructionsFile === void 0 ? [] : [import_node_path51.default.dirname(codebaseInstructionsFile)]
79987
+ ...codebaseInstructionsFile === void 0 ? [] : [import_node_path52.default.dirname(codebaseInstructionsFile)]
79476
79988
  ].filter((dir) => dir.length > 0);
79477
79989
  }
79478
79990
  function mostlyCrlf(text2) {
@@ -79481,32 +79993,32 @@ ${preview.text}` } : {}
79481
79993
  }
79482
79994
  const EDITOR_MAX_BYTES = 2 * 1024 * 1024;
79483
79995
  async function openInPanelEditor(filePath) {
79484
- const real = await confineToAny(import_node_path51.default.resolve(filePath), managedRoots());
79485
- const stat = await import_promises28.default.stat(real);
79996
+ const real = await confineToAny(import_node_path52.default.resolve(filePath), managedRoots());
79997
+ const stat = await import_promises29.default.stat(real);
79486
79998
  if (stat.size > EDITOR_MAX_BYTES)
79487
- throw new Error(`${import_node_path51.default.basename(real)} is too large to edit here (${String(Math.round(stat.size / 1024))} KB).`);
79488
- const raw = await import_promises28.default.readFile(real, "utf8");
79999
+ throw new Error(`${import_node_path52.default.basename(real)} is too large to edit here (${String(Math.round(stat.size / 1024))} KB).`);
80000
+ const raw = await import_promises29.default.readFile(real, "utf8");
79489
80001
  const crlf = mostlyCrlf(raw);
79490
- post({ type: "editorFile", path: real, name: import_node_path51.default.basename(real), content: raw.split("\r\n").join("\n"), mtimeMs: stat.mtimeMs, eol: crlf ? "crlf" : "lf" });
80002
+ post({ type: "editorFile", path: real, name: import_node_path52.default.basename(real), content: raw.split("\r\n").join("\n"), mtimeMs: stat.mtimeMs, eol: crlf ? "crlf" : "lf" });
79491
80003
  }
79492
80004
  async function handleSaveEditorFile(filePath, content, mtimeMs) {
79493
80005
  try {
79494
- const real = await confineToAny(import_node_path51.default.resolve(filePath), managedRoots());
79495
- const current = await import_promises28.default.stat(real).catch(() => void 0);
80006
+ const real = await confineToAny(import_node_path52.default.resolve(filePath), managedRoots());
80007
+ const current = await import_promises29.default.stat(real).catch(() => void 0);
79496
80008
  if (current !== void 0 && Math.abs(current.mtimeMs - mtimeMs) > 1) {
79497
80009
  post({
79498
80010
  type: "editorSaved",
79499
80011
  path: real,
79500
80012
  ok: false,
79501
80013
  conflict: true,
79502
- message: `${import_node_path51.default.basename(real)} was changed on disk after you opened it. Copy your text, close the editor, and open it again to see the new version.`
80014
+ message: `${import_node_path52.default.basename(real)} was changed on disk after you opened it. Copy your text, close the editor, and open it again to see the new version.`
79503
80015
  });
79504
80016
  return;
79505
80017
  }
79506
- const before = current === void 0 ? "" : await import_promises28.default.readFile(real, "utf8");
80018
+ const before = current === void 0 ? "" : await import_promises29.default.readFile(real, "utf8");
79507
80019
  const crlf = mostlyCrlf(before);
79508
80020
  await writeFileAtomically(real, crlf ? content.split("\r\n").join("\n").split("\n").join("\r\n") : content);
79509
- const saved = await import_promises28.default.stat(real);
80021
+ const saved = await import_promises29.default.stat(real);
79510
80022
  post({ type: "editorSaved", path: real, ok: true, mtimeMs: saved.mtimeMs });
79511
80023
  await postSkills().catch(() => void 0);
79512
80024
  } catch (error51) {
@@ -79523,10 +80035,10 @@ ${preview.text}` } : {}
79523
80035
  await handleOpenManagedFile(existing.filePath);
79524
80036
  return;
79525
80037
  }
79526
- const target = import_node_path51.default.join(skillsDir, "standing-instructions.md");
80038
+ const target = import_node_path52.default.join(skillsDir, "standing-instructions.md");
79527
80039
  try {
79528
- await import_promises28.default.mkdir(skillsDir, { recursive: true });
79529
- await import_promises28.default.writeFile(target, STANDING_SKILL_TEMPLATE, { encoding: "utf8", flag: "wx" });
80040
+ await import_promises29.default.mkdir(skillsDir, { recursive: true });
80041
+ await import_promises29.default.writeFile(target, STANDING_SKILL_TEMPLATE, { encoding: "utf8", flag: "wx" });
79530
80042
  } catch (error51) {
79531
80043
  const code = error51.code;
79532
80044
  if (code !== "EEXIST") {
@@ -79543,8 +80055,8 @@ ${preview.text}` } : {}
79543
80055
  return;
79544
80056
  }
79545
80057
  try {
79546
- await import_promises28.default.mkdir(import_node_path51.default.dirname(codebaseInstructionsFile), { recursive: true });
79547
- await import_promises28.default.writeFile(codebaseInstructionsFile, "", { encoding: "utf8", flag: "wx" });
80058
+ await import_promises29.default.mkdir(import_node_path52.default.dirname(codebaseInstructionsFile), { recursive: true });
80059
+ await import_promises29.default.writeFile(codebaseInstructionsFile, "", { encoding: "utf8", flag: "wx" });
79548
80060
  } catch (error51) {
79549
80061
  if (error51.code !== "EEXIST") {
79550
80062
  post({ type: "error", message: error51 instanceof Error ? error51.message : String(error51) });
@@ -79560,15 +80072,15 @@ ${preview.text}` } : {}
79560
80072
  return;
79561
80073
  if (!isValidToolName(name))
79562
80074
  throw new Error(`"${name}" is not a valid tool name.`);
79563
- const ownCopy = import_node_path51.default.join(dir, toolFileName(name));
80075
+ const ownCopy = import_node_path52.default.join(dir, toolFileName(name));
79564
80076
  if (filePath !== void 0) {
79565
- const same2 = (a, b) => normalizeForComparison(import_node_path51.default.resolve(a)) === normalizeForComparison(import_node_path51.default.resolve(b));
80077
+ const same2 = (a, b) => normalizeForComparison(import_node_path52.default.resolve(a)) === normalizeForComparison(import_node_path52.default.resolve(b));
79566
80078
  if (!same2(filePath, ownCopy)) {
79567
- const fromBucket = mirroredToolsDirs.some((mirror) => same2(import_node_path51.default.dirname(filePath), mirror));
80079
+ const fromBucket = mirroredToolsDirs.some((mirror) => same2(import_node_path52.default.dirname(filePath), mirror));
79568
80080
  throw new Error(fromBucket ? `"${name}" at ${filePath} comes from a bucket folder, so deleting it here would be undone by the next sync. Decline it to hide this version, or remove it from the bucket to remove it for everyone.` : `${filePath} is not in the tools folder this machine writes to (${dir}), so it was not deleted.`);
79569
80081
  }
79570
80082
  }
79571
- await import_promises28.default.rm(ownCopy, { force: true });
80083
+ await import_promises29.default.rm(ownCopy, { force: true });
79572
80084
  await forgetTool(dir, name);
79573
80085
  await python.refresh();
79574
80086
  await postPython();
@@ -79581,7 +80093,7 @@ ${preview.text}` } : {}
79581
80093
  return `"${name}" is not a valid tool name.`;
79582
80094
  const onDisk = async (candidate) => {
79583
80095
  try {
79584
- await import_promises28.default.stat(candidate);
80096
+ await import_promises29.default.stat(candidate);
79585
80097
  return true;
79586
80098
  } catch {
79587
80099
  return false;
@@ -79590,7 +80102,7 @@ ${preview.text}` } : {}
79590
80102
  let dir;
79591
80103
  let filePath = "";
79592
80104
  for (const candidate of python.toolDirectories()) {
79593
- const attempt = import_node_path51.default.join(candidate, toolFileName(name));
80105
+ const attempt = import_node_path52.default.join(candidate, toolFileName(name));
79594
80106
  if (await onDisk(attempt)) {
79595
80107
  dir = candidate;
79596
80108
  filePath = attempt;
@@ -79599,7 +80111,7 @@ ${preview.text}` } : {}
79599
80111
  }
79600
80112
  if (dir === void 0)
79601
80113
  return `no file for "${name}" in any configured tools folder`;
79602
- const source = await import_promises28.default.readFile(filePath, "utf8");
80114
+ const source = await import_promises29.default.readFile(filePath, "utf8");
79603
80115
  const described = await python.describe(name, filePath);
79604
80116
  if (described === void 0)
79605
80117
  return `"${name}" could not be loaded, so it was not approved`;
@@ -79621,7 +80133,7 @@ ${preview.text}` } : {}
79621
80133
  function samePath(a, b) {
79622
80134
  if (a === void 0 || b === void 0)
79623
80135
  return false;
79624
- const norm2 = (value) => process.platform === "win32" ? import_node_path51.default.resolve(value).toLowerCase() : import_node_path51.default.resolve(value);
80136
+ const norm2 = (value) => process.platform === "win32" ? import_node_path52.default.resolve(value).toLowerCase() : import_node_path52.default.resolve(value);
79625
80137
  return norm2(a) === norm2(b);
79626
80138
  }
79627
80139
  function publishFolder(kind, mirrors) {
@@ -79709,12 +80221,12 @@ ${preview.text}` } : {}
79709
80221
  const suffix = kind === "skills" ? ".md" : ".py";
79710
80222
  let entries = [];
79711
80223
  try {
79712
- entries = (await import_promises28.default.readdir(dir)).filter((entry) => !entry.startsWith(".") && entry.toLowerCase().endsWith(suffix));
80224
+ entries = (await import_promises29.default.readdir(dir)).filter((entry) => !entry.startsWith(".") && entry.toLowerCase().endsWith(suffix));
79713
80225
  } catch {
79714
80226
  entries = [];
79715
80227
  }
79716
80228
  if (entries.length === 0) {
79717
- const exists2 = await import_promises28.default.stat(dir).then(() => true).catch(() => false);
80229
+ const exists2 = await import_promises29.default.stat(dir).then(() => true).catch(() => false);
79718
80230
  ui.showInfo(exists2 ? `Nothing in ${dir} to upload.` : `${dir} does not exist yet, so there is nothing to upload.`);
79719
80231
  return;
79720
80232
  }
@@ -79729,7 +80241,7 @@ ${preview.text}` } : {}
79729
80241
  target,
79730
80242
  ...mirror.prefix !== void 0 ? { prefix: mirror.prefix } : {},
79731
80243
  relative: entry,
79732
- contents: await import_promises28.default.readFile(import_node_path51.default.join(dir, entry))
80244
+ contents: await import_promises29.default.readFile(import_node_path52.default.join(dir, entry))
79733
80245
  });
79734
80246
  uploaded += 1;
79735
80247
  } catch (error51) {
@@ -79751,9 +80263,9 @@ ${preview.text}` } : {}
79751
80263
  if (!isValidToolName(name))
79752
80264
  throw new Error(`"${name}" is not a valid tool name.`);
79753
80265
  for (const candidate of python.toolDirectories()) {
79754
- const attempt = import_node_path51.default.join(candidate, toolFileName(name));
80266
+ const attempt = import_node_path52.default.join(candidate, toolFileName(name));
79755
80267
  try {
79756
- post({ type: "pythonToolSource", name, source: await import_promises28.default.readFile(attempt, "utf8") });
80268
+ post({ type: "pythonToolSource", name, source: await import_promises29.default.readFile(attempt, "utf8") });
79757
80269
  return;
79758
80270
  } catch {
79759
80271
  }
@@ -79804,7 +80316,7 @@ ${preview.text}` } : {}
79804
80316
  continue;
79805
80317
  for (const candidate of python.toolDirectories()) {
79806
80318
  try {
79807
- const source = await import_promises28.default.readFile(import_node_path51.default.join(candidate, toolFileName(name)), "utf8");
80319
+ const source = await import_promises29.default.readFile(import_node_path52.default.join(candidate, toolFileName(name)), "utf8");
79808
80320
  declined[name] = hashSource(source);
79809
80321
  recorded += 1;
79810
80322
  break;
@@ -79853,7 +80365,7 @@ ${preview.text}` } : {}
79853
80365
  throw new Error(`"${name}" is not a valid tool name.`);
79854
80366
  const onDisk = async (candidate) => {
79855
80367
  try {
79856
- await import_promises28.default.stat(candidate);
80368
+ await import_promises29.default.stat(candidate);
79857
80369
  return true;
79858
80370
  } catch {
79859
80371
  return false;
@@ -79862,7 +80374,7 @@ ${preview.text}` } : {}
79862
80374
  let dir;
79863
80375
  let filePath = "";
79864
80376
  for (const candidate of python.toolDirectories()) {
79865
- const attempt = import_node_path51.default.join(candidate, toolFileName(name));
80377
+ const attempt = import_node_path52.default.join(candidate, toolFileName(name));
79866
80378
  if (await onDisk(attempt)) {
79867
80379
  dir = candidate;
79868
80380
  filePath = attempt;
@@ -79872,7 +80384,7 @@ ${preview.text}` } : {}
79872
80384
  if (dir === void 0) {
79873
80385
  throw new Error(`No file for "${name}" was found in any configured tools folder.`);
79874
80386
  }
79875
- const source = await import_promises28.default.readFile(filePath, "utf8");
80387
+ const source = await import_promises29.default.readFile(filePath, "utf8");
79876
80388
  const described = await python.describe(name, filePath);
79877
80389
  if (described === void 0) {
79878
80390
  throw new Error(`"${name}" could not be loaded, so it was not approved. Fix the file and try again.`);
@@ -79888,7 +80400,7 @@ ${preview.text}` } : {}
79888
80400
  function mirrorForDir(sourceDir) {
79889
80401
  if (sourceDir === void 0)
79890
80402
  return void 0;
79891
- const wanted = import_node_path51.default.resolve(sourceDir).toLowerCase();
80403
+ const wanted = import_node_path52.default.resolve(sourceDir).toLowerCase();
79892
80404
  for (const mirror of cachedSkillMirrors) {
79893
80405
  if (mirror.enabled !== true)
79894
80406
  continue;
@@ -79898,7 +80410,7 @@ ${preview.text}` } : {}
79898
80410
  kind: "skills",
79899
80411
  ...mirror.prefix !== void 0 ? { prefix: mirror.prefix } : {}
79900
80412
  });
79901
- if (import_node_path51.default.resolve(localDir).toLowerCase() === wanted)
80413
+ if (import_node_path52.default.resolve(localDir).toLowerCase() === wanted)
79902
80414
  return { mirror, localDir };
79903
80415
  }
79904
80416
  return void 0;
@@ -79963,8 +80475,8 @@ ${preview.text}` } : {}
79963
80475
  });
79964
80476
  let localProblem;
79965
80477
  try {
79966
- await import_promises28.default.rm(import_node_path51.default.join(found2.localDir, `${name}.md`), { force: true });
79967
- await import_promises28.default.rm(import_node_path51.default.join(found2.localDir, name), { recursive: true, force: true });
80478
+ await import_promises29.default.rm(import_node_path52.default.join(found2.localDir, `${name}.md`), { force: true });
80479
+ await import_promises29.default.rm(import_node_path52.default.join(found2.localDir, name), { recursive: true, force: true });
79968
80480
  } catch (error51) {
79969
80481
  localProblem = error51 instanceof Error ? error51.message : String(error51);
79970
80482
  }
@@ -79999,7 +80511,7 @@ ${preview.text}` } : {}
79999
80511
  throw new Error(`"${name}" lives in ${existing.sourceDir}, which is a read-only skills folder. Delete the file there, or remove the folder in Settings.`);
80000
80512
  }
80001
80513
  const from = existing?.sourceDir !== void 0 && samePath(existing.sourceDir, personalSkillsDir) ? existing.sourceDir : skillsDir;
80002
- await import_promises28.default.rm(import_node_path51.default.join(from, skillFileName(name)), { force: true });
80514
+ await import_promises29.default.rm(import_node_path52.default.join(from, skillFileName(name)), { force: true });
80003
80515
  await postSkills();
80004
80516
  } catch (error51) {
80005
80517
  post({ type: "error", message: error51 instanceof Error ? error51.message : String(error51) });
@@ -80179,9 +80691,9 @@ ${preview.text}` } : {}
80179
80691
  const MENTION_SCAN_LIMIT = 2e3;
80180
80692
  const MENTION_RESULT_LIMIT = 30;
80181
80693
  let scheduleToolAccess;
80182
- const approvalsKey = workspaceRoot ?? "__no_workspace__";
80694
+ const approvalsKey = projectRoot ?? "__no_workspace__";
80183
80695
  function comparableApprovalsKey(key2) {
80184
- return key2 === "__no_workspace__" ? key2 : normalizeForComparison(import_node_path51.default.resolve(key2));
80696
+ return key2 === "__no_workspace__" ? key2 : normalizeForComparison(import_node_path52.default.resolve(key2));
80185
80697
  }
80186
80698
  function approvalsFrom(stored) {
80187
80699
  if (stored === void 0)
@@ -80392,14 +80904,14 @@ ${preview.text}` } : {}
80392
80904
  ...taskExpertEstimate === void 0 ? {} : { estimate: taskExpertEstimate }
80393
80905
  });
80394
80906
  }
80395
- const expertEventsPath = import_node_path51.default.join(storageDir, "expert-events.jsonl");
80907
+ const expertEventsPath = import_node_path52.default.join(storageDir, "expert-events.jsonl");
80396
80908
  let expertEvents;
80397
80909
  let juniorTurnWithoutExpert = false;
80398
80910
  async function loadExpertEvents() {
80399
80911
  if (expertEvents !== void 0)
80400
80912
  return expertEvents;
80401
80913
  try {
80402
- const raw = await import_promises28.default.readFile(expertEventsPath, "utf8");
80914
+ const raw = await import_promises29.default.readFile(expertEventsPath, "utf8");
80403
80915
  const parsed = [];
80404
80916
  for (const line of raw.split("\n")) {
80405
80917
  if (line.trim().length === 0)
@@ -80420,8 +80932,8 @@ ${preview.text}` } : {}
80420
80932
  try {
80421
80933
  const events = await loadExpertEvents();
80422
80934
  events.push(event);
80423
- await import_promises28.default.mkdir(import_node_path51.default.dirname(expertEventsPath), { recursive: true });
80424
- await import_promises28.default.appendFile(expertEventsPath, `${JSON.stringify(event)}
80935
+ await import_promises29.default.mkdir(import_node_path52.default.dirname(expertEventsPath), { recursive: true });
80936
+ await import_promises29.default.appendFile(expertEventsPath, `${JSON.stringify(event)}
80425
80937
  `, "utf8");
80426
80938
  } catch (error51) {
80427
80939
  logger.warn(`could not record expert spend: ${String(error51)}`);
@@ -80706,11 +81218,15 @@ ${preview.text}` } : {}
80706
81218
  function contextMentionPath(file2) {
80707
81219
  if (workspaceRoot === void 0)
80708
81220
  return file2;
80709
- const relative = import_node_path51.default.relative(workspaceRoot, file2);
80710
- return relative.length > 0 && !relative.startsWith("..") && !import_node_path51.default.isAbsolute(relative) ? relative.split(import_node_path51.default.sep).join("/") : file2;
81221
+ const relative = import_node_path52.default.relative(workspaceRoot, file2);
81222
+ return relative.length > 0 && !relative.startsWith("..") && !import_node_path52.default.isAbsolute(relative) ? relative.split(import_node_path52.default.sep).join("/") : file2;
80711
81223
  }
80712
81224
  function hostCapabilities() {
80713
81225
  return {
81226
+ // The branch this window or tab works on, shown under the chat's name; and the repository, when this
81227
+ // folder is one of its branch folders (git/worktrees.ts).
81228
+ ...workspaceBranch !== void 0 ? { workspaceBranch } : {},
81229
+ ...projectRoot !== void 0 && workspaceRoot !== void 0 && projectRoot !== workspaceRoot ? { branchFolderOf: import_node_path52.default.basename(projectRoot) } : {},
80714
81230
  // The GitHub Copilot preset, offered only where VS Code's models can be reached.
80715
81231
  hostModels: services.languageModels !== void 0,
80716
81232
  nativeGuide: ui.openWalkthrough !== void 0,
@@ -81225,14 +81741,14 @@ ${error51.stack.split("\n").slice(1, 6).join("\n")}`;
81225
81741
  }
81226
81742
  function readUserNpmrc() {
81227
81743
  try {
81228
- return (0, import_node_fs11.readFileSync)(process.env["NPM_CONFIG_USERCONFIG"] ?? import_node_path51.default.join(import_node_os6.default.homedir(), ".npmrc"), "utf8");
81744
+ return (0, import_node_fs12.readFileSync)(process.env["NPM_CONFIG_USERCONFIG"] ?? import_node_path52.default.join(import_node_os6.default.homedir(), ".npmrc"), "utf8");
81229
81745
  } catch {
81230
81746
  return void 0;
81231
81747
  }
81232
81748
  }
81233
81749
  function addonFolders(config2) {
81234
81750
  return {
81235
- configured: (config2.addons?.folders ?? []).map((folder) => import_node_path51.default.resolve(folder)),
81751
+ configured: (config2.addons?.folders ?? []).map((folder) => import_node_path52.default.resolve(folder)),
81236
81752
  defaults: defaultAddonFolders(process.env, process.execPath, process.platform, readUserNpmrc())
81237
81753
  };
81238
81754
  }
@@ -81256,7 +81772,7 @@ ${error51.stack.split("\n").slice(1, 6).join("\n")}`;
81256
81772
  stored.add(ref);
81257
81773
  const delivery = deliveryFor(addonRoot, addon, settings, stored);
81258
81774
  await writeFileAtomically(delivery.file, JSON.stringify(delivery.contents, null, 2));
81259
- await import_promises28.default.mkdir(addonDownloadsDir(addonRoot, addon), { recursive: true });
81775
+ await import_promises29.default.mkdir(addonDownloadsDir(addonRoot, addon), { recursive: true });
81260
81776
  delivered.set(addon.package, delivery.env);
81261
81777
  } catch (error51) {
81262
81778
  logger.warn(`Could not prepare the settings for add-on ${addon.package}: ${describeFailure2(error51)}`);
@@ -81513,7 +82029,7 @@ ${error51.stack.split("\n").slice(1, 6).join("\n")}`;
81513
82029
  }
81514
82030
  async function handleSaveAddonFolders(folders) {
81515
82031
  const cleaned = [...new Set(folders.map((folder) => folder.trim()).filter((folder) => folder.length > 0))];
81516
- const relative = cleaned.find((folder) => !import_node_path51.default.isAbsolute(folder));
82032
+ const relative = cleaned.find((folder) => !import_node_path52.default.isAbsolute(folder));
81517
82033
  if (relative !== void 0) {
81518
82034
  await postAddons(`"${relative}" is not a full path. Add-on folders are full paths, such as C:\\addons.`);
81519
82035
  return;
@@ -81524,7 +82040,7 @@ ${error51.stack.split("\n").slice(1, 6).join("\n")}`;
81524
82040
  postMcp();
81525
82041
  await postAddons();
81526
82042
  }
81527
- const shadowGit = workspaceRoot !== void 0 ? new ShadowGit(workspaceRoot, import_node_path51.default.join(storageDir, "checkpoints", "shadow.git"), services.codebaseDir !== void 0 ? import_node_path51.default.join(services.codebaseDir, "checkpoint-objects") : void 0) : void 0;
82043
+ const shadowGit = workspaceRoot !== void 0 ? new ShadowGit(workspaceRoot, import_node_path52.default.join(storageDir, "checkpoints", "shadow.git"), services.codebaseDir !== void 0 ? import_node_path52.default.join(services.codebaseDir, "checkpoint-objects") : void 0) : void 0;
81528
82044
  async function postProfiles() {
81529
82045
  const { config: config2 } = await configManager.load();
81530
82046
  const profiles = await Promise.all((config2.profiles ?? []).map((profile) => toSummary(profile, secrets)));
@@ -81949,7 +82465,8 @@ ${error51.stack.split("\n").slice(1, 6).join("\n")}`;
81949
82465
  ...services.fileReach === "anywhere" ? { reach: "anywhere" } : {},
81950
82466
  // Resolved per turn by the host, so an edit applies to the next command rather than
81951
82467
  // needing a new session. Absent in the extension, where there is nothing to resolve.
81952
- ...services.sessionEnv !== void 0 ? { sessionEnv: services.sessionEnv() } : {},
82468
+ // The host's own values, and this branch folder's (LIGHT_CODE_BRANCH, LIGHT_CODE_PORT_OFFSET).
82469
+ ...services.sessionEnv !== void 0 || Object.keys(branchEnv).length > 0 ? { sessionEnv: { ...services.sessionEnv?.() ?? {}, ...branchEnv } } : {},
81953
82470
  /*
81954
82471
  * Omitted for a scheduled run: there is nobody to answer, and a run that could grant
81955
82472
  * itself new filesystem access would defeat the point of its allowlist.
@@ -81960,7 +82477,7 @@ ${error51.stack.split("\n").slice(1, 6).join("\n")}`;
81960
82477
  ...schedule === void 0 ? { requestForm } : {},
81961
82478
  // A skill read with the user's defaults for its placeholders carries them (`skills/defaults.ts`).
81962
82479
  annotateRead: (realPath) => {
81963
- const fold = (value) => process.platform === "win32" ? import_node_path51.default.resolve(value).toLowerCase() : import_node_path51.default.resolve(value);
82480
+ const fold = (value) => process.platform === "win32" ? import_node_path52.default.resolve(value).toLowerCase() : import_node_path52.default.resolve(value);
81964
82481
  const skill = skills.find((each) => fold(each.filePath) === fold(realPath));
81965
82482
  return skill === void 0 ? void 0 : skillDefaultsReadNote(skill.name, config2.skillDefaults?.[skill.name]);
81966
82483
  },
@@ -82589,8 +83106,8 @@ ${direction}` : attachMentions(text2, mentions);
82589
83106
  const fromHub = hub === void 0 || root !== workspaceRoot ? void 0 : await hubGitDiff(hub);
82590
83107
  if (typeof fromHub === "string")
82591
83108
  throw new Error(fromHub);
82592
- const git = (args) => new Promise((resolve) => {
82593
- const child = (0, import_node_child_process14.spawn)("git", ["--no-optional-locks", "-C", root, ...args], {
83109
+ const git2 = (args) => new Promise((resolve) => {
83110
+ const child = (0, import_node_child_process15.spawn)("git", ["--no-optional-locks", "-C", root, ...args], {
82594
83111
  env: { ...process.env, GIT_TERMINAL_PROMPT: "0" },
82595
83112
  windowsHide: true
82596
83113
  });
@@ -82606,15 +83123,15 @@ ${direction}` : attachMentions(text2, mentions);
82606
83123
  resolve({ ok: code === 0, out });
82607
83124
  });
82608
83125
  });
82609
- const status2 = fromHub !== void 0 ? { ok: true, out: fromHub.status } : await git(["status", "--short", "--untracked-files=normal"]);
83126
+ const status2 = fromHub !== void 0 ? { ok: true, out: fromHub.status } : await git2(["status", "--short", "--untracked-files=normal"]);
82610
83127
  if (!status2.ok)
82611
83128
  throw new Error("This folder is not a git repository, or git could not be run.");
82612
83129
  if (status2.out.trim().length === 0)
82613
83130
  throw new Error("Nothing has changed, so there is nothing to describe.");
82614
- const staged = fromHub === void 0 && options.preferStaged === true ? await git(["diff", "--cached", "--no-color", "--no-ext-diff", "--stat", "--patch"]) : void 0;
82615
- let diff = fromHub !== void 0 ? { ok: true, out: fromHub.diff } : staged !== void 0 && staged.ok && staged.out.trim().length > 0 ? staged : await git(["diff", "HEAD", "--no-color", "--no-ext-diff", "--stat", "--patch"]);
83131
+ const staged = fromHub === void 0 && options.preferStaged === true ? await git2(["diff", "--cached", "--no-color", "--no-ext-diff", "--stat", "--patch"]) : void 0;
83132
+ let diff = fromHub !== void 0 ? { ok: true, out: fromHub.diff } : staged !== void 0 && staged.ok && staged.out.trim().length > 0 ? staged : await git2(["diff", "HEAD", "--no-color", "--no-ext-diff", "--stat", "--patch"]);
82616
83133
  if (!diff.ok)
82617
- diff = await git(["diff", "--no-color", "--no-ext-diff", "--stat", "--patch"]);
83134
+ diff = await git2(["diff", "--no-color", "--no-ext-diff", "--stat", "--patch"]);
82618
83135
  const shown2 = diff.out.length > 24e3 ? `${diff.out.slice(0, 24e3)}
82619
83136
  ... (diff cut here)` : diff.out;
82620
83137
  const config2 = await loadSettings();
@@ -83221,7 +83738,7 @@ ${redact(shown2, cachedSecretValues)}` }
83221
83738
  return { mode: cachedSearchScope, author: cachedAttribution.author };
83222
83739
  }
83223
83740
  function currentProjectNames() {
83224
- const names = [cachedAttribution.project, workspaceRoot !== void 0 ? import_node_path51.default.basename(workspaceRoot) : void 0];
83741
+ const names = [cachedAttribution.project, workspaceRoot !== void 0 ? import_node_path52.default.basename(workspaceRoot) : void 0];
83225
83742
  return names.filter((name) => name !== void 0 && name.length > 0);
83226
83743
  }
83227
83744
  function indexProject(config2) {
@@ -83324,8 +83841,8 @@ ${redact(shown2, cachedSecretValues)}` }
83324
83841
  limit: limits.limit,
83325
83842
  previewChars: limits.previewChars
83326
83843
  });
83327
- for (const path62 of answer.skipped ?? [])
83328
- skipped.add(path62);
83844
+ for (const path63 of answer.skipped ?? [])
83845
+ skipped.add(path63);
83329
83846
  return { messages: answer.messages, truncated: answer.truncated };
83330
83847
  },
83331
83848
  ...embedder !== void 0 && search !== void 0 && collection !== void 0 ? {
@@ -83624,9 +84141,9 @@ ${redact(shown2, cachedSecretValues)}` }
83624
84141
  });
83625
84142
  const all = result.folders.map((entry) => entry.path);
83626
84143
  const wanted = new Set(chosen);
83627
- for (const path62 of all) {
83628
- if (chosen.some((root) => path62 === root || path62.startsWith(`${root}\\`)))
83629
- wanted.add(path62);
84144
+ for (const path63 of all) {
84145
+ if (chosen.some((root) => path63 === root || path63.startsWith(`${root}\\`)))
84146
+ wanted.add(path63);
83630
84147
  }
83631
84148
  return [...wanted];
83632
84149
  } catch {
@@ -83634,10 +84151,10 @@ ${redact(shown2, cachedSecretValues)}` }
83634
84151
  }
83635
84152
  }
83636
84153
  async function handleRequestOutlookFolders(depth, force = false) {
83637
- const cachePath = import_node_path51.default.join(storageDir, "outlook-folders.json");
84154
+ const cachePath = import_node_path52.default.join(storageDir, "outlook-folders.json");
83638
84155
  let served = false;
83639
84156
  try {
83640
- const cached2 = JSON.parse(await import_promises28.default.readFile(cachePath, "utf8"));
84157
+ const cached2 = JSON.parse(await import_promises29.default.readFile(cachePath, "utf8"));
83641
84158
  post({
83642
84159
  type: "outlookFolders",
83643
84160
  folders: cached2.folders,
@@ -83654,8 +84171,8 @@ ${redact(shown2, cachedSecretValues)}` }
83654
84171
  const scannedAt = Date.now();
83655
84172
  post({ type: "outlookFolders", folders: result.folders, scannedAt });
83656
84173
  try {
83657
- await import_promises28.default.mkdir(import_node_path51.default.dirname(cachePath), { recursive: true });
83658
- await import_promises28.default.writeFile(cachePath, JSON.stringify({ scannedAt, folders: result.folders }), "utf8");
84174
+ await import_promises29.default.mkdir(import_node_path52.default.dirname(cachePath), { recursive: true });
84175
+ await import_promises29.default.writeFile(cachePath, JSON.stringify({ scannedAt, folders: result.folders }), "utf8");
83659
84176
  } catch {
83660
84177
  }
83661
84178
  } catch (error51) {
@@ -84373,12 +84890,12 @@ ${redact(shown2, cachedSecretValues)}` }
84373
84890
  if (!isSafeSegment(settings.project) || !isSafeSegment(settings.repo))
84374
84891
  return { reason: "Enter the project key and repository slug." };
84375
84892
  const digest = (0, import_node_crypto16.createHash)("sha256").update(JSON.stringify([bitbucket.baseUrl, settings.project, settings.repo, settings.branch, settings.folder]).toLowerCase()).digest("hex").slice(0, 12);
84376
- const root = import_node_path51.default.join(mirrorRoot, "teamrepo", `${settings.project}-${settings.repo}-${digest}`.toLowerCase());
84893
+ const root = import_node_path52.default.join(mirrorRoot, "teamrepo", `${settings.project}-${settings.repo}-${digest}`.toLowerCase());
84377
84894
  return {
84378
- dirs: { skills: import_node_path51.default.join(root, "skills"), tools: import_node_path51.default.join(root, "tools") },
84895
+ dirs: { skills: import_node_path52.default.join(root, "skills"), tools: import_node_path52.default.join(root, "tools") },
84379
84896
  // Where new skills and tools are saved while the repository is on - see loadSettings and pythonFolders.
84380
- own: { skills: import_node_path51.default.join(root, "saved-here", "skills"), tools: import_node_path51.default.join(root, "saved-here", "tools") },
84381
- stateFile: import_node_path51.default.join(root, TEAM_REPO_STATE_FILE),
84897
+ own: { skills: import_node_path52.default.join(root, "saved-here", "skills"), tools: import_node_path52.default.join(root, "saved-here", "tools") },
84898
+ stateFile: import_node_path52.default.join(root, TEAM_REPO_STATE_FILE),
84382
84899
  settings
84383
84900
  };
84384
84901
  }
@@ -84432,24 +84949,24 @@ ${redact(shown2, cachedSecretValues)}` }
84432
84949
  out.push(dir);
84433
84950
  return out;
84434
84951
  };
84435
- const has2 = async (target) => import_promises28.default.stat(target).then(() => true, () => false);
84952
+ const has2 = async (target) => import_promises29.default.stat(target).then(() => true, () => false);
84436
84953
  if (kind === "skill") {
84437
84954
  for (const dir of unique([skillsDir, localSkillsDir, personalSkillsDir, ...mirroredSkillsDirs])) {
84438
- if (await has2(import_node_path51.default.join(dir, skillFileName(name))))
84439
- plan2.local.push(import_node_path51.default.join(dir, skillFileName(name)));
84440
- if (await has2(import_node_path51.default.join(dir, name, "SKILL.md")))
84441
- plan2.local.push(import_node_path51.default.join(dir, name));
84955
+ if (await has2(import_node_path52.default.join(dir, skillFileName(name))))
84956
+ plan2.local.push(import_node_path52.default.join(dir, skillFileName(name)));
84957
+ if (await has2(import_node_path52.default.join(dir, name, "SKILL.md")))
84958
+ plan2.local.push(import_node_path52.default.join(dir, name));
84442
84959
  }
84443
84960
  for (const extra of config2.skills?.paths ?? []) {
84444
84961
  const dir = resolveSkillDir(extra);
84445
- if (dir !== void 0 && (await has2(import_node_path51.default.join(dir, skillFileName(name))) || await has2(import_node_path51.default.join(dir, name, "SKILL.md")))) {
84962
+ if (dir !== void 0 && (await has2(import_node_path52.default.join(dir, skillFileName(name))) || await has2(import_node_path52.default.join(dir, name, "SKILL.md")))) {
84446
84963
  plan2.notes.push(`Also in ${dir}, a folder you added in Settings -> Skills - not removed; delete it there.`);
84447
84964
  }
84448
84965
  }
84449
84966
  } else {
84450
84967
  for (const dir of unique([pythonFolders(config2).toolsDir, localToolsDir(config2), personalToolsDir, ...mirroredToolsDirs])) {
84451
- if (await has2(import_node_path51.default.join(dir, toolFileName(name))))
84452
- plan2.local.push(import_node_path51.default.join(dir, toolFileName(name)));
84968
+ if (await has2(import_node_path52.default.join(dir, toolFileName(name))))
84969
+ plan2.local.push(import_node_path52.default.join(dir, toolFileName(name)));
84453
84970
  }
84454
84971
  }
84455
84972
  const mirrors = (kind === "skill" ? cachedSkillMirrors : cachedToolMirrors).filter((mirror) => mirror.enabled === true);
@@ -84528,9 +85045,9 @@ ${redact(shown2, cachedSecretValues)}` }
84528
85045
  const localProblems = [];
84529
85046
  for (const entry of local) {
84530
85047
  try {
84531
- await import_promises28.default.rm(entry, { recursive: true, force: true });
85048
+ await import_promises29.default.rm(entry, { recursive: true, force: true });
84532
85049
  if (kind === "tool")
84533
- await forgetTool(import_node_path51.default.dirname(entry), name).catch(() => void 0);
85050
+ await forgetTool(import_node_path52.default.dirname(entry), name).catch(() => void 0);
84534
85051
  } catch (error51) {
84535
85052
  localProblems.push(`${entry} (${error51 instanceof Error ? error51.message : String(error51)})`);
84536
85053
  }
@@ -84567,8 +85084,8 @@ ${redact(shown2, cachedSecretValues)}` }
84567
85084
  function isPersonalSkill(skill) {
84568
85085
  if (personalSkillsDir === void 0)
84569
85086
  return false;
84570
- const norm2 = (value) => process.platform === "win32" ? import_node_path51.default.resolve(value).toLowerCase() : import_node_path51.default.resolve(value);
84571
- return norm2(skill.filePath).startsWith(norm2(personalSkillsDir) + import_node_path51.default.sep);
85087
+ const norm2 = (value) => process.platform === "win32" ? import_node_path52.default.resolve(value).toLowerCase() : import_node_path52.default.resolve(value);
85088
+ return norm2(skill.filePath).startsWith(norm2(personalSkillsDir) + import_node_path52.default.sep);
84572
85089
  }
84573
85090
  function bucketFolderLabels(config2) {
84574
85091
  const label = (kind, mirror) => {
@@ -84786,6 +85303,66 @@ ${redact(shown2, cachedSecretValues)}` }
84786
85303
  const mirrorSyncInFlight = /* @__PURE__ */ new Set();
84787
85304
  let mirrorSyncTimer;
84788
85305
  let lastAutoMirrorSync = 0;
85306
+ const branchEnv = {};
85307
+ async function prepareBranchFolder() {
85308
+ if (workspaceRoot === void 0)
85309
+ return;
85310
+ try {
85311
+ if (workspaceBranch !== void 0)
85312
+ branchEnv["LIGHT_CODE_BRANCH"] = workspaceBranch;
85313
+ if (projectRoot !== void 0 && projectRoot !== workspaceRoot) {
85314
+ const list2 = await listWorktrees(workspaceRoot).catch(() => []);
85315
+ const index = list2.findIndex((each) => samePath(each.path, workspaceRoot));
85316
+ branchEnv["LIGHT_CODE_PORT_OFFSET"] = String(Math.max(index, 1));
85317
+ } else if (workspaceBranch !== void 0) {
85318
+ branchEnv["LIGHT_CODE_PORT_OFFSET"] = "0";
85319
+ }
85320
+ const marker = setupMarkerFor(workspaceRoot);
85321
+ if (marker === void 0 || !await import_promises29.default.stat(marker).then(() => true, () => false))
85322
+ return;
85323
+ await import_promises29.default.rm(marker, { force: true });
85324
+ const { config: config2 } = await configManager.load();
85325
+ const parts = [];
85326
+ const copy = config2.branches?.copyFiles ?? [];
85327
+ if (copy.length > 0 && projectRoot !== void 0 && projectRoot !== workspaceRoot) {
85328
+ const result = await copySetupFiles(projectRoot, workspaceRoot, copy);
85329
+ if (result.copied.length > 0)
85330
+ parts.push(`copied ${result.copied.join(", ")} from the main checkout`);
85331
+ if (result.skipped.length > 0)
85332
+ parts.push(`not copied: ${result.skipped.join(", ")}`);
85333
+ }
85334
+ const command = config2.branches?.setupCommand?.trim();
85335
+ if (command !== void 0 && command.length > 0) {
85336
+ const label = workspaceBranch ?? import_node_path52.default.basename(workspaceRoot);
85337
+ if (ui.runInTerminal !== void 0) {
85338
+ ui.runInTerminal({ name: `Set up ${label}`, command, cwd: workspaceRoot, env: branchEnv });
85339
+ parts.push(`running "${command}" in a terminal`);
85340
+ } else {
85341
+ ui.showInfo(`Setting up branch ${label}: running "${command}"\u2026`);
85342
+ const child = new NodeTerminal(cachedCommandRules.shell).run(command, { cwd: workspaceRoot, env: branchEnv });
85343
+ let tail = "";
85344
+ child.onData((chunk) => {
85345
+ tail = (tail + chunk).slice(-2e3);
85346
+ });
85347
+ child.onExit((code) => {
85348
+ const last = tail.trim().split(/\r?\n/).slice(-5).join("\n");
85349
+ if (code === 0)
85350
+ ui.showInfo(`Branch ${label} is set up ("${command}" finished).`);
85351
+ else
85352
+ ui.showWarning(`Setting up branch ${label}: "${command}" ended with code ${String(code)}.${last.length > 0 ? `
85353
+ ${last}` : ""}`);
85354
+ });
85355
+ }
85356
+ }
85357
+ if (parts.length > 0) {
85358
+ logger.info(`branch folder setup: ${parts.join("; ")}`);
85359
+ if (ui.runInTerminal !== void 0 || copy.length > 0)
85360
+ ui.showInfo(`Setting up this branch folder: ${parts.join("; ")}.`);
85361
+ }
85362
+ } catch (error51) {
85363
+ logger.warn("branch folder setup failed", error51 instanceof Error ? error51.message : String(error51));
85364
+ }
85365
+ }
84789
85366
  function startMirrorSync() {
84790
85367
  const tick = async () => {
84791
85368
  const { config: config2 } = await configManager.load();
@@ -84830,8 +85407,8 @@ ${redact(shown2, cachedSecretValues)}` }
84830
85407
  approvalStamps.set("machine", stamp2);
84831
85408
  }
84832
85409
  for (const dir of python.toolDirectories()) {
84833
- const file2 = import_node_path51.default.join(dir, REGISTRY_FILE);
84834
- const stamp2 = await import_promises28.default.stat(file2).then((stat) => stat.mtimeMs, () => 0);
85410
+ const file2 = import_node_path52.default.join(dir, REGISTRY_FILE);
85411
+ const stamp2 = await import_promises29.default.stat(file2).then((stat) => stat.mtimeMs, () => 0);
84835
85412
  if (approvalStamps.has(file2) && approvalStamps.get(file2) !== stamp2)
84836
85413
  changed = true;
84837
85414
  approvalStamps.set(file2, stamp2);
@@ -84923,7 +85500,7 @@ ${redact(shown2, cachedSecretValues)}` }
84923
85500
  try {
84924
85501
  const available = await listSkillImages(skill.filePath, {
84925
85502
  readdir: async (dir) => {
84926
- const entries = await import_promises28.default.readdir(dir, { withFileTypes: true });
85503
+ const entries = await import_promises29.default.readdir(dir, { withFileTypes: true });
84927
85504
  return entries.map((entry) => ({ name: entry.name, isDirectory: entry.isDirectory() }));
84928
85505
  }
84929
85506
  });
@@ -84932,7 +85509,7 @@ ${redact(shown2, cachedSecretValues)}` }
84932
85509
  return;
84933
85510
  }
84934
85511
  const folder = skill.filePath.slice(0, skill.filePath.length - "SKILL.md".length);
84935
- const bytes = await import_promises28.default.readFile(import_node_path51.default.join(folder, SKILL_IMAGE_DIR, image));
85512
+ const bytes = await import_promises29.default.readFile(import_node_path52.default.join(folder, SKILL_IMAGE_DIR, image));
84936
85513
  const dataUri = skillImageDataUri(image, bytes);
84937
85514
  post({
84938
85515
  type: "skillImage",
@@ -85052,7 +85629,7 @@ ${redact(shown2, cachedSecretValues)}` }
85052
85629
  for (const skill of sending) {
85053
85630
  let body = "";
85054
85631
  try {
85055
- body = await import_promises28.default.readFile(skill.filePath, "utf8");
85632
+ body = await import_promises29.default.readFile(skill.filePath, "utf8");
85056
85633
  } catch {
85057
85634
  continue;
85058
85635
  }
@@ -85163,7 +85740,7 @@ ${redact(shown2, cachedSecretValues)}` }
85163
85740
  return { name: skill.name, state: "missing" };
85164
85741
  let body;
85165
85742
  try {
85166
- body = await import_promises28.default.readFile(skill.filePath, "utf8");
85743
+ body = await import_promises29.default.readFile(skill.filePath, "utf8");
85167
85744
  } catch {
85168
85745
  return { name: skill.name, state: "stale" };
85169
85746
  }
@@ -85259,7 +85836,7 @@ ${redact(shown2, cachedSecretValues)}` }
85259
85836
  return withoutRipgrep();
85260
85837
  try {
85261
85838
  const listed = await new Promise((resolve, reject2) => {
85262
- const child = (0, import_node_child_process14.spawn)(ripgrepPath, ["--files", "--hidden", "--glob", "!.git"], {
85839
+ const child = (0, import_node_child_process15.spawn)(ripgrepPath, ["--files", "--hidden", "--glob", "!.git"], {
85263
85840
  cwd: workspaceRoot
85264
85841
  });
85265
85842
  let out = "";
@@ -85298,17 +85875,17 @@ ${redact(shown2, cachedSecretValues)}` }
85298
85875
  }
85299
85876
  function docsFingerprintPath(index, storeId, kind) {
85300
85877
  const suffix = kind === void 0 ? "docs" : `docs.${kind}`;
85301
- return import_node_path51.default.join(manifestsRoot, "index-manifests", `${manifestKey(index, storeId)}.${suffix}.json`);
85878
+ return import_node_path52.default.join(manifestsRoot, "index-manifests", `${manifestKey(index, storeId)}.${suffix}.json`);
85302
85879
  }
85303
85880
  function manifestKey(index, storeId) {
85304
85881
  return `${index}@${storeId}`;
85305
85882
  }
85306
85883
  function manifestPath(index, storeId) {
85307
- return import_node_path51.default.join(manifestsRoot, "index-manifests", `${manifestKey(index, storeId)}.json`);
85884
+ return import_node_path52.default.join(manifestsRoot, "index-manifests", `${manifestKey(index, storeId)}.json`);
85308
85885
  }
85309
85886
  async function readDocsFingerprint(index, storeId, kind) {
85310
85887
  try {
85311
- const raw = JSON.parse(await import_promises28.default.readFile(docsFingerprintPath(index, storeId, kind), "utf8"));
85888
+ const raw = JSON.parse(await import_promises29.default.readFile(docsFingerprintPath(index, storeId, kind), "utf8"));
85312
85889
  return typeof raw.fingerprint === "string" ? raw.fingerprint : void 0;
85313
85890
  } catch {
85314
85891
  return void 0;
@@ -85368,10 +85945,10 @@ ${redact(shown2, cachedSecretValues)}` }
85368
85945
  }
85369
85946
  options.report?.("Writing", { done: 0, total: documents.length });
85370
85947
  await writer.upsert(index, documents);
85371
- await import_promises28.default.mkdir(import_node_path51.default.dirname(docsFingerprintPath(index, search.id, wanted)), {
85948
+ await import_promises29.default.mkdir(import_node_path52.default.dirname(docsFingerprintPath(index, search.id, wanted)), {
85372
85949
  recursive: true
85373
85950
  });
85374
- await import_promises28.default.writeFile(docsFingerprintPath(index, search.id, wanted), JSON.stringify({ fingerprint, indexedAt: Date.now(), count: documents.length }), "utf8");
85951
+ await import_promises29.default.writeFile(docsFingerprintPath(index, search.id, wanted), JSON.stringify({ fingerprint, indexedAt: Date.now(), count: documents.length }), "utf8");
85375
85952
  return { indexed: documents.length, index };
85376
85953
  } catch (error51) {
85377
85954
  return { error: error51 instanceof Error ? error51.message : String(error51) };
@@ -85542,7 +86119,7 @@ ${redact(shown2, cachedSecretValues)}` }
85542
86119
  }
85543
86120
  post({ type: "storeSync", running: true, fromLabel: source.label });
85544
86121
  const sourcePath = manifestPath(index, fromId);
85545
- const manifest = await import_promises28.default.readFile(sourcePath, "utf8").then((raw) => JSON.parse(raw)).catch(() => void 0);
86122
+ const manifest = await import_promises29.default.readFile(sourcePath, "utf8").then((raw) => JSON.parse(raw)).catch(() => void 0);
85546
86123
  const result = await syncVectorStores({
85547
86124
  from: createVectorIndexWriter(httpClient, source, await vectorStoreConnectionFor(source, fromId)),
85548
86125
  to: createVectorIndexWriter(httpClient, target.store, await vectorStoreConnectionFor(target.store, target.id)),
@@ -85558,8 +86135,8 @@ ${redact(shown2, cachedSecretValues)}` }
85558
86135
  });
85559
86136
  if (manifest !== void 0) {
85560
86137
  const targetPath = manifestPath(index, target.id);
85561
- await import_promises28.default.mkdir(import_node_path51.default.dirname(targetPath), { recursive: true });
85562
- await import_promises28.default.writeFile(targetPath, JSON.stringify(manifest), "utf8");
86138
+ await import_promises29.default.mkdir(import_node_path52.default.dirname(targetPath), { recursive: true });
86139
+ await import_promises29.default.writeFile(targetPath, JSON.stringify(manifest), "utf8");
85563
86140
  }
85564
86141
  post({ type: "storeSync", running: false, copied: result.copied, fromLabel: source.label });
85565
86142
  } catch (error51) {
@@ -85607,7 +86184,7 @@ ${redact(shown2, cachedSecretValues)}` }
85607
86184
  type: "project",
85608
86185
  hasWorkspace: workspaceRoot !== void 0,
85609
86186
  ...configured !== void 0 ? { configured } : {},
85610
- ...workspaceRoot !== void 0 ? { folder: import_node_path51.default.basename(workspaceRoot) } : {},
86187
+ ...workspaceRoot !== void 0 ? { folder: import_node_path52.default.basename(workspaceRoot) } : {},
85611
86188
  ...author !== void 0 ? { author } : {},
85612
86189
  ...index !== void 0 ? { indexName: index } : {},
85613
86190
  ...ownerConfigured !== void 0 && ownerConfigured.length > 0 ? { ownerConfigured } : {},
@@ -85747,11 +86324,11 @@ ${redact(shown2, cachedSecretValues)}` }
85747
86324
  if (workspaceRoot === void 0)
85748
86325
  return found2;
85749
86326
  const root = workspaceRoot;
85750
- const relative = import_node_path51.default.relative(root, folder);
85751
- if (relative.startsWith("..") || import_node_path51.default.isAbsolute(relative))
86327
+ const relative = import_node_path52.default.relative(root, folder);
86328
+ if (relative.startsWith("..") || import_node_path52.default.isAbsolute(relative))
85752
86329
  return found2;
85753
86330
  const output = await new Promise((resolve) => {
85754
- const child = (0, import_node_child_process14.spawn)("git", ["-c", "core.quotePath=false", "log", "--diff-filter=A", "--relative", "--format=@@%an", "--name-only", "--", relative.length > 0 ? relative : "."], {
86331
+ const child = (0, import_node_child_process15.spawn)("git", ["-c", "core.quotePath=false", "log", "--diff-filter=A", "--relative", "--format=@@%an", "--name-only", "--", relative.length > 0 ? relative : "."], {
85755
86332
  cwd: root,
85756
86333
  windowsHide: true
85757
86334
  });
@@ -85765,7 +86342,7 @@ ${redact(shown2, cachedSecretValues)}` }
85765
86342
  if (line.startsWith("@@"))
85766
86343
  author = line.slice(2).trim();
85767
86344
  else if (line.trim().length > 0 && author !== void 0 && author.length > 0) {
85768
- found2.set(normalizeForComparison(import_node_path51.default.resolve(root, line.trim())), author);
86345
+ found2.set(normalizeForComparison(import_node_path52.default.resolve(root, line.trim())), author);
85769
86346
  }
85770
86347
  }
85771
86348
  return found2;
@@ -85780,14 +86357,14 @@ ${redact(shown2, cachedSecretValues)}` }
85780
86357
  const toolFolders = ours([folders.toolsDir ?? localTools, localTools]);
85781
86358
  const candidates = [];
85782
86359
  const consider = async (kind, name, filePath, folder, location) => {
85783
- const source = await import_promises28.default.readFile(filePath, "utf8");
86360
+ const source = await import_promises29.default.readFile(filePath, "utf8");
85784
86361
  const missing = missingAttribution(kind, source);
85785
86362
  if (missing.length === 0)
85786
86363
  return;
85787
86364
  if (kind === "skill" && !/^---\r?\n/.test(source))
85788
86365
  return;
85789
86366
  const current = readAttribution(kind, source);
85790
- const modified = (await import_promises28.default.stat(filePath)).mtime;
86367
+ const modified = (await import_promises29.default.stat(filePath)).mtime;
85791
86368
  const automatic = {
85792
86369
  ...missing.includes("version") ? { version: 1 } : {},
85793
86370
  ...missing.includes("updated") ? { updated: attributionTimestamp(modified) } : {}
@@ -85809,7 +86386,7 @@ ${redact(shown2, cachedSecretValues)}` }
85809
86386
  },
85810
86387
  source,
85811
86388
  folder,
85812
- relative: import_node_path51.default.relative(folder, filePath).split(import_node_path51.default.sep).join("/")
86389
+ relative: import_node_path52.default.relative(folder, filePath).split(import_node_path52.default.sep).join("/")
85813
86390
  });
85814
86391
  };
85815
86392
  for (const folder of skillFolders) {
@@ -85820,14 +86397,14 @@ ${redact(shown2, cachedSecretValues)}` }
85820
86397
  }
85821
86398
  for (const folder of toolFolders) {
85822
86399
  const location = samePath(folder, localTools) ? "project" : "bucket";
85823
- const entries = await import_promises28.default.readdir(folder).catch(() => []);
86400
+ const entries = await import_promises29.default.readdir(folder).catch(() => []);
85824
86401
  for (const entry of entries) {
85825
86402
  if (entry.startsWith(".") || !entry.endsWith(".py"))
85826
86403
  continue;
85827
86404
  const name = entry.slice(0, -3);
85828
86405
  if (!isValidToolName(name))
85829
86406
  continue;
85830
- await consider("tool", name, import_node_path51.default.join(folder, entry), folder, location);
86407
+ await consider("tool", name, import_node_path52.default.join(folder, entry), folder, location);
85831
86408
  }
85832
86409
  }
85833
86410
  const readOnly = skills.filter((skill) => skill.sourceDir !== void 0 && !skillFolders.some((folder) => samePath(folder, skill.sourceDir))).length;
@@ -85859,7 +86436,7 @@ ${redact(shown2, cachedSecretValues)}` }
85859
86436
  } catch {
85860
86437
  }
85861
86438
  }
85862
- const gitAuthor = gitAuthors.get(normalizeForComparison(import_node_path51.default.resolve(candidate.entry.filePath)));
86439
+ const gitAuthor = gitAuthors.get(normalizeForComparison(import_node_path52.default.resolve(candidate.entry.filePath)));
85863
86440
  if (gitAuthor !== void 0) {
85864
86441
  candidate.entry.suggestion = { author: gitAuthor, source: "git: the commit that added this file" };
85865
86442
  }
@@ -85896,7 +86473,7 @@ ${redact(shown2, cachedSecretValues)}` }
85896
86473
  const next = fillAttribution(candidate.entry.kind, candidate.source, values);
85897
86474
  if (next === candidate.source)
85898
86475
  continue;
85899
- await import_promises28.default.writeFile(candidate.entry.filePath, next, "utf8");
86476
+ await import_promises29.default.writeFile(candidate.entry.filePath, next, "utf8");
85900
86477
  written += 1;
85901
86478
  if (candidate.entry.kind === "tool" && candidate.entry.approved === true) {
85902
86479
  await repinApproval(candidate.folder, candidate.entry.name, candidate.source, next);
@@ -85968,7 +86545,7 @@ ${redact(shown2, cachedSecretValues)}` }
85968
86545
  aliases: plan2.kind === "codebase" ? codebaseAliases(config2) : plan2.kind === "skills" ? skillAliases(config2) : [],
85969
86546
  onProgress: (count3) => post({ type: "indexRenames", running: true, plans, store, current: plan2.to, copied: count3 })
85970
86547
  });
85971
- await copyBookkeeping(import_node_path51.default.join(manifestsRoot, "index-manifests"), plan2.from, plan2.to, search.id);
86548
+ await copyBookkeeping(import_node_path52.default.join(manifestsRoot, "index-manifests"), plan2.from, plan2.to, search.id);
85972
86549
  done.push({ ...plan2, copied });
85973
86550
  }
85974
86551
  post({ type: "indexRenames", running: false, plans: [], store, done });
@@ -85981,7 +86558,7 @@ ${redact(shown2, cachedSecretValues)}` }
85981
86558
  const legacy = codebaseIndexName(config2, false);
85982
86559
  if (current === void 0 || legacy === void 0 || current === legacy)
85983
86560
  return;
85984
- const exists2 = async (file2) => import_promises28.default.stat(file2).then(() => true, () => false);
86561
+ const exists2 = async (file2) => import_promises29.default.stat(file2).then(() => true, () => false);
85985
86562
  if (await exists2(manifestPath(current, search.id)))
85986
86563
  return;
85987
86564
  if (!await exists2(manifestPath(legacy, search.id)))
@@ -85998,7 +86575,7 @@ ${redact(shown2, cachedSecretValues)}` }
85998
86575
  project: projectName(config2, workspaceRoot),
85999
86576
  aliases: codebaseAliases(config2)
86000
86577
  });
86001
- await copyBookkeeping(import_node_path51.default.join(manifestsRoot, "index-manifests"), legacy, current, search.id);
86578
+ await copyBookkeeping(import_node_path52.default.join(manifestsRoot, "index-manifests"), legacy, current, search.id);
86002
86579
  post({ type: "indexRenames", running: false, plans: [], done: [{ kind: "codebase", from: legacy, to: current, copied }] });
86003
86580
  logger.info(`copied ${String(copied)} chunks from ${legacy} to ${current} rather than re-embedding them`);
86004
86581
  }
@@ -86016,7 +86593,7 @@ ${redact(shown2, cachedSecretValues)}` }
86016
86593
  const writer = createVectorIndexWriter(httpClient, search.store, await vectorStoreConnectionFor(search.store, search.id));
86017
86594
  const paths = await writer.listPaths(index, { signal });
86018
86595
  await deleteInBatches(writer, index, paths, (done, total) => reportIndexing("codebase", "Removing", { done, total }), signal);
86019
- await import_promises28.default.rm(manifestPath(index, search.id), { force: true });
86596
+ await import_promises29.default.rm(manifestPath(index, search.id), { force: true });
86020
86597
  post({
86021
86598
  type: "indexResult",
86022
86599
  result: {
@@ -86055,7 +86632,7 @@ ${redact(shown2, cachedSecretValues)}` }
86055
86632
  const existing = kind === void 0 ? all : all.filter((id) => parseDocEntryId(id)?.kind === kind);
86056
86633
  if (existing.length > 0)
86057
86634
  await writer.deleteByPaths(index, existing);
86058
- await Promise.all([void 0, ...kind === void 0 ? ["tool", "skill"] : [kind]].map((each) => import_promises28.default.rm(docsFingerprintPath(index, search.id, each), { force: true })));
86635
+ await Promise.all([void 0, ...kind === void 0 ? ["tool", "skill"] : [kind]].map((each) => import_promises29.default.rm(docsFingerprintPath(index, search.id, each), { force: true })));
86059
86636
  post({ type: "docsIndexed", indexed: 0, index });
86060
86637
  logger.info(`cleared ${String(existing.length)} documentation entries from "${index}"`);
86061
86638
  } catch (error51) {
@@ -86164,8 +86741,8 @@ ${redact(shown2, cachedSecretValues)}` }
86164
86741
  denylist,
86165
86742
  manifest,
86166
86743
  saveManifest: async (next) => {
86167
- await import_promises28.default.mkdir(import_node_path51.default.dirname(manifestFile), { recursive: true });
86168
- await import_promises28.default.writeFile(manifestFile, JSON.stringify(next), "utf8");
86744
+ await import_promises29.default.mkdir(import_node_path52.default.dirname(manifestFile), { recursive: true });
86745
+ await import_promises29.default.writeFile(manifestFile, JSON.stringify(next), "utf8");
86169
86746
  },
86170
86747
  ...isIgnored2 !== void 0 ? { isIgnored: isIgnored2 } : {},
86171
86748
  /*
@@ -86193,7 +86770,7 @@ ${redact(shown2, cachedSecretValues)}` }
86193
86770
  }
86194
86771
  async function loadIndexManifest(file2, embedder) {
86195
86772
  try {
86196
- return JSON.parse(await import_promises28.default.readFile(file2, "utf8"));
86773
+ return JSON.parse(await import_promises29.default.readFile(file2, "utf8"));
86197
86774
  } catch {
86198
86775
  return {
86199
86776
  model: embedder.model,
@@ -86211,9 +86788,9 @@ ${redact(shown2, cachedSecretValues)}` }
86211
86788
  }
86212
86789
  const usageLog = new UsageLog(storageDir);
86213
86790
  const usageInstance = usageInstanceId(storageDir);
86214
- const usageProfileFile = import_node_path51.default.join(storageDir, "usage-profile.json");
86215
- const legacyBackfillFile = import_node_path51.default.join(storageDir, "usage-backfill.json");
86216
- const usageDir = import_node_path51.default.join(storageDir, "usage");
86791
+ const usageProfileFile = import_node_path52.default.join(storageDir, "usage-profile.json");
86792
+ const legacyBackfillFile = import_node_path52.default.join(storageDir, "usage-backfill.json");
86793
+ const usageDir = import_node_path52.default.join(storageDir, "usage");
86217
86794
  const toolStartedAt = /* @__PURE__ */ new Map();
86218
86795
  let usagePushTimer;
86219
86796
  let usagePushing;
@@ -86231,7 +86808,7 @@ ${redact(shown2, cachedSecretValues)}` }
86231
86808
  return (request) => runFastFs(exe, request);
86232
86809
  }
86233
86810
  function skillAtPath(requested2) {
86234
- const absolute = import_node_path51.default.isAbsolute(requested2) ? requested2 : workspaceRoot === void 0 ? void 0 : import_node_path51.default.resolve(workspaceRoot, requested2);
86811
+ const absolute = import_node_path52.default.isAbsolute(requested2) ? requested2 : workspaceRoot === void 0 ? void 0 : import_node_path52.default.resolve(workspaceRoot, requested2);
86235
86812
  if (absolute === void 0)
86236
86813
  return void 0;
86237
86814
  return skills.find((skill) => samePath(skill.filePath, absolute));
@@ -86304,7 +86881,7 @@ ${redact(shown2, cachedSecretValues)}` }
86304
86881
  const folder = chosen.path?.trim();
86305
86882
  if (folder === void 0 || folder.length === 0)
86306
86883
  return { problem: "The shared folder has no path." };
86307
- if (!import_node_path51.default.isAbsolute(folder))
86884
+ if (!import_node_path52.default.isAbsolute(folder))
86308
86885
  return { problem: `"${folder}" is not an absolute path. Use the full path of a folder everybody can reach, such as a network share.` };
86309
86886
  const helper = usageHelper();
86310
86887
  return { store: new FolderShardStore(folder, ...helper !== void 0 ? [helper] : []), target };
@@ -86333,7 +86910,7 @@ ${redact(shown2, cachedSecretValues)}` }
86333
86910
  }
86334
86911
  async function readUsageBackfill() {
86335
86912
  try {
86336
- const text2 = await import_promises28.default.readFile(import_node_path51.default.join(usageDir, "backfill.json"), "utf8").catch(() => import_promises28.default.readFile(legacyBackfillFile, "utf8"));
86913
+ const text2 = await import_promises29.default.readFile(import_node_path52.default.join(usageDir, "backfill.json"), "utf8").catch(() => import_promises29.default.readFile(legacyBackfillFile, "utf8"));
86337
86914
  const saved = JSON.parse(text2);
86338
86915
  if (typeof saved.at !== "number")
86339
86916
  return void 0;
@@ -86349,7 +86926,7 @@ ${redact(shown2, cachedSecretValues)}` }
86349
86926
  legacyDoneFile: legacyBackfillFile,
86350
86927
  run: async (before) => {
86351
86928
  const status2 = python.status();
86352
- return backfillFromTasks(import_node_path51.default.join(storageDir, "tasks"), {
86929
+ return backfillFromTasks(import_node_path52.default.join(storageDir, "tasks"), {
86353
86930
  user: cachedAttribution.author ?? "unknown",
86354
86931
  project: cachedAttribution.project,
86355
86932
  workspaceRoot,
@@ -86409,7 +86986,7 @@ ${redact(shown2, cachedSecretValues)}` }
86409
86986
  }
86410
86987
  async function readLocalProfile() {
86411
86988
  try {
86412
- const saved = JSON.parse(await import_promises28.default.readFile(usageProfileFile, "utf8"));
86989
+ const saved = JSON.parse(await import_promises29.default.readFile(usageProfileFile, "utf8"));
86413
86990
  return saved.user === (cachedAttribution.author ?? "unknown") ? cleanProfile(saved.profile) : void 0;
86414
86991
  } catch {
86415
86992
  return void 0;
@@ -86445,7 +87022,7 @@ ${redact(shown2, cachedSecretValues)}` }
86445
87022
  });
86446
87023
  async function contentHash2(file2) {
86447
87024
  try {
86448
- const text2 = (await import_promises28.default.readFile(file2, "utf8")).replace(/\r\n/g, "\n");
87025
+ const text2 = (await import_promises29.default.readFile(file2, "utf8")).replace(/\r\n/g, "\n");
86449
87026
  const meaningful = text2.split("\n").filter((line) => !/^(author|project|version|updated)\s*:/i.test(line) && !/^__(author|project|version|updated)__\s*=/.test(line)).join("\n").trim();
86450
87027
  return (0, import_node_crypto16.createHash)("sha256").update(meaningful).digest("hex").slice(0, 16);
86451
87028
  } catch {
@@ -86522,18 +87099,18 @@ ${redact(shown2, cachedSecretValues)}` }
86522
87099
  kind: "tool",
86523
87100
  name: issue2.name,
86524
87101
  filePath: issue2.filePath,
86525
- deletable: samePath(import_node_path51.default.dirname(issue2.filePath), status2.toolsDir),
86526
- location: where(import_node_path51.default.dirname(issue2.filePath), status2.toolsDir),
87102
+ deletable: samePath(import_node_path52.default.dirname(issue2.filePath), status2.toolsDir),
87103
+ location: where(import_node_path52.default.dirname(issue2.filePath), status2.toolsDir),
86527
87104
  issue: issue2.kind === "unapproved" ? "waiting for approval" : issue2.kind === "hash-mismatch" ? "changed since approval" : issue2.detail.split("\n")[0] ?? "not loaded"
86528
87105
  });
86529
87106
  }
86530
87107
  return items;
86531
87108
  }
86532
- const usageDirectoryFile = import_node_path51.default.join(storageDir, "usage-directory.json");
87109
+ const usageDirectoryFile = import_node_path52.default.join(storageDir, "usage-directory.json");
86533
87110
  let directoryRunning;
86534
87111
  async function readDirectoryCache() {
86535
87112
  try {
86536
- const saved = JSON.parse(await import_promises28.default.readFile(usageDirectoryFile, "utf8"));
87113
+ const saved = JSON.parse(await import_promises29.default.readFile(usageDirectoryFile, "utf8"));
86537
87114
  return { ...saved, people: saved.people ?? {} };
86538
87115
  } catch {
86539
87116
  return { people: {} };
@@ -86864,7 +87441,7 @@ ${redact(shown2, cachedSecretValues)}` }
86864
87441
  let indexedFiles = 0;
86865
87442
  if (index !== void 0) {
86866
87443
  try {
86867
- const manifest = JSON.parse(await import_promises28.default.readFile(import_node_path51.default.join(manifestsRoot, "index-manifests", `${index}.json`), "utf8"));
87444
+ const manifest = JSON.parse(await import_promises29.default.readFile(import_node_path52.default.join(manifestsRoot, "index-manifests", `${index}.json`), "utf8"));
86868
87445
  indexedFiles = Object.keys(manifest.files ?? {}).length;
86869
87446
  } catch {
86870
87447
  }
@@ -87314,7 +87891,7 @@ ${redact(shown2, cachedSecretValues)}` }
87314
87891
  const source = await ui.showOpenDialog({ kind: "file", extensions: ["json"] });
87315
87892
  if (source === void 0)
87316
87893
  return;
87317
- const imported = parseConfig(await import_promises28.default.readFile(source, "utf8"));
87894
+ const imported = parseConfig(await import_promises29.default.readFile(source, "utf8"));
87318
87895
  post({
87319
87896
  type: "shareSections",
87320
87897
  direction: "import",
@@ -87339,18 +87916,18 @@ ${redact(shown2, cachedSecretValues)}` }
87339
87916
  answer({ error: bytes.length === 0 ? "There was nothing to save." : "That file is too large to save from here." });
87340
87917
  return;
87341
87918
  }
87342
- const safeName = [...import_node_path51.default.basename(name)].map((c2) => c2.charCodeAt(0) < 32 || '<>:"/\\|?*'.includes(c2) ? "-" : c2).join("") || "file";
87343
- const extension = import_node_path51.default.extname(safeName).slice(1);
87919
+ const safeName = [...import_node_path52.default.basename(name)].map((c2) => c2.charCodeAt(0) < 32 || '<>:"/\\|?*'.includes(c2) ? "-" : c2).join("") || "file";
87920
+ const extension = import_node_path52.default.extname(safeName).slice(1);
87344
87921
  try {
87345
87922
  const target = await ui.showSaveDialog({
87346
- defaultName: workspaceRoot !== void 0 ? import_node_path51.default.join(workspaceRoot, safeName) : safeName,
87923
+ defaultName: workspaceRoot !== void 0 ? import_node_path52.default.join(workspaceRoot, safeName) : safeName,
87347
87924
  ...extension.length > 0 ? { extensions: [extension] } : {}
87348
87925
  });
87349
87926
  if (target === void 0) {
87350
87927
  answer({});
87351
87928
  return;
87352
87929
  }
87353
- await import_promises28.default.writeFile(target, bytes);
87930
+ await import_promises29.default.writeFile(target, bytes);
87354
87931
  answer({ path: target });
87355
87932
  } catch (error51) {
87356
87933
  answer({ error: `Could not save it: ${error51 instanceof Error ? error51.message : String(error51)}` });
@@ -87361,7 +87938,7 @@ ${redact(shown2, cachedSecretValues)}` }
87361
87938
  if (archive === void 0)
87362
87939
  return;
87363
87940
  try {
87364
- await import_promises28.default.access(archive.path);
87941
+ await import_promises29.default.access(archive.path);
87365
87942
  } catch {
87366
87943
  post({
87367
87944
  type: "error",
@@ -87373,7 +87950,7 @@ ${redact(shown2, cachedSecretValues)}` }
87373
87950
  const target = await ui.showSaveDialog({ defaultName: archive.defaultName, extensions: ["zip"] });
87374
87951
  if (target === void 0)
87375
87952
  return;
87376
- await import_promises28.default.copyFile(archive.path, target);
87953
+ await import_promises29.default.copyFile(archive.path, target);
87377
87954
  ui.showInfo(`Saved the Light Code source to ${target}. Extract it, open the folder in VS Code, and follow START_HERE.md \u2014 it builds as it stands.`);
87378
87955
  } catch (error51) {
87379
87956
  post({ type: "error", message: `Could not save the source: ${error51 instanceof Error ? error51.message : String(error51)}` });
@@ -87390,7 +87967,7 @@ ${redact(shown2, cachedSecretValues)}` }
87390
87967
  });
87391
87968
  if (target === void 0)
87392
87969
  return;
87393
- await import_promises28.default.writeFile(target, JSON.stringify(exported, null, 2), "utf8");
87970
+ await import_promises29.default.writeFile(target, JSON.stringify(exported, null, 2), "utf8");
87394
87971
  const written = describeSections(exported).filter((section) => section.present);
87395
87972
  const needed = written.flatMap((section) => section.secretRefs);
87396
87973
  ui.showInfo(needed.length === 0 ? `Exported ${String(written.length)} section(s) to ${target}.` : `Exported ${String(written.length)} section(s) to ${target}. Whoever imports it will need to enter: ${needed.join(", ")}.`);
@@ -87403,7 +87980,7 @@ ${redact(shown2, cachedSecretValues)}` }
87403
87980
  const source = request.path ?? await ui.showOpenDialog({ kind: "file", extensions: ["json"] });
87404
87981
  if (source === void 0)
87405
87982
  return;
87406
- const raw = await import_promises28.default.readFile(source, "utf8");
87983
+ const raw = await import_promises29.default.readFile(source, "utf8");
87407
87984
  const imported = parseConfig(raw);
87408
87985
  const chosen = request.sections ?? SHARE_SECTIONS.map((section) => section.id);
87409
87986
  const { config: existing } = await configManager.load();
@@ -87457,7 +88034,7 @@ ${redact(shown2, cachedSecretValues)}` }
87457
88034
  if (changeLedger !== void 0) {
87458
88035
  const shared = await changeLedger.othersSince(targets, taskCheckpoint.createdAt);
87459
88036
  if (shared.size > 0) {
87460
- const shown2 = (file2) => import_node_path51.default.relative(workspaceRoot ?? "", file2).split(import_node_path51.default.sep).join("/");
88037
+ const shown2 = (file2) => import_node_path52.default.relative(workspaceRoot ?? "", file2).split(import_node_path52.default.sep).join("/");
87461
88038
  const detail = [...shared].map(([file2, chats]) => `${shown2(file2)} (${chats.join(", ")})`).join("; ");
87462
88039
  const all = await ui.showActionMessage(`Another chat also changed ${String(shared.size)} of these files after this chat started: ${detail}. Rolling them back would undo that chat's changes too.`, "Roll those back too", "warning");
87463
88040
  if (!all) {
@@ -87628,7 +88205,7 @@ ${redact(shown2, cachedSecretValues)}` }
87628
88205
  post({
87629
88206
  type: "projectSettings",
87630
88207
  workspaceOpen: workspaceRoot !== void 0,
87631
- overridden: describeOverrides(overridesFor(stored, workspaceRoot))
88208
+ overridden: describeOverrides(overridesFor(stored, projectRoot))
87632
88209
  });
87633
88210
  } catch (error51) {
87634
88211
  logger.warn(`could not read this project's settings: ${String(error51)}`);
@@ -87655,7 +88232,7 @@ ${redact(shown2, cachedSecretValues)}` }
87655
88232
  const pathRequest = pendingPathApprovals.get(id);
87656
88233
  userGate.resolve(id, "approve");
87657
88234
  if (pathRequest !== void 0) {
87658
- const folder = import_node_path51.default.dirname(pathRequest);
88235
+ const folder = import_node_path52.default.dirname(pathRequest);
87659
88236
  sessionPathGrants.add(normalizeForComparison(pathRequest));
87660
88237
  if (scope === "folder" && !cachedReadRoots.includes(folder)) {
87661
88238
  const { config: config2 } = await configManager.load();
@@ -87856,7 +88433,7 @@ ${redact(shown2, cachedSecretValues)}` }
87856
88433
  async function handleProbePythonEnv(venvDir, script) {
87857
88434
  const exists2 = async (candidate) => {
87858
88435
  try {
87859
- return (await import_promises28.default.stat(candidate)).isFile();
88436
+ return (await import_promises29.default.stat(candidate)).isFile();
87860
88437
  } catch {
87861
88438
  return false;
87862
88439
  }
@@ -87895,10 +88472,10 @@ ${redact(shown2, cachedSecretValues)}` }
87895
88472
  });
87896
88473
  return;
87897
88474
  }
87898
- let dir = import_node_path51.default.dirname(import_node_path51.default.resolve(scriptPath));
88475
+ let dir = import_node_path52.default.dirname(import_node_path52.default.resolve(scriptPath));
87899
88476
  for (let depth = 0; depth < 3; depth++) {
87900
88477
  for (const name of VENV_DIR_NAMES) {
87901
- const candidate = import_node_path51.default.join(dir, name);
88478
+ const candidate = import_node_path52.default.join(dir, name);
87902
88479
  const found2 = await search(candidate);
87903
88480
  if (found2 !== void 0) {
87904
88481
  post({
@@ -87910,7 +88487,7 @@ ${redact(shown2, cachedSecretValues)}` }
87910
88487
  return;
87911
88488
  }
87912
88489
  }
87913
- const parent = import_node_path51.default.dirname(dir);
88490
+ const parent = import_node_path52.default.dirname(dir);
87914
88491
  if (parent === dir)
87915
88492
  break;
87916
88493
  dir = parent;
@@ -88790,12 +89367,12 @@ Could not be drawn: ${entry.message}`);
88790
89367
  let lastReportPath;
88791
89368
  async function saveReport(title, contents) {
88792
89369
  try {
88793
- const directory = import_node_path51.default.join(storageDir, "reports");
88794
- await import_promises28.default.mkdir(directory, { recursive: true });
89370
+ const directory = import_node_path52.default.join(storageDir, "reports");
89371
+ await import_promises29.default.mkdir(directory, { recursive: true });
88795
89372
  const stamp2 = (/* @__PURE__ */ new Date()).toISOString().replace(/[:.]/g, "-");
88796
89373
  const slug = title.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "").slice(0, 60);
88797
- const target = import_node_path51.default.join(directory, `${stamp2}${slug.length > 0 ? `-${slug}` : ""}.md`);
88798
- await import_promises28.default.writeFile(target, `# ${title}
89374
+ const target = import_node_path52.default.join(directory, `${stamp2}${slug.length > 0 ? `-${slug}` : ""}.md`);
89375
+ await import_promises29.default.writeFile(target, `# ${title}
88799
89376
 
88800
89377
  ${contents}
88801
89378
  `, "utf8");
@@ -88808,9 +89385,9 @@ ${contents}
88808
89385
  }
88809
89386
  async function pruneReports(directory) {
88810
89387
  const keep = 100;
88811
- const entries = (await import_promises28.default.readdir(directory)).filter((name) => name.endsWith(".md")).sort();
89388
+ const entries = (await import_promises29.default.readdir(directory)).filter((name) => name.endsWith(".md")).sort();
88812
89389
  for (const name of entries.slice(0, Math.max(0, entries.length - keep))) {
88813
- await import_promises28.default.rm(import_node_path51.default.join(directory, name), { force: true });
89390
+ await import_promises29.default.rm(import_node_path52.default.join(directory, name), { force: true });
88814
89391
  }
88815
89392
  }
88816
89393
  let scheduleTimer;
@@ -88923,11 +89500,11 @@ ${contents}
88923
89500
  }
88924
89501
  const CLAIM_STALE_MS = 60 * 60 * 1e3;
88925
89502
  async function claimSchedule(id) {
88926
- const claimPath = import_node_path51.default.join(storageDir, "schedule-claims", `${id}.json`);
89503
+ const claimPath = import_node_path52.default.join(storageDir, "schedule-claims", `${id}.json`);
88927
89504
  const mine = JSON.stringify({ pid: process.pid, at: Date.now() });
88928
89505
  try {
88929
- await import_promises28.default.mkdir(import_node_path51.default.dirname(claimPath), { recursive: true });
88930
- await import_promises28.default.writeFile(claimPath, mine, { encoding: "utf8", flag: "wx" });
89506
+ await import_promises29.default.mkdir(import_node_path52.default.dirname(claimPath), { recursive: true });
89507
+ await import_promises29.default.writeFile(claimPath, mine, { encoding: "utf8", flag: "wx" });
88931
89508
  return true;
88932
89509
  } catch (error51) {
88933
89510
  if (error51.code !== "EEXIST") {
@@ -88936,22 +89513,22 @@ ${contents}
88936
89513
  }
88937
89514
  }
88938
89515
  try {
88939
- const held = JSON.parse(await import_promises28.default.readFile(claimPath, "utf8"));
89516
+ const held = JSON.parse(await import_promises29.default.readFile(claimPath, "utf8"));
88940
89517
  const at = typeof held.at === "number" ? held.at : 0;
88941
89518
  if (Date.now() - at < CLAIM_STALE_MS) {
88942
89519
  logger.info(`schedule ${id} is already running in another window`);
88943
89520
  return false;
88944
89521
  }
88945
89522
  logger.warn(`taking over a stale claim on schedule ${id}`);
88946
- await import_promises28.default.writeFile(claimPath, mine, "utf8");
89523
+ await import_promises29.default.writeFile(claimPath, mine, "utf8");
88947
89524
  return true;
88948
89525
  } catch {
88949
- await import_promises28.default.writeFile(claimPath, mine, "utf8").catch(() => void 0);
89526
+ await import_promises29.default.writeFile(claimPath, mine, "utf8").catch(() => void 0);
88950
89527
  return true;
88951
89528
  }
88952
89529
  }
88953
89530
  async function releaseSchedule(id) {
88954
- await import_promises28.default.rm(import_node_path51.default.join(storageDir, "schedule-claims", `${id}.json`), { force: true }).catch(() => void 0);
89531
+ await import_promises29.default.rm(import_node_path52.default.join(storageDir, "schedule-claims", `${id}.json`), { force: true }).catch(() => void 0);
88955
89532
  }
88956
89533
  async function runSchedule(id, reason) {
88957
89534
  if (reason === "due" && !await claimSchedule(id))
@@ -89206,6 +89783,7 @@ ${contents}
89206
89783
  if (services.runsSchedules !== false)
89207
89784
  startScheduleTimer();
89208
89785
  startMirrorSync();
89786
+ void prepareBranchFolder();
89209
89787
  startApprovalWatch();
89210
89788
  startHubSync();
89211
89789
  return {
@@ -89620,12 +90198,12 @@ function createShowDiagramTool() {
89620
90198
  }
89621
90199
 
89622
90200
  // ../../packages/core/dist/lsp/manager.js
89623
- var import_promises29 = __toESM(require("node:fs/promises"), 1);
89624
- var import_node_path53 = __toESM(require("node:path"), 1);
90201
+ var import_promises30 = __toESM(require("node:fs/promises"), 1);
90202
+ var import_node_path54 = __toESM(require("node:path"), 1);
89625
90203
 
89626
90204
  // ../../packages/core/dist/lsp/catalog.js
89627
- var import_node_fs12 = require("node:fs");
89628
- var import_node_path52 = __toESM(require("node:path"), 1);
90205
+ var import_node_fs13 = require("node:fs");
90206
+ var import_node_path53 = __toESM(require("node:path"), 1);
89629
90207
  var c = (command, ...args) => ({ command, args });
89630
90208
  var LSP_LANGUAGES = [
89631
90209
  { id: "python", label: "Python", extensions: ["py", "pyi"], candidates: [c("pyright-langserver", "--stdio"), c("basedpyright-langserver", "--stdio"), c("pylsp"), c("jedi-language-server")] },
@@ -89673,17 +90251,17 @@ var LSP_LANGUAGES = [
89673
90251
  { id: "sql", label: "SQL", extensions: ["sql"], candidates: [c("sql-language-server", "up", "--method", "stdio")] }
89674
90252
  ];
89675
90253
  function languageFor(file2) {
89676
- const ext = import_node_path52.default.extname(file2).slice(1).toLowerCase();
90254
+ const ext = import_node_path53.default.extname(file2).slice(1).toLowerCase();
89677
90255
  return LSP_LANGUAGES.find((l) => l.extensions.includes(ext));
89678
90256
  }
89679
90257
  function languageIdFor(language, file2) {
89680
- const ext = import_node_path52.default.extname(file2).slice(1).toLowerCase();
90258
+ const ext = import_node_path53.default.extname(file2).slice(1).toLowerCase();
89681
90259
  return language.languageIdFor?.(ext) ?? language.id;
89682
90260
  }
89683
90261
  var found = /* @__PURE__ */ new Map();
89684
90262
  function findOnPath(command, env2 = process.env) {
89685
- if (import_node_path52.default.isAbsolute(command))
89686
- return (0, import_node_fs12.existsSync)(command) ? command : void 0;
90263
+ if (import_node_path53.default.isAbsolute(command))
90264
+ return (0, import_node_fs13.existsSync)(command) ? command : void 0;
89687
90265
  if (env2 !== process.env)
89688
90266
  return searchPath(command, env2);
89689
90267
  const hit = found.get(command);
@@ -89694,12 +90272,12 @@ function findOnPath(command, env2 = process.env) {
89694
90272
  return value;
89695
90273
  }
89696
90274
  function searchPath(command, env2) {
89697
- const dirs = (env2.PATH ?? env2.Path ?? "").split(import_node_path52.default.delimiter).filter((d) => d.length > 0);
90275
+ const dirs = (env2.PATH ?? env2.Path ?? "").split(import_node_path53.default.delimiter).filter((d) => d.length > 0);
89698
90276
  const exts = process.platform === "win32" ? ["", ...(env2.PATHEXT ?? ".EXE;.CMD;.BAT").toLowerCase().split(";")] : [""];
89699
90277
  for (const dir of dirs) {
89700
90278
  for (const ext of exts) {
89701
- const candidate = import_node_path52.default.join(dir, command + ext);
89702
- if ((0, import_node_fs12.existsSync)(candidate) && (process.platform !== "win32" || ext !== "" || /\.(exe|cmd|bat)$/i.test(candidate)))
90279
+ const candidate = import_node_path53.default.join(dir, command + ext);
90280
+ if ((0, import_node_fs13.existsSync)(candidate) && (process.platform !== "win32" || ext !== "" || /\.(exe|cmd|bat)$/i.test(candidate)))
89703
90281
  return candidate;
89704
90282
  }
89705
90283
  }
@@ -89707,7 +90285,7 @@ function searchPath(command, env2) {
89707
90285
  }
89708
90286
 
89709
90287
  // ../../packages/core/dist/lsp/client.js
89710
- var import_node_child_process15 = require("node:child_process");
90288
+ var import_node_child_process16 = require("node:child_process");
89711
90289
  var import_node_url = require("node:url");
89712
90290
  function keyFor(uri) {
89713
90291
  try {
@@ -89737,7 +90315,7 @@ var LspClient = class {
89737
90315
  this.root = root;
89738
90316
  this.log = log;
89739
90317
  const shim = /\.(cmd|bat)$/i.test(executable);
89740
- this.child = shim ? (0, import_node_child_process15.spawn)(process.env.ComSpec ?? "cmd.exe", ["/d", "/s", "/c", `"${executable}"`, ...args], { cwd: root, windowsHide: true, windowsVerbatimArguments: true }) : (0, import_node_child_process15.spawn)(executable, args, { cwd: root, windowsHide: true });
90318
+ this.child = shim ? (0, import_node_child_process16.spawn)(process.env.ComSpec ?? "cmd.exe", ["/d", "/s", "/c", `"${executable}"`, ...args], { cwd: root, windowsHide: true, windowsVerbatimArguments: true }) : (0, import_node_child_process16.spawn)(executable, args, { cwd: root, windowsHide: true });
89741
90319
  this.child.stdout?.on("data", (chunk) => this.onData(chunk));
89742
90320
  this.child.stderr?.on("data", (chunk) => {
89743
90321
  const text2 = chunk.toString("utf8").trim();
@@ -89930,7 +90508,7 @@ var LspManager = class {
89930
90508
  return void 0;
89931
90509
  const args = [...found2.candidate.args];
89932
90510
  if (language.id === "java" && !args.includes("-data"))
89933
- args.push("-data", import_node_path53.default.join(this.storageDir, "jdtls-workspace"));
90511
+ args.push("-data", import_node_path54.default.join(this.storageDir, "jdtls-workspace"));
89934
90512
  try {
89935
90513
  client = new LspClient(found2.executable, args, this.root, this.log);
89936
90514
  this.clients.set(language.id, client);
@@ -89941,7 +90519,7 @@ var LspManager = class {
89941
90519
  }
89942
90520
  let text2;
89943
90521
  try {
89944
- text2 = await import_promises29.default.readFile(file2, "utf8");
90522
+ text2 = await import_promises30.default.readFile(file2, "utf8");
89945
90523
  } catch {
89946
90524
  return void 0;
89947
90525
  }
@@ -89951,7 +90529,7 @@ var LspManager = class {
89951
90529
  this.failed.set(language.id, client.lastError ?? "stopped");
89952
90530
  return void 0;
89953
90531
  }
89954
- return { server: import_node_path53.default.basename(client.executable).replace(/\.(exe|cmd|bat)$/i, ""), diagnostics: diagnostics ?? [] };
90532
+ return { server: import_node_path54.default.basename(client.executable).replace(/\.(exe|cmd|bat)$/i, ""), diagnostics: diagnostics ?? [] };
89955
90533
  } catch (error51) {
89956
90534
  this.failed.set(language.id, error51 instanceof Error ? error51.message : String(error51));
89957
90535
  client.dispose();
@@ -91229,7 +91807,16 @@ comment or move fails after the fields were saved, the result says exactly which
91229
91807
  "queue",
91230
91808
  "agent offline",
91231
91809
  "api token",
91232
- "sso"
91810
+ "sso",
91811
+ "create job",
91812
+ "new job",
91813
+ "clone job",
91814
+ "copy job",
91815
+ "modify job",
91816
+ "job parameters",
91817
+ "add parameter",
91818
+ "job config",
91819
+ "config.xml"
91233
91820
  ],
91234
91821
  body: `
91235
91822
  **Settings \u2192 DevOps \u2192 Jenkins**: the site address, an **API token**, your **Jenkins user id**, and
@@ -91266,7 +91853,15 @@ an access token as a Bearer token, leave the user id empty and paste that token
91266
91853
  end of its log. Needs a pipeline job that has run at least once and the Replay permission. Run
91267
91854
  \`jenkins_check_jenkinsfile\` first; it is instant and catches syntax and unknown steps.
91268
91855
 
91269
- There is no tool that changes a job's configuration.
91856
+ - \`jenkins_write_job\` \u2014 **create a job, copy one into a new job, or change a job**. "A job like
91857
+ platform/api but with a HOTFIX branch parameter" is a copy with new parameters. Parameters are set by
91858
+ name, type (string, text, boolean, choice), default, description and choices, or removed; anything
91859
+ else (script path, branch, schedule, agent label) is an exact edit of the job's config.xml. The
91860
+ approval shows the diff of the configuration Jenkins will be sent - against the job copied, or the job
91861
+ as Jenkins holds it now - and it **cannot be set to always allow**. It never deletes a job, never
91862
+ creates or copies over an existing one, and refuses to save if the job was edited on Jenkins after
91863
+ you were shown the change. Ticking **My access is read-only** removes it with the other acting tools.
91864
+ Needs the Job/Create or Job/Configure permission on your Jenkins.
91270
91865
  `
91271
91866
  },
91272
91867
  {
@@ -91562,6 +92157,66 @@ together.
91562
92157
 
91563
92158
  Problems from syncing in the background (the repository, buckets, tools that did not load) show in
91564
92159
  **Settings \u2192 Usage \u2192 Needs attention**.
92160
+ `
92161
+ },
92162
+ {
92163
+ id: "branches",
92164
+ title: "Several branches at once, side by side",
92165
+ keywords: [
92166
+ "branch",
92167
+ "branches",
92168
+ "worktree",
92169
+ "git worktree",
92170
+ "different branches",
92171
+ "another branch",
92172
+ "switch branch",
92173
+ "work on two branches",
92174
+ "parallel branches",
92175
+ "branch folder",
92176
+ "new chat on a branch",
92177
+ "open branch",
92178
+ "close branch",
92179
+ "run and debug a branch",
92180
+ "port offset",
92181
+ "setup command",
92182
+ "pnpm install in branch"
92183
+ ],
92184
+ body: `
92185
+ Work on several branches of one repository at the same time, each in its own folder - git worktrees, part of
92186
+ git since 2015. You clone once; opening a branch makes a folder for it beside the repository
92187
+ (<repo>.worktrees\\\\<branch>, or under config:branches (folder)), sharing the repository's history. Nothing is
92188
+ downloaded again, your codebase stays on its own branch, and a commit in any branch folder is in the one
92189
+ repository straight away.
92190
+
92191
+ **VS Code**: Light Code: Open Branch in New Window (Command Palette, or the branch button in Source Control)
92192
+ lists local branches, fetched remote branches and those already open, plus New branch\u2026 (made from the branch
92193
+ you choose). The branch opens in a new VS Code window - running, debugging and terminals there use that
92194
+ branch's files and its own launch.json, with its own Light Code. Light Code: Branches lists every branch folder
92195
+ with its state (clean, uncommitted changes, commits not pushed) to open it or close it.
92196
+
92197
+ **Fire Code**: New chat on a branch\u2026 (the tab's or New chat's menu) opens the branch as a chat tab working in
92198
+ its own folder. Each tab shows its chat name with the branch underneath (trimmed when long - a Jira key is kept
92199
+ whole - full name on hover); renaming the chat never changes the branch. Close branch\u2026 (right-click a branch
92200
+ chat's tab) removes its folder and the chat. Fire Code's Commit and push acts on the codebase's own folder; in
92201
+ a branch chat, commit through the agent or git in that folder.
92202
+
92203
+ **Setting a branch up** (once, when its folder is first opened): config:branches (copyFiles) - files git does
92204
+ not track that it needs, such as .env, copied from the main checkout - and config:branches (setupCommand),
92205
+ e.g. pnpm install or uv sync (VS Code runs it in a terminal you can watch). Each branch folder has its own
92206
+ node_modules or .venv, because a shared one breaks as soon as branches differ. Per project; user-scope only
92207
+ (a repository cannot set a command for you), and never exported.
92208
+
92209
+ **Running two at once**: commands and debug sessions in a branch folder get LIGHT_CODE_BRANCH and
92210
+ LIGHT_CODE_PORT_OFFSET (0 in the main checkout, 1, 2... in branch folders), so a dev server can add the
92211
+ offset to its port. Nothing is written into your repository for this.
92212
+
92213
+ **Shared or separate**: codebase instructions, skills, settings and "always allow" approvals are shared by all
92214
+ of a repository's branches; checkpoints and rollback, chat history and running processes are each folder's own.
92215
+ The agent in a branch folder can only change files in that folder.
92216
+
92217
+ **Safe by git's own rules**: one branch can be open in only one folder at a time; closing a folder checks for
92218
+ uncommitted changes and unpushed commits first and never deletes the branch; folders stay until you close them
92219
+ (not temporary). If you delete one by hand, git forgets it (git worktree prune) and committed work is safe.
91565
92220
  `
91566
92221
  },
91567
92222
  {
@@ -93503,8 +94158,8 @@ function createLightCodeHelpTool() {
93503
94158
  }
93504
94159
 
93505
94160
  // ../../packages/core/dist/tools/listFiles.js
93506
- var import_node_child_process16 = require("node:child_process");
93507
- var import_node_path54 = __toESM(require("node:path"), 1);
94161
+ var import_node_child_process17 = require("node:child_process");
94162
+ var import_node_path55 = __toESM(require("node:path"), 1);
93508
94163
 
93509
94164
  // ../../packages/core/dist/tools/ripgrepError.js
93510
94165
  function ripgrepDidNotStart(error51) {
@@ -93537,7 +94192,7 @@ function isRipgrepNoMatchError(error51) {
93537
94192
  }
93538
94193
  function runRipgrepFiles(rgPath, dir, signal, includeIgnored) {
93539
94194
  return new Promise((resolve, reject2) => {
93540
- (0, import_node_child_process16.execFile)(rgPath, [
94195
+ (0, import_node_child_process17.execFile)(rgPath, [
93541
94196
  "--files",
93542
94197
  "--hidden",
93543
94198
  ...includeIgnored ? ["--no-ignore-vcs"] : [],
@@ -93585,7 +94240,7 @@ var listFilesTool = {
93585
94240
  });
93586
94241
  if (files.length === 0)
93587
94242
  return noFiles;
93588
- const listed = files.map((file2) => file2.split("/").join(import_node_path54.default.sep)).join("\n");
94243
+ const listed = files.map((file2) => file2.split("/").join(import_node_path55.default.sep)).join("\n");
93589
94244
  return { content: truncated ? `${listed}
93590
94245
  (listing cut short \u2014 list a narrower folder)` : listed };
93591
94246
  }
@@ -93653,10 +94308,10 @@ function readSmall(raw, params3) {
93653
94308
  const end = params3.limit !== void 0 ? start + params3.limit : lines2.length;
93654
94309
  return number4(lines2.slice(start, end), start + 1);
93655
94310
  }
93656
- async function readLarge(fs42, realPath, params3, size) {
94311
+ async function readLarge(fs43, realPath, params3, size) {
93657
94312
  const human = formatBytes(size);
93658
94313
  if (params3.tail !== void 0) {
93659
- const part = await readTail(fs42, realPath, size, params3.tail);
94314
+ const part = await readTail(fs43, realPath, size, params3.tail);
93660
94315
  return [
93661
94316
  `${human} file \u2014 last ${String(part.lines.length)} lines.`,
93662
94317
  /*
@@ -93671,7 +94326,7 @@ async function readLarge(fs42, realPath, params3, size) {
93671
94326
  }
93672
94327
  if (params3.offset !== void 0) {
93673
94328
  const limit = params3.limit ?? DEFAULT_LARGE_LIMIT;
93674
- const part = await readLineWindow(fs42, realPath, size, params3.offset, limit);
94329
+ const part = await readLineWindow(fs43, realPath, size, params3.offset, limit);
93675
94330
  const shown2 = part.lines.length;
93676
94331
  return [
93677
94332
  `${human} file \u2014 lines ${String(params3.offset)}\u2013${String(params3.offset + shown2 - 1)}${part.hasMoreAfter ? ", more follows" : " (end of file)"}.`,
@@ -93679,7 +94334,7 @@ async function readLarge(fs42, realPath, params3, size) {
93679
94334
  number4(part.lines, params3.offset)
93680
94335
  ].join("\n");
93681
94336
  }
93682
- const total = await countLines(fs42, realPath, size);
94337
+ const total = await countLines(fs43, realPath, size);
93683
94338
  return [
93684
94339
  `${realPathName(realPath)} is ${human} (${total.toLocaleString()} lines) \u2014 too large to read at once.`,
93685
94340
  "",
@@ -93747,7 +94402,7 @@ var readDocumentTool = {
93747
94402
  };
93748
94403
 
93749
94404
  // ../../packages/core/dist/tools/searchFiles.js
93750
- var import_node_child_process17 = require("node:child_process");
94405
+ var import_node_child_process18 = require("node:child_process");
93751
94406
  var paramsSchema22 = external_exports.object({
93752
94407
  path: external_exports.string().min(1).default(".").describe("Directory to search, relative to the workspace root."),
93753
94408
  pattern: external_exports.string().min(1).describe("Regular expression to search for."),
@@ -93766,7 +94421,7 @@ function runRipgrepSearch(rgPath, dir, pattern, filePattern, signal, includeIgno
93766
94421
  args.push("-g", filePattern);
93767
94422
  args.push("--regexp", pattern, ".");
93768
94423
  return new Promise((resolve, reject2) => {
93769
- (0, import_node_child_process17.execFile)(rgPath, args, { cwd: dir, signal, maxBuffer: 10 * 1024 * 1024 }, (error51, stdout) => {
94424
+ (0, import_node_child_process18.execFile)(rgPath, args, { cwd: dir, signal, maxBuffer: 10 * 1024 * 1024 }, (error51, stdout) => {
93770
94425
  if (error51 && !isRipgrepNoMatchError2(error51)) {
93771
94426
  reject2(error51);
93772
94427
  return;
@@ -93814,7 +94469,7 @@ var searchFilesTool = {
93814
94469
  };
93815
94470
 
93816
94471
  // ../../packages/core/dist/tools/writeToFile.js
93817
- var import_node_path55 = __toESM(require("node:path"), 1);
94472
+ var import_node_path56 = __toESM(require("node:path"), 1);
93818
94473
  var paramsSchema23 = external_exports.object({
93819
94474
  path: external_exports.string().min(1).describe("Path to the file, relative to the workspace root."),
93820
94475
  content: external_exports.string().describe("Full file content to write.")
@@ -93842,7 +94497,7 @@ var writeToFileTool = {
93842
94497
  return { content: changed, isError: true, path: params3.path };
93843
94498
  }
93844
94499
  if (!exists2) {
93845
- await context.fs.mkdir(import_node_path55.default.dirname(resolved.realPath));
94500
+ await context.fs.mkdir(import_node_path56.default.dirname(resolved.realPath));
93846
94501
  }
93847
94502
  await context.fs.writeFile(resolved.realPath, params3.content);
93848
94503
  await recordWrite(context, resolved.realPath);
@@ -93943,21 +94598,21 @@ function createDefaultToolRegistry() {
93943
94598
  }
93944
94599
 
93945
94600
  // ../../packages/core/dist/dataset/store.js
93946
- var import_promises30 = __toESM(require("node:fs/promises"), 1);
93947
- var import_node_path56 = __toESM(require("node:path"), 1);
94601
+ var import_promises31 = __toESM(require("node:fs/promises"), 1);
94602
+ var import_node_path57 = __toESM(require("node:path"), 1);
93948
94603
  var DatasetStore = class {
93949
94604
  filePath;
93950
94605
  statePath;
93951
94606
  constructor(storageDir, datasetId) {
93952
94607
  const safe = datasetId.replace(/[^A-Za-z0-9._-]/g, "_");
93953
- this.filePath = import_node_path56.default.join(storageDir, "datasets", `${safe}.jsonl`);
93954
- this.statePath = import_node_path56.default.join(storageDir, "datasets", `${safe}.state.json`);
94608
+ this.filePath = import_node_path57.default.join(storageDir, "datasets", `${safe}.jsonl`);
94609
+ this.statePath = import_node_path57.default.join(storageDir, "datasets", `${safe}.state.json`);
93955
94610
  }
93956
94611
  /** Every record. A malformed line is skipped — one bad line costs one record, not the corpus. */
93957
94612
  async load() {
93958
94613
  let raw;
93959
94614
  try {
93960
- raw = await import_promises30.default.readFile(this.filePath, "utf8");
94615
+ raw = await import_promises31.default.readFile(this.filePath, "utf8");
93961
94616
  } catch {
93962
94617
  return [];
93963
94618
  }
@@ -93979,18 +94634,18 @@ var DatasetStore = class {
93979
94634
  async append(records) {
93980
94635
  if (records.length === 0)
93981
94636
  return;
93982
- await import_promises30.default.mkdir(import_node_path56.default.dirname(this.filePath), { recursive: true });
93983
- await import_promises30.default.writeFile(this.filePath, "", { flag: "a" });
94637
+ await import_promises31.default.mkdir(import_node_path57.default.dirname(this.filePath), { recursive: true });
94638
+ await import_promises31.default.writeFile(this.filePath, "", { flag: "a" });
93984
94639
  const lines2 = records.map((record2) => JSON.stringify(record2)).join("\n");
93985
- await import_promises30.default.appendFile(this.filePath, `${lines2}
94640
+ await import_promises31.default.appendFile(this.filePath, `${lines2}
93986
94641
  `, "utf8");
93987
94642
  }
93988
94643
  /** Rewrites with exactly these. Temp-and-rename, so an interrupted prune leaves the old file. */
93989
94644
  async replace(records) {
93990
- await import_promises30.default.mkdir(import_node_path56.default.dirname(this.filePath), { recursive: true });
94645
+ await import_promises31.default.mkdir(import_node_path57.default.dirname(this.filePath), { recursive: true });
93991
94646
  const temporary = `${this.filePath}.tmp`;
93992
94647
  const body = records.map((record2) => JSON.stringify(record2)).join("\n");
93993
- await import_promises30.default.writeFile(temporary, records.length === 0 ? "" : `${body}
94648
+ await import_promises31.default.writeFile(temporary, records.length === 0 ? "" : `${body}
93994
94649
  `, "utf8");
93995
94650
  await replaceFile(temporary, this.filePath);
93996
94651
  }
@@ -94004,7 +94659,7 @@ var DatasetStore = class {
94004
94659
  async compact() {
94005
94660
  let before;
94006
94661
  try {
94007
- before = (await import_promises30.default.readFile(this.filePath, "utf8")).split("\n").filter((line) => line.trim().length > 0).length;
94662
+ before = (await import_promises31.default.readFile(this.filePath, "utf8")).split("\n").filter((line) => line.trim().length > 0).length;
94008
94663
  } catch {
94009
94664
  return { before: 0, after: 0 };
94010
94665
  }
@@ -94015,12 +94670,12 @@ var DatasetStore = class {
94015
94670
  return { before, after: records.length };
94016
94671
  }
94017
94672
  async clear() {
94018
- await import_promises30.default.rm(this.filePath, { force: true });
94019
- await import_promises30.default.rm(this.statePath, { force: true });
94673
+ await import_promises31.default.rm(this.filePath, { force: true });
94674
+ await import_promises31.default.rm(this.statePath, { force: true });
94020
94675
  }
94021
94676
  async sizeBytes() {
94022
94677
  try {
94023
- return (await import_promises30.default.stat(this.filePath)).size;
94678
+ return (await import_promises31.default.stat(this.filePath)).size;
94024
94679
  } catch {
94025
94680
  return 0;
94026
94681
  }
@@ -94034,16 +94689,16 @@ var DatasetStore = class {
94034
94689
  */
94035
94690
  async lastSyncedAt() {
94036
94691
  try {
94037
- const parsed = JSON.parse(await import_promises30.default.readFile(this.statePath, "utf8"));
94692
+ const parsed = JSON.parse(await import_promises31.default.readFile(this.statePath, "utf8"));
94038
94693
  return typeof parsed.lastSyncedAt === "number" ? parsed.lastSyncedAt : void 0;
94039
94694
  } catch {
94040
94695
  return void 0;
94041
94696
  }
94042
94697
  }
94043
94698
  async recordSync(at) {
94044
- await import_promises30.default.mkdir(import_node_path56.default.dirname(this.statePath), { recursive: true });
94699
+ await import_promises31.default.mkdir(import_node_path57.default.dirname(this.statePath), { recursive: true });
94045
94700
  const temporary = `${this.statePath}.tmp`;
94046
- await import_promises30.default.writeFile(temporary, JSON.stringify({ lastSyncedAt: at }), "utf8");
94701
+ await import_promises31.default.writeFile(temporary, JSON.stringify({ lastSyncedAt: at }), "utf8");
94047
94702
  await replaceFile(temporary, this.statePath);
94048
94703
  }
94049
94704
  };
@@ -94471,8 +95126,8 @@ var S3Client = class {
94471
95126
  const host = inPath ? origin.host : `${bucket}.${origin.host}`;
94472
95127
  const mount = origin.pathname === "/" ? "" : origin.pathname.replace(/\/+$/, "");
94473
95128
  const prefix = inPath ? `${mount}/${bucket}` : mount;
94474
- const path62 = key2 === "" ? "" : `/${key2.split("/").map((part) => encodeURIComponent(part)).join("/")}`;
94475
- const url2 = new URL(`${origin.protocol}//${host}${prefix}${path62}`);
95129
+ const path63 = key2 === "" ? "" : `/${key2.split("/").map((part) => encodeURIComponent(part)).join("/")}`;
95130
+ const url2 = new URL(`${origin.protocol}//${host}${prefix}${path63}`);
94476
95131
  for (const [name, value] of Object.entries(call.query ?? {}))
94477
95132
  url2.searchParams.set(name, value);
94478
95133
  return url2.toString();
@@ -94739,9 +95394,9 @@ async function syncFromS3(options) {
94739
95394
  return result;
94740
95395
  }
94741
95396
  var MANIFEST_NAME = ".lightcode-sync.json";
94742
- async function readManifest(fs42, manifestPath) {
95397
+ async function readManifest(fs43, manifestPath) {
94743
95398
  try {
94744
- const parsed = JSON.parse((await fs42.readBytes(manifestPath)).toString("utf8"));
95399
+ const parsed = JSON.parse((await fs43.readBytes(manifestPath)).toString("utf8"));
94745
95400
  return typeof parsed === "object" && parsed !== null && !Array.isArray(parsed) ? parsed : {};
94746
95401
  } catch {
94747
95402
  return {};
@@ -94759,14 +95414,14 @@ function join(dir, relative) {
94759
95414
  const left = dir.replace(/[\\/]+$/, "");
94760
95415
  return `${left}/${relative}`;
94761
95416
  }
94762
- async function writeWhole3(fs42, target, bytes) {
94763
- if (fs42.rename === void 0) {
94764
- await fs42.writeBytes(target, bytes);
95417
+ async function writeWhole3(fs43, target, bytes) {
95418
+ if (fs43.rename === void 0) {
95419
+ await fs43.writeBytes(target, bytes);
94765
95420
  return;
94766
95421
  }
94767
95422
  const temporary = `${target}.${String(process.pid)}.${String(Date.now())}.part`;
94768
- await fs42.writeBytes(temporary, bytes);
94769
- await fs42.rename(temporary, target);
95423
+ await fs43.writeBytes(temporary, bytes);
95424
+ await fs43.rename(temporary, target);
94770
95425
  }
94771
95426
  function dirname(filePath) {
94772
95427
  const cut = filePath.lastIndexOf("/");
@@ -95445,8 +96100,8 @@ async function readJsonBody(request, maxBytes = 32 * 1024 * 1024) {
95445
96100
  }
95446
96101
 
95447
96102
  // src/fileSecretStore.ts
95448
- var import_promises31 = __toESM(require("node:fs/promises"), 1);
95449
- var import_node_path57 = __toESM(require("node:path"), 1);
96103
+ var import_promises32 = __toESM(require("node:fs/promises"), 1);
96104
+ var import_node_path58 = __toESM(require("node:path"), 1);
95450
96105
 
95451
96106
  // src/vaultCrypto.ts
95452
96107
  var import_node_crypto20 = require("node:crypto");
@@ -95500,7 +96155,7 @@ var FileSecretStore = class {
95500
96155
  sealedShut = false;
95501
96156
  async currentStamp() {
95502
96157
  try {
95503
- const stat = await import_promises31.default.stat(this.filePath);
96158
+ const stat = await import_promises32.default.stat(this.filePath);
95504
96159
  return `${String(stat.mtimeMs)}:${String(stat.size)}`;
95505
96160
  } catch {
95506
96161
  return void 0;
@@ -95511,7 +96166,7 @@ var FileSecretStore = class {
95511
96166
  if (this.cache !== void 0 && stamp2 === this.stamp) return this.cache;
95512
96167
  this.stamp = stamp2;
95513
96168
  try {
95514
- const raw = await import_promises31.default.readFile(this.filePath, "utf8");
96169
+ const raw = await import_promises32.default.readFile(this.filePath, "utf8");
95515
96170
  const parsed = JSON.parse(raw.replace(/^\uFEFF/, ""));
95516
96171
  this.sealedShut = false;
95517
96172
  if (isVaultEnvelope(parsed)) {
@@ -95544,10 +96199,10 @@ var FileSecretStore = class {
95544
96199
  );
95545
96200
  }
95546
96201
  mutate(secrets);
95547
- await import_promises31.default.mkdir(import_node_path57.default.dirname(this.filePath), { recursive: true });
96202
+ await import_promises32.default.mkdir(import_node_path58.default.dirname(this.filePath), { recursive: true });
95548
96203
  const temp = `${this.filePath}.${process.pid}.tmp`;
95549
96204
  const body = this.key === void 0 ? secrets : sealSecrets(secrets, this.key);
95550
- await import_promises31.default.writeFile(temp, JSON.stringify(body, null, 2), { encoding: "utf8", mode: 384 });
96205
+ await import_promises32.default.writeFile(temp, JSON.stringify(body, null, 2), { encoding: "utf8", mode: 384 });
95551
96206
  await replaceFile(temp, this.filePath);
95552
96207
  this.stamp = await this.currentStamp();
95553
96208
  });
@@ -95580,8 +96235,8 @@ var FileSecretStore = class {
95580
96235
 
95581
96236
  // src/reviewQueue.ts
95582
96237
  var import_node_crypto21 = __toESM(require("node:crypto"), 1);
95583
- var import_promises32 = __toESM(require("node:fs/promises"), 1);
95584
- var import_node_path58 = __toESM(require("node:path"), 1);
96238
+ var import_promises33 = __toESM(require("node:fs/promises"), 1);
96239
+ var import_node_path59 = __toESM(require("node:path"), 1);
95585
96240
  var ReviewQueue = class {
95586
96241
  constructor(filePath) {
95587
96242
  this.filePath = filePath;
@@ -95591,7 +96246,7 @@ var ReviewQueue = class {
95591
96246
  async load() {
95592
96247
  if (this.cache !== void 0) return this.cache;
95593
96248
  try {
95594
- const parsed = JSON.parse(await import_promises32.default.readFile(this.filePath, "utf8"));
96249
+ const parsed = JSON.parse(await import_promises33.default.readFile(this.filePath, "utf8"));
95595
96250
  this.cache = Array.isArray(parsed) ? parsed : [];
95596
96251
  } catch {
95597
96252
  this.cache = [];
@@ -95600,9 +96255,9 @@ var ReviewQueue = class {
95600
96255
  }
95601
96256
  async persist(items) {
95602
96257
  this.cache = items;
95603
- await import_promises32.default.mkdir(import_node_path58.default.dirname(this.filePath), { recursive: true });
96258
+ await import_promises33.default.mkdir(import_node_path59.default.dirname(this.filePath), { recursive: true });
95604
96259
  const temporary = `${this.filePath}.tmp`;
95605
- await import_promises32.default.writeFile(temporary, JSON.stringify(items, null, 2), { encoding: "utf8", mode: 384 });
96260
+ await import_promises33.default.writeFile(temporary, JSON.stringify(items, null, 2), { encoding: "utf8", mode: 384 });
95606
96261
  await replaceFile(temporary, this.filePath);
95607
96262
  }
95608
96263
  async list() {
@@ -95840,9 +96495,9 @@ var RoutedSecretStore = class {
95840
96495
  };
95841
96496
 
95842
96497
  // src/userVariables.ts
95843
- var import_promises33 = __toESM(require("node:fs/promises"), 1);
95844
- var import_node_fs13 = require("node:fs");
95845
- var import_node_path59 = __toESM(require("node:path"), 1);
96498
+ var import_promises34 = __toESM(require("node:fs/promises"), 1);
96499
+ var import_node_fs14 = require("node:fs");
96500
+ var import_node_path60 = __toESM(require("node:path"), 1);
95846
96501
  var UserVariableStore = class {
95847
96502
  constructor(filePath) {
95848
96503
  this.filePath = filePath;
@@ -95857,9 +96512,9 @@ var UserVariableStore = class {
95857
96512
  }
95858
96513
  async save(variables) {
95859
96514
  const parsed = sessionVariablesSchema.parse(variables);
95860
- await import_promises33.default.mkdir(import_node_path59.default.dirname(this.filePath), { recursive: true });
96515
+ await import_promises34.default.mkdir(import_node_path60.default.dirname(this.filePath), { recursive: true });
95861
96516
  const temporary = `${this.filePath}.tmp`;
95862
- await import_promises33.default.writeFile(temporary, JSON.stringify({ variables: parsed }, null, 2), {
96517
+ await import_promises34.default.writeFile(temporary, JSON.stringify({ variables: parsed }, null, 2), {
95863
96518
  encoding: "utf8",
95864
96519
  mode: 384
95865
96520
  });
@@ -95868,14 +96523,14 @@ var UserVariableStore = class {
95868
96523
  }
95869
96524
  };
95870
96525
  function userVariableStoreFor(dataDir, principal) {
95871
- return new UserVariableStore(userVariablesPath(import_node_path59.default.join(dataDir, "users", storageKeyFor(principal))));
96526
+ return new UserVariableStore(userVariablesPath(import_node_path60.default.join(dataDir, "users", storageKeyFor(principal))));
95872
96527
  }
95873
96528
  function userVariablesPath(userDir) {
95874
- return import_node_path59.default.join(userDir, "variables.json");
96529
+ return import_node_path60.default.join(userDir, "variables.json");
95875
96530
  }
95876
96531
  function readVariablesFile(filePath) {
95877
96532
  try {
95878
- const raw = JSON.parse((0, import_node_fs13.readFileSync)(filePath, "utf8"));
96533
+ const raw = JSON.parse((0, import_node_fs14.readFileSync)(filePath, "utf8"));
95879
96534
  const parsed = sessionVariablesSchema.safeParse(raw["variables"]);
95880
96535
  return parsed.success ? parsed.data : [];
95881
96536
  } catch {
@@ -95899,13 +96554,13 @@ function hostedUser(env2 = process.env) {
95899
96554
  }
95900
96555
 
95901
96556
  // src/session.ts
95902
- var import_node_fs14 = require("node:fs");
95903
- var import_promises34 = __toESM(require("node:fs/promises"), 1);
95904
- var import_node_path61 = __toESM(require("node:path"), 1);
96557
+ var import_node_fs15 = require("node:fs");
96558
+ var import_promises35 = __toESM(require("node:fs/promises"), 1);
96559
+ var import_node_path62 = __toESM(require("node:path"), 1);
95905
96560
 
95906
96561
  // src/credentialTool.ts
95907
- var import_node_child_process18 = require("node:child_process");
95908
- var import_node_path60 = __toESM(require("node:path"), 1);
96562
+ var import_node_child_process19 = require("node:child_process");
96563
+ var import_node_path61 = __toESM(require("node:path"), 1);
95909
96564
  var CREDENTIAL_PREFIX2 = "tool:";
95910
96565
  var WRAPPER = [
95911
96566
  "import importlib.util, json, sys",
@@ -95925,7 +96580,7 @@ async function fetchCredential(options, reference) {
95925
96580
  if (name.length === 0) return { problem: "A credential reference needs a name: tool:<name>." };
95926
96581
  const budget = options.timeoutMs ?? 3e4;
95927
96582
  const run3 = await new Promise((resolve) => {
95928
- const child = (0, import_node_child_process18.spawn)(options.interpreter, ["-c", WRAPPER, import_node_path60.default.resolve(options.file), name], {
96583
+ const child = (0, import_node_child_process19.spawn)(options.interpreter, ["-c", WRAPPER, import_node_path61.default.resolve(options.file), name], {
95929
96584
  windowsHide: true,
95930
96585
  // The environment this was started in, as with the identity function: the libraries that
95931
96586
  // hold credentials are configured through it, and nothing here is model-authored.
@@ -96110,7 +96765,7 @@ var FileConfigStore = class {
96110
96765
  const filePath = this.pathFor(scope);
96111
96766
  if (filePath === void 0) return void 0;
96112
96767
  try {
96113
- return await import_promises34.default.readFile(filePath, "utf8");
96768
+ return await import_promises35.default.readFile(filePath, "utf8");
96114
96769
  } catch (error51) {
96115
96770
  if (error51.code === "ENOENT") return void 0;
96116
96771
  throw error51;
@@ -96121,13 +96776,13 @@ var FileConfigStore = class {
96121
96776
  const filePath = this.pathFor(scope);
96122
96777
  if (filePath === void 0)
96123
96778
  throw new Error(`Cannot write ${scope} config: no workspace is open`);
96124
- await import_promises34.default.mkdir(import_node_path61.default.dirname(filePath), { recursive: true });
96779
+ await import_promises35.default.mkdir(import_node_path62.default.dirname(filePath), { recursive: true });
96125
96780
  const temporary = `${filePath}.${process.pid.toString(36)}.tmp`;
96126
- await import_promises34.default.writeFile(temporary, contents, { encoding: "utf8", mode: 384 });
96781
+ await import_promises35.default.writeFile(temporary, contents, { encoding: "utf8", mode: 384 });
96127
96782
  await replaceFile(temporary, filePath);
96128
96783
  try {
96129
96784
  const backupTemp = `${configBackupPath(filePath)}.tmp`;
96130
- await import_promises34.default.writeFile(backupTemp, contents, { encoding: "utf8", mode: 384 });
96785
+ await import_promises35.default.writeFile(backupTemp, contents, { encoding: "utf8", mode: 384 });
96131
96786
  await replaceFile(backupTemp, configBackupPath(filePath));
96132
96787
  } catch {
96133
96788
  }
@@ -96136,7 +96791,7 @@ var FileConfigStore = class {
96136
96791
  const filePath = this.pathFor(scope);
96137
96792
  if (filePath === void 0) return void 0;
96138
96793
  try {
96139
- return await import_promises34.default.readFile(configBackupPath(filePath), "utf8");
96794
+ return await import_promises35.default.readFile(configBackupPath(filePath), "utf8");
96140
96795
  } catch {
96141
96796
  return void 0;
96142
96797
  }
@@ -96146,7 +96801,7 @@ var FileConfigStore = class {
96146
96801
  if (filePath === void 0) return void 0;
96147
96802
  const target = `${filePath}.corrupt-${(/* @__PURE__ */ new Date()).toISOString().replace(/[:.]/g, "-")}`;
96148
96803
  try {
96149
- await import_promises34.default.rename(filePath, target);
96804
+ await import_promises35.default.rename(filePath, target);
96150
96805
  return target;
96151
96806
  } catch {
96152
96807
  return void 0;
@@ -96158,8 +96813,8 @@ var FileConfigStore = class {
96158
96813
  };
96159
96814
  let watcher;
96160
96815
  try {
96161
- watcher = (0, import_node_fs14.watch)(import_node_path61.default.dirname(filePath), (_event, filename) => {
96162
- if (filename === import_node_path61.default.basename(filePath)) onChange();
96816
+ watcher = (0, import_node_fs15.watch)(import_node_path62.default.dirname(filePath), (_event, filename) => {
96817
+ if (filename === import_node_path62.default.basename(filePath)) onChange();
96163
96818
  });
96164
96819
  } catch {
96165
96820
  }
@@ -96174,7 +96829,7 @@ var FileWorkspaceState = class {
96174
96829
  values = {};
96175
96830
  async load() {
96176
96831
  try {
96177
- const parsed = JSON.parse(await import_promises34.default.readFile(this.filePath, "utf8"));
96832
+ const parsed = JSON.parse(await import_promises35.default.readFile(this.filePath, "utf8"));
96178
96833
  if (typeof parsed === "object" && parsed !== null)
96179
96834
  this.values = parsed;
96180
96835
  } catch {
@@ -96187,8 +96842,8 @@ var FileWorkspaceState = class {
96187
96842
  async set(key2, value) {
96188
96843
  if (value === void 0) delete this.values[key2];
96189
96844
  else this.values[key2] = value;
96190
- await import_promises34.default.mkdir(import_node_path61.default.dirname(this.filePath), { recursive: true });
96191
- await import_promises34.default.writeFile(this.filePath, JSON.stringify(this.values, null, 2), {
96845
+ await import_promises35.default.mkdir(import_node_path62.default.dirname(this.filePath), { recursive: true });
96846
+ await import_promises35.default.writeFile(this.filePath, JSON.stringify(this.values, null, 2), {
96192
96847
  encoding: "utf8",
96193
96848
  mode: 384
96194
96849
  });
@@ -96236,7 +96891,7 @@ function createBrowserUi(workspaceRoot, post, fastFs) {
96236
96891
  openFile: async (filePath) => {
96237
96892
  try {
96238
96893
  post(
96239
- [`[info] ${import_node_path61.default.basename(filePath)}`, "", await import_promises34.default.readFile(filePath, "utf8")].join("\n")
96894
+ [`[info] ${import_node_path62.default.basename(filePath)}`, "", await import_promises35.default.readFile(filePath, "utf8")].join("\n")
96240
96895
  );
96241
96896
  } catch (error51) {
96242
96897
  post(`[warning] Could not read ${filePath}: ${String(error51)}`);
@@ -96271,14 +96926,14 @@ function createBrowserUi(workspaceRoot, post, fastFs) {
96271
96926
  if (found2.length >= limit || level > 12 || depth !== void 0 && level > depth) return;
96272
96927
  let entries;
96273
96928
  try {
96274
- entries = await import_promises34.default.readdir(dir, { withFileTypes: true });
96929
+ entries = await import_promises35.default.readdir(dir, { withFileTypes: true });
96275
96930
  } catch {
96276
96931
  return;
96277
96932
  }
96278
96933
  for (const entry of entries) {
96279
96934
  if (found2.length >= limit) return;
96280
96935
  if (entry.name.startsWith(".") && entry.name !== ".env") continue;
96281
- const full = import_node_path61.default.join(dir, entry.name);
96936
+ const full = import_node_path62.default.join(dir, entry.name);
96282
96937
  if (entry.isDirectory()) {
96283
96938
  if (!skip.has(entry.name)) await walk(full, level + 1);
96284
96939
  } else if (depth !== void 0 && level !== depth) {
@@ -96314,11 +96969,11 @@ var SHARED_COLLECTIONS = [
96314
96969
  { key: "mcpServers" }
96315
96970
  ];
96316
96971
  async function createSession(options) {
96317
- const userDir = import_node_path61.default.join(options.dataDir, "users", storageKeyFor(options.principal));
96318
- await import_promises34.default.mkdir(userDir, { recursive: true, mode: 448 });
96972
+ const userDir = import_node_path62.default.join(options.dataDir, "users", storageKeyFor(options.principal));
96973
+ await import_promises35.default.mkdir(userDir, { recursive: true, mode: 448 });
96319
96974
  const variableStore = new UserVariableStore(userVariablesPath(userDir));
96320
96975
  const userVariables = () => variableStore.read();
96321
- const workspaceState = new FileWorkspaceState(import_node_path61.default.join(userDir, "workspace-state.json"));
96976
+ const workspaceState = new FileWorkspaceState(import_node_path62.default.join(userDir, "workspace-state.json"));
96322
96977
  await workspaceState.load();
96323
96978
  const services = {
96324
96979
  /*
@@ -96406,16 +97061,16 @@ async function createSession(options) {
96406
97061
  */
96407
97062
  secrets: new CredentialPointerStore(
96408
97063
  withCredentialTool(
96409
- options.sharedSecrets === void 0 ? new FileSecretStore(options.secretsFile ?? import_node_path61.default.join(userDir, "secrets.json"), options.secretsKey) : new RoutedSecretStore(
96410
- new FileSecretStore(options.secretsFile ?? import_node_path61.default.join(userDir, "secrets.json"), options.secretsKey),
97064
+ options.sharedSecrets === void 0 ? new FileSecretStore(options.secretsFile ?? import_node_path62.default.join(userDir, "secrets.json"), options.secretsKey) : new RoutedSecretStore(
97065
+ new FileSecretStore(options.secretsFile ?? import_node_path62.default.join(userDir, "secrets.json"), options.secretsKey),
96411
97066
  options.sharedSecrets
96412
97067
  ),
96413
97068
  options
96414
97069
  )
96415
97070
  ),
96416
97071
  configStore: withSharedEntries(
96417
- options.sharedProfiles === void 0 ? new FileConfigStore(options.configFile ?? import_node_path61.default.join(userDir, "config.json"), options.workspaceRoot) : new SharedProfileConfigStore(
96418
- new FileConfigStore(options.configFile ?? import_node_path61.default.join(userDir, "config.json"), options.workspaceRoot),
97072
+ options.sharedProfiles === void 0 ? new FileConfigStore(options.configFile ?? import_node_path62.default.join(userDir, "config.json"), options.workspaceRoot) : new SharedProfileConfigStore(
97073
+ new FileConfigStore(options.configFile ?? import_node_path62.default.join(userDir, "config.json"), options.workspaceRoot),
96419
97074
  options.sharedProfiles
96420
97075
  ),
96421
97076
  options
@@ -96533,8 +97188,8 @@ async function startServer(options) {
96533
97188
  ));
96534
97189
  const roles = options.roles ?? SINGLE_USER_POLICY;
96535
97190
  const sharedStore = options.sharedConfig;
96536
- const sharedSecretStore = new FileSecretStore(import_node_path62.default.join(options.dataDir, "shared-secrets.json"));
96537
- const reviews = new ReviewQueue(import_node_path62.default.join(options.dataDir, "reviews.json"));
97191
+ const sharedSecretStore = new FileSecretStore(import_node_path63.default.join(options.dataDir, "shared-secrets.json"));
97192
+ const reviews = new ReviewQueue(import_node_path63.default.join(options.dataDir, "reviews.json"));
96538
97193
  let sharedCache = {
96539
97194
  variables: [],
96540
97195
  adminIds: [],
@@ -96910,14 +97565,14 @@ async function startServer(options) {
96910
97565
  return "No workspace is open, so there is nowhere to write it.";
96911
97566
  try {
96912
97567
  if (item.kind === "skill") {
96913
- const dir2 = import_node_path62.default.join(options.workspaceRoot, ".lightcode", "skills");
96914
- await import_promises35.default.mkdir(dir2, { recursive: true });
96915
- await import_promises35.default.writeFile(import_node_path62.default.join(dir2, `${item.name}.md`), item.content, "utf8");
97568
+ const dir2 = import_node_path63.default.join(options.workspaceRoot, ".lightcode", "skills");
97569
+ await import_promises36.default.mkdir(dir2, { recursive: true });
97570
+ await import_promises36.default.writeFile(import_node_path63.default.join(dir2, `${item.name}.md`), item.content, "utf8");
96916
97571
  return void 0;
96917
97572
  }
96918
- const dir = import_node_path62.default.join(options.workspaceRoot, ".lightcode", "tools");
96919
- await import_promises35.default.mkdir(dir, { recursive: true });
96920
- await import_promises35.default.writeFile(import_node_path62.default.join(dir, `${item.name}.py`), item.content, "utf8");
97573
+ const dir = import_node_path63.default.join(options.workspaceRoot, ".lightcode", "tools");
97574
+ await import_promises36.default.mkdir(dir, { recursive: true });
97575
+ await import_promises36.default.writeFile(import_node_path63.default.join(dir, `${item.name}.py`), item.content, "utf8");
96921
97576
  return void 0;
96922
97577
  } catch (error51) {
96923
97578
  return error51 instanceof Error ? error51.message : String(error51);
@@ -96940,7 +97595,7 @@ async function startServer(options) {
96940
97595
  async function readCredentials() {
96941
97596
  if (options.credentialsFile === void 0) return [];
96942
97597
  try {
96943
- const parsed = JSON.parse(await import_promises35.default.readFile(options.credentialsFile, "utf8"));
97598
+ const parsed = JSON.parse(await import_promises36.default.readFile(options.credentialsFile, "utf8"));
96944
97599
  const list2 = Array.isArray(parsed.credentials) ? parsed.credentials : [];
96945
97600
  return list2.flatMap((entry) => {
96946
97601
  const c2 = entry;
@@ -96956,7 +97611,7 @@ async function startServer(options) {
96956
97611
  connection.transport.post({ type: "credentials", credentials: await readCredentials() });
96957
97612
  }
96958
97613
  if (options.credentialsFile !== void 0) {
96959
- (0, import_node_fs15.watchFile)(options.credentialsFile, { interval: 1500 }, () => {
97614
+ (0, import_node_fs16.watchFile)(options.credentialsFile, { interval: 1500 }, () => {
96960
97615
  for (const connection of connections.values()) void postCredentials(connection);
96961
97616
  });
96962
97617
  }
@@ -97066,7 +97721,7 @@ async function startServer(options) {
97066
97721
  return;
97067
97722
  }
97068
97723
  response.writeHead(200, {
97069
- "Content-Type": CONTENT_TYPES2[import_node_path62.default.extname(asset)] ?? "application/octet-stream",
97724
+ "Content-Type": CONTENT_TYPES2[import_node_path63.default.extname(asset)] ?? "application/octet-stream",
97070
97725
  ...securityHeaders()
97071
97726
  });
97072
97727
  response.end(body);