sdd-flow-kit 1.0.14 → 1.0.16
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 +8 -3
- package/dist/postinstall.js +34 -18
- package/dist/steps/setupProject.js +15 -5
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -18,8 +18,9 @@
|
|
|
18
18
|
检查是否安装 - `ls .cursor/skills/sdd-flow-kit/SKILL.md`
|
|
19
19
|
- `ls .claude/skills/sdd-flow-kit/SKILL.md`
|
|
20
20
|
- `ls docs/*-doc-skill/SKILL.md`
|
|
21
|
-
3.
|
|
22
|
-
- `node ./node_modules/sdd-flow-kit/dist/postinstall.js
|
|
21
|
+
3. 若 skill 未生成,执行手动兜底:
|
|
22
|
+
- `node ./node_modules/sdd-flow-kit/dist/postinstall.js`(轻量,秒级)
|
|
23
|
+
- 或 `npx sdd-flow-kit install -y`(完整环境)
|
|
23
24
|
|
|
24
25
|
4. (可选)预演安装:`npx sdd-flow-kit install --dry-run --plan-json`
|
|
25
26
|
5. (可选)环境健检:`npx sdd-flow-kit doctor --agent claude-code`
|
|
@@ -44,7 +45,11 @@
|
|
|
44
45
|
|
|
45
46
|
团队推荐安装命令(稳妥):
|
|
46
47
|
|
|
47
|
-
`pnpm add -D sdd-flow-kit
|
|
48
|
+
`pnpm add -D sdd-flow-kit`
|
|
49
|
+
|
|
50
|
+
> `postinstall` 仅做**轻量**初始化(写入 skill / Cursor 规则 / docs-skill / `.opsx/config.json`),**不会**交互提问,也**不会**跑 `npx opsx-workflow`(避免 `pnpm i` 卡住)。
|
|
51
|
+
> 完整环境(分支切换 + opsx-workflow)请另执行:`npx sdd-flow-kit install -y`
|
|
52
|
+
> 跳过 postinstall:`SDD_FLOW_KIT_SKIP_POSTINSTALL=1 pnpm add -D sdd-flow-kit`
|
|
48
53
|
|
|
49
54
|
#### 使用说明
|
|
50
55
|
|
package/dist/postinstall.js
CHANGED
|
@@ -8,13 +8,6 @@ const promises_1 = __importDefault(require("node:fs/promises"));
|
|
|
8
8
|
const node_process_1 = __importDefault(require("node:process"));
|
|
9
9
|
const setupProject_1 = require("./steps/setupProject");
|
|
10
10
|
const ALLOWED_PROJECTS = ["OMS", "ADI", "欢盟", "AD Tools"];
|
|
11
|
-
function resolveProjectKindFromEnv() {
|
|
12
|
-
const raw = (node_process_1.default.env.SDD_FLOW_KIT_PROJECT ?? "").trim();
|
|
13
|
-
if (ALLOWED_PROJECTS.includes(raw)) {
|
|
14
|
-
return raw;
|
|
15
|
-
}
|
|
16
|
-
return "OMS";
|
|
17
|
-
}
|
|
18
11
|
async function inferProjectKind(projectRoot) {
|
|
19
12
|
const fromEnv = (node_process_1.default.env.SDD_FLOW_KIT_PROJECT ?? "").trim();
|
|
20
13
|
if (ALLOWED_PROJECTS.includes(fromEnv)) {
|
|
@@ -30,7 +23,6 @@ async function inferProjectKind(projectRoot) {
|
|
|
30
23
|
return "欢盟";
|
|
31
24
|
if (hit("ad-tools") || hit("adtools") || hit("tools"))
|
|
32
25
|
return "AD Tools";
|
|
33
|
-
// 尝试读取项目 package.json 的 name 做二次推断
|
|
34
26
|
try {
|
|
35
27
|
const pkgText = await promises_1.default.readFile(node_path_1.default.join(projectRoot, "package.json"), "utf8");
|
|
36
28
|
const pkg = JSON.parse(pkgText);
|
|
@@ -50,33 +42,57 @@ async function inferProjectKind(projectRoot) {
|
|
|
50
42
|
}
|
|
51
43
|
return "OMS";
|
|
52
44
|
}
|
|
45
|
+
async function inferAgent(projectRoot) {
|
|
46
|
+
const fromEnv = (node_process_1.default.env.SDD_FLOW_KIT_AGENT ?? "").trim();
|
|
47
|
+
const allowed = ["cursor", "claude-code", "codex", "openclaw"];
|
|
48
|
+
if (allowed.includes(fromEnv))
|
|
49
|
+
return fromEnv;
|
|
50
|
+
const exists = async (rel) => {
|
|
51
|
+
try {
|
|
52
|
+
await promises_1.default.access(node_path_1.default.join(projectRoot, rel));
|
|
53
|
+
return true;
|
|
54
|
+
}
|
|
55
|
+
catch {
|
|
56
|
+
return false;
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
if (await exists(".cursor"))
|
|
60
|
+
return "cursor";
|
|
61
|
+
if (await exists(".claude"))
|
|
62
|
+
return "claude-code";
|
|
63
|
+
if (await exists(".codex"))
|
|
64
|
+
return "codex";
|
|
65
|
+
if (await exists(".openclaw"))
|
|
66
|
+
return "openclaw";
|
|
67
|
+
return "cursor";
|
|
68
|
+
}
|
|
53
69
|
async function main() {
|
|
54
|
-
|
|
70
|
+
if (node_process_1.default.env.SDD_FLOW_KIT_SKIP_POSTINSTALL === "1") {
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
55
73
|
const initCwd = node_process_1.default.env.INIT_CWD ? node_path_1.default.resolve(node_process_1.default.env.INIT_CWD) : null;
|
|
56
74
|
const pkgDir = node_path_1.default.resolve(__dirname, "..");
|
|
57
75
|
const projectRoot = initCwd ?? node_process_1.default.cwd();
|
|
58
|
-
// 避免在本包自身仓库开发安装依赖时重复触发自动初始化。
|
|
59
76
|
if (projectRoot === pkgDir)
|
|
60
77
|
return;
|
|
61
|
-
const isInteractive = Boolean(node_process_1.default.stdin.isTTY && node_process_1.default.stdout.isTTY);
|
|
62
78
|
const projectKind = await inferProjectKind(projectRoot);
|
|
79
|
+
const agent = await inferAgent(projectRoot);
|
|
63
80
|
// eslint-disable-next-line no-console
|
|
64
|
-
console.log(`[sdd-flow-kit] postinstall
|
|
81
|
+
console.log(`[sdd-flow-kit] postinstall (light) at: ${projectRoot}`);
|
|
65
82
|
// eslint-disable-next-line no-console
|
|
66
|
-
console.log(`[sdd-flow-kit]
|
|
83
|
+
console.log(`[sdd-flow-kit] agent=${agent}, project=${projectKind}`);
|
|
67
84
|
await (0, setupProject_1.setupProject)({
|
|
68
85
|
projectRoot,
|
|
69
|
-
agent
|
|
70
|
-
|
|
71
|
-
|
|
86
|
+
agent,
|
|
87
|
+
yes: true,
|
|
88
|
+
light: true,
|
|
72
89
|
dryRun: false,
|
|
73
90
|
projectKind,
|
|
74
91
|
});
|
|
75
92
|
// eslint-disable-next-line no-console
|
|
76
|
-
console.log("[sdd-flow-kit] setup
|
|
93
|
+
console.log("[sdd-flow-kit] light setup done (skills/rules only). Full env: npx sdd-flow-kit install -y");
|
|
77
94
|
}
|
|
78
95
|
main().catch((err) => {
|
|
79
|
-
// 不阻断依赖安装,仅告警
|
|
80
96
|
// eslint-disable-next-line no-console
|
|
81
97
|
console.warn("[sdd-flow-kit] postinstall setup skipped:", err instanceof Error ? err.message : err);
|
|
82
98
|
});
|
|
@@ -268,20 +268,29 @@ async function setupProject(options) {
|
|
|
268
268
|
const plannedActions = [];
|
|
269
269
|
const branches = listLocalBranches(options.projectRoot);
|
|
270
270
|
const branchExists = branches.includes(selectedBranch);
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
:
|
|
274
|
-
|
|
271
|
+
let branchResult;
|
|
272
|
+
if (options.light) {
|
|
273
|
+
branchResult = { branch: selectedBranch, created: false };
|
|
274
|
+
plannedActions.push("light mode: skipped git branch checkout");
|
|
275
|
+
}
|
|
276
|
+
else if (options.dryRun) {
|
|
277
|
+
branchResult = { branch: selectedBranch, created: !branchExists };
|
|
275
278
|
plannedActions.push(branchExists
|
|
276
279
|
? `would checkout existing branch: ${selectedBranch}`
|
|
277
280
|
: `would create and checkout branch: ${selectedBranch}`);
|
|
278
281
|
}
|
|
282
|
+
else {
|
|
283
|
+
branchResult = ensureBranch(options.projectRoot, selectedBranch);
|
|
284
|
+
}
|
|
279
285
|
let environmentReady = await isEditorEnvironmentReady(options.projectRoot, selectedAgent);
|
|
280
286
|
let setupExecuted = false;
|
|
281
287
|
let skillInstalled = false;
|
|
282
288
|
let docsSkillInstalled = false;
|
|
283
289
|
let opsxConfigInstalled = false;
|
|
284
|
-
if (
|
|
290
|
+
if (options.light) {
|
|
291
|
+
plannedActions.push("light mode: skipped npx @lixin5257xxx/opsx-workflow setup");
|
|
292
|
+
}
|
|
293
|
+
else if (!environmentReady) {
|
|
285
294
|
const { cmd, args } = buildSetupCommand(options.projectRoot, selectedAgent);
|
|
286
295
|
if (options.dryRun) {
|
|
287
296
|
plannedActions.push(`would run: ${cmd} ${args.join(" ")}`);
|
|
@@ -332,6 +341,7 @@ async function setupProject(options) {
|
|
|
332
341
|
`skillInstalled: ${skillInstalled}`,
|
|
333
342
|
`docsSkillInstalled: ${docsSkillInstalled}`,
|
|
334
343
|
`opsxConfigInstalled: ${opsxConfigInstalled}`,
|
|
344
|
+
`light: ${Boolean(options.light)}`,
|
|
335
345
|
`dryRun: ${Boolean(options.dryRun)}`,
|
|
336
346
|
"",
|
|
337
347
|
"plannedActions:",
|