deepcode-ai 1.1.6 → 1.1.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -3517,8 +3517,11 @@ Caminho: ${selectedPath}`;
3517
3517
  if (error instanceof BudgetExceededError) {
3518
3518
  throw error;
3519
3519
  }
3520
- session.metadata.planError = error instanceof Error ? error.message : String(error);
3521
- this.eventBus.emit("app:warn", { message: `Task planning failed: ${session.metadata.planError}. Continuing without structured plan.` });
3520
+ session.metadata.planError = formatErrorChain(error);
3521
+ this.eventBus.emit("app:warn", {
3522
+ message: formatPlanningFailureWarning(error),
3523
+ context: { error: session.metadata.planError }
3524
+ });
3522
3525
  }
3523
3526
  }
3524
3527
  let finalText = "";
@@ -4284,6 +4287,45 @@ ${assistantText}` : assistantText;
4284
4287
  }
4285
4288
  }
4286
4289
  };
4290
+ function formatPlanningFailureWarning(error) {
4291
+ if (error instanceof ProviderError) {
4292
+ const provider = formatProviderName(error.provider);
4293
+ const status = typeof error.statusCode === "number" ? ` (${error.statusCode})` : "";
4294
+ if (error.statusCode === 429) {
4295
+ return `Task planning skipped: ${provider} rate limit hit${status}. Continuing without structured plan.`;
4296
+ }
4297
+ if (error.statusCode && error.statusCode >= 500) {
4298
+ return `Task planning skipped: ${provider} returned a temporary service error${status}. Continuing without structured plan.`;
4299
+ }
4300
+ return `Task planning failed: ${compactPlanningError(error.message)}. Continuing without structured plan.`;
4301
+ }
4302
+ const detail = error instanceof Error ? error.message : String(error);
4303
+ return `Task planning failed: ${compactPlanningError(detail)}. Continuing without structured plan.`;
4304
+ }
4305
+ function compactPlanningError(message) {
4306
+ const firstLine2 = message.replace(/\s+/g, " ").trim();
4307
+ return firstLine2.length > 240 ? `${firstLine2.slice(0, 237)}...` : firstLine2;
4308
+ }
4309
+ function formatProviderName(provider) {
4310
+ switch (provider) {
4311
+ case "openrouter":
4312
+ return "OpenRouter";
4313
+ case "openai":
4314
+ return "OpenAI";
4315
+ case "anthropic":
4316
+ return "Anthropic";
4317
+ case "deepseek":
4318
+ return "DeepSeek";
4319
+ case "groq":
4320
+ return "Groq";
4321
+ case "ollama":
4322
+ return "Ollama";
4323
+ case "opencode":
4324
+ return "OpenCode";
4325
+ default:
4326
+ return provider;
4327
+ }
4328
+ }
4287
4329
  function truncateForMetadata(value, maxLength = 2e3) {
4288
4330
  return value.length > maxLength ? `${value.slice(0, maxLength)}...` : value;
4289
4331
  }
@@ -27408,10 +27450,11 @@ var providerCommand = {
27408
27450
  }
27409
27451
  session.setProvider(parsed.data);
27410
27452
  const state = session.getState();
27453
+ const targetLabel = state.model ? `${state.provider}/${state.model}` : `${state.provider}/(model unset)`;
27411
27454
  return {
27412
27455
  type: "message",
27413
27456
  messageType: "info",
27414
- content: `Provider set to ${state.provider}${state.model ? `/${state.model}` : ""}.`
27457
+ content: `Session provider set: ${targetLabel}. Test connection did not run. Use /model to choose a model if unset.`
27415
27458
  };
27416
27459
  }
27417
27460
  };
@@ -27434,7 +27477,7 @@ var modelCommand = {
27434
27477
  return {
27435
27478
  type: "message",
27436
27479
  messageType: "info",
27437
- content: `Model set to ${state.model ?? "(unset)"}.`
27480
+ content: `Session model set: ${state.provider}/${state.model ?? "(unset)"}.`
27438
27481
  };
27439
27482
  }
27440
27483
  };
