@@ -149,30 +149,44 @@ def test_update_concept_appends_source(self, tmp_path):
149149
150150
151151class TestUpdateIndex :
152- def test_appends_entries (self , tmp_path ):
152+ def test_appends_entries_with_briefs (self , tmp_path ):
153153 wiki = tmp_path / "wiki"
154154 wiki .mkdir ()
155155 (wiki / "index.md" ).write_text (
156156 "# Index\n \n ## Documents\n \n ## Concepts\n \n ## Explorations\n " ,
157157 encoding = "utf-8" ,
158158 )
159- _update_index (wiki , "my-doc" , ["attention" , "transformer" ])
159+ _update_index (wiki , "my-doc" , ["attention" , "transformer" ],
160+ doc_brief = "Introduces transformers" ,
161+ concept_briefs = {"attention" : "Focus mechanism" , "transformer" : "NN architecture" })
160162 text = (wiki / "index.md" ).read_text ()
161- assert "[[summaries/my-doc]]" in text
162- assert "[[concepts/attention]]" in text
163- assert "[[concepts/transformer]]" in text
163+ assert "[[summaries/my-doc]] — Introduces transformers " in text
164+ assert "[[concepts/attention]] — Focus mechanism " in text
165+ assert "[[concepts/transformer]] — NN architecture " in text
164166
165167 def test_no_duplicates (self , tmp_path ):
166168 wiki = tmp_path / "wiki"
167169 wiki .mkdir ()
168170 (wiki / "index.md" ).write_text (
169- "# Index\n \n ## Documents\n - [[summaries/my-doc]]\n \n ## Concepts\n " ,
171+ "# Index\n \n ## Documents\n - [[summaries/my-doc]] — Old brief \n \n ## Concepts\n " ,
170172 encoding = "utf-8" ,
171173 )
172- _update_index (wiki , "my-doc" , [])
174+ _update_index (wiki , "my-doc" , [], doc_brief = "New brief" )
173175 text = (wiki / "index.md" ).read_text ()
174176 assert text .count ("[[summaries/my-doc]]" ) == 1
175177
178+ def test_backwards_compat_no_briefs (self , tmp_path ):
179+ wiki = tmp_path / "wiki"
180+ wiki .mkdir ()
181+ (wiki / "index.md" ).write_text (
182+ "# Index\n \n ## Documents\n \n ## Concepts\n \n ## Explorations\n " ,
183+ encoding = "utf-8" ,
184+ )
185+ _update_index (wiki , "my-doc" , ["attention" ])
186+ text = (wiki / "index.md" ).read_text ()
187+ assert "[[summaries/my-doc]]" in text
188+ assert "[[concepts/attention]]" in text
189+
176190
177191class TestReadWikiContext :
178192 def test_empty_wiki (self , tmp_path ):
@@ -257,6 +271,28 @@ def test_sorted_alphabetically(self, tmp_path):
257271 slugs = [line .split (":" )[0 ].lstrip ("- " ) for line in lines ]
258272 assert slugs == ["apple" , "mango" , "zebra" ]
259273
274+ def test_reads_brief_from_frontmatter (self , tmp_path ):
275+ wiki = tmp_path / "wiki"
276+ concepts = wiki / "concepts"
277+ concepts .mkdir (parents = True )
278+ (concepts / "attention.md" ).write_text (
279+ "---\n sources: [paper.pdf]\n brief: Selective focus mechanism\n ---\n \n # Attention\n \n Long content..." ,
280+ encoding = "utf-8" ,
281+ )
282+ result = _read_concept_briefs (wiki )
283+ assert "- attention: Selective focus mechanism" in result
284+
285+ def test_falls_back_to_body_truncation (self , tmp_path ):
286+ wiki = tmp_path / "wiki"
287+ concepts = wiki / "concepts"
288+ concepts .mkdir (parents = True )
289+ (concepts / "old.md" ).write_text (
290+ "---\n sources: [paper.pdf]\n ---\n \n Old concept without brief field." ,
291+ encoding = "utf-8" ,
292+ )
293+ result = _read_concept_briefs (wiki )
294+ assert "- old: Old concept without brief field." in result
295+
260296
261297class TestBacklinkSummary :
262298 def test_adds_missing_concept_links (self , tmp_path ):
0 commit comments