Skip to content

Feat/upgrade#23

Merged
kooksee merged 7 commits intomainfrom
feat/upgrade
Mar 14, 2026
Merged

Feat/upgrade#23
kooksee merged 7 commits intomainfrom
feat/upgrade

Conversation

@kooksee
Copy link
Contributor

@kooksee kooksee commented Mar 13, 2026

Description / 描述

Type of Change / 变更类型

  • 🐛 Bug fix / 缺陷修复
  • ✨ New feature / 新功能
  • 💥 Breaking change / 破坏性变更
  • 📝 Documentation / 文档更新
  • 🔧 Configuration / 配置变更
  • ♻️ Refactor / 代码重构
  • 🎨 Style / 代码风格
  • ⚡ Performance / 性能优化
  • ✅ Test / 测试相关

Related Issues / 关联 Issue

Pre-submission Checklist / 提交前检查清单

Critical Issues / 关键问题 🔴

  • No requirements mismatch [REQ] / 无需求不匹配
  • No logic bugs [LOGI] / 无逻辑缺陷
  • No security vulnerabilities [SEC] / 无安全漏洞
  • No auth/permission issues [AUTH] / 无认证授权问题

High Priority / 高优先级 🟠

  • Design is appropriate [DSN] / 设计合理
  • Error handling is robust [RBST] / 错误处理健壮
  • Transactions handled correctly [TRANS] / 事务处理正确
  • No concurrency issues [CONC] / 无并发问题
  • Performance is acceptable [PERF] / 性能可接受

Code Quality / 代码质量 🟡🟢

  • Code is maintainable [MAIN] / 代码可维护
  • No unnecessary coupling [CPL] / 无不必要耦合
  • Code is readable [READ] / 代码可读
  • No code duplication [DUP] / 无代码重复
  • Naming is clear [NAM] / 命名清晰

Testing / 测试

  • Unit tests added/updated / 已添加/更新单元测试
  • Integration tests passed / 集成测试通过
  • Manual testing completed / 已完成手动测试

Documentation / 文档

  • Code comments added where needed / 已添加必要的代码注释
  • README updated if needed / 如需要已更新 README
  • API docs updated if needed / 如需要已更新 API 文档

Screenshots / 截图

Additional Notes / 补充说明


💡 Review Guidelines: This PR will be reviewed following our Code Review Guide / 代码审查指南

@gemini-code-assist
Copy link

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request primarily focuses on a significant dependency upgrade, migrating the project to github.com/pubgo/funk/v2 and updating the Go language version. This modernization effort streamlines error handling and paves the way for new features. Additionally, it introduces functionality to integrate protobuild with AI agent platforms by providing a command to install skill templates, expanding its utility in automated development workflows.

