Skip to main content
Glama

aida_log_files

Log file changes from git diffs to track code modifications and line counts for AI development observability.

Instructions

记录文件变更。无需传参,自动扫描 git diff 获取变更文件列表和行数。在完成一轮代码修改后调用。

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The handler function 'handleLogFiles' implements the 'aida_log_files' tool logic. It scans git diffs, parses changes, updates the project run data, and saves the result.
    function handleLogFiles(): any {
      const { path, data } = ensureRunJson();
    
      // Auto-scan git diff
      let diffOutput = '';
      try {
        diffOutput = execSync('git diff --stat HEAD', { cwd: projectRoot, encoding: 'utf-8' });
      } catch {
        // If no HEAD (first commit), try against empty tree
        try {
          diffOutput = execSync('git diff --stat --cached', { cwd: projectRoot, encoding: 'utf-8' });
        } catch {
          return { success: true, message: '没有检测到文件变更', filesLogged: 0 };
        }
      }
    
      if (!diffOutput.trim()) {
        return { success: true, message: '没有检测到文件变更', filesLogged: 0 };
      }
    
      // Parse git diff --stat output
      // Format: " src/foo.ts | 10 ++++------"  or  " src/bar.ts | 5 +++++"
      const lines = diffOutput.split('\n').filter(l => l.includes('|'));
      let totalAdded = 0;
      let totalRemoved = 0;
      const filesLogged: string[] = [];
    
      for (const line of lines) {
        const match = line.match(/^\s*(.+?)\s*\|\s*(\d+)\s*([+-]*)/);
        if (!match) continue;
    
        const filePath = match[1].trim();
        const changes = parseInt(match[2]) || 0;
        const indicators = match[3] || '';
    
        // Count + and - in the indicators
        const plusCount = (indicators.match(/\+/g) || []).length;
        const minusCount = (indicators.match(/-/g) || []).length;
        const total = plusCount + minusCount;
    
        let linesAdded = 0;
        let linesRemoved = 0;
        if (total > 0) {
          linesAdded = Math.round(changes * plusCount / total);
          linesRemoved = Math.round(changes * minusCount / total);
        } else {
          linesAdded = changes;
        }
    
        // Determine change type
        let changeType: 'created' | 'modified' | 'deleted' = 'modified';
        if (linesRemoved === 0 && linesAdded > 0) changeType = 'created';
    
        const existing = data.files.find(f => f.path === filePath);
        if (existing) {
          existing.changeCount = (existing.changeCount || 1) + 1;
          existing.linesAdded += linesAdded;
          existing.linesRemoved += linesRemoved;
          existing.lastModified = now();
        } else {
          data.files.push({
            path: filePath,
            changeType,
            linesAdded,
            linesRemoved,
            changeCount: 1,
            lastModified: now(),
          });
        }
    
        totalAdded += linesAdded;
        totalRemoved += linesRemoved;
        filesLogged.push(filePath);
      }
    
      data.summary.filesChanged = data.files.length;
      data.summary.linesAdded = data.files.reduce((s, f) => s + (f.linesAdded || 0), 0);
      data.summary.linesRemoved = data.files.reduce((s, f) => s + (f.linesRemoved || 0), 0);
      addEvent(data, 'files_scanned', { count: filesLogged.length });
      save(path, data);
    
      return {
        success: true,
        filesLogged: filesLogged.length,
        linesAdded: totalAdded,
        linesRemoved: totalRemoved,
        message: `${filesLogged.length} files logged (+${totalAdded} -${totalRemoved})`,
      };
    }
  • Tool registration for 'aida_log_files' within the main message switch-case block.
    case 'aida_log_files':
      result = handleLogFiles();
      break;
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden of behavioral disclosure. It successfully explains the automatic git diff scanning mechanism and zero-parameter design, but lacks details on data persistence, output format, or whether the recording operation has side effects on the repository.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Three sentences with zero waste: first states purpose, second explains mechanism and parameters, third specifies invocation timing. Information is front-loaded and appropriately sized for the tool's simplicity.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a zero-parameter tool without output schema, the description adequately covers purpose, invocation context, and data source. It omits output format details, but this is acceptable given the lack of output schema and the tool's straightforward logging nature.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

With zero parameters, the baseline score is 4. The description appropriately confirms no arguments are required ('无需传参') and does not need to compensate for missing schema documentation.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description uses a specific verb ('记录'/record) with a clear resource ('文件变更'/file changes) and distinguishes itself from siblings by specifying the unique mechanism ('自动扫描 git diff'/automatically scans git diff) rather than logging bugs, reviews, or rules like the other aida_log_* tools.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines5/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Provides explicit temporal guidance on when to invoke: '在完成一轮代码修改后调用' (Call after completing a round of code modifications). It also clarifies the zero-parameter requirement ('无需传参'), eliminating confusion about whether arguments are needed.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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