easy-coding-harness 0.1.8 → 0.3.0

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 (36) hide show
  1. package/CHANGELOG.md +120 -0
  2. package/README.md +109 -135
  3. package/dist/cli.js +1218 -282
  4. package/dist/cli.js.map +1 -1
  5. package/package.json +10 -1
  6. package/templates/claude/agents/ec-implementer.md +1 -1
  7. package/templates/claude/agents/ec-reviewer.md +1 -1
  8. package/templates/common/bundled-skills/ec-init/SKILL.md +174 -0
  9. package/templates/common/bundled-skills/ec-init/references/memory-migration.md +87 -0
  10. package/templates/common/bundled-skills/ec-meta/SKILL.md +5 -2
  11. package/templates/common/bundled-skills/ec-meta/references/customize-local/README.md +2 -1
  12. package/templates/common/bundled-skills/ec-meta/references/local-architecture/README.md +14 -11
  13. package/templates/common/bundled-skills/ec-meta/references/platform-files/README.md +8 -4
  14. package/templates/common/skills/ec-analysis/SKILL.md +111 -130
  15. package/templates/common/skills/ec-brainstorming/SKILL.md +1 -1
  16. package/templates/common/skills/ec-git/SKILL.md +10 -10
  17. package/templates/common/skills/ec-implementing/SKILL.md +31 -24
  18. package/templates/common/skills/ec-memory/SKILL.md +41 -16
  19. package/templates/common/skills/ec-reviewing/SKILL.md +1 -1
  20. package/templates/common/skills/ec-task-close/SKILL.md +4 -3
  21. package/templates/common/skills/ec-task-management/SKILL.md +9 -24
  22. package/templates/common/skills/ec-verification/SKILL.md +10 -4
  23. package/templates/common/skills/ec-workflow/SKILL.md +48 -17
  24. package/templates/main-constraint/AGENTS.md.tpl +16 -3
  25. package/templates/main-constraint/CLAUDE.md.tpl +16 -3
  26. package/templates/runtime/memory/SHORT_MEMORY_TEMPLATE.md +75 -0
  27. package/templates/runtime/memory/long/BUSINESS.md +42 -9
  28. package/templates/runtime/memory/long/MEMORY.md +37 -2
  29. package/templates/runtime/memory/long/TECHNICAL.md +45 -1
  30. package/templates/runtime/templates/dev-spec-skeleton.md +80 -0
  31. package/templates/shared-hooks/easy_coding_state.py +610 -0
  32. package/templates/shared-hooks/easy_coding_status.py +72 -81
  33. package/templates/shared-hooks/inject-subagent-context.py +5 -12
  34. package/templates/shared-hooks/inject-workflow-state.py +2 -1
  35. package/templates/shared-hooks/session-start.py +2 -1
  36. package/templates/common/skills/ec-init/SKILL.md +0 -96
@@ -3,6 +3,8 @@ name: ec-analysis
3
3
  description: ANALYSIS-stage skill. Use when ec-workflow enters ANALYSIS. Creates the dev-spec skeleton FIRST (template-first), then fills incrementally — producing the narrative plan, execution plan (execution.jsonl), and test strategy. Ends in WAITING_CONFIRM. Grounds every conclusion in real code, never restates the requirement.
4
4
  ---
5
5
 
6
+ > **SKELETON FIRST — your first two tool calls MUST be: (1) Read `.easy-coding/templates/dev-spec-skeleton.md`, (2) Write its EXACT content to the task's dev-spec.md. No exceptions. Do not analyze or think before the skeleton file exists on disk.**
7
+
6
8
  # ec-analysis — turn a requirement into a confirmable plan
7
9
 
8
10
  ec-workflow dispatches you when a task enters ANALYSIS. You read the codebase, decide *how*
@@ -12,20 +14,44 @@ Communicate with the user in the user's language.
12
14
 
13
15
  ## HARD RULES (non-negotiable, violations = failed analysis)
14
16
 
15
- 1. **Your FIRST tool call** in this skill MUST be a file-write that creates
16
- `.easy-coding/tasks/{task-id}/dev-spec.md` with the COMPLETE template skeleton from the
17
- "Required output" section below. No reading, no thinking out loud, no "let me analyze
18
- first" skeleton file FIRST. If this file does not exist after your first tool call, you
19
- have already failed.
17
+ 1. **Your FIRST TWO tool calls** in this skill MUST be:
18
+ - **Call 1 (Read):** Read `.easy-coding/templates/dev-spec-skeleton.md`.
19
+ - **Call 2 (Write):** Write the EXACT content you just read to
20
+ `.easy-coding/tasks/{task-id}/dev-spec.md`. This is a mechanical copy do not rephrase
21
+ headers, omit sections, rearrange content, or substitute placeholders with your own text.
22
+ The file content must be identical to the template you just read.
23
+ If dev-spec.md does not exist with the correct template after your second tool call,
24
+ you have already failed. Do not read code, think aloud, or analyze before the skeleton
25
+ is on disk.
20
26
  2. **All subsequent analysis** fills sections of this file via edits. You do NOT hold analysis
21
27
  in your head and dump it at the end — you write each section into the file as you go.
