ccg-ros2-workflow 2.2.1 → 3.0.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 (186) hide show
  1. package/README.md +211 -96
  2. package/README.zh-CN.md +256 -0
  3. package/dist/cli.mjs +15 -15
  4. package/dist/index.d.mts +61 -34
  5. package/dist/index.d.ts +61 -34
  6. package/dist/index.mjs +4 -4
  7. package/dist/shared/ccg-ros2-workflow.Bhm8c7P1.mjs +5154 -0
  8. package/package.json +31 -12
  9. package/templates/codex/AGENTS.md +348 -0
  10. package/templates/codex/agents/ccg-implement.toml +73 -0
  11. package/templates/codex/agents/ccg-research.toml +73 -0
  12. package/templates/codex/agents/ccg-review.toml +82 -0
  13. package/templates/codex/config.toml +21 -0
  14. package/templates/codex/hooks/ccg-workflow.py +253 -0
  15. package/templates/codex/hooks.json +15 -0
  16. package/templates/commands/agents/planner.md +97 -122
  17. package/templates/commands/agents/system-integrator.md +2 -2
  18. package/templates/commands/agents/team-architect.md +97 -0
  19. package/templates/commands/agents/team-qa.md +121 -0
  20. package/templates/commands/agents/team-reviewer.md +112 -0
  21. package/templates/commands/commit.md +30 -1
  22. package/templates/commands/context.md +332 -0
  23. package/templates/commands/go.md +206 -0
  24. package/templates/commands/init.md +1 -1
  25. package/templates/commands/spec-impl.md +41 -21
  26. package/templates/commands/spec-init.md +21 -27
  27. package/templates/commands/spec-plan.md +54 -21
  28. package/templates/commands/spec-research.md +78 -26
  29. package/templates/commands/spec-review.md +20 -16
  30. package/templates/{commands → commands-legacy}/analyze.md +1 -1
  31. package/templates/commands-legacy/backend.md +224 -0
  32. package/templates/commands-legacy/codex-exec.md +411 -0
  33. package/templates/{commands → commands-legacy}/debug.md +1 -1
  34. package/templates/commands-legacy/enhance.md +55 -0
  35. package/templates/{commands → commands-legacy}/feat.md +2 -2
  36. package/templates/commands-legacy/frontend.md +213 -0
  37. package/templates/{commands → commands-legacy}/optimize.md +1 -1
  38. package/templates/{commands → commands-legacy}/plan.md +1 -15
  39. package/templates/{commands → commands-legacy}/team-plan.md +1 -1
  40. package/templates/commands-legacy/team.md +475 -0
  41. package/templates/{commands → commands-legacy}/test.md +1 -1
  42. package/templates/commands-legacy/workflow.md +283 -0
  43. package/templates/engine/model-router.md +123 -0
  44. package/templates/engine/phase-guide.md +207 -0
  45. package/templates/engine/strategies/debug-investigate.md +169 -0
  46. package/templates/engine/strategies/deep-research.md +141 -0
  47. package/templates/engine/strategies/direct-fix.md +108 -0
  48. package/templates/engine/strategies/full-collaborate.md +389 -0
  49. package/templates/engine/strategies/git-action.md +43 -0
  50. package/templates/engine/strategies/guided-develop.md +282 -0
  51. package/templates/engine/strategies/optimize-measure.md +103 -0
  52. package/templates/engine/strategies/quick-implement.md +96 -0
  53. package/templates/engine/strategies/refactor-safely.md +180 -0
  54. package/templates/engine/strategies/review-audit.md +123 -0
  55. package/templates/hooks/session-start.js +100 -0
  56. package/templates/hooks/skill-router.js +144 -0
  57. package/templates/hooks/subagent-context.js +161 -0
  58. package/templates/hooks/task-utils.js +190 -0
  59. package/templates/hooks/workflow-state.js +55 -0
  60. package/templates/output-styles/abyss-command.md +56 -0
  61. package/templates/output-styles/abyss-concise.md +89 -0
  62. package/templates/output-styles/abyss-ritual.md +70 -0
  63. package/templates/output-styles/engineer-professional.md +20 -3
  64. package/templates/output-styles/laowang-engineer.md +2 -2
  65. package/templates/prompts/antigravity/analyzer.md +59 -0
  66. package/templates/prompts/antigravity/architect.md +55 -0
  67. package/templates/prompts/antigravity/builder.md +52 -0
  68. package/templates/prompts/antigravity/debugger.md +48 -0
  69. package/templates/prompts/antigravity/frontend.md +50 -0
  70. package/templates/prompts/antigravity/optimizer.md +40 -0
  71. package/templates/prompts/antigravity/reviewer.md +67 -0
  72. package/templates/prompts/antigravity/tester.md +39 -0
  73. package/templates/prompts/claude/debugger.md +1 -1
  74. package/templates/prompts/claude/reviewer.md +1 -1
  75. package/templates/prompts/codex/analyzer.md +8 -0
  76. package/templates/prompts/codex/architect.md +9 -1
  77. package/templates/prompts/codex/builder.md +61 -0
  78. package/templates/prompts/codex/debugger.md +9 -1
  79. package/templates/prompts/codex/optimizer.md +7 -0
  80. package/templates/prompts/codex/reviewer.md +7 -0
  81. package/templates/prompts/codex/tester.md +8 -1
  82. package/templates/prompts/gemini/analyzer.md +11 -3
  83. package/templates/prompts/gemini/architect.md +10 -2
  84. package/templates/prompts/gemini/debugger.md +8 -0
  85. package/templates/prompts/gemini/frontend.md +10 -2
  86. package/templates/prompts/gemini/optimizer.md +9 -2
  87. package/templates/prompts/gemini/reviewer.md +7 -0
  88. package/templates/prompts/gemini/tester.md +8 -1
  89. package/templates/rules/ccg-skill-routing.md +91 -0
  90. package/templates/rules/ccg-skills.md +65 -0
  91. package/templates/skills/SKILL.md +92 -0
  92. package/templates/skills/domains/ai/SKILL.md +34 -0
  93. package/templates/skills/domains/ai/agent-dev.md +242 -0
  94. package/templates/skills/domains/ai/llm-security.md +288 -0
  95. package/templates/skills/domains/ai/prompt-and-eval.md +279 -0
  96. package/templates/skills/domains/ai/rag-system.md +542 -0
  97. package/templates/skills/domains/architecture/SKILL.md +42 -0
  98. package/templates/skills/domains/architecture/api-design.md +225 -0
  99. package/templates/skills/domains/architecture/caching.md +299 -0
  100. package/templates/skills/domains/architecture/cloud-native.md +285 -0
  101. package/templates/skills/domains/architecture/message-queue.md +329 -0
  102. package/templates/skills/domains/architecture/security-arch.md +297 -0
  103. package/templates/skills/domains/data-engineering/SKILL.md +207 -0
  104. package/templates/skills/domains/development/SKILL.md +46 -0
  105. package/templates/skills/domains/development/cpp.md +369 -0
  106. package/templates/skills/domains/development/go.md +323 -0
  107. package/templates/skills/domains/development/java.md +277 -0
  108. package/templates/skills/domains/development/python.md +487 -0
  109. package/templates/skills/domains/development/rust.md +313 -0
  110. package/templates/skills/domains/development/shell.md +313 -0
  111. package/templates/skills/domains/development/typescript.md +277 -0
  112. package/templates/skills/domains/devops/SKILL.md +39 -0
  113. package/templates/skills/domains/devops/cost-optimization.md +272 -0
  114. package/templates/skills/domains/devops/database.md +217 -0
  115. package/templates/skills/domains/devops/devsecops.md +198 -0
  116. package/templates/skills/domains/devops/git-workflow.md +181 -0
  117. package/templates/skills/domains/devops/observability.md +280 -0
  118. package/templates/skills/domains/devops/performance.md +336 -0
  119. package/templates/skills/domains/devops/testing.md +283 -0
  120. package/templates/skills/domains/infrastructure/SKILL.md +200 -0
  121. package/templates/skills/domains/mobile/SKILL.md +224 -0
  122. package/templates/skills/domains/orchestration/SKILL.md +29 -0
  123. package/templates/skills/domains/orchestration/multi-agent.md +263 -0
  124. package/templates/skills/domains/ros2-control/SKILL.md +206 -0
  125. package/templates/skills/domains/ros2-hardware/SKILL.md +277 -0
  126. package/templates/skills/domains/ros2-manipulation/SKILL.md +237 -0
  127. package/templates/skills/domains/ros2-navigation/SKILL.md +196 -0
  128. package/templates/skills/domains/ros2-perception/SKILL.md +166 -0
  129. package/templates/skills/domains/ros2-upper-app/SKILL.md +50 -0
  130. package/templates/skills/domains/ros2-upper-app/launch-files.md +224 -0
  131. package/templates/skills/domains/ros2-upper-app/parameters.md +192 -0
  132. package/templates/skills/domains/ros2-upper-app/python-nodes.md +249 -0
  133. package/templates/skills/domains/ros2-upper-app/rviz-config.md +158 -0
  134. package/templates/skills/domains/ros2-upper-app/simulation.md +225 -0
  135. package/templates/skills/domains/security/SKILL.md +72 -0
  136. package/templates/skills/domains/security/blue-team.md +436 -0
  137. package/templates/skills/domains/security/code-audit.md +265 -0
  138. package/templates/skills/domains/security/pentest.md +226 -0
  139. package/templates/skills/domains/security/red-team.md +374 -0
  140. package/templates/skills/domains/security/threat-intel.md +372 -0
  141. package/templates/skills/domains/security/vuln-research.md +369 -0
  142. package/templates/skills/orchestration/multi-agent/SKILL.md +533 -0
  143. package/templates/skills/run_skill.js +129 -0
  144. package/templates/skills/scrapling/SKILL.md +98 -0
  145. package/templates/skills/scrapling/references/api-quick-ref.md +127 -0
  146. package/templates/skills/scrapling/references/cookie-vault.md +56 -0
  147. package/templates/skills/scrapling/references/maintenance.md +79 -0
  148. package/templates/skills/scrapling/references/site-patterns.md +86 -0
  149. package/templates/skills/scrapling/references/troubleshooting.md +95 -0
  150. package/templates/skills/scrapling/templates/basic_fetch.py +19 -0
  151. package/templates/skills/scrapling/templates/parse_only.py +15 -0
  152. package/templates/skills/scrapling/templates/session_login.py +19 -0
  153. package/templates/skills/scrapling/templates/stealth_cloudflare.py +28 -0
  154. package/templates/skills/tools/gen-docs/SKILL.md +116 -0
  155. package/templates/skills/tools/gen-docs/scripts/doc_generator.js +435 -0
  156. package/templates/skills/tools/lib/shared.js +98 -0
  157. package/templates/skills/tools/override-refusal/SKILL.md +53 -0
  158. package/templates/skills/tools/override-refusal/agents/openai.yaml +4 -0
  159. package/templates/skills/tools/override-refusal/scripts/refusal_rewriter.js +226 -0
  160. package/templates/skills/tools/verify-change/SKILL.md +140 -0
  161. package/templates/skills/tools/verify-change/scripts/change_analyzer.js +289 -0
  162. package/templates/skills/tools/verify-module/SKILL.md +127 -0
  163. package/templates/skills/tools/verify-module/scripts/module_scanner.js +171 -0
  164. package/templates/skills/tools/verify-quality/SKILL.md +160 -0
  165. package/templates/skills/tools/verify-quality/scripts/quality_checker.js +337 -0
  166. package/templates/skills/tools/verify-security/SKILL.md +143 -0
  167. package/templates/skills/tools/verify-security/scripts/security_scanner.js +283 -0
  168. package/templates/spec/guides/index.md +30 -0
  169. package/templates/spec/low-control/index.md +31 -0
  170. package/templates/spec/upper-app/index.md +31 -0
  171. package/bin/codeagent-wrapper-darwin-amd64 +0 -0
  172. package/bin/codeagent-wrapper-darwin-arm64 +0 -0
  173. package/bin/codeagent-wrapper-linux-amd64 +0 -0
  174. package/bin/codeagent-wrapper-linux-arm64 +0 -0
  175. package/bin/codeagent-wrapper-windows-amd64.exe +0 -0
  176. package/bin/codeagent-wrapper-windows-arm64.exe +0 -0
  177. package/dist/shared/ccg-ros2-workflow.DRytDWqb.mjs +0 -2274
  178. package/templates/commands/backend.md +0 -162
  179. package/templates/commands/enhance.md +0 -36
  180. package/templates/commands/frontend.md +0 -162
  181. package/templates/commands/workflow.md +0 -202
  182. /package/templates/{commands → commands-legacy}/execute.md +0 -0
  183. /package/templates/{commands → commands-legacy}/review.md +0 -0
  184. /package/templates/{commands → commands-legacy}/team-exec.md +0 -0
  185. /package/templates/{commands → commands-legacy}/team-research.md +0 -0
  186. /package/templates/{commands → commands-legacy}/team-review.md +0 -0
