Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions src/paperbot/agents/code_analysis/agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ async def process(self, *args, **kwargs) -> Dict[str, Any]:
# 如果是单仓库模式,尝试返回扁平化结果适配 Coordinator
if "repo_url" in kwargs and result['analysis_results']:
repo_result = result['analysis_results'][0]
if repo_result.get("placeholder"):
return repo_result
return self._flatten_result(repo_result)

return result
Expand All @@ -64,7 +66,8 @@ def _flatten_result(self, repo_result: Dict[str, Any]) -> Dict[str, Any]:
"stars": meta.get("stars"),
"forks": meta.get("forks"),
"language": structure.get('primary_language', 'Unknown'),
"updated_at": meta.get("last_commit_at"),
"updated_at": meta.get("updated_at") or meta.get("last_commit_at"),
"last_commit_date": meta.get("last_commit_date") or meta.get("last_commit_at"),
"has_readme": structure.get('documentation', {}).get('has_readme', False),
"reproducibility_score": quality.get('overall_score', 0) * 100,
"quality_notes": str(quality.get('recommendations', [])),
Expand Down Expand Up @@ -125,6 +128,7 @@ def _placeholder(self, repo_url: Optional[str], reason: str) -> Dict[str, Any]:
"forks": None,
"language": None,
"updated_at": None,
"last_commit_date": None,
"has_readme": False,
"reproducibility_score": None,
"quality_notes": f"Repository unavailable: {reason}",
Expand Down Expand Up @@ -226,6 +230,7 @@ def _extract_repo_meta(self, repo_path: Path, repo_url: str) -> Dict[str, Any]:
last_commit = next(repo.iter_commits(max_count=1), None)
if last_commit:
meta["last_commit_at"] = last_commit.committed_datetime.isoformat()
meta["last_commit_date"] = meta["last_commit_at"]
except Exception as e:
self.log_error(e, {"repo_meta": "commit_time"})

Expand All @@ -245,8 +250,8 @@ def _extract_repo_meta(self, repo_path: Path, repo_url: str) -> Dict[str, Any]:
data = resp.json()
meta["stars"] = data.get("stargazers_count")
meta["forks"] = data.get("forks_count")
meta["updated_at"] = data.get("updated_at")
except Exception as e:
self.log_error(e, {"repo_meta": "github_api"})

return meta

Loading
Loading