pi-amplike 0.1.3 → 0.2.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.
- package/extensions/handoff.ts +13 -10
- package/package.json +1 -1
package/extensions/handoff.ts
CHANGED
|
@@ -117,12 +117,6 @@ async function performHandoff(pi: ExtensionAPI, ctx: ExtensionContext, goal: str
|
|
|
117
117
|
return "Handoff cancelled.";
|
|
118
118
|
}
|
|
119
119
|
|
|
120
|
-
// Create new session directly via sessionManager.
|
|
121
|
-
// ctx.newSession() is only available on ExtensionCommandContext (commands),
|
|
122
|
-
// but sessionManager.newSession() works at runtime from any context.
|
|
123
|
-
const sm = ctx.sessionManager as any;
|
|
124
|
-
sm.newSession({ parentSession: currentSessionFile });
|
|
125
|
-
|
|
126
120
|
// Build the final prompt with user's goal first for easy identification
|
|
127
121
|
let finalPrompt = result;
|
|
128
122
|
if (currentSessionFile) {
|
|
@@ -131,12 +125,21 @@ async function performHandoff(pi: ExtensionAPI, ctx: ExtensionContext, goal: str
|
|
|
131
125
|
finalPrompt = `${goal}\n\n${result}`;
|
|
132
126
|
}
|
|
133
127
|
|
|
134
|
-
//
|
|
135
|
-
//
|
|
136
|
-
|
|
128
|
+
// Create new session and send the prompt.
|
|
129
|
+
// When called from a tool, we must defer the session switch until after
|
|
130
|
+
// the current turn completes (tool_result is recorded), otherwise the
|
|
131
|
+
// new session gets a tool_result without a corresponding tool_use block.
|
|
132
|
+
const sm = ctx.sessionManager as any;
|
|
133
|
+
const doSwitch = () => {
|
|
134
|
+
sm.newSession({ parentSession: currentSessionFile });
|
|
137
135
|
pi.sendUserMessage(finalPrompt, { deliverAs: "followUp" });
|
|
136
|
+
};
|
|
137
|
+
|
|
138
|
+
if (fromTool) {
|
|
139
|
+
// Defer to next tick so the tool_result is recorded in the OLD session first
|
|
140
|
+
setTimeout(doSwitch, 0);
|
|
138
141
|
} else {
|
|
139
|
-
|
|
142
|
+
doSwitch();
|
|
140
143
|
}
|
|
141
144
|
return undefined;
|
|
142
145
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pi-amplike",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "Pi skills and extensions that provide Amp Code-like workflows (handoff, session query, web search, visit webpage).",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"homepage": "https://github.com/pasky/pi-amplike",
|