flowmind 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (47) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +855 -0
  3. package/README_CN.md +854 -0
  4. package/bin/flowmind.js +464 -0
  5. package/core/adapters/api-doc-adapter.js +71 -0
  6. package/core/adapters/base-adapter.js +80 -0
  7. package/core/adapters/database-manager-adapter.js +60 -0
  8. package/core/adapters/database-query-adapter.js +51 -0
  9. package/core/adapters/knowledge-base-adapter.js +75 -0
  10. package/core/adapters/log-service-adapter.js +41 -0
  11. package/core/adapters/mcp-adapter.js +65 -0
  12. package/core/adapters/report-adapter.js +60 -0
  13. package/core/adapters/workflow-adapter.js +62 -0
  14. package/core/component-registry.js +281 -0
  15. package/core/component-types.js +63 -0
  16. package/core/config-manager.js +360 -0
  17. package/core/index.js +223 -0
  18. package/core/learning-engine.js +588 -0
  19. package/core/mcp-compatibility.js +150 -0
  20. package/core/providers/aliyun/dms-adapter.js +98 -0
  21. package/core/providers/aliyun/redis-adapter.js +88 -0
  22. package/core/providers/aliyun/sls-adapter.js +86 -0
  23. package/core/providers/friday/flow-adapter.js +85 -0
  24. package/core/providers/friday/report-adapter.js +83 -0
  25. package/core/providers/yapi/yapi-adapter.js +79 -0
  26. package/core/providers/yuque/yuque-adapter.js +90 -0
  27. package/core/scene-matcher.js +326 -0
  28. package/core/skill-loader.js +291 -0
  29. package/package.json +67 -0
  30. package/scripts/migrate-config.js +153 -0
  31. package/skills/api-sync/SKILL.md +203 -0
  32. package/skills/archive-change/SKILL.md +172 -0
  33. package/skills/auto-flow/SKILL.md +277 -0
  34. package/skills/code-review/SKILL.md +206 -0
  35. package/skills/code-review-audit/SKILL.md +150 -0
  36. package/skills/data-logic-validation/SKILL.md +162 -0
  37. package/skills/data-validation/SKILL.md +210 -0
  38. package/skills/git-review/SKILL.md +190 -0
  39. package/skills/learning-engine/SKILL.md +352 -0
  40. package/skills/learning-feedback/SKILL.md +174 -0
  41. package/skills/log-audit/SKILL.md +226 -0
  42. package/skills/project-review/SKILL.md +196 -0
  43. package/skills/requirement-analyst/SKILL.md +275 -0
  44. package/skills/resource-bind/SKILL.md +222 -0
  45. package/skills/sls-log-audit/SKILL.md +223 -0
  46. package/skills/yapi-sync-interface/SKILL.md +145 -0
  47. package/skills/yuque-sync-design/SKILL.md +157 -0
