Files
heicode-mananger/heicode/model/agent_template.go
T
chenchenandClaude Opus 4.8 4605cf4f62 feat(agent): HM-maintained agent template library (md), sent to AM on deploy
Templates now live in HM (not AM). A template is a Claude-Code style subagent
.md definition; HM passes it to AM at deploy time.

- model AgentTemplate (agent_templates): template_key, name_zh / description_zh
  (Chinese display for the console), model, definition (full .md), source, status.
- 19 presets from oh-my-claudecode (MIT, NOTICE.md attribution) embedded via
  go:embed and idempotently seeded; Chinese name+desc mapping in code.
- GET /api/heicode/agent-templates now reads HM's library (Chinese name/desc),
  not AM. Admin CRUD at /api/agent-templates (AdminAuth).
- deploy loads the chosen template and sends {template_key, agent_definition (md),
  model, env, callback_url} to AM via a generic /api/agent/agents/start; removed
  the AM-template-listing path. AM adapter still isolated (amStartArgs).
- tests: frontmatter parse, seed (19 + 架构顾问), start round-trip asserts
  agent_definition in payload. All green.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-04 00:05:08 +08:00

21 lines
1.3 KiB
Go

package model
// AgentTemplate is an HM-maintained agent definition (a Claude-Code style
// subagent markdown). The web console shows name_zh / description_zh (Chinese);
// Definition holds the full agent .md that HM passes to AM at deploy time.
type AgentTemplate struct {
Id int `json:"id" gorm:"primaryKey"`
TemplateKey string `json:"template_key" gorm:"type:varchar(64);uniqueIndex;not null"` // e.g. "architect"
NameZh string `json:"name_zh" gorm:"type:varchar(128)"` // 中文名 (display)
DescriptionZh string `json:"description_zh" gorm:"type:text"` // 中文简介 (display)
Model string `json:"model" gorm:"type:varchar(64)"` // parsed from frontmatter
Definition string `json:"definition" gorm:"type:text"` // full agent .md (sent to AM)
Source string `json:"source" gorm:"type:varchar(16);default:'preset';index"` // preset | custom
Status string `json:"status" gorm:"type:varchar(16);default:'active';index"`
SortOrder int `json:"sort_order" gorm:"default:0;index"`
CreatedAt int64 `json:"created_at" gorm:"autoCreateTime"`
UpdatedAt int64 `json:"updated_at" gorm:"autoUpdateTime"`
}
func (AgentTemplate) TableName() string { return "agent_templates" }