|
| 1 | +# Contentstack Utils Python – Agent guide |
| 2 | + |
| 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. |
| 4 | + |
| 5 | +## What this repo is |
| 6 | + |
| 7 | +- **Name:** [contentstack-utils-python](https://github.com/contentstack/contentstack-utils-python) — **`contentstack_utils`** on PyPI (**Contentstack Python Utils SDK**). |
| 8 | +- **Purpose:** Utilities for **Contentstack** headless CMS: **RTE / embedded** rendering (`Utils`, `Options`), **GQL** helpers, **editable tags** on entries, HTML/metadata helpers. Often used alongside the **Contentstack** Python delivery package. |
| 9 | +- **Out of scope:** This package does **not** ship HTTP clients or stack credentials. Apps fetch content with the [Content Delivery API](https://www.contentstack.com/docs/developers/apis/content-delivery-api/) / Python SDK, then pass field data into **`Utils`**. |
| 10 | + |
| 11 | +## Tech stack (at a glance) |
| 12 | + |
| 13 | +| Area | Details | |
| 14 | +|------|---------| |
| 15 | +| **Language** | **Python** (`python_requires` in `setup.py`; classifiers list 3.6–3.9; dev tooling in `requirements.txt` may need a newer interpreter) | |
| 16 | +| **Package** | **`setuptools`** — `find_packages()`, `contentstack_utils/` | |
| 17 | +| **Runtime deps** | **`lxml`** (XML/HTML parsing in `utils.py` and helpers) | |
| 18 | +| **Tests** | **pytest** + **pytest-cov**, **pytest-html** (optional HTML report) | |
| 19 | +| **Lint / format** | **ruff**, **black**, **flake8**, **isort** (see `requirements.txt`) | |
| 20 | + |
| 21 | +## Source layout |
| 22 | + |
| 23 | +| Path | Role | |
| 24 | +|------|------| |
| 25 | +| `contentstack_utils/utils.py` | **`Utils`** — `render_content`, embedded/RTE flows; extends **`Automate`** | |
| 26 | +| `contentstack_utils/render/options.py` | **`Options`** for rendering | |
| 27 | +| `contentstack_utils/helper/` | **Metadata**, **NodeToHtml**, **converter** (e.g. `convert_style`) | |
| 28 | +| `contentstack_utils/embedded/` | **ItemType**, **StyleType** | |
| 29 | +| `contentstack_utils/gql.py` | **GQL** helpers | |
| 30 | +| `contentstack_utils/automate.py` | **`Automate`** base for automation-style rendering | |
| 31 | +| `contentstack_utils/entry_editable.py` | **`addEditableTags`**, **`addTags`**, **`getTag`**; re-exported via **`Utils`** static methods and package **`__init__`** | |
| 32 | +| `contentstack_utils/__init__.py` | Public exports — keep **`__all__`** aligned with documented API | |
| 33 | +| `tests/` | pytest modules (`test_*.py`), mocks under `tests/mocks/` | |
| 34 | + |
| 35 | +## Commands (quick reference) |
| 36 | + |
| 37 | +```bash |
| 38 | +python -m venv .venv && source .venv/bin/activate # or equivalent on Windows |
| 39 | +pip install -r requirements.txt |
| 40 | +pip install -e . |
| 41 | +pytest |
| 42 | +pytest --html=tests/test-report/test-report.html --self-contained-html |
| 43 | +coverage run -m pytest && coverage report -m |
| 44 | +``` |
| 45 | + |
| 46 | +## Security |
| 47 | + |
| 48 | +- Do not commit **API keys**, **delivery tokens**, or other secrets. Examples in **`README.md`** use placeholders only. |
| 49 | + |
| 50 | +## Where the real documentation lives: skills |
| 51 | + |
| 52 | +Read these **`SKILL.md` files** for full conventions—**this is the source of truth** for implementation and review: |
| 53 | + |
| 54 | +| Skill | Path | What it covers | |
| 55 | +|-------|------|----------------| |
| 56 | +| **Development workflow** | [`skills/dev-workflow/SKILL.md`](skills/dev-workflow/SKILL.md) | Branches, CI, venv, **pytest**, ruff/black/flake8, PR expectations | |
| 57 | +| **Contentstack Utils (SDK)** | [`skills/contentstack-utils/SKILL.md`](skills/contentstack-utils/SKILL.md) | **`Utils`**, **`Options`**, RTE/embedded, **GQL**, editable tags, JS parity, semver | |
| 58 | +| **Python style & layout** | [`skills/python-style/SKILL.md`](skills/python-style/SKILL.md) | Package layout, typing, imports, **`lxml`**, **`setup.py`**, security | |
| 59 | +| **Testing** | [`skills/testing/SKILL.md`](skills/testing/SKILL.md) | **pytest** layout, coverage, **`tests/mocks/`**, hygiene | |
| 60 | +| **Code review** | [`skills/code-review/SKILL.md`](skills/code-review/SKILL.md) | PR checklist (API, **`__all__`**, deps, tests, secrets) | |
| 61 | +| **Framework / integration** | [`skills/framework/SKILL.md`](skills/framework/SKILL.md) | **`lxml`**, companion **Contentstack** Python SDK, dependency boundaries | |
| 62 | + |
| 63 | +An index with short “when to use” hints is in [`skills/README.md`](skills/README.md). |
| 64 | + |
| 65 | +## Using Cursor |
| 66 | + |
| 67 | +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