完成统一方案 v0.1 剩余客户端要求(#10/#11/#12)+ 对接文档。 - #10 项目文件夹产物(§12):Manager 解析 runtime 的 markdown 多文件 artifact 成项目文件树, 新增 .../artifacts/{id}/manifest、/files/{path}、/archive 三接口(按需解析,zip 打包)。 - #11 本地修改 revision 协议(§12.7):新模型 AgentArtifactRevision + 迁移; .../local-edits、/local-edits/batch、/revisions;base_revision 冲突检测返回 ARTIFACT_REVISION_CONFLICT;Manager 持有 accepted 基线,回调 Runtime(审计事件)。 - #12 云部署控制面(§18):新模型 AgentCloudDeployment + 迁移; GET /api/heicode/deployment-targets;.../tasks/{id}/deployments(创建/列表); 生产环境进 waiting_approval;客户端只传 resource_binding_id(禁 inline secret); 真实云执行留 executor=pending_worker,等 Deploy Worker 接入。 - 文档:新增 docs/integration/heicode-desktop-unified-api.md(取代旧 sub-agile 文档, 覆盖 capabilities/统一任务路由/display_status/项目文件夹/本地修改/云部署/客户端约束/错误码)。 验证:go build ./... + go test(controller/router/model/middleware)全绿。 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
45 lines
2.0 KiB
Go
45 lines
2.0 KiB
Go
package model
|
|
|
|
// AgentArtifactRevision stores client-submitted local edits to a project
|
|
// artifact as monotonic revisions (unified spec §12.7). Manager is the owner of
|
|
// the accepted-revision baseline; Runtime reads new revisions via Manager.
|
|
type AgentArtifactRevision struct {
|
|
Id int `gorm:"primaryKey" json:"id"`
|
|
ArtifactID string `gorm:"type:varchar(128);index" json:"artifact_id"`
|
|
DeploymentID string `gorm:"type:varchar(64);index" json:"deployment_id"`
|
|
UserID string `gorm:"type:varchar(64);index" json:"user_id"`
|
|
Revision int `gorm:"index" json:"revision"`
|
|
ProjectRevision int `json:"project_revision"`
|
|
Source string `gorm:"type:varchar(64)" json:"source"`
|
|
BaseContentHash string `gorm:"type:varchar(128)" json:"base_content_hash"`
|
|
ContentHash string `gorm:"type:varchar(128)" json:"content_hash"`
|
|
ChangeSummary string `gorm:"type:varchar(512)" json:"change_summary"`
|
|
CreatedBy string `gorm:"type:varchar(64)" json:"created_by"`
|
|
Status string `gorm:"type:varchar(32)" json:"status"`
|
|
PayloadJSON string `gorm:"type:text" json:"-"`
|
|
CreatedAtMs int64 `gorm:"bigint;index" json:"created_at"`
|
|
}
|
|
|
|
func (AgentArtifactRevision) TableName() string {
|
|
return "agent_artifact_revisions"
|
|
}
|
|
|
|
func InsertAgentArtifactRevision(r *AgentArtifactRevision) error {
|
|
return DB.Create(r).Error
|
|
}
|
|
|
|
func ListAgentArtifactRevisions(artifactID string) ([]AgentArtifactRevision, error) {
|
|
var rows []AgentArtifactRevision
|
|
err := DB.Where("artifact_id = ?", artifactID).Order("revision asc, id asc").Find(&rows).Error
|
|
return rows, err
|
|
}
|
|
|
|
// LatestAgentArtifactRevision returns the highest-revision row for an artifact.
|
|
func LatestAgentArtifactRevision(artifactID string) (AgentArtifactRevision, bool) {
|
|
var row AgentArtifactRevision
|
|
if err := DB.Where("artifact_id = ?", artifactID).Order("revision desc, id desc").First(&row).Error; err != nil {
|
|
return AgentArtifactRevision{}, false
|
|
}
|
|
return row, true
|
|
}
|