@epiccontext/mcp 0.1.46 → 0.1.48

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/dist/cli/files.js CHANGED
@@ -1,2312 +1,557 @@
1
1
  import * as fs from "fs";
2
2
  import * as path from "path";
3
3
  import { getStorybookTemplateFiles } from "../templates/storybook.js";
4
- /**
5
- * Read all markdown files from a directory recursively
6
- */
7
- export function readContextFolder(contextPath) {
8
- const files = [];
9
- if (!fs.existsSync(contextPath)) {
10
- return files;
11
- }
12
- function walkDir(dir, relativeTo) {
13
- const entries = fs.readdirSync(dir, { withFileTypes: true });
14
- for (const entry of entries) {
15
- const fullPath = path.join(dir, entry.name);
16
- const relativePath = path.relative(relativeTo, fullPath);
17
- if (entry.isDirectory()) {
18
- // Skip hidden directories and node_modules
19
- if (!entry.name.startsWith(".") && entry.name !== "node_modules") {
20
- walkDir(fullPath, relativeTo);
21
- }
22
- }
23
- else if (entry.isFile() && entry.name.endsWith(".md")) {
24
- // Skip README and AI-GUIDE
25
- const lowerName = entry.name.toLowerCase();
26
- if (lowerName !== "readme.md" && lowerName !== "ai-guide.md") {
27
- const content = fs.readFileSync(fullPath, "utf-8");
28
- files.push({
29
- path: relativePath,
30
- content,
31
- });
32
- }
33
- }
34
- }
35
- }
36
- walkDir(contextPath, contextPath);
37
- return files;
38
- }
39
- /**
40
- * Write files to the context folder
41
- * By default, skips files where local version is newer than cloud version
42
- */
43
- export function writeContextFolder(contextPath, files, options = {}) {
44
- let written = 0;
45
- let skipped = 0;
46
- const skippedPaths = [];
47
- for (const file of files) {
48
- const fullPath = path.join(contextPath, file.path);
49
- const dir = path.dirname(fullPath);
50
- // Create directory if needed
51
- if (!fs.existsSync(dir)) {
52
- fs.mkdirSync(dir, { recursive: true });
53
- }
54
- // Always overwrite AI-GUIDE.md (it's server-generated and should be authoritative)
55
- // This ensures users get the latest block type definitions on every pull
56
- const isAIGuide = file.path.toLowerCase() === "ai-guide.md";
57
- // Check if local file is newer than cloud version (unless force is set or it's AI-GUIDE.md)
58
- if (!options.force && !isAIGuide && file.updatedAt && fs.existsSync(fullPath)) {
59
- const localMtime = getFileModTime(fullPath);
60
- const cloudMtime = new Date(file.updatedAt);
61
- if (localMtime && localMtime > cloudMtime) {
62
- // Local file is newer, skip overwriting
63
- skipped++;
64
- skippedPaths.push(file.path);
65
- continue;
66
- }
67
- }
68
- // Write file
69
- try {
70
- fs.writeFileSync(fullPath, file.content, "utf-8");
71
- written++;
72
- }
73
- catch (error) {
74
- console.error(`Failed to write ${file.path}:`, error);
75
- skipped++;
76
- }
77
- }
78
- return { written, skipped, skippedPaths };
79
- }
80
- /**
81
- * Delete local files that don't exist in the cloud
82
- * Used during pull to remove files that were deleted in the UI
83
- */
84
- export function deleteOrphanedLocalFiles(contextPath, cloudFiles) {
85
- // Build a set of all cloud file paths (normalized)
86
- const cloudPaths = new Set();
87
- for (const file of cloudFiles) {
88
- cloudPaths.add(file.path);
89
- }
90
- // Get all local markdown files
91
- const localFiles = readContextFolder(contextPath);
92
- const deleted = [];
93
- for (const localFile of localFiles) {
94
- // If local file doesn't exist in cloud, delete it
95
- if (!cloudPaths.has(localFile.path)) {
96
- const fullPath = path.join(contextPath, localFile.path);
97
- try {
98
- fs.unlinkSync(fullPath);
99
- deleted.push(localFile.path);
100
- }
101
- catch (error) {
102
- console.error(`Failed to delete ${localFile.path}:`, error);
103
- }
104
- }
105
- }
106
- return { deleted: deleted.length, deletedPaths: deleted };
107
- }
108
- /**
109
- * Ensure the context folder exists with basic structure
110
- */
111
- export function ensureContextFolder(contextPath) {
112
- if (!fs.existsSync(contextPath)) {
113
- fs.mkdirSync(contextPath, { recursive: true });
114
- }
115
- // Create default section folders
116
- // Note: folder names use hyphens, but section types in the app use underscores
117
- const defaultSections = [
118
- "constitution",
119
- "brand",
120
- "product",
121
- "business-strategy",
122
- "users",
123
- "research",
124
- "technical",
125
- "design-system",
126
- "information-architecture",
127
- "metrics",
128
- "decisions",
129
- "development",
130
- "marketing",
131
- ];
132
- for (const section of defaultSections) {
133
- const sectionPath = path.join(contextPath, section);
134
- if (!fs.existsSync(sectionPath)) {
135
- fs.mkdirSync(sectionPath, { recursive: true });
136
- }
137
- }
138
- // Create README.md
139
- const readmePath = path.join(contextPath, "README.md");
140
- if (!fs.existsSync(readmePath)) {
141
- const readme = `# CONTEXT
142
-
143
- This folder contains product context documentation synced with EpicContext.
144
-
145
- ## IMPORTANT: File Format
146
-
147
- **All markdown files MUST have YAML frontmatter with these required fields:**
148
-
149
- \`\`\`yaml
150
- ---
151
- type: persona # Block type (persona, feature, decision, etc.)
152
- section: brand # Section name (must match folder name)
153
- key: unique-key # Unique identifier (use kebab-case)
154
- name: Display Name # Human-readable name
155
- status: draft # Status: draft, complete, or empty
156
- ---
157
- \`\`\`
158
-
159
- See \`AI-GUIDE.md\` for detailed format instructions.
160
-
161
- ## Structure
162
-
163
- Each folder represents a section of your product documentation:
164
-
165
- - \`constitution/\` - Non-negotiable rules and principles
166
- - \`brand/\` - Identity, voice, and visual system
167
- - \`product/\` - Vision, features, and roadmap
168
- - \`business-strategy/\` - Strategic planning and business models
169
- - \`users/\` - Personas, jobs to be done, and user journeys
170
- - \`research/\` - Market and competitor analysis
171
- - \`technical/\` - Stack, architecture, and constraints
172
- - \`design-system/\` - Links to Storybook and Figma
173
- - \`information-architecture/\` - Site structure and taxonomies
174
- - \`metrics/\` - KPIs and analytics
175
- - \`decisions/\` - Architecture decision records
176
- - \`development/\` - Epics, stories, tasks, and roadmaps
177
- - \`marketing/\` - Marketing campaigns and SEO content strategy
178
-
179
- ## Syncing
180
-
181
- This folder is synced with your EpicContext project using the MCP server.
182
-
183
- To sync changes:
184
- \`\`\`bash
185
- epicontext sync
186
- \`\`\`
187
-
188
- To watch for changes and auto-sync:
189
- \`\`\`bash
190
- epicontext watch
191
- \`\`\`
192
- `;
193
- fs.writeFileSync(readmePath, readme, "utf-8");
194
- }
195
- // Create AI-GUIDE.md with detailed format instructions
196
- const aiGuidePath = path.join(contextPath, "AI-GUIDE.md");
197
- if (!fs.existsSync(aiGuidePath)) {
198
- const aiGuide = `# AI Agent Guide for EpicContext
199
-
200
- This file contains instructions for AI agents (Claude, Cursor, etc.) on how to create and edit documentation files in this CONTEXT folder.
201
-
202
- ## CRITICAL: Required YAML Frontmatter
203
-
204
- Every markdown file in this folder **MUST** have YAML frontmatter with these required fields:
205
-
206
- \`\`\`yaml
207
- ---
208
- type: persona # REQUIRED: Block type (see list below)
209
- section: brand # REQUIRED: Section name (must match folder name)
210
- key: my-unique-key # REQUIRED: Unique identifier within section (use kebab-case)
211
- name: My Display Name # REQUIRED: Human-readable display name
212
- status: draft # REQUIRED: One of: draft, complete, empty
213
- ---
214
-
215
- Your content goes here after the frontmatter...
216
- \`\`\`
217
-
218
- ## Block Types by Section
219
-
220
- **Note:** Every section also supports \`section_guide\` blocks for section-specific AI instructions.
221
-
222
- ### constitution/
223
- - \`constraint\` - Technical, business, or resource constraints
224
- - \`implementation_log\` - Implementation tracking for AI agents
225
- - \`ai_rules\` - Rules and guidelines for AI agents
226
- - \`context_guide\` - Guide for using this context
227
- - \`glossary\` - Domain-specific terminology and definitions
228
-
229
- ### brand/
230
- - \`brand_positioning\` - Golden Circle (WHY/HOW/WHAT) + Positioning Statement
231
- - \`brand_color_palette\` - Visual color palette with hex, RGB, and usage
232
- - \`brand_typography\` - Font families with preview at all sizes
233
- - \`brand_iconography\` - Icon library selection and style guide
234
- - \`tone_of_voice\` - Voice archetype, tone attributes, vocabulary
235
- - \`messaging_framework\` - Elevator pitch, value props, CTAs
236
- - \`logo\` - Logo assets with multiple background versions
237
- - \`brand_assets\` - Photography, illustrations, patterns, graphics
238
-
239
- ### product/
240
- - \`product_overview\` - Vision, overview, strategy
241
- - \`feature\` - Feature definitions
242
- - \`feature_market_analysis\` - Feature competitive analysis
243
- - \`product_strategy_canvas\` - Product strategy canvas
244
-
245
- ### business-strategy/
246
- - \`ogsm\` - Objectives, Goals, Strategies, Measures framework
247
- - \`obeya_board\` - Visual management board
248
- - \`swot_analysis\` - SWOT analysis matrix
249
- - \`business_model_canvas\` - Business model canvas
250
- - \`porters_five_forces\` - Porter's Five Forces analysis
251
- - \`strategic_group_map\` - Strategic group mapping
252
-
253
- ### users/
254
- - \`persona\` - User personas
255
- - \`jtbd\` - Jobs to be done
256
- - \`journey_map\` - User journey maps
257
-
258
- ### research/
259
- - \`competitor\` - Competitor analysis
260
- - \`market_research\` - Market research and insights
261
- - \`user_research\` - User research findings
262
- - \`survey\` - Survey research with response data and analysis
263
-
264
- ### technical/
265
- - \`tech_stack\` - Technology stack (frontend, backend, infrastructure)
266
- - \`architecture_diagram\` - C4 model system architecture diagrams
267
- - \`integration\` - Third-party integrations
268
- - \`constraint\` - Technical constraints
269
- - \`dev_setup\` - Local development setup and prerequisites
270
- - \`api_endpoint\` - Individual API endpoint documentation
271
- - \`api_spec\` - Complete API specification (collection of endpoints in one file)
272
- - \`data_model\` - Individual database model/entity
273
- - \`data_schema\` - Complete database schema (collection of models in one file)
274
- - \`environment\` - Deployment environment configuration
275
- - \`testing_strategy\` - Testing philosophy and standards
276
- - \`cost_calculator\` - Infrastructure and operational costs breakdown
277
-
278
- ### design-system/
279
- - \`storybook_link\` - Link to hosted Storybook with authentication
280
- - \`figma_embed\` - Link to Figma design files
281
-
282
- ### information-architecture/
283
- - \`ia_tree\` - Information architecture tree (page hierarchy with links)
284
- - \`taxonomy\` - Hierarchical classification systems (content types, categories)
285
-
286
- ### metrics/
287
- - \`metric\` - Unified metrics (north_star, kpi, supporting, input types via metric_type field)
288
- - \`analytics_event\` - Analytics event definitions
289
-
290
- ### decisions/
291
- - \`decision\` - Architecture Decision Records (ADRs)
292
-
293
- ### development/
294
- - \`epic\` - Large initiatives that group user stories
295
- - \`user_story\` - User-facing features with acceptance criteria
296
- - \`task\` - Technical implementation tasks / AI agent plans
297
- - \`roadmap\` - Timeline view of epics and milestones
298
- - \`impact_effort_matrix\` - Prioritization matrix
299
- - \`release\` - Release planning
300
-
301
- ### marketing/
302
- - \`marketing_campaign\` - Paid advertising campaigns (Meta, Google, LinkedIn, TikTok) with creative assets
303
- - \`seo_content\` - SEO content strategy and optimization plans
304
-
305
- ## Example Files
306
-
307
- ### Tone of Voice Block
308
- \`\`\`markdown
309
- ---
310
- type: tone_of_voice
311
- section: brand
312
- key: brand-voice
313
- name: Brand Voice
314
- status: draft
315
- ---
316
-
317
- # Brand Voice
318
-
319
- ## Brand Personality
320
- Professional, helpful, clear, innovative
321
-
322
- **Archetype:** The Sage
323
-
324
- ## We Are...
325
- - Clear and concise
326
- - Helpful and supportive
327
- - Professional yet approachable
328
-
329
- ## We Are NOT...
330
- - Overly casual or slangy
331
- - Condescending or preachy
332
- \`\`\`
333
-
334
- ### Persona Block
335
- \`\`\`markdown
336
- ---
337
- type: persona
338
- section: users
339
- key: primary-user
340
- name: Primary User Persona
341
- status: draft
342
- role: Product Manager
343
- tech_comfort: advanced
344
- is_primary: true
345
- ---
346
-
347
- # Sarah - Product Manager
348
-
349
- > "I need tools that help me stay organized without adding overhead."
350
-
351
- **Role:** Product Manager
352
- **Primary Persona:** true
353
- **Tech Comfort:** advanced
354
-
355
- ## Profile
356
-
357
- **Age:** 28-35
358
- **Education:** Bachelor's
359
- **Location:** San Francisco
360
- **Gender:** Female
361
- **Occupation:** Product Manager
362
- **Relationship Status:**
363
-
364
- **Personality Traits:** Organized, Data-driven, Collaborative
365
-
366
- ## Motivations
367
-
368
- Values efficiency and wants to ensure the team works from a single source of truth.
369
-
370
- ## Goals
371
-
372
- - Ship features faster
373
- - Keep stakeholders informed
374
- - Reduce context switching
375
-
376
- ## Pain Points
377
-
378
- - Too many disconnected tools
379
- - Context switching overhead
380
- - Hard to keep documentation up to date
381
-
382
- ## Behaviors
383
-
384
- - Uses multiple productivity tools daily
385
- - Prefers async communication
386
- - Documents decisions thoroughly
387
-
388
- ### Tools
389
- Notion, Slack, Figma, Linear
390
-
391
- ## Jobs to Be Done
392
-
393
- - When I plan a sprint, I want to see all relevant context, so I can make informed prioritization decisions
394
- \`\`\`
395
-
396
- ### Decision Block (ADR)
397
- \`\`\`markdown
398
- ---
399
- type: decision
400
- section: decisions
401
- key: database-choice
402
- name: Database Technology Choice
403
- status: complete
404
- ---
405
-
406
- # ADR-001: Database Technology Choice
407
-
408
- **Date:** 2024-01-15
409
- **Status:** Accepted
410
-
411
- ### Context
412
- We need to choose a database for our application...
413
-
414
- ### Decision
415
- We will use PostgreSQL with Supabase...
416
-
417
- ### Rationale
418
- PostgreSQL offers the best balance of features...
419
-
420
- ### Consequences
421
- - Need to set up Supabase project
422
- - Team needs PostgreSQL knowledge
423
- \`\`\`
424
-
425
- ### Feature Block
426
- \`\`\`markdown
427
- ---
428
- type: feature
429
- section: product
430
- key: user-auth
431
- name: User Authentication
432
- status: draft
433
- ---
434
-
435
- # User Authentication
436
-
437
- Enable users to create accounts and sign in securely.
438
-
439
- **Priority:** Must Have
440
- **Status:** Planned
441
-
442
- ### User Story
443
- As a user, I want to create an account so that I can save my preferences.
444
-
445
- ### Acceptance Criteria
446
- - Users can sign up with email
447
- - Users can sign in with password
448
- - Password reset flow works
449
- \`\`\`
450
-
451
- ### Journey Map Block (with Block Reference)
452
- \`\`\`markdown
453
- ---
454
- type: journey_map
455
- section: users
456
- key: user-onboarding
457
- name: User Onboarding Journey
458
- status: draft
459
- persona_ref: primary-user
460
- ---
461
-
462
- # User Onboarding Journey
463
-
464
- A journey map showing how new users get started with our product.
465
-
466
- ## Phases
467
- 1. Discovery
468
- 2. Sign Up
469
- 3. First Use
470
-
471
- ## Steps
472
-
473
- ### Step 1: Landing Page
474
- **Phase:** Discovery
475
- **Actions:**
476
- - User visits homepage
477
- - Reads value proposition
478
-
479
- **Experience:**
480
- - gain: Clear messaging (impact: 2)
481
- - pain: Too much information (impact: -1)
482
-
483
- **Insights:**
484
- - Users want quick overview
485
- \`\`\`
486
-
487
- ### Information Architecture Block (ia_tree)
488
-
489
- IA tree blocks document the application's page hierarchy, navigation structure, and connections between pages. They use embedded JSON in a \`sync:data\` block with a \`tree\` (hierarchy) and \`links\` (connections) structure.
490
-
491
- #### Purpose
492
- - Map out the complete site/app structure visually
493
- - Show parent-child relationships between pages
494
- - Document modals, sections, and components within pages
495
- - **Define connections/links between pages and components**
496
- - Track page types with visual differentiation
497
-
498
- #### Data Structure
499
-
500
- The sync:data block contains two top-level properties:
501
-
502
- \`\`\`json
503
- {
504
- "tree": { ... }, // The page/node hierarchy (IATreeNode)
505
- "links": [ ... ] // Connections between nodes (IALink[])
506
- }
507
- \`\`\`
508
-
509
- #### Node Structure (IATreeNode)
510
-
511
- | Property | Required | Description |
512
- |----------|----------|-------------|
513
- | \`id\` | Yes | Unique identifier (use kebab-case, e.g., "user-settings") |
514
- | \`label\` | Yes | Display name shown in the UI |
515
- | \`type\` | Yes | Node type: \`page\`, \`modal\`, \`external\`, or \`node\` |
516
- | \`url\` | No | Route path for navigable pages (e.g., "/dashboard") |
517
- | \`description\` | No | Brief description of the page/section purpose |
518
- | \`position\` | Yes | Visual position: \`{ "x": number, "y": number }\` |
519
- | \`children\` | No | Array of child nodes |
520
- | \`subNodes\` | No | Sections/components within this page |
521
- | \`isNew\` | No | Flag to show "NEW" badge on the node |
522
-
523
- #### Node Types (Visual Shapes)
524
-
525
- | Type | Visual | Description |
526
- |------|--------|-------------|
527
- | \`page\` | Square (sharp corners) | A routable page/screen |
528
- | \`modal\` | Rounded (large radius) | Modal/dialog overlay |
529
- | \`external\` | Dashed border | External link |
530
- | \`node\` | Rounded corners | Generic structural node |
531
-
532
- #### Sub-Node Types (Content Areas Within Nodes)
533
-
534
- | Type | Description |
535
- |------|-------------|
536
- | \`section\` | A major content section |
537
- | \`component\` | A reusable UI component |
538
- | \`widget\` | Interactive widget/feature |
539
-
540
- Sub-nodes appear inside their parent node and can be the source of links to other nodes.
541
-
542
- #### Link Structure (IALink)
543
-
544
- Links define relationships and navigation paths between nodes. **IMPORTANT:** You MUST include the \`links\` array to show connections.
545
-
546
- | Property | Required | Description |
547
- |----------|----------|-------------|
548
- | \`id\` | Yes | Unique ID for the link (e.g., "link-login-to-dashboard") |
549
- | \`sourceId\` | Yes | ID of the source node |
550
- | \`targetId\` | Yes | ID of the target node |
551
- | \`sourceSubNodeId\` | No | If link starts from a sub-node, its ID |
552
- | \`type\` | Yes | Link type (see below) |
553
- | \`label\` | No | Description of the connection |
554
-
555
- #### Link Types
556
-
557
- | Type | Color | Style | Use Case |
558
- |------|-------|-------|----------|
559
- | \`action\` | Green (#22c55e) | Solid | User action that navigates (clicks, taps) |
560
- | \`related\` | Purple (#8b5cf6) | Solid | Related content connection |
561
- | \`parent\` | Blue (#3b82f6) | Solid | Parent-child hierarchy |
562
- | \`references\` | Amber (#f59e0b) | Dashed | Content reference/link |
563
-
564
- #### Connection Types
565
-
566
- **1. Node → Node Connection:**
567
- \`\`\`json
568
- {
569
- "id": "link-home-to-settings",
570
- "sourceId": "home-page",
571
- "targetId": "settings-modal",
572
- "type": "action",
573
- "label": "Opens settings"
574
- }
575
- \`\`\`
576
-
577
- **2. Sub-Node → Node Connection:**
578
- \`\`\`json
579
- {
580
- "id": "link-cta-to-signup",
581
- "sourceId": "home-page",
582
- "sourceSubNodeId": "hero-cta-button",
583
- "targetId": "signup-page",
584
- "type": "action",
585
- "label": "Sign up CTA click"
586
- }
587
- \`\`\`
588
-
589
- #### Complete Example
590
-
591
- \`\`\`markdown
592
- ---
593
- type: ia_tree
594
- section: information-architecture
595
- key: app-structure
596
- name: Application Structure
597
- status: draft
598
- ---
599
-
600
- # Application Structure
601
-
602
- Complete information architecture showing pages, modals, and navigation flows.
603
-
604
- <!-- sync:data -->
605
- \\\`\`\`json
606
- {
607
- "tree": {
608
- "id": "app-root",
609
- "label": "Application",
610
- "type": "node",
611
- "description": "Root application node",
612
- "position": { "x": 50, "y": 50 },
613
- "children": [
614
- {
615
- "id": "login",
616
- "label": "Login",
617
- "type": "page",
618
- "url": "/login",
619
- "position": { "x": 50, "y": 200 },
620
- "subNodes": [
621
- { "id": "login-form", "name": "Login Form", "type": "component" },
622
- { "id": "forgot-link", "name": "Forgot Password Link", "type": "component" }
623
- ]
624
- },
625
- {
626
- "id": "dashboard",
627
- "label": "Dashboard",
628
- "type": "page",
629
- "url": "/dashboard",
630
- "description": "Main workspace",
631
- "position": { "x": 400, "y": 200 },
632
- "subNodes": [
633
- { "id": "project-grid", "name": "Project Grid", "type": "section" },
634
- { "id": "create-btn", "name": "Create Project Button", "type": "component" }
635
- ]
636
- },
637
- {
638
- "id": "new-project",
639
- "label": "New Project",
640
- "type": "modal",
641
- "description": "Create project dialog",
642
- "position": { "x": 750, "y": 200 }
643
- }
644
- ]
645
- },
646
- "links": [
647
- {
648
- "id": "link-login-form-to-dashboard",
649
- "sourceId": "login",
650
- "sourceSubNodeId": "login-form",
651
- "targetId": "dashboard",
652
- "type": "action",
653
- "label": "Successful login"
654
- },
655
- {
656
- "id": "link-forgot-to-reset",
657
- "sourceId": "login",
658
- "sourceSubNodeId": "forgot-link",
659
- "targetId": "password-reset",
660
- "type": "action",
661
- "label": "Forgot password flow"
662
- },
663
- {
664
- "id": "link-create-btn-to-modal",
665
- "sourceId": "dashboard",
666
- "sourceSubNodeId": "create-btn",
667
- "targetId": "new-project",
668
- "type": "action",
669
- "label": "Opens create dialog"
670
- },
671
- {
672
- "id": "link-modal-to-dashboard",
673
- "sourceId": "new-project",
674
- "targetId": "dashboard",
675
- "type": "action",
676
- "label": "After creation, returns to dashboard"
677
- }
678
- ]
679
- }
680
- \\\`\`\`
681
- <!-- /sync:data -->
682
- \`\`\`
683
-
684
- #### Best Practices
685
-
686
- 1. **Always include positions for nodes:**
687
- Space nodes ~300-400px apart horizontally, ~150-200px vertically to avoid overlap.
688
-
689
- 2. **Create meaningful connections:**
690
- - Every sub-node that leads somewhere should have a link
691
- - Data flows should show input → processing → output
692
- - User journeys should connect in logical sequence
693
-
694
- 3. **Use descriptive IDs:**
695
- - Node IDs: \`home-page\`, \`settings-modal\`, \`auth-flow\`
696
- - Sub-node IDs: \`nav-menu\`, \`hero-cta\`, \`project-list\`
697
- - Link IDs: \`link-nav-to-dashboard\`, \`link-cta-to-signup\`
698
-
699
- 4. **Group related nodes visually:**
700
- - Authentication pages together (x: 50-300)
701
- - Dashboard pages together (x: 400-700)
702
- - Settings/admin together (x: 800-1100)
703
-
704
- 5. **Choose appropriate link types:**
705
- - \`action\`: User clicks/taps to navigate
706
- - \`related\`: Content is related but not direct navigation
707
- - \`parent\`: Hierarchical relationship
708
- - \`references\`: One content references another
709
-
710
- #### Common Mistakes
711
-
712
- WRONG: Missing links array
713
- \`\`\`json
714
- { "tree": { "id": "root", ... } }
715
- \`\`\`
716
-
717
- CORRECT: Always include links (even if empty)
718
- \`\`\`json
719
- { "tree": { "id": "root", ... }, "links": [] }
720
- \`\`\`
721
-
722
- WRONG: Missing position for nodes
723
- \`\`\`json
724
- { "id": "dashboard", "label": "Dashboard", "type": "page" }
725
- \`\`\`
726
-
727
- CORRECT: Always include position
728
- \`\`\`json
729
- { "id": "dashboard", "label": "Dashboard", "type": "page", "position": { "x": 400, "y": 200 } }
730
- \`\`\`
731
-
732
- WRONG: Link without type
733
- \`\`\`json
734
- { "id": "link-1", "sourceId": "a", "targetId": "b" }
735
- \`\`\`
736
-
737
- CORRECT: Always specify link type
738
- \`\`\`json
739
- { "id": "link-1", "sourceId": "a", "targetId": "b", "type": "action" }
740
- \`\`\`
741
-
742
- ### Architecture Diagram Block (C4 Model)
743
-
744
- Architecture diagram blocks document system architecture visually using the C4 model (Context, Container, Component). They use embedded JSON in a \`sync:data\` block with \`elements\` and \`connections\`.
745
-
746
- #### Purpose
747
- - Visualize system architecture at different abstraction levels
748
- - Show how systems, containers, and components interact
749
- - Document communication patterns and technologies
750
- - Provide clear diagrams for different audiences (technical, leadership)
751
-
752
- #### C4 Model Levels
753
-
754
- | Level | Purpose | Shows | Audience |
755
- |-------|---------|-------|----------|
756
- | **Context** | Big picture | Systems + external actors | Everyone |
757
- | **Container** | Applications & data stores | Apps, databases, services within your system | Technical + Leadership |
758
- | **Component** | Inside a container | Components, modules, classes | Developers, Architects |
759
-
760
- #### Data Structure
761
-
762
- The sync:data block contains:
763
-
764
- \`\`\`json
765
- {
766
- "elements": [ ... ], // Systems, containers, components, people
767
- "connections": [ ... ], // Communication paths between elements
768
- "legend": [ ... ] // Optional color legend
769
- }
770
- \`\`\`
771
-
772
- #### Element Structure (ArchitectureElement)
773
-
774
- | Property | Required | Description |
775
- |----------|----------|-------------|
776
- | \`id\` | Yes | Unique identifier (kebab-case, e.g., "web-app") |
777
- | \`label\` | Yes | Display name shown in the diagram |
778
- | \`type\` | Yes | Element type (see types below) |
779
- | \`description\` | No | Brief description of what this element does |
780
- | \`technology\` | No | Technology stack (e.g., "React", "Node.js", "PostgreSQL") |
781
- | \`isExternal\` | No | True if outside your system boundary |
782
- | \`position\` | Yes | Visual position: \`{ "x": number, "y": number }\` |
783
- | \`color\` | No | Override default color (hex code) |
784
- | \`icon\` | No | Lucide icon name for visual representation |
785
-
786
- #### Element Types
787
-
788
- | Type | Default Color | Description | Visual |
789
- |------|--------------|-------------|--------|
790
- | \`system\` | #438DD5 (blue) | Software system (yours or external) | Large box |
791
- | \`container\` | #438DD5 (blue) | Application, service, database | Medium box |
792
- | \`component\` | #85BBF0 (light blue) | Module, class, or logical component | Small box |
793
- | \`person\` | #08427B (dark blue) | User, actor, or role | Person shape |
794
- | \`database\` | #438DD5 (blue) | Data store (SQL, NoSQL, file) | Cylinder |
795
- | \`queue\` | #438DD5 (blue) | Message queue, event stream | Rounded box |
796
- | \`external\` | #999999 (gray) | External system you don't control | Dashed box |
797
-
798
- #### Connection Structure (ArchitectureConnection)
799
-
800
- | Property | Required | Description |
801
- |----------|----------|-------------|
802
- | \`id\` | Yes | Unique ID (e.g., "conn-web-to-api") |
803
- | \`sourceId\` | Yes | ID of the source element |
804
- | \`targetId\` | Yes | ID of the target element |
805
- | \`label\` | No | Description of what flows (e.g., "REST API", "Events") |
806
- | \`communicationType\` | No | Type of communication (see below) |
807
- | \`technology\` | No | Protocol or technology (e.g., "HTTPS", "gRPC", "WebSocket") |
808
- | \`description\` | No | Additional details about the connection |
809
-
810
- #### Communication Types
811
-
812
- | Type | Arrow Style | Description |
813
- |------|-------------|-------------|
814
- | \`sync\` | Solid → | Synchronous request/response |
815
- | \`async\` | Dashed → | Asynchronous messaging |
816
- | \`read\` | Solid → (read) | Data read operation |
817
- | \`write\` | Solid → (write) | Data write operation |
818
- | \`bidirectional\` | ↔ | Two-way communication |
819
-
820
- #### Complete Example
821
-
822
- \`\`\`markdown
823
- ---
824
- type: architecture_diagram
825
- section: technical
826
- key: system-context
827
- name: System Context Diagram
828
- status: draft
829
- level: context
830
- audience: non-technical
831
- ---
832
-
833
- # System Context Diagram
834
-
835
- High-level overview of how our application fits into the broader ecosystem.
836
-
837
- ## Description
838
- This diagram shows our EpicContext application and how it interacts with external users and systems.
839
-
840
- <!-- sync:data -->
841
- \\\`\`\`json
842
- {
843
- "elements": [
844
- {
845
- "id": "user",
846
- "label": "Product Team",
847
- "type": "person",
848
- "description": "Uses EpicContext to manage product documentation",
849
- "position": { "x": 400, "y": 50 }
850
- },
851
- {
852
- "id": "epiccontext",
853
- "label": "EpicContext",
854
- "type": "system",
855
- "description": "SaaS platform for managing design context documentation",
856
- "technology": "Next.js, Supabase",
857
- "position": { "x": 400, "y": 250 }
4
+ // Section metadata for modular AI guides
5
+ // Note: "section_guide" is allowed in ALL sections but is a generic/admin type
6
+ const SECTION_INFO = {
7
+ constitution: {
8
+ name: "Constitution",
9
+ description: "Non-negotiable rules for all work",
10
+ folder: "constitution",
11
+ blockTypes: ["ai_rules", "context_guide", "constraint", "implementation_log", "glossary", "section_guide"],
858
12
  },
859
- {
860
- "id": "ai-agents",
861
- "label": "AI Coding Agents",
862
- "type": "person",
863
- "description": "Claude Code, Cursor, etc. that consume context",
864
- "position": { "x": 700, "y": 50 }
13
+ brand: {
14
+ name: "Brand",
15
+ description: "Identity, voice, and visual expression",
16
+ folder: "brand",
17
+ blockTypes: ["brand_positioning", "brand_visual_identity", "brand_moodboard", "tone_of_voice", "messaging_framework", "section_guide"],
865
18
  },
866
- {
867
- "id": "supabase",
868
- "label": "Supabase",
869
- "type": "external",
870
- "description": "Backend-as-a-Service for auth and database",
871
- "technology": "PostgreSQL",
872
- "isExternal": true,
873
- "position": { "x": 400, "y": 450 }
19
+ product: {
20
+ name: "Product",
21
+ description: "Vision, features, and roadmap",
22
+ folder: "product",
23
+ blockTypes: ["product_overview", "feature", "product_strategy_canvas", "feature_market_analysis", "section_guide"],
874
24
  },
875
- {
876
- "id": "clerk",
877
- "label": "Clerk",
878
- "type": "external",
879
- "description": "Authentication provider",
880
- "isExternal": true,
881
- "position": { "x": 150, "y": 250 }
25
+ users: {
26
+ name: "Users & Journeys",
27
+ description: "Personas, jobs to be done, and user journeys",
28
+ folder: "users",
29
+ blockTypes: ["persona", "jtbd", "journey_map", "section_guide"],
882
30
  },
883
- {
884
- "id": "mcp-server",
885
- "label": "MCP Server",
886
- "type": "system",
887
- "description": "Local server that syncs context to codebase",
888
- "technology": "Node.js",
889
- "position": { "x": 700, "y": 250 }
890
- }
891
- ],
892
- "connections": [
893
- {
894
- "id": "conn-user-to-app",
895
- "sourceId": "user",
896
- "targetId": "epiccontext",
897
- "label": "Manages documentation",
898
- "communicationType": "sync",
899
- "technology": "HTTPS"
900
- },
901
- {
902
- "id": "conn-app-to-supabase",
903
- "sourceId": "epiccontext",
904
- "targetId": "supabase",
905
- "label": "Stores data",
906
- "communicationType": "sync",
907
- "technology": "PostgreSQL/REST"
31
+ research: {
32
+ name: "Research",
33
+ description: "Market, competitors, and insights",
34
+ folder: "research",
35
+ blockTypes: ["competitor", "user_research", "research_data", "research_document", "section_guide"],
908
36
  },
909
- {
910
- "id": "conn-app-to-clerk",
911
- "sourceId": "epiccontext",
912
- "targetId": "clerk",
913
- "label": "Authenticates users",
914
- "communicationType": "sync",
915
- "technology": "HTTPS"
37
+ technical: {
38
+ name: "Technical",
39
+ description: "Stack, architecture, and constraints",
40
+ folder: "technical",
41
+ blockTypes: ["tech_stack", "architecture_diagram", "integration", "constraint", "dev_setup", "api_endpoint", "api_spec", "data_model", "data_schema", "environment", "testing_strategy", "cost_calculator", "section_guide"],
916
42
  },
917
- {
918
- "id": "conn-app-to-mcp",
919
- "sourceId": "epiccontext",
920
- "targetId": "mcp-server",
921
- "label": "Syncs via API",
922
- "communicationType": "sync",
923
- "technology": "REST API"
43
+ "design-system": {
44
+ name: "Design System",
45
+ description: "Components, tokens, and implementation patterns",
46
+ folder: "design-system",
47
+ blockTypes: ["storybook_link", "figma_embed", "section_guide"],
924
48
  },
925
- {
926
- "id": "conn-ai-to-mcp",
927
- "sourceId": "ai-agents",
928
- "targetId": "mcp-server",
929
- "label": "Reads context",
930
- "communicationType": "read",
931
- "technology": "MCP Protocol"
932
- }
933
- ],
934
- "legend": [
935
- { "color": "#08427B", "label": "Person/User" },
936
- { "color": "#438DD5", "label": "Our System" },
937
- { "color": "#999999", "label": "External System" }
938
- ]
939
- }
940
- \\\`\`\`
941
- <!-- /sync:data -->
942
- \`\`\`
943
-
944
- #### Container Level Example
945
-
946
- \`\`\`markdown
947
- ---
948
- type: architecture_diagram
949
- section: technical
950
- key: container-diagram
951
- name: Container Diagram
952
- status: draft
953
- level: container
954
- audience: technical
955
- ---
956
-
957
- # Container Diagram
958
-
959
- Applications and data stores that make up EpicContext.
960
-
961
- <!-- sync:data -->
962
- \\\`\`\`json
963
- {
964
- "elements": [
965
- {
966
- "id": "web-app",
967
- "label": "Web Application",
968
- "type": "container",
969
- "description": "SPA for managing context",
970
- "technology": "Next.js 14, React, TypeScript",
971
- "position": { "x": 200, "y": 100 }
49
+ "information-architecture": {
50
+ name: "Information Architecture",
51
+ description: "Site structure and navigation hierarchy",
52
+ folder: "information-architecture",
53
+ blockTypes: ["ia_tree", "taxonomy", "section_guide"],
972
54
  },
973
- {
974
- "id": "api",
975
- "label": "API Routes",
976
- "type": "container",
977
- "description": "Server-side API endpoints",
978
- "technology": "Next.js API Routes",
979
- "position": { "x": 500, "y": 100 }
55
+ metrics: {
56
+ name: "Metrics",
57
+ description: "KPIs and analytics",
58
+ folder: "metrics",
59
+ blockTypes: ["metric", "north_star", "kpi", "analytics_event", "section_guide"],
980
60
  },
981
- {
982
- "id": "database",
983
- "label": "Database",
984
- "type": "database",
985
- "description": "Stores all application data",
986
- "technology": "PostgreSQL (Supabase)",
987
- "position": { "x": 500, "y": 300 }
61
+ decisions: {
62
+ name: "Decisions",
63
+ description: "What we decided and why",
64
+ folder: "decisions",
65
+ blockTypes: ["decision", "section_guide"],
988
66
  },
989
- {
990
- "id": "file-storage",
991
- "label": "File Storage",
992
- "type": "database",
993
- "description": "Stores uploaded assets",
994
- "technology": "Supabase Storage",
995
- "position": { "x": 200, "y": 300 }
67
+ development: {
68
+ name: "Development",
69
+ description: "Epics, user stories, tasks, and roadmap",
70
+ folder: "development",
71
+ blockTypes: ["epic", "user_story", "task", "roadmap", "release", "impact_effort_matrix", "section_guide"],
996
72
  },
997
- {
998
- "id": "mcp-package",
999
- "label": "MCP Package",
1000
- "type": "container",
1001
- "description": "NPM package for local sync",
1002
- "technology": "Node.js, TypeScript",
1003
- "position": { "x": 750, "y": 200 }
1004
- }
1005
- ],
1006
- "connections": [
1007
- {
1008
- "id": "conn-web-to-api",
1009
- "sourceId": "web-app",
1010
- "targetId": "api",
1011
- "label": "API calls",
1012
- "communicationType": "sync",
1013
- "technology": "HTTPS/JSON"
73
+ "business-strategy": {
74
+ name: "Business & Strategy",
75
+ description: "Strategic planning frameworks and business models",
76
+ folder: "business-strategy",
77
+ blockTypes: ["ogsm", "business_model_canvas", "swot_analysis", "porters_five_forces", "strategic_group_map", "obeya_board", "section_guide"],
1014
78
  },
1015
- {
1016
- "id": "conn-api-to-db",
1017
- "sourceId": "api",
1018
- "targetId": "database",
1019
- "label": "Queries",
1020
- "communicationType": "bidirectional",
1021
- "technology": "Supabase Client"
79
+ marketing: {
80
+ name: "Marketing",
81
+ description: "Marketing campaigns, ads, and content strategy",
82
+ folder: "marketing",
83
+ blockTypes: ["marketing_campaign", "seo_content", "section_guide"],
1022
84
  },
1023
- {
1024
- "id": "conn-web-to-storage",
1025
- "sourceId": "web-app",
1026
- "targetId": "file-storage",
1027
- "label": "Uploads/Downloads",
1028
- "communicationType": "bidirectional",
1029
- "technology": "Supabase Storage API"
85
+ reports: {
86
+ name: "Reports",
87
+ description: "Business cases, pain point analysis, and user sentiment reports",
88
+ folder: "reports",
89
+ blockTypes: ["business_case", "pain_points_report", "user_sentiment_report", "section_guide"],
1030
90
  },
1031
- {
1032
- "id": "conn-mcp-to-api",
1033
- "sourceId": "mcp-package",
1034
- "targetId": "api",
1035
- "label": "Syncs context",
1036
- "communicationType": "sync",
1037
- "technology": "REST API"
1038
- }
1039
- ]
1040
- }
1041
- \\\`\`\`
1042
- <!-- /sync:data -->
1043
- \`\`\`
1044
-
1045
- #### Best Practices
1046
-
1047
- 1. **Choose the right level:**
1048
- - Start with Context for stakeholder communication
1049
- - Use Container for development planning
1050
- - Use Component for detailed design of complex containers
1051
-
1052
- 2. **Position elements logically:**
1053
- - Users/actors at top
1054
- - Your system in the middle
1055
- - External dependencies at bottom or sides
1056
- - Space elements ~200-300px apart
1057
-
1058
- 3. **Label connections clearly:**
1059
- - Use verbs: "Reads data", "Sends events", "Authenticates"
1060
- - Include technology when relevant: "REST API", "gRPC", "WebSocket"
1061
- - Keep labels concise but informative
1062
-
1063
- 4. **Use consistent colors:**
1064
- - Blue (#438DD5) for your internal systems
1065
- - Gray (#999999) for external systems
1066
- - Dark blue (#08427B) for people/users
1067
- - Add legend for custom colors
1068
-
1069
- 5. **Include technology details:**
1070
- - For Container level: framework, language, runtime
1071
- - For connections: protocol, message format
1072
- - Helps developers understand the stack
1073
-
1074
- 6. **Keep diagrams focused:**
1075
- - Context: 3-6 systems maximum
1076
- - Container: 5-10 containers maximum
1077
- - Component: 5-15 components maximum
1078
- - Create multiple diagrams if needed
1079
-
1080
- #### Common Mistakes
1081
-
1082
- WRONG: Missing positions
1083
- \`\`\`json
1084
- { "id": "api", "label": "API", "type": "container" }
1085
- \`\`\`
1086
-
1087
- CORRECT: Always include positions
1088
- \`\`\`json
1089
- { "id": "api", "label": "API", "type": "container", "position": { "x": 400, "y": 200 } }
1090
- \`\`\`
1091
-
1092
- WRONG: Vague connection labels
1093
- \`\`\`json
1094
- { "id": "conn-1", "sourceId": "a", "targetId": "b", "label": "uses" }
1095
- \`\`\`
1096
-
1097
- CORRECT: Specific, actionable labels
1098
- \`\`\`json
1099
- { "id": "conn-1", "sourceId": "a", "targetId": "b", "label": "Fetches user data", "technology": "REST API" }
1100
- \`\`\`
1101
-
1102
- WRONG: Too many elements on one diagram
1103
- Create separate diagrams for different aspects or zoom levels.
1104
-
1105
- CORRECT: Focused diagrams
1106
- - One Context diagram for the big picture
1107
- - Separate Container diagrams per major system
1108
- - Component diagrams only for complex containers
1109
-
1110
- ### Brand Section Blocks
1111
-
1112
- The brand section uses specialized visual block types that store complex data. These blocks use embedded JSON in \`sync:data\` blocks for reliable import/export.
1113
-
1114
- #### Brand Positioning Block
1115
-
1116
- Documents strategic brand positioning using the Golden Circle (WHY/HOW/WHAT) and Positioning Statement frameworks.
1117
-
1118
- **Fields:**
1119
- - \`brand_name\` - Your brand name
1120
- - \`tagline\` - Brand slogan/tagline
1121
- - \`positioning_statement\` - Structured positioning statement
1122
- - \`why_purpose\` - WHY: Why does the brand exist?
1123
- - \`how_approach\` - HOW: How do you deliver on your WHY?
1124
- - \`what_offering\` - WHAT: What products/services do you offer?
1125
-
1126
- **Example:**
1127
- \`\`\`markdown
1128
- ---
1129
- type: brand_positioning
1130
- section: brand
1131
- key: main-positioning
1132
- name: Brand Positioning
1133
- status: complete
1134
- ---
1135
-
1136
- # Brand Positioning
1137
-
1138
- Our strategic brand positioning defines why we exist and how we communicate value.
1139
-
1140
- ## Brand Identity
1141
-
1142
- **Brand Name:** EpicContext
1143
- **Tagline:** Context for AI, Clarity for Teams
1144
-
1145
- ## Positioning Statement
1146
-
1147
- For **product teams who use AI coding agents**,
1148
- **EpicContext** is the **context management platform**
1149
- that **gives AI agents complete product understanding**
1150
- unlike **scattered docs and chat conversations**,
1151
- because **we structure context in AI-native formats**.
1152
-
1153
- ## Golden Circle (WHY → HOW → WHAT)
1154
-
1155
- ### WHY - The Purpose
1156
- We believe AI coding agents can build better software when they truly understand the product context. We exist to bridge the gap between human knowledge and AI capability.
1157
-
1158
- ### HOW - The Unique Approach
1159
- By providing structured, versioned context documentation that syncs directly to codebases and AI tools, with visual editors that make documentation effortless.
1160
-
1161
- ### WHAT - The Products/Services
1162
- A SaaS platform with block-based editors for brand, product, users, and technical context, plus MCP integration for Claude and other AI agents.
1163
-
1164
- <!-- sync:data -->
1165
- \\\`\`\`json
1166
- {
1167
- "brand_name": "EpicContext",
1168
- "tagline": "Context for AI, Clarity for Teams",
1169
- "positioning_statement": {
1170
- "target_market": "product teams who use AI coding agents",
1171
- "category": "context management platform",
1172
- "unique_benefit": "gives AI agents complete product understanding",
1173
- "competitors": "scattered docs and chat conversations",
1174
- "reason_to_believe": "we structure context in AI-native formats"
1175
- },
1176
- "why_purpose": "We believe AI coding agents can build better software when they truly understand the product context. We exist to bridge the gap between human knowledge and AI capability.",
1177
- "how_approach": "By providing structured, versioned context documentation that syncs directly to codebases and AI tools, with visual editors that make documentation effortless.",
1178
- "what_offering": "A SaaS platform with block-based editors for brand, product, users, and technical context, plus MCP integration for Claude and other AI agents."
1179
- }
1180
- \\\`\`\`
1181
- <!-- /sync:data -->
1182
- \`\`\`
1183
-
1184
- ---
1185
-
1186
- #### Brand Color Palette Block
1187
-
1188
- Visual color palette with multiple color definitions including hex, RGB, CMYK, and Pantone values.
1189
-
1190
- **Structure:**
1191
- \`\`\`json
1192
- {
1193
- "description": "Overview of the color palette",
1194
- "palette": {
1195
- "colors": [
1196
- {
1197
- "id": "unique-id",
1198
- "name": "Color Name",
1199
- "hex": "#RRGGBB",
1200
- "rgb": "R, G, B",
1201
- "cmyk": "C, M, Y, K",
1202
- "pantone": "Pantone Code",
1203
- "category": "primary|secondary|neutral|accent|semantic",
1204
- "usage": "When to use this color"
1205
- }
1206
- ]
1207
- },
1208
- "usage_guidelines": "General color usage guidelines"
1209
- }
1210
- \`\`\`
1211
-
1212
- **Example:**
1213
- \`\`\`markdown
1214
- ---
1215
- type: brand_color_palette
1216
- section: brand
1217
- key: primary-colors
1218
- name: Primary Brand Colors
1219
- status: complete
1220
- ---
1221
-
1222
- # Primary Brand Colors
1223
-
1224
- Our primary color palette establishes brand recognition and visual hierarchy.
1225
-
1226
- ## Colors
1227
-
1228
- ### EpicContext Blue
1229
- - HEX: #3B82F6
1230
- - RGB: 59, 130, 246
1231
- - Usage: Primary actions, links, brand elements
1232
-
1233
- ### Success Green
1234
- - HEX: #22C55E
1235
- - RGB: 34, 197, 94
1236
- - Usage: Success states, positive actions
1237
-
1238
- ### Dark Gray
1239
- - HEX: #1F2937
1240
- - RGB: 31, 41, 55
1241
- - Usage: Primary text, headings
1242
-
1243
- ## Usage Guidelines
1244
- Use EpicContext Blue for primary CTAs and brand elements. Reserve Success Green for positive feedback only.
1245
-
1246
- <!-- sync:data -->
1247
- \\\`\`\`json
1248
- {
1249
- "description": "Our primary color palette establishes brand recognition and visual hierarchy.",
1250
- "palette": {
1251
- "colors": [
1252
- {
1253
- "id": "brand-blue",
1254
- "name": "EpicContext Blue",
1255
- "hex": "#3B82F6",
1256
- "rgb": "59, 130, 246",
1257
- "category": "primary",
1258
- "usage": "Primary actions, links, brand elements"
1259
- },
1260
- {
1261
- "id": "success-green",
1262
- "name": "Success Green",
1263
- "hex": "#22C55E",
1264
- "rgb": "34, 197, 94",
1265
- "category": "semantic",
1266
- "usage": "Success states, positive actions"
1267
- },
1268
- {
1269
- "id": "dark-gray",
1270
- "name": "Dark Gray",
1271
- "hex": "#1F2937",
1272
- "rgb": "31, 41, 55",
1273
- "category": "neutral",
1274
- "usage": "Primary text, headings"
1275
- }
1276
- ]
1277
- },
1278
- "usage_guidelines": "Use EpicContext Blue for primary CTAs and brand elements. Reserve Success Green for positive feedback only."
1279
- }
1280
- \\\`\`\`
1281
- <!-- /sync:data -->
1282
- \`\`\`
1283
-
1284
- ---
1285
-
1286
- #### Brand Typography Block
1287
-
1288
- Typography system with font family, weights, and preview sizes.
1289
-
1290
- **Structure:**
1291
- \`\`\`json
1292
- {
1293
- "description": "Overview of typography choices",
1294
- "typography": {
1295
- "fontFamily": "Font Name",
1296
- "fontRole": "primary|secondary|display|code",
1297
- "fontSource": "google|adobe|system|custom",
1298
- "fontSourceUrl": "URL to font",
1299
- "weights": ["400", "500", "600", "700"],
1300
- "styles": ["normal", "italic"],
1301
- "usage": "When to use this font"
1302
- }
1303
- }
1304
- \`\`\`
1305
-
1306
- **Example:**
1307
- \`\`\`markdown
1308
- ---
1309
- type: brand_typography
1310
- section: brand
1311
- key: primary-typography
1312
- name: Primary Typography
1313
- status: complete
1314
- ---
1315
-
1316
- # Primary Typography
1317
-
1318
- Our typography system uses Inter for its excellent readability and modern aesthetic.
1319
-
1320
- ## Font
1321
-
1322
- **Family:** Inter
1323
- **Role:** Primary (headings and body)
1324
- **Source:** Google Fonts
1325
-
1326
- ### Weights
1327
- - 400 (Regular)
1328
- - 500 (Medium)
1329
- - 600 (SemiBold)
1330
- - 700 (Bold)
1331
-
1332
- ### Usage
1333
- Use Inter for all UI text, headings, and body copy. Use 600 weight for emphasis, 700 for headings.
1334
-
1335
- <!-- sync:data -->
1336
- \\\`\`\`json
1337
- {
1338
- "description": "Our typography system uses Inter for its excellent readability and modern aesthetic.",
1339
- "typography": {
1340
- "fontFamily": "Inter",
1341
- "fontRole": "primary",
1342
- "fontSource": "google",
1343
- "fontSourceUrl": "https://fonts.google.com/specimen/Inter",
1344
- "weights": ["400", "500", "600", "700"],
1345
- "styles": ["normal"],
1346
- "usage": "Use Inter for all UI text, headings, and body copy. Use 600 weight for emphasis, 700 for headings."
1347
- }
1348
- }
1349
- \\\`\`\`
1350
- <!-- /sync:data -->
1351
- \`\`\`
1352
-
1353
- ---
1354
-
1355
- #### Brand Iconography Block
1356
-
1357
- Icon library selection with style settings and curated icon list.
1358
-
1359
- **Structure:**
1360
- \`\`\`json
1361
- {
1362
- "description": "Overview of iconography style",
1363
- "iconography": {
1364
- "library": "lucide|heroicons|phosphor|feather|custom",
1365
- "style": "outline|solid|duotone",
1366
- "strokeWidth": 2,
1367
- "defaultSize": 24,
1368
- "cornerStyle": "rounded|sharp",
1369
- "selectedIcons": ["icon-name-1", "icon-name-2"],
1370
- "usage": "How to use icons"
1371
- }
1372
- }
1373
- \`\`\`
1374
-
1375
- **Example:**
1376
- \`\`\`markdown
1377
- ---
1378
- type: brand_iconography
1379
- section: brand
1380
- key: icon-system
1381
- name: Icon System
1382
- status: complete
1383
- ---
1384
-
1385
- # Icon System
1386
-
1387
- We use Lucide icons with consistent styling across all interfaces.
1388
-
1389
- ## Icon Library
1390
-
1391
- **Library:** Lucide
1392
- **Style:** Outline
1393
- **Stroke Width:** 2px
1394
- **Default Size:** 24px
1395
-
1396
- ### Selected Brand Icons
1397
- - Home, Search, Settings
1398
- - User, Users, Bell
1399
- - File, Folder, Upload
1400
-
1401
- ### Usage Guidelines
1402
- Always use outline style. Maintain 2px stroke width. Use 24px for standard UI, 20px for compact areas.
1403
-
1404
- <!-- sync:data -->
1405
- \\\`\`\`json
1406
- {
1407
- "description": "We use Lucide icons with consistent styling across all interfaces.",
1408
- "iconography": {
1409
- "library": "lucide",
1410
- "style": "outline",
1411
- "strokeWidth": 2,
1412
- "defaultSize": 24,
1413
- "cornerStyle": "rounded",
1414
- "selectedIcons": ["home", "search", "settings", "user", "users", "bell", "file", "folder", "upload"],
1415
- "usage": "Always use outline style. Maintain 2px stroke width. Use 24px for standard UI, 20px for compact areas."
1416
- }
1417
- }
1418
- \\\`\`\`
1419
- <!-- /sync:data -->
1420
- \`\`\`
1421
-
1422
- ---
1423
-
1424
- #### Logo Block
1425
-
1426
- Logo assets with multiple background versions and usage guidelines.
1427
-
1428
- **Structure:**
1429
- \`\`\`json
1430
- {
1431
- "description": "Overview of this logo variant",
1432
- "logo": {
1433
- "logoType": "primary|secondary|wordmark|icon|monochrome",
1434
- "versions": [
1435
- {
1436
- "id": "version-id",
1437
- "url": "https://storage.example.com/logo.svg",
1438
- "backgroundColor": "#FFFFFF",
1439
- "backgroundName": "Light Background"
1440
- }
1441
- ],
1442
- "primaryColor": "#3B82F6",
1443
- "secondaryColor": "#1F2937",
1444
- "minimumSize": "32px",
1445
- "clearSpace": "1x logo height",
1446
- "usageGuidelines": "When and how to use this logo",
1447
- "donts": "What to avoid"
1448
- }
1449
- }
1450
- \`\`\`
1451
-
1452
- **Example:**
1453
- \`\`\`markdown
1454
- ---
1455
- type: logo
1456
- section: brand
1457
- key: primary-logo
1458
- name: Primary Logo
1459
- status: complete
1460
- ---
1461
-
1462
- # Primary Logo
1463
-
1464
- Our primary logo for use across all brand touchpoints.
1465
-
1466
- ## Description
1467
- The primary EpicContext logo combines the mark with the wordmark for maximum brand recognition.
1468
-
1469
- ## Logo Versions
1470
-
1471
- ### Light Background (#FFFFFF)
1472
- [Logo image on white background]
1473
-
1474
- ### Dark Background (#1A1A1A)
1475
- [Logo image on dark background]
1476
-
1477
- ## Logo Colors
1478
- - Primary: #3B82F6
1479
- - Secondary: #1F2937
1480
-
1481
- ## Sizing
1482
- - Minimum Size: 32px height
1483
- - Clear Space: 1x logo height around all sides
1484
-
1485
- ## Usage Guidelines
1486
- Use the full logo on marketing materials, website headers, and official documents. Use the icon only where space is limited.
1487
-
1488
- ## Don't
1489
- - Don't stretch or distort the logo
1490
- - Don't change the colors
1491
- - Don't place on busy backgrounds
1492
- - Don't add effects or shadows
1493
-
1494
- <!-- sync:data -->
1495
- \\\`\`\`json
1496
- {
1497
- "description": "The primary EpicContext logo combines the mark with the wordmark for maximum brand recognition.",
1498
- "logo": {
1499
- "logoType": "primary",
1500
- "versions": [
1501
- {
1502
- "id": "light",
1503
- "url": "",
1504
- "backgroundColor": "#FFFFFF",
1505
- "backgroundName": "Light Background"
1506
- },
1507
- {
1508
- "id": "dark",
1509
- "url": "",
1510
- "backgroundColor": "#1A1A1A",
1511
- "backgroundName": "Dark Background"
1512
- }
1513
- ],
1514
- "primaryColor": "#3B82F6",
1515
- "secondaryColor": "#1F2937",
1516
- "minimumSize": "32px",
1517
- "clearSpace": "1x logo height",
1518
- "usageGuidelines": "Use the full logo on marketing materials, website headers, and official documents. Use the icon only where space is limited.",
1519
- "donts": "Don't stretch or distort the logo. Don't change the colors. Don't place on busy backgrounds. Don't add effects or shadows."
1520
- }
1521
- }
1522
- \\\`\`\`
1523
- <!-- /sync:data -->
1524
- \`\`\`
1525
-
1526
- ---
1527
-
1528
- #### Brand Assets Block
1529
-
1530
- Visual assets library for photography, illustrations, patterns, and other brand graphics.
1531
-
1532
- **Structure:**
1533
- \`\`\`json
1534
- {
1535
- "name": "Collection Name",
1536
- "description": "Overview of this asset collection",
1537
- "assets": {
1538
- "assets": [
1539
- {
1540
- "id": "unique-id",
1541
- "category": "photography|illustration|pattern|texture|icon|graphic|template|background|other",
1542
- "url": "https://storage.example.com/asset.jpg",
1543
- "name": "Asset Name",
1544
- "backgroundColor": "#F5F5F5",
1545
- "description": "Asset description"
1546
- }
1547
- ],
1548
- "sizes": [
1549
- { "name": "Full", "size": 200 },
1550
- { "name": "Large", "size": 120 },
1551
- { "name": "Medium", "size": 64 },
1552
- { "name": "Small", "size": 32 }
1553
- ],
1554
- "dos": "Best practices for using these assets",
1555
- "donts": "What to avoid",
1556
- "guidelines": "General usage guidelines"
1557
- }
1558
- }
1559
- \`\`\`
1560
-
1561
- **Example:**
1562
- \`\`\`markdown
1563
- ---
1564
- type: brand_assets
1565
- section: brand
1566
- key: photography-library
1567
- name: Photography Library
1568
- status: draft
1569
- ---
1570
-
1571
- # Photography Library
1572
-
1573
- Our curated photography collection for marketing and product materials.
1574
-
1575
- ## Description
1576
- Professional photography that reflects our brand values of clarity, professionalism, and innovation.
1577
-
1578
- ## Assets
1579
-
1580
- ### photography: Hero Image 1
1581
- [Product screenshot showing the dashboard]
1582
- Clean workspace photography showing our app in use.
1583
-
1584
- ### photography: Team Collaboration
1585
- [Team working together]
1586
- Diverse team collaborating in a modern office setting.
1587
-
1588
- ## Do's
1589
- - Use high-resolution images (minimum 1200px wide)
1590
- - Maintain consistent lighting and color grading
1591
- - Show real product interfaces when possible
1592
- - Feature diverse representation
1593
-
1594
- ## Don'ts
1595
- - Don't use overly staged or stock-looking photos
1596
- - Don't apply heavy filters that alter brand colors
1597
- - Don't use outdated product screenshots
1598
- - Don't crop faces awkwardly
1599
-
1600
- ## Guidelines
1601
- All photography should feel authentic and professional. Prefer candid moments over posed shots. Ensure proper model releases for any identifiable people.
1602
-
1603
- <!-- sync:data -->
1604
- \\\`\`\`json
1605
- {
1606
- "name": "Photography Library",
1607
- "description": "Professional photography that reflects our brand values of clarity, professionalism, and innovation.",
1608
- "assets": {
1609
- "assets": [
1610
- {
1611
- "id": "hero-1",
1612
- "category": "photography",
1613
- "url": "",
1614
- "name": "Hero Image 1",
1615
- "backgroundColor": "#F5F5F5",
1616
- "description": "Clean workspace photography showing our app in use."
1617
- },
1618
- {
1619
- "id": "team-collab",
1620
- "category": "photography",
1621
- "url": "",
1622
- "name": "Team Collaboration",
1623
- "backgroundColor": "#F5F5F5",
1624
- "description": "Diverse team collaborating in a modern office setting."
1625
- }
1626
- ],
1627
- "sizes": [
1628
- { "name": "Full", "size": 200 },
1629
- { "name": "Large", "size": 120 },
1630
- { "name": "Medium", "size": 64 },
1631
- { "name": "Small", "size": 32 }
1632
- ],
1633
- "dos": "Use high-resolution images (minimum 1200px wide). Maintain consistent lighting and color grading. Show real product interfaces when possible. Feature diverse representation.",
1634
- "donts": "Don't use overly staged or stock-looking photos. Don't apply heavy filters that alter brand colors. Don't use outdated product screenshots. Don't crop faces awkwardly.",
1635
- "guidelines": "All photography should feel authentic and professional. Prefer candid moments over posed shots. Ensure proper model releases for any identifiable people."
1636
- }
1637
- }
1638
- \\\`\`\`
1639
- <!-- /sync:data -->
1640
- \`\`\`
1641
-
1642
- ---
1643
-
1644
- #### Tone of Voice Block
1645
-
1646
- Brand voice personality and communication guidelines.
1647
-
1648
- **Fields:**
1649
- - \`voice_personality\` - Brand personality traits
1650
- - \`voice_archetype\` - Voice archetype (sage, hero, creator, etc.)
1651
- - \`tone_attributes\` - Key tone attributes
1652
- - \`we_are\` - Positive characteristics
1653
- - \`we_are_not\` - What to avoid
1654
- - \`writing_principles\` - Core writing principles
1655
- - \`vocabulary_do\` - Words we use
1656
- - \`vocabulary_dont\` - Words we avoid
1657
- - \`example_good\` - Good copy example
1658
- - \`example_bad\` - Bad copy example
1659
- - \`grammar_style\` - Grammar and style rules
1660
-
1661
- **Example:**
1662
- \`\`\`markdown
1663
- ---
1664
- type: tone_of_voice
1665
- section: brand
1666
- key: brand-voice
1667
- name: Brand Voice
1668
- status: complete
1669
- ---
1670
-
1671
- # Brand Voice
1672
-
1673
- ## Brand Personality
1674
- Professional, helpful, clear, innovative, empowering
1675
-
1676
- **Archetype:** The Sage - Wise, knowledgeable, trusted advisor
1677
-
1678
- ## Tone Attributes
1679
- Confident but not arrogant. Helpful but not patronizing. Technical but accessible. Enthusiastic but measured.
1680
-
1681
- ## We Are...
1682
- - Clear and concise
1683
- - Helpful and supportive
1684
- - Confident and knowledgeable
1685
- - Professional yet approachable
1686
-
1687
- ## We Are NOT...
1688
- - Overly casual or slangy
1689
- - Condescending or preachy
1690
- - Robotic or cold
1691
- - Vague or ambiguous
1692
-
1693
- ## Writing Principles
1694
- 1. Lead with the benefit
1695
- 2. Use active voice
1696
- 3. Be specific, not generic
1697
- 4. Respect the reader's time
1698
-
1699
- ## Vocabulary
1700
-
1701
- **Words We Use:**
1702
- Context, clarity, empower, streamline, intelligent, seamless, structured
1703
-
1704
- **Words We Avoid:**
1705
- Revolutionary, best-in-class, synergy, leverage (as verb), utilize (use "use")
1706
-
1707
- ## Examples
1708
-
1709
- **Good Example:**
1710
- "Save hours every week by giving AI agents the context they need. No more explaining your product from scratch."
1711
-
1712
- **Bad Example:**
1713
- "Our revolutionary AI-powered solution leverages cutting-edge technology to synergize your workflow paradigms."
1714
-
1715
- ## Grammar & Style
1716
- - Use sentence case for headings
1717
- - Oxford comma always
1718
- - Numbers under 10 spelled out
1719
- - Contractions are fine (we're, you'll)
1720
- \`\`\`
1721
-
1722
- ---
1723
-
1724
- #### Messaging Framework Block
1725
-
1726
- External communication: elevator pitch, value props, and CTAs.
1727
-
1728
- **Fields:**
1729
- - \`core_message\` - The single most important message
1730
- - \`elevator_pitch\` - 30-second explanation
1731
- - \`value_prop_1/2/3\` - Key value propositions
1732
- - \`proof_points\` - Evidence and social proof
1733
- - \`audience_specific\` - Audience-tailored messaging
1734
- - \`call_to_action\` - Primary CTA
1735
- - \`secondary_ctas\` - Alternative CTAs
1736
- - \`boilerplate\` - Company description
1737
-
1738
- **Example:**
1739
- \`\`\`markdown
1740
- ---
1741
- type: messaging_framework
1742
- section: brand
1743
- key: core-messaging
1744
- name: Core Messaging Framework
1745
- status: complete
1746
- ---
1747
-
1748
- # Core Messaging Framework
1749
-
1750
- ## Core Message
1751
- AI coding agents build better software when they understand your product context.
1752
-
1753
- ## Elevator Pitch
1754
- EpicContext helps product teams give AI coding agents the context they need to build features that actually match your vision. Instead of explaining your product in every chat, create structured documentation that AI agents can reference automatically.
1755
-
1756
- ## Value Propositions
1757
-
1758
- ### 1. Save Time
1759
- Stop re-explaining your product in every AI conversation. Document once, reference forever.
1760
-
1761
- ### 2. Better AI Output
1762
- AI agents with context produce code that matches your patterns, follows your conventions, and understands your users.
1763
-
1764
- ### 3. Team Alignment
1765
- Keep everyone on the same page with a single source of truth for product context.
1766
-
1767
- ## Proof Points
1768
- - Teams save 5+ hours per week on context documentation
1769
- - 90% reduction in AI misunderstandings
1770
- - "Finally, AI that understands our product" - CTO, TechCorp
1771
-
1772
- ## Audience-Specific Messaging
1773
-
1774
- **For Developers:**
1775
- Write better prompts with less effort. EpicContext gives your AI assistant the background it needs.
1776
-
1777
- **For Product Managers:**
1778
- Ensure AI-built features match your vision. Document requirements once, reference them in every AI interaction.
1779
-
1780
- ## Calls to Action
1781
-
1782
- **Primary:** Start Free Trial
1783
-
1784
- **Secondary:** Watch Demo, Read Case Studies, Join Waitlist
1785
-
1786
- ## Boilerplate
1787
- EpicContext is the leading context management platform for product teams using AI coding agents. We help teams document and share product context in formats AI agents can understand, resulting in better code and faster development cycles.
1788
- \`\`\`
1789
-
1790
- ---
1791
-
1792
- #### Best Practices for Brand Blocks
1793
-
1794
- 1. **Use specialized block types**: Never use \`text\` for brand content. Each type has specific fields and visual editors.
1795
-
1796
- 2. **Include sync:data blocks**: For blocks with complex visual data (colors, typography, icons, logos, assets), always include the \`<!-- sync:data -->\` block with full JSON for reliable import/export.
1797
-
1798
- 3. **Be comprehensive**: Fill all relevant fields. Thin brand documentation leads to inconsistent AI-generated content.
1799
-
1800
- 4. **Keep it updated**: Brand guidelines change. Update status to \`draft\` when editing, \`complete\` when finalized.
1801
-
1802
- 5. **Cross-reference**: Messaging should align with positioning. Colors should be referenced in usage guidelines.
1803
-
1804
- ---
1805
-
1806
- ### Development Section Blocks (Epic → Story → Task)
1807
-
1808
- The development section uses a hierarchical structure to plan and track work. This creates a clear flow from high-level initiatives down to specific implementation tasks.
1809
-
1810
- #### Hierarchy Flow
1811
-
1812
- \`\`\`
1813
- Epic (Large initiative)
1814
- └── User Story (User-facing feature)
1815
- └── Task / Agent Plan (Technical implementation)
1816
- \`\`\`
1817
-
1818
- **How AI/Developers Should Use This:**
1819
- 1. **Product Owner/User** creates Epics for major initiatives
1820
- 2. **Product Owner/User** breaks Epics into User Stories
1821
- 3. **AI Agent/Developer** reads Stories and creates Tasks with implementation plans
1822
- 4. **AI Agent/Developer** executes Tasks and updates outcomes
1823
-
1824
- ---
1825
-
1826
- #### Epic Block
1827
-
1828
- An Epic represents a large body of work that delivers significant value. It groups related User Stories.
1829
-
1830
- **Required Fields:**
1831
- - \`summary\` - One-line description
1832
- - \`status\` - todo, in_progress, done
1833
-
1834
- **Key Fields:**
1835
- - \`description\` - Detailed explanation
1836
- - \`priority\` - highest, high, medium, low, lowest
1837
- - \`story_refs\` - Links to child User Stories
1838
- - \`impact_score\` / \`effort_score\` - 1-5 scale for prioritization
1839
- - \`start_date\` / \`due_date\` - Timeline
1840
- - \`labels\` - Comma-separated tags
1841
-
1842
- **Example:**
1843
- \`\`\`markdown
1844
- ---
1845
- type: epic
1846
- section: development
1847
- key: user-authentication
1848
- name: User Authentication System
1849
- status: draft
1850
- priority: high
1851
- start_date: 2025-01-15
1852
- due_date: 2025-02-28
1853
- labels: security, mvp, phase-1
1854
- story_refs:
1855
- - email-login
1856
- - oauth-integration
1857
- - password-reset
1858
- ---
1859
-
1860
- # User Authentication System
91
+ };
92
+ /**
93
+ * Generate the CORE AI guide (slim version without detailed schemas)
94
+ * This is ~250 lines instead of ~1900 lines
95
+ */
96
+ function generateCoreAIGuide() {
97
+ const today = new Date().toISOString().split("T")[0];
98
+ const allBlockTypes = Object.values(SECTION_INFO)
99
+ .flatMap(s => s.blockTypes)
100
+ .filter((v, i, a) => a.indexOf(v) === i) // unique
101
+ .sort();
102
+ return `# AI Agent Guide for CONTEXT Folder
1861
103
 
1862
- Implement a complete authentication system allowing users to securely access their accounts.
104
+ > **For Claude Code, Cursor, and other AI coding agents**
105
+ > This guide explains how to create and structure content in this CONTEXT folder.
1863
106
 
1864
- ## Summary
1865
- Build secure user authentication with email/password and OAuth support.
107
+ ## Guide Structure
1866
108
 
1867
- ## Description
1868
- This epic covers all authentication-related features including registration, login, logout, password management, and third-party OAuth integration. The goal is to provide a frictionless yet secure authentication experience.
109
+ This guide is **modular** to reduce context loading:
1869
110
 
1870
- ### Goals
1871
- - Enable secure user registration with email verification
1872
- - Support login via email/password and OAuth (Google, GitHub)
1873
- - Implement password reset flow with secure tokens
1874
- - Add session management with JWT
111
+ - **This file (AI-GUIDE.md)**: Core rules, block type list, navigation (~250 lines)
112
+ - **Section guides (.ai-guides/)**: Detailed schemas for each section (~200-400 lines each)
1875
113
 
1876
- ### Success Criteria
1877
- - Users can create accounts and verify email
1878
- - Login works with email/password and OAuth providers
1879
- - Password reset emails arrive within 30 seconds
1880
- - Sessions expire after 24 hours of inactivity
114
+ **Load only what you need:**
115
+ 1. Always read this core guide first
116
+ 2. Then read the section guide for the section you're working on
1881
117
 
1882
- ### Out of Scope
1883
- - Two-factor authentication (planned for Phase 2)
1884
- - Social login beyond Google/GitHub
118
+ \`\`\`
119
+ CONTEXT/
120
+ ├── AI-GUIDE.md ← You are here (core rules)
121
+ ├── .ai-guides/
122
+ │ ├── brand-guide.md ← Brand section schemas
123
+ │ ├── development-guide.md ← Development section schemas
124
+ │ ├── product-guide.md ← Product section schemas
125
+ │ ├── users-guide.md ← Users section schemas
126
+ │ └── ... ← Other section guides
1885
127
  \`\`\`
1886
128
 
1887
129
  ---
1888
130
 
1889
- #### User Story Block
1890
-
1891
- A User Story describes a feature from the user's perspective. It belongs to an Epic and can have Tasks.
1892
-
1893
- **Required Fields:**
1894
- - \`summary\` - Brief description
1895
- - \`status\` - todo, in_progress, in_review, done
1896
-
1897
- **Key Fields:**
1898
- - \`user_story\` - "As a [role], I want [goal], so that [benefit]" format
1899
- - \`acceptance_criteria\` - Testable conditions (Given/When/Then)
1900
- - \`epic_ref\` - Link to parent Epic
1901
- - \`story_points\` - 1, 2, 3, 5, 8, 13, 21 (Fibonacci)
1902
- - \`priority\` - highest, high, medium, low, lowest
1903
- - \`impact_score\` / \`effort_score\` - 1-5 scale
1904
- - \`sprint\` - Sprint assignment
1905
-
1906
- **Example:**
1907
- \`\`\`markdown
1908
- ---
1909
- type: user_story
1910
- section: development
1911
- key: email-login
1912
- name: Email Login
1913
- status: draft
1914
- priority: high
1915
- story_points: 5
1916
- impact_score: 5
1917
- effort_score: 3
1918
- epic_ref: user-authentication
1919
- sprint: Sprint 1
1920
- ---
131
+ ## CRITICAL RULES - READ FIRST
1921
132
 
1922
- # Email Login
133
+ ### BLOCK TYPE ENFORCEMENT
1923
134
 
1924
- Allow users to securely log in with their email and password.
135
+ **ONLY use block types from the Valid Block Types list below.** Using undefined types will:
136
+ - Show "No schema defined" in the UI
137
+ - Lose all content when synced
138
+ - Break import/export
1925
139
 
1926
- ## Summary
1927
- Implement email/password authentication with proper security measures.
140
+ ### DO:
141
+ - **ONLY use block types listed in this guide**
142
+ - Create **ONE FILE PER BLOCK** (one user story = one file)
143
+ - Use the **exact folder structure** shown below
144
+ - Include **YAML frontmatter** with type, section, key, name, status
145
+ - Use **kebab-case** for keys and filenames
146
+ - **Read the section guide** for detailed schemas before creating blocks
1928
147
 
1929
- ## User Story
1930
- As a registered user, I want to log in with my email and password, so that I can access my account securely and quickly.
148
+ ### DO NOT:
149
+ - **Invent new block types** - if it's not in this guide, it doesn't exist
150
+ - ❌ Create a single large file with multiple items
151
+ - ❌ Put files in wrong folders
152
+ - ❌ Use generic markdown without frontmatter
153
+ - ❌ Skip reading the section guide for detailed schemas
1931
154
 
1932
- ## Description
1933
- Users need a fast and secure way to access their accounts. The login form should validate input, show helpful error messages, and redirect to the dashboard on success.
155
+ ### LANGUAGE CONSISTENCY
1934
156
 
1935
- ## Acceptance Criteria
157
+ **CRITICAL:** All content must be in ONE consistent language.
158
+ Check existing CONTEXT files to determine the project's language.
1936
159
 
1937
- ### Scenario: Successful login
1938
- - Given I am on the login page
1939
- - When I enter a valid email and correct password
1940
- - Then I am redirected to the dashboard
1941
- - And I see a welcome message with my name
160
+ ---
1942
161
 
1943
- ### Scenario: Invalid credentials
1944
- - Given I am on the login page
1945
- - When I enter an invalid email or wrong password
1946
- - Then I see an error message "Invalid email or password"
1947
- - And I remain on the login page
1948
- - And the password field is cleared
162
+ ## Valid Block Types (Quick Reference)
1949
163
 
1950
- ### Scenario: Rate limiting
1951
- - Given I have failed login 5 times in 5 minutes
1952
- - When I try to login again
1953
- - Then I see "Too many attempts. Please try again in 15 minutes"
164
+ These are the ONLY valid values for \`type:\` in frontmatter:
1954
165
 
1955
- ## Technical Notes
1956
- - Use bcrypt for password hashing (cost factor 12)
1957
- - Implement rate limiting: 5 attempts per 5 minutes per IP
1958
- - Generate JWT with 24h expiry
1959
- - Store refresh token in httpOnly cookie
166
+ \`\`\`
167
+ ${allBlockTypes.join(", ")}
1960
168
  \`\`\`
1961
169
 
170
+ **For detailed schemas, see the section guide in \`.ai-guides/\`**
171
+
1962
172
  ---
1963
173
 
1964
- #### Task / Agent Plan Block
174
+ ## Block Type Section → Folder Reference
1965
175
 
1966
- A Task contains the technical implementation plan. AI coding agents (Claude Code, Cursor, etc.) should create Tasks when planning work.
176
+ | Block Type | Section | Folder | Guide |
177
+ |------------|---------|--------|-------|
178
+ ${Object.entries(SECTION_INFO).flatMap(([key, info]) => info.blockTypes.map(bt => `| \`${bt}\` | ${info.name} | \`${info.folder}/\` | \`.ai-guides/${info.folder}-guide.md\` |`)).join("\n")}
1967
179
 
