跳到正文
agore-skill
教程

开发环境搭建

用 mise 安装固定版本的工具链,构建 CLI,运行测试,并通过完整的本地门禁。

在本教程中,我们将为 agore-skill 搭建一套完整的开发环境,并进行端到端 验证。完成之后,你将拥有一个构建好的二进制文件、一个全绿的测试套件,以及 与 CI 相同的本地门禁。

我们最终要达成的效果

完成本教程后,以下命令都能正常工作:

mise run build      # builds bin/agore-skill
mise run test       # unit tests pass
mise run cover      # coverage is at or above the 90.0% gate
mise run check      # the full local gate is green

前置条件

  • **mise。**只需安装一次:
curl https://mise.run | sh

仓库根目录的 mise.toml 是工具版本的单一事实来源:它固定了 Go 1.26.11、Node 24.14.0、pnpm 10.32.1、golangci-lint 2.15.0、actionlint 1.7.12、shellcheck 0.12.0、GoReleaser 2.20.3、govulncheck 1.10.0、act 0.2.87 和 VHS 0.12.1。进入仓库即会自动激活这些工具。

  • Docker,仅当你计划用 act 在本地运行 CI 时才 需要。本教程的其余内容都不需要 Docker。

安装工具链

mise run setup

setup 会运行 go mod download 和 pnpm --dir docs install --frozen-lockfile ——即 Go 与文档这两套依赖图。首次运行会下载固定版本的工具链,可能需要 几分钟。

构建 CLI

mise run build
./bin/agore-skill --help

你应该会看到六个项目命令(create、eval、init、inspect、 lint、release),以及 fang 附带的 completion 与 help 辅助命令。 mise run build 使用 -trimpath 编译到 bin/ 目录,该目录已被 gitignore。

运行测试

mise run test        # go test ./...
mise run test:race   # with the race detector
mise run vet         # go vet

检查覆盖率

mise run cover

cover 会运行 scripts/coverage.sh:以原子方式生成覆盖率 profile 并执行 测试,然后进行门禁检查,当总语句覆盖率低于 90.0% 时判定失败(可通过 COVERAGE_MIN 覆盖)。门槛本身才是契约;脚本会打印当前的总数。

运行 linter 与安全扫描

mise run lint        # golangci-lint, actionlint, shellcheck, goreleaser check
mise run security    # govulncheck ./...

运行端到端生命周期

mise run e2e

e2e 会将二进制文件构建到临时目录,并在其中驱动完整的生命周期—— init、create、inspect、lint --strict、release --snapshot ——然后校验归档内容与校验和,确认 SKILL.md 未被改动,也没有任何内容 泄漏到仓库中。

把所有内容组合起来

mise run ci      # build, vet, test, test:race, cover
mise run check   # ci + lint + security + docs:build + e2e

check 是一个 pull request 必须通过的门禁——此外,如果条件允许,再用 act 实际运行一次真实 的工作流。

后续步骤

本页目录