Skip to content
This repository was archived by the owner on Jan 23, 2026. It is now read-only.
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions cmd/agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (
"syscall"

"github.com/agentuity/cli/internal/agent"
"github.com/agentuity/cli/internal/codeagent"
"github.com/agentuity/cli/internal/errsystem"
"github.com/agentuity/cli/internal/project"
"github.com/agentuity/cli/internal/templates"
Expand Down Expand Up @@ -333,6 +334,24 @@ var agentCreateCmd = &cobra.Command{
if err := theproject.Project.Save(theproject.Dir); err != nil {
errsystem.New(errsystem.ErrSaveProject, err, errsystem.WithContextMessage("Failed to save project to disk")).ShowErrorAndExit()
}

// --- New: ask what the agent should do & generate code ---------------------
goal, _ := cmd.Flags().GetString("goal")
codeOptIn, _ := cmd.Flags().GetBool("experimental-code-agent")
if goal == "" && tui.HasTTY {
goal = tui.Input(logger, "Describe what the "+name+" Agent should do", "Enter a brief description or objective for the Agent (multi-line supported; hit <enter> on an empty line to finish)")
}
if goal != "" && codeOptIn {
dir := filepath.Join(theproject.Dir, theproject.Project.Bundler.AgentConfig.Dir, util.SafeFilename(name))
genOpts := codeagent.Options{Dir: dir, Goal: goal, Logger: logger}
codegenAction := func() {
if err := codeagent.Generate(ctx, genOpts); err != nil {
tui.ShowWarning("Agent code generation failed: %s", err)
}
}
tui.ShowSpinner("Crafting Agent code ...", codegenAction)
}
// ---------------------------------------------------------------------------
}
tui.ShowSpinner("Creating Agent ...", action)

Expand Down Expand Up @@ -716,4 +735,6 @@ func init() {
for _, cmd := range []*cobra.Command{agentCreateCmd, agentDeleteCmd} {
cmd.Flags().Bool("force", false, "Force the creation of the agent even if it already exists")
}
agentCreateCmd.Flags().String("goal", "", "A description of what the agent should do (optional)")
agentCreateCmd.Flags().Bool("experimental-code-agent", false, "Enable experimental code agent")
}
112 changes: 112 additions & 0 deletions cmd/dev.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ package cmd
import (
"context"
"fmt"
"io"
"os"
"os/exec"
"os/signal"
"runtime"
"syscall"
Expand All @@ -20,6 +22,12 @@ import (
"github.com/bep/debounce"
"github.com/spf13/cobra"
"github.com/spf13/viper"

"github.com/agentuity/cli/internal/debugagent"
debugmon "github.com/agentuity/cli/internal/dev/debugmon"

"github.com/agentuity/cli/internal/dev/linkify"
Comment on lines +25 to +29
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"github.com/agentuity/cli/internal/debugagent"
debugmon "github.com/agentuity/cli/internal/dev/debugmon"
"github.com/agentuity/cli/internal/dev/linkify"
"github.com/agentuity/cli/internal/debugagent"
"github.com/agentuity/cli/internal/dev/debugmon"
"github.com/agentuity/cli/internal/dev/linkify"

"github.com/charmbracelet/glamour"
)

var devCmd = &cobra.Command{
Expand Down Expand Up @@ -87,6 +95,8 @@ Examples:
}
}

experimentalDebug, _ := cmd.Flags().GetBool("experimental-debug-agent")

websocketConn, err := dev.NewWebsocket(dev.WebsocketArgs{
Ctx: ctx,
Logger: log,
Expand All @@ -110,6 +120,107 @@ Examples:
errsystem.New(errsystem.ErrInvalidConfiguration, err, errsystem.WithContextMessage("Failed to run project")).ShowErrorAndExit()
}

var monitorOutChan chan debugmon.ErrorEvent
if experimentalDebug {
log.Info("Debug Agent enabled")
monitorOutChan = make(chan debugmon.ErrorEvent, 8)

r, w := io.Pipe()
// Capture only stderr for error monitoring; stdout goes directly to console.
projectServerCmd.Stdout = os.Stdout
projectServerCmd.Stderr = io.MultiWriter(os.Stderr, w)

mon := debugmon.New(log, monitorOutChan)
go mon.Run(r)

go func() {
for evt := range monitorOutChan {
fmt.Println(tui.Text("Analyzing error ..."))
res, derr := debugagent.Analyze(context.Background(), debugagent.Options{
Dir: dir,
Error: evt.Raw,
Logger: log,
})
analysis := linkify.LinkifyMarkdown(res.Analysis, dir)

fmt.Println()
fmt.Println(tui.Title("Debug Agent Suggestions"))
fmt.Println()

// Render markdown nicely using glamour
renderer, err := glamour.NewTermRenderer(
glamour.WithAutoStyle(),
glamour.WithWordWrap(120),
)
if err != nil {
// Fallback to plain output
fmt.Println(tui.Text(analysis))
} else {
rendered, err := renderer.Render(analysis)
if err != nil {
fmt.Println(tui.Text(analysis))
} else {
fmt.Print(rendered)
}
}

// Ask user if we should attempt an automatic fix
choice := tui.Select(log, "Attempt automatic fix?", "Choose an option", []tui.Option{
{ID: "y", Text: "Yes"},
{ID: "e", Text: "Provide extra guidance then fix"},
{ID: "n", Text: "No"},
})

if choice == "y" || choice == "e" {
// Compose an extra prompt containing the previous analysis and optional user guidance.
composeExtra := func(userInput string) string {
// Limit analysis length to keep prompt compact.
const maxAnalysis = 4000
prior := res.Analysis
if len(prior) > maxAnalysis {
prior = prior[:maxAnalysis] + "\n...[truncated]"
}
if userInput == "" {
return fmt.Sprintf("Here is the previous analysis you produced (for reference, not to repeat):\n\n%s", prior)
}
return fmt.Sprintf("Here is the previous analysis you produced (for reference, not to repeat):\n\n%s\n\nAdditional user guidance:\n\n%s", prior, userInput)
}

userGuidance := ""
if choice == "e" {
userGuidance = tui.Input(log, "Provide additional guidance", "Describe how to tweak the fix")
}

extraPrompt := composeExtra(userGuidance)

fmt.Println(tui.Text("Applying fix ..."))
res, derr = debugagent.Analyze(context.Background(), debugagent.Options{
Dir: dir,
Error: evt.Raw,
Extra: extraPrompt,
Logger: log,
AllowWrites: true,
})
if derr != nil {
log.Error("auto-fix failed: %v", derr)
} else if res.Edited {
// Suppress monitor for a short period to avoid picking up diff/build noise.
mon.SuppressFor(3 * time.Second)

fmt.Println()
fmt.Println(tui.Title("Applied Changes"))
cmd := exec.Command("git", "--no-pager", "-C", dir, "diff", "--color", "--", ".")
cmd.Stdout = os.Stdout
cmd.Env = append(os.Environ(), "GIT_PAGER=cat")
cmd.Run()
fmt.Println(tui.Text("(end of diff)"))
}
}
fmt.Println()
}
}()
}

build := func(initial bool) {
started := time.Now()
var ok bool
Expand Down Expand Up @@ -265,6 +376,7 @@ func init() {
devCmd.Flags().String("websocket-id", "", "The websocket room id to use for the development agent")
devCmd.Flags().String("org-id", "", "The organization to run the project")
devCmd.Flags().Int("port", 0, "The port to run the development server on (uses project default if not provided)")
devCmd.Flags().Bool("experimental-debug-agent", false, "Enable LLM-based runtime error assistance")
devCmd.Flags().MarkHidden("websocket-id")
devCmd.Flags().MarkHidden("org-id")
}
28 changes: 26 additions & 2 deletions cmd/project.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"sort"
"syscall"

"github.com/agentuity/cli/internal/codeagent"
"github.com/agentuity/cli/internal/errsystem"
"github.com/agentuity/cli/internal/mcp"
"github.com/agentuity/cli/internal/organization"
Expand Down Expand Up @@ -326,7 +327,7 @@ Examples:

orgId := promptForOrganization(ctx, logger, cmd, apiUrl, apikey)

var name, description, agentName, agentDescription, authType, githubAction string
var name, description, agentName, agentDescription, authType, githubAction, agentGoal string

if len(args) > 0 {
name = args[0]
Expand All @@ -340,6 +341,9 @@ Examples:
if len(args) > 3 {
agentDescription = args[3]
}
goalFlag, _ := cmd.Flags().GetString("goal")
agentGoal = goalFlag
Comment on lines +344 to +345
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not sure what foalFlag is supposed to do

Suggested change
goalFlag, _ := cmd.Flags().GetString("goal")
agentGoal = goalFlag
agentGoal, _ := cmd.Flags().GetString("goal")

experimentalCode, _ := cmd.Flags().GetBool("experimental-code-agent")

authType, _ = cmd.Flags().GetString("auth")
githubAction, _ = cmd.Flags().GetString("action")
Expand Down Expand Up @@ -446,6 +450,9 @@ Examples:
templateName = resp.Template
providerName = resp.Runtime
provider = resp.Provider
if agentGoal == "" {
agentGoal = tui.Input(logger, "Describe what the initial agent should do", "Enter a brief description of the agent's functionality")
}
}
}

Expand Down Expand Up @@ -551,9 +558,24 @@ Examples:

})

