partnercore-proxy 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (73) hide show
  1. package/CHANGELOG.md +54 -0
  2. package/LICENSE +22 -0
  3. package/README.md +234 -0
  4. package/dist/al/extension-manager.d.ts +52 -0
  5. package/dist/al/extension-manager.d.ts.map +1 -0
  6. package/dist/al/extension-manager.js +348 -0
  7. package/dist/al/extension-manager.js.map +1 -0
  8. package/dist/al/index.d.ts +3 -0
  9. package/dist/al/index.d.ts.map +1 -0
  10. package/dist/al/index.js +19 -0
  11. package/dist/al/index.js.map +1 -0
  12. package/dist/al/language-server.d.ts +134 -0
  13. package/dist/al/language-server.d.ts.map +1 -0
  14. package/dist/al/language-server.js +431 -0
  15. package/dist/al/language-server.js.map +1 -0
  16. package/dist/cli.d.ts +8 -0
  17. package/dist/cli.d.ts.map +1 -0
  18. package/dist/cli.js +207 -0
  19. package/dist/cli.js.map +1 -0
  20. package/dist/cloud/index.d.ts +2 -0
  21. package/dist/cloud/index.d.ts.map +1 -0
  22. package/dist/cloud/index.js +18 -0
  23. package/dist/cloud/index.js.map +1 -0
  24. package/dist/cloud/relay-client.d.ts +84 -0
  25. package/dist/cloud/relay-client.d.ts.map +1 -0
  26. package/dist/cloud/relay-client.js +211 -0
  27. package/dist/cloud/relay-client.js.map +1 -0
  28. package/dist/config/index.d.ts +3 -0
  29. package/dist/config/index.d.ts.map +1 -0
  30. package/dist/config/index.js +19 -0
  31. package/dist/config/index.js.map +1 -0
  32. package/dist/config/loader.d.ts +20 -0
  33. package/dist/config/loader.d.ts.map +1 -0
  34. package/dist/config/loader.js +136 -0
  35. package/dist/config/loader.js.map +1 -0
  36. package/dist/config/types.d.ts +51 -0
  37. package/dist/config/types.d.ts.map +1 -0
  38. package/dist/config/types.js +33 -0
  39. package/dist/config/types.js.map +1 -0
  40. package/dist/index.d.ts +13 -0
  41. package/dist/index.d.ts.map +1 -0
  42. package/dist/index.js +29 -0
  43. package/dist/index.js.map +1 -0
  44. package/dist/mcp/index.d.ts +2 -0
  45. package/dist/mcp/index.d.ts.map +1 -0
  46. package/dist/mcp/index.js +18 -0
  47. package/dist/mcp/index.js.map +1 -0
  48. package/dist/mcp/server.d.ts +33 -0
  49. package/dist/mcp/server.d.ts.map +1 -0
  50. package/dist/mcp/server.js +98 -0
  51. package/dist/mcp/server.js.map +1 -0
  52. package/dist/router/index.d.ts +2 -0
  53. package/dist/router/index.d.ts.map +1 -0
  54. package/dist/router/index.js +18 -0
  55. package/dist/router/index.js.map +1 -0
  56. package/dist/router/tool-router.d.ts +87 -0
  57. package/dist/router/tool-router.d.ts.map +1 -0
  58. package/dist/router/tool-router.js +557 -0
  59. package/dist/router/tool-router.js.map +1 -0
  60. package/dist/utils/index.d.ts +3 -0
  61. package/dist/utils/index.d.ts.map +1 -0
  62. package/dist/utils/index.js +19 -0
  63. package/dist/utils/index.js.map +1 -0
  64. package/dist/utils/logger.d.ts +20 -0
  65. package/dist/utils/logger.d.ts.map +1 -0
  66. package/dist/utils/logger.js +99 -0
  67. package/dist/utils/logger.js.map +1 -0
  68. package/dist/utils/security.d.ts +66 -0
  69. package/dist/utils/security.d.ts.map +1 -0
  70. package/dist/utils/security.js +358 -0
  71. package/dist/utils/security.js.map +1 -0
  72. package/mcp.json +125 -0
  73. package/package.json +107 -0
