Skip to main content

Module paths

Module paths 

Source
Expand description

Trusty Code’s own configuration and state layout (#5426, epic #2892).

Why: every discovery site used to join the literal .claude/ itself, which made another product’s directory the source of truth for this one and left nothing stopping a write INTO it. #5426 makes <project>/.trusty-code/ the read-preferred and write-only location, with .claude/ (and .open-mpm/) demoted to compatibility inputs. What: resolve_project_entry (the one precedence rule: .trusty-code → .claude → .open-mpm, then a native default) plus the per-entry agents_dir/skills_dir/plugins_dir/settings_file wrappers; native_config_dir/check_native_write_target (the write boundary, symlink escapes included); private_state (~/.trusty-code/, mode 0700); and import (the deterministic, non-overwriting .claude/ import). Test: paths::tests::*, paths::private_state::private_state_tests::*, paths::import::import_tests::*. Trusty Code’s own configuration and state layout (#5426, epic #2892).

Why: every discovery site in this crate hard-coded .claude/ — the agents directory, the skills directory, the plugin tree, settings.json, and the project context file each joined that literal themselves. That made Claude Code’s directory the source of truth for a product that is not Claude Code: a clean project could not install or run without a .claude/ tree, and nothing stopped Trusty Code writing INTO another product’s directory. #5426 inverts the relationship. <project>/.trusty-code/ is where Trusty Code reads and — critically — the ONLY place it writes; .claude/ (and the older .open-mpm/) stay readable as compatibility INPUTS, never as write targets.

What: one resolver, resolve_project_entry, that every discovery site calls instead of joining a literal. It walks SEARCH_ROOTS in order and reports the winning source (ConfigSource) alongside the path, so diagnostics can answer “which directory won, and what else was tried?” without re-deriving the rule. native_config_dir and check_native_write_target are the write half: a path that is not beneath <project>/.trusty-code/ — including one that reaches outside it through a symlink — is refused rather than written. private_state owns the private mutable half (~/.trusty-code/, mode 0700), and import owns the deterministic, non-overwriting legacy import from .claude/.

Precedence, and where it is documented. The order is .trusty-code/ → .claude/ → .open-mpm/, then a default that names .trusty-code/ even when nothing exists yet. The operator-facing statement of that rule, including the fallback and warning behaviour, lives in the crate README — this module is its implementation, not a second specification.

Test: paths::tests::*, paths::private_state_tests::*, paths::import_tests::*.

Every link below is written as a crate::paths::… reference definition rather than a bare [name]. This module carries outer /// docs at its pub mod paths; declaration in lib.rs as well as these inner //! docs, and rustdoc resolves the merged block in the scope of its first fragment — the crate root — where none of these names exist. See #7001.

Modules§

import
Deterministic, reversible legacy import from .claude/ into .trusty-code/ (#5426, epic #2892).
private_state
Private mutable state beneath ~/.trusty-code/ (#5426, epic #2892).
write_dir
Pinned, symlink-refusing write handles beneath <project>/.trusty-code/ (#7779).

Structs§

ResolvedConfig
What a project-scoped lookup resolved to, and what it had to skip to get there.

Enums§

ConfigSource
Which configuration root a resolved path came from.
EntryKind
Whether a lookup targets a directory or a single file.
WriteTargetError
Why a candidate write target was refused.

Constants§

CLAUDE_COMPAT_DIRNAME
Claude Code’s project configuration directory name.
OPEN_MPM_LEGACY_DIRNAME
The pre-Claude-Code open-mpm configuration directory name.
SEARCH_ROOTS
The search order every project-scoped lookup walks, highest precedence first.
SECRET_KEY_EXEMPTIONS
Whole keys that name a COUNT rather than a credential.
SECRET_KEY_HINTS
Normalised key words whose presence marks a value as secret-bearing.
SETTINGS_FILENAME
The project-settings filename, shared by both configuration roots.
TRUSTY_CODE_DIRNAME
Trusty Code’s own project configuration directory name.

Functions§

agents_dir
The agents directory for a project root.
check_native_write_target
Refuse any write target that is not genuinely beneath <project>/.trusty-code/.
find_secret_key
Find the first secret-bearing key path in a JSON value, if any.
is_secret_key
Whether one JSON key names a credential.
native_child
A path beneath native_config_dir.
native_config_dir
Trusty Code’s own project configuration directory — the ONLY write target.
plugins_dir
The plugins directory for a project root.
resolve_project_entry
Resolve one project-scoped configuration entry across SEARCH_ROOTS.
settings_file
The settings.json file for a project root.
skills_dir
The skills directory for a project root.