feat: ship a global AGENTS.md via the global-agents extension #10
No reviewers
Labels
No labels
dependencies
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
alex/pi-shared!10
Loading…
Reference in a new issue
No description provided.
Delete branch "pi/issue9-1782836087"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
Removes the need to manually drop
~/.pi/agent/AGENTS.mdby shipping the global agent rules with this package. Afterpi install git:forge.l3x.in/alex/pi-shared, the rules are active in every session automatically.Fixes #9
How it works (the extensibility analysis)
Pi packages can declare
extensions,skills,prompts, andthemesin their manifest, but cannot ship a global context file. GlobalAGENTS.mdfiles are loaded only from the global agent dir (~/.pi/agent/AGENTS.md, vialoadProjectContextFiles) or from project ancestors — there is no package manifest key orresources_discoverreturn value for context files.The cleanest native way to close that gap is an extension that injects the rules into the system prompt through the
before_agent_starthook (returning{ systemPrompt }, the exact mechanism pi's ownexamples/extensions/claude-rules.tsuses).Changes
agents/AGENTS.md— the global rules content (sandbox Git env, "don't commit/push without permission", Markdown no-wrap policy).extensions/global-agents.ts— a new extension that:agents/AGENTS.mdrelative to itself viaimport.meta.url,session_start(so/newand/reloadpick up edits without a restart),<global_context>block, mirroring pi's own<project_context>context-file format."extensions": ["./extensions"]— nopackage.jsonchange needed.README.md— documents the feature and how to disable it (pi config→ disableglobal-agents, or filter insettings.json).Verification
tsc --stricttypecheck against the installed@earendil-works/pi-coding-agenttypes passes.session_start→ refreshes the cached rules without errorbefore_agent_start→ correctly appends the<global_context>block (860 chars) containing the rules to the base system prompt.To disable the rules:
pi config→ disableglobal-agents, or filter it out insettings.json(seedocs/packages.md"Package Filtering").