商业产业 Hacker News AI 2026-07-04T20:27 正文 ok 717 words

🔶 Speck:受编译器和构建工具启发的 AI 规格驱动代理

英文标题:🔶 Speck – AI spec-driven agents, inspired by compilers and build tools

Speck 是一个规格驱动的代理编译器,提供简单命令管理完整的智能体流程,支持可复现与可验证的代码生成,将传统聊天界面移至幕后。它采用三层架构(功能规格/技术规格/代码),使用 BLAKE3 哈希检测变更并实现双向同步,可迁移现有项目,并内置冲突解决、代码审查、Git 钩子和技术栈切换等功能。Speck 基于 zerostack,通过专用提示(prompts)在规格与代码之间传播更新,对追求严谨、可审计开发流程的团队具有重要价值。项目以 GPL-3.0-only 许可发布,提供预编译二进制文件。
打开原文相关 3 · 机会 2
media59.7 KB media37.9 KB

中文

横幅图片


规格驱动的代理编译器:使用简单命令完成完整的代理管理,支持可复现且可验证的代码生成,将传统聊天界面移至幕后。

注意: speck 基于 zerostack,并需要可工作的 zerostack 二进制文件位于 PATH 中。

  • 三层架构:specs/features/(做什么)→ specs/technical/(怎么做)→ src/(代码)。编辑任一层,其他层保持同步。
  • 双向同步:speck apply 通过 BLAKE3 哈希检测变更,并使用专门的 AI 提示在层之间传播更新。
  • 从现有项目迁移:speck migrate 从任意代码库反向生成 specs/technical/,再从中衍生出 specs/features/。
  • 脚手架:speck init 引导创建新项目,包含规范的 AGENTS.md、ARCHITECTURE.md 和提示模板。
  • 冲突解决:当代码和规格都被编辑时,speck 会提示选择优先级(或使用 --prefer-code / --prefer-specs)。
  • 代码审查:speck review 通过专用提示执行全面、结构化的审查,输出 Markdown 报告。
  • Git 钩子:speck git-hooks 安装 pre-commit、pre-push、post-merge 和 post-checkout 钩子,自动运行 speck apply、speck fmt 或 speck status。
  • 技术栈切换:speck switch-lang 破坏性地更改语言/框架,并从功能规格重新构建所有内容。
  • 文件管理:speck mv 和 speck rm 移动或删除文件,同时保持哈希数据库同步。
  • 变更检测:speck status 列出按层分组的已编辑和未注册文件。

你可以从 Github releases 下载预编译二进制文件。

git clone https://github.com/gi-dellav/speck.git
cd speck
cargo install --path .


# 确保 zerostack 已安装并配置
zerostack --version

# 搭建新的 speck 项目
speck init

# 或迁移现有代码库
speck migrate

# 在规格和代码之间同步编辑
speck apply

# 检查发生了什么变化
speck status

# 完整代码审查
speck review --output report.md

Speck 从项目根目录读取 Speck.toml:

字段 描述
name 项目名称(默认为目录名称)
source_dir 源代码目录(默认为 src)
model 可选的默认模型
features_dir 高级规格的可选替代路径
fmt_cmd 可选的格式化命令
test_cmd 可选的测试命令

Speck 维护一个三层架构,每一层都是同一产品的不同表示:

层 位置 内容 受众
功能 specs/features/ 高层次、非技术性——用户故事、验收条件 产品经理、利益相关者
技术 specs/technical/ 低层次——如何实现以及为什么,与源文件 1:1 映射 开发者
源代码 src/(可配置) 实际代码 编译器

speck apply 运行一个 4 步管道:

  1. 检测变更——将当前 BLAKE3 哈希与 .speck_hash.toml 进行比较
  2. feat2tech——将功能规格编辑向下传播到技术规格
  3. tech2code——将技术规格编辑向下传播到源代码
  4. code2tech——将源代码编辑向上传播到技术规格

每一步都使用专门的 zerostack 提示,并设置适当的温度(确定性更新为 0,创造性规格扩展则更高)。

当源文件及其对应的技术规格自上次同步以来都被编辑时,speck 无法知道哪一个应该作为权威。它会以交互方式提示:

Both spec and code changed for src/auth.rs — which takes priority?
[1] Code (update specs to match)
[2] Specs (update code to match)

使用 --prefer-code 或 --prefer-specs 可以非交互式地解决所有冲突。

命令 描述
speck init 用模板和目录结构搭建新的 speck 项目
speck migrate 从现有代码库反向生成规格
speck apply 在规格和代码之间双向同步编辑
speck status 列出按层分组的已编辑和未注册文件
speck review 通过代理运行全面的代码审查
speck fmt 运行配置的格式化工具并刷新哈希
speck chat 打开 zerostack TUI 会话,然后自动应用更改
speck force-update 重置所有哈希以匹配当前文件内容
speck reset 清除哈希(可选择删除 src/ 或 specs/technical/)
speck switch-lang 更改技术栈并从功能规格重新构建所有内容
speck mv 移动文件并更新哈希跟踪
speck rm 删除文件并更新哈希跟踪
speck git-hooks 安装 Git 钩子(pre-commit、pre-push、post-merge、post-checkout)

