bot-forge 1.0.2

Rust CLI for installing agent skills and developer tools from configurable forms.
Documentation
# 使用 rust-dev 内置目录作为基础,再由本文件覆盖版本、镜像和组件配置。
catalog = "rust-dev"

# 集中固定工具链版本,后续可通过 toolchain-ref = "rust" 引用。
versions = { rust = "1.89.0" }

# 允许执行证书安装、npm 离线包安装等 shell 命令。
[policy]
allow_shell = true

# Ubuntu APT 镜像:安装系统包前生成 Deb822 软件源文件。
# 将“镜像仓地址待填写”替换为实际镜像站域名或 IP,保留 /ubuntu 路径。
[apt_mirror]
uri = "https://镜像仓地址待填写/ubuntu"
suites = [
  "{codename}",
  "{codename}-updates",
  "{codename}-security",
]
components = [
  "main",
  "restricted",
  "universe",
  "multiverse",
]
architectures = ["{architecture}"]
signed_by = "/usr/share/keyrings/ubuntu-archive-keyring.gpg"
source_file = "/etc/apt/sources.list.d/bot-forge.sources"

# Linux 安装前置检查:访问检测地址,成功则跳过证书安装。
[preflight.certificate]
platforms = ["linux-*"]

[preflight.certificate.detect]
kind = "command"
program = "curl"
args = [
  "--silent",
  "--show-error",
  "--location",
  "--output",
  "/dev/null",
  "--connect-timeout",
  "10",
  "--max-time",
  "30",
  "https://镜像仓地址待填写/certificate/health",
]
timeout_secs = 40

# 检测失败时下载并执行证书安装脚本,退出时自动删除临时文件 aaa。
[preflight.certificate.install]
backend = "shell"
resources = ["network", "system-certificate-store"]
timeout_secs = 300
inactivity_timeout_secs = 120
command = """
set -eu
trap 'rm -f aaa' EXIT
curl -k -o aaa "https://镜像仓地址待填写/certificate/aaa"
chmod +x aaa
./aaa install
"""

# bot-forge 管理的通用可执行文件目录。
[environment.paths]
managed-bin = "$BOT_FORGE_HOME/bin"

# Node.js 可执行文件目录(Linux)。
[[environment.mutations]]
id = "node-bin"
kind = "path-prepend"
value = "$BOT_FORGE_HOME/node/bin"
scope = "user"
platforms = ["linux-*"]

# Node.js 可执行文件目录(Windows)。
[[environment.mutations]]
id = "node-bin-windows"
kind = "path-prepend"
value = "$BOT_FORGE_HOME/node"
scope = "user"
platforms = ["windows-*"]

# Cargo 用户命令目录(Linux/Windows)。
[[environment.mutations]]
id = "cargo-bin"
kind = "path-prepend"
value = "$HOME/.cargo/bin"
scope = "user"
platforms = ["linux-*", "windows-*"]

# Python winget 默认安装目录(Windows),确保同一次安装中的 uv 能立即调用 Python。
[[environment.mutations]]
id = "python-bin-windows"
kind = "path-prepend"
value = "$HOME/AppData/Local/Programs/Python/Python312"
scope = "user"
platforms = ["windows-*"]

[[environment.mutations]]
id = "python-scripts-windows"
kind = "path-prepend"
value = "$HOME/AppData/Local/Programs/Python/Python312/Scripts"
scope = "user"
platforms = ["windows-*"]

# uv 虚拟环境命令目录(Linux/macOS)。
[[environment.mutations]]
id = "uv-bin"
kind = "path-prepend"
value = "$BOT_FORGE_HOME/python-tools/uv/bin"
scope = "user"
platforms = ["linux-*", "macos-*"]

# uv 虚拟环境命令目录(Windows)。
[[environment.mutations]]
id = "uv-bin-windows"
kind = "path-prepend"
value = "$BOT_FORGE_HOME/python-tools/uv/Scripts"
scope = "user"
platforms = ["windows-*"]

# Rustup 自更新文件镜像地址。
[[environment.mutations]]
id = "rustup-update-root"
kind = "variable"
name = "RUSTUP_UPDATE_ROOT"
value = "https://镜像仓地址待填写/rustup"
scope = "user"
platforms = ["linux-*", "windows-*"]

# Rust 工具链、标准库和组件下载镜像地址。
[[environment.mutations]]
id = "rustup-dist-server"
kind = "variable"
name = "RUSTUP_DIST_SERVER"
value = "https://镜像仓地址待填写/rustup-dist"
scope = "user"
platforms = ["linux-*", "windows-*"]

