feat: preflight - prerequisites checked and tool paths recorded before wikitool runs; launcher refuses without it (#151, POSIX half)
CI / verify (push) Successful in 2m18s
Release / release (push) Successful in 36s

Files changed:
- .claude/settings.json
- .gitea/workflows/ci.yml
- .gitea/workflows/nightly.yml
- .gitea/workflows/release.yml
- .gitea/workflows/tracker-live.yml
- .github/hooks/wiki-trace.json
- .gitignore
- .vibe/hooks.toml
- AGENTS.md
- CHANGES.md
- EVALS.md
- INSTALL.md
- README.md
- VERSION
- instructions/bootstrap.md
- instructions/preflight.md
- instructions/setup-instance.md
- instructions/upgrade-instance.md
- tools/CONTRACT.md
- tools/README.md
- tools/chemenu/cli.py
- tools/chemenu/commands/dist_cmd.py
- tools/chemenu/commands/docs_verify.py
- tools/chemenu/commands/doctor.py
- tools/chemenu/commands/git_publish.py
- tools/chemenu/commands/migrate_cmd.py
- tools/chemenu/config.py
- tools/chemenu/corpus_cache.py
- tools/chemenu/prerequisites.py
- tools/chemenu/search/ripgrep.py
- tools/chemenu/tests/conftest.py
- tools/chemenu/tests/test_dist_upgrade.py
- tools/chemenu/tests/test_doctor.py
- tools/chemenu/tests/test_preflight.py
- tools/chemenu/toolpaths.py
- tools/preflight.sh
- tools/prerequisites.txt
- tools/run_wikitool.py
- tools/trace-hook
- tools/wikitool
This commit is contained in:
torben committed 2026-10-01 05:52:55 +02:00
1 parent 5a731729f6
commit e4b2b6d9b1
40 files changed
+1849 -125

No files matched your search

+39 -17
View File
@@ -1,25 +1,47 @@
#!/usr/bin/env bash
# Entry point for the wikitool CLI. Activates the local venv and runs the
# chemenu package as a module so agents can invoke it via a stable path:
#!/bin/sh
# Entry point for the wikitool CLI, so agents and people invoke it through one
# stable path on every platform:
#
# tools/wikitool <command> [options]
#
# Setup (one time):
# cd tools
# python3 -m venv .venv
# .venv/bin/pip install -r requirements.txt
set -euo pipefail
DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
# This is the POSIX half - Linux, macOS and Git Bash on Windows. PowerShell 7
# resolves the same string to tools/wikitool.ps1 first.
#
# Nothing here sets up an environment. tools/preflight.sh does that, once per
# checkout and again after every stack update: it records the tool paths in
# .wikitool-tools.json and creates tools/.venv. Until it has passed, this script
# stops with exit 42 and names it - the preflight is the one step that must not
# be skipped or improvised around (instructions/preflight.md).
set -eu
DIR=$(CDPATH='' cd -- "$(dirname -- "$0")" && pwd -P)
ROOT=$(dirname -- "$DIR")
if [ ! -x "$DIR/.venv/bin/python" ]; then
echo "wikitool: venv not found at $DIR/.venv" >&2
echo "Run: cd tools && python3 -m venv .venv && .venv/bin/pip install -r requirements.txt" >&2
exit 1
# Both venv layouts: bin/ everywhere but Windows, Scripts\ there - which is also
# what a venv created by a native Windows Python looks like from Git Bash.
if [ -x "$DIR/.venv/bin/python" ]; then
PY="$DIR/.venv/bin/python"
elif [ -f "$DIR/.venv/Scripts/python.exe" ]; then
PY="$DIR/.venv/Scripts/python.exe"
else
PY=""
fi
if [ -z "$PY" ] || ! grep -q '"complete": true' "$ROOT/.wikitool-tools.json" 2>/dev/null; then
cat >&2 <<'EOF'
STOP - this checkout is not set up yet (or no longer after an update).
Run the preflight first; it checks what this computer has, records the tool
paths and creates tools/.venv:
tools/preflight.sh
It exits 0 when everything is in place. If it exits 42, show its output to the
user as it is and wait - it says what to do. See instructions/preflight.md.
EOF
exit 42
fi
# Do NOT cd into $DIR: that would resolve relative CLI arguments (e.g.
# --markdown "kb/Lint Report.md") against tools/ instead of the caller's cwd.
# Add $DIR to PYTHONPATH instead so `chemenu` is importable regardless of
# where this script is invoked from.
export PYTHONPATH="$DIR${PYTHONPATH:+:$PYTHONPATH}"
exec "$DIR/.venv/bin/python" -m chemenu.cli "$@"
# Running a script puts its own directory on sys.path, which is how `chemenu`
# becomes importable without PYTHONPATH (whose separator differs on Windows).
exec "$PY" "$DIR/run_wikitool.py" "$@"