|
| 1 | +--- |
| 2 | +id: microcli-cli-app |
| 3 | +created: 2026-03-28 |
| 4 | +modified: 2026-03-28 |
| 5 | +type: plan |
| 6 | +status: done |
| 7 | +expires: 2026-04-04 |
| 8 | +--- |
| 9 | + |
| 10 | +# Plan: microcli CLI App (new + learn commands) |
| 11 | + |
| 12 | +## Context |
| 13 | + |
| 14 | +Transform microcli into a self-contained CLI tool with two main features: |
| 15 | +- `microcli new` → Bootstrap new microapps |
| 16 | +- `microcli learn` → Learning workflow for microcli framework |
| 17 | + |
| 18 | +## Phases |
| 19 | + |
| 20 | +### Phase 1: Entry Points ✅ |
| 21 | +**Goal:** Set up dual entry points (CLI app vs library) |
| 22 | + |
| 23 | +**Deliverables:** |
| 24 | +- [x] `__main__.py` entry point for `python -m microcli` |
| 25 | +- [x] `core.main()` remains unchanged for user scripts |
| 26 | + |
| 27 | +### Phase 2: CLI App Structure ✅ |
| 28 | +**Goal:** Create the CLI app that handles `new` and `learn` |
| 29 | + |
| 30 | +**Deliverables:** |
| 31 | +- [x] `cli.py` as a microcli microapp using @command decorators |
| 32 | +- [x] `new` command: name, title, commands (positional args) |
| 33 | +- [x] `learn` command with optional --topic flag |
| 34 | + |
| 35 | +### Phase 3: Template Generator ✅ |
| 36 | +**Goal:** Generate scaffolded microapps from templates |
| 37 | + |
| 38 | +**Deliverables:** |
| 39 | +- [x] Template generator with `///script` header |
| 40 | +- [x] Module docstring with `microcli learn` prompt |
| 41 | +- [x] One `@command` per item in commands list |
| 42 | +- [x] Each command has `ok("TODO: ...")` body |
| 43 | +- [x] Extensive comments with `microcli learn <topic>` breadcrumbs |
| 44 | + |
| 45 | +### Phase 4: Learn Content ✅ |
| 46 | +**Goal:** Curated learn topics for framework education |
| 47 | + |
| 48 | +**Deliverables:** |
| 49 | +- [x] Topics: principles, parameters, ok-fail, utilities, patterns, complex-inputs, reference |
| 50 | +- [x] Each topic has rich formatted content |
| 51 | +- [x] `learn` without args lists available topics |
| 52 | +- [x] `learn --topic <name>` shows topic content |
| 53 | + |
| 54 | +### Phase 5: Integration Tests ✅ |
| 55 | +**Goal:** Verify everything works end-to-end |
| 56 | + |
| 57 | +**Deliverables:** |
| 58 | +- [x] Tests for new and learn commands |
| 59 | +- [x] Template generates valid Python |
| 60 | +- [x] Full workflow test: new → run → learn |
| 61 | + |
| 62 | +## Technical Approach |
| 63 | + |
| 64 | +### File Structure |
| 65 | +``` |
| 66 | +src/microcli/ |
| 67 | +├── __init__.py # Library exports (unchanged) |
| 68 | +├── __main__.py # Entry: python -m microcli |
| 69 | +├── core.py # Library (unchanged) |
| 70 | +├── learn.py # Auto-discover (unchanged) |
| 71 | +├── stdin.py # Stdin support (unchanged) |
| 72 | +├── cli.py # NEW: microcli app (new/learn) |
| 73 | +├── learn_content.py # NEW: Curated learn topics |
| 74 | +└── templates/ |
| 75 | + └── skeleton.py # NEW: Template generator |
| 76 | +``` |
| 77 | + |
| 78 | +### Entry Points |
| 79 | +- `python -m microcli` → `__main__.py` → `cli.main()` |
| 80 | +- `microcli` command → `cli.main()` (via pyproject.toml) |
| 81 | +- User scripts with `m.main()` → `core.main()` (unchanged!) |
| 82 | + |
| 83 | +## Success Criteria |
| 84 | + |
| 85 | +- [x] `python -m microcli --help` shows CLI help |
| 86 | +- [x] `microcli new notes "Notes" create,list` creates notes.py |
| 87 | +- [x] Generated notes.py runs: `python notes.py list` |
| 88 | +- [x] `microcli learn` lists available topics |
| 89 | +- [x] `microcli learn --topic principles` shows principles content |
| 90 | +- [x] User scripts continue to work unchanged (core.main() unchanged) |
| 91 | +- [x] 48 tests pass |
| 92 | + |
| 93 | +## Risks & Mitigations |
| 94 | + |
| 95 | +| Risk | Mitigation | |
| 96 | +|------|------------| |
| 97 | +| Breaking existing user scripts | Keep core.main() unchanged | |
| 98 | +| Template generation edge cases | Test with various inputs | |
| 99 | +| Learn content completeness | Start with essential topics, expand later | |
| 100 | + |
| 101 | +## Notes |
| 102 | + |
| 103 | +- Global `--learn` flag renamed to `--tour` to avoid conflict with `learn` command |
| 104 | +- CLI app (`cli.py`) is itself a microcli microapp using `@command` decorators |
| 105 | +- User scripts use `--tour` for auto-discovered command tours |
0 commit comments