@nexus-framework/cli 0.1.2 → 0.1.3

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.
@@ -11,6 +11,20 @@
11
11
  * status and auto-populate template docs from codebase analysis.
12
12
  */
13
13
  import { version } from '../version.js';
14
+ /* ──────────────────────────────────────────────────────────────
15
+ * Display helpers
16
+ * ────────────────────────────────────────────────────────────── */
17
+ function getFrameworkDisplay(framework) {
18
+ const map = {
19
+ nextjs: 'Next.js 15 (App Router)',
20
+ 'react-vite': 'React + Vite',
21
+ sveltekit: 'SvelteKit',
22
+ nuxt: 'Nuxt 3',
23
+ astro: 'Astro',
24
+ remix: 'Remix',
25
+ };
26
+ return map[framework] ?? framework;
27
+ }
14
28
  /* ──────────────────────────────────────────────────────────────
15
29
  * Frontmatter helper
16
30
  * ────────────────────────────────────────────────────────────── */
@@ -46,6 +60,8 @@ export function generateDocs(config) {
46
60
  files.push(generateTestStrategy(config));
47
61
  files.push(generateImplementation(config));
48
62
  files.push(generateDeployment(config));
63
+ files.push(generateProjectIndex(config));
64
+ files.push(generateKnowledge(config));
49
65
  files.push(generateNexusIndex(config));
50
66
  files.push(generateNexusManifest(config));
51
67
  return files;
@@ -56,57 +72,24 @@ function generateVision(config) {
56
72
  content: `${frontmatter('01_vision', 'Product Vision & Requirements')}# Product Vision & Requirements
57
73
 
58
74
  **Project:** ${config.displayName}
59
- **Created:** ${new Date().toISOString().split('T')[0]}
60
- **Status:** 🟡 In Development
61
75
 
62
76
  ---
63
77
 
64
78
  ## 🎯 Product Vision
65
-
66
- <!-- Describe what you're building and why. Be specific about the problem you're solving. -->
67
-
68
- TODO: Write your product vision here.
69
-
70
- ---
79
+ <!-- What are you building and why? What problem does it solve? -->
71
80
 
72
81
  ## 👥 Target Users
73
-
74
- <!-- Who are your users? What are their pain points? Create 2-3 personas. -->
75
-
76
- TODO: Define your user personas.
77
-
78
- ---
82
+ <!-- 2-3 personas: role, goals, pain points, needs -->
79
83
 
80
84
  ## ✨ Core Features (MVP)
81
-
82
- <!-- List your must-have features with acceptance criteria. -->
83
-
84
- ### Feature 1: [Feature Name]
85
- **User Story:** As a [user], I want to [action] so that [benefit].
86
-
87
- **Acceptance Criteria:**
88
- - [ ] Criteria 1
89
- - [ ] Criteria 2
90
- - [ ] Criteria 3
91
-
92
- ---
85
+ <!-- List each feature with a user story + acceptance criteria.
86
+ AI: After filling this, copy each feature into .nexus/docs/index.md Feature Backlog. -->
93
87
 
94
88
  ## 🚫 Out of Scope (V1)
95
-
96
- <!-- What are you explicitly NOT building? This is just as important. -->
97
-
98
- - ❌ Item 1
99
- - ❌ Item 2
100
-
101
- ---
89
+ <!-- What you are explicitly NOT building yet -->
102
90
 
103
91
  ## 📊 Success Metrics
104
-
105
- <!-- How will you know if this project is successful? -->
106
-
107
- | Metric | Target | Timeframe |
108
- |--------|--------|-----------|
109
- | TODO | TODO | TODO |
92
+ <!-- How you'll measure success: metric, target, timeframe -->
110
93
  `,
111
94
  };
112
95
  }
