chore: 初始化仓库,导入项目基线代码
Academy v0.8.3 完整代码基线:Go 后端(internal/cmd/cli/mcp-server/docreader)、 Vue 前端(frontend)、数据库迁移(migrations)、部署编排(docker/helm/deploy)与文档。 今日开发的培训推送管理改动随后单独提交。
This commit is contained in:
commit
7ec21f35b0
5767 files changed
+1436788
No files matched your search
@@ -0,0 +1,84 @@
|
||||
package tools
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
|
||||
"academy/internal/types"
|
||||
"academy/internal/types/interfaces"
|
||||
)
|
||||
|
||||
type wikiUpdateIssueTool struct {
|
||||
BaseTool
|
||||
wikiService interfaces.WikiPageService
|
||||
kbIDs []string
|
||||
}
|
||||
|
||||
func NewWikiUpdateIssueTool(wikiService interfaces.WikiPageService, kbIDs []string) types.Tool {
|
||||
return &wikiUpdateIssueTool{
|
||||
BaseTool: NewBaseTool(
|
||||
ToolWikiUpdateIssue,
|
||||
"Update the status of a specific wiki page issue (e.g., set it to 'resolved' or 'ignored').",
|
||||
json.RawMessage(`{
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"issue_id": {
|
||||
"type": "string",
|
||||
"description": "The short iN issue ID from wiki_read_issue."
|
||||
},
|
||||
"status": {
|
||||
"type": "string",
|
||||
"enum": ["resolved", "ignored", "pending"],
|
||||
"description": "The new status for the issue."
|
||||
}
|
||||
},
|
||||
"required": ["issue_id", "status"]
|
||||
}`),
|
||||
),
|
||||
wikiService: wikiService,
|
||||
kbIDs: kbIDs,
|
||||
}
|
||||
}
|
||||
|
||||
func (t *wikiUpdateIssueTool) Execute(ctx context.Context, args json.RawMessage) (*types.ToolResult, error) {
|
||||
var params struct {
|
||||
IssueID string `json:"issue_id"`
|
||||
Status string `json:"status"`
|
||||
}
|
||||
if err := json.Unmarshal(args, ¶ms); err != nil {
|
||||
return &types.ToolResult{Success: false, Error: "Invalid parameters: " + err.Error()}, nil
|
||||
}
|
||||
|
||||
if params.IssueID == "" {
|
||||
return &types.ToolResult{Success: false, Error: "issue_id is required"}, nil
|
||||
}
|
||||
if params.Status == "" {
|
||||
return &types.ToolResult{Success: false, Error: "status is required"}, nil
|
||||
}
|
||||
|
||||
if len(t.kbIDs) == 0 {
|
||||
return &types.ToolResult{Success: false, Error: "No knowledge bases available"}, nil
|
||||
}
|
||||
issue, err := resolveWikiIssue(ctx, t.wikiService, params.IssueID, t.kbIDs)
|
||||
if err != nil {
|
||||
return &types.ToolResult{Success: false, Error: err.Error()}, nil
|
||||
}
|
||||
|
||||
// Update only after the issue has been proven to belong to an allowed KB.
|
||||
err = t.wikiService.UpdateIssueStatus(ctx, issue.KnowledgeBaseID, params.IssueID, params.Status)
|
||||
if err != nil {
|
||||
return &types.ToolResult{Success: false, Error: "Failed to update issue status: " + err.Error()}, nil
|
||||
}
|
||||
|
||||
return &types.ToolResult{
|
||||
Success: true,
|
||||
Output: fmt.Sprintf("Successfully updated issue %s to status '%s'", params.IssueID, params.Status),
|
||||
Data: map[string]interface{}{"data_change": wikiDataChange("update_issue", issue.KnowledgeBaseID)},
|
||||
}, nil
|
||||
}
|
||||
|
||||
// ApprovalGrant scopes a session-wide approval to the run's knowledge bases.
|
||||
func (t *wikiUpdateIssueTool) ApprovalGrant(ctx context.Context, _ json.RawMessage) (string, string) {
|
||||
return wikiApprovalGrant(ctx, t.Name(), t.kbIDs)
|
||||
}
|
||||
Reference in new issue
Block a user