driftdetect-lsp 0.9.26 → 0.9.28

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 (112) hide show
  1. package/LICENSE +121 -0
  2. package/package.json +15 -15
  3. package/dist/bin/server.d.ts +0 -12
  4. package/dist/bin/server.js +0 -26
  5. package/dist/bin/server.js.map +0 -1
  6. package/dist/capabilities.d.ts +0 -91
  7. package/dist/capabilities.d.ts.map +0 -1
  8. package/dist/capabilities.js +0 -183
  9. package/dist/capabilities.js.map +0 -1
  10. package/dist/commands/approve-pattern.d.ts +0 -15
  11. package/dist/commands/approve-pattern.js +0 -83
  12. package/dist/commands/approve-pattern.js.map +0 -1
  13. package/dist/commands/create-variant.d.ts +0 -22
  14. package/dist/commands/create-variant.js +0 -109
  15. package/dist/commands/create-variant.js.map +0 -1
  16. package/dist/commands/explain-ai.d.ts +0 -11
  17. package/dist/commands/explain-ai.js +0 -144
  18. package/dist/commands/explain-ai.js.map +0 -1
  19. package/dist/commands/fix-ai.d.ts +0 -11
  20. package/dist/commands/fix-ai.js +0 -146
  21. package/dist/commands/fix-ai.js.map +0 -1
  22. package/dist/commands/ignore-once.d.ts +0 -33
  23. package/dist/commands/ignore-once.js +0 -147
  24. package/dist/commands/ignore-once.js.map +0 -1
  25. package/dist/commands/ignore-pattern.d.ts +0 -15
  26. package/dist/commands/ignore-pattern.js +0 -77
  27. package/dist/commands/ignore-pattern.js.map +0 -1
  28. package/dist/commands/index.d.ts +0 -14
  29. package/dist/commands/index.js +0 -14
  30. package/dist/commands/index.js.map +0 -1
  31. package/dist/commands/rescan.d.ts +0 -19
  32. package/dist/commands/rescan.js +0 -125
  33. package/dist/commands/rescan.js.map +0 -1
  34. package/dist/commands/show-patterns.d.ts +0 -30
  35. package/dist/commands/show-patterns.js +0 -175
  36. package/dist/commands/show-patterns.js.map +0 -1
  37. package/dist/commands/show-violations.d.ts +0 -11
  38. package/dist/commands/show-violations.js +0 -259
  39. package/dist/commands/show-violations.js.map +0 -1
  40. package/dist/handlers/code-actions.d.ts +0 -32
  41. package/dist/handlers/code-actions.js +0 -184
  42. package/dist/handlers/code-actions.js.map +0 -1
  43. package/dist/handlers/code-lens.d.ts +0 -32
  44. package/dist/handlers/code-lens.js +0 -162
  45. package/dist/handlers/code-lens.js.map +0 -1
  46. package/dist/handlers/commands.d.ts +0 -48
  47. package/dist/handlers/commands.js +0 -360
  48. package/dist/handlers/commands.js.map +0 -1
  49. package/dist/handlers/diagnostics.d.ts +0 -73
  50. package/dist/handlers/diagnostics.js +0 -259
  51. package/dist/handlers/diagnostics.js.map +0 -1
  52. package/dist/handlers/document-sync.d.ts +0 -37
  53. package/dist/handlers/document-sync.js +0 -49
  54. package/dist/handlers/document-sync.js.map +0 -1
  55. package/dist/handlers/hover.d.ts +0 -30
  56. package/dist/handlers/hover.js +0 -119
  57. package/dist/handlers/hover.js.map +0 -1
  58. package/dist/handlers/index.d.ts +0 -23
  59. package/dist/handlers/index.js +0 -16
  60. package/dist/handlers/index.js.map +0 -1
  61. package/dist/handlers/initialize.d.ts +0 -41
  62. package/dist/handlers/initialize.d.ts.map +0 -1
  63. package/dist/handlers/initialize.js +0 -33
  64. package/dist/handlers/initialize.js.map +0 -1
  65. package/dist/index.d.ts +0 -22
  66. package/dist/index.js +0 -26
  67. package/dist/index.js.map +0 -1
  68. package/dist/integration/core-scanner.d.ts +0 -89
  69. package/dist/integration/core-scanner.js +0 -309
  70. package/dist/integration/core-scanner.js.map +0 -1
  71. package/dist/integration/index.d.ts +0 -11
  72. package/dist/integration/index.js +0 -11
  73. package/dist/integration/index.js.map +0 -1
  74. package/dist/integration/pattern-store-adapter.d.ts +0 -117
  75. package/dist/integration/pattern-store-adapter.js +0 -349
  76. package/dist/integration/pattern-store-adapter.js.map +0 -1
  77. package/dist/integration/types.d.ts +0 -134
  78. package/dist/integration/types.js +0 -39
  79. package/dist/integration/types.js.map +0 -1
  80. package/dist/server/index.d.ts +0 -5
  81. package/dist/server/index.js +0 -5
  82. package/dist/server/index.js.map +0 -1
  83. package/dist/server/types.d.ts +0 -139
  84. package/dist/server/types.js +0 -8
  85. package/dist/server/types.js.map +0 -1
  86. package/dist/server.d.ts +0 -63
  87. package/dist/server.js +0 -208
  88. package/dist/server.js.map +0 -1
  89. package/dist/types/index.d.ts +0 -5
  90. package/dist/types/index.js +0 -5
  91. package/dist/types/index.js.map +0 -1
  92. package/dist/types/lsp-types.d.ts +0 -321
  93. package/dist/types/lsp-types.js +0 -274
  94. package/dist/types/lsp-types.js.map +0 -1
  95. package/dist/utils/diagnostic.d.ts +0 -84
  96. package/dist/utils/diagnostic.js +0 -256
  97. package/dist/utils/diagnostic.js.map +0 -1
  98. package/dist/utils/document.d.ts +0 -40
  99. package/dist/utils/document.d.ts.map +0 -1
  100. package/dist/utils/document.js +0 -138
  101. package/dist/utils/document.js.map +0 -1
  102. package/dist/utils/index.d.ts +0 -8
  103. package/dist/utils/index.d.ts.map +0 -1
  104. package/dist/utils/index.js +0 -8
  105. package/dist/utils/index.js.map +0 -1
  106. package/dist/utils/position.d.ts +0 -44
  107. package/dist/utils/position.d.ts.map +0 -1
  108. package/dist/utils/position.js +0 -96
  109. package/dist/utils/position.js.map +0 -1
  110. package/dist/utils/workspace.d.ts +0 -98
  111. package/dist/utils/workspace.js +0 -241
  112. package/dist/utils/workspace.js.map +0 -1
