mycontext-cli 4.2.0 → 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.
- package/README.md +108 -135
- package/dist/README.md +108 -135
- package/dist/cli.js +72 -0
- package/dist/cli.js.map +1 -1
- package/dist/commands/init.d.ts.map +1 -1
- package/dist/commands/init.js +36 -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/package.json +3 -3
- 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 +23 -21
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.
|
|
14
|
-
|
|
15
|
-
## 🤖 Scalable Agent Teams Architecture
|
|
7
|
+
[](https://www.npmjs.com/package/mycontext-cli)
|
|
8
|
+
[](https://opensource.org/licenses/MIT)
|
|
16
9
|
|
|
17
|
-
|
|
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,170 @@ 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
|
|
82
|
-
|
|
83
|
-
# Generate specific components
|
|
84
|
-
mycontext generate components
|
|
70
|
+
# Full sync (context.json + README)
|
|
71
|
+
mycontext sync
|
|
85
72
|
|
|
86
|
-
#
|
|
87
|
-
mycontext
|
|
73
|
+
# Preview changes without writing
|
|
74
|
+
mycontext sync --dry-run
|
|
88
75
|
|
|
89
|
-
#
|
|
90
|
-
mycontext
|
|
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 generate`
|
|
90
|
+
Generate context files, types, and code from your specifications.
|
|
103
91
|
|
|
104
92
|
```bash
|
|
105
|
-
|
|
93
|
+
# Full context generation
|
|
94
|
+
mycontext generate context --full
|
|
106
95
|
|
|
107
|
-
#
|
|
108
|
-
mycontext
|
|
109
|
-
```
|
|
96
|
+
# Generate types from schema
|
|
97
|
+
mycontext generate types --from-schema
|
|
110
98
|
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
- Missing dependencies
|
|
115
|
-
- Configuration issues
|
|
99
|
+
# Generate components
|
|
100
|
+
mycontext generate components
|
|
101
|
+
```
|
|
116
102
|
|
|
117
103
|
---
|
|
118
104
|
|
|
119
105
|
### `mycontext agent`
|
|
120
|
-
|
|
106
|
+
Multi-agent task execution via the Brain blackboard pattern.
|
|
121
107
|
|
|
122
108
|
```bash
|
|
123
|
-
#
|
|
109
|
+
# Plan a feature
|
|
124
110
|
mycontext agent --plan "Add user authentication"
|
|
125
111
|
|
|
126
|
-
# Execute
|
|
112
|
+
# Execute autonomously
|
|
127
113
|
mycontext agent --execute "Implement shopping cart"
|
|
128
114
|
```
|
|
129
115
|
|
|
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
116
|
---
|
|
137
117
|
|
|
138
|
-
|
|
118
|
+
### `mycontext analyze`
|
|
119
|
+
Reverse-engineer UI from screenshots into specifications.
|
|
139
120
|
|
|
140
121
|
```bash
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
cd my-app
|
|
122
|
+
mycontext analyze screenshot.png
|
|
123
|
+
```
|
|
144
124
|
|
|
145
|
-
|
|
146
|
-
npx mycontext-cli init
|
|
125
|
+
---
|
|
147
126
|
|
|
148
|
-
|
|
149
|
-
# GitHub Models (Free, High Quality)
|
|
150
|
-
echo 'GITHUB_TOKEN=your-token' >> .mycontext/.env
|
|
127
|
+
## 🎯 Quick Start
|
|
151
128
|
|
|
152
|
-
|
|
153
|
-
|
|
129
|
+
```bash
|
|
130
|
+
# 1. Initialize (in any project directory)
|
|
131
|
+
npx mycontext-cli init
|
|
154
132
|
|
|
155
|
-
#
|
|
156
|
-
|
|
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
|
|
157
136
|
|
|
158
|
-
#
|
|
159
|
-
mycontext
|
|
137
|
+
# 3. Scan your project
|
|
138
|
+
mycontext scan --assess
|
|
160
139
|
|
|
161
|
-
#
|
|
162
|
-
mycontext
|
|
140
|
+
# 4. Auto-sync context + README
|
|
141
|
+
mycontext sync
|
|
163
142
|
```
|
|
164
143
|
|
|
165
144
|
---
|
|
166
145
|
|
|
167
|
-
## 🔧
|
|
168
|
-
|
|
169
|
-
### AI Provider Setup
|
|
146
|
+
## 🔧 AI Provider Setup
|
|
170
147
|
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
**GitHub Models** (Recommended - Free & High Quality)
|
|
174
|
-
```bash
|
|
175
|
-
GITHUB_TOKEN=ghp_your_token_here
|
|
176
|
-
# Get token: https://github.com/settings/tokens
|
|
177
|
-
```
|
|
148
|
+
Configure in `.mycontext/.env` — MyContext auto-detects whichever key is present:
|
|
178
149
|
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
GEMINI_API_KEY
|
|
182
|
-
|
|
183
|
-
|
|
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/) |
|
|
184
157
|
|
|
185
|
-
|
|
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
|
-
```
|
|
158
|
+
Provider fallback chain: Gemini → GitHub Models → OpenRouter → Anthropic → xAI
|
|
195
159
|
|
|
196
160
|
---
|
|
197
161
|
|
|
198
162
|
## 📁 Project Structure
|
|
199
163
|
|
|
200
|
-
After running `mycontext init
|
|
164
|
+
After running `mycontext init`:
|
|
201
165
|
|
|
202
166
|
```
|
|
203
167
|
.mycontext/
|
|
204
|
-
├── .env # AI provider
|
|
205
|
-
├── context.json # Living Brain
|
|
206
|
-
├── ALIGN # Alignment Guard
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
└── 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
|
+
└── ...
|
|
212
175
|
```
|
|
213
176
|
|
|
214
177
|
---
|
|
215
178
|
|
|
216
|
-
##
|
|
179
|
+
## 🏛️ Architecture: Unified Context
|
|
180
|
+
|
|
181
|
+
`context.json` supports two schemas that coexist:
|
|
217
182
|
|
|
218
|
-
|
|
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` |
|
|
219
187
|
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
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
|
|
225
201
|
|
|
226
202
|
---
|
|
227
203
|
|
|
@@ -229,7 +205,6 @@ Every project starts with a **deterministic spec**. The CLI ensures that code ne
|
|
|
229
205
|
|
|
230
206
|
This package is part of the [MyContext Monorepo](https://github.com/farajabien/mycontext-cli).
|
|
231
207
|
|
|
232
|
-
For local development:
|
|
233
208
|
```bash
|
|
234
209
|
git clone https://github.com/farajabien/mycontext-cli.git
|
|
235
210
|
cd mycontext-cli
|
|
@@ -242,13 +217,11 @@ cd apps/cli && pnpm link --global
|
|
|
242
217
|
|
|
243
218
|
## 📄 License
|
|
244
219
|
|
|
245
|
-
MIT © MyContext
|
|
246
|
-
|
|
247
|
-
---
|
|
220
|
+
MIT © MyContext — See [LICENSE](https://github.com/farajabien/mycontext-cli/blob/main/LICENSE)
|
|
248
221
|
|
|
249
222
|
## 🔗 Links
|
|
250
223
|
|
|
251
|
-
- [
|
|
252
|
-
- [Report Issues](https://github.com/farajabien/mycontext-cli/issues)
|
|
224
|
+
- [Monorepo](https://github.com/farajabien/mycontext-cli)
|
|
253
225
|
- [npm Package](https://www.npmjs.com/package/mycontext-cli)
|
|
226
|
+
- [Report Issues](https://github.com/farajabien/mycontext-cli/issues)
|
|
254
227
|
- [Core Package (@myycontext/core)](https://www.npmjs.com/package/@myycontext/core)
|