Skip to main content

Module cli

Module cli 

Source
Expand description

CLI layer — clap definitions + command dispatch.

Each subcommand is a separate module. The CLI layer:

  • Parses args into typed commands
  • Locates .agents/ root (walk up from cwd, or --root flag)
  • Calls library functions
  • Formats output (human-readable by default, --json for machine)
  • Maps MarsError to exit codes and stderr messages

Modules§

add
mars add <source> — add or update a source, then sync.
cache
mars cache — manage the global source cache.
check
mars check [PATH] — validate a source package before publishing.
doctor
mars doctor — validate state consistency.
init
mars init [TARGET] [--link DIR...] — scaffold a mars-managed directory with mars.toml.
link
mars link <dir> — symlink agents/ and skills/ into another directory.
list
mars list — show available agents and skills.
outdated
mars outdated — show available updates without applying.
output
Shared output formatting for CLI commands.
override_cmd
mars override — set a local dev override for a source.
remove
mars remove <source> — remove a source from config and prune its items.
rename
mars rename — rename a managed item.
repair
mars repair — rebuild state from lock + sources.
resolve_cmd
mars resolve — mark conflicts as resolved after user fixes them.
sync
mars sync — resolve + install (make reality match config).
upgrade
mars upgrade — upgrade sources to newest versions within constraints.
why
mars why <name> — explain why an item is installed.

Structs§

Cli
mars — agent package manager for .agents/
MarsContext
Resolved context for a mars command — both the managed root and its parent project root.

Enums§

Command

Constants§

TOOL_DIRS
Tool-specific directories that commonly need linking. Root detection searches these in addition to WELL_KNOWN. mars link warns if the target isn’t in TOOL_DIRS or WELL_KNOWN.
WELL_KNOWN
Directories where mars manages mars.toml as the primary root. These are the default target for mars init.

Functions§

dispatch
Dispatch a parsed CLI command to the appropriate handler and map errors to the final exit code.
find_agents_root
Find the mars-managed root by walking up from cwd, or use --root flag.
is_symlink
Check if a path is a symlink (uses symlink_metadata, doesn’t follow).