Skip to content

[codex] chore(mastra): switch to upstream packages#2985

Merged
Kitenite merged 3 commits into
mainfrom
chore/mastra-upstream-latest
Mar 29, 2026
Merged

[codex] chore(mastra): switch to upstream packages#2985
Kitenite merged 3 commits into
mainfrom
chore/mastra-upstream-latest

Conversation

@Kitenite
Copy link
Copy Markdown
Collaborator

@Kitenite Kitenite commented Mar 29, 2026

Summary

This switches Superset back to the published upstream Mastra packages and removes the repo-specific Mastracode fork patch flow.

What Changed

  • removes the root fork tarball overrides for mastracode and @mastra/*
  • updates desktop, chat, and host-service to the current published upstream packages
  • deletes the custom patch-mastracode-dependency.ts script and the fork workflow doc
  • updates repo guidance to prefer upstream Mastra packages by default
  • adapts chat runtime typing to the current upstream Mastra surface
  • keeps desktop packaging green by materializing exact nested native dependency versions when Bun cannot satisfy both runtime consumers from one top-level install
  • fixes a leaking desktop test mock so the full filtered test run stays green

Why

The original fork carried behavior that upstream Mastra now ships directly, while the local fork path added ongoing maintenance cost and custom build steps. The remaining build problem after removing the fork was not Mastra-specific; it was the desktop native packaging path around libsql and detect-libc under Bun's isolated install layout.

Impact

  • simpler dependency graph with no repo-local Mastra patch step
  • easier upgrades because desktop, chat, and host-service now follow upstream package releases directly
  • desktop build/package flow remains valid after the migration

Validation

  • bun run typecheck -- --filter=@superset/chat --filter=@superset/host-service --filter=@superset/desktop
  • bun run build -- --filter=@superset/chat --filter=@superset/host-service --filter=@superset/desktop
  • bun run test -- --filter=@superset/chat --filter=@superset/host-service --filter=@superset/desktop
  • bunx @biomejs/biome@2.4.2 check AGENTS.md README.md package.json apps/desktop/package.json apps/desktop/scripts/copy-native-modules.ts apps/desktop/src/lib/trpc/routers/changes/utils/merge-pull-request.test.ts packages/chat/package.json packages/chat/src/server/trpc/utils/runtime/runtime.ts packages/chat/src/server/trpc/utils/runtime/superset-mcp.ts packages/host-service/package.json

Summary by cubic

Switches the repo to upstream mastracode and @mastra/* packages and removes the fork/patch workflow. Keeps desktop CI green with semver-aware native module packaging under Bun and stabilizes tests.

  • Dependencies

    • Remove tarball overrides/resolutions for mastracode, @mastra/core, @mastra/memory.
    • Bump to upstream: mastracode@0.9.2, @mastra/core@1.17.0 (chat), @mastra/mcp@1.3.1.
    • Add detect-libc@2.0.4 to desktop runtime deps.
    • Delete scripts/patch-mastracode-dependency.ts and docs/mastracode-fork-workflow.md; update README/AGENTS to prefer upstream.
  • Bug Fixes

    • Desktop native packaging: semver-check libsql deps, materialize exact nested copies when top-level ranges don’t match, and fall back to npm tarballs when Bun store misses artifacts.
    • Tests: fix leaking mocks in merge-pull-request.test.ts by using scoped spyOn and restoring with mock.restore() to keep filtered runs green.
    • Chat runtime: call mode.agent with current state and tighten MCP tool typing.

Written for commit 2a7ec51. Summary will update on new commits.

Summary by CodeRabbit

Release Notes

  • Dependencies

    • Updated to use published upstream mastracode and @mastra/* packages directly (mastracode 0.9.2, @mastra/core 1.17.0, @mastra/mcp 1.3.1).
    • Removed internal dependency override mechanisms and patching steps from build pipeline.
  • Bug Fixes

    • Enhanced native module resolution logic for improved dependency compatibility handling.
  • Tests

    • Strengthened test infrastructure with improved mocking and type safety.
  • Documentation

    • Removed outdated internal workflow documentation.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Mar 29, 2026

Caution

Review failed

Pull request was closed or merged during review

📝 Walkthrough

Walkthrough

Migrates from a Superset-managed mastracode fork workflow to published upstream mastracode and @mastra/* packages. Updates dependency versions, removes fork-specific scripts and documentation, and refactors build utilities for module version detection and dependency resolution.

Changes

Cohort / File(s) Summary
Documentation & Configuration
AGENTS.md, README.md, docs/mastracode-fork-workflow.md
Updated agent guidelines and readme sections to direct users to published upstream packages instead of fork tarball overrides; removed dedicated fork workflow documentation entirely.
Dependency Resolution
package.json, apps/desktop/package.json, packages/chat/package.json, packages/host-service/package.json
Removed top-level resolutions overrides for fork URLs; updated mastracode and @mastra/* versions across all workspace packages to upstream releases (0.9.2 and 1.17.0 respectively); removed @mastra/core from desktop dependencies and added detect-libc.
Build & Script Cleanup
scripts/patch-mastracode-dependency.ts, apps/desktop/package.json (scripts)
Deleted fork dependency patching script; removed prepare:mastracode-dependency script and its invocation from prebuild and prepackage lifecycle hooks.
Native Module Resolution
apps/desktop/scripts/copy-native-modules.ts
Introduced semver-based version detection with readInstalledModuleVersion() and copyExactModuleVersion(); added copyDependencyForPackage() to verify and materialize dependencies against semver ranges, replacing symlinks with real directories when necessary.
Test Infrastructure & Runtime
apps/desktop/src/lib/trpc/routers/changes/utils/merge-pull-request.test.ts
Refactored mocking from top-level mock.module() to spyOn().mockImplementation() in beforeAll; strengthened type safety with concrete Parameters<...> signatures; consolidated repeated mock data; improved cleanup via afterAll.
Type & Logic Updates
packages/chat/src/server/trpc/utils/runtime/runtime.ts, packages/chat/src/server/trpc/utils/runtime/superset-mcp.ts
Updated generateAndSetTitle to pass runtime state to mode.agent() when it is a function; refined getSupersetMcpTools return type from Record<string, unknown> to Record<string, MastraExtraTool> with new typed interface for MCP tool structure.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Poem

🐰 Farewell to forks, we hop away!
Upstream packages lead the way,
With cleaner scripts and versions bright,
Our dependencies flow just right! ✨

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely summarizes the main change: switching to upstream Mastra packages from a repo-specific fork.
Description check ✅ Passed The description is comprehensive and well-structured, covering summary, what changed, why, impact, and validation steps. All required template sections are present or appropriately addressed.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch chore/mastra-upstream-latest

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Mar 29, 2026

🧹 Preview Cleanup Complete

The following preview resources have been cleaned up:

  • ✅ Neon database branch
  • ✅ Electric Fly.io app

Thank you for your contribution! 🎉

Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai Bot left a comment

Choose a reason for hiding this comment

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

1 issue found across 13 files

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="apps/desktop/scripts/copy-native-modules.ts">

<violation number="1" location="apps/desktop/scripts/copy-native-modules.ts:152">
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.</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

}
}

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

@Kitenite Kitenite merged commit 6338ce3 into main Mar 29, 2026
14 of 15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant