codymaster 4.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 (193) hide show
  1. package/CHANGELOG.md +50 -0
  2. package/README.md +285 -0
  3. package/adapters/antigravity.js +15 -0
  4. package/adapters/claude-code.js +17 -0
  5. package/adapters/cursor.js +16 -0
  6. package/commands/bootstrap.md +49 -0
  7. package/commands/build.md +48 -0
  8. package/commands/content.md +48 -0
  9. package/commands/continuity.md +60 -0
  10. package/commands/debug.md +51 -0
  11. package/commands/demo.md +96 -0
  12. package/commands/deploy.md +51 -0
  13. package/commands/plan.md +42 -0
  14. package/commands/review.md +55 -0
  15. package/commands/track.md +46 -0
  16. package/commands/ux.md +46 -0
  17. package/dist/agent-dispatch.js +161 -0
  18. package/dist/chains/builtin.js +85 -0
  19. package/dist/continuity.js +385 -0
  20. package/dist/dashboard.js +926 -0
  21. package/dist/data.js +122 -0
  22. package/dist/index.js +2434 -0
  23. package/dist/judge.js +252 -0
  24. package/dist/parallel-dispatch.js +359 -0
  25. package/dist/parallel-quality.js +172 -0
  26. package/dist/skill-chain.js +258 -0
  27. package/install.sh +513 -0
  28. package/package.json +79 -0
  29. package/skills/.content-factory-state.json +132 -0
  30. package/skills/.git 2/logs/refs/heads/main +1 -0
  31. package/skills/.git 2/logs/refs/remotes/origin/main +1 -0
  32. package/skills/.git 2/objects/02/fb0956734b5f8ba3f918b7defd04a89cfe0076 +0 -0
  33. package/skills/.git 2/objects/08/1e129d75dc6feac6c02037272e6bd1a04e3324 +0 -0
  34. package/skills/.git 2/objects/0c/5393416f3c5e01c9a655a802bff0dd52f76f0a +0 -0
  35. package/skills/.git 2/objects/10/0b9be46978a946a77188f68be725098a122001 +0 -0
  36. package/skills/.git 2/objects/10/cf041167fc9843610eb3d90259ef3396315fdc +0 -0
  37. package/skills/.git 2/objects/12/5e19538dd6e1338ffe74f6c4c165b00435bf48 +0 -0
  38. package/skills/.git 2/objects/16/a9b9d0088d5c1347628b45a2620b479d8ad57c +0 -0
  39. package/skills/.git 2/objects/17/8c2a9ef93c33ae4eec9d58e82321f9229843a1 +0 -0
  40. package/skills/.git 2/objects/25/397ae41d09104d763bdcac2695209d85cdea89 +0 -0
  41. package/skills/.git 2/objects/2f/a836b7947f2d458e1f639788bf4bb0983a3305 +0 -0
  42. package/skills/.git 2/objects/3a/baaaf0a1c0909c0828335791557125fba911e0 +0 -0
  43. package/skills/.git 2/objects/42/2924221b81f5ce3c4e4daac9a64a24f9b01f9a +0 -0
  44. package/skills/.git 2/objects/42/ec0ce707447dc11446a34c9995fb8533801731 +0 -0
  45. package/skills/.git 2/objects/46/e43ce92866d56ce74b1d750db307cfe6154a15 +0 -0
  46. package/skills/.git 2/objects/48/5e41b633c63f55b8277bcc59f44f67681f671a +0 -0
  47. package/skills/.git 2/objects/49/49c596a3a89fa240642acd95dd3258e261eb09 +0 -0
  48. package/skills/.git 2/objects/50/9d42d8412ef8eaf7f7e138476bac2e4d10ce60 +0 -0
  49. package/skills/.git 2/objects/55/0c8c389d981b463ef849aeb792d8be3ccb6ec8 +0 -0
  50. package/skills/.git 2/objects/5d/82d3b18410cdda3ace3677436f0cb599dbe2d2 +0 -0
  51. package/skills/.git 2/objects/60/0617c58e871a38b33bf29e282d132bb3c381ad +0 -0
  52. package/skills/.git 2/objects/6a/8369a99c687b7245c92ffaf0e0f0dab9014504 +0 -0
  53. package/skills/.git 2/objects/79/bea435d40ab531c1aaf6be0432c6a5b7aaed21 +0 -0
  54. package/skills/.git 2/objects/7e/5ebd79251c2f14e4aceb86c74b6b6daae6b500 +0 -0
  55. package/skills/.git 2/objects/81/98a822a60178d6d5023ddb3e222cddf048742e +0 -0
  56. package/skills/.git 2/objects/86/0a0e1943dfe53411d2e499a1f16f46a96ef758 +0 -0
  57. package/skills/.git 2/objects/86/971fb55fdc081fdbae52376f0f13e57a4e9b04 +0 -0
  58. package/skills/.git 2/objects/88/b89dd609a0a03f8d4fe8bfde20d5b8fc1d326d +0 -0
  59. package/skills/.git 2/objects/90/8737edb6b7809e32cc01590b4e08ba42a9d40d +0 -0
  60. package/skills/.git 2/objects/93/d5a8a9a7d4fb7f11491cb596a6880528725118 +0 -0
  61. package/skills/.git 2/objects/98/46a2ab81d0c3b3eb00ef88fc56989aa7e9f316 +0 -0
  62. package/skills/.git 2/objects/9b/d8dd1e49cf274eaf9c555f3ab39dce7af5715e +0 -0
  63. package/skills/.git 2/objects/a1/13329fb0cec96ae78b222d33a24c3b5bc7fa1f +0 -0
  64. package/skills/.git 2/objects/a9/e6effe626e8a3aea3a8fc3364b492191c6e7d0 +0 -0
  65. package/skills/.git 2/objects/ad/6de7e48d9782cca9353d1ff0aa1aab7fe1df85 +0 -0
  66. package/skills/.git 2/objects/af/54ae316f771ff692e299ffcd8bf2f06b413b59 +0 -0
  67. package/skills/.git 2/objects/b0/4cb8b0b00dad633e731c1472161419e738d674 +0 -0
  68. package/skills/.git 2/objects/b3/094abb0b9ed46419b269e4a4e36a459690e3b0 +0 -0
  69. package/skills/.git 2/objects/b9/435c5d4baac2cfc5c83009ddd27b46b60db5f1 +0 -0
  70. package/skills/.git 2/objects/ba/5da17dbaec5ec2dcfdfd126aead518d1171d5c +0 -0
  71. package/skills/.git 2/objects/c0/bf58703aa258ba5dd63083bebaec8f223d844c +0 -0
  72. package/skills/.git 2/objects/c4/701a34edf1fc1bad58ccc57bd03f9426acb59a +0 -0
  73. package/skills/.git 2/objects/c7/5ccce9a4e5cc74d9b3174550cf6d993ca43638 +0 -0
  74. package/skills/.git 2/objects/c7/710d59b5a35b0f1f0a0399386643a0bd94c929 +0 -0
  75. package/skills/.git 2/objects/d1/fe58237112e953e5fec52da22cf38e08be3df9 +5 -0
  76. package/skills/.git 2/objects/d2/2bbe9fd2f74c95bc5583e803f5e435f1e2cd86 +0 -0
  77. package/skills/.git 2/objects/d7/e72852ea2bff74581dbf247d400120086229f4 +0 -0
  78. package/skills/.git 2/objects/d8/d4c3b5553e4fd72807e1d4b49ef07d9ef3ac35 +0 -0
  79. package/skills/.git 2/objects/dc/75050c2876f6a02ae2a53a3c886f395b622977 +0 -0
  80. package/skills/.git 2/objects/ee/e8546f95acec500187c08a28a8b9ee02db0dec +0 -0
  81. package/skills/.git 2/objects/ef/263c059208b416c2146434f10cb2b9fabcba16 +0 -0
  82. package/skills/.git 2/objects/f3/ae597e84d9a59b88acd21c99bde2eaf686d785 +0 -0
  83. package/skills/.git 2/objects/f3/f6f5673c821d3d8e76fa267a9e882e7a5387ea +0 -0
  84. package/skills/.git 2/objects/f9/6e6d0ad02624dd11d5848594d056caef7a5e8b +0 -0
  85. package/skills/.git 2/objects/ff/278988fc1edf0db3abcf18de795f4cc0b4f3e1 +0 -0
  86. package/skills/.git 2/refs/heads/main +1 -0
  87. package/skills/.git 2/refs/remotes/origin/main +1 -0
  88. package/skills/.pytest_cache 2/v/cache/nodeids +76 -0
  89. package/skills/.pytest_cache 2/v/cache/stepwise +1 -0
  90. package/skills/_shared/helpers.md +123 -0
  91. package/skills/_shared/outputs-convention.md +24 -0
  92. package/skills/cm-ads-tracker/SKILL.md +109 -0
  93. package/skills/cm-ads-tracker/evals/evals.json +55 -0
  94. package/skills/cm-ads-tracker/references/gtm-architecture.md +321 -0
  95. package/skills/cm-ads-tracker/references/industry-events.md +294 -0
  96. package/skills/cm-ads-tracker/references/platforms-api.md +238 -0
  97. package/skills/cm-ads-tracker/templates/capi-payload.md +79 -0
  98. package/skills/cm-ads-tracker/templates/datalayer-push.js +104 -0
  99. package/skills/cm-ads-tracker/templates/gtm-variables.js +56 -0
  100. package/skills/cm-brainstorm-idea/SKILL.md +423 -0
  101. package/skills/cm-code-review/SKILL.md +151 -0
  102. package/skills/cm-content-factory/SKILL.md +416 -0
  103. package/skills/cm-continuity/SKILL.md +399 -0
  104. package/skills/cm-dashboard/SKILL.md +533 -0
  105. package/skills/cm-dashboard/ui/app.js +1270 -0
  106. package/skills/cm-dashboard/ui/index.html +206 -0
  107. package/skills/cm-dashboard/ui/style.css +440 -0
  108. package/skills/cm-debugging/SKILL.md +412 -0
  109. package/skills/cm-deep-search/SKILL.md +242 -0
  110. package/skills/cm-design-system/SKILL.md +97 -0
  111. package/skills/cm-design-system/resources/halo-modern.md +40 -0
  112. package/skills/cm-design-system/resources/lunaris-advanced.md +40 -0
  113. package/skills/cm-design-system/resources/nitro-enterprise.md +39 -0
  114. package/skills/cm-design-system/resources/shadcn-default.md +37 -0
  115. package/skills/cm-dockit/README.md +100 -0
  116. package/skills/cm-dockit/SKILL.md +302 -0
  117. package/skills/cm-dockit/index.html +443 -0
  118. package/skills/cm-dockit/package-lock.json +1850 -0
  119. package/skills/cm-dockit/package.json +14 -0
  120. package/skills/cm-dockit/prompts/analysis.md +34 -0
  121. package/skills/cm-dockit/prompts/api-reference.md +24 -0
  122. package/skills/cm-dockit/prompts/architecture.md +21 -0
  123. package/skills/cm-dockit/prompts/data-flow.md +20 -0
  124. package/skills/cm-dockit/prompts/database.md +21 -0
  125. package/skills/cm-dockit/prompts/deployment.md +22 -0
  126. package/skills/cm-dockit/prompts/flows.md +21 -0
  127. package/skills/cm-dockit/prompts/jtbd.md +20 -0
  128. package/skills/cm-dockit/prompts/personas.md +24 -0
  129. package/skills/cm-dockit/prompts/sop-modules.md +40 -0
  130. package/skills/cm-dockit/scripts/doc-gen.sh +121 -0
  131. package/skills/cm-dockit/scripts/dockit-dashboard.sh +142 -0
  132. package/skills/cm-dockit/scripts/dockit-runner.sh +607 -0
  133. package/skills/cm-dockit/scripts/dockit-task.sh +166 -0
  134. package/skills/cm-dockit/skills/analyze-codebase.md +174 -0
  135. package/skills/cm-dockit/skills/api-reference.md +237 -0
  136. package/skills/cm-dockit/skills/changelog-guide.md +195 -0
  137. package/skills/cm-dockit/skills/content-guidelines.md +190 -0
  138. package/skills/cm-dockit/skills/sop-guide.md +184 -0
  139. package/skills/cm-dockit/skills/tech-docs.md +287 -0
  140. package/skills/cm-dockit/templates/markdown/structure.md +60 -0
  141. package/skills/cm-dockit/templates/vitepress-premium/.vitepress/config.mts +110 -0
  142. package/skills/cm-dockit/templates/vitepress-premium/.vitepress/theme/custom.css +189 -0
  143. package/skills/cm-dockit/templates/vitepress-premium/.vitepress/theme/index.ts +4 -0
  144. package/skills/cm-dockit/templates/vitepress-premium/package.json +19 -0
  145. package/skills/cm-dockit/templates/vitepress-premium/tests/frontend.test.ts +45 -0
  146. package/skills/cm-dockit/tests/runner.test.ts +66 -0
  147. package/skills/cm-dockit/workflows/export-markdown.md +82 -0
  148. package/skills/cm-dockit/workflows/generate-docs.md +68 -0
  149. package/skills/cm-dockit/workflows/setup-vitepress.md +181 -0
  150. package/skills/cm-example/SKILL.md +26 -0
  151. package/skills/cm-execution/SKILL.md +268 -0
  152. package/skills/cm-git-worktrees/SKILL.md +164 -0
  153. package/skills/cm-how-it-work/SKILL.md +189 -0
  154. package/skills/cm-identity-guard/SKILL.md +412 -0
  155. package/skills/cm-jtbd/SKILL.md +98 -0
  156. package/skills/cm-planning/SKILL.md +130 -0
  157. package/skills/cm-project-bootstrap/SKILL.md +161 -0
  158. package/skills/cm-project-bootstrap/templates/AGENTS.md +42 -0
  159. package/skills/cm-project-bootstrap/templates/frontend-safety.test.js +51 -0
  160. package/skills/cm-project-bootstrap/templates/i18n-sync.test.js +38 -0
  161. package/skills/cm-project-bootstrap/templates/pr-template.md +12 -0
  162. package/skills/cm-project-bootstrap/templates/project-identity.json +29 -0
  163. package/skills/cm-project-bootstrap/templates/vitest.config.js +10 -0
  164. package/skills/cm-quality-gate/SKILL.md +218 -0
  165. package/skills/cm-readit/SKILL.md +289 -0
  166. package/skills/cm-readit/audio-player.md +206 -0
  167. package/skills/cm-readit/examples/blog-reader.js +352 -0
  168. package/skills/cm-readit/examples/voice-cro.js +390 -0
  169. package/skills/cm-readit/tts-engine.md +262 -0
  170. package/skills/cm-readit/ui-patterns.md +362 -0
  171. package/skills/cm-readit/voice-cro.md +223 -0
  172. package/skills/cm-safe-deploy/SKILL.md +120 -0
  173. package/skills/cm-safe-deploy/templates/deploy.sh +89 -0
  174. package/skills/cm-safe-i18n/SKILL.md +473 -0
  175. package/skills/cm-secret-shield/SKILL.md +580 -0
  176. package/skills/cm-skill-chain/SKILL.md +78 -0
  177. package/skills/cm-skill-index/SKILL.md +318 -0
  178. package/skills/cm-skill-mastery/SKILL.md +169 -0
  179. package/skills/cm-start/SKILL.md +65 -0
  180. package/skills/cm-status/SKILL.md +12 -0
  181. package/skills/cm-tdd/SKILL.md +370 -0
  182. package/skills/cm-terminal/SKILL.md +177 -0
  183. package/skills/cm-test-gate/SKILL.md +242 -0
  184. package/skills/cm-ui-preview/SKILL.md +291 -0
  185. package/skills/cm-ux-master/DESIGN_STANDARD_TEMPLATE.md +54 -0
  186. package/skills/cm-ux-master/SKILL.md +114 -0
  187. package/skills/cro-methodology/SKILL.md +98 -0
  188. package/skills/cro-methodology/references/COPYWRITING.md +178 -0
  189. package/skills/cro-methodology/references/OBJECTIONS.md +135 -0
  190. package/skills/cro-methodology/references/PERSUASION.md +158 -0
  191. package/skills/cro-methodology/references/RESEARCH.md +220 -0
  192. package/skills/cro-methodology/references/funnel-analysis.md +365 -0
  193. package/skills/cro-methodology/references/testing-methodology.md +330 -0
