engine7 7.1.54 → 7.1.55
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/cli.mjs +11 -6
- package/package.json +1 -1
package/dist/cli.mjs
CHANGED
|
@@ -1831,9 +1831,14 @@ async function ask(rl, question, defaultValue) {
|
|
|
1831
1831
|
});
|
|
1832
1832
|
});
|
|
1833
1833
|
}
|
|
1834
|
-
async function askChoice(rl, question, choices, defaultIdx = 0) {
|
|
1834
|
+
async function askChoice(rl, question, choices, defaultIdx = 0, current) {
|
|
1835
|
+
let currentIdx = -1;
|
|
1836
|
+
if (current) {
|
|
1837
|
+
currentIdx = choices.findIndex((c) => c === current || c.split(" ")[0] === current || current.startsWith(c.split(" ")[0]));
|
|
1838
|
+
}
|
|
1839
|
+
if (currentIdx >= 0) defaultIdx = currentIdx;
|
|
1835
1840
|
console.log(question);
|
|
1836
|
-
choices.forEach((c, i) => console.log(` ${i + 1}. ${c}`));
|
|
1841
|
+
choices.forEach((c, i) => console.log(` ${i + 1}. ${c}${i === currentIdx ? " \u2190\uFF08\u4E0A\u6B21\u5DF2\u9009\uFF09" : ""}`));
|
|
1837
1842
|
const answer = await ask(rl, `\u9009\u62E9 (1-${choices.length})`, String(defaultIdx + 1));
|
|
1838
1843
|
const idx = parseInt(answer, 10) - 1;
|
|
1839
1844
|
return choices[idx >= 0 && idx < choices.length ? idx : defaultIdx];
|
|
@@ -1950,12 +1955,12 @@ async function interactiveConfig(rl, defaults) {
|
|
|
1950
1955
|
"deepseek (DeepSeek)": "deepseek",
|
|
1951
1956
|
"custom (\u81EA\u5B9A\u4E49/\u5176\u4ED6 Anthropic \u517C\u5BB9\u7AEF\u70B9)": "custom"
|
|
1952
1957
|
};
|
|
1953
|
-
const chosenProvider = await askChoice(rl, "\u4E3B\u6A21\u578B Provider:", providers, 0);
|
|
1958
|
+
const chosenProvider = await askChoice(rl, "\u4E3B\u6A21\u578B Provider:", providers, 0, defaults.primaryProvider);
|
|
1954
1959
|
v.primaryProvider = providerMap[chosenProvider] || "dashscope";
|
|
1955
1960
|
v.zhipuPlan = "";
|
|
1956
1961
|
if (v.primaryProvider === "zhipu") {
|
|
1957
1962
|
const planOptions = ["coding-plan (GLM Coding \u8BA2\u9605\uFF0C\u5305\u6708)", "api-pay (API \u6309\u91CF\u4ED8\u8D39)"];
|
|
1958
|
-
const chosenPlan = await askChoice(rl, "\u667A\u8C31\u8BA2\u9605\u7C7B\u578B:", planOptions, 0);
|
|
1963
|
+
const chosenPlan = await askChoice(rl, "\u667A\u8C31\u8BA2\u9605\u7C7B\u578B:", planOptions, 0, defaults.zhipuPlan === "token" ? "api-pay" : defaults.zhipuPlan === "coding" ? "coding-plan" : void 0);
|
|
1959
1964
|
v.zhipuPlan = chosenPlan.startsWith("coding") ? "coding" : "token";
|
|
1960
1965
|
}
|
|
1961
1966
|
v.customBaseUrl = "";
|
|
@@ -1965,7 +1970,7 @@ async function interactiveConfig(rl, defaults) {
|
|
|
1965
1970
|
const isKnownCustom = defaults.primaryProvider !== "dashscope" && defaults.primaryProvider !== "minimax" && defaults.primaryProvider !== "zhipu" && defaults.primaryProvider !== "deepseek";
|
|
1966
1971
|
v.primaryProvider = await ask(rl, "Provider ID\uFF08\u5C0F\u5199\u5B57\u6BCD\uFF0C\u5982 kimi / moonshot / openrouter / zai\uFF09", isKnownCustom ? defaults.primaryProvider : "custom");
|
|
1967
1972
|
const apiOptions = ["anthropic (Anthropic \u517C\u5BB9\uFF0C\u63A8\u8350)", "openai-completions (OpenAI \u517C\u5BB9 /v1/chat/completions)"];
|
|
1968
|
-
const chosenApi = await askChoice(rl, "API \u7C7B\u578B:", apiOptions, 0);
|
|
1973
|
+
const chosenApi = await askChoice(rl, "API \u7C7B\u578B:", apiOptions, 0, defaults.customApi || void 0);
|
|
1969
1974
|
v.customApi = chosenApi.startsWith("anthropic") ? "anthropic" : "openai-completions";
|
|
1970
1975
|
const baseUrlExample = v.customApi === "anthropic" ? "\uFF08\u5982 https://api.moonshot.cn/anthropic\uFF09" : "\uFF08\u5982 https://api.deepinfra.com/v1/openai\uFF09";
|
|
1971
1976
|
v.customBaseUrl = await ask(rl, `baseUrl ${baseUrlExample}`, defaults.customBaseUrl || "");
|
|
@@ -1999,7 +2004,7 @@ async function interactiveConfig(rl, defaults) {
|
|
|
1999
2004
|
v.primaryModel = v.primaryProvider + "/" + v.customModelId;
|
|
2000
2005
|
} else if (modelMap[v.primaryProvider]) {
|
|
2001
2006
|
const models = modelMap[v.primaryProvider];
|
|
2002
|
-
v.primaryModel = await askChoice(rl, "\u4E3B\u6A21\u578B:", models, 0);
|
|
2007
|
+
v.primaryModel = await askChoice(rl, "\u4E3B\u6A21\u578B:", models, 0, defaults.primaryModel || void 0);
|
|
2003
2008
|
} else {
|
|
2004
2009
|
console.log("\u26A0\uFE0F \u8FD8\u7F3A\u6A21\u578B ID\uFF0C\u8865\u4E00\u4E0B\uFF1A");
|
|
2005
2010
|
v.customModelId = await ask(rl, "\u6A21\u578B ID\uFF08\u5982 glm-5.3 / kimi-k2-turbo-preview\uFF09");
|