The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
Merge origin/main into feat/hsp-sync-client
Ben Barclayf5b68ad58b01
diff --cc agent/skill_utils.pyindex 9276f145abd,eea78d6a07c..a302c6981a4--- a/agent/skill_utils.py+++ b/agent/skill_utils.py@@@ -49,57 -49,8 +49,57 @@@ EXCLUDED_SKILL_DIRS = frozenset# archive workflow preserves a complete old skill package under references/.SKILL_SUPPORT_DIRS = frozenset(("references", "templates", "assets", "scripts"))+# ── Org-shared skills (sync contract) ───────────────────────────+# Org mirrors live under ~/.hermes/skills/_org/<org_id>/. Resolution is+# TOKEN-GATED via a marker file the sync client writes after verifying the+# token (skills_sync_client.pull_org_skills): only the marked org's mirror is+# scanned. No marker ⇒ no org skills load. The marker is plain data (org_id+# string) so this module stays import-light; the VERIFICATION lives in the+# sync client, which is the only writer. Offline grace: the marker persists,+# so already-pulled org skills keep working without connectivity; a VERIFIED+# org change (or personal-org token) rewrites/removes it.++ORG_MIRROR_DIR_NAME = "_org"+ORG_ACTIVE_MARKER = ".active_org"+ORG_PROVENANCE_FILE = ".org-provenance.json"+# Records the fingerprint of each skill exactly as upstream sent it, so a+# later local edit is detectable and an org pull can refuse to clobber it.+ORG_BASELINE_FILE = ".org-baseline.json"+++def read_active_org_id(skills_dir: Path) -> Optional[str]:+ """The org id whose mirror may resolve, or None (no org skills load)."""+ try:+ marker = skills_dir / ORG_MIRROR_DIR_NAME / ORG_ACTIVE_MARKER+ if not marker.exists():+ return None+ val = marker.read_text(encoding="utf-8").strip()+ return val or None+ except OSError:+ return None+++def is_org_mirror_path(path, skills_dir: Path) -> bool:+ """True when *path* is inside the org mirror (``_org/``)."""+ try:+ rel = Path(path).resolve().relative_to(Path(skills_dir).resolve())+ except (OSError, ValueError):+ return False+ return bool(rel.parts) and rel.parts[0] == ORG_MIRROR_DIR_NAME+++def org_id_of_path(path, skills_dir: Path) -> Optional[str]:+ """The ``<org_id>`` segment for a path under ``_org/<org_id>/...``."""+ try:+ rel = Path(path).resolve().relative_to(Path(skills_dir).resolve())+ except (OSError, ValueError):+ return None+ if len(rel.parts) >= 2 and rel.parts[0] == ORG_MIRROR_DIR_NAME:+ return rel.parts[1]+ return None+- def is_excluded_skill_path(path) -> bool:+ def is_excluded_skill_path(path, *, root: Optional[Path] = None) -> bool:"""True if *path* should be skipped by active skill scanners.Use this on every ``SKILL.md`` path produced by direct ``rglob`` scans todiff --cc gateway/run.pyindex 4f610b3bf89,2e208a724e2..3d3c5bd4ef5--- a/gateway/run.py+++ b/gateway/run.py@@@ -22830,23 -24652,28 +24652,45 @@@ def _start_gateway_housekeeping(stop_evexcept Exception as e:logger.debug("Curator tick error: %s", e)+ # Skill Sync — best-effort periodic pull on the same cadence.+ # Inert unless the access gate is open and a sync base URL is+ # configured; never raises.+ try:+ from tools.skills_sync_client import maybe_pull_skills+ maybe_pull_skills()+ except Exception as e:+ logger.debug("Sync pull tick error: %s", e)++ # Org-shared skills. Gated on real org membership (the token must+ # carry an org role), so a solo account never reaches the network.+ try:+ from tools.skills_sync_client import maybe_pull_org_skills+ maybe_pull_org_skills()+ except Exception as e:+ logger.debug("Org sync pull tick error: %s", e)++ # Stale-session auto-archive — a live timer, so gateways that stay up+ # for weeks keep sweeping on schedule (the startup hook fires once).+ # maybe_auto_archive() is gated by sessions.min_interval_hours in+ # state_meta; this is just the poll rate. Opens its own SessionDB —+ # SQLite connections are thread-bound and this runs off-loop.+ if tick_count % AUTO_ARCHIVE_EVERY == 0:+ try:+ from hermes_cli.config import load_config as _load_full_config+ from hermes_state import SessionDB+ _sess_cfg = (_load_full_config().get("sessions") or {})+ if _sess_cfg.get("auto_archive", False):+ _adb = SessionDB()+ try:+ _adb.maybe_auto_archive(+ idle_days=float(_sess_cfg.get("auto_archive_days", 3)),+ min_interval_hours=int(_sess_cfg.get("min_interval_hours", 24)),+ )+ finally:+ _adb.close()+ except Exception as e:+ logger.debug("Auto-archive tick error: %s", e)+stop_event.wait(timeout=interval)logger.info("Gateway housekeeping stopped")diff --cc hermes_cli/main.pyindex ee45af38930,4db17c3e872..e7859bd351b--- a/hermes_cli/main.py+++ b/hermes_cli/main.py@@@ -400,9 -428,11 +428,12 @@@ from pathlib import Patfrom typing import Optional+ import functools as _functools++ from hermes_cli.sessions_cmd import cmd_sessions # noqa: F401from hermes_cli.subcommands._shared import add_accept_hooks_flag as _add_accept_hooks_flagfrom hermes_cli.subcommands.cron import build_cron_parser+from hermes_cli.subcommands.sync import build_sync_parserfrom hermes_cli.subcommands.gateway import build_gateway_parserfrom hermes_cli.subcommands.profile import build_profile_parserfrom hermes_cli.subcommands.model import build_model_parserdiff --cc tools/skill_manager_tool.pyindex 1482e0fa68c,c201ebaffd6..9c89e6b5c94--- a/tools/skill_manager_tool.py+++ b/tools/skill_manager_tool.py@@@ -1007,10 -950,7 +1028,11 @@@ def _edit_skill(name: str, content: str"path": str(existing["path"]),"_change": {"description": _desc},}+ org_note = _maybe_auto_propose_org_edit(name, existing["path"])+ if org_note:+ result["org_sharing"] = org_note+ result["message"] = f"{result['message']} {org_note}"+ _add_description_prompt_preview(result, content)return result