@contentrain/skills 0.9.4 → 0.9.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@contentrain/skills",
3
- "version": "0.9.4",
3
+ "version": "0.9.6",
4
4
  "license": "MIT",
5
5
  "description": "AI agent skills for Contentrain — workflow procedures, framework integration guides",
6
6
  "type": "module",
@@ -61,9 +61,9 @@
61
61
  "tsdown": "^0.21.0",
62
62
  "typescript": "^5.7.0",
63
63
  "vitest": "^3.0.0",
64
- "@contentrain/mcp": "3.4.3",
65
- "@contentrain/rules": "0.7.2",
66
- "@contentrain/wp-import": "0.4.6"
64
+ "@contentrain/mcp": "3.10.1",
65
+ "@contentrain/rules": "0.7.3",
66
+ "@contentrain/wp-import": "0.13.0"
67
67
  },
68
68
  "scripts": {
69
69
  "build": "tsdown src/index.ts --format esm,cjs --dts",
@@ -196,8 +196,9 @@ Several fields are managed by the platform. Agents MUST NOT set or modify them.
196
196
  | `i18n: false` on model | Single file: `data.json` (or `{slug}.md` for documents) |
197
197
  | Locale code | ISO 639-1: `en`, `tr`, `de`, `fr`, `ja`, `ar` |
198
198
  | ID/slug are locale-agnostic | Same entry ID or document slug across all locales |
199
- | Entry parity (collections) | All locales MUST have the same set of entry IDs |
200
- | Key parity (dictionaries) | All locales MUST have the same set of keys |
199
+ | Entry parity (collections) | All covered locales MUST have the same set of entry IDs |
200
+ | Key parity (dictionaries) | All covered locales MUST have the same set of keys |
201
+ | `locales` on model (optional) | The project locales this model covers — a subset of `locales.supported`. Absent means all of them. Parity is checked against it |
201
202
 
202
203
  ### Validation Checks
203
204
 
@@ -15,7 +15,8 @@ Every rule applies whenever the project has more than one locale configured.
15
15
  ### 1.1 Coverage Requirement
16
16
 
17
17
  - Read `.contentrain/config.json` → `locales.supported` to determine the full list of supported locales.
18
- - EVERY entry that exists in the source locale MUST have a corresponding entry in ALL supported target locales.
18
+ - A model MAY narrow that list with an optional `locales` array (a subset of `locales.supported`). When present, it — not the project list — is the model's coverage. Absent means every supported locale.
19
+ - EVERY entry that exists in the source locale MUST have a corresponding entry in ALL of the model's covered target locales.
19
20
  - Missing translations are deployment blockers. Treat a missing locale file as an error, not a warning.
20
21
 
21
22
  ### 1.2 Dictionary Entries
@@ -88,6 +88,7 @@ Create or update a model definition (upsert).
88
88
  | `kind` | string | Yes | `singleton`, `collection`, `document`, `dictionary` |
89
89
  | `domain` | string | Yes | Organizational group |
90
90
  | `i18n` | boolean | Yes | Whether model supports localization |
91
+ | `locales` | string[] | No | The project locales this model covers — a subset of `config.locales.supported`. Absent means all of them, which is what parity is validated against. Declare it only for a genuinely partial model (a partially-translated site) |
91
92
  | `title_field` | string | Yes | Field shown as an entry's title. Must name a field on this model typed `string`, `text`, `slug`, `email`, `url`, `code`, `markdown` or `richtext`. Dictionaries have no fields — use `"key"` |
92
93
  | `fields` | object | No | Field definitions (not for dictionary) |
93
94
  | `description` | string | No | Model description |
@@ -36,9 +36,11 @@ REST returns more than WXR (rendered HTML, media metadata, per-type discovery);
36
36
  **Private or partial REST.** A site can answer `/wp-json` but hide drafts, private types and some fields. An Application Password lifts the run to `rest_auth`:
37
37
 
38
38
  ```bash
39
- npx contentrain import https://example.com --auth "user:xxxx xxxx xxxx xxxx"
39
+ CONTENTRAIN_WP_APP_PASSWORD="xxxx xxxx xxxx xxxx" npx contentrain import https://example.com --auth user
40
40
  ```
41
41
 
42
+ Ask the user to set the password in the environment (or run the command themselves for the hidden prompt). Never put `user:password` on the command line: it lands in shell history. A WXR import leaves author and commenter e-mail addresses out of the store; add `--include-emails` only when the user asks and the repository stays private.
43
+
42
44
  Check first, so you tell the user what they will get rather than discovering it after:
43
45
 
44
46
  ```bash
@@ -76,7 +78,7 @@ Open `import-report.json` and tell the user what it says. These fields decide wh
76
78
  | `title_fallback` | Entries that had no title | They exist but are unlabelled; worth a pass |
77
79
  | `acf_fields` / `meta_fields` | Custom fields found and their inferred types | Verify the types match intent before content is edited |
78
80
 
79
- **Known gap:** post bodies carry Gutenberg block comments and shortcodes verbatim. They render as-is in HTML but they are WordPress syntax, not portable content. Say so — do not present the import as clean markup when it is not.
81
+ **Known gap:** post bodies carry shortcodes (`[gallery]`) verbatim: WordPress syntax, not portable content. Gutenberg block delimiters are stripped (the markup stays); self-closing server-rendered blocks (`wp:latest-posts`, `wp:block`) leave nothing and are counted in `blocks_dynamic_dropped`. Say so — do not present the import as clean markup when shortcodes remain.
80
82
 
81
83
  ### 4. Validate
82
84
 
@@ -76,7 +76,7 @@ Inferred types are a guess from one value. Check `meta_fields` and `acf_fields`
76
76
 
77
77
  ## What is not imported
78
78
 
79
- Post types matching `attachment|nav_menu_item|wp_*|jp_*|pattern|revision|oembed_cache|customize_changeset|user_request|custom_css` are skipped and listed in `report.skipped_types`, and so are theme / page-builder internals that store design rather than content: GeneratePress elements (`gp_elements`, `gp-elements`), GenerateBlocks styles (`gblocks_*`, `gblocks-*`), Elementor templates (`elementor_library`, `e-landing-page`) and form definitions (`wpcf7_contact_form`, `wpforms*`). Membership and other content-bearing CPTs stay; ACF field records stay too, since their cross-model parents are part of the lossless import. Attachments are not skipped content — they arrive as the `media` collection.
79
+ Post types matching `attachment|nav_menu_item|wp_*|jp_*|pattern|revision|oembed_cache|customize_changeset|user_request|custom_css` are skipped and listed in `report.skipped_types`, and so are theme / page-builder internals that store design rather than content: GeneratePress elements (`gp_elements`, `gp-elements`), GenerateBlocks styles (`gblocks_*`, `gblocks-*`), Elementor templates (`elementor_library`) and form definitions (`wpcf7_contact_form`, `wpforms*`). Elementor landing pages (`e-landing-page`) are not internals: they are public pages at `/<slug>/`, so they import as `page` — into the `pages` model, with their slug, permalink (`link`) and meta, sharing the page address space (a clash gets the usual slug move). Over REST the type is listed only when it is `show_in_rest`; a site that hides it must be imported from a WXR export. Membership and other content-bearing CPTs stay; ACF field records stay too, since their cross-model parents are part of the lossless import. Attachments are not skipped content — they arrive as the `media` collection.
80
80
 
81
81
  Also outside the import: themes, widgets, plugin settings, users' passwords and roles, and the media **files** themselves (only their metadata and URLs come across).
82
82
 
@@ -90,6 +90,6 @@ A relation whose target was not part of the import (a comment on a skipped post
90
90
 
91
91
  ## Known gaps
92
92
 
93
- - **Gutenberg and shortcodes** stay verbatim in `body`. `<!-- wp:paragraph -->` and `[gallery]` render as-is in HTML but they are WordPress syntax; converting them is a separate pass.
93
+ - **Gutenberg block delimiters** (`<!-- wp:… -->`, `<!-- /wp:… -->`) are stripped from `body`; the markup inside every block stays. Self-closing, server-rendered blocks (`wp:latest-posts`, `wp:block`, `wp:query`) hold no markup and disappear: `blocks_dynamic_dropped` in the report counts them by name. **Shortcodes** (`[gallery]`) stay verbatim in `body`; converting them is a separate pass.
94
94
  - **Media files** stay on the old host until moved.
95
95
  - **Redirects** are not generated. `slug_rewritten` + `slug_fallback` in the report say how many URLs changed.
@@ -14,7 +14,7 @@ Follow these guidelines when populating image, video, or file fields in any cont
14
14
 
15
15
  Media references are stored in one of two models. Identify which one the project uses before populating image, video, or file fields. The asset rules below (dimensions, formats, size limits, naming) apply to **both**; only the **Asset Organization** section (paths under `assets_path`, relative references) is specific to the local-file model.
16
16
 
17
- 1. **Local file model (default / OSS).** Media lives on disk under `config.json > assets_path` (default `.contentrain/assets/`) and is referenced by a **relative path from the project root** (e.g. `.contentrain/assets/blog/hero.webp`). To turn relative paths into URLs at read time, set `config.json > cdn.url` (or `contentrain generate --cdnBaseUrl <base>`) and use the `media()` resolver baked into the `@contentrain/query` generated client — `media('media/...') → {cdn.url}/{path}`.
17
+ 1. **Local file model (default / OSS).** Media lives on disk under `config.json > assets_path` (default `.contentrain/assets/`) and is referenced by a **relative path from the project root** (e.g. `.contentrain/assets/blog/hero.webp`). To turn relative paths into URLs at read time, set `config.json > cdn.url` (or `contentrain generate --mediaBaseUrl <base>`) and use the `media()`/`mediaBody()` resolvers baked into the `@contentrain/query` generated client — `media('media/...') → {mediaBaseUrl}/{path}`, `mediaBody(markdown)` for `](media/...)` references inside markdown. The Astro loader (`contentrainLoader({ mediaBaseUrl })`) applies the same resolver automatically to media fields and markdown bodies.
18
18
 
19
19
  2. **Studio CDN model.** Media lives in the Studio CDN/object store and is referenced by a relative storage path (`media/...`) returned by the media library. Pass either that `media/...` path or its URL to `contentrain_content_save`: in **cloud mode** the value is **automatically normalized to an absolute public delivery URL** on save (`{base}/{path}`), in both media fields and markdown bodies, so the committed content renders in a browser anywhere with no SDK. In **local mode** the relative path is kept verbatim. The rewrite is idempotent and never touches external URLs (`http(s)://`, `//`, `data:`) or already-absolute delivery URLs — so for external images (a CDN or Unsplash URL), just save the URL directly.
