sqlew 4.1.2 → 4.3.1

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 (232) hide show
  1. package/CHANGELOG.md +59 -0
  2. package/README.md +268 -409
  3. package/assets/claude-md-snippets/plan-mode-integration.md +36 -10
  4. package/assets/config.example.toml +120 -282
  5. package/assets/sample-skills/sqlew-decision-format/SKILL.md +73 -0
  6. package/dist/cli/hooks/check-completion.d.ts.map +1 -1
  7. package/dist/cli/hooks/check-completion.js +90 -2
  8. package/dist/cli/hooks/check-completion.js.map +1 -1
  9. package/dist/cli/hooks/init-hooks.d.ts.map +1 -1
  10. package/dist/cli/hooks/init-hooks.js +97 -5
  11. package/dist/cli/hooks/init-hooks.js.map +1 -1
  12. package/dist/cli/hooks/on-enter-plan.d.ts +22 -0
  13. package/dist/cli/hooks/on-enter-plan.d.ts.map +1 -0
  14. package/dist/cli/hooks/on-enter-plan.js +51 -0
  15. package/dist/cli/hooks/on-enter-plan.js.map +1 -0
  16. package/dist/cli/hooks/on-exit-plan.d.ts +20 -0
  17. package/dist/cli/hooks/on-exit-plan.d.ts.map +1 -0
  18. package/dist/cli/hooks/on-exit-plan.js +66 -0
  19. package/dist/cli/hooks/on-exit-plan.js.map +1 -0
  20. package/dist/cli/hooks/on-stop.d.ts +19 -0
  21. package/dist/cli/hooks/on-stop.d.ts.map +1 -0
  22. package/dist/cli/hooks/on-stop.js +152 -0
  23. package/dist/cli/hooks/on-stop.js.map +1 -0
  24. package/dist/cli/hooks/on-subagent-stop.d.ts +20 -0
  25. package/dist/cli/hooks/on-subagent-stop.d.ts.map +1 -0
  26. package/dist/cli/hooks/on-subagent-stop.js +94 -0
  27. package/dist/cli/hooks/on-subagent-stop.js.map +1 -0
  28. package/dist/cli/hooks/plan-pattern-extractor.d.ts +87 -0
  29. package/dist/cli/hooks/plan-pattern-extractor.d.ts.map +1 -0
  30. package/dist/cli/hooks/plan-pattern-extractor.js +218 -0
  31. package/dist/cli/hooks/plan-pattern-extractor.js.map +1 -0
  32. package/dist/cli/hooks/plan-processor.d.ts +43 -0
  33. package/dist/cli/hooks/plan-processor.d.ts.map +1 -0
  34. package/dist/cli/hooks/plan-processor.js +115 -0
  35. package/dist/cli/hooks/plan-processor.js.map +1 -0
  36. package/dist/cli/hooks/plan-toml-parser.d.ts +42 -0
  37. package/dist/cli/hooks/plan-toml-parser.d.ts.map +1 -0
  38. package/dist/cli/hooks/plan-toml-parser.js +178 -0
  39. package/dist/cli/hooks/plan-toml-parser.js.map +1 -0
  40. package/dist/cli/hooks/save.d.ts +7 -9
  41. package/dist/cli/hooks/save.d.ts.map +1 -1
  42. package/dist/cli/hooks/save.js +50 -25
  43. package/dist/cli/hooks/save.js.map +1 -1
  44. package/dist/cli/hooks/stdin-parser.d.ts +66 -2
  45. package/dist/cli/hooks/stdin-parser.d.ts.map +1 -1
  46. package/dist/cli/hooks/stdin-parser.js +57 -2
  47. package/dist/cli/hooks/stdin-parser.js.map +1 -1
  48. package/dist/cli/hooks/suggest.d.ts +8 -4
  49. package/dist/cli/hooks/suggest.d.ts.map +1 -1
  50. package/dist/cli/hooks/suggest.js +21 -123
  51. package/dist/cli/hooks/suggest.js.map +1 -1
  52. package/dist/cli/hooks/track-plan.d.ts +8 -1
  53. package/dist/cli/hooks/track-plan.d.ts.map +1 -1
  54. package/dist/cli/hooks/track-plan.js +64 -66
  55. package/dist/cli/hooks/track-plan.js.map +1 -1
  56. package/dist/cli.d.ts.map +1 -1
  57. package/dist/cli.js +107 -6
  58. package/dist/cli.js.map +1 -1
  59. package/dist/config/global-config.d.ts +90 -0
  60. package/dist/config/global-config.d.ts.map +1 -1
  61. package/dist/config/global-config.js +86 -1
  62. package/dist/config/global-config.js.map +1 -1
  63. package/dist/database/initialization/init.js +3 -3
  64. package/dist/database/initialization/init.js.map +1 -1
  65. package/dist/database/migrations/v4/20260102204000_v4_fix_decision_set_example.d.ts +15 -0
  66. package/dist/database/migrations/v4/20260102204000_v4_fix_decision_set_example.d.ts.map +1 -0
  67. package/dist/database/migrations/v4/20260102204000_v4_fix_decision_set_example.js +74 -0
  68. package/dist/database/migrations/v4/20260102204000_v4_fix_decision_set_example.js.map +1 -0
  69. package/dist/index.js +8 -4
  70. package/dist/index.js.map +1 -1
  71. package/dist/init-skills.d.ts +12 -3
  72. package/dist/init-skills.d.ts.map +1 -1
  73. package/dist/init-skills.js +96 -24
  74. package/dist/init-skills.js.map +1 -1
  75. package/dist/knexfile.d.ts.map +1 -1
  76. package/dist/knexfile.js +16 -12
  77. package/dist/knexfile.js.map +1 -1
  78. package/dist/server/setup.js +5 -5
  79. package/dist/server/setup.js.map +1 -1
  80. package/dist/server/tool-handlers.d.ts.map +1 -1
  81. package/dist/server/tool-handlers.js +7 -1
  82. package/dist/server/tool-handlers.js.map +1 -1
  83. package/dist/server/tool-registry.js +1 -1
  84. package/dist/server/tool-registry.js.map +1 -1
  85. package/dist/tests/feature/decision/truncate.test.d.ts +8 -0
  86. package/dist/tests/feature/decision/truncate.test.d.ts.map +1 -0
  87. package/dist/tests/feature/decision/truncate.test.js +192 -0
  88. package/dist/tests/feature/decision/truncate.test.js.map +1 -0
  89. package/dist/tests/unit/config/plan-toml-cache.test.d.ts +9 -0
  90. package/dist/tests/unit/config/plan-toml-cache.test.d.ts.map +1 -0
  91. package/dist/tests/unit/config/plan-toml-cache.test.js +230 -0
  92. package/dist/tests/unit/config/plan-toml-cache.test.js.map +1 -0
  93. package/dist/tests/unit/hooks/plan-toml-parser.test.d.ts +10 -0
  94. package/dist/tests/unit/hooks/plan-toml-parser.test.d.ts.map +1 -0
  95. package/dist/tests/unit/hooks/plan-toml-parser.test.js +316 -0
  96. package/dist/tests/unit/hooks/plan-toml-parser.test.js.map +1 -0
  97. package/dist/tools/constraints/actions/activate.d.ts +46 -0
  98. package/dist/tools/constraints/actions/activate.d.ts.map +1 -0
  99. package/dist/tools/constraints/actions/activate.js +105 -0
  100. package/dist/tools/constraints/actions/activate.js.map +1 -0
  101. package/dist/tools/constraints/actions/add.d.ts.map +1 -1
  102. package/dist/tools/constraints/actions/add.js +30 -13
  103. package/dist/tools/constraints/actions/add.js.map +1 -1
  104. package/dist/tools/constraints/actions/deactivate.d.ts.map +1 -1
  105. package/dist/tools/constraints/actions/deactivate.js +7 -4
  106. package/dist/tools/constraints/actions/deactivate.js.map +1 -1
  107. package/dist/tools/constraints/actions/get.d.ts.map +1 -1
  108. package/dist/tools/constraints/actions/get.js +10 -7
  109. package/dist/tools/constraints/actions/get.js.map +1 -1
  110. package/dist/tools/constraints/actions/suggest-pending.d.ts +41 -0
  111. package/dist/tools/constraints/actions/suggest-pending.d.ts.map +1 -0
  112. package/dist/tools/constraints/actions/suggest-pending.js +71 -0
  113. package/dist/tools/constraints/actions/suggest-pending.js.map +1 -0
  114. package/dist/tools/constraints/help/example.d.ts.map +1 -1
  115. package/dist/tools/constraints/help/example.js +65 -1
  116. package/dist/tools/constraints/help/example.js.map +1 -1
  117. package/dist/tools/constraints/help/help.d.ts.map +1 -1
  118. package/dist/tools/constraints/help/help.js +10 -5
  119. package/dist/tools/constraints/help/help.js.map +1 -1
  120. package/dist/tools/constraints/index.d.ts +2 -0
  121. package/dist/tools/constraints/index.d.ts.map +1 -1
  122. package/dist/tools/constraints/index.js +2 -0
  123. package/dist/tools/constraints/index.js.map +1 -1
  124. package/dist/tools/context/actions/add-context.d.ts.map +1 -1
  125. package/dist/tools/context/actions/add-context.js +13 -6
  126. package/dist/tools/context/actions/add-context.js.map +1 -1
  127. package/dist/tools/context/actions/has-updates.d.ts.map +1 -1
  128. package/dist/tools/context/actions/has-updates.js +0 -4
  129. package/dist/tools/context/actions/has-updates.js.map +1 -1
  130. package/dist/tools/context/actions/list-contexts.d.ts.map +1 -1
  131. package/dist/tools/context/actions/list-contexts.js +12 -7
  132. package/dist/tools/context/actions/list-contexts.js.map +1 -1
  133. package/dist/tools/context/actions/list.d.ts.map +1 -1
  134. package/dist/tools/context/actions/list.js +8 -0
  135. package/dist/tools/context/actions/list.js.map +1 -1
  136. package/dist/tools/context/actions/search-advanced.d.ts.map +1 -1
  137. package/dist/tools/context/actions/search-advanced.js +41 -27
  138. package/dist/tools/context/actions/search-advanced.js.map +1 -1
  139. package/dist/tools/context/actions/search-layer.d.ts.map +1 -1
  140. package/dist/tools/context/actions/search-layer.js +8 -0
  141. package/dist/tools/context/actions/search-layer.js.map +1 -1
  142. package/dist/tools/context/actions/search-tags.d.ts.map +1 -1
  143. package/dist/tools/context/actions/search-tags.js +8 -0
  144. package/dist/tools/context/actions/search-tags.js.map +1 -1
  145. package/dist/tools/files/actions/check-lock.d.ts.map +1 -1
  146. package/dist/tools/files/actions/check-lock.js +9 -3
  147. package/dist/tools/files/actions/check-lock.js.map +1 -1
  148. package/dist/tools/files/actions/get.d.ts.map +1 -1
  149. package/dist/tools/files/actions/get.js +18 -13
  150. package/dist/tools/files/actions/get.js.map +1 -1
  151. package/dist/tools/files/actions/record-batch.d.ts.map +1 -1
  152. package/dist/tools/files/actions/record-batch.js +11 -6
  153. package/dist/tools/files/actions/record-batch.js.map +1 -1
  154. package/dist/tools/files/actions/record.d.ts.map +1 -1
  155. package/dist/tools/files/actions/record.js +8 -2
  156. package/dist/tools/files/actions/record.js.map +1 -1
  157. package/dist/tools/files/help/example.d.ts.map +1 -1
  158. package/dist/tools/files/help/example.js +11 -0
  159. package/dist/tools/files/help/example.js.map +1 -1
  160. package/dist/tools/files/help/help.d.ts.map +1 -1
  161. package/dist/tools/files/help/help.js +11 -0
  162. package/dist/tools/files/help/help.js.map +1 -1
  163. package/dist/tools/suggest/actions/by-context.d.ts.map +1 -1
  164. package/dist/tools/suggest/actions/by-context.js +5 -15
  165. package/dist/tools/suggest/actions/by-context.js.map +1 -1
  166. package/dist/tools/suggest/actions/by-key.d.ts.map +1 -1
  167. package/dist/tools/suggest/actions/by-key.js +5 -15
  168. package/dist/tools/suggest/actions/by-key.js.map +1 -1
  169. package/dist/tools/suggest/actions/by-tags.d.ts.map +1 -1
  170. package/dist/tools/suggest/actions/by-tags.js +5 -15
  171. package/dist/tools/suggest/actions/by-tags.js.map +1 -1
  172. package/dist/tools/suggest/actions/constraint-by-context.d.ts +1 -1
  173. package/dist/tools/suggest/actions/constraint-by-context.d.ts.map +1 -1
  174. package/dist/tools/suggest/actions/constraint-by-context.js +9 -16
  175. package/dist/tools/suggest/actions/constraint-by-context.js.map +1 -1
  176. package/dist/tools/suggest/actions/constraint-by-tags.d.ts +1 -1
  177. package/dist/tools/suggest/actions/constraint-by-tags.d.ts.map +1 -1
  178. package/dist/tools/suggest/actions/constraint-by-tags.js +11 -17
  179. package/dist/tools/suggest/actions/constraint-by-tags.js.map +1 -1
  180. package/dist/tools/suggest/actions/constraint-by-text.d.ts +1 -1
  181. package/dist/tools/suggest/actions/constraint-by-text.d.ts.map +1 -1
  182. package/dist/tools/suggest/actions/constraint-by-text.js +6 -15
  183. package/dist/tools/suggest/actions/constraint-by-text.js.map +1 -1
  184. package/dist/types/actions.d.ts +1 -1
  185. package/dist/types/actions.d.ts.map +1 -1
  186. package/dist/types.d.ts +9 -230
  187. package/dist/types.d.ts.map +1 -1
  188. package/dist/utils/action-specs/constraint-specs.d.ts +1 -1
  189. package/dist/utils/action-specs/constraint-specs.d.ts.map +1 -1
  190. package/dist/utils/action-specs/constraint-specs.js +22 -5
  191. package/dist/utils/action-specs/constraint-specs.js.map +1 -1
  192. package/dist/utils/action-specs/decision-specs.d.ts.map +1 -1
  193. package/dist/utils/action-specs/decision-specs.js +11 -10
  194. package/dist/utils/action-specs/decision-specs.js.map +1 -1
  195. package/dist/utils/action-specs/file-specs.js +4 -4
  196. package/dist/utils/action-specs/file-specs.js.map +1 -1
  197. package/dist/utils/hook-queue.d.ts +43 -3
  198. package/dist/utils/hook-queue.d.ts.map +1 -1
  199. package/dist/utils/hook-queue.js +326 -32
  200. package/dist/utils/hook-queue.js.map +1 -1
  201. package/dist/utils/param-normalizer.d.ts +52 -0
  202. package/dist/utils/param-normalizer.d.ts.map +1 -0
  203. package/dist/utils/param-normalizer.js +70 -0
  204. package/dist/utils/param-normalizer.js.map +1 -0
  205. package/dist/utils/parameter-validator.d.ts.map +1 -1
  206. package/dist/utils/parameter-validator.js +2 -0
  207. package/dist/utils/parameter-validator.js.map +1 -1
  208. package/dist/utils/suggest-helpers.d.ts +82 -0
  209. package/dist/utils/suggest-helpers.d.ts.map +1 -0
  210. package/dist/utils/suggest-helpers.js +93 -0
  211. package/dist/utils/suggest-helpers.js.map +1 -0
  212. package/dist/utils/text-truncate.d.ts +13 -0
  213. package/dist/utils/text-truncate.d.ts.map +1 -0
  214. package/dist/utils/text-truncate.js +18 -0
  215. package/dist/utils/text-truncate.js.map +1 -0
  216. package/dist/utils/validators.d.ts +1 -1
  217. package/dist/utils/validators.d.ts.map +1 -1
  218. package/dist/utils/validators.js +1 -1
  219. package/dist/utils/validators.js.map +1 -1
  220. package/dist/watcher/base-watcher.d.ts.map +1 -1
  221. package/dist/watcher/base-watcher.js +4 -3
  222. package/dist/watcher/base-watcher.js.map +1 -1
  223. package/dist/watcher/file-watcher.d.ts.map +1 -1
  224. package/dist/watcher/file-watcher.js +5 -1
  225. package/dist/watcher/file-watcher.js.map +1 -1
  226. package/dist/watcher/queue-watcher.d.ts +12 -1
  227. package/dist/watcher/queue-watcher.d.ts.map +1 -1
  228. package/dist/watcher/queue-watcher.js +92 -12
  229. package/dist/watcher/queue-watcher.js.map +1 -1
  230. package/docs/ADR_CONCEPTS.md +4 -0
  231. package/docs/HOOKS_GUIDE.md +1 -1
  232. package/package.json +1 -1