1968
- **Required Fields:**
1969
- - \`description\` - What needs to be done
1970
- - \`status\` - planned, todo, in_progress, in_review, done, abandoned
180
+ ---
1971
181
 
1972
- **Key Fields:**
1973
- - \`story_ref\` - Link to parent User Story
1974
- - \`plan_steps\` - Step-by-step implementation plan
1975
- - \`agent_source\` - manual, claude_code, cursor, copilot, windsurf, aider, other_ai
1976
- - \`files_affected\` - List of files to create/modify
1977
- - \`codebase_context\` - Relevant architecture notes
1978
- - \`technical_notes\` - Implementation details
1979
- - \`dependencies\` - Prerequisites or packages needed
1980
- - \`estimated_hours\` - Time estimate
1981
- - \`outcome\` - Results after completion
182
+ ## Universal File Template
1982
183
 
1983
- **Example (AI Agent Plan):**
1984
184
  \`\`\`markdown
1985
185
  ---
1986
- type: task
1987
- section: development
1988
- key: implement-login-api
1989
- name: Implement Login API Endpoint
186
+ type: [block_type]
187
+ section: [section_type]
188
+ key: [unique-kebab-case-key]
189
+ name: "Human Readable Name"
1990
190
  status: draft
1991
- priority: high
1992
- agent_source: claude_code
1993
- story_ref: email-login
1994
- estimated_hours: 4
191
+ created: ${today}
192
+ updated: ${today}
1995
193
  ---
1996
194
 
1997
- # Implement Login API Endpoint
1998
-
1999
- Create the POST /api/auth/login endpoint that validates credentials and returns JWT tokens.
2000
-
2001
- ## Description
2002
- Implement the login API endpoint with proper validation, rate limiting, and token generation.
2003
-
2004
- ## Implementation Plan
2005
-
2006
- ### Step 1: Create Login Route Handler
2007
- Create \`app/api/auth/login/route.ts\` with POST handler:
2008
- - Accept email and password in request body
2009
- - Validate input format using zod schema
2010
- - Return 400 for invalid input with specific error messages
2011
-
2012
- ### Step 2: Implement User Lookup
2013
- Query the users table by email:
2014
- - Use Supabase client with service role for server-side
2015
- - Return generic "Invalid credentials" to prevent email enumeration
2016
- - Handle case-insensitive email matching
2017
-
2018
- ### Step 3: Password Verification
2019
- Compare provided password with stored hash:
2020
- - Use bcrypt.compare() for timing-safe comparison
2021
- - Log failed attempts for security monitoring
2022
- - Increment rate limit counter on failure
2023
-
2024
- ### Step 4: Generate JWT Tokens
2025
- On successful authentication:
2026
- - Generate access token (24h expiry) with user ID and email
2027
- - Generate refresh token (7d expiry) stored in httpOnly cookie
2028
- - Include minimal claims to reduce token size
2029
-
2030
- ### Step 5: Implement Rate Limiting
2031
- Add rate limiting middleware:
2032
- - Use Redis or in-memory store for attempt tracking
2033
- - Key by IP address + email combination
2034
- - Block after 5 failed attempts for 15 minutes
2035
- - Return 429 with Retry-After header
2036
-
2037
- ### Step 6: Add Tests
2038
- Create \`app/api/auth/login/route.test.ts\`:
2039
- - Test successful login returns tokens
2040
- - Test invalid email format returns 400
2041
- - Test wrong password returns 401
2042
- - Test rate limiting blocks after 5 attempts
2043
-
2044
- ## Files Affected
2045
- - \`app/api/auth/login/route.ts\` (create)
2046
- - \`lib/auth/jwt.ts\` (create)
2047
- - \`lib/auth/password.ts\` (create)
2048
- - \`lib/middleware/rate-limit.ts\` (create)
2049
- - \`app/api/auth/login/route.test.ts\` (create)
2050
-
2051
- ## Codebase Context
2052
- - Using Next.js 14 App Router
2053
- - Supabase for database and auth
2054
- - JWT library: jose
2055
- - Password hashing: bcrypt
2056
- - Validation: zod
2057
-
2058
- ## Dependencies
2059
- - jose (JWT handling)
2060
- - bcrypt (password hashing)
2061
- - zod (validation)
2062
-
2063
- ## Technical Notes
2064
- - Follow existing API patterns in \`app/api/\` folder
2065
- - Use \`@/lib/supabase/server\` for database access
2066
- - Error responses should match the ErrorResponse type in \`types/api.ts\`
2067
- \`\`\`
2068
-
2069
- ---
195
+ # Title
2070
196
 
2071
- #### Roadmap Block
2072
-
2073
- A Roadmap provides a timeline view of Epics across time periods (quarters, months, sprints).
2074
-
2075
- **Key Fields:**
2076
- - \`description\` - Purpose of this roadmap
2077
- - \`timeline\` - Visual timeline data with columns and epic placements
2078
- - \`notes\` - Additional context, risks, assumptions
2079
-
2080
- **Timeline Structure:**
2081
- \`\`\`json
2082
- {
2083
- "columns": [
2084
- { "id": "q1-2025", "name": "Q1 2025", "period": "quarter" },
2085
- { "id": "q2-2025", "name": "Q2 2025", "period": "quarter" }
2086
- ],
2087
- "items": [
2088
- {
2089
- "epicRef": "user-authentication",
2090
- "startColumn": "q1-2025",
2091
- "spanColumns": 1,
2092
- "row": 0
2093
- }
2094
- ],
2095
- "settings": { "defaultPeriod": "quarter" }
2096
- }
197
+ [Content following the block type schema from section guide]
2097
198
  \`\`\`
2098
199
 
2099
200
  ---
2100
201
 
2101
- #### Workflow: From User Request to Implementation
202
+ ## Which Block Type Should I Use?
2102
203
 
2103
- **1. User/Product Owner Creates Epic:**
2104
- \`\`\`
2105
- "We need user authentication for the MVP"
2106
- Create Epic: user-authentication
2107
- Set priority: high
2108
- Set dates: Q1 2025
2109
- \`\`\`
204
+ | What You're Documenting | Block Type | Folder |
205
+ |------------------------|------------|--------|
206
+ | User persona | \`persona\` | \`users/personas/\` |
207
+ | Job to be done | \`jtbd\` | \`users/jobs-to-be-done/\` |
208
+ | User journey | \`journey_map\` | \`users/journey-maps/\` |
209
+ | Product vision | \`product_overview\` | \`product/\` |
210
+ | Feature | \`feature\` | \`product/features/\` |
211
+ | Large initiative (weeks) | \`epic\` | \`development/epics/\` |
212
+ | User story (days) | \`user_story\` | \`development/stories/\` |
213
+ | Technical task (hours) | \`task\` | \`development/tasks/\` |
214
+ | Brand positioning | \`brand_positioning\` | \`brand/\` |
215
+ | Visual identity | \`brand_visual_identity\` | \`brand/\` |
216
+ | Tone of voice | \`tone_of_voice\` | \`brand/\` |
217
+ | Architecture decision | \`decision\` | \`decisions/\` |
218
+ | Technical constraint | \`constraint\` | \`technical/\` |
219
+ | External service | \`integration\` | \`technical/integrations/\` |
220
+ | Competitor analysis | \`competitor\` | \`research/competitors/\` |
221
+ | Site structure | \`ia_tree\` | \`information-architecture/\` |
222
+ | Metric/KPI | \`metric\` | \`metrics/\` |
2110
223
 
2111
- **2. User/Product Owner Breaks Down Stories:**
2112
- \`\`\`
2113
- Epic: user-authentication
2114
- → Story: email-login (5 points)
2115
- → Story: oauth-integration (8 points)
2116
- → Story: password-reset (3 points)
2117
- \`\`\`
224
+ ---
2118
225
 
2119
- **3. AI Agent Reads Story and Plans:**
2120
- \`\`\`
2121
- AI reads: email-login story
2122
- → Creates Task: implement-login-api (4 hours)
2123
- → Creates Task: build-login-form (3 hours)
2124
- → Creates Task: add-login-tests (2 hours)
2125
- \`\`\`
226
+ ## Context Navigation
2126
227
 
2127
- **4. AI Agent Executes and Documents:**
2128
- \`\`\`
2129
- Task: implement-login-api
2130
- Status: in_progress
2131
- [AI implements code]
2132
- → Status: done
2133
- Outcome: "Completed. Added rate limiting as discussed."
2134
- \`\`\`
228
+ **Read enough to answer these questions, then stop:**
229
+ 1. What should I build? (from task/story)
230
+ 2. Who am I building it for? (from persona)
231
+ 3. What constraints apply? (from constitution/technical)
232
+ 4. How should it look/behave? (from brand/design system)
233
+
234
+ **Link Priority:**
235
+ - **ALWAYS READ:** \`constitution/\`, parent refs (\`story_ref\`, \`epic_ref\`)
236
+ - **IF RELEVANT:** \`personas_ref\`, \`decisions_ref\`, \`integrations_ref\`
237
+ - **SKIP UNLESS NEEDED:** Sibling blocks, metrics, competitors
2135
238
 
2136
239
  ---
2137
240
 
2138
- #### Best Practices for AI Agents
241
+ ## Linking Blocks
2139
242
 
2140
- 1. **Read the Story First**: Before creating tasks, fully understand the user story and acceptance criteria.
243
+ Key relationships (use exact \`key\` values from target blocks):
2141
244
 
2142
- 2. **Break Down Thoughtfully**: Create tasks that are:
2143
- - Independently testable
2144
- - 2-8 hours of work each
2145
- - Clearly scoped with specific files
245
+ | From | Field | To | Required? |
246
+ |------|-------|---|-----------|
247
+ | \`user_story\` | \`epic_ref\` | \`epic\` | **Yes** |
248
+ | \`task\` | \`story_ref\` | \`user_story\` | **Yes** |
249
+ | \`journey_map\` | \`persona_ref\` | \`persona\` | **Yes** |
250
+ | \`jtbd\` | \`persona_ref\` | \`persona\` | No |
251
+ | \`feature\` | \`personas_ref\` | \`persona\` | No |
252
+ | \`epic\` | \`product_ref\` | \`product_overview\` | No |
2146
253
 
2147
- 3. **Document Your Plan**: In \`plan_steps\`, explain:
2148
- - What you'll do in each step
2149
- - Why you're making certain choices
2150
- - What files you'll touch
254
+ ---
2151
255
 
2152
- 4. **Track Codebase Context**: Note relevant:
2153
- - Existing patterns to follow
2154
- - Related code to reference
2155
- - Constraints or dependencies
256
+ ## Syncing with EpicContext
2156
257
 
2157
- 5. **Update Outcomes**: After completing a task, document:
2158
- - What was actually done
2159
- - Any deviations from the plan
2160
- - Issues encountered and how they were resolved
258
+ \`\`\`bash
259
+ npx @epiccontext/mcp push # Push local changes to cloud
260
+ npx @epiccontext/mcp pull # Pull cloud changes to local
261
+ npx @epiccontext/mcp status # Check sync status
262
+ \`\`\`
2161
263
 
2162
264
  ---
2163
265
 
2164
- ### Design System Blocks
266
+ ## Section Guides Reference
2165
267
 
2166
- #### Storybook Link Block
268
+ For detailed block schemas, examples, and guidelines, read the appropriate section guide:
2167
269
 
2168
- A Storybook Link connects your EpicContext project to a deployed Storybook design system with authentication.
270
+ | Section | Guide File | Block Types |
271
+ |---------|-----------|-------------|
272
+ ${Object.entries(SECTION_INFO).map(([key, info]) => `| ${info.name} | \`.ai-guides/${info.folder}-guide.md\` | ${info.blockTypes.length} types |`).join("\n")}
2169
273
 
