@vanillagreen/pi-qol 1.4.0 → 1.4.1

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.
@@ -6,6 +6,11 @@ import { serializeMessagesForSummary } from "./compaction.js";
6
6
  import { HANDOFF_SYSTEM_PROMPT } from "./constants.js";
7
7
  import { settingBoolean } from "./settings.js";
8
8
 
9
+ function errorMessage(error: unknown): string {
10
+ const message = error instanceof Error ? error.message : String(error);
11
+ return message.length > 180 ? `${message.slice(0, 179)}…` : message;
12
+ }
13
+
9
14
  export async function runHandoff(args: string, ctx: ExtensionCommandContext): Promise<void> {
10
15
  if (!ctx.hasUI) {
11
16
  ctx.ui.notify("handoff requires interactive mode", "error");
@@ -36,56 +41,58 @@ export async function runHandoff(args: string, ctx: ExtensionCommandContext): Pr
36
41
 
37
42
  const releaseModalLock = acquireVstackModalLock();
38
43
  let result: string | null = null;
44
+ let generationError: unknown;
39
45
  try {
40
- result = await ctx.ui.custom<string | null>((tui: any, theme: any, _kb: any, done: (value: string | null) => void) => {
41
- const loader = new BorderedLoader(tui, theme, "Generating handoff prompt...");
42
- loader.onAbort = () => done(null);
43
-
44
- const doGenerate = async () => {
45
- const auth = await ctx.modelRegistry.getApiKeyAndHeaders(ctx.model!);
46
- if (!auth.ok || !auth.apiKey) {
47
- throw new Error(auth.ok ? `No API key for ${ctx.model!.provider}` : auth.error);
48
- }
49
-
50
- const userMessage: Message = {
51
- role: "user",
52
- content: [
53
- {
54
- type: "text",
55
- text: `## Conversation History\n\n${conversationText}\n\n## User's Goal for New Thread\n\n${goal}`,
56
- },
57
- ],
58
- timestamp: Date.now(),
46
+ result = await ctx.ui.custom<string | null>((tui: any, theme: any, _kb: any, done: (value: string | null) => void) => {
47
+ const loader = new BorderedLoader(tui, theme, "Generating handoff prompt...");
48
+ loader.onAbort = () => done(null);
49
+
50
+ const doGenerate = async () => {
51
+ const auth = await ctx.modelRegistry.getApiKeyAndHeaders(ctx.model!);
52
+ if (!auth.ok || !auth.apiKey) {
53
+ throw new Error(auth.ok ? `No API key for ${ctx.model!.provider}` : auth.error);
54
+ }
55
+
56
+ const userMessage: Message = {
57
+ role: "user",
58
+ content: [
59
+ {
60
+ type: "text",
61
+ text: `## Conversation History\n\n${conversationText}\n\n## User's Goal for New Thread\n\n${goal}`,
62
+ },
63
+ ],
64
+ timestamp: Date.now(),
65
+ };
66
+
67
+ const response = await complete(
68
+ ctx.model!,
69
+ { systemPrompt: HANDOFF_SYSTEM_PROMPT, messages: [userMessage] },
70
+ { apiKey: auth.apiKey, headers: auth.headers, signal: loader.signal },
71
+ );
72
+
73
+ if (response.stopReason === "aborted") return null;
74
+ return response.content
75
+ .filter((content): content is { type: "text"; text: string } => content.type === "text")
76
+ .map((content) => content.text)
77
+ .join("\n");
59
78
  };
60
79
 
61
- const response = await complete(
62
- ctx.model!,
63
- { systemPrompt: HANDOFF_SYSTEM_PROMPT, messages: [userMessage] },
64
- { apiKey: auth.apiKey, headers: auth.headers, signal: loader.signal },
65
- );
66
-
67
- if (response.stopReason === "aborted") return null;
68
- return response.content
69
- .filter((content): content is { type: "text"; text: string } => content.type === "text")
70
- .map((content) => content.text)
71
- .join("\n");
72
- };
73
-
74
- doGenerate()
75
- .then(done)
76
- .catch((error) => {
77
- console.error("Handoff generation failed:", error);
78
- done(null);
79
- });
80
-
81
- return loader;
82
- });
80
+ doGenerate()
81
+ .then(done)
82
+ .catch((error) => {
83
+ generationError = error;
84
+ done(null);
85
+ });
86
+
87
+ return loader;
88
+ });
83
89
  } finally {
84
90
  releaseModalLock();
85
91
  }
86
92
 
87
93
  if (result === null) {
88
- ctx.ui.notify("Cancelled", "info");
94
+ if (generationError) ctx.ui.notify(`Handoff generation failed: ${errorMessage(generationError)}`, "error");
95
+ else ctx.ui.notify("Cancelled", "info");
89
96
  return;
90
97
  }
91
98
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vanillagreen/pi-qol",
3
- "version": "1.4.0",
3
+ "version": "1.4.1",
4
4
  "description": "Pi quality-of-life extension: compact statusline/π prompt, reliable multiline input, styled pasted-image chips, session naming/search/context import, handoff, permission prompts, notifications, custom compaction, and a collapsed-thinking timer.",
5
5
  "license": "MIT",
6
6
  "keywords": [