@@ -15,7 +15,7 @@ export const FILE_ACTION_SPECS = {
15
15
  layer: 'business',
16
16
  description: 'Added JWT validation'
17
17
  },
18
- hint: "Valid change_type: created, modified, deleted"
18
+ hint: "Valid change_type: created, modified, deleted. Aliases: path→file_path, type→change_type"
19
19
  },
20
20
  get: {
21
21
  required: [],
@@ -25,7 +25,7 @@ export const FILE_ACTION_SPECS = {
25
25
  layer: 'business',
26
26
  limit: 10
27
27
  },
28
- hint: "Use 'since' with ISO 8601 timestamp for time-based filtering"
28
+ hint: "Use 'since' with ISO 8601 timestamp for time-based filtering. Alias: path→file_path"
29
29
  },
30
30
  check_lock: {
31
31
  required: ['file_path'],
@@ -35,7 +35,7 @@ export const FILE_ACTION_SPECS = {
35
35
  file_path: 'src/database/schema.sql',
36
36
  lock_duration: 300
37
37
  },
38
- hint: "Default lock_duration is 300 seconds (5 minutes). Prevents concurrent edits."
38
+ hint: "Default lock_duration is 300 seconds (5 minutes). Aliases: path→file_path, duration→lock_duration"
39
39
  },
