fix formatting

This commit is contained in:
Joe Danziger
2025-05-09 12:21:51 -04:00
parent 476048b184
commit d48a3d3edc
7 changed files with 129 additions and 91 deletions

View File

@@ -39,7 +39,9 @@ export function registerInitializeProjectTool(server) {
rules: z
.array(z.string())
.optional()
.describe('List of brand rules to include at initialization (e.g., ["cursor", "roo"]). If omitted, defaults to ["cursor"].')
.describe(
'List of brand rules to include at initialization (e.g., ["cursor", "roo"]). If omitted, defaults to ["cursor"].'
)
}),
execute: withNormalizedProjectRoot(async (args, context) => {
const { log } = context;

View File

@@ -5,9 +5,9 @@
import { z } from 'zod';
import {
createErrorResponse,
handleApiResult,
withNormalizedProjectRoot
createErrorResponse,
handleApiResult,
withNormalizedProjectRoot
} from './utils.js';
import { rulesDirect } from '../core/direct-functions/rules.js';
@@ -16,24 +16,42 @@ import { rulesDirect } from '../core/direct-functions/rules.js';
* @param {Object} server - FastMCP server instance
*/
export function registerRulesTool(server) {
server.addTool({
name: 'rules',
description: 'Add or remove brand rules and MCP config from the project (mirrors CLI rules add/remove).',
parameters: z.object({
action: z.enum(['add', 'remove']).describe('Whether to add or remove brand rules.'),
rules: z.array(z.string()).min(1).describe('List of brand rules to add or remove (e.g., ["roo", "windsurf"]).'),
projectRoot: z.string().describe('The root directory of the project. Must be an absolute path.'),
yes: z.boolean().optional().default(true).describe('Run non-interactively (default: true).')
}),
execute: withNormalizedProjectRoot(async (args, { log, session }) => {
try {
log.info(`[rules tool] Executing action: ${args.action} for rules: ${args.rules.join(', ')} in ${args.projectRoot}`);
const result = await rulesDirect(args, log, { session });
return handleApiResult(result, log);
} catch (error) {
log.error(`[rules tool] Error: ${error.message}`);
return createErrorResponse(error.message, { details: error.stack });
}
})
});
server.addTool({
name: 'rules',
description:
'Add or remove brand rules and MCP config from the project (mirrors CLI rules add/remove).',
parameters: z.object({
action: z
.enum(['add', 'remove'])
.describe('Whether to add or remove brand rules.'),
rules: z
.array(z.string())
.min(1)
.describe(
'List of brand rules to add or remove (e.g., ["roo", "windsurf"]).'
),
projectRoot: z
.string()
.describe(
'The root directory of the project. Must be an absolute path.'
),
yes: z
.boolean()
.optional()
.default(true)
.describe('Run non-interactively (default: true).')
}),
execute: withNormalizedProjectRoot(async (args, { log, session }) => {
try {
log.info(
`[rules tool] Executing action: ${args.action} for rules: ${args.rules.join(', ')} in ${args.projectRoot}`
);
const result = await rulesDirect(args, log, { session });
return handleApiResult(result, log);
} catch (error) {
log.error(`[rules tool] Error: ${error.message}`);
return createErrorResponse(error.message, { details: error.stack });
}
})
});
}