Skip to content

Move the last scripts into leaf-dev, and drop every import-path edit - #1384

Merged
max-sixty merged 1 commit into
mainfrom
scripts-audit
Sep 28, 2026
Merged

max-sixty merged 1 commit into
mainfrom
scripts-audit

Conversation

@max-sixty

@max-sixty max-sixty commented Sep 28, 2026 •

Copy link
Copy Markdown
Owner

scripts/ held what the suite could import only through pytest's pythonpath = ["scripts"]. Each script becomes a leaf-dev command in the module that owns it, the directory is gone, and nothing in the tree reaches code through sys.path, PYTHONPATH, pythonpath or a file path any more.

Was Now
scripts/preview.py leaf-dev preview
scripts/corpus.py leaf-dev corpus
scripts/keydocs.py leaf-dev keydocs
scripts/verify_site.py (+ verify-site-browser.js) leaf-dev verify-site
scripts/verify_codex_task.py leaf-dev verify-codex-task
scripts/deploy-site-dev.sh worker/deploy-dev.sh (npm run deploy:dev)
  • Preview's worker. leaf-dev preview execs its worker into the selected checkout's --no-dev environment, overlaid with this checkout's leaf_dev and watchfiles. The worker runs python -m leaf_dev.preview rather than the command group, because the group's other commands import leaf_website, which that environment lacks. The argparse options become click options with the same names, and the hidden --_worker flag becomes --worker. Usage errors still exit 2, and a failed leaf call still exits with that call's own status.
  • Callers. CI, publish-site (its run lines and path filters), the eslint override, the Worker's npm script, and the tests all use the new names. The suite imports from leaf_dev import preview, verify_site, corpus, keydocs, and runs the preview as python -m leaf_dev preview.
  • Guidance. scripts/AGENTS.md folds into dev/AGENTS.md, which now states the rule against import-path edits. The AGENTS.md repository map, /developing-leaf and the other docs name the commands.
  • Tests that faked a stale install. Two tests put an older leaf first on PYTHONPATH to stand in for a stale plugin install: the --version/--root test and the re-vendor restart test. Each now installs the payload (install_payload) and runs that install's own bin/leaf, as a host does. Their assertions are unchanged.
  • Regenerated files. examples/corpus.html and docs/registry.html each change one line, the generator name in their header comment.

TODO.md's "Repository tooling" item is done, so it is removed. leaf-dev bench-check already stopped using PYTHONPATH in #1373.

Checks:

  • leaf-dev --help lists the five new commands.
  • leaf-dev preview triage-board --export writes the page. leaf-dev corpus reproduces the committed corpus.
  • pytest passed 153 of 153 on test_interact_preview, test_interact_product, test_website_server, and the two rewritten tests.
  • pre-commit passes on every changed file.
  • The nightly test_render_export tests that wait for a watched edit fail locally. They fail on this machine regardless of the change: plain watchfiles.watch on a fresh temp directory reports no edit at all right now, at a load average above 40. Four of them, run alone on the merge base (2553559), fail the same way. CI's run is the reading for those tests.

This was written by Claude Code on behalf of max-sixty

🤖 Generated with Claude Code

`scripts/` held what tests could import only through pytest's
`pythonpath = ["scripts"]`. Each script becomes a `leaf-dev` command in the
module that owns it, and the directory is gone:

- `leaf-dev preview` (was `scripts/preview.py`). Its worker, exec'd into the
  selected checkout's environment, runs `python -m leaf_dev.preview` rather than
  the group, whose other commands import what that environment lacks.
- `leaf-dev corpus` and `leaf-dev keydocs`, which regenerate
  `examples/corpus.html` and the key index in `docs/registry.html`.
- `leaf-dev verify-site`, with its browser helper beside it.
- `leaf-dev verify-codex-task`.
- `worker/deploy-dev.sh` (was `scripts/deploy-site-dev.sh`), beside the Worker
  whose `npm run deploy:dev` runs it.

`scripts/AGENTS.md` folds into `dev/AGENTS.md`, which now states the rule: code
reaches a module by importing it from the package, never through `sys.path`,
`PYTHONPATH` or a file path.

Two tests put an older `leaf` first on `PYTHONPATH` to stand in for a stale
plugin install. They now install the payload (`install_payload`) and run its own
`bin/leaf`, as a host does. The `--version`/`--root` test and the re-vendor
restart test assert what they did before.

`TODO.md`'s "Repository tooling" item is done and removed.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
@max-sixty
max-sixty merged commit dddda11 into main Sep 28, 2026
5 checks passed
@max-sixty
max-sixty deleted the scripts-audit branch September 28, 2026 07:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants