Skip to content

fix: ai-plan workflow - add opencode.json copy and fix sed syntax - #207

Merged
ModerRAS merged 1 commit into
masterfrom
fix/ai-plan-sed
Mar 16, 2026
Merged

fix: ai-plan workflow - add opencode.json copy and fix sed syntax#207
ModerRAS merged 1 commit into
masterfrom
fix/ai-plan-sed

Conversation

@ModerRAS

@ModerRAS ModerRAS commented Mar 16, 2026

Copy link
Copy Markdown
Owner

Summary

  • Add opencode.json copy to Generate plan step
  • Fix sed syntax for variable substitution

Summary by CodeRabbit

  • Chores
    • Updated workflow configuration handling to process multiple configuration files simultaneously during automated setup.

Copilot AI review requested due to automatic review settings March 16, 2026 01:07
@ModerRAS
ModerRAS merged commit 5b0e0c6 into master Mar 16, 2026
4 of 6 checks passed
@claude

claude Bot commented Mar 16, 2026

Copy link
Copy Markdown

Claude finished @ModerRAS's task —— View job


Code Review for PR #207: fix: ai-plan workflow - add opencode.json copy and fix sed syntax

Summary: This PR fixes two issues in the AI planning workflow:

  1. Adds missing opencode.json copy to the "Generate plan" step
  2. Fixes sed syntax for environment variable substitution

Code Quality and Best Practices ✅

Positive aspects:

  • The fix addresses a clear bug where configuration files weren't being properly copied before the planning step
  • Using ${MINIMAX_API_KEY} syntax in sed is correct for Bash environment variable expansion
  • The workflow follows GitHub Actions best practices with proper step organization and conditionals

Areas for improvement:

  1. Code duplication: The same sed commands appear in both "Copy configs and setup" (lines 37-39) and "Generate plan" (lines 98-99) steps. Consider extracting this to a reusable action or function.
  2. Error handling: The sed commands could fail silently if the source files don't exist. Adding || exit 1 would make failures more explicit.
  3. Security: The API key is properly stored as a secret, which is good practice.

Potential Bugs or Issues 🐛

Fixed issues:

  • Missing configuration: Without the opencode.json copy in the "Generate plan" step, the opencode command would likely fail or use incorrect configuration
  • sed syntax: The previous syntax might have been incorrect (e.g., using $MINIMAX_API_KEY without braces), which could cause substitution failures

Remaining considerations:

  1. Path consistency: The workflow assumes .github/workflows/opencode.json exists. Consider adding a check or making the path configurable.
  2. Race condition: If the "Copy configs and setup" step runs but "Generate plan" doesn't (due to conditional), the config might be stale. The duplication actually helps here.

Performance Considerations ⚡

Minimal impact: The changes add two file copy operations which are negligible in terms of performance. The workflow efficiency remains unchanged.

Optimization opportunity:

  • The bun add -g opencode-ai command appears twice (lines 29 and 95). This could be consolidated to run once.

Security Concerns 🔒

Good practices:

  • ✅ API key stored as GitHub secret (secrets.MINIMAX_API_KEY)
  • ✅ Environment variable used for substitution rather than hardcoded values
  • ✅ No sensitive data exposed in logs

Potential concerns:

  1. sed injection: The sed command uses ${MINIMAX_API_KEY} directly. If the API key contains special sed characters (like /, \, &), it could break the substitution or cause unexpected behavior. Consider using a more robust approach:
    sed "s/MINIMAX_API_KEY/$(echo "$MINIMAX_API_KEY" | sed 's/[\/&]/\\&/g')/g"
  2. File permissions: The config files are written to ~/.config/opencode/. Ensure this directory has appropriate permissions.

Test Coverage 📊

Workflow testing: GitHub Actions workflows are difficult to unit test, but:

  • ✅ The changes are minimal and focused
  • ✅ Should be tested through actual workflow runs
  • ✅ Consider adding a test workflow that validates the sed substitution works correctly

Recommendation: Add a simple validation step after the sed commands to ensure the substitution worked:

