AstroResearch/scratch/test_size.py
Asfmq 0ba85d7749 refactor: Prettier 格式化全量前端、Library 服务端分页筛选、Agent 工具输出可视化与 .agent 目录统一
代码质量:
  - 新增 .prettierrc + eslint-plugin-prettier,全量格式化所有 TSX/TS/CSS 文件
  - npm scripts 新增 format / format:check / lint:fix

  Logo 重设计:
  - SVG logo 从简单星月改为望远镜+轨道+三角架+星光,favicon 同步更新

  Library 服务端分页与多维筛选:
  - LibraryQueryParams 支持 q(全局搜索)/status(下载状态)/doctype/author/year/journal/sort_by
  - API 返回 {items, total},默认每页 12 条
  - 前端新增筛选面板:搜索栏、状态下拉、文献类型、排序、分页控件

  Agent 工具输出可视化:
  - 新增 SpecialToolRenderers.tsx:query_target 天体参数卡片(含 SIMBAD/VizieR 链接)、search_papers
  文献列表(内嵌下载/阅读/星系跳转按钮)
  - 系统内部工具(compress_context 等)无错误时自动隐藏,减少时间线噪音
  - ToolCallCard 与 Reader/Citation 打通:可在工具输出中直接打开文献或跳转引用星系

  .agent 目录统一:
  - memory/tool-results/trajectories/images 全部归入 library/.agent/ 子目录

  PDF 加载修复:
  - BilingualViewer 改用 fetch → blob:// URL 加载 PDF,绕过 iframe SameSite Cookie 限制
2026-07-03 00:11:02 +08:00

41 lines
1.6 KiB
Python

import sqlite3
import json
conn = sqlite3.connect('./library/astro_research.db')
cursor = conn.cursor()
cursor.execute("SELECT bibcode, title, authors, year, pub, keywords, abstract, doi, arxiv_id, citation_count, reference_count, pdf_path, html_path, markdown_path, translation_path, doctype FROM papers ORDER BY created_at DESC LIMIT 2000")
rows = cursor.fetchall()
columns = [c[0] for c in cursor.description]
data = []
for r in rows:
row_dict = dict(zip(columns, r))
# Parse JSON strings
try:
row_dict['authors'] = json.loads(row_dict['authors']) if row_dict['authors'] else []
except:
row_dict['authors'] = []
try:
row_dict['keywords'] = json.loads(row_dict['keywords']) if row_dict['keywords'] else []
except:
row_dict['keywords'] = []
# map database fields to StandardPaper
row_dict['pub_journal'] = row_dict.pop('pub')
row_dict['abstract_text'] = row_dict.pop('abstract')
row_dict['is_downloaded'] = bool(row_dict['pdf_path'] or row_dict['html_path'])
row_dict['has_pdf'] = bool(row_dict['pdf_path'])
row_dict['has_html'] = bool(row_dict['html_path'])
row_dict['has_markdown'] = bool(row_dict['markdown_path'])
row_dict['has_translation'] = bool(row_dict['translation_path'])
row_dict['has_vector'] = False # placeholder
row_dict['pdf_error'] = None
row_dict['html_error'] = None
data.append(row_dict)
json_str = json.dumps(data, ensure_ascii=False)
print("Row count:", len(data))
print("Total JSON bytes:", len(json_str.encode('utf-8')))
print("Avg bytes per row:", len(json_str.encode('utf-8')) / len(data))
conn.close()