@shi_zhen/code-helper 0.1.5 → 0.1.6
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/index.js +74 -7
- package/dist/cli/index.js.map +1 -1
- package/dist/cli/index.mjs +74 -7
- package/dist/cli/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/cli/index.js
CHANGED
|
@@ -37,7 +37,7 @@ var require_package = __commonJS({
|
|
|
37
37
|
"package.json"(exports2, module2) {
|
|
38
38
|
module2.exports = {
|
|
39
39
|
name: "@shi_zhen/code-helper",
|
|
40
|
-
version: "0.1.
|
|
40
|
+
version: "0.1.6",
|
|
41
41
|
description: "Code Helper - A unified tool to manage your Claude Code",
|
|
42
42
|
repository: {
|
|
43
43
|
type: "git",
|
|
@@ -697,6 +697,15 @@ function switchProfile(id) {
|
|
|
697
697
|
if (profile.timeout) {
|
|
698
698
|
settings.env.API_TIMEOUT_MS = profile.timeout;
|
|
699
699
|
}
|
|
700
|
+
if (profile.haikuModel) {
|
|
701
|
+
settings.env.ANTHROPIC_DEFAULT_HAIKU_MODEL = profile.haikuModel;
|
|
702
|
+
}
|
|
703
|
+
if (profile.sonnetModel) {
|
|
704
|
+
settings.env.ANTHROPIC_DEFAULT_SONNET_MODEL = profile.sonnetModel;
|
|
705
|
+
}
|
|
706
|
+
if (profile.opusModel) {
|
|
707
|
+
settings.env.ANTHROPIC_DEFAULT_OPUS_MODEL = profile.opusModel;
|
|
708
|
+
}
|
|
700
709
|
writeClaudeSettings(settings);
|
|
701
710
|
config.currentProfileId = id;
|
|
702
711
|
writeProfiles(config);
|
|
@@ -717,14 +726,14 @@ var import_ora = __toESM(require("ora"));
|
|
|
717
726
|
// src/cli/utils/api.ts
|
|
718
727
|
var import_http = __toESM(require("http"));
|
|
719
728
|
var import_https = __toESM(require("https"));
|
|
720
|
-
async function verifyApiKey(baseUrl, apiKey) {
|
|
729
|
+
async function verifyApiKey(baseUrl, apiKey, model) {
|
|
721
730
|
return new Promise((resolve) => {
|
|
722
731
|
try {
|
|
723
732
|
const url = new URL(baseUrl);
|
|
724
733
|
const isHttps = url.protocol === "https:";
|
|
725
734
|
const client = isHttps ? import_https.default : import_http.default;
|
|
726
735
|
const testPayload = JSON.stringify({
|
|
727
|
-
model: "claude-3-5-sonnet-20241022",
|
|
736
|
+
model: model || "claude-3-5-sonnet-20241022",
|
|
728
737
|
max_tokens: 1,
|
|
729
738
|
messages: [{ role: "user", content: "test" }]
|
|
730
739
|
});
|
|
@@ -814,6 +823,15 @@ async function showAuthMenu() {
|
|
|
814
823
|
console.log(
|
|
815
824
|
`${theme.dim(" API Key:")} ${maskApiKey(currentProfile.apiKey)}`
|
|
816
825
|
);
|
|
826
|
+
if (currentProfile.haikuModel) {
|
|
827
|
+
console.log(`${theme.dim(" Haiku Model:")} ${currentProfile.haikuModel}`);
|
|
828
|
+
}
|
|
829
|
+
if (currentProfile.sonnetModel) {
|
|
830
|
+
console.log(`${theme.dim(" Sonnet Model:")} ${currentProfile.sonnetModel}`);
|
|
831
|
+
}
|
|
832
|
+
if (currentProfile.opusModel) {
|
|
833
|
+
console.log(`${theme.dim(" Opus Model:")} ${currentProfile.opusModel}`);
|
|
834
|
+
}
|
|
817
835
|
console.log();
|
|
818
836
|
}
|
|
819
837
|
const savedProfiles = getAllProfiles();
|
|
@@ -1117,9 +1135,49 @@ async function handleManualAuth() {
|
|
|
1117
1135
|
}
|
|
1118
1136
|
}
|
|
1119
1137
|
]);
|
|
1138
|
+
let haikuModel;
|
|
1139
|
+
let sonnetModel;
|
|
1140
|
+
let opusModel;
|
|
1141
|
+
const { configModels } = await import_inquirer.default.prompt([
|
|
1142
|
+
{
|
|
1143
|
+
type: "confirm",
|
|
1144
|
+
name: "configModels",
|
|
1145
|
+
message: "\u662F\u5426\u9700\u8981\u914D\u7F6E\u6A21\u578B\u6620\u5C04\uFF1F\uFF08\u7528\u4E8E ZenMux \u7B49\u9700\u8981\u81EA\u5B9A\u4E49\u6A21\u578B\u7684\u5E73\u53F0\uFF09",
|
|
1146
|
+
default: false
|
|
1147
|
+
}
|
|
1148
|
+
]);
|
|
1149
|
+
if (configModels) {
|
|
1150
|
+
console.log();
|
|
1151
|
+
console.log(theme.dim("\u8BF7\u8F93\u5165\u5404\u6A21\u578B\u7684\u6620\u5C04\u540D\u79F0\uFF08\u76F4\u63A5\u56DE\u8F66\u8DF3\u8FC7\uFF09\uFF1A"));
|
|
1152
|
+
console.log();
|
|
1153
|
+
const modelAnswers = await import_inquirer.default.prompt([
|
|
1154
|
+
{
|
|
1155
|
+
type: "input",
|
|
1156
|
+
name: "haikuModel",
|
|
1157
|
+
message: "ANTHROPIC_DEFAULT_HAIKU_MODEL\uFF08\u5FEB\u901F\u6A21\u578B\uFF09:",
|
|
1158
|
+
default: ""
|
|
1159
|
+
},
|
|
1160
|
+
{
|
|
1161
|
+
type: "input",
|
|
1162
|
+
name: "sonnetModel",
|
|
1163
|
+
message: "ANTHROPIC_DEFAULT_SONNET_MODEL\uFF08\u5747\u8861\u6A21\u578B\uFF09:",
|
|
1164
|
+
default: ""
|
|
1165
|
+
},
|
|
1166
|
+
{
|
|
1167
|
+
type: "input",
|
|
1168
|
+
name: "opusModel",
|
|
1169
|
+
message: "ANTHROPIC_DEFAULT_OPUS_MODEL\uFF08\u6700\u5F3A\u6A21\u578B\uFF09:",
|
|
1170
|
+
default: ""
|
|
1171
|
+
}
|
|
1172
|
+
]);
|
|
1173
|
+
if (modelAnswers.haikuModel?.trim()) haikuModel = modelAnswers.haikuModel.trim();
|
|
1174
|
+
if (modelAnswers.sonnetModel?.trim()) sonnetModel = modelAnswers.sonnetModel.trim();
|
|
1175
|
+
if (modelAnswers.opusModel?.trim()) opusModel = modelAnswers.opusModel.trim();
|
|
1176
|
+
}
|
|
1177
|
+
const verifyModel = sonnetModel || haikuModel || opusModel;
|
|
1120
1178
|
console.log();
|
|
1121
1179
|
const spinner = (0, import_ora.default)("\u6B63\u5728\u9A8C\u8BC1 API Key...").start();
|
|
1122
|
-
const verification = await verifyApiKey(baseUrl.trim(), apiKey.trim());
|
|
1180
|
+
const verification = await verifyApiKey(baseUrl.trim(), apiKey.trim(), verifyModel);
|
|
1123
1181
|
if (!verification.valid) {
|
|
1124
1182
|
spinner.fail("API Key \u9A8C\u8BC1\u5931\u8D25");
|
|
1125
1183
|
console.log();
|
|
@@ -1133,6 +1191,9 @@ async function handleManualAuth() {
|
|
|
1133
1191
|
if (timeout && timeout.trim()) {
|
|
1134
1192
|
options.timeout = timeout.trim();
|
|
1135
1193
|
}
|
|
1194
|
+
if (haikuModel) options.haikuModel = haikuModel;
|
|
1195
|
+
if (sonnetModel) options.sonnetModel = sonnetModel;
|
|
1196
|
+
if (opusModel) options.opusModel = opusModel;
|
|
1136
1197
|
await saveApiConfig(baseUrl.trim(), apiKey.trim(), options);
|
|
1137
1198
|
console.log();
|
|
1138
1199
|
showSuccess("\u914D\u7F6E\u5DF2\u751F\u6548");
|
|
@@ -1142,7 +1203,10 @@ async function handleManualAuth() {
|
|
|
1142
1203
|
baseUrl.trim(),
|
|
1143
1204
|
apiKey.trim(),
|
|
1144
1205
|
void 0,
|
|
1145
|
-
timeout && timeout.trim() ? timeout.trim() : void 0
|
|
1206
|
+
timeout && timeout.trim() ? timeout.trim() : void 0,
|
|
1207
|
+
haikuModel,
|
|
1208
|
+
sonnetModel,
|
|
1209
|
+
opusModel
|
|
1146
1210
|
);
|
|
1147
1211
|
} catch (error) {
|
|
1148
1212
|
console.log();
|
|
@@ -1150,7 +1214,7 @@ async function handleManualAuth() {
|
|
|
1150
1214
|
await waitForEnter();
|
|
1151
1215
|
}
|
|
1152
1216
|
}
|
|
1153
|
-
async function askToSaveProfile(defaultName, baseUrl, apiKey, model, timeout) {
|
|
1217
|
+
async function askToSaveProfile(defaultName, baseUrl, apiKey, model, timeout, haikuModel, sonnetModel, opusModel) {
|
|
1154
1218
|
console.log();
|
|
1155
1219
|
const { save } = await import_inquirer.default.prompt([
|
|
1156
1220
|
{
|
|
@@ -1179,7 +1243,10 @@ async function askToSaveProfile(defaultName, baseUrl, apiKey, model, timeout) {
|
|
|
1179
1243
|
baseUrl,
|
|
1180
1244
|
apiKey,
|
|
1181
1245
|
model,
|
|
1182
|
-
timeout
|
|
1246
|
+
timeout,
|
|
1247
|
+
haikuModel,
|
|
1248
|
+
sonnetModel,
|
|
1249
|
+
opusModel
|
|
1183
1250
|
});
|
|
1184
1251
|
switchProfile(newProfile.id);
|
|
1185
1252
|
showSuccess(`\u914D\u7F6E "${name.trim()}" \u5DF2\u4FDD\u5B58`);
|