@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
package/README.md CHANGED
@@ -12,33 +12,22 @@ This package is the policy layer of the Contentrain ecosystem. It defines how ag
12
12
  - content quality
13
13
  - normalize workflows
14
14
  - git-backed review flows
15
- - IDE rule distribution
16
15
 
17
16
  If `@contentrain/mcp` is the deterministic execution layer, `@contentrain/rules` is the behavioral contract.
18
17
 
19
- ## 🚀 Install
18
+ ## Install
20
19
 
21
20
  ```bash
22
21
  pnpm add @contentrain/rules
23
22
  ```
24
23
 
25
- ## 📦 What It Contains
24
+ ## What It Contains
26
25
 
27
- ### Shared rule sets
26
+ ### Essential guardrails
28
27
 
29
- Published under `shared/*`:
28
+ Published under `essential/*`:
30
29
 
31
- - `content-quality.md`
32
- - `seo-rules.md`
33
- - `i18n-quality.md`
34
- - `accessibility-rules.md`
35
- - `security-rules.md`
36
- - `media-rules.md`
37
- - `content-conventions.md`
38
- - `schema-rules.md`
39
- - `mcp-usage.md`
40
- - `workflow-rules.md`
41
- - `normalize-rules.md`
30
+ - `contentrain-essentials.md` — compact, always-loaded rules (~86 lines) covering architecture, model kinds, MCP tools, mandatory protocols, and security basics
42
31
 
43
32
  ### Prompt layers
44
33
 
@@ -55,39 +44,27 @@ Published under `context/*`:
55
44
 
56
45
  - `context-bridge.md`
57
46
 
58
- ### IDE bundles
59
-
60
- Published under `ide/*`:
61
-
62
- - `ide/claude-code/contentrain.md`
63
- - `ide/cursor/contentrain.cursorrules`
64
- - `ide/windsurf/contentrain.windsurfrules`
65
- - `ide/generic/contentrain.md`
66
-
67
- ## 🧰 Public Exports
47
+ ## Public Exports
68
48
 
69
49
  The package root exports constants that can be used by tooling:
70
50
 
71
- - `FIELD_TYPES`
72
- - `MODEL_KINDS`
73
- - `MCP_TOOLS`
74
- - `CONTENT_QUALITY_RULES`
75
- - `ARCHITECTURE_RULES`
76
- - `ALL_SHARED_RULES`
77
- - `IDE_RULE_FILES`
78
- - `STACKS`
51
+ - `FIELD_TYPES` — 27 flat field types
52
+ - `MODEL_KINDS` — singleton, collection, document, dictionary
53
+ - `MCP_TOOLS` — 15 MCP tool names
54
+ - `ESSENTIAL_RULES_FILE` — path to essential guardrails markdown
55
+ - `STACKS` — supported framework stacks
79
56
 
80
- ## 🧪 Example
57
+ ## Example
81
58
 
82
59
  ```ts
83
- import { IDE_RULE_FILES, MCP_TOOLS, ALL_SHARED_RULES } from '@contentrain/rules'
60
+ import { MCP_TOOLS, ESSENTIAL_RULES_FILE, FIELD_TYPES } from '@contentrain/rules'
84
61
 
85
62
  console.log(MCP_TOOLS.includes('contentrain_validate'))
86
- console.log(IDE_RULE_FILES['claude-code'])
87
- console.log(ALL_SHARED_RULES)
63
+ console.log(ESSENTIAL_RULES_FILE) // 'essential/contentrain-essentials.md'
64
+ console.log(FIELD_TYPES.length) // 27
88
65
  ```
89
66
 
90
- ## 🧠 Design Role
67
+ ## Design Role
91
68
 
92
69
  `@contentrain/rules` exists to keep agent behavior aligned across tools and environments.
93
70
 
@@ -97,26 +74,22 @@ It should answer questions like:
97
74
  - How should an agent use MCP tools?
98
75
  - What is the normalize contract?
99
76
  - What workflow and review constraints exist?
100
- - How should rules be packaged for Claude Code, Cursor, Windsurf, and generic agents?
101
77
 
102
- ## 🔗 Relationship To Other Packages
78
+ Detailed reference material and step-by-step procedures live in `@contentrain/skills` (Agent Skills standard format).
79
+
80
+ ## Relationship To Other Packages
103
81
 
