Finds the outermost project root by walking up from file_path.
For monorepos with nested .git dirs (e.g. mono/backend/.git + mono/frontend/.git),
returns the outermost ancestor containing .git, a workspace marker, or a known
monorepo config file — so the whole monorepo is treated as one project.
Returns the project root for file_path, falling back to cwd if none found.
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 CRP mode is Tdd (otherwise returns empty string
to avoid wasting ~80-100 tokens per MCP instructions payload).