安装器如何把规则装进项目 深度解析
这个子页面聚焦 Agentsmith 的装配模型:wizard 或 flag path 最终都要生成 managed block,再把 profile、脚本、hook 和模板铺到项目里。核心证据横跨 setup.sh 的参数解析、core/profile 规则和 assemble 测试。
导入链与契约
安装装配流不是“复制一个 CLAUDE.md”这么简单。它要判断项目类型、恢复已有 operator 字段、填充 placeholders,并且只替换自己管理的 block。这里用 core/10-operating-model.md:9、core/20-principle-rules.md:31、profiles/software-dev.md:46 作为规则端证据,再用 scripts/test-assemble.sh:45 到 scripts/test-assemble.sh:80 观察它如何防止半渲染输出进入 agent。
4**Unit of work:** one tracked item (an issue, a ticket, a task, a deliverable) per session by 5default. Its description is the contract. Two or three closely-related items on the same branch 6or workspace is fine when they share scope naturally. For an obvious small fix, a one-line 7description instead of a formal ticket is acceptable. 8 9**Autonomy:** proceed through **plan → do → verify → finalize → hand off** without asking for 10approval between steps. Decide routing and scope calls yourself, explain the WHY in the 11commit/PR/summary, and move on. The autonomy is in the *quantity of un-gated steps*, never in 12the *quality bar* — the principle rules and the profile's gates still apply to every step. 13 14**When the item is ambiguous:** research the right answer (official docs, reputable sources, 15the codebase/asset itself) and pick the researched path. **Do not default to "most 16conservative" or pick at random.** Note what you researched in the commit/PR/summary so the 17choice is auditable later.
核心实现,逐段拆
▸Profile 与通用规则的分层契约
装配的结果必须让 agent 明白一个 session 的运行协议。core/10-operating-model.md:4、core/10-operating-model.md:9、core/10-operating-model.md:14、core/10-operating-model.md:23 把任务单位、自主推进、模糊需求研究和按风险调 rigor 写成核心规则;这也是 setup.sh 最终写入 managed block 的意义。
23**Match your rigor to the stakes.** Work sits on a spectrum from quick-and-loose (a throwaway 24draft, a scratch experiment — "does it seem to work?") to fully disciplined (production systems, 25anything irreversible or outward-facing — verified at every stage). The skill is picking the 26right point per task: don't ceremony-wrap a five-minute scratch task, and don't "seem-to-work" 27something that ships to real users or touches real money. The profile sets the floor; raise it 28when the stakes are high. The single thing that separates disciplined work from guessing is 29**how the output gets verified** — see the principle rules. 30 31**Mind the last 20%.** You can produce the easy 80% of almost anything fast; the remaining 20% — 32the edge cases, the error handling, the integration seams, the subtle correctness — is where the 33real work is and where "looks right, even passes a quick check" hides the bugs. Spend your 34attention there, on the ambiguous and the hard-to-verify, not on re-admiring the easy part. 35 36**Conductor vs orchestrator — pick the altitude.** Some work wants *conductor* mode: hands-on, 37step-by-step, you watching each change (debugging, exploring unfamiliar ground, high-stakes 38edits). Other work wants *orchestrator* mode: define the goal, delegate to subagents, review 39outcomes rather than keystrokes (well-specified features, migrations, parallelizable sweeps). 40Neither is "more advanced" — choose by the task, and drop to conductor the moment something gets 41surprising. 42 43**Budget — a self-check, not a hard stop.** Keep work atomic (one concern per commit/change) 44and deliverables small. If you find yourself with 5+ unrelated changes stacked up, either split 45them or stop and hand off cleanly. Don't pause for elapsed time or time-of-day — momentum is 46fine as long as the quality bar holds. If you'd overshoot a natural stopping point, finish the 47current unit cleanly and write the handoff (see `50-git-and-handoff`).
▸装配测试如何抓半渲染规则
如果 core/profile 装配失败,agent 不会崩溃,只会读到错误规则,所以测试重点放在“输出是否可用”。scripts/test-assemble.sh:49、scripts/test-assemble.sh:63、scripts/test-assemble.sh:72、scripts/test-assemble.sh:83、scripts/test-assemble.sh:90 检查每个 profile、flag-driven placeholder 和 stacked profile。
45for p in "${profiles[@]}"; do 46 name="$(basename "$p" .md)" 47 out="$WORK/$name" 48 mkdir -p "$out" 49 if ! bash "$SETUP" --profile "$name" --assemble-only --target "$out" \ 50 --operator-name "Test" --tracker "Linear" >/dev/null 2>&1; then 51 bad "$name: assembly failed outright" 52 continue 53 fi 54 f="$out/CLAUDE.md" 55 if [ ! -s "$f" ]; then 56 bad "$name: produced no CLAUDE.md" 57 continue 58 fi 59 60 errs="" 61 # An unrendered token means the agent reads a literal "{{TRACKER}}" as if it were the rule. 62 # Never acceptable, in any profile. 63 leaked="$(grep -oE '\{\{[A-Z_]+\}\}' "$f" 2>/dev/null | sort -u | tr '\n' ' ')" 64 [ -n "$leaked" ] && errs="$errs unrendered:[$leaked]" 65 # [TODO: set X] means "the assembler had no value for X". Two very different cases: 66 # - X is flag-driven (below) → setup COULD have filled it and didn't. That's a bug: the agent 67 # gets a blank where a rule should be. This is the regression that would fire if a 68 # placeholder were renamed in core/ but not in fill_placeholders(). 69 # - X has no flag (BRAND_PALETTE, BRAND_FONT) → the TODO IS the product. It's the documented 70 # handoff to the human (INSTALL.md's placeholder table; setup's own "resolve any [TODO]" 71 # next-step). Flagging it would make this suite red by design and train people to ignore it. 72 for tok in OPERATOR_NAME OPERATOR_ROLE OPERATOR_BIO TRACKER TRACKER_POLICY; do 73 grep -qF "[TODO: set $tok]" "$f" 2>/dev/null && errs="$errs unfilled-flag-token:[$tok]" 74 done 75 76 if [ -n "$errs" ]; then 77 bad "$name: assembled with leaks —$errs" 78 else 79 ok "$name: assembles clean (no unrendered tokens, no TODO blanks)" 80 fi
关键流程
▸从规则材料到项目文件
关键路径的风险点在于写文件前后的身份恢复与占位符填充。core/20-principle-rules.md:47、core/20-principle-rules.md:54、profiles/software-dev.md:32、scripts/test-assemble.sh:61 共同说明:规则文件本身是生产物,必须像代码一样测试。
边界 / 失败模式
scripts/test-assemble.sh:27使用临时目录,避免测试污染真实全局 CLAUDE.md。scripts/test-assemble.sh:63会找未渲染 token,防止 agent 把 `{{TRACKER}}` 当成真实规则。core/10-operating-model.md:57强调外部系统首写要授权,安装器推荐 tracker 时不能等同授权。