stylemcp 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.
Files changed (83) hide show
  1. package/README.md +261 -0
  2. package/action/action.yml +59 -0
  3. package/action/package.json +24 -0
  4. package/action/src/index.ts +455 -0
  5. package/dist/cli/index.d.ts +3 -0
  6. package/dist/cli/index.d.ts.map +1 -0
  7. package/dist/cli/index.js +335 -0
  8. package/dist/cli/index.js.map +1 -0
  9. package/dist/index.d.ts +5 -0
  10. package/dist/index.d.ts.map +1 -0
  11. package/dist/index.js +10 -0
  12. package/dist/index.js.map +1 -0
  13. package/dist/rewriter/index.d.ts +45 -0
  14. package/dist/rewriter/index.d.ts.map +1 -0
  15. package/dist/rewriter/index.js +163 -0
  16. package/dist/rewriter/index.js.map +1 -0
  17. package/dist/schema/copy-patterns.d.ts +298 -0
  18. package/dist/schema/copy-patterns.d.ts.map +1 -0
  19. package/dist/schema/copy-patterns.js +53 -0
  20. package/dist/schema/copy-patterns.js.map +1 -0
  21. package/dist/schema/cta-rules.d.ts +274 -0
  22. package/dist/schema/cta-rules.d.ts.map +1 -0
  23. package/dist/schema/cta-rules.js +45 -0
  24. package/dist/schema/cta-rules.js.map +1 -0
  25. package/dist/schema/index.d.ts +2172 -0
  26. package/dist/schema/index.d.ts.map +1 -0
  27. package/dist/schema/index.js +92 -0
  28. package/dist/schema/index.js.map +1 -0
  29. package/dist/schema/tests.d.ts +274 -0
  30. package/dist/schema/tests.d.ts.map +1 -0
  31. package/dist/schema/tests.js +37 -0
  32. package/dist/schema/tests.js.map +1 -0
  33. package/dist/schema/tokens.d.ts +632 -0
  34. package/dist/schema/tokens.d.ts.map +1 -0
  35. package/dist/schema/tokens.js +68 -0
  36. package/dist/schema/tokens.js.map +1 -0
  37. package/dist/schema/voice.d.ts +280 -0
  38. package/dist/schema/voice.d.ts.map +1 -0
  39. package/dist/schema/voice.js +52 -0
  40. package/dist/schema/voice.js.map +1 -0
  41. package/dist/server/billing.d.ts +53 -0
  42. package/dist/server/billing.d.ts.map +1 -0
  43. package/dist/server/billing.js +216 -0
  44. package/dist/server/billing.js.map +1 -0
  45. package/dist/server/http.d.ts +5 -0
  46. package/dist/server/http.d.ts.map +1 -0
  47. package/dist/server/http.js +470 -0
  48. package/dist/server/http.js.map +1 -0
  49. package/dist/server/index.d.ts +3 -0
  50. package/dist/server/index.d.ts.map +1 -0
  51. package/dist/server/index.js +480 -0
  52. package/dist/server/index.js.map +1 -0
  53. package/dist/server/middleware/auth.d.ts +15 -0
  54. package/dist/server/middleware/auth.d.ts.map +1 -0
  55. package/dist/server/middleware/auth.js +83 -0
  56. package/dist/server/middleware/auth.js.map +1 -0
  57. package/dist/utils/pack-loader.d.ts +13 -0
  58. package/dist/utils/pack-loader.d.ts.map +1 -0
  59. package/dist/utils/pack-loader.js +98 -0
  60. package/dist/utils/pack-loader.js.map +1 -0
  61. package/dist/validator/index.d.ts +21 -0
  62. package/dist/validator/index.d.ts.map +1 -0
  63. package/dist/validator/index.js +60 -0
  64. package/dist/validator/index.js.map +1 -0
  65. package/dist/validator/rules/constraints.d.ts +8 -0
  66. package/dist/validator/rules/constraints.d.ts.map +1 -0
  67. package/dist/validator/rules/constraints.js +150 -0
  68. package/dist/validator/rules/constraints.js.map +1 -0
  69. package/dist/validator/rules/cta.d.ts +11 -0
  70. package/dist/validator/rules/cta.d.ts.map +1 -0
  71. package/dist/validator/rules/cta.js +113 -0
  72. package/dist/validator/rules/cta.js.map +1 -0
  73. package/dist/validator/rules/voice.d.ts +6 -0
  74. package/dist/validator/rules/voice.d.ts.map +1 -0
  75. package/dist/validator/rules/voice.js +106 -0
  76. package/dist/validator/rules/voice.js.map +1 -0
  77. package/package.json +61 -0
  78. package/packs/saas/copy_patterns.yaml +423 -0
  79. package/packs/saas/cta_rules.yaml +362 -0
  80. package/packs/saas/manifest.yaml +16 -0
  81. package/packs/saas/tests.yaml +305 -0
  82. package/packs/saas/tokens.json +226 -0
  83. package/packs/saas/voice.yaml +232 -0
