Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ bun run clean:workspaces # Clean all workspace node_modules
2. **Prefer `gh` CLI** - when performing git operations (PRs, issues, checkout, etc.), prefer the GitHub CLI (`gh`) over raw `git` commands where possible
3. **Shared command source** - keep command definitions in `.agents/commands/` only. `.claude/commands` and `.cursor/commands` should be symlinks to `../.agents/commands`. (`packages/chat` discovers slash commands from `.claude/commands`.)
4. **Workspace MCP config** - keep shared MCP servers in `.mcp.json`; `.cursor/mcp.json` should link to `../.mcp.json`. Codex uses `.codex/config.toml` (run with `CODEX_HOME=.codex codex ...`). OpenCode uses `opencode.json` and should mirror the same MCP set using OpenCode's `remote`/`local` schema.
5. **Mastracode fork workflow** - for Superset's internal `mastracode` fork bundle and release process, follow `docs/mastracode-fork-workflow.md`.
5. **Mastra dependencies** - use the published upstream `mastracode` and `@mastra/*` packages. Do not add fork tarball overrides or custom patch steps unless explicitly requested.


---
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -203,9 +203,9 @@ Scripts have access to environment variables:
- `SUPERSET_WORKSPACE_NAME` — Name of the workspace
- `SUPERSET_ROOT_PATH` — Path to the main repository

## Internal Dependency Overrides
## Mastra Dependencies

For the internal `mastracode` fork/bundle workflow used by this repo, see [docs/mastracode-fork-workflow.md](docs/mastracode-fork-workflow.md).
This repo uses the published upstream `mastracode` and `@mastra/*` packages directly. Avoid adding custom tarball overrides unless there is a repo-specific blocker.

## Tech Stack

Expand Down
9 changes: 4 additions & 5 deletions apps/desktop/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,14 @@
"clean": "git clean -xdf .cache .turbo dist dist-electron release node_modules",
"start": "electron-vite preview",
"generate:icons": "bun run scripts/generate-file-icons.ts",
"prepare:mastracode-dependency": "bun run ../../scripts/patch-mastracode-dependency.ts",
"predev": "cross-env NODE_ENV=development bun run clean:dev && bun run generate:icons && cross-env NODE_ENV=development bun run scripts/clean-launch-services.ts && cross-env NODE_ENV=development bun run scripts/patch-dev-protocol.ts",
"dev": "cross-env NODE_ENV=development electron-vite dev --watch",
"compile:app": "cross-env NODE_OPTIONS=--max-old-space-size=8192 electron-vite build",
"copy:native-modules": "bun run scripts/copy-native-modules.ts",
"validate:native-runtime": "bun run scripts/validate-native-runtime.ts",
"prebuild": "bun run clean:dev && bun run generate:icons && bun run compile:app && bun run copy:native-modules && bun run prepare:mastracode-dependency && bun run validate:native-runtime",
"prebuild": "bun run clean:dev && bun run generate:icons && bun run compile:app && bun run copy:native-modules && bun run validate:native-runtime",
"build": "cross-env CSC_IDENTITY_AUTO_DISCOVERY=false electron-builder --publish never",
"prepackage": "bun run copy:native-modules && bun run prepare:mastracode-dependency && bun run validate:native-runtime",
"prepackage": "bun run copy:native-modules && bun run validate:native-runtime",
"package": "electron-builder --config electron-builder.ts",
"install:deps": "electron-builder install-app-deps",
"release": "electron-builder --publish always",
Expand Down Expand Up @@ -72,7 +71,6 @@
"@hono/node-server": "^1.14.1",
"@hookform/resolvers": "^5.2.2",
"@lezer/highlight": "^1.2.3",
"@mastra/core": "1.8.0-superset.2",
"@parcel/watcher": "^2.5.6",
"@pierre/diffs": "1.1.7",
"@radix-ui/react-dialog": "^1.1.15",
Expand Down Expand Up @@ -157,6 +155,7 @@
"culori": "^4.0.2",
"date-fns": "^4.1.0",
"default-shell": "^2.2.0",
"detect-libc": "2.0.4",
"dnd-core": "^16.0.1",
"dotenv": "^17.3.1",
"drizzle-orm": "0.45.1",
Expand All @@ -179,7 +178,7 @@
"lowdb": "^7.0.1",
"lowlight": "^3.3.0",
"lucide-react": "^0.563.0",
"mastracode": "0.4.0-superset.12",
"mastracode": "0.9.2",
"nanoid": "^5.1.6",
"node-addon-api": "^7.1.0",
"node-pty": "1.1.0",
Expand Down
120 changes: 117 additions & 3 deletions apps/desktop/scripts/copy-native-modules.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import {
rmSync,
} from "node:fs";
import { dirname, join } from "node:path";
import { satisfies } from "semver";
import { requiredMaterializedNodeModules } from "../runtime-dependencies";

