vale_sync
Download Vale style packages to resolve missing styles errors by reading configuration files and fetching required resources.
Instructions
Download Vale styles and packages by running 'vale sync'. Use this when you see errors about missing styles directories (E100 errors like 'The path does not exist'). This command reads the .vale.ini configuration and downloads the required style packages.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| config_path | No | Optional path to .vale.ini file. If not provided, uses the server's configured path or searches in the current directory. |
Implementation Reference
- src/index.ts:283-338 (handler)Main execution handler for the 'vale_sync' tool. Validates input, checks Vale installation, determines config path, calls syncValeStyles helper, and formats success/error responses.case "vale_sync": { const { config_path } = args as { config_path?: string }; debug(`vale_sync called - config_path: ${config_path}`); // Check if Vale is available const valeCheck = await checkValeInstalled(); if (!valeCheck.installed) { return createValeNotInstalledResponse(); } // Determine which config to use const effectiveConfigPath = config_path || valeConfigPath; // Run vale sync const syncResult = await syncValeStyles(effectiveConfigPath); debug(`vale_sync result - success: ${syncResult.success}`); if (syncResult.success) { return { content: [ { type: "text", text: `✅ **Vale Sync Successful** ${syncResult.message} ${syncResult.output ? `**Output:**\n\`\`\`\n${syncResult.output}\n\`\`\`` : ""} The styles have been downloaded and are ready to use. You can now run \`check_file\` again.`, }, ], }; } else { return { content: [ { type: "text", text: `❌ **Vale Sync Failed** ${syncResult.message} ${syncResult.error ? `**Error:**\n\`\`\`\n${syncResult.error}\n\`\`\`` : ""} Please check your .vale.ini configuration and ensure: 1. The StylesPath is correct 2. Packages are properly defined 3. You have internet connectivity to download packages See Vale documentation: https://vale.sh/docs/topics/packages/`, }, ], }; } }
- src/index.ts:212-225 (schema)Tool definition and input schema for 'vale_sync', specifying the optional config_path parameter.{ name: "vale_sync", description: "Download Vale styles and packages by running 'vale sync'. Use this when you see errors about missing styles directories (E100 errors like 'The path does not exist'). This command reads the .vale.ini configuration and downloads the required style packages.", inputSchema: { type: "object", properties: { config_path: { type: "string", description: "Optional path to .vale.ini file. If not provided, uses the server's configured path or searches in the current directory.", }, }, }, },
- src/index.ts:244-248 (registration)Registration of tool list handler that includes 'vale_sync' in the available tools returned to clients.server.setRequestHandler(ListToolsRequestSchema, async () => { return { tools: TOOLS, }; });
- src/vale-runner.ts:82-127 (helper)Helper function that executes the 'vale sync' CLI command with optional config file, handling working directory and returning success/error with output.export async function syncValeStyles(configPath?: string): Promise<{ success: boolean; message: string; output?: string; error?: string; }> { try { // Build command let command = "vale sync"; let workingDir = process.cwd(); // If config path provided, use its directory as working dir (Fix #9: async file check) if (configPath) { try { await fs.access(configPath, fsSync.constants.R_OK); workingDir = path.dirname(path.resolve(configPath)); command += ` --config="${configPath}"`; } catch { // Config path doesn't exist or isn't readable, use default console.error(`Warning: Config path ${configPath} is not accessible`); } } console.error(`Running: ${command}`); console.error(`Working directory: ${workingDir}`); const { stdout, stderr } = await execAsync(command, { cwd: workingDir, }); const output = stdout + (stderr ? `\n${stderr}` : ""); return { success: true, message: "Vale styles synchronized successfully", output: output.trim(), }; } catch (error) { const errorMsg = error instanceof Error ? error.message : "Unknown error"; return { success: false, message: "Failed to sync Vale styles", error: errorMsg, }; } }