microsoft/qdk

Public

mirrored fromhttps://github.com/microsoft/qdkAvailable

CodeCommitsIssuesPull requestsActionsInsightsSecurity
1365fba5cb78ce29bb89f92fea9c0419a3a85a14

Branches

Tags

  • No tags available.
0Branches0Tags
Go to file
Add file
Code

Clone

HTTPS

Download ZIP

.github/copilot-instructions.md

105lines · modecode

1# Copilot instructions for the `qsharp` repo
2
3## Overview
4
5This repo contains the Microsoft Quantum Development Kit (QDK), which provides tooling for the Q# language. Q# is an open-source programming language designed for developing and running quantum algorithms. This repo is publicly available at https://github.com/microsoft/qsharp .
6
7
8## Architecture
9
10All internal source code for the compiler and related tooling has been moved under the `source/` directory at the repository root. This does not include Q# libraries (`library/`), samples (`samples/`), katas (`katas/`), or any standard files and folders typically found at the root of a repository (such as configuration, documentation, or build scripts).
11
12Most of the core components are implemented in Rust. These components are packaged in two ways:
13
141. Compiled as a native Python module and packaged into the `qsharp` Python package
152. Compiled into WebAssembly and packaged into the `qsharp-lang` npm package
16
17## Repo Contents
18
19**Rust**
20
21- **allocator/**: A copy of `mimalloc`, used for memory allocation in the Rust components of the QDK
22- **compiler/**: Core compiler and language processing components
23 - **qsc/**: Core compiler logic
24 - **qsc_ast/**: Abstract syntax tree definition and utilities
25 - **qsc_circuit/**: Circuit diagram representation and generation
26 - **qsc_codegen/**: Code generation utilities (QIR, Q#)
27 - **qsc_data_structures/**: Common data structures used by the compiler
28 - **qsc_doc_gen/**: Documentation generation tools
29 - **qsc_eval/**: Runtime evaluation and simulation
30 - **qsc_fir/**: Flat IR
31 - **qsc_formatter/**: Q# code formatter
32 - **qsc_frontend/**: Compiler frontend components
33 - **qsc_hir/**: High-level Intermediate Representation
34 - **qsc_linter/**: Code quality and style checking
35 - **qsc_lowerer/**: IR lowering transformations
36 - **qsc_parse/**: Q# parser
37 - **qsc_partial_eval/**: Partial evaluation and optimization
38 - **qsc_passes/**: HIR passes
39 - **qsc_project/**: Project system and manifest handling
40 - **qsc_qasm/**: OpenQASM compiler frontend
41 - **qsc_rca/**: Resource counting and analysis
42 - **qsc_rir/**: Runtime Intermediate Representation
43- **fuzz/**: Fuzz testing infrastructure for the compiler
44- **language_service/**: Q# language service for editor features
45- **noisy_simulator/**: Simulator for quantum noise modeling
46- **resource_estimator/**: Quantum Resource Estimator implementation
47- **wasm/**: WebAssembly bindings for core components
48
49**Build & Release**
50- **docker/**: Docker container configurations
51
52**Python**
53
54- **pip/**: The `qsharp` Python package
55- **jupyterlab/**: JupyterLab extension for Q#
56- **widgets/**: Q# Jupyter widgets
57
58**Q# Content**
59
60- **katas/**: Quantum computing tutorials and exercises
61- **library/**: Q# standard and domain-specific libraries
62 - **chemistry/**: Chemistry-specific quantum operations
63 - **core/**: Q# core library
64 - **fixed_point/**: Fixed-point arithmetic support
65 - **qtest/**: Testing utilities
66 - **rotations/**: Quantum rotation operations
67 - **signed/**: Signed arithmetic operations
68 - **std/**: Q# standard library
69- **samples/**: Example Q# programs demonstrating language features
70- **samples_test/**: Tests for sample code
71
72**JavaScript/TypeScript**
73
74- **npm/**: The `qsharp-lang` npm package
75- **playground/**: Q# Playground website
76- **vscode/**: Visual Studio Code extension for Q#
77 - **src/**: Product source
78 - **test/**: Integration tests
79
80## Development Workflow
81
82- `./build.py` runs full CI checks, including lints and unit tests.
83- `./build.py --wasm --npm --vscode` only builds the VS Code extension, including its dependencies the WASM module and the `qsharp-lang` npm package.
84- `./build.py --pip` only builds the `qsharp` Python package, including its native dependencies.
85- Pass `--no-check` to `./build.py`, in combination with any other command line options, to skip the lints and formatting checks.
86- When working in Rust parts of the codebase, using `cargo` commands is usually more efficient than building via `./build.py`.
87 - Many lints can be auto-fixed via `cargo clippy --fix`.
88- When working in JavaScript/TypeScript parts of the codebase, using `npm` scripts is usually more efficient than building via `./build.py`.
89
90## Coding Standards
91
92- When adding new tests, follow the patterns established in existing tests in the same file or suite. Often, tests will use helper functions for brevity and readability. Design your tests to reuse these helpers where possible.
93- Before opening a PR, ensure the following.
94 - Code **must** be formatted by running `cargo fmt` and `npm run prettier:fix`.
95 - `./build.py` without any command-line arguments **must** run without errors or warnings.
96
97## Specific Guidelines for Parts of the Codebase
98
99### VS Code Integration Tests (`vscode/test/`)
100
101- `npm test` from the `vscode/` directory runs the integration tests.
102 - `npm test -- --suite=language-service`: Run only the `language-service` test suite
103- Tests use the VS Code for Web testing framework (`@vscode/test-web`), which uses `playwright` under the covers to automate headless Chrome.
104- `mocha` interface is used to declare tests, `chai` for asserts. No mocking library is used. Do *not* add dependencies to the test suite.
105- Tests run in the real VS Code environment, in the extension host, which means they can directly interact with the VS Code API.
106