@monotykamary/pi-vcc 0.8.0 → 0.8.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.
- package/package.json +1 -1
- package/src/core/content.ts +22 -0
- package/src/core/search-entries.ts +5 -2
package/package.json
CHANGED
package/src/core/content.ts
CHANGED
|
@@ -59,6 +59,28 @@ const thinkingParts = (content: Message["content"]): string[] => {
|
|
|
59
59
|
export const thinkingOf = (content: Message["content"]): string =>
|
|
60
60
|
thinkingParts(content).join("\n");
|
|
61
61
|
|
|
62
|
+
const toolCallArgText = (args: Record<string, unknown>): string => {
|
|
63
|
+
const vals: string[] = [];
|
|
64
|
+
for (const v of Object.values(args ?? {})) {
|
|
65
|
+
if (typeof v === "string" && v.length > 0) vals.push(v);
|
|
66
|
+
}
|
|
67
|
+
return vals.join("\n");
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
const toolCallParts = (content: Message["content"]): string[] => {
|
|
71
|
+
if (!content || typeof content === "string") return [];
|
|
72
|
+
return content
|
|
73
|
+
.filter((part) => part.type === "toolCall")
|
|
74
|
+
.map((part) => toolCallArgText(part.arguments));
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
/** Extract all string-valued arguments from toolCall content parts.
|
|
78
|
+
* Lets vcc_recall match against tool invocations — e.g. a bash
|
|
79
|
+
* toolCall's `arguments.command`, a grep's `pattern`, an edit's
|
|
80
|
+
* `oldText`/`newText`. Non-string args are skipped. */
|
|
81
|
+
export const toolCallsOf = (content: Message["content"]): string =>
|
|
82
|
+
toolCallParts(content).filter(Boolean).join("\n");
|
|
83
|
+
|
|
62
84
|
/** Extract a snippet of ~`radius` chars around the first match of `term` in `text`. */
|
|
63
85
|
const snippet = (text: string, term: string, radius = 60): string | null => {
|
|
64
86
|
const idx = text.toLowerCase().indexOf(term.toLowerCase());
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Message } from "@earendil-works/pi-ai";
|
|
2
2
|
import type { RenderedEntry } from "./render-entries";
|
|
3
|
-
import { textOf, thinkingOf } from "./content";
|
|
3
|
+
import { textOf, thinkingOf, toolCallsOf } from "./content";
|
|
4
4
|
|
|
5
5
|
export interface SearchHit extends RenderedEntry {
|
|
6
6
|
/** Context snippet around the first matched term (only when query provided) */
|
|
@@ -270,10 +270,13 @@ const fullText = (msg: Message): string => {
|
|
|
270
270
|
if ((msg as any).role === "bashExecution") {
|
|
271
271
|
return `${(msg as any).command ?? ""} ${(msg as any).output ?? ""}`;
|
|
272
272
|
}
|
|
273
|
-
// Include thinking
|
|
273
|
+
// Include thinking + toolCall arguments so recall can match against
|
|
274
|
+
// model reasoning and tool invocations (e.g. a bash toolCall's command).
|
|
274
275
|
let text = textOf(msg.content);
|
|
275
276
|
const thinking = thinkingOf(msg.content);
|
|
276
277
|
if (thinking) text = thinking + "\n" + text;
|
|
278
|
+
const toolArgs = toolCallsOf(msg.content);
|
|
279
|
+
if (toolArgs) text = toolArgs + "\n" + text;
|
|
277
280
|
return text;
|
|
278
281
|
};
|
|
279
282
|
|