Skip to content

Commit 1967cc9

Browse files
shuvebclaude
andcommitted
Initial commit: mfbt CLI tool
Python CLI for the mfbt platform with interactive TUI mode (K9S-style), OAuth 2.1 PKCE auth, API key management, and subcommands for managing projects, phases, modules, features, and implementations. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
0 parents  commit 1967cc9

File tree

99 files changed

+57295
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

99 files changed

+57295
-0
lines changed

.github/workflows/ci.yml

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
branches: [main]
8+
9+
jobs:
10+
quality:
11+
runs-on: ubuntu-latest
12+
strategy:
13+
matrix:
14+
python-version: ["3.10", "3.11", "3.12"]
15+
steps:
16+
- uses: actions/checkout@v4
17+
18+
- uses: actions/setup-python@v5
19+
with:
20+
python-version: ${{ matrix.python-version }}
21+
22+
- name: Install uv
23+
run: pip install uv
24+
25+
- name: Create venv and install dependencies
26+
run: |
27+
uv venv
28+
uv pip install -e . -r requirements-dev.txt
29+
30+
- name: Lint with ruff
31+
run: uv run ruff check src/ tests/
32+
33+
- name: Type check with mypy
34+
run: uv run mypy src/mfbt/
35+
36+
- name: Run tests with coverage
37+
run: >
38+
uv run pytest tests/
39+
--cov=mfbt
40+
--cov-report=term-missing
41+
--cov-fail-under=75
42+
-q

.gitignore

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# mfbt config
2+
.mfbt/
3+
4+
# Python
5+
__pycache__/
6+
*.py[cod]
7+
*$py.class
8+
9+
# Build/dist
10+
dist/
11+
build/
12+
*.egg-info/
13+
14+
# Virtual environments
15+
.venv/
16+
venv/
17+
18+
# Tool caches
19+
.pytest_cache/
20+
.mypy_cache/
21+
.ruff_cache/
22+
23+
# OS
24+
.DS_Store

.pre-commit-config.yaml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
repos:
2+
- repo: https://github.com/psf/black
3+
rev: "24.4.2"
4+
hooks:
5+
- id: black
6+
language_version: python3
7+
8+
- repo: https://github.com/astral-sh/ruff-pre-commit
9+
rev: "v0.4.4"
10+
hooks:
11+
- id: ruff
12+
args: ["--fix"]
13+
14+
- repo: https://github.com/pre-commit/mirrors-mypy
15+
rev: "v1.10.0"
16+
hooks:
17+
- id: mypy
18+
additional_dependencies: []
19+
args: ["--config-file=pyproject.toml"]

