Skip to content

Commit 3805170

Browse files
committed
feat: Enhance tools and workflows in the Mastra project
- refactor: Remove optional error field from jsonToCsvTool output schema and throw errors instead of returning them. - refactor: Switch from pdf-parse to unpdf for PDF data conversion, improving performance and removing dynamic imports. - refactor: Update PDF reading logic in readPDF tool to utilize unpdf, enhancing text extraction capabilities. - chore: Update imports from 'fs' and 'path' to 'node:fs' and 'node:path' for consistency across tools. - refactor: Simplify error handling in polygon tools by throwing errors instead of returning error objects. - refactor: Update semantic-utils to use node imports for fs/promises and path. - fix: Adjust test-generator tool to ensure optional context is handled correctly. - style: Improve navigation menu styles and structure for better accessibility and usability. - chore: Add new workflow documentation for Gemini King mode, detailing operational directives and coding standards. - chore: Create Copilot Processing documentation to outline enhancements made to GitHub tools and address Unreal Engine conflicts.
1 parent 6e88eea commit 3805170

62 files changed

Lines changed: 3010 additions & 4162 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
---
2+
description: kingg
3+
---
4+
5+
# SYSTEM ROLE & BEHAVIORAL PROTOCOLS
6+
7+
**ROLE:** Senior Frontend Architect & Avant-Garde UI Designer.
8+
**EXPERIENCE:** 15+ years. Master of visual hierarchy, whitespace, and UX engineering.
9+
10+
## 1. OPERATIONAL DIRECTIVES (DEFAULT MODE)
11+
* **Follow Instructions:** Execute the request immediately. Do not deviate.
12+
* **Zero Fluff:** No philosophical lectures or unsolicited advice in standard mode.
13+
* **Stay Focused:** Concise answers only. No wandering.
14+
* **Output First:** Prioritize code and visual solutions.
15+
16+
## 2. THE "ULTRATHINK" PROTOCOL (TRIGGER COMMAND)
17+
**TRIGGER:** When the user prompts **"ULTRATHINK"**:
18+
* **Override Brevity:** Immediately suspend the "Zero Fluff" rule.
19+
* **Maximum Depth:** You must engage in exhaustive, deep-level reasoning.
20+
* **Multi-Dimensional Analysis:** Analyze the request through every lens:
21+
* *Psychological:* User sentiment and cognitive load.
22+
* *Technical:* Rendering performance, repaint/reflow costs, and state complexity.
23+
* *Accessibility:* WCAG AAA strictness.
24+
* *Scalability:* Long-term maintenance and modularity.
25+
* **Prohibition:** **NEVER** use surface-level logic. If the reasoning feels easy, dig deeper until the logic is irrefutable.
26+
27+
## 3. DESIGN PHILOSOPHY: "INTENTIONAL MINIMALISM"
28+
* **Anti-Generic:** Reject standard "bootstrapped" layouts. If it looks like a template, it is wrong.
29+
* **Uniqueness:** Strive for bespoke layouts, asymmetry, and distinctive typography.
30+
* **The "Why" Factor:** Before placing any element, strictly calculate its purpose. If it has no purpose, delete it.
31+
* **Minimalism:** Reduction is the ultimate sophistication.
32+
33+
## 4. FRONTEND CODING STANDARDS
34+
* **Library Discipline (CRITICAL):** If a UI library (e.g., Shadcn UI, Radix, MUI) is detected or active in the project, **YOU MUST USE IT**.
35+
* **Do not** build custom components (like modals, dropdowns, or buttons) from scratch if the library provides them.
36+
* **Do not** pollute the codebase with redundant CSS.
37+
* *Exception:* You may wrap or style library components to achieve the "Avant-Garde" look, but the underlying primitive must come from the library to ensure stability and accessibility.
38+
* **Stack:** Modern (React/Vue/Svelte), Tailwind/Custom CSS, semantic HTML5.
39+
* **Visuals:** Focus on micro-interactions, perfect spacing, and "invisible" UX.
40+
41+
## 5. RESPONSE FORMAT
42+
43+
**IF NORMAL:**
44+
1. **Rationale:** (1 sentence on why the elements were placed there).
45+
2. **The Code.**
46+
47+
**IF "ULTRATHINK" IS ACTIVE:**
48+
1. **Deep Reasoning Chain:** (Detailed breakdown of the architectural and design decisions).
49+
2. **Edge Case Analysis:** (What could go wrong and how we prevented it).
50+
3. **The Code:** (Optimized, bespoke, production-ready, utilizing existing libraries).

