diff options
| author | tv <tv@krebsco.de> | 2026-11-20 20:57:58 +0000 |
|---|---|---|
| committer | tv <tv@krebsco.de> | 2026-11-21 04:58:48 +0100 |
| commit | b90f3c2332651983943689cbabec89d201ecc9db (patch) | |
| tree | 00f7f6793d1b512eb1e8f1d99695d51cdc7799a8 /configs | |
| parent | 2331b50f9c0353ab92e1c15795587f4a1d0dd803 (diff) | |
configs/hermes: make the copies of bundled skills writable
Hermes copies its bundled (and optional) skills out of the store into
~/.hermes/skills with shutil.copytree, which keeps the store's modes,
so the copies were read-only, files and directories: skill_manage
couldn't patch a bundled skill, nor write its temporary files next to
it. Patch the three places that copy a skill (seeding, updating,
restoring) to make the copy writable for its owner afterwards, and
copy the categories' DESCRIPTION.md without its mode.
The manifest's hashes are of paths and contents only, so writable
copies don't count as user-modified, and updates still replace them.
Tested against the pinned source's tools/ with read-only bundled
skills: seeding, an update and a restore leave nothing read-only
(before: 382 paths), and nothing gets reported as user-modified.
Copies made before this stay read-only; chmod -R u+w ~/.hermes/skills
fixes them.
Diffstat (limited to 'configs')
| -rw-r--r-- | configs/hermes.nix | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/configs/hermes.nix b/configs/hermes.nix index 902c280..0cc0736 100644 --- a/configs/hermes.nix +++ b/configs/hermes.nix @@ -47,6 +47,35 @@ let substituteInPlace gateway/run.py --replace-fail \ 'RedactingFormatter("%(asctime)s %(levelname)s %(name)s: %(message)s")' \ 'RedactingFormatter(("" if os.environ.get("JOURNAL_STREAM") else "%(asctime)s ") + "%(levelname)s %(name)s: %(message)s")' + + # Bundled and optional skills get copied out of the store with the + # store's modes, i.e. read-only, so skill_manage can neither patch + # them nor write its temporary files next to them: make the copies + # writable (and the categories' DESCRIPTION.md, without its mode). + # The manifest's hashes are of contents only, so that doesn't make + # them count as user-modified. + substituteInPlace tools/skills_sync.py \ + --replace-fail 'shutil.copytree(src, dest, ignore=_ignore_runtime_cache)' \ + '_copytree_writable(src, dest, ignore=_ignore_runtime_cache)' \ + --replace-fail 'shutil.copytree(skill_src, dest, ignore=_ignore_runtime_cache)' \ + '_copytree_writable(skill_src, dest, ignore=_ignore_runtime_cache)' \ + --replace-fail 'shutil.copy2(desc_md, dest_desc)' \ + 'shutil.copyfile(desc_md, dest_desc)' + substituteInPlace tools/skills_sync_bundled_ops.py \ + --replace-fail 'shutil.copytree(src, dest, ignore=_ignore_runtime_cache, dirs_exist_ok=True,' \ + 'ss._copytree_writable(src, dest, ignore=_ignore_runtime_cache, dirs_exist_ok=True,' + cat >> tools/skills_sync.py <<'EOF' + + + def _copytree_writable(src, dst, **kwargs): + result = shutil.copytree(src, dst, **kwargs) + for root, _dirs, files in os.walk(dst): + for path in [root, *(os.path.join(root, name) for name in files)]: + st = os.lstat(path) + if not stat.S_ISLNK(st.st_mode): + os.chmod(path, st.st_mode | stat.S_IWUSR) + return result + EOF ''; }; |