@@ -0,0 +1,161 @@
1
+ ---
2
+ name: cm-project-bootstrap
3
+ description: Use when starting any new project from scratch. Asks for project identity (name, GitHub org, Cloudflare account), detects project type, sets up design system, staging+production, i18n from day 1, SEO foundation, AGENTS.md manifest, test infrastructure, 8-gate deploy pipeline, and disciplined development workflows. Prevents wrong deploys, redundant repos, and technical debt from day 0.
4
+ ---
5
+
6
+ # CodyMaster Project Bootstrap v2.0
7
+
8
+ > **Every project starts here. No exceptions.**
9
+
10
+ ## Core Principles
11
+
12
+ - ASK FIRST. BUILD SECOND. NEVER ASSUME IDENTITY.
13
+ - STAGING IS MANDATORY. PRODUCTION IS EARNED.
14
+ - I18N FROM DAY 1. DESIGN SYSTEM BEFORE COMPONENTS.
15
+ - SEO IS INFRASTRUCTURE. EVERY PROJECT GETS AN AGENTS.MD.
16
+
17
+ ## 11-Phase Bootstrap Process
18
+
19
+ | Phase | Name | Purpose |
20
+ |-------|------|---------|
21
+ | 0 | Identity Lock | WHO are you deploying as? |
22
+ | 0.5 | Security Foundation | HOW to prevent secret leaks? (calls `cm-secret-shield`) |
23
+ | 1 | Project Type Detection | WHAT kind of project? |
24
+ | 2 | Repository & Environments | WHERE does code live? |
25
+ | 3 | Design System Foundation | HOW does it look? |
26
+ | 4 | i18n From Day 1 | WHICH languages? |
27
+ | 5 | SEO Foundation | HOW will people find it? |
28
+ | 6 | AGENTS.md + Git Safety | HOW do agents collaborate? |
29
+ | 7 | Test Infrastructure | HOW do we catch bugs? |
30
+ | 8 | Deploy Pipeline (8 Gates) | HOW does code ship? |
31
+ | 9 | Development Workflow | HOW do we work daily? |
32
+
33
+ ---
34
+
35
+ ## Phase 0: Identity Lock 🔐
36
+
37
+ > **MANDATORY. Cannot proceed without this.**
38
+
39
+ 1. Check `~/.cm-identity-history.json` for previous identities → suggest pre-fill
40
+ 2. Ask 6 questions (with suggestions from history):
41
+ - Project name (kebab-case), GitHub org, Cloudflare ID, Domain, Primary language, Target languages
42
+ 3. Verify identity with user confirmation
43
+ 4. Create `.project-identity.json` with all config
44
+ 5. Save to `~/.cm-identity-history.json` for future projects
45
+ 6. Call `cm-identity-guard` to verify git config matches
46
+
47
+ ## Phase 0.5: Security Foundation 🛡️
48
+
49
+ > Calls `cm-secret-shield` for setup.
50
+
51
+ 1. Create `.gitleaks.toml` with Supabase + generic high-entropy rules
52
+ 2. Setup pre-commit hook (`.git/hooks/pre-commit`) — scans staged files
53
+ 3. Add `security:scan` script to `package.json`
54
+ 4. Create `.dev.vars.example` template (committed). `.dev.vars` = real secrets (gitignored)
55
+
56
+ ## Phase 1: Project Type Detection 🔍
57
+
58
+ > Default UI: shadcn/ui + Tailwind. Default layout: Mobile-first.
59
+
60
+ | Type | Stack |
61
+ |------|-------|
62
+ | A. Static Website | HTML + vanilla JS + CSS |
63
+ | B. SPA (Vite) | Vite + React + TS + shadcn/ui |
64
+ | C. Cloudflare Workers | Hono + wrangler + TS |
65
+ | D. Fullstack | Hono + Vite + React + shadcn/ui |
66
+ | E. Content Site | Astro + MDX |
67
+
68
+ Scaffold based on type, install `vitest` for all. Enforce mobile-first base styles.
69
+
70
+ ## Phase 2: Repository & Environments 🏠
71
+
72
+ 1. `git init` + `main` (staging) + `production` branches
73
+ 2. Configure Cloudflare Pages: `npx wrangler pages project create`
74
+ 3. Add `deploy:staging` and `deploy:production` scripts
75
+ 4. Create hardened `.gitignore` (secrets, env files, build output)
76
+
77
+ ## Phase 3: Design System Foundation 🎨
78
+
79
+ > Design tokens BEFORE components. shadcn/ui as default. Mobile-first always.
80
+
81
+ 1. Check `~/.cm-design-profiles/{org}.json` for existing brand profile → reuse
82
+ 2. If no profile: ask brand context (name, industry, style, primary color, dark mode)
83
+ 3. Create design tokens (CSS custom properties for shadcn/ui or vanilla)
84
+ 4. Install base shadcn/ui components: button, input, label, card, dialog, dropdown-menu, toast, skeleton
85
+ 5. Add mobile-first base styles (44px touch targets, responsive container, safe-area)
86
+ 6. Save design profile to `~/.cm-design-profiles/`
87
+
88
+ ## Phase 4: i18n From Day 1 🌍
89
+
90
+ 1. Create i18n engine (vanilla `i18n.js` or `react-i18next`)
91
+ 2. Create language files: primary (source of truth) + targets
92
+ 3. Rules: ALL strings via `t()` or `data-i18n`. MAX 30 strings per batch. Run i18n-sync test after every batch.
93
+
94
+ ## Phase 5: SEO Foundation 🔍
95
+
96
+ Every page must have: title (<60 chars), meta description (150-160 chars), exactly ONE h1, heading hierarchy (no skipping), semantic HTML, alt attributes, canonical URL, Open Graph, lang attribute, unique IDs.
97
+
98
+ ## Phase 6: AGENTS.md + Git Safety 🤖
99
+
100
+ 1. Create `AGENTS.md` at root — project overview, commands, structure, conventions, rules
101
+ 2. Enforce conventional commits: `feat:`, `fix:`, `docs:`, `test:`, `chore:`, `i18n:`
102
+ 3. Branch protection: main (staging, no force push), production (merge from main only)
103
+ 4. Create PR template (`.github/pull_request_template.md`)
104
+
105
+ ## Phase 7: Test Infrastructure 🧪
106
+
107
+ 1. Create `vitest.config.js`
108
+ 2. Create `tests/unit/frontend-safety.test.js` — HTML structure, JS syntax, CSS tokens, AGENTS.md exists
109
+ 3. Create `tests/unit/i18n-sync.test.js` — key parity across languages
110
+ 4. Wire up `test:gate` in package.json
111
+
112
+ ## Phase 8: Deploy Pipeline (8 Gates) 🚀
113
+
114
+ Gates run sequentially: Identity → Branch → Test → Build → i18n → Lint → Accessibility → Performance.
115
+ See `cm-safe-deploy` for the full 9-gate pipeline details.
116
+
117
+ ## Phase 9: Development Workflow 🔄
118
+
119
+ Daily loop: Plan → Branch → TDD → Build → Test → Review → Commit → Deploy staging → Verify → Merge production.
120
+
121
+ Deploy rules: `deploy` = staging. `deploy production` = requires staging verified first.
122
+
123
+ ## Phase 9.5: Working Memory Init 🧠
124
+
125
+ 1. Create `.cm/CONTINUITY.md` from `cm-continuity` template
126
+ 2. Add `.cm/` to `.gitignore` (local working memory)
127
+ 3. Reference in AGENTS.md
128
+
129
+ ## Adaptive Skills Discovery 🧠
130
+
131
+ When agent encounters unknown task:
132
+ 1. DETECT gap → 2. `npx skills find "{keyword}"` → 3. REVIEW SKILL.md → 4. ASK user → 5. INSTALL → 6. USE → 7. LOG to `.cm-skills-log.json`
133
+
134
+ Safety: always show user before installing, prefer known repos, install project-level, log every install.
135
+
136
+ ## Output Checklist ✅
137
+
138
+ After bootstrap, project MUST have: `.project-identity.json`, `AGENTS.md`, `.gitignore` (hardened), `.gitleaks.toml`, pre-commit hook, `.dev.vars.example`, `package.json` (with deploy/test scripts), design tokens/shadcn, i18n files, SEO meta tags, test files, main + production branches, `.cm/CONTINUITY.md`.
139
+
140
+ ## Template Files (load on-demand with view_file)
141
+
142
+ | Template | Use When |
143
+ |----------|----------|
144
+ | `templates/vitest.config.js` | Phase 7: Setting up test infrastructure |
145
+ | `templates/frontend-safety.test.js` | Phase 7: Creating frontend safety tests |
146
+ | `templates/i18n-sync.test.js` | Phase 7: Creating i18n sync tests |
147
+ | `templates/project-identity.json` | Phase 0: Creating .project-identity.json |
148
+ | `templates/AGENTS.md` | Phase 6: Creating AGENTS.md |
149
+ | `templates/pr-template.md` | Phase 6: Creating PR template |
150
+
151
+ ## Anti-Patterns ❌
152
+
153
+ | Anti-Pattern | Prevention |
154
+ |-------------|------------|
155
+ | Skip identity lock | Phase 0 is MANDATORY |
156
+ | No staging branch | Always 2 branches |
157
+ | i18n "later" | Phase 4 from day 1 |
158
+ | Raw hex colors | Design tokens only |
159
+ | No AGENTS.md | Phase 6 creates it |
160
+ | deploy = production | deploy = staging default |
161
+ | 600 i18n strings at once | MAX 30 per batch |
@@ -0,0 +1,42 @@
1
+ # AGENTS.md — {{PROJECT_NAME}}
2
+
3
+ > AI agents: Read this file FIRST before any task.
4
+
5
+ ## Project Identity
6
+ - **Name**: {{PROJECT_NAME}}
7
+ - **Type**: {{PROJECT_TYPE}} (Cloudflare Pages)
8
+ - **Primary Language**: {{PRIMARY_LANG}}
9
+ - **Tech Stack**: {{TECH_STACK}}
10
+
11
+ ## Commands
12
+ - `npm run dev` — Start local dev server
13
+ - `npm run test` — Run all tests
14
+ - `npm run test:gate` — Run pre-deploy test gate
15
+ - `npm run deploy:staging` — Deploy to staging
16
+ - `npm run deploy:production` — Deploy to production
17
+
18
+ ## Project Structure
19
+ ```
20
+ public/ — Static files served directly
21
+ static/css/ — Stylesheets (design-tokens.css, style.css)
22
+ static/js/ — JavaScript (app.js, i18n.js)
23
+ static/i18n/ — Language files (vi.json, en.json, ...)
24
+ src/ — Backend source (if applicable)
25
+ tests/ — Test files
26
+ docs/plans/ — Implementation plans
27
+ ```
28
+
29
+ ## Code Conventions
30
+ - **i18n**: ALL user-facing strings must use t() or data-i18n. vi.json is source of truth.
31
+ - **CSS**: Use design tokens only. Never raw hex colors or arbitrary spacing.
32
+ - **Commits**: Conventional format — `feat:`, `fix:`, `docs:`, `test:`, `chore:`
33
+ - **Branches**: `main` = staging, `production` = production only
34
+ - **Deploy**: Always staging first. Production requires explicit request.
35
+
36
+ ## Important Rules
37
+ 1. Run `cm-identity-guard` before any git push
38
+ 2. Never force push to main or production
39
+ 3. i18n extraction: MAX 30 strings per batch
40
+ 4. Run test:gate before every deploy
41
+ 5. Check `.project-identity.json` for deploy targets
42
+ 6. Read `.cm/CONTINUITY.md` at the start of every session for context
@@ -0,0 +1,51 @@
1
+ import { describe, it, expect } from 'vitest';
2
+ import { readFileSync, readdirSync, existsSync } from 'fs';
3
+ import { join } from 'path';
4
+
5
+ describe('Frontend Safety', () => {
6
+ // Test 1: HTML files have proper structure
7
+ it('index.html has required meta tags', () => {
8
+ const html = readFileSync('public/index.html', 'utf-8');
9
+ expect(html).toContain('<meta charset=');
10
+ expect(html).toContain('<meta name="viewport"');
11
+ expect(html).toContain('<title');
12
+ expect(html).toContain('lang=');
13
+ });
14
+
15
+ // Test 2: No syntax errors in JS files
16
+ it('JavaScript files parse without errors', () => {
17
+ const jsDir = 'public/static/js';
18
+ if (!existsSync(jsDir)) return;
19
+ const files = readdirSync(jsDir).filter(f => f.endsWith('.js'));
20
+ files.forEach(file => {
21
+ const content = readFileSync(join(jsDir, file), 'utf-8');
22
+ expect(() => new Function(content)).not.toThrow();
23
+ });
24
+ });
25
+
26
+ // Test 3: CSS files reference design tokens (not raw values)
27
+ it('stylesheets use design tokens', () => {
28
+ const cssFile = 'public/static/css/style.css';
29
+ if (!existsSync(cssFile)) return;
30
+ const css = readFileSync(cssFile, 'utf-8');
31
+ const rawColors = css.match(/#[0-9a-fA-F]{3,8}(?!.*design-tokens)/g);
32
+ if (rawColors && rawColors.length > 0) {
33
+ console.warn(`⚠️ Found ${rawColors.length} raw color values. Use design tokens instead.`);
34
+ }
35
+ });
36
+
37
+ // Test 4: Design tokens file exists
38
+ it('design-tokens.css exists', () => {
39
+ expect(existsSync('public/static/css/design-tokens.css')).toBe(true);
40
+ });
41
+
42
+ // Test 5: AGENTS.md exists
43
+ it('AGENTS.md exists at project root', () => {
44
+ expect(existsSync('AGENTS.md')).toBe(true);
45
+ });
46
+
47
+ // Test 6: .project-identity.json exists
48
+ it('.project-identity.json exists', () => {
49
+ expect(existsSync('.project-identity.json')).toBe(true);
50
+ });
51
+ });
@@ -0,0 +1,38 @@
1
+ import { describe, it, expect } from 'vitest';
2
+ import { readFileSync, readdirSync, existsSync } from 'fs';
3
+ import { join } from 'path';
4
+
5
+ describe('i18n Sync', () => {
6
+ const i18nDir = 'public/static/i18n';
7
+
8
+ it('primary language file exists', () => {
9
+ expect(existsSync(join(i18nDir, 'vi.json'))).toBe(true);
10
+ });
11
+
12
+ it('all language files have same keys as primary', () => {
13
+ if (!existsSync(i18nDir)) return;
14
+ const primaryKeys = getAllKeys(
15
+ JSON.parse(readFileSync(join(i18nDir, 'vi.json'), 'utf-8'))
16
+ );
17
+
18
+ const langFiles = readdirSync(i18nDir)
19
+ .filter(f => f.endsWith('.json') && f !== 'vi.json');
20
+
21
+ langFiles.forEach(file => {
22
+ const langKeys = getAllKeys(
23
+ JSON.parse(readFileSync(join(i18nDir, file), 'utf-8'))
24
+ );
25
+ const missing = primaryKeys.filter(k => !langKeys.includes(k));
26
+ expect(missing, `${file} missing keys: ${missing.join(', ')}`).toEqual([]);
27
+ });
28
+ });
29
+ });
30
+
31
+ function getAllKeys(obj, prefix = '') {
32
+ return Object.entries(obj).flatMap(([key, val]) => {
33
+ const fullKey = prefix ? `${prefix}.${key}` : key;
34
+ return typeof val === 'object' && val !== null
35
+ ? getAllKeys(val, fullKey)
36
+ : [fullKey];
37
+ });
38
+ }
@@ -0,0 +1,12 @@
1
+ ## What Changed
2
+ <!-- Brief description -->
3
+
4
+ ## Test Plan
5
+ - [ ] Tests pass (`npm run test:gate`)
6
+ - [ ] Staging verified
7
+ - [ ] i18n keys present in all languages
8
+ - [ ] No raw strings in UI
9
+
10
+ ## Deploy
11
+ - [ ] Ready for staging
12
+ - [ ] Ready for production (requires staging verification)
@@ -0,0 +1,29 @@
1
+ {
2
+ "project": {
3
+ "name": "{{PROJECT_NAME}}",
4
+ "type": "{{PROJECT_TYPE}}",
5
+ "primaryLanguage": "{{PRIMARY_LANG}}",
6
+ "targetLanguages": ["{{TARGET_LANGS}}"]
7
+ },
8
+ "github": {
9
+ "org": "{{GITHUB_ORG}}",
10
+ "repo": "{{GITHUB_ORG}}/{{PROJECT_NAME}}"
11
+ },
12
+ "cloudflare": {
13
+ "accountId": "{{CF_ACCOUNT_ID}}",
14
+ "projectName": "{{PROJECT_NAME}}",
15
+ "customDomain": "{{DOMAIN}}"
16
+ },
17
+ "deploy": {
18
+ "staging": {
19
+ "branch": "main",
20
+ "url": "https://{{PROJECT_NAME}}.pages.dev"
21
+ },
22
+ "production": {
23
+ "branch": "production",
24
+ "url": "https://{{DOMAIN}}"
25
+ }
26
+ },
27
+ "createdAt": "{{ISO_DATE}}",
28
+ "createdBy": "cm-project-bootstrap v2.0"
29
+ }
@@ -0,0 +1,10 @@
1
+ // vitest.config.js (or vitest.config.ts)
2
+ import { defineConfig } from 'vitest/config';
3
+
4
+ export default defineConfig({
5
+ test: {
6
+ globals: true,
7
+ environment: 'node',
8
+ include: ['tests/**/*.test.{js,ts}'],
9
+ },
10
+ });
@@ -0,0 +1,218 @@
1
+ ---
2
+ name: cm-quality-gate
3
+ description: "Use before any deployment or completion claim. Enforces test gates, evidence-based verification, and frontend safety checks. No deploy without passing. No claims without evidence."
4
+ ---
5
+
6
+ # Quality Gate — Test + Verify + Ship Safe
7
+
8
+ > **Role: QA Lead** — You enforce test gates, evidence-based verification, and frontend safety. No deploy without passing you.
9
+
10
+ > **Three checkpoints, one skill:** Pre-deploy testing, evidence verification, frontend safety.
11
+
12
+ ## The Iron Laws
13
+ 1. **NO DEPLOY** without passing `test:gate`.
14
+ 2. **NO CLAIMS** without fresh verification output.
15
+ 3. **NO FRAGILE FRONTEND** — safety tests are mandatory.
16
+
17
+ ---
18
+
19
+ ## Phase 0: Infrastructure Setup
20
+ > **Goal:** Identify the framework and install the correct testing dependencies.
21
+
22
+ 1. **Detect Stack:** Check `package.json` for framework (React, Vue, Astro, etc.) and `wrangler.json(c)`.
23
+ 2. **Install Deps:** `npm install -D vitest jsdom acorn`
24
+ 3. **Configure:** Create `vitest.config.ts` or `vite.config.ts` with `environment: 'jsdom'`.
25
+ 4. **Wire Scripts:**
26
+ ```json
27
+ {
28
+ "scripts": {
29
+ "test:gate": "vitest run --reporter=verbose"
30
+ }
31
+ }
32
+ ```
33
+
34
+ ---
35
+
36
+ ## Phase 1: The 4 Core Test Layers
37
+ Do not combine these files. They form the "Quality Gate."
38
+
39
+ ### Layer 1: Frontend Safety (`test/frontend-safety.test.ts`)
40
+ Prevents white screens, template corruption, and syntax errors.
41
+ ```javascript
42
+ test('app.js does not contain catastrophic corruption', () => {
43
+ const code = fs.readFileSync('public/static/app.js', 'utf-8');
44
+ expect(code).not.toMatch(/=\s*'[^']*\$\{t\(/); // Bug #1
45
+ expect(code).not.toMatch(/<\s+[a-zA-Z]/); // Bug #2
46
+ });
47
+ ```
48
+
49
+ ### Layer 2: API Routes (`test/api-routes.test.ts`)
50
+ Ensures backend endpoints respond correctly.
51
+
52
+ ### Layer 3: Business Logic (`test/business-logic.test.ts`)
53
+ Tests pure functions, validations, and transformations.
54
+
55
+ ### Layer 4: i18n Synchronization (`test/i18n-sync.test.ts`)
56
+ Guarantees all language files have identical key counts.
57
+
58
+ ---
59
+
60
+ ## Phase 2: Execution (The Gates)
61
+
62
+ ### Gate 1: Pre-Deploy Testing
63
+ **ALWAYS** run `npm run test:gate` before deploying. 0 failures required.
64
+
65
+ ### Protocol
66
+
67
+ 1. **Check for skip override** (explicit user words only):
68
+ - ✅ "skip tests", "skip testing", "deploy without testing"
69
+ - ❌ "deploy", "quick deploy", "just push it" (= tests required)
70
+
71
+ 2. **Run test gate:**
72
+ ```bash
73
+ npm run test:gate
74
+ ```
75
+
76
+ 3. **Parse results:** total files, total tests, failures, duration
77
+
78
+ 4. **Gate decision:**
79
+ - 0 failures → proceed to deploy
80
+ - Any failures → **STOP. Fix first. Do NOT deploy.**
81
+
82
+ ### Anti-Patterns
83
+
84
+ | DON'T | DO |
85
+ |-------|-----|
86
+ | Deploy then test | Test then deploy |
87
+ | "Tests passed earlier" | Run fresh test:gate NOW |
88
+ | Skip for "small changes" | Every change gets tested |
89
+ | Run test + deploy parallel | Sequential: test → gate → deploy |
90
+
91
+ ### Gate 2: Evidence Before Claims
92
+ **ALWAYS** run the proving command before saying "fixed" or "done."
93
+
94
+ ### The Gate Function
95
+
96
+ ```
97
+ 1. IDENTIFY → What command proves this claim?
98
+ 2. RUN → Execute the FULL command (fresh)
99
+ 3. READ → Full output, check exit code
100
+ 4. VERIFY → Does output confirm the claim?
101
+ 5. ONLY THEN → Make the claim
102
+ ```
103
+
104
+ ### Common Failures
105
+
106
+ | Claim | Requires | Not Sufficient |
107
+ |-------|----------|----------------|
108
+ | Tests pass | Test output: 0 failures | "Should pass", previous run |
109
+ | Build succeeds | Build: exit 0 | Linter passing |
110
+ | Bug fixed | Test symptom: passes | Code changed, assumed fixed |
111
+ | Requirements met | Line-by-line checklist | Tests passing |
112
+
113
+ ### Red Flags — STOP
114
+ - Using "should", "probably", "seems to"
115
+ - Expressing satisfaction before verification
116
+ - Trusting agent success reports
117
+ - ANY wording implying success without running verification
118
+
119
+ ### Gate 3: Frontend Integrity
120
+ Automated via Layer 1 above.
121
+
122
+ ### When
123
+ Setting up or enhancing test suites for projects with frontend JavaScript/TypeScript.
124
+
125
+ ### The 7 Layers
126
+
127
+ | Layer | What it checks | Priority |
128
+ |-------|---------------|----------|
129
+ | 1. Syntax Validation | JS parses without errors (via acorn) | **CRITICAL** |
130
+ | 2. Function Integrity | Named functions exist and are callable | Required |
131
+ | 3. Template Safety | HTML templates have matching tags | Required |
132
+ | 4. Asset References | Referenced files actually exist | Required |
133
+ | 5. Corruption Patterns | Known bad patterns (empty functions, truncation) | Required |
134
+ | 6. Import/Export | Module references resolve | Recommended |
135
+ | 7. CSS Validation | CSS files parse correctly | Recommended |
136
+
137
+ ### Setup
138
+
139
+ ```bash
140
+ npm install -D vitest acorn
141
+ ```
142
+
143
+ ### Layer 1: Syntax Check (Most Critical)
144
+
145
+ ```javascript
146
+ import { parse } from 'acorn';
147
+ import { readFileSync } from 'fs';
148
+
149
+ test('app.js has valid syntax', () => {
150
+ const code = readFileSync('public/static/app.js', 'utf-8');
151
+ expect(() => parse(code, { ecmaVersion: 2022, sourceType: 'script' })).not.toThrow();
152
+ });
153
+ ```
154
+
155
+ > This single test would have prevented the March 2026 white-screen incident.
156
+
157
+ ---
158
+
159
+ ### Gate 4: Update Working Memory
160
+
161
+ Per `_shared/helpers.md#Update-Continuity`
162
+
163
+ After ALL gates pass → record `✅ Quality gate passed: [test count] tests, 0 failures`
164
+
165
+ After ANY gate fails → **FIRST run Memory Integrity Check:**
166
+ 1. List active learnings/decisions for the failing module
167
+ 2. Ask: "Did AI follow a learning/decision that caused this failure?"
168
+ 3. If YES → HEAL memory (invalidate/correct/scope-reduce) BEFORE recording new learning
169
+ 4. Record meta-learning in `.cm/meta-learnings.json` if memory was the cause
170
+
171
+ ---
172
+
173
+ ### Gate 5: Quality Score Report
174
+
175
+ After all gates execute, output a numeric quality score:
176
+
177
+ ```
178
+ 🎯 Gate Score: 87/100
179
+ ├── Secret Scan: 10/10 ✅
180
+ ├── Syntax: 10/10 ✅
181
+ ├── Tests: 8/10 ⚠️ (2 skipped tests)
182
+ ├── i18n Parity: 10/10 ✅
183
+ ├── Build: 10/10 ✅
184
+ ├── Dist Verify: 10/10 ✅
185
+ ├── Frontend Safety: 9/10 ✅
186
+ └── Coverage: 7/10 ⚠️ (75% vs 80% target)
187
+ ```
188
+
189
+ **Scoring Rules:**
190
+ | Component | Max | How to Score |
191
+ |-----------|-----|-------------|
192
+ | Secret Scan | 10 | 10 = clean, 0 = any secret found |
193
+ | Syntax | 10 | 10 = no errors, 0 = parse fails |
194
+ | Tests | 15 | 15 = all pass, −2 per failure, −1 per skip |
195
+ | i18n | 10 | 10 = parity, −5 per mismatch |
196
+ | Build | 15 | 15 = clean build, 0 = build fails |
197
+ | Dist Verify | 10 | 10 = all files present, −2 per missing |
198
+ | Frontend Safety | 15 | 15 = all layers pass, −3 per failure |
199
+ | Coverage | 15 | 15 = ≥80%, scale down linearly |
200
+
201
+ **Thresholds:**
202
+ - **≥80** → ✅ **PASS** — safe to deploy
203
+ - **60-79** → ⚠️ **WARN** — deploy with caution, document risks
204
+ - **<60** → ❌ **FAIL** — fix before deploy
205
+
206
+ ---
207
+
208
+ ## Integration
209
+ | Skill | Relationship |
210
+ |-------|-------------|
211
+ | `cm-safe-deploy` | Quality gate is the primary blocker for the deploy pipeline |
212
+ | `cm-identity-guard` | Verify identity before using quality gate to ship |
213
+ | `cm-tdd` | TDD creates the logic for Layer 3 |
214
+ | `cm-safe-i18n` | Leverages Layer 4 for parity checks |
215
+
216
+ ## The Bottom Line
217
+
218
+ **Test before deploy. Evidence before claims. Safety before shipping. Non-negotiable.**