sqlew 2.1.3 → 3.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/CHANGELOG.md +891 -535
- package/README.md +302 -613
- package/assets/kanban-style.png +0 -0
- package/assets/schema.sql +531 -402
- package/dist/database.d.ts +9 -0
- package/dist/database.d.ts.map +1 -1
- package/dist/database.js +33 -34
- package/dist/database.js.map +1 -1
- package/dist/index.js +1024 -21
- package/dist/index.js.map +1 -1
- package/dist/migrations/add-task-tables.d.ts +47 -0
- package/dist/migrations/add-task-tables.d.ts.map +1 -0
- package/dist/migrations/add-task-tables.js +285 -0
- package/dist/migrations/add-task-tables.js.map +1 -0
- package/dist/migrations/index.d.ts +96 -0
- package/dist/migrations/index.d.ts.map +1 -0
- package/dist/migrations/index.js +239 -0
- package/dist/migrations/index.js.map +1 -0
- package/dist/migrations/migrate-decisions-to-tasks.d.ts +61 -0
- package/dist/migrations/migrate-decisions-to-tasks.d.ts.map +1 -0
- package/dist/migrations/migrate-decisions-to-tasks.js +442 -0
- package/dist/migrations/migrate-decisions-to-tasks.js.map +1 -0
- package/dist/schema.d.ts.map +1 -1
- package/dist/schema.js +14 -3
- package/dist/schema.js.map +1 -1
- package/dist/tools/constraints.d.ts +4 -0
- package/dist/tools/constraints.d.ts.map +1 -1
- package/dist/tools/constraints.js +6 -27
- package/dist/tools/constraints.js.map +1 -1
- package/dist/tools/context.d.ts +17 -1
- package/dist/tools/context.d.ts.map +1 -1
- package/dist/tools/context.js +195 -190
- package/dist/tools/context.js.map +1 -1
- package/dist/tools/files.d.ts.map +1 -1
- package/dist/tools/files.js +113 -166
- package/dist/tools/files.js.map +1 -1
- package/dist/tools/messaging.d.ts +2 -9
- package/dist/tools/messaging.d.ts.map +1 -1
- package/dist/tools/messaging.js +67 -126
- package/dist/tools/messaging.js.map +1 -1
- package/dist/tools/tasks.d.ts +90 -0
- package/dist/tools/tasks.d.ts.map +1 -0
- package/dist/tools/tasks.js +732 -0
- package/dist/tools/tasks.js.map +1 -0
- package/dist/tools/utils.d.ts +8 -1
- package/dist/tools/utils.d.ts.map +1 -1
- package/dist/tools/utils.js +50 -21
- package/dist/tools/utils.js.map +1 -1
- package/dist/types.d.ts +14 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/utils/batch.d.ts +69 -0
- package/dist/utils/batch.d.ts.map +1 -0
- package/dist/utils/batch.js +148 -0
- package/dist/utils/batch.js.map +1 -0
- package/dist/utils/query-builder.d.ts +68 -0
- package/dist/utils/query-builder.d.ts.map +1 -0
- package/dist/utils/query-builder.js +116 -0
- package/dist/utils/query-builder.js.map +1 -0
- package/dist/utils/task-stale-detection.d.ts +28 -0
- package/dist/utils/task-stale-detection.d.ts.map +1 -0
- package/dist/utils/task-stale-detection.js +92 -0
- package/dist/utils/task-stale-detection.js.map +1 -0
- package/dist/utils/validators.d.ts +57 -0
- package/dist/utils/validators.d.ts.map +1 -0
- package/dist/utils/validators.js +117 -0
- package/dist/utils/validators.js.map +1 -0
- package/docs/AI_AGENT_GUIDE.md +1471 -0
- package/{ARCHITECTURE.md → docs/ARCHITECTURE.md} +636 -636
- package/docs/BEST_PRACTICES.md +481 -0
- package/docs/DECISION_TO_TASK_MIGRATION_GUIDE.md +457 -0
- package/docs/MIGRATION_CHAIN.md +280 -0
- package/{MIGRATION_v2.md → docs/MIGRATION_v2.md} +538 -538
- package/docs/SHARED_CONCEPTS.md +339 -0
- package/docs/TASK_ACTIONS.md +854 -0
- package/docs/TASK_LINKING.md +729 -0
- package/docs/TASK_MIGRATION.md +701 -0
- package/docs/TASK_OVERVIEW.md +363 -0
- package/docs/TASK_SYSTEM.md +1244 -0
- package/docs/TOOL_REFERENCE.md +471 -0
- package/docs/TOOL_SELECTION.md +279 -0
- package/docs/WORKFLOWS.md +602 -0
- package/docs/refactoring-summary-2025-10-17.md +365 -0
- package/docs/requirement-2025-10-17.md +508 -0
- package/package.json +64 -63
|
@@ -0,0 +1,457 @@
|
|
|
1
|
+
# Decision to Task Migration Guide for LLMs
|
|
2
|
+
|
|
3
|
+
## Overview
|
|
4
|
+
|
|
5
|
+
This guide helps AI agents migrate decisions from the `decision` tool to the `task` tool when appropriate. The task system (v3.0.0) provides 70% token efficiency for actionable items compared to decisions.
|
|
6
|
+
|
|
7
|
+
**Key Insight**: Not all decisions should become tasks. Only actionable, implementation-oriented decisions benefit from migration.
|
|
8
|
+
|
|
9
|
+
## When to Convert: Decision vs Task
|
|
10
|
+
|
|
11
|
+
### ✅ Convert to Task (Actionable Items)
|
|
12
|
+
|
|
13
|
+
Decisions with these characteristics should become tasks:
|
|
14
|
+
|
|
15
|
+
1. **Implementation Work**
|
|
16
|
+
- "Implement X feature"
|
|
17
|
+
- "Refactor Y module"
|
|
18
|
+
- "Fix Z bug"
|
|
19
|
+
- Keywords: implement, build, create, refactor, fix, add, develop
|
|
20
|
+
|
|
21
|
+
2. **Work-in-Progress (WIP)**
|
|
22
|
+
- Decisions prefixed with "WIP:"
|
|
23
|
+
- Decisions with "TODO:" or "IN PROGRESS:"
|
|
24
|
+
- Example: `wip_add_logging|WIP: Adding structured logging to all services`
|
|
25
|
+
|
|
26
|
+
3. **Phase/Milestone Work**
|
|
27
|
+
- Decisions describing implementation phases
|
|
28
|
+
- Example: `phase2_sample_reference_complete|Phase 2.1 Sample Reference System complete`
|
|
29
|
+
- **Note**: Completed phases can become `done` or `archived` tasks for tracking
|
|
30
|
+
|
|
31
|
+
4. **Test Tasks**
|
|
32
|
+
- Decisions created for testing purposes
|
|
33
|
+
- Example: `test_task_decision|Use Jest for testing`
|
|
34
|
+
|
|
35
|
+
### ❌ Keep as Decision (Knowledge/Documentation)
|
|
36
|
+
|
|
37
|
+
Decisions with these characteristics should remain decisions:
|
|
38
|
+
|
|
39
|
+
1. **Documentation/Explanation**
|
|
40
|
+
- Explains how a system works
|
|
41
|
+
- Describes patterns or best practices
|
|
42
|
+
- Keywords: pattern, example, guide, explanation, documentation
|
|
43
|
+
- Example: `motifs_v2_pattern_batch_generation|Batch generation pattern: Generate multiple...`
|
|
44
|
+
|
|
45
|
+
2. **Architectural Decisions**
|
|
46
|
+
- Records why a choice was made
|
|
47
|
+
- Example: `api/synthesis/oscillator-type-moved|Moved oscillator_type from base SynthConfig...`
|
|
48
|
+
|
|
49
|
+
3. **Status Reports**
|
|
50
|
+
- Records what was implemented (past tense)
|
|
51
|
+
- Example: `phase3_actual_implementation_status|Phase 3 ACTUALLY IMPLEMENTED...`
|
|
52
|
+
|
|
53
|
+
4. **Parameter/Configuration Documentation**
|
|
54
|
+
- Explains how parameters work
|
|
55
|
+
- Example: `motifs_v2_fabric_emotion_motif_length|Emotion parameter controls motif length...`
|
|
56
|
+
|
|
57
|
+
5. **Troubleshooting Guides**
|
|
58
|
+
- Diagnostic information
|
|
59
|
+
- Example: `motifs_v2_troubleshooting_no_notes|Troubleshooting: No notes generated...`
|
|
60
|
+
|
|
61
|
+
6. **Deprecated/Migrated Documentation**
|
|
62
|
+
- Records migration history
|
|
63
|
+
- Example: `docs_hierarchical_fabric_system_md|DEPRECATED: Documentation file...`
|
|
64
|
+
|
|
65
|
+
## Migration Process
|
|
66
|
+
|
|
67
|
+
### Step 1: Query Decisions
|
|
68
|
+
|
|
69
|
+
Use the `decision` MCP tool to list active decisions:
|
|
70
|
+
|
|
71
|
+
```javascript
|
|
72
|
+
{
|
|
73
|
+
action: "list",
|
|
74
|
+
status: "active",
|
|
75
|
+
limit: 100
|
|
76
|
+
}
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
### Step 2: Analyze Each Decision
|
|
80
|
+
|
|
81
|
+
For each decision, ask these questions:
|
|
82
|
+
|
|
83
|
+
1. **Is it actionable?** (Does it describe work to be done?)
|
|
84
|
+
2. **Is it complete?** (If complete, should it be archived or kept as knowledge?)
|
|
85
|
+
3. **Is it a duplicate?** (Check if a task already exists)
|
|
86
|
+
4. **What's the status?** (todo, in_progress, done, blocked?)
|
|
87
|
+
|
|
88
|
+
### Step 3: Extract Task Metadata
|
|
89
|
+
|
|
90
|
+
From the decision, extract:
|
|
91
|
+
|
|
92
|
+
- **Title**: Short, actionable (50 chars max)
|
|
93
|
+
- **Description**: Full decision value (optional, can be long)
|
|
94
|
+
- **Status**: Map decision status to task status
|
|
95
|
+
- Decision: `active` + WIP → Task: `in_progress`
|
|
96
|
+
- Decision: `active` + not WIP → Task: `todo`
|
|
97
|
+
- Decision: `active` + completed → Task: `done`
|
|
98
|
+
- Decision: `deprecated` → Task: `archived`
|
|
99
|
+
- **Priority**: Infer from urgency/importance (1=low, 2=medium, 3=high, 4=critical)
|
|
100
|
+
- **Layer**: Preserve from decision (presentation, business, data, infrastructure, cross-cutting)
|
|
101
|
+
- **Tags**: Preserve from decision
|
|
102
|
+
- **Assigned Agent**: Map from decision's `decided_by_agent`
|
|
103
|
+
|
|
104
|
+
### Step 4: Create Task
|
|
105
|
+
|
|
106
|
+
Use the `task` MCP tool:
|
|
107
|
+
|
|
108
|
+
```javascript
|
|
109
|
+
{
|
|
110
|
+
action: "create",
|
|
111
|
+
title: "Implement sample reference generator",
|
|
112
|
+
description: "Implemented sample reference generator with instrument-specific note ranges and Fabric-driven density. Generator produces SampleReference metadata for Sampler and Granular synths.",
|
|
113
|
+
status: "done", // Completed phase
|
|
114
|
+
priority: 3, // High priority (phase work)
|
|
115
|
+
assigned_agent: "system",
|
|
116
|
+
layer: "data",
|
|
117
|
+
tags: ["phase2", "sample-reference", "fabric"]
|
|
118
|
+
}
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
### Step 5: Link to Original Decision
|
|
122
|
+
|
|
123
|
+
After creating the task, link it to the original decision:
|
|
124
|
+
|
|
125
|
+
```javascript
|
|
126
|
+
{
|
|
127
|
+
action: "link",
|
|
128
|
+
task_id: 123,
|
|
129
|
+
link_type: "decision",
|
|
130
|
+
target_id: "phase2_sample_reference_generator", // Decision key
|
|
131
|
+
link_relation: "migrated_from"
|
|
132
|
+
}
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
### Step 6: Hard-Delete Unnecessary Decisions
|
|
136
|
+
|
|
137
|
+
**IMPORTANT:** For pure actionable items (WIP, TODO, implementation tasks), use **hard-delete** to permanently remove them and reduce database bloat.
|
|
138
|
+
|
|
139
|
+
**Recommended: Hard-Delete** (For pure WIP/task items with no knowledge value)
|
|
140
|
+
```javascript
|
|
141
|
+
{
|
|
142
|
+
action: "hard_delete",
|
|
143
|
+
key: "wip_add_logging"
|
|
144
|
+
}
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
**Rationale:**
|
|
148
|
+
- Prevents deprecated decision bloat
|
|
149
|
+
- Tasks are now the source of truth
|
|
150
|
+
- Task links maintain traceability
|
|
151
|
+
- 70 records removed per decision (decision + tags + scopes + version history)
|
|
152
|
+
|
|
153
|
+
**Alternative: Keep and Update** (ONLY for decisions with knowledge value)
|
|
154
|
+
```javascript
|
|
155
|
+
{
|
|
156
|
+
action: "set",
|
|
157
|
+
key: "phase2_sample_reference_generator",
|
|
158
|
+
value: "Knowledge: Sample reference generator uses instrument-specific ranges (Piano: C3-C6, Bass: E1-E3, ...) and Fabric-driven density. Implementation tracked in task #123.",
|
|
159
|
+
status: "active"
|
|
160
|
+
}
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
**When to use each:**
|
|
164
|
+
- **Hard-delete:** WIP items, test tasks, pure implementation work (95% of migrations)
|
|
165
|
+
- **Keep & Update:** Decisions that also document "why" or have architectural insight (5% of migrations)
|
|
166
|
+
|
|
167
|
+
## Example Migrations
|
|
168
|
+
|
|
169
|
+
### Example 1: WIP Decision → In-Progress Task
|
|
170
|
+
|
|
171
|
+
**Before (Decision):**
|
|
172
|
+
```
|
|
173
|
+
key: wip_add_logging
|
|
174
|
+
value: WIP: Adding structured logging to all services
|
|
175
|
+
layer: infrastructure
|
|
176
|
+
agent: test-agent
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
**After (Task):**
|
|
180
|
+
```javascript
|
|
181
|
+
{
|
|
182
|
+
action: "create",
|
|
183
|
+
title: "Add structured logging to all services",
|
|
184
|
+
description: "Implementing structured logging system across all microservices",
|
|
185
|
+
status: "in_progress",
|
|
186
|
+
priority: 2,
|
|
187
|
+
assigned_agent: "test-agent",
|
|
188
|
+
layer: "infrastructure",
|
|
189
|
+
tags: ["logging", "infrastructure"]
|
|
190
|
+
}
|
|
191
|
+
// Then link and hard-delete decision
|
|
192
|
+
{
|
|
193
|
+
action: "link",
|
|
194
|
+
task_id: 8,
|
|
195
|
+
link_type: "decision",
|
|
196
|
+
target_id: "wip_add_logging",
|
|
197
|
+
link_relation: "migrated_from"
|
|
198
|
+
}
|
|
199
|
+
{
|
|
200
|
+
action: "hard_delete",
|
|
201
|
+
key: "wip_add_logging"
|
|
202
|
+
}
|
|
203
|
+
```
|
|
204
|
+
|
|
205
|
+
### Example 2: Completed Phase → Done Task
|
|
206
|
+
|
|
207
|
+
**Before (Decision):**
|
|
208
|
+
```
|
|
209
|
+
key: phase2_sample_reference_complete
|
|
210
|
+
value: Phase 2.1 Sample Reference System complete: SampleReference struct, generator with instrument-specific ranges, Fabric-driven density, 13 passing tests (8 unit + 5 integration)
|
|
211
|
+
layer: data
|
|
212
|
+
```
|
|
213
|
+
|
|
214
|
+
**After (Task):**
|
|
215
|
+
```javascript
|
|
216
|
+
{
|
|
217
|
+
action: "create",
|
|
218
|
+
title: "Phase 2.1: Sample Reference System",
|
|
219
|
+
description: "SampleReference struct, generator with instrument-specific ranges, Fabric-driven density, 13 passing tests (8 unit + 5 integration)",
|
|
220
|
+
acceptance_criteria: "- SampleReference struct implemented\n- Instrument-specific ranges\n- Fabric-driven density\n- 13 passing tests",
|
|
221
|
+
status: "done",
|
|
222
|
+
priority: 3,
|
|
223
|
+
assigned_agent: "system",
|
|
224
|
+
layer: "data",
|
|
225
|
+
tags: ["phase2", "sample-reference", "testing"]
|
|
226
|
+
}
|
|
227
|
+
```
|
|
228
|
+
|
|
229
|
+
### Example 3: Knowledge Decision → Keep as Decision
|
|
230
|
+
|
|
231
|
+
**Keep This (Don't Convert):**
|
|
232
|
+
```
|
|
233
|
+
key: motifs_v2_fabric_emotion_motif_length
|
|
234
|
+
value: Emotion parameter controls motif length in MotifsV2Pipeline. Range: -1.0 to 3.0...
|
|
235
|
+
layer: business
|
|
236
|
+
```
|
|
237
|
+
|
|
238
|
+
**Reason**: This is documentation explaining how a parameter works. It's knowledge, not an action item.
|
|
239
|
+
|
|
240
|
+
## Batch Migration Strategy
|
|
241
|
+
|
|
242
|
+
For large-scale migration, use batch operations:
|
|
243
|
+
|
|
244
|
+
```javascript
|
|
245
|
+
// Step 1: Query all WIP decisions
|
|
246
|
+
{
|
|
247
|
+
action: "search_advanced",
|
|
248
|
+
search_text: "WIP:",
|
|
249
|
+
status: ["active"],
|
|
250
|
+
limit: 100
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
// Step 2: Create tasks in batch
|
|
254
|
+
{
|
|
255
|
+
action: "batch_create",
|
|
256
|
+
tasks: [
|
|
257
|
+
{
|
|
258
|
+
title: "Task 1",
|
|
259
|
+
status: "in_progress",
|
|
260
|
+
priority: 2,
|
|
261
|
+
// ...
|
|
262
|
+
},
|
|
263
|
+
{
|
|
264
|
+
title: "Task 2",
|
|
265
|
+
status: "todo",
|
|
266
|
+
priority: 1,
|
|
267
|
+
// ...
|
|
268
|
+
}
|
|
269
|
+
],
|
|
270
|
+
atomic: false // Best-effort for AI agents
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
// Step 3: Link tasks to decisions
|
|
274
|
+
for (let i = 0; i < createdTasks.length; i++) {
|
|
275
|
+
{
|
|
276
|
+
action: "link",
|
|
277
|
+
task_id: createdTasks[i].id,
|
|
278
|
+
link_type: "decision",
|
|
279
|
+
target_id: wip_decisions[i].key,
|
|
280
|
+
link_relation: "migrated_from"
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
// Step 4: Hard-delete migrated decisions (no batch API, do individually)
|
|
285
|
+
for (const decision of wip_decisions) {
|
|
286
|
+
{
|
|
287
|
+
action: "hard_delete",
|
|
288
|
+
key: decision.key
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
```
|
|
292
|
+
|
|
293
|
+
## Token Efficiency Analysis
|
|
294
|
+
|
|
295
|
+
**Decision Storage:**
|
|
296
|
+
- Key: ~30 bytes
|
|
297
|
+
- Value: ~300 bytes (avg)
|
|
298
|
+
- Metadata: ~50 bytes
|
|
299
|
+
- **Total: ~380 bytes per decision**
|
|
300
|
+
|
|
301
|
+
**Task Storage (Metadata-Only Query):**
|
|
302
|
+
- Title: ~50 bytes
|
|
303
|
+
- Status/Priority: ~10 bytes
|
|
304
|
+
- Layer/Tags: ~30 bytes
|
|
305
|
+
- **Total: ~90 bytes per task (76% reduction)**
|
|
306
|
+
|
|
307
|
+
**For 200 decisions → tasks migration:**
|
|
308
|
+
- Before: 200 × 380 = 76,000 bytes
|
|
309
|
+
- After: 200 × 90 = 18,000 bytes
|
|
310
|
+
- **Savings: 58,000 bytes (76% reduction) for list queries**
|
|
311
|
+
|
|
312
|
+
## Common Pitfalls
|
|
313
|
+
|
|
314
|
+
### ❌ Pitfall 1: Converting All Decisions
|
|
315
|
+
|
|
316
|
+
**Wrong**: Migrate all 202 decisions to tasks
|
|
317
|
+
|
|
318
|
+
**Right**: Migrate only ~10-20 actionable decisions, keep rest as knowledge
|
|
319
|
+
|
|
320
|
+
### ❌ Pitfall 2: Losing Context
|
|
321
|
+
|
|
322
|
+
**Wrong**: Hard-delete decision WITHOUT linking first
|
|
323
|
+
|
|
324
|
+
**Right**: Link task to decision FIRST, then hard-delete decision
|
|
325
|
+
|
|
326
|
+
**Correct Order:**
|
|
327
|
+
1. Create task
|
|
328
|
+
2. Link task to decision (`task.link` action)
|
|
329
|
+
3. Hard-delete decision (`decision.hard_delete` action)
|
|
330
|
+
|
|
331
|
+
This maintains traceability through task links while eliminating bloat.
|
|
332
|
+
|
|
333
|
+
### ❌ Pitfall 3: Wrong Status Mapping
|
|
334
|
+
|
|
335
|
+
**Wrong**: All decisions → `todo` tasks
|
|
336
|
+
|
|
337
|
+
**Right**: Map correctly:
|
|
338
|
+
- WIP → `in_progress`
|
|
339
|
+
- Completed → `done` or `archived`
|
|
340
|
+
- Planned → `todo`
|
|
341
|
+
- Blocked → `blocked`
|
|
342
|
+
|
|
343
|
+
### ❌ Pitfall 4: Ignoring Layers/Tags
|
|
344
|
+
|
|
345
|
+
**Wrong**: Create tasks without layer/tags
|
|
346
|
+
|
|
347
|
+
**Right**: Preserve metadata for filtering and organization
|
|
348
|
+
|
|
349
|
+
## Verification Checklist
|
|
350
|
+
|
|
351
|
+
After migration, verify:
|
|
352
|
+
|
|
353
|
+
- [ ] All actionable decisions converted to tasks
|
|
354
|
+
- [ ] Knowledge decisions remain as decisions
|
|
355
|
+
- [ ] Tasks linked to original decisions (BEFORE deletion)
|
|
356
|
+
- [ ] Original decisions hard-deleted (reduces bloat by ~70 records per decision)
|
|
357
|
+
- [ ] Status mapping correct (WIP → in_progress, etc.)
|
|
358
|
+
- [ ] Priority assigned based on urgency
|
|
359
|
+
- [ ] Layer and tags preserved
|
|
360
|
+
- [ ] No duplicate tasks created
|
|
361
|
+
- [ ] Database integrity verified (no orphaned records)
|
|
362
|
+
|
|
363
|
+
## Automated Migration Script (Pseudo-code)
|
|
364
|
+
|
|
365
|
+
```javascript
|
|
366
|
+
async function migrateDecisionsToTasks(db) {
|
|
367
|
+
// 1. Get all active decisions
|
|
368
|
+
const decisions = await mcp.decision({
|
|
369
|
+
action: "list",
|
|
370
|
+
status: "active",
|
|
371
|
+
limit: 500
|
|
372
|
+
});
|
|
373
|
+
|
|
374
|
+
const tasksToCreate = [];
|
|
375
|
+
const decisionsToUpdate = [];
|
|
376
|
+
|
|
377
|
+
for (const decision of decisions) {
|
|
378
|
+
// 2. Determine if actionable
|
|
379
|
+
const isActionable =
|
|
380
|
+
decision.key.startsWith("wip_") ||
|
|
381
|
+
decision.value.match(/^WIP:/i) ||
|
|
382
|
+
decision.value.match(/^TODO:/i) ||
|
|
383
|
+
decision.value.match(/^(Implement|Build|Create|Refactor|Fix|Add)/i);
|
|
384
|
+
|
|
385
|
+
if (!isActionable) continue; // Keep as decision
|
|
386
|
+
|
|
387
|
+
// 3. Extract metadata
|
|
388
|
+
const task = {
|
|
389
|
+
title: extractTitle(decision),
|
|
390
|
+
description: decision.value,
|
|
391
|
+
status: decision.key.startsWith("wip_") ? "in_progress" : "todo",
|
|
392
|
+
priority: inferPriority(decision),
|
|
393
|
+
assigned_agent: decision.agent || "system",
|
|
394
|
+
layer: decision.layer,
|
|
395
|
+
tags: decision.tags || []
|
|
396
|
+
};
|
|
397
|
+
|
|
398
|
+
tasksToCreate.push(task);
|
|
399
|
+
|
|
400
|
+
// 4. Mark for hard-deletion
|
|
401
|
+
decisionsToUpdate.push({
|
|
402
|
+
key: decision.key,
|
|
403
|
+
original: decision.value,
|
|
404
|
+
shouldHardDelete: true
|
|
405
|
+
});
|
|
406
|
+
}
|
|
407
|
+
|
|
408
|
+
// 5. Create tasks
|
|
409
|
+
const createdTasks = await mcp.task({
|
|
410
|
+
action: "batch_create",
|
|
411
|
+
tasks: tasksToCreate,
|
|
412
|
+
atomic: false
|
|
413
|
+
});
|
|
414
|
+
|
|
415
|
+
// 6. Link and hard-delete
|
|
416
|
+
for (let i = 0; i < createdTasks.length; i++) {
|
|
417
|
+
const task = createdTasks[i];
|
|
418
|
+
const decision = decisionsToUpdate[i];
|
|
419
|
+
|
|
420
|
+
// Link (maintains traceability)
|
|
421
|
+
await mcp.task({
|
|
422
|
+
action: "link",
|
|
423
|
+
task_id: task.id,
|
|
424
|
+
link_type: "decision",
|
|
425
|
+
target_id: decision.key,
|
|
426
|
+
link_relation: "migrated_from"
|
|
427
|
+
});
|
|
428
|
+
|
|
429
|
+
// Hard-delete (removes bloat)
|
|
430
|
+
await mcp.decision({
|
|
431
|
+
action: "hard_delete",
|
|
432
|
+
key: decision.key
|
|
433
|
+
});
|
|
434
|
+
}
|
|
435
|
+
|
|
436
|
+
return {
|
|
437
|
+
migrated: createdTasks.length,
|
|
438
|
+
kept: decisions.length - createdTasks.length
|
|
439
|
+
};
|
|
440
|
+
}
|
|
441
|
+
```
|
|
442
|
+
|
|
443
|
+
## Summary
|
|
444
|
+
|
|
445
|
+
**Key Principles:**
|
|
446
|
+
1. **Not all decisions are tasks** - Only actionable items should migrate
|
|
447
|
+
2. **Preserve context** - Link tasks to original decisions BEFORE deletion
|
|
448
|
+
3. **Hard-delete unnecessary decisions** - Reduces bloat (~70 records per decision)
|
|
449
|
+
4. **Map status correctly** - WIP → in_progress, completed → done
|
|
450
|
+
5. **Maintain metadata** - Preserve layers, tags, priority
|
|
451
|
+
6. **Verify results** - Check token efficiency and data integrity
|
|
452
|
+
|
|
453
|
+
**Expected Results:**
|
|
454
|
+
- 202 decisions → ~10-20 tasks (5-10% migration rate)
|
|
455
|
+
- Remaining ~180-190 decisions stay as knowledge/documentation
|
|
456
|
+
- 70% token efficiency for task list queries
|
|
457
|
+
- Better task management with status tracking and auto-stale detection
|