@google/gemini-cli 0.67.0 → 0.69.0-preview.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 (74) hide show
  1. package/README.md +18 -24
  2. package/bundle/{chunk-IDJ4QXBF.js → chunk-2KKDGWF2.js} +1 -1
  3. package/bundle/{chunk-7LX6MRZ6.js → chunk-2ONJU4V7.js} +1 -1
  4. package/bundle/chunk-3HEOCQDN.js +65 -0
  5. package/bundle/{chunk-VO6PFWLY.js → chunk-4SOPZCNA.js} +29 -15
  6. package/bundle/{chunk-56IGTM4O.js → chunk-6KCLIS6W.js} +1 -1
  7. package/bundle/{chunk-2E3ETS5J.js → chunk-BRHBBQC5.js} +2 -2
  8. package/bundle/{chunk-M73CYIV5.js → chunk-C5BED6L6.js} +2 -2
  9. package/bundle/{chunk-VK766A3F.js → chunk-CGQSFR2I.js} +7 -2
  10. package/bundle/{chunk-OJ62HCXG.js → chunk-CWHEOJXF.js} +7 -2
  11. package/bundle/{chunk-LAR4JEC7.js → chunk-DWMZSQYG.js} +6050 -2877
  12. package/bundle/{chunk-QTXJG3I3.js → chunk-GDCMMKZ2.js} +1 -1
  13. package/bundle/{chunk-YUO7RUF4.js → chunk-GQ7FZNO2.js} +1 -1
  14. package/bundle/{chunk-GBUWHRK6.js → chunk-JJWPYMIO.js} +3 -3
  15. package/bundle/{chunk-NGQU3QTQ.js → chunk-KUXCUQKX.js} +5859 -2837
  16. package/bundle/{chunk-P62CI7AR.js → chunk-LYKP3S67.js} +29 -15
  17. package/bundle/{chunk-O7MGOE2I.js → chunk-MP4TVGOP.js} +6050 -2877
  18. package/bundle/{chunk-IGE3G3WZ.js → chunk-PH5XENTH.js} +1 -1
  19. package/bundle/{chunk-CJFBYU4J.js → chunk-RBDD6IBU.js} +937 -327
  20. package/bundle/{chunk-5RNHNFYV.js → chunk-SYOIMUZI.js} +937 -327
  21. package/bundle/{chunk-BW65QRZA.js → chunk-U3FFDEKY.js} +29 -15
  22. package/bundle/{chunk-MQNW2IRI.js → chunk-U5FJ6OGB.js} +2 -2
  23. package/bundle/{chunk-PUNFASKY.js → chunk-UAHZWXSG.js} +7 -2
  24. package/bundle/chunk-UW3ZS3BH.js +65 -0
  25. package/bundle/{chunk-4JH2G4F4.js → chunk-V7L3FMBE.js} +3 -3
  26. package/bundle/chunk-VQTELFV3.js +65 -0
  27. package/bundle/{chunk-QA5FT4VY.js → chunk-YODS6HR2.js} +3 -3
  28. package/bundle/{chunk-XETHQLRU.js → chunk-YP5TA33N.js} +937 -327
  29. package/bundle/{cleanup-B6AOSVD4.js → cleanup-3T2KXSP4.js} +2 -2
  30. package/bundle/{cleanup-BRFB47DL.js → cleanup-NNQCI4KC.js} +2 -2
  31. package/bundle/{cleanup-S5QFYCEP.js → cleanup-TA4VYDXQ.js} +2 -2
  32. package/bundle/{core-N27LU4DK.js → core-6XF5EO7Z.js} +37 -1
  33. package/bundle/{dist-E6RCLXQU.js → core-TUJHM7E7.js} +37 -1
  34. package/bundle/{devtoolsService-6V46WMXX.js → devtoolsService-7EMPANTX.js} +2 -2
  35. package/bundle/{devtoolsService-E74ZMDMM.js → devtoolsService-I7WFRUEA.js} +2 -2
  36. package/bundle/{devtoolsService-EFJXZRFD.js → devtoolsService-RCBUZGYD.js} +2 -2
  37. package/bundle/{core-GTUUQBGE.js → dist-OSQFIX7F.js} +37 -1
  38. package/bundle/docs/changelogs/index.md +42 -0
  39. package/bundle/docs/changelogs/latest.md +89 -91
  40. package/bundle/docs/changelogs/preview.md +106 -90
  41. package/bundle/docs/cli/sandbox.md +8 -2
  42. package/bundle/docs/cli/themes.md +56 -8
  43. package/bundle/docs/cli/trusted-folders.md +13 -0
  44. package/bundle/docs/extensions/releasing.md +32 -0
  45. package/bundle/docs/reference/commands.md +4 -0
  46. package/bundle/docs/reference/configuration.md +10 -10
  47. package/bundle/docs/reference/policy-engine.md +6 -0
  48. package/bundle/formatError-KEQ3HU3Y.js +14 -0
  49. package/bundle/formatError-LJFIC7G3.js +14 -0
  50. package/bundle/formatError-MIUNQEYE.js +14 -0
  51. package/bundle/{gemini-QWDTSJTS.js → gemini-22ON2CZG.js} +601 -142
  52. package/bundle/{gemini-4JPKPLQN.js → gemini-HLS52ZNZ.js} +601 -142
  53. package/bundle/{gemini-VF5FS3OM.js → gemini-ZZZEFPSK.js} +601 -142
  54. package/bundle/gemini.js +14 -13
  55. package/bundle/{interactiveCli-QJZZISQQ.js → interactiveCli-5HMWVTK2.js} +2967 -2329
  56. package/bundle/{interactiveCli-FQ3YKGOG.js → interactiveCli-HQBE3C3C.js} +2967 -2329
  57. package/bundle/{interactiveCli-F2YYMYTP.js → interactiveCli-NKFQZXB5.js} +2967 -2329
  58. package/bundle/{liteRtServerManager-JAV3GR4V.js → liteRtServerManager-2IOXWO76.js} +4 -4
  59. package/bundle/{liteRtServerManager-X5CCMKM6.js → liteRtServerManager-AG4Y5JMZ.js} +4 -4
  60. package/bundle/{liteRtServerManager-27R2M6XE.js → liteRtServerManager-OFNVXXQ4.js} +4 -4
  61. package/bundle/{oauth2-provider-6UCP23AQ.js → oauth2-provider-2DHNJ2S3.js} +1 -1
  62. package/bundle/{oauth2-provider-H2KV36NU.js → oauth2-provider-OEGXLWIL.js} +1 -1
  63. package/bundle/{oauth2-provider-C65IJMNQ.js → oauth2-provider-YDNSNN32.js} +1 -1
  64. package/bundle/policies/yolo.toml +1 -0
  65. package/bundle/sandbox-macos-permissive-open.sb +8 -0
  66. package/bundle/sandbox-macos-permissive-proxied.sb +8 -0
  67. package/bundle/sandbox-macos-restrictive-open.sb +1 -0
  68. package/bundle/sandbox-macos-restrictive-proxied.sb +1 -0
  69. package/bundle/sandbox-macos-strict-open.sb +1 -0
  70. package/bundle/sandbox-macos-strict-proxied.sb +1 -0
  71. package/bundle/{start-GNOA75NQ.js → start-7GJH3MKY.js} +6 -6
  72. package/bundle/{start-K2AYYNST.js → start-JSVKPUTV.js} +6 -6
  73. package/bundle/{start-E4ZL44QM.js → start-N33LF5WK.js} +6 -6
  74. package/package.json +1 -1
