Skip to main content

Module command_root

Module command_root 

Source
Expand description

The project a command-line invocation acts for, and the read boundary a command-line read enforces against it.

The root comes from --root/--project-root, then LEAN_CTX_PROJECT_ROOT (reconciled with the working directory, AP04-G10), then the git root above the working directory. Shared by the CLI commands, the daemon client and the shell-hook rewriters, so every entry point names the same project.

Functions§

cli_read_is_refused
Whether lean-ctx read <raw> from this process would be refused (#1903). Shell-hook rewriters keep such reads on the native command instead of turning a working cat into an access-denied error.
detect_project_root
The project this process acts for, from args and the working directory.
jail_cli_read_path
#1903: lean-ctx read enforces the same boundary as MCP ctx_read — the PathJail (project root + allow_paths/extra_roots/read_only_roots + the lean-ctx state dir) and the secret-path policy — with the same error text. A relative path is resolved against the process CWD (a shell user’s intent), never re-anchored at the project root. A broad root (home, /, agent config dir) is refused like lean-ctx call does, unless the jail is disabled (path_jail = false), because jailing to ~ would admit every file the user owns.
promote_to_git_root
require_project_root
The project a command that writes project-scoped state acts for; Err instead of ~, / or an agent directory (AP04-G10).