@@ -122,14 +105,7 @@ function generateArchitecture(config) {
122
105
  ---
123
106
 
124
107
  ## 🏗️ Architecture Overview
125
-
126
- <!-- High-level diagram of your system. ASCII art or link to a diagram tool. -->
127
-
128
- \`\`\`
129
- TODO: Draw your architecture diagram here.
130
- \`\`\`
131
-
132
- ---
108
+ <!-- High-level system diagram (ASCII or link to diagram tool) -->
133
109
 
134
110
  ## 🛠️ Tech Stack
135
111
 
@@ -139,21 +115,11 @@ TODO: Draw your architecture diagram here.
139
115
  | Data | ${config.dataStrategy} | ${config.dataStrategy} strategy |
140
116
  | Testing | ${config.testFramework} | Selected during project setup |
141
117
 
142
- ---
143
-
144
118
  ## 📁 Directory Structure
145
-
146
- <!-- Document your folder conventions and where things go. -->
147
-
148
- TODO: Document your project's directory conventions.
149
-
150
- ---
119
+ <!-- Folder conventions: what goes where and why -->
151
120
 
152
121
  ## 🔄 Data Flow
153
-
154
- <!-- How does data move through your system? -->
155
-
156
- TODO: Describe your data flow.
122
+ <!-- How data moves through the system: user → UI → store → API → DB -->
157
123
  `,
158
124
  };
159
125
  }
@@ -168,26 +134,13 @@ function generateDataContracts(config) {
168
134
  ---
169
135
 
170
136
  ## 📊 Database Schema
171
-
172
- <!-- Define your data models, tables, relationships. -->
173
-
174
- TODO: Define your data models.
175
-
176
- ---
137
+ <!-- Define data models, tables/collections, and their fields with types -->
177
138
 
178
139
  ## ✅ Validation Rules
179
-
180
- <!-- What validation rules apply to your data? -->
181
-
182
- TODO: Document validation rules.
183
-
184
- ---
140
+ <!-- Required fields, min/max, format constraints, custom validators -->
185
141
 
186
142
  ## 🔗 Relationships
187
-
188
- <!-- How do your data models relate to each other? -->
189
-
190
- TODO: Document data relationships.
143
+ <!-- How models relate: one-to-many, many-to-many, foreign keys -->
191
144
  `,
192
145
  };
193
146
  }
@@ -201,21 +154,7 @@ function generateApiContracts(config) {
201
154
  ---
202
155
 
203
156
  ## 🔌 Endpoints
204
-
205
- <!-- Define your API endpoints with request/response shapes. -->
206
-
207
- ### \`GET /api/example\`
208
-
209
- **Description:** TODO
210
-
211
- **Response:**
212
- \`\`\`json
213
- {
214
- "data": []
215
- }
216
- \`\`\`
217
-
218
- ---
157
+ <!-- Define each API endpoint: method, path, description, request/response shapes -->
219
158
 
220
159
  ## 📋 Status Codes
221
160
 
@@ -230,6 +169,42 @@ function generateApiContracts(config) {
230
169
  };
231
170
  }
232
171
  function generateBusinessLogic(config) {
172
+ const patterns = config.appPatterns;
173
+ // Build pattern-specific sections based on user's selections
174
+ const patternSections = [];
175
+ if (patterns.includes('offline-first') || config.dataStrategy === 'local-first') {
176
+ patternSections.push(`## 🔄 Sync & Conflict Resolution
177
+ <!-- How do local changes sync with the server? What happens on conflict?
178
+ Define: sync trigger, queue structure, conflict strategy (last-write-wins / merge / user-prompt) -->`);
179
+ }
180
+ if (patterns.includes('real-time')) {
181
+ patternSections.push(`## ⚡ Real-Time System
182
+ <!-- WebSocket or SSE? What events are broadcast? Who receives them?
183
+ Define: connection lifecycle, event types, reconnection strategy, presence -->`);
184
+ }
185
+ if (patterns.includes('pwa')) {
186
+ patternSections.push(`## 📲 PWA / Service Worker
187
+ <!-- What is cached? Cache strategy (cache-first / network-first)?
188
+ Define: cache manifest, update flow, install prompt timing -->`);
189
+ }
190
+ if (patterns.includes('theming')) {
191
+ patternSections.push(`## 🎨 Theming System
192
+ <!-- CSS variables? Theme provider? How are themes stored and applied?
193
+ Define: theme shape (colors, fonts, spacing), persistence, switching logic -->`);
194
+ }
195
+ if (patterns.includes('i18n')) {
196
+ patternSections.push(`## 🌍 Internationalization (i18n)
197
+ <!-- Which i18n library? How are translations structured?
198
+ Define: default locale, supported locales, namespace strategy, lazy loading -->`);
199
+ }
200
+ if (patterns.includes('white-label')) {
201
+ patternSections.push(`## 🏷️ White Label / Multi-Tenant
202
+ <!-- How are tenants identified? Subdomain, path, or config?
203
+ Define: tenant resolution, per-tenant config shape, branding override points -->`);
204
+ }
205
+ const patternContent = patternSections.length > 0
206
+ ? patternSections.join('\n\n') + '\n'
207
+ : '';
233
208
  return {
234
209
  path: '.nexus/docs/05_business_logic.md',
235
210
  content: `${frontmatter('05_business_logic', 'Business Logic')}# Business Logic
@@ -239,30 +214,20 @@ function generateBusinessLogic(config) {
239
214
  ---
240
215
 
241
216
  ## 📐 Business Rules
242
-
243
- <!-- Document the core rules and logic of your application. -->
244
-
245
- TODO: Define your business rules.
246
-
247
- ---
217
+ <!-- Core rules of the application: what can/can't happen, constraints, permissions -->
248
218
 
249
219
  ## 🔄 State Machines
250
-
251
- <!-- If your app has complex state, document it here. -->
252
-
253
- TODO: Document state machines and flows.
254
-
255
- ---
220
+ <!-- Complex state flows: e.g. task lifecycle, auth flow, checkout process -->
256
221
 
257
222
  ## 🧮 Algorithms
223
+ <!-- Non-trivial logic: scoring, sorting, filtering, calculations -->
258
224
 
259
- <!-- Any non-trivial algorithms or calculations. -->
260
-
261
- TODO: Document algorithms.
262
- `,
225
+ ${patternContent}`,
263
226
  };
264
227
  }
