Skip to content

Commit 4a9a5ce

Browse files
committed
chore: bump everything and fix linking
1 parent afdc029 commit 4a9a5ce

File tree

5 files changed

+75
-26
lines changed

5 files changed

+75
-26
lines changed

.github/workflows/release.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,8 @@ jobs:
9595
cache: "pnpm"
9696
- name: Install dependencies
9797
run: pnpm install --frozen-lockfile
98+
- name: Build agent package
99+
run: pnpm --filter @posthog/agent run build
98100
- name: Import code signing certificate
99101
if: env.APPLE_CODESIGN_IDENTITY != ''
100102
env:

apps/array/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@poshog/array",
3-
"version": "0.3.0",
3+
"version": "0.4.0",
44
"description": "Array - PostHog desktop task manager",
55
"main": ".vite/build/index.js",
66
"versionHash": "dynamic",

apps/array/vite.main.config.mts

Lines changed: 67 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ function fixFilenameCircularRef(): Plugin {
2727
if (chunk.type === "chunk") {
2828
// Replace circular __filename references with direct __filename usage
2929
chunk.code = chunk.code.replace(
30-
/const __filename(\d+) = url\.fileURLToPath\(typeof document === "undefined" \? require\("url"\)\.pathToFileURL\(__filename\1\)\.href : [^;]+\);/g,
30+
/const __filename(\d+) = [\w$]+\.fileURLToPath\(typeof document === "undefined" \? require\("url"\)\.pathToFileURL\(__filename\1\)\.href : [^;]+\);/g,
3131
"const __filename$1 = __filename;",
3232
);
3333
}
@@ -66,37 +66,84 @@ function copyClaudeExecutable(): Plugin {
6666
return {
6767
name: "copy-claude-executable",
6868
writeBundle() {
69-
const sdkDir = join(
70-
__dirname,
71-
"node_modules/@posthog/agent/dist/claude-cli/",
72-
);
73-
74-
// IMPORTANT: Copy to claude-cli/ subdirectory to isolate the package.json
75-
// If we put package.json in .vite/build/, it breaks Vite's CommonJS output
7669
const destDir = join(__dirname, ".vite/build/claude-cli");
7770

7871
if (!existsSync(destDir)) {
7972
mkdirSync(destDir, { recursive: true });
8073
}
8174

82-
const files = ["cli.js", "package.json", "yoga.wasm"];
75+
// Define potential sources for the Claude CLI artifacts
76+
// Priority 1: Pre-built agent package (Production / CI)
77+
// Priority 2: Workspace source files (Development)
78+
const candidates = [
79+
// Local node_modules (standard package structure)
80+
{
81+
path: join(__dirname, "node_modules/@posthog/agent/dist/claude-cli"),
82+
type: "package",
83+
},
84+
// Root node_modules (hoisted package)
85+
{
86+
path: join(
87+
__dirname,
88+
"../../node_modules/@posthog/agent/dist/claude-cli",
89+
),
90+
type: "package",
91+
},
92+
// Direct workspace access (monorepo build)
93+
{
94+
path: join(__dirname, "../../packages/agent/dist/claude-cli"),
95+
type: "package",
96+
},
97+
];
8398

84-
for (const file of files) {
85-
const src = join(sdkDir, file);
86-
const dest = join(destDir, file);
87-
88-
if (!existsSync(src)) {
89-
console.warn(
90-
`[copy-claude-executable] ${file} not found. ` +
91-
`Run 'pnpm build' in the agent directory first.`,
99+
// Check if any pre-built candidate exists
100+
for (const candidate of candidates) {
101+
if (
102+
existsSync(join(candidate.path, "cli.js")) &&
103+
existsSync(join(candidate.path, "yoga.wasm"))
104+
) {
105+
console.log(
106+
`[copy-claude-executable] Found pre-built artifacts at ${candidate.path}`,
92107
);
93-
continue;
108+
const files = ["cli.js", "package.json", "yoga.wasm"];
109+
for (const file of files) {
110+
copyFileSync(join(candidate.path, file), join(destDir, file));
111+
}
112+
console.log("Copied Claude CLI to claude-cli/ subdirectory");
113+
return;
94114
}
115+
}
95116

96-
copyFileSync(src, dest);
117+
// Fallback: Assemble from individual source packages (Development Workspace)
118+
console.log(
119+
"[copy-claude-executable] Pre-built artifacts not found. Attempting to assemble from workspace sources...",
120+
);
121+
122+
const rootNodeModules = join(__dirname, "../../node_modules");
123+
const sdkDir = join(rootNodeModules, "@anthropic-ai/claude-agent-sdk");
124+
const yogaDir = join(rootNodeModules, "yoga-wasm-web/dist");
125+
126+
if (
127+
existsSync(join(sdkDir, "cli.js")) &&
128+
existsSync(join(yogaDir, "yoga.wasm"))
129+
) {
130+
copyFileSync(join(sdkDir, "cli.js"), join(destDir, "cli.js"));
131+
copyFileSync(
132+
join(sdkDir, "package.json"),
133+
join(destDir, "package.json"),
134+
); // Note: This copies the SDK package.json, which might not be ideal but works for type: module
135+
copyFileSync(join(yogaDir, "yoga.wasm"), join(destDir, "yoga.wasm"));
136+
console.log(
137+
"Assembled Claude CLI from workspace sources in claude-cli/ subdirectory",
138+
);
139+
return;
97140
}
98141

99-
console.log("Copied Claude CLI to claude-cli/ subdirectory");
142+
console.warn(
143+
"[copy-claude-executable] FAILED to find Claude CLI artifacts. Agent execution may fail.",
144+
);
145+
console.warn("Checked paths:", candidates.map((c) => c.path).join(", "));
146+
console.warn("Checked workspace sources:", sdkDir);
100147
},
101148
};
102149
}

packages/agent/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@posthog/agent",
3-
"version": "1.23.0",
3+
"version": "1.24.0",
44
"description": "TypeScript agent framework wrapping Claude Agent SDK with Git-based task execution for PostHog",
55
"main": "./dist/index.js",
66
"module": "./dist/index.js",

packages/agent/rollup.config.mjs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,12 +50,12 @@ export default defineConfig({
5050
},
5151
// Bundle Claude CLI so consumers don't need to navigate nested node_modules
5252
{
53-
src: "node_modules/@anthropic-ai/claude-agent-sdk/cli.js",
53+
src: "../../node_modules/@anthropic-ai/claude-agent-sdk/cli.js",
5454
dest: "dist/claude-cli",
5555
},
5656
// Create package.json for ES module support
5757
{
58-
src: "node_modules/@anthropic-ai/claude-agent-sdk/package.json",
58+
src: "../../node_modules/@anthropic-ai/claude-agent-sdk/package.json",
5959
dest: "dist/claude-cli",
6060
transform: (_contents) => {
6161
// Only keep "type": "module" from the original package.json
@@ -64,11 +64,11 @@ export default defineConfig({
6464
},
6565
// Copy yoga.wasm file that Claude CLI needs
6666
{
67-
src: "node_modules/yoga-wasm-web/dist/yoga.wasm",
67+
src: "../../node_modules/yoga-wasm-web/dist/yoga.wasm",
6868
dest: "dist/claude-cli",
6969
},
7070
],
71-
hook: "writeBundle",
71+
hook: "buildStart", // Changed hook from writeBundle to buildStart to ensure copy happens early
7272
}),
7373
],
7474
});

0 commit comments

Comments
 (0)