@contentrain/rules 0.1.0 โ†’ 0.3.0

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/README.md CHANGED
@@ -1,5 +1,8 @@
1
1
  # `@contentrain/rules`
2
2
 
3
+ [![npm version](https://img.shields.io/npm/v/%40contentrain%2Frules?label=%40contentrain%2Frules)](https://www.npmjs.com/package/@contentrain/rules)
4
+ [![GitHub source](https://img.shields.io/badge/source-Contentrain%2Fai-181717?logo=github)](https://github.com/Contentrain/ai/tree/main/packages/rules)
5
+
3
6
  Shared AI-agent rules for Contentrain.
4
7
 
5
8
  This package is the policy layer of the Contentrain ecosystem. It defines how agents should behave when they work with:
@@ -9,33 +12,22 @@ This package is the policy layer of the Contentrain ecosystem. It defines how ag
9
12
  - content quality
10
13
  - normalize workflows
11
14
  - git-backed review flows
12
- - IDE rule distribution
13
15
 
14
16
  If `@contentrain/mcp` is the deterministic execution layer, `@contentrain/rules` is the behavioral contract.
15
17
 
16
- ## ๐Ÿš€ Install
18
+ ## Install
17
19
 
18
20
  ```bash
19
21
  pnpm add @contentrain/rules
20
22
  ```
21
23
 
22
- ## ๐Ÿ“ฆ What It Contains
24
+ ## What It Contains
23
25
 
24
- ### Shared rule sets
26
+ ### Essential guardrails
25
27
 
26
- Published under `shared/*`:
28
+ Published under `essential/*`:
27
29
 
28
- - `content-quality.md`
29
- - `seo-rules.md`
30
- - `i18n-quality.md`
31
- - `accessibility-rules.md`
32
- - `security-rules.md`
33
- - `media-rules.md`
34
- - `content-conventions.md`
35
- - `schema-rules.md`
36
- - `mcp-usage.md`
37
- - `workflow-rules.md`
38
- - `normalize-rules.md`
30
+ - `contentrain-essentials.md` โ€” compact, always-loaded rules (~86 lines) covering architecture, model kinds, MCP tools, mandatory protocols, and security basics
39
31
 
40
32
  ### Prompt layers
41
33
 
@@ -52,39 +44,27 @@ Published under `context/*`:
52
44
 
53
45
  - `context-bridge.md`
54
46
 
55
- ### IDE bundles
56
-
57
- Published under `ide/*`:
58
-
59
- - `ide/claude-code/contentrain.md`
60
- - `ide/cursor/contentrain.cursorrules`
61
- - `ide/windsurf/contentrain.windsurfrules`
62
- - `ide/generic/contentrain.md`
63
-
64
- ## ๐Ÿงฐ Public Exports
47
+ ## Public Exports
65
48
 
66
49
  The package root exports constants that can be used by tooling:
67
50
 
68
- - `FIELD_TYPES`
69
- - `MODEL_KINDS`
70
- - `MCP_TOOLS`
71
- - `CONTENT_QUALITY_RULES`
72
- - `ARCHITECTURE_RULES`
73
- - `ALL_SHARED_RULES`
74
- - `IDE_RULE_FILES`
75
- - `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
76
56
 
77
- ## ๐Ÿงช Example
57
+ ## Example
78
58
 
79
59
  ```ts
80
- import { IDE_RULE_FILES, MCP_TOOLS, ALL_SHARED_RULES } from '@contentrain/rules'
60
+ import { MCP_TOOLS, ESSENTIAL_RULES_FILE, FIELD_TYPES } from '@contentrain/rules'
81
61
 
82
62
  console.log(MCP_TOOLS.includes('contentrain_validate'))
83
- console.log(IDE_RULE_FILES['claude-code'])
84
- console.log(ALL_SHARED_RULES)
63
+ console.log(ESSENTIAL_RULES_FILE) // 'essential/contentrain-essentials.md'
64
+ console.log(FIELD_TYPES.length) // 27
85
65
  ```
86
66
 
87
- ## ๐Ÿง  Design Role
67
+ ## Design Role
88
68
 
89
69
  `@contentrain/rules` exists to keep agent behavior aligned across tools and environments.
90
70
 
@@ -94,26 +74,22 @@ It should answer questions like:
94
74
  - How should an agent use MCP tools?
95
75
  - What is the normalize contract?
96
76
  - What workflow and review constraints exist?
97
- - How should rules be packaged for Claude Code, Cursor, Windsurf, and generic agents?
98
77
 
99
- ## ๐Ÿ”— 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
100
81
 
101
82
  - `@contentrain/mcp` enforces file, validation, and git behavior
102
- - `@contentrain/skills` provides step-by-step workflow playbooks
83
+ - `@contentrain/skills` provides Agent Skills with progressive disclosure (SKILL.md + references/)
103
84
  - `contentrain` exposes CLI and serve UX
104
85
  - `@contentrain/query` is the generated runtime consumption layer
105
86
 
106
87
  Rule of thumb:
107
88
 
108
- - `rules` = policy and constraints
109
- - `skills` = procedures and playbooks
110
-
111
- ## ๐Ÿ›  Build
112
-
113
- The build does two things:
89
+ - `rules` = essential guardrails (always loaded, ~86 lines)
90
+ - `skills` = detailed procedures and reference docs (on-demand)
114
91
 
115
- 1. builds the typed JS entry from `src/index.ts`
116
- 2. generates IDE bundle files from the shared markdown rules
92
+ ## Build
117
93
 
118
94
  From the monorepo root:
119
95
 
@@ -123,6 +99,6 @@ pnpm --filter @contentrain/rules test
123
99
  pnpm --filter @contentrain/rules typecheck
124
100
  ```
125
101
 
126
- ## ๐Ÿ“„ License
102
+ ## License
127
103
 
128
104
  MIT
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,86 @@
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 (worktree/branch/commit/merge), 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
+ - Every write operation creates a worktree + branch automatically
69
+ - **auto-merge** mode: branch merges to main after commit
70
+ - **review** mode: branch pushed to remote for team review
71
+ - Branch naming: `contentrain/{operation}/{model}/{locale}/{timestamp}`
72
+ - Never create branches manually, never commit directly to main
73
+ - 50+ active branches = warning, 80+ = blocked
74
+
75
+ ## Localization
76
+
77
+ - All supported locales must have entries for every content item
78
+ - Collection entry IDs and dictionary keys must match across all locales
79
+ - IDs and slugs are locale-agnostic โ€” same reference works everywhere
80
+
81
+ ## Security
82
+
83
+ - No `<script>`, `javascript:`, or event handlers in richtext/markdown
84
+ - No secrets (API keys, tokens, passwords) in any content field
85
+ - URLs must use `https://` (except localhost). No `file://`, no path traversal
86
+ - Media paths must be relative to `assets_path`, no absolute system paths
package/package.json CHANGED
@@ -1,17 +1,17 @@
1
1
  {
2
2
  "name": "@contentrain/rules",
3
- "version": "0.1.0",
3
+ "version": "0.3.0",
4
4
  "license": "MIT",
5
5
  "description": "AI agent rules for Contentrain โ€” quality standards, architecture conventions, IDE integration",
6
6
  "type": "module",
7
7
  "repository": {
8
8
  "type": "git",
9
- "url": "git+https://github.com/contentrain/contentrain-ai.git",
9
+ "url": "git+https://github.com/Contentrain/ai.git",
10
10
  "directory": "packages/rules"
11
11
  },
12
- "homepage": "https://github.com/contentrain/contentrain-ai/tree/main/packages/rules",
12
+ "homepage": "https://github.com/Contentrain/ai/tree/main/packages/rules",
13
13
  "bugs": {
14
- "url": "https://github.com/contentrain/contentrain-ai/issues"
14
+ "url": "https://github.com/Contentrain/ai/issues"
15
15
  },
16
16
  "keywords": [
17
17
  "contentrain",
@@ -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
  }