refactor: extract kb_framework package, build graph in memory

Scripts become thin CLIs over kb_framework (graph, query, query_tools,
vault, instructions) so the hosted read-only connector shares one
implementation with the stdio server. The MCP server builds the graph
from Markdown on demand and invalidates it on writes; refresh_graph
rebuilds in memory and reports validation problems. Pre-commit hook
validates only; index/graph.json is no longer read, written or staged
(generate-graph.py --write remains for operators). Golden fixtures pin
graph and tool payloads to the previous output. Agent and skill docs
updated to match.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
2026-10-06 20:40:13 +02:00
co-authored by Claude Fable 5.1
parent 4fec637599
commit 96780317a7
37 changed files with 1858 additions and 899 deletions
+8 -15
View File
@@ -40,9 +40,7 @@ class ToolTestCase(unittest.TestCase):
self._tmp = tempfile.TemporaryDirectory()
self.root = Path(self._tmp.name).resolve() / "vault"
self.root.mkdir()
self.state = mcp.AppState(
root=self.root, graph_path=self.root / "index" / "graph.json"
)
self.state = mcp.AppState(root=self.root)
_git(self.root, "init", "-q", "-b", "main")
_git(self.root, "config", "user.email", "test@example.com")
_git(self.root, "config", "user.name", "Test")
@@ -440,18 +438,13 @@ class TestGraphSummary(ToolTestCase):
"""
def write_graph(self, nodes: list) -> None:
self.state.graph_path.parent.mkdir(parents=True, exist_ok=True)
self.state.graph_path.write_text(
json.dumps(
{
"version": 1,
"generated_at": "2026-09-14T00:00:00Z",
"nodes": nodes,
"edges": [],
}
),
encoding="utf-8",
)
# The graph lives in memory; seed the cache the way a build would.
self.state.graph_cache = {
"version": 1,
"generated_at": "2026-09-14T00:00:00Z",
"nodes": nodes,
"edges": [],
}
def node(self, node_id: str, **fields) -> dict:
base = {