b4fbd6fe9f
Deploy Site / deploy-vercel (push) Has been skipped
Deploy Site / deploy-docs (push) Has been skipped
Build Skills Index / build-index (push) Has been skipped
CI / Deny unrelated histories (push) Has been skipped
CI / Detect affected areas (push) Successful in 27m35s
CI / OSV scan (push) Failing after 4s
CI / Build&Test Docker image (push) Successful in 9s
CI / Supply-chain scan (push) Has been skipped
CI / Lint Docker scripts (push) Failing after 5m13s
CI / Check contributors (push) Failing after 12m8s
CI / Docs Site (push) Failing after 12m8s
CI / TypeScript (push) Failing after 12m8s
CI / Python lints (push) Failing after 12m9s
CI / Python tests (push) Failing after 12m9s
CI / Check uv.lock (push) Failing after 23m22s
CI / CI timing report (push) Has been cancelled
Build Skills Index / trigger-deploy (push) Has been cancelled
CI / All required checks pass (push) Has been cancelled
54 lines
2.3 KiB
Python
54 lines
2.3 KiB
Python
"""Guard: every `hermes update` path that reports user-modified skills must
|
|
also tell the user how to find them.
|
|
|
|
`hermes update` keeps (does not overwrite) bundled skills the user edited and
|
|
prints a ``~ N user-modified (kept)`` count. There are two independent update
|
|
code paths in ``hermes_cli/main.py`` that print this notice (the git-pull path
|
|
in ``_cmd_update_impl`` and the unpack/install path). Both must point the user
|
|
at ``hermes skills list-modified`` so the count is actionable — otherwise,
|
|
depending on which path a user hits, they may never learn the discovery command
|
|
exists.
|
|
|
|
This is an *invariant* test (the two sibling notices must agree), not a literal
|
|
snapshot: it asserts the relationship "count line ⇒ discovery hint", so it
|
|
keeps holding if the wording is reworded, as long as both sites stay in sync.
|
|
"""
|
|
|
|
import re
|
|
from pathlib import Path
|
|
|
|
import hermes_cli.main as main_mod
|
|
|
|
|
|
_COUNT_RE = re.compile(r"user-modified \(kept\)")
|
|
_HINT_RE = re.compile(r"hermes skills list-modified")
|
|
|
|
|
|
def _source_lines() -> list[str]:
|
|
return Path(main_mod.__file__).read_text(encoding="utf-8").splitlines()
|
|
|
|
|
|
def test_every_user_modified_notice_points_at_list_modified():
|
|
lines = _source_lines()
|
|
count_sites = [i for i, ln in enumerate(lines) if _COUNT_RE.search(ln)]
|
|
|
|
# The notice must exist somewhere (guard against it being deleted outright),
|
|
# but we deliberately do NOT assert a fixed *count* of sites: consolidating
|
|
# the duplicated print paths into a shared helper is a welcome refactor and
|
|
# must not fail this test. The invariant is per-site, not how many sites.
|
|
assert count_sites, (
|
|
"no 'user-modified (kept)' notice found in main.py — the update "
|
|
"summary that surfaces kept user edits appears to have been removed"
|
|
)
|
|
|
|
for idx in count_sites:
|
|
# The count print and its discovery hint sit on adjacent lines; allow a
|
|
# small window so wording/formatting tweaks don't break the check.
|
|
window = "\n".join(lines[idx : idx + 5])
|
|
assert _HINT_RE.search(window), (
|
|
"a 'user-modified (kept)' notice near line "
|
|
f"{idx + 1} of main.py does not point users at "
|
|
"`hermes skills list-modified` within the following lines — the "
|
|
"update paths have drifted apart again:\n" + window
|
|
)
|