Skip to content

Commit b07d16b

Browse files
Adds GitHub Copilot instructions (#1316)
1 parent 36c391f commit b07d16b

File tree

1 file changed

+75
-0
lines changed

1 file changed

+75
-0
lines changed

.github/copilot-instructions.md

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
# Copilot Instructions for Dev Proxy
2+
3+
## Overview
4+
Dev Proxy is a cross-platform .NET API simulator and proxy for testing how applications handle API failures, rate limits, latency, and more. It is highly extensible via a plugin architecture and is configured using JSON files. The project is organized as a multi-project .NET solution.
5+
6+
**Key technologies:**
7+
- Uses a fork of Titanium.Web.Proxy: [svrooij/unobtanium-web-proxy](https://github.com/svrooij/unobtanium-web-proxy)
8+
- CLI built with System.CommandLine
9+
- .NET Dependency Injection is used throughout
10+
11+
## Architecture
12+
- **Main entry point:** `DevProxy/Program.cs` sets up the web host, loads configuration, logging, and plugins, and starts the proxy engine.
13+
- **Proxy Engine:** `DevProxy/Proxy/ProxyEngine.cs` manages network interception, request/response handling, plugin invocation, and system proxy integration.
14+
- **Plugins:** Implement the `IPlugin` interface (`DevProxy.Abstractions/Plugins/IPlugin.cs`). For most plugins, inherit from `BasePlugin` or `BaseReportingPlugin` in `DevProxy.Abstractions/Plugins/`. Plugins are loaded dynamically based on configuration in `devproxyrc.json` or similar config files. Plugins can:
15+
- Intercept and modify requests/responses
16+
- Add custom commands/options to the CLI (via System.CommandLine)
17+
- React to events (recording, logging, etc.)
18+
- **Configuration:**
19+
- Main config: `DevProxy/config/devproxyrc.json` (or other JSON files in `config/`)
20+
- Plugins and URLs to watch are defined here. See `m365.json` for examples.
21+
- **Commands:**
22+
- CLI commands are defined in `DevProxy/Commands/` and registered via `DevProxyCommand.cs` (using System.CommandLine).
23+
- Certificate management: `cert ensure` and `cert remove` (see `CertCommand.cs`).
24+
- **Cross-platform support:**
25+
- macOS-specific scripts: `trust-cert.sh`, `remove-cert.sh`, `toggle-proxy.sh` in `DevProxy/`.
26+
27+
## Dev Proxy MCP Server
28+
- The Dev Proxy MCP server exposes access to Dev Proxy documentation and JSON schemas, making it invaluable for both contributors and users.
29+
- Use the MCP server to programmatically retrieve up-to-date docs and schema definitions for config and plugins.
30+
- See: [@devproxy/mcp on npm](https://www.npmjs.com/package/@devproxy/mcp)
31+
32+
## Developer Workflows
33+
- **Build:** Use the VS Code task `build` or run `dotnet build DevProxy.sln`.
34+
- **Run:** Use the VS Code task `watch` or run `dotnet watch run --project DevProxy.sln`.
35+
- **Publish:** Use the VS Code task `publish` or run `dotnet publish DevProxy.sln`.
36+
- **Debug:** Attach to the running process or use `dotnet watch run` for hot reload.
37+
- **Test:** (No test project detected; add tests in `tests/` if needed.)
38+
39+
## Project Conventions
40+
- **Plugin loading:** Plugins must be registered in the config file and implement `IPlugin` (preferably via `BasePlugin` or `BaseReportingPlugin`). Use the `PluginServiceExtensions` for registration logic.
41+
- **URL matching:** URLs to watch are defined as wildcards in config and converted to regexes at runtime.
42+
- **Logging:** Uses Microsoft.Extensions.Logging. Log levels and output are configurable.
43+
- **Configuration tokens:** Paths in config can use `~appFolder` for resolution.
44+
- **Hotkeys:** When running interactively, hotkeys are available (see console output for details).
45+
- **Schema validation:** Config files reference a `$schema` for validation and versioning.
46+
- **CLI:** All CLI commands and options are built using System.CommandLine.
47+
- **Dependency Injection:** All services, plugins, and commands are registered and resolved via .NET DI.
48+
49+
## Key Files & Directories
50+
- `DevProxy/Program.cs` — Main entry
51+
- `DevProxy/Proxy/ProxyEngine.cs` — Core proxy logic
52+
- `DevProxy/Commands/` — CLI commands (System.CommandLine)
53+
- `DevProxy/Plugins/` — Plugin loader and helpers
54+
- `DevProxy.Abstractions/Plugins/IPlugin.cs` — Plugin interface
55+
- `DevProxy.Abstractions/Plugins/BasePlugin.cs`, `BaseReportingPlugin.cs` — Plugin base classes
56+
- `DevProxy/config/` — Example and default configs
57+
- `media/` — Branding assets
58+
- `scripts/` — Local build/setup scripts
59+
60+
## External Dependencies
61+
- [svrooij/unobtanium-web-proxy](https://github.com/svrooij/unobtanium-web-proxy) — Core proxy engine (fork of Titanium.Web.Proxy)
62+
- Microsoft.Extensions.* — Logging, configuration, DI
63+
- System.CommandLine — CLI framework
64+
65+
## Examples
66+
- To add a new plugin, inherit from `BasePlugin` or `BaseReportingPlugin`, implement `IPlugin`, and register it in the config file under `plugins`.
67+
- To add a new CLI command, implement a `Command` in `DevProxy/Commands/` and register it in `DevProxyCommand.cs`.
68+
69+
## Resources
70+
- [Official documentation](https://aka.ms/devproxy)
71+
- [YouTube channel](https://youtube.com/@devproxy)
72+
73+
---
74+
75+
*Update this file as project conventions evolve. For questions, see the README or open an issue.*

0 commit comments

Comments
 (0)