From b0ecd0bfb7d8e05ef4121ef912f8e34ac2b0c4e7 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 27 Feb 2026 15:22:09 +0000 Subject: [PATCH 1/4] Initial plan From 660bef1775d4f118be38360139448689c74df437 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 27 Feb 2026 15:27:15 +0000 Subject: [PATCH 2/4] feat: support passing environment variables when starting Dev Proxy Co-authored-by: garrytrinder <11563347+garrytrinder@users.noreply.github.com> --- README.md | 17 +++++++++++++++++ package.json | 15 +++++++++++++++ src/services/terminal.ts | 15 ++++++++++++++- src/task-provider.ts | 9 +++++++-- src/test/task-provider.test.ts | 22 +++++++++++++++++++++ src/test/terminal.test.ts | 35 ++++++++++++++++++++++++++++++++++ 6 files changed, 110 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 58d2f09..bb54644 100644 --- a/README.md +++ b/README.md @@ -227,6 +227,7 @@ You can also manually add the extension to recommendations at any time using the | `dev-proxy-toolkit.closeTerminal` | `boolean` | `true` | Close terminal when stopping | | `dev-proxy-toolkit.apiPort` | `number` | `8897` | Port for Dev Proxy API communication | | `dev-proxy-toolkit.devProxyPath` | `string` | `""` | Custom path to Dev Proxy executable (uses auto-detection if empty) | +| `dev-proxy-toolkit.env` | `object` | `{}` | Environment variables to set when starting Dev Proxy | ## Tasks @@ -255,6 +256,22 @@ Run Dev Proxy as a VS Code task for integration with build workflows. } ``` +You can pass environment variables to Dev Proxy using the `env` property: + +```json +{ + "label": "Start Dev Proxy", + "type": "devproxy", + "command": "start", + "env": { + "NODE_ENV": "development", + "DEBUG": "true" + }, + "isBackground": true, + "problemMatcher": "$devproxy-watch" +} +``` + ## MCP Server This extension includes an MCP server for AI-assisted development. See [Dev Proxy MCP Server](https://github.com/dev-proxy-tools/mcp) for available tools. diff --git a/package.json b/package.json index d17d028..f756e0e 100644 --- a/package.json +++ b/package.json @@ -166,6 +166,13 @@ "type": "string" }, "description": "Additional command-line arguments" + }, + "env": { + "type": "object", + "additionalProperties": { + "type": "string" + }, + "description": "Environment variables to set when starting Dev Proxy" } } } @@ -219,6 +226,14 @@ "type": "string", "default": "", "description": "Custom path to the Dev Proxy executable. If empty, auto-detection is used." + }, + "dev-proxy-toolkit.env": { + "type": "object", + "additionalProperties": { + "type": "string" + }, + "default": {}, + "description": "Environment variables to set when starting Dev Proxy." } } }, diff --git a/src/services/terminal.ts b/src/services/terminal.ts index 2d9e6a5..6272b0a 100644 --- a/src/services/terminal.ts +++ b/src/services/terminal.ts @@ -10,11 +10,13 @@ export class TerminalService { private readonly createNewTerminal: boolean; private readonly showTerminal: boolean; private readonly closeTerminalOnStop: boolean; + private readonly env: { [key: string]: string } | undefined; constructor(config?: TerminalServiceConfig) { this.createNewTerminal = config?.createNewTerminal ?? true; this.showTerminal = config?.showTerminal ?? true; this.closeTerminalOnStop = config?.closeTerminalOnStop ?? true; + this.env = config?.env; } /** @@ -22,10 +24,12 @@ export class TerminalService { */ static fromConfiguration(): TerminalService { const config = vscode.workspace.getConfiguration('dev-proxy-toolkit'); + const env = config.get<{ [key: string]: string }>('env'); return new TerminalService({ createNewTerminal: config.get('newTerminal', true), showTerminal: config.get('showTerminal', true), closeTerminalOnStop: config.get('closeTerminal', true), + env: env && Object.keys(env).length > 0 ? env : undefined, }); } @@ -41,7 +45,15 @@ export class TerminalService { return vscode.window.activeTerminal; } - const terminal = vscode.window.createTerminal('Dev Proxy'); + const terminalOptions: vscode.TerminalOptions = { + name: 'Dev Proxy', + }; + + if (this.env) { + terminalOptions.env = this.env; + } + + const terminal = vscode.window.createTerminal(terminalOptions); if (this.showTerminal) { terminal.show(); @@ -79,4 +91,5 @@ export interface TerminalServiceConfig { createNewTerminal?: boolean; showTerminal?: boolean; closeTerminalOnStop?: boolean; + env?: { [key: string]: string }; } diff --git a/src/task-provider.ts b/src/task-provider.ts index bc36a89..87d92c9 100644 --- a/src/task-provider.ts +++ b/src/task-provider.ts @@ -7,6 +7,7 @@ interface DevProxyTaskDefinition extends vscode.TaskDefinition { command: 'start' | 'stop'; configFile?: string; args?: string[]; + env?: { [key: string]: string }; label?: string; } @@ -68,9 +69,13 @@ export class DevProxyTaskProvider implements vscode.TaskProvider { if (definition.command === 'start') { const args = this.buildArgumentsFromDefinition(definition); - execution = new vscode.ShellExecution(this.devProxyExe, args, { + const shellOptions: vscode.ShellExecutionOptions = { cwd: '${workspaceFolder}' - }); + }; + if (definition.env && Object.keys(definition.env).length > 0) { + shellOptions.env = definition.env; + } + execution = new vscode.ShellExecution(this.devProxyExe, args, shellOptions); } else if (definition.command === 'stop') { // Use curl to stop Dev Proxy via API const configuration = vscode.workspace.getConfiguration('dev-proxy-toolkit'); diff --git a/src/test/task-provider.test.ts b/src/test/task-provider.test.ts index 3d90795..5286981 100644 --- a/src/test/task-provider.test.ts +++ b/src/test/task-provider.test.ts @@ -161,6 +161,28 @@ suite('DevProxyTaskProvider', () => { assert.ok(resolved, 'Should resolve task with args'); }); + + test('should handle env in definition', () => { + const provider = new DevProxyTaskProvider(mockContext); + + const taskDefinition = { + type: 'devproxy', + command: 'start' as const, + env: { 'NODE_ENV': 'test', 'DEBUG': 'true' }, + label: 'Start with Env', + }; + + const mockTask = new vscode.Task( + taskDefinition, + vscode.TaskScope.Workspace, + 'Start with Env', + 'devproxy' + ); + + const resolved = provider.resolveTask(mockTask); + + assert.ok(resolved, 'Should resolve task with env'); + }); }); suite('task properties', () => { diff --git a/src/test/terminal.test.ts b/src/test/terminal.test.ts index 0ab9b01..9700174 100644 --- a/src/test/terminal.test.ts +++ b/src/test/terminal.test.ts @@ -111,6 +111,41 @@ suite('TerminalService', () => { assert.ok((mockTerminal.hide as sinon.SinonStub).calledOnce); assert.ok((mockTerminal.show as sinon.SinonStub).notCalled); }); + + test('should pass env to terminal when env is provided', () => { + const mockTerminal = { + show: sandbox.stub(), + hide: sandbox.stub(), + name: 'Dev Proxy', + } as unknown as vscode.Terminal; + + const createStub = sandbox.stub(vscode.window, 'createTerminal').returns(mockTerminal); + + const env = { 'NODE_ENV': 'test', 'DEBUG': 'true' }; + const service = new TerminalService({ createNewTerminal: true, showTerminal: true, env }); + service.getOrCreateTerminal(); + + assert.ok(createStub.calledOnce); + const options = createStub.firstCall.args[0] as vscode.TerminalOptions; + assert.deepStrictEqual(options.env, env, 'Should pass env to terminal options'); + }); + + test('should not include env in terminal options when env is undefined', () => { + const mockTerminal = { + show: sandbox.stub(), + hide: sandbox.stub(), + name: 'Dev Proxy', + } as unknown as vscode.Terminal; + + const createStub = sandbox.stub(vscode.window, 'createTerminal').returns(mockTerminal); + + const service = new TerminalService({ createNewTerminal: true, showTerminal: true }); + service.getOrCreateTerminal(); + + assert.ok(createStub.calledOnce); + const options = createStub.firstCall.args[0] as vscode.TerminalOptions; + assert.strictEqual(options.env, undefined, 'Should not include env in terminal options'); + }); }); suite('disposeDevProxyTerminals', () => { From ecedc986af7c73afce36311fc55daabd4bfe4b95 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 27 Feb 2026 15:28:04 +0000 Subject: [PATCH 3/4] test: verify env is passed to ShellExecution in task provider test Co-authored-by: garrytrinder <11563347+garrytrinder@users.noreply.github.com> --- src/test/task-provider.test.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/test/task-provider.test.ts b/src/test/task-provider.test.ts index 5286981..e52a4e0 100644 --- a/src/test/task-provider.test.ts +++ b/src/test/task-provider.test.ts @@ -165,10 +165,11 @@ suite('DevProxyTaskProvider', () => { test('should handle env in definition', () => { const provider = new DevProxyTaskProvider(mockContext); + const env = { 'NODE_ENV': 'test', 'DEBUG': 'true' }; const taskDefinition = { type: 'devproxy', command: 'start' as const, - env: { 'NODE_ENV': 'test', 'DEBUG': 'true' }, + env, label: 'Start with Env', }; @@ -182,6 +183,8 @@ suite('DevProxyTaskProvider', () => { const resolved = provider.resolveTask(mockTask); assert.ok(resolved, 'Should resolve task with env'); + const execution = resolved!.execution as vscode.ShellExecution; + assert.deepStrictEqual(execution.options?.env, env, 'Should pass env to shell execution options'); }); }); From b127a3e78b73ea46e52cffa14c793ef67025542c Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 27 Feb 2026 21:15:20 +0000 Subject: [PATCH 4/4] docs: add changelog and readme updates for env variable support Co-authored-by: garrytrinder <11563347+garrytrinder@users.noreply.github.com> --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index a4f3930..87550ef 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Added: - Install: Added automated install and upgrade support for Linux using official setup scripts +- Setting: Added `env` setting to pass environment variables when starting Dev Proxy +- Task provider: Added `env` property to task definition for passing environment variables - Quick Fixes: Enable local language model fix now adds or updates `languageModel.enabled: true` for supported plugins only - Workspace: Added automatic prompt to recommend extension in `.vscode/extensions.json` when Dev Proxy config files are detected - Command: Added `Add to Workspace Recommendations` to manually add extension to workspace recommendations