specops 0.2.5 → 0.3.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/.opencode/agent/specops-codebase-mapper.md +764 -0
- package/.opencode/agent/specops-debugger.md +1246 -0
- package/.opencode/agent/specops-executor.md +475 -0
- package/.opencode/agent/specops-integration-checker.md +443 -0
- package/.opencode/agent/specops-phase-researcher.md +547 -0
- package/.opencode/agent/specops-plan-checker.md +690 -0
- package/.opencode/agent/specops-planner.md +581 -0
- package/.opencode/agent/specops-project-researcher.md +354 -0
- package/.opencode/agent/specops-research-synthesizer.md +242 -0
- package/.opencode/agent/specops-roadmapper.md +642 -0
- package/.opencode/agent/specops-work-verifier.md +573 -0
- package/.opencode/references/checkpoints.md +776 -0
- package/.opencode/references/continuation-format.md +249 -0
- package/.opencode/references/decimal-phase-calculation.md +65 -0
- package/.opencode/references/git-integration.md +248 -0
- package/.opencode/references/git-planning-commit.md +38 -0
- package/.opencode/references/model-profile-resolution.md +34 -0
- package/.opencode/references/model-profiles.md +92 -0
- package/.opencode/references/phase-argument-parsing.md +61 -0
- package/.opencode/references/planning-config.md +196 -0
- package/.opencode/references/questioning.md +145 -0
- package/.opencode/references/tdd.md +263 -0
- package/.opencode/references/ui-brand.md +160 -0
- package/.opencode/references/verification-patterns.md +612 -0
- package/.opencode/templates/DEBUG.md +164 -0
- package/.opencode/templates/UAT.md +180 -0
- package/.opencode/templates/VALIDATION.md +76 -0
- package/.opencode/templates/codebase/architecture.md +255 -0
- package/.opencode/templates/codebase/concerns.md +310 -0
- package/.opencode/templates/codebase/conventions.md +307 -0
- package/.opencode/templates/codebase/integrations.md +280 -0
- package/.opencode/templates/codebase/stack.md +186 -0
- package/.opencode/templates/codebase/structure.md +285 -0
- package/.opencode/templates/codebase/testing.md +480 -0
- package/.opencode/templates/context.md +221 -0
- package/.opencode/templates/continue-here.md +78 -0
- package/.opencode/templates/debug-subagent-prompt.md +91 -0
- package/.opencode/templates/discovery.md +147 -0
- package/.opencode/templates/milestone-archive.md +123 -0
- package/.opencode/templates/milestone.md +115 -0
- package/.opencode/templates/phase-prompt.md +333 -0
- package/.opencode/templates/planner-subagent-prompt.md +117 -0
- package/.opencode/templates/project.md +184 -0
- package/.opencode/templates/requirements.md +130 -0
- package/.opencode/templates/research-project/ARCHITECTURE.md +204 -0
- package/.opencode/templates/research-project/FEATURES.md +147 -0
- package/.opencode/templates/research-project/PITFALLS.md +200 -0
- package/.opencode/templates/research-project/STACK.md +120 -0
- package/.opencode/templates/research-project/SUMMARY.md +170 -0
- package/.opencode/templates/research.md +278 -0
- package/.opencode/templates/retrospective.md +54 -0
- package/.opencode/templates/roadmap.md +202 -0
- package/.opencode/templates/state.md +176 -0
- package/.opencode/templates/summary-complex.md +59 -0
- package/.opencode/templates/summary-minimal.md +41 -0
- package/.opencode/templates/summary-standard.md +48 -0
- package/.opencode/templates/summary.md +248 -0
- package/.opencode/templates/user-setup.md +311 -0
- package/.opencode/templates/verification-report.md +322 -0
- package/.opencode/workflows/add-phase.md +111 -0
- package/.opencode/workflows/add-tests.md +350 -0
- package/.opencode/workflows/add-todo.md +157 -0
- package/.opencode/workflows/audit-milestone.md +297 -0
- package/.opencode/workflows/check-todos.md +176 -0
- package/.opencode/workflows/cleanup.md +152 -0
- package/.opencode/workflows/complete-milestone.md +763 -0
- package/.opencode/workflows/diagnose-issues.md +219 -0
- package/.opencode/workflows/discovery-phase.md +288 -0
- package/.opencode/workflows/discuss-phase.md +542 -0
- package/.opencode/workflows/execute-phase.md +449 -0
- package/.opencode/workflows/execute-plan.md +447 -0
- package/.opencode/workflows/health.md +156 -0
- package/.opencode/workflows/help.md +489 -0
- package/.opencode/workflows/insert-phase.md +129 -0
- package/.opencode/workflows/list-phase-assumptions.md +178 -0
- package/.opencode/workflows/map-codebase.md +315 -0
- package/.opencode/workflows/new-milestone.md +382 -0
- package/.opencode/workflows/new-project.md +1116 -0
- package/.opencode/workflows/pause-work.md +122 -0
- package/.opencode/workflows/plan-milestone-gaps.md +274 -0
- package/.opencode/workflows/plan-phase.md +569 -0
- package/.opencode/workflows/progress.md +381 -0
- package/.opencode/workflows/quick.md +453 -0
- package/.opencode/workflows/remove-phase.md +154 -0
- package/.opencode/workflows/research-phase.md +73 -0
- package/.opencode/workflows/resume-project.md +304 -0
- package/.opencode/workflows/set-profile.md +80 -0
- package/.opencode/workflows/settings.md +213 -0
- package/.opencode/workflows/transition.md +544 -0
- package/.opencode/workflows/update.md +219 -0
- package/.opencode/workflows/verify-phase.md +242 -0
- package/.opencode/workflows/verify-work.md +569 -0
- package/commands/specops/add-phase.md +43 -0
- package/commands/specops/add-tests.md +41 -0
- package/commands/specops/add-todo.md +47 -0
- package/commands/specops/audit-milestone.md +36 -0
- package/commands/specops/check-todos.md +45 -0
- package/commands/specops/cleanup.md +18 -0
- package/commands/specops/complete-milestone.md +136 -0
- package/commands/specops/debug.md +167 -0
- package/commands/specops/discuss-phase.md +83 -0
- package/commands/specops/execute-phase.md +41 -0
- package/commands/specops/health.md +22 -0
- package/commands/specops/help.md +22 -0
- package/commands/specops/insert-phase.md +32 -0
- package/commands/specops/join-discord.md +18 -0
- package/commands/specops/list-phase-assumptions.md +46 -0
- package/commands/specops/map-codebase.md +71 -0
- package/commands/specops/new-milestone.md +44 -0
- package/commands/specops/new-project.md +42 -0
- package/commands/specops/pause-work.md +38 -0
- package/commands/specops/plan-milestone-gaps.md +34 -0
- package/commands/specops/plan-phase.md +45 -0
- package/commands/specops/progress.md +24 -0
- package/commands/specops/quick.md +41 -0
- package/commands/specops/reapply-patches.md +111 -0
- package/commands/specops/remove-phase.md +31 -0
- package/commands/specops/research-phase.md +189 -0
- package/commands/specops/resume-work.md +40 -0
- package/commands/specops/set-profile.md +34 -0
- package/commands/specops/settings.md +36 -0
- package/commands/specops/update.md +37 -0
- package/commands/specops/verify-work.md +38 -0
- package/dist/__integration__/fixtures/generator.d.ts +4 -0
- package/dist/__integration__/fixtures/generator.js +1 -0
- package/dist/__integration__/mocks/server.d.ts +7 -0
- package/dist/__integration__/mocks/server.js +1 -0
- package/dist/__integration__/setup.d.ts +6 -0
- package/dist/__integration__/setup.js +1 -0
- package/dist/acceptance/lazyDetector.js +1 -1
- package/dist/acceptance/reporter.js +1 -1
- package/dist/acceptance/runner.js +1 -1
- package/dist/cli.js +1 -1
- package/dist/context/index.js +1 -1
- package/dist/context/promptTemplate.js +1 -1
- package/dist/context/techContextLoader.js +1 -1
- package/dist/engine.d.ts +1 -0
- package/dist/engine.js +1 -1
- package/dist/evolution/distiller.js +1 -1
- package/dist/evolution/index.js +1 -1
- package/dist/evolution/memoryGraph.js +1 -1
- package/dist/evolution/selector.js +1 -1
- package/dist/evolution/signals.js +1 -1
- package/dist/evolution/solidify.js +1 -1
- package/dist/evolution/store.js +1 -1
- package/dist/evolution/types.js +1 -1
- package/dist/init.d.ts +4 -3
- package/dist/init.js +1 -1
- package/dist/machines/agentMachine.js +1 -1
- package/dist/machines/supervisorMachine.js +1 -1
- package/dist/persistence/schema.js +1 -1
- package/dist/persistence/stateFile.js +1 -1
- package/dist/plugin-engine.js +1 -1
- package/dist/plugin.js +1 -1
- package/dist/requirement-analysis/analyzers/repository-parser.d.ts +121 -0
- package/dist/requirement-analysis/analyzers/repository-parser.js +1 -0
- package/dist/requirement-analysis/generators/prd-generator.d.ts +90 -0
- package/dist/requirement-analysis/generators/prd-generator.js +1 -0
- package/dist/requirement-analysis/integrations/v1-integration.d.ts +73 -0
- package/dist/requirement-analysis/integrations/v1-integration.js +1 -0
- package/dist/requirement-analysis/tools/analyze-requirements.js +1 -0
- package/dist/requirement-analysis/types/analysis-result.d.ts +326 -0
- package/dist/requirement-analysis/types/analysis-result.js +1 -0
- package/dist/requirement-analysis/types/feature-mapping.d.ts +294 -0
- package/dist/requirement-analysis/types/feature-mapping.js +1 -0
- package/dist/requirement-analysis/types/index.d.ts +171 -0
- package/dist/requirement-analysis/types/index.js +1 -0
- package/dist/requirement-analysis/types/tech-stack.d.ts +213 -0
- package/dist/requirement-analysis/types/tech-stack.js +1 -0
- package/dist/requirement-analysis/utils/error-handler.d.ts +112 -0
- package/dist/requirement-analysis/utils/error-handler.js +1 -0
- package/dist/types/index.d.ts +4 -2
- package/dist/types/index.js +1 -1
- package/dist/utils/id.js +1 -1
- package/package.json +4 -2
- package/skills/competitor-search/SKILL.md +169 -0
- package/skills/demand-analysis/SKILL.md +307 -0
- package/skills/feature-search/SKILL.md +182 -0
- package/skills/requirement-analysis/README.md +464 -0
- package/skills/requirement-analysis/SKILL.md +224 -0
- package/skills/requirement-analysis/templates/feature-mapping-template.json +210 -0
- package/skills/requirement-analysis/templates/prd-template.md +104 -0
- package/skills/tech-selection/SKILL.md +198 -0
- package/dist/__e2e__/01-state-engine.e2e.test.d.ts +0 -10
- package/dist/__e2e__/01-state-engine.e2e.test.js +0 -1
- package/dist/acceptance/lazyDetector.test.d.ts +0 -1
- package/dist/acceptance/lazyDetector.test.js +0 -1
- package/dist/acceptance/reporter.test.d.ts +0 -1
- package/dist/acceptance/reporter.test.js +0 -1
- package/dist/acceptance/runner.test.d.ts +0 -1
- package/dist/acceptance/runner.test.js +0 -1
- package/dist/context/promptTemplate.test.d.ts +0 -1
- package/dist/context/promptTemplate.test.js +0 -1
- package/dist/context/techContextLoader.test.d.ts +0 -1
- package/dist/context/techContextLoader.test.js +0 -1
- package/dist/machines/agentMachine.test.d.ts +0 -1
- package/dist/machines/agentMachine.test.js +0 -1
- package/dist/machines/supervisorMachine.test.d.ts +0 -1
- package/dist/machines/supervisorMachine.test.js +0 -1
- package/dist/persistence/stateFile.test.d.ts +0 -1
- package/dist/persistence/stateFile.test.js +0 -1
|
@@ -0,0 +1,464 @@
|
|
|
1
|
+
# 需求分析技能使用指南
|
|
2
|
+
|
|
3
|
+
## 快速开始
|
|
4
|
+
|
|
5
|
+
### 基本用法
|
|
6
|
+
|
|
7
|
+
```typescript
|
|
8
|
+
import { V1Integration } from '../src/requirement-analysis/integrations/v1-integration.js';
|
|
9
|
+
|
|
10
|
+
const analyzer = new V1Integration();
|
|
11
|
+
|
|
12
|
+
// 分析项目需求
|
|
13
|
+
const result = await analyzer.analyzeRequirements('/path/to/project', {
|
|
14
|
+
includeTechStack: true,
|
|
15
|
+
generatePRD: true,
|
|
16
|
+
depth: 'medium'
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
console.log('分析完成:', result.id);
|
|
20
|
+
console.log('项目名称:', result.projectInfo.name);
|
|
21
|
+
console.log('功能数量:', result.featureMapping.summary.totalFeatures);
|
|
22
|
+
console.log('质量评分:', result.qualityScore.overall);
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
### 命令行使用
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
# 基本分析
|
|
29
|
+
npm run analyze-requirements /path/to/project
|
|
30
|
+
|
|
31
|
+
# 深度分析并生成PRD
|
|
32
|
+
npm run analyze-requirements /path/to/project --depth=deep --prd
|
|
33
|
+
|
|
34
|
+
# 仅技术栈分析
|
|
35
|
+
npm run analyze-requirements /path/to/project --tech-only
|
|
36
|
+
|
|
37
|
+
# 导出到v1系统
|
|
38
|
+
npm run analyze-requirements /path/to/project --export-v1
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
## 详细功能
|
|
42
|
+
|
|
43
|
+
### 1. 项目信息分析
|
|
44
|
+
|
|
45
|
+
```typescript
|
|
46
|
+
import { RepositoryParser } from '../src/requirement-analysis/analyzers/repository-parser.js';
|
|
47
|
+
|
|
48
|
+
const parser = new RepositoryParser();
|
|
49
|
+
|
|
50
|
+
// 解析项目基本信息
|
|
51
|
+
const projectInfo = await parser.parseProjectInfo('/path/to/project');
|
|
52
|
+
|
|
53
|
+
console.log('项目类型:', projectInfo.type);
|
|
54
|
+
console.log('主要语言:', projectInfo.primaryLanguages);
|
|
55
|
+
console.log('代码行数:', projectInfo.codebaseStats.totalLines);
|
|
56
|
+
console.log('项目成熟度:', projectInfo.maturity);
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
**支持的项目类型:**
|
|
60
|
+
- `web-app` - Web应用
|
|
61
|
+
- `mobile-app` - 移动应用
|
|
62
|
+
- `desktop-app` - 桌面应用
|
|
63
|
+
- `api-service` - API服务
|
|
64
|
+
- `library` - 代码库
|
|
65
|
+
- `cli-tool` - 命令行工具
|
|
66
|
+
- `microservice` - 微服务
|
|
67
|
+
- `monorepo` - 单体仓库
|
|
68
|
+
|
|
69
|
+
### 2. PRD文档生成
|
|
70
|
+
|
|
71
|
+
```typescript
|
|
72
|
+
import { PRDGenerator } from '../src/requirement-analysis/generators/prd-generator.js';
|
|
73
|
+
|
|
74
|
+
const generator = new PRDGenerator('./custom-template.md');
|
|
75
|
+
|
|
76
|
+
// 生成PRD文档
|
|
77
|
+
const prd = await generator.generatePRD(projectInfo, featureMapping, techStack);
|
|
78
|
+
|
|
79
|
+
console.log('PRD内容:', prd.content);
|
|
80
|
+
console.log('质量评分:', prd.qualityScore);
|
|
81
|
+
console.log('章节数量:', prd.sections.length);
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
**PRD模板变量:**
|
|
85
|
+
- `{{projectName}}` - 项目名称
|
|
86
|
+
- `{{projectDescription}}` - 项目描述
|
|
87
|
+
- `{{totalFeatures}}` - 功能总数
|
|
88
|
+
- `{{totalHours}}` - 总工作量
|
|
89
|
+
- `{{overviewSection}}` - 概述章节
|
|
90
|
+
- `{{featuresSection}}` - 功能章节
|
|
91
|
+
- `{{technicalSection}}` - 技术章节
|
|
92
|
+
- `{{timelineSection}}` - 时间线章节
|
|
93
|
+
- `{{resourcesSection}}` - 资源章节
|
|
94
|
+
|
|
95
|
+
### 3. v1系统集成
|
|
96
|
+
|
|
97
|
+
```typescript
|
|
98
|
+
import { V1Integration } from '../src/requirement-analysis/integrations/v1-integration.js';
|
|
99
|
+
|
|
100
|
+
const integration = new V1Integration();
|
|
101
|
+
|
|
102
|
+
// 创建v1项目
|
|
103
|
+
const v1Project = await integration.createV1Project(analysisResult);
|
|
104
|
+
|
|
105
|
+
// 创建v1任务
|
|
106
|
+
const v1Tasks = await integration.createV1Tasks(analysisResult);
|
|
107
|
+
|
|
108
|
+
// 导出完整格式
|
|
109
|
+
const v1Export = await integration.exportToV1Format(analysisResult);
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
## 配置选项
|
|
113
|
+
|
|
114
|
+
### 分析选项
|
|
115
|
+
|
|
116
|
+
```typescript
|
|
117
|
+
interface AnalysisOptions {
|
|
118
|
+
// 是否包含技术栈分析(默认:true)
|
|
119
|
+
includeTechStack?: boolean;
|
|
120
|
+
|
|
121
|
+
// 是否生成PRD文档(默认:true)
|
|
122
|
+
generatePRD?: boolean;
|
|
123
|
+
|
|
124
|
+
// PRD模板路径(默认:内置模板)
|
|
125
|
+
prdTemplate?: string;
|
|
126
|
+
|
|
127
|
+
// 分析深度(默认:medium)
|
|
128
|
+
depth?: 'shallow' | 'medium' | 'deep';
|
|
129
|
+
|
|
130
|
+
// 排除的文件模式
|
|
131
|
+
excludePatterns?: string[];
|
|
132
|
+
|
|
133
|
+
// 自定义配置
|
|
134
|
+
customConfig?: Record<string, any>;
|
|
135
|
+
}
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
### 深度级别说明
|
|
139
|
+
|
|
140
|
+
**shallow(浅层)**
|
|
141
|
+
- 仅分析项目结构和基本信息
|
|
142
|
+
- 适合大型项目的快速概览
|
|
143
|
+
- 分析时间:< 30秒
|
|
144
|
+
|
|
145
|
+
**medium(中等)**
|
|
146
|
+
- 包含功能映射和技术栈分析
|
|
147
|
+
- 平衡分析质量和性能
|
|
148
|
+
- 分析时间:1-3分钟
|
|
149
|
+
|
|
150
|
+
**deep(深度)**
|
|
151
|
+
- 完整的代码分析和依赖关系
|
|
152
|
+
- 最高质量的分析结果
|
|
153
|
+
- 分析时间:3-10分钟
|
|
154
|
+
|
|
155
|
+
### 排除模式
|
|
156
|
+
|
|
157
|
+
```typescript
|
|
158
|
+
const options = {
|
|
159
|
+
excludePatterns: [
|
|
160
|
+
'node_modules',
|
|
161
|
+
'*.test.js',
|
|
162
|
+
'coverage',
|
|
163
|
+
'dist',
|
|
164
|
+
'.git',
|
|
165
|
+
'tmp'
|
|
166
|
+
]
|
|
167
|
+
};
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
## 自定义模板
|
|
171
|
+
|
|
172
|
+
### PRD模板格式
|
|
173
|
+
|
|
174
|
+
创建自定义PRD模板文件 `custom-prd-template.md`:
|
|
175
|
+
|
|
176
|
+
```markdown
|
|
177
|
+
# {{projectName}} 产品需求文档
|
|
178
|
+
|
|
179
|
+
## 项目信息
|
|
180
|
+
- **项目名称**: {{projectName}}
|
|
181
|
+
- **项目描述**: {{projectDescription}}
|
|
182
|
+
- **功能总数**: {{totalFeatures}}
|
|
183
|
+
- **预估工作量**: {{totalHours}} 小时
|
|
184
|
+
|
|
185
|
+
{{overviewSection}}
|
|
186
|
+
|
|
187
|
+
{{featuresSection}}
|
|
188
|
+
|
|
189
|
+
{{technicalSection}}
|
|
190
|
+
|
|
191
|
+
{{timelineSection}}
|
|
192
|
+
|
|
193
|
+
{{resourcesSection}}
|
|
194
|
+
|
|
195
|
+
## 附录
|
|
196
|
+
- 生成时间: {{timestamp}}
|
|
197
|
+
- 分析工具: v1需求分析技能
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
### 使用自定义模板
|
|
201
|
+
|
|
202
|
+
```typescript
|
|
203
|
+
const generator = new PRDGenerator('./templates/custom-prd-template.md');
|
|
204
|
+
const prd = await generator.generatePRD(projectInfo, featureMapping, techStack);
|
|
205
|
+
```
|
|
206
|
+
|
|
207
|
+
## 输出示例
|
|
208
|
+
|
|
209
|
+
### 分析结果概览
|
|
210
|
+
|
|
211
|
+
```json
|
|
212
|
+
{
|
|
213
|
+
"id": "analysis-1640995200000-abc123def",
|
|
214
|
+
"projectPath": "/Users/admin/my-project",
|
|
215
|
+
"timestamp": "2023-12-31T12:00:00.000Z",
|
|
216
|
+
"projectInfo": {
|
|
217
|
+
"name": "my-awesome-app",
|
|
218
|
+
"type": "web-app",
|
|
219
|
+
"primaryLanguages": ["TypeScript", "JavaScript"],
|
|
220
|
+
"maturity": "development"
|
|
221
|
+
},
|
|
222
|
+
"featureMapping": {
|
|
223
|
+
"summary": {
|
|
224
|
+
"totalFeatures": 8,
|
|
225
|
+
"totalEstimatedHours": 320,
|
|
226
|
+
"complexityDistribution": {
|
|
227
|
+
"3": 4,
|
|
228
|
+
"4": 3,
|
|
229
|
+
"5": 1
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
},
|
|
233
|
+
"qualityScore": {
|
|
234
|
+
"overall": 85,
|
|
235
|
+
"dimensions": {
|
|
236
|
+
"featureCompleteness": 90,
|
|
237
|
+
"technicalFeasibility": 85,
|
|
238
|
+
"requirementClarity": 80,
|
|
239
|
+
"complexityReasonableness": 85
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
```
|
|
244
|
+
|
|
245
|
+
### 功能映射示例
|
|
246
|
+
|
|
247
|
+
```json
|
|
248
|
+
{
|
|
249
|
+
"id": "core-auth",
|
|
250
|
+
"name": "用户认证系统",
|
|
251
|
+
"description": "实现用户登录、注册、权限管理功能",
|
|
252
|
+
"priority": 5,
|
|
253
|
+
"complexity": 3,
|
|
254
|
+
"estimatedHours": 40,
|
|
255
|
+
"category": "core",
|
|
256
|
+
"userStories": [
|
|
257
|
+
{
|
|
258
|
+
"id": "auth-login",
|
|
259
|
+
"asA": "用户",
|
|
260
|
+
"iWant": "能够登录系统",
|
|
261
|
+
"soThat": "访问个人功能",
|
|
262
|
+
"priority": 5
|
|
263
|
+
}
|
|
264
|
+
],
|
|
265
|
+
"acceptanceCriteria": [
|
|
266
|
+
"用户可以使用邮箱和密码登录",
|
|
267
|
+
"登录失败时显示错误信息",
|
|
268
|
+
"登录成功后跳转到主页"
|
|
269
|
+
]
|
|
270
|
+
}
|
|
271
|
+
```
|
|
272
|
+
|
|
273
|
+
## 错误处理
|
|
274
|
+
|
|
275
|
+
### 常见错误及解决方案
|
|
276
|
+
|
|
277
|
+
**1. 项目路径无效**
|
|
278
|
+
```
|
|
279
|
+
错误: 无法访问项目路径 /invalid/path
|
|
280
|
+
解决: 检查路径是否存在且有读取权限
|
|
281
|
+
```
|
|
282
|
+
|
|
283
|
+
**2. 内存不足**
|
|
284
|
+
```
|
|
285
|
+
错误: JavaScript heap out of memory
|
|
286
|
+
解决: 使用 shallow 分析深度或增加排除模式
|
|
287
|
+
```
|
|
288
|
+
|
|
289
|
+
**3. 模板加载失败**
|
|
290
|
+
```
|
|
291
|
+
错误: 无法加载模板文件
|
|
292
|
+
解决: 检查模板文件路径和格式
|
|
293
|
+
```
|
|
294
|
+
|
|
295
|
+
**4. v1集成失败**
|
|
296
|
+
```
|
|
297
|
+
错误: v1系统连接失败
|
|
298
|
+
解决: 检查v1系统状态和网络连接
|
|
299
|
+
```
|
|
300
|
+
|
|
301
|
+
### 错误处理最佳实践
|
|
302
|
+
|
|
303
|
+
```typescript
|
|
304
|
+
try {
|
|
305
|
+
const result = await analyzer.analyzeRequirements(projectPath, options);
|
|
306
|
+
console.log('分析成功:', result.id);
|
|
307
|
+
} catch (error) {
|
|
308
|
+
if (error.code === 'ENOENT') {
|
|
309
|
+
console.error('项目路径不存在:', projectPath);
|
|
310
|
+
} else if (error.code === 'EACCES') {
|
|
311
|
+
console.error('权限不足,无法访问:', projectPath);
|
|
312
|
+
} else {
|
|
313
|
+
console.error('分析失败:', error.message);
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
```
|
|
317
|
+
|
|
318
|
+
## 性能优化
|
|
319
|
+
|
|
320
|
+
### 大型项目处理
|
|
321
|
+
|
|
322
|
+
```typescript
|
|
323
|
+
// 对于大型项目,使用浅层分析
|
|
324
|
+
const options = {
|
|
325
|
+
depth: 'shallow',
|
|
326
|
+
excludePatterns: [
|
|
327
|
+
'node_modules',
|
|
328
|
+
'dist',
|
|
329
|
+
'build',
|
|
330
|
+
'*.min.js',
|
|
331
|
+
'coverage'
|
|
332
|
+
]
|
|
333
|
+
};
|
|
334
|
+
|
|
335
|
+
const result = await analyzer.analyzeRequirements(projectPath, options);
|
|
336
|
+
```
|
|
337
|
+
|
|
338
|
+
### 缓存机制
|
|
339
|
+
|
|
340
|
+
```typescript
|
|
341
|
+
// 启用分析结果缓存
|
|
342
|
+
const options = {
|
|
343
|
+
customConfig: {
|
|
344
|
+
enableCache: true,
|
|
345
|
+
cacheDir: './analysis-cache',
|
|
346
|
+
cacheTTL: 3600 // 1小时
|
|
347
|
+
}
|
|
348
|
+
};
|
|
349
|
+
```
|
|
350
|
+
|
|
351
|
+
### 并行处理
|
|
352
|
+
|
|
353
|
+
```typescript
|
|
354
|
+
// 批量分析多个项目
|
|
355
|
+
const projects = ['/path/to/project1', '/path/to/project2'];
|
|
356
|
+
const results = await Promise.all(
|
|
357
|
+
projects.map(path => analyzer.analyzeRequirements(path))
|
|
358
|
+
);
|
|
359
|
+
```
|
|
360
|
+
|
|
361
|
+
## 集成示例
|
|
362
|
+
|
|
363
|
+
### 与CI/CD集成
|
|
364
|
+
|
|
365
|
+
```yaml
|
|
366
|
+
# .github/workflows/requirement-analysis.yml
|
|
367
|
+
name: Requirement Analysis
|
|
368
|
+
on:
|
|
369
|
+
push:
|
|
370
|
+
branches: [main]
|
|
371
|
+
|
|
372
|
+
jobs:
|
|
373
|
+
analyze:
|
|
374
|
+
runs-on: ubuntu-latest
|
|
375
|
+
steps:
|
|
376
|
+
- uses: actions/checkout@v2
|
|
377
|
+
- name: Setup Node.js
|
|
378
|
+
uses: actions/setup-node@v2
|
|
379
|
+
with:
|
|
380
|
+
node-version: '18'
|
|
381
|
+
- name: Install dependencies
|
|
382
|
+
run: npm install
|
|
383
|
+
- name: Run requirement analysis
|
|
384
|
+
run: npm run analyze-requirements . --export-v1
|
|
385
|
+
- name: Upload results
|
|
386
|
+
uses: actions/upload-artifact@v2
|
|
387
|
+
with:
|
|
388
|
+
name: analysis-results
|
|
389
|
+
path: analysis-results.json
|
|
390
|
+
```
|
|
391
|
+
|
|
392
|
+
### 与Webhook集成
|
|
393
|
+
|
|
394
|
+
```typescript
|
|
395
|
+
// webhook-handler.js
|
|
396
|
+
import express from 'express';
|
|
397
|
+
import { V1Integration } from './src/requirement-analysis/integrations/v1-integration.js';
|
|
398
|
+
|
|
399
|
+
const app = express();
|
|
400
|
+
const analyzer = new V1Integration();
|
|
401
|
+
|
|
402
|
+
app.post('/analyze', async (req, res) => {
|
|
403
|
+
try {
|
|
404
|
+
const { projectPath, options } = req.body;
|
|
405
|
+
const result = await analyzer.analyzeRequirements(projectPath, options);
|
|
406
|
+
|
|
407
|
+
// 发送结果到v1系统
|
|
408
|
+
await sendToV1System(result);
|
|
409
|
+
|
|
410
|
+
res.json({ success: true, analysisId: result.id });
|
|
411
|
+
} catch (error) {
|
|
412
|
+
res.status(500).json({ error: error.message });
|
|
413
|
+
}
|
|
414
|
+
});
|
|
415
|
+
```
|
|
416
|
+
|
|
417
|
+
## 故障排除
|
|
418
|
+
|
|
419
|
+
### 调试模式
|
|
420
|
+
|
|
421
|
+
```typescript
|
|
422
|
+
// 启用详细日志
|
|
423
|
+
const options = {
|
|
424
|
+
customConfig: {
|
|
425
|
+
debug: true,
|
|
426
|
+
logLevel: 'verbose'
|
|
427
|
+
}
|
|
428
|
+
};
|
|
429
|
+
|
|
430
|
+
const result = await analyzer.analyzeRequirements(projectPath, options);
|
|
431
|
+
```
|
|
432
|
+
|
|
433
|
+
### 性能监控
|
|
434
|
+
|
|
435
|
+
```typescript
|
|
436
|
+
// 监控分析性能
|
|
437
|
+
console.time('analysis');
|
|
438
|
+
const result = await analyzer.analyzeRequirements(projectPath);
|
|
439
|
+
console.timeEnd('analysis');
|
|
440
|
+
|
|
441
|
+
console.log('分析统计:', {
|
|
442
|
+
filesAnalyzed: result.projectInfo.codebaseStats.totalFiles,
|
|
443
|
+
linesAnalyzed: result.projectInfo.codebaseStats.totalLines,
|
|
444
|
+
featuresGenerated: result.featureMapping.summary.totalFeatures
|
|
445
|
+
});
|
|
446
|
+
```
|
|
447
|
+
|
|
448
|
+
## 更新日志
|
|
449
|
+
|
|
450
|
+
### v1.0.0 (2024-01-01)
|
|
451
|
+
- 初始版本发布
|
|
452
|
+
- 支持基本项目分析
|
|
453
|
+
- PRD文档生成
|
|
454
|
+
- v1系统集成
|
|
455
|
+
|
|
456
|
+
### v1.1.0 (计划中)
|
|
457
|
+
- 增强代码分析能力
|
|
458
|
+
- 支持更多项目类型
|
|
459
|
+
- 改进PRD模板系统
|
|
460
|
+
- 性能优化
|
|
461
|
+
|
|
462
|
+
---
|
|
463
|
+
|
|
464
|
+
如有问题或建议,请提交Issue或联系开发团队。
|
|
@@ -0,0 +1,224 @@
|
|
|
1
|
+
# 需求分析技能 (Requirement Analysis Skill)
|
|
2
|
+
|
|
3
|
+
## 技能概述
|
|
4
|
+
|
|
5
|
+
需求分析技能是一个智能化的项目需求分析工具,能够通过分析现有代码库自动生成功能映射、技术栈分析和产品需求文档(PRD)。该技能专门为 v1 看板系统设计,提供从代码到需求的逆向工程能力。
|
|
6
|
+
|
|
7
|
+
## 核心功能
|
|
8
|
+
|
|
9
|
+
### 1. 项目信息解析
|
|
10
|
+
- 自动识别项目类型(Web应用、API服务、CLI工具等)
|
|
11
|
+
- 分析代码库规模和语言分布
|
|
12
|
+
- 评估项目成熟度和技术债务
|
|
13
|
+
|
|
14
|
+
### 2. 功能映射生成
|
|
15
|
+
- 基于代码结构推断功能模块
|
|
16
|
+
- 生成用户故事和验收标准
|
|
17
|
+
- 建立功能依赖关系图
|
|
18
|
+
- 评估开发复杂度和工作量
|
|
19
|
+
|
|
20
|
+
### 3. 技术栈分析
|
|
21
|
+
- 检测现有技术栈和版本信息
|
|
22
|
+
- 分析技术栈兼容性
|
|
23
|
+
- 提供技术升级建议
|
|
24
|
+
- 识别潜在技术风险
|
|
25
|
+
|
|
26
|
+
### 4. PRD 自动生成
|
|
27
|
+
- 生成结构化的产品需求文档
|
|
28
|
+
- 包含项目概述、功能需求、技术需求
|
|
29
|
+
- 提供实施时间线和资源需求
|
|
30
|
+
- 支持自定义模板
|
|
31
|
+
|
|
32
|
+
### 5. v1 系统集成
|
|
33
|
+
- 与 v1 任务管理系统无缝集成
|
|
34
|
+
- 自动创建项目和任务
|
|
35
|
+
- 支持现有项目的需求补充
|
|
36
|
+
- 提供质量评分和改进建议
|
|
37
|
+
|
|
38
|
+
## 使用场景
|
|
39
|
+
|
|
40
|
+
### 场景1:新项目需求分析
|
|
41
|
+
当用户提供一个项目路径,需要生成完整的需求文档时:
|
|
42
|
+
|
|
43
|
+
```
|
|
44
|
+
用户:请分析 /path/to/project 的需求,生成PRD文档
|
|
45
|
+
助手:我来为您分析项目需求并生成PRD文档...
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
### 场景2:现有项目功能梳理
|
|
49
|
+
当用户需要梳理现有项目的功能模块时:
|
|
50
|
+
|
|
51
|
+
```
|
|
52
|
+
用户:帮我分析这个项目有哪些功能模块,生成功能清单
|
|
53
|
+
助手:我来分析项目的功能模块结构...
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
### 场景3:技术栈评估
|
|
57
|
+
当用户需要评估项目的技术栈选择时:
|
|
58
|
+
|
|
59
|
+
```
|
|
60
|
+
用户:分析一下这个项目的技术栈,给出优化建议
|
|
61
|
+
助手:我来分析项目的技术栈并提供优化建议...
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
### 场景4:项目迁移到v1
|
|
65
|
+
当用户想要将现有项目迁移到v1管理时:
|
|
66
|
+
|
|
67
|
+
```
|
|
68
|
+
用户:我想把这个项目迁移到v1系统管理
|
|
69
|
+
助手:我来分析项目并创建v1项目和任务...
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
## 触发条件
|
|
73
|
+
|
|
74
|
+
该技能在以下情况下被触发:
|
|
75
|
+
|
|
76
|
+
1. **关键词触发**:
|
|
77
|
+
- "需求分析"、"requirement analysis"
|
|
78
|
+
- "生成PRD"、"产品需求文档"
|
|
79
|
+
- "功能映射"、"feature mapping"
|
|
80
|
+
- "技术栈分析"、"tech stack analysis"
|
|
81
|
+
- "项目分析"、"project analysis"
|
|
82
|
+
|
|
83
|
+
2. **路径触发**:
|
|
84
|
+
- 用户提供项目路径并要求分析
|
|
85
|
+
- 用户上传项目文件并要求分析
|
|
86
|
+
|
|
87
|
+
3. **集成触发**:
|
|
88
|
+
- 用户要求创建v1项目
|
|
89
|
+
- 用户要求从代码生成任务
|
|
90
|
+
|
|
91
|
+
## 工作流程
|
|
92
|
+
|
|
93
|
+
### 阶段1:项目信息收集
|
|
94
|
+
1. 验证项目路径有效性
|
|
95
|
+
2. 解析项目基本信息
|
|
96
|
+
3. 分析代码库结构和统计信息
|
|
97
|
+
4. 识别主要编程语言和框架
|
|
98
|
+
|
|
99
|
+
### 阶段2:深度分析
|
|
100
|
+
1. 生成功能映射和依赖关系
|
|
101
|
+
2. 分析技术栈兼容性
|
|
102
|
+
3. 评估项目复杂度和风险
|
|
103
|
+
4. 计算工作量估算
|
|
104
|
+
|
|
105
|
+
### 阶段3:文档生成
|
|
106
|
+
1. 根据模板生成PRD文档
|
|
107
|
+
2. 创建功能清单和用户故事
|
|
108
|
+
3. 生成技术建议和架构指导
|
|
109
|
+
4. 提供实施时间线
|
|
110
|
+
|
|
111
|
+
### 阶段4:系统集成
|
|
112
|
+
1. 创建v1兼容的项目结构
|
|
113
|
+
2. 生成任务列表和依赖关系
|
|
114
|
+
3. 设置项目配置和元数据
|
|
115
|
+
4. 提供质量评分和改进建议
|
|
116
|
+
|
|
117
|
+
## 配置选项
|
|
118
|
+
|
|
119
|
+
```typescript
|
|
120
|
+
interface AnalysisOptions {
|
|
121
|
+
includeTechStack?: boolean; // 是否包含技术栈分析
|
|
122
|
+
generatePRD?: boolean; // 是否生成PRD文档
|
|
123
|
+
prdTemplate?: string; // PRD模板路径
|
|
124
|
+
depth?: 'shallow' | 'medium' | 'deep'; // 分析深度
|
|
125
|
+
excludePatterns?: string[]; // 排除的文件模式
|
|
126
|
+
customConfig?: Record<string, any>; // 自定义配置
|
|
127
|
+
}
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
## 输出格式
|
|
131
|
+
|
|
132
|
+
### 分析结果结构
|
|
133
|
+
```typescript
|
|
134
|
+
interface RequirementAnalysisResult {
|
|
135
|
+
id: string; // 分析ID
|
|
136
|
+
projectPath: string; // 项目路径
|
|
137
|
+
timestamp: Date; // 分析时间
|
|
138
|
+
projectInfo: ProjectInfo; // 项目基本信息
|
|
139
|
+
featureMapping: FeatureMappingResult; // 功能映射
|
|
140
|
+
techStack: TechStackAnalysis; // 技术栈分析
|
|
141
|
+
prd: PRDResult; // PRD文档
|
|
142
|
+
qualityScore: QualityScore; // 质量评分
|
|
143
|
+
}
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
### PRD文档章节
|
|
147
|
+
1. **项目概述** - 项目基本信息和目标
|
|
148
|
+
2. **功能需求** - 详细功能列表和用户故事
|
|
149
|
+
3. **技术需求** - 技术栈要求和架构建议
|
|
150
|
+
4. **实施时间线** - 开发阶段和里程碑
|
|
151
|
+
5. **资源需求** - 人力资源和技术资源需求
|
|
152
|
+
|
|
153
|
+
## 质量保证
|
|
154
|
+
|
|
155
|
+
### 分析质量评分
|
|
156
|
+
- **功能完整性** (0-100):功能识别的完整程度
|
|
157
|
+
- **技术可行性** (0-100):技术方案的可行性
|
|
158
|
+
- **需求清晰度** (0-100):需求描述的清晰程度
|
|
159
|
+
- **复杂度合理性** (0-100):复杂度评估的合理性
|
|
160
|
+
|
|
161
|
+
### 改进建议
|
|
162
|
+
系统会根据质量评分自动生成改进建议:
|
|
163
|
+
- 功能模块补充建议
|
|
164
|
+
- 技术栈优化建议
|
|
165
|
+
- 需求文档完善建议
|
|
166
|
+
- 复杂度调整建议
|
|
167
|
+
|
|
168
|
+
## 扩展能力
|
|
169
|
+
|
|
170
|
+
### 自定义模板
|
|
171
|
+
支持自定义PRD模板,用户可以:
|
|
172
|
+
- 修改文档结构和章节
|
|
173
|
+
- 添加特定行业的需求模板
|
|
174
|
+
- 集成企业标准文档格式
|
|
175
|
+
|
|
176
|
+
### 插件机制
|
|
177
|
+
支持扩展分析器和生成器:
|
|
178
|
+
- 自定义代码分析规则
|
|
179
|
+
- 添加特定框架的识别逻辑
|
|
180
|
+
- 集成第三方分析工具
|
|
181
|
+
|
|
182
|
+
### API集成
|
|
183
|
+
提供标准API接口:
|
|
184
|
+
- RESTful API for 外部系统集成
|
|
185
|
+
- Webhook支持实时通知
|
|
186
|
+
- 批量分析接口
|
|
187
|
+
|
|
188
|
+
## 最佳实践
|
|
189
|
+
|
|
190
|
+
### 使用建议
|
|
191
|
+
1. **项目准备**:确保项目代码完整且可访问
|
|
192
|
+
2. **配置优化**:根据项目规模选择合适的分析深度
|
|
193
|
+
3. **模板定制**:为不同类型项目准备专用模板
|
|
194
|
+
4. **结果验证**:人工审核自动生成的需求文档
|
|
195
|
+
|
|
196
|
+
### 常见问题
|
|
197
|
+
1. **分析失败**:检查项目路径和权限
|
|
198
|
+
2. **结果不准确**:调整分析深度和排除模式
|
|
199
|
+
3. **性能问题**:对大型项目使用浅层分析
|
|
200
|
+
4. **集成问题**:确保v1系统版本兼容
|
|
201
|
+
|
|
202
|
+
## 技术实现
|
|
203
|
+
|
|
204
|
+
### 核心模块
|
|
205
|
+
- `RepositoryParser`:项目解析器
|
|
206
|
+
- `PRDGenerator`:PRD文档生成器
|
|
207
|
+
- `V1Integration`:v1系统集成
|
|
208
|
+
- `TechStackAnalyzer`:技术栈分析器
|
|
209
|
+
|
|
210
|
+
### 依赖关系
|
|
211
|
+
- Node.js文件系统API
|
|
212
|
+
- TypeScript类型系统
|
|
213
|
+
- v1核心模块
|
|
214
|
+
- 模板引擎
|
|
215
|
+
|
|
216
|
+
### 性能优化
|
|
217
|
+
- 异步文件处理
|
|
218
|
+
- 智能缓存机制
|
|
219
|
+
- 增量分析支持
|
|
220
|
+
- 并行处理优化
|
|
221
|
+
|
|
222
|
+
---
|
|
223
|
+
|
|
224
|
+
*该技能为v1看板系统的核心功能之一,持续优化中。如有问题或建议,请联系开发团队。*
|