@@ -0,0 +1,352 @@
1
+ ---
2
+ name: learning-engine
3
+ description: Core learning engine that powers FlowMind's ability to learn from user corrections and preferences. This is the heart of FlowMind's intelligence.
4
+ metadata:
5
+ version: "1.0.0"
6
+ author: flowmind
7
+ category: core
8
+ priority: highest
9
+ ---
10
+
11
+ # FlowMind Learning Engine
12
+
13
+ The core intelligence that makes FlowMind learn and adapt to your workflow.
14
+
15
+ ## How Learning Works
16
+
17
+ ### The Learning Loop
18
+
19
+ ```mermaid
20
+ graph TD
21
+ A[User Request] --> B[FlowMind Executes]
22
+ B --> C{User Feedback?}
23
+ C -->|Correction| D[Capture Learning]
24
+ C -->|Confirmation| E[Reinforce Learning]
25
+ C -->|No Feedback| F[Continue]
26
+ D --> G[Store Learning]
27
+ E --> G
28
+ G --> H[Apply Next Time]
29
+ H --> A
30
+ ```
31
+
32
+ ### Learning Types
33
+
34
+ | Type | Trigger | Example |
35
+ |------|---------|---------|
36
+ | **Correction** | User corrects output | "不对,用表格格式" |
37
+ | **Refinement** | User improves process | "先查错误再查链路" |
38
+ | **Preference** | User specifies style | "用中文回复" |
39
+ | **Scene Mapping** | User defines workflow | "这类需求走xxx流程" |
40
+
41
+ ## Learning Storage
42
+
43
+ ### Directory Structure
44
+
45
+ ```
46
+ ~/.flowmind/learning/
47
+ ├── records/ # Learning records by skill
48
+ │ ├── log-audit/
49
+ │ │ ├── 2026-06-22-001.json
50
+ │ │ └── 2026-06-22-002.json
51
+ │ ├── code-review/
52
+ │ └── _global/
53
+ ├── scenes.json # Scene-skill mappings
54
+ ├── skill-bindings.json # Skill learning bindings
55
+ └── stats.json # Learning statistics
56
+ ```
57
+
58
+ ### Learning Record Format
59
+
60
+ ```json
61
+ {
62
+ "id": "learn-20260622-001",
63
+ "timestamp": "2026-06-22T10:30:00Z",
64
+ "skill": "log-audit",
65
+ "type": "output_format",
66
+ "severity": "major",
67
+ "context": {
68
+ "userRequest": "查询 traceId 日志",
69
+ "executionContext": "Log audit skill execution"
70
+ },
71
+ "correction": {
72
+ "original": "Tree format output",
73
+ "corrected": "Sequential list format",
74
+ "reason": "User prefers chronological view"
75
+ },
76
+ "application": {
77
+ "condition": "When outputting trace results",
78
+ "action": "Use sequential list format",
79
+ "priority": "high"
80
+ },
81
+ "verification": {
82
+ "verified": true,
83
+ "verifiedAt": "2026-06-22T10:31:00Z"
84
+ },
85
+ "stats": {
86
+ "appliedCount": 5,
87
+ "successCount": 5
88
+ }
89
+ }
90
+ ```
91
+
92
+ ### Scene Mapping Format
93
+
94
+ ```json
95
+ {
96
+ "version": "1.0",
97
+ "mappings": [
98
+ {
99
+ "id": "scene-001",
100
+ "name": "Trace Log Query",
101
+ "keywords": ["traceId", "日志", "链路", "trace"],
102
+ "patterns": [
103
+ "查询.*traceId.*日志",
104
+ "查看.*链路"
105
+ ],
106
+ "workflow": {
107
+ "skills": ["log-audit"],
108
+ "params": {
109
+ "format": "sequential-list",
110
+ "includeRequest": true,
111
+ "includeResponse": true
112
+ }
113
+ },
114
+ "preferences": {
115
+ "outputFormat": "sequential-list",
116
+ "language": "zh-CN"
117
+ },
118
+ "stats": {
119
+ "useCount": 10,
120
+ "lastUsed": "2026-06-22T15:00:00Z",
121
+ "successRate": 1.0
122
+ }
123
+ }
124
+ ]
125
+ }
126
+ ```
127
+
128
+ ## Learning Process
129
+
130
+ ### Step 1: Detect Learning Opportunity
131
+
132
+ ```javascript
133
+ function detectLearning(input, context) {
134
+ // Check for correction patterns
135
+ if (isCorrectionPattern(input)) {
136
+ return { type: 'correction', ... };
137
+ }
138
+
139
+ // Check for scene mapping patterns
140
+ if (isSceneMappingPattern(input)) {
141
+ return { type: 'scene_mapping', ... };
142
+ }
143
+
144
+ // Check for preference patterns
145
+ if (isPreferencePattern(input)) {
146
+ return { type: 'preference', ... };
147
+ }
148
+
149
+ return null;
150
+ }
151
+ ```
152
+
153
+ ### Step 2: Capture Context
154
+
155
+ ```javascript
156
+ function captureContext(userRequest, executionResult) {
157
+ return {
158
+ userRequest: userRequest,
159
+ executionContext: executionResult.context,
160
+ timestamp: new Date().toISOString(),
161
+ skill: executionResult.skill
162
+ };
163
+ }
164
+ ```
165
+
166
+ ### Step 3: Create Learning Record
167
+
168
+ ```javascript
169
+ function createLearningRecord(context, correction) {
170
+ const record = {
171
+ id: generateId(),
172
+ timestamp: new Date().toISOString(),
173
+ skill: context.skill,
174
+ type: correction.type,
175
+ context: context,
176
+ correction: correction,
177
+ application: generateApplicationRule(correction)
178
+ };
179
+
180
+ return saveLearningRecord(record);
181
+ }
182
+ ```
183
+
184
+ ### Step 4: Update Bindings
185
+
186
+ ```javascript
187
+ function updateSkillBindings(skill, record) {
188
+ const bindings = loadSkillBindings();
189
+
190
+ if (!bindings[skill]) {
191
+ bindings[skill] = { records: [], rules: [] };
192
+ }
193
+
194
+ bindings[skill].records.push(record.id);
195
+ bindings[skill].rules.push(record.application);
196
+
197
+ saveSkillBindings(bindings);
198
+ }
199
+ ```
200
+
201
+ ## Knowledge Application
202
+
203
+ ### Pre-Execution Check
204
+
205
+ Before executing any task:
206
+
207
+ ```javascript
208
+ async function executeWithLearning(request, context) {
209
+ // 1. Check scene mappings
210
+ const sceneMatch = matchScene(request);
211
+ if (sceneMatch && sceneMatch.confidence >= 0.7) {
212
+ return applySceneWorkflow(sceneMatch, request);
213
+ }
214
+
215
+ // 2. Check skill learning bindings
216
+ const skill = selectSkill(request);
217
+ const learnings = getSkillLearnings(skill);
218
+
219
+ // 3. Apply learnings
220
+ let result = await executeSkill(skill, request, context);
221
+ result = applyLearnings(result, learnings);
222
+
223
+ return result;
224
+ }
225
+ ```
226
+
227
+ ### Matching Algorithm
228
+
229
+ ```javascript
230
+ function matchScene(request) {
231
+ const scenes = loadScenes();
232
+ let bestMatch = null;
233
+ let bestScore = 0;
234
+
235
+ for (const scene of scenes) {
236
+ const score = calculateMatchScore(request, scene);
237
+ if (score > bestScore) {
238
+ bestScore = score;
239
+ bestMatch = scene;
240
+ }
241
+ }
242
+
243
+ return bestScore >= 0.7 ? bestMatch : null;
244
+ }
245
+
246
+ function calculateMatchScore(request, scene) {
247
+ const keywordScore = matchKeywords(request, scene.keywords) * 0.4;
248
+ const patternScore = matchPatterns(request, scene.patterns) * 0.3;
249
+ const historyScore = (scene.stats.useCount / 100) * 0.2;
250
+ const confidenceScore = scene.stats.successRate * 0.1;
251
+
252
+ return keywordScore + patternScore + historyScore + confidenceScore;
253
+ }
254
+ ```
255
+
256
+ ## User Confirmation
257
+
258
+ When learning is captured:
259
+
260
+ ```
261
+ ┌─────────────────────────────────────────────────────┐
262
+ │ 🧠 Learning Captured │
263
+ ├─────────────────────────────────────────────────────┤
264
+ │ ID: learn-20260622-001 │
265
+ │ Skill: log-audit │
266
+ │ Type: output_format │
267
+ ├─────────────────────────────────────────────────────┤
268
+ │ Your preference has been recorded. │
269
+ │ FlowMind will apply this automatically next time. │
270
+ └─────────────────────────────────────────────────────┘
271
+ ```
272
+
273
+ When learning is applied:
274
+
275
+ ```
276
+ ┌─────────────────────────────────────────────────────┐
277
+ │ ✨ Applying Learned Workflow │
278
+ ├─────────────────────────────────────────────────────┤
279
+ │ Based on: learn-20260622-001 │
280
+ │ Applied: 5 times │
281
+ │ Success rate: 100% │
282
+ ├─────────────────────────────────────────────────────┤
283
+ │ Using your preferred: sequential list format │
284
+ └─────────────────────────────────────────────────────┘
285
+ ```
286
+
287
+ ## Management Commands
288
+
289
+ ### View Learnings
290
+
291
+ ```bash
292
+ flowmind learn list [--skill <name>] [--type <type>]
293
+ ```
294
+
295
+ ### View Scenes
296
+
297
+ ```bash
298
+ flowmind scenes list
299
+ ```
300
+
301
+ ### Delete Learning
302
+
303
+ ```bash
304
+ flowmind learn delete <id>
305
+ ```
306
+
307
+ ### Reset Skill
308
+
309
+ ```bash
310
+ flowmind learn reset <skill>
311
+ ```
312
+
313
+ ### Export/Import
314
+
315
+ ```bash
316
+ flowmind learn export [--output <file>]
317
+ flowmind learn import <file>
318
+ ```
319
+
320
+ ## Privacy & Security
321
+
322
+ - **Local Only**: All learning data stored locally
323
+ - **No Cloud**: Nothing sent to external servers
324
+ - **User Control**: Full control over all data
325
+ - **Encryption**: Optional encryption for sensitive data
326
+
327
+ ## Best Practices
328
+
329
+ 1. **Be Specific**: More specific corrections = better learning
330
+ 2. **Confirm Patterns**: Verify learned patterns are correct
331
+ 3. **Review Regularly**: Check and clean old learnings
332
+ 4. **Share Knowledge**: Export and share with team
333
+
334
+ ## Troubleshooting
335
+
336
+ ### Learning Not Applying
337
+
338
+ 1. Check if learning exists: `flowmind learn list`
339
+ 2. Verify confidence threshold in config
340
+ 3. Check skill bindings
341
+
342
+ ### Wrong Behavior
343
+
344
+ 1. Review scene mappings: `flowmind scenes list`
345
+ 2. Check learning records
346
+ 3. Reset if needed: `flowmind learn reset <skill>`
347
+
348
+ ### Performance Issues
349
+
350
+ 1. Limit learning records per skill
351
+ 2. Archive old learnings
352
+ 3. Clean up unused scenes
@@ -0,0 +1,174 @@
1
+ ---
2
+ name: learning-feedback
3
+ description: Global learning skill for FlowMind. Captures user corrections, feedback, and refined processing logic. Automatically binds learning to relevant skills for future application.
4
+ metadata:
5
+ version: "1.0.0"
6
+ author: flowmind
7
+ category: core
8
+ priority: global
9
+ ---
10
+
11
+ # Learning Feedback Skill
12
+
13
+ Global learning skill that captures user corrections, feedback, and refined processing logic. Learning records are automatically bound to relevant skills for future application.
14
+
15
+ ## Features
16
+
17
+ ### Correction Learning
18
+ - Captures user corrections ("不对", "错了", "应该是")
19
+ - Records original vs corrected approach
20
+ - Binds learning to affected skills
21
+
22
+ ### Refinement Learning
23
+ - Captures optimization suggestions ("优化一下", "改进")
24
+ - Records processing logic refinements
25
+ - Applies to future similar tasks
26
+
27
+ ### Scene-Skill Mapping
28
+ - Records user-specified handling preferences
29
+ - Auto-applies on matching scenes
30
+ - Supports complex multi-skill workflows
31
+
32
+ ### Knowledge Application
33
+ - Pre-execution learning check
34
+ - Automatic correction application
35
+ - Learning effectiveness tracking
36
+
37
+ ## Trigger Patterns
38
+
39
+ ```
40
+ "不对", "错了", "应该是", "正确的是"
41
+ "不是这样", "重新处理", "修改为"
42
+ "你应该...", "需要...", "改成..."
43
+ "更准确的做法是", "更好的方式是"
44
+ "优化一下", "改进", "调整"
45
+ "流程不对", "顺序错了", "逻辑有问题"
46
+ "先...再...", "应该先..."
47
+ "记住这个方式", "下次直接这样"
48
+ "按照上次的方式处理"
49
+ ```
50
+
51
+ ## Output Format
52
+
53
+ ```
54
+ ┌─────────────────────────────────────────────────────┐
55
+ │ ✅ Learning Record Saved │
56
+ ├─────────────────────────────────────────────────────┤
57
+ │ Record ID: {uuid} │
58
+ │ Skill: {affected-skill} │
59
+ │ Type: {correction-type} │
60
+ ├─────────────────────────────────────────────────────┤
61
+ │ Original: {brief-summary} │
62
+ │ Corrected: {brief-summary} │
63
+ ├─────────────────────────────────────────────────────┤
64
+ │ This learning will be auto-applied in future tasks │
65
+ └─────────────────────────────────────────────────────┘
66
+ ```
67
+
68
+ ## Learning Types
69
+
70
+ | Type | Description | Example |
71
+ |------|-------------|---------|
72
+ | output_format | Output format correction | "用表格格式" |
73
+ | logic_flow | Processing logic correction | "先查错误再查链路" |
74
+ | data_accuracy | Data accuracy correction | "source_id 不是 host" |
75
+ | skill_execution | Skill execution correction | "应该用 SLS 技能" |
76
+ | query_syntax | Query syntax correction | "用 PromQL 不是 SQL" |
77
+
78
+ ## Scene Mapping
79
+
80
+ ### Scene Detection
81
+
82
+ ```
83
+ User Input → Keyword Extraction → Pattern Matching → Scene Match
84
+
85
+ [Match] → Apply Recorded Workflow
86
+ [No Match] → Normal Flow → Record if Confirmed
87
+ ```
88
+
89
+ ### Scene Mapping Examples
90
+
91
+ ```
92
+ 场景: 查询TraceId链路
93
+ 关键词: traceId, 链路, 调用链
94
+ 技能: sls-log-audit
95
+ 偏好: 顺序列表格式
96
+
97
+ → 自动应用: 使用 sls-log-audit,输出顺序列表
98
+ ```
99
+
100
+ ## Learning Storage
101
+
102
+ ```
103
+ ~/.flowmind/learning/
104
+ ├── records/ # Learning records
105
+ │ ├── _global/ # Global learning
106
+ │ ├── code-review/ # Per-skill learning
107
+ │ └── log-audit/
108
+ ├── skill-bindings.json # Skill binding mapping
109
+ ├── scene-mappings.json # Scene-skill mappings
110
+ └── stats.json # Learning statistics
111
+ ```
112
+
113
+ ## Learning Integration
114
+
115
+ This skill is a **global skill** that enhances all other skills:
116
+
117
+ - Before executing any skill, check for applicable learning
118
+ - Apply learned corrections automatically
119
+ - Track learning effectiveness over time
120
+
121
+ ## Examples
122
+
123
+ ### Example 1: Output Format Correction
124
+
125
+ ```
126
+ User: 查询 traceId abc123 的日志
127
+ FlowMind: [Returns tree format]
128
+ User: 不对,应该用顺序列表格式
129
+
130
+ FlowMind:
131
+ ┌─────────────────────────────────────────────────────┐
132
+ │ ✅ Learning Record Saved │
133
+ ├─────────────────────────────────────────────────────┤
134
+ │ Skill: log-audit │
135
+ │ Type: output_format │
136
+ │ Original: Tree format │
137
+ │ Corrected: Sequential list format │
138
+ ├─────────────────────────────────────────────────────┤
139
+ │ Future log queries will use sequential list format │
140
+ └─────────────────────────────────────────────────────┘
141
+ ```
142
+
143
+ ### Example 2: Scene Mapping
144
+
145
+ ```
146
+ User: 排查线上问题先查错误日志,再查链路,最后查代码
147
+
148
+ FlowMind:
149
+ ┌─────────────────────────────────────────────────────┐
150
+ │ ✅ Scene Mapping Saved │
151
+ ├─────────────────────────────────────────────────────┤
152
+ │ Scene: 线上问题排查 │
153
+ │ Keywords: 排查, 线上问题, 故障排查 │
154
+ │ Skill Sequence: │
155
+ │ 1. log-audit (错误日志) │
156
+ │ 2. log-audit (链路分析) │
157
+ │ 3. code-review (代码审查) │
158
+ ├─────────────────────────────────────────────────────┤
159
+ │ Next time will auto-apply this workflow │
160
+ └─────────────────────────────────────────────────────┘
161
+ ```
162
+
163
+ ## Configuration
164
+
165
+ ```json
166
+ {
167
+ "learning-feedback": {
168
+ "autoApply": true,
169
+ "confidenceThreshold": 0.7,
170
+ "maxRecordsPerSkill": 100,
171
+ "archiveAfterDays": 90
172
+ }
173
+ }
174
+ ```