package/LICENSE ADDED
@@ -0,0 +1,121 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work.
38
+
39
+ "Derivative Works" shall mean any work, whether in Source or Object
40
+ form, that is based on (or derived from) the Work and for which the
41
+ editorial revisions, annotations, elaborations, or other modifications
42
+ represent, as a whole, an original work of authorship.
43
+
44
+ "Contribution" shall mean any work of authorship, including
45
+ the original version of the Work and any modifications or additions
46
+ to that Work or Derivative Works thereof, that is intentionally
47
+ submitted to the Licensor for inclusion in the Work by the copyright owner.
48
+
49
+ "Contributor" shall mean Licensor and any individual or Legal Entity
50
+ on behalf of whom a Contribution has been received by Licensor and
51
+ subsequently incorporated within the Work.
52
+
53
+ 2. Grant of Copyright License. Subject to the terms and conditions of
54
+ this License, each Contributor hereby grants to You a perpetual,
55
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
56
+ copyright license to reproduce, prepare Derivative Works of,
57
+ publicly display, publicly perform, sublicense, and distribute the
58
+ Work and such Derivative Works in Source or Object form.
59
+
60
+ 3. Grant of Patent License. Subject to the terms and conditions of
61
+ this License, each Contributor hereby grants to You a perpetual,
62
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
63
+ patent license to make, have made, use, offer to sell, sell, import,
64
+ and otherwise transfer the Work.
65
+
66
+ 4. Redistribution. You may reproduce and distribute copies of the
67
+ Work or Derivative Works thereof in any medium, with or without
68
+ modifications, and in Source or Object form, provided that You
69
+ meet the following conditions:
70
+
71
+ (a) You must give any other recipients of the Work or
72
+ Derivative Works a copy of this License; and
73
+
74
+ (b) You must cause any modified files to carry prominent notices
75
+ stating that You changed the files; and
76
+
77
+ (c) You must retain, in the Source form of any Derivative Works
78
+ that You distribute, all copyright, patent, trademark, and
79
+ attribution notices from the Source form of the Work; and
80
+
81
+ (d) If the Work includes a "NOTICE" text file as part of its
82
+ distribution, then any Derivative Works that You distribute must
83
+ include a readable copy of the attribution notices contained
84
+ within such NOTICE file.
85
+
86
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
87
+ any Contribution intentionally submitted for inclusion in the Work
88
+ by You to the Licensor shall be under the terms and conditions of
89
+ this License, without any additional terms or conditions.
90
+
91
+ 6. Trademarks. This License does not grant permission to use the trade
92
+ names, trademarks, service marks, or product names of the Licensor.
93
+
94
+ 7. Disclaimer of Warranty. Unless required by applicable law or
95
+ agreed to in writing, Licensor provides the Work on an "AS IS" BASIS,
96
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND.
97
+
98
+ 8. Limitation of Liability. In no event and under no legal theory,
99
+ shall any Contributor be liable to You for damages, including any
100
+ direct, indirect, special, incidental, or consequential damages.
101
+
102
+ 9. Accepting Warranty or Additional Liability. While redistributing
103
+ the Work or Derivative Works thereof, You may choose to offer,
104
+ and charge a fee for, acceptance of support, warranty, indemnity,
105
+ or other liability obligations.
106
+
107
+ END OF TERMS AND CONDITIONS
108
+
109
+ Copyright 2025 Geoffrey Fernald
110
+
111
+ Licensed under the Apache License, Version 2.0 (the "License");
112
+ you may not use this file except in compliance with the License.
113
+ You may obtain a copy of the License at
114
+
115
+ http://www.apache.org/licenses/LICENSE-2.0
116
+
117
+ Unless required by applicable law or agreed to in writing, software
118
+ distributed under the License is distributed on an "AS IS" BASIS,
119
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
120
+ See the License for the specific language governing permissions and
121
+ limitations under the License.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "driftdetect-lsp",
3
- "version": "0.9.26",
3
+ "version": "0.9.28",
4
4
  "description": "Language Server Protocol implementation for Drift",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
