diff --git a/.cursor/rules/README.md b/.cursor/rules/README.md new file mode 100644 index 0000000..f5c1f87 --- /dev/null +++ b/.cursor/rules/README.md @@ -0,0 +1,5 @@ +# Cursor (optional) + +**Cursor** users: start at **[AGENTS.md](../../AGENTS.md)**. All conventions live in **`skills/*/SKILL.md`**. + +This folder only points contributors to **`AGENTS.md`** so editor-specific config does not duplicate the canonical docs. diff --git a/AGENTS.md b/AGENTS.md new file mode 100644 index 0000000..ba43fe9 --- /dev/null +++ b/AGENTS.md @@ -0,0 +1,41 @@ +# CLI: Migrate HTML RTE to JSON RTE – Agent guide + +**Universal entry point** for contributors and AI agents. Detailed conventions live in **`skills/*/SKILL.md`**. + +## What this repo is + +| Field | Detail | +|--------|--------| +| **Name:** | [cli-cm-migrate-rte](https://github.com/contentstack/cli-cm-migrate-rte) (`@contentstack/cli-cm-migrate-rte`) | +| **Purpose:** | **oClif** plugin for **Contentstack CLI** (`csdx`) to migrate HTML RTE fields to JSON RTE using serializers and DOM parsing. | +| **Out of scope:** | Not a general-purpose CLI—extends the Contentstack CLI command set only. | + +## Tech stack (at a glance) + +| Area | Details | +|------|---------| +| Language | JavaScript (Node **≥ 18**); commands under **`src/commands/`** | +| Build | oClif manifest (`oclif manifest` in `prepack`); no separate compile step for app code | +| Tests | **Mocha** + **nyc** — `npm test` → `test/**/*.test.js` with `test/setup.js` | +| Lint / coverage | **ESLint** with `eslint-config-oclif` (run `npx eslint .` if no script) | +| CI | `.github/workflows/unit-test.yml`, `check-version-bump.yml`, `sca-scan.yml`, `policy-scan.yml`, `issues-jira.yml` | + +## Commands (quick reference) + +| Command type | Command | +|--------------|---------| +| Test | `npm test` | +| Lint (manual) | `npx eslint .` (project uses ESLint 8 + oClif config) | + +## Where the documentation lives: skills + +| Skill | Path | What it covers | +|-------|------|----------------| +| **Development workflow** | [`skills/dev-workflow/SKILL.md`](skills/dev-workflow/SKILL.md) | oClif, Husky, versioning, CLI release | +| **Migrate RTE plugin** | [`skills/cli-migrate-rte/SKILL.md`](skills/cli-migrate-rte/SKILL.md) | Commands, serializers, jsdom usage | +| **Testing** | [`skills/testing/SKILL.md`](skills/testing/SKILL.md) | Mocha, nock, fixtures | +| **Code review** | [`skills/code-review/SKILL.md`](skills/code-review/SKILL.md) | PR checklist for CLI behavior | + +## Using Cursor (optional) + +If you use **Cursor**, [`.cursor/rules/README.md`](.cursor/rules/README.md) only points to **`AGENTS.md`**—same docs as everyone else. diff --git a/skills/cli-migrate-rte/SKILL.md b/skills/cli-migrate-rte/SKILL.md new file mode 100644 index 0000000..03ede38 --- /dev/null +++ b/skills/cli-migrate-rte/SKILL.md @@ -0,0 +1,25 @@ +--- +name: cli-migrate-rte +description: Use for migrate-html-rte command behavior, JSON RTE serializer, and DOM parsing in cli-cm-migrate-rte. +--- + +# Migrate RTE plugin – cli-cm-migrate-rte + +## When to use + +- Changing migration logic, stack entry updates, or `@contentstack/json-rte-serializer` usage +- Debugging jsdom-based HTML transforms + +## Instructions + +### Dependencies + +- Relies on **`@contentstack/cli-command`**, **`@contentstack/cli-utilities`**, and **`@contentstack/json-rte-serializer`**—pin versions per Contentstack CLI compatibility matrix. + +### Command UX + +- Short name **`MGRTRTE`** is configured under `csdxConfig`—keep help text and flags aligned with Contentstack CLI standards. + +### Safety + +- Migrations mutate content—prefer dry-run or backup guidance in docs when adding destructive paths; validate on copies first. diff --git a/skills/code-review/SKILL.md b/skills/code-review/SKILL.md new file mode 100644 index 0000000..4db54e2 --- /dev/null +++ b/skills/code-review/SKILL.md @@ -0,0 +1,25 @@ +--- +name: code-review +description: Use when reviewing PRs for cli-cm-migrate-rte—command safety, tests, and CLI dependency alignment. +--- + +# Code review – cli-cm-migrate-rte + +## When to use + +- Reviewing migration logic or dependency bumps on `@contentstack/*` packages + +## Instructions + +### Checklist + +- **Safety**: Migration cannot silently corrupt entries; edge cases covered by tests. +- **CLI contract**: Flags, prompts, and exit codes match oClif expectations and docs. +- **Deps**: `@contentstack/cli-*` versions aligned with the CLI release train. +- **Tests**: `npm test` green; new behavior has Mocha coverage. + +### Severity hints + +- **Blocker**: Data loss risk, failing tests, or broken manifest/readme generation. +- **Major**: Missing tests for HTML edge cases or serializer upgrades. +- **Minor**: Logging, messages, internal structure. diff --git a/skills/dev-workflow/SKILL.md b/skills/dev-workflow/SKILL.md new file mode 100644 index 0000000..eabfece --- /dev/null +++ b/skills/dev-workflow/SKILL.md @@ -0,0 +1,30 @@ +--- +name: dev-workflow +description: Use for oClif plugin lifecycle, npm scripts, Husky, and Contentstack CLI integration for cli-cm-migrate-rte. +--- + +# Development workflow – cli-cm-migrate-rte + +## When to use + +- Adding or renaming commands under `src/commands/` +- Preparing `npm pack` / publish with oClif manifest + +## Instructions + +### oClif + +- Commands are discovered from **`./src/commands`** (`package.json` `oclif.commands`). +- **`prepack`** runs `oclif manifest` and `oclif readme`—ensure generated files stay consistent with git. + +### Versioning + +- **`npm version`** hook updates README via oClif—follow semver for CLI consumers. + +### Node + +- **`engines.node`** is **≥ 18**—test on supported Node LTS. + +### Husky + +- **`prepare`** sets up Husky—hooks run in dev after install. diff --git a/skills/testing/SKILL.md b/skills/testing/SKILL.md new file mode 100644 index 0000000..acf2b08 --- /dev/null +++ b/skills/testing/SKILL.md @@ -0,0 +1,25 @@ +--- +name: testing +description: Use for Mocha tests, nyc coverage, and test/setup.js patterns in cli-cm-migrate-rte. +--- + +# Testing – cli-cm-migrate-rte + +## When to use + +- Adding tests under `test/**/*.test.js` +- Mocking HTTP with **nock** for CLI flows + +## Instructions + +### Runner + +- **`npm test`** runs Mocha with `test/setup.js` and **nyc** (coverage check relaxed via `--check-coverage=false` in script—still collect locally). + +### Structure + +- Keep one concern per test file; use fixtures for HTML/RTE samples instead of huge inline strings when possible. + +### Integration + +- Heavy integration tests may need CLI auth mocks—never commit API keys; use nock or env stubs.