sdd-flow-kit 1.3.21 → 1.3.22
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 +42 -13
- package/dist/core/inferProject.js +26 -0
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -27,15 +27,42 @@ const runGuard_1 = require("./steps/runGuard");
|
|
|
27
27
|
const bootstrap_1 = require("./core/bootstrap");
|
|
28
28
|
const projectRoots_1 = require("./core/projectRoots");
|
|
29
29
|
const versionIntent_1 = require("./core/versionIntent");
|
|
30
|
+
const inferProject_1 = require("./core/inferProject");
|
|
30
31
|
const ALLOWED_AGENTS = ["cursor", "claude-code", "codex", "openclaw", "custom"];
|
|
31
|
-
|
|
32
|
+
/** 读取 flag 后的参数;allowMultiWord 时合并至下一个以 - 开头的 token(支持未加引号的 AD Tools)。 */
|
|
33
|
+
function getArgValue(flag, options) {
|
|
32
34
|
const idx = process_1.default.argv.indexOf(flag);
|
|
33
35
|
if (idx === -1)
|
|
34
36
|
return null;
|
|
35
|
-
const
|
|
36
|
-
if (!
|
|
37
|
+
const first = process_1.default.argv[idx + 1];
|
|
38
|
+
if (!first || first.startsWith("-"))
|
|
37
39
|
return null;
|
|
38
|
-
|
|
40
|
+
if (!(options === null || options === void 0 ? void 0 : options.allowMultiWord))
|
|
41
|
+
return first;
|
|
42
|
+
const parts = [first];
|
|
43
|
+
for (let i = idx + 2; i < process_1.default.argv.length; i += 1) {
|
|
44
|
+
const token = process_1.default.argv[i];
|
|
45
|
+
if (token.startsWith("-"))
|
|
46
|
+
break;
|
|
47
|
+
parts.push(token);
|
|
48
|
+
}
|
|
49
|
+
return parts.join(" ");
|
|
50
|
+
}
|
|
51
|
+
/** 统计 flag 在 argv 中占用的 token 数(含多词值),供 getFreeTextArgs 跳过。 */
|
|
52
|
+
function countFlagArgTokens(flag) {
|
|
53
|
+
const idx = process_1.default.argv.indexOf(flag);
|
|
54
|
+
if (idx === -1)
|
|
55
|
+
return 0;
|
|
56
|
+
if (flag === "--project") {
|
|
57
|
+
const raw = getArgValue("--project", { allowMultiWord: true });
|
|
58
|
+
if (!raw)
|
|
59
|
+
return 1;
|
|
60
|
+
return 1 + raw.split(" ").length;
|
|
61
|
+
}
|
|
62
|
+
const next = process_1.default.argv[idx + 1];
|
|
63
|
+
if (!next || next.startsWith("-"))
|
|
64
|
+
return 1;
|
|
65
|
+
return 2;
|
|
39
66
|
}
|
|
40
67
|
function getFreeTextArgs(startIndex) {
|
|
41
68
|
const flagsWithValue = new Set([
|
|
@@ -64,7 +91,8 @@ function getFreeTextArgs(startIndex) {
|
|
|
64
91
|
continue;
|
|
65
92
|
}
|
|
66
93
|
if (flagsWithValue.has(token)) {
|
|
67
|
-
|
|
94
|
+
const consumed = countFlagArgTokens(token);
|
|
95
|
+
i += Math.max(consumed - 1, 0);
|
|
68
96
|
continue;
|
|
69
97
|
}
|
|
70
98
|
if (token.startsWith("--"))
|
|
@@ -142,7 +170,7 @@ function printHelp() {
|
|
|
142
170
|
" 环境变量 SDD_FLOW_KIT_LEGACY_MONOREPO=1 恢复「仓库根无 package.json 时落到 frontend/」",
|
|
143
171
|
" --agent <name> cursor | claude-code | codex | openclaw | custom(默认 claude-code)",
|
|
144
172
|
" --branch <name> 开发分支;不存在会自动创建",
|
|
145
|
-
" --project <name> OMS | ADI | 欢盟 | AD Tools | BreakX(默认 OMS
|
|
173
|
+
" --project <name> OMS | ADI | 欢盟 | AD Tools | BreakX(默认 OMS;支持 \"AD Tools\" / AD Tools / adtools)",
|
|
146
174
|
" -y 非交互模式(使用默认值)",
|
|
147
175
|
" --dry-run 预演模式:仅检测并输出计划,不执行写入/安装/切分支",
|
|
148
176
|
" --plan-json 输出机器可读 JSON 计划结果",
|
|
@@ -152,7 +180,7 @@ function printHelp() {
|
|
|
152
180
|
].join("\n"));
|
|
153
181
|
}
|
|
154
182
|
async function main() {
|
|
155
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l
|
|
183
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
|
|
156
184
|
const cmd = process_1.default.argv[2];
|
|
157
185
|
if (!cmd || cmd === "--help" || cmd === "-h") {
|
|
158
186
|
printHelp();
|
|
@@ -216,7 +244,9 @@ async function main() {
|
|
|
216
244
|
? ((_h = getArgValue("--text")) !== null && _h !== void 0 ? _h : getFreeTextArgs(3)).trim()
|
|
217
245
|
: "";
|
|
218
246
|
const guardIntent = rawGuardText ? (0, versionIntent_1.parseVersionIntent)(rawGuardText) : null;
|
|
219
|
-
const
|
|
247
|
+
const rawProjectArg = getArgValue("--project", { allowMultiWord: true });
|
|
248
|
+
const resolvedProject = rawProjectArg ? (0, inferProject_1.resolveProjectKindInput)(rawProjectArg) : null;
|
|
249
|
+
const projectKind = (_j = resolvedProject !== null && resolvedProject !== void 0 ? resolvedProject : ((guardIntent === null || guardIntent === void 0 ? void 0 : guardIntent.product) ? (0, inferProject_1.resolveProjectKindInput)(guardIntent.product) : null)) !== null && _j !== void 0 ? _j : "OMS";
|
|
220
250
|
if (!ALLOWED_AGENTS.includes(agentValue)) {
|
|
221
251
|
// eslint-disable-next-line no-console
|
|
222
252
|
console.error(`不支持的 --agent: ${agentValue}`);
|
|
@@ -225,10 +255,9 @@ async function main() {
|
|
|
225
255
|
return;
|
|
226
256
|
}
|
|
227
257
|
const agent = agentValue;
|
|
228
|
-
|
|
229
|
-
if (!allowedProjects.includes(projectKind)) {
|
|
258
|
+
if (rawProjectArg && !resolvedProject) {
|
|
230
259
|
// eslint-disable-next-line no-console
|
|
231
|
-
console.error(`不支持的 --project: ${
|
|
260
|
+
console.error(`不支持的 --project: ${rawProjectArg}(可选:${inferProject_1.ALLOWED_PROJECTS.join(" / ")};别名示例:adtools)`);
|
|
232
261
|
process_1.default.exitCode = 1;
|
|
233
262
|
return;
|
|
234
263
|
}
|
|
@@ -467,7 +496,7 @@ async function main() {
|
|
|
467
496
|
process_1.default.exitCode = 1;
|
|
468
497
|
return;
|
|
469
498
|
}
|
|
470
|
-
const from = ((
|
|
499
|
+
const from = ((_k = getArgValue("--from")) !== null && _k !== void 0 ? _k : "docs-done");
|
|
471
500
|
if (!CHAIN_FROM.includes(from)) {
|
|
472
501
|
// eslint-disable-next-line no-console
|
|
473
502
|
console.error(`chain 需要 --from ${CHAIN_FROM.join("|")}`);
|
|
@@ -496,7 +525,7 @@ async function main() {
|
|
|
496
525
|
process_1.default.exitCode = 1;
|
|
497
526
|
return;
|
|
498
527
|
}
|
|
499
|
-
const modeArg = (
|
|
528
|
+
const modeArg = (_l = getArgValue("--execution-mode")) !== null && _l !== void 0 ? _l : getArgValue("--executionMode");
|
|
500
529
|
const textArg = getArgValue("--text");
|
|
501
530
|
const strictCommands = process_1.default.argv.includes("--strict-commands");
|
|
502
531
|
const result = await (0, runSessionMode_1.runSessionMode)({
|
|
@@ -5,6 +5,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.PRODUCT_PREFIX_BY_KIND = exports.DOC_SKILL_BY_KIND = exports.ALLOWED_PROJECTS = void 0;
|
|
7
7
|
exports.productToKind = productToKind;
|
|
8
|
+
exports.resolveProjectKindInput = resolveProjectKindInput;
|
|
8
9
|
exports.resolveDocSkillDir = resolveDocSkillDir;
|
|
9
10
|
exports.inferProjectKind = inferProjectKind;
|
|
10
11
|
const promises_1 = __importDefault(require("fs/promises"));
|
|
@@ -38,6 +39,31 @@ function productToKind(product) {
|
|
|
38
39
|
return "BreakX";
|
|
39
40
|
return "OMS";
|
|
40
41
|
}
|
|
42
|
+
/**
|
|
43
|
+
* 将 CLI `--project` 入参解析为规范项目类型。
|
|
44
|
+
* 支持精确名、别名(adtools / ad-tools)及带空格写法;无法识别时返回 null(避免 productToKind 默认回落 OMS)。
|
|
45
|
+
*/
|
|
46
|
+
function resolveProjectKindInput(raw) {
|
|
47
|
+
const value = raw.trim();
|
|
48
|
+
if (!value)
|
|
49
|
+
return null;
|
|
50
|
+
if (exports.ALLOWED_PROJECTS.includes(value)) {
|
|
51
|
+
return value;
|
|
52
|
+
}
|
|
53
|
+
const upper = value.toUpperCase();
|
|
54
|
+
const compact = upper.replace(/[\s_-]+/g, "");
|
|
55
|
+
if (upper === "ADI" || upper.includes("ADINSIGHT"))
|
|
56
|
+
return "ADI";
|
|
57
|
+
if (upper === "OMS" || upper.includes("OPERATION"))
|
|
58
|
+
return "OMS";
|
|
59
|
+
if (value === "欢盟" || upper === "HUAN" || upper === "HUANMENG" || compact === "HM")
|
|
60
|
+
return "欢盟";
|
|
61
|
+
if (upper.includes("AD TOOLS") || compact === "ADTOOLS")
|
|
62
|
+
return "AD Tools";
|
|
63
|
+
if (compact === "BREAKX" || upper.includes("POQUAN") || value.includes("破圈"))
|
|
64
|
+
return "BreakX";
|
|
65
|
+
return null;
|
|
66
|
+
}
|
|
41
67
|
/** 从 projectRoot 向上查找 docs/*-doc-skill(适配 frontend 子目录 + 根目录 docs) */
|
|
42
68
|
async function resolveDocSkillDir(projectRoot, kind) {
|
|
43
69
|
const dirName = exports.DOC_SKILL_BY_KIND[kind];
|