refactor(coding-agent): replace AgentSessionRuntimeHost with closure-based AgentSessionRuntime
- Replace AgentSessionRuntimeHost and bootstrap abstractions with AgentSessionRuntime - Runtime creation is now closure-based via CreateAgentSessionRuntimeFactory - Factory closes over process-global fixed inputs, recreates cwd-bound services per effective cwd - Session config (model, thinking, tools, scoped models) re-resolved per target cwd - CLI resource paths resolved once at startup as absolute paths - Swap lifecycle: teardown old, create next, apply next (hard fail on creation error) - Unified diagnostics model (info/warning/error) for args, services, session resolution, resources - No logging or process exits inside creation/parsing logic - Removed session_directory support - Removed session_switch and session_fork extension events (use session_start with reason) - Moved package/config CLI to package-manager-cli.ts - Fixed theme init for --resume session picker - Fixed flaky reftable footer test (content-based polling) - Fixed silent drop of unknown single-dash CLI flags - Added error diagnostics for missing explicit CLI resource paths - Updated SDK docs, examples, plans, exports, tests, changelog fixes #2753
This commit is contained in:
@@ -226,9 +226,8 @@ Run `npm install` in the extension directory, then imports from `node_modules/`
|
||||
### Lifecycle Overview
|
||||
|
||||
```
|
||||
pi starts (CLI only)
|
||||
pi starts
|
||||
│
|
||||
├─► session_directory (CLI startup only, no ctx)
|
||||
├─► session_start { reason: "startup" }
|
||||
└─► resources_discover { reason: "startup" }
|
||||
│
|
||||
@@ -311,27 +310,6 @@ pi.on("resources_discover", async (event, _ctx) => {
|
||||
|
||||
See [session.md](session.md) for session storage internals and the SessionManager API.
|
||||
|
||||
#### session_directory
|
||||
|
||||
Fired by the `pi` CLI during startup session resolution, before the initial session manager is created.
|
||||
|
||||
This event is:
|
||||
- CLI-only. It is not emitted in SDK mode.
|
||||
- Startup-only. It is not emitted for later interactive `/new` or `/resume` actions.
|
||||
- Lower priority than `--session-dir` and `sessionDir` in `settings.json`.
|
||||
- Special-cased to receive no `ctx` argument.
|
||||
|
||||
If multiple extensions return `sessionDir`, the last one wins.
|
||||
Combined precedence is: `--session-dir` CLI flag, then `sessionDir` in settings, then extension `session_directory` hooks.
|
||||
|
||||
```typescript
|
||||
pi.on("session_directory", async (event) => {
|
||||
return {
|
||||
sessionDir: `/tmp/pi-sessions/${encodeURIComponent(event.cwd)}`,
|
||||
};
|
||||
});
|
||||
```
|
||||
|
||||
#### session_start
|
||||
|
||||
Fired when a session is started, loaded, or reloaded.
|
||||
@@ -759,9 +737,7 @@ Transforms chain across handlers. See [input-transform.ts](../examples/extension
|
||||
|
||||
## ExtensionContext
|
||||
|
||||
All handlers except `session_directory` receive `ctx: ExtensionContext`.
|
||||
|
||||
`session_directory` is a CLI startup hook and receives only the event.
|
||||
All handlers receive `ctx: ExtensionContext`.
|
||||
|
||||
### ctx.ui
|
||||
|
||||
|
||||
Reference in New Issue
Block a user