mycontext-cli 4.1.5 → 4.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (116) hide show
  1. package/README.md +108 -126
  2. package/dist/README.md +108 -126
  3. package/dist/agents/implementations/ArchitectAgent.d.ts.map +1 -1
  4. package/dist/agents/implementations/ArchitectAgent.js +9 -1
  5. package/dist/agents/implementations/ArchitectAgent.js.map +1 -1
  6. package/dist/agents/implementations/BackendDevAgent.d.ts +1 -1
  7. package/dist/agents/implementations/BackendDevAgent.d.ts.map +1 -1
  8. package/dist/agents/implementations/BackendDevAgent.js +29 -16
  9. package/dist/agents/implementations/BackendDevAgent.js.map +1 -1
  10. package/dist/agents/implementations/CodeGenSubAgent.d.ts.map +1 -1
  11. package/dist/agents/implementations/CodeGenSubAgent.js +17 -9
  12. package/dist/agents/implementations/CodeGenSubAgent.js.map +1 -1
  13. package/dist/agents/implementations/EnhancementAgent.js.map +1 -1
  14. package/dist/agents/implementations/FeatureAssemblyAgent.d.ts +1 -1
  15. package/dist/agents/implementations/FeatureAssemblyAgent.d.ts.map +1 -1
  16. package/dist/agents/implementations/FeatureAssemblyAgent.js +10 -9
  17. package/dist/agents/implementations/FeatureAssemblyAgent.js.map +1 -1
  18. package/dist/agents/implementations/PromptConstructorAgent.d.ts.map +1 -1
  19. package/dist/agents/implementations/PromptConstructorAgent.js +26 -42
  20. package/dist/agents/implementations/PromptConstructorAgent.js.map +1 -1
  21. package/dist/cli.js +72 -0
  22. package/dist/cli.js.map +1 -1
  23. package/dist/clients/ProviderChain.d.ts +6 -65
  24. package/dist/clients/ProviderChain.d.ts.map +1 -1
  25. package/dist/clients/ProviderChain.js +34 -194
  26. package/dist/clients/ProviderChain.js.map +1 -1
  27. package/dist/commands/agent.js +1 -1
  28. package/dist/commands/agent.js.map +1 -1
  29. package/dist/commands/assemble-features.js +1 -1
  30. package/dist/commands/assemble-features.js.map +1 -1
  31. package/dist/commands/design-analyze.js +2 -2
  32. package/dist/commands/generate-context-files.d.ts.map +1 -1
  33. package/dist/commands/generate-context-files.js +13 -0
  34. package/dist/commands/generate-context-files.js.map +1 -1
  35. package/dist/commands/generate.d.ts +1 -0
  36. package/dist/commands/generate.d.ts.map +1 -1
  37. package/dist/commands/generate.js +96 -23
  38. package/dist/commands/generate.js.map +1 -1
  39. package/dist/commands/init.d.ts.map +1 -1
  40. package/dist/commands/init.js +36 -2
  41. package/dist/commands/init.js.map +1 -1
  42. package/dist/commands/sync-readme.js +1 -1
  43. package/dist/commands/sync-readme.js.map +1 -1
  44. package/dist/core/agents/DependencySentinel.d.ts +15 -0
  45. package/dist/core/agents/DependencySentinel.d.ts.map +1 -0
  46. package/dist/core/agents/DependencySentinel.js +141 -0
  47. package/dist/core/agents/DependencySentinel.js.map +1 -0
  48. package/dist/core/ai/AICore.d.ts +48 -0
  49. package/dist/core/ai/AICore.d.ts.map +1 -0
  50. package/dist/core/ai/AICore.js +228 -0
  51. package/dist/core/ai/AICore.js.map +1 -0
  52. package/dist/core/brain/BrainClient.d.ts +18 -0
  53. package/dist/core/brain/BrainClient.d.ts.map +1 -0
  54. package/dist/core/brain/BrainClient.js +170 -0
  55. package/dist/core/brain/BrainClient.js.map +1 -0
  56. package/dist/package.json +5 -5
  57. package/dist/services/ContextSyncer.d.ts +40 -0
  58. package/dist/services/ContextSyncer.d.ts.map +1 -0
  59. package/dist/services/ContextSyncer.js +219 -0
  60. package/dist/services/ContextSyncer.js.map +1 -0
  61. package/dist/services/ProjectScanner.d.ts +74 -0
  62. package/dist/services/ProjectScanner.d.ts.map +1 -0
  63. package/dist/services/ProjectScanner.js +343 -0
  64. package/dist/services/ProjectScanner.js.map +1 -0
  65. package/dist/services/ScaffoldAgent.d.ts +35 -0
  66. package/dist/services/ScaffoldAgent.d.ts.map +1 -0
  67. package/dist/services/ScaffoldAgent.js +228 -0
  68. package/dist/services/ScaffoldAgent.js.map +1 -0
  69. package/dist/tui/PlanningMode.d.ts +42 -0
  70. package/dist/tui/PlanningMode.d.ts.map +1 -0
  71. package/dist/tui/PlanningMode.js +401 -0
  72. package/dist/tui/PlanningMode.js.map +1 -0
  73. package/dist/tui/TUIClient.d.ts +20 -0
  74. package/dist/tui/TUIClient.d.ts.map +1 -0
  75. package/dist/tui/TUIClient.js +50 -0
  76. package/dist/tui/TUIClient.js.map +1 -0
  77. package/dist/types/living-context.d.ts +76 -0
  78. package/dist/types/living-context.d.ts.map +1 -0
  79. package/dist/types/living-context.js +3 -0
  80. package/dist/types/living-context.js.map +1 -0
  81. package/dist/types/mega-context.d.ts +118 -0
  82. package/dist/types/mega-context.d.ts.map +1 -0
  83. package/dist/types/mega-context.js +3 -0
  84. package/dist/types/mega-context.js.map +1 -0
  85. package/dist/types/tui.d.ts +29 -0
  86. package/dist/types/tui.d.ts.map +1 -0
  87. package/dist/types/tui.js +8 -0
  88. package/dist/types/tui.js.map +1 -0
  89. package/dist/types/unified-context.d.ts +102 -0
  90. package/dist/types/unified-context.d.ts.map +1 -0
  91. package/dist/types/unified-context.js +50 -0
  92. package/dist/types/unified-context.js.map +1 -0
  93. package/dist/utils/FileGenerator.d.ts +14 -0
  94. package/dist/utils/FileGenerator.d.ts.map +1 -0
  95. package/dist/utils/FileGenerator.js +154 -0
  96. package/dist/utils/FileGenerator.js.map +1 -0
  97. package/dist/utils/NextJSProjectGenerator.d.ts.map +1 -1
  98. package/dist/utils/NextJSProjectGenerator.js +59 -0
  99. package/dist/utils/NextJSProjectGenerator.js.map +1 -1
  100. package/dist/utils/contextRenderer.d.ts +12 -0
  101. package/dist/utils/contextRenderer.d.ts.map +1 -0
  102. package/dist/utils/contextRenderer.js +105 -0
  103. package/dist/utils/contextRenderer.js.map +1 -0
  104. package/dist/utils/deepMerge.d.ts +14 -0
  105. package/dist/utils/deepMerge.d.ts.map +1 -0
  106. package/dist/utils/deepMerge.js +87 -0
  107. package/dist/utils/deepMerge.js.map +1 -0
  108. package/dist/utils/fileSystem.d.ts +4 -0
  109. package/dist/utils/fileSystem.d.ts.map +1 -1
  110. package/dist/utils/fileSystem.js +47 -0
  111. package/dist/utils/fileSystem.js.map +1 -1
  112. package/dist/utils/hybridAIClient.d.ts +12 -117
  113. package/dist/utils/hybridAIClient.d.ts.map +1 -1
  114. package/dist/utils/hybridAIClient.js +31 -750
  115. package/dist/utils/hybridAIClient.js.map +1 -1
  116. package/package.json +25 -23
