mirror of
https://github.com/Ar9av/obsidian-wiki.git
synced 2026-09-14 20:36:34 +08:00
4bf87a8d19
Two strands of work. Session brain — a topic graph over raw agent session history, so you can find the session where something happened instead of remembering its UUID. Reads every Claude transcript plus the pruned sessions that survive only as prompts in history.jsonl, clusters them with local TF-IDF and community detection (no embeddings, no API calls, no new dependencies), and writes a sidecar at ~/.claude/session-brain/ — the vault is never touched. Ships five modules, the sessions-* CLI commands, an interactive graph.html, and the /session-brain and /wiki-sessions skills. This is retrieval, deliberately distinct from wiki-history-ingest, which distils sessions into permanent vault pages. Docs — README.md was 598 lines and put trust-check flags and a 17-row agent matrix in front of anyone evaluating the project. Cut it to a 129- line landing page (problem statement, 60-second install, four blocks of runnable commands, graph screenshot, why-not-a-notes-folder) and move the reference material into docs/: installation, agents, skills, cli, configuration, architecture, session-brain, contributing. README_TW.md mirrors the new structure; docs/ stays English-only for now. The restructure also closed real drift: - Ten skills existed but appeared in no reference — session-brain, session-search, wiki-dedup, wiki-digest, wiki-import, wiki-context-pack, wiki-stage-commit, wiki-switch, vault-skill-factory, and obsidian-layout-adjustment. - SETUP.md listed 12 of 39 skills and still claimed "no scripts, no dependencies" despite the pip package. It is now a signpost into docs/. - Eight config variables were undocumented anywhere, including WIKI_STAGED_WRITES, which wiki-setup prompts for and three skills read. Added to .env.example and docs/configuration.md. - sessions-name and a number of CLI flags were missing from the docs. Two details worth noting. README links are absolute GitHub URLs because pyproject sets readme = "README.md" as the PyPI long_description, and PyPI resolves relative hrefs against pypi.org rather than the repo — docs/ links would have 404'd on the package page. And three doc-drift guards asserted their facts against README.md; since those facts moved rather than disappeared, the assertions were repointed at the page that now owns each one instead of padding content back into the README. Also gitignore /vault/ (a local knowledge vault, not a fixture) and the packed browser extension. Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
56 lines
2.0 KiB
Python
56 lines
2.0 KiB
Python
from __future__ import annotations
|
|
|
|
from pathlib import Path
|
|
import re
|
|
import unittest
|
|
|
|
|
|
ROOT = Path(__file__).resolve().parents[1]
|
|
|
|
|
|
class WikiNarrateDocsTest(unittest.TestCase):
|
|
def read(self, relpath: str) -> str:
|
|
return (ROOT / relpath).read_text()
|
|
|
|
def test_skill_declares_the_canonical_command_and_voices(self) -> None:
|
|
skill = self.read(".skills/wiki-narrate/SKILL.md")
|
|
|
|
self.assertIn("/wiki-narrate <topic> [--voice briefing|plain-language|lecturer] [--save]", skill)
|
|
self.assertIn("default voice is `briefing`", skill)
|
|
self.assertIn("case-sensitive", skill)
|
|
self.assertIn("Unsupported values", skill)
|
|
|
|
def test_skill_requires_closed_set_citations(self) -> None:
|
|
skill = self.read(".skills/wiki-narrate/SKILL.md")
|
|
|
|
self.assertIn("every factual sentence", skill)
|
|
self.assertIn("^[inferred]", skill)
|
|
self.assertIn("^[ambiguous]", skill)
|
|
self.assertIn("web knowledge", skill)
|
|
self.assertIn("model memory", skill)
|
|
|
|
def test_skill_keeps_readouts_out_of_the_knowledge_graph(self) -> None:
|
|
skill = self.read(".skills/wiki-narrate/SKILL.md")
|
|
|
|
self.assertIn("`_readouts/<slug>.md`", skill)
|
|
self.assertIn("must not update `index.md` or `.manifest.json`", skill)
|
|
self.assertIn("exclude `_readouts/`", skill)
|
|
|
|
def test_voice_reference_has_exactly_the_three_first_release_voices(self) -> None:
|
|
voices = self.read(".skills/wiki-narrate/references/voices.md")
|
|
|
|
headings = set(re.findall(r"^## `([^`]+)`$", voices, flags=re.MULTILINE))
|
|
self.assertEqual(headings, {"briefing", "plain-language", "lecturer"})
|
|
|
|
def test_routing_and_skills_reference_expose_wiki_narrate(self) -> None:
|
|
agents = self.read("AGENTS.md")
|
|
skills = self.read("docs/skills.md")
|
|
|
|
self.assertIn("`wiki-narrate`", agents)
|
|
self.assertIn("`wiki-narrate`", skills)
|
|
self.assertIn("`/wiki-narrate <topic>`", skills)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
unittest.main()
|