ChatGPT Work's desktop import (Settings > Import, Aug 11 2026 release) keeps setup imported from Claude Code / Cursor automatically up to date. This ports the idea to `hermes import-agent`: - Every successful import registers its source + a content digest of everything the importer read in HERMES_HOME/import-sync.json. - `hermes import-agent --sync` re-imports every registered source whose files changed since the last run (digest compare; unchanged = no-op). Prompt-free and cron-friendly; `--sync --dry-run` previews. - Skills previously imported by import-agent are refreshed in place on sync; user-created skills under the import category keep conflict semantics and are never clobbered. - Credential files never affect the digest, so token refreshes cannot trigger (or leak into) a sync. Tests: 13 new tests in tests/hermes_cli/test_agent_import.py (61 total passing), including a sabotage-verified in-place-refresh test; E2E run against a temp HERMES_HOME exercised register -> no-op sync -> changed sync through the real command path.
37 lines
1.8 KiB
Python
37 lines
1.8 KiB
Python
"""``hermes import-agent`` subcommand parser (logic lives in ``hermes_cli/agent_import.py``)."""
|
|
|
|
from __future__ import annotations
|
|
|
|
from typing import Callable
|
|
|
|
from hermes_cli.subcommands._shared import add_yes_flag
|
|
|
|
|
|
def build_import_agent_parser(subparsers, *, cmd_import_agent: Callable) -> None:
|
|
"""Attach the ``import-agent`` subcommand to ``subparsers``."""
|
|
parser = subparsers.add_parser(
|
|
"import-agent", help="Import a Claude Code or Codex CLI setup into Hermes",
|
|
description="One-command import of another coding agent's setup into Hermes. "
|
|
"Maps CLAUDE.md/AGENTS.md instructions, permission allowlists, MCP "
|
|
"servers, skills, and memories into their Hermes equivalents. "
|
|
"Always shows a preview before making changes. API keys and "
|
|
"credentials are never imported — run 'hermes setup' for those.")
|
|
parser.add_argument(
|
|
"agent", nargs="?", choices=["claude-code", "codex"],
|
|
help="Which agent to import from (default: auto-detect ~/.claude or ~/.codex)")
|
|
parser.add_argument(
|
|
"--source", help="Path to the agent's config directory (default: ~/.claude or ~/.codex)")
|
|
parser.add_argument(
|
|
"--dry-run", action="store_true",
|
|
help="Preview only — stop after showing what would be imported")
|
|
parser.add_argument(
|
|
"--overwrite", action="store_true",
|
|
help="Overwrite existing Hermes items on name conflicts (default: skip)")
|
|
add_yes_flag(parser, "Skip confirmation prompts")
|
|
parser.add_argument(
|
|
"--sync", action="store_true",
|
|
help="Re-import every previously imported source whose files changed since the last "
|
|
"import (registered in HERMES_HOME/import-sync.json). Runs without prompts; "
|
|
"combine with --dry-run to preview.")
|
|
parser.set_defaults(func=cmd_import_agent)
|