Skip to content
This repository was archived by the owner on Jan 23, 2026. It is now read-only.
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
6 changes: 6 additions & 0 deletions cmd/agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,11 @@ var agentCreateCmd = &cobra.Command{
errsystem.New(errsystem.ErrInvalidConfiguration, err, errsystem.WithAttributes(map[string]any{"identifier": theproject.Project.Bundler.Identifier})).ShowErrorAndExit()
}

template, err := templates.LoadTemplateForRuntime(context.Background(), tmpdir, theproject.Project.Bundler.Identifier)
if err != nil {
errsystem.New(errsystem.ErrInvalidConfiguration, err, errsystem.WithAttributes(map[string]any{"identifier": theproject.Project.Bundler.Identifier})).ShowErrorAndExit()
}

if err := rules.NewAgent(templates.TemplateContext{
Logger: logger,
AgentName: name,
Expand All @@ -313,6 +318,7 @@ var agentCreateCmd = &cobra.Command{
AgentDescription: description,
ProjectDir: theproject.Dir,
TemplateDir: tmpdir,
Template: template,
AgentuityCommand: getAgentuityCommand(),
}); err != nil {
errsystem.New(errsystem.ErrApiRequest, err, errsystem.WithAttributes(map[string]any{"name": name})).ShowErrorAndExit()
Expand Down
3 changes: 3 additions & 0 deletions internal/templates/template.go
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,9 @@ func (t *TemplateRules) NewProject(ctx TemplateContext) error {
}

func (t *TemplateRules) NewAgent(ctx TemplateContext) error {
if ctx.Template == nil {
return fmt.Errorf("template is nil and is required")
}
for _, step := range t.NewAgentSteps.Steps {
if command, ok := resolveStep(ctx, step); ok {
if err := command.Run(ctx); err != nil {
Expand Down
13 changes: 13 additions & 0 deletions internal/templates/templates.go
Original file line number Diff line number Diff line change
Expand Up @@ -392,6 +392,19 @@ func LoadTemplates(ctx context.Context, dir string, custom bool) (Templates, err
return LoadTemplatesFromGithub(ctx, dir)
}

func LoadTemplateForRuntime(ctx context.Context, dir string, runtime string) (*Template, error) {
templates, err := LoadTemplates(ctx, dir, false)
if err != nil {
return nil, err
}
for _, template := range templates {
if template.Identifier == runtime {
return &template, nil
}
}
return nil, fmt.Errorf("template for runtime %s not found", runtime)
}

func LoadLanguageTemplates(ctx context.Context, dir string, runtime string) (LanguageTemplates, error) {
filename := filepath.Join(dir, runtime, "templates.yaml")
reader, err := getEmbeddedFile(filename)
Expand Down
Loading