agent/cmd/core-agent/commands.go
Snider bf10d16f49 feat(agent): batch — sprint MCP tools + cmd cleanup (#142 #225 #226 #227)
Codex 5.5 batch lane processed 26 open Mantis tickets. 13 stale-fixed,
4 implemented, 9 deferred.

Tickets implemented:
- #142 — agentic_sprint_start + agentic_sprint_complete MCP tools wired to /v1/sprints/{id}/{start,complete} platform endpoints with tests
- #225 — cmd/core-agent/commands.go: removed raw flag parsing; startupArgs() uses Core arg filtering + local log-level strip
- #226 — cmd/core-agent/main.go: syscall.Exit(1) → core.Exit(1)
- #227 — pkg/agentic/dispatch.go: runtime.GOOS → Core environment-backed OS detection

Tickets stale-fixed: #161, #162, #163, #166, #167, #168, #171, #172, #223, #224, #230, #231, #232, #233
Tickets deferred: #160, #164, #165, #173, #222, #228, #229, #234

Co-authored-by: Codex <noreply@openai.com>
Closes tasks.lthn.sh/view.php?id=142
Closes tasks.lthn.sh/view.php?id=225
Closes tasks.lthn.sh/view.php?id=226
Closes tasks.lthn.sh/view.php?id=227
2026-04-25 14:55:23 +01:00

109 lines
3.3 KiB
Go

// SPDX-License-Identifier: EUPL-1.2
package main
import (
"os"
"dappco.re/go/agent/pkg/agentic"
"dappco.re/go/core"
)
type applicationCommandSet struct {
coreApp *core.Core
}
// args := startupArgs()
// _ = c.Cli().Run("version")
func startupArgs() []string {
return applyLogLevel(core.FilterArgs(os.Args[1:]))
}
// args := applyLogLevel([]string{"version", "-q"})
// args := applyLogLevel([]string{"--debug", "mcp"})
func applyLogLevel(args []string) []string {
var cleaned []string
for _, arg := range args {
switch arg {
case "--quiet", "-q":
core.SetLevel(core.LevelError)
case "--debug", "-d":
core.SetLevel(core.LevelDebug)
default:
cleaned = append(cleaned, arg)
}
}
return cleaned
}
// c.Command("version", core.Command{Description: "Print version and build info", Action: commands.version})
// c.Command("check", core.Command{Description: "Verify workspace, deps, and config", Action: commands.check})
// c.Command("env", core.Command{Description: "Show all core.Env() keys and values", Action: commands.env})
func registerApplicationCommands(c *core.Core) {
commands := applicationCommandSet{coreApp: c}
c.Command("version", core.Command{
Description: "Print version and build info",
Action: commands.version,
})
c.Command("check", core.Command{
Description: "Verify workspace, deps, and config",
Action: commands.check,
})
c.Command("env", core.Command{
Description: "Show all core.Env() keys and values",
Action: commands.env,
})
}
func (commands applicationCommandSet) version(_ core.Options) core.Result {
core.Print(nil, "core-agent %s", commands.coreApp.App().Version)
core.Print(nil, " go: %s", core.Env("GO"))
core.Print(nil, " os: %s/%s", core.Env("OS"), core.Env("ARCH"))
core.Print(nil, " home: %s", agentic.HomeDir())
core.Print(nil, " hostname: %s", core.Env("HOSTNAME"))
core.Print(nil, " pid: %s", core.Env("PID"))
core.Print(nil, " channel: %s", updateChannel())
return core.Result{OK: true}
}
func (commands applicationCommandSet) check(_ core.Options) core.Result {
fs := commands.coreApp.Fs()
core.Print(nil, "core-agent %s health check", commands.coreApp.App().Version)
core.Print(nil, "")
core.Print(nil, " binary: core-agent")
agentsPath := core.JoinPath(agentic.CoreRoot(), "agents.yaml")
if fs.IsFile(agentsPath) {
core.Print(nil, " agents: %s (ok)", agentsPath)
} else {
core.Print(nil, " agents: %s (MISSING)", agentsPath)
}
workspaceRoot := agentic.WorkspaceRoot()
if fs.IsDir(workspaceRoot) {
statusFiles := agentic.WorkspaceStatusPaths()
core.Print(nil, " workspace: %s (%d workspaces)", workspaceRoot, len(statusFiles))
} else {
core.Print(nil, " workspace: %s (MISSING)", workspaceRoot)
}
core.Print(nil, " services: %d registered", len(commands.coreApp.Services()))
core.Print(nil, " actions: %d registered", len(commands.coreApp.Actions()))
core.Print(nil, " commands: %d registered", len(commands.coreApp.Commands()))
core.Print(nil, " env keys: %d loaded", len(core.EnvKeys()))
core.Print(nil, "")
core.Print(nil, "ok")
return core.Result{OK: true}
}
func (commands applicationCommandSet) env(_ core.Options) core.Result {
keys := core.EnvKeys()
for _, key := range keys {
core.Print(nil, " %-15s %s", key, core.Env(key))
}
return core.Result{OK: true}
}