@unity-china/codely-cli 1.0.0-beta.43 → 1.0.0-beta.45

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/bundle/gemini.js CHANGED
@@ -25910,7 +25910,7 @@ var require_backend = __commonJS({
25910
25910
  });
25911
25911
  return value;
25912
25912
  },
25913
- useEffect: function useEffect38(create4) {
25913
+ useEffect: function useEffect39(create4) {
25914
25914
  nextHook();
25915
25915
  hookLog.push({
25916
25916
  displayName: null,
@@ -25983,7 +25983,7 @@ var require_backend = __commonJS({
25983
25983
  return [initialArg, function() {
25984
25984
  }];
25985
25985
  },
25986
- useRef: function useRef14(initialValue) {
25986
+ useRef: function useRef15(initialValue) {
25987
25987
  var hook = nextHook();
25988
25988
  initialValue = null !== hook ? hook.memoizedState : {
25989
25989
  current: initialValue
@@ -25998,7 +25998,7 @@ var require_backend = __commonJS({
25998
25998
  });
25999
25999
  return initialValue;
26000
26000
  },
26001
- useState: function useState42(initialState2) {
26001
+ useState: function useState43(initialState2) {
26002
26002
  var hook = nextHook();
26003
26003
  initialState2 = null !== hook ? hook.memoizedState : "function" === typeof initialState2 ? initialState2() : initialState2;
26004
26004
  hookLog.push({
@@ -34598,7 +34598,7 @@ var require_backend = __commonJS({
34598
34598
  var symbolOrNumber = renderer_typeof(type) === "object" && type !== null ? type.$$typeof : type;
34599
34599
  return renderer_typeof(symbolOrNumber) === "symbol" ? symbolOrNumber.toString() : symbolOrNumber;
34600
34600
  }
34601
- var _ReactTypeOfWork = ReactTypeOfWork, CacheComponent = _ReactTypeOfWork.CacheComponent, ClassComponent = _ReactTypeOfWork.ClassComponent, IncompleteClassComponent = _ReactTypeOfWork.IncompleteClassComponent, IncompleteFunctionComponent = _ReactTypeOfWork.IncompleteFunctionComponent, FunctionComponent = _ReactTypeOfWork.FunctionComponent, IndeterminateComponent = _ReactTypeOfWork.IndeterminateComponent, ForwardRef = _ReactTypeOfWork.ForwardRef, HostRoot = _ReactTypeOfWork.HostRoot, HostHoistable = _ReactTypeOfWork.HostHoistable, HostSingleton = _ReactTypeOfWork.HostSingleton, HostComponent = _ReactTypeOfWork.HostComponent, HostPortal = _ReactTypeOfWork.HostPortal, HostText = _ReactTypeOfWork.HostText, Fragment7 = _ReactTypeOfWork.Fragment, LazyComponent = _ReactTypeOfWork.LazyComponent, LegacyHiddenComponent = _ReactTypeOfWork.LegacyHiddenComponent, MemoComponent = _ReactTypeOfWork.MemoComponent, OffscreenComponent = _ReactTypeOfWork.OffscreenComponent, Profiler = _ReactTypeOfWork.Profiler, ScopeComponent = _ReactTypeOfWork.ScopeComponent, SimpleMemoComponent = _ReactTypeOfWork.SimpleMemoComponent, SuspenseComponent = _ReactTypeOfWork.SuspenseComponent, SuspenseListComponent = _ReactTypeOfWork.SuspenseListComponent, TracingMarkerComponent = _ReactTypeOfWork.TracingMarkerComponent, Throw = _ReactTypeOfWork.Throw, ViewTransitionComponent = _ReactTypeOfWork.ViewTransitionComponent, ActivityComponent = _ReactTypeOfWork.ActivityComponent;
34601
+ var _ReactTypeOfWork = ReactTypeOfWork, CacheComponent = _ReactTypeOfWork.CacheComponent, ClassComponent = _ReactTypeOfWork.ClassComponent, IncompleteClassComponent = _ReactTypeOfWork.IncompleteClassComponent, IncompleteFunctionComponent = _ReactTypeOfWork.IncompleteFunctionComponent, FunctionComponent = _ReactTypeOfWork.FunctionComponent, IndeterminateComponent = _ReactTypeOfWork.IndeterminateComponent, ForwardRef = _ReactTypeOfWork.ForwardRef, HostRoot = _ReactTypeOfWork.HostRoot, HostHoistable = _ReactTypeOfWork.HostHoistable, HostSingleton = _ReactTypeOfWork.HostSingleton, HostComponent = _ReactTypeOfWork.HostComponent, HostPortal = _ReactTypeOfWork.HostPortal, HostText = _ReactTypeOfWork.HostText, Fragment6 = _ReactTypeOfWork.Fragment, LazyComponent = _ReactTypeOfWork.LazyComponent, LegacyHiddenComponent = _ReactTypeOfWork.LegacyHiddenComponent, MemoComponent = _ReactTypeOfWork.MemoComponent, OffscreenComponent = _ReactTypeOfWork.OffscreenComponent, Profiler = _ReactTypeOfWork.Profiler, ScopeComponent = _ReactTypeOfWork.ScopeComponent, SimpleMemoComponent = _ReactTypeOfWork.SimpleMemoComponent, SuspenseComponent = _ReactTypeOfWork.SuspenseComponent, SuspenseListComponent = _ReactTypeOfWork.SuspenseListComponent, TracingMarkerComponent = _ReactTypeOfWork.TracingMarkerComponent, Throw = _ReactTypeOfWork.Throw, ViewTransitionComponent = _ReactTypeOfWork.ViewTransitionComponent, ActivityComponent = _ReactTypeOfWork.ActivityComponent;
34602
34602
  function resolveFiberType(type) {
34603
34603
  var typeSymbol = getTypeSymbol(type);
34604
34604
  switch (typeSymbol) {
@@ -34655,7 +34655,7 @@ var require_backend = __commonJS({
34655
34655
  case HostPortal:
34656
34656
  case HostText:
34657
34657
  return null;
34658
- case Fragment7:
34658
+ case Fragment6:
34659
34659
  return "Fragment";
34660
34660
  case LazyComponent:
34661
34661
  return "Lazy";
@@ -34808,7 +34808,7 @@ var require_backend = __commonJS({
34808
34808
  function renderer_attach(hook, rendererID, renderer2, global2, shouldStartProfilingNow, profilingSettings) {
34809
34809
  var version3 = renderer2.reconcilerVersion || renderer2.version;
34810
34810
  var _getInternalReactCons = getInternalReactConstants(version3), getDisplayNameForFiber = _getInternalReactCons.getDisplayNameForFiber, getTypeSymbol = _getInternalReactCons.getTypeSymbol, ReactPriorityLevels = _getInternalReactCons.ReactPriorityLevels, ReactTypeOfWork = _getInternalReactCons.ReactTypeOfWork, StrictModeBits = _getInternalReactCons.StrictModeBits;
34811
- var ActivityComponent = ReactTypeOfWork.ActivityComponent, CacheComponent = ReactTypeOfWork.CacheComponent, ClassComponent = ReactTypeOfWork.ClassComponent, ContextConsumer = ReactTypeOfWork.ContextConsumer, DehydratedSuspenseComponent = ReactTypeOfWork.DehydratedSuspenseComponent, ForwardRef = ReactTypeOfWork.ForwardRef, Fragment7 = ReactTypeOfWork.Fragment, FunctionComponent = ReactTypeOfWork.FunctionComponent, HostRoot = ReactTypeOfWork.HostRoot, HostHoistable = ReactTypeOfWork.HostHoistable, HostSingleton = ReactTypeOfWork.HostSingleton, HostPortal = ReactTypeOfWork.HostPortal, HostComponent = ReactTypeOfWork.HostComponent, HostText = ReactTypeOfWork.HostText, IncompleteClassComponent = ReactTypeOfWork.IncompleteClassComponent, IncompleteFunctionComponent = ReactTypeOfWork.IncompleteFunctionComponent, IndeterminateComponent = ReactTypeOfWork.IndeterminateComponent, LegacyHiddenComponent = ReactTypeOfWork.LegacyHiddenComponent, MemoComponent = ReactTypeOfWork.MemoComponent, OffscreenComponent = ReactTypeOfWork.OffscreenComponent, SimpleMemoComponent = ReactTypeOfWork.SimpleMemoComponent, SuspenseComponent = ReactTypeOfWork.SuspenseComponent, SuspenseListComponent = ReactTypeOfWork.SuspenseListComponent, TracingMarkerComponent = ReactTypeOfWork.TracingMarkerComponent, Throw = ReactTypeOfWork.Throw, ViewTransitionComponent = ReactTypeOfWork.ViewTransitionComponent;
34811
+ var ActivityComponent = ReactTypeOfWork.ActivityComponent, CacheComponent = ReactTypeOfWork.CacheComponent, ClassComponent = ReactTypeOfWork.ClassComponent, ContextConsumer = ReactTypeOfWork.ContextConsumer, DehydratedSuspenseComponent = ReactTypeOfWork.DehydratedSuspenseComponent, ForwardRef = ReactTypeOfWork.ForwardRef, Fragment6 = ReactTypeOfWork.Fragment, FunctionComponent = ReactTypeOfWork.FunctionComponent, HostRoot = ReactTypeOfWork.HostRoot, HostHoistable = ReactTypeOfWork.HostHoistable, HostSingleton = ReactTypeOfWork.HostSingleton, HostPortal = ReactTypeOfWork.HostPortal, HostComponent = ReactTypeOfWork.HostComponent, HostText = ReactTypeOfWork.HostText, IncompleteClassComponent = ReactTypeOfWork.IncompleteClassComponent, IncompleteFunctionComponent = ReactTypeOfWork.IncompleteFunctionComponent, IndeterminateComponent = ReactTypeOfWork.IndeterminateComponent, LegacyHiddenComponent = ReactTypeOfWork.LegacyHiddenComponent, MemoComponent = ReactTypeOfWork.MemoComponent, OffscreenComponent = ReactTypeOfWork.OffscreenComponent, SimpleMemoComponent = ReactTypeOfWork.SimpleMemoComponent, SuspenseComponent = ReactTypeOfWork.SuspenseComponent, SuspenseListComponent = ReactTypeOfWork.SuspenseListComponent, TracingMarkerComponent = ReactTypeOfWork.TracingMarkerComponent, Throw = ReactTypeOfWork.Throw, ViewTransitionComponent = ReactTypeOfWork.ViewTransitionComponent;
34812
34812
  var ImmediatePriority = ReactPriorityLevels.ImmediatePriority, UserBlockingPriority = ReactPriorityLevels.UserBlockingPriority, NormalPriority = ReactPriorityLevels.NormalPriority, LowPriority = ReactPriorityLevels.LowPriority, IdlePriority = ReactPriorityLevels.IdlePriority, NoPriority = ReactPriorityLevels.NoPriority;
34813
34813
  var getLaneLabelMap = renderer2.getLaneLabelMap, injectProfilingHooks = renderer2.injectProfilingHooks, overrideHookState = renderer2.overrideHookState, overrideHookStateDeletePath = renderer2.overrideHookStateDeletePath, overrideHookStateRenamePath = renderer2.overrideHookStateRenamePath, overrideProps = renderer2.overrideProps, overridePropsDeletePath = renderer2.overridePropsDeletePath, overridePropsRenamePath = renderer2.overridePropsRenamePath, scheduleRefresh = renderer2.scheduleRefresh, setErrorHandler = renderer2.setErrorHandler, setSuspenseHandler = renderer2.setSuspenseHandler, scheduleUpdate = renderer2.scheduleUpdate, getCurrentFiber = renderer2.getCurrentFiber;
34814
34814
  var supportsTogglingError = typeof setErrorHandler === "function" && typeof scheduleUpdate === "function";
@@ -35153,7 +35153,7 @@ var require_backend = __commonJS({
35153
35153
  return true;
35154
35154
  case HostRoot:
35155
35155
  return false;
35156
- case Fragment7:
35156
+ case Fragment6:
35157
35157
  return key === null;
35158
35158
  default:
35159
35159
  var typeSymbol = getTypeSymbol(type);
@@ -35227,7 +35227,7 @@ var require_backend = __commonJS({
35227
35227
  return ElementTypeHostComponent;
35228
35228
  case HostPortal:
35229
35229
  case HostText:
35230
- case Fragment7:
35230
+ case Fragment6:
35231
35231
  return ElementTypeOtherOrUnknown;
35232
35232
  case MemoComponent:
35233
35233
  case SimpleMemoComponent:
@@ -80631,7 +80631,7 @@ var init_codelyOAuth2 = __esm({
80631
80631
  import * as https2 from "https";
80632
80632
  import * as http3 from "http";
80633
80633
  import { URL as URL3 } from "url";
80634
- var import_https_proxy_agent3, getCodelyStorageEndpoint, CodelyLogger;
80634
+ var import_https_proxy_agent3, getCodelyStorageEndpoint, CODELY_LOGGER_NO_EMIT_ENV, CodelyLogger;
80635
80635
  var init_codely_logger = __esm({
80636
80636
  "packages/core/dist/src/telemetry/codely-logger/codely-logger.js"() {
80637
80637
  "use strict";
@@ -80641,6 +80641,7 @@ var init_codely_logger = __esm({
80641
80641
  init_codelyOAuth2();
80642
80642
  init_serverUrl();
80643
80643
  getCodelyStorageEndpoint = () => `${getServerBaseUrl()}/api/codely/storage`;
80644
+ CODELY_LOGGER_NO_EMIT_ENV = "CODELY_LOGGER_NO_EMIT";
80644
80645
  CodelyLogger = class _CodelyLogger {
80645
80646
  static instance;
80646
80647
  config;
@@ -80674,6 +80675,9 @@ var init_codely_logger = __esm({
80674
80675
  return this.accessToken;
80675
80676
  }
80676
80677
  async sendEventToCodely(event) {
80678
+ if (process.env[CODELY_LOGGER_NO_EMIT_ENV]?.trim()) {
80679
+ return;
80680
+ }
80677
80681
  if (process.env.CUSTOM_AUTH) {
80678
80682
  return;
80679
80683
  }
@@ -363862,13 +363866,21 @@ var init_activate_skill = __esm({
363862
363866
  init_getFolderStructure();
363863
363867
  ActivateSkillToolInvocation = class extends BaseToolInvocation {
363864
363868
  config;
363869
+ allowedSkillNames;
363865
363870
  cachedFolderStructure;
363866
- constructor(config4, params) {
363871
+ constructor(config4, params, allowedSkillNames) {
363867
363872
  super(params);
363868
363873
  this.config = config4;
363874
+ this.allowedSkillNames = allowedSkillNames;
363875
+ }
363876
+ isSkillAllowed(name3) {
363877
+ return this.allowedSkillNames ? this.allowedSkillNames.has(name3) : true;
363869
363878
  }
363870
363879
  getDescription() {
363871
363880
  const skillName = this.params.name;
363881
+ if (!this.isSkillAllowed(skillName)) {
363882
+ return `"${skillName}" (not allowed)`;
363883
+ }
363872
363884
  const skill = this.config.getSkillManager().getSkill(skillName);
363873
363885
  if (skill) {
363874
363886
  return `"${skillName}": ${skill.description}`;
@@ -363883,6 +363895,9 @@ var init_activate_skill = __esm({
363883
363895
  }
363884
363896
  async shouldConfirmExecute() {
363885
363897
  const skillName = this.params.name;
363898
+ if (!this.isSkillAllowed(skillName)) {
363899
+ return false;
363900
+ }
363886
363901
  const skill = this.config.getSkillManager().getSkill(skillName);
363887
363902
  if (!skill || skill.disabled) {
363888
363903
  return false;
@@ -363911,8 +363926,8 @@ ${folderStructure}`,
363911
363926
  const skillName = this.params.name;
363912
363927
  const skillManager = this.config.getSkillManager();
363913
363928
  const skill = skillManager.getSkill(skillName);
363914
- if (!skill || skill.disabled) {
363915
- const availableSkills = skillManager.getSkills().map((s3) => s3.name).join(", ");
363929
+ const availableSkills = skillManager.getSkills().map((s3) => s3.name).filter((name3) => this.isSkillAllowed(name3)).join(", ");
363930
+ if (!this.isSkillAllowed(skillName) || !skill || skill.disabled) {
363916
363931
  const errorMessage = `Skill "${skillName}" not found. Available skills are: ${availableSkills}`;
363917
363932
  return {
363918
363933
  llmContent: `Error: ${errorMessage}`,
@@ -363945,9 +363960,11 @@ ${folderStructure}`
363945
363960
  ActivateSkillTool = class _ActivateSkillTool extends BaseDeclarativeTool {
363946
363961
  config;
363947
363962
  static Name = ACTIVATE_SKILL_TOOL_NAME;
363948
- constructor(config4) {
363963
+ allowedSkillNames;
363964
+ constructor(config4, options2) {
363965
+ const allowlist = Array.isArray(options2?.allowedSkillNames) && options2.allowedSkillNames.length > 0 ? new Set(options2.allowedSkillNames) : null;
363949
363966
  const skills = config4.getSkillManager().getSkills();
363950
- const skillNames = skills.map((s3) => s3.name);
363967
+ const skillNames = skills.map((s3) => s3.name).filter((name3) => allowlist ? allowlist.has(name3) : true);
363951
363968
  const schema = skillNames.length === 0 ? {
363952
363969
  type: "object",
363953
363970
  properties: {
@@ -363985,11 +364002,19 @@ ${folderStructure}`
363985
364002
  false
363986
364003
  );
363987
364004
  this.config = config4;
364005
+ this.allowedSkillNames = allowlist;
364006
+ }
364007
+ isSkillAllowed(name3) {
364008
+ return this.allowedSkillNames ? this.allowedSkillNames.has(name3) : true;
363988
364009
  }
363989
364010
  validateToolParams(params) {
363990
364011
  if (!params.name || typeof params.name !== "string") {
363991
364012
  return 'Parameter "name" must be a non-empty string.';
363992
364013
  }
364014
+ if (!this.isSkillAllowed(params.name)) {
364015
+ const available = this.config.getSkillManager().getSkills().map((s3) => s3.name).filter((name3) => this.isSkillAllowed(name3));
364016
+ return `Skill "${params.name}" not found. Available skills: ${available.join(", ")}`;
364017
+ }
363993
364018
  const skill = this.config.getSkillManager().getSkill(params.name);
363994
364019
  if (!skill || skill.disabled) {
363995
364020
  const available = this.config.getSkillManager().getSkills().map((s3) => s3.name);
@@ -363998,7 +364023,7 @@ ${folderStructure}`
363998
364023
  return null;
363999
364024
  }
364000
364025
  createInvocation(params) {
364001
- return new ActivateSkillToolInvocation(this.config, params);
364026
+ return new ActivateSkillToolInvocation(this.config, params, this.allowedSkillNames);
364002
364027
  }
364003
364028
  };
364004
364029
  }
@@ -365236,7 +365261,7 @@ function urlMatches(urlArray, targetUrl) {
365236
365261
  const normalizedTarget = normalizeUrl2(targetUrl);
365237
365262
  return urlArray.some((url4) => normalizeUrl2(url4) === normalizedTarget);
365238
365263
  }
365239
- function getCoreSystemPrompt(userMemory, config4, additionalPrompts) {
365264
+ function getCoreSystemPrompt(userMemory, config4, additionalPrompts, runtimeContext) {
365240
365265
  const enableSequentialThinking = config4?.enableSequentialThinking ?? true;
365241
365266
  const planToolingGuidance = enableSequentialThinking ? [
365242
365267
  ` - Use the '${SequentialThinkTool.Name}' and '${TodoWriteTool.Name}' together to plan before implementing the task.`,
@@ -365268,9 +365293,9 @@ function getCoreSystemPrompt(userMemory, config4, additionalPrompts) {
365268
365293
  }
365269
365294
  }
365270
365295
  }
365271
- if (config4?.systemPromptMappings) {
365272
- const currentModel = process23.env.OPENAI_MODEL || "";
365273
- const currentBaseUrl = process23.env.OPENAI_BASE_URL || "";
365296
+ if (config4?.systemPromptMappings && process23.env.CUSTOM_AUTH && runtimeContext?.authType === AuthType3.USE_OPENAI) {
365297
+ const currentModel = runtimeContext.model || "";
365298
+ const currentBaseUrl = runtimeContext.baseUrl || "";
365274
365299
  const matchedMapping = config4.systemPromptMappings.find((mapping) => {
365275
365300
  const { baseUrls, modelNames } = mapping;
365276
365301
  if (baseUrls && modelNames && urlMatches(baseUrls, currentBaseUrl) && modelNames.includes(currentModel)) {
@@ -365802,6 +365827,7 @@ var init_prompts = __esm({
365802
365827
  init_gitUtils();
365803
365828
  init_memoryTool();
365804
365829
  init_tool_names();
365830
+ init_contentGenerator();
365805
365831
  SystemPromptExtensions = class _SystemPromptExtensions {
365806
365832
  static instance;
365807
365833
  extensions = [];
@@ -367484,7 +367510,10 @@ Original error: ${getErrorMessage(error41)}`);
367484
367510
  },
367485
367511
  config: {
367486
367512
  systemInstruction: { text: getCompressionPrompt() },
367487
- tools: []
367513
+ tools: [],
367514
+ // Compression summaries can be truncated if users configured a low global max output.
367515
+ // Override with a safe default so compression remains effective.
367516
+ maxOutputTokens: 5e3
367488
367517
  }
367489
367518
  }, prompt_id);
367490
367519
  let fullResponse = "";
@@ -375712,6 +375741,10 @@ var init_agentLoader = __esm({
375712
375741
  const parsedTools = parseStringList(toolsRaw)?.filter((t3) => t3 !== DELEGATE_TO_AGENT_TOOL_NAME).filter(Boolean);
375713
375742
  const toolList = parsedTools ?? [];
375714
375743
  const inheritTools = toolsRaw === void 0 || toolsRaw === null || toolList.length === 0;
375744
+ const skillsRaw = frontmatter["skills"];
375745
+ const parsedSkills = parseStringList(skillsRaw)?.filter(Boolean);
375746
+ const skillList = parsedSkills ?? [];
375747
+ const inheritSkills = skillsRaw === void 0 || skillsRaw === null || skillList.length === 0;
375715
375748
  const modelRaw = frontmatter["model"];
375716
375749
  const model = typeof modelRaw === "string" ? modelRaw.trim().toLowerCase() === "inherit" ? "" : modelRaw.trim() : "";
375717
375750
  const queryRaw = frontmatter["query"];
@@ -375736,6 +375769,8 @@ var init_agentLoader = __esm({
375736
375769
  };
375737
375770
  if (inheritTools)
375738
375771
  metadata["inheritTools"] = true;
375772
+ if (inheritSkills)
375773
+ metadata["inheritSkills"] = true;
375739
375774
  if (Object.keys(extraFrontmatter).length > 0) {
375740
375775
  metadata["frontmatter"] = extraFrontmatter;
375741
375776
  }
@@ -375758,6 +375793,7 @@ var init_agentLoader = __esm({
375758
375793
  stream: stream4
375759
375794
  },
375760
375795
  toolConfig: inheritTools ? void 0 : { tools: toolList },
375796
+ skillConfig: inheritSkills ? void 0 : { skills: skillList },
375761
375797
  // Claude-style YAML agents: keep inputs minimal and consistent. We always
375762
375798
  // expose a single required `task` param and do not support YAML-defined schemas.
375763
375799
  inputConfig: buildInputConfig(void 0),
@@ -375779,6 +375815,9 @@ var init_agentLoader = __esm({
375779
375815
  const rawAllowedTools = config4.agent.tools?.allowed_tools;
375780
375816
  const tools = (Array.isArray(rawAllowedTools) ? rawAllowedTools : []).filter((t3) => typeof t3 === "string" && t3.trim().length > 0).map((t3) => t3.trim()).filter((t3) => t3 !== DELEGATE_TO_AGENT_TOOL_NAME);
375781
375817
  const inheritTools = !rawAllowedTools || tools.length === 0;
375818
+ const rawAllowedSkills = config4.agent.skills?.allowed_skills;
375819
+ const skills = (Array.isArray(rawAllowedSkills) ? rawAllowedSkills : []).filter((s3) => typeof s3 === "string" && s3.trim().length > 0).map((s3) => s3.trim());
375820
+ const inheritSkills = !rawAllowedSkills || skills.length === 0;
375782
375821
  return {
375783
375822
  name: agentName,
375784
375823
  displayName: config4.agent.name || baseName,
@@ -375807,11 +375846,13 @@ var init_agentLoader = __esm({
375807
375846
  stream: config4.agent.run_config?.stream ?? false
375808
375847
  },
375809
375848
  toolConfig: inheritTools ? void 0 : { tools },
375849
+ skillConfig: inheritSkills ? void 0 : { skills },
375810
375850
  inputConfig: buildInputConfig(coerceStringRecord(config4.validation?.input_schema)),
375811
375851
  metadata: {
375812
375852
  source: filePath,
375813
375853
  scope,
375814
- ...inheritTools ? { inheritTools: true } : {}
375854
+ ...inheritTools ? { inheritTools: true } : {},
375855
+ ...inheritSkills ? { inheritSkills: true } : {}
375815
375856
  }
375816
375857
  };
375817
375858
  }
@@ -375832,6 +375873,9 @@ var init_agentLoader = __esm({
375832
375873
  const rawTools = Array.isArray(config4.tools) ? config4.tools : void 0;
375833
375874
  const tools = (Array.isArray(rawTools) ? rawTools : []).filter((t3) => typeof t3 === "string" && t3.trim().length > 0).map((t3) => t3.trim()).filter((t3) => t3 !== DELEGATE_TO_AGENT_TOOL_NAME);
375834
375875
  const inheritTools = !rawTools || tools.length === 0;
375876
+ const rawSkills = Array.isArray(config4.skills) ? config4.skills : void 0;
375877
+ const skills = (Array.isArray(rawSkills) ? rawSkills : []).filter((s3) => typeof s3 === "string" && s3.trim().length > 0).map((s3) => s3.trim());
375878
+ const inheritSkills = !rawSkills || skills.length === 0;
375835
375879
  const kindRaw = typeof config4.kind === "string" ? config4.kind : void 0;
375836
375880
  const kind = kindRaw === "remote" ? "remote" : "local";
375837
375881
  const validationInputSchema = coerceStringRecord(config4.validation?.input_schema);
@@ -375860,11 +375904,13 @@ var init_agentLoader = __esm({
375860
375904
  stream: typeof run?.stream === "boolean" ? run.stream : false
375861
375905
  },
375862
375906
  toolConfig: inheritTools ? void 0 : { tools },
375907
+ skillConfig: inheritSkills ? void 0 : { skills },
375863
375908
  inputConfig: buildInputConfig(inputSchema),
375864
375909
  metadata: {
375865
375910
  source: filePath,
375866
375911
  scope,
375867
- ...inheritTools ? { inheritTools: true } : {}
375912
+ ...inheritTools ? { inheritTools: true } : {},
375913
+ ...inheritSkills ? { inheritSkills: true } : {}
375868
375914
  }
375869
375915
  };
375870
375916
  }
@@ -375937,7 +375983,7 @@ You run as a non-interactive subagent (do NOT ask the user questions). Your job
375937
375983
  # thinking_budget = -1
375938
375984
 
375939
375985
  [agent.model_config.sampling_params]
375940
- # reasoning_effort = "high" # "minimal" | "low" | "medium" | "high"
375986
+ # reasoning_effort = "high" # "minimal" | "low" | "medium" | "high" | "xhigh"
375941
375987
  # max_completion_tokens = 8192
375942
375988
  # temperature = 0.2
375943
375989
  # top_p = 0.95
@@ -375959,6 +376005,11 @@ stream = false
375959
376005
  #### Tool allowlist (empty = ALL tools)
375960
376006
  allowed_tools = []
375961
376007
 
376008
+ [agent.skills]
376009
+ #### Skills allowlist (empty = ALL skills)
376010
+ #### Only relevant when the main session has --experimental-skills enabled.
376011
+ allowed_skills = []
376012
+
375962
376013
  #### Available tools (DisplayName (real_name)):
375963
376014
  ${toolHintLines}
375964
376015
 
@@ -376004,6 +376055,10 @@ kind = "local"
376004
376055
  #### Tool allowlist (empty = ALL tools)
376005
376056
  tools = []
376006
376057
 
376058
+ #### Skills allowlist (empty = ALL skills)
376059
+ #### Only relevant when the main session has --experimental-skills enabled.
376060
+ skills = []
376061
+
376007
376062
  #### Available tools (DisplayName (real_name)):
376008
376063
  ${toolHintLines}
376009
376064
 
@@ -376091,6 +376146,11 @@ description: ${description || `Specialized agent for ${displayName.toLowerCase()
376091
376146
  tools:
376092
376147
  # tools: read_file, search_file_content, glob
376093
376148
 
376149
+ #### Skills allowlist (Claude-style; empty/omitted = ALL skills)
376150
+ #### Only relevant when the main session has --experimental-skills enabled.
376151
+ skills:
376152
+ # skills: code-review, testing
376153
+
376094
376154
  #### Available tools (DisplayName (real_name)):
376095
376155
  ${toolHintLines}
376096
376156
 
@@ -379257,6 +379317,7 @@ var init_executor = __esm({
379257
379317
  init_modelSamplingParams();
379258
379318
  init_generateContentResponseUtilities();
379259
379319
  init_tool_names();
379320
+ init_activate_skill();
379260
379321
  TASK_COMPLETE_TOOL_NAME = "complete_task";
379261
379322
  MAX_IDLE_RESPONSES = 3;
379262
379323
  AgentExecutor = class _AgentExecutor {
@@ -379310,6 +379371,14 @@ var init_executor = __esm({
379310
379371
  }
379311
379372
  }
379312
379373
  }
379374
+ const skillAllowlist = effectiveDefinition.skillConfig?.skills ?? [];
379375
+ const shouldRestrictSkills = Array.isArray(skillAllowlist) && skillAllowlist.length > 0;
379376
+ const hasActivateSkillTool = Boolean(effectiveDefinition.toolConfig?.tools?.some((t3) => typeof t3 === "string" && t3 === ACTIVATE_SKILL_TOOL_NAME));
379377
+ if (shouldRestrictSkills && hasActivateSkillTool) {
379378
+ agentToolRegistry.registerTool(new ActivateSkillTool(runtimeContext, {
379379
+ allowedSkillNames: skillAllowlist
379380
+ }));
379381
+ }
379313
379382
  const parentPromptId = promptIdContext.getStore();
379314
379383
  return new _AgentExecutor(effectiveDefinition, runtimeContext, agentToolRegistry, parentPromptId, onActivity);
379315
379384
  }
@@ -379972,7 +380041,7 @@ Your result MUST be a concise but informative summary for the caller (main agent
379972
380041
  let finalPrompt = getCoreSystemPrompt(userMemory, {
379973
380042
  systemPromptMappings,
379974
380043
  enableSequentialThinking: !this.runtimeContext.isThinkingSupportedModel()
379975
- });
380044
+ }, void 0, this.runtimeContext.getContentGeneratorConfig());
379976
380045
  finalPrompt += `
379977
380046
 
379978
380047
  # Agent Specialization
@@ -381211,6 +381280,7 @@ var init_config2 = __esm({
381211
381280
  cliVersion;
381212
381281
  experimentalZedIntegration = false;
381213
381282
  experimentalSkills = false;
381283
+ enabledSkills;
381214
381284
  disabledSkills = [];
381215
381285
  agentRegistry;
381216
381286
  agentRegistryInitPromise;
@@ -381281,6 +381351,7 @@ var init_config2 = __esm({
381281
381351
  this.sessionTokenLimit = params.sessionTokenLimit ?? -1;
381282
381352
  this.experimentalZedIntegration = params.experimentalZedIntegration ?? false;
381283
381353
  this.experimentalSkills = params.experimentalSkills ?? false;
381354
+ this.enabledSkills = params.enabledSkills;
381284
381355
  this.disabledSkills = params.disabledSkills ?? [];
381285
381356
  this.listExtensions = params.listExtensions ?? false;
381286
381357
  this.storage = new Storage(this.targetDir);
@@ -381880,7 +381951,17 @@ var init_config2 = __esm({
381880
381951
  this.disabledSkills = disabledSkills;
381881
381952
  }
381882
381953
  await this.skillManager.discoverSkills();
381883
- this.skillManager.setDisabledSkills(this.disabledSkills);
381954
+ const allowlist = Array.isArray(this.enabledSkills) && this.enabledSkills.length > 0 ? new Set(this.enabledSkills) : null;
381955
+ const allowlistDisabled = [];
381956
+ if (allowlist) {
381957
+ for (const skill of this.skillManager.getAllSkills()) {
381958
+ if (!allowlist.has(skill.name)) {
381959
+ allowlistDisabled.push(skill.name);
381960
+ }
381961
+ }
381962
+ }
381963
+ const effectiveDisabled = Array.from(/* @__PURE__ */ new Set([...this.disabledSkills, ...allowlistDisabled]));
381964
+ this.skillManager.setDisabledSkills(effectiveDisabled);
381884
381965
  const registry2 = await this.getToolRegistry();
381885
381966
  registry2.registerTool(new ActivateSkillTool(this));
381886
381967
  try {
@@ -397922,7 +398003,7 @@ var require_react_is_development = __commonJS({
397922
398003
  var ContextProvider = REACT_PROVIDER_TYPE;
397923
398004
  var Element3 = REACT_ELEMENT_TYPE;
397924
398005
  var ForwardRef = REACT_FORWARD_REF_TYPE;
397925
- var Fragment7 = REACT_FRAGMENT_TYPE;
398006
+ var Fragment6 = REACT_FRAGMENT_TYPE;
397926
398007
  var Lazy = REACT_LAZY_TYPE;
397927
398008
  var Memo = REACT_MEMO_TYPE;
397928
398009
  var Portal = REACT_PORTAL_TYPE;
@@ -397981,7 +398062,7 @@ var require_react_is_development = __commonJS({
397981
398062
  exports2.ContextProvider = ContextProvider;
397982
398063
  exports2.Element = Element3;
397983
398064
  exports2.ForwardRef = ForwardRef;
397984
- exports2.Fragment = Fragment7;
398065
+ exports2.Fragment = Fragment6;
397985
398066
  exports2.Lazy = Lazy;
397986
398067
  exports2.Memo = Memo;
397987
398068
  exports2.Portal = Portal;
@@ -414993,7 +415074,7 @@ var NoColorTheme = new Theme(
414993
415074
 
414994
415075
  // packages/cli/src/ui/themes/theme-manager.ts
414995
415076
  import process26 from "node:process";
414996
- var DEFAULT_THEME = QwenDark;
415077
+ var DEFAULT_THEME = ANSI;
414997
415078
  var ThemeManager = class {
414998
415079
  availableThemes;
414999
415080
  activeTheme;
@@ -415180,15 +415261,16 @@ var USER_SETTINGS_DIR = path53.join(homedir15(), SETTINGS_DIRECTORY_NAME);
415180
415261
  var USER_SETTINGS_PATH = path53.join(USER_SETTINGS_DIR, "settings.json");
415181
415262
  var DEFAULT_EXCLUDED_ENV_VARS = ["DEBUG", "DEBUG_MODE"];
415182
415263
  function getSystemSettingsPath() {
415183
- if (process.env.GEMINI_CLI_SYSTEM_SETTINGS_PATH) {
415184
- return process.env.GEMINI_CLI_SYSTEM_SETTINGS_PATH;
415264
+ const override = process.env.CODELY_CLI_SYSTEM_SETTINGS_PATH;
415265
+ if (override) {
415266
+ return override;
415185
415267
  }
415186
415268
  if (platform8() === "darwin") {
415187
- return "/Library/Application Support/QwenCode/settings.json";
415269
+ return "/Library/Application Support/CodelyCLI/settings.json";
415188
415270
  } else if (platform8() === "win32") {
415189
- return "C:\\ProgramData\\qwen-code\\settings.json";
415271
+ return "C:\\ProgramData\\codely-cli\\settings.json";
415190
415272
  } else {
415191
- return "/etc/qwen-code/settings.json";
415273
+ return "/etc/codely-cli/settings.json";
415192
415274
  }
415193
415275
  }
415194
415276
  function getWorkspaceSettingsPath(workspaceDir) {
@@ -415224,23 +415306,24 @@ var LoadedSettings = class {
415224
415306
  const workspace = this.workspace.settings;
415225
415307
  const { folderTrust, ...workspaceWithoutFolderTrust } = workspace;
415226
415308
  return {
415309
+ // Precedence (low -> high): system < user < workspace.
415310
+ ...system,
415227
415311
  ...user,
415228
415312
  ...workspaceWithoutFolderTrust,
415229
- ...system,
415230
415313
  customThemes: {
415314
+ ...system.customThemes || {},
415231
415315
  ...user.customThemes || {},
415232
- ...workspace.customThemes || {},
415233
- ...system.customThemes || {}
415316
+ ...workspace.customThemes || {}
415234
415317
  },
415235
415318
  mcpServers: {
415319
+ ...system.mcpServers || {},
415236
415320
  ...user.mcpServers || {},
415237
- ...workspace.mcpServers || {},
415238
- ...system.mcpServers || {}
415321
+ ...workspace.mcpServers || {}
415239
415322
  },
415240
415323
  skills: {
415324
+ ...system.skills || {},
415241
415325
  ...user.skills || {},
415242
415326
  ...workspaceWithoutFolderTrust.skills || {},
415243
- ...system.skills || {},
415244
415327
  // Union disabled lists across scopes for Gemini-compat behavior.
415245
415328
  disabled: Array.from(
415246
415329
  /* @__PURE__ */ new Set([
@@ -417317,6 +417400,43 @@ var useGeminiStream = (geminiClient, history, addItem, config4, logger7, onDebug
417317
417400
  const [pendingHistoryItemRef, setPendingHistoryItem] = useStateAndRef(null);
417318
417401
  const processedMemoryToolsRef = (0, import_react37.useRef)(/* @__PURE__ */ new Set());
417319
417402
  const { startNewPrompt, getPromptCount } = useSessionStats();
417403
+ const pendingGeminiTextRef = (0, import_react37.useRef)("");
417404
+ const flushTimerRef = (0, import_react37.useRef)(null);
417405
+ const clearFlushTimer = (0, import_react37.useCallback)(() => {
417406
+ if (flushTimerRef.current) {
417407
+ clearTimeout(flushTimerRef.current);
417408
+ flushTimerRef.current = null;
417409
+ }
417410
+ }, []);
417411
+ const flushPendingGeminiText = (0, import_react37.useCallback)(
417412
+ (options2) => {
417413
+ const force = options2?.force ?? false;
417414
+ if (!force && flushTimerRef.current) {
417415
+ return;
417416
+ }
417417
+ const doFlush = () => {
417418
+ flushTimerRef.current = null;
417419
+ if (pendingHistoryItemRef.current?.type !== "gemini" && pendingHistoryItemRef.current?.type !== "gemini_content") {
417420
+ return;
417421
+ }
417422
+ setPendingHistoryItem((item) => {
417423
+ if (!item) return item;
417424
+ if (item.type !== "gemini" && item.type !== "gemini_content")
417425
+ return item;
417426
+ if (item.text === pendingGeminiTextRef.current) return item;
417427
+ return { ...item, text: pendingGeminiTextRef.current };
417428
+ });
417429
+ };
417430
+ if (force) {
417431
+ clearFlushTimer();
417432
+ doFlush();
417433
+ return;
417434
+ }
417435
+ flushTimerRef.current = setTimeout(doFlush, 50);
417436
+ },
417437
+ [clearFlushTimer, pendingHistoryItemRef, setPendingHistoryItem]
417438
+ );
417439
+ (0, import_react37.useEffect)(() => clearFlushTimer, [clearFlushTimer]);
417320
417440
  const gitService = (0, import_react37.useMemo)(() => {
417321
417441
  if (!config4.getProjectRoot()) {
417322
417442
  return;
@@ -417395,6 +417515,7 @@ var useGeminiStream = (geminiClient, history, addItem, config4, logger7, onDebug
417395
417515
  turnCancelledRef.current = true;
417396
417516
  isSubmittingQueryRef.current = false;
417397
417517
  abortControllerRef.current?.abort();
417518
+ flushPendingGeminiText({ force: true });
417398
417519
  if (pendingHistoryItemRef.current) {
417399
417520
  addItem(pendingHistoryItemRef.current, Date.now());
417400
417521
  }
@@ -417411,6 +417532,7 @@ var useGeminiStream = (geminiClient, history, addItem, config4, logger7, onDebug
417411
417532
  }, [
417412
417533
  streamingState,
417413
417534
  addItem,
417535
+ flushPendingGeminiText,
417414
417536
  setPendingHistoryItem,
417415
417537
  onCancelSubmit,
417416
417538
  pendingHistoryItemRef,
@@ -417533,20 +417655,23 @@ var useGeminiStream = (geminiClient, history, addItem, config4, logger7, onDebug
417533
417655
  return "";
417534
417656
  }
417535
417657
  let newGeminiMessageBuffer = currentGeminiMessageBuffer + eventValue;
417658
+ const shouldForceFlush = eventValue.includes("\n") || eventValue.toLowerCase().includes("</think>") || eventValue.toLowerCase().includes("</thinking>");
417536
417659
  if (pendingHistoryItemRef.current?.type !== "gemini" && pendingHistoryItemRef.current?.type !== "gemini_content") {
417537
417660
  if (pendingHistoryItemRef.current) {
417538
417661
  addItem(pendingHistoryItemRef.current, userMessageTimestamp);
417539
417662
  }
417540
417663
  setPendingHistoryItem({ type: "gemini", text: "" });
417541
417664
  newGeminiMessageBuffer = eventValue;
417665
+ pendingGeminiTextRef.current = newGeminiMessageBuffer;
417666
+ flushPendingGeminiText({ force: true });
417667
+ return newGeminiMessageBuffer;
417542
417668
  }
417669
+ pendingGeminiTextRef.current = newGeminiMessageBuffer;
417543
417670
  const splitPoint = findLastSafeSplitPoint(newGeminiMessageBuffer);
417544
417671
  if (splitPoint === newGeminiMessageBuffer.length) {
417545
- setPendingHistoryItem((item) => ({
417546
- type: item?.type,
417547
- text: newGeminiMessageBuffer
417548
- }));
417672
+ flushPendingGeminiText({ force: shouldForceFlush });
417549
417673
  } else {
417674
+ flushPendingGeminiText({ force: true });
417550
417675
  const beforeText = newGeminiMessageBuffer.substring(0, splitPoint);
417551
417676
  const afterText = newGeminiMessageBuffer.substring(splitPoint);
417552
417677
  addItem(
@@ -417558,16 +417683,24 @@ var useGeminiStream = (geminiClient, history, addItem, config4, logger7, onDebug
417558
417683
  );
417559
417684
  setPendingHistoryItem({ type: "gemini_content", text: afterText });
417560
417685
  newGeminiMessageBuffer = afterText;
417686
+ pendingGeminiTextRef.current = newGeminiMessageBuffer;
417687
+ flushPendingGeminiText({ force: true });
417561
417688
  }
417562
417689
  return newGeminiMessageBuffer;
417563
417690
  },
417564
- [addItem, pendingHistoryItemRef, setPendingHistoryItem]
417691
+ [
417692
+ addItem,
417693
+ flushPendingGeminiText,
417694
+ pendingHistoryItemRef,
417695
+ setPendingHistoryItem
417696
+ ]
417565
417697
  );
417566
417698
  const handleUserCancelledEvent = (0, import_react37.useCallback)(
417567
417699
  (userMessageTimestamp) => {
417568
417700
  if (turnCancelledRef.current) {
417569
417701
  return;
417570
417702
  }
417703
+ flushPendingGeminiText({ force: true });
417571
417704
  if (pendingHistoryItemRef.current) {
417572
417705
  if (pendingHistoryItemRef.current.type === "tool_group") {
417573
417706
  const updatedTools = pendingHistoryItemRef.current.tools.map(
@@ -417590,10 +417723,17 @@ var useGeminiStream = (geminiClient, history, addItem, config4, logger7, onDebug
417590
417723
  setIsResponding(false);
417591
417724
  setThought(null);
417592
417725
  },
417593
- [addItem, pendingHistoryItemRef, setPendingHistoryItem, setThought]
417726
+ [
417727
+ addItem,
417728
+ flushPendingGeminiText,
417729
+ pendingHistoryItemRef,
417730
+ setPendingHistoryItem,
417731
+ setThought
417732
+ ]
417594
417733
  );
417595
417734
  const handleErrorEvent = (0, import_react37.useCallback)(
417596
417735
  (eventValue, userMessageTimestamp) => {
417736
+ flushPendingGeminiText({ force: true });
417597
417737
  if (pendingHistoryItemRef.current) {
417598
417738
  addItem(pendingHistoryItemRef.current, userMessageTimestamp);
417599
417739
  setPendingHistoryItem(null);
@@ -417613,7 +417753,14 @@ var useGeminiStream = (geminiClient, history, addItem, config4, logger7, onDebug
417613
417753
  );
417614
417754
  setThought(null);
417615
417755
  },
417616
- [addItem, pendingHistoryItemRef, setPendingHistoryItem, config4, setThought]
417756
+ [
417757
+ addItem,
417758
+ flushPendingGeminiText,
417759
+ pendingHistoryItemRef,
417760
+ setPendingHistoryItem,
417761
+ config4,
417762
+ setThought
417763
+ ]
417617
417764
  );
417618
417765
  const handleFinishedEvent = (0, import_react37.useCallback)(
417619
417766
  (event, userMessageTimestamp) => {
@@ -417839,6 +417986,7 @@ var useGeminiStream = (geminiClient, history, addItem, config4, logger7, onDebug
417839
417986
  return;
417840
417987
  }
417841
417988
  if (pendingHistoryItemRef.current) {
417989
+ flushPendingGeminiText({ force: true });
417842
417990
  addItem(pendingHistoryItemRef.current, userMessageTimestamp);
417843
417991
  setPendingHistoryItem(null);
417844
417992
  }
@@ -417895,7 +418043,9 @@ var useGeminiStream = (geminiClient, history, addItem, config4, logger7, onDebug
417895
418043
  config4,
417896
418044
  startNewPrompt,
417897
418045
  getPromptCount,
417898
- handleLoopDetectedEvent
418046
+ handleLoopDetectedEvent,
418047
+ cancelOngoingRequest,
418048
+ flushPendingGeminiText
417899
418049
  ]
417900
418050
  );
417901
418051
  const handleCompletedTools = (0, import_react37.useCallback)(
@@ -419218,7 +419368,7 @@ async function getPackageJson2() {
419218
419368
  // packages/cli/src/utils/version.ts
419219
419369
  async function getCliVersion() {
419220
419370
  const pkgJson = await getPackageJson2();
419221
- return "1.0.0-beta.43";
419371
+ return "1.0.0-beta.45";
419222
419372
  }
419223
419373
 
419224
419374
  // packages/cli/src/ui/commands/types.ts
@@ -419751,7 +419901,7 @@ import process30 from "node:process";
419751
419901
 
419752
419902
  // packages/cli/src/generated/git-commit.ts
419753
419903
  init_esbuild_polyfill();
419754
- var GIT_COMMIT_INFO = "92247f00";
419904
+ var GIT_COMMIT_INFO = "b8a99db1";
419755
419905
 
419756
419906
  // packages/cli/src/ui/commands/bugCommand.ts
419757
419907
  var bugCommand = {
@@ -421523,7 +421673,7 @@ Analyze the current directory and generate a comprehensive **${contextFileName}*
421523
421673
  - Based on the initial view, pick the most informative files. Typical priorities (choose any that exist, up to ten):
421524
421674
  - \`ProjectSettings/ProjectVersion.txt\` \u2013 Unity version.
421525
421675
  - \`Packages/manifest.json\` \u2013 package list, target platforms, render pipeline.
421526
- - \`Assets/Scenes/*.unity\` \u2013 entry/start scene(s).
421676
+ - \`Assets/Scenes/*.unity\` or \`Assets/Scenes/*.scene\` \u2013 entry/start scene(s). Note: Unity engine uses \`.unity\` extension, while Tuanjie engine uses \`.scene\` extension. Check both patterns when searching for scene files.
421527
421677
  - \`Assets/Prefabs/*.prefab\` \u2013 key game objects (player, UI manager, etc.).
421528
421678
  - \`Assets/Scripts/**/*.cs\` \u2013 main scripts (e.g., \`GameManager.cs\`, \`PlayerController.cs\`).
421529
421679
  - Any \`*.asmdef\` files \u2013 code\u2011assembly boundaries.
@@ -421553,8 +421703,8 @@ Analyze the current directory and generate a comprehensive **${contextFileName}*
421553
421703
  - Render pipeline (URP/HDRP/Legacy) and any major packages (Cinemachine, Input System, DOTS, etc.).
421554
421704
 
421555
421705
  - **Key Scenes & Entry Point**
421556
- - List the main scenes (\`*.unity\`).
421557
- - Indicate which scene is loaded first (often \`Boot.unity\` or \`Main.unity\`).
421706
+ - List the main scenes (\`*.unity\` for Unity engine or \`*.scene\` for Tuanjie engine). When searching for scene files, check both patterns: \`*.unity\` and \`*.scene\`.
421707
+ - Indicate which scene is loaded first (often \`Boot.unity\`/\`Boot.scene\` or \`Main.unity\`/\`Main.scene\`).
421558
421708
 
421559
421709
  - **Core Assets**
421560
421710
  - Important prefabs (Player, UI Canvas, GameManager, etc.).
@@ -425655,6 +425805,7 @@ init_esbuild_polyfill();
425655
425805
  var UNITY_EXTENSIONS = [
425656
425806
  ".cs",
425657
425807
  ".unity",
425808
+ ".scene",
425658
425809
  ".prefab",
425659
425810
  ".mat",
425660
425811
  ".asset",
@@ -426525,7 +426676,7 @@ ManageEditorTool.Name = "unity_editor";
426525
426676
  init_esbuild_polyfill();
426526
426677
  var ManageGameObjectTool = class _ManageGameObjectTool extends UnityToolBase {
426527
426678
  constructor() {
426528
- super(_ManageGameObjectTool.Name, "Unity GameObject Manager", "Manages Unity GameObjects with comprehensive operations including create, modify, delete, find, and component management. Supports primitives, prefabs, transforms, and advanced component manipulation with property setting and reference assignments.", {
426679
+ super(_ManageGameObjectTool.Name, "Unity GameObject Manager", "Manages Unity GameObjects with comprehensive operations including create, modify, delete, find, list_children, and component management. Supports primitives, prefabs, transforms, and advanced component manipulation with property setting and reference assignments.", {
426529
426680
  type: "object",
426530
426681
  properties: {
426531
426682
  action: {
@@ -426539,13 +426690,14 @@ var ManageGameObjectTool = class _ManageGameObjectTool extends UnityToolBase {
426539
426690
  "modify",
426540
426691
  "delete",
426541
426692
  "find",
426693
+ "list_children",
426542
426694
  "select",
426543
426695
  "add_component",
426544
426696
  "remove_component",
426545
426697
  "set_component_property",
426546
426698
  "get_components"
426547
426699
  ],
426548
- description: 'Operation to perform. Ensure operations are idempotent (safe to call multiple times). Use "select" to set Unity Editor selection.'
426700
+ description: 'Operation to perform. Ensure operations are idempotent (safe to call multiple times). Use "list_children" to retrieve a depth-limited *tree-structured* children hierarchy for a specific GameObject (large results can be written to a JSON file under Assets/). Use "select" to set Unity Editor selection. For full-scene hierarchy roots, prefer unity_scene action="get_hierarchy".'
426549
426701
  },
426550
426702
  component_type: {
426551
426703
  type: "string",
@@ -426569,7 +426721,7 @@ var ManageGameObjectTool = class _ManageGameObjectTool extends UnityToolBase {
426569
426721
  },
426570
426722
  target: {
426571
426723
  oneOf: [{ type: "string" }, { type: "number" }],
426572
- description: "GameObject identifier (name or path string) for modify/delete/component actions"
426724
+ description: "GameObject identifier (name/path/instance ID) for modify/delete/component actions. For list_children, this is the root GameObject whose subtree will be returned."
426573
426725
  },
426574
426726
  searchMethod: {
426575
426727
  type: "string",
@@ -426675,7 +426827,34 @@ var ManageGameObjectTool = class _ManageGameObjectTool extends UnityToolBase {
426675
426827
  searchInactive: {
426676
426828
  type: "boolean",
426677
426829
  description: "Include inactive GameObjects in search",
426678
- default: false
426830
+ default: true
426831
+ },
426832
+ depth: {
426833
+ type: "integer",
426834
+ description: 'For list_children action: how many levels below target to traverse (1 = direct children). The returned result keeps a tree structure (nested "children") up to this depth.',
426835
+ minimum: 1,
426836
+ default: 1
426837
+ },
426838
+ includeInactive: {
426839
+ type: "boolean",
426840
+ description: "For list_children action: whether to include inactive objects in the returned results (alias of searchInactive).",
426841
+ default: true
426842
+ },
426843
+ resultMode: {
426844
+ type: "string",
426845
+ enum: ["auto", "inline", "file"],
426846
+ description: "For list_children action: 'auto' returns inline unless the result exceeds maxInlineItems, then writes the full tree JSON to a file and returns its path; 'inline' errors if too large (no truncation); 'file' always writes JSON to disk and returns its path.",
426847
+ default: "auto"
426848
+ },
426849
+ maxInlineItems: {
426850
+ type: "integer",
426851
+ description: "For list_children action: maximum number of descendant nodes (within depth) allowed for inline output before switching to file (or erroring in inline mode).",
426852
+ minimum: 1,
426853
+ default: 200
426854
+ },
426855
+ outputPath: {
426856
+ type: "string",
426857
+ description: "For list_children action with resultMode='file' (or auto overflow): output JSON path under Assets/. The tool returns this path so callers can read the full, untruncated result."
426679
426858
  },
426680
426859
  selectAll: {
426681
426860
  type: "boolean",
@@ -426718,6 +426897,7 @@ var ManageGameObjectTool = class _ManageGameObjectTool extends UnityToolBase {
426718
426897
  "modify",
426719
426898
  "delete",
426720
426899
  "find",
426900
+ "list_children",
426721
426901
  "select",
426722
426902
  "add_component",
426723
426903
  "remove_component",
@@ -426832,6 +427012,46 @@ var ManageGameObjectTool = class _ManageGameObjectTool extends UnityToolBase {
426832
427012
  return "target or searchTerm is required for find";
426833
427013
  }
426834
427014
  break;
427015
+ case "list_children":
427016
+ if (!params.target) {
427017
+ return "target is required for list_children action";
427018
+ }
427019
+ if (params.includeInactive !== void 0 && params.searchInactive === void 0) {
427020
+ params.searchInactive = params.includeInactive;
427021
+ }
427022
+ if (params.depth !== void 0) {
427023
+ try {
427024
+ const parsedDepth = UnityToolBase.parseInteger(params.depth, "depth");
427025
+ if (parsedDepth !== void 0) {
427026
+ if (parsedDepth < 1) {
427027
+ return "depth must be >= 1";
427028
+ }
427029
+ params.depth = parsedDepth;
427030
+ }
427031
+ } catch (error41) {
427032
+ return error41 instanceof Error ? error41.message : "Invalid depth parameter";
427033
+ }
427034
+ }
427035
+ if (params.maxInlineItems !== void 0) {
427036
+ try {
427037
+ const parsedMaxInline = UnityToolBase.parseInteger(params.maxInlineItems, "maxInlineItems");
427038
+ if (parsedMaxInline !== void 0) {
427039
+ if (parsedMaxInline < 1) {
427040
+ return "maxInlineItems must be >= 1";
427041
+ }
427042
+ params.maxInlineItems = parsedMaxInline;
427043
+ }
427044
+ } catch (error41) {
427045
+ return error41 instanceof Error ? error41.message : "Invalid maxInlineItems parameter";
427046
+ }
427047
+ }
427048
+ if (params.outputPath && !params.outputPath.startsWith("Assets/")) {
427049
+ return "outputPath must start with Assets/";
427050
+ }
427051
+ if (params.resultMode && !["auto", "inline", "file"].includes(params.resultMode)) {
427052
+ return `Invalid resultMode: ${params.resultMode}. Valid values are: auto, inline, file`;
427053
+ }
427054
+ break;
426835
427055
  case "select":
426836
427056
  break;
426837
427057
  default:
@@ -427016,8 +427236,12 @@ ManagePackageTool.Name = "unity_package";
427016
427236
  // packages/codely-unity-client/dist/src/tools/unity-tools/manage-scene/ManageSceneTool.js
427017
427237
  init_esbuild_polyfill();
427018
427238
  var ManageSceneTool = class _ManageSceneTool extends UnityToolBase {
427239
+ static hasAllowedSceneExtension(path96) {
427240
+ const lower2 = path96.toLowerCase();
427241
+ return _ManageSceneTool.AllowedSceneExtensions.some((ext3) => lower2.endsWith(ext3));
427242
+ }
427019
427243
  constructor() {
427020
- super(_ManageSceneTool.Name, "Unity Scene Manager", "Manages Unity scenes: create, load, save, get hierarchy, get active scene info, and build settings. Provides comprehensive scene operations for Unity projects.", {
427244
+ super(_ManageSceneTool.Name, "Unity Scene Manager", "Manages Unity scenes: create, load, save, get hierarchy, get active scene info, and build settings. IMPORTANT: Scene files use .unity extension for Unity engine and .scene extension for Tuanjie engine (the tool validates/accepts both). Note: for very large scenes, get_hierarchy may return only scene root objects (roots-only) with hints to drill down using unity_gameobject list_children.", {
427021
427245
  type: "object",
427022
427246
  properties: {
427023
427247
  action: {
@@ -427032,15 +427256,15 @@ var ManageSceneTool = class _ManageSceneTool extends UnityToolBase {
427032
427256
  "get_active",
427033
427257
  "get_build_settings"
427034
427258
  ],
427035
- description: "Scene operation to perform. ensure_scene_open requires full scene path ending with .unity"
427259
+ description: "Scene operation to perform. ensure_scene_open requires full scene path ending with .unity or .scene. get_hierarchy may return roots-only for very large scenes."
427036
427260
  },
427037
427261
  name: {
427038
427262
  type: "string",
427039
- description: "Scene name (without .unity extension). Used for create, load, save actions."
427263
+ description: "Scene name (without .unity/.scene extension). Used for create, load, save actions."
427040
427264
  },
427041
427265
  path: {
427042
427266
  type: "string",
427043
- description: 'For ensure_scene_open: full scene path ending with .unity (e.g., "Assets/Scenes/MyScene.unity"). For create/load/save: directory path (default: "Assets/Scenes/").'
427267
+ description: 'For ensure_scene_open: full scene path ending with .unity or .scene (e.g., "Assets/Scenes/MyScene.unity"). For create/load/save: directory path (default: "Assets/Scenes/").'
427044
427268
  },
427045
427269
  build_index: {
427046
427270
  type: "integer",
@@ -427079,8 +427303,8 @@ var ManageSceneTool = class _ManageSceneTool extends UnityToolBase {
427079
427303
  if (!params.path.startsWith("Assets/")) {
427080
427304
  return 'path must start with "Assets/"';
427081
427305
  }
427082
- if (!params.path.endsWith(".unity")) {
427083
- return 'path must end with ".unity" for scene files';
427306
+ if (!_ManageSceneTool.hasAllowedSceneExtension(params.path)) {
427307
+ return 'path must end with ".unity" or ".scene" for scene files';
427084
427308
  }
427085
427309
  break;
427086
427310
  case "ensure_scene_saved":
@@ -427089,8 +427313,8 @@ var ManageSceneTool = class _ManageSceneTool extends UnityToolBase {
427089
427313
  if (!params.name) {
427090
427314
  return "name is required for create action";
427091
427315
  }
427092
- if (params.name.toLowerCase().endsWith(".unity")) {
427093
- return "name should not include .unity extension";
427316
+ if (_ManageSceneTool.hasAllowedSceneExtension(params.name)) {
427317
+ return "name should not include .unity/.scene extension";
427094
427318
  }
427095
427319
  break;
427096
427320
  case "load":
@@ -427099,8 +427323,8 @@ var ManageSceneTool = class _ManageSceneTool extends UnityToolBase {
427099
427323
  }
427100
427324
  break;
427101
427325
  case "save":
427102
- if (params.name && params.name.toLowerCase().endsWith(".unity")) {
427103
- return "name should not include .unity extension";
427326
+ if (params.name && _ManageSceneTool.hasAllowedSceneExtension(params.name)) {
427327
+ return "name should not include .unity/.scene extension";
427104
427328
  }
427105
427329
  break;
427106
427330
  case "get_hierarchy":
@@ -427130,6 +427354,7 @@ var ManageSceneTool = class _ManageSceneTool extends UnityToolBase {
427130
427354
  }
427131
427355
  };
427132
427356
  ManageSceneTool.Name = "unity_scene";
427357
+ ManageSceneTool.AllowedSceneExtensions = [".unity", ".scene"];
427133
427358
 
427134
427359
  // packages/codely-unity-client/dist/src/tools/unity-tools/manage-screenshot/ScreenShotTool.js
427135
427360
  init_esbuild_polyfill();
@@ -428093,7 +428318,7 @@ var UnityToolsManager = class {
428093
428318
  Available Unity Builtin Tools (13 total):
428094
428319
 
428095
428320
  - \`unity_editor\`: Controls editor state, compilation, long-task waiting, and queries Unity project info (use get_current_state for full state, and start_compilation_pipeline + wait_for_compile for script edits)
428096
- - \`unity_scene\`: Creates, loads, saves scenes with ensure operations for idempotent scene workflows
428321
+ - \`unity_scene\`: Creates, loads, saves scenes with ensure operations for idempotent scene workflows. **IMPORTANT**: Scene files use \`.unity\` extension for Unity engine and \`.scene\` extension for Tuanjie engine. When searching for scene files (e.g., using FindFiles), always check both patterns: \`*.unity\` and \`*.scene\`.
428097
428322
  - \`unity_gameobject\`: Creates, modifies, deletes GameObjects with ensure operations for components/materials
428098
428323
  - \`unity_script\`: Creates, edits, and manages C# script files (used together with compile + console check)
428099
428324
  - \`unity_asset\`: Creates, imports, and manages prefabs and assets with meta safety operations
@@ -461299,10 +461524,16 @@ function spawnAcpAgent(args) {
461299
461524
  var webUiServeCommand = {
461300
461525
  command: "web-ui",
461301
461526
  describe: "Start Codely Web UI (localhost) by proxying ACP over WebSocket to a spawned agent process",
461302
- builder: (yargs) => yargs.usage("Usage: codely serve web-ui [--port <port>] [options]").option("port", {
461527
+ builder: (yargs) => yargs.usage(
461528
+ "Usage: codely serve web-ui [--port <port>] [--host <host>] [options]"
461529
+ ).option("port", {
461303
461530
  type: "number",
461304
461531
  default: 3939,
461305
461532
  describe: "HTTP server port for Web UI (default: 3939)"
461533
+ }).option("host", {
461534
+ type: "string",
461535
+ default: "127.0.0.1",
461536
+ describe: "HTTP server host for Web UI (default: 127.0.0.1). Use 0.0.0.0 to accept connections from any network interface."
461306
461537
  }).option("open", {
461307
461538
  type: "boolean",
461308
461539
  default: false,
@@ -461314,11 +461545,16 @@ var webUiServeCommand = {
461314
461545
  describe: "Enable debug logging"
461315
461546
  }).example([
461316
461547
  ["$0 serve web-ui", "Start Web UI on http://127.0.0.1:3939"],
461317
- ["$0 serve web-ui --port 3000", "Start Web UI on port 3000"]
461548
+ ["$0 serve web-ui --port 3000", "Start Web UI on port 3000"],
461549
+ [
461550
+ "$0 serve web-ui --host 0.0.0.0",
461551
+ "Start Web UI accessible from any network interface"
461552
+ ]
461318
461553
  ]).version(false),
461319
461554
  handler: async (argv) => {
461320
461555
  const args = argv;
461321
461556
  const port = args.port ?? 3939;
461557
+ const host = args.host ?? "127.0.0.1";
461322
461558
  const debug3 = Boolean(args.debug);
461323
461559
  const cwd3 = process.cwd();
461324
461560
  const { staticDir, indexPath } = resolveStaticDir();
@@ -461422,11 +461658,11 @@ If you're running an installed bundle, your package may be missing bundled Web U
461422
461658
  });
461423
461659
  await new Promise((resolve26, reject) => {
461424
461660
  server.once("error", reject);
461425
- server.listen(port, "127.0.0.1", () => resolve26());
461661
+ server.listen(port, host, () => resolve26());
461426
461662
  });
461427
- const url4 = `http://127.0.0.1:${port}`;
461663
+ const url4 = `http://${host}:${port}`;
461428
461664
  console.error(`\u2705 Web UI listening on ${url4}`);
461429
- console.error(` WS endpoint: ws://127.0.0.1:${port}/ws`);
461665
+ console.error(` WS endpoint: ws://${host}:${port}/ws`);
461430
461666
  if (args.open) {
461431
461667
  try {
461432
461668
  await open_default(url4, { wait: false });
@@ -461706,6 +461942,13 @@ async function parseArguments() {
461706
461942
  type: "boolean",
461707
461943
  description: "Enable experimental Skills feature",
461708
461944
  default: false
461945
+ }).option("skills", {
461946
+ type: "array",
461947
+ string: true,
461948
+ description: "Limit enabled skills to the provided list (requires --experimental-skills). Supports comma-separated values or repeated --skills flags.",
461949
+ coerce: (skills) => skills.flatMap(
461950
+ (value) => String(value ?? "").split(",").map((s3) => s3.trim()).filter(Boolean)
461951
+ )
461709
461952
  }).option("allowed-mcp-server-names", {
461710
461953
  type: "array",
461711
461954
  string: true,
@@ -461742,8 +461985,8 @@ async function parseArguments() {
461742
461985
  }).option("reasoning_effort", {
461743
461986
  type: "string",
461744
461987
  alias: ["reasoningEffort"],
461745
- choices: ["minimal", "low", "medium", "high"],
461746
- description: "OpenAI reasoning_effort for reasoning/compatible models (minimal|low|medium|high)"
461988
+ choices: ["minimal", "low", "medium", "high", "xhigh"],
461989
+ description: "OpenAI reasoning_effort for reasoning/compatible models (minimal|low|medium|high|xhigh)"
461747
461990
  }).option("enable_thinking", {
461748
461991
  type: "boolean",
461749
461992
  alias: ["enableThinking"],
@@ -461811,6 +462054,11 @@ async function parseArguments() {
461811
462054
  "Cannot use both --example-prompt and --prompt-interactive (-i) together"
461812
462055
  );
461813
462056
  }
462057
+ if (Array.isArray(argv.skills) && argv.skills.filter(Boolean).length > 0 && !argv.experimentalSkills) {
462058
+ throw new Error(
462059
+ "Cannot use --skills without --experimental-skills. Enable skills first with --experimental-skills."
462060
+ );
462061
+ }
461814
462062
  return true;
461815
462063
  })
461816
462064
  ).command(mcpCommand2).command(extensionsCommand2).command(serveCommand).version(await getCliVersion()).alias("v", "version").help().alias("h", "help").strict().demandCommand(0, 0);
@@ -461887,10 +462135,14 @@ async function loadCliConfig(settings, extensions, sessionId2, argv, cwd3 = proc
461887
462135
  (_, i3) => allExtensions[i3].isActive
461888
462136
  );
461889
462137
  if (argv.openaiApiKey) {
461890
- process33.env.OPENAI_API_KEY = argv.openaiApiKey;
462138
+ if (process33.env.CUSTOM_AUTH && settings.selectedAuthType === AuthType3.USE_OPENAI) {
462139
+ process33.env.OPENAI_API_KEY = argv.openaiApiKey;
462140
+ }
461891
462141
  }
461892
462142
  if (argv.openaiBaseUrl) {
461893
- process33.env.OPENAI_BASE_URL = argv.openaiBaseUrl;
462143
+ if (process33.env.CUSTOM_AUTH && settings.selectedAuthType === AuthType3.USE_OPENAI) {
462144
+ process33.env.OPENAI_BASE_URL = argv.openaiBaseUrl;
462145
+ }
461894
462146
  }
461895
462147
  if (argv.tavilyApiKey) {
461896
462148
  process33.env.TAVILY_API_KEY = argv.tavilyApiKey;
@@ -462112,7 +462364,7 @@ async function loadCliConfig(settings, extensions, sessionId2, argv, cwd3 = proc
462112
462364
  cwd: cwd3,
462113
462365
  fileDiscoveryService: fileService,
462114
462366
  bugCommand: settings.bugCommand,
462115
- model: argv.model || settings.model || process33.env.OPENAI_MODEL || DEFAULT_CODELY_MODEL,
462367
+ model: argv.model || settings.model || (process33.env.CUSTOM_AUTH && settings.selectedAuthType === AuthType3.USE_OPENAI ? process33.env.OPENAI_MODEL : void 0) || DEFAULT_CODELY_MODEL,
462116
462368
  flashModel: argv.flash || settings.flashModel,
462117
462369
  multimodalModel: argv.multimodal || settings.multimodalModel,
462118
462370
  extensionContextFilePaths,
@@ -462120,6 +462372,7 @@ async function loadCliConfig(settings, extensions, sessionId2, argv, cwd3 = proc
462120
462372
  sessionTokenLimit: settings.sessionTokenLimit ?? -1,
462121
462373
  experimentalZedIntegration: argv.experimentalAcp || false,
462122
462374
  experimentalSkills: argv.experimentalSkills || false,
462375
+ enabledSkills: argv.experimentalSkills && argv.skills && argv.skills.length > 0 ? argv.skills : void 0,
462123
462376
  disabledSkills: settings.skills?.disabled ?? [],
462124
462377
  listExtensions: argv.listExtensions || false,
462125
462378
  extensions: allExtensions,
@@ -466374,8 +466627,11 @@ var AutoAcceptIndicator = ({
466374
466627
  init_esbuild_polyfill();
466375
466628
  var import_jsx_runtime10 = __toESM(require_jsx_runtime(), 1);
466376
466629
  var ShellModeIndicator = () => /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(Box_default, { children: /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(Text, { color: Colors.AccentYellow, children: [
466377
- "shell mode enabled",
466378
- /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(Text, { color: Colors.Gray, children: " (esc to disable)" })
466630
+ "SHELL MODE: type a command and press Enter to run",
466631
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(Text, { color: Colors.Gray, children: [
466632
+ " ",
466633
+ "(Esc to exit; press ! on empty input to toggle)"
466634
+ ] })
466379
466635
  ] }) });
466380
466636
 
466381
466637
  // packages/cli/src/ui/components/InputPrompt.tsx
@@ -487178,6 +487434,15 @@ var EMPTY_LINE_HEIGHT = 1;
487178
487434
  var CODE_BLOCK_PREFIX_PADDING = 1;
487179
487435
  var LIST_ITEM_PREFIX_PADDING = 1;
487180
487436
  var LIST_ITEM_TEXT_FLEX_GROW = 1;
487437
+ var HEADER_REGEX = /^ *(#{1,4}) +(.*)/;
487438
+ var CODE_FENCE_REGEX = /^ *(`{3,}|~{3,}) *(\w*?) *$/;
487439
+ var UL_ITEM_REGEX = /^([ \t]*)([-*+]) +(.*)/;
487440
+ var OL_ITEM_REGEX = /^([ \t]*)(\d+)\. +(.*)/;
487441
+ var HR_REGEX = /^ *([-*_] *){3,} *$/;
487442
+ var TABLE_ROW_REGEX = /^\s*\|(.+)\|\s*$/;
487443
+ var TABLE_SEPARATOR_REGEX = /^\s*\|?\s*(:?-+:?)\s*(\|\s*(:?-+:?)\s*)+\|?\s*$/;
487444
+ var THINK_START_REGEX = /^__THINK_START__$/;
487445
+ var THINK_END_REGEX = /^__THINK_END__$/;
487181
487446
  function processThinkTags(text) {
487182
487447
  if (!text) return text;
487183
487448
  const firstNonWhitespaceIndex = text.search(/\S/);
@@ -487222,257 +487487,253 @@ var MarkdownDisplayInternal = ({
487222
487487
  terminalWidth,
487223
487488
  enableThinkTags = true
487224
487489
  }) => {
487225
- if (!text) return /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(import_jsx_runtime35.Fragment, {});
487226
- const processedText = enableThinkTags ? processThinkTags(text) : text.replace(/\n\n+/g, "\n\n");
487227
- const lines = processedText.split("\n");
487228
- const headerRegex = /^ *(#{1,4}) +(.*)/;
487229
- const codeFenceRegex = /^ *(`{3,}|~{3,}) *(\w*?) *$/;
487230
- const ulItemRegex = /^([ \t]*)([-*+]) +(.*)/;
487231
- const olItemRegex = /^([ \t]*)(\d+)\. +(.*)/;
487232
- const hrRegex = /^ *([-*_] *){3,} *$/;
487233
- const tableRowRegex = /^\s*\|(.+)\|\s*$/;
487234
- const tableSeparatorRegex = /^\s*\|?\s*(:?-+:?)\s*(\|\s*(:?-+:?)\s*)+\|?\s*$/;
487235
- const thinkStartRegex = /^__THINK_START__$/;
487236
- const thinkEndRegex = /^__THINK_END__$/;
487237
- const contentBlocks = [];
487238
- let inCodeBlock = false;
487239
- let lastLineEmpty = true;
487240
- let codeBlockContent = [];
487241
- let codeBlockLang = null;
487242
- let codeBlockFence = "";
487243
- let inTable = false;
487244
- let tableRows = [];
487245
- let tableHeaders = [];
487246
- let inThinkBlock = false;
487247
- let thinkContent = [];
487248
- function addContentBlock(block2) {
487249
- if (block2) {
487250
- contentBlocks.push(block2);
487251
- lastLineEmpty = false;
487252
- }
487253
- }
487254
- lines.forEach((line, index) => {
487255
- const key = `line-${index}`;
487256
- if (inCodeBlock) {
487257
- const fenceMatch = line.match(codeFenceRegex);
487258
- if (fenceMatch && fenceMatch[1].startsWith(codeBlockFence[0]) && fenceMatch[1].length >= codeBlockFence.length) {
487490
+ const processedText = import_react76.default.useMemo(() => {
487491
+ if (!text) return "";
487492
+ return enableThinkTags ? processThinkTags(text) : text.replace(/\n\n+/g, "\n\n");
487493
+ }, [text, enableThinkTags]);
487494
+ const lines = import_react76.default.useMemo(() => processedText.split("\n"), [processedText]);
487495
+ const contentBlocks = import_react76.default.useMemo(() => {
487496
+ const blocks = [];
487497
+ let inCodeBlock = false;
487498
+ let lastLineEmpty = true;
487499
+ let codeBlockContent = [];
487500
+ let codeBlockLang = null;
487501
+ let codeBlockFence = "";
487502
+ let inTable = false;
487503
+ let tableRows = [];
487504
+ let tableHeaders = [];
487505
+ let inThinkBlock = false;
487506
+ let thinkContent = [];
487507
+ function addContentBlock(block2) {
487508
+ if (block2) {
487509
+ blocks.push(block2);
487510
+ lastLineEmpty = false;
487511
+ }
487512
+ }
487513
+ lines.forEach((line, index) => {
487514
+ const key = `line-${index}`;
487515
+ if (inCodeBlock) {
487516
+ const fenceMatch = line.match(CODE_FENCE_REGEX);
487517
+ if (fenceMatch && fenceMatch[1].startsWith(codeBlockFence[0]) && fenceMatch[1].length >= codeBlockFence.length) {
487518
+ addContentBlock(
487519
+ /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
487520
+ RenderCodeBlock,
487521
+ {
487522
+ content: codeBlockContent,
487523
+ lang: codeBlockLang,
487524
+ isPending,
487525
+ availableTerminalHeight,
487526
+ terminalWidth
487527
+ },
487528
+ key
487529
+ )
487530
+ );
487531
+ inCodeBlock = false;
487532
+ codeBlockContent = [];
487533
+ codeBlockLang = null;
487534
+ codeBlockFence = "";
487535
+ } else {
487536
+ codeBlockContent.push(line);
487537
+ }
487538
+ return;
487539
+ }
487540
+ if (inThinkBlock) {
487541
+ if (line.match(THINK_END_REGEX)) {
487542
+ addContentBlock(
487543
+ /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
487544
+ RenderThinkBlock,
487545
+ {
487546
+ content: thinkContent,
487547
+ isPending,
487548
+ isStreaming: false,
487549
+ terminalWidth
487550
+ },
487551
+ key
487552
+ )
487553
+ );
487554
+ inThinkBlock = false;
487555
+ thinkContent = [];
487556
+ } else if (!line.match(THINK_START_REGEX)) {
487557
+ thinkContent.push(line);
487558
+ }
487559
+ return;
487560
+ }
487561
+ const codeFenceMatch = line.match(CODE_FENCE_REGEX);
487562
+ const headerMatch = line.match(HEADER_REGEX);
487563
+ const ulMatch = line.match(UL_ITEM_REGEX);
487564
+ const olMatch = line.match(OL_ITEM_REGEX);
487565
+ const hrMatch = line.match(HR_REGEX);
487566
+ const tableRowMatch = line.match(TABLE_ROW_REGEX);
487567
+ const tableSeparatorMatch = line.match(TABLE_SEPARATOR_REGEX);
487568
+ const thinkStartMatch = line.match(THINK_START_REGEX);
487569
+ const thinkEndMatch = line.match(THINK_END_REGEX);
487570
+ if (thinkStartMatch) {
487571
+ inThinkBlock = true;
487572
+ } else if (thinkEndMatch) {
487573
+ return;
487574
+ } else if (codeFenceMatch) {
487575
+ inCodeBlock = true;
487576
+ codeBlockFence = codeFenceMatch[1];
487577
+ codeBlockLang = codeFenceMatch[2] || null;
487578
+ } else if (tableRowMatch && !inTable) {
487579
+ if (index + 1 < lines.length && lines[index + 1].match(TABLE_SEPARATOR_REGEX)) {
487580
+ inTable = true;
487581
+ tableHeaders = tableRowMatch[1].split("|").map((cell) => cell.trim());
487582
+ tableRows = [];
487583
+ } else {
487584
+ addContentBlock(
487585
+ /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(Box_default, { children: /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(Text, { wrap: "wrap", children: /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(RenderInline, { text: line }) }) }, key)
487586
+ );
487587
+ }
487588
+ } else if (inTable && tableSeparatorMatch) {
487589
+ } else if (inTable && tableRowMatch) {
487590
+ const cells = tableRowMatch[1].split("|").map((cell) => cell.trim());
487591
+ while (cells.length < tableHeaders.length) {
487592
+ cells.push("");
487593
+ }
487594
+ if (cells.length > tableHeaders.length) {
487595
+ cells.length = tableHeaders.length;
487596
+ }
487597
+ tableRows.push(cells);
487598
+ } else if (inTable && !tableRowMatch) {
487599
+ if (tableHeaders.length > 0 && tableRows.length > 0) {
487600
+ addContentBlock(
487601
+ /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
487602
+ RenderTable,
487603
+ {
487604
+ headers: tableHeaders,
487605
+ rows: tableRows,
487606
+ terminalWidth
487607
+ },
487608
+ `table-${blocks.length}`
487609
+ )
487610
+ );
487611
+ }
487612
+ inTable = false;
487613
+ tableRows = [];
487614
+ tableHeaders = [];
487615
+ if (line.trim().length > 0) {
487616
+ addContentBlock(
487617
+ /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(Box_default, { children: /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(Text, { wrap: "wrap", children: /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(RenderInline, { text: line }) }) }, key)
487618
+ );
487619
+ }
487620
+ } else if (hrMatch) {
487259
487621
  addContentBlock(
487260
- /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
487261
- RenderCodeBlock,
487262
- {
487263
- content: codeBlockContent,
487264
- lang: codeBlockLang,
487265
- isPending,
487266
- availableTerminalHeight,
487267
- terminalWidth
487268
- },
487269
- key
487270
- )
487622
+ /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(Box_default, { children: /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(Text, { dimColor: true, children: "---" }) }, key)
487271
487623
  );
487272
- inCodeBlock = false;
487273
- codeBlockContent = [];
487274
- codeBlockLang = null;
487275
- codeBlockFence = "";
487276
- } else {
487277
- codeBlockContent.push(line);
487278
- }
487279
- return;
487280
- }
487281
- if (inThinkBlock) {
487282
- if (line.match(thinkEndRegex)) {
487624
+ } else if (headerMatch) {
487625
+ const level = headerMatch[1].length;
487626
+ const headerText = headerMatch[2];
487627
+ let headerNode = null;
487628
+ switch (level) {
487629
+ case 1:
487630
+ headerNode = /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(Text, { bold: true, color: Colors.AccentCyan, children: /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(RenderInline, { text: headerText }) });
487631
+ break;
487632
+ case 2:
487633
+ headerNode = /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(Text, { bold: true, color: Colors.AccentBlue, children: /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(RenderInline, { text: headerText }) });
487634
+ break;
487635
+ case 3:
487636
+ headerNode = /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(Text, { bold: true, children: /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(RenderInline, { text: headerText }) });
487637
+ break;
487638
+ case 4:
487639
+ headerNode = /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(Text, { italic: true, color: Colors.Gray, children: /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(RenderInline, { text: headerText }) });
487640
+ break;
487641
+ default:
487642
+ headerNode = /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(Text, { children: /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(RenderInline, { text: headerText }) });
487643
+ break;
487644
+ }
487645
+ if (headerNode) addContentBlock(/* @__PURE__ */ (0, import_jsx_runtime35.jsx)(Box_default, { children: headerNode }, key));
487646
+ } else if (ulMatch) {
487647
+ const leadingWhitespace = ulMatch[1];
487648
+ const marker = ulMatch[2];
487649
+ const itemText = ulMatch[3];
487283
487650
  addContentBlock(
487284
487651
  /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
487285
- RenderThinkBlock,
487652
+ RenderListItem,
487286
487653
  {
487287
- content: thinkContent,
487288
- isPending,
487289
- isStreaming: false,
487290
- terminalWidth
487654
+ itemText,
487655
+ type: "ul",
487656
+ marker,
487657
+ leadingWhitespace
487291
487658
  },
487292
487659
  key
487293
487660
  )
487294
487661
  );
487295
- inThinkBlock = false;
487296
- thinkContent = [];
487297
- } else if (!line.match(thinkStartRegex)) {
487298
- thinkContent.push(line);
487299
- }
487300
- return;
487301
- }
487302
- const codeFenceMatch = line.match(codeFenceRegex);
487303
- const headerMatch = line.match(headerRegex);
487304
- const ulMatch = line.match(ulItemRegex);
487305
- const olMatch = line.match(olItemRegex);
487306
- const hrMatch = line.match(hrRegex);
487307
- const tableRowMatch = line.match(tableRowRegex);
487308
- const tableSeparatorMatch = line.match(tableSeparatorRegex);
487309
- const thinkStartMatch = line.match(thinkStartRegex);
487310
- const thinkEndMatch = line.match(thinkEndRegex);
487311
- if (thinkStartMatch) {
487312
- inThinkBlock = true;
487313
- } else if (thinkEndMatch) {
487314
- return;
487315
- } else if (codeFenceMatch) {
487316
- inCodeBlock = true;
487317
- codeBlockFence = codeFenceMatch[1];
487318
- codeBlockLang = codeFenceMatch[2] || null;
487319
- } else if (tableRowMatch && !inTable) {
487320
- if (index + 1 < lines.length && lines[index + 1].match(tableSeparatorRegex)) {
487321
- inTable = true;
487322
- tableHeaders = tableRowMatch[1].split("|").map((cell) => cell.trim());
487323
- tableRows = [];
487324
- } else {
487325
- addContentBlock(
487326
- /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(Box_default, { children: /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(Text, { wrap: "wrap", children: /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(RenderInline, { text: line }) }) }, key)
487327
- );
487328
- }
487329
- } else if (inTable && tableSeparatorMatch) {
487330
- } else if (inTable && tableRowMatch) {
487331
- const cells = tableRowMatch[1].split("|").map((cell) => cell.trim());
487332
- while (cells.length < tableHeaders.length) {
487333
- cells.push("");
487334
- }
487335
- if (cells.length > tableHeaders.length) {
487336
- cells.length = tableHeaders.length;
487337
- }
487338
- tableRows.push(cells);
487339
- } else if (inTable && !tableRowMatch) {
487340
- if (tableHeaders.length > 0 && tableRows.length > 0) {
487662
+ } else if (olMatch) {
487663
+ const leadingWhitespace = olMatch[1];
487664
+ const marker = olMatch[2];
487665
+ const itemText = olMatch[3];
487341
487666
  addContentBlock(
487342
487667
  /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
487343
- RenderTable,
487668
+ RenderListItem,
487344
487669
  {
487345
- headers: tableHeaders,
487346
- rows: tableRows,
487347
- terminalWidth
487670
+ itemText,
487671
+ type: "ol",
487672
+ marker,
487673
+ leadingWhitespace
487348
487674
  },
487349
- `table-${contentBlocks.length}`
487675
+ key
487350
487676
  )
487351
487677
  );
487678
+ } else {
487679
+ if (line.trim().length === 0 && !inCodeBlock) {
487680
+ if (!lastLineEmpty) {
487681
+ blocks.push(
487682
+ /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(Box_default, { height: EMPTY_LINE_HEIGHT }, `spacer-${index}`)
487683
+ );
487684
+ lastLineEmpty = true;
487685
+ }
487686
+ } else {
487687
+ addContentBlock(
487688
+ /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(Box_default, { children: /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(Text, { wrap: "wrap", children: /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(RenderInline, { text: line }) }) }, key)
487689
+ );
487690
+ }
487352
487691
  }
487353
- inTable = false;
487354
- tableRows = [];
487355
- tableHeaders = [];
487356
- if (line.trim().length > 0) {
487357
- addContentBlock(
487358
- /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(Box_default, { children: /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(Text, { wrap: "wrap", children: /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(RenderInline, { text: line }) }) }, key)
487359
- );
487360
- }
487361
- } else if (hrMatch) {
487692
+ });
487693
+ if (inCodeBlock) {
487362
487694
  addContentBlock(
487363
- /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(Box_default, { children: /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(Text, { dimColor: true, children: "---" }) }, key)
487695
+ /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
487696
+ RenderCodeBlock,
487697
+ {
487698
+ content: codeBlockContent,
487699
+ lang: codeBlockLang,
487700
+ isPending,
487701
+ availableTerminalHeight,
487702
+ terminalWidth
487703
+ },
487704
+ "line-eof"
487705
+ )
487364
487706
  );
487365
- } else if (headerMatch) {
487366
- const level = headerMatch[1].length;
487367
- const headerText = headerMatch[2];
487368
- let headerNode = null;
487369
- switch (level) {
487370
- case 1:
487371
- headerNode = /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(Text, { bold: true, color: Colors.AccentCyan, children: /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(RenderInline, { text: headerText }) });
487372
- break;
487373
- case 2:
487374
- headerNode = /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(Text, { bold: true, color: Colors.AccentBlue, children: /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(RenderInline, { text: headerText }) });
487375
- break;
487376
- case 3:
487377
- headerNode = /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(Text, { bold: true, children: /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(RenderInline, { text: headerText }) });
487378
- break;
487379
- case 4:
487380
- headerNode = /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(Text, { italic: true, color: Colors.Gray, children: /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(RenderInline, { text: headerText }) });
487381
- break;
487382
- default:
487383
- headerNode = /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(Text, { children: /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(RenderInline, { text: headerText }) });
487384
- break;
487385
- }
487386
- if (headerNode) addContentBlock(/* @__PURE__ */ (0, import_jsx_runtime35.jsx)(Box_default, { children: headerNode }, key));
487387
- } else if (ulMatch) {
487388
- const leadingWhitespace = ulMatch[1];
487389
- const marker = ulMatch[2];
487390
- const itemText = ulMatch[3];
487707
+ }
487708
+ if (inThinkBlock) {
487391
487709
  addContentBlock(
487392
487710
  /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
487393
- RenderListItem,
487711
+ RenderThinkBlock,
487394
487712
  {
487395
- itemText,
487396
- type: "ul",
487397
- marker,
487398
- leadingWhitespace
487713
+ content: thinkContent,
487714
+ isPending,
487715
+ isStreaming: true,
487716
+ terminalWidth
487399
487717
  },
487400
- key
487718
+ "think-eof"
487401
487719
  )
487402
487720
  );
487403
- } else if (olMatch) {
487404
- const leadingWhitespace = olMatch[1];
487405
- const marker = olMatch[2];
487406
- const itemText = olMatch[3];
487721
+ }
487722
+ if (inTable && tableHeaders.length > 0 && tableRows.length > 0) {
487407
487723
  addContentBlock(
487408
487724
  /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
487409
- RenderListItem,
487725
+ RenderTable,
487410
487726
  {
487411
- itemText,
487412
- type: "ol",
487413
- marker,
487414
- leadingWhitespace
487727
+ headers: tableHeaders,
487728
+ rows: tableRows,
487729
+ terminalWidth
487415
487730
  },
487416
- key
487731
+ `table-${blocks.length}`
487417
487732
  )
487418
487733
  );
487419
- } else {
487420
- if (line.trim().length === 0 && !inCodeBlock) {
487421
- if (!lastLineEmpty) {
487422
- contentBlocks.push(
487423
- /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(Box_default, { height: EMPTY_LINE_HEIGHT }, `spacer-${index}`)
487424
- );
487425
- lastLineEmpty = true;
487426
- }
487427
- } else {
487428
- addContentBlock(
487429
- /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(Box_default, { children: /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(Text, { wrap: "wrap", children: /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(RenderInline, { text: line }) }) }, key)
487430
- );
487431
- }
487432
487734
  }
487433
- });
487434
- if (inCodeBlock) {
487435
- addContentBlock(
487436
- /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
487437
- RenderCodeBlock,
487438
- {
487439
- content: codeBlockContent,
487440
- lang: codeBlockLang,
487441
- isPending,
487442
- availableTerminalHeight,
487443
- terminalWidth
487444
- },
487445
- "line-eof"
487446
- )
487447
- );
487448
- }
487449
- if (inThinkBlock) {
487450
- addContentBlock(
487451
- /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
487452
- RenderThinkBlock,
487453
- {
487454
- content: thinkContent,
487455
- isPending,
487456
- isStreaming: true,
487457
- terminalWidth
487458
- },
487459
- "think-eof"
487460
- )
487461
- );
487462
- }
487463
- if (inTable && tableHeaders.length > 0 && tableRows.length > 0) {
487464
- addContentBlock(
487465
- /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
487466
- RenderTable,
487467
- {
487468
- headers: tableHeaders,
487469
- rows: tableRows,
487470
- terminalWidth
487471
- },
487472
- `table-${contentBlocks.length}`
487473
- )
487474
- );
487475
- }
487735
+ return blocks;
487736
+ }, [lines, isPending, availableTerminalHeight, terminalWidth]);
487476
487737
  return /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(Box_default, { flexDirection: "column", alignItems: "flex-start", children: contentBlocks });
487477
487738
  };
487478
487739
  var RenderCodeBlockInternal = ({
@@ -487565,8 +487826,8 @@ var RenderThinkBlockInternal = ({
487565
487826
  terminalWidth: _terminalWidth
487566
487827
  }) => {
487567
487828
  const MAX_VISIBLE_THINK_LINES = 10;
487829
+ const MAX_THINK_LINES_WHEN_NOT_PENDING = 50;
487568
487830
  const MAX_VISIBLE_THINK_CHARS_WHEN_COLLAPSED = 500;
487569
- const shouldCollapse = isPending && isStreaming;
487570
487831
  const filteredContent = content.filter((line) => line.trim().length > 0);
487571
487832
  if (filteredContent.length === 0) {
487572
487833
  return null;
@@ -487577,6 +487838,8 @@ var RenderThinkBlockInternal = ({
487577
487838
  if (cleanedContent.length === 0) {
487578
487839
  return null;
487579
487840
  }
487841
+ void isStreaming;
487842
+ const shouldCollapse = isPending || cleanedContent.length > MAX_THINK_LINES_WHEN_NOT_PENDING;
487580
487843
  let visibleContent = cleanedContent;
487581
487844
  let hiddenLineCount = 0;
487582
487845
  if (shouldCollapse) {
@@ -487637,7 +487900,23 @@ var RenderThinkBlockInternal = ({
487637
487900
  }
487638
487901
  );
487639
487902
  };
487640
- var RenderThinkBlock = import_react76.default.memo(RenderThinkBlockInternal);
487903
+ var RenderThinkBlock = import_react76.default.memo(
487904
+ RenderThinkBlockInternal,
487905
+ (prevProps, nextProps) => {
487906
+ if (prevProps.isPending !== nextProps.isPending || prevProps.isStreaming !== nextProps.isStreaming || prevProps.terminalWidth !== nextProps.terminalWidth) {
487907
+ return false;
487908
+ }
487909
+ if (prevProps.content.length !== nextProps.content.length) {
487910
+ return false;
487911
+ }
487912
+ for (let i3 = 0; i3 < prevProps.content.length; i3++) {
487913
+ if (prevProps.content[i3] !== nextProps.content[i3]) {
487914
+ return false;
487915
+ }
487916
+ }
487917
+ return true;
487918
+ }
487919
+ );
487641
487920
  var MarkdownDisplay = import_react76.default.memo(MarkdownDisplayInternal);
487642
487921
 
487643
487922
  // packages/cli/src/ui/components/messages/GeminiMessage.tsx
@@ -487699,7 +487978,7 @@ var import_jsx_runtime39 = __toESM(require_jsx_runtime(), 1);
487699
487978
  var STATIC_HEIGHT = 1;
487700
487979
  var RESERVED_LINE_COUNT = 5;
487701
487980
  var STATUS_INDICATOR_WIDTH = 3;
487702
- var MIN_LINES_SHOWN = 2;
487981
+ var MIN_LINES_SHOWN = 4;
487703
487982
  var MAX_TOOL_DESCRIPTION_CHARACTERS = 240;
487704
487983
  var MAXIMUM_RESULT_DISPLAY_CHARACTERS = 1e6;
487705
487984
  function formatToolDescription(description) {
@@ -487724,11 +488003,10 @@ var ToolMessage = ({
487724
488003
  emphasis = "medium",
487725
488004
  renderOutputAsMarkdown = true
487726
488005
  }) => {
487727
- const availableHeight = availableTerminalHeight ? Math.max(
488006
+ const availableHeight = availableTerminalHeight === void 0 ? void 0 : Math.max(
487728
488007
  availableTerminalHeight - STATIC_HEIGHT - RESERVED_LINE_COUNT,
487729
- MIN_LINES_SHOWN + 1
487730
- // enforce minimum lines shown
487731
- ) : void 0;
488008
+ MIN_LINES_SHOWN
488009
+ );
487732
488010
  if (availableHeight) {
487733
488011
  renderOutputAsMarkdown = false;
487734
488012
  }
@@ -487758,7 +488036,7 @@ var ToolMessage = ({
487758
488036
  {
487759
488037
  paddingLeft: STATUS_INDICATOR_WIDTH,
487760
488038
  width: "100%",
487761
- marginTop: 1,
488039
+ marginTop: availableHeight === void 0 ? 1 : 0,
487762
488040
  alignItems: "flex-start",
487763
488041
  children: /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)(Box_default, { flexDirection: "column", alignItems: "flex-start", width: "100%", children: [
487764
488042
  typeof resultDisplay === "string" && renderOutputAsMarkdown && /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(Box_default, { flexDirection: "column", alignItems: "flex-start", children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
@@ -487772,7 +488050,14 @@ var ToolMessage = ({
487772
488050
  }
487773
488051
  ) }),
487774
488052
  typeof resultDisplay === "string" && !renderOutputAsMarkdown && // PowerShell output handling - split by lines for better formatting
487775
- /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(MaxSizedBox, { maxHeight: availableHeight, maxWidth: childWidth, children: resultDisplay.split(/\r?\n/).map((line, index) => /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(Box_default, { alignItems: "flex-start", children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(Text, { wrap: "wrap", children: line || " " }) }, index)) }),
488053
+ /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(MaxSizedBox, { maxHeight: availableHeight, maxWidth: childWidth, children: (() => {
488054
+ const lines = resultDisplay.split(/\r?\n/);
488055
+ while (lines.length > 0 && (lines[lines.length - 1] ?? "").trim() === "") {
488056
+ lines.pop();
488057
+ }
488058
+ const displayLines = lines.length > 0 ? lines : [" "];
488059
+ return displayLines.map((line, index) => /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(Box_default, { alignItems: "flex-start", children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(Text, { wrap: "wrap", children: line || " " }) }, index));
488060
+ })() }),
487776
488061
  typeof resultDisplay !== "string" && /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
487777
488062
  DiffRenderer,
487778
488063
  {
@@ -488052,6 +488337,85 @@ var ToolConfirmationMessage = ({
488052
488337
 
488053
488338
  // packages/cli/src/ui/components/messages/ToolGroupMessage.tsx
488054
488339
  var import_jsx_runtime41 = __toESM(require_jsx_runtime(), 1);
488340
+ var LARGE_TOOL_GROUP_THRESHOLD = 10;
488341
+ var TOOL_GROUP_RENDER_QUEUE_DELAY_MS = 100;
488342
+ var TOOL_GROUP_RENDER_QUEUE_DELAY_MS_LARGE = 1e3;
488343
+ var TOOL_GROUP_TICK_INTERVAL_MS = 100;
488344
+ var TERMINAL_TOOL_STATUSES = /* @__PURE__ */ new Set([
488345
+ "Success" /* Success */,
488346
+ "Error" /* Error */,
488347
+ "Canceled" /* Canceled */
488348
+ ]);
488349
+ var COMPACT_TOOL_OUTPUT_PREVIEW_LINES = 3;
488350
+ var COMPACT_DESCRIPTION_MAX_CHARS = 80;
488351
+ function renderCadenceMs(toolCount) {
488352
+ return toolCount > LARGE_TOOL_GROUP_THRESHOLD ? TOOL_GROUP_RENDER_QUEUE_DELAY_MS_LARGE : TOOL_GROUP_RENDER_QUEUE_DELAY_MS;
488353
+ }
488354
+ function statusSymbol(status) {
488355
+ switch (status) {
488356
+ case "Pending" /* Pending */:
488357
+ return TOOL_STATUS.PENDING;
488358
+ case "Executing" /* Executing */:
488359
+ return TOOL_STATUS.EXECUTING;
488360
+ case "Success" /* Success */:
488361
+ return TOOL_STATUS.SUCCESS;
488362
+ case "Confirming" /* Confirming */:
488363
+ return TOOL_STATUS.CONFIRMING;
488364
+ case "Canceled" /* Canceled */:
488365
+ return TOOL_STATUS.CANCELED;
488366
+ case "Error" /* Error */:
488367
+ return TOOL_STATUS.ERROR;
488368
+ default: {
488369
+ const exhaustiveCheck = status;
488370
+ return String(exhaustiveCheck);
488371
+ }
488372
+ }
488373
+ }
488374
+ function compactDescription(description) {
488375
+ const singleLine = description.replace(/\s+/g, " ").trim();
488376
+ if (singleLine.length <= COMPACT_DESCRIPTION_MAX_CHARS) return singleLine;
488377
+ return `${singleLine.slice(0, COMPACT_DESCRIPTION_MAX_CHARS - 1)}\u2026`;
488378
+ }
488379
+ function toolOutputPreviewLines(tool, maxLines) {
488380
+ const rd = tool.resultDisplay;
488381
+ if (typeof rd === "string") {
488382
+ const lines = rd.split(/\r?\n/);
488383
+ while (lines.length > 0 && (lines[lines.length - 1] ?? "").trim() === "") {
488384
+ lines.pop();
488385
+ }
488386
+ if (lines.length === 0) return [];
488387
+ return lines.slice(Math.max(0, lines.length - maxLines));
488388
+ }
488389
+ if (rd && typeof rd === "object") {
488390
+ const fileName = rd.fileName;
488391
+ if (typeof fileName === "string" && fileName.trim() !== "") {
488392
+ return [`(diff) ${fileName}`];
488393
+ }
488394
+ return ["(diff)"];
488395
+ }
488396
+ return [];
488397
+ }
488398
+ function toolCallsRenderSignature(toolCalls) {
488399
+ let signature = `${toolCalls.length}|`;
488400
+ for (const t3 of toolCalls) {
488401
+ signature += `${t3.callId}:${t3.status}:`;
488402
+ const rd = t3.resultDisplay;
488403
+ if (typeof rd === "string") {
488404
+ signature += `s${rd.length}`;
488405
+ } else if (rd && typeof rd === "object") {
488406
+ const maybeFileDiff = rd.fileDiff;
488407
+ if (typeof maybeFileDiff === "string") {
488408
+ signature += `d${maybeFileDiff.length}`;
488409
+ } else {
488410
+ signature += "o";
488411
+ }
488412
+ } else {
488413
+ signature += "n";
488414
+ }
488415
+ signature += ";";
488416
+ }
488417
+ return signature;
488418
+ }
488055
488419
  var ToolGroupMessage = ({
488056
488420
  toolCalls,
488057
488421
  availableTerminalHeight,
@@ -488059,44 +488423,154 @@ var ToolGroupMessage = ({
488059
488423
  config: config4,
488060
488424
  isFocused = true
488061
488425
  }) => {
488062
- const hasPending = !toolCalls.every(
488426
+ const [renderToolCalls, setRenderToolCalls] = (0, import_react78.useState)(toolCalls);
488427
+ const latestToolCallsRef = (0, import_react78.useRef)(toolCalls);
488428
+ const scheduledFlushRef = (0, import_react78.useRef)(
488429
+ void 0
488430
+ );
488431
+ const lastRenderedSignatureRef = (0, import_react78.useRef)(
488432
+ toolCallsRenderSignature(toolCalls)
488433
+ );
488434
+ const lastRenderedAtRef = (0, import_react78.useRef)(Date.now());
488435
+ const compactDesiredHeightRef = (0, import_react78.useRef)(void 0);
488436
+ const toolCallsSignature = toolCallsRenderSignature(toolCalls);
488437
+ const cadenceMs = renderCadenceMs(toolCalls.length);
488438
+ (0, import_react78.useEffect)(() => {
488439
+ latestToolCallsRef.current = toolCalls;
488440
+ const needsImmediateRender = toolCalls.some(
488441
+ (t3) => t3.status === "Confirming" /* Confirming */
488442
+ );
488443
+ if (needsImmediateRender) {
488444
+ if (scheduledFlushRef.current !== void 0) {
488445
+ clearTimeout(scheduledFlushRef.current);
488446
+ scheduledFlushRef.current = void 0;
488447
+ }
488448
+ lastRenderedSignatureRef.current = toolCallsSignature;
488449
+ lastRenderedAtRef.current = Date.now();
488450
+ setRenderToolCalls([...toolCalls]);
488451
+ return;
488452
+ }
488453
+ if (scheduledFlushRef.current !== void 0) return;
488454
+ scheduledFlushRef.current = setTimeout(() => {
488455
+ scheduledFlushRef.current = void 0;
488456
+ lastRenderedSignatureRef.current = toolCallsRenderSignature(
488457
+ latestToolCallsRef.current
488458
+ );
488459
+ lastRenderedAtRef.current = Date.now();
488460
+ setRenderToolCalls([...latestToolCallsRef.current]);
488461
+ }, cadenceMs);
488462
+ }, [toolCallsSignature, toolCalls, cadenceMs]);
488463
+ (0, import_react78.useEffect)(
488464
+ () => () => {
488465
+ if (scheduledFlushRef.current !== void 0) {
488466
+ clearTimeout(scheduledFlushRef.current);
488467
+ }
488468
+ },
488469
+ []
488470
+ );
488471
+ (0, import_react78.useEffect)(() => {
488472
+ const interval = setInterval(() => {
488473
+ const current = latestToolCallsRef.current;
488474
+ const currentSignature = toolCallsRenderSignature(current);
488475
+ if (currentSignature === lastRenderedSignatureRef.current) return;
488476
+ const now = Date.now();
488477
+ const currentCadence = renderCadenceMs(current.length);
488478
+ if (now - lastRenderedAtRef.current < currentCadence) return;
488479
+ lastRenderedSignatureRef.current = currentSignature;
488480
+ lastRenderedAtRef.current = now;
488481
+ setRenderToolCalls([...current]);
488482
+ const anyConfirming = current.some(
488483
+ (t3) => t3.status === "Confirming" /* Confirming */
488484
+ );
488485
+ const allTerminal = current.every(
488486
+ (t3) => TERMINAL_TOOL_STATUSES.has(t3.status)
488487
+ );
488488
+ if (!anyConfirming && allTerminal) {
488489
+ clearInterval(interval);
488490
+ }
488491
+ }, TOOL_GROUP_TICK_INTERVAL_MS);
488492
+ return () => clearInterval(interval);
488493
+ }, []);
488494
+ const isConfirmingNow = toolCalls.some(
488495
+ (t3) => t3.status === "Confirming" /* Confirming */
488496
+ );
488497
+ const isGroupCompleteNow = toolCalls.every(
488498
+ (t3) => TERMINAL_TOOL_STATUSES.has(t3.status)
488499
+ );
488500
+ const toolCallsForRender = isConfirmingNow || isGroupCompleteNow ? toolCalls : renderToolCalls;
488501
+ const hasPending = !toolCallsForRender.every(
488063
488502
  (t3) => t3.status === "Success" /* Success */
488064
488503
  );
488065
- const isShellCommand = toolCalls.some((t3) => t3.name === SHELL_COMMAND_NAME);
488066
- const borderColor = hasPending || isShellCommand ? Colors.AccentYellow : Colors.Gray;
488067
- const staticHeight = (
488068
- /* border */
488069
- 2 + /* marginBottom */
488070
- 1
488504
+ const isShellCommand = toolCallsForRender.some(
488505
+ (t3) => t3.name === SHELL_COMMAND_NAME
488071
488506
  );
488072
- const innerWidth = terminalWidth - 4;
488507
+ const borderColor = hasPending || isShellCommand ? Colors.AccentYellow : Colors.Gray;
488508
+ const boxChromeHeight = 2;
488073
488509
  const toolAwaitingApproval = (0, import_react78.useMemo)(
488074
- () => toolCalls.find((tc) => tc.status === "Confirming" /* Confirming */),
488075
- [toolCalls]
488510
+ () => toolCallsForRender.find((tc) => tc.status === "Confirming" /* Confirming */),
488511
+ [toolCallsForRender]
488076
488512
  );
488077
- let countToolCallsWithResults = 0;
488078
- for (const tool of toolCalls) {
488079
- if (tool.resultDisplay !== void 0 && tool.resultDisplay !== "") {
488080
- countToolCallsWithResults++;
488081
- }
488082
- }
488083
- const countOneLineToolCalls = toolCalls.length - countToolCallsWithResults;
488084
- const availableTerminalHeightPerToolMessage = availableTerminalHeight ? Math.max(
488513
+ const availableTerminalHeightPerToolMessage = availableTerminalHeight !== void 0 && !isGroupCompleteNow ? Math.max(
488085
488514
  Math.floor(
488086
- (availableTerminalHeight - staticHeight - countOneLineToolCalls) / Math.max(1, countToolCallsWithResults)
488515
+ (availableTerminalHeight - boxChromeHeight) / Math.max(toolCallsForRender.length, 1)
488087
488516
  ),
488088
488517
  1
488089
488518
  ) : void 0;
488519
+ const shouldUseCompactMode = availableTerminalHeight !== void 0 && toolCallsForRender.length > 1 && !isConfirmingNow && !isGroupCompleteNow;
488520
+ const desiredCompactHeight = shouldUseCompactMode && availableTerminalHeight !== void 0 ? (() => {
488521
+ let compactLines = 0;
488522
+ for (const tool of toolCallsForRender) {
488523
+ const preview = toolOutputPreviewLines(
488524
+ tool,
488525
+ COMPACT_TOOL_OUTPUT_PREVIEW_LINES
488526
+ );
488527
+ compactLines += 1 + preview.length;
488528
+ }
488529
+ const candidate = boxChromeHeight + compactLines;
488530
+ if (toolCallsForRender.length > LARGE_TOOL_GROUP_THRESHOLD) {
488531
+ const prev = compactDesiredHeightRef.current;
488532
+ const next = prev === void 0 ? candidate : Math.max(prev, candidate);
488533
+ compactDesiredHeightRef.current = next;
488534
+ return next;
488535
+ }
488536
+ if (compactDesiredHeightRef.current !== void 0) {
488537
+ compactDesiredHeightRef.current = void 0;
488538
+ }
488539
+ return candidate;
488540
+ })() : void 0;
488541
+ if (!shouldUseCompactMode && compactDesiredHeightRef.current !== void 0) {
488542
+ compactDesiredHeightRef.current = void 0;
488543
+ }
488544
+ const isCompactClamped = desiredCompactHeight !== void 0 && availableTerminalHeight !== void 0 && desiredCompactHeight > availableTerminalHeight;
488545
+ const effectiveCompactHeight = desiredCompactHeight !== void 0 && availableTerminalHeight !== void 0 ? Math.min(desiredCompactHeight, availableTerminalHeight) : void 0;
488546
+ const compactMaxHeight = effectiveCompactHeight !== void 0 ? Math.max(effectiveCompactHeight - boxChromeHeight, MINIMUM_MAX_HEIGHT) : void 0;
488547
+ const groupMarginLeft = shouldUseCompactMode && isCompactClamped ? 0 : 1;
488548
+ const innerWidth = terminalWidth - (groupMarginLeft === 1 ? 4 : 3);
488090
488549
  return /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
488091
488550
  Box_default,
488092
488551
  {
488093
488552
  flexDirection: "column",
488094
488553
  borderStyle: "round",
488095
488554
  width: "100%",
488096
- marginLeft: 1,
488555
+ marginLeft: groupMarginLeft,
488097
488556
  borderDimColor: hasPending,
488098
488557
  borderColor,
488099
- children: toolCalls.map((tool) => {
488558
+ height: shouldUseCompactMode ? effectiveCompactHeight : void 0,
488559
+ overflow: shouldUseCompactMode ? "hidden" : void 0,
488560
+ children: shouldUseCompactMode ? /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(MaxSizedBox, { maxHeight: compactMaxHeight, maxWidth: innerWidth, children: toolCallsForRender.flatMap((tool) => {
488561
+ const head = `${statusSymbol(tool.status)} ${tool.name}: ${compactDescription(tool.description)}`;
488562
+ const preview = toolOutputPreviewLines(
488563
+ tool,
488564
+ COMPACT_TOOL_OUTPUT_PREVIEW_LINES
488565
+ );
488566
+ return [
488567
+ /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(Box_default, { alignItems: "flex-start", children: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(Text, { wrap: "truncate", children: head }) }, `${tool.callId}-h`),
488568
+ ...preview.map((line, index) => /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(Box_default, { alignItems: "flex-start", children: /* @__PURE__ */ (0, import_jsx_runtime41.jsxs)(Text, { color: Colors.Gray, wrap: "truncate", children: [
488569
+ " ",
488570
+ line
488571
+ ] }) }, `${tool.callId}-o-${index}`))
488572
+ ];
488573
+ }) }) : toolCallsForRender.map((tool) => {
488100
488574
  const isConfirming = toolAwaitingApproval?.callId === tool.callId;
488101
488575
  return /* @__PURE__ */ (0, import_jsx_runtime41.jsxs)(Box_default, { flexDirection: "column", minHeight: 1, children: [
488102
488576
  /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
@@ -490875,6 +491349,18 @@ var appEvents = new EventEmitter14();
490875
491349
  // packages/cli/src/ui/App.tsx
490876
491350
  var import_jsx_runtime60 = __toESM(require_jsx_runtime(), 1);
490877
491351
  var CTRL_EXIT_PROMPT_DURATION_MS = 1e3;
491352
+ function getInputPlaceholder({
491353
+ shellModeActive,
491354
+ vimModeEnabled
491355
+ }) {
491356
+ if (shellModeActive) {
491357
+ return " Shell command only";
491358
+ }
491359
+ if (vimModeEnabled) {
491360
+ return " Press 'i' for INSERT mode and 'Esc' for NORMAL mode.";
491361
+ }
491362
+ return " Type your message or @path/to/file";
491363
+ }
490878
491364
  var AppWrapper = (props) => /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(SessionStatsProvider, { children: /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(VimModeProvider, { settings: props.settings, children: /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(App2, { ...props }) }) });
490879
491365
  var App2 = ({ config: config4, settings, startupWarnings = [], version: version3 }) => {
490880
491366
  const isFocused = useFocus();
@@ -491529,7 +492015,10 @@ var App2 = ({ config: config4, settings, startupWarnings = [], version: version3
491529
492015
  const mainAreaWidth = Math.floor(terminalWidth * 0.9);
491530
492016
  const debugConsoleMaxHeight = Math.floor(Math.max(terminalHeight * 0.2, 5));
491531
492017
  const staticAreaMaxItemHeight = Math.max(terminalHeight * 4, 100);
491532
- const placeholder = vimModeEnabled ? " Press 'i' for INSERT mode and 'Esc' for NORMAL mode." : " Type your message or @path/to/file";
492018
+ const placeholder = getInputPlaceholder({
492019
+ shellModeActive,
492020
+ vimModeEnabled
492021
+ });
491533
492022
  return /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(StreamingContext.Provider, { value: streamingState, children: /* @__PURE__ */ (0, import_jsx_runtime60.jsxs)(Box_default, { flexDirection: "column", width: "90%", children: [
491534
492023
  /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
491535
492024
  Static,
@@ -492261,18 +492750,20 @@ async function start_sandbox(config4, nodeArgs = [], cliConfig) {
492261
492750
  if (process.env.GOOGLE_API_KEY) {
492262
492751
  args.push("--env", `GOOGLE_API_KEY=${process.env.GOOGLE_API_KEY}`);
492263
492752
  }
492264
- if (process.env.OPENAI_API_KEY) {
492265
- args.push("--env", `OPENAI_API_KEY=${process.env.OPENAI_API_KEY}`);
492753
+ if (process.env.CUSTOM_AUTH) {
492754
+ if (process.env.OPENAI_API_KEY) {
492755
+ args.push("--env", `OPENAI_API_KEY=${process.env.OPENAI_API_KEY}`);
492756
+ }
492757
+ if (process.env.OPENAI_BASE_URL) {
492758
+ args.push("--env", `OPENAI_BASE_URL=${process.env.OPENAI_BASE_URL}`);
492759
+ }
492760
+ if (process.env.OPENAI_MODEL) {
492761
+ args.push("--env", `OPENAI_MODEL=${process.env.OPENAI_MODEL}`);
492762
+ }
492266
492763
  }
492267
492764
  if (process.env.TAVILY_API_KEY) {
492268
492765
  args.push("--env", `TAVILY_API_KEY=${process.env.TAVILY_API_KEY}`);
492269
492766
  }
492270
- if (process.env.OPENAI_BASE_URL) {
492271
- args.push("--env", `OPENAI_BASE_URL=${process.env.OPENAI_BASE_URL}`);
492272
- }
492273
- if (process.env.OPENAI_MODEL) {
492274
- args.push("--env", `OPENAI_MODEL=${process.env.OPENAI_MODEL}`);
492275
- }
492276
492767
  if (process.env.GOOGLE_GENAI_USE_VERTEXAI) {
492277
492768
  args.push(
492278
492769
  "--env",
@@ -506057,6 +506548,195 @@ var RequestError3 = class _RequestError extends Error {
506057
506548
  init_esbuild_polyfill();
506058
506549
  init_strip_ansi();
506059
506550
  init_dist6();
506551
+ function toText(value) {
506552
+ return typeof value === "string" ? value : "";
506553
+ }
506554
+ function toToolStatus(status) {
506555
+ const s3 = typeof status === "string" ? status.toLowerCase() : "";
506556
+ if (s3 === "pending") return "pending";
506557
+ if (s3 === "confirming" || s3 === "executing") return "in_progress";
506558
+ if (s3 === "success") return "completed";
506559
+ if (s3 === "error" || s3 === "canceled" || s3 === "cancelled") return "failed";
506560
+ return "completed";
506561
+ }
506562
+ function toToolKind(kind) {
506563
+ switch (kind) {
506564
+ case "read":
506565
+ case "edit":
506566
+ case "delete":
506567
+ case "move":
506568
+ case "search":
506569
+ case "execute":
506570
+ case "think":
506571
+ case "fetch":
506572
+ case "other":
506573
+ return kind;
506574
+ default:
506575
+ return "other";
506576
+ }
506577
+ }
506578
+ function historyToUiMessages(history) {
506579
+ const out = [];
506580
+ for (const item of history) {
506581
+ switch (item.type) {
506582
+ case "user": {
506583
+ out.push({ role: "user", type: "text", text: toText(item.text) });
506584
+ break;
506585
+ }
506586
+ case "user_shell": {
506587
+ const text = toText(item.text);
506588
+ if (text.trim().length > 0) {
506589
+ out.push({ role: "user", type: "text", text });
506590
+ }
506591
+ break;
506592
+ }
506593
+ case "gemini":
506594
+ case "gemini_content": {
506595
+ out.push({ role: "assistant", type: "text", text: toText(item.text) });
506596
+ break;
506597
+ }
506598
+ case "info": {
506599
+ const text = toText(item.text);
506600
+ if (text.trim().length > 0) {
506601
+ out.push({ role: "assistant", type: "text", text });
506602
+ }
506603
+ break;
506604
+ }
506605
+ case "error": {
506606
+ const text = toText(item.text);
506607
+ if (text.trim().length > 0) {
506608
+ out.push({ role: "assistant", type: "text", text: `Error: ${text}` });
506609
+ }
506610
+ break;
506611
+ }
506612
+ case "tool_group": {
506613
+ const tools = Array.isArray(item.tools) ? item.tools : [];
506614
+ const lines = tools.map((t3) => {
506615
+ const name3 = typeof t3?.name === "string" ? t3.name : "tool";
506616
+ const status = typeof t3?.status === "string" ? t3.status : "";
506617
+ return status ? `- ${name3} (${status})` : `- ${name3}`;
506618
+ }).filter((l2) => l2.trim().length > 0);
506619
+ if (lines.length > 0) {
506620
+ out.push({
506621
+ role: "assistant",
506622
+ type: "text",
506623
+ text: `Tool calls:
506624
+ ${lines.join("\n")}`
506625
+ });
506626
+ }
506627
+ break;
506628
+ }
506629
+ default:
506630
+ break;
506631
+ }
506632
+ }
506633
+ return out.filter((m2) => m2.text.trim().length > 0);
506634
+ }
506635
+ function historyToUiFeedAndTools(history) {
506636
+ const feed = [];
506637
+ const tools = [];
506638
+ for (const item of history) {
506639
+ switch (item.type) {
506640
+ case "user": {
506641
+ const text = toText(item.text);
506642
+ if (text.trim().length > 0) {
506643
+ feed.push({
506644
+ kind: "message",
506645
+ message: { role: "user", type: "text", text }
506646
+ });
506647
+ }
506648
+ break;
506649
+ }
506650
+ case "user_shell": {
506651
+ const text = toText(item.text);
506652
+ if (text.trim().length > 0) {
506653
+ feed.push({
506654
+ kind: "message",
506655
+ message: { role: "user", type: "text", text }
506656
+ });
506657
+ }
506658
+ break;
506659
+ }
506660
+ case "gemini":
506661
+ case "gemini_content": {
506662
+ const text = toText(item.text);
506663
+ if (text.trim().length > 0) {
506664
+ feed.push({
506665
+ kind: "message",
506666
+ message: { role: "assistant", type: "text", text }
506667
+ });
506668
+ }
506669
+ break;
506670
+ }
506671
+ case "info": {
506672
+ const text = toText(item.text);
506673
+ if (text.trim().length > 0) {
506674
+ feed.push({
506675
+ kind: "message",
506676
+ message: { role: "assistant", type: "text", text }
506677
+ });
506678
+ }
506679
+ break;
506680
+ }
506681
+ case "error": {
506682
+ const text = toText(item.text);
506683
+ if (text.trim().length > 0) {
506684
+ feed.push({
506685
+ kind: "message",
506686
+ message: {
506687
+ role: "assistant",
506688
+ type: "text",
506689
+ text: `Error: ${text}`
506690
+ }
506691
+ });
506692
+ }
506693
+ break;
506694
+ }
506695
+ case "tool_group": {
506696
+ const groupTools = Array.isArray(item.tools) ? item.tools : [];
506697
+ for (const t3 of groupTools) {
506698
+ const toolCallId = typeof t3?.callId === "string" && t3.callId.trim().length > 0 ? t3.callId : `tool_${Date.now()}_${Math.random().toString(16).slice(2)}`;
506699
+ const title = typeof t3?.name === "string" ? t3.name : "Tool call";
506700
+ const status = toToolStatus(t3?.status);
506701
+ const kind = toToolKind(t3?.kind);
506702
+ const resultDisplay = typeof t3?.resultDisplay === "string" ? t3.resultDisplay : "";
506703
+ tools.push({
506704
+ toolCallId,
506705
+ title,
506706
+ status,
506707
+ kind,
506708
+ ...resultDisplay.trim().length > 0 ? {
506709
+ content: [
506710
+ {
506711
+ type: "content",
506712
+ content: { type: "text", text: resultDisplay }
506713
+ }
506714
+ ]
506715
+ } : {}
506716
+ });
506717
+ feed.push({ kind: "tool", toolCallId });
506718
+ }
506719
+ break;
506720
+ }
506721
+ default:
506722
+ break;
506723
+ }
506724
+ }
506725
+ return { feed, tools };
506726
+ }
506727
+ function toReplaceHistoryMeta(history) {
506728
+ const { feed, tools } = historyToUiFeedAndTools(history);
506729
+ return {
506730
+ codely: {
506731
+ ui: {
506732
+ action: "replace_history",
506733
+ feed,
506734
+ tools,
506735
+ messages: historyToUiMessages(history)
506736
+ }
506737
+ }
506738
+ };
506739
+ }
506060
506740
  function buildCommandNameList(commands) {
506061
506741
  const seen = /* @__PURE__ */ new Set();
506062
506742
  const names = [];
@@ -506129,6 +506809,54 @@ var AcpSlashCommandRunner = class {
506129
506809
  }
506130
506810
  return available;
506131
506811
  }
506812
+ /**
506813
+ * Returns argument completion candidates for the given raw slash command line.
506814
+ *
506815
+ * Example:
506816
+ * - "/chat resume " -> ["tag1", "tag2", ...]
506817
+ * - "/model use gpt" -> ["gpt-4.1", "gpt-4o", ...]
506818
+ */
506819
+ async complete(rawQuery, signal, maxResults = 20) {
506820
+ const trimmed2 = rawQuery.trimStart();
506821
+ if (!trimmed2.startsWith("/")) return [];
506822
+ await this.ensureCommandsLoaded(signal);
506823
+ const afterSlash = trimmed2.substring(1);
506824
+ const hasTrailingSpace = /\s$/.test(afterSlash);
506825
+ const parts = afterSlash.trim().split(/\s+/).filter(Boolean);
506826
+ if (parts.length === 0) return [];
506827
+ let currentCommands = this.commands;
506828
+ let commandToExecute;
506829
+ let pathIndex = 0;
506830
+ for (const part of parts) {
506831
+ let found = currentCommands.find((cmd) => cmd.name === part);
506832
+ if (!found) {
506833
+ found = currentCommands.find((cmd) => cmd.altNames?.includes(part));
506834
+ }
506835
+ if (!found) break;
506836
+ commandToExecute = found;
506837
+ pathIndex++;
506838
+ if (found.subCommands) {
506839
+ currentCommands = found.subCommands;
506840
+ } else {
506841
+ break;
506842
+ }
506843
+ }
506844
+ if (!commandToExecute?.completion) return [];
506845
+ const argsParts = parts.slice(pathIndex);
506846
+ const fixedArgsParts = hasTrailingSpace ? argsParts : argsParts.slice(0, -1);
506847
+ const partialArg = !hasTrailingSpace && argsParts.length > 0 ? argsParts[argsParts.length - 1] : "";
506848
+ const { context: context2 } = this.createCommandContext(
506849
+ trimmed2,
506850
+ commandToExecute.name,
506851
+ fixedArgsParts.join(" ")
506852
+ );
506853
+ try {
506854
+ const items = await commandToExecute.completion(context2, partialArg);
506855
+ return items.slice(0, maxResults);
506856
+ } catch {
506857
+ return [];
506858
+ }
506859
+ }
506132
506860
  createCommandContext(rawCommand, commandName, args) {
506133
506861
  const collectedOutput = [];
506134
506862
  const gitService = this.config.getProjectRoot() ? new GitService(this.config.getProjectRoot()) : void 0;
@@ -506187,7 +506915,7 @@ var AcpSlashCommandRunner = class {
506187
506915
  getCollectedOutput: () => collectedOutput.join("\n")
506188
506916
  };
506189
506917
  }
506190
- processCommandResult(result) {
506918
+ async processCommandResult(result) {
506191
506919
  switch (result.type) {
506192
506920
  case "message":
506193
506921
  return { handled: true, response: result.content };
@@ -506208,10 +506936,25 @@ Tool execution via slash commands is not supported in ACP mode yet.`
506208
506936
  response: `Dialog "${result.dialog}" is not supported in ACP mode.`
506209
506937
  };
506210
506938
  case "load_history":
506939
+ try {
506940
+ await this.config.getGeminiClient().setHistory(result.clientHistory);
506941
+ } catch (e3) {
506942
+ const msg = e3 instanceof Error ? e3.message : String(e3);
506943
+ return {
506944
+ handled: true,
506945
+ response: `Failed to restore model history: ${msg}`
506946
+ };
506947
+ }
506948
+ return {
506949
+ handled: true,
506950
+ // Keep a small human-readable message for ACP clients that don't support our meta.
506951
+ response: "Conversation restored.",
506952
+ meta: toReplaceHistoryMeta(result.history)
506953
+ };
506211
506954
  case "load_history_with_resume":
506212
506955
  return {
506213
506956
  handled: true,
506214
- response: "History loading is not supported in ACP mode."
506957
+ response: "Use /chat resume to restore conversation history."
506215
506958
  };
506216
506959
  case "confirm_shell_commands":
506217
506960
  case "confirm_action":
@@ -506299,7 +507042,7 @@ Supported commands in ACP mode:
506299
507042
  content: stripAnsi(output)
506300
507043
  };
506301
507044
  }
506302
- const processed = this.processCommandResult(result);
507045
+ const processed = await this.processCommandResult(result);
506303
507046
  if (!processed.handled && processed.forwardToModelText) {
506304
507047
  return {
506305
507048
  handled: false,
@@ -506314,7 +507057,8 @@ Supported commands in ACP mode:
506314
507057
  return {
506315
507058
  handled: true,
506316
507059
  messageType: "info",
506317
- content: finalText
507060
+ content: finalText,
507061
+ ...processed.meta ? { meta: processed.meta } : {}
506318
507062
  };
506319
507063
  } catch (error41) {
506320
507064
  const msg = error41 instanceof Error ? error41.message : String(error41);
@@ -506329,6 +507073,84 @@ Supported commands in ACP mode:
506329
507073
 
506330
507074
  // packages/cli/src/zed-integration/zedIntegration.ts
506331
507075
  import { randomUUID as randomUUID7 } from "crypto";
507076
+
507077
+ // packages/cli/src/zed-integration/autoCompress.ts
507078
+ init_esbuild_polyfill();
507079
+ init_dist6();
507080
+ async function* streamWithAutoCompressAndRetry(options2) {
507081
+ const { createStream, compress, isRetryableError, onRetry } = options2;
507082
+ let alreadyRetried = false;
507083
+ while (true) {
507084
+ let emittedChunk = false;
507085
+ try {
507086
+ const stream4 = await createStream();
507087
+ for await (const event of stream4) {
507088
+ if (event.type === StreamEventType.CHUNK) {
507089
+ emittedChunk = true;
507090
+ }
507091
+ yield event;
507092
+ }
507093
+ return;
507094
+ } catch (error41) {
507095
+ if (alreadyRetried || emittedChunk || !isRetryableError(error41)) {
507096
+ throw error41;
507097
+ }
507098
+ alreadyRetried = true;
507099
+ const didCompress = await compress();
507100
+ if (!didCompress) {
507101
+ throw error41;
507102
+ }
507103
+ if (onRetry) {
507104
+ await onRetry();
507105
+ }
507106
+ yield { type: StreamEventType.RETRY };
507107
+ }
507108
+ }
507109
+ }
507110
+
507111
+ // packages/cli/src/zed-integration/acpTelemetry.ts
507112
+ init_esbuild_polyfill();
507113
+ init_dist6();
507114
+ function extractPromptTextForTelemetry(blocks) {
507115
+ return blocks.filter(
507116
+ (p) => p.type === "text" && typeof p.text === "string"
507117
+ ).map((p) => p.text).join("\n");
507118
+ }
507119
+ function emitAcpUserPromptTelemetry(params) {
507120
+ const prompt = extractPromptTextForTelemetry(params.promptBlocks);
507121
+ logUserPrompt(
507122
+ params.config,
507123
+ new UserPromptEvent(
507124
+ prompt.length,
507125
+ params.promptId,
507126
+ params.authType,
507127
+ prompt
507128
+ )
507129
+ );
507130
+ }
507131
+ function emitAcpApiRequestTelemetry(params) {
507132
+ logApiRequest(
507133
+ params.config,
507134
+ new ApiRequestEvent(params.model, params.promptId)
507135
+ );
507136
+ }
507137
+ function emitAcpApiResponseTelemetry(params) {
507138
+ const responseId = typeof params.responseId === "string" && params.responseId.trim().length > 0 ? params.responseId : `${params.promptId}-${Date.now()}`;
507139
+ logApiResponse(
507140
+ params.config,
507141
+ new ApiResponseEvent(
507142
+ responseId,
507143
+ params.model,
507144
+ params.durationMs,
507145
+ params.promptId,
507146
+ params.authType,
507147
+ params.usageMetadata,
507148
+ params.responseText
507149
+ )
507150
+ );
507151
+ }
507152
+
507153
+ // packages/cli/src/zed-integration/zedIntegration.ts
506332
507154
  function getAcpAuthMethods() {
506333
507155
  if (!process.env.CUSTOM_AUTH) {
506334
507156
  return [
@@ -506611,6 +507433,45 @@ var GeminiAgent = class {
506611
507433
  }
506612
507434
  return session.prompt(params);
506613
507435
  }
507436
+ async extMethod(method, params) {
507437
+ if (method === "workspace/suggest_paths") {
507438
+ const parsed = external_exports.object({
507439
+ sessionId: external_exports.string(),
507440
+ pattern: external_exports.string(),
507441
+ maxResults: external_exports.number().optional()
507442
+ }).safeParse(params);
507443
+ if (!parsed.success) {
507444
+ throw RequestError3.invalidParams(parsed.error.format());
507445
+ }
507446
+ const { sessionId: sessionId2, pattern, maxResults } = parsed.data;
507447
+ const session = this.sessions.get(sessionId2);
507448
+ if (!session) {
507449
+ throw new Error(`Session not found: ${sessionId2}`);
507450
+ }
507451
+ const max = maxResults ?? 20;
507452
+ const paths = await session.suggestPaths(pattern, max);
507453
+ return { paths };
507454
+ }
507455
+ if (method === "slash/complete") {
507456
+ const parsed = external_exports.object({
507457
+ sessionId: external_exports.string(),
507458
+ line: external_exports.string(),
507459
+ maxResults: external_exports.number().optional()
507460
+ }).safeParse(params);
507461
+ if (!parsed.success) {
507462
+ throw RequestError3.invalidParams(parsed.error.format());
507463
+ }
507464
+ const { sessionId: sessionId2, line, maxResults } = parsed.data;
507465
+ const session = this.sessions.get(sessionId2);
507466
+ if (!session) {
507467
+ throw new Error(`Session not found: ${sessionId2}`);
507468
+ }
507469
+ const max = maxResults ?? 20;
507470
+ const items = await session.completeSlash(line, max);
507471
+ return { items };
507472
+ }
507473
+ throw RequestError3.methodNotFound(`_${method}`);
507474
+ }
506614
507475
  };
506615
507476
  var Session2 = class {
506616
507477
  constructor(id, config4, settings, client) {
@@ -506622,9 +507483,41 @@ var Session2 = class {
506622
507483
  }
506623
507484
  pendingPrompt = null;
506624
507485
  slashCommands;
507486
+ fileSearch = null;
506625
507487
  getChat() {
506626
507488
  return this.config.getGeminiClient().getChat();
506627
507489
  }
507490
+ async ensureFileSearch() {
507491
+ if (this.fileSearch) return this.fileSearch;
507492
+ const root = this.config.getTargetDir();
507493
+ const opts = this.config.getFileFilteringOptions?.();
507494
+ const searcher = new FileSearch({
507495
+ projectRoot: root,
507496
+ ignoreDirs: [],
507497
+ useGitignore: opts?.respectGitIgnore ?? true,
507498
+ useGeminiignore: opts?.respectGeminiIgnore ?? true,
507499
+ cache: true,
507500
+ cacheTtl: 30,
507501
+ maxDepth: !(this.config.getEnableRecursiveFileSearch?.() ?? true) ? 0 : void 0
507502
+ });
507503
+ await searcher.initialize();
507504
+ this.fileSearch = searcher;
507505
+ return searcher;
507506
+ }
507507
+ async suggestPaths(pattern, maxResults) {
507508
+ const searcher = await this.ensureFileSearch();
507509
+ const results = await searcher.search(pattern, { maxResults });
507510
+ return results.filter((p) => !/\s/.test(p)).slice(0, maxResults);
507511
+ }
507512
+ async completeSlash(line, maxResults) {
507513
+ const controller = new AbortController();
507514
+ const items = await this.slashCommands.complete(
507515
+ line,
507516
+ controller.signal,
507517
+ maxResults
507518
+ );
507519
+ return items.slice(0, maxResults);
507520
+ }
506628
507521
  async advertiseAvailableCommands() {
506629
507522
  const controller = new AbortController();
506630
507523
  const availableCommands = await this.slashCommands.getAvailableCommands(
@@ -506647,7 +507540,8 @@ var Session2 = class {
506647
507540
  const pendingSend = new AbortController();
506648
507541
  this.pendingPrompt = pendingSend;
506649
507542
  const promptId = Math.random().toString(16).slice(2);
506650
- const chat = this.getChat();
507543
+ const geminiClient = this.config.getGeminiClient();
507544
+ const authType = this.config.getContentGeneratorConfig()?.authType;
506651
507545
  const firstText = params.prompt.find(
506652
507546
  (p) => p.type === "text" && typeof p.text === "string"
506653
507547
  )?.text ?? "";
@@ -506661,7 +507555,8 @@ var Session2 = class {
506661
507555
  const prefix = slashResult.messageType === "error" ? "Error: " : "";
506662
507556
  await this.sendUpdate({
506663
507557
  sessionUpdate: "agent_message_chunk",
506664
- content: { type: "text", text: `${prefix}${slashResult.content}` }
507558
+ content: { type: "text", text: `${prefix}${slashResult.content}` },
507559
+ ...slashResult.meta ? { _meta: slashResult.meta } : {}
506665
507560
  });
506666
507561
  return { stopReason: "end_turn" };
506667
507562
  }
@@ -506681,6 +507576,12 @@ var Session2 = class {
506681
507576
  }
506682
507577
  }
506683
507578
  }
507579
+ emitAcpUserPromptTelemetry({
507580
+ config: this.config,
507581
+ promptId,
507582
+ authType,
507583
+ promptBlocks: promptBlocksForModel
507584
+ });
506684
507585
  const parts = await this.#resolvePrompt(
506685
507586
  promptBlocksForModel,
506686
507587
  pendingSend.signal
@@ -506688,21 +507589,68 @@ var Session2 = class {
506688
507589
  let nextMessage = { role: "user", parts };
506689
507590
  while (nextMessage !== null) {
506690
507591
  if (pendingSend.signal.aborted) {
506691
- chat.addHistory(nextMessage);
507592
+ this.getChat().addHistory(nextMessage);
506692
507593
  return { stopReason: "cancelled" };
506693
507594
  }
506694
507595
  const functionCalls = [];
507596
+ const currentMessageParts = nextMessage.parts ?? [];
506695
507597
  try {
506696
- const responseStream = await chat.sendMessageStream(
506697
- this.config.getModel(),
506698
- {
506699
- message: nextMessage?.parts ?? [],
506700
- config: {
506701
- abortSignal: pendingSend.signal
507598
+ const modelForRequest = this.config.getModel();
507599
+ const requestStartedAt = Date.now();
507600
+ let aggregatedResponseText = "";
507601
+ let usageMetadata;
507602
+ let responseId = "";
507603
+ emitAcpApiRequestTelemetry({
507604
+ config: this.config,
507605
+ promptId,
507606
+ model: modelForRequest
507607
+ });
507608
+ const responseStream = streamWithAutoCompressAndRetry({
507609
+ createStream: async () => {
507610
+ const preCompressed = await geminiClient.tryCompressChat(
507611
+ promptId,
507612
+ false
507613
+ );
507614
+ if (preCompressed && this.config.getDebugMode()) {
507615
+ await this.sendUpdate({
507616
+ sessionUpdate: "agent_thought_chunk",
507617
+ content: {
507618
+ type: "text",
507619
+ text: `[Auto-Compress] Pre-send compression: ${preCompressed.originalTokenCount} \u2192 ${preCompressed.newTokenCount} tokens`
507620
+ }
507621
+ });
506702
507622
  }
507623
+ const chat = this.getChat();
507624
+ return await chat.sendMessageStream(
507625
+ this.config.getModel(),
507626
+ {
507627
+ message: currentMessageParts,
507628
+ config: {
507629
+ abortSignal: pendingSend.signal
507630
+ }
507631
+ },
507632
+ promptId
507633
+ );
506703
507634
  },
506704
- promptId
506705
- );
507635
+ compress: async () => {
507636
+ const compressed = await geminiClient.tryCompressChat(
507637
+ promptId,
507638
+ true
507639
+ );
507640
+ return compressed !== null;
507641
+ },
507642
+ isRetryableError: (error41) => !pendingSend.signal.aborted && isContextWindowExceededError(error41),
507643
+ onRetry: async () => {
507644
+ if (!this.config.getDebugMode()) return;
507645
+ await this.sendUpdate({
507646
+ sessionUpdate: "agent_thought_chunk",
507647
+ content: {
507648
+ type: "text",
507649
+ text: "[Auto-Compress] Context too long; compressed history and retrying."
507650
+ }
507651
+ });
507652
+ }
507653
+ });
506706
507654
  nextMessage = null;
506707
507655
  const thinkTagProcessor2 = new ThinkTagStreamProcessor();
506708
507656
  thinkTagProcessor2.reset();
@@ -506714,6 +507662,14 @@ var Session2 = class {
506714
507662
  continue;
506715
507663
  }
506716
507664
  const resp = event.type === StreamEventType.CHUNK ? event.value : event;
507665
+ const maybeResponseId = resp?.responseId ?? resp?.response_id;
507666
+ if (typeof maybeResponseId === "string" && maybeResponseId) {
507667
+ responseId = maybeResponseId;
507668
+ }
507669
+ const maybeUsage = resp?.usageMetadata;
507670
+ if (maybeUsage && typeof maybeUsage === "object") {
507671
+ usageMetadata = maybeUsage;
507672
+ }
506717
507673
  if (resp.candidates && resp.candidates.length > 0) {
506718
507674
  const candidate = resp.candidates[0];
506719
507675
  const parts2 = candidate.content?.parts ?? [];
@@ -506740,6 +507696,7 @@ var Session2 = class {
506740
507696
  });
506741
507697
  }
506742
507698
  if (content.length > 0) {
507699
+ aggregatedResponseText += content;
506743
507700
  this.sendUpdate({
506744
507701
  sessionUpdate: "agent_message_chunk",
506745
507702
  content: { type: "text", text: content }
@@ -506752,6 +507709,17 @@ var Session2 = class {
506752
507709
  functionCalls.push(...resp.functionCalls);
506753
507710
  }
506754
507711
  }
507712
+ const durationMs = Date.now() - requestStartedAt;
507713
+ emitAcpApiResponseTelemetry({
507714
+ config: this.config,
507715
+ promptId,
507716
+ authType,
507717
+ model: modelForRequest,
507718
+ responseId,
507719
+ durationMs,
507720
+ usageMetadata,
507721
+ responseText: aggregatedResponseText
507722
+ });
506755
507723
  } catch (error41) {
506756
507724
  if (getErrorStatus(error41) === 429) {
506757
507725
  throw new RequestError3(
@@ -506778,10 +507746,10 @@ var Session2 = class {
506778
507746
  } else {
506779
507747
  if (!pendingSend.signal.aborted) {
506780
507748
  try {
506781
- const geminiClient = this.config.getGeminiClient();
507749
+ const geminiClient2 = this.config.getGeminiClient();
506782
507750
  const nextSpeakerCheck = await checkNextSpeaker(
506783
507751
  this.getChat(),
506784
- geminiClient,
507752
+ geminiClient2,
506785
507753
  pendingSend.signal
506786
507754
  );
506787
507755
  logNextSpeakerCheck(
@@ -506973,7 +507941,25 @@ var Session2 = class {
506973
507941
  });
506974
507942
  }
506975
507943
  try {
506976
- const toolResult = await invocation.execute(abortSignal);
507944
+ const updateOutput2 = (output) => {
507945
+ void (async () => {
507946
+ await this.sendUpdate({
507947
+ sessionUpdate: "tool_call_update",
507948
+ toolCallId: callId,
507949
+ status: "in_progress",
507950
+ content: [
507951
+ {
507952
+ type: "content",
507953
+ content: { type: "text", text: output }
507954
+ }
507955
+ ]
507956
+ });
507957
+ })();
507958
+ };
507959
+ const toolResult = await invocation.execute(
507960
+ abortSignal,
507961
+ updateOutput2
507962
+ );
506977
507963
  const content = toToolCallContent(toolResult);
506978
507964
  await this.sendUpdate({
506979
507965
  sessionUpdate: "tool_call_update",