40
40
  record_batch: {
41
41
  required: ['file_changes'],
@@ -48,7 +48,7 @@ export const FILE_ACTION_SPECS = {
48
48
  ],
49
49
  atomic: false
50
50
  },
51
- hint: "Max 50 file changes per batch. Use atomic:false for best-effort recording."
51
+ hint: "Max 50 file changes per batch. Use atomic:false for best-effort recording. Alias: changes→file_changes"
52
52
  }
53
53
  };
54
54
  //# sourceMappingURL=file-specs.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"file-specs.js","sourceRoot":"","sources":["../../../src/utils/action-specs/file-specs.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,MAAM,CAAC,MAAM,iBAAiB,GAA+B;IAC3D,MAAM,EAAE;QACN,QAAQ,EAAE,CAAC,WAAW,EAAE,aAAa,CAAC;QACtC,QAAQ,EAAE,CAAC,OAAO,EAAE,aAAa,EAAE,YAAY,CAAC,EAAG,mCAAmC;QACtF,OAAO,EAAE;YACP,MAAM,EAAE,QAAQ;YAChB,SAAS,EAAE,iBAAiB;YAC5B,WAAW,EAAE,UAAU;YACvB,KAAK,EAAE,UAAU;YACjB,WAAW,EAAE,sBAAsB;SACpC;QACD,IAAI,EAAE,+CAA+C;KACtD;IAED,GAAG,EAAE;QACH,QAAQ,EAAE,EAAE;QACZ,QAAQ,EAAE,CAAC,WAAW,EAAE,YAAY,EAAE,OAAO,EAAE,aAAa,EAAE,OAAO,EAAE,OAAO,CAAC;QAC/E,OAAO,EAAE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;QACZ,QAAQ,EAAE,CAAC,WAAW,EAAE,YAAY,EAAE,OAAO,EAAE,aAAa,EAAE,OAAO,EAAE,OAAO,CAAC;QAC/E,OAAO,EAAE;YACP,MAAM,EAAE,KAAK;YACb,KAAK,EAAE,UAAU;YACjB,KAAK,EAAE,EAAE;SACV;QACD,IAAI,EAAE,qFAAqF;KAC5F;IAED,UAAU,EAAE;QACV,QAAQ,EAAE,CAAC,WAAW,CAAC;QACvB,QAAQ,EAAE,CAAC,eAAe,CAAC;QAC3B,OAAO,EAAE;YACP,MAAM,EAAE,YAAY;YACpB,SAAS,EAAE,yBAAyB;YACpC,aAAa,EAAE,GAAG;SACnB;QACD,IAAI,EAAE,mGAAmG;KAC1G;IAED,YAAY,EAAE;QACZ,QAAQ,EAAE,CAAC,cAAc,CAAC;QAC1B,QAAQ,EAAE,CAAC,QAAQ,CAAC;QACpB,OAAO,EAAE;YACP,MAAM,EAAE,cAAc;YACtB,YAAY,EAAE;gBACZ,EAAE,SAAS,EAAE,YAAY,EAAE,WAAW,EAAE,UAAU,EAAE,KAAK,EAAE,cAAc,EAAE;gBAC3E,EAAE,SAAS,EAAE,cAAc,EAAE,WAAW,EAAE,UAAU,EAAE,KAAK,EAAE,MAAM,EAAE;aACtE;YACD,MAAM,EAAE,KAAK;SACd;QACD,IAAI,EAAE,wGAAwG;KAC/G;CACF,CAAC"}