265
228
  function generateTestStrategy(config) {
229
+ const pm = config.packageManager;
230
+ const runCmd = pm === 'npm' ? 'npm run' : pm;
266
231
  return {
267
232
  path: '.nexus/docs/06_test_strategy.md',
268
233
  content: `${frontmatter('06_test_strategy', 'Test Strategy')}# Test Strategy
@@ -273,13 +238,10 @@ function generateTestStrategy(config) {
273
238
  ---
274
239
 
275
240
  ## 🧪 Testing Philosophy
276
-
277
- <!-- What's your approach to testing? What's the coverage target? -->
241
+ <!-- Coverage target, what gets tested, what doesn't -->
278
242
 
279
243
  **Coverage Target:** 80%+
280
244
 
281
- ---
282
-
283
245
  ## 📋 Test Types
284
246
 
285
247
  | Type | Tool | Coverage |
@@ -288,14 +250,11 @@ function generateTestStrategy(config) {
288
250
  | Integration | ${config.testFramework} | API routes, data flows |
289
251
  | E2E | Playwright | Critical user journeys |
290
252
 
291
- ---
292
-
293
253
  ## 🏃 Running Tests
294
254
 
295
255
  \`\`\`bash
296
- npm test # Run all tests
297
- npm run test:watch # Watch mode
298
- npm run test:coverage # With coverage report
256
+ ${runCmd} test # Run all tests
257
+ ${runCmd} test -- --watch # Watch mode
299
258
  \`\`\`
300
259
  `,
301
260
  };
@@ -309,32 +268,83 @@ function generateImplementation(config) {
309
268
 
310
269
  ---
311
270
 
312
- ## 🔨 Build Order
271
+ ## 🎯 Current Phase
313
272
 
314
- <!-- What order should features be built in? -->
273
+ <!-- AI: After populating this doc, set the current phase based on what exists in the codebase. -->
315
274
 
316
- ### Phase 1: Foundation
317
- - [ ] Project setup ✅ (done by NEXUS CLI)
318
- - [ ] Core data models
319
- - [ ] Basic UI layout
275
+ **Active Phase:** TODO — Set this to the current build phase
276
+ **Blocked:** None
320
277
 
321
- ### Phase 2: Core Features
322
- - [ ] Feature 1
323
- - [ ] Feature 2
324
- - [ ] Feature 3
278
+ ---
279
+
280
+ ## 🔨 Build Phases
325
281
 
326
- ### Phase 3: Polish
327
- - [ ] Error handling
328
- - [ ] Loading states
329
- - [ ] Responsive design
282
+ <!-- AI: Derive these phases from 01_vision.md features. Each phase should be a coherent milestone. -->
283
+
284
+ ### Phase 1: Foundation
285
+ **Goal:** Project skeleton, core data models, basic navigation
286
+
287
+ | Task | File(s) | Status | Notes |
288
+ |------|---------|--------|-------|
289
+ | Project setup | (auto) | ✅ Done by NEXUS CLI | — |
290
+ | Core data models / types | \`src/types/\` or \`src/lib/\` | TODO | Define from 03_data_contracts.md |
291
+ | Basic layout / navigation | \`src/app/\` or \`src/routes/\` | TODO | — |
292
+ | Database / storage setup | \`src/lib/\` | TODO | Match data strategy: ${config.dataStrategy} |
293
+
294
+ ### Phase 2: Core Features (MVP)
295
+ **Goal:** Implement the features from 01_vision.md that make this usable
296
+
297
+ | Task | File(s) | Status | Notes |
298
+ |------|---------|--------|-------|
299
+ | Feature 1 | TODO | TODO | — |
300
+ | Feature 2 | TODO | TODO | — |
301
+ | Feature 3 | TODO | TODO | — |
302
+
303
+ ### Phase 3: Polish & Quality
304
+ **Goal:** Error handling, loading states, tests, responsive design
305
+
306
+ | Task | File(s) | Status | Notes |
307
+ |------|---------|--------|-------|
308
+ | Error boundaries / handling | TODO | TODO | — |
309
+ | Loading / skeleton states | TODO | TODO | — |
310
+ | Unit tests for core logic | \`tests/unit/\` | TODO | Match 06_test_strategy.md |
311
+ | Responsive design | TODO | TODO | — |
312
+
313
+ ### Phase 4: Deployment
314
+ **Goal:** CI/CD, environment config, production deploy
315
+
316
+ | Task | File(s) | Status | Notes |
317
+ |------|---------|--------|-------|
318
+ | CI/CD pipeline | \`.github/workflows/\` | ✅ Generated | — |
319
+ | Environment variables | \`.env.example\` | TODO | See 08_deployment.md |
320
+ | Production deploy | TODO | TODO | — |
330
321
 
331
322
  ---
332
323
 
333
324
  ## 📁 File-by-File Plan
334
325
 
335
- <!-- For AI agents: list each file that needs to be created and what it should contain. -->
326
+ <!-- AI: After populating 01_vision.md, list every file that needs creating.
327
+ Also copy each feature into .nexus/docs/index.md Feature Backlog table. -->
328
+
329
+ | # | File Path | Purpose | Status |
330
+ |---|-----------|---------|--------|
336
331
 
337
- TODO: Create a file-by-file implementation plan.
332
+ ---
333
+
334
+ ## 🧪 Testing Plan
335
+
336
+ | Test File | What It Tests | Status |
337
+ |-----------|--------------|--------|
338
+
339
+ ---
340
+
341
+ ## ⚠️ AI Agent: How To Use This File
342
+
343
+ 1. **Derive phases from \`01_vision.md\`** — turn user stories into build phases
344
+ 2. **Copy each feature into \`.nexus/docs/index.md\` Feature Backlog** — that drives all work
345
+ 3. **Fill the file-by-file plan** — list every file with its purpose
346
+ 4. **Update status as you work** — mark tasks ✅ when done
347
+ 5. **This file answers "what code do I write next?"**
338
348
  `,
339
349
  };
340
350
  }
