@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.
Files changed (70) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +440 -0
  3. package/README.zh-CN.md +447 -0
  4. package/bin/agent-execution-template.js +792 -0
  5. package/docs/SPEC.md +1039 -0
  6. package/docs/token-efficient-protocol-v0.1.md +101 -0
  7. package/package.json +35 -0
  8. package/template/en/ai/README.md +130 -0
  9. package/template/en/ai/project/archive/.gitkeep +0 -0
  10. package/template/en/ai/project/inbox/.gitkeep +1 -0
  11. package/template/en/ai/project/inbox/ideas/.gitkeep +1 -0
  12. package/template/en/ai/project/inbox/processed/.gitkeep +0 -0
  13. package/template/en/ai/project/inbox/raw/.gitkeep +1 -0
  14. package/template/en/ai/project/metrics.json +20 -0
  15. package/template/en/ai/project/project.md +42 -0
  16. package/template/en/ai/project/proposals/final-shape-updates/.gitkeep +1 -0
  17. package/template/en/ai/project/proposals/final-shape-updates/_template.md +64 -0
  18. package/template/en/ai/project/refs/architecture.md +23 -0
  19. package/template/en/ai/project/refs/commands.md +43 -0
  20. package/template/en/ai/project/refs/constraints.md +24 -0
  21. package/template/en/ai/project/refs/decisions.md +13 -0
  22. package/template/en/ai/project/refs/final-shape.md +59 -0
  23. package/template/en/ai/project/refs/module-map.md +31 -0
  24. package/template/en/ai/project/refs/roadmap.md +31 -0
  25. package/template/en/ai/project/result.json +34 -0
  26. package/template/en/ai/project/result.md +32 -0
  27. package/template/en/ai/project/runtime.md +74 -0
  28. package/template/en/ai/project/task.md +110 -0
  29. package/template/en/ai/template/LANG +1 -0
  30. package/template/en/ai/template/VERSION +1 -0
  31. package/template/en/ai/template/bootstrap.md +194 -0
  32. package/template/en/ai/template/prompt.md +118 -0
  33. package/template/en/ai/template/protocol.md +332 -0
  34. package/template/en/ai/template/reconcile.md +140 -0
  35. package/template/en/ai/template/rules/core.md +197 -0
  36. package/template/en/ai/template/rules/output.md +51 -0
  37. package/template/en/ai/template/schemas/metrics.schema.json +119 -0
  38. package/template/en/ai/template/schemas/result.schema.json +234 -0
  39. package/template/zh/ai/README.md +129 -0
  40. package/template/zh/ai/project/archive/.gitkeep +0 -0
  41. package/template/zh/ai/project/inbox/.gitkeep +1 -0
  42. package/template/zh/ai/project/inbox/ideas/.gitkeep +1 -0
  43. package/template/zh/ai/project/inbox/processed/.gitkeep +0 -0
  44. package/template/zh/ai/project/inbox/raw/.gitkeep +1 -0
  45. package/template/zh/ai/project/metrics.json +20 -0
  46. package/template/zh/ai/project/project.md +42 -0
  47. package/template/zh/ai/project/proposals/final-shape-updates/.gitkeep +1 -0
  48. package/template/zh/ai/project/proposals/final-shape-updates/_template.md +64 -0
  49. package/template/zh/ai/project/refs/architecture.md +23 -0
  50. package/template/zh/ai/project/refs/commands.md +43 -0
  51. package/template/zh/ai/project/refs/constraints.md +24 -0
  52. package/template/zh/ai/project/refs/decisions.md +13 -0
  53. package/template/zh/ai/project/refs/final-shape.md +54 -0
  54. package/template/zh/ai/project/refs/module-map.md +30 -0
  55. package/template/zh/ai/project/refs/roadmap.md +29 -0
  56. package/template/zh/ai/project/result.json +34 -0
  57. package/template/zh/ai/project/result.md +32 -0
  58. package/template/zh/ai/project/runtime.md +74 -0
  59. package/template/zh/ai/project/task.md +106 -0
  60. package/template/zh/ai/template/LANG +1 -0
  61. package/template/zh/ai/template/VERSION +1 -0
  62. package/template/zh/ai/template/bootstrap.md +180 -0
  63. package/template/zh/ai/template/prompt.md +104 -0
  64. package/template/zh/ai/template/protocol.md +300 -0
  65. package/template/zh/ai/template/reconcile.md +134 -0
  66. package/template/zh/ai/template/rules/core.md +174 -0
  67. package/template/zh/ai/template/rules/output.md +51 -0
  68. package/template/zh/ai/template/schemas/metrics.schema.json +119 -0
  69. package/template/zh/ai/template/schemas/result.schema.json +234 -0
  70. package/test/selftest.js +280 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Agent Execution Template contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,440 @@
