pi-qq 0.1.8 → 0.1.9

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.
Files changed (3) hide show
  1. package/README.md +1 -1
  2. package/package.json +1 -1
  3. package/qq.ts +23 -18
package/README.md CHANGED
@@ -74,7 +74,7 @@ Press **alt+q** / **Option+Q** to toggle `/qq ` at the front of the editor:
74
74
  - The main transcript is never polluted by `/qq` questions or answers.
75
75
  - The side call receives read-only main-session context.
76
76
  - Recent mode sends only the latest messages for speed; full mode sends broader but still bounded context, not unlimited history.
77
- - Large text parts are clipped, thinking blocks are removed, and images are omitted from the side-call context for speed.
77
+ - Large text parts are clipped; images, tool calls, and tool results are converted into plain-text background so the side call never uses provider tool protocol.
78
78
  - The side call has no tools.
79
79
  - Recent `/qq` answers are kept in memory only so `/qq-history` can reopen them after dismissal.
80
80
  - `/qq-history` is view-only; it is not used as context for future `/qq` model calls.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pi-qq",
3
- "version": "0.1.8",
3
+ "version": "0.1.9",
4
4
  "description": "Ask transcript-safe, context-aware side questions in Pi with /qq or alt+q, then reopen recent answers with /qq-history.",
5
5
  "keywords": [
6
6
  "pi-package",
package/qq.ts CHANGED
@@ -145,33 +145,38 @@ function clipText(text: string): string {
145
145
  return `${text.slice(0, MAX_TEXT_CHARS_PER_PART)}\n[…truncated for /qq speed…]`;
146
146
  }
147
147
 
148
- function trimContentArray<T extends Array<{ type: string }>>(content: T): T {
149
- return content
150
- .filter((part) => part.type !== "thinking")
151
- .map((part) => {
152
- if (part.type === "text" && "text" in part && typeof part.text === "string") {
153
- return { ...part, text: clipText(part.text) };
154
- }
155
- if (part.type === "image") {
156
- return { type: "text", text: "[image omitted for /qq speed]" };
157
- }
158
- return part;
159
- }) as T;
148
+ function contentPartsToText(content: Array<{ type: string }>): string {
149
+ const parts: string[] = [];
150
+ for (const part of content) {
151
+ if (part.type === "text" && "text" in part && typeof part.text === "string") {
152
+ parts.push(clipText(part.text));
153
+ } else if (part.type === "image") {
154
+ parts.push("[image omitted for /qq speed]");
155
+ } else if (part.type === "toolCall" && "name" in part && typeof part.name === "string") {
156
+ parts.push(`[assistant requested tool: ${part.name}]`);
157
+ }
158
+ }
159
+ return parts.join("\n").trim();
160
160
  }
161
161
 
162
- function trimUserContent(content: UserMessage["content"]): UserMessage["content"] {
163
- if (typeof content === "string") return clipText(content);
164
- return trimContentArray(content);
162
+ function userContentToText(content: UserMessage["content"]): string {
163
+ return typeof content === "string" ? clipText(content) : contentPartsToText(content);
165
164
  }
166
165
 
167
166
  function trimMessageForContext(message: Message): Message {
168
167
  if (message.role === "assistant") {
169
- return { ...message, content: trimContentArray(message.content) };
168
+ const text = contentPartsToText(message.content) || "[assistant message omitted for /qq speed]";
169
+ return { ...message, content: [{ type: "text", text }] };
170
170
  }
171
171
  if (message.role === "user") {
172
- return { ...message, content: trimUserContent(message.content) };
172
+ return { ...message, content: [{ type: "text", text: userContentToText(message.content) }] };
173
173
  }
174
- return { ...message, content: trimContentArray(message.content) };
174
+ const text = contentPartsToText(message.content) || "[tool result omitted for /qq speed]";
175
+ return {
176
+ role: "user",
177
+ content: [{ type: "text", text: `[tool result: ${message.toolName}]\n${text}` }],
178
+ timestamp: message.timestamp,
179
+ };
175
180
  }
176
181
 
177
182
  function selectRecentContextMessages(messages: Message[]): Message[] {