@tianhai/pi-workflow-kit 0.14.0 → 0.15.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.
@@ -0,0 +1,70 @@
1
+ # Design: Enforce Generic Lessons in `docs/lessons.md`
2
+
3
+ ## Problem
4
+
5
+ During `executing-tasks`, the agent writes lessons to `docs/lessons.md` scoped to the task at hand. In a monorepo, this produces domain-specific rules that are only useful within one feature or sprint — for example:
6
+
7
+ > "Always validate `userId` before calling `UserProfile.Get`"
8
+
9
+ The real lesson — applicable across any domain — would be:
10
+
11
+ > "Always validate required ID fields at the service boundary — missing IDs should return 400, not 500"
12
+
13
+ Domain-specific rules decay immediately after the feature is done and pollute the lessons file for future work.
14
+
15
+ ## Goal
16
+
17
+ Rules in `docs/lessons.md` should be generic patterns applicable to any domain or feature in the repo, not instances of a pattern tied to one service or entity.
18
+
19
+ ## Affected files
20
+
21
+ - `skills/executing-tasks/SKILL.md`
22
+ - `skills/finalizing/SKILL.md`
23
+
24
+ ## Changes
25
+
26
+ ### 1. `executing-tasks` — Step 6 "Learn from mistakes"
27
+
28
+ Add a **generalization test** after "Only add rules that would change future behavior."
29
+
30
+ ```
31
+ Before writing, apply the **generalization test**: would this rule apply equally to a
32
+ completely different feature or domain in this repo? If not, rewrite it — strip out
33
+ specific service names, entity types, and domain concepts, and express the underlying
34
+ pattern instead. If you can't express a generic form, don't write the rule.
35
+
36
+ ❌ Domain-specific (only survives this sprint):
37
+ "Always validate `userId` before calling `UserProfile.Get`"
38
+
39
+ ✅ Generic (applies across the whole repo):
40
+ "Always validate required ID fields at the service boundary — missing IDs should
41
+ return 400, not 500"
42
+ ```
43
+
44
+ ### 2. `executing-tasks` — `docs/lessons.md` format template comment
45
+
46
+ Add one line to the comment block so the constraint is visible every time the agent opens the file:
47
+
48
+ ```
49
+ Rules must be generic patterns applicable to any domain or feature — not specific to
50
+ one service, entity, or use case.
51
+ ```
52
+
53
+ ### 3. `finalizing` — Step 2 "Review lessons learned"
54
+
55
+ Add a generalization audit bullet between "Add any lessons..." and "Retire rules...":
56
+
57
+ ```
58
+ - Generalize domain-specific rules — if a rule names a specific service, entity, or
59
+ feature, either rewrite it as a generic pattern or remove it if no generic form exists
60
+ ```
61
+
62
+ ### 4. `finalizing` — `docs/lessons.md` format template comment
63
+
64
+ Same addition as change 2 — keep both template definitions consistent.
65
+
66
+ ## Slice summary
67
+
68
+ One end-to-end slice:
69
+
70
+ > **Lessons stay generic** — at write-time (executing-tasks step 6) the agent is required to generalize before writing; the file's own comment reinforces the constraint; at finalization the agent audits and cleans up anything that slipped through.
@@ -0,0 +1,114 @@
1
+ # Implementation Plan: Enforce Generic Lessons in `docs/lessons.md`
2
+
3
+ Design: docs/plans/2026-05-20-generic-lessons-design.md
4
+
5
+ Two skill files need four text edits total. No tests (markdown-only changes). Both
6
+ tasks are trivial — exact old/new text is specified so the executor can apply them
7
+ without guessing.
8
+
9
+ ---
10
+
11
+ ## Task 1: Add generalization test + update format comment in `executing-tasks`
12
+
13
+ <!-- tdd: trivial -->
14
+
15
+ File: `skills/executing-tasks/SKILL.md`
16
+
17
+ Two edits in one file:
18
+
19
+ ### Edit A — Step 6 "Learn from mistakes"
20
+
21
+ Replace:
22
+ ```
23
+ 6. **Learn from mistakes** — if you caught yourself making a mistake during this task that you've made before or that would apply to future tasks, append a rule to `docs/lessons.md`. Only add rules that would change future behavior. If the file doesn't exist, create it with the standard format (see below).
24
+ ```
25
+
26
+ With:
27
+ ```
28
+ 6. **Learn from mistakes** — if you caught yourself making a mistake during this task that you've made before or that would apply to future tasks, append a rule to `docs/lessons.md`. Only add rules that would change future behavior. If the file doesn't exist, create it with the standard format (see below).
29
+
30
+ Before writing, apply the **generalization test**: would this rule apply equally to a completely different feature or domain in this repo? If not, rewrite it — strip out specific service names, entity types, and domain concepts, and express the underlying pattern instead. If you can't express a generic form, don't write the rule.
31
+
32
+ ❌ **Domain-specific** (only survives this sprint):
33
+ > "Always validate `userId` before calling `UserProfile.Get`"
34
+
35
+ ✅ **Generic** (applies across the whole repo):
36
+ > "Always validate required ID fields at the service boundary — missing IDs should return 400, not 500"
37
+ ```
38
+
39
+ ### Edit B — `docs/lessons.md` format template comment
40
+
41
+ Replace:
42
+ ```
43
+ <!--
44
+ Agent: read this at the start of each task during executing-tasks.
45
+ Follow every rule. Add new rules when you catch yourself making repeat mistakes.
46
+ Retire rules that no longer apply during finalizing.
47
+ -->
48
+ ```
49
+
50
+ With:
51
+ ```
52
+ <!--
53
+ Agent: read this at the start of each task during executing-tasks.
54
+ Follow every rule. Add new rules when you catch yourself making repeat mistakes.
55
+ Rules must be generic patterns applicable to any domain or feature — not specific to one service, entity, or use case.
56
+ Retire rules that no longer apply during finalizing.
57
+ -->
58
+ ```
59
+
60
+ Steps:
61
+ 1. Apply Edit A to `skills/executing-tasks/SKILL.md`
62
+ 2. Apply Edit B to `skills/executing-tasks/SKILL.md`
63
+ 3. Verify: open the file and confirm both edits are present and the surrounding text is intact
64
+
65
+ ---
66
+
67
+ ## Task 2: Add generalization audit bullet + update format comment in `finalizing`
68
+
69
+ <!-- tdd: trivial -->
70
+
71
+ File: `skills/finalizing/SKILL.md`
72
+
73
+ Two edits in one file:
74
+
75
+ ### Edit A — Step 2 "Review lessons learned"
76
+
77
+ Replace:
78
+ ```
79
+ - Add any lessons from this session that were missed during execution
80
+ - Retire rules that no longer apply (remove the bullet)
81
+ ```
82
+
83
+ With:
84
+ ```
85
+ - Add any lessons from this session that were missed during execution
86
+ - **Generalize domain-specific rules** — if a rule names a specific service, entity, or feature, either rewrite it as a generic pattern or remove it if no generic form exists
87
+ - Retire rules that no longer apply (remove the bullet)
88
+ ```
89
+
90
+ ### Edit B — `docs/lessons.md` format template comment
91
+
92
+ Replace:
93
+ ```
94
+ <!--
95
+ Agent: read this at the start of each task during executing-tasks.
96
+ Follow every rule. Add new rules when you catch yourself making repeat mistakes.
97
+ Retire rules that no longer apply during finalizing.
98
+ -->
99
+ ```
100
+
101
+ With:
102
+ ```
103
+ <!--
104
+ Agent: read this at the start of each task during executing-tasks.
105
+ Follow every rule. Add new rules when you catch yourself making repeat mistakes.
106
+ Rules must be generic patterns applicable to any domain or feature — not specific to one service, entity, or use case.
107
+ Retire rules that no longer apply during finalizing.
108
+ -->
109
+ ```
110
+
111
+ Steps:
112
+ 1. Apply Edit A to `skills/finalizing/SKILL.md`
113
+ 2. Apply Edit B to `skills/finalizing/SKILL.md`
114
+ 3. Verify: open the file and confirm both edits are present and the surrounding text is intact
@@ -0,0 +1,11 @@
1
+ # Progress: generic-lessons
2
+
3
+ Plan: docs/plans/2026-05-20-generic-lessons-implementation.md
4
+ Branch: generic-lessons
5
+ Started: 2026-05-20T00:00:00Z
6
+ Last updated: 2026-05-20T00:00:00Z
7
+
8
+ | # | Status | Task | Commit |
9
+ |---|--------|------|--------|
10
+ | 1 | ✅ done | Add generalization test + update format comment in `executing-tasks` | 96010f7 |
11
+ | 2 | ✅ done | Add generalization audit bullet + update format comment in `finalizing` | 72f088d |
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tianhai/pi-workflow-kit",
3
- "version": "0.14.0",
3
+ "version": "0.15.0",
4
4
  "description": "Enforce structured brainstorm→plan→execute→finalize workflow with TDD discipline in AI coding agents",