@@ -2,7 +2,7 @@ const require = (await import('node:module')).createRequire(import.meta.url); co
2
2
  import {
3
3
  exitCli,
4
4
  require_source
5
- } from "./chunk-IGE3G3WZ.js";
5
+ } from "./chunk-6KCLIS6W.js";
6
6
  import {
7
7
  AppEvent,
8
8
  appEvents
@@ -69,22 +69,25 @@ import {
69
69
  use_stdin_default,
70
70
  use_stdout_default,
71
71
  validateCustomTheme
72
- } from "./chunk-P62CI7AR.js";
72
+ } from "./chunk-LYKP3S67.js";
73
73
  import {
74
74
  isDevelopment,
75
75
  require_semver
76
- } from "./chunk-M73CYIV5.js";
76
+ } from "./chunk-U5FJ6OGB.js";
77
77
  import {
78
78
  emptyIcon,
79
79
  mapCoreStatusToDisplayStatus,
80
80
  require_react
81
- } from "./chunk-QTXJG3I3.js";
81
+ } from "./chunk-GDCMMKZ2.js";
82
82
  import {
83
83
  ALL_EDITORS,
84
84
  ApprovalMode,
85
85
  AsyncFzf,
86
86
  Config,
87
87
  CoreEvent,
88
+ DEFAULT_GEMINI_MODEL_AUTO,
89
+ DEFAULT_HEATMAP_WINDOW_DAYS,
90
+ DEFAULT_MODEL_CONFIGS,
88
91
  DiscoveredMCPTool,
89
92
  ExtensionDisableEvent,
90
93
  ExtensionEnableEvent,
@@ -95,12 +98,17 @@ import {
95
98
  ExtensionUpdateEvent,
96
99
  GEMINI_CLI_COMPANION_EXTENSION_NAME,
97
100
  GEMINI_DIR,
101
+ GEMINI_MODEL_ALIAS_AUTO,
102
+ GEMINI_MODEL_ALIAS_FLASH,
103
+ GEMINI_MODEL_ALIAS_FLASH_LITE,
104
+ GEMINI_MODEL_ALIAS_PRO,
98
105
  INITIAL_HISTORY_LENGTH,
99
106
  IdeClient,
100
107
  IdeConnectionEvent,
101
108
  KeychainTokenStorage,
102
109
  MCPOAuthTokenStorage,
103
110
  ModelSlashCommandEvent,
111
+ PREVIEW_GEMINI_MODEL_AUTO,
104
112
  ProjectIdRequiredError,
105
113
  REFERENCE_CONTENT_END,
106
114
  REFERENCE_CONTENT_START,
@@ -112,7 +120,9 @@ import {
112
120
  Storage,
113
121
  UPGRADE_URL_PAGE,
114
122
  UserAccountManager,
123
+ VALID_GEMINI_MODELS,
115
124
  ValidationRequiredError,
125
+ aggregateUsageFromRecordings,
116
126
  appendToLastTextPart,
117
127
  applyAdminAllowlist,
118
128
  applyInboxMemoryPatch,
@@ -149,6 +159,7 @@ import {
149
159
  flatMapTextParts,
150
160
  flushTelemetry,
151
161
  formatCheckpointDisplayList,
162
+ formatLocalDateKey,
152
163
  getAdminBlockedMcpServersMessage,
153
164
  getAdminErrorMessage,
154
165
  getDisplayString,
@@ -207,6 +218,7 @@ import {
207
218
  logRewind,
208
219
  mcpServerRequiresOAuth,
209
220
  moveInboxSkill,
221
+ normalizePath,
210
222
  openBrowserSecurely,
211
223
  open_default,
212
224
  partToString,
@@ -219,11 +231,14 @@ import {
219
231
  require_cross_spawn,
220
232
  require_is_stream,
221
233
  require_path_key,
234
+ require_proper_lockfile,
222
235
  require_pump,
236
+ require_strip_json_comments,
223
237
  require_toml,
224
238
  resetBrowserSession,
225
239
  resolveAtCommandPath,
226
240
  resolveEditorTypeFromCommand,
241
+ resolveHeatmapDateArg,
227
242
  resolveToRealPath,
228
243
  safeLookup,
229
244
  shortenPath,
@@ -233,13 +248,14 @@ import {
233
248
  spawnAsync,
234
249
  startMemoryService,
235
250
  startupProfiler,
251
+ stripExtendedLengthPrefix,
236
252
  stripLineNumberSuffix,
237
253
  tildeifyPath,
238
254
  tokenLimit,
239
255
  uiTelemetryService,
240
256
  unescapePath,
241
257
  validateUrlDestination
242
- } from "./chunk-LAR4JEC7.js";
258
+ } from "./chunk-DWMZSQYG.js";
243
259
  import {
244
260
  require_src
245
261
  } from "./chunk-L6PII3GR.js";
@@ -5881,7 +5897,7 @@ var require_yauzl = __commonJS({
5881
5897
  exports.ZipFile = ZipFile;
5882
5898
  exports.Entry = Entry;
5883
5899
  exports.RandomAccessReader = RandomAccessReader;
5884
- function open(path37, options, callback) {
5900
+ function open(path38, options, callback) {
5885
5901
  if (typeof options === "function") {
5886
5902
  callback = options;
5887
5903
  options = null;
@@ -5893,7 +5909,7 @@ var require_yauzl = __commonJS({
5893
5909
  if (options.validateEntrySizes == null) options.validateEntrySizes = true;
5894
5910
  if (options.strictFileNames == null) options.strictFileNames = false;
5895
5911
  if (callback == null) callback = defaultCallback;
5896
- fs33.open(path37, "r", function(err, fd) {
5912
+ fs33.open(path38, "r", function(err, fd) {
5897
5913
  if (err) return callback(err);
5898
5914
  fromFd(fd, options, function(err2, zipfile) {
5899
5915
  if (err2) fs33.close(fd, defaultCallback);
@@ -6495,12 +6511,12 @@ var require_extract_zip = __commonJS({
6495
6511
  var debug = require_src()("extract-zip");
6496
6512
  var { createWriteStream: createWriteStream5, promises: fs33 } = __require("fs");
6497
6513
  var getStream = require_get_stream();
6498
- var path37 = __require("path");
6514
+ var path38 = __require("path");
6499
6515
  var { promisify: promisify5 } = __require("util");
6500
6516
  var stream = __require("stream");
6501
6517
  var yauzl = require_yauzl();
6502
6518
  var openZip = promisify5(yauzl.open);
6503
- var pipeline2 = promisify5(stream.pipeline);
6519
+ var pipeline3 = promisify5(stream.pipeline);
6504
6520
  var Extractor = class {
6505
6521
  constructor(zipPath, opts) {
6506
6522
  this.zipPath = zipPath;
@@ -6532,12 +6548,12 @@ var require_extract_zip = __commonJS({
6532
6548
  this.zipfile.readEntry();
6533
6549
  return;
6534
6550
  }
6535
- const destDir = path37.dirname(path37.join(this.opts.dir, entry.fileName));
6551
+ const destDir = path38.dirname(path38.join(this.opts.dir, entry.fileName));
6536
6552
  try {
6537
6553
  await fs33.mkdir(destDir, { recursive: true });
6538
6554
  const canonicalDestDir = await fs33.realpath(destDir);
6539
- const relativeDestDir = path37.relative(this.opts.dir, canonicalDestDir);
6540
- if (relativeDestDir.split(path37.sep).includes("..")) {
6555
+ const relativeDestDir = path38.relative(this.opts.dir, canonicalDestDir);
6556
+ if (relativeDestDir.split(path38.sep).includes("..")) {
6541
6557
  throw new Error(`Out of bound path "${canonicalDestDir}" found while processing file ${entry.fileName}`);
6542
6558
  }
6543
6559
  await this.extractEntry(entry);
@@ -6559,7 +6575,7 @@ var require_extract_zip = __commonJS({
6559
6575
  if (this.opts.onEntry) {
6560
6576
  this.opts.onEntry(entry, this.zipfile);
6561
6577
  }
6562
- const dest = path37.join(this.opts.dir, entry.fileName);
6578
+ const dest = path38.join(this.opts.dir, entry.fileName);
6563
6579
  const mode = entry.externalFileAttributes >> 16 & 65535;
6564
6580
  const IFMT = 61440;
6565
6581
  const IFDIR = 16384;
@@ -6573,7 +6589,7 @@ var require_extract_zip = __commonJS({
6573
6589
  if (!isDir) isDir = madeBy === 0 && entry.externalFileAttributes === 16;
6574
6590
  debug("extracting entry", { filename: entry.fileName, isDir, isSymlink: symlink2 });
6575
6591
  const procMode = this.getExtractedMode(mode, isDir) & 511;
6576
- const destDir = isDir ? dest : path37.dirname(dest);
6592
+ const destDir = isDir ? dest : path38.dirname(dest);
6577
6593
  const mkdirOptions = { recursive: true };
6578
6594
  if (isDir) {
6579
6595
  mkdirOptions.mode = procMode;
@@ -6588,7 +6604,7 @@ var require_extract_zip = __commonJS({
6588
6604
  debug("creating symlink", link, dest);
6589
6605
  await fs33.symlink(link, dest);
6590
6606
  } else {
6591
- await pipeline2(readStream, createWriteStream5(dest, { mode: procMode }));
6607
+ await pipeline3(readStream, createWriteStream5(dest, { mode: procMode }));
6592
6608
  }
6593
6609
  }
6594
6610
  getExtractedMode(entryMode, isDir) {
@@ -6615,7 +6631,7 @@ var require_extract_zip = __commonJS({
6615
6631
  };
6616
6632
  module.exports = async function(zipPath, opts) {
6617
6633
  debug("creating target directory", opts.dir);
6618
- if (!path37.isAbsolute(opts.dir)) {
6634
+ if (!path38.isAbsolute(opts.dir)) {
6619
6635
  throw new Error("Target directory is expected to be absolute");
6620
6636
  }
6621
6637
  await fs33.mkdir(opts.dir, { recursive: true });
@@ -6647,7 +6663,7 @@ var require_strip_final_newline = __commonJS({
6647
6663
  var require_npm_run_path = __commonJS({
6648
6664
  "node_modules/run-jxa/node_modules/npm-run-path/index.js"(exports, module) {
6649
6665
  "use strict";
6650
- var path37 = __require("path");
6666
+ var path38 = __require("path");
6651
6667
  var pathKey = require_path_key();
6652
6668
  var npmRunPath = (options) => {
6653
6669
  options = {
@@ -6657,16 +6673,16 @@ var require_npm_run_path = __commonJS({
6657
6673
  ...options
6658
6674
  };
6659
6675
  let previous;
6660
- let cwdPath = path37.resolve(options.cwd);
6676
+ let cwdPath = path38.resolve(options.cwd);
6661
6677
  const result = [];
6662
6678
  while (previous !== cwdPath) {
6663
- result.push(path37.join(cwdPath, "node_modules/.bin"));
6679
+ result.push(path38.join(cwdPath, "node_modules/.bin"));
6664
6680
  previous = cwdPath;
6665
- cwdPath = path37.resolve(cwdPath, "..");
6681
+ cwdPath = path38.resolve(cwdPath, "..");
6666
6682
  }
6667
- const execPathDir = path37.resolve(options.cwd, options.execPath, "..");
6683
+ const execPathDir = path38.resolve(options.cwd, options.execPath, "..");
6668
6684
  result.push(execPathDir);
6669
- return result.concat(options.path).join(path37.delimiter);
6685
+ return result.concat(options.path).join(path38.delimiter);
6670
6686
  };
6671
6687
  module.exports = npmRunPath;
6672
6688
  module.exports.default = npmRunPath;
@@ -6676,9 +6692,9 @@ var require_npm_run_path = __commonJS({
6676
6692
  ...options
6677
6693
  };
6678
6694
  const env2 = { ...options.env };
6679
- const path38 = pathKey({ env: env2 });
6680
- options.path = env2[path38];
6681
- env2[path38] = module.exports(options);
6695
+ const path39 = pathKey({ env: env2 });
6696
+ options.path = env2[path39];
6697
+ env2[path39] = module.exports(options);
6682
6698
  return env2;
6683
6699
  };
6684
6700
  }
@@ -7794,7 +7810,7 @@ var require_command = __commonJS({
7794
7810
  var require_execa = __commonJS({
7795
7811
  "node_modules/run-jxa/node_modules/execa/index.js"(exports, module) {
7796
7812
  "use strict";
7797
- var path37 = __require("path");
7813
+ var path38 = __require("path");
7798
7814
  var childProcess3 = __require("child_process");
7799
7815
  var crossSpawn = require_cross_spawn();
7800
7816
  var stripFinalNewline = require_strip_final_newline();
@@ -7836,7 +7852,7 @@ var require_execa = __commonJS({
7836
7852
  };
7837
7853
  options.env = getEnv(options);
7838
7854
  options.stdio = normalizeStdio(options);
7839
- if (process.platform === "win32" && path37.basename(file, ".exe") === "cmd") {
7855
+ if (process.platform === "win32" && path38.basename(file, ".exe") === "cmd") {
7840
7856
  args.unshift("/q");
7841
7857
  }
7842
7858
  return { file, args, options, parsed };
@@ -12118,14 +12134,14 @@ var require_util3 = __commonJS({
12118
12134
  }
12119
12135
  const port = url.port != null ? url.port : url.protocol === "https:" ? 443 : 80;
12120
12136
  let origin = url.origin != null ? url.origin : `${url.protocol || ""}//${url.hostname || ""}:${port}`;
12121
- let path37 = url.path != null ? url.path : `${url.pathname || ""}${url.search || ""}`;
12137
+ let path38 = url.path != null ? url.path : `${url.pathname || ""}${url.search || ""}`;
12122
12138
  if (origin[origin.length - 1] === "/") {
12123
12139
  origin = origin.slice(0, origin.length - 1);
12124
12140
  }
12125
- if (path37 && path37[0] !== "/") {
12126
- path37 = `/${path37}`;
12141
+ if (path38 && path38[0] !== "/") {
12142
+ path38 = `/${path38}`;
12127
12143
  }
12128
- return new URL(`${origin}${path37}`);
12144
+ return new URL(`${origin}${path38}`);
12129
12145
  }
12130
12146
  if (!isHttpOrHttpsPrefixed(url.origin || url.protocol)) {
12131
12147
  throw new InvalidArgumentError("Invalid URL protocol: the URL must start with `http:` or `https:`.");
@@ -12687,9 +12703,9 @@ var require_diagnostics = __commonJS({
12687
12703
  "undici:client:sendHeaders",
12688
12704
  (evt) => {
12689
12705
  const {
12690
- request: { method, path: path37, origin }
12706
+ request: { method, path: path38, origin }
12691
12707
  } = evt;
12692
- debugLog("sending request to %s %s/%s", method, origin, path37);
12708
+ debugLog("sending request to %s %s/%s", method, origin, path38);
12693
12709
  }
12694
12710
  );
12695
12711
  }
@@ -12703,14 +12719,14 @@ var require_diagnostics = __commonJS({
12703
12719
  "undici:request:headers",
12704
12720
  (evt) => {
12705
12721
  const {
12706
- request: { method, path: path37, origin },
12722
+ request: { method, path: path38, origin },
12707
12723
  response: { statusCode }
12708
12724
  } = evt;
12709
12725
  debugLog(
12710
12726
  "received response to %s %s/%s - HTTP %d",
12711
12727
  method,
12712
12728
  origin,
12713
- path37,
12729
+ path38,
12714
12730
  statusCode
12715
12731
  );
12716
12732
  }
@@ -12719,23 +12735,23 @@ var require_diagnostics = __commonJS({
12719
12735
  "undici:request:trailers",
12720
12736
  (evt) => {
12721
12737
  const {
12722
- request: { method, path: path37, origin }
12738
+ request: { method, path: path38, origin }
12723
12739
  } = evt;
12724
- debugLog("trailers received from %s %s/%s", method, origin, path37);
12740
+ debugLog("trailers received from %s %s/%s", method, origin, path38);
12725
12741
  }
12726
12742
  );
12727
12743
  diagnosticsChannel.subscribe(
12728
12744
  "undici:request:error",
12729
12745
  (evt) => {
12730
12746
  const {
12731
- request: { method, path: path37, origin },
12747
+ request: { method, path: path38, origin },
12732
12748
  error
12733
12749
  } = evt;
12734
12750
  debugLog(
12735
12751
  "request to %s %s/%s errored - %s",
12736
12752
  method,
12737
12753
  origin,
12738
- path37,
12754
+ path38,
12739
12755
  error.message
12740
12756
  );
12741
12757
  }
@@ -12830,7 +12846,7 @@ var require_request = __commonJS({
12830
12846
  var kHandler = Symbol("handler");
12831
12847
  var Request = class {
12832
12848
  constructor(origin, {
12833
- path: path37,
12849
+ path: path38,
12834
12850
  method,
12835
12851
  body,
12836
12852
  headers,
@@ -12845,11 +12861,11 @@ var require_request = __commonJS({
12845
12861
  servername,
12846
12862
  throwOnError
12847
12863
  }, handler2) {
12848
- if (typeof path37 !== "string") {
12864
+ if (typeof path38 !== "string") {
12849
12865
  throw new InvalidArgumentError("path must be a string");
12850
- } else if (path37[0] !== "/" && !(path37.startsWith("http://") || path37.startsWith("https://")) && method !== "CONNECT") {
12866
+ } else if (path38[0] !== "/" && !(path38.startsWith("http://") || path38.startsWith("https://")) && method !== "CONNECT") {
12851
12867
  throw new InvalidArgumentError("path must be an absolute URL or start with a slash");
12852
- } else if (invalidPathRegex.test(path37)) {
12868
+ } else if (invalidPathRegex.test(path38)) {
12853
12869
  throw new InvalidArgumentError("invalid request path");
12854
12870
  }
12855
12871
  if (typeof method !== "string") {
@@ -12914,7 +12930,7 @@ var require_request = __commonJS({
12914
12930
  this.completed = false;
12915
12931
  this.aborted = false;
12916
12932
  this.upgrade = upgrade || null;
12917
- this.path = query ? serializePathWithQuery(path37, query) : path37;
12933
+ this.path = query ? serializePathWithQuery(path38, query) : path38;
12918
12934
  this.origin = origin;
12919
12935
  this.idempotent = idempotent == null ? method === "HEAD" || method === "GET" : idempotent;
12920
12936
  this.blocking = blocking ?? this.method !== "HEAD";
@@ -15324,11 +15340,11 @@ var require_util4 = __commonJS({
15324
15340
  var { isUint8Array } = __require("node:util/types");
15325
15341
  var { webidl } = require_webidl();
15326
15342
  var supportedHashes = [];
15327
- var crypto3;
15343
+ var crypto4;
15328
15344
  try {
15329
- crypto3 = __require("node:crypto");
15345
+ crypto4 = __require("node:crypto");
15330
15346
  const possibleRelevantHashes = ["sha256", "sha384", "sha512"];
15331
- supportedHashes = crypto3.getHashes().filter((hash) => possibleRelevantHashes.includes(hash));
15347
+ supportedHashes = crypto4.getHashes().filter((hash) => possibleRelevantHashes.includes(hash));
15332
15348
  } catch {
15333
15349
  }
15334
15350
  function responseURL(response) {
@@ -15631,7 +15647,7 @@ var require_util4 = __commonJS({
15631
15647
  return isOriginPotentiallyTrustworthy(url.origin);
15632
15648
  }
15633
15649
  function bytesMatch(bytes, metadataList) {
15634
- if (crypto3 === void 0) {
15650
+ if (crypto4 === void 0) {
15635
15651
  return true;
15636
15652
  }
15637
15653
  const parsedMetadata = parseMetadata(metadataList);
@@ -15646,7 +15662,7 @@ var require_util4 = __commonJS({
15646
15662
  for (const item of metadata) {
15647
15663
  const algorithm = item.algo;
15648
15664
  const expectedValue = item.hash;
15649
- let actualValue = crypto3.createHash(algorithm).update(bytes).digest("base64");
15665
+ let actualValue = crypto4.createHash(algorithm).update(bytes).digest("base64");
15650
15666
  if (actualValue[actualValue.length - 1] === "=") {
15651
15667
  if (actualValue[actualValue.length - 2] === "=") {
15652
15668
  actualValue = actualValue.slice(0, -2);
@@ -16664,8 +16680,8 @@ var require_body = __commonJS({
16664
16680
  var { multipartFormDataParser } = require_formdata_parser();
16665
16681
  var random;
16666
16682
  try {
16667
- const crypto3 = __require("node:crypto");
16668
- random = (max) => crypto3.randomInt(0, max);
16683
+ const crypto4 = __require("node:crypto");
16684
+ random = (max) => crypto4.randomInt(0, max);
16669
16685
  } catch {
16670
16686
  random = (max) => Math.floor(Math.random() * max);
16671
16687
  }
@@ -17699,7 +17715,7 @@ var require_client_h1 = __commonJS({
17699
17715
  return method !== "GET" && method !== "HEAD" && method !== "OPTIONS" && method !== "TRACE" && method !== "CONNECT";
17700
17716
  }
17701
17717
  function writeH1(client, request) {
17702
- const { method, path: path37, host, upgrade, blocking, reset } = request;
17718
+ const { method, path: path38, host, upgrade, blocking, reset } = request;
17703
17719
  let { body, headers, contentLength } = request;
17704
17720
  const expectsPayload = method === "PUT" || method === "POST" || method === "PATCH" || method === "QUERY" || method === "PROPFIND" || method === "PROPPATCH";
17705
17721
  if (util2.isFormDataLike(body)) {
@@ -17765,7 +17781,7 @@ var require_client_h1 = __commonJS({
17765
17781
  if (blocking) {
17766
17782
  socket[kBlocking] = true;
17767
17783
  }
17768
- let header = `${method} ${path37} HTTP/1.1\r
17784
+ let header = `${method} ${path38} HTTP/1.1\r
17769
17785
  `;
17770
17786
  if (typeof host === "string") {
17771
17787
  header += `host: ${host}\r
@@ -18116,7 +18132,7 @@ var require_client_h2 = __commonJS({
18116
18132
  "packages/cli/node_modules/undici/lib/dispatcher/client-h2.js"(exports, module) {
18117
18133
  "use strict";
18118
18134
  var assert = __require("node:assert");
18119
- var { pipeline: pipeline2 } = __require("node:stream");
18135
+ var { pipeline: pipeline3 } = __require("node:stream");
18120
18136
  var util2 = require_util3();
18121
18137
  var {
18122
18138
  RequestContentLengthMismatchError,
@@ -18322,7 +18338,7 @@ var require_client_h2 = __commonJS({
18322
18338
  function writeH2(client, request) {
18323
18339
  const requestTimeout = request.bodyTimeout ?? client[kBodyTimeout];
18324
18340
  const session = client[kHTTP2Session];
18325
- const { method, path: path37, host, upgrade, expectContinue, signal, headers: reqHeaders } = request;
18341
+ const { method, path: path38, host, upgrade, expectContinue, signal, headers: reqHeaders } = request;
18326
18342
  let { body } = request;
18327
18343
  if (upgrade) {
18328
18344
  util2.errorRequest(client, request, new Error("Upgrade not supported for H2"));
@@ -18393,7 +18409,7 @@ var require_client_h2 = __commonJS({
18393
18409
  stream.setTimeout(requestTimeout);
18394
18410
  return true;
18395
18411
  }
18396
- headers[HTTP2_HEADER_PATH] = path37;
18412
+ headers[HTTP2_HEADER_PATH] = path38;
18397
18413
  headers[HTTP2_HEADER_SCHEME] = "https";
18398
18414
  const expectsPayload = method === "PUT" || method === "POST" || method === "PATCH";
18399
18415
  if (body && typeof body.read === "function") {
@@ -18611,7 +18627,7 @@ var require_client_h2 = __commonJS({
18611
18627
  }
18612
18628
  function writeStream(abort, socket, expectsPayload, h2stream, body, client, request, contentLength) {
18613
18629
  assert(contentLength !== 0 || client[kRunning] === 0, "stream body cannot be pipelined");
18614
- const pipe = pipeline2(
18630
+ const pipe = pipeline3(
18615
18631
  body,
18616
18632
  h2stream,
18617
18633
  (err) => {
@@ -21505,7 +21521,7 @@ var require_api_pipeline = __commonJS({
21505
21521
  util2.destroy(ret, err);
21506
21522
  }
21507
21523
  };
21508
- function pipeline2(opts, handler2) {
21524
+ function pipeline3(opts, handler2) {
21509
21525
  try {
21510
21526
  const pipelineHandler = new PipelineHandler(opts, handler2);
21511
21527
  this.dispatch({ ...opts, body: pipelineHandler.req }, pipelineHandler);
@@ -21514,7 +21530,7 @@ var require_api_pipeline = __commonJS({
21514
21530
  return new PassThrough().destroy(err);
21515
21531
  }
21516
21532
  }
21517
- module.exports = pipeline2;
21533
+ module.exports = pipeline3;
21518
21534
  }
21519
21535
  });
21520
21536
 
@@ -21875,20 +21891,20 @@ var require_mock_utils = __commonJS({
21875
21891
  }
21876
21892
  return normalizedQp;
21877
21893
  }
21878
- function safeUrl(path37) {
21879
- if (typeof path37 !== "string") {
21880
- return path37;
21894
+ function safeUrl(path38) {
21895
+ if (typeof path38 !== "string") {
21896
+ return path38;
21881
21897
  }
21882
- const pathSegments = path37.split("?", 3);
21898
+ const pathSegments = path38.split("?", 3);
21883
21899
  if (pathSegments.length !== 2) {
21884
- return path37;
21900
+ return path38;
21885
21901
  }
21886
21902
  const qp = new URLSearchParams(pathSegments.pop());
21887
21903
  qp.sort();
21888
21904
  return [...pathSegments, qp.toString()].join("?");
21889
21905
  }
21890
- function matchKey(mockDispatch2, { path: path37, method, body, headers }) {
21891
- const pathMatch = matchValue(mockDispatch2.path, path37);
21906
+ function matchKey(mockDispatch2, { path: path38, method, body, headers }) {
21907
+ const pathMatch = matchValue(mockDispatch2.path, path38);
21892
21908
  const methodMatch = matchValue(mockDispatch2.method, method);
21893
21909
  const bodyMatch = typeof mockDispatch2.body !== "undefined" ? matchValue(mockDispatch2.body, body) : true;
21894
21910
  const headersMatch = matchHeaders(mockDispatch2, headers);
@@ -21913,8 +21929,8 @@ var require_mock_utils = __commonJS({
21913
21929
  const basePath = key.query ? serializePathWithQuery(key.path, key.query) : key.path;
21914
21930
  const resolvedPath = typeof basePath === "string" ? safeUrl(basePath) : basePath;
21915
21931
  const resolvedPathWithoutTrailingSlash = removeTrailingSlash(resolvedPath);
21916
- let matchedMockDispatches = mockDispatches.filter(({ consumed }) => !consumed).filter(({ path: path37, ignoreTrailingSlash }) => {
21917
- return ignoreTrailingSlash ? matchValue(removeTrailingSlash(safeUrl(path37)), resolvedPathWithoutTrailingSlash) : matchValue(safeUrl(path37), resolvedPath);
21932
+ let matchedMockDispatches = mockDispatches.filter(({ consumed }) => !consumed).filter(({ path: path38, ignoreTrailingSlash }) => {
21933
+ return ignoreTrailingSlash ? matchValue(removeTrailingSlash(safeUrl(path38)), resolvedPathWithoutTrailingSlash) : matchValue(safeUrl(path38), resolvedPath);
21918
21934
  });
21919
21935
  if (matchedMockDispatches.length === 0) {
21920
21936
  throw new MockNotMatchedError(`Mock dispatch not matched for path '${resolvedPath}'`);
@@ -21952,19 +21968,19 @@ var require_mock_utils = __commonJS({
21952
21968
  mockDispatches.splice(index, 1);
21953
21969
  }
21954
21970
  }
21955
- function removeTrailingSlash(path37) {
21956
- while (path37.endsWith("/")) {
21957
- path37 = path37.slice(0, -1);
21971
+ function removeTrailingSlash(path38) {
21972
+ while (path38.endsWith("/")) {
21973
+ path38 = path38.slice(0, -1);
21958
21974
  }
21959
- if (path37.length === 0) {
21960
- path37 = "/";
21975
+ if (path38.length === 0) {
21976
+ path38 = "/";
21961
21977
  }
21962
- return path37;
21978
+ return path38;
21963
21979
  }
21964
21980
  function buildKey(opts) {
21965
- const { path: path37, method, body, headers, query } = opts;
21981
+ const { path: path38, method, body, headers, query } = opts;
21966
21982
  return {
21967
- path: path37,
21983
+ path: path38,
21968
21984
  method,
21969
21985
  body,
21970
21986
  headers,
@@ -22615,10 +22631,10 @@ var require_pending_interceptors_formatter = __commonJS({
22615
22631
  }
22616
22632
  format(pendingInterceptors) {
22617
22633
  const withPrettyHeaders = pendingInterceptors.map(
22618
- ({ method, path: path37, data: { statusCode }, persist, times, timesInvoked, origin }) => ({
22634
+ ({ method, path: path38, data: { statusCode }, persist, times, timesInvoked, origin }) => ({
22619
22635
  Method: method,
22620
22636
  Origin: origin,
22621
- Path: path37,
22637
+ Path: path38,
22622
22638
  "Status code": statusCode,
22623
22639
  Persistent: persist ? PERSISTENT : NOT_PERSISTENT,
22624
22640
  Invocations: timesInvoked,
@@ -22695,9 +22711,9 @@ var require_mock_agent = __commonJS({
22695
22711
  const acceptNonStandardSearchParameters = this[kMockAgentAcceptsNonStandardSearchParameters];
22696
22712
  const dispatchOpts = { ...opts };
22697
22713
  if (acceptNonStandardSearchParameters && dispatchOpts.path) {
22698
- const [path37, searchParams] = dispatchOpts.path.split("?");
22714
+ const [path38, searchParams] = dispatchOpts.path.split("?");
22699
22715
  const normalizedSearchParams = normalizeSearchParams(searchParams, acceptNonStandardSearchParameters);
22700
- dispatchOpts.path = `${path37}?${normalizedSearchParams}`;
22716
+ dispatchOpts.path = `${path38}?${normalizedSearchParams}`;
22701
22717
  }
22702
22718
  return this[kAgent].dispatch(dispatchOpts, handler2);
22703
22719
  }
@@ -22991,9 +23007,9 @@ var require_redirect_handler = __commonJS({
22991
23007
  return;
22992
23008
  }
22993
23009
  const { origin, pathname, search } = util2.parseURL(new URL(this.location, this.opts.origin && new URL(this.opts.path, this.opts.origin)));
22994
- const path37 = search ? `${pathname}${search}` : pathname;
23010
+ const path38 = search ? `${pathname}${search}` : pathname;
22995
23011
  this.opts.headers = cleanRequestHeaders(this.opts.headers, statusCode === 303, this.opts.origin !== origin);
22996
- this.opts.path = path37;
23012
+ this.opts.path = path38;
22997
23013
  this.opts.origin = origin;
22998
23014
  this.opts.maxRedirections = 0;
22999
23015
  this.opts.query = null;
@@ -26930,7 +26946,7 @@ var require_fetch = __commonJS({
26930
26946
  subresourceSet
26931
26947
  } = require_constants3();
26932
26948
  var EE = __require("node:events");
26933
- var { Readable, pipeline: pipeline2, finished, isErrored, isReadable } = __require("node:stream");
26949
+ var { Readable, pipeline: pipeline3, finished, isErrored, isReadable } = __require("node:stream");
26934
26950
  var { addAbortListener, bufferToLowerCasedHeaderName } = require_util3();
26935
26951
  var { dataURLProcessor, serializeAMimeType, minimizeSupportedMimeType } = require_data_url();
26936
26952
  var { getGlobalDispatcher } = require_global2();
@@ -27873,7 +27889,7 @@ var require_fetch = __commonJS({
27873
27889
  status,
27874
27890
  statusText,
27875
27891
  headersList,
27876
- body: decoders.length ? pipeline2(this.body, ...decoders, (err) => {
27892
+ body: decoders.length ? pipeline3(this.body, ...decoders, (err) => {
27877
27893
  if (err) {
27878
27894
  this.onError(err);
27879
27895
  }
@@ -28695,9 +28711,9 @@ var require_util6 = __commonJS({
28695
28711
  }
28696
28712
  }
28697
28713
  }
28698
- function validateCookiePath(path37) {
28699
- for (let i = 0; i < path37.length; ++i) {
28700
- const code = path37.charCodeAt(i);
28714
+ function validateCookiePath(path38) {
28715
+ for (let i = 0; i < path38.length; ++i) {
28716
+ const code = path38.charCodeAt(i);
28701
28717
  if (code < 32 || // exclude CTLs (0-31)
28702
28718
  code === 127 || // DEL
28703
28719
  code === 59) {
@@ -29582,13 +29598,13 @@ var require_frame = __commonJS({
29582
29598
  "use strict";
29583
29599
  var { maxUnsigned16Bit, opcodes } = require_constants5();
29584
29600
  var BUFFER_SIZE = 8 * 1024;
29585
- var crypto3;
29601
+ var crypto4;
29586
29602
  var buffer = null;
29587
29603
  var bufIdx = BUFFER_SIZE;
29588
29604
  try {
29589
- crypto3 = __require("node:crypto");
29605
+ crypto4 = __require("node:crypto");
29590
29606
  } catch {
29591
- crypto3 = {
29607
+ crypto4 = {
29592
29608
  // not full compatibility, but minimum.
29593
29609
  randomFillSync: function randomFillSync(buffer2, _offset, _size) {
29594
29610
  for (let i = 0; i < buffer2.length; ++i) {
@@ -29601,7 +29617,7 @@ var require_frame = __commonJS({
29601
29617
  function generateMask() {
29602
29618
  if (bufIdx === BUFFER_SIZE) {
29603
29619
  bufIdx = 0;
29604
- crypto3.randomFillSync(buffer ??= Buffer.allocUnsafeSlow(BUFFER_SIZE), 0, BUFFER_SIZE);
29620
+ crypto4.randomFillSync(buffer ??= Buffer.allocUnsafeSlow(BUFFER_SIZE), 0, BUFFER_SIZE);
29605
29621
  }
29606
29622
  return [buffer[bufIdx++], buffer[bufIdx++], buffer[bufIdx++], buffer[bufIdx++]];
29607
29623
  }
@@ -29699,9 +29715,9 @@ var require_connection = __commonJS({
29699
29715
  var { getDecodeSplit } = require_util4();
29700
29716
  var { WebsocketFrameSend } = require_frame();
29701
29717
  var assert = __require("node:assert");
29702
- var crypto3;
29718
+ var crypto4;
29703
29719
  try {
29704
- crypto3 = __require("node:crypto");
29720
+ crypto4 = __require("node:crypto");
29705
29721
  } catch {
29706
29722
  }
29707
29723
  function establishWebSocketConnection(url, protocols, client, handler2, options) {
@@ -29721,7 +29737,7 @@ var require_connection = __commonJS({
29721
29737
  const headersList = getHeadersList(new Headers(options.headers));
29722
29738
  request.headersList = headersList;
29723
29739
  }
29724
- const keyValue = crypto3.randomBytes(16).toString("base64");
29740
+ const keyValue = crypto4.randomBytes(16).toString("base64");
29725
29741
  request.headersList.append("sec-websocket-key", keyValue, true);
29726
29742
  request.headersList.append("sec-websocket-version", "13", true);
29727
29743
  for (const protocol of protocols) {
@@ -29754,7 +29770,7 @@ var require_connection = __commonJS({
29754
29770
  return;
29755
29771
  }
29756
29772
  const secWSAccept = response.headersList.get("Sec-WebSocket-Accept");
29757
- const digest = crypto3.createHash("sha1").update(keyValue + uid).digest("base64");
29773
+ const digest = crypto4.createHash("sha1").update(keyValue + uid).digest("base64");
29758
29774
  if (secWSAccept !== digest) {
29759
29775
  failWebsocketConnection(handler2, 1002, "Incorrect hash received in Sec-WebSocket-Accept header.");
29760
29776
  return;
@@ -31366,7 +31382,7 @@ ${value}`;
31366
31382
  var require_eventsource = __commonJS({
31367
31383
  "packages/cli/node_modules/undici/lib/web/eventsource/eventsource.js"(exports, module) {
31368
31384
  "use strict";
31369
- var { pipeline: pipeline2 } = __require("node:stream");
31385
+ var { pipeline: pipeline3 } = __require("node:stream");
31370
31386
  var { fetching } = require_fetch();
31371
31387
  var { makeRequest } = require_request2();
31372
31388
  var { webidl } = require_webidl();
@@ -31527,7 +31543,7 @@ var require_eventsource = __commonJS({
31527
31543
  ));
31528
31544
  }
31529
31545
  });
31530
- pipeline2(
31546
+ pipeline3(
31531
31547
  response.body.stream,
31532
31548
  eventSourceStream,
31533
31549
  (error) => {
@@ -31737,11 +31753,11 @@ var require_undici = __commonJS({
31737
31753
  if (typeof opts.path !== "string") {
31738
31754
  throw new InvalidArgumentError("invalid opts.path");
31739
31755
  }
31740
- let path37 = opts.path;
31756
+ let path38 = opts.path;
31741
31757
  if (!opts.path.startsWith("/")) {
31742
- path37 = `/${path37}`;
31758
+ path38 = `/${path38}`;
31743
31759
  }
31744
- url = new URL(util2.parseOrigin(url).origin + path37);
31760
+ url = new URL(util2.parseOrigin(url).origin + path38);
31745
31761
  } else {
31746
31762
  if (!opts) {
31747
31763
  opts = typeof url === "object" ? url : {};
@@ -32413,15 +32429,20 @@ function useKeypress(onKeypress, {
32413
32429
  priority
32414
32430
  }) {
32415
32431
  const { subscribe, unsubscribe } = useKeypressContext();
32432
+ const onKeypressRef = (0, import_react2.useRef)(onKeypress);
32433
+ (0, import_react2.useEffect)(() => {
32434
+ onKeypressRef.current = onKeypress;
32435
+ }, [onKeypress]);
32416
32436
  (0, import_react2.useEffect)(() => {
32417
32437
  if (!isActive) {
32418
32438
  return;
32419
32439
  }
32420
- subscribe(onKeypress, priority);
32440
+ const handler2 = (key) => onKeypressRef.current(key);
32441
+ subscribe(handler2, priority);
32421
32442
  return () => {
32422
- unsubscribe(onKeypress);
32443
+ unsubscribe(handler2);
32423
32444
  };
32424
- }, [isActive, onKeypress, subscribe, unsubscribe, priority]);
32445
+ }, [isActive, subscribe, unsubscribe, priority]);
32425
32446
  }
32426
32447
 
32427
32448
  // packages/cli/src/ui/hooks/useFocus.ts
@@ -36639,13 +36660,47 @@ var NoColorTheme = new Theme(
36639
36660
 
36640
36661
  // packages/cli/src/ui/themes/theme-manager.ts
36641
36662
  import process2 from "node:process";
36663
+ var import_strip_json_comments = __toESM(require_strip_json_comments(), 1);
36664
+ var SINGLE_CUSTOM_THEME_KEYS = /* @__PURE__ */ new Set([
36665
+ "type",
36666
+ "name",
36667
+ "text",
36668
+ "background",
36669
+ "border",
36670
+ "ui",
36671
+ "status",
36672
+ "Background",
36673
+ "Foreground",
36674
+ "LightBlue",
36675
+ "AccentBlue",
36676
+ "AccentPurple",
36677
+ "AccentCyan",
36678
+ "AccentGreen",
36679
+ "AccentYellow",
36680
+ "AccentRed",
36681
+ "DiffAdded",
36682
+ "DiffRemoved",
36683
+ "Comment",
36684
+ "Gray",
36685
+ "DarkGray",
36686
+ "GradientColors"
36687
+ ]);
36688
+ function isPlainRecord(value) {
36689
+ return typeof value === "object" && value !== null && !Array.isArray(value);
36690
+ }
36691
+ function isStringValue(value) {
36692
+ return typeof value === "string";
36693
+ }
36642
36694
  var DEFAULT_THEME = DefaultDark;
36643
36695
  var ThemeManager = class {
36644
36696
  availableThemes;
36645
36697
  activeTheme;
36698
+ userThemes = /* @__PURE__ */ new Map();
36699
+ userThemesLoaded = false;
36646
36700
  settingsThemes = /* @__PURE__ */ new Map();
36647
36701
  extensionThemes = /* @__PURE__ */ new Map();
36648
36702
  fileThemes = /* @__PURE__ */ new Map();
36703
+ fileThemesByPath = /* @__PURE__ */ new Map();
36649
36704
  terminalBackground;
36650
36705
  // Cache for dynamic colors
36651
36706
  cachedColors;
@@ -36729,8 +36784,181 @@ var ThemeManager = class {
36729
36784
  debugLogger.warn(`Invalid custom theme "${name}": ${validation.error}`);
36730
36785
  }
36731
36786
  }
36732
- if (this.activeTheme && this.activeTheme.type === "custom" && this.settingsThemes.has(this.activeTheme.name)) {
36733
- this.activeTheme = this.settingsThemes.get(this.activeTheme.name);
36787
+ if (this.activeTheme && this.activeTheme.type === "custom" && !this.userThemes.has(this.activeTheme.name)) {
36788
+ const updatedSettingsTheme = this.settingsThemes.get(
36789
+ this.activeTheme.name
36790
+ );
36791
+ if (updatedSettingsTheme) {
36792
+ this.activeTheme = updatedSettingsTheme;
36793
+ this.clearCache();
36794
+ }
36795
+ }
36796
+ }
36797
+ /**
36798
+ * Returns candidate standalone theme.json paths in ascending precedence order:
36799
+ * 1. ~/.config/gemini/theme.json
36800
+ * 2. $XDG_CONFIG_HOME/gemini/theme.json (if XDG_CONFIG_HOME is set)
36801
+ * 3. ~/.gemini/theme.json (respecting GEMINI_CLI_HOME via homedir())
36802
+ */
36803
+ getUserThemePaths() {
36804
+ const homeDir = this.homedir();
36805
+ if (!homeDir) {
36806
+ return [];
36807
+ }
36808
+ const candidates = [
36809
+ path.join(homeDir, ".config", "gemini", "theme.json")
36810
+ ];
36811
+ const xdgConfigHome = process2.env["XDG_CONFIG_HOME"];
36812
+ if (xdgConfigHome) {
36813
+ candidates.push(path.join(xdgConfigHome, "gemini", "theme.json"));
36814
+ }
36815
+ candidates.push(path.join(homeDir, GEMINI_DIR, "theme.json"));
36816
+ const deduplicatedByKey = /* @__PURE__ */ new Map();
36817
+ for (const candidate of candidates) {
36818
+ const resolved = path.resolve(candidate);
36819
+ const key = normalizePath(resolved);
36820
+ deduplicatedByKey.delete(key);
36821
+ deduplicatedByKey.set(key, resolved);
36822
+ }
36823
+ return Array.from(deduplicatedByKey.values());
36824
+ }
36825
+ parseUserThemeEntries(parsed) {
36826
+ if (!isPlainRecord(parsed)) {
36827
+ return [];
36828
+ }
36829
+ const keys = Object.keys(parsed);
36830
+ if (keys.length === 0) {
36831
+ return [];
36832
+ }
36833
+ if (parsed["type"] !== "custom") {
36834
+ const customThemes = parsed["customThemes"];
36835
+ if (isPlainRecord(customThemes)) {
36836
+ return Object.entries(customThemes).filter(
36837
+ (entry) => isPlainRecord(entry[1])
36838
+ );
36839
+ }
36840
+ const ui2 = parsed["ui"];
36841
+ if (isPlainRecord(ui2)) {
36842
+ const uiCustomThemes = ui2["customThemes"];
36843
+ if (isPlainRecord(uiCustomThemes)) {
36844
+ return Object.entries(uiCustomThemes).filter(
36845
+ (entry) => isPlainRecord(entry[1])
36846
+ );
36847
+ }
36848
+ }
36849
+ }
36850
+ const rawName = parsed["name"];
36851
+ const hasNestedCustomTheme = Object.values(parsed).some(
36852
+ (val) => isPlainRecord(val) && val["type"] === "custom"
36853
+ );
36854
+ const isSingleTheme = !hasNestedCustomTheme && (parsed["type"] === "custom" || isStringValue(rawName) || keys.every((key) => SINGLE_CUSTOM_THEME_KEYS.has(key)));
36855
+ if (isSingleTheme) {
36856
+ const themeName = isStringValue(rawName) && rawName.trim().length > 0 ? rawName : "custom";
36857
+ return [[themeName, parsed]];
36858
+ }
36859
+ return Object.entries(parsed).filter(
36860
+ (entry) => isPlainRecord(entry[1])
36861
+ );
36862
+ }
36863
+ resolveRealPath(targetPath) {
36864
+ return stripExtendedLengthPrefix(this.fs.realpathSync(targetPath));
36865
+ }
36866
+ resolveCanonicalDirectory(dirPath) {
36867
+ const resolvedDir = path.resolve(dirPath);
36868
+ try {
36869
+ const canonical = this.resolveRealPath(resolvedDir);
36870
+ if (isStringValue(canonical) && canonical.length > 0) {
36871
+ return path.resolve(canonical);
36872
+ }
36873
+ } catch {
36874
+ }
36875
+ return resolvedDir;
36876
+ }
36877
+ /**
36878
+ * Loads custom themes from standalone user theme.json files
36879
+ * (~/.gemini/theme.json and XDG fallback ~/.config/gemini/theme.json).
36880
+ */
36881
+ loadUserThemes() {
36882
+ this.userThemes.clear();
36883
+ this.userThemesLoaded = true;
36884
+ const homeDir = this.homedir();
36885
+ if (!homeDir) {
36886
+ return;
36887
+ }
36888
+ const trustedRoots = [this.resolveCanonicalDirectory(homeDir)];
36889
+ const xdgConfigHome = process2.env["XDG_CONFIG_HOME"];
36890
+ if (xdgConfigHome) {
36891
+ trustedRoots.push(this.resolveCanonicalDirectory(xdgConfigHome));
36892
+ }
36893
+ for (const candidatePath of this.getUserThemePaths()) {
36894
+ try {
36895
+ if (!this.fs.existsSync(candidatePath)) {
36896
+ continue;
36897
+ }
36898
+ const canonicalPath = this.resolveRealPath(candidatePath);
36899
+ if (!trustedRoots.some((rootDir) => isSubpath(rootDir, canonicalPath))) {
36900
+ debugLogger.warn(
36901
+ `Theme file at "${candidatePath}" resolves outside trusted configuration directories. Only load themes from trusted sources.`
36902
+ );
36903
+ continue;
36904
+ }
36905
+ const rawContent = this.fs.readFileSync(canonicalPath, "utf-8");
36906
+ const parsed = JSON.parse((0, import_strip_json_comments.default)(rawContent));
36907
+ if (!isPlainRecord(parsed)) {
36908
+ debugLogger.warn(
36909
+ `Invalid theme file "${candidatePath}": expected a JSON object.`
36910
+ );
36911
+ continue;
36912
+ }
36913
+ const entries = this.parseUserThemeEntries(parsed);
36914
+ for (const [entryKey, rawThemeConfig] of entries) {
36915
+ const rawConfigName = rawThemeConfig.name;
36916
+ const resolvedName = isStringValue(rawConfigName) && rawConfigName.trim().length > 0 ? rawConfigName : entryKey;
36917
+ const candidateConfig = {
36918
+ ...rawThemeConfig,
36919
+ name: resolvedName
36920
+ };
36921
+ const validation = validateCustomTheme(candidateConfig);
36922
+ if (!validation.isValid) {
36923
+ debugLogger.warn(
36924
+ `Invalid custom theme "${entryKey}" in "${candidatePath}": ${validation.error}`
36925
+ );
36926
+ continue;
36927
+ }
36928
+ if (validation.warning) {
36929
+ debugLogger.warn(`Theme "${entryKey}": ${validation.warning}`);
36930
+ }
36931
+ const themeWithDefaults = {
36932
+ ...DEFAULT_THEME.colors,
36933
+ ...candidateConfig,
36934
+ name: resolvedName,
36935
+ type: "custom"
36936
+ };
36937
+ try {
36938
+ const theme2 = createCustomTheme(themeWithDefaults);
36939
+ this.userThemes.set(resolvedName, theme2);
36940
+ } catch (error) {
36941
+ debugLogger.warn(
36942
+ `Failed to load custom theme "${entryKey}" from "${candidatePath}":`,
36943
+ error
36944
+ );
36945
+ }
36946
+ }
36947
+ } catch (error) {
36948
+ if (!(error instanceof Error && "code" in error && error.code === "ENOENT")) {
36949
+ debugLogger.warn(
36950
+ `Could not load themes from "${candidatePath}":`,
36951
+ error
36952
+ );
36953
+ }
36954
+ }
36955
+ }
36956
+ this.clearCache();
36957
+ if (this.activeTheme && this.activeTheme.type === "custom") {
36958
+ const updatedUserTheme = this.userThemes.get(this.activeTheme.name);
36959
+ if (updatedUserTheme) {
36960
+ this.activeTheme = updatedUserTheme;
36961
+ }
36734
36962
  }
36735
36963
  }
36736
36964
  /**
@@ -36808,12 +37036,21 @@ var ThemeManager = class {
36808
37036
  clearExtensionThemes() {
36809
37037
  this.extensionThemes.clear();
36810
37038
  }
37039
+ /**
37040
+ * Clears all standalone user themes loaded from theme.json files.
37041
+ * This is primarily for testing purposes to reset state between tests.
37042
+ */
37043
+ clearUserThemes() {
37044
+ this.userThemes.clear();
37045
+ this.userThemesLoaded = false;
37046
+ }
36811
37047
  /**
36812
37048
  * Clears all themes loaded from files.
36813
37049
  * This is primarily for testing purposes to reset state between tests.
36814
37050
  */
36815
37051
  clearFileThemes() {
36816
37052
  this.fileThemes.clear();
37053
+ this.fileThemesByPath.clear();
36817
37054
  }
36818
37055
  /**
36819
37056
  * Re-initializes the ThemeManager with new dependencies.
@@ -36826,6 +37063,10 @@ var ThemeManager = class {
36826
37063
  if (dependencies.homedir) {
36827
37064
  this.homedir = dependencies.homedir;
36828
37065
  }
37066
+ this.userThemes.clear();
37067
+ this.userThemesLoaded = false;
37068
+ this.fileThemes.clear();
37069
+ this.fileThemesByPath.clear();
36829
37070
  }
36830
37071
  /**
36831
37072
  * Resets the ThemeManager state to defaults.
@@ -36835,9 +37076,12 @@ var ThemeManager = class {
36835
37076
  if (dependencies) {
36836
37077
  this.reinitialize(dependencies);
36837
37078
  }
37079
+ this.userThemes.clear();
37080
+ this.userThemesLoaded = false;
36838
37081
  this.settingsThemes.clear();
36839
37082
  this.extensionThemes.clear();
36840
37083
  this.fileThemes.clear();
37084
+ this.fileThemesByPath.clear();
36841
37085
  this.activeTheme = DEFAULT_THEME;
36842
37086
  this.terminalBackground = void 0;
36843
37087
  this.clearCache();
@@ -36865,7 +37109,7 @@ var ThemeManager = class {
36865
37109
  const isBuiltIn = this.availableThemes.some(
36866
37110
  (t) => t.name === this.activeTheme.name
36867
37111
  );
36868
- const isCustom = [...this.settingsThemes.values()].includes(this.activeTheme) || [...this.extensionThemes.values()].includes(this.activeTheme) || [...this.fileThemes.values()].includes(this.activeTheme);
37112
+ const isCustom = this.userThemes.get(this.activeTheme.name) === this.activeTheme || this.settingsThemes.get(this.activeTheme.name) === this.activeTheme || this.extensionThemes.get(this.activeTheme.name) === this.activeTheme || this.fileThemes.get(this.activeTheme.name) === this.activeTheme;
36869
37113
  if (isBuiltIn || isCustom) {
36870
37114
  return this.activeTheme;
36871
37115
  }
@@ -36972,11 +37216,16 @@ var ThemeManager = class {
36972
37216
  return themeType === backgroundType;
36973
37217
  }
36974
37218
  _getAllCustomThemes() {
36975
- return [
36976
- ...Array.from(this.settingsThemes.values()),
36977
- ...Array.from(this.extensionThemes.values()),
36978
- ...Array.from(this.fileThemes.values())
36979
- ];
37219
+ if (!this.userThemesLoaded) {
37220
+ this.loadUserThemes();
37221
+ }
37222
+ const mergedByName = new Map([
37223
+ ...this.fileThemes,
37224
+ ...this.extensionThemes,
37225
+ ...this.settingsThemes,
37226
+ ...this.userThemes
37227
+ ]);
37228
+ return Array.from(mergedByName.values());
36980
37229
  }
36981
37230
  /**
36982
37231
  * Gets a list of custom theme names.
@@ -36991,7 +37240,10 @@ var ThemeManager = class {
36991
37240
  * @returns True if the theme is custom.
36992
37241
  */
36993
37242
  isCustomTheme(themeName) {
36994
- return this.settingsThemes.has(themeName) || this.extensionThemes.has(themeName) || this.fileThemes.has(themeName);
37243
+ if (!this.userThemesLoaded) {
37244
+ this.loadUserThemes();
37245
+ }
37246
+ return this.userThemes.has(themeName) || this.settingsThemes.has(themeName) || this.extensionThemes.has(themeName) || this.fileThemes.has(themeName);
36995
37247
  }
36996
37248
  /**
36997
37249
  * Returns a list of available theme names.
@@ -37052,19 +37304,25 @@ var ThemeManager = class {
37052
37304
  }
37053
37305
  loadThemeFromFile(themePath) {
37054
37306
  try {
37055
- const canonicalPath = this.fs.realpathSync(path.resolve(themePath));
37056
- if (this.fileThemes.has(canonicalPath)) {
37057
- return this.fileThemes.get(canonicalPath);
37307
+ const canonicalPath = this.resolveRealPath(path.resolve(themePath));
37308
+ if (this.fileThemesByPath.has(canonicalPath)) {
37309
+ return this.fileThemesByPath.get(canonicalPath);
37310
+ }
37311
+ const rawHome = this.homedir();
37312
+ if (!rawHome) {
37313
+ return void 0;
37058
37314
  }
37059
- const homeDir = path.resolve(this.homedir());
37060
- if (!canonicalPath.startsWith(homeDir)) {
37315
+ const canonicalHome = this.resolveCanonicalDirectory(rawHome);
37316
+ if (!isSubpath(canonicalHome, canonicalPath)) {
37061
37317
  debugLogger.warn(
37062
37318
  `Theme file at "${themePath}" is outside your home directory. Only load themes from trusted sources.`
37063
37319
  );
37064
37320
  return void 0;
37065
37321
  }
37066
37322
  const themeContent = this.fs.readFileSync(canonicalPath, "utf-8");
37067
- const customThemeConfig = JSON.parse(themeContent);
37323
+ const customThemeConfig = JSON.parse(
37324
+ (0, import_strip_json_comments.default)(themeContent)
37325
+ );
37068
37326
  const validation = validateCustomTheme(customThemeConfig);
37069
37327
  if (!validation.isValid) {
37070
37328
  debugLogger.warn(
@@ -37082,7 +37340,8 @@ var ThemeManager = class {
37082
37340
  type: "custom"
37083
37341
  };
37084
37342
  const theme2 = createCustomTheme(themeWithDefaults);
37085
- this.fileThemes.set(canonicalPath, theme2);
37343
+ this.fileThemesByPath.set(canonicalPath, theme2);
37344
+ this.fileThemes.set(theme2.name, theme2);
37086
37345
  return theme2;
37087
37346
  } catch (error) {
37088
37347
  if (!(error instanceof Error && "code" in error && error.code === "ENOENT")) {
@@ -37107,6 +37366,12 @@ var ThemeManager = class {
37107
37366
  if (this.isPath(themeName)) {
37108
37367
  return this.loadThemeFromFile(themeName);
37109
37368
  }
37369
+ if (!this.userThemesLoaded) {
37370
+ this.loadUserThemes();
37371
+ }
37372
+ if (this.userThemes.has(themeName)) {
37373
+ return this.userThemes.get(themeName);
37374
+ }
37110
37375
  if (this.settingsThemes.has(themeName)) {
37111
37376
  return this.settingsThemes.get(themeName);
37112
37377
  }
@@ -38661,6 +38926,7 @@ async function getMissingSettings(extensionConfig, extensionId, workspaceDir) {
38661
38926
 
38662
38927
  // packages/cli/src/config/extension-manager.ts
38663
38928
  var import_chalk2 = __toESM(require_source(), 1);
38929
+ var import_proper_lockfile = __toESM(require_proper_lockfile(), 1);
38664
38930
  import * as fs12 from "node:fs";
38665
38931
  import * as path9 from "node:path";
38666
38932
  import { stat } from "node:fs/promises";
@@ -38708,8 +38974,8 @@ var Override = class _Override {
38708
38974
  output() {
38709
38975
  return `${this.isDisable ? "!" : ""}${this.baseRule}${this.includeSubdirs ? "*" : ""}`;
38710
38976
  }
38711
- matchesPath(path37) {
38712
- return this.asRegex().test(path37);
38977
+ matchesPath(path38) {
38978
+ return this.asRegex().test(path38);
38713
38979
  }
38714
38980
  };
38715
38981
  var ensureLeadingAndTrailingSlash = function(dirPath) {
@@ -38832,7 +39098,7 @@ var ExtensionEnablementManager = class {
38832
39098
  };
38833
39099
 
38834
39100
  // packages/cli/src/config/extension-manager.ts
38835
- import { createHash as createHash2, randomUUID } from "node:crypto";
39101
+ import { createHash as createHash2, randomUUID as randomUUID2 } from "node:crypto";
38836
39102
 
38837
39103
  // packages/cli/src/config/extension.ts
38838
39104
  import * as fs8 from "node:fs";
@@ -38929,10 +39195,12 @@ function extensionUpdatesReducer(state, action) {
38929
39195
  }
38930
39196
 
38931
39197
  // packages/cli/src/config/extensions/github.ts
39198
+ import * as crypto2 from "node:crypto";
38932
39199
  import * as os3 from "node:os";
38933
39200
  import * as https2 from "node:https";
38934
39201
  import * as fs10 from "node:fs";
38935
39202
  import * as path8 from "node:path";
39203
+ import { pipeline } from "node:stream/promises";
38936
39204
 
38937
39205
  // packages/cli/node_modules/tar/dist/esm/index.min.js
38938
39206
  import Hr from "events";
@@ -41847,6 +42115,14 @@ import * as https from "node:https";
41847
42115
  function getGitHubToken() {
41848
42116
  return process.env["GITHUB_TOKEN"] || void 0;
41849
42117
  }
42118
+ function isTrustedGitHubUrl(url) {
42119
+ try {
42120
+ const parsedUrl = new URL(url);
42121
+ return parsedUrl.protocol === "https:" && (parsedUrl.hostname === "github.com" || parsedUrl.hostname.endsWith(".github.com"));
42122
+ } catch {
42123
+ return false;
42124
+ }
42125
+ }
41850
42126
  var lookupPublicAddress = (hostname, options, callback) => safeLookup(
41851
42127
  hostname,
41852
42128
  {
@@ -41856,6 +42132,7 @@ var lookupPublicAddress = (hostname, options, callback) => safeLookup(
41856
42132
  callback
41857
42133
  );
41858
42134
  var REDIRECT_STATUS_CODES = /* @__PURE__ */ new Set([301, 302, 303, 307, 308]);
42135
+ var REQUEST_TIMEOUT_MS = 3e4;
41859
42136
  async function fetchJson(url, redirectCount = 0) {
41860
42137
  if (!await validateUrlDestination(url)) {
41861
42138
  throw new Error(`Access to blocked or private host ${url} is not allowed.`);
@@ -41864,14 +42141,8 @@ async function fetchJson(url, redirectCount = 0) {
41864
42141
  "User-Agent": "gemini-cli"
41865
42142
  };
41866
42143
  const token = getGitHubToken();
41867
- if (token) {
41868
- try {
41869
- const parsedUrl = new URL(url);
41870
- if (parsedUrl.protocol === "https:" && (parsedUrl.hostname === "github.com" || parsedUrl.hostname.endsWith(".github.com"))) {
41871
- headers.Authorization = `token ${token}`;
41872
- }
41873
- } catch {
41874
- }
42144
+ if (token && isTrustedGitHubUrl(url)) {
42145
+ headers.Authorization = `token ${token}`;
41875
42146
  }
41876
42147
  return new Promise((resolve9, reject) => {
41877
42148
  let settled = false;
@@ -41896,7 +42167,7 @@ async function fetchJson(url, redirectCount = 0) {
41896
42167
  const requestOptions = {
41897
42168
  headers,
41898
42169
  lookup: lookupPublicAddress,
41899
- timeout: 3e4
42170
+ timeout: REQUEST_TIMEOUT_MS
41900
42171
  };
41901
42172
  const req = https.get(url, requestOptions, (res) => {
41902
42173
  res.on(
@@ -41989,7 +42260,9 @@ async function fetchJson(url, redirectCount = 0) {
41989
42260
  });
41990
42261
  req.on("error", (error) => failUnlessRedirecting(() => error));
41991
42262
  req.on("timeout", () => {
41992
- failUnlessRedirecting(() => new Error("Request timed out after 30000ms"));
42263
+ failUnlessRedirecting(
42264
+ () => new Error(`Request timed out after ${REQUEST_TIMEOUT_MS}ms`)
42265
+ );
41993
42266
  req.destroy();
41994
42267
  });
41995
42268
  });
@@ -42059,7 +42332,7 @@ function tryParseGithubUrl(source2) {
42059
42332
  );
42060
42333
  }
42061
42334
  const owner = parts[0];
42062
- const repo = parts[1].replace(".git", "");
42335
+ const repo = parts[1].replace(/\.git$/i, "");
42063
42336
  return {
42064
42337
  owner,
42065
42338
  repo
@@ -42340,39 +42613,175 @@ function findReleaseAsset(assets) {
42340
42613
  return void 0;
42341
42614
  }
42342
42615
  async function downloadFile(url, dest, options, redirectCount = 0) {
42616
+ let parsedUrl;
42617
+ try {
42618
+ parsedUrl = new URL(url);
42619
+ } catch (error) {
42620
+ throw new Error(`Invalid download URL ${url}: ${getErrorMessage(error)}`, {
42621
+ cause: error
42622
+ });
42623
+ }
42624
+ if (parsedUrl.protocol !== "https:") {
42625
+ throw new Error(
42626
+ `Refusing to download from insecure protocol ${parsedUrl.protocol} for URL ${url}. Only HTTPS is supported.`
42627
+ );
42628
+ }
42629
+ const requestUrl = parsedUrl.toString();
42630
+ if (!await validateUrlDestination(requestUrl)) {
42631
+ throw new Error(
42632
+ `Access to blocked or private host ${requestUrl} is not allowed.`
42633
+ );
42634
+ }
42343
42635
  const headers = {
42344
42636
  "User-agent": "gemini-cli",
42345
42637
  Accept: "application/octet-stream",
42346
42638
  ...options?.headers
42347
42639
  };
42640
+ const trustedGitHubUrl = isTrustedGitHubUrl(requestUrl);
42641
+ if (!trustedGitHubUrl) {
42642
+ for (const key of Object.keys(headers)) {
42643
+ if (key.toLowerCase() === "authorization") {
42644
+ delete headers[key];
42645
+ }
42646
+ }
42647
+ }
42348
42648
  const token = getGitHubToken();
42349
- if (token) {
42649
+ if (token && trustedGitHubUrl) {
42350
42650
  headers["Authorization"] = `token ${token}`;
42351
42651
  }
42352
- return new Promise((resolve9, reject) => {
42353
- https2.get(url, { headers }, (res) => {
42354
- if (res.statusCode === 302 || res.statusCode === 301) {
42355
- if (redirectCount >= 10) {
42356
- return reject(new Error("Too many redirects"));
42652
+ let tempDest;
42653
+ let downloadPipeline;
42654
+ try {
42655
+ await new Promise((resolve9, reject) => {
42656
+ let settled = false;
42657
+ let isRedirecting = false;
42658
+ let responseStream;
42659
+ const settleResolve = () => {
42660
+ if (!settled) {
42661
+ settled = true;
42662
+ resolve9();
42357
42663
  }
42358
- if (!res.headers.location) {
42359
- return reject(
42360
- new Error("Redirect response missing Location header")
42664
+ };
42665
+ const settleReject = (error) => {
42666
+ if (!settled) {
42667
+ settled = true;
42668
+ reject(
42669
+ error instanceof Error ? error : new Error(getErrorMessage(error))
42361
42670
  );
42362
42671
  }
42363
- downloadFile(res.headers.location, dest, options, redirectCount + 1).then(resolve9).catch(reject);
42364
- return;
42672
+ };
42673
+ const requestOptions = {
42674
+ headers,
42675
+ lookup: lookupPublicAddress,
42676
+ timeout: REQUEST_TIMEOUT_MS
42677
+ };
42678
+ const req = https2.get(requestUrl, requestOptions, (res) => {
42679
+ res.on("error", (error) => {
42680
+ if (!isRedirecting) {
42681
+ settleReject(error);
42682
+ }
42683
+ });
42684
+ if (res.statusCode && REDIRECT_STATUS_CODES.has(res.statusCode)) {
42685
+ if (redirectCount >= 10) {
42686
+ res.resume?.();
42687
+ settleReject(new Error("Too many redirects"));
42688
+ return;
42689
+ }
42690
+ if (!res.headers.location) {
42691
+ res.resume?.();
42692
+ settleReject(
42693
+ new Error("Redirect response missing Location header")
42694
+ );
42695
+ return;
42696
+ }
42697
+ let redirectUrl;
42698
+ try {
42699
+ redirectUrl = new URL(res.headers.location, requestUrl).toString();
42700
+ } catch (error) {
42701
+ res.resume?.();
42702
+ settleReject(
42703
+ new Error(
42704
+ `Invalid redirect URL from ${requestUrl} (status ${res.statusCode}): ${getErrorMessage(error)}`,
42705
+ { cause: error }
42706
+ )
42707
+ );
42708
+ return;
42709
+ }
42710
+ isRedirecting = true;
42711
+ res.resume?.();
42712
+ void downloadFile(redirectUrl, dest, options, redirectCount + 1).then(
42713
+ settleResolve,
42714
+ settleReject
42715
+ );
42716
+ return;
42717
+ }
42718
+ if (res.statusCode !== 200) {
42719
+ res.resume?.();
42720
+ settleReject(
42721
+ new Error(`Request failed with status code ${res.statusCode}`)
42722
+ );
42723
+ return;
42724
+ }
42725
+ responseStream = res;
42726
+ const currentTempDest = `${dest}.${crypto2.randomUUID()}.tmp`;
42727
+ tempDest = currentTempDest;
42728
+ let file;
42729
+ try {
42730
+ file = fs10.createWriteStream(currentTempDest);
42731
+ } catch (error) {
42732
+ res.destroy?.();
42733
+ settleReject(error);
42734
+ return;
42735
+ }
42736
+ file.on("error", settleReject);
42737
+ downloadPipeline = pipeline(res, file);
42738
+ void downloadPipeline.then(() => {
42739
+ if (res.complete === false) {
42740
+ settleReject(
42741
+ new Error(
42742
+ `Response ended prematurely while downloading ${requestUrl}`
42743
+ )
42744
+ );
42745
+ return;
42746
+ }
42747
+ settleResolve();
42748
+ }, settleReject);
42749
+ });
42750
+ req.on("error", (error) => {
42751
+ if (isRedirecting) {
42752
+ return;
42753
+ }
42754
+ settleReject(error);
42755
+ responseStream?.destroy?.();
42756
+ });
42757
+ req.on("timeout", () => {
42758
+ if (!isRedirecting) {
42759
+ settleReject(
42760
+ new Error(`Request timed out after ${REQUEST_TIMEOUT_MS}ms`)
42761
+ );
42762
+ responseStream?.destroy?.();
42763
+ }
42764
+ req.destroy?.();
42765
+ });
42766
+ });
42767
+ if (tempDest) {
42768
+ await fs10.promises.rename(tempDest, dest);
42769
+ }
42770
+ } catch (error) {
42771
+ if (downloadPipeline) {
42772
+ try {
42773
+ await downloadPipeline;
42774
+ } catch {
42365
42775
  }
42366
- if (res.statusCode !== 200) {
42367
- return reject(
42368
- new Error(`Request failed with status code ${res.statusCode}`)
42369
- );
42776
+ }
42777
+ if (tempDest) {
42778
+ try {
42779
+ await fs10.promises.unlink(tempDest);
42780
+ } catch {
42370
42781
  }
42371
- const file = fs10.createWriteStream(dest);
42372
- res.pipe(file);
42373
- file.on("finish", () => file.close(resolve9));
42374
- }).on("error", reject);
42375
- });
42782
+ }
42783
+ throw error;
42784
+ }
42376
42785
  }
42377
42786
  async function extractFile(file, dest) {
42378
42787
  if (file.endsWith(".tar.gz")) {
@@ -42583,7 +42992,7 @@ async function retryWithBackoff(fn2, options = {}) {
42583
42992
  }
42584
42993
  throw new Error("Unreachable");
42585
42994
  }
42586
- async function removeDirectoryWithRetry(path37, options = {}) {
42995
+ async function removeDirectoryWithRetry(path38, options = {}) {
42587
42996
  const { recursive = true, force = true, ...retryOptions } = options;
42588
42997
  const isRetryableError = (error) => {
42589
42998
  if (isNodeError(error)) {
@@ -42591,7 +43000,7 @@ async function removeDirectoryWithRetry(path37, options = {}) {
42591
43000
  }
42592
43001
  return false;
42593
43002
  };
42594
- await retryWithBackoff(() => fs11.promises.rm(path37, { recursive, force }), {
43003
+ await retryWithBackoff(() => fs11.promises.rm(path38, { recursive, force }), {
42595
43004
  maxRetries: 5,
42596
43005
  initialDelay: 100,
42597
43006
  shouldRetry: isRetryableError,
@@ -42600,6 +43009,9 @@ async function removeDirectoryWithRetry(path37, options = {}) {
42600
43009
  }
42601
43010
 
42602
43011
  // packages/cli/src/config/extension-manager.ts
43012
+ var INSTALL_LOCK_SUFFIX = ".lock";
43013
+ var INSTALL_LOCK_STALE_MS = 15e3;
43014
+ var INSTALL_LOCK_RETRIES = { retries: 15, minTimeout: 200, maxTimeout: 500 };
42603
43015
  var ExtensionManager = class extends ExtensionLoader {
42604
43016
  extensionEnablementManager;
42605
43017
  integrityManager;
@@ -42620,7 +43032,7 @@ var ExtensionManager = class extends ExtensionLoader {
42620
43032
  this.telemetryConfig = new Config({
42621
43033
  telemetry: options.settings.telemetry,
42622
43034
  interactive: false,
42623
- sessionId: randomUUID(),
43035
+ sessionId: randomUUID2(),
42624
43036
  clientVersion: options.clientVersion ?? "unknown",
42625
43037
  targetDir: options.workspaceDir,
42626
43038
  cwd: options.workspaceDir,
@@ -42744,6 +43156,7 @@ Would you like to attempt to install via "git clone" instead?`
42744
43156
  } else {
42745
43157
  throw new Error(`Unsupported install type: ${installMetadata.type}`);
42746
43158
  }
43159
+ let releaseLock;
42747
43160
  try {
42748
43161
  newExtensionConfig = await this.loadExtensionConfig(localSourcePath);
42749
43162
  const newExtensionName = newExtensionConfig.name;
@@ -42792,11 +43205,19 @@ Would you like to attempt to install via "git clone" instead?`
42792
43205
  const destinationPath = new ExtensionStorage(
42793
43206
  newExtensionName
42794
43207
  ).getExtensionDir();
42795
- if ((!isUpdate || newExtensionName !== previousName) && fs12.existsSync(destinationPath)) {
42796
- throw new Error(
42797
- `Cannot install extension "${newExtensionName}" because a directory with that name already exists. Please remove it manually.`
42798
- );
42799
- }
43208
+ const assertDestinationIsAvailable = () => {
43209
+ if ((!isUpdate || newExtensionName !== previousName) && fs12.existsSync(destinationPath)) {
43210
+ throw new Error(
43211
+ `Cannot install extension "${newExtensionName}" because a directory with that name already exists. Please remove it manually.`
43212
+ );
43213
+ }
43214
+ };
43215
+ assertDestinationIsAvailable();
43216
+ releaseLock = await acquireExtensionInstallLock(
43217
+ destinationPath,
43218
+ newExtensionName
43219
+ );
43220
+ assertDestinationIsAvailable();
42800
43221
  let previousSettings;
42801
43222
  let wasEnabledGlobally = false;
42802
43223
  let wasEnabledWorkspace = false;
@@ -42909,6 +43330,15 @@ Would you like to attempt to install via "git clone" instead?`
42909
43330
  );
42910
43331
  }
42911
43332
  } finally {
43333
+ if (releaseLock) {
43334
+ try {
43335
+ await releaseLock();
43336
+ } catch (releaseError) {
43337
+ debugLogger.warn(
43338
+ `Failed to release the install lock for extension "${newExtensionConfig?.name}": ${getErrorMessage(releaseError)}`
43339
+ );
43340
+ }
43341
+ }
42912
43342
  if (tempDir) {
42913
43343
  try {
42914
43344
  await removeDirectoryWithRetry(tempDir);
@@ -43079,6 +43509,9 @@ Would you like to attempt to install via "git clone" instead?`
43079
43509
  * Builds an extension without side effects (does not mutate loadedExtensions or start it).
43080
43510
  */
43081
43511
  async _buildExtension(extensionDir) {
43512
+ if (path9.basename(extensionDir).endsWith(INSTALL_LOCK_SUFFIX)) {
43513
+ return null;
43514
+ }
43082
43515
  try {
43083
43516
  const stats = await fs12.promises.stat(extensionDir);
43084
43517
  if (!stats.isDirectory()) {
@@ -43564,6 +43997,32 @@ async function copyExtension(source2, destination) {
43564
43997
  await fs12.promises.cp(source2, destination, { recursive: true });
43565
43998
  await makeWritableRecursive(destination);
43566
43999
  }
44000
+ async function acquireExtensionInstallLock(destinationPath, extensionName) {
44001
+ await fs12.promises.mkdir(path9.dirname(destinationPath), { recursive: true });
44002
+ try {
44003
+ return await (0, import_proper_lockfile.lock)(destinationPath, {
44004
+ // `destinationPath` usually does not exist yet. With `realpath: false`,
44005
+ // proper-lockfile neither resolves nor stats it; it only creates and
44006
+ // checks the `<destinationPath>.lock` directory.
44007
+ realpath: false,
44008
+ stale: INSTALL_LOCK_STALE_MS,
44009
+ retries: INSTALL_LOCK_RETRIES,
44010
+ // The default handler throws from a timer, which would crash the CLI.
44011
+ onCompromised: (error) => {
44012
+ debugLogger.warn(
44013
+ `Lost the install lock for extension "${extensionName}": ${getErrorMessage(error)}`
44014
+ );
44015
+ }
44016
+ });
44017
+ } catch (error) {
44018
+ if (isNodeError(error) && error.code === "ELOCKED") {
44019
+ throw new Error(
44020
+ `Cannot install extension "${extensionName}" because another installation or update of it is already in progress. Please try again later.`
44021
+ );
44022
+ }
44023
+ throw error;
44024
+ }
44025
+ }
43567
44026
  function getContextFileNames(config) {
43568
44027
  if (!config.contextFileName) {
43569
44028
  return ["GEMINI.md"];
@@ -43990,9 +44449,9 @@ function isSettingsValue(value) {
43990
44449
  const type = typeof value;
43991
44450
  return type === "string" || type === "number" || type === "boolean" || type === "object";
43992
44451
  }
43993
- function getNestedValue(obj, path37) {
44452
+ function getNestedValue(obj, path38) {
43994
44453
  let current = obj;
43995
- for (const key of path37) {
44454
+ for (const key of path38) {
43996
44455
  if (!isRecord2(current) || !(key in current)) {
43997
44456
  return void 0;
43998
44457
  }
@@ -44005,8 +44464,8 @@ function getEffectiveValue(key, settings) {
44005
44464
  if (!definition) {
44006
44465
  return void 0;
44007
44466
  }
44008
- const path37 = key.split(".");
44009
- const value = getNestedValue(settings, path37);
44467
+ const path38 = key.split(".");
44468
+ const value = getNestedValue(settings, path38);
44010
44469
  if (value !== void 0 && isSettingsValue(value)) {
44011
44470
  return value;
44012
44471
  }
@@ -44016,8 +44475,8 @@ function getDialogSettingKeys() {
44016
44475
  return Object.values(getFlattenedSchema()).filter((definition) => definition.showInDialog !== false).map((definition) => definition.key);
44017
44476
  }
44018
44477
  function isInSettingsScope(key, scopeSettings) {
44019
- const path37 = key.split(".");
44020
- const value = getNestedValue(scopeSettings, path37);
44478
+ const path38 = key.split(".");
44479
+ const value = getNestedValue(scopeSettings, path38);
44021
44480
  return value !== void 0;
44022
44481
  }
44023
44482
  function getDisplayValue(key, scopeSettings, _mergedSettings) {
@@ -44471,7 +44930,7 @@ async function readLocalFiles(resolvedFiles, config, signal, userMessageTimestam
44471
44930
  const match = fileContentRegex.exec(part);
44472
44931
  if (match) {
44473
44932
  const filePathSpecInContent = match[1];
44474
- const fileActualContent = match[2].trim();
44933
+ const fileActualContent = match[2];
44475
44934
  const resolvedFile = filesToRead.find(
44476
44935
  (rf) => rf.absolutePath === filePathSpecInContent || rf.pathSpec === filePathSpecInContent
44477
44936
  );
@@ -44490,7 +44949,9 @@ async function readLocalFiles(resolvedFiles, config, signal, userMessageTimestam
44490
44949
  Content from @${displayPath}:
44491
44950
  `
44492
44951
  });
44493
- parts.push({ text: fileActualContent });
44952
+ if (fileActualContent !== "") {
44953
+ parts.push({ text: fileActualContent });
44954
+ }
44494
44955
  } else {
44495
44956
  parts.push({ text: part });
44496
44957
  }
@@ -44668,8 +45129,8 @@ var import_execa = __toESM(require_execa(), 1);
44668
45129
 
44669
45130
  // node_modules/crypto-random-string/index.js
44670
45131
  import { promisify } from "util";
44671
- import crypto2 from "crypto";
44672
- var randomBytesAsync = promisify(crypto2.randomBytes);
45132
+ import crypto3 from "crypto";
45133
+ var randomBytesAsync = promisify(crypto3.randomBytes);
44673
45134
  var urlSafeCharacters = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-._~".split("");
44674
45135
  var numericCharacters = "0123456789".split("");
44675
45136
  var distinguishableCharacters = "CDEHKMPRTUWXY012458".split("");
@@ -44682,7 +45143,7 @@ var generateForCustomCharacters = (length, characters) => {
44682
45143
  let string = "";
44683
45144
  let stringLength = 0;
44684
45145
  while (stringLength < length) {
44685
- const entropy = crypto2.randomBytes(entropyLength);
45146
+ const entropy = crypto3.randomBytes(entropyLength);
44686
45147
  let entropyPosition = 0;
44687
45148
  while (entropyPosition < entropyLength && stringLength < length) {
44688
45149
  const entropyValue = entropy.readUInt16LE(entropyPosition);
@@ -44717,7 +45178,7 @@ var generateForCustomCharactersAsync = async (length, characters) => {
44717
45178
  }
44718
45179
  return string;
44719
45180
  };
44720
- var generateRandomBytes = (byteLength, type, length) => crypto2.randomBytes(byteLength).toString(type).slice(0, length);
45181
+ var generateRandomBytes = (byteLength, type, length) => crypto3.randomBytes(byteLength).toString(type).slice(0, length);
44721
45182
  var generateRandomBytesAsync = async (byteLength, type, length) => {
44722
45183
  const buffer = await randomBytesAsync(byteLength);
44723
45184
  return buffer.toString(type).slice(0, length);
@@ -45093,7 +45554,7 @@ async function writeClipboardImages(filePaths) {
45093
45554
  if (process5.platform !== "darwin") {
45094
45555
  return;
45095
45556
  }
45096
- const paths = filePaths.map((path37) => path37 instanceof URL ? fileURLToPath(path37) : path37);
45557
+ const paths = filePaths.map((path38) => path38 instanceof URL ? fileURLToPath(path38) : path38);
45097
45558
  await runJxa((...paths2) => {
45098
45559
  ObjC.import("AppKit");
45099
45560
  ObjC.import("Foundation");
@@ -51034,7 +51495,7 @@ var persistentState = new PersistentState();
51034
51495
  // packages/cli/src/ui/utils/terminalSetup.ts
51035
51496
  var VSCODE_SHIFT_ENTER_SEQUENCE = "\\\r\n";
51036
51497
  var execAsync = promisify4(exec);
51037
- function stripJsonComments(content) {
51498
+ function stripJsonComments2(content) {
51038
51499
  return content.replace(/^\s*\/\/.*$/gm, "");
51039
51500
  }
51040
51501
  var TERMINAL_DATA = {
@@ -51138,7 +51599,7 @@ async function configureVSCodeStyle(terminalName, appName) {
51138
51599
  const content = await fs21.readFile(keybindingsFile, "utf8");
51139
51600
  await backupFile(keybindingsFile);
51140
51601
  try {
51141
- const cleanContent = stripJsonComments(content);
51602
+ const cleanContent = stripJsonComments2(content);
51142
51603
  const parsedContent = JSON.parse(cleanContent);
51143
51604
  if (!Array.isArray(parsedContent)) {
51144
51605
  return {
@@ -51270,7 +51731,7 @@ async function shouldPromptForTerminalSetup() {
51270
51731
  const keybindingsFile = path18.join(configDir, "keybindings.json");
51271
51732
  try {
51272
51733
  const content = await fs21.readFile(keybindingsFile, "utf8");
51273
- const cleanContent = stripJsonComments(content);
51734
+ const cleanContent = stripJsonComments2(content);
51274
51735
  const parsedContent = JSON.parse(cleanContent);
51275
51736
  if (!Array.isArray(parsedContent)) {
51276
51737
  return true;
@@ -51914,7 +52375,12 @@ var ShellProcessor = class {
51914
52375
  const userArgsRaw = context.invocation?.args || "";
51915
52376
  if (!prompt.includes(SHELL_INJECTION_TRIGGER)) {
51916
52377
  return [
51917
- { text: prompt.replaceAll(SHORTHAND_ARGS_PLACEHOLDER, userArgsRaw) }
52378
+ {
52379
+ text: prompt.replaceAll(
52380
+ SHORTHAND_ARGS_PLACEHOLDER,
52381
+ () => userArgsRaw
52382
+ )
52383
+ }
51918
52384
  ];
51919
52385
  }
51920
52386
  const config = context.services.agentContext?.config;
@@ -51930,7 +52396,12 @@ var ShellProcessor = class {
51930
52396
  );
51931
52397
  if (injections.length === 0) {
51932
52398
  return [
51933
- { text: prompt.replaceAll(SHORTHAND_ARGS_PLACEHOLDER, userArgsRaw) }
52399
+ {
52400
+ text: prompt.replaceAll(
52401
+ SHORTHAND_ARGS_PLACEHOLDER,
52402
+ () => userArgsRaw
52403
+ )
52404
+ }
51934
52405
  ];
51935
52406
  }
51936
52407
  const { shell: shell2 } = getShellConfiguration();
@@ -51943,7 +52414,7 @@ var ShellProcessor = class {
51943
52414
  }
51944
52415
  const resolvedCommand = command.replaceAll(
51945
52416
  SHORTHAND_ARGS_PLACEHOLDER,
51946
- userArgsEscaped
52417
+ () => userArgsEscaped
51947
52418
  );
51948
52419
  return { ...injection, resolvedCommand };
51949
52420
  }
@@ -51982,7 +52453,7 @@ var ShellProcessor = class {
51982
52453
  const segment = prompt.substring(lastIndex, injection.startIndex);
51983
52454
  processedPrompt += segment.replaceAll(
51984
52455
  SHORTHAND_ARGS_PLACEHOLDER,
51985
- userArgsRaw
52456
+ () => userArgsRaw
51986
52457
  );
51987
52458
  if (injection.resolvedCommand) {
51988
52459
  const activeTheme = themeManager.getActiveTheme();
@@ -52023,7 +52494,7 @@ var ShellProcessor = class {
52023
52494
  const finalSegment = prompt.substring(lastIndex);
52024
52495
  processedPrompt += finalSegment.replaceAll(
52025
52496
  SHORTHAND_ARGS_PLACEHOLDER,
52026
- userArgsRaw
52497
+ () => userArgsRaw
52027
52498
  );
52028
52499
  return [{ text: processedPrompt }];
52029
52500
  }
@@ -53254,6 +53725,7 @@ var _ExpandableText = ({
53254
53725
  maxWidth = MAX_WIDTH,
53255
53726
  maxLines
53256
53727
  }) => {
53728
+ const labelCharacters = Array.from(label);
53257
53729
  const hasMatch = matchedIndex !== void 0 && matchedIndex >= 0 && matchedIndex < label.length && userInput.length > 0;
53258
53730
  if (!hasMatch) {
53259
53731
  let display = label;
@@ -53262,53 +53734,69 @@ var _ExpandableText = ({
53262
53734
  const lines = label.split("\n");
53263
53735
  let truncated = lines.slice(0, maxLines).join("\n");
53264
53736
  const hasMoreLines = lines.length > maxLines;
53265
- if (truncated.length > maxWidth) {
53266
- truncated = truncated.slice(0, maxWidth) + "...";
53737
+ const truncatedCharacters = Array.from(truncated);
53738
+ if (truncatedCharacters.length > maxWidth) {
53739
+ truncated = truncatedCharacters.slice(0, maxWidth).join("") + "...";
53267
53740
  } else if (hasMoreLines) {
53268
53741
  truncated += "...";
53269
53742
  }
53270
53743
  display = truncated;
53271
- } else if (label.length > maxWidth) {
53272
- display = label.slice(0, maxWidth) + "...";
53744
+ } else if (labelCharacters.length > maxWidth) {
53745
+ display = labelCharacters.slice(0, maxWidth).join("") + "...";
53273
53746
  }
53274
53747
  }
53275
53748
  return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(Text, { wrap: "wrap", color: textColor, children: display });
53276
53749
  }
53277
- const matchLength = userInput.length;
53750
+ const matchCharactersLength = Array.from(userInput).length;
53751
+ let matchedCharacterIndex = 0;
53752
+ let matchedUtf16Index = 0;
53753
+ while (matchedCharacterIndex < labelCharacters.length && matchedUtf16Index < matchedIndex) {
53754
+ matchedUtf16Index += labelCharacters[matchedCharacterIndex].length;
53755
+ matchedCharacterIndex += 1;
53756
+ }
53278
53757
  let before = "";
53279
53758
  let match = "";
53280
53759
  let after = "";
53281
- if (isExpanded || label.length <= maxWidth) {
53282
- before = label.slice(0, matchedIndex);
53283
- match = label.slice(matchedIndex, matchedIndex + matchLength);
53284
- after = label.slice(matchedIndex + matchLength);
53285
- } else if (matchLength >= maxWidth) {
53286
- match = label.slice(matchedIndex, matchedIndex + maxWidth - 1) + "...";
53760
+ if (isExpanded || labelCharacters.length <= maxWidth) {
53761
+ before = labelCharacters.slice(0, matchedCharacterIndex).join("");
53762
+ match = labelCharacters.slice(
53763
+ matchedCharacterIndex,
53764
+ matchedCharacterIndex + matchCharactersLength
53765
+ ).join("");
53766
+ after = labelCharacters.slice(matchedCharacterIndex + matchCharactersLength).join("");
53767
+ } else if (matchCharactersLength >= maxWidth) {
53768
+ match = labelCharacters.slice(matchedCharacterIndex, matchedCharacterIndex + maxWidth - 1).join("") + "...";
53287
53769
  } else {
53288
- const contextSpace = maxWidth - matchLength;
53770
+ const contextSpace = maxWidth - matchCharactersLength;
53289
53771
  const beforeSpace = Math.floor(contextSpace / 2);
53290
53772
  const afterSpace = Math.ceil(contextSpace / 2);
53291
- let start = matchedIndex - beforeSpace;
53292
- let end = matchedIndex + matchLength + afterSpace;
53773
+ let start = matchedCharacterIndex - beforeSpace;
53774
+ let end = matchedCharacterIndex + matchCharactersLength + afterSpace;
53293
53775
  if (start < 0) {
53294
53776
  end += -start;
53295
53777
  start = 0;
53296
53778
  }
53297
- if (end > label.length) {
53298
- start -= end - label.length;
53299
- end = label.length;
53779
+ if (end > labelCharacters.length) {
53780
+ start -= end - labelCharacters.length;
53781
+ end = labelCharacters.length;
53300
53782
  }
53301
53783
  start = Math.max(0, start);
53302
- const finalMatchIndex = matchedIndex - start;
53303
- const slicedLabel = label.slice(start, end);
53304
- before = slicedLabel.slice(0, finalMatchIndex);
53305
- match = slicedLabel.slice(finalMatchIndex, finalMatchIndex + matchLength);
53306
- after = slicedLabel.slice(finalMatchIndex + matchLength);
53784
+ const finalMatchIndex = matchedCharacterIndex - start;
53785
+ const slicedLabel = labelCharacters.slice(start, end);
53786
+ const beforeChars = slicedLabel.slice(0, finalMatchIndex);
53787
+ match = slicedLabel.slice(finalMatchIndex, finalMatchIndex + matchCharactersLength).join("");
53788
+ const afterChars = slicedLabel.slice(
53789
+ finalMatchIndex + matchCharactersLength
53790
+ );
53307
53791
  if (start > 0) {
53308
- before = before.length >= 3 ? "..." + before.slice(3) : "...";
53792
+ before = beforeChars.length >= 3 ? "..." + beforeChars.slice(3).join("") : "...";
53793
+ } else {
53794
+ before = beforeChars.join("");
53309
53795
  }
53310
- if (end < label.length) {
53311
- after = after.length >= 3 ? after.slice(0, -3) + "..." : "...";
53796
+ if (end < labelCharacters.length) {
53797
+ after = afterChars.length >= 3 ? afterChars.slice(0, -3).join("") + "..." : "...";
53798
+ } else {
53799
+ after = afterChars.join("");
53312
53800
  }
53313
53801
  }
53314
53802
  return /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(Text, { color: textColor, wrap: "wrap", children: [
@@ -54524,10 +55012,10 @@ function enableFeature(settings, featureName, strategy) {
54524
55012
  };
54525
55013
  }
54526
55014
  const modifiedScopes = [];
54527
- for (const { scope, path: path37 } of foundInDisabledScopes) {
55015
+ for (const { scope, path: path38 } of foundInDisabledScopes) {
54528
55016
  if (isLoadableSettingScope(scope)) {
54529
55017
  strategy.enable(settings, scope, featureName);
54530
- modifiedScopes.push({ scope, path: path37 });
55018
+ modifiedScopes.push({ scope, path: path38 });
54531
55019
  }
54532
55020
  }
54533
55021
  return {
@@ -55018,7 +55506,7 @@ var authCommand = {
55018
55506
  import process12 from "node:process";
55019
55507
 
55020
55508
  // packages/cli/src/generated/git-commit.ts
55021
- var GIT_COMMIT_INFO = "b367c7296";
55509
+ var GIT_COMMIT_INFO = "1603e9bab";
55022
55510
 
55023
55511
  // packages/cli/src/ui/utils/historyExportUtils.ts
55024
55512
  import * as fsPromises from "node:fs/promises";
@@ -55068,13 +55556,13 @@ async function exportHistoryToFile(options) {
55068
55556
  // packages/cli/src/ui/utils/memorySnapshot.ts
55069
55557
  import { createWriteStream as createWriteStream3 } from "node:fs";
55070
55558
  import { mkdir as mkdir3 } from "node:fs/promises";
55071
- import { dirname as dirname4 } from "node:path";
55072
- import { pipeline } from "node:stream/promises";
55559
+ import { dirname as dirname5 } from "node:path";
55560
+ import { pipeline as pipeline2 } from "node:stream/promises";
55073
55561
  import { getHeapSnapshot } from "node:v8";
55074
55562
  var MEMORY_SNAPSHOT_AUTO_THRESHOLD_BYTES = 2 * 1024 * 1024 * 1024;
55075
55563
  async function captureHeapSnapshot(filePath) {
55076
- await mkdir3(dirname4(filePath), { recursive: true });
55077
- await pipeline(getHeapSnapshot(), createWriteStream3(filePath));
55564
+ await mkdir3(dirname5(filePath), { recursive: true });
55565
+ await pipeline2(getHeapSnapshot(), createWriteStream3(filePath));
55078
55566
  }
55079
55567
 
55080
55568
  // packages/cli/src/ui/commands/bugCommand.ts
@@ -55652,7 +56140,7 @@ var chatCommand = {
55652
56140
  };
55653
56141
 
55654
56142
  // packages/cli/src/ui/commands/clearCommand.ts
55655
- import { randomUUID as randomUUID2 } from "node:crypto";
56143
+ import { randomUUID as randomUUID3 } from "node:crypto";
55656
56144
  var clearCommand = {
55657
56145
  name: "clear",
55658
56146
  altNames: ["new"],
@@ -55669,7 +56157,7 @@ var clearCommand = {
55669
56157
  config?.injectionService.clear();
55670
56158
  let newSessionId;
55671
56159
  if (config) {
55672
- newSessionId = randomUUID2();
56160
+ newSessionId = randomUUID3();
55673
56161
  config.resetNewSessionState(newSessionId);
55674
56162
  }
55675
56163
  if (geminiClient) {
@@ -59769,7 +60257,7 @@ var RewindViewer = ({
59769
60257
  var import_jsx_runtime32 = __toESM(require_jsx_runtime(), 1);
59770
60258
  async function rewindConversation(context, client, recordingService, messageId, newText) {
59771
60259
  try {
59772
- const conversation = recordingService.rewindTo(messageId);
60260
+ const conversation = await (recordingService.rewindToAsync ? recordingService.rewindToAsync(messageId) : recordingService.rewindTo(messageId));
59773
60261
  if (!conversation) {
59774
60262
  const errorMsg = "Could not fetch conversation file";
59775
60263
  debugLogger.error(errorMsg);
@@ -59777,10 +60265,20 @@ async function rewindConversation(context, client, recordingService, messageId,
59777
60265
  coreEvents.emitFeedback("error", errorMsg);
59778
60266
  return;
59779
60267
  }
59780
- const { uiHistory } = convertSessionToHistoryFormats(conversation.messages);
59781
- const clientHistory = convertSessionToClientHistory(conversation.messages);
60268
+ const messages = conversation.messages ?? [];
60269
+ const { uiHistory } = convertSessionToHistoryFormats(messages);
60270
+ const clientHistory = convertSessionToClientHistory(messages);
59782
60271
  client.setHistory(clientHistory);
59783
- await context.services.agentContext?.config.getMemoryContextManager()?.refresh();
60272
+ client.clearCurrentSequenceModel?.();
60273
+ const config = context.services.agentContext?.config;
60274
+ if (config) {
60275
+ config.getModelAvailabilityService?.()?.reset();
60276
+ const configuredModel = config.getModel?.();
60277
+ if (configuredModel) {
60278
+ config.setActiveModel?.(configuredModel);
60279
+ }
60280
+ await config.getMemoryContextManager()?.refresh();
60281
+ }
59784
60282
  const startId = 1;
59785
60283
  const historyWithIds = uiHistory.map(
59786
60284
  (item, idx) => ({
@@ -59825,75 +60323,80 @@ var rewindCommand = {
59825
60323
  messageType: "error",
59826
60324
  content: "Recording service unavailable"
59827
60325
  };
59828
- const conversation = recordingService.getConversation();
59829
- if (!conversation)
59830
- return {
59831
- type: "message",
59832
- messageType: "info",
59833
- content: "No conversation found."
59834
- };
59835
- const hasUserInteractions = conversation.messages.some(
59836
- (msg) => msg.type === "user"
59837
- );
59838
- if (!hasUserInteractions) {
60326
+ const buildRewindActionReturn = (conversation) => {
60327
+ if (!conversation)
60328
+ return {
60329
+ type: "message",
60330
+ messageType: "info",
60331
+ content: "No conversation found."
60332
+ };
60333
+ const hasUserInteractions = (conversation.messages ?? []).some(
60334
+ (msg) => msg.type === "user"
60335
+ );
60336
+ if (!hasUserInteractions) {
60337
+ return {
60338
+ type: "message",
60339
+ messageType: "info",
60340
+ content: "Nothing to rewind to."
60341
+ };
60342
+ }
59839
60343
  return {
59840
- type: "message",
59841
- messageType: "info",
59842
- content: "Nothing to rewind to."
59843
- };
59844
- }
59845
- return {
59846
- type: "custom_dialog",
59847
- component: /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
59848
- RewindViewer,
59849
- {
59850
- conversation,
59851
- onExit: () => {
59852
- context.ui.removeComponent();
59853
- },
59854
- onRewind: async (messageId, newText, outcome) => {
59855
- if (outcome !== "cancel" /* Cancel */) {
59856
- logRewind(config, new RewindEvent(outcome));
59857
- }
59858
- switch (outcome) {
59859
- case "cancel" /* Cancel */:
59860
- context.ui.removeComponent();
59861
- return;
59862
- case "revert_only" /* RevertOnly */:
59863
- if (conversation) {
59864
- await revertFileChanges(conversation, messageId);
59865
- }
59866
- context.ui.removeComponent();
59867
- coreEvents.emitFeedback("info", "File changes reverted.");
59868
- return;
59869
- case "rewind_and_revert" /* RewindAndRevert */:
59870
- if (conversation) {
59871
- await revertFileChanges(conversation, messageId);
59872
- }
59873
- await rewindConversation(
59874
- context,
59875
- client,
59876
- recordingService,
59877
- messageId,
59878
- newText
59879
- );
59880
- return;
59881
- case "rewind_only" /* RewindOnly */:
59882
- await rewindConversation(
59883
- context,
59884
- client,
59885
- recordingService,
59886
- messageId,
59887
- newText
59888
- );
59889
- return;
59890
- default:
59891
- checkExhaustive(outcome);
60344
+ type: "custom_dialog",
60345
+ component: /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
60346
+ RewindViewer,
60347
+ {
60348
+ conversation,
60349
+ onExit: () => {
60350
+ context.ui.removeComponent();
60351
+ },
60352
+ onRewind: async (messageId, newText, outcome) => {
60353
+ if (outcome !== "cancel" /* Cancel */) {
60354
+ logRewind(config, new RewindEvent(outcome));
60355
+ }
60356
+ switch (outcome) {
60357
+ case "cancel" /* Cancel */:
60358
+ context.ui.removeComponent();
60359
+ return;
60360
+ case "revert_only" /* RevertOnly */:
60361
+ if (conversation) {
60362
+ await revertFileChanges(conversation, messageId);
60363
+ }
60364
+ context.ui.removeComponent();
60365
+ coreEvents.emitFeedback("info", "File changes reverted.");
60366
+ return;
60367
+ case "rewind_and_revert" /* RewindAndRevert */:
60368
+ if (conversation) {
60369
+ await revertFileChanges(conversation, messageId);
60370
+ }
60371
+ await rewindConversation(
60372
+ context,
60373
+ client,
60374
+ recordingService,
60375
+ messageId,
60376
+ newText
60377
+ );
60378
+ return;
60379
+ case "rewind_only" /* RewindOnly */:
60380
+ await rewindConversation(
60381
+ context,
60382
+ client,
60383
+ recordingService,
60384
+ messageId,
60385
+ newText
60386
+ );
60387
+ return;
60388
+ default:
60389
+ checkExhaustive(outcome);
60390
+ }
59892
60391
  }
59893
60392
  }
59894
- }
59895
- )
60393
+ )
60394
+ };
59896
60395
  };
60396
+ if (recordingService.getConversationAsync) {
60397
+ return recordingService.getConversationAsync().then(buildRewindActionReturn);
60398
+ }
60399
+ return buildRewindActionReturn(recordingService.getConversation());
59897
60400
  }
59898
60401
  };
59899
60402
 
@@ -59927,14 +60430,14 @@ function enableHook(settings, hookName) {
59927
60430
  }
59928
60431
  const modifiedScopes = [];
59929
60432
  try {
59930
- for (const { scope, path: path37 } of foundInDisabledScopes) {
60433
+ for (const { scope, path: path38 } of foundInDisabledScopes) {
59931
60434
  if (isLoadableSettingScope(scope)) {
59932
60435
  const currentScopeDisabled = settings.forScope(scope).settings.hooksConfig?.disabled ?? [];
59933
60436
  const newDisabled = currentScopeDisabled.filter(
59934
60437
  (name) => name !== hookName
59935
60438
  );
59936
60439
  settings.setValue(scope, "hooksConfig.disabled", newDisabled);
59937
- modifiedScopes.push({ scope, path: path37 });
60440
+ modifiedScopes.push({ scope, path: path38 });
59938
60441
  }
59939
60442
  }
59940
60443
  } catch (error) {
@@ -60229,7 +60732,7 @@ async function enableAction3(context, args) {
60229
60732
  }
60230
60733
  const feedback = renderHookActionFeedback(
60231
60734
  result,
60232
- (label, path37) => `${label} (${path37})`
60735
+ (label, path38) => `${label} (${path38})`
60233
60736
  );
60234
60737
  return {
60235
60738
  type: "message",
@@ -60271,7 +60774,7 @@ async function disableAction3(context, args) {
60271
60774
  }
60272
60775
  const feedback = renderHookActionFeedback(
60273
60776
  result,
60274
- (label, path37) => `${label} (${path37})`
60777
+ (label, path38) => `${label} (${path38})`
60275
60778
  );
60276
60779
  return {
60277
60780
  type: "message",
@@ -60825,7 +61328,7 @@ Use /mcp auth <server-name> to authenticate.`
60825
61328
  type: "info",
60826
61329
  text: `Starting OAuth authentication for MCP server '${serverName}'...`
60827
61330
  });
60828
- const { MCPOAuthProvider } = await import("./core-GTUUQBGE.js");
61331
+ const { MCPOAuthProvider } = await import("./core-6XF5EO7Z.js");
60829
61332
  let oauthConfig = server.oauth;
60830
61333
  if (!oauthConfig) {
60831
61334
  oauthConfig = { enabled: false };
@@ -76466,6 +76969,37 @@ var memoryCommand = (_config) => {
76466
76969
  };
76467
76970
 
76468
76971
  // packages/cli/src/ui/commands/modelCommand.ts
76972
+ function getValidModelNames(context) {
76973
+ const validModels = /* @__PURE__ */ new Set([
76974
+ ...Array.from(VALID_GEMINI_MODELS).filter((model) => model !== "none"),
76975
+ ...Object.keys(DEFAULT_MODEL_CONFIGS.modelDefinitions ?? {}),
76976
+ GEMINI_MODEL_ALIAS_AUTO,
76977
+ GEMINI_MODEL_ALIAS_PRO,
76978
+ GEMINI_MODEL_ALIAS_FLASH,
76979
+ GEMINI_MODEL_ALIAS_FLASH_LITE,
76980
+ PREVIEW_GEMINI_MODEL_AUTO,
76981
+ DEFAULT_GEMINI_MODEL_AUTO
76982
+ ]);
76983
+ const config = context.services.agentContext?.config;
76984
+ const serviceDefinitions = config?.getModelConfigService?.()?.getModelDefinitions?.();
76985
+ if (serviceDefinitions) {
76986
+ for (const model of Object.keys(serviceDefinitions)) {
76987
+ validModels.add(model);
76988
+ }
76989
+ }
76990
+ const modelConfigs = context.services.settings?.merged?.modelConfigs;
76991
+ if (modelConfigs?.customAliases) {
76992
+ for (const alias of Object.keys(modelConfigs.customAliases)) {
76993
+ validModels.add(alias);
76994
+ }
76995
+ }
76996
+ if (modelConfigs?.modelDefinitions) {
76997
+ for (const model of Object.keys(modelConfigs.modelDefinitions)) {
76998
+ validModels.add(model);
76999
+ }
77000
+ }
77001
+ return validModels;
77002
+ }
76469
77003
  var setModelCommand = {
76470
77004
  name: "set",
76471
77005
  description: "Set the model to use. Usage: /model set <model-name> [--persist]",
@@ -76473,15 +77007,24 @@ var setModelCommand = {
76473
77007
  autoExecute: false,
76474
77008
  action: async (context, args) => {
76475
77009
  const parts = args.trim().split(/\s+/).filter(Boolean);
76476
- if (parts.length === 0) {
77010
+ const persist = parts.includes("--persist");
77011
+ const nonFlagParts = parts.filter((part) => part !== "--persist");
77012
+ if (nonFlagParts.length === 0) {
76477
77013
  context.ui.addItem({
76478
77014
  type: "error" /* ERROR */,
76479
77015
  text: "Usage: /model set <model-name> [--persist]"
76480
77016
  });
76481
77017
  return;
76482
77018
  }
76483
- const modelName = parts[0];
76484
- const persist = parts.includes("--persist");
77019
+ const modelName = nonFlagParts[0];
77020
+ const validModels = getValidModelNames(context);
77021
+ if (!validModels.has(modelName)) {
77022
+ context.ui.addItem({
77023
+ type: "error" /* ERROR */,
77024
+ text: `Invalid model "${modelName}". Run /model to view and select from available models.`
77025
+ });
77026
+ return;
77027
+ }
76485
77028
  if (context.services.agentContext?.config) {
76486
77029
  context.services.agentContext.config.setModel(modelName, !persist);
76487
77030
  const event = new ModelSlashCommandEvent(modelName);
@@ -76491,6 +77034,10 @@ var setModelCommand = {
76491
77034
  text: `Model set to ${modelName}${persist ? " (persisted)" : ""}`
76492
77035
  });
76493
77036
  }
77037
+ },
77038
+ completion: async (context, partialArg) => {
77039
+ const validModels = Array.from(getValidModelNames(context));
77040
+ return validModels.filter((model) => model.startsWith(partialArg));
76494
77041
  }
76495
77042
  };
76496
77043
  var manageModelCommand = {
@@ -76514,7 +77061,12 @@ var modelCommand = {
76514
77061
  kind: "built-in" /* BUILT_IN */,
76515
77062
  autoExecute: false,
76516
77063
  subCommands: [manageModelCommand, setModelCommand],
76517
- action: async (context, args) => manageModelCommand.action(context, args)
77064
+ action: async (context, args) => {
77065
+ if (args.trim().length > 0) {
77066
+ return setModelCommand.action?.(context, args);
77067
+ }
77068
+ return manageModelCommand.action?.(context, args);
77069
+ }
76518
77070
  };
76519
77071
 
76520
77072
  // packages/cli/src/ui/components/triage/TriageDuplicates.tsx
@@ -78436,6 +78988,7 @@ var resumeCommand = {
78436
78988
  };
78437
78989
 
78438
78990
  // packages/cli/src/ui/commands/statsCommand.ts
78991
+ import path35 from "node:path";
78439
78992
  function getUserIdentity(context) {
78440
78993
  const selectedAuthType = context.services.settings.merged.security.auth.selectedType || "";
78441
78994
  const userAccountManager = new UserAccountManager();
@@ -78482,14 +79035,56 @@ async function defaultSessionView(context) {
78482
79035
  }
78483
79036
  context.ui.addItem(statsItem);
78484
79037
  }
79038
+ async function heatmapView(context, rawArgs) {
79039
+ const now = /* @__PURE__ */ new Date();
79040
+ const parsedDate = resolveHeatmapDateArg(rawArgs, now);
79041
+ if (!parsedDate.ok) {
79042
+ context.ui.addItem({
79043
+ type: "error" /* ERROR */,
79044
+ text: parsedDate.error
79045
+ });
79046
+ return;
79047
+ }
79048
+ let chatsDir = "";
79049
+ try {
79050
+ const projectTempDir = context.services.agentContext?.config?.storage?.getProjectTempDir();
79051
+ if (projectTempDir) {
79052
+ chatsDir = path35.join(projectTempDir, "chats");
79053
+ }
79054
+ } catch {
79055
+ chatsDir = "";
79056
+ }
79057
+ const dataset = await aggregateUsageFromRecordings(
79058
+ chatsDir,
79059
+ DEFAULT_HEATMAP_WINDOW_DAYS,
79060
+ now
79061
+ );
79062
+ const heatmapItem = {
79063
+ type: "heatmap_stats" /* HEATMAP_STATS */,
79064
+ dailyUsage: Object.fromEntries(dataset.dailyUsage),
79065
+ totalWindowTokens: dataset.totalWindowTokens,
79066
+ totalWindowSessions: dataset.totalWindowSessions,
79067
+ totalWindowTurns: dataset.totalWindowTurns,
79068
+ currentStreak: dataset.currentStreak,
79069
+ longestStreak: dataset.longestStreak,
79070
+ today: formatLocalDateKey(now),
79071
+ selectedDate: parsedDate.date
79072
+ };
79073
+ context.ui.addItem(heatmapItem);
79074
+ }
78485
79075
  var statsCommand = {
78486
79076
  name: "stats",
78487
79077
  altNames: ["usage"],
78488
- description: "Check session stats. Usage: /stats [session|model|tools]",
79078
+ description: "Check session stats. Usage: /stats [session|model|tools|heatmap]",
78489
79079
  kind: "built-in" /* BUILT_IN */,
78490
79080
  autoExecute: false,
78491
79081
  isSafeConcurrent: true,
78492
- action: async (context) => {
79082
+ action: async (context, args) => {
79083
+ const trimmed = (args ?? "").trim();
79084
+ if (trimmed === "heatmap" || trimmed.startsWith("heatmap ")) {
79085
+ await heatmapView(context, trimmed.slice("heatmap".length));
79086
+ return;
79087
+ }
78493
79088
  await defaultSessionView(context);
78494
79089
  },
78495
79090
  subCommands: [
@@ -78538,6 +79133,21 @@ var statsCommand = {
78538
79133
  type: "tool_stats" /* TOOL_STATS */
78539
79134
  });
78540
79135
  }
79136
+ },
79137
+ {
79138
+ name: "heatmap",
79139
+ description: "Show calendar heatmap of daily token usage. Usage: /stats heatmap [today|yesterday|YYYY-MM-DD]",
79140
+ kind: "built-in" /* BUILT_IN */,
79141
+ autoExecute: true,
79142
+ isSafeConcurrent: true,
79143
+ showCompletionLoading: false,
79144
+ completion: (_context, partialArg) => {
79145
+ const prefix = partialArg.trim().toLowerCase();
79146
+ return ["today", "yesterday"].filter((opt) => opt.startsWith(prefix));
79147
+ },
79148
+ action: async (context, args) => {
79149
+ await heatmapView(context, args);
79150
+ }
78541
79151
  }
78542
79152
  ]
78543
79153
  };
@@ -78655,7 +79265,7 @@ function disableSkill(settings, skillName, scope) {
78655
79265
  // packages/cli/src/utils/skillUtils.ts
78656
79266
  var import_extract_zip2 = __toESM(require_extract_zip(), 1);
78657
79267
  import * as fs31 from "node:fs/promises";
78658
- import * as path35 from "node:path";
79268
+ import * as path36 from "node:path";
78659
79269
  import * as os7 from "node:os";
78660
79270
  function renderSkillActionFeedback(result, formatScope) {
78661
79271
  const { skillName, action, status, error } = result;
@@ -78689,7 +79299,7 @@ function renderSkillActionFeedback(result, formatScope) {
78689
79299
  return `Skill "${skillName}" ${actionVerb} ${preposition} ${s3} settings.`;
78690
79300
  }
78691
79301
  function isPathTraversal(relative3) {
78692
- return relative3 === ".." || relative3.startsWith(".." + path35.sep) || path35.isAbsolute(relative3);
79302
+ return relative3 === ".." || relative3.startsWith(".." + path36.sep) || path36.isAbsolute(relative3);
78693
79303
  }
78694
79304
  function isInvalidSubpath(relative3) {
78695
79305
  return relative3 === "" || isPathTraversal(relative3);
@@ -78702,7 +79312,7 @@ async function installSkill(source2, scope, subpath, onLog, requestConsent = ()
78702
79312
  try {
78703
79313
  if (isGitUrl) {
78704
79314
  tempDirToClean = await fs31.mkdtemp(
78705
- path35.join(os7.tmpdir(), "gemini-skill-")
79315
+ path36.join(os7.tmpdir(), "gemini-skill-")
78706
79316
  );
78707
79317
  sourcePath = tempDirToClean;
78708
79318
  onLog(`Cloning skill from ${source2}...`);
@@ -78715,19 +79325,19 @@ async function installSkill(source2, scope, subpath, onLog, requestConsent = ()
78715
79325
  );
78716
79326
  } else if (isSkillFile) {
78717
79327
  tempDirToClean = await fs31.mkdtemp(
78718
- path35.join(os7.tmpdir(), "gemini-skill-")
79328
+ path36.join(os7.tmpdir(), "gemini-skill-")
78719
79329
  );
78720
79330
  sourcePath = tempDirToClean;
78721
79331
  onLog(`Extracting skill from ${source2}...`);
78722
- await (0, import_extract_zip2.default)(path35.resolve(source2), { dir: tempDirToClean });
79332
+ await (0, import_extract_zip2.default)(path36.resolve(source2), { dir: tempDirToClean });
78723
79333
  }
78724
79334
  if (subpath) {
78725
- sourcePath = path35.join(sourcePath, subpath);
79335
+ sourcePath = path36.join(sourcePath, subpath);
78726
79336
  }
78727
- sourcePath = path35.resolve(sourcePath);
79337
+ sourcePath = path36.resolve(sourcePath);
78728
79338
  if (tempDirToClean) {
78729
- const resolvedTemp = path35.resolve(tempDirToClean);
78730
- const relative3 = path35.relative(resolvedTemp, sourcePath);
79339
+ const resolvedTemp = path36.resolve(tempDirToClean);
79340
+ const relative3 = path36.relative(resolvedTemp, sourcePath);
78731
79341
  if (isPathTraversal(relative3)) {
78732
79342
  throw new Error("Invalid path: Directory traversal not allowed.");
78733
79343
  }
@@ -78745,14 +79355,14 @@ async function installSkill(source2, scope, subpath, onLog, requestConsent = ()
78745
79355
  if (!await requestConsent(skills, targetDir)) {
78746
79356
  throw new Error("Skill installation cancelled by user.");
78747
79357
  }
78748
- const resolvedTarget = path35.resolve(targetDir);
79358
+ const resolvedTarget = path36.resolve(targetDir);
78749
79359
  await fs31.mkdir(resolvedTarget, { recursive: true });
78750
79360
  const installedSkills = [];
78751
79361
  for (const skill of skills) {
78752
79362
  const skillName = skill.name;
78753
- const skillDir = path35.dirname(skill.location);
78754
- const destPath = path35.resolve(resolvedTarget, skillName);
78755
- const relative3 = path35.relative(resolvedTarget, destPath);
79363
+ const skillDir = path36.dirname(skill.location);
79364
+ const destPath = path36.resolve(resolvedTarget, skillName);
79365
+ const relative3 = path36.relative(resolvedTarget, destPath);
78756
79366
  if (isInvalidSubpath(relative3)) {
78757
79367
  throw new Error("Invalid skill name: Path traversal detected.");
78758
79368
  }
@@ -78772,7 +79382,7 @@ async function installSkill(source2, scope, subpath, onLog, requestConsent = ()
78772
79382
  }
78773
79383
  }
78774
79384
  async function linkSkill(source2, scope, onLog, requestConsent = () => Promise.resolve(true)) {
78775
- const sourcePath = path35.resolve(source2);
79385
+ const sourcePath = path36.resolve(source2);
78776
79386
  onLog(`Searching for skills in ${sourcePath}...`);
78777
79387
  const skills = await loadSkillsFromDir(sourcePath);
78778
79388
  if (skills.length === 0) {
@@ -78797,14 +79407,14 @@ async function linkSkill(source2, scope, onLog, requestConsent = () => Promise.r
78797
79407
  if (!await requestConsent(skills, targetDir)) {
78798
79408
  throw new Error("Skill linking cancelled by user.");
78799
79409
  }
78800
- const resolvedTarget = path35.resolve(targetDir);
79410
+ const resolvedTarget = path36.resolve(targetDir);
78801
79411
  await fs31.mkdir(resolvedTarget, { recursive: true });
78802
79412
  const linkedSkills = [];
78803
79413
  for (const skill of skills) {
78804
79414
  const skillName = skill.name;
78805
- const skillSourceDir = path35.dirname(skill.location);
78806
- const destPath = path35.resolve(resolvedTarget, skillName);
78807
- const relative3 = path35.relative(resolvedTarget, destPath);
79415
+ const skillSourceDir = path36.dirname(skill.location);
79416
+ const destPath = path36.resolve(resolvedTarget, skillName);
79417
+ const relative3 = path36.relative(resolvedTarget, destPath);
78808
79418
  if (isInvalidSubpath(relative3)) {
78809
79419
  throw new Error("Invalid skill name: Path traversal detected.");
78810
79420
  }
@@ -78828,12 +79438,12 @@ async function uninstallSkill(name, scope) {
78828
79438
  const workspaceDir = process.cwd();
78829
79439
  const storage = new Storage(workspaceDir);
78830
79440
  const targetDir = scope === "workspace" ? storage.getProjectSkillsDir() : Storage.getUserSkillsDir();
78831
- const resolvedTarget = path35.resolve(targetDir);
79441
+ const resolvedTarget = path36.resolve(targetDir);
78832
79442
  const discoveredSkills = await loadSkillsFromDir(resolvedTarget);
78833
79443
  const skillToUninstall = discoveredSkills.find((s3) => s3.name === name);
78834
79444
  if (!skillToUninstall) {
78835
- const skillPath = path35.resolve(resolvedTarget, name);
78836
- const relative4 = path35.relative(resolvedTarget, skillPath);
79445
+ const skillPath = path36.resolve(resolvedTarget, name);
79446
+ const relative4 = path36.relative(resolvedTarget, skillPath);
78837
79447
  if (isInvalidSubpath(relative4)) {
78838
79448
  return null;
78839
79449
  }
@@ -78844,8 +79454,8 @@ async function uninstallSkill(name, scope) {
78844
79454
  await fs31.rm(skillPath, { recursive: true, force: true });
78845
79455
  return { location: skillPath };
78846
79456
  }
78847
- const skillDir = path35.resolve(path35.dirname(skillToUninstall.location));
78848
- const relative3 = path35.relative(resolvedTarget, skillDir);
79457
+ const skillDir = path36.resolve(path36.dirname(skillToUninstall.location));
79458
+ const relative3 = path36.relative(resolvedTarget, skillDir);
78849
79459
  if (isInvalidSubpath(relative3)) {
78850
79460
  return null;
78851
79461
  }
@@ -78979,7 +79589,7 @@ async function disableAction4(context, args) {
78979
79589
  const result = disableSkill(context.services.settings, skillName, scope);
78980
79590
  let feedback = renderSkillActionFeedback(
78981
79591
  result,
78982
- (label, path37) => `${label} (${path37})`
79592
+ (label, path38) => `${label} (${path38})`
78983
79593
  );
78984
79594
  if (result.status === "success" || result.status === "no-op") {
78985
79595
  feedback += ' You can run "/skills reload" to refresh your current instance.';
@@ -79015,7 +79625,7 @@ async function enableAction4(context, args) {
79015
79625
  const result = enableSkill(context.services.settings, skillName);
79016
79626
  let feedback = renderSkillActionFeedback(
79017
79627
  result,
79018
- (label, path37) => `${label} (${path37})`
79628
+ (label, path38) => `${label} (${path38})`
79019
79629
  );
79020
79630
  if (result.status === "success" || result.status === "no-op") {
79021
79631
  feedback += ' You can run "/skills reload" to refresh your current instance.';
@@ -79206,7 +79816,7 @@ var vimCommand = {
79206
79816
 
79207
79817
  // packages/cli/src/ui/commands/setupGithubCommand.ts
79208
79818
  var import_undici2 = __toESM(require_undici(), 1);
79209
- import path36 from "node:path";
79819
+ import path37 from "node:path";
79210
79820
  import * as fs32 from "node:fs";
79211
79821
  import { Writable } from "node:stream";
79212
79822
 
@@ -79336,7 +79946,7 @@ function getOpenUrlsCommands(readmeUrl) {
79336
79946
  }
79337
79947
  async function updateGitignore(gitRepoRoot) {
79338
79948
  const gitignoreEntries = [".gemini/", "gha-creds-*.json"];
79339
- const gitignorePath = path36.join(gitRepoRoot, ".gitignore");
79949
+ const gitignorePath = path37.join(gitRepoRoot, ".gitignore");
79340
79950
  try {
79341
79951
  let existingContent = "";
79342
79952
  let fileExists2 = true;
@@ -79391,9 +80001,9 @@ async function downloadFiles({
79391
80001
  `Empty body while downloading ${endpoint}: ${response.status} - ${response.statusText}`
79392
80002
  );
79393
80003
  }
79394
- const destination = path36.resolve(
80004
+ const destination = path37.resolve(
79395
80005
  targetDir,
79396
- path36.basename(fileBasename)
80006
+ path37.basename(fileBasename)
79397
80007
  );
79398
80008
  const fileStream = fs32.createWriteStream(destination, {
79399
80009
  mode: 420,
@@ -79466,9 +80076,9 @@ var setupGithubCommand = {
79466
80076
  const proxy = context?.services?.agentContext?.config.getProxy();
79467
80077
  const releaseTag = await getLatestGitHubRelease(proxy);
79468
80078
  const readmeUrl = `https://github.com/google-github-actions/run-gemini-cli/blob/${releaseTag}/README.md#quick-start`;
79469
- const workflowsDir = path36.join(gitRepoRoot, ".github", "workflows");
80079
+ const workflowsDir = path37.join(gitRepoRoot, ".github", "workflows");
79470
80080
  await createDirectory(workflowsDir);
79471
- const commandsDir = path36.join(gitRepoRoot, ".github", "commands");
80081
+ const commandsDir = path37.join(gitRepoRoot, ".github", "commands");
79472
80082
  await createDirectory(commandsDir);
79473
80083
  await downloadSetupFiles({
79474
80084
  configs: [