diff --git a/LESSONS.md b/LESSONS.md index 32be700e3..0d26d3721 100644 --- a/LESSONS.md +++ b/LESSONS.md @@ -1702,6 +1702,11 @@ each one. request (#6688, cd030691a). 0b8c4bfc3's new field left TestEveryWordHasZh red (e9fcc6229). A change that adds a route or a label runs internal/cli, internal/gateway and internal/tui whole. + 11-17: 618bfc1a9 gave Kimi Code a "subagent pool" field and ran + internal/agent and internal/gui only (both machines were loaded), + so TestEveryWordHasZh was red again (fixed in the commit after + it). internal/agent's TestEveryFieldLabelHasTUIZh now fails on such + a label in the package the change runs. - A red with an issue still needs an owner. #6677 was red on main for about three hours. A session that met it commented "Not taking it" and shipped past it, and the review fixed it in 4c86b0ab4. The four diff --git a/docs/code-standards.md b/docs/code-standards.md index 96076e098..2a8e5b3ef 100644 --- a/docs/code-standards.md +++ b/docs/code-standards.md @@ -77,7 +77,8 @@ listed as not run, never left out. A guard that keeps being missed gets a twin in the package the change runs: internal/gui's TestEveryRouteIsNamedForTheCLI for a new route, internal/agent's TestEveryAgentNamedForTheLibrary for a new agent - (red on main four times before it, last at 00b2c11a6, 11-17). + (red on main four times before it, last at 00b2c11a6, 11-17), and + its TestEveryFieldLabelHasTUIZh for a new field's label (618bfc1a9). A change under `site/public/docs` ends with `node llms-full.mjs` and `node search-index.mjs` in site/, then `node --test site/*.test.mjs` from the repo root: both files are built from those pages and diff --git a/internal/agent/tui_zh_named_test.go b/internal/agent/tui_zh_named_test.go new file mode 100644 index 000000000..91601632f --- /dev/null +++ b/internal/agent/tui_zh_named_test.go @@ -0,0 +1,54 @@ +package agent + +import ( + "os" + "path/filepath" + "regexp" + "strings" + "testing" +) + +// Every agent field's label has its Chinese in internal/tui's zh map +// (i18n.go), which the TUI shows it through. internal/tui's +// TestEveryWordHasZh checks it too, but a change that adds a field runs +// this package, and a new label with no Chinese left that test red on +// main (e9fcc6229 for "permission mode", 11-15; "subagent pool" from +// 618bfc1a9, 11-17), each found after the push. tui imports agent, so +// this reads its files. +func TestEveryFieldLabelHasTUIZh(t *testing.T) { + dir := filepath.Join("..", "tui") + zh, err := os.ReadFile(filepath.Join(dir, "i18n.go")) + if err != nil { + t.Fatal(err) + } + tests, err := os.ReadFile(filepath.Join(dir, "i18n_test.go")) + if err != nil { + t.Fatal(err) + } + m := regexp.MustCompile(`var keepAsIs = map\[string\]bool\{([^}]*)\}`).FindSubmatch(tests) + if m == nil { + t.Fatal("internal/tui/i18n_test.go has no keepAsIs line") + } + keep := map[string]bool{} + for _, k := range regexp.MustCompile(`"([^"]*)":`).FindAllSubmatch(m[1], -1) { + keep[string(k[1])] = true + } + n := 0 + seen := map[string]bool{} + for _, a := range All() { + for _, f := range a.Fields { + if keep[f.Label] || seen[f.Label] || strings.TrimSpace(f.Label) == "" { + continue + } + seen[f.Label] = true + n++ + q := regexp.QuoteMeta(`"` + f.Label + `"`) + if !regexp.MustCompile(`(?m)^\s*` + q + `:\s*"`).Match(zh) { + t.Errorf("%s's field %q (label %q) has no Chinese in internal/tui/i18n.go's zh map", a.ID, f.Key, f.Label) + } + } + } + if n < 30 { + t.Fatalf("read %d labels", n) + } +}