Fence local profile capabilities

This commit is contained in:
slhx agent
2026-06-21 05:15:01 +02:00
parent 73c65a9b6f
commit fb68747848
3 changed files with 118 additions and 0 deletions
+39
View File
@@ -8,6 +8,7 @@ const lsp = @import("lsp.zig");
const mobile_acceptance = @import("mobile_acceptance.zig");
const panel = @import("panel.zig");
const pi_bridge = @import("pi_bridge.zig");
const profile = @import("profile.zig");
const protocol = @import("protocol.zig");
const replay = @import("replay.zig");
const repo = @import("repo.zig");
@@ -26,6 +27,7 @@ const help_text =
\\ mim [--help]
\\ mim [--version]
\\ mim context [task] [intent]
\\ mim profile
\\ mim mimctl context <socket|-> [task] [intent]
\\ mim --mimctl <socket|-> <request...>
\\
@@ -71,6 +73,14 @@ pub fn main(init: std.process.Init) !u8 {
try printLocalContext(allocator, init.io, &args, stdout);
return 0;
}
if (std.mem.eql(u8, arg, "profile")) {
try printProfile(allocator, init.io, stdout);
return 0;
}
if (isProfileStub(arg)) {
try printProfileStub(init.io, stderr, arg);
return 69;
}
if (std.mem.eql(u8, arg, "mimctl")) {
const sub = args.next() orelse {
try stderr.writeStreamingAll(init.io, "mim: mimctl requires a subcommand\n");
@@ -134,6 +144,26 @@ fn printLocalContext(allocator: std.mem.Allocator, io: std.Io, args: *std.proces
try stdout.writeStreamingAll(io, text);
}
fn printProfile(allocator: std.mem.Allocator, io: std.Io, stdout: std.Io.File) !void {
const text = try profile.statusAlloc(allocator);
defer allocator.free(text);
try stdout.writeStreamingAll(io, text);
}
fn isProfileStub(arg: []const u8) bool {
return std.mem.eql(u8, arg, "remote") or
std.mem.eql(u8, arg, "plugin") or
std.mem.eql(u8, arg, "plugins") or
std.mem.eql(u8, arg, "background-agent") or
std.mem.eql(u8, arg, "bundled-pi");
}
fn printProfileStub(io: std.Io, stderr: std.Io.File, arg: []const u8) !void {
try stderr.writeStreamingAll(io, "mim: ");
try stderr.writeStreamingAll(io, arg);
try stderr.writeStreamingAll(io, " not built in this profile\n");
}
fn requestMimctl(
allocator: std.mem.Allocator,
io: std.Io,
@@ -193,6 +223,7 @@ test {
_ = mobile_acceptance;
_ = panel;
_ = pi_bridge;
_ = profile;
_ = protocol;
_ = replay;
_ = repo;
@@ -207,6 +238,14 @@ test "regular: help text names the binary and smoke boundary" {
try std.testing.expect(std.mem.indexOf(u8, help_text, "mim - mobile-first terminal code editor") != null);
try std.testing.expect(std.mem.indexOf(u8, help_text, "canonical smoke path") != null);
try std.testing.expect(std.mem.indexOf(u8, help_text, "mim context") != null);
try std.testing.expect(std.mem.indexOf(u8, help_text, "mim profile") != null);
}
test "regular: excluded profile capabilities have explicit stubs" {
try std.testing.expect(isProfileStub("remote"));
try std.testing.expect(isProfileStub("plugin"));
try std.testing.expect(isProfileStub("background-agent"));
try std.testing.expect(!isProfileStub("context"));
}
test "regular: version output is stable enough for smoke checks" {