package/README.md ADDED
@@ -0,0 +1,261 @@
1
+ # StyleMCP
2
+
3
+ Executable brand rules for AI models and agents. Keep every AI-generated message on-brand.
4
+
5
+ ## What is StyleMCP?
6
+
7
+ StyleMCP validates and rewrites AI-generated text to match your brand voice. Use it as:
8
+
9
+ - **REST API** - Validate text from any application
10
+ - **MCP Server** - Direct integration with Claude and other AI agents
11
+ - **CLI** - Check copy in your terminal or CI/CD
12
+ - **GitHub Action** - Catch off-brand copy in pull requests
13
+
14
+ ## Quick Start
15
+
16
+ ### API
17
+
18
+ ```bash
19
+ curl -X POST https://stylemcp.com/api/validate \
20
+ -H "Content-Type: application/json" \
21
+ -d '{"text": "Click here to learn more!"}'
22
+ ```
23
+
24
+ Response:
25
+
26
+ ```json
27
+ {
28
+ "valid": false,
29
+ "score": 65,
30
+ "issues": [
31
+ {
32
+ "rule": "no-click-here",
33
+ "message": "Avoid 'click here' - describe the destination instead",
34
+ "suggestion": "Learn more about our features"
35
+ }
36
+ ]
37
+ }
38
+ ```
39
+
40
+ ### CLI
41
+
42
+ ```bash
43
+ # Install
44
+ npm install -g stylemcp
45
+
46
+ # Validate text
47
+ stylemcp validate "Click here to learn more"
48
+
49
+ # Validate file
50
+ stylemcp validate src/copy/homepage.json --pack saas
51
+
52
+ # Rewrite text
53
+ stylemcp rewrite "Please utilize our product" --mode aggressive
54
+ ```
55
+
56
+ ### MCP (Claude Desktop)
57
+
58
+ Add to your `claude_desktop_config.json`:
59
+
60
+ ```json
61
+ {
62
+ "mcpServers": {
63
+ "stylemcp": {
64
+ "command": "npx",
65
+ "args": ["stylemcp"]
66
+ }
67
+ }
68
+ }
69
+ ```
70
+
71
+ Now Claude can validate and rewrite text using your brand rules.
72
+
73
+ ## API Endpoints
74
+
75
+ | Method | Endpoint | Description |
76
+ |--------|----------|-------------|
77
+ | POST | `/api/validate` | Validate text against brand rules |
78
+ | POST | `/api/rewrite` | Rewrite text to match brand voice |
79
+ | POST | `/api/validate/batch` | Validate multiple texts |
80
+ | GET | `/api/packs` | List available style packs |
81
+ | GET | `/api/packs/{pack}/voice` | Get voice guidelines |
82
+ | GET | `/api/packs/{pack}/ctas` | Get CTA rules |
83
+ | GET | `/api/mcp/sse` | MCP SSE endpoint |
84
+ | POST | `/api/mcp/call` | MCP tool calls |
85
+
86
+ ## Style Packs
87
+
88
+ StyleMCP uses **style packs** - YAML files that define your brand rules.
89
+
90
+ ### Default Pack: `saas`
91
+
92
+ The included `saas` pack is designed for B2B SaaS products:
93
+
94
+ - **Vocabulary**: Prefer "use" over "utilize", "help" over "assist"
95
+ - **Forbidden words**: "synergy", "leverage", "cutting-edge", "game-changing"
96
+ - **Patterns to avoid**: "click here", "we're sorry for any inconvenience"
97
+ - **CTA rules**: Avoid "Submit", "Click here", "OK" - prefer "Save", "Create", "Sign up"
98
+
99
+ ### Pack Structure
100
+
101
+ ```
102
+ packs/
103
+ my-brand/
104
+ manifest.yaml # Pack metadata
105
+ voice.yaml # Tone, vocabulary, forbidden words
106
+ copy_patterns.yaml # Reusable copy templates
107
+ cta_rules.yaml # Button/CTA guidelines
108
+ tokens.json # Design tokens (optional)
109
+ ```
110
+
111
+ ### Create Your Own Pack
112
+
113
+ ```bash
114
+ # Copy the default pack
115
+ cp -r packs/saas packs/my-brand
116
+
117
+ # Edit the rules
118
+ nano packs/my-brand/voice.yaml
119
+
120
+ # Use your pack
121
+ curl -X POST https://stylemcp.com/api/validate \
122
+ -d '{"text": "Your text", "pack": "my-brand"}'
123
+ ```
124
+
125
+ ### voice.yaml Example
126
+
127
+ ```yaml
128
+ tone:
129
+ summary: "Friendly, clear, and helpful"
130
+ attributes:
131
+ - name: friendly
132
+ weight: 0.8
133
+ - name: professional
134
+ weight: 0.7
135
+
136
+ vocabulary:
137
+ rules:
138
+ - preferred: "use"
139
+ avoid: ["utilize", "leverage"]
140
+ - preferred: "help"
141
+ avoid: ["assist", "facilitate"]
142
+
143
+ forbidden:
144
+ - "synergy"
145
+ - "paradigm shift"
146
+ - "game-changing"
147
+
148
+ doNot:
149
+ - pattern: "click here"
150
+ reason: "Poor accessibility"
151
+ suggestion: "Describe the destination"
152
+ severity: error
153
+
154
+ - pattern: "\\b(obviously|simply|just)\\b"
155
+ isRegex: true
156
+ reason: "Can make users feel stupid"
157
+ severity: warning
158
+ ```
159
+
160
+ ## Self-Hosting
161
+
162
+ ### Docker
163
+
164
+ ```bash
165
+ # Clone the repo
166
+ git clone https://github.com/stylemcp/stylemcp.git
167
+ cd stylemcp
168
+
169
+ # Set up environment
170
+ echo "STYLEMCP_API_KEY=$(openssl rand -hex 32)" > .env
171
+
172
+ # Run with Docker
173
+ docker compose up -d
174
+
175
+ # Check health
176
+ curl http://localhost:3000/health
177
+ ```
178
+
179
+ ### Manual
180
+
181
+ ```bash
182
+ # Install dependencies
183
+ npm install
184
+
185
+ # Build
186
+ npm run build
187
+
188
+ # Start server
189
+ npm start
190
+ ```
191
+
192
+ ## GitHub Actions
193
+
194
+ ```yaml
195
+ name: Brand Check
196
+ on: [pull_request]
197
+
198
+ jobs:
199
+ validate:
200
+ runs-on: ubuntu-latest
201
+ steps:
202
+ - uses: actions/checkout@v4
203
+
204
+ - name: Validate copy
205
+ run: |
206
+ npx stylemcp validate src/copy/*.json \
207
+ --min-score 80 \
208
+ --format github
209
+ ```
210
+
211
+ ## Environment Variables
212
+
213
+ | Variable | Description | Default |
214
+ |----------|-------------|---------|
215
+ | `PORT` | Server port | 3000 |
216
+ | `STYLEMCP_API_KEY` | API key for authentication | (none) |
217
+ | `GITHUB_WEBHOOK_SECRET` | GitHub webhook secret | (none) |
218
+
219
+ ## MCP Tools
220
+
221
+ When used as an MCP server, StyleMCP provides these tools:
222
+
223
+ | Tool | Description |
224
+ |------|-------------|
225
+ | `validate_text` | Validate text against brand rules |
226
+ | `rewrite_to_style` | Rewrite text to match brand voice |
227
+ | `get_voice_rules` | Get voice and tone guidelines |
228
+ | `get_copy_patterns` | Get approved copy patterns |
229
+ | `get_cta_rules` | Get CTA guidelines |
230
+ | `get_tokens` | Get design tokens |
231
+ | `list_packs` | List available style packs |
232
+
233
+ ## What Gets Validated?
234
+
235
+ The `saas` pack checks for:
236
+
237
+ ### Vocabulary
238
+ - Use simple words: "use" not "utilize", "help" not "assist"
239
+ - Avoid jargon: "synergy", "leverage", "paradigm shift"
240
+ - Avoid weak intensifiers: "very", "really", "extremely"
241
+
242
+ ### Patterns
243
+ - No "click here" (accessibility issue)
244
+ - No "we're sorry for any inconvenience" (corporate non-apology)
245
+ - No double "please" (sounds desperate)
246
+ - No starting with "Sorry" (lead with solutions)
247
+
248
+ ### CTAs
249
+ - Avoid generic: "Submit", "OK", "Yes/No", "Click here"
250
+ - Use specific actions: "Save", "Create", "Sign up", "Export"
251
+ - Max 4 words
252
+
253
+ ### Constraints
254
+ - Max 25 words per sentence
255
+ - No exclamation marks (in most contexts)
256
+ - First-person plural ("we", "our")
257
+ - Oxford comma
258
+
259
+ ## License
260
+
261
+ MIT
@@ -0,0 +1,59 @@
1
+ name: 'StyleMCP'
2
+ description: 'Validate text and copy against brand/voice rules. Brand CI for AI output.'
3
+ author: 'StyleMCP'
4
+
5
+ branding:
6
+ icon: 'check-circle'
7
+ color: 'blue'
8
+
9
+ inputs:
10
+ pack:
11
+ description: 'Style pack to use (built-in: saas, or path to custom pack)'
12
+ required: false
13
+ default: 'saas'
14
+ files:
15
+ description: 'Glob pattern for files to validate (e.g., "src/**/*.tsx", "docs/**/*.md")'
16
+ required: false
17
+ default: ''
18
+ text:
19
+ description: 'Direct text to validate (alternative to files)'
20
+ required: false
21
+ default: ''
22
+ min-score:
23
+ description: 'Minimum passing score (0-100)'
24
+ required: false
25
+ default: '70'
26
+ strict:
27
+ description: 'Fail on any violation, regardless of score'
28
+ required: false
29
+ default: 'false'
30
+ fail-on-warning:
31
+ description: 'Treat warnings as failures'
32
+ required: false
33
+ default: 'false'
34
+ content-type:
35
+ description: 'Content type hint (ui-copy, marketing, docs, support, general)'
36
+ required: false
37
+ default: 'general'
38
+ comment-on-pr:
39
+ description: 'Post validation results as a PR comment'
40
+ required: false
41
+ default: 'true'
42
+ github-token:
43
+ description: 'GitHub token for PR comments (defaults to GITHUB_TOKEN)'
44
+ required: false
45
+ default: ${{ github.token }}
46
+
47
+ outputs:
48
+ score:
49
+ description: 'Overall validation score (0-100)'
50
+ valid:
51
+ description: 'Whether validation passed'
52
+ violations:
53
+ description: 'Number of violations found'
54
+ report:
55
+ description: 'Full validation report as JSON'
56
+
57
+ runs:
58
+ using: 'node20'
59
+ main: 'dist/index.js'
@@ -0,0 +1,24 @@
1
+ {
2
+ "name": "stylemcp-action",
3
+ "version": "0.1.0",
4
+ "private": true,
5
+ "description": "GitHub Action for StyleMCP validation",
6
+ "main": "dist/index.js",
7
+ "scripts": {
8
+ "build": "ncc build src/index.ts -o dist --source-map --license licenses.txt",
9
+ "package": "npm run build"
10
+ },
11
+ "dependencies": {
12
+ "@actions/core": "^1.10.1",
13
+ "@actions/github": "^6.0.0",
14
+ "glob": "^10.4.1",
15
+ "js-yaml": "^4.1.0",
16
+ "zod": "^3.23.8"
17
+ },
18
+ "devDependencies": {
19
+ "@types/js-yaml": "^4.0.9",
20
+ "@types/node": "^20.14.0",
21
+ "@vercel/ncc": "^0.38.1",
22
+ "typescript": "^5.5.0"
23
+ }
24
+ }