|
| 1 | +# cli |
| 2 | + |
| 3 | +Shell-layer extensions for the LazyOwn cmd2 CLI. Every file here plugs into |
| 4 | +`LazyOwnShell` without touching the 27k-line `lazyown.py` core directly. The |
| 5 | +layer follows strict Dependency Inversion: each module depends on small |
| 6 | +`typing.Protocol` interfaces rather than on the concrete shell class. |
| 7 | + |
| 8 | +## Files |
| 9 | + |
| 10 | +| File | Purpose | |
| 11 | +|------|---------| |
| 12 | +| `wizard.py` | Guided first-run setup. Walks the operator through rhost, lhost, domain, device, os_id, api_key, and SecLists paths. Auto-detects lhost from the routing table. Zero imports from `lazyown.py` or `lazyc2.py`. | |
| 13 | +| `aliases.py` | Dynamic alias resolver. Alias templates keep `{rhost}` / `{lhost}` placeholders and are rendered against `self.params` at execution time. `DynamicAliasResolver` + `cli/aliases.yaml` drive this. | |
| 14 | +| `aliases.yaml` | Declarative alias definitions consumed by `aliases.py`. | |
| 15 | +| `graph_advisor.py` | Reads `graphify-out/graph_lazyown.json` and answers three queries: fuzzy node search, graph neighbour walk, and next-step recommendation weighted by recent activity. Caches by `(path, mtime)`. | |
| 16 | +| `reactive_hints.py` | `register_postcmd_hook` callback. After every `do_*` fires, prints one dim line of graph-driven next-step suggestions. Controlled by `enable_inline_hints` in `payload.json`. | |
| 17 | +| `dashboard_tui.py` | Full-screen Textual TUI dashboard. Launched by the `dashboard` CLI command. Refreshes every 5 seconds. Reads `payload.json`, `sessions/world_model.json`, `sessions/tasks.json`, session CSV, and credential files. | |
| 18 | +| `cli_enhancements.py` | Fuzzy command finder (`fz`), interactive parameter form (`form`), live scan tail (`status_tail`), log grep (`grep_log`), hot addon reloader (`reload_addons`), and payload-aware Tab completer. | |
| 19 | +| `fuzzy_picker.py` | Curses-driven fuzzy dropdown anchored at the bottom of the terminal. Opens on Tab when two or more completions exist. Navigation: arrow keys, Page Up/Down, Backspace to refine, Enter or Tab to insert. | |
| 20 | +| `palette.py` | Phase-aware command palette. Reads the command index and filters by engagement phase. | |
| 21 | +| `palette_command.py` | cmd2 command and Tab-completer for the `palette` verb. | |
| 22 | +| `palette_graph.py` | Graph-backed palette scoring. Merges fuzzy text rank with graph centrality. | |
| 23 | +| `palette_telemetry.py` | Records palette usage to improve future ranking. | |
| 24 | +| `banner_config.py` | Powerlevel10k-style prompt segment wizard. Manages the neon-box prompt configuration stored in `payload.json`. | |
| 25 | +| `exploit_advisor.py` | Suggests exploits based on discovered service versions. Backed by the parquet knowledge bases. | |
| 26 | +| `engagement_hooks.py` | Pre/post-command hooks that update `sessions/world_model.json` after each command. | |
| 27 | +| `ops_commands.py` | Operational commands loaded as a cmd2 `CommandSet`. | |
| 28 | +| `protips.py` | Context-sensitive tips printed below the prompt. | |
| 29 | +| `registry.py` | Central registry of CLI extensions. Used by `lazyown.py` to auto-discover and wire command sets. | |
| 30 | +| `show.py` | Display helpers for tabular output inside the shell. | |
| 31 | +| `assign.py` | `assign` and `set` command logic extracted for reuse. | |
| 32 | +| `command_index.json` | Pre-built index of every `do_*` command, alias, addon, and plugin. Rebuilt by `scripts/build_command_index.py`. | |
| 33 | +| `commands/` | cmd2 `CommandSet` subpackage. See `commands/README.md`. | |
| 34 | + |
| 35 | +## Design rules |
| 36 | + |
| 37 | +- No file in `cli/` may import `lazyown.py` or `lazyc2.py`. |
| 38 | +- Output goes through `rich.console.Console`, never raw `print()`, so ANSI |
| 39 | + handling is correct on all terminals and piped output. |
| 40 | +- Graph-dependent features (`reactive_hints`, `graph_advisor`, `palette_graph`) |
| 41 | + degrade silently when `graphify-out/graph_lazyown.json` is absent — no |
| 42 | + error, no output. |
| 43 | +- `wizard.py` takes a `params: dict` and a `save: Callable` injected by the |
| 44 | + caller. It never reads `payload.json` directly. |
| 45 | + |
| 46 | +## Rebuild the command index |
| 47 | + |
| 48 | +```bash |
| 49 | +python scripts/build_command_index.py |
| 50 | +``` |
| 51 | + |
| 52 | +Run this after adding a new `do_*` command, alias, addon, or plugin so Tab |
| 53 | +completion and `fz` reflect the change immediately. |
0 commit comments