@contentrain/rules 0.3.0 → 0.3.2
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,10 +1,17 @@
|
|
|
1
1
|
# `@contentrain/rules`
|
|
2
2
|
|
|
3
3
|
[](https://www.npmjs.com/package/@contentrain/rules)
|
|
4
|
+
[](https://agentskills.io)
|
|
4
5
|
[](https://github.com/Contentrain/ai/tree/main/packages/rules)
|
|
6
|
+
[](https://ai.contentrain.io/packages/rules)
|
|
5
7
|
|
|
6
8
|
Shared AI-agent rules for Contentrain.
|
|
7
9
|
|
|
10
|
+
Start here:
|
|
11
|
+
|
|
12
|
+
- [2-minute product demo](https://ai.contentrain.io/demo)
|
|
13
|
+
- [Rules & skills docs](https://ai.contentrain.io/packages/rules)
|
|
14
|
+
|
|
8
15
|
This package is the policy layer of the Contentrain ecosystem. It defines how agents should behave when they work with:
|
|
9
16
|
|
|
10
17
|
- Contentrain MCP tools
|
|
@@ -89,6 +96,8 @@ Rule of thumb:
|
|
|
89
96
|
- `rules` = essential guardrails (always loaded, ~86 lines)
|
|
90
97
|
- `skills` = detailed procedures and reference docs (on-demand)
|
|
91
98
|
|
|
99
|
+
See [`AGENTS.md`](../../AGENTS.md) at the repo root for agent-level project guidance.
|
|
100
|
+
|
|
92
101
|
## Build
|
|
93
102
|
|
|
94
103
|
From the monorepo root:
|
|
@@ -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 (
|
|
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`
|
|
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
|
|
@@ -7,7 +7,7 @@ This project uses Contentrain for AI-driven content management. These rules are
|
|
|
7
7
|
MCP is **deterministic infrastructure**. The agent (you) is the **intelligence layer**.
|
|
8
8
|
|
|
9
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/
|
|
10
|
+
- **MCP handles:** file I/O, validation, Git transactions (dedicated contentrain branch/worktree/commit/update-ref), project scanning
|
|
11
11
|
- MCP does NOT make content decisions. It is framework-agnostic.
|
|
12
12
|
|
|
13
13
|
## Four Model Kinds
|
|
@@ -52,6 +52,7 @@ MCP is **deterministic infrastructure**. The agent (you) is the **intelligence l
|
|
|
52
52
|
| `contentrain_apply` | Apply normalize (extract/reuse) |
|
|
53
53
|
| `contentrain_validate` | Validate content against schemas |
|
|
54
54
|
| `contentrain_submit` | Push branches to remote |
|
|
55
|
+
| `contentrain_merge` | Merge a review-mode branch into contentrain locally |
|
|
55
56
|
| `contentrain_bulk` | Batch operations (copy_locale/update_status/delete_entries) |
|
|
56
57
|
|
|
57
58
|
## Mandatory Protocols
|
|
@@ -65,13 +66,45 @@ MCP is **deterministic infrastructure**. The agent (you) is the **intelligence l
|
|
|
65
66
|
|
|
66
67
|
## Git Workflow
|
|
67
68
|
|
|
68
|
-
-
|
|
69
|
-
-
|
|
70
|
-
-
|
|
71
|
-
-
|
|
72
|
-
-
|
|
69
|
+
- A dedicated `contentrain` branch is the single source of truth for content state, created at init
|
|
70
|
+
- Every write operation creates a temporary worktree on the `contentrain` branch automatically
|
|
71
|
+
- Feature branches (`contentrain/{operation}/{model}/{locale}/{timestamp}`) are created from `contentrain` for each operation
|
|
72
|
+
- **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
|
|
73
|
+
- **review** mode: feature branch pushed to remote for team review
|
|
74
|
+
- Developer's working tree is never mutated during MCP git operations (no stash, no checkout, no merge on the developer's tree)
|
|
75
|
+
- If the developer manually edits `.contentrain/` files, MCP sync skips dirty files and warns
|
|
76
|
+
- The `contentrain` branch is protected from deletion
|
|
77
|
+
- context.json is committed together with content changes, not as a separate commit
|
|
78
|
+
- Never create branches manually, never commit directly to main or the `contentrain` branch
|
|
73
79
|
- 50+ active branches = warning, 80+ = blocked
|
|
74
80
|
|
|
81
|
+
## CLI Serve — Review & Approval
|
|
82
|
+
|
|
83
|
+
Normalize and review workflows often need browser-based approval:
|
|
84
|
+
|
|
85
|
+
```bash
|
|
86
|
+
contentrain serve # starts http://localhost:3333
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
Key pages: `/normalize` (extraction approval), `/branches` (merge/delete), `/validate` (error review), `/content` (browse).
|
|
90
|
+
|
|
91
|
+
Agent should start or ensure serve is running when:
|
|
92
|
+
- Normalize extraction needs user approval
|
|
93
|
+
- Multiple branches await review
|
|
94
|
+
- Validation errors need visual inspection
|
|
95
|
+
|
|
96
|
+
Branch merge options: CLI serve UI (localhost:3333/branches), `contentrain_merge` MCP tool, or git platform PR.
|
|
97
|
+
|
|
98
|
+
## SDK Regeneration
|
|
99
|
+
|
|
100
|
+
After model/content changes or normalize reuse, run:
|
|
101
|
+
|
|
102
|
+
```bash
|
|
103
|
+
npx contentrain generate
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
This regenerates `.contentrain/client/` — required for `#contentrain` imports to work.
|
|
107
|
+
|
|
75
108
|
## Localization
|
|
76
109
|
|
|
77
110
|
- All supported locales must have entries for every content item
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@contentrain/rules",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.2",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "AI agent rules for Contentrain — quality standards, architecture conventions, IDE integration",
|
|
6
6
|
"type": "module",
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
"url": "git+https://github.com/Contentrain/ai.git",
|
|
10
10
|
"directory": "packages/rules"
|
|
11
11
|
},
|
|
12
|
-
"homepage": "https://
|
|
12
|
+
"homepage": "https://ai.contentrain.io/packages/rules",
|
|
13
13
|
"bugs": {
|
|
14
14
|
"url": "https://github.com/Contentrain/ai/issues"
|
|
15
15
|
},
|
|
@@ -17,11 +17,15 @@
|
|
|
17
17
|
"contentrain",
|
|
18
18
|
"ai",
|
|
19
19
|
"rules",
|
|
20
|
+
"agent-skills",
|
|
21
|
+
"agent-rules",
|
|
20
22
|
"mcp",
|
|
21
23
|
"prompt-engineering",
|
|
22
24
|
"claude-code",
|
|
23
25
|
"cursor",
|
|
24
|
-
"windsurf"
|
|
26
|
+
"windsurf",
|
|
27
|
+
"copilot",
|
|
28
|
+
"codex"
|
|
25
29
|
],
|
|
26
30
|
"sideEffects": false,
|
|
27
31
|
"publishConfig": {
|
package/prompts/generate-mode.md
CHANGED
|
@@ -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
|
|
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
|
|