claude-code: drop what was removed while away, render one at a time, refuse an empty settings set

Review of the nox-mesh plugin: a watch hands over what is there, not what
went, so the view is pruned to the state's keys before it starts; the
watches and the tools render one at a time, as the home's record is read
and written whole; the register answer names how an item is offered.
This commit is contained in:
jochen
2026-10-05 14:25:10 +02:00
parent dd1035a27d
commit 1d8f1ceff8
5 changed files with 70 additions and 2 deletions
+28 -2
View File
@@ -223,6 +223,23 @@ func (v *ConfigView) Take(key, op string, item *Item) bool {
return v.writeThrough()
}
// Prune drops what the view holds and the state no longer does: a registration removed while this node
// was away is never handed over by the watch, which hands over what is there, not what went.
func (v *ConfigView) Prune(present []string) bool {
keep := map[string]bool{}
for _, k := range present {
keep[k] = true
}
v.mu.Lock()
for k := range v.items {
if !keep[k] {
delete(v.items, k)
}
}
v.mu.Unlock()
return v.writeThrough()
}
// Items is what applies here, by key.
func (v *ConfigView) Items() map[string]Item {
v.mu.Lock()
@@ -730,8 +747,17 @@ func Register(p Paths, it Item, nodes []string, unregister bool, state ConfigSta
}
verb := map[bool]string{false: "registered", true: "unregistered"}[unregister]
answer := map[string]any{verb: it.Kind + " " + it.Name, "keys": keys}
if it.Kind != KindSettings && it.Scope != ScopeHome && !unregister {
answer["offered as"] = Plugin + ":" + it.Name
if !unregister {
switch {
case it.Scope == ScopeHome && it.Kind == KindCommand:
answer["offered as"] = "/" + it.Name
case it.Scope == ScopeHome:
answer["offered as"] = it.Name + ", from the home"
case it.Kind == KindSkill || it.Kind == KindAgent || it.Kind == KindOutputStyle:
answer["offered as"] = Plugin + ":" + it.Name
case it.Kind == KindCommand:
answer["offered as"] = "/" + Plugin + ":" + it.Name
}
}
if changed {
rendered, err := RenderNow(p, write)