driftdetect-vscode 0.8.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (309) hide show
  1. package/.turbo/turbo-build.log +4 -0
  2. package/.turbo/turbo-test.log +138 -0
  3. package/.vscode/launch.json +17 -0
  4. package/.vscode/tasks.json +15 -0
  5. package/LICENSE +121 -0
  6. package/dist/activation/activation-controller.d.ts +61 -0
  7. package/dist/activation/activation-controller.d.ts.map +1 -0
  8. package/dist/activation/activation-controller.js +235 -0
  9. package/dist/activation/activation-controller.js.map +1 -0
  10. package/dist/activation/activation-phases.d.ts +28 -0
  11. package/dist/activation/activation-phases.d.ts.map +1 -0
  12. package/dist/activation/activation-phases.js +80 -0
  13. package/dist/activation/activation-phases.js.map +1 -0
  14. package/dist/activation/index.d.ts +6 -0
  15. package/dist/activation/index.d.ts.map +1 -0
  16. package/dist/activation/index.js +6 -0
  17. package/dist/activation/index.js.map +1 -0
  18. package/dist/client/connection-config.d.ts +50 -0
  19. package/dist/client/connection-config.d.ts.map +1 -0
  20. package/dist/client/connection-config.js +56 -0
  21. package/dist/client/connection-config.js.map +1 -0
  22. package/dist/client/connection-manager.d.ts +70 -0
  23. package/dist/client/connection-manager.d.ts.map +1 -0
  24. package/dist/client/connection-manager.js +214 -0
  25. package/dist/client/connection-manager.js.map +1 -0
  26. package/dist/client/index.d.ts +8 -0
  27. package/dist/client/index.d.ts.map +1 -0
  28. package/dist/client/index.js +8 -0
  29. package/dist/client/index.js.map +1 -0
  30. package/dist/client/language-client-factory.d.ts +29 -0
  31. package/dist/client/language-client-factory.d.ts.map +1 -0
  32. package/dist/client/language-client-factory.js +76 -0
  33. package/dist/client/language-client-factory.js.map +1 -0
  34. package/dist/client/request-middleware.d.ts +38 -0
  35. package/dist/client/request-middleware.d.ts.map +1 -0
  36. package/dist/client/request-middleware.js +85 -0
  37. package/dist/client/request-middleware.js.map +1 -0
  38. package/dist/commands/command-definitions.d.ts +53 -0
  39. package/dist/commands/command-definitions.d.ts.map +1 -0
  40. package/dist/commands/command-definitions.js +212 -0
  41. package/dist/commands/command-definitions.js.map +1 -0
  42. package/dist/commands/command-router.d.ts +80 -0
  43. package/dist/commands/command-router.d.ts.map +1 -0
  44. package/dist/commands/command-router.js +127 -0
  45. package/dist/commands/command-router.js.map +1 -0
  46. package/dist/commands/handlers/connection-handlers.d.ts +14 -0
  47. package/dist/commands/handlers/connection-handlers.d.ts.map +1 -0
  48. package/dist/commands/handlers/connection-handlers.js +57 -0
  49. package/dist/commands/handlers/connection-handlers.js.map +1 -0
  50. package/dist/commands/handlers/constants-handlers.d.ts +11 -0
  51. package/dist/commands/handlers/constants-handlers.d.ts.map +1 -0
  52. package/dist/commands/handlers/constants-handlers.js +84 -0
  53. package/dist/commands/handlers/constants-handlers.js.map +1 -0
  54. package/dist/commands/handlers/index.d.ts +10 -0
  55. package/dist/commands/handlers/index.d.ts.map +1 -0
  56. package/dist/commands/handlers/index.js +10 -0
  57. package/dist/commands/handlers/index.js.map +1 -0
  58. package/dist/commands/handlers/pattern-handlers.d.ts +13 -0
  59. package/dist/commands/handlers/pattern-handlers.d.ts.map +1 -0
  60. package/dist/commands/handlers/pattern-handlers.js +127 -0
  61. package/dist/commands/handlers/pattern-handlers.js.map +1 -0
  62. package/dist/commands/handlers/scan-handlers.d.ts +15 -0
  63. package/dist/commands/handlers/scan-handlers.d.ts.map +1 -0
  64. package/dist/commands/handlers/scan-handlers.js +74 -0
  65. package/dist/commands/handlers/scan-handlers.js.map +1 -0
  66. package/dist/commands/handlers/ui-handlers.d.ts +12 -0
  67. package/dist/commands/handlers/ui-handlers.d.ts.map +1 -0
  68. package/dist/commands/handlers/ui-handlers.js +74 -0
  69. package/dist/commands/handlers/ui-handlers.js.map +1 -0
  70. package/dist/commands/handlers/violation-handlers.d.ts +13 -0
  71. package/dist/commands/handlers/violation-handlers.d.ts.map +1 -0
  72. package/dist/commands/handlers/violation-handlers.js +76 -0
  73. package/dist/commands/handlers/violation-handlers.js.map +1 -0
  74. package/dist/commands/index.d.ts +7 -0
  75. package/dist/commands/index.d.ts.map +1 -0
  76. package/dist/commands/index.js +7 -0
  77. package/dist/commands/index.js.map +1 -0
  78. package/dist/commands/middleware/connection-check-middleware.d.ts +12 -0
  79. package/dist/commands/middleware/connection-check-middleware.d.ts.map +1 -0
  80. package/dist/commands/middleware/connection-check-middleware.js +34 -0
  81. package/dist/commands/middleware/connection-check-middleware.js.map +1 -0
  82. package/dist/commands/middleware/index.d.ts +7 -0
  83. package/dist/commands/middleware/index.d.ts.map +1 -0
  84. package/dist/commands/middleware/index.js +7 -0
  85. package/dist/commands/middleware/index.js.map +1 -0
  86. package/dist/commands/middleware/logging-middleware.d.ts +12 -0
  87. package/dist/commands/middleware/logging-middleware.d.ts.map +1 -0
  88. package/dist/commands/middleware/logging-middleware.js +24 -0
  89. package/dist/commands/middleware/logging-middleware.js.map +1 -0
  90. package/dist/commands/middleware/telemetry-middleware.d.ts +22 -0
  91. package/dist/commands/middleware/telemetry-middleware.d.ts.map +1 -0
  92. package/dist/commands/middleware/telemetry-middleware.js +30 -0
  93. package/dist/commands/middleware/telemetry-middleware.js.map +1 -0
  94. package/dist/config/config-manager.d.ts +53 -0
  95. package/dist/config/config-manager.d.ts.map +1 -0
  96. package/dist/config/config-manager.js +178 -0
  97. package/dist/config/config-manager.js.map +1 -0
  98. package/dist/config/defaults.d.ts +11 -0
  99. package/dist/config/defaults.d.ts.map +1 -0
  100. package/dist/config/defaults.js +43 -0
  101. package/dist/config/defaults.js.map +1 -0
  102. package/dist/config/index.d.ts +7 -0
  103. package/dist/config/index.d.ts.map +1 -0
  104. package/dist/config/index.js +7 -0
  105. package/dist/config/index.js.map +1 -0
  106. package/dist/config/validator.d.ts +22 -0
  107. package/dist/config/validator.d.ts.map +1 -0
  108. package/dist/config/validator.js +93 -0
  109. package/dist/config/validator.js.map +1 -0
  110. package/dist/extension.d.ts +32 -0
  111. package/dist/extension.d.ts.map +1 -0
  112. package/dist/extension.js +50 -0
  113. package/dist/extension.js.map +1 -0
  114. package/dist/infrastructure/disposable-manager.d.ts +43 -0
  115. package/dist/infrastructure/disposable-manager.d.ts.map +1 -0
  116. package/dist/infrastructure/disposable-manager.js +75 -0
  117. package/dist/infrastructure/disposable-manager.js.map +1 -0
  118. package/dist/infrastructure/event-bus.d.ts +85 -0
  119. package/dist/infrastructure/event-bus.d.ts.map +1 -0
  120. package/dist/infrastructure/event-bus.js +74 -0
  121. package/dist/infrastructure/event-bus.js.map +1 -0
  122. package/dist/infrastructure/index.d.ts +10 -0
  123. package/dist/infrastructure/index.d.ts.map +1 -0
  124. package/dist/infrastructure/index.js +10 -0
  125. package/dist/infrastructure/index.js.map +1 -0
  126. package/dist/infrastructure/logger.d.ts +37 -0
  127. package/dist/infrastructure/logger.d.ts.map +1 -0
  128. package/dist/infrastructure/logger.js +86 -0
  129. package/dist/infrastructure/logger.js.map +1 -0
  130. package/dist/infrastructure/service-container.d.ts +68 -0
  131. package/dist/infrastructure/service-container.d.ts.map +1 -0
  132. package/dist/infrastructure/service-container.js +94 -0
  133. package/dist/infrastructure/service-container.js.map +1 -0
  134. package/dist/state/index.d.ts +7 -0
  135. package/dist/state/index.d.ts.map +1 -0
  136. package/dist/state/index.js +7 -0
  137. package/dist/state/index.js.map +1 -0
  138. package/dist/state/initial-state.d.ts +11 -0
  139. package/dist/state/initial-state.d.ts.map +1 -0
  140. package/dist/state/initial-state.js +58 -0
  141. package/dist/state/initial-state.js.map +1 -0
  142. package/dist/state/selectors.d.ts +41 -0
  143. package/dist/state/selectors.d.ts.map +1 -0
  144. package/dist/state/selectors.js +61 -0
  145. package/dist/state/selectors.js.map +1 -0
  146. package/dist/state/state-manager.d.ts +54 -0
  147. package/dist/state/state-manager.d.ts.map +1 -0
  148. package/dist/state/state-manager.js +166 -0
  149. package/dist/state/state-manager.js.map +1 -0
  150. package/dist/types/config-types.d.ts +69 -0
  151. package/dist/types/config-types.d.ts.map +1 -0
  152. package/dist/types/config-types.js +5 -0
  153. package/dist/types/config-types.js.map +1 -0
  154. package/dist/types/extension-types.d.ts +45 -0
  155. package/dist/types/extension-types.d.ts.map +1 -0
  156. package/dist/types/extension-types.js +5 -0
  157. package/dist/types/extension-types.js.map +1 -0
  158. package/dist/types/index.d.ts +12 -0
  159. package/dist/types/index.d.ts.map +1 -0
  160. package/dist/types/index.js +12 -0
  161. package/dist/types/index.js.map +1 -0
  162. package/dist/types/lsp-types.d.ts +70 -0
  163. package/dist/types/lsp-types.d.ts.map +1 -0
  164. package/dist/types/lsp-types.js +5 -0
  165. package/dist/types/lsp-types.js.map +1 -0
  166. package/dist/types/state-types.d.ts +82 -0
  167. package/dist/types/state-types.d.ts.map +1 -0
  168. package/dist/types/state-types.js +5 -0
  169. package/dist/types/state-types.js.map +1 -0
  170. package/dist/types/vscode-types.d.ts +36 -0
  171. package/dist/types/vscode-types.d.ts.map +1 -0
  172. package/dist/types/vscode-types.js +7 -0
  173. package/dist/types/vscode-types.js.map +1 -0
  174. package/dist/ui/decorations/decoration-controller.d.ts +45 -0
  175. package/dist/ui/decorations/decoration-controller.d.ts.map +1 -0
  176. package/dist/ui/decorations/decoration-controller.js +198 -0
  177. package/dist/ui/decorations/decoration-controller.js.map +1 -0
  178. package/dist/ui/decorations/decoration-types.d.ts +28 -0
  179. package/dist/ui/decorations/decoration-types.d.ts.map +1 -0
  180. package/dist/ui/decorations/decoration-types.js +98 -0
  181. package/dist/ui/decorations/decoration-types.js.map +1 -0
  182. package/dist/ui/decorations/index.d.ts +7 -0
  183. package/dist/ui/decorations/index.d.ts.map +1 -0
  184. package/dist/ui/decorations/index.js +6 -0
  185. package/dist/ui/decorations/index.js.map +1 -0
  186. package/dist/ui/index.d.ts +7 -0
  187. package/dist/ui/index.d.ts.map +1 -0
  188. package/dist/ui/index.js +7 -0
  189. package/dist/ui/index.js.map +1 -0
  190. package/dist/ui/notifications/index.d.ts +5 -0
  191. package/dist/ui/notifications/index.d.ts.map +1 -0
  192. package/dist/ui/notifications/index.js +5 -0
  193. package/dist/ui/notifications/index.js.map +1 -0
  194. package/dist/ui/notifications/notification-service.d.ts +66 -0
  195. package/dist/ui/notifications/notification-service.d.ts.map +1 -0
  196. package/dist/ui/notifications/notification-service.js +103 -0
  197. package/dist/ui/notifications/notification-service.js.map +1 -0
  198. package/dist/ui/status-bar/index.d.ts +6 -0
  199. package/dist/ui/status-bar/index.d.ts.map +1 -0
  200. package/dist/ui/status-bar/index.js +6 -0
  201. package/dist/ui/status-bar/index.js.map +1 -0
  202. package/dist/ui/status-bar/status-bar-controller.d.ts +37 -0
  203. package/dist/ui/status-bar/status-bar-controller.d.ts.map +1 -0
  204. package/dist/ui/status-bar/status-bar-controller.js +111 -0
  205. package/dist/ui/status-bar/status-bar-controller.js.map +1 -0
  206. package/dist/ui/status-bar/status-bar-modes.d.ts +26 -0
  207. package/dist/ui/status-bar/status-bar-modes.d.ts.map +1 -0
  208. package/dist/ui/status-bar/status-bar-modes.js +97 -0
  209. package/dist/ui/status-bar/status-bar-modes.js.map +1 -0
  210. package/dist/views/base-tree-provider.d.ts +74 -0
  211. package/dist/views/base-tree-provider.d.ts.map +1 -0
  212. package/dist/views/base-tree-provider.js +95 -0
  213. package/dist/views/base-tree-provider.js.map +1 -0
  214. package/dist/views/constants-tree-provider.d.ts +112 -0
  215. package/dist/views/constants-tree-provider.d.ts.map +1 -0
  216. package/dist/views/constants-tree-provider.js +344 -0
  217. package/dist/views/constants-tree-provider.js.map +1 -0
  218. package/dist/views/files-tree-provider.d.ts +37 -0
  219. package/dist/views/files-tree-provider.d.ts.map +1 -0
  220. package/dist/views/files-tree-provider.js +98 -0
  221. package/dist/views/files-tree-provider.js.map +1 -0
  222. package/dist/views/index.d.ts +10 -0
  223. package/dist/views/index.d.ts.map +1 -0
  224. package/dist/views/index.js +10 -0
  225. package/dist/views/index.js.map +1 -0
  226. package/dist/views/patterns-tree-provider.d.ts +39 -0
  227. package/dist/views/patterns-tree-provider.d.ts.map +1 -0
  228. package/dist/views/patterns-tree-provider.js +139 -0
  229. package/dist/views/patterns-tree-provider.js.map +1 -0
  230. package/dist/views/violations-tree-provider.d.ts +46 -0
  231. package/dist/views/violations-tree-provider.d.ts.map +1 -0
  232. package/dist/views/violations-tree-provider.js +158 -0
  233. package/dist/views/violations-tree-provider.js.map +1 -0
  234. package/dist/webview/index.d.ts +7 -0
  235. package/dist/webview/index.d.ts.map +1 -0
  236. package/dist/webview/index.js +7 -0
  237. package/dist/webview/index.js.map +1 -0
  238. package/dist/webview/webview-manager.d.ts +57 -0
  239. package/dist/webview/webview-manager.d.ts.map +1 -0
  240. package/dist/webview/webview-manager.js +167 -0
  241. package/dist/webview/webview-manager.js.map +1 -0
  242. package/package.json +405 -0
  243. package/resources/drift-icon.png +0 -0
  244. package/resources/drift-icon.svg +5 -0
  245. package/resources/icons/error.svg +4 -0
  246. package/resources/icons/info.svg +4 -0
  247. package/resources/icons/lightbulb.svg +4 -0
  248. package/resources/icons/warning.svg +4 -0
  249. package/src/activation/activation-controller.ts +320 -0
  250. package/src/activation/activation-phases.ts +96 -0
  251. package/src/activation/index.ts +6 -0
  252. package/src/client/connection-config.ts +64 -0
  253. package/src/client/connection-manager.ts +263 -0
  254. package/src/client/index.ts +8 -0
  255. package/src/client/language-client-factory.ts +111 -0
  256. package/src/client/request-middleware.ts +117 -0
  257. package/src/commands/command-definitions.ts +243 -0
  258. package/src/commands/command-router.ts +194 -0
  259. package/src/commands/handlers/connection-handlers.ts +74 -0
  260. package/src/commands/handlers/constants-handlers.ts +99 -0
  261. package/src/commands/handlers/index.ts +10 -0
  262. package/src/commands/handlers/pattern-handlers.ts +167 -0
  263. package/src/commands/handlers/scan-handlers.ts +107 -0
  264. package/src/commands/handlers/ui-handlers.ts +88 -0
  265. package/src/commands/handlers/violation-handlers.ts +97 -0
  266. package/src/commands/index.ts +7 -0
  267. package/src/commands/middleware/connection-check-middleware.ts +46 -0
  268. package/src/commands/middleware/index.ts +7 -0
  269. package/src/commands/middleware/logging-middleware.ts +28 -0
  270. package/src/commands/middleware/telemetry-middleware.ts +46 -0
  271. package/src/config/config-manager.ts +213 -0
  272. package/src/config/defaults.ts +45 -0
  273. package/src/config/index.ts +7 -0
  274. package/src/config/validator.ts +118 -0
  275. package/src/extension.ts +57 -0
  276. package/src/infrastructure/disposable-manager.ts +87 -0
  277. package/src/infrastructure/event-bus.ts +121 -0
  278. package/src/infrastructure/index.ts +10 -0
  279. package/src/infrastructure/logger.ts +108 -0
  280. package/src/infrastructure/service-container.ts +123 -0
  281. package/src/state/index.ts +7 -0
  282. package/src/state/initial-state.ts +60 -0
  283. package/src/state/selectors.ts +126 -0
  284. package/src/state/state-manager.ts +198 -0
  285. package/src/types/config-types.ts +77 -0
  286. package/src/types/extension-types.ts +58 -0
  287. package/src/types/index.ts +12 -0
  288. package/src/types/lsp-types.ts +77 -0
  289. package/src/types/state-types.ts +92 -0
  290. package/src/types/vscode-types.ts +40 -0
  291. package/src/ui/decorations/decoration-controller.ts +252 -0
  292. package/src/ui/decorations/decoration-types.ts +129 -0
  293. package/src/ui/decorations/index.ts +7 -0
  294. package/src/ui/index.ts +7 -0
  295. package/src/ui/notifications/index.ts +5 -0
  296. package/src/ui/notifications/notification-service.ts +167 -0
  297. package/src/ui/status-bar/index.ts +6 -0
  298. package/src/ui/status-bar/status-bar-controller.ts +135 -0
  299. package/src/ui/status-bar/status-bar-modes.ts +119 -0
  300. package/src/views/base-tree-provider.ts +127 -0
  301. package/src/views/constants-tree-provider.ts +525 -0
  302. package/src/views/files-tree-provider.ts +140 -0
  303. package/src/views/index.ts +10 -0
  304. package/src/views/patterns-tree-provider.ts +179 -0
  305. package/src/views/violations-tree-provider.ts +210 -0
  306. package/src/webview/index.ts +7 -0
  307. package/src/webview/webview-manager.ts +238 -0
  308. package/tsconfig.json +22 -0
  309. package/tsconfig.tsbuildinfo +1 -0