22
- 3. **Your chat output to the user** MUST be the final content of dev-spec.md (copy it into
23
- your reply or reference it). You MUST NOT invent a different, abbreviated format. No
24
- "执行计划" summary tables, no bullet-point plans, no freestyle answers. The template IS
25
- the format. If your reply to the user does not contain every mandatory section header from
26
- the template, you have failed.
28
+ 3. **Your chat output to the user IS dev-spec.md, verbatim.** After dev-spec.md is complete,
29
+ use the Read tool to read it back, then output exactly what you read as your reply — this
30
+ is a copy operation, not a re-narration. Do NOT reconstruct it from memory, do NOT
31
+ abbreviate, do NOT invent a different format. No "执行计划" summary tables, no bullet-point
32
+ plans, no freestyle answers. The template IS the format. If your reply does not contain
33
+ every mandatory section header from the template, you have failed.
27
34
  4. **Three files must exist** in `.easy-coding/tasks/{task-id}/` when you finish:
28
35
  `dev-spec.md`, `execution.jsonl` (plan record), `test-strategy.md`. Missing any one = failed.
36
+ 5. **Stay faithful to the user's delivery form (anti-downgrade).** The delivery form —
37
+ change real code vs. produce a document — is set by the user's original request, NOT by
38
+ you. If the user asked to refactor / fix / add a feature (a CODE task), you MUST plan real
39
+ code changes. You may NOT downgrade it to "produce a report / audit / inventory only" or
40
+ "defer all changes to follow-up sub-tasks." A large change surface is NOT a reason to
41
+ downgrade: decompose it into batches/units in 实施拆解, and surface "split into batches? /
42
+ which subset this round?" as an explicit item in 待用户决策 for the user to decide. Never
43
+ make a scope-narrowing decision yourself and present it as settled. Never fabricate a
44
+ premise such as "the user already fixed scope X in INIT" or "auto_mode already selected Y"
45
+ to justify narrowing — `auto_mode` only waives the WAITING_CONFIRM confirmation step and
46
+ carries NO scope or delivery-form decision whatsoever.
47
+ 6. **改动范围 lists ONLY real project code.** The 改动范围 table carries only changes to real
48
+ project source/config files. Any harness artifact under `.easy-coding/` (dev-spec.md,
49
+ execution.jsonl, test-strategy.md, memory files, generated reports, etc.) is FORBIDDEN in
50
+ this table — those are process outputs, not "changes." The table MAY be empty, but ONLY
51
+ when the user explicitly asked for a no-code delivery form (e.g. a pure documentation
52
+ request); in that case declare the deliverable in 需求解析 > 输出. If the task type is a
53
+ code task (重构 / Bug 修复 / 新功能 / 性能优化) yet 改动范围 is empty, you have downgraded
54
+ the task — this is a failed analysis.
29
55
 
30
56
  ## Inputs to load (in this order)
31
57
 
@@ -44,16 +70,19 @@ Communicate with the user in the user's language.
44
70
 
45
71
  If the task spans repositories: declare them in the dev-spec (trigger repo + involved repos
46
72
  by **name**, never local paths). For each involved repo, read its ABSTRACT to understand the
47
- interface. Cache any local path the user provides only in `state.json.repo_paths`. If a repo
48
- name cannot be located locally, ask the user for the path before proceeding.
73
+ interface. Cache any local path the user provides through the state API only:
74
+ `{{PYTHON_CMD}} {{platform_config_dir}}/hooks/easy_coding_state.py set-repo-path --session-file <P> --repo <repo-name> --path <local-path>`.
75
+ If a repo name cannot be located locally, ask the user for the path before proceeding.
49
76
 
50
77
  ## Analysis procedure (mandatory sequence)
51
78
 
52
79
  You MUST execute these steps in exact order. Do not rearrange, skip, or combine steps.
53
80
 
54
- 1. **Write skeleton** — FIRST tool call: write `.easy-coding/tasks/{task-id}/dev-spec.md`
55
- using the full template from the next section. Every section header and every `{待填写}`
56
- placeholder must be present. This is not optional.
81
+ 1. **Write skeleton** — FIRST TWO tool calls:
82
+ - Read `.easy-coding/templates/dev-spec-skeleton.md` (the template file).
83
+ - Write its exact content to `.easy-coding/tasks/{task-id}/dev-spec.md`.
84
+ This is a copy operation, not a generation task. Every section header and every `{待填写}`
85
+ placeholder in the template must appear in the written file unchanged.
57
86
  2. **Fill 项目模式 + 任务类型** — edit dev-spec.md in place.
58
87
  3. **Fill 需求解析** — edit dev-spec.md: 目标 / 输入 / 输出 / 边界.
59
88
  4. **Read source code, fill 现状** — read the actual files, then edit dev-spec.md with
@@ -67,113 +96,55 @@ You MUST execute these steps in exact order. Do not rearrange, skip, or combine
67
96
  10. **Write execution.jsonl** — append the plan record (see section below).
68
97
  11. **Write test-strategy.md** — write the testability table (see section below).
69
98
  12. **Self-check** — run the gates below. Fix any failure in the files.
