This file provides comprehensive guidance for iFlow CLI when working with code in this repository.
This repository is a production-ready GitHub Action that wraps the iFlow CLI, enabling users to run intelligent code analysis and automation commands within GitHub workflows. The action is built with Rust and packaged in a multi-stage Docker container that includes Node.js 24, uv (ultra-fast Python package manager), GitHub CLI, and the iFlow CLI.
- Intelligent Code Analysis: Run AI-powered code reviews, documentation generation, and issue triage
- Workflow Automation: Automate GitHub issues, PR reviews, and project management tasks
- Flexible Configuration: Support for both CLI flags and GitHub Actions environment variables
- Rich Reporting: Generate detailed execution summaries with GitHub Actions integration
- Multi-language Support: Pre-configured environment for Rust, Python, Node.js, and more
- Version Management: Configurable versions for GitHub CLI and iFlow CLI
-
Entry Points:
src/main.rs: Main entry point that uses Clap for command-line argument parsingsrc/lib.rs: Library code for generating GitHub Actions summaries
-
Docker Infrastructure:
- Multi-stage build: Optimized for size and performance
- Ubuntu 22.04 base: Production-ready with security updates
- Pre-installed tools: Node.js 24, npm, uv, GitHub CLI, Rust 1.90, xmake
- Non-root user: Runs as
iflowuser for security
-
GitHub Actions Integration:
action.yml: Complete action definition with 10+ configurable inputs- Rich step summaries with emoji indicators and troubleshooting hints
- Automatic output handling for GitHub Actions workflows
- Docker-based action with pre-installed development toolchain
- Configurable authentication with iFlow API (API key or settings JSON)
- Advanced timeout handling (1-86400 seconds) with graceful degradation
- Pre-execution commands support for environment setup
- Real-time output streaming during execution
- Comprehensive error handling with actionable troubleshooting guidance
- Version management for GitHub CLI and iFlow CLI
# Build the Rust binary locally
cargo build --release
# Build Docker image for testing
docker build -t iflow-cli-action .
# Build with specific Rust version
cargo build --release
# Build with release optimizations
cargo build --release# Run all Rust tests
cargo test
# Run tests with verbose output
cargo test --verbose
# Run specific test
cargo test test_name
# Run tests with coverage
cargo tarpaulin# Basic execution
./target/release/iflow-cli-action --prompt "Analyze this code" --api-key YOUR_API_KEY
# With custom model and timeout
./target/release/iflow-cli-action --prompt "Review this PR" --api-key YOUR_API_KEY --model "qwen3-coder-plus" --timeout 1800
# With pre-execution commands
./target/release/iflow-cli-action --prompt "Generate docs" --api-key YOUR_API_KEY --precmd "npm install && npm run build"
# With specific versions
./target/release/iflow-cli-action --prompt "Test" --api-key YOUR_API_KEY --gh-version "2.76.2" --iflow-version "0.2.4"# Test with environment variables
INPUT_PROMPT="Analyze this code" INPUT_API_KEY=your-key ./target/release/iflow-cli-action
# With pre-execution setup
INPUT_PROMPT="Run tests" INPUT_API_KEY=your-key INPUT_PRECMD="npm ci" ./target/release/iflow-cli-action
# With custom settings JSON
INPUT_SETTINGS_JSON='{"theme":"Default","selectedAuthType":"iflow","apiKey":"your-key"}' ./target/release/iflow-cli-action
# With version specifications
INPUT_PROMPT="Test" INPUT_API_KEY=your-key INPUT_GH_VERSION="2.76.2" INPUT_IFLOW_VERSION="0.2.4" ./target/release/iflow-cli-action- Dual-mode configuration: CLI flags and GitHub Actions environment variables
- Validation: Comprehensive input validation with helpful error messages
- Settings JSON: Support for complete custom configuration via JSON
- Environment detection: Automatic GitHub Actions environment detection
- Version management: Configurable tool versions for flexible deployments
- Automatic installation: Pre-installed via npm in Docker image
- Settings configuration: Automatic
~/.iflow/settings.jsongeneration - Command execution: Non-interactive mode with
--yoloand--promptflags - Output handling: Real-time streaming with buffer capture
- Version control: Support for specific iFlow CLI versions
- Output variables:
resultandexit_codeviaGITHUB_OUTPUT - Step summaries: Rich Markdown summaries with emoji indicators
- Error annotations: GitHub Actions compatible error and notice messages
- Timeout handling: Graceful timeout detection with troubleshooting hints
- Concurrent execution: Safe concurrent workflow execution
| Parameter | Type | Default | Description |
|---|---|---|---|
prompt |
string | - | Required The prompt to execute with iFlow CLI |
api_key |
string | - | iFlow API key for authentication |
settings_json |
string | - | Complete iFlow settings.json content (overrides other config) |
base_url |
string | https://apis.iflow.cn/v1 |
Custom base URL for iFlow API |
model |
string | qwen3-coder-plus |
Model name to use |
working_directory |
string | . |
Working directory to run from |
timeout |
int | 3600 |
Timeout in seconds (1-86400) |
precmd |
string | - | Shell commands to run before iFlow |
gh_version |
string | - | Version of GitHub CLI to install (e.g., "2.76.2") |
iflow_version |
string | - | Version of iFlow CLI to install (e.g., "0.2.4") |
debug |
boolean | false |
Enable debug logging |
dry_run |
boolean | false |
Dry run mode for E2E testing |
| Variable | Description |
|---|---|
result |
Complete output from iFlow CLI execution |
exit_code |
Exit code from iFlow CLI (0 = success) |
Execute shell commands before running iFlow CLI:
- uses: iflow-ai/iflow-cli-action@main
with:
prompt: "Analyze the codebase"
precmd: |
npm install
npm run build
echo "Environment ready"Provide complete configuration via JSON:
- uses: iflow-ai/iflow-cli-action@main
with:
prompt: "Generate documentation"
settings_json: |
{
"theme": "Default",
"selectedAuthType": "iflow",
"apiKey": "${{ secrets.IFLOW_API_KEY }}",
"baseUrl": "https://custom-api.example.com",
"modelName": "Custom-Model"
}Specify exact versions for GitHub CLI and iFlow CLI:
- uses: iflow-ai/iflow-cli-action@main
with:
prompt: "Analyze code"
api_key: ${{ secrets.IFLOW_API_KEY }}
gh_version: "2.76.2"
iflow_version: "0.2.4"- Add CLI flag in
src/main.rsusing Clap attributes - Update validation logic in the
validatemethod - Update action.yml with new input definition
- Update documentation in README files
- Update execution logic in
src/main.rsfor command changes - Modify argument parsing if needed
- Update output handling in execution functions
- Test with various scenarios (success, timeout, error)
- Update
generate_summary_markdownfunction insrc/lib.rs - Add new sections for metrics or troubleshooting
- Improve formatting with better Markdown structure
- Add emoji indicators for better visual feedback
- Modify Dockerfile for new dependencies
- Test multi-stage build locally
- Update base image versions carefully
- Verify non-root user permissions
- Test with GitHub Actions environment
# Build and test
cargo build --release
./target/release/iflow-cli-action --prompt "Test prompt" --api-key test-key
# Test with timeout
./target/release/iflow-cli-action --prompt "Long running task" --api-key test-key --timeout 60
# Test pre-execution commands
./target/release/iflow-cli-action --prompt "Test" --api-key test-key --precmd "echo 'Setup complete'"
# Test version specifications
./target/release/iflow-cli-action --prompt "Test" --api-key test-key --gh-version "2.76.2" --iflow-version "0.2.4"# Build test image
docker build -t iflow-cli-action:test .
# Test basic functionality
docker run -e INPUT_PROMPT="Test prompt" -e INPUT_API_KEY=test-key iflow-cli-action:test
# Test with volume mounting
docker run -v $(pwd):/workspace -e INPUT_PROMPT="Analyze /workspace" -e INPUT_API_KEY=test-key -e INPUT_WORKING_DIRECTORY=/workspace iflow-cli-action:test
# Test timeout handling
docker run -e INPUT_PROMPT="Test" -e INPUT_API_KEY=test-key -e INPUT_TIMEOUT=5 iflow-cli-action:test
# Test pre-execution commands
docker run -e INPUT_PROMPT="Test" -e INPUT_API_KEY=test-key -e INPUT_PRECMD="ls -la && pwd" iflow-cli-action:test
# Test version specifications
docker run -e INPUT_PROMPT="Test" -e INPUT_API_KEY=test-key -e INPUT_GH_VERSION="2.76.2" -e INPUT_IFLOW_VERSION="0.2.4" iflow-cli-action:test# Create test workflow
name: Test iFlow CLI Action
on: [push, pull_request]
jobs:
test-action:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: ./
with:
prompt: "Test the action"
api_key: ${{ secrets.IFLOW_API_KEY }}
precmd: |
echo "Testing pre-execution"
ls -la
gh_version: "2.76.2"
iflow_version: "0.2.4"The repository includes several example workflows:
- iFlow CLI Assistant (
iflow-cli-assistant.yml): AI-powered PR and issue assistance - iFlow with MCP (
iflow-with-mcp.yml): Model Context Protocol integration - Issue Triage (
issue-triage.yaml): Automatically label new issues - Issue Killer (
issue-killer.yml): Implement features based on GitHub issues - PR Review (
pr-review.yml): Automated code review for pull requests - PR Review Killer (
pr-review-killer.yml): Direct code modifications via PR comments - Vibe Ideas (
vibe-ideas.yml): Generate project ideas and suggestions - Unit Tests (
unittest.yml): Automated testing - Release CI Image (
release-ci-image.yml): Docker image building and publishing - Deploy Homepage (
deploy-homepage.yml): Documentation deployment
- uses: iflow-ai/iflow-cli-action@main
with:
prompt: "Analyze the codebase for security issues"
api_key: ${{ secrets.IFLOW_API_KEY }}- uses: iflow-ai/iflow-cli-action@main
id: analysis
with:
prompt: "Generate comprehensive documentation"
api_key: ${{ secrets.IFLOW_API_KEY }}
model: "qwen3-coder-plus"
timeout: 7200
precmd: |
npm install
npm run build
gh_version: "2.76.2"
iflow_version: "0.2.4"
- name: Use analysis results
run: |
echo "Exit code: ${{ steps.analysis.outputs.exit_code }}"
echo "Results: ${{ steps.analysis.outputs.result }}"- Symptom: Exit code 124, execution stops abruptly
- Solution: Increase timeout value or optimize prompt
- Debug: Check step summary for timeout troubleshooting hints
- Symptom: API key invalid or missing
- Solution: Verify API key in repository secrets
- Debug: Test with minimal configuration first
- Symptom: Container fails to start
- Solution: Check Docker image availability and permissions
- Debug: Test locally with
docker run
- Symptom: Pre-execution commands fail
- Solution: Check command syntax and working directory
- Debug: Test commands in local Docker container
- Symptom: GitHub CLI or iFlow CLI version conflicts
- Solution: Use specific version parameters or default versions
- Debug: Check version compatibility matrix
Enable verbose logging by setting environment variables:
# Local debugging
export INPUT_PROMPT="Debug test"
export INPUT_API_KEY="your-key"
export GITHUB_ACTIONS="true" # Simulate GitHub Actions
./target/release/iflow-cli-action
# With specific versions for testing
export INPUT_GH_VERSION="2.76.2"
export INPUT_IFLOW_VERSION="0.2.4"- Timeout tuning: Start with shorter timeouts, increase as needed
- Model selection: Choose appropriate model for task complexity
- Pre-execution optimization: Cache dependencies when possible
- Version management: Use compatible tool versions
- API key management: Always use GitHub secrets for API keys
- Command injection: Validate all user inputs in
precmd - File permissions: Ensure proper file permissions in Docker
- Network security: Use HTTPS endpoints for API calls
- Version pinning: Pin specific versions for reproducible builds