@nick848/sf-cli 1.0.15 → 1.0.16

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.mjs CHANGED
@@ -7576,25 +7576,21 @@ ${chalk9.yellow("\u793A\u4F8B:")}
7576
7576
 
7577
7577
  // src/commands/model.ts
7578
7578
  init_esm_shims();
7579
-
7580
- // src/services/index.ts
7581
- init_esm_shims();
7582
-
7583
- // src/commands/model.ts
7584
7579
  async function handleModel(args, ctx) {
7585
7580
  const subCommand = args[0];
7586
7581
  const configManager = ctx.configManager;
7582
+ const modelService = ctx.modelService;
7587
7583
  switch (subCommand) {
7588
7584
  case "list":
7589
7585
  return listModels();
7590
7586
  case "current":
7591
7587
  return showCurrentModel(configManager);
7592
7588
  case "set":
7593
- return setModelDirectly(args[1], configManager);
7589
+ return setModelDirectly(args[1], configManager, modelService);
7594
7590
  case "verify":
7595
7591
  return verifyCurrentModel(configManager);
7596
7592
  default:
7597
- return selectModel(configManager);
7593
+ return selectModel(configManager, modelService);
7598
7594
  }
7599
7595
  }
7600
7596
  async function listModels() {
@@ -7635,7 +7631,7 @@ async function showCurrentModel(configManager) {
7635
7631
  ];
7636
7632
  return { output: lines.join("\n") };
7637
7633
  }
7638
- async function setModelDirectly(modelId, configManager) {
7634
+ async function setModelDirectly(modelId, configManager, modelService) {
7639
7635
  if (!modelId) {
7640
7636
  return {
7641
7637
  output: chalk9.red("\u8BF7\u6307\u5B9A\u6A21\u578BID\uFF0C\u4F8B\u5982: /model set gpt-4o")
@@ -7650,11 +7646,22 @@ async function setModelDirectly(modelId, configManager) {
7650
7646
  }
7651
7647
  configManager.set("model", modelId);
7652
7648
  await configManager.save();
7649
+ const apiKey = configManager.get("apiKey");
7650
+ if (apiKey) {
7651
+ try {
7652
+ await modelService.configureModel({
7653
+ provider: modelInfo.provider,
7654
+ model: modelId,
7655
+ apiKey
7656
+ });
7657
+ } catch {
7658
+ }
7659
+ }
7653
7660
  return {
7654
7661
  output: chalk9.green(`\u2713 \u5DF2\u5207\u6362\u5230\u6A21\u578B: ${modelInfo.name} (${modelInfo.provider})`)
7655
7662
  };
7656
7663
  }
7657
- async function verifyCurrentModel(configManager) {
7664
+ async function verifyCurrentModel(configManager, modelService) {
7658
7665
  const currentModel = configManager.get("model");
7659
7666
  const apiKey = configManager.get("apiKey");
7660
7667
  if (!apiKey) {
@@ -7687,7 +7694,7 @@ async function verifyCurrentModel(configManager) {
7687
7694
  };
7688
7695
  }
7689
7696
  }
7690
- async function selectModel(configManager) {
7697
+ async function selectModel(configManager, modelService) {
7691
7698
  try {
7692
7699
  const currentModel = configManager.get("model");
7693
7700
  const currentApiKey = configManager.get("apiKey");
@@ -7751,6 +7758,11 @@ async function selectModel(configManager) {
7751
7758
  configManager.set("model", modelResponse.model);
7752
7759
  configManager.set("apiKey", apiKeyResponse.apiKey);
7753
7760
  await configManager.save();
7761
+ await modelService.configureModel({
7762
+ provider: selectedModel.provider,
7763
+ model: modelResponse.model,
7764
+ apiKey: apiKeyResponse.apiKey
7765
+ });
7754
7766
  return {
7755
7767
  output: chalk9.green(`
7756
7768
  \u2713 \u6A21\u578B\u914D\u7F6E\u5B8C\u6210