Highlights

  • Dependency Upgrade: Upgraded the core github.com/pubgo/funk library to its v2 version across the codebase, necessitating updates to import paths and error handling patterns.
  • Go Version Update: The project's Go version has been updated from 1.24.6 to 1.25, along with various other indirect Go module dependencies.
  • Agent Skills Integration: Introduced a new skills command to facilitate the installation of Agent Skills templates, including options for generating OpenAI metadata, enhancing protobuild's integration with AI-driven development tools.
  • CLI Command Enhancements: The main CLI command (protobuild) has been refined with updated Use and Short descriptions, and now includes an upgrade command for self-updating the tool.
  • Error Handling Modernization: Adopted funk/v2's assert.Must and assert.Must1 for more concise error handling in several web server and utility functions, replacing explicit if err != nil checks.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Changelog
  • cmd/format/format.go
    • Updated github.com/pubgo/funk/assert import to v2.
  • cmd/formatcmd/cmd.go
    • Updated github.com/pubgo/funk/errors import to v2.
  • cmd/protobuild/cmd.go
    • Updated multiple github.com/pubgo/funk imports to their v2 versions.
    • Added new imports for errors, io/fs, path/filepath, and github.com/pubgo/funk/v2/cmds/upgradecmd.
    • Introduced defaultSkillContent and defaultOpenAIContent string literals for agent skill templates.
    • Modified the Main function signature, removing the ver parameter.
    • Updated the Use and Short descriptions for the main protobuild command.
    • Added newSkillsCommand() and upgradecmd.New() to the main command's subcommands.
    • Implemented newSkillsCommand to install agent skills templates with options for output directory, OpenAI metadata, and force overwrite.
    • Added writeFileIfNeeded helper function for the skills command.
    • Modified handleStdinPlugin to return redant.DefaultHelpFn() for help or empty input.
    • Replaced generic.Ptr with lo.ToPtr in handleStdinPlugin.
    • Updated running.Project, running.Version, and running.CommitID to be called as functions in newVersionCommand.
  • cmd/protobuild/cmd_doctor.go
    • Updated github.com/pubgo/funk/recovery import to v2.
  • cmd/protobuild/cmd_init.go
    • Updated github.com/pubgo/funk/recovery import to v2.
  • cmd/protobuild/commands.go
    • Updated github.com/pubgo/funk/pathutil and github.com/pubgo/funk/recovery imports to v2.
  • cmd/protobuild/proto_walker.go
    • Updated github.com/pubgo/funk/assert and github.com/pubgo/funk/pathutil imports to v2.
  • cmd/protobuild/protoc_builder.go
    • Updated github.com/pubgo/funk/assert, github.com/pubgo/funk/log, and github.com/pubgo/funk/pathutil imports to v2.
  • cmd/protobuild/util.go
    • Updated github.com/pubgo/funk/assert, github.com/pubgo/funk/errors, github.com/pubgo/funk/pathutil, and github.com/pubgo/funk/strutil imports to v2.
    • Replaced errors.NewFmt with errors.New in getChecksumData.
  • cmd/protobuild/vendor_service.go
    • Updated github.com/pubgo/funk/assert, github.com/pubgo/funk/errors, github.com/pubgo/funk/pathutil, and github.com/pubgo/funk/recovery imports to v2.
    • Replaced errors.WrapTag with errors.WrapTags using a map for tags.
  • cmd/protobuild/yaml_types.go
    • Updated github.com/pubgo/funk/assert and github.com/pubgo/funk/errors imports to v2.
    • Replaced errors.Format with errors.Errorf in UnmarshalYAML methods.
  • cmd/webcmd/cmd.go
    • Reordered imports for better organization.
  • cmd/webcmd/server.go
    • Added github.com/pubgo/funk/v2/assert import.
    • Wrapped several function calls (openBrowser, s.server.Shutdown, json.NewEncoder(w).Encode, filepath.Walk, fmt.Fprintf) with assert.Must or assert.Must1 for streamlined error handling.
    • Changed map[string]interface{} to map[string]any for type consistency.
  • docs/AGENT_SKILL.md
    • Added a new documentation file detailing how to expose protobuild as an Agent/LLM skill, including manifest, usage notes, and OpenAI/MCP tool definitions.
  • go.mod
    • Updated Go version from 1.24.6 to 1.25.
    • Upgraded github.com/pubgo/funk to v2 v2.0.0-beta.16.
    • Upgraded github.com/samber/lo to v1.52.0.
    • Upgraded golang.org/x/mod to v0.32.0.
    • Upgraded golang.org/x/term to v0.39.0.
    • Upgraded google.golang.org/genproto/googleapis/api and google.golang.org/protobuf to newer versions.
  • go.sum
    • Updated checksums for numerous dependencies due to version upgrades and new indirect dependencies.
  • internal/config/loader.go
    • Changed file permission 0644 to 0o644 for octal literal.
  • internal/config/yaml_types.go
    • Updated github.com/pubgo/funk/errors import to v2.
    • Replaced errors.Format with errors.Errorf in UnmarshalYAML.
  • internal/depresolver/gomod.go
    • Updated github.com/pubgo/funk/pathutil import to v2.
  • internal/depresolver/manager.go
    • Updated github.com/pubgo/funk/pathutil import to v2.
  • internal/modutil/util.go
    • Updated github.com/pubgo/funk/assert and github.com/pubgo/funk/pathutil imports to v2.
    • Changed result.Wrap(shutil.GoModGraph()).Must() to result.Wrap(shutil.GoModGraph()).Unwrap().
  • internal/modutil/util_test.go
    • Updated github.com/pubgo/funk/pretty import to v2.
    • Changed result.Wrap(shutil.GoModGraph()).Must() to result.Wrap(shutil.GoModGraph()).Unwrap().
  • internal/protoutil/gen.go
    • Updated github.com/pubgo/funk/assert import to v2.
  • internal/shutil/shell.go
    • Updated github.com/pubgo/funk/assert and github.com/pubgo/funk/errors imports to v2.
  • main.go
    • Updated main function to use assert.Exit for error handling and version.SetVersion from funk/v2.
    • Removed manual error handling and os.Exit(1).
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