package/README.md CHANGED
@@ -1,16 +1,21 @@
1
1
  # mycontext-cli
2
2
 
3
- **The Command-Line Anchor for Zero-Drift Autonomous Development.**
3
+ **The Command-Line Brain for Zero-Drift Autonomous Development.**
4
4
 
5
- `mycontext-cli` is your AI-powered development companion that transforms screenshots into specs, generates production-ready code, and keeps your implementation perfectly aligned with design intent.
5
+ `mycontext-cli` is your AI-powered development companion that builds a **Living Brain** (`context.json`) for your codebase — so AI agents operate on facts, not hallucinations. It scaffolds projects deterministically, detects context drift, and keeps your implementation perfectly aligned with design intent.
6
+
7
+ [![npm version](https://img.shields.io/npm/v/mycontext-cli.svg)](https://www.npmjs.com/package/mycontext-cli)
8
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
6
9
 
7
10
  ## ✨ Key Features
8
11
 
9
- 🎯 **Screenshot → Spec** - Reverse-engineer any UI into comprehensive specifications (Powered by Gemini 2.0 Flash)
10
- 🤖 **Autonomous Code Generation** - AI agents that write code grounded in deterministic specs
11
- 🔒 **Zero-Drift Development** - Maintain perfect alignment between design intent and implementation
12
- 📊 **Living DB** - Deterministic manifest that evolves with your project
13
- 🚀 **Instant Setup** - Initialize Next.js projects with shadcn/ui, InstantDB, and more
12
+ - 🧠 **Living Brain** A single source of truth (`context.json`) that acts as the shared "blackboard" for all agents
13
+ - 🔄 **Self-Recontextualization** `mycontext sync` autonomously updates context + README by scanning your actual code
14
+ - 📂 **Bidirectional Drift Detection** Finds what's in code but not in context, and vice versa
15
+ - 🏗️ **Deterministic Scaffolding** AI interview MegaContext → scaffold with zero guessing
16
+ - 🧱 **Lego Assembly** Component registry + semantic retrieval for consistent code generation
17
+ - 🌲 **Fractal Architecture** — Recursive decomposition down to atomic UX flows
18
+ - 🤖 **Scalable Agent Teams** — Agents coordinate via shared state, not fragile message-passing
14
19
 
15
20
  ---
16
21
 
@@ -29,190 +34,170 @@ npx mycontext-cli init
29
34
  ## 🛠️ Commands Reference
30
35
 
31
36
  ### `mycontext init`
32
- Initialize a new project with the MyContext ecosystem.
37
+ Interactive TUI that interviews you → builds a complete MegaContext deterministically scaffolds.
33
38
 
34
39
  ```bash
35
40
  mycontext init
36
-
37
- # Skip prompts (use defaults)
38
- mycontext init --yes
39
41
  ```
40
42
 
41
43
  **What it does:**
42
- - Creates `.mycontext/` directory structure
43
- - Generates initial `design-manifest.json`
44
- - Sets up shadcn/ui components
45
- - Optional InstantDB initialization
46
- - Installs required dependencies
44
+ - Detects existing context.json → offers Refine / Scan / Sync / Fresh
45
+ - AI-driven interview to populate MegaContext (entities, routes, roles, design)
46
+ - Scaffolds Next.js + InstantDB with schema, routes, ALIGN, README, .env
47
47
 
48
48
  ---
49
49
 
50
- ### `mycontext analyze <screenshot>`
51
- Analyze a screenshot and generate comprehensive specifications.
50
+ ### `mycontext scan`
51
+ Walk the real file tree and compare against your planned context.
52
52
 
53
53
  ```bash
54
- mycontext analyze path/to/screenshot.png
54
+ # Quick scan — file tree stats
55
+ mycontext scan
55
56
 
56
- # Output to specific file
57
- mycontext analyze screenshot.png --output .mycontext/screen-spec.json
58
- ```
57
+ # AI-powered assessment drift detection + merge suggestions
58
+ mycontext scan --assess
59
59
 
60
- **What it does:**
61
- - Uses Gemini 2.0 Flash vision model
62
- - Extracts UI components, layout, and design tokens
63
- - Generates detailed specifications
64
- - Updates design manifest
60
+ # Machine-readable output
61
+ mycontext scan --assess --json
62
+ ```
65
63
 
66
64
  ---
67
65
 
68
- ### `mycontext generate`
69
- Generate context files, components, or code from your specifications.
66
+ ### `mycontext sync` ✨ NEW
67
+ Autonomous self-recontextualization. Scans assesses deep merges context.json → LLM-generates README.
70
68
 
71
69
  ```bash
72
- # Generate full context for AI coding assistants
73
- mycontext generate context --full
74
-
75
- # Generate specific components
76
- mycontext generate components
70
+ # Full sync (context.json + README)
71
+ mycontext sync
77
72
 
78
- # Generate Next.js routes from specs
79
- mycontext generate screens
73
+ # Preview changes without writing
74
+ mycontext sync --dry-run
80
75
 
81
- # Generate sample data
82
- mycontext generate sample-data
76
+ # Sync only context or only README
77
+ mycontext sync --context
78
+ mycontext sync --readme
83
79
  ```
84
80
 
85
- **Context files include:**
86
- - Project overview and architecture
87
- - Design tokens and component hierarchy
88
- - Data models and API specifications
89
- - Current implementation status
81
+ **How it works:**
82
+ 1. `ProjectScanner` walks your file tree and reads key files
83
+ 2. LLM compares actual code vs. planned context → generates `ContextDiffReport`
84
+ 3. `deepMerge()` safely updates context.json (recursive, arrays deduped by name/id)
85
+ 4. LLM generates README content between `<!-- mycontext:start -->` / `<!-- mycontext:end -->` markers
90
86
 
91
87
  ---
92
88
 
93
- ### `mycontext status`
94
- Check narrative compliance - analyze drift between spec and implementation.
89
+ ### `mycontext generate`
90
+ Generate context files, types, and code from your specifications.
95
91
 
96
92
  ```bash
97
- mycontext status
93
+ # Full context generation
94
+ mycontext generate context --full
98
95
 
99
- # Detailed report
100
- mycontext status --verbose
101
- ```
96
+ # Generate types from schema
97
+ mycontext generate types --from-schema
102
98
 
103
- **What it checks:**
104
- - Design manifest integrity
105
- - Component implementation status
106
- - Missing dependencies
107
- - Configuration issues
99
+ # Generate components
100
+ mycontext generate components
101
+ ```
108
102
 
109
103
  ---
110
104
 
111
105
  ### `mycontext agent`
112
- Autonomous development agent for feature implementation.
106
+ Multi-agent task execution via the Brain blackboard pattern.
113
107
 
114
108
  ```bash
115
- # Generate implementation plan
109
+ # Plan a feature
116
110
  mycontext agent --plan "Add user authentication"
117
111
 
118
- # Execute autonomous code generation
112
+ # Execute autonomously
119
113
  mycontext agent --execute "Implement shopping cart"
120
114
  ```
121
115
 
122
- **Features:**
123
- - Multi-agent orchestration (Architect, CodeGen, QA, Security)
124
- - Deterministic prompt construction
125
- - Context-aware code generation
126
- - Built-in testing and validation
127
-
128
116
  ---
129
117
 
130
- ## 🎯 Quick Start Example
118
+ ### `mycontext analyze`
119
+ Reverse-engineer UI from screenshots into specifications.
131
120
 
132
121
  ```bash
133
- # 1. Create a new Next.js project
134
- npx create-next-app my-app
135
- cd my-app
122
+ mycontext analyze screenshot.png
123
+ ```
136
124
 
137
- # 2. Initialize MyContext
138
- npx mycontext-cli init
125
+ ---
139
126
 
140
- # 3. Configure AI provider (choose one)
141
- # GitHub Models (Free, High Quality)
142
- echo 'GITHUB_TOKEN=your-token' >> .mycontext/.env
127
+ ## 🎯 Quick Start
143
128
 
144
- # Or Gemini (Free tier + Vision)
145
- echo 'GEMINI_API_KEY=your-key' >> .mycontext/.env
129
+ ```bash
130
+ # 1. Initialize (in any project directory)
131
+ npx mycontext-cli init
146
132
 
147
- # 4. Analyze a design screenshot
148
- mycontext analyze designs/homepage.png
133
+ # 2. Configure AI (choose one — all have free tiers)
134
+ echo 'GEMINI_API_KEY=your-key' >> .mycontext/.env
135
+ # Or: GITHUB_TOKEN, OPENROUTER_API_KEY, ANTHROPIC_API_KEY, XAI_API_KEY
149
136
 
150
- # 5. Generate full context for AI assistants
151
- mycontext generate context --full
137
+ # 3. Scan your project
138
+ mycontext scan --assess
152
139
 
153
- # 6. Use autonomous agent for feature development
154
- mycontext agent --plan "Add dark mode toggle"
140
+ # 4. Auto-sync context + README
141
+ mycontext sync
155
142
  ```
156
143
 
157
144
  ---
158
145
 
159
- ## 🔧 Configuration
160
-
161
- ### AI Provider Setup
146
+ ## 🔧 AI Provider Setup
162
147
 
163
- MyContext supports multiple AI providers. Configure in `.mycontext/.env`:
148
+ Configure in `.mycontext/.env` — MyContext auto-detects whichever key is present:
164
149
 
165
- **GitHub Models** (Recommended - Free & High Quality)
166
- ```bash
167
- GITHUB_TOKEN=ghp_your_token_here
168
- # Get token: https://github.com/settings/tokens
169
- ```
150
+ | Provider | Env Variable | Free Tier | Get Key |
151
+ |----------|-------------|-----------|---------|
152
+ | **Gemini** | `GEMINI_API_KEY` | ✅ Yes | [aistudio.google.com/apikey](https://aistudio.google.com/apikey) |
153
+ | **GitHub Models** | `GITHUB_TOKEN` | ✅ Yes | [github.com/settings/tokens](https://github.com/settings/tokens) |
154
+ | **OpenRouter** | `OPENROUTER_API_KEY` | Credits | [openrouter.ai/keys](https://openrouter.ai/keys) |
155
+ | **Anthropic** | `ANTHROPIC_API_KEY` | Credits | [console.anthropic.com](https://console.anthropic.com/) |
156
+ | **xAI (Grok)** | `XAI_API_KEY` | Credits | [x.ai](https://x.ai/) |
170
157
 
171
- **Gemini** (Free Tier + Vision for screenshots)
172
- ```bash
173
- GEMINI_API_KEY=your_gemini_key
174
- # Get key: https://aistudio.google.com/apikey
175
- ```
176
-
177
- **Claude** (Best for advanced reasoning)
178
- ```bash
179
- ANTHROPIC_API_KEY=your_claude_key
180
- # Get key: https://console.anthropic.com/
181
- ```
182
-
183
- **OpenAI**
184
- ```bash
185
- OPENAI_API_KEY=your_openai_key
186
- ```
158
+ Provider fallback chain: Gemini GitHub Models OpenRouter → Anthropic → xAI
187
159
 
188
160
  ---
189
161
 
190
162
  ## 📁 Project Structure
191
163
 
192
- After running `mycontext init`, your project will have:
164
+ After running `mycontext init`:
193
165
 
194
166
  ```
195
167
  .mycontext/
196
- ├── .env # AI provider configuration
197
- ├── design-manifest.json # Living DB - source of truth
198
- ├── context/ # Generated context files
199
- │ ├── PROJECT_OVERVIEW.md
200
- ├── ARCHITECTURE.md
201
- │ └── ...
202
- └── logs/ # Operation logs
168
+ ├── .env # AI provider keys
169
+ ├── context.json # Living Brain primary source of truth
170
+ ├── ALIGN # Alignment Guard — rules for AI assistants
171
+ └── context/ # Exported Markdown views for humans/AI
172
+ ├── 01-prd.md
173
+ ├── 01a-features.md
174
+ └── ...
203
175
  ```
204
176
 
205
177
  ---
206
178
 
207
- ## 🎯 The Philosophy: Hard Gravity
179
+ ## 🏛️ Architecture: Unified Context
180
+
181
+ `context.json` supports two schemas that coexist:
208
182
 
209
- Every project starts with a **deterministic spec**. The CLI ensures that code never drifts from its design intent, providing a "Hard Gravity" anchor that keeps the project cohesive even as it scales beyond human capacity to track every detail.
183
+ | Schema | Purpose | Key Fields |
184
+ |--------|---------|------------|
185
+ | **MegaContext** | Deterministic scaffolding | `database.entities`, `routing.routes`, `auth.roles`, `topLevelDesign` |
186
+ | **Brain** | Existing/scanned projects | `brain.narrative`, `brain.registry`, `brain.checkpoints`, `brain.memory` |
210
187
 
211
- **Zero-Drift Development:**
212
- 1. **Screenshot → Spec** - AI vision extracts design intent
213
- 2. **Spec → Code** - Agents generate implementation
214
- 3. **Code → Validation** - Continuous narrative compliance checks
215
- 4. **Never Drift** - Living DB maintains alignment
188
+ The `UnifiedContext` type bridges both. `getContextSummary()` extracts data from either shape. `deepMerge()` safely combines them.
189
+
190
+ ---
191
+
192
+ ## 🎯 Philosophy: Hard Gravity
193
+
194
+ Every project starts with a **deterministic spec**. The CLI ensures code never drifts from design intent:
195
+
196
+ 1. **Interview → MegaContext** — AI-driven 100% knowledge collection
197
+ 2. **MegaContext → Scaffold** — Deterministic generation, zero guessing
198
+ 3. **Scan → Assess** — Continuous bidirectional drift detection
199
+ 4. **Sync → Update** — Autonomous self-recontextualization
200
+ 5. **Never Drift** — Living Brain maintains alignment
216
201
 
217
202
  ---
218
203
 
@@ -220,7 +205,6 @@ Every project starts with a **deterministic spec**. The CLI ensures that code ne
220
205
 
221
206
  This package is part of the [MyContext Monorepo](https://github.com/farajabien/mycontext-cli).
222
207
 
223
- For local development:
224
208
  ```bash
225
209
  git clone https://github.com/farajabien/mycontext-cli.git
226
210
  cd mycontext-cli
@@ -233,13 +217,11 @@ cd apps/cli && pnpm link --global
233
217
 
234
218
  ## 📄 License
235
219
 
236
- MIT © MyContext - See [LICENSE](https://github.com/farajabien/mycontext-cli/blob/main/LICENSE) for details.
237
-
238
- ---
220
+ MIT © MyContext See [LICENSE](https://github.com/farajabien/mycontext-cli/blob/main/LICENSE)
239
221
 
240
222
  ## 🔗 Links
241
223
 
242
- - [Documentation](https://github.com/farajabien/mycontext-cli#readme)
243
- - [Report Issues](https://github.com/farajabien/mycontext-cli/issues)
224
+ - [Monorepo](https://github.com/farajabien/mycontext-cli)
244
225
  - [npm Package](https://www.npmjs.com/package/mycontext-cli)
226
+ - [Report Issues](https://github.com/farajabien/mycontext-cli/issues)
245
227
  - [Core Package (@myycontext/core)](https://www.npmjs.com/package/@myycontext/core)