The codemod picked the files to read by the old top-level folder name and the old paths. A file that joins a folder variable to a moved file's name mentions neither, so it was never read and its path was never flagged. The names of the files that left a folder that stays are now search words too. For a whole-package move that set is empty and the files read are the same.
When a file leaves a folder that stays, the folder's name no longer counts
as moved, so the only trace of the old place in a join is the file's own
name. rewrite_imports.py flagged that name only when the join started at a
repository-root expression: tools_dir = ROOT / "tools" followed by
tools_dir / "blueprints.py" kept its old path with no flag.
A path join that ends in the name of a file that left a folder that stays
is now flagged whatever expression holds the folder. For a whole-package
move that set of files is empty, so its output is unchanged.
rewrite_imports.py and rewrite_docs.py treated every folder above a moved
file as a moved folder. That holds when a whole package moves. When a few
files leave a folder it does not: moving three files from tools/ to cron/
printed 58 flags that named tools/, tests/ and tests/tools/ as moved, and
rewrote every `tools/*.py` glob in the docs to `cron/*.py`.
A folder now counts as moved only when every tracked file under it moved.
renames.py holds that rule once (emptied_folders) together with the path
questions the import and TOML passes ask (MovedPaths); the docs pass reads
the same rule. A path built from pieces is flagged by the name of the
outermost file or folder the move took away, so a file that left a folder
that stays is still found. A docs glob follows a move only when every file
it matches moved together under its own name; otherwise it stays as
written and is counted as partial-glob.
rewrite_imports.py takes --no-compat-table for a move whose old names no
release, updater or plugin imports. The default still writes the table,
so build_chunk.py and migrate_branch.py are unchanged.
Whole-folder moves give the same output as before: on
`git mv acp_adapter hermes_agent/acp_adapter` both scripts print the same
log and write the same diff with and without this change.
_rename_like() compared the sequence of quote characters on the line and the token line-up. A branch
that moved the quotes from the module name to another argument, use(tui_gateway, "callback"), kept
both, so the resolver renamed the bare name into hermes_agent.tui_gateway, an attribute lookup. Each
renamed token's quote parity must now match its lined-up base token; such a line stays a conflict.
--continue stops when tracked files have unstaged changes, which the import rewrite step would discard.
--push compares the branch with the remote default branch's full name, so release/stable is refused too.
just migrate-branch --continue and --abort reuse the interpreter the first run set up, so they start after commit A moved hermes_cli.
A resolved hunk renames only the token that lines up with the renamed one, on a line whose quotes are unchanged; anything else stops.
Commit A of a chunk may also modify hermes_agent/compat/moves.py, which just move-chunk amends into it.
Python scripts without a .py extension that the branch changed go to the import rewriter.
A conflict in a file the branch rewrote was resolved with `git checkout --ours` on the whole
file. That dropped every other hunk the import-rewrite merge brought: main's commits when main
was merged into the chunk between A and B, and hand fixes when commit C carried the trailer.
Now git merges every non-conflicting hunk, and a conflicting hunk is resolved only when one side
changed nothing but module names there (both sides read with moved names spelled the old way); a
line that side renamed keeps the rename, and a line the other side edited takes the same
whole-token rename when that is all the renaming side changed on it. Every other hunk stops with its file and line. The same
rule applies to the final merge of the target.
Commit B is no longer "the last commit with the trailer". Trailers may carry a role
(`Hermes-Move: NN-name move|codemod|fix`); without roles, A is the first trailer commit and B is
only A's direct child, so later trailer commits are hand fixes that arrive with the target.
Also:
- files the branch added only inside a new subdirectory of a package A moved whole are moved to
the new path (git's directory rename detection leaves them behind), then rewritten;
- the codemod gets only files that still exist (a branch that deletes a moved file no longer
wedges on --continue);
- docs lines the branch added are rewritten with scripts/move/rewrite_docs.py, and any non-Python
line the branch added that still names a moved module or path is listed and stops the run
unless --accept-flags;
- --push pushes HEAD to refs/heads/<branch> on the branch's own remote and refuses the remote's
default branch; a detached HEAD is refused up front.
scripts/move/migrate_branch.py finds the move chunks a branch is missing by
their Hermes-Move trailer and, for each in landing order, merges the commit
before the rename, merges the rename with directory rename detection, runs
scripts/move/rewrite_imports.py on the Python files the branch changed, and
merges the import rewrite keeping the branch version of those files. It then
merges the target. Any other conflict stops the run; --continue resumes and
--abort restores the branch. Merges only; the remote is touched only with
--push.
The config.yaml key gateway.platforms.<name>.enabled was rewritten to
hermes_agent.gateway.platforms.<name>.enabled. The config-path deny list
matches gateway.platforms. only when a real segment follows, and a name
token stops at a placeholder or a wildcard, so the bare gateway.platforms
was read as the package. A config path that is also a package, alone or
before a placeholder or wildcard, now stays as written and is counted as
flagged-config-or-module for a person to check.
The docs pass counted a `bare-dir` skip for every `cron/*`, `tools/*` or
`plugins/**` it saw, even in a chunk that does not move that folder, so the
skip counts in the build log were inflated. The check now runs only for a
folder the chunk moves. What the pass writes is unchanged.
Add a test that a whole-folder glob on a moved folder that is not ambiguous
(`tui_gateway/*`) is still rewritten, and that an unmoved `cron/*` counts no
skip.
A glob that takes every file of a folder whose name is also a HERMES_HOME dir or an MCP method family (cron/*, tools/*, plugins/**) is skipped like the bare folder; a file pattern such as cron/*.py still follows the move.
rewrite_docs.py imports the old-path file generator only when it checks a .py path, so a copy of scripts/move outside the checkout no longer exits or fails to import.
English that follows from/import in running prose ("from providers like X") and config keys named like a
moved package (plugins.enabled, providers.<id>.api_key) were rewritten to hermes_agent.* names.
- from M import ... / import M / -m M are rewritten only as code: in a code span, a code fence, a >>> line, or
an import statement that parses as Python and starts its line. A bare top-level word alone is never
rewritten. import M becomes from hermes_agent import M.
- A dotted name is rewritten when it names a moved module or package, or a moved module plus an attribute it
defines; a bare package that is also a config section (agent, plugins, providers, ...) needs the attribute.
- DEFAULT_CONFIG keys (shared reader in renames.py, found wherever hermes_cli moved to) and i18n keys
(locales/en.yaml, first argument of t()) are left alone.
- Files generate_shims.py wrote are skipped.
The windows-footguns check flagged three reads/writes in rewrite_docs without
the policy encoding. Reads now use utf-8-sig; a file that started with a BOM
gets it back via write_bytes so rewritten files keep their bytes.
`just move-chunk` stopped with "nothing to commit" when no tool changed a file (a moved leaf that nothing
imports), and left commit A as the head. The command now makes commit B without changes, so every chunk has
the same two commits and a second run has nothing left to do.
The package list in pyproject.toml keeps an old package name while a generated file lives under it. A
`copy` row was not counted, so a package kept only by copy rows would have lost its line. No row is in
that position today: both copy rows sit under hermes_cli, which by-path rows keep.
The import rewrite now splits a multi-name import statement in the order of its names, so each module still loads in the same order.
move_roots now deletes only __pycache__ folders at hermes_agent/<ROOT> and refuses when any other file is there.
An __import__ through a variable, a helper, an empty fromlist or five arguments keeps its old module name.
move_roots refuses a Windows ROOT that has a root but no drive (\outside).
The --from-commit help says commit A also holds the MOVES update.
The row sat directly under the old-updater test row, which the hermes_cli chunk deletes in its hand
fixes, so that pick conflicted on every rebuild. It is now the last row of EXCLUDED.
The docs pass rewrites paths in SKILL.md files, the inputs of website/scripts/generate-skill-docs.py, and
skips the generated pages. Nothing regenerated them, so the docs job failed from the first chunk that
touched a path a skill names. The chunk command and just move-generate now run that generator.
scripts/build/launcher_wrapper.py is the text of minted launchers. It imports hermes_bootstrap first: the
root file, which repairs a torn update and installs the old-name finder before hermes_agent is importable.
The rewrite turned it into hermes_agent.hermes_bootstrap; it is now an excluded site.
The pyproject rewrite kept an old path in update-startup-files only while a generated file lived there.
The root hermes_bootstrap.py stays hand-written, so its entry was replaced by the new path and updates
stopped syntax-checking the file every launcher imports first.
A packages.find row ("pkg", "pkg.*") of a moved package stays while
required_names.py gives it a generated old-path file, and goes otherwise:
hermes_agent.* already ships the new place.
Decision D47. The call-argument sink and the module:attr reading rewrote hook
events, session keys, config keys, i18n keys and message text. A string now
changes only in a sink (sinks.py): import functions and helpers whose
parameter reaches one, validated patch targets, sys.modules keys, logger
names, -m/-c argv pairs, commands given to a process, Python code given to an
interpreter. A name, loop or table that feeds a sink is followed, and
rewritten only when every use feeds a sink. Every other string that names a
moved module or path is flagged with a class of its own.
import a becomes from hermes_agent import a (ruff PLR0402), except where the
from-form changes behaviour: a try that tells a missing module apart, and a
function that removes modules from sys.modules, keep the module form with
noqa. __import__("pkg.mod").Attr gets fromlist. Moved modules under folders
without __init__.py resolve. Code split across literals and f-strings is
edited piece by piece (pieces.py). Path flags need a moved file or folder
after the top folder, so tools/list and hermes-agent/ are not paths.
The bot_desktop row anchored text that left the base in ecf7061700, so the
shipped module name was rewritten; it now anchors the base spelling. The
_launcher_script row covered the whole def, including a live import; it now
anchors the minted return statement (anchor_spans widens a return like a def).
print_runtime_command's --module default is persisted text. Two test sites
that exercise old top-level names on purpose get OLD_NAMES rows.
KEPT_NAMES names the reasons whose module names tests may mirror.
`import a` became `import hermes_agent.a`, which binds `hermes_agent` for the whole
function: an earlier `hermes_agent.x` read there raised UnboundLocalError (practice
chunk 04, tests/hermes_state/test_fts_layout_drift.py). It now becomes
`import hermes_agent.a as a` and its uses keep their spelling. A function-local
`import a.b` whose new root another read in that function needs is flagged.
A string passed to a call is rewritten when its whole value names a moved module,
`module.attr` or `module:attr` of a name the module defines (`where="batch_runner.AIAgent"`,
`_tools_mod("tui_gateway.checkpoints")`); a bare top-level name needs `(module, attr)`
evidence (`_lazy("hermes_state", "SessionDB")`); a dotted name that only starts with
one is flagged. `"-m", "<mod>"` pairs in call arguments and f-string target heads
(`f"pkg.mod.{name}"`) are rewritten. DEFAULT_CONFIG keys (`agent.reasoning_effort`,
also a module) never change.
pyproject.toml entry points and package-data keys follow their module; package lists
are flagged (the old directory may still hold a shim). The run ends by naming
`just move-generate`, which regenerates the files built from rewritten docstrings.
Exclusion rows were (path, first line, last line) of the pre-move file. The codemod runs after
commit A, when the file sits at its new path, so no row ever matched a moved file
(hermes_cli/_old_updater.py was rewritten on chunk 11), and in migrate-branch a branch's
inserted lines shifted the site out of its range. Rows are now (path, anchor, reason): the path
also matches the file's new path through this move and the compat MOVES table, and the anchor is
exact source text, widened to the whole def, class or assignment it starts. A row whose anchor is
gone is flagged instead of silently doing nothing. Rows regenerated against origin/main.
A UTF-8 BOM is kept on rewrite; a .py file that is not UTF-8 is skipped with an `undecodable`
flag instead of crashing the whole run. A moved module the working tree no longer has (a branch
deleted it) is left out of the plan instead of raising FileNotFoundError.
String literals were checked against every moved path with a freshly compiled regex each; with
853 paths on chunk 11 that overflowed re's cache and took 80% of the run. One precompiled pattern
now, and the plan goes to each worker once.
Child-process code passed as python -c text or a string template has no compat finder,
so an old name there fails only at run time; the rehearsal on tui_gateway found 13.
scripts/move/renames.py reads old -> new dotted module names from a git mv commit.
scripts/move/rewrite_imports.py rewrites imports and their attribute chains with LibCST, plus
the strings the strict compat finder in tests cannot see: -m module arguments of child
processes, sys.modules keys and logger names. Every other site that names a moved module or
path is printed as a flag with its class, and the run fails until it is resolved.
libcst joins the dev dependency group; just move-rewrite runs it.
Released code takes plugins/platforms/<name>/ for a bundled platform only when the folder holds __init__.py
and plugin.yaml, and loads <name>/gateway_env.py by path only after that. The list kept gateway_env.py for
16 platforms and nothing else, so after plugins moves the scan found no platform and never read those files.
An updater that restarts paused gateways itself after the swap reads that scan to strip platform credentials
from a served profile's environment (by the code: v0.22.7 and v0.23.0, and v0.23.1 on Windows). Measured with
a v0.23.1 process whose checkout was swapped: 24 prefixes with no platform found, 60 with all 26.
Each of the 26 platform folders now keeps a marker __init__.py (kind exists) and a byte copy of plugin.yaml
(kind copy). The gateway_env.py rows become by-path, which is what a release does with them.
An exists file used to be a forwarding shim. It is now a marker that raises ImportError naming the moved
module. A gateway that started before the update and loads a platform late would otherwise get the moved
adapter, which is not an instance of the adapter base class it holds; it now fails with a message that says
to restart.
Two cases the generated old-path files did not handle.
A `python -m <old name>` launch puts the current folder first on sys.path. When that folder holds another
hermes_agent/ package (a developer's checkout opened as a workspace), the old-path package found it and
forwarded into the wrong tree. The generated file now puts its own root first for a `-m` launch, as it
already did when run as a script.
A `copy` row keeps a byte copy of a moved file at its old path. The generator resolved every row to
`<module>.py`, so a row for a data file would have copied the sibling module's source. A row whose name is
not a .py file now copies that file. Released apps fetch such a file from main by URL.
After a failed forward the generated file imported hermes_bootstrap only when Python was locating a module
for `python -m` (sys.argv[:1] == ["-m"]). A file that runs as __main__ (`python cli.py`, a documented
command) is a process entry too: with hermes_agent/compat/__init__.py cut short by a killed update it raised
SyntaxError and the checkout was not restored. Both launches now reach the bootstrap; a plain import still
re-raises without it, and a healthy launch never gets to this branch.
The generated old-path file imported the root hermes_bootstrap on every python -m launch, so light targets that never imported it (an old updater's abort recovery, uninstall) ran launch preparation and dependency activation, and exited 1 when activation failed.
It now forwards first and imports hermes_bootstrap only when forwarding fails during a python -m launch (a torn or moved-aside hermes_agent), then forwards once more. The torn-update test tears the compat package itself, so it fails when the repair comes after the compat import.
Package shims import the root hermes_bootstrap first during a python -m launch, and relaunch_command reads the -m module from sys.orig_argv while Python is still locating it.
Six acp_adapter modules that an editor ACP server imports lazily get old-path files.
A hand-written file at an old path runs before hermes_agent can be imported. An update must refuse a
tree where it does not compile, which it does only for files in [tool.hermes] update-startup-files.