mirror of
https://github.com/kevinveenbirkenbach/computer-playbook.git
synced 2026-11-08 11:46:35 +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>
61 lines
1.8 KiB
Bash
Executable File
61 lines
1.8 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# Smoke-test the interactive console REPL end-to-end: prompt format,
|
|
# stateful cd / home / return / `infinito` jump, relative-then-absolute
|
|
# command resolve, and executable-leaf-runs-instead-of-cd. Runs `python
|
|
# -m cli.console` with a scripted stdin and asserts the prompt sequence
|
|
# the REPL produced.
|
|
set -euo pipefail
|
|
|
|
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
# shellcheck source=scripts/tests/environment/utils/common.sh
|
|
source "${SCRIPT_DIR}/utils/common.sh"
|
|
|
|
cd "${REPO_ROOT}"
|
|
|
|
log_file="$(mktemp -t infinito-console-smoke.XXXXXX)"
|
|
trap 'rm -f "${log_file}"' EXIT
|
|
|
|
# Feed a navigation sequence covering every entry point:
|
|
# - bare-category cd : administration / meta
|
|
# - infinito alone : jumps to root
|
|
# - infinito <path> : absolute jump even from a nested cwd
|
|
# - / and .. : root and up-one
|
|
# - /abs/path : absolute path nav with slashes
|
|
# - ../rel/path : relative path nav with leading dotdot
|
|
printf '%s\n' \
|
|
'ls' \
|
|
'administration' \
|
|
'ls' \
|
|
'infinito meta' \
|
|
'..' \
|
|
'/administration/deploy' \
|
|
'../..' \
|
|
'infinito administration' \
|
|
'../meta' \
|
|
'/' \
|
|
'exit' |
|
|
"${PYTHON}" -m cli.console \
|
|
>"${log_file}" 2>&1 || true
|
|
|
|
assert_log_contains() {
|
|
local needle="${1}"
|
|
if ! grep -qF -- "${needle}" "${log_file}"; then
|
|
echo "[FAIL] console output missing: ${needle}" >&2
|
|
echo "--- captured console output ---" >&2
|
|
cat "${log_file}" >&2
|
|
exit 1
|
|
fi
|
|
echo "[OK] console output contains: ${needle}"
|
|
}
|
|
|
|
assert_log_contains "infinito> "
|
|
assert_log_contains "infinito administration> "
|
|
assert_log_contains "infinito meta> "
|
|
assert_log_contains "infinito administration deploy> "
|
|
assert_log_contains "🗂️"
|
|
assert_log_contains "⚙️"
|
|
assert_log_contains "administration"
|
|
assert_log_contains "deploy"
|
|
|
|
echo "Console smoke test passed."
|