write-report-json
Compile PR and issue metrics into a report.json file at /app/report.json using the required schema for the December community pulse write-up.
- License 许可
- MIT
- 最近更新
- 2026-10-02
- Stars
- ★ 93
- Forks
- 8
01 前言 Front Matter
- name
- write-report-json
- description
- Compile PR and issue metrics into a report.json file at /app/report.json using the required schema for the December community pulse write-up.
03 SKILL.md 正文
Writing report.json
After computing all metrics, write the result to /app/report.json.
Required JSON structure
{
"pr": {
"total": <int>,
"merged": <int>,
"closed": <int>,
"avg_merge_days": <float>,
"top_contributor": <str>
},
"issue": {
"total": <int>,
"bug": <int>,
"resolved_bugs": <int>
}
}
Full end-to-end script
#!/usr/bin/env python3
import json
import subprocess
from collections import Counter
from datetime import datetime, timezone
START = datetime(2024, 12, 1, tzinfo=timezone.utc)
END = datetime(2024, 12, 31, 23, 59, 59, tzinfo=timezone.utc)
def parse_dt(s):
return datetime.fromisoformat(s.replace("Z", "+00:00"))
def in_range(dt_str):
return START <= parse_dt(dt_str) <= END
# --- PRs ---
pr_result = subprocess.run([
"gh", "search", "prs",
"--repo", "cli/cli",
"--created", "2024-12-01..2024-12-31",
"--limit", "200",
"--json", "number,state,createdAt,mergedAt,closedAt,author"
], capture_output=True, text=True, check=True)
all_prs = json.loads(pr_result.stdout)
prs = [pr for pr in all_prs if in_range(pr["createdAt"])]
merged_prs = [pr for pr in prs if pr.get("mergedAt")]
closed_prs = [pr for pr in prs if pr["state"].lower() == "closed" and not pr.get("mergedAt")]
if merged_prs:
avg_merge_days = round(
sum(
(parse_dt(pr["mergedAt"]) - parse_dt(pr["createdAt"])).total_seconds() / 86400
for pr in merged_prs
) / len(merged_prs),
1
)
else:
avg_merge_days = 0.0
author_counts = Counter(
pr["author"]["login"] for pr in prs if pr.get("author")
)
top_contributor = author_counts.most_common(1)[0][0] if author_counts else ""
# --- Issues ---
issue_result = subprocess.run([
"gh", "search", "issues",
"--repo", "cli/cli",
"--created", "2024-12-01..2024-12-31",
"--limit", "200",
"--json", "number,state,createdAt,closedAt,labels"
], capture_output=True, text=True, check=True)
all_issues = json.loads(issue_result.stdout)
issues = [i for i in all_issues if in_range(i["createdAt"])]
def is_bug(issue):
return any("bug" in label["name"].lower() for label in issue.get("labels", []))
bug_issues = [i for i in issues if is_bug(i)]
resolved_bugs = [
i for i in bug_issues
if i.get("closedAt") and in_range(i["closedAt"])
]
# --- Report ---
report = {
"pr": {
"total": len(prs),
"merged": len(merged_prs),
"closed": len(closed_prs),
"avg_merge_days": avg_merge_days,
"top_contributor": top_contributor
},
"issue": {
"total": len(issues),
"bug": len(bug_issues),
"resolved_bugs": len(resolved_bugs)
}
}
with open("/app/report.json", "w") as f:
json.dump(report, f, indent=2)
print(json.dumps(report, indent=2))
Notes
- Always post-filter by
createdAtrange even when usinggh searchwith--created, as a safety net. resolved_bugscounts bug issues whoseclosedAtalso falls within December 2024.closedPRs are those withstate == "closed"and nomergedAt(i.e., not merged, just closed).
04 同仓库更多 Skills
object_counter
Count occurrences of an object in the image using computer vision algorithm.
travel-planning-workflow
Invoke this skill when performing travel planning. It defines a structured workflow for generating itineraries. Following this workflow is essential to ensure the final plan satisfies user requirements.
bundled-dataset-search-tool
invoke this skill when you need to perform database search for travel planning. This skill provides some useful pre-packaged tools to look up accommodations, attractions, cities, driving distance, flights, and restaurants from the bundled dataset.
glm-output
Output-processing guidance for GLM tasks. Especially useful after glm-basics and glm-calibration when you need verifier-matching metrics from output.nc and a final /root/metrics.json.
glm-calibration
Calibration guidance for GLM tasks. Often most effective after glm-basics has clarified the setup; glm-output is the companion skill for exact final metric computation.
glm-basics
A good starting point for GLM calibration tasks. Use to inspect glm3.nml, confirm how GLM runs, and identify the relevant files before moving on to calibration and output evaluation.