sumulige-claude 1.1.2 → 1.2.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 (102) hide show
  1. package/.claude/hooks/code-formatter.cjs +7 -2
  2. package/.claude/hooks/multi-session.cjs +9 -3
  3. package/.claude/hooks/pre-commit.cjs +0 -0
  4. package/.claude/hooks/pre-push.cjs +0 -0
  5. package/.claude/hooks/project-kickoff.cjs +22 -11
  6. package/.claude/hooks/rag-skill-loader.cjs +7 -0
  7. package/.claude/hooks/thinking-silent.cjs +9 -3
  8. package/.claude/hooks/todo-manager.cjs +19 -13
  9. package/.claude/hooks/verify-work.cjs +10 -4
  10. package/.claude/quality-gate.json +9 -3
  11. package/.claude/settings.local.json +16 -1
  12. package/.claude/templates/hooks/README.md +302 -0
  13. package/.claude/templates/hooks/hook.sh.template +94 -0
  14. package/.claude/templates/hooks/user-prompt-submit.cjs.template +116 -0
  15. package/.claude/templates/hooks/user-response-submit.cjs.template +94 -0
  16. package/.claude/templates/hooks/validate.js +173 -0
  17. package/.claude/workflow/document-scanner.js +426 -0
  18. package/.claude/workflow/knowledge-engine.js +941 -0
  19. package/.claude/workflow/notebooklm/browser.js +1028 -0
  20. package/.claude/workflow/phases/phase1-research.js +578 -0
  21. package/.claude/workflow/phases/phase1-research.ts +465 -0
  22. package/.claude/workflow/phases/phase2-approve.js +722 -0
  23. package/.claude/workflow/phases/phase3-plan.js +1200 -0
  24. package/.claude/workflow/phases/phase4-develop.js +894 -0
  25. package/.claude/workflow/search-cache.js +230 -0
  26. package/.claude/workflow/templates/approval.md +315 -0
  27. package/.claude/workflow/templates/development.md +377 -0
  28. package/.claude/workflow/templates/planning.md +328 -0
  29. package/.claude/workflow/templates/research.md +250 -0
  30. package/.claude/workflow/types.js +37 -0
  31. package/.claude/workflow/web-search.js +278 -0
  32. package/.claude-plugin/marketplace.json +2 -2
  33. package/AGENTS.md +176 -0
  34. package/CHANGELOG.md +7 -14
  35. package/cli.js +20 -0
  36. package/config/quality-gate.json +9 -3
  37. package/development/cache/web-search/search_1193d605f8eb364651fc2f2041b58a31.json +36 -0
  38. package/development/cache/web-search/search_3798bf06960edc125f744a1abb5b72c5.json +36 -0
  39. package/development/cache/web-search/search_37c7d4843a53f0d83f1122a6f908a2a3.json +36 -0
  40. package/development/cache/web-search/search_44166fa0153709ee168485a22aa0ab40.json +36 -0
  41. package/development/cache/web-search/search_4deaebb1f77e86a8ca066dc5a49c59fd.json +36 -0
  42. package/development/cache/web-search/search_94da91789466070a7f545612e73c7372.json +36 -0
  43. package/development/cache/web-search/search_dd5de8491b8b803a3cb01339cd210fb0.json +36 -0
  44. package/development/knowledge-base/.index.clean.json +0 -0
  45. package/development/knowledge-base/.index.json +486 -0
  46. package/development/knowledge-base/test-best-practices.md +29 -0
  47. package/development/projects/proj_mkh1pazz_ixmt1/phase1/feasibility-report.md +160 -0
  48. package/development/projects/proj_mkh4jvnb_z7rwf/phase1/feasibility-report.md +160 -0
  49. package/development/projects/proj_mkh4jxkd_ewz5a/phase1/feasibility-report.md +160 -0
  50. package/development/projects/proj_mkh4k84n_ni73k/phase1/feasibility-report.md +160 -0
  51. package/development/projects/proj_mkh4wfyd_u9w88/phase1/feasibility-report.md +160 -0
  52. package/development/projects/proj_mkh4wsbo_iahvf/development/projects/proj_mkh4xbpg_4na5w/phase1/feasibility-report.md +160 -0
  53. package/development/projects/proj_mkh4wsbo_iahvf/phase1/feasibility-report.md +160 -0
  54. package/development/projects/proj_mkh4xulg_1ka8x/phase1/feasibility-report.md +160 -0
  55. package/development/projects/proj_mkh4xwhj_gch8j/phase1/feasibility-report.md +160 -0
  56. package/development/projects/proj_mkh4y2qk_9lm8z/phase1/feasibility-report.md +160 -0
  57. package/development/projects/proj_mkh4y2qk_9lm8z/phase2/requirements.md +226 -0
  58. package/development/projects/proj_mkh4y2qk_9lm8z/phase3/PRD.md +345 -0
  59. package/development/projects/proj_mkh4y2qk_9lm8z/phase3/TASK_PLAN.md +284 -0
  60. package/development/projects/proj_mkh4y2qk_9lm8z/phase3/prototype/README.md +14 -0
  61. package/development/projects/proj_mkh4y2qk_9lm8z/phase4/DEVELOPMENT_LOG.md +35 -0
  62. package/development/projects/proj_mkh4y2qk_9lm8z/phase4/TASKS.md +34 -0
  63. package/development/projects/proj_mkh4y2qk_9lm8z/phase4/source/.env.example +5 -0
  64. package/development/projects/proj_mkh4y2qk_9lm8z/phase4/source/README.md +60 -0
  65. package/development/projects/proj_mkh4y2qk_9lm8z/phase4/source/package.json +25 -0
  66. package/development/projects/proj_mkh4y2qk_9lm8z/phase4/source/src/index.js +70 -0
  67. package/development/projects/proj_mkh4y2qk_9lm8z/phase4/source/src/routes/index.js +48 -0
  68. package/development/projects/proj_mkh4y2qk_9lm8z/phase4/source/tests/health.test.js +20 -0
  69. package/development/projects/proj_mkh4y2qk_9lm8z/phase4/source/tests/jest.config.js +21 -0
  70. package/development/projects/proj_mkh7veqg_3lypc/phase1/feasibility-report.md +160 -0
  71. package/development/projects/proj_mkh7veqg_3lypc/phase2/requirements.md +226 -0
  72. package/development/projects/proj_mkh7veqg_3lypc/phase3/PRD.md +345 -0
  73. package/development/projects/proj_mkh7veqg_3lypc/phase3/TASK_PLAN.md +284 -0
  74. package/development/projects/proj_mkh7veqg_3lypc/phase3/prototype/README.md +14 -0
  75. package/development/projects/proj_mkh8k8fo_rmqn5/phase1/feasibility-report.md +160 -0
  76. package/development/projects/proj_mkh8xyhy_1vshq/phase1/feasibility-report.md +178 -0
  77. package/development/projects/proj_mkh8zddd_dhamf/phase1/feasibility-report.md +377 -0
  78. package/development/projects/proj_mkh8zddd_dhamf/phase2/requirements.md +442 -0
  79. package/development/projects/proj_mkh8zddd_dhamf/phase3/api-design.md +800 -0
  80. package/development/projects/proj_mkh8zddd_dhamf/phase3/architecture.md +625 -0
  81. package/development/projects/proj_mkh8zddd_dhamf/phase3/data-model.md +830 -0
  82. package/development/projects/proj_mkh8zddd_dhamf/phase3/risks.md +957 -0
  83. package/development/projects/proj_mkh8zddd_dhamf/phase3/wbs.md +381 -0
  84. package/development/todos/.state.json +14 -1
  85. package/development/todos/INDEX.md +31 -73
  86. package/development/todos/completed/develop/local-knowledge-index.md +85 -0
  87. package/development/todos/{active → completed/develop}/todo-system.md +13 -3
  88. package/development/todos/completed/develop/web-search-integration.md +83 -0
  89. package/development/todos/completed/test/phase1-e2e-test.md +103 -0
  90. package/lib/commands.js +388 -0
  91. package/package.json +3 -2
  92. package/tests/config-manager.test.js +677 -0
  93. package/tests/config-validator.test.js +436 -0
  94. package/tests/errors.test.js +477 -0
  95. package/tests/manual/phase1-e2e.sh +389 -0
  96. package/tests/manual/phase2-test-cases.md +311 -0
  97. package/tests/manual/phase3-test-cases.md +309 -0
  98. package/tests/manual/phase4-test-cases.md +414 -0
  99. package/tests/manual/test-cases.md +417 -0
  100. package/tests/quality-gate.test.js +679 -0
  101. package/tests/quality-rules.test.js +619 -0
  102. package/tests/version-check.test.js +75 -0
