Skip to content

Commit 19d259e

Browse files
Merge pull request #272 from contentstack/fix/dx-6041-update-cursor-rules
chore: Refactor documentation in AGENTS.md and remove redundant Cursor…
2 parents 3936b65 + 5c46015 commit 19d259e

File tree

15 files changed

+262
-352
lines changed

15 files changed

+262
-352
lines changed

.cursor/rules/README.md

Lines changed: 3 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,5 @@
1-
# Cursor rules — `@contentstack/utils`
1+
# Cursor (optional)
22

3-
This folder holds project-specific rules for AI assistants working in **contentstack-utils-javascript**. For the full project overview, see **[`AGENTS.md`](../../AGENTS.md)** at the repository root.
3+
**Cursor** users: start at **[`AGENTS.md`](../../AGENTS.md)**. All conventions live in **`skills/*/SKILL.md`**.
44

5-
## How rules are picked up
6-
7-
Each rule is a `.md`/`.mdc` file. Files with YAML frontmatter can set `description`, `globs`, and `alwaysApply`. Cursor uses these to decide when a rule is included in context.
8-
9-
### Referencing rules in chat
10-
11-
In Cursor, you can **`@`-mention** a rule file (e.g. type `@` and choose the rule from the list) to force its guidance into the conversation. The file name (without extension) is the usual handle, e.g. **`typescript`**, **`testing`**, **`code-review`**.
12-
13-
## Rule index
14-
15-
| File | `alwaysApply` | Globs | When it applies |
16-
|------|----------------|-------|------------------|
17-
| [`dev-workflow.md`](dev-workflow.md) | no | *(none)* | Branching, CI alignment, commits, releases, and day-to-day commands for this repo. |
18-
| [`typescript.mdc`](typescript.mdc) | no | `src/**/*.ts`, `__test__/**/*.ts` | TypeScript version, layout, ESLint/Prettier, strictness, imports. |
19-
| [`typescript-contentstack-utils.mdc`](typescript-contentstack-utils.mdc) | no | `src/**/*.ts` | Delivery-oriented utils only: RTE rendering, GQL helpers, endpoints JSON, Live Preview tags—**not** full CDA/CMA SDK surface. |
20-
| [`testing.mdc`](testing.mdc) | no | `__test__/**/*.ts` | Jest, jsdom, mocks, coverage output paths, no live-test env. |
21-
| [`code-review.mdc`](code-review.mdc) | **yes** | *(global)* | PR checklist: public API docs, compatibility, errors, dependencies, terminology (utils + delivery context). |
22-
23-
## Related
24-
25-
- **[`AGENTS.md`](../../AGENTS.md)** — Single entry point (package purpose, stack, commands).
26-
- **[`skills/README.md`](../../skills/README.md)** — Longer-form skill docs for the same themes.
5+
This folder only points contributors to **`AGENTS.md`** so editor-specific config does not duplicate the canonical docs.

.cursor/rules/code-review.mdc

Lines changed: 0 additions & 41 deletions
This file was deleted.

.cursor/rules/dev-workflow.md

Lines changed: 0 additions & 38 deletions
This file was deleted.

.cursor/rules/testing.mdc

Lines changed: 0 additions & 38 deletions
This file was deleted.

.cursor/rules/typescript-contentstack-utils.mdc

Lines changed: 0 additions & 34 deletions
This file was deleted.

.cursor/rules/typescript.mdc

Lines changed: 0 additions & 34 deletions
This file was deleted.

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,5 @@ coverage/
1616
.dccache
1717
snyk_output.log
1818
talisman_output.log
19-
regions.json
19+
regions.json
20+
.vscode/settings.json

AGENTS.md

Lines changed: 45 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,52 +1,52 @@
1-
# Agent guidance — `@contentstack/utils`
1+
# Contentstack Utils JavaScript – Agent guide
22

3-
## What this package is
3+
**Universal entry point** for anyone automating or assisting work in this repo—AI agents (Cursor, Copilot, CLI tools), reviewers, and contributors. Conventions and detailed guidance live in **`skills/*/SKILL.md`**, not in editor-specific config, so the same instructions apply whether or not you use Cursor.
44

