Skip to main content

Module rules_inject

Module rules_inject 

Source
Expand description

Rules + SKILL.md injection for every supported agent, split by concern (GL#440): content (payloads), targets (agent catalog), detect (installation checks), write (atomic file surgery), skills (SKILL.md). This hub owns the shared types and the orchestration entry points.

Content is delegated to core::rules_canonical — all rule text lives there as pub const sections. Markers (START_MARK, END_MARK, RULES_VERSION) are also re-exported from canonical.

Re-exports§

pub use crate::core::rules_canonical::END_MARK;
pub use crate::core::rules_canonical::RULES_VERSION;
pub use crate::core::rules_canonical::START_MARK;

Structs§

InjectResult
RulesTargetStatus

Constants§

GEMINI_DEDICATED_CONTEXT_FILENAME
The context.fileName entry registered for Gemini in dedicated mode.

Functions§

any_rules_marker_present
Returns true if a lean-ctx rules marker is present in any supported agent’s rules file.
canonical_rules_block
Forwarding functions — content is delegated to core::rules_canonical.
check_rules_freshness
Check if the rules file for a given MCP client is up-to-date.
collect_rules_status
cursor_mdc_document
Wrap a rendered rules body in the Cursor mdc frontmatter. The description stays profile-neutral: whether native tools are replaced (Dedicated) or hook-covered (GL #1153) is stated by the body itself.
expected_blocks_by_target
The canonical rules block lean-ctx would write for each target, keyed by the target’s display name.
gemini_dedicated_rules_path
host_guidance_present
Whether lean-ctx setup has left guidance for any host: a rules target, or the instruction-file block of a host that has no rules target (Claude Code’s CLAUDE.md, CodeBuddy’s CODEBUDDY.md, #555). The “run setup” tip needs this wider check: any_rules_marker_present alone never sees a Claude-only installation.
inject_all_rules
inject_rules_for_agent
Inject global rules for a single agent (by CLI key like “opencode”, “cursor”, etc.).
inject_rules_where
inject_all_rules restricted to the agents allows admits (by agent key).
install_all_skills
Install SKILL.md for all detected agents. Returns Vec<(display_name, was_new_or_updated)>.
install_skill_for_agent
Install SKILL.md for a specific agent. Returns the installed path.
install_skills_where
install_all_skills restricted to the agents allows admits.
opencode_dedicated_rules_path
planned_rules_files
Rules files a setup run would write for the agents allows admits: the installed tools’ targets plus the Claude Code pointer block. Writes nothing. The real run additionally skips tools whose MCP entry is missing (GH #1435).
planned_skill_files
SKILL.md files a setup run would write for the agents allows admits. Writes nothing.
rules_dedicated_markdown
rules_longform_markdown
Long-form rules for the on-demand project LEAN-CTX.md (#578). Same config-driven shadow/compression handling as the dedicated render, but the LONGFORM profile with the verbose teaching sections.
rules_shared_content