2170
- **Key Fields:**
2171
- - \`name\` - Display name for the Storybook
2172
- - \`url\` - Deployed Storybook URL (Vercel, Netlify, etc.)
2173
- - \`description\` - What's documented in this Storybook
2174
- - \`requires_auth\` - Enable EpicContext authentication
2175
- - \`auth_secret\` - Shared secret for token validation
2176
- - \`tokens_path\` - URL path to design tokens docs
2177
- - \`components_path\` - URL path to component docs
2178
- - \`repo_url\` - Git repository URL (optional)
2179
-
2180
- **Example:**
2181
- \`\`\`markdown
2182
274
  ---
2183
- type: storybook_link
2184
- section: design-system
2185
- key: main-storybook
2186
- name: Design System Storybook
2187
- status: complete
2188
- ---
2189
-
2190
- # Design System Storybook
2191
275
 
2192
- Component library, design tokens, and usage guidelines.
276
+ *Core AI guide - auto-generated by EpicContext CLI*
277
+ *Generated: ${new Date().toISOString()}*
2193
278
 
2194
- **URL:** https://design-system.yourcompany.vercel.app
2195
- **Repository:** https://github.com/yourcompany/design-system
2196
- **Authentication:** Enabled (EpicContext SSO)
2197
-
2198
- ## Quick Links
2199
- - [Design Tokens](https://design-system.yourcompany.vercel.app?path=/docs/tokens-colors--docs)
2200
- - [Components](https://design-system.yourcompany.vercel.app?path=/docs/components-button--docs)
279
+ **Next step:** Read the section guide for the section you're working on.
280
+ `;
281
+ }
282
+ /**
283
+ * Generate a section-specific guide
284
+ */
285
+ function generateSectionGuide(sectionKey) {
286
+ const info = SECTION_INFO[sectionKey];
287
+ if (!info)
288
+ return null;
289
+ const today = new Date().toISOString().split("T")[0];
290
+ return `# ${info.name} Section Guide
2201
291
 
2202
- ## Categories
2203
- Tokens, Components, Patterns
2204
- \`\`\`
292
+ > ${info.description}
293
+ > Folder: \`CONTEXT/${info.folder}/\`
2205
294
 
2206
- **Setting Up Protected Storybook:**
295
+ This guide contains detailed schemas and examples for this section.
296
+ For core rules and navigation, see \`CONTEXT/AI-GUIDE.md\`.
2207
297
 
2208
- 1. Clone the EpicContext Storybook template:
2209
- \`\`\`bash
2210
- npx degit epiccontext/storybook-template my-design-system
2211
- cd my-design-system && npm install
2212
- \`\`\`
2213
- 2. Deploy to Vercel: \`npx vercel\`
2214
- 3. In EpicContext, create a Storybook Link block and click "Generate Secret"
2215
- 4. Add \`EPICCONTEXT_STORYBOOK_SECRET\` to Vercel environment variables
2216
- 5. Add your Storybook URL to the block
2217
- 6. Team members can access via "Open Storybook" in EpicContext UI
298
+ ---
2218
299
 
2219
- The template includes middleware that validates JWT tokens signed by EpicContext, providing SSO-style access to your design system.
300
+ ## Block Types in This Section
2220
301
 
2221
- **Template Repository:** https://github.com/epiccontext/storybook-template
302
+ | Block Type | Description | File Location |
303
+ |------------|-------------|---------------|
304
+ ${info.blockTypes.map(bt => `| \`${bt}\` | See schema below | \`${info.folder}/\` |`).join("\n")}
2222
305
 
