@iaforged/context-code 1.0.80 → 1.0.81

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.
@@ -1,8 +1,7 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import { c as _c } from "react/compiler-runtime";
3
3
  import * as React from 'react';
4
4
  import { Box } from '../../ink.js';
5
- import { Divider } from '../design-system/Divider.js';
6
5
  import { calculateFeedWidth, Feed } from './Feed.js';
7
6
  export function FeedColumn(t0) {
8
7
  const $ = _c(10);
@@ -23,7 +22,7 @@ export function FeedColumn(t0) {
23
22
  if ($[2] !== actualWidth || $[3] !== feeds) {
24
23
  let t3;
25
24
  if ($[5] !== actualWidth || $[6] !== feeds.length) {
26
- t3 = (feed_0, index) => _jsxs(React.Fragment, { children: [_jsx(Feed, { config: feed_0, actualWidth: actualWidth }), index < feeds.length - 1 && _jsx(Divider, { color: "claude", width: actualWidth })] }, index);
25
+ t3 = (feed_0, index) => _jsx(React.Fragment, { children: _jsx(Feed, { config: feed_0, actualWidth: actualWidth }) }, index);
27
26
  $[5] = actualWidth;
28
27
  $[6] = feeds.length;
29
28
  $[7] = t3;
@@ -41,7 +40,7 @@ export function FeedColumn(t0) {
41
40
  }
42
41
  let t3;
43
42
  if ($[8] !== t2) {
44
- t3 = _jsx(Box, { flexDirection: "column", children: t2 });
43
+ t3 = _jsx(Box, { flexDirection: "column", gap: 1, children: t2 });
45
44
  $[8] = t2;
46
45
  $[9] = t3;
47
46
  }
@@ -251,8 +251,8 @@ export function LogoV2() {
251
251
  }
252
252
  const layoutMode = getLayoutMode(columns);
253
253
  const userTheme = resolveThemeSetting(getGlobalConfig().theme);
254
- const borderTitle = ` ${color("claude", userTheme)("Context Code")} ${color("inactive", userTheme)(`v${version}`)} `;
255
- const compactBorderTitle = color("claude", userTheme)(" Context Code ");
254
+ const borderTitle = ` ${color("claude", userTheme)("CTX")} ${color("inactive", userTheme)(`v${version}`)} `;
255
+ const compactBorderTitle = color("claude", userTheme)(" CTX ");
256
256
  if (layoutMode === "compact") {
257
257
  let welcomeMessage = formatWelcomeMessage(username);
258
258
  if (stringWidth(welcomeMessage) > columns - 4) {
@@ -335,7 +335,7 @@ export function LogoV2() {
335
335
  t18 = $[42];
336
336
  t19 = $[43];
337
337
  }
338
- return _jsxs(_Fragment, { children: [_jsx(OffscreenFreeze, { children: _jsxs(Box, { flexDirection: "column", borderStyle: "round", borderColor: "claude", borderText: t11, paddingX: 1, paddingY: 1, alignItems: "center", width: columns, children: [_jsx(Text, { bold: true, children: welcomeMessage }), t12, t13, _jsx(Text, { dimColor: true, children: billingType }), agentName ? _jsxs(Text, { dimColor: true, children: ["@", agentName] }) : null, _jsx(Text, { dimColor: true, children: truncatedCwd })] }) }), t14, t15, t16, t17, t18, t19] });
338
+ return _jsxs(_Fragment, { children: [_jsx(OffscreenFreeze, { children: _jsxs(Box, { flexDirection: "column", borderStyle: "round", borderColor: "claude", borderText: t11, paddingX: 2, paddingY: 1, alignItems: "center", width: columns, children: [_jsx(Text, { color: "claude", children: "CTX" }), _jsx(Text, { bold: true, children: welcomeMessage }), t12, _jsx(Text, { dimColor: true, children: modelDisplayName }), _jsx(Text, { dimColor: true, children: billingType }), agentName ? _jsxs(Text, { dimColor: true, children: ["@", agentName] }) : null, _jsx(Text, { dimColor: true, children: truncatedCwd })] }) }), t14, t15, t16, t17, t18, t19] });
339
339
  }
340
340
  const welcomeMessage_0 = formatWelcomeMessage(username);
341
341
  const modelLine = !process.env.IS_DEMO && config.oauthAccount?.organizationName ? `${modelDisplayName} · ${billingType} · ${config.oauthAccount.organizationName}` : `${modelDisplayName} · ${billingType}`;
@@ -364,9 +364,9 @@ export function LogoV2() {
364
364
  t14 = $[45];
365
365
  }
366
366
  const T2 = Box;
367
- const t15 = layoutMode === "horizontal" ? "row" : "column";
368
- const t16 = 1;
369
- const t17 = 1;
367
+ const t15 = "column";
368
+ const t16 = 2;
369
+ const t17 = 2;
370
370
  let t18;
371
371
  if ($[46] !== welcomeMessage_0) {
372
372
  t18 = _jsx(Box, { marginTop: 1, children: _jsx(Text, { bold: true, children: welcomeMessage_0 }) });
@@ -404,7 +404,7 @@ export function LogoV2() {
404
404
  }
405
405
  let t22;
406
406
  if ($[53] !== t20 || $[54] !== t21) {
407
- t22 = _jsxs(Box, { flexDirection: "column", alignItems: "center", children: [t20, t21] });
407
+ t22 = _jsxs(Box, { flexDirection: "column", alignItems: "center", children: [_jsx(Text, { color: "claude", children: "CTX" }), t20, t21] });
408
408
  $[53] = t20;
409
409
  $[54] = t21;
410
410
  $[55] = t22;
@@ -414,7 +414,7 @@ export function LogoV2() {
414
414
  }
415
415
  let t23;
416
416
  if ($[56] !== leftWidth || $[57] !== t18 || $[58] !== t22) {
417
- t23 = _jsxs(Box, { flexDirection: "column", width: leftWidth, justifyContent: "space-between", alignItems: "center", minHeight: 9, children: [t18, t19, t22] });
417
+ t23 = _jsxs(Box, { flexDirection: "column", width: leftWidth, justifyContent: "space-between", alignItems: "center", minHeight: 11, children: [t18, t19, t22] });
418
418
  $[56] = leftWidth;
419
419
  $[57] = t18;
420
420
  $[58] = t22;
@@ -425,14 +425,14 @@ export function LogoV2() {
425
425
  }
426
426
  let t24;
427
427
  if ($[60] !== layoutMode) {
428
- t24 = layoutMode === "horizontal" && _jsx(Box, { height: "100%", borderStyle: "single", borderColor: "claude", borderDimColor: true, borderTop: false, borderBottom: false, borderLeft: false });
428
+ t24 = null;
429
429
  $[60] = layoutMode;
430
430
  $[61] = t24;
431
431
  }
432
432
  else {
433
433
  t24 = $[61];
434
434
  }
435
- const t25 = layoutMode === "horizontal" && _jsx(FeedColumn, { feeds: showOnboarding ? [createProjectOnboardingFeed(getSteps()), createRecentActivityFeed(activities)] : showGuestPassesUpsell ? [createRecentActivityFeed(activities), createGuestPassesFeed()] : showOverageCreditUpsell ? [createRecentActivityFeed(activities), createOverageCreditFeed()] : [createRecentActivityFeed(activities), createWhatsNewFeed(changelog)], maxWidth: rightWidth });
435
+ const t25 = _jsx(FeedColumn, { feeds: showOnboarding ? [createProjectOnboardingFeed(getSteps()), createRecentActivityFeed(activities)] : showGuestPassesUpsell ? [createRecentActivityFeed(activities), createGuestPassesFeed()] : showOverageCreditUpsell ? [createRecentActivityFeed(activities), createOverageCreditFeed()] : [createRecentActivityFeed(activities), createWhatsNewFeed(changelog)], maxWidth: Math.max(leftWidth, rightWidth) });
436
436
  let t26;
437
437
  if ($[62] !== T2 || $[63] !== t15 || $[64] !== t23 || $[65] !== t24 || $[66] !== t25) {
438
438
  t26 = _jsxs(T2, { flexDirection: t15, paddingX: t16, gap: t17, children: [t23, t24, t25] });
@@ -4,5 +4,5 @@ import { Box, Text } from '../../ink.js';
4
4
  import { Clawd } from './Clawd.js';
5
5
  const WELCOME_WIDTH = 54;
6
6
  export function WelcomeV2() {
7
- return (_jsx(Box, { flexDirection: "column", width: WELCOME_WIDTH, children: _jsxs(Box, { borderStyle: "round", borderColor: "claude", paddingX: 2, paddingY: 1, flexDirection: "column", alignItems: "center", children: [_jsx(Text, { color: "claude", bold: true, children: "CONTEXT CODE" }), _jsxs(Text, { dimColor: true, children: ["v", MACRO.VERSION] }), _jsx(Box, { marginY: 1, children: _jsx(Clawd, {}) }), _jsx(Text, { children: "Lee el proyecto. Ejecuta cambios. Mant\u00E9n contexto." }), _jsx(Text, { dimColor: true, children: "Configuraci\u00F3n inicial del entorno" })] }) }));
7
+ return (_jsx(Box, { flexDirection: "column", width: WELCOME_WIDTH, children: _jsxs(Box, { borderStyle: "round", borderColor: "claude", paddingX: 3, paddingY: 1, flexDirection: "column", alignItems: "center", children: [_jsx(Text, { color: "claude", children: "CTX" }), _jsx(Text, { bold: true, children: "Context Code" }), _jsxs(Text, { dimColor: true, children: ["v", MACRO.VERSION] }), _jsx(Box, { marginTop: 1, marginBottom: 1, children: _jsx(Clawd, {}) }), _jsx(Text, { children: "Lee, edita y ejecuta sin perder contexto." }), _jsx(Text, { dimColor: true, children: "Configuracion inicial" })] }) }));
8
8
  }
@@ -1,62 +1,214 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { c as _c } from "react/compiler-runtime";
2
+ import * as React from 'react';
3
3
  import { Box, Text } from '../../ink.js';
4
- import { getAgentModelOptions } from '../../utils/model/agent.js';
5
- import { Select } from '../CustomSelect/select.js';
6
- export function ModelSelector(t0) {
7
- const $ = _c(11);
8
- const { initialModel, onComplete, onCancel } = t0;
9
- let t1;
10
- if ($[0] !== initialModel) {
11
- bb0: {
12
- const base = getAgentModelOptions();
13
- if (initialModel && !base.some(o => o.value === initialModel)) {
14
- t1 = [{
15
- value: initialModel,
16
- label: initialModel,
17
- description: "Current model (custom ID)"
18
- }, ...base];
19
- break bb0;
20
- }
21
- t1 = base;
22
- }
23
- $[0] = initialModel;
24
- $[1] = t1;
25
- }
26
- else {
27
- t1 = $[1];
4
+ import { getAgentModelDisplay, getAgentModelOptions, } from '../../utils/model/agent.js';
5
+ import { fetchProviderModels, } from '../../utils/model/providerModels.js';
6
+ import { getVisibleProvider, VISIBLE_PROVIDERS, } from '../../utils/model/providerCatalog.js';
7
+ import { toProviderPreference } from '../../utils/model/providerSwitch.js';
8
+ import { getAPIProvider } from '../../utils/model/providers.js';
9
+ import { Select, } from '../CustomSelect/select.js';
10
+ const INHERIT_OPTION = '__inherit_parent__';
11
+ const MANUAL_MODEL_OPTION = '__manual_model__';
12
+ function isClaudeProvider(provider) {
13
+ return provider === 'claude';
14
+ }
15
+ function inferInitialProvider(initialModel, initialProvider) {
16
+ if (initialProvider) {
17
+ return initialProvider;
28
18
  }
29
- const modelOptions = t1;
30
- const defaultModel = initialModel ?? "sonnet";
31
- let t2;
32
- if ($[2] === Symbol.for("react.memo_cache_sentinel")) {
33
- t2 = _jsx(Box, { marginBottom: 1, children: _jsx(Text, { dimColor: true, children: "Model determines the agent's reasoning capabilities and speed." }) });
34
- $[2] = t2;
19
+ if (!initialModel || initialModel === 'inherit') {
20
+ return undefined;
35
21
  }
36
- else {
37
- t2 = $[2];
22
+ const claudeValues = new Set(getAgentModelOptions().map(option => option.value));
23
+ if (claudeValues.has(initialModel)) {
24
+ return 'claude';
38
25
  }
39
- let t3;
40
- if ($[3] !== onCancel || $[4] !== onComplete) {
41
- t3 = () => onCancel ? onCancel() : onComplete(undefined);
42
- $[3] = onCancel;
43
- $[4] = onComplete;
44
- $[5] = t3;
26
+ return toProviderPreference(getAPIProvider());
27
+ }
28
+ function getProviderOptions() {
29
+ return [
30
+ {
31
+ value: INHERIT_OPTION,
32
+ label: 'Heredar del padre',
33
+ description: 'Usa el mismo proveedor y modelo de la conversacion principal.',
34
+ },
35
+ ...VISIBLE_PROVIDERS.map(provider => ({
36
+ value: provider.id,
37
+ label: provider.label,
38
+ description: provider.description,
39
+ })),
40
+ ];
41
+ }
42
+ function mapClaudeModelOptions() {
43
+ return getAgentModelOptions()
44
+ .filter(option => option.value !== 'inherit')
45
+ .map(option => ({
46
+ value: option.value,
47
+ label: option.label,
48
+ description: option.description,
49
+ }));
50
+ }
51
+ function mapDynamicModelOptions(models) {
52
+ return models.map(model => ({
53
+ value: model.value,
54
+ label: model.label,
55
+ description: model.description,
56
+ }));
57
+ }
58
+ function ensureCurrentModelOption(options, provider, initialModel) {
59
+ if (!initialModel || initialModel === 'inherit') {
60
+ return options;
45
61
  }
46
- else {
47
- t3 = $[5];
62
+ if (options.some(option => option.value === initialModel)) {
63
+ return options;
48
64
  }
49
- let t4;
50
- if ($[6] !== defaultModel || $[7] !== modelOptions || $[8] !== onComplete || $[9] !== t3) {
51
- t4 = _jsxs(Box, { flexDirection: "column", children: [t2, _jsx(Select, { options: modelOptions, defaultValue: defaultModel, onChange: onComplete, onCancel: t3 })] });
52
- $[6] = defaultModel;
53
- $[7] = modelOptions;
54
- $[8] = onComplete;
55
- $[9] = t3;
56
- $[10] = t4;
65
+ return [
66
+ {
67
+ value: initialModel,
68
+ label: getAgentModelDisplay(initialModel, provider),
69
+ description: 'Modelo actual guardado manualmente.',
70
+ },
71
+ ...options,
72
+ ];
73
+ }
74
+ function toApiProvider(provider) {
75
+ switch (provider) {
76
+ case 'claude':
77
+ return 'firstParty';
78
+ case 'openai':
79
+ return 'openai';
80
+ case 'openrouter':
81
+ return 'openrouter';
82
+ case 'ollama':
83
+ return 'ollama';
84
+ case 'ollama-cloud':
85
+ return 'ollama-cloud';
86
+ case 'gemini-api':
87
+ return 'gemini-api';
88
+ case 'gemini-google':
89
+ return 'gemini-google';
90
+ case 'zai':
91
+ return 'zai';
92
+ case 'minimax':
93
+ return 'minimax';
57
94
  }
58
- else {
59
- t4 = $[10];
95
+ }
96
+ export function ModelSelector({ initialModel, initialProvider, onComplete, onCancel, }) {
97
+ const inferredProvider = React.useMemo(() => inferInitialProvider(initialModel, initialProvider), [initialModel, initialProvider]);
98
+ const [step, setStep] = React.useState(inferredProvider ? 'model' : 'provider');
99
+ const [selectedProvider, setSelectedProvider] = React.useState(inferredProvider);
100
+ const [manualModel, setManualModel] = React.useState(initialModel && initialModel !== 'inherit' ? initialModel : '');
101
+ const [providerModels, setProviderModels] = React.useState([]);
102
+ const [isLoadingModels, setIsLoadingModels] = React.useState(false);
103
+ const [loadError, setLoadError] = React.useState(null);
104
+ React.useEffect(() => {
105
+ if (!selectedProvider || isClaudeProvider(selectedProvider)) {
106
+ setProviderModels([]);
107
+ setIsLoadingModels(false);
108
+ setLoadError(null);
109
+ return;
110
+ }
111
+ let cancelled = false;
112
+ const loadModels = async () => {
113
+ setIsLoadingModels(true);
114
+ setLoadError(null);
115
+ try {
116
+ const models = await fetchProviderModels(toApiProvider(selectedProvider));
117
+ if (cancelled) {
118
+ return;
119
+ }
120
+ setProviderModels(models);
121
+ if (models.length === 0) {
122
+ const providerLabel = getVisibleProvider(selectedProvider).label;
123
+ setLoadError(`No se pudieron cargar modelos de ${providerLabel}. Puedes escribir el ID manualmente.`);
124
+ }
125
+ }
126
+ catch (error) {
127
+ if (cancelled) {
128
+ return;
129
+ }
130
+ setProviderModels([]);
131
+ setLoadError(error instanceof Error
132
+ ? error.message
133
+ : 'No se pudieron cargar los modelos del proveedor.');
134
+ }
135
+ finally {
136
+ if (!cancelled) {
137
+ setIsLoadingModels(false);
138
+ }
139
+ }
140
+ };
141
+ void loadModels();
142
+ return () => {
143
+ cancelled = true;
144
+ };
145
+ }, [selectedProvider]);
146
+ const providerOptions = React.useMemo(() => getProviderOptions(), []);
147
+ const modelOptions = React.useMemo(() => {
148
+ if (!selectedProvider) {
149
+ return [];
150
+ }
151
+ const baseOptions = isClaudeProvider(selectedProvider)
152
+ ? mapClaudeModelOptions()
153
+ : mapDynamicModelOptions(providerModels);
154
+ const optionsWithCurrent = ensureCurrentModelOption(baseOptions, selectedProvider, initialModel);
155
+ const withManualOption = [
156
+ ...optionsWithCurrent,
157
+ {
158
+ type: 'input',
159
+ value: MANUAL_MODEL_OPTION,
160
+ label: 'Modelo manual',
161
+ description: 'Escribe el ID exacto si no aparece en la lista.',
162
+ placeholder: 'ID del modelo',
163
+ initialValue: manualModel,
164
+ onChange: value => setManualModel(value),
165
+ },
166
+ ];
167
+ return withManualOption;
168
+ }, [initialModel, manualModel, providerModels, selectedProvider]);
169
+ const providerDescription = selectedProvider
170
+ ? getVisibleProvider(selectedProvider).label
171
+ : undefined;
172
+ const defaultModelValue = React.useMemo(() => {
173
+ if (!selectedProvider) {
174
+ return undefined;
175
+ }
176
+ if (!initialModel || initialModel === 'inherit') {
177
+ return modelOptions[0]?.value;
178
+ }
179
+ return modelOptions.some(option => option.value === initialModel)
180
+ ? initialModel
181
+ : MANUAL_MODEL_OPTION;
182
+ }, [initialModel, modelOptions, selectedProvider]);
183
+ if (step === 'provider') {
184
+ return (_jsxs(Box, { flexDirection: "column", children: [_jsx(Box, { marginBottom: 1, children: _jsx(Text, { dimColor: true, children: "Elige si este agente debe heredar el proveedor del hilo o quedar fijo a un proveedor concreto." }) }), _jsx(Select, { options: providerOptions, defaultValue: selectedProvider ? selectedProvider : INHERIT_OPTION, layout: "compact-vertical", onChange: value => {
185
+ if (value === INHERIT_OPTION) {
186
+ onComplete({ model: 'inherit' });
187
+ return;
188
+ }
189
+ setSelectedProvider(value);
190
+ setStep('model');
191
+ }, onCancel: onCancel })] }));
60
192
  }
61
- return t4;
193
+ return (_jsxs(Box, { flexDirection: "column", children: [_jsxs(Box, { marginBottom: 1, flexDirection: "column", children: [_jsx(Text, { dimColor: true, children: providerDescription
194
+ ? `Proveedor seleccionado: ${providerDescription}`
195
+ : 'Proveedor seleccionado' }), _jsx(Text, { dimColor: true, children: "Para volver a elegir proveedor, presiona `Esc`." })] }), isLoadingModels ? (_jsx(Text, { dimColor: true, children: "Cargando modelos..." })) : (_jsx(Select, { options: modelOptions, defaultValue: defaultModelValue, layout: "compact-vertical", onChange: value => {
196
+ if (value === MANUAL_MODEL_OPTION) {
197
+ const trimmed = manualModel.trim();
198
+ if (!trimmed) {
199
+ return;
200
+ }
201
+ onComplete({
202
+ provider: selectedProvider,
203
+ model: trimmed,
204
+ });
205
+ return;
206
+ }
207
+ onComplete({
208
+ provider: selectedProvider,
209
+ model: value,
210
+ });
211
+ }, onCancel: () => {
212
+ setStep('provider');
213
+ } })), loadError ? (_jsx(Box, { marginTop: 1, children: _jsx(Text, { color: "warning", children: loadError }) })) : null] }));
62
214
  }
@@ -2,6 +2,7 @@ import { capitalize } from '../stringUtils.js';
2
2
  import { MODEL_ALIASES } from './aliases.js';
3
3
  import { applyBedrockRegionPrefix, getBedrockRegionPrefix } from './bedrock.js';
4
4
  import { getCanonicalName, getRuntimeMainLoopModel, parseUserSpecifiedModel, } from './model.js';
5
+ import { getVisibleProvider } from './providerCatalog.js';
5
6
  import { getAPIProvider } from './providers.js';
6
7
  export const AGENT_MODEL_OPTIONS = [...MODEL_ALIASES, 'inherit'];
7
8
  /**
@@ -91,14 +92,22 @@ function aliasMatchesParentTier(alias, parentModel) {
91
92
  return false;
92
93
  }
93
94
  }
94
- export function getAgentModelDisplay(model) {
95
+ export function getAgentModelDisplay(model, provider) {
95
96
  // When model is omitted, getDefaultSubagentModel() returns 'inherit' at runtime
96
97
  if (!model)
97
- return 'Inherit from parent (default)';
98
+ return 'Heredar del padre (predeterminado)';
98
99
  if (model === 'inherit')
99
- return 'Inherit from parent';
100
+ return 'Heredar del padre';
101
+ if (provider && provider !== 'claude')
102
+ return model;
100
103
  return capitalize(model);
101
104
  }
105
+ export function getAgentProviderDisplay(provider) {
106
+ if (!provider) {
107
+ return 'Heredar del padre';
108
+ }
109
+ return getVisibleProvider(provider).label;
110
+ }
102
111
  /**
103
112
  * Get available model options for agents
104
113
  */
@@ -0,0 +1,11 @@
1
+ import { AsyncLocalStorage } from 'async_hooks';
2
+ const providerOverrideStorage = new AsyncLocalStorage();
3
+ export function getProviderOverride() {
4
+ return providerOverrideStorage.getStore();
5
+ }
6
+ export function runWithProviderOverride(provider, fn) {
7
+ if (!provider) {
8
+ return fn();
9
+ }
10
+ return providerOverrideStorage.run(provider, fn);
11
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@iaforged/context-code",
3
- "version": "1.0.80",
3
+ "version": "1.0.81",
4
4
  "description": "Context Code es un asistente de desarrollo para la terminal. Puede revisar tu proyecto, editar archivos, ejecutar comandos y apoyarte en tareas reales de programacion.",
5
5
  "author": "Context AI",
6
6
  "license": "MIT",