sumulige-claude 1.5.1 → 1.5.2
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/.claude/hooks/hook-registry.json +0 -15
- package/.claude/rules/coding-style.md +18 -7
- package/.claude/rules/hooks.md +15 -4
- package/.claude/rules/performance.md +15 -5
- package/.claude/rules/security.md +140 -4
- package/.claude/rules/testing.md +138 -9
- package/.claude/rules/web-design-standard.md +16 -5
- package/.claude/skills/algorithmic-art/metadata.yaml +28 -0
- package/.claude/skills/api-tester/SKILL.md +61 -0
- package/.claude/skills/api-tester/examples/basic.md +3 -0
- package/.claude/skills/api-tester/metadata.yaml +30 -0
- package/.claude/skills/api-tester/templates/default.md +3 -0
- package/.claude/skills/brand-guidelines/metadata.yaml +26 -0
- package/.claude/skills/canvas-design/metadata.yaml +27 -0
- package/.claude/skills/code-reviewer-123/SKILL.md +61 -0
- package/.claude/skills/code-reviewer-123/examples/basic.md +3 -0
- package/.claude/skills/code-reviewer-123/metadata.yaml +30 -0
- package/.claude/skills/code-reviewer-123/templates/default.md +3 -0
- package/.claude/skills/doc-coauthoring/metadata.yaml +27 -0
- package/.claude/skills/docx/metadata.yaml +30 -0
- package/.claude/skills/frontend-design/metadata.yaml +28 -0
- package/.claude/skills/internal-comms/metadata.yaml +28 -0
- package/.claude/skills/mcp-builder/metadata.yaml +26 -0
- package/.claude/skills/my-skill/SKILL.md +61 -0
- package/.claude/skills/my-skill/examples/basic.md +3 -0
- package/.claude/skills/my-skill/metadata.yaml +30 -0
- package/.claude/skills/my-skill/templates/default.md +3 -0
- package/.claude/skills/pdf/metadata.yaml +29 -0
- package/.claude/skills/pptx/metadata.yaml +29 -0
- package/.claude/skills/react-best-practices/metadata.yaml +26 -0
- package/.claude/skills/react-node-practices/SKILL.md +409 -0
- package/.claude/skills/react-node-practices/metadata.yaml +56 -0
- package/.claude/skills/skill-creator/metadata.yaml +25 -0
- package/.claude/skills/slack-gif-creator/metadata.yaml +28 -0
- package/.claude/skills/test-skill-name/SKILL.md +61 -0
- package/.claude/skills/test-skill-name/examples/basic.md +3 -0
- package/.claude/skills/test-skill-name/metadata.yaml +30 -0
- package/.claude/skills/test-skill-name/templates/default.md +3 -0
- package/.claude/skills/test-workflow/metadata.yaml +32 -0
- package/.claude/skills/theme-factory/metadata.yaml +26 -0
- package/.claude/skills/threejs-fundamentals/metadata.yaml +27 -0
- package/.claude/skills/web-artifacts-builder/metadata.yaml +30 -0
- package/.claude/skills/web-design-guidelines/metadata.yaml +26 -0
- package/.claude/skills/webapp-testing/metadata.yaml +26 -0
- package/.claude/skills/xlsx/metadata.yaml +29 -0
- package/LICENSE +21 -0
- package/cli.js +1 -1
- package/package.json +25 -3
- package/.claude/.kickoff-hint.txt +0 -52
- package/.claude/.sumulige-claude-version +0 -1
- package/.claude/.version +0 -1
- package/.claude/AGENTS.md +0 -42
- package/.claude/ANCHORS.md +0 -40
- package/.claude/CLAUDE.md +0 -138
- package/.claude/MEMORY.md +0 -69
- package/.claude/PROJECT_LOG.md +0 -101
- package/.claude/THINKING_CHAIN_GUIDE.md +0 -287
- package/.claude/USAGE.md +0 -175
- package/.claude/boris-optimizations.md +0 -167
- package/.claude/handoffs/INDEX.md +0 -21
- package/.claude/handoffs/LATEST.md +0 -76
- package/.claude/handoffs/handoff_2026-01-22T13-07-04-757Z.md +0 -76
- package/.claude/quality-gate.json +0 -82
- package/.claude/rag/skill-index.json +0 -135
- package/.claude/settings.json +0 -99
- package/.claude/settings.local.json +0 -175
- package/.claude/templates/PROJECT_KICKOFF.md +0 -89
- package/.claude/templates/PROJECT_PROPOSAL.md +0 -227
- package/.claude/templates/TASK_PLAN.md +0 -121
- package/.claude/templates/hooks/README.md +0 -302
- package/.claude/templates/hooks/hook.sh.template +0 -94
- package/.claude/templates/hooks/user-prompt-submit.cjs.template +0 -116
- package/.claude/templates/hooks/user-response-submit.cjs.template +0 -94
- package/.claude/templates/hooks/validate.js +0 -173
- package/.claude/templates/tasks/develop.md +0 -69
- package/.claude/templates/tasks/research.md +0 -64
- package/.claude/templates/tasks/test.md +0 -96
- package/.claude/thinking-routes/.last-sync +0 -1
- package/.claude/thinking-routes/QUICKREF.md +0 -98
- package/.claude/workflow/document-scanner.js +0 -426
- package/.claude/workflow/knowledge-engine.js +0 -941
- package/.claude/workflow/notebooklm/browser.js +0 -1028
- package/.claude/workflow/phases/phase1-research.js +0 -578
- package/.claude/workflow/phases/phase1-research.ts +0 -465
- package/.claude/workflow/phases/phase2-approve.js +0 -722
- package/.claude/workflow/phases/phase3-plan.js +0 -1200
- package/.claude/workflow/phases/phase4-develop.js +0 -894
- package/.claude/workflow/search-cache.js +0 -230
- package/.claude/workflow/templates/approval.md +0 -315
- package/.claude/workflow/templates/development.md +0 -377
- package/.claude/workflow/templates/planning.md +0 -328
- package/.claude/workflow/templates/research.md +0 -250
- package/.claude/workflow/types.js +0 -37
- package/.claude/workflow/web-search.js +0 -278
- package/.claude-plugin/marketplace.json +0 -71
- package/.github/workflows/sync-skills.yml +0 -74
- package/.versionrc +0 -25
- package/AGENTS.md +0 -580
- package/CHANGELOG.md +0 -481
- package/CLAUDE-template.md +0 -114
- package/DEV_TOOLS_GUIDE.md +0 -190
- package/PROJECT_STRUCTURE.md +0 -266
- package/Q&A.md +0 -325
- package/config/defaults.json +0 -34
- package/config/official-skills.json +0 -183
- package/config/quality-gate.json +0 -67
- package/config/skill-categories.json +0 -40
- package/config/version-manifest.json +0 -85
- package/demos/power-3d-scatter.html +0 -683
- package/development/cache/web-search/search_1193d605f8eb364651fc2f2041b58a31.json +0 -36
- package/development/cache/web-search/search_3798bf06960edc125f744a1abb5b72c5.json +0 -36
- package/development/cache/web-search/search_37c7d4843a53f0d83f1122a6f908a2a3.json +0 -36
- package/development/cache/web-search/search_44166fa0153709ee168485a22aa0ab40.json +0 -36
- package/development/cache/web-search/search_4deaebb1f77e86a8ca066dc5a49c59fd.json +0 -36
- package/development/cache/web-search/search_94da91789466070a7f545612e73c7372.json +0 -36
- package/development/cache/web-search/search_dd5de8491b8b803a3cb01339cd210fb0.json +0 -36
- package/development/knowledge-base/.index.clean.json +0 -1
- package/development/knowledge-base/.index.json +0 -486
- package/development/knowledge-base/test-best-practices.md +0 -29
- package/development/projects/proj_mkh1pazz_ixmt1/phase1/feasibility-report.md +0 -160
- package/development/projects/proj_mkh4jvnb_z7rwf/phase1/feasibility-report.md +0 -160
- package/development/projects/proj_mkh4jxkd_ewz5a/phase1/feasibility-report.md +0 -160
- package/development/projects/proj_mkh4k84n_ni73k/phase1/feasibility-report.md +0 -160
- package/development/projects/proj_mkh4wfyd_u9w88/phase1/feasibility-report.md +0 -160
- package/development/projects/proj_mkh4wsbo_iahvf/development/projects/proj_mkh4xbpg_4na5w/phase1/feasibility-report.md +0 -160
- package/development/projects/proj_mkh4wsbo_iahvf/phase1/feasibility-report.md +0 -160
- package/development/projects/proj_mkh4xulg_1ka8x/phase1/feasibility-report.md +0 -160
- package/development/projects/proj_mkh4xwhj_gch8j/phase1/feasibility-report.md +0 -160
- package/development/projects/proj_mkh4y2qk_9lm8z/phase1/feasibility-report.md +0 -160
- package/development/projects/proj_mkh4y2qk_9lm8z/phase2/requirements.md +0 -226
- package/development/projects/proj_mkh4y2qk_9lm8z/phase3/PRD.md +0 -345
- package/development/projects/proj_mkh4y2qk_9lm8z/phase3/TASK_PLAN.md +0 -284
- package/development/projects/proj_mkh4y2qk_9lm8z/phase3/prototype/README.md +0 -14
- package/development/projects/proj_mkh4y2qk_9lm8z/phase4/DEVELOPMENT_LOG.md +0 -35
- package/development/projects/proj_mkh4y2qk_9lm8z/phase4/TASKS.md +0 -34
- package/development/projects/proj_mkh4y2qk_9lm8z/phase4/source/.env.example +0 -5
- package/development/projects/proj_mkh4y2qk_9lm8z/phase4/source/README.md +0 -60
- package/development/projects/proj_mkh4y2qk_9lm8z/phase4/source/package.json +0 -25
- package/development/projects/proj_mkh4y2qk_9lm8z/phase4/source/src/index.js +0 -70
- package/development/projects/proj_mkh4y2qk_9lm8z/phase4/source/src/routes/index.js +0 -48
- package/development/projects/proj_mkh4y2qk_9lm8z/phase4/source/tests/health.test.js +0 -20
- package/development/projects/proj_mkh4y2qk_9lm8z/phase4/source/tests/jest.config.js +0 -21
- package/development/projects/proj_mkh7veqg_3lypc/phase1/feasibility-report.md +0 -160
- package/development/projects/proj_mkh7veqg_3lypc/phase2/requirements.md +0 -226
- package/development/projects/proj_mkh7veqg_3lypc/phase3/PRD.md +0 -345
- package/development/projects/proj_mkh7veqg_3lypc/phase3/TASK_PLAN.md +0 -284
- package/development/projects/proj_mkh7veqg_3lypc/phase3/prototype/README.md +0 -14
- package/development/projects/proj_mkh8k8fo_rmqn5/phase1/feasibility-report.md +0 -160
- package/development/projects/proj_mkh8xyhy_1vshq/phase1/feasibility-report.md +0 -178
- package/development/projects/proj_mkh8zddd_dhamf/phase1/feasibility-report.md +0 -377
- package/development/projects/proj_mkh8zddd_dhamf/phase2/requirements.md +0 -442
- package/development/projects/proj_mkh8zddd_dhamf/phase3/api-design.md +0 -800
- package/development/projects/proj_mkh8zddd_dhamf/phase3/architecture.md +0 -625
- package/development/projects/proj_mkh8zddd_dhamf/phase3/data-model.md +0 -830
- package/development/projects/proj_mkh8zddd_dhamf/phase3/risks.md +0 -957
- package/development/projects/proj_mkh8zddd_dhamf/phase3/wbs.md +0 -381
- package/development/todos/.state.json +0 -19
- package/development/todos/INDEX.md +0 -63
- package/development/todos/active/_README.md +0 -49
- package/development/todos/archived/_README.md +0 -11
- package/development/todos/backlog/_README.md +0 -11
- package/development/todos/backlog/mcp-integration.md +0 -35
- package/development/todos/completed/_README.md +0 -11
- package/development/todos/completed/boris-optimizations.md +0 -39
- package/development/todos/completed/develop/local-knowledge-index.md +0 -85
- package/development/todos/completed/develop/todo-system.md +0 -47
- package/development/todos/completed/develop/web-search-integration.md +0 -83
- package/development/todos/completed/test/phase1-e2e-test.md +0 -103
- package/docs/DEVELOPMENT.md +0 -461
- package/docs/MARKETPLACE.md +0 -352
- package/docs/RELEASE.md +0 -93
- package/jest.config.js +0 -63
- package/lib/commands.js +0 -3588
- package/lib/config-manager.js +0 -441
- package/lib/config-schema.js +0 -408
- package/lib/config-validator.js +0 -330
- package/lib/config.js +0 -122
- package/lib/errors.js +0 -305
- package/lib/incremental-sync.js +0 -274
- package/lib/marketplace.js +0 -487
- package/lib/migrations.js +0 -154
- package/lib/permission-audit.js +0 -255
- package/lib/quality-gate.js +0 -431
- package/lib/quality-rules.js +0 -373
- package/lib/utils.js +0 -150
- package/lib/version-check.js +0 -169
- package/lib/version-manifest.js +0 -171
- package/project-paradigm.md +0 -313
- package/prompts/how-to-find.md +0 -163
- package/prompts/linus-architect.md +0 -71
- package/prompts/software-architect.md +0 -173
- package/prompts/web-designer.md +0 -249
- package/scripts/fix-hooks.mjs +0 -97
- package/scripts/sync-external.mjs +0 -298
- package/scripts/sync-to-home.sh +0 -108
- package/scripts/update-registry.mjs +0 -325
- package/sources.yaml +0 -83
- package/tests/README.md +0 -263
- package/tests/commands.test.js +0 -1086
- package/tests/config-manager.test.js +0 -677
- package/tests/config-schema.test.js +0 -425
- package/tests/config-validator.test.js +0 -436
- package/tests/config.test.js +0 -100
- package/tests/errors.test.js +0 -477
- package/tests/manual/phase1-e2e.sh +0 -389
- package/tests/manual/phase2-test-cases.md +0 -311
- package/tests/manual/phase3-test-cases.md +0 -309
- package/tests/manual/phase4-test-cases.md +0 -414
- package/tests/manual/test-cases.md +0 -417
- package/tests/marketplace.test.js +0 -420
- package/tests/migrations.test.js +0 -187
- package/tests/quality-gate.test.js +0 -679
- package/tests/quality-rules.test.js +0 -619
- package/tests/sync-external.test.js +0 -214
- package/tests/update-registry.test.js +0 -251
- package/tests/utils.test.js +0 -171
- package/tests/version-check.test.js +0 -75
- package/tests/web-search.test.js +0 -392
- package/thinkinglens-silent.md +0 -138
|
@@ -1,625 +0,0 @@
|
|
|
1
|
-
# Architecture 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 代码审查工具的系统架构设计,基于 Phase 1 可行性分析和 Phase 2 需求文档。
|
|
13
|
-
|
|
14
|
-
**核心架构原则**:
|
|
15
|
-
- **模块化**: 每个组件职责单一,易于测试和维护
|
|
16
|
-
- **可扩展**: 支持新增语言、规则和集成点
|
|
17
|
-
- **高性能**: 增量扫描、缓存机制、并行处理
|
|
18
|
-
- **隐私优先**: 本地模式不发送代码到外部 API
|
|
19
|
-
|
|
20
|
-
---
|
|
21
|
-
|
|
22
|
-
## 1. System Overview
|
|
23
|
-
|
|
24
|
-
### 1.1 High-Level Architecture
|
|
25
|
-
|
|
26
|
-
```
|
|
27
|
-
┌─────────────────────────────────────────────────────────────────────────────┐
|
|
28
|
-
│ USER LAYER │
|
|
29
|
-
│ ┌─────────────────┐ ┌─────────────────┐ ┌─────────────────┐ │
|
|
30
|
-
│ │ CLI Tool │ │ CI/CD Plugin │ │ IDE Plugin │ │
|
|
31
|
-
│ │ (smc-review) │ │ (GitHub Action)│ │ (Future) │ │
|
|
32
|
-
│ └────────┬────────┘ └────────┬────────┘ └────────┬────────┘ │
|
|
33
|
-
│ │ │ │ │
|
|
34
|
-
└───────────┼────────────────────┼────────────────────┼──────────────────────┘
|
|
35
|
-
│ │ │
|
|
36
|
-
▼ ▼ ▼
|
|
37
|
-
┌─────────────────────────────────────────────────────────────────────────────┐
|
|
38
|
-
│ API GATEWAY (Go) │
|
|
39
|
-
│ ┌──────────────────────────────────────────────────────────────────────┐ │
|
|
40
|
-
│ │ Request Router │ Auth Handler │ Rate Limiter │ Task Queue │ │
|
|
41
|
-
│ └──────────────────────────────────────────────────────────────────────┘ │
|
|
42
|
-
└─────────────────────────────────────┬───────────────────────────────────────┘
|
|
43
|
-
│
|
|
44
|
-
┌─────────────────────────┼─────────────────────────┐
|
|
45
|
-
│ │ │
|
|
46
|
-
▼ ▼ ▼
|
|
47
|
-
┌───────────────────┐ ┌───────────────────┐ ┌───────────────────────┐
|
|
48
|
-
│ Parser Service │ │ Rule Engine │ │ LLM Service │
|
|
49
|
-
│ │ │ │ │ (Optional) │
|
|
50
|
-
│ ┌───────────────┐ │ │ ┌───────────────┐ │ │ ┌─────────────────┐ │
|
|
51
|
-
│ │ Tree-sitter │ │ │ │ Security Rules│ │ │ │ Claude 3.5 API │ │
|
|
52
|
-
│ │ Python │ │ │ │ Code Smell │ │ │ │ Local Llama │ │
|
|
53
|
-
│ │ JavaScript │ │ │ │ Custom Rules │ │ │ │ Fallback │ │
|
|
54
|
-
│ └───────────────┘ │ │ └───────────────┘ │ │ └─────────────────┘ │
|
|
55
|
-
└─────────┬─────────┘ └─────────┬─────────┘ └───────────┬───────────┘
|
|
56
|
-
│ │ │
|
|
57
|
-
└───────────────────────┼─────────────────────────┘
|
|
58
|
-
▼
|
|
59
|
-
┌─────────────────────────────┐
|
|
60
|
-
│ Report Aggregator │
|
|
61
|
-
│ ┌─────────────────────────┐ │
|
|
62
|
-
│ │ Issue Deduplication │ │
|
|
63
|
-
│ │ Severity Calculation │ │
|
|
64
|
-
│ │ Output Formatting │ │
|
|
65
|
-
│ └─────────────────────────┘ │
|
|
66
|
-
└──────────────┬──────────────┘
|
|
67
|
-
▼
|
|
68
|
-
┌─────────────────────────────────────────────────────────────────────────────┐
|
|
69
|
-
│ DATA LAYER │
|
|
70
|
-
│ ┌─────────────────┐ ┌─────────────────┐ ┌─────────────────┐ │
|
|
71
|
-
│ │ PostgreSQL │ │ Redis │ │ File System │ │
|
|
72
|
-
│ │ │ │ │ │ │ │
|
|
73
|
-
│ │ - Scan Results │ │ - AST Cache │ │ - Config Files │ │
|
|
74
|
-
│ │ - Rules │ │ - Rule Cache │ │ - Reports │ │
|
|
75
|
-
│ │ - History │ │ - Session Data │ │ - Temp Files │ │
|
|
76
|
-
│ └─────────────────┘ └─────────────────┘ └─────────────────┘ │
|
|
77
|
-
└─────────────────────────────────────────────────────────────────────────────┘
|
|
78
|
-
```
|
|
79
|
-
|
|
80
|
-
### 1.2 Component Overview
|
|
81
|
-
|
|
82
|
-
| Component | Language | Responsibility | Lines (Est.) |
|
|
83
|
-
|-----------|----------|----------------|--------------|
|
|
84
|
-
| **CLI Tool** | Go | 命令行接口、配置加载 | ~2,000 |
|
|
85
|
-
| **Parser Service** | Go | AST 解析、代码遍历 | ~1,500 |
|
|
86
|
-
| **Rule Engine** | Go | 规则匹配、问题检测 | ~2,500 |
|
|
87
|
-
| **LLM Service** | Go | AI API 调用、结果解析 | ~1,000 |
|
|
88
|
-
| **Report Generator** | Go | 报告生成、输出格式化 | ~1,200 |
|
|
89
|
-
| **Database Layer** | Go | 数据持久化、查询 | ~800 |
|
|
90
|
-
| **CI/CD Integration** | YAML/Go | GitHub Action 配置 | ~500 |
|
|
91
|
-
| **Total** | | | ~9,500 |
|
|
92
|
-
|
|
93
|
-
---
|
|
94
|
-
|
|
95
|
-
## 2. Module Design
|
|
96
|
-
|
|
97
|
-
### 2.1 Module Structure
|
|
98
|
-
|
|
99
|
-
```
|
|
100
|
-
smc-review/
|
|
101
|
-
├── cmd/
|
|
102
|
-
│ └── smc-review/
|
|
103
|
-
│ └── main.go # CLI 入口
|
|
104
|
-
├── internal/
|
|
105
|
-
│ ├── cli/
|
|
106
|
-
│ │ ├── cmd.go # Cobra 命令定义
|
|
107
|
-
│ │ ├── scan.go # scan 命令实现
|
|
108
|
-
│ │ ├── init.go # init 命令实现
|
|
109
|
-
│ │ ├── config.go # config 命令实现
|
|
110
|
-
│ │ └── report.go # report 命令实现
|
|
111
|
-
│ ├── parser/
|
|
112
|
-
│ │ ├── parser.go # Parser 接口
|
|
113
|
-
│ │ ├── tree_sitter.go # Tree-sitter 实现
|
|
114
|
-
│ │ ├── python.go # Python 解析器
|
|
115
|
-
│ │ ├── javascript.go # JavaScript 解析器
|
|
116
|
-
│ │ └── ast.go # AST 数据结构
|
|
117
|
-
│ ├── ruleengine/
|
|
118
|
-
│ │ ├── engine.go # 规则引擎核心
|
|
119
|
-
│ │ ├── rule.go # 规则接口
|
|
120
|
-
│ │ ├── security_rules.go # 安全规则集
|
|
121
|
-
│ │ ├── quality_rules.go # 质量规则集
|
|
122
|
-
│ │ └── custom_rules.go # 自定义规则加载
|
|
123
|
-
│ ├── llm/
|
|
124
|
-
│ │ ├── client.go # LLM 客户端接口
|
|
125
|
-
│ │ ├── claude.go # Claude API 实现
|
|
126
|
-
│ │ ├── local.go # 本地模型实现
|
|
127
|
-
│ │ └── prompt.go # Prompt 模板
|
|
128
|
-
│ ├── report/
|
|
129
|
-
│ │ ├── generator.go # 报告生成器
|
|
130
|
-
│ │ ├── formatter.go # 输出格式化
|
|
131
|
-
│ │ └── template.go # 报告模板
|
|
132
|
-
│ ├── db/
|
|
133
|
-
│ │ ├── database.go # 数据库接口
|
|
134
|
-
│ │ ├── postgres.go # PostgreSQL 实现
|
|
135
|
-
│ │ ├── migrations.go # 数据库迁移
|
|
136
|
-
│ │ └── models.go # 数据模型
|
|
137
|
-
│ ├── cache/
|
|
138
|
-
│ │ ├── cache.go # 缓存接口
|
|
139
|
-
│ │ └── redis.go # Redis 实现
|
|
140
|
-
│ └── config/
|
|
141
|
-
│ ├── config.go # 配置结构
|
|
142
|
-
│ ├── loader.go # 配置加载
|
|
143
|
-
│ └── validator.go # 配置验证
|
|
144
|
-
├── pkg/
|
|
145
|
-
│ ├── types/
|
|
146
|
-
│ │ ├── issue.go # Issue 类型
|
|
147
|
-
│ │ ├── scan_result.go # ScanResult 类型
|
|
148
|
-
│ │ └── report.go # Report 类型
|
|
149
|
-
│ └── utils/
|
|
150
|
-
│ ├── fileutil.go # 文件工具
|
|
151
|
-
│ └── gitutil.go # Git 工具
|
|
152
|
-
├── .github/
|
|
153
|
-
│ └── workflows/
|
|
154
|
-
│ └── code-review.yml # GitHub Action
|
|
155
|
-
└── go.mod
|
|
156
|
-
```
|
|
157
|
-
|
|
158
|
-
### 2.2 Module Dependencies
|
|
159
|
-
|
|
160
|
-
```
|
|
161
|
-
┌─────────────┐
|
|
162
|
-
│ CLI │
|
|
163
|
-
└──────┬──────┘
|
|
164
|
-
│
|
|
165
|
-
┌───────────────┼───────────────┐
|
|
166
|
-
│ │ │
|
|
167
|
-
▼ ▼ ▼
|
|
168
|
-
┌─────────────┐ ┌─────────────┐ ┌─────────────┐
|
|
169
|
-
│ Config │ │ Parser │ │ Cache │
|
|
170
|
-
└──────┬──────┘ └──────┬──────┘ └─────────────┘
|
|
171
|
-
│ │
|
|
172
|
-
└───────┬───────┘
|
|
173
|
-
│
|
|
174
|
-
┌───────────┼───────────┐
|
|
175
|
-
│ │ │
|
|
176
|
-
▼ ▼ ▼
|
|
177
|
-
┌───────────┐ ┌───────────┐ ┌───────────┐
|
|
178
|
-
│ Rule │ │ LLM │ │ DB │
|
|
179
|
-
│ Engine │ │ Service │ │ │
|
|
180
|
-
└─────┬─────┘ └─────┬─────┘ └───────────┘
|
|
181
|
-
│ │
|
|
182
|
-
└──────┬──────┘
|
|
183
|
-
▼
|
|
184
|
-
┌─────────────┐
|
|
185
|
-
│ Report │
|
|
186
|
-
│ Generator │
|
|
187
|
-
└─────────────┘
|
|
188
|
-
```
|
|
189
|
-
|
|
190
|
-
---
|
|
191
|
-
|
|
192
|
-
## 3. Data Flow
|
|
193
|
-
|
|
194
|
-
### 3.1 Scan Flow
|
|
195
|
-
|
|
196
|
-
```
|
|
197
|
-
┌─────────────────────────────────────────────────────────────────────────────┐
|
|
198
|
-
│ SCAN FLOW │
|
|
199
|
-
└─────────────────────────────────────────────────────────────────────────────┘
|
|
200
|
-
|
|
201
|
-
User CLI Parser Rule Engine
|
|
202
|
-
│ │ │ │
|
|
203
|
-
│ smc-review scan │ │ │
|
|
204
|
-
├──────────────────────>│ │ │
|
|
205
|
-
│ │ │ │
|
|
206
|
-
│ │ Load config │ │
|
|
207
|
-
│ ├───────────────────────────────────────────────>│
|
|
208
|
-
│ │ │ │
|
|
209
|
-
│ │ Get changed files │ │
|
|
210
|
-
│ │ (git diff) │ │
|
|
211
|
-
│ ├──────────>│ │ │
|
|
212
|
-
│ │ │ │ │
|
|
213
|
-
│ │ │ Parse │ │
|
|
214
|
-
│ │ │ files │ │
|
|
215
|
-
│ │ ├──────────────────────────────────>│
|
|
216
|
-
│ │ │ │ │
|
|
217
|
-
│ │ │ AST │ │
|
|
218
|
-
│ │ │<─────────┘ │
|
|
219
|
-
│ │ │ │ │
|
|
220
|
-
│ │ │ │ Run rules │
|
|
221
|
-
│ │ │ ├──────────>│ │
|
|
222
|
-
│ │ │ │ │ │
|
|
223
|
-
│ │ │ │ Issues │ │
|
|
224
|
-
│ │ │ │<──────────┘ │
|
|
225
|
-
│ │ │ │ │
|
|
226
|
-
│ │ │ │ [Optional] LLM │
|
|
227
|
-
│ │ │ ├───────────────────────>│
|
|
228
|
-
│ │ │ │ │
|
|
229
|
-
│ │ │ │ Enhanced issues │
|
|
230
|
-
│ │ │ │<───────────────────────┤
|
|
231
|
-
│ │ │ │ │
|
|
232
|
-
│ │ │ │ Generate report │
|
|
233
|
-
│ │ │ ├───────────────────────>│
|
|
234
|
-
│ │ │ │ │
|
|
235
|
-
│ │ │ │ Report │
|
|
236
|
-
│ │ │ │<───────────────────────┤
|
|
237
|
-
│ │ │ │ │
|
|
238
|
-
│ │ Output report │ │
|
|
239
|
-
│ ├───────────────────────────────────────────────>│
|
|
240
|
-
│ │ │ │
|
|
241
|
-
│ Report output │ │ │
|
|
242
|
-
│<──────────────────────┘ │ │
|
|
243
|
-
│ │ │ │
|
|
244
|
-
```
|
|
245
|
-
|
|
246
|
-
### 3.2 CI/CD Integration Flow
|
|
247
|
-
|
|
248
|
-
```
|
|
249
|
-
┌─────────────────────────────────────────────────────────────────────────────┐
|
|
250
|
-
│ CI/CD INTEGRATION FLOW │
|
|
251
|
-
└─────────────────────────────────────────────────────────────────────────────┘
|
|
252
|
-
|
|
253
|
-
GitHub smc-review GitHub API
|
|
254
|
-
Action REST API
|
|
255
|
-
│ │
|
|
256
|
-
│ PR created │
|
|
257
|
-
│<────────────────────────────────────────────────────────┤
|
|
258
|
-
│ │
|
|
259
|
-
│ Trigger workflow │
|
|
260
|
-
├────────────────────────────────────────────────────────>│
|
|
261
|
-
│ │
|
|
262
|
-
│ Download smc-review │
|
|
263
|
-
│<────────────────────────────────────────────────────────┤
|
|
264
|
-
│ │
|
|
265
|
-
│ Run scan │
|
|
266
|
-
├──────────────────────────────┐ │
|
|
267
|
-
│ │ │
|
|
268
|
-
│ │ Get PR diff │
|
|
269
|
-
│ ├──────────────────────────>│
|
|
270
|
-
│ │ │
|
|
271
|
-
│ │ Changed files │
|
|
272
|
-
│ │<──────────────────────────┤
|
|
273
|
-
│ │ │
|
|
274
|
-
│ │ Scan files │
|
|
275
|
-
│ ├──────────┐ │
|
|
276
|
-
│ │ │ │
|
|
277
|
-
│ │ Results │ │
|
|
278
|
-
│ │<─────────┘ │
|
|
279
|
-
│ │ │
|
|
280
|
-
│ │ Post comment │
|
|
281
|
-
│ ├──────────────────────────>│
|
|
282
|
-
│ │ │
|
|
283
|
-
│ Exit with status │ │
|
|
284
|
-
│<─────────────────────────────┘ │
|
|
285
|
-
│ │
|
|
286
|
-
```
|
|
287
|
-
|
|
288
|
-
---
|
|
289
|
-
|
|
290
|
-
## 4. Technology Stack
|
|
291
|
-
|
|
292
|
-
### 4.1 Confirmed Technologies
|
|
293
|
-
|
|
294
|
-
| Layer | Technology | Version | Justification |
|
|
295
|
-
|-------|-----------|---------|---------------|
|
|
296
|
-
| **Language** | Go | 1.21+ | 高性能、并发强、单二进制部署 |
|
|
297
|
-
| **AST Parser** | Tree-sitter | 0.20+ | 支持 40+ 语言,GitHub 同款 |
|
|
298
|
-
| **CLI Framework** | Cobra | 1.8+ | 标准 Go CLI 框架 |
|
|
299
|
-
| **Database** | PostgreSQL | 14+ | JSONB 支持,存储扫描结果 |
|
|
300
|
-
| **Cache** | Redis | 7+ | AST 结果缓存 |
|
|
301
|
-
| **LLM API** | Anthropic Claude | 3.5 Sonnet | 代码理解最佳 |
|
|
302
|
-
| **Local LLM** | Llama 3.1 | 8B | 离线场景,隐私要求 |
|
|
303
|
-
| **Testing** | testify | 1.8+ | Go 测试框架 |
|
|
304
|
-
|
|
305
|
-
### 4.2 Go Dependencies
|
|
306
|
-
|
|
307
|
-
```go
|
|
308
|
-
module github.com/smc-review/smc-review
|
|
309
|
-
|
|
310
|
-
go 1.21
|
|
311
|
-
|
|
312
|
-
require (
|
|
313
|
-
github.com/spf13/cobra v1.8.0
|
|
314
|
-
github.com/tree-sitter/go-tree-sitter v0.20.0
|
|
315
|
-
github.com/lib/pq v1.10.9
|
|
316
|
-
github.com/redis/go-redis/v9 v9.3.0
|
|
317
|
-
github.com/anthropics/anthropic-go/v3 v3.0.0
|
|
318
|
-
github.com/spf13/viper v1.17.0
|
|
319
|
-
github.com/stretchr/testify v1.8.4
|
|
320
|
-
gopkg.in/yaml.v3 v3.0.1
|
|
321
|
-
)
|
|
322
|
-
```
|
|
323
|
-
|
|
324
|
-
---
|
|
325
|
-
|
|
326
|
-
## 5. Architecture Decision Records (ADR)
|
|
327
|
-
|
|
328
|
-
### ADR-001: Go as Primary Language
|
|
329
|
-
|
|
330
|
-
**Status**: Accepted
|
|
331
|
-
|
|
332
|
-
**Context**: 需要选择一种高性能、易于部署的语言作为主要开发语言。
|
|
333
|
-
|
|
334
|
-
**Decision**: 使用 Go 1.21+ 作为主要开发语言。
|
|
335
|
-
|
|
336
|
-
**Consequences**:
|
|
337
|
-
|
|
338
|
-
*Positive*:
|
|
339
|
-
- 高性能编译型语言,适合 I/O 密集型任务
|
|
340
|
-
- 内置并发支持 (goroutines)
|
|
341
|
-
- 单二进制部署,无运行时依赖
|
|
342
|
-
- 丰富的生态系统
|
|
343
|
-
|
|
344
|
-
*Negative*:
|
|
345
|
-
- 泛型支持较新 (Go 1.18+)
|
|
346
|
-
- 错误处理较为冗长
|
|
347
|
-
|
|
348
|
-
**Alternatives Considered**:
|
|
349
|
-
- Rust: 性能更优,但学习曲线陡峭
|
|
350
|
-
- Python: 开发速度快,但性能较差
|
|
351
|
-
- Node.js: 生态丰富,但单线程模型不适合此场景
|
|
352
|
-
|
|
353
|
-
---
|
|
354
|
-
|
|
355
|
-
### ADR-002: Tree-sitter for AST Parsing
|
|
356
|
-
|
|
357
|
-
**Status**: Accepted
|
|
358
|
-
|
|
359
|
-
**Context**: 需要一个多语言代码解析方案。
|
|
360
|
-
|
|
361
|
-
**Decision**: 使用 Tree-sitter 作为 AST 解析引擎。
|
|
362
|
-
|
|
363
|
-
**Consequences**:
|
|
364
|
-
|
|
365
|
-
*Positive*:
|
|
366
|
-
- 支持 40+ 编程语言
|
|
367
|
-
- 增量解析,错误恢复能力强
|
|
368
|
-
- GitHub 同款,社区活跃
|
|
369
|
-
- Go 绑定可用
|
|
370
|
-
|
|
371
|
-
*Negative*:
|
|
372
|
-
- 每种语言需要单独的语法文件
|
|
373
|
-
- AST 结构因语言而异
|
|
374
|
-
|
|
375
|
-
**Alternatives Considered**:
|
|
376
|
-
- ANTLR: 需要为每种语言编写语法
|
|
377
|
-
- Language Server Protocol: 过于重量级
|
|
378
|
-
- 正则表达式: 不可靠,无法处理复杂语法
|
|
379
|
-
|
|
380
|
-
---
|
|
381
|
-
|
|
382
|
-
### ADR-003: PostgreSQL for Data Persistence
|
|
383
|
-
|
|
384
|
-
**Status**: Accepted
|
|
385
|
-
|
|
386
|
-
**Context**: 需要存储扫描结果、规则配置和历史数据。
|
|
387
|
-
|
|
388
|
-
**Decision**: 使用 PostgreSQL 14+ 作为主数据库。
|
|
389
|
-
|
|
390
|
-
**Consequences**:
|
|
391
|
-
|
|
392
|
-
*Positive*:
|
|
393
|
-
- JSONB 支持灵活的数据结构
|
|
394
|
-
- ACID 保证数据一致性
|
|
395
|
-
- 丰富的查询能力
|
|
396
|
-
- 成熟的备份/恢复方案
|
|
397
|
-
|
|
398
|
-
*Negative*:
|
|
399
|
-
- 需要额外部署组件
|
|
400
|
-
- 小型项目可能过重
|
|
401
|
-
|
|
402
|
-
**Alternatives Considered**:
|
|
403
|
-
- SQLite: 轻量,但不支持并发写入
|
|
404
|
-
- MongoDB: Schema-free,但查询能力较弱
|
|
405
|
-
- 纯文件存储: 简单,但不支持复杂查询
|
|
406
|
-
|
|
407
|
-
---
|
|
408
|
-
|
|
409
|
-
### ADR-004: Optional LLM Enhancement
|
|
410
|
-
|
|
411
|
-
**Status**: Accepted
|
|
412
|
-
|
|
413
|
-
**Context**: AI 增强分析是差异化功能,但不应成为阻塞点。
|
|
414
|
-
|
|
415
|
-
**Decision**: LLM 服务作为可选模块,规则引擎优先。
|
|
416
|
-
|
|
417
|
-
**Consequences**:
|
|
418
|
-
|
|
419
|
-
*Positive*:
|
|
420
|
-
- 无 LLM 也能完成基础扫描
|
|
421
|
-
- 降低依赖风险
|
|
422
|
-
- 逐步验证 AI 价值
|
|
423
|
-
|
|
424
|
-
*Negative*:
|
|
425
|
-
- 需要维护两套分析逻辑
|
|
426
|
-
- 可能影响用户对 AI 功能的发现
|
|
427
|
-
|
|
428
|
-
**Alternatives Considered**:
|
|
429
|
-
- 仅 LLM: 过于依赖外部服务
|
|
430
|
-
- 本地模型优先: 硬件要求高
|
|
431
|
-
|
|
432
|
-
---
|
|
433
|
-
|
|
434
|
-
### ADR-005: GitHub First, GitLab Later
|
|
435
|
-
|
|
436
|
-
**Status**: Accepted
|
|
437
|
-
|
|
438
|
-
**Context**: 需要选择 CI/CD 集成优先级。
|
|
439
|
-
|
|
440
|
-
**Decision**: v1.0 优先支持 GitHub Actions,GitLab 延迟到 v1.1+。
|
|
441
|
-
|
|
442
|
-
**Consequences**:
|
|
443
|
-
|
|
444
|
-
*Positive*:
|
|
445
|
-
- 聚焦资源,快速交付
|
|
446
|
-
- GitHub 市场份额最大
|
|
447
|
-
- Action 配置相对简单
|
|
448
|
-
|
|
449
|
-
*Negative*:
|
|
450
|
-
- 限制初始用户群
|
|
451
|
-
- 后续需要适配 GitLab
|
|
452
|
-
|
|
453
|
-
**Alternatives Considered**:
|
|
454
|
-
- 同时支持: 增加复杂度
|
|
455
|
-
- 抽象集成层: 过早优化
|
|
456
|
-
|
|
457
|
-
---
|
|
458
|
-
|
|
459
|
-
## 6. Scalability Considerations
|
|
460
|
-
|
|
461
|
-
### 6.1 Performance Optimization
|
|
462
|
-
|
|
463
|
-
| 技术 | 应用场景 | 预期效果 |
|
|
464
|
-
|------|----------|----------|
|
|
465
|
-
| **增量扫描** | 只扫描 Git diff 变更文件 | 减少 80% 扫描时间 |
|
|
466
|
-
| **AST 缓存** | Redis 缓存解析结果 | 减少 50% 解析时间 |
|
|
467
|
-
| **并行处理** | goroutine 并行扫描文件 | 线性加速到 CPU 核心数 |
|
|
468
|
-
| **规则预编译** | 启动时编译规则 | 减少运行时开销 |
|
|
469
|
-
|
|
470
|
-
### 6.2 Scalability Targets
|
|
471
|
-
|
|
472
|
-
| 指标 | v1.0 目标 | v2.0 目标 |
|
|
473
|
-
|------|----------|----------|
|
|
474
|
-
| 代码库规模 | <100 万行 | <500 万行 |
|
|
475
|
-
| 并发扫描 | 单实例 | 分布式 |
|
|
476
|
-
| 存储容量 | 10GB | 100GB+ |
|
|
477
|
-
| 响应时间 | <5s/1000 行 | <10s/10000 行 |
|
|
478
|
-
|
|
479
|
-
---
|
|
480
|
-
|
|
481
|
-
## 7. Security Architecture
|
|
482
|
-
|
|
483
|
-
### 7.1 Threat Model
|
|
484
|
-
|
|
485
|
-
| 威胁 | 影响 | 缓解措施 |
|
|
486
|
-
|------|------|----------|
|
|
487
|
-
| 代码泄露到外部 | 高 | 本地模式默认,API 模式需显式启用 |
|
|
488
|
-
| LLM 注入攻击 | 中 | Prompt 模板化,不直接拼接用户输入 |
|
|
489
|
-
| 配置文件注入 | 低 | 配置验证,沙箱执行 |
|
|
490
|
-
| 依赖供应链攻击 | 中 | Go modules 验证,定期更新 |
|
|
491
|
-
|
|
492
|
-
### 7.2 Data Flow Privacy
|
|
493
|
-
|
|
494
|
-
```
|
|
495
|
-
┌─────────────────────────────────────────────────────────────────┐
|
|
496
|
-
│ PRIVACY MODES │
|
|
497
|
-
└─────────────────────────────────────────────────────────────────┘
|
|
498
|
-
|
|
499
|
-
LOCAL MODE (Default) API MODE (Optional)
|
|
500
|
-
┌───────────────────┐ ┌───────────────────┐
|
|
501
|
-
│ User Code │ │ User Code │
|
|
502
|
-
│ ↓ │ │ ↓ │
|
|
503
|
-
│ Parser + Rules │ │ Parser + Rules │
|
|
504
|
-
│ ↓ │ │ ↓ │
|
|
505
|
-
│ Local Report │ │ Anonymized Snip │
|
|
506
|
-
│ │ │ ↓ │
|
|
507
|
-
│ ✅ No external │ │ LLM API │
|
|
508
|
-
│ network call │ │ ↓ │
|
|
509
|
-
│ │ │ Enhanced Result │
|
|
510
|
-
└───────────────────┘ │ ↓ │
|
|
511
|
-
│ Local Report │
|
|
512
|
-
└───────────────────┘
|
|
513
|
-
```
|
|
514
|
-
|
|
515
|
-
---
|
|
516
|
-
|
|
517
|
-
## 8. Monitoring & Observability
|
|
518
|
-
|
|
519
|
-
### 8.1 Metrics to Track
|
|
520
|
-
|
|
521
|
-
| 类别 | 指标 | 目标 |
|
|
522
|
-
|------|------|------|
|
|
523
|
-
| **性能** | 扫描时间/1000 行 | <5s |
|
|
524
|
-
| | 内存占用 | <512MB |
|
|
525
|
-
| **质量** | 漏检率 | <5% |
|
|
526
|
-
| | 误报率 | <15% |
|
|
527
|
-
| **使用** | 日活用户 | >10 |
|
|
528
|
-
| | 平均扫描次数/用户 | >5 |
|
|
529
|
-
|
|
530
|
-
### 8.2 Logging Strategy
|
|
531
|
-
|
|
532
|
-
```go
|
|
533
|
-
// 结构化日志示例
|
|
534
|
-
log.WithFields(log.Fields{
|
|
535
|
-
"scan_id": scanID,
|
|
536
|
-
"file": filePath,
|
|
537
|
-
"language": "python",
|
|
538
|
-
"issues_found": len(issues),
|
|
539
|
-
"duration_ms": duration.Milliseconds(),
|
|
540
|
-
}).Info("File scan completed")
|
|
541
|
-
```
|
|
542
|
-
|
|
543
|
-
---
|
|
544
|
-
|
|
545
|
-
## 9. Deployment Architecture
|
|
546
|
-
|
|
547
|
-
### 9.1 Installation Methods
|
|
548
|
-
|
|
549
|
-
```
|
|
550
|
-
┌─────────────────────────────────────────────────────────────────┐
|
|
551
|
-
│ INSTALLATION OPTIONS │
|
|
552
|
-
└─────────────────────────────────────────────────────────────────┘
|
|
553
|
-
|
|
554
|
-
Method 1: Binary Download Method 2: Homebrew
|
|
555
|
-
┌─────────────────────┐ ┌─────────────────────┐
|
|
556
|
-
│ curl -L ... | tar │ │ brew install smc- │
|
|
557
|
-
│ │ │ review │
|
|
558
|
-
│ Single binary │ │ │
|
|
559
|
-
└─────────────────────┘ └─────────────────────┘
|
|
560
|
-
|
|
561
|
-
Method 3: Docker Method 4: Build from Source
|
|
562
|
-
┌─────────────────────┐ ┌─────────────────────┐
|
|
563
|
-
│ docker pull smc/ │ │ git clone ... │
|
|
564
|
-
│ review │ │ cd smc-review │
|
|
565
|
-
│ │ │ go build │
|
|
566
|
-
│ Self-contained │ │ │
|
|
567
|
-
└─────────────────────┘ └─────────────────────┘
|
|
568
|
-
```
|
|
569
|
-
|
|
570
|
-
### 9.2 Configuration Locations
|
|
571
|
-
|
|
572
|
-
| 平台 | 配置文件路径 |
|
|
573
|
-
|------|-------------|
|
|
574
|
-
| macOS/Linux | `~/.config/smc-review/config.yml` |
|
|
575
|
-
| Windows | `%APPDATA%\smc-review\config.yml` |
|
|
576
|
-
| 项目级 | `.code-review.yml` (Git 根目录) |
|
|
577
|
-
|
|
578
|
-
---
|
|
579
|
-
|
|
580
|
-
## 10. Quality Gates
|
|
581
|
-
|
|
582
|
-
### 10.1 Code Quality Standards
|
|
583
|
-
|
|
584
|
-
| 指标 | 阈值 | 工具 |
|
|
585
|
-
|------|------|------|
|
|
586
|
-
| 测试覆盖率 | >70% | go test -cover |
|
|
587
|
-
| 代码复杂度 | <15 (圈复杂度) | gocyclo |
|
|
588
|
-
| 代码重复 | <5% | dupl |
|
|
589
|
-
| 文档覆盖 | 100% (导出函数) | godoc |
|
|
590
|
-
|
|
591
|
-
### 10.2 Pre-commit Hooks
|
|
592
|
-
|
|
593
|
-
```bash
|
|
594
|
-
#!/bin/bash
|
|
595
|
-
# .git/hooks/pre-commit
|
|
596
|
-
|
|
597
|
-
go fmt ./...
|
|
598
|
-
go vet ./...
|
|
599
|
-
go test ./... -cover
|
|
600
|
-
golangci-lint run
|
|
601
|
-
```
|
|
602
|
-
|
|
603
|
-
---
|
|
604
|
-
|
|
605
|
-
## 11. Next Steps
|
|
606
|
-
|
|
607
|
-
1. Review architecture with stakeholders
|
|
608
|
-
2. Confirm technology stack decisions
|
|
609
|
-
3. Proceed to detailed API design (api-design.md)
|
|
610
|
-
4. Define data models (data-model.md)
|
|
611
|
-
5. Create work breakdown structure (wbs.md)
|
|
612
|
-
|
|
613
|
-
---
|
|
614
|
-
|
|
615
|
-
## Metadata
|
|
616
|
-
|
|
617
|
-
- **Created**: 1/17/2026
|
|
618
|
-
- **Author**: Phase 3 Design Executor
|
|
619
|
-
- **Reviewers**: Pending
|
|
620
|
-
- **Status**: Draft for Review
|
|
621
|
-
- **Related Docs**: phase2/requirements.md
|
|
622
|
-
|
|
623
|
-
---
|
|
624
|
-
|
|
625
|
-
*This architecture design document serves as the blueprint for the AI Code Review Tool implementation.*
|