# Cargo crates.io 镜像:写入用户的 .cargo/config.toml。
# sparse 仓库地址通常必须以 / 结尾。
[[environment.mutations]]
id = "cargo-registry-mirror"
kind = "file-fragment"
path = ".cargo/config.toml"
platforms = ["linux-*", "windows-*"]
lines = [
  "[source.crates-io]",
  "replace-with = \"bot-forge-mirror\"",
  "[source.bot-forge-mirror]",
  "registry = \"sparse+https://镜像仓地址待填写/cargo/index/\"",
]

# npm registry:供 npm、tsx、OpenSpec 和 GitNexus 依赖解析使用。
[[environment.mutations]]
id = "npm-registry"
kind = "file-fragment"
path = ".npmrc"
platforms = ["linux-*", "windows-*"]
lines = [
  "registry=https://镜像仓地址待填写/npm/",
]

# 组件分组:profile 通过 group:<名称> 一次引用一组工具。
[groups]
# 日常编译与开发工具。
daily-development = [
  "git",
  "cmake",
  "ninja",
  "python",
  "llvm-toolchain",
  "rust-analyzer",
  "rust-src",
  "miri",
  "cargo-fuzz",
  "nodejs",
  "tsx",
  "openspec",
]
# 代码质量、测试、审计和项目辅助工具。
quality-checks = [
  "cargo-expand",
  "cargo-nextest",
  "cargo-audit",
  "cargo-deny",
  "cargo-geiger",
  "cargo-llvm-cov",
  "bot-gate",
  "bot-metric",
  "cargo-valgrind",
]
# 高级分析工具。
advanced-analysis = [
  "bindgen-cli",
]
# 开发自动化工具。
developer-automation = [
  "uv",
  "project-brain",
  "gitnexus",
]

# 安装等级:后一级继承前一级,advanced 是当前配置的完整安装等级。
[profiles.minimal]
components = ["rust-build-base", "rust-toolchain", "rust-bot"]

[profiles.standard]
inherits = ["minimal"]
components = ["group:daily-development", "group:quality-checks"]

[profiles.advanced]
inherits = ["standard"]
components = ["group:advanced-analysis", "group:developer-automation"]

# 操作系统包管理器安装项:按平台选择 apt、winget 或 brew。
[package-tools]
# Rust/C/C++ 编译所需的基础工具和系统库。
rust-build-base = { detect = ["dpkg", "-s", "build-essential", "pkg-config", "libssl-dev"], apt = ["build-essential", "pkg-config", "libssl-dev"], apt_update = true, provides = ["rust-build-base"], winget = "Microsoft.VisualStudio.2022.BuildTools", winget_detect = ["winget", "list", "--exact", "--id", "Microsoft.VisualStudio.2022.BuildTools"], winget_arguments = ["--override", "--quiet --wait --norestart --add Microsoft.VisualStudio.Workload.VCTools --includeRecommended"], brew = ["pkgconf", "openssl@3"], brew_detect = [["xcrun", "--find", "clang"], ["brew", "list", "--versions", "pkgconf", "openssl@3"]] }
# Python、pip 和 venv;uv 的 pip 安装依赖此组件。
python = { detect = ["python3", "-c", "import sys, pip; print(sys.version.split()[0]); raise SystemExit(0 if sys.version_info >= (3, 11) else 1)"], apt = ["python3", "python3-pip", "python3-venv"], winget = "Python.Python.3.12", winget_detect = ["python", "-c", "import sys, pip; print(sys.version.split()[0]); raise SystemExit(0 if sys.version_info >= (3, 11) else 1)"], brew = ["python@3.12"] }
# 通用源码管理与构建工具。
git = { detect = ["git", "--version"], apt = ["git"], apt_update = true, winget = "Git.Git", brew = ["git"] }
cmake = { detect = ["cmake", "--version"], apt = ["cmake"], apt_update = true, winget = "Kitware.CMake", brew = ["cmake"] }
ninja = { detect = ["ninja", "--version"], apt = ["ninja-build"], winget = "Ninja-build.Ninja", brew = ["ninja"] }
valgrind = { detect = ["valgrind", "--version"], apt = ["valgrind"] }
# LLVM、Clang、libclang 和二进制分析工具。
llvm-toolchain = { detect = ["dpkg", "-s", "clang", "llvm", "libclang-dev", "binutils"], apt = ["clang", "llvm", "libclang-dev", "binutils"], apt_update = true, winget = "LLVM.LLVM", winget_detect = [["where", "clang"], ["where", "llvm-nm"], ["where", "llvm-config"], ["where", "libclang.dll"]], brew = ["llvm"], brew_detect = ["brew", "list", "--versions", "llvm"] }

# Rustup 安装项:负责 Rust 工具链及官方组件。
[rustup-tools]
rust-analyzer = "rust-analyzer"

