Skip to main content
Glama

π“‚€π“’π“‹Ήπ”Έβ„•π•Œπ”Ήπ•€π•Šπ“‹Ήπ“’π“‚€ - Intelligent Guidance for

by Hive-Academy

init_rules

Initialize workflow rules for AI agents (cursor or copilot) to guide project development. Specify the agent and project root to deploy rules effectively.

Instructions

Initialize Anubis workflow rules to specified AI agent (cursor or copilot)

Input Schema

NameRequiredDescriptionDefault
agentNameYesAI agent to deploy rules for (cursor or copilot)
projectRootNoRoot directory of the target project. Defaults to current working directory.

Input Schema (JSON Schema)

{ "$schema": "http://json-schema.org/draft-07/schema#", "additionalProperties": false, "properties": { "agentName": { "description": "AI agent to deploy rules for (cursor or copilot)", "enum": [ "cursor", "copilot", "roocode", "kilocode" ], "type": "string" }, "projectRoot": { "description": "Root directory of the target project. Defaults to current working directory.", "type": "string" } }, "required": [ "agentName" ], "type": "object" }

Implementation Reference

  • MCP tool handler function for 'init_rules'. Handles input validation implicitly via schema, delegates to InitRulesService, and formats MCP response.
    @Tool({ name: 'init_rules', description: 'Initialize Anubis workflow rules to specified AI agent (cursor or copilot)', parameters: InitRulesInputSchema as ZodSchema<InitRulesInput>, }) async InitRules(input: InitRulesInput) { try { const projectRoot = input.projectRoot || process.cwd(); const result = await this.initRulesService.InitRules( input.agentName, projectRoot, ); return { content: [ { type: 'text' as const, text: JSON.stringify( { success: result.success, message: 'message' in result ? result.message : 'No message available', data: { targetFile: result.targetFile }, timestamp: new Date().toISOString(), }, null, 2, ), }, ], }; } catch (error) { return { content: [ { type: 'text' as const, text: JSON.stringify( { success: false, error: { message: error.message, code: 'DEPLOY_RULES_ERROR', }, timestamp: new Date().toISOString(), }, null, 2, ), }, ], }; } }
  • Zod input schema defining parameters for the init_rules tool: agentName (enum) and optional projectRoot.
    const InitRulesInputSchema = z.object({ agentName: z .enum(['cursor', 'copilot', 'roocode', 'kilocode']) .describe('AI agent to deploy rules for (cursor or copilot)'), projectRoot: z .string() .optional() .describe( 'Root directory of the target project. Defaults to current working directory.', ), });
  • Core handler logic for deploying Anubis workflow rules to the specified AI agent. Manages templates, directories, frontmatter, and special handling for roocode/kilocode.
    async InitRules( agentName: string, projectRoot: string, ): Promise<{ success: boolean; message: string; targetFile?: string; }> { const config = this.agentConfigs[agentName]; if (!config) { return { success: false, message: `Unsupported AI agent: ${agentName}. Supported agents: ${Object.keys(this.agentConfigs).join(', ')}`, }; } try { // Ensure target directories exist await this.ensureDirectories(projectRoot, config.ensureDirectories); // Use the provided template file if specified, otherwise use the default from config const templateToUse = config.sourceTemplate; // Read source template const sourceContent = await this.readTemplate(templateToUse); // Process content (add frontmatter if required) const processedContent = config.requiresFrontmatter ? this.addFrontmatter(sourceContent, config) : sourceContent; // Write to target location const targetFilePath = path.join( projectRoot, config.targetPath, config.targetFileName, ); await fs.writeFile(targetFilePath, processedContent, 'utf8'); if (config.specialHandling === 'roocode') { const sourceJsonPath = path.join( this.templatesPath, 'custom-mode.json', ); const targetJsonPath = path.join(projectRoot, '.roomodes'); await fs.copyFile(sourceJsonPath, targetJsonPath); } if (config.specialHandling === 'kilocode') { const sourceJsonPath = path.join( this.templatesPath, 'custom-mode.json', ); const targetJsonPath = path.join(projectRoot, '.kilocodemodes'); await fs.copyFile(sourceJsonPath, targetJsonPath); } return { success: true, message: `Successfully deployed Anubis rules for ${config.name}`, targetFile: targetFilePath, }; } catch (error) { return { success: false, message: `Failed to deploy rules for ${config.name}: ${error.message}`, }; } }
  • NestJS module that provides and exports InitRulesMcpService (containing the MCP tool) and InitRulesService.
    @Module({ providers: [InitRulesService, InitRulesMcpService], exports: [InitRulesService, InitRulesMcpService], }) export class InitRulesModule {}
  • Configuration object defining supported AI agents, their templates, target paths, and special handling.
    private readonly agentConfigs: Record<string, AIAgentConfig> = { cursor: { name: 'Cursor IDE', sourceTemplate: 'workflow-protocol-function-calls.md', targetPath: '.cursor/rules', targetFileName: '000-workflow-core.mdc', requiresFrontmatter: true, ensureDirectories: ['.cursor', '.cursor/rules'], }, copilot: { name: 'GitHub Copilot', sourceTemplate: 'workflow-protocol-function-calls.md', targetPath: '.github', targetFileName: 'copilot-instructions.md', requiresFrontmatter: false, ensureDirectories: ['.github'], }, roocode: { name: 'RooCode', sourceTemplate: 'workflow-protocol-xml.md', targetPath: '.roo/rules-anubis', targetFileName: 'rules.md', requiresFrontmatter: false, // XML file doesn't need frontmatter ensureDirectories: ['.roo', '.roo/rules-anubis'], specialHandling: 'roocode', // Add special flag }, kilocode: { name: 'KiloCode', sourceTemplate: 'workflow-protocol-xml.md', targetPath: '.kilocode/rules-anubis', targetFileName: 'rules.md', requiresFrontmatter: false, // XML file doesn't need frontmatter ensureDirectories: ['.kilocode', '.kilocode/rules-anubis'], specialHandling: 'kilocode', // Add special flag }, };

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/Hive-Academy/Anubis-MCP'

If you have feedback or need assistance with the MCP directory API, please join our Discord server