Skip to content
Merged
21 changes: 21 additions & 0 deletions .ai/skills/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Agent Skills (Cursor + Codex)

This directory contains project-level skills for AI coding agents.

## Structure

```
.ai/skills/
docs/
SKILL.md
```

## Linking to Cursor and Codex

Use a single source (`.ai/skills`) and symlink it for each tool:

```bash
mkdir -p .cursor .codex
ln -sfn ../.ai/skills .cursor/skills
ln -sfn ../.ai/skills .codex/skills
```
61 changes: 61 additions & 0 deletions .ai/skills/docs/SKILL.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
---
name: plugin-docs-authoring
description: Rules for writing and updating plugin documentation. Use when creating new docs pages, updating existing docs (README, docs/*.md), or reviewing documentation changes.
---

## Prerequisites

Read `AGENTS.md` first for terminology, architecture, and template types.
This skill only covers documentation-specific rules.

## File Responsibilities

Each file has a strict scope. Do not mix responsibilities between files.

| File | Scope | Tone |
|------|-------|------|
| `README.md` | High-level overview, install, basic setup, links to docs | Short, navigational |
| `docs/configuration.md` | Plugin options only | Technical, example-driven |
| `docs/admin.md` | Admin panel user guide — what you can do, typical workflow | User-facing, no endpoints |

## Writing Rules

### Structure

1. Start every page with a one-sentence summary of what the page covers.
2. Use `##` for main sections, `###` for subsections. Do not go deeper than `####`.
3. Put "what the user can do" before technical details.
4. End pages with a `## See Also` section linking to related docs.

### Style

1. Write in English.
2. Use short sentences and short paragraphs.
3. Prefer bullet lists over long prose.
4. Use code blocks for every example — never inline large snippets.
5. Do not use emojis.

### Cross-referencing

1. Do not duplicate content between files — link to the authoritative page.
2. If you remove a page, update all references across docs and README.
3. Keep all internal links relative (`./blocks.md`, `../blocks.md`).

## Checklist (run before finishing)

- [ ] Does the content match the current architecture?
- [ ] Is `docs/admin.md` still non-technical (no raw endpoints)?
- [ ] Is `README.md` still short and navigational?
- [ ] Are there any dead links?
- [ ] Is there duplicated content between files?

## Workflow

When asked to update or create docs:

1. Read this skill first.
2. Identify which files are affected (use the File Responsibilities table).
3. Read the current state of those files.
4. Make changes following the rules above.
5. Run the checklist.
6. Report: list of changed files + short summary of what and why.
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,14 @@ build/
# IDE
.vscode/
.idea/
.cursor/
.codex/
.claude/
*.swp
*.swo
*~
.github-workflow


# OS
.DS_Store
Expand Down
127 changes: 127 additions & 0 deletions AGENTS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
# AGENTS.md

Instructions for AI coding agents working on this repository.

## Project Overview

Medusa plugin for automations.
Provides rule-based triggers and actions
for notifications and custom workflows.

- Package: `@codee-sh/medusa-plugin-automations`
- Medusa: `>= 2.8.8`
- Node.js: `>= 20`
- Package manager: `yarn` (v3, see `.yarnrc.yml`)

## Scripts

```bash
yarn build # build plugin (medusa plugin:build)
yarn dev # develop plugin (medusa plugin:develop)
yarn prepublishOnly # build before publish (medusa plugin:build)
yarn publish-local # publish locally (npx medusa plugin:publish)
yarn publish-package # publish to npm (dotenv npm publish --access public)
yarn format # prettier write (src)
yarn format:check # prettier check (src)
yarn changeset # add changeset
yarn version # version bump
yarn release # publish via changesets
yarn release:manual # build + npm publish
yarn prepare-release # prep release branch
```

## Shell Scripts

Daily workflow helpers in `scripts/`:

- `scripts/create-pr.sh` — create a PR (used by `yarn pr:create`).
- `scripts/prepare-release.sh` — prepare a release branch (used by `yarn prepare-release`).

## Code Style

- Prettier: 60-char print width, no semicolons, double quotes, trailing commas (es5)
- Config: `.prettierrc`
- TypeScript: ES2021, Node16 modules, strict null checks, decorators enabled
- Config: `tsconfig.json`

## Branch Model

- `main` — release-ready, every commit is tagged and deployable
- `develop` — nightly builds and upcoming release work
- Topic branches: `feat/<name>`, `fix/<name>`, `chore/<name>`, `docs/<name>`
- PRs target `develop` by default
- Hotfixes branch from `main`, merge back to `main` and `develop`

## Versioning and Release

- Uses [Changesets](https://github.com/changesets/changesets) for version management
- Add changeset: `yarn changeset`
- Version bump: `yarn changeset version`
- Release: merge release branch to `main`, tag is created automatically
- CI: GitHub Actions for PR labeling and release-on-merge

## Architecture

### High-Level Flow

```
Event/Schedule/Manual trigger
→ Subscriber/Job
→ Rule evaluation
→ Action handlers
→ Medusa Notification Module (delivery)
```

### Source Tree

```
src/
├── admin/ # Admin panel UI
├── api/ # Admin API routes (/api/admin/mpn/...)
├── emails/ # Email helpers/templates
├── hooks/ # React hooks for API calls
├── jobs/ # Scheduled jobs
├── links/ # Module links
├── modules/
│ └── mpn-automation/ # Core module: models, services, migrations
├── providers/ # Notification providers (e.g. slack)
├── subscribers/ # Medusa event subscribers
├── utils/ # Helpers
└── workflows/ # Automation + domain workflows
```

### Key Modules

| Module | Path | Purpose |
|--------|------|---------|
| `mpn-automation` | `src/modules/mpn-automation/` | Core: DB models, services, migrations |
| Providers | `src/providers/` | Notification providers (e.g. Slack) |
| Workflows | `src/workflows/` | Automation + domain workflows |
| Subscribers | `src/subscribers/` | Event listeners for triggers |

## Documentation

- `README.md` — overview, install, basic setup
- `docs/configuration.md` — plugin options, actions, rules
- `docs/admin.md` — admin panel user guide
- `CONTRIBUTING.md` — branch model, PR rules, release process

## AI Skills

Project skills live in `skills/`.
If symlinked, use `.ai/skills/` with
`.cursor/skills` and `.codex/skills`.

| Skill | When to use |
|-------|-------------|
| `docs` | Writing or updating documentation |

## Rules for Agents

1. Always run `yarn format` before committing.
2. Follow the branch model: feature work from `develop`, PRs to `develop`.
3. Add a changeset (`yarn changeset`) for any user-facing change.
4. Use consistent terminology: `automation`, `trigger`,
`rule`, `action`, `mpn-automation`, `workflow`.
5. When changing docs, follow the `docs` skill.
6. Do not commit `.env`, `node_modules`, `.medusa/`, or build artifacts.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# @codee-sh/medusa-plugin-automations

## 1.0.11

### Patch Changes

- dd40d44: Add skills and agents
- f9cf002: Add changeset

## 1.0.10

### Patch Changes
Expand Down
34 changes: 22 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
# Medusa plugin automations

A comprehensive automation plugin for Medusa v2 that provides a flexible rule-based automation system with triggers, conditions, and actions. Create automated workflows that can send notifications (email, Slack), execute custom actions, or trigger other processes based on events, schedules, or manual triggers with customizable rules.
Automation plugin for Medusa v2 with rule-based
triggers and actions for notifications and workflows.

## Features

- **Automation Triggers**: Create automations triggered by events, schedules, or manual actions ([see details](#automation-triggers))
- **Rule-Based Conditions**: Define complex conditions with support for arrays, relations, and multiple data types ([see details](#rules-and-conditions))
- **Rich Attribute Support**: Pre-configured attributes for Products, Variants, Tags, Categories, and Inventory ([see available attributes](./docs/configuration.md#available-attributes-reference))
- **Multiple Action Types**: Execute various actions including email notifications, Slack messages, SMS, push notifications, and custom actions ([see details](#actions))
- **Event Subscribers**: Built-in subscribers for common Medusa events ([see available events](./docs/configuration.md#available-subscribers))
- **Automation Triggers**: Events, schedules, or manual actions ([see details](#automation-triggers))
- **Rule-Based Conditions**: Arrays, relations, and multiple data types ([see details](#rules-and-conditions))
- **Rich Attribute Support**: Products, Variants, Tags, Categories, Inventory ([see available attributes](./docs/attributes.md))
- **Multiple Action Types**: Email, Slack, and custom actions ([see details](#actions))
- **Event Subscribers**: Built-in subscribers for common Medusa events ([see available events](./docs/available-subscribers.md))
- **Admin Panel**: Manage automations directly from Medusa Admin ([see details](#admin-panel))
- **Extensible**: Add custom action handlers and extend automation capabilities
- **Extensible**: Add custom action handlers
- **Type-Safe**: Full TypeScript support with exported types and workflows

## Compatibility
Expand Down Expand Up @@ -64,19 +65,20 @@ Navigate to **Notifications > Automations** in your Medusa Admin dashboard, or d

Automations are triggered by:
- **Events**: Medusa events (e.g., `inventory.inventory-level.updated`, `product.updated`)
- **Schedule**: Time-based triggers with configurable intervals (In progress)
- **Schedule**: Time-based triggers with configurable intervals
- **Manual**: Triggered manually from the admin panel

See [Available Subscribers](./docs/configuration.md#available-subscribers) in the configuration documentation for a complete list of supported events.
See [Available Subscribers](./docs/available-subscribers.md) for a complete list of supported events.

### Rules and Conditions

Each automation can have multiple rules that define when actions should be executed. Rules support primitive fields, relations (arrays), nested objects, and various operators for complex conditions.

For detailed information, see:
- [Available Attributes Reference](./docs/configuration.md#available-attributes-reference) - Complete list of attributes for each event type
- [Rule Operators](./docs/configuration.md#rule-operators) - All supported operators with examples
- [Available Attributes Reference](./docs/attributes.md) - Complete list of attributes for each event type
- [Rule Operators](./docs/rule-operators.md) - All supported operators with examples
- [Rule Values](./docs/configuration.md#rule-values) - Supported data types and usage
- [Custom Action Handlers](./docs/custom-action-handlers.md) - Extend actions with custom handlers

### Actions

Expand All @@ -88,6 +90,9 @@ When automation rules pass, actions are executed. Supported action types include

See [Actions](./docs/configuration.md#actions) and [Slack Notification Provider](./docs/configuration.md#slack-notification-provider) in the configuration documentation for details on configuring and extending actions.

Email and Slack templates are rendered by
`@codee-sh/medusa-plugin-notification-emails`.

## Admin Panel

Access the automations management interface in Medusa Admin at `/app/notifications/automations`. See [Admin Panel Documentation](./docs/admin.md) for details.
Expand All @@ -114,7 +119,7 @@ The plugin exports the following:

## Related Plugins

For email templates and rendering functionality, see [@codee-sh/medusa-plugin-automations-emails](https://github.com/codee-sh/medusa-plugin-notification-emails).
For email and Slack template rendering, see [@codee-sh/medusa-plugin-notification-emails](https://github.com/codee-sh/medusa-plugin-notification-emails).

## License

Expand All @@ -123,3 +128,8 @@ MIT
## Author

Codee Team - [https://codee.dev](https://codee.dev)

## See Also

- [Configuration](./docs/configuration.md)
- [Admin Panel](./docs/admin.md)
Loading