@contentrain/rules 0.2.0 → 0.3.1

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.
Files changed (60) hide show
  1. package/README.md +24 -51
  2. package/context/context-bridge.md +2 -2
  3. package/dist/index.cjs +2 -26
  4. package/dist/index.d.cts +2 -11
  5. package/dist/index.d.cts.map +1 -1
  6. package/dist/index.d.mts +2 -11
  7. package/dist/index.d.mts.map +1 -1
  8. package/dist/index.mjs +2 -23
  9. package/dist/index.mjs.map +1 -1
  10. package/essential/contentrain-essentials.md +91 -0
  11. package/package.json +6 -9
  12. package/prompts/generate-mode.md +1 -1
  13. package/ide/claude-code/contentrain.md +0 -2984
  14. package/ide/claude-code/rules/contentrain-accessibility-rules.md +0 -155
  15. package/ide/claude-code/rules/contentrain-content-conventions.md +0 -314
  16. package/ide/claude-code/rules/contentrain-content-quality.md +0 -294
  17. package/ide/claude-code/rules/contentrain-i18n-quality.md +0 -293
  18. package/ide/claude-code/rules/contentrain-mcp-usage.md +0 -405
  19. package/ide/claude-code/rules/contentrain-media-rules.md +0 -165
  20. package/ide/claude-code/rules/contentrain-normalize-rules.md +0 -312
  21. package/ide/claude-code/rules/contentrain-schema-rules.md +0 -380
  22. package/ide/claude-code/rules/contentrain-security-rules.md +0 -141
  23. package/ide/claude-code/rules/contentrain-seo-rules.md +0 -224
  24. package/ide/claude-code/rules/contentrain-workflow-rules.md +0 -262
  25. package/ide/cursor/contentrain.cursorrules +0 -2959
  26. package/ide/cursor/rules/contentrain-accessibility-rules.mdc +0 -160
  27. package/ide/cursor/rules/contentrain-content-conventions.mdc +0 -319
  28. package/ide/cursor/rules/contentrain-content-quality.mdc +0 -299
  29. package/ide/cursor/rules/contentrain-i18n-quality.mdc +0 -298
  30. package/ide/cursor/rules/contentrain-mcp-usage.mdc +0 -410
  31. package/ide/cursor/rules/contentrain-media-rules.mdc +0 -170
  32. package/ide/cursor/rules/contentrain-normalize-rules.mdc +0 -317
  33. package/ide/cursor/rules/contentrain-schema-rules.mdc +0 -385
  34. package/ide/cursor/rules/contentrain-security-rules.mdc +0 -146
  35. package/ide/cursor/rules/contentrain-seo-rules.mdc +0 -229
  36. package/ide/cursor/rules/contentrain-workflow-rules.mdc +0 -267
  37. package/ide/generic/contentrain.md +0 -2984
  38. package/ide/windsurf/contentrain.windsurfrules +0 -2984
  39. package/ide/windsurf/rules/contentrain-accessibility-rules.md +0 -160
  40. package/ide/windsurf/rules/contentrain-content-conventions.md +0 -319
  41. package/ide/windsurf/rules/contentrain-content-quality.md +0 -299
  42. package/ide/windsurf/rules/contentrain-i18n-quality.md +0 -298
  43. package/ide/windsurf/rules/contentrain-mcp-usage.md +0 -410
  44. package/ide/windsurf/rules/contentrain-media-rules.md +0 -170
  45. package/ide/windsurf/rules/contentrain-normalize-rules.md +0 -317
  46. package/ide/windsurf/rules/contentrain-schema-rules.md +0 -385
  47. package/ide/windsurf/rules/contentrain-security-rules.md +0 -146
  48. package/ide/windsurf/rules/contentrain-seo-rules.md +0 -229
  49. package/ide/windsurf/rules/contentrain-workflow-rules.md +0 -267
  50. package/shared/accessibility-rules.md +0 -155
  51. package/shared/content-conventions.md +0 -314
  52. package/shared/content-quality.md +0 -294
  53. package/shared/i18n-quality.md +0 -293
  54. package/shared/mcp-usage.md +0 -405
  55. package/shared/media-rules.md +0 -165
  56. package/shared/normalize-rules.md +0 -312
  57. package/shared/schema-rules.md +0 -380
  58. package/shared/security-rules.md +0 -141
  59. package/shared/seo-rules.md +0 -224
  60. package/shared/workflow-rules.md +0 -262
