|
| 1 | +# Skill Preload Feature — Implementation State |
| 2 | + |
| 3 | +Branch: `chat-ux-enhancements` (super-canopy) |
| 4 | +Mastra PR: superset-sh/mastra#9 (branch `mk/skill-preload-and-command-paths`) |
| 5 | + |
| 6 | +## What this does |
| 7 | + |
| 8 | +When a user embeds a `/command` chip in a message — e.g. "please help me /redesign this component" — the system: |
| 9 | + |
| 10 | +1. Extracts the custom command name(s) from the chip nodes |
| 11 | +2. Strips the leading `/` from each chip in the message text sent to the LLM |
| 12 | +3. Passes the command names as `metadata.skills` to the backend |
| 13 | +4. The backend forwards them as `preloadSkills` to `harness.sendMessage()` |
| 14 | +5. The harness prepends an instruction so the agent calls `skill(name)` for each one before responding |
| 15 | +6. Visible `SkillToolCall` blocks appear in the chat UI before the LLM reply |
| 16 | + |
| 17 | +Built-in slash commands (`/new`, `/stop`, `/model`, `/mcp`) are unaffected — only `kind === "custom"` commands are extracted as skills. |
| 18 | + |
| 19 | +--- |
| 20 | + |
| 21 | +## Files changed in super-canopy |
| 22 | + |
| 23 | +### New files |
| 24 | +- `apps/desktop/src/renderer/components/Chat/ChatInterface/components/ToolCallBlock/components/SkillToolCall/SkillToolCall.tsx` |
| 25 | +- `apps/desktop/src/renderer/components/Chat/ChatInterface/components/ToolCallBlock/components/SkillToolCall/index.ts` |
| 26 | + |
| 27 | +### Modified files |
| 28 | + |
| 29 | +**`packages/chat/src/server/trpc/zod.ts`** |
| 30 | +- Added `skills?: z.array(z.string())` to `sendMessageInput` metadata schema |
| 31 | + |
| 32 | +**`packages/chat/src/server/trpc/service.ts`** |
| 33 | +- Passes `preloadSkills: input.metadata?.skills` to `harness.sendMessage()` |
| 34 | + |
| 35 | +**`apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/components/WorkspaceChat/components/WorkspaceChatInterface/utils/sendMessage/sendMessage.ts`** |
| 36 | +- Added `skills?: string[]` to `ChatSendMessageInput.metadata` type |
| 37 | + |
| 38 | +**`apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/components/WorkspaceChat/components/WorkspaceChatInterface/ChatPaneInterface.tsx`** |
| 39 | +- Added import: `findSlashCommandByNameOrAlias` from `@superset/chat/shared` |
| 40 | +- In `handleSend`: extracts custom skill chip names from content via regex, strips `/` prefix, passes as `metadata.skills` |
| 41 | +- Added `slashCommands` to `useCallback` dependency array |
| 42 | + |
| 43 | +**`apps/desktop/src/renderer/components/Chat/ChatInterface/components/ToolCallBlock/ToolCallBlock.tsx`** |
| 44 | +- Added import + registration for `SkillToolCall` |
| 45 | +- Handles `toolName === "skill" || toolName === "load_skill"` |
| 46 | + |
| 47 | +--- |
| 48 | + |
| 49 | +## Files changed in mastra fork (superset-sh/mastra#9) |
| 50 | + |
| 51 | +**`mastracode/src/agents/workspace.ts`** |
| 52 | +- Added `.claude/commands/` and `.agents/commands/` (local + global) to `skillPaths` |
| 53 | +- These directories are where Superset slash command files live (`.md` files) |
| 54 | + |
| 55 | +**`packages/core/src/harness/harness.ts`** |
| 56 | +- Added `preloadSkills?: string[]` to `sendMessage()` signature |
| 57 | +- When provided: prepends `<system>` block instructing agent to call `skill(name)` for each entry before responding |
| 58 | + |
| 59 | +--- |
| 60 | + |
| 61 | +## Local testing setup |
| 62 | + |
| 63 | +The `package.json` resolutions in this branch are **temporarily pointing to local tarballs** at `/tmp/mastra-local/`. These files only exist on the machine where they were built. |
| 64 | + |
| 65 | +To rebuild from the mastra fork on a new machine: |
| 66 | + |
| 67 | +```bash |
| 68 | +# 1. Clone or pull the mastra fork |
| 69 | +git clone https://github.com/superset-sh/mastra.git ~/Sites/mastra |
| 70 | +cd ~/Sites/mastra |
| 71 | +git checkout mk/skill-preload-and-command-paths |
| 72 | + |
| 73 | +# 2. Install dependencies |
| 74 | +corepack enable |
| 75 | +pnpm install |
| 76 | + |
| 77 | +# 3. Build mastracode and @mastra/core |
| 78 | +pnpm turbo build --filter="@mastra/core" --filter="mastracode" |
| 79 | + |
| 80 | +# 4. Pack the tarballs |
| 81 | +mkdir -p /tmp/mastra-local |
| 82 | +cd mastracode && pnpm pack --pack-destination /tmp/mastra-local && cd .. |
| 83 | +cd packages/core && pnpm pack --pack-destination /tmp/mastra-local && cd ../.. |
| 84 | + |
| 85 | +# 5. Wire into super-canopy (already done in package.json on this branch) |
| 86 | +cd /path/to/super-canopy |
| 87 | +bun install |
| 88 | +``` |
| 89 | + |
| 90 | +To restore production packages after testing: |
| 91 | + |
| 92 | +```bash |
| 93 | +# In super-canopy package.json, revert resolutions back to: |
| 94 | +# "mastracode": "https://github.com/superset-sh/mastra/releases/download/mastracode-v0.4.0-superset.16/mastracode-0.10.0-alpha.6.tgz" |
| 95 | +# "@mastra/core": "https://github.com/superset-sh/mastra/releases/download/mastracode-v0.4.0-superset.16/mastra-core-1.18.0-alpha.3.tgz" |
| 96 | +bun install |
| 97 | +``` |
| 98 | + |
| 99 | +Once superset-sh/mastra#9 is merged and a new tarball release is cut, update the `resolutions` URLs to point to the new release and remove the local tarball entries. |
| 100 | + |
| 101 | +--- |
| 102 | + |
| 103 | +## What's NOT done yet |
| 104 | + |
| 105 | +- The `package.json` resolutions need to be reverted to GitHub URLs before merging this branch (the local `/tmp/mastra-local/` paths will break on CI and other machines) |
| 106 | +- Once mastra#9 is merged + released as `mastracode-v0.4.0-superset.17` (or similar), update resolutions to the new release URLs |
| 107 | +- The `TiptapPromptEditor`'s `SlashCommandPreview` component shows a preview for the old single-command-at-start flow — may want to update it to handle embedded chips |
| 108 | +- Consider whether the `focusShortcutText` hint in the workspace `ChatInputFooter` needs to be re-added (it was removed in a previous refactor; the main `ChatInputFooter` passes it via `TiptapPromptEditor` but the workspace version does not pass `sessionId`/`workspaceId`) |
| 109 | + |
| 110 | +--- |
| 111 | + |
| 112 | +## How to test |
| 113 | + |
| 114 | +1. Add a command file to the project: |
| 115 | + ```bash |
| 116 | + echo "You are a UI redesign expert. Analyze the component and suggest improvements." > .claude/commands/redesign.md |
| 117 | + ``` |
| 118 | + |
| 119 | +2. Start the desktop app: |
| 120 | + ```bash |
| 121 | + bun dev --filter=@superset/desktop |
| 122 | + ``` |
| 123 | + |
| 124 | +3. In chat, type `help me /redesign`, select `redesign` from the slash command popover, then submit. |
| 125 | + |
| 126 | +4. Expected: `Skill(redesign)` tool call block appears in the chat before the LLM reply, with "Successfully loaded skill" shown when complete. |
0 commit comments