2223
306
  ---
2224
307
 
2225
- ## Block References
308
+ ## Detailed Block Schemas
2226
309
 
2227
- Some blocks can reference other blocks using reference fields in frontmatter:
310
+ ${info.blockTypes.map(bt => `### ${bt}
2228
311
 
2229
- ### Single Reference (one-to-one)
312
+ **Type:** \`${bt}\`
313
+ **Section:** ${sectionKey}
314
+ **File Location:** \`${info.folder}/[name].md\`
315
+
316
+ **Required Frontmatter:**
2230
317
  \`\`\`yaml
2231
318
  ---
2232
- type: journey_map
2233
- section: users
2234
- key: user-onboarding
2235
- persona_ref: primary-user # References a persona block
319
+ type: ${bt}
320
+ section: ${sectionKey}
321
+ key: example-${bt.replace(/_/g, "-")}
322
+ name: "Example ${bt.split("_").map(w => w.charAt(0).toUpperCase() + w.slice(1)).join(" ")}"
323
+ status: draft
324
+ created: ${today}
325
+ updated: ${today}
2236
326
  ---
2237
327
  \`\`\`
2238
328
 
2239
- ### Multiple References (one-to-many)
2240
- \`\`\`yaml
2241
- ---
2242
- type: epic
2243
- section: development
2244
- key: authentication-epic
2245
- stories_ref: # References multiple user_story blocks
2246
- - login-story
2247
- - signup-story
2248
- - password-reset-story
329
+ **Content:** Follow the standard block structure with appropriate headings for this block type.
330
+
2249
331
  ---
2250
- \`\`\`
332
+ `).join("\n")}
2251
333
 
