sdd-flow-kit 1.0.1 → 1.0.3

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 CHANGED
@@ -15,6 +15,9 @@
15
15
 
16
16
  1. 进入你要开发的项目目录
17
17
  2. 安装:`npm i -D sdd-flow-kit`
18
+ - 安装后会自动执行一次初始化(postinstall)
19
+ - 交互终端下会提示选择项目类型(OMS / ADI / 欢盟 / AD Tools,默认 OMS)
20
+ - 非交互环境自动使用默认值(agent=claude-code, project=OMS)
18
21
  3. 安装流程(安装即用,默认 `claude-code`):`npx sdd-flow-kit install`
19
22
  - 会自动安装对应 AI 环境并写入项目级触发 Skill(仅在“开发 <产品> <版本> 需求/版本/PRD”场景触发)
20
23
  - 会在项目根目录生成 `docs/<项目>-doc-skill/`(用于 PRD 下载脚本与说明),可通过 `--project` 选择:`OMS` / `ADI` / `欢盟` / `AD Tools`(默认 `OMS`)
@@ -22,6 +25,8 @@
22
25
  5. (可选)环境健检:`npx sdd-flow-kit doctor --agent claude-code`
23
26
  6. 完成后,直接在 Cursor / Claude Code / Codex / OpenClaw 中用自然语言发起需求,例如:`开发 ADI 2.3.2 需求`
24
27
 
28
+ > 可通过环境变量覆盖安装时默认项目类型:`SDD_FLOW_KIT_PROJECT=ADI npm i -D sdd-flow-kit`
29
+
25
30
  #### 使用说明
26
31
 
27
32
  1. `install`(等价 `setup`):提示选择开发环境(cursor/claude-code/codex/openclaw,默认 claude-code)与开发分支(无则自动创建),并检测/安装 openspec+superpower 基础环境,同时写入项目级 Skill
@@ -0,0 +1,46 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const node_path_1 = __importDefault(require("node:path"));
7
+ const node_process_1 = __importDefault(require("node:process"));
8
+ const setupProject_1 = require("./steps/setupProject");
9
+ const ALLOWED_PROJECTS = ["OMS", "ADI", "欢盟", "AD Tools"];
10
+ function resolveProjectKindFromEnv() {
11
+ const raw = (node_process_1.default.env.SDD_FLOW_KIT_PROJECT ?? "").trim();
12
+ if (ALLOWED_PROJECTS.includes(raw)) {
13
+ return raw;
14
+ }
15
+ return "OMS";
16
+ }
17
+ async function main() {
18
+ // npm/pnpm 安装依赖时,INIT_CWD 指向用户项目根目录。
19
+ const initCwd = node_process_1.default.env.INIT_CWD ? node_path_1.default.resolve(node_process_1.default.env.INIT_CWD) : null;
20
+ const pkgDir = node_path_1.default.resolve(__dirname, "..");
21
+ const projectRoot = initCwd ?? node_process_1.default.cwd();
22
+ // 避免在本包自身仓库开发安装依赖时重复触发自动初始化。
23
+ if (projectRoot === pkgDir)
24
+ return;
25
+ const isInteractive = Boolean(node_process_1.default.stdin.isTTY && node_process_1.default.stdout.isTTY);
26
+ const projectKind = resolveProjectKindFromEnv();
27
+ // eslint-disable-next-line no-console
28
+ console.log(`[sdd-flow-kit] postinstall bootstrap at: ${projectRoot}`);
29
+ // eslint-disable-next-line no-console
30
+ console.log(`[sdd-flow-kit] interactive=${isInteractive}, defaultProject=${projectKind}`);
31
+ await (0, setupProject_1.setupProject)({
32
+ projectRoot,
33
+ agent: "claude-code",
34
+ // 交互安装允许用户在 setupProject 内选择 agent/project/branch
35
+ yes: !isInteractive,
36
+ dryRun: false,
37
+ projectKind,
38
+ });
39
+ // eslint-disable-next-line no-console
40
+ console.log("[sdd-flow-kit] setup completed");
41
+ }
42
+ main().catch((err) => {
43
+ // 不阻断依赖安装,仅告警
44
+ // eslint-disable-next-line no-console
45
+ console.warn("[sdd-flow-kit] postinstall setup skipped:", err instanceof Error ? err.message : err);
46
+ });
@@ -160,13 +160,28 @@ function skillInstallPath(projectRoot, agent) {
160
160
  return null;
161
161
  return node_path_1.default.join(projectRoot, rel);
162
162
  }
163
- async function installAgentSkill(projectRoot, agent) {
164
- const target = skillInstallPath(projectRoot, agent);
165
- if (!target)
163
+ function allSkillInstallPaths(projectRoot) {
164
+ const agents = ["cursor", "claude-code", "codex", "openclaw"];
165
+ return agents
166
+ .map((agent) => skillInstallPath(projectRoot, agent))
167
+ .filter((p) => Boolean(p));
168
+ }
169
+ async function installAgentSkill(projectRoot) {
170
+ const targets = allSkillInstallPaths(projectRoot);
171
+ if (targets.length === 0)
166
172
  return;
167
173
  const template = await (0, templates_1.loadTemplateText)("artifacts/06-agent-skill.template.md");
168
- const content = template.replaceAll("{{AGENT_NAME}}", agent);
169
- await (0, fs_1.writeTextFileEnsuredDir)(target, content);
174
+ for (const target of targets) {
175
+ const agentName = target.includes("/.cursor/")
176
+ ? "cursor"
177
+ : target.includes("/.claude/")
178
+ ? "claude-code"
179
+ : target.includes("/.codex/")
180
+ ? "codex"
181
+ : "openclaw";
182
+ const content = template.replaceAll("{{AGENT_NAME}}", agentName);
183
+ await (0, fs_1.writeTextFileEnsuredDir)(target, content);
184
+ }
170
185
  }
171
186
  function renderVars(template, vars) {
172
187
  let out = template;
@@ -249,15 +264,14 @@ async function setupProject(options) {
249
264
  plannedActions.push("environment already ready, no setup needed");
250
265
  }
251
266
  if (options.dryRun) {
252
- const skillPath = skillInstallPath(options.projectRoot, selectedAgent);
253
- if (skillPath) {
267
+ for (const skillPath of allSkillInstallPaths(options.projectRoot)) {
254
268
  plannedActions.push(`would install skill: ${skillPath}`);
255
269
  }
256
270
  const { dir } = docSkillDirName(selectedKind);
257
271
  plannedActions.push(`would install docs skill: ${node_path_1.default.join(options.projectRoot, "docs", dir)}`);
258
272
  }
259
273
  else {
260
- await installAgentSkill(options.projectRoot, selectedAgent);
274
+ await installAgentSkill(options.projectRoot);
261
275
  skillInstalled = true;
262
276
  await installDocsSkill(options.projectRoot, selectedKind);
263
277
  docsSkillInstalled = true;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sdd-flow-kit",
3
- "version": "1.0.1",
3
+ "version": "1.0.3",
4
4
  "private": false,
5
5
  "description": "Cross-agent SDD automated development workflow kit (ADI/ADI-like).",
6
6
  "license": "MIT",
@@ -17,7 +17,8 @@
17
17
  "scripts": {
18
18
  "build": "tsc -p tsconfig.json",
19
19
  "start": "node dist/cli.js",
20
- "prepublishOnly": "npm run build"
20
+ "prepublishOnly": "npm run build",
21
+ "postinstall": "node dist/postinstall.js"
21
22
  },
22
23
  "devDependencies": {
23
24
  "@types/node": "^20.14.10",