@@ -0,0 +1,283 @@
1
+ #!/usr/bin/env node
2
+ 'use strict';
3
+
4
+ const fs = require('fs');
5
+ const path = require('path');
6
+
7
+ const SEVERITY_ORDER = { critical: 0, high: 1, medium: 2, low: 3, info: 4 };
8
+
9
+ // prettier-ignore
10
+ const SECURITY_RULES = [
11
+ {
12
+ id: 'SQL_INJECTION_DYNAMIC', category: '注入',
13
+ severity: 'critical',
14
+ pattern: new RegExp(
15
+ '\\b(execute|query|raw)\\s*\\(\\s*' +
16
+ '(f["\']|["\'][^"\'\\n]*["\']\\s*\\+\\s*|["\'][^"\'\\n]*["\']\\s*%\\s*[^,)]|["\'][^"\'\\n]*["\']' +
17
+ '\\.format\\s*\\()', 'i'),
18
+ extensions: ['.py', '.js', '.ts', '.go', '.java', '.php'],
19
+ message: '可能存在 SQL 注入风险',
20
+ recommendation: '使用参数化查询或 ORM',
21
+ },
22
+ {
23
+ id: 'SQL_INJECTION_FSTRING', category: '注入',
24
+ severity: 'critical',
25
+ pattern: /cursor\.(execute|executemany)\s*\(\s*f["']/i,
26
+ extensions: ['.py'],
27
+ message: '使用 f-string 构造 SQL 语句',
28
+ recommendation: '使用参数化查询',
29
+ },
30
+ {
31
+ id: 'COMMAND_INJECTION', category: '注入',
32
+ severity: 'critical',
33
+ pattern: /(os\.system|os\.popen|subprocess\.call|subprocess\.run|subprocess\.Popen)\s*\([^)]*shell\s*=\s*True/i,
34
+ extensions: ['.py'],
35
+ message: '使用 shell=True 可能导致命令注入',
36
+ recommendation: '避免 shell=True,使用列表参数',
37
+ },
38
+ {
39
+ id: 'COMMAND_INJECTION_EVAL', category: '注入',
40
+ severity: 'critical',
41
+ pattern: /\b(eval|exec)\s*\([^)]*\b(input|request|argv|args)/i,
42
+ extensions: ['.py'],
43
+ message: 'eval/exec 执行用户输入',
44
+ recommendation: '避免对用户输入使用 eval/exec',
45
+ },
46
+ {
47
+ id: 'HARDCODED_SECRET', category: '敏感信息',
48
+ severity: 'high',
49
+ pattern: /(?<!\w)(password|passwd|pwd|secret|api_key|apikey|token|auth_token)\s*=\s*["'][^"']{8,}["']/i,
50
+ excludePattern: /(example|placeholder|changeme|xxx|your[_-]|TODO|FIXME|<.*>|\*{3,})/i,
51
+ extensions: [
52
+ '.py', '.js', '.ts', '.go', '.java', '.php',
53
+ '.rb', '.yaml', '.yml', '.json', '.env',
54
+ ],
55
+ message: '可能存在硬编码密钥/密码',
56
+ recommendation: '使用环境变量或密钥管理服务',
57
+ },
58
+ {
59
+ id: 'HARDCODED_AWS_KEY', category: '敏感信息',
60
+ severity: 'critical',
61
+ pattern: /AKIA[0-9A-Z]{16}/,
62
+ extensions: ['*'],
63
+ message: '发现 AWS Access Key',
64
+ recommendation: '立即轮换密钥,使用 IAM 角色或环境变量',
65
+ },
66
+ {
67
+ id: 'HARDCODED_PRIVATE_KEY', category: '敏感信息',
68
+ severity: 'critical',
69
+ pattern: /-----BEGIN (RSA |EC |DSA |OPENSSH )?PRIVATE KEY-----/,
70
+ extensions: ['*'],
71
+ message: '发现私钥',
72
+ recommendation: '私钥不应提交到代码库',
73
+ },
74
+ {
75
+ id: 'XSS_INNERHTML', category: 'XSS', severity: 'high',
76
+ pattern: /\.innerHTML\s*=|\.outerHTML\s*=|document\.write\s*\(/i,
77
+ extensions: ['.js', '.ts', '.jsx', '.tsx', '.html'],
78
+ message: '直接操作 innerHTML 可能导致 XSS',
79
+ recommendation: '使用 textContent 或框架的安全绑定',
80
+ },
81
+ {
82
+ id: 'XSS_DANGEROUSLY', category: 'XSS',
83
+ severity: 'medium',
84
+ pattern: /dangerouslySetInnerHTML/i,
85
+ extensions: ['.js', '.ts', '.jsx', '.tsx'],
86
+ message: '使用 dangerouslySetInnerHTML',
87
+ recommendation: '确保内容已经过净化处理',
88
+ },
89
+ {
90
+ id: 'UNSAFE_PICKLE', category: '反序列化',
91
+ severity: 'high',
92
+ pattern: /pickle\.loads?\s*\(|yaml\.load\s*\([^)]*Loader\s*=\s*yaml\.Loader/i,
93
+ extensions: ['.py'],
94
+ message: '不安全的反序列化',
95
+ recommendation: '使用 yaml.safe_load() 或验证数据来源',
96
+ },
97
+ {
98
+ id: 'WEAK_CRYPTO_MD5', category: '加密',
99
+ severity: 'medium',
100
+ pattern: /\b(md5|MD5)\s*\(|hashlib\.md5\s*\(/i,
101
+ extensions: ['.py', '.js', '.ts', '.go', '.java', '.php'],
102
+ message: '使用弱哈希算法 MD5',
103
+ recommendation: '使用 bcrypt/argon2 或 SHA-256+',
104
+ },
105
+ {
106
+ id: 'WEAK_CRYPTO_SHA1', category: '加密',
107
+ severity: 'low',
108
+ pattern: /\b(sha1|SHA1)\s*\(|hashlib\.sha1\s*\(/i,
109
+ extensions: ['.py', '.js', '.ts', '.go', '.java', '.php'],
110
+ message: '使用弱哈希算法 SHA1',
111
+ recommendation: '使用 SHA-256 或更强的算法',
112
+ },
113
+ {
114
+ id: 'PATH_TRAVERSAL', category: '路径遍历',
115
+ severity: 'high',
116
+ pattern: new RegExp(
117
+ '(open|read|write|Path|os\\.path\\.join)\\s*\\([^\\n]*' +
118
+ '(request|input|argv|args|params|query|form|path_param)\\b', 'i'),
119
+ extensions: ['.py'],
120
+ message: '可能存在路径遍历风险',
121
+ recommendation: '验证并规范化用户输入的路径',
122
+ },
123
+ {
124
+ id: 'SSRF', category: 'SSRF', severity: 'high',
125
+ pattern: new RegExp(
126
+ '(requests\\.(get|post|put|delete|head)|urllib\\.request\\.urlopen)' +
127
+ '\\s*\\([^\\n]*(request|input|argv|args|params|query|url)\\b', 'i'),
128
+ extensions: ['.py'],
129
+ message: '可能存在 SSRF 风险',
130
+ recommendation: '验证并限制目标 URL',
131
+ },
132
+ {
133
+ id: 'DEBUG_CODE', category: '调试', severity: 'low',
134
+ pattern: /\b(console\.log|debugger|pdb\.set_trace|breakpoint)\s*\(/i,
135
+ extensions: ['.py', '.js', '.ts'],
136
+ message: '发现调试代码',
137
+ recommendation: '生产环境移除调试代码',
138
+ },
139
+ {
140
+ id: 'INSECURE_RANDOM', category: '加密',
141
+ severity: 'medium',
142
+ pattern: /\brandom\.(random|randint|choice|shuffle)\s*\(/i,
143
+ extensions: ['.py'],
144
+ message: '使用不安全的随机数生成器',
145
+ recommendation: '安全场景使用 secrets 模块',
146
+ },
147
+ {
148
+ id: 'XXE', category: 'XXE', severity: 'high',
149
+ pattern: /etree\.(parse|fromstring)\s*\([^)]*\)|xml\.dom\.minidom\.parse/i,
150
+ extensions: ['.py'],
151
+ message: 'XML 解析可能存在 XXE 风险',
152
+ recommendation: '禁用外部实体: XMLParser(resolve_entities=False)',
153
+ },
154
+ ];
155
+
156
+ const CODE_EXTENSIONS = new Set([
157
+ '.py', '.js', '.ts', '.jsx', '.tsx', '.go',
158
+ '.java', '.php', '.rb', '.yaml', '.yml', '.json',
159
+ ]);
160
+ const DEFAULT_EXCLUDES = [
161
+ '.git', 'node_modules', '__pycache__', '.venv', 'venv',
162
+ 'dist', 'build', '.tox', 'tests', 'test', '__tests__', 'spec',
163
+ ];
164
+
165
+ function scanFile(filePath, rules) {
166
+ const findings = [];
167
+ const ext = path.extname(filePath).toLowerCase();
168
+ let content;
169
+ try { content = fs.readFileSync(filePath, 'utf-8'); } catch { return findings; }
170
+ const lines = content.split('\n');
171
+
172
+ for (const rule of rules) {
173
+ const exts = rule.extensions;
174
+ if (!exts.includes('*') && !exts.includes(ext)) continue;
175
+
176
+ for (let i = 0; i < lines.length; i++) {
177
+ const line = lines[i];
178
+ const stripped = line.trim();
179
+ const isComment = stripped.startsWith('#') ||
180
+ stripped.startsWith('//') || stripped.startsWith('*') ||
181
+ stripped.startsWith('/*');
182
+ if (isComment) continue;
183
+ const ruleDefRe = /^\s*(id|pattern|severity|message|recommendation|extensions|excludePattern|category)\s*:/;
184
+ if (ruleDefRe.test(stripped)) continue;
185
+
186
+ if (rule.pattern.test(line)) {
187
+ rule.pattern.lastIndex = 0;
188
+ if (rule.excludePattern && rule.excludePattern.test(line)) {
189
+ rule.excludePattern.lastIndex = 0; continue;
190
+ }
191
+ findings.push({
192
+ severity: rule.severity, category: rule.category,
193
+ message: rule.message, file_path: filePath,
194
+ line_number: i + 1,
195
+ line_content: stripped.slice(0, 100),
196
+ recommendation: rule.recommendation,
197
+ });
198
+ }
199
+ }
200
+ }
201
+ return findings;
202
+ }
203
+
204
+ function walkDir(dir, excludeDirs) {
205
+ const results = [];
206
+ let entries;
207
+ try { entries = fs.readdirSync(dir, { withFileTypes: true }); } catch { return results; }
208
+ for (const entry of entries) {
209
+ if (excludeDirs.includes(entry.name)) continue;
210
+ const full = path.join(dir, entry.name);
211
+ if (entry.isDirectory()) { results.push(...walkDir(full, excludeDirs)); }
212
+ else if (entry.isFile()) {
213
+ if (CODE_EXTENSIONS.has(path.extname(entry.name).toLowerCase())) {
214
+ results.push(full);
215
+ }
216
+ }
217
+ }
218
+ return results;
219
+ }
220
+
221
+ function scanDirectory(scanPath, excludeDirs) {
222
+ const resolved = path.resolve(scanPath);
223
+ const findings = [];
224
+ const files = walkDir(resolved, excludeDirs);
225
+ for (const f of files) findings.push(...scanFile(f, SECURITY_RULES));
226
+ findings.sort((a, b) =>
227
+ (SEVERITY_ORDER[a.severity] ?? 9) - (SEVERITY_ORDER[b.severity] ?? 9));
228
+ const passed = !findings.some(
229
+ f => f.severity === 'critical' || f.severity === 'high'
230
+ );
231
+ return { scan_path: resolved, files_scanned: files.length, passed, findings };
232
+ }
233
+
234
+ const { buildReport, countBySeverity, parseCliArgs } = require(
235
+ path.join(__dirname, '..', '..', 'lib', 'shared.js')
236
+ );
237
+
238
+ function formatReport(result, verbose) {
239
+ const counts = countBySeverity(result.findings);
240
+ const fields = {
241
+ '扫描路径': result.scan_path,
242
+ '扫描文件': result.files_scanned,
243
+ '扫描结果': result.passed ? '\u2713 通过' : '\u2717 发现高危问题',
244
+ '统计': `严重: ${counts.critical || 0} | 高危: ${counts.high || 0}` +
245
+ ` | 中危: ${counts.medium || 0} | 低危: ${counts.low || 0}`,
246
+ };
247
+ return buildReport(
248
+ '代码安全扫描报告', fields, result.findings, verbose, 'category'
249
+ );
250
+ }
251
+
252
+
253
+ function main() {
254
+ const opts = parseCliArgs(process.argv, { exclude: [] });
255
+ if (opts.help) {
256
+ console.log('Usage: security_scanner.js [path] [-v] [--json] [--exclude dir1 dir2]');
257
+ process.exit(0);
258
+ }
259
+ const scanPath = opts.target;
260
+ const verbose = opts.verbose;
261
+ const jsonOut = opts.json;
262
+ const excludeDirs = [...DEFAULT_EXCLUDES, ...opts.exclude];
263
+ const result = scanDirectory(scanPath, excludeDirs);
264
+
265
+ if (jsonOut) {
266
+ console.log(JSON.stringify({
267
+ scan_path: result.scan_path,
268
+ files_scanned: result.files_scanned,
269
+ passed: result.passed,
270
+ counts: countBySeverity(result.findings),
271
+ findings: result.findings,
272
+ }, null, 2));
273
+ } else {
274
+ console.log(formatReport(result, verbose));
275
+ }
276
+ process.exit(result.passed ? 0 : 1);
277
+ }
278
+
279
+ if (require.main === module) {
280
+ main();
281
+ }
282
+
283
+ module.exports = { scanFile, SECURITY_RULES };
@@ -0,0 +1,30 @@
1
+ # Guides — 跨模块开发指南
2
+
3
+ > 本文件定义跨前底层控制的通用指南。适用于所有模块和子 Agent。
4
+ > 按项目实际情况修改内容。
5
+
6
+ ## 架构原则
7
+
8
+ - 单一职责: 每个模块/函数只做一件事
9
+ - 依赖方向: 高层依赖低层,禁止循环
10
+ - 接口优先: 跨模块通过接口通信,不直接访问内部
11
+
12
+ ## Git 提交规范
13
+
14
+ - 格式: Conventional Commits (`feat:`, `fix:`, `refactor:`, `docs:`, `chore:`)
15
+ - 原子提交: 一个逻辑变更一个 commit
16
+ - 不提交: `.env`, `node_modules/`, 编译产物, IDE 配置
17
+
18
+ ## 代码审查清单
19
+
20
+ - [ ] 变更是否符合需求?
21
+ - [ ] 是否有测试覆盖?
22
+ - [ ] 是否引入安全风险?
23
+ - [ ] 是否有性能影响?
24
+ - [ ] 命名是否清晰?
25
+
26
+ ## 文档要求
27
+
28
+ - 公共 API 必须有类型注释
29
+ - 复杂逻辑加注释说明 WHY(不是 WHAT)
30
+ - 新模块需要 README
@@ -0,0 +1,31 @@
1
+ # Backend Spec — 底层控制编码规范
2
+
3
+ > 本文件定义底层控制代码的编码规范。子 Agent 在写代码前会自动读取此文件。
4
+ > 按项目实际情况修改内容。
5
+
6
+ ## API 规范
7
+
8
+ - 路由命名: RESTful, kebab-case
9
+ - 请求/响应格式: JSON, camelCase fields
10
+ - 错误格式: `{ "error": { "code": "...", "message": "..." } }`
11
+ - 认证: Bearer token in Authorization header
12
+
13
+ ## 错误处理
14
+
15
+ - 所有 API 端点必须返回结构化错误
16
+ - 4xx: 客户端错误(验证失败、未授权等)
17
+ - 5xx: 服务端错误(包装内部异常,不暴露堆栈)
18
+ - 超时: 设置合理超时,超时后返回 504
19
+
20
+ ## 测试要求
21
+
22
+ - 核心逻辑覆盖率 > 80%
23
+ - API 端点必须有集成测试
24
+ - 测试命名: `describe('模块') → it('should 行为')`
25
+
26
+ ## 安全清单
27
+
28
+ - [ ] 输入验证(不信任任何用户输入)
29
+ - [ ] SQL 参数化(禁止字符串拼接)
30
+ - [ ] 密钥不硬编码(使用环境变量)
31
+ - [ ] 敏感数据日志脱敏
@@ -0,0 +1,31 @@
1
+ # Frontend Spec — 上层应用编码规范
2
+
3
+ > 本文件定义上层应用代码的编码规范。子 Agent 在写代码前会自动读取此文件。
4
+ > 按项目实际情况修改内容。
5
+
6
+ ## 组件规范
7
+
8
+ - 组件命名: PascalCase
9
+ - 文件结构: 一个组件一个文件
10
+ - Props: TypeScript 接口定义,必须有类型
11
+ - 状态: 优先 local state,跨组件共享用 store
12
+
13
+ ## 样式规范
14
+
15
+ - 方案: CSS Modules / Tailwind / styled-components(按项目选择)
16
+ - 命名: BEM 或 utility-first
17
+ - 响应式: mobile-first
18
+ - 主题: 使用 CSS 变量 / design tokens
19
+
20
+ ## 可访问性
21
+
22
+ - [ ] 语义化 HTML(button 不用 div)
23
+ - [ ] ARIA 标签(交互元素必须有 label)
24
+ - [ ] 键盘导航(Tab 序和 Focus 管理)
25
+ - [ ] 颜色对比度 > 4.5:1
26
+
27
+ ## 性能
28
+
29
+ - 图片: 使用 lazy loading + 合适格式(WebP)
30
+ - 包大小: 关注 bundle analyzer,避免大依赖
31
+ - 渲染: 避免不必要的 re-render
Binary file
Binary file
Binary file
Binary file