2252
- ### Common Reference Fields
2253
- | Field | Used In | References |
2254
- |-------|---------|------------|
2255
- | \`persona_ref\` | journey_map, jtbd | persona block |
2256
- | \`epic_ref\` | user_story | epic block |
2257
- | \`story_ref\` | task | user_story block |
2258
- | \`stories_ref\` | epic | user_story blocks |
2259
- | \`product_ref\` | feature, epic | product overview block |
334
+ *Section guide for ${info.name} - auto-generated by EpicContext CLI*
335
+ *Generated: ${new Date().toISOString()}*
336
+ `;
337
+ }
338
+ /**
339
+ * Generate all section guides in the .ai-guides folder
340
+ */
341
+ function generateSectionGuides(aiGuidesDir) {
342
+ for (const [sectionKey, info] of Object.entries(SECTION_INFO)) {
343
+ const guideContent = generateSectionGuide(sectionKey);
344
+ if (guideContent) {
345
+ const guidePath = path.join(aiGuidesDir, `${info.folder}-guide.md`);
346
+ if (!fs.existsSync(guidePath)) {
347
+ fs.writeFileSync(guidePath, guideContent, "utf-8");
348
+ }
349
+ }
350
+ }
351
+ }
352
+ /**
353
+ * Read all markdown files from a directory recursively
354
+ */
355
+ export function readContextFolder(contextPath) {
356
+ const files = [];
357
+ if (!fs.existsSync(contextPath)) {
358
+ return files;
359
+ }
360
+ function walkDir(dir, relativeTo) {
361
+ const entries = fs.readdirSync(dir, { withFileTypes: true });
362
+ for (const entry of entries) {
363
+ const fullPath = path.join(dir, entry.name);
364
+ const relativePath = path.relative(relativeTo, fullPath);
365
+ if (entry.isDirectory()) {
366
+ // Skip hidden directories and node_modules
367
+ if (!entry.name.startsWith(".") && entry.name !== "node_modules") {
368
+ walkDir(fullPath, relativeTo);
369
+ }
370
+ }
371
+ else if (entry.isFile() && entry.name.endsWith(".md")) {
372
+ // Skip README and AI-GUIDE
373
+ const lowerName = entry.name.toLowerCase();
374
+ if (lowerName !== "readme.md" && lowerName !== "ai-guide.md") {
375
+ const content = fs.readFileSync(fullPath, "utf-8");
376
+ files.push({
377
+ path: relativePath,
378
+ content,
379
+ });
380
+ }
381
+ }
382
+ }
383
+ }
384
+ walkDir(contextPath, contextPath);
385
+ return files;
386
+ }
387
+ /**
388
+ * Write files to the context folder
389
+ * By default, skips files where local version is newer than cloud version
390
+ */
391
+ export function writeContextFolder(contextPath, files, options = {}) {
392
+ let written = 0;
393
+ let skipped = 0;
394
+ const skippedPaths = [];
395
+ for (const file of files) {
396
+ const fullPath = path.join(contextPath, file.path);
397
+ const dir = path.dirname(fullPath);
398
+ // Create directory if needed
399
+ if (!fs.existsSync(dir)) {
400
+ fs.mkdirSync(dir, { recursive: true });
401
+ }
402
+ // Always overwrite AI-GUIDE.md (it's server-generated and should be authoritative)
403
+ // This ensures users get the latest block type definitions on every pull
404
+ const isAIGuide = file.path.toLowerCase() === "ai-guide.md";
405
+ // Check if local file is newer than cloud version (unless force is set or it's AI-GUIDE.md)
406
+ if (!options.force && !isAIGuide && file.updatedAt && fs.existsSync(fullPath)) {
407
+ const localMtime = getFileModTime(fullPath);
408
+ const cloudMtime = new Date(file.updatedAt);
409
+ if (localMtime && localMtime > cloudMtime) {
410
+ // Local file is newer, skip overwriting
411
+ skipped++;
412
+ skippedPaths.push(file.path);
413
+ continue;
414
+ }
415
+ }
416
+ // Write file
417
+ try {
418
+ fs.writeFileSync(fullPath, file.content, "utf-8");
419
+ written++;
420
+ }
421
+ catch (error) {
422
+ console.error(`Failed to write ${file.path}:`, error);
423
+ skipped++;
424
+ }
425
+ }
426
+ return { written, skipped, skippedPaths };
427
+ }
428
+ /**
429
+ * Delete local files that don't exist in the cloud
430
+ * Used during pull to remove files that were deleted in the UI
431
+ */
432
+ export function deleteOrphanedLocalFiles(contextPath, cloudFiles) {
433
+ // Build a set of all cloud file paths (normalized)
434
+ const cloudPaths = new Set();
435
+ for (const file of cloudFiles) {
436
+ cloudPaths.add(file.path);
437
+ }
438
+ // Get all local markdown files
439
+ const localFiles = readContextFolder(contextPath);
440
+ const deleted = [];
441
+ for (const localFile of localFiles) {
442
+ // If local file doesn't exist in cloud, delete it
443
+ if (!cloudPaths.has(localFile.path)) {
444
+ const fullPath = path.join(contextPath, localFile.path);
445
+ try {
446
+ fs.unlinkSync(fullPath);
447
+ deleted.push(localFile.path);
448
+ }
449
+ catch (error) {
450
+ console.error(`Failed to delete ${localFile.path}:`, error);
451
+ }
452
+ }
453
+ }
454
+ return { deleted: deleted.length, deletedPaths: deleted };
455
+ }
456
+ /**
457
+ * Ensure the context folder exists with basic structure
458
+ */
459
+ export function ensureContextFolder(contextPath) {
460
+ if (!fs.existsSync(contextPath)) {
461
+ fs.mkdirSync(contextPath, { recursive: true });
462
+ }
463
+ // Create default section folders
464
+ // Note: folder names use hyphens, but section types in the app use underscores
465
+ const defaultSections = [
466
+ "constitution",
467
+ "brand",
468
+ "product",
469
+ "business-strategy",
470
+ "users",
471
+ "research",
472
+ "technical",
473
+ "design-system",
474
+ "information-architecture",
475
+ "metrics",
476
+ "decisions",
477
+ "development",
478
+ "marketing",
479
+ "reports",
480
+ ];
481
+ for (const section of defaultSections) {
482
+ const sectionPath = path.join(contextPath, section);
483
+ if (!fs.existsSync(sectionPath)) {
484
+ fs.mkdirSync(sectionPath, { recursive: true });
485
+ }
486
+ }
487
+ // Create README.md
488
+ const readmePath = path.join(contextPath, "README.md");
489
+ if (!fs.existsSync(readmePath)) {
490
+ const readme = `# CONTEXT
2260
491
 
2261
- ## Important Rules
492
+ This folder contains product context documentation synced with EpicContext.
2262
493
 
2263
- 1. **Always include all 5 frontmatter fields** (type, section, key, name, status)
2264
- 2. **The \`section\` field must match the folder name** (e.g., files in \`brand/\` must have \`section: brand\`)
2265
- 3. **The \`key\` must be unique within the section** (use kebab-case, no spaces)
2266
- 4. **Always use specific block types** - each section has its own block types, never use generic \`text\`
2267
- 5. **Set \`status: draft\` for new content** and \`status: complete\` when finalized
494
+ ## IMPORTANT: File Format
2268
495
 
2269
- ## Common Mistakes to Avoid
496
+ **All markdown files MUST have YAML frontmatter with these required fields:**
2270
497
 
2271
- WRONG: Using \`title\` and \`description\` instead of proper frontmatter
2272
498
  \`\`\`yaml
2273
499
  ---
2274
- title: My Document # WRONG - not recognized
2275
- description: About this # WRONG - not recognized
500
+ type: persona # Block type (persona, feature, decision, etc.)
501
+ section: brand # Section name (must match folder name)
502
+ key: unique-key # Unique identifier (use kebab-case)
503
+ name: Display Name # Human-readable name
504
+ status: draft # Status: draft, complete, or empty
2276
505
  ---
2277
506
  \`\`\`
2278
507
 
2279
- CORRECT: Using the required frontmatter fields
2280
- \`\`\`yaml
2281
- ---
2282
- type: tone_of_voice
2283
- section: brand
2284
- key: brand-voice
2285
- name: Brand Voice
2286
- status: draft
2287
- ---
2288
- \`\`\`
508
+ See \`AI-GUIDE.md\` for detailed format instructions.
2289
509
 
2290
- WRONG: Missing required fields
2291
- \`\`\`yaml
2292
- ---
2293
- type: persona
2294
- name: My Persona
2295
- # Missing: section, key, status
2296
- ---
510
+ ## Structure
511
+
512
+ Each folder represents a section of your product documentation:
513
+
514
+ - \`constitution/\` - Non-negotiable rules and principles
515
+ - \`brand/\` - Identity, voice, and visual system
516
+ - \`product/\` - Vision, features, and roadmap
517
+ - \`business-strategy/\` - Strategic planning and business models
518
+ - \`users/\` - Personas, jobs to be done, and user journeys
519
+ - \`research/\` - Market and competitor analysis
520
+ - \`technical/\` - Stack, architecture, and constraints
521
+ - \`design-system/\` - Links to Storybook and Figma
522
+ - \`information-architecture/\` - Site structure and taxonomies
523
+ - \`metrics/\` - KPIs and analytics
524
+ - \`decisions/\` - Architecture decision records
525
+ - \`development/\` - Epics, stories, tasks, and roadmaps
526
+ - \`marketing/\` - Marketing campaigns and SEO content strategy
527
+
528
+ ## Syncing
529
+
530
+ This folder is synced with your EpicContext project using the MCP server.
531
+
532
+ To sync changes:
533
+ \`\`\`bash
534
+ epicontext sync
2297
535
  \`\`\`
2298
536
 
2299
- CORRECT: All required fields present
2300
- \`\`\`yaml
2301
- ---
2302
- type: persona
2303
- section: users
2304
- key: primary-user
2305
- name: Primary User
2306
- status: draft
2307
- ---
537
+ To watch for changes and auto-sync:
538
+ \`\`\`bash
539
+ epicontext watch
2308
540
  \`\`\`
2309
541
  `;
542
+ fs.writeFileSync(readmePath, readme, "utf-8");
543
+ }
544
+ // Create .ai-guides folder for modular section guides
545
+ const aiGuidesDir = path.join(contextPath, ".ai-guides");
546
+ if (!fs.existsSync(aiGuidesDir)) {
547
+ fs.mkdirSync(aiGuidesDir, { recursive: true });
548
+ }
549
+ // Generate section-specific guides
550
+ generateSectionGuides(aiGuidesDir);
551
+ // Create AI-GUIDE.md (slim core version) with detailed format instructions
552
+ const aiGuidePath = path.join(contextPath, "AI-GUIDE.md");
553
+ if (!fs.existsSync(aiGuidePath)) {
554
+ const aiGuide = generateCoreAIGuide();
2310
555
  fs.writeFileSync(aiGuidePath, aiGuide, "utf-8");
2311
556
  }
2312
557
  // Create README.md for each section with detailed guidance
@@ -2321,19 +566,17 @@ status: draft
2321
566
  - **Glossary**: Domain-specific terminology and definitions
2322
567
 
2323
568
  This is the first section AI agents should read to understand project boundaries.`,
2324
- blockTypes: ["ai_rules", "context_guide", "constraint", "implementation_log", "glossary"],
569
+ blockTypes: ["ai_rules", "context_guide", "constraint", "implementation_log", "glossary", "section_guide"],
2325
570
  },
2326
571
  "brand": {
2327
572
  description: "Identity, voice, and visual system",
2328
573
  guidance: `Use this section to document:
2329
574
  - **Brand Positioning**: Golden Circle (WHY/HOW/WHAT) and positioning statement
2330
- - **Color Palette**: Primary, secondary, and semantic colors with hex/RGB values
2331
- - **Typography**: Font families, weights, and usage guidelines
2332
- - **Iconography**: Icon library, style, and selected icons
575
+ - **Visual Identity**: Colors, typography, logo, icons, assets combined (use brand_visual_identity)
576
+ - **Brand Moodboard**: Inspiration and reference images for brand development
2333
577
  - **Tone of Voice**: Brand personality, voice archetype, vocabulary
2334
- - **Messaging**: Elevator pitch, value propositions, CTAs
2335
- - **Logos**: Logo variants for different backgrounds`,
2336
- blockTypes: ["brand_positioning", "brand_color_palette", "brand_typography", "brand_iconography", "tone_of_voice", "messaging_framework", "logo", "brand_assets"],
578
+ - **Messaging**: Elevator pitch, value propositions, CTAs`,
579
+ blockTypes: ["brand_positioning", "brand_visual_identity", "brand_moodboard", "tone_of_voice", "messaging_framework", "section_guide"],
2337
580
  },