70
- 13. **Present to user** — output the FINAL content of dev-spec.md to the user as your reply.
71
- Do not summarize, abbreviate, or reformat. The dev-spec.md content IS your reply.
72
-
73
- ## Required output: dev-spec.md template
74
-
75
- The skeleton below is the EXACT file you MUST write as step 1. Copy it character-for-character
76
- into `.easy-coding/tasks/{task-id}/dev-spec.md`. Do not rephrase headers, do not omit
77
- sections, do not invent alternative formats. Later steps fill the `{待填写}` placeholders
78
- via edits. Conditional sections are added only if applicable.
79
-
80
- ````markdown
81
- [阶段:ANALYSIS]
82
-
83
- ## 技术方案:{任务标题}
84
-
85
- ### 项目模式
86
- {初创项目/迭代项目}
87
-
88
- ### 任务类型
89
- {新功能 / Bug 修复 / 重构 / 性能优化 / 前端设计实现}
90
-
91
- ### 需求解析
92
- - **目标**:{待填写 — 真正要解决的问题}
93
- - **输入**:{待填写 — 用户输入 / 系统输入 / 触发条件}
94
- - **输出**:{待填写 — 最终交付结果}
95
- - **边界**:{待填写 — 明确不做什么}
96
-
97
- ### 现状
98
- - **相关代码 / 页面 / 接口 / 模块**:{待填写 — 基于实际文件与代码的现状说明}
99
- - **当前实现方式**:{待填写 — 现在是如何工作的}
100
- - **现有问题 / 缺口**:{待填写 — 为什么需要改}
101
- - **证据**:{待填写 — 引用的关键文件、类、页面、接口,含 file:line}
102
-
103
- ### 冲突摘要
104
- - 需求 vs RULES:{待填写 "无冲突"}
105
- - 需求 vs ABSTRACT:{待填写 "无冲突"}
106
- - 需求 vs 现有代码:{待填写 或 "无冲突"}
107
- - Dev-Spec vs 现有代码:{待填写 "无冲突"}
108
-
109
- ### 待用户决策
110
- - {待填写 影响技术路线、接口、改动范围的问题逐条列出;若无则写"无"}
111
-
112
- ### 影响面分析
113
- - **涉及模块**:{待填写}
114
- - **核心类 / 页面 / 接口**:{待填写}
115
- - **数据库变更**:{有/无}
116
- - **接口变更**:{有/无}
117
- - **关联历史任务**:{待填写 相关短期记忆序号;无则"无"}
118
-
119
- ### 改动范围
120
- | 改动文件 | 改动类型 | 文件编码 | 改动核心内容 |
121
- |----------|---------|---------|-------------|
122
- | `{文件路径}` | 新增 | 项目编码 {X},依据:{xxx} | {核心改动} |
123
- | `{文件路径}` | 修改 | 保持原编码 {X} | {核心改动} |
124
- | `{文件路径}` | 删除 | — | {删除原因} |
125
-
126
- ### 修改方案
127
- - **总体改法**:{待填写 — 一句话说清改哪里、怎么改}
128
- - **后端改动**:{待填写;不涉及则写"不涉及"}
129
- - **前端改动**:{待填写;不涉及则写"不涉及"}
130
- - **兼容处理**:{待填写 — 旧逻辑如何迁移、保留或替换}
131
- - **风险点**:{待填写 — 最容易出问题的位置}
132
-
133
- ### 实施拆解
134
-
135
- | 单元 | 说明 | 类型 | 涉及文件 | 依赖 |
136
- |------|------|------|---------|------|
137
- | U1 | {title} | {backend/frontend/test/...} | {files} | — |
138
- | U2 | {title} | {type} | {files} | — |
139
- | U3 | {title} | {type} | {files} | U1, U2 |
140
-
141
- **执行策略**:{parallel / sequential / single}
142
- - 第一批(并行):U1 {title} | U2 {title}
143
- - 第二批(等待第一批):U3 {title}
144
- (若 single:单一实施单元,主 agent 直接执行)
145
-
146
- ### 测试策略
147
-
148
- | 测试点 | 级别 | 归属单元 | 方式 | 验证命令 |
149
- |--------|------|---------|------|---------|
150
- | {描述} | 必测 | U1 | 单测 | `npm test -- --filter=xxx` |
151
- | {描述} | 应测 | U2 | 快照 | `npm test -- --snapshot` |
152
-
153
- - **人工验收**:{待填写 — 用户需要检查的关键行为}
154
- - **无法验证项**:{待填写 — 无 / 说明缺失环境、数据或权限}
155
-
156
- ### 风险与注意事项
157
- - {风险 1}
158
- - {风险 2}
159
- ````
160
-
161
- > **编码规则**:修改已有文件必须保持原始编码;新文件声明项目编码并附证据;证据冲突或
162
- > 未知时标记"需用户确认"。用户可在确认前覆盖任何编码单元格。
163
-
164
- **条件展开章节**(仅在满足条件时添加,否则完全不出现):
165
-
166
- - `### 背景数据应用` — 命中项目知识资产(ABSTRACT.md、BUSINESS.md、TECHNICAL.md、RULES.md)
167
- 且其内容影响本次方案时展开。含架构参考、业务记忆、技术记忆、记忆冲突、规范约束。
168
- - `### 核心改动明细` — 多模块且改动范围表不足以表达当前逻辑和目标逻辑时展开。
169
- 逐文件列出"当前逻辑 → 准备怎么改"。
170
- - `### 前端实现映射` — 涉及前端页面、组件、交互时展开。含页面/模块映射、组件映射、
171
- 数据来源、Mock 使用计划。
172
-
173
- **禁止输出**:
174
- - 仅复述需求、几乎不引用代码现状的空泛方案。
175
- - 只列"已加载哪些信息"但不给出具体可实施改法。
176
- - 为了凑格式输出与本次任务无关的条件章节。
99
+ 13. **Present to user** — Read dev-spec.md back from disk and output exactly what you read as
100
+ your reply. Do not summarize, abbreviate, reformat, or reconstruct from memory. The
101
+ dev-spec.md content on disk IS your reply.
102
+
103
+ ## Required output: dev-spec.md structure
104
+
105
+ The template lives at `.easy-coding/templates/dev-spec-skeleton.md`. You MUST read it with
106
+ the Read tool and write its exact content to the task's dev-spec.md as step 1. Do NOT generate
107
+ the skeleton from memory or from this instruction — READ the file and WRITE what you read.
108
+
109
+ If `.easy-coding/templates/dev-spec-skeleton.md` does not exist, tell the user to run
110
+ `easy-coding upgrade` in the terminal to restore it. Do not generate the skeleton from memory.
111
+
112
+ If the hook injects `[easy-coding:analysis-template-drift:missing:...]`, you have deviated
113
+ from the template. Re-read the template file, compare it against your dev-spec.md, and fix
114
+ any missing or renamed section headers immediately.
115
+
116
+ **Mandatory section headers** (all 13 must be present in the skeleton — the hook validates these):
117
+
118
+ 1. `## 技术方案`
119
+ 2. `### 项目模式`
120
+ 3. `### 任务类型`
121
+ 4. `### 需求解析`
122
+ 5. `### 现状`
123
+ 6. `### 冲突摘要`
124
+ 7. `### 待用户决策`
125
+ 8. `### 影响面分析`
126
+ 9. `### 改动范围`
127
+ 10. `### 修改方案`
128
+ 11. `### 实施拆解`
129
+ 12. `### 测试策略`
130
+ 13. `### 风险与注意事项`
131
+
132
+ > **Encoding rule**: modified files keep their original encoding; new files declare the
133
+ > project encoding with evidence; conflicting or unknown encoding → mark "需用户确认".
134
+ > Users can override any encoding cell at confirmation.
135
+
136
+ **Conditional sections** (add only when applicable, otherwise omit entirely):
137
+
138
+ - `### 背景数据应用` — project knowledge assets (ABSTRACT.md, BUSINESS.md, TECHNICAL.md,
139
+ RULES.md) are relevant and influence the plan.
140
+ - `### 核心改动明细` — multi-module change where the scope table is insufficient to express
141
+ current logic and target logic.
142
+ - `### 前端实现映射` — frontend pages, components, or interactions are involved.
143
+
144
+ **Forbidden output:**
145
+ - Restating requirements without citing code evidence.
146
+ - Listing "loaded information" without a concrete implementation approach.
147
+ - Including conditional sections that are irrelevant to the current task.
177
148
 