// run the git flow
projectGitFlow(ctx, provider, tmplContext, githubAction)

// run code generation for the initial agent if a goal is provided
if agentGoal != "" && experimentalCode {
// determine the agent source directory via template rules
dirRule, err := templates.LoadTemplateRuleForIdentifier(tmplDir, provider.Identifier)
if err == nil {
dir := filepath.Join(projectDir, dirRule.SrcDir, util.SafeFilename(agentName))
genOpts := codeagent.Options{Dir: dir, Goal: agentGoal, Logger: logger}
codegenAction := func() {
if err := codeagent.Generate(ctx, genOpts); err != nil {
logger.Warn("Agent code generation failed: %s", err)
}
}
tui.ShowSpinner("Crafting Agent code ...", codegenAction)
}
}

if format == "json" {
json.NewEncoder(os.Stdout).Encode(projectData)
} else {
Expand Down Expand Up @@ -813,4 +835,6 @@ func init() {
projectNewCmd.Flags().String("templates-dir", "", "The directory to load the templates. Defaults to loading them from the github.com/agentuity/templates repository")
projectNewCmd.Flags().String("auth", "bearer", "The authentication type for the agent (bearer or none)")
projectNewCmd.Flags().String("action", "github-app", "The action to take for the project (github-action, github-app, none)")
projectNewCmd.Flags().String("goal", "", "A description of what the initial agent should do (optional)")
projectNewCmd.Flags().Bool("experimental-code-agent", false, "Enable experimental code agent generation")
}
23 changes: 17 additions & 6 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,20 @@ require (
github.com/Masterminds/semver v1.5.0
github.com/agentuity/go-common v1.0.47
github.com/agentuity/mcp-golang/v2 v2.0.2
github.com/anthropics/anthropic-sdk-go v0.2.0-beta.3
github.com/bep/debounce v1.2.1
github.com/bmatcuk/doublestar/v4 v4.8.1
github.com/charmbracelet/bubbles v0.20.0
github.com/charmbracelet/bubbletea v1.3.4
github.com/charmbracelet/glamour v0.10.0
github.com/charmbracelet/huh v0.6.0
github.com/charmbracelet/huh/spinner v0.0.0-20250313000648-36d9de46d64e
github.com/charmbracelet/lipgloss v1.1.0
github.com/charmbracelet/lipgloss v1.1.1-0.20250404203927-76690c660834
github.com/evanw/esbuild v0.25.0
github.com/fsnotify/fsnotify v1.7.0
github.com/google/uuid v1.6.0
github.com/gorilla/websocket v1.5.3
github.com/invopop/jsonschema v0.13.0
github.com/marcozac/go-jsonc v0.1.1
github.com/mattn/go-isatty v0.0.20
github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c
Expand All @@ -33,20 +36,26 @@ require (
dario.cat/mergo v1.0.0 // indirect
github.com/Microsoft/go-winio v0.6.2 // indirect
github.com/ProtonMail/go-crypto v1.1.5 // indirect
github.com/alecthomas/chroma/v2 v2.14.0 // indirect
github.com/aymerick/douceur v0.2.0 // indirect
github.com/bahlo/generic-list-go v0.2.0 // indirect
github.com/buger/jsonparser v1.1.1 // indirect
github.com/charmbracelet/colorprofile v0.2.3-0.20250311203215-f60798e515dc // indirect
github.com/charmbracelet/x/cellbuf v0.0.13-0.20250311204145-2c3ea96c31dd // indirect
github.com/charmbracelet/x/cellbuf v0.0.13 // indirect
github.com/charmbracelet/x/exp/slice v0.0.0-20250327172914-2fdc97757edf // indirect
github.com/cloudflare/circl v1.6.0 // indirect
github.com/cyphar/filepath-securejoin v0.4.1 // indirect
github.com/dlclark/regexp2 v1.11.0 // indirect
github.com/emirpasic/gods v1.18.1 // indirect
github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376 // indirect
github.com/go-git/go-billy/v5 v5.6.2 // indirect
github.com/golang/groupcache v0.0.0-20241129210726-2c02b8208cf8 // indirect
github.com/invopop/jsonschema v0.13.0 // indirect
github.com/gorilla/css v1.0.1 // indirect
github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 // indirect
github.com/kevinburke/ssh_config v1.2.0 // indirect
github.com/mailru/easyjson v0.9.0 // indirect
github.com/microcosm-cc/bluemonday v1.0.27 // indirect
github.com/muesli/reflow v0.3.0 // indirect
github.com/pjbgf/sha1cd v0.3.2 // indirect
github.com/sergi/go-diff v1.3.2-0.20230802210424-5b0b94c5c0d3 // indirect
github.com/skeema/knownhosts v1.3.1 // indirect
Expand All @@ -57,8 +66,10 @@ require (
github.com/wk8/go-ordered-map/v2 v2.1.8 // indirect
github.com/xanzy/ssh-agent v0.3.3 // indirect
github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e // indirect
github.com/yuin/goldmark v1.7.8 // indirect
github.com/yuin/goldmark-emoji v1.0.5 // indirect
golang.org/x/crypto v0.36.0 // indirect
golang.org/x/term v0.30.0 // indirect
golang.org/x/term v0.31.0 // indirect
gopkg.in/warnings.v0 v0.1.2 // indirect
)

Expand Down Expand Up @@ -132,9 +143,9 @@ require (
go.uber.org/atomic v1.9.0 // indirect
go.uber.org/multierr v1.9.0 // indirect
golang.org/x/net v0.38.0 // indirect
golang.org/x/sync v0.12.0 // indirect
golang.org/x/sync v0.13.0 // indirect
golang.org/x/sys v0.32.0
golang.org/x/text v0.23.0 // indirect
golang.org/x/text v0.24.0 // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20250303144028-a0af3efb3deb // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20250303144028-a0af3efb3deb // indirect
google.golang.org/grpc v1.71.0 // indirect
Expand Down
Loading
Loading