5
5
  "keywords": [
6
6
  "pi-package",
@@ -166,6 +166,14 @@ For each task:
166
166
 
167
167
  Run tests after each refactor step. Never refactor while tests are failing.
168
168
  6. **Learn from mistakes** — if you caught yourself making a mistake during this task that you've made before or that would apply to future tasks, append a rule to `docs/lessons.md`. Only add rules that would change future behavior. If the file doesn't exist, create it with the standard format (see below).
169
+
170
+ Before writing, apply the **generalization test**: would this rule apply equally to a completely different feature or domain in this repo? If not, rewrite it — strip out specific service names, entity types, and domain concepts, and express the underlying pattern instead. If you can't express a generic form, don't write the rule.
171
+
172
+ ❌ **Domain-specific** (only survives this sprint):
173
+ > "Always validate `userId` before calling `UserProfile.Get`"
174
+
175
+ ✅ **Generic** (applies across the whole repo):
176
+ > "Always validate required ID fields at the service boundary — missing IDs should return 400, not 500"
169
177
  7. **Commit** — after all steps are done (no checkpoint gates remain in the task), `git add` the relevant files and commit with a clear message.
170
178
  8. **Update progress** — mark `✅ done` + record the commit hash.
171
179
  9. **Suggest session break if needed** — after completing ~3-5 tasks since the last break, suggest:
@@ -188,6 +196,7 @@ For each task:
188
196
  <!--
189
197
  Agent: read this at the start of each task during executing-tasks.
190
198
  Follow every rule. Add new rules when you catch yourself making repeat mistakes.
199
+ Rules must be generic patterns applicable to any domain or feature — not specific to one service, entity, or use case.
191
200
  Retire rules that no longer apply during finalizing.
192
201
  -->
193
202
 
@@ -37,6 +37,7 @@ Wait for the user to confirm before proceeding.
37
37
 
38
38
  2. **Review lessons learned** — if `docs/lessons.md` exists, review it:
39
39
  - Add any lessons from this session that were missed during execution
40
+ - **Generalize domain-specific rules** — if a rule names a specific service, entity, or feature, either rewrite it as a generic pattern or remove it if no generic form exists
40
41
  - Retire rules that no longer apply (remove the bullet)
41
42
  - If no changes are needed, leave it as-is
42
43
 
@@ -48,6 +49,7 @@ Wait for the user to confirm before proceeding.
48
49
  <!--
49
50
  Agent: read this at the start of each task during executing-tasks.
50
51
  Follow every rule. Add new rules when you catch yourself making repeat mistakes.
52
+ Rules must be generic patterns applicable to any domain or feature — not specific to one service, entity, or use case.
51
53
  Retire rules that no longer apply during finalizing.
52
54
  -->
53
55