diff --git a/hermes_cli/profile_cmd.py b/hermes_cli/profile_cmd.py index e9eb16180e..794391325c 100644 --- a/hermes_cli/profile_cmd.py +++ b/hermes_cli/profile_cmd.py @@ -168,7 +168,7 @@ def _profile_create(args): if cloned: source_label = clone_from or get_active_profile_name() if clone_all: - print(f"Full copy from {source_label} (excluding session history, backups, and snapshots).") + print(f"Full copy from {source_label} (excluding session history, cron jobs, backups, and snapshots).") else: print(f"Cloned config, .env, SOUL.md, and skills from {source_label}.") # Auto-clone Honcho config for the new profile (only with clone operations) diff --git a/hermes_cli/profiles.py b/hermes_cli/profiles.py index e4a0d3b1a3..0fc6151979 100644 --- a/hermes_cli/profiles.py +++ b/hermes_cli/profiles.py @@ -52,8 +52,12 @@ _CLONE_ALL_DEFAULT_EXCLUDE_ROOT: frozenset[str] = frozenset({ # (+wal/shm, can reach many GB), session dirs, `hermes backup` archives, quick-backup # snapshots, checkpoints. Inheriting them is never useful (restoring one inside the # clone would resurrect the SOURCE profile's state) and can balloon the copy by tens of GB. +# ``cron`` is scheduled work bound to the source profile and its origin channel: a clone +# that inherits jobs.json runs every job twice (two gateways, same job ids, double spend, +# duplicate deliveries) the moment its gateway starts. The empty dir is recreated below. _CLONE_ALL_HISTORY_EXCLUDE_ROOT: frozenset[str] = frozenset({ "state.db", "state.db-wal", "state.db-shm", "sessions", "backups", "state-snapshots", "checkpoints", + "cron", }) # Marker written by `hermes profile create --no-skills`. When present at a profile root, @@ -776,6 +780,9 @@ def _clone_all_into(source_dir: Path, profile_dir: Path, canon: str) -> None: """--clone-all: full copytree minus infrastructure/history, then strip runtime files and cloned single-use OAuth grants.""" shutil.copytree(source_dir, profile_dir, symlinks=True, ignore=_clone_all_copytree_ignore(source_dir)) + # Excluded history dirs (sessions/, cron/) must still exist as empty dirs so the clone runs. + for subdir in _PROFILE_DIRS: + (profile_dir / subdir).mkdir(parents=True, exist_ok=True) for stale in _CLONE_ALL_STRIP: (profile_dir / stale).unlink(missing_ok=True) # auth.json / .anthropic_oauth.json copied verbatim fork single-use OAuth grants diff --git a/tests/hermes_cli/test_profiles.py b/tests/hermes_cli/test_profiles.py index ea508eeddb..93437a08dc 100644 --- a/tests/hermes_cli/test_profiles.py +++ b/tests/hermes_cli/test_profiles.py @@ -190,6 +190,21 @@ class TestCreateProfile: assert (profile_dir / ".env").read_text().strip() == "KEY=val" assert (profile_dir / "SOUL.md").read_text() == "Be helpful." + def test_clone_all_does_not_copy_cron_jobs(self, profile_env): + # Cron jobs are scheduled work bound to the source profile + origin channel; a clone + # that inherits jobs.json fires every job twice (two gateways, same job ids). + default_home = profile_env / ".hermes" + (default_home / "config.yaml").write_text("model: test") + (default_home / "cron").mkdir() + (default_home / "cron" / "jobs.json").write_text(json.dumps({"jobs": [{"id": "abc123def456"}]})) + (default_home / "cron" / "output").mkdir() + + profile_dir = create_profile("coder", clone_all=True, no_alias=True) + + assert (profile_dir / "cron").is_dir() + assert not any((profile_dir / "cron").iterdir()) + assert yaml.safe_load((profile_dir / "config.yaml").read_text())["model"] == "test" + diff --git a/website/docs/reference/profile-commands.md b/website/docs/reference/profile-commands.md index 1f13d8e03b..47e6bda448 100644 --- a/website/docs/reference/profile-commands.md +++ b/website/docs/reference/profile-commands.md @@ -81,7 +81,7 @@ Creates a new profile. |-------------------|-------------| | `` | Name for the new profile. Must be a valid directory name (alphanumeric, hyphens, underscores). | | `--clone` | Copy `config.yaml`, `.env`, `SOUL.md`, and skills from the current profile. | -| `--clone-all` | Copy everything (config, memories, skills, cron, plugins) from the current profile. Excludes per-profile history: sessions, `state.db`, backups, state-snapshots, checkpoints. | +| `--clone-all` | Copy everything (config, memories, skills, plugins) from the current profile. Excludes per-profile history: sessions, `state.db`, backups, state-snapshots, checkpoints — and cron jobs, which stay bound to the source profile (a clone that inherited them would fire every job twice). | | `--clone-from ` | Clone config/skills/SOUL from a specific profile instead of the current one. Implies `--clone` unless paired with `--clone-all`. | | `--no-alias` | Skip wrapper script creation. | | `--description ""` | One- or two-sentence description of what this profile is good at. Used by the kanban orchestrator to route tasks based on role instead of profile name alone. Skip and add later via `hermes profile describe`. Persisted in `/profile.yaml`. | diff --git a/website/docs/user-guide/profiles.md b/website/docs/user-guide/profiles.md index ca3349defd..6eda1f11e9 100644 --- a/website/docs/user-guide/profiles.md +++ b/website/docs/user-guide/profiles.md @@ -62,7 +62,7 @@ Copies your current profile's `config.yaml`, `.env`, `SOUL.md`, and skills into hermes profile create backup --clone-all ``` -Copies **everything** — config, API keys, personality, all memories, skills, cron jobs, plugins. A complete working snapshot. Per-profile history is excluded (session history, `state.db`, `backups/`, `state-snapshots/`, `checkpoints/`) — these belong to the source profile and can reach tens of GB. For a full backup including history, use `hermes profile export` or `hermes backup` instead. +Copies **everything** — config, API keys, personality, all memories, skills, plugins. A complete working snapshot. Per-profile history is excluded (session history, `state.db`, `backups/`, `state-snapshots/`, `checkpoints/`) — these belong to the source profile and can reach tens of GB. **Cron jobs are not cloned** either: they are scheduled work bound to the source profile and its delivery channel, and a clone that inherited them would run every job twice (two gateways, same job ids). The new profile starts with an empty `cron/`. For a full backup including history and cron jobs, use `hermes profile export` or `hermes backup` instead. :::note OAuth logins are shared, not copied Anthropic (Claude Pro/Max), OpenAI Codex, and xAI OAuth logins use **single-use refresh tokens** — a copy of one is not a second credential, it is the same credential with two owners, and the first profile to refresh it revokes it for every other copy. `--clone-all` (and the dashboard's credential mirroring) therefore drops those OAuth rows from the clone. The new profile keeps reading the login from the root `~/.hermes/auth.json`, and a token refresh performed inside any profile is written back to root, so all profiles stay signed in. Static API keys are copied as usual. To give a profile its own separate OAuth login, run `hermes -p auth add ` inside it.