Skip to content

feat: named agents, audit timestamps, --trace logging#32

Merged
kienbui1995 merged 1 commit intomainfrom
feat/named-agents-audit-trace
Apr 11, 2026
Merged

feat: named agents, audit timestamps, --trace logging#32
kienbui1995 merged 1 commit intomainfrom
feat/named-agents-audit-trace

Conversation

@kienbui1995
Copy link
Copy Markdown
Owner

@kienbui1995 kienbui1995 commented Apr 11, 2026

Named Agents

<!-- .magic-code/agents/reviewer.md -->
---
model: claude-haiku-4-5
description: Code review agent
tools:
- read_file
- grep_search
---
Review code for bugs and style issues.

Auto-discovered, injected into system prompt.

Audit Completeness

Timestamps added to every audit log entry.

--trace

magic-code --trace 'fix the bug'

Shows tool inputs, outputs, and duration at trace level.

183 tests pass (+3 for agents).

Summary by CodeRabbit

Release Notes

  • New Features
    • Added --trace CLI flag to enable detailed debug logging of tool executions with timing and output metrics.
    • Introduced support for discovering and loading named agents from project directories, automatically integrating them into system operations.
    • Enhanced audit logging with timestamps for improved tracking and debugging visibility.

Named agents:
- agents/*.md files with model/description/tools in YAML frontmatter
- Auto-discovered from .magic-code/agents/ and agents/
- Injected into system prompt so LLM knows available agents
- 3 new tests

Audit completeness:
- Added timestamp to every audit log entry

Debug/trace:
- --trace flag enables structured tool call logging (input + output + duration)
- trace-level logs in tool registry execution

183 tests pass.
@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Apr 11, 2026

Caution

Review failed

Pull request was closed or merged during review

📝 Walkthrough

Walkthrough

The changes introduce agent discovery and loading functionality to the CLI with a new --trace flag for structured logging, enable agents to be discovered from project directories and integrated into system prompts, and enhance observability through trace-level logging of tool execution and audit log timestamps.

Changes

Cohort / File(s) Summary
CLI Agent Integration
mc/crates/mc-cli/src/main.rs
Added --trace boolean flag to CLI struct; updated logging setup to enable trace-level logging for tool registry when flag is set; integrated agent discovery and agents prompt section into system prompt construction.
Agent Module
mc/crates/mc-core/src/agents.rs
New module introducing AgentDef struct with name, optional model, description, instructions, and allowed_tools fields. Implements discover_agents() to scan .magic-code/agents/ and agents/ directories for markdown files with YAML frontmatter, parsing agent definitions. Implements agents_prompt_section() to format agents into a markdown section. Includes unit tests for frontmatter parsing and discovery behavior.
Core Module Exports
mc/crates/mc-core/src/lib.rs
Added public re-exports of AgentDef, discover_agents, and agents_prompt_section from new agents module.
Observability Enhancements
mc/crates/mc-tools/src/audit.rs, mc/crates/mc-tools/src/registry.rs
Added ts (timestamp) field to JSONL audit logs via chrono_now() helper formatting Unix time as HH:MM:SS. Added trace-level logging in ToolRegistry::execute to record tool input before validation and output after execution with elapsed time and output length.

Sequence Diagram

sequenceDiagram
    participant CLI as CLI
    participant Core as mc-core
    participant FS as File System
    participant Prompt as System Prompt
    
    CLI->>CLI: Parse --trace flag
    CLI->>CLI: Configure logging (trace/debug/warn)
    CLI->>Core: discover_agents(project.cwd)
    Core->>FS: Scan .magic-code/agents/ & agents/
    FS-->>Core: Return .md files
    Core->>Core: Parse frontmatter & extract AgentDef
    Core-->>CLI: Return Vec<AgentDef>
    alt Agents found
        CLI->>Core: agents_prompt_section(&agents)
        Core-->>CLI: Formatted agents markdown
        CLI->>Prompt: Append agents section
    else No agents
        CLI->>Core: agents_prompt_section(&agents)
        Core-->>CLI: Empty string
    end
    CLI->>Prompt: Build system prompt with agents
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Poem

🐰 ✨ Agents hop into the CLI with traces so bright,
Discovered from directories, configured just right,
Timestamps and logging now chronicle the way,
Tools speak their secrets in a verbose display! 🌙

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 60.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'feat: named agents, audit timestamps, --trace logging' accurately and specifically summarizes all three main changes in the PR: agent discovery/support, audit log timestamps, and the new trace logging flag.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/named-agents-audit-trace

Comment @coderabbitai help to get the list of available commands and usage tips.

@kienbui1995 kienbui1995 merged commit 0925a92 into main Apr 11, 2026
4 of 5 checks passed
@kienbui1995 kienbui1995 deleted the feat/named-agents-audit-trace branch April 11, 2026 20:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant