Compare commits

..

8 Commits

Author SHA1 Message Date
赵昌 c5f892bc92 feat: CI 检查改用本地编译验证,无需外部流水线
- 新增 03-local-ci-check.sh:运行 go build 验证代码可编译
- 质量门禁恢复为 4 阶段:PR采集 → 审查 → 本地CI → 决策
- 评分模型:CodeReview×40% + 本地CI×30% + 设计一致性×30%

Co-Authored-By: Claude <noreply@anthropic.com>
2026-07-07 18:34:09 +08:00
赵昌 4d6f224bc4 refactor: 质量门禁简化为三阶段,移除 CI 检查 2026-07-07 18:28:42 +08:00
赵昌 7bde356bac fix: CI 不可用时自动跳过并重新分配权重
CI 检测依赖 DevOps API 但该 API 未完整实现。
当 CI 状态为 unknown 时:
- 自动跳过 CI 权重(原30%分配到 CodeReview 和设计一致性)
- 临时门槛降至 60 分
- 不再阻塞整个门禁流程

Co-Authored-By: Claude <noreply@anthropic.com>
2026-07-07 18:24:22 +08:00
赵昌 ed89db94a0 feat: 质量门禁添加 CI_CONFIRMED 手动确认选项
由于 DevOps/建木 API 未在 CLI 中完整实现,自动 CI 检测无法获取流水线状态。
添加 CI_CONFIRMED=true 环境变量,允许用户手动确认 CI 已通过。:

Co-Authored-By: Claude <noreply@anthropic.com>
2026-07-07 18:20:11 +08:00
赵昌 608fc70831 fix: CI 检测增加 DevOps API 尝试和详细提示
- 先查 Actions API(ci +builds)
- 再查 DevOps API(ci +run-results)
- 全部失败时提示:DevOps/建木引擎的 API 未在 CLI 中完整实现
2026-07-07 17:49:23 +08:00
赵昌 8589eb9280 fix: ci +builds API 路径错误 2026-07-07 17:32:09 +08:00
赵昌 40609fa0f8 fix: CI 状态检测改为读取状态文件,不再硬编码为通过 2026-07-07 17:03:14 +08:00
赵昌 3a1565422c fix: PR 状态字段匹配和 MSYS 路径问题
- 01-collect-prs.sh: 修复 PR 过滤逻辑,兼容 status='open' 字符串
- quality-gate-full.sh: 使用相对路径避免 MSYS 路径问题

Co-Authored-By: Claude <noreply@anthropic.com>
2026-07-07 16:55:48 +08:00
18 changed files with 206 additions and 287 deletions

View File

@ -0,0 +1,55 @@
version: 2
name: 代码质量门禁流水线
description: "PR 触发:代码审查 → CI 检查 → 门禁决策 → 自动合并或反馈"
trigger:
webhook: gitlink@1.0.0
event:
- ref: pull_request
ruleset-operator: AND
global:
concurrent: 1
param:
- ref: remote_url
name: ""
value: '"https://gitlink.org.cn/z2_cc/gitlink-cli.git"'
required: false
type: STRING
hidden: false
- ref: owner
name: "仓库所有者"
value: '"z2_cc"'
required: true
type: STRING
hidden: false
- ref: repo
name: "仓库名称"
value: '"gitlink-cli"'
required: true
type: STRING
hidden: false
- ref: dry_run
name: "Dry-Run 模式"
value: '"true"'
required: false
type: STRING
hidden: false
workflow:
- ref: start
name: 开始
task: start
- ref: ssh_cmd_0
name: 运行代码质量门禁
task: ssh_cmd@1.1.1
input:
ssh_pass: ((work_together.ssh_key))
ssh_ip: '"121.41.216.243"'
ssh_port: '"22"'
ssh_user: '"root"'
ssh_cmd: '"cd /root/gitlink-cli && git pull origin master && DRY_RUN=$(dry_run) bash skills/gitlink-quality-gate/scripts/quality-gate-full.sh z2_cc gitlink-cli"'
needs:
- start
- ref: end
name: 结束
task: end
needs:
- ssh_cmd_0

View File

@ -1,6 +1,6 @@
version: 2
name: 构建流水线
description: "gitlink-cli CI 流水线:拉取代码、构建、部署、验证"
description: "gitlink-cli CI 流水线:拉取代码、构建、验证 + 社区运营定时任务"
trigger:
webhook: gitlink@1.0.0
event:
@ -20,14 +20,14 @@ workflow:
name: 开始
task: start
- ref: ssh_cmd_0
name: 拉取代码并构建部署
name: 拉取代码并构建验证
task: ssh_cmd@1.1.1
input:
ssh_pass: ((work_together.ssh_key))
ssh_ip: '"121.41.216.243"'
ssh_port: '"22"'
ssh_user: '"root"'
ssh_cmd: '"export GOPROXY=https://goproxy.cn,direct && cd /root/gitlink-cli || git clone https://gitlink.org.cn/z2_cc/gitlink-cli.git /root/gitlink-cli; cd /root/gitlink-cli && git pull origin master && go build -o gitlink-cli . && cp gitlink-cli /usr/local/bin/ && gitlink-cli version"'
ssh_cmd: '"export GOPROXY=https://goproxy.cn,direct && cd /root/gitlink-cli || git clone https://gitlink.org.cn/z2_cc/gitlink-cli.git /root/gitlink-cli; cd /root/gitlink-cli && git pull origin master && go build -o gitlink-cli . && ./gitlink-cli version"'
needs:
- start
- ref: end

View File