CLAUDE.md

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
# CLAUDE.md - mfbt CLI
2+
3+
## Project Overview
4+
5+
**mfbt CLI** is a Python-based CLI tool for the mfbt platform, targeting publication to PyPI. It provides both an interactive TUI mode (K9S-style) and traditional subcommands for managing mfbt projects.
6+
7+
- **Language:** Python 3.10+ (uses modern features: pattern matching, improved type hints)
8+
- **Backend:** Integrates with mfbt REST API (`{BASE_URL}/api/v1/`)
9+
- **Auth:** OAuth 2.1 with PKCE (1hr access tokens, 30-day refresh tokens), plus API key management (`mfbtsk-{uuid}`, passed as `Authorization: Bearer {key}`)
10+
- **Config:** `.mfbt` directory stores auth tokens and project configuration
11+
12+
## API Specification
13+
14+
The file `openapi.json` in the project root contains the full OpenAPI spec for the mfbt backend. **Do NOT read this file in full** — it is very large. Instead, use Grep or search tools to find specific endpoints, schemas, or parameters as needed.
15+
16+
## Architecture
17+
18+
### Core Systems
19+
20+
1. **Authentication & Configuration** — Browser-based OAuth flow, token refresh/session management, API key support, project selection post-auth
21+
2. **Interactive TUI Mode** — Launched when CLI runs without subcommands; K9S-style keyboard-driven navigation with real-time status updates
22+
3. **Subcommands**`status`, `next`, `modules`, `features`, plus commands for brainstorming phases, implementations, and jobs. Consistent output formatting (table, JSON, etc.)
23+
4. **API Integration Layer** — REST client for all mfbt endpoints, paginated responses (`{items, total, page, page_size, total_pages}`), error handling (404 for unauthorized, 402 for token limits), job polling for async operations, WebSocket support for real-time job status
24+
5. **API Key Management** — CRUD via `/api/v1/users/me/api-keys`
25+
26+
### Key API Endpoints
27+
28+
- Projects CRUD
29+
- Brainstorming phases
30+
- Modules, features, and implementations
31+
- Job monitoring: `GET /api/v1/jobs/{job_id}`
32+
- Thread comments
33+
- MCP config retrieval: `GET /api/v1/projects/{id}/mcp-config`
34+
- API key management: `/api/v1/users/me/api-keys`
35+
36+
### Constraints
37+
38+
- Must work with existing mfbt FastAPI backend
39+
- Support both UUIDs and short URL identifiers
40+
- Handle ISO 8601 UTC timestamps
41+
- Graceful degradation when token limits reached (HTTP 402)
42+
43+
## MFBT MCP Server (Virtual Filesystem)
44+
45+
This project uses the **mfbt MCP server**, which exposes a virtual filesystem (VFS) for navigating mfbt project data. **Always call `readMeFirst`** at the start of a session to get the full VFS guide, available tools, and recommended workflow.
46+
47+
### Key MCP Concepts
48+
49+
- The VFS exposes project phases, modules, features, and implementations as a navigable filesystem
50+
- Use UNIX-like commands: `ls`, `cat`, `tree`, `find`, `grep`, `head`, `tail`
51+
- Smart metadata on directories guides what to work on next (progress %, next feature, completion status)
52+
- Two feature sources: `system-generated/` (AI-created from brainstorming) and `user-defined/` (manually created or imported)
53+
54+
### MCP VFS Structure
55+
56+
```
57+
/
58+
├── phases/
59+
│ ├── system-generated/{phase}/
60+
│ │ ├── phase-spec/ # full.md, summary.md, by-section/
61+
│ │ ├── phase-prompt-plan/ # full.md, by-section/
62+
│ │ └── features/{module}/{feature}/
63+
│ │ ├── implementations/{impl}/
64+
│ │ │ ├── spec.md # WHAT to build
65+
│ │ │ ├── prompt_plan.md # HOW to build
66+
│ │ │ └── notes.md # Writable learnings
67+
│ │ └── conversations/conversations.md
68+
│ └── user-defined/features/{module}/{feature}/
69+
│ └── (same structure as above)
70+
├── project-info/team-info.json
71+
├── system-info/users/available-users-list.csv
72+
└── for-coding-agents/
73+
├── agents.md # Grounding context (read at session start)
74+
└── mfbt-usage-guide/ # Workflow guides
75+
```
76+
77+
### MCP Recommended Workflow
78+
79+
1. `cat /for-coding-agents/agents.md --branch_name='your-branch'` — grounding context
80+
2. `ls /``ls /phases/` → drill into phases, modules, features
81+
3. Read `spec.md` (what to build) and `prompt_plan.md` (how to build)
82+
4. `setMetadataValueForKey .../features/{module}/{feature}/ in_progress true` — mark as started
83+
5. Implement the feature
84+
6. `write .../implementations/{impl}/notes.md '<learnings>'` — document what you learned
85+
7. `setMetadataValueForKey .../implementations/{impl}/ is_complete true` — mark done (auto-syncs feature status)
86+
87+
### MCP Tips
88+
89+
- Include `coding_agent_name: "claude_code"` and `branch_name` in tool calls
90+
- Use `summary.md` for quick spec overviews; `by-section/` for large specs
91+
- Focus on `must_have` features first, then `important`, then `optional`
92+
- `notes.md` auto-feeds into `agents.md` grounding — document architectural decisions and gotchas
93+
- Use `grep` to search across specs and prompt plans
94+
- For team communication (posting comments), see `/for-coding-agents/mfbt-usage-guide/`
95+
- To update status: `in_progress` on features when starting, `is_complete` on implementations when done

README.md

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
# mfbt CLI
2+
3+
Command-line tool for the mfbt platform. Provides both an interactive TUI mode and traditional subcommands for managing mfbt projects.
4+
5+
## Requirements
6+
7+
- Python 3.10+
8+
9+
## Installation
10+
11+
```bash
12+
pip install mfbt-cli
13+
```
14+
15+
## Development Setup
16+
17+
```bash
18+
# Clone the repository
19+
git clone <repo-url>
20+
cd mfbt-cli
21+
22+
# Create a virtual environment
23+
python -m venv .venv
24+
source .venv/bin/activate # Unix
25+
# .venv\Scripts\activate # Windows
26+
27+
# Install in editable mode with dev dependencies
28+
pip install -e .
29+
pip install -r requirements-dev.txt
30+
31+
# Run tests
32+
pytest tests/ -v
33+
34+
# Code quality
35+
black --check src/ tests/
36+
ruff check src/ tests/
37+
mypy src/
38+
```
39+
40+
## Usage
41+
42+
```bash
43+
# Show version
44+
mfbt --version
45+
46+
# Run with verbose output
47+
mfbt -v
48+
mfbt -vv # debug
49+
mfbt -vvv # trace
50+
```

SECURITY.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# Security Policy
2+
3+
## Supported Versions
4+
5+
| Version | Supported |
6+
| ------- | --------- |
7+
| 0.1.x | Yes |
8+
9+
## Reporting a Vulnerability
10+
11+
If you discover a security vulnerability, please report it responsibly:
12+
13+
1. **Do not** open a public issue.
14+
2. Email security details to the project maintainers.
15+
3. Include steps to reproduce, impact assessment, and any suggested fixes.
16+
17+
We will acknowledge receipt within 48 hours and aim to provide a fix within 7 days for critical issues.
18+
19+
## Scope
20+
21+
- Authentication token storage and handling
22+
- API key management
23+
- File permission management for `.mfbt/` directory
24+
- Any data transmission to/from the mfbt API

0 commit comments

Comments
 (0)