Skip to main content

Module import

Module import 

Source
Expand description

Deterministic, reversible legacy import from .claude/ into .trusty-code/ (#5426, epic #2892).

Why: switching discovery to .trusty-code/ would strand every project whose agents and skills live under .claude/. An import has to be observable before it runs (a plan), it must never overwrite a file the project author wrote, and it must be undoable — so it reports exactly which files it created, and nothing else.

What: plan_import walks .claude/agents/, .claude/skills/, and .claude/settings.json and produces a SORTED ImportPlan naming, for each source file, the target under .trusty-code/ and the ImportAction that would be taken. apply_import executes exactly that plan and returns an ImportReport listing the files it created. Determinism is what makes the dry run trustworthy: the same tree always yields the same plan in the same order, so --dry-run output and the real run cannot disagree.

Four refusals, all producing ImportAction::Refuse rather than an error that aborts the whole import:

  • the target already exists (never overwrite a user-authored file);
  • the source is, or reaches through, a symlink out of .claude/;
  • the source carries the executable bit (an imported executable would be trusted by every later .trusty-code/ consumer);
  • a settings.json whose JSON carries a secret-bearing key (super::find_secret_key).

Test: paths::import_tests::*.

Structs§

ImportEntry
One source file and the target it maps to.
ImportPlan
Everything an import would do, in a stable order.
ImportReport
What an applied import actually created, and what it declined.

Enums§

ImportAction
What an import would do with one source file.

Constants§

IMPORTED_SUBTREES
The .claude/ subtrees an import considers, in plan order.

Functions§

apply_import
Execute a plan, creating only the files it marked ImportAction::Copy.
plan_import
Build the import plan for a project root.