@@ -0,0 +1,800 @@
1
+ # API Design Document
2
+
3
+ **Project**: proj_mkh8zddd_dhamf (AI 代码审查工具)
4
+ **Date**: 1/17/2026
5
+ **Phase**: 3 - Planning
6
+ **Status**: In Progress
7
+
8
+ ---
9
+
10
+ ## Executive Summary
11
+
12
+ 本文档定义 AI 代码审查工具的 CLI 命令接口、配置文件格式和输出格式规范。
13
+
14
+ **设计原则**:
15
+ - **简洁**: 最少的命令完成常用任务
16
+ - **直观**: 默认行为符合用户预期
17
+ - **可配置**: 支持项目级和全局配置
18
+ - **可扩展**: 易于添加新命令和选项
19
+
20
+ ---
21
+
22
+ ## 1. CLI Command Design
23
+
24
+ ### 1.1 Command Overview
25
+
26
+ ```
27
+ smc-review <command> [options] [arguments]
28
+
29
+ Commands:
30
+ scan Scan code for issues
31
+ init Initialize configuration in current directory
32
+ config Manage configuration
33
+ report Generate reports from scan results
34
+ version Show version information
35
+ help Show help information
36
+
37
+ Global Options:
38
+ -c, --config <file> Use specific config file
39
+ -v, --verbose Enable verbose output
40
+ -q, --quiet Suppress non-error output
41
+ --no-color Disable colored output
42
+ ```
43
+
44
+ ### 1.2 Command Details
45
+
46
+ #### 1.2.1 scan
47
+
48
+ 扫描代码库中的问题。
49
+
50
+ ```
51
+ Usage: smc-review scan [options] [path]
52
+
53
+ Arguments:
54
+ path Path to scan (default: current directory)
55
+ Can be a file, directory, or glob pattern
56
+
57
+ Options:
58
+ -o, --output <format> Output format: table, json, markdown, sarif (default: table)
59
+ -r, --recursive Scan subdirectories recursively (default: true)
60
+ --rules <rules> Comma-separated list of rules to run (default: all)
61
+ --exclude <patterns> Comma-separated glob patterns to exclude
62
+ --severity <level> Minimum severity: critical, high, medium, low (default: low)
63
+ --diff Only scan changed files (git diff)
64
+ --cached Use cached AST results when available
65
+ --ai Enable AI-enhanced analysis (requires API key)
66
+ --no-ai Disable AI analysis even if configured
67
+ --timeout <seconds> Maximum scan time (default: 300)
68
+ -j, --jobs <n> Number of parallel jobs (default: CPU count)
69
+ --output-file <file> Write output to file instead of stdout
70
+
71
+ Examples:
72
+ smc-review scan ./src
73
+ smc-review scan --diff --severity high
74
+ smc-review scan --output json --output-file results.json
75
+ smc-review scan --exclude "node_modules/**/*.js,dist/**"
76
+ ```
77
+
78
+ #### 1.2.2 init
79
+
80
+ 初始化项目配置。
81
+
82
+ ```
83
+ Usage: smc-review init [options]
84
+
85
+ Options:
86
+ -f, --force Overwrite existing config file
87
+ --template <name> Use preset template: default, strict, relaxed
88
+ --interactive Interactive mode with prompts
89
+
90
+ Examples:
91
+ smc-review init
92
+ smc-review init --template strict
93
+ smc-review init --force
94
+ ```
95
+
96
+ #### 1.2.3 config
97
+
98
+ 管理配置。
99
+
100
+ ```
101
+ Usage: smc-review config <subcommand> [options]
102
+
103
+ Subcommands:
104
+ get <key> Get configuration value
105
+ set <key> <value> Set configuration value
106
+ list List all configuration
107
+ validate Validate current configuration
108
+ reset Reset to default configuration
109
+
110
+ Options:
111
+ --global Operate on global config (~/.config/smc-review/)
112
+ --project Operate on project config (.code-review.yml)
113
+
114
+ Examples:
115
+ smc-review config list
116
+ smc-review config set scan.severity high
117
+ smc-review config get rules.enabled
118
+ smc-review config validate --project
119
+ ```
120
+
121
+ #### 1.2.4 report
122
+
123
+ 从扫描结果生成报告。
124
+
125
+ ```
126
+ Usage: smc-review report [options]
127
+
128
+ Options:
129
+ -i, --input <file> Input scan results file (JSON format)
130
+ -o, --output <file> Output report file
131
+ -f, --format <fmt> Report format: markdown, html, pdf, json
132
+ -t, --template <tpl> Custom report template
133
+ --trend Generate trend report (requires history)
134
+
135
+ Examples:
136
+ smc-review report -i scan-results.json -o report.md
137
+ smc-review report --input results.json --format html --output report.html
138
+ smc-review report --trend --days 30
139
+ ```
140
+
141
+ #### 1.2.5 version
142
+
143
+ 显示版本信息。
144
+
145
+ ```
146
+ Usage: smc-review version
147
+
148
+ Output:
149
+ smc-review v1.0.0
150
+ Build: 2026-01-17
151
+ Tree-sitter: v0.20.0
152
+ Supported languages: Python, JavaScript, TypeScript
153
+ ```
154
+
155
+ ### 1.3 Exit Codes
156
+
157
+ | Code | Meaning |
158
+ |------|---------|
159
+ | 0 | Success, no issues found |
160
+ | 1 | Issues found (severity at or above threshold) |
161
+ | 2 | Error occurred (invalid args, file not found, etc.) |
162
+ | 3 | Configuration error |
163
+ | 4 | Scan timeout |
164
+ | 5 | LLM API error |
165
+
166
+ ---
167
+
168
+ ## 2. Configuration File Format
169
+
170
+ ### 2.1 File Location
171
+
172
+ 配置文件按优先级从高到低:
173
+
174
+ 1. `--config` 指定的文件
175
+ 2. 当前目录的 `.code-review.yml`
176
+ 3. 项目根目录的 `.code-review.yml`
177
+ 4. `~/.config/smc-review/config.yml`
178
+
179
+ ### 2.2 Configuration Schema
180
+
181
+ ```yaml
182
+ # .code-review.yml
183
+ version: "1.0"
184
+
185
+ # Scan configuration
186
+ scan:
187
+ # Paths to include (glob patterns)
188
+ include:
189
+ - "**/*.py"
190
+ - "**/*.js"
191
+ - "**/*.ts"
192
+ - "**/*.jsx"
193
+ - "**/*.tsx"
194
+
195
+ # Paths to exclude (glob patterns)
196
+ exclude:
197
+ - "node_modules/**"
198
+ - "dist/**"
199
+ - "build/**"
200
+ - "vendor/**"
201
+ - "**/*.min.js"
202
+ - "**/*.test.js"
203
+ - "**/*.spec.js"
204
+
205
+ # Minimum severity to report
206
+ min_severity: low # critical, high, medium, low
207
+
208
+ # Recursive scan
209
+ recursive: true
210
+
211
+ # Parallel jobs
212
+ jobs: 4
213
+
214
+ # Cache settings
215
+ cache:
216
+ enabled: true
217
+ ttl: 86400 # 24 hours in seconds
218
+
219
+ # Rules configuration
220
+ rules:
221
+ # Enable/disable rule categories
222
+ categories:
223
+ security:
224
+ enabled: true
225
+ severity: high
226
+ quality:
227
+ enabled: true
228
+ severity: medium
229
+ performance:
230
+ enabled: false
231
+
232
+ # Specific rule settings
233
+ specific:
234
+ - id: sql-injection
235
+ enabled: true
236
+ severity: critical
237
+ languages: [python, javascript]
238
+
239
+ - id: xss
240
+ enabled: true
241
+ severity: high
242
+ languages: [javascript, typescript]
243
+
244
+ - id: long-function
245
+ enabled: true
246
+ severity: low
247
+ params:
248
+ max_lines: 50
249
+
250
+ - id: high-complexity
251
+ enabled: true
252
+ severity: medium
253
+ params:
254
+ max_complexity: 10
255
+
256
+ # Custom rules (inline definition)
257
+ custom: []
258
+
259
+ # AI Configuration (optional)
260
+ ai:
261
+ enabled: false
262
+ provider: anthropic # anthropic, openai, local
263
+ model: claude-3-5-sonnet-20241022
264
+
265
+ # API settings
266
+ api:
267
+ endpoint: https://api.anthropic.com/v1/messages
268
+ timeout: 30
269
+ max_retries: 3
270
+
271
+ # Prompt settings
272
+ prompt:
273
+ temperature: 0.3
274
+ max_tokens: 1000
275
+
276
+ # Cost control
277
+ cost_control:
278
+ max_requests_per_scan: 10
279
+ max_tokens_per_scan: 10000
280
+
281
+ # Output configuration
282
+ output:
283
+ # Default format
284
+ format: table # table, json, markdown, sarif
285
+
286
+ # Colored output
287
+ color: auto # auto, always, never
288
+
289
+ # Show code snippets in output
290
+ show_snippets: true
291
+
292
+ # Snippet context lines
293
+ context_lines: 3
294
+
295
+ # Ignore patterns (similar to .gitignore)
296
+ ignore:
297
+ # Specific files
298
+ files:
299
+ - "**/__pycache__/**"
300
+ - "**/pyvenv/**"
301
+ - "**/.venv/**"
302
+
303
+ # Specific issues (by ID or pattern)
304
+ issues:
305
+ - id: long-function
306
+ files: ["**/test_*.py", "**/*_test.py"]
307
+ reason: "Test functions can be longer"
308
+ - id: no-docstring
309
+ files: ["**/migrations/**"]
310
+
311
+ # Integration settings
312
+ integrations:
313
+ github:
314
+ enabled: false
315
+ # Auto-comment on PRs
316
+ pr_comment: true
317
+ # Fail checks on issues
318
+ fail_on_severity: high
319
+
320
+ # Report configuration
321
+ reports:
322
+ # History tracking
323
+ history:
324
+ enabled: true
325
+ retention_days: 90
326
+
327
+ # Trend analysis
328
+ trends:
329
+ enabled: true
330
+ comparison_period: 7 # days
331
+ ```
332
+
333
+ ### 2.3 Configuration Templates
334
+
335
+ #### 2.3.1 Default Template
336
+
337
+ ```yaml
338
+ # Balanced configuration for general use
339
+ scan:
340
+ min_severity: medium
341
+ rules:
342
+ categories:
343
+ security:
344
+ enabled: true
345
+ quality:
346
+ enabled: true
347
+ ai:
348
+ enabled: false
349
+ ```
350
+
351
+ #### 2.3.2 Strict Template
352
+
353
+ ```yaml
354
+ # Strict configuration for security-critical projects
355
+ scan:
356
+ min_severity: low
357
+ rules:
358
+ categories:
359
+ security:
360
+ enabled: true
361
+ severity: critical
362
+ quality:
363
+ enabled: true
364
+ severity: low
365
+ ai:
366
+ enabled: true
367
+ cost_control:
368
+ max_requests_per_scan: 50
369
+ integrations:
370
+ github:
371
+ fail_on_severity: medium
372
+ ```
373
+
374
+ #### 2.3.3 Relaxed Template
375
+
376
+ ```yaml
377
+ # Relaxed configuration for learning/prototyping
378
+ scan:
379
+ min_severity: high
380
+ rules:
381
+ categories:
382
+ security:
383
+ enabled: true
384
+ quality:
385
+ enabled: false
386
+ ai:
387
+ enabled: false
388
+ ignore:
389
+ issues:
390
+ - id: long-function
391
+ reason: "Not enforced in relaxed mode"
392
+ ```
393
+
394
+ ### 2.4 Environment Variables
395
+
396
+ | Variable | Description | Default |
397
+ |----------|-------------|---------|
398
+ | `SMC_REVIEW_CONFIG` | Path to config file | - |
399
+ | `SMC_REVIEW_API_KEY` | LLM API key | - |
400
+ | `SMC_REVIEW_CACHE_DIR` | Cache directory | `~/.cache/smc-review` |
401
+ | `SMC_REVIEW_LOG_LEVEL` | Log level | `info` |
402
+ | `SMC_REVIEW_NO_COLOR` | Disable colors | `false` |
403
+ | `SMC_REVIEW_JOBS` | Default parallel jobs | CPU count |
404
+
405
+ ---
406
+
407
+ ## 3. Output Formats
408
+
409
+ ### 3.1 Table Format (Default)
410
+
411
+ ```
412
+ Code Review Results
413
+
414
+ Summary
415
+ -------
416
+ Files scanned: 47
417
+ Issues found: 12
418
+ Critical: 2
419
+ High: 4
420
+ Medium: 4
421
+ Low: 2
422
+
423
+ Issues
424
+ ------
425
+
426
+ CRITICAL src/auth/login.py:45
427
+ SQL Injection: User input directly concatenated into SQL query
428
+ def authenticate(username, password):
429
+ query = f"SELECT * FROM users WHERE username='{username}'"
430
+ ^^^^^^^^^^^^^^^^^^^^^^^^
431
+
432
+ HIGH src/services/payment.js:23
433
+ XSS Vulnerability: User input rendered without sanitization
434
+ function renderComment(comment) {
435
+ return `<div>${comment.text}</div>`;
436
+ ^^^^^^^^^^^
437
+
438
+ MEDIUM src/utils/helpers.py:89
439
+ Long Function: Function exceeds 50 lines (67 lines)
440
+ def process_data(data, options, config):
441
+ ...
442
+
443
+ LOW src/api/routes.py:156
444
+ Missing Docstring: Public function lacks documentation
445
+ def calculate_total(items):
446
+
447
+ Scan completed in 3.2s
448
+ ```
449
+
450
+ ### 3.2 JSON Format
451
+
452
+ ```json
453
+ {
454
+ "version": "1.0.0",
455
+ "scan_id": "scan_20260117_123456",
456
+ "timestamp": "2026-01-17T12:34:56Z",
457
+ "summary": {
458
+ "files_scanned": 47,
459
+ "total_issues": 12,
460
+ "by_severity": {
461
+ "critical": 2,
462
+ "high": 4,
463
+ "medium": 4,
464
+ "low": 2
465
+ },
466
+ "by_category": {
467
+ "security": 6,
468
+ "quality": 4,
469
+ "performance": 2
470
+ }
471
+ },
472
+ "issues": [
473
+ {
474
+ "id": "issue_001",
475
+ "rule_id": "sql-injection",
476
+ "severity": "critical",
477
+ "category": "security",
478
+ "title": "SQL Injection",
479
+ "description": "User input directly concatenated into SQL query",
480
+ "file": "src/auth/login.py",
481
+ "line": 45,
482
+ "column": 12,
483
+ "end_line": 45,
484
+ "end_column": 50,
485
+ "code_snippet": "query = f\"SELECT * FROM users WHERE username='{username}'\"",
486
+ "suggestion": "Use parameterized queries instead",
487
+ "suggested_code": "cursor.execute(\"SELECT * FROM users WHERE username=%s\", (username,))",
488
+ "references": [
489
+ "https://owasp.org/www-community/attacks/SQL_Injection"
490
+ ],
491
+ "confidence": "high",
492
+ "ai_enhanced": false
493
+ }
494
+ ],
495
+ "performance": {
496
+ "duration_seconds": 3.2,
497
+ "files_per_second": 14.7
498
+ }
499
+ }
500
+ ```
501
+
502
+ ### 3.3 Markdown Format
503
+
504
+ ```markdown
505
+ # Code Review Report
506
+
507
+ **Generated**: 2026-01-17 12:34:56 UTC
508
+ **Scan ID**: `scan_20260117_123456`
509
+
510
+ ## Summary
511
+
512
+ | Metric | Value |
513
+ |--------|-------|
514
+ | Files Scanned | 47 |
515
+ | Total Issues | 12 |
516
+ | Critical | 2 |
517
+ | High | 4 |
518
+ | Medium | 4 |
519
+ | Low | 2 |
520
+
521
+ ## Critical Issues
522
+
523
+ ### SQL Injection in `src/auth/login.py:45`
524
+
525
+ **Severity**: Critical
526
+ **Category**: Security
527
+
528
+ User input directly concatenated into SQL query.
529
+
530
+ ```python
531
+ def authenticate(username, password):
532
+ query = f"SELECT * FROM users WHERE username='{username}'"
533
+ cursor.execute(query)
534
+ ```
535
+
536
+ **Suggestion**:
537
+ Use parameterized queries to prevent SQL injection.
538
+
539
+ ```python
540
+ def authenticate(username, password):
541
+ query = "SELECT * FROM users WHERE username=%s"
542
+ cursor.execute(query, (username,))
543
+ ```
544
+
545
+ **References**:
546
+ - [OWASP SQL Injection](https://owasp.org/www-community/attacks/SQL_Injection)
547
+
548
+ ---
549
+
550
+ ## High Issues
551
+
552
+ ### XSS Vulnerability in `src/services/payment.js:23`
553
+
554
+ ...
555
+
556
+ ---
557
+
558
+ ## Performance
559
+
560
+ | Metric | Value |
561
+ |--------|-------|
562
+ | Scan Duration | 3.2s |
563
+ | Files/Second | 14.7 |
564
+
565
+ ---
566
+
567
+ *Generated by smc-review v1.0.0*
568
+ ```
569
+
570
+ ### 3.4 SARIF Format
571
+
572
+ ```json
573
+ {
574
+ "version": "2.1.0",
575
+ "$schema": "https://json.schemastore.org/sarif-2.1.0.json",
576
+ "runs": [
577
+ {
578
+ "tool": {
579
+ "driver": {
580
+ "name": "smc-review",
581
+ "version": "1.0.0",
582
+ "informationUri": "https://github.com/smc-review/smc-review"
583
+ }
584
+ },
585
+ "results": [
586
+ {
587
+ "ruleId": "sql-injection",
588
+ "level": "error",
589
+ "message": {
590
+ "text": "User input directly concatenated into SQL query"
591
+ },
592
+ "locations": [
593
+ {
594
+ "physicalLocation": {
595
+ "artifactLocation": {
596
+ "uri": "src/auth/login.py"
597
+ },
598
+ "region": {
599
+ "startLine": 45,
600
+ "startColumn": 12,
601
+ "endLine": 45,
602
+ "endColumn": 50
603
+ }
604
+ }
605
+ }
606
+ ]
607
+ }
608
+ ]
609
+ }
610
+ ]
611
+ }
612
+ ```
613
+
614
+ ---
615
+
616
+ ## 4. GitHub Actions Integration
617
+
618
+ ### 4.1 Action Configuration
619
+
620
+ ```yaml
621
+ # .github/workflows/code-review.yml
622
+ name: Code Review
623
+
624
+ on:
625
+ pull_request:
626
+ types: [opened, synchronize, reopened]
627
+ push:
628
+ branches: [main, develop]
629
+
630
+ permissions:
631
+ contents: read
632
+ pull-requests: write
633
+
634
+ jobs:
635
+ code-review:
636
+ runs-on: ubuntu-latest
637
+ steps:
638
+ - name: Checkout code
639
+ uses: actions/checkout@v4
640
+ with:
641
+ fetch-depth: 0
642
+
643
+ - name: Install smc-review
644
+ run: |
645
+ curl -L https://github.com/smc-review/smc-review/releases/latest/download/smc-review-linux-amd64.tar.gz | tar xz
646
+ sudo mv smc-review /usr/local/bin/
647
+ smc-review version
648
+
649
+ - name: Run code review
650
+ id: review
651
+ env:
652
+ SMC_REVIEW_API_KEY: ${{ secrets.SMC_REVIEW_API_KEY }}
653
+ run: |
654
+ smc-review scan --diff --output json --output-file results.json
655
+
656
+ - name: Post PR comment
657
+ if: github.event_name == 'pull_request'
658
+ uses: actions/github-script@v7
659
+ with:
660
+ script: |
661
+ const fs = require('fs');
662
+ const results = JSON.parse(fs.readFileSync('results.json', 'utf8'));
663
+ const body = formatResults(results);
664
+ github.rest.issues.createComment({
665
+ issue_number: context.issue.number,
666
+ owner: context.repo.owner,
667
+ repo: context.repo.repo,
668
+ body: body
669
+ });
670
+
671
+ - name: Upload results
672
+ uses: actions/upload-artifact@v4
673
+ with:
674
+ name: code-review-results
675
+ path: results.json
676
+ ```
677
+
678
+ ### 4.2 Action Inputs
679
+
680
+ | Input | Description | Required | Default |
681
+ |-------|-------------|----------|---------|
682
+ | `path` | Path to scan | No | `.` |
683
+ | `format` | Output format | No | `table` |
684
+ | `severity` | Minimum severity | No | `low` |
685
+ | `ai-enabled` | Enable AI analysis | No | `false` |
686
+ | `config-file` | Custom config file | No | `.code-review.yml` |
687
+
688
+ ### 4.3 Action Outputs
689
+
690
+ | Output | Description |
691
+ |--------|-------------|
692
+ | `results-file` | Path to results JSON |
693
+ | `issue-count` | Number of issues found |
694
+ | `critical-count` | Number of critical issues |
695
+ | `high-count` | Number of high issues |
696
+
697
+ ---
698
+
699
+ ## 5. Error Messages
700
+
701
+ ### 5.1 Error Format
702
+
703
+ ```
704
+ Error: <error message>
705
+ Details: <additional context>
706
+ Hint: <suggested action>
707
+ ```
708
+
709
+ ### 5.2 Common Errors
710
+
711
+ | Error | Message | Hint |
712
+ |-------|---------|------|
713
+ | `E001` | Configuration file not found | Run `smc-review init` to create a config file |
714
+ | `E002` | Invalid configuration | Run `smc-review config validate` for details |
715
+ | `E003` | No files to scan | Check include/exclude patterns |
716
+ | `E004` | Parse error in file | Fix syntax errors or exclude the file |
717
+ | `E005` | LLM API timeout | Increase timeout with `--ai-timeout` or disable AI |
718
+ | `E006` | Cache write failed | Check disk space or disable cache |
719
+ | `E007` | Rule compilation failed | Check rule syntax in config file |
720
+
721
+ ---
722
+
723
+ ## 6. API Reference (Internal)
724
+
725
+ ### 6.1 Go Package Structure
726
+
727
+ ```go
728
+ // Package cli provides the command-line interface
729
+ package cli
730
+
731
+ // Scanner performs code scanning
732
+ type Scanner struct {
733
+ config *config.Config
734
+ parser parser.Parser
735
+ rules *ruleengine.Engine
736
+ llm llm.Client
737
+ }
738
+
739
+ // ScanResult contains the results of a scan
740
+ type ScanResult struct {
741
+ ScanID string
742
+ Timestamp time.Time
743
+ Summary Summary
744
+ Issues []Issue
745
+ Performance Performance
746
+ }
747
+
748
+ // ScanOptions configures the scan operation
749
+ type ScanOptions struct {
750
+ Path string
751
+ Output Format
752
+ Severity Severity
753
+ Diff bool
754
+ AI bool
755
+ Jobs int
756
+ Timeout time.Duration
757
+ }
758
+ ```
759
+
760
+ ### 6.2 CLI Handler Signatures
761
+
762
+ ```go
763
+ // Command handlers
764
+ func NewRootCmd() *cobra.Command
765
+ func NewScanCmd() *cobra.Command
766
+ func NewInitCmd() *cobra.Command
767
+ func NewConfigCmd() *cobra.Command
768
+ func NewReportCmd() *cobra.Command
769
+ func NewVersionCmd() *cobra.Command
770
+
771
+ // Scan runner
772
+ func RunScan(opts ScanOptions) (*ScanResult, error)
773
+
774
+ // Configuration
775
+ func LoadConfig(path string) (*config.Config, error)
776
+ func ValidateConfig(cfg *config.Config) error
777
+ ```
778
+
779
+ ---
780
+
781
+ ## 7. Next Steps
782
+
783
+ 1. Review CLI command design with stakeholders
784
+ 2. Prototype table output format
785
+ 3. Implement configuration loader
786
+ 4. Create GitHub Action marketplace entry
787
+ 5. Proceed to data model design (data-model.md)
788
+
789
+ ---
790
+
791
+ ## Metadata
792
+
793
+ - **Created**: 1/17/2026
794
+ - **Author**: Phase 3 Design Executor
795
+ - **Status**: Draft for Review
796
+ - **Related Docs**: phase3/architecture.md
797
+
798
+ ---
799
+
800
+ *This API design document defines the external interfaces of the AI Code Review Tool.*