@@ -1,155 +0,0 @@
1
- # Accessibility Rules
2
-
3
- These rules are MANDATORY for all AI agents creating or editing content in Contentrain projects.
4
- Violations will be flagged during validation. No exceptions unless explicitly overridden by `context.json` configuration.
5
-
6
- ---
7
-
8
- ## Image Accessibility
9
-
10
- 1. Every `image` type field MUST have a corresponding alt text value. If the model defines an `image_alt` field, populate it. If not, include alt text guidance in the image field's `description` metadata.
11
-
12
- 2. Alt text MUST describe the image's **content and function**, not its appearance.
13
- - GOOD: `"CEO Jane Doe speaking at the 2024 product launch"`
14
- - BAD: `"A photo with blue tones and a person on stage"`
15
-
16
- 3. Decorative images (visual separators, background textures) MUST have alt text set to an empty string `""`. Never leave alt text undefined or null — explicitly set it to `""`.
17
-
18
- 4. Complex images (charts, infographics, diagrams) MUST have a short alt text summarizing the conclusion, plus a detailed description in an adjacent text field or in the body content.
19
- - Example alt: `"Bar chart showing Q3 revenue grew 22% year-over-year"`
20
- - Example adjacent text: full data table or written summary
21
-
22
- 5. Alt text MUST NOT exceed **125 characters**. Screen readers may truncate longer text.
23
-
24
- 6. Icon images used as interactive elements MUST have alt text describing the **action**, not the icon.
25
- - GOOD: `"Search"`, `"Close menu"`, `"Open settings"`
26
- - BAD: `"Magnifying glass icon"`, `"X icon"`
27
-
28
- 7. Do not begin alt text with "Image of" or "Photo of" — the screen reader already announces it as an image.
29
-
30
- ---
31
-
32
- ## Language & Readability
33
-
34
- 1. Target a **grade 8-10 reading level** (Flesch-Kincaid) for general content.
35
-
36
- 2. Target **grade 6-8** for public-facing critical content: legal notices, safety information, error messages, onboarding flows.
37
-
38
- 3. Use plain language. Prefer common words over formal synonyms:
39
- - "use" not "utilize"
40
- - "start" not "commence"
41
- - "help" not "facilitate"
42
- - "buy" not "purchase"
43
- - "end" not "terminate"
44
-
45
- 4. Define every acronym and abbreviation on first use: `"Content Management System (CMS)"`. After the first definition, use the acronym freely.
46
-
47
- 5. Do not use jargon unless the content targets a technical audience. Check `context.json > tone` to determine the audience. When `tone` is `"technical"`, domain-specific terms are acceptable without definitions.
48
-
49
- 6. Keep sentences short: **15-20 words average**. Break long sentences at natural clause boundaries.
50
-
51
- 7. Keep paragraphs short: **3-5 sentences maximum**. Use line breaks between paragraphs.
52
-
53
- 8. Use active voice. Passive voice is acceptable only when the actor is unknown or irrelevant.
54
- - GOOD: `"The system saves your changes automatically."`
55
- - BAD: `"Your changes are saved automatically by the system."`
56
-
57
- ---
58
-
59
- ## Link Text
60
-
61
- 1. Link text MUST be descriptive and self-explanatory. It must make sense **out of context** because screen readers present links in an isolated list.
62
- - GOOD: `"Download the 2024 Annual Report"`
63
- - BAD: `"Click here"`
64
-
65
- 2. NEVER use these as standalone link text: `"click here"`, `"read more"`, `"learn more"`, `"here"`, `"link"`, `"this"`.
66
-
67
- 3. For file downloads, include the file type and size in the link text:
68
- - `"Download the Q3 Budget (PDF, 2.4 MB)"`
69
-
70
- 4. Do not use the raw URL as link text unless the content is specifically listing URLs.
71
-
72
- 5. Keep link text concise — describe the destination or action in 2-8 words.
73
-
74
- ---
75
-
76
- ## Heading Semantics
77
-
78
- 1. Headings MUST describe the content of their section. Never use headings purely for visual styling (font size, bold).
79
-
80
- 2. Heading levels MUST reflect **document hierarchy**:
81
- - `h2` for top-level sections within the page
82
- - `h3` for subsections of an `h2`
83
- - `h4` for subsections of an `h3`
84
- - Never skip levels (e.g., `h2` directly to `h4`)
85
-
86
- 3. Every distinct content section SHOULD have a heading.
87
-
88
- 4. Headings MUST NOT be empty or contain only whitespace.
89
-
90
- 5. Do not duplicate heading text within the same page unless sections are genuinely distinct (e.g., "Overview" under two different parent headings is acceptable).
91
-
92
- ---
93
-
94
- ## Content Structure
95
-
96
- 1. Use **semantic markup** appropriate to the content type:
97
- - Unordered lists (`ul`) for items without sequence
98
- - Ordered lists (`ol`) for steps or ranked items
99
- - Headings for section titles
100
- - Paragraphs for body text
101
- - Blockquotes for quoted material
102
-
103
- 2. Tables MUST include a header row or header column. Keep table structure simple — avoid merged cells and nested tables.
104
-
105
- 3. Provide a text alternative for every piece of non-text content (images, charts, embedded media).
106
-
107
- 4. Sequential content (steps, instructions, timelines) MUST follow logical reading order. Do not rely on CSS or layout to reorder content.
108
-
109
- 5. Lists MUST have at least two items. A single-item list should be rewritten as a paragraph or inline text.
110
-
111
- ---
112
-
113
- ## Color & Visual References
114
-
115
- 1. NEVER use color alone to convey meaning.
116
- - BAD: `"Required fields are highlighted in red."`
117
- - GOOD: `"Required fields are marked with an asterisk (*)."`
118
-
119
- 2. Do not reference visual position in content text.
120
- - BAD: `"Click the button on the right."`
121
- - GOOD: `"Click the Submit button."`
122
-
123
- 3. Ensure all text content is meaningful without any visual context. Content must be understandable when read aloud or rendered in plain text.
124
-
125
- ---
126
-
127
- ## Error Messages & Forms
128
-
129
- 1. Error messages MUST identify **which field** has the error.
130
-
131
- 2. Error messages MUST describe **what the error is** and how to fix it.
132
- - GOOD: `"Enter a valid email address (e.g., name@example.com)."`
133
- - BAD: `"Invalid input."`
134
-
135
- 3. Use **positive framing** — tell the user what to do, not what they did wrong.
136
- - GOOD: `"Enter a date in YYYY-MM-DD format."`
137
- - BAD: `"Wrong date format."`
138
-
139
- 4. Group related form fields with descriptive labels. Every input field MUST have a label.
140
-
141
- 5. Do not use placeholder text as a substitute for labels.
142
-
143
- ---
144
-
145
- ## Multimedia
146
-
147
- 1. Video content MUST reference a transcript — either as inline content, a URL, or a relation to a document entry.
148
-
149
- 2. Audio content MUST have a text transcript available.
150
-
151
- 3. If content auto-plays, note this in metadata so the frontend can provide pause/stop controls. Auto-playing media with audio is strongly discouraged.
152
-
153
- 4. Time-based media (video, audio, animations) MUST include duration information when the model supports it.
154
-
155
- 5. Animated content (GIFs, auto-playing videos) should be flagged if longer than 5 seconds — provide a mechanism to pause.
@@ -1,314 +0,0 @@
1
- # Contentrain Content Conventions
2
-
3
- > These rules govern how content is structured, stored, and serialized in the `.contentrain/` directory. Follow them exactly when creating or modifying content through MCP tools.
4
-
5
- ---
6
-
7
- ## 1. Directory Structure
8
-
9
- All Contentrain data lives under the `.contentrain/` directory at the project root. Understand every subdirectory's purpose before reading or writing.
10
-
11
- ```
12
- .contentrain/
13
- config.json # Project configuration (stack, workflow, locales, domains)
14
- vocabulary.json # Canonical terms for consistent terminology
15
- context.json # Project intelligence — MCP writes after every write op, agents READ ONLY
16
- assets.json # Media asset registry
17
- models/
18
- {model-id}.json # Model definitions (one file per model)
19
- content/
20
- {domain}/
21
- {model-id}/
22
- en.json # Content per locale (i18n: true)
23
- tr.json
24
- data.json # Content without locale (i18n: false)
25
- {slug}/ # Document kind only
26
- en.md
27
- tr.md
28
- meta/
29
- {model-id}/
30
- {locale}.json # System-managed metadata
31
- {slug}/ # Document kind only
32
- {locale}.json
33
- client/ # SDK generated client — auto-generated, NEVER edit
34
- assets/ # Media files (images, videos, documents)
35
- ```
36
-
37
- ### Critical Boundaries
38
-
39
- - **NEVER write to `.contentrain/meta/`** -- metadata is system-managed (status, source, updated_by, approved_by).
40
- - **NEVER edit `.contentrain/client/`** -- this is auto-generated by `contentrain generate`.
41
- - **NEVER edit `.contentrain/context.json`** -- MCP writes it; agents read it for project intelligence.
42
- - **ALWAYS use MCP tools** to create/update content and models. Do not write JSON files directly.
43
-
44
- ---
45
-
46
- ## 2. config.json Structure
47
-
48
- The project configuration file controls global behavior. It is created by `contentrain_init`.
49
-
50
- ```json
51
- {
52
- "version": 1,
53
- "stack": "nuxt",
54
- "workflow": "auto-merge",
55
- "repository": {
56
- "provider": "github",
57
- "owner": "contentrain",
58
- "name": "demo",
59
- "default_branch": "main"
60
- },
61
- "locales": {
62
- "default": "en",
63
- "supported": ["en", "tr"]
64
- },
65
- "domains": ["blog", "marketing", "system"],
66
- "assets_path": ".contentrain/assets",
67
- "branchRetention": 30
68
- }
69
- ```
70
-
71
- ### Field Reference
72
-
73
- | Field | Type | Description |
74
- |-------|------|-------------|
75
- | `version` | `number` | Config schema version. Always `1`. |
76
- | `stack` | `string` | Detected or set framework: `"nuxt"`, `"next"`, `"astro"`, `"sveltekit"`, `"react"`, `"node"` |
77
- | `workflow` | `string` | `"auto-merge"` (solo dev) or `"review"` (team governance) |
78
- | `repository` | `object` | Git remote info. Provider is always `"github"` in v1. |
79
- | `locales.default` | `string` | Primary locale (ISO 639-1) |
80
- | `locales.supported` | `string[]` | All locales including default |
81
- | `domains` | `string[]` | Organizational groups for content (e.g., `"blog"`, `"marketing"`, `"system"`) |
82
- | `assets_path` | `string` | Path for media files |
83
- | `branchRetention` | `number` | Days to keep merged branches |
84
-
85
- ---
86
-
87
- ## 3. Content File Formats by Model Kind
88
-
89
- Each of the 4 model kinds has a distinct storage format. Know them precisely.
90
-
91
- ### 3.1 Singleton
92
-
93
- One JSON object per locale file. No `id` field.
94
-
95
- **Path:** `.contentrain/content/{domain}/{model-id}/{locale}.json`
96
-
97
- ```json
98
- {
99
- "cta": "Get Started",
100
- "subtitle": "The modern content platform",
101
- "title": "Build faster"
102
- }
103
- ```
104
-
105
- **Use for:** Hero sections, navigation, site config, form labels -- anything with exactly one instance per locale.
106
-
107
- ### 3.2 Collection
108
-
109
- Object-map on disk: keys are entry IDs, sorted lexicographically. The `id` field is the key itself and is NOT stored inside the entry object.
110
-
111
- **Path:** `.contentrain/content/{domain}/{model-id}/{locale}.json`
112
-
113
- ```json
114
- {
115
- "a1b2c3d4e5f6": {
116
- "avatar": "assets/ahmet.jpg",
117
- "name": "Ahmet",
118
- "role": "CEO"
119
- },
120
- "f6e5d4c3b2a1": {
121
- "avatar": "assets/jane.jpg",
122
- "name": "Jane",
123
- "role": "CTO"
124
- }
125
- }
126
- ```
127
-
128
- **MCP output format differs from storage:** MCP tools return collections as arrays with `id` injected:
129
-
130
- ```json
131
- [
132
- { "id": "a1b2c3d4e5f6", "name": "Ahmet", "role": "CEO", "avatar": "assets/ahmet.jpg" },
133
- { "id": "f6e5d4c3b2a1", "name": "Jane", "role": "CTO", "avatar": "assets/jane.jpg" }
134
- ]
135
- ```
136
-
137
- **Why object-map?**
138
- - Sorted keys produce predictable diffs and minimize Git merge conflicts.
139
- - No ID duplication -- key IS the ID.
140
- - Consistent structure with metadata files.
141
-
142
- ### 3.3 Document
143
-
144
- Markdown file with YAML-like frontmatter. One file per slug per locale.
145
-
146
- **Path:** `.contentrain/content/{domain}/{model-id}/{slug}/{locale}.md`
147
-
148
- ```markdown
149
- ---
150
- title: Getting Started
151
- slug: getting-started
152
- author: a1b2c3d4e5f6
153
- tags: [tutorial, intro]
154
- ---
155
- # Getting Started with Contentrain
156
-
157
- Your markdown body content here...
158
- ```
159
-
160
- **Use for:** Blog posts, documentation pages, changelogs -- long-form content with typed metadata.
161
-
162
- ### 3.4 Dictionary
163
-
164
- Flat key-value JSON per locale. No `fields` in the model definition -- all values are strings.
165
-
166
- **Path:** `.contentrain/content/{domain}/{model-id}/{locale}.json`
167
-
168
- ```json
169
- {
170
- "auth.expired": "Session expired",
171
- "auth.failed": "Authentication failed",
172
- "validation.required": "{field} is required"
173
- }
174
- ```
175
-
176
- **Use for:** Error messages, UI strings, i18n translation files, mobile app strings.
177
-
178
- ---
179
-
180
- ## 4. Canonical Serialization Rules
181
-
182
- ALL JSON files in `.contentrain/` MUST follow these rules for deterministic, git-friendly output:
183
-
184
- 1. **Keys sorted lexicographically** within every object (including nested objects).
185
- 2. **2-space indent** for all nesting levels.
186
- 3. **UTF-8 encoding** without BOM.
187
- 4. **Trailing newline** at end of file (single `\n` after closing brace/bracket).
188
- 5. **Omit null values** -- do not write `"field": null`.
189
- 6. **Omit default values** -- if `required` is `false`, do not include it. If `default` is `null`, do not include it.
190
- 7. **Field key order in content entries** follows the model definition insertion order for readability, but storage uses lexicographic sort for determinism.
191
-
192
- ### Why This Matters
193
-
194
- - Deterministic output means identical data always produces identical files.
195
- - Sorted keys prevent artificial Git diffs from key reordering.
196
- - Clean diffs enable meaningful code review of content changes.
197
-
198
- ---
199
-
200
- ## 5. System Fields
201
-
202
- Several fields are managed by the platform. Agents MUST NOT set or modify them.
203
-
204
- | Field | Where | Managed By |
205
- |-------|-------|------------|
206
- | `id` | Collection entry key | Auto-generated 12-char hex UUID |
207
- | `slug` | Document directory name | Derived from content or set by agent via `slug` field |
208
- | `createdAt` | Not stored | Derived from Git commit history |
209
- | `updatedAt` | Not stored | Derived from Git commit history |
210
- | `status` | `.contentrain/meta/` | Platform workflow engine |
211
- | `source` | `.contentrain/meta/` | Set by MCP: `"agent"`, `"human"`, or `"import"` |
212
- | `updated_by` | `.contentrain/meta/` | Set by MCP: agent name or user email |
213
- | `approved_by` | `.contentrain/meta/` | Set by Studio on review approval |
214
-
215
- **Rule:** When creating content via `contentrain_content_save`, provide only the content fields defined in the model. Do not include `id`, `createdAt`, `updatedAt`, `status`, or any metadata fields.
216
-
217
- ---
218
-
219
- ## 6. Localization Rules
220
-
221
- | Rule | Detail |
222
- |------|--------|
223
- | `i18n: true` on model | Each locale gets its own file: `en.json`, `tr.json`, etc. |
224
- | `i18n: false` on model | Single file: `data.json` (or `{slug}.md` for documents) |
225
- | Locale code | ISO 639-1: `en`, `tr`, `de`, `fr`, `ja`, `ar` |
226
- | ID/slug are locale-agnostic | The same entry ID or document slug is used across all locales |
227
- | Entry parity (collections) | All locales MUST have the same set of entry IDs |
228
- | Key parity (dictionaries) | All locales MUST have the same set of keys |
229
-
230
- ### Validation Checks
231
-
232
- | Check | Severity | Example |
233
- |-------|----------|---------|
234
- | Missing locale file | Error | `hero: tr.json missing` |
235
- | Collection entry ID mismatch | Error | `team-members: entry "member-2" missing in tr` |
236
- | Dictionary key missing | Warning | `error-messages: tr missing 5 keys` |
237
- | Document missing translation | Warning | `blog-post: "getting-started" has no tr translation` |
238
-
239
- ---
240
-
241
- ## 7. Vocabulary
242
-
243
- The `vocabulary.json` file provides canonical terms for consistent content.
244
-
245
- ```json
246
- {
247
- "version": 1,
248
- "terms": {
249
- "email": { "en": "Email", "tr": "E-posta" },
250
- "sign-up": { "en": "Sign Up", "tr": "Kayit Ol" }
251
- }
252
- }
253
- ```
254
-
255
- ### Rules
256
-
257
- - **Check vocabulary FIRST** before writing any content. Use existing terms when they match.
258
- - **Add new terms** to the vocabulary when creating content with reusable terminology.
259
- - **Term keys** are kebab-case identifiers.
260
- - **Each term** maps to locale-specific approved strings.
261
- - Vocabulary ensures consistency across models, locales, and agent sessions.
262
-
263
- ---
264
-
265
- ## 8. context.json
266
-
267
- MCP writes `context.json` after every write operation. It provides project intelligence for agents and Studio synchronization.
268
-
269
- ```json
270
- {
271
- "version": "1.0",
272
- "lastOperation": {
273
- "tool": "content_save",
274
- "model": "blog-post",
275
- "locale": "en",
276
- "entries": ["a1b2c3d4e5f6"],
277
- "timestamp": "2026-03-11T14:30:00Z",
278
- "source": "mcp-local"
279
- },
280
- "stats": {
281
- "models": 5,
282
- "entries": 142,
283
- "locales": ["en", "tr"],
284
- "lastSync": "2026-03-11T14:30:00Z"
285
- }
286
- }
287
- ```
288
-
289
- ### Rules
290
-
291
- - **Read only** -- agents MUST NOT write to this file.
292
- - **Use it for awareness** -- check last operation, entry counts, locale coverage.
293
- - `source` values: `"mcp-local"` (IDE), `"mcp-studio"` (Studio server-side), `"studio-ui"` (Studio direct).
294
- - Updated only on write operations (not reads).
295
- - Git-tracked within `.contentrain/`.
296
-
297
- ---
298
-
299
- ## 9. Assets
300
-
301
- Media files are stored in the configured `assets_path`. The `assets.json` file tracks registered assets.
302
-
303
- ```json
304
- [
305
- { "path": "assets/hero.webp", "type": "image/webp", "size": 245680, "alt": "Hero background" }
306
- ]
307
- ```
308
-
309
- ### Rules for Media References
310
-
311
- - Use relative paths from the `.contentrain/` root in content fields.
312
- - Media field types (`image`, `video`, `file`) store string path references.
313
- - In v1, media fields are URL/path strings only. Upload and processing are out of scope.
314
- - Always provide `alt` text for images when the information is available.