2338
581
  "product": {
2339
582
  description: "Vision, features, and roadmap",
@@ -2342,7 +585,7 @@ This is the first section AI agents should read to understand project boundaries
2342
585
  - **Features**: Individual feature definitions with acceptance criteria
2343
586
  - **Product Strategy Canvas**: Product-specific strategy and goals
2344
587
  - **Feature Market Analysis**: Competitive analysis for specific features`,
2345
- blockTypes: ["product_overview", "feature", "product_strategy_canvas", "feature_market_analysis"],
588
+ blockTypes: ["product_overview", "feature", "product_strategy_canvas", "feature_market_analysis", "section_guide"],
2346
589
  },
2347
590
  "business-strategy": {
2348
591
  description: "Strategic planning frameworks and business models",
@@ -2353,7 +596,7 @@ This is the first section AI agents should read to understand project boundaries
2353
596
  - **Porter's Five Forces**: Competitive forces analysis
2354
597
  - **Strategic Group Map**: Market positioning visualization
2355
598
  - **Obeya Board**: Visual management board`,
2356
- blockTypes: ["ogsm", "business_model_canvas", "swot_analysis", "porters_five_forces", "strategic_group_map", "obeya_board"],
599
+ blockTypes: ["ogsm", "business_model_canvas", "swot_analysis", "porters_five_forces", "strategic_group_map", "obeya_board", "section_guide"],
2357
600
  },
