Skip to content

Commit 8cf5188

Browse files
authored
Merge branch 'main' into swap-model-on-plan-card
2 parents 1398046 + 073091a commit 8cf5188

118 files changed

Lines changed: 4474 additions & 1704 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

apps/code/electron.vite.config.ts

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { readFileSync } from "node:fs";
1+
import { existsSync, readFileSync } from "node:fs";
22
import { builtinModules, createRequire } from "node:module";
33
import path from "node:path";
44
import { fileURLToPath } from "node:url";
@@ -45,6 +45,43 @@ const nodeExternals = [
4545
// the staged node_modules at runtime (see scripts/before-pack.ts).
4646
const nativeModules = buildExternals;
4747

48+
const nearestPackageType = (fromFile: string): string | undefined => {
49+
let dir = path.dirname(fromFile);
50+
while (true) {
51+
const manifest = path.join(dir, "package.json");
52+
if (existsSync(manifest)) {
53+
try {
54+
return JSON.parse(readFileSync(manifest, "utf-8")).type;
55+
} catch {
56+
return undefined;
57+
}
58+
}
59+
const parent = path.dirname(dir);
60+
if (parent === dir) return undefined;
61+
dir = parent;
62+
}
63+
};
64+
65+
const resolvesToCommonJs = (name: string): boolean => {
66+
let resolved: string;
67+
try {
68+
resolved = require.resolve(name);
69+
} catch {
70+
return false;
71+
}
72+
if (resolved.endsWith(".cjs")) return true;
73+
if (resolved.endsWith(".mjs")) return false;
74+
return nearestPackageType(resolved) !== "module";
75+
};
76+
77+
const computeDevThirdPartyExternals = (): RegExp[] =>
78+
Object.keys(pkg.dependencies ?? {})
79+
.filter((name) => !name.startsWith("@posthog/") && resolvesToCommonJs(name))
80+
.map(
81+
(name) =>
82+
new RegExp(`^${name.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")}(/.+)?$`),
83+
);
84+
4885
export default defineConfig(({ mode }) => {
4986
const env = loadEnv(mode, path.resolve(__dirname, "../.."), "");
5087
const isDev = mode === "development";
@@ -115,6 +152,7 @@ export default defineConfig(({ mode }) => {
115152
"electron/main",
116153
...nodeExternals,
117154
...nativeModules,
155+
...(isDev ? computeDevThirdPartyExternals() : []),
118156
],
119157
onwarn(warning, warn) {
120158
if (warning.code === "UNUSED_EXTERNAL_IMPORT") return;

apps/code/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@
5757
"@types/react": "^19.2.15",
5858
"@types/react-dom": "^19.2.3",
5959
"@types/semver": "^7.7.1",
60-
"@vitejs/plugin-react": "^4.7.0",
60+
"@vitejs/plugin-react": "^5.2.0",
6161
"@vitest/ui": "^4.1.8",
6262
"adm-zip": "^0.5.17",
6363
"electron": "^42.3.0",

apps/code/src/renderer/di/bindings.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,8 @@ import {
5959
type BundleLocalSkill,
6060
CLOUD_ARTIFACT_BUNDLE_LOCAL_SKILL,
6161
CLOUD_ARTIFACT_READ_FILE_AS_BASE64,
62+
CLOUD_ARTIFACT_RESOLVE_SKILL_DEPENDENCIES,
63+
type ResolveSkillBundleDependencies,
6264
} from "@posthog/core/sessions/cloudArtifactIdentifiers";
6365
import {
6466
LOCAL_HANDOFF_DIALOG,
@@ -272,6 +274,7 @@ export interface RendererBindings {
272274
[REVERT_HUNK_SERVICE]: RevertHunkService;
273275
[SKILLS_WORKSPACE_CLIENT]: SkillsWorkspaceClient;
274276
[CLOUD_ARTIFACT_BUNDLE_LOCAL_SKILL]: BundleLocalSkill;
277+
[CLOUD_ARTIFACT_RESOLVE_SKILL_DEPENDENCIES]: ResolveSkillBundleDependencies;
275278
[CLOUD_ARTIFACT_READ_FILE_AS_BASE64]: ReadFileAsBase64;
276279
[LLM_GATEWAY_SERVICE]: LlmGatewayService;
277280
[TITLE_GENERATOR_FILE_READ_CLIENT]: FileReadClient;

apps/code/src/renderer/di/container.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ import type { LlmMessage } from "@posthog/core/llm-gateway/schemas";
3232
import {
3333
CLOUD_ARTIFACT_BUNDLE_LOCAL_SKILL,
3434
CLOUD_ARTIFACT_READ_FILE_AS_BASE64,
35+
CLOUD_ARTIFACT_RESOLVE_SKILL_DEPENDENCIES,
3536
} from "@posthog/core/sessions/cloudArtifactIdentifiers";
3637
import {
3738
LOCAL_HANDOFF_DIALOG,
@@ -393,6 +394,11 @@ container
393394
.toConstantValue((skillBundleRef) =>
394395
hostTrpcClient.skills.bundleLocal.query(skillBundleRef),
395396
);
397+
container
398+
.bind(CLOUD_ARTIFACT_RESOLVE_SKILL_DEPENDENCIES)
399+
.toConstantValue((skillBundleRefs) =>
400+
hostTrpcClient.skills.resolveDependencies.query(skillBundleRefs),
401+
);
396402
container.bind(LLM_GATEWAY_SERVICE).toConstantValue({
397403
prompt: (
398404
messages: LlmMessage[],

apps/code/vite-main-plugins.mts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,11 @@ function detectBinaryArch(
119119
return null;
120120
}
121121

122+
function isStagedCopyCurrent(source: string, dest: string): boolean {
123+
if (!existsSync(dest)) return false;
124+
return statSync(dest).mtimeMs >= statSync(source).mtimeMs;
125+
}
126+
122127
function signClaudeBinary(destPath: string): void {
123128
if (targetPlatform() !== "darwin") return;
124129
if (process.platform !== "darwin") {
@@ -196,6 +201,11 @@ export function copyClaudeExecutable(): Plugin {
196201
return;
197202
}
198203

204+
if (isStagedCopyCurrent(source, destBinary)) {
205+
claudeCliCopied = true;
206+
return;
207+
}
208+
199209
copyFileSync(source, destBinary);
200210
if (targetPlatform() !== "win32") {
201211
execSync(`chmod +x "${destBinary}"`);
@@ -569,6 +579,11 @@ export function copyCodexAcpBinaries(): Plugin {
569579

570580
if (existsSync(sourcePath)) {
571581
const destPath = join(destDir, binaryName);
582+
583+
if (isStagedCopyCurrent(sourcePath, destPath)) {
584+
continue;
585+
}
586+
572587
copyFileSync(sourcePath, destPath);
573588
console.log(`Copied ${binary.name} binary to ${destDir}`);
574589

apps/code/vite.shared.mts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,10 @@ export const workspaceAliases: Alias[] = [
102102
"../../packages/workspace-server/src/$1",
103103
),
104104
},
105+
{
106+
find: /^@posthog\/platform\/(.+)$/,
107+
replacement: path.resolve(__dirname, "../../packages/platform/src/$1"),
108+
},
105109
];
106110

107111
export const mainAliases: Alias[] = [
@@ -113,6 +117,10 @@ export const mainAliases: Alias[] = [
113117
"../../packages/electron-trpc/src/main/index.ts",
114118
),
115119
},
120+
{
121+
find: /^@posthog\/git\/(.+)$/,
122+
replacement: path.resolve(__dirname, "../../packages/git/src/$1"),
123+
},
116124
...workspaceAliases,
117125
];
118126

apps/mobile/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@
6464
"phosphor-react-native": "^3.0.2",
6565
"posthog-react-native": "^4.18.0",
6666
"posthog-react-native-session-replay": "^1.6.0",
67-
"react": "19.1.0",
67+
"react": "19.2.6",
6868
"react-native": "0.81.5",
6969
"react-native-keyboard-controller": "1.18.5",
7070
"react-native-reanimated": "~4.1.1",
@@ -77,11 +77,11 @@
7777
},
7878
"devDependencies": {
7979
"@testing-library/react-native": "^13.3.3",
80-
"@types/react": "^19.1.0",
80+
"@types/react": "^19.2.0",
8181
"@types/react-test-renderer": "^19.1.0",
8282
"@vitejs/plugin-react": "^4.7.0",
8383
"react-native-svg-transformer": "^1.5.3",
84-
"react-test-renderer": "^19.1.0",
84+
"react-test-renderer": "^19.2.6",
8585
"tailwindcss": "^3.4.18",
8686
"typescript": "~5.9.2",
8787
"vite": "^6.4.1",

package.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,5 +61,10 @@
6161
"biome check --write --unsafe --files-ignore-unknown=true --no-errors-on-unmatched",
6262
"bash -c 'pnpm typecheck'"
6363
]
64+
},
65+
"pnpm": {
66+
"overrides": {
67+
"vite": "npm:rolldown-vite@7.3.1"
68+
}
6469
}
6570
}

packages/agent/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@
125125
"tsup": "^8.5.1",
126126
"tsx": "^4.20.6",
127127
"typescript": "^5.5.0",
128-
"vitest": "^2.1.8"
128+
"vitest": "^4.1.8"
129129
},
130130
"dependencies": {
131131
"@agentclientprotocol/sdk": "0.25.0",

packages/agent/src/adapters/claude/conversion/acp-to-sdk.ts

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import type { PromptRequest } from "@agentclientprotocol/sdk";
44
import type { SDKUserMessage } from "@anthropic-ai/claude-agent-sdk";
55
import type { ContentBlockParam } from "@anthropic-ai/sdk/resources";
66
import { isClaudeImageMimeType, isImageFile } from "@posthog/shared";
7+
import { isLocalSkillCommandChunk } from "../../local-skill";
78

89
const PDF_EXTENSIONS = new Set(["pdf"]);
910

@@ -80,18 +81,6 @@ function transformMcpCommand(text: string): string {
8081
return text;
8182
}
8283

83-
function isLocalSkillCommandChunk(
84-
chunk: PromptRequest["prompt"][number],
85-
skillName: string,
86-
): boolean {
87-
if (chunk.type !== "text") {
88-
return false;
89-
}
90-
91-
const match = chunk.text.trim().match(/^\/([^\s]+)(?:\s+[\s\S]*)?$/);
92-
return match?.[1] === skillName;
93-
}
94-
9584
function processPromptChunk(
9685
chunk: PromptRequest["prompt"][number],
9786
content: ContentBlockParam[],

0 commit comments

Comments
 (0)