dev-manager-tauri/.blueprint/modules/github-decommission.md
lanrtop 289b558278 refactor(github): GitHub 全面退役——免登录 + 发布/导入/同步链路移除 + 凭据去 GitHub 化
D1 免登录改造:App 启动直接进主界面,删 LoginPage/github.rs/OAuth 全套命令、
   Sidebar 账户区与 GitHub OAuth 设置弹窗、健康检查 GitHub Token 项
D2 移除发布/导入/PR/CI 入口:删 PublishModal/ImportRepoModal、ProjectCard 的
   PR compare 链接与 Actions 状态灯、RepoRegistryModal 同步 tab、CicdModal runs tab、
   publish.rs 的 github_create_repo/git_push_to_github
D3 spacesSync 单机化:删 spacesSync/useSpacesSync/SpacesPage/DiscoveryPanel,
   拆除 App→Dashboard→ProjectCard 的 spacesJson 链
D4 git_ops 凭据链重写:ssh agent → git credential helper → gitea_instances token
   前缀匹配 → default,不再依赖 github_token

保留:server_software GitHub 镜像(Releases 下载加速)、gitea_migrate 迁移入口、
cicd.rs(待 Gitea Actions 改造卡);DB 表不删(R05 migration 兼容)

顺带:修复 servers.rs 两个存量测试的 schema 漂移(测试建表缺 deploy_type 列);
      包含会话前未提交的 agent-infra F3(get_agent_health 健康诊断,与 lib.rs/
      commands.ts 物理耦合无法拆分提交)

验证:cargo test 53 passed / typecheck 全绿 / vitest passWithNoTests
2026-07-02 13:15:56 +09:00

60 lines
4.9 KiB
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# GitHub 退役清理
围绕自建 Gitea 的战略确定后(见 gitea-integration),移除 GitHub 作为 git 后端的全部纠缠。
排查发现纠缠比蓝图标记的深:GitHub OAuth 是应用登录门槛(App.tsx 无账号连界面都进不去),
spaces.json 每 5 分钟同步 GitHub 仓库,git_ops 所有凭据硬依赖 github_token。
## 边界(保留项)
- `server_software.rs` 的 GitHub 镜像管理:用途是 Releases 下载加速,与 git 后端无关,保留
- `gitea_migrate_repo` 对 GitHub 的引用:迁移功能需要读旧家,保留
- `cicd.rs` 后端命令:保留,待 gitea-integration「Gitea Actions workflow 生成」卡改造
- DB 表(github_mirrors、settings 旧 key 等):代码停用但表不删,避免旧版本升级 migration 断裂(R05)
## 任务卡
### ✅ D1. 免登录改造(去掉 GitHub OAuth 登录门槛)
- status: done
- complexity: M
- files: src/App.tsx, src/components/auth/LoginPage.tsx(删), src/components/layout/Sidebar.tsx, src-tauri/src/commands/github.rs(删), src-tauri/src/commands/settings.rs, src-tauri/src/lib.rs, src/lib/commands.ts
- acceptance: 应用启动直接进主界面,无登录页;github.rs 及 8 个 OAuth 命令删除;Sidebar 账户区与「应用设置」GitHub OAuth 弹窗删除;健康检查移除 GitHub Token 项;GLOBAL_KEYS 移除 github_client_id/secret;typecheck + cargo test 通过
### ✅ D2. 移除 GitHub 发布 / 导入 / PR / CI 状态入口
- status: done
- complexity: M
- files: src/components/dashboard/PublishModal.tsx(删), src/components/dashboard/ImportRepoModal.tsx(删), src/components/dashboard/ProjectCard.tsx, src/components/dashboard/RepoRegistryModal.tsx, src/components/dashboard/CicdModal.tsx, src/components/manage/ManagePage.tsx, src-tauri/src/commands/publish.rs, src/lib/commands.ts
- acceptance: 发布按钮 / 从 GitHub 导入 / PR compare 链接 / Actions 运行状态显示全部移除;publish.rs 仅删 github_create_repo / git_push_to_github / get_token,通用工具(WSL 路径、scan_local_git 等)保留;CicdModal 保留配置 tab、删 runs tab;typecheck 通过
### ✅ D3. 删除 spacesSync(单机化,跨空间 GitHub 云同步下线)
- status: done
- complexity: S
- files: src/lib/spacesSync.ts(删), src/hooks/useSpacesSync.ts(删), src/components/spaces/SpacesPage.tsx(删,已无引用的死代码), src/components/dashboard/Dashboard.tsx, src/components/dashboard/ProjectCard.tsx, src/components/dashboard/ProjectModal.tsx
- acceptance: spacesJson prop 链(App → Dashboard → ProjectCard)拆除;跨空间感知/接续 UI、可发现项目区块、push 后 catalog 上报全部移除;typecheck 通过
### ✅ D4. git_ops 凭据去 GitHub 化
- status: done
- complexity: M
- files: src-tauri/src/commands/git_ops.rs
- acceptance: git_clone/fetch/pull/push/upstream_behind 不再硬依赖 settings.github_token;凭据链改为 git credential helper → gitea_instances token 前缀匹配 → ssh agent → default;无 token 时不再报「未登录 GitHub 账户」;cargo test 通过
## 决策记录
- 免登录而非换 Gitea 登录:炼境是单人本地工具,"登录"概念本身无收益;Gitea 身份已由 gitea_instances.access_token 承载,远端操作按需取凭据
- spacesSync 直接删而非迁 Gitea:用户确认单机使用,跨空间感知无真实场景
- git 凭据优先走 git credential helper:与用户 CLI 使用同一凭据源(Windows Credential Manager),GitHub/Gitea 通吃,炼境不再自管 git 凭据
## 复盘笔记
【复盘】GitHub 退役清理(D1-D4,2026-07-02)
任务类型: 架构调整
复杂度: M×3 + S×1
实际轮数: 1轮(预估 2 轮)
是否返工: 否
有效策略: 先全量排查(grep 全代码库)再动手,发现蓝图未标记的两个深耦合(登录门槛、spacesSync 定时同步);按"前端入口 → 封装层 → 后端命令 → 凭据层"顺序拆除,每层完成即 typecheck
遗留风险: ① Gitea token 作 basic auth username 的凭据方式(userpass_plaintext(token, ""))未在真实 Gitea 实例上验证过 push;② CicdModal 仍生成 GitHub Actions 模板,待 gitea-integration 的 workflow 改造卡处理;③ 前端测试清零(parseRepoPath 测试随功能删除),vitest 配了 passWithNoTests
auto_applied_rules: R01, R05
rule_effectiveness: R01=有效(删命令时同步删 commands.ts 封装,无断层), R05=有效(保留 DB 表不删避免 migration 断裂)
【陷阱记录】servers.rs 存量测试 schema 漂移(顺手修复)
测试 setup 的 CREATE TABLE 手抄了 project_server_map 旧 schema,缺 deploy_type/container_name/start_command 三列,与 db.rs migrate() 不一致导致 2 个测试常红。已补齐。根因:测试建表语句是手抄副本而非复用 migrate(),schema 演进时必然漂移——后续新测试应从 db::migrate 复制对应段(CONVENTIONS 测试模板已有此要求)。