@contentrain/skills 0.1.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.
@@ -0,0 +1,88 @@
1
+ # Skill: Review the Project with `contentrain serve`
2
+
3
+ > Start the local review UI as a bridge between agent and developer.
4
+
5
+ ---
6
+
7
+ ## When to Use
8
+
9
+ Use this when:
10
+
11
+ - a normalize plan, branch, or validation result needs developer review
12
+ - the developer wants to browse models, content, or history visually
13
+ - another skill needs to hand off to the UI for approval (normalize, review)
14
+
15
+ ---
16
+
17
+ ## Steps
18
+
19
+ ### 1. Check if Serve is Already Running
20
+
21
+ Before starting a new instance, check if port 3333 is already in use:
22
+
23
+ ```bash
24
+ lsof -ti:3333
25
+ ```
26
+
27
+ If a process is running, serve is already up — skip to Step 3.
28
+
29
+ ### 2. Start Serve
30
+
31
+ Run from the project root (where `.contentrain/` lives):
32
+
33
+ ```bash
34
+ contentrain serve
35
+ ```
36
+
37
+ Optional flags:
38
+
39
+ - `--port` (default: 3333)
40
+ - `--host` (default: localhost)
41
+ - `--open=false` (prevent auto-opening browser)
42
+ - `--stdio` (MCP stdio transport for IDE integration — no web UI)
43
+
44
+ Wait for the "Contentrain Serve" banner confirming the server is ready.
45
+
46
+ ### 3. Direct the Developer to the Right Page
47
+
48
+ Based on the current context, tell the developer exactly where to go:
49
+
50
+ | Context | URL | What to do |
51
+ |---|---|---|
52
+ | Normalize plan ready | `http://localhost:3333/normalize` | Review extractions, approve or reject |
53
+ | Pending branches | `http://localhost:3333/branches` | Review and merge branches |
54
+ | Validation issues | `http://localhost:3333/validate` | Inspect errors and warnings |
55
+ | Content browsing | `http://localhost:3333/content` | Browse entries and models |
56
+ | General overview | `http://localhost:3333` | Dashboard with project stats |
57
+
58
+ ### 4. Wait for Developer Action
59
+
60
+ After directing the developer to the UI:
61
+
62
+ - **Normalize flow:** Check `.contentrain/normalize-plan.json` — if deleted, check for new branches to determine approve vs reject
63
+ - **Branch flow:** Check branch list — if branch was merged or deleted, proceed accordingly
64
+ - **Validation flow:** Re-read validation results after developer reviews
65
+
66
+ The UI communicates back through filesystem changes (plan files, branches, context.json). Poll these to detect the developer's decision.
67
+
68
+ ### 5. Resume the Workflow
69
+
70
+ After the developer acts in the UI:
71
+
72
+ - If **approved**: continue with the next step in the calling skill (validate, submit, Phase 2)
73
+ - If **rejected**: ask the developer what to change and iterate
74
+ - If **merged**: confirm and report the final state
75
+
76
+ Do NOT leave the developer hanging — always follow up after UI interaction.
77
+
78
+ ---
79
+
80
+ ## UI Philosophy
81
+
82
+ The serve UI is a **monitoring + approval surface**, not an action trigger:
83
+
84
+ - **Monitoring**: models, content, validation, history, branches — read-only browsing
85
+ - **Approval**: approve/reject normalize plans, merge/delete branches — human decisions
86
+ - **Prompts**: every page shows copyable agent prompts that developers paste into their AI agent
87
+
88
+ All mutations (create, edit, delete, scan, fix, normalize) are **agent-driven via MCP tools**. The UI never triggers these directly.
@@ -0,0 +1,172 @@
1
+ # Skill: Translate Content to a New Locale
2
+
3
+ > Translate existing content entries to a target locale, following i18n quality rules.
4
+
5
+ ---
6
+
7
+ ## When to Use
8
+
9
+ The user wants to translate content, add a new language, or says something like "translate to Turkish", "add German locale", "create French translations", "fill in missing translations", "localize".
10
+
11
+ ---
12
+
13
+ ## Steps
14
+
15
+ ### 1. Check Project State
16
+
17
+ Call `contentrain_status` to understand:
18
+
19
+ - Supported locales (from `config.json` → `locales.supported`).
20
+ - Source locale (from `config.json` → `locales.source`).
21
+ - Available models and their i18n status.
22
+ - Any pending changes or validation errors.
23
+
24
+ ### 2. Determine Target Locale
25
+
26
+ If the user specified a locale, use it. Otherwise:
27
+
28
+ - Ask which locale to translate to.
29
+ - If the target locale is not in `locales.supported`, inform the user it needs to be added to the configuration first.
30
+
31
+ ### 3. Select Models to Translate
32
+
33
+ Identify which models need translation:
34
+
35
+ - List all models with `i18n: true`.
36
+ - For each model, call `contentrain_content_list(model: "<modelId>", locale: "<sourceLocale>")` to get the source content.
37
+ - Check which models already have entries in the target locale by calling `contentrain_content_list(model: "<modelId>", locale: "<targetLocale>")`.
38
+ - Report the translation gap: how many entries exist in the source locale but not the target.
39
+
40
+ Ask the user which models to translate, or offer to translate all models with missing entries.
41
+
42
+ ### 4. Load Vocabulary
43
+
44
+ Read `.contentrain/vocabulary.json` for canonical term translations. All vocabulary-defined terms must use the exact translation specified for the target locale — do not create alternative translations.
45
+
46
+ ### 5. Translate Following i18n Rules
47
+
48
+ Apply the rules from `i18n-quality.md` during translation:
49
+
50
+ #### Translation Quality
51
+
52
+ - Translate meaning, not words. Produce idiomatic text in the target language.
53
+ - Match the sentence structure of the target language, not the source.
54
+ - Preserve the tone: if the source is casual, the translation must be casual. If formal, stay formal.
55
+ - Fix any machine-translation artifacts: literal translations, incorrect gender agreement, wrong register.
56
+
57
+ #### Vocabulary Alignment
58
+
59
+ - Check `.contentrain/vocabulary.json` for approved translations of terms in the target locale.
60
+ - Keep technical terms in their original form if no widely accepted translation exists (API, SDK, CLI, URL).
61
+ - Use brand terms exactly as specified per locale in the vocabulary.
62
+ - Do not alternate between synonyms — use the same translation for repeated terms throughout.
63
+
64
+ #### Cultural Adaptation
65
+
66
+ - Adapt idioms, metaphors, and culturally specific references. Do not translate literally when a cultural equivalent exists.
67
+ - Use locale-appropriate date formats, number formats, and units of measurement.
68
+ - Replace culturally specific references with locale-appropriate equivalents.
69
+ - Avoid idioms that do not translate — use target-language equivalents.
70
+
71
+ #### String Length Awareness
72
+
73
+ - Check field `max` constraints in the model definition.
74
+ - Account for expansion ratios: German +30-40%, French +15-25%, Chinese -30-50%.
75
+ - If a translation exceeds the field limit, rewrite it shorter. Never truncate mid-word.
76
+ - Pay special attention to UI strings (button labels, menu items) with tight space constraints.
77
+ - Flag any fields that hit `max` constraints.
78
+
79
+ #### Pluralization
80
+
81
+ - Use correct CLDR plural categories for the target language.
82
+ - English: `one`, `other`. German: `one`, `other`. Russian: `one`, `few`, `many`, `other`. Arabic: all six categories.
83
+
84
+ #### Preserve Non-Translatable Content
85
+
86
+ - Keep relation IDs, slugs, URLs, image paths, and code snippets unchanged — only translate human-readable text.
87
+ - Preserve markdown structure, HTML tags, line breaks, and whitespace patterns from the source.
88
+ - Entry IDs (object-map keys) remain the same across locales.
89
+
90
+ ### 6. Kind-Specific Rules
91
+
92
+ - **singleton:** Translate all string/text/markdown/richtext fields.
93
+ - **collection:** Translate each entry's fields. Use the same entry IDs across locales.
94
+ - **document:** Translate frontmatter fields and markdown body. Slug may stay the same or be localized (ask the user).
95
+ - **dictionary:** Translate all values. Keys remain identical across locales (e.g., `"auth.login"` key stays the same, value changes).
96
+
97
+ ### 7. Present Translations for Review
98
+
99
+ Show the user a side-by-side comparison:
100
+
101
+ ```
102
+ Model: hero (singleton)
103
+ Field: title
104
+ en: "Build faster with AI"
105
+ tr: "AI ile daha hizli gelistirin"
106
+
107
+ Field: description
108
+ en: "Ship content-driven apps in minutes"
109
+ tr: "Icerik odakli uygulamalari dakikalar icinde yayinlayin"
110
+ ```
111
+
112
+ Wait for user approval. The user may request adjustments to tone, phrasing, or terminology.
113
+
114
+ ### 7.5. Bulk Copy for New Locales
115
+
116
+ When translating a model to a brand-new locale, use `copy_locale` to bootstrap the target locale with source content before translating:
117
+
118
+ ```
119
+ contentrain_bulk({ operation: "copy_locale", model: "<model-id>", source_locale: "en", target_locale: "<target>" })
120
+ ```
121
+
122
+ This creates target locale files with the source content as a starting point. Then translate each entry's values in-place — keys and entry IDs remain identical.
123
+
124
+ After all translations are saved, re-generate the SDK client so the application picks up the new locale data:
125
+
126
+ ```bash
127
+ npx contentrain generate
128
+ ```
129
+
130
+ ### 8. Save Translations
131
+
132
+ After approval, call `contentrain_content_save` for each model and target locale:
133
+
134
+ ```
135
+ contentrain_content_save(model: "<model-id>", entries: [
136
+ { id: "<same-id>", locale: "<target-locale>", data: { ...translatedFields } }
137
+ ])
138
+ ```
139
+
140
+ Use the same `id` (for collections) or `slug` (for documents) as the source entry to maintain the cross-locale link. Batch all entries for a model in one call.
141
+
142
+ ### 9. Validate
143
+
144
+ Call `contentrain_validate` to verify:
145
+
146
+ - i18n completeness — all source locale keys exist in the target locale.
147
+ - Schema compliance — translated values respect field constraints (`min`, `max`, `pattern`).
148
+ - Vocabulary alignment — vocabulary terms match their canonical translations.
149
+ - Referential integrity — relation fields are unchanged and still valid.
150
+
151
+ If validation fails, fix issues and re-save.
152
+
153
+ ### 10. Submit
154
+
155
+ Call `contentrain_submit` to commit the translations:
156
+
157
+ - Branch: `contentrain/content/{model}/{targetLocale}/{timestamp}`.
158
+ - Each locale can be submitted independently.
159
+
160
+ ### 11. Final Summary
161
+
162
+ Report to the user:
163
+
164
+ - Models translated: X.
165
+ - Entries translated: X.
166
+ - Target locale(s): X.
167
+ - Vocabulary terms applied: X.
168
+ - Any fields that hit `max` constraints (flagged for review).
169
+ - Validation result.
170
+ - Submission status.
171
+ - Reminder to review translations for nuance that automated checks cannot catch.
172
+ - Suggestion: run `/contentrain-review` to verify overall i18n coverage.
@@ -0,0 +1,85 @@
1
+ # Skill: Validate and Fix Content Issues
2
+
3
+ > Diagnose validation failures, apply safe fixes, and re-check the project.
4
+
5
+ ---
6
+
7
+ ## When to Use
8
+
9
+ Use this when:
10
+
11
+ - validation reports errors or warnings
12
+ - the user asks to fix schema/content issues
13
+ - a write operation succeeded but the project still needs verification
14
+
15
+ ---
16
+
17
+ ## Steps
18
+
19
+ ### 1. Run Validation
20
+
21
+ Call `contentrain_validate` first.
22
+
23
+ Group results into:
24
+
25
+ - schema/type errors
26
+ - missing required fields
27
+ - relation integrity problems
28
+ - locale completeness issues
29
+ - canonical format warnings
30
+
31
+ ### 2. Decide Auto-fix vs Manual Fix
32
+
33
+ Auto-fix candidates:
34
+
35
+ - canonical formatting
36
+ - orphan metadata cleanup
37
+ - structural housekeeping reported by the validator
38
+
39
+ Manual fix candidates:
40
+
41
+ - missing required content
42
+ - wrong field values
43
+ - broken relations
44
+ - incorrect slugs/IDs
45
+
46
+ ### 3. Use Auto-fix Carefully
47
+
48
+ If the issues are structural, run:
49
+
50
+ ```json
51
+ {
52
+ "fix": true
53
+ }
54
+ ```
55
+
56
+ After that, validate again.
57
+
58
+ ### 4. Fix Semantic Errors
59
+
60
+ For real content or schema issues:
61
+
62
+ - inspect the model with `contentrain_describe`
63
+ - patch content with `contentrain_content_save`
64
+ - patch schema with `contentrain_model_save`
65
+
66
+ Do not claim the project is valid until validation is rerun.
67
+
68
+ ### 5. Re-run Validation
69
+
70
+ Call `contentrain_validate` again and compare:
71
+
72
+ - errors reduced to zero
73
+ - remaining warnings acknowledged
74
+
75
+ ### 6. Submit or Recommend Review
76
+
77
+ If validation is clean:
78
+
79
+ - call `contentrain_submit` when pending review branches exist
80
+
81
+ If validation still fails:
82
+
83
+ - summarize remaining blockers precisely
84
+ - tell the user which model/entry needs manual attention
85
+