十年匠心定制 · 商业建站与技术教学双线并行 咨询热线:400-886-1026 service@lmnt.cn
ARTICLE DETAIL

资讯详情

深耕网站建设与运营推广的一线实战洞察。

spec-kit 安装实战指南:双渠道安装 specify CLI、init 参数详解与离线部署

spec-kit 安装实战指南:双渠道安装 specify CLI、init 参数详解与离线部署 spec-kit 安装实战指南双渠道安装 specify CLI、init 参数详解与离线部署【免费下载链接】spec-kit Toolkit to help you get started with Spec-Driven Development项目地址: https://gitcode.com/GitHub_Trending/sp/spec-kit本文围绕 spec-kit 仓库的安装指南展开覆盖前置条件、从 GitHub 源码与 PyPI 两条官方渠道安装specifyCLI、一次性uvx运行、specify init的集成/脚本类型等关键参数以及企业离线环境的 wheel 打包部署。读完后你可以完成一次可验证的完整安装并能针对 CI、代理环境或 air-gapped 环境选择正确的安装路径并理解这些安装行为背后的源码实现。前置条件在安装之前确认本地环境满足以下条件引自 docs/installation.md依赖说明操作系统Linux/macOS或 Windows现已支持原生 PowerShell 脚本无需 WSLAI 编码代理Claude Code、GitHub Copilot、CodeBuddy CLI、Gemini CLI、Pi Coding Agent 或 Oh My Pi 等任一包管理工具uv推荐或 pipx 用于持久化安装Python3.11pyproject.toml 中requires-python 3.11明确了该下限Git可选——仅在启用 git 扩展时需要Python 版本要求可以直接在构建配置中得到印证pyproject.toml 声明requires-python 3.11包名为specify-cli入口命令由[project.scripts]一节注册specify specify_cli:main。这意味着无论走哪条安装渠道最终暴露到 PATH 的都是同一个specify命令。运行时依赖同样定义在 pyproject.toml 中包括typer、click、rich、pyyaml、packaging、pathspec、json5等——这也是离线安装时需要一并下载的依赖集合见后文 air-gapped 章节。两条官方分发渠道spec-kit 通过两个官方渠道分发均由维护者发布和维护GitHub 源码仓库github/spec-kit——源码安装可精确锁定到某个 release tagPyPI 上的specify-cli包——用常规 Python 工具链安装。两条路线对常规安装均受支持。安装后运行specify version作为本地版本/运行时健全性检查它能确认specify命令可用并报告版本号但不能证明可执行文件来自 PyPI 还是 GitHub。这个语义在源码中同样成立——version命令定义在 src/specify_cli/init.py。此外从本仓库本地构建的 wheel 在离线/air-gapped 环境中同样是合法的产物。如果你需要确认安装来源可以检查包管理器记录的元数据pipx list --json会报告每个工具的完整安装规格对 uv/pip 安装可查看其*.dist-info目录中的 PEP 610direct_url.json——Git 或 URL 安装会在那里记录仓库/归档 URL而普通 PyPI 索引安装则不会生成该文件。详见 PyPI 安装指南。渠道一从源码安装推荐锁定 release tag一次性安装、处处可用。将vX.Y.Z替换为某个 release tag——必须保留前导v例如v0.12.11而不是0.12.11uv tool install specify-cli --from githttps://github.com/github/spec-kit.gitvX.Y.Z该命令依赖 uv。如果看到command not found: uv先按 uv 安装指南 安装 uvmacOS/Linux 官方脚本、HomebrewWindows 的 WinGet/Scoop 均可。安装后初始化项目specify init PROJECT_NAME --integration copilot如果不锁定 tag使用githttps://github.com/github/spec-kit.git不带vX.Y.Z得到的是main分支的最新代码可能包含未发布变更——生产环境建议始终锁 tag。渠道二从 PyPI 安装spec-kit 同时以specify-cli包发布到 PyPI无需引用 Git URL用你惯用的 Python 工具安装即可引自 docs/install/pypi.md# Using uv (recommended) uv tool install specify-cli # Or using pipx pipx install specify-cli # Or using pip pip install specify-cli锁定特定版本为可复现的安装固定精确版本PyPI 上的版本号与 GitHub release tag 对应例如 PyPI0.12.11对应 tagv0.12.11注意 PyPI 命令中不带v# Using uv uv tool install specify-cli0.12.11 # Or using pipx pipx install specify-cli0.12.11 # Or using pip pip install specify-cli0.12.11从自定义或私有包索引安装企业网络、镜像、代理或制品库环境常需要从非公共 PyPI 的索引安装各工具都提供了指向其他索引的方式# uv — via environment variable (applies to the whole command) UV_DEFAULT_INDEXhttps://your-index.example.com/pypi/simple/ uv tool install specify-cli # uv — via flag uv tool install --default-index https://your-index.example.com/pypi/simple/ specify-cli # pipx — pass a pip argument through pipx install specify-cli --index-url https://your-index.example.com/pypi/simple/ # pip pip install specify-cli --index-url https://your-index.example.com/pypi/simple/同一索引配置对锁定版本安装、升级--force/--upgrade和一次性使用同样适用。如果索引需要认证建议使用凭据环境变量、keyring 或 netrc避免把密钥直接写进命令行 URL可能经 shell 历史、进程列表或日志泄漏。升级与卸载升级通过当初使用的同一工具重新安装完成。注意如果最初锁定了版本uv tool upgrade会保留该 pin要升级到最新 PyPI 版本使用不带 pin 的安装命令# Using uv uv tool install --force specify-cli # Or using pipx pipx install --force specify-cli # Or using pip pip install --upgrade specify-cli# Using uv uv tool uninstall specify-cli # Or using pipx pipx uninstall specify-cli # Or using pip pip uninstall specify-cli注意specify self upgrade目前是从 GitHub 源码 release URL 重建uv tool与pipx安装而不会保留基于 PyPI 的安装方式。如果想留在 PyPI 渠道请使用上面的包管理器命令裸pip install specify-cli属于非托管安装用pip install --upgrade specify-cli升级。详见 升级指南。pipx 从 Git 安装替代渠道pipx 指南 还演示了用 pipx 直接从 Git 安装的路径# Install a specific stable release (recommended — 保留前导 v) pipx install githttps://github.com/github/spec-kit.gitvX.Y.Z # Or install latest from main (may include unreleased changes) pipx install githttps://github.com/github/spec-kit.git升级pipx install --force githttps://github.com/github/spec-kit.gitvX.Y.Z。一次性使用uvx如果想在不永久安装的情况下试用 spec-kit可以用uvx直接运行工具会下载到临时环境命令结束后即被丢弃引自 docs/install/one-time.md# Create a new project (latest from main) uvx --from githttps://github.com/github/spec-kit.git specify init PROJECT_NAME # Or target a specific release (保留前导 v) uvx --from githttps://github.com/github/spec-kit.gitvX.Y.Z specify init PROJECT_NAME # Initialize in the current directory uvx --from githttps://github.com/github/spec-kit.git specify init . --integration copilot # Or use the --here flag uvx --from githttps://github.com/github/spec-kit.git specify init --here --integration copilot如果你计划长期使用持久化安装更合适工具常驻 PATH、每次调用不用重新下载并可用uv tool list/uv tool upgrade/uv tool uninstall管理。specify init关键参数详解安装完成后specify init是把 spec-kit 骨架落到项目里的入口。以下参数说明完整继承自 docs/installation.md并结合 src/specify_cli/commands/init.py 中的命令签名做了补充。指定编码代理集成--integration交互式终端会在初始化过程中提示你选择编码代理集成非交互会话如 CI 或管道运行在未传--integration时默认使用 GitHub Copilot。这一点在源码中可以直接确认src/specify_cli/_agent_config.py 定义DEFAULT_INIT_INTEGRATION copilot且 resolve_default_init_integration 支持通过环境变量SPECKIT_INTEGRATION_DEFAULT覆盖该回退值——当该变量指向一个已注册的集成键时生效取值无效时会向 stderr 输出警告而非静默回退。也可以在初始化时主动指定specify init project_name --integration claude specify init project_name --integration gemini specify init project_name --integration copilot specify init project_name --integration codebuddy specify init project_name --integration pi specify init project_name --integration omp传入了未知集成名时CLI 会报错并列出INTEGRATION_REGISTRY中全部可用键见 init.py。此外还有一个generic集成用于自带代理场景但它必须搭配--integration-options提供--commands-dir否则直接报错退出见 init.pyspecify init my-project --integration generic --integration-options--commands-dir .myagent/commands/指定脚本类型--script自动化脚本提供 Bash.sh、PowerShell.ps1与 Python.py三种变体。自动行为Windows 默认ps其他系统默认sh交互模式下若不传--script会弹出选择提示强制指定脚本类型specify init project_name --script sh specify init project_name --script ps specify init project_name --script py源码中对应的默认值逻辑是 init.py 的default_script ps if os.name nt else sh合法取值集合定义在 src/specify_cli/_agent_config.pysh POSIX Shell、ps PowerShell、py Python传非法值会立即报错并列出可选值。跳过代理工具检查--ignore-agent-tools如果你只想拿到模板、不想检查目标代理工具是否已安装specify init project_name --integration claude --ignore-agent-tools从源码看只有当所选集成的配置标记了requires_cli时才会执行工具探测check_tool实现位于 src/specify_cli/_utils.py探测失败会打印安装提示并以非零码退出--ignore-agent-tools可整体跳过该检查。其余常用选项源码中确认除文档主体列出的参数外init命令签名中还包含以下选项在 CI 或脚本化场景中很有用选项作用--here/.在当前目录初始化而不是新建目录--force使用--here或目录已存在时跳过确认、直接合并/覆盖--non-interactive绝不提示未指定的选择用文档默认值无安全默认值时失败而非挂起。专为分配了 PTY 但不能发送方向键输入的 Agent harness 设计--preset id初始化时顺带安装 preset--extension spec初始化时安装扩展内置名称、本地路径或 HTTPS URL可重复--trust-extension-urls预授权 URL 扩展安装跳过交互信任提示非交互 URL 安装必需从源码结构看URL 形式的扩展安装采用默认拒绝策略init.py 中交互式会话会逐个弹出 Untrusted Source 确认框非交互会话下未确认的 URL 一律被拒除非传了--trust-extension-urls。空目录初始化失败时还会自动清理已创建的项目目录init.py不会留下半成品。安装验证安装后运行specify version它确认specify命令可用且报告预期版本如前所述它不能区分可执行文件来自 PyPI 还是 GitHub。保持更新定期运行specify self check了解是否有新版本可用——它是只读操作绝不修改你的安装。准备升级时按 升级指南 操作。初始化之后你的编码代理中应能看到以下命令/speckit.specify— 创建规格说明/speckit.plan— 生成实现计划/speckit.tasks— 拆解为可执行任务/speckit.implement— 执行实现任务/speckit.analyze— 校验跨产物一致性/speckit.clarify— 识别并消解歧义/speckit.checklist— 生成质量检查清单/speckit.constitution— 创建或更新项目原则/speckit.converge— 对照产物评估代码库并追加剩余任务/speckit.taskstoissues— 将任务转换为 issue脚本会安装到与所选脚本类型匹配的变体子目录.specify/scripts/bash/— 包含.sh脚本Linux/macOS 默认.specify/scripts/powershell/— 包含.ps1脚本Windows 默认.specify/scripts/python/— 包含.py脚本通过--script py选择同时安装平台 shell 回退对应的源脚本在仓库中就是 scripts/bash、scripts/powershell 与 scripts/python 三个目录。故障排查企业 / Air-Gapped 安装如果环境禁止访问 PyPI 或 GitHub可以在联网机器上构建可移植的 wheel 包再转移到 air-gapped 目标机引自 docs/install/air-gapped.md。Step 1在联网机器上构建 wheel重要pip download会解析平台相关的 wheel例如 PyYAML 含原生扩展。必须在与目标机相同 OS 和 Python 版本的机器上执行此步要支持多平台时需在每种目标 OSLinux、macOS、Windows与 Python 版本上重复执行。# Clone the repository git clone https://github.com/github/spec-kit.git cd spec-kit # Build the wheel pip install build python -m build --wheel --outdir dist/ # Download the wheel and all its runtime dependencies pip download -d dist/ dist/specify_cli-*.whlStep 2将整个dist/目录含specify-cliwheel 与全部依赖 wheel通过 USB、网络共享或其他批准方式复制到目标机。Step 3在 air-gapped 机器上安装pip install --no-index --find-links./dist specify-cliStep 4初始化项目—— 无需网络访问默认使用内置资源specify init my-project --integration copilot要求 Python 3.11。 Windows 注意离线脚手架需要 PowerShell 7pwsh不支持 Windows PowerShell 5.xpowershell.exe。这条无网络初始化能力的来源可以从构建配置中确认pyproject.toml 的force-include一节把templates/、scripts/、内置扩展git、agent-context、assess、bug、内置 workflowspeckit与内置 presetlean、constitution-sync全部打包进specify_cli/core_pack/注释明确写着 Bundle core assets sospecify initworks without network access (air-gapped / enterprise)。init命令的文档字符串也说明了这一点项目文件由包内内置资源脚手架生成初始化不需要网络且模板版本与所装 CLI 版本一致。相关契约测试见 tests/contract/test_wheel_core_pack_scripts.py 与 tests/contract/test_wheel_bundled_presets.py用于保证 wheel 中的内置资源完整可用。Linux 上的 Git Credential Manager如果在 Linux 上遇到 Git 认证问题可以安装 Git Credential Manager#!/usr/bin/env bash set -e echo Downloading Git Credential Manager v2.6.1... wget https://github.com/git-ecosystem/git-credential-manager/releases/download/v2.6.1/gcm-linux_amd64.2.6.1.deb echo Installing Git Credential Manager... sudo dpkg -i gcm-linux_amd64.2.6.1.deb echo Configuring Git to use GCM... git config --global credential.helper manager echo Cleaning up... rm gcm-linux_amd64.2.6.1.deb小结如何选择安装路径场景推荐路径日常开发、需要可复现版本uv tool install specify-cli --from git...vX.Y.Z锁 tag保留v不想引用 Git URL、有 PyPI 访问权uv tool install specify-cli可加版本固定临时试用uvx --from git... specify init PROJECTCI / 脚本化、Agent harness追加--non-interactive必要时--force、显式--integration企业内网 / 代理自定义索引UV_DEFAULT_INDEX/--index-url完全离线同平台构建 wheel pip install --no-index --find-links./dist无论走哪条路径装完都先跑specify version做本地验证再按 快速上手 初始化第一个项目。【免费下载链接】spec-kit Toolkit to help you get started with Spec-Driven Development项目地址: https://gitcode.com/GitHub_Trending/sp/spec-kit创作声明:本文部分内容由AI辅助生成(AIGC),仅供参考
返回列表