Skip to content

Commit 84b9f08

Browse files
committed
pi: rename /recap to /fold and /rewind to /drop
1 parent c700e2a commit 84b9f08

File tree

2 files changed

+49
-49
lines changed

2 files changed

+49
-49
lines changed

dotfiles/pi/.pi/agent/extensions/rewind.ts renamed to dotfiles/pi/.pi/agent/extensions/drop.ts

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,47 @@
11
/**
2-
* Rewind extension - quick recap using the last message as summary
2+
* Drop extension - quick fold using the last message as summary
33
*
44
* Commands:
5-
* /rewind - Navigate back to the last recap point (or session start),
6-
* using the last message as the branch summary instead of
7-
* generating one with the LLM.
5+
* /drop - Navigate back to the last fold point (or session start),
6+
* using the last message as the branch summary instead of
7+
* generating one with the LLM.
88
*
9-
* This is a fast, zero-cost alternative to /recap. Compatible with recap's
10-
* anchor system (uses the same "recap" label).
9+
* This is a fast, zero-cost alternative to /fold. Compatible with fold's
10+
* anchor system (uses the same "fold" label).
1111
*
1212
* Usage:
13-
* /rewind
13+
* /drop
1414
*/
1515

1616
import type { ExtensionAPI, SessionEntry } from "@mariozechner/pi-coding-agent";
1717