1
+ # Agent Execution Template
2
+
3
+ English | [简体中文](README.zh-CN.md)
4
+
5
+ [![npm](https://img.shields.io/npm/v/@wnlen/agent-execution-template?color=cb3837)](https://www.npmjs.com/package/@wnlen/agent-execution-template)
6
+ [![license](https://img.shields.io/badge/license-MIT-green.svg)](LICENSE)
7
+ [![protocol](https://img.shields.io/badge/protocol-v0.8-blue.svg)](docs/SPEC.md)
8
+ [![agent agnostic](https://img.shields.io/badge/agent-agnostic-111111.svg)](#works-with)
9
+
10
+ > A 30-second execution protocol for AI coding agents.
11
+ > Install it into any repository, let the agent bootstrap project context from existing docs, confirm the task contract, and keep execution auditable.
12
+
13
+ ```bash
14
+ npx -y @wnlen/agent-execution-template init --lang en
15
+ ```
16
+
17
+ Then tell your coding agent:
18
+
19
+ ```text
20
+ Start initializing this project
21
+ ```
22
+
23
+ Agent Execution Template is not another agent framework. It is the missing execution layer between your repository and tools like Codex, Claude Code, Cursor, Aider, or any other AI coding agent.
24
+
25
+ It turns AI coding from:
26
+
27
+ ```text
28
+ chat prompt -> ad hoc edits -> unclear verification -> lost context
29
+ ```
30
+
31
+ into:
32
+
33
+ ```text
34
+ bootstrap project -> confirm context -> draft task -> confirm contract -> execute -> recorded result
35
+ ```
36
+
37
+ ## Why It Exists
38
+
39
+ AI coding agents are powerful, but most teams still run them through loose chat context. That creates predictable failure modes:
40
+
41
+ - You repeat the same project background every session.
42
+ - The agent drifts beyond the task boundary.
43
+ - Risk, permissions, and acceptance criteria stay implicit.
44
+ - Code changes are made without reliable verification records.
45
+ - Useful execution history disappears into chat logs.
46
+ - Template upgrades accidentally overwrite project-specific context.
47
+ - Cheap and strong models are used without a clear division of labor.
48
+ - The two files that define execution precision are often written by hand.
49
+ - Execution can become stable while still lacking a direction layer for judging
50
+ whether a task is worth doing or whether the project is drifting.
51
+
52
+ Agent Execution Template fixes this with a small, installable file protocol:
53
+
54
+ ```text
55
+ ai/template/ reusable execution protocol
56
+ ai/project/ project-specific working context and direction layer
57
+ ```
58
+
59
+ `update` can refresh the protocol, while your project workspace stays protected.
60
+
61
+ ## Quick Start
62
+
63
+ Install the protocol into the current repository:
64
+
65
+ ```bash
66
+ npx -y @wnlen/agent-execution-template init --lang en
67
+ ```
68
+
69
+ Ask your agent to bootstrap project context from existing docs and manifests:
70
+
71
+ ```text
72
+ Start initializing this project
73
+ ```
74
+
75
+ The agent will generate project context and summarize what needs confirmation,
76
+ risks, and the recommended next step in chat:
77
+
78
+ ```text
79
+ ai/project/project.md
80
+ ai/project/refs/*
81
+ ```
82
+
83
+ Reply with corrections, or confirm and continue:
84
+
85
+ ```text
86
+ Continue this project
87
+ ```
88
+
89
+ The agent will draft or execute from current context:
90
+
91
+ ```text
92
+ ai/project/task.md
93
+ ```
94
+
95
+ After the task draft is confirmed, you can also say:
96
+
97
+ ```text
98
+ Continue this project
99
+ ```
100
+
101
+ Review the execution output:
102
+
103
+ ```text
104
+ ai/project/result.md
105
+ ai/project/result.json
106
+ ai/project/metrics.json
107
+ ```
108
+
109
+ Check the installation:
110
+
111
+ ```bash
112
+ npx -y @wnlen/agent-execution-template doctor
113
+ ```
114
+
115
+ When you forget what to do next:
116
+
117
+ ```bash
118
+ npx -y @wnlen/agent-execution-template next --lang en
119
+ ```
120
+
121
+ Resummarize and improve the project context:
122
+
123
+ ```bash
124
+ npx -y @wnlen/agent-execution-template refresh --lang en
125
+ ```
126
+
127
+ Upgrade only the reusable protocol files:
128
+
129
+ ```bash
130
+ npx -y @wnlen/agent-execution-template update --lang en
131
+ ```
132
+
133
+ Print the direction-amendment entrypoint:
134
+
135
+ ```bash
136
+ npx -y @wnlen/agent-execution-template strategy --lang en
137
+ ```
138
+
139
+ ## What You Get
140
+
141
+ | Capability | What it means |
142
+ | --- | --- |
143
+ | Installable protocol | Add an AI execution contract to any repository in seconds. |
144
+ | Agent agnostic | Works with Codex, Claude Code, Cursor, Aider, and other coding agents. |
145
+ | Bootstrap mode | Reads approved docs/manifests, falls back to bounded code inference, drafts `project.md` and refs, then stops for confirmation. |
146
+ | Project North Star | Stores final shape, task-worthiness criteria, and drift criteria in `ai/project/refs/final-shape.md`. |
147
+ | Strategy amendment gate | New direction goes through `inbox/ideas/`, a proposal, human confirmation, then an explicit apply task. |
148
+ | Protected project context | `update` refreshes `ai/template/**` without overwriting `ai/project/**`. |
149
+ | Project context refresh | `refresh` backs up old `ai/project/**`, creates a fresh project context, and imports the old context into the inbox for reconciliation. |
150
+ | Bounded task execution | Goals, scope, permissions, risk, and acceptance criteria live in one task file. |
151
+ | Auditable results | Every run can leave human-readable output, machine-readable facts, and metrics. |
152
+ | Token-efficient model policy | Cheap models handle bounded work; strong models are reserved for judgment points. |
153
+ | Upgradeable template | Reuse protocol improvements without losing local project memory. |
154
+ | Doctor checks | Validate required files and template version before running the agent. |
155
+
156
+ ## Installed Layout
157
+
158
+ ```text
159
+ ai/
160
+ README.md
161
+
162
+ template/
163
+ VERSION
164
+ bootstrap.md
165
+ prompt.md
166
+ reconcile.md
167
+ protocol.md
168
+ rules/
169
+ core.md
170
+ output.md
171
+ schemas/
172
+ result.schema.json
173
+ metrics.schema.json
174
+
175
+ project/
176
+ project.md
177
+ runtime.md
178
+ task.md
179
+ result.json
180
+ result.md
181
+ metrics.json
182
+ inbox/
183
+ ideas/
184
+ raw/
185
+ proposals/
186
+ final-shape-updates/
187
+ refs/
188
+ final-shape.md
189
+ module-map.md
190
+ roadmap.md
191
+ archive/
192
+ ```
193
+
194
+ The split is the core design:
195
+
196
+ - `ai/template/**` is reusable protocol. It can be safely updated from this package.
197
+ - `ai/project/**` is your project workspace. It stores local context, tasks, references, results, and metrics.
198
+
199
+ ## Commands
200
+
201
+ ### `init`
202
+
203
+ ```bash
204
+ npx -y @wnlen/agent-execution-template init --lang en
205
+ ```
206
+
207
+ Creates `ai/` in the current project.
208
+
209
+ - Updates or creates `ai/template/**`.
210
+ - Creates missing `ai/project/**` files.
211
+ - Keeps existing `ai/project/**` files intact.
212
+ - Use `--lang zh` or omit `--lang` for the Chinese template.
213
+
214
+ ### `next`
215
+
216
+ ```bash
217
+ npx -y @wnlen/agent-execution-template next --lang en
218
+ ```
219
+
220
+ Prints the next step based on the current project state:
221
+
222
+ - If the template is not installed, it tells you to run `init`.
223
+ - If `ai/project/inbox/` has material, it routes to context reconcile.
224
+ - If `ai/project/inbox/ideas/` has ideas, it routes to a direction amendment proposal.
225
+ - If a direction proposal exists, it asks for human review and confirmation.
226
+ - If no intake is waiting, it tells the agent to continue the project.
227
+
228
+ ### `update`
229
+
230
+ ```bash
231
+ npx -y @wnlen/agent-execution-template update --lang en
232
+ ```
233
+
234
+ Updates only `ai/template/**`.
235
+
236
+ Use this when the protocol improves but your project context should remain untouched.
237
+ Without `--lang`, `update` follows the installed language in `ai/template/LANG`.
238
+
239
+ ### `refresh`
240
+
241
+ ```bash
242
+ npx -y @wnlen/agent-execution-template refresh --lang en
243
+ ```
244
+
245
+ Resummarizes and improves project context.
246
+
247
+ - Renames old `ai/project/**` to `ai/project.backup.<timestamp>`.
248
+ - Generates a fresh `ai/project/**`.
249
+ - Copies the old context into `ai/project/inbox/raw/old-project/`.
250
+ - Prints the next prompt to give your agent.
251
+
252
+ You can also use the more explicit alias:
253
+
254
+ ```bash
255
+ npx -y @wnlen/agent-execution-template improve-context --lang en
256
+ ```
257
+
258
+ ### `doctor`
259
+
260
+ ```bash
261
+ npx -y @wnlen/agent-execution-template doctor
262
+ ```
263
+
264
+ Checks the installed template version and required files.
265
+
266
+ It reports:
267
+
268
+ - `[OK]` for present and usable files.
269
+ - `[WARN]` for empty required project context files.
270
+ - `[MISSING]` for missing required files.
271
+
272
+ ### `reconcile`
273
+
274
+ ```bash
275
+ npx -y @wnlen/agent-execution-template reconcile --lang en
276
+ ```
277
+
278
+ Prints the shortest context-reconcile instructions.
279
+
280
+ ### `strategy`
281
+
282
+ ```bash
283
+ npx -y @wnlen/agent-execution-template strategy --lang en
284
+ ```
285
+
286
+ Prints the shortest direction-amendment instructions. New ideas go to
287
+ `ai/project/inbox/ideas/`, then the agent generates a `strategy_update`
288
+ proposal. After human confirmation, `apply_strategy_update` merges it.
289
+
290
+ ## Execution Model
291
+
292
+ Agent Execution Template defines a simple loop:
293
+
294
+ ```text
295
+ Project Bootstrap -> Project Confirm -> Task Draft -> Task Confirm -> Plan -> Execute -> Review -> Result
296
+ ```
297
+
298
+ The point is not to build a complex orchestrator. The point is to make one AI-assisted coding run clear enough to execute, verify, rerun, and audit.
299
+
300
+ The protocol records:
301
+
302
+ - approved bootstrap sources,
303
+ - the task contract,
304
+ - assumptions and risk,
305
+ - verification attempts,
306
+ - human-readable results,
307
+ - machine-readable execution facts,
308
+ - model tier and cost signals.
309
+
310
+ ## Context Reconcile
311
+
312
+ When a more complete or more authoritative document appears after the project has been using the template, put it in:
313
+
314
+ ```text
315
+ ai/project/inbox/
316
+ ```
317
+
318
+ Then ask your agent:
319
+
320
+ ```text
321
+ Reconcile the new material in ai/project/inbox/
322
+ ```
323
+
324
+ The agent must produce a reconciliation plan first, wait for confirmation, then merge long-lived facts into `project.md`, `runtime.md`, and `refs/*`.
325
+ After reconciliation, processed material is moved to `ai/project/inbox/processed/` for traceability.
326
+
327
+ ## Project North Star
328
+
329
+ Long-term direction does not belong in the current task. Agent Execution Template
330
+ stores the direction layer inside protected `ai/project/**` files:
331
+
332
+ ```text
333
+ ai/project/refs/final-shape.md # project North Star / final shape
334
+ ai/project/refs/module-map.md # current module map
335
+ ai/project/refs/roadmap.md # staged roadmap
336
+ ai/project/inbox/ideas/ # new idea intake
337
+ ai/project/proposals/final-shape-updates/
338
+ ai/project/proposals/final-shape-updates/_template.md
339
+ ```
340
+
341
+ Routine execution tasks must not edit the North Star, module map, or roadmap
342
+ directly. Direction changes should follow:
343
+
344
+ ```text
345
+ idea -> strategy_update proposal -> human confirm -> apply_strategy_update
346
+ ```
347
+
348
+ That keeps `task.md` as the current work order while `final-shape.md` explains
349
+ why a task is worth doing and where the project should grow.
350
+
351
+ ## Token-Efficient by Design
352
+
353
+ The optional token-efficient profile gives agents a model division rule:
354
+
355
+ - Use `cheap` models for bounded reads, small edits, drafts, repetitive checks, and mechanical cleanup.
356
+ - Use `standard` models for moderate implementation work.
357
+ - Use `strong` models for planning, architecture review, risk judgment, failure review, and acceptance disputes.
358
+
359
+ The goal is not fewer tokens at any cost. The goal is more acceptable work per unit of model cost.
360
+
361
+ Read more in [Token-Efficient AI Execution Protocol v0.1](docs/token-efficient-protocol-v0.1.md).
362
+
363
+ ## Works With
364
+
365
+ Agent Execution Template is intentionally tool-neutral. Any agent that can read project files and follow instructions can use it.
366
+
367
+ Common pairings:
368
+
369
+ - Codex
370
+ - Claude Code
371
+ - Cursor
372
+ - Aider
373
+ - custom coding agents
374
+ - low-cost model runners for bounded execution
375
+
376
+ ## Designed For
377
+
378
+ - Developers who run AI coding agents across many repositories.
379
+ - Teams that want repeatable AI execution without adopting a full agent platform.
380
+ - Projects where task boundaries, verification, and audit trails matter.
381
+ - Workflows that use cheap models by default and escalate only for judgment.
382
+ - Repositories that need AI context to live in files, not only in chat history.
383
+ - Users who want AI to draft the critical context files while humans confirm the final boundary.
384
+
385
+ ## Not This
386
+
387
+ Agent Execution Template is not:
388
+
389
+ - an IDE,
390
+ - an agent platform,
391
+ - a multi-agent scheduler,
392
+ - a cloud service,
393
+ - a prompt collection,
394
+ - a replacement for Codex, Claude Code, Cursor, or Aider.
395
+
396
+ It is a small file protocol for making those tools behave more consistently inside real software projects.
397
+
398
+ ## Specification
399
+
400
+ - [Full specification](docs/SPEC.md)
401
+ - [Token-efficient protocol profile](docs/token-efficient-protocol-v0.1.md)
402
+
403
+ Current package:
404
+
405
+ ```text
406
+ Package: @wnlen/agent-execution-template
407
+ Protocol: v0.8
408
+ License: MIT
409
+ ```
410
+
411
+ ## Development
412
+
413
+ Run the self-test:
414
+
415
+ ```bash
416
+ npm test
417
+ ```
418
+
419
+ The test suite verifies the core CLI contract:
420
+
421
+ - `init` creates the expected protocol and project files.
422
+ - `update` does not overwrite `ai/project/**`.
423
+ - `doctor` reports missing and empty required files correctly.
424
+
425
+ ## Contributing
426
+
427
+ Issues and pull requests are welcome.
428
+
429
+ Good contributions usually improve one of these areas:
430
+
431
+ - clearer task contracts,
432
+ - safer project/template boundaries,
433
+ - better result schemas,
434
+ - better metrics for model cost and verification,
435
+ - stronger examples for real coding-agent workflows,
436
+ - sharper documentation for team adoption.
437
+
438
+ ## License
439
+
440
+ [MIT](LICENSE)