@@ -27473,7 +27516,7 @@ Usage: /mode <build|plan>`
27473
27516
  return {
27474
27517
  type: "message",
27475
27518
  messageType: "info",
27476
- content: `Mode set to ${target}.`
27519
+ content: `Mode set: ${target.toUpperCase()}.`
27477
27520
  };
27478
27521
  }
27479
27522
  };
@@ -27614,6 +27657,7 @@ var ProviderDialog = ({
27614
27657
  hasApiKey,
27615
27658
  getProviderKeyHint,
27616
27659
  onSelectProvider,
27660
+ onSetDefaultProvider,
27617
27661
  onSaveApiKey,
27618
27662
  onTestProvider,
27619
27663
  onClose
@@ -27641,12 +27685,24 @@ var ProviderDialog = ({
27641
27685
  );
27642
27686
  const actionItems = useMemo11(
27643
27687
  () => [
27688
+ {
27689
+ key: "use",
27690
+ value: "use",
27691
+ icon: "\u25CF",
27692
+ label: selectedProvider === currentProvider ? "Current session provider" : "Use provider for this session"
27693
+ },
27644
27694
  {
27645
27695
  key: "editKey",
27646
27696
  value: "editKey",
27647
27697
  icon: "\u270E",
27648
27698
  label: isLocal ? "Edit API key (optional)" : "Edit API key"
27649
27699
  },
27700
+ {
27701
+ key: "setDefault",
27702
+ value: "setDefault",
27703
+ icon: "\u25C6",
27704
+ label: "Set as default in config"
27705
+ },
27650
27706
  {
27651
27707
  key: "test",
27652
27708
  value: "test",
@@ -27668,7 +27724,7 @@ var ProviderDialog = ({
27668
27724
  label: "Close"
27669
27725
  }
27670
27726
  ],
27671
- [canTest, isLocal]
27727
+ [canTest, currentProvider, isLocal, selectedProvider]
27672
27728
  );
27673
27729
  const selectProvider = useCallback18(
27674
27730
  (provider) => {
@@ -27714,16 +27770,33 @@ var ProviderDialog = ({
27714
27770
  void runTest();
27715
27771
  return;
27716
27772
  }
27773
+ if (action === "use") {
27774
+ onSelectProvider(selectedProvider);
27775
+ onClose();
27776
+ return;
27777
+ }
27778
+ if (action === "setDefault") {
27779
+ setIsBusy(true);
27780
+ setStatus({ text: `Saving ${selectedProvider} as default\u2026`, ok: true });
27781
+ void onSetDefaultProvider(selectedProvider).then(() => {
27782
+ setStatus({ text: `Saved ${selectedProvider} as config default.`, ok: true });
27783
+ onClose();
27784
+ }).catch((err) => {
27785
+ setStatus({ text: err instanceof Error ? err.message : String(err), ok: false });
27786
+ }).finally(() => {
27787
+ setIsBusy(false);
27788
+ });
27789
+ return;
27790
+ }
27717
27791
  if (action === "back") {
27718
27792
  setStatus(null);
27719
27793
  setTestLatencyMs(void 0);
27720
27794
  setPhase("providers");
27721
27795
  return;
27722
27796
  }
27723
- onSelectProvider(selectedProvider);
27724
27797
  onClose();
27725
27798
  },
27726
- [isBusy, onClose, onSelectProvider, runTest, selectedProvider]
27799
+ [isBusy, onClose, onSelectProvider, onSetDefaultProvider, runTest, selectedProvider]
27727
27800
  );
27728
27801
  const saveApiKey = useCallback18(async () => {
27729
27802
  const normalized2 = apiKeyInput.trim();
@@ -27826,6 +27899,10 @@ var ProviderDialog = ({
27826
27899
  }
27827
27900
  ),
27828
27901
  phase === "actions" && /* @__PURE__ */ jsxs37(Fragment9, { children: [
27902
+ /* @__PURE__ */ jsxs37(Box34, { marginBottom: 1, gap: 1, children: [
27903
+ /* @__PURE__ */ jsx43(Text40, { color: theme.ui.comment, children: "session" }),
27904
+ /* @__PURE__ */ jsx43(Text40, { color: selectedProvider === currentProvider ? theme.text.accent : theme.text.secondary, children: selectedProvider === currentProvider ? "active" : `still using ${currentProvider}` })
27905
+ ] }),
27829
27906
  /* @__PURE__ */ jsxs37(Box34, { marginBottom: 1, gap: 1, children: [
27830
27907
  /* @__PURE__ */ jsx43(Text40, { color: theme.ui.comment, children: "key" }),
27831
27908
  isLocal ? /* @__PURE__ */ jsx43(Text40, { color: theme.text.accent, children: "no key required" }) : keyHint ? /* @__PURE__ */ jsx43(Text40, { color: theme.text.secondary, children: keyHint }) : /* @__PURE__ */ jsx43(Text40, { color: theme.ui.comment, dimColor: true, children: "not configured" })
@@ -27837,7 +27914,7 @@ var ProviderDialog = ({
27837
27914
  onSelect: selectAction,
27838
27915
  isFocused: !isBusy,
27839
27916
  showNumbers: false,
27840
- maxItemsToShow: 4,
27917
+ maxItemsToShow: 6,
27841
27918
  renderItem: (item, { titleColor }) => /* @__PURE__ */ jsxs37(Box34, { gap: 1, children: [
27842
27919
  /* @__PURE__ */ jsx43(Text40, { color: titleColor, children: item.icon }),
27843
27920
  /* @__PURE__ */ jsx43(Text40, { color: titleColor, children: item.label }),
@@ -27878,7 +27955,10 @@ var ProviderDialog = ({
27878
27955
  borderLeft: false,
27879
27956
  borderRight: false,
27880
27957
  borderColor: theme.ui.comment,
27881
- children: /* @__PURE__ */ jsx43(Text40, { color: theme.ui.comment, dimColor: true, children: footer })
27958
+ children: /* @__PURE__ */ jsxs37(Text40, { color: theme.ui.comment, dimColor: true, children: [
27959
+ footer,
27960
+ phase === "actions" && " Test does not change the session."
27961
+ ] })
27882
27962
  }
27883
27963
  )
27884
27964
  ]
@@ -28238,7 +28318,11 @@ var ModelDialog = ({
28238
28318
  minWidth: 58,
28239
28319
  children: [
28240
28320
  /* @__PURE__ */ jsxs40(Box37, { justifyContent: "space-between", marginBottom: 1, children: [
28241
- /* @__PURE__ */ jsx46(Text43, { bold: true, color: theme.text.primary, children: "Select model" }),
28321
+ /* @__PURE__ */ jsxs40(Box37, { gap: 1, children: [
28322
+ /* @__PURE__ */ jsx46(Text43, { bold: true, color: theme.text.primary, children: "Select model" }),
28323
+ /* @__PURE__ */ jsx46(Text43, { color: theme.text.secondary, children: "for" }),
28324
+ /* @__PURE__ */ jsx46(Text43, { color: theme.text.accent, children: currentProvider })
28325
+ ] }),
28242
28326
  /* @__PURE__ */ jsx46(Text43, { color: theme.ui.comment, dimColor: true, children: "esc" })
28243
28327
  ] }),
28244
28328
  /* @__PURE__ */ jsxs40(
@@ -28315,7 +28399,7 @@ var ModelDialog = ({
28315
28399
  borderLeft: false,
28316
28400
  borderRight: false,
28317
28401
  borderColor: theme.ui.comment,
28318
- children: /* @__PURE__ */ jsx46(Text43, { color: theme.ui.comment, dimColor: true, children: "\u2191\u2193 navigate type to search Enter select Esc close" })
28402
+ children: /* @__PURE__ */ jsx46(Text43, { color: theme.ui.comment, dimColor: true, children: "\u2191\u2193 navigate type to search Enter use for session Esc close" })
28319
28403
  }
28320
28404
  )
28321
28405
  ]
@@ -28459,6 +28543,7 @@ var AppContainer = ({ cwd, config, provider, model }) => {
28459
28543
  const [pendingAssistantText, setPendingAssistantText] = useState25("");
28460
28544
  const [approvalQueue, setApprovalQueue] = useState25([]);
28461
28545
  const [providerLabel, setProviderLabel] = useState25("(unconfigured)");
28546
+ const [targetSource, setTargetSource] = useState25("config");
28462
28547
  const [currentModel, setCurrentModel] = useState25("(unconfigured)");
28463
28548
  const [agentMode, setAgentMode] = useState25("build");
28464
28549
  const [streamingState, setStreamingState] = useState25(
@@ -28605,11 +28690,21 @@ var AppContainer = ({ cwd, config, provider, model }) => {
28605
28690
  const session = sessionRef.current;
28606
28691
  if (!runtime || !session) return;
28607
28692
  session.provider = provider2;
28608
- session.model = resolveConfiguredModelForProvider(runtime.config, provider2) ?? session.model;
28693
+ session.model = resolveConfiguredModelForProvider(runtime.config, provider2);
28609
28694
  runtime.sessions.save(session);
28695
+ setTargetSource("session");
28610
28696
  setCurrentModel(session.model ?? "(unconfigured)");
28611
28697
  setProviderLabel(formatProviderLabel(session.provider, session.model));
28612
- }, []);
28698
+ if (!session.model) {
28699
+ historyManager.addItem(
28700
+ {
28701
+ type: "warning",
28702
+ text: `Provider changed to ${provider2}, but no model is configured. Run /model or set defaultModels.${provider2}.`
28703
+ },
28704
+ Date.now()
28705
+ );
28706
+ }
28707
+ }, [historyManager]);
28613
28708
  const setSessionModel = useCallback22((model2) => {
28614
28709
  const runtime = runtimeRef.current;
28615
28710
  const session = sessionRef.current;
@@ -28617,6 +28712,7 @@ var AppContainer = ({ cwd, config, provider, model }) => {
28617
28712
  const normalized2 = model2.trim();
28618
28713
  session.model = normalized2.length > 0 ? normalized2 : void 0;
28619
28714
  runtime.sessions.save(session);
28715
+ setTargetSource("session");
28620
28716
  setCurrentModel(session.model ?? "(unconfigured)");
28621
28717
  setProviderLabel(formatProviderLabel(session.provider, session.model));
28622
28718
  }, []);
@@ -28734,6 +28830,7 @@ var AppContainer = ({ cwd, config, provider, model }) => {
28734
28830
  });
28735
28831
  setAuthSummary(formatAuthSummary(runtime.config.github));
28736
28832
  setAgentMode(runtime.config.agentMode);
28833
+ setTargetSource(provider || model ? "cli" : "config");
28737
28834
  setCurrentModel(session.model ?? "(unconfigured)");
28738
28835
  setProviderLabel(formatProviderLabel(session.provider, session.model));
28739
28836
  const unsubscribers = [];
@@ -29334,6 +29431,48 @@ var AppContainer = ({ cwd, config, provider, model }) => {
29334
29431
  },
29335
29432
  [historyManager, persistConfig]
29336
29433
  );
29434
+ const handleSetDefaultProvider = useCallback22(
29435
+ async (provider2) => {
29436
+ const runtime = runtimeRef.current;
29437
+ const session = sessionRef.current;
29438
+ const previousDefaultProvider = runtime?.config.defaultProvider;
29439
+ const configuredModel = runtime ? previousDefaultProvider === provider2 ? resolveConfiguredModelForProvider(runtime.config, provider2) : runtime.config.defaultModels?.[provider2] : void 0;
29440
+ await persistConfig((cfg) => ({
29441
+ ...cfg,
29442
+ defaultProvider: provider2,
29443
+ defaultModel: cfg.defaultProvider === provider2 ? cfg.defaultModel : void 0
29444
+ }));
29445
+ if (runtime) {
29446
+ runtime.config.defaultProvider = provider2;
29447
+ if (previousDefaultProvider !== provider2) {
29448
+ runtime.config.defaultModel = void 0;
29449
+ }
29450
+ }
29451
+ if (session) {
29452
+ session.provider = provider2;
29453
+ session.model = configuredModel;
29454
+ runtime?.sessions.save(session);
29455
+ setProviderLabel(formatProviderLabel(session.provider, session.model));
29456
+ setCurrentModel(session.model ?? "(unconfigured)");
29457
+ }
29458
+ setTargetSource("config");
29459
+ setProviderConfigVersion((version) => version + 1);
29460
+ historyManager.addItem(
29461
+ { type: "info", text: `Default provider saved: ${provider2}.` },
29462
+ Date.now()
29463
+ );
29464
+ if (!configuredModel) {
29465
+ historyManager.addItem(
29466
+ {
29467
+ type: "warning",
29468
+ text: `Default provider ${provider2} has no configured model. Run /model or set defaultModels.${provider2}.`
29469
+ },
29470
+ Date.now()
29471
+ );
29472
+ }
29473
+ },
29474
+ [historyManager, persistConfig]
29475
+ );
29337
29476
  const handleTestProvider = useCallback22(
29338
29477
  async (provider2) => {
29339
29478
  const runtime = runtimeRef.current;
@@ -29500,6 +29639,7 @@ var AppContainer = ({ cwd, config, provider, model }) => {
29500
29639
  () => buildDialogModel(activeDialog, {
29501
29640
  cwd,
29502
29641
  providerLabel,
29642
+ targetSource,
29503
29643
  currentModel,
29504
29644
  agentMode,
29505
29645
  compactMode,
@@ -29517,6 +29657,7 @@ var AppContainer = ({ cwd, config, provider, model }) => {
29517
29657
  authSummary,
29518
29658
  permissionSummary,
29519
29659
  providerLabel,
29660
+ targetSource,
29520
29661
  slashCommands,
29521
29662
  themeName
29522
29663
  ]
@@ -29616,15 +29757,22 @@ var AppContainer = ({ cwd, config, provider, model }) => {
29616
29757
  return /* @__PURE__ */ jsx47(CompactModeProvider, { value: { compactMode }, children: /* @__PURE__ */ jsx47(ConfigContext.Provider, { value: configAdapter, children: /* @__PURE__ */ jsx47(SettingsContext.Provider, { value: loadedSettings, children: /* @__PURE__ */ jsx47(StreamingContext.Provider, { value: streamingState, children: /* @__PURE__ */ jsx47(VimModeProvider, { initialVimEnabled: loadedSettings.merged.general?.vimMode ?? false, children: /* @__PURE__ */ jsx47(KeypressProvider, { kittyProtocolEnabled: false, config: configAdapter, children: /* @__PURE__ */ jsx47(ShellFocusContext.Provider, { value: true, children: /* @__PURE__ */ jsx47(AgentViewProvider, { children: /* @__PURE__ */ jsx47(BackgroundTaskViewProvider, { children: /* @__PURE__ */ jsx47(UIStateContext.Provider, { value: uiState, children: /* @__PURE__ */ jsx47(UIActionsContext.Provider, { value: uiActions, children: /* @__PURE__ */ jsxs41(Box38, { flexDirection: "column", flexGrow: 1, children: [
29617
29758
  /* @__PURE__ */ jsxs41(Box38, { marginLeft: 2, marginRight: 2, marginTop: 1, marginBottom: 1, children: [
29618
29759
  /* @__PURE__ */ jsx47(Text44, { bold: true, color: theme.text.accent, children: "DeepCode" }),
29760
+ /* @__PURE__ */ jsx47(Text44, { color: theme.text.secondary, children: " Target: " }),
29761
+ /* @__PURE__ */ jsx47(Text44, { color: theme.text.primary, children: providerLabel }),
29619
29762
  /* @__PURE__ */ jsxs41(Text44, { color: theme.text.secondary, children: [
29620
- " ",
29621
- providerLabel
29622
- ] }),
29623
- /* @__PURE__ */ jsxs41(Text44, { color: theme.text.secondary, children: [
29624
- " [",
29625
- agentMode,
29626
- "]"
29763
+ " (",
29764
+ targetSource,
29765
+ ")"
29627
29766
  ] }),
29767
+ /* @__PURE__ */ jsx47(Text44, { color: theme.text.secondary, children: " Mode: " }),
29768
+ /* @__PURE__ */ jsx47(
29769
+ Text44,
29770
+ {
29771
+ bold: true,
29772
+ color: agentMode === "build" ? theme.status.success : theme.status.warning,
29773
+ children: agentMode.toUpperCase()
29774
+ }
29775
+ ),
29628
29776
  /* @__PURE__ */ jsxs41(Text44, { color: theme.text.secondary, children: [
29629
29777
  " ",
29630
29778
  streamingState === "responding" ? "running" : streamingState === "waiting_for_confirmation" ? "waiting-approval" : "idle"
@@ -29672,6 +29820,7 @@ var AppContainer = ({ cwd, config, provider, model }) => {
29672
29820
  hasApiKey: providerHasApiKey,
29673
29821
  getProviderKeyHint,
29674
29822
  onSelectProvider: setSessionProvider,
29823
+ onSetDefaultProvider: handleSetDefaultProvider,
29675
29824
  onSaveApiKey: handleSaveProviderApiKey,
29676
29825
  onTestProvider: handleTestProvider,
29677
29826
  onClose: closeDialog
@@ -29732,7 +29881,7 @@ var AppContainer = ({ cwd, config, provider, model }) => {
29732
29881
  ] }) }) }) }) }) }) }) }) }) }) }) });
29733
29882
  };
29734
29883
  function formatProviderLabel(provider, model) {
29735
- return model ? `${provider}/${model}` : provider;
29884
+ return model ? `${provider}/${model}` : `${provider}/(model unset)`;
29736
29885
  }
29737
29886
  function formatNumber(value) {
29738
29887
  if (!Number.isFinite(value)) return String(value);
@@ -29806,7 +29955,7 @@ function buildDialogModel(dialog, options) {
29806
29955
  title: "Settings",
29807
29956
  lines: [
29808
29957
  `Working directory: ${options.cwd}`,
29809
- `Provider/Model: ${options.providerLabel}`,
29958
+ `Provider/Model: ${options.providerLabel} (${options.targetSource})`,
29810
29959
  `Mode: ${options.agentMode}`,
29811
29960
  `Compact mode: ${options.compactMode ? "on" : "off"}`,
29812
29961
  `Theme: ${options.themeName}`