@mariozechner/pi-coding-agent 0.28.0 → 0.29.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -186,7 +186,7 @@ interface ToolSessionEvent {
186
186
  entries: SessionEntry[]; // All session entries
187
187
  sessionFile: string | null; // Current session file
188
188
  previousSessionFile: string | null; // Previous session file
189
- reason: "start" | "switch" | "branch" | "clear";
189
+ reason: "start" | "switch" | "branch" | "new";
190
190
  }
191
191
  ```
192
192
 
@@ -194,7 +194,7 @@ interface ToolSessionEvent {
194
194
  - `start`: Initial session load on startup
195
195
  - `switch`: User switched to a different session (`/resume`)
196
196
  - `branch`: User branched from a previous message (`/branch`)
197
- - `clear`: User cleared the session (`/clear`)
197
+ - `new`: User started a new session (`/new`)
198
198
 
199
199
  ### State Management Pattern
200
200
 
@@ -250,7 +250,7 @@ const factory: CustomToolFactory = (pi) => {
250
250
  This pattern ensures:
251
251
  - When user branches, state is correct for that point in history
252
252
  - When user switches sessions, state matches that session
253
- - When user clears, state resets
253
+ - When user starts a new session, state resets
254
254
 
255
255
  ## Custom Rendering
256
256
 
package/docs/hooks.md CHANGED
@@ -125,10 +125,10 @@ user switches session (/resume)
125
125
  ├─► session (reason: "before_switch", can cancel)
126
126
  └─► session (reason: "switch", AFTER switch)
127
127
 
128
- user clears session (/clear)
128
+ user starts new session (/new)
129
129
 
130
- ├─► session (reason: "before_clear", can cancel)
131
- └─► session (reason: "clear", AFTER clear)
130
+ ├─► session (reason: "before_new", can cancel)
131
+ └─► session (reason: "new", AFTER new session starts)
132
132
 
133
133
  context compaction (auto or /compact)
134
134
 
@@ -151,12 +151,12 @@ pi.on("session", async (event, ctx) => {
151
151
  // event.entries: SessionEntry[] - all session entries
152
152
  // event.sessionFile: string | null - current session file (null with --no-session)
153
153
  // event.previousSessionFile: string | null - previous session file
154
- // event.reason: "start" | "before_switch" | "switch" | "before_clear" | "clear" |
154
+ // event.reason: "start" | "before_switch" | "switch" | "before_new" | "new" |
155
155
  // "before_branch" | "branch" | "before_compact" | "compact" | "shutdown"
156
156
  // event.targetTurnIndex: number - only for "before_branch" and "branch"
157
157
 
158
158
  // Cancel a before_* action:
159
- if (event.reason === "before_clear") {
159
+ if (event.reason === "before_new") {
160
160
  return { cancel: true };
161
161
  }
162
162
 
@@ -171,7 +171,7 @@ pi.on("session", async (event, ctx) => {
171
171
  **Reasons:**
172
172
  - `start`: Initial session load on startup
173
173
  - `before_switch` / `switch`: User switched sessions (`/resume`)
174
- - `before_clear` / `clear`: User cleared the session (`/clear`)
174
+ - `before_new` / `new`: User started a new session (`/new`)
175
175
  - `before_branch` / `branch`: User branched the session (`/branch`)
176
176
  - `before_compact` / `compact`: Context compaction (auto or `/compact`)
177
177
  - `shutdown`: Process is exiting (double Ctrl+C, Ctrl+D, or SIGTERM)
@@ -848,9 +848,9 @@ Session switch:
848
848
 
849
849
  Clear:
850
850
  -> AgentSession.reset()
851
- -> hookRunner.emit({ type: "session", reason: "before_clear", ... }) # can cancel
852
- -> [if not cancelled: clear happens]
853
- -> hookRunner.emit({ type: "session", reason: "clear", ... })
851
+ -> hookRunner.emit({ type: "session", reason: "before_new", ... }) # can cancel
852
+ -> [if not cancelled: new session starts]
853
+ -> hookRunner.emit({ type: "session", reason: "new", ... })
854
854
 
855
855
  Shutdown (interactive mode):
856
856
  -> handleCtrlC() or handleCtrlD()
@@ -10,7 +10,7 @@ import type { HookAPI } from "@mariozechner/pi-coding-agent/hooks";
10
10
  export default function (pi: HookAPI) {
11
11
  pi.on("session", async (event, ctx) => {
12
12
  // Only handle before_* events (the ones that can be cancelled)
13
- if (event.reason === "before_clear") {
13
+ if (event.reason === "before_new") {
14
14
  if (!ctx.hasUI) return;
15
15
 
16
16
  const confirmed = await ctx.ui.confirm(
@@ -10,7 +10,7 @@ import type { HookAPI } from "@mariozechner/pi-coding-agent/hooks";
10
10
  export default function (pi: HookAPI) {
11
11
  pi.on("session", async (event, ctx) => {
12
12
  // Only guard destructive actions
13
- if (event.reason !== "before_clear" && event.reason !== "before_switch" && event.reason !== "before_branch") {
13
+ if (event.reason !== "before_new" && event.reason !== "before_switch" && event.reason !== "before_branch") {
14
14
  return;
15
15
  }
16
16
 
@@ -36,11 +36,7 @@ export default function (pi: HookAPI) {
36
36
  const changedFiles = stdout.trim().split("\n").filter(Boolean).length;
37
37
 
38
38
  const action =
39
- event.reason === "before_clear"
40
- ? "clear session"
41
- : event.reason === "before_switch"
42
- ? "switch session"
43
- : "branch";
39
+ event.reason === "before_new" ? "new session" : event.reason === "before_switch" ? "switch session" : "branch";
44
40
 
45
41
  const choice = await ctx.ui.select(`You have ${changedFiles} uncommitted file(s). ${action} anyway?`, [
46
42
  "Yes, proceed anyway",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mariozechner/pi-coding-agent",
3
- "version": "0.28.0",
3
+ "version": "0.29.0",
4
4
  "description": "Coding agent CLI with read, bash, edit, write tools and session management",
5
5
  "type": "module",
6
6
  "piConfig": {
@@ -38,9 +38,9 @@
38
38
  "prepublishOnly": "npm run clean && npm run build"
39
39
  },
40
40
  "dependencies": {
41
- "@mariozechner/pi-agent-core": "^0.28.0",
42
- "@mariozechner/pi-ai": "^0.28.0",
43
- "@mariozechner/pi-tui": "^0.28.0",
41
+ "@mariozechner/pi-agent-core": "^0.29.0",
42
+ "@mariozechner/pi-ai": "^0.29.0",
43
+ "@mariozechner/pi-tui": "^0.29.0",
44
44
  "chalk": "^5.5.0",
45
45
  "cli-highlight": "^2.1.11",
46
46
  "diff": "^8.0.2",