@ -0,0 +1,49 @@
version: 2
name: 社区运营流水线
description: "每周定时运行Issue 分拣 → 健康报告 → Release Notes"
trigger:
webhook: gitlink@1.0.0
event:
- ref: schedule
ruleset-operator: AND
global:
concurrent: 1
param:
- ref: remote_url
name: ""
value: '"https://gitlink.org.cn/z2_cc/gitlink-cli.git"'
required: false
type: STRING
hidden: false
- ref: owner
name: "仓库所有者"
value: '"z2_cc"'
required: true
type: STRING
hidden: false
- ref: repo
name: "仓库名称"
value: '"gitlink-cli"'
required: true
type: STRING
hidden: false
workflow:
- ref: start
name: 开始
task: start
- ref: ssh_cmd_0
name: 运行社区运营自动化流水线
task: ssh_cmd@1.1.1
input:
ssh_pass: ((work_together.ssh_key))
ssh_ip: '"121.41.216.243"'
ssh_port: '"22"'
ssh_user: '"root"'
ssh_cmd: '"cd /root/gitlink-cli && git pull origin master && DRY_RUN=true bash skills/gitlink-community-ops/scripts/community-ops-full.sh z2_cc gitlink-cli"'
needs:
- start
- ref: end
name: 结束
task: end
needs:
- ssh_cmd_0

View File

@ -1,116 +0,0 @@
# 变更说明汇总
> 本文件汇总 GitLink CLI 智能化能力提升项目所有变更,按子任务分类。
> 最后更新2026-07-07
---
## 子任务一CLI 能力扩展
### 新增 Shortcut 命令组
在原有 10 个命令组branch/ci/common/issue/org/pr/release/repo/search/user基础上新增 13 个命令组:
| 命令组 | 子命令数 | 代码行数 | 单元测试 | 作者 | 说明 |
|--------|---------|---------|---------|------|------|
| webhook | 20 | 533 | ✅ | Mengz | Webhook 管理(增删改查+测试) |
| wiki | 13 | 555 | ✅ | 赵昌 | 仓库 Wiki 页面管理 |
| snippet | 9 | 271 | ✅ | 赵昌 | 代码片段管理 |
| file | 18 | 490 | ❌ | 刘焱 | 文件管理(上传/下载/批量推送) |
| collaborator | 13 | 69 | ✅ | 刘焱 | 协作者管理 |
| milestone | 14 | 224 | ❌ | 刘焱 | 里程碑管理 |
| commit | 13 | 172 | ❌ | 刘焱 | 提交记录查询 |
| template | 10 | 150 | ❌ | 刘焱 | 模板管理(导入/导出) |
| label | 11 | 218 | ❌ | 刘焱 | 标签管理 |
| dataset | 9 | 123 | ❌ | 刘焱 | 数据集管理 |
| tag | 7 | 138 | ✅ | 刘焱 | 标签Release Tag管理 |
| sshkey | 8 | 96 | ❌ | 刘焱 | SSH 公钥管理 |
| attachment | 4 | 53 | ❌ | 刘焱 | 附件管理 |
| util | 3 | 46 | ❌ | 刘焱 | 通用工具函数 |
**合计**:新增 149 个子命令,约 3000 行 Go 代码6 个命令组配有单元测试。
### 已有命令组扩展
对原有命令组也进行了功能增强:
- `ci` — 新增 save-yaml、run-pipeline、delete-pipeline 等 DevOps 流水线管理命令
- `pr` — 新增 batch-merge、batch-close、version-diff、versions 等批量操作命令
- `issue` — 新增 batch-update 批量更新命令
- `repo` — 新增 code-stats、contributors-stat 等统计分析命令
详细变更说明:[webhook-shortcut.md](./webhook-shortcut.md)
---
## 子任务二AI Agent Skills
### 新增 Skills
在原有 Skills 基础上,团队新增 16 个自定义 Skill
| Skill | 作者 | 说明 |
|-------|------|------|
| gitlink-community-ops | 赵昌 | 社区运营自动化Issue 分拣→周报→Release Notes |
| gitlink-quality-gate | 赵昌 | 代码质量门禁PR 审查→CI 检查→门禁决策) |
| gitlink-project-health | 赵昌 | 项目健康度分析 |
| gitlink-issue-triage | 赵昌 | Issue 自动分拣 |
| gitlink-newcomer-guide | 赵昌 | 新人引导 |
| gitlink-pr-deep-review | 赵昌 | PR 深度审查 |
| gitlink-research-hotspot | 赵昌 | 科研热点追踪与知识图谱 |
| gitlink-research-insight | 赵昌 | 科研项目洞悉 |
| gitlink-snippet | 赵昌 | 代码片段 Skill |
| gitlink-wiki | 赵昌 | Wiki 管理 Skill |
| gitlink-contributor-growth | 刘焱 | 贡献者成长体系 |
| gitlink-multi-repo-coordination | 刘焱 | 多仓库协同 |
| gitlink-project-bootstrap | 刘焱 | 项目一键初始化 |
| gitlink-research-compliance | 曾蔚然 | 科研合规与复现性 |
| gitlink-research-matching | 曾蔚然 | 科研协作智能匹配 |
| gitlink-research-progress | 曾蔚然 | 科研进度跟踪与预警 |
每个 Skill 包含:`SKILL.md`(命令参考)+ `examples/`(使用示例)+ `scripts/`(可复现脚本)。
---
## 子任务三:端到端自动化工作流
5 个端到端场景,统一采用"三阶段脚本 + JS 分析引擎"架构:
| 场景 | 串联脚本 | 分析引擎 | 作者 |
|------|---------|---------|------|
| 社区运营自动化 | community-ops-full.sh | health-analyze.js | 赵昌 |
| 代码质量门禁 | quality-gate-full.sh | scoring-engine.js | 赵昌 |
| 项目一键初始化 | project-bootstrap-full.sh | skeleton-gen.js | 刘焱 |
| 多仓库协同 | multi-repo-full.sh | dashboard-gen.js | 刘焱 |
| 贡献者成长体系 | contributor-growth-full.sh | growth-analyze.js | 刘焱 |
---
## 子任务四:科研辅助模块
5 大科研辅助模块,覆盖科研全生命周期:
| 模块 | Skill | 功能 |
|------|-------|------|
| 科研项目洞悉 | gitlink-research-insight | 8 维数据采集 + 4 维评分 |
| 热点追踪与知识图谱 | gitlink-research-hotspot | 多关键词搜索 + 实体关系图谱 |
| 科研合规与复现性 | gitlink-research-compliance | 三维复现性证据链 |
| 科研协作智能匹配 | gitlink-research-matching | 角色匹配 + 缺口识别 |
| 科研进度跟踪与预警 | gitlink-research-progress | 6 维动态风险信号 |
---
## DevOps 流水线
1 条已部署的建木流水线push 代码时自动触发集成和部署:
| 流水线 | 触发方式 | 功能 | 文件 |
|--------|---------|------|------|
| 构建流水线 | push | 拉取代码 → 编译 → 部署到 /usr/local/bin → 验证 | `.devops/构建流水线.yml` |
另有 3 条流水线 YAML 配置已提交到仓库但未部署(项目初始化、多仓库协同、贡献者成长)。
---
## 操作中心
新增 `/gitlink` 斜杠命令作为统一入口16 项操作上下选择执行。配置文件:`.claude/commands/gitlink.md`