104
82
  - `@contentrain/mcp` enforces file, validation, and git behavior
105
- - `@contentrain/skills` provides step-by-step workflow playbooks
83
+ - `@contentrain/skills` provides Agent Skills with progressive disclosure (SKILL.md + references/)
106
84
  - `contentrain` exposes CLI and serve UX
107
85
  - `@contentrain/query` is the generated runtime consumption layer
108
86
 
109
87
  Rule of thumb:
110
88
 
111
- - `rules` = policy and constraints
112
- - `skills` = procedures and playbooks
113
-
114
- ## 🛠 Build
115
-
116
- The build does two things:
89
+ - `rules` = essential guardrails (always loaded, ~86 lines)
90
+ - `skills` = detailed procedures and reference docs (on-demand)
117
91
 
118
- 1. builds the typed JS entry from `src/index.ts`
119
- 2. generates IDE bundle files from the shared markdown rules
92
+ ## Build
120
93
 
121
94
  From the monorepo root:
122
95
 
@@ -126,6 +99,6 @@ pnpm --filter @contentrain/rules test
126
99
  pnpm --filter @contentrain/rules typecheck
127
100
  ```
128
101
 
129
- ## 📄 License
102
+ ## License
130
103
 
131
104
  MIT
@@ -4,7 +4,7 @@
4
4
 
5
5
  `context.json` is the project intelligence file. It provides AI agents and Contentrain Studio with structured knowledge about the project: its tech stack, content patterns, conventions, and normalize configuration.
6
6
 
7
- - **Written by:** MCP tools (updated after every write operation)
7
+ - **Written by:** MCP tools (committed together with content changes in the same branch, not as a separate commit)
8
8
  - **Read by:** AI agents (at the start of every session) and Studio (for UI configuration)
9
9
  - **Location:** `.contentrain/context.json`
10
10
 
@@ -206,7 +206,7 @@ When creating `context.json` for the first time, use stack-appropriate defaults.
206
206
 
207
207
  ## Update Behavior
208
208
 
209
- MCP tools update `context.json` after every write operation:
209
+ MCP tools update `context.json` as part of each write operation, committed together with the content changes in the same branch (not as a separate commit):
210
210
  - `contentrain_init` creates the initial file
211
211
  - `contentrain_model_save` updates the domains list if a new domain is used
212
212
  - `contentrain_content_save` updates content stats
package/dist/index.cjs CHANGED
@@ -57,28 +57,7 @@ const MCP_TOOLS = [
57
57
  "contentrain_submit",
58
58
  "contentrain_bulk"
59
59
  ];
60
- const CONTENT_QUALITY_RULES = [
61
- "content-quality",
62
- "seo-rules",
63
- "i18n-quality",
64
- "accessibility-rules",
65
- "security-rules",
66
- "media-rules"
67
- ];
68
- const ARCHITECTURE_RULES = [
69
- "content-conventions",
70
- "schema-rules",
71
- "mcp-usage",
72
- "workflow-rules",
73
- "normalize-rules"
74
- ];
75
- const ALL_SHARED_RULES = [...CONTENT_QUALITY_RULES, ...ARCHITECTURE_RULES];
76
- const IDE_RULE_FILES = {
77
- "claude-code": "ide/claude-code/contentrain.md",
78
- "cursor": "ide/cursor/contentrain.cursorrules",
79
- "windsurf": "ide/windsurf/contentrain.windsurfrules",
80
- "generic": "ide/generic/contentrain.md"
81
- };
60
+ const ESSENTIAL_RULES_FILE = "essential/contentrain-essentials.md";
82
61
  const STACKS = [
83
62
  "nuxt",
84
63
  "next",
@@ -88,11 +67,8 @@ const STACKS = [
88
67
  "node"
89
68
  ];
90
69
  //#endregion
91
- exports.ALL_SHARED_RULES = ALL_SHARED_RULES;
92
- exports.ARCHITECTURE_RULES = ARCHITECTURE_RULES;
93
- exports.CONTENT_QUALITY_RULES = CONTENT_QUALITY_RULES;
70
+ exports.ESSENTIAL_RULES_FILE = ESSENTIAL_RULES_FILE;
94
71
  exports.FIELD_TYPES = FIELD_TYPES;
95
- exports.IDE_RULE_FILES = IDE_RULE_FILES;
96
72
  exports.MCP_TOOLS = MCP_TOOLS;
97
73
  exports.MODEL_KINDS = MODEL_KINDS;
98
74
  exports.STACKS = STACKS;
package/dist/index.d.cts CHANGED
@@ -10,18 +10,9 @@ declare const MODEL_KINDS: readonly ["singleton", "collection", "document", "dic
10
10
  type ModelKind = (typeof MODEL_KINDS)[number];
11
11
  declare const MCP_TOOLS: readonly ["contentrain_status", "contentrain_describe", "contentrain_describe_format", "contentrain_init", "contentrain_scaffold", "contentrain_model_save", "contentrain_model_delete", "contentrain_content_save", "contentrain_content_delete", "contentrain_content_list", "contentrain_scan", "contentrain_apply", "contentrain_validate", "contentrain_submit", "contentrain_bulk"];
12
12
  type McpTool = (typeof MCP_TOOLS)[number];
13
- declare const CONTENT_QUALITY_RULES: readonly ["content-quality", "seo-rules", "i18n-quality", "accessibility-rules", "security-rules", "media-rules"];
14
- declare const ARCHITECTURE_RULES: readonly ["content-conventions", "schema-rules", "mcp-usage", "workflow-rules", "normalize-rules"];
15
- declare const ALL_SHARED_RULES: readonly ["content-quality", "seo-rules", "i18n-quality", "accessibility-rules", "security-rules", "media-rules", "content-conventions", "schema-rules", "mcp-usage", "workflow-rules", "normalize-rules"];
16
- declare const IDE_RULE_FILES: {
17
- readonly 'claude-code': "ide/claude-code/contentrain.md";
18
- readonly cursor: "ide/cursor/contentrain.cursorrules";
19
- readonly windsurf: "ide/windsurf/contentrain.windsurfrules";
20
- readonly generic: "ide/generic/contentrain.md";
21
- };
22
- type IdeTarget = keyof typeof IDE_RULE_FILES;
13
+ declare const ESSENTIAL_RULES_FILE: "essential/contentrain-essentials.md";
23
14
  declare const STACKS: readonly ["nuxt", "next", "astro", "sveltekit", "react", "node"];
24
15
  type Stack = (typeof STACKS)[number];
25
16
  //#endregion
26
- export { ALL_SHARED_RULES, ARCHITECTURE_RULES, CONTENT_QUALITY_RULES, FIELD_TYPES, FieldType, IDE_RULE_FILES, IdeTarget, MCP_TOOLS, MODEL_KINDS, McpTool, ModelKind, STACKS, Stack };
17
+ export { ESSENTIAL_RULES_FILE, FIELD_TYPES, FieldType, MCP_TOOLS, MODEL_KINDS, McpTool, ModelKind, STACKS, Stack };
27
18
  //# sourceMappingURL=index.d.cts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.cts","names":[],"sources":["../src/index.ts"],"mappings":";;AAQA;;;;cAAa,WAAA;AAAA,KAUD,SAAA,WAAoB,WAAA;AAAA,cAInB,WAAA;AAAA,KACD,SAAA,WAAoB,WAAA;AAAA,cAInB,SAAA;AAAA,KAUD,OAAA,WAAkB,SAAA;AAAA,cAIjB,qBAAA;AAAA,cAKA,kBAAA;AAAA,cAKA,gBAAA;AAAA,cAIA,cAAA;EAAA;;;;;KAOD,SAAA,gBAAyB,cAAA;AAAA,cAIxB,MAAA;AAAA,KACD,KAAA,WAAgB,MAAA"}
1
+ {"version":3,"file":"index.d.cts","names":[],"sources":["../src/index.ts"],"mappings":";;AAQA;;;;cAAa,WAAA;AAAA,KAUD,SAAA,WAAoB,WAAA;AAAA,cAInB,WAAA;AAAA,KACD,SAAA,WAAoB,WAAA;AAAA,cAInB,SAAA;AAAA,KAUD,OAAA,WAAkB,SAAA;AAAA,cAIjB,oBAAA;AAAA,cAIA,MAAA;AAAA,KACD,KAAA,WAAgB,MAAA"}
package/dist/index.d.mts CHANGED
@@ -10,18 +10,9 @@ declare const MODEL_KINDS: readonly ["singleton", "collection", "document", "dic
10
10
  type ModelKind = (typeof MODEL_KINDS)[number];
11
11
  declare const MCP_TOOLS: readonly ["contentrain_status", "contentrain_describe", "contentrain_describe_format", "contentrain_init", "contentrain_scaffold", "contentrain_model_save", "contentrain_model_delete", "contentrain_content_save", "contentrain_content_delete", "contentrain_content_list", "contentrain_scan", "contentrain_apply", "contentrain_validate", "contentrain_submit", "contentrain_bulk"];
12
12
  type McpTool = (typeof MCP_TOOLS)[number];
13
- declare const CONTENT_QUALITY_RULES: readonly ["content-quality", "seo-rules", "i18n-quality", "accessibility-rules", "security-rules", "media-rules"];
14
- declare const ARCHITECTURE_RULES: readonly ["content-conventions", "schema-rules", "mcp-usage", "workflow-rules", "normalize-rules"];
15
- declare const ALL_SHARED_RULES: readonly ["content-quality", "seo-rules", "i18n-quality", "accessibility-rules", "security-rules", "media-rules", "content-conventions", "schema-rules", "mcp-usage", "workflow-rules", "normalize-rules"];
16
- declare const IDE_RULE_FILES: {
17
- readonly 'claude-code': "ide/claude-code/contentrain.md";
18
- readonly cursor: "ide/cursor/contentrain.cursorrules";
19
- readonly windsurf: "ide/windsurf/contentrain.windsurfrules";
20
- readonly generic: "ide/generic/contentrain.md";
21
- };
22
- type IdeTarget = keyof typeof IDE_RULE_FILES;
13
+ declare const ESSENTIAL_RULES_FILE: "essential/contentrain-essentials.md";
23
14
  declare const STACKS: readonly ["nuxt", "next", "astro", "sveltekit", "react", "node"];
24
15
  type Stack = (typeof STACKS)[number];
25
16
  //#endregion
26
- export { ALL_SHARED_RULES, ARCHITECTURE_RULES, CONTENT_QUALITY_RULES, FIELD_TYPES, FieldType, IDE_RULE_FILES, IdeTarget, MCP_TOOLS, MODEL_KINDS, McpTool, ModelKind, STACKS, Stack };
17
+ export { ESSENTIAL_RULES_FILE, FIELD_TYPES, FieldType, MCP_TOOLS, MODEL_KINDS, McpTool, ModelKind, STACKS, Stack };
27
18
  //# sourceMappingURL=index.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.mts","names":[],"sources":["../src/index.ts"],"mappings":";;AAQA;;;;cAAa,WAAA;AAAA,KAUD,SAAA,WAAoB,WAAA;AAAA,cAInB,WAAA;AAAA,KACD,SAAA,WAAoB,WAAA;AAAA,cAInB,SAAA;AAAA,KAUD,OAAA,WAAkB,SAAA;AAAA,cAIjB,qBAAA;AAAA,cAKA,kBAAA;AAAA,cAKA,gBAAA;AAAA,cAIA,cAAA;EAAA;;;;;KAOD,SAAA,gBAAyB,cAAA;AAAA,cAIxB,MAAA;AAAA,KACD,KAAA,WAAgB,MAAA"}
1
+ {"version":3,"file":"index.d.mts","names":[],"sources":["../src/index.ts"],"mappings":";;AAQA;;;;cAAa,WAAA;AAAA,KAUD,SAAA,WAAoB,WAAA;AAAA,cAInB,WAAA;AAAA,KACD,SAAA,WAAoB,WAAA;AAAA,cAInB,SAAA;AAAA,KAUD,OAAA,WAAkB,SAAA;AAAA,cAIjB,oBAAA;AAAA,cAIA,MAAA;AAAA,KACD,KAAA,WAAgB,MAAA"}
package/dist/index.mjs CHANGED
@@ -56,28 +56,7 @@ const MCP_TOOLS = [
56
56
  "contentrain_submit",
57
57
  "contentrain_bulk"
58
58
  ];
59
- const CONTENT_QUALITY_RULES = [
60
- "content-quality",
61
- "seo-rules",
62
- "i18n-quality",
63
- "accessibility-rules",
64
- "security-rules",
65
- "media-rules"
66
- ];
67
- const ARCHITECTURE_RULES = [
68
- "content-conventions",
69
- "schema-rules",
70
- "mcp-usage",
71
- "workflow-rules",
72
- "normalize-rules"
73
- ];
74
- const ALL_SHARED_RULES = [...CONTENT_QUALITY_RULES, ...ARCHITECTURE_RULES];
75
- const IDE_RULE_FILES = {
76
- "claude-code": "ide/claude-code/contentrain.md",
77
- "cursor": "ide/cursor/contentrain.cursorrules",
78
- "windsurf": "ide/windsurf/contentrain.windsurfrules",
79
- "generic": "ide/generic/contentrain.md"
80
- };
59
+ const ESSENTIAL_RULES_FILE = "essential/contentrain-essentials.md";
81
60
  const STACKS = [
82
61
  "nuxt",
83
62
  "next",
@@ -87,6 +66,6 @@ const STACKS = [
87
66
  "node"
88
67
  ];
89
68
  //#endregion
90
- export { ALL_SHARED_RULES, ARCHITECTURE_RULES, CONTENT_QUALITY_RULES, FIELD_TYPES, IDE_RULE_FILES, MCP_TOOLS, MODEL_KINDS, STACKS };
69
+ export { ESSENTIAL_RULES_FILE, FIELD_TYPES, MCP_TOOLS, MODEL_KINDS, STACKS };
91
70
 
92
71
  //# sourceMappingURL=index.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","names":[],"sources":["../src/index.ts"],"sourcesContent":["/**\n * @contentrain/rules — AI agent rules for Contentrain\n *\n * Quality standards, architecture conventions, and IDE integration.\n */\n\n// ─── Field Types (27 flat types) ───\n\nexport const FIELD_TYPES = [\n 'string', 'text', 'email', 'url', 'slug', 'color', 'phone', 'code', 'icon',\n 'markdown', 'richtext',\n 'number', 'integer', 'decimal', 'percent', 'rating',\n 'boolean', 'date', 'datetime',\n 'image', 'video', 'file',\n 'relation', 'relations',\n 'select', 'array', 'object',\n] as const\n\nexport type FieldType = (typeof FIELD_TYPES)[number]\n\n// ─── Model Kinds ───\n\nexport const MODEL_KINDS = ['singleton', 'collection', 'document', 'dictionary'] as const\nexport type ModelKind = (typeof MODEL_KINDS)[number]\n\n// ─── MCP Tools (15 tools) ───\n\nexport const MCP_TOOLS = [\n 'contentrain_status', 'contentrain_describe', 'contentrain_describe_format',\n 'contentrain_init', 'contentrain_scaffold',\n 'contentrain_model_save', 'contentrain_model_delete',\n 'contentrain_content_save', 'contentrain_content_delete', 'contentrain_content_list',\n 'contentrain_scan', 'contentrain_apply',\n 'contentrain_validate', 'contentrain_submit',\n 'contentrain_bulk',\n] as const\n\nexport type McpTool = (typeof MCP_TOOLS)[number]\n\n// ─── Rule Sets ───\n\nexport const CONTENT_QUALITY_RULES = [\n 'content-quality', 'seo-rules', 'i18n-quality',\n 'accessibility-rules', 'security-rules', 'media-rules',\n] as const\n\nexport const ARCHITECTURE_RULES = [\n 'content-conventions', 'schema-rules', 'mcp-usage',\n 'workflow-rules', 'normalize-rules',\n] as const\n\nexport const ALL_SHARED_RULES = [...CONTENT_QUALITY_RULES, ...ARCHITECTURE_RULES] as const\n\n// ─── IDE Rule Paths ───\n\nexport const IDE_RULE_FILES = {\n 'claude-code': 'ide/claude-code/contentrain.md',\n 'cursor': 'ide/cursor/contentrain.cursorrules',\n 'windsurf': 'ide/windsurf/contentrain.windsurfrules',\n 'generic': 'ide/generic/contentrain.md',\n} as const\n\nexport type IdeTarget = keyof typeof IDE_RULE_FILES\n\n// ─── Stacks ───\n\nexport const STACKS = ['nuxt', 'next', 'astro', 'sveltekit', 'react', 'node'] as const\nexport type Stack = (typeof STACKS)[number]\n"],"mappings":";;;;;;AAQA,MAAa,cAAc;CACzB;CAAU;CAAQ;CAAS;CAAO;CAAQ;CAAS;CAAS;CAAQ;CACpE;CAAY;CACZ;CAAU;CAAW;CAAW;CAAW;CAC3C;CAAW;CAAQ;CACnB;CAAS;CAAS;CAClB;CAAY;CACZ;CAAU;CAAS;CACpB;AAMD,MAAa,cAAc;CAAC;CAAa;CAAc;CAAY;CAAa;AAKhF,MAAa,YAAY;CACvB;CAAsB;CAAwB;CAC9C;CAAoB;CACpB;CAA0B;CAC1B;CAA4B;CAA8B;CAC1D;CAAoB;CACpB;CAAwB;CACxB;CACD;AAMD,MAAa,wBAAwB;CACnC;CAAmB;CAAa;CAChC;CAAuB;CAAkB;CAC1C;AAED,MAAa,qBAAqB;CAChC;CAAuB;CAAgB;CACvC;CAAkB;CACnB;AAED,MAAa,mBAAmB,CAAC,GAAG,uBAAuB,GAAG,mBAAmB;AAIjF,MAAa,iBAAiB;CAC5B,eAAe;CACf,UAAU;CACV,YAAY;CACZ,WAAW;CACZ;AAMD,MAAa,SAAS;CAAC;CAAQ;CAAQ;CAAS;CAAa;CAAS;CAAO"}
1
+ {"version":3,"file":"index.mjs","names":[],"sources":["../src/index.ts"],"sourcesContent":["/**\n * @contentrain/rules — AI agent rules for Contentrain\n *\n * Quality standards, architecture conventions, and IDE integration.\n */\n\n// ─── Field Types (27 flat types) ───\n\nexport const FIELD_TYPES = [\n 'string', 'text', 'email', 'url', 'slug', 'color', 'phone', 'code', 'icon',\n 'markdown', 'richtext',\n 'number', 'integer', 'decimal', 'percent', 'rating',\n 'boolean', 'date', 'datetime',\n 'image', 'video', 'file',\n 'relation', 'relations',\n 'select', 'array', 'object',\n] as const\n\nexport type FieldType = (typeof FIELD_TYPES)[number]\n\n// ─── Model Kinds ───\n\nexport const MODEL_KINDS = ['singleton', 'collection', 'document', 'dictionary'] as const\nexport type ModelKind = (typeof MODEL_KINDS)[number]\n\n// ─── MCP Tools (15 tools) ───\n\nexport const MCP_TOOLS = [\n 'contentrain_status', 'contentrain_describe', 'contentrain_describe_format',\n 'contentrain_init', 'contentrain_scaffold',\n 'contentrain_model_save', 'contentrain_model_delete',\n 'contentrain_content_save', 'contentrain_content_delete', 'contentrain_content_list',\n 'contentrain_scan', 'contentrain_apply',\n 'contentrain_validate', 'contentrain_submit',\n 'contentrain_bulk',\n] as const\n\nexport type McpTool = (typeof MCP_TOOLS)[number]\n\n// ─── Essential Rules ───\n\nexport const ESSENTIAL_RULES_FILE = 'essential/contentrain-essentials.md' as const\n\n// ─── Stacks ───\n\nexport const STACKS = ['nuxt', 'next', 'astro', 'sveltekit', 'react', 'node'] as const\nexport type Stack = (typeof STACKS)[number]\n"],"mappings":";;;;;;AAQA,MAAa,cAAc;CACzB;CAAU;CAAQ;CAAS;CAAO;CAAQ;CAAS;CAAS;CAAQ;CACpE;CAAY;CACZ;CAAU;CAAW;CAAW;CAAW;CAC3C;CAAW;CAAQ;CACnB;CAAS;CAAS;CAClB;CAAY;CACZ;CAAU;CAAS;CACpB;AAMD,MAAa,cAAc;CAAC;CAAa;CAAc;CAAY;CAAa;AAKhF,MAAa,YAAY;CACvB;CAAsB;CAAwB;CAC9C;CAAoB;CACpB;CAA0B;CAC1B;CAA4B;CAA8B;CAC1D;CAAoB;CACpB;CAAwB;CACxB;CACD;AAMD,MAAa,uBAAuB;AAIpC,MAAa,SAAS;CAAC;CAAQ;CAAQ;CAAS;CAAa;CAAS;CAAO"}
@@ -0,0 +1,91 @@
1
+ # Contentrain — Essential Rules
2
+
3
+ This project uses Contentrain for AI-driven content management. These rules are mandatory.
4
+
5
+ ## Architecture
6
+
7
+ MCP is **deterministic infrastructure**. The agent (you) is the **intelligence layer**.
8
+
9
+ - **Agent decides:** what is content vs code, domain grouping, model structure, replacement expressions (stack-aware), content quality
10
+ - **MCP handles:** file I/O, validation, Git transactions (dedicated contentrain branch/worktree/commit/update-ref), project scanning
11
+ - MCP does NOT make content decisions. It is framework-agnostic.
12
+
13
+ ## Four Model Kinds
14
+
15
+ | Kind | Storage | Use For |
16
+ |------|---------|---------|
17
+ | **singleton** | One JSON object per locale | Page sections, site config, navigation |
18
+ | **collection** | Object-map by entry ID (sorted keys) | Team members, FAQs, products, categories |
19
+ | **document** | Markdown with frontmatter, per slug per locale | Blog posts, docs, changelogs |
20
+ | **dictionary** | Flat key-value (all strings), NO fields, NO id/slug | UI strings, error messages, translations |
21
+
22
+ ## Content Format Rules
23
+
24
+ - **JSON only** — no YAML (except document frontmatter)
25
+ - **Canonical serialization:** sorted keys, 2-space indent, UTF-8, trailing newline, omit nulls
26
+ - **Collection IDs:** auto-generated 12-char hex, used as object-map keys (NOT stored inside entry)
27
+ - **Dictionary keys:** dot-notation, semantic, English (`auth.login.button`)
28
+
29
+ ## Critical Boundaries
30
+
31
+ - **NEVER** write to `.contentrain/meta/` — system-managed metadata
32
+ - **NEVER** edit `.contentrain/client/` — auto-generated SDK
33
+ - **NEVER** edit `.contentrain/context.json` — MCP writes, agents read
34
+ - **NEVER** include system fields in content data: `id`, `status`, `source`, `updated_by`, `updated_at`, `createdAt`, `updatedAt`
35
+ - **ALWAYS** use MCP tools — do not write `.contentrain/` JSON files directly
36
+
37
+ ## MCP Tools
38
+
39
+ | Tool | Purpose |
40
+ |------|---------|
41
+ | `contentrain_status` | Full project state (call FIRST in every session) |
42
+ | `contentrain_describe` | Schema + sample for one model |
43
+ | `contentrain_describe_format` | Storage format contract (call BEFORE creating models) |
44
+ | `contentrain_init` | Initialize `.contentrain/` directory |
45
+ | `contentrain_scaffold` | Generate models from template |
46
+ | `contentrain_model_save` | Create/update model definition (upsert) |
47
+ | `contentrain_model_delete` | Delete model (checks referential integrity) |
48
+ | `contentrain_content_save` | Create/update content entries (upsert) |
49
+ | `contentrain_content_delete` | Delete content entry |
50
+ | `contentrain_content_list` | List entries for a model |
51
+ | `contentrain_scan` | Scan project (graph/candidates/summary) |
52
+ | `contentrain_apply` | Apply normalize (extract/reuse) |
53
+ | `contentrain_validate` | Validate content against schemas |
54
+ | `contentrain_submit` | Push branches to remote |
55
+ | `contentrain_bulk` | Batch operations (copy_locale/update_status/delete_entries) |
56
+
57
+ ## Mandatory Protocols
58
+
59
+ 1. **Status first** — ALWAYS call `contentrain_status` before any operation on an existing project
60
+ 2. **Describe format first** — ALWAYS call `contentrain_describe_format` before creating models or content
61
+ 3. **Dry run first** — ALWAYS use `dry_run: true` before any `contentrain_apply`, review output, then `dry_run: false`
62
+ 4. **Validate before submit** — ALWAYS call `contentrain_validate` before `contentrain_submit`
63
+ 5. **Batch changes** — group related saves, validate once, submit once
64
+ 6. **Normalize = review** — normalize operations ALWAYS use review workflow, never auto-merge
65
+
66
+ ## Git Workflow
67
+
68
+ - A dedicated `contentrain` branch is the single source of truth for content state, created at init
69
+ - Every write operation creates a temporary worktree on the `contentrain` branch automatically
70
+ - Feature branches (`contentrain/{operation}/{model}/{locale}/{timestamp}`) are created from `contentrain` for each operation
71
+ - **auto-merge** mode: feature branch merges into `contentrain`, then `contentrain` advances baseBranch via update-ref (fast-forward), then `.contentrain/` files are selectively synced to the developer's working tree
72
+ - **review** mode: feature branch pushed to remote for team review
73
+ - Developer's working tree is never mutated during MCP git operations (no stash, no checkout, no merge on the developer's tree)
74
+ - If the developer manually edits `.contentrain/` files, MCP sync skips dirty files and warns
75
+ - The `contentrain` branch is protected from deletion
76
+ - context.json is committed together with content changes, not as a separate commit
77
+ - Never create branches manually, never commit directly to main or the `contentrain` branch
78
+ - 50+ active branches = warning, 80+ = blocked
79
+
80
+ ## Localization
81
+
82
+ - All supported locales must have entries for every content item
83
+ - Collection entry IDs and dictionary keys must match across all locales
84
+ - IDs and slugs are locale-agnostic — same reference works everywhere
85
+
86
+ ## Security
87
+
88
+ - No `<script>`, `javascript:`, or event handlers in richtext/markdown
89
+ - No secrets (API keys, tokens, passwords) in any content field
90
+ - URLs must use `https://` (except localhost). No `file://`, no path traversal
91
+ - Media paths must be relative to `assets_path`, no absolute system paths
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@contentrain/rules",
3
- "version": "0.2.0",
3
+ "version": "0.3.1",
4
4
  "license": "MIT",