.github/copilot-instructions.md

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -38,24 +38,3 @@ call the `init` tool from the next-devtools-mcp server FIRST. This establishes
3838
proper context and ensures all Next.js queries use official documentation.
3939
- This step is crucial for accurate and efficient development within Next.js environments.
4040
- 🧩 When working with Next.js projects, always utilize the `next-devtools-mcp` server for all Next.js related queries.
41-
42-
[byterover-mcp]
43-
44-
[byterover-mcp]
45-
46-
You are given two tools from Byterover MCP server, including
47-
## 1. `byterover-store-knowledge`
48-
You `MUST` always use this tool when:
49-
50-
+ Learning new patterns, APIs, or architectural decisions from the codebase
51-
+ Encountering error solutions or debugging techniques
52-
+ Finding reusable code patterns or utility functions
53-
+ Completing any significant task or plan implementation
54-
55-
## 2. `byterover-retrieve-knowledge`
56-
You `MUST` always use this tool when:
57-
58-
+ Starting any new task or implementation to gather relevant context
59-
+ Before making architectural decisions to understand existing patterns
60-
+ When debugging issues to check for previous solutions
61-
+ Working with unfamiliar parts of the codebase

Copilot-Processing.md

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
# Copilot Processing: GitHub Tool Enhancement
2+
3+
## User Request
4+
5+
The user provided `src/mastra/tools/github.ts` and mentioned `vscode-websearchforcopilot_webSearch`.
6+
Instructions also mention Unreal Engine ThirdPerson template project and UE C++ standards, which was investigated and found to be a conflict/error in the instructions.
7+
8+
## Project Context Discovery
9+
10+
- **Project Type**: Mastra-based multi-agent toolkit (AgentStack).
11+
- **Tech Stack**: Next.js 16, TypeScript, Mastra, PgVector, AI Elements.
12+
- **Unreal Engine Conflict**: No mention of Unreal Engine or C++ in `memory-bank/` or codebase. The instructions in the prompt are likely a mistake or leftover from another context.
13+
- **Decision**: Proceed with Mastra/Next.js context as defined in the Memory Bank.
14+
15+
## Status
16+
17+
- [x] Research user intent regarding Unreal Engine vs Mastra (Confirmed Mastra project)
18+
- [x] Identify potential enhancements for `github.ts`
19+
- [x] Implement new GitHub tools:
20+
- [x] `createPullRequest`
21+
- [x] `mergePullRequest`
22+
- [x] `addIssueComment`
23+
- [x] `getPullRequest`
24+
- [x] `getIssue`
25+
- [x] Fix `bgColorAgent.ts` TypeScript error:
26+
- [x] Update `colorChangeTool` to use `@mastra/core/tools`
27+
- [x] Add `execute` function to `colorChangeTool`
28+
- [x] Fix Navbar Runtime Error:
29+
- [x] Update `ui/navigation-menu.tsx` to handle `asChild` correctly in `NavigationMenuTrigger`.
30+
- [x] Update @ai-sdk/google to v3:
31+
- [x] Update `src/mastra/config/google.ts` to use `createGoogleGenerativeAI`.
32+
- [x] Update `src/mastra/config/pg-storage.ts` to use local provider instance instead of legacy facade.
33+
- [x] Update documentation
34+
35+
## Summary
36+
37+
Enhanced the GitHub toolset in `src/mastra/tools/github.ts` by adding 5 new tools:
38+
39+
1. `createPullRequest`: Create a new PR with title, head, base, and body.
40+
2. `mergePullRequest`: Merge an existing PR using merge, squash, or rebase methods.
41+
3. `addIssueComment`: Add comments to issues or PRs.
42+
4. `getPullRequest`: Retrieve detailed information about a specific PR.
43+
5. `getIssue`: Retrieve detailed information about a specific issue.
44+
45+
Fixed a TypeScript error in `src/mastra/agents/bgColorAgent.ts` where `colorChangeTool` was incompatible with the `Agent` class.
46+
47+
Fixed a runtime error in `app/components/navbar.tsx` caused by `NavigationMenuTrigger` receiving multiple children when `asChild` was true. The `NavigationMenuTrigger` component in `ui/navigation-menu.tsx` was updated to only render the chevron icon when `asChild` is false.
48+
49+
Updated `src/mastra/config/google.ts` and `src/mastra/config/pg-storage.ts` to be compatible with `@ai-sdk/google` v3. This involved:
50+
51+
- Using `createGoogleGenerativeAI` to create a provider instance in `google.ts`.
52+
- Updating `pg-storage.ts` to import the `google` provider from the local config instead of the removed facade in `@ai-sdk/google`.
53+
- Removing unnecessary type casts in `pg-storage.ts`.

