Skip to content

Commit d1e505f

Browse files
committed
Add GitHub Copilot instructions
1 parent 3a5fd97 commit d1e505f

File tree

1 file changed

+105
-0
lines changed

1 file changed

+105
-0
lines changed

.github/copilot-instructions.md

Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
# Dev Proxy Toolkit VS Code Extension - AI Development Guide
2+
3+
## Architecture Overview
4+
5+
This VS Code extension provides integration with Microsoft Dev Proxy, an API simulator tool. The extension follows a modular architecture with clear separation of concerns:
6+
7+
- **Core Detection**: `src/detect.ts` - Handles Dev Proxy installation detection, version checking, and running status via API polling on port 8897
8+
- **Configuration Analysis**: `src/diagnostics.ts` - Complex JSON schema validation using `json-to-ast` for Dev Proxy config files
9+
- **Plugin System**: `src/constants.ts` - Maintains comprehensive mappings of 40+ Dev Proxy plugins to their snippet names and configuration requirements
10+
- **State Management**: Global state tracking via VS Code's `ExtensionContext.globalState` for Dev Proxy installation details
11+
12+
## Critical Patterns
13+
14+
### Plugin Configuration Validation
15+
The extension performs sophisticated validation of Dev Proxy configuration files:
16+
```typescript
17+
// Plugin validation follows this pattern in diagnostics.ts
18+
const pluginSnippet = pluginSnippets[pluginName];
19+
if (pluginSnippet.config?.required && !configSectionNode) {
20+
// Error: Missing required config section
21+
}
22+
```
23+
24+
### Version-Aware Features
25+
All Dev Proxy interactions respect user's version preference (stable vs beta):
26+
```typescript
27+
const versionPreference = configuration.get('version') as VersionPreference;
28+
const devProxyExe = getDevProxyExe(versionPreference);
29+
```
30+
31+
### AST-Based JSON Analysis
32+
Use `json-to-ast` for reliable JSON parsing and range detection:
33+
```typescript
34+
const documentNode = parse(document.getText()) as parse.ObjectNode;
35+
const range = getRangeFromASTNode(node); // For precise diagnostic positioning
36+
```
37+
38+
## Development Workflow
39+
40+
### Build & Watch
41+
- **Development**: `npm run watch` - Webpack watch mode with source maps
42+
- **Testing**: `npm run watch-tests` - TypeScript compilation for tests
43+
- **Packaging**: `npm run package` - Production webpack build
44+
45+
### Testing Strategy
46+
- Tests use sinon for mocking external dependencies
47+
- Test files in `src/test/examples/` provide realistic Dev Proxy configurations
48+
- Extension activation requires waiting for `vscode.extensions.getExtension().isActive`
49+
50+
### Key Dependencies
51+
- `json-to-ast`: Critical for precise JSON parsing and error positioning
52+
- `semver`: Version comparison for feature compatibility
53+
- VS Code Test framework with electron runner
54+
55+
## Extension Points
56+
57+
### Command Registration Pattern
58+
Commands follow enablement contexts based on Dev Proxy state:
59+
```json
60+
"enablement": "isDevProxyRunning && !isDevProxyRecording"
61+
```
62+
63+
### MCP Server Integration
64+
Extension provides Model Context Protocol server with tools:
65+
- `mcp_dev_proxy_FindDocs` - Documentation lookup
66+
- `mcp_dev_proxy_GetVersion` - Version detection
67+
68+
### Task Provider
69+
Custom task definitions for Dev Proxy operations:
70+
```json
71+
{
72+
"type": "devproxy",
73+
"command": "start|stop",
74+
"configFile": "path/to/config"
75+
}
76+
```
77+
78+
## Cross-Platform Considerations
79+
80+
### Package Manager Detection
81+
- **Windows**: Winget availability check before installation
82+
- **macOS**: Homebrew validation
83+
- **Linux**: Manual installation guidance
84+
85+
### Executable Detection
86+
Version preference affects executable name:
87+
- Stable: `devproxy`
88+
- Beta: `devproxy-beta`
89+
90+
## Configuration Schema Management
91+
92+
The extension maintains awareness of Dev Proxy schema versions and validates compatibility:
93+
- Schema URLs must match installed Dev Proxy version
94+
- Plugin path deprecation warnings for v0.29.0+ (old: `dev-proxy-plugins.dll`, new: `DevProxy.Plugins.dll`)
95+
- Automatic schema update code actions available
96+
97+
## Plugin Ecosystem Knowledge
98+
99+
Maintain plugin relationships in `constants.ts`:
100+
- 40+ plugins with instance/config snippet mappings
101+
- Required vs optional configuration sections
102+
- Plugin ordering rules (reporters last, ApiCenterOnboarding after OpenApiSpecGenerator)
103+
- Summary plugins require reporter plugins
104+
105+
When adding new plugins, update both `pluginSnippets` and `pluginDocs` objects with consistent naming.

0 commit comments

Comments
 (0)