# 固定 Rust 版本并安装 rustfmt、clippy;bootstrap 是首次下载 rustup-init 的地址。
[rustup-tools.rust-toolchain]
requires = ["capability:rust-build-base"]
provides = ["cargo", "rustup"]
detect = [
  ["rustc", "+1.89.0", "--version"],
  ["cargo", "+1.89.0", "--version"],
  ["rustfmt", "+1.89.0", "--version"],
  ["cargo", "+1.89.0", "clippy", "--version"],
]
toolchain-ref = "rust"
components = ["rustfmt", "clippy"]
default = true

[rustup-tools.rust-toolchain.bootstrap]
url = "https://镜像仓地址待填写/rustup/archive/1.28.2/{target}/rustup-init{exe}"

# 更换 rustup-init 文件后必须同步更新对应平台的 SHA-256。
[rustup-tools.rust-toolchain.bootstrap.sha256]
linux-x86_64-gnu = "20a06e644b0d9bd2fbdbfd52d42540bdde820ea7df86e92e533c073da0cdd43c"
linux-aarch64-gnu = "e3853c5a252fca15252d07cb23a1bdd9377a8c6f3efa01531109281ae47f841c"
windows-x86_64-msvc = "88d8258dcf6ae4f7a80c7d1088e1f36fa7025a1cfd1343731b4ee6f385121fc0"
windows-aarch64-msvc = "de9f7d29ccd39efa59a3dda3ec363b396e09b92681229b9b8f6aaa4c84285e9c"
macos-x86_64 = "71c3d31f59109831012c6e1c71a4f0f6f9a207efe8256f46bccb74d756e8960e"
macos-aarch64 = "dc09f17d99c16582821598c68f1198c7e249a9d7df14e01809e892dc0e8cc761"

# 附加 Rustup 组件。
[rustup-tools.llvm-tools-preview]
components = ["llvm-tools-preview"]
toolchain-ref = "rust"
detect = ["rustup", "component", "list", "--installed", "--toolchain", "1.89.0"]
detect-stdout-contains = "llvm-tools"

[rustup-tools.rust-src]
components = ["rust-src"]
toolchain = "nightly"
detect = ["rustup", "component", "list", "--installed", "--toolchain", "nightly"]
detect-stdout-contains = "rust-src"

[rustup-tools.miri]
components = ["miri"]
toolchain = "nightly"
requires = ["rust-src"]
detect = ["cargo", "+nightly", "miri", "--version"]

# Cargo 安装项:使用指定 Rust 工具链安装固定版本的 CLI。
[cargo-tools]
cargo-audit = { version = "0.22.2", toolchain = "1.89.0" }
cargo-deny = { version = "0.20.2", toolchain = "1.89.0" }
cargo-geiger = { version = "0.13.0", toolchain = "1.89.0" }
cargo-expand = { version = "1.0.126", toolchain = "1.89.0" }
cargo-fuzz = { version = "0.13.1", toolchain = "1.89.0" }
cargo-nextest = { version = "0.9.120", toolchain = "1.89.0" }
cargo-llvm-cov = { version = "0.9.0", toolchain = "1.89.0", requires = ["llvm-tools-preview"] }
# 已发布工具直接从 Cargo registry 安装。
bot-gate = { version = "1.2.1", toolchain = "1.89.0" }
bot-metric = { version = "1.2.0", toolchain = "1.89.0" }
# 未发布工具仍从内部 Git 镜像按固定提交安装。
bot-compass = { version = "1.0.0", toolchain = "1.89.0", source = "https://镜像仓地址待填写/git/xuanwu/bot-compass.git", revision = "6916eabc4e0c57d3fcdacb25fc092cb63bcbcdbf", requires = ["git"] }
rust-bot = { version = "2.0.0", crate = "rust-bot", bin = "rust-bot", detect = ["rust-bot", "--version"], toolchain = "1.89.0" }
# --version is forwarded to Cargo; --help reports cargo-valgrind's own version.
cargo-valgrind = { version = "2.4.1", toolchain = "1.89.0", detect = ["cargo", "valgrind", "--help"], platforms = ["linux-*"], requires = ["valgrind"] }
bindgen-cli = { version = "0.72.1", toolchain = "1.89.0", bin = "bindgen" }

# uv:由 Python/pip 安装到 bot-forge 独立环境,避免污染系统 Python。
[[components]]
id = "uv"
allow_insecure_hosts = ["*"]
requires = ["python"]
provides = ["uv"]
detect = { kind = "command", program = "uv", args = ["--version"] }
install = { backend = "pip", package = "uv", version = "0.12.3", python = "python3", environment = "$BOT_FORGE_HOME/python-tools/uv", index = "https://镜像仓地址待填写/pypi/simple" }

# Windows 使用 python 命令,其余安装参数与主变体一致。
[[components.variants]]
id = "windows-python"
platforms = ["windows-*"]
install = { backend = "pip", package = "uv", version = "0.12.3", python = "python", environment = "$BOT_FORGE_HOME/python-tools/uv", index = "https://镜像仓地址待填写/pypi/simple" }

