dsj1984/mandrel/tree/main/.agents/mods/mandrel-status
关于这个 mod
Mandrel
一个面向 AI 编程助手的约定式工作流框架,建立在以 Story 为中心的 GitHub 编排之上。规划、执行和状态都原生存放在 GitHub Issues、Labels 和 Projects V2 中。
Prerequisites
Mandrel 以 mandrel npm 软件包的形式发布,并将编排接入项目的 GitHub 仓库。你不需要预先创建 Git 仓库或 GitHub 远程仓库——bootstrap.js 会在冷启动过程中一并创建它们(git init → gh repo create --push → gh project create)。你需要:
- Node.js >= 22.22.1(< 25)。
- 位于
PATH中的git。 - 已完成身份验证的 GitHub CLI
gh>= 2.40——运行一次gh auth login,让编排脚本从操作系统密钥链获取令牌。普通的gh auth login令牌不包含创建 GitHub Projects V2 看板所需的projectscope;这种情况下 bootstrap 会降级为 warn-and-skip-board(不会硬失败)。要启用看板创建,请在运行bootstrap.js前使用gh auth refresh -s project授予该 scope(出现提示时在浏览器中重新认证)。
Quickstart
标准的冷启动路径是运行一个命令,再运行一个斜线命令:
npx mandrel init # install mandrel → sync → prompt → bootstrap → onboarding tail → /mandrel-plan handoff
# then, inside Claude Code (commands load from .claude/commands/):
/mandrel-plan --seed "…" # interrogate → author one Story (default) → persist
/mandrel-deliver <id> # story-<id> → PR → main
当 ./.agents/ 不存在时,npx mandrel init 会安装 mandrel,通过 mandrel sync 将其具体化,然后询问是否要立即配置(选项 1 → 运行 bootstrap.js,接着执行引导收尾流程:技术栈检测、文档脚手架选项、mandrel doctor 就绪检查,以及 /mandrel-plan 交接),还是停在仅生成文件(选项 2 → 随时重新运行 mandrel init 来配置)。传入 --assume-yes 可执行非交互运行,直接进入配置(并将该标志转发给 bootstrap)。如果 ./.agents/ 已经存在(你先运行过 npm install mandrel),init 会跳过安装和同步,直接进入提示。完成 mandrel init 后,你会进入 /mandrel-plan 交接——运行 /mandrel-plan --seed "<idea>" 编写第一个 Story,然后用 /mandrel-deliver <storyId> 交付(story-<id> → PR → main)。
Manual equivalent
如果你更喜欢手动执行 mandrel init 封装的步骤,请在项目根目录运行:
npm install mandrel # pin an exact, provenance-signed version
npx mandrel sync # materialize ./.agents/ from the package
node .agents/scripts/bootstrap.js
npm install mandrel 会在锁定文件中固定一个精确且带来源签名的版本。软件包的 postinstall 钩子会尽力运行 mandrel sync,因此 ./.agents/ 通常会自动生成;上面的显式 npx mandrel sync 是针对 --ignore-scripts 或沙箱 CI 安装的保险步骤。随时运行 npx mandrel doctor,确认安装状态正常。
pnpm 用户——请提升 mandrel 的运行时依赖。 生成的
./.agents/scripts/*.js会从项目根目录运行,并从顶层node_modules解析第三方依赖(ajv、js-yaml、…)。 npm 和 yarn 会自动把传递依赖提升到那里;pnpm 默认的隔离布局则不会——它会将依赖保留在.pnpm虚拟存储中,因此框架脚本(以及mandrel doctor的runtime-deps检查)无法看到它们。请在安装前将以下内容加入.npmrc:
# Lift mandrel's runtime deps to the top-level node_modules so the
# materialized .agents/scripts can resolve them.
shamefully-hoist=true
想要更精确的替代方案?可以把 shamefully-hoist 换成针对 .agents/runtime-deps.json 中每个软件包的带作用域 public-hoist-pattern[]= 行——请读取该文件,不要直接复制这里的列表,因为 complexity kernel 的闭包包含多个软件包。如果 mandrel doctor 报告 runtime-deps missing: …,这就是修复方法。
bootstrap.js 在 TTY 中是交互式的,会自动接受它能从本地 git remote 和 git config user.name 推断出的 owner、repo、base branch 和 operator handle——只有无法推断的字段才会询问(通常是可选的 Projects V2 number)。如果当前文件夹还不是 Git 仓库,或 GitHub 仓库不存在,它会创建这些内容:运行 git init 并创建首个提交,然后运行 gh repo create --source=. --push(使用 --visibility private|public|internal 设置新仓库的可见性,默认是 private),再为 Projects V2 看板运行 gh project create。可以用 --owner、--repo、--base-branch 或 --operator-handle 覆盖任何推断值。对于 CI / 脚本化安装,传入 --assume-yes 以及所需的覆盖参数。脚本具有幂等性——可以安全地随时重新运行。
消费者参考和端到端工作流说明见 .agents/README.md 与 docs/SDLC.md。每个 .agentrc.json 键都记录在 .agents/docs/configuration.md 中,斜线命令索引位于 .agents/docs/workflows.md。
Update
用一个命令将 mandrel 更新到最新发布版本,并重新生成 ./.agents/:
npx mandrel update
mandrel update 会按顺序执行以下周期:
- Resolve 最新发布版本(探测注册表的
npm view mandrel version)和当前已安装版本。 - No-op short-circuit——已经是最新版本 ⇒ 无需执行任何操作。
- Install 使用项目的软件包管理器安装目标版本——根据锁定文件自动检测(
pnpm-lock.yaml⇒ pnpm,yarn.lock⇒ yarn,否则使用 npm),这样升级会落入真实的锁定文件。依赖升级会留在磁盘上并处于暂存状态——mandrel update不会执行git add/git commit,所以你可以自行检查并提交锁定文件变更。 - Sync——从刚安装的负载重新生成
./.agents/。 - Migrate——对跨越的版本范围应用按版本键控的迁移步骤。
- Doctor——运行检查注册表,验证生成的安装。
- Surface——显示目标变更日志章节。
Flags
--dry-run——打印解析出的目标版本和有序步骤计划,然后退出。不升级依赖、不写入文件、不运行 seam。--install-cmd "<cmd>"——覆盖自动检测到的安装命令。软件包管理器通常根据锁定文件检测(pnpm-lock.yaml⇒pnpm add -D …,yarn.lock⇒yarn add -D …,否则为npm install …),所以很少需要覆盖。当你传入该参数时,会将{target}占位符替换为解析出的最新版本——例如--install-cmd "pnpm add -D mandrel@{target} -w"——这样覆盖命令仍能使用自动探测到的版本。注册表探测始终使用npm view(与 PM 无关的注册表查询)。
Manual equivalent
如果你更喜欢手动执行这些步骤:
npm install mandrel@latest # or pnpm add / yarn up
npx mandrel sync # re-materialize ./.agents/
npx mandrel doctor # verify the install
Benchmarking
Mandrel 的效果由独立的配套仓库 mandrel-bench 衡量,它是已发布 mandrel 软件包的消费者。它固定一个特定的框架版本,通过 mandrel sync 将其具体化,并在场景语料上驱动 Mandrel 自己的 /mandrel-plan→/mandrel-deliver 流程(另加一个裸模型对照)。每次运行都会在五个维度上评分——Quality、Planning fidelity 和 Autonomy(脚手架带来的价值),以及 Efficiency 和 Overhead ratio(它付出的代价)——以带噪声区间的分布形式报告,追踪不同版本和模型下框架相对裸模型基线的增值。
基准测试有意放在独立仓库中:固定 harness、改变锁定的 mandrel 版本,可以清楚地将 harness-version 与 framework-version 解耦;而通过已发布软件包 + mandrel sync 路径运行,则能检验真实的消费者契约。依赖关系是单向的——mandrel-bench 依赖 mandrel,反之不成立。有关维度、运行模型和如何为新版本进行基准测试,请参阅 mandrel-bench README。
Contributors
已发布的 mandrel 软件包包含三个目录——.agents/、bin/ 和 lib/——以及单个文件 docs/CHANGELOG.md,并排除 .agents/ 和 lib/ 下的 __tests__ 子树(见 package.json 中的 files 数组)。
.agents/ 是 mandrel sync 具体化到消费者 ./.agents/ 目录的负载;bin/mandrel.js 及其 lib/ 实现留在 node_modules/mandrel/ 中,为本 README 中反复使用的 npx mandrel … CLI 提供支持。该仓库中的其他所有内容——docs/、tests/、.github/ 以及根目录工具配置——都是内部开发工具,不会发布。
框架自身开发期间的常用命令:
npm run lint # biome + markdownlint + repo ratchets + generated-doc drift
npm run format # biome format — JavaScript/JSON only, not markdown
npm test # framework tests
npm run test:coverage # tests with coverage gate
更深入的参考材料位于 docs/,而不是内嵌在此处:
docs/architecture.md——模块图、仓库布局、状态机和技术栈。.agents/docs/configuration.md——每个.agentrc.json键的说明。.agents/docs/workflows.md——斜线命令索引(根据工作流集合自动生成)。docs/CHANGELOG.md——发布历史。AGENTS.md——仓库级方向指针;它会链接到docs/onboarding.md,说明布局、命令和开发标准。docs/release-operations.md——Release Checklist、Install Matrix 发布闸门、单软件包发布拓扑、PAT / npm-token 设置和大版本策略。发布由release-please自动完成:将 Conventional Commits 合入main后,它会开启chore: release mainPR;CI 变绿后该 PR 会自行 squash-merge,给main打标签,并将mandrel发布到 npm。
默认会禁用安装脚本:已提交的 .npmrc 设置 ignore-scripts=true,因此 npm install / npm ci 不会执行依赖生命周期钩子——这是针对受破坏传递依赖包中恶意生命周期脚本的纵深防御措施(CWE-1357)。CI 会显式传入 --ignore-scripts。如果你确实需要某次安装运行安装脚本,请仅对该次调用运行 npm install --ignore-scripts=false。
CRAP 和 Maintainability 闸门会在四个位置触发——.husky/pre-commit(quality-preview.js --staged,按暂存索引评分)、.husky/pre-push(相对于 origin/main 的差异范围)、close-validation(Story 关闭)和 CI(ci.yml,push + PR)——都针对 .agentrc.json 中 delivery.quality.* 的相同阈值。四者全部阻断:pre-commit 钩子最早触发,阈值违规时拒绝提交;而绿色的 npm run lint / npm test / check-baselines.js 运行并不能预测它。
License
MIT
安装
请先查看作者 README 确认 marketplace 和插件名称;命令可能随仓库结构改变。
claude plugin marketplace add dsj1984/mandrel claude plugin install mandrel-status
原文 / README
Mandrel
An opinionated workflow framework for AI coding assistants built on Story-centric GitHub orchestration. Planning, execution, and state all live natively in GitHub Issues, Labels, and Projects V2.
Prerequisites
Mandrel is distributed as the
mandrel npm
package and wires its orchestration into your project's GitHub repository.
You do not need a pre-created Git repo or GitHub remote — bootstrap.js
provisions both as part of a cold start (git init → gh repo create --push
→ gh project create). You need:
- Node.js >= 22.22.1 (< 25).
giton yourPATH.- GitHub CLI
gh>= 2.40, authenticated — rungh auth loginonce so orchestration scripts pick up your token from the OS keychain. A vanillagh auth logintoken does not carry theprojectscope needed to provision the GitHub Projects V2 board; bootstrap degrades to warn-and-skip-board in that case (no hard failure). To enable board provisioning, grant the scope withgh auth refresh -s project(re-auth in the browser when prompted) before runningbootstrap.js.
Quickstart
The canonical cold-start path is one command, then one slash command:
npx mandrel init # install mandrel → sync → prompt → bootstrap → onboarding tail → /mandrel-plan handoff
# then, inside Claude Code (commands load from .claude/commands/):
/mandrel-plan --seed "…" # interrogate → author one Story (default) → persist
/mandrel-deliver <id> # story-<id> → PR → main
npx mandrel init installs mandrel (when ./.agents/ is absent),
materializes it via mandrel sync, then asks whether to configure now
(option 1 → runs bootstrap.js, then the onboarding tail: stack detection,
docs scaffolding offer, mandrel doctor readiness gate, and a /mandrel-plan
handoff) or stop at just the files (option 2 → re-run mandrel init
any time to configure). Pass --assume-yes for a non-interactive run that
proceeds straight to configure (and forwards the flag to bootstrap). When
./.agents/ is already present (you ran npm install mandrel first), init
skips the install/sync and goes straight to the prompt. Once mandrel init
completes, you land at the /mandrel-plan handoff — run /mandrel-plan --seed "<idea>" to
author your first Story, then deliver it with /mandrel-deliver <storyId>
(story-<id> → PR → main).
Manual equivalent
If you prefer to drive the steps mandrel init wraps by hand, run them from
your project root:
npm install mandrel # pin an exact, provenance-signed version
npx mandrel sync # materialize ./.agents/ from the package
node .agents/scripts/bootstrap.js
npm install mandrel pins an exact, provenance-signed version in
your lockfile. The package's postinstall hook runs mandrel sync
best-effort, so ./.agents/ is usually materialized automatically; the
explicit npx mandrel sync above is the belt-and-suspenders step for
--ignore-scripts or sandboxed-CI installs. Run npx mandrel doctor any
time to confirm the install is healthy.
pnpm users — hoist mandrel's runtime deps. The materialized
./.agents/scripts/*.jsrun from your project root and resolve their third-party deps (ajv, js-yaml, …) from your top-levelnode_modules. npm and yarn hoist transitive deps there automatically; pnpm's default isolated layout does not — it keeps them in the.pnpmvirtual store, so the framework scripts (andmandrel doctor'sruntime-depscheck) cannot see them. Add the following to your.npmrcbefore installing:# Lift mandrel's runtime deps to the top-level node_modules so the # materialized .agents/scripts can resolve them. shamefully-hoist=truePrefer a surgical alternative? Replace
shamefully-hoistwith a scopedpublic-hoist-pattern[]=line per package listed in.agents/runtime-deps.json— read the file rather than copying a list from here, since the complexity kernel's closure is several packages. Ifmandrel doctorreportsruntime-deps missing: …, this is the fix.
bootstrap.js is interactive on a TTY and auto-accepts the
owner/repo/base branch/operator handle it can infer from your local
git remote and git config user.name — you only get prompted for
fields it can't infer (typically the optional Projects V2 number). When the
folder is not yet a git repo, or the GitHub repo doesn't exist, it
provisions them: git init plus a first commit, then
gh repo create --source=. --push (use --visibility private|public|internal,
default private, to set the new repo's visibility), then gh project create
for the Projects V2 board. Override anything inferred with --owner,
--repo, --base-branch, or --operator-handle. For CI / scripted installs
pass --assume-yes plus whichever overrides you need. The script is
idempotent — safe to re-run anytime.
For the consumer reference and the end-to-end workflow narrative, see
.agents/README.md and
docs/SDLC.md. Every .agentrc.json key is
documented in .agents/docs/configuration.md, and the
slash-command index lives in
.agents/docs/workflows.md.
Update
Advance mandrel to the newest published version and
re-materialize ./.agents/ in one command:
npx mandrel update
mandrel update runs an ordered cycle:
- Resolve the newest published version (a
npm view mandrel versionregistry probe) and the currently installed version. - No-op short-circuit — already on the newest version ⇒ nothing to do.
- Install the target version with the project's package manager —
auto-detected from the lockfile (
pnpm-lock.yaml⇒ pnpm,yarn.lock⇒ yarn, otherwise npm) so the bump lands in your real lockfile. The dependency bump is left staged on disk —mandrel updateperforms nogit add/git commit, so you review and commit the lockfile change yourself. - Sync — re-materialize
./.agents/from the freshly installed payload. - Migrate — apply version-keyed migration steps for the crossed range.
- Doctor — run the check registry to verify the resulting install.
- Surface the target changelog section.
Flags
--dry-run— print the resolved target version and the ordered step plan, then exit. No dependency is bumped, no file is written, no seam runs.--install-cmd "<cmd>"— override the auto-detected install command. The package manager is normally detected from your lockfile (pnpm-lock.yaml⇒pnpm add -D …,yarn.lock⇒yarn add -D …, otherwisenpm install …), so an override is rarely needed. When you do pass one, a{target}placeholder is substituted with the resolved newest version — e.g.--install-cmd "pnpm add -D mandrel@{target} -w"— so the override can still consume the auto-probed version. The registry probe always stays onnpm view(it is a PM-agnostic registry query).
Manual equivalent
If you prefer to drive the steps by hand:
npm install mandrel@latest # or pnpm add / yarn up
npx mandrel sync # re-materialize ./.agents/
npx mandrel doctor # verify the install
Benchmarking
Mandrel's effectiveness is measured by a separate companion repo,
mandrel-bench — a consumer of
the published mandrel package. It pins a specific framework version,
materializes it via mandrel sync, and drives Mandrel's own /mandrel-plan→/mandrel-deliver
pipeline (plus a bare-model control) over a scenario corpus. Each run is scored
across five dimensions — Quality, Planning fidelity, and Autonomy (what the
scaffolding buys) versus Efficiency and Overhead ratio (what it costs) —
reported as distributions with a noise-band, tracking the framework's
value-add over the bare-model baseline across versions and models.
The benchmark lives in its own repo on purpose: holding the harness fixed while
varying the pinned mandrel version cleanly decouples harness-version from
framework-version, and running through the published-package + mandrel sync
path exercises the real consumer contract. The dependency is one-directional —
mandrel-bench depends on mandrel, never the reverse. See the
mandrel-bench README for the
dimensions, run model, and how to benchmark a new version.
Contributors
The published mandrel package ships three directories — .agents/, bin/,
and lib/ — plus the single file docs/CHANGELOG.md, and excludes the
__tests__ subtrees under .agents/ and lib/ (see the files array in
package.json).
.agents/ is the payload mandrel sync materializes into a consumer's
./.agents/ directory; bin/mandrel.js and its lib/ implementation stay
inside node_modules/mandrel/ and back the npx mandrel … CLI used
throughout this README. Everything else in this repository — docs/,
tests/, .github/, the root tooling configs — is internal development
tooling and is not published.
Common commands while developing the framework itself:
npm run lint # biome + markdownlint + repo ratchets + generated-doc drift
npm run format # biome format — JavaScript/JSON only, not markdown
npm test # framework tests
npm run test:coverage # tests with coverage gate
Deeper reference material lives in docs/ rather than inline here:
docs/architecture.md— module map, repo layout, state machine, and tech stack..agents/docs/configuration.md— every.agentrc.jsonkey explained..agents/docs/workflows.md— slash-command index (auto-generated from the workflow set).docs/CHANGELOG.md— release history.AGENTS.md— the repository-level orientation pointer; it links on todocs/onboarding.mdfor the layout, commands, and development standards.docs/release-operations.md— the Release Checklist, the Install Matrix release gate, the single-package release topology, PAT / npm-token setup, and the major-version policy. Releases are automated byrelease-please: land Conventional Commits onmainand it opens a combinedchore: release mainPR that squash-merges itself once CI is green, tagsmain, and publishesmandrelto npm.
Install scripts are disabled by default: the committed
.npmrc sets ignore-scripts=true, so npm install / npm ci
will not execute dependency lifecycle hooks — a defense-in-depth measure
against malicious lifecycle scripts in compromised transitive packages
(CWE-1357). CI passes --ignore-scripts explicitly. If you knowingly need
install scripts for a specific install, run
npm install --ignore-scripts=false for that invocation only.
CRAP and Maintainability gates fire at four sites — .husky/pre-commit
(quality-preview.js --staged, scored on the staged index), .husky/pre-push
(diff-scoped against origin/main), close-validation (story close), and CI
(ci.yml, push + PR) — against the same thresholds from
delivery.quality.* in .agentrc.json. All four are blocking: the
pre-commit hook fires earliest and refuses the commit on a threshold
violation, and a green npm run lint / npm test / check-baselines.js
run does not predict it.
License
MIT

