Expand description
Collapse duplicated lean-ctx guidance (#578): the planner and fixer behind
lean-ctx rules dedup, setup, doctor --fix and the hook refresh.
A client should pay for lean-ctx rules exactly once per session. Older
installs (and parent-directory walks in monorepos) left full rule copies
in several auto-loaded files; doctor overhead detects the duplication,
this module repairs it:
- lean-ctx-OWNED dedicated rule files outside the canonical global
location (project/parent
.cursor/rules/lean-ctx.mdc,.claude/rules/lean-ctx.md, …) → deleted. .cursorruleslean-ctx blocks → removed when the canonical global Cursor mdc exists (Cursor auto-loads both; pointer lives in AGENTS.md).- Stale compression blocks in
.cursorrules→ removed under the same condition (the global mdc carries the block). - Compression block in a shared
AGENTS.md(#684) → removed (pointer kept) once every AGENTS.md reader is covered by its own canonical carrier; otherwise reported and left as the carrier.
Only lean-ctx-owned files and lean-ctx-marked blocks are ever touched.
Unmarked user content is reported, never modified. Default is a dry-run
report; --apply executes with .bak backups for partial edits.
Enums§
- Action
- One planned dedup action.
Functions§
- apply
- Executes one action. Returns a human-readable result line.
- auto_
apply - Non-interactive auto-heal used by
lean-ctx setupanddoctor --fix(#578): applies every fixable dedup action (owned duplicates deleted, marked blocks stripped with.bakbackups) and returns one result line per action.Report-only findings (user-maintained content) are never touched. - plan
- Plans the dedup for
project(walking parents up to, excluding,home). - retire_
rules_ file - Retire a lean-ctx rules file that duplicates a host’s single rules channel
(A3): a wholly lean-ctx-owned file is deleted; a file a user extended keeps
every line outside the lean-ctx markers (backup at
<file>.bak). Returns a result line when something changed. Shared bysetup/initwriters andrules dedup, so no path ever deletes user text.