|
18 | 18 | if str(_root) not in sys.path: |
19 | 19 | sys.path.insert(0, str(_root)) |
20 | 20 |
|
21 | | -from utils.cursor_md_exporter import cursor_cli_session_to_markdown |
| 21 | +from utils.cursor_md_exporter import ( |
| 22 | + _build_ide_session_summary, |
| 23 | + cursor_cli_session_to_markdown, |
| 24 | +) |
22 | 25 |
|
23 | 26 |
|
24 | 27 | def _make_meta_hex(meta: dict) -> str: |
@@ -241,6 +244,43 @@ def test_title_quoting_with_special_chars(self): |
241 | 244 | # Frontmatter title must have embedded quotes escaped as \" |
242 | 245 | self.assertIn('title: "He said \\"hello\\""', result) |
243 | 246 |
|
| 247 | + def test_non_dict_meta_json_falls_back_to_empty_mapping(self): |
| 248 | + """List/scalar meta JSON must not crash; agentId falls back to parent dir name.""" |
| 249 | + db_path = self._db_path("scalar-meta") |
| 250 | + os.makedirs(os.path.dirname(db_path), exist_ok=True) |
| 251 | + conn = sqlite3.connect(db_path) |
| 252 | + conn.execute("CREATE TABLE meta (key TEXT PRIMARY KEY, value TEXT)") |
| 253 | + conn.execute("CREATE TABLE blobs (id TEXT PRIMARY KEY, data BLOB)") |
| 254 | + conn.execute( |
| 255 | + "INSERT INTO meta VALUES ('0', ?)", |
| 256 | + (json.dumps(["not", "a", "dict"]).encode("utf-8").hex(),), |
| 257 | + ) |
| 258 | + conn.commit() |
| 259 | + conn.close() |
| 260 | + |
| 261 | + result = cursor_cli_session_to_markdown(db_path) |
| 262 | + self.assertIn(f'log_id: "{Path(db_path).parent.name}"', result) |
| 263 | + self.assertIn("log_type: cli_agent", result) |
| 264 | + |
| 265 | + def test_web_only_tool_stats_produce_session_summary(self): |
| 266 | + """Search/web-only sessions still get a Tool Results summary block.""" |
| 267 | + summary = _build_ide_session_summary( |
| 268 | + [], |
| 269 | + [], |
| 270 | + [], |
| 271 | + { |
| 272 | + "terminal_success": 0, |
| 273 | + "terminal_error": 0, |
| 274 | + "file_reads": 0, |
| 275 | + "file_edits": 0, |
| 276 | + "searches": 0, |
| 277 | + "web": 2, |
| 278 | + }, |
| 279 | + ) |
| 280 | + self.assertIn("## Session Summary", summary) |
| 281 | + self.assertIn("### Tool Results", summary) |
| 282 | + self.assertIn("Web Fetches: 2", summary) |
| 283 | + |
244 | 284 |
|
245 | 285 | if __name__ == "__main__": |
246 | 286 | unittest.main() |
0 commit comments