mycontext-cli 4.2.0 → 4.2.2
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/README.md +128 -133
- package/dist/README.md +128 -133
- package/dist/cli.js +76 -0
- package/dist/cli.js.map +1 -1
- package/dist/commands/doctor.d.ts +18 -0
- package/dist/commands/doctor.d.ts.map +1 -0
- package/dist/commands/doctor.js +53 -0
- package/dist/commands/doctor.js.map +1 -0
- package/dist/commands/init.d.ts.map +1 -1
- package/dist/commands/init.js +99 -2
- package/dist/commands/init.js.map +1 -1
- package/dist/core/brain/BrainClient.d.ts +2 -0
- package/dist/core/brain/BrainClient.d.ts.map +1 -1
- package/dist/core/brain/BrainClient.js +19 -0
- package/dist/core/brain/BrainClient.js.map +1 -1
- package/dist/doctor/DoctorEngine.d.ts +5 -0
- package/dist/doctor/DoctorEngine.d.ts.map +1 -0
- package/dist/doctor/DoctorEngine.js +491 -0
- package/dist/doctor/DoctorEngine.js.map +1 -0
- package/dist/doctor/api.d.ts +4 -0
- package/dist/doctor/api.d.ts.map +1 -0
- package/dist/doctor/api.js +19 -0
- package/dist/doctor/api.js.map +1 -0
- package/dist/doctor/rules/dead-code-rules.d.ts +3 -0
- package/dist/doctor/rules/dead-code-rules.d.ts.map +1 -0
- package/dist/doctor/rules/dead-code-rules.js +269 -0
- package/dist/doctor/rules/dead-code-rules.js.map +1 -0
- package/dist/doctor/rules/index.d.ts +11 -0
- package/dist/doctor/rules/index.d.ts.map +1 -0
- package/dist/doctor/rules/index.js +21 -0
- package/dist/doctor/rules/index.js.map +1 -0
- package/dist/doctor/rules/nextjs-rules.d.ts +3 -0
- package/dist/doctor/rules/nextjs-rules.d.ts.map +1 -0
- package/dist/doctor/rules/nextjs-rules.js +357 -0
- package/dist/doctor/rules/nextjs-rules.js.map +1 -0
- package/dist/doctor/rules/node-rules.d.ts +3 -0
- package/dist/doctor/rules/node-rules.d.ts.map +1 -0
- package/dist/doctor/rules/node-rules.js +290 -0
- package/dist/doctor/rules/node-rules.js.map +1 -0
- package/dist/doctor/rules/turbo-rules.d.ts +3 -0
- package/dist/doctor/rules/turbo-rules.d.ts.map +1 -0
- package/dist/doctor/rules/turbo-rules.js +215 -0
- package/dist/doctor/rules/turbo-rules.js.map +1 -0
- package/dist/doctor/types.d.ts +87 -0
- package/dist/doctor/types.d.ts.map +1 -0
- package/dist/doctor/types.js +6 -0
- package/dist/doctor/types.js.map +1 -0
- package/dist/package.json +4 -4
- package/dist/services/ContextSyncer.d.ts +40 -0
- package/dist/services/ContextSyncer.d.ts.map +1 -0
- package/dist/services/ContextSyncer.js +219 -0
- package/dist/services/ContextSyncer.js.map +1 -0
- package/dist/services/ProjectScanner.d.ts +74 -0
- package/dist/services/ProjectScanner.d.ts.map +1 -0
- package/dist/services/ProjectScanner.js +343 -0
- package/dist/services/ProjectScanner.js.map +1 -0
- package/dist/services/ScaffoldAgent.d.ts +35 -0
- package/dist/services/ScaffoldAgent.d.ts.map +1 -0
- package/dist/services/ScaffoldAgent.js +228 -0
- package/dist/services/ScaffoldAgent.js.map +1 -0
- package/dist/tui/PlanningMode.d.ts +42 -0
- package/dist/tui/PlanningMode.d.ts.map +1 -0
- package/dist/tui/PlanningMode.js +401 -0
- package/dist/tui/PlanningMode.js.map +1 -0
- package/dist/tui/TUIClient.d.ts +20 -0
- package/dist/tui/TUIClient.d.ts.map +1 -0
- package/dist/tui/TUIClient.js +50 -0
- package/dist/tui/TUIClient.js.map +1 -0
- package/dist/types/mega-context.d.ts +118 -0
- package/dist/types/mega-context.d.ts.map +1 -0
- package/dist/types/mega-context.js +3 -0
- package/dist/types/mega-context.js.map +1 -0
- package/dist/types/tui.d.ts +29 -0
- package/dist/types/tui.d.ts.map +1 -0
- package/dist/types/tui.js +8 -0
- package/dist/types/tui.js.map +1 -0
- package/dist/types/unified-context.d.ts +102 -0
- package/dist/types/unified-context.d.ts.map +1 -0
- package/dist/types/unified-context.js +50 -0
- package/dist/types/unified-context.js.map +1 -0
- package/dist/utils/FileGenerator.d.ts +5 -0
- package/dist/utils/FileGenerator.d.ts.map +1 -1
- package/dist/utils/FileGenerator.js +48 -0
- package/dist/utils/FileGenerator.js.map +1 -1
- package/dist/utils/deepMerge.d.ts +14 -0
- package/dist/utils/deepMerge.d.ts.map +1 -0
- package/dist/utils/deepMerge.js +87 -0
- package/dist/utils/deepMerge.js.map +1 -0
- package/dist/utils/fileSystem.d.ts.map +1 -1
- package/dist/utils/fileSystem.js +32 -4
- package/dist/utils/fileSystem.js.map +1 -1
- package/package.json +24 -22
package/README.md
CHANGED
|
@@ -1,24 +1,21 @@
|
|
|
1
1
|
# mycontext-cli
|
|
2
2
|
|
|
3
|
-
**The Command-Line
|
|
3
|
+
**The Command-Line Brain for Zero-Drift Autonomous Development.**
|
|
4
4
|
|
|
5
|
-
`mycontext-cli` is your AI-powered development companion that
|
|
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
6
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
🎯 **Screenshot → Spec** - Reverse-engineer any UI into comprehensive specifications.
|
|
10
|
-
🧠 **Living Brain (Shared State)** - A single source of truth (`context.json`) that acts as the "blackboard" for all agents.
|
|
11
|
-
🤖 **Context-Aware Co-Pilot** - Agents that *read* your code before writing, ensuring non-destructive updates.
|
|
12
|
-
🛡️ **Zero-Drift Sync** - Perfect alignment between design intent, code, and documentation via the `.ALIGN` guard.
|
|
13
|
-
🚀 **Instant Setup** - Initialize Next.js projects with `shadcn/ui`, `lucide-react`, and standard error/loading states.
|
|
7
|
+
[](https://www.npmjs.com/package/mycontext-cli)
|
|
8
|
+
[](https://opensource.org/licenses/MIT)
|
|
14
9
|
|
|
15
|
-
##
|
|
16
|
-
|
|
17
|
-
MyContext implements **Antigravity ("Shared State")** architecture. Instead of fragile, direct message-passing between agents (which breaks at scale), we use a **Living Brain** (`context.json`) as a persistent state machine.
|
|
10
|
+
## ✨ Key Features
|
|
18
11
|
|
|
19
|
-
- **
|
|
20
|
-
- **
|
|
21
|
-
- **
|
|
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
|
|
22
19
|
|
|
23
20
|
---
|
|
24
21
|
|
|
@@ -37,191 +34,192 @@ npx mycontext-cli init
|
|
|
37
34
|
## 🛠️ Commands Reference
|
|
38
35
|
|
|
39
36
|
### `mycontext init`
|
|
40
|
-
|
|
37
|
+
Interactive TUI that interviews you → builds a complete MegaContext → deterministically scaffolds.
|
|
41
38
|
|
|
42
39
|
```bash
|
|
43
40
|
mycontext init
|
|
44
|
-
|
|
45
|
-
# Skip prompts (use defaults)
|
|
46
|
-
mycontext init --yes
|
|
47
41
|
```
|
|
48
42
|
|
|
49
43
|
**What it does:**
|
|
50
|
-
-
|
|
51
|
-
-
|
|
52
|
-
-
|
|
53
|
-
- Optional InstantDB initialization
|
|
54
|
-
- 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
|
|
55
47
|
|
|
56
48
|
---
|
|
57
49
|
|
|
58
|
-
### `mycontext
|
|
59
|
-
|
|
50
|
+
### `mycontext scan`
|
|
51
|
+
Walk the real file tree and compare against your planned context.
|
|
60
52
|
|
|
61
53
|
```bash
|
|
62
|
-
|
|
54
|
+
# Quick scan — file tree stats
|
|
55
|
+
mycontext scan
|
|
63
56
|
|
|
64
|
-
#
|
|
65
|
-
mycontext
|
|
66
|
-
```
|
|
57
|
+
# AI-powered assessment — drift detection + merge suggestions
|
|
58
|
+
mycontext scan --assess
|
|
67
59
|
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
- Generates detailed specifications
|
|
72
|
-
- Updates design manifest
|
|
60
|
+
# Machine-readable output
|
|
61
|
+
mycontext scan --assess --json
|
|
62
|
+
```
|
|
73
63
|
|
|
74
64
|
---
|
|
75
65
|
|
|
76
|
-
### `mycontext
|
|
77
|
-
|
|
66
|
+
### `mycontext sync` ✨ NEW
|
|
67
|
+
Autonomous self-recontextualization. Scans → assesses → deep merges context.json → LLM-generates README.
|
|
78
68
|
|
|
79
69
|
```bash
|
|
80
|
-
#
|
|
81
|
-
mycontext
|
|
70
|
+
# Full sync (context.json + README)
|
|
71
|
+
mycontext sync
|
|
82
72
|
|
|
83
|
-
#
|
|
84
|
-
mycontext
|
|
73
|
+
# Preview changes without writing
|
|
74
|
+
mycontext sync --dry-run
|
|
85
75
|
|
|
86
|
-
#
|
|
87
|
-
mycontext
|
|
88
|
-
|
|
89
|
-
# Generate sample data
|
|
90
|
-
mycontext generate sample-data
|
|
76
|
+
# Sync only context or only README
|
|
77
|
+
mycontext sync --context
|
|
78
|
+
mycontext sync --readme
|
|
91
79
|
```
|
|
92
80
|
|
|
93
|
-
**
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
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
|
|
98
86
|
|
|
99
87
|
---
|
|
100
88
|
|
|
101
|
-
### `mycontext
|
|
102
|
-
|
|
89
|
+
### `mycontext doctor` ✨ NEW
|
|
90
|
+
Diagnose and fix project issues. Identify Next.js best practices, Turborepo misconfigurations, and dead code.
|
|
103
91
|
|
|
104
92
|
```bash
|
|
105
|
-
|
|
93
|
+
# Run diagnostics
|
|
94
|
+
mycontext doctor
|
|
95
|
+
|
|
96
|
+
# Auto-fix fixable issues
|
|
97
|
+
mycontext doctor --fix
|
|
106
98
|
|
|
107
|
-
#
|
|
108
|
-
mycontext
|
|
99
|
+
# Run on a specific workspace in a monorepo
|
|
100
|
+
mycontext doctor --project apps/web
|
|
109
101
|
```
|
|
110
102
|
|
|
111
103
|
**What it checks:**
|
|
112
|
-
-
|
|
113
|
-
-
|
|
114
|
-
-
|
|
115
|
-
-
|
|
104
|
+
- **Next.js**: Root layouts, metadata, client directives, image/link usage
|
|
105
|
+
- **Turborepo**: `turbo.json`, workspace protocols, pipeline coverage
|
|
106
|
+
- **Node.js**: Lock files, `.gitignore`, engines, unused deps
|
|
107
|
+
- **Dead Code**: Unused exports, orphan files, unused components
|
|
108
|
+
|
|
109
|
+
---
|
|
110
|
+
|
|
111
|
+
### `mycontext generate`
|
|
112
|
+
Generate context files, types, and code from your specifications.
|
|
113
|
+
|
|
114
|
+
```bash
|
|
115
|
+
# Full context generation
|
|
116
|
+
mycontext generate context --full
|
|
117
|
+
|
|
118
|
+
# Generate types from schema
|
|
119
|
+
mycontext generate types --from-schema
|
|
120
|
+
|
|
121
|
+
# Generate components
|
|
122
|
+
mycontext generate components
|
|
123
|
+
```
|
|
116
124
|
|
|
117
125
|
---
|
|
118
126
|
|
|
119
127
|
### `mycontext agent`
|
|
120
|
-
|
|
128
|
+
Multi-agent task execution via the Brain blackboard pattern.
|
|
121
129
|
|
|
122
130
|
```bash
|
|
123
|
-
#
|
|
131
|
+
# Plan a feature
|
|
124
132
|
mycontext agent --plan "Add user authentication"
|
|
125
133
|
|
|
126
|
-
# Execute
|
|
134
|
+
# Execute autonomously
|
|
127
135
|
mycontext agent --execute "Implement shopping cart"
|
|
128
136
|
```
|
|
129
137
|
|
|
130
|
-
**Features:**
|
|
131
|
-
- Multi-agent orchestration (Architect, CodeGen, QA, Security)
|
|
132
|
-
- Deterministic prompt construction
|
|
133
|
-
- Context-aware code generation
|
|
134
|
-
- Built-in testing and validation
|
|
135
|
-
|
|
136
138
|
---
|
|
137
139
|
|
|
138
|
-
|
|
140
|
+
### `mycontext analyze`
|
|
141
|
+
Reverse-engineer UI from screenshots into specifications.
|
|
139
142
|
|
|
140
143
|
```bash
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
cd my-app
|
|
144
|
+
mycontext analyze screenshot.png
|
|
145
|
+
```
|
|
144
146
|
|
|
145
|
-
|
|
146
|
-
npx mycontext-cli init
|
|
147
|
+
---
|
|
147
148
|
|
|
148
|
-
|
|
149
|
-
# GitHub Models (Free, High Quality)
|
|
150
|
-
echo 'GITHUB_TOKEN=your-token' >> .mycontext/.env
|
|
149
|
+
## 🎯 Quick Start
|
|
151
150
|
|
|
152
|
-
|
|
153
|
-
|
|
151
|
+
```bash
|
|
152
|
+
# 1. Initialize (in any project directory)
|
|
153
|
+
npx mycontext-cli init
|
|
154
154
|
|
|
155
|
-
#
|
|
156
|
-
|
|
155
|
+
# 2. Configure AI (choose one — all have free tiers)
|
|
156
|
+
echo 'GEMINI_API_KEY=your-key' >> .mycontext/.env
|
|
157
|
+
# Or: GITHUB_TOKEN, OPENROUTER_API_KEY, ANTHROPIC_API_KEY, XAI_API_KEY
|
|
157
158
|
|
|
158
|
-
#
|
|
159
|
-
mycontext
|
|
159
|
+
# 3. Scan your project
|
|
160
|
+
mycontext scan --assess
|
|
160
161
|
|
|
161
|
-
#
|
|
162
|
-
mycontext
|
|
162
|
+
# 4. Auto-sync context + README
|
|
163
|
+
mycontext sync
|
|
163
164
|
```
|
|
164
165
|
|
|
165
166
|
---
|
|
166
167
|
|
|
167
|
-
## 🔧
|
|
168
|
-
|
|
169
|
-
### AI Provider Setup
|
|
168
|
+
## 🔧 AI Provider Setup
|
|
170
169
|
|
|
171
|
-
|
|
170
|
+
Configure in `.mycontext/.env` — MyContext auto-detects whichever key is present:
|
|
172
171
|
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
172
|
+
| Provider | Env Variable | Free Tier | Get Key |
|
|
173
|
+
|----------|-------------|-----------|---------|
|
|
174
|
+
| **Gemini** | `GEMINI_API_KEY` | ✅ Yes | [aistudio.google.com/apikey](https://aistudio.google.com/apikey) |
|
|
175
|
+
| **GitHub Models** | `GITHUB_TOKEN` | ✅ Yes | [github.com/settings/tokens](https://github.com/settings/tokens) |
|
|
176
|
+
| **OpenRouter** | `OPENROUTER_API_KEY` | Credits | [openrouter.ai/keys](https://openrouter.ai/keys) |
|
|
177
|
+
| **Anthropic** | `ANTHROPIC_API_KEY` | Credits | [console.anthropic.com](https://console.anthropic.com/) |
|
|
178
|
+
| **xAI (Grok)** | `XAI_API_KEY` | Credits | [x.ai](https://x.ai/) |
|
|
178
179
|
|
|
179
|
-
|
|
180
|
-
```bash
|
|
181
|
-
GEMINI_API_KEY=your_gemini_key
|
|
182
|
-
# Get key: https://aistudio.google.com/apikey
|
|
183
|
-
```
|
|
184
|
-
|
|
185
|
-
**Claude** (Best for advanced reasoning)
|
|
186
|
-
```bash
|
|
187
|
-
ANTHROPIC_API_KEY=your_claude_key
|
|
188
|
-
# Get key: https://console.anthropic.com/
|
|
189
|
-
```
|
|
190
|
-
|
|
191
|
-
**OpenAI**
|
|
192
|
-
```bash
|
|
193
|
-
OPENAI_API_KEY=your_openai_key
|
|
194
|
-
```
|
|
180
|
+
Provider fallback chain: Gemini → GitHub Models → OpenRouter → Anthropic → xAI
|
|
195
181
|
|
|
196
182
|
---
|
|
197
183
|
|
|
198
184
|
## 📁 Project Structure
|
|
199
185
|
|
|
200
|
-
After running `mycontext init
|
|
186
|
+
After running `mycontext init`:
|
|
201
187
|
|
|
202
188
|
```
|
|
203
189
|
.mycontext/
|
|
204
|
-
├── .env # AI provider
|
|
205
|
-
├── context.json # Living Brain
|
|
206
|
-
├── ALIGN # Alignment Guard
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
└── logs/ # Operation logs
|
|
190
|
+
├── .env # AI provider keys
|
|
191
|
+
├── context.json # Living Brain — primary source of truth
|
|
192
|
+
├── ALIGN # Alignment Guard — rules for AI assistants
|
|
193
|
+
└── context/ # Exported Markdown views for humans/AI
|
|
194
|
+
├── 01-prd.md
|
|
195
|
+
├── 01a-features.md
|
|
196
|
+
└── ...
|
|
212
197
|
```
|
|
213
198
|
|
|
214
199
|
---
|
|
215
200
|
|
|
216
|
-
##
|
|
201
|
+
## 🏛️ Architecture: Unified Context
|
|
202
|
+
|
|
203
|
+
`context.json` supports two schemas that coexist:
|
|
217
204
|
|
|
218
|
-
|
|
205
|
+
| Schema | Purpose | Key Fields |
|
|
206
|
+
|--------|---------|------------|
|
|
207
|
+
| **MegaContext** | Deterministic scaffolding | `database.entities`, `routing.routes`, `auth.roles`, `topLevelDesign` |
|
|
208
|
+
| **Brain** | Existing/scanned projects | `brain.narrative`, `brain.registry`, `brain.checkpoints`, `brain.memory` |
|
|
219
209
|
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
210
|
+
The `UnifiedContext` type bridges both. `getContextSummary()` extracts data from either shape. `deepMerge()` safely combines them.
|
|
211
|
+
|
|
212
|
+
---
|
|
213
|
+
|
|
214
|
+
## 🎯 Philosophy: Hard Gravity
|
|
215
|
+
|
|
216
|
+
Every project starts with a **deterministic spec**. The CLI ensures code never drifts from design intent:
|
|
217
|
+
|
|
218
|
+
1. **Interview → MegaContext** — AI-driven 100% knowledge collection
|
|
219
|
+
2. **MegaContext → Scaffold** — Deterministic generation, zero guessing
|
|
220
|
+
3. **Scan → Assess** — Continuous bidirectional drift detection
|
|
221
|
+
4. **Sync → Update** — Autonomous self-recontextualization
|
|
222
|
+
5. **Never Drift** — Living Brain maintains alignment
|
|
225
223
|
|
|
226
224
|
---
|
|
227
225
|
|
|
@@ -229,7 +227,6 @@ Every project starts with a **deterministic spec**. The CLI ensures that code ne
|
|
|
229
227
|
|
|
230
228
|
This package is part of the [MyContext Monorepo](https://github.com/farajabien/mycontext-cli).
|
|
231
229
|
|
|
232
|
-
For local development:
|
|
233
230
|
```bash
|
|
234
231
|
git clone https://github.com/farajabien/mycontext-cli.git
|
|
235
232
|
cd mycontext-cli
|
|
@@ -242,13 +239,11 @@ cd apps/cli && pnpm link --global
|
|
|
242
239
|
|
|
243
240
|
## 📄 License
|
|
244
241
|
|
|
245
|
-
MIT © MyContext
|
|
246
|
-
|
|
247
|
-
---
|
|
242
|
+
MIT © MyContext — See [LICENSE](https://github.com/farajabien/mycontext-cli/blob/main/LICENSE)
|
|
248
243
|
|
|
249
244
|
## 🔗 Links
|
|
250
245
|
|
|
251
|
-
- [
|
|
252
|
-
- [Report Issues](https://github.com/farajabien/mycontext-cli/issues)
|
|
246
|
+
- [Monorepo](https://github.com/farajabien/mycontext-cli)
|
|
253
247
|
- [npm Package](https://www.npmjs.com/package/mycontext-cli)
|
|
248
|
+
- [Report Issues](https://github.com/farajabien/mycontext-cli/issues)
|
|
254
249
|
- [Core Package (@myycontext/core)](https://www.npmjs.com/package/@myycontext/core)
|