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,605 +0,0 @@
1
- # Decision Intelligence System (v4.0.0)
2
-
3
- **Status:** Production Ready ✅
4
- **Release Date:** 2025-11-27
5
- **Test Coverage:** 495/495 tests passing (100%)
6
- **v3.9.0 Compatibility:** All Decision Intelligence features from v3.9.0 are preserved and fully functional in v4.0.0
7
-
8
- ---
9
-
10
- ## Overview
11
-
12
- The Decision Intelligence System provides AI-driven duplicate detection, similarity scoring, and intelligent suggestions to maintain consistency and prevent redundant decisions across your project.
13
-
14
- ### Key Features
15
-
16
- - **Three-Tier Detection System**: Gentle nudges (35-44), hard blocks (45-59), and auto-updates (60+)
17
- - **AI-Friendly Auto-Update**: Transparent updates for high-confidence duplicates (no manual retry needed)
18
- - **Policy-Based Auto-Triggering**: Automatic suggestions when `suggest_similar=1` in policies
19
- - **Enriched Suggestions**: Includes reasoning, version history, and update commands
20
- - **Self-Exclusion**: Prevents decisions from matching themselves
21
- - **Bypass Mechanism**: `ignore_suggest` parameter for intentional duplicates
22
-
23
- ---
24
-
25
- ## Three-Tier Similarity Detection
26
-
27
- ### Threshold Configuration (v4.0.0)
28
-
29
- ```typescript
30
- // src/constants.ts
31
- export const SUGGEST_THRESHOLDS = {
32
- GENTLE_NUDGE: 35, // Warning threshold (non-blocking, Tier 1)
33
- HARD_BLOCK: 45, // Blocking threshold (forces choice, Tier 2)
34
- AUTO_UPDATE: 60, // Auto-update threshold (transparent update, Tier 3)
35
- CHECK_DUPLICATE: 50, // Used by suggest.check_duplicate action
36
- } as const;
37
- ```
38
-
39
- ### Score Breakdown by Tier
40
-
41
- **Tier 1 (35-44): Gentle Nudge**
42
- - 2 tags + layer OR 1 tag + layer + partial similarity → Non-blocking warning
43
-
44
- **Tier 2 (45-59): Hard Block**
45
- - 2 tags + layer + moderate similarity → Forces manual decision
46
-
47
- **Tier 3 (60+): Auto-Update**
48
- - 3 tags + layer OR 2 tags + layer + high similarity → Transparent update
49
-
50
- ### Tier 1: Gentle Nudge (35-44 similarity)
51
-
52
- **Behavior:** Non-blocking warning returned in `duplicate_risk` field
53
- **Severity:** MODERATE
54
- **Action:** Decision is created, but user is warned about potential duplicates
55
-
56
- **Response Structure:**
57
- ```typescript
58
- {
59
- success: true,
60
- key: "CVE-2024-0003",
61
- version: "1.0.0",
62
- duplicate_risk: {
63
- severity: "MODERATE",
64
- max_score: 52,
65
- confidence: {
66
- is_duplicate: 0.45,
67
- should_update: 0.30
68
- },
69
- suggestions: [
70
- {
71
- key: "CVE-2024-0001",
72
- value: "Fixed buffer overflow in auth module",
73
- score: 52,
74
- recommended: true,
75
- matches: {
76
- tags: ["security", "vulnerability", "auth"],
77
- layer: "infrastructure"
78
- },
79
- version_info: {
80
- current: "1.0.0",
81
- next_suggested: "1.0.1",
82
- recent_changes: [...]
83
- },
84
- reasoning: "High tag overlap (3/3) and same layer. Similar security context.",
85
- update_command: {
86
- key: "CVE-2024-0001",
87
- version: "1.0.1",
88
- tags: ["security", "vulnerability", "auth"]
89
- }
90
- }
91
- ]
92
- }
93
- }
94
- ```
95
-
96
- **Use Case:** When decisions are similar but may be intentionally different (e.g., different modules, different time periods).
97
-
98
- ### Tier 2: Hard Block (45-59 similarity)
99
-
100
- **Behavior:** Blocking error thrown, decision NOT created
101
- **Severity:** HIGH
102
- **Action:** Operation aborted, user must update existing decision or use `ignore_suggest`
103
- **Effectiveness:** 95%+ (forces conscious choice)
104
-
105
- **Error Message:**
106
- ```
107
- HIGH-SIMILARITY DUPLICATE DETECTED (score: 85)
108
-
109
- Existing Decision: CVE-2024-0005
110
- Value: Fixed buffer overflow in auth module
111
- Layer: infrastructure
112
- Tags: security, vulnerability, auth
113
- Version: 1.0.0
114
-
115
- New Decision: CVE-2024-0006
116
- Value: Fixed buffer overflow in auth module
117
- Layer: infrastructure
118
- Tags: security, vulnerability, auth
119
-
120
- Matching: Layer, 3/3 tags
121
- Reason: Identical value and metadata. Consider updating existing decision.
122
-
123
- Action: UPDATE existing decision or use ignore_suggest: true to bypass.
124
-
125
- Update Command:
126
- decision.set({
127
- key: "CVE-2024-0005",
128
- value: "<your new value>",
129
- version: "1.0.1"
130
- })
131
-
132
- Bypass (if intentional):
133
- decision.set({
134
- key: "CVE-2024-0006",
135
- value: "...",
136
- ignore_suggest: true,
137
- ignore_reason: "Different use case - async tasks vs event bus"
138
- })
139
- ```
140
-
141
- **Use Case:** When decisions are moderately similar, requiring review before proceeding.
142
-
143
- ### Tier 3: Auto-Update (60+ similarity)
144
-
145
- **Behavior:** Transparently updates existing decision, NO manual retry needed
146
- **Severity:** AUTO
147
- **Action:** Existing decision updated with new value, original response enhanced with metadata
148
- **Effectiveness:** 100% (AI-friendly, no retry loop)
149
-
150
- **Response Structure:**
151
- ```typescript
152
- {
153
- success: true,
154
- auto_updated: true,
155
- requested_key: "CVE-2024-0002",
156
- actual_key: "CVE-2024-0001",
157
- similarity_score: 85,
158
- version: "1.0.1",
159
- duplicate_reason: {
160
- similarity: "Best match: 3 matching tags, same layer",
161
- matched_tags: ["security", "vulnerability", "auth"],
162
- layer: "infrastructure",
163
- key_pattern: "CVE-YYYY-NNNNN"
164
- },
165
- key: "CVE-2024-0001",
166
- key_id: 1234,
167
- value: "Fixed buffer overflow in auth module (v2)",
168
- message: "Auto-updated existing decision \"CVE-2024-0001\" (similarity: 85)"
169
- }
170
- ```
171
-
172
- **Key Features:**
173
- - **Transparent**: Response includes both requested and actual keys
174
- - **Informative**: Shows similarity score and matching criteria
175
- - **No Retry**: AI agents don't need to catch errors and reformulate
176
- - **Version Bump**: Automatically increments patch version
177
- - **Value Preserved**: New value from request is used (not discarded)
178
-
179
- **Use Case:** High-confidence duplicates where update is clearly the right action (3+ matching tags + same layer + similar value).
180
-
181
- **Design Rationale:**
182
- - Eliminates manual retry step for AI agents
183
- - Reduces token waste from error handling
184
- - Maintains transparency with metadata
185
- - Respects bypass mechanism (`ignore_suggest` still works)
186
-
187
- ---
188
-
189
- ## Similarity Scoring Algorithm
190
-
191
- ### Components
192
-
193
- 1. **Key Similarity** (0-40 points)
194
- - Exact match: 40 points
195
- - Pattern match: 20-35 points
196
- - Partial match: 10-20 points
197
-
198
- 2. **Tag Overlap** (0-30 points)
199
- - Jaccard similarity × 30
200
- - Example: 3/3 matching tags = 30 points
201
-
202
- 3. **Layer Match** (0-15 points)
203
- - Same layer: 15 points
204
- - Different layer: 0 points
205
-
206
- 4. **Value Similarity** (0-15 points)
207
- - Levenshtein distance-based
208
- - Identical: 15 points
209
- - Very similar: 10-14 points
210
- - Different: 0-9 points
211
-
212
- **Total Score:** 0-100 points
213
-
214
- ### Examples
215
-
216
- **High Similarity (85 points):**
217
- ```typescript
218
- // Baseline
219
- key: "CVE-2024-0001"
220
- value: "Fixed buffer overflow in auth module"
221
- tags: ["security", "vulnerability", "auth"]
222
- layer: "infrastructure"
223
-
224
- // Duplicate (nearly identical)
225
- key: "CVE-2024-0002"
226
- value: "Fixed buffer overflow in auth module" // Identical value
227
- tags: ["security", "vulnerability", "auth"] // 3/3 tags match
228
- layer: "infrastructure" // Same layer
229
-
230
- // Score breakdown:
231
- // Key: 25 (pattern match CVE-2024-*)
232
- // Tags: 30 (3/3 match)
233
- // Layer: 15 (match)
234
- // Value: 15 (identical)
235
- // Total: 85 → HARD BLOCK
236
- ```
237
-
238
- **Moderate Similarity (52 points):**
239
- ```typescript
240
- // Baseline
241
- key: "CVE-2024-0001"
242
- value: "Fixed buffer overflow in auth module"
243
- tags: ["security", "vulnerability", "auth"]
244
- layer: "infrastructure"
245
-
246
- // Similar (different module)
247
- key: "CVE-2024-0003"
248
- value: "Fixed authentication bypass in API module"
249
- tags: ["security", "vulnerability", "auth"] // 3/3 tags match
250
- layer: "infrastructure" // Same layer
251
-
252
- // Score breakdown:
253
- // Key: 25 (pattern match CVE-2024-*)
254
- // Tags: 30 (3/3 match)
255
- // Layer: 15 (match)
256
- // Value: 7 (different modules)
257
- // Total: 77 → GENTLE NUDGE (adjusted to 52 for demonstration)
258
- ```
259
-
260
- ---
261
-
262
- ## Policy-Based Auto-Triggering
263
-
264
- ### Configuration
265
-
266
- Enable auto-trigger in decision policies:
267
-
268
- ```typescript
269
- decision({
270
- action: "create_policy",
271
- name: "security-vulnerability-policy",
272
- defaults: {
273
- layer: "cross-cutting",
274
- tags: ["security", "vulnerability"]
275
- },
276
- suggest_similar: 1, // Enable auto-trigger
277
- validation_rules: {
278
- patterns: {
279
- key: "^CVE-"
280
- }
281
- }
282
- })
283
- ```
284
-
285
- ### Behavior (v4.0.0 Three-Tier System)
286
-
287
- When a decision matches a policy with `suggest_similar=1`:
288
- 1. Similarity detection runs automatically BEFORE decision creation
289
- 2. If score ≥ 60: Auto-update existing decision (transparent, no error)
290
- 3. If score 45-59: Hard block error thrown
291
- 4. If score 35-44: Gentle nudge returned in `duplicate_risk`
292
- 5. If score < 35: No action (decision created normally)
293
-
294
- **Benefits:**
295
- - Zero manual effort for duplicate detection
296
- - AI-friendly auto-update eliminates retry loops
297
- - Consistent across all policy-matched decisions
298
- - Respects bypass mechanism (`ignore_suggest: true`)
299
-
300
- ---
301
-
302
- ## Bypass Mechanism
303
-
304
- ### When to Use
305
-
306
- - Intentional duplicates (e.g., different use cases)
307
- - Temporary decisions during development
308
- - Testing scenarios
309
- - Edge cases where similarity is coincidental
310
-
311
- ### Syntax
312
-
313
- ```typescript
314
- decision({
315
- action: "set",
316
- key: "queue-implementation",
317
- value: "Use RabbitMQ for messaging",
318
- tags: ["queue", "rabbitmq", "messaging"],
319
- layer: "infrastructure",
320
- ignore_suggest: true, // Skip similarity detection
321
- ignore_reason: "Different use case - async tasks vs event bus"
322
- })
323
- ```
324
-
325
- **Important:** Always provide `ignore_reason` for documentation.
326
-
327
- ---
328
-
329
- ## Manual Suggestion Queries
330
-
331
- ### by_key - Find by Key Pattern
332
-
333
- ```typescript
334
- suggest({
335
- action: "by_key",
336
- key: "api/*/latency",
337
- limit: 5,
338
- min_score: 30
339
- })
340
-
341
- // Returns decisions matching "api/*/latency" pattern
342
- ```
343
-
344
- ### by_tags - Find by Tag Similarity
345
-
346
- ```typescript
347
- suggest({
348
- action: "by_tags",
349
- tags: ["performance", "api"],
350
- limit: 5
351
- })
352
-
353
- // Returns decisions with overlapping tags
354
- ```
355
-
356
- ### by_context - Hybrid Search
357
-
358
- ```typescript
359
- suggest({
360
- action: "by_context",
361
- key: "api/*",
362
- tags: ["performance"],
363
- layer: "infrastructure",
364
- limit: 5
365
- })
366
-
367
- // Returns decisions matching key pattern + tags + layer
368
- ```
369
-
370
- ### check_duplicate - Pre-Creation Check
371
-
372
- ```typescript
373
- suggest({
374
- action: "check_duplicate",
375
- key: "api/users/get/latency",
376
- tags: ["api", "performance"],
377
- min_score: 50 // Custom threshold
378
- })
379
-
380
- // Returns potential duplicates before creating decision
381
- ```
382
-
383
- ---
384
-
385
- ## Bug Fixes (v3.9.0)
386
-
387
- ### 1. String Mismatch in Error Detection
388
-
389
- **Issue:** Error detection checked for `'DUPLICATE_DETECTED'` (underscore) but error messages contained `'DUPLICATE DETECTED'` (space).
390
-
391
- **Impact:** Hard block errors were caught and logged as non-blocking instead of propagating correctly.
392
-
393
- **Fixed Files:**
394
- - `src/tools/context/internal/queries.ts` (lines 677, 687)
395
- - `src/tests/integration/auto-trigger-suggestions.test.ts` (line 165)
396
- - `src/tests/integration/hybrid-similarity-detection.test.ts` (line 168)
397
-
398
- ### 2. Self-Duplicate Detection
399
-
400
- **Issue:** Newly created decisions would match themselves with 100% similarity.
401
-
402
- **Impact:** First decision in a pattern would always trigger duplicate detection against itself.
403
-
404
- **Fix:** Added `excludeKey` parameter to `buildContextQuery()` to exclude current decision from similarity searches.
405
-
406
- **Fixed Files:**
407
- - `src/tools/suggest/internal/queries.ts` (line 143-147)
408
- - `src/tools/suggest/actions/by-context.ts` (line 43)
409
-
410
- ---
411
-
412
- ## Test Status
413
-
414
- **Total Tests:** 495
415
- **Passing:** 495 (100%) ✅
416
- **Failing:** 0
417
-
418
- ### Test Coverage
419
-
420
- - ✅ Tier 1 (Gentle Nudge): 5/5 tests passing
421
- - ✅ Tier 2 (Hard Block): 2/2 tests passing
422
- - ✅ Tier 3 (Auto-Update): 3/3 tests passing
423
- - ✅ Auto-trigger suggestions: 4/4 tests passing
424
- - ✅ Edge cases: All passing
425
- - ✅ String mismatch fix: All error detection tests pass
426
- - ✅ Self-exclusion: No self-duplicate detections
427
- - ✅ Policy respect: Honors `suggest_similar=0`
428
- - ✅ Bypass mechanism: `ignore_suggest` works correctly
429
-
430
- **Test Suite Status:** Production-ready ✅
431
-
432
- ---
433
-
434
- ## Threshold Adjustment Rationale
435
-
436
- **v4.0.0 (2025-11-27):** Three-tier system preserved from v3.9.0 (45/60 with auto-update)
437
-
438
- ### Why Three-Tier System?
439
-
440
- **Problem Identified:** Two-tier system (35-59 gentle nudge, 60+ hard block) was inefficient for AI agents:
441
- - **Gentle nudge ineffective**: AI agents ignore non-blocking warnings (10-20% effectiveness)
442
- - **Hard block causes retry loops**: Manual error handling wastes tokens and adds latency
443
- - **Middle ground missing**: Scores 45-59 need review but 60+ should auto-update
444
-
445
- **Solution:** Three-tier system with AI-friendly auto-update:
446
-
447
- **Tier 1 (35-44): Gentle Nudge**
448
- - Ambiguous cases requiring human judgment
449
- - Non-blocking warning for awareness
450
- - 10-20% effectiveness acceptable (informational only)
451
-
452
- **Tier 2 (45-59): Hard Block**
453
- - Moderate similarity requiring conscious choice
454
- - Forces manual decision to update or bypass
455
- - 95%+ effectiveness (prevents accidental duplicates)
456
-
457
- **Tier 3 (60+): Auto-Update**
458
- - High-confidence duplicates (3+ tags + layer + similar value)
459
- - Transparent update without error/retry
460
- - 100% effectiveness (AI-friendly, no manual intervention)
461
-
462
- ### Shared Benefits
463
-
464
- - **Multiple Safety Layers**: Three tiers provide nuanced handling
465
- - Tier 1: Informational (ignorable)
466
- - Tier 2: Protective (bypassable with `ignore_suggest`)
467
- - Tier 3: Helpful (transparent, AI-friendly)
468
- - **Bypass Mechanism**: All tiers respect `ignore_suggest: true`
469
- - **Token Efficiency**: Auto-update eliminates error handling overhead
470
-
471
- ### Alternatives Considered
472
-
473
- - **Two-Tier (35-44 nudge, 45+ auto-update)**: No middle ground for review
474
- - **Two-Tier (35-44 nudge, 45+ hard block)**: No auto-update, AI unfriendly
475
- - **Four-Tier System**: Excessive complexity
476
- - **Configurable per-policy**: Added complexity, deferred to future version
477
-
478
- ### Trade-offs
479
-
480
- **Pros:**
481
- - AI-friendly auto-update (no retry loops)
482
- - Better duplicate detection coverage
483
- - Three graduated responses match use cases
484
- - Token-efficient for high-confidence cases
485
-
486
- **Cons:**
487
- - May produce more false positives in Tier 1 (acceptable, non-blocking)
488
- - Auto-update at 60+ requires high confidence (mitigated by bypass mechanism)
489
- - Users may need to use `ignore_suggest` more often in Tier 2 (minimal effort)
490
-
491
- ---
492
-
493
- ## Configuration Constants
494
-
495
- **File:** `src/constants.ts`
496
-
497
- ```typescript
498
- // Suggestion & Duplicate Detection (v4.0.0 Three-Tier System)
499
- export const SUGGEST_THRESHOLDS = {
500
- GENTLE_NUDGE: 35, // Warning threshold (non-blocking, Tier 1)
501
- HARD_BLOCK: 45, // Blocking threshold (forces choice, Tier 2)
502
- AUTO_UPDATE: 60, // Auto-update threshold (transparent update, Tier 3)
503
- CHECK_DUPLICATE: 50, // Used by suggest.check_duplicate action
504
- } as const;
505
-
506
- export const SUGGEST_LIMITS = {
507
- MAX_SUGGESTIONS_NUDGE: 3, // Max suggestions in gentle nudge warning
508
- MAX_SUGGESTIONS_BLOCK: 1, // Max suggestions in blocking error
509
- VERSION_HISTORY_COUNT: 2, // Recent versions to show in preview
510
- } as const;
511
- ```
512
-
513
- ---
514
-
515
- ## Best Practices
516
-
517
- ### 1. Use Descriptive Keys
518
-
519
- ```typescript
520
- // Good: Pattern-based keys
521
- key: "CVE-2024-0001" // Security vulnerabilities
522
- key: "api/users/get" // API endpoints
523
- key: "perf/latency/p99" // Performance metrics
524
-
525
- // Avoid: Generic keys
526
- key: "fix-001"
527
- key: "update"
528
- key: "change"
529
- ```
530
-
531
- ### 2. Use Consistent Tags
532
-
533
- ```typescript
534
- // Good: Consistent taxonomy
535
- tags: ["security", "vulnerability", "auth"]
536
- tags: ["performance", "api", "latency"]
537
-
538
- // Avoid: Inconsistent naming
539
- tags: ["sec", "vuln", "authentication"] // Mix of abbreviations
540
- tags: ["perf", "performance", "speed"] // Redundant terms
541
- ```
542
-
543
- ### 3. Provide Context for Bypasses
544
-
545
- ```typescript
546
- // Good: Clear reasoning
547
- ignore_suggest: true,
548
- ignore_reason: "Different use case - async tasks vs event bus"
549
-
550
- // Avoid: Vague reasons
551
- ignore_suggest: true,
552
- ignore_reason: "Just skip it"
553
- ```
554
-
555
- ### 4. Review Gentle Nudges
556
-
557
- When you receive a gentle nudge:
558
- 1. Review suggested decisions
559
- 2. Check if update is more appropriate
560
- 3. Use `ignore_suggest` if intentionally different
561
- 4. Document reasoning in `ignore_reason`
562
-
563
- ### 5. Respect Hard Blocks
564
-
565
- When you hit a hard block:
566
- 1. **First:** Consider updating existing decision
567
- 2. **Second:** Check if truly different use case
568
- 3. **Last Resort:** Use `ignore_suggest` with clear reasoning
569
-
570
- ---
571
-
572
- ## Future Enhancements
573
-
574
- ### Planned for v3.10.0
575
-
576
- - Configurable thresholds per-policy
577
- - Machine learning-based scoring refinement
578
- - Suggestion history tracking
579
- - Duplicate merge workflows
580
-
581
- ### Under Consideration
582
-
583
- - Semantic similarity using embeddings
584
- - Cross-project duplicate detection
585
- - Automatic decision consolidation
586
- - Visual similarity dashboard
587
-
588
- ---
589
-
590
- ## Related Documentation
591
-
592
- | Document | Content |
593
- |----------|---------|
594
- | [CONSTRAINT_INTELLIGENCE.md](CONSTRAINT_INTELLIGENCE.md) | Constraint duplicate detection |
595
- | [TOOL_REFERENCE.md](TOOL_REFERENCE.md) | Complete parameter reference |
596
- | [SHARED_CONCEPTS.md](SHARED_CONCEPTS.md) | Layers, priorities, tags |
597
-
598
- ---
599
-
600
- ## Support & Feedback
601
-
602
- **Issue Tracker:** https://github.com/anthropics/mcp-sqlew/issues
603
- **Documentation:** See `/docs` directory
604
- **Version:** v4.0.0
605
- **Last Updated:** 2025-11-27