driftdetect-lsp 0.1.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 (141) hide show
  1. package/dist/bin/server.d.ts +12 -0
  2. package/dist/bin/server.d.ts.map +1 -0
  3. package/dist/bin/server.js +26 -0
  4. package/dist/bin/server.js.map +1 -0
  5. package/dist/capabilities.d.ts +91 -0
  6. package/dist/capabilities.d.ts.map +1 -0
  7. package/dist/capabilities.js +183 -0
  8. package/dist/capabilities.js.map +1 -0
  9. package/dist/commands/approve-pattern.d.ts +15 -0
  10. package/dist/commands/approve-pattern.d.ts.map +1 -0
  11. package/dist/commands/approve-pattern.js +83 -0
  12. package/dist/commands/approve-pattern.js.map +1 -0
  13. package/dist/commands/create-variant.d.ts +22 -0
  14. package/dist/commands/create-variant.d.ts.map +1 -0
  15. package/dist/commands/create-variant.js +109 -0
  16. package/dist/commands/create-variant.js.map +1 -0
  17. package/dist/commands/explain-ai.d.ts +11 -0
  18. package/dist/commands/explain-ai.d.ts.map +1 -0
  19. package/dist/commands/explain-ai.js +144 -0
  20. package/dist/commands/explain-ai.js.map +1 -0
  21. package/dist/commands/fix-ai.d.ts +11 -0
  22. package/dist/commands/fix-ai.d.ts.map +1 -0
  23. package/dist/commands/fix-ai.js +146 -0
  24. package/dist/commands/fix-ai.js.map +1 -0
  25. package/dist/commands/ignore-once.d.ts +33 -0
  26. package/dist/commands/ignore-once.d.ts.map +1 -0
  27. package/dist/commands/ignore-once.js +147 -0
  28. package/dist/commands/ignore-once.js.map +1 -0
  29. package/dist/commands/ignore-pattern.d.ts +15 -0
  30. package/dist/commands/ignore-pattern.d.ts.map +1 -0
  31. package/dist/commands/ignore-pattern.js +77 -0
  32. package/dist/commands/ignore-pattern.js.map +1 -0
  33. package/dist/commands/index.d.ts +14 -0
  34. package/dist/commands/index.d.ts.map +1 -0
  35. package/dist/commands/index.js +14 -0
  36. package/dist/commands/index.js.map +1 -0
  37. package/dist/commands/rescan.d.ts +19 -0
  38. package/dist/commands/rescan.d.ts.map +1 -0
  39. package/dist/commands/rescan.js +125 -0
  40. package/dist/commands/rescan.js.map +1 -0
  41. package/dist/commands/show-patterns.d.ts +30 -0
  42. package/dist/commands/show-patterns.d.ts.map +1 -0
  43. package/dist/commands/show-patterns.js +175 -0
  44. package/dist/commands/show-patterns.js.map +1 -0
  45. package/dist/commands/show-violations.d.ts +11 -0
  46. package/dist/commands/show-violations.d.ts.map +1 -0
  47. package/dist/commands/show-violations.js +259 -0
  48. package/dist/commands/show-violations.js.map +1 -0
  49. package/dist/handlers/code-actions.d.ts +32 -0
  50. package/dist/handlers/code-actions.d.ts.map +1 -0
  51. package/dist/handlers/code-actions.js +184 -0
  52. package/dist/handlers/code-actions.js.map +1 -0
  53. package/dist/handlers/code-lens.d.ts +32 -0
  54. package/dist/handlers/code-lens.d.ts.map +1 -0
  55. package/dist/handlers/code-lens.js +162 -0
  56. package/dist/handlers/code-lens.js.map +1 -0
  57. package/dist/handlers/commands.d.ts +48 -0
  58. package/dist/handlers/commands.d.ts.map +1 -0
  59. package/dist/handlers/commands.js +360 -0
  60. package/dist/handlers/commands.js.map +1 -0
  61. package/dist/handlers/diagnostics.d.ts +73 -0
  62. package/dist/handlers/diagnostics.d.ts.map +1 -0
  63. package/dist/handlers/diagnostics.js +259 -0
  64. package/dist/handlers/diagnostics.js.map +1 -0
  65. package/dist/handlers/document-sync.d.ts +37 -0
  66. package/dist/handlers/document-sync.d.ts.map +1 -0
  67. package/dist/handlers/document-sync.js +49 -0
  68. package/dist/handlers/document-sync.js.map +1 -0
  69. package/dist/handlers/hover.d.ts +30 -0
  70. package/dist/handlers/hover.d.ts.map +1 -0
  71. package/dist/handlers/hover.js +119 -0
  72. package/dist/handlers/hover.js.map +1 -0
  73. package/dist/handlers/index.d.ts +23 -0
  74. package/dist/handlers/index.d.ts.map +1 -0
  75. package/dist/handlers/index.js +16 -0
  76. package/dist/handlers/index.js.map +1 -0
  77. package/dist/handlers/initialize.d.ts +41 -0
  78. package/dist/handlers/initialize.d.ts.map +1 -0
  79. package/dist/handlers/initialize.js +33 -0
  80. package/dist/handlers/initialize.js.map +1 -0
  81. package/dist/index.d.ts +22 -0
  82. package/dist/index.d.ts.map +1 -0
  83. package/dist/index.js +26 -0
  84. package/dist/index.js.map +1 -0
  85. package/dist/integration/core-scanner.d.ts +89 -0
  86. package/dist/integration/core-scanner.d.ts.map +1 -0
  87. package/dist/integration/core-scanner.js +309 -0
  88. package/dist/integration/core-scanner.js.map +1 -0
  89. package/dist/integration/index.d.ts +11 -0
  90. package/dist/integration/index.d.ts.map +1 -0
  91. package/dist/integration/index.js +11 -0
  92. package/dist/integration/index.js.map +1 -0
  93. package/dist/integration/pattern-store-adapter.d.ts +117 -0
  94. package/dist/integration/pattern-store-adapter.d.ts.map +1 -0
  95. package/dist/integration/pattern-store-adapter.js +349 -0
  96. package/dist/integration/pattern-store-adapter.js.map +1 -0
  97. package/dist/integration/types.d.ts +134 -0
  98. package/dist/integration/types.d.ts.map +1 -0
  99. package/dist/integration/types.js +39 -0
  100. package/dist/integration/types.js.map +1 -0
  101. package/dist/server/index.d.ts +5 -0
  102. package/dist/server/index.d.ts.map +1 -0
  103. package/dist/server/index.js +5 -0
  104. package/dist/server/index.js.map +1 -0
  105. package/dist/server/types.d.ts +139 -0
  106. package/dist/server/types.d.ts.map +1 -0
  107. package/dist/server/types.js +8 -0
  108. package/dist/server/types.js.map +1 -0
  109. package/dist/server.d.ts +63 -0
  110. package/dist/server.d.ts.map +1 -0
  111. package/dist/server.js +208 -0
  112. package/dist/server.js.map +1 -0
  113. package/dist/types/index.d.ts +5 -0
  114. package/dist/types/index.d.ts.map +1 -0
  115. package/dist/types/index.js +5 -0
  116. package/dist/types/index.js.map +1 -0
  117. package/dist/types/lsp-types.d.ts +321 -0
  118. package/dist/types/lsp-types.d.ts.map +1 -0
  119. package/dist/types/lsp-types.js +274 -0
  120. package/dist/types/lsp-types.js.map +1 -0
  121. package/dist/utils/diagnostic.d.ts +84 -0
  122. package/dist/utils/diagnostic.d.ts.map +1 -0
  123. package/dist/utils/diagnostic.js +256 -0
  124. package/dist/utils/diagnostic.js.map +1 -0
  125. package/dist/utils/document.d.ts +40 -0
  126. package/dist/utils/document.d.ts.map +1 -0
  127. package/dist/utils/document.js +132 -0
  128. package/dist/utils/document.js.map +1 -0
  129. package/dist/utils/index.d.ts +8 -0
  130. package/dist/utils/index.d.ts.map +1 -0
  131. package/dist/utils/index.js +8 -0
  132. package/dist/utils/index.js.map +1 -0
  133. package/dist/utils/position.d.ts +44 -0
  134. package/dist/utils/position.d.ts.map +1 -0
  135. package/dist/utils/position.js +96 -0
  136. package/dist/utils/position.js.map +1 -0
  137. package/dist/utils/workspace.d.ts +98 -0
  138. package/dist/utils/workspace.d.ts.map +1 -0
  139. package/dist/utils/workspace.js +241 -0
  140. package/dist/utils/workspace.js.map +1 -0
  141. package/package.json +49 -0
