@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-56IGTM4O.js";
5
+ } from "./chunk-2ONJU4V7.js";
6
6
  import {
7
7
  AppEvent,
8
8
  appEvents
@@ -69,16 +69,16 @@ import {
69
69
  use_stdin_default,
70
70
  use_stdout_default,
71
71
  validateCustomTheme
72
- } from "./chunk-BW65QRZA.js";
72
+ } from "./chunk-U3FFDEKY.js";
73
73
  import {
74
74
  isDevelopment,
75
75
  require_semver
76
- } from "./chunk-2E3ETS5J.js";
76
+ } from "./chunk-C5BED6L6.js";
77
77
  import {
78
78
  emptyIcon,
79
79
  mapCoreStatusToDisplayStatus,
80
80
  require_react
81
- } from "./chunk-YUO7RUF4.js";
81
+ } from "./chunk-GQ7FZNO2.js";
82
82
  import {
83
83
  ALL_EDITORS,
84
84
  ApprovalMode,
@@ -87,6 +87,9 @@ import {
87
87
  Config,
88
88
  CoreEvent,
89
89
  CoreToolCallStatus,
90
+ DEFAULT_GEMINI_MODEL_AUTO,
91
+ DEFAULT_HEATMAP_WINDOW_DAYS,
92
+ DEFAULT_MODEL_CONFIGS,
90
93
  DiscoveredMCPTool,
91
94
  ExtensionDisableEvent,
92
95
  ExtensionEnableEvent,
@@ -97,6 +100,10 @@ import {
97
100
  ExtensionUpdateEvent,
98
101
  GEMINI_CLI_COMPANION_EXTENSION_NAME,
99
102
  GEMINI_DIR,
103
+ GEMINI_MODEL_ALIAS_AUTO,
104
+ GEMINI_MODEL_ALIAS_FLASH,
105
+ GEMINI_MODEL_ALIAS_FLASH_LITE,
106
+ GEMINI_MODEL_ALIAS_PRO,
100
107
  HookType,
101
108
  IDEConnectionStatus,
102
109
  INITIAL_HISTORY_LENGTH,
@@ -110,6 +117,7 @@ import {
110
117
  MCPOAuthTokenStorage,
111
118
  MCPServerStatus,
112
119
  ModelSlashCommandEvent,
120
+ PREVIEW_GEMINI_MODEL_AUTO,
113
121
  PolicyDecision,
114
122
  ProjectIdRequiredError,
115
123
  REFERENCE_CONTENT_END,
@@ -125,7 +133,9 @@ import {
125
133
  TrustLevel,
126
134
  UPGRADE_URL_PAGE,
127
135
  UserAccountManager,
136
+ VALID_GEMINI_MODELS,
128
137
  ValidationRequiredError,
138
+ aggregateUsageFromRecordings,
129
139
  appendToLastTextPart,
130
140
  applyAdminAllowlist,
131
141
  applyInboxMemoryPatch,
@@ -162,6 +172,7 @@ import {
162
172
  flatMapTextParts,
163
173
  flushTelemetry,
164
174
  formatCheckpointDisplayList,
175
+ formatLocalDateKey,
165
176
  getAdminBlockedMcpServersMessage,
166
177
  getAdminErrorMessage,
167
178
  getDisplayString,
@@ -220,6 +231,7 @@ import {
220
231
  logRewind,
221
232
  mcpServerRequiresOAuth,
222
233
  moveInboxSkill,
234
+ normalizePath,
223
235
  openBrowserSecurely,
224
236
  open_default,
225
237
  partToString,
@@ -232,11 +244,14 @@ import {
232
244
  require_cross_spawn,
233
245
  require_is_stream,
234
246
  require_path_key,
247
+ require_proper_lockfile,
235
248
  require_pump,
249
+ require_strip_json_comments,
236
250
  require_toml,
237
251
  resetBrowserSession,
238
252
  resolveAtCommandPath,
239
253
  resolveEditorTypeFromCommand,
254
+ resolveHeatmapDateArg,
240
255
  resolveToRealPath,
241
256
  safeLookup,
242
257
  shortenPath,
@@ -246,13 +261,14 @@ import {
246
261
  spawnAsync,
247
262
  startMemoryService,
248
263
  startupProfiler,
264
+ stripExtendedLengthPrefix,
249
265
  stripLineNumberSuffix,
250
266
  tildeifyPath,
251
267
  tokenLimit,
252
268
  uiTelemetryService,
253
269
  unescapePath,
254
270
  validateUrlDestination
255
- } from "./chunk-NGQU3QTQ.js";
271
+ } from "./chunk-KUXCUQKX.js";
256
272
  import {
257
273
  require_src
258
274
  } from "./chunk-L6PII3GR.js";
@@ -5894,7 +5910,7 @@ var require_yauzl = __commonJS({
5894
5910
  exports.ZipFile = ZipFile;
5895
5911
  exports.Entry = Entry;
5896
5912
  exports.RandomAccessReader = RandomAccessReader;
5897
- function open(path37, options, callback) {
5913
+ function open(path38, options, callback) {
5898
5914
  if (typeof options === "function") {
5899
5915
  callback = options;
5900
5916
  options = null;
@@ -5906,7 +5922,7 @@ var require_yauzl = __commonJS({
5906
5922
  if (options.validateEntrySizes == null) options.validateEntrySizes = true;
5907
5923
  if (options.strictFileNames == null) options.strictFileNames = false;
5908
5924
  if (callback == null) callback = defaultCallback;
5909
- fs33.open(path37, "r", function(err, fd) {
5925
+ fs33.open(path38, "r", function(err, fd) {
5910
5926
  if (err) return callback(err);
5911
5927
  fromFd(fd, options, function(err2, zipfile) {
5912
5928
  if (err2) fs33.close(fd, defaultCallback);
@@ -6508,12 +6524,12 @@ var require_extract_zip = __commonJS({
6508
6524
  var debug = require_src()("extract-zip");
6509
6525
  var { createWriteStream: createWriteStream5, promises: fs33 } = __require("fs");
6510
6526
  var getStream = require_get_stream();
6511
- var path37 = __require("path");
6527
+ var path38 = __require("path");
6512
6528
  var { promisify: promisify5 } = __require("util");
6513
6529
  var stream = __require("stream");
6514
6530
  var yauzl = require_yauzl();
6515
6531
  var openZip = promisify5(yauzl.open);
6516
- var pipeline2 = promisify5(stream.pipeline);
6532
+ var pipeline3 = promisify5(stream.pipeline);
6517
6533
  var Extractor = class {
6518
6534
  constructor(zipPath, opts) {
6519
6535
  this.zipPath = zipPath;
@@ -6545,12 +6561,12 @@ var require_extract_zip = __commonJS({
6545
6561
  this.zipfile.readEntry();
6546
6562
  return;
6547
6563
  }
6548
- const destDir = path37.dirname(path37.join(this.opts.dir, entry.fileName));
6564
+ const destDir = path38.dirname(path38.join(this.opts.dir, entry.fileName));
6549
6565
  try {
6550
6566
  await fs33.mkdir(destDir, { recursive: true });
6551
6567
  const canonicalDestDir = await fs33.realpath(destDir);
6552
- const relativeDestDir = path37.relative(this.opts.dir, canonicalDestDir);
6553
- if (relativeDestDir.split(path37.sep).includes("..")) {
6568
+ const relativeDestDir = path38.relative(this.opts.dir, canonicalDestDir);
6569
+ if (relativeDestDir.split(path38.sep).includes("..")) {
6554
6570
  throw new Error(`Out of bound path "${canonicalDestDir}" found while processing file ${entry.fileName}`);
6555
6571
  }
6556
6572
  await this.extractEntry(entry);
@@ -6572,7 +6588,7 @@ var require_extract_zip = __commonJS({
6572
6588
  if (this.opts.onEntry) {
6573
6589
  this.opts.onEntry(entry, this.zipfile);
6574
6590
  }
6575
- const dest = path37.join(this.opts.dir, entry.fileName);
6591
+ const dest = path38.join(this.opts.dir, entry.fileName);
6576
6592
  const mode = entry.externalFileAttributes >> 16 & 65535;
6577
6593
  const IFMT = 61440;
6578
6594
  const IFDIR = 16384;
@@ -6586,7 +6602,7 @@ var require_extract_zip = __commonJS({
6586
6602
  if (!isDir) isDir = madeBy === 0 && entry.externalFileAttributes === 16;
6587
6603
  debug("extracting entry", { filename: entry.fileName, isDir, isSymlink: symlink2 });
6588
6604
  const procMode = this.getExtractedMode(mode, isDir) & 511;
6589
- const destDir = isDir ? dest : path37.dirname(dest);
6605
+ const destDir = isDir ? dest : path38.dirname(dest);
6590
6606
  const mkdirOptions = { recursive: true };
6591
6607
  if (isDir) {
6592
6608
  mkdirOptions.mode = procMode;
@@ -6601,7 +6617,7 @@ var require_extract_zip = __commonJS({
6601
6617
  debug("creating symlink", link, dest);
6602
6618
  await fs33.symlink(link, dest);
6603
6619
  } else {
6604
- await pipeline2(readStream, createWriteStream5(dest, { mode: procMode }));
6620
+ await pipeline3(readStream, createWriteStream5(dest, { mode: procMode }));
6605
6621
  }
6606
6622
  }
6607
6623
  getExtractedMode(entryMode, isDir) {
@@ -6628,7 +6644,7 @@ var require_extract_zip = __commonJS({
6628
6644
  };
6629
6645
  module.exports = async function(zipPath, opts) {
6630
6646
  debug("creating target directory", opts.dir);
6631
- if (!path37.isAbsolute(opts.dir)) {
6647
+ if (!path38.isAbsolute(opts.dir)) {
6632
6648
  throw new Error("Target directory is expected to be absolute");
6633
6649
  }
6634
6650
  await fs33.mkdir(opts.dir, { recursive: true });
@@ -6660,7 +6676,7 @@ var require_strip_final_newline = __commonJS({
6660
6676
  var require_npm_run_path = __commonJS({
6661
6677
  "node_modules/run-jxa/node_modules/npm-run-path/index.js"(exports, module) {
6662
6678
  "use strict";
6663
- var path37 = __require("path");
6679
+ var path38 = __require("path");
6664
6680
  var pathKey = require_path_key();
6665
6681
  var npmRunPath = (options) => {
6666
6682
  options = {
@@ -6670,16 +6686,16 @@ var require_npm_run_path = __commonJS({
6670
6686
  ...options
6671
6687
  };
6672
6688
  let previous;
6673
- let cwdPath = path37.resolve(options.cwd);
6689
+ let cwdPath = path38.resolve(options.cwd);
6674
6690
  const result = [];
6675
6691
  while (previous !== cwdPath) {
6676
- result.push(path37.join(cwdPath, "node_modules/.bin"));
6692
+ result.push(path38.join(cwdPath, "node_modules/.bin"));
6677
6693
  previous = cwdPath;
6678
- cwdPath = path37.resolve(cwdPath, "..");
6694
+ cwdPath = path38.resolve(cwdPath, "..");
6679
6695
  }
6680
- const execPathDir = path37.resolve(options.cwd, options.execPath, "..");
6696
+ const execPathDir = path38.resolve(options.cwd, options.execPath, "..");
6681
6697
  result.push(execPathDir);
6682
- return result.concat(options.path).join(path37.delimiter);
6698
+ return result.concat(options.path).join(path38.delimiter);
6683
6699
  };
6684
6700
  module.exports = npmRunPath;
6685
6701
  module.exports.default = npmRunPath;
@@ -6689,9 +6705,9 @@ var require_npm_run_path = __commonJS({
6689
6705
  ...options
6690
6706
  };
6691
6707
  const env2 = { ...options.env };
6692
- const path38 = pathKey({ env: env2 });
6693
- options.path = env2[path38];
6694
- env2[path38] = module.exports(options);
6708
+ const path39 = pathKey({ env: env2 });
6709
+ options.path = env2[path39];
6710
+ env2[path39] = module.exports(options);
6695
6711
  return env2;
6696
6712
  };
6697
6713
  }
@@ -7807,7 +7823,7 @@ var require_command = __commonJS({
7807
7823
  var require_execa = __commonJS({
7808
7824
  "node_modules/run-jxa/node_modules/execa/index.js"(exports, module) {
7809
7825
  "use strict";
7810
- var path37 = __require("path");
7826
+ var path38 = __require("path");
7811
7827
  var childProcess3 = __require("child_process");
7812
7828
  var crossSpawn = require_cross_spawn();
7813
7829
  var stripFinalNewline = require_strip_final_newline();
@@ -7849,7 +7865,7 @@ var require_execa = __commonJS({
7849
7865
  };
7850
7866
  options.env = getEnv(options);
7851
7867
  options.stdio = normalizeStdio(options);
7852
- if (process.platform === "win32" && path37.basename(file, ".exe") === "cmd") {
7868
+ if (process.platform === "win32" && path38.basename(file, ".exe") === "cmd") {
7853
7869
  args.unshift("/q");
7854
7870
  }
7855
7871
  return { file, args, options, parsed };
@@ -12131,14 +12147,14 @@ var require_util3 = __commonJS({
12131
12147
  }
12132
12148
  const port = url.port != null ? url.port : url.protocol === "https:" ? 443 : 80;
12133
12149
  let origin = url.origin != null ? url.origin : `${url.protocol || ""}//${url.hostname || ""}:${port}`;
12134
- let path37 = url.path != null ? url.path : `${url.pathname || ""}${url.search || ""}`;
12150
+ let path38 = url.path != null ? url.path : `${url.pathname || ""}${url.search || ""}`;
12135
12151
  if (origin[origin.length - 1] === "/") {
12136
12152
  origin = origin.slice(0, origin.length - 1);
12137
12153
  }
12138
- if (path37 && path37[0] !== "/") {
12139
- path37 = `/${path37}`;
12154
+ if (path38 && path38[0] !== "/") {
12155
+ path38 = `/${path38}`;
12140
12156
  }
12141
- return new URL(`${origin}${path37}`);
12157
+ return new URL(`${origin}${path38}`);
12142
12158
  }
12143
12159
  if (!isHttpOrHttpsPrefixed(url.origin || url.protocol)) {
12144
12160
  throw new InvalidArgumentError("Invalid URL protocol: the URL must start with `http:` or `https:`.");
@@ -12700,9 +12716,9 @@ var require_diagnostics = __commonJS({
12700
12716
  "undici:client:sendHeaders",
12701
12717
  (evt) => {
12702
12718
  const {
12703
- request: { method, path: path37, origin }
12719
+ request: { method, path: path38, origin }
12704
12720
  } = evt;
12705
- debugLog("sending request to %s %s/%s", method, origin, path37);
12721
+ debugLog("sending request to %s %s/%s", method, origin, path38);
12706
12722
  }
12707
12723
  );
12708
12724
  }
@@ -12716,14 +12732,14 @@ var require_diagnostics = __commonJS({
12716
12732
  "undici:request:headers",
12717
12733
  (evt) => {
12718
12734
  const {
12719
- request: { method, path: path37, origin },
12735
+ request: { method, path: path38, origin },
12720
12736
  response: { statusCode }
12721
12737
  } = evt;
12722
12738
  debugLog(
12723
12739
  "received response to %s %s/%s - HTTP %d",
12724
12740
  method,
12725
12741
  origin,
12726
- path37,
12742
+ path38,
12727
12743
  statusCode
12728
12744
  );
12729
12745
  }
@@ -12732,23 +12748,23 @@ var require_diagnostics = __commonJS({
12732
12748
  "undici:request:trailers",
12733
12749
  (evt) => {
12734
12750
  const {
12735
- request: { method, path: path37, origin }
12751
+ request: { method, path: path38, origin }
12736
12752
  } = evt;
12737
- debugLog("trailers received from %s %s/%s", method, origin, path37);
12753
+ debugLog("trailers received from %s %s/%s", method, origin, path38);
12738
12754
  }
12739
12755
  );
12740
12756
  diagnosticsChannel.subscribe(
12741
12757
  "undici:request:error",
12742
12758
  (evt) => {
12743
12759
  const {
12744
- request: { method, path: path37, origin },
12760
+ request: { method, path: path38, origin },
12745
12761
  error
12746
12762
  } = evt;
12747
12763
  debugLog(
12748
12764
  "request to %s %s/%s errored - %s",
12749
12765
  method,
12750
12766
  origin,
12751
- path37,
12767
+ path38,
12752
12768
  error.message
12753
12769
  );
12754
12770
  }
@@ -12843,7 +12859,7 @@ var require_request = __commonJS({
12843
12859
  var kHandler = Symbol("handler");
12844
12860
  var Request = class {
12845
12861
  constructor(origin, {
12846
- path: path37,
12862
+ path: path38,
12847
12863
  method,
12848
12864
  body,
12849
12865
  headers,
@@ -12858,11 +12874,11 @@ var require_request = __commonJS({
12858
12874
  servername,
12859
12875
  throwOnError
12860
12876
  }, handler2) {
12861
- if (typeof path37 !== "string") {
12877
+ if (typeof path38 !== "string") {
12862
12878
  throw new InvalidArgumentError("path must be a string");
12863
- } else if (path37[0] !== "/" && !(path37.startsWith("http://") || path37.startsWith("https://")) && method !== "CONNECT") {
12879
+ } else if (path38[0] !== "/" && !(path38.startsWith("http://") || path38.startsWith("https://")) && method !== "CONNECT") {
12864
12880
  throw new InvalidArgumentError("path must be an absolute URL or start with a slash");
12865
- } else if (invalidPathRegex.test(path37)) {
12881
+ } else if (invalidPathRegex.test(path38)) {
12866
12882
  throw new InvalidArgumentError("invalid request path");
12867
12883
  }
12868
12884
  if (typeof method !== "string") {
@@ -12927,7 +12943,7 @@ var require_request = __commonJS({
12927
12943
  this.completed = false;
12928
12944
  this.aborted = false;
12929
12945
  this.upgrade = upgrade || null;
12930
- this.path = query ? serializePathWithQuery(path37, query) : path37;
12946
+ this.path = query ? serializePathWithQuery(path38, query) : path38;
12931
12947
  this.origin = origin;
12932
12948
  this.idempotent = idempotent == null ? method === "HEAD" || method === "GET" : idempotent;
12933
12949
  this.blocking = blocking ?? this.method !== "HEAD";
@@ -15337,11 +15353,11 @@ var require_util4 = __commonJS({
15337
15353
  var { isUint8Array } = __require("node:util/types");
15338
15354
  var { webidl } = require_webidl();
15339
15355
  var supportedHashes = [];
15340
- var crypto3;
15356
+ var crypto4;
15341
15357
  try {
15342
- crypto3 = __require("node:crypto");
15358
+ crypto4 = __require("node:crypto");
15343
15359
  const possibleRelevantHashes = ["sha256", "sha384", "sha512"];
15344
- supportedHashes = crypto3.getHashes().filter((hash) => possibleRelevantHashes.includes(hash));
15360
+ supportedHashes = crypto4.getHashes().filter((hash) => possibleRelevantHashes.includes(hash));
15345
15361
  } catch {
15346
15362
  }
15347
15363
  function responseURL(response) {
@@ -15644,7 +15660,7 @@ var require_util4 = __commonJS({
15644
15660
  return isOriginPotentiallyTrustworthy(url.origin);
15645
15661
  }
15646
15662
  function bytesMatch(bytes, metadataList) {
15647
- if (crypto3 === void 0) {
15663
+ if (crypto4 === void 0) {
15648
15664
  return true;
15649
15665
  }
15650
15666
  const parsedMetadata = parseMetadata(metadataList);
@@ -15659,7 +15675,7 @@ var require_util4 = __commonJS({
15659
15675
  for (const item of metadata) {
15660
15676
  const algorithm = item.algo;
15661
15677
  const expectedValue = item.hash;
15662
- let actualValue = crypto3.createHash(algorithm).update(bytes).digest("base64");
15678
+ let actualValue = crypto4.createHash(algorithm).update(bytes).digest("base64");
15663
15679
  if (actualValue[actualValue.length - 1] === "=") {
15664
15680
  if (actualValue[actualValue.length - 2] === "=") {
15665
15681
  actualValue = actualValue.slice(0, -2);
@@ -16677,8 +16693,8 @@ var require_body = __commonJS({
16677
16693
  var { multipartFormDataParser } = require_formdata_parser();
16678
16694
  var random;
16679
16695
  try {
16680
- const crypto3 = __require("node:crypto");
16681
- random = (max) => crypto3.randomInt(0, max);
16696
+ const crypto4 = __require("node:crypto");
16697
+ random = (max) => crypto4.randomInt(0, max);
16682
16698
  } catch {
16683
16699
  random = (max) => Math.floor(Math.random() * max);
16684
16700
  }
@@ -17712,7 +17728,7 @@ var require_client_h1 = __commonJS({
17712
17728
  return method !== "GET" && method !== "HEAD" && method !== "OPTIONS" && method !== "TRACE" && method !== "CONNECT";
17713
17729
  }
17714
17730
  function writeH1(client, request) {
17715
- const { method, path: path37, host, upgrade, blocking, reset } = request;
17731
+ const { method, path: path38, host, upgrade, blocking, reset } = request;
17716
17732
  let { body, headers, contentLength } = request;
17717
17733
  const expectsPayload = method === "PUT" || method === "POST" || method === "PATCH" || method === "QUERY" || method === "PROPFIND" || method === "PROPPATCH";
17718
17734
  if (util2.isFormDataLike(body)) {
@@ -17778,7 +17794,7 @@ var require_client_h1 = __commonJS({
17778
17794
  if (blocking) {
17779
17795
  socket[kBlocking] = true;
17780
17796
  }
17781
- let header = `${method} ${path37} HTTP/1.1\r
17797
+ let header = `${method} ${path38} HTTP/1.1\r
17782
17798
  `;
17783
17799
  if (typeof host === "string") {
17784
17800
  header += `host: ${host}\r
@@ -18129,7 +18145,7 @@ var require_client_h2 = __commonJS({
18129
18145
  "packages/cli/node_modules/undici/lib/dispatcher/client-h2.js"(exports, module) {
18130
18146
  "use strict";
18131
18147
  var assert = __require("node:assert");
18132
- var { pipeline: pipeline2 } = __require("node:stream");
18148
+ var { pipeline: pipeline3 } = __require("node:stream");
18133
18149
  var util2 = require_util3();
18134
18150
  var {
18135
18151
  RequestContentLengthMismatchError,
@@ -18335,7 +18351,7 @@ var require_client_h2 = __commonJS({
18335
18351
  function writeH2(client, request) {
18336
18352
  const requestTimeout = request.bodyTimeout ?? client[kBodyTimeout];
18337
18353
  const session = client[kHTTP2Session];
18338
- const { method, path: path37, host, upgrade, expectContinue, signal, headers: reqHeaders } = request;
18354
+ const { method, path: path38, host, upgrade, expectContinue, signal, headers: reqHeaders } = request;
18339
18355
  let { body } = request;
18340
18356
  if (upgrade) {
18341
18357
  util2.errorRequest(client, request, new Error("Upgrade not supported for H2"));
@@ -18406,7 +18422,7 @@ var require_client_h2 = __commonJS({
18406
18422
  stream.setTimeout(requestTimeout);
18407
18423
  return true;
18408
18424
  }
18409
- headers[HTTP2_HEADER_PATH] = path37;
18425
+ headers[HTTP2_HEADER_PATH] = path38;
18410
18426
  headers[HTTP2_HEADER_SCHEME] = "https";
18411
18427
  const expectsPayload = method === "PUT" || method === "POST" || method === "PATCH";
18412
18428
  if (body && typeof body.read === "function") {
@@ -18624,7 +18640,7 @@ var require_client_h2 = __commonJS({
18624
18640
  }
18625
18641
  function writeStream(abort, socket, expectsPayload, h2stream, body, client, request, contentLength) {
18626
18642
  assert(contentLength !== 0 || client[kRunning] === 0, "stream body cannot be pipelined");
18627
- const pipe = pipeline2(
18643
+ const pipe = pipeline3(
18628
18644
  body,
18629
18645
  h2stream,
18630
18646
  (err) => {
@@ -21518,7 +21534,7 @@ var require_api_pipeline = __commonJS({
21518
21534
  util2.destroy(ret, err);
21519
21535
  }
21520
21536
  };
21521
- function pipeline2(opts, handler2) {
21537
+ function pipeline3(opts, handler2) {
21522
21538
  try {
21523
21539
  const pipelineHandler = new PipelineHandler(opts, handler2);
21524
21540
  this.dispatch({ ...opts, body: pipelineHandler.req }, pipelineHandler);
@@ -21527,7 +21543,7 @@ var require_api_pipeline = __commonJS({
21527
21543
  return new PassThrough().destroy(err);
21528
21544
  }
21529
21545
  }
21530
- module.exports = pipeline2;
21546
+ module.exports = pipeline3;
21531
21547
  }
21532
21548
  });
21533
21549
 
@@ -21888,20 +21904,20 @@ var require_mock_utils = __commonJS({
21888
21904
  }
21889
21905
  return normalizedQp;
21890
21906
  }
21891
- function safeUrl(path37) {
21892
- if (typeof path37 !== "string") {
21893
- return path37;
21907
+ function safeUrl(path38) {
21908
+ if (typeof path38 !== "string") {
21909
+ return path38;
21894
21910
  }
21895
- const pathSegments = path37.split("?", 3);
21911
+ const pathSegments = path38.split("?", 3);
21896
21912
  if (pathSegments.length !== 2) {
21897
- return path37;
21913
+ return path38;
21898
21914
  }
21899
21915
  const qp = new URLSearchParams(pathSegments.pop());
21900
21916
  qp.sort();
21901
21917
  return [...pathSegments, qp.toString()].join("?");
21902
21918
  }
21903
- function matchKey(mockDispatch2, { path: path37, method, body, headers }) {
21904
- const pathMatch = matchValue(mockDispatch2.path, path37);
21919
+ function matchKey(mockDispatch2, { path: path38, method, body, headers }) {
21920
+ const pathMatch = matchValue(mockDispatch2.path, path38);
21905
21921
  const methodMatch = matchValue(mockDispatch2.method, method);
21906
21922
  const bodyMatch = typeof mockDispatch2.body !== "undefined" ? matchValue(mockDispatch2.body, body) : true;
21907
21923
  const headersMatch = matchHeaders(mockDispatch2, headers);
@@ -21926,8 +21942,8 @@ var require_mock_utils = __commonJS({
21926
21942
  const basePath = key.query ? serializePathWithQuery(key.path, key.query) : key.path;
21927
21943
  const resolvedPath = typeof basePath === "string" ? safeUrl(basePath) : basePath;
21928
21944
  const resolvedPathWithoutTrailingSlash = removeTrailingSlash(resolvedPath);
21929
- let matchedMockDispatches = mockDispatches.filter(({ consumed }) => !consumed).filter(({ path: path37, ignoreTrailingSlash }) => {
21930
- return ignoreTrailingSlash ? matchValue(removeTrailingSlash(safeUrl(path37)), resolvedPathWithoutTrailingSlash) : matchValue(safeUrl(path37), resolvedPath);
21945
+ let matchedMockDispatches = mockDispatches.filter(({ consumed }) => !consumed).filter(({ path: path38, ignoreTrailingSlash }) => {
21946
+ return ignoreTrailingSlash ? matchValue(removeTrailingSlash(safeUrl(path38)), resolvedPathWithoutTrailingSlash) : matchValue(safeUrl(path38), resolvedPath);
21931
21947
  });
21932
21948
  if (matchedMockDispatches.length === 0) {
21933
21949
  throw new MockNotMatchedError(`Mock dispatch not matched for path '${resolvedPath}'`);
@@ -21965,19 +21981,19 @@ var require_mock_utils = __commonJS({
21965
21981
  mockDispatches.splice(index, 1);
21966
21982
  }
21967
21983
  }
21968
- function removeTrailingSlash(path37) {
21969
- while (path37.endsWith("/")) {
21970
- path37 = path37.slice(0, -1);
21984
+ function removeTrailingSlash(path38) {
21985
+ while (path38.endsWith("/")) {
21986
+ path38 = path38.slice(0, -1);
21971
21987
  }
21972
- if (path37.length === 0) {
21973
- path37 = "/";
21988
+ if (path38.length === 0) {
21989
+ path38 = "/";
21974
21990
  }
21975
- return path37;
21991
+ return path38;
21976
21992
  }
21977
21993
  function buildKey(opts) {
21978
- const { path: path37, method, body, headers, query } = opts;
21994
+ const { path: path38, method, body, headers, query } = opts;
21979
21995
  return {
21980
- path: path37,
21996
+ path: path38,
21981
21997
  method,
21982
21998
  body,
21983
21999
  headers,
@@ -22628,10 +22644,10 @@ var require_pending_interceptors_formatter = __commonJS({
22628
22644
  }
22629
22645
  format(pendingInterceptors) {
22630
22646
  const withPrettyHeaders = pendingInterceptors.map(
22631
- ({ method, path: path37, data: { statusCode }, persist, times, timesInvoked, origin }) => ({
22647
+ ({ method, path: path38, data: { statusCode }, persist, times, timesInvoked, origin }) => ({
22632
22648
  Method: method,
22633
22649
  Origin: origin,
22634
- Path: path37,
22650
+ Path: path38,
22635
22651
  "Status code": statusCode,
22636
22652
  Persistent: persist ? PERSISTENT : NOT_PERSISTENT,
22637
22653
  Invocations: timesInvoked,
@@ -22708,9 +22724,9 @@ var require_mock_agent = __commonJS({
22708
22724
  const acceptNonStandardSearchParameters = this[kMockAgentAcceptsNonStandardSearchParameters];
22709
22725
  const dispatchOpts = { ...opts };
22710
22726
  if (acceptNonStandardSearchParameters && dispatchOpts.path) {
22711
- const [path37, searchParams] = dispatchOpts.path.split("?");
22727
+ const [path38, searchParams] = dispatchOpts.path.split("?");
22712
22728
  const normalizedSearchParams = normalizeSearchParams(searchParams, acceptNonStandardSearchParameters);
22713
- dispatchOpts.path = `${path37}?${normalizedSearchParams}`;
22729
+ dispatchOpts.path = `${path38}?${normalizedSearchParams}`;
22714
22730
  }
22715
22731
  return this[kAgent].dispatch(dispatchOpts, handler2);
22716
22732
  }
@@ -23004,9 +23020,9 @@ var require_redirect_handler = __commonJS({
23004
23020
  return;
23005
23021
  }
23006
23022
  const { origin, pathname, search } = util2.parseURL(new URL(this.location, this.opts.origin && new URL(this.opts.path, this.opts.origin)));
23007
- const path37 = search ? `${pathname}${search}` : pathname;
23023
+ const path38 = search ? `${pathname}${search}` : pathname;
23008
23024
  this.opts.headers = cleanRequestHeaders(this.opts.headers, statusCode === 303, this.opts.origin !== origin);
23009
- this.opts.path = path37;
23025
+ this.opts.path = path38;
23010
23026
  this.opts.origin = origin;
23011
23027
  this.opts.maxRedirections = 0;
23012
23028
  this.opts.query = null;
@@ -26943,7 +26959,7 @@ var require_fetch = __commonJS({
26943
26959
  subresourceSet
26944
26960
  } = require_constants3();
26945
26961
  var EE = __require("node:events");
26946
- var { Readable, pipeline: pipeline2, finished, isErrored, isReadable } = __require("node:stream");
26962
+ var { Readable, pipeline: pipeline3, finished, isErrored, isReadable } = __require("node:stream");
26947
26963
  var { addAbortListener, bufferToLowerCasedHeaderName } = require_util3();
26948
26964
  var { dataURLProcessor, serializeAMimeType, minimizeSupportedMimeType } = require_data_url();
26949
26965
  var { getGlobalDispatcher } = require_global2();
@@ -27886,7 +27902,7 @@ var require_fetch = __commonJS({
27886
27902
  status,
27887
27903
  statusText,
27888
27904
  headersList,
27889
- body: decoders.length ? pipeline2(this.body, ...decoders, (err) => {
27905
+ body: decoders.length ? pipeline3(this.body, ...decoders, (err) => {
27890
27906
  if (err) {
27891
27907
  this.onError(err);
27892
27908
  }
@@ -28708,9 +28724,9 @@ var require_util6 = __commonJS({
28708
28724
  }
28709
28725
  }
28710
28726
  }
28711
- function validateCookiePath(path37) {
28712
- for (let i = 0; i < path37.length; ++i) {
28713
- const code = path37.charCodeAt(i);
28727
+ function validateCookiePath(path38) {
28728
+ for (let i = 0; i < path38.length; ++i) {
28729
+ const code = path38.charCodeAt(i);
28714
28730
  if (code < 32 || // exclude CTLs (0-31)
28715
28731
  code === 127 || // DEL
28716
28732
  code === 59) {
@@ -29595,13 +29611,13 @@ var require_frame = __commonJS({
29595
29611
  "use strict";
29596
29612
  var { maxUnsigned16Bit, opcodes } = require_constants5();
29597
29613
  var BUFFER_SIZE = 8 * 1024;
29598
- var crypto3;
29614
+ var crypto4;
29599
29615
  var buffer = null;
29600
29616
  var bufIdx = BUFFER_SIZE;
29601
29617
  try {
29602
- crypto3 = __require("node:crypto");
29618
+ crypto4 = __require("node:crypto");
29603
29619
  } catch {
29604
- crypto3 = {
29620
+ crypto4 = {
29605
29621
  // not full compatibility, but minimum.
29606
29622
  randomFillSync: function randomFillSync(buffer2, _offset, _size) {
29607
29623
  for (let i = 0; i < buffer2.length; ++i) {
@@ -29614,7 +29630,7 @@ var require_frame = __commonJS({
29614
29630
  function generateMask() {
29615
29631
  if (bufIdx === BUFFER_SIZE) {
29616
29632
  bufIdx = 0;
29617
- crypto3.randomFillSync(buffer ??= Buffer.allocUnsafeSlow(BUFFER_SIZE), 0, BUFFER_SIZE);
29633
+ crypto4.randomFillSync(buffer ??= Buffer.allocUnsafeSlow(BUFFER_SIZE), 0, BUFFER_SIZE);
29618
29634
  }
29619
29635
  return [buffer[bufIdx++], buffer[bufIdx++], buffer[bufIdx++], buffer[bufIdx++]];
29620
29636
  }
@@ -29712,9 +29728,9 @@ var require_connection = __commonJS({
29712
29728
  var { getDecodeSplit } = require_util4();
29713
29729
  var { WebsocketFrameSend } = require_frame();
29714
29730
  var assert = __require("node:assert");
29715
- var crypto3;
29731
+ var crypto4;
29716
29732
  try {
29717
- crypto3 = __require("node:crypto");
29733
+ crypto4 = __require("node:crypto");
29718
29734
  } catch {
29719
29735
  }
29720
29736
  function establishWebSocketConnection(url, protocols, client, handler2, options) {
@@ -29734,7 +29750,7 @@ var require_connection = __commonJS({
29734
29750
  const headersList = getHeadersList(new Headers(options.headers));
29735
29751
  request.headersList = headersList;
29736
29752
  }
29737
- const keyValue = crypto3.randomBytes(16).toString("base64");
29753
+ const keyValue = crypto4.randomBytes(16).toString("base64");
29738
29754
  request.headersList.append("sec-websocket-key", keyValue, true);
29739
29755
  request.headersList.append("sec-websocket-version", "13", true);
29740
29756
  for (const protocol of protocols) {
@@ -29767,7 +29783,7 @@ var require_connection = __commonJS({
29767
29783
  return;
29768
29784
  }
29769
29785
  const secWSAccept = response.headersList.get("Sec-WebSocket-Accept");
29770
- const digest = crypto3.createHash("sha1").update(keyValue + uid).digest("base64");
29786
+ const digest = crypto4.createHash("sha1").update(keyValue + uid).digest("base64");
29771
29787
  if (secWSAccept !== digest) {
29772
29788
  failWebsocketConnection(handler2, 1002, "Incorrect hash received in Sec-WebSocket-Accept header.");
29773
29789
  return;
@@ -31379,7 +31395,7 @@ ${value}`;
31379
31395
  var require_eventsource = __commonJS({
31380
31396
  "packages/cli/node_modules/undici/lib/web/eventsource/eventsource.js"(exports, module) {
31381
31397
  "use strict";
31382
- var { pipeline: pipeline2 } = __require("node:stream");
31398
+ var { pipeline: pipeline3 } = __require("node:stream");
31383
31399
  var { fetching } = require_fetch();
31384
31400
  var { makeRequest } = require_request2();
31385
31401
  var { webidl } = require_webidl();
@@ -31540,7 +31556,7 @@ var require_eventsource = __commonJS({
31540
31556
  ));
31541
31557
  }
31542
31558
  });
31543
- pipeline2(
31559
+ pipeline3(
31544
31560
  response.body.stream,
31545
31561
  eventSourceStream,
31546
31562
  (error) => {
@@ -31750,11 +31766,11 @@ var require_undici = __commonJS({
31750
31766
  if (typeof opts.path !== "string") {
31751
31767
  throw new InvalidArgumentError("invalid opts.path");
31752
31768
  }
31753
- let path37 = opts.path;
31769
+ let path38 = opts.path;
31754
31770
  if (!opts.path.startsWith("/")) {
31755
- path37 = `/${path37}`;
31771
+ path38 = `/${path38}`;
31756
31772
  }
31757
- url = new URL(util2.parseOrigin(url).origin + path37);
31773
+ url = new URL(util2.parseOrigin(url).origin + path38);
31758
31774
  } else {
31759
31775
  if (!opts) {
31760
31776
  opts = typeof url === "object" ? url : {};
@@ -32426,15 +32442,20 @@ function useKeypress(onKeypress, {
32426
32442
  priority
32427
32443
  }) {
32428
32444
  const { subscribe, unsubscribe } = useKeypressContext();
32445
+ const onKeypressRef = (0, import_react2.useRef)(onKeypress);
32446
+ (0, import_react2.useEffect)(() => {
32447
+ onKeypressRef.current = onKeypress;
32448
+ }, [onKeypress]);
32429
32449
  (0, import_react2.useEffect)(() => {
32430
32450
  if (!isActive) {
32431
32451
  return;
32432
32452
  }
32433
- subscribe(onKeypress, priority);
32453
+ const handler2 = (key) => onKeypressRef.current(key);
32454
+ subscribe(handler2, priority);
32434
32455
  return () => {
32435
- unsubscribe(onKeypress);
32456
+ unsubscribe(handler2);
32436
32457
  };
32437
- }, [isActive, onKeypress, subscribe, unsubscribe, priority]);
32458
+ }, [isActive, subscribe, unsubscribe, priority]);
32438
32459
  }
32439
32460
 
32440
32461
  // packages/cli/src/ui/hooks/useFocus.ts
@@ -36652,13 +36673,47 @@ var NoColorTheme = new Theme(
36652
36673
 
36653
36674
  // packages/cli/src/ui/themes/theme-manager.ts
36654
36675
  import process2 from "node:process";
36676
+ var import_strip_json_comments = __toESM(require_strip_json_comments(), 1);
36677
+ var SINGLE_CUSTOM_THEME_KEYS = /* @__PURE__ */ new Set([
36678
+ "type",
36679
+ "name",
36680
+ "text",
36681
+ "background",
36682
+ "border",
36683
+ "ui",
36684
+ "status",
36685
+ "Background",
36686
+ "Foreground",
36687
+ "LightBlue",
36688
+ "AccentBlue",
36689
+ "AccentPurple",
36690
+ "AccentCyan",
36691
+ "AccentGreen",
36692
+ "AccentYellow",
36693
+ "AccentRed",
36694
+ "DiffAdded",
36695
+ "DiffRemoved",
36696
+ "Comment",
36697
+ "Gray",
36698
+ "DarkGray",
36699
+ "GradientColors"
36700
+ ]);
36701
+ function isPlainRecord(value) {
36702
+ return typeof value === "object" && value !== null && !Array.isArray(value);
36703
+ }
36704
+ function isStringValue(value) {
36705
+ return typeof value === "string";
36706
+ }
36655
36707
  var DEFAULT_THEME = DefaultDark;
36656
36708
  var ThemeManager = class {
36657
36709
  availableThemes;
36658
36710
  activeTheme;
36711
+ userThemes = /* @__PURE__ */ new Map();
36712
+ userThemesLoaded = false;
36659
36713
  settingsThemes = /* @__PURE__ */ new Map();
36660
36714
  extensionThemes = /* @__PURE__ */ new Map();
36661
36715
  fileThemes = /* @__PURE__ */ new Map();
36716
+ fileThemesByPath = /* @__PURE__ */ new Map();
36662
36717
  terminalBackground;
36663
36718
  // Cache for dynamic colors
36664
36719
  cachedColors;
@@ -36742,8 +36797,181 @@ var ThemeManager = class {
36742
36797
  debugLogger.warn(`Invalid custom theme "${name}": ${validation.error}`);
36743
36798
  }
36744
36799
  }
36745
- if (this.activeTheme && this.activeTheme.type === "custom" && this.settingsThemes.has(this.activeTheme.name)) {
36746
- this.activeTheme = this.settingsThemes.get(this.activeTheme.name);
36800
+ if (this.activeTheme && this.activeTheme.type === "custom" && !this.userThemes.has(this.activeTheme.name)) {
36801
+ const updatedSettingsTheme = this.settingsThemes.get(
36802
+ this.activeTheme.name
36803
+ );
36804
+ if (updatedSettingsTheme) {
36805
+ this.activeTheme = updatedSettingsTheme;
36806
+ this.clearCache();
36807
+ }
36808
+ }
36809
+ }
36810
+ /**
36811
+ * Returns candidate standalone theme.json paths in ascending precedence order:
36812
+ * 1. ~/.config/gemini/theme.json
36813
+ * 2. $XDG_CONFIG_HOME/gemini/theme.json (if XDG_CONFIG_HOME is set)
36814
+ * 3. ~/.gemini/theme.json (respecting GEMINI_CLI_HOME via homedir())
36815
+ */
36816
+ getUserThemePaths() {
36817
+ const homeDir = this.homedir();
36818
+ if (!homeDir) {
36819
+ return [];
36820
+ }
36821
+ const candidates = [
36822
+ path.join(homeDir, ".config", "gemini", "theme.json")
36823
+ ];
36824
+ const xdgConfigHome = process2.env["XDG_CONFIG_HOME"];
36825
+ if (xdgConfigHome) {
36826
+ candidates.push(path.join(xdgConfigHome, "gemini", "theme.json"));
36827
+ }
36828
+ candidates.push(path.join(homeDir, GEMINI_DIR, "theme.json"));
36829
+ const deduplicatedByKey = /* @__PURE__ */ new Map();
36830
+ for (const candidate of candidates) {
36831
+ const resolved = path.resolve(candidate);
36832
+ const key = normalizePath(resolved);
36833
+ deduplicatedByKey.delete(key);
36834
+ deduplicatedByKey.set(key, resolved);
36835
+ }
36836
+ return Array.from(deduplicatedByKey.values());
36837
+ }
36838
+ parseUserThemeEntries(parsed) {
36839
+ if (!isPlainRecord(parsed)) {
36840
+ return [];
36841
+ }
36842
+ const keys = Object.keys(parsed);
36843
+ if (keys.length === 0) {
36844
+ return [];
36845
+ }
36846
+ if (parsed["type"] !== "custom") {
36847
+ const customThemes = parsed["customThemes"];
36848
+ if (isPlainRecord(customThemes)) {
36849
+ return Object.entries(customThemes).filter(
36850
+ (entry) => isPlainRecord(entry[1])
36851
+ );
36852
+ }
36853
+ const ui2 = parsed["ui"];
36854
+ if (isPlainRecord(ui2)) {
36855
+ const uiCustomThemes = ui2["customThemes"];
36856
+ if (isPlainRecord(uiCustomThemes)) {
36857
+ return Object.entries(uiCustomThemes).filter(
36858
+ (entry) => isPlainRecord(entry[1])
36859
+ );
36860
+ }
36861
+ }
36862
+ }
36863
+ const rawName = parsed["name"];
36864
+ const hasNestedCustomTheme = Object.values(parsed).some(
36865
+ (val) => isPlainRecord(val) && val["type"] === "custom"
36866
+ );
36867
+ const isSingleTheme = !hasNestedCustomTheme && (parsed["type"] === "custom" || isStringValue(rawName) || keys.every((key) => SINGLE_CUSTOM_THEME_KEYS.has(key)));
36868
+ if (isSingleTheme) {
36869
+ const themeName = isStringValue(rawName) && rawName.trim().length > 0 ? rawName : "custom";
36870
+ return [[themeName, parsed]];
36871
+ }
36872
+ return Object.entries(parsed).filter(
36873
+ (entry) => isPlainRecord(entry[1])
36874
+ );
36875
+ }
36876
+ resolveRealPath(targetPath) {
36877
+ return stripExtendedLengthPrefix(this.fs.realpathSync(targetPath));
36878
+ }
36879
+ resolveCanonicalDirectory(dirPath) {
36880
+ const resolvedDir = path.resolve(dirPath);
36881
+ try {
36882
+ const canonical = this.resolveRealPath(resolvedDir);
36883
+ if (isStringValue(canonical) && canonical.length > 0) {
36884
+ return path.resolve(canonical);
36885
+ }
36886
+ } catch {
36887
+ }
36888
+ return resolvedDir;
36889
+ }
36890
+ /**
36891
+ * Loads custom themes from standalone user theme.json files
36892
+ * (~/.gemini/theme.json and XDG fallback ~/.config/gemini/theme.json).
36893
+ */
36894
+ loadUserThemes() {
36895
+ this.userThemes.clear();
36896
+ this.userThemesLoaded = true;
36897
+ const homeDir = this.homedir();
36898
+ if (!homeDir) {
36899
+ return;
36900
+ }
36901
+ const trustedRoots = [this.resolveCanonicalDirectory(homeDir)];
36902
+ const xdgConfigHome = process2.env["XDG_CONFIG_HOME"];
36903
+ if (xdgConfigHome) {
36904
+ trustedRoots.push(this.resolveCanonicalDirectory(xdgConfigHome));
36905
+ }
36906
+ for (const candidatePath of this.getUserThemePaths()) {
36907
+ try {
36908
+ if (!this.fs.existsSync(candidatePath)) {
36909
+ continue;
36910
+ }
36911
+ const canonicalPath = this.resolveRealPath(candidatePath);
36912
+ if (!trustedRoots.some((rootDir) => isSubpath(rootDir, canonicalPath))) {
36913
+ debugLogger.warn(
36914
+ `Theme file at "${candidatePath}" resolves outside trusted configuration directories. Only load themes from trusted sources.`
36915
+ );
36916
+ continue;
36917
+ }
36918
+ const rawContent = this.fs.readFileSync(canonicalPath, "utf-8");
36919
+ const parsed = JSON.parse((0, import_strip_json_comments.default)(rawContent));
36920
+ if (!isPlainRecord(parsed)) {
36921
+ debugLogger.warn(
36922
+ `Invalid theme file "${candidatePath}": expected a JSON object.`
36923
+ );
36924
+ continue;
36925
+ }
36926
+ const entries = this.parseUserThemeEntries(parsed);
36927
+ for (const [entryKey, rawThemeConfig] of entries) {
36928
+ const rawConfigName = rawThemeConfig.name;
36929
+ const resolvedName = isStringValue(rawConfigName) && rawConfigName.trim().length > 0 ? rawConfigName : entryKey;
36930
+ const candidateConfig = {
36931
+ ...rawThemeConfig,
36932
+ name: resolvedName
36933
+ };
36934
+ const validation = validateCustomTheme(candidateConfig);
36935
+ if (!validation.isValid) {
36936
+ debugLogger.warn(
36937
+ `Invalid custom theme "${entryKey}" in "${candidatePath}": ${validation.error}`
36938
+ );
36939
+ continue;
36940
+ }
36941
+ if (validation.warning) {
36942
+ debugLogger.warn(`Theme "${entryKey}": ${validation.warning}`);
36943
+ }
36944
+ const themeWithDefaults = {
36945
+ ...DEFAULT_THEME.colors,
36946
+ ...candidateConfig,
36947
+ name: resolvedName,
36948
+ type: "custom"
36949
+ };
36950
+ try {
36951
+ const theme2 = createCustomTheme(themeWithDefaults);
36952
+ this.userThemes.set(resolvedName, theme2);
36953
+ } catch (error) {
36954
+ debugLogger.warn(
36955
+ `Failed to load custom theme "${entryKey}" from "${candidatePath}":`,
36956
+ error
36957
+ );
36958
+ }
36959
+ }
36960
+ } catch (error) {
36961
+ if (!(error instanceof Error && "code" in error && error.code === "ENOENT")) {
36962
+ debugLogger.warn(
36963
+ `Could not load themes from "${candidatePath}":`,
36964
+ error
36965
+ );
36966
+ }
36967
+ }
36968
+ }
36969
+ this.clearCache();
36970
+ if (this.activeTheme && this.activeTheme.type === "custom") {
36971
+ const updatedUserTheme = this.userThemes.get(this.activeTheme.name);
36972
+ if (updatedUserTheme) {
36973
+ this.activeTheme = updatedUserTheme;
36974
+ }
36747
36975
  }
36748
36976
  }
36749
36977
  /**
@@ -36821,12 +37049,21 @@ var ThemeManager = class {
36821
37049
  clearExtensionThemes() {
36822
37050
  this.extensionThemes.clear();
36823
37051
  }
37052
+ /**
37053
+ * Clears all standalone user themes loaded from theme.json files.
37054
+ * This is primarily for testing purposes to reset state between tests.
37055
+ */
37056
+ clearUserThemes() {
37057
+ this.userThemes.clear();
37058
+ this.userThemesLoaded = false;
37059
+ }
36824
37060
  /**
36825
37061
  * Clears all themes loaded from files.
36826
37062
  * This is primarily for testing purposes to reset state between tests.
36827
37063
  */
36828
37064
  clearFileThemes() {
36829
37065
  this.fileThemes.clear();
37066
+ this.fileThemesByPath.clear();
36830
37067
  }
36831
37068
  /**
36832
37069
  * Re-initializes the ThemeManager with new dependencies.
@@ -36839,6 +37076,10 @@ var ThemeManager = class {
36839
37076
  if (dependencies.homedir) {
36840
37077
  this.homedir = dependencies.homedir;
36841
37078
  }
37079
+ this.userThemes.clear();
37080
+ this.userThemesLoaded = false;
37081
+ this.fileThemes.clear();
37082
+ this.fileThemesByPath.clear();
36842
37083
  }
36843
37084
  /**
36844
37085
  * Resets the ThemeManager state to defaults.
@@ -36848,9 +37089,12 @@ var ThemeManager = class {
36848
37089
  if (dependencies) {
36849
37090
  this.reinitialize(dependencies);
36850
37091
  }
37092
+ this.userThemes.clear();
37093
+ this.userThemesLoaded = false;
36851
37094
  this.settingsThemes.clear();
36852
37095
  this.extensionThemes.clear();
36853
37096
  this.fileThemes.clear();
37097
+ this.fileThemesByPath.clear();
36854
37098
  this.activeTheme = DEFAULT_THEME;
36855
37099
  this.terminalBackground = void 0;
36856
37100
  this.clearCache();
@@ -36878,7 +37122,7 @@ var ThemeManager = class {
36878
37122
  const isBuiltIn = this.availableThemes.some(
36879
37123
  (t) => t.name === this.activeTheme.name
36880
37124
  );
36881
- const isCustom = [...this.settingsThemes.values()].includes(this.activeTheme) || [...this.extensionThemes.values()].includes(this.activeTheme) || [...this.fileThemes.values()].includes(this.activeTheme);
37125
+ 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;
36882
37126
  if (isBuiltIn || isCustom) {
36883
37127
  return this.activeTheme;
36884
37128
  }
@@ -36985,11 +37229,16 @@ var ThemeManager = class {
36985
37229
  return themeType === backgroundType;
36986
37230
  }
36987
37231
  _getAllCustomThemes() {
36988
- return [
36989
- ...Array.from(this.settingsThemes.values()),
36990
- ...Array.from(this.extensionThemes.values()),
36991
- ...Array.from(this.fileThemes.values())
36992
- ];
37232
+ if (!this.userThemesLoaded) {
37233
+ this.loadUserThemes();
37234
+ }
37235
+ const mergedByName = new Map([
37236
+ ...this.fileThemes,
37237
+ ...this.extensionThemes,
37238
+ ...this.settingsThemes,
37239
+ ...this.userThemes
37240
+ ]);
37241
+ return Array.from(mergedByName.values());
36993
37242
  }
36994
37243
  /**
36995
37244
  * Gets a list of custom theme names.
@@ -37004,7 +37253,10 @@ var ThemeManager = class {
37004
37253
  * @returns True if the theme is custom.
37005
37254
  */
37006
37255
  isCustomTheme(themeName) {
37007
- return this.settingsThemes.has(themeName) || this.extensionThemes.has(themeName) || this.fileThemes.has(themeName);
37256
+ if (!this.userThemesLoaded) {
37257
+ this.loadUserThemes();
37258
+ }
37259
+ return this.userThemes.has(themeName) || this.settingsThemes.has(themeName) || this.extensionThemes.has(themeName) || this.fileThemes.has(themeName);
37008
37260
  }
37009
37261
  /**
37010
37262
  * Returns a list of available theme names.
@@ -37065,19 +37317,25 @@ var ThemeManager = class {
37065
37317
  }
37066
37318
  loadThemeFromFile(themePath) {
37067
37319
  try {
37068
- const canonicalPath = this.fs.realpathSync(path.resolve(themePath));
37069
- if (this.fileThemes.has(canonicalPath)) {
37070
- return this.fileThemes.get(canonicalPath);
37320
+ const canonicalPath = this.resolveRealPath(path.resolve(themePath));
37321
+ if (this.fileThemesByPath.has(canonicalPath)) {
37322
+ return this.fileThemesByPath.get(canonicalPath);
37323
+ }
37324
+ const rawHome = this.homedir();
37325
+ if (!rawHome) {
37326
+ return void 0;
37071
37327
  }
37072
- const homeDir = path.resolve(this.homedir());
37073
- if (!canonicalPath.startsWith(homeDir)) {
37328
+ const canonicalHome = this.resolveCanonicalDirectory(rawHome);
37329
+ if (!isSubpath(canonicalHome, canonicalPath)) {
37074
37330
  debugLogger.warn(
37075
37331
  `Theme file at "${themePath}" is outside your home directory. Only load themes from trusted sources.`
37076
37332
  );
37077
37333
  return void 0;
37078
37334
  }
37079
37335
  const themeContent = this.fs.readFileSync(canonicalPath, "utf-8");
37080
- const customThemeConfig = JSON.parse(themeContent);
37336
+ const customThemeConfig = JSON.parse(
37337
+ (0, import_strip_json_comments.default)(themeContent)
37338
+ );
37081
37339
  const validation = validateCustomTheme(customThemeConfig);
37082
37340
  if (!validation.isValid) {
37083
37341
  debugLogger.warn(
@@ -37095,7 +37353,8 @@ var ThemeManager = class {
37095
37353
  type: "custom"
37096
37354
  };
37097
37355
  const theme2 = createCustomTheme(themeWithDefaults);
37098
- this.fileThemes.set(canonicalPath, theme2);
37356
+ this.fileThemesByPath.set(canonicalPath, theme2);
37357
+ this.fileThemes.set(theme2.name, theme2);
37099
37358
  return theme2;
37100
37359
  } catch (error) {
37101
37360
  if (!(error instanceof Error && "code" in error && error.code === "ENOENT")) {
@@ -37120,6 +37379,12 @@ var ThemeManager = class {
37120
37379
  if (this.isPath(themeName)) {
37121
37380
  return this.loadThemeFromFile(themeName);
37122
37381
  }
37382
+ if (!this.userThemesLoaded) {
37383
+ this.loadUserThemes();
37384
+ }
37385
+ if (this.userThemes.has(themeName)) {
37386
+ return this.userThemes.get(themeName);
37387
+ }
37123
37388
  if (this.settingsThemes.has(themeName)) {
37124
37389
  return this.settingsThemes.get(themeName);
37125
37390
  }
@@ -38674,6 +38939,7 @@ async function getMissingSettings(extensionConfig, extensionId, workspaceDir) {
38674
38939
 
38675
38940
  // packages/cli/src/config/extension-manager.ts
38676
38941
  var import_chalk2 = __toESM(require_source(), 1);
38942
+ var import_proper_lockfile = __toESM(require_proper_lockfile(), 1);
38677
38943
  import * as fs12 from "node:fs";
38678
38944
  import * as path9 from "node:path";
38679
38945
  import { stat } from "node:fs/promises";
@@ -38721,8 +38987,8 @@ var Override = class _Override {
38721
38987
  output() {
38722
38988
  return `${this.isDisable ? "!" : ""}${this.baseRule}${this.includeSubdirs ? "*" : ""}`;
38723
38989
  }
38724
- matchesPath(path37) {
38725
- return this.asRegex().test(path37);
38990
+ matchesPath(path38) {
38991
+ return this.asRegex().test(path38);
38726
38992
  }
38727
38993
  };
38728
38994
  var ensureLeadingAndTrailingSlash = function(dirPath) {
@@ -38845,7 +39111,7 @@ var ExtensionEnablementManager = class {
38845
39111
  };
38846
39112
 
38847
39113
  // packages/cli/src/config/extension-manager.ts
38848
- import { createHash as createHash2, randomUUID } from "node:crypto";
39114
+ import { createHash as createHash2, randomUUID as randomUUID2 } from "node:crypto";
38849
39115
 
38850
39116
  // packages/cli/src/config/extension.ts
38851
39117
  import * as fs8 from "node:fs";
@@ -38942,10 +39208,12 @@ function extensionUpdatesReducer(state, action) {
38942
39208
  }
38943
39209
 
38944
39210
  // packages/cli/src/config/extensions/github.ts
39211
+ import * as crypto2 from "node:crypto";
38945
39212
  import * as os3 from "node:os";
38946
39213
  import * as https2 from "node:https";
38947
39214
  import * as fs10 from "node:fs";
38948
39215
  import * as path8 from "node:path";
39216
+ import { pipeline } from "node:stream/promises";
38949
39217
 
38950
39218
  // packages/cli/node_modules/tar/dist/esm/index.min.js
38951
39219
  import Hr from "events";
@@ -41860,6 +42128,14 @@ import * as https from "node:https";
41860
42128
  function getGitHubToken() {
41861
42129
  return process.env["GITHUB_TOKEN"] || void 0;
41862
42130
  }
42131
+ function isTrustedGitHubUrl(url) {
42132
+ try {
42133
+ const parsedUrl = new URL(url);
42134
+ return parsedUrl.protocol === "https:" && (parsedUrl.hostname === "github.com" || parsedUrl.hostname.endsWith(".github.com"));
42135
+ } catch {
42136
+ return false;
42137
+ }
42138
+ }
41863
42139
  var lookupPublicAddress = (hostname, options, callback) => safeLookup(
41864
42140
  hostname,
41865
42141
  {
@@ -41869,6 +42145,7 @@ var lookupPublicAddress = (hostname, options, callback) => safeLookup(
41869
42145
  callback
41870
42146
  );
41871
42147
  var REDIRECT_STATUS_CODES = /* @__PURE__ */ new Set([301, 302, 303, 307, 308]);
42148
+ var REQUEST_TIMEOUT_MS = 3e4;
41872
42149
  async function fetchJson(url, redirectCount = 0) {
41873
42150
  if (!await validateUrlDestination(url)) {
41874
42151
  throw new Error(`Access to blocked or private host ${url} is not allowed.`);
@@ -41877,14 +42154,8 @@ async function fetchJson(url, redirectCount = 0) {
41877
42154
  "User-Agent": "gemini-cli"
41878
42155
  };
41879
42156
  const token = getGitHubToken();
41880
- if (token) {
41881
- try {
41882
- const parsedUrl = new URL(url);
41883
- if (parsedUrl.protocol === "https:" && (parsedUrl.hostname === "github.com" || parsedUrl.hostname.endsWith(".github.com"))) {
41884
- headers.Authorization = `token ${token}`;
41885
- }
41886
- } catch {
41887
- }
42157
+ if (token && isTrustedGitHubUrl(url)) {
42158
+ headers.Authorization = `token ${token}`;
41888
42159
  }
41889
42160
  return new Promise((resolve9, reject) => {
41890
42161
  let settled = false;
@@ -41909,7 +42180,7 @@ async function fetchJson(url, redirectCount = 0) {
41909
42180
  const requestOptions = {
41910
42181
  headers,
41911
42182
  lookup: lookupPublicAddress,
41912
- timeout: 3e4
42183
+ timeout: REQUEST_TIMEOUT_MS
41913
42184
  };
41914
42185
  const req = https.get(url, requestOptions, (res) => {
41915
42186
  res.on(
@@ -42002,7 +42273,9 @@ async function fetchJson(url, redirectCount = 0) {
42002
42273
  });
42003
42274
  req.on("error", (error) => failUnlessRedirecting(() => error));
42004
42275
  req.on("timeout", () => {
42005
- failUnlessRedirecting(() => new Error("Request timed out after 30000ms"));
42276
+ failUnlessRedirecting(
42277
+ () => new Error(`Request timed out after ${REQUEST_TIMEOUT_MS}ms`)
42278
+ );
42006
42279
  req.destroy();
42007
42280
  });
42008
42281
  });
@@ -42072,7 +42345,7 @@ function tryParseGithubUrl(source2) {
42072
42345
  );
42073
42346
  }
42074
42347
  const owner = parts[0];
42075
- const repo = parts[1].replace(".git", "");
42348
+ const repo = parts[1].replace(/\.git$/i, "");
42076
42349
  return {
42077
42350
  owner,
42078
42351
  repo
@@ -42353,39 +42626,175 @@ function findReleaseAsset(assets) {
42353
42626
  return void 0;
42354
42627
  }
42355
42628
  async function downloadFile(url, dest, options, redirectCount = 0) {
42629
+ let parsedUrl;
42630
+ try {
42631
+ parsedUrl = new URL(url);
42632
+ } catch (error) {
42633
+ throw new Error(`Invalid download URL ${url}: ${getErrorMessage(error)}`, {
42634
+ cause: error
42635
+ });
42636
+ }
42637
+ if (parsedUrl.protocol !== "https:") {
42638
+ throw new Error(
42639
+ `Refusing to download from insecure protocol ${parsedUrl.protocol} for URL ${url}. Only HTTPS is supported.`
42640
+ );
42641
+ }
42642
+ const requestUrl = parsedUrl.toString();
42643
+ if (!await validateUrlDestination(requestUrl)) {
42644
+ throw new Error(
42645
+ `Access to blocked or private host ${requestUrl} is not allowed.`
42646
+ );
42647
+ }
42356
42648
  const headers = {
42357
42649
  "User-agent": "gemini-cli",
42358
42650
  Accept: "application/octet-stream",
42359
42651
  ...options?.headers
42360
42652
  };
42653
+ const trustedGitHubUrl = isTrustedGitHubUrl(requestUrl);
42654
+ if (!trustedGitHubUrl) {
42655
+ for (const key of Object.keys(headers)) {
42656
+ if (key.toLowerCase() === "authorization") {
42657
+ delete headers[key];
42658
+ }
42659
+ }
42660
+ }
42361
42661
  const token = getGitHubToken();
42362
- if (token) {
42662
+ if (token && trustedGitHubUrl) {
42363
42663
  headers["Authorization"] = `token ${token}`;
42364
42664
  }
42365
- return new Promise((resolve9, reject) => {
42366
- https2.get(url, { headers }, (res) => {
42367
- if (res.statusCode === 302 || res.statusCode === 301) {
42368
- if (redirectCount >= 10) {
42369
- return reject(new Error("Too many redirects"));
42665
+ let tempDest;
42666
+ let downloadPipeline;
42667
+ try {
42668
+ await new Promise((resolve9, reject) => {
42669
+ let settled = false;
42670
+ let isRedirecting = false;
42671
+ let responseStream;
42672
+ const settleResolve = () => {
42673
+ if (!settled) {
42674
+ settled = true;
42675
+ resolve9();
42370
42676
  }
42371
- if (!res.headers.location) {
42372
- return reject(
42373
- new Error("Redirect response missing Location header")
42677
+ };
42678
+ const settleReject = (error) => {
42679
+ if (!settled) {
42680
+ settled = true;
42681
+ reject(
42682
+ error instanceof Error ? error : new Error(getErrorMessage(error))
42374
42683
  );
42375
42684
  }
42376
- downloadFile(res.headers.location, dest, options, redirectCount + 1).then(resolve9).catch(reject);
42377
- return;
42685
+ };
42686
+ const requestOptions = {
42687
+ headers,
42688
+ lookup: lookupPublicAddress,
42689
+ timeout: REQUEST_TIMEOUT_MS
42690
+ };
42691
+ const req = https2.get(requestUrl, requestOptions, (res) => {
42692
+ res.on("error", (error) => {
42693
+ if (!isRedirecting) {
42694
+ settleReject(error);
42695
+ }
42696
+ });
42697
+ if (res.statusCode && REDIRECT_STATUS_CODES.has(res.statusCode)) {
42698
+ if (redirectCount >= 10) {
42699
+ res.resume?.();
42700
+ settleReject(new Error("Too many redirects"));
42701
+ return;
42702
+ }
42703
+ if (!res.headers.location) {
42704
+ res.resume?.();
42705
+ settleReject(
42706
+ new Error("Redirect response missing Location header")
42707
+ );
42708
+ return;
42709
+ }
42710
+ let redirectUrl;
42711
+ try {
42712
+ redirectUrl = new URL(res.headers.location, requestUrl).toString();
42713
+ } catch (error) {
42714
+ res.resume?.();
42715
+ settleReject(
42716
+ new Error(
42717
+ `Invalid redirect URL from ${requestUrl} (status ${res.statusCode}): ${getErrorMessage(error)}`,
42718
+ { cause: error }
42719
+ )
42720
+ );
42721
+ return;
42722
+ }
42723
+ isRedirecting = true;
42724
+ res.resume?.();
42725
+ void downloadFile(redirectUrl, dest, options, redirectCount + 1).then(
42726
+ settleResolve,
42727
+ settleReject
42728
+ );
42729
+ return;
42730
+ }
42731
+ if (res.statusCode !== 200) {
42732
+ res.resume?.();
42733
+ settleReject(
42734
+ new Error(`Request failed with status code ${res.statusCode}`)
42735
+ );
42736
+ return;
42737
+ }
42738
+ responseStream = res;
42739
+ const currentTempDest = `${dest}.${crypto2.randomUUID()}.tmp`;
42740
+ tempDest = currentTempDest;
42741
+ let file;
42742
+ try {
42743
+ file = fs10.createWriteStream(currentTempDest);
42744
+ } catch (error) {
42745
+ res.destroy?.();
42746
+ settleReject(error);
42747
+ return;
42748
+ }
42749
+ file.on("error", settleReject);
42750
+ downloadPipeline = pipeline(res, file);
42751
+ void downloadPipeline.then(() => {
42752
+ if (res.complete === false) {
42753
+ settleReject(
42754
+ new Error(
42755
+ `Response ended prematurely while downloading ${requestUrl}`
42756
+ )
42757
+ );
42758
+ return;
42759
+ }
42760
+ settleResolve();
42761
+ }, settleReject);
42762
+ });
42763
+ req.on("error", (error) => {
42764
+ if (isRedirecting) {
42765
+ return;
42766
+ }
42767
+ settleReject(error);
42768
+ responseStream?.destroy?.();
42769
+ });
42770
+ req.on("timeout", () => {
42771
+ if (!isRedirecting) {
42772
+ settleReject(
42773
+ new Error(`Request timed out after ${REQUEST_TIMEOUT_MS}ms`)
42774
+ );
42775
+ responseStream?.destroy?.();
42776
+ }
42777
+ req.destroy?.();
42778
+ });
42779
+ });
42780
+ if (tempDest) {
42781
+ await fs10.promises.rename(tempDest, dest);
42782
+ }
42783
+ } catch (error) {
42784
+ if (downloadPipeline) {
42785
+ try {
42786
+ await downloadPipeline;
42787
+ } catch {
42378
42788
  }
42379
- if (res.statusCode !== 200) {
42380
- return reject(
42381
- new Error(`Request failed with status code ${res.statusCode}`)
42382
- );
42789
+ }
42790
+ if (tempDest) {
42791
+ try {
42792
+ await fs10.promises.unlink(tempDest);
42793
+ } catch {
42383
42794
  }
42384
- const file = fs10.createWriteStream(dest);
42385
- res.pipe(file);
42386
- file.on("finish", () => file.close(resolve9));
42387
- }).on("error", reject);
42388
- });
42795
+ }
42796
+ throw error;
42797
+ }
42389
42798
  }
42390
42799
  async function extractFile(file, dest) {
42391
42800
  if (file.endsWith(".tar.gz")) {
@@ -42596,7 +43005,7 @@ async function retryWithBackoff(fn2, options = {}) {
42596
43005
  }
42597
43006
  throw new Error("Unreachable");
42598
43007
  }
42599
- async function removeDirectoryWithRetry(path37, options = {}) {
43008
+ async function removeDirectoryWithRetry(path38, options = {}) {
42600
43009
  const { recursive = true, force = true, ...retryOptions } = options;
42601
43010
  const isRetryableError = (error) => {
42602
43011
  if (isNodeError(error)) {
@@ -42604,7 +43013,7 @@ async function removeDirectoryWithRetry(path37, options = {}) {
42604
43013
  }
42605
43014
  return false;
42606
43015
  };
42607
- await retryWithBackoff(() => fs11.promises.rm(path37, { recursive, force }), {
43016
+ await retryWithBackoff(() => fs11.promises.rm(path38, { recursive, force }), {
42608
43017
  maxRetries: 5,
42609
43018
  initialDelay: 100,
42610
43019
  shouldRetry: isRetryableError,
@@ -42613,6 +43022,9 @@ async function removeDirectoryWithRetry(path37, options = {}) {
42613
43022
  }
42614
43023
 
42615
43024
  // packages/cli/src/config/extension-manager.ts
43025
+ var INSTALL_LOCK_SUFFIX = ".lock";
43026
+ var INSTALL_LOCK_STALE_MS = 15e3;
43027
+ var INSTALL_LOCK_RETRIES = { retries: 15, minTimeout: 200, maxTimeout: 500 };
42616
43028
  var ExtensionManager = class extends ExtensionLoader {
42617
43029
  extensionEnablementManager;
42618
43030
  integrityManager;
@@ -42633,7 +43045,7 @@ var ExtensionManager = class extends ExtensionLoader {
42633
43045
  this.telemetryConfig = new Config({
42634
43046
  telemetry: options.settings.telemetry,
42635
43047
  interactive: false,
42636
- sessionId: randomUUID(),
43048
+ sessionId: randomUUID2(),
42637
43049
  clientVersion: options.clientVersion ?? "unknown",
42638
43050
  targetDir: options.workspaceDir,
42639
43051
  cwd: options.workspaceDir,
@@ -42757,6 +43169,7 @@ Would you like to attempt to install via "git clone" instead?`
42757
43169
  } else {
42758
43170
  throw new Error(`Unsupported install type: ${installMetadata.type}`);
42759
43171
  }
43172
+ let releaseLock;
42760
43173
  try {
42761
43174
  newExtensionConfig = await this.loadExtensionConfig(localSourcePath);
42762
43175
  const newExtensionName = newExtensionConfig.name;
@@ -42805,11 +43218,19 @@ Would you like to attempt to install via "git clone" instead?`
42805
43218
  const destinationPath = new ExtensionStorage(
42806
43219
  newExtensionName
42807
43220
  ).getExtensionDir();
42808
- if ((!isUpdate || newExtensionName !== previousName) && fs12.existsSync(destinationPath)) {
42809
- throw new Error(
42810
- `Cannot install extension "${newExtensionName}" because a directory with that name already exists. Please remove it manually.`
42811
- );
42812
- }
43221
+ const assertDestinationIsAvailable = () => {
43222
+ if ((!isUpdate || newExtensionName !== previousName) && fs12.existsSync(destinationPath)) {
43223
+ throw new Error(
43224
+ `Cannot install extension "${newExtensionName}" because a directory with that name already exists. Please remove it manually.`
43225
+ );
43226
+ }
43227
+ };
43228
+ assertDestinationIsAvailable();
43229
+ releaseLock = await acquireExtensionInstallLock(
43230
+ destinationPath,
43231
+ newExtensionName
43232
+ );
43233
+ assertDestinationIsAvailable();
42813
43234
  let previousSettings;
42814
43235
  let wasEnabledGlobally = false;
42815
43236
  let wasEnabledWorkspace = false;
@@ -42922,6 +43343,15 @@ Would you like to attempt to install via "git clone" instead?`
42922
43343
  );
42923
43344
  }
42924
43345
  } finally {
43346
+ if (releaseLock) {
43347
+ try {
43348
+ await releaseLock();
43349
+ } catch (releaseError) {
43350
+ debugLogger.warn(
43351
+ `Failed to release the install lock for extension "${newExtensionConfig?.name}": ${getErrorMessage(releaseError)}`
43352
+ );
43353
+ }
43354
+ }
42925
43355
  if (tempDir) {
42926
43356
  try {
42927
43357
  await removeDirectoryWithRetry(tempDir);
@@ -43092,6 +43522,9 @@ Would you like to attempt to install via "git clone" instead?`
43092
43522
  * Builds an extension without side effects (does not mutate loadedExtensions or start it).
43093
43523
  */
43094
43524
  async _buildExtension(extensionDir) {
43525
+ if (path9.basename(extensionDir).endsWith(INSTALL_LOCK_SUFFIX)) {
43526
+ return null;
43527
+ }
43095
43528
  try {
43096
43529
  const stats = await fs12.promises.stat(extensionDir);
43097
43530
  if (!stats.isDirectory()) {
@@ -43577,6 +44010,32 @@ async function copyExtension(source2, destination) {
43577
44010
  await fs12.promises.cp(source2, destination, { recursive: true });
43578
44011
  await makeWritableRecursive(destination);
43579
44012
  }
44013
+ async function acquireExtensionInstallLock(destinationPath, extensionName) {
44014
+ await fs12.promises.mkdir(path9.dirname(destinationPath), { recursive: true });
44015
+ try {
44016
+ return await (0, import_proper_lockfile.lock)(destinationPath, {
44017
+ // `destinationPath` usually does not exist yet. With `realpath: false`,
44018
+ // proper-lockfile neither resolves nor stats it; it only creates and
44019
+ // checks the `<destinationPath>.lock` directory.
44020
+ realpath: false,
44021
+ stale: INSTALL_LOCK_STALE_MS,
44022
+ retries: INSTALL_LOCK_RETRIES,
44023
+ // The default handler throws from a timer, which would crash the CLI.
44024
+ onCompromised: (error) => {
44025
+ debugLogger.warn(
44026
+ `Lost the install lock for extension "${extensionName}": ${getErrorMessage(error)}`
44027
+ );
44028
+ }
44029
+ });
44030
+ } catch (error) {
44031
+ if (isNodeError(error) && error.code === "ELOCKED") {
44032
+ throw new Error(
44033
+ `Cannot install extension "${extensionName}" because another installation or update of it is already in progress. Please try again later.`
44034
+ );
44035
+ }
44036
+ throw error;
44037
+ }
44038
+ }
43580
44039
  function getContextFileNames(config) {
43581
44040
  if (!config.contextFileName) {
43582
44041
  return ["GEMINI.md"];
@@ -44003,9 +44462,9 @@ function isSettingsValue(value) {
44003
44462
  const type = typeof value;
44004
44463
  return type === "string" || type === "number" || type === "boolean" || type === "object";
44005
44464
  }
44006
- function getNestedValue(obj, path37) {
44465
+ function getNestedValue(obj, path38) {
44007
44466
  let current = obj;
44008
- for (const key of path37) {
44467
+ for (const key of path38) {
44009
44468
  if (!isRecord2(current) || !(key in current)) {
44010
44469
  return void 0;
44011
44470
  }
@@ -44018,8 +44477,8 @@ function getEffectiveValue(key, settings) {
44018
44477
  if (!definition) {
44019
44478
  return void 0;
44020
44479
  }
44021
- const path37 = key.split(".");
44022
- const value = getNestedValue(settings, path37);
44480
+ const path38 = key.split(".");
44481
+ const value = getNestedValue(settings, path38);
44023
44482
  if (value !== void 0 && isSettingsValue(value)) {
44024
44483
  return value;
44025
44484
  }
@@ -44029,8 +44488,8 @@ function getDialogSettingKeys() {
44029
44488
  return Object.values(getFlattenedSchema()).filter((definition) => definition.showInDialog !== false).map((definition) => definition.key);
44030
44489
  }
44031
44490
  function isInSettingsScope(key, scopeSettings) {
44032
- const path37 = key.split(".");
44033
- const value = getNestedValue(scopeSettings, path37);
44491
+ const path38 = key.split(".");
44492
+ const value = getNestedValue(scopeSettings, path38);
44034
44493
  return value !== void 0;
44035
44494
  }
44036
44495
  function getDisplayValue(key, scopeSettings, _mergedSettings) {
@@ -44484,7 +44943,7 @@ async function readLocalFiles(resolvedFiles, config, signal, userMessageTimestam
44484
44943
  const match = fileContentRegex.exec(part);
44485
44944
  if (match) {
44486
44945
  const filePathSpecInContent = match[1];
44487
- const fileActualContent = match[2].trim();
44946
+ const fileActualContent = match[2];
44488
44947
  const resolvedFile = filesToRead.find(
44489
44948
  (rf) => rf.absolutePath === filePathSpecInContent || rf.pathSpec === filePathSpecInContent
44490
44949
  );
@@ -44503,7 +44962,9 @@ async function readLocalFiles(resolvedFiles, config, signal, userMessageTimestam
44503
44962
  Content from @${displayPath}:
44504
44963
  `
44505
44964
  });
44506
- parts.push({ text: fileActualContent });
44965
+ if (fileActualContent !== "") {
44966
+ parts.push({ text: fileActualContent });
44967
+ }
44507
44968
  } else {
44508
44969
  parts.push({ text: part });
44509
44970
  }
@@ -44681,8 +45142,8 @@ var import_execa = __toESM(require_execa(), 1);
44681
45142
 
44682
45143
  // node_modules/crypto-random-string/index.js
44683
45144
  import { promisify } from "util";
44684
- import crypto2 from "crypto";
44685
- var randomBytesAsync = promisify(crypto2.randomBytes);
45145
+ import crypto3 from "crypto";
45146
+ var randomBytesAsync = promisify(crypto3.randomBytes);
44686
45147
  var urlSafeCharacters = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-._~".split("");
44687
45148
  var numericCharacters = "0123456789".split("");
44688
45149
  var distinguishableCharacters = "CDEHKMPRTUWXY012458".split("");
@@ -44695,7 +45156,7 @@ var generateForCustomCharacters = (length, characters) => {
44695
45156
  let string = "";
44696
45157
  let stringLength = 0;
44697
45158
  while (stringLength < length) {
44698
- const entropy = crypto2.randomBytes(entropyLength);
45159
+ const entropy = crypto3.randomBytes(entropyLength);
44699
45160
  let entropyPosition = 0;
44700
45161
  while (entropyPosition < entropyLength && stringLength < length) {
44701
45162
  const entropyValue = entropy.readUInt16LE(entropyPosition);
@@ -44730,7 +45191,7 @@ var generateForCustomCharactersAsync = async (length, characters) => {
44730
45191
  }
44731
45192
  return string;
44732
45193
  };
44733
- var generateRandomBytes = (byteLength, type, length) => crypto2.randomBytes(byteLength).toString(type).slice(0, length);
45194
+ var generateRandomBytes = (byteLength, type, length) => crypto3.randomBytes(byteLength).toString(type).slice(0, length);
44734
45195
  var generateRandomBytesAsync = async (byteLength, type, length) => {
44735
45196
  const buffer = await randomBytesAsync(byteLength);
44736
45197
  return buffer.toString(type).slice(0, length);
@@ -45106,7 +45567,7 @@ async function writeClipboardImages(filePaths) {
45106
45567
  if (process5.platform !== "darwin") {
45107
45568
  return;
45108
45569
  }
45109
- const paths = filePaths.map((path37) => path37 instanceof URL ? fileURLToPath(path37) : path37);
45570
+ const paths = filePaths.map((path38) => path38 instanceof URL ? fileURLToPath(path38) : path38);
45110
45571
  await runJxa((...paths2) => {
45111
45572
  ObjC.import("AppKit");
45112
45573
  ObjC.import("Foundation");
@@ -51047,7 +51508,7 @@ var persistentState = new PersistentState();
51047
51508
  // packages/cli/src/ui/utils/terminalSetup.ts
51048
51509
  var VSCODE_SHIFT_ENTER_SEQUENCE = "\\\r\n";
51049
51510
  var execAsync = promisify4(exec);
51050
- function stripJsonComments(content) {
51511
+ function stripJsonComments2(content) {
51051
51512
  return content.replace(/^\s*\/\/.*$/gm, "");
51052
51513
  }
51053
51514
  var TERMINAL_DATA = {
@@ -51151,7 +51612,7 @@ async function configureVSCodeStyle(terminalName, appName) {
51151
51612
  const content = await fs21.readFile(keybindingsFile, "utf8");
51152
51613
  await backupFile(keybindingsFile);
51153
51614
  try {
51154
- const cleanContent = stripJsonComments(content);
51615
+ const cleanContent = stripJsonComments2(content);
51155
51616
  const parsedContent = JSON.parse(cleanContent);
51156
51617
  if (!Array.isArray(parsedContent)) {
51157
51618
  return {
@@ -51283,7 +51744,7 @@ async function shouldPromptForTerminalSetup() {
51283
51744
  const keybindingsFile = path18.join(configDir, "keybindings.json");
51284
51745
  try {
51285
51746
  const content = await fs21.readFile(keybindingsFile, "utf8");
51286
- const cleanContent = stripJsonComments(content);
51747
+ const cleanContent = stripJsonComments2(content);
51287
51748
  const parsedContent = JSON.parse(cleanContent);
51288
51749
  if (!Array.isArray(parsedContent)) {
51289
51750
  return true;
@@ -51927,7 +52388,12 @@ var ShellProcessor = class {
51927
52388
  const userArgsRaw = context.invocation?.args || "";
51928
52389
  if (!prompt.includes(SHELL_INJECTION_TRIGGER)) {
51929
52390
  return [
51930
- { text: prompt.replaceAll(SHORTHAND_ARGS_PLACEHOLDER, userArgsRaw) }
52391
+ {
52392
+ text: prompt.replaceAll(
52393
+ SHORTHAND_ARGS_PLACEHOLDER,
52394
+ () => userArgsRaw
52395
+ )
52396
+ }
51931
52397
  ];
51932
52398
  }
51933
52399
  const config = context.services.agentContext?.config;
@@ -51943,7 +52409,12 @@ var ShellProcessor = class {
51943
52409
  );
51944
52410
  if (injections.length === 0) {
51945
52411
  return [
51946
- { text: prompt.replaceAll(SHORTHAND_ARGS_PLACEHOLDER, userArgsRaw) }
52412
+ {
52413
+ text: prompt.replaceAll(
52414
+ SHORTHAND_ARGS_PLACEHOLDER,
52415
+ () => userArgsRaw
52416
+ )
52417
+ }
51947
52418
  ];
51948
52419
  }
51949
52420
  const { shell: shell2 } = getShellConfiguration();
@@ -51956,7 +52427,7 @@ var ShellProcessor = class {
51956
52427
  }
51957
52428
  const resolvedCommand = command.replaceAll(
51958
52429
  SHORTHAND_ARGS_PLACEHOLDER,
51959
- userArgsEscaped
52430
+ () => userArgsEscaped
51960
52431
  );
51961
52432
  return { ...injection, resolvedCommand };
51962
52433
  }
@@ -51995,7 +52466,7 @@ var ShellProcessor = class {
51995
52466
  const segment = prompt.substring(lastIndex, injection.startIndex);
51996
52467
  processedPrompt += segment.replaceAll(
51997
52468
  SHORTHAND_ARGS_PLACEHOLDER,
51998
- userArgsRaw
52469
+ () => userArgsRaw
51999
52470
  );
52000
52471
  if (injection.resolvedCommand) {
52001
52472
  const activeTheme = themeManager.getActiveTheme();
@@ -52036,7 +52507,7 @@ var ShellProcessor = class {
52036
52507
  const finalSegment = prompt.substring(lastIndex);
52037
52508
  processedPrompt += finalSegment.replaceAll(
52038
52509
  SHORTHAND_ARGS_PLACEHOLDER,
52039
- userArgsRaw
52510
+ () => userArgsRaw
52040
52511
  );
52041
52512
  return [{ text: processedPrompt }];
52042
52513
  }
@@ -53267,6 +53738,7 @@ var _ExpandableText = ({
53267
53738
  maxWidth = MAX_WIDTH,
53268
53739
  maxLines
53269
53740
  }) => {
53741
+ const labelCharacters = Array.from(label);
53270
53742
  const hasMatch = matchedIndex !== void 0 && matchedIndex >= 0 && matchedIndex < label.length && userInput.length > 0;
53271
53743
  if (!hasMatch) {
53272
53744
  let display = label;
@@ -53275,53 +53747,69 @@ var _ExpandableText = ({
53275
53747
  const lines = label.split("\n");
53276
53748
  let truncated = lines.slice(0, maxLines).join("\n");
53277
53749
  const hasMoreLines = lines.length > maxLines;
53278
- if (truncated.length > maxWidth) {
53279
- truncated = truncated.slice(0, maxWidth) + "...";
53750
+ const truncatedCharacters = Array.from(truncated);
53751
+ if (truncatedCharacters.length > maxWidth) {
53752
+ truncated = truncatedCharacters.slice(0, maxWidth).join("") + "...";
53280
53753
  } else if (hasMoreLines) {
53281
53754
  truncated += "...";
53282
53755
  }
53283
53756
  display = truncated;
53284
- } else if (label.length > maxWidth) {
53285
- display = label.slice(0, maxWidth) + "...";
53757
+ } else if (labelCharacters.length > maxWidth) {
53758
+ display = labelCharacters.slice(0, maxWidth).join("") + "...";
53286
53759
  }
53287
53760
  }
53288
53761
  return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(Text, { wrap: "wrap", color: textColor, children: display });
53289
53762
  }
53290
- const matchLength = userInput.length;
53763
+ const matchCharactersLength = Array.from(userInput).length;
53764
+ let matchedCharacterIndex = 0;
53765
+ let matchedUtf16Index = 0;
53766
+ while (matchedCharacterIndex < labelCharacters.length && matchedUtf16Index < matchedIndex) {
53767
+ matchedUtf16Index += labelCharacters[matchedCharacterIndex].length;
53768
+ matchedCharacterIndex += 1;
53769
+ }
53291
53770
  let before = "";
53292
53771
  let match = "";
53293
53772
  let after = "";
53294
- if (isExpanded || label.length <= maxWidth) {
53295
- before = label.slice(0, matchedIndex);
53296
- match = label.slice(matchedIndex, matchedIndex + matchLength);
53297
- after = label.slice(matchedIndex + matchLength);
53298
- } else if (matchLength >= maxWidth) {
53299
- match = label.slice(matchedIndex, matchedIndex + maxWidth - 1) + "...";
53773
+ if (isExpanded || labelCharacters.length <= maxWidth) {
53774
+ before = labelCharacters.slice(0, matchedCharacterIndex).join("");
53775
+ match = labelCharacters.slice(
53776
+ matchedCharacterIndex,
53777
+ matchedCharacterIndex + matchCharactersLength
53778
+ ).join("");
53779
+ after = labelCharacters.slice(matchedCharacterIndex + matchCharactersLength).join("");
53780
+ } else if (matchCharactersLength >= maxWidth) {
53781
+ match = labelCharacters.slice(matchedCharacterIndex, matchedCharacterIndex + maxWidth - 1).join("") + "...";
53300
53782
  } else {
53301
- const contextSpace = maxWidth - matchLength;
53783
+ const contextSpace = maxWidth - matchCharactersLength;
53302
53784
  const beforeSpace = Math.floor(contextSpace / 2);
53303
53785
  const afterSpace = Math.ceil(contextSpace / 2);
53304
- let start = matchedIndex - beforeSpace;
53305
- let end = matchedIndex + matchLength + afterSpace;
53786
+ let start = matchedCharacterIndex - beforeSpace;
53787
+ let end = matchedCharacterIndex + matchCharactersLength + afterSpace;
53306
53788
  if (start < 0) {
53307
53789
  end += -start;
53308
53790
  start = 0;
53309
53791
  }
53310
- if (end > label.length) {
53311
- start -= end - label.length;
53312
- end = label.length;
53792
+ if (end > labelCharacters.length) {
53793
+ start -= end - labelCharacters.length;
53794
+ end = labelCharacters.length;
53313
53795
  }
53314
53796
  start = Math.max(0, start);
53315
- const finalMatchIndex = matchedIndex - start;
53316
- const slicedLabel = label.slice(start, end);
53317
- before = slicedLabel.slice(0, finalMatchIndex);
53318
- match = slicedLabel.slice(finalMatchIndex, finalMatchIndex + matchLength);
53319
- after = slicedLabel.slice(finalMatchIndex + matchLength);
53797
+ const finalMatchIndex = matchedCharacterIndex - start;
53798
+ const slicedLabel = labelCharacters.slice(start, end);
53799
+ const beforeChars = slicedLabel.slice(0, finalMatchIndex);
53800
+ match = slicedLabel.slice(finalMatchIndex, finalMatchIndex + matchCharactersLength).join("");
53801
+ const afterChars = slicedLabel.slice(
53802
+ finalMatchIndex + matchCharactersLength
53803
+ );
53320
53804
  if (start > 0) {
53321
- before = before.length >= 3 ? "..." + before.slice(3) : "...";
53805
+ before = beforeChars.length >= 3 ? "..." + beforeChars.slice(3).join("") : "...";
53806
+ } else {
53807
+ before = beforeChars.join("");
53322
53808
  }
53323
- if (end < label.length) {
53324
- after = after.length >= 3 ? after.slice(0, -3) + "..." : "...";
53809
+ if (end < labelCharacters.length) {
53810
+ after = afterChars.length >= 3 ? afterChars.slice(0, -3).join("") + "..." : "...";
53811
+ } else {
53812
+ after = afterChars.join("");
53325
53813
  }
53326
53814
  }
53327
53815
  return /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(Text, { color: textColor, wrap: "wrap", children: [
@@ -54537,10 +55025,10 @@ function enableFeature(settings, featureName, strategy) {
54537
55025
  };
54538
55026
  }
54539
55027
  const modifiedScopes = [];
54540
- for (const { scope, path: path37 } of foundInDisabledScopes) {
55028
+ for (const { scope, path: path38 } of foundInDisabledScopes) {
54541
55029
  if (isLoadableSettingScope(scope)) {
54542
55030
  strategy.enable(settings, scope, featureName);
54543
- modifiedScopes.push({ scope, path: path37 });
55031
+ modifiedScopes.push({ scope, path: path38 });
54544
55032
  }
54545
55033
  }
54546
55034
  return {
@@ -55031,7 +55519,7 @@ var authCommand = {
55031
55519
  import process12 from "node:process";
55032
55520
 
55033
55521
  // packages/cli/src/generated/git-commit.ts
55034
- var GIT_COMMIT_INFO = "dc6602cec";
55522
+ var GIT_COMMIT_INFO = "d8f2b28de";
55035
55523
 
55036
55524
  // packages/cli/src/ui/utils/historyExportUtils.ts
55037
55525
  import * as fsPromises from "node:fs/promises";
@@ -55081,13 +55569,13 @@ async function exportHistoryToFile(options) {
55081
55569
  // packages/cli/src/ui/utils/memorySnapshot.ts
55082
55570
  import { createWriteStream as createWriteStream3 } from "node:fs";
55083
55571
  import { mkdir as mkdir3 } from "node:fs/promises";
55084
- import { dirname as dirname4 } from "node:path";
55085
- import { pipeline } from "node:stream/promises";
55572
+ import { dirname as dirname5 } from "node:path";
55573
+ import { pipeline as pipeline2 } from "node:stream/promises";
55086
55574
  import { getHeapSnapshot } from "node:v8";
55087
55575
  var MEMORY_SNAPSHOT_AUTO_THRESHOLD_BYTES = 2 * 1024 * 1024 * 1024;
55088
55576
  async function captureHeapSnapshot(filePath) {
55089
- await mkdir3(dirname4(filePath), { recursive: true });
55090
- await pipeline(getHeapSnapshot(), createWriteStream3(filePath));
55577
+ await mkdir3(dirname5(filePath), { recursive: true });
55578
+ await pipeline2(getHeapSnapshot(), createWriteStream3(filePath));
55091
55579
  }
55092
55580
 
55093
55581
  // packages/cli/src/ui/commands/bugCommand.ts
@@ -55665,7 +56153,7 @@ var chatCommand = {
55665
56153
  };
55666
56154
 
55667
56155
  // packages/cli/src/ui/commands/clearCommand.ts
55668
- import { randomUUID as randomUUID2 } from "node:crypto";
56156
+ import { randomUUID as randomUUID3 } from "node:crypto";
55669
56157
  var clearCommand = {
55670
56158
  name: "clear",
55671
56159
  altNames: ["new"],
@@ -55682,7 +56170,7 @@ var clearCommand = {
55682
56170
  config?.injectionService.clear();
55683
56171
  let newSessionId;
55684
56172
  if (config) {
55685
- newSessionId = randomUUID2();
56173
+ newSessionId = randomUUID3();
55686
56174
  config.resetNewSessionState(newSessionId);
55687
56175
  }
55688
56176
  if (geminiClient) {
@@ -59782,7 +60270,7 @@ var RewindViewer = ({
59782
60270
  var import_jsx_runtime32 = __toESM(require_jsx_runtime(), 1);
59783
60271
  async function rewindConversation(context, client, recordingService, messageId, newText) {
59784
60272
  try {
59785
- const conversation = recordingService.rewindTo(messageId);
60273
+ const conversation = await (recordingService.rewindToAsync ? recordingService.rewindToAsync(messageId) : recordingService.rewindTo(messageId));
59786
60274
  if (!conversation) {
59787
60275
  const errorMsg = "Could not fetch conversation file";
59788
60276
  debugLogger.error(errorMsg);
@@ -59790,10 +60278,20 @@ async function rewindConversation(context, client, recordingService, messageId,
59790
60278
  coreEvents.emitFeedback("error", errorMsg);
59791
60279
  return;
59792
60280
  }
59793
- const { uiHistory } = convertSessionToHistoryFormats(conversation.messages);
59794
- const clientHistory = convertSessionToClientHistory(conversation.messages);
60281
+ const messages = conversation.messages ?? [];
60282
+ const { uiHistory } = convertSessionToHistoryFormats(messages);
60283
+ const clientHistory = convertSessionToClientHistory(messages);
59795
60284
  client.setHistory(clientHistory);
59796
- await context.services.agentContext?.config.getMemoryContextManager()?.refresh();
60285
+ client.clearCurrentSequenceModel?.();
60286
+ const config = context.services.agentContext?.config;
60287
+ if (config) {
60288
+ config.getModelAvailabilityService?.()?.reset();
60289
+ const configuredModel = config.getModel?.();
60290
+ if (configuredModel) {
60291
+ config.setActiveModel?.(configuredModel);
60292
+ }
60293
+ await config.getMemoryContextManager()?.refresh();
60294
+ }
59797
60295
  const startId = 1;
59798
60296
  const historyWithIds = uiHistory.map(
59799
60297
  (item, idx) => ({
@@ -59838,75 +60336,80 @@ var rewindCommand = {
59838
60336
  messageType: "error",
59839
60337
  content: "Recording service unavailable"
59840
60338
  };
59841
- const conversation = recordingService.getConversation();
59842
- if (!conversation)
59843
- return {
59844
- type: "message",
59845
- messageType: "info",
59846
- content: "No conversation found."
59847
- };
59848
- const hasUserInteractions = conversation.messages.some(
59849
- (msg) => msg.type === "user"
59850
- );
59851
- if (!hasUserInteractions) {
60339
+ const buildRewindActionReturn = (conversation) => {
60340
+ if (!conversation)
60341
+ return {
60342
+ type: "message",
60343
+ messageType: "info",
60344
+ content: "No conversation found."
60345
+ };
60346
+ const hasUserInteractions = (conversation.messages ?? []).some(
60347
+ (msg) => msg.type === "user"
60348
+ );
60349
+ if (!hasUserInteractions) {
60350
+ return {
60351
+ type: "message",
60352
+ messageType: "info",
60353
+ content: "Nothing to rewind to."
60354
+ };
60355
+ }
59852
60356
  return {
59853
- type: "message",
59854
- messageType: "info",
59855
- content: "Nothing to rewind to."
59856
- };
59857
- }
59858
- return {
59859
- type: "custom_dialog",
59860
- component: /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
59861
- RewindViewer,
59862
- {
59863
- conversation,
59864
- onExit: () => {
59865
- context.ui.removeComponent();
59866
- },
59867
- onRewind: async (messageId, newText, outcome) => {
59868
- if (outcome !== "cancel" /* Cancel */) {
59869
- logRewind(config, new RewindEvent(outcome));
59870
- }
59871
- switch (outcome) {
59872
- case "cancel" /* Cancel */:
59873
- context.ui.removeComponent();
59874
- return;
59875
- case "revert_only" /* RevertOnly */:
59876
- if (conversation) {
59877
- await revertFileChanges(conversation, messageId);
59878
- }
59879
- context.ui.removeComponent();
59880
- coreEvents.emitFeedback("info", "File changes reverted.");
59881
- return;
59882
- case "rewind_and_revert" /* RewindAndRevert */:
59883
- if (conversation) {
59884
- await revertFileChanges(conversation, messageId);
59885
- }
59886
- await rewindConversation(
59887
- context,
59888
- client,
59889
- recordingService,
59890
- messageId,
59891
- newText
59892
- );
59893
- return;
59894
- case "rewind_only" /* RewindOnly */:
59895
- await rewindConversation(
59896
- context,
59897
- client,
59898
- recordingService,
59899
- messageId,
59900
- newText
59901
- );
59902
- return;
59903
- default:
59904
- checkExhaustive(outcome);
60357
+ type: "custom_dialog",
60358
+ component: /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
60359
+ RewindViewer,
60360
+ {
60361
+ conversation,
60362
+ onExit: () => {
60363
+ context.ui.removeComponent();
60364
+ },
60365
+ onRewind: async (messageId, newText, outcome) => {
60366
+ if (outcome !== "cancel" /* Cancel */) {
60367
+ logRewind(config, new RewindEvent(outcome));
60368
+ }
60369
+ switch (outcome) {
60370
+ case "cancel" /* Cancel */:
60371
+ context.ui.removeComponent();
60372
+ return;
60373
+ case "revert_only" /* RevertOnly */:
60374
+ if (conversation) {
60375
+ await revertFileChanges(conversation, messageId);
60376
+ }
60377
+ context.ui.removeComponent();
60378
+ coreEvents.emitFeedback("info", "File changes reverted.");
60379
+ return;
60380
+ case "rewind_and_revert" /* RewindAndRevert */:
60381
+ if (conversation) {
60382
+ await revertFileChanges(conversation, messageId);
60383
+ }
60384
+ await rewindConversation(
60385
+ context,
60386
+ client,
60387
+ recordingService,
60388
+ messageId,
60389
+ newText
60390
+ );
60391
+ return;
60392
+ case "rewind_only" /* RewindOnly */:
60393
+ await rewindConversation(
60394
+ context,
60395
+ client,
60396
+ recordingService,
60397
+ messageId,
60398
+ newText
60399
+ );
60400
+ return;
60401
+ default:
60402
+ checkExhaustive(outcome);
60403
+ }
59905
60404
  }
59906
60405
  }
59907
- }
59908
- )
60406
+ )
60407
+ };
59909
60408
  };
60409
+ if (recordingService.getConversationAsync) {
60410
+ return recordingService.getConversationAsync().then(buildRewindActionReturn);
60411
+ }
60412
+ return buildRewindActionReturn(recordingService.getConversation());
59910
60413
  }
59911
60414
  };
59912
60415
 
@@ -59940,14 +60443,14 @@ function enableHook(settings, hookName) {
59940
60443
  }
59941
60444
  const modifiedScopes = [];
59942
60445
  try {
59943
- for (const { scope, path: path37 } of foundInDisabledScopes) {
60446
+ for (const { scope, path: path38 } of foundInDisabledScopes) {
59944
60447
  if (isLoadableSettingScope(scope)) {
59945
60448
  const currentScopeDisabled = settings.forScope(scope).settings.hooksConfig?.disabled ?? [];
59946
60449
  const newDisabled = currentScopeDisabled.filter(
59947
60450
  (name) => name !== hookName
59948
60451
  );
59949
60452
  settings.setValue(scope, "hooksConfig.disabled", newDisabled);
59950
- modifiedScopes.push({ scope, path: path37 });
60453
+ modifiedScopes.push({ scope, path: path38 });
59951
60454
  }
59952
60455
  }
59953
60456
  } catch (error) {
@@ -60242,7 +60745,7 @@ async function enableAction3(context, args) {
60242
60745
  }
60243
60746
  const feedback = renderHookActionFeedback(
60244
60747
  result,
60245
- (label, path37) => `${label} (${path37})`
60748
+ (label, path38) => `${label} (${path38})`
60246
60749
  );
60247
60750
  return {
60248
60751
  type: "message",
@@ -60284,7 +60787,7 @@ async function disableAction3(context, args) {
60284
60787
  }
60285
60788
  const feedback = renderHookActionFeedback(
60286
60789
  result,
60287
- (label, path37) => `${label} (${path37})`
60790
+ (label, path38) => `${label} (${path38})`
60288
60791
  );
60289
60792
  return {
60290
60793
  type: "message",
@@ -60838,7 +61341,7 @@ Use /mcp auth <server-name> to authenticate.`
60838
61341
  type: "info",
60839
61342
  text: `Starting OAuth authentication for MCP server '${serverName}'...`
60840
61343
  });
60841
- const { MCPOAuthProvider } = await import("./dist-E6RCLXQU.js");
61344
+ const { MCPOAuthProvider } = await import("./dist-OSQFIX7F.js");
60842
61345
  let oauthConfig = server.oauth;
60843
61346
  if (!oauthConfig) {
60844
61347
  oauthConfig = { enabled: false };
@@ -76479,6 +76982,37 @@ var memoryCommand = (_config) => {
76479
76982
  };
76480
76983
 
76481
76984
  // packages/cli/src/ui/commands/modelCommand.ts
76985
+ function getValidModelNames(context) {
76986
+ const validModels = /* @__PURE__ */ new Set([
76987
+ ...Array.from(VALID_GEMINI_MODELS).filter((model) => model !== "none"),
76988
+ ...Object.keys(DEFAULT_MODEL_CONFIGS.modelDefinitions ?? {}),
76989
+ GEMINI_MODEL_ALIAS_AUTO,
76990
+ GEMINI_MODEL_ALIAS_PRO,
76991
+ GEMINI_MODEL_ALIAS_FLASH,
76992
+ GEMINI_MODEL_ALIAS_FLASH_LITE,
76993
+ PREVIEW_GEMINI_MODEL_AUTO,
76994
+ DEFAULT_GEMINI_MODEL_AUTO
76995
+ ]);
76996
+ const config = context.services.agentContext?.config;
76997
+ const serviceDefinitions = config?.getModelConfigService?.()?.getModelDefinitions?.();
76998
+ if (serviceDefinitions) {
76999
+ for (const model of Object.keys(serviceDefinitions)) {
77000
+ validModels.add(model);
77001
+ }
77002
+ }
77003
+ const modelConfigs = context.services.settings?.merged?.modelConfigs;
77004
+ if (modelConfigs?.customAliases) {
77005
+ for (const alias of Object.keys(modelConfigs.customAliases)) {
77006
+ validModels.add(alias);
77007
+ }
77008
+ }
77009
+ if (modelConfigs?.modelDefinitions) {
77010
+ for (const model of Object.keys(modelConfigs.modelDefinitions)) {
77011
+ validModels.add(model);
77012
+ }
77013
+ }
77014
+ return validModels;
77015
+ }
76482
77016
  var setModelCommand = {
76483
77017
  name: "set",
76484
77018
  description: "Set the model to use. Usage: /model set <model-name> [--persist]",
@@ -76486,15 +77020,24 @@ var setModelCommand = {
76486
77020
  autoExecute: false,
76487
77021
  action: async (context, args) => {
76488
77022
  const parts = args.trim().split(/\s+/).filter(Boolean);
76489
- if (parts.length === 0) {
77023
+ const persist = parts.includes("--persist");
77024
+ const nonFlagParts = parts.filter((part) => part !== "--persist");
77025
+ if (nonFlagParts.length === 0) {
76490
77026
  context.ui.addItem({
76491
77027
  type: "error" /* ERROR */,
76492
77028
  text: "Usage: /model set <model-name> [--persist]"
76493
77029
  });
76494
77030
  return;
76495
77031
  }
76496
- const modelName = parts[0];
76497
- const persist = parts.includes("--persist");
77032
+ const modelName = nonFlagParts[0];
77033
+ const validModels = getValidModelNames(context);
77034
+ if (!validModels.has(modelName)) {
77035
+ context.ui.addItem({
77036
+ type: "error" /* ERROR */,
77037
+ text: `Invalid model "${modelName}". Run /model to view and select from available models.`
77038
+ });
77039
+ return;
77040
+ }
76498
77041
  if (context.services.agentContext?.config) {
76499
77042
  context.services.agentContext.config.setModel(modelName, !persist);
76500
77043
  const event = new ModelSlashCommandEvent(modelName);
@@ -76504,6 +77047,10 @@ var setModelCommand = {
76504
77047
  text: `Model set to ${modelName}${persist ? " (persisted)" : ""}`
76505
77048
  });
76506
77049
  }
77050
+ },
77051
+ completion: async (context, partialArg) => {
77052
+ const validModels = Array.from(getValidModelNames(context));
77053
+ return validModels.filter((model) => model.startsWith(partialArg));
76507
77054
  }
76508
77055
  };
76509
77056
  var manageModelCommand = {
@@ -76527,7 +77074,12 @@ var modelCommand = {
76527
77074
  kind: "built-in" /* BUILT_IN */,
76528
77075
  autoExecute: false,
76529
77076
  subCommands: [manageModelCommand, setModelCommand],
76530
- action: async (context, args) => manageModelCommand.action(context, args)
77077
+ action: async (context, args) => {
77078
+ if (args.trim().length > 0) {
77079
+ return setModelCommand.action?.(context, args);
77080
+ }
77081
+ return manageModelCommand.action?.(context, args);
77082
+ }
76531
77083
  };
76532
77084
 
76533
77085
  // packages/cli/src/ui/components/triage/TriageDuplicates.tsx
@@ -78449,6 +79001,7 @@ var resumeCommand = {
78449
79001
  };
78450
79002
 
78451
79003
  // packages/cli/src/ui/commands/statsCommand.ts
79004
+ import path35 from "node:path";
78452
79005
  function getUserIdentity(context) {
78453
79006
  const selectedAuthType = context.services.settings.merged.security.auth.selectedType || "";
78454
79007
  const userAccountManager = new UserAccountManager();
@@ -78495,14 +79048,56 @@ async function defaultSessionView(context) {
78495
79048
  }
78496
79049
  context.ui.addItem(statsItem);
78497
79050
  }
79051
+ async function heatmapView(context, rawArgs) {
79052
+ const now = /* @__PURE__ */ new Date();
79053
+ const parsedDate = resolveHeatmapDateArg(rawArgs, now);
79054
+ if (!parsedDate.ok) {
79055
+ context.ui.addItem({
79056
+ type: "error" /* ERROR */,
79057
+ text: parsedDate.error
79058
+ });
79059
+ return;
79060
+ }
79061
+ let chatsDir = "";
79062
+ try {
79063
+ const projectTempDir = context.services.agentContext?.config?.storage?.getProjectTempDir();
79064
+ if (projectTempDir) {
79065
+ chatsDir = path35.join(projectTempDir, "chats");
79066
+ }
79067
+ } catch {
79068
+ chatsDir = "";
79069
+ }
79070
+ const dataset = await aggregateUsageFromRecordings(
79071
+ chatsDir,
79072
+ DEFAULT_HEATMAP_WINDOW_DAYS,
79073
+ now
79074
+ );
79075
+ const heatmapItem = {
79076
+ type: "heatmap_stats" /* HEATMAP_STATS */,
79077
+ dailyUsage: Object.fromEntries(dataset.dailyUsage),
79078
+ totalWindowTokens: dataset.totalWindowTokens,
79079
+ totalWindowSessions: dataset.totalWindowSessions,
79080
+ totalWindowTurns: dataset.totalWindowTurns,
79081
+ currentStreak: dataset.currentStreak,
79082
+ longestStreak: dataset.longestStreak,
79083
+ today: formatLocalDateKey(now),
79084
+ selectedDate: parsedDate.date
79085
+ };
79086
+ context.ui.addItem(heatmapItem);
79087
+ }
78498
79088
  var statsCommand = {
78499
79089
  name: "stats",
78500
79090
  altNames: ["usage"],
78501
- description: "Check session stats. Usage: /stats [session|model|tools]",
79091
+ description: "Check session stats. Usage: /stats [session|model|tools|heatmap]",
78502
79092
  kind: "built-in" /* BUILT_IN */,
78503
79093
  autoExecute: false,
78504
79094
  isSafeConcurrent: true,
78505
- action: async (context) => {
79095
+ action: async (context, args) => {
79096
+ const trimmed = (args ?? "").trim();
79097
+ if (trimmed === "heatmap" || trimmed.startsWith("heatmap ")) {
79098
+ await heatmapView(context, trimmed.slice("heatmap".length));
79099
+ return;
79100
+ }
78506
79101
  await defaultSessionView(context);
78507
79102
  },
78508
79103
  subCommands: [
@@ -78551,6 +79146,21 @@ var statsCommand = {
78551
79146
  type: "tool_stats" /* TOOL_STATS */
78552
79147
  });
78553
79148
  }
79149
+ },
79150
+ {
79151
+ name: "heatmap",
79152
+ description: "Show calendar heatmap of daily token usage. Usage: /stats heatmap [today|yesterday|YYYY-MM-DD]",
79153
+ kind: "built-in" /* BUILT_IN */,
79154
+ autoExecute: true,
79155
+ isSafeConcurrent: true,
79156
+ showCompletionLoading: false,
79157
+ completion: (_context, partialArg) => {
79158
+ const prefix = partialArg.trim().toLowerCase();
79159
+ return ["today", "yesterday"].filter((opt) => opt.startsWith(prefix));
79160
+ },
79161
+ action: async (context, args) => {
79162
+ await heatmapView(context, args);
79163
+ }
78554
79164
  }
78555
79165
  ]
78556
79166
  };
@@ -78668,7 +79278,7 @@ function disableSkill(settings, skillName, scope) {
78668
79278
  // packages/cli/src/utils/skillUtils.ts
78669
79279
  var import_extract_zip2 = __toESM(require_extract_zip(), 1);
78670
79280
  import * as fs31 from "node:fs/promises";
78671
- import * as path35 from "node:path";
79281
+ import * as path36 from "node:path";
78672
79282
  import * as os7 from "node:os";
78673
79283
  function renderSkillActionFeedback(result, formatScope) {
78674
79284
  const { skillName, action, status, error } = result;
@@ -78702,7 +79312,7 @@ function renderSkillActionFeedback(result, formatScope) {
78702
79312
  return `Skill "${skillName}" ${actionVerb} ${preposition} ${s3} settings.`;
78703
79313
  }
78704
79314
  function isPathTraversal(relative3) {
78705
- return relative3 === ".." || relative3.startsWith(".." + path35.sep) || path35.isAbsolute(relative3);
79315
+ return relative3 === ".." || relative3.startsWith(".." + path36.sep) || path36.isAbsolute(relative3);
78706
79316
  }
78707
79317
  function isInvalidSubpath(relative3) {
78708
79318
  return relative3 === "" || isPathTraversal(relative3);
@@ -78715,7 +79325,7 @@ async function installSkill(source2, scope, subpath, onLog, requestConsent = ()
78715
79325
  try {
78716
79326
  if (isGitUrl) {
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(`Cloning skill from ${source2}...`);
@@ -78728,19 +79338,19 @@ async function installSkill(source2, scope, subpath, onLog, requestConsent = ()
78728
79338
  );
78729
79339
  } else if (isSkillFile) {
78730
79340
  tempDirToClean = await fs31.mkdtemp(
78731
- path35.join(os7.tmpdir(), "gemini-skill-")
79341
+ path36.join(os7.tmpdir(), "gemini-skill-")
78732
79342
  );
78733
79343
  sourcePath = tempDirToClean;
78734
79344
  onLog(`Extracting skill from ${source2}...`);
78735
- await (0, import_extract_zip2.default)(path35.resolve(source2), { dir: tempDirToClean });
79345
+ await (0, import_extract_zip2.default)(path36.resolve(source2), { dir: tempDirToClean });
78736
79346
  }
78737
79347
  if (subpath) {
78738
- sourcePath = path35.join(sourcePath, subpath);
79348
+ sourcePath = path36.join(sourcePath, subpath);
78739
79349
  }
78740
- sourcePath = path35.resolve(sourcePath);
79350
+ sourcePath = path36.resolve(sourcePath);
78741
79351
  if (tempDirToClean) {
78742
- const resolvedTemp = path35.resolve(tempDirToClean);
78743
- const relative3 = path35.relative(resolvedTemp, sourcePath);
79352
+ const resolvedTemp = path36.resolve(tempDirToClean);
79353
+ const relative3 = path36.relative(resolvedTemp, sourcePath);
78744
79354
  if (isPathTraversal(relative3)) {
78745
79355
  throw new Error("Invalid path: Directory traversal not allowed.");
78746
79356
  }
@@ -78758,14 +79368,14 @@ async function installSkill(source2, scope, subpath, onLog, requestConsent = ()
78758
79368
  if (!await requestConsent(skills, targetDir)) {
78759
79369
  throw new Error("Skill installation cancelled by user.");
78760
79370
  }
78761
- const resolvedTarget = path35.resolve(targetDir);
79371
+ const resolvedTarget = path36.resolve(targetDir);
78762
79372
  await fs31.mkdir(resolvedTarget, { recursive: true });
78763
79373
  const installedSkills = [];
78764
79374
  for (const skill of skills) {
78765
79375
  const skillName = skill.name;
78766
- const skillDir = path35.dirname(skill.location);
78767
- const destPath = path35.resolve(resolvedTarget, skillName);
78768
- const relative3 = path35.relative(resolvedTarget, destPath);
79376
+ const skillDir = path36.dirname(skill.location);
79377
+ const destPath = path36.resolve(resolvedTarget, skillName);
79378
+ const relative3 = path36.relative(resolvedTarget, destPath);
78769
79379
  if (isInvalidSubpath(relative3)) {
78770
79380
  throw new Error("Invalid skill name: Path traversal detected.");
78771
79381
  }
@@ -78785,7 +79395,7 @@ async function installSkill(source2, scope, subpath, onLog, requestConsent = ()
78785
79395
  }
78786
79396
  }
78787
79397
  async function linkSkill(source2, scope, onLog, requestConsent = () => Promise.resolve(true)) {
78788
- const sourcePath = path35.resolve(source2);
79398
+ const sourcePath = path36.resolve(source2);
78789
79399
  onLog(`Searching for skills in ${sourcePath}...`);
78790
79400
  const skills = await loadSkillsFromDir(sourcePath);
78791
79401
  if (skills.length === 0) {
@@ -78810,14 +79420,14 @@ async function linkSkill(source2, scope, onLog, requestConsent = () => Promise.r
78810
79420
  if (!await requestConsent(skills, targetDir)) {
78811
79421
  throw new Error("Skill linking cancelled by user.");
78812
79422
  }
78813
- const resolvedTarget = path35.resolve(targetDir);
79423
+ const resolvedTarget = path36.resolve(targetDir);
78814
79424
  await fs31.mkdir(resolvedTarget, { recursive: true });
78815
79425
  const linkedSkills = [];
78816
79426
  for (const skill of skills) {
78817
79427
  const skillName = skill.name;
78818
- const skillSourceDir = path35.dirname(skill.location);
78819
- const destPath = path35.resolve(resolvedTarget, skillName);
78820
- const relative3 = path35.relative(resolvedTarget, destPath);
79428
+ const skillSourceDir = path36.dirname(skill.location);
79429
+ const destPath = path36.resolve(resolvedTarget, skillName);
79430
+ const relative3 = path36.relative(resolvedTarget, destPath);
78821
79431
  if (isInvalidSubpath(relative3)) {
78822
79432
  throw new Error("Invalid skill name: Path traversal detected.");
78823
79433
  }
@@ -78841,12 +79451,12 @@ async function uninstallSkill(name, scope) {
78841
79451
  const workspaceDir = process.cwd();
78842
79452
  const storage = new Storage(workspaceDir);
78843
79453
  const targetDir = scope === "workspace" ? storage.getProjectSkillsDir() : Storage.getUserSkillsDir();
78844
- const resolvedTarget = path35.resolve(targetDir);
79454
+ const resolvedTarget = path36.resolve(targetDir);
78845
79455
  const discoveredSkills = await loadSkillsFromDir(resolvedTarget);
78846
79456
  const skillToUninstall = discoveredSkills.find((s3) => s3.name === name);
78847
79457
  if (!skillToUninstall) {
78848
- const skillPath = path35.resolve(resolvedTarget, name);
78849
- const relative4 = path35.relative(resolvedTarget, skillPath);
79458
+ const skillPath = path36.resolve(resolvedTarget, name);
79459
+ const relative4 = path36.relative(resolvedTarget, skillPath);
78850
79460
  if (isInvalidSubpath(relative4)) {
78851
79461
  return null;
78852
79462
  }
@@ -78857,8 +79467,8 @@ async function uninstallSkill(name, scope) {
78857
79467
  await fs31.rm(skillPath, { recursive: true, force: true });
78858
79468
  return { location: skillPath };
78859
79469
  }
78860
- const skillDir = path35.resolve(path35.dirname(skillToUninstall.location));
78861
- const relative3 = path35.relative(resolvedTarget, skillDir);
79470
+ const skillDir = path36.resolve(path36.dirname(skillToUninstall.location));
79471
+ const relative3 = path36.relative(resolvedTarget, skillDir);
78862
79472
  if (isInvalidSubpath(relative3)) {
78863
79473
  return null;
78864
79474
  }
@@ -78992,7 +79602,7 @@ async function disableAction4(context, args) {
78992
79602
  const result = disableSkill(context.services.settings, skillName, scope);
78993
79603
  let feedback = renderSkillActionFeedback(
78994
79604
  result,
78995
- (label, path37) => `${label} (${path37})`
79605
+ (label, path38) => `${label} (${path38})`
78996
79606
  );
78997
79607
  if (result.status === "success" || result.status === "no-op") {
78998
79608
  feedback += ' You can run "/skills reload" to refresh your current instance.';
@@ -79028,7 +79638,7 @@ async function enableAction4(context, args) {
79028
79638
  const result = enableSkill(context.services.settings, skillName);
79029
79639
  let feedback = renderSkillActionFeedback(
79030
79640
  result,
79031
- (label, path37) => `${label} (${path37})`
79641
+ (label, path38) => `${label} (${path38})`
79032
79642
  );
79033
79643
  if (result.status === "success" || result.status === "no-op") {
79034
79644
  feedback += ' You can run "/skills reload" to refresh your current instance.';
@@ -79219,7 +79829,7 @@ var vimCommand = {
79219
79829
 
79220
79830
  // packages/cli/src/ui/commands/setupGithubCommand.ts
79221
79831
  var import_undici2 = __toESM(require_undici(), 1);
79222
- import path36 from "node:path";
79832
+ import path37 from "node:path";
79223
79833
  import * as fs32 from "node:fs";
79224
79834
  import { Writable } from "node:stream";
79225
79835
 
@@ -79349,7 +79959,7 @@ function getOpenUrlsCommands(readmeUrl) {
79349
79959
  }
79350
79960
  async function updateGitignore(gitRepoRoot) {
79351
79961
  const gitignoreEntries = [".gemini/", "gha-creds-*.json"];
79352
- const gitignorePath = path36.join(gitRepoRoot, ".gitignore");
79962
+ const gitignorePath = path37.join(gitRepoRoot, ".gitignore");
79353
79963
  try {
79354
79964
  let existingContent = "";
79355
79965
  let fileExists2 = true;
@@ -79404,9 +80014,9 @@ async function downloadFiles({
79404
80014
  `Empty body while downloading ${endpoint}: ${response.status} - ${response.statusText}`
79405
80015
  );
79406
80016
  }
79407
- const destination = path36.resolve(
80017
+ const destination = path37.resolve(
79408
80018
  targetDir,
79409
- path36.basename(fileBasename)
80019
+ path37.basename(fileBasename)
79410
80020
  );
79411
80021
  const fileStream = fs32.createWriteStream(destination, {
79412
80022
  mode: 420,
@@ -79479,9 +80089,9 @@ var setupGithubCommand = {
79479
80089
  const proxy = context?.services?.agentContext?.config.getProxy();
79480
80090
  const releaseTag = await getLatestGitHubRelease(proxy);
79481
80091
  const readmeUrl = `https://github.com/google-github-actions/run-gemini-cli/blob/${releaseTag}/README.md#quick-start`;
79482
- const workflowsDir = path36.join(gitRepoRoot, ".github", "workflows");
80092
+ const workflowsDir = path37.join(gitRepoRoot, ".github", "workflows");
79483
80093
  await createDirectory(workflowsDir);
79484
- const commandsDir = path36.join(gitRepoRoot, ".github", "commands");
80094
+ const commandsDir = path37.join(gitRepoRoot, ".github", "commands");
79485
80095
  await createDirectory(commandsDir);
79486
80096
  await downloadSetupFiles({
79487
80097
  configs: [