Let the knowledge base list its records by kind, status, topic or a flag (issue 1064)

This commit is contained in:
jochen
2026-10-17 22:59:09 +02:00
parent 1124f17912
commit 1cfbcf8e30
6 changed files with 353 additions and 2 deletions
@@ -37,7 +37,7 @@ import (
const Seat = "knowledge-base"
// Verbs are the seat's verbs, as the manifest declares and claims them (ADR 0290 rule 6).
var Verbs = []string{"ask", "get", "holds", "links", "history", "reserve", "propose", "import", "return"}
var Verbs = []string{"ask", "get", "list", "holds", "links", "history", "reserve", "propose", "import", "return"}
// HealthTool is the module's own tool the node-engine asks how it is.
const HealthTool = "knowledge_health"
@@ -813,6 +813,46 @@ func Tools(k *KB, caller func(map[string]any) string) []stdio.Tool {
}
return k.Get(g)
}},
{Name: Seat + ".list",
Description: "The records that match, newest first, number by number, one short row each — number, kind, title, status, " +
"topic, date and versions — optionally only those of one kind (decision or research), at one status, of one topic of " +
"the reading order, or named by flag: research-done is an active research effort naming what it became in a became " +
"link to a decision, every such decision accepted — a candidate for graduated; proposed-old is a proposal whose " +
"current version is more than a day old. before pages the newest-first list: give the answer's next to read on below it.",
Input: schema(nil, map[string]any{"kind": kindArg(),
"status": map[string]any{"type": "string", "enum": AllStatuses, "description": "only records at this status"},
"topic": text("only records of this topic, as the reading order groups them"),
"flag": map[string]any{"type": "string", "enum": ListFlags,
"description": "only the research efforts done (research-done), or the proposals grown old (proposed-old)"},
"before": integer("only records numbered below this: the next of the page before, to read on"),
"limit": map[string]any{"type": "integer", "minimum": 1, "maximum": MostListResult, "description": "at most this many rows (default 50)"},
}),
Run: func(m map[string]any) (any, error) {
a, err := readArgs("list", m, "kind", "status", "topic", "flag", "before", "limit")
if err != nil {
return nil, err
}
var ask ListAsk
if ask.Kind, err = a.str("kind"); err != nil {
return nil, err
}
if ask.Status, err = a.str("status"); err != nil {
return nil, err
}
if ask.Topic, err = a.str("topic"); err != nil {
return nil, err
}
if ask.Flag, err = a.str("flag"); err != nil {
return nil, err
}
if ask.Before, err = a.num("before", false); err != nil {
return nil, err
}
if ask.Limit, err = a.num("limit", false); err != nil {
return nil, err
}
return k.List(ask)
}},
{Name: Seat + ".holds",
Description: "The clauses in force now, for a topic of the reading order or for one record, each with the record it comes " +
"from; a clause changed in part says by what. Never a clause only drafted from prose: those are counted and not served. " +