The worktree pruner never removed a dirty or unpushed tree at any age, so leftovers of finished lanes (stray probe files, WIP commits on closed PRs) accumulated forever: 658 trees / ~1 TB on one machine, 553 of them named lane trees. Approved design (Teknium, 2026-10-17): - Snapshot-then-delete: an idle tree past its tier (hermes-*/subagent-* 24h, named 72h) with uncommitted changes or unpushed commits is archived to refs/hermes/archive/<tree> (HEAD + staged + unstaged + non-ignored untracked bytes, built with a temporary index; large untracked files skipped and listed) and then removed. A failed archive keeps the tree. Branch kept when published on a remote, otherwise the archive anchors its commits. - Never touched at any age or budget: live hermes lock owners, any live process whose cwd/open fd is inside the tree (/proc on Linux, psutil cwd elsewhere), trees with recent file/ref activity, Kanban t_<hex> trees. - No count cap; optional worktrees.max_total_gb evicts the oldest idle trees first. - Per-profile registry (<HERMES_HOME>/worktree_repos.json) of every repo Hermes made a worktree in (hermes -w, /worktree new, subagent isolation, Desktop git pane); the 6h cron sweep unions it with its existing sources, scoped and throttled per profile. - Subagent worktrees with commits/edits are archived and removed at child finish (branch kept). - Interactive `hermes -w` (CLI and --tui) exit with a dirty/unpushed tree asks Keep (default) / Archive & remove / Remove and discard; non-interactive exits never ask. - `hermes worktree restore <name> [--path]`, archives in `hermes worktree list`, a full decision table in `hermes worktree prune --dry-run`, archive retention (30 days). - worktrees.archive_dirty: false restores the classic never-delete-dirty pruner exactly.
42 lines
1.6 KiB
Python
42 lines
1.6 KiB
Python
"""Entry factories for ``config_defaults.OPTIONAL_ENV_VARS`` (pure-data leaf, no imports)."""
|
|
|
|
|
|
def _env(description, prompt, **keys):
|
|
"""One OPTIONAL_ENV_VARS entry; keyword order is preserved as dict key order."""
|
|
return {"description": description, "prompt": prompt, **keys}
|
|
|
|
|
|
_OMIT = object()
|
|
|
|
|
|
def _category(category, password, advanced):
|
|
"""Entry factory for one category with its usual password/advanced defaults.
|
|
|
|
``url``/``help``/``tools`` are only written when passed; ``password=None`` omits the key;
|
|
``advanced`` is only written when true. Key order matches the plain ``_env`` entries.
|
|
"""
|
|
def make(description, prompt, url=_OMIT, *, help=_OMIT, tools=_OMIT, password=password,
|
|
advanced=advanced):
|
|
d = {"description": description, "prompt": prompt}
|
|
d.update((k, v) for k, v in (("help", help), ("url", url), ("tools", tools)) if v is not _OMIT)
|
|
if password is not None:
|
|
d["password"] = password
|
|
d["category"] = category
|
|
if advanced:
|
|
d["advanced"] = True
|
|
return d
|
|
return make
|
|
|
|
|
|
_prov = _category("provider", password=True, advanced=True)
|
|
_tool = _category("tool", password=True, advanced=False)
|
|
_msg = _category("messaging", password=False, advanced=False)
|
|
_skill = _category("skill", password=True, advanced=True)
|
|
_setting = _category("setting", password=False, advanced=False)
|
|
|
|
|
|
def _base_url(name, prompt_name=None):
|
|
"""Provider ``*_BASE_URL`` override entry (advanced, not a secret)."""
|
|
prompt = f"{prompt_name or name} base URL (leave empty for default)"
|
|
return _prov(f"{name} base URL override", prompt, None, password=False)
|