Skip to content
Merged
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
19 changes: 14 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
.PHONY: build lint generate test test_install test_install_linux test_install_alpine test_install_debian
.PHONY: build fmt lint test generate test_install test_install_linux test_install_alpine test_install_debian

build: lint generate
@go build -o agentuity

lint:
fmt:
@go fmt ./...
@go vet ./...
@go mod tidy

lint:
@make fmt

generate:
@echo "Running go generate..."
@go generate ./...
Expand All @@ -25,6 +28,12 @@ test_install_debian:
@docker run -it --rm agentuity-test-install-debian

test:
@go test -race ./...

test_install: test_install_linux test_install_alpine test_install_debian
@make fmt
@make lint
@make generate
@go test -v -count=1 -race ./...
@make test_install_linux
@make test_install_alpine
@make test_install_debian

test_install: test_install_linux test_install_alpine test_install_debian
21 changes: 13 additions & 8 deletions cmd/agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (
"github.com/agentuity/cli/internal/util"
"github.com/agentuity/go-common/env"
"github.com/agentuity/go-common/logger"
cproject "github.com/agentuity/go-common/project"
"github.com/agentuity/go-common/slice"
"github.com/agentuity/go-common/tui"
"github.com/charmbracelet/lipgloss/tree"
Expand All @@ -48,7 +49,8 @@ var agentDeleteCmd = &cobra.Command{
ctx, cancel := signal.NotifyContext(context.Background(), os.Interrupt, syscall.SIGINT, syscall.SIGTERM)
defer cancel()
theproject := project.EnsureProject(ctx, cmd)
apiUrl, _, _ := util.GetURLs(logger)
urls := util.GetURLs(logger)
apiUrl := urls.API

if !tui.HasTTY && len(args) == 0 {
logger.Fatal("No TTY detected, please specify an Agent id from the command line")
Expand Down Expand Up @@ -99,7 +101,7 @@ var agentDeleteCmd = &cobra.Command{
maybedelete = append(maybedelete, agent.Filename)
}
}
var agents []project.AgentConfig
var agents []cproject.AgentConfig
for _, agent := range theproject.Project.Agents {
if !slice.Contains(deleted, agent.ID) {
agents = append(agents, agent)
Expand Down Expand Up @@ -231,7 +233,8 @@ var agentCreateCmd = &cobra.Command{
logger := env.NewLogger(cmd)
theproject := project.EnsureProject(ctx, cmd)
apikey := theproject.Token
apiUrl, _, _ := util.GetURLs(logger)
urls := util.GetURLs(logger)
apiUrl := urls.API

var remoteAgents []agent.Agent

Expand Down Expand Up @@ -328,7 +331,7 @@ var agentCreateCmd = &cobra.Command{
errsystem.New(errsystem.ErrApiRequest, err, errsystem.WithAttributes(map[string]any{"name": name})).ShowErrorAndExit()
}

theproject.Project.Agents = append(theproject.Project.Agents, project.AgentConfig{
theproject.Project.Agents = append(theproject.Project.Agents, cproject.AgentConfig{
ID: agentID,
Name: name,
Description: description,
Expand Down Expand Up @@ -392,8 +395,8 @@ func reconcileAgentList(logger logger.Logger, cmd *cobra.Command, apiUrl string,
}

// make a map of the agents in the agentuity config file
fileAgents := make(map[string]project.AgentConfig)
fileAgentsByID := make(map[string]project.AgentConfig)
fileAgents := make(map[string]cproject.AgentConfig)
fileAgentsByID := make(map[string]cproject.AgentConfig)
for _, agent := range theproject.Project.Agents {
key := normalAgentName(agent.Name, theproject.Project.IsPython())
if existing, ok := fileAgents[key]; ok {
Expand Down Expand Up @@ -598,7 +601,8 @@ var agentListCmd = &cobra.Command{
ctx, cancel := signal.NotifyContext(context.Background(), os.Interrupt, syscall.SIGINT, syscall.SIGTERM)
defer cancel()
project := project.EnsureProject(ctx, cmd)
apiUrl, _, _ := util.GetURLs(logger)
urls := util.GetURLs(logger)
apiUrl := urls.API

// perform the reconcilation
keys, state := reconcileAgentList(logger, cmd, apiUrl, project.Token, project)
Expand Down Expand Up @@ -647,7 +651,8 @@ Examples:
ctx, cancel := signal.NotifyContext(context.Background(), os.Interrupt, syscall.SIGINT, syscall.SIGTERM)
defer cancel()
project := project.EnsureProject(ctx, cmd)
apiUrl, _, _ := util.GetURLs(logger)
urls := util.GetURLs(logger)
apiUrl := urls.API

// perform the reconcilation
keys, state := reconcileAgentList(logger, cmd, apiUrl, project.Token, project)
Expand Down
18 changes: 11 additions & 7 deletions cmd/apikey.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ var apikeyListCmd = &cobra.Command{
Args: cobra.NoArgs,
Short: "List API keys",
Long: `List all API keys.

This command displays all apikeys set for your org or project.

Examples:
Expand All @@ -83,7 +83,8 @@ Examples:
agentuity apikey ls --mask`,
Run: func(cmd *cobra.Command, args []string) {
logger := env.NewLogger(cmd)
apiUrl, _, _ := util.GetURLs(logger)
urls := util.GetURLs(logger)
apiUrl := urls.API
ctx, cancel := signal.NotifyContext(context.Background(), os.Interrupt, syscall.SIGINT, syscall.SIGTERM)
defer cancel()
format, _ := cmd.Flags().GetString("format")
Expand Down Expand Up @@ -152,7 +153,7 @@ var apikeyCreateCmd = &cobra.Command{
Args: cobra.MaximumNArgs(1),
Short: "Create an API key",
Long: `Create an API key.

This command creates an API key for your org or project.

Examples:
Expand All @@ -161,7 +162,8 @@ Examples:
agentuity apikey create <name> --expires-at <expiresAt> --project-id <projectId>`,
Run: func(cmd *cobra.Command, args []string) {
logger := env.NewLogger(cmd)
apiUrl, _, _ := util.GetURLs(logger)
urls := util.GetURLs(logger)
apiUrl := urls.API
ctx, cancel := signal.NotifyContext(context.Background(), os.Interrupt, syscall.SIGINT, syscall.SIGTERM)
defer cancel()
apiKey, _ := util.EnsureLoggedIn(ctx, logger, cmd)
Expand Down Expand Up @@ -223,7 +225,8 @@ var apikeyDeleteCmd = &cobra.Command{
Long: `Delete an API key.`,
Run: func(cmd *cobra.Command, args []string) {
logger := env.NewLogger(cmd)
apiUrl, _, _ := util.GetURLs(logger)
urls := util.GetURLs(logger)
apiUrl := urls.API
ctx, cancel := signal.NotifyContext(context.Background(), os.Interrupt, syscall.SIGINT, syscall.SIGTERM)
defer cancel()
apiKey, _ := util.EnsureLoggedIn(ctx, logger, cmd)
Expand Down Expand Up @@ -264,13 +267,14 @@ var apikeyGetCmd = &cobra.Command{
Args: cobra.ExactArgs(1),
Short: "Get an API key",
Long: `Get an API key.

Examples:
agentuity apikey get <id>
agentuity apikey get <id> --mask`,
Run: func(cmd *cobra.Command, args []string) {
logger := env.NewLogger(cmd)
apiUrl, _, _ := util.GetURLs(logger)
urls := util.GetURLs(logger)
apiUrl := urls.API
ctx, cancel := signal.NotifyContext(context.Background(), os.Interrupt, syscall.SIGINT, syscall.SIGTERM)
defer cancel()
apiKey, _ := util.EnsureLoggedIn(ctx, logger, cmd)
Expand Down
12 changes: 9 additions & 3 deletions cmd/auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,9 @@ Examples:
agentuity auth login`,
Run: func(cmd *cobra.Command, args []string) {
logger := env.NewLogger(cmd)
apiUrl, appUrl, _ := util.GetURLs(logger)
urls := util.GetURLs(logger)
apiUrl := urls.API
appUrl := urls.App
var otp string
var upgrade bool
ctx, cancel := signal.NotifyContext(context.Background(), os.Interrupt, syscall.SIGINT, syscall.SIGTERM)
Expand Down Expand Up @@ -144,7 +146,8 @@ Examples:
agentuity auth whoami`,
Run: func(cmd *cobra.Command, args []string) {
logger := env.NewLogger(cmd)
apiUrl, _, _ := util.GetURLs(logger)
urls := util.GetURLs(logger)
apiUrl := urls.API
ctx, cancel := signal.NotifyContext(context.Background(), os.Interrupt, syscall.SIGINT, syscall.SIGTERM)
defer cancel()
apiKey, userId := util.EnsureLoggedIn(ctx, logger, cmd)
Expand Down Expand Up @@ -183,7 +186,10 @@ Examples:
agentuity auth signup`,
Run: func(cmd *cobra.Command, args []string) {
logger := env.NewLogger(cmd)
apiUrl, appUrl, _ := util.GetURLs(logger)
urls := util.GetURLs(logger)
apiUrl := urls.API
appUrl := urls.App

var otp string
ctx, cancel := signal.NotifyContext(context.Background(), os.Interrupt, syscall.SIGINT, syscall.SIGTERM)
defer cancel()
Expand Down
Loading
Loading