MCPcopy Create free account
hub / github.com/OpenRaiser/PaperFlow / sync_reading_notes_github

Function sync_reading_notes_github

deployments/desktop/shared/agents.py:1587–1700  ·  view source on GitHub ↗
(user_id: str = "", response_language: str = "zh")

Source from the content-addressed store, hash-verified

1585 "model": getattr(provider, "model", "unknown"),
1586 "summary": str(getattr(response, "text", "") or "").strip(),
1587 }
1588 except Exception as exc:
1589 return {
1590 "enabled": True,
1591 "reviewed": False,
1592 "error": str(exc),
1593 "summary": f"LLM review failed: {exc}" if language == "en" else f"LLM 校对失败:{exc}",
1594 }
1595
1596
1597def sync_reading_notes_github(user_id: str = "", response_language: str = "zh") -> Dict[str, Any]:
1598 del user_id
1599 language = _normalize_response_language(response_language)
1600 repo_dir = _configured_reading_notes_git_dir()
1601 if repo_dir is None:
1602 raise ValueError(
1603 "Reading notes Git directory was not found. Configure PAPERFLOW_READING_NOTES_GIT_DIR in Settings."
1604 if language == "en"
1605 else "未找到阅读笔记 Git 目录,请在设置里配置 PAPERFLOW_READING_NOTES_GIT_DIR。"
1606 )
1607 repo_dir.mkdir(parents=True, exist_ok=True)
1608 branch = _configured_reading_notes_git_branch()
1609 remote_url = _notes_git_remote(repo_dir)
1610 if not remote_url:
1611 raise ValueError(
1612 "Reading notes GitHub remote is not configured. Configure PAPERFLOW_READING_NOTES_GIT_REMOTE in Settings."
1613 if language == "en"
1614 else "未配置阅读笔记 GitHub 远端,请在设置里配置 PAPERFLOW_READING_NOTES_GIT_REMOTE。"
1615 )
1616
1617 _ensure_notes_git_repo(repo_dir, remote_url, branch)
1618 _ensure_notes_gitignore(repo_dir)
1619
1620 pulled, remote_conflict_discarded, remote_first_message = _remote_first_sync_notes_worktree(repo_dir, branch, language)
1621 pull_warning = remote_first_message if remote_conflict_discarded else ""
1622
1623 _run_git(["add", "."], repo_dir)
1624 _guard_reading_notes_deletions(repo_dir, language)
1625 llm_review = _notes_llm_sync_review(
1626 repo_dir,
1627 branch,
1628 _env_bool("PAPERFLOW_READING_NOTES_GIT_LLM_REVIEW", default=True),
1629 response_language=language,
1630 )
1631 staged_status = _git_output(["status", "--short"], repo_dir)
1632 committed = False
1633 commit_hash = ""
1634 if staged_status:
1635 message = f"Sync PaperFlow reading notes {datetime.now().strftime('%Y-%m-%d %H:%M')}"
1636 _run_git(["commit", "-m", message], repo_dir, timeout=120)
1637 committed = True
1638 commit_hash = _git_output(["rev-parse", "--short", "HEAD"], repo_dir)
1639
1640 rebased = False
1641 rebase_output = ""
1642
1643 local_ahead, _remote_ahead = _git_ahead_behind(repo_dir, branch)
1644 pushed = False

Callers

nothing calls this directly

Calls 15

_notes_git_remoteFunction · 0.85
_ensure_notes_git_repoFunction · 0.85
_ensure_notes_gitignoreFunction · 0.85
_run_gitFunction · 0.85
_notes_llm_sync_reviewFunction · 0.85
_git_outputFunction · 0.85
_git_ahead_behindFunction · 0.85

Tested by

no test coverage detected