Skip to content

Commit 2aa8c5a

Browse files
committed
refactor: consolidate command and diagnostic constants into a single file, update imports across the codebase
1 parent d94de39 commit 2aa8c5a

22 files changed

Lines changed: 97 additions & 68 deletions

AGENTS.md

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,18 @@ This file provides instructions for AI coding assistants (GitHub Copilot, Claude
88
src/
99
├── commands/ # Add new commands here (one file per feature group)
1010
├── services/ # Business logic, API clients
11-
├── constants/ # All IDs, keys, URLs (commands.ts)
1211
├── data/ # Plugin metadata (plugins.json) - edit JSON, not code
13-
├── utils/ # Pure helper functions
12+
├── utils/ # Pure helper functions + getDiagnosticCode, getSchemaUrl
1413
├── test/ # Tests split by domain (*.test.ts)
14+
├── constants.ts # All IDs, keys, URLs
1515
└── *.ts # Core extension modules
1616
```
1717

1818
## Common Tasks
1919

2020
### Adding a New Command
2121

22-
1. **Register the command ID** in `src/constants/commands.ts`:
22+
1. **Register the command ID** in `src/constants.ts`:
2323
```typescript
2424
export const Commands = {
2525
// ... existing
@@ -38,6 +38,8 @@ src/
3838

3939
3. **Create/update command file** in `src/commands/`:
4040
```typescript
41+
import { Commands } from '../constants';
42+
4143
export function registerMyCommands(context: vscode.ExtensionContext) {
4244
context.subscriptions.push(
4345
vscode.commands.registerCommand(Commands.MY_NEW_COMMAND, async () => {
@@ -72,7 +74,7 @@ src/
7274

7375
### Adding a Diagnostic
7476

75-
1. Add diagnostic code to `DiagnosticCodes` in `src/constants/commands.ts`
77+
1. Add diagnostic code to `DiagnosticCodes` in `src/constants.ts`
7678
2. Add diagnostic creation in `src/diagnostics.ts`
7779
3. Add code action (quick fix) in `src/code-actions.ts`
7880
4. Add test in `src/test/schema.test.ts` or `src/test/plugins.test.ts`
@@ -86,8 +88,8 @@ src/
8688
### Imports
8789
- Use barrel exports from `index.ts` files:
8890
```typescript
89-
import { Commands, DiagnosticCodes } from './constants';
90-
import { DevProxyApiClient } from './services';
91+
import { Commands, DiagnosticCodes } from '../constants';
92+
import { getDiagnosticCode, getSchemaUrl } from '../utils';
9193
```
9294

9395
### Testing
@@ -115,7 +117,7 @@ src/
115117
| File | Purpose |
116118
|------|---------|
117119
| `src/extension.ts` | Entry point, activation |
118-
| `src/constants/commands.ts` | All command IDs, context keys, URLs |
120+
| `src/constants.ts` | All command IDs, context keys, URLs |
119121
| `src/data/plugins.json` | Plugin metadata (editable without code) |
120122
| `src/services/api-client.ts` | All Dev Proxy HTTP API calls |
121123
| `src/test/helpers.ts` | Test utilities, mock factories |

src/commands/config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import * as vscode from 'vscode';
2-
import { Commands } from '../constants/commands';
2+
import { Commands } from '../constants';
33
import { executeCommand } from '../utils/shell';
44
import { getDevProxyExe } from '../detect';
55
import { VersionPreference } from '../enums';

src/commands/discovery.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import * as vscode from 'vscode';
2-
import { Commands } from '../constants/commands';
2+
import { Commands } from '../constants';
33
import { TerminalService } from '../services/terminal';
44
import { getDevProxyExe } from '../detect';
55
import { VersionPreference } from '../enums';

src/commands/docs.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import * as vscode from 'vscode';
2-
import { Commands } from '../constants/commands';
2+
import { Commands } from '../constants';
33
import { pluginDocs } from '../data';
44
import parse from 'json-to-ast';
55
import { getASTNode, getRangeFromASTNode } from '../utils/ast';

src/commands/install.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import * as vscode from 'vscode';
2-
import { Commands, Urls } from '../constants/commands';
2+
import { Commands, Urls } from '../constants';
33
import {
44
executeCommand,
55
getPackageIdentifier,

src/commands/jwt.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import * as vscode from 'vscode';
2-
import { Commands } from '../constants/commands';
2+
import { Commands } from '../constants';
33
import { executeCommand } from '../utils/shell';
44
import { getDevProxyExe } from '../detect';
55
import { VersionPreference } from '../enums';

src/commands/proxy.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import * as vscode from 'vscode';
2-
import { Commands, ContextKeys } from '../constants/commands';
2+
import { Commands, ContextKeys } from '../constants';
33
import { DevProxyApiClient } from '../services/api-client';
44
import { TerminalService } from '../services/terminal';
55
import { isConfigFile } from '../utils';

src/commands/recording.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import * as vscode from 'vscode';
2-
import { Commands, ContextKeys } from '../constants/commands';
2+
import { Commands, ContextKeys } from '../constants';
33
import { DevProxyApiClient } from '../services/api-client';
44

55
/**
Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -88,23 +88,3 @@ export const Urls = {
8888
schemaBase: 'https://raw.githubusercontent.com/dotnet/dev-proxy/main/schemas',
8989
diagnosticsDoc: 'https://learn.microsoft.com/microsoft-cloud/dev/dev-proxy/technical-reference/toolkit-diagnostics',
9090
} as const;
91-
92-
/**
93-
* Get a diagnostic code object with a clickable documentation link.
94-
* @param code The diagnostic code from DiagnosticCodes
95-
* @returns An object with value and target for VS Code diagnostic code
96-
*/
97-
export function getDiagnosticCode(code: string): { value: string; target: import('vscode').Uri } {
98-
const vscode = require('vscode');
99-
return {
100-
value: code,
101-
target: vscode.Uri.parse(`${Urls.diagnosticsDoc}#${code.toLowerCase()}`),
102-
};
103-
}
104-
105-
/**
106-
* Build a schema URL for a specific version.
107-
*/
108-
export function getSchemaUrl(version: string): string {
109-
return `${Urls.schemaBase}/v${version}/rc.schema.json`;
110-
}

src/constants/index.ts

Lines changed: 0 additions & 5 deletions
This file was deleted.

0 commit comments

Comments
 (0)