@posthog/agent 2.3.18 → 2.3.22
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/dist/adapters/claude/conversion/tool-use-to-acp.js +29 -5
- package/dist/adapters/claude/conversion/tool-use-to-acp.js.map +1 -1
- package/dist/agent.js +43 -19
- package/dist/agent.js.map +1 -1
- package/dist/posthog-api.js +1 -1
- package/dist/posthog-api.js.map +1 -1
- package/dist/server/agent-server.js +63 -39
- package/dist/server/agent-server.js.map +1 -1
- package/dist/server/bin.cjs +67 -43
- package/dist/server/bin.cjs.map +1 -1
- package/package.json +1 -1
- package/src/adapters/claude/conversion/tool-use-to-acp.ts +48 -12
- package/src/adapters/claude/permissions/permission-handlers.ts +1 -1
package/package.json
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import fs from "node:fs";
|
|
1
2
|
import path from "node:path";
|
|
2
3
|
import type {
|
|
3
4
|
PlanEntry,
|
|
@@ -179,18 +180,22 @@ export function toolInfoFromToolUse(
|
|
|
179
180
|
: null;
|
|
180
181
|
let newText: string = input?.new_string ? String(input.new_string) : "";
|
|
181
182
|
|
|
182
|
-
//
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
183
|
+
// try to display a rich diff by first checking if file content is cached
|
|
184
|
+
// and valid (old_text exists in the content), then fall back to reading
|
|
185
|
+
// file from disk, then fall back to fragemented snippet diff
|
|
186
|
+
if (filePath && oldText !== null) {
|
|
187
|
+
const fileContent = resolveFileContent(
|
|
188
|
+
filePath,
|
|
189
|
+
oldText,
|
|
190
|
+
options?.cachedFileContent,
|
|
191
|
+
);
|
|
192
|
+
if (fileContent) {
|
|
193
|
+
const newContent = input?.replace_all
|
|
194
|
+
? fileContent.replaceAll(oldText, newText)
|
|
195
|
+
: fileContent.replace(oldText, newText);
|
|
196
|
+
oldText = fileContent;
|
|
197
|
+
newText = newContent;
|
|
198
|
+
}
|
|
194
199
|
}
|
|
195
200
|
|
|
196
201
|
return {
|
|
@@ -759,6 +764,37 @@ export function planEntries(input: { todos: ClaudePlanEntry[] }): PlanEntry[] {
|
|
|
759
764
|
}));
|
|
760
765
|
}
|
|
761
766
|
|
|
767
|
+
/**
|
|
768
|
+
* attempt to resolve full file contents for diff generation
|
|
769
|
+
*
|
|
770
|
+
* 1) check file content cache exists, and is valid (old_text in content)
|
|
771
|
+
* 2) if missing or invalid, read file from disk
|
|
772
|
+
* 3) if both fail, return null, we'll fall back to fragmented snippet diff
|
|
773
|
+
*/
|
|
774
|
+
function resolveFileContent(
|
|
775
|
+
filePath: string,
|
|
776
|
+
oldText: string,
|
|
777
|
+
cachedFileContent?: Record<string, string>,
|
|
778
|
+
): string | null {
|
|
779
|
+
if (cachedFileContent && filePath in cachedFileContent) {
|
|
780
|
+
const cached = cachedFileContent[filePath];
|
|
781
|
+
if (cached.includes(oldText)) {
|
|
782
|
+
return cached;
|
|
783
|
+
}
|
|
784
|
+
}
|
|
785
|
+
|
|
786
|
+
try {
|
|
787
|
+
const content = fs.readFileSync(filePath, "utf-8");
|
|
788
|
+
if (content.includes(oldText)) {
|
|
789
|
+
return content;
|
|
790
|
+
}
|
|
791
|
+
} catch {
|
|
792
|
+
return null;
|
|
793
|
+
}
|
|
794
|
+
|
|
795
|
+
return null;
|
|
796
|
+
}
|
|
797
|
+
|
|
762
798
|
function markdownEscape(text: string): string {
|
|
763
799
|
let escapedText = "```";
|
|
764
800
|
for (const [m] of text.matchAll(/^```+/gm)) {
|
|
@@ -356,7 +356,7 @@ async function handleDefaultPermissionFlow(
|
|
|
356
356
|
kind: toolInfo.kind,
|
|
357
357
|
content: toolInfo.content,
|
|
358
358
|
locations: toolInfo.locations,
|
|
359
|
-
rawInput: toolInput as Record<string, unknown
|
|
359
|
+
rawInput: { ...(toolInput as Record<string, unknown>), toolName },
|
|
360
360
|
},
|
|
361
361
|
});
|
|
362
362
|
|