@@ -348,12 +358,7 @@ function generateDeployment(config) {
348
358
  ---
349
359
 
350
360
  ## 🚀 Deployment Strategy
351
-
352
- <!-- Where and how will this be deployed? -->
353
-
354
- TODO: Define your deployment strategy.
355
-
356
- ---
361
+ <!-- Where and how will this be deployed? Platform, region, scaling -->
357
362
 
358
363
  ## 🔧 Environment Variables
359
364
 
@@ -361,17 +366,223 @@ TODO: Define your deployment strategy.
361
366
  |----------|-------------|----------|---------|
362
367
  | \`NODE_ENV\` | Environment | Yes | \`development\` |
363
368
 
369
+ ## 📦 CI/CD
370
+
371
+ GitHub Actions workflow at \`.github/workflows/ci.yml\` runs on push/PR to \`main\`:
372
+ lint → typecheck → test → build
373
+ `,
374
+ };
375
+ }
376
+ /* ──────────────────────────────────────────────────────────────
377
+ * Project Index — THE AI AGENT'S BRAIN
378
+ *
379
+ * This is THE most important file in the NEXUS system.
380
+ * It's NOT just a doc to fill in — it's the living project tracker
381
+ * that the AI agent must use to know:
382
+ * - What's been built
383
+ * - What to build next
384
+ * - Current blockers
385
+ * - Feature backlog
386
+ * - Session-by-session progress
387
+ *
388
+ * The agent must READ this before every task and UPDATE it after.
389
+ * ────────────────────────────────────────────────────────────── */
390
+ function generateProjectIndex(config) {
391
+ const frameworkDisplay = getFrameworkDisplay(config.frontendFramework);
392
+ const now = new Date().toISOString().split('T')[0];
393
+ return {
394
+ path: '.nexus/docs/index.md',
395
+ content: `${frontmatter('project_index', 'Project Index — AI Agent Brain')}# ${config.displayName} — Project Index
396
+
397
+ > **🧠 THIS IS THE AI AGENT'S BRAIN.**
398
+ > This is NOT just another doc to fill in. This is the living project tracker.
399
+ > AI agents MUST read this file before every task and update it after every task.
400
+
401
+ **Project:** ${config.displayName}
402
+ **Framework:** ${frameworkDisplay}
403
+ **Data Strategy:** ${config.dataStrategy}
404
+ **Created:** ${now}
405
+ **Status:** 🟡 Scaffolded — Awaiting vision + first feature
406
+
364
407
  ---
365
408
 
366
- ## 📦 CI/CD
409
+ ## 🎯 Current Objective
410
+
411
+ <!-- AI: This section must ALWAYS reflect what you're working on RIGHT NOW.
412
+ Update it at the start of every task. -->
413
+
414
+ **Current Phase:** Phase 1 — Foundation
415
+ **Active Task:** Populate NEXUS docs from user's project vision
416
+ **Blocked:** None
417
+ **Next Up:** See "What's Next" section below
418
+
419
+ ---
367
420
 
368
- A GitHub Actions workflow has been generated at \`.github/workflows/ci.yml\`.
421
+ ## 📊 Project Status Matrix
369
422
 
370
- It runs on every push and PR to \`main\`:
371
- 1. ✅ Lint
372
- 2. Type check
373
- 3. ✅ Tests
374
- 4. ✅ Build
423
+ <!-- AI: Update these statuses as you complete work. This is how you track progress. -->
424
+
425
+ | Area | Status | Notes |
426
+ |------|--------|-------|
427
+ | 📋 Vision & Requirements | 🔴 Template | Needs user input → \`.nexus/docs/01_vision.md\` |
428
+ | 🏗️ Architecture | 🔴 Template | Auto-fill from codebase → \`.nexus/docs/02_architecture.md\` |
429
+ | 📊 Data Contracts | 🔴 Template | Define from code → \`.nexus/docs/03_data_contracts.md\` |
430
+ | 🔌 API Contracts | 🔴 Template | Define from code → \`.nexus/docs/04_api_contracts.md\` |
431
+ | 📐 Business Logic | 🔴 Template | Needs user input → \`.nexus/docs/05_business_logic.md\` |
432
+ | 🧪 Test Strategy | 🔴 Template | Auto-fill from code → \`.nexus/docs/06_test_strategy.md\` |
433
+ | 🔨 Implementation Plan | 🔴 Template | Build from vision → \`.nexus/docs/07_implementation.md\` |
434
+ | 🚀 Deployment | 🔴 Template | Auto-fill from code → \`.nexus/docs/08_deployment.md\` |
435
+ | 🏠 Core Features | 🔴 Not started | See feature backlog below |
436
+ | 🧪 Tests | 🔴 Not started | — |
437
+
438
+ ---
439
+
440
+ ## 🗂️ Feature Backlog
441
+
442
+ <!-- AI: After populating 01_vision.md, copy EVERY Core Feature into this table.
443
+ Assign each a priority and phase. This is the ONLY list you work from. -->
444
+
445
+ | # | Feature | Priority | Status | Phase | Notes |
446
+ |---|---------|----------|--------|-------|-------|
447
+
448
+ ---
449
+
450
+ ## 📁 What Has Been Built
451
+
452
+ <!-- AI: Update this as you create files. Track every module, component, and test.
453
+ This is how you know what exists and what doesn't. -->
454
+
455
+ ### Source Files
456
+
457
+ | Module | Files | Status | Description |
458
+ |--------|-------|--------|-------------|
459
+ | Project scaffold | \`package.json\`, \`tsconfig.json\`, configs | ✅ | Generated by NEXUS CLI |
460
+ | Landing page | \`src/\` (framework-specific) | ✅ | NEXUS branded starter page |
461
+ | NEXUS docs | \`.nexus/docs/\` (8 files + index) | 🟡 Template | Awaiting population |
462
+ | AI config | \`.nexus/ai/\` + root files | ✅ | AI agent instructions |
463
+ | CI/CD | \`.github/workflows/ci.yml\` | ✅ | Lint + typecheck + test + build |
464
+
465
+ ### Tests
466
+
467
+ | File | Tests | Covers |
468
+ |------|-------|--------|
469
+ | TODO | TODO | TODO |
470
+
471
+ ---
472
+
473
+ ## 🔄 Progress Log
474
+
475
+ <!-- AI: Add an entry here every time you complete meaningful work.
476
+ This is the project's changelog and your memory across sessions. -->
477
+
478
+ ### ${now} — Project Created
479
+ - ✅ Scaffolded with NEXUS CLI (${frameworkDisplay}, ${config.dataStrategy})
480
+ - ✅ Generated project structure, configs, landing page, CI/CD
481
+ - ✅ Generated NEXUS documentation system (8 template docs)
482
+ - ⏳ Docs need to be populated with project-specific content
483
+
484
+ ---
485
+
486
+ ## 🎯 What's Next (Prioritized)
487
+
488
+ <!-- AI: THIS IS YOUR TODO LIST. Work through it top to bottom.
489
+ After completing an item, move it to the Progress Log and update the status matrix.
490
+ Add new items as they emerge. -->
491
+
492
+ ### 🔴 Do First (Before Any Feature Work)
493
+ 1. **Populate NEXUS docs** — Read the codebase + ask the user about their vision, then fill in all 8 docs (see onboarding protocol in AI instructions)
494
+ 2. **Build the implementation plan** — Turn features from \`01_vision.md\` into concrete build phases in \`07_implementation.md\` with a file-by-file plan
495
+ 3. **Update this index** — Fill in the feature backlog, status matrix, and "What Has Been Built" sections
496
+
497
+ ### 🟡 Then Build (Phase 1 — Foundation)
498
+ 4. **Core data models / types** — Define from \`03_data_contracts.md\`
499
+ 5. **Basic layout / navigation** — Main app shell, routing
500
+ 6. **Database / storage setup** — Match data strategy: ${config.dataStrategy}
501
+
502
+ ### 🟢 Then Build (Phase 2 — Core Features)
503
+ 7. **Feature 1** — TODO (derive from vision)
504
+ 8. **Feature 2** — TODO (derive from vision)
505
+ 9. **Feature 3** — TODO (derive from vision)
506
+
507
+ ---
508
+
509
+ ## ⚠️ AI Agent Operating Rules
510
+
511
+ **YOU MUST FOLLOW THESE RULES. They are not suggestions.**
512
+
513
+ 1. **READ this file before EVERY task** — it tells you what to do next
514
+ 2. **UPDATE this file after EVERY task** — move completed items to Progress Log, update status matrix
515
+ 3. **DON'T ask "what enhancements would you like?"** — check the "What's Next" section instead
516
+ 4. **DON'T treat docs as one-time fill-ins** — they are living documents, update them as the project evolves
517
+ 5. **The feature backlog is your roadmap** — suggest the next item from it, don't invent random features
518
+ 6. **The implementation plan (\`07_implementation.md\`) tells you WHAT CODE to write** — check it before every feature
519
+ 7. **The progress log is your memory** — add entries so you (or the next agent) know what happened
520
+ 8. **If the user asks for a feature, check if it's already in the backlog** — if yes, just build it; if no, add it first
521
+ 9. **After every session, ensure this file reflects reality** — statuses, progress, blockers, next steps
522
+ 10. **Learn as you go** — when you discover something non-obvious (bug pattern, architecture insight, package quirk), append it to \`.nexus/docs/knowledge.md\`. Scan that file before making big decisions.
523
+
524
+ ---
525
+
526
+ *Generated by [NEXUS CLI](https://github.com/GDA-Africa/nexus-cli) v${version} — AI-native project scaffolding by [GDA Africa](https://github.com/GDA-Africa)*
527
+ `,
528
+ };
529
+ }
530
+ /* ──────────────────────────────────────────────────────────────
531
+ * Progressive Knowledge Base — .nexus/docs/knowledge.md
532
+ *
533
+ * An append-only living document. AI agents add entries as they
534
+ * learn things about the project — architectural decisions,
535
+ * bug patterns, package quirks, performance findings, etc.
536
+ *
537
+ * NOT a template doc (no status: template frontmatter).
538
+ * Agents should NEVER delete entries — only append.
539
+ * ────────────────────────────────────────────────────────────── */
540
+ function generateKnowledge(config) {
541
+ const now = new Date().toISOString().split('T')[0];
542
+ return {
543
+ path: '.nexus/docs/knowledge.md',
544
+ content: `# ${config.displayName} — Knowledge Base
545
+
546
+ > **Progressive learning file.** AI agents append entries here as they discover
547
+ > project-specific insights. This file grows organically — never delete entries.
548
+
549
+ ---
550
+
551
+ ## How This Works
552
+
553
+ - **When to add:** After discovering something non-obvious — a bug pattern, an architecture decision, a package quirk, a performance finding, a convention choice
554
+ - **When NOT to add:** Routine task completion (that goes in \`index.md\` Progress Log)
555
+ - **Format:** One entry = category tag + one-line insight + optional detail line
556
+ - **When to read:** Before making architectural decisions, debugging recurring issues, or choosing packages/patterns — scan for relevant categories first
557
+
558
+ ---
559
+
560
+ ## Categories
561
+
562
+ | Tag | Use When |
563
+ |-----|----------|
564
+ | \`architecture\` | Design decisions, structural choices, why X over Y |
565
+ | \`bug-fix\` | Recurring bugs, root causes, things to watch for |
566
+ | \`pattern\` | Code patterns that work well (or don't) in this project |
567
+ | \`package\` | Package quirks, version issues, config gotchas |
568
+ | \`performance\` | Bottlenecks found, optimizations applied |
569
+ | \`convention\` | Team/project conventions established during development |
570
+ | \`gotcha\` | Non-obvious traps, edge cases, things that wasted time |
571
+
572
+ ---
573
+
574
+ ## Entries
575
+
576
+ <!-- AI: Append new entries below this line. Format:
577
+
578
+ ### [CATEGORY] Short title
579
+ **${now}** — One-line insight.
580
+ Optional: Brief supporting detail (1-2 sentences max).
581
+
582
+ -->
583
+
584
+ ### [convention] Project scaffolded with NEXUS CLI
585
+ **${now}** — This project was generated with NEXUS CLI. Follow the doc system in \`.nexus/docs/\` and always read \`index.md\` (the brain) before each task.
375
586
  `,
376
587
  };
377
588
  }