# Project Brain:跨平台 Wheel 内置 INT8 模型,原生依赖由内网 Python 镜像按系统和架构解析。
# 当前依赖集支持 Linux x86_64/ARM64、Windows x86_64 和 macOS x86_64/ARM64;暂不支持 Windows ARM64。
[[components]]
id = "project-brain"
allow_insecure_hosts = ["*"]
requires = ["capability:uv"]
platforms = ["linux-x86_64-gnu", "linux-aarch64-gnu", "windows-x86_64-msvc", "macos-*"]
detect = { kind = "command", program = "project-brain", args = ["--version"], stdout_contains = "project-brain 0.6.0" }
install = { backend = "uv-tool", package = "https://镜像仓地址待填写/project-brain/project_brain-0.6.0-py3-none-any.whl", bins = ["project-brain"], force = true, index = "https://镜像仓地址待填写/pypi/simple" }

# Node.js:Linux 和 Windows 均使用镜像中的固定版本预编译归档。
[[components]]
id = "nodejs"
platforms = ["linux-x86_64-gnu"]
detect = { kind = "command", program = "node", args = ["-e", "const [major] = process.versions.node.split('.').map(Number); if (major < 22) process.exit(1); console.log(process.version)"] }
install = { backend = "archive", url = "https://镜像仓地址待填写/nodejs/v22.22.0/node-v22.22.0-linux-x64.tar.xz", sha256 = "9aa8e9d2298ab68c600bd6fb86a6c13bce11a4eca1ba9b39d79fa021755d7c37", format = "tar_xz", target = "$BOT_FORGE_HOME/node", strip_components = 1, allow_links = true }

# Linux ARM64 归档变体。
[[components.variants]]
id = "linux-aarch64"
platforms = ["linux-aarch64-gnu"]
install = { backend = "archive", url = "https://镜像仓地址待填写/nodejs/v22.22.0/node-v22.22.0-linux-arm64.tar.xz", sha256 = "1bf1eb9ee63ffc4e5d324c0b9b62cf4a289f44332dfef9607cea1a0d9596ba6f", format = "tar_xz", target = "$BOT_FORGE_HOME/node", strip_components = 1, allow_links = true }

[[components.variants]]
id = "windows-x86-64"
platforms = ["windows-x86_64-msvc"]
install = { backend = "archive", url = "https://镜像仓地址待填写/nodejs/v22.22.0/node-v22.22.0-win-x64.zip", sha256 = "c97fa376d2becdc8863fcd3ca2dd9a83a9f3468ee7ccf7a6d076ec66a645c77a", format = "zip", target = "$BOT_FORGE_HOME/node", strip_components = 1 }

# GitNexus:按系统/架构选择内部服务器上的 npm 离线包。
[[components]]
id = "gitnexus"
requires = ["nodejs"]
platforms = ["linux-x86_64-gnu", "linux-aarch64-gnu", "windows-x86_64-msvc"]
detect = { kind = "command", program = "gitnexus", args = ["--version"] }

[[components.variants]]
id = "linux-x86-64"
platforms = ["linux-x86_64-gnu"]

[components.variants.install]
backend = "shell"
command = "npm install -g --no-audit --no-fund -- \"https://镜像仓地址待填写/gitnexus/gitnexus-linux-x64-1.6.8.tgz\""
resources = ["network", "package-manager:npm"]
timeout_secs = 600
inactivity_timeout_secs = 300

[[components.variants]]
id = "linux-arm64"
platforms = ["linux-aarch64-gnu"]

[components.variants.install]
backend = "shell"
command = "npm install -g --no-audit --no-fund -- \"https://镜像仓地址待填写/gitnexus/gitnexus-linux-arm64-1.6.8.tgz\""
resources = ["network", "package-manager:npm"]
timeout_secs = 600
inactivity_timeout_secs = 300

[[components.variants]]
id = "windows-x86-64"
platforms = ["windows-x86_64-msvc"]

[components.variants.install]
backend = "shell"
command = "npm install -g --no-audit --no-fund -- \"https://镜像仓地址待填写/gitnexus/gitnexus-win32-x64-1.6.8.tgz\""
resources = ["network", "package-manager:npm"]
timeout_secs = 600
inactivity_timeout_secs = 300

# tsx:通过 npm registry 安装固定版本。
[[components]]
id = "tsx"
requires = ["nodejs"]
detect = { kind = "command", program = "tsx", args = ["--version"] }
install = { backend = "npm", package = "tsx", version = "4.23.5" }

# OpenSpec:通过 npm registry 安装固定版本。
[[components]]
id = "openspec"
requires = ["nodejs"]
detect = { kind = "command", program = "openspec", args = ["--version"] }
install = { backend = "npm", package = "@fission-ai/openspec", version = "1.8.0" }