Every agent's model. One place. Codex on DeepSeek, Claude Code on Kimi, from the menu bar.
redact: a folder or a program's word is no one's name or address (kekek711 on X)
yetone2eee5d6d1e00
diff --git a/internal/redact/model.go b/internal/redact/model.goindex 2c7862970..833ec0f82 100644--- a/internal/redact/model.go+++ b/internal/redact/model.go@@ -339,7 +339,7 @@ func modelFits(s string, a, b int, kind string) bool {case "ADDRESS":// a path is no address (-Users-x-projects-a/2b1a….jsonl); a Chinese// one has no spaces, a Latin one has them- if isASCII(v) && !strings.ContainsAny(v, " \t\n") && strings.ContainsAny(v, `/\`) {+ if isASCII(v) && !strings.ContainsAny(v, " \t\n") && strings.ContainsAny(v, `/\`) || programWords(v) {return false}return strings.IndexFunc(v, unicode.IsLetter) >= 0@@ -371,9 +371,27 @@ func modelFits(s string, a, b int, kind string) bool {return true}+// programWords says v, which the model took for a person's or a place's,+// is a program's words: it has an underscore (node_modules, __pycache__,+// node_modules 太, the model running on into the sentence after it), or+// it is Latin letters in lower case with no digit (dist, vendor,+// site-packages, ls node_modules). No name and no address is written so:+// a name has its capitals (personFits), an address its number or its+// capitals (42 Wallaby Way), a Chinese one its characters. The model took+// such a folder for personal data and the agent read a placeholder where+// the folder was ("node_modules给识别成姓名了", kekek711 on X, 10-29).+func programWords(v string) bool {+ if strings.Contains(v, "_") {+ return true+ }+ return isASCII(v) && strings.IndexFunc(v, unicode.IsLetter) >= 0 && strings.IndexFunc(v, func(r rune) bool { return unicode.IsUpper(r) || unicode.IsDigit(r) }) < 0+}+// wordsOnlyRe is words in lower case and nothing else, joined by - . or-// _: drizzle-orm, reflect-metadata, lodash.merge, secretstorage.-var wordsOnlyRe = regexp.MustCompile(`^[a-z]+(?:[-._][a-z]+)*$`)+// _: drizzle-orm, reflect-metadata, lodash.merge, secretstorage; and a+// folder's name as a path or Python writes it, with the slash after it+// or underscores around it: node_modules/, __pycache__.+var wordsOnlyRe = regexp.MustCompile(`^_*[a-z]+(?:[-._][a-z]+)*_*/?$`)// wordsOnly says v, which the model took for a secret, is made of words// in lower case alone, as a package's, a tool's or a setting's name is.diff --git a/internal/redact/program_words_test.go b/internal/redact/program_words_test.gonew file mode 100644index 000000000..4fff12d03--- /dev/null+++ b/internal/redact/program_words_test.go@@ -0,0 +1,84 @@+package redact++import (+ "encoding/json"+ "strings"+ "testing"+)++// kekek711 on X, 10-29: "node_modules给识别成姓名了". With the local model+// on, the folder went to the vendor as a placeholder of personal data, and+// the agent couldn't read or list it. A program's words (a folder, an+// identifier) are no one's name or address, wherever the model's span+// ends: alone, with the command before it, or run on into the sentence+// after it. Here in a Claude Code request as it is sent: a Bash call, its+// tool_result, and the user's sentence.+func TestModelLeavesProgramWords(t *testing.T) {+ const (+ cmd = "ls node_modules"+ listing = "@types\ntypescript\nvite\n"+ bin = "node_modules/.bin/tsc --noEmit"+ sentence = "node_modules 太大了"+ )+ body, _ := json.Marshal(map[string]any{"model": "claude-opus-5-5", "messages": []any{+ map[string]any{"role": "assistant", "content": []any{map[string]any{"type": "tool_use", "id": "toolu_01", "name": "Bash", "input": map[string]any{"command": cmd}}}},+ map[string]any{"role": "user", "content": []any{map[string]any{"type": "tool_result", "tool_use_id": "toolu_01", "content": listing + bin + "\n"}}},+ map[string]any{"role": "user", "content": sentence},+ }})+ for _, label := range []string{"private_person", "private_address", "secret"} {+ for _, v := range []string{"node_modules", "node_modules/", "node_modules 太", "ls node_modules"} {+ if label == "secret" && strings.Contains(v, " ") {+ continue // a secret's span with words around it: not changed here+ }+ Forget()+ resetSent()+ f := &fakeModel{values: map[string]string{v: label}}+ out, _ := MaskJSON(body, Options{Secrets: true, Personal: true, Model: f.find})+ for _, want := range []string{`"command":"` + cmd + `"`, bin, sentence} {+ if !strings.Contains(string(out), want) {+ t.Errorf("%s %q: %q masked: %s", label, v, want, out)+ }+ }+ }+ }+ // the class: a folder or a word of a program's, as the model finds it+ for _, c := range []struct{ text, value string }{+ {"du -sh site-packages __pycache__ dist vendor", "site-packages"},+ {"du -sh site-packages __pycache__ dist vendor", "__pycache__"},+ {"du -sh site-packages __pycache__ dist vendor", "dist"},+ {"du -sh site-packages __pycache__ dist vendor", "vendor"},+ {"find . -name __pycache__ -prune", "__pycache__"},+ {"rm -rf node_modules && pnpm install", "node_modules"},+ {"确实有问题。node_modules给识别成姓名了", "node_modules给"},+ } {+ for _, label := range []string{"private_person", "private_address", "secret"} {+ if label == "secret" && strings.Contains(c.value, "给") {+ continue+ }+ Forget()+ f := &fakeModel{values: map[string]string{c.value: label}}+ if out, n := Mask(c.text, Options{Secrets: true, Personal: true, Model: f.find}); n != 0 {+ t.Errorf("%s %q: masked %q", label, c.value, out)+ }+ }+ }+}++// A real name and a real address beside the folder are masked still.+func TestModelStillMasksNamesBesideProgramWords(t *testing.T) {+ Forget()+ const text = "Rina Kowalczyk said node_modules is 2 GB; she lives at 42 Wallaby Way, Sydney, 张伟住在建国路88号"+ f := &fakeModel{values: map[string]string{+ "Rina Kowalczyk": "private_person", "42 Wallaby Way, Sydney": "private_address", "建国路88号": "private_address",+ "node_modules": "private_person",+ }}+ out, n := Mask(text, Options{Secrets: true, Personal: true, Model: f.find})+ for _, gone := range []string{"Rina Kowalczyk", "42 Wallaby Way", "建国路88号"} {+ if strings.Contains(out, gone) {+ t.Errorf("%q not masked: %q", gone, out)+ }+ }+ if !strings.Contains(out, " node_modules is 2 GB") || n != 3 {+ t.Errorf("%d masked: %q", n, out)+ }+}