@mastra/code-sdk 0.1.0-alpha.6 → 0.1.0-alpha.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +25 -0
- package/dist/agents/mastracode-gateway.d.ts +4 -2
- package/dist/agents/mastracode-gateway.d.ts.map +1 -1
- package/dist/agents/mastracode-gateway.js +11 -7
- package/dist/agents/mastracode-gateway.js.map +1 -1
- package/dist/agents/model.js +1 -1
- package/dist/agents/model.js.map +1 -1
- package/dist/agents/workspace.d.ts.map +1 -1
- package/dist/agents/workspace.js +51 -19
- package/dist/agents/workspace.js.map +1 -1
- package/dist/index.js +4 -4
- package/dist/index.js.map +1 -1
- package/dist/onboarding/settings.d.ts +6 -2
- package/dist/onboarding/settings.d.ts.map +1 -1
- package/dist/onboarding/settings.js +6 -2
- package/dist/onboarding/settings.js.map +1 -1
- package/dist/plugins/dependencies.d.ts.map +1 -1
- package/dist/plugins/dependencies.js +28 -58
- package/dist/plugins/dependencies.js.map +1 -1
- package/dist/utils/path-security.d.ts +2 -0
- package/dist/utils/path-security.d.ts.map +1 -0
- package/dist/utils/path-security.js +9 -0
- package/dist/utils/path-security.js.map +1 -0
- package/dist/utils/slash-command-loader.d.ts +5 -1
- package/dist/utils/slash-command-loader.d.ts.map +1 -1
- package/dist/utils/slash-command-loader.js +30 -8
- package/dist/utils/slash-command-loader.js.map +1 -1
- package/package.json +7 -7
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/utils/slash-command-loader.ts"],"sourcesContent":["import { promises as fs } from 'node:fs';\nimport * as path from 'node:path';\nimport { parse as parseYaml } from 'yaml';\nimport { DEFAULT_CONFIG_DIR } from '../constants.js';\n\n/**\n * Metadata for a slash command\n */\nexport interface SlashCommandMetadata {\n /** Command name (e.g., \"git:commit\") */\n name: string;\n /** Human-readable description */\n description: string;\n /** The command template with variables */\n template: string;\n /** Source file path */\n sourcePath: string;\n /** Namespace derived from directory structure */\n namespace?: string;\n /** Whether this command should also be exposed as /goal/<name> */\n goal?: boolean;\n}\n\n/**\n * Parse a command file and extract metadata and template\n * Supports both frontmatter-based and plain markdown files\n */\nexport async function parseCommandFile(filePath: string, baseDir?: string): Promise<SlashCommandMetadata | null> {\n try {\n const content = await fs.readFile(filePath, 'utf-8');\n const trimmedContent = content.trim();\n\n // Check if file has frontmatter (starts with ---)\n if (!trimmedContent.startsWith('---')) {\n // No frontmatter - treat entire file as template\n // Derive name from file path\n const name = baseDir ? extractCommandName(filePath, baseDir) : path.basename(filePath, '.md');\n\n return {\n name,\n description: '',\n template: content,\n sourcePath: filePath,\n };\n }\n\n // Split frontmatter and template\n const parts = content.split('---');\n if (parts.length < 3) {\n return null;\n }\n\n const frontmatter = parts[1]!.trim();\n const template = parts.slice(2).join('---').trim();\n\n // Parse YAML frontmatter\n const metadata = parseYaml(frontmatter) as Record<string, unknown>;\n\n // Derive name from file path if not specified in frontmatter\n let name: string;\n if (typeof metadata?.name === 'string' && metadata.name) {\n name = metadata.name;\n } else if (baseDir) {\n name = extractCommandName(filePath, baseDir);\n } else {\n name = path.basename(filePath, '.md');\n }\n\n return {\n name,\n description: typeof metadata?.description === 'string' ? metadata.description : '',\n template,\n sourcePath: filePath,\n namespace: typeof metadata?.namespace === 'string' ? metadata.namespace : undefined,\n goal: metadata?.goal === true,\n };\n } catch (error) {\n console.error(`Error parsing command file ${filePath}:`, error);\n return null;\n }\n}\n\n/**\n * Extract command name from file path\n * Converts path like \"git/commit.md\" to \"git:commit\"\n */\nexport function extractCommandName(filePath: string, baseDir: string): string {\n const relativePath = path.relative(baseDir, filePath);\n const dirName = path.dirname(relativePath);\n const baseName = path.basename(relativePath, '.md');\n\n if (dirName === '.' || dirName === '') {\n return baseName;\n }\n\n // Replace path separators with colons for namespacing\n const namespace = dirName.replace(/[\\\\/]/g, ':');\n return `${namespace}:${baseName}`;\n}\n\n/**\n * Recursively scan a directory for command files.\n * @param dirPath - Current directory to scan\n * @param rootDir - Original root commands directory (used for namespace derivation).\n * When omitted the first call sets it to dirPath.\n */\nexport async function scanCommandDirectory(dirPath: string, rootDir?: string): Promise<SlashCommandMetadata[]> {\n const baseDir = rootDir ?? dirPath;\n const commands: SlashCommandMetadata[] = [];\n\n try {\n const entries = await fs.readdir(dirPath, { withFileTypes: true });\n\n for (const entry of entries) {\n const fullPath = path.join(dirPath, entry.name);\n\n if (entry.isDirectory()) {\n // Recursively scan subdirectories, preserving the root directory for namespace derivation\n const subCommands = await scanCommandDirectory(fullPath, baseDir);\n commands.push(...subCommands);\n } else if (entry.isFile() && entry.name.endsWith('.md')) {\n // Parse markdown command files, passing the root commands dir as baseDir for name derivation\n const command = await parseCommandFile(fullPath, baseDir);\n if (command) {\n commands.push(command);\n }\n }\n }\n } catch {\n // Directory doesn't exist or can't be read - silently skip\n }\n\n return commands;\n}\n/**\n * Load custom slash commands from all configured directories\n * Priority: mastra project > claude project > opencode project > mastra user > claude user > opencode user\n */\nexport async function loadCustomCommands(\n projectDir?: string,\n configDirName = DEFAULT_CONFIG_DIR,\n extraCommandDirs: string[] = [],\n): Promise<SlashCommandMetadata[]> {\n // Use a Map so later (higher priority) sources override earlier ones with the same name\n const commandMap = new Map<string, SlashCommandMetadata>();\n\n const addCommands = (newCommands: SlashCommandMetadata[]) => {\n for (const cmd of newCommands) {\n commandMap.set(cmd.name, cmd);\n }\n };\n\n const homeDir = process.env.HOME || process.env.USERPROFILE;\n\n // 1. Load from opencode user directory ~/.opencode/command (lowest priority)\n if (homeDir) {\n const opencodeUserDir = path.join(homeDir, '.opencode', 'command');\n const opencodeUserCommands = await scanCommandDirectory(opencodeUserDir);\n addCommands(opencodeUserCommands);\n }\n\n // 2. Load from claude user directory ~/.claude/commands (Claude Code compat)\n if (homeDir) {\n const claudeUserDir = path.join(homeDir, '.claude', 'commands');\n const claudeUserCommands = await scanCommandDirectory(claudeUserDir);\n addCommands(claudeUserCommands);\n }\n\n // 3. Load from mastra user directory ~/<configDirName>/commands\n if (homeDir) {\n const mastraUserDir = path.join(homeDir, configDirName, 'commands');\n const mastraUserCommands = await scanCommandDirectory(mastraUserDir);\n addCommands(mastraUserCommands);\n }\n\n // 4. Load from opencode project directory .opencode/command\n if (projectDir) {\n const opencodeProjectDir = path.join(projectDir, '.opencode', 'command');\n const opencodeProjectCommands = await scanCommandDirectory(opencodeProjectDir);\n addCommands(opencodeProjectCommands);\n }\n\n // 5. Load from claude project directory .claude/commands (Claude Code compat)\n if (projectDir) {\n const claudeProjectDir = path.join(projectDir, '.claude', 'commands');\n const claudeProjectCommands = await scanCommandDirectory(claudeProjectDir);\n addCommands(claudeProjectCommands);\n }\n\n // 6. Load from mastra project directory <configDirName>/commands\n if (projectDir) {\n const mastraProjectDir = path.join(projectDir, configDirName, 'commands');\n const mastraProjectCommands = await scanCommandDirectory(mastraProjectDir);\n addCommands(mastraProjectCommands);\n }\n\n // 7. Load from active plugin command directories (highest priority)\n for (const commandsDir of extraCommandDirs) {\n addCommands(await scanCommandDirectory(commandsDir));\n }\n\n return Array.from(commandMap.values());\n}\n\n/**\n * Get the commands directory path for a project\n */\nexport function getProjectCommandsDir(projectDir: string, configDirName = DEFAULT_CONFIG_DIR): string {\n return path.join(projectDir, configDirName, 'commands');\n}\n\n/**\n * Initialize a commands directory with an example command\n */\nexport async function initCommandsDirectory(projectDir: string, configDirName = DEFAULT_CONFIG_DIR): Promise<void> {\n const commandsDir = getProjectCommandsDir(projectDir, configDirName);\n\n try {\n await fs.mkdir(commandsDir, { recursive: true });\n\n // Create an example command\n const examplePath = path.join(commandsDir, 'example.md');\n const exampleContent = `---\nname: example\ndescription: An example slash command\n---\n\nThis is an example slash command template.\nYou can use variables like \\$ARGUMENTS or \\$1, \\$2 for positional args.\nYou can also include file content with @filename.\nShell commands with !command will be executed and output included.\n`;\n\n try {\n await fs.access(examplePath);\n // File already exists, don't overwrite\n } catch {\n await fs.writeFile(examplePath, exampleContent, 'utf-8');\n }\n } catch (error) {\n console.error('Error initializing commands directory:', error);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AA;AAAA;AAAA;AAWvB,QAAI;AACF,YAAM,GAAG,OAAO,WAAW;AAAA,IAE7B,QAAQ;AACN,YAAM,GAAG,UAAU,aAAa,gBAAgB,OAAO;AAAA,IACzD;AAAA,EACF,SAAS,OAAO;AACd,YAAQ,MAAM,0CAA0C,KAAK;AAAA,EAC/D;AACF;","names":["name"]}
|
|
1
|
+
{"version":3,"sources":["../../src/utils/slash-command-loader.ts"],"sourcesContent":["import { promises as fs } from 'node:fs';\nimport * as path from 'node:path';\nimport { parse as parseYaml } from 'yaml';\nimport { DEFAULT_CONFIG_DIR } from '../constants.js';\nimport { isPathWithinRoot } from './path-security.js';\n\n/**\n * Metadata for a slash command\n */\nexport interface SlashCommandMetadata {\n /** Command name (e.g., \"git:commit\") */\n name: string;\n /** Human-readable description */\n description: string;\n /** The command template with variables */\n template: string;\n /** Source file path */\n sourcePath: string;\n /** Namespace derived from directory structure */\n namespace?: string;\n /** Whether this command should also be exposed as /goal/<name> */\n goal?: boolean;\n}\n\n/**\n * Parse a command file and extract metadata and template\n * Supports both frontmatter-based and plain markdown files\n */\nexport async function parseCommandFile(filePath: string, baseDir?: string): Promise<SlashCommandMetadata | null> {\n try {\n const content = await fs.readFile(filePath, 'utf-8');\n const trimmedContent = content.trim();\n\n // Check if file has frontmatter (starts with ---)\n if (!trimmedContent.startsWith('---')) {\n // No frontmatter - treat entire file as template\n // Derive name from file path\n const name = baseDir ? extractCommandName(filePath, baseDir) : path.basename(filePath, '.md');\n\n return {\n name,\n description: '',\n template: content,\n sourcePath: filePath,\n };\n }\n\n // Split frontmatter and template\n const parts = content.split('---');\n if (parts.length < 3) {\n return null;\n }\n\n const frontmatter = parts[1]!.trim();\n const template = parts.slice(2).join('---').trim();\n\n // Parse YAML frontmatter\n const metadata = parseYaml(frontmatter) as Record<string, unknown>;\n\n // Derive name from file path if not specified in frontmatter\n let name: string;\n if (typeof metadata?.name === 'string' && metadata.name) {\n name = metadata.name;\n } else if (baseDir) {\n name = extractCommandName(filePath, baseDir);\n } else {\n name = path.basename(filePath, '.md');\n }\n\n return {\n name,\n description: typeof metadata?.description === 'string' ? metadata.description : '',\n template,\n sourcePath: filePath,\n namespace: typeof metadata?.namespace === 'string' ? metadata.namespace : undefined,\n goal: metadata?.goal === true,\n };\n } catch (error) {\n console.error(`Error parsing command file ${filePath}:`, error);\n return null;\n }\n}\n\n/**\n * Extract command name from file path\n * Converts path like \"git/commit.md\" to \"git:commit\"\n */\nexport function extractCommandName(filePath: string, baseDir: string): string {\n const relativePath = path.relative(baseDir, filePath);\n const dirName = path.dirname(relativePath);\n const baseName = path.basename(relativePath, '.md');\n\n if (dirName === '.' || dirName === '') {\n return baseName;\n }\n\n // Replace path separators with colons for namespacing\n const namespace = dirName.replace(/[\\\\/]/g, ':');\n return `${namespace}:${baseName}`;\n}\n\n/**\n * Recursively scan a directory for command files.\n * @param dirPath - Current directory to scan\n * @param rootDir - Original root commands directory (used for namespace derivation).\n * When omitted the first call sets it to dirPath.\n */\nexport interface ScanCommandDirectoryOptions {\n allowedRoot?: string;\n visitedDirectories?: Set<string>;\n}\n\nexport async function scanCommandDirectory(\n dirPath: string,\n rootDir?: string,\n options: ScanCommandDirectoryOptions = {},\n): Promise<SlashCommandMetadata[]> {\n const baseDir = rootDir ?? dirPath;\n const commands: SlashCommandMetadata[] = [];\n const visitedDirectories = options.visitedDirectories ?? new Set<string>();\n\n try {\n const realDirectory = await fs.realpath(dirPath);\n const realAllowedRoot = options.allowedRoot ? await fs.realpath(options.allowedRoot) : undefined;\n if (realAllowedRoot && !isPathWithinRoot(realDirectory, realAllowedRoot)) return commands;\n if (visitedDirectories.has(realDirectory)) return commands;\n visitedDirectories.add(realDirectory);\n\n const entries = await fs.readdir(dirPath, { withFileTypes: true });\n\n for (const entry of entries) {\n const fullPath = path.join(dirPath, entry.name);\n const stats = entry.isSymbolicLink() ? await fs.stat(fullPath).catch(() => null) : entry;\n if (!stats) continue;\n\n if (stats.isDirectory()) {\n // Recursively scan subdirectories, preserving the root directory for namespace derivation\n const subCommands = await scanCommandDirectory(fullPath, baseDir, {\n ...options,\n visitedDirectories,\n });\n commands.push(...subCommands);\n } else if (entry.name.endsWith('.md') && stats.isFile()) {\n if (realAllowedRoot) {\n const realFile = await fs.realpath(fullPath).catch(() => null);\n if (!realFile || !isPathWithinRoot(realFile, realAllowedRoot)) continue;\n }\n\n // Parse markdown command files, passing the root commands dir as baseDir for name derivation\n const command = await parseCommandFile(fullPath, baseDir);\n if (command) {\n commands.push(command);\n }\n }\n }\n } catch {\n // Directory doesn't exist or can't be read - silently skip\n }\n\n return commands;\n}\n/**\n * Load custom slash commands from all configured directories\n * Priority: mastra project > claude project > opencode project > mastra user > claude user > opencode user\n */\nexport async function loadCustomCommands(\n projectDir?: string,\n configDirName = DEFAULT_CONFIG_DIR,\n extraCommandDirs: string[] = [],\n): Promise<SlashCommandMetadata[]> {\n // Use a Map so later (higher priority) sources override earlier ones with the same name\n const commandMap = new Map<string, SlashCommandMetadata>();\n\n const addCommands = (newCommands: SlashCommandMetadata[]) => {\n for (const cmd of newCommands) {\n commandMap.set(cmd.name, cmd);\n }\n };\n\n const homeDir = process.env.HOME || process.env.USERPROFILE;\n\n // 1. Load from opencode user directory ~/.opencode/command (lowest priority)\n if (homeDir) {\n const opencodeUserDir = path.join(homeDir, '.opencode', 'command');\n const opencodeUserCommands = await scanCommandDirectory(opencodeUserDir);\n addCommands(opencodeUserCommands);\n }\n\n // 2. Load from claude user directory ~/.claude/commands (Claude Code compat)\n if (homeDir) {\n const claudeUserDir = path.join(homeDir, '.claude', 'commands');\n const claudeUserCommands = await scanCommandDirectory(claudeUserDir);\n addCommands(claudeUserCommands);\n }\n\n // 3. Load from mastra user directory ~/<configDirName>/commands\n if (homeDir) {\n const mastraUserDir = path.join(homeDir, configDirName, 'commands');\n const mastraUserCommands = await scanCommandDirectory(mastraUserDir);\n addCommands(mastraUserCommands);\n }\n\n // 4. Load from opencode project directory .opencode/command\n if (projectDir) {\n const opencodeProjectDir = path.join(projectDir, '.opencode', 'command');\n const opencodeProjectCommands = await scanCommandDirectory(opencodeProjectDir, undefined, {\n allowedRoot: projectDir,\n });\n addCommands(opencodeProjectCommands);\n }\n\n // 5. Load from claude project directory .claude/commands (Claude Code compat)\n if (projectDir) {\n const claudeProjectDir = path.join(projectDir, '.claude', 'commands');\n const claudeProjectCommands = await scanCommandDirectory(claudeProjectDir, undefined, {\n allowedRoot: projectDir,\n });\n addCommands(claudeProjectCommands);\n }\n\n // 6. Load from mastra project directory <configDirName>/commands\n if (projectDir) {\n const mastraProjectDir = path.join(projectDir, configDirName, 'commands');\n const mastraProjectCommands = await scanCommandDirectory(mastraProjectDir, undefined, {\n allowedRoot: projectDir,\n });\n addCommands(mastraProjectCommands);\n }\n\n // 7. Load from active plugin command directories (highest priority)\n for (const commandsDir of extraCommandDirs) {\n addCommands(await scanCommandDirectory(commandsDir, undefined, { allowedRoot: commandsDir }));\n }\n\n return Array.from(commandMap.values());\n}\n\n/**\n * Get the commands directory path for a project\n */\nexport function getProjectCommandsDir(projectDir: string, configDirName = DEFAULT_CONFIG_DIR): string {\n return path.join(projectDir, configDirName, 'commands');\n}\n\n/**\n * Initialize a commands directory with an example command\n */\nexport async function initCommandsDirectory(projectDir: string, configDirName = DEFAULT_CONFIG_DIR): Promise<void> {\n const commandsDir = getProjectCommandsDir(projectDir, configDirName);\n\n try {\n await fs.mkdir(commandsDir, { recursive: true });\n\n // Create an example command\n const examplePath = path.join(commandsDir, 'example.md');\n const exampleContent = `---\nname: example\ndescription: An example slash command\n---\n\nThis is an example slash command template.\nYou can use variables like \\$ARGUMENTS or \\$1, \\$2 for positional args.\nYou can also include file content with @filename.\nShell commands with !command will be executed and output included.\n`;\n\n try {\n await fs.access(examplePath);\n // File already exists, don't overwrite\n } catch {\n await fs.writeFile(examplePath, exampleContent, 'utf-8');\n }\n } catch (error) {\n console.error('Error initializing commands directory:', error);\n }\n}\n"],"mappings":"AAAA,SAAS,YAAY,UAAU;AAC/B,YAAY,U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Aa;AAAA,IACf,CAAC;AACD,gBAAY,qBAAqB;AAAA,EACnC;AAGA,MAAI,YAAY;AACd,UAAM,mBAAmB,KAAK,KAAK,YAAY,eAAe,UAAU;AACxE,UAAM,wBAAwB,MAAM,qBAAqB,kBAAkB,QAAW;AAAA,MACpF,aAAa;AAAA,IACf,CAAC;AACD,gBAAY,qBAAqB;AAAA,EACnC;AAGA,aAAW,eAAe,kBAAkB;AAC1C,gBAAY,MAAM,qBAAqB,aAAa,QAAW,EAAE,aAAa,YAAY,CAAC,CAAC;AAAA,EAC9F;AAEA,SAAO,MAAM,KAAK,WAAW,OAAO,CAAC;AACvC;AAKO,SAAS,sBAAsB,YAAoB,gBAAgB,oBAA4B;AACpG,SAAO,KAAK,KAAK,YAAY,eAAe,UAAU;AACxD;AAKA,eAAsB,sBAAsB,YAAoB,gBAAgB,oBAAmC;AACjH,QAAM,cAAc,sBAAsB,YAAY,aAAa;AAEnE,MAAI;AACF,UAAM,GAAG,MAAM,aAAa,EAAE,WAAW,KAAK,CAAC;AAG/C,UAAM,cAAc,KAAK,KAAK,aAAa,YAAY;AACvD,UAAM,iBAAiB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAWvB,QAAI;AACF,YAAM,GAAG,OAAO,WAAW;AAAA,IAE7B,QAAQ;AACN,YAAM,GAAG,UAAU,aAAa,gBAAgB,OAAO;AAAA,IACzD;AAAA,EACF,SAAS,OAAO;AACd,YAAQ,MAAM,0CAA0C,KAAK;AAAA,EAC/D;AACF;","names":["name"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mastra/code-sdk",
|
|
3
|
-
"version": "0.1.0-alpha.
|
|
3
|
+
"version": "0.1.0-alpha.7",
|
|
4
4
|
"description": "Mastra Code SDK: the agent core behind Mastra Code (everything except the TUI) — build your own UIs and surfaces on top of it",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"publishConfig": {
|
|
@@ -56,19 +56,19 @@
|
|
|
56
56
|
"vscode-languageserver-protocol": "^3.17.5",
|
|
57
57
|
"yaml": "^2.7.1",
|
|
58
58
|
"zod": "^4.3.6",
|
|
59
|
-
"@mastra/core": "1.51.0-alpha.6",
|
|
60
59
|
"@mastra/agent-browser": "0.4.1",
|
|
61
|
-
"@mastra/
|
|
60
|
+
"@mastra/duckdb": "1.5.1",
|
|
61
|
+
"@mastra/core": "1.51.0-alpha.7",
|
|
62
62
|
"@mastra/github-signals": "0.2.2",
|
|
63
63
|
"@mastra/libsql": "1.16.0-alpha.0",
|
|
64
64
|
"@mastra/mcp": "1.14.0-alpha.0",
|
|
65
|
-
"@mastra/memory": "1.23.0-alpha.3",
|
|
66
|
-
"@mastra/observability": "1.16.1-alpha.0",
|
|
67
|
-
"@mastra/duckdb": "1.5.1",
|
|
68
65
|
"@mastra/pg": "1.15.1",
|
|
66
|
+
"@mastra/observability": "1.16.1-alpha.1",
|
|
67
|
+
"@mastra/schema-compat": "1.3.4-alpha.1",
|
|
68
|
+
"@mastra/memory": "1.23.0-alpha.3",
|
|
69
69
|
"@mastra/stagehand": "0.3.0",
|
|
70
70
|
"@mastra/tavily": "1.1.0",
|
|
71
|
-
"@mastra/
|
|
71
|
+
"@mastra/fastembed": "1.2.0"
|
|
72
72
|
},
|
|
73
73
|
"devDependencies": {
|
|
74
74
|
"@libsql/client": "^0.17.4",
|