178
149
  ## Implementation units → execution.jsonl
179
150
 
@@ -184,10 +155,13 @@ Decompose the work into units, then append ONE `plan` record to
184
155
  {"type":"plan","strategy":"parallel","units":[{"id":"U1","title":"...","type":"backend","files":["..."],"depends_on":[],"rules_sections":["naming","error-handling"],"abstract_modules":["user-service"]}],"parallel_groups":[{"level":0,"units":["U1","U2"]},{"level":1,"units":["U3"]}]}
185
156
  ```
186
157
 
187
- Strategy selection (drives whether ec-implementing spawns sub-agents):
188
- - `single` — one unit. Main agent implements directly.
189
- - `sequential` — multiple units with a hard dependency chain.
190
- - `parallel` — two or more independent units. ec-implementing MUST use sub-agents.
158
+ Strategy selection (drives ec-implementing's sub-agent orchestration shape — every strategy
159
+ dispatches sub-agents; none implements inline):
160
+ - `single` — one unit. ec-implementing dispatches one sub-agent.
161
+ - `sequential` — multiple units with a hard dependency chain. ec-implementing dispatches
162
+ sub-agents one at a time in dependency order.
163
+ - `parallel` — two or more independent units. ec-implementing dispatches sub-agents per level
164
+ concurrently.
191
165
 
192
166
  Each unit carries `rules_sections` and `abstract_modules` so ec-implementing can build a
193
167
  precise task card without the sub-agent re-reading the whole repo. `depends_on` sets the
@@ -226,7 +200,7 @@ VERIFICATION baseline).
226
200
  - [ ] `dev-spec.md` 文件是否已写入 `.easy-coding/tasks/{task-id}/`?
227
201
  - [ ] `execution.jsonl` 文件是否已写入?
228
202
  - [ ] `test-strategy.md` 文件是否已写入?
229
- - [ ] dev-spec.md 是否包含全部 12 个核心章节标题?
203
+ - [ ] dev-spec.md 是否包含全部 13 个必填章节标题(参见上方清单)?
230
204
  - [ ] 每个"现状"断言是否引用了真实文件/类/行号?
231
205
  - [ ] 是否有具体的修改方案,而非仅罗列"已加载的文件"?
232
206
  - [ ] 不适用的条件章节是否已完全省略(而非留空)?
@@ -234,9 +208,15 @@ VERIFICATION baseline).
234
208
  - [ ] 改动范围表中每行是否填写了文件编码及证据?
235
209
  - [ ] 所有 `{待填写}` 占位符是否已替换为实际内容?
236
210
  - [ ] 回复给用户的内容是否是 dev-spec.md 的完整内容(而非自创的缩略格式)?
211
+ - [ ] 交付形态是否忠于用户原始需求?代码类任务(重构/修复/功能)是否规划了真实代码改动,而非降级为"仅出报告/分析清单/留作后续子任务"?
212
+ - [ ] 「改动范围」是否只含真实项目源码/配置,且不含任何 `.easy-coding/` 下的 harness 产物(dev-spec/execution/test-strategy/记忆/报告)?
213
+ - [ ] 若「改动范围」为空,是否确为用户明确要求的无代码交付形态,而非 AI 自行降级的结果?
214
+ - [ ] 任何"本次不做全部 / 分批落地 / 范围收窄"的决定,是否已列入「待用户决策」交由用户拍板,而非自行拍板并假托既定?
237
215
 
238
216
  ## Revision handling
239
217
 
218
+ > 修订同样受 HARD RULE 5/6 约束:用户的修订诉求若是扩大或细化代码改动,不得借机把任务降级为"出报告";范围收窄仍须作为 待用户决策 项由用户确认。
219
+
240
220
  On user revision request at WAITING_CONFIRM, do NOT reply with only a change summary.
241
221
  Re-output the COMPLETE revised dev-spec.md:
242
222
 
@@ -250,6 +230,7 @@ Re-output the COMPLETE revised dev-spec.md:
250
230
 
251
231
  ## End state
252
232
 
253
- Output the COMPLETE content of dev-spec.md as your reply to the user — not a summary, not a
254
- different format, not a table you invented. Then set stage to WAITING_CONFIRM and hand
255
- control back to ec-workflow. Never start implementing from this skill.
233
+ Read dev-spec.md back from disk and output the COMPLETE content as your reply to the user —
234
+ not a summary, not a different format, not a table you invented. Then set stage to
235
+ WAITING_CONFIRM and hand control back to ec-workflow. Never start implementing from this
236
+ skill.
@@ -78,5 +78,5 @@ be suspended (ec-workflow's intent routing handles the rest).
78
78
 
79
79
  - Write no implementation code, scaffold nothing, take no implementation action.
80
80
  - The only ec-* skill you may invoke is `ec-workflow` (on user confirmation after approval).
81
- Do not touch state.json or the state machine directly.
81
+ Do not touch session files, task status fields, or the state machine directly.
82
82
  - One question per message — never overwhelm.
@@ -6,8 +6,8 @@ description: Git discipline skill for Easy Coding projects. Use when the task in
6
6
  # ec-git — git discipline
7
7
 
8
8
  Activate for any git operation inside an Easy Coding project: pull, merge, rebase, commit,
9
- push, PR. You manage git hygiene only — you never change `state.json` stage fields or trigger
10
- stage transitions.
9
+ push, PR. You manage git hygiene only — you never change session files, task status fields,
10
+ or trigger stage transitions.
11
11
 
12
12
  Communicate with the user in the user's language.
13
13
 
@@ -15,7 +15,7 @@ Communicate with the user in the user's language.
15
15
 
16
16
  | Path | In commit set? | Why |
17
17
  |---|---|---|
18
- | `state.json` | **never** | personal runtime state, differs per developer |
18
+ | `sessions/` | **never** | personal runtime state, differs per developer |
19
19
  | `config.yaml` | yes | shared team config |
20
20
  | `tasks/*/task.json` `dev-spec.md` `execution.jsonl` `test-strategy.md` | yes | per-task folders, no merge conflicts; team-readable decision record |
21
21
  | `SOUL.md` `RULES.md` `ABSTRACT.md` `TEST_STRATEGY.md` `CHANGELOG.md` | yes | shared project knowledge |
@@ -24,7 +24,7 @@ Communicate with the user in the user's language.
24
24
  | `spec/dev/` | only if user explicitly asks | dev-spec candidates for the *current* requirement, default out of commit |
25
25
 
26
26
  `.easy-coding/` changes are part of the commit set by default (treated like code changes),
27
- with `state.json` always excluded. The CLI already added `state.json` to `.gitignore`.
27
+ with `.easy-coding/sessions/` always excluded. The CLI already added it to `.gitignore`.
28
28
 
29
29
  ## Rules
30
30
 
@@ -33,15 +33,15 @@ with `state.json` always excluded. The CLI already added `state.json` to `.gitig
33
33
  2. **Conflict handling for `.easy-coding/`** (mostly `memory/`): first explain the conflict
34
34
  details to the user, get confirmation, then do an inductive semantic merge — never blindly
35
35
  pick ours/theirs. This requirement applies only to conflicts inside `.easy-coding/`.
36
- 3. **Cross-repo commit sets.** When a task spans repos (per the dev-spec / `state.json`
37
- `repo_paths`), the commit/push covers every involved repo. Read `repo_paths` to locate
38
- each one, check changes, and commit/push them as one coherent change set — do not leave a
39
- sub-repo behind.
36
+ 3. **Cross-repo commit sets.** When a task spans repos (per the dev-spec / current task
37
+ `repo_paths`), the commit/push covers every involved repo. Read `repo_paths` from the
38
+ current task state to locate each checkout, check changes, and commit/push them as one
39
+ coherent change set — do not leave a sub-repo behind.
40
40
  4. **No false success.** Never claim a commit or push succeeded without reading the command
41
41
  output. A failed push reported as success is a serious error.
42
42
 
43
43
  ## Boundaries
44
44
 
45
- - Do not touch `state.json` stage fields or run stage transitions — git only.
46
- - Do not commit `state.json`.
45
+ - Do not touch session files, task status fields, or run stage transitions — git only.
46
+ - Do not commit `.easy-coding/sessions/`.
47
47
  - Do not commit `spec/dev/` unless the user explicitly asks.
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: ec-implementing
3
- description: IMPLEMENT-stage skill. Use when ec-workflow enters IMPLEMENT with a confirmed plan. Executes execution.jsonl units under strict file-scope control, enforces RULES compliance and encoding preservation, writes tests per strategy, and dispatches sub-agents for parallel work.
3
+ description: IMPLEMENT-stage skill. Use when ec-workflow enters IMPLEMENT with a confirmed plan. Executes execution.jsonl units under strict file-scope control, enforces RULES compliance and encoding preservation, writes tests per strategy, and dispatches sub-agents for every unit regardless of strategy.
4
4
  ---
5
5
 
6
6
  # ec-implementing — execute the confirmed plan
@@ -33,38 +33,45 @@ Communicate with the user in the user's language.
33
33
 
34
34
  ## Sub-agent dispatch
35
35
 
36
- Read the `plan` record's `strategy` field. Then:
36
+ Read the `plan` record's `strategy` field. EVERY strategy dispatches sub-agents — the field
37
+ only decides the orchestration shape, never whether the main agent writes code itself:
37
38
 
38
- - `single` → main agent implements directly, no sub-agents.
39
- - `sequential` → main agent implements units one by one in dependency order.
40
- - `parallel` sub-agents are MANDATORY (see gate below).
39
+ - `single` → dispatch ONE sub-agent for the single unit.
40
+ - `sequential` → dispatch sub-agents one at a time in dependency order (await each `result`
41
+ before dispatching the next).
42
+ - `parallel` → dispatch sub-agents per level concurrently (see gate below).
41
43
 
42
44
  <HARD-GATE>
43
- PARALLEL STRATEGY = MANDATORY SUB-AGENT DISPATCH. NO EXCEPTIONS.
45
+ EVERY STRATEGY = MANDATORY SUB-AGENT DISPATCH. NO EXCEPTIONS.
44
46
 
45
- If the plan record says `"strategy":"parallel"`, you MUST dispatch sub-agents using
46
- {{sub_agent_dispatch}}. You are FORBIDDEN from implementing parallel units yourself.
47
- Doing the work inline instead of dispatching is a protocol violation equivalent to
48
- skipping WAITING_CONFIRM.
47
+ You MUST dispatch sub-agents using {{sub_agent_dispatch}} for every unit, whatever the
48
+ strategy. You are FORBIDDEN from implementing any unit yourself in the main agent. Doing the
49
+ work inline instead of dispatching is a protocol violation equivalent to skipping
50
+ WAITING_CONFIRM.
49
51
 
50
52
  Self-check before writing ANY implementation code:
51
- - Is strategy "parallel"? Did I dispatch via {{sub_agent_dispatch}}? If no → STOP.
52
- - Am I working on a unit in a parallel level without dispatching? → STOP.
53
+ - Am I about to write implementation code in the main agent? → STOP. Dispatch a sub-agent.
54
+ - Did every unit get a dispatch (single=1, sequential=N serial, parallel=N concurrent)? If no → STOP.
53
55
 
54
- The ONLY case where you implement code directly is strategy "single" or "sequential".
56
+ There is NO case where the main agent writes implementation code itself. Even a single unit
57
+ goes through a sub-agent — this isolates implementation context from the main agent's window.
55
58
  </HARD-GATE>
56
59
 
57
- Parallel dispatch loop:
58
- 1. Sort `parallel_groups` by level.
59
- 2. Read RULES.md and ABSTRACT.md once.
60
- 3. For each unit in the current level, build a **task card** (next section) and dispatch.
61
- 4. Dispatch all units in the level concurrently via {{sub_agent_dispatch}}.
60
+ ## Dispatch loop (all strategies)
61
+
62
+ 1. Read RULES.md and ABSTRACT.md once — the main agent pre-digests context; sub-agents never
63
+ read them.
64
+ 2. For each unit, build a **task card** (next section). Append a `dispatch` record before
65
+ dispatching and a `result` record per returned unit, to execution.jsonl.
66
+ 3. Dispatch according to strategy, via {{sub_agent_dispatch}}:
67
+ - `single` → dispatch the one unit, await its `result`.
68
+ - `sequential` → sort units by `depends_on`; dispatch one, await its `result`, then the next.
69
+ - `parallel` → sort `parallel_groups` by level; dispatch all units in a level concurrently,
70
+ await the level, then advance.
62
71
  Platform spawn rule: {{platform_spawn_instruction}}
63
- 5. Append a `dispatch` record per unit, then a `result` record per returned unit, to
64
- execution.jsonl.
65
- 6. After the level returns: check for file conflicts (two units touched the same file),
72
+ 4. After each unit/level returns: check for file conflicts (two units touched the same file),
66
73
  collect `issues` and `needs_attention`. Resolve conflicts before advancing.
67
- 7. Advance to the next level. After all levels, summarize.
74
+ 5. After all units/levels, summarize.
68
75
 
69
76
  ## Task card — the sub-agent contract
70
77
 
@@ -105,8 +112,8 @@ hit something that invalidates the plan, return to ANALYSIS instead of improvisi
105
112
 
106
113
  ## Self-check gates (before handing back)
107
114
 
108
- - [ ] Strategy was "parallel" ALL units dispatched via sub-agents? (VIOLATION if no)
109
- - [ ] Strategy was "sequential" → units implemented in dependency order?
115
+ - [ ] EVERY unit was dispatched to a sub-agent no inline implementation by the main agent? (VIOLATION if no)
116
+ - [ ] Sequential units dispatched in dependency order; parallel units dispatched per level?
110
117
  - [ ] Each dispatched unit has a `dispatch` record in execution.jsonl?
111
118
  - [ ] Each returned unit has a `result` record?
112
119
  - [ ] No files modified outside the change-scope table?
@@ -14,24 +14,41 @@ recorded comment/doc language.
14
14
 
15
15
  ## MEMORY_SHORT — write one short memory entry
16
16
 
17
- Create one file under `.easy-coding/memory/short/` with schema-v2 frontmatter:
17
+ Create one file under `.easy-coding/memory/short/` following the format in
18
+ `.easy-coding/memory/SHORT_MEMORY_TEMPLATE.md`. File naming convention:
19
+ `{NNN}_{YYYYMMDD}_{smart_name}.md`. The entry is immutable after creation.
20
+ Frontmatter (all fields required):
18
21
 
19
22
  ```yaml
20
23
  ---
24
+ memory_schema: 2
21
25
  id: SM-{YYYYMMDD}-{NN}
22
26
  date: {YYYY-MM-DD}
23
- task_type: {feature | bugfix | refactor | perf}
24
- domain: {business domain}
25
- tags: [tag1, tag2]
26
- related_files: [file1, file2]
27
- target_long: {business | technical | both | none}
27
+ task_type: {feature | bugfix | refactor | perf | doc | workflow}
28
+ project_mode: {startup | iteration}
29
+ domain:
30
+ - {business domain or module}
31
+ tags:
32
+ - {keyword}
33
+ related_files:
34
+ - {key file or module}
35
+ commit: {hash | none}
36
+ verification: {passed | partial | not_run}
37
+ memory_value: {business | technical | both | none}
38
+ target_long: {BUSINESS | TECHNICAL | BOTH | NONE}
28
39
  ---
29
- {body: what was done, why this approach, key decisions. Pull facts from execution.jsonl
30
- result/verify records, not from a fuzzy memory of the conversation.}
40
+ The body follows the template structure: Task Summary, Execution Evidence, Business Memory
41
+ Candidates, Technical Memory Candidates, Non-Distillation Content, and Related Memories.
42
+ Pull facts from execution.jsonl result/verify records, not from a fuzzy memory of the
43
+ conversation. Refer to SHORT_MEMORY_TEMPLATE.md for the complete section format.
31
44
  ```
32
45
 
33
46
  If the task was cross-repo, record the repo names involved and the collaboration reason.
34
47
 
48
+ **Immutability:** Short memories are write-once. Never edit an existing short memory file —
49
+ create a new one instead. Short memories serve as both a recent-detail sliding window and a
50
+ distillation buffer for long-term memory.
51
+
35
52
  **Sliding window (informational):** The short memory directory has a soft cap defined by
36
53
  `memory.short_term_max` (default 10). MEMORY_SHORT only WRITES one entry per completed task
37
54
  — it never counts, trims, or triggers distillation. Trimming is exclusively MEMORY_LONG's
@@ -40,21 +57,25 @@ responsibility and only runs when the threshold is exceeded.
40
57
  ## MEMORY_LONG — distill durable knowledge (CONDITIONAL)
41
58
 
42
59
  <HARD-GATE>
43
- MEMORY_LONG IS A NO-OP WHEN SHORT MEMORY COUNT <= threshold.
60
+ MEMORY_LONG IS CONTROLLED BY THE STATE API `memory_long` INSTRUCTION.
44
61
 
45
62
  Before performing ANY distillation work:
46
- 1. Count `.md` files in `.easy-coding/memory/short/` (only files with schema-v2 frontmatter).
47
- 2. Read `memory.short_term_max` from `.easy-coding/config.yaml` (default: 10).
48
- 3. If count <= short_term_max: output "MEMORY_LONG: no-op (short memory count = {N},
63
+ 1. Read the `memory_long` object returned by the state API transition to MEMORY_LONG.
64
+ If it is not visible in context, re-run the same transition command for MEMORY_LONG to
65
+ re-emit the snapshot, then use that `memory_long` object.
66
+ 2. Treat `memory_long.action` as authoritative. Do NOT recount short memories yourself and
67
+ do NOT override the state API instruction with prompt reasoning.
68
+ 3. If `action == "no-op"`: output "MEMORY_LONG: no-op (short memory count = {short_count},
49
69
  threshold = {short_term_max})" and immediately hand back to ec-workflow to advance to
50
70
  COMPLETE. Do NOT read long memory files, do NOT attempt distillation, do NOT modify any file.
51
- 4. If count > short_term_max: proceed with distillation below.
71
+ 4. If `action == "distill"`: distill exactly the older `trim_count` short-memory entries
72
+ and keep the latest `short_term_keep` entries.
52
73
 
53
74
  This gate is absolute. Even a single short memory entry below threshold does NOT trigger
54
75
  long-term compression regardless of any other signal.
55
76
  </HARD-GATE>
56
77
 
57
- ### When count > threshold: distillation flow
78
+ ### When action == "distill": distillation flow
58
79
 
59
80
  Three-file long memory:
60
81
  - `MEMORY.md` — index of all entries with status (active | deprecated | superseded | deleted).
@@ -62,8 +83,8 @@ Three-file long memory:
62
83
  - `TECHNICAL.md` — architecture decisions, implementation patterns, gotchas.
63
84
 
64
85
  Distillation steps:
65
- 1. Read `memory.short_term_keep` from config (default: 5). Keep the latest N entries;
66
- the older entries become distillation candidates.
86
+ 1. Use `memory_long.short_term_keep` and `memory_long.trim_count`. Keep the latest
87
+ `short_term_keep` entries; the older `trim_count` entries become distillation candidates.
67
88
  2. Read the `target_long` of candidate short memories; route to business/technical.
68
89
  3. **Progressive loading** — read only the existing long entries matching this round's
69
90
  domain/tags/related_files. No unbounded whole-repo memory scan.
@@ -73,6 +94,10 @@ Distillation steps:
73
94
  5. **Retirement check**: for older entries decide delete (no value) / merge (semantic
74
95
  duplicate) / deprecate (was valid, now superseded).
75
96
  6. Update the `MEMORY.md` index to reflect every change.
97
+ 7. After the long-memory files and index are successfully written, delete the consumed
98
+ short-memory candidate files. Leave only the latest `short_term_keep` short memories.
99
+ This is sliding-window consumption after successful distillation, not destructive
100
+ deletion of durable long-term knowledge.
76
101
 
77
102
  ## ABSTRACT backfill / update
78
103
 
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: ec-reviewing
3
- description: REVIEW-stage skill. Use when ec-workflow enters REVIEW. Reviews changed files across correctness, RULES compliance, completeness, tests, and security; returns a graded verdict (accept/fix/replan/blocked) with file-and-line evidence; dispatches multi-dimension sub-agents when the change set is large.
3
+ description: REVIEW-stage skill. Use when ec-workflow enters REVIEW. Reviews changed files across correctness, RULES compliance, completeness, tests, and security; returns a graded verdict (accept/fix/replan/blocked) with file-and-line evidence; dispatches multi-dimension sub-agents for every review regardless of change-set size.
4
4
  ---
5
5
 
6
6
  # ec-reviewing — graded, evidence-backed review
@@ -18,9 +18,10 @@ when you recognize abandonment intent in the user's message.
18
18
  Require an explicit yes. (Skip the confirm only if the task is already COMPLETE and the
19
19
  user just wants it tidied.)
20
20
  2. **Record the reason.** Capture the user's reason in one line.
21
- 3. **Clean state:**
22
- - `task.json`: `status` `CLOSED`, `closed_reason` "{reason}".
23
- - `state.json`: `current_task` null (leave `current_stage` as the hook will report idle).
21
+ 3. **Close through the state API:** run
22
+ `{{PYTHON_CMD}} {{platform_config_dir}}/hooks/easy_coding_state.py close-current --session-file <P> --reason "<reason>" --agent <agent-id>`.
23
+ This sets `task.json.status` to `CLOSED`, records `closed_reason`, updates history, and
24
+ clears session `current_task` so the next hook injection returns to Ready.
24
25
  4. **No memory flow.** Do not run MEMORY_SHORT/LONG. An incomplete task's memory is dirty data.
25
26
  5. **Linked tasks.** If the task has `spawned_from` or `spawned_tasks`, note the closure fact
26
27
  on the relation so a future agent understands the chain.