1818
export default function (pi: ExtensionAPI) {
19-
let pendingRewindSummary: string | null = null;
19+
let pendingDropSummary: string | null = null;
2020

2121
// Intercept tree navigation to provide the last message as summary
2222
pi.on("session_before_tree", async (_event, _ctx) => {
23-
if (pendingRewindSummary !== null) {
24-
const summary = pendingRewindSummary;
25-
pendingRewindSummary = null;
23+
if (pendingDropSummary !== null) {
24+
const summary = pendingDropSummary;
25+
pendingDropSummary = null;
2626
return { summary: { summary, details: {} } };
2727
}
2828
});
2929

30-
pi.registerCommand("rewind", {
31-
description: "Navigate back to last recap point using last message as summary",
30+
pi.registerCommand("drop", {
31+
description: "Navigate back to last fold point using last message as summary",
3232
handler: async (_args, ctx) => {
3333
if (!ctx.hasUI) {
34-
ctx.ui.notify("rewind requires interactive mode", "error");
34+
ctx.ui.notify("drop requires interactive mode", "error");
3535
return;
3636
}
3737

38-
// Find anchor: last recap marker or first entry
38+
// Find anchor: last fold marker or first entry
3939
const branch = ctx.sessionManager.getBranch();
4040
let anchorId: string | undefined;
4141

4242
for (const entry of branch) {
4343
const label = ctx.sessionManager.getLabel(entry.id);
44-
if (label === "recap") {
44+
if (label === "fold") {
4545
anchorId = entry.id;
4646
}
4747
}
@@ -52,7 +52,7 @@ export default function (pi: ExtensionAPI) {
5252
}
5353

5454
if (!anchorId) {
55-
ctx.ui.notify("No conversation to rewind", "error");
55+
ctx.ui.notify("No conversation to drop", "error");
5656
return;
5757
}
5858

@@ -66,7 +66,7 @@ export default function (pi: ExtensionAPI) {
6666
);
6767

6868
if (messageEntries.length === 0) {
69-
ctx.ui.notify("No messages to rewind", "error");
69+
ctx.ui.notify("No messages to drop", "error");
7070
return;
7171
}
7272

@@ -89,21 +89,21 @@ export default function (pi: ExtensionAPI) {
8989
}
9090

9191
// Store summary for session_before_tree handler
92-
pendingRewindSummary = text;
92+
pendingDropSummary = text;
9393

9494
// Navigate tree back to anchor with the last message as summary
9595
const navResult = await ctx.navigateTree(anchorId, {
9696
summarize: true,
97-
label: "recap",
97+
label: "fold",
9898
});
9999

100100
if (navResult.cancelled) {
101-
pendingRewindSummary = null;
101+
pendingDropSummary = null;
102102
ctx.ui.notify("Cancelled", "info");
103103
return;
104104
}
105105

106-
ctx.ui.notify("Rewind complete. Ready for next task.", "info");
106+
ctx.ui.notify("Drop complete. Ready for next task.", "info");
107107
},
108108
});
109109
}
Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,24 @@
11
/**
2-
* Recap extension - summarize and roll back the session tree
2+
* Fold extension - summarize and roll back the session tree
33
*
44
* Commands:
5-
* /recap - Summarize the conversation and navigate back to a clean starting point
5+
* /fold - Summarize the conversation and navigate back to a clean starting point
66
*
7-
* Recap generates a summary of the current conversation branch, then navigates
8-
* the session tree back to the beginning (or the last recap point), using the
7+
* Fold generates a summary of the current conversation branch, then navigates
8+
* the session tree back to the beginning (or the last fold point), using the
99
* generated summary as the branch summary.
1010
*
1111
* The editor is left empty for the user to type their next prompt.
1212
*
1313
* Usage:
14-
* /recap
14+
* /fold
1515
*/
1616

1717
import { complete, type Message } from "@mariozechner/pi-ai";
1818
import type { ExtensionAPI, SessionEntry } from "@mariozechner/pi-coding-agent";
1919
import { convertToLlm, serializeConversation } from "@mariozechner/pi-coding-agent";
2020

21-
const RECAP_SYSTEM_PROMPT = `You are a context summarization assistant. Given a conversation history, generate a concise summary that captures:
21+
const FOLD_SYSTEM_PROMPT = `You are a context summarization assistant. Given a conversation history, generate a concise summary that captures:
2222
2323
1. Relevant context from the conversation (decisions made, approaches taken, key findings)
2424
2. Any relevant files that were discussed or modified
@@ -40,22 +40,22 @@ We've been working on X. Key decisions:
4040
[What's been accomplished and what remains]`;
4141

4242
export default function (pi: ExtensionAPI) {
43-
let pendingRecapSummary: string | null = null;
43+
let pendingFoldSummary: string | null = null;
4444

45-
// Intercept tree navigation to provide custom summary when recapping
45+
// Intercept tree navigation to provide custom summary when folding
4646
pi.on("session_before_tree", async (_event, _ctx) => {
47-
if (pendingRecapSummary !== null) {
48-
const summary = pendingRecapSummary;
49-
pendingRecapSummary = null;
47+
if (pendingFoldSummary !== null) {
48+
const summary = pendingFoldSummary;
49+
pendingFoldSummary = null;
5050
return { summary: { summary, details: {} } };
5151
}
5252
});
5353

54-
pi.registerCommand("recap", {
54+
pi.registerCommand("fold", {
5555
description: "Summarize conversation and roll back to a clean starting point",
5656
handler: async (_args, ctx) => {
5757
if (!ctx.hasUI) {
58-
ctx.ui.notify("recap requires interactive mode", "error");
58+
ctx.ui.notify("fold requires interactive mode", "error");
5959
return;
6060
}
6161

@@ -64,13 +64,13 @@ export default function (pi: ExtensionAPI) {
6464
return;
6565
}
6666

67-
// Find anchor: last recap marker or first entry
67+
// Find anchor: last fold marker or first entry
6868
const branch = ctx.sessionManager.getBranch();
6969
let anchorId: string | undefined;
7070

7171
for (const entry of branch) {
7272
const label = ctx.sessionManager.getLabel(entry.id);
73-
if (label === "recap") {
73+
if (label === "fold") {
7474
anchorId = entry.id;
7575
}
7676
}
@@ -81,7 +81,7 @@ export default function (pi: ExtensionAPI) {
8181
}
8282

8383
if (!anchorId) {
84-
ctx.ui.notify("No conversation to recap", "error");
84+
ctx.ui.notify("No conversation to fold", "error");
8585
return;
8686
}
8787

@@ -93,16 +93,16 @@ export default function (pi: ExtensionAPI) {
9393
.map((entry) => entry.message);
9494

9595
if (messages.length === 0) {
96-
ctx.ui.notify("No conversation to recap", "error");
96+
ctx.ui.notify("No conversation to fold", "error");
9797
return;
9898
}
9999

100100
// Convert to LLM format and serialize
101101
const llmMessages = convertToLlm(messages);
102102
const conversationText = serializeConversation(llmMessages);
103103

104-
// Generate the recap summary (non-blocking: editor stays active)
105-
ctx.ui.setWidget("recap", [ctx.ui.theme.fg("accent", "● ") + ctx.ui.theme.fg("muted", "Generating recap summary...")]);
104+
// Generate the fold summary (non-blocking: editor stays active)
105+
ctx.ui.setWidget("fold", [ctx.ui.theme.fg("accent", "● ") + ctx.ui.theme.fg("muted", "Generating fold summary...")]);
106106

107107
let result: string | null = null;
108108
try {
@@ -121,7 +121,7 @@ export default function (pi: ExtensionAPI) {
121121

122122
const response = await complete(
123123
ctx.model!,
124-
{ systemPrompt: RECAP_SYSTEM_PROMPT, messages: [userMessage] },
124+
{ systemPrompt: FOLD_SYSTEM_PROMPT, messages: [userMessage] },
125125
{ apiKey },
126126
);
127127

@@ -134,33 +134,33 @@ export default function (pi: ExtensionAPI) {
134134
.join("\n");
135135
}
136136
} catch (err) {
137-
console.error("Recap generation failed:", err);
137+
console.error("Fold generation failed:", err);
138138
result = null;
139139
} finally {
140-
ctx.ui.setWidget("recap", undefined);
140+
ctx.ui.setWidget("fold", undefined);
141141
}
142142

143143
if (result === null) {
144-
ctx.ui.notify("Recap generation failed", "error");
144+
ctx.ui.notify("Fold generation failed", "error");
145145
return;
146146
}
147147

148148
// Store summary for session_before_tree handler
149-
pendingRecapSummary = result;
149+
pendingFoldSummary = result;
150150

151151
// Navigate tree back to anchor with custom summary
152152
const navResult = await ctx.navigateTree(anchorId, {
153153
summarize: true,
154-
label: "recap",
154+
label: "fold",
155155
});
156156

157157
if (navResult.cancelled) {
158-
pendingRecapSummary = null;
158+
pendingFoldSummary = null;
159159
ctx.ui.notify("Cancelled", "info");
160160
return;
161161
}
162162

163-
ctx.ui.notify("Recap complete. Ready for next task.", "info");
163+
ctx.ui.notify("Fold complete. Ready for next task.", "info");
164164
},
165165
});
166166
}

0 commit comments

Comments
 (0)