20
20
 
@@ -83,16 +83,19 @@ const doc = document('blog-post').bySlug('getting-started')
83
83
  Media / image / file field values are plain strings. How you turn them into a URL depends on the storage model:
84
84
 
85
85
  - **Studio-CDN content** already carries absolute delivery URLs — the write path normalizes `media/...` references on save — so use the field value directly, no resolution needed.
86
- - **Relative-path content** (OSS / local-file model, values like `media/...`) resolves through an optional `media()` helper baked into the generated client. Set `config.json > cdn.url` (or run `contentrain generate --cdnBaseUrl <base>`) and the client exports it:
86
+ - **Relative-path content** (OSS / local-file model, values like `media/...`) resolves through optional `media()`/`mediaBody()` helpers baked into the generated client. Set `config.json > cdn.url` (or run `contentrain generate --mediaBaseUrl <base>`) and the client exports them:
87
87
 
88
88
  ```typescript
89
- import { media } from '#contentrain'
89
+ import { media, mediaBody } from '#contentrain'
90
90
 
91
- media('media/original/hero.webp') // → '{cdn.url}/media/original/hero.webp'
91
+ media('media/original/hero.webp') // → '{mediaBaseUrl}/media/original/hero.webp'
92
92
  media('https://images.unsplash.com/x.jpg') // → unchanged (external pass-through)
93
+ mediaBody('See ![cover](media/hero.webp)') // → resolves `](media/...)` refs inside markdown
93
94
  ```