@@ -0,0 +1,12 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * Drift LSP Server Entry Point
4
+ *
5
+ * This is the executable entry point for the Drift LSP server.
6
+ * It can be run directly or spawned by an editor extension.
7
+ *
8
+ * Usage:
9
+ * drift-lsp [--debug]
10
+ */
11
+ export {};
12
+ //# sourceMappingURL=server.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../src/bin/server.ts"],"names":[],"mappings":";AACA;;;;;;;;GAQG"}
@@ -0,0 +1,26 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * Drift LSP Server Entry Point
4
+ *
5
+ * This is the executable entry point for the Drift LSP server.
6
+ * It can be run directly or spawned by an editor extension.
7
+ *
8
+ * Usage:
9
+ * drift-lsp [--debug]
10
+ */
11
+ import { startDriftServer } from '../server.js';
12
+ // Parse command line arguments
13
+ const args = process.argv.slice(2);
14
+ const debug = args.includes('--debug') || args.includes('-d');
15
+ // Start the server
16
+ const server = startDriftServer({ debug });
17
+ // Handle process signals
18
+ process.on('SIGINT', () => {
19
+ server.stop();
20
+ process.exit(0);
21
+ });
22
+ process.on('SIGTERM', () => {
23
+ server.stop();
24
+ process.exit(0);
25
+ });
26
+ //# sourceMappingURL=server.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"server.js","sourceRoot":"","sources":["../../src/bin/server.ts"],"names":[],"mappings":";AACA;;;;;;;;GAQG;AAEH,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAEhD,+BAA+B;AAC/B,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;AACnC,MAAM,KAAK,GAAG,IAAI,CAAC,QAAQ,CAAC,SAAS,CAAC,IAAI,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;AAE9D,mBAAmB;AACnB,MAAM,MAAM,GAAG,gBAAgB,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC;AAE3C,yBAAyB;AACzB,OAAO,CAAC,EAAE,CAAC,QAAQ,EAAE,GAAG,EAAE;IACxB,MAAM,CAAC,IAAI,EAAE,CAAC;IACd,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC,CAAC,CAAC;AAEH,OAAO,CAAC,EAAE,CAAC,SAAS,EAAE,GAAG,EAAE;IACzB,MAAM,CAAC,IAAI,EAAE,CAAC;IACd,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC,CAAC,CAAC"}
@@ -0,0 +1,91 @@
1
+ /**
2
+ * LSP Server Capabilities
3
+ *
4
+ * Defines the capabilities that the Drift LSP server advertises to clients.
5
+ * Based on the Language Server Protocol specification.
6
+ *
7
+ * @requirements 27.1 - THE LSP_Server SHALL implement the Language Server Protocol specification
8
+ * @requirements 27.2 - THE LSP_Server SHALL support document synchronization
9
+ * @requirements 27.3 - THE LSP_Server SHALL publish diagnostics for violations
10
+ * @requirements 27.4 - THE LSP_Server SHALL provide code actions for quick fixes
11
+ * @requirements 27.5 - THE LSP_Server SHALL provide hover information for violations
12
+ * @requirements 27.6 - THE LSP_Server SHALL provide code lens for pattern information
13
+ */
14
+ import type { ServerCapabilities, InitializeResult } from 'vscode-languageserver';
15
+ /**
16
+ * Server identification information
17
+ */
18
+ export declare const SERVER_INFO: {
19
+ readonly name: "drift-lsp";
20
+ readonly version: "0.0.1";
21
+ };
22
+ /**
23
+ * All Drift LSP commands
24
+ * @requirements 28.1-28.9 - LSP Server Commands
25
+ */
26
+ export declare const DRIFT_COMMANDS: {
27
+ /** Approve a pattern for enforcement */
28
+ readonly APPROVE_PATTERN: "drift.approvePattern";
29
+ /** Ignore a pattern (don't enforce) */
30
+ readonly IGNORE_PATTERN: "drift.ignorePattern";
31
+ /** Ignore a single occurrence of a violation */
32
+ readonly IGNORE_ONCE: "drift.ignoreOnce";
33
+ /** Create a variant (intentional deviation) */
34
+ readonly CREATE_VARIANT: "drift.createVariant";
35
+ /** Request AI explanation for a violation */
36
+ readonly EXPLAIN_AI: "drift.explainWithAI";
37
+ /** Request AI-generated fix for a violation */
38
+ readonly FIX_AI: "drift.fixWithAI";
39
+ /** Rescan workspace for patterns and violations */
40
+ readonly RESCAN: "drift.rescan";
41
+ /** Show all discovered patterns */
42
+ readonly SHOW_PATTERNS: "drift.showPatterns";
43
+ /** Show all current violations */
44
+ readonly SHOW_VIOLATIONS: "drift.showViolations";
45
+ };
46
+ /**
47
+ * Array of all command IDs for registration
48
+ */
49
+ export declare const ALL_COMMANDS: readonly string[];
50
+ /**
51
+ * Supported code action kinds
52
+ */
53
+ export declare const SUPPORTED_CODE_ACTION_KINDS: readonly ["quickfix", "refactor", "source"];
54
+ /**
55
+ * Build the full server capabilities object
56
+ *
57
+ * This defines what the Drift LSP server can do, following the spec:
58
+ * - textDocumentSync: Document synchronization with incremental changes
59
+ * - diagnosticProvider: Publish diagnostics for violations
60
+ * - codeActionProvider: Quick fixes and refactoring actions
61
+ * - hoverProvider: Show violation details on hover
62
+ * - codeLensProvider: Inline pattern information
63
+ * - executeCommandProvider: All drift.* commands
64
+ * - workspace: Workspace folder support and file operations
65
+ */
66
+ export declare function buildServerCapabilities(): ServerCapabilities;
67
+ /**
68
+ * Build the initialize result to send to the client
69
+ */
70
+ export declare function buildInitializeResult(): InitializeResult;
71
+ /**
72
+ * Check if client supports a specific capability path
73
+ */
74
+ export declare function clientSupportsCapability(clientCapabilities: Record<string, unknown> | undefined, path: string): boolean;
75
+ /**
76
+ * Check if client supports workspace configuration
77
+ */
78
+ export declare function clientSupportsConfiguration(clientCapabilities: Record<string, unknown> | undefined): boolean;
79
+ /**
80
+ * Check if client supports workspace folders
81
+ */
82
+ export declare function clientSupportsWorkspaceFolders(clientCapabilities: Record<string, unknown> | undefined): boolean;
83
+ /**
84
+ * Check if client supports work done progress
85
+ */
86
+ export declare function clientSupportsWorkDoneProgress(clientCapabilities: Record<string, unknown> | undefined): boolean;
87
+ /**
88
+ * Check if client supports diagnostic related information
89
+ */
90
+ export declare function clientSupportsDiagnosticRelatedInfo(clientCapabilities: Record<string, unknown> | undefined): boolean;
91
+ //# sourceMappingURL=capabilities.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"capabilities.d.ts","sourceRoot":"","sources":["../src/capabilities.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAMH,OAAO,KAAK,EAAE,kBAAkB,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAMlF;;GAEG;AACH,eAAO,MAAM,WAAW;;;CAGd,CAAC;AAMX;;;GAGG;AACH,eAAO,MAAM,cAAc;IACzB,wCAAwC;;IAExC,uCAAuC;;IAEvC,gDAAgD;;IAEhD,+CAA+C;;IAE/C,6CAA6C;;IAE7C,+CAA+C;;IAE/C,mDAAmD;;IAEnD,mCAAmC;;IAEnC,kCAAkC;;CAE1B,CAAC;AAEX;;GAEG;AACH,eAAO,MAAM,YAAY,EAAE,SAAS,MAAM,EAAkC,CAAC;AAM7E;;GAEG;AACH,eAAO,MAAM,2BAA2B,6CAI9B,CAAC;AAMX;;;;;;;;;;;GAWG;AACH,wBAAgB,uBAAuB,IAAI,kBAAkB,CAqD5D;AAED;;GAEG;AACH,wBAAgB,qBAAqB,IAAI,gBAAgB,CAKxD;AAMD;;GAEG;AACH,wBAAgB,wBAAwB,CACtC,kBAAkB,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,EACvD,IAAI,EAAE,MAAM,GACX,OAAO,CAgBT;AAED;;GAEG;AACH,wBAAgB,2BAA2B,CACzC,kBAAkB,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,GACtD,OAAO,CAET;AAED;;GAEG;AACH,wBAAgB,8BAA8B,CAC5C,kBAAkB,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,GACtD,OAAO,CAET;AAED;;GAEG;AACH,wBAAgB,8BAA8B,CAC5C,kBAAkB,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,GACtD,OAAO,CAET;AAED;;GAEG;AACH,wBAAgB,mCAAmC,CACjD,kBAAkB,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,GACtD,OAAO,CAKT"}
@@ -0,0 +1,183 @@
1
+ /**
2
+ * LSP Server Capabilities
3
+ *
4
+ * Defines the capabilities that the Drift LSP server advertises to clients.
5
+ * Based on the Language Server Protocol specification.
6
+ *
7
+ * @requirements 27.1 - THE LSP_Server SHALL implement the Language Server Protocol specification
8
+ * @requirements 27.2 - THE LSP_Server SHALL support document synchronization
9
+ * @requirements 27.3 - THE LSP_Server SHALL publish diagnostics for violations
10
+ * @requirements 27.4 - THE LSP_Server SHALL provide code actions for quick fixes
11
+ * @requirements 27.5 - THE LSP_Server SHALL provide hover information for violations
12
+ * @requirements 27.6 - THE LSP_Server SHALL provide code lens for pattern information
13
+ */
14
+ import { TextDocumentSyncKind, CodeActionKind, } from 'vscode-languageserver';
15
+ // ============================================================================
16
+ // Server Information
17
+ // ============================================================================
18
+ /**
19
+ * Server identification information
20
+ */
21
+ export const SERVER_INFO = {
22
+ name: 'drift-lsp',
23
+ version: '0.0.1',
24
+ };
25
+ // ============================================================================
26
+ // Command Definitions
27
+ // ============================================================================
28
+ /**
29
+ * All Drift LSP commands
30
+ * @requirements 28.1-28.9 - LSP Server Commands
31
+ */
32
+ export const DRIFT_COMMANDS = {
33
+ /** Approve a pattern for enforcement */
34
+ APPROVE_PATTERN: 'drift.approvePattern',
35
+ /** Ignore a pattern (don't enforce) */
36
+ IGNORE_PATTERN: 'drift.ignorePattern',
37
+ /** Ignore a single occurrence of a violation */
38
+ IGNORE_ONCE: 'drift.ignoreOnce',
39
+ /** Create a variant (intentional deviation) */
40
+ CREATE_VARIANT: 'drift.createVariant',
41
+ /** Request AI explanation for a violation */
42
+ EXPLAIN_AI: 'drift.explainWithAI',
43
+ /** Request AI-generated fix for a violation */
44
+ FIX_AI: 'drift.fixWithAI',
45
+ /** Rescan workspace for patterns and violations */
46
+ RESCAN: 'drift.rescan',
47
+ /** Show all discovered patterns */
48
+ SHOW_PATTERNS: 'drift.showPatterns',
49
+ /** Show all current violations */
50
+ SHOW_VIOLATIONS: 'drift.showViolations',
51
+ };
52
+ /**
53
+ * Array of all command IDs for registration
54
+ */
55
+ export const ALL_COMMANDS = Object.values(DRIFT_COMMANDS);
56
+ // ============================================================================
57
+ // Code Action Kinds
58
+ // ============================================================================
59
+ /**
60
+ * Supported code action kinds
61
+ */
62
+ export const SUPPORTED_CODE_ACTION_KINDS = [
63
+ CodeActionKind.QuickFix,
64
+ CodeActionKind.Refactor,
65
+ CodeActionKind.Source,
66
+ ];
67
+ // ============================================================================
68
+ // Server Capabilities Builder
69
+ // ============================================================================
70
+ /**
71
+ * Build the full server capabilities object
72
+ *
73
+ * This defines what the Drift LSP server can do, following the spec:
74
+ * - textDocumentSync: Document synchronization with incremental changes
75
+ * - diagnosticProvider: Publish diagnostics for violations
76
+ * - codeActionProvider: Quick fixes and refactoring actions
77
+ * - hoverProvider: Show violation details on hover
78
+ * - codeLensProvider: Inline pattern information
79
+ * - executeCommandProvider: All drift.* commands
80
+ * - workspace: Workspace folder support and file operations
81
+ */
82
+ export function buildServerCapabilities() {
83
+ return {
84
+ // Document synchronization
85
+ // @requirements 27.2 - Support document synchronization (open, change, save, close)
86
+ textDocumentSync: {
87
+ openClose: true,
88
+ change: TextDocumentSyncKind.Incremental,
89
+ save: { includeText: true },
90
+ },
91
+ // Diagnostics (squiggly lines)
92
+ // @requirements 27.3 - Publish diagnostics for violations
93
+ diagnosticProvider: {
94
+ interFileDependencies: true,
95
+ workspaceDiagnostics: true,
96
+ },
97
+ // Code actions (quick fixes)
98
+ // @requirements 27.4 - Provide code actions for quick fixes
99
+ codeActionProvider: {
100
+ codeActionKinds: [...SUPPORTED_CODE_ACTION_KINDS],
101
+ resolveProvider: true,
102
+ },
103
+ // Hover information
104
+ // @requirements 27.5 - Provide hover information for violations
105
+ hoverProvider: true,
106
+ // Code lens (inline actions)
107
+ // @requirements 27.6 - Provide code lens for pattern information
108
+ codeLensProvider: {
109
+ resolveProvider: true,
110
+ },
111
+ // Commands
112
+ // @requirements 28.1-28.9 - All drift.* commands
113
+ executeCommandProvider: {
114
+ commands: [...ALL_COMMANDS],
115
+ },
116
+ // Workspace features
117
+ workspace: {
118
+ workspaceFolders: {
119
+ supported: true,
120
+ changeNotifications: true,
121
+ },
122
+ fileOperations: {
123
+ didCreate: { filters: [{ pattern: { glob: '**/*' } }] },
124
+ didRename: { filters: [{ pattern: { glob: '**/*' } }] },
125
+ didDelete: { filters: [{ pattern: { glob: '**/*' } }] },
126
+ },
127
+ },
128
+ };
129
+ }
130
+ /**
131
+ * Build the initialize result to send to the client
132
+ */
133
+ export function buildInitializeResult() {
134
+ return {
135
+ capabilities: buildServerCapabilities(),
136
+ serverInfo: { ...SERVER_INFO },
137
+ };
138
+ }
139
+ // ============================================================================
140
+ // Client Capability Helpers
141
+ // ============================================================================
142
+ /**
143
+ * Check if client supports a specific capability path
144
+ */
145
+ export function clientSupportsCapability(clientCapabilities, path) {
146
+ if (!clientCapabilities) {
147
+ return false;
148
+ }
149
+ const parts = path.split('.');
150
+ let current = clientCapabilities;
151
+ for (const part of parts) {
152
+ if (current === null || current === undefined || typeof current !== 'object') {
153
+ return false;
154
+ }
155
+ current = current[part];
156
+ }
157
+ return current === true || (typeof current === 'object' && current !== null);
158
+ }
159
+ /**
160
+ * Check if client supports workspace configuration
161
+ */
162
+ export function clientSupportsConfiguration(clientCapabilities) {
163
+ return clientSupportsCapability(clientCapabilities, 'workspace.configuration');
164
+ }
165
+ /**
166
+ * Check if client supports workspace folders
167
+ */
168
+ export function clientSupportsWorkspaceFolders(clientCapabilities) {
169
+ return clientSupportsCapability(clientCapabilities, 'workspace.workspaceFolders');
170
+ }
171
+ /**
172
+ * Check if client supports work done progress
173
+ */
174
+ export function clientSupportsWorkDoneProgress(clientCapabilities) {
175
+ return clientSupportsCapability(clientCapabilities, 'window.workDoneProgress');
176
+ }
177
+ /**
178
+ * Check if client supports diagnostic related information
179
+ */
180
+ export function clientSupportsDiagnosticRelatedInfo(clientCapabilities) {
181
+ return clientSupportsCapability(clientCapabilities, 'textDocument.publishDiagnostics.relatedInformation');
182
+ }
183
+ //# sourceMappingURL=capabilities.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"capabilities.js","sourceRoot":"","sources":["../src/capabilities.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EACL,oBAAoB,EACpB,cAAc,GACf,MAAM,uBAAuB,CAAC;AAG/B,+EAA+E;AAC/E,qBAAqB;AACrB,+EAA+E;AAE/E;;GAEG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG;IACzB,IAAI,EAAE,WAAW;IACjB,OAAO,EAAE,OAAO;CACR,CAAC;AAEX,+EAA+E;AAC/E,sBAAsB;AACtB,+EAA+E;AAE/E;;;GAGG;AACH,MAAM,CAAC,MAAM,cAAc,GA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AAE,CAAC;YAC7E,OAAO,KAAK,CAAC;QACf,CAAC;QACD,OAAO,GAAI,OAAmC,CAAC,IAAI,CAAC,CAAC;IACvD,CAAC;IAED,OAAO,OAAO,KAAK,IAAI,IAAI,CAAC,OAAO,OAAO,KAAK,QAAQ,IAAI,OAAO,KAAK,IAAI,CAAC,CAAC;AAC/E,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,2BAA2B,CACzC,kBAAuD;IAEvD,OAAO,wBAAwB,CAAC,kBAAkB,EAAE,yBAAyB,CAAC,CAAC;AACjF,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,8BAA8B,CAC5C,kBAAuD;IAEvD,OAAO,wBAAwB,CAAC,kBAAkB,EAAE,4BAA4B,CAAC,CAAC;AACpF,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,8BAA8B,CAC5C,kBAAuD;IAEvD,OAAO,wBAAwB,CAAC,kBAAkB,EAAE,yBAAyB,CAAC,CAAC;AACjF,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,mCAAmC,CACjD,kBAAuD;IAEvD,OAAO,wBAAwB,CAC7B,kBAAkB,EAClB,oDAAoD,CACrD,CAAC;AACJ,CAAC"}
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Approve Pattern Command - drift.approvePattern
3
+ * @requirements 28.1
4
+ */
5
+ import type { ServerContext, CommandResult } from '../server/types.js';
6
+ /**
7
+ * Execute approve pattern command
8
+ * Marks a pattern as approved, removing all violations for that pattern
9
+ */
10
+ export declare function executeApprovePattern(context: ServerContext, patternId: string): Promise<CommandResult>;
11
+ /**
12
+ * Approve multiple patterns at once
13
+ */
14
+ export declare function executeApprovePatterns(context: ServerContext, patternIds: string[]): Promise<CommandResult>;
15
+ //# sourceMappingURL=approve-pattern.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"approve-pattern.d.ts","sourceRoot":"","sources":["../../src/commands/approve-pattern.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAEvE;;;GAGG;AACH,wBAAsB,qBAAqB,CACzC,OAAO,EAAE,aAAa,EACtB,SAAS,EAAE,MAAM,GAChB,OAAO,CAAC,aAAa,CAAC,CAmExB;AAED;;GAEG;AACH,wBAAsB,sBAAsB,CAC1C,OAAO,EAAE,aAAa,EACtB,UAAU,EAAE,MAAM,EAAE,GACnB,OAAO,CAAC,aAAa,CAAC,CAiBxB"}
@@ -0,0 +1,83 @@
1
+ /**
2
+ * Approve Pattern Command - drift.approvePattern
3
+ * @requirements 28.1
4
+ */
5
+ /**
6
+ * Execute approve pattern command
7
+ * Marks a pattern as approved, removing all violations for that pattern
8
+ */
9
+ export async function executeApprovePattern(context, patternId) {
10
+ const { state, logger, connection } = context;
11
+ if (!patternId) {
12
+ return {
13
+ success: false,
14
+ error: 'Pattern ID is required',
15
+ };
16
+ }
17
+ logger.info(`Approving pattern: ${patternId}`);
18
+ // Check if pattern exists
19
+ const pattern = state.patterns.get(patternId);
20
+ if (!pattern) {
21
+ // Pattern might not be in cache, but we can still approve it
22
+ logger.warn(`Pattern not found in cache: ${patternId}`);
23
+ }
24
+ // TODO: Integrate with driftdetect-core pattern store to persist approval
25
+ // For now, we'll update the in-memory state
26
+ // Remove violations for this pattern from all documents
27
+ let removedCount = 0;
28
+ for (const [uri, violations] of state.violations) {
29
+ const filtered = violations.filter((v) => v.patternId !== patternId);
30
+ const removed = violations.length - filtered.length;
31
+ if (removed > 0) {
32
+ state.violations.set(uri, filtered);
33
+ removedCount += removed;
34
+ // Update diagnostics for this document
35
+ const diagnostics = state.diagnostics.get(uri);
36
+ if (diagnostics) {
37
+ const filteredDiagnostics = diagnostics.filter((d) => d.patternId !== patternId);
38
+ state.diagnostics.set(uri, filteredDiagnostics);
39
+ // Publish updated diagnostics
40
+ connection.sendDiagnostics({
41
+ uri,
42
+ diagnostics: filteredDiagnostics.map((diag) => ({
43
+ range: diag.range,
44
+ severity: diag.severity === 'error' ? 1 : diag.severity === 'warning' ? 2 : diag.severity === 'info' ? 3 : 4,
45
+ code: diag.code,
46
+ source: diag.source,
47
+ message: diag.message,
48
+ })),
49
+ });
50
+ }
51
+ }
52
+ }
53
+ // Show notification
54
+ connection.window.showInformationMessage(`Pattern "${patternId}" approved. ${removedCount} violation${removedCount === 1 ? '' : 's'} removed.`);
55
+ logger.info(`Pattern approved: ${patternId}, removed ${removedCount} violations`);
56
+ return {
57
+ success: true,
58
+ message: `Pattern "${patternId}" approved`,
59
+ data: {
60
+ patternId,
61
+ removedViolations: removedCount,
62
+ },
63
+ };
64
+ }
65
+ /**
66
+ * Approve multiple patterns at once
67
+ */
68
+ export async function executeApprovePatterns(context, patternIds) {
69
+ const results = [];
70
+ for (const patternId of patternIds) {
71
+ const result = await executeApprovePattern(context, patternId);
72
+ if (result.success && result.data) {
73
+ results.push(result.data);
74
+ }
75
+ }
76
+ const totalRemoved = results.reduce((sum, r) => sum + r.removedViolations, 0);
77
+ return {
78
+ success: true,
79
+ message: `Approved ${results.length} patterns, removed ${totalRemoved} violations`,
80
+ data: { results },
81
+ };
82
+ }
83
+ //# sourceMappingURL=approve-pattern.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"approve-pattern.js","sourceRoot":"","sources":["../../src/commands/approve-pattern.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,qBAAqB,CACzC,OAAsB,EACtB,SAAiB;IAEjB,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,GAAG,OAAO,CAAC;IAE9C,IAAI,CAAC,SAAS,EAAE,CAAC;QACf,OAAO;YACL,OAAO,EAAE,KAAK;YACd,KAAK,EAAE,wBAAwB;SAChC,CAAC;IACJ,CAAC;IAED,MAAM,CAAC,IAAI,CAAC,sBAAsB,SAAS,EAAE,CAAC,CAAC;IAE/C,0BAA0B;IAC1B,MAAM,OAAO,GAAG,KAAK,CAAC,QAAQ,C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C,EAAE,EAAE,CAAC,GAAG,GAAG,CAAC,CAAC,iBAAiB,EAAE,CAAC,CAAC,CAAC;IAE9E,OAAO;QACL,OAAO,EAAE,IAAI;QACb,OAAO,EAAE,YAAY,OAAO,CAAC,MAAM,sBAAsB,YAAY,aAAa;QAClF,IAAI,EAAE,EAAE,OAAO,EAAE;KAClB,CAAC;AACJ,CAAC"}
@@ -0,0 +1,22 @@
1
+ /**
2
+ * Create Variant Command - drift.createVariant
3
+ * @requirements 28.4
4
+ */
5
+ import type { ServerContext, CommandResult } from '../server/types.js';
6
+ /**
7
+ * Execute create variant command
8
+ * Creates a new pattern variant from an existing violation
9
+ */
10
+ export declare function executeCreateVariant(context: ServerContext, patternId: string, violationId?: string): Promise<CommandResult>;
11
+ /**
12
+ * Validate variant name
13
+ */
14
+ export declare function validateVariantName(name: string): string | null;
15
+ /**
16
+ * Get suggested variant names based on violation context
17
+ */
18
+ export declare function getSuggestedVariantNames(basePatternName: string, violationContext?: {
19
+ file?: string;
20
+ message?: string;
21
+ }): string[];
22
+ //# sourceMappingURL=create-variant.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"create-variant.d.ts","sourceRoot":"","sources":["../../src/commands/create-variant.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAEvE;;;GAGG;AACH,wBAAsB,oBAAoB,CACxC,OAAO,EAAE,aAAa,EACtB,SAAS,EAAE,MAAM,EACjB,WAAW,CAAC,EAAE,MAAM,GACnB,OAAO,CAAC,aAAa,CAAC,CAoExB;AAWD;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAc/D;AAED;;GAEG;AACH,wBAAgB,wBAAwB,CACtC,eAAe,EAAE,MAAM,EACvB,gBAAgB,CAAC,EAAE;IACjB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB,GACA,MAAM,EAAE,CAoBV"}
@@ -0,0 +1,109 @@
1
+ /**
2
+ * Create Variant Command - drift.createVariant
3
+ * @requirements 28.4
4
+ */
5
+ /**
6
+ * Execute create variant command
7
+ * Creates a new pattern variant from an existing violation
8
+ */
9
+ export async function executeCreateVariant(context, patternId, violationId) {
10
+ const { state, logger, connection } = context;
11
+ if (!patternId) {
12
+ return {
13
+ success: false,
14
+ error: 'Pattern ID is required',
15
+ };
16
+ }
17
+ logger.info(`Creating variant for pattern: ${patternId}`);
18
+ // Get the base pattern
19
+ const basePattern = state.patterns.get(patternId);
20
+ if (!basePattern) {
21
+ return {
22
+ success: false,
23
+ error: `Pattern not found: ${patternId}`,
24
+ };
25
+ }
26
+ // If violation ID provided, get the violation for context
27
+ let violation = null;
28
+ if (violationId) {
29
+ for (const violations of state.violations.values()) {
30
+ const found = violations.find((v) => v.id === violationId);
31
+ if (found) {
32
+ violation = { file: found.file, location: found.range };
33
+ break;
34
+ }
35
+ }
36
+ }
37
+ // TODO: Integrate with driftdetect-core variant manager
38
+ // For now, we'll create a variant with a generated name
39
+ // Generate variant ID and name
40
+ const variantId = generateVariantId(patternId);
41
+ const variantName = `${basePattern.name ?? patternId} (variant)`;
42
+ // Create the variant (in-memory for now)
43
+ const variant = {
44
+ id: variantId,
45
+ basePatternId: patternId,
46
+ name: variantName,
47
+ description: undefined,
48
+ createdAt: new Date().toISOString(),
49
+ context: violation ? {
50
+ file: violation.file,
51
+ location: violation.location,
52
+ } : undefined,
53
+ };
54
+ logger.info(`Variant created: ${variantId}`);
55
+ // Show success message
56
+ connection.window.showInformationMessage(`Variant "${variantName}" created for pattern "${patternId}"`);
57
+ return {
58
+ success: true,
59
+ message: `Variant "${variantName}" created`,
60
+ data: {
61
+ variant,
62
+ basePatternId: patternId,
63
+ },
64
+ };
65
+ }
66
+ /**
67
+ * Generate a unique variant ID
68
+ */
69
+ function generateVariantId(basePatternId) {
70
+ const timestamp = Date.now().toString(36);
71
+ const random = Math.random().toString(36).substring(2, 6);
72
+ return `${basePatternId}:variant:${timestamp}${random}`;
73
+ }
74
+ /**
75
+ * Validate variant name
76
+ */
77
+ export function validateVariantName(name) {
78
+ if (!name || name.trim().length === 0) {
79
+ return 'Variant name cannot be empty';
80
+ }
81
+ if (name.length > 100) {
82
+ return 'Variant name must be 100 characters or less';
83
+ }
84
+ if (!/^[a-zA-Z0-9\s\-_()]+$/.test(name)) {
85
+ return 'Variant name can only contain letters, numbers, spaces, hyphens, underscores, and parentheses';
86
+ }
87
+ return null;
88
+ }
89
+ /**
90
+ * Get suggested variant names based on violation context
91
+ */
92
+ export function getSuggestedVariantNames(basePatternName, violationContext) {
93
+ const suggestions = [];
94
+ // Base suggestion
95
+ suggestions.push(`${basePatternName} (variant)`);
96
+ // File-based suggestion
97
+ if (violationContext?.file) {
98
+ const fileName = violationContext.file.split('/').pop()?.replace(/\.[^.]+$/, '');
99
+ if (fileName) {
100
+ suggestions.push(`${basePatternName} (${fileName})`);
101
+ }
102
+ }
103
+ // Context-based suggestions
104
+ suggestions.push(`${basePatternName} (alternative)`);
105
+ suggestions.push(`${basePatternName} (exception)`);
106
+ suggestions.push(`${basePatternName} (legacy)`);
107
+ return suggestions;
108
+ }
109
+ //# sourceMappingURL=create-variant.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"create-variant.js","sourceRoot":"","sources":["../../src/commands/create-variant.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,oBAAoB,CACxC,OAAsB,EACtB,SAAiB,EACjB,WAAoB;IAEpB,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,GAAG,OAAO,CAAC;IAE9C,IAAI,CAAC,SAAS,EAAE,CAAC;QACf,OAAO;YACL,OAAO,EAAE,KAAK;YACd,KAAK,EAAE,wBAAwB;SAChC,CAAC;IACJ,CAAC;IAED,MAAM,CAAC,IAAI,CAAC,iCAAiC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AC,CAAC;IAEjD,wBAAwB;IACxB,IAAI,gBAAgB,EAAE,IAAI,EAAE,CAAC;QAC3B,MAAM,QAAQ,GAAG,gBAAgB,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,OAAO,CAAC,UAAU,EAAE,EAAE,CAAC,CAAC;QACjF,IAAI,QAAQ,EAAE,CAAC;YACb,WAAW,CAAC,IAAI,CAAC,GAAG,eAAe,KAAK,QAAQ,GAAG,CAAC,CAAC;QACvD,CAAC;IACH,CAAC;IAED,4BAA4B;IAC5B,WAAW,CAAC,IAAI,CAAC,GAAG,eAAe,gBAAgB,CAAC,CAAC;IACrD,WAAW,CAAC,IAAI,CAAC,GAAG,eAAe,cAAc,CAAC,CAAC;IACnD,WAAW,CAAC,IAAI,CAAC,GAAG,eAAe,WAAW,CAAC,CAAC;IAEhD,OAAO,WAAW,CAAC;AACrB,CAAC"}
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Explain AI Command - drift.explainWithAI
3
+ * @requirements 28.5
4
+ */
5
+ import type { ServerContext, CommandResult } from '../server/types.js';
6
+ /**
7
+ * Execute explain with AI command
8
+ * Uses AI to explain why a violation occurred and how to fix it
9
+ */
10
+ export declare function executeExplainAI(context: ServerContext, violationId: string, patternId: string): Promise<CommandResult>;
11
+ //# sourceMappingURL=explain-ai.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"explain-ai.d.ts","sourceRoot":"","sources":["../../src/commands/explain-ai.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAEvE;;;GAGG;AACH,wBAAsB,gBAAgB,CACpC,OAAO,EAAE,aAAa,EACtB,WAAW,EAAE,MAAM,EACnB,SAAS,EAAE,MAAM,GAChB,OAAO,CAAC,aAAa,CAAC,CAsGxB"}