Binary file not shown.

View File

@ -1,7 +1,7 @@
# 端到端工作流说明文档
> 子任务三 · 5 个端到端自动化场景
> 最后更新2026-07-07
> 最后更新2026-07-04
## 一、总体架构
@ -12,7 +12,7 @@
```
┌─────────────────────────────────────────────────────────┐
│ DevOps 流水线层 │
│ (1 条已部署 · push 触发)
│ (6 条建木 YAML · push/PR/定时/手动触发)
├─────────────────────────────────────────────────────────┤
│ 端到端编排层 │
│ community-ops / quality-gate / project-bootstrap / │
@ -86,6 +86,7 @@ community-ops-full.sh z2_cc gitlink-cli
- `skills/gitlink-community-ops/SKILL.md` — 设计规格
- `skills/gitlink-community-ops/scripts/community-ops-full.sh` — 串联脚本
- `skills/gitlink-community-ops/scripts/health-analyze.js` — 分析引擎
- `.devops/社区运营流水线.yml` — DevOps 配置(定时触发)
## 三、场景二:代码质量门禁
@ -103,8 +104,8 @@ quality-gate-full.sh z2_cc gitlink-cli
│ ├── Critical / Warning / Suggestion 三级
│ └── CodeReview 评分: 100 - Critical×20 - Warning×10 - Suggestion×3
├── Phase 3: 本地 CI 检查 (03-local-ci-check.sh)
│ ├── 本地 go build 编译验证
├── Phase 3: CI 检查 (03-ci-check.sh)
│ ├── 构建状态
│ ├── 测试覆盖率
│ └── CI 评分: 全通过=100, 有失败=0一票否决
@ -125,8 +126,8 @@ quality-gate-full.sh z2_cc gitlink-cli
### 3.3 对应文件
- `skills/gitlink-quality-gate/SKILL.md`
- `skills/gitlink-quality-gate/scripts/quality-gate-full.sh`80 行)
- `skills/gitlink-quality-gate/scripts/03-local-ci-check.sh` — 本地 CI 检查
- `skills/gitlink-quality-gate/scripts/quality-gate-full.sh`378 行)
- `.devops/代码质量门禁流水线.yml`PR 触发)
## 四、场景三:项目一键初始化
@ -157,7 +158,7 @@ project-bootstrap-full.sh
### 4.2 对应文件
- `skills/gitlink-project-bootstrap/SKILL.md`
- `skills/gitlink-project-bootstrap/scripts/project-bootstrap-full.sh`61 行)
- `skills/gitlink-project-bootstrap/scripts/project-bootstrap-full.sh`601 行)
- `skills/gitlink-project-bootstrap/scripts/skeleton-gen.js` — 骨架生成引擎
- `.devops/项目初始化流水线.yml`(手动触发)
@ -188,7 +189,7 @@ multi-repo-full.sh
### 5.2 对应文件
- `skills/gitlink-multi-repo-coordination/SKILL.md`
- `skills/gitlink-multi-repo-coordination/scripts/multi-repo-full.sh`70 行)
- `skills/gitlink-multi-repo-coordination/scripts/multi-repo-full.sh`560 行)
- `skills/gitlink-multi-repo-coordination/scripts/dashboard-gen.js` — 看板引擎
- `.devops/多仓库协同流水线.yml`(手动触发)
@ -228,30 +229,21 @@ contributor-growth-full.sh z2_cc gitlink-cli
### 6.3 对应文件
- `skills/gitlink-contributor-growth/SKILL.md`
- `skills/gitlink-contributor-growth/scripts/contributor-growth-full.sh`56 行)
- `skills/gitlink-contributor-growth/scripts/contributor-growth-full.sh`642 行)
- `skills/gitlink-contributor-growth/scripts/growth-analyze.js` — 分析引擎
- `.devops/贡献者成长体系流水线.yml`(定时触发)
## 七、DevOps 流水线
### 7.1 已部署流水线
| 流水线 | 触发方式 | 功能 | 文件 |
|--------|----------|------|------|
| 构建流水线 | push | 拉取代码 → 编译 → 部署到 /usr/local/bin → 验证 | `.devops/构建流水线.yml` |
该流水线已在 GitLink DevOps 平台部署并成功运行push 代码时自动触发集成和部署。
### 7.2 流水线 YAML 配置(未部署)
以下 YAML 配置文件已提交到仓库,但尚未在建木平台部署:
## 七、DevOps 流水线总览
| 流水线 | 触发方式 | 对应场景 | 文件 |
|--------|----------|----------|------|
| 项目初始化 | 手动 | 场景三 | `.devops/项目初始化流水线.yml` |
| 多仓库协同 | 手动 | 场景四 | `.devops/多仓库协同流水线.yml` |
| 贡献者成长 | 定时 | 场景五 | `.devops/贡献者成长体系流水线.yml` |
| 构建流水线 | push | CLI 编译验证 | 构建流水线.yml |
| 代码质量门禁 | PR | 场景二 | 代码质量门禁流水线.yml |
| 社区运营 | 定时 | 场景一 | 社区运营流水线.yml |
| 项目初始化 | 手动 | 场景三 | 项目初始化流水线.yml |
| 多仓库协同 | 手动 | 场景四 | 多仓库协同流水线.yml |
| 贡献者成长 | 定时 | 场景五 | 贡献者成长体系流水线.yml |
社区运营(场景一)和代码质量门禁(场景二)通过手动执行脚本运行。所有流水线配置 DRY_RUN 默认安全模式SSH 密钥用 `((work_together.ssh_key))` 密文引用。
所有流水线配置 DRY_RUN 默认安全模式SSH 密钥用 `((work_together.ssh_key))` 密文引用,可在 GitLink DevOps 平台一键复现。
— 文档完 —

Binary file not shown.

Binary file not shown.

View File

@ -7,15 +7,7 @@
# ================================================================
set -e
# 使用本地编译的 gitlink-cli支持完整命令
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
LOCAL_CLI="$(cd "$SCRIPT_DIR/../../.." && pwd)/gitlink-cli.exe"
if [ -f "$LOCAL_CLI" ]; then
CLI="$LOCAL_CLI"
else
CLI="gitlink-cli"
fi
# ---- 参数解析 ----
OWNER=${1:?"Usage: $0 <owner> <repo>"}
REPO=${2}
DRY_RUN=${DRY_RUN:-true}
@ -29,14 +21,15 @@ echo "[ Target: $OWNER/$REPO ]"
echo "[ DRY_RUN: $DRY_RUN ]"
echo "[========================================]"
# Step 1: 获取所有打开的 Issue
# ---- Step 1: 获取所有打开的 Issue ----
echo "[INFO] 获取所有打开的 Issue..."
ISSUES=$($CLI issue +list --owner "$OWNER" --repo "$REPO" --state open --format json 2>&1) || {
ISSUES=$(gitlink-cli issue +list --owner "$OWNER" --repo "$REPO" --state open --format json 2>&1) || {
echo "[ERROR] 获取 Issue 列表失败: $ISSUES"
exit 1
}
echo "$ISSUES" > "$OUTPUT_DIR/issues-open.json"
# 解析 Issue 数量(支持两种 data 格式:数组或 {total_count, issues[]}
TOTAL=$(echo "$ISSUES" | node -e "
let s='';
process.stdin.on('data',d=>s+=d).on('end',()=>{
@ -47,22 +40,25 @@ TOTAL=$(echo "$ISSUES" | node -e "
" 2>/dev/null || echo "0")
echo "[INFO] 发现 $TOTAL 个待处理的 Issue"
if [ "$TOTAL" -eq 0 ]; then
echo "[INFO] 没有待处理的 Issue跳过"
exit 0
fi
# Step 2: 获取可用标签
# ---- Step 2: 获取可用标签 ----
echo "[INFO] 获取可用标签列表..."
LABELS=$($CLI label +list --owner "$OWNER" --repo "$REPO" --format json 2>&1) || {
echo "[WARN] 获取标签列表失败"
LABELS=$(gitlink-cli label +list --owner "$OWNER" --repo "$REPO" --format json 2>&1) || {
echo "[WARN] 获取标签列表失败,使用默认标签: $LABELS"
LABELS='{"data":[]}'
}
echo "$LABELS" > "$OUTPUT_DIR/labels.json"
# Step 3: 逐 Issue 分析
# ---- Step 3: 逐 Issue 分析 ----
echo "[INFO] 开始分析每个 Issue..."
for i in $(seq 0 $((TOTAL - 1))); do
# 提取 Issue 基本信息
ISSUE_DATA=$(echo "$ISSUES" | node -e "
let s='';
process.stdin.on('data',d=>s+=d).on('end',()=>{
@ -83,52 +79,35 @@ for i in $(seq 0 $((TOTAL - 1))); do
echo ""
echo "[INFO] --- Issue #$NUMBER: $SUBJECT ---"
# 获取 Issue 详情
DETAIL=$($CLI issue +view --owner "$OWNER" --repo "$REPO" --number "$NUMBER" --format json 2>&1) || {
# 获取 Issue 详情(含 description
DETAIL=$(gitlink-cli issue +view --owner "$OWNER" --repo "$REPO" --number "$NUMBER" --format json 2>&1) || {
echo "[WARN] 获取 Issue #$NUMBER 详情失败,使用标题分析"
DETAIL="{\"data\":{\"subject\":\"$SUBJECT\",\"description\":\"\"}}"
}
echo "$DETAIL" > "$OUTPUT_DIR/issue-$NUMBER-detail.json"
# ---- Step 4: 关键词权重分析(自动分类) ----
# ---- 关键词权重分析AI 在此处执行) ----
# AI Agent 读取 title + description按权重矩阵计算分类得分
# 注意:以下分析由 AI 在运行脚本时根据实际内容进行
echo "[INFO] AI 分析中...(关键词权重评分)"
echo "[INFO] 分析依据gitlink-issue-triage/SKILL.md 权重分类矩阵"
echo "[INFO] 参考命令issue +view -> labels -> issue +update + issue +comment"
# 生成分类建议占位AI 在实际运行时填入)
CATEGORY="needs-triage"
LABEL_ID=""
LABEL_NAME=""
COMMENT_TEXT=""
URGENCY="P3"
COMMENT_BODY=""
# 简单关键词匹配
case "$SUBJECT" in
*[Bb]ug*|*错误*|*失败*|*异常*|*crash*|*报错*)
CATEGORY="bug"; LABEL_ID="325573"; LABEL_NAME="缺陷"
COMMENT_TEXT="AI 自动分类结果:🐛 Bug缺陷"
;;
*建议*|*希望*|*feature*|*新增*|*支持*|*Shortcut*|*命令*|*兼容*|*封装*|*API*|*子任务*|*Webhook*|*Wiki*|*Snippet*)
CATEGORY="enhancement"; LABEL_ID="325574"; LABEL_NAME="功能"
COMMENT_TEXT="AI 自动分类结果:✨ 功能需求"
;;
*文档*|*README*|*拼写*|*帮助*|*doc*|*说明*)
CATEGORY="documentation"; LABEL_ID="325580"; LABEL_NAME="文档"
COMMENT_TEXT="AI 自动分类结果:📝 文档"
;;
*demo*|*测试*|*test*)
CATEGORY="test"; LABEL_ID="325581"; LABEL_NAME="测试"
COMMENT_TEXT="AI 自动分类结果:🧪 测试"
;;
esac
echo "[INFO] 分类结果: $CATEGORY (标签: $LABEL_NAME)"
# ---- Step 5: 打标签 + 加评论 ----
# ---- Step 4: 打标签dry-run 保护) ----
if [ "$DRY_RUN" = "true" ]; then
echo "[DRY-RUN] 将为 Issue #$NUMBER 添加标签: $LABEL_NAME ($LABEL_ID)"
echo "[DRY-RUN] 将添加引导评论: $COMMENT_TEXT"
echo "[DRY-RUN] 将为 Issue #$NUMBER 添加标签: \$CATEGORY"
echo "[DRY-RUN] 将添加引导评论"
else
echo "[INFO] 为 Issue #$NUMBER 打标签和添加评论..."
if [ -n "$LABEL_ID" ]; then
$CLI issue +batch-update --owner "$OWNER" --repo "$REPO" --numbers "$NUMBER" --label "$LABEL_ID" 2>&1 || echo "[WARN] 打标签失败"
fi
if [ -n "$COMMENT_TEXT" ]; then
$CLI issue +comment --owner "$OWNER" --repo "$REPO" --number "$NUMBER" --body "$COMMENT_TEXT" 2>&1 || echo "[WARN] 添加评论失败"
fi
# 实际执行(由 AI 填入具体参数)
# gitlink-cli issue +update --owner "$OWNER" --repo "$REPO" --number "$NUMBER" --labels "$LABEL_ID"
# gitlink-cli issue +comment --owner "$OWNER" --repo "$REPO" --number "$NUMBER" --body "$COMMENT_BODY"
echo "[INFO] Issue #$NUMBER 处理完成"
fi
done

View File

@ -56,17 +56,8 @@ allResults.forEach(r => {
// 按 Star 排序取前 10 个项目
const topProjects = projects.sort((a, b) => b.stars - a.stars).slice(0, 10);
// 排除编程语言后的热门主题 TOP 8
const LANG_FILTER = new Set([
'python','c','c++','c#','csharp','javascript','typescript','go','golang',
'rust','java','ruby','php','shell','bash','makefile','cmake','jupyter notebook',
'kotlin','swift','scala','haskell','lua','perl','r','dart','elixir','clojure',
'erlang','objective-c','assembly','html','css','vue','react','nodejs','node',
'dockerfile','postscript','coldfusion','tex','latex','batchfile','viml','vimscript',
'roff','pascal','fortran','cobol','ada','prolog','lisp','smalltalk','delphi'
]);
// 热门主题 TOP 8
const topTopics = Object.entries(topicMap)
.filter(([t]) => !LANG_FILTER.has(t.toLowerCase()))
.sort((a, b) => b[1] - a[1])
.slice(0, 8)
.map(([t, c], i) => ({ rank: i + 1, topic: t, count: c }));

View File

@ -17,28 +17,26 @@ const prs = readJSON('prs-all.json').data || {};
const langs = readJSON('repo-languages.json').data || {};
const contribs = readJSON('repo-contributors.json').data || {};
// ==== 数据提取 ====
// ==== 数据提取(兼容实际字段名)====
const name = repo.name || 'unknown';
const fullName = repo.full_name || 'unknown';
const isMirror = !!repo.mirror; // 镜像仓库检测
// description
// description: 从 issue 的 project 信息中获取,或从 repo 顶层获取
let description = '';
try { description = issues.issues[0].project.description || ''; } catch(e) {}
if (!description) description = repo.description || repo.about || '';
// 从 repo 的 fork_info 获取描述
if (!description && repo.fork_info) {
try { description = issues.issues[0].project.description || ''; } catch(e) {}
}
// 创建时间
// 创建时间:从 issue 的第一条创建时间推断,或从项目信息获取
let created = repo.created_at || repo.created_on || '';
if (!created && issues.issues && issues.issues.length > 0) {
created = issues.issues[issues.issues.length - 1].created_at || '';
}
// 支持 "2026-06-04 15:35" 格式的日期
if (created) created = created.replace(' ', 'T');
const updated = repo.updated_at || repo.last_updated || '';
// Star/Like — GitLink 使用 praises_count 和 watchers_count
const stars = repo.praises_count || repo.watchers_count || 0;
const forks = repo.forked_count || 0;
const defaultBranch = repo.default_branch || 'master';
@ -47,6 +45,7 @@ const contributorCount = repo.contributor_users_count || 0;
const langEntries = Object.entries(langs).sort((a,b) => parseFloat(b[1]) - parseFloat(a[1]));
const topLangs = langEntries.slice(0, 3).map(e => e[0] + ' ' + e[1]).join(', ');
const topics = (repo.topics || []).join(', ') || '无标签';
// 项目年龄(月)
@ -65,138 +64,108 @@ const closedCount = issues.closed_count || 0;
const openedCount = issues.opened_count || 0;
const totalIssues = closedCount + openedCount || issueList.length || issuesCount;
// PR 数据
// PR 数据 — status 是字符串 "open"/"merged"/"closed"
const prList = prs.pulls || [];
let prOpen = 0, prMerged = 0, prClosed = 0;
let prOpen = 0, prMerged = 0;
prList.forEach(p => {
const s = (p.status || '').toLowerCase();
if (s === 'open' || s === 'opened') prOpen++;
else if (s === 'merged' || s === 'merge') prMerged++;
else if (s === 'closed') prClosed++;
});
const prTotal = repo.pull_requests_count || prList.length || 0;
const prTotal = repo.pull_requests_count || prList.length || 1;
// 贡献者
const contribList = contribs.list || [];
const uniqueContributors = contribList.length || contributorCount;
// ==== 是否有足够的社区活动数据 ====
const hasActivity = totalIssues > 0 || prTotal > 0 || uniqueContributors > 1;
// ==== 维度评分 ====
// 1. 成熟度评分 (0-10)
// 修复:创建时间不可用时给中等分
const ageScore = ageMonths > 0 ? Math.min(10, ageMonths / 2) : 5;
const ageScore = Math.min(10, Math.max(0, ageMonths / 2));
const starScore = stars > 100 ? 10 : stars > 50 ? 7 : stars > 10 ? 5 : Math.max(1, stars);
const forkScore = forks > 50 ? 10 : forks > 20 ? 7 : forks > 5 ? 5 : Math.max(1, forks);
const updateScore = ageMonths > 0 ? 7 : 5;
const updateScore = 7;
const maturityScore = Math.round((ageScore * 0.25 + starScore * 0.25 + forkScore * 0.20 + updateScore * 0.30) * 10) / 10;
// 2. 文档质量评分 (0-10)
let docScore = 3;
if (description && description.length > 5) docScore += 2;
if (description && description.length > 10) docScore += 2;
if (repo.license_short_name || repo.license_name) docScore += 2;
if (repo.open_devops) docScore += 1;
if (repo.has_tests) docScore += 1;
// 镜像仓库且无检测到的文档,给保底分表示"数据不可用"
if (isMirror && docScore < 4) docScore = 4;
docScore = Math.min(10, docScore);
// 3. 贡献模式评分 (0-10)
const contribScore = Math.min(10, Math.max(1, uniqueContributors * 2));
const freqScore = hasActivity ? 6 : 3;
let contribModeScore;
if (isMirror && uniqueContributors <= 1) {
// 镜像仓库:贡献数据不可用,给中等分
contribModeScore = 5;
} else {
contribModeScore = Math.round((contribScore * 0.30 + freqScore * 0.30 + 5 * 0.20 + 5 * 0.20) * 10) / 10;
}
const freqScore = 6;
const contribModeScore = Math.round((contribScore * 0.30 + freqScore * 0.30 + 5 * 0.20 + 5 * 0.20) * 10) / 10;
// 4. 社区健康度评分 (0-10)
let closeRate = 0, mergeRate = 0;
let closeRateScore, mergeRateScore, communityScore;
if (isMirror && totalIssues === 0 && prTotal === 0) {
closeRateScore = 5; mergeRateScore = 5; communityScore = 5;
} else {
closeRate = totalIssues > 0 ? Math.round(closedCount / totalIssues * 100) : 0;
closeRateScore = closeRate > 80 ? 10 : closeRate > 50 ? 7 : closeRate > 30 ? 5 : totalIssues > 0 ? 3 : 5;
mergeRate = prTotal > 0 ? Math.round(prMerged / prTotal * 100) : 0;
mergeRateScore = mergeRate > 70 ? 10 : mergeRate > 40 ? 7 : prTotal > 0 ? 3 : 5;
communityScore = Math.round((closeRateScore * 0.30 + 6 * 0.25 + mergeRateScore * 0.25 + 6 * 0.20) * 10) / 10;
}
const closeRate = totalIssues > 0 ? Math.round(closedCount / totalIssues * 100) : 0;
const closeRateScore = closeRate > 80 ? 10 : closeRate > 50 ? 7 : closeRate > 30 ? 5 : 3;
const mergeRate = prTotal > 0 ? Math.round(prMerged / prTotal * 100) : 0;
const mergeRateScore = mergeRate > 70 ? 10 : mergeRate > 40 ? 7 : 3;
const communityScore = Math.round((closeRateScore * 0.30 + 6 * 0.25 + mergeRateScore * 0.25 + 6 * 0.20) * 10) / 10;
// 5. 综合评分
// 镜像仓库:调整权重
let totalScore;
if (isMirror && !hasActivity) {
// 镜像仓库:成熟度和文档权重提高
totalScore = Math.round((maturityScore * 0.40 + docScore * 0.30 + contribModeScore * 0.15 + communityScore * 0.15) * 10) / 10;
} else {
totalScore = Math.round((maturityScore * 0.25 + docScore * 0.20 + contribModeScore * 0.30 + communityScore * 0.25) * 10) / 10;
}
const totalScore = Math.round((maturityScore * 0.25 + docScore * 0.20 + contribModeScore * 0.30 + communityScore * 0.25) * 10) / 10;
const level = totalScore >= 9 ? '🟢 优秀' : totalScore >= 7 ? '🟢 良好' : totalScore >= 5 ? '🟡 一般' : totalScore >= 3 ? '🔴 堪忧' : '🔴 危险';
// 可读的状态显示
const totalIssuesStr = totalIssues > 0 ? `${totalIssues}(关闭 ${closedCount} / 打开 ${totalIssues - closedCount}` : `${totalIssues || '—'}`;
const prTotalStr = prTotal > 0 ? `${prTotal}(合并 ${prMerged} / 打开 ${prOpen}` : `${prTotal || '—'}`;
const contributorsStr = uniqueContributors > 0 ? `${uniqueContributors}` : '—';
// 可复现性
const hasLicense = repo.license_short_name ? '✅' : '❌';
const hasReadme = (description && description.length > 0) ? '✅' : '❌';
const hasDevops = repo.open_devops ? '✅' : '❌';
// 改进建议
const suggestions = [];
if (stars < 20) suggestions.push('🟡 中优先级 — 项目影响力有限,建议在社区中推广');
if (!repo.license_short_name && !isMirror) suggestions.push('🔴 高优先级 — 缺少开源许可证,建议添加 LICENSE 文件');
if (uniqueContributors < 3 && !isMirror) suggestions.push('🔴 高优先级 — 贡献者较少,建议标记 good-first-issue 吸引新贡献者');
if (!repo.license_short_name) suggestions.push('🔴 高优先级 — 缺少开源许可证,建议添加 LICENSE 文件');
if (uniqueContributors < 3) suggestions.push('🔴 高优先级 — 贡献者较少,建议标记 good-first-issue 吸引新贡献者');
if (closeRate < 50 && totalIssues > 0) suggestions.push('🟡 中优先级 — Issue 关闭率偏低,建议定期清理积压 Issue');
if (mergeRate < 50 && prTotal > 1) suggestions.push('🟡 中优先级 — PR 合并率偏低,建议加快 PR 处理速度');
if (isMirror && !hasActivity) suggestions.push(' 该项目为镜像仓库,部分社区活动数据不可用,评分仅供参考');
if (suggestions.length === 0) suggestions.push('🟢 低优先级 — 项目状态良好,继续保持');
const now = new Date();
const dateStr = now.toISOString().slice(0, 10);
const timeStr = now.toISOString().slice(0, 19).replace('T', ' ');
const ageDisplay = ageMonths > 0 ? `${Math.round(ageMonths)} 个月` : '未知';
const mirrorNote = isMirror ? '\n> 该项目为镜像仓库,部分数据(贡献者/Issue/PR可能不完整\n' : '';
// ==== 生成报告 ====
const report = `# 🔬 科研项目洞察报告 — ${fullName}
**分析日期** ${dateStr}
**综合评分** ${totalScore}/10 ${level}${isMirror ? ' 📦 镜像仓库' : ''}
${mirrorNote}
**综合评分** ${totalScore}/10 ${level}
## 项目画像
| 维度 | 数据 |
|------|------|
| 项目名称 | ${name} |
| 描述 | ${description || '无描述'} |
| 创建时间 | ${created || '未知'}${ageDisplay} |
| 创建时间 | ${created || '未知'}${Math.round(ageMonths)} 个月 |
| Star / Fork | ${stars} / ${forks} |
| 默认分支 | ${defaultBranch} |
| 主要语言 | ${topLangs || '未知'} |
| 研究主题 | ${topics} |
| 贡献者数 | ${contributorsStr} |
| 贡献者数 | ${uniqueContributors} |
| Issue 总数 | ${totalIssues} |
## 项目成熟度${maturityScore}/10
**评分因子**
- 项目年龄${ageDisplay} ${ageScore.toFixed(1)} 权重 25%
- 项目年龄${Math.round(ageMonths)} 个月 ${ageScore.toFixed(1)} 权重 25%
- 社区影响力${stars} Star / ${forks} Fork ${Math.round(starScore)} 权重 25%
- Fork 活跃度${forks} Fork ${Math.round(forkScore)} 权重 20%
- 维护活跃度最近更新 ${updated || '未知'} ${updateScore} 权重 30%
**分析** ${stars > 50 ? '项目已有一定社区影响力,处于成长期。' : '项目尚在早期阶段,需加强社区推广。'}
**分析** 项目创建约 ${Math.round(ageMonths)} 个月获得 ${stars} Star ${forks} Fork${stars > 50 ? '项目已有一定社区影响力,处于成长期。' : '项目尚在早期阶段,需加强社区推广。'}
## 文档质量${docScore}/10
| 检查项 | 状态 | 说明 |
|--------|------|------|
| README | ${description && description.length > 5 ? '✅' : '❌'} | ${description ? '项目描述已填写' : '建议完善 README'} |
| 开源许可证 | ${repo.license_short_name ? '✅' : '❌'} | ${repo.license_short_name || '未检测到,建议添加'} |
| DevOps CI | ${repo.open_devops ? '✅' : '❌'} | ${repo.open_devops ? '已配置' : '建议配置 CI 流水线'} |
| README | ${hasReadme} | ${description ? '项目描述已填写' : '建议完善 README'} |
| 开源许可证 | ${hasLicense} | ${repo.license_short_name || '未检测到,建议添加'} |
| DevOps CI | ${hasDevops} | ${repo.open_devops ? '已配置' : '建议配置 CI 流水线'} |
**改进建议** ${docScore < 6 ? '建议补充 README、LICENSE 和 CI 配置以提升项目规范性' : '文档基本完善'}
@ -204,29 +173,29 @@ ${mirrorNote}
| 指标 | 数据 | 评分 |
|------|------|------|
| 贡献者数量 | ${contributorsStr} | ${isMirror && uniqueContributors <= 1 ? '—(镜像仓库)' : contribScore + '/10'} |
| 提交活跃度 | ${hasActivity ? '中等' : '—(镜像仓库)'} | ${isMirror && !hasActivity ? '—' : freqScore + '/10'} |
| 贡献者数量 | ${uniqueContributors} | ${contribScore}/10 |
| 提交活跃度 | 中等 | ${freqScore}/10 |
**分析** ${isMirror && uniqueContributors <= 1 ? '该项目为镜像仓库,贡献者数据不代表实际开发团队。' : uniqueContributors < 3 ? '目前贡献者偏少,建议通过 good-first-issue 标签吸引新贡献者。' : '团队协作良好,有多位贡献者共同维护。'}
**分析** 项目有 ${uniqueContributors} 位贡献者${uniqueContributors < 3 ? '目前贡献者偏少,建议通过 good-first-issue 标签吸引新贡献者。' : '团队协作良好,有多位贡献者共同维护。'}
## 社区健康度${communityScore}/10
| 指标 | 数据 | 评分 |
|------|------|------|
| Issue 总数 | ${totalIssuesStr} | |
| 关闭率 | ${totalIssues > 0 ? Math.round(closedCount / totalIssues * 100) + '%' : '—'} | ${closeRateScore}/10 |
| PR 总数 | ${prTotalStr} | |
| 合并率 | ${prTotal > 0 ? Math.round(prMerged / prTotal * 100) + '%' : '—'} | ${mergeRateScore}/10 |
| Issue 总数 | ${totalIssues}关闭 ${closedCount} / 打开 ${totalIssues - closedCount}| |
| 关闭率 | ${closeRate}% | ${closeRateScore}/10 |
| PR 总数 | ${prTotal}合并 ${prMerged} / 打开 ${prOpen}| |
| 合并率 | ${mergeRate}% | ${mergeRateScore}/10 |
**分析** ${isMirror && totalIssues === 0 && prTotal === 0 ? '该项目为镜像仓库,没有独立 Issue 和 PR 数据。' : (closeRate > 50 ? 'Issue 关闭率 ✅ 良好' : 'Issue 关闭率 ⚠️ 偏低') + '' + (mergeRate > 50 ? 'PR 合并率 ✅ 良好' : 'PR 合并率 ⚠️ 偏低')}
**分析** Issue 关闭率 ${closeRate}%${closeRate > 50 ? ' ✅ 良好' : ' ⚠️ 偏低'}PR 合并率 ${mergeRate}%${mergeRate > 50 ? ' ✅ 良好' : ' ⚠️ 偏低'}
## 可复现性评估
| 检查项 | 状态 | 说明 |
|--------|------|------|
| 开源许可证 | ${repo.license_short_name ? '✅' : '❌'} | ${repo.license_short_name || '建议添加以便他人使用'} |
| 依赖文档化 | ${hasActivity ? '—' : '⏭️'} | ${hasActivity ? '需人工检查' : '镜像仓库,跳过'} |
| 运行说明 | ${description && description.length > 5 ? '✅' : '❌'} | ${description ? 'README 包含基本说明' : 'README 缺少运行说明'} |
| CI 配置 | ${repo.open_devops ? '✅' : '❌'} | ${repo.open_devops ? '已有 DevOps 流水线' : '建议配置 CI'} |
| 开源许可证 | ${hasLicense} | ${repo.license_short_name || '建议添加以便他人使用'} |
| 依赖文档化 | | 需人工检查 go.mod / package.json |
| 运行说明 | ${hasReadme} | ${description ? 'README 包含基本说明' : 'README 缺少运行说明'} |
| CI 配置 | ${hasDevops} | ${repo.open_devops ? '已有 DevOps 流水线' : '建议配置 CI'} |
## 改进建议
${suggestions.map((s, i) => (i + 1) + '. ' + s).join('\n')}

View File

@ -20,17 +20,17 @@ echo "============================================"
echo ""
# Step 1: 数据采集
echo "▸ Step 1/3: 数据采集"
echo "▸ Step 1/2: 数据采集"
bash "$SCRIPT_DIR/01-collect-repo-data.sh" "$OWNER" "$REPO"
echo ""
# Step 2: 分析并生成报告
echo "▸ Step 2/3: 分析生成报告"
echo "▸ Step 2/2: 分析生成报告"
bash "$SCRIPT_DIR/02-analyze-contributions.sh" "$OWNER" "$REPO"
echo ""
# Step 3: 生成 HTML 可视化
echo "▸ Step 3/3: 生成 HTML 可视化报告..."
echo "▸ Step 3/2: 生成 HTML 可视化报告..."
node "$SCRIPT_DIR/../../gitlink-shared/scripts/md-to-html.js" "$OUTPUT_DIR/research-insight-report.md"
echo ""