mirror of
https://gitea.com/gitea/gitea-mcp.git
synced 2026-08-03 15:49:23 +02:00
docs: rewrite the tool tables and slim down the READMEs (#215)
Fixes https://gitea.com/gitea/gitea-mcp/issues/214. The tool tables listed tools that had not existed for several releases. They are regenerated from the registry, gain an `Access` column so it is visible what disappears under `-r` / `GITEA_READONLY`, and get their fine-grained scopes back. `TestReadmeToolTables` now compares them against the registry in both directions, for every translation. Other corrections from verifying the prose against the source: the pagination parameter is `per_page`, not `perPage`; Go 1.26 is required, not 1.24; the Chinese READMEs were missing the OpenCode and Mistral Vibe sections. Also trimmed the drifted table of contents and the sections the intro and `gitea-mcp --help` already cover, and dropped the heading emoji. `CLAUDE.md` had its own stale tool list, so it now points at `AGENTS.md` like gitea/gitea does. --------- Co-authored-by: silverwind <me@silverwind.io> Reviewed-on: https://gitea.com/gitea/gitea-mcp/pulls/215 Reviewed-by: silverwind <2021+silverwind@noreply.gitea.com>
This commit is contained in:
@@ -0,0 +1,69 @@
|
||||
package operation
|
||||
|
||||
import (
|
||||
"maps"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"regexp"
|
||||
"slices"
|
||||
"strings"
|
||||
"testing"
|
||||
)
|
||||
|
||||
// toolTableRow matches a row of the "Available Tools" table in the README
|
||||
// files, capturing the tool name and the access cell, e.g.
|
||||
// "| get_me | User | Read | Get the current authenticated user |".
|
||||
var toolTableRow = regexp.MustCompile(`^\|\s*([a-z_]+)\s*\|[^|]*\|\s*(\S+)\s*\|`)
|
||||
|
||||
// readmeAccessLabels maps each README to the access-column labels it uses.
|
||||
var readmeAccessLabels = map[string]map[string]string{
|
||||
"../README.md": {"Read": "read", "Write": "write"},
|
||||
"../README.zh-cn.md": {"读取": "read", "写入": "write"},
|
||||
"../README.zh-tw.md": {"讀取": "read", "寫入": "write"},
|
||||
}
|
||||
|
||||
// TestReadmeToolTables ensures the tool tables in the README files stay in sync
|
||||
// with the registered tools, in both directions and for every translation.
|
||||
// The tables listed tools that no longer existed for several releases before
|
||||
// anyone noticed.
|
||||
func TestReadmeToolTables(t *testing.T) {
|
||||
registered := map[string]string{}
|
||||
for _, d := range domainTools {
|
||||
for _, st := range d.ReadTools() {
|
||||
registered[st.Tool.Name] = "read"
|
||||
}
|
||||
for _, st := range d.WriteTools() {
|
||||
registered[st.Tool.Name] = "write"
|
||||
}
|
||||
}
|
||||
|
||||
for path, labels := range readmeAccessLabels {
|
||||
t.Run(filepath.Base(path), func(t *testing.T) {
|
||||
content, err := os.ReadFile(path)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
documented := map[string]string{}
|
||||
for line := range strings.SplitSeq(string(content), "\n") {
|
||||
if match := toolTableRow.FindStringSubmatch(line); match != nil {
|
||||
documented[match[1]] = labels[match[2]]
|
||||
}
|
||||
}
|
||||
|
||||
for _, name := range slices.Sorted(maps.Keys(registered)) {
|
||||
access, ok := documented[name]
|
||||
switch {
|
||||
case !ok:
|
||||
t.Errorf("tool %q is registered but missing from the tool table", name)
|
||||
case access != registered[name]:
|
||||
t.Errorf("tool %q is documented with %q access, want %q", name, access, registered[name])
|
||||
}
|
||||
}
|
||||
for _, name := range slices.Sorted(maps.Keys(documented)) {
|
||||
if _, ok := registered[name]; !ok {
|
||||
t.Errorf("tool %q is in the tool table but is not registered", name)
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user