package/CHANGELOG.md ADDED
@@ -0,0 +1,54 @@
1
+ # Changelog
2
+
3
+ All notable changes to this project will be documented in this file.
4
+
5
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
+ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
+
8
+ ## [Unreleased]
9
+
10
+ ## [0.1.0] - 2024-12-26
11
+
12
+ ### Added
13
+ - Initial release of PartnerCore Proxy
14
+ - AL Language Server integration via Microsoft AL extension
15
+ - Auto-download from VS Code Marketplace
16
+ - Symbol navigation (definitions, references)
17
+ - Code completion
18
+ - Hover information
19
+ - Real compiler diagnostics
20
+ - Cloud relay to PartnerCore MCP server
21
+ - API key authentication
22
+ - Secure HTTPS communication
23
+ - Local tools:
24
+ - `al_get_symbols` - Get all symbols in an AL file
25
+ - `al_find_symbol` - Search symbols by name
26
+ - `al_find_references` - Find all references to a symbol
27
+ - `al_get_diagnostics` - Get compiler diagnostics
28
+ - `al_go_to_definition` - Navigate to symbol definition
29
+ - `al_hover` - Get type info and documentation
30
+ - `al_completion` - Get code completions
31
+ - `read_file` - Read file contents
32
+ - `write_file` - Write file contents
33
+ - `list_files` - List files in directory
34
+ - `search_files` - Search for text in files
35
+ - Cloud tools (routed to PartnerCore):
36
+ - `partnercore_review` - AI-powered code review
37
+ - `partnercore_improve` - Get improvement suggestions
38
+ - `partnercore_analyze` - Pattern-based analysis
39
+ - `partnercore_validate` - Validate against standards
40
+ - `partnercore_kb_search` - Search knowledge base
41
+ - `partnercore_template` - Get code templates
42
+ - `partnercore_generate` - Generate AL code
43
+ - CLI commands:
44
+ - `start` - Start the MCP proxy server
45
+ - `check` - Check configuration and connections
46
+ - `download-extension` - Download/update AL extension
47
+ - MCP marketplace manifest (`mcp.json`)
48
+
49
+ ### Security
50
+ - [SECURITY] Path traversal prevention in file operations
51
+ - [SECURITY] API keys never logged
52
+ - [SECURITY] HTTPS-only cloud communication
53
+ - [SECURITY] Workspace sandboxing for file access
54
+
package/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 Ciellos
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
22
+
package/README.md ADDED
@@ -0,0 +1,234 @@
1
+ # @ciellos/partnercore-proxy
2
+
3
+ **Local MCP proxy for Microsoft Dynamics 365 Business Central AL development**
4
+
5
+ [![npm version](https://img.shields.io/npm/v/@ciellos/partnercore-proxy.svg)](https://www.npmjs.com/package/@ciellos/partnercore-proxy)
6
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
7
+
8
+ ## Overview
9
+
10
+ PartnerCore Proxy bridges local AL development with cloud-based AI assistance:
11
+
12
+ - **Real AL Language Server** - Symbol navigation, diagnostics, completions via Microsoft's AL extension
13
+ - **Intelligent Routing** - Local operations stay local; cloud operations require API key
14
+ - **Secure by Design** - API keys never logged, file access sandboxed to workspace
15
+ - **MCP Standard** - Works with Claude, Cursor, and any MCP-compatible AI assistant
16
+
17
+ ## Quick Start
18
+
19
+ ### Global Installation
20
+
21
+ ```bash
22
+ npm install -g @ciellos/partnercore-proxy
23
+ ```
24
+
25
+ ### Run with npx (no install)
26
+
27
+ ```bash
28
+ npx @ciellos/partnercore-proxy start --workspace /path/to/al-project
29
+ ```
30
+
31
+ ### MCP Configuration
32
+
33
+ Add to your AI assistant's MCP configuration:
34
+
35
+ **Cursor (`~/.cursor/mcp.json`):**
36
+ ```json
37
+ {
38
+ "mcpServers": {
39
+ "partnercore": {
40
+ "command": "npx",
41
+ "args": ["@ciellos/partnercore-proxy", "start"],
42
+ "env": {
43
+ "AL_WORKSPACE_ROOT": "/path/to/your/al-project",
44
+ "PARTNERCORE_API_KEY": "your-api-key"
45
+ }
46
+ }
47
+ }
48
+ }
49
+ ```
50
+
51
+ **Claude Desktop (`claude_desktop_config.json`):**
52
+ ```json
53
+ {
54
+ "mcpServers": {
55
+ "partnercore": {
56
+ "command": "partnercore-proxy",
57
+ "args": ["start", "--workspace", "/path/to/al-project"],
58
+ "env": {
59
+ "PARTNERCORE_API_KEY": "your-api-key"
60
+ }
61
+ }
62
+ }
63
+ }
64
+ ```
65
+
66
+ ## Features
67
+
68
+ ### Local Tools (No API Key Required)
69
+
70
+ | Tool | Description |
71
+ |------|-------------|
72
+ | `al_get_symbols` | Get all symbols in an AL file (tables, pages, codeunits, procedures) |
73
+ | `al_find_symbol` | Search for symbols by name across the workspace |
74
+ | `al_find_references` | Find all references to a symbol |
75
+ | `al_get_diagnostics` | Get real compiler diagnostics (errors, warnings) |
76
+ | `al_go_to_definition` | Navigate to symbol definition |
77
+ | `al_hover` | Get type information and documentation |
78
+ | `al_completion` | Get intelligent code completion suggestions |
79
+ | `read_file` | Read file contents (sandboxed to workspace) |
80
+ | `write_file` | Write file contents (sandboxed to workspace) |
81
+ | `list_files` | List files in directory |
82
+ | `search_files` | Search for text in files |
83
+
84
+ ### Cloud Tools (API Key Required)
85
+
86
+ | Tool | Description |
87
+ |------|-------------|
88
+ | `partnercore_review` | AI-powered code review with 252+ AL patterns |
89
+ | `partnercore_improve` | Get specific improvement suggestions |
90
+ | `partnercore_analyze` | Deep pattern-based code analysis |
91
+ | `partnercore_validate` | Validate against BC/AL standards |
92
+ | `partnercore_kb_search` | Search PartnerCore knowledge base |
93
+ | `partnercore_template` | Get production-ready AL code templates |
94
+ | `partnercore_generate` | Generate AL code from descriptions |
95
+
96
+ ## CLI Commands
97
+
98
+ ```bash
99
+ # Start the MCP proxy
100
+ partnercore-proxy start [options]
101
+
102
+ Options:
103
+ -w, --workspace <path> AL workspace root (containing app.json)
104
+ -v, --verbose Enable verbose logging
105
+ --no-cloud Disable cloud connection (local tools only)
106
+
107
+ # Check configuration
108
+ partnercore-proxy check
109
+
110
+ # Download/update AL extension
111
+ partnercore-proxy download-extension
112
+ ```
113
+
114
+ ## Environment Variables
115
+
116
+ | Variable | Required | Description |
117
+ |----------|----------|-------------|
118
+ | `AL_WORKSPACE_ROOT` | Yes | Path to AL project (containing `app.json`) |
119
+ | `PARTNERCORE_API_KEY` | No* | API key for cloud features |
120
+ | `PARTNERCORE_ENV` | No | Environment: `production` or `uat` (default: `production`) |
121
+ | `PARTNERCORE_CLOUD_URL` | No | Override cloud URL (takes precedence over ENV) |
122
+ | `LOG_LEVEL` | No | `debug`, `info`, `warn`, `error` (default: `info`) |
123
+
124
+ *Cloud tools require API key. Local tools work without it.
125
+
126
+ ### Environment Endpoints
127
+
128
+ | Environment | URL |
129
+ |-------------|-----|
130
+ | **Production** (default) | `https://partnercore-mcp-prod.agreeablebush-0fe29c4e.eastus.azurecontainerapps.io` |
131
+ | **UAT** | `https://partnercore-mcp-uat.happysand-4085830a.eastus.azurecontainerapps.io` |
132
+
133
+ To use UAT environment:
134
+ ```bash
135
+ export PARTNERCORE_ENV=uat
136
+ partnercore-proxy start
137
+ ```
138
+
139
+ ## Architecture
140
+
141
+ ```
142
+ ┌─────────────────────────────────────────────────────────────────────┐
143
+ │ AI Assistant (Claude/Cursor/Copilot) │
144
+ └─────────────────────────────────────────────────────────────────────┘
145
+
146
+ ▼ MCP Protocol (stdio)
147
+ ┌─────────────────────────────────────────────────────────────────────┐
148
+ │ PartnerCore Proxy (Your Machine) │
149
+ │ ┌───────────────────────────────────────────────────────────────┐ │
150
+ │ │ Tool Router │ │
151
+ │ │ al_* tools ──────► AL Language Server (local, fast) │ │
152
+ │ │ file tools ──────► Sandboxed File System │ │
153
+ │ │ partnercore_* ───► Cloud API (HTTPS, authenticated) │ │
154
+ │ └───────────────────────────────────────────────────────────────┘ │
155
+ └─────────────────────────────────────────────────────────────────────┘
156
+ │ │
157
+ ▼ ▼
158
+ ┌──────────────────┐ ┌─────────────────────────────────┐
159
+ │ Your AL Files │ │ PartnerCore Cloud │
160
+ │ (local only) │ │ - Knowledge Base │
161
+ └──────────────────┘ │ - 252+ Patterns │
162
+ │ - AI Code Review │
163
+ └─────────────────────────────────┘
164
+ ```
165
+
166
+ ## Security
167
+
168
+ ### File System Sandboxing
169
+ - All file operations are restricted to the configured workspace root
170
+ - Path traversal attacks are prevented
171
+ - Maximum file sizes enforced
172
+
173
+ ### API Key Protection
174
+ - API keys are **never logged** at any level
175
+ - Keys transmitted only over HTTPS
176
+ - Automatic masking in error messages
177
+
178
+ ### Network Security
179
+ - Cloud communication uses HTTPS/TLS only
180
+ - Only connects to:
181
+ - `marketplace.visualstudio.com` (Microsoft VS Code Marketplace)
182
+ - `partnercore-mcp-prod.*.azurecontainerapps.io` (PartnerCore Production)
183
+ - `partnercore-mcp-uat.*.azurecontainerapps.io` (PartnerCore UAT)
184
+
185
+ See [SECURITY.md](./SECURITY.md) for full security documentation.
186
+
187
+ ## Getting an API Key
188
+
189
+ 1. Visit [https://partnercore.ai](https://partnercore.ai)
190
+ 2. Sign up for a PartnerCore account
191
+ 3. Generate an API key in your dashboard
192
+ 4. Add it to your MCP configuration
193
+
194
+ **Without an API key**, you can still use all local AL Language Server features!
195
+
196
+ ## Troubleshooting
197
+
198
+ ### "AL Language Server not initialized"
199
+ - Ensure `app.json` exists in your workspace root
200
+ - Check that the AL extension downloaded successfully: `partnercore-proxy download-extension`
201
+
202
+ ### "File not found" errors
203
+ - Paths must be relative to the workspace root
204
+ - Absolute paths outside workspace are blocked for security
205
+
206
+ ### Cloud tools return "Cloud client not configured"
207
+ - Set `PARTNERCORE_API_KEY` environment variable
208
+ - Verify with `partnercore-proxy check`
209
+
210
+ ### Verbose logging
211
+ ```bash
212
+ partnercore-proxy start --verbose
213
+ ```
214
+
215
+ ## Requirements
216
+
217
+ - **Node.js**: 18.0.0 or higher
218
+ - **Operating System**: Windows, macOS, or Linux
219
+ - **AL Project**: Valid `app.json` in workspace
220
+
221
+ ## Contributing
222
+
223
+ Contributions are welcome! Please see [CONTRIBUTING.md](./CONTRIBUTING.md).
224
+
225
+ ## License
226
+
227
+ MIT - see [LICENSE](./LICENSE)
228
+
229
+ ## Links
230
+
231
+ - [PartnerCore Cloud](https://partnercore.ai)
232
+ - [Ciellos](https://ciellos.com)
233
+ - [GitHub Repository](https://github.com/ciellos-dev/partnercore-proxy)
234
+ - [MCP Specification](https://modelcontextprotocol.io)
@@ -0,0 +1,52 @@
1
+ /**
2
+ * AL Extension Manager
3
+ *
4
+ * Handles downloading and managing the Microsoft AL Language extension
5
+ * which contains the EditorServices.Host executable for LSP communication.
6
+ */
7
+ import { ALConfig, ALExtensionInfo } from '../config/types.js';
8
+ /**
9
+ * AL Extension Manager
10
+ */
11
+ export declare class ALExtensionManager {
12
+ private config;
13
+ private logger;
14
+ constructor(config: ALConfig);
15
+ /**
16
+ * Get or download the AL extension
17
+ */
18
+ getExtension(): Promise<ALExtensionInfo>;
19
+ /**
20
+ * Load an existing extension from a specified path
21
+ */
22
+ private loadExistingExtension;
23
+ /**
24
+ * Find cached extension
25
+ */
26
+ private findCachedExtension;
27
+ /**
28
+ * Download extension from VS Code Marketplace
29
+ */
30
+ private downloadExtension;
31
+ /**
32
+ * Query VS Code Marketplace for extension info
33
+ */
34
+ private queryMarketplace;
35
+ /**
36
+ * Download a file
37
+ */
38
+ private downloadFile;
39
+ /**
40
+ * Find EditorServices.Host executable in extension directory
41
+ */
42
+ private findEditorServices;
43
+ /**
44
+ * Recursively search for EditorServices executable
45
+ */
46
+ private searchForEditorServices;
47
+ /**
48
+ * List files recursively for debugging
49
+ */
50
+ private listFilesRecursive;
51
+ }
52
+ //# sourceMappingURL=extension-manager.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"extension-manager.d.ts","sourceRoot":"","sources":["../../src/al/extension-manager.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAMH,OAAO,EAAE,QAAQ,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAmC/D;;GAEG;AACH,qBAAa,kBAAkB;IAC7B,OAAO,CAAC,MAAM,CAAW;IACzB,OAAO,CAAC,MAAM,CAAe;gBAEjB,MAAM,EAAE,QAAQ;IAI5B;;OAEG;IACG,YAAY,IAAI,OAAO,CAAC,eAAe,CAAC;IAiB9C;;OAEG;IACH,OAAO,CAAC,qBAAqB;IA4B7B;;OAEG;IACH,OAAO,CAAC,mBAAmB;IAiC3B;;OAEG;YACW,iBAAiB;IAwE/B;;OAEG;YACW,gBAAgB;IAiE9B;;OAEG;YACW,YAAY;IAgB1B;;OAEG;IACH,OAAO,CAAC,kBAAkB;IAkC1B;;OAEG;IACH,OAAO,CAAC,uBAAuB;IA0B/B;;OAEG;IACH,OAAO,CAAC,kBAAkB;CAqB3B"}