SuperPi.Plugins.Rules (super_pi v0.1.0)

Copy Markdown View Source

Project & Agent Rules Plugin (SuperPi.Extension behaviour).

Implements rule loading and injection semantics:

  • Walks up from workspace directories to the repository root discovering AGENTS.md, GEMINI.md, and .agents/rules/*.md, plus global config rules (<global config>/AGENTS.md).
  • Deduplicates all rules by canonical resolved path so a rule file is never injected twice.
  • Enforces the Per-File Limit (24,000 bytes), truncating cleanly on line boundaries when a rule file exceeds 24,000 bytes.
  • Enforces the Aggregate Rules Budget (20,000 tokens / ~80,000 bytes): rules within budget are inlined as <RULE[path]> blocks inside a pi.system section (id: "user_rules"); over-budget rules are demoted to file-path pointers so the agent can read them on demand.

Summary

Functions

Formats discovered rule files under token_budget (20,000 tokens), demoting over-budget files to path pointers.

Truncates raw rule text to @per_file_byte_limit (24,000 bytes) on a line boundary.

Functions

build_rules_section(rule_paths, token_budget \\ 20000)

Formats discovered rule files under token_budget (20,000 tokens), demoting over-budget files to path pointers.

description()

id()

name()

truncate_rule_to_limit(content, max_bytes \\ 24000)

Truncates raw rule text to @per_file_byte_limit (24,000 bytes) on a line boundary.