yg-team-cli 2.4.6 → 2.4.8
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/README.md +12 -0
- package/dist/cli.js +56 -30
- package/dist/cli.js.map +1 -1
- package/dist/index.js +56 -30
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -194,7 +194,7 @@ var init_logger = __esm({
|
|
|
194
194
|
import fs from "fs-extra";
|
|
195
195
|
import path2 from "path";
|
|
196
196
|
import { glob } from "glob";
|
|
197
|
-
var FileUtils,
|
|
197
|
+
var FileUtils, StringUtils, DateUtils, GitUtils, SpecUtils;
|
|
198
198
|
var init_utils = __esm({
|
|
199
199
|
"src/lib/utils.ts"() {
|
|
200
200
|
"use strict";
|
|
@@ -271,7 +271,7 @@ var init_utils = __esm({
|
|
|
271
271
|
return path2.dirname(new URL(url).pathname);
|
|
272
272
|
}
|
|
273
273
|
};
|
|
274
|
-
|
|
274
|
+
StringUtils = class {
|
|
275
275
|
/**
|
|
276
276
|
* 转换为 kebab-case
|
|
277
277
|
*/
|
|
@@ -895,6 +895,7 @@ import path3 from "path";
|
|
|
895
895
|
import fs2 from "fs-extra";
|
|
896
896
|
import os from "os";
|
|
897
897
|
var ClaudeAI = class {
|
|
898
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
898
899
|
verbose;
|
|
899
900
|
constructor(verbose = false) {
|
|
900
901
|
this.verbose = verbose;
|
|
@@ -962,8 +963,13 @@ ${promptText}`;
|
|
|
962
963
|
}
|
|
963
964
|
}
|
|
964
965
|
await fs2.writeFile(tempFile, finalPrompt, "utf-8");
|
|
965
|
-
const result = await execa("claude", ["
|
|
966
|
-
stdio: "inherit"
|
|
966
|
+
const result = await execa("claude", ["-p", finalPrompt], {
|
|
967
|
+
stdio: ["pipe", "pipe", "inherit"],
|
|
968
|
+
// stdin: pipe, stdout: pipe (capture), stderr: inherit (show errors)
|
|
969
|
+
timeout: options?.timeout || 3e5,
|
|
970
|
+
// 5 分钟超时
|
|
971
|
+
maxBuffer: 1024 * 1024 * 10
|
|
972
|
+
// 10MB buffer
|
|
967
973
|
});
|
|
968
974
|
return result.stdout || "";
|
|
969
975
|
} finally {
|
|
@@ -988,24 +994,16 @@ ${promptText}`;
|
|
|
988
994
|
* 发送对话(支持上下文)
|
|
989
995
|
*/
|
|
990
996
|
async chat(messages, options) {
|
|
991
|
-
const
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
});
|
|
1002
|
-
return result.stdout || "";
|
|
1003
|
-
} finally {
|
|
1004
|
-
try {
|
|
1005
|
-
await fs2.remove(tempFile);
|
|
1006
|
-
} catch {
|
|
1007
|
-
}
|
|
1008
|
-
}
|
|
997
|
+
const fullPrompt = messages.map((msg) => {
|
|
998
|
+
const role = msg.role === "system" ? "\u7CFB\u7EDF\u6307\u4EE4" : `${msg.role === "user" ? "\u7528\u6237" : "\u52A9\u624B"}`;
|
|
999
|
+
return `[${role}]: ${msg.content}`;
|
|
1000
|
+
}).join("\n\n");
|
|
1001
|
+
const result = await execa("claude", ["-p", fullPrompt], {
|
|
1002
|
+
stdio: ["pipe", "pipe", "inherit"],
|
|
1003
|
+
timeout: options?.timeout || 3e5,
|
|
1004
|
+
maxBuffer: 1024 * 1024 * 10
|
|
1005
|
+
});
|
|
1006
|
+
return result.stdout || "";
|
|
1009
1007
|
}
|
|
1010
1008
|
/**
|
|
1011
1009
|
* 分析代码
|
|
@@ -1627,7 +1625,7 @@ var initCommand = new Command("init").argument("[project-name]", "\u9879\u76EE\u
|
|
|
1627
1625
|
]);
|
|
1628
1626
|
projectName = answers.projectName;
|
|
1629
1627
|
}
|
|
1630
|
-
if (!
|
|
1628
|
+
if (!StringUtils.validateProjectName(projectName)) {
|
|
1631
1629
|
logger.error("\u9879\u76EE\u540D\u79F0\u53EA\u80FD\u5305\u542B\u5C0F\u5199\u5B57\u6BCD\u3001\u6570\u5B57\u548C\u8FDE\u5B57\u7B26");
|
|
1632
1630
|
process.exit(1);
|
|
1633
1631
|
}
|
|
@@ -3171,7 +3169,7 @@ var addFeatureCommand = new Command4("add-feature").argument("<feature-name>", "
|
|
|
3171
3169
|
logger.info("\u8BF7\u5B89\u88C5 Claude CLI: npm install -g @anthropic-ai/claude-code");
|
|
3172
3170
|
process.exit(1);
|
|
3173
3171
|
}
|
|
3174
|
-
const featureSlug =
|
|
3172
|
+
const featureSlug = StringUtils.toKebabCase(featureName);
|
|
3175
3173
|
const specFile = path10.join("docs/specs", `${featureSlug}.md`);
|
|
3176
3174
|
const specExists = await FileUtils.exists(specFile);
|
|
3177
3175
|
if (specExists) {
|
|
@@ -3572,7 +3570,8 @@ async function updateAiMemory(featureName, featureSlug) {
|
|
|
3572
3570
|
return;
|
|
3573
3571
|
}
|
|
3574
3572
|
let content = await FileUtils.read(aiMemoryFile);
|
|
3575
|
-
const
|
|
3573
|
+
const featureDisplay = featureName.replace(/[-_]/g, " ").split(" ").map((word) => word.charAt(0).toUpperCase() + word.slice(1).toLowerCase()).join(" ");
|
|
3574
|
+
const newRow = `| ${featureDisplay} | ${featureSlug}.md | \u25CB \u672A\u5F00\u59CB | 0/0 | - | |`;
|
|
3576
3575
|
if (!content.includes("## \u529F\u80FD\u6E05\u5355")) {
|
|
3577
3576
|
content += `
|
|
3578
3577
|
## \u529F\u80FD\u6E05\u5355 (Feature Inventory)
|
|
@@ -3583,18 +3582,45 @@ ${newRow}
|
|
|
3583
3582
|
`;
|
|
3584
3583
|
} else {
|
|
3585
3584
|
const lines = content.split("\n");
|
|
3586
|
-
|
|
3587
|
-
|
|
3588
|
-
|
|
3585
|
+
let featureInventorySection = false;
|
|
3586
|
+
let insertIndex = -1;
|
|
3587
|
+
for (let i = 0; i < lines.length; i++) {
|
|
3588
|
+
const line = lines[i];
|
|
3589
|
+
if (line.includes("## \u529F\u80FD\u6E05\u5355")) {
|
|
3590
|
+
featureInventorySection = true;
|
|
3591
|
+
continue;
|
|
3592
|
+
}
|
|
3593
|
+
if (featureInventorySection && line.startsWith("## ") && !line.includes("\u529F\u80FD\u6E05\u5355")) {
|
|
3594
|
+
break;
|
|
3595
|
+
}
|
|
3596
|
+
if (featureInventorySection && /^\|[-]+\|/.test(line.trim())) {
|
|
3597
|
+
insertIndex = i + 1;
|
|
3598
|
+
break;
|
|
3599
|
+
}
|
|
3600
|
+
}
|
|
3601
|
+
if (insertIndex !== -1) {
|
|
3602
|
+
lines.splice(insertIndex, 0, newRow);
|
|
3589
3603
|
content = lines.join("\n");
|
|
3590
3604
|
} else {
|
|
3591
|
-
|
|
3605
|
+
const sectionIndex = lines.findIndex((line) => line.includes("## \u529F\u80FD\u6E05\u5355"));
|
|
3606
|
+
if (sectionIndex !== -1) {
|
|
3607
|
+
const tableLines = [
|
|
3608
|
+
"",
|
|
3609
|
+
"| \u529F\u80FD | Spec \u6587\u4EF6 | \u72B6\u6001 | \u8FDB\u5EA6 | \u5B8C\u6210\u65E5\u671F | \u5907\u6CE8 |",
|
|
3610
|
+
"|------|----------|------|------|---------|------|",
|
|
3611
|
+
newRow,
|
|
3612
|
+
""
|
|
3613
|
+
];
|
|
3614
|
+
lines.splice(sectionIndex + 1, 0, ...tableLines);
|
|
3615
|
+
content = lines.join("\n");
|
|
3616
|
+
} else {
|
|
3617
|
+
content += `
|
|
3592
3618
|
${newRow}
|
|
3593
3619
|
`;
|
|
3620
|
+
}
|
|
3594
3621
|
}
|
|
3595
3622
|
}
|
|
3596
3623
|
await FileUtils.write(aiMemoryFile, content);
|
|
3597
|
-
logger.success("AI_MEMORY.md \u5DF2\u66F4\u65B0");
|
|
3598
3624
|
}
|
|
3599
3625
|
async function showSpecPreview(specFile) {
|
|
3600
3626
|
logger.newLine();
|