@@ -22,20 +22,9 @@
22
22
  "files": [
23
23
  "dist"
24
24
  ],
25
- "scripts": {
26
- "build": "tsc",
27
- "clean": "rm -rf dist",
28
- "dev": "tsc --watch",
29
- "lint": "eslint src --ext .ts",
30
- "lint:fix": "eslint src --ext .ts --fix",
31
- "test": "vitest run",
32
- "test:watch": "vitest",
33
- "test:coverage": "vitest run --coverage",
34
- "typecheck": "tsc --noEmit"
35
- },
36
25
  "dependencies": {
37
- "driftdetect-core": "workspace:*",
38
- "driftdetect-detectors": "workspace:*",
26
+ "driftdetect-core": "^0.9.28",
27
+ "driftdetect-detectors": "^0.9.28",
39
28
  "vscode-languageserver": "^9.0.1",
40
29
  "vscode-languageserver-textdocument": "^1.0.11",
41
30
  "vscode-uri": "^3.0.8"
@@ -45,5 +34,16 @@
45
34
  "@vitest/coverage-v8": "^1.0.0",
46
35
  "typescript": "^5.3.0",
47
36
  "vitest": "^1.0.0"
37
+ },
38
+ "scripts": {
39
+ "build": "tsc",
40
+ "clean": "rm -rf dist",
41
+ "dev": "tsc --watch",
42
+ "lint": "eslint src --ext .ts",
43
+ "lint:fix": "eslint src --ext .ts --fix",
44
+ "test": "vitest run",
45
+ "test:watch": "vitest",
46
+ "test:coverage": "vitest run --coverage",
47
+ "typecheck": "tsc --noEmit"
48
48
  }
49
- }
49
+ }
@@ -1,12 +0,0 @@
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
@@ -1,26 +0,0 @@
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
@@ -1 +0,0 @@
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"}
@@ -1,91 +0,0 @@
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
@@ -1 +0,0 @@
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"}
@@ -1,183 +0,0 @@
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
@@ -1 +0,0 @@
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,GAAG;IAC5B,wCAAwC;IACxC,eAAe,EAAE,sBAAsB;IACvC,uCAAuC;IACvC,cAAc,EAAE,qBAAqB;IACrC,gDAA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vD,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"}
@@ -1,15 +0,0 @@
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
@@ -1,83 +0,0 @@
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
@@ -1 +0,0 @@
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,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;IAC9C,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,6DAA6D;QAC7D,MAAM,CAAC,IAAI,CAAC,+BAA+B,SAAS,EAAE,CAAC,CAAC;IAC1D,CAAC;IAED,0EAA0E;IAC1E,4CAA4C;IAE5C,wDAAwD;IACxD,IAAI,YAAY,GAAG,CAAC,CAAC;IACrB,KAAK,MAAM,CAAC,GAAG,EAAE,UAAU,CAAC,IAAI,KAAK,CAAC,UAAU,EAAE,CAAC;QACjD,MAAM,QAAQ,GAAG,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,SAAS,KAAK,SAAS,CAAC,CAAC;QACrE,MAAM,OAAO,GAAG,UAAU,CAAC,MAAM,GAAG,QAAQ,CAAC,MAAM,CAAC;QACpD,IAAI,OAAO,GAAG,CAAC,EAAE,CAAC;YAChB,KAAK,CAAC,UAAU,CAAC,GAAG,CAAC,GAAG,EAAE,QAAQ,CAAC,CAAC;YACpC,YAAY,I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;QACb,OAAO,EAAE,YAAY,SAAS,YAAY;QAC1C,IAAI,EAAE;YACJ,SAAS;YACT,iBAAiB,EAAE,YAAY;SAChC;KACF,CAAC;AACJ,CAAC;AAED;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,sBAAsB,CAC1C,OAAsB,EACtB,UAAoB;IAEpB,MAAM,OAAO,GAAuD,EAAE,CAAC;IAEvE,KAAK,MAAM,SAAS,IAAI,UAAU,EAAE,CAAC;QACnC,MAAM,MAAM,GAAG,MAAM,qBAAqB,CAAC,OAAO,EAAE,SAAS,CAAC,CAAC;QAC/D,IAAI,MAAM,CAAC,OAAO,IAAI,MAAM,CAAC,IAAI,EAAE,CAAC;YAClC,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,IAAwD,CAAC,CAAC;QAChF,CAAC;IACH,CAAC;IAED,MAAM,YAAY,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,CAAC,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"}
@@ -1,22 +0,0 @@
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