Skip to content

The agent that grows with you

feat: profile clone can opt into staying synced with its source (--sync-imports)

teknium17bb52c0b747d
diff --git a/hermes_cli/profile_cmd.py b/hermes_cli/profile_cmd.py
index d45e8f1d22d..e67cf556feb 100644
--- a/hermes_cli/profile_cmd.py
+++ b/hermes_cli/profile_cmd.py
@@ -196,6 +196,7 @@ def _profile_create(args):
no_skills = getattr(args, "no_skills", False)
clone_from = getattr(args, "clone_from", None)
clone_channels = getattr(args, "clone_channels", False)
+ sync_imports = getattr(args, "sync_imports", False)
clone_config = clone or clone_from is not None
cloned = clone_config or clone_all
source_label = clone_from or get_active_profile_name()
@@ -203,7 +204,7 @@ def _profile_create(args):
profile_dir = create_profile(
name=name, clone_from=clone_from, clone_all=clone_all, clone_config=clone_config,
no_alias=no_alias, no_skills=no_skills, description=getattr(args, "description", None),
- clone_channels=clone_channels,
+ clone_channels=clone_channels, sync_imports=sync_imports,
)
except (ValueError, FileExistsError, FileNotFoundError) as e:
_die(f"Error: {e}")
@@ -213,6 +214,9 @@ def _profile_create(args):
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}.")
+ if sync_imports:
+ print(f"Import sources carried over — `hermes -p {name} import-agent --sync` "
+ "keeps pulling the same Claude Code / Codex trees.")
_print_channel_clone_notice(name, source_label, clone_channels, "--clone-all" if clone_all else "--clone")
# Auto-clone Honcho config for the new profile (only with clone operations)
try:
diff --git a/hermes_cli/profiles.py b/hermes_cli/profiles.py
index 5e6b16f7300..9284e3c032c 100644
--- a/hermes_cli/profiles.py
+++ b/hermes_cli/profiles.py
@@ -16,6 +16,7 @@ from pathlib import Path
from typing import Dict, List, Optional, Tuple
from agent.skill_utils import is_excluded_skill_path
+from hermes_cli.agent_import_sync import SYNC_MANIFEST_NAME
from hermes_cli.archive_safe import archive_root_dirs, make_targz, normalize_archive_parts, safe_extract_targz
from hermes_constants import clear_named_profile_deleted, mark_named_profile_deleted, named_profile_is_deleted
@@ -859,10 +860,16 @@ def _clone_all_into(source_dir: Path, profile_dir: Path, canon: str) -> None:
)
-def _bootstrap_profile_dir(profile_dir: Path, source_dir: Optional[Path]) -> None:
+def _bootstrap_profile_dir(profile_dir: Path, source_dir: Optional[Path],
+ sync_imports: bool = False) -> None:
"""Fresh layout: bootstrap dirs, then either seed a model block (no source) or clone
config files, installed skills (the dashboard's "clone from default" must keep bundled
- AND user-installed skills), and memory/identity files from *source_dir*."""
+ AND user-installed skills), and memory/identity files from *source_dir*.
+
+ ``sync_imports`` also copies the source's ``import-sync.json`` (the ``hermes import-agent``
+ manifest) so the clone stays registered against the same external Claude Code / Codex trees
+ and ``hermes -p <clone> import-agent --sync`` keeps pulling from them. The link is to the
+ external tree, never to the source profile: both profiles stay independent islands."""
profile_dir.mkdir(parents=True, exist_ok=True)
for subdir in _PROFILE_DIRS:
(profile_dir / subdir).mkdir(parents=True, exist_ok=True)
@@ -879,12 +886,14 @@ def _bootstrap_profile_dir(profile_dir: Path, source_dir: Optional[Path]) -> Non
)
for relpath in _CLONE_SUBDIR_FILES:
_clone_file(source_dir, profile_dir, relpath)
+ if sync_imports:
+ _clone_file(source_dir, profile_dir, SYNC_MANIFEST_NAME)
def create_profile(
name: str, clone_from: Optional[str] = None, clone_all: bool = False, clone_config: bool = False,
no_alias: bool = False, no_skills: bool = False, description: Optional[str] = None,
- clone_channels: bool = False,
+ clone_channels: bool = False, sync_imports: bool = False,
) -> Path:
"""Create a new profile directory and return its path.
@@ -895,12 +904,17 @@ def create_profile(
makes two gateways fight over one bot (``hermes_cli.profile_channels``; callers list what
was left behind with ``channel_platforms_configured(source_dir)``).
``no_skills`` creates an empty profile and writes a marker so ``hermes update`` skips
- re-seeding its skills; it is mutually exclusive with the clone options, which copy skills."""
+ re-seeding its skills; it is mutually exclusive with the clone options, which copy skills.
+ ``sync_imports`` (``--clone`` only; ``--clone-all`` copies the file anyway) also copies the
+ ``import-agent`` sync manifest so the clone can keep pulling the same external agent trees."""
if no_skills and (clone_from is not None or clone_config or clone_all):
raise ValueError(
"--no-skills is mutually exclusive with --clone / --clone-from / --clone-all "
"(cloning explicitly copies skills from the source profile)."
)
+ if sync_imports and not (clone_config or clone_all):
+ raise ValueError("--sync-imports requires --clone or --clone-from (there is no import "
+ "manifest to carry over without a source profile).")
cloning = clone_from is not None or clone_all or clone_config
if clone_channels and not cloning:
raise ValueError("--clone-channels only applies to a clone (--clone, --clone-from or --clone-all).")
@@ -932,7 +946,7 @@ def create_profile(
if clone_all and source_dir:
_clone_all_into(source_dir, staging, canon)
else:
- _bootstrap_profile_dir(staging, source_dir)
+ _bootstrap_profile_dir(staging, source_dir, sync_imports=sync_imports)
if source_dir is not None and not clone_channels:
from hermes_cli.profile_channels import strip_channel_settings
stripped = strip_channel_settings(staging, include_state=clone_all, source_dir=source_dir)
diff --git a/hermes_cli/subcommands/profile.py b/hermes_cli/subcommands/profile.py
index 16c83b2de27..7202871ca61 100644
--- a/hermes_cli/subcommands/profile.py
+++ b/hermes_cli/subcommands/profile.py
@@ -32,6 +32,11 @@ def build_profile_parser(subparsers, *, cmd_profile: Callable) -> None:
help="Also copy the source's messaging channels (bot tokens, allowlists, platform sections). "
"Two profiles holding one bot token collide; refused when the source is served by a live "
"multiplexed gateway.")
+ profile_create.add_argument(
+ "--sync-imports", action="store_true",
+ help="With --clone/--clone-from: also carry over the `hermes import-agent` sync manifest so "
+ "the new profile stays registered against the same Claude Code / Codex trees "
+ "(`hermes -p <name> import-agent --sync`). Never syncs config from the source profile.")
profile_create.add_argument(
"--no-alias", action="store_true", help="Skip wrapper script creation")
profile_create.add_argument(
diff --git a/tests/hermes_cli/test_profiles.py b/tests/hermes_cli/test_profiles.py
index b5cbb279aab..bd8e22abb98 100644
--- a/tests/hermes_cli/test_profiles.py
+++ b/tests/hermes_cli/test_profiles.py
@@ -201,6 +201,31 @@ class TestCreateProfile:
assert (profile_dir / ".env").read_text().strip() == "KEY=val"
assert (profile_dir / "SOUL.md").read_text() == "Be helpful."
+ def test_clone_sync_imports_carries_manifest_but_never_links_profiles(self, profile_env):
+ """--sync-imports copies import-sync.json (a pointer at EXTERNAL agent trees) and nothing
+ else changes: the clone still gets its own config/skills copies, never a live link."""
+ from hermes_cli.agent_import_sync import SYNC_MANIFEST_NAME, load_sync_manifest
+
+ default_home = profile_env / ".hermes"
+ (default_home / "config.yaml").write_text("model: test")
+ manifest = {"version": 1, "agents": {"claude-code": {
+ "source": str(profile_env / ".claude"), "digest": "d", "overwrite": False,
+ "last_import": 1, "imported_skills": ["s1"]}}}
+ (default_home / SYNC_MANIFEST_NAME).write_text(json.dumps(manifest))
+
+ plain = create_profile("plain", clone_config=True, no_alias=True)
+ assert not (plain / SYNC_MANIFEST_NAME).exists()
+
+ synced = create_profile("synced", clone_config=True, sync_imports=True, no_alias=True)
+ assert load_sync_manifest(synced)["agents"] == manifest["agents"]
+ # Editing the source afterwards does not reach the clone: still an independent island.
+ (default_home / "config.yaml").write_text("model: changed")
+ assert yaml.safe_load((synced / "config.yaml").read_text())["model"] == "test"
+
+ def test_sync_imports_requires_a_clone_source(self, profile_env):
+ with pytest.raises(ValueError, match="--sync-imports requires"):
+ create_profile("lonely", sync_imports=True, no_alias=True)
+
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).
diff --git a/website/docs/reference/cli-commands.md b/website/docs/reference/cli-commands.md
index 8e4181da810..19b5e236556 100644
--- a/website/docs/reference/cli-commands.md
+++ b/website/docs/reference/cli-commands.md
@@ -1807,6 +1807,7 @@ Examples:
```bash
hermes profile list
hermes profile create work --clone
+hermes profile create work --clone --sync-imports # also carry over the import-agent sync manifest
hermes profile use work
hermes profile alias work --name h-work
hermes profile export work -o work-backup.tar.gz
diff --git a/website/docs/user-guide/import-from-other-agents.md b/website/docs/user-guide/import-from-other-agents.md
index 38807261ca5..2814766b9bf 100644
--- a/website/docs/user-guide/import-from-other-agents.md
+++ b/website/docs/user-guide/import-from-other-agents.md
@@ -70,3 +70,5 @@ Sync is prompt-free and cheap: sources whose files are unchanged are skipped by
- **Credential files never trigger a sync** — token refreshes in `~/.claude/.credentials.json` or `~/.codex/auth.json` are ignored by the digest, and secrets are still stripped from anything imported.
This mirrors ChatGPT Work's *Settings > Import* automatic updates, adapted to an explicit, inspectable command instead of a background service.
+
+The manifest is per profile. A profile created with `hermes profile create <name> --clone --sync-imports` carries it over, so `hermes -p <name> import-agent --sync` keeps pulling from the same external trees (see [Profiles](./profiles.md#keep-a-clones-imported-agent-setups-synced---sync-imports)).
diff --git a/website/docs/user-guide/profiles.md b/website/docs/user-guide/profiles.md
index 251de3a771f..43aa3db1325 100644
--- a/website/docs/user-guide/profiles.md
+++ b/website/docs/user-guide/profiles.md
@@ -56,6 +56,17 @@ hermes profile create work --clone
Copies your current profile's `config.yaml`, `.env`, `SOUL.md`, skills, and the curated memory files `memories/MEMORY.md` and `memories/USER.md` into the new profile — memory is treated as part of the agent's identity, like `SOUL.md`. Sessions, `state.db`, cron jobs and everything else start empty. For a blank memory as well, create the profile without `--clone` or delete the two files afterwards; the agent never falls back to another profile's memory when they are absent. Edit `~/.hermes/profiles/work/.env` for different API keys, or `~/.hermes/profiles/work/SOUL.md` for a different personality.
+#### Keep a clone's imported agent setups synced (`--sync-imports`)
+
+If the source profile has run [`hermes import-agent`](./import-from-other-agents.md), its `import-sync.json` records which external Claude Code / Codex trees it imported. `--clone` leaves that manifest behind, so the clone gets a one-off copy of those skills and memories and stops there. Add `--sync-imports` to carry the manifest over:
+
+```bash
+hermes profile create work --clone --sync-imports
+hermes -p work import-agent --sync # pulls changes from the same ~/.claude / ~/.codex
+```
+
+This is explicit, opt-in and one-directional, and it links the clone to the **external agent trees only** — never to the source profile. Both profiles stay independent islands: editing the source's `config.yaml`, `SOUL.md` or skills afterwards never reaches the clone. `--clone-all` copies the manifest as part of the full copy.
+
### Clone everything (`--clone-all`)
```bash