From 49e13613d24caa3d5925538cf8da1a8f058f7998 Mon Sep 17 00:00:00 2001 From: Virgil Date: Wed, 1 Apr 2026 13:42:31 +0000 Subject: [PATCH] feat(agentic): add dispatch console command Co-Authored-By: Virgil --- pkg/agentic/commands.go | 13 +++++++++++-- pkg/agentic/commands_test.go | 10 ++++++++++ 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/pkg/agentic/commands.go b/pkg/agentic/commands.go index 341a577..29d956b 100644 --- a/pkg/agentic/commands.go +++ b/pkg/agentic/commands.go @@ -19,6 +19,7 @@ func (s *PrepSubsystem) registerCommands(ctx context.Context) { c := s.Core() c.Command("run/task", core.Command{Description: "Run a single task end-to-end", Action: s.cmdRunTask}) c.Command("run/orchestrator", core.Command{Description: "Run the queue orchestrator (standalone, no MCP)", Action: s.cmdOrchestrator}) + c.Command("dispatch", core.Command{Description: "Dispatch queued agents", Action: s.cmdDispatch}) c.Command("prep", core.Command{Description: "Prepare a workspace: clone repo, build prompt", Action: s.cmdPrep}) c.Command("prep-workspace", core.Command{Description: "Prepare a workspace: clone repo, build prompt", Action: s.cmdPrep}) c.Command("generate", core.Command{Description: "Generate content from a prompt using the platform content pipeline", Action: s.cmdGenerate}) @@ -101,13 +102,21 @@ func (s *PrepSubsystem) runTask(ctx context.Context, options core.Options) core. } func (s *PrepSubsystem) cmdOrchestrator(_ core.Options) core.Result { + return s.runDispatchLoop("orchestrator") +} + +func (s *PrepSubsystem) cmdDispatch(_ core.Options) core.Result { + return s.runDispatchLoop("dispatch") +} + +func (s *PrepSubsystem) runDispatchLoop(label string) core.Result { ctx := s.commandContext() - core.Print(nil, "core-agent orchestrator running (pid %s)", core.Env("PID")) + core.Print(nil, "core-agent %s running (pid %s)", label, core.Env("PID")) core.Print(nil, " workspace: %s", WorkspaceRoot()) core.Print(nil, " watching queue, draining on 30s tick + completion poke") <-ctx.Done() - core.Print(nil, "orchestrator shutting down") + core.Print(nil, "%s shutting down", label) return core.Result{OK: true} } diff --git a/pkg/agentic/commands_test.go b/pkg/agentic/commands_test.go index f2e83a1..2f737bb 100644 --- a/pkg/agentic/commands_test.go +++ b/pkg/agentic/commands_test.go @@ -1137,6 +1137,15 @@ func TestCommands_CmdOrchestrator_Good_CancelledCtx(t *testing.T) { assert.True(t, r.OK) } +func TestCommands_CmdDispatch_Good_CancelledCtx(t *testing.T) { + s, _ := testPrepWithCore(t, nil) + ctx, cancel := context.WithCancel(context.Background()) + cancel() + s.startupContext = ctx + r := s.cmdDispatch(core.NewOptions()) + assert.True(t, r.OK) +} + func TestCommands_ParseIntStr_Good(t *testing.T) { assert.Equal(t, 42, parseIntString("42")) assert.Equal(t, 123, parseIntString("issue-123")) @@ -1156,6 +1165,7 @@ func TestCommands_RegisterCommands_Good_AllRegistered(t *testing.T) { cmds := c.Commands() assert.Contains(t, cmds, "run/task") assert.Contains(t, cmds, "run/orchestrator") + assert.Contains(t, cmds, "dispatch") assert.Contains(t, cmds, "prep") assert.Contains(t, cmds, "complete") assert.Contains(t, cmds, "scan")