--- name: linux-post-install description: Use when working on the Linux_post_install repo — creating, modifying, or fixing pos CLI tools (bin/pos-*, install.sh, features/, apps/, lib/, systemd/, completions/), regenerating docs via make gen, or running the make check / make lint / make test gates. Front-loads the # POS: header system, the pos tool model, the doc-authority order (templates > DEV.md > AGENTS.md > code), the definition of done, and the test conventions. --- # Linux_post_install — Toolkit Operations Operational playbook for changing the Linux_post_install repo (Debian/Ubuntu bootstrap + homelab toolkit, Bash). Read `DOC/AGENT_Context_Project.md` first for any non-trivial task — it opens with a **Document Map** (auto-generated line ranges) to jump straight to the relevant section. For day-to-day *usage* docs see `DOC/HOWTO.md`; for the `pos` CLI reference see `DOC/POS.md`. ## Repo shape - `bin/pos--` — tools (45 of them); category-less `bin/pos-` for dispatcher/dev-level (`pos-config`, `pos-tree`). Legacy `bin/wr-*`, `mp3`, `mp4`, `vbox`, `ssh-load-all` are thin forwarders — keep them that way. - `lib/` — shared libraries: `common.sh` (run/spawn/err/warn, `ensure_user_bus`), `registry.sh` (POS_* header query API — consumers source it, never re-implement sed/grep), `menu-lib.sh` (`menu_ask_value`, `--allow-empty`), `jq-seam.sh` (stub-friendly jq), `config.sh` (env files, `pos config` scopes), `share-lib.sh`, `usb-lib.sh`, `ai-lib.sh` (use the `llamafile` seam in tests). - `features/`, `apps/`, `templates/` (pos-tool.sh, app.sh, feature.sh — starting points for new files), `systemd/`, `completions/pos.bash` (gen output), `tests/` (suite, see below), `x64_bin/`+`arm64_bin/` (prebuilt hotspot binaries), `scripts/` (gen-docs, check-sync, lint-conventions, ci-status), `Makefile` (check/gen/lint/test/hook), `.gitea/workflows/lint.yml` (CI). - Gen blocks `GEN:START`/`GEN:END` (AGENT_Context filetable/tree/dispatch/selfcontained/docmap + `completions/pos.bash`) are `make gen` output — never hand-edit. ## Tool model - Format: shebang → `set -euo pipefail` → `# POS: ` header (missing header hard-fails `make gen`) → `# POS_FLAGS:` / `# POS_SUBCMDS:` / `# POS_CONFIG:` / `# POS_DEPS:` / `# POS_EXAMPLES:` headers → `command -v` deps guards **before** `-h|--help` dispatch → case-based help. - File must be executable (`100755`) and run standalone from `/usr/local/bin` after install (source `lib/common.sh` via `$(dirname "$0")/../lib/common.sh` fallback chain). - New tools are auto-discovered; `make gen` only uses the text after the first `— ` in the header. - Stdin readers must be added to `INTERACTIVE_CMDS` in `bin/pos` or the logging `tee` pipe hangs/swallows prompts. - Deps: apt → `PACKAGES` array in `preinstall.sh`; non-apt/manual installers → `command -v || err` guard inside the tool. Secrets never committed; runtime config `~/.config/linux_post_install/.env` (chmod 600), env-var precedence. - Entertainment plugins (`entertainment/`) must NOT source `lib/common.sh` (stdout is the Telegram message); markers `# POS_PLUGIN:` + `# POS_KEYS:`. - ScaleTail compose is a git submodule — `git submodule update --init` before `pos docker compose *`. - Generators must be byte-order deterministic (`LC_ALL=C`, sort) or CI `git diff --exit-code` trips. ## Doc authority (MAINTENANCE.md Phase 0) 1. `templates/*.sh` — codified current convention; required starting point for new files (`cp templates/pos-tool.sh bin/pos--`). 2. `DOC/DEV.md` — convention detail, checklists (wins on detail). 3. `AGENTS.md` — operational/process facts (wins on process). 4. Code + `# POS:` headers — ground truth for behavior and GEN blocks. Drift in POS/HOWTO/README/SCRIPTS/SYSTEMD/APPS docs is a doc bug — fix the doc. ## Definition of done After touching `bin/pos-*` (or anything structural): ```bash make gen # regenerates gen blocks + completions make gen # run twice — must be byte-idempotent make check # self-consistency: bash -n + exec bits + doc-sync + dispatch smoke make lint # convention gate — must end "0 FAIL, 0 WARN" make test # full suite (18 files / 416 checks) unless tests/README.md says otherwise ``` Also: `bash -n ` for new/edited scripts, `git diff --check`, CI gate (`.gitea/workflows/lint.yml`, job `gates`) runs the same four commands on push to main and tags `ci-ok/`; query with `scripts/ci-status.sh [--wait] []`. ## Test conventions (`tests/`) - Suite lives in `tests/`; run standalone after suite load: `test_run