@wnlen/agent-execution-template 0.8.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +440 -0
- package/README.zh-CN.md +447 -0
- package/bin/agent-execution-template.js +792 -0
- package/docs/SPEC.md +1039 -0
- package/docs/token-efficient-protocol-v0.1.md +101 -0
- package/package.json +35 -0
- package/template/en/ai/README.md +130 -0
- package/template/en/ai/project/archive/.gitkeep +0 -0
- package/template/en/ai/project/inbox/.gitkeep +1 -0
- package/template/en/ai/project/inbox/ideas/.gitkeep +1 -0
- package/template/en/ai/project/inbox/processed/.gitkeep +0 -0
- package/template/en/ai/project/inbox/raw/.gitkeep +1 -0
- package/template/en/ai/project/metrics.json +20 -0
- package/template/en/ai/project/project.md +42 -0
- package/template/en/ai/project/proposals/final-shape-updates/.gitkeep +1 -0
- package/template/en/ai/project/proposals/final-shape-updates/_template.md +64 -0
- package/template/en/ai/project/refs/architecture.md +23 -0
- package/template/en/ai/project/refs/commands.md +43 -0
- package/template/en/ai/project/refs/constraints.md +24 -0
- package/template/en/ai/project/refs/decisions.md +13 -0
- package/template/en/ai/project/refs/final-shape.md +59 -0
- package/template/en/ai/project/refs/module-map.md +31 -0
- package/template/en/ai/project/refs/roadmap.md +31 -0
- package/template/en/ai/project/result.json +34 -0
- package/template/en/ai/project/result.md +32 -0
- package/template/en/ai/project/runtime.md +74 -0
- package/template/en/ai/project/task.md +110 -0
- package/template/en/ai/template/LANG +1 -0
- package/template/en/ai/template/VERSION +1 -0
- package/template/en/ai/template/bootstrap.md +194 -0
- package/template/en/ai/template/prompt.md +118 -0
- package/template/en/ai/template/protocol.md +332 -0
- package/template/en/ai/template/reconcile.md +140 -0
- package/template/en/ai/template/rules/core.md +197 -0
- package/template/en/ai/template/rules/output.md +51 -0
- package/template/en/ai/template/schemas/metrics.schema.json +119 -0
- package/template/en/ai/template/schemas/result.schema.json +234 -0
- package/template/zh/ai/README.md +129 -0
- package/template/zh/ai/project/archive/.gitkeep +0 -0
- package/template/zh/ai/project/inbox/.gitkeep +1 -0
- package/template/zh/ai/project/inbox/ideas/.gitkeep +1 -0
- package/template/zh/ai/project/inbox/processed/.gitkeep +0 -0
- package/template/zh/ai/project/inbox/raw/.gitkeep +1 -0
- package/template/zh/ai/project/metrics.json +20 -0
- package/template/zh/ai/project/project.md +42 -0
- package/template/zh/ai/project/proposals/final-shape-updates/.gitkeep +1 -0
- package/template/zh/ai/project/proposals/final-shape-updates/_template.md +64 -0
- package/template/zh/ai/project/refs/architecture.md +23 -0
- package/template/zh/ai/project/refs/commands.md +43 -0
- package/template/zh/ai/project/refs/constraints.md +24 -0
- package/template/zh/ai/project/refs/decisions.md +13 -0
- package/template/zh/ai/project/refs/final-shape.md +54 -0
- package/template/zh/ai/project/refs/module-map.md +30 -0
- package/template/zh/ai/project/refs/roadmap.md +29 -0
- package/template/zh/ai/project/result.json +34 -0
- package/template/zh/ai/project/result.md +32 -0
- package/template/zh/ai/project/runtime.md +74 -0
- package/template/zh/ai/project/task.md +106 -0
- package/template/zh/ai/template/LANG +1 -0
- package/template/zh/ai/template/VERSION +1 -0
- package/template/zh/ai/template/bootstrap.md +180 -0
- package/template/zh/ai/template/prompt.md +104 -0
- package/template/zh/ai/template/protocol.md +300 -0
- package/template/zh/ai/template/reconcile.md +134 -0
- package/template/zh/ai/template/rules/core.md +174 -0
- package/template/zh/ai/template/rules/output.md +51 -0
- package/template/zh/ai/template/schemas/metrics.schema.json +119 -0
- package/template/zh/ai/template/schemas/result.schema.json +234 -0
- package/test/selftest.js +280 -0
|
@@ -0,0 +1,332 @@
|
|
|
1
|
+
# Protocol
|
|
2
|
+
|
|
3
|
+
Agent Execution Template v0.8 separates reusable protocol from project-specific
|
|
4
|
+
execution context.
|
|
5
|
+
|
|
6
|
+
```text
|
|
7
|
+
ai/template/ = reusable execution protocol
|
|
8
|
+
ai/project/ = current project execution workspace
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
Template is protocol. Project is the field workspace.
|
|
12
|
+
|
|
13
|
+
The project workspace stores both execution state and direction. The direction
|
|
14
|
+
layer answers "why is this worth doing and where should the project grow"; the
|
|
15
|
+
execution layer answers "what is this task and how will it be accepted."
|
|
16
|
+
|
|
17
|
+
```text
|
|
18
|
+
ai/project/refs/final-shape.md = project North Star
|
|
19
|
+
ai/project/refs/module-map.md = current module map
|
|
20
|
+
ai/project/refs/roadmap.md = staged roadmap
|
|
21
|
+
ai/project/task.md = current execution contract
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
## Execution Flow
|
|
25
|
+
|
|
26
|
+
```text
|
|
27
|
+
Project Bootstrap / Context Reconcile / Strategy Update -> Project Confirm -> Task Draft -> Task Confirm -> Plan -> Execute -> Review -> Result
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
1. For project discovery, follow `ai/template/bootstrap.md`; do not summarize it.
|
|
31
|
+
2. End bootstrap with the Post-Bootstrap Handoff, including a confirmable
|
|
32
|
+
in-chat summary and recommended next step. Do not only ask the human to open
|
|
33
|
+
files and inspect them.
|
|
34
|
+
3. For task execution, follow `ai/template/prompt.md`; do not summarize it.
|
|
35
|
+
4. When new authoritative material appears, put it in `ai/project/inbox/` and
|
|
36
|
+
follow `ai/template/reconcile.md`; do not summarize it. Reconciliation must
|
|
37
|
+
produce a plan first and update context only after confirmation.
|
|
38
|
+
5. When a new idea would change the final product shape, module boundaries, or
|
|
39
|
+
roadmap, put it in `ai/project/inbox/ideas/`, then create a
|
|
40
|
+
`strategy_update` task to produce a proposal.
|
|
41
|
+
6. Only after the human confirms the proposal may an `apply_strategy_update`
|
|
42
|
+
task modify `final-shape.md`, `module-map.md`, or `roadmap.md`.
|
|
43
|
+
7. If `ai/project/task.md` is missing or incomplete, draft it from the current
|
|
44
|
+
goal and confirmed project context, then stop with the Task Draft Handoff.
|
|
45
|
+
8. After task confirmation, check readiness, risk, model policy, refs,
|
|
46
|
+
permission, and acceptance.
|
|
47
|
+
9. Execute only within the project task boundary.
|
|
48
|
+
10. Write `ai/project/result.json`, `ai/project/result.md`, and `ai/project/metrics.json`.
|
|
49
|
+
|
|
50
|
+
## Bootstrap Mode
|
|
51
|
+
|
|
52
|
+
Bootstrap Mode prepares stable project understanding:
|
|
53
|
+
|
|
54
|
+
- `ai/project/project.md`
|
|
55
|
+
- `ai/project/refs/*.md`
|
|
56
|
+
|
|
57
|
+
Use Bootstrap Mode when `ai/project/project.md` is empty, placeholder-only,
|
|
58
|
+
stale, incomplete, or the user asks to bootstrap project context.
|
|
59
|
+
|
|
60
|
+
Bootstrap Mode must:
|
|
61
|
+
|
|
62
|
+
- read only the approved bootstrap sources first;
|
|
63
|
+
- summarize stable project facts into `ai/project/project.md`;
|
|
64
|
+
- update focused refs when durable architecture, command, constraint, or
|
|
65
|
+
decision facts can be inferred;
|
|
66
|
+
- create `ai/project/task.md` only if the human also provides a current task,
|
|
67
|
+
and only draft the task contract;
|
|
68
|
+
- mark unknown facts as `Unknown` instead of guessing;
|
|
69
|
+
- ask at most 3 questions only when answers change scope, risk, permission, or
|
|
70
|
+
acceptance;
|
|
71
|
+
- stop after writing draft project context files; if a current task was
|
|
72
|
+
provided, it may also write a task draft before stopping;
|
|
73
|
+
- never edit source, business, config, dependency, or generated files.
|
|
74
|
+
|
|
75
|
+
### Bootstrap Read Scope
|
|
76
|
+
|
|
77
|
+
Read high-signal sources in this order:
|
|
78
|
+
|
|
79
|
+
1. Root documentation:
|
|
80
|
+
- `README*`
|
|
81
|
+
- `AGENTS.md`
|
|
82
|
+
- `CLAUDE.md`
|
|
83
|
+
- `CONTRIBUTING*`
|
|
84
|
+
- `CHANGELOG*`
|
|
85
|
+
2. Package and build metadata:
|
|
86
|
+
- `package.json`
|
|
87
|
+
- `pyproject.toml`
|
|
88
|
+
- `Cargo.toml`
|
|
89
|
+
- `go.mod`
|
|
90
|
+
- `pom.xml`
|
|
91
|
+
- `build.gradle*`
|
|
92
|
+
- `Makefile`
|
|
93
|
+
3. Project documentation:
|
|
94
|
+
- `docs/**`
|
|
95
|
+
- prefer overview, architecture, setup, testing, deployment, API, ADR, and
|
|
96
|
+
decision files.
|
|
97
|
+
4. Existing AI context:
|
|
98
|
+
- `ai/project/refs/*.md`
|
|
99
|
+
5. Shallow repository structure:
|
|
100
|
+
- source, test, config, and documentation directories only.
|
|
101
|
+
|
|
102
|
+
If docs and manifests are missing or insufficient, infer from code with a
|
|
103
|
+
bounded read:
|
|
104
|
+
|
|
105
|
+
- inspect top-level directories and filenames first;
|
|
106
|
+
- inspect likely entrypoints such as `src/`, `app/`, `lib/`, `packages/`,
|
|
107
|
+
`services/`, `cmd/`, `internal/`, `server/`, `client/`, `test/`, `tests/`;
|
|
108
|
+
- inspect route, module, config, and test files only enough to identify
|
|
109
|
+
project purpose, module boundaries, commands, and constraints;
|
|
110
|
+
- do not read the whole codebase unless the human explicitly authorizes it.
|
|
111
|
+
|
|
112
|
+
Do not read by default:
|
|
113
|
+
|
|
114
|
+
- dependency directories such as `node_modules`, `vendor`, `.venv`;
|
|
115
|
+
- generated outputs such as `dist`, `build`, `target`, `coverage`;
|
|
116
|
+
- lockfiles except to infer package manager;
|
|
117
|
+
- secret or environment files such as `.env*`;
|
|
118
|
+
- archive/history directories unless the user explicitly references them.
|
|
119
|
+
|
|
120
|
+
If the repository is large, read the root docs and manifests first, then ask
|
|
121
|
+
before expanding the read scope.
|
|
122
|
+
|
|
123
|
+
### Bootstrap Outputs
|
|
124
|
+
|
|
125
|
+
`ai/project/project.md` should contain long-lived project identity:
|
|
126
|
+
|
|
127
|
+
- name, purpose, and primary users;
|
|
128
|
+
- language, framework, package manager, and test runner;
|
|
129
|
+
- source, test, config, and documentation layout;
|
|
130
|
+
- stable constraints, conventions, and important unknowns.
|
|
131
|
+
|
|
132
|
+
`ai/project/refs/*.md` should contain focused durable context:
|
|
133
|
+
|
|
134
|
+
- project North Star, final shape, and task-worthiness criteria;
|
|
135
|
+
- current module map, staged roadmap, and direction constraints;
|
|
136
|
+
- architecture and module boundaries;
|
|
137
|
+
- run, build, test, and verification commands;
|
|
138
|
+
- security, compatibility, performance, data, and deployment constraints;
|
|
139
|
+
- documented decisions only when evidence exists.
|
|
140
|
+
|
|
141
|
+
Recommended routing:
|
|
142
|
+
|
|
143
|
+
```text
|
|
144
|
+
final shape / North Star / task worthiness -> ai/project/refs/final-shape.md
|
|
145
|
+
current module structure / boundaries -> ai/project/refs/module-map.md
|
|
146
|
+
stage goals / near-term roadmap -> ai/project/refs/roadmap.md
|
|
147
|
+
architecture / API / technical boundaries -> ai/project/refs/architecture.md
|
|
148
|
+
commands / verification -> ai/project/refs/commands.md
|
|
149
|
+
non-negotiable constraints -> ai/project/refs/constraints.md
|
|
150
|
+
confirmed key decisions -> ai/project/refs/decisions.md
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
After writing drafts, stop with the Post-Bootstrap Handoff from
|
|
154
|
+
`ai/template/bootstrap.md`. If the human did not provide a current task,
|
|
155
|
+
recommend the next best task. If the human already provided a current task,
|
|
156
|
+
you may also draft `ai/project/task.md`, but do not execute.
|
|
157
|
+
|
|
158
|
+
## Task Draft Mode
|
|
159
|
+
|
|
160
|
+
Task Draft Mode prepares the current execution contract:
|
|
161
|
+
|
|
162
|
+
- `ai/project/task.md`
|
|
163
|
+
|
|
164
|
+
Use Task Draft Mode when project context is confirmed but `ai/project/task.md`
|
|
165
|
+
is empty, placeholder-only, incomplete, or the human provides a new task goal
|
|
166
|
+
that was not already drafted during bootstrap.
|
|
167
|
+
|
|
168
|
+
Task Draft Mode should:
|
|
169
|
+
|
|
170
|
+
- read confirmed `ai/project/project.md`;
|
|
171
|
+
- read relevant `ai/project/refs/*.md`;
|
|
172
|
+
- convert the current human goal into task type, priority, risk, scope,
|
|
173
|
+
permissions, command policy, model policy, and acceptance criteria;
|
|
174
|
+
- ask at most 3 questions only for scope, risk, permission, or acceptance
|
|
175
|
+
blockers;
|
|
176
|
+
- stop after writing the task draft with the Task Draft Handoff from
|
|
177
|
+
`ai/template/prompt.md`;
|
|
178
|
+
- never edit source or business files.
|
|
179
|
+
|
|
180
|
+
## Context Reconcile Mode
|
|
181
|
+
|
|
182
|
+
Context Reconcile Mode absorbs new authoritative material and corrects existing
|
|
183
|
+
long-lived context.
|
|
184
|
+
|
|
185
|
+
New material should usually live in:
|
|
186
|
+
|
|
187
|
+
- `ai/project/inbox/*.md`
|
|
188
|
+
- `docs/**`
|
|
189
|
+
|
|
190
|
+
Processed material is moved to `ai/project/inbox/processed/` and is not read
|
|
191
|
+
again as pending intake by default.
|
|
192
|
+
|
|
193
|
+
The user can simply say "Reconcile the new material in ai/project/inbox/".
|
|
194
|
+
Use Context Reconcile Mode by following `ai/template/reconcile.md`.
|
|
195
|
+
|
|
196
|
+
Context Reconcile Mode must:
|
|
197
|
+
|
|
198
|
+
- read existing `ai/project/project.md`, `ai/project/runtime.md`, and `ai/project/refs/*.md`;
|
|
199
|
+
- read the new material named by the human; if none is named, read `ai/project/inbox/*.md`;
|
|
200
|
+
- produce a reconciliation plan first without modifying files;
|
|
201
|
+
- update `ai/project/project.md`, `ai/project/runtime.md`, and `ai/project/refs/*.md` only after human confirmation;
|
|
202
|
+
- after applying reconciliation, move processed `ai/project/inbox/*.md` material to `ai/project/inbox/processed/`;
|
|
203
|
+
- not modify `task.md`, `result.*`, `metrics.json`, source, tests, config, or dependency files by default;
|
|
204
|
+
- not dump raw new material into refs; absorb long-lived, structured, reusable facts.
|
|
205
|
+
|
|
206
|
+
If new material would change directional content in `final-shape.md`,
|
|
207
|
+
`module-map.md`, or `roadmap.md`, Context Reconcile Mode may only recommend a
|
|
208
|
+
`strategy_update`; it must not directly edit those files.
|
|
209
|
+
|
|
210
|
+
## Strategy Update Mode
|
|
211
|
+
|
|
212
|
+
Strategy Update Mode handles changes to project direction, final shape, module
|
|
213
|
+
boundaries, or roadmap.
|
|
214
|
+
|
|
215
|
+
Use it when:
|
|
216
|
+
|
|
217
|
+
- `ai/project/inbox/ideas/` contains new product, business, architecture, or
|
|
218
|
+
direction ideas;
|
|
219
|
+
- the user asks to update the North Star, final shape, product constitution,
|
|
220
|
+
module map, or roadmap;
|
|
221
|
+
- a routine task discovers that the current execution goal may conflict with
|
|
222
|
+
project direction.
|
|
223
|
+
|
|
224
|
+
### `strategy_update`
|
|
225
|
+
|
|
226
|
+
`strategy_update` only produces a proposal. It does not write code and does not
|
|
227
|
+
modify official direction files.
|
|
228
|
+
|
|
229
|
+
It must read:
|
|
230
|
+
|
|
231
|
+
- `ai/project/refs/final-shape.md`
|
|
232
|
+
- `ai/project/refs/module-map.md`
|
|
233
|
+
- `ai/project/refs/roadmap.md`
|
|
234
|
+
- `ai/project/refs/decisions.md`
|
|
235
|
+
- `ai/project/refs/constraints.md`
|
|
236
|
+
- human-specified new material; if none is named, read `ai/project/inbox/ideas/*`
|
|
237
|
+
|
|
238
|
+
Write the proposal to:
|
|
239
|
+
|
|
240
|
+
```text
|
|
241
|
+
ai/project/proposals/final-shape-updates/YYYYMMDD-topic.md
|
|
242
|
+
```
|
|
243
|
+
|
|
244
|
+
Use `ai/project/proposals/final-shape-updates/_template.md` as the structural
|
|
245
|
+
template.
|
|
246
|
+
|
|
247
|
+
The proposal must include:
|
|
248
|
+
|
|
249
|
+
1. Summary of the new idea
|
|
250
|
+
2. Alignment with current `final-shape.md`
|
|
251
|
+
3. Conflicts
|
|
252
|
+
4. Parts to absorb
|
|
253
|
+
5. Parts to reject
|
|
254
|
+
6. Impact on the module map
|
|
255
|
+
7. Impact on the roadmap
|
|
256
|
+
8. Suggested diff
|
|
257
|
+
9. Risks
|
|
258
|
+
10. Merge recommendation
|
|
259
|
+
|
|
260
|
+
Stop after producing the proposal and wait for human confirmation. Do not
|
|
261
|
+
modify `final-shape.md`, `module-map.md`, `roadmap.md`, source, tests, config,
|
|
262
|
+
or dependency files.
|
|
263
|
+
|
|
264
|
+
### `apply_strategy_update`
|
|
265
|
+
|
|
266
|
+
`apply_strategy_update` only applies a confirmed proposal.
|
|
267
|
+
|
|
268
|
+
It requires:
|
|
269
|
+
|
|
270
|
+
- explicit human confirmation that a proposal may be merged;
|
|
271
|
+
- the proposal is already `accepted`, or is updated from `proposed` to
|
|
272
|
+
`accepted` immediately before execution based on explicit human confirmation;
|
|
273
|
+
- `task.md.permission.modify.allowed` includes the official direction files
|
|
274
|
+
that will be changed;
|
|
275
|
+
- applying only the confirmed proposal content, without opportunistic expansion.
|
|
276
|
+
|
|
277
|
+
Allowed updates:
|
|
278
|
+
|
|
279
|
+
- `ai/project/refs/final-shape.md`
|
|
280
|
+
- `ai/project/refs/module-map.md`
|
|
281
|
+
- `ai/project/refs/roadmap.md`
|
|
282
|
+
- `ai/project/refs/decisions.md` or `constraints.md` when necessary
|
|
283
|
+
|
|
284
|
+
After applying:
|
|
285
|
+
|
|
286
|
+
- update proposal status to `applied`;
|
|
287
|
+
- fill `applied_at`;
|
|
288
|
+
- make `result.md` list the merged proposal, changed files, and items left
|
|
289
|
+
unmerged.
|
|
290
|
+
|
|
291
|
+
If the human rejects a proposal, keep the proposal file, update `status` to
|
|
292
|
+
`rejected`, and do not delete that historical strategy record.
|
|
293
|
+
|
|
294
|
+
## Human-Minimal Task
|
|
295
|
+
|
|
296
|
+
The human should normally provide intent and confirm generated project and task
|
|
297
|
+
contracts. The agent should draft routine detail from existing docs, manifests,
|
|
298
|
+
refs, and project files.
|
|
299
|
+
|
|
300
|
+
- Ask at most 3 clarification questions.
|
|
301
|
+
- Ask only when the answer changes scope, risk, permission, or acceptance.
|
|
302
|
+
- Do not ask about details that can be safely inferred from project files.
|
|
303
|
+
- Convert safe uncertainty into explicit assumptions in `ai/project/result.json`.
|
|
304
|
+
- If acceptance remains unverifiable, stop with `status = "blocked"`.
|
|
305
|
+
- If the task is executable, proceed without further human interaction.
|
|
306
|
+
|
|
307
|
+
## Model Division
|
|
308
|
+
|
|
309
|
+
Follow `ai/project/task.md.model_policy`.
|
|
310
|
+
|
|
311
|
+
- Default cheap.
|
|
312
|
+
- Escalate for judgment.
|
|
313
|
+
- Record why.
|
|
314
|
+
|
|
315
|
+
Use the default tier for routine execution. Use `strong` only when an
|
|
316
|
+
escalation trigger is hit and the required role is listed in
|
|
317
|
+
`strong_model_roles`.
|
|
318
|
+
|
|
319
|
+
If the host cannot switch models, stop or mark the task `partial`/`blocked`
|
|
320
|
+
with the needed strong-model role.
|
|
321
|
+
|
|
322
|
+
## Sync Rules
|
|
323
|
+
|
|
324
|
+
When importing from this template repo into a real project:
|
|
325
|
+
|
|
326
|
+
- Overwrite only `ai/template/**`.
|
|
327
|
+
- Never overwrite `ai/project/**`.
|
|
328
|
+
|
|
329
|
+
When flowing improvements from a real project back into this template repo:
|
|
330
|
+
|
|
331
|
+
- Return only `ai/template/**`.
|
|
332
|
+
- Never return `ai/project/**`.
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
# AI Context Reconcile
|
|
2
|
+
|
|
3
|
+
Do not summarize this file.
|
|
4
|
+
Execute the context reconciliation workflow below.
|
|
5
|
+
|
|
6
|
+
You are absorbing new authoritative material into an existing Agent Execution Template project context.
|
|
7
|
+
This is not a fresh bootstrap and not a full overwrite.
|
|
8
|
+
|
|
9
|
+
Goal: merge long-lived facts from the new material, correct outdated or inaccurate context, and preserve existing context that is still correct.
|
|
10
|
+
|
|
11
|
+
## When To Use
|
|
12
|
+
|
|
13
|
+
Use this workflow when a project has been using the template for a while and a more complete or more authoritative business, product, architecture, or process document appears.
|
|
14
|
+
|
|
15
|
+
New material should usually live in:
|
|
16
|
+
|
|
17
|
+
- `ai/project/inbox/*.md`
|
|
18
|
+
- `ai/project/inbox/raw/*.md`
|
|
19
|
+
- `docs/**`
|
|
20
|
+
|
|
21
|
+
`ai/project/inbox/` is the intake area for material that has not yet been
|
|
22
|
+
absorbed. After reconciliation is confirmed, move processed material to
|
|
23
|
+
`ai/project/inbox/processed/` for traceability and to avoid repeated
|
|
24
|
+
reconciliation.
|
|
25
|
+
|
|
26
|
+
## First Read
|
|
27
|
+
|
|
28
|
+
1. `ai/template/protocol.md`
|
|
29
|
+
2. `ai/template/rules/core.md`
|
|
30
|
+
3. `ai/project/project.md`
|
|
31
|
+
4. `ai/project/runtime.md`
|
|
32
|
+
5. `ai/project/refs/*.md`
|
|
33
|
+
6. The new material named by the human; if none is named, read `ai/project/inbox/*.md`
|
|
34
|
+
|
|
35
|
+
Do not read `ai/project/inbox/processed/**`, `ai/project/archive/**`, source,
|
|
36
|
+
tests, config, or dependency files by default unless the human explicitly asks
|
|
37
|
+
you to use them for fact checking.
|
|
38
|
+
|
|
39
|
+
## Reconciliation Principles
|
|
40
|
+
|
|
41
|
+
- Do not overwrite the whole context set.
|
|
42
|
+
- Preserve existing context that is still correct.
|
|
43
|
+
- Split new material into the right places:
|
|
44
|
+
- Project identity, users, and stable conventions -> `ai/project/project.md`
|
|
45
|
+
- Current valid execution context -> `ai/project/runtime.md`
|
|
46
|
+
- Final shape / North Star / task-worthiness criteria -> `ai/project/refs/final-shape.md`
|
|
47
|
+
- Current module structure / boundaries / dependency direction -> `ai/project/refs/module-map.md`
|
|
48
|
+
- Stage goals / near-term roadmap / deferred items -> `ai/project/refs/roadmap.md`
|
|
49
|
+
- Architecture / API / module boundaries -> `ai/project/refs/architecture.md`
|
|
50
|
+
- Commands -> `ai/project/refs/commands.md`
|
|
51
|
+
- Constraints -> `ai/project/refs/constraints.md`
|
|
52
|
+
- Durable decisions -> `ai/project/refs/decisions.md`
|
|
53
|
+
- Do not dump raw source text into `refs/*`; absorb structured, long-lived, reusable context.
|
|
54
|
+
- If new material would change directional content in the North Star, module
|
|
55
|
+
map, or roadmap, only recommend creating a `strategy_update` proposal. Do not
|
|
56
|
+
directly modify those direction files during context reconciliation.
|
|
57
|
+
- `task.md`, `result.json`, `result.md`, and `metrics.json` usually do not participate in business-context reconciliation unless the human explicitly asks you to extract long-lived facts from them.
|
|
58
|
+
|
|
59
|
+
## Two-Phase Workflow
|
|
60
|
+
|
|
61
|
+
### Phase 1: Reconciliation Plan
|
|
62
|
+
|
|
63
|
+
First produce a reconciliation plan. Do not modify files.
|
|
64
|
+
|
|
65
|
+
The plan must include:
|
|
66
|
+
|
|
67
|
+
1. Content to add
|
|
68
|
+
2. Content to correct
|
|
69
|
+
3. Conflicts with existing context
|
|
70
|
+
4. Content to remove or downgrade
|
|
71
|
+
5. Questions requiring human confirmation, at most 3
|
|
72
|
+
6. Files expected to change
|
|
73
|
+
|
|
74
|
+
If there are no questions requiring confirmation, explicitly write "no extra confirmation needed".
|
|
75
|
+
|
|
76
|
+
Stop at the end of Phase 1 and wait for human confirmation.
|
|
77
|
+
|
|
78
|
+
### Phase 2: Apply Reconciliation
|
|
79
|
+
|
|
80
|
+
Only update files after the human explicitly confirms the reconciliation plan.
|
|
81
|
+
|
|
82
|
+
Allowed targets:
|
|
83
|
+
|
|
84
|
+
- `ai/project/project.md`
|
|
85
|
+
- `ai/project/runtime.md`
|
|
86
|
+
- `ai/project/refs/*.md`
|
|
87
|
+
- `ai/project/inbox/processed/**`, for material processed in this run
|
|
88
|
+
|
|
89
|
+
Do not modify these unless the human explicitly asks:
|
|
90
|
+
|
|
91
|
+
- Source, tests, config, dependency files
|
|
92
|
+
- `ai/project/refs/final-shape.md`
|
|
93
|
+
- `ai/project/refs/module-map.md`
|
|
94
|
+
- `ai/project/refs/roadmap.md`
|
|
95
|
+
- `ai/project/task.md`
|
|
96
|
+
- `ai/project/result.json`
|
|
97
|
+
- `ai/project/result.md`
|
|
98
|
+
- `ai/project/metrics.json`
|
|
99
|
+
- `ai/project/archive/**`
|
|
100
|
+
|
|
101
|
+
After applying reconciliation, move the processed `ai/project/inbox/*.md`
|
|
102
|
+
material into `ai/project/inbox/processed/`. If a filename conflicts, keep the
|
|
103
|
+
original name and add a date or sequence number. Do not move
|
|
104
|
+
`ai/project/inbox/ideas/**`; direction ideas should continue through
|
|
105
|
+
`strategy_update`.
|
|
106
|
+
|
|
107
|
+
## Final Handoff
|
|
108
|
+
|
|
109
|
+
After applying reconciliation, the final response must include:
|
|
110
|
+
|
|
111
|
+
```text
|
|
112
|
+
Context reconciliation is complete.
|
|
113
|
+
|
|
114
|
+
Updated:
|
|
115
|
+
- file
|
|
116
|
+
|
|
117
|
+
Archived material:
|
|
118
|
+
- ai/project/inbox/processed/file.md
|
|
119
|
+
|
|
120
|
+
Key changes:
|
|
121
|
+
- Added:
|
|
122
|
+
- Corrected:
|
|
123
|
+
- Deprecated:
|
|
124
|
+
|
|
125
|
+
Still uncertain:
|
|
126
|
+
- Up to 3 items; write "none" if there are none
|
|
127
|
+
|
|
128
|
+
Recommended next step:
|
|
129
|
+
1. Priority task:
|
|
130
|
+
Reason:
|
|
131
|
+
2. Alternative task:
|
|
132
|
+
Reason:
|
|
133
|
+
|
|
134
|
+
Reply with:
|
|
135
|
+
- Confirm, draft task 1
|
|
136
|
+
- Confirm, but do: <one-sentence task>
|
|
137
|
+
- Correction: <what to change>
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
Do not make the human hunt through files to find changes; file paths are only for traceability.
|
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
# Core Rules
|
|
2
|
+
|
|
3
|
+
## Readiness Gate
|
|
4
|
+
|
|
5
|
+
Before editing code, check that `ai/project/task.md` clearly defines:
|
|
6
|
+
|
|
7
|
+
- Goal
|
|
8
|
+
- Scope
|
|
9
|
+
- Acceptance
|
|
10
|
+
- Permission
|
|
11
|
+
|
|
12
|
+
If readiness fails, do not edit code. Write blocked results to:
|
|
13
|
+
|
|
14
|
+
- `ai/project/result.json`
|
|
15
|
+
- `ai/project/result.md`
|
|
16
|
+
- `ai/project/metrics.json`
|
|
17
|
+
|
|
18
|
+
## Bootstrap Gate
|
|
19
|
+
|
|
20
|
+
If `ai/project/project.md` is empty, placeholder-only, incomplete, or the user
|
|
21
|
+
asks to bootstrap project context, follow `ai/template/bootstrap.md` before
|
|
22
|
+
execution.
|
|
23
|
+
|
|
24
|
+
Bootstrap Mode may write only project context files:
|
|
25
|
+
|
|
26
|
+
- `ai/project/project.md`
|
|
27
|
+
- `ai/project/refs/final-shape.md`
|
|
28
|
+
- `ai/project/refs/module-map.md`
|
|
29
|
+
- `ai/project/refs/roadmap.md`
|
|
30
|
+
- `ai/project/refs/architecture.md`
|
|
31
|
+
- `ai/project/refs/commands.md`
|
|
32
|
+
- `ai/project/refs/constraints.md`
|
|
33
|
+
- `ai/project/refs/decisions.md`
|
|
34
|
+
|
|
35
|
+
Bootstrap Mode may write `ai/project/task.md` only if the human also provides
|
|
36
|
+
a current task goal. In that case, draft only the task contract and do not
|
|
37
|
+
enter implementation.
|
|
38
|
+
|
|
39
|
+
Bootstrap Mode must not edit source code, tests, configuration, dependency
|
|
40
|
+
files, generated files, runtime files, result files, or metrics files.
|
|
41
|
+
|
|
42
|
+
After writing bootstrap drafts, stop with the Post-Bootstrap Handoff from
|
|
43
|
+
`ai/template/bootstrap.md`. The handoff must include a confirmable in-chat
|
|
44
|
+
summary and recommended next step, not only file paths to inspect. If the human
|
|
45
|
+
already provided a current task goal, bootstrap may also draft
|
|
46
|
+
`ai/project/task.md` in the same run, but it must still stop for confirmation
|
|
47
|
+
and must not enter implementation.
|
|
48
|
+
|
|
49
|
+
## Bootstrap Read Scope
|
|
50
|
+
|
|
51
|
+
Read only high-signal project sources by default:
|
|
52
|
+
|
|
53
|
+
- Root docs: `README*`, `AGENTS.md`, `CLAUDE.md`, `CONTRIBUTING*`, `CHANGELOG*`
|
|
54
|
+
- Manifests: `package.json`, `pyproject.toml`, `Cargo.toml`, `go.mod`,
|
|
55
|
+
`pom.xml`, `build.gradle*`, `Makefile`
|
|
56
|
+
- Project docs: `docs/**`, preferring overview, architecture, setup, testing,
|
|
57
|
+
deployment, API, ADR, and decision files
|
|
58
|
+
- Existing AI refs: `ai/project/refs/*.md`
|
|
59
|
+
- Shallow source/test/config/docs directory listing
|
|
60
|
+
- If docs are missing or insufficient, bounded reads of likely entrypoints such
|
|
61
|
+
as `src/`, `app/`, `lib/`, `packages/`, `services/`, `cmd/`, `internal/`,
|
|
62
|
+
`server/`, `client/`, `test/`, and `tests/`
|
|
63
|
+
|
|
64
|
+
Do not read dependency folders, build outputs, coverage outputs, secret files,
|
|
65
|
+
environment files, or archives unless explicitly authorized or referenced by
|
|
66
|
+
the user.
|
|
67
|
+
|
|
68
|
+
## Task Draft Gate
|
|
69
|
+
|
|
70
|
+
If project context is confirmed but `ai/project/task.md` is empty,
|
|
71
|
+
placeholder-only, incomplete, or the human provides a new task goal, draft
|
|
72
|
+
`ai/project/task.md` from confirmed project context and stop for human
|
|
73
|
+
confirmation before implementation.
|
|
74
|
+
|
|
75
|
+
Task Draft Mode may write only:
|
|
76
|
+
|
|
77
|
+
- `ai/project/task.md`
|
|
78
|
+
|
|
79
|
+
Task Draft Mode must end with the Task Draft Handoff from
|
|
80
|
+
`ai/template/prompt.md`.
|
|
81
|
+
|
|
82
|
+
## Context Reconcile Gate
|
|
83
|
+
|
|
84
|
+
If the user provides new authoritative business, product, architecture, or
|
|
85
|
+
process material and wants it merged into existing context, or says
|
|
86
|
+
"Reconcile the new material in ai/project/inbox/", follow
|
|
87
|
+
`ai/template/reconcile.md`. Do not re-bootstrap and do not overwrite the whole
|
|
88
|
+
context set.
|
|
89
|
+
|
|
90
|
+
New material should usually live in:
|
|
91
|
+
|
|
92
|
+
- `ai/project/inbox/*.md`
|
|
93
|
+
- `ai/project/inbox/raw/*.md`
|
|
94
|
+
- `docs/**`
|
|
95
|
+
|
|
96
|
+
Processed material is moved to `ai/project/inbox/processed/` and should not
|
|
97
|
+
trigger context reconciliation again by default.
|
|
98
|
+
|
|
99
|
+
Context reconciliation must produce a plan first and wait for human
|
|
100
|
+
confirmation before updating files.
|
|
101
|
+
|
|
102
|
+
By default, context reconciliation may update only:
|
|
103
|
+
|
|
104
|
+
- `ai/project/project.md`
|
|
105
|
+
- `ai/project/runtime.md`
|
|
106
|
+
- `ai/project/refs/*.md`
|
|
107
|
+
|
|
108
|
+
If new material would change directional content in the North Star, module map,
|
|
109
|
+
or roadmap, Context Reconcile Mode may only recommend a `strategy_update`. It
|
|
110
|
+
must not directly modify:
|
|
111
|
+
|
|
112
|
+
- `ai/project/refs/final-shape.md`
|
|
113
|
+
- `ai/project/refs/module-map.md`
|
|
114
|
+
- `ai/project/refs/roadmap.md`
|
|
115
|
+
|
|
116
|
+
Do not modify current task, results, metrics, archives, source, tests, config,
|
|
117
|
+
or dependency files unless the human explicitly authorizes it.
|
|
118
|
+
|
|
119
|
+
## Strategy Update Gate
|
|
120
|
+
|
|
121
|
+
If the user asks to update the North Star, final shape, product constitution,
|
|
122
|
+
module map, roadmap, or project direction, or if
|
|
123
|
+
`ai/project/inbox/ideas/` contains non-`.gitkeep` new ideas, execute
|
|
124
|
+
`strategy_update`.
|
|
125
|
+
|
|
126
|
+
`strategy_update` may only:
|
|
127
|
+
|
|
128
|
+
- read official direction docs, decisions, constraints, and idea inputs;
|
|
129
|
+
- use `ai/project/proposals/final-shape-updates/_template.md` as its structural
|
|
130
|
+
template;
|
|
131
|
+
- create `ai/project/proposals/final-shape-updates/YYYYMMDD-topic.md`;
|
|
132
|
+
- set the new proposal status to `proposed`;
|
|
133
|
+
- stop for human confirmation.
|
|
134
|
+
|
|
135
|
+
It must not directly modify official direction docs, source, tests, config, or
|
|
136
|
+
dependency files.
|
|
137
|
+
|
|
138
|
+
Only after the human explicitly confirms a proposal may
|
|
139
|
+
`apply_strategy_update` run. During application:
|
|
140
|
+
|
|
141
|
+
- the confirmed proposal should move from `proposed` to `accepted`, or already
|
|
142
|
+
be `accepted`;
|
|
143
|
+
- after merge, update the proposal to `applied` and fill `applied_at`;
|
|
144
|
+
- if the human rejects the proposal, keep the file and set `status` to
|
|
145
|
+
`rejected`;
|
|
146
|
+
- apply only confirmed content, without opportunistic expansion.
|
|
147
|
+
|
|
148
|
+
## Risk Gate
|
|
149
|
+
|
|
150
|
+
Before editing code or running commands, check whether the task involves:
|
|
151
|
+
|
|
152
|
+
- Data migration
|
|
153
|
+
- Authentication / authorization
|
|
154
|
+
- Payment / SMS / external callbacks
|
|
155
|
+
- Public API changes
|
|
156
|
+
- Production deployment
|
|
157
|
+
- Broad refactoring
|
|
158
|
+
- Irreversible or destructive actions
|
|
159
|
+
|
|
160
|
+
If risk is high and not explicitly authorized in `ai/project/task.md`, stop and
|
|
161
|
+
write blocked results.
|
|
162
|
+
|
|
163
|
+
## Ref Loading
|
|
164
|
+
|
|
165
|
+
Read refs only when needed or required by `ai/project/task.md`:
|
|
166
|
+
|
|
167
|
+
- Final shape / North Star / task-worthiness -> `ai/project/refs/final-shape.md`
|
|
168
|
+
- Current module structure / boundaries / dependency direction -> `ai/project/refs/module-map.md`
|
|
169
|
+
- Stage goals / near-term roadmap / deferred work -> `ai/project/refs/roadmap.md`
|
|
170
|
+
- Architecture / API / module boundary -> `ai/project/refs/architecture.md`
|
|
171
|
+
- Historical decision -> `ai/project/refs/decisions.md`
|
|
172
|
+
- Security / compatibility / performance / data / deployment -> `ai/project/refs/constraints.md`
|
|
173
|
+
- Build / test / run / deploy command -> `ai/project/refs/commands.md`
|
|
174
|
+
|
|
175
|
+
Record every ref read in `ai/project/result.json.refs_read` with a reason.
|
|
176
|
+
|
|
177
|
+
## Execution Rules
|
|
178
|
+
|
|
179
|
+
- Current task first.
|
|
180
|
+
- Do not expand scope.
|
|
181
|
+
- Do not scan unrelated files.
|
|
182
|
+
- Do not rewrite unrelated modules.
|
|
183
|
+
- Read files before guessing.
|
|
184
|
+
- Modify only files allowed by `ai/project/task.md`.
|
|
185
|
+
- Run only commands allowed by `ai/project/task.md` and `ai/project/refs/commands.md`.
|
|
186
|
+
- Prefer minimal safe changes.
|
|
187
|
+
- Record assumptions in `ai/project/result.json`.
|
|
188
|
+
- Verify when possible.
|
|
189
|
+
- Do not mark `status = "success"` unless verification passed.
|
|
190
|
+
- Do not edit `ai/project/runtime.md` unless `ai/project/task.md` explicitly allows it.
|
|
191
|
+
- If runtime changes are needed, propose them in `ai/project/result.json.runtime_update`.
|
|
192
|
+
|
|
193
|
+
## Runtime Governance
|
|
194
|
+
|
|
195
|
+
`ai/project/runtime.md` stores stable, currently valid execution context only.
|
|
196
|
+
It is not a project diary. Historical tasks and results belong in
|
|
197
|
+
`ai/project/archive/`.
|