Skip to content

feat: add pi-coding-agent integration#251

Closed
bytes032 wants to merge 3 commits intoentireio:mainfrom
bytes032:pi-integration
Closed

feat: add pi-coding-agent integration#251
bytes032 wants to merge 3 commits intoentireio:mainfrom
bytes032:pi-integration

Conversation

@bytes032
Copy link
Copy Markdown

@bytes032 bytes032 commented Feb 11, 2026

Summary

This PR finalizes PI integration on top of Entire’s generic lifecycle architecture while preserving PI-specific tree transcript behavior.

PI now follows the same integration flow as Claude/Gemini:

ParseHookEvent() -> Event -> DispatchLifecycleEvent()

PI-specific differences (tree branches + extension hooks) remain intentional.

What Changed

1. PI lifecycle mapping on new architecture

  • session-start -> SessionStart
  • user-prompt-submit -> TurnStart
  • stop -> TurnEnd
  • before-compact -> Compaction
  • session-end -> SessionEnd
  • leaf_id from PI stop is captured and persisted for active-branch correctness.

2. PI tree-aware transcript behavior preserved

  • Active-branch (leaf-aware) extraction is retained for:
  • prompts
  • modified files
  • token usage
  • summary extraction
  • Leaf hints are persisted so post-hoc reads resolve the correct branch.

3. PI hook robustness improvements

  • Added non-blocking timeout protection for hook subprocess execution.
  • Improved session_switch / session_fork previous-session end handling by deriving prior session ID from previousSessionFile when needed.

4. Hook registration parity

  • PI implements HookHandler (GetHookNames) so entire hooks pi <verb> subcommands are registered consistently like other agents.

5. PI-aware condensation correctness

  • Condensation paths now use PI leaf context so prompt/token/summary/context extraction is scoped to the active branch.
  • This avoids reading abandoned branches from append-only tree transcripts.

6. PI-only stop flush mitigation

  • On stop, PI now waits briefly (best-effort, bounded) for transcript flush/non-empty content before emitting TurnEnd.
  • This is PI-only and does not alter shared core lifecycle behavior.

Why these changes are needed

Without these fixes, PI metadata can drift in branched sessions:

  • prompts/context from abandoned branches
  • token overcount across non-active branches
  • summary mismatch vs active branch
  • checkpoint metadata not matching user-visible branch state

Known Limitation + Strict Core Fix Path

Current limitation (shared core behavior):

  • turn-end full-transcript finalize remains best-effort
  • if finalize fails at turn-end, a checkpoint may retain provisional transcript content

How to make this strict (core change, not in this PR):

  1. Do not clear pending TurnCheckpointIDs when finalize fails.
  2. Retry UpdateCommitted on subsequent safe lifecycle points (TurnEnd / SessionEnd).
  3. Clear pending IDs only after successful full-transcript update.

This would provide eventual full-transcript consistency as a hard guarantee.

PI-Specific Differences (Intentional)

  • PI uses extension-based hook integration (.pi/extensions/entire/index.ts), not JSON settings-based hook registration like Claude/Gemini.
  • This is intentional and matches PI’s native extension model.

Validation

  • go test ./cmd/entire/cli/agent/pi ./cmd/entire/cli/summarize ./cmd/entire/cli/strategy
  • go test ./cmd/entire/cli/...
  • All passing.

@bytes032 bytes032 requested a review from a team as a code owner February 11, 2026 12:38
@bytes032
Copy link
Copy Markdown
Author

@Soph @gtrrz-victor @khaong this should be ready for review

@khaong
Copy link
Copy Markdown
Contributor

khaong commented Feb 17, 2026

Thanks for putting this together! We're currently reworking the agent interface (#281) to make integrations simpler and more consistent, so we're holding agent PRs until that lands — otherwise a lot of this would need to be redone against the new interface.

We'll update #281 when it's ready for contributions.

@khaong khaong added on-hold Blocked on other work agent-support adding support for additional AI agents competing-pr Multiple PRs addressing the same thing — needs team decision labels Feb 17, 2026
@bytes032 bytes032 closed this Mar 31, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agent-support adding support for additional AI agents competing-pr Multiple PRs addressing the same thing — needs team decision on-hold Blocked on other work

Development

Successfully merging this pull request may close these issues.

2 participants