5-
**[@contentstack/utils](https://www.npmjs.com/package/@contentstack/utils)** (`contentstack-utils-javascript`) is a **JavaScript/TypeScript utilities library** for Contentstack. It is **not** the Content Delivery API (CDA) SDK or the Content Management API (CMA) SDK. It focuses on **JSON RTE / Supercharged RTE** rendering (`jsonToHTML`), **embedded entry and asset** rendering (`render`, `renderContent`), **GraphQL-oriented helpers** (`GQL`, `updateAssetURLForGQL`), **Live Preview–style editable tags** (`addEditableTags` / `addTags`), and **region endpoint lookup** (`getContentstackEndpoint`). Typical usage is **alongside** the Delivery SDK (see repository `README.md` examples with `@contentstack/delivery-sdk`).
5+
## What this repo is
66

7-
- **Repository:** [github.com/contentstack/contentstack-utils-javascript](https://github.com/contentstack/contentstack-utils-javascript)
7+
- **Name:** [`@contentstack/utils`](https://www.npmjs.com/package/@contentstack/utils)[contentstack/contentstack-utils-javascript](https://github.com/contentstack/contentstack-utils-javascript)
8+
- **Purpose:** TypeScript/JavaScript **utilities** for Contentstack: JSON RTE / Supercharged RTE to HTML (`jsonToHTML`), embedded entry and asset rendering (`render`, `renderContent`), GraphQL helpers (`GQL`, `updateAssetURLForGQL`), Live Preview–style editable tags (`addEditableTags`), region endpoint lookup (`getContentstackEndpoint`), and variant-related helpers (`getVariantAliases`, `getVariantMetadataTags`). Used **with** the [Content Delivery API](https://www.contentstack.com/docs/developers/apis/content-delivery-api/) and delivery-shaped JSON (see root `README.md` and [`@contentstack/delivery-sdk`](https://www.npmjs.com/package/@contentstack/delivery-sdk) usage patterns).
9+
- **Out of scope:** This package does **not** ship HTTP clients, stack credentials, or the full CDA/CMA SDK surface. Apps fetch content with the Delivery SDK or other clients, then pass entry JSON into these helpers. Runtime API calls are **not** part of the library; `regions.json` for endpoint lookup is a **build-time** asset.
810

9-
## Tech stack
11+
## Tech stack (at a glance)
1012

1113
| Area | Details |
1214
|------|---------|
13-
| Language | TypeScript **4.9** (`tsconfig.json`, `strict: true`, `strictNullChecks: false`) |
14-
| Build | **TypeScript** (`tsc`) → `dist/lib`; **Rollup** (`rollup -c`) → `dist/index.es.js`; types in `dist/types/` |
15-
| Test | **Jest 29** + **ts-jest**, **jsdom** environment (`jest.config.ts`) |
16-
| Lint / format | **ESLint 9** flat config (`eslint.config.js`); **Prettier 3** (`npm run format`) — there is **no** `lint` npm script; use `npx eslint` as needed |
17-
| Runtime HTTP / JSON for API calls | **None** in library code; `regions.json` is a **build-time** asset (see below) |
18-
19-
## Source layout and public API
20-
21-
| Role | Path |
22-
|------|------|
23-
| Public entry (sources) | `src/index.ts` |
24-
| Options / render types | `src/options/` |
25-
| RTE / node model | `src/Models/`, `src/nodes/` |
26-
| Helpers | `src/helper/` |
27-
| GQL + asset URL rewrite | `src/gql.ts`, `src/updateAssetURLForGQL.ts` |
28-
| Endpoints helper | `src/endpoints.ts` + `src/assets/regions.json` (generated; see build) |
29-
| Published bundle | `dist/` (per `package.json` `main` / `types`) |
30-
31-
## Common commands
32-
33-
| Command | Purpose |
34-
|---------|---------|
35-
| `npm run build` | Cleans `dist`, ensures `src/assets/regions.json` (download or warning), runs `tsc` + Rollup |
36-
| `npm test` | Runs `pretest`**build**, then Jest with coverage; outputs under `reports/` |
37-
| `npm run test:debug` | Jest watch, in-band |
38-
| `npm run format` | Prettier on `src/**/*.ts` |
39-
| `npm run download-regions` | Fetches `regions.json` only (used by `prebuild`) |
40-
41-
**Tests:** Unit tests only, under `__test__/**/*.test.ts`, with mocks in `__test__/mock/`. There are **no** live/integration tests requiring stack credentials in this repository.
42-
43-
## Credentials / environment
44-
45-
- **Unit tests:** No API keys or `.env` required.
46-
- **Build:** `download-regions` calls a public URL (`artifacts.contentstack.com`); offline builds may warn and rely on an existing `src/assets/regions.json`. Note `regions.json` is listed in `.gitignore`; clones may need a successful `npm run build` (or manual file) before tests pass.
47-
- **Publish:** GitHub release workflow uses `NPM_TOKEN` / `GIT_TOKEN` secrets (maintainers only).
48-
49-
## More detail for AI / IDE rules
50-
51-
- [`.cursor/rules/README.md`](.cursor/rules/README.md) — Cursor rules index (`alwaysApply`, globs, when to use).
52-
- [`skills/README.md`](skills/README.md) — Topic skills (testing, code review, package mental model).
15+
| Language | TypeScript **4.9** (`tsconfig.json`: `strict: true`, `strictNullChecks: false`) |
16+
| Build | `tsc``dist/lib` + declarations in `dist/types/`; **Rollup**`dist/index.es.js` (`rollup.config.js`). `prebuild` runs `download-regions` for `src/assets/regions.json`. |
17+
| Tests | **Jest 29** + **ts-jest**, **jsdom** (`jest.config.ts`). Tests under **`__test__/**/*.test.ts`**, mocks in **`__test__/mock/`**. |
18+
| Lint / coverage | **ESLint 9** flat config (`eslint.config.js`); **Prettier 3** (`npm run format`). Coverage under `reports/coverage/` when running `npm test`. |
19+
| Runtime | No HTTP client dependency; pure transforms + bundled `regions.json` for endpoints. |
20+
21+
## Commands (quick reference)
22+
23+
```bash
24+
npm run build && npm test
25+
npx eslint src __test__
26+
npm run format
27+
npm run download-regions # regions.json only (also run as part of prebuild)
28+
```
29+
30+
`npm test` runs **`pretest``npm run build`**, then Jest with coverage; outputs under **`reports/`**. Use **`npm run test:debug`** for Jest watch mode (`--runInBand`).
31+
32+
**CI:** `.github/workflows/ci.yml` (unit tests / coverage on `development`, `staging`, `master`). Branch rules: `.github/workflows/check-branch.yml`. Publish: `.github/workflows/npm-publish.yml` (on GitHub release).
33+
34+
Install: `npm i @contentstack/utils` — see root **`README.md`** and **`package.json`** for the current version.
35+
36+
## Where the real documentation lives: skills
37+
38+
Read these **`SKILL.md` files** for full conventions—**this is the source of truth** for implementation and review:
39+
40+
| Skill | Path | What it covers |
41+
|-------|------|----------------|
42+
| **Development workflow** | [`skills/dev-workflow/SKILL.md`](skills/dev-workflow/SKILL.md) | Branches, CI, build/test/lint, Husky (Snyk/Talisman, commitlint), PR expectations, releases |
43+
| **TypeScript (layout & tooling)** | [`skills/typescript/SKILL.md`](skills/typescript/SKILL.md) | Compiler settings, `src/` layout, ESLint/Prettier, `regions.json` / `.gitignore` |
44+
| **Contentstack Utils (package)** | [`skills/contentstack-utils/SKILL.md`](skills/contentstack-utils/SKILL.md) | Public API and domain: exports from `src/index.ts`, RTE/embed/GQL/endpoints/Live Preview/variants—not the full CDA/CMA SDK; no network layer |
45+
| **Testing** | [`skills/testing/SKILL.md`](skills/testing/SKILL.md) | Jest, mocks, coverage/report paths, `pretest` build, offline unit tests (no stack credentials) |
46+
| **Code review** | [`skills/code-review/SKILL.md`](skills/code-review/SKILL.md) | PR checklist (API docs, compatibility, errors, deps/SCA, tests), Blocker/Major/Minor, terminology |
47+
48+
There is **no** `skills/framework/` folder: this repo does not ship a shared HTTP client, retry layer, or native build system beyond npm/TypeScript/Rollup.
49+
50+
## Using Cursor
51+
52+
If you use **Cursor**, [`.cursor/rules/README.md`](.cursor/rules/README.md) only points to **`AGENTS.md`**—same source of truth as everyone else; no separate `.mdc` rule files.

0 commit comments

Comments
 (0)