@chongyan/autospec 1.0.1 → 1.0.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/LICENSE +21 -21
- package/README.en.md +447 -321
- package/README.md +418 -286
- package/knowledge/01-principles/00-principles-hierarchy.md +247 -0
- package/knowledge/01-principles/01-first-principles.md +241 -0
- package/knowledge/01-principles/02-strategic-principles.md +286 -0
- package/knowledge/01-principles/03-tactical-principles.md +385 -0
- package/knowledge/01-principles/04-operational-principles.md +275 -0
- package/knowledge/01-principles/05-domain-principles.md +539 -0
- package/knowledge/01-principles/06-methodology-principles.md +281 -0
- package/knowledge/01-principles/07-cognitive-principles.md +277 -0
- package/knowledge/01-principles/08-auto-fix-principles.md +320 -0
- package/knowledge/01-principles/09-constitution.md +220 -0
- package/knowledge/{principles/evolution.md → 01-principles/10-evolution-mechanism.md} +160 -14
- package/knowledge/01-principles/README.en.md +385 -0
- package/knowledge/01-principles/README.md +385 -0
- package/knowledge/{process/overview.md → 02-process/00-overview.md} +90 -5
- package/knowledge/02-process/README.en.md +143 -0
- package/knowledge/02-process/README.md +186 -0
- package/knowledge/{guides/support/pipeline-protocol.md → 03-guides/00-pipeline-protocol.md} +10 -10
- package/knowledge/{guides/support/team-orchestrator.md → 03-guides/01-team-orchestrator.md} +53 -8
- package/knowledge/{guides/stages/requirement-analyzer.md → 03-guides/02-analyze-requirement.md} +3 -3
- package/knowledge/{guides/stages/ai-effect-evaluator.md → 03-guides/08-evaluate-ai-effect.md} +14 -7
- package/knowledge/{guides/support/skill-distiller.md → 03-guides/19-distill-skill.md} +3 -3
- package/knowledge/{guides/support/skill-updater.md → 03-guides/20-update-skill.md} +1 -1
- package/knowledge/{guides/support/methodology-extractor.md → 03-guides/22-extract-methodology.md} +2 -2
- package/knowledge/{guides/support/complexity-assessor.md → 03-guides/24-assess-complexity.md} +6 -4
- package/knowledge/{guides/support/tech-stack-analyzer.md → 03-guides/26-analyze-tech-stack.md} +1 -1
- package/knowledge/{guides/domain-driven-design.md → 03-guides/42-apply-ddd.md} +1 -1
- package/knowledge/{process/ai-sdlc.md → 03-guides/43-run-ai-sdlc.md} +1 -1
- package/knowledge/{guides/knowledge-management.md → 03-guides/44-manage-knowledge.md} +4 -4
- package/knowledge/03-guides/README.en.md +212 -0
- package/knowledge/03-guides/README.md +212 -0
- package/knowledge/{checklists/requirement.md → 04-checklists/00-requirement.md} +1 -1
- package/knowledge/{checklists/design.md → 04-checklists/01-design.md} +1 -1
- package/knowledge/{checklists/code.md → 04-checklists/02-code.md} +16 -1
- package/knowledge/{checklists/release.md → 04-checklists/04-release.md} +1 -1
- package/knowledge/04-checklists/README.en.md +119 -0
- package/knowledge/04-checklists/README.md +123 -0
- package/knowledge/{config/validation-patterns.yaml → 05-config/00-validation-patterns.yaml} +1 -1
- package/knowledge/{config/team-tasks.yaml → 05-config/02-team-tasks.yaml} +2 -2
- package/knowledge/05-config/03-role-composition.yaml +346 -0
- package/knowledge/{config/skill-compositions.yaml → 05-config/05-skill-compositions.yaml} +24 -24
- package/knowledge/05-config/README.en.md +54 -0
- package/knowledge/05-config/README.md +132 -0
- package/knowledge/06-environment/00-template-registry.md +310 -0
- package/knowledge/06-environment/01-detection-patterns.yaml +1692 -0
- package/knowledge/{environment → 06-environment}/README.en.md +4 -0
- package/knowledge/{environment → 06-environment}/README.md +66 -25
- package/knowledge/{standards/coding-style.md → 07-standards/00-coding-style.md} +123 -4
- package/knowledge/{standards/code-review.md → 07-standards/01-code-review.md} +3 -3
- package/knowledge/{standards/data-consistency.md → 07-standards/02-data-consistency.md} +1 -1
- package/knowledge/{standards/document-versioning.md → 07-standards/03-document-versioning.md} +1 -1
- package/knowledge/{standards/risk-detection.md → 07-standards/04-risk-detection.md} +5 -5
- package/knowledge/07-standards/README.en.md +119 -0
- package/knowledge/07-standards/README.md +123 -0
- package/knowledge/08-organization/00-vision-mission.md +113 -0
- package/knowledge/{organization/ai-native-team.md → 08-organization/01-ai-native-culture.md} +1 -1
- package/knowledge/{organization/team-metrics.md → 08-organization/02-team-metrics.md} +1 -1
- package/knowledge/08-organization/03-committee-structure.md +54 -0
- package/knowledge/08-organization/04-governance-metrics.md +55 -0
- package/knowledge/08-organization/05-improvement-process.md +71 -0
- package/knowledge/08-organization/README.en.md +165 -0
- package/knowledge/08-organization/README.md +165 -0
- package/knowledge/09-templates/00-requirement-proposal.md +344 -0
- package/knowledge/09-templates/01-architecture-design.md +494 -0
- package/knowledge/09-templates/02-api-design.md +408 -0
- package/knowledge/09-templates/03-database-design.md +313 -0
- package/knowledge/09-templates/04-product-design.md +237 -0
- package/knowledge/09-templates/05-domain-business.md +388 -0
- package/knowledge/09-templates/06-test-design.md +268 -0
- package/knowledge/09-templates/07-evaluation-design.md +372 -0
- package/knowledge/09-templates/08-component-knowledge.md +272 -0
- package/knowledge/09-templates/09-best-practices.md +218 -0
- package/knowledge/{environment/middleware-knowledge.md → 09-templates/10-middleware-knowledge.md} +106 -1
- package/knowledge/09-templates/README.en.md +222 -0
- package/knowledge/09-templates/README.md +216 -0
- package/knowledge/README.en.md +372 -0
- package/knowledge/README.md +354 -99
- package/package.json +1 -1
- package/plugins/.claude-plugin/plugin.json +460 -81
- package/plugins/agents/roles/ceo.md +1 -1
- package/plugins/agents/roles/product-owner.md +1 -1
- package/plugins/agents/roles/tech-lead.md +1 -1
- package/plugins/agents/support/consistency-checker.md +36 -3
- package/plugins/agents/support/monitoring-agent.md +215 -0
- package/plugins/agents/support/safety-auditor.md +2 -2
- package/plugins/agents/support/stage-gate-evaluator.md +95 -11
- package/plugins/agents/support/test-coverage-reviewer.md +1 -1
- package/plugins/benchmarks/templates/README.md +165 -13
- package/plugins/benchmarks/templates/commands/apply-template.yaml +108 -0
- package/plugins/benchmarks/templates/commands/archive-template.yaml +65 -0
- package/plugins/benchmarks/templates/commands/env-export-template.yaml +64 -0
- package/plugins/benchmarks/templates/commands/env-sync-template.yaml +104 -0
- package/plugins/benchmarks/templates/commands/env-template-template.yaml +96 -0
- package/plugins/benchmarks/templates/commands/env-template.yaml +58 -0
- package/plugins/benchmarks/templates/commands/env-update-template.yaml +110 -0
- package/plugins/benchmarks/templates/commands/env-validate-template.yaml +95 -0
- package/plugins/benchmarks/templates/commands/field-evolve-template.yaml +104 -0
- package/plugins/benchmarks/templates/commands/project-evolve-template.yaml +104 -0
- package/plugins/benchmarks/templates/commands/propose-template.yaml +88 -0
- package/plugins/benchmarks/templates/commands/review-template.yaml +124 -0
- package/plugins/benchmarks/templates/commands/run-template.yaml +127 -0
- package/plugins/benchmarks/templates/commands/test-template.yaml +149 -0
- package/plugins/benchmarks/templates/pipeline/experiment-template.yaml +92 -0
- package/plugins/benchmarks/templates/pipeline/hotfix-template.yaml +81 -0
- package/plugins/benchmarks/templates/skills/agile-iteration-template.yaml +78 -0
- package/plugins/benchmarks/templates/skills/benchmark-executor-template.yaml +114 -0
- package/plugins/benchmarks/templates/skills/benchmark-generator-template.yaml +52 -0
- package/plugins/benchmarks/templates/skills/delivery-stage-template.yaml +130 -0
- package/plugins/benchmarks/templates/skills/design-stage-template.yaml +131 -0
- package/plugins/benchmarks/templates/skills/experiment-iteration-template.yaml +60 -0
- package/plugins/benchmarks/templates/skills/exploration-phase-template.yaml +114 -0
- package/plugins/benchmarks/templates/skills/field-evolve-analyzer-template.yaml +51 -0
- package/plugins/benchmarks/templates/skills/field-evolve-distiller-template.yaml +34 -0
- package/plugins/benchmarks/templates/skills/field-evolve-executor-template.yaml +50 -0
- package/plugins/benchmarks/templates/skills/field-evolve-fixer-template.yaml +52 -0
- package/plugins/benchmarks/templates/skills/field-evolve-learner-template.yaml +33 -0
- package/plugins/benchmarks/templates/skills/field-evolve-scanner-template.yaml +74 -0
- package/plugins/benchmarks/templates/skills/field-evolve-template.yaml +71 -0
- package/plugins/benchmarks/templates/skills/field-evolve-verifier-template.yaml +51 -0
- package/plugins/benchmarks/templates/skills/hotfix-iteration-template.yaml +54 -0
- package/plugins/benchmarks/templates/skills/implementation-stage-template.yaml +127 -0
- package/plugins/benchmarks/templates/skills/layer1-validation-template.yaml +121 -0
- package/plugins/benchmarks/templates/skills/project-evolve-analyzer-template.yaml +51 -0
- package/plugins/benchmarks/templates/skills/project-evolve-fixer-template.yaml +52 -0
- package/plugins/benchmarks/templates/skills/project-evolve-generator-template.yaml +34 -0
- package/plugins/benchmarks/templates/skills/project-evolve-learner-template.yaml +50 -0
- package/plugins/benchmarks/templates/skills/project-evolve-reviewer-template.yaml +50 -0
- package/plugins/benchmarks/templates/skills/project-evolve-scanner-template.yaml +75 -0
- package/plugins/benchmarks/templates/skills/project-evolve-template.yaml +72 -0
- package/plugins/benchmarks/templates/skills/project-evolve-verifier-template.yaml +51 -0
- package/plugins/benchmarks/templates/skills/skill-forge-template.yaml +117 -0
- package/plugins/benchmarks/templates/skills/startup-guard-template.yaml +103 -0
- package/plugins/benchmarks/templates/skills/testing-stage-template.yaml +146 -0
- package/plugins/benchmarks/templates/skills/waterfall-iteration-template.yaml +55 -0
- package/plugins/commands/README.en.md +2 -2
- package/plugins/commands/README.md +2 -2
- package/plugins/commands/apply.md +102 -16
- package/plugins/commands/archive.md +60 -4
- package/plugins/commands/env-sync.md +1047 -406
- package/plugins/commands/env-template.md +11 -135
- package/plugins/commands/env-update.md +1 -1
- package/plugins/commands/env-validate.md +3 -3
- package/plugins/commands/explore.md +118 -1
- package/plugins/commands/field-evolve.md +51 -175
- package/plugins/commands/project-evolve.md +167 -68
- package/plugins/commands/propose.md +97 -6
- package/plugins/commands/review.md +5 -5
- package/plugins/commands/run.md +841 -13
- package/plugins/commands/status.md +138 -17
- package/plugins/commands/test.md +389 -0
- package/plugins/hooks/constitution-guard.js +1 -1
- package/plugins/hooks/environment-autocommit.js +366 -24
- package/plugins/hooks/environment-manager.js +3 -2
- package/plugins/hooks/execution-tracker.js +109 -4
- package/plugins/hooks/layer1-validator.js +117 -1
- package/plugins/hooks/lib/auto-fix-loop.js +605 -0
- package/plugins/hooks/lib/environment-config-loader.js +11 -7
- package/plugins/hooks/lib/hook-state-manager.js +98 -0
- package/plugins/hooks/lib/memory-extractor.js +27 -5
- package/plugins/hooks/lib/memory-manager.js +1 -1
- package/plugins/hooks/lib/test-auto-fix.test.js +194 -0
- package/plugins/hooks/monitoring-trigger.js +467 -0
- package/plugins/skills/README.en.md +15 -3
- package/plugins/skills/README.md +21 -11
- package/plugins/skills/agile-iteration/SKILL.md +187 -0
- package/plugins/skills/delivery-stage/SKILL.md +133 -12
- package/plugins/skills/design-stage/SKILL.md +103 -12
- package/plugins/skills/experiment-evaluator/SKILL.md +271 -0
- package/plugins/skills/experiment-iteration/SKILL.md +154 -0
- package/plugins/skills/exploration-phase/SKILL.md +93 -10
- package/plugins/skills/field-evolve-analyzer/SKILL.md +65 -0
- package/plugins/skills/field-evolve-distiller/SKILL.md +66 -0
- package/plugins/skills/field-evolve-executor/SKILL.md +94 -0
- package/plugins/skills/field-evolve-executor/executor.js +342 -0
- package/plugins/skills/field-evolve-fixer/SKILL.md +69 -0
- package/plugins/skills/field-evolve-learner/SKILL.md +65 -0
- package/plugins/skills/field-evolve-scanner/SKILL.md +87 -0
- package/plugins/skills/field-evolve-scanner/scripts/fallback-scanner.js +288 -0
- package/plugins/skills/field-evolve-verifier/SKILL.md +64 -0
- package/plugins/skills/hotfix-iteration/SKILL.md +279 -0
- package/plugins/skills/implementation-stage/SKILL.md +156 -15
- package/plugins/skills/layer1-validation/SKILL.md +1 -1
- package/plugins/skills/pending-dashboard/SKILL.md +9 -8
- package/plugins/skills/project-evolve-analyzer/SKILL.md +95 -0
- package/plugins/skills/project-evolve-fixer/SKILL.md +99 -0
- package/plugins/skills/project-evolve-generator/SKILL.md +149 -0
- package/plugins/skills/project-evolve-learner/SKILL.md +103 -0
- package/plugins/skills/project-evolve-reviewer/SKILL.md +104 -0
- package/plugins/skills/project-evolve-scanner/SKILL.md +95 -0
- package/plugins/skills/project-evolve-scanner/scripts/dependency-reuse-checker.js +395 -0
- package/plugins/skills/project-evolve-scanner/scripts/subsystem-coverage.js +315 -0
- package/plugins/skills/project-evolve-verifier/SKILL.md +105 -0
- package/plugins/skills/requirement-stage/SKILL.md +47 -13
- package/plugins/skills/skill-forge/SKILL.md +2 -2
- package/plugins/skills/testing-stage/SKILL.md +583 -8
- package/plugins/skills/waterfall-iteration/SKILL.md +115 -0
- package/scripts/cli/index.js +1 -1
- package/scripts/cli/init.js +30 -4
- package/scripts/cli/list.js +3 -2
- package/scripts/config/commands.config.js +8 -8
- package/scripts/config/hooks.config.js +1 -1
- package/scripts/install/constants.js +204 -165
- package/scripts/state.js +210 -1
- package/knowledge/config/README.en.md +0 -44
- package/knowledge/config/README.md +0 -44
- package/knowledge/config/role-composition.yaml +0 -98
- package/knowledge/config/team-triggers.yaml +0 -198
- package/knowledge/domain/README.md +0 -115
- package/knowledge/domain/flows/README.md +0 -194
- package/knowledge/domain/glossary.md +0 -143
- package/knowledge/domain/rules.md +0 -138
- package/knowledge/environment/component-knowledge.md +0 -316
- package/knowledge/environment/detection-patterns.yaml +0 -502
- package/knowledge/environment/template-registry.md +0 -321
- package/knowledge/guides/requirement-engineering.md +0 -329
- package/knowledge/guides/system-design.md +0 -352
- package/knowledge/principles/constitution.md +0 -134
- package/knowledge/principles/core-principles.md +0 -368
- package/knowledge/principles/design-philosophy.md +0 -877
- package/knowledge/process/README.en.md +0 -38
- package/knowledge/process/README.md +0 -48
- package/knowledge/templates/ai-evaluation.md +0 -150
- package/knowledge/templates/api-design.md +0 -117
- package/knowledge/templates/database-design.md +0 -132
- package/knowledge/templates/domain-driven-design.md +0 -321
- package/knowledge/templates/product-proposal.md +0 -201
- package/knowledge/templates/system-design.md +0 -227
- package/knowledge/templates/task-breakdown.md +0 -107
- package/knowledge/templates/test-case.md +0 -170
- package/plugins/commands/validate.md +0 -108
- package/plugins/skills/benchmark-executor/README.md +0 -93
- package/plugins/skills/evolution-process/SKILL.md +0 -291
- package/plugins/skills/project-evolution/SKILL.md +0 -847
- package/scripts/evolution/evolution-router.js +0 -273
- package/scripts/evolution/evolution-signal-collector.js +0 -307
- package/scripts/evolution/knowledge-loader.js +0 -346
- package/scripts/evolution/marketplace.js +0 -317
- package/scripts/evolution/version-manager.js +0 -371
- /package/knowledge/{process → 02-process}/01-requirement.md +0 -0
- /package/knowledge/{process → 02-process}/02-design.md +0 -0
- /package/knowledge/{process → 02-process}/03-implementation.md +0 -0
- /package/knowledge/{process → 02-process}/04-review.md +0 -0
- /package/knowledge/{process → 02-process}/05-testing.md +0 -0
- /package/knowledge/{process → 02-process}/06-delivery.md +0 -0
- /package/knowledge/{guides/stages/design-planner.md → 03-guides/03-design-solution.md} +0 -0
- /package/knowledge/{guides/stages/code-implementer.md → 03-guides/04-implement-code.md} +0 -0
- /package/knowledge/{guides/stages/test-planner.md → 03-guides/05-plan-testing.md} +0 -0
- /package/knowledge/{guides/stages/test-generator.md → 03-guides/06-generate-tests.md} +0 -0
- /package/knowledge/{guides/stages/release-checker.md → 03-guides/07-check-release.md} +0 -0
- /package/knowledge/{guides/stages/requirement-reviewer.md → 03-guides/09-review-requirement.md} +0 -0
- /package/knowledge/{guides/stages/design-reviewer.md → 03-guides/10-review-design.md} +0 -0
- /package/knowledge/{guides/stages/code-reviewer.md → 03-guides/11-review-code.md} +0 -0
- /package/knowledge/{guides/stages/test-reviewer.md → 03-guides/12-review-testing.md} +0 -0
- /package/knowledge/{guides/stages/security-reviewer.md → 03-guides/13-audit-security.md} +0 -0
- /package/knowledge/{guides/stages/consistency-checker.md → 03-guides/14-check-consistency.md} +0 -0
- /package/knowledge/{guides/stages/unit-test-runner.md → 03-guides/15-run-unit-tests.md} +0 -0
- /package/knowledge/{guides/stages/integration-test-runner.md → 03-guides/16-run-integration-tests.md} +0 -0
- /package/knowledge/{guides/stages/test-context-analyzer.md → 03-guides/17-analyze-test-context.md} +0 -0
- /package/knowledge/{guides/support/practice-logger.md → 03-guides/18-log-practice.md} +0 -0
- /package/knowledge/{guides/support/skill-validator.md → 03-guides/21-validate-skill.md} +0 -0
- /package/knowledge/{guides/support/scope-inference.md → 03-guides/23-infer-scope.md} +0 -0
- /package/knowledge/{guides/support/component-discovery.md → 03-guides/25-discover-component.md} +0 -0
- /package/knowledge/{guides/support/environment-scanner.md → 03-guides/27-scan-environment.md} +0 -0
- /package/knowledge/{guides/support/environment-validator.md → 03-guides/28-validate-environment.md} +0 -0
- /package/knowledge/{guides/support/knowledge-generator.md → 03-guides/29-generate-knowledge.md} +0 -0
- /package/knowledge/{guides/support/ai-capability-analyzer.md → 03-guides/30-analyze-ai-capability.md} +0 -0
- /package/knowledge/{guides/support/ai-component-analyzer.md → 03-guides/31-analyze-ai-component.md} +0 -0
- /package/knowledge/{guides/support/ai-agent-analyzer.md → 03-guides/32-analyze-ai-agent.md} +0 -0
- /package/knowledge/{guides/support/ai-rag-analyzer.md → 03-guides/33-analyze-ai-rag.md} +0 -0
- /package/knowledge/{guides/support/ai-task-assessor.md → 03-guides/34-assess-ai-task.md} +0 -0
- /package/knowledge/{guides/support/ai-pipeline-evaluator.md → 03-guides/35-evaluate-ai-pipeline.md} +0 -0
- /package/knowledge/{guides/support/ai-artifact-evaluator.md → 03-guides/36-evaluate-ai-artifact.md} +0 -0
- /package/knowledge/{guides/support/ai-evaluation-planner.md → 03-guides/37-plan-ai-evaluation.md} +0 -0
- /package/knowledge/{guides/support/ai-path-evaluator.md → 03-guides/38-evaluate-ai-path.md} +0 -0
- /package/knowledge/{guides/support/ai-data-validator.md → 03-guides/39-validate-ai-data.md} +0 -0
- /package/knowledge/{guides/support/ai-anomaly-analyzer.md → 03-guides/40-detect-ai-anomaly.md} +0 -0
- /package/knowledge/{guides/support/ai-test-diagnostics.md → 03-guides/41-diagnose-ai-test.md} +0 -0
- /package/knowledge/{guides/support/test-runner.md → 03-guides/45-test-runner.md} +0 -0
- /package/knowledge/{checklists/test.md → 04-checklists/03-test.md} +0 -0
- /package/knowledge/{config/team-stage.yaml → 05-config/01-team-stage.yaml} +0 -0
- /package/knowledge/{config/role-extensions.yaml → 05-config/04-role-extensions.yaml} +0 -0
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: project-evolve-learner
|
|
3
|
+
description: "学习模式:观察人工操作,学习团队偏好,调整进化策略"
|
|
4
|
+
type: learner
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# Project-Evolve Learner
|
|
8
|
+
|
|
9
|
+
## 定位
|
|
10
|
+
|
|
11
|
+
学习模式技能,观察人工操作,学习团队偏好,调整进化策略。
|
|
12
|
+
|
|
13
|
+
## 输入
|
|
14
|
+
|
|
15
|
+
- 人工修改记录
|
|
16
|
+
- 团队偏好配置
|
|
17
|
+
|
|
18
|
+
## 输出
|
|
19
|
+
|
|
20
|
+
- 学习结果:团队偏好
|
|
21
|
+
- 策略调整:优化建议
|
|
22
|
+
- 偏好配置:更新后的偏好
|
|
23
|
+
|
|
24
|
+
## 执行步骤
|
|
25
|
+
|
|
26
|
+
### Step 1: 人工操作收集
|
|
27
|
+
|
|
28
|
+
```
|
|
29
|
+
收集人工操作:
|
|
30
|
+
1. Git 提交记录
|
|
31
|
+
2. 代码审查记录
|
|
32
|
+
3. 配置变更
|
|
33
|
+
4. 人工跳过建议
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
### Step 2: 行为分析
|
|
37
|
+
|
|
38
|
+
```
|
|
39
|
+
分析团队行为:
|
|
40
|
+
1. 代码风格偏好
|
|
41
|
+
2. 常用工具
|
|
42
|
+
3. 审批习惯
|
|
43
|
+
4. 问题处理方式
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
### Step 3: 偏好提取
|
|
47
|
+
|
|
48
|
+
```
|
|
49
|
+
提取团队偏好:
|
|
50
|
+
1. 命名规范
|
|
51
|
+
2. 注释习惯
|
|
52
|
+
3. 测试策略
|
|
53
|
+
4. 文档要求
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
### Step 4: 策略调整
|
|
57
|
+
|
|
58
|
+
```
|
|
59
|
+
调整进化策略:
|
|
60
|
+
1. 降低某些建议优先级
|
|
61
|
+
2. 增加特定检查
|
|
62
|
+
3. 调整阈值
|
|
63
|
+
4. 更新偏好配置
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
### Step 5: 效果验证
|
|
67
|
+
|
|
68
|
+
```
|
|
69
|
+
验证学习效果:
|
|
70
|
+
1. 建议采纳率
|
|
71
|
+
2. 人工干预减少
|
|
72
|
+
3. 团队满意度
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
## 使用示例
|
|
76
|
+
|
|
77
|
+
```
|
|
78
|
+
# 执行学习模式
|
|
79
|
+
读取 plugins/skills/project-evolve-learner/SKILL.md 并执行
|
|
80
|
+
|
|
81
|
+
# 输出
|
|
82
|
+
- 分析提交: 50
|
|
83
|
+
- 发现偏好: 5
|
|
84
|
+
- 策略调整: 3
|
|
85
|
+
- 建议采纳率: +20%
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
## 学习内容
|
|
89
|
+
|
|
90
|
+
| 类别 | 学习内容 | 应用 |
|
|
91
|
+
|------|----------|------|
|
|
92
|
+
| 代码风格 | 命名、格式、注释 | 调整 lint 规则 |
|
|
93
|
+
| 测试策略 | 覆盖率、测试位置 | 调整检查阈值 |
|
|
94
|
+
| 文档要求 | 文档深度、格式 | 调整文档检查 |
|
|
95
|
+
| 审批流程 | 审批人、流程 | 调整确认点 |
|
|
96
|
+
|
|
97
|
+
## 与其他技能的区别
|
|
98
|
+
|
|
99
|
+
| 技能 | 侧重点 |
|
|
100
|
+
|------|--------|
|
|
101
|
+
| analyzer | 问题识别 |
|
|
102
|
+
| fixer | 自动修复 |
|
|
103
|
+
| **learner** | 从人工操作学习 |
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: project-evolve-reviewer
|
|
3
|
+
description: "效果回顾:回顾进化效果,持续改进,分析进化趋势"
|
|
4
|
+
type: reviewer
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# Project-Evolve Reviewer
|
|
8
|
+
|
|
9
|
+
## 定位
|
|
10
|
+
|
|
11
|
+
效果回顾技能,回顾进化效果,持续改进,分析进化趋势。
|
|
12
|
+
|
|
13
|
+
## 输入
|
|
14
|
+
|
|
15
|
+
- 历史进化记录
|
|
16
|
+
- 时间范围(最近 N 天)
|
|
17
|
+
|
|
18
|
+
## 输出
|
|
19
|
+
|
|
20
|
+
- 效果报告:进化前后对比
|
|
21
|
+
- 趋势分析:质量趋势
|
|
22
|
+
- 改进机会:新的优化点
|
|
23
|
+
|
|
24
|
+
## 执行步骤
|
|
25
|
+
|
|
26
|
+
### Step 1: 历史数据收集
|
|
27
|
+
|
|
28
|
+
```
|
|
29
|
+
收集历史记录:
|
|
30
|
+
1. 进化次数
|
|
31
|
+
2. 修复数量
|
|
32
|
+
3. 质量变化
|
|
33
|
+
4. 时间线
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
### Step 2: 效果分析
|
|
37
|
+
|
|
38
|
+
```
|
|
39
|
+
分析进化效果:
|
|
40
|
+
1. 代码质量趋势
|
|
41
|
+
2. 测试覆盖率趋势
|
|
42
|
+
3. 构建时间趋势
|
|
43
|
+
4. Bug 率趋势
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
### Step 3: 改进评估
|
|
47
|
+
|
|
48
|
+
```
|
|
49
|
+
评估改进效果:
|
|
50
|
+
1. 哪些改进有效
|
|
51
|
+
2. 哪些改进无效
|
|
52
|
+
3. 原因分析
|
|
53
|
+
4. 经验总结
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
### Step 4: 机会识别
|
|
57
|
+
|
|
58
|
+
```
|
|
59
|
+
识别新机会:
|
|
60
|
+
1. 重复问题模式
|
|
61
|
+
2. 优化空间
|
|
62
|
+
3. 自动化机会
|
|
63
|
+
4. 工具改进
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
### Step 5: 报告生成
|
|
67
|
+
|
|
68
|
+
```
|
|
69
|
+
生成回顾报告:
|
|
70
|
+
1. 效果总结
|
|
71
|
+
2. 趋势图表
|
|
72
|
+
3. 经验教训
|
|
73
|
+
4. 下一步建议
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
## 使用示例
|
|
77
|
+
|
|
78
|
+
```
|
|
79
|
+
# 执行效果回顾
|
|
80
|
+
读取 plugins/skills/project-evolve-reviewer/SKILL.md 并执行
|
|
81
|
+
|
|
82
|
+
# 输出
|
|
83
|
+
- 进化次数: 12
|
|
84
|
+
- 质量提升: +15%
|
|
85
|
+
- 有效改进: 85%
|
|
86
|
+
- 下一步: 3个优化点
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
## 分析维度
|
|
90
|
+
|
|
91
|
+
| 维度 | 分析内容 | 指标 |
|
|
92
|
+
|------|----------|------|
|
|
93
|
+
| 频率分析 | 进化频率 | 次/周 |
|
|
94
|
+
| 效果分析 | 质量提升 | 分数变化 |
|
|
95
|
+
| 效率分析 | 修复效率 | 时间/修复 |
|
|
96
|
+
| 趋势分析 | 长期趋势 | 环比/同比 |
|
|
97
|
+
|
|
98
|
+
## 与其他技能的区别
|
|
99
|
+
|
|
100
|
+
| 技能 | 侧重点 |
|
|
101
|
+
|------|--------|
|
|
102
|
+
| analyzer | 当前问题分析 |
|
|
103
|
+
| verifier | 单次修复验证 |
|
|
104
|
+
| **reviewer** | 长期效果回顾 |
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: project-evolve-scanner
|
|
3
|
+
description: "项目扫描:检测技术栈、目录结构、依赖配置,自动发现项目特征和评测点"
|
|
4
|
+
type: scanner
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# Project-Evolve Scanner
|
|
8
|
+
|
|
9
|
+
## 定位
|
|
10
|
+
|
|
11
|
+
项目扫描技能,用于检测项目技术栈、目录结构、依赖配置,自动发现项目特征和评测点。
|
|
12
|
+
|
|
13
|
+
## 输入
|
|
14
|
+
|
|
15
|
+
- 项目路径(默认当前目录)
|
|
16
|
+
- 扫描深度配置
|
|
17
|
+
|
|
18
|
+
## 输出
|
|
19
|
+
|
|
20
|
+
- 项目特征报告:项目类型、框架、技术栈
|
|
21
|
+
- 评测点列表:可优化的代码质量点
|
|
22
|
+
- 记忆结构:用于后续进化分析
|
|
23
|
+
|
|
24
|
+
## 执行步骤
|
|
25
|
+
|
|
26
|
+
### Step 1: 技术栈检测
|
|
27
|
+
|
|
28
|
+
```
|
|
29
|
+
检测构建文件:
|
|
30
|
+
- package.json → Node.js/React/Vue
|
|
31
|
+
- pom.xml/build.gradle → Java/Spring
|
|
32
|
+
- go.mod → Go
|
|
33
|
+
- requirements.txt/pyproject.toml → Python
|
|
34
|
+
- Cargo.toml → Rust
|
|
35
|
+
- Gemfile → Ruby
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
### Step 2: 目录结构分析
|
|
39
|
+
|
|
40
|
+
```
|
|
41
|
+
检测目录:
|
|
42
|
+
- src/, lib/ → 源码目录
|
|
43
|
+
- tests/, test/ → 测试目录
|
|
44
|
+
- docs/, documentation/ → 文档目录
|
|
45
|
+
- config/ → 配置目录
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
### Step 3: 依赖分析
|
|
49
|
+
|
|
50
|
+
```
|
|
51
|
+
分析依赖:
|
|
52
|
+
- 生产依赖
|
|
53
|
+
- 开发依赖
|
|
54
|
+
- 依赖版本
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
### Step 4: 评测点发现
|
|
58
|
+
|
|
59
|
+
```
|
|
60
|
+
自动发现:
|
|
61
|
+
- 代码复杂度
|
|
62
|
+
- 测试覆盖率
|
|
63
|
+
- 文档完整性
|
|
64
|
+
- 配置规范性
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
### Step 5: 生成记忆结构
|
|
68
|
+
|
|
69
|
+
```
|
|
70
|
+
创建记忆:
|
|
71
|
+
- 项目特征
|
|
72
|
+
- 评测点
|
|
73
|
+
- 优化建议
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
## 使用示例
|
|
77
|
+
|
|
78
|
+
```
|
|
79
|
+
# 扫描当前项目
|
|
80
|
+
读取 plugins/skills/project-evolve-scanner/SKILL.md 并执行
|
|
81
|
+
|
|
82
|
+
# 输出
|
|
83
|
+
- 项目类型: Node.js + React
|
|
84
|
+
- 技术栈: TypeScript, Jest, ESLint
|
|
85
|
+
- 评测点: 15个
|
|
86
|
+
- 优化建议: 8条
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
## 与 self-evolve-scanner 的区别
|
|
90
|
+
|
|
91
|
+
| 特性 | self-evolve-scanner | project-evolve-scanner |
|
|
92
|
+
|------|---------------------|------------------------|
|
|
93
|
+
| 目标 | 框架自我测试 | 扫描真实项目 |
|
|
94
|
+
| 扫描内容 | 框架代码 | 用户项目代码 |
|
|
95
|
+
| 输出 | 框架指标 | 项目评测点 |
|
|
@@ -0,0 +1,395 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Dependency Reuse Checker
|
|
5
|
+
*
|
|
6
|
+
* 检查依赖包复用情况,识别重复造轮子
|
|
7
|
+
*
|
|
8
|
+
* 功能:
|
|
9
|
+
* 1. 扫描项目依赖(package.json / pom.xml / build.gradle / go.mod 等)
|
|
10
|
+
* 2. 提取功能需求关键词,匹配现有依赖包
|
|
11
|
+
* 3. 检查团队组件使用手册
|
|
12
|
+
* 4. 搜索项目现有代码中是否有可复用的实现
|
|
13
|
+
* 5. 输出"依赖包优先"建议
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
import fs from 'fs';
|
|
17
|
+
import path from 'path';
|
|
18
|
+
import { fileURLToPath } from 'url';
|
|
19
|
+
|
|
20
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
21
|
+
const __dirname = path.dirname(__filename);
|
|
22
|
+
|
|
23
|
+
// 常见功能关键词与依赖包映射
|
|
24
|
+
const FUNCTION_TO_PACKAGES = {
|
|
25
|
+
// HTTP 请求
|
|
26
|
+
'http': ['axios', 'fetch', 'node-fetch', 'got', 'request'],
|
|
27
|
+
'request': ['axios', 'fetch', 'node-fetch', 'got', 'request'],
|
|
28
|
+
'fetch': ['axios', 'fetch', 'node-fetch', 'got'],
|
|
29
|
+
|
|
30
|
+
// 数据处理
|
|
31
|
+
'json': ['fast-json-stable-stringify', 'lodash', 'ramda'],
|
|
32
|
+
'date': ['dayjs', 'moment', 'date-fns', 'luxon'],
|
|
33
|
+
'format': ['sprintf-js', 'numeral', 'decimal.js'],
|
|
34
|
+
|
|
35
|
+
// 验证
|
|
36
|
+
'validate': ['joi', 'yup', 'zod', 'validator'],
|
|
37
|
+
'schema': ['joi', 'yup', 'zod', 'ajv'],
|
|
38
|
+
'type': ['joi', 'yup', 'zod', 'runtypes'],
|
|
39
|
+
|
|
40
|
+
// 工具
|
|
41
|
+
'deep': ['lodash', 'ramda', 'deep-equal'],
|
|
42
|
+
'clone': ['lodash', 'ramda', 'clone-deep'],
|
|
43
|
+
'merge': ['lodash', 'ramda', 'deepmerge'],
|
|
44
|
+
'pick': ['lodash', 'ramda', 'filter-obj'],
|
|
45
|
+
'omit': ['lodash', 'ramda', 'filter-obj'],
|
|
46
|
+
|
|
47
|
+
// 加密
|
|
48
|
+
'crypto': ['crypto-js', 'bcrypt', 'argon2', 'scrypt'],
|
|
49
|
+
'hash': ['crypto-js', 'bcrypt', 'argon2', 'md5'],
|
|
50
|
+
'encrypt': ['crypto-js', 'bcrypt', 'argon2'],
|
|
51
|
+
'password': ['bcrypt', 'argon2', 'scrypt'],
|
|
52
|
+
|
|
53
|
+
// 异步
|
|
54
|
+
'promise': ['bluebird'],
|
|
55
|
+
'async': ['async', 'p-series', 'p-map'],
|
|
56
|
+
'retry': ['async-retry', 'p-retry', 'promise-retry'],
|
|
57
|
+
'timeout': ['timeout-abort-controller'],
|
|
58
|
+
|
|
59
|
+
// 日志
|
|
60
|
+
'log': ['winston', 'pino', 'loglevel', 'bunyan'],
|
|
61
|
+
'logger': ['winston', 'pino', 'bunyan'],
|
|
62
|
+
|
|
63
|
+
// 测试
|
|
64
|
+
'test': ['jest', 'mocha', 'ava', 'tap'],
|
|
65
|
+
'mock': ['jest-mock', 'sinon', 'proxyquire', 'mock-fs'],
|
|
66
|
+
'coverage': ['nyc', 'c8', 'istanbul'],
|
|
67
|
+
|
|
68
|
+
// 命令行
|
|
69
|
+
'cli': ['commander', 'yargs', 'meow', 'argparse'],
|
|
70
|
+
'prompt': ['inquirer', 'prompts', 'enquirer'],
|
|
71
|
+
'table': ['cli-table', 'table', 'ascii-table'],
|
|
72
|
+
|
|
73
|
+
// 文件
|
|
74
|
+
'glob': ['glob', 'fast-glob', 'minimatch'],
|
|
75
|
+
'fs': ['fs-extra', 'graceful-fs'],
|
|
76
|
+
'watch': ['chokidar', 'watch', 'gaze'],
|
|
77
|
+
|
|
78
|
+
// 环境
|
|
79
|
+
'env': ['dotenv', 'env-var', 'envalid'],
|
|
80
|
+
'config': ['convict', 'config', 'node-config'],
|
|
81
|
+
|
|
82
|
+
// 邮件
|
|
83
|
+
'email': ['nodemailer', 'sendgrid', 'mailgun-js'],
|
|
84
|
+
'mail': ['nodemailer', 'sendgrid', 'mailgun-js'],
|
|
85
|
+
|
|
86
|
+
// 缓存
|
|
87
|
+
'cache': ['node-cache', 'memory-cache', 'lru-cache'],
|
|
88
|
+
'redis': ['ioredis', 'node-redis', 'redis'],
|
|
89
|
+
|
|
90
|
+
// WebSocket
|
|
91
|
+
'websocket': ['ws', 'socket.io', 'primus'],
|
|
92
|
+
'socket': ['socket.io', 'ws', 'primus'],
|
|
93
|
+
|
|
94
|
+
// 验证
|
|
95
|
+
'email-validate': ['email-validator', 'validator'],
|
|
96
|
+
'url-validate': ['validator', 'is-url'],
|
|
97
|
+
'phone': ['phone', 'libphonenumber-js'],
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
// 解析命令行参数
|
|
101
|
+
function parseArgs() {
|
|
102
|
+
const args = process.argv.slice(2);
|
|
103
|
+
const options = {
|
|
104
|
+
project: '.',
|
|
105
|
+
verbose: false,
|
|
106
|
+
output: null,
|
|
107
|
+
};
|
|
108
|
+
|
|
109
|
+
for (let i = 0; i < args.length; i++) {
|
|
110
|
+
switch (args[i]) {
|
|
111
|
+
case '--project':
|
|
112
|
+
case '-p':
|
|
113
|
+
options.project = args[++i];
|
|
114
|
+
break;
|
|
115
|
+
case '--verbose':
|
|
116
|
+
case '-v':
|
|
117
|
+
options.verbose = true;
|
|
118
|
+
break;
|
|
119
|
+
case '--output':
|
|
120
|
+
case '-o':
|
|
121
|
+
options.output = args[++i];
|
|
122
|
+
break;
|
|
123
|
+
case '--help':
|
|
124
|
+
case '-h':
|
|
125
|
+
printHelp();
|
|
126
|
+
process.exit(0);
|
|
127
|
+
break;
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
return options;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
function printHelp() {
|
|
135
|
+
console.log(`
|
|
136
|
+
Dependency Reuse Checker
|
|
137
|
+
|
|
138
|
+
用法:
|
|
139
|
+
node dependency-reuse-checker.js --project <path> [选项]
|
|
140
|
+
|
|
141
|
+
选项:
|
|
142
|
+
-p, --project <path> 项目路径(默认:当前目录)
|
|
143
|
+
-o, --output <path> 输出报告路径(默认:stdout)
|
|
144
|
+
-v, --verbose 详细输出
|
|
145
|
+
-h, --help 显示帮助
|
|
146
|
+
|
|
147
|
+
示例:
|
|
148
|
+
node dependency-reuse-checker.js --project ./my-project
|
|
149
|
+
node dependency-reuse-checker.js --project ./my-project --output report.json
|
|
150
|
+
`);
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
// 读取项目依赖
|
|
154
|
+
function readDependencies(projectPath) {
|
|
155
|
+
const deps = {
|
|
156
|
+
dependencies: {},
|
|
157
|
+
devDependencies: {},
|
|
158
|
+
};
|
|
159
|
+
|
|
160
|
+
// package.json
|
|
161
|
+
const packageJsonPath = path.join(projectPath, 'package.json');
|
|
162
|
+
if (fs.existsSync(packageJsonPath)) {
|
|
163
|
+
try {
|
|
164
|
+
const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf-8'));
|
|
165
|
+
deps.dependencies = packageJson.dependencies || {};
|
|
166
|
+
deps.devDependencies = packageJson.devDependencies || {};
|
|
167
|
+
} catch (e) {
|
|
168
|
+
console.error('解析 package.json 失败:', e.message);
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
return deps;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
// 扫描代码中的功能关键词
|
|
176
|
+
function scanCodeForKeywords(projectPath) {
|
|
177
|
+
const keywords = new Set();
|
|
178
|
+
const patterns = [
|
|
179
|
+
/require\s*\(\s*['"]([^'"]+)['"]\s*\)/g,
|
|
180
|
+
/import\s+.*?\s+from\s+['"]([^'"]+)['"]/g,
|
|
181
|
+
];
|
|
182
|
+
|
|
183
|
+
function scanDir(dir) {
|
|
184
|
+
if (!fs.existsSync(dir)) return;
|
|
185
|
+
|
|
186
|
+
const files = fs.readdirSync(dir);
|
|
187
|
+
for (const file of files) {
|
|
188
|
+
const fullPath = path.join(dir, file);
|
|
189
|
+
const stat = fs.statSync(fullPath);
|
|
190
|
+
|
|
191
|
+
if (stat.isDirectory()) {
|
|
192
|
+
// 跳过 node_modules 和隐藏目录
|
|
193
|
+
if (file !== 'node_modules' && !file.startsWith('.')) {
|
|
194
|
+
scanDir(fullPath);
|
|
195
|
+
}
|
|
196
|
+
} else if (/\.(js|ts|jsx|tsx)$/.test(file)) {
|
|
197
|
+
try {
|
|
198
|
+
const content = fs.readFileSync(fullPath, 'utf-8');
|
|
199
|
+
for (const pattern of patterns) {
|
|
200
|
+
let match;
|
|
201
|
+
while ((match = pattern.exec(content)) !== null) {
|
|
202
|
+
const pkg = match[1];
|
|
203
|
+
// 检查是否是本地模块
|
|
204
|
+
if (!pkg.startsWith('.') && !pkg.startsWith('/')) {
|
|
205
|
+
// 提取关键词
|
|
206
|
+
const basePkg = pkg.split('/')[0].replace('@', '');
|
|
207
|
+
if (FUNCTION_TO_PACKAGES[basePkg]) {
|
|
208
|
+
keywords.add(basePkg);
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
} catch (e) {
|
|
214
|
+
// 忽略读取错误
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
const srcDir = path.join(projectPath, 'src');
|
|
221
|
+
const libDir = path.join(projectPath, 'lib');
|
|
222
|
+
const appDir = path.join(projectPath, 'app');
|
|
223
|
+
|
|
224
|
+
scanDir(fs.existsSync(srcDir) ? srcDir : projectPath);
|
|
225
|
+
if (fs.existsSync(libDir)) scanDir(libDir);
|
|
226
|
+
if (fs.existsSync(appDir)) scanDir(appDir);
|
|
227
|
+
|
|
228
|
+
return Array.from(keywords);
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
// 检查是否有可复用的现有实现
|
|
232
|
+
function checkExistingImplementation(projectPath, keyword) {
|
|
233
|
+
const results = [];
|
|
234
|
+
|
|
235
|
+
// 搜索可能的工具函数目录
|
|
236
|
+
const utilsDirs = ['utils', 'util', 'helpers', 'helper', 'lib', 'tools', 'common'];
|
|
237
|
+
|
|
238
|
+
function searchDir(dir, depth = 0) {
|
|
239
|
+
if (depth > 3) return; // 限制搜索深度
|
|
240
|
+
|
|
241
|
+
if (!fs.existsSync(dir)) return;
|
|
242
|
+
|
|
243
|
+
try {
|
|
244
|
+
const files = fs.readdirSync(dir);
|
|
245
|
+
for (const file of files) {
|
|
246
|
+
const fullPath = path.join(dir, file);
|
|
247
|
+
const stat = fs.statSync(fullPath);
|
|
248
|
+
|
|
249
|
+
if (stat.isDirectory()) {
|
|
250
|
+
if (!file.startsWith('.') && file !== 'node_modules') {
|
|
251
|
+
searchDir(fullPath, depth + 1);
|
|
252
|
+
}
|
|
253
|
+
} else if (/\.(js|ts)$/.test(file)) {
|
|
254
|
+
try {
|
|
255
|
+
const content = fs.readFileSync(fullPath, 'utf-8');
|
|
256
|
+
if (content.toLowerCase().includes(keyword.toLowerCase())) {
|
|
257
|
+
results.push({
|
|
258
|
+
file: path.relative(projectPath, fullPath),
|
|
259
|
+
match: keyword,
|
|
260
|
+
});
|
|
261
|
+
}
|
|
262
|
+
} catch (e) {
|
|
263
|
+
// 忽略
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
} catch (e) {
|
|
268
|
+
// 忽略权限错误
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
for (const utilsDir of utilsDirs) {
|
|
273
|
+
searchDir(path.join(projectPath, utilsDir));
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
return results;
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
// 生成建议
|
|
280
|
+
function generateSuggestions(keyword, existingDeps, existingImpl) {
|
|
281
|
+
const suggestions = [];
|
|
282
|
+
|
|
283
|
+
// 检查是否已安装相关包
|
|
284
|
+
const relatedPkgs = FUNCTION_TO_PACKAGES[keyword] || [];
|
|
285
|
+
const installed = relatedPkgs.filter(pkg =>
|
|
286
|
+
existingDeps.dependencies[pkg] || existingDeps.devDependencies[pkg]
|
|
287
|
+
);
|
|
288
|
+
|
|
289
|
+
if (installed.length > 0) {
|
|
290
|
+
suggestions.push({
|
|
291
|
+
type: 'use-existing',
|
|
292
|
+
message: `已安装相关依赖: ${installed.join(', ')}`,
|
|
293
|
+
priority: 'high',
|
|
294
|
+
});
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
// 检查是否有现有实现
|
|
298
|
+
if (existingImpl.length > 0) {
|
|
299
|
+
suggestions.push({
|
|
300
|
+
type: 'use-existing',
|
|
301
|
+
message: `发现现有实现: ${existingImpl.map(e => e.file).join(', ')}`,
|
|
302
|
+
priority: 'medium',
|
|
303
|
+
});
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
// 建议使用依赖包
|
|
307
|
+
if (installed.length === 0 && existingImpl.length === 0) {
|
|
308
|
+
suggestions.push({
|
|
309
|
+
type: 'consider-package',
|
|
310
|
+
message: `建议使用依赖包: ${relatedPkgs.join(', ')}`,
|
|
311
|
+
priority: 'low',
|
|
312
|
+
});
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
return suggestions;
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
// 主函数
|
|
319
|
+
async function main() {
|
|
320
|
+
const options = parseArgs();
|
|
321
|
+
|
|
322
|
+
console.log('🔍 Dependency Reuse Checker\n');
|
|
323
|
+
|
|
324
|
+
try {
|
|
325
|
+
// 1. 读取项目依赖
|
|
326
|
+
console.log('📦 读取项目依赖...');
|
|
327
|
+
const deps = readDependencies(options.project);
|
|
328
|
+
console.log(` 依赖: ${Object.keys(deps.dependencies).length}`);
|
|
329
|
+
console.log(` 开发依赖: ${Object.keys(deps.devDependencies).length}`);
|
|
330
|
+
|
|
331
|
+
// 2. 扫描代码关键词
|
|
332
|
+
console.log('\n🔎 扫描代码关键词...');
|
|
333
|
+
const keywords = scanCodeForKeywords(options.project);
|
|
334
|
+
console.log(` 发现关键词: ${keywords.join(', ')}`);
|
|
335
|
+
|
|
336
|
+
// 3. 分析每个关键词
|
|
337
|
+
console.log('\n📊 分析复用机会...\n');
|
|
338
|
+
const results = [];
|
|
339
|
+
|
|
340
|
+
for (const keyword of keywords) {
|
|
341
|
+
const existingImpl = checkExistingImplementation(options.project, keyword);
|
|
342
|
+
const suggestions = generateSuggestions(keyword, deps, existingImpl);
|
|
343
|
+
|
|
344
|
+
results.push({
|
|
345
|
+
keyword,
|
|
346
|
+
suggestions,
|
|
347
|
+
existingImplementation: existingImpl,
|
|
348
|
+
});
|
|
349
|
+
|
|
350
|
+
if (options.verbose) {
|
|
351
|
+
console.log(`\n[${keyword}]`);
|
|
352
|
+
for (const s of suggestions) {
|
|
353
|
+
console.log(` - ${s.message}`);
|
|
354
|
+
}
|
|
355
|
+
}
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
// 4. 生成报告
|
|
359
|
+
const report = {
|
|
360
|
+
timestamp: new Date().toISOString(),
|
|
361
|
+
project: options.project,
|
|
362
|
+
summary: {
|
|
363
|
+
totalKeywords: keywords.length,
|
|
364
|
+
reuseOpportunities: results.filter(r => r.suggestions.some(s => s.type === 'use-existing')).length,
|
|
365
|
+
newPackageSuggestions: results.filter(r => r.suggestions.some(s => s.type === 'consider-package')).length,
|
|
366
|
+
},
|
|
367
|
+
results,
|
|
368
|
+
};
|
|
369
|
+
|
|
370
|
+
// 5. 输出
|
|
371
|
+
if (options.output) {
|
|
372
|
+
fs.writeFileSync(options.output, JSON.stringify(report, null, 2));
|
|
373
|
+
console.log(`\n✅ 报告已保存: ${options.output}`);
|
|
374
|
+
} else {
|
|
375
|
+
console.log('\n📋 总结:');
|
|
376
|
+
console.log(` 关键词总数: ${report.summary.totalKeywords}`);
|
|
377
|
+
console.log(` 复用机会: ${report.summary.reuseOpportunities}`);
|
|
378
|
+
console.log(` 新包建议: ${report.summary.newPackageSuggestions}`);
|
|
379
|
+
}
|
|
380
|
+
|
|
381
|
+
process.exit(0);
|
|
382
|
+
|
|
383
|
+
} catch (error) {
|
|
384
|
+
console.error('\n❌ 检查失败:', error.message);
|
|
385
|
+
if (options.verbose) {
|
|
386
|
+
console.error(error.stack);
|
|
387
|
+
}
|
|
388
|
+
process.exit(1);
|
|
389
|
+
}
|
|
390
|
+
}
|
|
391
|
+
|
|
392
|
+
main().catch(error => {
|
|
393
|
+
console.error('未捕获的错误:', error);
|
|
394
|
+
process.exit(1);
|
|
395
|
+
});
|