@chenmk/superflow 0.1.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.
Files changed (198) hide show
  1. package/INSTALL.en.md +106 -0
  2. package/INSTALL.md +664 -0
  3. package/LICENSE +21 -0
  4. package/README.md +142 -0
  5. package/README.zh-CN.md +117 -0
  6. package/assets/context-templates/business-rules.md +98 -0
  7. package/assets/context-templates/decisions.md +153 -0
  8. package/assets/context-templates/external-systems.md +166 -0
  9. package/assets/context-templates/incidents.md +89 -0
  10. package/assets/manifest.json +53 -0
  11. package/assets/prompts/superflow-archive.md +9 -0
  12. package/assets/prompts/superflow-clarify.md +10 -0
  13. package/assets/prompts/superflow-design.md +10 -0
  14. package/assets/prompts/superflow-docs.md +10 -0
  15. package/assets/prompts/superflow-implement.md +10 -0
  16. package/assets/prompts/superflow-pipeline.md +13 -0
  17. package/assets/prompts/superflow-verify.md +10 -0
  18. package/assets/rules/superflow-phase-guard.md +50 -0
  19. package/assets/scripts/claude-auto-backup-hook.sh +313 -0
  20. package/assets/scripts/codex-auto-backup-hook.sh +361 -0
  21. package/assets/scripts/install-sql-pre-commit.sh +44 -0
  22. package/assets/scripts/superflow-contract-hooks.sh +744 -0
  23. package/assets/scripts/superflow-delivery-check.sh +315 -0
  24. package/assets/scripts/superflow-dependency-update-hook.sh +161 -0
  25. package/assets/scripts/superflow-enforce-hook.sh +70 -0
  26. package/assets/scripts/superflow-hook-guard.sh +132 -0
  27. package/assets/scripts/superflow-integration-evidence-hook.sh +80 -0
  28. package/assets/scripts/superflow-sql-sync-hook.py +950 -0
  29. package/assets/scripts/superflow-test-report-lint.py +433 -0
  30. package/assets/scripts/superflow-verify-integration.sh +90 -0
  31. package/assets/scripts/sync-settings-json.py +52 -0
  32. package/assets/skills/api-doc-changelog/SKILL.md +193 -0
  33. package/assets/skills/openspec-apply-change/SKILL.md +156 -0
  34. package/assets/skills/openspec-archive-change/SKILL.md +114 -0
  35. package/assets/skills/openspec-explore/SKILL.md +288 -0
  36. package/assets/skills/openspec-propose/SKILL.md +110 -0
  37. package/assets/skills/superflow-archive/SKILL.md +61 -0
  38. package/assets/skills/superflow-clarify/SKILL.md +146 -0
  39. package/assets/skills/superflow-clarify/agents/openai.yaml +4 -0
  40. package/assets/skills/superflow-design/SKILL.md +83 -0
  41. package/assets/skills/superflow-design/agents/openai.yaml +4 -0
  42. package/assets/skills/superflow-docs/SKILL.md +316 -0
  43. package/assets/skills/superflow-docs/agents/openai.yaml +4 -0
  44. package/assets/skills/superflow-hotfix/SKILL.md +48 -0
  45. package/assets/skills/superflow-implement/SKILL.md +461 -0
  46. package/assets/skills/superflow-implement/agents/openai.yaml +4 -0
  47. package/assets/skills/superflow-pipeline/SKILL.md +844 -0
  48. package/assets/skills/superflow-pipeline/agents/openai.yaml +4 -0
  49. package/assets/skills/superflow-pipeline/references/api-design-template.md +431 -0
  50. package/assets/skills/superflow-pipeline/references/architecture-design-template.md +119 -0
  51. package/assets/skills/superflow-pipeline/references/batch-prompt-template.md +536 -0
  52. package/assets/skills/superflow-pipeline/references/batch-split-guide.md +140 -0
  53. package/assets/skills/superflow-pipeline/references/decision-point.md +30 -0
  54. package/assets/skills/superflow-pipeline/references/dirty-worktree.md +35 -0
  55. package/assets/skills/superflow-pipeline/references/document-templates.md +123 -0
  56. package/assets/skills/superflow-pipeline/references/feature-gated-workflow.md +124 -0
  57. package/assets/skills/superflow-pipeline/references/implementation-prompt-template.md +1056 -0
  58. package/assets/skills/superflow-pipeline/references/mock-strategy-guide.md +86 -0
  59. package/assets/skills/superflow-pipeline/references/openspec-format.md +57 -0
  60. package/assets/skills/superflow-pipeline/references/orchestration.md +639 -0
  61. package/assets/skills/superflow-pipeline/references/p0-baseline-template.md +174 -0
  62. package/assets/skills/superflow-pipeline/references/project-config.md +40 -0
  63. package/assets/skills/superflow-pipeline/references/prompt-usage-template.md +152 -0
  64. package/assets/skills/superflow-pipeline/references/quality-gate.md +299 -0
  65. package/assets/skills/superflow-pipeline/references/quality-standards.md +190 -0
  66. package/assets/skills/superflow-pipeline/references/reviewer-checklist.md +154 -0
  67. package/assets/skills/superflow-pipeline/references/sql-risk-review-checklist.md +323 -0
  68. package/assets/skills/superflow-pipeline/references/subagent-progress.md +90 -0
  69. package/assets/skills/superflow-pipeline/references/superpower-technical-design-template.md +125 -0
  70. package/assets/skills/superflow-pipeline/references/test-execution-template.md +220 -0
  71. package/assets/skills/superflow-pipeline/references/test-guide.md +30 -0
  72. package/assets/skills/superflow-pipeline/references/traceability-matrix.md +106 -0
  73. package/assets/skills/superflow-pipeline/references/validation-integrity.md +134 -0
  74. package/assets/skills/superflow-pipeline/scripts/superflow-archive.sh +178 -0
  75. package/assets/skills/superflow-pipeline/scripts/superflow-env.sh +118 -0
  76. package/assets/skills/superflow-pipeline/scripts/superflow-guard.sh +428 -0
  77. package/assets/skills/superflow-pipeline/scripts/superflow-handoff.sh +296 -0
  78. package/assets/skills/superflow-pipeline/scripts/superflow-state.sh +574 -0
  79. package/assets/skills/superflow-pipeline/scripts/superflow-status.sh +172 -0
  80. package/assets/skills/superflow-pipeline/scripts/superflow-yaml-validate.sh +138 -0
  81. package/assets/skills/superflow-table-impact-analysis/SKILL.md +77 -0
  82. package/assets/skills/superflow-tweak/SKILL.md +46 -0
  83. package/assets/skills/superflow-verify/SKILL.md +112 -0
  84. package/assets/skills-en/api-doc-changelog/SKILL.md +193 -0
  85. package/assets/skills-en/openspec-apply-change/SKILL.md +156 -0
  86. package/assets/skills-en/openspec-archive-change/SKILL.md +114 -0
  87. package/assets/skills-en/openspec-explore/SKILL.md +288 -0
  88. package/assets/skills-en/openspec-propose/SKILL.md +110 -0
  89. package/assets/skills-en/superflow-archive/SKILL.md +61 -0
  90. package/assets/skills-en/superflow-clarify/SKILL.md +146 -0
  91. package/assets/skills-en/superflow-clarify/agents/openai.yaml +4 -0
  92. package/assets/skills-en/superflow-design/SKILL.md +83 -0
  93. package/assets/skills-en/superflow-design/agents/openai.yaml +4 -0
  94. package/assets/skills-en/superflow-docs/SKILL.md +316 -0
  95. package/assets/skills-en/superflow-docs/agents/openai.yaml +4 -0
  96. package/assets/skills-en/superflow-hotfix/SKILL.md +48 -0
  97. package/assets/skills-en/superflow-implement/SKILL.md +461 -0
  98. package/assets/skills-en/superflow-implement/agents/openai.yaml +4 -0
  99. package/assets/skills-en/superflow-pipeline/SKILL.md +844 -0
  100. package/assets/skills-en/superflow-pipeline/agents/openai.yaml +4 -0
  101. package/assets/skills-en/superflow-pipeline/references/api-design-template.md +431 -0
  102. package/assets/skills-en/superflow-pipeline/references/architecture-design-template.md +119 -0
  103. package/assets/skills-en/superflow-pipeline/references/batch-prompt-template.md +536 -0
  104. package/assets/skills-en/superflow-pipeline/references/batch-split-guide.md +140 -0
  105. package/assets/skills-en/superflow-pipeline/references/decision-point.md +30 -0
  106. package/assets/skills-en/superflow-pipeline/references/dirty-worktree.md +35 -0
  107. package/assets/skills-en/superflow-pipeline/references/document-templates.md +123 -0
  108. package/assets/skills-en/superflow-pipeline/references/feature-gated-workflow.md +124 -0
  109. package/assets/skills-en/superflow-pipeline/references/implementation-prompt-template.md +1056 -0
  110. package/assets/skills-en/superflow-pipeline/references/mock-strategy-guide.md +86 -0
  111. package/assets/skills-en/superflow-pipeline/references/openspec-format.md +57 -0
  112. package/assets/skills-en/superflow-pipeline/references/orchestration.md +639 -0
  113. package/assets/skills-en/superflow-pipeline/references/p0-baseline-template.md +174 -0
  114. package/assets/skills-en/superflow-pipeline/references/project-config.md +40 -0
  115. package/assets/skills-en/superflow-pipeline/references/prompt-usage-template.md +152 -0
  116. package/assets/skills-en/superflow-pipeline/references/quality-gate.md +299 -0
  117. package/assets/skills-en/superflow-pipeline/references/quality-standards.md +190 -0
  118. package/assets/skills-en/superflow-pipeline/references/reviewer-checklist.md +154 -0
  119. package/assets/skills-en/superflow-pipeline/references/sql-risk-review-checklist.md +323 -0
  120. package/assets/skills-en/superflow-pipeline/references/subagent-progress.md +90 -0
  121. package/assets/skills-en/superflow-pipeline/references/superpower-technical-design-template.md +125 -0
  122. package/assets/skills-en/superflow-pipeline/references/test-execution-template.md +220 -0
  123. package/assets/skills-en/superflow-pipeline/references/test-guide.md +30 -0
  124. package/assets/skills-en/superflow-pipeline/references/traceability-matrix.md +106 -0
  125. package/assets/skills-en/superflow-pipeline/references/validation-integrity.md +134 -0
  126. package/assets/skills-en/superflow-pipeline/scripts/superflow-archive.sh +178 -0
  127. package/assets/skills-en/superflow-pipeline/scripts/superflow-env.sh +118 -0
  128. package/assets/skills-en/superflow-pipeline/scripts/superflow-guard.sh +428 -0
  129. package/assets/skills-en/superflow-pipeline/scripts/superflow-handoff.sh +296 -0
  130. package/assets/skills-en/superflow-pipeline/scripts/superflow-state.sh +574 -0
  131. package/assets/skills-en/superflow-pipeline/scripts/superflow-status.sh +172 -0
  132. package/assets/skills-en/superflow-pipeline/scripts/superflow-yaml-validate.sh +138 -0
  133. package/assets/skills-en/superflow-table-impact-analysis/SKILL.md +77 -0
  134. package/assets/skills-en/superflow-tweak/SKILL.md +46 -0
  135. package/assets/skills-en/superflow-verify/SKILL.md +112 -0
  136. package/dist/cli/index.js +186 -0
  137. package/dist/cli/index.js.map +1 -0
  138. package/dist/commands/archive.js +6 -0
  139. package/dist/commands/archive.js.map +1 -0
  140. package/dist/commands/clarify.js +6 -0
  141. package/dist/commands/clarify.js.map +1 -0
  142. package/dist/commands/design.js +6 -0
  143. package/dist/commands/design.js.map +1 -0
  144. package/dist/commands/docs.js +6 -0
  145. package/dist/commands/docs.js.map +1 -0
  146. package/dist/commands/doctor.js +473 -0
  147. package/dist/commands/doctor.js.map +1 -0
  148. package/dist/commands/implement.js +6 -0
  149. package/dist/commands/implement.js.map +1 -0
  150. package/dist/commands/init.js +471 -0
  151. package/dist/commands/init.js.map +1 -0
  152. package/dist/commands/pipeline.js +6 -0
  153. package/dist/commands/pipeline.js.map +1 -0
  154. package/dist/commands/scan.js +59 -0
  155. package/dist/commands/scan.js.map +1 -0
  156. package/dist/commands/status.js +173 -0
  157. package/dist/commands/status.js.map +1 -0
  158. package/dist/commands/uninstall.js +213 -0
  159. package/dist/commands/uninstall.js.map +1 -0
  160. package/dist/commands/update.js +187 -0
  161. package/dist/commands/update.js.map +1 -0
  162. package/dist/commands/verify.js +6 -0
  163. package/dist/commands/verify.js.map +1 -0
  164. package/dist/core/assets.js +27 -0
  165. package/dist/core/assets.js.map +1 -0
  166. package/dist/core/context.js +100 -0
  167. package/dist/core/context.js.map +1 -0
  168. package/dist/core/dependencies.js +146 -0
  169. package/dist/core/dependencies.js.map +1 -0
  170. package/dist/core/detect.js +71 -0
  171. package/dist/core/detect.js.map +1 -0
  172. package/dist/core/i18n.js +103 -0
  173. package/dist/core/i18n.js.map +1 -0
  174. package/dist/core/integrity.js +46 -0
  175. package/dist/core/integrity.js.map +1 -0
  176. package/dist/core/manifest.js +18 -0
  177. package/dist/core/manifest.js.map +1 -0
  178. package/dist/core/prompts.js +20 -0
  179. package/dist/core/prompts.js.map +1 -0
  180. package/dist/core/registry.js +134 -0
  181. package/dist/core/registry.js.map +1 -0
  182. package/dist/core/rules.js +17 -0
  183. package/dist/core/rules.js.map +1 -0
  184. package/dist/core/scripts.js +40 -0
  185. package/dist/core/scripts.js.map +1 -0
  186. package/dist/core/skill-check.js +31 -0
  187. package/dist/core/skill-check.js.map +1 -0
  188. package/dist/core/skills.js +56 -0
  189. package/dist/core/skills.js.map +1 -0
  190. package/dist/core/state.js +43 -0
  191. package/dist/core/state.js.map +1 -0
  192. package/dist/types.js +2 -0
  193. package/dist/types.js.map +1 -0
  194. package/dist/utils/path.js +11 -0
  195. package/dist/utils/path.js.map +1 -0
  196. package/dist/utils/shell.js +29 -0
  197. package/dist/utils/shell.js.map +1 -0
  198. package/package.json +60 -0
