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.
- package/README.md +1 -1
- package/package.json +1 -1
- 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,
|
|
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
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
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
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
|
|
163
|
-
|
|
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
|
-
|
|
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:
|
|
172
|
+
return { ...message, content: [{ type: "text", text: userContentToText(message.content) }] };
|
|
173
173
|
}
|
|
174
|
-
|
|
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[] {
|