Contributing Guide
Relevant source files
The following files were used as context for generating this wiki page:
This guide provides instructions for contributing to Dyad, an early-stage AI-powered code editor. Given the project's rapid evolution, it's crucial to follow these guidelines to ensure contributions align with the project's design and user experience goals. Before starting work on a pull request, please open an issue to discuss the proposed changes.
Non-code contributions are also highly appreciated, including bug reports, feature requests, and participation in the Dyad subreddit. For a high-level overview of the project's design, contributors should consult the Architecture Guide and the Agent Architecture Guide.
Sources: CONTRIBUTING.md:3-14
Development Setup
To begin development, you must set up the local environment. Dyad is an Electron application, and the setup process involves installing dependencies, creating a necessary directory for the database, and applying database migrations.
The following diagram illustrates the setup workflow:
Sources: CONTRIBUTING.md:16-37
Setup Commands
The setup process is managed through npm scripts defined in package.json.
| Command | Description | Source |
|---|---|---|
npm install | Installs all project dependencies. | CONTRIBUTING.md:18 |
mkdir -p userData | Creates the userData directory required for the database. | CONTRIBUTING.md:23 |
npm run db:generate | Generates database migration files based on schema changes. | CONTRIBUTING.md:31 |
npm run db:push | Applies pending database migrations. | CONTRIBUTING.md:32 |
npm start | Runs the Electron application in development mode. | CONTRIBUTING.md:36 |
Sources: CONTRIBUTING.md:18-36, package.json
Coding Standards
The project enforces a consistent coding style through a formatter and linter, which are managed by Biome. It is highly recommended to set up the pre-commit hook, which automatically runs these tools before each commit.
To initialize the pre-commit hook, run the following command once in your repository:
npm run init-precommit
Sources: CONTRIBUTING.md:40-46, package.json
Biome Configuration
The Biome configuration in biome.json defines the formatting and linting rules. Key settings include:
| Setting | Value | Description |
|---|---|---|
formatter.enabled | true | Enables the code formatter. |
formatter.indentStyle | space | Uses spaces for indentation. |
formatter.indentWidth | 2 | Sets indentation width to 2 spaces. |
linter.enabled | true | Enables the code linter. |
linter.rules.recommended | true | Enables a set of recommended linting rules. |
Sources: biome.json:3-13
Testing
The project includes both unit and end-to-end (E2E) tests to ensure code quality and stability.
Test Commands
| Command | Description |
|---|---|
npm test | Runs the unit test suite. |
npm run pre:e2e | Builds the application specifically for E2E testing. This is only needed when app code changes, not test code. |
npm run e2e | Runs the entire E2E test suite. |
npm run e2e <test_file_path> | Runs a specific E2E test file. |
npm run e2e <test_file_path> -- --update-snapshots | Updates the snapshots for a specific E2E test. |
Sources: CONTRIBUTING.md:48-69, package.json
AI Interaction and Prompting
A core part of Dyad is its AI, whose behavior is governed by a series of system prompts. Contributions that affect the AI must adhere to these established patterns.
AI Chat Modes
The AI operates in several distinct modes, each with a specific system prompt that defines its role and capabilities. The constructSystemPrompt function selects the appropriate prompt based on the active chatMode.
This diagram shows how the constructSystemPrompt function dispatches to different prompt generation logic based on the chatMode.
Sources: src/prompts/system_prompt.ts:474-492
AI Commands (Dyad Tags)
The AI interacts with the application's backend and filesystem by emitting custom XML-like tags. Any code generation or file manipulation must use these tags. Markdown code blocks are strictly forbidden for code output.
| Tag | Description |
|---|---|
<dyad-write path="..." description="..."> | Creates or overwrites a file with the provided content. |
<dyad-rename from="..." to="..."> | Renames a file or directory. |
<dyad-delete path="..."> | Deletes a file or directory. |
<dyad-add-dependency packages="..."> | Adds one or more npm packages. |
<dyad-command type="..."> | Suggests a UI command for the user (e.g., rebuild, restart). |
<dyad-chat-summary> | Sets a concise summary for the current chat session. |
<dyad-security-finding title="..." level="..."> | Used in security review mode to report a vulnerability. |
Sources: src/prompts/system_prompt.ts:74-97, src/prompts/summarize_chat_system_prompt.ts:31-33, src/prompts/security_review_prompt.ts:16-21
Thinking Process
Before generating a response, the AI is instructed to use a <think> block to outline its plan. This structured thinking process ensures that all aspects of a user's request are considered. The process involves identifying the task, examining relevant code, diagnosing causes, and planning the approach.
Sources: src/prompts/system_prompt.ts:8-56
AI Rules
The AI's behavior regarding a specific application's tech stack is defined in an AI_RULES.md file within the user's project. The readAiRules function reads this file to provide context-specific rules to the AI. If the file doesn't exist, a default set of rules is used.
Sources: src/prompts/system_prompt.ts:494-504