Returns the project root for file_path, falling back to cwd if none found.
Outside a request, checks LEAN_CTX_PROJECT_ROOT env var and config.toml
project_root first.
Logs a warning when the fallback is a broad directory (home, root).
Returns the file name component of a path for compact display.
Normalize a path for display by converting Windows backslashes to forward
slashes. Forward slashes are valid path separators on Windows, and unlike
backslashes they are never misinterpreted as escape sequences by the JSON,
markdown, or terminal layers of MCP clients — which corrupted Windows paths
in tool output (e.g. C:\Users\… rendered as CUsers…). See issue #324.
Generates the INSTRUCTION CODES block for agent system prompts.
Only emits content when the instructions being built are in Tdd CRP mode
(otherwise returns empty — the codes are only emitted in tdd outputs, so
defining them would waste ~60 tokens per MCP instructions payload, #579).
True inside a request that is bound to no project: project-keyed writes
are refused there (project_unresolved, AP01 §3) instead of keying them
on a file’s location.