Repository navigation
fix(pi-cursor-agent): Parse context files from Pi 0.85+ project_context format - #34
Open
david-torres wants to merge 1 commit into
Open
david-torres wants to merge 1 commit into
david-torres wants to merge 1 commit into
Conversation
…xt format Pi 0.85 changed how context files (AGENTS.md / CLAUDE.md) are embedded in the system prompt: the legacy '# Project Context' heading with '## /abs/path' sections was replaced by <project_context>/<project_instructions path="..."> XML blocks (see core/system-prompt.js in pi 0.85.1). The bridge parser only knew the legacy format, so context file extraction returned nothing. Because skills still extracted successfully, hasExtracted stayed true and cleanedPrompt discarded the rest of the prompt — silently dropping every AGENTS.md instead of injecting them as cursor rules (sudosubin#11, sudosubin#12). Parse the new XML format first and fall back to the legacy heading format for older Pi versions.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Pi 0.85 changed how context files (
AGENTS.md/CLAUDE.md) are embedded in the system prompt. The legacy format:was replaced by XML blocks (
core/system-prompt.jsin pi 0.85.1):The bridge parser (
src/bridge/pi-context/parser.ts) only recognizes the legacy# Project Contextheading, so context file extraction now returns nothing. The failure is silent and worse than a no-op: the<available_skills>marker survived the format change, so skills still extract,hasExtractedstays true, andcleanedPromptstrips everything except the preserved metadata lines — the context files are dropped entirely rather than passed through in the prompt. The feature added in #12 (for #11) effectively regressed to 'AGENTS.md is never delivered' for anyone on current Pi.Fix
Parse the new XML format first and fall back to the legacy heading format for older Pi versions. Path and content trimming and the empty-check match the legacy behavior.
cleanedPrompthandling is unchanged and correctly strips the XML block once extraction succeeds (covered by a new test).Tests
extracts context files from Pi 0.85+ XML formatXML format preserves markdown headings inside context file content— content containing# Project Context/## /not/a/filelines stays intact (the legacy splitter would have mangled it)cleanedPrompt strips XML-format context blockAll existing legacy-format tests unchanged and passing (37/37),
tscandbiome checkclean. Also verified manually against the exact promptbuildSystemPromptin pi 0.85.1 produces for a real repo with global + project AGENTS.md: both files extract with byte-identical content.Longer term it may be worth asking Pi for structured access to context files at the provider boundary instead of re-parsing the rendered prompt — happy to open a follow-up issue if useful.