yg-team-cli 2.1.4 → 2.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/index.js CHANGED
@@ -421,7 +421,7 @@ __export(user_config_exports, {
421
421
  userConfigManager: () => userConfigManager
422
422
  });
423
423
  import path5 from "path";
424
- import os from "os";
424
+ import os2 from "os";
425
425
  import crypto from "crypto";
426
426
  var UserConfigManager, userConfigManager;
427
427
  var init_user_config = __esm({
@@ -433,7 +433,7 @@ var init_user_config = __esm({
433
433
  UserConfigManager = class {
434
434
  configPath;
435
435
  constructor() {
436
- const configDir = path5.join(os.homedir(), ".team-cli");
436
+ const configDir = path5.join(os2.homedir(), ".team-cli");
437
437
  this.configPath = path5.join(configDir, "config.json");
438
438
  }
439
439
  /**
@@ -556,10 +556,10 @@ var init_user_config = __esm({
556
556
  * 获取机器特定密钥
557
557
  */
558
558
  getMachineKey() {
559
- const hostname = os.hostname();
560
- const platform = os.platform();
561
- const arch = os.arch();
562
- const cpus = os.cpus();
559
+ const hostname = os2.hostname();
560
+ const platform = os2.platform();
561
+ const arch = os2.arch();
562
+ const cpus = os2.cpus();
563
563
  const machineInfo = `${hostname}-${platform}-${arch}-${cpus[0]?.model || "unknown"}`;
564
564
  return crypto.createHash("sha256").update(machineInfo).digest();
565
565
  }
@@ -853,7 +853,7 @@ init_logger();
853
853
  import { Command } from "commander";
854
854
  import inquirer from "inquirer";
855
855
  import path6 from "path";
856
- import fs2 from "fs-extra";
856
+ import fs3 from "fs-extra";
857
857
 
858
858
  // src/lib/claude.ts
859
859
  init_esm_shims();
@@ -861,6 +861,8 @@ init_logger();
861
861
  init_utils();
862
862
  import { execa } from "execa";
863
863
  import path3 from "path";
864
+ import fs2 from "fs-extra";
865
+ import os from "os";
864
866
  var ClaudeAI = class {
865
867
  verbose;
866
868
  constructor(verbose = false) {
@@ -892,6 +894,8 @@ var ClaudeAI = class {
892
894
  * 发送 prompt 到 Claude
893
895
  */
894
896
  async prompt(promptText, options) {
897
+ const tempDir = os.tmpdir();
898
+ const tempFile = path3.join(tempDir, `team-cli-prompt-${Date.now()}.txt`);
895
899
  try {
896
900
  let finalPrompt = promptText;
897
901
  const validContextFiles = [];
@@ -926,21 +930,18 @@ ${promptText}`;
926
930
  }
927
931
  }
928
932
  }
929
- const args = ["-p", finalPrompt];
930
- const result = await execa("claude", args, {
933
+ await fs2.writeFile(tempFile, finalPrompt, "utf-8");
934
+ const result = await execa("claude", ["--dangerously-skip-permissions", tempFile], {
931
935
  stdio: "inherit",
932
936
  timeout: options?.timeout || 3e5
933
937
  // 默认 5 分钟
934
938
  });
935
939
  return result.stdout || "";
936
- } catch (error) {
937
- if (error.killed && error.signal === "SIGTERM") {
938
- throw new Error("Claude \u6267\u884C\u8D85\u65F6");
940
+ } finally {
941
+ try {
942
+ await fs2.remove(tempFile);
943
+ } catch {
939
944
  }
940
- const stderr = error.stderr || "";
941
- const exitCode = error.exitCode !== void 0 ? ` (\u9000\u51FA\u7801: ${error.exitCode})` : "";
942
- throw new Error(`Claude \u8C03\u7528\u5931\u8D25: ${error.message}${exitCode}${stderr ? `
943
- ${stderr}` : ""}`);
944
945
  }
945
946
  }
946
947
  /**
@@ -958,26 +959,24 @@ ${stderr}` : ""}`);
958
959
  * 发送对话(支持上下文)
959
960
  */
960
961
  async chat(messages, options) {
961
- const spinner = logger.startLoading("\u6B63\u5728\u8C03\u7528 Claude...");
962
+ const tempDir = os.tmpdir();
963
+ const tempFile = path3.join(tempDir, `team-cli-prompt-${Date.now()}.txt`);
962
964
  try {
963
965
  const fullPrompt = messages.map((msg) => {
964
966
  const role = msg.role === "system" ? "\u7CFB\u7EDF\u6307\u4EE4" : `${msg.role === "user" ? "\u7528\u6237" : "\u52A9\u624B"}`;
965
967
  return `[${role}]: ${msg.content}`;
966
968
  }).join("\n\n");
967
- const args = ["-p", fullPrompt];
968
- const result = await execa("claude", args, {
969
- stdio: this.verbose ? "inherit" : "pipe",
970
- timeout: options?.timeout || 3e5,
971
- reject: false
969
+ await fs2.writeFile(tempFile, fullPrompt, "utf-8");
970
+ const result = await execa("claude", ["--dangerously-skip-permissions", tempFile], {
971
+ stdio: "inherit",
972
+ timeout: options?.timeout || 3e5
972
973
  });
973
- spinner.succeed("Claude \u54CD\u5E94\u5B8C\u6210");
974
- if (result.exitCode !== 0 && !result.stdout) {
975
- throw new Error(`Claude \u547D\u4EE4\u6267\u884C\u5931\u8D25 (\u9000\u51FA\u7801: ${result.exitCode})`);
976
- }
977
974
  return result.stdout || "";
978
- } catch (error) {
979
- spinner.fail("Claude \u8C03\u7528\u5931\u8D25");
980
- throw error;
975
+ } finally {
976
+ try {
977
+ await fs2.remove(tempFile);
978
+ } catch {
979
+ }
981
980
  }
982
981
  }
983
982
  /**
@@ -2023,10 +2022,10 @@ async function cloneBackendTemplate(projectPath, versionOptions) {
2023
2022
  stdio: "pipe"
2024
2023
  });
2025
2024
  const latestTag = tags.split("\n")[0] || void 0;
2026
- await fs2.copy(tempDir, backendPath, {
2025
+ await fs3.copy(tempDir, backendPath, {
2027
2026
  filter: (src) => !src.includes(".git")
2028
2027
  });
2029
- await fs2.remove(tempDir);
2028
+ await fs3.remove(tempDir);
2030
2029
  const gitDir = path6.join(backendPath, ".git");
2031
2030
  if (await FileUtils.exists(gitDir)) {
2032
2031
  await FileUtils.remove(gitDir);
@@ -5017,7 +5016,7 @@ init_logger();
5017
5016
  init_utils();
5018
5017
  import { execa as execa4 } from "execa";
5019
5018
  import inquirer9 from "inquirer";
5020
- import fs3 from "fs-extra";
5019
+ import fs4 from "fs-extra";
5021
5020
  var updateCommand = new Command13("update").description("\u68C0\u67E5\u5E76\u66F4\u65B0\u6A21\u677F\u7248\u672C").option("-f, --frontend", "\u68C0\u67E5\u524D\u7AEF\u6A21\u677F\u66F4\u65B0").option("-b, --backend", "\u68C0\u67E5\u540E\u7AEF\u6A21\u677F\u66F4\u65B0").option("-a, --all", "\u68C0\u67E5\u6240\u6709\u6A21\u677F (\u9ED8\u8BA4)").option("-t, --tag <tag>", "\u66F4\u65B0\u5230\u6307\u5B9A\u6807\u7B7E").option("-B, --branch <branch>", "\u66F4\u65B0\u5230\u6307\u5B9A\u5206\u652F").option("--dry-run", "\u9884\u89C8\u66F4\u65B0\uFF0C\u4E0D\u5B9E\u9645\u6267\u884C").action(async (options) => {
5022
5021
  try {
5023
5022
  logger.header("\u6A21\u677F\u7248\u672C\u68C0\u67E5");
@@ -5149,7 +5148,7 @@ async function performUpdate(projectPath, updates) {
5149
5148
  }
5150
5149
  const ref = updateOptions?.tag || updateOptions?.branch || "HEAD";
5151
5150
  const backupDir = path17.join(projectPath, `.backup-${Date.now()}`);
5152
- await fs3.copy(targetPath, path17.join(backupDir, targetDir));
5151
+ await fs4.copy(targetPath, path17.join(backupDir, targetDir));
5153
5152
  logger.info(`\u5DF2\u521B\u5EFA\u5907\u4EFD: ${backupDir}`);
5154
5153
  if (updateOptions?.dryRun) {
5155
5154
  logger.info("[Dry Run] \u5C06\u4F1A\u66F4\u65B0\u5230\u4EE5\u4E0B\u7248\u672C:");
@@ -5178,15 +5177,15 @@ async function performUpdate(projectPath, updates) {
5178
5177
  if (!keepFiles.includes(file)) {
5179
5178
  const filePath = path17.join(targetPath, file);
5180
5179
  try {
5181
- await fs3.remove(filePath);
5180
+ await fs4.remove(filePath);
5182
5181
  } catch {
5183
5182
  }
5184
5183
  }
5185
5184
  }
5186
- await fs3.copy(tempDir, targetPath, {
5185
+ await fs4.copy(tempDir, targetPath, {
5187
5186
  filter: (src) => !src.includes(".git")
5188
5187
  });
5189
- await fs3.remove(tempDir);
5188
+ await fs4.remove(tempDir);
5190
5189
  await updateTemplateVersion(projectPath, type, commit.trim(), {
5191
5190
  tag: updateOptions?.tag || latestTag,
5192
5191
  branch: updateOptions?.branch
@@ -5197,9 +5196,9 @@ async function performUpdate(projectPath, updates) {
5197
5196
  } catch (error) {
5198
5197
  logger.error(`\u66F4\u65B0\u5931\u8D25: ${error.message}`);
5199
5198
  logger.info("\u6B63\u5728\u6062\u590D\u5907\u4EFD...");
5200
- await fs3.remove(targetPath);
5201
- await fs3.copy(path17.join(backupDir, targetDir), targetPath);
5202
- await fs3.remove(backupDir);
5199
+ await fs4.remove(targetPath);
5200
+ await fs4.copy(path17.join(backupDir, targetDir), targetPath);
5201
+ await fs4.remove(backupDir);
5203
5202
  logger.info("\u5DF2\u6062\u590D\u5230\u66F4\u65B0\u524D\u7684\u72B6\u6001");
5204
5203
  }
5205
5204
  }
@@ -5685,7 +5684,7 @@ var Table = class {
5685
5684
 
5686
5685
  // src/index.ts
5687
5686
  var program = new Command16();
5688
- program.name("team-cli").description("AI-Native \u56E2\u961F\u7814\u53D1\u811A\u624B\u67B6").version("2.1.4");
5687
+ program.name("team-cli").description("AI-Native \u56E2\u961F\u7814\u53D1\u811A\u624B\u67B6").version("2.1.6");
5689
5688
  program.option("-v, --verbose", "\u8BE6\u7EC6\u8F93\u51FA\u6A21\u5F0F").option("--debug", "\u8C03\u8BD5\u6A21\u5F0F");
5690
5689
  program.addCommand(initCommand);
5691
5690
  program.addCommand(splitPrdCommand);