sqlew 4.0.4 → 4.1.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 (203) hide show
  1. package/CHANGELOG.md +1805 -1762
  2. package/LICENSE +177 -39
  3. package/NOTICE +24 -0
  4. package/README.md +409 -390
  5. package/assets/claude-md-snippets/plan-mode-integration.md +17 -6
  6. package/assets/config.example.toml +282 -284
  7. package/assets/sample-agents/README.md +36 -40
  8. package/assets/sample-agents/sqlew-architect.md +321 -322
  9. package/assets/sample-agents/sqlew-researcher.md +292 -293
  10. package/assets/sample-agents/sqlew-scrum-master.md +286 -287
  11. package/assets/sample-commands/README.md +56 -57
  12. package/assets/sample-skills/sqlew-plan-guidance/SKILL.md +33 -26
  13. package/dist/cli/hooks/check-completion.d.ts +19 -0
  14. package/dist/cli/hooks/check-completion.d.ts.map +1 -0
  15. package/dist/cli/hooks/check-completion.js +104 -0
  16. package/dist/cli/hooks/check-completion.js.map +1 -0
  17. package/dist/cli/hooks/init-hooks.d.ts +35 -0
  18. package/dist/cli/hooks/init-hooks.d.ts.map +1 -0
  19. package/dist/cli/hooks/init-hooks.js +425 -0
  20. package/dist/cli/hooks/init-hooks.js.map +1 -0
  21. package/dist/cli/hooks/mark-done.d.ts +25 -0
  22. package/dist/cli/hooks/mark-done.d.ts.map +1 -0
  23. package/dist/cli/hooks/mark-done.js +128 -0
  24. package/dist/cli/hooks/mark-done.js.map +1 -0
  25. package/dist/cli/hooks/plan-id-utils.d.ts +83 -0
  26. package/dist/cli/hooks/plan-id-utils.d.ts.map +1 -0
  27. package/dist/cli/hooks/plan-id-utils.js +183 -0
  28. package/dist/cli/hooks/plan-id-utils.js.map +1 -0
  29. package/dist/cli/hooks/save.d.ts +23 -0
  30. package/dist/cli/hooks/save.d.ts.map +1 -0
  31. package/dist/cli/hooks/save.js +90 -0
  32. package/dist/cli/hooks/save.js.map +1 -0
  33. package/dist/cli/hooks/stdin-parser.d.ts +139 -0
  34. package/dist/cli/hooks/stdin-parser.d.ts.map +1 -0
  35. package/dist/cli/hooks/stdin-parser.js +127 -0
  36. package/dist/cli/hooks/stdin-parser.js.map +1 -0
  37. package/dist/cli/hooks/suggest.d.ts +19 -0
  38. package/dist/cli/hooks/suggest.d.ts.map +1 -0
  39. package/dist/cli/hooks/suggest.js +157 -0
  40. package/dist/cli/hooks/suggest.js.map +1 -0
  41. package/dist/cli/hooks/track-plan.d.ts +36 -0
  42. package/dist/cli/hooks/track-plan.d.ts.map +1 -0
  43. package/dist/cli/hooks/track-plan.js +152 -0
  44. package/dist/cli/hooks/track-plan.js.map +1 -0
  45. package/dist/cli.d.ts.map +1 -1
  46. package/dist/cli.js +56 -16
  47. package/dist/cli.js.map +1 -1
  48. package/dist/config/global-config.d.ts +187 -0
  49. package/dist/config/global-config.d.ts.map +1 -0
  50. package/dist/config/global-config.js +206 -0
  51. package/dist/config/global-config.js.map +1 -0
  52. package/dist/config/loader.d.ts +42 -0
  53. package/dist/config/loader.d.ts.map +1 -1
  54. package/dist/config/loader.js +96 -0
  55. package/dist/config/loader.js.map +1 -1
  56. package/dist/constants.d.ts +4 -0
  57. package/dist/constants.d.ts.map +1 -1
  58. package/dist/constants.js +10 -0
  59. package/dist/constants.js.map +1 -1
  60. package/dist/database/operations/queries.d.ts.map +1 -1
  61. package/dist/database/operations/queries.js +11 -2
  62. package/dist/database/operations/queries.js.map +1 -1
  63. package/dist/index.js +5 -2
  64. package/dist/index.js.map +1 -1
  65. package/dist/init-agents.js +0 -1
  66. package/dist/init-agents.js.map +1 -1
  67. package/dist/init-skills.d.ts +4 -3
  68. package/dist/init-skills.d.ts.map +1 -1
  69. package/dist/init-skills.js +10 -3
  70. package/dist/init-skills.js.map +1 -1
  71. package/dist/server/setup.d.ts +8 -0
  72. package/dist/server/setup.d.ts.map +1 -1
  73. package/dist/server/setup.js +141 -21
  74. package/dist/server/setup.js.map +1 -1
  75. package/dist/sync-agents.d.ts.map +1 -1
  76. package/dist/sync-agents.js +48 -3
  77. package/dist/sync-agents.js.map +1 -1
  78. package/dist/sync-commands.d.ts.map +1 -1
  79. package/dist/sync-commands.js +43 -3
  80. package/dist/sync-commands.js.map +1 -1
  81. package/dist/tools/constraints/actions/get.d.ts.map +1 -1
  82. package/dist/tools/constraints/actions/get.js +5 -8
  83. package/dist/tools/constraints/actions/get.js.map +1 -1
  84. package/dist/tools/constraints/help/help.d.ts.map +1 -1
  85. package/dist/tools/constraints/help/help.js +1 -6
  86. package/dist/tools/constraints/help/help.js.map +1 -1
  87. package/dist/tools/context/actions/get.d.ts.map +1 -1
  88. package/dist/tools/context/actions/get.js.map +1 -1
  89. package/dist/tools/context/actions/search-layer.d.ts.map +1 -1
  90. package/dist/tools/context/actions/search-layer.js +5 -3
  91. package/dist/tools/context/actions/search-layer.js.map +1 -1
  92. package/dist/tools/context/actions/set-from-policy.d.ts +2 -1
  93. package/dist/tools/context/actions/set-from-policy.d.ts.map +1 -1
  94. package/dist/tools/context/actions/set-from-policy.js.map +1 -1
  95. package/dist/tools/context/help/help.d.ts.map +1 -1
  96. package/dist/tools/context/help/help.js +1 -7
  97. package/dist/tools/context/help/help.js.map +1 -1
  98. package/dist/tools/context/internal/queries.d.ts.map +1 -1
  99. package/dist/tools/context/internal/queries.js +5 -2
  100. package/dist/tools/context/internal/queries.js.map +1 -1
  101. package/dist/tools/context/types.d.ts +1 -1
  102. package/dist/tools/context/types.d.ts.map +1 -1
  103. package/dist/tools/files/actions/get.d.ts.map +1 -1
  104. package/dist/tools/files/actions/get.js +4 -6
  105. package/dist/tools/files/actions/get.js.map +1 -1
  106. package/dist/tools/files/help/help.d.ts.map +1 -1
  107. package/dist/tools/files/help/help.js +1 -6
  108. package/dist/tools/files/help/help.js.map +1 -1
  109. package/dist/tools/suggest/help/constraint-help.d.ts.map +1 -1
  110. package/dist/tools/suggest/help/constraint-help.js +0 -2
  111. package/dist/tools/suggest/help/constraint-help.js.map +1 -1
  112. package/dist/tools/suggest/internal/constraint-queries.d.ts.map +1 -1
  113. package/dist/tools/suggest/internal/constraint-queries.js +12 -5
  114. package/dist/tools/suggest/internal/constraint-queries.js.map +1 -1
  115. package/dist/tools/suggest/internal/queries.js +2 -2
  116. package/dist/tools/suggest/internal/queries.js.map +1 -1
  117. package/dist/tools/tasks/help/help.d.ts.map +1 -1
  118. package/dist/tools/tasks/help/help.js +0 -6
  119. package/dist/tools/tasks/help/help.js.map +1 -1
  120. package/dist/tools/tasks/help/use-case.d.ts.map +1 -1
  121. package/dist/tools/tasks/help/use-case.js +0 -1
  122. package/dist/tools/tasks/help/use-case.js.map +1 -1
  123. package/dist/tools/tasks/watcher/status.d.ts.map +1 -1
  124. package/dist/tools/tasks/watcher/status.js +5 -1
  125. package/dist/tools/tasks/watcher/status.js.map +1 -1
  126. package/dist/types/decision/params.d.ts +7 -6
  127. package/dist/types/decision/params.d.ts.map +1 -1
  128. package/dist/types/decision/templates.d.ts +3 -2
  129. package/dist/types/decision/templates.d.ts.map +1 -1
  130. package/dist/types/view-entities.d.ts +2 -1
  131. package/dist/types/view-entities.d.ts.map +1 -1
  132. package/dist/types.d.ts +19 -11
  133. package/dist/types.d.ts.map +1 -1
  134. package/dist/types.js +4 -1
  135. package/dist/types.js.map +1 -1
  136. package/dist/utils/enum-converter.d.ts +72 -0
  137. package/dist/utils/enum-converter.d.ts.map +1 -0
  138. package/dist/utils/enum-converter.js +76 -0
  139. package/dist/utils/enum-converter.js.map +1 -0
  140. package/dist/utils/hook-queue.d.ts +81 -0
  141. package/dist/utils/hook-queue.d.ts.map +1 -0
  142. package/dist/utils/hook-queue.js +156 -0
  143. package/dist/utils/hook-queue.js.map +1 -0
  144. package/dist/utils/project-root.d.ts +9 -2
  145. package/dist/utils/project-root.d.ts.map +1 -1
  146. package/dist/utils/project-root.js +16 -2
  147. package/dist/utils/project-root.js.map +1 -1
  148. package/dist/utils/tag-parser.d.ts.map +1 -1
  149. package/dist/utils/tag-parser.js +6 -0
  150. package/dist/utils/tag-parser.js.map +1 -1
  151. package/dist/utils/validators.d.ts +1 -1
  152. package/dist/utils/validators.d.ts.map +1 -1
  153. package/dist/utils/validators.js +1 -1
  154. package/dist/utils/validators.js.map +1 -1
  155. package/dist/utils/vcs-adapter.d.ts +44 -0
  156. package/dist/utils/vcs-adapter.d.ts.map +1 -1
  157. package/dist/utils/vcs-adapter.js +88 -0
  158. package/dist/utils/vcs-adapter.js.map +1 -1
  159. package/dist/utils/view-queries.d.ts.map +1 -1
  160. package/dist/utils/view-queries.js +9 -19
  161. package/dist/utils/view-queries.js.map +1 -1
  162. package/dist/watcher/base-watcher.d.ts +69 -0
  163. package/dist/watcher/base-watcher.d.ts.map +1 -0
  164. package/dist/watcher/base-watcher.js +130 -0
  165. package/dist/watcher/base-watcher.js.map +1 -0
  166. package/dist/watcher/index.d.ts +3 -0
  167. package/dist/watcher/index.d.ts.map +1 -1
  168. package/dist/watcher/index.js +2 -0
  169. package/dist/watcher/index.js.map +1 -1
  170. package/dist/watcher/queue-watcher.d.ts +64 -0
  171. package/dist/watcher/queue-watcher.d.ts.map +1 -0
  172. package/dist/watcher/queue-watcher.js +187 -0
  173. package/dist/watcher/queue-watcher.js.map +1 -0
  174. package/docs/ADR_CONCEPTS.md +140 -0
  175. package/docs/CONFIGURATION.md +922 -925
  176. package/docs/CROSS_DATABASE.md +153 -0
  177. package/docs/DATABASE_AUTH.md +70 -356
  178. package/docs/HOOKS_GUIDE.md +159 -0
  179. package/docs/SLASH_COMMANDS.md +329 -337
  180. package/docs/TASK_SYSTEM_DEPRECATED.md +88 -0
  181. package/docs/changelogs/CHANGELOG_ARCHIVE_v3.4_and_older.md +293 -296
  182. package/docs/cli/DATA_EXPORT_IMPORT.md +699 -700
  183. package/docs/cli/README.md +276 -277
  184. package/package.json +123 -119
  185. package/docs/ACCEPTANCE_CRITERIA.md +0 -625
  186. package/docs/AI_AGENT_GUIDE.md +0 -198
  187. package/docs/ARCHITECTURE.md +0 -167
  188. package/docs/AUTO_FILE_TRACKING.md +0 -841
  189. package/docs/BATCH_VALIDATION.md +0 -617
  190. package/docs/BEST_PRACTICES.md +0 -168
  191. package/docs/CONSTRAINT_INTELLIGENCE.md +0 -339
  192. package/docs/DECISION_CONTEXT.md +0 -675
  193. package/docs/DECISION_INTELLIGENCE.md +0 -605
  194. package/docs/GIT_AWARE_AUTO_COMPLETE.md +0 -646
  195. package/docs/MIGRATION_GUIDE_V3.9.0.md +0 -371
  196. package/docs/SHARED_CONCEPTS.md +0 -225
  197. package/docs/SPECIALIZED_AGENTS.md +0 -126
  198. package/docs/TASK_ACTIONS.md +0 -1177
  199. package/docs/TASK_OVERVIEW.md +0 -452
  200. package/docs/TASK_PRUNING.md +0 -594
  201. package/docs/TOOL_REFERENCE.md +0 -1077
  202. package/docs/TOOL_SELECTION.md +0 -83
  203. package/docs/WORKFLOWS.md +0 -941
