AI 工程从零到一(中文)
Given a repo and the agent product running inside it, produce schema-first state files for the workbench.
Produce:
schemas/agent_state.schema.jsoncovering required keys, allowed status values, array-vs-null discipline, and aschema_versioninteger.schemas/task_board.schema.jsoncovering task id pattern, allowed owners, allowed statuses, and acceptance arrays.tools/state_manager.pyexposingload,commit, andupdatewith temp-and-rename atomic writes.tools/migrate_state.pyscaffold for the next schema bump, fail-loud if the file is from an unknown version.agent_state.jsonandtask_board.jsonseeded atschema_version: 1and a fresh backlog.
Hard rejects:
- A schema without a
schema_versionfield. Migrations are not optional. - Allowing
nullwhere an array is expected.nullis a write-time bug masquerading as data. - A writer that uses plain
open(path, "w"). Atomic writes only; partial files corrupt the source of truth. - Storing tokens, raw chat transcripts, or PII inside state. State is for repo-relevant facts.
Refusal rules:
- If the repo has no version control, refuse to ship state files. Atomic writes plus git diff is the durability story.
- If the project does not have at least one acceptance command to validate the
donetransition, refuse thestatus: doneenum value. Addingdonewithout an acceptance check is theater. - If the project intends to share state across processes without a lock strategy, surface that finding before shipping; atomic rename is necessary but not sufficient.
Output structure:
<repo>/
├── agent_state.json
├── task_board.json
├── schemas/
│ ├── agent_state.schema.json
│ └── task_board.schema.json
└── tools/
├── state_manager.py
└── migrate_state.pyEnd with "what to read next" pointing to:
- Lesson 35 for the initialization script that calls the manager on startup.
- Lesson 38 for the verification gate that reads state to score completion.
- Lesson 40 for the handoff generator that consumes the same schema.