@@ -0,0 +1,471 @@
1
+ import path from 'path';
2
+ import { fileURLToPath } from 'url';
3
+ import { existsSync } from 'fs';
4
+ import { createInterface } from 'readline/promises';
5
+ import { stdin as input, stdout as output } from 'process';
6
+ import { detectOS, getPlatformPaths, parseAgentSelection, parseInstallScope, resolveAgents, } from '../core/detect.js';
7
+ import { stateFile } from '../utils/path.js';
8
+ import { installOpenspec, initializeOpenspec, openspecInitArgs, installSuperpowers, installCodexSuperpowers, installUnderstand, installCodexUnderstand, installApiDocChangelog, } from '../core/dependencies.js';
9
+ import { deploySkill } from '../core/skills.js';
10
+ import { deployScripts } from '../core/scripts.js';
11
+ import { deployPrompts } from '../core/prompts.js';
12
+ import { deployRules } from '../core/rules.js';
13
+ import { registerHook, clearSddHooks } from '../core/registry.js';
14
+ import { loadState, saveState, initState } from '../core/state.js';
15
+ import { scaffoldBusinessContext, checkUnderstandScan, printSoftPrompt } from '../core/context.js';
16
+ import { ALL_RULES, ALL_SKILLS, CODEX_PROMPTS, scriptsForAgent, hookScriptsForAgent, } from '../core/assets.js';
17
+ import { normalizeLanguage, t } from '../core/i18n.js';
18
+ const __filename = fileURLToPath(import.meta.url);
19
+ const __dirname = path.dirname(__filename);
20
+ // dist/commands/init.js → ../../assets
21
+ const ASSETS_DIR = path.resolve(__dirname, '..', '..', 'assets');
22
+ export async function initCommand(cmdOptions) {
23
+ // commander 的 --no-hooks 标志让 options.hooks = false;默认是 true
24
+ // commander 的 --no-scan 标志让 options.scan = false;默认是 true
25
+ try {
26
+ const agent = await resolveInitAgentSelection(cmdOptions);
27
+ const language = await resolveInitLanguage(cmdOptions);
28
+ await runInit({
29
+ dryRun: !!cmdOptions.dryRun,
30
+ agent,
31
+ resume: !!cmdOptions.resume,
32
+ noHooks: cmdOptions.hooks === false, // 明确 false 才算 noHooks
33
+ noOpenspecInit: cmdOptions.openspecInit === false,
34
+ noScan: cmdOptions.scan === false, // 明确 false 才算 noScan
35
+ yes: !!cmdOptions.yes,
36
+ json: !!cmdOptions.json,
37
+ skipExisting: !!cmdOptions.skipExisting,
38
+ overwrite: !!cmdOptions.overwrite,
39
+ scope: parseInstallScope(cmdOptions.scope),
40
+ language,
41
+ projectPath: path.resolve(cmdOptions.targetPath ?? process.cwd()),
42
+ });
43
+ }
44
+ catch (err) {
45
+ if (cmdOptions.json) {
46
+ console.log(JSON.stringify({ ok: false, error: err.message }, null, 2));
47
+ }
48
+ else {
49
+ console.error(`[FAIL] ${err.message}`);
50
+ }
51
+ process.exit(1);
52
+ }
53
+ }
54
+ async function resolveInitLanguage(cmdOptions) {
55
+ if (cmdOptions.language) {
56
+ const parsed = normalizeLanguage(cmdOptions.language);
57
+ if (!parsed)
58
+ throw new Error(`invalid language: ${cmdOptions.language}`);
59
+ return parsed;
60
+ }
61
+ if (cmdOptions.yes || cmdOptions.json || cmdOptions.dryRun || cmdOptions.resume) {
62
+ return 'zh';
63
+ }
64
+ if (!process.stdin.isTTY || !process.stdout.isTTY)
65
+ return 'zh';
66
+ return promptLanguageSelection();
67
+ }
68
+ async function resolveInitAgentSelection(cmdOptions) {
69
+ if (cmdOptions.agent)
70
+ return parseAgentSelection(cmdOptions.agent);
71
+ if (cmdOptions.yes || cmdOptions.json || cmdOptions.dryRun || cmdOptions.resume) {
72
+ return 'both';
73
+ }
74
+ if (!process.stdin.isTTY || !process.stdout.isTTY)
75
+ return 'both';
76
+ return promptAgentSelection();
77
+ }
78
+ export function parseInitAgentInput(value) {
79
+ const normalized = value.trim().toLowerCase();
80
+ if (!normalized || normalized === 'a' || normalized === 'all' || normalized === 'both') {
81
+ return 'both';
82
+ }
83
+ const parts = normalized
84
+ .split(/[,\s]+/)
85
+ .map((part) => part.trim())
86
+ .filter(Boolean);
87
+ const selected = new Set();
88
+ for (const part of parts) {
89
+ if (part === '1' || part === 'claude' || part === 'c') {
90
+ selected.add('claude');
91
+ }
92
+ else if (part === '2' || part === 'codex' || part === 'x') {
93
+ selected.add('codex');
94
+ }
95
+ else {
96
+ return null;
97
+ }
98
+ }
99
+ if (selected.size === 2)
100
+ return 'both';
101
+ if (selected.has('claude'))
102
+ return 'claude';
103
+ if (selected.has('codex'))
104
+ return 'codex';
105
+ return null;
106
+ }
107
+ function initStepSummary(result) {
108
+ const completed = result.steps.filter((step) => step.status === 'completed');
109
+ const skipped = result.steps.filter((step) => step.status === 'skipped');
110
+ const failed = result.steps.filter((step) => step.status === 'failed');
111
+ const lines = [
112
+ '',
113
+ '=== superflow init summary ===',
114
+ `Agents: ${result.agents.join(', ')}`,
115
+ `Language: ${result.language}`,
116
+ `Scope: ${result.scope}`,
117
+ `Project: ${result.projectPath}`,
118
+ `Steps: ${completed.length} completed, ${skipped.length} skipped, ${failed.length} failed`,
119
+ ];
120
+ if (completed.length > 0) {
121
+ lines.push(`Completed: ${completed.map((step) => `${step.id}.${step.name}`).join(' / ')}`);
122
+ }
123
+ if (skipped.length > 0) {
124
+ lines.push(`Skipped: ${skipped.map((step) => `${step.id}.${step.name}`).join(' / ')}`);
125
+ }
126
+ if (failed.length > 0) {
127
+ lines.push(`Failed: ${failed
128
+ .map((step) => `${step.id}.${step.name}${step.error ? ` (${step.error})` : ''}`)
129
+ .join(' / ')}`);
130
+ }
131
+ return lines;
132
+ }
133
+ function printInitSummary(result, write) {
134
+ for (const line of initStepSummary(result)) {
135
+ write(line);
136
+ }
137
+ }
138
+ async function promptAgentSelection() {
139
+ const rl = createInterface({ input, output });
140
+ try {
141
+ while (true) {
142
+ console.log(`\n${t('zh', 'agentPrompt')}`);
143
+ console.log(` 1) ${t('zh', 'agentClaude')}`);
144
+ console.log(` 2) ${t('zh', 'agentCodex')}`);
145
+ console.log(` a) ${t('zh', 'agentBoth')}`);
146
+ const answer = await rl.question(t('zh', 'agentAnswer'));
147
+ const selection = parseInitAgentInput(answer);
148
+ if (selection)
149
+ return selection;
150
+ console.log(t('zh', 'agentInvalid'));
151
+ }
152
+ }
153
+ finally {
154
+ rl.close();
155
+ }
156
+ }
157
+ async function promptLanguageSelection() {
158
+ const rl = createInterface({ input, output });
159
+ try {
160
+ while (true) {
161
+ console.log(`\n${t('en', 'languagePrompt')}`);
162
+ console.log(` 1) ${t('en', 'languageEnglish')}`);
163
+ console.log(` 2) ${t('en', 'languageChinese')}`);
164
+ const answer = await rl.question('Enter 1 / 2 / en / zh: ');
165
+ const language = normalizeLanguage(answer);
166
+ if (language)
167
+ return language;
168
+ console.log(t('en', 'languageInvalid'));
169
+ }
170
+ }
171
+ finally {
172
+ rl.close();
173
+ }
174
+ }
175
+ export async function runInit(options) {
176
+ if (options.skipExisting && options.overwrite) {
177
+ throw new Error('--skip-existing and --overwrite cannot be used together');
178
+ }
179
+ const state = options.resume
180
+ ? (loadState(stateFile) ?? initState('0.1.0', 'claude', options.language))
181
+ : initState('0.1.0', 'claude', options.language);
182
+ state.language = options.language;
183
+ const osType = detectOS();
184
+ const agents = resolveAgents(options.agent);
185
+ const projectPath = options.projectPath;
186
+ const result = {
187
+ ok: true,
188
+ dryRun: options.dryRun,
189
+ agents,
190
+ scope: options.scope,
191
+ language: options.language,
192
+ projectPath,
193
+ steps: [],
194
+ skills: { total: ALL_SKILLS.length, names: ALL_SKILLS },
195
+ rules: { total: ALL_RULES.length, names: ALL_RULES },
196
+ scripts: {},
197
+ hooks: {},
198
+ stateFile,
199
+ };
200
+ const log = (message = '') => {
201
+ if (!options.json)
202
+ console.log(message);
203
+ };
204
+ const warn = (message) => {
205
+ if (!options.json)
206
+ console.warn(message);
207
+ };
208
+ for (const agent of agents) {
209
+ const scripts = scriptsForAgent(agent);
210
+ const hooks = hookScriptsForAgent(agent);
211
+ result.scripts[agent] = { total: scripts.length, names: scripts };
212
+ result.hooks[agent] = {
213
+ total: hooks.length,
214
+ names: hooks,
215
+ registered: !options.noHooks,
216
+ };
217
+ }
218
+ const steps = [
219
+ { id: 1, name: t(options.language, 'stepDetect'), run: async () => {
220
+ log(`OS: ${osType}`);
221
+ log(`Agents: ${agents.join(', ')}`);
222
+ for (const agent of agents) {
223
+ const platform = getPlatformPaths(agent, options.scope, projectPath);
224
+ log(`${platform.name} skillsDir: ${platform.skillsDir}`);
225
+ log(`${platform.name} rulesDir: ${platform.rulesDir}`);
226
+ log(`${platform.name} scriptsDir: ${platform.scriptsDir}`);
227
+ log(`${platform.name} settingsFile: ${platform.settingsFile}`);
228
+ }
229
+ } },
230
+ { id: 2, name: t(options.language, 'stepDeps'), run: async () => {
231
+ if (options.dryRun) {
232
+ log('[dry-run] npm install -g @fission-ai/openspec@latest');
233
+ if (options.noOpenspecInit) {
234
+ log('[dry-run] --no-openspec-init set, skipping openspec init');
235
+ }
236
+ else {
237
+ log(`[dry-run] openspec ${openspecInitArgs(projectPath, agents, options.scope).join(' ')}`);
238
+ }
239
+ if (agents.includes('claude')) {
240
+ log('[dry-run] Claude plugins: superpowers / understand-anything / api-doc');
241
+ }
242
+ if (agents.includes('codex')) {
243
+ log('[dry-run] Codex plugins/skills: superpowers / understand-anything / api-doc');
244
+ }
245
+ return;
246
+ }
247
+ const openspec = await installOpenspec();
248
+ if (!openspec.ok)
249
+ throw new Error(`openspec install failed: ${openspec.error}`);
250
+ if (options.noOpenspecInit) {
251
+ log(' ⚠ --no-openspec-init: 跳过当前项目 OpenSpec 原生初始化');
252
+ }
253
+ else {
254
+ const openspecInit = await initializeOpenspec(projectPath, agents, options.scope);
255
+ if (!openspecInit.ok) {
256
+ throw new Error(`openspec init failed: ${openspecInit.error}`);
257
+ }
258
+ log(` ✓ OpenSpec initialized for tools: ${agents.join(', ')}`);
259
+ }
260
+ if (agents.includes('claude')) {
261
+ const sup = await installSuperpowers();
262
+ if (!sup.ok)
263
+ throw new Error(`superpowers install failed: ${sup.error}`);
264
+ const und = await installUnderstand();
265
+ if (!und.ok)
266
+ warn(`[WARN] understand-anything: ${und.error}`);
267
+ const api = await installApiDocChangelog(getPlatformPaths('claude', options.scope, projectPath).skillsDir);
268
+ if (!api.ok)
269
+ warn(`[WARN] api-doc-changelog: ${api.error}`);
270
+ }
271
+ if (agents.includes('codex')) {
272
+ const sup = await installCodexSuperpowers();
273
+ if (!sup.ok)
274
+ throw new Error(`codex superpowers install failed: ${sup.error}`);
275
+ const und = await installCodexUnderstand();
276
+ if (!und.ok)
277
+ warn(`[WARN] codex understand-anything: ${und.error}`);
278
+ const api = await installApiDocChangelog(getPlatformPaths('codex', options.scope, projectPath).skillsDir);
279
+ if (!api.ok)
280
+ warn(`[WARN] codex api-doc-changelog: ${api.error}`);
281
+ }
282
+ } },
283
+ { id: 3, name: `${t(options.language, 'stepSkills')} (${ALL_SKILLS.length})`, run: async () => {
284
+ const skillsRoot = options.language === 'en'
285
+ ? path.join(ASSETS_DIR, 'skills-en')
286
+ : path.join(ASSETS_DIR, 'skills');
287
+ if (options.dryRun) {
288
+ for (const agent of agents) {
289
+ const platform = getPlatformPaths(agent, options.scope, projectPath);
290
+ log(`[dry-run] cp -R ${ALL_SKILLS.join(', ')} → ${platform.skillsDir}`);
291
+ }
292
+ return;
293
+ }
294
+ for (const agent of agents) {
295
+ const platform = getPlatformPaths(agent, options.scope, projectPath);
296
+ log(` ${platform.name}:`);
297
+ for (const name of ALL_SKILLS) {
298
+ const dest = path.join(platform.skillsDir, name);
299
+ const existed = existsSync(dest);
300
+ await deploySkill(name, skillsRoot, platform.skillsDir, {
301
+ agent,
302
+ overwrite: options.overwrite,
303
+ skipExisting: options.skipExisting,
304
+ });
305
+ log(` ${options.skipExisting && existed ? '-' : '✓'} ${name}`);
306
+ }
307
+ state.platforms[agent].skills = ALL_SKILLS;
308
+ }
309
+ } },
310
+ { id: 4, name: t(options.language, 'stepScriptsHooks'), run: async () => {
311
+ if (options.dryRun) {
312
+ for (const agent of agents) {
313
+ const platform = getPlatformPaths(agent, options.scope, projectPath);
314
+ const scripts = scriptsForAgent(agent);
315
+ const hookScripts = hookScriptsForAgent(agent);
316
+ log(`[dry-run] cp ${scripts.length} scripts → ${platform.scriptsDir}`);
317
+ if (!options.noHooks) {
318
+ log(`[dry-run] register ${hookScripts.length} hooks → ${platform.settingsFile}`);
319
+ }
320
+ else {
321
+ log(`[dry-run] --no-hooks set, skipping hook registration`);
322
+ }
323
+ }
324
+ return;
325
+ }
326
+ for (const agent of agents) {
327
+ const platform = getPlatformPaths(agent, options.scope, projectPath);
328
+ const scripts = scriptsForAgent(agent);
329
+ await deployScripts(scripts, path.join(ASSETS_DIR, 'scripts'), platform.scriptsDir, {
330
+ agent,
331
+ skipExisting: options.skipExisting,
332
+ });
333
+ log(` ✓ ${platform.name}: ${scripts.length} scripts deployed`);
334
+ state.platforms[agent].scripts = scripts;
335
+ if (options.noHooks) {
336
+ log(` ⚠ --no-hooks: 跳过 ${platform.name} hook 注册(脚本已部署,hook 需手工配)`);
337
+ }
338
+ else {
339
+ const cleared = clearSddHooks(platform.settingsFile);
340
+ if (cleared > 0) {
341
+ log(` ✓ cleared ${cleared} old superflow/legacy sdd hooks (avoid duplicate registration)`);
342
+ }
343
+ const hookScripts = hookScriptsForAgent(agent);
344
+ for (const script of hookScripts) {
345
+ const command = path.join(platform.scriptsDir, script);
346
+ try {
347
+ const timeout = script === 'superflow-dependency-update-hook.sh' ? 300 : undefined;
348
+ registerHook(platform.settingsFile, script, command, { timeout });
349
+ if (script === 'superflow-sql-sync-hook.py') {
350
+ registerHook(platform.settingsFile, script, command, { matcherOverride: 'Bash' });
351
+ }
352
+ }
353
+ catch (err) {
354
+ warn(` [WARN] ${script}: ${err.message}`);
355
+ }
356
+ }
357
+ state.platforms[agent].hooks = hookScripts;
358
+ log(` ✓ ${hookScripts.length} hooks registered to ${platform.settingsFile}`);
359
+ }
360
+ }
361
+ } },
362
+ { id: 5, name: t(options.language, 'stepPrompts'), run: async () => {
363
+ if (!agents.includes('codex')) {
364
+ log(' - 未选择 Codex,跳过 prompt alias');
365
+ return;
366
+ }
367
+ const platform = getPlatformPaths('codex', options.scope, projectPath);
368
+ if (options.dryRun) {
369
+ log(`[dry-run] cp ${CODEX_PROMPTS.join(', ')} → ${platform.promptsDir}`);
370
+ return;
371
+ }
372
+ await deployPrompts(CODEX_PROMPTS, path.join(ASSETS_DIR, 'prompts'), platform.promptsDir, { skipExisting: options.skipExisting });
373
+ log(` ✓ Codex: ${CODEX_PROMPTS.length} prompt alias deployed`);
374
+ } },
375
+ { id: 6, name: `${t(options.language, 'stepRules')} (${ALL_RULES.length})`, run: async () => {
376
+ if (options.dryRun) {
377
+ for (const agent of agents) {
378
+ const platform = getPlatformPaths(agent, options.scope, projectPath);
379
+ log(`[dry-run] cp ${ALL_RULES.join(', ')} → ${platform.rulesDir}`);
380
+ }
381
+ return;
382
+ }
383
+ for (const agent of agents) {
384
+ const platform = getPlatformPaths(agent, options.scope, projectPath);
385
+ await deployRules(ALL_RULES, path.join(ASSETS_DIR, 'rules'), platform.rulesDir, {
386
+ skipExisting: options.skipExisting,
387
+ });
388
+ log(` ✓ ${platform.name}: ${ALL_RULES.length} rule(s) deployed`);
389
+ }
390
+ } },
391
+ { id: 7, name: t(options.language, 'stepScan'), run: async () => {
392
+ if (options.noScan) {
393
+ if (options.dryRun) {
394
+ log(`[dry-run] --no-scan set, skipping Step 7 entirely`);
395
+ }
396
+ else {
397
+ log(' ⚠ --no-scan: 跳过 Step 7 项目扫描(脚手架 + understand-anything + 软提示)');
398
+ }
399
+ return;
400
+ }
401
+ if (options.dryRun) {
402
+ log(`[dry-run] scaffold <cwd>/docs/sdd-context/ (4 files) + understand-anything scan + 软提示`);
403
+ return;
404
+ }
405
+ // 1. 脚手架 4 个初始文件
406
+ const cwd = projectPath;
407
+ const scaffolding = await scaffoldBusinessContext(cwd);
408
+ log(` ✓ scaffolded docs/sdd-context/ (copied ${scaffolding.copied.length}, skipped ${scaffolding.skipped.length})`);
409
+ // 2. 检查 understand-anything 是否已扫
410
+ const understandResult = await checkUnderstandScan(cwd);
411
+ if (understandResult.ok) {
412
+ log(' ✓ understand-anything graph detected: ' + understandResult.graphPath);
413
+ }
414
+ else {
415
+ log(' ⚠ understand-anything 还没扫(用户在 Claude 会话中跑 /understand)');
416
+ }
417
+ // 3. 软提示
418
+ if (!options.json) {
419
+ printSoftPrompt(cwd, scaffolding, understandResult);
420
+ }
421
+ } },
422
+ ];
423
+ for (const step of steps) {
424
+ if (state.completedSteps.includes(step.id)) {
425
+ log(`Step ${step.id} (${step.name}): already completed, skipping`);
426
+ result.steps.push({ id: step.id, name: step.name, status: 'skipped' });
427
+ continue;
428
+ }
429
+ log(`\n=== Step ${step.id}: ${step.name} ===`);
430
+ try {
431
+ await step.run();
432
+ result.steps.push({ id: step.id, name: step.name, status: 'completed' });
433
+ state.completedSteps.push(step.id);
434
+ if (!options.dryRun) {
435
+ state.lastInit = new Date().toISOString();
436
+ saveState(stateFile, state);
437
+ }
438
+ }
439
+ catch (err) {
440
+ state.completedSteps = state.completedSteps.filter((n) => n !== step.id);
441
+ if (!options.dryRun)
442
+ saveState(stateFile, state);
443
+ result.ok = false;
444
+ result.steps.push({
445
+ id: step.id,
446
+ name: step.name,
447
+ status: 'failed',
448
+ error: err.message,
449
+ });
450
+ if (options.json) {
451
+ console.log(JSON.stringify(result, null, 2));
452
+ }
453
+ else {
454
+ console.error(`[FAIL] Step ${step.id} failed: ${err.message}`);
455
+ printInitSummary(result, (line) => console.error(line));
456
+ console.error(t(options.language, 'runResume'));
457
+ }
458
+ process.exit(1);
459
+ }
460
+ }
461
+ if (!options.dryRun) {
462
+ log(`\n=== ${t(options.language, 'initComplete')} ===`);
463
+ log(`${t(options.language, 'stateLabel')}: ${stateFile}`);
464
+ printInitSummary(result, log);
465
+ }
466
+ if (options.json) {
467
+ console.log(JSON.stringify(result, null, 2));
468
+ }
469
+ return result;
470
+ }
471
+ //# sourceMappingURL=init.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"init.js","sourceRoot":"","sources":["../../src/commands/init.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,aAAa,EAAE,MAAM,KAAK,CAAC;AACpC,OAAO,EAAE,UAAU,EAAE,MAAM,IAAI,CAAC;AAChC,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,KAAK,IAAI,KAAK,EAAE,MAAM,IAAI,MAAM,EAAE,MAAM,SAAS,CAAC;AAC3D,OAAO,EACL,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gBAC1E,gBAAgB,CAAC,MAAM,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC;gBACxD,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,OAAO,CAAC,QAAQ,EAAE,WAAW,CAAC,CAAC,CAAC;YAClD,CAAC;YACD,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAClB,CAAC;IACH,CAAC;IAED,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,CAAC;QACpB,GAAG,CAAC,SAAS,CAAC,CAAC,OAAO,CAAC,QAAQ,EAAE,cAAc,CAAC,MAAM,CAAC,CAAC;QACxD,GAAG,CAAC,GAAG,CAAC,CAAC,OAAO,CAAC,QAAQ,EAAE,YAAY,CAAC,KAAK,SAAS,EAAE,CAAC,CAAC;QAC1D,gBAAgB,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAChC,CAAC;IACD,IAAI,OAAO,CAAC,IAAI,EAAE,CAAC;QACjB,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;IAC/C,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC"}
@@ -0,0 +1,6 @@
1
+ import { checkSkillDeployment } from '../core/skill-check.js';
2
+ const SKILL_NAME = 'superflow-pipeline';
3
+ export async function pipelineCommand(options = {}) {
4
+ checkSkillDeployment(SKILL_NAME, options);
5
+ }
6
+ //# sourceMappingURL=pipeline.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pipeline.js","sourceRoot":"","sources":["../../src/commands/pipeline.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAA0B,MAAM,wBAAwB,CAAC;AAEtF,MAAM,UAAU,GAAG,oBAAoB,CAAC;AAExC,MAAM,CAAC,KAAK,UAAU,eAAe,CACnC,UAA6B,EAAE;IAE/B,oBAAoB,CAAC,UAAU,EAAE,OAAO,CAAC,CAAC;AAC5C,CAAC"}
@@ -0,0 +1,59 @@
1
+ import { promises as fs } from 'fs';
2
+ import path from 'path';
3
+ import { scaffoldBusinessContext, checkUnderstandScan, printSoftPrompt } from '../core/context.js';
4
+ const CONTEXT_FILES = [
5
+ 'business-rules.md',
6
+ 'incidents.md',
7
+ 'decisions.md',
8
+ 'external-systems.md',
9
+ ];
10
+ export async function scanCommand(cmdOptions) {
11
+ await runScan({
12
+ dryRun: !!cmdOptions.dryRun,
13
+ force: !!cmdOptions.force,
14
+ });
15
+ }
16
+ export async function runScan(options) {
17
+ const cwd = process.cwd();
18
+ const targetDir = path.join(cwd, 'docs', 'sdd-context');
19
+ console.log('=== superflow scan ===\n');
20
+ console.log(`Target: ${targetDir}`);
21
+ console.log(`Mode: ${options.force ? 'force (overwrite)' : 'default (skip existing)'}\n`);
22
+ if (options.dryRun) {
23
+ console.log('[dry-run] Will scaffold 4 files, run understand-anything scan, print soft prompt');
24
+ return;
25
+ }
26
+ // 1. 确保目标目录存在
27
+ await fs.mkdir(targetDir, { recursive: true });
28
+ // 2. 脚手架
29
+ let scaffolding = await scaffoldBusinessContext(cwd);
30
+ console.log(`Scaffold: copied ${scaffolding.copied.length}, skipped ${scaffolding.skipped.length}`);
31
+ // 3. --force 时删除已存在的再复制
32
+ if (options.force) {
33
+ console.log('--force: removing existing files first');
34
+ for (const filename of CONTEXT_FILES) {
35
+ const target = path.join(targetDir, filename);
36
+ try {
37
+ await fs.unlink(target);
38
+ }
39
+ catch {
40
+ // 文件不存在无所谓
41
+ }
42
+ }
43
+ // 重新脚手架(此时所有都该被复制)
44
+ scaffolding = await scaffoldBusinessContext(cwd);
45
+ console.log(`Scaffold (after force): copied ${scaffolding.copied.length}`);
46
+ }
47
+ // 4. 检查 understand-anything 扫描状态
48
+ console.log('\nChecking understand-anything graph...');
49
+ const understandResult = await checkUnderstandScan(cwd);
50
+ if (understandResult.ok) {
51
+ console.log('✓ understand-anything graph found: ' + understandResult.graphPath);
52
+ }
53
+ else {
54
+ console.log('⚠ understand-anything 还没扫(在 Claude 会话中跑 /understand)');
55
+ }
56
+ // 5. 软提示
57
+ printSoftPrompt(cwd, scaffolding, understandResult);
58
+ }
59
+ //# sourceMappingURL=scan.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"scan.js","sourceRoot":"","sources":["../../src/commands/scan.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,IAAI,EAAE,EAAE,MAAM,IAAI,CAAC;AACpC,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,uBAAuB,EAAE,mBAAmB,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAOnG,MAAM,aAAa,GAAG;IACpB,mBAAmB;IACnB,cAAc;IACd,cAAc;IACd,qBAAqB;CACb,CAAC;AAEX,MAAM,CAAC,KAAK,UAAU,WAAW,CAAC,UAAiD;IACjF,MAAM,OAAO,CAAC;QACZ,MAAM,EAAE,CAAC,CAAC,UAAU,CAAC,MAAM;QAC3B,KAAK,EAAE,CAAC,CAAC,UAAU,CAAC,KAAK;KAC1B,CAAC,CAAC;AACL,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,OAAO,CAAC,OAAoB;IAChD,MAAM,GAAG,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC;IAC1B,MAAM,SAAS,GAAG,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,MAAM,EAAE,aAAa,CAAC,CAAC;IAExD,OAAO,CAAC,GAAG,CAAC,0BAA0B,CAAC,CAAC;IACxC,OAAO,CAAC,GAAG,CAAC,WAAW,SAAS,EAAE,CAAC,CAAC;IACpC,OAAO,CAAC,GAAG,CAAC,SAAS,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,mBAAmB,CAAC,CAAC,CAAC,yBAAyB,IAAI,CAAC,CAAC;IAE1F,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC;QACnB,OAAO,CAAC,GAAG,CAAC,kFAAkF,CAAC,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