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/cli.js
CHANGED
|
@@ -417,6 +417,8 @@ var init_utils = __esm({
|
|
|
417
417
|
// src/lib/claude.ts
|
|
418
418
|
import { execa } from "execa";
|
|
419
419
|
import path3 from "path";
|
|
420
|
+
import fs2 from "fs-extra";
|
|
421
|
+
import os from "os";
|
|
420
422
|
var ClaudeAI, claudeAI;
|
|
421
423
|
var init_claude = __esm({
|
|
422
424
|
"src/lib/claude.ts"() {
|
|
@@ -455,7 +457,8 @@ var init_claude = __esm({
|
|
|
455
457
|
* 发送 prompt 到 Claude
|
|
456
458
|
*/
|
|
457
459
|
async prompt(promptText, options) {
|
|
458
|
-
const
|
|
460
|
+
const tempDir = os.tmpdir();
|
|
461
|
+
const tempFile = path3.join(tempDir, `team-cli-prompt-${Date.now()}.txt`);
|
|
459
462
|
try {
|
|
460
463
|
let finalPrompt = promptText;
|
|
461
464
|
const validContextFiles = [];
|
|
@@ -490,30 +493,18 @@ ${promptText}`;
|
|
|
490
493
|
}
|
|
491
494
|
}
|
|
492
495
|
}
|
|
493
|
-
|
|
494
|
-
const result = await execa("claude",
|
|
495
|
-
stdio:
|
|
496
|
-
timeout: options?.timeout || 3e5
|
|
496
|
+
await fs2.writeFile(tempFile, finalPrompt, "utf-8");
|
|
497
|
+
const result = await execa("claude", [tempFile], {
|
|
498
|
+
stdio: "inherit",
|
|
499
|
+
timeout: options?.timeout || 3e5
|
|
497
500
|
// 默认 5 分钟
|
|
498
|
-
reject: false
|
|
499
|
-
// 不自动拒绝非零退出码
|
|
500
501
|
});
|
|
501
|
-
spinner.succeed("Claude \u54CD\u5E94\u5B8C\u6210");
|
|
502
|
-
if (result.exitCode !== 0 && !result.stdout) {
|
|
503
|
-
const stderr = result.stderr || "";
|
|
504
|
-
throw new Error(`Claude \u547D\u4EE4\u6267\u884C\u5931\u8D25 (\u9000\u51FA\u7801: ${result.exitCode})${stderr ? `
|
|
505
|
-
${stderr}` : ""}`);
|
|
506
|
-
}
|
|
507
502
|
return result.stdout || "";
|
|
508
|
-
}
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
503
|
+
} finally {
|
|
504
|
+
try {
|
|
505
|
+
await fs2.remove(tempFile);
|
|
506
|
+
} catch {
|
|
512
507
|
}
|
|
513
|
-
const stderr = error.stderr || "";
|
|
514
|
-
const exitCode = error.exitCode !== void 0 ? ` (\u9000\u51FA\u7801: ${error.exitCode})` : "";
|
|
515
|
-
throw new Error(`Claude \u8C03\u7528\u5931\u8D25: ${error.message}${exitCode}${stderr ? `
|
|
516
|
-
${stderr}` : ""}`);
|
|
517
508
|
}
|
|
518
509
|
}
|
|
519
510
|
/**
|
|
@@ -531,26 +522,24 @@ ${stderr}` : ""}`);
|
|
|
531
522
|
* 发送对话(支持上下文)
|
|
532
523
|
*/
|
|
533
524
|
async chat(messages, options) {
|
|
534
|
-
const
|
|
525
|
+
const tempDir = os.tmpdir();
|
|
526
|
+
const tempFile = path3.join(tempDir, `team-cli-prompt-${Date.now()}.txt`);
|
|
535
527
|
try {
|
|
536
528
|
const fullPrompt = messages.map((msg) => {
|
|
537
529
|
const role = msg.role === "system" ? "\u7CFB\u7EDF\u6307\u4EE4" : `${msg.role === "user" ? "\u7528\u6237" : "\u52A9\u624B"}`;
|
|
538
530
|
return `[${role}]: ${msg.content}`;
|
|
539
531
|
}).join("\n\n");
|
|
540
|
-
|
|
541
|
-
const result = await execa("claude",
|
|
542
|
-
stdio:
|
|
543
|
-
timeout: options?.timeout || 3e5
|
|
544
|
-
reject: false
|
|
532
|
+
await fs2.writeFile(tempFile, fullPrompt, "utf-8");
|
|
533
|
+
const result = await execa("claude", [tempFile], {
|
|
534
|
+
stdio: "inherit",
|
|
535
|
+
timeout: options?.timeout || 3e5
|
|
545
536
|
});
|
|
546
|
-
spinner.succeed("Claude \u54CD\u5E94\u5B8C\u6210");
|
|
547
|
-
if (result.exitCode !== 0 && !result.stdout) {
|
|
548
|
-
throw new Error(`Claude \u547D\u4EE4\u6267\u884C\u5931\u8D25 (\u9000\u51FA\u7801: ${result.exitCode})`);
|
|
549
|
-
}
|
|
550
537
|
return result.stdout || "";
|
|
551
|
-
}
|
|
552
|
-
|
|
553
|
-
|
|
538
|
+
} finally {
|
|
539
|
+
try {
|
|
540
|
+
await fs2.remove(tempFile);
|
|
541
|
+
} catch {
|
|
542
|
+
}
|
|
554
543
|
}
|
|
555
544
|
}
|
|
556
545
|
/**
|
|
@@ -896,7 +885,7 @@ __export(user_config_exports, {
|
|
|
896
885
|
userConfigManager: () => userConfigManager
|
|
897
886
|
});
|
|
898
887
|
import path5 from "path";
|
|
899
|
-
import
|
|
888
|
+
import os2 from "os";
|
|
900
889
|
import crypto from "crypto";
|
|
901
890
|
var UserConfigManager, userConfigManager;
|
|
902
891
|
var init_user_config = __esm({
|
|
@@ -908,7 +897,7 @@ var init_user_config = __esm({
|
|
|
908
897
|
UserConfigManager = class {
|
|
909
898
|
configPath;
|
|
910
899
|
constructor() {
|
|
911
|
-
const configDir = path5.join(
|
|
900
|
+
const configDir = path5.join(os2.homedir(), ".team-cli");
|
|
912
901
|
this.configPath = path5.join(configDir, "config.json");
|
|
913
902
|
}
|
|
914
903
|
/**
|
|
@@ -1031,10 +1020,10 @@ var init_user_config = __esm({
|
|
|
1031
1020
|
* 获取机器特定密钥
|
|
1032
1021
|
*/
|
|
1033
1022
|
getMachineKey() {
|
|
1034
|
-
const hostname =
|
|
1035
|
-
const platform =
|
|
1036
|
-
const arch =
|
|
1037
|
-
const cpus =
|
|
1023
|
+
const hostname = os2.hostname();
|
|
1024
|
+
const platform = os2.platform();
|
|
1025
|
+
const arch = os2.arch();
|
|
1026
|
+
const cpus = os2.cpus();
|
|
1038
1027
|
const machineInfo = `${hostname}-${platform}-${arch}-${cpus[0]?.model || "unknown"}`;
|
|
1039
1028
|
return crypto.createHash("sha256").update(machineInfo).digest();
|
|
1040
1029
|
}
|
|
@@ -1320,7 +1309,7 @@ var init_gitlab_api = __esm({
|
|
|
1320
1309
|
import { Command } from "commander";
|
|
1321
1310
|
import inquirer from "inquirer";
|
|
1322
1311
|
import path6 from "path";
|
|
1323
|
-
import
|
|
1312
|
+
import fs3 from "fs-extra";
|
|
1324
1313
|
import { Listr } from "listr2";
|
|
1325
1314
|
async function generateTechStack(projectPath) {
|
|
1326
1315
|
const content = `# \u6280\u672F\u6808
|
|
@@ -1894,10 +1883,10 @@ async function cloneBackendTemplate(projectPath, versionOptions) {
|
|
|
1894
1883
|
stdio: "pipe"
|
|
1895
1884
|
});
|
|
1896
1885
|
const latestTag = tags.split("\n")[0] || void 0;
|
|
1897
|
-
await
|
|
1886
|
+
await fs3.copy(tempDir, backendPath, {
|
|
1898
1887
|
filter: (src) => !src.includes(".git")
|
|
1899
1888
|
});
|
|
1900
|
-
await
|
|
1889
|
+
await fs3.remove(tempDir);
|
|
1901
1890
|
const gitDir = path6.join(backendPath, ".git");
|
|
1902
1891
|
if (await FileUtils.exists(gitDir)) {
|
|
1903
1892
|
await FileUtils.remove(gitDir);
|
|
@@ -2452,12 +2441,14 @@ async function executeDevelopment(specFile, milestone, todo) {
|
|
|
2452
2441
|
const prompt = buildDevPrompt(specFile, milestone, todo, taskDescription);
|
|
2453
2442
|
logger.newLine();
|
|
2454
2443
|
logger.separator("\u2500", 60);
|
|
2455
|
-
logger.info("
|
|
2444
|
+
logger.info("\u5373\u5C06\u8C03\u7528 Claude AI...");
|
|
2456
2445
|
logger.separator("\u2500", 60);
|
|
2457
2446
|
logger.newLine();
|
|
2458
2447
|
logger.info(` \u4EFB\u52A1\u63CF\u8FF0: ${taskDescription}`);
|
|
2459
2448
|
logger.info(` Spec \u6587\u4EF6: ${specFile}`);
|
|
2460
2449
|
logger.newLine();
|
|
2450
|
+
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");
|
|
2451
|
+
logger.newLine();
|
|
2461
2452
|
const result = await claudeAI.prompt(prompt, {
|
|
2462
2453
|
contextFiles: ["TECH_STACK.md", "CONVENTIONS.md", "AI_MEMORY.md", specFile]
|
|
2463
2454
|
});
|
|
@@ -5103,7 +5094,7 @@ import { Command as Command13 } from "commander";
|
|
|
5103
5094
|
import path17 from "path";
|
|
5104
5095
|
import { execa as execa4 } from "execa";
|
|
5105
5096
|
import inquirer9 from "inquirer";
|
|
5106
|
-
import
|
|
5097
|
+
import fs4 from "fs-extra";
|
|
5107
5098
|
async function performUpdate(projectPath, updates) {
|
|
5108
5099
|
logger.newLine();
|
|
5109
5100
|
logger.info("\u5F00\u59CB\u66F4\u65B0\u6A21\u677F...");
|
|
@@ -5142,7 +5133,7 @@ async function performUpdate(projectPath, updates) {
|
|
|
5142
5133
|
}
|
|
5143
5134
|
const ref = updateOptions?.tag || updateOptions?.branch || "HEAD";
|
|
5144
5135
|
const backupDir = path17.join(projectPath, `.backup-${Date.now()}`);
|
|
5145
|
-
await
|
|
5136
|
+
await fs4.copy(targetPath, path17.join(backupDir, targetDir));
|
|
5146
5137
|
logger.info(`\u5DF2\u521B\u5EFA\u5907\u4EFD: ${backupDir}`);
|
|
5147
5138
|
if (updateOptions?.dryRun) {
|
|
5148
5139
|
logger.info("[Dry Run] \u5C06\u4F1A\u66F4\u65B0\u5230\u4EE5\u4E0B\u7248\u672C:");
|
|
@@ -5171,15 +5162,15 @@ async function performUpdate(projectPath, updates) {
|
|
|
5171
5162
|
if (!keepFiles.includes(file)) {
|
|
5172
5163
|
const filePath = path17.join(targetPath, file);
|
|
5173
5164
|
try {
|
|
5174
|
-
await
|
|
5165
|
+
await fs4.remove(filePath);
|
|
5175
5166
|
} catch {
|
|
5176
5167
|
}
|
|
5177
5168
|
}
|
|
5178
5169
|
}
|
|
5179
|
-
await
|
|
5170
|
+
await fs4.copy(tempDir, targetPath, {
|
|
5180
5171
|
filter: (src) => !src.includes(".git")
|
|
5181
5172
|
});
|
|
5182
|
-
await
|
|
5173
|
+
await fs4.remove(tempDir);
|
|
5183
5174
|
await updateTemplateVersion(projectPath, type, commit.trim(), {
|
|
5184
5175
|
tag: updateOptions?.tag || latestTag,
|
|
5185
5176
|
branch: updateOptions?.branch
|
|
@@ -5190,9 +5181,9 @@ async function performUpdate(projectPath, updates) {
|
|
|
5190
5181
|
} catch (error) {
|
|
5191
5182
|
logger.error(`\u66F4\u65B0\u5931\u8D25: ${error.message}`);
|
|
5192
5183
|
logger.info("\u6B63\u5728\u6062\u590D\u5907\u4EFD...");
|
|
5193
|
-
await
|
|
5194
|
-
await
|
|
5195
|
-
await
|
|
5184
|
+
await fs4.remove(targetPath);
|
|
5185
|
+
await fs4.copy(path17.join(backupDir, targetDir), targetPath);
|
|
5186
|
+
await fs4.remove(backupDir);
|
|
5196
5187
|
logger.info("\u5DF2\u6062\u590D\u5230\u66F4\u65B0\u524D\u7684\u72B6\u6001");
|
|
5197
5188
|
}
|
|
5198
5189
|
}
|
|
@@ -5873,7 +5864,7 @@ var init_index = __esm({
|
|
|
5873
5864
|
init_config();
|
|
5874
5865
|
init_diff();
|
|
5875
5866
|
program = new Command16();
|
|
5876
|
-
program.name("team-cli").description("AI-Native \u56E2\u961F\u7814\u53D1\u811A\u624B\u67B6").version("2.1.
|
|
5867
|
+
program.name("team-cli").description("AI-Native \u56E2\u961F\u7814\u53D1\u811A\u624B\u67B6").version("2.1.5");
|
|
5877
5868
|
program.option("-v, --verbose", "\u8BE6\u7EC6\u8F93\u51FA\u6A21\u5F0F").option("--debug", "\u8C03\u8BD5\u6A21\u5F0F");
|
|
5878
5869
|
program.addCommand(initCommand);
|
|
5879
5870
|
program.addCommand(splitPrdCommand);
|