5
5
  "description": "AI agent rules for Contentrain — quality standards, architecture conventions, IDE integration",
6
6
  "type": "module",
@@ -34,27 +34,24 @@
34
34
  "require": "./dist/index.cjs",
35
35
  "default": "./dist/index.mjs"
36
36
  },
37
- "./shared/*": "./shared/*",
37
+ "./essential/*": "./essential/*",
38
38
  "./prompts/*": "./prompts/*",
39
- "./context/*": "./context/*",
40
- "./ide/*": "./ide/*"
39
+ "./context/*": "./context/*"
41
40
  },
42
41
  "files": [
43
42
  "dist",
44
- "shared",
43
+ "essential",
45
44
  "prompts",
46
- "context",
47
- "ide"
45
+ "context"
48
46
  ],
49
47
  "devDependencies": {
50
48
  "@types/node": "^22.0.0",
51
49
  "tsdown": "^0.21.0",
52
- "tsx": "^4.0.0",
53
50
  "typescript": "^5.7.0",
54
51
  "vitest": "^3.0.0"
55
52
  },
56
53
  "scripts": {
57
- "build": "tsdown src/index.ts --format esm,cjs --dts && node --import tsx scripts/build-rules.ts",
54
+ "build": "tsdown src/index.ts --format esm,cjs --dts",
58
55
  "test": "vitest run",
59
56
  "typecheck": "tsc --noEmit"
60
57
  }
@@ -173,7 +173,7 @@ Call `contentrain_validate` after all content is created.
173
173
 
174
174
  Call `contentrain_submit` to finalize.
175
175
 
176
- - In `auto-merge` mode: branch is merged to main, content is published.
176
+ - In `auto-merge` mode: feature branch is merged into `contentrain`, baseBranch is advanced via update-ref, `.contentrain/` files are selectively synced to the developer's working tree, content is published.
177
177
  - In `review` mode: branch is pushed to remote for team review.
178
178
  - Normalize operations always use review mode regardless of config.
179
179