feat: rename Content field to Instruction across skill-related models and requests for consistency
This commit is contained in:
@@ -241,7 +241,7 @@ func buildSelectedSkillInstruction(skill *models.SkillDefinition, toolDefinition
|
|||||||
if desc := strings.TrimSpace(skill.Description); desc != "" {
|
if desc := strings.TrimSpace(skill.Description); desc != "" {
|
||||||
lines = append(lines, fmt.Sprintf("- description: %s", desc))
|
lines = append(lines, fmt.Sprintf("- description: %s", desc))
|
||||||
}
|
}
|
||||||
if content := strings.TrimSpace(skill.Content); content != "" {
|
if content := strings.TrimSpace(skill.Instruction); content != "" {
|
||||||
lines = append(lines, "", "技能说明:", content)
|
lines = append(lines, "", "技能说明:", content)
|
||||||
}
|
}
|
||||||
if examples := parseJSONStringArray(skill.Examples); len(examples) > 0 {
|
if examples := parseJSONStringArray(skill.Examples); len(examples) > 0 {
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ func BuildSkillDefinitionResponse(item *models.SkillDefinition) response.SkillDe
|
|||||||
Code: item.Code,
|
Code: item.Code,
|
||||||
Name: item.Name,
|
Name: item.Name,
|
||||||
Description: item.Description,
|
Description: item.Description,
|
||||||
Content: item.Content,
|
Instruction: item.Instruction,
|
||||||
Examples: examples,
|
Examples: examples,
|
||||||
AllowedToolCodes: allowedToolCodes,
|
AllowedToolCodes: allowedToolCodes,
|
||||||
Priority: item.Priority,
|
Priority: item.Priority,
|
||||||
|
|||||||
@@ -908,7 +908,7 @@ type SkillDefinition struct {
|
|||||||
Code string `gorm:"type:varchar(100);not null;default:'';uniqueIndex"` // Code 为 Skill 的稳定唯一编码,供程序内部引用和路由判断使用,例如 refund_skill。
|
Code string `gorm:"type:varchar(100);not null;default:'';uniqueIndex"` // Code 为 Skill 的稳定唯一编码,供程序内部引用和路由判断使用,例如 refund_skill。
|
||||||
Name string `gorm:"type:varchar(100);not null;default:'';index"` // Name 为 Skill 的展示名称,用于后台列表、配置页和人工选择场景。
|
Name string `gorm:"type:varchar(100);not null;default:'';index"` // Name 为 Skill 的展示名称,用于后台列表、配置页和人工选择场景。
|
||||||
Description string `gorm:"type:varchar(255);not null;default:''"` // Description 为 Skill 的简要说明,用于描述该 Skill 的适用场景和职责边界。
|
Description string `gorm:"type:varchar(255);not null;default:''"` // Description 为 Skill 的简要说明,用于描述该 Skill 的适用场景和职责边界。
|
||||||
Content string `gorm:"type:longtext"` // Content 为 Skill 的主体文档,使用 Markdown 编写,供 Agent 理解任务目标、步骤和工具使用要求。
|
Instruction string `gorm:"type:longtext"` // Instruction 为 Skill 的主体说明文档存储字段,使用 Markdown 编写,供 Agent 理解任务目标、步骤和工具使用要求。
|
||||||
Examples string `gorm:"type:text"` // Examples 为示例问法 JSON 数组字符串。
|
Examples string `gorm:"type:text"` // Examples 为示例问法 JSON 数组字符串。
|
||||||
AllowedToolCodes string `gorm:"type:text"` // AllowedToolCodes 为允许使用的工具编码 JSON 数组字符串。
|
AllowedToolCodes string `gorm:"type:text"` // AllowedToolCodes 为允许使用的工具编码 JSON 数组字符串。
|
||||||
Priority int `gorm:"type:int;not null;default:0;index"` // Priority 为 Skill 命中冲突时的优先级,数值越大优先级越高。
|
Priority int `gorm:"type:int;not null;default:0;index"` // Priority 为 Skill 命中冲突时的优先级,数值越大优先级越高。
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ type CreateSkillDefinitionRequest struct {
|
|||||||
Code string `json:"code"`
|
Code string `json:"code"`
|
||||||
Name string `json:"name"`
|
Name string `json:"name"`
|
||||||
Description string `json:"description"`
|
Description string `json:"description"`
|
||||||
Content string `json:"content"`
|
Instruction string `json:"instruction"`
|
||||||
Examples []string `json:"examples"`
|
Examples []string `json:"examples"`
|
||||||
AllowedToolCodes []string `json:"allowedToolCodes"`
|
AllowedToolCodes []string `json:"allowedToolCodes"`
|
||||||
Priority int `json:"priority"`
|
Priority int `json:"priority"`
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ type SkillDefinitionResponse struct {
|
|||||||
Code string `json:"code"`
|
Code string `json:"code"`
|
||||||
Name string `json:"name"`
|
Name string `json:"name"`
|
||||||
Description string `json:"description"`
|
Description string `json:"description"`
|
||||||
Content string `json:"content"`
|
Instruction string `json:"instruction"`
|
||||||
Examples []string `json:"examples"`
|
Examples []string `json:"examples"`
|
||||||
AllowedToolCodes []string `json:"allowedToolCodes"`
|
AllowedToolCodes []string `json:"allowedToolCodes"`
|
||||||
Priority int `json:"priority"`
|
Priority int `json:"priority"`
|
||||||
|
|||||||
@@ -112,7 +112,7 @@ func (s *skillDefinitionService) CreateSkillDefinition(req request.CreateSkillDe
|
|||||||
Code: normalized.Code,
|
Code: normalized.Code,
|
||||||
Name: normalized.Name,
|
Name: normalized.Name,
|
||||||
Description: normalized.Description,
|
Description: normalized.Description,
|
||||||
Content: normalized.Content,
|
Instruction: normalized.Instruction,
|
||||||
Examples: mustMarshalSkillStringArray(normalized.Examples),
|
Examples: mustMarshalSkillStringArray(normalized.Examples),
|
||||||
AllowedToolCodes: mustMarshalSkillStringArray(normalized.AllowedToolCodes),
|
AllowedToolCodes: mustMarshalSkillStringArray(normalized.AllowedToolCodes),
|
||||||
Priority: normalized.Priority,
|
Priority: normalized.Priority,
|
||||||
@@ -151,7 +151,7 @@ func (s *skillDefinitionService) UpdateSkillDefinition(req request.UpdateSkillDe
|
|||||||
"code": normalized.Code,
|
"code": normalized.Code,
|
||||||
"name": normalized.Name,
|
"name": normalized.Name,
|
||||||
"description": normalized.Description,
|
"description": normalized.Description,
|
||||||
"content": normalized.Content,
|
"content": normalized.Instruction,
|
||||||
"examples": mustMarshalSkillStringArray(normalized.Examples),
|
"examples": mustMarshalSkillStringArray(normalized.Examples),
|
||||||
"allowed_tool_codes": mustMarshalSkillStringArray(normalized.AllowedToolCodes),
|
"allowed_tool_codes": mustMarshalSkillStringArray(normalized.AllowedToolCodes),
|
||||||
"priority": resolveSkillPriorityForService(normalized.Priority, current.Priority),
|
"priority": resolveSkillPriorityForService(normalized.Priority, current.Priority),
|
||||||
@@ -167,7 +167,7 @@ func (s *skillDefinitionService) normalizeSkillDefinitionRequest(req request.Cre
|
|||||||
Code: strings.TrimSpace(req.Code),
|
Code: strings.TrimSpace(req.Code),
|
||||||
Name: strings.TrimSpace(req.Name),
|
Name: strings.TrimSpace(req.Name),
|
||||||
Description: strings.TrimSpace(req.Description),
|
Description: strings.TrimSpace(req.Description),
|
||||||
Content: strings.TrimSpace(req.Content),
|
Instruction: strings.TrimSpace(req.Instruction),
|
||||||
Priority: normalizeSkillPriorityForService(req.Priority),
|
Priority: normalizeSkillPriorityForService(req.Priority),
|
||||||
Remark: strings.TrimSpace(req.Remark),
|
Remark: strings.TrimSpace(req.Remark),
|
||||||
}
|
}
|
||||||
@@ -177,8 +177,8 @@ func (s *skillDefinitionService) normalizeSkillDefinitionRequest(req request.Cre
|
|||||||
if normalized.Name == "" {
|
if normalized.Name == "" {
|
||||||
return nil, errorsx.InvalidParam("Skill 名称不能为空")
|
return nil, errorsx.InvalidParam("Skill 名称不能为空")
|
||||||
}
|
}
|
||||||
if normalized.Content == "" {
|
if normalized.Instruction == "" {
|
||||||
return nil, errorsx.InvalidParam("Content 不能为空")
|
return nil, errorsx.InvalidParam("技能说明不能为空")
|
||||||
}
|
}
|
||||||
examples, err := normalizeSkillStringArray(req.Examples)
|
examples, err := normalizeSkillStringArray(req.Examples)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ const emptyForm: EditForm = {
|
|||||||
code: "",
|
code: "",
|
||||||
name: "",
|
name: "",
|
||||||
description: "",
|
description: "",
|
||||||
content: "",
|
instruction: "",
|
||||||
examplesText: "",
|
examplesText: "",
|
||||||
remark: "",
|
remark: "",
|
||||||
};
|
};
|
||||||
@@ -50,7 +50,7 @@ const skillFormSchema = z.object({
|
|||||||
.regex(/^[a-zA-Z0-9_-]+$/, "Skill 编码仅支持字母、数字、下划线和中划线"),
|
.regex(/^[a-zA-Z0-9_-]+$/, "Skill 编码仅支持字母、数字、下划线和中划线"),
|
||||||
name: z.string().trim().min(1, "Skill 名称不能为空"),
|
name: z.string().trim().min(1, "Skill 名称不能为空"),
|
||||||
description: z.string().trim(),
|
description: z.string().trim(),
|
||||||
content: z.string().trim().min(1, "Content 不能为空"),
|
instruction: z.string().trim().min(1, "技能说明不能为空"),
|
||||||
examplesText: z.string().trim(),
|
examplesText: z.string().trim(),
|
||||||
remark: z.string().trim(),
|
remark: z.string().trim(),
|
||||||
});
|
});
|
||||||
@@ -71,7 +71,7 @@ function buildForm(item: SkillDefinition | null): EditForm {
|
|||||||
code: item.code,
|
code: item.code,
|
||||||
name: item.name,
|
name: item.name,
|
||||||
description: item.description ?? "",
|
description: item.description ?? "",
|
||||||
content: item.content ?? "",
|
instruction: item.instruction ?? "",
|
||||||
examplesText: (item.examples ?? []).join("\n"),
|
examplesText: (item.examples ?? []).join("\n"),
|
||||||
remark: item.remark ?? "",
|
remark: item.remark ?? "",
|
||||||
};
|
};
|
||||||
@@ -85,7 +85,7 @@ function buildPayload(
|
|||||||
code: form.code.trim(),
|
code: form.code.trim(),
|
||||||
name: form.name.trim(),
|
name: form.name.trim(),
|
||||||
description: form.description.trim(),
|
description: form.description.trim(),
|
||||||
content: form.content.trim(),
|
instruction: form.instruction.trim(),
|
||||||
examples: form.examplesText
|
examples: form.examplesText
|
||||||
.split("\n")
|
.split("\n")
|
||||||
.map((item) => item.trim())
|
.map((item) => item.trim())
|
||||||
@@ -307,22 +307,22 @@ function SkillEditDialogBody({
|
|||||||
</FieldContent>
|
</FieldContent>
|
||||||
</Field>
|
</Field>
|
||||||
|
|
||||||
<Field data-invalid={!!errors.content}>
|
<Field data-invalid={!!errors.instruction}>
|
||||||
<FieldLabel htmlFor="skill-content">Content</FieldLabel>
|
<FieldLabel htmlFor="skill-instruction">技能说明</FieldLabel>
|
||||||
<FieldContent>
|
<FieldContent>
|
||||||
<Textarea
|
<Textarea
|
||||||
id="skill-content"
|
id="skill-instruction"
|
||||||
rows={12}
|
rows={12}
|
||||||
placeholder="请输入 Skill 文档内容,描述目标、步骤、工具使用规则和边界。"
|
placeholder="请输入 Skill 文档内容,描述目标、步骤、工具使用规则和边界。"
|
||||||
aria-invalid={!!errors.content}
|
aria-invalid={!!errors.instruction}
|
||||||
{...register("content")}
|
{...register("instruction")}
|
||||||
/>
|
/>
|
||||||
<FieldError errors={[errors.content]} />
|
<FieldError errors={[errors.instruction]} />
|
||||||
</FieldContent>
|
</FieldContent>
|
||||||
</Field>
|
</Field>
|
||||||
|
|
||||||
<Field data-invalid={!!errors.examplesText}>
|
<Field data-invalid={!!errors.examplesText}>
|
||||||
<FieldLabel htmlFor="skill-examples">Examples</FieldLabel>
|
<FieldLabel htmlFor="skill-examples">示例问法</FieldLabel>
|
||||||
<FieldContent>
|
<FieldContent>
|
||||||
<Textarea
|
<Textarea
|
||||||
id="skill-examples"
|
id="skill-examples"
|
||||||
|
|||||||
@@ -273,7 +273,7 @@ export type SkillDefinition = {
|
|||||||
code: string
|
code: string
|
||||||
name: string
|
name: string
|
||||||
description: string
|
description: string
|
||||||
content: string
|
instruction: string
|
||||||
examples: string[]
|
examples: string[]
|
||||||
allowedToolCodes: string[]
|
allowedToolCodes: string[]
|
||||||
priority: number
|
priority: number
|
||||||
@@ -290,7 +290,7 @@ export type CreateSkillDefinitionPayload = {
|
|||||||
code: string
|
code: string
|
||||||
name: string
|
name: string
|
||||||
description: string
|
description: string
|
||||||
content: string
|
instruction: string
|
||||||
examples: string[]
|
examples: string[]
|
||||||
allowedToolCodes: string[]
|
allowedToolCodes: string[]
|
||||||
priority?: number
|
priority?: number
|
||||||
|
|||||||
Reference in New Issue
Block a user