app/chat/providers/chat-context.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,12 @@ export function ChatProvider({
304304
output = (part as ToolUIPart as unknown as { output?: unknown }).output as Record<string, unknown>
305305
}
306306

307-
if (!output || typeof output !== "object") {return null}
307+
const isPlainObject = (v: unknown): v is Record<string, unknown> =>
308+
v !== null && typeof v === "object" && !Array.isArray(v)
309+
310+
if (!isPlainObject(output)) {
311+
return null
312+
}
308313

309314
const out = output
310315

app/components/charts/RadarWidget.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@
22

33
import { Legend, PolarAngleAxis, PolarGrid, PolarRadiusAxis, Radar, RadarChart, ResponsiveContainer, Tooltip } from 'recharts'
44

5-
export type RadarPoint = { subject: string; a: number; b?: number }
5+
export interface RadarPoint { subject: string; a: number; b?: number }
66

77
interface RadarWidgetProps {
88
data: RadarPoint[]
99
height?: number
10-
seriesA?: { key?: 'a'; label?: string; color?: string }
11-
seriesB?: { key?: 'b'; label?: string; color?: string }
10+
seriesA?: { key: 'a'; label?: string; color?: string }
11+
seriesB?: { key: 'b'; label?: string; color?: string }
1212
}
1313

1414
export function RadarWidget({

app/components/navbar.tsx

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,9 @@ export function Navbar() {
8787
</NavigationMenuTrigger>
8888

8989
<NavigationMenuContent>
90-
<div className="grid grid-cols-[auto,200px] gap-4 p-2 items-start">
91-
<div className="flex flex-col gap-2">
90+
<div className="flex flex-col md:flex-row gap-8 p-6 min-w-max">
91+
<div className="flex flex-col gap-3 w-64">
92+
<div className="text-xs font-bold text-muted-foreground uppercase tracking-widest mb-2">Products</div>
9293
<Link href="/chat" className={`flex items-center gap-3 rounded-sm p-2 text-sm ${pathname === "/chat" ? "bg-primary/10 shadow-sm" : "hover:bg-primary/5"}`}>
9394
<svg className="size-5 text-primary" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round">
9495
<path d="M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"/>
@@ -147,8 +148,8 @@ export function Navbar() {
147148
</Link>
148149
</div>
149150

150-
<div className="flex flex-col gap-1">
151-
<div className="text-xs font-semibold text-muted-foreground uppercase tracking-wide">Docs</div>
151+
<div className="flex flex-col gap-2 w-56">
152+
<div className="text-xs font-bold text-muted-foreground uppercase tracking-widest mb-2">Docs</div>
152153
{docsLinks.map((dl) => (
153154
<NavigationMenuLink asChild key={dl.href}>
154155
<Link href={dl.href} className={`flex flex-col gap-0 p-2 rounded-sm text-sm ${pathname === dl.href ? "bg-muted/10 shadow-sm" : "hover:bg-muted/5"}`}>

next.config.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ const nextConfig: NextConfig = {
2020
"playwright-core",
2121
"re2",
2222
"svgjson",
23+
"unpdf"
2324
],
2425
allowedDevOrigins: ['http://localhost:4111', '**'],
2526
typedRoutes: false,

0 commit comments

Comments
 (0)