Skip to main content
Glama

aida_log_rule

Logs project-level technical rules for AI development, capturing patterns from coding deviations to improve code quality through standardized guidelines.

Instructions

沉淀项目规则。当偏差的 rootCause 为 rule-missing 且修复方案属于项目级技术规范(非业务逻辑)时,询问用户同意后调用此工具沉淀规则。仅限:公共组件使用规范、API 调用规范、参数传递规范、代码风格/架构规范。禁止沉淀业务逻辑。

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
contentYes规则内容,简洁描述项目规范
categoryYes规则分类
sourceDeviationNo关联的偏差 ID,如 DEV-01

Implementation Reference

  • The `handleLogRule` function implements the logic for the `aida_log_rule` MCP tool, which records project-level rules in both a central registry and the current session's `run.json`.
    function handleLogRule(args: any): any {
      const { path, data } = ensureRunJson();
      const branch = getBranchName();
      const dev = getDevName();
      const category = args.category || 'general';
      const content = args.content;
    
      // Write to project-level registry with fingerprint dedup
      const { entry, isDuplicate } = addRule(projectRoot, {
        content,
        category,
        branch,
        deviation: args.sourceDeviation || null,
        author: dev,
        status: 'active',
      });
    
      if (isDuplicate) {
        return { success: true, message: `规则已存在: ${entry.id}(fingerprint 重复)`, ruleId: entry.id, isDuplicate: true };
      }
    
      // Also record in run.json.rules[] for per-run tracking
      const localId = nextId(data.rules, 'RULE');
      data.rules.push({
        ruleId: localId,
        file: `rules.json#${entry.id}`,
        content,
        sourceDeviation: args.sourceDeviation || null,
        sedimentedAt: now(),
      });
      data.summary.rulesSedimented = data.rules.filter(r => (r as any).status !== 'pending').length;
      addEvent(data, 'rule_sedimented', { ruleId: localId, registryId: entry.id });
      addTimeline(data, 'rule', `${localId}: ${content.substring(0, 50)}`);
      save(path, data);
    
      // Rebuild markdown views so AI can read rules next session
      buildRuleViews(projectRoot);
    
      return { success: true, ruleId: entry.id, message: `规则已沉淀: ${entry.id} [${category}] ${content.substring(0, 60)}` };
    }
  • The `aida_log_rule` tool definition, including name, description, and input schema.
      name: 'aida_log_rule',
      description: '沉淀项目规则。当偏差的 rootCause 为 rule-missing 且修复方案属于项目级技术规范(非业务逻辑)时,询问用户同意后调用此工具沉淀规则。仅限:公共组件使用规范、API 调用规范、参数传递规范、代码风格/架构规范。禁止沉淀业务逻辑。',
      inputSchema: {
        type: 'object',
        properties: {
          content: { type: 'string', description: '规则内容,简洁描述项目规范' },
          category: { type: 'string', enum: [...RULE_CATEGORIES], description: '规则分类' },
          sourceDeviation: { type: 'string', description: '关联的偏差 ID,如 DEV-01' },
        },
        required: ['content', 'category'],
      },
    },

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/LWTlong/ai-dev-analytics'

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