mirror of
https://github.com/kevinveenbirkenbach/computer-playbook.git
synced 2026-11-06 02:54:26 +00:00
Reworks the REPL into a stateful shell that tracks a category path: typing a bare category name cd's into it, `/` returns to root, `..` walks one level up (chained as `../..` etc.), path tokens with slashes or a leading `..` navigate, `infinito [path]` always jumps absolute, and `ls` renders the current folder with a 🗂️/⚙️ emoji column, name, and a 30-char-truncated description (folders sorted before commands). Executable leaves (sub-packages with `__main__.py`) run instead of cd-ing into them. The prompt prints `🖥️ infinito <space-separated path>> `; the screen clears (incl. scrollback via `\033[3J`) before each command run, and the run echoes the resolved invocation in the fresh frame so the user sees what is about to execute. Splits `repl.py` (~250 lines) into focused modules: `constants.py` (sentinels), `navigation.py` (path/category resolve + prompt + normalize), `ls.py` (folder rendering + truncate), `runner.py` (subprocess dispatch + clear_screen), `banner.py` (startup banner). `repl.py` is now a thin `main()` loop with backward-compat re-exports so external consumers keep the `repl.<symbol>` surface. Mirrors the split on the test side into `test_navigation.py`, `test_runner.py`, `test_ls.py`, and a `test_repl.py` that owns only main-loop integration with a shared `_MainLoopHarness` mixin. Adds `scripts/tests/environment/11_console.sh` as a CI smoke that feeds a navigation sequence through the REPL and asserts every prompt shape plus the `ls` emoji output, so a regression in the prompt format, the path resolver, or the folder rendering is caught by the environment-test orchestrator. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
42 lines
1.2 KiB
Python
42 lines
1.2 KiB
Python
from __future__ import annotations
|
|
|
|
from cli.core.colors import Fore, Style, color_text
|
|
|
|
from .constants import (
|
|
AUTHOR,
|
|
AUTHOR_URL,
|
|
DOCS_URL,
|
|
LICENSE_NAME,
|
|
LICENSE_URL,
|
|
WEB_URL,
|
|
)
|
|
|
|
|
|
def print_banner() -> None:
|
|
print(color_text("infinito.nexus console 🦫🖥️", Fore.CYAN + Style.BRIGHT))
|
|
print(
|
|
color_text(
|
|
"Type 'exit', 'quit', or Ctrl+D to leave. Ctrl+C cancels the current line.",
|
|
Style.DIM,
|
|
)
|
|
)
|
|
print()
|
|
print(color_text(" Help: type 'help' or '<command> --help'", Fore.YELLOW))
|
|
print(
|
|
color_text(
|
|
# nocheck: project-root-import `..` in REPL nav help text, not path construction
|
|
" Nav: '<category>' enter, '/' root, '..' up, '/abs/path' or '../rel/path' to jump, 'infinito [path]' absolute, 'ls' list",
|
|
Fore.YELLOW,
|
|
)
|
|
)
|
|
print(color_text(f" Web: {WEB_URL}", Fore.YELLOW))
|
|
print(color_text(f" Docs: {DOCS_URL}", Fore.YELLOW))
|
|
print(color_text(f" Author: {AUTHOR} - {AUTHOR_URL}", Style.DIM))
|
|
print(
|
|
color_text(
|
|
f" License: {LICENSE_NAME} - {LICENSE_URL}",
|
|
Style.DIM,
|
|
)
|
|
)
|
|
print()
|