|
| 1 | +# AGENTS.md |
| 2 | + |
| 3 | +Instructions for AI coding agents working on this repository. |
| 4 | + |
| 5 | +## Project Overview |
| 6 | + |
| 7 | +Medusa plugin for automations. |
| 8 | +Provides rule-based triggers and actions |
| 9 | +for notifications and custom workflows. |
| 10 | + |
| 11 | +- Package: `@codee-sh/medusa-plugin-automations` |
| 12 | +- Medusa: `>= 2.8.8` |
| 13 | +- Node.js: `>= 20` |
| 14 | +- Package manager: `yarn` (v3, see `.yarnrc.yml`) |
| 15 | + |
| 16 | +## Scripts |
| 17 | + |
| 18 | +```bash |
| 19 | +yarn build # build plugin (medusa plugin:build) |
| 20 | +yarn dev # develop plugin (medusa plugin:develop) |
| 21 | +yarn prepublishOnly # build before publish (medusa plugin:build) |
| 22 | +yarn publish-local # publish locally (npx medusa plugin:publish) |
| 23 | +yarn publish-package # publish to npm (dotenv npm publish --access public) |
| 24 | +yarn format # prettier write (src) |
| 25 | +yarn format:check # prettier check (src) |
| 26 | +yarn changeset # add changeset |
| 27 | +yarn version # version bump |
| 28 | +yarn release # publish via changesets |
| 29 | +yarn release:manual # build + npm publish |
| 30 | +yarn prepare-release # prep release branch |
| 31 | +``` |
| 32 | + |
| 33 | +## Code Style |
| 34 | + |
| 35 | +- Prettier: 60-char print width, no semicolons, double quotes, trailing commas (es5) |
| 36 | +- Config: `.prettierrc` |
| 37 | +- TypeScript: ES2021, Node16 modules, strict null checks, decorators enabled |
| 38 | +- Config: `tsconfig.json` |
| 39 | + |
| 40 | +## Branch Model |
| 41 | + |
| 42 | +- `main` — release-ready, every commit is tagged and deployable |
| 43 | +- `develop` — nightly builds and upcoming release work |
| 44 | +- Topic branches: `feat/<name>`, `fix/<name>`, `chore/<name>`, `docs/<name>` |
| 45 | +- PRs target `develop` by default |
| 46 | +- Hotfixes branch from `main`, merge back to `main` and `develop` |
| 47 | + |
| 48 | +## Versioning and Release |
| 49 | + |
| 50 | +- Uses [Changesets](https://github.com/changesets/changesets) for version management |
| 51 | +- Add changeset: `yarn changeset` |
| 52 | +- Version bump: `yarn changeset version` |
| 53 | +- Release: merge release branch to `main`, tag is created automatically |
| 54 | +- CI: GitHub Actions for PR labeling and release-on-merge |
| 55 | + |
| 56 | +## Architecture |
| 57 | + |
| 58 | +### High-Level Flow |
| 59 | + |
| 60 | +``` |
| 61 | +Event/Schedule/Manual trigger |
| 62 | + → Subscriber/Job |
| 63 | + → Rule evaluation |
| 64 | + → Action handlers |
| 65 | + → Medusa Notification Module (delivery) |
| 66 | +``` |
| 67 | + |
| 68 | +### Source Tree |
| 69 | + |
| 70 | +``` |
| 71 | +src/ |
| 72 | +├── admin/ # Admin panel UI |
| 73 | +├── api/ # Admin API routes (/api/admin/mpn/...) |
| 74 | +├── emails/ # Email helpers/templates |
| 75 | +├── hooks/ # React hooks for API calls |
| 76 | +├── jobs/ # Scheduled jobs |
| 77 | +├── links/ # Module links |
| 78 | +├── modules/ |
| 79 | +│ └── mpn-automation/ # Core module: models, services, migrations |
| 80 | +├── providers/ # Notification providers (e.g. slack) |
| 81 | +├── subscribers/ # Medusa event subscribers |
| 82 | +├── utils/ # Helpers |
| 83 | +└── workflows/ # Automation + domain workflows |
| 84 | +``` |
| 85 | + |
| 86 | +### Key Modules |
| 87 | + |
| 88 | +| Module | Path | Purpose | |
| 89 | +|--------|------|---------| |
| 90 | +| `mpn-automation` | `src/modules/mpn-automation/` | Core: DB models, services, migrations | |
| 91 | +| Providers | `src/providers/` | Notification providers (e.g. Slack) | |
| 92 | +| Workflows | `src/workflows/` | Automation + domain workflows | |
| 93 | +| Subscribers | `src/subscribers/` | Event listeners for triggers | |
| 94 | + |
| 95 | +## Documentation |
| 96 | + |
| 97 | +- `README.md` — overview, install, basic setup |
| 98 | +- `docs/configuration.md` — plugin options, actions, rules |
| 99 | +- `docs/admin.md` — admin panel user guide |
| 100 | +- `CONTRIBUTING.md` — branch model, PR rules, release process |
| 101 | + |
| 102 | +## AI Skills |
| 103 | + |
| 104 | +Project skills live in `skills/`. |
| 105 | +If symlinked, use `.ai/skills/` with |
| 106 | +`.cursor/skills` and `.codex/skills`. |
| 107 | + |
| 108 | +| Skill | When to use | |
| 109 | +|-------|-------------| |
| 110 | +| `docs` | Writing or updating documentation | |
| 111 | + |
| 112 | +## Rules for Agents |
| 113 | + |
| 114 | +1. Always run `yarn format` before committing. |
| 115 | +2. Follow the branch model: feature work from `develop`, PRs to `develop`. |
| 116 | +3. Add a changeset (`yarn changeset`) for any user-facing change. |
| 117 | +4. Use consistent terminology: `automation`, `trigger`, |
| 118 | + `rule`, `action`, `mpn-automation`, `workflow`. |
| 119 | +5. When changing docs, follow the `docs` skill. |
| 120 | +6. Do not commit `.env`, `node_modules`, `.medusa/`, or build artifacts. |
0 commit comments