From 6fdac2ec2f0e2b1f54acb84be760a87efdd2e376 Mon Sep 17 00:00:00 2001 From: lanrtop Date: Tue, 30 Jun 2026 17:32:48 +0900 Subject: [PATCH] =?UTF-8?q?chore(blueprint):=20gitea-integration=20?= =?UTF-8?q?=E6=9E=B6=E6=9E=84=E8=AE=BE=E8=AE=A1=20+=205=20=E5=BC=A0?= =?UTF-8?q?=E5=8F=AF=E6=89=A7=E8=A1=8C=E4=BB=BB=E5=8A=A1=E5=8D=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .blueprint/manifest.yaml | 7 +- .blueprint/modules/gitea-integration.md | 86 +++++++++ .blueprint/usage.json | 221 ++++++++++++++++++++++++ 3 files changed, 311 insertions(+), 3 deletions(-) diff --git a/.blueprint/manifest.yaml b/.blueprint/manifest.yaml index dd92b9d..3c0ee7e 100644 --- a/.blueprint/manifest.yaml +++ b/.blueprint/manifest.yaml @@ -304,8 +304,8 @@ modules: name: 飞轮智能成长 area: backend status: in_progress - progress: 95 - note: "F1+F2 完成(2026-06-30);阶段三(预测层)待 ≥10 项目数据积累后启动" + progress: 98 + note: "L0+F1+F2 完成,project_id 双路径冲突修复(2026-06-30);阶段三(预测层)待数据积累" position: [1750, 650] - id: cloud-products @@ -375,9 +375,10 @@ modules: - id: gitea-integration name: Gitea 集成 area: backend - status: concept + status: planned progress: 0 position: [3500, 150] + updated: 2026-06-30 - id: agent-infrastructure name: Agent 友好基础设施生成 diff --git a/.blueprint/modules/gitea-integration.md b/.blueprint/modules/gitea-integration.md index 1306413..2af2852 100644 --- a/.blueprint/modules/gitea-integration.md +++ b/.blueprint/modules/gitea-integration.md @@ -25,6 +25,54 @@ > 详见 `E:/code-project/enterprise-system/docs/ai-context/git-workflow.md` 与 `AGENTS.md`。 +## 架构设计(2026-06-30 /architect) + +### 实现策略 + +**webhook 接收端**:扩展已有 MCP Server(Axum,端口 27190),添加 `POST /webhook/gitea/:project_id` 路由。零新依赖,复用端口和进程。 + +**HTTP 客户端**:`ureq`(Cargo.toml 已有,github.rs 已有使用范例),调 Gitea API v1。 + +**数据表**:新增 `gitea_instances`(实例管理)+ `gitea_repos`(项目-仓库绑定)。 + +```sql +CREATE TABLE IF NOT EXISTS gitea_instances ( + id TEXT PRIMARY KEY, + name TEXT NOT NULL, + url TEXT NOT NULL, -- https://gitea.myserver.com + access_token TEXT NOT NULL, + is_default INTEGER NOT NULL DEFAULT 0, + created_at TEXT DEFAULT (datetime('now')) +); + +CREATE TABLE IF NOT EXISTS gitea_repos ( + id TEXT PRIMARY KEY, + instance_id TEXT NOT NULL REFERENCES gitea_instances(id) ON DELETE CASCADE, + project_id TEXT NOT NULL, -- blueprint_buffs.project_id(UUID) + gitea_owner TEXT NOT NULL, + gitea_repo_name TEXT NOT NULL, + clone_url TEXT, + webhook_secret TEXT, -- HMAC-SHA256 secret + webhook_id INTEGER, -- Gitea 返回的 hook ID + linked_at TEXT DEFAULT (datetime('now')) +); +CREATE UNIQUE INDEX IF NOT EXISTS idx_gitea_repos_project ON gitea_repos(project_id); +``` + +**webhook 流程**: +``` +Gitea push → POST /webhook/gitea/:project_id + 1. 从 gitea_repos 查 webhook_secret + 2. HMAC-SHA256 验签 X-Gitea-Signature-256 + 3. 解析 payload.commits[](sha / message / timestamp) + 4. 批量 record_commit(project_id, sha, message, date) + 5. 返回 200 OK;验签失败记 log_event +``` + +**网络说明**:Gitea 服务器需能访问宿主机 `{ip}:27190`(MCP 端口)。UI 显示可复制的 webhook 回调地址,用户自行确认网络可达。 + +--- + ## 任务卡(concept,待 /architect) ### 💭 Gitea API 对接(握线基础) @@ -53,3 +101,41 @@ - status: concept - complexity: M - acceptance: TBD —— remote 切换 + 推送,安全增量,不丢历史 + +--- + +## 任务卡(可执行,拆自 2026-06-30 /architect) + +### 📋 G1. DB schema + Gitea 实例 CRUD +- status: todo +- complexity: M +- files: src-tauri/src/db.rs, src-tauri/src/commands/gitea.rs, src-tauri/src/lib.rs, src/lib/commands.ts +- acceptance: gitea_instances + gitea_repos 表建好(migrate);save/list/delete/test_connection 命令可调;test_connection 调 GET /api/v1/user 返回 Gitea 用户名验证 token 有效性 + +### 📋 G2. 仓库创建 / 迁移 / 绑定 +- status: todo +- complexity: M +- depends: G1 +- files: src-tauri/src/commands/gitea.rs, src/lib/commands.ts +- acceptance: gitea_create_repo 调 Gitea API 建仓后写 gitea_repos;gitea_migrate_repo 能从 GitHub/GitLab 迁移仓库到 Gitea;gitea_link_repo 绑定已有仓库;命令失败返回可读错误 + +### 📋 G3. Webhook 接收端(MCP Server 扩展) +- status: todo +- complexity: M +- depends: G1 +- files: src-tauri/src/mcp_server.rs +- acceptance: POST /webhook/gitea/:project_id 路由上线;HMAC-SHA256 验签通过后解析 commits 数组批量写 commit_metrics;验签失败记 log_event;单元测试覆盖 parse_push_payload + hmac_verify + +### 📋 G4. Webhook 注册命令 +- status: todo +- complexity: M +- depends: G2, G3 +- files: src-tauri/src/commands/gitea.rs, src/lib/commands.ts +- acceptance: gitea_setup_webhook 生成随机 secret,调 Gitea API POST /repos/:owner/:repo/hooks 注册(events=push),写 webhook_secret + webhook_id 到 gitea_repos;gitea_unlink_repo 清理绑定 + +### 📋 G5. Gitea 治理面板 UI +- status: todo +- complexity: M +- depends: G1, G2, G3, G4 +- files: src/components/dashboard/GiteaPanel.tsx, src/components/dashboard/BlueprintModal.tsx +- acceptance: 治理面板新增"Gitea"区块;可添加/测试/删除实例;显示已绑定仓库列表(仓库名/webhook 状态);操作:新建仓库、迁移、绑定已有、设置 webhook;显示可复制的 webhook 回调地址 diff --git a/.blueprint/usage.json b/.blueprint/usage.json index ef7a348..b60a304 100644 --- a/.blueprint/usage.json +++ b/.blueprint/usage.json @@ -7881,6 +7881,227 @@ "todo": 1, "total": 175 } + }, + { + "at": "2026-06-30T01:41:43Z", + "blocked_reasons": [], + "conventions_version": "1.8.0", + "delta": { + "newly_blocked": [], + "newly_done": [ + "agent-infrastructure/A. 框架层扫描 + 契约路径推断", + "agent-infrastructure/B. 三件套文件生成", + "agent-infrastructure/C. 文档腐化评分", + "agent-infrastructure/D. 栈确认 UI + 生成按钮", + "agent-infrastructure/E. 看板腐化指示器", + "flywheel-intelligence/F1. Git 健康度后端——全量历史导入 + 跨项目聚合", + "flywheel-intelligence/F2. 飞轮面板——Git 健康度区块 + 全量导入按钮" + ], + "unblocked": [] + }, + "iteration": 1, + "modules": { + "blocked": 0, + "concept": 1, + "done": 47, + "in_progress": 1, + "planned": 0, + "stalled": [ + "flywheel-intelligence" + ], + "total": 51 + }, + "task_ids": { + "blocked": [], + "done": [ + "agent-infrastructure/A. 框架层扫描 + 契约路径推断", + "agent-infrastructure/B. 三件套文件生成", + "agent-infrastructure/C. 文档腐化评分", + "agent-infrastructure/D. 栈确认 UI + 生成按钮", + "agent-infrastructure/E. 看板腐化指示器", + "api-keys/API 密钥 CRUD 与安全展示", + "auto-update/Capabilities 权限配置", + "auto-update/下载 & 安装", + "auto-update/更新检测", + "auto-update/自动检查更新", + "auto-update/错误提示", + "blueprint-buff/BlueprintView 跨项目切换", + "blueprint-buff/Buff 生命周期 Rust 命令", + "blueprint-buff/blueprint_buffs 数据表", + "blueprint-buff/git watcher + 任务匹配写回 + 飞轮快照", + "blueprint-buff/前端 Buff 管理 UI", + "blueprint-buff/前端实时刷新", + "blueprint-feedback/归档 command", + "blueprint-feedback/归档候选展示", + "blueprint-feedback/梦核分析入口(蓝图弹窗)", + "blueprint-feedback/梦核提示词增加停滞模块数据", + "blueprint-flywheel/get_flywheel_stats command", + "blueprint-flywheel/get_flywheel_stats 支持迭代感知", + "blueprint-flywheel/usage.json 埋点写入", + "blueprint-flywheel/梦核提示词生成 command", + "blueprint-flywheel/飞轮健康面板", + "blueprint-governance/CLAUDE.md 模板定义", + "blueprint-governance/CONVENTIONS.md 版本化", + "blueprint-governance/GovernancePanel 规则编辑器 UI", + "blueprint-governance/get_blueprint_status command", + "blueprint-governance/sync/梦核/summary 切换为 effective 内容", + "blueprint-governance/sync_blueprint_rules command", + "blueprint-governance/批量同步所有项目规则", + "blueprint-governance/用户版 CONVENTIONS 存储层初始化", + "blueprint-governance/用户版 CONVENTIONS 读写 command", + "blueprint-onboarding/generate_blueprint_prompt command", + "blueprint-onboarding/蓝图操作弹窗", + "blueprint-onboarding/项目列表蓝图状态徽章", + "blueprint-reader/合并返回完整蓝图数据", + "blueprint-reader/读取 manifest.yaml", + "blueprint-reader/读取 modules/*.md", + "blueprint-view/.blueprint/ 数据结构设计", + "blueprint-view/React Flow 节点图渲染", + "blueprint-view/blocked 状态支持", + "blueprint-view/下一步汇总面板", + "blueprint-view/任务卡复制派发", + "blueprint-view/批量执行提示词入口", + "blueprint-view/智能连线路由", + "blueprint-view/模块详情面板", + "blueprint-view/统计汇总条", + "blueprint-view/蓝图治理面板", + "blueprint-view/蓝图读取 Command", + "blueprint-view/边高亮与模块聚焦", + "blueprint-view/顶部状态行扩展", + "blueprint-view/项目卡片蓝图入口", + "cicd-workflow/Actions 运行历史", + "cicd-workflow/CI/CD 配置 CRUD", + "cicd-workflow/Tauri OSS 分发模板", + "cicd-workflow/Web SSH 部署模板", + "cicd-workflow/Workflow 文件生成", + "claude-autonomy-config/Beast 全局状态读取与展示", + "cloud-db-instances/云数据库实例信息管理", + "cloud-docker-apps/Docker 应用列表与状态管理", + "cloud-products/DB 迁移:cloud_products 表", + "cloud-products/Dashboard 接入:云产品标签页", + "cloud-products/Rust CRUD:cloud_products.rs", + "cloud-products/前端 Panel:CloudProductsPanel.tsx", + "cloud-products/接线:mod.rs + lib.rs + commands.ts", + "deploy-info/项目部署信息记录面板", + "devtools-scan/WSL 工具扫描", + "devtools-scan/Windows 工具扫描", + "devtools-scan/工具信息持久化", + "flywheel-intelligence/F1. Git 健康度后端——全量历史导入 + 跨项目聚合", + "flywheel-intelligence/F2. 飞轮面板——Git 健康度区块 + 全量导入按钮", + "flywheel-intelligence/MCP Server 支持 SSE 传输", + "flywheel-intelligence/复盘笔记覆盖率可见性", + "flywheel-intelligence/独立项目自动创建产品组", + "flywheel-intelligence/补测试:飞轮存量函数安全网", + "flywheel-intelligence/阶段一:复盘笔记接入梦核飞轮", + "flywheel-intelligence/阶段二:usage.json 扩展采集维度", + "git-ops/上游状态检测", + "git-ops/分支管理", + "git-ops/基础操作", + "github-auth/OAuth Device Flow", + "github-auth/Token 管理", + "github-publish/GitHub 仓库创建与推送", + "health-center/T1 · Backend 健康检查聚合命令", + "health-center/T2 · 质量指标聚合", + "health-center/T3 · 前端健康中心页面", + "health-center/T4 · 扩展 MCP get_diagnostics", + "host-apps/宿主机应用清单与快启", + "mcp-config-inject/加入产品组时注入配置", + "mcp-config-inject/端口变更时重新注入所有配置", + "mcp-config-inject/退出产品组时清除配置", + "mcp-server/MCP 端口可配置(Rust 侧)", + "mcp-server/启动时绑定 HTTP 端口", + "mcp-server/实现 MCP JSON-RPC 基础协议", + "mcp-server/实现产品组上下文工具", + "onboarding-pack/A 模板分发引擎", + "onboarding-pack/B apply_onboarding_pack 编排 + 前端入口", + "onboarding-pack/C1 commit_metrics 表 + Conventional 解析器", + "onboarding-pack/C2 挂接 buff watcher + 飞轮快照", + "onboarding-pack/D 数据可信度提示", + "product-group-mcp/产品组详情显示 MCP 注入状态", + "product-group-mcp/设置页添加 MCP 端口配置", + "project-dashboard/分组画布", + "project-dashboard/项目卡片列表", + "project-dashboard/项目发现面板", + "project-dashboard/项目快捷操作", + "project-env-scan/环境信息持久化", + "project-env-scan/项目环境检测", + "project-mentor/T1 · 后端聚合 command(MentorContext)", + "project-mentor/T10 · 启动健康扫描 + 前端 Alert Banner", + "project-mentor/T11 · 项目历史快照", + "project-mentor/T2 · MCP 项目导师查询接口", + "project-mentor/T3 · 前端导师面板", + "project-mentor/T4 · 炼境自指接入", + "project-mentor/T5 · project_notes 数据层 + 后端命令", + "project-mentor/T6 · MCP append_project_note 工具", + "project-mentor/T7 · MentorPanel 展示 AI 笔记", + "project-mentor/T8 · 后端全组巡检命令", + "project-mentor/T9 · 前端全组巡检按钮", + "project-mgmt/子文件夹扫描", + "project-mgmt/批量导入项目", + "project-mgmt/项目 CRUD", + "project-mgmt/项目档案(Profile)", + "project-templates/P1+P3 模板扩充(React 生态全覆盖)", + "project-templates/从模板创建项目", + "project-templates/内置模板种植", + "project-templates/模板 CRUD", + "project-tools/工具 CRUD", + "project-tools/工具启动", + "repo-registry/仓库导入", + "repo-registry/仓库挂载", + "repo-registry/仓库注册表管理", + "runtime-diagnostics/T1 · SQLite runtime_logs 表", + "runtime-diagnostics/T2 · 替换 eprintln! 为结构化日志", + "runtime-diagnostics/T3 · MCP Server 新增 get_diagnostics 工具", + "runtime-diagnostics/T4 · 注入失败结果返回前端", + "runtime-diagnostics/T5 · 设置页 MCP 真实健康检查", + "server-registry/服务器 CRUD 与项目关联", + "server-software/服务器软件扫描与展示", + "service-config/服务配置 CRUD 与环境分组", + "settings-page/WSL 发行版选择", + "settings-page/关于 & 更新", + "settings-page/终端配置", + "settings-page/编辑器检测", + "shell-launch/打开终端", + "shell-launch/打开编辑器", + "source-library/源码库分类管理与项目详情", + "sqlite-db/数据库迁移", + "sqlite-db/连接池初始化", + "ssh-config-sync/SSH Config 写入与同步", + "tags-groups/分组管理", + "tags-groups/标签管理", + "tray-service/关闭窗口最小化到托盘", + "tray-service/系统托盘图标与菜单", + "tray-service/集成 tauri-plugin-single-instance", + "user-project-todos/前端:备忘清单 UI 组件", + "user-project-todos/数据层:user_project_todos 表 + Rust commands", + "v2rayn-import/当前节点读取", + "v2rayn-import/数据库路径检测", + "v2rayn-import/节点列表扫描", + "vscode-remote/VS Code Remote SSH 一键连接", + "workspace-mgmt/空间 CRUD", + "workspace-mgmt/空间级设置", + "workspace-mgmt/部署命令管理", + "wsl-proxy/代理一致性测试", + "wsl-proxy/代理同步", + "wsl-proxy/代理清除", + "wsl-proxy/代理状态检测" + ] + }, + "tasks": { + "avg_rounds_M": null, + "blocked": 0, + "complexity_dist": { + "L": 6, + "M": 67, + "S": 49 + }, + "dispatched": 0, + "done": 171, + "in_progress": 0, + "rework_count": 23, + "todo": 1, + "total": 182 + } } ] } \ No newline at end of file