install-script-generator

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Install Script Generator

安装脚本生成器

Generate robust, cross-platform installation scripts with automatic environment detection, verification, and documentation.
生成具备自动环境探测、验证及文档生成功能的健壮跨平台安装脚本。

Workflow

工作流程

Phase 1: Environment Exploration

第一阶段:环境探测

Gather comprehensive system information:
bash
undefined
收集全面的系统信息:
bash
undefined

Run the environment explorer script

运行环境探测脚本

python3 scripts/env_explorer.py

The script detects:
- Operating system (Windows/Linux/macOS) and version
- CPU architecture (x86_64, ARM64, etc.)
- Package managers available (apt, yum, brew, choco, winget)
- Shell environment (bash, zsh, powershell, cmd)
- Existing dependencies and versions
- User permissions (admin/sudo availability)

Output: JSON summary of system capabilities and constraints.
python3 scripts/env_explorer.py

该脚本会检测:
- 操作系统(Windows/Linux/macOS)及版本
- CPU架构(x86_64、ARM64等)
- 可用的包管理器(apt、yum、brew、choco、winget)
- Shell环境(bash、zsh、powershell、cmd)
- 已有的依赖项及版本
- 用户权限(是否拥有管理员/sudo权限)

输出:系统能力与约束的JSON摘要。

Phase 2: Installation Planning

第二阶段:安装规划

Based on the environment analysis and target software:
  1. Identify dependencies - List all required packages/libraries
  2. Check existing installations - Avoid reinstalling what exists
  3. Order operations - Resolve dependency graph
  4. Add verification steps - Each step must be verifiable
  5. Plan rollback - Define cleanup on failure
Create the plan using:
bash
python3 scripts/plan_generator.py --target "<software_name>" --env-file env_info.json
Plan structure:
yaml
target: "<software_name>"
platform: "detected_os"
steps:
  - name: "Install dependency X"
    command: "..."
    verify: "command to verify success"
    rollback: "cleanup command if failed"
  - name: "Configure system"
    command: "..."
    verify: "..."
基于环境分析结果及目标软件:
  1. 识别依赖项 - 列出所有必需的包/库
  2. 检查已安装项 - 避免重复安装已存在的内容
  3. 排序操作步骤 - 解析依赖关系图
  4. 添加验证步骤 - 每个步骤都必须可验证
  5. 规划回滚方案 - 定义失败时的清理流程
使用以下命令生成规划:
bash
python3 scripts/plan_generator.py --target "<software_name>" --env-file env_info.json
规划结构:
yaml
target: "<software_name>"
platform: "detected_os"
steps:
  - name: "安装依赖X"
    command: "..."
    verify: "验证成功的命令"
    rollback: "失败时的清理命令"
  - name: "配置系统"
    command: "..."
    verify: "..."

Phase 3: Execution

第三阶段:执行

Execute the plan with real-time verification:
bash
python3 scripts/executor.py --plan installation_plan.yaml
Execution behavior:
  • Run each step sequentially
  • Verify success after each step
  • On failure: execute rollback, report error, stop
  • Log all output for debugging
  • Generate installation report
通过实时验证执行规划:
bash
python3 scripts/executor.py --plan installation_plan.yaml
执行行为:
  • 按顺序运行每个步骤
  • 每个步骤完成后验证成功与否
  • 失败时:执行回滚、报告错误并停止
  • 记录所有输出用于调试
  • 生成安装报告

Phase 4: Documentation Generation

第四阶段:文档生成

After successful installation, generate usage documentation:
bash
python3 scripts/doc_generator.py --target "<software_name>" --plan installation_plan.yaml
Output includes:
  • Installation summary (what was installed, where)
  • Quick start guide
  • Common commands/usage examples
  • Troubleshooting tips
  • Uninstallation instructions
安装成功后,生成使用文档:
bash
python3 scripts/doc_generator.py --target "<software_name>" --plan installation_plan.yaml
输出内容包括:
  • 安装摘要(已安装内容、安装路径)
  • 快速入门指南
  • 常用命令/使用示例
  • 故障排除提示
  • 卸载说明

Output Files

输出文件

The skill generates these files in the current directory:
FileDescription
env_info.json
System environment analysis
installation_plan.yaml
Detailed installation steps
install_report.md
Execution log and status
USAGE_GUIDE.md
User documentation
该技能会在当前目录生成以下文件:
文件描述
env_info.json
系统环境分析结果
installation_plan.yaml
详细的安装步骤
install_report.md
执行日志与状态
USAGE_GUIDE.md
用户文档

Platform-Specific Notes

平台特定说明

Windows

Windows

  • Prefer
    winget
    over
    choco
    when available
  • Use PowerShell for script execution
  • Handle UAC elevation requirements
  • 当可用时,优先使用
    winget
    而非
    choco
  • 使用PowerShell执行脚本
  • 处理UAC提权要求

Linux

Linux

  • Detect distro family (Debian/RedHat/Arch)
  • Use appropriate package manager
  • Handle sudo requirements gracefully
  • 检测发行版家族(Debian/RedHat/Arch)
  • 使用对应的包管理器
  • 优雅处理sudo权限要求

macOS

macOS

  • Use Homebrew as primary package manager
  • Handle Apple Silicon vs Intel differences
  • Respect Gatekeeper and notarization
  • 使用Homebrew作为主要包管理器
  • 处理Apple Silicon与Intel架构的差异
  • 遵循Gatekeeper与公证机制

Example Usage

示例用法

User request: "Create an installation script for Node.js"
  1. Run env_explorer.py to detect system
  2. Generate plan with Node.js as target
  3. Execute plan (installs Node.js + npm)
  4. Generate USAGE_GUIDE.md with npm commands
用户请求:"为Node.js创建安装脚本"
  1. 运行env_explorer.py检测系统
  2. 以Node.js为目标生成安装规划
  3. 执行规划(安装Node.js + npm)
  4. 生成包含npm命令的USAGE_GUIDE.md

Error Handling

错误处理

  • All scripts exit with non-zero codes on failure
  • Verification failures trigger rollback
  • Detailed error messages include remediation hints
  • Partial installations are cleaned up automatically
  • 所有脚本在失败时会返回非零退出码
  • 验证失败会触发回滚
  • 详细的错误信息包含修复提示
  • 部分安装会被自动清理