此 PR 主要将 funk 库升级到 v2,并为 Agent 集成引入了新的 skills 命令。大部分变动是依赖更新和针对新版 funk 的 API 调整。然而,我在 cmd/webcmd/server.go 文件中发现了一些关于错误处理的问题。具体来说,有几处不恰当地使用了 assert.Must,可能导致应用崩溃或行为不正确。在 handleCommand 函数中存在一个严重 bug,命令执行失败将导致 panic 而不是被优雅地处理。此外,filepath.Walk 的错误被忽略,这可能会掩盖潜在的文件系统问题。


output, err := cmd.CombinedOutput()

assert.Must(err)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

critical

这是一个 bug。assert.Must(err) 会在 cmd.CombinedOutput() 返回错误时导致 panic。这会阻止后续的错误处理逻辑(例如设置 result.Success = falseresult.Error)执行。因此,客户端将永远不会收到关于命令失败的正确响应。请移除此行,让后续代码来处理错误。

Comment on lines 132 to 135
go func() {
time.Sleep(500 * time.Millisecond)
openBrowser(url)
assert.Must(openBrowser(url))
}()

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

goroutine 中使用 assert.Must 可能会导致整个应用程序崩溃。openBrowser 失败(例如,在没有图形界面的环境中)是一个非关键性错误,不应该导致服务停止。建议在这里记录错误而不是 panic。

Suggested change
go func() {
time.Sleep(500 * time.Millisecond)
openBrowser(url)
assert.Must(openBrowser(url))
}()
go func() {
time.Sleep(500 * time.Millisecond)
if err := openBrowser(url); err != nil {
slog.Warn("failed to open browser", "url", url, "err", err)
}
}()

Comment on lines 138 to 143
go func() {
<-ctx.Done()
shutdownCtx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
defer cancel()
s.server.Shutdown(shutdownCtx)
assert.Must(s.server.Shutdown(shutdownCtx))
}()

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

goroutine 中对 s.server.Shutdown 使用 assert.Must 同样有风险。如果 Shutdown 返回错误,将导致整个程序 panic,这对于优雅停机来说是不理想的。建议记录错误而不是 panic。

Suggested change
go func() {
<-ctx.Done()
shutdownCtx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
defer cancel()
s.server.Shutdown(shutdownCtx)
assert.Must(s.server.Shutdown(shutdownCtx))
}()
go func() {
<-ctx.Done()
shutdownCtx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
defer cancel()
if err := s.server.Shutdown(shutdownCtx); err != nil {
slog.Error("server shutdown failed", "err", err)
}
}()

