- project_map_reinit now regenerates only the target subtree + ancestors by default, falling back to full reinit when subtree file count exceeds reinitFullThresholdPercent (default 10%). - Add reinitFullThresholdPercent config option. - Expose fix=true on project_map_validate Pi tool for localized repair. - Update docs and runtime guidance to prefer patch / validate --fix before full reinit. - Add integration tests for smart reinit and update typebox mock.
5.6 KiB
Troubleshooting pi-project-map
Stale map issues
Symptom
project_map_validate reports missing, orphaned, or stale-signature discrepancies, or a directory map describes files that no longer exist.
Likely cause
A source file was edited, added, or deleted without running project_map_patch or project_map_reinit.
What to do
- run
project_map_validateto inspect discrepancies - if the list is small and localized, run
project_map_patch <changed-file>orproject_map_validatewithfix=true - if the list is large or structural, run
project_map_reinit - re-run
project_map_validateto confirm clean state
Prevention
- patch immediately after editing source
- in Pi, use the
project_map_patchtool with the changed file path - watch for the
session_startdirty warning
Validate discrepancies
Symptom
validate --fix fails with validate --fix requires an LLM client.
Cause
Repair needs an LLM client to regenerate stale artifacts.
Fix
- CLI: provide
--llm-provider=...and the required API key - Pi: use the tool surface so the runtime provides the LLM client
Symptom
Many stale-signature discrepancies appear.
Cause
AST exports no longer match listed exports, or generated signatures are stale.
Fix
- patch the changed file/directory, or run
project-map validate --fix - if widespread, reinit and validate again
Symptom
broken-link appears after moving directories.
Fix
Run project-map validate --fix first. If the damage spans many directories, run project_map_reinit.
Prompt injection mode surprises
Symptom
No project-map context appears in a Pi session.
Checks before init
- confirm
.pi-project-map.jsondoes not setpromptInjectionModetooff - confirm root
.pi-map.md/.pi-map.index.mddo not exist yet - confirm the session is at agent start; the pre-init hint is emitted from
before_agent_start
Checks after init
- confirm root
.pi-map.mdand.pi-map.index.mdexist - confirm mode is
strongorstrictif you expect automatic artifact injection - confirm the outgoing context does not already contain the root-pair marker
- confirm the turn is actually relevant (
agent_start,edit_intent,architecture_sensitive,compaction,artifact_change)
Symptom
Root pair is injected repeatedly.
Likely cause
Marker scanning failed or artifact invalidation forced reinjection, often because project_map_reinit is being used instead of project_map_patch or project_map_validate --fix.
Fix
- inspect whether
<!-- PI_MAP_ROOT_PAIR_START -->is present in outgoing context - check whether root artifacts changed on disk
- confirm payload/message serialization still exposes marker text
- prefer
project_map_patch <file>for edits andproject_map_validatewithfix=truefor localized discrepancies
Symptom
advisory mode shows a reminder but no maps are loaded.
Expected behavior
That is intentional. Advisory mode is reminder-only; read the root pair manually.
Strict bypass confusion
Symptom
A sensitive edit is blocked with the strict guard.
What is happening
In strict mode, the turn was classified as sensitive and the protocol path is missing from outgoing context.
Resolution options
- restore the protocol path by ensuring the root pair and trust boundary are present in context
- include an explicit bypass marker:
[PI_MAP_BYPASS: emergency fix needed without full context]
- switch to
strongmode if strict is too noisy for the task
Symptom
Bypass marker is ignored.
Cause
The marker must contain a non-empty reason. Empty or whitespace-only reasons are rejected.
Symptom
Strict guard triggers on obviously non-sensitive turns.
Cause
Heuristic sensitive-turn detection can false-positive on words like refactor, redesign, or dependency graph.
LLM / provider / cache issues
Symptom
project-map init fails with No LLM client configured.
CLI fix
- set
OPENAI_API_KEYfor OpenAI provider - set
KIMI_API_KEYfor Kimi provider - or configure provider/model in
.pi-project-map.json
Pi fix
- select a model in Pi
- log in if the provider requires credentials
- ensure Pi runtime LLM access is working
Symptom
External/provider request fails.
Checks
- API key validity
- network connectivity
llmBaseUrlcorrectness if using a proxy- provider rate limits
Symptom
Second init still makes many LLM calls.
Cause
Cache miss.
Checks
- consistent cache directory between runs
- cache file exists and is readable
- file contents did not change
Symptom
Cache file is huge.
Cause
There is no eviction policy yet.
Fix
Remove the local cache directory if needed.
Test / lint expectations
Main checks
npm test
npm run typecheck
npm run build
node dist/cli.js validate .
Lint note
npm run lint is currently not a reliable gate if the repo has no ESLint config. Treat missing-lint-config failures as repository hygiene issues, not feature regressions.
Common failures
| Failure | Likely cause |
|---|---|
| Pi LLM client tests fail | Pi runtime or mocks drifted |
| Prompt-injection sequence tests fail | Reinjection / strict logic changed |
| Validate tests fail | Format parsing, merge encoding, or discovery rules changed |
| AST tests fail | tree-sitter grammar/runtime drift |
Known limitations
- token budgeting is heuristic, not tokenizer-exact
- retrieval is deterministic, not semantic-search-driven
- strict mode is a prompt-level guard, not a hard tool sandbox
- payload scanning assumes string or JSON-serializable structures