@@ -7,7 +7,7 @@
7
7
  * @since v4.1.0
8
8
  */
9
9
  /** Queue item action type */
10
- export type QueueAction = 'create' | 'update';
10
+ export type QueueAction = 'create' | 'update' | 'activate';
11
11
  /** Queue item for decision operations */
12
12
  export interface DecisionQueueItem {
13
13
  type: 'decision';
@@ -21,9 +21,26 @@ export interface DecisionQueueItem {
21
21
  tags?: string[];
22
22
  };
23
23
  }
24
+ /** Queue item for constraint operations */
25
+ export interface ConstraintQueueItem {
26
+ type: 'constraint';
27
+ action: QueueAction;
28
+ timestamp: string;
29
+ data: {
30
+ text: string;
31
+ category?: string;
32
+ priority?: string;
33
+ layer?: string;
34
+ tags?: string[];
35
+ active?: boolean;
36
+ plan_id?: string;
37
+ };
38
+ }
39
+ /** Union type for all queue items */
40
+ export type QueueItem = DecisionQueueItem | ConstraintQueueItem;
24
41
  /** Queue file structure */
25
42
  export interface QueueFile {
26
- items: DecisionQueueItem[];
43
+ items: QueueItem[];
27
44
  }
28
45
  /**
29
46
  * Get queue file path for a project
@@ -67,9 +84,10 @@ export declare function enqueueDecisionUpdate(projectPath: string, data: {
67
84
  *
68
85
  * @param projectPath - Project root path
69
86
  * @param processor - Function to process each item
87
+ * @param callId - Optional call ID for tracing
70
88
  * @returns Number of items processed
71
89
  */
72
- export declare function processQueue(projectPath: string, processor: (item: DecisionQueueItem) => Promise<void>): Promise<number>;
90
+ export declare function processQueue(projectPath: string, processor: (item: QueueItem) => Promise<void>, callId?: string): Promise<number>;
73
91
  /**
74
92
  * Clear the queue file
75
93
  */
@@ -78,4 +96,26 @@ export declare function clearQueue(projectPath: string): void;
78
96
  * Check if queue has pending items
79
97
  */
80
98
  export declare function hasQueueItems(projectPath: string): boolean;
99
+ /**
100
+ * Enqueue a constraint creation
101
+ *
102
+ * @param projectPath - Project root path
103
+ * @param data - Constraint data
104
+ */
105
+ export declare function enqueueConstraintCreate(projectPath: string, data: {
106
+ text: string;
107
+ category?: string;
108
+ priority?: string;
109
+ layer?: string;
110
+ tags?: string[];
111
+ active?: boolean;
112
+ plan_id?: string;
113
+ }): void;
114
+ /**
115
+ * Enqueue constraint activation (set active=1)
116
+ *
117
+ * @param projectPath - Project root path
118
+ * @param planId - Plan ID to match constraints
119
+ */
120
+ export declare function enqueueConstraintActivate(projectPath: string, planId: string): void;
81
121
  //# sourceMappingURL=hook-queue.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"hook-queue.d.ts","sourceRoot":"","sources":["../../src/utils/hook-queue.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AASH,6BAA6B;AAC7B,MAAM,MAAM,WAAW,GAAG,QAAQ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,EAAE,MAAM,CAAC;IACb,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;IAChB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB,GACA,IAAI,CA+BN;AAED;;;;;GAKG;AACH,wBAAgB,yBAAyB,CACvC,WAAW,EAAE,MAAM,EACnB,MAAM,EAAE,MAAM,GACb,IAAI,CAcN"}
