【架构优化】从 applyPromptPlaceholders 中拆出仓库描述 promptRepositoryLine 与上游输出收集 upstreamNodeOutputs

Đang mở
#458 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

@fx-kurumi đang làm issue này rồi.

Từ ngày 13/11/2026.

  • #459 của @fx-kurumi — đang mở

Đánh giá

Độ khó
2/5
Thời gian dự kiến
1-3 giờ
Mức phù hợp với người mới
20/100
Loại issue
Tái cấu trúc
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Đình trệ
Công nghệ
go
Lĩnh vực
backend

Hướng nghiên cứu

Start in internal/engine/prompt.go at applyPromptPlaceholders, where the {{repository}} and {{upstream}} values are derived inline. The issue asks for two extracted helpers, promptRepositoryLine and upstreamNodeOutputs, with behavior unchanged, plus a new test file covering their branches. Pull request #459 is already open against this issue, so check with the maintainers before starting. Done means gofmt, go vet ./internal/engine/ and go test ./internal/engine/ pass.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

现状问题

internal/engine/prompt.go 的 applyPromptPlaceholders 约 85 行,把十几个占位符的取值推导和替换写在同一个函数里。其中两段是不依赖 prompt 的纯推导,却内联在替换流程中间:

  • {{repository}}:根据 run.Repository 拼出仓库描述(未绑定 / 工蜂项目 ID / Git SSH);
  • {{upstream}}:遍历 wf.Edges 收集指向当前节点、且上游有输出的节点结果。

这两段无法单独测试,也让主函数难读。

重构方案

  • 拆出 promptRepositoryLine(run domain.Run) string,原样搬迁仓库描述推导;
  • 拆出 upstreamNodeOutputs(wf, node, run) []string,原样搬迁上游输出收集;
  • applyPromptPlaceholders 改为调用这两个函数,替换顺序、追加段落与文案完全不变。

影响范围

仅 internal/engine/prompt.go(包内私有函数),新增测试文件;对外接口与行为不变。

验证方式

  • 新增单元测试覆盖两个新函数的各分支(未绑定仓库、工蜂仓库、SSH 仓库;无上游、上游无输出、多上游按边顺序);
  • gofmt、go vet ./internal/engine/、go test ./internal/engine/。
Ngôn ngữ chính
Go
Star
141
Fork
28
Merge trung bình
1 ngày 15 giờ
Pull request đã merge (30 ngày)
113

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của Tencent/LoopForge

Tất cả issue của Tencent/LoopForge

Issue tương tự

Thêm issue về Go

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.