AGENTS.md
AGENTS.mdAGENTS.mdroot
Quality
91/100
Scores the file, not the repository.Length
1,559 words
30 headings · 7 code blocksRepository
51k
— · pushed 0 days agoLast changed
3 days ago
First indexed 3 days ago.1# DBeaver – AI Agent Instructions23## What is DBeaver?45DBeaver Community Edition (CE) is a free, open-source, multi-platform database management tool written in **Java**. It supports 100+ database drivers out of the box and is built on **Eclipse RCP** with an **OSGi** plugin architecture. The commercial product shares the same model layer as DBeaver CE and the browser-based [CloudBeaver](https://github.com/dbeaver/cloudbeaver).67---89## Repository Layout1011```12dbeaver/13├── plugins/ # OSGi bundles (source code)14│ ├── org.jkiss.dbeaver.model/ # Core API interfaces (no UI, no JDBC)15│ ├── org.jkiss.dbeaver.model.jdbc/ # JDBC base implementations16│ ├── org.jkiss.dbeaver.model.sql/ # SQL model (dialect, LSM parser glue)17│ ├── org.jkiss.dbeaver.model.lsm/ # ANTLR4-based SQL parser18│ ├── org.jkiss.dbeaver.core/ # Desktop RCP application core19│ ├── org.jkiss.dbeaver.registry/ # Driver/connection registry20│ ├── org.jkiss.dbeaver.ext.{db}/ # Per-DB model plugin (no UI deps)21│ ├── org.jkiss.dbeaver.ext.{db}.ui/ # Per-DB UI plugin22│ ├── org.jkiss.dbeaver.ui.*/ # Shared UI components23│ └── org.jkiss.dbeaver.osgi.test.runner/ # OSGi JUnit 5 test harness24├── test/ # OSGi test plugins (eclipse-test-plugin packaging)25│ ├── org.jkiss.dbeaver.ext.{db}.test/26│ └── org.jkiss.dbeaver.model.sql.test/27├── features/ # Eclipse feature descriptors28├── product/ # Product configurations & aggregator POMs29│ └── aggregate/ # Top-level Maven build entry point30├── docs/31│ ├── codestyle/eclipse-formatter-profile.xml32│ ├── license_header.txt33│ └── devel.txt # Branch/process overview34├── pom.xml # Root Tycho Maven POM35└── project.deps # External dependency repo names (e.g. "dbeaver-common")36```3738The build depends on a sibling repository called **`dbeaver-common`** (must be checked out at `../dbeaver-common`).3940---4142## Technology Stack4344| Layer | Technology |45|-------|-----------|46| Language | Java 21 |47| Plugin system | OSGi / Eclipse Equinox |48| UI framework | Eclipse RCP (SWT + JFace) |49| Build system | Apache Maven + Eclipse Tycho |50| DB connectivity | JDBC; optional ODBC/NoSQL in EE |51| SQL parsing | JSQLParser, ANTLR4 (LSM module) |52| Testing | JUnit 5, Mockito, custom OSGi test runner |5354---5556## Build System5758DBeaver uses **Eclipse Tycho** (Maven plugin for OSGi). Each plugin is packaged as `eclipse-plugin`; test plugins as `eclipse-test-plugin`.5960### Building6162```bash63# Full build from the aggregator64mvn package -f product/aggregate/pom.xml -Pproduct-dbeaver-ce,product-dbeaver-eclipse-ce6566# Build only a single plugin (fast iteration)67mvn package -f plugins/org.jkiss.dbeaver.ext.mysql/pom.xml68```6970> **CI** runs the same command via the reusable workflow in `.github/workflows/push-pr-devel.yml`.7172### Plugin packaging rules7374- Every plugin has a `META-INF/MANIFEST.MF` (bundle metadata) and a `pom.xml` with `<packaging>eclipse-plugin</packaging>`.75- Dependencies between plugins are declared in `MANIFEST.MF` under `Require-Bundle:`, **not** in `pom.xml`.76- `plugin.xml` declares Eclipse extension points and extensions.77- All source is under `src/` (no `src/main/java`).7879---8081## Code Conventions8283### Package and class naming8485| Prefix | Meaning | Example |86|--------|---------|---------|87| `DBP*` | Platform-level capability | `DBPDataSource`, `DBPObject` |88| `DBS*` | Database structure/metadata | `DBSObject`, `DBSTable`, `DBSSchema` |89| `DBC*` | Connectivity (execution context) | `DBCSession`, `DBCException` |90| `DBD*` | Data values/formatting | `DBDValueHandler`, `DBDDataFilter` |91| `DBR*` | Runtime (progress, jobs) | `DBRProgressMonitor`, `DBRRunnableWithProgress` |92| `JDBC*`| JDBC-specific implementations | `JDBCDataSource`, `JDBCSQLDialect` |9394All production code lives in the `org.jkiss.dbeaver.*` namespace.9596### License header9798Every Java file **must** begin with:99100```java101/*102 * DBeaver - Universal Database Manager103 * Copyright (C) 2010-<year> DBeaver Corp and others104 *105 * Licensed under the Apache License, Version 2.0 (the "License");106 * ...107 */108```109110See `docs/license_header.txt` for the canonical template.111112### Annotations113114- Use `@NotNull` and `@Nullable` from `org.jkiss.code` on all method parameters and return types where applicable.115- Expose object properties to the UI via `@Property` (from `org.jkiss.dbeaver.model.meta`) on getter methods.116- Mark associations (child collections) with `@Association`.117- Use `@ForTest` on members that exist solely for unit-testing access.118119### Logging120121```java122private static final Log log = Log.getLog(MyClass.class);123// ...124log.debug("...");125log.warn("...", exception);126log.error("...", exception);127```128129`Log` is `org.jkiss.dbeaver.Log`. Do **not** use `System.out/err` or SLF4J directly.130131### Exception handling132133- `DBException` (and its subclasses like `DBCException`, `DBDatabaseException`) are the standard checked exceptions for database errors.134- Wrap JDBC `SQLException` in `DBException` when surfacing to upper layers.135- Use `DBWorkbench.getPlatform()` to access platform services (not static singletons passed around).136137### Progress monitoring138139Long-running operations always accept a `DBRProgressMonitor`:140141```java142public void doSomething(DBRProgressMonitor monitor) throws DBException {143 monitor.beginTask("Loading...", 100);144 try {145 // work146 monitor.worked(50);147 } finally {148 monitor.done();149 }150}151```152153Use `VoidProgressMonitor.INSTANCE` in tests when a real monitor is not needed.154155### NLS / Localization156157- Each plugin that has user-visible strings has a `*Messages.java` + `*Messages.properties` (and locale variants).158- Reference strings as `Messages.MY_STRING_KEY`.159- `plugin.xml` uses `%key` references to the `plugin.properties` file.160161---162163## Architecture Patterns164165### Model / UI separation166167Plugins are split into pure-model (`ext.mysql`) and UI (`ext.mysql.ui`) bundles. Model plugins **must not** import SWT, JFace, or Eclipse workbench packages. This separation allows the model layer to be reused in server-side products (CloudBeaver).168169### Extension-point driven design170171Features are contributed via Eclipse extension points declared in `plugin.xml`. Key extension points:172173| Extension point ID | Purpose |174|-------------------|---------|175| `org.jkiss.dbeaver.dataSourceProvider` | Register a new database driver/provider |176| `org.jkiss.dbeaver.navigator` (via tree config in plugin.xml) | Define the navigator tree structure for a database |177| `org.jkiss.dbeaver.service` | Register a service implementation |178| `org.jkiss.dbeaver.dataFormatter` | Register a data formatter |179| `org.jkiss.dbeaver.dataTypeProvider` | Register value handler for a SQL type |180181### Adding a new database driver182183> **Note**: For many drivers, updating `plugin.xml` alone is enough — you only need to implement Java classes when the existing JDBC infrastructure does not cover your use case.1841851. Create `plugins/org.jkiss.dbeaver.ext.{db}/` with `META-INF/MANIFEST.MF`, `plugin.xml`, and a `pom.xml` (`eclipse-plugin`).1862. Add an optionally-UI sibling `plugins/org.jkiss.dbeaver.ext.{db}.ui/`.1873. Implement `DBPDataSourceProvider<YourDataSource>` → register it in `plugin.xml` under `org.jkiss.dbeaver.dataSourceProvider`.1884. Implement `JDBCDataSource` (from `org.jkiss.dbeaver.model.jdbc`) for JDBC-based drivers.1895. Implement `SQLDialect` (or extend `JDBCSQLDialect`) for SQL syntax specifics.1906. Add the new plugin to `plugins/pom.xml` `<modules>` list.1917. Add a test plugin `test/org.jkiss.dbeaver.ext.{db}.test/` and register it in `test/pom.xml`.192193### JDBCUtils and result set reading194195The utility class `org.jkiss.dbeaver.model.impl.jdbc.JDBCUtils` (in `org.jkiss.dbeaver.model.jdbc` bundle) contains `safeGet*` helpers for reading from `ResultSet`/`JDBCResultSet` without checked exceptions:196197```java198String name = JDBCUtils.safeGetString(dbResult, "table_name");199long oid = JDBCUtils.safeGetLong(dbResult, "oid");200```201202---203204## Testing205206### Test structure207208- Test plugins are in the `test/` directory.209- Each test plugin mirrors a production plugin: `test/org.jkiss.dbeaver.ext.postgresql.test/`.210- Tests extend `DBeaverUnitTest` (from `org.jkiss.dbeaver.osgi.test.runner`) or use `@RunWithApplication`/`@RunWithProduct` annotations for integration tests that need a running OSGi container.211212### Running tests213214Tests are run by Maven Tycho as part of the standard build. There is no separate test-only Maven command; tests execute during `mvn package` (or `mvn verify`) when the `desktop` profile is active (it is active by default when `!headless-platform`).215216### Writing tests217218```java219import org.jkiss.junit.DBeaverUnitTest;220import org.junit.jupiter.api.Test;221import static org.junit.jupiter.api.Assertions.*;222223public class MyFeatureTest extends DBeaverUnitTest {224225 @Test226 public void shouldDoSomething() {227 // given228 var query = new SQLQuery(null, "SELECT 1");229 // then230 assertFalse(query.isDropDangerous());231 }232}233```234235Use Mockito for mocking. Common mocks: `DBRProgressMonitor`, `DBPDataSourceContainer`, `DBPDataSource`.236237---238239## Branches and Git Workflow240241- **`devel`** — the main development branch; all PRs must target this branch.242- **`master`** — inactive branch; do not use or commit to it.243- **Release branches** — exist for each release; never commit to them directly.244- Pull requests that only fix typos, formatting, or trivial refactoring are generally **not accepted** per the contributor guide.245- **Naming convention**: issues, commit messages, and PR titles should follow the format `org/repo#issueNumber title` (e.g., `dbeaver/dbeaver#12345 Fix NPE in PostgreSQL dialect`).246- **Branch naming**: branches should follow the format `org/project#issueNumber-issueTitle` (e.g., `dbeaver/dbeaver#12345-fix-npe-postgresql`).247- **Linking PRs to issues**: always link a pull request to its corresponding GitHub issue. Use the GitHub UI "Development" link on the PR sidebar when possible; if a direct link is not available, add `Closes org/project#issueNumber` in the PR description (e.g., `Closes dbeaver/dbeaver#12345`).248- **AI-generated PRs**: large pull requests that are entirely AI-generated are strongly discouraged. Keep AI-assisted contributions focused and small, and ensure each change is understood and reviewed by a human contributor.249- **AI tools disclosure**: if AI tools were used to generate code, mention it in the PR description. Example: *This PR was generated with AI (GitHub Copilot)*.250251---252253## Common Pitfalls / Known Issues2542551. **Build requires sibling `dbeaver-common`**: The root `pom.xml` references `../dbeaver-common/pom.xml` as its parent. Clone `dbeaver-common` alongside this repo before building.2562. **No `src/main/java`**: Sources live directly under `src/` (Tycho convention for OSGi plugins). Do not create Maven standard directory layout.2573. **Dependencies in `MANIFEST.MF`, not `pom.xml`**: Adding a dependency means editing `Require-Bundle:` in `META-INF/MANIFEST.MF`. Maven `<dependencies>` are only for Maven-only artifacts resolved via P2 (`pomDependencies=consider`).2584. **UI thread safety**: All SWT/UI updates must run on the display thread. Use `UIUtils.asyncExec(Runnable)` or `UIUtils.syncExec(Runnable)` (from `org.jkiss.dbeaver.ui`).2595. **`@Property` on getters only**: The `@Property` annotation is processed reflectively at runtime; it must be placed on the getter method, not the field.2606. **Java 21 required**: The target platform requires `JavaSE-21`. Do not use preview features.261262---263264## Key Files Quick Reference265266| File | Purpose |267|------|---------|268| `pom.xml` (root) | Tycho build configuration, Java version, target platforms |269| `plugins/pom.xml` | Aggregator listing all plugin modules |270| `test/pom.xml` | Aggregator listing all test modules |271| `product/aggregate/pom.xml` | Top-level build entry point used by CI |272| `plugins/org.jkiss.dbeaver.model/META-INF/MANIFEST.MF` | Core API bundle exports |273| `docs/license_header.txt` | Required license header for Java files |274| `docs/devel.txt` | Brief contributor workflow notes |275| `.github/workflows/push-pr-devel.yml` | CI: build on PR and push to `devel` |276277## Code Contribution Guide278279For detailed contribution instructions, see the [Code contribution guide](https://github.com/dbeaver/dbeaver/wiki/Contribute-your-code).280
Similar configs
Same format, overlapping stack, ranked by quality.
| Repository | Format | Stack | Covers | Score | Changed |
|---|---|---|---|---|---|
| trick77/agents-md-syncAGENTS.md · 2 | AGENTS.md | setupbuildteststyle+5 | 100/100 | 3 days ago | |
| SkeneTechnologies/skene-cookbookAGENTS.md · 51 | AGENTS.md | setupbuildtestlint-format+7 | 100/100 | 2 days ago | |
| duckduckgo/content-scope-scriptsspecial-pages/AGENTS.md · 70 | AGENTS.md | buildteststylearch+3 | 100/100 | 3 days ago | |
| wpscanteam/wpscanAGENTS.md · 9.7k | AGENTS.md | setupbuildteststyle+6 | 100/100 | 2 days ago | |
| OnlyTerp/prompt-cache-skillsAGENTS.md · 112 | AGENTS.md | setupbuildtestlint-format+5 | 100/100 | 3 days ago | |
| mui/material-uiAGENTS.md · 99k | AGENTS.md | setupbuildtestlint-format+9 | 100/100 | 3 days ago | |
| n8n-io/n8npackages/@n8n/agents/AGENTS.md · 199k | AGENTS.md | buildteststylearch+3 | 100/100 | 3 days ago | |
| aaif-goose/gooseAGENTS.md · 52k | AGENTS.md | setupbuildtestlint-format+6 | 100/100 | 3 days ago |
