deepcode-ai 1.1.34 → 1.1.36
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 +75 -19
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -3359,6 +3359,7 @@ function isSimpleDirectCommand(input) {
|
|
|
3359
3359
|
}
|
|
3360
3360
|
function resolveExecutionTarget(config, session, mode, explicitProvider) {
|
|
3361
3361
|
const modeOverride = config.modeDefaults?.[mode];
|
|
3362
|
+
const hasPinnedProvider = Boolean(explicitProvider ?? modeOverride?.provider) || session.metadata.providerPinned === true;
|
|
3362
3363
|
const provider = explicitProvider ?? modeOverride?.provider ?? session.provider ?? config.defaultProvider ?? resolveUsableProviderTarget(config, []).provider;
|
|
3363
3364
|
const modeModel = modeOverride?.provider && modeOverride.provider !== provider ? void 0 : modeOverride?.model;
|
|
3364
3365
|
const model = modeModel ?? (provider === session.provider ? session.model : void 0) ?? resolveConfiguredModelForProvider(config, provider);
|
|
@@ -3368,6 +3369,9 @@ function resolveExecutionTarget(config, session, mode, explicitProvider) {
|
|
|
3368
3369
|
if (hasProviderCredentials(config.providers[provider], provider) && model) {
|
|
3369
3370
|
return { provider, model };
|
|
3370
3371
|
}
|
|
3372
|
+
if (hasPinnedProvider) {
|
|
3373
|
+
return { provider, model };
|
|
3374
|
+
}
|
|
3371
3375
|
const fallback = resolveUsableProviderTarget(config, [
|
|
3372
3376
|
explicitProvider,
|
|
3373
3377
|
modeOverride?.provider,
|
|
@@ -10579,7 +10583,7 @@ function resolveSessionTarget(config, overrides = {}) {
|
|
|
10579
10583
|
requestedProvider,
|
|
10580
10584
|
config.defaultProvider
|
|
10581
10585
|
]);
|
|
10582
|
-
const parsedSelection = overrides.model ? parseModelSelection(overrides.model,
|
|
10586
|
+
const parsedSelection = overrides.model ? requestedProvider ? { provider: requestedProvider, model: overrides.model.trim() } : parseModelSelection(overrides.model, fallback.provider) : null;
|
|
10583
10587
|
if (overrides.model && !parsedSelection) {
|
|
10584
10588
|
throw new Error(
|
|
10585
10589
|
`Invalid model selection: ${overrides.model}. Use "<model>" or "<provider>/<model>".`
|
|
@@ -25863,7 +25867,7 @@ function useCommandCompletion(buffer, cwd, slashCommands, commandContext, revers
|
|
|
25863
25867
|
const handleAutocomplete = useCallback12(
|
|
25864
25868
|
(indexToUse) => {
|
|
25865
25869
|
if (indexToUse < 0 || indexToUse >= suggestions.length) {
|
|
25866
|
-
return;
|
|
25870
|
+
return null;
|
|
25867
25871
|
}
|
|
25868
25872
|
const suggestion = suggestions[indexToUse].value;
|
|
25869
25873
|
let start = completionStart;
|
|
@@ -25874,7 +25878,7 @@ function useCommandCompletion(buffer, cwd, slashCommands, commandContext, revers
|
|
|
25874
25878
|
end = lineOffset + slashCompletionRange.completionEnd;
|
|
25875
25879
|
}
|
|
25876
25880
|
if (start === -1 || end === -1) {
|
|
25877
|
-
return;
|
|
25881
|
+
return null;
|
|
25878
25882
|
}
|
|
25879
25883
|
let suggestionText = suggestion;
|
|
25880
25884
|
if (completionMode === "SLASH") {
|
|
@@ -25887,11 +25891,20 @@ function useCommandCompletion(buffer, cwd, slashCommands, commandContext, revers
|
|
|
25887
25891
|
if (charAfterCompletion !== " ") {
|
|
25888
25892
|
suggestionText += " ";
|
|
25889
25893
|
}
|
|
25894
|
+
const startOffset = logicalPosToOffset(buffer.lines, cursorRow, start);
|
|
25895
|
+
const endOffset = logicalPosToOffset(buffer.lines, cursorRow, end);
|
|
25896
|
+
const currentText = toCodePoints(buffer.text);
|
|
25897
|
+
const nextText = [
|
|
25898
|
+
...currentText.slice(0, startOffset),
|
|
25899
|
+
suggestionText,
|
|
25900
|
+
...currentText.slice(endOffset)
|
|
25901
|
+
].join("");
|
|
25890
25902
|
buffer.replaceRangeByOffset(
|
|
25891
|
-
|
|
25892
|
-
|
|
25903
|
+
startOffset,
|
|
25904
|
+
endOffset,
|
|
25893
25905
|
suggestionText
|
|
25894
25906
|
);
|
|
25907
|
+
return nextText;
|
|
25895
25908
|
},
|
|
25896
25909
|
[
|
|
25897
25910
|
cursorRow,
|
|
@@ -27104,22 +27117,22 @@ ${currentText}`);
|
|
|
27104
27117
|
}
|
|
27105
27118
|
const acceptActiveCompletionSuggestion = () => {
|
|
27106
27119
|
if (completion.suggestions.length === 0) {
|
|
27107
|
-
return
|
|
27120
|
+
return null;
|
|
27108
27121
|
}
|
|
27109
27122
|
const targetIndex = completion.activeSuggestionIndex === -1 ? 0 : completion.activeSuggestionIndex;
|
|
27110
27123
|
if (targetIndex >= completion.suggestions.length) {
|
|
27111
|
-
return
|
|
27124
|
+
return null;
|
|
27112
27125
|
}
|
|
27113
|
-
completion.handleAutocomplete(targetIndex);
|
|
27126
|
+
const completedText = completion.handleAutocomplete(targetIndex);
|
|
27114
27127
|
exportCompletion.navigatedRef.current = false;
|
|
27115
27128
|
setExpandedSuggestionIndex(-1);
|
|
27116
|
-
return
|
|
27129
|
+
return completedText;
|
|
27117
27130
|
};
|
|
27118
27131
|
if (completion.isPerfectMatch && keyMatchers[
|
|
27119
27132
|
"return"
|
|
27120
27133
|
/* RETURN */
|
|
27121
27134
|
](key)) {
|
|
27122
|
-
if (completion.showSuggestions && exportCompletion.navigatedRef.current && exportCompletion.navigatedTextRef.current === buffer.text && acceptActiveCompletionSuggestion()) {
|
|
27135
|
+
if (completion.showSuggestions && exportCompletion.navigatedRef.current && exportCompletion.navigatedTextRef.current === buffer.text && acceptActiveCompletionSuggestion() !== null) {
|
|
27123
27136
|
return true;
|
|
27124
27137
|
}
|
|
27125
27138
|
handleSubmitAndClear(buffer.text);
|
|
@@ -27162,9 +27175,9 @@ ${currentText}`);
|
|
|
27162
27175
|
"acceptSuggestion"
|
|
27163
27176
|
/* ACCEPT_SUGGESTION */
|
|
27164
27177
|
](key) && !key.paste) {
|
|
27165
|
-
const
|
|
27166
|
-
if (
|
|
27167
|
-
handleSubmitAndClear(
|
|
27178
|
+
const completedText = acceptActiveCompletionSuggestion();
|
|
27179
|
+
if (completedText !== null && key.name === "return" && isExactRunnableSlashCommand(completedText.trim(), slashCommands)) {
|
|
27180
|
+
handleSubmitAndClear(completedText);
|
|
27168
27181
|
}
|
|
27169
27182
|
return true;
|
|
27170
27183
|
}
|
|
@@ -28328,7 +28341,7 @@ function parseVersion2(version) {
|
|
|
28328
28341
|
if (!match) return null;
|
|
28329
28342
|
return [Number(match[1]), Number(match[2]), Number(match[3])];
|
|
28330
28343
|
}
|
|
28331
|
-
var VERSION = "1.1.
|
|
28344
|
+
var VERSION = "1.1.36".length > 0 ? "1.1.36" : "0.0.0-dev";
|
|
28332
28345
|
var updateCommand = {
|
|
28333
28346
|
name: "update",
|
|
28334
28347
|
description: "Check published DeepCode versions",
|
|
@@ -30085,7 +30098,9 @@ var AppContainer = ({ cwd, config, provider, model, resumeSessionId }) => {
|
|
|
30085
30098
|
if (!runtime || !session) return;
|
|
30086
30099
|
session.provider = provider2;
|
|
30087
30100
|
session.model = resolveConfiguredModelForProvider(runtime.config, provider2);
|
|
30101
|
+
session.metadata = { ...session.metadata, providerPinned: true };
|
|
30088
30102
|
runtime.sessions.save(session);
|
|
30103
|
+
writeSavedProvider(cwd, provider2, session.model);
|
|
30089
30104
|
setTargetSource("session");
|
|
30090
30105
|
setCurrentModel(session.model ?? "(unconfigured)");
|
|
30091
30106
|
setProviderLabel(formatProviderLabel(session.provider, session.model));
|
|
@@ -30098,18 +30113,20 @@ var AppContainer = ({ cwd, config, provider, model, resumeSessionId }) => {
|
|
|
30098
30113
|
Date.now()
|
|
30099
30114
|
);
|
|
30100
30115
|
}
|
|
30101
|
-
}, [historyManager]);
|
|
30116
|
+
}, [cwd, historyManager]);
|
|
30102
30117
|
const setSessionModel = useCallback26((model2) => {
|
|
30103
30118
|
const runtime = runtimeRef.current;
|
|
30104
30119
|
const session = sessionRef.current;
|
|
30105
30120
|
if (!runtime || !session) return;
|
|
30106
30121
|
const normalized2 = model2.trim();
|
|
30107
30122
|
session.model = normalized2.length > 0 ? normalized2 : void 0;
|
|
30123
|
+
session.metadata = { ...session.metadata, providerPinned: true };
|
|
30108
30124
|
runtime.sessions.save(session);
|
|
30125
|
+
writeSavedProvider(cwd, session.provider, session.model);
|
|
30109
30126
|
setTargetSource("session");
|
|
30110
30127
|
setCurrentModel(session.model ?? "(unconfigured)");
|
|
30111
30128
|
setProviderLabel(formatProviderLabel(session.provider, session.model));
|
|
30112
|
-
}, []);
|
|
30129
|
+
}, [cwd]);
|
|
30113
30130
|
const setSessionMode = useCallback26((mode) => {
|
|
30114
30131
|
setAgentMode(mode);
|
|
30115
30132
|
const runtime = runtimeRef.current;
|
|
@@ -30284,7 +30301,11 @@ var AppContainer = ({ cwd, config, provider, model, resumeSessionId }) => {
|
|
|
30284
30301
|
interactive: true
|
|
30285
30302
|
});
|
|
30286
30303
|
if (!mounted) return;
|
|
30287
|
-
const
|
|
30304
|
+
const savedProvider = !provider && !model ? readSavedProvider(cwd) : null;
|
|
30305
|
+
const target = resolveSessionTarget(runtime.config, {
|
|
30306
|
+
provider: provider ?? savedProvider?.provider,
|
|
30307
|
+
model: model ?? savedProvider?.model
|
|
30308
|
+
});
|
|
30288
30309
|
let session;
|
|
30289
30310
|
let resumed = false;
|
|
30290
30311
|
if (resumeSessionId) {
|
|
@@ -30296,10 +30317,17 @@ var AppContainer = ({ cwd, config, provider, model, resumeSessionId }) => {
|
|
|
30296
30317
|
session = existing;
|
|
30297
30318
|
if (provider) session.provider = target.provider;
|
|
30298
30319
|
if (model) session.model = target.model;
|
|
30320
|
+
if (provider || model) {
|
|
30321
|
+
session.metadata = { ...session.metadata, providerPinned: true };
|
|
30322
|
+
}
|
|
30299
30323
|
runtime.sessions.save(session);
|
|
30300
30324
|
resumed = true;
|
|
30301
30325
|
} else {
|
|
30302
30326
|
session = runtime.sessions.create(target);
|
|
30327
|
+
if (provider || model || savedProvider) {
|
|
30328
|
+
session.metadata = { ...session.metadata, providerPinned: true };
|
|
30329
|
+
runtime.sessions.save(session);
|
|
30330
|
+
}
|
|
30303
30331
|
addHistoryItem(
|
|
30304
30332
|
{ type: "warning", text: `Session ${resumeSessionId} not found; starting new session.` },
|
|
30305
30333
|
Date.now()
|
|
@@ -30307,6 +30335,10 @@ var AppContainer = ({ cwd, config, provider, model, resumeSessionId }) => {
|
|
|
30307
30335
|
}
|
|
30308
30336
|
} else {
|
|
30309
30337
|
session = runtime.sessions.create(target);
|
|
30338
|
+
if (provider || model || savedProvider) {
|
|
30339
|
+
session.metadata = { ...session.metadata, providerPinned: true };
|
|
30340
|
+
runtime.sessions.save(session);
|
|
30341
|
+
}
|
|
30310
30342
|
}
|
|
30311
30343
|
runtimeRef.current = runtime;
|
|
30312
30344
|
sessionRef.current = session;
|
|
@@ -30327,7 +30359,7 @@ var AppContainer = ({ cwd, config, provider, model, resumeSessionId }) => {
|
|
|
30327
30359
|
setAuthSummary(formatAuthSummary(runtime.config.github));
|
|
30328
30360
|
const persistedMode = typeof session.metadata.agentMode === "string" && (session.metadata.agentMode === "build" || session.metadata.agentMode === "plan") ? session.metadata.agentMode : runtime.config.agentMode;
|
|
30329
30361
|
setAgentMode(persistedMode);
|
|
30330
|
-
setTargetSource(provider || model ? "cli" : "config");
|
|
30362
|
+
setTargetSource(provider || model ? "cli" : savedProvider ? "session" : "config");
|
|
30331
30363
|
setCurrentModel(session.model ?? "(unconfigured)");
|
|
30332
30364
|
setProviderLabel(formatProviderLabel(session.provider, session.model));
|
|
30333
30365
|
setMcpConnected(runtime.mcp.connectedCount);
|
|
@@ -31070,7 +31102,9 @@ var AppContainer = ({ cwd, config, provider, model, resumeSessionId }) => {
|
|
|
31070
31102
|
if (session) {
|
|
31071
31103
|
session.provider = provider2;
|
|
31072
31104
|
session.model = configuredModel;
|
|
31105
|
+
session.metadata = { ...session.metadata, providerPinned: true };
|
|
31073
31106
|
runtime?.sessions.save(session);
|
|
31107
|
+
writeSavedProvider(cwd, provider2, configuredModel);
|
|
31074
31108
|
setProviderLabel(formatProviderLabel(session.provider, session.model));
|
|
31075
31109
|
setCurrentModel(session.model ?? "(unconfigured)");
|
|
31076
31110
|
}
|
|
@@ -31090,7 +31124,7 @@ var AppContainer = ({ cwd, config, provider, model, resumeSessionId }) => {
|
|
|
31090
31124
|
);
|
|
31091
31125
|
}
|
|
31092
31126
|
},
|
|
31093
|
-
[historyManager, persistConfig]
|
|
31127
|
+
[cwd, historyManager, persistConfig]
|
|
31094
31128
|
);
|
|
31095
31129
|
const handleTestProvider = useCallback26(
|
|
31096
31130
|
async (provider2) => {
|
|
@@ -31609,6 +31643,28 @@ function writeSavedTheme(cwd, themeName) {
|
|
|
31609
31643
|
fs8.writeFileSync(file, `${JSON.stringify({ theme: themeName }, null, 2)}
|
|
31610
31644
|
`);
|
|
31611
31645
|
}
|
|
31646
|
+
function tuiProviderFilePath(cwd) {
|
|
31647
|
+
return path15.join(cwd, ".deepcode", "tui-provider.json");
|
|
31648
|
+
}
|
|
31649
|
+
function readSavedProvider(cwd) {
|
|
31650
|
+
try {
|
|
31651
|
+
const parsed = JSON.parse(fs8.readFileSync(tuiProviderFilePath(cwd), "utf8"));
|
|
31652
|
+
const result = ProviderIdSchema.safeParse(parsed.provider);
|
|
31653
|
+
if (!result.success) return null;
|
|
31654
|
+
return {
|
|
31655
|
+
provider: result.data,
|
|
31656
|
+
model: typeof parsed.model === "string" ? parsed.model : void 0
|
|
31657
|
+
};
|
|
31658
|
+
} catch {
|
|
31659
|
+
return null;
|
|
31660
|
+
}
|
|
31661
|
+
}
|
|
31662
|
+
function writeSavedProvider(cwd, provider, model) {
|
|
31663
|
+
const file = tuiProviderFilePath(cwd);
|
|
31664
|
+
fs8.mkdirSync(path15.dirname(file), { recursive: true });
|
|
31665
|
+
fs8.writeFileSync(file, `${JSON.stringify({ provider, model }, null, 2)}
|
|
31666
|
+
`);
|
|
31667
|
+
}
|
|
31612
31668
|
function errorMessage(error) {
|
|
31613
31669
|
return error instanceof Error ? error.message : String(error);
|
|
31614
31670
|
}
|