@@ -1,675 +0,0 @@
1
- # Decision Context - Rich Decision Documentation (v3.2.2+)
2
-
3
- ## Overview
4
-
5
- The **Decision Context** feature allows you to attach rich documentation to architectural and implementation decisions, explaining **WHY** a decision was made, what alternatives were considered, and the trade-offs involved. This goes beyond simple key-value storage to provide deep historical context that helps future developers (both human and AI) understand past reasoning.
6
-
7
- > **Preserved in v4.0.0**: This feature is fully preserved in the v4.0.0 schema refactoring. All decision context data (rationale, alternatives, trade-offs, related links) continues to work without changes. The schema uses `v4_decision_context` table with the same structure and functionality.
8
-
9
- ---
10
-
11
- ## 🆕 Decision Intelligence Integration (v3.9.0)
12
-
13
- ### Project Historical Records with Automatic Updates
14
-
15
- **v3.9.0 introduces intelligent duplicate detection** that treats decisions as **living historical records** rather than static entries. This transforms how you maintain project knowledge:
16
-
17
- #### The Problem: Decision Fragmentation
18
-
19
- Without intelligent detection, teams create fragmented decision records:
20
- ```
21
- api-authentication → "Use JWT"
22
- auth-method → "JWT tokens"
23
- api-auth-strategy → "JWT with refresh tokens"
24
- ```
25
-
26
- **Result**: 3 separate entries for the same decision, making it impossible to track the evolution of your authentication strategy.
27
-
28
- #### The Solution: Three-Tier Historical Record Management
29
-
30
- **Tier 1 (35-44 score): Related Record Alert**
31
- - Shows potentially related historical records
32
- - Allows you to link or update existing records
33
- - Perfect for discovering "we discussed this before"
34
-
35
- **Tier 2 (45-59 score): Update Existing Record**
36
- - High similarity suggests same topic
37
- - Prompts you to update the existing record with new context
38
- - Maintains decision continuity
39
-
40
- **Tier 3 (60+ score): Automatic Historical Update**
41
- - Transparently updates existing record
42
- - Preserves complete version history
43
- - Zero friction for iterative refinement
44
-
45
- #### Example: Evolving Authentication Decision
46
-
47
- **Initial Decision (January)**:
48
- ```typescript
49
- {
50
- action: "set",
51
- key: "api-authentication",
52
- value: "Use JWT tokens for API authentication",
53
- tags: ["api", "security", "authentication"],
54
- layer: "business"
55
- }
56
- ```
57
-
58
- **Updated Context (March)** - After security review:
59
- ```typescript
60
- {
61
- action: "set",
62
- key: "api-auth-jwt-expiration", // Similar key
63
- value: "JWT tokens with 15-minute expiration",
64
- tags: ["api", "security", "authentication"], // Same tags
65
- layer: "business" // Same layer
66
- }
67
-
68
- // v3.9.0 Response:
69
- {
70
- "success": true,
71
- "auto_updated": true,
72
- "requested_key": "api-auth-jwt-expiration",
73
- "actual_key": "api-authentication", // Updated existing record!
74
- "version": "1.0.1", // Version incremented
75
- "message": "Auto-updated existing decision (similarity: 85)"
76
- }
77
- ```
78
-
79
- **Result**: Single historical record with version history:
80
- - v1.0.0: "Use JWT tokens for API authentication"
81
- - v1.0.1: "JWT tokens with 15-minute expiration"
82
-
83
- **Query version history**:
84
- ```typescript
85
- {
86
- action: "versions",
87
- key: "api-authentication"
88
- }
89
- // Returns both versions with timestamps
90
- ```
91
-
92
- ### Benefits for Project History
93
-
94
- 1. **Single Source of Truth**: One record per decision topic, not scattered duplicates
95
- 2. **Complete Version Trail**: Track how decisions evolved over time
96
- 3. **Context Accumulation**: Add context to existing decisions, building richer documentation
97
- 4. **Automatic Consolidation**: Similar decisions merge into the canonical record
98
- 5. **Discoverable History**: `suggest` tool finds related decisions instantly
99
-
100
- ### Combining Context with Duplicate Detection
101
-
102
- **Best Practice**: Use duplicate detection to find existing records, then add context:
103
-
104
- ```typescript
105
- // Step 1: Check for existing related decisions
106
- {
107
- action: "check_duplicate",
108
- key: "cache-strategy-redis",
109
- tags: ["caching", "performance", "redis"]
110
- }
111
-
112
- // Response shows existing "cache-implementation" decision
113
-
114
- // Step 2: Update existing record (Tier 3 auto-update)
115
- {
116
- action: "set",
117
- key: "cache-strategy-redis",
118
- value: "Redis LRU cache with 1000-item limit",
119
- tags: ["caching", "performance", "redis"],
120
- layer: "infrastructure"
121
- }
122
- // Auto-updates "cache-implementation" to v1.0.2
123
-
124
- // Step 3: Add rich context to the canonical record
125
- {
126
- action: "add_decision_context",
127
- key: "cache-implementation", // The actual key that was updated
128
- rationale: "Updated to Redis after hitting memory limits with in-process cache. 1000-item LRU covers 98% of requests.",
129
- alternatives_considered: [
130
- "Increase in-memory cache - Rejected: OOM risk",
131
- "Memcached - Rejected: No persistence",
132
- "Redis with TTL - Rejected: Hot items get evicted"
133
- ],
134
- tradeoffs: {
135
- "pros": ["Persistent cache", "Shared across instances", "Built-in LRU"],
136
- "cons": ["Network latency", "Operational complexity"]
137
- }
138
- }
139
- ```
140
-
141
- ### Policy-Based Historical Record Management
142
-
143
- Enable automatic duplicate checking for all decisions in a category:
144
-
145
- ```typescript
146
- {
147
- action: "create_policy",
148
- name: "architecture-decisions",
149
- defaults: {
150
- layer: "cross-cutting",
151
- tags: ["architecture"]
152
- },
153
- suggest_similar: 1, // Auto-check for duplicates
154
- validation_rules: {
155
- patterns: { key: "^arch/" }
156
- }
157
- }
158
-
159
- // Now all arch/* decisions automatically check history
160
- {
161
- action: "set",
162
- key: "arch/database-strategy",
163
- value: "PostgreSQL with read replicas",
164
- // Automatically checks for related arch/* decisions
165
- // Updates existing record if high similarity found
166
- }
167
- ```
168
-
169
- ### See Also
170
-
171
- - **[DECISION_INTELLIGENCE.md](DECISION_INTELLIGENCE.md)** - Complete three-tier system documentation
172
- - **[WORKFLOWS.md](WORKFLOWS.md)** - Workflow 5: Decision Intelligence & Duplicate Prevention
173
-
174
- ---
175
-
176
- ## When Do You Need This Feature?
177
-
178
- ### ❌ When You DON'T Need It
179
-
180
- **Simple Configuration Decisions** - Use regular `decision` tool:
181
- ```typescript
182
- // Just storing a value - no context needed
183
- { action: "set", key: "max_retries", value: 3 }
184
- { action: "set", key: "api_endpoint", value: "https://api.example.com" }
185
- ```
186
-
187
- **Obvious Choices** - Self-explanatory decisions:
188
- ```typescript
189
- // Technology choices that are industry standard
190
- { action: "set", key: "language", value: "TypeScript" }
191
- ```
192
-
193
- ---
194
-
195
- ### ✅ When You NEED It
196
-
197
- #### **Scenario 1: Multi-Session AI Development**
198
-
199
- **Problem**: You're developing a feature over multiple days. On Day 3, an AI agent revisits a Day 1 decision and doesn't understand why approach X was chosen over Y.
200
-
201
- **Before Decision Context** (Day 1):
202
- ```typescript
203
- // Agent 1 makes a decision
204
- { action: "set", key: "auth/token_storage", value: "httponly_cookie" }
205
- ```
206
-
207
- **On Day 3** - Agent 2 asks: *"Why httponly cookie instead of localStorage?"*
208
- - No documented rationale
209
- - Agent 2 might waste 20 minutes re-evaluating the same alternatives
210
- - Risk of choosing a worse approach due to lack of context
211
-
212
- **With Decision Context** (Day 1):
213
- ```typescript
214
- // Agent 1 documents the decision with full context
215
- {
216
- action: "add_decision_context",
217
- key: "auth/token_storage",
218
- rationale: "Using httpOnly cookies to prevent XSS attacks. The application handles sensitive financial data, so localStorage (vulnerable to XSS) is unacceptable despite better mobile support.",
219
- alternatives_considered: [
220
- "localStorage - Rejected: Vulnerable to XSS attacks",
221
- "sessionStorage - Rejected: Doesn't persist across tabs",
222
- "IndexedDB - Rejected: Overly complex for simple token storage"
223
- ],
224
- tradeoffs: {
225
- "pros": [
226
- "XSS-resistant (httpOnly flag)",
227
- "Automatic CSRF protection with SameSite",
228
- "Works on all modern browsers"
229
- ],
230
- "cons": [
231
- "Requires server-side session management",
232
- "More complex mobile app integration",
233
- "Cannot be accessed by JavaScript"
234
- ]
235
- },
236
- decided_by: "security-agent"
237
- }
238
- ```
239
-
240
- **On Day 3** - Agent 2 reads the context:
241
- - ✅ Instantly understands security was the priority
242
- - ✅ Sees all alternatives were already evaluated
243
- - ✅ No wasted time re-analyzing
244
- - ✅ Can make informed decision if requirements change
245
-
246
- ---
247
-
248
- #### **Scenario 2: Architecture Reviews & Team Handoffs**
249
-
250
- **Problem**: New developer (or AI agent) joins the project 6 months later. They see a non-standard architecture choice and want to "fix" it, not knowing it was intentional.
251
-
252
- **Real Example: Database Choice**
253
-
254
- **Without Context**:
255
- ```typescript
256
- { action: "set", key: "db/engine", value: "sqlite" }
257
- ```
258
-
259
- **New developer thinks**: *"SQLite? That's just for prototypes. Let me migrate to PostgreSQL..."*
260
- - Wastes 2 days migrating
261
- - Breaks deployment (the app runs on edge functions where PostgreSQL isn't available)
262
- - Rolls back changes
263
-
264
- **With Context**:
265
- ```typescript
266
- {
267
- action: "add_decision_context",
268
- key: "db/engine",
269
- rationale: "Using SQLite because this app deploys to Cloudflare Workers (edge compute), which provides D1 (SQLite-compatible). PostgreSQL is not available in this environment. Performance requirements are modest (< 1000 req/min).",
270
- alternatives_considered: [
271
- "PostgreSQL - Rejected: Not available on Cloudflare Workers edge runtime",
272
- "DynamoDB - Rejected: Adds 50-100ms latency vs local SQLite",
273
- "Durable Objects - Rejected: Experimental, limited query capabilities"
274
- ],
275
- tradeoffs: {
276
- "pros": [
277
- "Zero latency (co-located with compute)",
278
- "Native Cloudflare D1 support",
279
- "No external database costs",
280
- "Simple deployment"
281
- ],
282
- "cons": [
283
- "Limited to 1GB database size",
284
- "No real-time multi-write (uses eventual consistency)",
285
- "Fewer advanced SQL features than PostgreSQL"
286
- ]
287
- },
288
- decided_by: "architect-agent",
289
- related_constraint_id: 42 // Links to "must run on edge" constraint
290
- }
291
- ```
292
-
293
- **New developer reads context**:
294
- - ✅ Understands deployment environment constraint
295
- - ✅ Sees PostgreSQL was already evaluated and rejected
296
- - ✅ Saves 2 days of wasted migration work
297
- - ✅ Can propose alternative if constraints change
298
-
299
- ---
300
-
301
- #### **Scenario 3: Breaking Changes & Deprecations**
302
-
303
- **Problem**: You need to introduce a breaking API change. Future agents need to understand why compatibility was broken and how to migrate.
304
-
305
- **Example: API Versioning**
306
-
307
- **Without Context**:
308
- ```typescript
309
- { action: "set", key: "api/version", value: "v2" }
310
- ```
311
-
312
- **Future agent sees v1 code and thinks**: *"This is old, should I delete it?"*
313
-
314
- **With Context**:
315
- ```typescript
316
- {
317
- action: "add_decision_context",
318
- key: "api/version_v2_breaking_change",
319
- rationale: "Introduced v2 API with breaking changes to fix fundamental design flaw in v1's authentication model. V1 used client-provided user IDs (security vulnerability CVE-2024-XXXX). V2 enforces server-side session validation. V1 will be deprecated 2025-12-31.",
320
- alternatives_considered: [
321
- "Patch v1 in-place - Rejected: Would break all existing clients immediately",
322
- "Add optional server-validation flag - Rejected: Allows insecure usage to persist",
323
- "Create v2 with gradual migration - Selected: Gives clients 12 months to migrate"
324
- ],
325
- tradeoffs: {
326
- "pros": [
327
- "Fixes critical security vulnerability",
328
- "Provides migration window for clients",
329
- "Cleaner API design in v2"
330
- ],
331
- "cons": [
332
- "Requires maintaining two API versions for 12 months",
333
- "Client migration effort (approx 2 hours per integration)",
334
- "Potential user confusion during transition"
335
- ]
336
- },
337
- decided_by: "security-team",
338
- related_task_id: 156 // Links to "Implement v2 API" task
339
- }
340
- ```
341
-
342
- **Future agent benefits**:
343
- - ✅ Understands why v1 can't be deleted yet (12-month migration window)
344
- - ✅ Knows exact deprecation date (2025-12-31)
345
- - ✅ Can communicate migration requirements to users
346
- - ✅ Understands security reasoning behind breaking change
347
-
348
- ---
349
-
350
- #### **Scenario 4: Performance Optimization Trade-offs**
351
-
352
- **Problem**: Performance optimization often involves trade-offs (memory vs speed, complexity vs latency). Future agents need to understand these choices to avoid "optimizing" in the wrong direction.
353
-
354
- **Example: Caching Strategy**
355
-
356
- **With Context**:
357
- ```typescript
358
- {
359
- action: "add_decision_context",
360
- key: "cache/strategy",
361
- rationale: "Using LRU cache with 1000-item limit instead of unbounded cache. Benchmarks showed 1000 items covers 98% of requests with 50MB memory usage. Unbounded cache grew to 2GB in production testing, causing OOM errors.",
362
- alternatives_considered: [
363
- "Unbounded cache - Rejected: Memory leaks in long-running processes",
364
- "TTL-based cache - Rejected: Hot items get evicted unnecessarily",
365
- "Two-tier (L1 LRU + L2 Redis) - Rejected: Adds 5ms latency and operational complexity"
366
- ],
367
- tradeoffs: {
368
- "pros": [
369
- "Predictable memory usage (max 50MB)",
370
- "98% hit rate on production traffic",
371
- "Simple implementation (no external dependencies)"
372
- ],
373
- "cons": [
374
- "2% of requests miss cache (cold items)",
375
- "No cross-server cache sharing",
376
- "Requires tuning item limit per deployment size"
377
- ]
378
- },
379
- decided_by: "performance-agent"
380
- }
381
- ```
382
-
383
- **Future optimization agent**:
384
- - ✅ Understands 1000-item limit is intentional (not arbitrary)
385
- - ✅ Knows unbounded cache was already tested and failed
386
- - ✅ Can propose Redis tier if cross-server sharing becomes critical
387
- - ✅ Won't waste time re-benchmarking already-tested alternatives
388
-
389
- ---
390
-
391
- ## Workflow Patterns
392
-
393
- ### Pattern 1: Decision → Context → Task
394
-
395
- **Use when**: A decision requires implementation work
396
-
397
- ```typescript
398
- // Step 1: Make the decision
399
- {
400
- action: "set",
401
- key: "db/connection_pooling",
402
- value: "enabled",
403
- tags: ["performance", "database"]
404
- }
405
-
406
- // Step 2: Document context
407
- {
408
- action: "add_decision_context",
409
- key: "db/connection_pooling",
410
- rationale: "Enabling connection pooling to reduce connection overhead from 50ms to 5ms per query. Application makes 100 req/sec, so this saves 4.5 seconds of connection time per second (90% reduction).",
411
- tradeoffs: {
412
- "pros": ["90% connection time reduction", "Better resource utilization"],
413
- "cons": ["Requires pool size tuning", "More complex error handling"]
414
- }
415
- }
416
-
417
- // Step 3: Create implementation task
418
- {
419
- action: "create",
420
- title: "Implement database connection pooling",
421
- layer: "data",
422
- tags: ["performance"],
423
- priority: "high"
424
- }
425
-
426
- // Step 4: Link decision to task
427
- {
428
- action: "add_decision_context",
429
- key: "db/connection_pooling",
430
- rationale: "...", // Same as above
431
- related_task_id: 123 // Link to the task created in step 3
432
- }
433
- ```
434
-
435
- ---
436
-
437
- ### Pattern 2: Review Decision Context Over Time
438
-
439
- **Use when**: Requirements change, and you need to revisit old decisions
440
-
441
- ```typescript
442
- // Query all decision contexts for a specific layer
443
- {
444
- action: "list_decision_contexts",
445
- decision_key: "auth/token_storage" // Get all context entries for this decision
446
- }
447
-
448
- // Example response:
449
- {
450
- "contexts": [
451
- {
452
- "id": 1,
453
- "decision_key": "auth/token_storage",
454
- "rationale": "Using httpOnly cookies...",
455
- "decided_by": "security-agent",
456
- "decision_date": "2025-01-15T10:00:00Z"
457
- },
458
- {
459
- "id": 5,
460
- "decision_key": "auth/token_storage",
461
- "rationale": "Updated to add SameSite=Strict after CSRF attack attempt...",
462
- "decided_by": "security-team",
463
- "decision_date": "2025-03-20T14:30:00Z"
464
- }
465
- ]
466
- }
467
- ```
468
-
469
- **Insight**: Decision context accumulates over time, showing decision evolution.
470
-
471
- ---
472
-
473
- ## Best Practices
474
-
475
- ### 1. Write for Future You (or Future AI)
476
-
477
- Assume the reader has **zero context** about your project. Explain:
478
- - **Why** this decision was necessary
479
- - **What problem** it solves
480
- - **Why alternatives** were rejected
481
-
482
- ❌ Bad rationale:
483
- ```
484
- "Using Redis for better performance"
485
- ```
486
-
487
- ✅ Good rationale:
488
- ```
489
- "Using Redis for session storage to handle 10,000 concurrent users. Previous in-memory storage caused server crashes under load due to limited RAM (8GB per instance). Redis provides distributed storage with automatic failover."
490
- ```
491
-
492
- ---
493
-
494
- ### 2. Use JSON Arrays for Alternatives
495
-
496
- Make alternatives scannable and structured:
497
-
498
- ```typescript
499
- alternatives_considered: [
500
- "Option A - Rejected: Reason X",
501
- "Option B - Rejected: Reason Y",
502
- "Option C - Selected: Reason Z"
503
- ]
504
- ```
505
-
506
- ---
507
-
508
- ### 3. Balance Pros/Cons Honestly
509
-
510
- Don't hide the downsides - future developers need to know when to revisit:
511
-
512
- ```typescript
513
- tradeoffs: {
514
- "pros": [
515
- "Fast implementation (2 days)",
516
- "Well-documented library"
517
- ],
518
- "cons": [
519
- "Library is deprecated (EOL 2026)", // Important to know!
520
- "License is AGPL (might conflict with commercial use)"
521
- ]
522
- }
523
- ```
524
-
525
- ---
526
-
527
- ### 4. Link to Related Work
528
-
529
- Create traceability:
530
-
531
- ```typescript
532
- {
533
- related_task_id: 42, // Implementation task
534
- related_constraint_id: 7 // "Must support offline mode" constraint
535
- }
536
- ```
537
-
538
- ---
539
-
540
- ## API Reference
541
-
542
- ### Add Decision Context
543
-
544
- ```typescript
545
- {
546
- action: "add_decision_context",
547
- key: "decision_key", // Required: Decision to document
548
- rationale: "Explanation...", // Required: Why this decision?
549
- alternatives_considered: [ // Optional: JSON array
550
- "Alternative 1 - Rejected: Reason",
551
- "Alternative 2 - Selected: Reason"
552
- ],
553
- tradeoffs: { // Optional: JSON object
554
- "pros": ["Pro 1", "Pro 2"],
555
- "cons": ["Con 1", "Con 2"]
556
- },
557
- decided_by: "agent-name", // Optional: Who decided
558
- related_task_id: 123, // Optional: Link to task
559
- related_constraint_id: 45 // Optional: Link to constraint
560
- }
561
- ```
562
-
563
- ### Get Decision with Context
564
-
565
- ```typescript
566
- {
567
- action: "get",
568
- key: "decision_key",
569
- include_context: true // Include all context entries
570
- }
571
- ```
572
-
573
- ### List Decision Contexts
574
-
575
- ```typescript
576
- {
577
- action: "list_decision_contexts",
578
- decision_key: "auth/token_storage", // Optional: Filter by decision
579
- related_task_id: 123, // Optional: Filter by task
580
- limit: 50, // Optional: Default 50
581
- offset: 0 // Optional: Default 0
582
- }
583
- ```
584
-
585
- ---
586
-
587
- ## Version History
588
-
589
- | Version | Changes |
590
- |---------|---------|
591
- | **v4.0.0** | Feature fully preserved. Schema refactored with `v4_` prefix: `v4_decision_context` table. No API changes. |
592
- | **v3.9.0** | Added Decision Intelligence System with duplicate detection and automatic historical record consolidation. Added `check_duplicate`, `versions`, and policy-based management. |
593
- | **v3.2.2** | Initial Release: `add_decision_context` action, `rationale`, `alternatives_considered`, `tradeoffs` fields, `related_task_id` and `related_constraint_id` linking. |
594
-
595
- ---
596
-
597
- ## Token Efficiency
598
-
599
- **Decision Context is optional** - only use it for important decisions where future understanding is critical.
600
-
601
- **Token Cost Comparison**:
602
- - Simple decision: ~50 tokens
603
- - Decision with context: ~200-500 tokens
604
- - Time saved avoiding re-analysis: 1000-5000 tokens
605
-
606
- **Use it when**:
607
- - Decision is non-obvious or controversial
608
- - Trade-offs were significant
609
- - Future developers might question the choice
610
- - Multiple alternatives were considered
611
-
612
- **Skip it when**:
613
- - Decision is self-explanatory
614
- - Value is temporary/experimental
615
- - Standard industry practice
616
-
617
- ---
618
-
619
- ## Migration from Old Decisions
620
-
621
- If you have old decisions that need context, add it retroactively:
622
-
623
- ```typescript
624
- // Step 1: Find old decision
625
- { action: "get", key: "old_decision" }
626
-
627
- // Step 2: Add context
628
- {
629
- action: "add_decision_context",
630
- key: "old_decision",
631
- rationale: "Retroactive documentation: This decision was made on 2024-06-15 to solve problem X. At the time, we chose approach Y because of constraint Z."
632
- }
633
- ```
634
-
635
- ---
636
-
637
- ## Summary: When to Use Decision Context
638
-
639
- | **Scenario** | **Use Decision Context?** | **Why?** |
640
- |-------------|---------------------------|----------|
641
- | Simple config value | ❌ No | Self-explanatory |
642
- | Architecture choice | ✅ Yes | Future developers need to understand trade-offs |
643
- | Breaking change | ✅ Yes | Migration context critical |
644
- | Temporary experiment | ❌ No | Will be replaced soon |
645
- | Performance optimization | ✅ Yes | Trade-offs need documentation |
646
- | Security decision | ✅ Yes | Reasoning must be preserved |
647
- | Technology selection | ✅ Yes | Alternatives evaluation important |
648
-
649
- ---
650
-
651
- ## Key Takeaways
652
-
653
- ### Decision Context + Decision Intelligence = Complete Historical Records
654
-
655
- **v3.9.0 transforms how you manage project knowledge:**
656
-
657
- 1. **Decision Context** (v3.2.2) → Adds rich documentation (rationale, alternatives, trade-offs)
658
- 2. **Decision Intelligence** (v3.9.0) → Prevents fragmentation, maintains continuity
659
-
660
- **Together they provide:**
661
- - **Living historical records** that evolve with your project
662
- - **Version trails** showing decision evolution over time
663
- - **Automatic consolidation** preventing scattered duplicates
664
- - **Rich context** explaining WHY decisions were made
665
- - **Discoverable knowledge** via similarity search
666
-
667
- **Best workflow:**
668
- 1. Use `check_duplicate` before creating new decisions
669
- 2. Let auto-update merge similar decisions into canonical records
670
- 3. Add rich context to the consolidated record
671
- 4. Query `versions` to see decision evolution
672
-
673
- **Decision Context transforms decisions from "what" into "why"** - making your codebase understandable to future developers and AI agents across months or years of development.
674
-
675
- **Decision Intelligence ensures decisions are living records** - automatically updated and consolidated rather than scattered across fragmented entries.