Speck 在 data/prompts/ 中附带五个专门的 zerostack 提示:

提示 用途
speck-code2tech 源代码 → 技术规格
speck-tech2code 技术规格 → 源代码
speck-feat2tech 功能规格 → 技术规格
speck-tech2feat 技术规格 → 功能规格
speck-review 全面代码审查

这些提示在 speck init 时安装到你的项目中,并可按项目自定义。

Speck 自带了默认的 AGENTS.md 和 ARCHITECTURE.md 模板,在 speck init 时会被搭建到新项目中。这些模板为所有在代码库上工作的代理(包括 zerostack)提供了共享的核心知识。

GPL-3.0-only

English / 原文

banner


Spec-driven agentic compiler: simple commands for complete agent managament, allowing for reproducible and verifiable code generation, moving the traditional chat interface out of the spotlight.

note: speck is a based on zerostack and it requires a working zerostack binary on PATH.

  • Three-layer architecture : specs/features/ (what) → specs/technical/ (how) → src/ (code). Edit any layer, the others stay in sync.
  • Bidirectional sync : speck apply detects changes via BLAKE3 hashes and propagates them through the layers using specialized AI prompts.
  • Migration from existing projects : speck migrate reverse-engineers specs/technical/ from any codebase, then derives specs/features/ from that.
  • Scaffolding : speck init bootstraps a new project with canonical AGENTS.md, ARCHITECTURE.md, and prompt templates.
  • Conflict resolution : when both code and specs are edited, speck prompts for priority (or use --prefer-code / --prefer-specs).
  • Code review : speck review runs a comprehensive, structured review via a specialized prompt, outputting a Markdown report.
  • Git hooks : speck git-hooks installs pre-commit, pre-push, post-merge, and post-checkout hooks that run speck apply, speck fmt, or speck status automatically.
  • Tech stack switching : speck switch-lang destructively changes language/framework and rebuilds everything from feature specs.
  • File management : speck mv and speck rm move or remove files while keeping the hash database in sync.
  • Change detection : speck status lists edited and unregistered files grouped by layer.

You can download compiled binaries from Github releases.

git clone https://github.com/gi-dellav/speck.git
cd speck
cargo install --path .


# Ensure zerostack is installed and configured
zerostack --version

# Scaffold a new speck project
speck init

# Or migrate an existing codebase
speck migrate

# Sync edits between specs and code
speck apply

# Check what changed
speck status

# Full code review
speck review --output report.md

Speck reads Speck.toml from the project root:

Field Description
name Project name (defaults to directory name)
source_dir Source code directory (defaults to src)
model Optional default model to use
features_dir Optional alternate path for high-level specs
fmt_cmd Optional formatter command
test_cmd Optional test command

Speck maintains a three-layer architecture where each layer is a different representation of the same product:

Layer Location Content Audience
Features specs/features/ High-level, non-technical — user stories, acceptance criteria PMs, stakeholders
Technical specs/technical/ Low-level — HOW and WHY, mapped 1:1 onto source files Developers
Source src/ (configurable) The actual code Compiler

speck apply runs a 4-step pipeline:

  1. Detect changes — compare current BLAKE3 hashes against .speck_hash.toml
  2. feat2tech — propagate feature spec edits down to technical specs
  3. tech2code — propagate technical spec edits down to source code
  4. code2tech — propagate source code edits up to technical specs

Each step uses a specialized zerostack prompt at the appropriate temperature (0 for deterministic updates, higher for creative spec expansion).

When both a source file and its corresponding technical spec are edited since the last sync, speck cannot know which is authoritative. It prompts interactively:

Both spec and code changed for src/auth.rs — which takes priority?
[1] Code (update specs to match)
[2] Specs (update code to match)

Use --prefer-code or --prefer-specs to resolve all conflicts non-interactively.

Command Description
speck init Scaffold a new speck project with templates and directory structure
speck migrate Reverse-engineer specs from an existing codebase
speck apply Sync edits bidirectionally between specs and code
speck status List edited and unregistered files grouped by layer
speck review Run a comprehensive code review via agent
speck fmt Run the configured formatter and refresh hashes
speck chat Open a zerostack TUI session, then auto-apply changes
speck force-update Reset all hashes to match current file contents
speck reset Clear hashes (optionally delete src/ or specs/technical/)
speck switch-lang Change tech stack and rebuild everything from features
speck mv Move a file and update hash tracking
speck rm Remove a file and update hash tracking
speck git-hooks Install git hooks (pre-commit, pre-push, post-merge, post-checkout)

Speck ships with five specialized zerostack prompts in data/prompts/:

Prompt Purpose
speck-code2tech Source code → technical specs
speck-tech2code Technical specs → source code
speck-feat2tech Feature specs → technical specs
speck-tech2feat Technical specs → feature specs
speck-review Comprehensive code review

These are installed into your project on speck init and can be customized per-project.

Speck ships default AGENTS.md and ARCHITECTURE.md templates that are scaffolded into new projects on speck init. These provide shared core knowledge for all agents (including zerostack) working on the codebase.

GPL-3.0-only