Skip to content

Commit a1da2d1

Browse files
dev: add AGENTS.md
1 parent d8e0b4f commit a1da2d1

2 files changed

Lines changed: 82 additions & 1 deletion

File tree

.distignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,4 +30,5 @@ docker-compose.ci.yml
3030
CONTRIBUTING.md
3131
artifacts
3232
phpstan.neon
33-
phpstan-baseline.neon
33+
phpstan-baseline.neon
34+
AGENTS.md

AGENTS.md

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
# Agent Workflow
2+
3+
## Project Overview
4+
5+
Visualizer is a WordPress plugin for creating interactive charts and tables. It uses Google Visualization API, Chart.js, and DataTables.net as rendering libraries. Charts are stored as a custom post type (`visualizer`) with post meta prefixed `visualizer-*`. The plugin has both a classic PHP/jQuery dashboard editor and a React-based Gutenberg block editor — changes to chart settings UI must be synchronized in both.
6+
7+
## Commands
8+
9+
### PHP
10+
```bash
11+
composer install # Install PHP dependencies
12+
composer lint # Run PHPCS (WordPress coding standards)
13+
composer format # Auto-fix PHPCS issues
14+
composer phpstan # Run PHPStan static analysis (level 6)
15+
./vendor/bin/phpunit # Run all PHPUnit tests
16+
./vendor/bin/phpunit tests/test-export.php # Run a single test file
17+
```
18+
19+
### Gutenberg Block (from `classes/Visualizer/Gutenberg/`)
20+
```bash
21+
npm install # Install JS dependencies
22+
npm run build # Production build
23+
npm run dev # Watch mode for development
24+
```
25+
26+
### E2E Tests & Environment
27+
```bash
28+
npm install # Install root JS dependencies (Playwright, etc.)
29+
npm run test:env:start # Start wp-env WordPress environment
30+
npm run test:env:stop # Stop wp-env
31+
npm run test:e2e:playwright # Run Playwright E2E tests
32+
npm run test:e2e:playwright:debug # Run Playwright tests with UI
33+
```
34+
35+
## Architecture
36+
37+
### Module System
38+
The plugin uses a module-based architecture rooted in `classes/Visualizer/`. Each module extends `Visualizer_Module`:
39+
40+
- **Module/Admin** — Admin dashboard, chart library page
41+
- **Module/Frontend** — Frontend rendering, shortcode handling, asset enqueueing
42+
- **Module/Chart** — Chart CRUD operations
43+
- **Module/Sources** — Data source management
44+
- **Module/Wizard** — First-time setup wizard
45+
- **Module/AMP** — AMP compatibility
46+
47+
### Data Flow
48+
1. Chart markup is placed on page via shortcode (`[visualizer id="123"]`) or Gutenberg block (`gutenberg_block_callback` in `Block.php`)
49+
2. Chart data is loaded into `window.visualizer` global object (also available via REST endpoint)
50+
3. `js/render-facade.js` scans for chart markup and dispatches rendering to the appropriate library
51+
4. Library-specific renderers: `js/render-google.js`, `js/render-chartjs.js`, `js/render-datatables.js`
52+
53+
### Two Editor Systems
54+
- **Classic editor**: PHP templates in `classes/Visualizer/Render/` with jQuery interactions in `js/frame.js` and `js/library.js`
55+
- **Gutenberg block**: React components in `classes/Visualizer/Gutenberg/src/`, built with Webpack to `classes/Visualizer/Gutenberg/build/`
56+
57+
Import UI lives in `classes/Visualizer/Render/Layout.php` (classic) and `classes/Visualizer/Gutenberg/src/Components/Import` (Gutenberg).
58+
59+
### Data Sources
60+
Source handlers in `classes/Visualizer/Source/` parse CSV, JSON, database queries, and post meta. Sample data files are in `samples/`.
61+
62+
### Pro Version
63+
The plugin checks for a companion `visualizer-pro` plugin. Pro features (database import, WooCommerce reports, advanced chart types) are in the separate `visualizer-pro` repository at `inc/addon.php`.
64+
65+
## Key Configuration
66+
- **Plugin constants and post type**: `classes/Visualizer/Plugin.php`
67+
- **Plugin entry point and autoloader**: `index.php`
68+
- **PHPCS rules**: `phpcs.xml` (WordPress-Core + WordPress-Docs)
69+
- **PHPStan**: `phpstan.neon` (level 6, baseline in `phpstan-baseline.neon`)
70+
- **Playwright config**: `tests/e2e/playwright.config.js`
71+
- **Semantic release**: `.releaserc.yml`
72+
73+
## Coding Standards
74+
- Follow WordPress Coding Standards (enforced by PHPCS)
75+
- PHP 7.4 minimum compatibility
76+
- Text domain: `visualizer`
77+
- Escape all output (`esc_html()`, `esc_attr()`, `wp_kses_post()`)
78+
- Sanitize all input (`sanitize_text_field()`, etc.)
79+
- Prepare all database queries with `$wpdb->prepare()`
80+
- Use WordPress nonces for form submissions

0 commit comments

Comments
 (0)