# mycontext-cli

> The Conversational Specification & Implementation Agent for AI-Native Development.  
> Design features, maintain a **Living Brain**, and drive your entire codebase with a single interactive terminal cockpit.

[![npm version](https://img.shields.io/npm/v/mycontext-cli)](https://www.npmjs.com/package/mycontext-cli)
[![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](LICENSE)

---

## What is MyContext?

MyContext treats your project specifications as a **Living Brain** — a structured JSON document (`.mycontext/context.json`) that acts as the single source of truth for your app's goals, features, components, and design system. 

Instead of maintaining static, out-of-date Markdown files or writing complex CLI commands, you interact directly with an autonomous **Specification & Implementation Agent Cockpit** in your terminal. The agent parses your requests, updates the Living Brain with structured JSON deltas, and automatically synchs and renders them back to clean, read-only Markdown specs (`requirements.md`, `design.md`, and `tasks.md`).

---

## Installation

Install MyContext globally on your machine:

```bash
npm install -g mycontext-cli
# or
pnpm add -g mycontext-cli
```

Verify the installation:

```bash
mycontext --version
```

---

## Quick Start (Conversational Cockpit)

You no longer need to remember dozens of complex CLI flags. Just run `mycontext` in your project folder to boot the guided agent terminal:

```bash
# 1. Navigate to your project folder (or an empty directory)
cd my-app

# 2. Launch the MyContext Agent Cockpit
mycontext
```

### What happens next?

1. **Setup Mode (New Projects)**: If run in a fresh folder, MyContext launches a beautiful guided setup—assisting you with project scope, setting up LLM provider credentials, and seeding your initial Living Brain structure.
2. **Agent Chat Mode**: Immediately boots you into an interactive terminal chat cockpit. You can converse directly with the Specification Agent:
   - *"Design a user profile settings page with light/dark theme toggles."*
   - *"Create an implementation checklist for authentication."*
   - *"Execute tasks TASK-PAY-01 and TASK-PAY-02 to generate the components."*

---

## Core Concepts

| Concept | What it is |
|---|---|
| **Living Brain** | `.mycontext/context.json` — the central, single source of truth for your application. |
| **Agent Chat Cockpit** | A premium, interactive terminal shell (`TUIShell`) for conversational, spec-driven coding. |
| **Self-Rendering Specs** | JSON delta specs automatically output clean Markdown to `.mycontext/specs/[feature-id]/` during sync cycles. |
| **EARS Requirements** | Easy Approach to Requirements Syntax for deterministic, testable spec acceptance criteria. |
| **Sub-agent Workers** | Specialized AI executors (`CodeGenSubAgent`) spawned by the cockpit to build high-fidelity code. |
| **Circuit Breaker** | Integrated resilience system that remembers and recovers from exhausted AI models. |
| **Monorepo Scoper** | Smart scanning engine that maintains dependency boundaries across multi-app projects. |

---

## Environment Variables

MyContext loads `.env` files from your project automatically. Ensure your preferred AI provider keys are set:

| Variable | Description |
|---|---|
| `ANTHROPIC_API_KEY` | Anthropic Claude API key |
| `OPENAI_API_KEY` | OpenAI API key |
| `XAI_API_KEY` | xAI (Grok) API key |
| `MYCONTEXT_API_KEY` | MyContext cloud service key |
| `INSTANTDB_APP_ID` | InstantDB application ID |

Loaded in order (first match wins):  
`.mycontext/.env.local` → `.mycontext/.env` → `.env.local` → `.env`

---

## Project Structure

All project configuration and rendered specifications live in `.mycontext/`:

```
.mycontext/
├── context.json            ← Living Brain (source of truth)
├── .env.local              ← Local secrets (git-ignored)
└── specs/                  ← Auto-rendered markdown specifications
    └── [feature-id]/
        ├── requirements.md ← EARS requirements and glossary
        ├── design.md       ← Component mappings and correctness properties
        └── tasks.md        ← Live implementation checklist and tasks
```

---

## Links

- [Issues](https://github.com/farajabien/mycontext-cli/issues)
- [npm](https://www.npmjs.com/package/mycontext-cli)

---

*Built with MyContext — spec-driven development for the AI era.*