94
95
 
95
- `media()` is omitted when no base is configured, and is idempotent — external URLs (`http(s)://`, `//`, `data:`) and already-absolute delivery URLs pass through untouched. It is the **local-mode** counterpart of CDN mode's `client.media()` (which returns a `MediaAccessor` over the media manifest, below).
96
+ Both take an optional second argument overriding the baked base for that call — a Nuxt app passes its own `useRuntimeConfig()` value here instead of rebaking per environment. The Astro loader (`contentrainLoader({ mediaBaseUrl })`) applies the same resolver automatically.
97
+
98
+ `media()`/`mediaBody()` do not exist on the client at all when no base is configured at generate time — not a pass-through, an absent export. A host that never bakes a base in (reading it purely from its own runtime config or env, e.g. Nuxt) must import `resolveMediaUrl(value, base)` / `resolveMediaRefsInBody(markdown, base)` from `@contentrain/query` directly instead of going through the generated client. Both take a nullable base and no-op when it is absent, so calling them unconditionally is safe. `media()`, when present, is idempotent — external URLs (`http(s)://`, `//`, `data:`) and already-absolute delivery URLs pass through untouched. It is the **local-mode** counterpart of CDN mode's `client.media()` (which returns a `MediaAccessor` over the media manifest, below).
96
99
 
97
100
  ## CDN Mode (Remote Data)
98
101
 
@@ -189,7 +192,7 @@ const history = await conv.history(response.conversationId)
189
192
  - Locale fallback chain: explicit → config default → first available
190
193
  - Generated files in `.contentrain/client/` are **immutable** — always regenerate, never edit
191
194
  - Run `contentrain generate` after any model change
192
- - **Media**: Studio-CDN fields already carry absolute URLs; for relative `media/...` values set `config.cdn.url` (or `generate --cdnBaseUrl`) and resolve with the generated `media()` helper
195
+ - **Media**: Studio-CDN fields already carry absolute URLs; for relative `media/...` values set `config.cdn.url` (or `generate --mediaBaseUrl`) and resolve with the generated `media()`/`mediaBody()` helpers
193
196
 
194
197
  ## Framework Integration
195
198
 
@@ -120,7 +120,9 @@ Example:
120
120
  listings, pickers and relation references, and must be a field on this model
121
121
  typed `string`, `text`, `slug`, `email`, `url`, `code`, `markdown` or
122
122
  `richtext`. Dictionary models have no fields, so they use the reserved value
123
- `"key"` — the entry key is the title.
123
+ `"key"` — the entry key is the title. A singleton made of section objects
124
+ (`hero`, `services`) names a section's heading with a dotted path,
125
+ `"hero.heading"` — one level into an `object` field, never an array.
124
126
 
125
127
  Choose what a reader uses to tell one entry from another: the headline, the
126
128
  name, the question. Not the slug, not the icon, not a relation ID. Consumers