// Target architecture for cross-compilation. When set, platform-specific
Expand Down Expand Up @@ -110,6 +111,119 @@ function copyModuleIfSymlink(
return true;
}

function readInstalledModuleVersion(modulePath: string): string | null {
const packageJsonPath = join(modulePath, "package.json");
if (!existsSync(packageJsonPath)) return null;
type PackageJson = { version?: string };
const packageJson = JSON.parse(
readFileSync(packageJsonPath, "utf8"),
) as PackageJson;
return packageJson.version ?? null;
}

function copyExactModuleVersion(
nodeModulesDir: string,
moduleName: string,
version: string,
destPath: string,
required: boolean,
): boolean {
const bunStoreDir = getBunStoreDir(nodeModulesDir);
const bunStoreFolderName = findBunStoreFolderName(
bunStoreDir,
moduleName,
version,
);
if (bunStoreFolderName) {
const sourcePath = join(
bunStoreDir,
bunStoreFolderName,
"node_modules",
moduleName,
);
if (existsSync(sourcePath)) {
mkdirSync(dirname(destPath), { recursive: true });
cpSync(sourcePath, destPath, { recursive: true });
console.log(` Copied ${moduleName}@${version} to: ${destPath}`);
return true;
}
}

if (fetchNpmPackage(moduleName, version, destPath)) {
Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai Bot Mar 29, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1: The new libsql dependency materialization treats semver ranges as exact versions, which can fetch invalid npm tarball URLs and copy a non-matching Bun store version.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At apps/desktop/scripts/copy-native-modules.ts, line 152:

<comment>The new libsql dependency materialization treats semver ranges as exact versions, which can fetch invalid npm tarball URLs and copy a non-matching Bun store version.</comment>

<file context>
@@ -110,6 +111,119 @@ function copyModuleIfSymlink(
+		}
+	}
+
+	if (fetchNpmPackage(moduleName, version, destPath)) {
+		return true;
+	}
</file context>
Fix with Cubic

return true;
}

if (required) {
console.error(
` [ERROR] Failed to materialize ${moduleName}@${version} at ${destPath}`,
);
process.exit(1);
}

return false;
}

function copyDependencyForPackage(
nodeModulesDir: string,
parentModuleName: string,
dependencyName: string,
dependencyRange: string,
required: boolean,
): void {
const topLevelDependencyPath = join(nodeModulesDir, dependencyName);
const topLevelVersion = readInstalledModuleVersion(topLevelDependencyPath);

if (topLevelVersion && satisfies(topLevelVersion, dependencyRange)) {
copyModuleIfSymlink(nodeModulesDir, dependencyName, required);
return;
}

if (!topLevelVersion) {
console.log(
` ${dependencyName}: top-level version missing; materializing ${dependencyRange} at the workspace root`,
);
copyExactModuleVersion(
nodeModulesDir,
dependencyName,
dependencyRange,
topLevelDependencyPath,
required,
);
return;
}

const nestedDependencyPath = join(
nodeModulesDir,
parentModuleName,
"node_modules",
dependencyName,
);
const nestedVersion = readInstalledModuleVersion(nestedDependencyPath);
if (nestedVersion && satisfies(nestedVersion, dependencyRange)) {
const nestedStats = lstatSync(nestedDependencyPath);
if (nestedStats.isSymbolicLink()) {
const realPath = realpathSync(nestedDependencyPath);
rmSync(nestedDependencyPath);
cpSync(realPath, nestedDependencyPath, {
recursive: true,
});
}
return;
}

console.log(
` ${dependencyName}: top-level version ${topLevelVersion ?? "missing"} does not satisfy ${dependencyRange}; materializing nested copy for ${parentModuleName}`,
);

copyExactModuleVersion(
nodeModulesDir,
dependencyName,
dependencyRange,
nestedDependencyPath,
required,
);
}

/**
* Fetch an npm package tarball and extract it to destPath.
* Used when cross-compiling and the target platform package isn't in the Bun store.
Expand Down Expand Up @@ -241,12 +355,12 @@ function copyLibsqlDependencies(nodeModulesDir: string): void {
const libsqlPkg = JSON.parse(
readFileSync(libsqlPkgJsonPath, "utf8"),
) as LibsqlPackageJson;
const deps = Object.keys(libsqlPkg.dependencies ?? {});
const deps = libsqlPkg.dependencies ?? {};
const optionalDeps = libsqlPkg.optionalDependencies ?? {};

console.log("\nPreparing libsql runtime dependencies...");
for (const dep of deps) {
copyModuleIfSymlink(nodeModulesDir, dep, true);
for (const [dep, version] of Object.entries(deps)) {
copyDependencyForPackage(nodeModulesDir, "libsql", dep, version, true);
}

// Copy whichever optional native platform packages Bun installed for this platform.
Expand Down
Loading
Loading