mirror of
https://github.com/hanzoai/agents.git
synced 2026-10-30 18:48:36 +00:00
Transforms hanzoai/agents from a marketplace config repo into a full agent orchestration platform by merging the AgentField infrastructure: - Go control plane (K8s-like agent orchestration, service mesh, DAG workflows) - Python SDK (FastAPI-based agent framework, LiteLLM, memory, DID/VC) - TypeScript SDK (@hanzo/agents - Vercel AI SDK, MCP, workflows) - Go SDK (idiomatic agent builder + client) - React 19 embedded dashboard (XyFlow DAGs, Recharts, Radix UI) - Docker/K8s/Helm deployment configs - Examples: hello world, deep research, RAG, simulation, benchmarks - Functional test suite across Python/Go/TypeScript All references rebranded: AgentField → Hanzo Agents - Module: github.com/hanzoai/agents/control-plane - Python: hanzo_agents - TypeScript: @hanzo/agents - Go: github.com/hanzoai/agents/sdk/go - Env vars: HANZO_AGENTS_* - Config: hanzo-agents.yaml Previous marketplace configs moved to config/ directory.
77 lines
2.2 KiB
Go
77 lines
2.2 KiB
Go
package templates
|
|
|
|
import (
|
|
"embed"
|
|
"fmt"
|
|
"io/fs"
|
|
"strings"
|
|
"text/template"
|
|
)
|
|
|
|
//go:embed python/*.tmpl go/*.tmpl typescript/*.tmpl
|
|
var content embed.FS
|
|
|
|
// TemplateData holds the data to be passed to the templates.
|
|
type TemplateData struct {
|
|
ProjectName string // "my-awesome-agent"
|
|
NodeID string // "my-awesome-agent" (same as ProjectName)
|
|
GoModule string // "my-awesome-agent" (Go module name)
|
|
AuthorName string // "John Doe"
|
|
AuthorEmail string // "[email protected]"
|
|
CurrentYear int // 2025
|
|
CreatedAt string // "2025-01-05 10:30:00 EST"
|
|
Language string // "python", "go", or "typescript"
|
|
}
|
|
|
|
// GetTemplate retrieves a specific template by its path.
|
|
func GetTemplate(name string) (*template.Template, error) {
|
|
tmpl, err := template.ParseFS(content, name)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return tmpl, nil
|
|
}
|
|
|
|
// GetTemplateFiles returns a map of template file paths for the specified language.
|
|
// The map keys are the template paths in the embed.FS, and values are the destination paths.
|
|
func GetTemplateFiles(language string) (map[string]string, error) {
|
|
files := make(map[string]string)
|
|
|
|
// Determine the language directory
|
|
langDir := language
|
|
if language != "python" && language != "go" && language != "typescript" {
|
|
return nil, fmt.Errorf("unsupported language: %s (supported: python, go, typescript)", language)
|
|
}
|
|
|
|
// Walk the language-specific directory
|
|
err := fs.WalkDir(content, langDir, func(path string, d fs.DirEntry, err error) error {
|
|
if err != nil {
|
|
return err
|
|
}
|
|
if !d.IsDir() && strings.HasSuffix(path, ".tmpl") {
|
|
// Remove the language prefix and .tmpl suffix
|
|
// e.g., "python/main.py.tmpl" -> "main.py"
|
|
relativePath := strings.TrimPrefix(path, langDir+"/")
|
|
relativePath = strings.TrimSuffix(relativePath, ".tmpl")
|
|
files[path] = relativePath
|
|
}
|
|
return nil
|
|
})
|
|
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
return files, nil
|
|
}
|
|
|
|
// ReadTemplateContent reads the content of an embedded template file.
|
|
func ReadTemplateContent(path string) ([]byte, error) {
|
|
return content.ReadFile(path)
|
|
}
|
|
|
|
// GetSupportedLanguages returns the list of supported languages.
|
|
func GetSupportedLanguages() []string {
|
|
return []string{"python", "go", "typescript"}
|
|
}
|