@leocm/flowcraft 2.2.0 → 2.3.0
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 +7 -2
- package/bin/cli.js +108 -108
- package/flowcraft.yaml +30 -30
- package/install.sh +24 -24
- package/lib/args.js +38 -38
- package/lib/config.js +20 -20
- package/lib/copy.js +131 -131
- package/lib/fix.js +110 -110
- package/lib/fsutil.js +104 -104
- package/lib/global.js +229 -229
- package/lib/init.js +43 -43
- package/lib/runtime.js +84 -84
- package/lib/version.js +55 -55
- package/lib/wizard.js +125 -125
- package/package.json +33 -33
- package/presets/backend.yaml +20 -20
- package/presets/default.yaml +15 -15
- package/presets/frontend.yaml +20 -20
- package/presets/quick-fix.yaml +15 -15
- package/setup/.claude/hooks/check-phase-test.py +152 -152
- package/setup/.claude/hooks/check-phase-write.py +235 -235
- package/setup/.claude/hooks/dispatch.py +67 -67
- package/setup/.claude/hooks/file-suggestion.py +45 -45
- package/setup/.claude/hooks/flowcraft_env.py +162 -162
- package/setup/.claude/hooks/permission-request.py +132 -132
- package/setup/.claude/hooks/post-tool-failure.py +36 -36
- package/setup/.claude/hooks/pre-compact.py +66 -66
- package/setup/.claude/hooks/review-runner.py +846 -846
- package/setup/.claude/hooks/setup-keys.py +282 -282
- package/setup/.claude/hooks/statusline.py +63 -63
- package/setup/.claude/hooks/stop-check.py +186 -186
- package/setup/.claude/hooks/subagent-start.py +50 -50
- package/setup/.claude/hooks/subagent-stop.py +63 -63
- package/setup/.claude/hooks/task-completed.py +57 -57
- package/setup/.claude/hooks/task_manager.py +592 -592
- package/setup/.claude/hooks/user-prompt-submit.py +91 -91
- package/setup/.claude/settings.json +233 -233
- package/setup/.claude/skills/Pstatus/SKILL.md +68 -68
- package/setup/.claude/skills/archive/SKILL.md +195 -195
- package/setup/.claude/skills/brainstorming/SKILL.md +5 -5
- package/setup/.claude/skills/brainstorming/scripts/server.cjs +723 -723
- package/setup/.claude/skills/brainstorming/scripts/start-server.py +245 -245
- package/setup/.claude/skills/brainstorming/scripts/stop-server.py +178 -178
- package/setup/.claude/skills/brainstorming/visual-companion.md +298 -298
- package/setup/.claude/skills/chrome-integration/SKILL.md +66 -66
- package/setup/.claude/skills/code-review/SKILL.md +264 -264
- package/setup/.claude/skills/executing-plans/SKILL.md +1 -1
- package/setup/.claude/skills/gitnexus/gitnexus-cli/SKILL.md +67 -67
- package/setup/.claude/skills/gitnexus/gitnexus-debugging/SKILL.md +1 -1
- package/setup/.claude/skills/gitnexus/gitnexus-exploring/SKILL.md +1 -1
- package/setup/.claude/skills/gitnexus/gitnexus-guide/SKILL.md +1 -1
- package/setup/.claude/skills/gitnexus/gitnexus-impact-analysis/SKILL.md +1 -1
- package/setup/.claude/skills/gitnexus/gitnexus-refactoring/SKILL.md +1 -1
- package/setup/.claude/skills/methodology/SKILL.md +124 -0
- package/setup/.claude/skills/phase/SKILL.md +62 -62
- package/setup/.claude/skills/playwright/SKILL.md +85 -85
- package/setup/.claude/skills/review/SKILL.md +97 -97
- package/setup/.claude/skills/task/SKILL.md +26 -26
- package/setup/.claude/skills/test-driven-development/SKILL.md +1 -1
- package/setup/.claude/skills/ui-ux-pro-max/SKILL.md +1 -1
- package/setup/.claude/skills/verification-before-completion/SKILL.md +1 -1
- package/setup/.claude/skills/writing-plans/SKILL.md +1 -1
- package/setup/.codex/.agents/skills/archive/SKILL.md +195 -195
- package/setup/.codex/.agents/skills/brainstorming/SKILL.md +5 -5
- package/setup/.codex/.agents/skills/brainstorming/scripts/server.cjs +723 -723
- package/setup/.codex/.agents/skills/brainstorming/scripts/start-server.py +245 -245
- package/setup/.codex/.agents/skills/brainstorming/scripts/stop-server.py +178 -178
- package/setup/.codex/.agents/skills/brainstorming/visual-companion.md +298 -298
- package/setup/.codex/.agents/skills/chrome-integration/SKILL.md +66 -66
- package/setup/.codex/.agents/skills/code-review/SKILL.md +264 -264
- package/setup/.codex/.agents/skills/executing-plans/SKILL.md +1 -1
- package/setup/.codex/.agents/skills/gitnexus/gitnexus-cli/SKILL.md +67 -67
- package/setup/.codex/.agents/skills/gitnexus/gitnexus-debugging/SKILL.md +1 -1
- package/setup/.codex/.agents/skills/gitnexus/gitnexus-exploring/SKILL.md +1 -1
- package/setup/.codex/.agents/skills/gitnexus/gitnexus-guide/SKILL.md +1 -1
- package/setup/.codex/.agents/skills/gitnexus/gitnexus-impact-analysis/SKILL.md +1 -1
- package/setup/.codex/.agents/skills/gitnexus/gitnexus-refactoring/SKILL.md +1 -1
- package/setup/.codex/.agents/skills/methodology/SKILL.md +124 -0
- package/setup/.codex/.agents/skills/phase/SKILL.md +62 -62
- package/setup/.codex/.agents/skills/playwright/SKILL.md +85 -85
- package/setup/.codex/.agents/skills/review/SKILL.md +97 -97
- package/setup/.codex/.agents/skills/task/SKILL.md +27 -27
- package/setup/.codex/.agents/skills/test-driven-development/SKILL.md +1 -1
- package/setup/.codex/.agents/skills/ui-ux-pro-max/SKILL.md +1 -1
- package/setup/.codex/.agents/skills/verification-before-completion/SKILL.md +1 -1
- package/setup/.codex/.agents/skills/writing-plans/SKILL.md +1 -1
- package/setup/.codex/hooks/review-runner.py +851 -851
- package/setup/.codex/hooks/setup-keys.py +287 -287
- package/setup/AGENTS.md +11 -1
- package/setup/CLAUDE.md +11 -1
- package/setup/install.sh +24 -24
- package/setup/tests/test_decision_timeout.py +241 -241
- package/setup/tests/test_hook_guards.py +357 -357
- package/setup/tests/test_sdlc_bootstrap.py +167 -167
- package/setup/tests/test_sessionlog_switch.py +199 -199
- package/setup/tests/test_task_manager.py +148 -148
package/lib/runtime.js
CHANGED
|
@@ -1,84 +1,84 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* runtime.js — 运行时探测/安装(R4:ensure_runtimes 等价,Python 必需 + Node 可选)
|
|
3
|
-
*/
|
|
4
|
-
'use strict';
|
|
5
|
-
|
|
6
|
-
const { spawnSync } = require('node:child_process');
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* 探测 Python 3 命令(python3/python/py/py3 顺序,对齐 detect_python)
|
|
10
|
-
* @returns {string|null} 可用命令名,找不到返回 null
|
|
11
|
-
*/
|
|
12
|
-
function detectPython() {
|
|
13
|
-
for (const cand of ['python3', 'python', 'py', 'py3']) {
|
|
14
|
-
const r = spawnSync(cand, ['--version'], { encoding: 'utf8', shell: true });
|
|
15
|
-
const out = `${r.stdout || ''}${r.stderr || ''}`;
|
|
16
|
-
if (out.includes('Python 3')) return cand;
|
|
17
|
-
}
|
|
18
|
-
return null;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
* 探测 Node.js(>=20,对齐 detect_node)
|
|
23
|
-
* @returns {boolean} 是否可用
|
|
24
|
-
*/
|
|
25
|
-
function detectNode() {
|
|
26
|
-
const r = spawnSync('node', ['--version'], { encoding: 'utf8', shell: true });
|
|
27
|
-
const major = parseInt((r.stdout || '').replace(/^v/, ''), 10);
|
|
28
|
-
return Number.isInteger(major) && major >= 20;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
/**
|
|
32
|
-
* 尝试安装 Python 3(winget/brew/apt/官方安装器,尽力而为)
|
|
33
|
-
* @returns {boolean} 是否执行成功
|
|
34
|
-
*/
|
|
35
|
-
function installPython() {
|
|
36
|
-
console.log('[运行时] 未检测到 Python 3,开始安装 Python 3.13 ...');
|
|
37
|
-
const tryRun = (cmd, args) => spawnSync(cmd, args, { encoding: 'utf8', shell: true }).status === 0;
|
|
38
|
-
if (tryRun('winget', ['install', '-e', '--id', 'Python.Python.3.13', '--accept-source-agreements', '--accept-package-agreements'])) return true;
|
|
39
|
-
if (tryRun('brew', ['install', 'python@3.13'])) return true;
|
|
40
|
-
if (tryRun('apt-get', ['install', '-y', 'python3'])) return true;
|
|
41
|
-
console.log('未能自动安装 Python,请手动安装 3.13(https://www.python.org/downloads/)');
|
|
42
|
-
return false;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
/**
|
|
46
|
-
* 尝试安装 Node.js 24(winget/brew/apt/官方安装器,尽力而为)
|
|
47
|
-
* @returns {boolean} 是否执行成功
|
|
48
|
-
*/
|
|
49
|
-
function installNode() {
|
|
50
|
-
console.log('[运行时] 未检测到可用 Node.js,开始安装 Node.js 24 ...');
|
|
51
|
-
const tryRun = (cmd, args) => spawnSync(cmd, args, { encoding: 'utf8', shell: true }).status === 0;
|
|
52
|
-
if (tryRun('winget', ['install', '-e', '--id', 'OpenJS.NodeJS.24', '--accept-source-agreements', '--accept-package-agreements'])) return true;
|
|
53
|
-
if (tryRun('brew', ['install', 'node@24'])) return true;
|
|
54
|
-
if (tryRun('apt-get', ['install', '-y', 'nodejs'])) return true;
|
|
55
|
-
console.log('未能自动安装 Node.js,请手动安装 24(https://nodejs.org/)');
|
|
56
|
-
return false;
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
/**
|
|
60
|
-
* 检测/安装运行时(对齐 ensure_runtimes)
|
|
61
|
-
* @returns {string} 探测到的 python 命令(缺失且安装失败时抛错)
|
|
62
|
-
*/
|
|
63
|
-
function ensureRuntimes() {
|
|
64
|
-
console.log('[运行时] 检查 Python 与 Node.js ...');
|
|
65
|
-
let py = detectPython();
|
|
66
|
-
if (!py) {
|
|
67
|
-
installPython();
|
|
68
|
-
py = detectPython();
|
|
69
|
-
if (!py) throw new Error('未找到 Python 3(hooks 依赖),请手动安装后重试');
|
|
70
|
-
console.log(` Python(已安装): ${py}`);
|
|
71
|
-
} else {
|
|
72
|
-
console.log(` Python: ${py}`);
|
|
73
|
-
}
|
|
74
|
-
if (detectNode()) console.log(' Node.js: 可用');
|
|
75
|
-
else {
|
|
76
|
-
installNode();
|
|
77
|
-
if (detectNode()) console.log(' Node.js(已安装): 可用');
|
|
78
|
-
else console.log('警告: Node.js 未就绪(brainstorming 服务需要),可稍后手动安装');
|
|
79
|
-
}
|
|
80
|
-
console.log('');
|
|
81
|
-
return py;
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
module.exports = { detectPython, detectNode, installPython, installNode, ensureRuntimes };
|
|
1
|
+
/**
|
|
2
|
+
* runtime.js — 运行时探测/安装(R4:ensure_runtimes 等价,Python 必需 + Node 可选)
|
|
3
|
+
*/
|
|
4
|
+
'use strict';
|
|
5
|
+
|
|
6
|
+
const { spawnSync } = require('node:child_process');
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* 探测 Python 3 命令(python3/python/py/py3 顺序,对齐 detect_python)
|
|
10
|
+
* @returns {string|null} 可用命令名,找不到返回 null
|
|
11
|
+
*/
|
|
12
|
+
function detectPython() {
|
|
13
|
+
for (const cand of ['python3', 'python', 'py', 'py3']) {
|
|
14
|
+
const r = spawnSync(cand, ['--version'], { encoding: 'utf8', shell: true });
|
|
15
|
+
const out = `${r.stdout || ''}${r.stderr || ''}`;
|
|
16
|
+
if (out.includes('Python 3')) return cand;
|
|
17
|
+
}
|
|
18
|
+
return null;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* 探测 Node.js(>=20,对齐 detect_node)
|
|
23
|
+
* @returns {boolean} 是否可用
|
|
24
|
+
*/
|
|
25
|
+
function detectNode() {
|
|
26
|
+
const r = spawnSync('node', ['--version'], { encoding: 'utf8', shell: true });
|
|
27
|
+
const major = parseInt((r.stdout || '').replace(/^v/, ''), 10);
|
|
28
|
+
return Number.isInteger(major) && major >= 20;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* 尝试安装 Python 3(winget/brew/apt/官方安装器,尽力而为)
|
|
33
|
+
* @returns {boolean} 是否执行成功
|
|
34
|
+
*/
|
|
35
|
+
function installPython() {
|
|
36
|
+
console.log('[运行时] 未检测到 Python 3,开始安装 Python 3.13 ...');
|
|
37
|
+
const tryRun = (cmd, args) => spawnSync(cmd, args, { encoding: 'utf8', shell: true }).status === 0;
|
|
38
|
+
if (tryRun('winget', ['install', '-e', '--id', 'Python.Python.3.13', '--accept-source-agreements', '--accept-package-agreements'])) return true;
|
|
39
|
+
if (tryRun('brew', ['install', 'python@3.13'])) return true;
|
|
40
|
+
if (tryRun('apt-get', ['install', '-y', 'python3'])) return true;
|
|
41
|
+
console.log('未能自动安装 Python,请手动安装 3.13(https://www.python.org/downloads/)');
|
|
42
|
+
return false;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* 尝试安装 Node.js 24(winget/brew/apt/官方安装器,尽力而为)
|
|
47
|
+
* @returns {boolean} 是否执行成功
|
|
48
|
+
*/
|
|
49
|
+
function installNode() {
|
|
50
|
+
console.log('[运行时] 未检测到可用 Node.js,开始安装 Node.js 24 ...');
|
|
51
|
+
const tryRun = (cmd, args) => spawnSync(cmd, args, { encoding: 'utf8', shell: true }).status === 0;
|
|
52
|
+
if (tryRun('winget', ['install', '-e', '--id', 'OpenJS.NodeJS.24', '--accept-source-agreements', '--accept-package-agreements'])) return true;
|
|
53
|
+
if (tryRun('brew', ['install', 'node@24'])) return true;
|
|
54
|
+
if (tryRun('apt-get', ['install', '-y', 'nodejs'])) return true;
|
|
55
|
+
console.log('未能自动安装 Node.js,请手动安装 24(https://nodejs.org/)');
|
|
56
|
+
return false;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* 检测/安装运行时(对齐 ensure_runtimes)
|
|
61
|
+
* @returns {string} 探测到的 python 命令(缺失且安装失败时抛错)
|
|
62
|
+
*/
|
|
63
|
+
function ensureRuntimes() {
|
|
64
|
+
console.log('[运行时] 检查 Python 与 Node.js ...');
|
|
65
|
+
let py = detectPython();
|
|
66
|
+
if (!py) {
|
|
67
|
+
installPython();
|
|
68
|
+
py = detectPython();
|
|
69
|
+
if (!py) throw new Error('未找到 Python 3(hooks 依赖),请手动安装后重试');
|
|
70
|
+
console.log(` Python(已安装): ${py}`);
|
|
71
|
+
} else {
|
|
72
|
+
console.log(` Python: ${py}`);
|
|
73
|
+
}
|
|
74
|
+
if (detectNode()) console.log(' Node.js: 可用');
|
|
75
|
+
else {
|
|
76
|
+
installNode();
|
|
77
|
+
if (detectNode()) console.log(' Node.js(已安装): 可用');
|
|
78
|
+
else console.log('警告: Node.js 未就绪(brainstorming 服务需要),可稍后手动安装');
|
|
79
|
+
}
|
|
80
|
+
console.log('');
|
|
81
|
+
return py;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
module.exports = { detectPython, detectNode, installPython, installNode, ensureRuntimes };
|
package/lib/version.js
CHANGED
|
@@ -1,55 +1,55 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* version.js — 项目类型探测与版本文件(R4:write_version_file 等价)
|
|
3
|
-
*/
|
|
4
|
-
'use strict';
|
|
5
|
-
|
|
6
|
-
const fs = require('node:fs');
|
|
7
|
-
const path = require('node:path');
|
|
8
|
-
const { nowStr } = require('./fsutil');
|
|
9
|
-
const { FRAMEWORK_VERSION } = require('./config');
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* 检测项目类型(对齐 install.sh detect_project_type)
|
|
13
|
-
* @param {string} projectRoot 项目根
|
|
14
|
-
* @returns {string} java-maven/java-gradle/node/python/go/rust/unknown
|
|
15
|
-
*/
|
|
16
|
-
function detectProjectType(projectRoot) {
|
|
17
|
-
const has = (f) => fs.existsSync(path.join(projectRoot, f));
|
|
18
|
-
if (has('pom.xml')) return 'java-maven';
|
|
19
|
-
if (has('build.gradle') || has('build.gradle.kts')) return 'java-gradle';
|
|
20
|
-
if (has('package.json')) return 'node';
|
|
21
|
-
if (has('pyproject.toml') || has('setup.py')) return 'python';
|
|
22
|
-
if (has('go.mod')) return 'go';
|
|
23
|
-
if (has('Cargo.toml')) return 'rust';
|
|
24
|
-
return 'unknown';
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
/**
|
|
28
|
-
* 读取已安装版本(flowcraft-version 首行)
|
|
29
|
-
* @param {string} targetDir .claude 目录
|
|
30
|
-
* @returns {string} 版本号,未安装返回空串
|
|
31
|
-
*/
|
|
32
|
-
function getInstalledVersion(targetDir) {
|
|
33
|
-
const vfile = path.join(targetDir, 'flowcraft-version');
|
|
34
|
-
if (!fs.existsSync(vfile)) return '';
|
|
35
|
-
return fs.readFileSync(vfile, 'utf8').split('\n')[0].trim();
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
/**
|
|
39
|
-
* 写入版本文件(对齐 write_version_file)
|
|
40
|
-
* @param {string} targetDir .claude 目录
|
|
41
|
-
* @param {string} projectRoot 项目根(探测项目类型)
|
|
42
|
-
* @param {string} presetMode 预设模式
|
|
43
|
-
* @param {string} [version] 版本号,默认 FRAMEWORK_VERSION
|
|
44
|
-
* @returns {void}
|
|
45
|
-
*/
|
|
46
|
-
function writeVersionFile(targetDir, projectRoot, presetMode, version) {
|
|
47
|
-
const vfile = path.join(targetDir, 'flowcraft-version');
|
|
48
|
-
fs.mkdirSync(targetDir, { recursive: true });
|
|
49
|
-
const ver = version || FRAMEWORK_VERSION;
|
|
50
|
-
const body = `${ver}\ninstalled: ${nowStr()}\npreset: ${presetMode || 'default'}\nproject_type: ${detectProjectType(projectRoot)}\n`;
|
|
51
|
-
fs.writeFileSync(vfile, body);
|
|
52
|
-
console.log(`✓ 版本文件已写入: ${vfile}`);
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
module.exports = { detectProjectType, getInstalledVersion, writeVersionFile };
|
|
1
|
+
/**
|
|
2
|
+
* version.js — 项目类型探测与版本文件(R4:write_version_file 等价)
|
|
3
|
+
*/
|
|
4
|
+
'use strict';
|
|
5
|
+
|
|
6
|
+
const fs = require('node:fs');
|
|
7
|
+
const path = require('node:path');
|
|
8
|
+
const { nowStr } = require('./fsutil');
|
|
9
|
+
const { FRAMEWORK_VERSION } = require('./config');
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* 检测项目类型(对齐 install.sh detect_project_type)
|
|
13
|
+
* @param {string} projectRoot 项目根
|
|
14
|
+
* @returns {string} java-maven/java-gradle/node/python/go/rust/unknown
|
|
15
|
+
*/
|
|
16
|
+
function detectProjectType(projectRoot) {
|
|
17
|
+
const has = (f) => fs.existsSync(path.join(projectRoot, f));
|
|
18
|
+
if (has('pom.xml')) return 'java-maven';
|
|
19
|
+
if (has('build.gradle') || has('build.gradle.kts')) return 'java-gradle';
|
|
20
|
+
if (has('package.json')) return 'node';
|
|
21
|
+
if (has('pyproject.toml') || has('setup.py')) return 'python';
|
|
22
|
+
if (has('go.mod')) return 'go';
|
|
23
|
+
if (has('Cargo.toml')) return 'rust';
|
|
24
|
+
return 'unknown';
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* 读取已安装版本(flowcraft-version 首行)
|
|
29
|
+
* @param {string} targetDir .claude 目录
|
|
30
|
+
* @returns {string} 版本号,未安装返回空串
|
|
31
|
+
*/
|
|
32
|
+
function getInstalledVersion(targetDir) {
|
|
33
|
+
const vfile = path.join(targetDir, 'flowcraft-version');
|
|
34
|
+
if (!fs.existsSync(vfile)) return '';
|
|
35
|
+
return fs.readFileSync(vfile, 'utf8').split('\n')[0].trim();
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* 写入版本文件(对齐 write_version_file)
|
|
40
|
+
* @param {string} targetDir .claude 目录
|
|
41
|
+
* @param {string} projectRoot 项目根(探测项目类型)
|
|
42
|
+
* @param {string} presetMode 预设模式
|
|
43
|
+
* @param {string} [version] 版本号,默认 FRAMEWORK_VERSION
|
|
44
|
+
* @returns {void}
|
|
45
|
+
*/
|
|
46
|
+
function writeVersionFile(targetDir, projectRoot, presetMode, version) {
|
|
47
|
+
const vfile = path.join(targetDir, 'flowcraft-version');
|
|
48
|
+
fs.mkdirSync(targetDir, { recursive: true });
|
|
49
|
+
const ver = version || FRAMEWORK_VERSION;
|
|
50
|
+
const body = `${ver}\ninstalled: ${nowStr()}\npreset: ${presetMode || 'default'}\nproject_type: ${detectProjectType(projectRoot)}\n`;
|
|
51
|
+
fs.writeFileSync(vfile, body);
|
|
52
|
+
console.log(`✓ 版本文件已写入: ${vfile}`);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
module.exports = { detectProjectType, getInstalledVersion, writeVersionFile };
|
package/lib/wizard.js
CHANGED
|
@@ -1,125 +1,125 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* wizard.js — 交互向导与完成提示(R2 --interactive,对齐 interactive_setup/show_stats/show_next_steps)
|
|
3
|
-
*/
|
|
4
|
-
'use strict';
|
|
5
|
-
|
|
6
|
-
const fs = require('node:fs');
|
|
7
|
-
const path = require('node:path');
|
|
8
|
-
const readline = require('node:readline/promises');
|
|
9
|
-
const { stdin, stdout } = require('node:process');
|
|
10
|
-
const { timestamp } = require('./fsutil');
|
|
11
|
-
const { detectProjectType, getInstalledVersion } = require('./version');
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* 备份框架文件(升级时用,对齐 backup_framework_files)
|
|
15
|
-
* @param {string} targetDir .claude 目录
|
|
16
|
-
* @param {string} projectRoot 项目根
|
|
17
|
-
* @returns {void}
|
|
18
|
-
*/
|
|
19
|
-
function backupFrameworkFiles(targetDir, projectRoot) {
|
|
20
|
-
const backupDir = path.join(targetDir, 'backup', timestamp());
|
|
21
|
-
let backed = false;
|
|
22
|
-
for (const sub of ['hooks', 'skills']) {
|
|
23
|
-
const src = path.join(targetDir, sub);
|
|
24
|
-
if (fs.existsSync(src)) {
|
|
25
|
-
fs.cpSync(src, path.join(backupDir, sub), { recursive: true });
|
|
26
|
-
backed = true;
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
for (const f of ['CLAUDE.md', 'AGENTS.md']) {
|
|
30
|
-
const src = path.join(projectRoot, f);
|
|
31
|
-
if (fs.existsSync(src)) {
|
|
32
|
-
fs.mkdirSync(backupDir, { recursive: true });
|
|
33
|
-
fs.copyFileSync(src, path.join(backupDir, f));
|
|
34
|
-
backed = true;
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
if (backed) console.log(`✓ 框架文件已备份到: ${backupDir}`);
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
/**
|
|
41
|
-
* 交互式配置向导(对齐 interactive_setup 提问流)
|
|
42
|
-
* @param {string} pkgRoot 包根
|
|
43
|
-
* @param {string} projectRoot 项目根
|
|
44
|
-
* @param {boolean} forceConfig 强制进入配置提问(--interactive 且已安装时)
|
|
45
|
-
* @returns {Promise<{presetFile:string|null,presetMode:string}>} 向导选择结果
|
|
46
|
-
*/
|
|
47
|
-
async function interactiveSetup(pkgRoot, projectRoot, forceConfig) {
|
|
48
|
-
const rl = readline.createInterface({ input: stdin, output: stdout });
|
|
49
|
-
try {
|
|
50
|
-
const projectType = detectProjectType(projectRoot);
|
|
51
|
-
console.log('\nFlowCraft 安装向导\n');
|
|
52
|
-
console.log(` 检测项目类型: ${projectType}\n`);
|
|
53
|
-
const installedVer = getInstalledVersion(path.join(projectRoot, '.claude'));
|
|
54
|
-
if (installedVer) {
|
|
55
|
-
console.log(` 检测到已安装 FlowCraft v${installedVer}\n`);
|
|
56
|
-
const up = (await rl.question(' 升级模式 A安全/B覆盖 [A]: ')).trim() || 'A';
|
|
57
|
-
const u = up.toUpperCase();
|
|
58
|
-
if (u === 'A' || u === 'B') {
|
|
59
|
-
console.log(u === 'B' ? '\n → 覆盖升级模式' : '\n → 安全升级模式');
|
|
60
|
-
backupFrameworkFiles(path.join(projectRoot, '.claude'), projectRoot);
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
if (!installedVer || forceConfig) return await askConfig(rl, pkgRoot);
|
|
64
|
-
return { presetFile: null, presetMode: '' };
|
|
65
|
-
} finally {
|
|
66
|
-
rl.close();
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
/**
|
|
71
|
-
* 配置模式提问(快速/自定义/团队模板)
|
|
72
|
-
* @param {object} rl readline 接口
|
|
73
|
-
* @param {string} pkgRoot 包根
|
|
74
|
-
* @returns {Promise<{presetFile:string|null,presetMode:string}>} 选择结果
|
|
75
|
-
*/
|
|
76
|
-
async function askConfig(rl, pkgRoot) {
|
|
77
|
-
console.log('\n 配置模式:A快速安装 B自定义配置 C团队模板');
|
|
78
|
-
const choice = (await rl.question(' 请选择 [A]: ')).trim() || 'A';
|
|
79
|
-
if (choice.toUpperCase() === 'B') {
|
|
80
|
-
await rl.question(' 审查标准 (alibaba/google) [alibaba]: ');
|
|
81
|
-
await rl.question(' 默认语言 (java/typescript/python/go) []: ');
|
|
82
|
-
await rl.question(' 默认框架 (spring-boot/nextjs/fastapi) []: ');
|
|
83
|
-
console.log(' → 自定义配置已记录');
|
|
84
|
-
return { presetFile: null, presetMode: 'custom' };
|
|
85
|
-
}
|
|
86
|
-
if (choice.toUpperCase() === 'C') {
|
|
87
|
-
console.log('\n 内置预设:1.default 2.backend 3.frontend 4.quick-fix');
|
|
88
|
-
const num = (await rl.question(' 选择预设 [1]: ')).trim() || '1';
|
|
89
|
-
const map = { 1: 'default', 2: 'backend', 3: 'frontend', 4: 'quick-fix' };
|
|
90
|
-
const mode = map[num] || 'default';
|
|
91
|
-
console.log(` → 已选择预设: ${mode}`);
|
|
92
|
-
return { presetFile: path.join(pkgRoot, 'presets', `${mode}.yaml`), presetMode: mode };
|
|
93
|
-
}
|
|
94
|
-
console.log(' → 使用默认配置');
|
|
95
|
-
return { presetFile: null, presetMode: 'default' };
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
/**
|
|
99
|
-
* 显示安装统计(对齐 show_stats;Sessionlog 行仅在启用分发时输出)
|
|
100
|
-
* @param {object} stats 统计对象
|
|
101
|
-
* @param {string} projectRoot 项目根
|
|
102
|
-
* @param {string|null} url 已启用分发的 sessionlog URL(null=未启用,不输出该行)
|
|
103
|
-
* @returns {void}
|
|
104
|
-
*/
|
|
105
|
-
function showStats(stats, projectRoot, url) {
|
|
106
|
-
console.log('\n=== 安装完成 ===');
|
|
107
|
-
console.log(`项目根目录: ${projectRoot}`);
|
|
108
|
-
console.log(`复制文件数: ${stats.copyCount}`);
|
|
109
|
-
console.log(`Codex hooks: ${fs.existsSync(path.join(projectRoot, '.codex', 'hooks.json')) ? '已安装' : '未安装'}`);
|
|
110
|
-
console.log(`修复行尾符: ${stats.fixCount} 个文件`);
|
|
111
|
-
console.log(`替换 Python: ${stats.replaceCount} 个文件`);
|
|
112
|
-
if (url) console.log(`Sessionlog URL: ${url}(已分发 ${stats.urlCount} 个文件)`);
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
/**
|
|
116
|
-
* 显示下一步引导(对齐 show_next_steps)
|
|
117
|
-
* @returns {void}
|
|
118
|
-
*/
|
|
119
|
-
function showNextSteps() {
|
|
120
|
-
console.log('\n安装完成!');
|
|
121
|
-
console.log(' 下一步: 1. 重启 Claude Code 或 Codex 2. 输入你的第一个任务 3. 或运行 /status 查看当前状态');
|
|
122
|
-
console.log(' 提示: 配置文件 flowcraft.yaml 可随时修改;团队共享将 flowcraft.yaml 提交到 git');
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
module.exports = { backupFrameworkFiles, interactiveSetup, showStats, showNextSteps };
|
|
1
|
+
/**
|
|
2
|
+
* wizard.js — 交互向导与完成提示(R2 --interactive,对齐 interactive_setup/show_stats/show_next_steps)
|
|
3
|
+
*/
|
|
4
|
+
'use strict';
|
|
5
|
+
|
|
6
|
+
const fs = require('node:fs');
|
|
7
|
+
const path = require('node:path');
|
|
8
|
+
const readline = require('node:readline/promises');
|
|
9
|
+
const { stdin, stdout } = require('node:process');
|
|
10
|
+
const { timestamp } = require('./fsutil');
|
|
11
|
+
const { detectProjectType, getInstalledVersion } = require('./version');
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* 备份框架文件(升级时用,对齐 backup_framework_files)
|
|
15
|
+
* @param {string} targetDir .claude 目录
|
|
16
|
+
* @param {string} projectRoot 项目根
|
|
17
|
+
* @returns {void}
|
|
18
|
+
*/
|
|
19
|
+
function backupFrameworkFiles(targetDir, projectRoot) {
|
|
20
|
+
const backupDir = path.join(targetDir, 'backup', timestamp());
|
|
21
|
+
let backed = false;
|
|
22
|
+
for (const sub of ['hooks', 'skills']) {
|
|
23
|
+
const src = path.join(targetDir, sub);
|
|
24
|
+
if (fs.existsSync(src)) {
|
|
25
|
+
fs.cpSync(src, path.join(backupDir, sub), { recursive: true });
|
|
26
|
+
backed = true;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
for (const f of ['CLAUDE.md', 'AGENTS.md']) {
|
|
30
|
+
const src = path.join(projectRoot, f);
|
|
31
|
+
if (fs.existsSync(src)) {
|
|
32
|
+
fs.mkdirSync(backupDir, { recursive: true });
|
|
33
|
+
fs.copyFileSync(src, path.join(backupDir, f));
|
|
34
|
+
backed = true;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
if (backed) console.log(`✓ 框架文件已备份到: ${backupDir}`);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* 交互式配置向导(对齐 interactive_setup 提问流)
|
|
42
|
+
* @param {string} pkgRoot 包根
|
|
43
|
+
* @param {string} projectRoot 项目根
|
|
44
|
+
* @param {boolean} forceConfig 强制进入配置提问(--interactive 且已安装时)
|
|
45
|
+
* @returns {Promise<{presetFile:string|null,presetMode:string}>} 向导选择结果
|
|
46
|
+
*/
|
|
47
|
+
async function interactiveSetup(pkgRoot, projectRoot, forceConfig) {
|
|
48
|
+
const rl = readline.createInterface({ input: stdin, output: stdout });
|
|
49
|
+
try {
|
|
50
|
+
const projectType = detectProjectType(projectRoot);
|
|
51
|
+
console.log('\nFlowCraft 安装向导\n');
|
|
52
|
+
console.log(` 检测项目类型: ${projectType}\n`);
|
|
53
|
+
const installedVer = getInstalledVersion(path.join(projectRoot, '.claude'));
|
|
54
|
+
if (installedVer) {
|
|
55
|
+
console.log(` 检测到已安装 FlowCraft v${installedVer}\n`);
|
|
56
|
+
const up = (await rl.question(' 升级模式 A安全/B覆盖 [A]: ')).trim() || 'A';
|
|
57
|
+
const u = up.toUpperCase();
|
|
58
|
+
if (u === 'A' || u === 'B') {
|
|
59
|
+
console.log(u === 'B' ? '\n → 覆盖升级模式' : '\n → 安全升级模式');
|
|
60
|
+
backupFrameworkFiles(path.join(projectRoot, '.claude'), projectRoot);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
if (!installedVer || forceConfig) return await askConfig(rl, pkgRoot);
|
|
64
|
+
return { presetFile: null, presetMode: '' };
|
|
65
|
+
} finally {
|
|
66
|
+
rl.close();
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* 配置模式提问(快速/自定义/团队模板)
|
|
72
|
+
* @param {object} rl readline 接口
|
|
73
|
+
* @param {string} pkgRoot 包根
|
|
74
|
+
* @returns {Promise<{presetFile:string|null,presetMode:string}>} 选择结果
|
|
75
|
+
*/
|
|
76
|
+
async function askConfig(rl, pkgRoot) {
|
|
77
|
+
console.log('\n 配置模式:A快速安装 B自定义配置 C团队模板');
|
|
78
|
+
const choice = (await rl.question(' 请选择 [A]: ')).trim() || 'A';
|
|
79
|
+
if (choice.toUpperCase() === 'B') {
|
|
80
|
+
await rl.question(' 审查标准 (alibaba/google) [alibaba]: ');
|
|
81
|
+
await rl.question(' 默认语言 (java/typescript/python/go) []: ');
|
|
82
|
+
await rl.question(' 默认框架 (spring-boot/nextjs/fastapi) []: ');
|
|
83
|
+
console.log(' → 自定义配置已记录');
|
|
84
|
+
return { presetFile: null, presetMode: 'custom' };
|
|
85
|
+
}
|
|
86
|
+
if (choice.toUpperCase() === 'C') {
|
|
87
|
+
console.log('\n 内置预设:1.default 2.backend 3.frontend 4.quick-fix');
|
|
88
|
+
const num = (await rl.question(' 选择预设 [1]: ')).trim() || '1';
|
|
89
|
+
const map = { 1: 'default', 2: 'backend', 3: 'frontend', 4: 'quick-fix' };
|
|
90
|
+
const mode = map[num] || 'default';
|
|
91
|
+
console.log(` → 已选择预设: ${mode}`);
|
|
92
|
+
return { presetFile: path.join(pkgRoot, 'presets', `${mode}.yaml`), presetMode: mode };
|
|
93
|
+
}
|
|
94
|
+
console.log(' → 使用默认配置');
|
|
95
|
+
return { presetFile: null, presetMode: 'default' };
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* 显示安装统计(对齐 show_stats;Sessionlog 行仅在启用分发时输出)
|
|
100
|
+
* @param {object} stats 统计对象
|
|
101
|
+
* @param {string} projectRoot 项目根
|
|
102
|
+
* @param {string|null} url 已启用分发的 sessionlog URL(null=未启用,不输出该行)
|
|
103
|
+
* @returns {void}
|
|
104
|
+
*/
|
|
105
|
+
function showStats(stats, projectRoot, url) {
|
|
106
|
+
console.log('\n=== 安装完成 ===');
|
|
107
|
+
console.log(`项目根目录: ${projectRoot}`);
|
|
108
|
+
console.log(`复制文件数: ${stats.copyCount}`);
|
|
109
|
+
console.log(`Codex hooks: ${fs.existsSync(path.join(projectRoot, '.codex', 'hooks.json')) ? '已安装' : '未安装'}`);
|
|
110
|
+
console.log(`修复行尾符: ${stats.fixCount} 个文件`);
|
|
111
|
+
console.log(`替换 Python: ${stats.replaceCount} 个文件`);
|
|
112
|
+
if (url) console.log(`Sessionlog URL: ${url}(已分发 ${stats.urlCount} 个文件)`);
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* 显示下一步引导(对齐 show_next_steps)
|
|
117
|
+
* @returns {void}
|
|
118
|
+
*/
|
|
119
|
+
function showNextSteps() {
|
|
120
|
+
console.log('\n安装完成!');
|
|
121
|
+
console.log(' 下一步: 1. 重启 Claude Code 或 Codex 2. 输入你的第一个任务 3. 或运行 /status 查看当前状态');
|
|
122
|
+
console.log(' 提示: 配置文件 flowcraft.yaml 可随时修改;团队共享将 flowcraft.yaml 提交到 git');
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
module.exports = { backupFrameworkFiles, interactiveSetup, showStats, showNextSteps };
|
package/package.json
CHANGED
|
@@ -1,33 +1,33 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@leocm/flowcraft",
|
|
3
|
-
"version": "2.
|
|
4
|
-
"description": "FlowCraft SDLC 框架安装 CLI(跨平台,行为与 install.sh 等价)",
|
|
5
|
-
"bin": {
|
|
6
|
-
"flowcraft": "bin/cli.js"
|
|
7
|
-
},
|
|
8
|
-
"files": [
|
|
9
|
-
"bin/",
|
|
10
|
-
"lib/",
|
|
11
|
-
"setup/",
|
|
12
|
-
"presets/",
|
|
13
|
-
"install.sh",
|
|
14
|
-
"README.md",
|
|
15
|
-
"flowcraft.yaml",
|
|
16
|
-
"!**/__pycache__/**",
|
|
17
|
-
"!**/*.pyc"
|
|
18
|
-
],
|
|
19
|
-
"engines": {
|
|
20
|
-
"node": ">=20"
|
|
21
|
-
},
|
|
22
|
-
"dependencies": {},
|
|
23
|
-
"scripts": {
|
|
24
|
-
"test": "node --test tests/*.test.js"
|
|
25
|
-
},
|
|
26
|
-
"keywords": [
|
|
27
|
-
"sdlc",
|
|
28
|
-
"claude-code",
|
|
29
|
-
"flowcraft",
|
|
30
|
-
"installer"
|
|
31
|
-
],
|
|
32
|
-
"author": "leocm"
|
|
33
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "@leocm/flowcraft",
|
|
3
|
+
"version": "2.3.0",
|
|
4
|
+
"description": "FlowCraft SDLC 框架安装 CLI(跨平台,行为与 install.sh 等价)",
|
|
5
|
+
"bin": {
|
|
6
|
+
"flowcraft": "bin/cli.js"
|
|
7
|
+
},
|
|
8
|
+
"files": [
|
|
9
|
+
"bin/",
|
|
10
|
+
"lib/",
|
|
11
|
+
"setup/",
|
|
12
|
+
"presets/",
|
|
13
|
+
"install.sh",
|
|
14
|
+
"README.md",
|
|
15
|
+
"flowcraft.yaml",
|
|
16
|
+
"!**/__pycache__/**",
|
|
17
|
+
"!**/*.pyc"
|
|
18
|
+
],
|
|
19
|
+
"engines": {
|
|
20
|
+
"node": ">=20"
|
|
21
|
+
},
|
|
22
|
+
"dependencies": {},
|
|
23
|
+
"scripts": {
|
|
24
|
+
"test": "node --test tests/*.test.js"
|
|
25
|
+
},
|
|
26
|
+
"keywords": [
|
|
27
|
+
"sdlc",
|
|
28
|
+
"claude-code",
|
|
29
|
+
"flowcraft",
|
|
30
|
+
"installer"
|
|
31
|
+
],
|
|
32
|
+
"author": "leocm"
|
|
33
|
+
}
|
package/presets/backend.yaml
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
# FlowCraft 预设: 后端服务
|
|
2
|
-
preset_name: "后端服务"
|
|
3
|
-
preset_version: "1.0"
|
|
4
|
-
description: "后端项目专用,P3测试强制,审查标准alibaba"
|
|
5
|
-
|
|
6
|
-
stages:
|
|
7
|
-
P1: auto
|
|
8
|
-
P2: true
|
|
9
|
-
P3: true # 后端必须测试
|
|
10
|
-
P4: true
|
|
11
|
-
P5: auto
|
|
12
|
-
|
|
13
|
-
review:
|
|
14
|
-
standard: alibaba
|
|
15
|
-
retry_limit: 3
|
|
16
|
-
|
|
17
|
-
tech_defaults:
|
|
18
|
-
language: java
|
|
19
|
-
framework: spring-boot
|
|
20
|
-
testing: junit
|
|
1
|
+
# FlowCraft 预设: 后端服务
|
|
2
|
+
preset_name: "后端服务"
|
|
3
|
+
preset_version: "1.0"
|
|
4
|
+
description: "后端项目专用,P3测试强制,审查标准alibaba"
|
|
5
|
+
|
|
6
|
+
stages:
|
|
7
|
+
P1: auto
|
|
8
|
+
P2: true
|
|
9
|
+
P3: true # 后端必须测试
|
|
10
|
+
P4: true
|
|
11
|
+
P5: auto
|
|
12
|
+
|
|
13
|
+
review:
|
|
14
|
+
standard: alibaba
|
|
15
|
+
retry_limit: 3
|
|
16
|
+
|
|
17
|
+
tech_defaults:
|
|
18
|
+
language: java
|
|
19
|
+
framework: spring-boot
|
|
20
|
+
testing: junit
|