grep -q "MINIMAX_API_KEY" ~/.config/opencode/opencode.json && echo "ERROR: Substitution failed" && exit 1

Overall Assessment

Grade: B+ - The PR fixes important issues but has room for minor improvements.

Key strengths:

  • Fixes critical configuration issues that would break the AI planning functionality
  • Uses proper environment variable syntax
  • Maintains existing workflow structure

Recommendations:

  1. Consider extracting the duplicated sed commands to reduce maintenance overhead
  2. Add error checking for the sed operations
  3. Consolidate the bun add -g opencode-ai command to run once
  4. Add validation that the substitution succeeded

The PR successfully addresses the stated issues and improves the reliability of the AI planning workflow.

@coderabbitai

coderabbitai Bot commented Mar 16, 2026

Copy link
Copy Markdown

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: ef314169-25f6-4fb5-9c78-e95a42f4a8a8

📥 Commits

Reviewing files that changed from the base of the PR and between 708dc6d and abaf3d2.

📒 Files selected for processing (1)
  • .github/workflows/ai-plan.yml

📝 Walkthrough

Walkthrough

The AI-plan workflow now substitutes and writes both opencode.json and oh-my-opencode.json configuration files to the OpenCode user config directory, expanding from the previous single-file substitution to handle multiple configuration sources simultaneously with MINIMAX API key injection.

Changes

Cohort / File(s) Summary
Workflow Configuration
.github/workflows/ai-plan.yml
Extended workflow step to substitute MINIMAX_API_KEY into and create both opencode.json and oh-my-opencode.json config files in ~/.config/opencode/ directory, replacing the previous single-file approach.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

Possibly related PRs

  • PR #189: Added initial ai-plan.yml workflow and oh-my-opencode.json configuration file that form the foundation for this expanded config handling.
  • PR #200: Previously modified the workflow step to substitute MINIMAX_API_KEY into OpenCode config files, which this change extends to include an additional configuration file.
  • PR #196: Modified .github/workflows/ai-plan.yml to adjust OpenCode invocation, indicating related workflow configuration development.

Poem

🐰 Two configs now dance in harmony's light,
Where MINIMAX keys weave into the night,
One file becomes two, substitution takes flight,
OpenCode's foundation grows steadily bright! ✨

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/ai-plan-sed
📝 Coding Plan
  • Generate coding plan for human review comments

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Updates the AI Issue Planning GitHub Actions workflow to generate OpenCode configuration files at runtime by substituting the MINIMAX_API_KEY placeholder before running opencode to post an implementation plan.

Changes:

  • Add generation of ~/.config/opencode/opencode.json during the “Generate plan” step.
  • Adjust placeholder substitution to use shell double-quoted sed expressions for config templating.

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


# 确保配置文件中的占位符被正确替换
sed 's/MINIMAX_API_KEY/'"$MINIMAX_API_KEY"'/g' .github/workflows/oh-my-opencode.json > ~/.config/opencode/oh-my-opencode.json
sed "s/MINIMAX_API_KEY/${MINIMAX_API_KEY}/g" .github/workflows/opencode.json > ~/.config/opencode/opencode.json
Comment on lines +98 to +99
sed "s/MINIMAX_API_KEY/${MINIMAX_API_KEY}/g" .github/workflows/opencode.json > ~/.config/opencode/opencode.json
sed "s/MINIMAX_API_KEY/${MINIMAX_API_KEY}/g" .github/workflows/oh-my-opencode.json > ~/.config/opencode/oh-my-opencode.json
@github-actions

Copy link
Copy Markdown
Contributor

🔍 PR检查报告

📋 检查概览

🧪 测试结果

平台 状态 详情
Ubuntu 🔴 失败 测试结果不可用
Windows 🔴 失败 测试结果不可用

📊 代码质量

  • ✅ 代码格式化检查
  • ✅ 安全漏洞扫描
  • ✅ 依赖包分析
  • ✅ 代码覆盖率收集

📁 测试产物

  • 测试结果文件已上传为artifacts
  • 代码覆盖率已上传到Codecov

🔗 相关链接


此报告由GitHub Actions自动生成

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