Skip to content

Commit 3652480

Browse files
Antigravity Agentclaude
andcommitted
feat(mu): Agent MU Core — error pattern detection, JSONL storage, pipeline hook (#72)
- New mu_agent.zig: MuAgent struct with detect(), log(), suggest(), stats(), save() - 8 error pattern rules (ast_fail, gen_fail, format_fail, type_mismatch, import_fail) - JSONL storage at .trinity/mu/patterns.jsonl - Pipeline integration: Link 11 (executeSweFix) auto-detects patterns on failure - CLI: `tri mu status`, `tri mu patterns`, `tri mu help` - 5 unit tests, all passing Closes #83 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent d64cb90 commit 3652480

4 files changed

Lines changed: 477 additions & 1 deletion

File tree

src/tri/main.zig

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ const tri_namespace = @import("tri_namespace.zig");
4545
const tri_mcp = @import("tri_mcp.zig");
4646
const tri_list = @import("tri_cmd_list.zig");
4747
const tri_swarm = @import("tri_swarm.zig");
48+
const mu_agent = @import("mu_agent.zig");
4849
// P2.10: Observability layer
4950
const observability = @import("observability.zig");
5051
const structured_log = @import("structured_log.zig");
@@ -449,6 +450,62 @@ pub fn main() !void {
449450
std.debug.print("Identity command - TODO: Implement\n", .{});
450451
},
451452
.swarm => try tri_swarm.runSwarmCommand(allocator, cmd_args),
453+
.mu => {
454+
var mu = mu_agent.MuAgent.init(allocator, ".trinity/mu/patterns.jsonl");
455+
defer mu.deinit();
456+
try mu.load();
457+
458+
const subcmd = if (cmd_args.len > 0) cmd_args[0] else "status";
459+
if (std.mem.eql(u8, subcmd, "status")) {
460+
const report = mu.stats();
461+
std.debug.print(
462+
\\🧠 MU STATUS REPORT
463+
\\═══════════════════════════════════════
464+
\\ Total patterns: {d}
465+
\\ Unresolved: {d}
466+
\\ Auto-fixable: {d}
467+
\\
468+
\\ By category:
469+
\\ ast_fail: {d}
470+
\\ gen_fail: {d}
471+
\\ format_fail: {d}
472+
\\ type_mismatch: {d}
473+
\\ import_fail: {d}
474+
\\ unknown: {d}
475+
\\
476+
, .{
477+
report.total_patterns, report.unresolved, report.auto_fixable,
478+
report.by_category[0], report.by_category[1], report.by_category[2],
479+
report.by_category[3], report.by_category[4], report.by_category[5],
480+
});
481+
for (mu.patterns.items) |p| {
482+
std.debug.print(" [{s}] {s} — count:{d} {s}\n", .{
483+
p.category.toString(), p.spec_file, p.count,
484+
if (p.auto_fixable) "auto" else "manual",
485+
});
486+
}
487+
} else if (std.mem.eql(u8, subcmd, "patterns")) {
488+
const report = mu.stats();
489+
std.debug.print("🧠 MU: {d} patterns ({d} unresolved, {d} auto-fixable)\n", .{
490+
report.total_patterns, report.unresolved, report.auto_fixable,
491+
});
492+
for (mu.patterns.items) |p| {
493+
std.debug.print(" [{s}] {s} — count:{d} {s}\n", .{
494+
p.category.toString(), p.spec_file, p.count,
495+
if (p.resolved) "RESOLVED" else "OPEN",
496+
});
497+
}
498+
} else {
499+
std.debug.print(
500+
\\🧠 MU — Memory Unit
501+
\\Usage: tri mu <command>
502+
\\ status Show patterns + stats
503+
\\ patterns List all known patterns
504+
\\ help Show this help
505+
\\
506+
, .{});
507+
}
508+
},
452509
.govern => {
453510
std.debug.print("Govern command - TODO: Implement\n", .{});
454511
},

0 commit comments

Comments
 (0)