@@ -6,8 +6,85 @@
6
6
  *
7
7
  * @since v4.1.0
8
8
  */
9
- import { existsSync, mkdirSync, readFileSync, writeFileSync } from 'fs';
9
+ import { existsSync, mkdirSync, readFileSync, writeFileSync, unlinkSync, renameSync, appendFileSync } from 'fs';
10
10
  import { join } from 'path';
11
+ import { debugLog } from './debug-logger.js';
12
+ // ============================================================================
13
+ // Debug Configuration
14
+ // ============================================================================
15
+ /**
16
+ * Enable detailed trace logging for queue operations.
17
+ * Set to `true` when debugging queue issues (writes to .sqlew/queue/trace.log)
18
+ *
19
+ * Also controls:
20
+ * - snapshot_*.json files (per-write snapshots)
21
+ * - pending-debug.json (write history)
22
+ */
23
+ const QUEUE_TRACE_ENABLED = false;
24
+ // ============================================================================
25
+ // File Lock for Queue Processing
26
+ // ============================================================================
27
+ /** Lock timeout in milliseconds (30 seconds) */
28
+ const LOCK_TIMEOUT_MS = 30000;
29
+ /**
30
+ * Try to acquire a lock for queue processing
31
+ * Uses file-based locking with timestamp for stale lock detection
32
+ *
33
+ * @param projectPath - Project root path
34
+ * @returns true if lock acquired, false if another process holds the lock
35
+ */
36
+ function tryAcquireLock(projectPath) {
37
+ const lockPath = join(projectPath, '.sqlew/queue/pending.lock');
38
+ if (existsSync(lockPath)) {
39
+ try {
40
+ const lock = JSON.parse(readFileSync(lockPath, 'utf-8'));
41
+ const age = Date.now() - lock.timestamp;
42
+ if (age < LOCK_TIMEOUT_MS) {
43
+ debugLog('INFO', '[hook-queue] Lock held by another process', {
44
+ pid: lock.pid,
45
+ ageMs: age,
46
+ });
47
+ return false; // Lock still valid, skip processing
48
+ }
49
+ debugLog('WARN', '[hook-queue] Stale lock detected, overwriting', {
50
+ pid: lock.pid,
51
+ ageMs: age,
52
+ });
53
+ }
54
+ catch {
55
+ // Lock file corrupted, overwrite it
56
+ debugLog('WARN', '[hook-queue] Corrupted lock file, overwriting');
57
+ }
58
+ }
59
+ // Acquire lock
60
+ try {
61
+ writeFileSync(lockPath, JSON.stringify({
62
+ pid: process.pid,
63
+ timestamp: Date.now(), // Unix epoch ms (timezone-independent)
64
+ }));
65
+ debugLog('INFO', '[hook-queue] Lock acquired', { pid: process.pid });
66
+ return true;
67
+ }
68
+ catch (error) {
69
+ debugLog('ERROR', '[hook-queue] Failed to acquire lock', { error });
70
+ return false;
71
+ }
72
+ }
73
+ /**
74
+ * Release the queue processing lock
75
+ *
76
+ * @param projectPath - Project root path
77
+ */
78
+ function releaseLock(projectPath) {
79
+ const lockPath = join(projectPath, '.sqlew/queue/pending.lock');
80
+ try {
81
+ unlinkSync(lockPath);
82
+ debugLog('INFO', '[hook-queue] Lock released');
83
+ }
84
+ catch {
85
+ // Ignore errors (file may already be deleted)
86
+ }
87
+ }
11
88
  // ============================================================================
12
89
  // Constants
13
90
  // ============================================================================
@@ -33,30 +110,138 @@ function ensureQueueDir(projectPath) {
33
110
  mkdirSync(queueDir, { recursive: true });
34
111
  }
35
112
  }
113
+ /**
114
+ * Write to queue trace log (debugLog-independent for Hook CLI)
115
+ * Logs ALL operations for debugging Hook flow
116
+ *
117
+ * @note Controlled by QUEUE_TRACE_ENABLED flag
118
+ */
119
+ function writeQueueTrace(projectPath, level, message, data) {
120
+ if (!QUEUE_TRACE_ENABLED)
121
+ return;
122
+ try {
123
+ const traceLogPath = join(projectPath, QUEUE_DIR, 'trace.log');
124
+ const dataStr = data ? ` | ${JSON.stringify(data)}` : '';
125
+ const entry = `[${new Date().toISOString()}] [${level}] [PID:${process.pid}] ${message}${dataStr}\n`;
126
+ appendFileSync(traceLogPath, entry, 'utf-8');
127
+ }
128
+ catch { /* ignore */ }
129
+ }
36
130
  /**
37
131
  * Read queue file (returns empty queue if not exists)
38
132
  */
39
133
  export function readQueue(projectPath) {
40
134
  const queuePath = getQueuePath(projectPath);
135
+ writeQueueTrace(projectPath, 'INFO', 'readQueue: START', { queuePath });
41
136
  if (!existsSync(queuePath)) {
137
+ writeQueueTrace(projectPath, 'INFO', 'readQueue: file does not exist, returning empty');
138
+ debugLog('DEBUG', '[hook-queue] readQueue: file does not exist', { queuePath });
42
139
  return { items: [] };
43
140
  }
44
141
  try {
45
142
  const content = readFileSync(queuePath, 'utf-8');
46
- return JSON.parse(content);
143
+ writeQueueTrace(projectPath, 'INFO', 'readQueue: read file', {
144
+ contentLength: content.length,
145
+ contentPreview: content.slice(0, 100),
146
+ });
147
+ debugLog('DEBUG', '[hook-queue] readQueue: read file', {
148
+ queuePath,
149
+ contentLength: content.length,
150
+ contentPreview: content.slice(0, 100),
151
+ });
152
+ const parsed = JSON.parse(content);
153
+ writeQueueTrace(projectPath, 'INFO', 'readQueue: SUCCESS', { itemCount: parsed.items?.length ?? 0 });
154
+ debugLog('DEBUG', '[hook-queue] readQueue: parsed successfully', {
155
+ itemCount: parsed.items?.length ?? 0,
156
+ });
157
+ return parsed;
47
158
  }
48
- catch {
49
- // If file is corrupted, return empty queue
159
+ catch (error) {
160
+ const errorMsg = error instanceof Error ? error.message : String(error);
161
+ writeQueueTrace(projectPath, 'ERROR', 'readQueue: JSON parse FAILED', { error: errorMsg });
162
+ debugLog('ERROR', '[hook-queue] readQueue: JSON parse failed', {
163
+ queuePath,
164
+ error: errorMsg,
165
+ });
50
166
  return { items: [] };
51
167
  }
52
168
  }
53
169
  /**
54
- * Write queue file
170
+ * Write queue file (atomic write to prevent partial reads)
171
+ *
172
+ * Uses write-to-temp + rename pattern to ensure readers always see
173
+ * complete file content, even on Windows where file locking is different.
174
+ *
175
+ * @param projectPath - Project root path
176
+ * @param queue - Queue data to write
177
+ * @param caller - Name of the calling function (for debug snapshots)
55
178
  */
56
- function writeQueue(projectPath, queue) {
179
+ function writeQueue(projectPath, queue, caller = 'unknown') {
57
180
  ensureQueueDir(projectPath);
58
181
  const queuePath = getQueuePath(projectPath);
59
- writeFileSync(queuePath, JSON.stringify(queue, null, 2), 'utf-8');
182
+ const tempPath = queuePath + '.tmp';
183
+ // Write to temp file first
184
+ const content = JSON.stringify(queue, null, 2);
185
+ writeFileSync(tempPath, content, 'utf-8');
186
+ // Atomic rename (Windows: uses MoveFileEx internally)
187
+ try {
188
+ renameSync(tempPath, queuePath);
189
+ }
190
+ catch (error) {
191
+ // Fallback: If rename fails (e.g., cross-device), write directly
192
+ debugLog('WARN', '[hook-queue] writeQueue: rename failed, using direct write', {
193
+ error: error instanceof Error ? error.message : String(error),
194
+ });
195
+ writeFileSync(queuePath, content, 'utf-8');
196
+ try {
197
+ unlinkSync(tempPath);
198
+ }
199
+ catch { /* ignore */ }
200
+ }
201
+ // DEBUG: Snapshot after each write with caller name + epoch time
202
+ // Controlled by QUEUE_TRACE_ENABLED flag
203
+ if (QUEUE_TRACE_ENABLED) {
204
+ const epoch = Date.now();
205
+ const snapshotPath = queuePath.replace('pending.json', `snapshot_${caller}_${epoch}.json`);
206
+ try {
207
+ const snapshotData = {
208
+ caller,
209
+ timestamp: new Date().toISOString(),
210
+ epoch,
211
+ pid: process.pid,
212
+ itemCount: queue.items.length,
213
+ items: queue.items,
214
+ };
215
+ writeFileSync(snapshotPath, JSON.stringify(snapshotData, null, 2), 'utf-8');
216
+ }
217
+ catch { /* ignore snapshot errors */ }
218
+ // DEBUG: Also write to pending-debug.json with timestamp for tracing
219
+ const debugPath = queuePath.replace('pending.json', 'pending-debug.json');
220
+ const debugData = {
221
+ timestamp: new Date().toISOString(),
222
+ pid: process.pid,
223
+ itemCount: queue.items.length,
224
+ items: queue.items,
225
+ };
226
+ try {
227
+ // Append to debug file (read existing + append)
228
+ let existing = [];
229
+ if (existsSync(debugPath)) {
230
+ try {
231
+ existing = JSON.parse(readFileSync(debugPath, 'utf-8'));
232
+ }
233
+ catch {
234
+ existing = [];
235
+ }
236
+ }
237
+ existing.push(debugData);
238
+ // Keep last 50 entries
239
+ if (existing.length > 50)
240
+ existing = existing.slice(-50);
241
+ writeFileSync(debugPath, JSON.stringify(existing, null, 2), 'utf-8');
242
+ }
243
+ catch { /* ignore debug file errors */ }
244
+ }
60
245
  }
61
246
  // ============================================================================
62
247
  // Enqueue Operations (Used by Hooks - Fast, No DB)
@@ -68,7 +253,16 @@ function writeQueue(projectPath, queue) {
68
253
  * @param data - Decision data
69
254
  */
70
255
  export function enqueueDecisionCreate(projectPath, data) {
256
+ writeQueueTrace(projectPath, 'INFO', 'enqueueDecisionCreate: START', { key: data.key });
71
257
  const queue = readQueue(projectPath);
258
+ writeQueueTrace(projectPath, 'INFO', 'enqueueDecisionCreate: after readQueue', { existingItems: queue.items.length });
259
+ // Duplicate check: skip if same key already in queue
260
+ const existingDecision = queue.items.find(i => i.type === 'decision' && i.data.key === data.key);
261
+ if (existingDecision) {
262
+ writeQueueTrace(projectPath, 'WARN', 'enqueueDecisionCreate: SKIP duplicate', { key: data.key });
263
+ debugLog('INFO', '[hook-queue] Skipping duplicate decision in queue', { key: data.key });
264
+ return;
265
+ }
72
266
  const item = {
73
267
  type: 'decision',
74
268
  action: 'create',
@@ -76,7 +270,9 @@ export function enqueueDecisionCreate(projectPath, data) {
76
270
  data,
77
271
  };
78
272
  queue.items.push(item);
79
- writeQueue(projectPath, queue);
273
+ writeQueueTrace(projectPath, 'INFO', 'enqueueDecisionCreate: before writeQueue', { totalItems: queue.items.length });
274
+ writeQueue(projectPath, queue, 'enqueueDecisionCreate');
275
+ writeQueueTrace(projectPath, 'INFO', 'enqueueDecisionCreate: DONE');
80
276
  }
81
277
  /**
82
278
  * Enqueue a decision status update
@@ -93,7 +289,7 @@ export function enqueueDecisionUpdate(projectPath, data) {
93
289
  data,
94
290
  };
95
291
  queue.items.push(item);
96
- writeQueue(projectPath, queue);
292
+ writeQueue(projectPath, queue, 'enqueueDecisionUpdate');
97
293
  }
98
294
  // ============================================================================
99
295
  // Process Queue (Used by MCP Server on Startup)
@@ -106,36 +302,76 @@ export function enqueueDecisionUpdate(projectPath, data) {
106
302
  *
107
303
  * @param projectPath - Project root path
108
304
  * @param processor - Function to process each item
305
+ * @param callId - Optional call ID for tracing
109
306
  * @returns Number of items processed
110
307
  */
111
- export async function processQueue(projectPath, processor) {
112
- const queue = readQueue(projectPath);
113
- if (queue.items.length === 0) {
308
+ export async function processQueue(projectPath, processor, callId) {
309
+ // Try to acquire file lock for exclusive processing
310
+ if (!tryAcquireLock(projectPath)) {
311
+ debugLog('INFO', '[hook-queue] Skipping processQueue - another process holds the lock', { callId });
114
312
  return 0;
115
313
  }
116
- let processed = 0;
117
- const errors = [];
118
- for (const item of queue.items) {
119
- try {
120
- await processor(item);
121
- processed++;
122
- }
123
- catch (error) {
124
- const message = error instanceof Error ? error.message : String(error);
125
- errors.push({ item, error: message });
126
- console.error(`[hook-queue] Error processing item: ${message}`);
314
+ try {
315
+ const queue = readQueue(projectPath);
316
+ debugLog('INFO', '[hook-queue] processQueue called', {
317
+ callId,
318
+ pid: process.pid,
319
+ itemCount: queue.items.length,
320
+ items: queue.items.map(i => ({
321
+ type: i.type,
322
+ action: i.action,
323
+ key: i.type === 'decision' ? i.data.key : undefined,
324
+ text: i.type === 'constraint' ? i.data.text?.slice(0, 30) : undefined,
325
+ })),
326
+ });
327
+ if (queue.items.length === 0) {
328
+ return 0;
127
329
  }
128
- }
129
- // Clear processed items (keep failed items for retry)
130
- if (errors.length === 0) {
330
+ // CRITICAL: Clear queue IMMEDIATELY after reading to prevent duplicate processing
331
+ // If another call comes in while we're processing, it will see an empty queue
332
+ debugLog('INFO', '[hook-queue] Clearing queue before processing (race condition prevention)', { callId });
131
333
  clearQueue(projectPath);
334
+ let processed = 0;
335
+ const errors = [];
336
+ for (let i = 0; i < queue.items.length; i++) {
337
+ const item = queue.items[i];
338
+ debugLog('INFO', `[hook-queue] Processing item ${i + 1}/${queue.items.length}`, {
339
+ callId,
340
+ type: item.type,
341
+ action: item.action,
342
+ });
343
+ try {
344
+ await processor(item);
345
+ processed++;
346
+ debugLog('INFO', `[hook-queue] Item ${i + 1} processed successfully`, { callId });
347
+ }
348
+ catch (error) {
349
+ const message = error instanceof Error ? error.message : String(error);
350
+ errors.push({ item, error: message });
351
+ debugLog('ERROR', `[hook-queue] Item ${i + 1} failed`, { callId, error: message });
352
+ console.error(`[hook-queue] Error processing item: ${message}`);
353
+ }
354
+ }
355
+ debugLog('INFO', '[hook-queue] Processing complete', {
356
+ callId,
357
+ processed,
358
+ errors: errors.length,
359
+ errorDetails: errors.map(e => e.error),
360
+ });
361
+ // Write back only failed items for retry
362
+ if (errors.length > 0) {
363
+ const failedItems = errors.map((e) => e.item);
364
+ debugLog('WARN', '[hook-queue] Writing back failed items for retry', {
365
+ callId,
366
+ failedCount: failedItems.length,
367
+ });
368
+ writeQueue(projectPath, { items: failedItems }, 'processQueue_retry');
369
+ }
370
+ return processed;
132
371
  }
133
- else {
134
- // Keep only failed items
135
- const failedItems = errors.map((e) => e.item);
136
- writeQueue(projectPath, { items: failedItems });
372
+ finally {
373
+ releaseLock(projectPath);
137
374
  }
138
- return processed;
139
375
  }
140
376
  /**
141
377
  * Clear the queue file
@@ -143,7 +379,7 @@ export async function processQueue(projectPath, processor) {
143
379
  export function clearQueue(projectPath) {
144
380
  const queuePath = getQueuePath(projectPath);
145
381
  if (existsSync(queuePath)) {
146
- writeQueue(projectPath, { items: [] });
382
+ writeQueue(projectPath, { items: [] }, 'clearQueue');
147
383
  }
148
384
  }
149
385
  /**
@@ -153,4 +389,62 @@ export function hasQueueItems(projectPath) {
153
389
  const queue = readQueue(projectPath);
154
390
  return queue.items.length > 0;
155
391
  }
392
+ // ============================================================================
393
+ // Constraint Queue Operations (v4.2.1+)
394
+ // ============================================================================
395
+ /**
396
+ * Enqueue a constraint creation
397
+ *
398
+ * @param projectPath - Project root path
399
+ * @param data - Constraint data
400
+ */
401
+ export function enqueueConstraintCreate(projectPath, data) {
402
+ writeQueueTrace(projectPath, 'INFO', 'enqueueConstraintCreate: START', { text: data.text?.slice(0, 30) });
403
+ const queue = readQueue(projectPath);
404
+ writeQueueTrace(projectPath, 'INFO', 'enqueueConstraintCreate: after readQueue', { existingItems: queue.items.length });
405
+ // Duplicate check: skip if same text already in queue
406
+ const existingConstraint = queue.items.find(i => i.type === 'constraint' && i.data.text === data.text);
407
+ if (existingConstraint) {
408
+ writeQueueTrace(projectPath, 'WARN', 'enqueueConstraintCreate: SKIP duplicate', { text: data.text?.slice(0, 30) });
409
+ debugLog('INFO', '[hook-queue] Skipping duplicate constraint in queue', { text: data.text?.slice(0, 30) });
410
+ return;
411
+ }
412
+ const item = {
413
+ type: 'constraint',
414
+ action: 'create',
415
+ timestamp: new Date().toISOString(),
416
+ data,
417
+ };
418
+ queue.items.push(item);
419
+ writeQueueTrace(projectPath, 'INFO', 'enqueueConstraintCreate: before writeQueue', { totalItems: queue.items.length });
420
+ debugLog('INFO', '[hook-queue] enqueueConstraintCreate', {
421
+ projectPath,
422
+ text: data.text?.slice(0, 30),
423
+ category: data.category,
424
+ queueSizeAfter: queue.items.length,
425
+ });
426
+ writeQueue(projectPath, queue, 'enqueueConstraintCreate');
427
+ writeQueueTrace(projectPath, 'INFO', 'enqueueConstraintCreate: DONE');
428
+ }
429
+ /**
430
+ * Enqueue constraint activation (set active=1)
431
+ *
432
+ * @param projectPath - Project root path
433
+ * @param planId - Plan ID to match constraints
434
+ */
435
+ export function enqueueConstraintActivate(projectPath, planId) {
436
+ const queue = readQueue(projectPath);
437
+ const item = {
438
+ type: 'constraint',
439
+ action: 'activate',
440
+ timestamp: new Date().toISOString(),
441
+ data: {
442
+ text: '', // Not used for activate action
443
+ plan_id: planId,
444
+ active: true,
445
+ },
446
+ };
447
+ queue.items.push(item);
448
+ writeQueue(projectPath, queue, 'enqueueConstraintActivate');
449
+ }
156
450
  //# sourceMappingURL=hook-queue.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"hook-queue.js","sourceRoot":"","sources":["../../src/utils/hook-queue.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,IAAI,CAAC;AACxE,OAAO,EAAE,IAAI,EAAW,MAAM,MAAM,CAAC;AA4BrC,+EAA+E;AAC/E,YAAY;AACZ,+EAA+E;AAE/E,+CAA+C;AAC/C,MAAM,SAAS,GAAG,cAAc,CAAC;AAEjC,sBAAsB;AACtB,MAAM,UAAU,GAAG,cAAc,CAAC;AAElC,+EAA+E;AAC/E,wBAAwB;AACxB,+EAA+E;AAE/E;;GAEG;AACH,MAAM,UAAU,YAAY,CAAC,WAAmB;IAC9C,OAAO,IAAI,CAAC,WAAW,EAAE,SAAS,EAAE,UAAU,CAAC,CAAC;AAClD,CAAC;AAED;;GAEG;AACH,SAAS,cAAc,CAAC,WAAmB;IACzC,MAAM,QAAQ,GAAG,IAAI,CAAC,WAAW,EAAE,SAAS,CAAC,CAAC;IAC9C,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,EAAE,CAAC;QAC1B,SAAS,CAAC,QAAQ,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;IAC3C,CAAC;AACH,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,SAAS,CAAC,WAAmB;IAC3C,MAAM,SAAS,GAAG,YAAY,CAAC,WAAW,CAAC,CAAC;IAC5C,IAAI,CAAC,UAAU,CAAC,SAAS,CAAC,EAAE,CAAC;QAC3B,OAAO,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC;IACvB,CAAC;IACD,IAAI,CAAC;QACH,MAAM,OAAO,GAAG,YAAY,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC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AAM;KACnC,CAAC,CAAC;IACH,UAAU,CAAC,WAAW,EAAE,KAAK,EAAE,yBAAyB,CAAC,CAAC;IAC1D,eAAe,CAAC,WAAW,EAAE,MAAM,EAAE,+BAA+B,CAAC,CAAC;AACxE,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,yBAAyB,CACvC,WAAmB,EACnB,MAAc;IAEd,MAAM,KAAK,GAAG,SAAS,CAAC,WAAW,CAAC,CAAC;IACrC,MAAM,IAAI,GAAwB;QAChC,IAAI,EAAE,YAAY;QAClB,MAAM,EAAE,UAAU;QAClB,SAAS,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;QACnC,IAAI,EAAE;YACJ,IAAI,EAAE,EAAE,EAAE,+BAA+B;YACzC,OAAO,EAAE,MAAM;YACf,MAAM,EAAE,IAAI;SACb;KACF,CAAC;IACF,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACvB,UAAU,CAAC,WAAW,EAAE,KAAK,EAAE,2BAA2B,CAAC,CAAC;AAC9D,CAAC"}
@@ -0,0 +1,52 @@
1
+ /**
2
+ * Parameter Alias Normalizer
3
+ *
4
+ * Converts short aliases to canonical parameter names before validation.
5
+ * This enables user-friendly shorter parameter names while maintaining
6
+ * consistent internal naming conventions.
7
+ *
8
+ * @example
9
+ * // Single alias
10
+ * normalizeParams(params, { path: 'file_path' });
11
+ *
12
+ * // Multiple aliases
13
+ * normalizeParams(params, {
14
+ * path: 'file_path',
15
+ * type: 'change_type'
16
+ * });
17
+ */
18
+ /**
19
+ * Normalize parameter aliases to canonical names.
20
+ *
21
+ * Only converts alias to canonical if:
22
+ * 1. The alias parameter exists
23
+ * 2. The canonical parameter does NOT exist (avoid overwrite)
24
+ *
25
+ * @param params - Original parameters object
26
+ * @param aliases - Mapping of alias names to canonical names { alias: canonical }
27
+ * @returns New object with normalized parameter names
28
+ */
29
+ export declare function normalizeParams<T extends object>(params: T, aliases: Record<string, string>): T;
30
+ /**
31
+ * Pre-defined alias mappings for each tool.
32
+ * Centralized definitions for consistency and documentation.
33
+ */
34
+ export declare const DECISION_ALIASES: {
35
+ readonly alternatives: "alternatives_considered";
36
+ readonly task_id: "related_task_id";
37
+ readonly constraint_id: "related_constraint_id";
38
+ readonly after: "updated_after";
39
+ readonly before: "updated_before";
40
+ readonly key: "decision_key";
41
+ };
42
+ export declare const FILE_ALIASES: {
43
+ readonly path: "file_path";
44
+ readonly type: "change_type";
45
+ readonly changes: "file_changes";
46
+ readonly duration: "lock_duration";
47
+ };
48
+ export declare const CONSTRAINT_ALIASES: {
49
+ readonly text: "constraint_text";
50
+ readonly id: "constraint_id";
51
+ };
52
+ //# sourceMappingURL=param-normalizer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"param-normalizer.d.ts","sourceRoot":"","sources":["../../src/utils/param-normalizer.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH;;;;;;;;;;GAUG;AACH,wBAAgB,eAAe,CAAC,CAAC,SAAS,MAAM,EAC9C,MAAM,EAAE,CAAC,EACT,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAC9B,CAAC,CAWH;AAED;;;GAGG;AACH,eAAO,MAAM,gBAAgB;;;;;;;CAUnB,CAAC;AAEX,eAAO,MAAM,YAAY;;;;;CASf,CAAC;AAEX,eAAO,MAAM,kBAAkB;;;CAKrB,CAAC"}