@@ -386,18 +597,27 @@ function generateNexusIndex(config) {
386
597
 
387
598
  ---
388
599
 
600
+ ## 🧠 Start Here
601
+
602
+ **AI agents: Read \`.nexus/docs/index.md\` FIRST** — that is your project brain.
603
+ It tracks status, features, progress, and what to work on next.
604
+
605
+ ---
606
+
389
607
  ## 📚 Document Map
390
608
 
391
609
  | Doc | Path | Purpose |
392
610
  |-----|------|---------|
611
+ | **🧠 Project Brain** | **\`.nexus/docs/index.md\`** | **Status, backlog, progress, what's next** |
393
612
  | Vision | \`.nexus/docs/01_vision.md\` | Product requirements & user stories |
394
613
  | Architecture | \`.nexus/docs/02_architecture.md\` | System design & tech stack |
395
614
  | Data Contracts | \`.nexus/docs/03_data_contracts.md\` | Database schemas & validation |
396
615
  | API Contracts | \`.nexus/docs/04_api_contracts.md\` | Endpoints & interfaces |
397
616
  | Business Logic | \`.nexus/docs/05_business_logic.md\` | Rules, algorithms & flows |
398
617
  | Test Strategy | \`.nexus/docs/06_test_strategy.md\` | Testing philosophy & coverage |
399
- | Implementation | \`.nexus/docs/07_implementation.md\` | Build order & file structure |
618
+ | Implementation | \`.nexus/docs/07_implementation.md\` | Build order & file-by-file plan |
400
619
  | Deployment | \`.nexus/docs/08_deployment.md\` | Infrastructure & CI/CD |
620
+ | **📚 Knowledge Base** | **\`.nexus/docs/knowledge.md\`** | **Learned insights, patterns & gotchas** |
401
621
 
402
622
  ---
403
623
 
@@ -405,11 +625,11 @@ function generateNexusIndex(config) {
405
625
 
406
626
  If you are an AI reading this project:
407
627
 
408
- 1. **Start with** \`.nexus/docs/01_vision.md\` to understand what this project does
409
- 2. **Read** \`.nexus/docs/02_architecture.md\` to understand the tech decisions
410
- 3. **Reference** \`.nexus/docs/03_data_contracts.md\` and \`.nexus/docs/04_api_contracts.md\` for exact schemas
411
- 4. **Follow** \`.nexus/docs/07_implementation.md\` for build order
412
- 5. **Run tests** after every change using the commands in \`.nexus/docs/06_test_strategy.md\`
628
+ 1. **START with \`.nexus/docs/index.md\`** your project brain, read it before every task
629
+ 2. **Read \`.nexus/docs/01_vision.md\`** to understand what this project does
630
+ 3. **Check \`.nexus/docs/07_implementation.md\`** for the file-by-file build plan
631
+ 4. **After every task, update \`.nexus/docs/index.md\`** progress log, status, what's next
632
+ 5. **Never ask "what should we do next?"** — the index tells you
413
633
  `,
414
634
  };
415
635
  }