yg-team-cli 2.1.3 → 2.1.5
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.js +44 -53
- package/dist/cli.js.map +1 -1
- package/dist/index.js +44 -53
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
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
|
|
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(
|
|
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 =
|
|
560
|
-
const platform =
|
|
561
|
-
const arch =
|
|
562
|
-
const 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
|
|
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,7 +894,8 @@ var ClaudeAI = class {
|
|
|
892
894
|
* 发送 prompt 到 Claude
|
|
893
895
|
*/
|
|
894
896
|
async prompt(promptText, options) {
|
|
895
|
-
const
|
|
897
|
+
const tempDir = os.tmpdir();
|
|
898
|
+
const tempFile = path3.join(tempDir, `team-cli-prompt-${Date.now()}.txt`);
|
|
896
899
|
try {
|
|
897
900
|
let finalPrompt = promptText;
|
|
898
901
|
const validContextFiles = [];
|
|
@@ -927,30 +930,18 @@ ${promptText}`;
|
|
|
927
930
|
}
|
|
928
931
|
}
|
|
929
932
|
}
|
|
930
|
-
|
|
931
|
-
const result = await execa("claude",
|
|
932
|
-
stdio:
|
|
933
|
-
timeout: options?.timeout || 3e5
|
|
933
|
+
await fs2.writeFile(tempFile, finalPrompt, "utf-8");
|
|
934
|
+
const result = await execa("claude", [tempFile], {
|
|
935
|
+
stdio: "inherit",
|
|
936
|
+
timeout: options?.timeout || 3e5
|
|
934
937
|
// 默认 5 分钟
|
|
935
|
-
reject: false
|
|
936
|
-
// 不自动拒绝非零退出码
|
|
937
938
|
});
|
|
938
|
-
spinner.succeed("Claude \u54CD\u5E94\u5B8C\u6210");
|
|
939
|
-
if (result.exitCode !== 0 && !result.stdout) {
|
|
940
|
-
const stderr = result.stderr || "";
|
|
941
|
-
throw new Error(`Claude \u547D\u4EE4\u6267\u884C\u5931\u8D25 (\u9000\u51FA\u7801: ${result.exitCode})${stderr ? `
|
|
942
|
-
${stderr}` : ""}`);
|
|
943
|
-
}
|
|
944
939
|
return result.stdout || "";
|
|
945
|
-
}
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
940
|
+
} finally {
|
|
941
|
+
try {
|
|
942
|
+
await fs2.remove(tempFile);
|
|
943
|
+
} catch {
|
|
949
944
|
}
|
|
950
|
-
const stderr = error.stderr || "";
|
|
951
|
-
const exitCode = error.exitCode !== void 0 ? ` (\u9000\u51FA\u7801: ${error.exitCode})` : "";
|
|
952
|
-
throw new Error(`Claude \u8C03\u7528\u5931\u8D25: ${error.message}${exitCode}${stderr ? `
|
|
953
|
-
${stderr}` : ""}`);
|
|
954
945
|
}
|
|
955
946
|
}
|
|
956
947
|
/**
|
|
@@ -968,26 +959,24 @@ ${stderr}` : ""}`);
|
|
|
968
959
|
* 发送对话(支持上下文)
|
|
969
960
|
*/
|
|
970
961
|
async chat(messages, options) {
|
|
971
|
-
const
|
|
962
|
+
const tempDir = os.tmpdir();
|
|
963
|
+
const tempFile = path3.join(tempDir, `team-cli-prompt-${Date.now()}.txt`);
|
|
972
964
|
try {
|
|
973
965
|
const fullPrompt = messages.map((msg) => {
|
|
974
966
|
const role = msg.role === "system" ? "\u7CFB\u7EDF\u6307\u4EE4" : `${msg.role === "user" ? "\u7528\u6237" : "\u52A9\u624B"}`;
|
|
975
967
|
return `[${role}]: ${msg.content}`;
|
|
976
968
|
}).join("\n\n");
|
|
977
|
-
|
|
978
|
-
const result = await execa("claude",
|
|
979
|
-
stdio:
|
|
980
|
-
timeout: options?.timeout || 3e5
|
|
981
|
-
reject: false
|
|
969
|
+
await fs2.writeFile(tempFile, fullPrompt, "utf-8");
|
|
970
|
+
const result = await execa("claude", [tempFile], {
|
|
971
|
+
stdio: "inherit",
|
|
972
|
+
timeout: options?.timeout || 3e5
|
|
982
973
|
});
|
|
983
|
-
spinner.succeed("Claude \u54CD\u5E94\u5B8C\u6210");
|
|
984
|
-
if (result.exitCode !== 0 && !result.stdout) {
|
|
985
|
-
throw new Error(`Claude \u547D\u4EE4\u6267\u884C\u5931\u8D25 (\u9000\u51FA\u7801: ${result.exitCode})`);
|
|
986
|
-
}
|
|
987
974
|
return result.stdout || "";
|
|
988
|
-
}
|
|
989
|
-
|
|
990
|
-
|
|
975
|
+
} finally {
|
|
976
|
+
try {
|
|
977
|
+
await fs2.remove(tempFile);
|
|
978
|
+
} catch {
|
|
979
|
+
}
|
|
991
980
|
}
|
|
992
981
|
}
|
|
993
982
|
/**
|
|
@@ -2033,10 +2022,10 @@ async function cloneBackendTemplate(projectPath, versionOptions) {
|
|
|
2033
2022
|
stdio: "pipe"
|
|
2034
2023
|
});
|
|
2035
2024
|
const latestTag = tags.split("\n")[0] || void 0;
|
|
2036
|
-
await
|
|
2025
|
+
await fs3.copy(tempDir, backendPath, {
|
|
2037
2026
|
filter: (src) => !src.includes(".git")
|
|
2038
2027
|
});
|
|
2039
|
-
await
|
|
2028
|
+
await fs3.remove(tempDir);
|
|
2040
2029
|
const gitDir = path6.join(backendPath, ".git");
|
|
2041
2030
|
if (await FileUtils.exists(gitDir)) {
|
|
2042
2031
|
await FileUtils.remove(gitDir);
|
|
@@ -2467,12 +2456,14 @@ async function executeDevelopment(specFile, milestone, todo) {
|
|
|
2467
2456
|
const prompt = buildDevPrompt(specFile, milestone, todo, taskDescription);
|
|
2468
2457
|
logger.newLine();
|
|
2469
2458
|
logger.separator("\u2500", 60);
|
|
2470
|
-
logger.info("
|
|
2459
|
+
logger.info("\u5373\u5C06\u8C03\u7528 Claude AI...");
|
|
2471
2460
|
logger.separator("\u2500", 60);
|
|
2472
2461
|
logger.newLine();
|
|
2473
2462
|
logger.info(` \u4EFB\u52A1\u63CF\u8FF0: ${taskDescription}`);
|
|
2474
2463
|
logger.info(` Spec \u6587\u4EF6: ${specFile}`);
|
|
2475
2464
|
logger.newLine();
|
|
2465
|
+
logger.info("\u{1F4DD} Claude \u5C06\u5728\u4E0B\u65B9\u6253\u5F00\u4EA4\u4E92\u754C\u9762\uFF0C\u8BF7\u6309\u7167\u63D0\u793A\u5B8C\u6210\u5F00\u53D1\u4EFB\u52A1");
|
|
2466
|
+
logger.newLine();
|
|
2476
2467
|
const result = await claudeAI.prompt(prompt, {
|
|
2477
2468
|
contextFiles: ["TECH_STACK.md", "CONVENTIONS.md", "AI_MEMORY.md", specFile]
|
|
2478
2469
|
});
|
|
@@ -5025,7 +5016,7 @@ init_logger();
|
|
|
5025
5016
|
init_utils();
|
|
5026
5017
|
import { execa as execa4 } from "execa";
|
|
5027
5018
|
import inquirer9 from "inquirer";
|
|
5028
|
-
import
|
|
5019
|
+
import fs4 from "fs-extra";
|
|
5029
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) => {
|
|
5030
5021
|
try {
|
|
5031
5022
|
logger.header("\u6A21\u677F\u7248\u672C\u68C0\u67E5");
|
|
@@ -5157,7 +5148,7 @@ async function performUpdate(projectPath, updates) {
|
|
|
5157
5148
|
}
|
|
5158
5149
|
const ref = updateOptions?.tag || updateOptions?.branch || "HEAD";
|
|
5159
5150
|
const backupDir = path17.join(projectPath, `.backup-${Date.now()}`);
|
|
5160
|
-
await
|
|
5151
|
+
await fs4.copy(targetPath, path17.join(backupDir, targetDir));
|
|
5161
5152
|
logger.info(`\u5DF2\u521B\u5EFA\u5907\u4EFD: ${backupDir}`);
|
|
5162
5153
|
if (updateOptions?.dryRun) {
|
|
5163
5154
|
logger.info("[Dry Run] \u5C06\u4F1A\u66F4\u65B0\u5230\u4EE5\u4E0B\u7248\u672C:");
|
|
@@ -5186,15 +5177,15 @@ async function performUpdate(projectPath, updates) {
|
|
|
5186
5177
|
if (!keepFiles.includes(file)) {
|
|
5187
5178
|
const filePath = path17.join(targetPath, file);
|
|
5188
5179
|
try {
|
|
5189
|
-
await
|
|
5180
|
+
await fs4.remove(filePath);
|
|
5190
5181
|
} catch {
|
|
5191
5182
|
}
|
|
5192
5183
|
}
|
|
5193
5184
|
}
|
|
5194
|
-
await
|
|
5185
|
+
await fs4.copy(tempDir, targetPath, {
|
|
5195
5186
|
filter: (src) => !src.includes(".git")
|
|
5196
5187
|
});
|
|
5197
|
-
await
|
|
5188
|
+
await fs4.remove(tempDir);
|
|
5198
5189
|
await updateTemplateVersion(projectPath, type, commit.trim(), {
|
|
5199
5190
|
tag: updateOptions?.tag || latestTag,
|
|
5200
5191
|
branch: updateOptions?.branch
|
|
@@ -5205,9 +5196,9 @@ async function performUpdate(projectPath, updates) {
|
|
|
5205
5196
|
} catch (error) {
|
|
5206
5197
|
logger.error(`\u66F4\u65B0\u5931\u8D25: ${error.message}`);
|
|
5207
5198
|
logger.info("\u6B63\u5728\u6062\u590D\u5907\u4EFD...");
|
|
5208
|
-
await
|
|
5209
|
-
await
|
|
5210
|
-
await
|
|
5199
|
+
await fs4.remove(targetPath);
|
|
5200
|
+
await fs4.copy(path17.join(backupDir, targetDir), targetPath);
|
|
5201
|
+
await fs4.remove(backupDir);
|
|
5211
5202
|
logger.info("\u5DF2\u6062\u590D\u5230\u66F4\u65B0\u524D\u7684\u72B6\u6001");
|
|
5212
5203
|
}
|
|
5213
5204
|
}
|
|
@@ -5693,7 +5684,7 @@ var Table = class {
|
|
|
5693
5684
|
|
|
5694
5685
|
// src/index.ts
|
|
5695
5686
|
var program = new Command16();
|
|
5696
|
-
program.name("team-cli").description("AI-Native \u56E2\u961F\u7814\u53D1\u811A\u624B\u67B6").version("2.1.
|
|
5687
|
+
program.name("team-cli").description("AI-Native \u56E2\u961F\u7814\u53D1\u811A\u624B\u67B6").version("2.1.5");
|
|
5697
5688
|
program.option("-v, --verbose", "\u8BE6\u7EC6\u8F93\u51FA\u6A21\u5F0F").option("--debug", "\u8C03\u8BD5\u6A21\u5F0F");
|
|
5698
5689
|
program.addCommand(initCommand);
|
|
5699
5690
|
program.addCommand(splitPrdCommand);
|