@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.
@@ -36,7 +36,7 @@ var require_package = __commonJS({
36
36
  "package.json"(exports, module) {
37
37
  module.exports = {
38
38
  name: "@shi_zhen/code-helper",
39
- version: "0.1.5",
39
+ version: "0.1.6",
40
40
  description: "Code Helper - A unified tool to manage your Claude Code",
41
41
  repository: {
42
42
  type: "git",
@@ -694,6 +694,15 @@ function switchProfile(id) {
694
694
  if (profile.timeout) {
695
695
  settings.env.API_TIMEOUT_MS = profile.timeout;
696
696
  }
697
+ if (profile.haikuModel) {
698
+ settings.env.ANTHROPIC_DEFAULT_HAIKU_MODEL = profile.haikuModel;
699
+ }
700
+ if (profile.sonnetModel) {
701
+ settings.env.ANTHROPIC_DEFAULT_SONNET_MODEL = profile.sonnetModel;
702
+ }
703
+ if (profile.opusModel) {
704
+ settings.env.ANTHROPIC_DEFAULT_OPUS_MODEL = profile.opusModel;
705
+ }
697
706
  writeClaudeSettings(settings);
698
707
  config.currentProfileId = id;
699
708
  writeProfiles(config);
@@ -714,14 +723,14 @@ import ora from "ora";
714
723
  // src/cli/utils/api.ts
715
724
  import http from "http";
716
725
  import https from "https";
717
- async function verifyApiKey(baseUrl, apiKey) {
726
+ async function verifyApiKey(baseUrl, apiKey, model) {
718
727
  return new Promise((resolve) => {
719
728
  try {
720
729
  const url = new URL(baseUrl);
721
730
  const isHttps = url.protocol === "https:";
722
731
  const client = isHttps ? https : http;
723
732
  const testPayload = JSON.stringify({
724
- model: "claude-3-5-sonnet-20241022",
733
+ model: model || "claude-3-5-sonnet-20241022",
725
734
  max_tokens: 1,
726
735
  messages: [{ role: "user", content: "test" }]
727
736
  });
@@ -811,6 +820,15 @@ async function showAuthMenu() {
811
820
  console.log(
812
821
  `${theme.dim(" API Key:")} ${maskApiKey(currentProfile.apiKey)}`
813
822
  );
823
+ if (currentProfile.haikuModel) {
824
+ console.log(`${theme.dim(" Haiku Model:")} ${currentProfile.haikuModel}`);
825
+ }
826
+ if (currentProfile.sonnetModel) {
827
+ console.log(`${theme.dim(" Sonnet Model:")} ${currentProfile.sonnetModel}`);
828
+ }
829
+ if (currentProfile.opusModel) {
830
+ console.log(`${theme.dim(" Opus Model:")} ${currentProfile.opusModel}`);
831
+ }
814
832
  console.log();
815
833
  }
816
834
  const savedProfiles = getAllProfiles();
@@ -1114,9 +1132,49 @@ async function handleManualAuth() {
1114
1132
  }
1115
1133
  }
1116
1134
  ]);
1135
+ let haikuModel;
1136
+ let sonnetModel;
1137
+ let opusModel;
1138
+ const { configModels } = await inquirer.prompt([
1139
+ {
1140
+ type: "confirm",
1141
+ name: "configModels",
1142
+ 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",
1143
+ default: false
1144
+ }
1145
+ ]);
1146
+ if (configModels) {
1147
+ console.log();
1148
+ console.log(theme.dim("\u8BF7\u8F93\u5165\u5404\u6A21\u578B\u7684\u6620\u5C04\u540D\u79F0\uFF08\u76F4\u63A5\u56DE\u8F66\u8DF3\u8FC7\uFF09\uFF1A"));
1149
+ console.log();
1150
+ const modelAnswers = await inquirer.prompt([
1151
+ {
1152
+ type: "input",
1153
+ name: "haikuModel",
1154
+ message: "ANTHROPIC_DEFAULT_HAIKU_MODEL\uFF08\u5FEB\u901F\u6A21\u578B\uFF09:",
1155
+ default: ""
1156
+ },
1157
+ {
1158
+ type: "input",
1159
+ name: "sonnetModel",
1160
+ message: "ANTHROPIC_DEFAULT_SONNET_MODEL\uFF08\u5747\u8861\u6A21\u578B\uFF09:",
1161
+ default: ""
1162
+ },
1163
+ {
1164
+ type: "input",
1165
+ name: "opusModel",
1166
+ message: "ANTHROPIC_DEFAULT_OPUS_MODEL\uFF08\u6700\u5F3A\u6A21\u578B\uFF09:",
1167
+ default: ""
1168
+ }
1169
+ ]);
1170
+ if (modelAnswers.haikuModel?.trim()) haikuModel = modelAnswers.haikuModel.trim();
1171
+ if (modelAnswers.sonnetModel?.trim()) sonnetModel = modelAnswers.sonnetModel.trim();
1172
+ if (modelAnswers.opusModel?.trim()) opusModel = modelAnswers.opusModel.trim();
1173
+ }
1174
+ const verifyModel = sonnetModel || haikuModel || opusModel;
1117
1175
  console.log();
1118
1176
  const spinner = ora("\u6B63\u5728\u9A8C\u8BC1 API Key...").start();
1119
- const verification = await verifyApiKey(baseUrl.trim(), apiKey.trim());
1177
+ const verification = await verifyApiKey(baseUrl.trim(), apiKey.trim(), verifyModel);
1120
1178
  if (!verification.valid) {
1121
1179
  spinner.fail("API Key \u9A8C\u8BC1\u5931\u8D25");
1122
1180
  console.log();
@@ -1130,6 +1188,9 @@ async function handleManualAuth() {
1130
1188
  if (timeout && timeout.trim()) {
1131
1189
  options.timeout = timeout.trim();
1132
1190
  }
1191
+ if (haikuModel) options.haikuModel = haikuModel;
1192
+ if (sonnetModel) options.sonnetModel = sonnetModel;
1193
+ if (opusModel) options.opusModel = opusModel;
1133
1194
  await saveApiConfig(baseUrl.trim(), apiKey.trim(), options);
1134
1195
  console.log();
1135
1196
  showSuccess("\u914D\u7F6E\u5DF2\u751F\u6548");
@@ -1139,7 +1200,10 @@ async function handleManualAuth() {
1139
1200
  baseUrl.trim(),
1140
1201
  apiKey.trim(),
1141
1202
  void 0,
1142
- timeout && timeout.trim() ? timeout.trim() : void 0
1203
+ timeout && timeout.trim() ? timeout.trim() : void 0,
1204
+ haikuModel,
1205
+ sonnetModel,
1206
+ opusModel
1143
1207
  );
1144
1208
  } catch (error) {
1145
1209
  console.log();
@@ -1147,7 +1211,7 @@ async function handleManualAuth() {
1147
1211
  await waitForEnter();
1148
1212
  }
1149
1213
  }
1150
- async function askToSaveProfile(defaultName, baseUrl, apiKey, model, timeout) {
1214
+ async function askToSaveProfile(defaultName, baseUrl, apiKey, model, timeout, haikuModel, sonnetModel, opusModel) {
1151
1215
  console.log();
1152
1216
  const { save } = await inquirer.prompt([
1153
1217
  {
@@ -1176,7 +1240,10 @@ async function askToSaveProfile(defaultName, baseUrl, apiKey, model, timeout) {
1176
1240
  baseUrl,
1177
1241
  apiKey,
1178
1242
  model,
1179
- timeout
1243
+ timeout,
1244
+ haikuModel,
1245
+ sonnetModel,
1246
+ opusModel
1180
1247
  });
1181
1248
  switchProfile(newProfile.id);
1182
1249
  showSuccess(`\u914D\u7F6E "${name.trim()}" \u5DF2\u4FDD\u5B58`);