yg-team-cli 2.1.4 → 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 +39 -40
- package/dist/cli.js.map +1 -1
- package/dist/index.js +39 -40
- 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,6 +457,8 @@ var init_claude = __esm({
|
|
|
455
457
|
* 发送 prompt 到 Claude
|
|
456
458
|
*/
|
|
457
459
|
async prompt(promptText, options) {
|
|
460
|
+
const tempDir = os.tmpdir();
|
|
461
|
+
const tempFile = path3.join(tempDir, `team-cli-prompt-${Date.now()}.txt`);
|
|
458
462
|
try {
|
|
459
463
|
let finalPrompt = promptText;
|
|
460
464
|
const validContextFiles = [];
|
|
@@ -489,21 +493,18 @@ ${promptText}`;
|
|
|
489
493
|
}
|
|
490
494
|
}
|
|
491
495
|
}
|
|
492
|
-
|
|
493
|
-
const result = await execa("claude",
|
|
496
|
+
await fs2.writeFile(tempFile, finalPrompt, "utf-8");
|
|
497
|
+
const result = await execa("claude", [tempFile], {
|
|
494
498
|
stdio: "inherit",
|
|
495
499
|
timeout: options?.timeout || 3e5
|
|
496
500
|
// 默认 5 分钟
|
|
497
501
|
});
|
|
498
502
|
return result.stdout || "";
|
|
499
|
-
}
|
|
500
|
-
|
|
501
|
-
|
|
503
|
+
} finally {
|
|
504
|
+
try {
|
|
505
|
+
await fs2.remove(tempFile);
|
|
506
|
+
} catch {
|
|
502
507
|
}
|
|
503
|
-
const stderr = error.stderr || "";
|
|
504
|
-
const exitCode = error.exitCode !== void 0 ? ` (\u9000\u51FA\u7801: ${error.exitCode})` : "";
|
|
505
|
-
throw new Error(`Claude \u8C03\u7528\u5931\u8D25: ${error.message}${exitCode}${stderr ? `
|
|
506
|
-
${stderr}` : ""}`);
|
|
507
508
|
}
|
|
508
509
|
}
|
|
509
510
|
/**
|
|
@@ -521,26 +522,24 @@ ${stderr}` : ""}`);
|
|
|
521
522
|
* 发送对话(支持上下文)
|
|
522
523
|
*/
|
|
523
524
|
async chat(messages, options) {
|
|
524
|
-
const
|
|
525
|
+
const tempDir = os.tmpdir();
|
|
526
|
+
const tempFile = path3.join(tempDir, `team-cli-prompt-${Date.now()}.txt`);
|
|
525
527
|
try {
|
|
526
528
|
const fullPrompt = messages.map((msg) => {
|
|
527
529
|
const role = msg.role === "system" ? "\u7CFB\u7EDF\u6307\u4EE4" : `${msg.role === "user" ? "\u7528\u6237" : "\u52A9\u624B"}`;
|
|
528
530
|
return `[${role}]: ${msg.content}`;
|
|
529
531
|
}).join("\n\n");
|
|
530
|
-
|
|
531
|
-
const result = await execa("claude",
|
|
532
|
-
stdio:
|
|
533
|
-
timeout: options?.timeout || 3e5
|
|
534
|
-
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
|
|
535
536
|
});
|
|
536
|
-
spinner.succeed("Claude \u54CD\u5E94\u5B8C\u6210");
|
|
537
|
-
if (result.exitCode !== 0 && !result.stdout) {
|
|
538
|
-
throw new Error(`Claude \u547D\u4EE4\u6267\u884C\u5931\u8D25 (\u9000\u51FA\u7801: ${result.exitCode})`);
|
|
539
|
-
}
|
|
540
537
|
return result.stdout || "";
|
|
541
|
-
}
|
|
542
|
-
|
|
543
|
-
|
|
538
|
+
} finally {
|
|
539
|
+
try {
|
|
540
|
+
await fs2.remove(tempFile);
|
|
541
|
+
} catch {
|
|
542
|
+
}
|
|
544
543
|
}
|
|
545
544
|
}
|
|
546
545
|
/**
|
|
@@ -886,7 +885,7 @@ __export(user_config_exports, {
|
|
|
886
885
|
userConfigManager: () => userConfigManager
|
|
887
886
|
});
|
|
888
887
|
import path5 from "path";
|
|
889
|
-
import
|
|
888
|
+
import os2 from "os";
|
|
890
889
|
import crypto from "crypto";
|
|
891
890
|
var UserConfigManager, userConfigManager;
|
|
892
891
|
var init_user_config = __esm({
|
|
@@ -898,7 +897,7 @@ var init_user_config = __esm({
|
|
|
898
897
|
UserConfigManager = class {
|
|
899
898
|
configPath;
|
|
900
899
|
constructor() {
|
|
901
|
-
const configDir = path5.join(
|
|
900
|
+
const configDir = path5.join(os2.homedir(), ".team-cli");
|
|
902
901
|
this.configPath = path5.join(configDir, "config.json");
|
|
903
902
|
}
|
|
904
903
|
/**
|
|
@@ -1021,10 +1020,10 @@ var init_user_config = __esm({
|
|
|
1021
1020
|
* 获取机器特定密钥
|
|
1022
1021
|
*/
|
|
1023
1022
|
getMachineKey() {
|
|
1024
|
-
const hostname =
|
|
1025
|
-
const platform =
|
|
1026
|
-
const arch =
|
|
1027
|
-
const cpus =
|
|
1023
|
+
const hostname = os2.hostname();
|
|
1024
|
+
const platform = os2.platform();
|
|
1025
|
+
const arch = os2.arch();
|
|
1026
|
+
const cpus = os2.cpus();
|
|
1028
1027
|
const machineInfo = `${hostname}-${platform}-${arch}-${cpus[0]?.model || "unknown"}`;
|
|
1029
1028
|
return crypto.createHash("sha256").update(machineInfo).digest();
|
|
1030
1029
|
}
|
|
@@ -1310,7 +1309,7 @@ var init_gitlab_api = __esm({
|
|
|
1310
1309
|
import { Command } from "commander";
|
|
1311
1310
|
import inquirer from "inquirer";
|
|
1312
1311
|
import path6 from "path";
|
|
1313
|
-
import
|
|
1312
|
+
import fs3 from "fs-extra";
|
|
1314
1313
|
import { Listr } from "listr2";
|
|
1315
1314
|
async function generateTechStack(projectPath) {
|
|
1316
1315
|
const content = `# \u6280\u672F\u6808
|
|
@@ -1884,10 +1883,10 @@ async function cloneBackendTemplate(projectPath, versionOptions) {
|
|
|
1884
1883
|
stdio: "pipe"
|
|
1885
1884
|
});
|
|
1886
1885
|
const latestTag = tags.split("\n")[0] || void 0;
|
|
1887
|
-
await
|
|
1886
|
+
await fs3.copy(tempDir, backendPath, {
|
|
1888
1887
|
filter: (src) => !src.includes(".git")
|
|
1889
1888
|
});
|
|
1890
|
-
await
|
|
1889
|
+
await fs3.remove(tempDir);
|
|
1891
1890
|
const gitDir = path6.join(backendPath, ".git");
|
|
1892
1891
|
if (await FileUtils.exists(gitDir)) {
|
|
1893
1892
|
await FileUtils.remove(gitDir);
|
|
@@ -5095,7 +5094,7 @@ import { Command as Command13 } from "commander";
|
|
|
5095
5094
|
import path17 from "path";
|
|
5096
5095
|
import { execa as execa4 } from "execa";
|
|
5097
5096
|
import inquirer9 from "inquirer";
|
|
5098
|
-
import
|
|
5097
|
+
import fs4 from "fs-extra";
|
|
5099
5098
|
async function performUpdate(projectPath, updates) {
|
|
5100
5099
|
logger.newLine();
|
|
5101
5100
|
logger.info("\u5F00\u59CB\u66F4\u65B0\u6A21\u677F...");
|
|
@@ -5134,7 +5133,7 @@ async function performUpdate(projectPath, updates) {
|
|
|
5134
5133
|
}
|
|
5135
5134
|
const ref = updateOptions?.tag || updateOptions?.branch || "HEAD";
|
|
5136
5135
|
const backupDir = path17.join(projectPath, `.backup-${Date.now()}`);
|
|
5137
|
-
await
|
|
5136
|
+
await fs4.copy(targetPath, path17.join(backupDir, targetDir));
|
|
5138
5137
|
logger.info(`\u5DF2\u521B\u5EFA\u5907\u4EFD: ${backupDir}`);
|
|
5139
5138
|
if (updateOptions?.dryRun) {
|
|
5140
5139
|
logger.info("[Dry Run] \u5C06\u4F1A\u66F4\u65B0\u5230\u4EE5\u4E0B\u7248\u672C:");
|
|
@@ -5163,15 +5162,15 @@ async function performUpdate(projectPath, updates) {
|
|
|
5163
5162
|
if (!keepFiles.includes(file)) {
|
|
5164
5163
|
const filePath = path17.join(targetPath, file);
|
|
5165
5164
|
try {
|
|
5166
|
-
await
|
|
5165
|
+
await fs4.remove(filePath);
|
|
5167
5166
|
} catch {
|
|
5168
5167
|
}
|
|
5169
5168
|
}
|
|
5170
5169
|
}
|
|
5171
|
-
await
|
|
5170
|
+
await fs4.copy(tempDir, targetPath, {
|
|
5172
5171
|
filter: (src) => !src.includes(".git")
|
|
5173
5172
|
});
|
|
5174
|
-
await
|
|
5173
|
+
await fs4.remove(tempDir);
|
|
5175
5174
|
await updateTemplateVersion(projectPath, type, commit.trim(), {
|
|
5176
5175
|
tag: updateOptions?.tag || latestTag,
|
|
5177
5176
|
branch: updateOptions?.branch
|
|
@@ -5182,9 +5181,9 @@ async function performUpdate(projectPath, updates) {
|
|
|
5182
5181
|
} catch (error) {
|
|
5183
5182
|
logger.error(`\u66F4\u65B0\u5931\u8D25: ${error.message}`);
|
|
5184
5183
|
logger.info("\u6B63\u5728\u6062\u590D\u5907\u4EFD...");
|
|
5185
|
-
await
|
|
5186
|
-
await
|
|
5187
|
-
await
|
|
5184
|
+
await fs4.remove(targetPath);
|
|
5185
|
+
await fs4.copy(path17.join(backupDir, targetDir), targetPath);
|
|
5186
|
+
await fs4.remove(backupDir);
|
|
5188
5187
|
logger.info("\u5DF2\u6062\u590D\u5230\u66F4\u65B0\u524D\u7684\u72B6\u6001");
|
|
5189
5188
|
}
|
|
5190
5189
|
}
|
|
@@ -5865,7 +5864,7 @@ var init_index = __esm({
|
|
|
5865
5864
|
init_config();
|
|
5866
5865
|
init_diff();
|
|
5867
5866
|
program = new Command16();
|
|
5868
|
-
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");
|
|
5869
5868
|
program.option("-v, --verbose", "\u8BE6\u7EC6\u8F93\u51FA\u6A21\u5F0F").option("--debug", "\u8C03\u8BD5\u6A21\u5F0F");
|
|
5870
5869
|
program.addCommand(initCommand);
|
|
5871
5870
|
program.addCommand(splitPrdCommand);
|