## Is the Entire CLI injecting anything in the start of this session and if not, why? investigate.

### Evidence:

- Current session: `019edc3a-aed0-7e9f-977d-e77ce53ecc1f`, agent type `Pi`.

- Entire hooks did fire (`session-start`, `turn-start`) per `.entire/logs/entire.log`.

- Session state shows Entire made the once-per-session decision:

```
1

"context_injection_decided": true
```

- But the Pi transcript has no `entire-context`, `inject_context`, or the expected injected text:

> `A trail ties together the context for a branch...`

### Why not:

1. **Entire does not inject on `SessionStart` for Pi.**
   
   Pi injection is wired to `TurnStart` / `before_agent_start`, not session creation.

2. **The trail-context gate is false for this clone.**
   
   `emitContextInjection()` only emits the payload if `trailsEnabledForRepo(ctx)` is true. That reads `.git/entire/preferences.json`, and this file has no `trails_enabled` value, so the function returns false. The code intentionally marks `context_injection_decided` before that check, so it fails closed and won’t retry/spam later.

3. **Also, the installed Pi extension is stale.**
   
   `.pi/extensions/entire/index.ts` currently ignores hook stdout. The source template now parses `{"inject_context": ...}` and returns a hidden `entire-context` message, but the installed extension does not. So even if Entire emitted injection stdout, this installed extension would not apply it until refreshed.

### Summary:
   
Entire tracked the session, but did not inject model context into this run. Refreshing the Pi hook extension (`entire configure --agent pi` / re-enable) and having `trails_enabled` cached true would be required for that injection path to work.

---

### Additional Actions

- Checked out latest `main`: `92154228dc32`
- Fast-forwarded from `origin/main`
- Rebuilt/installed `entire` into `~/.local/bin`
- Refreshed the Pi extension so it now parses `inject_context`
- Cached `trails_enabled: true`
- Reset this session’s failed `context_injection_decided` flag

> Note: working tree now has one generated config change:
```
M .pi/extensions/entire/index.ts
```
You may need to start a new Pi session for the updated extension file to be loaded.

---

### Refresh Requirements

No, not every agent.  
You only need to refresh agents whose **repo-local generated integration code** must learn how to consume the injection.

- **Pi:** yes, needed refresh. Its `.pi/extensions/entire/index.ts` had stale code that ignored hook stdout.
- **OpenCode:** likely same class — generated plugin may need refresh if installed before injection support.
- **Claude Code / Codex / Gemini:** usually no refresh needed if hooks are already installed. Their hooks call the `entire` binary; updating the binary is enough because injection is emitted by `entire hooks ...`.
- **Agents without `ContextInjector` support:** won’t get this model-context injection regardless.

Also: injection is **once per session** and gated by `trails_enabled`. Future sessions should work now. Existing sessions that already recorded `context_injection_decided: true` won’t retry unless that flag is cleared.

The text you pasted:
> A trail ties together the context for a branch...

is exactly the injection payload, so it looks like the refreshed Pi path is now working.

---

### Pull Requests Created

- CLI: [https://github.com/entireio/cli/pull/1469](https://github.com/entireio/cli/pull/1469)
- entire.io: [https://github.com/entirehq/entire.io/pull/2449](https://github.com/entirehq/entire.io/pull/2449)

> Note: I used a separate `../entire.io-pi-update` worktree so the existing dirty `../entire.io` checkout was left untouched.

### Commit Details

[9ea2071Update Pi extension for context injection

Entire-Checkpoint: ee09419b55ce+40/-5](/content/gh/entireio/cli/commit/9ea20713ad3c762e1ac2954fc2601c34682b34ce/index.html)
