feat(pi): wire project-context loader into system prompt (Unit A) - #8
Merged
Conversation
Add a pure loader that walks from cwd up to filesystem root, collects AGENTS.md and CLAUDE.md at each ancestor, and emits them in root-to-cwd order with per-file (32 KiB) and total (128 KiB) budgets. Feed the result to expert_persona.buildSystemPromptWithContext so the live Anthropic backend sees workspace context alongside the compiler snapshot, guarded by the existing prompt-injection delimiters. Plan: /Users/srdjans/.claude/plans/study-the-plan-provided-clever-wadler.md Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
srdjan
added a commit
that referenced
this pull request
Jul 12, 2026
… caching, Sonnet default, exit codes Wave 1 of the expert-analysis recommendations (#1, #2, #4, #5, #8). #1 Make the retry loop information-complete. The `.run_veto` arm now records the model's draft as an `apply_edit` tool_use and closes it with the compiler verdict as a tool_result (session-unique id keyed on transcript index). On a failure the tool_result carries the diagnostic + SQL escalation and the compiler-authored repair block is persisted as a follow-up system_note, so the whole retry context lives in the transcript instead of a transient `extra_user_text` that a mid-repair tool call would erase. Drops `diag_history` re-accumulation; `.retry_draft` now sends only a short framing nudge. Adds a regression test proving the failed draft + diagnostic survive a tool interleave. #2 Raise the per-turn wall-clock timeout 60s -> 300s (the recorded convergence for complex handlers ran 80-96s) and drop the eval harness's `turn_timeout_ms=0` override so measurement and production share one options struct. #4 Add a rolling cache breakpoint on the last message block so the conversation prefix hits the prompt cache instead of re-paying full input price every roundtrip. #5 Flip the default model claude-haiku -> claude-sonnet-4-6 (the measured 7/7 first-draft baseline); Haiku stays available via `--model` and the harness's ZIGTTP_CODEGEN_MODEL knob. Docs updated. #8 Outcome-bearing `--print` exit codes: 0 applied/clean, 1 hard error, 2 veto-exhausted, 3 budget, 4 approval-denied. Documented in the user guide. Also lands the OpenAI honest-demotion doc note (#7, docs portion). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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.
Summary
packages/pi/src/context/loader.zigwithloadProjectContext(allocator)that walks cwd -> root, collectsAGENTS.mdandCLAUDE.mdat each ancestor, and emits them in root-to-cwd order (outermost first, cwd last; within a directory AGENTS.md precedes CLAUDE.md).readFileCappedso large files never allocate beyond the cap.agent.zig::initFromEnvWithRegistryso the live Anthropic backend receives workspace context alongside the compiler snapshot, passed throughexpert_persona.buildSystemPromptWithContextwhich already applies the prompt-injection delimiters and data-not-instructions guardrail.packages/pi/src/tests.zig.Plan:
/Users/srdjans/.claude/plans/study-the-plan-provided-clever-wadler.md(Batch 2, Unit A).Test plan
zig build test-expert-app— new tests in loader.zig passzig build test— full suite greenzig build— clean compileprintf 'help\nquit\n' | timeout 10 ./zig-out/bin/zigts expert— prints/verifyandRegistered tools:printf '/meta\nquit\n' | timeout 10 ./zig-out/bin/zigts expert— prints"compiler_version"Loader tests cover: returns null on empty tree, reads single AGENTS.md, nested root-to-cwd ordering with AGENTS.md-before-CLAUDE.md, per-file truncation marker when a 64 KiB file is fed in, and combined-budget truncation marker when 6x30 KiB files are stacked. Tests use a
/tmp-rooted scratch dir rather thanstd.testing.tmpDirso the walker doesn't pick up this repo's own AGENTS.md / CLAUDE.md.🤖 Generated with Claude Code