2026-03-22 14:30:12 +00:00
|
|
|
// SPDX-License-Identifier: EUPL-1.2
|
|
|
|
|
|
2026-03-25 00:03:22 +00:00
|
|
|
package agentic
|
2026-03-22 14:30:12 +00:00
|
|
|
|
|
|
|
|
import (
|
2026-03-26 06:38:02 +00:00
|
|
|
"context"
|
|
|
|
|
|
2026-03-25 00:03:22 +00:00
|
|
|
core "dappco.re/go/core"
|
2026-03-22 14:30:12 +00:00
|
|
|
)
|
|
|
|
|
|
2026-03-25 00:03:22 +00:00
|
|
|
func (s *PrepSubsystem) registerWorkspaceCommands() {
|
feat(v0.8.0): full AX migration — ServiceRuntime, Actions, quality gates, transport
go-process:
- Register factory, Result lifecycle, 5 named Action handlers
- Start/Run/StartWithOptions/RunWithOptions all return core.Result
- core.ID() replaces fmt.Sprintf, core.As replaces errors.As
core/agent:
- PrepSubsystem + monitor.Subsystem + setup.Service embed ServiceRuntime[T]
- 22 named Actions + agent.completion Task pipeline in OnStartup
- ChannelNotifier removed — all IPC via c.ACTION(messages.X{})
- proc.go: all methods via s.Core().Process(), returns core.Result
- status.go: WriteAtomic + JSONMarshalString
- paths.go: Fs.NewUnrestricted() replaces unsafe.Pointer
- transport.go: ONE net/http file — HTTPGet/HTTPPost/HTTPDo/MCP transport
- All disallowed imports eliminated from source files (13 quality gates)
- String concat eliminated — core.Concat() throughout
- 1:1 _test.go + _example_test.go for every source file
- Reference docs synced from core/go v0.8.0
- RFC-025 updated with net/http, net/url, io/fs quality gates
- lib.go: io/fs eliminated via Data.ListNames, Array[T].Deduplicate
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-26 01:27:46 +00:00
|
|
|
c := s.Core()
|
refactor: extract command closures into named methods — agentic 61.4%
Move all command closure bodies from registerForgeCommands,
registerWorkspaceCommands into standalone methods (cmd*) on PrepSubsystem.
This makes them directly testable without CLI integration.
New: 9 forge command methods (cmdIssueGet, cmdIssueList, cmdIssueComment,
cmdIssueCreate, cmdPRGet, cmdPRList, cmdPRMerge, cmdRepoGet, cmdRepoList)
+ 3 workspace methods (cmdWorkspaceList, cmdWorkspaceClean, cmdWorkspaceDispatch)
Coverage: agentic 54.3% → 61.4% (+7.1pp)
Total: 501 agentic tests, 727 across all packages
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-25 00:52:00 +00:00
|
|
|
c.Command("workspace/list", core.Command{Description: "List all agent workspaces with status", Action: s.cmdWorkspaceList})
|
2026-04-02 00:38:10 +00:00
|
|
|
c.Command("agentic:workspace/list", core.Command{Description: "List all agent workspaces with status", Action: s.cmdWorkspaceList})
|
refactor: extract command closures into named methods — agentic 61.4%
Move all command closure bodies from registerForgeCommands,
registerWorkspaceCommands into standalone methods (cmd*) on PrepSubsystem.
This makes them directly testable without CLI integration.
New: 9 forge command methods (cmdIssueGet, cmdIssueList, cmdIssueComment,
cmdIssueCreate, cmdPRGet, cmdPRList, cmdPRMerge, cmdRepoGet, cmdRepoList)
+ 3 workspace methods (cmdWorkspaceList, cmdWorkspaceClean, cmdWorkspaceDispatch)
Coverage: agentic 54.3% → 61.4% (+7.1pp)
Total: 501 agentic tests, 727 across all packages
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-25 00:52:00 +00:00
|
|
|
c.Command("workspace/clean", core.Command{Description: "Remove completed/failed/blocked workspaces", Action: s.cmdWorkspaceClean})
|
2026-04-02 00:38:10 +00:00
|
|
|
c.Command("agentic:workspace/clean", core.Command{Description: "Remove completed/failed/blocked workspaces", Action: s.cmdWorkspaceClean})
|
refactor: extract command closures into named methods — agentic 61.4%
Move all command closure bodies from registerForgeCommands,
registerWorkspaceCommands into standalone methods (cmd*) on PrepSubsystem.
This makes them directly testable without CLI integration.
New: 9 forge command methods (cmdIssueGet, cmdIssueList, cmdIssueComment,
cmdIssueCreate, cmdPRGet, cmdPRList, cmdPRMerge, cmdRepoGet, cmdRepoList)
+ 3 workspace methods (cmdWorkspaceList, cmdWorkspaceClean, cmdWorkspaceDispatch)
Coverage: agentic 54.3% → 61.4% (+7.1pp)
Total: 501 agentic tests, 727 across all packages
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-25 00:52:00 +00:00
|
|
|
c.Command("workspace/dispatch", core.Command{Description: "Dispatch an agent to work on a repo task", Action: s.cmdWorkspaceDispatch})
|
2026-04-02 00:38:10 +00:00
|
|
|
c.Command("agentic:workspace/dispatch", core.Command{Description: "Dispatch an agent to work on a repo task", Action: s.cmdWorkspaceDispatch})
|
2026-04-01 20:43:42 +00:00
|
|
|
c.Command("workspace/watch", core.Command{Description: "Watch workspaces until they complete", Action: s.cmdWorkspaceWatch})
|
2026-04-02 00:38:10 +00:00
|
|
|
c.Command("agentic:workspace/watch", core.Command{Description: "Watch workspaces until they complete", Action: s.cmdWorkspaceWatch})
|
2026-04-01 20:43:42 +00:00
|
|
|
c.Command("watch", core.Command{Description: "Watch workspaces until they complete", Action: s.cmdWorkspaceWatch})
|
|
|
|
|
c.Command("agentic:watch", core.Command{Description: "Watch workspaces until they complete", Action: s.cmdWorkspaceWatch})
|
refactor: extract command closures into named methods — agentic 61.4%
Move all command closure bodies from registerForgeCommands,
registerWorkspaceCommands into standalone methods (cmd*) on PrepSubsystem.
This makes them directly testable without CLI integration.
New: 9 forge command methods (cmdIssueGet, cmdIssueList, cmdIssueComment,
cmdIssueCreate, cmdPRGet, cmdPRList, cmdPRMerge, cmdRepoGet, cmdRepoList)
+ 3 workspace methods (cmdWorkspaceList, cmdWorkspaceClean, cmdWorkspaceDispatch)
Coverage: agentic 54.3% → 61.4% (+7.1pp)
Total: 501 agentic tests, 727 across all packages
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-25 00:52:00 +00:00
|
|
|
}
|
2026-03-22 14:30:12 +00:00
|
|
|
|
2026-03-30 16:14:08 +00:00
|
|
|
func (s *PrepSubsystem) cmdWorkspaceList(_ core.Options) core.Result {
|
2026-03-29 20:15:58 +00:00
|
|
|
statusFiles := WorkspaceStatusPaths()
|
refactor: extract command closures into named methods — agentic 61.4%
Move all command closure bodies from registerForgeCommands,
registerWorkspaceCommands into standalone methods (cmd*) on PrepSubsystem.
This makes them directly testable without CLI integration.
New: 9 forge command methods (cmdIssueGet, cmdIssueList, cmdIssueComment,
cmdIssueCreate, cmdPRGet, cmdPRList, cmdPRMerge, cmdRepoGet, cmdRepoList)
+ 3 workspace methods (cmdWorkspaceList, cmdWorkspaceClean, cmdWorkspaceDispatch)
Coverage: agentic 54.3% → 61.4% (+7.1pp)
Total: 501 agentic tests, 727 across all packages
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-25 00:52:00 +00:00
|
|
|
count := 0
|
feat(v0.8.0): full AX migration — ServiceRuntime, Actions, quality gates, transport
go-process:
- Register factory, Result lifecycle, 5 named Action handlers
- Start/Run/StartWithOptions/RunWithOptions all return core.Result
- core.ID() replaces fmt.Sprintf, core.As replaces errors.As
core/agent:
- PrepSubsystem + monitor.Subsystem + setup.Service embed ServiceRuntime[T]
- 22 named Actions + agent.completion Task pipeline in OnStartup
- ChannelNotifier removed — all IPC via c.ACTION(messages.X{})
- proc.go: all methods via s.Core().Process(), returns core.Result
- status.go: WriteAtomic + JSONMarshalString
- paths.go: Fs.NewUnrestricted() replaces unsafe.Pointer
- transport.go: ONE net/http file — HTTPGet/HTTPPost/HTTPDo/MCP transport
- All disallowed imports eliminated from source files (13 quality gates)
- String concat eliminated — core.Concat() throughout
- 1:1 _test.go + _example_test.go for every source file
- Reference docs synced from core/go v0.8.0
- RFC-025 updated with net/http, net/url, io/fs quality gates
- lib.go: io/fs eliminated via Data.ListNames, Array[T].Deduplicate
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-26 01:27:46 +00:00
|
|
|
for _, sf := range statusFiles {
|
2026-03-30 21:22:54 +00:00
|
|
|
workspaceDir := core.PathDir(sf)
|
2026-03-30 21:30:49 +00:00
|
|
|
workspaceName := WorkspaceName(workspaceDir)
|
2026-03-30 21:22:54 +00:00
|
|
|
result := ReadStatusResult(workspaceDir)
|
2026-03-30 21:11:06 +00:00
|
|
|
workspaceStatus, ok := workspaceStatusValue(result)
|
2026-03-30 19:40:02 +00:00
|
|
|
if !ok {
|
2026-03-30 16:14:08 +00:00
|
|
|
continue
|
refactor: extract command closures into named methods — agentic 61.4%
Move all command closure bodies from registerForgeCommands,
registerWorkspaceCommands into standalone methods (cmd*) on PrepSubsystem.
This makes them directly testable without CLI integration.
New: 9 forge command methods (cmdIssueGet, cmdIssueList, cmdIssueComment,
cmdIssueCreate, cmdPRGet, cmdPRList, cmdPRMerge, cmdRepoGet, cmdRepoList)
+ 3 workspace methods (cmdWorkspaceList, cmdWorkspaceClean, cmdWorkspaceDispatch)
Coverage: agentic 54.3% → 61.4% (+7.1pp)
Total: 501 agentic tests, 727 across all packages
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-25 00:52:00 +00:00
|
|
|
}
|
2026-03-30 21:30:49 +00:00
|
|
|
core.Print(nil, " %-8s %-8s %-10s %s", workspaceStatus.Status, workspaceStatus.Agent, workspaceStatus.Repo, workspaceName)
|
2026-03-30 16:14:08 +00:00
|
|
|
count++
|
refactor: extract command closures into named methods — agentic 61.4%
Move all command closure bodies from registerForgeCommands,
registerWorkspaceCommands into standalone methods (cmd*) on PrepSubsystem.
This makes them directly testable without CLI integration.
New: 9 forge command methods (cmdIssueGet, cmdIssueList, cmdIssueComment,
cmdIssueCreate, cmdPRGet, cmdPRList, cmdPRMerge, cmdRepoGet, cmdRepoList)
+ 3 workspace methods (cmdWorkspaceList, cmdWorkspaceClean, cmdWorkspaceDispatch)
Coverage: agentic 54.3% → 61.4% (+7.1pp)
Total: 501 agentic tests, 727 across all packages
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-25 00:52:00 +00:00
|
|
|
}
|
|
|
|
|
if count == 0 {
|
|
|
|
|
core.Print(nil, " no workspaces")
|
|
|
|
|
}
|
|
|
|
|
return core.Result{OK: true}
|
|
|
|
|
}
|
|
|
|
|
|
2026-03-30 21:11:06 +00:00
|
|
|
func (s *PrepSubsystem) cmdWorkspaceClean(options core.Options) core.Result {
|
2026-03-30 21:22:54 +00:00
|
|
|
workspaceRoot := WorkspaceRoot()
|
2026-03-30 21:37:15 +00:00
|
|
|
filesystem := s.Core().Fs()
|
2026-03-30 21:11:06 +00:00
|
|
|
filter := options.String("_arg")
|
refactor: extract command closures into named methods — agentic 61.4%
Move all command closure bodies from registerForgeCommands,
registerWorkspaceCommands into standalone methods (cmd*) on PrepSubsystem.
This makes them directly testable without CLI integration.
New: 9 forge command methods (cmdIssueGet, cmdIssueList, cmdIssueComment,
cmdIssueCreate, cmdPRGet, cmdPRList, cmdPRMerge, cmdRepoGet, cmdRepoList)
+ 3 workspace methods (cmdWorkspaceList, cmdWorkspaceClean, cmdWorkspaceDispatch)
Coverage: agentic 54.3% → 61.4% (+7.1pp)
Total: 501 agentic tests, 727 across all packages
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-25 00:52:00 +00:00
|
|
|
if filter == "" {
|
|
|
|
|
filter = "all"
|
|
|
|
|
}
|
2026-04-01 23:13:51 +00:00
|
|
|
if !workspaceCleanFilterValid(filter) {
|
|
|
|
|
core.Print(nil, "usage: core-agent workspace clean [all|completed|failed|blocked]")
|
|
|
|
|
return core.Result{Value: core.E("agentic.cmdWorkspaceClean", core.Concat("unknown filter: ", filter), nil), OK: false}
|
|
|
|
|
}
|
refactor: extract command closures into named methods — agentic 61.4%
Move all command closure bodies from registerForgeCommands,
registerWorkspaceCommands into standalone methods (cmd*) on PrepSubsystem.
This makes them directly testable without CLI integration.
New: 9 forge command methods (cmdIssueGet, cmdIssueList, cmdIssueComment,
cmdIssueCreate, cmdPRGet, cmdPRList, cmdPRMerge, cmdRepoGet, cmdRepoList)
+ 3 workspace methods (cmdWorkspaceList, cmdWorkspaceClean, cmdWorkspaceDispatch)
Coverage: agentic 54.3% → 61.4% (+7.1pp)
Total: 501 agentic tests, 727 across all packages
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-25 00:52:00 +00:00
|
|
|
|
2026-03-29 20:15:58 +00:00
|
|
|
statusFiles := WorkspaceStatusPaths()
|
refactor: extract command closures into named methods — agentic 61.4%
Move all command closure bodies from registerForgeCommands,
registerWorkspaceCommands into standalone methods (cmd*) on PrepSubsystem.
This makes them directly testable without CLI integration.
New: 9 forge command methods (cmdIssueGet, cmdIssueList, cmdIssueComment,
cmdIssueCreate, cmdPRGet, cmdPRList, cmdPRMerge, cmdRepoGet, cmdRepoList)
+ 3 workspace methods (cmdWorkspaceList, cmdWorkspaceClean, cmdWorkspaceDispatch)
Coverage: agentic 54.3% → 61.4% (+7.1pp)
Total: 501 agentic tests, 727 across all packages
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-25 00:52:00 +00:00
|
|
|
var toRemove []string
|
2026-03-22 14:30:12 +00:00
|
|
|
|
feat(v0.8.0): full AX migration — ServiceRuntime, Actions, quality gates, transport
go-process:
- Register factory, Result lifecycle, 5 named Action handlers
- Start/Run/StartWithOptions/RunWithOptions all return core.Result
- core.ID() replaces fmt.Sprintf, core.As replaces errors.As
core/agent:
- PrepSubsystem + monitor.Subsystem + setup.Service embed ServiceRuntime[T]
- 22 named Actions + agent.completion Task pipeline in OnStartup
- ChannelNotifier removed — all IPC via c.ACTION(messages.X{})
- proc.go: all methods via s.Core().Process(), returns core.Result
- status.go: WriteAtomic + JSONMarshalString
- paths.go: Fs.NewUnrestricted() replaces unsafe.Pointer
- transport.go: ONE net/http file — HTTPGet/HTTPPost/HTTPDo/MCP transport
- All disallowed imports eliminated from source files (13 quality gates)
- String concat eliminated — core.Concat() throughout
- 1:1 _test.go + _example_test.go for every source file
- Reference docs synced from core/go v0.8.0
- RFC-025 updated with net/http, net/url, io/fs quality gates
- lib.go: io/fs eliminated via Data.ListNames, Array[T].Deduplicate
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-26 01:27:46 +00:00
|
|
|
for _, sf := range statusFiles {
|
2026-03-30 21:22:54 +00:00
|
|
|
workspaceDir := core.PathDir(sf)
|
2026-03-30 21:30:49 +00:00
|
|
|
workspaceName := WorkspaceName(workspaceDir)
|
2026-03-30 21:22:54 +00:00
|
|
|
result := ReadStatusResult(workspaceDir)
|
2026-03-30 21:11:06 +00:00
|
|
|
workspaceStatus, ok := workspaceStatusValue(result)
|
2026-03-30 19:40:02 +00:00
|
|
|
if !ok {
|
refactor: extract command closures into named methods — agentic 61.4%
Move all command closure bodies from registerForgeCommands,
registerWorkspaceCommands into standalone methods (cmd*) on PrepSubsystem.
This makes them directly testable without CLI integration.
New: 9 forge command methods (cmdIssueGet, cmdIssueList, cmdIssueComment,
cmdIssueCreate, cmdPRGet, cmdPRList, cmdPRMerge, cmdRepoGet, cmdRepoList)
+ 3 workspace methods (cmdWorkspaceList, cmdWorkspaceClean, cmdWorkspaceDispatch)
Coverage: agentic 54.3% → 61.4% (+7.1pp)
Total: 501 agentic tests, 727 across all packages
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-25 00:52:00 +00:00
|
|
|
continue
|
|
|
|
|
}
|
2026-03-30 21:11:06 +00:00
|
|
|
status := workspaceStatus.Status
|
refactor: extract command closures into named methods — agentic 61.4%
Move all command closure bodies from registerForgeCommands,
registerWorkspaceCommands into standalone methods (cmd*) on PrepSubsystem.
This makes them directly testable without CLI integration.
New: 9 forge command methods (cmdIssueGet, cmdIssueList, cmdIssueComment,
cmdIssueCreate, cmdPRGet, cmdPRList, cmdPRMerge, cmdRepoGet, cmdRepoList)
+ 3 workspace methods (cmdWorkspaceList, cmdWorkspaceClean, cmdWorkspaceDispatch)
Coverage: agentic 54.3% → 61.4% (+7.1pp)
Total: 501 agentic tests, 727 across all packages
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-25 00:52:00 +00:00
|
|
|
|
|
|
|
|
switch filter {
|
|
|
|
|
case "all":
|
|
|
|
|
if status == "completed" || status == "failed" || status == "blocked" || status == "merged" || status == "ready-for-review" {
|
2026-03-30 21:30:49 +00:00
|
|
|
toRemove = append(toRemove, workspaceName)
|
2026-03-22 14:30:12 +00:00
|
|
|
}
|
refactor: extract command closures into named methods — agentic 61.4%
Move all command closure bodies from registerForgeCommands,
registerWorkspaceCommands into standalone methods (cmd*) on PrepSubsystem.
This makes them directly testable without CLI integration.
New: 9 forge command methods (cmdIssueGet, cmdIssueList, cmdIssueComment,
cmdIssueCreate, cmdPRGet, cmdPRList, cmdPRMerge, cmdRepoGet, cmdRepoList)
+ 3 workspace methods (cmdWorkspaceList, cmdWorkspaceClean, cmdWorkspaceDispatch)
Coverage: agentic 54.3% → 61.4% (+7.1pp)
Total: 501 agentic tests, 727 across all packages
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-25 00:52:00 +00:00
|
|
|
case "completed":
|
|
|
|
|
if status == "completed" || status == "merged" || status == "ready-for-review" {
|
2026-03-30 21:30:49 +00:00
|
|
|
toRemove = append(toRemove, workspaceName)
|
2026-03-22 14:30:12 +00:00
|
|
|
}
|
refactor: extract command closures into named methods — agentic 61.4%
Move all command closure bodies from registerForgeCommands,
registerWorkspaceCommands into standalone methods (cmd*) on PrepSubsystem.
This makes them directly testable without CLI integration.
New: 9 forge command methods (cmdIssueGet, cmdIssueList, cmdIssueComment,
cmdIssueCreate, cmdPRGet, cmdPRList, cmdPRMerge, cmdRepoGet, cmdRepoList)
+ 3 workspace methods (cmdWorkspaceList, cmdWorkspaceClean, cmdWorkspaceDispatch)
Coverage: agentic 54.3% → 61.4% (+7.1pp)
Total: 501 agentic tests, 727 across all packages
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-25 00:52:00 +00:00
|
|
|
case "failed":
|
|
|
|
|
if status == "failed" {
|
2026-03-30 21:30:49 +00:00
|
|
|
toRemove = append(toRemove, workspaceName)
|
2026-03-22 14:30:12 +00:00
|
|
|
}
|
refactor: extract command closures into named methods — agentic 61.4%
Move all command closure bodies from registerForgeCommands,
registerWorkspaceCommands into standalone methods (cmd*) on PrepSubsystem.
This makes them directly testable without CLI integration.
New: 9 forge command methods (cmdIssueGet, cmdIssueList, cmdIssueComment,
cmdIssueCreate, cmdPRGet, cmdPRList, cmdPRMerge, cmdRepoGet, cmdRepoList)
+ 3 workspace methods (cmdWorkspaceList, cmdWorkspaceClean, cmdWorkspaceDispatch)
Coverage: agentic 54.3% → 61.4% (+7.1pp)
Total: 501 agentic tests, 727 across all packages
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-25 00:52:00 +00:00
|
|
|
case "blocked":
|
|
|
|
|
if status == "blocked" {
|
2026-03-30 21:30:49 +00:00
|
|
|
toRemove = append(toRemove, workspaceName)
|
2026-03-22 14:30:12 +00:00
|
|
|
}
|
refactor: extract command closures into named methods — agentic 61.4%
Move all command closure bodies from registerForgeCommands,
registerWorkspaceCommands into standalone methods (cmd*) on PrepSubsystem.
This makes them directly testable without CLI integration.
New: 9 forge command methods (cmdIssueGet, cmdIssueList, cmdIssueComment,
cmdIssueCreate, cmdPRGet, cmdPRList, cmdPRMerge, cmdRepoGet, cmdRepoList)
+ 3 workspace methods (cmdWorkspaceList, cmdWorkspaceClean, cmdWorkspaceDispatch)
Coverage: agentic 54.3% → 61.4% (+7.1pp)
Total: 501 agentic tests, 727 across all packages
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-25 00:52:00 +00:00
|
|
|
}
|
|
|
|
|
}
|
2026-03-22 14:30:12 +00:00
|
|
|
|
refactor: extract command closures into named methods — agentic 61.4%
Move all command closure bodies from registerForgeCommands,
registerWorkspaceCommands into standalone methods (cmd*) on PrepSubsystem.
This makes them directly testable without CLI integration.
New: 9 forge command methods (cmdIssueGet, cmdIssueList, cmdIssueComment,
cmdIssueCreate, cmdPRGet, cmdPRList, cmdPRMerge, cmdRepoGet, cmdRepoList)
+ 3 workspace methods (cmdWorkspaceList, cmdWorkspaceClean, cmdWorkspaceDispatch)
Coverage: agentic 54.3% → 61.4% (+7.1pp)
Total: 501 agentic tests, 727 across all packages
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-25 00:52:00 +00:00
|
|
|
if len(toRemove) == 0 {
|
|
|
|
|
core.Print(nil, "nothing to clean")
|
|
|
|
|
return core.Result{OK: true}
|
|
|
|
|
}
|
2026-03-22 14:30:12 +00:00
|
|
|
|
refactor: extract command closures into named methods — agentic 61.4%
Move all command closure bodies from registerForgeCommands,
registerWorkspaceCommands into standalone methods (cmd*) on PrepSubsystem.
This makes them directly testable without CLI integration.
New: 9 forge command methods (cmdIssueGet, cmdIssueList, cmdIssueComment,
cmdIssueCreate, cmdPRGet, cmdPRList, cmdPRMerge, cmdRepoGet, cmdRepoList)
+ 3 workspace methods (cmdWorkspaceList, cmdWorkspaceClean, cmdWorkspaceDispatch)
Coverage: agentic 54.3% → 61.4% (+7.1pp)
Total: 501 agentic tests, 727 across all packages
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-25 00:52:00 +00:00
|
|
|
for _, name := range toRemove {
|
2026-03-30 21:22:54 +00:00
|
|
|
path := core.JoinPath(workspaceRoot, name)
|
2026-03-30 21:37:15 +00:00
|
|
|
filesystem.DeleteAll(path)
|
refactor: extract command closures into named methods — agentic 61.4%
Move all command closure bodies from registerForgeCommands,
registerWorkspaceCommands into standalone methods (cmd*) on PrepSubsystem.
This makes them directly testable without CLI integration.
New: 9 forge command methods (cmdIssueGet, cmdIssueList, cmdIssueComment,
cmdIssueCreate, cmdPRGet, cmdPRList, cmdPRMerge, cmdRepoGet, cmdRepoList)
+ 3 workspace methods (cmdWorkspaceList, cmdWorkspaceClean, cmdWorkspaceDispatch)
Coverage: agentic 54.3% → 61.4% (+7.1pp)
Total: 501 agentic tests, 727 across all packages
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-25 00:52:00 +00:00
|
|
|
core.Print(nil, " removed %s", name)
|
|
|
|
|
}
|
|
|
|
|
core.Print(nil, "\n %d workspaces removed", len(toRemove))
|
|
|
|
|
return core.Result{OK: true}
|
|
|
|
|
}
|
2026-03-22 14:30:12 +00:00
|
|
|
|
2026-04-01 23:13:51 +00:00
|
|
|
func workspaceCleanFilterValid(filter string) bool {
|
|
|
|
|
switch filter {
|
|
|
|
|
case "all", "completed", "failed", "blocked":
|
|
|
|
|
return true
|
|
|
|
|
default:
|
|
|
|
|
return false
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2026-03-31 04:33:36 +00:00
|
|
|
// input := DispatchInput{Repo: "go-io", Task: "Fix the failing tests", Issue: 12}
|
2026-03-30 21:11:06 +00:00
|
|
|
func (s *PrepSubsystem) cmdWorkspaceDispatch(options core.Options) core.Result {
|
2026-04-01 12:39:18 +00:00
|
|
|
input := workspaceDispatchInputFromOptions(options)
|
|
|
|
|
if input.Repo == "" {
|
|
|
|
|
core.Print(nil, "usage: core-agent workspace dispatch <repo> --task=\"...\" --issue=N|--pr=N|--branch=X [--agent=codex] [--template=coding] [--plan-template=bug-fix] [--persona=code/reviewer] [--tag=v0.8.0] [--dry-run]")
|
2026-03-30 19:07:45 +00:00
|
|
|
return core.Result{Value: core.E("agentic.cmdWorkspaceDispatch", "repo is required", nil), OK: false}
|
refactor: extract command closures into named methods — agentic 61.4%
Move all command closure bodies from registerForgeCommands,
registerWorkspaceCommands into standalone methods (cmd*) on PrepSubsystem.
This makes them directly testable without CLI integration.
New: 9 forge command methods (cmdIssueGet, cmdIssueList, cmdIssueComment,
cmdIssueCreate, cmdPRGet, cmdPRList, cmdPRMerge, cmdRepoGet, cmdRepoList)
+ 3 workspace methods (cmdWorkspaceList, cmdWorkspaceClean, cmdWorkspaceDispatch)
Coverage: agentic 54.3% → 61.4% (+7.1pp)
Total: 501 agentic tests, 727 across all packages
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-25 00:52:00 +00:00
|
|
|
}
|
2026-03-26 06:38:02 +00:00
|
|
|
|
|
|
|
|
_, out, err := s.dispatch(context.Background(), nil, input)
|
|
|
|
|
if err != nil {
|
|
|
|
|
core.Print(nil, "dispatch failed: %s", err.Error())
|
|
|
|
|
return core.Result{Value: err, OK: false}
|
|
|
|
|
}
|
|
|
|
|
agent := out.Agent
|
|
|
|
|
if agent == "" {
|
|
|
|
|
agent = "codex"
|
|
|
|
|
}
|
2026-04-01 12:39:18 +00:00
|
|
|
core.Print(nil, "dispatched %s to %s", agent, input.Repo)
|
2026-03-26 06:38:02 +00:00
|
|
|
if out.WorkspaceDir != "" {
|
|
|
|
|
core.Print(nil, " workspace: %s", out.WorkspaceDir)
|
|
|
|
|
}
|
|
|
|
|
if out.PID > 0 {
|
|
|
|
|
core.Print(nil, " pid: %d", out.PID)
|
|
|
|
|
}
|
refactor: extract command closures into named methods — agentic 61.4%
Move all command closure bodies from registerForgeCommands,
registerWorkspaceCommands into standalone methods (cmd*) on PrepSubsystem.
This makes them directly testable without CLI integration.
New: 9 forge command methods (cmdIssueGet, cmdIssueList, cmdIssueComment,
cmdIssueCreate, cmdPRGet, cmdPRList, cmdPRMerge, cmdRepoGet, cmdRepoList)
+ 3 workspace methods (cmdWorkspaceList, cmdWorkspaceClean, cmdWorkspaceDispatch)
Coverage: agentic 54.3% → 61.4% (+7.1pp)
Total: 501 agentic tests, 727 across all packages
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-25 00:52:00 +00:00
|
|
|
return core.Result{OK: true}
|
2026-03-22 14:30:12 +00:00
|
|
|
}
|
2026-04-01 12:39:18 +00:00
|
|
|
|
2026-04-01 20:43:42 +00:00
|
|
|
func (s *PrepSubsystem) cmdWorkspaceWatch(options core.Options) core.Result {
|
|
|
|
|
watchOptions := core.NewOptions(options.Items()...)
|
|
|
|
|
if watchOptions.String("workspace") == "" && len(optionStringSliceValue(watchOptions, "workspaces")) == 0 {
|
|
|
|
|
if workspace := optionStringValue(options, "_arg"); workspace != "" {
|
|
|
|
|
watchOptions.Set("workspace", workspace)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
input := watchInputFromOptions(watchOptions)
|
|
|
|
|
|
|
|
|
|
_, output, err := s.watch(s.commandContext(), nil, input)
|
|
|
|
|
if err != nil {
|
|
|
|
|
core.Print(nil, "error: %v", err)
|
|
|
|
|
return core.Result{Value: err, OK: false}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
core.Print(nil, "completed: %d", len(output.Completed))
|
|
|
|
|
core.Print(nil, "failed: %d", len(output.Failed))
|
|
|
|
|
core.Print(nil, "duration: %s", output.Duration)
|
|
|
|
|
return core.Result{Value: output, OK: output.Success}
|
|
|
|
|
}
|
|
|
|
|
|
2026-04-01 12:39:18 +00:00
|
|
|
func workspaceDispatchInputFromOptions(options core.Options) DispatchInput {
|
|
|
|
|
dispatchOptions := core.NewOptions(options.Items()...)
|
|
|
|
|
if dispatchOptions.String("repo") == "" {
|
|
|
|
|
if repo := optionStringValue(options, "_arg", "repo"); repo != "" {
|
|
|
|
|
dispatchOptions.Set("repo", repo)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return dispatchInputFromOptions(dispatchOptions)
|
|
|
|
|
}
|