filepath.Walk(rootPath, func(path string, info fs.FileInfo, err error) error {
assert.Must(filepath.Walk(rootPath, func(path string, info fs.FileInfo, err error) error {
if err != nil {
return nil

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

filepath.Walk 的回调中,当 err != nil 时返回 nil 会导致错误被忽略。这可能会掩盖文件系统问题(例如权限错误),导致函数静默失败或返回不完整的结果。应该将错误向上传播。

Suggested change
return nil
return err

filepath.Walk(rootPath, func(path string, info fs.FileInfo, err error) error {
assert.Must(filepath.Walk(rootPath, func(path string, info fs.FileInfo, err error) error {
if err != nil {
return nil

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

filepath.Walk 的回调中,当 err != nil 时返回 nil 会导致错误被忽略。这可能会掩盖文件系统问题(例如权限错误),导致函数静默失败或返回不完整的结果。应该将错误向上传播。

Suggested change
return nil
return err

filepath.Walk(vendorPath, func(path string, info fs.FileInfo, err error) error {
assert.Must(filepath.Walk(vendorPath, func(path string, info fs.FileInfo, err error) error {
if err != nil {
return nil

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

filepath.Walk 的回调中,当 err != nil 时返回 nil 会导致错误被忽略。这可能会掩盖文件系统问题(例如权限错误),导致函数静默失败或返回不完整的结果。应该将错误向上传播。

Suggested change
return nil
return err

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR is an “upgrade” pass that primarily updates documentation/formatting, adds Agent Skills scaffolding support, and extends the formatter to support an additional engine.

Changes:

  • Add a protobuild skills command to generate an Agent Skills template (optional OpenAI metadata).
  • Extend protobuild format with a --clang-format engine and --clang-style option.
  • Restructure/translate multiple docs (Mermaid diagrams, tables) and remove legacy Gemini/Chinese docs files.

Reviewed changes

Copilot reviewed 14 out of 15 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
proto/example/v1/user.proto Reformat retag.tags option blocks into a more compact style.
docs/MULTI_SOURCE_DEPS.md Rewrite and reorganize the multi-source dependency design doc; switch diagrams to Mermaid.
docs/EXAMPLES.md Adjust headings/anchors and table formatting; remove bilingual headers.
docs/DESIGN_CN.md Remove the separate Chinese design doc (content appears consolidated elsewhere).
docs/DESIGN.md Convert the design doc content to Chinese and replace ASCII diagrams with Mermaid.
docs/AUDIT_REVIEW.md Table formatting and layout normalization.
docs/AGENT_SKILL.md Add a guide/template for exposing protobuild as an Agent Skill.
cmd/protobuild/cmd.go Add skills subcommand that writes .agents/skills/protobuild templates.
cmd/formatcmd/cmd.go Add clang-format formatting path, file collection, and unified diff output.
README_CN.md Remove the standalone Chinese README.
README.md Rewrite README content in Chinese; document new clang-format options and add Mermaid architecture diagram.
.github/gemini.json Remove Gemini Code Assist config.
.github/gemini-instructions.md Remove Gemini review instructions.
.github/copilot-instructions.md Update link to the code review guide location under .github/.
.github/codereview/CODE_REVIEW_GUIDE_CN.md Add a consolidated Chinese code review guide/checklist.

You can also share your feedback on Copilot code review. Take the survey.

Comment on lines 58 to 62
Use: name,
Short: "Format Protobuf files using buf format",
Short: "Format Protobuf files (buf, builtin, or clang-format)",
Long: `Format Protobuf files using buf format command.

By default, this command formats files in the 'root' directories defined in protobuf.yaml.
Comment on lines +402 to +417
tmp, err := os.CreateTemp("", "protobuild-clang-format-*.proto")
if err != nil {
return "", err
}
tmpPath := tmp.Name()
defer os.Remove(tmpPath)

if _, err := tmp.Write(formatted); err != nil {
_ = tmp.Close()
return "", err
}
if err := tmp.Close(); err != nil {
return "", err
}

cmd := exec.Command("diff", "-u", "-L", filePath, "-L", filePath+" (clang-format)", filePath, tmpPath)
Comment on lines +247 to +251
# 使用 clang-format(默认 style=file)
protobuild format --clang-format -w

# 使用 clang-format 并指定 style
protobuild format --clang-format --clang-style google -w
Comment on lines +46 to +47
author: pubgo
version: "1.0.0"
Comment on lines +79 to +85
defaultOpenAIContent = `interface:
display_name: "Protobuild"
short_description: "Proto build/lint/format tool"
icon_small: "./assets/protobuild-16.png"
icon_large: "./assets/protobuild-64.png"
brand_color: "#0F9D58"
default_prompt: "Use protobuild to vendor deps and generate proto code."
}

func normalizeTemplateIndent(content string) string {
return strings.ReplaceAll(content, "\n\t", "\n")
@kooksee kooksee merged commit 2d67750 into main Mar 14, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants