vscode-powerquery-sdk
Copilot instructions92 starsChanged 4 years agoMITView on GitHub
This repository contains the VS Code extension for the "Power Query Connector SDK". This document provides context to help GitHub Copilot assist with development tasks, particularly converting test frameworks and creating regression tests. Required Process: - Plan First: When given a complex task, before changing any code, analyze the task and then create a *.task.md to describe step by step how you will implement the task. Ask the user to review the plan. Revise the plan based on feedback. -…
- Installs packages
The file
Show its rules and text
We split this copilot-instructions.md into the rules it gives an agent
22 rules. About 0 are common, 16 are distinctive, and 6 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈16
Distinctive · estimate
This author's own choices. Worth a look.
6
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 7
If you're unsure about any aspect or if the task lacks necessary information, say "I don’t have enough information to confidently assess …
- Very specific: line 12
When given a complex task, before changing any code, analyze the task and then create a *.task.md to describe step by step how you will …
- Distinctive: line 15
Wait for Approval: Do not start coding until the user explicitly says "Execute the task"
- Very specific: line 17
When executing the tasks, use copilot-journal.md to track progress and decisions.
- Distinctive: line 18
Test After Each Change: Run tests to verify functionality
- Distinctive: line 19
Stop when Stuck: If you hit a roadblock, such as syntax error, test failures, update the journal, stop and ask for help
- Distinctive: line 21
Simple Completion: When done, just say "I'm done" (no summary needed)
- Very specific: line 23
When you finish a task related to an end user feature, update the CHANGELOG.md file with a summary of changes.
- Distinctive: line 198
Test against multiple NuGet package versions
- Very specific: line 234
Test files: *.test.ts (new framework), *.spec.ts (old framework)
- Distinctive: line 258
Test execution and VS Code extension packaging
- Distinctive: line 308
Always run commands from root unless specifically working on webview UI
- Distinctive: line 317
pqtest.exe not found: - Check NuGet package download and extraction
- Distinctive: line 321
Webview build failures: - Ensure both root and webview dependencies are installed
- Very specific: line 326
Missing webview assets: - Run npm run build from root to build webview
- Very specific: line 327
Development workflow: - Use npm start in webview directory for hot reload during UI development
- Distinctive: line 341
Test environments should use mock/test credentials
- Distinctive: line 342
Avoid storing real connection strings in test files
- Distinctive: line 350
Test Environment: All test environments must be Windows-based
- Distinctive: line 351
CI/CD Pipelines: Must use Windows runners/agents
- Distinctive: line 357
No cross-platform abstraction needed for core functionality
- Distinctive: line 399
Limited Unit Coverage: Only basic utility functions currently tested
≈ “Common” is an estimate: at least 1 in 5 of the 1,644 Copilot instructions files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Copilot Instructions for Power Query Connector SDK Extension
This repository contains the VS Code extension for the "Power Query Connector SDK". This document provides context to help GitHub Copilot assist with development tasks, particularly converting test frameworks and creating regression tests.
![!IMPORTANT] You are allowed to ask questions. If you're unsure about any aspect or if the task lacks necessary information, say "I don’t have enough information to confidently assess this."
Required Process:
- Plan First:
When given a complex task, before changing any code, analyze the task and then create a
*.task.mdto describe step by step how you will implement the task. Ask the user to review the plan. Revise the plan based on feedback. - Wait for Approval: Do not start coding until the user explicitly says "Execute the task"
- Checkpoint Journal
When executing the tasks, use
copilot-journal.mdto track progress and decisions. - Test After Each Change: Run tests to verify functionality
- Stop when Stuck: If you hit a roadblock, such as syntax error, test failures, update the journal, stop and ask for help
- Update Journal: Mark checkpoints as complete
- Simple Completion: When done, just say "I'm done" (no summary needed)
- Change log:
When you finish a task related to an end user feature, update the
CHANGELOG.mdfile with a summary of changes. Increase the patch version number by runningnpm version patchand commit the change. Include these steps when generating the task plan.
Project Overview
Extension Name: Power Query Connector SDK for Visual Studio Code
Publisher: PowerQuery
Extension ID: PowerQuery.vscode-powerquery-sdk
Purpose
This extension is used to create custom connectors for Power Query in Power BI. Power Query connectors are written in the M language. The extension provides:
- Project creation and management
- Building connector files (.mez)
- Credential management
- Query testing and evaluation
Dependencies
- Required Extension:
PowerQuery.vscode-powerquery- provides M language service - Core Tool: Microsoft.PowerQuery.SdkTools NuGet package containing:
pqtest.exe- M evaluation and testingpqservicehost.exe- service-based M evaluation (experimental)makepqx.exe- connector building utility
Architecture Overview
Key Components
- Extension Core (
src/extension.ts)- Main activation point
- Dependency injection setup
- Service initialization
- Testing Services
PqTestExecutableTaskQueue- Queue-based execution of pqtest.exePqServiceHostClient- RPC client for pqservicehost.exe (experimental)- Both implement
IPQTestServiceinterface
- Test Output Processing
- pqtest.exe outputs JSON to stdout
- Extension parses JSON and displays in webview
- Results shown in
PQTest resulttab
- Configuration
- Extension settings in
package.jsonundercontributes.configuration - User settings validation via
schemas/UserSettings.schema.json
- Extension settings in
Current Testing Structure
Test Directories
unit-tests/- Standard unit tests using Mocha- Tests utility classes and business logic
- Run with:
npm run test:unit-test
src/test/suite/- UI tests using@vscode/test-electronframework- Files:
extension.test.ts,project.test.ts,schema.test.ts - Uses
.vscode-test.mjsconfiguration - Clean test environment with dependency extensions
- Files:
src/test/commonSuite/- UI tests usingvscode-extension-testerframework- Files:
NewProject.spec.ts,PqSdkToolAcquisition.spec.ts - Legacy framework that needs migration
- Uses
scripts/test-e2e.tsfor execution
- Files:
Test Utilities (src/test/utils/)
editorUtils.ts- VS Code editor interactionssettingUtils.ts- Extension settings managementsideBarUtils.ts- Sidebar/tree view interactionsconnectorProjects.ts- Project creation helperspqSdkNugetPackageUtils.ts- NuGet package verification
pqtest.exe Integration
JSON Output Format
pqtest.exe operations return JSON to stdout with structures like:
interface GenericResult {
// Basic operation results
}
interface ExtensionInfo {
// Connector metadata from "info" operation
Members: Array<{
Name: string;
FunctionParameters?: Array<...>;
// ... other metadata
}>;
}
interface Credential {
// Authentication information from "list-credential"
}Key Operations
info- Get connector metadatarun-test- Execute M query, returns evaluation resulttest-connection- Test connector connectivitylist-credential- List stored credentialsset-credential- Store authentication datadelete-credential- Remove credentials
Command Line Usage
PQTest.exe <operation> --extension <connector.mez> --queryFile <query.pq> [options]Test Settings Schema
- Files ending in
.testsettings.jsonvalidated againstschemas/UserSettings.schema.json - Contains test configuration like authentication, data source paths, environment settings
- Used with
--settingsFileparameter
Migration Task Context
Current State
vscode-extension-testertests insrc/test/commonSuite/- Uses Selenium WebDriver for UI automation
- Complex setup with Chrome WebDriver downloads
- Flaky due to timing issues and external dependencies
Target State
- Migrate to
@vscode/test-electronframework - Native VS Code testing without browser automation
- More reliable and faster execution
- Consistent with
src/test/suite/pattern
Key Differences
// vscode-extension-tester (old)
import { Workbench, EditorView, SideBarView } from "vscode-extension-tester";
const workbench = new Workbench();
await workbench.executeCommand("command.id");
// @vscode/test-electron (new)
import * as vscode from "vscode";
await vscode.commands.executeCommand("command.id");Regression Testing Context
Purpose
Detect breaking changes in Microsoft.PowerQuery.SdkTools NuGet package versions that could affect:
- JSON output format changes
- New/removed command line options
- Behavioral differences in M evaluation
Test Strategy
- Golden File Approach
- Capture known-good JSON outputs for each pqtest.exe operation
- Store in
src/test/fixtures/or similar - Compare current output against golden files
- Test Operations to Cover
infooperation with sample connectorrun-testwith various M expressionslist-credential,set-credentialoperations- Error conditions and edge cases
- Version Management
- Test against multiple NuGet package versions
- Configurable version ranges in tests
- CI/CD integration for new version validation
Sample Test Structure
describe("PQTest Regression Tests", () => {
test("info operation output format", async () => {
const result = await pqTestService.DisplayExtensionInfo();
expect(result).toMatchSnapshot("info-output.json");
});
test("run-test operation basic query", async () => {
const result = await pqTestService.RunTestBattery("simple.query.pq");
expect(result).toHaveProperty("Output");
expect(result.Output).toBeDefined();
});
});File Patterns and Conventions
Important File Types
*.pq- M language query files*.mez- Compiled connector files*.testsettings.json- Test configuration files*.query.pq- Query files for testing*.proj,*.mproj- MSBuild project filespackage.json- Extension dependencies (root) and webview dependencies (webviews/)webpack.config.js- Extension bundling configurationwebviews/pq-test-result-view/config/webpack.*.js- Webview bundling configuration
Naming Conventions
- Test files:
*.test.ts(new framework),*.spec.ts(old framework) - Utility modules:
*Utils.ts - Service classes:
*Service.ts,*Client.ts - Configuration:
*Configuration.ts
Key Constants
// From src/constants/PowerQuerySdkExtension.ts
const PqTestExecutableName = "PQTest.exe";
const InternalMsftPqSdkToolsNugetName = "Microsoft.PowerQuery.SdkTools";
const SuggestedPqTestNugetVersion = "2.139.3";
const MaximumPqTestNugetVersion = "2.146.x";Project Structure and Build System
Dual Package Architecture
This project uses a dual package.json structure:
- Root package.json (
/package.json)- Main extension dependencies and scripts
- TypeScript compilation and bundling via Webpack
- Test execution and VS Code extension packaging
- Manages the core extension functionality
- Webview package.json (
/webviews/pq-test-result-view/package.json)- React-based webview for displaying pqtest results
- Separate build system with Babel/Webpack
- FluentUI components for VS Code-consistent UI
- Builds to
/webviewDist/pq-test-result-view/
Build Dependencies
- Root extension depends on webview build completion
postinstallscript automatically installs webview dependenciesbuildscript in root calls webview build process- Webview has separate dev server for standalone development
Common Commands and Tasks
Development
# Root level - Extension development
npm install # Install dependencies (includes webview)
npm run compile # Compile TypeScript extension code
npm run watch # Watch mode compilation
npm run package # Build VSIX package (includes webview build)
# Webview development (in webviews/pq-test-result-view/)
npm start # Start webview dev server on localhost:3001
npm run build # Build webview for production
npm run clean # Clean webview build artifactsTesting
npm test # Run all tests
npm run test:unit-test # Unit tests only
npm run test:e2e # UI Tests with @vscode/test-electron
npm run test:e2e:old # UI Tests with vscode-extension-testerExtension Tasks
- "Watch_VSC_PQ_SDK" - Development build task
- "Run Extension Tests" - E2E test execution
- "Dev_PQTest_Result_WebView" - Webview development
Important Build Notes
- Always run commands from root unless specifically working on webview UI
- The webview is built into the extension bundle during packaging
- For webview changes, test both standalone (npm start) and integrated modes
- Extension activation loads the built webview from
/webviewDist/
Troubleshooting Notes
Common Issues
- pqtest.exe not found - Check NuGet package download and extraction
- JSON parsing errors - pqtest.exe output might contain non-JSON content
- Timing issues - UI tests need proper delays for async operations
- Credential management - Tests may need to clear/reset credentials between runs
- Webview build failures - Ensure both root and webview dependencies are installed
- React/TypeScript version conflicts - Webview uses React 17, extension uses different TS/Node versions
Build System Issues
- Missing webview assets - Run
npm run buildfrom root to build webview - Development workflow - Use
npm startin webview directory for hot reload during UI development - Extension packaging - Webview must be built before creating VSIX package
Debug Configuration
- VS Code launch configs for debugging extension
- Debug adapter for M language debugging
- Output channel: "Power Query SDK" for extension logs
- Webview dev server runs on localhost:3001 for standalone testing
Security Considerations
- Credential storage in
%LOCALAPPDATA%/Microsoft/pqtest - Extension handles sensitive authentication data
- Test environments should use mock/test credentials
- Avoid storing real connection strings in test files
Platform Requirements
Windows-Only Dependencies
Important: The Microsoft.PowerQuery.SdkTools NuGet package is Windows-only. This affects all development and testing:
- Test Environment: All test environments must be Windows-based
- CI/CD Pipelines: Must use Windows runners/agents
- Local Development: Developers must use Windows machines
- pqtest.exe: Core testing executable only available on Windows
Development Implications
- No cross-platform abstraction needed for core functionality
- Can assume Windows file system behavior and path conventions
- Process execution can use Windows-specific patterns
- File paths can use Windows-style separators consistently
Testing Strategy and Framework Migration
Test Framework Hierarchy
The project is migrating from vscode-extension-tester to @vscode/test-electron with a unit-first testing philosophy:
Test Priority Order:
- Unit Tests (80% target): Pure business logic, validation, data transformations
- Service Tests: Single service with mocked dependencies
- Integration Tests (15% target): Multiple services working together
- UI Integration Tests (5% target): VS Code API interactions (minimal, focused)
External Dependencies Testing
Tests requiring external connections must be tagged with [External] for conditional execution:
describe("NuGet Package Service [External]", () => {
it("should download latest SDK tools", async () => {
// Test that requires internet access
});
});Build Environment Support:
- Local development:
npm run test:unit-test(includes external tests) - PR builds:
npm run test:unit-test(includes external tests) - Release builds:
npm run test:unit-test:no-external(excludes external tests)
Refactoring for Testability
Current codebase has testability issues that should be addressed:
- Monolithic Classes:
LifecycleCommands(~1,500 lines) needs service extraction - Hard-to-Test Dependencies: Direct VS Code API calls embedded in business logic
- Limited Unit Coverage: Only basic utility functions currently tested
Recommended Abstractions:
IFileSystem- Abstract file operations for testingIUIService- Abstract VS Code UI interactionsIPQTestService- Already exists, good example- Extract validation functions into pure, testable functions
Test Organization
tests/
├── unit/ # Pure unit tests (no external deps)
│ ├── validation/ # Pure validation functions
│ ├── utils/ # Utility functions
│ └── services/ # Service classes with mocks
├── integration/ # Service interaction tests
│ └── commands/ # Command workflow tests
└── vscode/ # VS Code API integration tests
└── CommandRegistration.test.tsDoes it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

