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

オープン
#458 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

@fx-kurumi がすでに取り組んでいます。

2026年11月13日 から。

  • #459 @fx-kurumi による — オープン

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
20/100
issue の種類
リファクタリング
明瞭さ
明確に書かれている
活発さ
停滞
技術スタック
go
領域
backend

調査の方向性

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.

索引モデルが issue の本文から書いたものです。

説明

现状问题

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/。
主要言語
Go
スター
141
フォーク
28
平均マージ
1日 15時間
マージ済み PR(30日)
113

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

Tencent/LoopForge のほかの issue

Tencent/LoopForge の issue をすべて見る

似ている issue

Go の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。