Add command model, priority tie-break, and boundary matching
Why: I1 increment one - recognition output becomes a command list for the host router, same-score ties resolve by priority (I5), and CJK substring false positives get an opt-in boundary mode (I3). Evidence: go vet clean; go test ./... all ok, including new command (6), boundary (3), and tie-break tests; intentctl lint smoke run shows boundary hints on short unbounded terms. Existing classifier and ambiguity fixtures repointed to an equal-priority pair; the greet corpus case now expects the I5 tie-break outcome. Impact: Result gains Commands; recognizer derives them at one point (guard/fallback stay empty); MatchSpec gains Boundary (default off, legacy behavior unchanged); lint gains boundary hints. Top/Branch stay for compatibility. Refs: Documents proposal 2026-10-07-agent-stack-n1q1i1-plans.md I1 WP1/WP4/WP5
This commit is contained in:
+34
-3
@@ -106,15 +106,46 @@ func cmdLint(args []string) error {
|
||||
conflicts := snap.Conflicts()
|
||||
if len(conflicts) == 0 {
|
||||
fmt.Println("共享词条提示:无")
|
||||
} else {
|
||||
fmt.Printf("共享词条提示(%d 条,非错误,计分与确定性次序会裁决):\n", len(conflicts))
|
||||
for _, cf := range conflicts {
|
||||
fmt.Printf(" %s 与 %s 共享词条 %q\n", cf.A, cf.B, cf.Term)
|
||||
}
|
||||
}
|
||||
// 词界提示(I3):短词条且未开 boundary 的 spec 容易被中文子串误命中
|
||||
// (如「配置」命中「配置项」)。提示非错误;boundary: true 可压掉。
|
||||
var hints []string
|
||||
for _, id := range snap.SpecIDs() {
|
||||
spec, ok := snap.SpecByID(id)
|
||||
if !ok || spec.Matcher.Boundary {
|
||||
continue
|
||||
}
|
||||
terms := append(append([]string(nil), spec.Matcher.IncludesAny...), spec.Matcher.IncludesAll...)
|
||||
for _, term := range terms {
|
||||
if runeLen(term) <= 2 {
|
||||
hints = append(hints, fmt.Sprintf(" %s 词条 %q 短且未开 boundary(中文子串误命中风险;可考虑 boundary: true)", id, term))
|
||||
}
|
||||
}
|
||||
}
|
||||
if len(hints) == 0 {
|
||||
fmt.Println("词界提示:无")
|
||||
return nil
|
||||
}
|
||||
fmt.Printf("共享词条提示(%d 条,非错误,计分与确定性次序会裁决):\n", len(conflicts))
|
||||
for _, cf := range conflicts {
|
||||
fmt.Printf(" %s 与 %s 共享词条 %q\n", cf.A, cf.B, cf.Term)
|
||||
fmt.Printf("词界提示(%d 条,非错误):\n", len(hints))
|
||||
for _, h := range hints {
|
||||
fmt.Println(h)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func runeLen(s string) int {
|
||||
n := 0
|
||||
for range s {
|
||||
n++
|
||||
}
|
||||
return n
|
||||
}
|
||||
|
||||
func cmdExplain(args []string) error {
|
||||
fs := flag.NewFlagSet("explain", flag.ContinueOnError)
|
||||
c := parseCommon(fs)
|
||||
|
||||
Reference in New Issue
Block a user