2358
601
  "users": {
2359
602
  description: "Personas, jobs to be done, and user journeys",
@@ -2366,18 +609,17 @@ Organize files in subfolders:
2366
609
  - \`personas/\` - User persona files
2367
610
  - \`jobs-to-be-done/\` - JTBD files
2368
611
  - \`journey-maps/\` - Journey map files`,
2369
- blockTypes: ["persona", "jtbd", "journey_map"],
612
+ blockTypes: ["persona", "jtbd", "journey_map", "section_guide"],
2370
613
  },
2371
614
  "research": {
2372
615
  description: "Market and competitor analysis",
2373
616
  guidance: `Use this section to document:
2374
617
  - **Competitors**: Analysis of competing products/services
2375
- - **Market Research**: Market size, trends, and opportunities
2376
- - **User Research**: Findings from user interviews, usability tests
2377
- - **Surveys**: Survey research with response data and analysis
618
+ - **User Research**: Research documents with highlights and key insights
619
+ - **Research Data**: Tabular research data with charts and analysis
2378
620
 
2379
- Organize files in subfolders: \`competitors/\`, \`surveys/\``,
2380
- blockTypes: ["competitor", "market_research", "user_research", "survey"],
621
+ Organize files in subfolders: \`competitors/\`, \`data-research/\`, \`research-documents/\``,
622
+ blockTypes: ["competitor", "user_research", "research_data", "research_document", "section_guide"],
2381
623
  },
