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,729 @@
|
|
|
1
|
+
# Task Linking Guide
|
|
2
|
+
|
|
3
|
+
**Version:** 3.0.0
|
|
4
|
+
**Last Updated:** 2025-10-17
|
|
5
|
+
|
|
6
|
+
## Table of Contents
|
|
7
|
+
|
|
8
|
+
1. [Overview](#overview)
|
|
9
|
+
2. [Link Types](#link-types)
|
|
10
|
+
3. [Decision Links](#decision-links)
|
|
11
|
+
4. [Constraint Links](#constraint-links)
|
|
12
|
+
5. [File Links](#file-links)
|
|
13
|
+
6. [Querying Links](#querying-links)
|
|
14
|
+
7. [Linking Strategies](#linking-strategies)
|
|
15
|
+
8. [Best Practices](#best-practices)
|
|
16
|
+
9. [Related Documentation](#related-documentation)
|
|
17
|
+
|
|
18
|
+
## Overview
|
|
19
|
+
|
|
20
|
+
Tasks can be linked to three types of entities to establish context and relationships:
|
|
21
|
+
- **Decisions:** Track which architectural decisions relate to this task
|
|
22
|
+
- **Constraints:** Associate performance/security/architecture constraints
|
|
23
|
+
- **Files:** Connect to modified files for context
|
|
24
|
+
|
|
25
|
+
**Benefits of Linking:**
|
|
26
|
+
- **Context Preservation:** See related decisions/constraints/files when viewing task
|
|
27
|
+
- **Traceability:** Track which tasks implement which decisions
|
|
28
|
+
- **Impact Analysis:** Find tasks affected by constraint changes
|
|
29
|
+
- **Code Navigation:** Jump to files related to a task
|
|
30
|
+
|
|
31
|
+
## Link Types
|
|
32
|
+
|
|
33
|
+
### Available Link Types
|
|
34
|
+
|
|
35
|
+
| Link Type | Target Entity | Required Parameter | Example |
|
|
36
|
+
|-----------|--------------|-------------------|---------|
|
|
37
|
+
| `decision` | Context Decision | `link_key` (string) | `"auth_method"` |
|
|
38
|
+
| `constraint` | System Constraint | `link_id` (number) | `5` |
|
|
39
|
+
| `file` | File Path | `link_path` (string) | `"/src/auth/jwt.ts"` |
|
|
40
|
+
|
|
41
|
+
### Basic Syntax
|
|
42
|
+
|
|
43
|
+
```javascript
|
|
44
|
+
{
|
|
45
|
+
action: "link",
|
|
46
|
+
task_id: 1,
|
|
47
|
+
link_type: "decision" | "constraint" | "file",
|
|
48
|
+
// Type-specific parameter:
|
|
49
|
+
link_key: "...", // For decision
|
|
50
|
+
link_id: 123, // For constraint
|
|
51
|
+
link_path: "..." // For file
|
|
52
|
+
}
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
## Decision Links
|
|
56
|
+
|
|
57
|
+
### When to Use
|
|
58
|
+
|
|
59
|
+
Link tasks to decisions when:
|
|
60
|
+
- Task implements an architectural decision
|
|
61
|
+
- Task is affected by a design choice
|
|
62
|
+
- Task needs context from a decision document
|
|
63
|
+
|
|
64
|
+
### Examples
|
|
65
|
+
|
|
66
|
+
**Linking to Authentication Decision:**
|
|
67
|
+
```javascript
|
|
68
|
+
// Decision exists: auth_method = "JWT with refresh tokens"
|
|
69
|
+
|
|
70
|
+
// Task: Implement JWT authentication
|
|
71
|
+
{
|
|
72
|
+
action: "create",
|
|
73
|
+
title: "Implement JWT authentication",
|
|
74
|
+
description: "Add JWT-based auth with refresh token support",
|
|
75
|
+
priority: "high",
|
|
76
|
+
tags: ["security", "authentication"],
|
|
77
|
+
layer: "business"
|
|
78
|
+
}
|
|
79
|
+
// Returns: { task_id: 1 }
|
|
80
|
+
|
|
81
|
+
// Link to decision
|
|
82
|
+
{
|
|
83
|
+
action: "link",
|
|
84
|
+
task_id: 1,
|
|
85
|
+
link_type: "decision",
|
|
86
|
+
link_key: "auth_method"
|
|
87
|
+
}
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
**Multiple Decision Links:**
|
|
91
|
+
```javascript
|
|
92
|
+
// Task affects multiple decisions
|
|
93
|
+
{
|
|
94
|
+
action: "link",
|
|
95
|
+
task_id: 1,
|
|
96
|
+
link_type: "decision",
|
|
97
|
+
link_key: "auth_method"
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
{
|
|
101
|
+
action: "link",
|
|
102
|
+
task_id: 1,
|
|
103
|
+
link_type: "decision",
|
|
104
|
+
link_key: "jwt_secret_rotation"
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
{
|
|
108
|
+
action: "link",
|
|
109
|
+
task_id: 1,
|
|
110
|
+
link_type: "decision",
|
|
111
|
+
link_key: "token_expiry_time"
|
|
112
|
+
}
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
### Use Cases
|
|
116
|
+
|
|
117
|
+
**Implementation Task:**
|
|
118
|
+
```javascript
|
|
119
|
+
// Decision: Use PostgreSQL for database
|
|
120
|
+
// Task: Setup PostgreSQL database
|
|
121
|
+
|
|
122
|
+
{
|
|
123
|
+
action: "link",
|
|
124
|
+
task_id: 5,
|
|
125
|
+
link_type: "decision",
|
|
126
|
+
link_key: "database_choice"
|
|
127
|
+
}
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
**Refactoring Task:**
|
|
131
|
+
```javascript
|
|
132
|
+
// Decision: Migrate from REST to GraphQL
|
|
133
|
+
// Task: Refactor API endpoints to GraphQL
|
|
134
|
+
|
|
135
|
+
{
|
|
136
|
+
action: "link",
|
|
137
|
+
task_id: 8,
|
|
138
|
+
link_type: "decision",
|
|
139
|
+
link_key: "api_architecture"
|
|
140
|
+
}
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
**Investigation Task:**
|
|
144
|
+
```javascript
|
|
145
|
+
// Decision: Evaluate caching strategies
|
|
146
|
+
// Task: Research Redis vs Memcached
|
|
147
|
+
|
|
148
|
+
{
|
|
149
|
+
action: "link",
|
|
150
|
+
task_id: 12,
|
|
151
|
+
link_type: "decision",
|
|
152
|
+
link_key: "caching_strategy"
|
|
153
|
+
}
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
## Constraint Links
|
|
157
|
+
|
|
158
|
+
### When to Use
|
|
159
|
+
|
|
160
|
+
Link tasks to constraints when:
|
|
161
|
+
- Task addresses a performance/security/architecture constraint
|
|
162
|
+
- Task is blocked by a constraint
|
|
163
|
+
- Task validates constraint compliance
|
|
164
|
+
|
|
165
|
+
### Examples
|
|
166
|
+
|
|
167
|
+
**Performance Constraint:**
|
|
168
|
+
```javascript
|
|
169
|
+
// Constraint exists: "API response time <100ms" (ID: 5)
|
|
170
|
+
|
|
171
|
+
// Task: Optimize database queries
|
|
172
|
+
{
|
|
173
|
+
action: "create",
|
|
174
|
+
title: "Optimize database queries for user listing",
|
|
175
|
+
description: "Reduce query time from 250ms to <100ms",
|
|
176
|
+
priority: "high",
|
|
177
|
+
tags: ["performance", "database"],
|
|
178
|
+
layer: "data"
|
|
179
|
+
}
|
|
180
|
+
// Returns: { task_id: 2 }
|
|
181
|
+
|
|
182
|
+
// Link to constraint
|
|
183
|
+
{
|
|
184
|
+
action: "link",
|
|
185
|
+
task_id: 2,
|
|
186
|
+
link_type: "constraint",
|
|
187
|
+
link_id: 5
|
|
188
|
+
}
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
**Security Constraint:**
|
|
192
|
+
```javascript
|
|
193
|
+
// Constraint exists: "All API endpoints must use HTTPS" (ID: 8)
|
|
194
|
+
|
|
195
|
+
// Task: Enforce HTTPS on all routes
|
|
196
|
+
{
|
|
197
|
+
action: "create",
|
|
198
|
+
title: "Enforce HTTPS on all API routes",
|
|
199
|
+
priority: "critical",
|
|
200
|
+
tags: ["security", "api"],
|
|
201
|
+
layer: "infrastructure"
|
|
202
|
+
}
|
|
203
|
+
// Returns: { task_id: 3 }
|
|
204
|
+
|
|
205
|
+
// Link to constraint
|
|
206
|
+
{
|
|
207
|
+
action: "link",
|
|
208
|
+
task_id: 3,
|
|
209
|
+
link_type: "constraint",
|
|
210
|
+
link_id: 8
|
|
211
|
+
}
|
|
212
|
+
```
|
|
213
|
+
|
|
214
|
+
**Architecture Constraint:**
|
|
215
|
+
```javascript
|
|
216
|
+
// Constraint exists: "Frontend must be framework-agnostic" (ID: 12)
|
|
217
|
+
|
|
218
|
+
// Task: Refactor to Web Components
|
|
219
|
+
{
|
|
220
|
+
action: "create",
|
|
221
|
+
title: "Migrate UI to Web Components",
|
|
222
|
+
description: "Replace framework-specific code with Web Components",
|
|
223
|
+
priority: "medium",
|
|
224
|
+
tags: ["refactoring", "architecture"],
|
|
225
|
+
layer: "presentation"
|
|
226
|
+
}
|
|
227
|
+
// Returns: { task_id: 7 }
|
|
228
|
+
|
|
229
|
+
// Link to constraint
|
|
230
|
+
{
|
|
231
|
+
action: "link",
|
|
232
|
+
task_id: 7,
|
|
233
|
+
link_type: "constraint",
|
|
234
|
+
link_id: 12
|
|
235
|
+
}
|
|
236
|
+
```
|
|
237
|
+
|
|
238
|
+
### Use Cases
|
|
239
|
+
|
|
240
|
+
**Compliance Task:**
|
|
241
|
+
```javascript
|
|
242
|
+
// Constraint: GDPR data retention policy
|
|
243
|
+
// Task: Implement data deletion workflow
|
|
244
|
+
|
|
245
|
+
{
|
|
246
|
+
action: "link",
|
|
247
|
+
task_id: 15,
|
|
248
|
+
link_type: "constraint",
|
|
249
|
+
link_id: 22
|
|
250
|
+
}
|
|
251
|
+
```
|
|
252
|
+
|
|
253
|
+
**Blocker Resolution:**
|
|
254
|
+
```javascript
|
|
255
|
+
// Constraint: Database schema must be finalized
|
|
256
|
+
// Task: Implement user service (blocked until schema ready)
|
|
257
|
+
|
|
258
|
+
{
|
|
259
|
+
action: "link",
|
|
260
|
+
task_id: 18,
|
|
261
|
+
link_type: "constraint",
|
|
262
|
+
link_id: 25
|
|
263
|
+
}
|
|
264
|
+
```
|
|
265
|
+
|
|
266
|
+
## File Links
|
|
267
|
+
|
|
268
|
+
### When to Use
|
|
269
|
+
|
|
270
|
+
Link tasks to files when:
|
|
271
|
+
- Task modifies specific files
|
|
272
|
+
- Task is scoped to certain modules
|
|
273
|
+
- Task affects file structure
|
|
274
|
+
|
|
275
|
+
### Examples
|
|
276
|
+
|
|
277
|
+
**Single File Link:**
|
|
278
|
+
```javascript
|
|
279
|
+
// Task: Refactor JWT authentication module
|
|
280
|
+
{
|
|
281
|
+
action: "create",
|
|
282
|
+
title: "Refactor JWT authentication module",
|
|
283
|
+
description: "Extract token generation to separate utility",
|
|
284
|
+
priority: "medium",
|
|
285
|
+
tags: ["refactoring", "authentication"],
|
|
286
|
+
layer: "business"
|
|
287
|
+
}
|
|
288
|
+
// Returns: { task_id: 4 }
|
|
289
|
+
|
|
290
|
+
// Link to file
|
|
291
|
+
{
|
|
292
|
+
action: "link",
|
|
293
|
+
task_id: 4,
|
|
294
|
+
link_type: "file",
|
|
295
|
+
link_path: "/src/auth/jwt.ts"
|
|
296
|
+
}
|
|
297
|
+
```
|
|
298
|
+
|
|
299
|
+
**Multiple File Links:**
|
|
300
|
+
```javascript
|
|
301
|
+
// Task: Implement user authentication flow
|
|
302
|
+
{
|
|
303
|
+
action: "create",
|
|
304
|
+
title: "Implement user authentication flow",
|
|
305
|
+
description: "Complete end-to-end authentication with JWT",
|
|
306
|
+
priority: "high",
|
|
307
|
+
tags: ["feature", "authentication"],
|
|
308
|
+
layer: "business"
|
|
309
|
+
}
|
|
310
|
+
// Returns: { task_id: 6 }
|
|
311
|
+
|
|
312
|
+
// Link to multiple files
|
|
313
|
+
{
|
|
314
|
+
action: "link",
|
|
315
|
+
task_id: 6,
|
|
316
|
+
link_type: "file",
|
|
317
|
+
link_path: "/src/auth/jwt.ts"
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
{
|
|
321
|
+
action: "link",
|
|
322
|
+
task_id: 6,
|
|
323
|
+
link_type: "file",
|
|
324
|
+
link_path: "/src/auth/middleware.ts"
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
{
|
|
328
|
+
action: "link",
|
|
329
|
+
task_id: 6,
|
|
330
|
+
link_type: "file",
|
|
331
|
+
link_path: "/src/routes/auth.ts"
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
{
|
|
335
|
+
action: "link",
|
|
336
|
+
task_id: 6,
|
|
337
|
+
link_type: "file",
|
|
338
|
+
link_path: "/src/models/user.ts"
|
|
339
|
+
}
|
|
340
|
+
```
|
|
341
|
+
|
|
342
|
+
### Use Cases
|
|
343
|
+
|
|
344
|
+
**Feature Implementation:**
|
|
345
|
+
```javascript
|
|
346
|
+
// Task: Add password reset functionality
|
|
347
|
+
// Files: password-reset controller, email service, user model
|
|
348
|
+
|
|
349
|
+
{
|
|
350
|
+
action: "link",
|
|
351
|
+
task_id: 10,
|
|
352
|
+
link_type: "file",
|
|
353
|
+
link_path: "/src/controllers/password-reset.ts"
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
{
|
|
357
|
+
action: "link",
|
|
358
|
+
task_id: 10,
|
|
359
|
+
link_type: "file",
|
|
360
|
+
link_path: "/src/services/email.ts"
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
{
|
|
364
|
+
action: "link",
|
|
365
|
+
task_id: 10,
|
|
366
|
+
link_type: "file",
|
|
367
|
+
link_path: "/src/models/user.ts"
|
|
368
|
+
}
|
|
369
|
+
```
|
|
370
|
+
|
|
371
|
+
**Bug Fix:**
|
|
372
|
+
```javascript
|
|
373
|
+
// Task: Fix memory leak in WebSocket handler
|
|
374
|
+
// File: WebSocket handler
|
|
375
|
+
|
|
376
|
+
{
|
|
377
|
+
action: "link",
|
|
378
|
+
task_id: 14,
|
|
379
|
+
link_type: "file",
|
|
380
|
+
link_path: "/src/websocket/handler.ts"
|
|
381
|
+
}
|
|
382
|
+
```
|
|
383
|
+
|
|
384
|
+
**Refactoring:**
|
|
385
|
+
```javascript
|
|
386
|
+
// Task: Extract shared utilities
|
|
387
|
+
// Files: Multiple files being refactored
|
|
388
|
+
|
|
389
|
+
{
|
|
390
|
+
action: "link",
|
|
391
|
+
task_id: 20,
|
|
392
|
+
link_type: "file",
|
|
393
|
+
link_path: "/src/utils/validation.ts"
|
|
394
|
+
}
|
|
395
|
+
|
|
396
|
+
{
|
|
397
|
+
action: "link",
|
|
398
|
+
task_id: 20,
|
|
399
|
+
link_type: "file",
|
|
400
|
+
link_path: "/src/utils/formatting.ts"
|
|
401
|
+
}
|
|
402
|
+
```
|
|
403
|
+
|
|
404
|
+
## Querying Links
|
|
405
|
+
|
|
406
|
+
### Get Task with Links
|
|
407
|
+
|
|
408
|
+
**Using `get` action:**
|
|
409
|
+
```javascript
|
|
410
|
+
{
|
|
411
|
+
action: "get",
|
|
412
|
+
task_id: 1
|
|
413
|
+
}
|
|
414
|
+
|
|
415
|
+
// Response includes all links
|
|
416
|
+
{
|
|
417
|
+
task_id: 1,
|
|
418
|
+
title: "Implement JWT authentication",
|
|
419
|
+
description: "Add JWT-based auth with refresh token support",
|
|
420
|
+
status: "in_progress",
|
|
421
|
+
priority: "high",
|
|
422
|
+
assignee: "auth-agent",
|
|
423
|
+
layer: "business",
|
|
424
|
+
tags: ["security", "authentication"],
|
|
425
|
+
created_ts: 1697545200,
|
|
426
|
+
updated_ts: 1697545800,
|
|
427
|
+
decision_links: ["auth_method", "jwt_secret_rotation"],
|
|
428
|
+
constraint_links: [5, 8],
|
|
429
|
+
file_links: ["/src/auth/jwt.ts", "/src/auth/middleware.ts"]
|
|
430
|
+
}
|
|
431
|
+
```
|
|
432
|
+
|
|
433
|
+
### Find Tasks by Link (SQL)
|
|
434
|
+
|
|
435
|
+
**Tasks Linked to Specific Decision:**
|
|
436
|
+
```sql
|
|
437
|
+
SELECT t.* FROM t_tasks t
|
|
438
|
+
JOIN t_task_decision_links tdl ON t.task_id = tdl.task_id
|
|
439
|
+
JOIN m_context_keys ck ON tdl.decision_key_id = ck.key_id
|
|
440
|
+
WHERE ck.key_name = 'auth_method';
|
|
441
|
+
```
|
|
442
|
+
|
|
443
|
+
**Tasks Linked to Specific Constraint:**
|
|
444
|
+
```sql
|
|
445
|
+
SELECT t.* FROM t_tasks t
|
|
446
|
+
JOIN t_task_constraint_links tcl ON t.task_id = tcl.task_id
|
|
447
|
+
WHERE tcl.constraint_id = 5;
|
|
448
|
+
```
|
|
449
|
+
|
|
450
|
+
**Tasks Linked to Specific File:**
|
|
451
|
+
```sql
|
|
452
|
+
SELECT t.* FROM t_tasks t
|
|
453
|
+
JOIN t_task_file_links tfl ON t.task_id = tfl.task_id
|
|
454
|
+
JOIN m_files f ON tfl.file_id = f.file_id
|
|
455
|
+
WHERE f.file_path = '/src/auth/jwt.ts';
|
|
456
|
+
```
|
|
457
|
+
|
|
458
|
+
**All Links for a Task:**
|
|
459
|
+
```sql
|
|
460
|
+
-- Decision links
|
|
461
|
+
SELECT ck.key_name FROM t_task_decision_links tdl
|
|
462
|
+
JOIN m_context_keys ck ON tdl.decision_key_id = ck.key_id
|
|
463
|
+
WHERE tdl.task_id = 1;
|
|
464
|
+
|
|
465
|
+
-- Constraint links
|
|
466
|
+
SELECT constraint_id FROM t_task_constraint_links
|
|
467
|
+
WHERE task_id = 1;
|
|
468
|
+
|
|
469
|
+
-- File links
|
|
470
|
+
SELECT f.file_path FROM t_task_file_links tfl
|
|
471
|
+
JOIN m_files f ON tfl.file_id = f.file_id
|
|
472
|
+
WHERE tfl.task_id = 1;
|
|
473
|
+
```
|
|
474
|
+
|
|
475
|
+
## Linking Strategies
|
|
476
|
+
|
|
477
|
+
### 1. Link-as-You-Go
|
|
478
|
+
|
|
479
|
+
Create task and immediately link to context:
|
|
480
|
+
|
|
481
|
+
```javascript
|
|
482
|
+
// Step 1: Create task
|
|
483
|
+
const task = {
|
|
484
|
+
action: "create",
|
|
485
|
+
title: "Implement caching layer",
|
|
486
|
+
description: "Add Redis-based caching for API responses",
|
|
487
|
+
priority: "high",
|
|
488
|
+
tags: ["performance", "caching"],
|
|
489
|
+
layer: "infrastructure"
|
|
490
|
+
};
|
|
491
|
+
// Returns: { task_id: 25 }
|
|
492
|
+
|
|
493
|
+
// Step 2: Link to decision
|
|
494
|
+
{
|
|
495
|
+
action: "link",
|
|
496
|
+
task_id: 25,
|
|
497
|
+
link_type: "decision",
|
|
498
|
+
link_key: "caching_strategy"
|
|
499
|
+
}
|
|
500
|
+
|
|
501
|
+
// Step 3: Link to constraint
|
|
502
|
+
{
|
|
503
|
+
action: "link",
|
|
504
|
+
task_id: 25,
|
|
505
|
+
link_type: "constraint",
|
|
506
|
+
link_id: 5 // "API response time <100ms"
|
|
507
|
+
}
|
|
508
|
+
|
|
509
|
+
// Step 4: Link to files
|
|
510
|
+
{
|
|
511
|
+
action: "link",
|
|
512
|
+
task_id: 25,
|
|
513
|
+
link_type: "file",
|
|
514
|
+
link_path: "/src/cache/redis.ts"
|
|
515
|
+
}
|
|
516
|
+
```
|
|
517
|
+
|
|
518
|
+
### 2. Batch Linking
|
|
519
|
+
|
|
520
|
+
Link task to multiple entities at once:
|
|
521
|
+
|
|
522
|
+
```javascript
|
|
523
|
+
// Create task
|
|
524
|
+
{ action: "create", title: "...", ... }
|
|
525
|
+
// Returns: { task_id: 30 }
|
|
526
|
+
|
|
527
|
+
// Batch link decisions
|
|
528
|
+
const decisions = ["auth_method", "jwt_secret", "token_expiry"];
|
|
529
|
+
decisions.forEach(key => {
|
|
530
|
+
{
|
|
531
|
+
action: "link",
|
|
532
|
+
task_id: 30,
|
|
533
|
+
link_type: "decision",
|
|
534
|
+
link_key: key
|
|
535
|
+
}
|
|
536
|
+
});
|
|
537
|
+
|
|
538
|
+
// Batch link files
|
|
539
|
+
const files = ["/src/auth/jwt.ts", "/src/auth/middleware.ts"];
|
|
540
|
+
files.forEach(path => {
|
|
541
|
+
{
|
|
542
|
+
action: "link",
|
|
543
|
+
task_id: 30,
|
|
544
|
+
link_type: "file",
|
|
545
|
+
link_path: path
|
|
546
|
+
}
|
|
547
|
+
});
|
|
548
|
+
```
|
|
549
|
+
|
|
550
|
+
### 3. Progressive Linking
|
|
551
|
+
|
|
552
|
+
Add links as task evolves:
|
|
553
|
+
|
|
554
|
+
```javascript
|
|
555
|
+
// Day 1: Create task
|
|
556
|
+
{ action: "create", title: "Optimize API performance" }
|
|
557
|
+
// Returns: { task_id: 35 }
|
|
558
|
+
|
|
559
|
+
// Day 2: Link to constraint (discovered during work)
|
|
560
|
+
{
|
|
561
|
+
action: "link",
|
|
562
|
+
task_id: 35,
|
|
563
|
+
link_type: "constraint",
|
|
564
|
+
link_id: 5
|
|
565
|
+
}
|
|
566
|
+
|
|
567
|
+
// Day 3: Link to files (as they're modified)
|
|
568
|
+
{
|
|
569
|
+
action: "link",
|
|
570
|
+
task_id: 35,
|
|
571
|
+
link_type: "file",
|
|
572
|
+
link_path: "/src/api/routes.ts"
|
|
573
|
+
}
|
|
574
|
+
|
|
575
|
+
// Day 4: Link to decision (made during optimization)
|
|
576
|
+
{
|
|
577
|
+
action: "link",
|
|
578
|
+
task_id: 35,
|
|
579
|
+
link_type: "decision",
|
|
580
|
+
link_key: "caching_strategy"
|
|
581
|
+
}
|
|
582
|
+
```
|
|
583
|
+
|
|
584
|
+
### 4. Cross-Reference Linking
|
|
585
|
+
|
|
586
|
+
Link related tasks through shared links:
|
|
587
|
+
|
|
588
|
+
```javascript
|
|
589
|
+
// Task A: Implement auth
|
|
590
|
+
{
|
|
591
|
+
action: "link",
|
|
592
|
+
task_id: 40,
|
|
593
|
+
link_type: "decision",
|
|
594
|
+
link_key: "auth_method"
|
|
595
|
+
}
|
|
596
|
+
|
|
597
|
+
// Task B: Add auth middleware (related to Task A)
|
|
598
|
+
{
|
|
599
|
+
action: "link",
|
|
600
|
+
task_id: 41,
|
|
601
|
+
link_type: "decision",
|
|
602
|
+
link_key: "auth_method" // Same decision
|
|
603
|
+
}
|
|
604
|
+
|
|
605
|
+
// Query: Find related tasks
|
|
606
|
+
// Both Task A and Task B linked to same decision
|
|
607
|
+
```
|
|
608
|
+
|
|
609
|
+
## Best Practices
|
|
610
|
+
|
|
611
|
+
### 1. Link Early and Often
|
|
612
|
+
|
|
613
|
+
```javascript
|
|
614
|
+
// ✅ GOOD: Link immediately after creation
|
|
615
|
+
const task = create({ action: "create", title: "..." });
|
|
616
|
+
link({ action: "link", task_id: task.task_id, link_type: "decision", link_key: "..." });
|
|
617
|
+
|
|
618
|
+
// ❌ BAD: Forget to link, lose context later
|
|
619
|
+
```
|
|
620
|
+
|
|
621
|
+
### 2. Use Meaningful Links
|
|
622
|
+
|
|
623
|
+
```javascript
|
|
624
|
+
// ✅ GOOD: Link to relevant decision
|
|
625
|
+
{
|
|
626
|
+
action: "link",
|
|
627
|
+
task_id: 1,
|
|
628
|
+
link_type: "decision",
|
|
629
|
+
link_key: "auth_method" // Directly related
|
|
630
|
+
}
|
|
631
|
+
|
|
632
|
+
// ❌ BAD: Link to unrelated decision
|
|
633
|
+
{
|
|
634
|
+
action: "link",
|
|
635
|
+
task_id: 1,
|
|
636
|
+
link_type: "decision",
|
|
637
|
+
link_key: "database_choice" // Not related to auth task
|
|
638
|
+
}
|
|
639
|
+
```
|
|
640
|
+
|
|
641
|
+
### 3. Link to Files Being Modified
|
|
642
|
+
|
|
643
|
+
```javascript
|
|
644
|
+
// ✅ GOOD: Link to actual files being changed
|
|
645
|
+
{
|
|
646
|
+
action: "link",
|
|
647
|
+
task_id: 5,
|
|
648
|
+
link_type: "file",
|
|
649
|
+
link_path: "/src/auth/jwt.ts" // Will modify this file
|
|
650
|
+
}
|
|
651
|
+
|
|
652
|
+
// ❌ BAD: Link to unrelated files
|
|
653
|
+
{
|
|
654
|
+
action: "link",
|
|
655
|
+
task_id: 5,
|
|
656
|
+
link_type: "file",
|
|
657
|
+
link_path: "/README.md" // Not modifying this
|
|
658
|
+
}
|
|
659
|
+
```
|
|
660
|
+
|
|
661
|
+
### 4. Use Links for Traceability
|
|
662
|
+
|
|
663
|
+
```javascript
|
|
664
|
+
// Implementation flow with full traceability
|
|
665
|
+
|
|
666
|
+
// 1. Decision made
|
|
667
|
+
{ action: "set", key: "auth_method", value: "JWT" }
|
|
668
|
+
|
|
669
|
+
// 2. Constraint added
|
|
670
|
+
{ action: "add", category: "security", constraint_text: "Auth tokens expire in 1h" }
|
|
671
|
+
// Returns: { constraint_id: 15 }
|
|
672
|
+
|
|
673
|
+
// 3. Task created with links
|
|
674
|
+
{ action: "create", title: "Implement JWT auth" }
|
|
675
|
+
// Returns: { task_id: 50 }
|
|
676
|
+
|
|
677
|
+
// 4. Link to decision
|
|
678
|
+
{ action: "link", task_id: 50, link_type: "decision", link_key: "auth_method" }
|
|
679
|
+
|
|
680
|
+
// 5. Link to constraint
|
|
681
|
+
{ action: "link", task_id: 50, link_type: "constraint", link_id: 15 }
|
|
682
|
+
|
|
683
|
+
// 6. Link to implementation files
|
|
684
|
+
{ action: "link", task_id: 50, link_type: "file", link_path: "/src/auth/jwt.ts" }
|
|
685
|
+
|
|
686
|
+
// Result: Full traceability from decision → constraint → task → files
|
|
687
|
+
```
|
|
688
|
+
|
|
689
|
+
### 5. Update Links When Scope Changes
|
|
690
|
+
|
|
691
|
+
```javascript
|
|
692
|
+
// Task scope expands
|
|
693
|
+
{ action: "update", task_id: 60, description: "Now includes OAuth2 support" }
|
|
694
|
+
|
|
695
|
+
// Add new decision link
|
|
696
|
+
{ action: "link", task_id: 60, link_type: "decision", link_key: "oauth2_provider" }
|
|
697
|
+
|
|
698
|
+
// Add new file links
|
|
699
|
+
{ action: "link", task_id: 60, link_type: "file", link_path: "/src/auth/oauth2.ts" }
|
|
700
|
+
```
|
|
701
|
+
|
|
702
|
+
### 6. Use Links for Impact Analysis
|
|
703
|
+
|
|
704
|
+
```javascript
|
|
705
|
+
// Before changing a constraint, find affected tasks
|
|
706
|
+
|
|
707
|
+
// SQL: Find tasks linked to constraint 5
|
|
708
|
+
SELECT t.* FROM t_tasks t
|
|
709
|
+
JOIN t_task_constraint_links tcl ON t.task_id = tcl.task_id
|
|
710
|
+
WHERE tcl.constraint_id = 5;
|
|
711
|
+
|
|
712
|
+
// Review tasks before updating constraint
|
|
713
|
+
// Update constraint if safe
|
|
714
|
+
// Notify assignees if tasks affected
|
|
715
|
+
```
|
|
716
|
+
|
|
717
|
+
## Related Documentation
|
|
718
|
+
|
|
719
|
+
- **[TASK_OVERVIEW.md](TASK_OVERVIEW.md)** - Task system overview and core concepts
|
|
720
|
+
- **[TASK_ACTIONS.md](TASK_ACTIONS.md)** - Complete action reference with examples
|
|
721
|
+
- **[TASK_MIGRATION.md](TASK_MIGRATION.md)** - Migrating from decision-based task tracking
|
|
722
|
+
- **[TASK_SYSTEM.md](TASK_SYSTEM.md)** - Complete documentation (original)
|
|
723
|
+
- **[AI_AGENT_GUIDE.md](AI_AGENT_GUIDE.md)** - Comprehensive AI agent guide
|
|
724
|
+
|
|
725
|
+
---
|
|
726
|
+
|
|
727
|
+
**Version:** 3.0.0
|
|
728
|
+
**Last Updated:** 2025-10-17
|
|
729
|
+
**Author:** sin5ddd
|