@@ -0,0 +1,243 @@
1
+ /**
2
+ * Command definitions
3
+ *
4
+ * Single responsibility: Define all extension commands.
5
+ */
6
+
7
+ /**
8
+ * All Drift command IDs
9
+ */
10
+ export const DRIFT_COMMANDS = {
11
+ // Connection commands
12
+ reconnect: 'drift.reconnect',
13
+ showStatus: 'drift.showStatus',
14
+ showError: 'drift.showError',
15
+
16
+ // Scan commands
17
+ rescan: 'drift.rescan',
18
+ scanFile: 'drift.scanFile',
19
+
20
+ // Pattern commands
21
+ showPatterns: 'drift.showPatterns',
22
+ approvePattern: 'drift.approvePattern',
23
+ ignorePattern: 'drift.ignorePattern',
24
+ createVariant: 'drift.createVariant',
25
+
26
+ // Violation commands
27
+ showViolations: 'drift.showViolations',
28
+ ignoreOnce: 'drift.ignoreOnce',
29
+ quickFix: 'drift.quickFix',
30
+
31
+ // AI commands
32
+ explainWithAI: 'drift.explainWithAI',
33
+ fixWithAI: 'drift.fixWithAI',
34
+
35
+ // UI commands
36
+ openDashboard: 'drift.openDashboard',
37
+ openSettings: 'drift.openSettings',
38
+
39
+ // Export commands
40
+ exportPatterns: 'drift.exportPatterns',
41
+ generateReport: 'drift.generateReport',
42
+
43
+ // Constants commands
44
+ showConstants: 'drift.showConstants',
45
+ showConstantsByCategory: 'drift.showConstantsByCategory',
46
+ showConstantsByLanguage: 'drift.showConstantsByLanguage',
47
+ showConstantIssues: 'drift.showConstantIssues',
48
+ goToConstant: 'drift.goToConstant',
49
+ findConstantUsages: 'drift.findConstantUsages',
50
+ } as const;
51
+
52
+ /**
53
+ * Command type
54
+ */
55
+ export type DriftCommand = typeof DRIFT_COMMANDS[keyof typeof DRIFT_COMMANDS];
56
+
57
+ /**
58
+ * Command metadata
59
+ */
60
+ export interface CommandDefinition {
61
+ id: DriftCommand;
62
+ title: string;
63
+ category: 'Drift';
64
+ icon?: string;
65
+ enablement?: string;
66
+ }
67
+
68
+ /**
69
+ * All command definitions
70
+ */
71
+ export const CommandDefinitions: CommandDefinition[] = [
72
+ // Connection
73
+ {
74
+ id: DRIFT_COMMANDS.reconnect,
75
+ title: 'Reconnect to Server',
76
+ category: 'Drift',
77
+ icon: '$(refresh)',
78
+ },
79
+ {
80
+ id: DRIFT_COMMANDS.showStatus,
81
+ title: 'Show Status',
82
+ category: 'Drift',
83
+ icon: '$(info)',
84
+ },
85
+ {
86
+ id: DRIFT_COMMANDS.showError,
87
+ title: 'Show Error Details',
88
+ category: 'Drift',
89
+ icon: '$(error)',
90
+ },
91
+
92
+ // Scan
93
+ {
94
+ id: DRIFT_COMMANDS.rescan,
95
+ title: 'Rescan Workspace',
96
+ category: 'Drift',
97
+ icon: '$(sync)',
98
+ enablement: 'drift.connected',
99
+ },
100
+ {
101
+ id: DRIFT_COMMANDS.scanFile,
102
+ title: 'Scan Current File',
103
+ category: 'Drift',
104
+ icon: '$(file-code)',
105
+ enablement: 'drift.connected && editorIsOpen',
106
+ },
107
+
108
+ // Patterns
109
+ {
110
+ id: DRIFT_COMMANDS.showPatterns,
111
+ title: 'Show All Patterns',
112
+ category: 'Drift',
113
+ icon: '$(list-tree)',
114
+ enablement: 'drift.connected',
115
+ },
116
+ {
117
+ id: DRIFT_COMMANDS.approvePattern,
118
+ title: 'Approve Pattern',
119
+ category: 'Drift',
120
+ icon: '$(check)',
121
+ enablement: 'drift.connected',
122
+ },
123
+ {
124
+ id: DRIFT_COMMANDS.ignorePattern,
125
+ title: 'Ignore Pattern',
126
+ category: 'Drift',
127
+ icon: '$(x)',
128
+ enablement: 'drift.connected',
129
+ },
130
+ {
131
+ id: DRIFT_COMMANDS.createVariant,
132
+ title: 'Create Variant',
133
+ category: 'Drift',
134
+ icon: '$(git-branch)',
135
+ enablement: 'drift.connected',
136
+ },
137
+
138
+ // Violations
139
+ {
140
+ id: DRIFT_COMMANDS.showViolations,
141
+ title: 'Show All Violations',
142
+ category: 'Drift',
143
+ icon: '$(warning)',
144
+ enablement: 'drift.connected',
145
+ },
146
+ {
147
+ id: DRIFT_COMMANDS.ignoreOnce,
148
+ title: 'Ignore This Occurrence',
149
+ category: 'Drift',
150
+ enablement: 'drift.connected',
151
+ },
152
+ {
153
+ id: DRIFT_COMMANDS.quickFix,
154
+ title: 'Apply Quick Fix',
155
+ category: 'Drift',
156
+ icon: '$(lightbulb)',
157
+ enablement: 'drift.connected',
158
+ },
159
+
160
+ // AI
161
+ {
162
+ id: DRIFT_COMMANDS.explainWithAI,
163
+ title: 'Explain with AI',
164
+ category: 'Drift',
165
+ icon: '$(sparkle)',
166
+ enablement: 'drift.connected && drift.aiEnabled',
167
+ },
168
+ {
169
+ id: DRIFT_COMMANDS.fixWithAI,
170
+ title: 'Fix with AI',
171
+ category: 'Drift',
172
+ icon: '$(wand)',
173
+ enablement: 'drift.connected && drift.aiEnabled',
174
+ },
175
+
176
+ // UI
177
+ {
178
+ id: DRIFT_COMMANDS.openDashboard,
179
+ title: 'Open Dashboard',
180
+ category: 'Drift',
181
+ icon: '$(dashboard)',
182
+ },
183
+ {
184
+ id: DRIFT_COMMANDS.openSettings,
185
+ title: 'Open Settings',
186
+ category: 'Drift',
187
+ icon: '$(gear)',
188
+ },
189
+
190
+ // Export
191
+ {
192
+ id: DRIFT_COMMANDS.exportPatterns,
193
+ title: 'Export Patterns',
194
+ category: 'Drift',
195
+ enablement: 'drift.connected',
196
+ },
197
+ {
198
+ id: DRIFT_COMMANDS.generateReport,
199
+ title: 'Generate Report',
200
+ category: 'Drift',
201
+ enablement: 'drift.connected',
202
+ },
203
+
204
+ // Constants
205
+ {
206
+ id: DRIFT_COMMANDS.showConstants,
207
+ title: 'Show Constants',
208
+ category: 'Drift',
209
+ icon: '$(symbol-constant)',
210
+ enablement: 'drift.connected',
211
+ },
212
+ {
213
+ id: DRIFT_COMMANDS.showConstantsByCategory,
214
+ title: 'View Constants by Category',
215
+ category: 'Drift',
216
+ enablement: 'drift.connected',
217
+ },
218
+ {
219
+ id: DRIFT_COMMANDS.showConstantsByLanguage,
220
+ title: 'View Constants by Language',
221
+ category: 'Drift',
222
+ enablement: 'drift.connected',
223
+ },
224
+ {
225
+ id: DRIFT_COMMANDS.showConstantIssues,
226
+ title: 'View Constant Issues',
227
+ category: 'Drift',
228
+ icon: '$(warning)',
229
+ enablement: 'drift.connected',
230
+ },
231
+ {
232
+ id: DRIFT_COMMANDS.goToConstant,
233
+ title: 'Go to Constant Definition',
234
+ category: 'Drift',
235
+ enablement: 'drift.connected',
236
+ },
237
+ {
238
+ id: DRIFT_COMMANDS.findConstantUsages,
239
+ title: 'Find Constant Usages',
240
+ category: 'Drift',
241
+ enablement: 'drift.connected',
242
+ },
243
+ ];
@@ -0,0 +1,194 @@
1
+ /**
2
+ * CommandRouter - Centralized command handling with middleware
3
+ *
4
+ * Single responsibility: Route commands through middleware chain.
5
+ */
6
+
7
+ import * as vscode from 'vscode';
8
+
9
+ import type { DriftCommand } from './command-definitions.js';
10
+ import type { Logger } from '../infrastructure/index.js';
11
+ import type { StateManager } from '../state/index.js';
12
+
13
+ /**
14
+ * Command context passed to handlers
15
+ */
16
+ export interface CommandContext {
17
+ command: DriftCommand;
18
+ args: unknown[];
19
+ startTime: number;
20
+ progress?: vscode.Progress<{ message?: string; increment?: number }>;
21
+ cancellationToken?: vscode.CancellationToken;
22
+ }
23
+
24
+ /**
25
+ * Command handler function
26
+ */
27
+ export type CommandHandler = (ctx: CommandContext) => Promise<void>;
28
+
29
+ /**
30
+ * Command middleware function
31
+ */
32
+ export type CommandMiddleware = (
33
+ ctx: CommandContext,
34
+ next: () => Promise<void>
35
+ ) => Promise<void>;
36
+
37
+ /**
38
+ * Command registration
39
+ */
40
+ interface CommandRegistration {
41
+ id: DriftCommand;
42
+ handler: CommandHandler;
43
+ showProgress?: boolean;
44
+ progressTitle?: string;
45
+ }
46
+
47
+ /**
48
+ * Command router with middleware support
49
+ */
50
+ export class CommandRouter implements vscode.Disposable {
51
+ private readonly handlers = new Map<DriftCommand, CommandRegistration>();
52
+ private readonly middleware: CommandMiddleware[] = [];
53
+ private readonly disposables: vscode.Disposable[] = [];
54
+
55
+ constructor(
56
+ private readonly context: vscode.ExtensionContext,
57
+ private readonly logger: Logger,
58
+ _stateManager: StateManager // Available for future use
59
+ ) {}
60
+
61
+ /**
62
+ * Add middleware to the chain
63
+ */
64
+ use(middleware: CommandMiddleware): this {
65
+ this.middleware.push(middleware);
66
+ return this;
67
+ }
68
+
69
+ /**
70
+ * Register a command handler
71
+ */
72
+ register(registration: CommandRegistration): vscode.Disposable {
73
+ this.handlers.set(registration.id, registration);
74
+
75
+ const disposable = vscode.commands.registerCommand(
76
+ registration.id,
77
+ async (...args: unknown[]) => {
78
+ await this.execute(registration, args);
79
+ }
80
+ );
81
+
82
+ this.disposables.push(disposable);
83
+ this.context.subscriptions.push(disposable);
84
+
85
+ return disposable;
86
+ }
87
+
88
+ /**
89
+ * Register multiple command handlers
90
+ */
91
+ registerAll(registrations: CommandRegistration[]): void {
92
+ for (const reg of registrations) {
93
+ this.register(reg);
94
+ }
95
+ }
96
+
97
+ /**
98
+ * Execute a command programmatically
99
+ */
100
+ async executeCommand(command: DriftCommand, ...args: unknown[]): Promise<void> {
101
+ await vscode.commands.executeCommand(command, ...args);
102
+ }
103
+
104
+ /**
105
+ * Dispose all registered commands
106
+ */
107
+ dispose(): void {
108
+ for (const d of this.disposables) {
109
+ d.dispose();
110
+ }
111
+ this.handlers.clear();
112
+ this.middleware.length = 0;
113
+ }
114
+
115
+ private async execute(registration: CommandRegistration, args: unknown[]): Promise<void> {
116
+ const ctx: CommandContext = {
117
+ command: registration.id,
118
+ args,
119
+ startTime: performance.now(),
120
+ };
121
+
122
+ try {
123
+ if (registration.showProgress) {
124
+ await this.executeWithProgress(registration, ctx);
125
+ } else {
126
+ await this.executeWithMiddleware(registration.handler, ctx);
127
+ }
128
+ } catch (error) {
129
+ this.handleError(registration.id, error);
130
+ }
131
+ }
132
+
133
+ private async executeWithProgress(
134
+ registration: CommandRegistration,
135
+ ctx: CommandContext
136
+ ): Promise<void> {
137
+ await vscode.window.withProgress(
138
+ {
139
+ location: vscode.ProgressLocation.Notification,
140
+ title: registration.progressTitle || `Drift: ${registration.id}`,
141
+ cancellable: true,
142
+ },
143
+ async (progress, token) => {
144
+ ctx.progress = progress;
145
+ ctx.cancellationToken = token;
146
+ await this.executeWithMiddleware(registration.handler, ctx);
147
+ }
148
+ );
149
+ }
150
+
151
+ private async executeWithMiddleware(
152
+ handler: CommandHandler,
153
+ ctx: CommandContext
154
+ ): Promise<void> {
155
+ let index = 0;
156
+
157
+ const next = async (): Promise<void> => {
158
+ if (index < this.middleware.length) {
159
+ const mw = this.middleware[index++]!;
160
+ await mw(ctx, next);
161
+ } else {
162
+ await handler(ctx);
163
+ }
164
+ };
165
+
166
+ await next();
167
+ }
168
+
169
+ private handleError(command: DriftCommand, error: unknown): void {
170
+ const message = error instanceof Error ? error.message : String(error);
171
+ this.logger.error(`Command ${command} failed:`, message);
172
+
173
+ vscode.window
174
+ .showErrorMessage(`Drift: ${message}`, 'Retry', 'Show Logs')
175
+ .then((action) => {
176
+ if (action === 'Retry') {
177
+ vscode.commands.executeCommand(command);
178
+ } else if (action === 'Show Logs') {
179
+ vscode.commands.executeCommand('drift.showLogs');
180
+ }
181
+ });
182
+ }
183
+ }
184
+
185
+ /**
186
+ * Factory function for creating command router
187
+ */
188
+ export function createCommandRouter(
189
+ context: vscode.ExtensionContext,
190
+ logger: Logger,
191
+ stateManager: StateManager
192
+ ): CommandRouter {
193
+ return new CommandRouter(context, logger, stateManager);
194
+ }
@@ -0,0 +1,74 @@
1
+ /**
2
+ * Connection command handlers
3
+ *
4
+ * Single responsibility: Handle connection-related commands.
5
+ */
6
+
7
+ import { DRIFT_COMMANDS } from '../command-definitions.js';
8
+
9
+ import type { ConnectionManager } from '../../client/index.js';
10
+ import type { StateManager } from '../../state/index.js';
11
+ import type { NotificationService } from '../../ui/notifications/notification-service.js';
12
+ import type { CommandRouter, CommandContext } from '../command-router.js';
13
+
14
+
15
+ /**
16
+ * Create connection command handlers
17
+ */
18
+ export function createConnectionHandlers(
19
+ router: CommandRouter,
20
+ connectionManager: ConnectionManager,
21
+ stateManager: StateManager,
22
+ notifications: NotificationService
23
+ ): void {
24
+ // Reconnect command
25
+ router.register({
26
+ id: DRIFT_COMMANDS.reconnect,
27
+ handler: async (_ctx: CommandContext) => {
28
+ await notifications.withProgress('Reconnecting...', async (progress) => {
29
+ progress.report({ message: 'Disconnecting...' });
30
+ await connectionManager.disconnect();
31
+
32
+ progress.report({ message: 'Connecting...' });
33
+ await connectionManager.connect();
34
+ });
35
+ },
36
+ });
37
+
38
+ // Show status command
39
+ router.register({
40
+ id: DRIFT_COMMANDS.showStatus,
41
+ handler: async (_ctx: CommandContext) => {
42
+ const state = stateManager.getState();
43
+ const { connection, patterns, violations, workspace } = state;
44
+
45
+ const items = [
46
+ `Connection: ${connection.status}`,
47
+ `Server Version: ${connection.serverVersion || 'Unknown'}`,
48
+ `Patterns: ${patterns.total}`,
49
+ `Violations: ${violations.total}`,
50
+ `Last Scan: ${workspace.lastScanTime ? new Date(workspace.lastScanTime).toLocaleString() : 'Never'}`,
51
+ ];
52
+
53
+ await notifications.info(items.join('\n'), [], { detail: 'Drift Status' });
54
+ },
55
+ });
56
+
57
+ // Show error command
58
+ router.register({
59
+ id: DRIFT_COMMANDS.showError,
60
+ handler: async (_ctx: CommandContext) => {
61
+ const state = stateManager.getState();
62
+ const error = state.connection.lastError;
63
+
64
+ if (error) {
65
+ await notifications.error(error, [
66
+ { title: 'Retry', command: DRIFT_COMMANDS.reconnect },
67
+ { title: 'Show Logs', command: 'drift.showLogs' },
68
+ ]);
69
+ } else {
70
+ await notifications.info('No errors to display.');
71
+ }
72
+ },
73
+ });
74
+ }
@@ -0,0 +1,99 @@
1
+ /**
2
+ * Constants command handlers
3
+ *
4
+ * Handlers for constants-related commands.
5
+ */
6
+
7
+ import * as vscode from 'vscode';
8
+
9
+ import type { ConstantsTreeProvider } from '../../views/constants-tree-provider.js';
10
+
11
+ /**
12
+ * Create constants command handlers
13
+ */
14
+ export function createConstantsHandlers(
15
+ constantsProvider: ConstantsTreeProvider
16
+ ): Record<string, (...args: unknown[]) => Promise<void>> {
17
+ return {
18
+ /**
19
+ * Show constants view by category
20
+ */
21
+ 'drift.showConstantsByCategory': async () => {
22
+ constantsProvider.setViewMode('category');
23
+ await vscode.commands.executeCommand('drift.constantsView.focus');
24
+ },
25
+
26
+ /**
27
+ * Show constants view by language
28
+ */
29
+ 'drift.showConstantsByLanguage': async () => {
30
+ constantsProvider.setViewMode('language');
31
+ await vscode.commands.executeCommand('drift.constantsView.focus');
32
+ },
33
+
34
+ /**
35
+ * Show constant issues
36
+ */
37
+ 'drift.showConstantIssues': async () => {
38
+ constantsProvider.setViewMode('issues');
39
+ await vscode.commands.executeCommand('drift.constantsView.focus');
40
+ },
41
+
42
+ /**
43
+ * Go to constant definition
44
+ */
45
+ 'drift.goToConstant': async (file: unknown, line: unknown) => {
46
+ if (typeof file !== 'string' || typeof line !== 'number') {
47
+ return;
48
+ }
49
+
50
+ try {
51
+ const uri = vscode.Uri.file(file);
52
+ const document = await vscode.workspace.openTextDocument(uri);
53
+ const editor = await vscode.window.showTextDocument(document);
54
+
55
+ const position = new vscode.Position(Math.max(0, line - 1), 0);
56
+ editor.selection = new vscode.Selection(position, position);
57
+ editor.revealRange(
58
+ new vscode.Range(position, position),
59
+ vscode.TextEditorRevealType.InCenter
60
+ );
61
+ } catch (error) {
62
+ vscode.window.showErrorMessage(`Failed to open file: ${file}`);
63
+ }
64
+ },
65
+
66
+ /**
67
+ * Find constant usages
68
+ */
69
+ 'drift.findConstantUsages': async (constantName: unknown) => {
70
+ if (typeof constantName !== 'string') {
71
+ // If no constant name provided, prompt for one
72
+ const input = await vscode.window.showInputBox({
73
+ prompt: 'Enter constant name to search for',
74
+ placeHolder: 'CONSTANT_NAME',
75
+ });
76
+ if (!input) {
77
+ return;
78
+ }
79
+ constantName = input;
80
+ }
81
+
82
+ // Use VSCode's built-in search
83
+ await vscode.commands.executeCommand('workbench.action.findInFiles', {
84
+ query: constantName,
85
+ isRegex: false,
86
+ isCaseSensitive: true,
87
+ matchWholeWord: true,
88
+ });
89
+ },
90
+
91
+ /**
92
+ * Show constants overview
93
+ */
94
+ 'drift.showConstants': async () => {
95
+ constantsProvider.setViewMode('category');
96
+ await vscode.commands.executeCommand('drift.constantsView.focus');
97
+ },
98
+ };
99
+ }
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Command handlers module exports
3
+ */
4
+
5
+ export { createConnectionHandlers } from './connection-handlers.js';
6
+ export { createScanHandlers } from './scan-handlers.js';
7
+ export { createPatternHandlers } from './pattern-handlers.js';
8
+ export { createViolationHandlers } from './violation-handlers.js';
9
+ export { createUIHandlers } from './ui-handlers.js';
10
+ export { createConstantsHandlers } from './constants-handlers.js';