把 github.com/Autumn-27/norma v0.4.3(commit 320ae32)的源码复制到 third_party/norma,并用 go.mod 的 replace 指向本地副本。上游删除仓库或 改写 tag 都不再影响本仓库构建。 - 已验证 GOPROXY=off 下可完整编译并打出发行包 - go.sum 中该模块的两条校验记录随之删除(本地 replace 不需要哈希) - 升级方法与授权注意事项见 third_party/README.md
41 lines
1.1 KiB
Go
41 lines
1.1 KiB
Go
package tool
|
|
|
|
import (
|
|
"context"
|
|
"encoding/json"
|
|
"fmt"
|
|
"strings"
|
|
)
|
|
|
|
// NewTaskList builds the TaskList tool: enumerate this session's background tasks.
|
|
func NewTaskList() CoreTool {
|
|
return Build(Spec{
|
|
Name: "TaskList",
|
|
Description: "Lists the background tasks started in this session with their status, exit code, and command.",
|
|
Schema: map[string]any{"type": "object", "properties": map[string]any{}},
|
|
ReadOnly: always,
|
|
Concurrent: always,
|
|
Permissions: allowReadOnly,
|
|
Run: runTaskList,
|
|
})
|
|
}
|
|
|
|
func runTaskList(_ context.Context, _ json.RawMessage, tc *ToolContext) (Result, error) {
|
|
if tc == nil || tc.Tasks == nil {
|
|
return Errorf("Error: background tasks are not enabled"), nil
|
|
}
|
|
tasks := tc.Tasks.List()
|
|
if len(tasks) == 0 {
|
|
return Text("No background tasks."), nil
|
|
}
|
|
var b strings.Builder
|
|
for _, t := range tasks {
|
|
fmt.Fprintf(&b, "%s [%s] %s", t.ID, t.Kind, t.Status)
|
|
if t.Status == TaskCompleted || t.Status == TaskFailed {
|
|
fmt.Fprintf(&b, " exit=%d", t.ExitCode)
|
|
}
|
|
fmt.Fprintf(&b, " %s\n", short(t.Command))
|
|
}
|
|
return Text(b.String()), nil
|
|
}
|