2382
624
  "technical": {
2383
625
  description: "Stack, architecture, and constraints",
@@ -2399,7 +641,7 @@ Organize files in subfolders:
2399
641
  - \`api/\` - API endpoint files
2400
642
  - \`models/\` - Data model files
2401
643
  - \`environments/\` - Environment files`,
2402
- blockTypes: ["tech_stack", "architecture_diagram", "integration", "constraint", "dev_setup", "api_endpoint", "api_spec", "data_model", "data_schema", "environment", "testing_strategy", "cost_calculator"],
644
+ blockTypes: ["tech_stack", "architecture_diagram", "integration", "constraint", "dev_setup", "api_endpoint", "api_spec", "data_model", "data_schema", "environment", "testing_strategy", "cost_calculator", "section_guide"],
2403
645
  },
2404
646
  "design-system": {
2405
647
  description: "Links to Storybook and Figma design resources",
@@ -2411,7 +653,7 @@ Organize files in subfolders:
2411
653
 
2412
654
  Note: This section is for linking external design tools, not for documenting
2413
655
  components directly. Component documentation lives in Storybook.`,
2414
- blockTypes: ["storybook_link", "figma_embed"],
656
+ blockTypes: ["storybook_link", "figma_embed", "section_guide"],
2415
657
  },
2416
658
  "information-architecture": {
2417
659
  description: "Site structure and taxonomies",
@@ -2425,7 +667,7 @@ components directly. Component documentation lives in Storybook.`,
2425
667
  - Hierarchical organization of content
2426
668
 
2427
669
  These blocks use visual editors in the EpicContext app.`,
2428
- blockTypes: ["ia_tree", "taxonomy"],
670
+ blockTypes: ["ia_tree", "taxonomy", "section_guide"],
2429
671
  },
2430
672
  "metrics": {
2431
673
  description: "KPIs and analytics",
@@ -2438,7 +680,7 @@ These blocks use visual editors in the EpicContext app.`,
2438
680
  - **Analytics Events**: Event tracking definitions for implementation
2439
681
 
2440
682
  Use AARRR categories (acquisition, activation, retention, revenue, referral) for the \`category\` field.`,
2441
- blockTypes: ["metric", "analytics_event"],
683
+ blockTypes: ["metric", "north_star", "kpi", "analytics_event", "section_guide"],
2442
684
  },
2443
685
  "decisions": {
2444
686
  description: "Architecture decision records",
@@ -2451,7 +693,7 @@ Use AARRR categories (acquisition, activation, retention, revenue, referral) for
2451
693
  - Consequences: What are the implications?
2452
694
 
2453
695
  Good ADRs help future team members understand why things are built this way.`,
2454
- blockTypes: ["decision"],
696
+ blockTypes: ["decision", "section_guide"],
2455
697
  },
2456
698
  "development": {
2457
699
  description: "Epics, stories, tasks, and roadmaps",
@@ -2468,7 +710,7 @@ Organize files in subfolders:
2468
710
  - \`stories/\` - User story files
2469
711
  - \`tasks/\` - Task/implementation plan files
2470
712
  - \`roadmaps/\` - Roadmap files`,
2471
- blockTypes: ["epic", "user_story", "task", "roadmap", "release", "impact_effort_matrix"],
713
+ blockTypes: ["epic", "user_story", "task", "roadmap", "release", "impact_effort_matrix", "section_guide"],
2472
714
  },
2473
715
  "marketing": {
2474
716
  description: "Marketing campaigns, ads, and content strategy",
@@ -2489,7 +731,28 @@ Organize files in subfolders:
2489
731
  - \`seo/\` - SEO content strategy files
2490
732
 
2491
733
  Always link campaigns to target personas and success metrics.`,
2492
- blockTypes: ["marketing_campaign", "seo_content"],
734
+ blockTypes: ["marketing_campaign", "seo_content", "section_guide"],
735
+ },
736
+ "reports": {
737
+ description: "Business cases, pain point analysis, and user sentiment reports",
738
+ guidance: `Use this section to create synthesis documents that analyze project context:
739
+ - **Business Case**: One-page business case with executive summary, market opportunity, value proposition, and recommendations
740
+ - Link to personas, features, and competitors for traceability
741
+ - Include confidence level based on data quality
742
+ - **Pain Points Report**: Analysis of bottlenecks across product, tech, and UX
743
+ - Categorize by domain (product, technical, UX, process)
744
+ - Include severity assessment and recommendations
745
+ - **User Sentiment Report**: User experience analysis with quotes and emotional journey
746
+ - Include positive/negative themes with supporting quotes
747
+ - Track satisfaction drivers and churn risks
748
+
749
+ Organize files in subfolders:
750
+ - \`business-cases/\` - Business case documents
751
+ - \`pain-points/\` - Pain points analysis reports
752
+ - \`sentiment/\` - User sentiment analysis reports
753
+
754
+ Reports should always reference source blocks (personas, journeys, research) for traceability.`,
755
+ blockTypes: ["business_case", "pain_points_report", "user_sentiment_report", "section_guide"],
2493
756
  },
2494
757
  };
2495
758
  for (const section of defaultSections) {