Skip to content

Commit 2ad1441

Browse files
committed
few fixes
1 parent c8fb98c commit 2ad1441

File tree

6 files changed

+41
-19
lines changed

6 files changed

+41
-19
lines changed

forge.config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ function copyNativeDependency(
9797
const config: ForgeConfig = {
9898
packagerConfig: {
9999
asar: {
100-
unpack: "{**/*.node,**/.vite/build/cli.js,**/.vite/build/yoga.wasm}",
100+
unpack: "{**/*.node,**/.vite/build/claude-cli/**}",
101101
},
102102
prune: false,
103103
name: "Array",

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@
6363
"@ai-sdk/openai": "^2.0.52",
6464
"@dnd-kit/react": "^0.1.21",
6565
"@phosphor-icons/react": "^2.1.10",
66-
"@posthog/agent": "1.18.0",
66+
"@posthog/agent": "file:/Users/peterkirkham/dev/agent",
6767
"@radix-ui/react-icons": "^1.3.2",
6868
"@radix-ui/themes": "^3.2.1",
6969
"@tanstack/react-query": "^5.90.2",

pnpm-lock.yaml

Lines changed: 15 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/main/services/agent.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@ function getClaudeCliPath(): string {
3535
const appPath = app.getAppPath();
3636

3737
return app.isPackaged
38-
? join(`${appPath}.unpacked`, ".vite/build/cli.js")
39-
: join(appPath, ".vite/build/cli.js");
38+
? join(`${appPath}.unpacked`, ".vite/build/claude-cli/cli.js")
39+
: join(appPath, ".vite/build/claude-cli/cli.js");
4040
}
4141

4242
function resolvePermissionMode(

src/renderer/App.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import { useDragDropHandlers } from "@features/panels";
66
import { Flex, Spinner, Text } from "@radix-ui/themes";
77
import { initializePostHog } from "@renderer/lib/analytics";
88
import { useEffect, useState } from "react";
9-
import { useDragDropHandlers } from "@/renderer/hooks/useDragDropHandlers";
109

1110
function App() {
1211
const { isAuthenticated, initializeOAuth } = useAuthStore();

vite.main.config.mts

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { copyFileSync, mkdirSync } from "node:fs";
1+
import { copyFileSync, existsSync, mkdirSync } from "node:fs";
22
import path, { join } from "node:path";
33
import { fileURLToPath } from "node:url";
44
import { defineConfig, type Plugin } from "vite";
@@ -67,18 +67,35 @@ function copyClaudeExecutable(): Plugin {
6767
writeBundle() {
6868
const sdkDir = join(
6969
__dirname,
70-
"node_modules/@posthog/agent/node_modules/@anthropic-ai/claude-agent-sdk",
70+
"node_modules/@posthog/agent/dist/claude-cli/",
7171
);
7272

73-
const files = ["cli.js", "yoga.wasm"];
73+
// IMPORTANT: Copy to claude-cli/ subdirectory to isolate the package.json
74+
// If we put package.json in .vite/build/, it breaks Vite's CommonJS output
75+
const destDir = join(__dirname, ".vite/build/claude-cli");
76+
77+
if (!existsSync(destDir)) {
78+
mkdirSync(destDir, { recursive: true });
79+
}
80+
81+
const files = ["cli.js", "package.json", "yoga.wasm"];
7482

7583
for (const file of files) {
7684
const src = join(sdkDir, file);
77-
const dest = join(__dirname, ".vite/build", file);
85+
const dest = join(destDir, file);
86+
87+
if (!existsSync(src)) {
88+
console.warn(
89+
`[copy-claude-executable] ${file} not found. ` +
90+
`Run 'pnpm build' in the agent directory first.`
91+
);
92+
continue;
93+
}
94+
7895
copyFileSync(src, dest);
7996
}
8097

81-
console.log("Copied Claude CLI and dependencies to build directory");
98+
console.log("Copied Claude CLI to claude-cli/ subdirectory");
8299
},
83100
};
84101
}

0 commit comments

Comments
 (0)