mirror of
https://github.com/catlog22/Claude-Code-Workflow.git
synced 2026-02-05 01:50:27 +08:00
Compare commits
705 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
369b470969 | ||
|
|
de989aa038 | ||
|
|
4ee165119b | ||
|
|
113c14970f | ||
|
|
7b2ac46760 | ||
|
|
346c87a706 | ||
|
|
e260a3f77b | ||
|
|
88616224e0 | ||
|
|
6e6c2b9e09 | ||
|
|
2bfce150ec | ||
|
|
ac95ee3161 | ||
|
|
8454ae4f41 | ||
|
|
341331325c | ||
|
|
1a05551d00 | ||
|
|
c6093ef741 | ||
|
|
a806d70d9b | ||
|
|
9bb50a13fa | ||
|
|
bb4cd0529e | ||
|
|
a8385e2ea5 | ||
|
|
37ba849e75 | ||
|
|
b63e254f36 | ||
|
|
86b1a15671 | ||
|
|
39b80b3386 | ||
|
|
5483a72e9f | ||
|
|
bcb4af3ba0 | ||
|
|
545679eeb9 | ||
|
|
2305e7b8e7 | ||
|
|
48871f0d9e | ||
|
|
a54246a46f | ||
|
|
e4b627bc76 | ||
|
|
392f89f62f | ||
|
|
1beb98366b | ||
|
|
c522681c4c | ||
|
|
abce912ee5 | ||
|
|
690597bae8 | ||
|
|
e5252f8a77 | ||
|
|
b76424feef | ||
|
|
76967a7350 | ||
|
|
7dcc0a1c05 | ||
|
|
5fb910610a | ||
|
|
d46406df4a | ||
|
|
8dc115a894 | ||
|
|
e9789e747a | ||
|
|
0342976c51 | ||
|
|
f196b76064 | ||
|
|
44cc4cad0f | ||
|
|
fc1471396c | ||
|
|
cf401d00e1 | ||
|
|
b66d20f5a6 | ||
|
|
a2206df50f | ||
|
|
2f10305945 | ||
|
|
92ded5908f | ||
|
|
1bd082a725 | ||
|
|
6d225948d1 | ||
|
|
35f9116cce | ||
|
|
345437415f | ||
|
|
715ef12c92 | ||
|
|
4e009bb03a | ||
|
|
a0f81f8841 | ||
|
|
f1324a0bc8 | ||
|
|
81725c94b1 | ||
|
|
917de6f167 | ||
|
|
e78e95049b | ||
|
|
a5c3dff8d3 | ||
|
|
0a7c1454d9 | ||
|
|
4a8481958a | ||
|
|
78b1287ced | ||
|
|
c6ad8e53b9 | ||
|
|
4006b2a0ee | ||
|
|
e464d93e29 | ||
|
|
0bb102c56a | ||
|
|
fca03a3f9c | ||
|
|
a9df4c6659 | ||
|
|
0a3246ab36 | ||
|
|
b5caee6b94 | ||
|
|
64d2156319 | ||
|
|
3f46a02df3 | ||
|
|
4b69492b16 | ||
|
|
67a578450c | ||
|
|
d5199ad2d4 | ||
|
|
f3c773a81e | ||
|
|
875b1f19bd | ||
|
|
c08f5382d3 | ||
|
|
21d764127f | ||
|
|
860dbdab56 | ||
|
|
113dce55c5 | ||
|
|
0b791c03cf | ||
|
|
bbc94fb73a | ||
|
|
f5e435f791 | ||
|
|
86d5be8288 | ||
|
|
9762445876 | ||
|
|
b791c09476 | ||
|
|
26283e7a5a | ||
|
|
1040459fef | ||
|
|
0fe8c18a82 | ||
|
|
0086413f95 | ||
|
|
8ff698ae73 | ||
|
|
8cdd6a8b5f | ||
|
|
b86a8afd8b | ||
|
|
53bd5a6d4b | ||
|
|
3a7bbe0e42 | ||
|
|
04a84f9893 | ||
|
|
11638facf7 | ||
|
|
4d93ffb06c | ||
|
|
204cb20617 | ||
|
|
63f0daebbb | ||
|
|
6ac041c1d8 | ||
|
|
279adfd391 | ||
|
|
0a07138c27 | ||
|
|
a5d9e8ca87 | ||
|
|
502c8a09a1 | ||
|
|
ed0255b8a2 | ||
|
|
6e94fc0740 | ||
|
|
b361a8c041 | ||
|
|
24dad8cefd | ||
|
|
071c98d89c | ||
|
|
994718dee2 | ||
|
|
3998d24e32 | ||
|
|
29274ee943 | ||
|
|
46d5739935 | ||
|
|
152cab2b7e | ||
|
|
0cc5101c0e | ||
|
|
4c78f53bcc | ||
|
|
cc5a5716cf | ||
|
|
af05874510 | ||
|
|
7a40f16235 | ||
|
|
8d178feaac | ||
|
|
b3c47294e7 | ||
|
|
9989cfcf21 | ||
|
|
1b6ace0447 | ||
|
|
a3b303d8e3 | ||
|
|
0c1c87f704 | ||
|
|
985085c624 | ||
|
|
7c16cc6427 | ||
|
|
6875108dda | ||
|
|
9cff6f5f43 | ||
|
|
fe2536d4cd | ||
|
|
16f27c080a | ||
|
|
874b70726d | ||
|
|
862365ffaf | ||
|
|
b8c807b2f9 | ||
|
|
7ea6362c50 | ||
|
|
b435391f17 | ||
|
|
88ff109ac4 | ||
|
|
261196a804 | ||
|
|
ea6cb8440f | ||
|
|
bf896342f4 | ||
|
|
f2b0a5bbc9 | ||
|
|
cf5fecd66d | ||
|
|
86d469ccc9 | ||
|
|
357d3524f5 | ||
|
|
4334162ddf | ||
|
|
2dcd1637f0 | ||
|
|
38e1cdc737 | ||
|
|
097a7346b9 | ||
|
|
9df8063fbd | ||
|
|
d00f0bc7ca | ||
|
|
24efef7f17 | ||
|
|
44b8269a74 | ||
|
|
dd51837bbc | ||
|
|
a17edc3e50 | ||
|
|
01ab3cf3fa | ||
|
|
a2c1b9b47c | ||
|
|
780e118844 | ||
|
|
159dfd179e | ||
|
|
6c80168612 | ||
|
|
a293a01d85 | ||
|
|
ab259b1970 | ||
|
|
fd50adf581 | ||
|
|
24a28f289d | ||
|
|
e727a07fc5 | ||
|
|
8179472e56 | ||
|
|
277b3f86f1 | ||
|
|
7a6f4c3f22 | ||
|
|
2f32d08d87 | ||
|
|
79d20add43 | ||
|
|
f363c635f5 | ||
|
|
61e3747768 | ||
|
|
54ec6a7c57 | ||
|
|
d6a3da2084 | ||
|
|
b9f17f0fcf | ||
|
|
88eb42f65b | ||
|
|
b1ac0cf8ff | ||
|
|
09eeb84cda | ||
|
|
2fb1d1243c | ||
|
|
ac62bf70db | ||
|
|
edb55c4895 | ||
|
|
8a7f636a85 | ||
|
|
97ab82628d | ||
|
|
be89552b0a | ||
|
|
df25b43884 | ||
|
|
04cd536da5 | ||
|
|
9a3608173a | ||
|
|
f5b6bb97bc | ||
|
|
2819f3597f | ||
|
|
c0c1a2eb92 | ||
|
|
012197a861 | ||
|
|
407b2e6930 | ||
|
|
6428febdf6 | ||
|
|
9f9ef1d054 | ||
|
|
ea04663035 | ||
|
|
f0954b3247 | ||
|
|
2fffe78dc9 | ||
|
|
02531c4d15 | ||
|
|
5fa7524ad7 | ||
|
|
21fbdbc55e | ||
|
|
1f1a078450 | ||
|
|
d3aeac4e9f | ||
|
|
e2e3d5a815 | ||
|
|
ddb7fb7d7a | ||
|
|
62d5ce3f34 | ||
|
|
15b3977e88 | ||
|
|
d70f02abed | ||
|
|
e11c4ba8ed | ||
|
|
60eab98782 | ||
|
|
d9f1d14d5e | ||
|
|
64e064e775 | ||
|
|
8c1d62208e | ||
|
|
c4960c3e84 | ||
|
|
82b8fcc608 | ||
|
|
a7c8ea04f1 | ||
|
|
2084ff3e21 | ||
|
|
890ca455b2 | ||
|
|
1dfabf6bda | ||
|
|
604405b2d6 | ||
|
|
190d2280fd | ||
|
|
4e66864cfd | ||
|
|
cac0566627 | ||
|
|
572c103fbf | ||
|
|
9d6bc92837 | ||
|
|
ffe9898fd3 | ||
|
|
a602a46985 | ||
|
|
f7dd3d23ff | ||
|
|
200812d204 | ||
|
|
261c98549d | ||
|
|
b85d9b9eb1 | ||
|
|
4610018193 | ||
|
|
9c9b1ad01c | ||
|
|
2f3a14e946 | ||
|
|
1376dc71d9 | ||
|
|
c1d12384c3 | ||
|
|
eea859dd6f | ||
|
|
3fe630f221 | ||
|
|
eeaefa7208 | ||
|
|
e58c33fb6e | ||
|
|
6716772e0a | ||
|
|
a8367bd4d7 | ||
|
|
ea13f9a575 | ||
|
|
7d152b7bf9 | ||
|
|
16c96229f9 | ||
|
|
40b003be68 | ||
|
|
46111b3987 | ||
|
|
f47726d43b | ||
|
|
502d088c98 | ||
|
|
f845e6e0ee | ||
|
|
e96eed817c | ||
|
|
6a6d1885d8 | ||
|
|
a34eeb63bf | ||
|
|
56acc4f19c | ||
|
|
fdf468ed99 | ||
|
|
680c2a0597 | ||
|
|
5b5dc85677 | ||
|
|
1e691fa751 | ||
|
|
1f87ca0be3 | ||
|
|
f14418603a | ||
|
|
1fae35c05d | ||
|
|
8523079a99 | ||
|
|
4daeb0eead | ||
|
|
86548af518 | ||
|
|
4e5eb6cd40 | ||
|
|
021ce619f0 | ||
|
|
63aaab596c | ||
|
|
bc52af540e | ||
|
|
8bbbdc61eb | ||
|
|
fd5f6c2c97 | ||
|
|
fd145c34cd | ||
|
|
10b3ace917 | ||
|
|
d6a2e0de59 | ||
|
|
35c6605681 | ||
|
|
ef2229b0bb | ||
|
|
b65977d8dc | ||
|
|
bc4176fda0 | ||
|
|
464f3343f3 | ||
|
|
bb6cf42df6 | ||
|
|
0f0cb7e08e | ||
|
|
39d070eab6 | ||
|
|
9ccaa7e2fd | ||
|
|
eeb90949ce | ||
|
|
7b677b20fb | ||
|
|
e2d56bc08a | ||
|
|
d515090097 | ||
|
|
d81dfaf143 | ||
|
|
d7e5ee44cc | ||
|
|
dde39fc6f5 | ||
|
|
9b4fdc1868 | ||
|
|
623afc1d35 | ||
|
|
085652560a | ||
|
|
af4ddb1280 | ||
|
|
7db659f0e1 | ||
|
|
ba526ea09e | ||
|
|
c308e429f8 | ||
|
|
c24ed016cb | ||
|
|
0c9a6d4154 | ||
|
|
7b5c3cacaa | ||
|
|
e6e7876b38 | ||
|
|
0eda520fd7 | ||
|
|
e22b525e9c | ||
|
|
86536aaa10 | ||
|
|
3ef766708f | ||
|
|
95a7f05aa9 | ||
|
|
f692834153 | ||
|
|
a228bb946b | ||
|
|
4d57f47717 | ||
|
|
c8cac5b201 | ||
|
|
f9c1216eec | ||
|
|
266f6f11ec | ||
|
|
1f5ce9c03a | ||
|
|
959d60b31f | ||
|
|
49845fe1ae | ||
|
|
aeb111420e | ||
|
|
6ff3e5f8fe | ||
|
|
d941166d84 | ||
|
|
ac9ba5c7e4 | ||
|
|
9e55f51501 | ||
|
|
43b8cfc7b0 | ||
|
|
633d918da1 | ||
|
|
6b4b9b0775 | ||
|
|
360d29d7be | ||
|
|
4fe7f6cde6 | ||
|
|
6922ca27de | ||
|
|
c3da637849 | ||
|
|
2f1c56285a | ||
|
|
85972b73ea | ||
|
|
6305f19bbb | ||
|
|
275d2cb0af | ||
|
|
d5f57d29ed | ||
|
|
7d8b13f34f | ||
|
|
340137d347 | ||
|
|
61cef8019a | ||
|
|
08308aa9ea | ||
|
|
94ae9e264c | ||
|
|
549e6e70e4 | ||
|
|
15514c8f91 | ||
|
|
29c8bb7a66 | ||
|
|
76f5311e78 | ||
|
|
ca6677149a | ||
|
|
880376aefc | ||
|
|
a20f81d44a | ||
|
|
a8627e7f68 | ||
|
|
4caa622942 | ||
|
|
6b8e73bd32 | ||
|
|
68c4c54b64 | ||
|
|
1dca4b06a2 | ||
|
|
a8ec42233f | ||
|
|
49a7c17ba8 | ||
|
|
8a15e08944 | ||
|
|
8c2d39d517 | ||
|
|
bf06f4ddcc | ||
|
|
28645aa4e4 | ||
|
|
cdcb517bc2 | ||
|
|
a63d547856 | ||
|
|
d994274023 | ||
|
|
a98db07731 | ||
|
|
908a745f95 | ||
|
|
5259bf48b2 | ||
|
|
ecaa011502 | ||
|
|
65cb5beec4 | ||
|
|
fd9c55162d | ||
|
|
ca77c114dd | ||
|
|
5282551277 | ||
|
|
76e1f855f1 | ||
|
|
57173c9b02 | ||
|
|
90a1321aac | ||
|
|
b360e0edc7 | ||
|
|
5ec9ad01a3 | ||
|
|
96f0d2a8f1 | ||
|
|
cba4d76b75 | ||
|
|
09beb84586 | ||
|
|
7803dad430 | ||
|
|
52c510501d | ||
|
|
bdd545727b | ||
|
|
1044886e7d | ||
|
|
cefb934a2c | ||
|
|
37614a3362 | ||
|
|
7f3033b1c1 | ||
|
|
7387a25d65 | ||
|
|
e1eafede65 | ||
|
|
9d7b77059f | ||
|
|
7519603fbd | ||
|
|
bafc3225d2 | ||
|
|
174393b5cb | ||
|
|
b77672dda4 | ||
|
|
1e91fa9f9e | ||
|
|
16083130f8 | ||
|
|
2c11392848 | ||
|
|
30ff742310 | ||
|
|
84168825d6 | ||
|
|
311ce2e4bc | ||
|
|
ea5c0bc9a4 | ||
|
|
0bd2cff5b7 | ||
|
|
faf32b5086 | ||
|
|
8f7ab3e268 | ||
|
|
a433861f77 | ||
|
|
886a8ef8b0 | ||
|
|
3124125b4c | ||
|
|
d0523684e5 | ||
|
|
b86cdd6644 | ||
|
|
55fa170b4e | ||
|
|
d2d6cce5f4 | ||
|
|
178d45e232 | ||
|
|
09d99abee6 | ||
|
|
6e93c36b89 | ||
|
|
fae2f7e279 | ||
|
|
2e68a18afd | ||
|
|
05514631f2 | ||
|
|
e9fb7be85f | ||
|
|
42fbc1936d | ||
|
|
87d38a3374 | ||
|
|
6aa79c6dc9 | ||
|
|
1bd3d9c9bf | ||
|
|
86d3e36722 | ||
|
|
05f762117a | ||
|
|
1298fdd20f | ||
|
|
ef770ff29b | ||
|
|
02d66325a0 | ||
|
|
a5024bdcbb | ||
|
|
6cb819cb3a | ||
|
|
08099cdcb9 | ||
|
|
1451594ae6 | ||
|
|
2e90230097 | ||
|
|
f90c6b9fab | ||
|
|
853977c676 | ||
|
|
2087f2d350 | ||
|
|
f4585c8dea | ||
|
|
a2c599d6fa | ||
|
|
256a07e584 | ||
|
|
b361f42c1c | ||
|
|
33f2aef4e6 | ||
|
|
4fb6b2d1de | ||
|
|
373f1d57c1 | ||
|
|
81f4d084b0 | ||
|
|
2a13d8b17f | ||
|
|
27a0129f72 | ||
|
|
7e3d9007cd | ||
|
|
df4d6fdc45 | ||
|
|
f28b6c6197 | ||
|
|
1825ed3bcf | ||
|
|
504ccfebbc | ||
|
|
74ad2d0463 | ||
|
|
0af84be775 | ||
|
|
6043e6aa3b | ||
|
|
e3dba87e08 | ||
|
|
ad6c18f615 | ||
|
|
be498acf59 | ||
|
|
6a45035e3f | ||
|
|
28bd781062 | ||
|
|
9922d455da | ||
|
|
ac23fe5b5a | ||
|
|
bab5625123 | ||
|
|
f674b90a62 | ||
|
|
6a545fdeb7 | ||
|
|
b01f021f1c | ||
|
|
f934ea6664 | ||
|
|
52639c9bdd | ||
|
|
152fb6b6ad | ||
|
|
990cf8a05d | ||
|
|
713894090d | ||
|
|
2391c77910 | ||
|
|
ffb0e90ff3 | ||
|
|
740bd1b61e | ||
|
|
a364a10d6a | ||
|
|
441bcb9e99 | ||
|
|
714f0c539b | ||
|
|
255d4244ea | ||
|
|
4fb247f7c5 | ||
|
|
54fd94547c | ||
|
|
96b44e1482 | ||
|
|
c268b531aa | ||
|
|
0b6e9db8e4 | ||
|
|
9157c5c78b | ||
|
|
54fb7afdb2 | ||
|
|
92ed2524b7 | ||
|
|
56c03c847a | ||
|
|
9129c981a4 | ||
|
|
da68ba0b82 | ||
|
|
e21d801523 | ||
|
|
195438d26a | ||
|
|
5bb01755bc | ||
|
|
520f2d26f2 | ||
|
|
8ac27548ad | ||
|
|
adc0dd23e4 | ||
|
|
31a45f1f30 | ||
|
|
4bde13e83a | ||
|
|
a5ab3f8b26 | ||
|
|
d183a647dd | ||
|
|
e5797bff8f | ||
|
|
4d73a3c9a9 | ||
|
|
754cddd4ad | ||
|
|
f6cc3736b2 | ||
|
|
6e99cd97ca | ||
|
|
f566b8aabc | ||
|
|
6efc499c77 | ||
|
|
2c675ee4db | ||
|
|
f6dfe28e08 | ||
|
|
e8e8746cc6 | ||
|
|
603bc00bca | ||
|
|
ae76926d5a | ||
|
|
fd48045fe3 | ||
|
|
6ec6643448 | ||
|
|
945fda2d14 | ||
|
|
7d71f603fe | ||
|
|
bd11a538a7 | ||
|
|
b9b4da6d8c | ||
|
|
70f8b14eaa | ||
|
|
0c8b2f2ec9 | ||
|
|
d532b3fd02 | ||
|
|
c56104c082 | ||
|
|
66ae1972ae | ||
|
|
7f4433e449 | ||
|
|
e1f2fc72d9 | ||
|
|
aa093f9468 | ||
|
|
a27f76abcb | ||
|
|
df34ef38d9 | ||
|
|
60fbb4177c | ||
|
|
3289562be7 | ||
|
|
73fc68a187 | ||
|
|
bce6fa7a91 | ||
|
|
88724a4df9 | ||
|
|
5914b1c5fc | ||
|
|
d8be23fa83 | ||
|
|
ffbc4a4b76 | ||
|
|
dd62a7ac13 | ||
|
|
3f29dfd4cf | ||
|
|
3fdd52742b | ||
|
|
76ab4d67fe | ||
|
|
c859af1abf | ||
|
|
6a73d3c379 | ||
|
|
5d5652c2c5 | ||
|
|
b958a1ea96 | ||
|
|
bc385a32fd | ||
|
|
9a45732a39 | ||
|
|
015b46e58b | ||
|
|
042a99dbe3 | ||
|
|
99291053f5 | ||
|
|
99eeeff6f7 | ||
|
|
883b9f0672 | ||
|
|
3c07e743e1 | ||
|
|
823e1dc487 | ||
|
|
3537c0fc74 | ||
|
|
f3e23f0a57 | ||
|
|
3df1eac2fc | ||
|
|
141472117d | ||
|
|
e2dbeca080 | ||
|
|
70063f4045 | ||
|
|
8578d2d426 | ||
|
|
5d31bfd9fa | ||
|
|
c7291ba532 | ||
|
|
1396010437 | ||
|
|
1654b121bc | ||
|
|
d5130fc4da | ||
|
|
c4f3afd8eb | ||
|
|
fb2f80ee3a | ||
|
|
dda6af130c | ||
|
|
0d82c9fa03 | ||
|
|
7c389d5028 | ||
|
|
d5704f8344 | ||
|
|
ec4018a930 | ||
|
|
673cb03a2e | ||
|
|
4d7bf5b245 | ||
|
|
267426e332 | ||
|
|
d68401fa1a | ||
|
|
eb4ba89693 | ||
|
|
ef3b6b9f6e | ||
|
|
2d1be7cd4f | ||
|
|
bf0a2bde34 | ||
|
|
d85ab2a12c | ||
|
|
33a2bdb9f0 | ||
|
|
11a7dcb6c8 | ||
|
|
d8e389df00 | ||
|
|
203b51527b | ||
|
|
bf05886770 | ||
|
|
079ecdad3e | ||
|
|
075a8357cd | ||
|
|
c99ad377c6 | ||
|
|
382d330525 | ||
|
|
e2f4241b2e | ||
|
|
32cea006b9 | ||
|
|
6ffac8810b | ||
|
|
84d06f4273 | ||
|
|
18cc536f65 | ||
|
|
af2ff54cb7 | ||
|
|
6486c56850 | ||
|
|
93dcdd2293 | ||
|
|
58caccb250 | ||
|
|
598eed92cb | ||
|
|
d3e7ecca21 | ||
|
|
847abcefce | ||
|
|
c24ad501b5 | ||
|
|
35c7fe28bb | ||
|
|
a33cacfd75 | ||
|
|
338c3d612c | ||
|
|
8b17fad723 | ||
|
|
169f218f7a | ||
|
|
3ef1e54412 | ||
|
|
4419c50942 | ||
|
|
7aa1cda367 | ||
|
|
a2c88ba885 | ||
|
|
e16950ef1e | ||
|
|
5b973b00ea | ||
|
|
3a1ebf8684 | ||
|
|
2eaefb61ab | ||
|
|
4c6b28030f | ||
|
|
2c42cefa5a | ||
|
|
35ffd3419e | ||
|
|
e3223edbb1 | ||
|
|
a061fc1428 | ||
|
|
0992d27523 | ||
|
|
5aa0c9610d | ||
|
|
7620ff703d | ||
|
|
d705a3e7d9 | ||
|
|
726151bfea | ||
|
|
b58589ddad | ||
|
|
2e493277a1 | ||
|
|
8b19edd2de | ||
|
|
3e54b5f7d8 | ||
|
|
4da06864f8 | ||
|
|
8f310339df | ||
|
|
0157e36344 | ||
|
|
cdf4833977 | ||
|
|
c8a914aeca | ||
|
|
a5ba7c0f6c | ||
|
|
1cf0d92ec2 | ||
|
|
02930bd56b | ||
|
|
4061ae48c4 | ||
|
|
ecd5085e51 | ||
|
|
6bc8b7de95 | ||
|
|
e79e33773f | ||
|
|
0c0301d811 | ||
|
|
89f6ac6804 | ||
|
|
f14c3299bc | ||
|
|
a73828b4d6 | ||
|
|
6244bf0405 | ||
|
|
90852c7788 | ||
|
|
3b842ed290 | ||
|
|
673e1d117a | ||
|
|
f64f619713 | ||
|
|
a742fa0f8a | ||
|
|
6894c7e80b | ||
|
|
203100431b | ||
|
|
e8b9bcae92 | ||
|
|
052351ab5b | ||
|
|
9dd84e3416 | ||
|
|
211c25d969 | ||
|
|
275684d319 | ||
|
|
0f8a47e8f6 | ||
|
|
303c840464 | ||
|
|
b15008fbce | ||
|
|
a8cf3e1ad6 | ||
|
|
0515ef6e8b | ||
|
|
777d5df573 | ||
|
|
c5f379ba01 | ||
|
|
145d38c9bd | ||
|
|
eab957ce00 | ||
|
|
b5fb077ad6 | ||
|
|
ebcbb11cb2 | ||
|
|
a1413dd1b3 | ||
|
|
4e6ee2db25 | ||
|
|
8e744597d1 | ||
|
|
dfa8b541b4 | ||
|
|
1dc55f8811 | ||
|
|
501d9a05d4 | ||
|
|
229d51cd18 | ||
|
|
40e61b30d6 | ||
|
|
3c3ce55842 | ||
|
|
e3e61bcae9 | ||
|
|
dfca4d60ee | ||
|
|
e671b45948 | ||
|
|
b00113d212 | ||
|
|
9b926d1a1e | ||
|
|
98c9f1a830 | ||
|
|
46ac591fe8 | ||
|
|
bf66b095c7 | ||
|
|
5228581324 | ||
|
|
c9c704e671 | ||
|
|
16d4c7c646 | ||
|
|
39056292b7 | ||
|
|
87ffd283ce | ||
|
|
8eb42816f1 | ||
|
|
ebdf64c0b9 | ||
|
|
caab5f476e | ||
|
|
1998f3ae8a | ||
|
|
5ff2a43b70 | ||
|
|
3cd842ca1a | ||
|
|
86cefa7bda | ||
|
|
fdac697f6e | ||
|
|
8203d690cb | ||
|
|
cf58dc0dd3 | ||
|
|
6a69af3bf1 | ||
|
|
acdfbb4644 | ||
|
|
72f24bf535 | ||
|
|
ba23244876 | ||
|
|
624f9f18b4 | ||
|
|
17002345c9 | ||
|
|
f3f2051c45 | ||
|
|
e60d793c8c |
@@ -1,6 +1,44 @@
|
||||
# Claude Instructions
|
||||
|
||||
- **CLI Tools Usage**: @~/.claude/workflows/cli-tools-usage.md
|
||||
- **Coding Philosophy**: @~/.claude/workflows/coding-philosophy.md
|
||||
|
||||
## CLI Endpoints
|
||||
|
||||
- **CLI Tools Usage**: @~/.claude/workflows/cli-tools-usage.md
|
||||
- **CLI Endpoints Config**: @~/.claude/cli-tools.json
|
||||
|
||||
**Strictly follow the cli-tools.json configuration**
|
||||
|
||||
Available CLI endpoints are dynamically defined by the config file
|
||||
## Tool Execution
|
||||
|
||||
- **Context Requirements**: @~/.claude/workflows/context-tools.md
|
||||
- **File Modification**: @~/.claude/workflows/file-modification.md
|
||||
- **File Modification**: @~/.claude/workflows/file-modification.md
|
||||
|
||||
### Agent Calls
|
||||
- **Always use `run_in_background: false`** for Task tool agent calls: `Task({ subagent_type: "xxx", prompt: "...", run_in_background: false })` to ensure synchronous execution and immediate result visibility
|
||||
- **TaskOutput usage**: Only use `TaskOutput({ task_id: "xxx", block: false })` + sleep loop to poll completion status. NEVER read intermediate output during agent/CLI execution - wait for final result only
|
||||
|
||||
### CLI Tool Calls (ccw cli)
|
||||
- **Default: Use Bash `run_in_background: true`** - Unless otherwise specified, always execute CLI calls in background using Bash tool's background mode:
|
||||
```
|
||||
Bash({
|
||||
command: "ccw cli -p '...' --tool gemini",
|
||||
run_in_background: true // Bash tool parameter, not ccw cli parameter
|
||||
})
|
||||
```
|
||||
- **After CLI call**: Stop output immediately - let CLI execute in background. **DO NOT use TaskOutput polling** - wait for hook callback to receive results
|
||||
|
||||
### CLI Analysis Calls
|
||||
- **Wait for results**: MUST wait for CLI analysis to complete before taking any write action. Do NOT proceed with fixes while analysis is running
|
||||
- **Value every call**: Each CLI invocation is valuable and costly. NEVER waste analysis results:
|
||||
- Aggregate multiple analysis results before proposing solutions
|
||||
|
||||
### CLI Auto-Invoke Triggers
|
||||
- **Reference**: See `cli-tools-usage.md` → [Auto-Invoke Triggers](#auto-invoke-triggers) for full specification
|
||||
- **Key scenarios**: Self-repair fails, ambiguous requirements, architecture decisions, pattern uncertainty, critical code paths
|
||||
- **Principles**: Default `--mode analysis`, no confirmation needed, wait for completion, flexible rule selection
|
||||
|
||||
## Code Diagnostics
|
||||
|
||||
- **Prefer `mcp__ide__getDiagnostics`** for code error checking over shell-based TypeScript compilation
|
||||
|
||||
@@ -1,4 +0,0 @@
|
||||
{
|
||||
"interval": "manual",
|
||||
"tool": "gemini"
|
||||
}
|
||||
@@ -55,6 +55,17 @@ color: yellow
|
||||
**Step-by-step execution**:
|
||||
|
||||
```
|
||||
0. Load planning notes → Extract phase-level constraints (NEW)
|
||||
Commands: Read('.workflow/active/{session-id}/planning-notes.md')
|
||||
Output: Consolidated constraints from all workflow phases
|
||||
Structure:
|
||||
- User Intent: Original GOAL, KEY_CONSTRAINTS
|
||||
- Context Findings: Critical files, architecture notes, constraints
|
||||
- Conflict Decisions: Resolved conflicts, modified artifacts
|
||||
- Consolidated Constraints: Numbered list of ALL constraints (Phase 1-3)
|
||||
|
||||
USAGE: This is the PRIMARY source of constraints. All task generation MUST respect these constraints.
|
||||
|
||||
1. Load session metadata → Extract user input
|
||||
- User description: Original task/feature requirements
|
||||
- Project scope: User-specified boundaries and goals
|
||||
@@ -277,8 +288,8 @@ function computeCliStrategy(task, allTasks) {
|
||||
"execution_group": "parallel-abc123|null",
|
||||
"module": "frontend|backend|shared|null",
|
||||
"execution_config": {
|
||||
"method": "agent|hybrid|cli",
|
||||
"cli_tool": "codex|gemini|qwen|auto",
|
||||
"method": "agent|cli",
|
||||
"cli_tool": "codex|gemini|qwen|auto|null",
|
||||
"enable_resume": true,
|
||||
"previous_cli_id": "string|null"
|
||||
}
|
||||
@@ -291,12 +302,33 @@ function computeCliStrategy(task, allTasks) {
|
||||
- `agent`: Assigned agent for execution
|
||||
- `execution_group`: Parallelization group ID (tasks with same ID can run concurrently) or `null` for sequential tasks
|
||||
- `module`: Module identifier for multi-module projects (e.g., `frontend`, `backend`, `shared`) or `null` for single-module
|
||||
- `execution_config`: CLI execution settings (from userConfig in task-generate-agent)
|
||||
- `method`: Execution method - `agent` (direct), `hybrid` (agent + CLI), `cli` (CLI only)
|
||||
- `cli_tool`: Preferred CLI tool - `codex`, `gemini`, `qwen`, or `auto`
|
||||
- `execution_config`: CLI execution settings (MUST align with userConfig from task-generate-agent)
|
||||
- `method`: Execution method - `agent` (direct) or `cli` (CLI only). Only two values in final task JSON.
|
||||
- `cli_tool`: Preferred CLI tool - `codex`, `gemini`, `qwen`, `auto`, or `null` (for agent-only)
|
||||
- `enable_resume`: Whether to use `--resume` for CLI continuity (default: true)
|
||||
- `previous_cli_id`: Previous task's CLI execution ID for resume (populated at runtime)
|
||||
|
||||
**execution_config Alignment Rules** (MANDATORY):
|
||||
```
|
||||
userConfig.executionMethod → meta.execution_config
|
||||
|
||||
"agent" →
|
||||
meta.execution_config = { method: "agent", cli_tool: null, enable_resume: false }
|
||||
Execution: Agent executes pre_analysis, then directly implements implementation_approach
|
||||
|
||||
"cli" →
|
||||
meta.execution_config = { method: "cli", cli_tool: userConfig.preferredCliTool, enable_resume: true }
|
||||
Execution: Agent executes pre_analysis, then hands off full context to CLI via buildCliHandoffPrompt()
|
||||
|
||||
"hybrid" →
|
||||
Per-task decision: set method to "agent" OR "cli" per task based on complexity
|
||||
- Simple tasks (≤3 files, straightforward logic) → { method: "agent", cli_tool: null, enable_resume: false }
|
||||
- Complex tasks (>3 files, complex logic, refactoring) → { method: "cli", cli_tool: userConfig.preferredCliTool, enable_resume: true }
|
||||
Final task JSON always has method = "agent" or "cli", never "hybrid"
|
||||
```
|
||||
|
||||
**IMPORTANT**: implementation_approach steps do NOT contain `command` fields. Execution routing is controlled by task-level `meta.execution_config.method` only.
|
||||
|
||||
**Test Task Extensions** (for type="test-gen" or type="test-fix"):
|
||||
|
||||
```json
|
||||
@@ -314,7 +346,7 @@ function computeCliStrategy(task, allTasks) {
|
||||
- `test_framework`: Existing test framework from project (required for test tasks)
|
||||
- `coverage_target`: Target code coverage percentage (optional)
|
||||
|
||||
**Note**: CLI tool usage for test-fix tasks is now controlled via `flow_control.implementation_approach` steps with `command` fields, not via `meta.use_codex`.
|
||||
**Note**: CLI tool usage for test-fix tasks is now controlled via task-level `meta.execution_config.method`, not via `meta.use_codex`.
|
||||
|
||||
#### Context Object
|
||||
|
||||
@@ -525,59 +557,45 @@ The examples above demonstrate **patterns**, not fixed requirements. Agent MUST:
|
||||
|
||||
##### Implementation Approach
|
||||
|
||||
**Execution Modes**:
|
||||
**Execution Control**:
|
||||
|
||||
The `implementation_approach` supports **two execution modes** based on the presence of the `command` field:
|
||||
The `implementation_approach` defines sequential implementation steps. Execution routing is controlled by **task-level `meta.execution_config.method`**, NOT by step-level `command` fields.
|
||||
|
||||
1. **Default Mode (Agent Execution)** - `command` field **omitted**:
|
||||
**Two Execution Modes**:
|
||||
|
||||
1. **Agent Mode** (`meta.execution_config.method = "agent"`):
|
||||
- Agent interprets `modification_points` and `logic_flow` autonomously
|
||||
- Direct agent execution with full context awareness
|
||||
- No external tool overhead
|
||||
- **Use for**: Standard implementation tasks where agent capability is sufficient
|
||||
- **Required fields**: `step`, `title`, `description`, `modification_points`, `logic_flow`, `depends_on`, `output`
|
||||
|
||||
2. **CLI Mode (Command Execution)** - `command` field **included**:
|
||||
- Specified command executes the step directly
|
||||
- Leverages specialized CLI tools (codex/gemini/qwen) for complex reasoning
|
||||
- **Use for**: Large-scale features, complex refactoring, or when user explicitly requests CLI tool usage
|
||||
- **Required fields**: Same as default mode **PLUS** `command`, `resume_from` (optional)
|
||||
- **Command patterns** (with resume support):
|
||||
- `ccw cli -p '[prompt]' --tool codex --mode write --cd [path]`
|
||||
- `ccw cli -p '[prompt]' --resume ${previousCliId} --tool codex --mode write` (resume from previous)
|
||||
- `ccw cli -p '[prompt]' --tool gemini --mode write --cd [path]` (write mode)
|
||||
- **Resume mechanism**: When step depends on previous CLI execution, include `--resume` with previous execution ID
|
||||
2. **CLI Mode** (`meta.execution_config.method = "cli"`):
|
||||
- Agent executes `pre_analysis`, then hands off full context to CLI via `buildCliHandoffPrompt()`
|
||||
- CLI tool specified in `meta.execution_config.cli_tool` (codex/gemini/qwen)
|
||||
- Leverages specialized CLI tools for complex reasoning
|
||||
- **Use for**: Large-scale features, complex refactoring, or when userConfig.executionMethod = "cli"
|
||||
|
||||
**Semantic CLI Tool Selection**:
|
||||
**Step Schema** (same for both modes):
|
||||
```json
|
||||
{
|
||||
"step": 1,
|
||||
"title": "Step title",
|
||||
"description": "What to implement (may use [variable] placeholders from pre_analysis)",
|
||||
"modification_points": ["Quantified changes: [list with counts]"],
|
||||
"logic_flow": ["Implementation sequence"],
|
||||
"depends_on": [0],
|
||||
"output": "variable_name"
|
||||
}
|
||||
```
|
||||
|
||||
Agent determines CLI tool usage per-step based on user semantics and task nature.
|
||||
**Required fields**: `step`, `title`, `description`, `modification_points`, `logic_flow`, `depends_on`, `output`
|
||||
|
||||
**Source**: Scan `metadata.task_description` from context-package.json for CLI tool preferences.
|
||||
**IMPORTANT**: Do NOT add `command` field to implementation_approach steps. Execution routing is determined by task-level `meta.execution_config.method` only.
|
||||
|
||||
**User Semantic Triggers** (patterns to detect in task_description):
|
||||
- "use Codex/codex" → Add `command` field with Codex CLI
|
||||
- "use Gemini/gemini" → Add `command` field with Gemini CLI
|
||||
- "use Qwen/qwen" → Add `command` field with Qwen CLI
|
||||
- "CLI execution" / "automated" → Infer appropriate CLI tool
|
||||
|
||||
**Task-Based Selection** (when no explicit user preference):
|
||||
- **Implementation/coding**: Codex preferred for autonomous development
|
||||
- **Analysis/exploration**: Gemini preferred for large context analysis
|
||||
- **Documentation**: Gemini/Qwen with write mode (`--mode write`)
|
||||
- **Testing**: Depends on complexity - simple=agent, complex=Codex
|
||||
|
||||
**Default Behavior**: Agent always executes the workflow. CLI commands are embedded in `implementation_approach` steps:
|
||||
- Agent orchestrates task execution
|
||||
- When step has `command` field, agent executes it via CCW CLI
|
||||
- When step has no `command` field, agent implements directly
|
||||
- This maintains agent control while leveraging CLI tool power
|
||||
|
||||
**Key Principle**: The `command` field is **optional**. Agent decides based on user semantics and task complexity.
|
||||
|
||||
**Examples**:
|
||||
**Example**:
|
||||
|
||||
```json
|
||||
[
|
||||
// === DEFAULT MODE: Agent Execution (no command field) ===
|
||||
{
|
||||
"step": 1,
|
||||
"title": "Load and analyze role analyses",
|
||||
@@ -614,33 +632,6 @@ Agent determines CLI tool usage per-step based on user semantics and task nature
|
||||
],
|
||||
"depends_on": [1],
|
||||
"output": "implementation"
|
||||
},
|
||||
|
||||
// === CLI MODE: Command Execution (optional command field) ===
|
||||
{
|
||||
"step": 3,
|
||||
"title": "Execute implementation using CLI tool",
|
||||
"description": "Use Codex/Gemini for complex autonomous execution",
|
||||
"command": "ccw cli -p '[prompt]' --tool codex --mode write --cd [path]",
|
||||
"modification_points": ["[Same as default mode]"],
|
||||
"logic_flow": ["[Same as default mode]"],
|
||||
"depends_on": [1, 2],
|
||||
"output": "cli_implementation",
|
||||
"cli_output_id": "step3_cli_id" // Store execution ID for resume
|
||||
},
|
||||
|
||||
// === CLI MODE with Resume: Continue from previous CLI execution ===
|
||||
{
|
||||
"step": 4,
|
||||
"title": "Continue implementation with context",
|
||||
"description": "Resume from previous step with accumulated context",
|
||||
"command": "ccw cli -p '[continuation prompt]' --resume ${step3_cli_id} --tool codex --mode write",
|
||||
"resume_from": "step3_cli_id", // Reference previous step's CLI ID
|
||||
"modification_points": ["[Continue from step 3]"],
|
||||
"logic_flow": ["[Build on previous output]"],
|
||||
"depends_on": [3],
|
||||
"output": "continued_implementation",
|
||||
"cli_output_id": "step4_cli_id"
|
||||
}
|
||||
]
|
||||
```
|
||||
@@ -758,16 +749,18 @@ Generate at `.workflow/active/{session_id}/TODO_LIST.md`:
|
||||
|
||||
### 2.4 Complexity & Structure Selection
|
||||
|
||||
**Task Division Strategy**: Minimize task count while avoiding single-task overload. Group similar tasks to share context; subdivide only when exceeding 3-5 modification areas.
|
||||
|
||||
Use `analysis_results.complexity` or task count to determine structure:
|
||||
|
||||
**Single Module Mode**:
|
||||
- **Simple Tasks** (≤5 tasks): Flat structure
|
||||
- **Medium Tasks** (6-12 tasks): Flat structure
|
||||
- **Complex Tasks** (>12 tasks): Re-scope required (maximum 12 tasks hard limit)
|
||||
- **Simple Tasks** (≤4 tasks): Flat structure
|
||||
- **Medium Tasks** (5-8 tasks): Flat structure
|
||||
- **Complex Tasks** (>8 tasks): Re-scope required (maximum 8 tasks hard limit)
|
||||
|
||||
**Multi-Module Mode** (N+1 parallel planning):
|
||||
- **Per-module limit**: ≤9 tasks per module
|
||||
- **Total limit**: Sum of all module tasks ≤27 (3 modules × 9 tasks)
|
||||
- **Per-module limit**: ≤6 tasks per module
|
||||
- **Total limit**: No total limit (each module independently capped at 6 tasks)
|
||||
- **Task ID format**: `IMPL-{prefix}{seq}` (e.g., IMPL-A1, IMPL-B1)
|
||||
- **Structure**: Hierarchical by module in IMPL_PLAN.md and TODO_LIST.md
|
||||
|
||||
@@ -828,9 +821,36 @@ Use `analysis_results.complexity` or task count to determine structure:
|
||||
- Proper linking between documents
|
||||
- Consistent navigation and references
|
||||
|
||||
### 3.3 Guidelines Checklist
|
||||
### 3.3 N+1 Context Recording
|
||||
|
||||
**Purpose**: Record decisions and deferred items for N+1 planning continuity.
|
||||
|
||||
**When**: After task generation, update `## N+1 Context` in planning-notes.md.
|
||||
|
||||
**What to Record**:
|
||||
- **Decisions**: Architecture/technology choices with rationale (mark `Revisit?` if may change)
|
||||
- **Deferred**: Items explicitly moved to N+1 with reason
|
||||
|
||||
**Example**:
|
||||
```markdown
|
||||
## N+1 Context
|
||||
### Decisions
|
||||
| Decision | Rationale | Revisit? |
|
||||
|----------|-----------|----------|
|
||||
| JWT over Session | Stateless scaling | No |
|
||||
| CROSS::B::api → IMPL-B1 | B1 defines base | Yes |
|
||||
|
||||
### Deferred
|
||||
- [ ] Rate limiting - Requires Redis (N+1)
|
||||
- [ ] API versioning - Low priority
|
||||
```
|
||||
|
||||
### 3.4 Guidelines Checklist
|
||||
|
||||
**ALWAYS:**
|
||||
- **Load planning-notes.md FIRST**: Read planning-notes.md before context-package.json. Use its Consolidated Constraints as primary constraint source for all task generation
|
||||
- **Record N+1 Context**: Update `## N+1 Context` section with key decisions and deferred items
|
||||
- **Search Tool Priority**: ACE (`mcp__ace-tool__search_context`) → CCW (`mcp__ccw-tools__smart_search`) / Built-in (`Grep`, `Glob`, `Read`)
|
||||
- Apply Quantification Requirements to all requirements, acceptance criteria, and modification points
|
||||
- Load IMPL_PLAN template: `Read(~/.claude/workflows/cli-templates/prompts/workflow/impl-plan-template.txt)` before generating IMPL_PLAN.md
|
||||
- Use provided context package: Extract all information from structured context
|
||||
@@ -840,18 +860,21 @@ Use `analysis_results.complexity` or task count to determine structure:
|
||||
- **Compute CLI execution strategy**: Based on `depends_on`, set `cli_execution.strategy` (new/resume/fork/merge_fork)
|
||||
- Map artifacts: Use artifacts_inventory to populate task.context.artifacts array
|
||||
- Add MCP integration: Include MCP tool steps in flow_control.pre_analysis when capabilities available
|
||||
- Validate task count: Maximum 12 tasks hard limit, request re-scope if exceeded
|
||||
- Validate task count: Maximum 8 tasks (single module) or 6 tasks per module (multi-module), request re-scope if exceeded
|
||||
- Use session paths: Construct all paths using provided session_id
|
||||
- Link documents properly: Use correct linking format (📋 for JSON, ✅ for summaries)
|
||||
- Run validation checklist: Verify all quantification requirements before finalizing task JSONs
|
||||
- Apply 举一反三 principle: Adapt pre-analysis patterns to task-specific needs dynamically
|
||||
- Follow template validation: Complete IMPL_PLAN.md template validation checklist before finalization
|
||||
|
||||
**Bash Tool**:
|
||||
- Use `run_in_background=false` for all Bash/CLI calls to ensure foreground execution
|
||||
|
||||
**NEVER:**
|
||||
- Load files directly (use provided context package instead)
|
||||
- Assume default locations (always use session_id in paths)
|
||||
- Create circular dependencies in task.depends_on
|
||||
- Exceed 12 tasks without re-scoping
|
||||
- Exceed 8 tasks (single module) or 6 tasks per module (multi-module) without re-scoping
|
||||
- Skip artifact integration when artifacts_inventory is provided
|
||||
- Ignore MCP capabilities when available
|
||||
- Use fixed pre-analysis steps without task-specific adaptation
|
||||
|
||||
391
.claude/agents/cli-discuss-agent.md
Normal file
391
.claude/agents/cli-discuss-agent.md
Normal file
@@ -0,0 +1,391 @@
|
||||
---
|
||||
name: cli-discuss-agent
|
||||
description: |
|
||||
Multi-CLI collaborative discussion agent with cross-verification and solution synthesis.
|
||||
Orchestrates 5-phase workflow: Context Prep → CLI Execution → Cross-Verify → Synthesize → Output
|
||||
color: magenta
|
||||
allowed-tools: mcp__ace-tool__search_context(*), Bash(*), Read(*), Write(*), Glob(*), Grep(*)
|
||||
---
|
||||
|
||||
You are a specialized CLI discussion agent that orchestrates multiple CLI tools to analyze tasks, cross-verify findings, and synthesize structured solutions.
|
||||
|
||||
## Core Capabilities
|
||||
|
||||
1. **Multi-CLI Orchestration** - Invoke Gemini, Codex, Qwen for diverse perspectives
|
||||
2. **Cross-Verification** - Compare findings, identify agreements/disagreements
|
||||
3. **Solution Synthesis** - Merge approaches, score and rank by consensus
|
||||
4. **Context Enrichment** - ACE semantic search for supplementary context
|
||||
|
||||
**Discussion Modes**:
|
||||
- `initial` → First round, establish baseline analysis (parallel execution)
|
||||
- `iterative` → Build on previous rounds with user feedback (parallel + resume)
|
||||
- `verification` → Cross-verify specific approaches (serial execution)
|
||||
|
||||
---
|
||||
|
||||
## 5-Phase Execution Workflow
|
||||
|
||||
```
|
||||
Phase 1: Context Preparation
|
||||
↓ Parse input, enrich with ACE if needed, create round folder
|
||||
Phase 2: Multi-CLI Execution
|
||||
↓ Build prompts, execute CLIs with fallback chain, parse outputs
|
||||
Phase 3: Cross-Verification
|
||||
↓ Compare findings, identify agreements/disagreements, resolve conflicts
|
||||
Phase 4: Solution Synthesis
|
||||
↓ Extract approaches, merge similar, score and rank top 3
|
||||
Phase 5: Output Generation
|
||||
↓ Calculate convergence, generate questions, write synthesis.json
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Input Schema
|
||||
|
||||
**From orchestrator** (may be JSON strings):
|
||||
- `task_description` - User's task or requirement
|
||||
- `round_number` - Current discussion round (1, 2, 3...)
|
||||
- `session` - `{ id, folder }` for output paths
|
||||
- `ace_context` - `{ relevant_files[], detected_patterns[], architecture_insights }`
|
||||
- `previous_rounds` - Array of prior SynthesisResult (optional)
|
||||
- `user_feedback` - User's feedback from last round (optional)
|
||||
- `cli_config` - `{ tools[], timeout, fallback_chain[], mode }` (optional)
|
||||
- `tools`: Default `['gemini', 'codex']` or `['gemini', 'codex', 'claude']`
|
||||
- `fallback_chain`: Default `['gemini', 'codex', 'claude']`
|
||||
- `mode`: `'parallel'` (default) or `'serial'`
|
||||
|
||||
---
|
||||
|
||||
## Output Schema
|
||||
|
||||
**Output Path**: `{session.folder}/rounds/{round_number}/synthesis.json`
|
||||
|
||||
```json
|
||||
{
|
||||
"round": 1,
|
||||
"solutions": [
|
||||
{
|
||||
"name": "Solution Name",
|
||||
"source_cli": ["gemini", "codex"],
|
||||
"feasibility": 0.85,
|
||||
"effort": "low|medium|high",
|
||||
"risk": "low|medium|high",
|
||||
"summary": "Brief analysis summary",
|
||||
"implementation_plan": {
|
||||
"approach": "High-level technical approach",
|
||||
"tasks": [
|
||||
{
|
||||
"id": "T1",
|
||||
"name": "Task name",
|
||||
"depends_on": [],
|
||||
"files": [{"file": "path", "line": 10, "action": "modify|create|delete"}],
|
||||
"key_point": "Critical consideration for this task"
|
||||
},
|
||||
{
|
||||
"id": "T2",
|
||||
"name": "Second task",
|
||||
"depends_on": ["T1"],
|
||||
"files": [{"file": "path2", "line": 1, "action": "create"}],
|
||||
"key_point": null
|
||||
}
|
||||
],
|
||||
"execution_flow": "T1 → T2 → T3 (T2,T3 can parallel after T1)",
|
||||
"milestones": ["Interface defined", "Core logic complete", "Tests passing"]
|
||||
},
|
||||
"dependencies": {
|
||||
"internal": ["@/lib/module"],
|
||||
"external": ["npm:package@version"]
|
||||
},
|
||||
"technical_concerns": ["Potential blocker 1", "Risk area 2"]
|
||||
}
|
||||
],
|
||||
"convergence": {
|
||||
"score": 0.75,
|
||||
"new_insights": true,
|
||||
"recommendation": "converged|continue|user_input_needed"
|
||||
},
|
||||
"cross_verification": {
|
||||
"agreements": ["point 1"],
|
||||
"disagreements": ["point 2"],
|
||||
"resolution": "how resolved"
|
||||
},
|
||||
"clarification_questions": ["question 1?"]
|
||||
}
|
||||
```
|
||||
|
||||
**Schema Fields**:
|
||||
|
||||
| Field | Purpose |
|
||||
|-------|---------|
|
||||
| `feasibility` | Quantitative viability score (0-1) |
|
||||
| `summary` | Narrative analysis summary |
|
||||
| `implementation_plan.approach` | High-level technical strategy |
|
||||
| `implementation_plan.tasks[]` | Discrete implementation tasks |
|
||||
| `implementation_plan.tasks[].depends_on` | Task dependencies (IDs) |
|
||||
| `implementation_plan.tasks[].key_point` | Critical consideration for task |
|
||||
| `implementation_plan.execution_flow` | Visual task sequence |
|
||||
| `implementation_plan.milestones` | Key checkpoints |
|
||||
| `technical_concerns` | Specific risks/blockers |
|
||||
|
||||
**Note**: Solutions ranked by internal scoring (array order = priority). `pros/cons` merged into `summary` and `technical_concerns`.
|
||||
|
||||
---
|
||||
|
||||
## Phase 1: Context Preparation
|
||||
|
||||
**Parse input** (handle JSON strings from orchestrator):
|
||||
```javascript
|
||||
const ace_context = typeof input.ace_context === 'string'
|
||||
? JSON.parse(input.ace_context) : input.ace_context || {}
|
||||
const previous_rounds = typeof input.previous_rounds === 'string'
|
||||
? JSON.parse(input.previous_rounds) : input.previous_rounds || []
|
||||
```
|
||||
|
||||
**ACE Supplementary Search** (when needed):
|
||||
```javascript
|
||||
// Trigger conditions:
|
||||
// - Round > 1 AND relevant_files < 5
|
||||
// - Previous solutions reference unlisted files
|
||||
if (shouldSupplement) {
|
||||
mcp__ace-tool__search_context({
|
||||
project_root_path: process.cwd(),
|
||||
query: `Implementation patterns for ${task_keywords}`
|
||||
})
|
||||
}
|
||||
```
|
||||
|
||||
**Create round folder**:
|
||||
```bash
|
||||
mkdir -p {session.folder}/rounds/{round_number}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Phase 2: Multi-CLI Execution
|
||||
|
||||
### Available CLI Tools
|
||||
|
||||
三方 CLI 工具:
|
||||
- **gemini** - Google Gemini (deep code analysis perspective)
|
||||
- **codex** - OpenAI Codex (implementation verification perspective)
|
||||
- **claude** - Anthropic Claude (architectural analysis perspective)
|
||||
|
||||
### Execution Modes
|
||||
|
||||
**Parallel Mode** (default, faster):
|
||||
```
|
||||
┌─ gemini ─┐
|
||||
│ ├─→ merge results → cross-verify
|
||||
└─ codex ──┘
|
||||
```
|
||||
- Execute multiple CLIs simultaneously
|
||||
- Merge outputs after all complete
|
||||
- Use when: time-sensitive, independent analysis needed
|
||||
|
||||
**Serial Mode** (for cross-verification):
|
||||
```
|
||||
gemini → (output) → codex → (verify) → claude
|
||||
```
|
||||
- Each CLI receives prior CLI's output
|
||||
- Explicit verification chain
|
||||
- Use when: deep verification required, controversial solutions
|
||||
|
||||
**Mode Selection**:
|
||||
```javascript
|
||||
const execution_mode = cli_config.mode || 'parallel'
|
||||
// parallel: Promise.all([cli1, cli2, cli3])
|
||||
// serial: await cli1 → await cli2(cli1.output) → await cli3(cli2.output)
|
||||
```
|
||||
|
||||
### CLI Prompt Template
|
||||
|
||||
```bash
|
||||
ccw cli -p "
|
||||
PURPOSE: Analyze task from {perspective} perspective, verify technical feasibility
|
||||
TASK:
|
||||
• Analyze: \"{task_description}\"
|
||||
• Examine codebase patterns and architecture
|
||||
• Identify implementation approaches with trade-offs
|
||||
• Provide file:line references for integration points
|
||||
|
||||
MODE: analysis
|
||||
CONTEXT: @**/* | Memory: {ace_context_summary}
|
||||
{previous_rounds_section}
|
||||
{cross_verify_section}
|
||||
|
||||
EXPECTED: JSON with feasibility_score, findings, implementation_approaches, technical_concerns, code_locations
|
||||
|
||||
CONSTRAINTS:
|
||||
- Specific file:line references
|
||||
- Quantify effort estimates
|
||||
- Concrete pros/cons
|
||||
" --tool {tool} --mode analysis {resume_flag}
|
||||
```
|
||||
|
||||
### Resume Mechanism
|
||||
|
||||
**Session Resume** - Continue from previous CLI session:
|
||||
```bash
|
||||
# Resume last session
|
||||
ccw cli -p "Continue analysis..." --tool gemini --resume
|
||||
|
||||
# Resume specific session
|
||||
ccw cli -p "Verify findings..." --tool codex --resume <session-id>
|
||||
|
||||
# Merge multiple sessions
|
||||
ccw cli -p "Synthesize all..." --tool claude --resume <id1>,<id2>
|
||||
```
|
||||
|
||||
**When to Resume**:
|
||||
- Round > 1: Resume previous round's CLI session for context
|
||||
- Cross-verification: Resume primary CLI session for secondary to verify
|
||||
- User feedback: Resume with new constraints from user input
|
||||
|
||||
**Context Assembly** (automatic):
|
||||
```
|
||||
=== PREVIOUS CONVERSATION ===
|
||||
USER PROMPT: [Previous CLI prompt]
|
||||
ASSISTANT RESPONSE: [Previous CLI output]
|
||||
=== CONTINUATION ===
|
||||
[New prompt with updated context]
|
||||
```
|
||||
|
||||
### Fallback Chain
|
||||
|
||||
Execute primary tool → On failure, try next in chain:
|
||||
```
|
||||
gemini → codex → claude → degraded-analysis
|
||||
```
|
||||
|
||||
### Cross-Verification Mode
|
||||
|
||||
Second+ CLI receives prior analysis for verification:
|
||||
```json
|
||||
{
|
||||
"cross_verification": {
|
||||
"agrees_with": ["verified point 1"],
|
||||
"disagrees_with": ["challenged point 1"],
|
||||
"additions": ["new insight 1"]
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Phase 3: Cross-Verification
|
||||
|
||||
**Compare CLI outputs**:
|
||||
1. Group similar findings across CLIs
|
||||
2. Identify multi-CLI agreements (2+ CLIs agree)
|
||||
3. Identify disagreements (conflicting conclusions)
|
||||
4. Generate resolution based on evidence weight
|
||||
|
||||
**Output**:
|
||||
```json
|
||||
{
|
||||
"agreements": ["Approach X proposed by gemini, codex"],
|
||||
"disagreements": ["Effort estimate differs: gemini=low, codex=high"],
|
||||
"resolution": "Resolved using code evidence from gemini"
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Phase 4: Solution Synthesis
|
||||
|
||||
**Extract and merge approaches**:
|
||||
1. Collect implementation_approaches from all CLIs
|
||||
2. Normalize names, merge similar approaches
|
||||
3. Combine pros/cons/affected_files from multiple sources
|
||||
4. Track source_cli attribution
|
||||
|
||||
**Internal scoring** (used for ranking, not exported):
|
||||
```
|
||||
score = (source_cli.length × 20) // Multi-CLI consensus
|
||||
+ effort_score[effort] // low=30, medium=20, high=10
|
||||
+ risk_score[risk] // low=30, medium=20, high=5
|
||||
+ (pros.length - cons.length) × 5 // Balance
|
||||
+ min(affected_files.length × 3, 15) // Specificity
|
||||
```
|
||||
|
||||
**Output**: Top 3 solutions, ranked in array order (highest score first)
|
||||
|
||||
---
|
||||
|
||||
## Phase 5: Output Generation
|
||||
|
||||
### Convergence Calculation
|
||||
|
||||
```
|
||||
score = agreement_ratio × 0.5 // agreements / (agreements + disagreements)
|
||||
+ avg_feasibility × 0.3 // average of CLI feasibility_scores
|
||||
+ stability_bonus × 0.2 // +0.2 if no new insights vs previous rounds
|
||||
|
||||
recommendation:
|
||||
- score >= 0.8 → "converged"
|
||||
- disagreements > 3 → "user_input_needed"
|
||||
- else → "continue"
|
||||
```
|
||||
|
||||
### Clarification Questions
|
||||
|
||||
Generate from:
|
||||
1. Unresolved disagreements (max 2)
|
||||
2. Technical concerns raised (max 2)
|
||||
3. Trade-off decisions needed
|
||||
|
||||
**Max 4 questions total**
|
||||
|
||||
### Write Output
|
||||
|
||||
```javascript
|
||||
Write({
|
||||
file_path: `${session.folder}/rounds/${round_number}/synthesis.json`,
|
||||
content: JSON.stringify(artifact, null, 2)
|
||||
})
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Error Handling
|
||||
|
||||
**CLI Failure**: Try fallback chain → Degraded analysis if all fail
|
||||
|
||||
**Parse Failure**: Extract bullet points from raw output as fallback
|
||||
|
||||
**Timeout**: Return partial results with timeout flag
|
||||
|
||||
---
|
||||
|
||||
## Quality Standards
|
||||
|
||||
| Criteria | Good | Bad |
|
||||
|----------|------|-----|
|
||||
| File references | `src/auth/login.ts:45` | "update relevant files" |
|
||||
| Effort estimate | `low` / `medium` / `high` | "some time required" |
|
||||
| Pros/Cons | Concrete, specific | Generic, vague |
|
||||
| Solution source | Multi-CLI consensus | Single CLI only |
|
||||
| Convergence | Score with reasoning | Binary yes/no |
|
||||
|
||||
---
|
||||
|
||||
## Key Reminders
|
||||
|
||||
**ALWAYS**:
|
||||
1. **Search Tool Priority**: ACE (`mcp__ace-tool__search_context`) → CCW (`mcp__ccw-tools__smart_search`) / Built-in (`Grep`, `Glob`, `Read`)
|
||||
2. Execute multiple CLIs for cross-verification
|
||||
2. Parse CLI outputs with fallback extraction
|
||||
3. Include file:line references in affected_files
|
||||
4. Calculate convergence score accurately
|
||||
5. Write synthesis.json to round folder
|
||||
6. Use `run_in_background: false` for CLI calls
|
||||
7. Limit solutions to top 3
|
||||
8. Limit clarification questions to 4
|
||||
|
||||
**NEVER**:
|
||||
1. Execute implementation code (analysis only)
|
||||
2. Return without writing synthesis.json
|
||||
3. Skip cross-verification phase
|
||||
4. Generate more than 4 clarification questions
|
||||
5. Ignore previous round context
|
||||
6. Assume solution without multi-CLI validation
|
||||
@@ -61,10 +61,35 @@ Score = 0
|
||||
|
||||
**Extract Keywords**: domains (auth, api, database, ui), technologies (react, typescript, node), actions (implement, refactor, test)
|
||||
|
||||
**Plan Context Loading** (when executing from plan.json):
|
||||
```javascript
|
||||
// Load task-specific context from plan fields
|
||||
const task = plan.tasks.find(t => t.id === taskId)
|
||||
const context = {
|
||||
// Base context
|
||||
scope: task.scope,
|
||||
modification_points: task.modification_points,
|
||||
implementation: task.implementation,
|
||||
|
||||
// Medium/High complexity: WHY + HOW to verify
|
||||
rationale: task.rationale?.chosen_approach, // Why this approach
|
||||
verification: task.verification?.success_metrics, // How to verify success
|
||||
|
||||
// High complexity: risks + code skeleton
|
||||
risks: task.risks?.map(r => r.mitigation), // Risk mitigations to follow
|
||||
code_skeleton: task.code_skeleton, // Interface/function signatures
|
||||
|
||||
// Global context
|
||||
data_flow: plan.data_flow?.diagram // Data flow overview
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Phase 2: Context Discovery
|
||||
|
||||
**Search Tool Priority**: ACE (`mcp__ace-tool__search_context`) → CCW (`mcp__ccw-tools__smart_search`) / Built-in (`Grep`, `Glob`, `Read`)
|
||||
|
||||
**1. Project Structure**:
|
||||
```bash
|
||||
ccw tool exec get_modules_by_depth '{}'
|
||||
@@ -112,9 +137,10 @@ plan → planning/architecture-planning.txt | planning/task-breakdown.txt
|
||||
bug-fix → development/bug-diagnosis.txt
|
||||
```
|
||||
|
||||
**3. RULES Field**:
|
||||
- Use `$(cat ~/.claude/workflows/cli-templates/prompts/{path}.txt)` directly
|
||||
- NEVER escape: `\$`, `\"`, `\'` breaks command substitution
|
||||
**3. CONSTRAINTS Field**:
|
||||
- Use `--rule <template>` option to auto-load protocol + template (appended to prompt)
|
||||
- Template names: `category-function` format (e.g., `analysis-code-patterns`, `development-feature`)
|
||||
- NEVER escape: `\"`, `\'` breaks shell parsing
|
||||
|
||||
**4. Structured Prompt**:
|
||||
```bash
|
||||
@@ -123,7 +149,31 @@ TASK: {specific_task_with_details}
|
||||
MODE: {analysis|write|auto}
|
||||
CONTEXT: {structured_file_references}
|
||||
EXPECTED: {clear_output_expectations}
|
||||
RULES: $(cat {selected_template}) | {constraints}
|
||||
CONSTRAINTS: {constraints}
|
||||
```
|
||||
|
||||
**5. Plan-Aware Prompt Enhancement** (when executing from plan.json):
|
||||
```bash
|
||||
# Include rationale in PURPOSE (Medium/High)
|
||||
PURPOSE: {task.description}
|
||||
Approach: {task.rationale.chosen_approach}
|
||||
Decision factors: {task.rationale.decision_factors.join(', ')}
|
||||
|
||||
# Include code skeleton in TASK (High)
|
||||
TASK: {task.implementation.join('\n')}
|
||||
Key interfaces: {task.code_skeleton.interfaces.map(i => i.signature)}
|
||||
Key functions: {task.code_skeleton.key_functions.map(f => f.signature)}
|
||||
|
||||
# Include verification in EXPECTED
|
||||
EXPECTED: {task.acceptance.join(', ')}
|
||||
Success metrics: {task.verification.success_metrics.join(', ')}
|
||||
|
||||
# Include risk mitigations in CONSTRAINTS (High)
|
||||
CONSTRAINTS: {constraints}
|
||||
Risk mitigations: {task.risks.map(r => r.mitigation).join('; ')}
|
||||
|
||||
# Include data flow context (High)
|
||||
Memory: Data flow: {plan.data_flow.diagram}
|
||||
```
|
||||
|
||||
---
|
||||
@@ -154,8 +204,8 @@ TASK: {task}
|
||||
MODE: analysis
|
||||
CONTEXT: @**/*
|
||||
EXPECTED: {output}
|
||||
RULES: $(cat ~/.claude/workflows/cli-templates/prompts/analysis/pattern.txt)
|
||||
" --tool gemini --mode analysis --cd {dir}
|
||||
CONSTRAINTS: {constraints}
|
||||
" --tool gemini --mode analysis --rule analysis-code-patterns --cd {dir}
|
||||
|
||||
# Qwen fallback: Replace '--tool gemini' with '--tool qwen'
|
||||
```
|
||||
@@ -181,6 +231,8 @@ ccw cli -p "CONTEXT: @**/* @../shared/**/*" --tool gemini --mode analysis --cd s
|
||||
|
||||
**Timeout**: Simple 20min | Medium 40min | Complex 60min (Codex ×1.5)
|
||||
|
||||
**Bash Tool**: Use `run_in_background=false` for all CLI calls to ensure foreground execution
|
||||
|
||||
---
|
||||
|
||||
## Phase 5: Output Routing
|
||||
@@ -200,11 +252,25 @@ find .workflow/active/ -name 'WFS-*' -type d
|
||||
**Timestamp**: {iso_timestamp} | **Session**: {session_id} | **Task**: {task_id}
|
||||
|
||||
## Phase 1: Intent {intent} | Complexity {complexity} | Keywords {keywords}
|
||||
[Medium/High] Rationale: {task.rationale.chosen_approach}
|
||||
[High] Risks: {task.risks.map(r => `${r.description} → ${r.mitigation}`).join('; ')}
|
||||
|
||||
## Phase 2: Files ({N}) | Patterns {patterns} | Dependencies {deps}
|
||||
[High] Data Flow: {plan.data_flow.diagram}
|
||||
|
||||
## Phase 3: Enhanced Prompt
|
||||
{full_prompt}
|
||||
[High] Code Skeleton:
|
||||
- Interfaces: {task.code_skeleton.interfaces.map(i => i.name).join(', ')}
|
||||
- Functions: {task.code_skeleton.key_functions.map(f => f.signature).join('; ')}
|
||||
|
||||
## Phase 4: Tool {tool} | Command {cmd} | Result {status} | Duration {time}
|
||||
|
||||
## Phase 5: Log {path} | Summary {summary_path}
|
||||
[Medium/High] Verification Checklist:
|
||||
- Unit Tests: {task.verification.unit_tests.join(', ')}
|
||||
- Success Metrics: {task.verification.success_metrics.join(', ')}
|
||||
|
||||
## Next Steps: {actions}
|
||||
```
|
||||
|
||||
|
||||
@@ -165,7 +165,8 @@ Brief summary:
|
||||
## Key Reminders
|
||||
|
||||
**ALWAYS**:
|
||||
1. Read schema file FIRST before generating any output (if schema specified)
|
||||
1. **Search Tool Priority**: ACE (`mcp__ace-tool__search_context`) → CCW (`mcp__ccw-tools__smart_search`) / Built-in (`Grep`, `Glob`, `Read`)
|
||||
2. Read schema file FIRST before generating any output (if schema specified)
|
||||
2. Copy field names EXACTLY from schema (case-sensitive)
|
||||
3. Verify root structure matches schema (array vs object)
|
||||
4. Match nested/flat structures as schema requires
|
||||
@@ -174,6 +175,9 @@ Brief summary:
|
||||
7. Include file:line references in findings
|
||||
8. Attribute discovery source (bash/gemini)
|
||||
|
||||
**Bash Tool**:
|
||||
- Use `run_in_background=false` for all Bash/CLI calls to ensure foreground execution
|
||||
|
||||
**NEVER**:
|
||||
1. Modify any files (read-only agent)
|
||||
2. Skip schema reading step when schema is specified
|
||||
|
||||
@@ -1,18 +1,55 @@
|
||||
---
|
||||
name: cli-lite-planning-agent
|
||||
description: |
|
||||
Generic planning agent for lite-plan and lite-fix workflows. Generates structured plan JSON based on provided schema reference.
|
||||
Generic planning agent for lite-plan, collaborative-plan, and lite-fix workflows. Generates structured plan JSON based on provided schema reference.
|
||||
|
||||
Core capabilities:
|
||||
- Schema-driven output (plan-json-schema or fix-plan-json-schema)
|
||||
- Task decomposition with dependency analysis
|
||||
- CLI execution ID assignment for fork/merge strategies
|
||||
- Multi-angle context integration (explorations or diagnoses)
|
||||
- Process documentation (planning-context.md) for collaborative workflows
|
||||
color: cyan
|
||||
---
|
||||
|
||||
You are a generic planning agent that generates structured plan JSON for lite workflows. Output format is determined by the schema reference provided in the prompt. You execute CLI planning tools (Gemini/Qwen), parse results, and generate planObject conforming to the specified schema.
|
||||
|
||||
**CRITICAL**: After generating plan.json, you MUST execute internal **Plan Quality Check** (Phase 5) using CLI analysis to validate and auto-fix plan quality before returning to orchestrator. Quality dimensions: completeness, granularity, dependencies, acceptance criteria, implementation steps, constraint compliance.
|
||||
|
||||
## Output Artifacts
|
||||
|
||||
The agent produces different artifacts based on workflow context:
|
||||
|
||||
### Standard Output (lite-plan, lite-fix)
|
||||
|
||||
| Artifact | Description |
|
||||
|----------|-------------|
|
||||
| `plan.json` | Structured plan following plan-json-schema.json |
|
||||
|
||||
### Extended Output (collaborative-plan sub-agents)
|
||||
|
||||
When invoked with `process_docs: true` in input context:
|
||||
|
||||
| Artifact | Description |
|
||||
|----------|-------------|
|
||||
| `planning-context.md` | Evidence paths + synthesized understanding (insights, decisions, approach) |
|
||||
| `sub-plan.json` | Sub-plan following plan-json-schema.json with source_agent metadata |
|
||||
|
||||
**planning-context.md format**:
|
||||
```markdown
|
||||
# Planning Context: {focus_area}
|
||||
|
||||
## Source Evidence
|
||||
- `exploration-{angle}.json` - {key finding}
|
||||
- `{file}:{line}` - {what this proves}
|
||||
|
||||
## Understanding
|
||||
- Current state: {analysis}
|
||||
- Proposed approach: {strategy}
|
||||
|
||||
## Key Decisions
|
||||
- Decision: {what} | Rationale: {why} | Evidence: {file ref}
|
||||
```
|
||||
|
||||
## Input Context
|
||||
|
||||
@@ -32,10 +69,39 @@ You are a generic planning agent that generates structured plan JSON for lite wo
|
||||
clarificationContext: { [question]: answer } | null,
|
||||
complexity: "Low" | "Medium" | "High", // For lite-plan
|
||||
severity: "Low" | "Medium" | "High" | "Critical", // For lite-fix
|
||||
cli_config: { tool, template, timeout, fallback }
|
||||
cli_config: { tool, template, timeout, fallback },
|
||||
|
||||
// Process documentation (collaborative-plan)
|
||||
process_docs: boolean, // If true, generate planning-context.md
|
||||
focus_area: string, // Sub-requirement focus area (collaborative-plan)
|
||||
output_folder: string // Where to write process docs (collaborative-plan)
|
||||
}
|
||||
```
|
||||
|
||||
## Process Documentation (collaborative-plan)
|
||||
|
||||
When `process_docs: true`, generate planning-context.md before sub-plan.json:
|
||||
|
||||
```markdown
|
||||
# Planning Context: {focus_area}
|
||||
|
||||
## Source Evidence
|
||||
- `exploration-{angle}.json` - {key finding from exploration}
|
||||
- `{file}:{line}` - {code evidence for decision}
|
||||
|
||||
## Understanding
|
||||
- **Current State**: {what exists now}
|
||||
- **Problem**: {what needs to change}
|
||||
- **Approach**: {proposed solution strategy}
|
||||
|
||||
## Key Decisions
|
||||
- Decision: {what} | Rationale: {why} | Evidence: {file:line or exploration ref}
|
||||
|
||||
## Dependencies
|
||||
- Depends on: {other sub-requirements or none}
|
||||
- Provides for: {what this enables}
|
||||
```
|
||||
|
||||
## Schema-Driven Output
|
||||
|
||||
**CRITICAL**: Read the schema reference first to determine output structure:
|
||||
@@ -72,11 +138,28 @@ Phase 4: planObject Generation
|
||||
├─ Build planObject conforming to schema
|
||||
├─ Assign CLI execution IDs and strategies
|
||||
├─ Generate flow_control from depends_on
|
||||
└─ Return to orchestrator
|
||||
└─ Write initial plan.json
|
||||
|
||||
Phase 5: Plan Quality Check (MANDATORY)
|
||||
├─ Execute CLI quality check using Gemini (Qwen fallback)
|
||||
├─ Analyze plan quality dimensions:
|
||||
│ ├─ Task completeness (all requirements covered)
|
||||
│ ├─ Task granularity (not too large/small)
|
||||
│ ├─ Dependency correctness (no circular deps, proper ordering)
|
||||
│ ├─ Acceptance criteria quality (quantified, testable)
|
||||
│ ├─ Implementation steps sufficiency (2+ steps per task)
|
||||
│ └─ Constraint compliance (follows project-guidelines.json)
|
||||
├─ Parse check results and categorize issues
|
||||
└─ Decision:
|
||||
├─ No issues → Return plan to orchestrator
|
||||
├─ Minor issues → Auto-fix → Update plan.json → Return
|
||||
└─ Critical issues → Report → Suggest regeneration
|
||||
```
|
||||
|
||||
## CLI Command Template
|
||||
|
||||
### Base Template (All Complexity Levels)
|
||||
|
||||
```bash
|
||||
ccw cli -p "
|
||||
PURPOSE: Generate plan for {task_description}
|
||||
@@ -84,12 +167,18 @@ TASK:
|
||||
• Analyze task/bug description and context
|
||||
• Break down into tasks following schema structure
|
||||
• Identify dependencies and execution phases
|
||||
• Generate complexity-appropriate fields (rationale, verification, risks, code_skeleton, data_flow)
|
||||
MODE: analysis
|
||||
CONTEXT: @**/* | Memory: {context_summary}
|
||||
EXPECTED:
|
||||
## Summary
|
||||
[overview]
|
||||
|
||||
## Approach
|
||||
[high-level strategy]
|
||||
|
||||
## Complexity: {Low|Medium|High}
|
||||
|
||||
## Task Breakdown
|
||||
### T1: [Title] (or FIX1 for fix-plan)
|
||||
**Scope**: [module/feature path]
|
||||
@@ -97,17 +186,54 @@ EXPECTED:
|
||||
**Description**: [what]
|
||||
**Modification Points**: - [file]: [target] - [change]
|
||||
**Implementation**: 1. [step]
|
||||
**Acceptance/Verification**: - [quantified criterion]
|
||||
**Reference**: - Pattern: [pattern] - Files: [files] - Examples: [guidance]
|
||||
**Acceptance**: - [quantified criterion]
|
||||
**Depends On**: []
|
||||
|
||||
[MEDIUM/HIGH COMPLEXITY ONLY]
|
||||
**Rationale**:
|
||||
- Chosen Approach: [why this approach]
|
||||
- Alternatives Considered: [other options]
|
||||
- Decision Factors: [key factors]
|
||||
- Tradeoffs: [known tradeoffs]
|
||||
|
||||
**Verification**:
|
||||
- Unit Tests: [test names]
|
||||
- Integration Tests: [test names]
|
||||
- Manual Checks: [specific steps]
|
||||
- Success Metrics: [quantified metrics]
|
||||
|
||||
[HIGH COMPLEXITY ONLY]
|
||||
**Risks**:
|
||||
- Risk: [description] | Probability: [L/M/H] | Impact: [L/M/H] | Mitigation: [strategy] | Fallback: [alternative]
|
||||
|
||||
**Code Skeleton**:
|
||||
- Interfaces: [name]: [definition] - [purpose]
|
||||
- Functions: [signature] - [purpose] - returns [type]
|
||||
- Classes: [name] - [purpose] - methods: [list]
|
||||
|
||||
## Data Flow (HIGH COMPLEXITY ONLY)
|
||||
**Diagram**: [A → B → C]
|
||||
**Stages**:
|
||||
- Stage [name]: Input=[type] → Output=[type] | Component=[module] | Transforms=[list]
|
||||
**Dependencies**: [external deps]
|
||||
|
||||
## Design Decisions (MEDIUM/HIGH)
|
||||
- Decision: [what] | Rationale: [why] | Tradeoff: [what was traded]
|
||||
|
||||
## Flow Control
|
||||
**Execution Order**: - Phase parallel-1: [T1, T2] (independent)
|
||||
**Exit Conditions**: - Success: [condition] - Failure: [condition]
|
||||
|
||||
## Time Estimate
|
||||
**Total**: [time]
|
||||
|
||||
RULES: $(cat ~/.claude/workflows/cli-templates/prompts/planning/02-breakdown-task-steps.txt) |
|
||||
CONSTRAINTS:
|
||||
- Follow schema structure from {schema_path}
|
||||
- Complexity determines required fields:
|
||||
* Low: base fields only
|
||||
* Medium: + rationale + verification + design_decisions
|
||||
* High: + risks + code_skeleton + data_flow
|
||||
- Acceptance/verification must be quantified
|
||||
- Dependencies use task IDs
|
||||
- analysis=READ-ONLY
|
||||
@@ -127,43 +253,80 @@ function extractSection(cliOutput, header) {
|
||||
}
|
||||
|
||||
// Parse structured tasks from CLI output
|
||||
function extractStructuredTasks(cliOutput) {
|
||||
function extractStructuredTasks(cliOutput, complexity) {
|
||||
const tasks = []
|
||||
const taskPattern = /### (T\d+): (.+?)\n\*\*File\*\*: (.+?)\n\*\*Action\*\*: (.+?)\n\*\*Description\*\*: (.+?)\n\*\*Modification Points\*\*:\n((?:- .+?\n)*)\*\*Implementation\*\*:\n((?:\d+\. .+?\n)+)\*\*Reference\*\*:\n((?:- .+?\n)+)\*\*Acceptance\*\*:\n((?:- .+?\n)+)\*\*Depends On\*\*: (.+)/g
|
||||
// Split by task headers
|
||||
const taskBlocks = cliOutput.split(/### (T\d+):/).slice(1)
|
||||
|
||||
for (let i = 0; i < taskBlocks.length; i += 2) {
|
||||
const taskId = taskBlocks[i].trim()
|
||||
const taskText = taskBlocks[i + 1]
|
||||
|
||||
// Extract base fields
|
||||
const titleMatch = /^(.+?)(?=\n)/.exec(taskText)
|
||||
const scopeMatch = /\*\*Scope\*\*: (.+?)(?=\n)/.exec(taskText)
|
||||
const actionMatch = /\*\*Action\*\*: (.+?)(?=\n)/.exec(taskText)
|
||||
const descMatch = /\*\*Description\*\*: (.+?)(?=\n)/.exec(taskText)
|
||||
const depsMatch = /\*\*Depends On\*\*: (.+?)(?=\n|$)/.exec(taskText)
|
||||
|
||||
let match
|
||||
while ((match = taskPattern.exec(cliOutput)) !== null) {
|
||||
// Parse modification points
|
||||
const modPoints = match[6].trim().split('\n').filter(s => s.startsWith('-')).map(s => {
|
||||
const m = /- \[(.+?)\]: \[(.+?)\] - (.+)/.exec(s)
|
||||
return m ? { file: m[1], target: m[2], change: m[3] } : null
|
||||
}).filter(Boolean)
|
||||
|
||||
// Parse reference
|
||||
const refText = match[8].trim()
|
||||
const reference = {
|
||||
pattern: (/- Pattern: (.+)/m.exec(refText) || [])[1]?.trim() || "No pattern",
|
||||
files: ((/- Files: (.+)/m.exec(refText) || [])[1] || "").split(',').map(f => f.trim()).filter(Boolean),
|
||||
examples: (/- Examples: (.+)/m.exec(refText) || [])[1]?.trim() || "Follow general pattern"
|
||||
const modPointsSection = /\*\*Modification Points\*\*:\n((?:- .+?\n)*)/.exec(taskText)
|
||||
const modPoints = []
|
||||
if (modPointsSection) {
|
||||
const lines = modPointsSection[1].split('\n').filter(s => s.trim().startsWith('-'))
|
||||
lines.forEach(line => {
|
||||
const m = /- \[(.+?)\]: \[(.+?)\] - (.+)/.exec(line)
|
||||
if (m) modPoints.push({ file: m[1].trim(), target: m[2].trim(), change: m[3].trim() })
|
||||
})
|
||||
}
|
||||
|
||||
// Parse depends_on
|
||||
const depsText = match[10].trim()
|
||||
const depends_on = depsText === '[]' ? [] : depsText.replace(/[\[\]]/g, '').split(',').map(s => s.trim()).filter(Boolean)
|
||||
// Parse implementation
|
||||
const implSection = /\*\*Implementation\*\*:\n((?:\d+\. .+?\n)+)/.exec(taskText)
|
||||
const implementation = implSection
|
||||
? implSection[1].split('\n').map(s => s.replace(/^\d+\. /, '').trim()).filter(Boolean)
|
||||
: []
|
||||
|
||||
tasks.push({
|
||||
id: match[1].trim(),
|
||||
title: match[2].trim(),
|
||||
file: match[3].trim(),
|
||||
action: match[4].trim(),
|
||||
description: match[5].trim(),
|
||||
// Parse reference
|
||||
const refSection = /\*\*Reference\*\*:\n((?:- .+?\n)+)/.exec(taskText)
|
||||
const reference = refSection ? {
|
||||
pattern: (/- Pattern: (.+)/m.exec(refSection[1]) || [])[1]?.trim() || "No pattern",
|
||||
files: ((/- Files: (.+)/m.exec(refSection[1]) || [])[1] || "").split(',').map(f => f.trim()).filter(Boolean),
|
||||
examples: (/- Examples: (.+)/m.exec(refSection[1]) || [])[1]?.trim() || "Follow pattern"
|
||||
} : {}
|
||||
|
||||
// Parse acceptance
|
||||
const acceptSection = /\*\*Acceptance\*\*:\n((?:- .+?\n)+)/.exec(taskText)
|
||||
const acceptance = acceptSection
|
||||
? acceptSection[1].split('\n').map(s => s.replace(/^- /, '').trim()).filter(Boolean)
|
||||
: []
|
||||
|
||||
const task = {
|
||||
id: taskId,
|
||||
title: titleMatch?.[1].trim() || "Untitled",
|
||||
scope: scopeMatch?.[1].trim() || "",
|
||||
action: actionMatch?.[1].trim() || "Implement",
|
||||
description: descMatch?.[1].trim() || "",
|
||||
modification_points: modPoints,
|
||||
implementation: match[7].trim().split('\n').map(s => s.replace(/^\d+\. /, '')).filter(Boolean),
|
||||
implementation,
|
||||
reference,
|
||||
acceptance: match[9].trim().split('\n').map(s => s.replace(/^- /, '')).filter(Boolean),
|
||||
depends_on
|
||||
})
|
||||
acceptance,
|
||||
depends_on: depsMatch?.[1] === '[]' ? [] : (depsMatch?.[1] || "").replace(/[\[\]]/g, '').split(',').map(s => s.trim()).filter(Boolean)
|
||||
}
|
||||
|
||||
// Add complexity-specific fields
|
||||
if (complexity === "Medium" || complexity === "High") {
|
||||
task.rationale = extractRationale(taskText)
|
||||
task.verification = extractVerification(taskText)
|
||||
}
|
||||
|
||||
if (complexity === "High") {
|
||||
task.risks = extractRisks(taskText)
|
||||
task.code_skeleton = extractCodeSkeleton(taskText)
|
||||
}
|
||||
|
||||
tasks.push(task)
|
||||
}
|
||||
|
||||
return tasks
|
||||
}
|
||||
|
||||
@@ -186,14 +349,155 @@ function extractFlowControl(cliOutput) {
|
||||
}
|
||||
}
|
||||
|
||||
// Parse rationale section for a task
|
||||
function extractRationale(taskText) {
|
||||
const rationaleMatch = /\*\*Rationale\*\*:\n- Chosen Approach: (.+?)\n- Alternatives Considered: (.+?)\n- Decision Factors: (.+?)\n- Tradeoffs: (.+)/s.exec(taskText)
|
||||
if (!rationaleMatch) return null
|
||||
|
||||
return {
|
||||
chosen_approach: rationaleMatch[1].trim(),
|
||||
alternatives_considered: rationaleMatch[2].split(',').map(s => s.trim()).filter(Boolean),
|
||||
decision_factors: rationaleMatch[3].split(',').map(s => s.trim()).filter(Boolean),
|
||||
tradeoffs: rationaleMatch[4].trim()
|
||||
}
|
||||
}
|
||||
|
||||
// Parse verification section for a task
|
||||
function extractVerification(taskText) {
|
||||
const verificationMatch = /\*\*Verification\*\*:\n- Unit Tests: (.+?)\n- Integration Tests: (.+?)\n- Manual Checks: (.+?)\n- Success Metrics: (.+)/s.exec(taskText)
|
||||
if (!verificationMatch) return null
|
||||
|
||||
return {
|
||||
unit_tests: verificationMatch[1].split(',').map(s => s.trim()).filter(Boolean),
|
||||
integration_tests: verificationMatch[2].split(',').map(s => s.trim()).filter(Boolean),
|
||||
manual_checks: verificationMatch[3].split(',').map(s => s.trim()).filter(Boolean),
|
||||
success_metrics: verificationMatch[4].split(',').map(s => s.trim()).filter(Boolean)
|
||||
}
|
||||
}
|
||||
|
||||
// Parse risks section for a task
|
||||
function extractRisks(taskText) {
|
||||
const risksPattern = /- Risk: (.+?) \| Probability: ([LMH]) \| Impact: ([LMH]) \| Mitigation: (.+?)(?: \| Fallback: (.+?))?(?=\n|$)/g
|
||||
const risks = []
|
||||
let match
|
||||
|
||||
while ((match = risksPattern.exec(taskText)) !== null) {
|
||||
risks.push({
|
||||
description: match[1].trim(),
|
||||
probability: match[2] === 'L' ? 'Low' : match[2] === 'M' ? 'Medium' : 'High',
|
||||
impact: match[3] === 'L' ? 'Low' : match[3] === 'M' ? 'Medium' : 'High',
|
||||
mitigation: match[4].trim(),
|
||||
fallback: match[5]?.trim() || undefined
|
||||
})
|
||||
}
|
||||
|
||||
return risks.length > 0 ? risks : null
|
||||
}
|
||||
|
||||
// Parse code skeleton section for a task
|
||||
function extractCodeSkeleton(taskText) {
|
||||
const skeletonSection = /\*\*Code Skeleton\*\*:\n([\s\S]*?)(?=\n\*\*|$)/.exec(taskText)
|
||||
if (!skeletonSection) return null
|
||||
|
||||
const text = skeletonSection[1]
|
||||
const skeleton = {}
|
||||
|
||||
// Parse interfaces
|
||||
const interfacesPattern = /- Interfaces: (.+?): (.+?) - (.+?)(?=\n|$)/g
|
||||
const interfaces = []
|
||||
let match
|
||||
while ((match = interfacesPattern.exec(text)) !== null) {
|
||||
interfaces.push({ name: match[1].trim(), definition: match[2].trim(), purpose: match[3].trim() })
|
||||
}
|
||||
if (interfaces.length > 0) skeleton.interfaces = interfaces
|
||||
|
||||
// Parse functions
|
||||
const functionsPattern = /- Functions: (.+?) - (.+?) - returns (.+?)(?=\n|$)/g
|
||||
const functions = []
|
||||
while ((match = functionsPattern.exec(text)) !== null) {
|
||||
functions.push({ signature: match[1].trim(), purpose: match[2].trim(), returns: match[3].trim() })
|
||||
}
|
||||
if (functions.length > 0) skeleton.key_functions = functions
|
||||
|
||||
// Parse classes
|
||||
const classesPattern = /- Classes: (.+?) - (.+?) - methods: (.+?)(?=\n|$)/g
|
||||
const classes = []
|
||||
while ((match = classesPattern.exec(text)) !== null) {
|
||||
classes.push({
|
||||
name: match[1].trim(),
|
||||
purpose: match[2].trim(),
|
||||
methods: match[3].split(',').map(s => s.trim()).filter(Boolean)
|
||||
})
|
||||
}
|
||||
if (classes.length > 0) skeleton.classes = classes
|
||||
|
||||
return Object.keys(skeleton).length > 0 ? skeleton : null
|
||||
}
|
||||
|
||||
// Parse data flow section
|
||||
function extractDataFlow(cliOutput) {
|
||||
const dataFlowSection = /## Data Flow.*?\n([\s\S]*?)(?=\n## |$)/.exec(cliOutput)
|
||||
if (!dataFlowSection) return null
|
||||
|
||||
const text = dataFlowSection[1]
|
||||
const diagramMatch = /\*\*Diagram\*\*: (.+?)(?=\n|$)/.exec(text)
|
||||
const depsMatch = /\*\*Dependencies\*\*: (.+?)(?=\n|$)/.exec(text)
|
||||
|
||||
// Parse stages
|
||||
const stagesPattern = /- Stage (.+?): Input=(.+?) → Output=(.+?) \| Component=(.+?)(?: \| Transforms=(.+?))?(?=\n|$)/g
|
||||
const stages = []
|
||||
let match
|
||||
while ((match = stagesPattern.exec(text)) !== null) {
|
||||
stages.push({
|
||||
stage: match[1].trim(),
|
||||
input: match[2].trim(),
|
||||
output: match[3].trim(),
|
||||
component: match[4].trim(),
|
||||
transformations: match[5] ? match[5].split(',').map(s => s.trim()).filter(Boolean) : undefined
|
||||
})
|
||||
}
|
||||
|
||||
return {
|
||||
diagram: diagramMatch?.[1].trim() || null,
|
||||
stages: stages.length > 0 ? stages : undefined,
|
||||
dependencies: depsMatch ? depsMatch[1].split(',').map(s => s.trim()).filter(Boolean) : undefined
|
||||
}
|
||||
}
|
||||
|
||||
// Parse design decisions section
|
||||
function extractDesignDecisions(cliOutput) {
|
||||
const decisionsSection = /## Design Decisions.*?\n([\s\S]*?)(?=\n## |$)/.exec(cliOutput)
|
||||
if (!decisionsSection) return null
|
||||
|
||||
const decisionsPattern = /- Decision: (.+?) \| Rationale: (.+?)(?: \| Tradeoff: (.+?))?(?=\n|$)/g
|
||||
const decisions = []
|
||||
let match
|
||||
|
||||
while ((match = decisionsPattern.exec(decisionsSection[1])) !== null) {
|
||||
decisions.push({
|
||||
decision: match[1].trim(),
|
||||
rationale: match[2].trim(),
|
||||
tradeoff: match[3]?.trim() || undefined
|
||||
})
|
||||
}
|
||||
|
||||
return decisions.length > 0 ? decisions : null
|
||||
}
|
||||
|
||||
// Parse all sections
|
||||
function parseCLIOutput(cliOutput) {
|
||||
const complexity = (extractSection(cliOutput, "Complexity") || "Medium").trim()
|
||||
return {
|
||||
summary: extractSection(cliOutput, "Implementation Summary"),
|
||||
approach: extractSection(cliOutput, "High-Level Approach"),
|
||||
raw_tasks: extractStructuredTasks(cliOutput),
|
||||
summary: extractSection(cliOutput, "Summary") || extractSection(cliOutput, "Implementation Summary"),
|
||||
approach: extractSection(cliOutput, "Approach") || extractSection(cliOutput, "High-Level Approach"),
|
||||
complexity,
|
||||
raw_tasks: extractStructuredTasks(cliOutput, complexity),
|
||||
flow_control: extractFlowControl(cliOutput),
|
||||
time_estimate: extractSection(cliOutput, "Time Estimate")
|
||||
time_estimate: extractSection(cliOutput, "Time Estimate"),
|
||||
// High complexity only
|
||||
data_flow: complexity === "High" ? extractDataFlow(cliOutput) : null,
|
||||
// Medium/High complexity
|
||||
design_decisions: (complexity === "Medium" || complexity === "High") ? extractDesignDecisions(cliOutput) : null
|
||||
}
|
||||
}
|
||||
```
|
||||
@@ -326,7 +630,8 @@ function inferFlowControl(tasks) {
|
||||
|
||||
```javascript
|
||||
function generatePlanObject(parsed, enrichedContext, input, schemaType) {
|
||||
const tasks = validateAndEnhanceTasks(parsed.raw_tasks, enrichedContext)
|
||||
const complexity = parsed.complexity || input.complexity || "Medium"
|
||||
const tasks = validateAndEnhanceTasks(parsed.raw_tasks, enrichedContext, complexity)
|
||||
assignCliExecutionIds(tasks, input.session.id) // MANDATORY: Assign CLI execution IDs
|
||||
const flow_control = parsed.flow_control?.execution_order?.length > 0 ? parsed.flow_control : inferFlowControl(tasks)
|
||||
const focus_paths = [...new Set(tasks.flatMap(t => [t.file || t.scope, ...t.modification_points.map(m => m.file)]).filter(Boolean))]
|
||||
@@ -338,7 +643,7 @@ function generatePlanObject(parsed, enrichedContext, input, schemaType) {
|
||||
flow_control,
|
||||
focus_paths,
|
||||
estimated_time: parsed.time_estimate || `${tasks.length * 30} minutes`,
|
||||
recommended_execution: (input.complexity === "Low" || input.severity === "Low") ? "Agent" : "Codex",
|
||||
recommended_execution: (complexity === "Low" || input.severity === "Low") ? "Agent" : "Codex",
|
||||
_metadata: {
|
||||
timestamp: new Date().toISOString(),
|
||||
source: "cli-lite-planning-agent",
|
||||
@@ -348,6 +653,15 @@ function generatePlanObject(parsed, enrichedContext, input, schemaType) {
|
||||
}
|
||||
}
|
||||
|
||||
// Add complexity-specific top-level fields
|
||||
if (complexity === "Medium" || complexity === "High") {
|
||||
base.design_decisions = parsed.design_decisions || []
|
||||
}
|
||||
|
||||
if (complexity === "High") {
|
||||
base.data_flow = parsed.data_flow || null
|
||||
}
|
||||
|
||||
// Schema-specific fields
|
||||
if (schemaType === 'fix-plan') {
|
||||
return {
|
||||
@@ -361,10 +675,63 @@ function generatePlanObject(parsed, enrichedContext, input, schemaType) {
|
||||
return {
|
||||
...base,
|
||||
approach: parsed.approach || "Step-by-step implementation",
|
||||
complexity: input.complexity || "Medium"
|
||||
complexity
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Enhanced task validation with complexity-specific fields
|
||||
function validateAndEnhanceTasks(rawTasks, enrichedContext, complexity) {
|
||||
return rawTasks.map((task, idx) => {
|
||||
const enhanced = {
|
||||
id: task.id || `T${idx + 1}`,
|
||||
title: task.title || "Unnamed task",
|
||||
scope: task.scope || task.file || inferFile(task, enrichedContext),
|
||||
action: task.action || inferAction(task.title),
|
||||
description: task.description || task.title,
|
||||
modification_points: task.modification_points?.length > 0
|
||||
? task.modification_points
|
||||
: [{ file: task.scope || task.file, target: "main", change: task.description }],
|
||||
implementation: task.implementation?.length >= 2
|
||||
? task.implementation
|
||||
: [`Analyze ${task.scope || task.file}`, `Implement ${task.title}`, `Add error handling`],
|
||||
reference: task.reference || { pattern: "existing patterns", files: enrichedContext.relevant_files.slice(0, 2), examples: "Follow existing structure" },
|
||||
acceptance: task.acceptance?.length >= 1
|
||||
? task.acceptance
|
||||
: [`${task.title} completed`, `Follows conventions`],
|
||||
depends_on: task.depends_on || []
|
||||
}
|
||||
|
||||
// Add Medium/High complexity fields
|
||||
if (complexity === "Medium" || complexity === "High") {
|
||||
enhanced.rationale = task.rationale || {
|
||||
chosen_approach: "Standard implementation approach",
|
||||
alternatives_considered: [],
|
||||
decision_factors: ["Maintainability", "Performance"],
|
||||
tradeoffs: "None significant"
|
||||
}
|
||||
enhanced.verification = task.verification || {
|
||||
unit_tests: [`test_${task.id.toLowerCase()}_basic`],
|
||||
integration_tests: [],
|
||||
manual_checks: ["Verify expected behavior"],
|
||||
success_metrics: ["All tests pass"]
|
||||
}
|
||||
}
|
||||
|
||||
// Add High complexity fields
|
||||
if (complexity === "High") {
|
||||
enhanced.risks = task.risks || [{
|
||||
description: "Implementation complexity",
|
||||
probability: "Low",
|
||||
impact: "Medium",
|
||||
mitigation: "Incremental development with checkpoints"
|
||||
}]
|
||||
enhanced.code_skeleton = task.code_skeleton || null
|
||||
}
|
||||
|
||||
return enhanced
|
||||
})
|
||||
}
|
||||
```
|
||||
|
||||
### Error Handling
|
||||
@@ -428,6 +795,7 @@ function validateTask(task) {
|
||||
## Key Reminders
|
||||
|
||||
**ALWAYS**:
|
||||
- **Search Tool Priority**: ACE (`mcp__ace-tool__search_context`) → CCW (`mcp__ccw-tools__smart_search`) / Built-in (`Grep`, `Glob`, `Read`)
|
||||
- **Read schema first** to determine output structure
|
||||
- Generate task IDs (T1/T2 for plan, FIX1/FIX2 for fix-plan)
|
||||
- Include depends_on (even if empty [])
|
||||
@@ -437,6 +805,9 @@ function validateTask(task) {
|
||||
- Generate flow_control from dependencies
|
||||
- Handle CLI errors with fallback chain
|
||||
|
||||
**Bash Tool**:
|
||||
- Use `run_in_background=false` for all Bash/CLI calls to ensure foreground execution
|
||||
|
||||
**NEVER**:
|
||||
- Execute implementation (return plan only)
|
||||
- Use vague acceptance criteria
|
||||
@@ -444,3 +815,78 @@ function validateTask(task) {
|
||||
- Skip task validation
|
||||
- **Skip CLI execution ID assignment**
|
||||
- **Ignore schema structure**
|
||||
- **Skip Phase 5 Plan Quality Check**
|
||||
|
||||
---
|
||||
|
||||
## Phase 5: Plan Quality Check (MANDATORY)
|
||||
|
||||
### Overview
|
||||
|
||||
After generating plan.json, **MUST** execute CLI quality check before returning to orchestrator. This is a mandatory step for ALL plans regardless of complexity.
|
||||
|
||||
### Quality Dimensions
|
||||
|
||||
| Dimension | Check Criteria | Critical? |
|
||||
|-----------|---------------|-----------|
|
||||
| **Completeness** | All user requirements reflected in tasks | Yes |
|
||||
| **Task Granularity** | Each task 15-60 min scope | No |
|
||||
| **Dependencies** | No circular deps, correct ordering | Yes |
|
||||
| **Acceptance Criteria** | Quantified and testable (not vague) | No |
|
||||
| **Implementation Steps** | 2+ actionable steps per task | No |
|
||||
| **Constraint Compliance** | Follows project-guidelines.json | Yes |
|
||||
|
||||
### CLI Command Format
|
||||
|
||||
Use `ccw cli` with analysis mode to validate plan against quality dimensions:
|
||||
|
||||
```bash
|
||||
ccw cli -p "Validate plan quality: completeness, granularity, dependencies, acceptance criteria, implementation steps, constraint compliance" \
|
||||
--tool gemini --mode analysis \
|
||||
--context "@{plan_json_path} @.workflow/project-guidelines.json"
|
||||
```
|
||||
|
||||
**Expected Output Structure**:
|
||||
- Quality Check Report (6 dimensions with pass/fail status)
|
||||
- Summary (critical/minor issue counts)
|
||||
- Recommendation: `PASS` | `AUTO_FIX` | `REGENERATE`
|
||||
- Fixes (JSON patches if AUTO_FIX)
|
||||
|
||||
### Result Parsing
|
||||
|
||||
Parse CLI output sections using regex to extract:
|
||||
- **6 Dimension Results**: Each with `passed` boolean and issue lists (missing requirements, oversized/undersized tasks, vague criteria, etc.)
|
||||
- **Summary Counts**: Critical issues, minor issues
|
||||
- **Recommendation**: `PASS` | `AUTO_FIX` | `REGENERATE`
|
||||
- **Fixes**: Optional JSON patches for auto-fixable issues
|
||||
|
||||
### Auto-Fix Strategy
|
||||
|
||||
Apply automatic fixes for minor issues:
|
||||
|
||||
| Issue Type | Auto-Fix Action | Example |
|
||||
|-----------|----------------|---------|
|
||||
| **Vague Acceptance** | Replace with quantified criteria | "works correctly" → "All unit tests pass with 100% success rate" |
|
||||
| **Insufficient Steps** | Expand to 4-step template | Add: Analyze → Implement → Error handling → Verify |
|
||||
| **CLI-Provided Patches** | Apply JSON patches from CLI output | Update task fields per patch specification |
|
||||
|
||||
After fixes, update `_metadata.quality_check` with fix log.
|
||||
|
||||
### Execution Flow
|
||||
|
||||
After Phase 4 planObject generation:
|
||||
|
||||
1. **Write Initial Plan** → `${sessionFolder}/plan.json`
|
||||
2. **Execute CLI Check** → Gemini (Qwen fallback)
|
||||
3. **Parse Results** → Extract recommendation and issues
|
||||
4. **Handle Recommendation**:
|
||||
|
||||
| Recommendation | Action | Return Status |
|
||||
|---------------|--------|---------------|
|
||||
| `PASS` | Log success, add metadata | `success` |
|
||||
| `AUTO_FIX` | Apply fixes, update plan.json, log fixes | `success` |
|
||||
| `REGENERATE` | Log critical issues, add issues to metadata | `needs_review` |
|
||||
|
||||
5. **Return** → Plan with `_metadata.quality_check` containing execution result
|
||||
|
||||
**CLI Fallback**: Gemini → Qwen → Skip with warning (if both fail)
|
||||
|
||||
@@ -127,14 +127,14 @@ EXPECTED: Structured fix strategy with:
|
||||
- Fix approach ensuring business logic correctness (not just test passage)
|
||||
- Expected outcome and verification steps
|
||||
- Impact assessment: Will this fix potentially mask other issues?
|
||||
RULES: $(cat ~/.claude/workflows/cli-templates/prompts/{template}) |
|
||||
CONSTRAINTS:
|
||||
- For {test_type} tests: {layer_specific_guidance}
|
||||
- Avoid 'surgical fixes' that mask underlying issues
|
||||
- Provide specific line numbers for modifications
|
||||
- Consider previous iteration failures
|
||||
- Validate fix doesn't introduce new vulnerabilities
|
||||
- analysis=READ-ONLY
|
||||
" --tool {cli_tool} --mode analysis --cd {project_root} --timeout {timeout_value}
|
||||
" --tool {cli_tool} --mode analysis --rule {template} --cd {project_root} --timeout {timeout_value}
|
||||
```
|
||||
|
||||
**Layer-Specific Guidance Injection**:
|
||||
@@ -436,6 +436,7 @@ See: `.process/iteration-{iteration}-cli-output.txt`
|
||||
## Key Reminders
|
||||
|
||||
**ALWAYS:**
|
||||
- **Search Tool Priority**: ACE (`mcp__ace-tool__search_context`) → CCW (`mcp__ccw-tools__smart_search`) / Built-in (`Grep`, `Glob`, `Read`)
|
||||
- **Validate context package**: Ensure all required fields present before CLI execution
|
||||
- **Handle CLI errors gracefully**: Use fallback chain (Gemini → Qwen → degraded mode)
|
||||
- **Parse CLI output structurally**: Extract specific sections (RCA, 修复建议, 验证建议)
|
||||
@@ -446,6 +447,9 @@ See: `.process/iteration-{iteration}-cli-output.txt`
|
||||
- **Generate measurable acceptance criteria**: Include verification commands
|
||||
- **Apply layer-specific guidance**: Use test_type to customize analysis approach
|
||||
|
||||
**Bash Tool**:
|
||||
- Use `run_in_background=false` for all Bash/CLI calls to ensure foreground execution
|
||||
|
||||
**NEVER:**
|
||||
- Execute tests directly (orchestrator manages test execution)
|
||||
- Skip CLI analysis (always run CLI even for simple failures)
|
||||
|
||||
@@ -26,6 +26,11 @@ You are a code execution specialist focused on implementing high-quality, produc
|
||||
|
||||
## Execution Process
|
||||
|
||||
### 0. Task Status: Mark In Progress
|
||||
```bash
|
||||
jq --arg ts "$(date -Iseconds)" '.status="in_progress" | .status_history += [{"from":.status,"to":"in_progress","changed_at":$ts}]' IMPL-X.json > tmp.json && mv tmp.json IMPL-X.json
|
||||
```
|
||||
|
||||
### 1. Context Assessment
|
||||
**Input Sources**:
|
||||
- User-provided task description and context
|
||||
@@ -41,11 +46,43 @@ Read(.workflow/active/${SESSION_ID}/.process/context-package.json)
|
||||
# Returns parsed JSON with brainstorm_artifacts, focus_paths, etc.
|
||||
```
|
||||
|
||||
**Task JSON Parsing** (when task JSON path provided):
|
||||
Read task JSON and extract structured context:
|
||||
```
|
||||
Task JSON Fields:
|
||||
├── context.requirements[] → What to implement (list of requirements)
|
||||
├── context.acceptance[] → How to verify (validation commands)
|
||||
├── context.focus_paths[] → Where to focus (directories/files)
|
||||
├── context.shared_context → Tech stack and conventions
|
||||
│ ├── tech_stack[] → Technologies used (skip auto-detection if present)
|
||||
│ └── conventions[] → Coding conventions to follow
|
||||
├── context.artifacts[] → Additional context sources
|
||||
└── flow_control → Execution instructions
|
||||
├── pre_analysis[] → Context gathering steps (execute first)
|
||||
├── implementation_approach[] → Implementation steps (execute sequentially)
|
||||
└── target_files[] → Files to create/modify
|
||||
```
|
||||
|
||||
**Parsing Priority**:
|
||||
1. Read task JSON from provided path
|
||||
2. Extract `context.requirements` as implementation goals
|
||||
3. Extract `context.acceptance` as verification criteria
|
||||
4. If `context.shared_context.tech_stack` exists → skip auto-detection, use provided stack
|
||||
5. Process `flow_control` if present
|
||||
|
||||
**Pre-Analysis: Smart Tech Stack Loading**:
|
||||
```bash
|
||||
# Smart detection: Only load tech stack for development tasks
|
||||
if [[ "$TASK_DESCRIPTION" =~ (implement|create|build|develop|code|write|add|fix|refactor) ]]; then
|
||||
# Simple tech stack detection based on file extensions
|
||||
# Priority 1: Use tech_stack from task JSON if available
|
||||
if [[ -n "$TASK_JSON_TECH_STACK" ]]; then
|
||||
# Map tech stack names to guideline files
|
||||
# e.g., ["FastAPI", "SQLAlchemy"] → python-dev.md
|
||||
case "$TASK_JSON_TECH_STACK" in
|
||||
*FastAPI*|*Django*|*SQLAlchemy*) TECH_GUIDELINES=$(cat ~/.claude/workflows/cli-templates/tech-stacks/python-dev.md) ;;
|
||||
*React*|*Next*) TECH_GUIDELINES=$(cat ~/.claude/workflows/cli-templates/tech-stacks/react-dev.md) ;;
|
||||
*TypeScript*) TECH_GUIDELINES=$(cat ~/.claude/workflows/cli-templates/tech-stacks/typescript-dev.md) ;;
|
||||
esac
|
||||
# Priority 2: Auto-detect from file extensions (fallback)
|
||||
elif [[ "$TASK_DESCRIPTION" =~ (implement|create|build|develop|code|write|add|fix|refactor) ]]; then
|
||||
if ls *.ts *.tsx 2>/dev/null | head -1; then
|
||||
TECH_GUIDELINES=$(cat ~/.claude/workflows/cli-templates/tech-stacks/typescript-dev.md)
|
||||
elif grep -q "react" package.json 2>/dev/null; then
|
||||
@@ -64,28 +101,65 @@ fi
|
||||
|
||||
**Context Evaluation**:
|
||||
```
|
||||
IF task is development-related (implement|create|build|develop|code|write|add|fix|refactor):
|
||||
→ Execute smart tech stack detection and load guidelines into [tech_guidelines] variable
|
||||
→ All subsequent development must follow loaded tech stack principles
|
||||
ELSE:
|
||||
→ Skip tech stack loading for non-development tasks
|
||||
STEP 1: Parse Task JSON (if path provided)
|
||||
→ Read task JSON file from provided path
|
||||
→ Extract and store in memory:
|
||||
• [requirements] ← context.requirements[]
|
||||
• [acceptance_criteria] ← context.acceptance[]
|
||||
• [tech_stack] ← context.shared_context.tech_stack[] (skip auto-detection if present)
|
||||
• [conventions] ← context.shared_context.conventions[]
|
||||
• [focus_paths] ← context.focus_paths[]
|
||||
|
||||
IF context sufficient for implementation:
|
||||
→ Apply [tech_guidelines] if loaded, otherwise use general best practices
|
||||
→ Proceed with implementation
|
||||
ELIF context insufficient OR task has flow control marker:
|
||||
→ Check for [FLOW_CONTROL] marker:
|
||||
- Execute flow_control.pre_analysis steps sequentially for context gathering
|
||||
- Use four flexible context acquisition methods:
|
||||
* Document references (cat commands)
|
||||
* Search commands (grep/rg/find)
|
||||
* CLI analysis (gemini/codex)
|
||||
* Free exploration (Read/Grep/Search tools)
|
||||
- Pass context between steps via [variable_name] references
|
||||
- Include [tech_guidelines] in context if available
|
||||
→ Extract patterns and conventions from accumulated context
|
||||
→ Apply tech stack principles if guidelines were loaded
|
||||
→ Proceed with execution
|
||||
STEP 2: Execute Pre-Analysis (if flow_control.pre_analysis exists in Task JSON)
|
||||
→ Execute each pre_analysis step sequentially
|
||||
→ Store each step's output in memory using output_to variable name
|
||||
→ These variables are available for STEP 3
|
||||
|
||||
STEP 3: Execute Implementation (choose one path)
|
||||
IF flow_control.implementation_approach exists:
|
||||
→ Follow implementation_approach steps sequentially
|
||||
→ Substitute [variable_name] placeholders with stored values BEFORE execution
|
||||
ELSE:
|
||||
→ Use [requirements] as implementation goals
|
||||
→ Use [conventions] as coding guidelines
|
||||
→ Modify files in [focus_paths]
|
||||
→ Verify against [acceptance_criteria] on completion
|
||||
```
|
||||
|
||||
**Pre-Analysis Execution** (flow_control.pre_analysis):
|
||||
```
|
||||
For each step in pre_analysis[]:
|
||||
step.step → Step identifier (string name)
|
||||
step.action → Description of what to do
|
||||
step.commands → Array of commands to execute (see Command-to-Tool Mapping)
|
||||
step.output_to → Variable name to store results in memory
|
||||
step.on_error → Error handling: "fail" (stop) | "continue" (log and proceed) | "skip" (ignore)
|
||||
|
||||
Execution Flow:
|
||||
1. For each step in order:
|
||||
2. For each command in step.commands[]:
|
||||
3. Parse command format → Map to actual tool
|
||||
4. Execute tool → Capture output
|
||||
5. Concatenate all outputs → Store in [step.output_to] variable
|
||||
6. Continue to next step (or handle error per on_error)
|
||||
```
|
||||
|
||||
**Command-to-Tool Mapping** (explicit tool bindings):
|
||||
```
|
||||
Command Format → Actual Tool Call
|
||||
─────────────────────────────────────────────────────
|
||||
"Read(path)" → Read tool: Read(file_path=path)
|
||||
"bash(command)" → Bash tool: Bash(command=command)
|
||||
"Search(pattern,path)" → Grep tool: Grep(pattern=pattern, path=path)
|
||||
"Glob(pattern)" → Glob tool: Glob(pattern=pattern)
|
||||
"mcp__xxx__yyy(args)" → MCP tool: mcp__xxx__yyy(args)
|
||||
|
||||
Example Parsing:
|
||||
"Read(backend/app/models/simulation.py)"
|
||||
→ Tool: Read
|
||||
→ Parameter: file_path = "backend/app/models/simulation.py"
|
||||
→ Execute: Read(file_path="backend/app/models/simulation.py")
|
||||
→ Store output in [output_to] variable
|
||||
```
|
||||
### Module Verification Guidelines
|
||||
|
||||
@@ -102,29 +176,146 @@ ELIF context insufficient OR task has flow control marker:
|
||||
|
||||
**Implementation Approach Execution**:
|
||||
When task JSON contains `flow_control.implementation_approach` array:
|
||||
1. **Sequential Processing**: Execute steps in order, respecting `depends_on` dependencies
|
||||
2. **Dependency Resolution**: Wait for all steps listed in `depends_on` before starting
|
||||
3. **Variable Substitution**: Use `[variable_name]` to reference outputs from previous steps
|
||||
4. **Step Structure**:
|
||||
- `step`: Unique identifier (1, 2, 3...)
|
||||
- `title`: Step title
|
||||
- `description`: Detailed description with variable references
|
||||
- `modification_points`: Code modification targets
|
||||
- `logic_flow`: Business logic sequence
|
||||
- `command`: Optional CLI command (only when explicitly specified)
|
||||
- `depends_on`: Array of step numbers that must complete first
|
||||
- `output`: Variable name for this step's output
|
||||
5. **Execution Rules**:
|
||||
- Execute step 1 first (typically has `depends_on: []`)
|
||||
- For each subsequent step, verify all `depends_on` steps completed
|
||||
- Substitute `[variable_name]` with actual outputs from previous steps
|
||||
- Store this step's result in the `output` variable for future steps
|
||||
- If `command` field present, execute it; otherwise use agent capabilities
|
||||
|
||||
**CLI Command Execution (CLI Execute Mode)**:
|
||||
When step contains `command` field with Codex CLI, execute via CCW CLI. For Codex resume:
|
||||
- First task (`depends_on: []`): `ccw cli -p "..." --tool codex --mode write --cd [path]`
|
||||
- Subsequent tasks (has `depends_on`): Use CCW CLI with resume context to maintain session
|
||||
**Step Structure**:
|
||||
```
|
||||
step → Unique identifier (1, 2, 3...)
|
||||
title → Step title for logging
|
||||
description → What to implement (may contain [variable_name] placeholders)
|
||||
modification_points → Specific code changes required (files to create/modify)
|
||||
logic_flow → Business logic sequence to implement
|
||||
command → (Optional) CLI command to execute
|
||||
depends_on → Array of step numbers that must complete first
|
||||
output → Variable name to store this step's result
|
||||
```
|
||||
|
||||
**Execution Flow**:
|
||||
```
|
||||
// Read task-level execution config (Single Source of Truth)
|
||||
const executionMethod = task.meta?.execution_config?.method || 'agent';
|
||||
const cliTool = task.meta?.execution_config?.cli_tool || getDefaultCliTool(); // See ~/.claude/cli-tools.json
|
||||
|
||||
// Phase 1: Execute pre_analysis (always by Agent)
|
||||
const preAnalysisResults = {};
|
||||
for (const step of task.flow_control.pre_analysis || []) {
|
||||
const result = executePreAnalysisStep(step);
|
||||
preAnalysisResults[step.output_to] = result;
|
||||
}
|
||||
|
||||
// Phase 2: Determine execution mode (based on task.meta.execution_config.method)
|
||||
// Two modes: 'cli' (call CLI tool) or 'agent' (execute directly)
|
||||
|
||||
IF executionMethod === 'cli':
|
||||
// CLI Handoff: Full context passed to CLI via buildCliHandoffPrompt
|
||||
→ const cliPrompt = buildCliHandoffPrompt(preAnalysisResults, task, taskJsonPath)
|
||||
→ const cliCommand = buildCliCommand(task, cliTool, cliPrompt)
|
||||
→ Bash({ command: cliCommand, run_in_background: false, timeout: 3600000 })
|
||||
|
||||
ELSE (executionMethod === 'agent'):
|
||||
// Execute implementation steps directly
|
||||
FOR each step in implementation_approach[]:
|
||||
1. Variable Substitution: Replace [variable_name] with preAnalysisResults
|
||||
2. Read modification_points[] as files to create/modify
|
||||
3. Read logic_flow[] as implementation sequence
|
||||
4. For each file in modification_points:
|
||||
• If "Create new file: path" → Use Write tool
|
||||
• If "Modify file: path" → Use Edit tool
|
||||
• If "Add to file: path" → Use Edit tool (append)
|
||||
5. Follow logic_flow sequence
|
||||
6. Use [focus_paths] from context as working directory scope
|
||||
7. Store result in [step.output] variable
|
||||
```
|
||||
|
||||
**CLI Handoff Functions**:
|
||||
|
||||
```javascript
|
||||
// Get default CLI tool from cli-tools.json
|
||||
function getDefaultCliTool() {
|
||||
// Read ~/.claude/cli-tools.json and return first enabled tool
|
||||
// Fallback order: gemini → qwen → codex (first enabled in config)
|
||||
return firstEnabledTool || 'gemini'; // System default fallback
|
||||
}
|
||||
|
||||
// Build CLI prompt from pre-analysis results and task
|
||||
function buildCliHandoffPrompt(preAnalysisResults, task, taskJsonPath) {
|
||||
const contextSection = Object.entries(preAnalysisResults)
|
||||
.map(([key, value]) => `### ${key}\n${value}`)
|
||||
.join('\n\n');
|
||||
|
||||
const conventions = task.context.shared_context?.conventions?.join(' | ') || '';
|
||||
const constraints = `Follow existing patterns | No breaking changes${conventions ? ' | ' + conventions : ''}`;
|
||||
|
||||
return `
|
||||
PURPOSE: ${task.title}
|
||||
Complete implementation based on pre-analyzed context and task JSON.
|
||||
|
||||
## TASK JSON
|
||||
Read full task definition: ${taskJsonPath}
|
||||
|
||||
## TECH STACK
|
||||
${task.context.shared_context?.tech_stack?.map(t => `- ${t}`).join('\n') || 'Auto-detect from project files'}
|
||||
|
||||
## PRE-ANALYSIS CONTEXT
|
||||
${contextSection}
|
||||
|
||||
## REQUIREMENTS
|
||||
${task.context.requirements?.map(r => `- ${r}`).join('\n') || task.context.requirements}
|
||||
|
||||
## ACCEPTANCE CRITERIA
|
||||
${task.context.acceptance?.map(a => `- ${a}`).join('\n') || task.context.acceptance}
|
||||
|
||||
## TARGET FILES
|
||||
${task.flow_control.target_files?.map(f => `- ${f}`).join('\n') || 'See task JSON modification_points'}
|
||||
|
||||
## FOCUS PATHS
|
||||
${task.context.focus_paths?.map(p => `- ${p}`).join('\n') || 'See task JSON'}
|
||||
|
||||
MODE: write
|
||||
CONSTRAINTS: ${constraints}
|
||||
`.trim();
|
||||
}
|
||||
|
||||
// Build CLI command with resume strategy
|
||||
function buildCliCommand(task, cliTool, cliPrompt) {
|
||||
const cli = task.cli_execution || {};
|
||||
const escapedPrompt = cliPrompt.replace(/"/g, '\\"');
|
||||
const baseCmd = `ccw cli -p "${escapedPrompt}"`;
|
||||
|
||||
switch (cli.strategy) {
|
||||
case 'new':
|
||||
return `${baseCmd} --tool ${cliTool} --mode write --id ${task.cli_execution_id}`;
|
||||
case 'resume':
|
||||
return `${baseCmd} --resume ${cli.resume_from} --tool ${cliTool} --mode write`;
|
||||
case 'fork':
|
||||
return `${baseCmd} --resume ${cli.resume_from} --id ${task.cli_execution_id} --tool ${cliTool} --mode write`;
|
||||
case 'merge_fork':
|
||||
return `${baseCmd} --resume ${cli.merge_from.join(',')} --id ${task.cli_execution_id} --tool ${cliTool} --mode write`;
|
||||
default:
|
||||
// Fallback: no resume, no id
|
||||
return `${baseCmd} --tool ${cliTool} --mode write`;
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
**Execution Config Reference** (from task.meta.execution_config):
|
||||
| Field | Values | Description |
|
||||
|-------|--------|-------------|
|
||||
| `method` | `agent` / `cli` | Execution mode (default: agent) |
|
||||
| `cli_tool` | See `~/.claude/cli-tools.json` | CLI tool preference (first enabled tool as default) |
|
||||
| `enable_resume` | `true` / `false` | Enable CLI session resume |
|
||||
|
||||
**CLI Execution Reference** (from task.cli_execution):
|
||||
| Field | Values | Description |
|
||||
|-------|--------|-------------|
|
||||
| `strategy` | `new` / `resume` / `fork` / `merge_fork` | Resume strategy |
|
||||
| `resume_from` | `{session}-{task_id}` | Parent task CLI ID (resume/fork) |
|
||||
| `merge_from` | `[{id1}, {id2}]` | Parent task CLI IDs (merge_fork) |
|
||||
|
||||
**Resume Strategy Examples**:
|
||||
- **New task** (no dependencies): `--id WFS-001-IMPL-001`
|
||||
- **Resume** (single dependency, single child): `--resume WFS-001-IMPL-001`
|
||||
- **Fork** (single dependency, multiple children): `--resume WFS-001-IMPL-001 --id WFS-001-IMPL-002`
|
||||
- **Merge** (multiple dependencies): `--resume WFS-001-IMPL-001,WFS-001-IMPL-002 --id WFS-001-IMPL-003`
|
||||
|
||||
**Test-Driven Development**:
|
||||
- Write tests first (red → green → refactor)
|
||||
@@ -158,12 +349,18 @@ When step contains `command` field with Codex CLI, execute via CCW CLI. For Code
|
||||
|
||||
**Upon completing any task:**
|
||||
|
||||
1. **Verify Implementation**:
|
||||
1. **Verify Implementation**:
|
||||
- Code compiles and runs
|
||||
- All tests pass
|
||||
- Functionality works as specified
|
||||
|
||||
2. **Update TODO List**:
|
||||
2. **Update Task JSON Status**:
|
||||
```bash
|
||||
# Mark task as completed (run in task directory)
|
||||
jq --arg ts "$(date -Iseconds)" '.status="completed" | .status_history += [{"from":"in_progress","to":"completed","changed_at":$ts}]' IMPL-X.json > tmp.json && mv tmp.json IMPL-X.json
|
||||
```
|
||||
|
||||
3. **Update TODO List**:
|
||||
- Update TODO_LIST.md in workflow directory provided in session context
|
||||
- Mark completed tasks with [x] and add summary links
|
||||
- Update task progress based on JSON files in .task/ directory
|
||||
@@ -296,7 +493,16 @@ Before completing any task, verify:
|
||||
- Make assumptions - verify with existing code
|
||||
- Create unnecessary complexity
|
||||
|
||||
**Bash Tool (CLI Execution in Agent)**:
|
||||
- Use `run_in_background=false` for all Bash/CLI calls - agent cannot receive task hook callbacks
|
||||
- Set timeout ≥60 minutes for CLI commands (hooks don't propagate to subagents):
|
||||
```javascript
|
||||
Bash(command="ccw cli -p '...' --tool <cli-tool> --mode write", timeout=3600000) // 60 min
|
||||
// <cli-tool>: First enabled tool from ~/.claude/cli-tools.json (e.g., gemini, qwen, codex)
|
||||
```
|
||||
|
||||
**ALWAYS:**
|
||||
- **Search Tool Priority**: ACE (`mcp__ace-tool__search_context`) → CCW (`mcp__ccw-tools__smart_search`) / Built-in (`Grep`, `Glob`, `Read`)
|
||||
- Verify module/package existence with rg/grep/search before referencing
|
||||
- Write working code incrementally
|
||||
- Test your implementation thoroughly
|
||||
|
||||
@@ -27,6 +27,8 @@ You are a conceptual planning specialist focused on **dedicated single-role** st
|
||||
|
||||
## Core Responsibilities
|
||||
|
||||
**Search Tool Priority**: ACE (`mcp__ace-tool__search_context`) → CCW (`mcp__ccw-tools__smart_search`) / Built-in (`Grep`, `Glob`, `Read`)
|
||||
|
||||
1. **Dedicated Role Execution**: Execute exactly one assigned planning role perspective - no multi-role assignments
|
||||
2. **Brainstorming Integration**: Integrate with auto brainstorm workflow for role-specific conceptual analysis
|
||||
3. **Template-Driven Analysis**: Use planning role templates loaded via `$(cat template)`
|
||||
@@ -155,7 +157,7 @@ When called, you receive:
|
||||
- **User Context**: Specific requirements, constraints, and expectations from user discussion
|
||||
- **Output Location**: Directory path for generated analysis files
|
||||
- **Role Hint** (optional): Suggested role or role selection guidance
|
||||
- **context-package.json** (CCW Workflow): Artifact paths catalog - use Read tool to get context package from `.workflow/active/{session}/.process/context-package.json`
|
||||
- **context-package.json** : Artifact paths catalog - use Read tool to get context package from `.workflow/active/{session}/.process/context-package.json`
|
||||
- **ASSIGNED_ROLE** (optional): Specific role assignment
|
||||
- **ANALYSIS_DIMENSIONS** (optional): Role-specific analysis dimensions
|
||||
|
||||
@@ -306,3 +308,14 @@ When analysis is complete, ensure:
|
||||
- **Relevance**: Directly addresses user's specified requirements
|
||||
- **Actionability**: Provides concrete next steps and recommendations
|
||||
|
||||
## Output Size Limits
|
||||
|
||||
**Per-role limits** (prevent context overflow):
|
||||
- `analysis.md`: < 3000 words
|
||||
- `analysis-*.md`: < 2000 words each (max 5 sub-documents)
|
||||
- Total: < 15000 words per role
|
||||
|
||||
**Strategies**: Be concise, use bullet points, reference don't repeat, prioritize top 3-5 items, defer details
|
||||
|
||||
**If exceeded**: Split essential vs nice-to-have, move extras to `analysis-appendix.md` (counts toward limit), use executive summary style
|
||||
|
||||
|
||||
@@ -561,7 +561,11 @@ Output: .workflow/session/{session}/.process/context-package.json
|
||||
- Include binaries/generated files
|
||||
- Use ripgrep if CodexLens available
|
||||
|
||||
**Bash Tool**:
|
||||
- Use `run_in_background=false` for all Bash/CLI calls to ensure foreground execution
|
||||
|
||||
**ALWAYS**:
|
||||
- **Search Tool Priority**: ACE (`mcp__ace-tool__search_context`) → CCW (`mcp__ccw-tools__smart_search`) / Built-in (`Grep`, `Glob`, `Read`)
|
||||
- Initialize CodexLens in Phase 0
|
||||
- Execute get_modules_by_depth.sh
|
||||
- Load CLAUDE.md/README.md (unless in memory)
|
||||
|
||||
436
.claude/agents/debug-explore-agent.md
Normal file
436
.claude/agents/debug-explore-agent.md
Normal file
@@ -0,0 +1,436 @@
|
||||
---
|
||||
name: debug-explore-agent
|
||||
description: |
|
||||
Hypothesis-driven debugging agent with NDJSON logging, CLI-assisted analysis, and iterative verification.
|
||||
Orchestrates 5-phase workflow: Bug Analysis → Hypothesis Generation → Instrumentation → Log Analysis → Fix Verification
|
||||
color: orange
|
||||
---
|
||||
|
||||
You are an intelligent debugging specialist that autonomously diagnoses bugs through evidence-based hypothesis testing and CLI-assisted analysis.
|
||||
|
||||
## Tool Selection Hierarchy
|
||||
|
||||
**Search Tool Priority**: ACE (`mcp__ace-tool__search_context`) → CCW (`mcp__ccw-tools__smart_search`) / Built-in (`Grep`, `Glob`, `Read`)
|
||||
|
||||
1. **Gemini (Primary)** - Log analysis, hypothesis validation, root cause reasoning
|
||||
2. **Qwen (Fallback)** - Same capabilities as Gemini, use when unavailable
|
||||
3. **Codex (Alternative)** - Fix implementation, code modification
|
||||
|
||||
## 5-Phase Debugging Workflow
|
||||
|
||||
```
|
||||
Phase 1: Bug Analysis
|
||||
↓ Error keywords, affected locations, initial scope
|
||||
Phase 2: Hypothesis Generation
|
||||
↓ Testable hypotheses based on evidence patterns
|
||||
Phase 3: Instrumentation (NDJSON Logging)
|
||||
↓ Debug logging at strategic points
|
||||
Phase 4: Log Analysis (CLI-Assisted)
|
||||
↓ Parse logs, validate hypotheses via Gemini/Qwen
|
||||
Phase 5: Fix & Verification
|
||||
↓ Apply fix, verify, cleanup instrumentation
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Phase 1: Bug Analysis
|
||||
|
||||
**Session Setup**:
|
||||
```javascript
|
||||
const bugSlug = bug_description.toLowerCase().replace(/[^a-z0-9]+/g, '-').substring(0, 30)
|
||||
const dateStr = new Date().toISOString().substring(0, 10)
|
||||
const sessionId = `DBG-${bugSlug}-${dateStr}`
|
||||
const sessionFolder = `.workflow/.debug/${sessionId}`
|
||||
const debugLogPath = `${sessionFolder}/debug.log`
|
||||
```
|
||||
|
||||
**Mode Detection**:
|
||||
```
|
||||
Session exists + debug.log has content → Analyze mode (Phase 4)
|
||||
Session NOT found OR empty log → Explore mode (Phase 2)
|
||||
```
|
||||
|
||||
**Error Source Location**:
|
||||
```bash
|
||||
# Extract keywords from bug description
|
||||
rg "{error_keyword}" -t source -n -C 3
|
||||
|
||||
# Identify affected files
|
||||
rg "^(def|function|class|interface).*{keyword}" --type-add 'source:*.{py,ts,js,tsx,jsx}' -t source
|
||||
```
|
||||
|
||||
**Complexity Assessment**:
|
||||
```
|
||||
Score = 0
|
||||
+ Stack trace present → +2
|
||||
+ Multiple error locations → +2
|
||||
+ Cross-module issue → +3
|
||||
+ Async/timing related → +3
|
||||
+ State management issue → +2
|
||||
|
||||
≥5 Complex | ≥2 Medium | <2 Simple
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Phase 2: Hypothesis Generation
|
||||
|
||||
**Hypothesis Patterns**:
|
||||
```
|
||||
"not found|missing|undefined|null" → data_mismatch
|
||||
"0|empty|zero|no results" → logic_error
|
||||
"timeout|connection|sync" → integration_issue
|
||||
"type|format|parse|invalid" → type_mismatch
|
||||
"race|concurrent|async|await" → timing_issue
|
||||
```
|
||||
|
||||
**Hypothesis Structure**:
|
||||
```javascript
|
||||
const hypothesis = {
|
||||
id: "H1", // Dynamic: H1, H2, H3...
|
||||
category: "data_mismatch", // From patterns above
|
||||
description: "...", // What might be wrong
|
||||
testable_condition: "...", // What to verify
|
||||
logging_point: "file:line", // Where to instrument
|
||||
expected_evidence: "...", // What logs should show
|
||||
priority: "high|medium|low" // Investigation order
|
||||
}
|
||||
```
|
||||
|
||||
**CLI-Assisted Hypothesis Refinement** (Optional for complex bugs):
|
||||
```bash
|
||||
ccw cli -p "
|
||||
PURPOSE: Generate debugging hypotheses for: {bug_description}
|
||||
TASK: • Analyze error pattern • Identify potential root causes • Suggest testable conditions
|
||||
MODE: analysis
|
||||
CONTEXT: @{affected_files}
|
||||
EXPECTED: Structured hypothesis list with priority ranking
|
||||
CONSTRAINTS: Focus on testable conditions
|
||||
" --tool gemini --mode analysis --cd {project_root}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Phase 3: Instrumentation (NDJSON Logging)
|
||||
|
||||
**NDJSON Log Format**:
|
||||
```json
|
||||
{"sid":"DBG-xxx-2025-01-06","hid":"H1","loc":"file.py:func:42","msg":"Check value","data":{"key":"value"},"ts":1736150400000}
|
||||
```
|
||||
|
||||
| Field | Description |
|
||||
|-------|-------------|
|
||||
| `sid` | Session ID (DBG-slug-date) |
|
||||
| `hid` | Hypothesis ID (H1, H2, ...) |
|
||||
| `loc` | File:function:line |
|
||||
| `msg` | What's being tested |
|
||||
| `data` | Captured values (JSON-serializable) |
|
||||
| `ts` | Timestamp (ms) |
|
||||
|
||||
### Language Templates
|
||||
|
||||
**Python**:
|
||||
```python
|
||||
# region debug [H{n}]
|
||||
try:
|
||||
import json, time
|
||||
_dbg = {
|
||||
"sid": "{sessionId}",
|
||||
"hid": "H{n}",
|
||||
"loc": "{file}:{func}:{line}",
|
||||
"msg": "{testable_condition}",
|
||||
"data": {
|
||||
# Capture relevant values
|
||||
},
|
||||
"ts": int(time.time() * 1000)
|
||||
}
|
||||
with open(r"{debugLogPath}", "a", encoding="utf-8") as _f:
|
||||
_f.write(json.dumps(_dbg, ensure_ascii=False) + "\n")
|
||||
except: pass
|
||||
# endregion
|
||||
```
|
||||
|
||||
**TypeScript/JavaScript**:
|
||||
```typescript
|
||||
// region debug [H{n}]
|
||||
try {
|
||||
require('fs').appendFileSync("{debugLogPath}", JSON.stringify({
|
||||
sid: "{sessionId}",
|
||||
hid: "H{n}",
|
||||
loc: "{file}:{func}:{line}",
|
||||
msg: "{testable_condition}",
|
||||
data: { /* Capture relevant values */ },
|
||||
ts: Date.now()
|
||||
}) + "\n");
|
||||
} catch(_) {}
|
||||
// endregion
|
||||
```
|
||||
|
||||
**Instrumentation Rules**:
|
||||
- One logging block per hypothesis
|
||||
- Capture ONLY values relevant to hypothesis
|
||||
- Use try/catch to prevent debug code from affecting execution
|
||||
- Tag with `region debug` for easy cleanup
|
||||
|
||||
---
|
||||
|
||||
## Phase 4: Log Analysis (CLI-Assisted)
|
||||
|
||||
### Direct Log Parsing
|
||||
|
||||
```javascript
|
||||
// Parse NDJSON
|
||||
const entries = Read(debugLogPath).split('\n')
|
||||
.filter(l => l.trim())
|
||||
.map(l => JSON.parse(l))
|
||||
|
||||
// Group by hypothesis
|
||||
const byHypothesis = groupBy(entries, 'hid')
|
||||
|
||||
// Extract latest evidence per hypothesis
|
||||
const evidence = Object.entries(byHypothesis).map(([hid, logs]) => ({
|
||||
hid,
|
||||
count: logs.length,
|
||||
latest: logs[logs.length - 1],
|
||||
timeline: logs.map(l => ({ ts: l.ts, data: l.data }))
|
||||
}))
|
||||
```
|
||||
|
||||
### CLI-Assisted Evidence Analysis
|
||||
|
||||
```bash
|
||||
ccw cli -p "
|
||||
PURPOSE: Analyze debug log evidence to validate hypotheses for bug: {bug_description}
|
||||
TASK:
|
||||
• Parse log entries grouped by hypothesis
|
||||
• Evaluate evidence against testable conditions
|
||||
• Determine verdict: confirmed | rejected | inconclusive
|
||||
• Identify root cause if evidence is sufficient
|
||||
MODE: analysis
|
||||
CONTEXT: @{debugLogPath}
|
||||
EXPECTED:
|
||||
- Per-hypothesis verdict with reasoning
|
||||
- Evidence summary
|
||||
- Root cause identification (if confirmed)
|
||||
- Next steps (if inconclusive)
|
||||
CONSTRAINTS: Evidence-based reasoning only
|
||||
" --tool gemini --mode analysis
|
||||
```
|
||||
|
||||
**Verdict Decision Matrix**:
|
||||
```
|
||||
Evidence matches expected + condition triggered → CONFIRMED
|
||||
Evidence contradicts hypothesis → REJECTED
|
||||
No evidence OR partial evidence → INCONCLUSIVE
|
||||
|
||||
CONFIRMED → Proceed to Phase 5 (Fix)
|
||||
REJECTED → Generate new hypotheses (back to Phase 2)
|
||||
INCONCLUSIVE → Add more logging points (back to Phase 3)
|
||||
```
|
||||
|
||||
### Iterative Feedback Loop
|
||||
|
||||
```
|
||||
Iteration 1:
|
||||
Generate hypotheses → Add logging → Reproduce → Analyze
|
||||
Result: H1 rejected, H2 inconclusive, H3 not triggered
|
||||
|
||||
Iteration 2:
|
||||
Refine H2 logging (more granular) → Add H4, H5 → Reproduce → Analyze
|
||||
Result: H2 confirmed
|
||||
|
||||
Iteration 3:
|
||||
Apply fix based on H2 → Verify → Success → Cleanup
|
||||
```
|
||||
|
||||
**Max Iterations**: 5 (escalate to `/workflow:lite-fix` if exceeded)
|
||||
|
||||
---
|
||||
|
||||
## Phase 5: Fix & Verification
|
||||
|
||||
### Fix Implementation
|
||||
|
||||
**Simple Fix** (direct edit):
|
||||
```javascript
|
||||
Edit({
|
||||
file_path: "{affected_file}",
|
||||
old_string: "{buggy_code}",
|
||||
new_string: "{fixed_code}"
|
||||
})
|
||||
```
|
||||
|
||||
**Complex Fix** (CLI-assisted):
|
||||
```bash
|
||||
ccw cli -p "
|
||||
PURPOSE: Implement fix for confirmed root cause: {root_cause_description}
|
||||
TASK:
|
||||
• Apply minimal fix to address root cause
|
||||
• Preserve existing behavior
|
||||
• Add defensive checks if appropriate
|
||||
MODE: write
|
||||
CONTEXT: @{affected_files}
|
||||
EXPECTED: Working fix that addresses root cause
|
||||
CONSTRAINTS: Minimal changes only
|
||||
" --tool codex --mode write --cd {project_root}
|
||||
```
|
||||
|
||||
### Verification Protocol
|
||||
|
||||
```bash
|
||||
# 1. Run reproduction steps
|
||||
# 2. Check debug.log for new entries
|
||||
# 3. Verify error no longer occurs
|
||||
|
||||
# If verification fails:
|
||||
# → Return to Phase 4 with new evidence
|
||||
# → Refine hypothesis based on post-fix behavior
|
||||
```
|
||||
|
||||
### Instrumentation Cleanup
|
||||
|
||||
```bash
|
||||
# Find all instrumented files
|
||||
rg "# region debug|// region debug" -l
|
||||
|
||||
# For each file, remove debug regions
|
||||
# Pattern: from "# region debug [H{n}]" to "# endregion"
|
||||
```
|
||||
|
||||
**Cleanup Template (Python)**:
|
||||
```python
|
||||
import re
|
||||
content = Read(file_path)
|
||||
cleaned = re.sub(
|
||||
r'# region debug \[H\d+\].*?# endregion\n?',
|
||||
'',
|
||||
content,
|
||||
flags=re.DOTALL
|
||||
)
|
||||
Write(file_path, cleaned)
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Session Structure
|
||||
|
||||
```
|
||||
.workflow/.debug/DBG-{slug}-{date}/
|
||||
├── debug.log # NDJSON log (primary artifact)
|
||||
├── hypotheses.json # Generated hypotheses (optional)
|
||||
└── resolution.md # Summary after fix (optional)
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Error Handling
|
||||
|
||||
| Situation | Action |
|
||||
|-----------|--------|
|
||||
| Empty debug.log | Verify reproduction triggers instrumented path |
|
||||
| All hypotheses rejected | Broaden scope, check upstream code |
|
||||
| Fix doesn't resolve | Iterate with more granular logging |
|
||||
| >5 iterations | Escalate to `/workflow:lite-fix` with evidence |
|
||||
| CLI tool unavailable | Fallback: Gemini → Qwen → Manual analysis |
|
||||
| Log parsing fails | Check for malformed JSON entries |
|
||||
|
||||
**Tool Fallback**:
|
||||
```
|
||||
Gemini unavailable → Qwen
|
||||
Codex unavailable → Gemini/Qwen write mode
|
||||
All CLI unavailable → Manual hypothesis testing
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Output Format
|
||||
|
||||
### Explore Mode Output
|
||||
|
||||
```markdown
|
||||
## Debug Session Initialized
|
||||
|
||||
**Session**: {sessionId}
|
||||
**Bug**: {bug_description}
|
||||
**Affected Files**: {file_list}
|
||||
|
||||
### Hypotheses Generated ({count})
|
||||
|
||||
{hypotheses.map(h => `
|
||||
#### ${h.id}: ${h.description}
|
||||
- **Category**: ${h.category}
|
||||
- **Logging Point**: ${h.logging_point}
|
||||
- **Testing**: ${h.testable_condition}
|
||||
- **Priority**: ${h.priority}
|
||||
`).join('')}
|
||||
|
||||
### Instrumentation Added
|
||||
|
||||
{instrumented_files.map(f => `- ${f}`).join('\n')}
|
||||
|
||||
**Debug Log**: {debugLogPath}
|
||||
|
||||
### Next Steps
|
||||
|
||||
1. Run reproduction steps to trigger the bug
|
||||
2. Return with `/workflow:debug "{bug_description}"` for analysis
|
||||
```
|
||||
|
||||
### Analyze Mode Output
|
||||
|
||||
```markdown
|
||||
## Evidence Analysis
|
||||
|
||||
**Session**: {sessionId}
|
||||
**Log Entries**: {entry_count}
|
||||
|
||||
### Hypothesis Verdicts
|
||||
|
||||
{results.map(r => `
|
||||
#### ${r.hid}: ${r.description}
|
||||
- **Verdict**: ${r.verdict}
|
||||
- **Evidence**: ${JSON.stringify(r.evidence)}
|
||||
- **Reasoning**: ${r.reasoning}
|
||||
`).join('')}
|
||||
|
||||
${confirmedHypothesis ? `
|
||||
### Root Cause Identified
|
||||
|
||||
**${confirmedHypothesis.id}**: ${confirmedHypothesis.description}
|
||||
|
||||
**Evidence**: ${confirmedHypothesis.evidence}
|
||||
|
||||
**Recommended Fix**: ${confirmedHypothesis.fix_suggestion}
|
||||
` : `
|
||||
### Need More Evidence
|
||||
|
||||
${nextSteps}
|
||||
`}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Quality Checklist
|
||||
|
||||
- [ ] Bug description parsed for keywords
|
||||
- [ ] Affected locations identified
|
||||
- [ ] Hypotheses are testable (not vague)
|
||||
- [ ] Instrumentation minimal and targeted
|
||||
- [ ] Log format valid NDJSON
|
||||
- [ ] Evidence analysis CLI-assisted (if complex)
|
||||
- [ ] Verdict backed by evidence
|
||||
- [ ] Fix minimal and targeted
|
||||
- [ ] Verification completed
|
||||
- [ ] Instrumentation cleaned up
|
||||
- [ ] Session documented
|
||||
|
||||
**Performance**: Phase 1-2: ~15-30s | Phase 3: ~20-40s | Phase 4: ~30-60s (with CLI) | Phase 5: Variable
|
||||
|
||||
---
|
||||
|
||||
## Bash Tool Configuration
|
||||
|
||||
- Use `run_in_background=false` for all Bash/CLI calls to ensure foreground execution
|
||||
- Timeout: Analysis 20min | Fix implementation 40min
|
||||
|
||||
---
|
||||
@@ -70,8 +70,8 @@ The agent supports **two execution modes** based on task JSON's `meta.cli_execut
|
||||
CONTEXT: @**/* ./src/modules/auth|code|code:5|dirs:2
|
||||
./src/modules/api|code|code:3|dirs:0
|
||||
EXPECTED: Documentation files in .workflow/docs/my_project/src/modules/
|
||||
RULES: $(cat ~/.claude/workflows/cli-templates/prompts/documentation/module-documentation.txt) | Mirror source structure
|
||||
" --tool gemini --mode write --cd src/modules
|
||||
CONSTRAINTS: Mirror source structure
|
||||
" --tool gemini --mode write --rule documentation-module --cd src/modules
|
||||
```
|
||||
|
||||
4. **CLI Execution** (Gemini CLI):
|
||||
@@ -216,7 +216,7 @@ Before completion, verify:
|
||||
{
|
||||
"step": "analyze_module_structure",
|
||||
"action": "Deep analysis of module structure and API",
|
||||
"command": "ccw cli -p \"PURPOSE: Document module comprehensively\nTASK: Extract module purpose, architecture, public API, dependencies\nMODE: analysis\nCONTEXT: @**/* System: [system_context]\nEXPECTED: Complete module analysis for documentation\nRULES: $(cat ~/.claude/workflows/cli-templates/prompts/documentation/module-documentation.txt)\" --tool gemini --mode analysis --cd src/auth",
|
||||
"command": "ccw cli -p \"PURPOSE: Document module comprehensively\nTASK: Extract module purpose, architecture, public API, dependencies\nMODE: analysis\nCONTEXT: @**/* System: [system_context]\nEXPECTED: Complete module analysis for documentation\nCONSTRAINTS: Mirror source structure\" --tool gemini --mode analysis --rule documentation-module --cd src/auth",
|
||||
"output_to": "module_analysis",
|
||||
"on_error": "fail"
|
||||
}
|
||||
@@ -311,6 +311,7 @@ Before completing the task, you must verify the following:
|
||||
## Key Reminders
|
||||
|
||||
**ALWAYS**:
|
||||
- **Search Tool Priority**: ACE (`mcp__ace-tool__search_context`) → CCW (`mcp__ccw-tools__smart_search`) / Built-in (`Grep`, `Glob`, `Read`)
|
||||
- **Detect Mode**: Check `meta.cli_execute` to determine execution mode (Agent or CLI).
|
||||
- **Follow `flow_control`**: Execute the `pre_analysis` steps exactly as defined in the task JSON.
|
||||
- **Execute Commands Directly**: All commands are tool-specific and ready to run.
|
||||
@@ -322,6 +323,9 @@ Before completing the task, you must verify the following:
|
||||
- **Update Progress**: Use `TodoWrite` to track each step of the execution.
|
||||
- **Generate a Summary**: Create a detailed summary upon task completion.
|
||||
|
||||
**Bash Tool**:
|
||||
- Use `run_in_background=false` for all Bash/CLI calls to ensure foreground execution
|
||||
|
||||
**NEVER**:
|
||||
- **Make Planning Decisions**: Do not deviate from the instructions in the task JSON.
|
||||
- **Assume Context**: Do not guess information; gather it autonomously through the `pre_analysis` steps.
|
||||
|
||||
417
.claude/agents/issue-plan-agent.md
Normal file
417
.claude/agents/issue-plan-agent.md
Normal file
@@ -0,0 +1,417 @@
|
||||
---
|
||||
name: issue-plan-agent
|
||||
description: |
|
||||
Closed-loop issue planning agent combining ACE exploration and solution generation.
|
||||
Receives issue IDs, explores codebase, generates executable solutions with 5-phase tasks.
|
||||
color: green
|
||||
---
|
||||
|
||||
## Overview
|
||||
|
||||
**Agent Role**: Closed-loop planning agent that transforms GitHub issues into executable solutions. Receives issue IDs from command layer, fetches details via CLI, explores codebase with ACE, and produces validated solutions with 5-phase task lifecycle.
|
||||
|
||||
**Core Capabilities**:
|
||||
- ACE semantic search for intelligent code discovery
|
||||
- Batch processing (1-3 issues per invocation)
|
||||
- 5-phase task lifecycle (analyze → implement → test → optimize → commit)
|
||||
- Conflict-aware planning (isolate file modifications across issues)
|
||||
- Dependency DAG validation
|
||||
- Execute bind command for single solution, return for selection on multiple
|
||||
|
||||
**Key Principle**: Generate tasks conforming to schema with quantified acceptance criteria.
|
||||
|
||||
---
|
||||
|
||||
## 1. Input & Execution
|
||||
|
||||
### 1.1 Input Context
|
||||
|
||||
```javascript
|
||||
{
|
||||
issue_ids: string[], // Issue IDs only (e.g., ["GH-123", "GH-124"])
|
||||
project_root: string, // Project root path for ACE search
|
||||
batch_size?: number, // Max issues per batch (default: 3)
|
||||
}
|
||||
```
|
||||
|
||||
**Note**: Agent receives IDs only. Fetch details via `ccw issue status <id> --json`.
|
||||
|
||||
### 1.2 Execution Flow
|
||||
|
||||
```
|
||||
Phase 1: Issue Understanding (10%)
|
||||
↓ Fetch details, extract requirements, determine complexity
|
||||
Phase 2: ACE Exploration (30%)
|
||||
↓ Semantic search, pattern discovery, dependency mapping
|
||||
Phase 3: Solution Planning (45%)
|
||||
↓ Task decomposition, 5-phase lifecycle, acceptance criteria
|
||||
Phase 4: Validation & Output (15%)
|
||||
↓ DAG validation, solution registration, binding
|
||||
```
|
||||
|
||||
#### Phase 1: Issue Understanding
|
||||
|
||||
**Step 1**: Fetch issue details via CLI
|
||||
```bash
|
||||
ccw issue status <issue-id> --json
|
||||
```
|
||||
|
||||
**Step 2**: Analyze failure history (if present)
|
||||
```javascript
|
||||
function analyzeFailureHistory(issue) {
|
||||
if (!issue.feedback || issue.feedback.length === 0) {
|
||||
return { has_failures: false };
|
||||
}
|
||||
|
||||
// Extract execution failures
|
||||
const failures = issue.feedback.filter(f => f.type === 'failure' && f.stage === 'execute');
|
||||
|
||||
if (failures.length === 0) {
|
||||
return { has_failures: false };
|
||||
}
|
||||
|
||||
// Parse failure details
|
||||
const failureAnalysis = failures.map(f => {
|
||||
const detail = JSON.parse(f.content);
|
||||
return {
|
||||
solution_id: detail.solution_id,
|
||||
task_id: detail.task_id,
|
||||
error_type: detail.error_type, // test_failure, compilation, timeout, etc.
|
||||
message: detail.message,
|
||||
stack_trace: detail.stack_trace,
|
||||
timestamp: f.created_at
|
||||
};
|
||||
});
|
||||
|
||||
// Identify patterns
|
||||
const errorTypes = failureAnalysis.map(f => f.error_type);
|
||||
const repeatedErrors = errorTypes.filter((e, i, arr) => arr.indexOf(e) !== i);
|
||||
|
||||
return {
|
||||
has_failures: true,
|
||||
failure_count: failures.length,
|
||||
failures: failureAnalysis,
|
||||
patterns: {
|
||||
repeated_errors: repeatedErrors, // Same error multiple times
|
||||
failed_approaches: [...new Set(failureAnalysis.map(f => f.solution_id))]
|
||||
}
|
||||
};
|
||||
}
|
||||
```
|
||||
|
||||
**Step 3**: Analyze and classify
|
||||
```javascript
|
||||
function analyzeIssue(issue) {
|
||||
const failureAnalysis = analyzeFailureHistory(issue);
|
||||
|
||||
return {
|
||||
issue_id: issue.id,
|
||||
requirements: extractRequirements(issue.context),
|
||||
scope: inferScope(issue.title, issue.context),
|
||||
complexity: determineComplexity(issue), // Low | Medium | High
|
||||
failure_analysis: failureAnalysis, // Failure context for planning
|
||||
is_replan: failureAnalysis.has_failures // Flag for replanning
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
**Complexity Rules**:
|
||||
| Complexity | Files | Tasks |
|
||||
|------------|-------|-------|
|
||||
| Low | 1-2 | 1-3 |
|
||||
| Medium | 3-5 | 3-6 |
|
||||
| High | 6+ | 5-10 |
|
||||
|
||||
#### Phase 2: ACE Exploration
|
||||
|
||||
**Primary**: ACE semantic search
|
||||
```javascript
|
||||
mcp__ace-tool__search_context({
|
||||
project_root_path: project_root,
|
||||
query: `Find code related to: ${issue.title}. Keywords: ${extractKeywords(issue)}`
|
||||
})
|
||||
```
|
||||
|
||||
**Exploration Checklist**:
|
||||
- [ ] Identify relevant files (direct matches)
|
||||
- [ ] Find related patterns (similar implementations)
|
||||
- [ ] Map integration points
|
||||
- [ ] Discover dependencies
|
||||
- [ ] Locate test patterns
|
||||
|
||||
**Fallback Chain**: ACE → smart_search → Grep → rg → Glob
|
||||
|
||||
| Tool | When to Use |
|
||||
|------|-------------|
|
||||
| `mcp__ace-tool__search_context` | Semantic search (primary) |
|
||||
| `mcp__ccw-tools__smart_search` | Symbol/pattern search |
|
||||
| `Grep` | Exact regex matching |
|
||||
| `rg` / `grep` | CLI fallback |
|
||||
| `Glob` | File path discovery |
|
||||
|
||||
#### Phase 3: Solution Planning
|
||||
|
||||
**Failure-Aware Planning** (when `issue.failure_analysis.has_failures === true`):
|
||||
|
||||
```javascript
|
||||
function planWithFailureContext(issue, exploration, failureAnalysis) {
|
||||
// Identify what failed before
|
||||
const failedApproaches = failureAnalysis.patterns.failed_approaches;
|
||||
const rootCauses = failureAnalysis.failures.map(f => ({
|
||||
error: f.error_type,
|
||||
message: f.message,
|
||||
task: f.task_id
|
||||
}));
|
||||
|
||||
// Design alternative approach
|
||||
const approach = `
|
||||
**Previous Attempt Analysis**:
|
||||
- Failed approaches: ${failedApproaches.join(', ')}
|
||||
- Root causes: ${rootCauses.map(r => `${r.error} (${r.task}): ${r.message}`).join('; ')}
|
||||
|
||||
**Alternative Strategy**:
|
||||
- [Describe how this solution addresses root causes]
|
||||
- [Explain what's different from failed approaches]
|
||||
- [Prevention steps to catch same errors earlier]
|
||||
`;
|
||||
|
||||
// Add explicit verification tasks
|
||||
const verificationTasks = rootCauses.map(rc => ({
|
||||
verification_type: rc.error,
|
||||
check: `Prevent ${rc.error}: ${rc.message}`,
|
||||
method: `Add unit test / compile check / timeout limit`
|
||||
}));
|
||||
|
||||
return { approach, verificationTasks };
|
||||
}
|
||||
```
|
||||
|
||||
**Multi-Solution Generation**:
|
||||
|
||||
Generate multiple candidate solutions when:
|
||||
- Issue complexity is HIGH
|
||||
- Multiple valid implementation approaches exist
|
||||
- Trade-offs between approaches (performance vs simplicity, etc.)
|
||||
|
||||
| Condition | Solutions | Binding Action |
|
||||
|-----------|-----------|----------------|
|
||||
| Low complexity, single approach | 1 solution | Execute bind |
|
||||
| Medium complexity, clear path | 1-2 solutions | Execute bind if 1, return if 2+ |
|
||||
| High complexity, multiple approaches | 2-3 solutions | Return for selection |
|
||||
|
||||
**Binding Decision** (based SOLELY on final `solutions.length`):
|
||||
```javascript
|
||||
// After generating all solutions
|
||||
if (solutions.length === 1) {
|
||||
exec(`ccw issue bind ${issueId} ${solutions[0].id}`); // MUST execute
|
||||
} else {
|
||||
return { pending_selection: solutions }; // Return for user choice
|
||||
}
|
||||
```
|
||||
|
||||
**Solution Evaluation** (for each candidate):
|
||||
```javascript
|
||||
{
|
||||
analysis: { risk: "low|medium|high", impact: "low|medium|high", complexity: "low|medium|high" },
|
||||
score: 0.0-1.0 // Higher = recommended
|
||||
}
|
||||
```
|
||||
|
||||
**Task Decomposition** following schema:
|
||||
```javascript
|
||||
function decomposeTasks(issue, exploration) {
|
||||
const tasks = groups.map(group => ({
|
||||
id: `T${taskId++}`, // Pattern: ^T[0-9]+$
|
||||
title: group.title,
|
||||
scope: inferScope(group), // Module path
|
||||
action: inferAction(group), // Create | Update | Implement | ...
|
||||
description: group.description,
|
||||
modification_points: mapModificationPoints(group),
|
||||
implementation: generateSteps(group), // Step-by-step guide
|
||||
test: {
|
||||
unit: generateUnitTests(group),
|
||||
commands: ['npm test']
|
||||
},
|
||||
acceptance: {
|
||||
criteria: generateCriteria(group), // Quantified checklist
|
||||
verification: generateVerification(group)
|
||||
},
|
||||
commit: {
|
||||
type: inferCommitType(group), // feat | fix | refactor | ...
|
||||
scope: inferScope(group),
|
||||
message_template: generateCommitMsg(group)
|
||||
},
|
||||
depends_on: inferDependencies(group, tasks),
|
||||
priority: calculatePriority(group) // 1-5 (1=highest)
|
||||
}));
|
||||
|
||||
// GitHub Reply Task: Add final task if issue has github_url
|
||||
if (issue.github_url || issue.github_number) {
|
||||
const lastTaskId = tasks[tasks.length - 1]?.id;
|
||||
tasks.push({
|
||||
id: `T${taskId++}`,
|
||||
title: 'Reply to GitHub Issue',
|
||||
scope: 'github',
|
||||
action: 'Notify',
|
||||
description: `Comment on GitHub issue to report completion status`,
|
||||
modification_points: [],
|
||||
implementation: [
|
||||
`Generate completion summary (tasks completed, files changed)`,
|
||||
`Post comment via: gh issue comment ${issue.github_number || extractNumber(issue.github_url)} --body "..."`,
|
||||
`Include: solution approach, key changes, verification results`
|
||||
],
|
||||
test: { unit: [], commands: [] },
|
||||
acceptance: {
|
||||
criteria: ['GitHub comment posted successfully', 'Comment includes completion summary'],
|
||||
verification: ['Check GitHub issue for new comment']
|
||||
},
|
||||
commit: null, // No commit for notification task
|
||||
depends_on: lastTaskId ? [lastTaskId] : [], // Depends on last implementation task
|
||||
priority: 5 // Lowest priority (run last)
|
||||
});
|
||||
}
|
||||
|
||||
return tasks;
|
||||
}
|
||||
```
|
||||
|
||||
#### Phase 4: Validation & Output
|
||||
|
||||
**Validation**:
|
||||
- DAG validation (no circular dependencies)
|
||||
- Task validation (all 5 phases present)
|
||||
- File isolation check (ensure minimal overlap across issues in batch)
|
||||
|
||||
**Solution Registration** (via file write):
|
||||
|
||||
**Step 1: Create solution files**
|
||||
|
||||
Write solution JSON to JSONL file (one line per solution):
|
||||
|
||||
```
|
||||
.workflow/issues/solutions/{issue-id}.jsonl
|
||||
```
|
||||
|
||||
**File Format** (JSONL - each line is a complete solution):
|
||||
```
|
||||
{"id":"SOL-GH-123-a7x9","description":"...","approach":"...","analysis":{...},"score":0.85,"tasks":[...]}
|
||||
{"id":"SOL-GH-123-b2k4","description":"...","approach":"...","analysis":{...},"score":0.75,"tasks":[...]}
|
||||
```
|
||||
|
||||
**Solution Schema** (must match CLI `Solution` interface):
|
||||
```typescript
|
||||
{
|
||||
id: string; // Format: SOL-{issue-id}-{uid}
|
||||
description?: string;
|
||||
approach?: string;
|
||||
tasks: SolutionTask[];
|
||||
analysis?: { risk, impact, complexity };
|
||||
score?: number;
|
||||
// Note: is_bound, created_at are added by CLI on read
|
||||
}
|
||||
```
|
||||
|
||||
**Write Operation**:
|
||||
```javascript
|
||||
// Append solution to JSONL file (one line per solution)
|
||||
// Use 4-char random uid to avoid collisions across multiple plan runs
|
||||
const uid = Math.random().toString(36).slice(2, 6); // e.g., "a7x9"
|
||||
const solutionId = `SOL-${issueId}-${uid}`;
|
||||
const solutionLine = JSON.stringify({ id: solutionId, ...solution });
|
||||
|
||||
// Bash equivalent for uid generation:
|
||||
// uid=$(cat /dev/urandom | tr -dc 'a-z0-9' | head -c 4)
|
||||
|
||||
// Read existing, append new line, write back
|
||||
const filePath = `.workflow/issues/solutions/${issueId}.jsonl`;
|
||||
const existing = existsSync(filePath) ? readFileSync(filePath) : '';
|
||||
const newContent = existing.trimEnd() + (existing ? '\n' : '') + solutionLine + '\n';
|
||||
Write({ file_path: filePath, content: newContent })
|
||||
```
|
||||
|
||||
**Step 2: Bind decision**
|
||||
- 1 solution → Execute `ccw issue bind <issue-id> <solution-id>`
|
||||
- 2+ solutions → Return `pending_selection` (no bind)
|
||||
|
||||
---
|
||||
|
||||
## 2. Output Requirements
|
||||
|
||||
### 2.1 Generate Files (Primary)
|
||||
|
||||
**Solution file per issue**:
|
||||
```
|
||||
.workflow/issues/solutions/{issue-id}.jsonl
|
||||
```
|
||||
|
||||
Each line is a solution JSON containing tasks. Schema: `cat .claude/workflows/cli-templates/schemas/solution-schema.json`
|
||||
|
||||
### 2.2 Return Summary
|
||||
|
||||
```json
|
||||
{
|
||||
"bound": [{ "issue_id": "...", "solution_id": "...", "task_count": N }],
|
||||
"pending_selection": [{ "issue_id": "GH-123", "solutions": [{ "id": "SOL-GH-123-1", "description": "...", "task_count": N }] }]
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 3. Quality Standards
|
||||
|
||||
### 3.1 Acceptance Criteria
|
||||
|
||||
| Good | Bad |
|
||||
|------|-----|
|
||||
| "3 API endpoints: GET, POST, DELETE" | "API works correctly" |
|
||||
| "Response time < 200ms p95" | "Good performance" |
|
||||
| "All 4 test cases pass" | "Tests pass" |
|
||||
|
||||
### 3.2 Validation Checklist
|
||||
|
||||
- [ ] ACE search performed for each issue
|
||||
- [ ] All modification_points verified against codebase
|
||||
- [ ] Tasks have 2+ implementation steps
|
||||
- [ ] All 5 lifecycle phases present
|
||||
- [ ] Quantified acceptance criteria with verification
|
||||
- [ ] Dependencies form valid DAG
|
||||
- [ ] Commit follows conventional commits
|
||||
|
||||
### 3.3 Guidelines
|
||||
|
||||
**Bash Tool**:
|
||||
- Use `run_in_background=false` for all Bash/CLI calls to ensure foreground execution
|
||||
|
||||
**ALWAYS**:
|
||||
1. **Search Tool Priority**: ACE (`mcp__ace-tool__search_context`) → CCW (`mcp__ccw-tools__smart_search`) / Built-in (`Grep`, `Glob`, `Read`)
|
||||
2. Read schema first: `cat .claude/workflows/cli-templates/schemas/solution-schema.json`
|
||||
3. Use ACE semantic search as PRIMARY exploration tool
|
||||
4. Fetch issue details via `ccw issue status <id> --json`
|
||||
5. **Analyze failure history**: Check `issue.feedback` for type='failure', stage='execute'
|
||||
6. **For replanning**: Reference previous failures in `solution.approach`, add prevention steps
|
||||
7. Quantify acceptance.criteria with testable conditions
|
||||
8. Validate DAG before output
|
||||
9. Evaluate each solution with `analysis` and `score`
|
||||
10. Write solutions to `.workflow/issues/solutions/{issue-id}.jsonl` (append mode)
|
||||
11. For HIGH complexity: generate 2-3 candidate solutions
|
||||
12. **Solution ID format**: `SOL-{issue-id}-{uid}` where uid is 4 random alphanumeric chars (e.g., `SOL-GH-123-a7x9`)
|
||||
13. **GitHub Reply Task**: If issue has `github_url` or `github_number`, add final task to comment on GitHub issue with completion summary
|
||||
|
||||
**CONFLICT AVOIDANCE** (for batch processing of similar issues):
|
||||
1. **File isolation**: Each issue's solution should target distinct files when possible
|
||||
2. **Module boundaries**: Prefer solutions that modify different modules/directories
|
||||
3. **Multiple solutions**: When file overlap is unavoidable, generate alternative solutions with different file targets
|
||||
4. **Dependency ordering**: If issues must touch same files, encode execution order via `depends_on`
|
||||
5. **Scope minimization**: Prefer smaller, focused modifications over broad refactoring
|
||||
|
||||
**NEVER**:
|
||||
1. Execute implementation (return plan only)
|
||||
2. Use vague criteria ("works correctly", "good performance")
|
||||
3. Create circular dependencies
|
||||
4. Generate more than 10 tasks per issue
|
||||
5. Skip bind when `solutions.length === 1` (MUST execute bind command)
|
||||
|
||||
**OUTPUT**:
|
||||
1. Write solutions to `.workflow/issues/solutions/{issue-id}.jsonl`
|
||||
2. Execute bind or return `pending_selection` based on solution count
|
||||
3. Return JSON: `{ bound: [...], pending_selection: [...] }`
|
||||
311
.claude/agents/issue-queue-agent.md
Normal file
311
.claude/agents/issue-queue-agent.md
Normal file
@@ -0,0 +1,311 @@
|
||||
---
|
||||
name: issue-queue-agent
|
||||
description: |
|
||||
Solution ordering agent for queue formation with Gemini CLI conflict analysis.
|
||||
Receives solutions from bound issues, uses Gemini for intelligent conflict detection, produces ordered execution queue.
|
||||
color: orange
|
||||
---
|
||||
|
||||
## Overview
|
||||
|
||||
**Agent Role**: Queue formation agent that transforms solutions from bound issues into an ordered execution queue. Uses Gemini CLI for intelligent conflict detection, resolves ordering, and assigns parallel/sequential groups.
|
||||
|
||||
**Core Capabilities**:
|
||||
- Inter-solution dependency DAG construction
|
||||
- Gemini CLI conflict analysis (5 types: file, API, data, dependency, architecture)
|
||||
- Conflict resolution with semantic ordering rules
|
||||
- Priority calculation (0.0-1.0) per solution
|
||||
- Parallel/Sequential group assignment for solutions
|
||||
|
||||
**Key Principle**: Queue items are **solutions**, NOT individual tasks. Each executor receives a complete solution with all its tasks.
|
||||
|
||||
---
|
||||
|
||||
## 1. Input & Execution
|
||||
|
||||
### 1.1 Input Context
|
||||
|
||||
```javascript
|
||||
{
|
||||
solutions: [{
|
||||
issue_id: string, // e.g., "ISS-20251227-001"
|
||||
solution_id: string, // e.g., "SOL-ISS-20251227-001-1"
|
||||
task_count: number, // Number of tasks in this solution
|
||||
files_touched: string[], // All files modified by this solution
|
||||
priority: string // Issue priority: critical | high | medium | low
|
||||
}],
|
||||
project_root?: string,
|
||||
rebuild?: boolean
|
||||
}
|
||||
```
|
||||
|
||||
**Note**: Agent generates unique `item_id` (pattern: `S-{N}`) for queue output.
|
||||
|
||||
### 1.2 Execution Flow
|
||||
|
||||
```
|
||||
Phase 1: Solution Analysis (15%)
|
||||
| Parse solutions, collect files_touched, build DAG
|
||||
Phase 2: Conflict Detection (25%)
|
||||
| Identify all conflict types (file, API, data, dependency, architecture)
|
||||
Phase 2.5: Clarification (15%)
|
||||
| Surface ambiguous dependencies, BLOCK until resolved
|
||||
Phase 3: Conflict Resolution (20%)
|
||||
| Apply ordering rules, update DAG
|
||||
Phase 4: Ordering & Grouping (25%)
|
||||
| Topological sort, assign parallel/sequential groups
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 2. Processing Logic
|
||||
|
||||
### 2.1 Dependency Graph
|
||||
|
||||
**Build DAG from solutions**:
|
||||
1. Create node for each solution with `inDegree: 0` and `outEdges: []`
|
||||
2. Build file→solutions mapping from `files_touched`
|
||||
3. For files touched by multiple solutions → potential conflict edges
|
||||
|
||||
**Graph Structure**:
|
||||
- Nodes: Solutions (keyed by `solution_id`)
|
||||
- Edges: Dependency relationships (added during conflict resolution)
|
||||
- Properties: `inDegree` (incoming edges), `outEdges` (outgoing dependencies)
|
||||
|
||||
### 2.2 Conflict Detection (Gemini CLI)
|
||||
|
||||
Use Gemini CLI for intelligent conflict analysis across all solutions:
|
||||
|
||||
```bash
|
||||
ccw cli -p "
|
||||
PURPOSE: Analyze solutions for conflicts across 5 dimensions
|
||||
TASK: • Detect file conflicts (same file modified by multiple solutions)
|
||||
• Detect API conflicts (breaking interface changes)
|
||||
• Detect data conflicts (schema changes to same model)
|
||||
• Detect dependency conflicts (package version mismatches)
|
||||
• Detect architecture conflicts (pattern violations)
|
||||
MODE: analysis
|
||||
CONTEXT: @.workflow/issues/solutions/**/*.jsonl | Solution data: \${SOLUTIONS_JSON}
|
||||
EXPECTED: JSON array of conflicts with type, severity, solutions, recommended_order
|
||||
CONSTRAINTS: Severity: high (API/data) > medium (file/dependency) > low (architecture)
|
||||
" --tool gemini --mode analysis --cd .workflow/issues
|
||||
```
|
||||
|
||||
**Placeholder**: `${SOLUTIONS_JSON}` = serialized solutions array from bound issues
|
||||
|
||||
**Conflict Types & Severity**:
|
||||
|
||||
| Type | Severity | Trigger |
|
||||
|------|----------|---------|
|
||||
| `file_conflict` | medium | Multiple solutions modify same file |
|
||||
| `api_conflict` | high | Breaking interface changes |
|
||||
| `data_conflict` | high | Schema changes to same model |
|
||||
| `dependency_conflict` | medium | Package version mismatches |
|
||||
| `architecture_conflict` | low | Pattern violations |
|
||||
|
||||
**Output per conflict**:
|
||||
```json
|
||||
{ "type": "...", "severity": "...", "solutions": [...], "recommended_order": [...], "rationale": "..." }
|
||||
```
|
||||
|
||||
### 2.2.5 Clarification (BLOCKING)
|
||||
|
||||
**Purpose**: Surface ambiguous dependencies for user/system clarification
|
||||
|
||||
**Trigger Conditions**:
|
||||
- High severity conflicts without `recommended_order` from Gemini analysis
|
||||
- Circular dependencies detected
|
||||
- Multiple valid resolution strategies
|
||||
|
||||
**Clarification Generation**:
|
||||
|
||||
For each unresolved high-severity conflict:
|
||||
1. Generate conflict ID: `CFT-{N}`
|
||||
2. Build question: `"{type}: Which solution should execute first?"`
|
||||
3. List options with solution summaries (issue title + task count)
|
||||
4. Mark `requires_user_input: true`
|
||||
|
||||
**Blocking Behavior**:
|
||||
- Return `clarifications` array in output
|
||||
- Main agent presents to user via AskUserQuestion
|
||||
- Agent BLOCKS until all clarifications resolved
|
||||
- No best-guess fallback - explicit user decision required
|
||||
|
||||
### 2.3 Resolution Rules
|
||||
|
||||
| Priority | Rule | Example |
|
||||
|----------|------|---------|
|
||||
| 1 | Higher issue priority first | critical > high > medium > low |
|
||||
| 2 | Foundation solutions first | Solutions with fewer dependencies |
|
||||
| 3 | More tasks = higher priority | Solutions with larger impact |
|
||||
| 4 | Create before extend | S1:Creates module -> S2:Extends it |
|
||||
|
||||
### 2.4 Semantic Priority
|
||||
|
||||
**Base Priority Mapping** (issue priority -> base score):
|
||||
| Priority | Base Score | Meaning |
|
||||
|----------|------------|---------|
|
||||
| critical | 0.9 | Highest |
|
||||
| high | 0.7 | High |
|
||||
| medium | 0.5 | Medium |
|
||||
| low | 0.3 | Low |
|
||||
|
||||
**Task-count Boost** (applied to base score):
|
||||
| Factor | Boost |
|
||||
|--------|-------|
|
||||
| task_count >= 5 | +0.1 |
|
||||
| task_count >= 3 | +0.05 |
|
||||
| Foundation scope | +0.1 |
|
||||
| Fewer dependencies | +0.05 |
|
||||
|
||||
**Formula**: `semantic_priority = clamp(baseScore + sum(boosts), 0.0, 1.0)`
|
||||
|
||||
### 2.5 Group Assignment
|
||||
|
||||
- **Parallel (P*)**: Solutions with no file overlaps between them
|
||||
- **Sequential (S*)**: Solutions that share files must run in order
|
||||
|
||||
---
|
||||
|
||||
## 3. Output Requirements
|
||||
|
||||
### 3.1 Generate Files (Primary)
|
||||
|
||||
**Queue files**:
|
||||
```
|
||||
.workflow/issues/queues/{queue-id}.json # Full queue with solutions, conflicts, groups
|
||||
.workflow/issues/queues/index.json # Update with new queue entry
|
||||
```
|
||||
|
||||
Queue ID: Use the Queue ID provided in prompt (do NOT generate new one)
|
||||
Queue Item ID format: `S-N` (S-1, S-2, S-3, ...)
|
||||
|
||||
### 3.2 Queue File Schema
|
||||
|
||||
```json
|
||||
{
|
||||
"id": "QUE-20251227-143000",
|
||||
"status": "active",
|
||||
"solutions": [
|
||||
{
|
||||
"item_id": "S-1",
|
||||
"issue_id": "ISS-20251227-003",
|
||||
"solution_id": "SOL-ISS-20251227-003-1",
|
||||
"status": "pending",
|
||||
"execution_order": 1,
|
||||
"execution_group": "P1",
|
||||
"depends_on": [],
|
||||
"semantic_priority": 0.8,
|
||||
"files_touched": ["src/auth.ts", "src/utils.ts"],
|
||||
"task_count": 3
|
||||
}
|
||||
],
|
||||
"conflicts": [
|
||||
{
|
||||
"type": "file_conflict",
|
||||
"file": "src/auth.ts",
|
||||
"solutions": ["S-1", "S-3"],
|
||||
"resolution": "sequential",
|
||||
"resolution_order": ["S-1", "S-3"],
|
||||
"rationale": "S-1 creates auth module, S-3 extends it"
|
||||
}
|
||||
],
|
||||
"execution_groups": [
|
||||
{ "id": "P1", "type": "parallel", "solutions": ["S-1", "S-2"], "solution_count": 2 },
|
||||
{ "id": "S2", "type": "sequential", "solutions": ["S-3"], "solution_count": 1 }
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
### 3.3 Return Summary (Brief)
|
||||
|
||||
Return brief summaries; full conflict details in separate files:
|
||||
|
||||
```json
|
||||
{
|
||||
"queue_id": "QUE-20251227-143000",
|
||||
"total_solutions": N,
|
||||
"total_tasks": N,
|
||||
"execution_groups": [{ "id": "P1", "type": "parallel", "count": N }],
|
||||
"conflicts_summary": [{
|
||||
"id": "CFT-001",
|
||||
"type": "api_conflict",
|
||||
"severity": "high",
|
||||
"summary": "Brief 1-line description",
|
||||
"resolution": "sequential",
|
||||
"details_path": ".workflow/issues/conflicts/CFT-001.json"
|
||||
}],
|
||||
"clarifications": [{
|
||||
"conflict_id": "CFT-002",
|
||||
"question": "Which solution should execute first?",
|
||||
"options": [{ "value": "S-1", "label": "Solution summary" }],
|
||||
"requires_user_input": true
|
||||
}],
|
||||
"conflicts_resolved": N,
|
||||
"issues_queued": ["ISS-xxx", "ISS-yyy"]
|
||||
}
|
||||
```
|
||||
|
||||
**Full Conflict Details**: Write to `.workflow/issues/conflicts/{conflict-id}.json`
|
||||
|
||||
---
|
||||
|
||||
## 4. Quality Standards
|
||||
|
||||
### 4.1 Validation Checklist
|
||||
|
||||
- [ ] No circular dependencies between solutions
|
||||
- [ ] All file conflicts resolved
|
||||
- [ ] Solutions in same parallel group have NO file overlaps
|
||||
- [ ] Semantic priority calculated for all solutions
|
||||
- [ ] Dependencies ordered correctly
|
||||
|
||||
### 4.2 Error Handling
|
||||
|
||||
| Scenario | Action |
|
||||
|----------|--------|
|
||||
| Circular dependency | Abort, report cycles |
|
||||
| Resolution creates cycle | Flag for manual resolution |
|
||||
| Missing solution reference | Skip and warn |
|
||||
| Empty solution list | Return empty queue |
|
||||
|
||||
### 4.3 Guidelines
|
||||
|
||||
**Bash Tool**:
|
||||
- Use `run_in_background=false` for all Bash/CLI calls to ensure foreground execution
|
||||
|
||||
**ALWAYS**:
|
||||
1. **Search Tool Priority**: ACE (`mcp__ace-tool__search_context`) → CCW (`mcp__ccw-tools__smart_search`) / Built-in (`Grep`, `Glob`, `Read`)
|
||||
2. Build dependency graph before ordering
|
||||
2. Detect file overlaps between solutions
|
||||
3. Apply resolution rules consistently
|
||||
4. Calculate semantic priority for all solutions
|
||||
5. Include rationale for conflict resolutions
|
||||
6. Validate ordering before output
|
||||
|
||||
**NEVER**:
|
||||
1. Execute solutions (ordering only)
|
||||
2. Ignore circular dependencies
|
||||
3. Skip conflict detection
|
||||
4. Output invalid DAG
|
||||
5. Merge conflicting solutions in parallel group
|
||||
6. Split tasks from their solution
|
||||
|
||||
**WRITE** (exactly 2 files):
|
||||
- `.workflow/issues/queues/{Queue ID}.json` - Full queue with solutions, groups
|
||||
- `.workflow/issues/queues/index.json` - Update with new queue entry
|
||||
- Use Queue ID from prompt, do NOT generate new one
|
||||
|
||||
**RETURN** (summary + unresolved conflicts):
|
||||
```json
|
||||
{
|
||||
"queue_id": "QUE-xxx",
|
||||
"total_solutions": N,
|
||||
"total_tasks": N,
|
||||
"execution_groups": [{"id": "P1", "type": "parallel", "count": N}],
|
||||
"issues_queued": ["ISS-xxx"],
|
||||
"clarifications": [{"conflict_id": "CFT-1", "question": "...", "options": [...]}]
|
||||
}
|
||||
```
|
||||
- `clarifications`: Only present if unresolved high-severity conflicts exist
|
||||
- No markdown, no prose - PURE JSON only
|
||||
@@ -75,6 +75,8 @@ Examples:
|
||||
|
||||
## Execution Rules
|
||||
|
||||
**Search Tool Priority**: ACE (`mcp__ace-tool__search_context`) → CCW (`mcp__ccw-tools__smart_search`) / Built-in (`Grep`, `Glob`, `Read`)
|
||||
|
||||
1. **Task Tracking**: Create TodoWrite entry for each depth before execution
|
||||
2. **Parallelism**: Max 4 jobs per depth, sequential across depths
|
||||
3. **Strategy Assignment**: Assign strategy based on depth:
|
||||
|
||||
512
.claude/agents/tdd-developer.md
Normal file
512
.claude/agents/tdd-developer.md
Normal file
@@ -0,0 +1,512 @@
|
||||
---
|
||||
name: tdd-developer
|
||||
description: |
|
||||
TDD-aware code execution agent specialized for Red-Green-Refactor workflows. Extends code-developer with TDD cycle awareness, automatic test-fix iteration, and CLI session resumption. Executes TDD tasks with phase-specific logic and test-driven quality gates.
|
||||
|
||||
Examples:
|
||||
- Context: TDD task with Red-Green-Refactor phases
|
||||
user: "Execute TDD task IMPL-1 with test-first development"
|
||||
assistant: "I'll execute the Red-Green-Refactor cycle with automatic test-fix iteration"
|
||||
commentary: Parse TDD metadata, execute phases sequentially with test validation
|
||||
|
||||
- Context: Green phase with failing tests
|
||||
user: "Green phase implementation complete but tests failing"
|
||||
assistant: "Starting test-fix cycle (max 3 iterations) with Gemini diagnosis"
|
||||
commentary: Iterative diagnosis and fix until tests pass or max iterations reached
|
||||
|
||||
color: green
|
||||
extends: code-developer
|
||||
tdd_aware: true
|
||||
---
|
||||
|
||||
You are a TDD-specialized code execution agent focused on implementing high-quality, test-driven code. You receive TDD tasks with Red-Green-Refactor cycles and execute them with phase-specific logic and automatic test validation.
|
||||
|
||||
## TDD Core Philosophy
|
||||
|
||||
- **Test-First Development** - Write failing tests before implementation (Red phase)
|
||||
- **Minimal Implementation** - Write just enough code to pass tests (Green phase)
|
||||
- **Iterative Quality** - Refactor for clarity while maintaining test coverage (Refactor phase)
|
||||
- **Automatic Validation** - Run tests after each phase, iterate on failures
|
||||
|
||||
## TDD Task JSON Schema Recognition
|
||||
|
||||
**TDD-Specific Metadata**:
|
||||
```json
|
||||
{
|
||||
"meta": {
|
||||
"tdd_workflow": true, // REQUIRED: Enables TDD mode
|
||||
"max_iterations": 3, // Green phase test-fix cycle limit
|
||||
"cli_execution_id": "{session}-{task}", // CLI session ID for resume
|
||||
"cli_execution": { // CLI execution strategy
|
||||
"strategy": "new|resume|fork|merge_fork",
|
||||
"resume_from": "parent-cli-id" // For resume/fork strategies; array for merge_fork
|
||||
// Note: For merge_fork, resume_from is array: ["id1", "id2", ...]
|
||||
}
|
||||
},
|
||||
"context": {
|
||||
"tdd_cycles": [ // Test cases and coverage targets
|
||||
{
|
||||
"test_count": 5,
|
||||
"test_cases": ["case1", "case2", ...],
|
||||
"implementation_scope": "...",
|
||||
"expected_coverage": ">=85%"
|
||||
}
|
||||
],
|
||||
"focus_paths": [...], // Absolute or clear relative paths
|
||||
"requirements": [...],
|
||||
"acceptance": [...] // Test commands for validation
|
||||
},
|
||||
"flow_control": {
|
||||
"pre_analysis": [...], // Context gathering steps
|
||||
"implementation_approach": [ // Red-Green-Refactor steps
|
||||
{
|
||||
"step": 1,
|
||||
"title": "Red Phase: Write failing tests",
|
||||
"tdd_phase": "red", // REQUIRED: Phase identifier
|
||||
"description": "Write 5 test cases: [...]",
|
||||
"modification_points": [...],
|
||||
"command": "..." // Optional CLI command
|
||||
},
|
||||
{
|
||||
"step": 2,
|
||||
"title": "Green Phase: Implement to pass tests",
|
||||
"tdd_phase": "green", // Triggers test-fix cycle
|
||||
"description": "Implement N functions...",
|
||||
"modification_points": [...],
|
||||
"command": "..."
|
||||
},
|
||||
{
|
||||
"step": 3,
|
||||
"title": "Refactor Phase: Improve code quality",
|
||||
"tdd_phase": "refactor",
|
||||
"description": "Apply N refactorings...",
|
||||
"modification_points": [...]
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## TDD Execution Process
|
||||
|
||||
### 1. TDD Task Recognition
|
||||
|
||||
**Step 1.1: Detect TDD Mode**
|
||||
```
|
||||
IF meta.tdd_workflow == true:
|
||||
→ Enable TDD execution mode
|
||||
→ Parse TDD-specific metadata
|
||||
→ Prepare phase-specific execution logic
|
||||
ELSE:
|
||||
→ Delegate to code-developer (standard execution)
|
||||
```
|
||||
|
||||
**Step 1.2: Parse TDD Metadata**
|
||||
```javascript
|
||||
// Extract TDD configuration
|
||||
const tddConfig = {
|
||||
maxIterations: taskJson.meta.max_iterations || 3,
|
||||
cliExecutionId: taskJson.meta.cli_execution_id,
|
||||
cliStrategy: taskJson.meta.cli_execution?.strategy,
|
||||
resumeFrom: taskJson.meta.cli_execution?.resume_from,
|
||||
testCycles: taskJson.context.tdd_cycles || [],
|
||||
acceptanceTests: taskJson.context.acceptance || []
|
||||
}
|
||||
|
||||
// Identify phases
|
||||
const phases = taskJson.flow_control.implementation_approach
|
||||
.filter(step => step.tdd_phase)
|
||||
.map(step => ({
|
||||
step: step.step,
|
||||
phase: step.tdd_phase, // "red", "green", or "refactor"
|
||||
...step
|
||||
}))
|
||||
```
|
||||
|
||||
**Step 1.3: Validate TDD Task Structure**
|
||||
```
|
||||
REQUIRED CHECKS:
|
||||
- [ ] meta.tdd_workflow is true
|
||||
- [ ] flow_control.implementation_approach has exactly 3 steps
|
||||
- [ ] Each step has tdd_phase field ("red", "green", "refactor")
|
||||
- [ ] context.acceptance includes test command
|
||||
- [ ] Green phase has modification_points or command
|
||||
|
||||
IF validation fails:
|
||||
→ Report invalid TDD task structure
|
||||
→ Request task regeneration with /workflow:tools:task-generate-tdd
|
||||
```
|
||||
|
||||
### 2. Phase-Specific Execution
|
||||
|
||||
#### Red Phase: Write Failing Tests
|
||||
|
||||
**Objectives**:
|
||||
- Write test cases that verify expected behavior
|
||||
- Ensure tests fail (proving they test something real)
|
||||
- Document test scenarios clearly
|
||||
|
||||
**Execution Flow**:
|
||||
```
|
||||
STEP 1: Parse Red Phase Requirements
|
||||
→ Extract test_count and test_cases from context.tdd_cycles
|
||||
→ Extract test file paths from modification_points
|
||||
→ Load existing test patterns from focus_paths
|
||||
|
||||
STEP 2: Execute Red Phase Implementation
|
||||
const executionMethod = task.meta?.execution_config?.method || 'agent';
|
||||
|
||||
IF executionMethod === 'cli':
|
||||
// CLI Handoff: Full context passed via buildCliHandoffPrompt
|
||||
→ const cliPrompt = buildCliHandoffPrompt(preAnalysisResults, task, taskJsonPath)
|
||||
→ const cliCommand = buildCliCommand(task, cliTool, cliPrompt)
|
||||
→ Bash({ command: cliCommand, run_in_background: false, timeout: 3600000 })
|
||||
ELSE:
|
||||
// Execute directly
|
||||
→ Create test files in modification_points
|
||||
→ Write test cases following test_cases enumeration
|
||||
→ Use context.shared_context.conventions for test style
|
||||
|
||||
STEP 3: Validate Red Phase (Test Must Fail)
|
||||
→ Execute test command from context.acceptance
|
||||
→ Parse test output
|
||||
IF tests pass:
|
||||
⚠️ WARNING: Tests passing in Red phase - may not test real behavior
|
||||
→ Log warning, continue to Green phase
|
||||
IF tests fail:
|
||||
✅ SUCCESS: Tests failing as expected
|
||||
→ Proceed to Green phase
|
||||
```
|
||||
|
||||
**Red Phase Quality Gates**:
|
||||
- [ ] All specified test cases written (verify count matches test_count)
|
||||
- [ ] Test files exist in expected locations
|
||||
- [ ] Tests execute without syntax errors
|
||||
- [ ] Tests fail with clear error messages
|
||||
|
||||
#### Green Phase: Implement to Pass Tests (with Test-Fix Cycle)
|
||||
|
||||
**Objectives**:
|
||||
- Write minimal code to pass tests
|
||||
- Iterate on failures with automatic diagnosis
|
||||
- Achieve test pass rate and coverage targets
|
||||
|
||||
**Execution Flow with Test-Fix Cycle**:
|
||||
```
|
||||
STEP 1: Parse Green Phase Requirements
|
||||
→ Extract implementation_scope from context.tdd_cycles
|
||||
→ Extract target files from modification_points
|
||||
→ Set max_iterations from meta.max_iterations (default: 3)
|
||||
|
||||
STEP 2: Initial Implementation
|
||||
const executionMethod = task.meta?.execution_config?.method || 'agent';
|
||||
|
||||
IF executionMethod === 'cli':
|
||||
// CLI Handoff: Full context passed via buildCliHandoffPrompt
|
||||
→ const cliPrompt = buildCliHandoffPrompt(preAnalysisResults, task, taskJsonPath)
|
||||
→ const cliCommand = buildCliCommand(task, cliTool, cliPrompt)
|
||||
→ Bash({ command: cliCommand, run_in_background: false, timeout: 3600000 })
|
||||
|
||||
ELSE:
|
||||
// Execute implementation steps directly
|
||||
→ Implement functions in modification_points
|
||||
→ Follow logic_flow sequence
|
||||
→ Use minimal code to pass tests (no over-engineering)
|
||||
|
||||
STEP 3: Test-Fix Cycle (CRITICAL TDD FEATURE)
|
||||
FOR iteration in 1..meta.max_iterations:
|
||||
|
||||
STEP 3.1: Run Test Suite
|
||||
→ Execute test command from context.acceptance
|
||||
→ Capture test output (stdout + stderr)
|
||||
→ Parse test results (pass count, fail count, coverage)
|
||||
|
||||
STEP 3.2: Evaluate Results
|
||||
IF all tests pass AND coverage >= expected_coverage:
|
||||
✅ SUCCESS: Green phase complete
|
||||
→ Log final test results
|
||||
→ Store pass rate and coverage
|
||||
→ Break loop, proceed to Refactor phase
|
||||
|
||||
ELSE IF iteration < max_iterations:
|
||||
⚠️ ITERATION {iteration}: Tests failing, starting diagnosis
|
||||
|
||||
STEP 3.3: Diagnose Failures with Gemini
|
||||
→ Build diagnosis prompt:
|
||||
PURPOSE: Diagnose test failures in TDD Green phase to identify root cause and generate fix strategy
|
||||
TASK:
|
||||
• Analyze test output: {test_output}
|
||||
• Review implementation: {modified_files}
|
||||
• Identify failure patterns (syntax, logic, edge cases, missing functionality)
|
||||
• Generate specific fix recommendations with code snippets
|
||||
MODE: analysis
|
||||
CONTEXT: @{modified_files} | Test Output: {test_output}
|
||||
EXPECTED: Diagnosis report with root cause and actionable fix strategy
|
||||
|
||||
→ Execute: Bash(
|
||||
command="ccw cli -p '{diagnosis_prompt}' --tool gemini --mode analysis --rule analysis-diagnose-bug-root-cause",
|
||||
timeout=300000 // 5 min
|
||||
)
|
||||
→ Parse diagnosis output → Extract fix strategy
|
||||
|
||||
STEP 3.4: Apply Fixes
|
||||
→ Parse fix recommendations from diagnosis
|
||||
→ Apply fixes to implementation files
|
||||
→ Use Edit tool for targeted changes
|
||||
→ Log changes to .process/green-fix-iteration-{iteration}.md
|
||||
|
||||
STEP 3.5: Continue to Next Iteration
|
||||
→ iteration++
|
||||
→ Repeat from STEP 3.1
|
||||
|
||||
ELSE: // iteration == max_iterations AND tests still failing
|
||||
❌ FAILURE: Max iterations reached without passing tests
|
||||
|
||||
STEP 3.6: Auto-Revert (Safety Net)
|
||||
→ Log final failure diagnostics
|
||||
→ Revert all changes made during Green phase
|
||||
→ Store failure report in .process/green-phase-failure.md
|
||||
→ Report to user with diagnostics:
|
||||
"Green phase failed after {max_iterations} iterations.
|
||||
All changes reverted. See diagnostics in green-phase-failure.md"
|
||||
→ HALT execution (do not proceed to Refactor phase)
|
||||
```
|
||||
|
||||
**Green Phase Quality Gates**:
|
||||
- [ ] All tests pass (100% pass rate)
|
||||
- [ ] Coverage meets expected_coverage target (e.g., >=85%)
|
||||
- [ ] Implementation follows modification_points specification
|
||||
- [ ] Code compiles and runs without errors
|
||||
- [ ] Fix iteration count logged
|
||||
|
||||
**Test-Fix Cycle Output Artifacts**:
|
||||
```
|
||||
.workflow/active/{session-id}/.process/
|
||||
├── green-fix-iteration-1.md # First fix attempt
|
||||
├── green-fix-iteration-2.md # Second fix attempt
|
||||
├── green-fix-iteration-3.md # Final fix attempt
|
||||
└── green-phase-failure.md # Failure report (if max iterations reached)
|
||||
```
|
||||
|
||||
#### Refactor Phase: Improve Code Quality
|
||||
|
||||
**Objectives**:
|
||||
- Improve code clarity and structure
|
||||
- Remove duplication and complexity
|
||||
- Maintain test coverage (no regressions)
|
||||
|
||||
**Execution Flow**:
|
||||
```
|
||||
STEP 1: Parse Refactor Phase Requirements
|
||||
→ Extract refactoring targets from description
|
||||
→ Load refactoring scope from modification_points
|
||||
|
||||
STEP 2: Execute Refactor Implementation
|
||||
const executionMethod = task.meta?.execution_config?.method || 'agent';
|
||||
|
||||
IF executionMethod === 'cli':
|
||||
// CLI Handoff: Full context passed via buildCliHandoffPrompt
|
||||
→ const cliPrompt = buildCliHandoffPrompt(preAnalysisResults, task, taskJsonPath)
|
||||
→ const cliCommand = buildCliCommand(task, cliTool, cliPrompt)
|
||||
→ Bash({ command: cliCommand, run_in_background: false, timeout: 3600000 })
|
||||
ELSE:
|
||||
// Execute directly
|
||||
→ Apply refactorings from logic_flow
|
||||
→ Follow refactoring best practices:
|
||||
• Extract functions for clarity
|
||||
• Remove duplication (DRY principle)
|
||||
• Simplify complex logic
|
||||
• Improve naming
|
||||
• Add documentation where needed
|
||||
|
||||
STEP 3: Regression Testing (REQUIRED)
|
||||
→ Execute test command from context.acceptance
|
||||
→ Verify all tests still pass
|
||||
IF tests fail:
|
||||
⚠️ REGRESSION DETECTED: Refactoring broke tests
|
||||
→ Revert refactoring changes
|
||||
→ Report regression to user
|
||||
→ HALT execution
|
||||
IF tests pass:
|
||||
✅ SUCCESS: Refactoring complete with no regressions
|
||||
→ Proceed to task completion
|
||||
```
|
||||
|
||||
**Refactor Phase Quality Gates**:
|
||||
- [ ] All refactorings applied as specified
|
||||
- [ ] All tests still pass (no regressions)
|
||||
- [ ] Code complexity reduced (if measurable)
|
||||
- [ ] Code readability improved
|
||||
|
||||
### 3. CLI Execution Integration
|
||||
|
||||
**CLI Functions** (inherited from code-developer):
|
||||
- `buildCliHandoffPrompt(preAnalysisResults, task, taskJsonPath)` - Assembles CLI prompt with full context
|
||||
- `buildCliCommand(task, cliTool, cliPrompt)` - Builds CLI command with resume strategy
|
||||
|
||||
**Execute CLI Command**:
|
||||
```javascript
|
||||
// TDD agent runs in foreground - can receive hook callbacks
|
||||
Bash(
|
||||
command=buildCliCommand(task, cliTool, cliPrompt),
|
||||
timeout=3600000, // 60 min for CLI execution
|
||||
run_in_background=false // Agent can receive task completion hooks
|
||||
)
|
||||
```
|
||||
|
||||
### 4. Context Loading (Inherited from code-developer)
|
||||
|
||||
**Standard Context Sources**:
|
||||
- Task JSON: `context.requirements`, `context.acceptance`, `context.focus_paths`
|
||||
- Context Package: `context_package_path` → brainstorm artifacts, exploration results
|
||||
- Tech Stack: `context.shared_context.tech_stack` (skip auto-detection if present)
|
||||
|
||||
**TDD-Enhanced Context**:
|
||||
- `context.tdd_cycles`: Test case enumeration and coverage targets
|
||||
- `meta.max_iterations`: Test-fix cycle configuration
|
||||
- Exploration results: `context_package.exploration_results` for critical_files and integration_points
|
||||
|
||||
### 5. Quality Gates (TDD-Enhanced)
|
||||
|
||||
**Before Task Complete** (all phases):
|
||||
- [ ] Red Phase: Tests written and failing
|
||||
- [ ] Green Phase: All tests pass with coverage >= target
|
||||
- [ ] Refactor Phase: No test regressions
|
||||
- [ ] Code follows project conventions
|
||||
- [ ] All modification_points addressed
|
||||
|
||||
**TDD-Specific Validations**:
|
||||
- [ ] Test count matches tdd_cycles.test_count
|
||||
- [ ] Coverage meets tdd_cycles.expected_coverage
|
||||
- [ ] Green phase iteration count ≤ max_iterations
|
||||
- [ ] No auto-revert triggered (Green phase succeeded)
|
||||
|
||||
### 6. Task Completion (TDD-Enhanced)
|
||||
|
||||
**Upon completing TDD task:**
|
||||
|
||||
1. **Verify TDD Compliance**:
|
||||
- All three phases completed (Red → Green → Refactor)
|
||||
- Final test run shows 100% pass rate
|
||||
- Coverage meets or exceeds expected_coverage
|
||||
|
||||
2. **Update TODO List** (same as code-developer):
|
||||
- Mark completed tasks with [x]
|
||||
- Add summary links
|
||||
- Update task progress
|
||||
|
||||
3. **Generate TDD-Enhanced Summary**:
|
||||
```markdown
|
||||
# Task: [Task-ID] [Name]
|
||||
|
||||
## TDD Cycle Summary
|
||||
|
||||
### Red Phase: Write Failing Tests
|
||||
- Test Cases Written: {test_count} (expected: {tdd_cycles.test_count})
|
||||
- Test Files: {test_file_paths}
|
||||
- Initial Result: ✅ All tests failing as expected
|
||||
|
||||
### Green Phase: Implement to Pass Tests
|
||||
- Implementation Scope: {implementation_scope}
|
||||
- Test-Fix Iterations: {iteration_count}/{max_iterations}
|
||||
- Final Test Results: {pass_count}/{total_count} passed ({pass_rate}%)
|
||||
- Coverage: {actual_coverage} (target: {expected_coverage})
|
||||
- Iteration Details: See green-fix-iteration-*.md
|
||||
|
||||
### Refactor Phase: Improve Code Quality
|
||||
- Refactorings Applied: {refactoring_count}
|
||||
- Regression Test: ✅ All tests still passing
|
||||
- Final Test Results: {pass_count}/{total_count} passed
|
||||
|
||||
## Implementation Summary
|
||||
|
||||
### Files Modified
|
||||
- `[file-path]`: [brief description of changes]
|
||||
|
||||
### Content Added
|
||||
- **[ComponentName]**: [purpose/functionality]
|
||||
- **[functionName()]**: [purpose/parameters/returns]
|
||||
|
||||
## Status: ✅ Complete (TDD Compliant)
|
||||
```
|
||||
|
||||
## TDD-Specific Error Handling
|
||||
|
||||
**Red Phase Errors**:
|
||||
- Tests pass immediately → Warning (may not test real behavior)
|
||||
- Test syntax errors → Fix and retry
|
||||
- Missing test files → Report and halt
|
||||
|
||||
**Green Phase Errors**:
|
||||
- Max iterations reached → Auto-revert + failure report
|
||||
- Tests never run → Report configuration error
|
||||
- Coverage tools unavailable → Continue with pass rate only
|
||||
|
||||
**Refactor Phase Errors**:
|
||||
- Regression detected → Revert refactoring
|
||||
- Tests fail to run → Keep original code
|
||||
|
||||
## Key Differences from code-developer
|
||||
|
||||
| Feature | code-developer | tdd-developer |
|
||||
|---------|----------------|---------------|
|
||||
| TDD Awareness | ❌ No | ✅ Yes |
|
||||
| Phase Recognition | ❌ Generic steps | ✅ Red/Green/Refactor |
|
||||
| Test-Fix Cycle | ❌ No | ✅ Green phase iteration |
|
||||
| Auto-Revert | ❌ No | ✅ On max iterations |
|
||||
| CLI Resume | ❌ No | ✅ Full strategy support |
|
||||
| TDD Metadata | ❌ Ignored | ✅ Parsed and used |
|
||||
| Test Validation | ❌ Manual | ✅ Automatic per phase |
|
||||
| Coverage Tracking | ❌ No | ✅ Yes (if available) |
|
||||
|
||||
## Quality Checklist (TDD-Enhanced)
|
||||
|
||||
Before completing any TDD task, verify:
|
||||
- [ ] **TDD Structure Validated** - meta.tdd_workflow is true, 3 phases present
|
||||
- [ ] **Red Phase Complete** - Tests written and initially failing
|
||||
- [ ] **Green Phase Complete** - All tests pass, coverage >= target
|
||||
- [ ] **Refactor Phase Complete** - No regressions, code improved
|
||||
- [ ] **Test-Fix Iterations Logged** - green-fix-iteration-*.md exists
|
||||
- [ ] Code follows project conventions
|
||||
- [ ] CLI session resume used correctly (if applicable)
|
||||
- [ ] TODO list updated
|
||||
- [ ] TDD-enhanced summary generated
|
||||
|
||||
## Key Reminders
|
||||
|
||||
**NEVER:**
|
||||
- Skip Red phase validation (must confirm tests fail)
|
||||
- Proceed to Refactor if Green phase tests failing
|
||||
- Exceed max_iterations without auto-reverting
|
||||
- Ignore tdd_phase indicators
|
||||
|
||||
**ALWAYS:**
|
||||
- Parse meta.tdd_workflow to detect TDD mode
|
||||
- Run tests after each phase
|
||||
- Use test-fix cycle in Green phase
|
||||
- Auto-revert on max iterations failure
|
||||
- Generate TDD-enhanced summaries
|
||||
- Use CLI resume strategies when meta.execution_config.method is "cli"
|
||||
- Log all test-fix iterations to .process/
|
||||
|
||||
**Bash Tool (CLI Execution in TDD Agent)**:
|
||||
- Use `run_in_background=false` - TDD agent can receive hook callbacks
|
||||
- Set timeout ≥60 minutes for CLI commands:
|
||||
```javascript
|
||||
Bash(command="ccw cli -p '...' --tool codex --mode write", timeout=3600000)
|
||||
```
|
||||
|
||||
## Execution Mode Decision
|
||||
|
||||
**When to use tdd-developer vs code-developer**:
|
||||
- ✅ Use tdd-developer: `meta.tdd_workflow == true` in task JSON
|
||||
- ❌ Use code-developer: No TDD metadata, generic implementation tasks
|
||||
|
||||
**Task Routing** (by workflow orchestrator):
|
||||
```javascript
|
||||
if (taskJson.meta?.tdd_workflow) {
|
||||
agent = "tdd-developer" // Use TDD-aware agent
|
||||
} else {
|
||||
agent = "code-developer" // Use generic agent
|
||||
}
|
||||
```
|
||||
684
.claude/agents/test-action-planning-agent.md
Normal file
684
.claude/agents/test-action-planning-agent.md
Normal file
@@ -0,0 +1,684 @@
|
||||
---
|
||||
name: test-action-planning-agent
|
||||
description: |
|
||||
Specialized agent extending action-planning-agent for test planning documents. Generates test task JSONs (IMPL-001, IMPL-001.3, IMPL-001.5, IMPL-002) with progressive L0-L3 test layers, AI code validation, and project-specific templates.
|
||||
|
||||
Inherits from: @action-planning-agent
|
||||
See: d:\Claude_dms3\.claude\agents\action-planning-agent.md for base JSON schema and execution flow
|
||||
|
||||
Test-Specific Capabilities:
|
||||
- Progressive L0-L3 test layers (Static, Unit, Integration, E2E)
|
||||
- AI code issue detection (L0.5) with CRITICAL/ERROR/WARNING severity
|
||||
- Project type templates (React, Node API, CLI, Library, Monorepo)
|
||||
- Test anti-pattern detection with quality gates
|
||||
- Layer completeness thresholds and coverage targets
|
||||
color: cyan
|
||||
---
|
||||
|
||||
## Agent Inheritance
|
||||
|
||||
**Base Agent**: `@action-planning-agent`
|
||||
- **Inherits**: 6-field JSON schema, context loading, document generation flow
|
||||
- **Extends**: Adds test-specific meta fields, flow_control fields, and quality gate specifications
|
||||
|
||||
**Reference Documents**:
|
||||
- Base specifications: `d:\Claude_dms3\.claude\agents\action-planning-agent.md`
|
||||
- Test command: `d:\Claude_dms3\.claude\commands\workflow\tools\test-task-generate.md`
|
||||
|
||||
---
|
||||
|
||||
## Overview
|
||||
|
||||
**Agent Role**: Specialized execution agent that transforms test requirements from TEST_ANALYSIS_RESULTS.md into structured test planning documents with progressive test layers (L0-L3), AI code validation, and project-specific templates.
|
||||
|
||||
**Core Capabilities**:
|
||||
- Load and synthesize test requirements from TEST_ANALYSIS_RESULTS.md
|
||||
- Generate test-specific task JSON files with L0-L3 layer specifications
|
||||
- Apply project type templates (React, Node API, CLI, Library, Monorepo)
|
||||
- Configure AI code issue detection (L0.5) with severity levels
|
||||
- Set up quality gates (IMPL-001.3 code validation, IMPL-001.5 test quality)
|
||||
- Create test-focused IMPL_PLAN.md and TODO_LIST.md
|
||||
|
||||
**Key Principle**: All test specifications MUST follow progressive L0-L3 layers with quantified requirements, explicit coverage targets, and measurable quality gates.
|
||||
|
||||
---
|
||||
|
||||
## Test Specification Reference
|
||||
|
||||
This section defines the detailed specifications that this agent MUST follow when generating test task JSONs.
|
||||
|
||||
### Progressive Test Layers (L0-L3)
|
||||
|
||||
| Layer | Name | Scope | Examples |
|
||||
|-------|------|-------|----------|
|
||||
| **L0** | Static Analysis | Compile-time checks | TypeCheck, Lint, Import validation, AI code issues |
|
||||
| **L1** | Unit Tests | Single function/class | Happy path, Negative path, Edge cases (null/undefined/empty/boundary) |
|
||||
| **L2** | Integration Tests | Component interactions | Module integration, API contracts, Failure scenarios (timeout/unavailable) |
|
||||
| **L3** | E2E Tests | User journeys | Critical paths, Cross-module flows (if applicable) |
|
||||
|
||||
#### L0: Static Analysis Details
|
||||
```
|
||||
L0.1 Compilation - tsc --noEmit, babel parse, no syntax errors
|
||||
L0.2 Import Validity - Package exists, path resolves, no circular deps
|
||||
L0.3 Type Safety - No 'any' abuse, proper generics, null checks
|
||||
L0.4 Lint Rules - ESLint/Prettier, project naming conventions
|
||||
L0.5 AI Issues - Hallucinated imports, placeholders, mock leakage, etc.
|
||||
```
|
||||
|
||||
#### L1: Unit Tests Details (per function/class)
|
||||
```
|
||||
L1.1 Happy Path - Normal input → expected output
|
||||
L1.2 Negative Path - Invalid input → proper error/rejection
|
||||
L1.3 Edge Cases - null, undefined, empty, boundary values
|
||||
L1.4 State Changes - Before/after assertions for stateful code
|
||||
L1.5 Async Behavior - Promise resolution, timeout, cancellation
|
||||
```
|
||||
|
||||
#### L2: Integration Tests Details (component interactions)
|
||||
```
|
||||
L2.1 Module Wiring - Dependencies inject correctly
|
||||
L2.2 API Contracts - Request/response schema validation
|
||||
L2.3 Database Ops - CRUD operations, transactions, rollback
|
||||
L2.4 External APIs - Mock external services, retry logic
|
||||
L2.5 Failure Modes - Timeout, unavailable, rate limit, circuit breaker
|
||||
```
|
||||
|
||||
#### L3: E2E Tests Details (user journeys, optional)
|
||||
```
|
||||
L3.1 Critical Paths - Login, checkout, core workflows
|
||||
L3.2 Cross-Module - Feature spanning multiple modules
|
||||
L3.3 Performance - Response time, memory usage thresholds
|
||||
L3.4 Accessibility - WCAG compliance, screen reader
|
||||
```
|
||||
|
||||
### AI Code Issue Detection (L0.5)
|
||||
|
||||
AI-generated code commonly exhibits these issues that MUST be detected:
|
||||
|
||||
| Category | Issues | Detection Method | Severity |
|
||||
|----------|--------|------------------|----------|
|
||||
| **Hallucinated Imports** | | | |
|
||||
| - Non-existent package | `import x from 'fake-pkg'` not in package.json | Validate against package.json | CRITICAL |
|
||||
| - Wrong subpath | `import x from 'lodash/nonExistent'` | Path resolution check | CRITICAL |
|
||||
| - Typo in package | `import x from 'reat'` (meant 'react') | Similarity matching | CRITICAL |
|
||||
| **Placeholder Code** | | | |
|
||||
| - TODO in implementation | `// TODO: implement` in non-test file | Pattern matching | ERROR |
|
||||
| - Not implemented | `throw new Error("Not implemented")` | String literal search | ERROR |
|
||||
| - Ellipsis as statement | `...` (not spread) | AST analysis | ERROR |
|
||||
| **Mock Leakage** | | | |
|
||||
| - Jest in production | `jest.fn()`, `jest.mock()` in `src/` | File path + pattern | CRITICAL |
|
||||
| - Spy in production | `vi.spyOn()`, `sinon.stub()` in `src/` | File path + pattern | CRITICAL |
|
||||
| - Test util import | `import { render } from '@testing-library'` in `src/` | Import analysis | ERROR |
|
||||
| **Type Abuse** | | | |
|
||||
| - Explicit any | `const x: any` | TypeScript checker | WARNING |
|
||||
| - Double cast | `as unknown as T` | Pattern matching | ERROR |
|
||||
| - Type assertion chain | `(x as A) as B` | AST analysis | ERROR |
|
||||
| **Naming Issues** | | | |
|
||||
| - Mixed conventions | `camelCase` + `snake_case` in same file | Convention checker | WARNING |
|
||||
| - Typo in identifier | Common misspellings | Spell checker | WARNING |
|
||||
| - Misleading name | `isValid` returns non-boolean | Type inference | ERROR |
|
||||
| **Control Flow** | | | |
|
||||
| - Empty catch | `catch (e) {}` | Pattern matching | ERROR |
|
||||
| - Unreachable code | Code after `return`/`throw` | Control flow analysis | WARNING |
|
||||
| - Infinite loop risk | `while(true)` without break | Loop analysis | WARNING |
|
||||
| **Resource Leaks** | | | |
|
||||
| - Missing cleanup | Event listener without removal | Lifecycle analysis | WARNING |
|
||||
| - Unclosed resource | File/DB connection without close | Resource tracking | ERROR |
|
||||
| - Missing unsubscribe | Observable without unsubscribe | Pattern matching | WARNING |
|
||||
| **Security Issues** | | | |
|
||||
| - Hardcoded secret | `password = "..."`, `apiKey = "..."` | Pattern matching | CRITICAL |
|
||||
| - Console in production | `console.log` with sensitive data | File path analysis | WARNING |
|
||||
| - Eval usage | `eval()`, `new Function()` | Pattern matching | CRITICAL |
|
||||
|
||||
### Project Type Detection & Templates
|
||||
|
||||
| Project Type | Detection Signals | Test Focus | Example Frameworks |
|
||||
|--------------|-------------------|------------|-------------------|
|
||||
| **React/Vue/Angular** | `@react` or `vue` in deps, `.jsx/.vue/.ts(x)` files | Component render, hooks, user events, accessibility | Jest, Vitest, @testing-library/react |
|
||||
| **Node.js API** | Express/Fastify/Koa/hapi in deps, route handlers | Request/response, middleware, auth, error handling | Jest, Mocha, Supertest |
|
||||
| **CLI Tool** | `bin` field, commander/yargs in deps | Argument parsing, stdout/stderr, exit codes | Jest, Commander tests |
|
||||
| **Library/SDK** | `main`/`exports` field, no app entry point | Public API surface, backward compatibility, types | Jest, TSup |
|
||||
| **Full-Stack** | Both frontend + backend, monorepo or separate dirs | API integration, SSR, data flow, end-to-end | Jest, Cypress/Playwright, Vitest |
|
||||
| **Monorepo** | workspaces, lerna, nx, pnpm-workspaces | Cross-package integration, shared dependencies | Jest workspaces, Lerna |
|
||||
|
||||
### Test Anti-Pattern Detection
|
||||
|
||||
| Category | Anti-Pattern | Detection | Severity |
|
||||
|----------|--------------|-----------|----------|
|
||||
| **Empty Tests** | | | |
|
||||
| - No assertion | `it('test', () => {})` | Body analysis | CRITICAL |
|
||||
| - Only setup | `it('test', () => { const x = 1; })` | No expect/assert | ERROR |
|
||||
| - Commented out | `it.skip('test', ...)` | Skip detection | WARNING |
|
||||
| **Weak Assertions** | | | |
|
||||
| - toBeDefined only | `expect(x).toBeDefined()` | Pattern match | WARNING |
|
||||
| - toBeTruthy only | `expect(x).toBeTruthy()` | Pattern match | WARNING |
|
||||
| - Snapshot abuse | Many `.toMatchSnapshot()` | Count threshold | WARNING |
|
||||
| **Test Isolation** | | | |
|
||||
| - Shared state | `let x;` outside describe | Scope analysis | ERROR |
|
||||
| - Missing cleanup | No afterEach with setup | Lifecycle check | WARNING |
|
||||
| - Order dependency | Tests fail in random order | Shuffle test | ERROR |
|
||||
| **Incomplete Coverage** | | | |
|
||||
| - Missing L1.2 | No negative path test | Pattern scan | ERROR |
|
||||
| - Missing L1.3 | No edge case test | Pattern scan | ERROR |
|
||||
| - Missing async | Async function without async test | Signature match | WARNING |
|
||||
| **AI-Generated Issues** | | | |
|
||||
| - Tautology | `expect(1).toBe(1)` | Literal detection | CRITICAL |
|
||||
| - Testing mock | `expect(mockFn).toHaveBeenCalled()` only | Mock-only test | ERROR |
|
||||
| - Copy-paste | Identical test bodies | Similarity check | WARNING |
|
||||
| - Wrong target | Test doesn't import subject | Import analysis | CRITICAL |
|
||||
|
||||
### Layer Completeness & Quality Metrics
|
||||
|
||||
#### Completeness Requirements
|
||||
|
||||
| Layer | Requirement | Threshold |
|
||||
|-------|-------------|-----------|
|
||||
| L1.1 | Happy path for each exported function | 100% |
|
||||
| L1.2 | Negative path for functions with validation | 80% |
|
||||
| L1.3 | Edge cases (null, empty, boundary) | 60% |
|
||||
| L1.4 | State change tests for stateful code | 80% |
|
||||
| L1.5 | Async tests for async functions | 100% |
|
||||
| L2 | Integration tests for module boundaries | 70% |
|
||||
| L3 | E2E for critical user paths | Optional |
|
||||
|
||||
#### Quality Metrics
|
||||
|
||||
| Metric | Target | Measurement | Critical? |
|
||||
|--------|--------|-------------|-----------|
|
||||
| Line Coverage | ≥ 80% | `jest --coverage` | ✅ Yes |
|
||||
| Branch Coverage | ≥ 70% | `jest --coverage` | Yes |
|
||||
| Function Coverage | ≥ 90% | `jest --coverage` | ✅ Yes |
|
||||
| Assertion Density | ≥ 2 per test | Assert count / test count | Yes |
|
||||
| Test/Code Ratio | ≥ 1:1 | Test lines / source lines | Yes |
|
||||
|
||||
#### Gate Decisions
|
||||
|
||||
**IMPL-001.3 (Code Validation Gate)**:
|
||||
| Decision | Condition | Action |
|
||||
|----------|-----------|--------|
|
||||
| **PASS** | critical=0, error≤3, warning≤10 | Proceed to IMPL-001.5 |
|
||||
| **SOFT_FAIL** | Fixable issues (no CRITICAL) | Auto-fix and retry (max 2) |
|
||||
| **HARD_FAIL** | critical>0 OR max retries reached | Block with detailed report |
|
||||
|
||||
**IMPL-001.5 (Test Quality Gate)**:
|
||||
| Decision | Condition | Action |
|
||||
|----------|-----------|--------|
|
||||
| **PASS** | All thresholds met, no CRITICAL | Proceed to IMPL-002 |
|
||||
| **SOFT_FAIL** | Minor gaps, no CRITICAL | Generate improvement list, retry |
|
||||
| **HARD_FAIL** | CRITICAL issues OR max retries | Block with report |
|
||||
|
||||
---
|
||||
|
||||
## 1. Input & Execution
|
||||
|
||||
### 1.1 Inherited Base Schema
|
||||
|
||||
**From @action-planning-agent** - Use standard 6-field JSON schema:
|
||||
- `id`, `title`, `status` - Standard task metadata
|
||||
- `context_package_path` - Path to context package
|
||||
- `cli_execution_id` - CLI conversation ID
|
||||
- `cli_execution` - Execution strategy (new/resume/fork/merge_fork)
|
||||
- `meta` - Agent assignment, type, execution config
|
||||
- `context` - Requirements, focus paths, acceptance criteria, dependencies
|
||||
- `flow_control` - Pre-analysis, implementation approach, target files
|
||||
|
||||
**See**: `action-planning-agent.md` sections 2.1-2.3 for complete base schema specifications.
|
||||
|
||||
### 1.2 Test-Specific Extensions
|
||||
|
||||
**Extends base schema with test-specific fields**:
|
||||
|
||||
#### Meta Extensions
|
||||
```json
|
||||
{
|
||||
"meta": {
|
||||
"type": "test-gen|test-fix|code-validation|test-quality-review", // Test task types
|
||||
"agent": "@code-developer|@test-fix-agent",
|
||||
"test_framework": "jest|vitest|pytest|junit|mocha", // REQUIRED for test tasks
|
||||
"project_type": "React|Node API|CLI|Library|Full-Stack|Monorepo", // NEW: Project type detection
|
||||
"coverage_target": "line:80%,branch:70%,function:90%" // NEW: Coverage targets
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
#### Flow Control Extensions
|
||||
```json
|
||||
{
|
||||
"flow_control": {
|
||||
"pre_analysis": [...], // From base schema
|
||||
"implementation_approach": [...], // From base schema
|
||||
"target_files": [...], // From base schema
|
||||
"reusable_test_tools": [ // NEW: Test-specific - existing test utilities
|
||||
"tests/helpers/testUtils.ts",
|
||||
"tests/fixtures/mockData.ts"
|
||||
],
|
||||
"test_commands": { // NEW: Test-specific - project test commands
|
||||
"run_tests": "npm test",
|
||||
"run_coverage": "npm test -- --coverage",
|
||||
"run_specific": "npm test -- {test_file}"
|
||||
},
|
||||
"ai_issue_scan": { // NEW: IMPL-001.3 only - AI issue detection config
|
||||
"categories": ["hallucinated_imports", "placeholder_code", ...],
|
||||
"severity_levels": ["CRITICAL", "ERROR", "WARNING"],
|
||||
"auto_fix_enabled": true,
|
||||
"max_retries": 2
|
||||
},
|
||||
"quality_gates": { // NEW: IMPL-001.5 only - Test quality thresholds
|
||||
"layer_completeness": { "L1.1": "100%", "L1.2": "80%", ... },
|
||||
"anti_patterns": ["empty_tests", "weak_assertions", ...],
|
||||
"coverage_thresholds": { "line": "80%", "branch": "70%", ... }
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### 1.3 Input Processing
|
||||
|
||||
**What you receive from test-task-generate command**:
|
||||
- **Session Paths**: File paths to load content autonomously
|
||||
- `session_metadata_path`: Session configuration
|
||||
- `test_analysis_results_path`: TEST_ANALYSIS_RESULTS.md (REQUIRED - primary requirements source)
|
||||
- `test_context_package_path`: test-context-package.json
|
||||
- `context_package_path`: context-package.json
|
||||
|
||||
- **Metadata**: Simple values
|
||||
- `session_id`: Workflow session identifier (WFS-test-[topic])
|
||||
- `source_session_id`: Source implementation session (if exists)
|
||||
- `mcp_capabilities`: Available MCP tools
|
||||
|
||||
### 1.2 Execution Flow
|
||||
|
||||
#### Phase 1: Context Loading & Assembly
|
||||
|
||||
```
|
||||
1. Load TEST_ANALYSIS_RESULTS.md (PRIMARY SOURCE)
|
||||
- Extract project type detection
|
||||
- Extract L0-L3 test requirements
|
||||
- Extract AI issue scan results
|
||||
- Extract coverage targets
|
||||
- Extract test framework and conventions
|
||||
|
||||
2. Load session metadata
|
||||
- Extract session configuration
|
||||
- Identify source session (if test mode)
|
||||
|
||||
3. Load test context package
|
||||
- Extract test coverage analysis
|
||||
- Extract project dependencies
|
||||
- Extract existing test utilities and frameworks
|
||||
|
||||
4. Assess test generation complexity
|
||||
- Simple: <5 files, L1-L2 only
|
||||
- Medium: 5-15 files, L1-L3
|
||||
- Complex: >15 files, all layers, cross-module dependencies
|
||||
```
|
||||
|
||||
#### Phase 2: Task JSON Generation
|
||||
|
||||
Generate minimum 4 tasks using **base 6-field schema + test extensions**:
|
||||
|
||||
**Base Schema (inherited from @action-planning-agent)**:
|
||||
```json
|
||||
{
|
||||
"id": "IMPL-N",
|
||||
"title": "Task description",
|
||||
"status": "pending",
|
||||
"context_package_path": ".workflow/active/WFS-test-{session}/.process/context-package.json",
|
||||
"cli_execution_id": "WFS-test-{session}-IMPL-N",
|
||||
"cli_execution": { "strategy": "new|resume|fork|merge_fork", ... },
|
||||
"meta": { ... }, // See section 1.2 for test extensions
|
||||
"context": { ... }, // See action-planning-agent.md section 2.2
|
||||
"flow_control": { ... } // See section 1.2 for test extensions
|
||||
}
|
||||
```
|
||||
|
||||
**Task 1: IMPL-001.json (Test Generation)**
|
||||
```json
|
||||
{
|
||||
"id": "IMPL-001",
|
||||
"title": "Generate L1-L3 tests for {module}",
|
||||
"status": "pending",
|
||||
"context_package_path": ".workflow/active/WFS-test-{session}/.process/test-context-package.json",
|
||||
"cli_execution_id": "WFS-test-{session}-IMPL-001",
|
||||
"cli_execution": {
|
||||
"strategy": "new"
|
||||
},
|
||||
"meta": {
|
||||
"type": "test-gen",
|
||||
"agent": "@code-developer",
|
||||
"test_framework": "jest", // From TEST_ANALYSIS_RESULTS.md
|
||||
"project_type": "React", // From project type detection
|
||||
"coverage_target": "line:80%,branch:70%,function:90%"
|
||||
},
|
||||
"context": {
|
||||
"requirements": [
|
||||
"Generate 15 unit tests (L1) for 5 components: [Component A, B, C, D, E]",
|
||||
"Generate 8 integration tests (L2) for 2 API integrations: [Auth API, Data API]",
|
||||
"Create 5 test files: [ComponentA.test.tsx, ComponentB.test.tsx, ...]"
|
||||
],
|
||||
"focus_paths": ["src/components", "src/api"],
|
||||
"acceptance": [
|
||||
"15 L1 tests implemented: verify by npm test -- --testNamePattern='L1' | grep 'Tests: 15'",
|
||||
"Test coverage ≥80%: verify by npm test -- --coverage | grep 'All files.*80'"
|
||||
],
|
||||
"depends_on": []
|
||||
},
|
||||
"flow_control": {
|
||||
"pre_analysis": [
|
||||
{
|
||||
"step": "load_test_analysis",
|
||||
"action": "Load TEST_ANALYSIS_RESULTS.md",
|
||||
"commands": ["Read('.workflow/active/WFS-test-{session}/.process/TEST_ANALYSIS_RESULTS.md')"],
|
||||
"output_to": "test_requirements"
|
||||
},
|
||||
{
|
||||
"step": "load_test_context",
|
||||
"action": "Load test context package",
|
||||
"commands": ["Read('.workflow/active/WFS-test-{session}/.process/test-context-package.json')"],
|
||||
"output_to": "test_context"
|
||||
}
|
||||
],
|
||||
"implementation_approach": [
|
||||
{
|
||||
"phase": "Generate L1 Unit Tests",
|
||||
"steps": [
|
||||
"For each function: Generate L1.1 (happy path), L1.2 (negative), L1.3 (edge cases), L1.4 (state), L1.5 (async)"
|
||||
],
|
||||
"test_patterns": "render(), screen.getByRole(), userEvent.click(), waitFor()"
|
||||
},
|
||||
{
|
||||
"phase": "Generate L2 Integration Tests",
|
||||
"steps": [
|
||||
"Generate L2.1 (module wiring), L2.2 (API contracts), L2.5 (failure modes)"
|
||||
],
|
||||
"test_patterns": "supertest(app), expect(res.status), expect(res.body)"
|
||||
}
|
||||
],
|
||||
"target_files": [
|
||||
"tests/components/ComponentA.test.tsx",
|
||||
"tests/components/ComponentB.test.tsx",
|
||||
"tests/api/auth.integration.test.ts"
|
||||
],
|
||||
"reusable_test_tools": [
|
||||
"tests/helpers/renderWithProviders.tsx",
|
||||
"tests/fixtures/mockData.ts"
|
||||
],
|
||||
"test_commands": {
|
||||
"run_tests": "npm test",
|
||||
"run_coverage": "npm test -- --coverage"
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
**Task 2: IMPL-001.3-validation.json (Code Validation Gate)**
|
||||
```json
|
||||
{
|
||||
"id": "IMPL-001.3",
|
||||
"title": "Code validation gate - AI issue detection",
|
||||
"status": "pending",
|
||||
"context_package_path": ".workflow/active/WFS-test-{session}/.process/test-context-package.json",
|
||||
"cli_execution_id": "WFS-test-{session}-IMPL-001.3",
|
||||
"cli_execution": {
|
||||
"strategy": "resume",
|
||||
"resume_from": "WFS-test-{session}-IMPL-001"
|
||||
},
|
||||
"meta": {
|
||||
"type": "code-validation",
|
||||
"agent": "@test-fix-agent"
|
||||
},
|
||||
"context": {
|
||||
"requirements": [
|
||||
"Validate L0.1-L0.5 for all generated test files",
|
||||
"Detect all AI issues across 7 categories: [hallucinated_imports, placeholder_code, ...]",
|
||||
"Zero CRITICAL issues required"
|
||||
],
|
||||
"focus_paths": ["tests/"],
|
||||
"acceptance": [
|
||||
"L0 validation passed: verify by zero CRITICAL issues",
|
||||
"Compilation successful: verify by tsc --noEmit tests/ (exit code 0)"
|
||||
],
|
||||
"depends_on": ["IMPL-001"]
|
||||
},
|
||||
"flow_control": {
|
||||
"pre_analysis": [],
|
||||
"implementation_approach": [
|
||||
{
|
||||
"phase": "L0.1 Compilation Check",
|
||||
"validation": "tsc --noEmit tests/"
|
||||
},
|
||||
{
|
||||
"phase": "L0.2 Import Validity",
|
||||
"validation": "Check all imports against package.json and node_modules"
|
||||
},
|
||||
{
|
||||
"phase": "L0.5 AI Issue Detection",
|
||||
"validation": "Scan for all 7 AI issue categories with severity levels"
|
||||
}
|
||||
],
|
||||
"target_files": [],
|
||||
"ai_issue_scan": {
|
||||
"categories": [
|
||||
"hallucinated_imports",
|
||||
"placeholder_code",
|
||||
"mock_leakage",
|
||||
"type_abuse",
|
||||
"naming_issues",
|
||||
"control_flow",
|
||||
"resource_leaks",
|
||||
"security_issues"
|
||||
],
|
||||
"severity_levels": ["CRITICAL", "ERROR", "WARNING"],
|
||||
"auto_fix_enabled": true,
|
||||
"max_retries": 2,
|
||||
"thresholds": {
|
||||
"critical": 0,
|
||||
"error": 3,
|
||||
"warning": 10
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
**Task 3: IMPL-001.5-review.json (Test Quality Gate)**
|
||||
```json
|
||||
{
|
||||
"id": "IMPL-001.5",
|
||||
"title": "Test quality gate - anti-patterns and coverage",
|
||||
"status": "pending",
|
||||
"context_package_path": ".workflow/active/WFS-test-{session}/.process/test-context-package.json",
|
||||
"cli_execution_id": "WFS-test-{session}-IMPL-001.5",
|
||||
"cli_execution": {
|
||||
"strategy": "resume",
|
||||
"resume_from": "WFS-test-{session}-IMPL-001.3"
|
||||
},
|
||||
"meta": {
|
||||
"type": "test-quality-review",
|
||||
"agent": "@test-fix-agent"
|
||||
},
|
||||
"context": {
|
||||
"requirements": [
|
||||
"Validate layer completeness: L1.1 100%, L1.2 80%, L1.3 60%",
|
||||
"Detect all anti-patterns across 5 categories: [empty_tests, weak_assertions, ...]",
|
||||
"Verify coverage: line ≥80%, branch ≥70%, function ≥90%"
|
||||
],
|
||||
"focus_paths": ["tests/"],
|
||||
"acceptance": [
|
||||
"Coverage ≥80%: verify by npm test -- --coverage | grep 'All files.*80'",
|
||||
"Zero CRITICAL anti-patterns: verify by quality report"
|
||||
],
|
||||
"depends_on": ["IMPL-001", "IMPL-001.3"]
|
||||
},
|
||||
"flow_control": {
|
||||
"pre_analysis": [],
|
||||
"implementation_approach": [
|
||||
{
|
||||
"phase": "Static Analysis",
|
||||
"validation": "Lint test files, check anti-patterns"
|
||||
},
|
||||
{
|
||||
"phase": "Coverage Analysis",
|
||||
"validation": "Calculate coverage percentage, identify gaps"
|
||||
},
|
||||
{
|
||||
"phase": "Quality Metrics",
|
||||
"validation": "Verify thresholds, layer completeness"
|
||||
}
|
||||
],
|
||||
"target_files": [],
|
||||
"quality_gates": {
|
||||
"layer_completeness": {
|
||||
"L1.1": "100%",
|
||||
"L1.2": "80%",
|
||||
"L1.3": "60%",
|
||||
"L1.4": "80%",
|
||||
"L1.5": "100%",
|
||||
"L2": "70%"
|
||||
},
|
||||
"anti_patterns": [
|
||||
"empty_tests",
|
||||
"weak_assertions",
|
||||
"test_isolation",
|
||||
"incomplete_coverage",
|
||||
"ai_generated_issues"
|
||||
],
|
||||
"coverage_thresholds": {
|
||||
"line": "80%",
|
||||
"branch": "70%",
|
||||
"function": "90%"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
**Task 4: IMPL-002.json (Test Execution & Fix)**
|
||||
```json
|
||||
{
|
||||
"id": "IMPL-002",
|
||||
"title": "Test execution and fix cycle",
|
||||
"status": "pending",
|
||||
"context_package_path": ".workflow/active/WFS-test-{session}/.process/test-context-package.json",
|
||||
"cli_execution_id": "WFS-test-{session}-IMPL-002",
|
||||
"cli_execution": {
|
||||
"strategy": "resume",
|
||||
"resume_from": "WFS-test-{session}-IMPL-001.5"
|
||||
},
|
||||
"meta": {
|
||||
"type": "test-fix",
|
||||
"agent": "@test-fix-agent"
|
||||
},
|
||||
"context": {
|
||||
"requirements": [
|
||||
"Execute all tests and fix failures until pass rate ≥95%",
|
||||
"Maximum 5 fix iterations",
|
||||
"Use Gemini for diagnosis, agent for fixes"
|
||||
],
|
||||
"focus_paths": ["tests/", "src/"],
|
||||
"acceptance": [
|
||||
"All tests pass: verify by npm test (exit code 0)",
|
||||
"Pass rate ≥95%: verify by test output"
|
||||
],
|
||||
"depends_on": ["IMPL-001", "IMPL-001.3", "IMPL-001.5"]
|
||||
},
|
||||
"flow_control": {
|
||||
"pre_analysis": [],
|
||||
"implementation_approach": [
|
||||
{
|
||||
"phase": "Initial Test Execution",
|
||||
"command": "npm test"
|
||||
},
|
||||
{
|
||||
"phase": "Iterative Fix Cycle",
|
||||
"steps": [
|
||||
"Diagnose failures with Gemini",
|
||||
"Apply fixes via agent or CLI",
|
||||
"Re-run tests",
|
||||
"Repeat until pass rate ≥95% or max iterations"
|
||||
],
|
||||
"max_iterations": 5
|
||||
}
|
||||
],
|
||||
"target_files": [],
|
||||
"test_fix_cycle": {
|
||||
"max_iterations": 5,
|
||||
"diagnosis_tool": "gemini",
|
||||
"fix_mode": "agent",
|
||||
"exit_conditions": ["all_tests_pass", "max_iterations_reached"]
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
#### Phase 3: Document Generation
|
||||
|
||||
```
|
||||
1. Create IMPL_PLAN.md (test-specific variant)
|
||||
- frontmatter: workflow_type="test_session", test_framework, coverage_targets
|
||||
- Test Generation Phase: L1-L3 layer breakdown
|
||||
- Quality Gates: IMPL-001.3 and IMPL-001.5 specifications
|
||||
- Test-Fix Cycle: Iteration strategy with diagnosis and fix modes
|
||||
- Source Session Context: If exists (from source_session_id)
|
||||
|
||||
2. Create TODO_LIST.md
|
||||
- Hierarchical structure with test phase containers
|
||||
- Links to task JSONs with status markers
|
||||
- Test layer indicators (L0, L1, L2, L3)
|
||||
- Quality gate indicators (validation, review)
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 2. Output Validation
|
||||
|
||||
### Task JSON Validation
|
||||
|
||||
**IMPL-001 Requirements**:
|
||||
- All L1.1-L1.5 tests explicitly defined for each target function
|
||||
- Project type template correctly applied
|
||||
- Reusable test tools and test commands included
|
||||
- Implementation approach includes all 3 phases (L1, L2, L3)
|
||||
|
||||
**IMPL-001.3 Requirements**:
|
||||
- All 7 AI issue categories included
|
||||
- Severity levels properly assigned
|
||||
- Auto-fix logic for ERROR and below
|
||||
- Acceptance criteria references zero CRITICAL rule
|
||||
|
||||
**IMPL-001.5 Requirements**:
|
||||
- Layer completeness thresholds: L1.1 100%, L1.2 80%, L1.3 60%
|
||||
- All 5 anti-pattern categories included
|
||||
- Coverage metrics: Line 80%, Branch 70%, Function 90%
|
||||
- Acceptance criteria references all thresholds
|
||||
|
||||
**IMPL-002 Requirements**:
|
||||
- Depends on: IMPL-001, IMPL-001.3, IMPL-001.5 (sequential)
|
||||
- Max iterations: 5
|
||||
- Diagnosis tool: Gemini
|
||||
- Exit conditions: all_tests_pass OR max_iterations_reached
|
||||
|
||||
### Quality Standards
|
||||
|
||||
Hard Constraints:
|
||||
- Task count: minimum 4, maximum 18
|
||||
- All requirements quantified from TEST_ANALYSIS_RESULTS.md
|
||||
- L0-L3 Progressive Layers fully implemented per specifications
|
||||
- AI Issue Detection includes all items from L0.5 checklist
|
||||
- Project Type Template correctly applied
|
||||
- Test Anti-Patterns validation rules implemented
|
||||
- Layer Completeness Thresholds met
|
||||
- Quality Metrics targets: Line 80%, Branch 70%, Function 90%
|
||||
|
||||
---
|
||||
|
||||
## 3. Success Criteria
|
||||
|
||||
- All test planning documents generated successfully
|
||||
- Task count reported: minimum 4
|
||||
- Test framework correctly detected and reported
|
||||
- Coverage targets clearly specified: L0 zero errors, L1 80%+, L2 70%+
|
||||
- L0-L3 layers explicitly defined in IMPL-001 task
|
||||
- AI issue detection configured in IMPL-001.3
|
||||
- Quality gates with measurable thresholds in IMPL-001.5
|
||||
- Source session status reported (if applicable)
|
||||
@@ -28,6 +28,8 @@ You are a test context discovery specialist focused on gathering test coverage i
|
||||
|
||||
## Tool Arsenal
|
||||
|
||||
**Search Tool Priority**: ACE (`mcp__ace-tool__search_context`) → CCW (`mcp__ccw-tools__smart_search`) / Built-in (`Grep`, `Glob`, `Read`)
|
||||
|
||||
### 1. Session & Implementation Context
|
||||
**Tools**:
|
||||
- `Read()` - Load session metadata and implementation summaries
|
||||
|
||||
@@ -51,6 +51,11 @@ You will execute tests across multiple layers, analyze failures with layer-speci
|
||||
|
||||
## Execution Process
|
||||
|
||||
### 0. Task Status: Mark In Progress
|
||||
```bash
|
||||
jq --arg ts "$(date -Iseconds)" '.status="in_progress" | .status_history += [{"from":.status,"to":"in_progress","changed_at":$ts}]' IMPL-X.json > tmp.json && mv tmp.json IMPL-X.json
|
||||
```
|
||||
|
||||
### Flow Control Execution
|
||||
When task JSON contains `flow_control` field, execute preparation and implementation steps systematically.
|
||||
|
||||
@@ -59,6 +64,14 @@ When task JSON contains `flow_control` field, execute preparation and implementa
|
||||
2. **Variable Substitution**: Use `[variable_name]` to reference previous outputs
|
||||
3. **Error Handling**: Follow step-specific strategies (`skip_optional`, `fail`, `retry_once`)
|
||||
|
||||
**Command-to-Tool Mapping** (for pre_analysis commands):
|
||||
```
|
||||
"Read(path)" → Read tool: Read(file_path=path)
|
||||
"bash(command)" → Bash tool: Bash(command=command)
|
||||
"Search(pattern,path)" → Grep tool: Grep(pattern=pattern, path=path)
|
||||
"Glob(pattern)" → Glob tool: Glob(pattern=pattern)
|
||||
```
|
||||
|
||||
**Implementation Approach** (`flow_control.implementation_approach`):
|
||||
When task JSON contains implementation_approach array:
|
||||
1. **Sequential Execution**: Process steps in order, respecting `depends_on` dependencies
|
||||
@@ -70,9 +83,15 @@ When task JSON contains implementation_approach array:
|
||||
- `description`: Detailed description with variable references
|
||||
- `modification_points`: Test and code modification targets
|
||||
- `logic_flow`: Test-fix iteration sequence
|
||||
- `command`: Optional CLI command (only when explicitly specified)
|
||||
- `depends_on`: Array of step numbers that must complete first
|
||||
- `output`: Variable name for this step's output
|
||||
5. **Execution Mode Selection**:
|
||||
- Based on `meta.execution_config.method`:
|
||||
- `"cli"` → Build CLI command via buildCliHandoffPrompt() and execute via Bash tool
|
||||
- `"agent"` (default) → Agent direct execution:
|
||||
- Parse `modification_points` as files to modify
|
||||
- Follow `logic_flow` for test-fix iteration
|
||||
- Use test_commands from flow_control for test execution
|
||||
|
||||
|
||||
### 1. Context Assessment & Test Discovery
|
||||
@@ -83,7 +102,7 @@ When task JSON contains implementation_approach array:
|
||||
- L1 (Unit): `*.test.*`, `*.spec.*` in `__tests__/`, `tests/unit/`
|
||||
- L2 (Integration): `tests/integration/`, `*.integration.test.*`
|
||||
- L3 (E2E): `tests/e2e/`, `*.e2e.test.*`, `cypress/`, `playwright/`
|
||||
- **context-package.json** (CCW Workflow): Use Read tool to get context package from `.workflow/active/{session}/.process/context-package.json`
|
||||
- **context-package.json** : Use Read tool to get context package from `.workflow/active/{session}/.process/context-package.json`
|
||||
- Identify test commands from project configuration
|
||||
|
||||
```bash
|
||||
@@ -315,9 +334,17 @@ When generating test results for orchestrator (saved to `.process/test-results.j
|
||||
- Pass rate >= 95% + any "high" or "medium" criticality failures → ⚠️ NEEDS FIX (continue iteration)
|
||||
- Pass rate < 95% → ❌ FAILED (continue iteration or abort)
|
||||
|
||||
## Task Status Update
|
||||
|
||||
**Upon task completion**, update task JSON status:
|
||||
```bash
|
||||
jq --arg ts "$(date -Iseconds)" '.status="completed" | .status_history += [{"from":"in_progress","to":"completed","changed_at":$ts}]' IMPL-X.json > tmp.json && mv tmp.json IMPL-X.json
|
||||
```
|
||||
|
||||
## Important Reminders
|
||||
|
||||
**ALWAYS:**
|
||||
- **Search Tool Priority**: ACE (`mcp__ace-tool__search_context`) → CCW (`mcp__ccw-tools__smart_search`) / Built-in (`Grep`, `Glob`, `Read`)
|
||||
- **Execute tests first** - Understand what's failing before fixing
|
||||
- **Diagnose thoroughly** - Find root cause, not just symptoms
|
||||
- **Fix minimally** - Change only what's needed to pass tests
|
||||
|
||||
@@ -284,6 +284,8 @@ You execute 6 distinct task types organized into 3 patterns. Each task includes
|
||||
|
||||
### ALWAYS
|
||||
|
||||
**Search Tool Priority**: ACE (`mcp__ace-tool__search_context`) → CCW (`mcp__ccw-tools__smart_search`) / Built-in (`Grep`, `Glob`, `Read`)
|
||||
|
||||
**W3C Format Compliance**: ✅ Include $schema in all token files | ✅ Use $type metadata for all tokens | ✅ Use $value wrapper for color (light/dark), duration, easing | ✅ Validate token structure against W3C spec
|
||||
|
||||
**Pattern Recognition**: ✅ Identify pattern from [TASK_TYPE_IDENTIFIER] first | ✅ Apply pattern-specific execution rules | ✅ Follow autonomy level
|
||||
|
||||
@@ -120,7 +120,11 @@ Before completing any task, verify:
|
||||
- Make assumptions - verify with existing materials
|
||||
- Skip quality verification steps
|
||||
|
||||
**Bash Tool**:
|
||||
- Use `run_in_background=false` for all Bash/CLI calls to ensure foreground execution
|
||||
|
||||
**ALWAYS:**
|
||||
- **Search Tool Priority**: ACE (`mcp__ace-tool__search_context`) → CCW (`mcp__ccw-tools__smart_search`) / Built-in (`Grep`, `Glob`, `Read`)
|
||||
- Verify resource/dependency existence before referencing
|
||||
- Execute tasks systematically and incrementally
|
||||
- Test and validate work thoroughly
|
||||
|
||||
18
.claude/cli-settings.json
Normal file
18
.claude/cli-settings.json
Normal file
@@ -0,0 +1,18 @@
|
||||
{
|
||||
"version": "1.0.0",
|
||||
"defaultTool": "gemini",
|
||||
"promptFormat": "plain",
|
||||
"smartContext": {
|
||||
"enabled": false,
|
||||
"maxFiles": 10
|
||||
},
|
||||
"nativeResume": true,
|
||||
"recursiveQuery": true,
|
||||
"cache": {
|
||||
"injectionMode": "auto",
|
||||
"defaultPrefix": "",
|
||||
"defaultSuffix": ""
|
||||
},
|
||||
"codeIndexMcp": "ace",
|
||||
"$schema": "./cli-settings.schema.json"
|
||||
}
|
||||
1102
.claude/commands/ccw-coordinator.md
Normal file
1102
.claude/commands/ccw-coordinator.md
Normal file
File diff suppressed because it is too large
Load Diff
364
.claude/commands/ccw-debug.md
Normal file
364
.claude/commands/ccw-debug.md
Normal file
@@ -0,0 +1,364 @@
|
||||
---
|
||||
name: ccw-debug
|
||||
description: Debug coordinator - analyze issue, select debug strategy, execute debug workflow in main process
|
||||
argument-hint: "[--mode cli|debug|test|bidirectional] [--yes|-y] \"bug description\""
|
||||
allowed-tools: Skill(*), TodoWrite(*), AskUserQuestion(*), Read(*), Bash(*)
|
||||
---
|
||||
|
||||
# CCW-Debug Command - Debug Coordinator
|
||||
|
||||
Debug orchestrator: issue analysis → strategy selection → debug execution.
|
||||
|
||||
## Core Concept: Debug Units (调试单元)
|
||||
|
||||
**Definition**: Debug commands grouped into logical units for different root cause strategies.
|
||||
|
||||
**Debug Units**:
|
||||
|
||||
| Unit Type | Pattern | Example |
|
||||
|-----------|---------|---------|
|
||||
| **Quick Diagnosis** | CLI analysis only | cli → recommendation |
|
||||
| **Hypothesis-Driven** | Debug exploration | debug-with-file → apply fix |
|
||||
| **Test-Driven** | Test generation/iteration | test-fix-gen → test-cycle-execute |
|
||||
| **Convergence** | Parallel debug + test | debug + test (parallel) |
|
||||
|
||||
**Atomic Rules**:
|
||||
1. CLI mode: Analysis only, recommendation for user action
|
||||
2. Debug/Test modes: Full cycle (analysis → fix → validate)
|
||||
3. Bidirectional mode: Parallel execution, merge findings
|
||||
|
||||
## Execution Model
|
||||
|
||||
**Synchronous (Main Process)**: Debug commands execute via Skill, blocking until complete.
|
||||
|
||||
```
|
||||
User Input → Analyze Issue → Select Strategy → [Confirm] → Execute Debug
|
||||
↓
|
||||
Skill (blocking)
|
||||
↓
|
||||
Update TodoWrite
|
||||
↓
|
||||
Generate Fix/Report
|
||||
```
|
||||
|
||||
## 5-Phase Workflow
|
||||
|
||||
### Phase 1: Analyze Issue
|
||||
|
||||
**Input** → Extract (description, symptoms) → Assess (error_type, clarity, complexity, scope) → **Analysis**
|
||||
|
||||
| Field | Values |
|
||||
|-------|--------|
|
||||
| error_type | syntax \| logic \| async \| integration \| unknown |
|
||||
| clarity | 0-3 (≥2 = clear) |
|
||||
| complexity | low \| medium \| high |
|
||||
| scope | single-module \| cross-module \| system |
|
||||
|
||||
#### Mode Detection (Priority Order)
|
||||
|
||||
```
|
||||
Input Keywords → Mode
|
||||
─────────────────────────────────────────────────────────
|
||||
quick|fast|immediate|recommendation|suggest → cli
|
||||
test|fail|coverage|pass → test
|
||||
multiple|system|distributed|concurrent → bidirectional
|
||||
(default) → debug
|
||||
```
|
||||
|
||||
**Output**: `IssueType: [type] | Clarity: [clarity]/3 | Complexity: [complexity] | RecommendedMode: [mode]`
|
||||
|
||||
---
|
||||
|
||||
### Phase 1.5: Issue Clarification (if clarity < 2)
|
||||
|
||||
```
|
||||
Analysis → Check clarity ≥ 2?
|
||||
↓
|
||||
YES → Continue to Phase 2
|
||||
↓
|
||||
NO → Ask Questions → Update Analysis
|
||||
```
|
||||
|
||||
**Questions Asked**: Error Symptoms, When It Occurs, Affected Components, Reproducibility
|
||||
|
||||
---
|
||||
|
||||
### Phase 2: Select Debug Strategy & Build Command Chain
|
||||
|
||||
```
|
||||
Analysis → Detect Mode (keywords) → Build Command Chain → Debug Workflow
|
||||
```
|
||||
|
||||
#### Command Chain Mapping
|
||||
|
||||
| Mode | Command Chain | Execution |
|
||||
|------|---------------|-----------|
|
||||
| **cli** | ccw cli --mode analysis --rule analysis-diagnose-bug-root-cause | Analysis only |
|
||||
| **debug** | debug-with-file → test-fix-gen → test-cycle-execute | Sequential |
|
||||
| **test** | test-fix-gen → test-cycle-execute | Sequential |
|
||||
| **bidirectional** | (debug-with-file ∥ test-fix-gen ∥ test-cycle-execute) → merge-findings | Parallel → Merge |
|
||||
|
||||
**Note**: `∥` = parallel execution
|
||||
|
||||
**Output**: `Mode: [mode] | Strategy: [strategy] | Commands: [1. /cmd1 2. /cmd2]`
|
||||
|
||||
---
|
||||
|
||||
### Phase 3: User Confirmation
|
||||
|
||||
```
|
||||
Debug Chain → Show Strategy → Ask User → User Decision:
|
||||
- ✓ Confirm → Continue to Phase 4
|
||||
- ⚙ Change Mode → Select Different Mode (back to Phase 2)
|
||||
- ✗ Cancel → Abort
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### Phase 4: Setup TODO Tracking & Status File
|
||||
|
||||
```
|
||||
Debug Chain → Create Session Dir → Initialize Tracking → Tracking State
|
||||
```
|
||||
|
||||
**Session Structure**:
|
||||
```
|
||||
Session ID: CCWD-{issue-slug}-{date}
|
||||
Session Dir: .workflow/.ccw-debug/{session_id}/
|
||||
|
||||
TodoWrite:
|
||||
CCWD:{mode}: [1/n] /command1 [in_progress]
|
||||
CCWD:{mode}: [2/n] /command2 [pending]
|
||||
...
|
||||
|
||||
status.json:
|
||||
{
|
||||
"session_id": "CCWD-...",
|
||||
"mode": "debug|cli|test|bidirectional",
|
||||
"status": "running",
|
||||
"parallel_execution": false|true,
|
||||
"issue": { description, error_type, clarity, complexity },
|
||||
"command_chain": [...],
|
||||
"findings": { debug, test, merged }
|
||||
}
|
||||
```
|
||||
|
||||
**Output**:
|
||||
- TODO: `-> CCWD:debug: [1/3] /workflow:debug-with-file | ...`
|
||||
- Status File: `.workflow/.ccw-debug/{session_id}/status.json`
|
||||
|
||||
---
|
||||
|
||||
### Phase 5: Execute Debug Chain
|
||||
|
||||
#### For Bidirectional Mode (Parallel Execution)
|
||||
|
||||
```
|
||||
Start Commands (parallel) → Execute debug-with-file ∥ test-fix-gen ∥ test-cycle-execute
|
||||
↓
|
||||
Collect Results → Merge Findings
|
||||
↓
|
||||
Update status.json (findings.merged)
|
||||
↓
|
||||
Mark completed
|
||||
```
|
||||
|
||||
#### For Sequential Modes (cli, debug, test)
|
||||
|
||||
```
|
||||
Start Command → Update status (running) → Execute via Skill → Result
|
||||
↓
|
||||
CLI Mode? → YES → Ask Escalation → Escalate or Done
|
||||
→ NO → Continue
|
||||
↓
|
||||
Update status (completed) → Next Command
|
||||
↓
|
||||
Error? → YES → Ask Action (Retry/Skip/Abort)
|
||||
→ NO → Continue
|
||||
```
|
||||
|
||||
#### Error Handling Pattern
|
||||
|
||||
```
|
||||
Command Error → Update status (failed) → Ask User:
|
||||
- Retry → Re-execute (same index)
|
||||
- Skip → Continue next command
|
||||
- Abort → Stop execution
|
||||
```
|
||||
|
||||
#### CLI Mode Escalation
|
||||
|
||||
```
|
||||
CLI Result → Findings.confidence?
|
||||
↓
|
||||
High → Present findings → User decides:
|
||||
• Done (end here)
|
||||
• Escalate to debug mode
|
||||
• Escalate to test mode
|
||||
↓
|
||||
Low → Recommend escalation
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Execution Flow Summary
|
||||
|
||||
```
|
||||
User Input
|
||||
|
|
||||
Phase 1: Analyze Issue
|
||||
|-- Extract: description, error_type, clarity, complexity, scope
|
||||
+-- If clarity < 2 -> Phase 1.5: Clarify Issue
|
||||
|
|
||||
Phase 2: Select Debug Strategy & Build Chain
|
||||
|-- Detect mode: cli | debug | test | bidirectional
|
||||
|-- Build command chain based on mode
|
||||
|-- Parallel execution for bidirectional
|
||||
+-- Consider escalation points (cli → debug/test)
|
||||
|
|
||||
Phase 3: User Confirmation (optional)
|
||||
|-- Show debug strategy
|
||||
+-- Allow mode change
|
||||
|
|
||||
Phase 4: Setup TODO Tracking & Status File
|
||||
|-- Create todos with CCWD prefix
|
||||
+-- Initialize .workflow/.ccw-debug/{session_id}/status.json
|
||||
|
|
||||
Phase 5: Execute Debug Chain
|
||||
|-- For sequential modes: execute commands in order
|
||||
|-- For bidirectional: execute debug + test in parallel
|
||||
|-- CLI mode: present findings, ask for escalation
|
||||
|-- Merge findings (bidirectional mode)
|
||||
+-- Update status and TODO
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Debug Pipeline Examples
|
||||
|
||||
| Issue | Mode | Pipeline |
|
||||
|-------|------|----------|
|
||||
| "Login timeout error (quick)" | cli | ccw cli → analysis → (escalate or done) |
|
||||
| "User login fails intermittently" | debug | debug-with-file → test-gen → test-cycle |
|
||||
| "Authentication tests failing" | test | test-fix-gen → test-cycle-execute |
|
||||
| "Multi-module auth + db sync issue" | bidirectional | (debug ∥ test) → merge findings |
|
||||
|
||||
**Legend**: `∥` = parallel execution
|
||||
|
||||
---
|
||||
|
||||
## State Management
|
||||
|
||||
### Dual Tracking System
|
||||
|
||||
**1. TodoWrite-Based Tracking** (UI Display):
|
||||
|
||||
```
|
||||
// Initial state (debug mode)
|
||||
CCWD:debug: [1/3] /workflow:debug-with-file [in_progress]
|
||||
CCWD:debug: [2/3] /workflow:test-fix-gen [pending]
|
||||
CCWD:debug: [3/3] /workflow:test-cycle-execute [pending]
|
||||
|
||||
// CLI mode: only 1 command
|
||||
CCWD:cli: [1/1] ccw cli --mode analysis [in_progress]
|
||||
|
||||
// Bidirectional mode
|
||||
CCWD:bidirectional: [1/3] /workflow:debug-with-file [in_progress] ∥
|
||||
CCWD:bidirectional: [2/3] /workflow:test-fix-gen [in_progress] ∥
|
||||
CCWD:bidirectional: [3/3] /workflow:test-cycle-execute [in_progress]
|
||||
CCWD:bidirectional: [4/4] merge-findings [pending]
|
||||
```
|
||||
|
||||
**2. Status.json Tracking**: Persistent state for debug monitoring.
|
||||
|
||||
**Location**: `.workflow/.ccw-debug/{session_id}/status.json`
|
||||
|
||||
**Structure**:
|
||||
```json
|
||||
{
|
||||
"session_id": "CCWD-auth-timeout-2025-02-02",
|
||||
"mode": "debug",
|
||||
"status": "running|completed|failed",
|
||||
"parallel_execution": false,
|
||||
"created_at": "2025-02-02T10:00:00Z",
|
||||
"updated_at": "2025-02-02T10:05:00Z",
|
||||
"issue": {
|
||||
"description": "User login timeout after 30 seconds",
|
||||
"error_type": "async",
|
||||
"clarity": 3,
|
||||
"complexity": "medium"
|
||||
},
|
||||
"command_chain": [
|
||||
{ "index": 0, "command": "/workflow:debug-with-file", "unit": "sequential", "status": "completed" },
|
||||
{ "index": 1, "command": "/workflow:test-fix-gen", "unit": "sequential", "status": "in_progress" },
|
||||
{ "index": 2, "command": "/workflow:test-cycle-execute", "unit": "sequential", "status": "pending" }
|
||||
],
|
||||
"current_index": 1,
|
||||
"findings": {
|
||||
"debug": { "root_cause": "...", "confidence": "high" },
|
||||
"test": { "failure_pattern": "..." },
|
||||
"merged": null
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
**Status Values**:
|
||||
- `running`: Debug workflow in progress
|
||||
- `completed`: Debug finished, fix applied
|
||||
- `failed`: Debug aborted or unfixable
|
||||
|
||||
**Mode-Specific Fields**:
|
||||
- `cli` mode: No findings field (recommendation-only)
|
||||
- `debug`/`test`: Single finding source
|
||||
- `bidirectional`: All three findings + merged result
|
||||
|
||||
---
|
||||
|
||||
## Key Design Principles
|
||||
|
||||
1. **Issue-Focused** - Diagnose root cause, not symptoms
|
||||
2. **Mode-Driven** - 4 debug strategies for different issues
|
||||
3. **Parallel Capability** - Bidirectional mode for complex systems
|
||||
4. **Escalation Support** - CLI → debug/test mode progression
|
||||
5. **Quick Diagnosis** - CLI mode for immediate recommendations
|
||||
6. **TODO Tracking** - Use CCWD prefix to isolate debug todos
|
||||
7. **Finding Convergence** - Merge parallel results for consensus
|
||||
---
|
||||
|
||||
## Usage
|
||||
|
||||
```bash
|
||||
# Auto-select mode
|
||||
/ccw-debug "Login failed: token validation error"
|
||||
|
||||
# Explicit mode selection
|
||||
/ccw-debug --mode cli "Quick diagnosis: API 500 error"
|
||||
/ccw-debug --mode debug "User profile sync intermittent failure"
|
||||
/ccw-debug --mode test "Permission check failing"
|
||||
/ccw-debug --mode bidirectional "Multi-module auth + cache sync issue"
|
||||
|
||||
# Auto mode (skip confirmations)
|
||||
/ccw-debug --yes "Production hotfix: database connection timeout"
|
||||
|
||||
# Resume or escalate from previous session
|
||||
/ccw-debug --mode debug --source-session CCWD-login-timeout-2025-01-27
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Mode Selection Decision Tree
|
||||
|
||||
```
|
||||
User calls: /ccw-debug "issue description"
|
||||
|
||||
├─ Keywords: "quick", "fast", "recommendation"
|
||||
│ └─ Mode: CLI (2-5 min analysis, optional escalation)
|
||||
│
|
||||
├─ Keywords: "test", "fail", "coverage"
|
||||
│ └─ Mode: Test (automated iteration, ≥95% pass)
|
||||
│
|
||||
├─ Keywords: "multiple", "system", "distributed"
|
||||
│ └─ Mode: Bidirectional (parallel debug + test)
|
||||
│
|
||||
└─ Default → Debug (full hypothesis-driven workflow)
|
||||
```
|
||||
456
.claude/commands/ccw-plan.md
Normal file
456
.claude/commands/ccw-plan.md
Normal file
@@ -0,0 +1,456 @@
|
||||
---
|
||||
name: ccw-plan
|
||||
description: Planning coordinator - analyze requirements, select planning strategy, execute planning workflow in main process
|
||||
argument-hint: "[--mode lite|multi-cli|full|plan-verify|replan|cli|issue|rapid-to-issue|brainstorm-with-file|analyze-with-file] [--yes|-y] \"task description\""
|
||||
allowed-tools: Skill(*), TodoWrite(*), AskUserQuestion(*), Read(*), Grep(*), Glob(*)
|
||||
---
|
||||
|
||||
# CCW-Plan Command - Planning Coordinator
|
||||
|
||||
Planning orchestrator: requirement analysis → strategy selection → planning execution.
|
||||
|
||||
## Core Concept: Planning Units (规划单元)
|
||||
|
||||
**Definition**: Planning commands are grouped into logical units based on verification requirements and collaboration strategies.
|
||||
|
||||
**Planning Units**:
|
||||
|
||||
| Unit Type | Pattern | Example |
|
||||
|-----------|---------|---------|
|
||||
| **Quick Planning** | plan-cmd (no verify) | lite-plan |
|
||||
| **Verified Planning** | plan-cmd → verify-cmd | plan → plan-verify |
|
||||
| **Collaborative Planning** | multi-cli-plan (implicit verify) | multi-cli-plan |
|
||||
| **With-File Planning** | brainstorm-with-file or analyze-with-file | brainstorm + plan options |
|
||||
| **CLI-Assisted Planning** | ccw cli (analysis) → recommendations | quick analysis + decision |
|
||||
| **Issue Workflow Planning** | plan → issue workflow (discover/queue/execute) | rapid-to-issue bridge |
|
||||
|
||||
**Atomic Rules**:
|
||||
1. Lite mode: No verification (fast iteration)
|
||||
2. Plan-verify mode: Mandatory quality gate
|
||||
3. Multi-cli/Full mode: Optional verification (via --skip-verify flag)
|
||||
4. With-File modes: Self-contained iteration with built-in post-completion options
|
||||
5. CLI mode: Quick analysis, user-driven decisions
|
||||
6. Issue modes: Planning integrated into issue workflow lifecycle
|
||||
|
||||
## Execution Model
|
||||
|
||||
**Synchronous (Main Process)**: Planning commands execute via Skill, blocking until complete.
|
||||
|
||||
```
|
||||
User Input → Analyze Requirements → Select Strategy → [Confirm] → Execute Planning
|
||||
↓
|
||||
Skill (blocking)
|
||||
↓
|
||||
Update TodoWrite
|
||||
↓
|
||||
Generate Artifacts
|
||||
```
|
||||
|
||||
## 5-Phase Workflow
|
||||
|
||||
### Phase 1: Analyze Requirements
|
||||
|
||||
**Input** → Extract (goal, scope, constraints) → Assess (complexity, clarity, criticality) → **Analysis**
|
||||
|
||||
| Field | Values |
|
||||
|-------|--------|
|
||||
| complexity | low \| medium \| high |
|
||||
| clarity | 0-3 (≥2 = clear) |
|
||||
| criticality | normal \| high \| critical |
|
||||
| scope | single-module \| cross-module \| system \| batch-issues |
|
||||
|
||||
**Output**: `Type: [task_type] | Goal: [goal] | Complexity: [complexity] | Clarity: [clarity]/3 | Criticality: [criticality]`
|
||||
|
||||
---
|
||||
|
||||
### Phase 1.5: Requirement Clarification (if clarity < 2)
|
||||
|
||||
```
|
||||
Analysis → Check clarity ≥ 2?
|
||||
↓
|
||||
YES → Continue to Phase 2
|
||||
↓
|
||||
NO → Ask Questions → Update Analysis
|
||||
```
|
||||
|
||||
**Questions Asked**: Goal (Create/Fix/Optimize/Analyze), Scope (Single file/Module/Cross-module/System), Constraints (Backward compat/Skip tests/Urgent hotfix)
|
||||
|
||||
---
|
||||
|
||||
### Phase 2: Select Planning Strategy & Build Command Chain
|
||||
|
||||
```
|
||||
Analysis → Detect Mode (keywords) → Build Command Chain → Planning Workflow
|
||||
```
|
||||
|
||||
#### Mode Detection (Priority Order)
|
||||
|
||||
```
|
||||
Input Keywords → Mode
|
||||
───────────────────────────────────────────────────────────────────────────────
|
||||
quick|fast|immediate|recommendation|suggest → cli
|
||||
issues?|batch|issue workflow|structured workflow|queue → issue
|
||||
issue transition|rapid.*issue|plan.*issue|convert.*issue → rapid-to-issue
|
||||
brainstorm|ideation|头脑风暴|创意|发散思维|multi-perspective → brainstorm-with-file
|
||||
analyze.*document|explore.*concept|collaborative analysis → analyze-with-file
|
||||
production|critical|payment|auth → plan-verify
|
||||
adjust|modify|change plan → replan
|
||||
uncertain|explore → full
|
||||
complex|multiple module|integrate → multi-cli
|
||||
(default) → lite
|
||||
```
|
||||
|
||||
#### Command Chain Mapping
|
||||
|
||||
| Mode | Command Chain | Verification | Use Case |
|
||||
|------|---------------|--------------|----------|
|
||||
| **cli** | ccw cli --mode analysis --rule planning-* | None | Quick planning recommendation |
|
||||
| **issue** | /issue:discover → /issue:plan → /issue:queue → /issue:execute | Optional | Batch issue planning & execution |
|
||||
| **rapid-to-issue** | lite-plan → /issue:convert-to-plan → queue → execute | Optional | Quick planning → Issue workflow bridge |
|
||||
| **brainstorm-with-file** | /workflow:brainstorm-with-file → (plan/issue options) | Self-contained | Multi-perspective ideation |
|
||||
| **analyze-with-file** | /workflow:analyze-with-file → (plan/issue options) | Self-contained | Collaborative architecture analysis |
|
||||
| **lite** | lite-plan | None | Fast simple planning |
|
||||
| **multi-cli** | multi-cli-plan → [plan-verify] | Optional | Multi-model collaborative planning |
|
||||
| **full** | brainstorm → plan → [plan-verify] | Optional | Comprehensive brainstorm + planning |
|
||||
| **plan-verify** | plan → **plan-verify** | **Mandatory** | Production/critical features |
|
||||
| **replan** | replan | None | Plan refinement/adjustment |
|
||||
|
||||
**Note**:
|
||||
- `[ ]` = optional verification
|
||||
- **bold** = mandatory quality gate
|
||||
- With-File modes include built-in post-completion options to create plans/issues
|
||||
|
||||
**Output**: `Mode: [mode] | Strategy: [strategy] | Commands: [1. /cmd1 2. /cmd2]`
|
||||
|
||||
---
|
||||
|
||||
### Phase 3: User Confirmation
|
||||
|
||||
```
|
||||
Planning Chain → Show Strategy → Ask User → User Decision:
|
||||
- ✓ Confirm → Continue to Phase 4
|
||||
- ⚙ Adjust → Change Mode (back to Phase 2)
|
||||
- ✗ Cancel → Abort
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### Phase 4: Setup TODO Tracking & Status File
|
||||
|
||||
```
|
||||
Planning Chain → Create Session Dir → Initialize Tracking → Tracking State
|
||||
```
|
||||
|
||||
**Session Structure**:
|
||||
```
|
||||
Session ID: CCWP-{goal-slug}-{date}
|
||||
Session Dir: .workflow/.ccw-plan/{session_id}/
|
||||
|
||||
TodoWrite:
|
||||
CCWP:{mode}: [1/n] /command1 [in_progress]
|
||||
CCWP:{mode}: [2/n] /command2 [pending]
|
||||
...
|
||||
|
||||
status.json:
|
||||
{
|
||||
"session_id": "CCWP-...",
|
||||
"mode": "plan-verify",
|
||||
"status": "running",
|
||||
"command_chain": [...],
|
||||
"quality_gate": "pending" // plan-verify mode only
|
||||
}
|
||||
```
|
||||
|
||||
**Output**:
|
||||
- TODO: `-> CCWP:plan-verify: [1/2] /workflow:plan | ...`
|
||||
- Status File: `.workflow/.ccw-plan/{session_id}/status.json`
|
||||
|
||||
---
|
||||
|
||||
### Phase 5: Execute Planning Chain
|
||||
|
||||
```
|
||||
Start Command → Update status (running) → Execute via Skill → Result
|
||||
```
|
||||
|
||||
#### For Plan-Verify Mode (Quality Gate)
|
||||
|
||||
```
|
||||
Quality Gate → PASS → Mark completed → Next command
|
||||
↓ FAIL (plan-verify mode)
|
||||
Ask User → Refine: replan + re-verify
|
||||
→ Override: continue anyway
|
||||
→ Abort: stop planning
|
||||
```
|
||||
|
||||
#### Error Handling Pattern
|
||||
|
||||
```
|
||||
Command Error → Update status (failed) → Ask User:
|
||||
- Retry → Re-execute (same index)
|
||||
- Skip → Continue next command
|
||||
- Abort → Stop execution
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Planning Pipeline Examples
|
||||
|
||||
| Input | Mode | Pipeline | Use Case |
|
||||
|-------|------|----------|----------|
|
||||
| "Quick: should we use OAuth2?" | cli | ccw cli --mode analysis → recommendation | Immediate planning advice |
|
||||
| "Plan user login system" | lite | lite-plan | Fast simple planning |
|
||||
| "Implement OAuth2 auth" | multi-cli | multi-cli-plan → [plan-verify] | Multi-model collaborative planning |
|
||||
| "Design notification system" | full | brainstorm → plan → [plan-verify] | Comprehensive brainstorm + planning |
|
||||
| "Payment processing (prod)" | plan-verify | plan → **plan-verify** | Production critical (mandatory gate) |
|
||||
| "头脑风暴: 用户通知系统重新设计" | brainstorm-with-file | brainstorm-with-file → (plan/issue options) | Multi-perspective ideation |
|
||||
| "协作分析: 认证架构设计决策" | analyze-with-file | analyze-with-file → (plan/issue options) | Collaborative analysis |
|
||||
| "Batch plan: handle 10 pending issues" | issue | /issue:discover → plan → queue → execute | Batch issue planning |
|
||||
| "Plan and create issues" | rapid-to-issue | lite-plan → convert-to-plan → queue → execute | Quick plan → Issue workflow |
|
||||
| "Update existing plan" | replan | replan | Plan refinement/adjustment |
|
||||
|
||||
**Legend**:
|
||||
- `[ ]` = optional verification
|
||||
- **bold** = mandatory quality gate
|
||||
- **With-File modes** include built-in post-completion options to create plans/issues
|
||||
|
||||
---
|
||||
|
||||
## State Management
|
||||
|
||||
### Dual Tracking System
|
||||
|
||||
**1. TodoWrite-Based Tracking** (UI Display):
|
||||
|
||||
```
|
||||
// Plan-verify mode (mandatory quality gate)
|
||||
CCWP:plan-verify: [1/2] /workflow:plan [in_progress]
|
||||
CCWP:plan-verify: [2/2] /workflow:plan-verify [pending]
|
||||
|
||||
// CLI mode (quick recommendations)
|
||||
CCWP:cli: [1/1] ccw cli --mode analysis [in_progress]
|
||||
|
||||
// Issue mode (batch planning)
|
||||
CCWP:issue: [1/4] /issue:discover [in_progress]
|
||||
CCWP:issue: [2/4] /issue:plan [pending]
|
||||
CCWP:issue: [3/4] /issue:queue [pending]
|
||||
CCWP:issue: [4/4] /issue:execute [pending]
|
||||
|
||||
// Rapid-to-issue mode (planning → issue bridge)
|
||||
CCWP:rapid-to-issue: [1/4] /workflow:lite-plan [in_progress]
|
||||
CCWP:rapid-to-issue: [2/4] /issue:convert-to-plan [pending]
|
||||
CCWP:rapid-to-issue: [3/4] /issue:queue [pending]
|
||||
CCWP:rapid-to-issue: [4/4] /issue:execute [pending]
|
||||
|
||||
// Brainstorm-with-file mode (self-contained)
|
||||
CCWP:brainstorm-with-file: [1/1] /workflow:brainstorm-with-file [in_progress]
|
||||
|
||||
// Analyze-with-file mode (self-contained)
|
||||
CCWP:analyze-with-file: [1/1] /workflow:analyze-with-file [in_progress]
|
||||
|
||||
// Lite mode (fast simple planning)
|
||||
CCWP:lite: [1/1] /workflow:lite-plan [in_progress]
|
||||
|
||||
// Multi-CLI mode (collaborative planning)
|
||||
CCWP:multi-cli: [1/1] /workflow:multi-cli-plan [in_progress]
|
||||
|
||||
// Full mode (brainstorm + planning with optional verification)
|
||||
CCWP:full: [1/2] /workflow:brainstorm [in_progress]
|
||||
CCWP:full: [2/2] /workflow:plan [pending]
|
||||
```
|
||||
|
||||
**2. Status.json Tracking**: Persistent state for planning monitoring.
|
||||
|
||||
**Location**: `.workflow/.ccw-plan/{session_id}/status.json`
|
||||
|
||||
**Structure**:
|
||||
```json
|
||||
{
|
||||
"session_id": "CCWP-oauth-auth-2025-02-02",
|
||||
"mode": "plan-verify",
|
||||
"status": "running|completed|failed",
|
||||
"created_at": "2025-02-02T10:00:00Z",
|
||||
"updated_at": "2025-02-02T10:05:00Z",
|
||||
"analysis": {
|
||||
"goal": "Implement OAuth2 authentication",
|
||||
"complexity": "high",
|
||||
"clarity_score": 2,
|
||||
"criticality": "high"
|
||||
},
|
||||
"command_chain": [
|
||||
{ "index": 0, "command": "/workflow:plan", "mandatory": false, "status": "completed" },
|
||||
{ "index": 1, "command": "/workflow:plan-verify", "mandatory": true, "status": "running" }
|
||||
],
|
||||
"current_index": 1,
|
||||
"quality_gate": "pending|PASS|FAIL"
|
||||
}
|
||||
```
|
||||
|
||||
**Status Values**:
|
||||
- `running`: Planning in progress
|
||||
- `completed`: Planning finished successfully
|
||||
- `failed`: Planning aborted or quality gate failed
|
||||
|
||||
**Quality Gate Values** (plan-verify mode only):
|
||||
- `pending`: Verification not started
|
||||
- `PASS`: Plan meets quality standards
|
||||
- `FAIL`: Plan needs refinement
|
||||
|
||||
**Mode-Specific Fields**:
|
||||
- **plan-verify**: `quality_gate` field (pending|PASS|FAIL)
|
||||
- **cli**: No command_chain, stores CLI recommendations and user decision
|
||||
- **issue**: includes issue discovery results and queue configuration
|
||||
- **rapid-to-issue**: includes plan output and conversion to issue
|
||||
- **with-file modes**: stores session artifacts and post-completion options
|
||||
- **other modes**: basic command_chain tracking
|
||||
|
||||
---
|
||||
|
||||
## Extended Planning Modes
|
||||
|
||||
### CLI-Assisted Planning (cli mode)
|
||||
|
||||
```
|
||||
Quick Input → ccw cli --mode analysis --rule planning-* → Recommendations → User Decision:
|
||||
- ✓ Accept → Create lite-plan from recommendations
|
||||
- ↗ Escalate → Switch to multi-cli or full mode
|
||||
- ✗ Done → Stop (recommendation only)
|
||||
```
|
||||
|
||||
**Use Cases**:
|
||||
- Quick architecture decision questions
|
||||
- Planning approach recommendations
|
||||
- Pattern/library selection advice
|
||||
|
||||
**CLI Rules** (auto-selected based on context):
|
||||
- `planning-plan-architecture-design` - Architecture decisions
|
||||
- `planning-breakdown-task-steps` - Task decomposition
|
||||
- `planning-design-component-spec` - Component specifications
|
||||
|
||||
---
|
||||
|
||||
### With-File Planning Workflows
|
||||
|
||||
**With-File workflows** provide documented exploration with multi-CLI collaboration, generating comprehensive session artifacts.
|
||||
|
||||
| Mode | Purpose | Key Features | Output Folder |
|
||||
|------|---------|--------------|---------------|
|
||||
| **brainstorm-with-file** | Multi-perspective ideation | Gemini/Codex/Claude perspectives, diverge-converge | `.workflow/.brainstorm/` |
|
||||
| **analyze-with-file** | Collaborative architecture analysis | Multi-round Q&A, CLI exploration, documented discussions | `.workflow/.analysis/` |
|
||||
|
||||
**Detection Keywords**:
|
||||
- **brainstorm-with-file**: 头脑风暴, 创意, 发散思维, multi-perspective, ideation
|
||||
- **analyze-with-file**: 协作分析, 深度理解, collaborative analysis, explore concept
|
||||
|
||||
**Characteristics**:
|
||||
1. **Self-Contained**: Each workflow handles its own iteration loop
|
||||
2. **Documented Process**: Creates evolving documents (brainstorm.md, discussion.md)
|
||||
3. **Multi-CLI**: Uses Gemini/Codex/Claude for different perspectives
|
||||
4. **Built-in Post-Completion**: Offers follow-up options (create plan, create issue, deep dive)
|
||||
|
||||
---
|
||||
|
||||
### Issue Workflow Integration
|
||||
|
||||
| Mode | Purpose | Command Chain | Typical Use |
|
||||
|------|---------|---------------|-------------|
|
||||
| **issue** | Batch issue planning | discover → plan → queue → execute | Multiple issues in codebase |
|
||||
| **rapid-to-issue** | Quick plan → Issue workflow | lite-plan → convert-to-plan → queue → execute | Fast iteration → structured execution |
|
||||
|
||||
**Issue Workflow Bridge**:
|
||||
```
|
||||
lite-plan (in-memory) → /issue:convert-to-plan → Creates issue JSON
|
||||
↓
|
||||
/issue:queue → Form execution queue
|
||||
↓
|
||||
/issue:execute → DAG-based parallel execution
|
||||
```
|
||||
|
||||
**When to use Issue Workflow**:
|
||||
- Need structured multi-stage execution (queue-based)
|
||||
- Want parallel DAG execution
|
||||
- Multiple related changes as individual commits
|
||||
- Converting brainstorm/plan output to executable tasks
|
||||
|
||||
---
|
||||
|
||||
## Key Design Principles
|
||||
|
||||
1. **Planning-Focused** - Pure planning coordination, no execution
|
||||
2. **Mode-Driven** - 10 planning modes for different needs (lite/multi-cli/full/plan-verify/replan + cli/issue/rapid-to-issue/brainstorm-with-file/analyze-with-file)
|
||||
3. **CLI Integration** - Quick analysis for immediate recommendations
|
||||
4. **With-File Support** - Multi-CLI collaboration with documented artifacts
|
||||
5. **Issue Workflow Bridge** - Seamless transition from planning to structured execution
|
||||
6. **Quality Gates** - Mandatory verification for production features
|
||||
7. **Flexible Verification** - Optional for exploration, mandatory for critical features
|
||||
8. **Progressive Clarification** - Low clarity triggers requirement questions
|
||||
9. **TODO Tracking** - Use CCWP prefix to isolate planning todos
|
||||
10. **Handoff Ready** - Generates artifacts ready for execution phase
|
||||
|
||||
---
|
||||
|
||||
## Usage
|
||||
|
||||
```bash
|
||||
# Auto-select mode (keyword-based detection)
|
||||
/ccw-plan "Add user authentication"
|
||||
|
||||
# Standard planning modes
|
||||
/ccw-plan --mode lite "Add logout endpoint"
|
||||
/ccw-plan --mode multi-cli "Implement OAuth2"
|
||||
/ccw-plan --mode full "Design notification system"
|
||||
/ccw-plan --mode plan-verify "Payment processing (production)"
|
||||
/ccw-plan --mode replan --session WFS-auth-2025-01-28
|
||||
|
||||
# CLI-assisted planning (quick recommendations)
|
||||
/ccw-plan --mode cli "Quick: should we use OAuth2 or JWT?"
|
||||
/ccw-plan --mode cli "Which state management pattern for React app?"
|
||||
|
||||
# With-File workflows (multi-CLI collaboration)
|
||||
/ccw-plan --mode brainstorm-with-file "头脑风暴: 用户通知系统重新设计"
|
||||
/ccw-plan --mode analyze-with-file "协作分析: 认证架构的设计决策"
|
||||
|
||||
# Issue workflow integration
|
||||
/ccw-plan --mode issue "Batch plan: handle all pending security issues"
|
||||
/ccw-plan --mode rapid-to-issue "Plan user profile feature and create issue"
|
||||
|
||||
# Auto mode (skip confirmations)
|
||||
/ccw-plan --yes "Quick feature: user profile endpoint"
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Mode Selection Decision Tree
|
||||
|
||||
```
|
||||
User calls: /ccw-plan "task description"
|
||||
|
||||
├─ Keywords: "quick", "fast", "recommendation"
|
||||
│ └─ Mode: CLI (quick analysis → recommendations)
|
||||
│
|
||||
├─ Keywords: "issue", "batch", "queue"
|
||||
│ └─ Mode: Issue (batch planning → execution queue)
|
||||
│
|
||||
├─ Keywords: "plan.*issue", "rapid.*issue"
|
||||
│ └─ Mode: Rapid-to-Issue (lite-plan → issue bridge)
|
||||
│
|
||||
├─ Keywords: "头脑风暴", "brainstorm", "ideation"
|
||||
│ └─ Mode: Brainstorm-with-file (multi-CLI ideation)
|
||||
│
|
||||
├─ Keywords: "协作分析", "analyze.*document"
|
||||
│ └─ Mode: Analyze-with-file (collaborative analysis)
|
||||
│
|
||||
├─ Keywords: "production", "critical", "payment"
|
||||
│ └─ Mode: Plan-Verify (mandatory quality gate)
|
||||
│
|
||||
├─ Keywords: "adjust", "modify", "change plan"
|
||||
│ └─ Mode: Replan (refine existing plan)
|
||||
│
|
||||
├─ Keywords: "uncertain", "explore"
|
||||
│ └─ Mode: Full (brainstorm → plan → [verify])
|
||||
│
|
||||
├─ Keywords: "complex", "multiple module"
|
||||
│ └─ Mode: Multi-CLI (collaborative planning)
|
||||
│
|
||||
└─ Default → Lite (fast simple planning)
|
||||
```
|
||||
387
.claude/commands/ccw-test.md
Normal file
387
.claude/commands/ccw-test.md
Normal file
@@ -0,0 +1,387 @@
|
||||
---
|
||||
name: ccw-test
|
||||
description: Test coordinator - analyze testing needs, select test strategy, execute test workflow in main process
|
||||
argument-hint: "[--mode gen|fix|verify|tdd] [--yes|-y] \"test description\""
|
||||
allowed-tools: Skill(*), TodoWrite(*), AskUserQuestion(*), Read(*), Bash(*)
|
||||
---
|
||||
|
||||
# CCW-Test Command - Test Coordinator
|
||||
|
||||
Test orchestrator: testing needs analysis → strategy selection → test execution.
|
||||
|
||||
## Core Concept: Test Units (测试单元)
|
||||
|
||||
**Definition**: Test commands grouped into logical units based on testing objectives.
|
||||
|
||||
**Test Units**:
|
||||
|
||||
| Unit Type | Pattern | Example |
|
||||
|-----------|---------|---------|
|
||||
| **Generation Only** | test-gen (no execution) | test-fix-gen |
|
||||
| **Test + Fix Cycle** | test-gen → test-execute-fix | test-fix-gen → test-cycle-execute |
|
||||
| **Verification Only** | existing-tests → execute | execute-tests |
|
||||
| **TDD Cycle** | tdd-plan → tdd-execute → verify | Red-Green-Refactor |
|
||||
|
||||
**Atomic Rules**:
|
||||
1. Gen mode: Generate tests only (no execution)
|
||||
2. Fix mode: Generate + auto-iteration until ≥95% pass
|
||||
3. Verify mode: Execute existing tests + report
|
||||
4. TDD mode: Full Red-Green-Refactor cycle compliance
|
||||
|
||||
## Execution Model
|
||||
|
||||
**Synchronous (Main Process)**: Test commands execute via Skill, blocking until complete.
|
||||
|
||||
```
|
||||
User Input → Analyze Testing Needs → Select Strategy → [Confirm] → Execute Tests
|
||||
↓
|
||||
Skill (blocking)
|
||||
↓
|
||||
Update TodoWrite
|
||||
↓
|
||||
Generate Tests/Results
|
||||
```
|
||||
|
||||
## 5-Phase Workflow
|
||||
|
||||
### Phase 1: Analyze Testing Needs
|
||||
|
||||
**Input** → Extract (description, target_module, existing_tests) → Assess (testing_goal, framework, coverage_target) → **Analysis**
|
||||
|
||||
| Field | Values |
|
||||
|-------|--------|
|
||||
| testing_goal | generate \| fix \| verify \| tdd |
|
||||
| framework | jest \| vitest \| pytest \| ... |
|
||||
| coverage_target | 0-100 (default: 80) |
|
||||
| existing_tests | true \| false |
|
||||
|
||||
#### Mode Detection (Priority Order)
|
||||
|
||||
```
|
||||
Input Keywords → Mode
|
||||
─────────────────────────────────────────────────────────
|
||||
generate|create|write test|need test → gen
|
||||
fix|repair|failing|broken → fix
|
||||
verify|validate|check|run test → verify
|
||||
tdd|test-driven|test first → tdd
|
||||
(default) → fix
|
||||
```
|
||||
|
||||
**Output**: `TestingGoal: [goal] | Mode: [mode] | Target: [module] | Framework: [framework]`
|
||||
|
||||
---
|
||||
|
||||
### Phase 1.5: Testing Clarification (if needed)
|
||||
|
||||
```
|
||||
Analysis → Check testing_goal known?
|
||||
↓
|
||||
YES → Check target_module set?
|
||||
↓
|
||||
YES → Continue to Phase 2
|
||||
↓
|
||||
NO → Ask Questions → Update Analysis
|
||||
```
|
||||
|
||||
**Questions Asked**: Testing Goal, Target Module/Files, Coverage Requirements, Test Framework
|
||||
|
||||
---
|
||||
|
||||
### Phase 2: Select Test Strategy & Build Command Chain
|
||||
|
||||
```
|
||||
Analysis → Detect Mode (keywords) → Build Command Chain → Test Workflow
|
||||
```
|
||||
|
||||
#### Command Chain Mapping
|
||||
|
||||
| Mode | Command Chain | Behavior |
|
||||
|------|---------------|----------|
|
||||
| **gen** | test-fix-gen | Generate only, no execution |
|
||||
| **fix** | test-fix-gen → test-cycle-execute (iterate) | Auto-iteration until ≥95% pass or max iterations |
|
||||
| **verify** | execute-existing-tests → coverage-report | Execute + report only |
|
||||
| **tdd** | tdd-plan → execute → tdd-verify | Red-Green-Refactor cycle compliance |
|
||||
|
||||
**Note**: `(iterate)` = auto-iteration until pass_rate ≥ 95% or max_iterations reached
|
||||
|
||||
**Output**: `Mode: [mode] | Strategy: [strategy] | Commands: [1. /cmd1 2. /cmd2]`
|
||||
|
||||
---
|
||||
|
||||
### Phase 3: User Confirmation
|
||||
|
||||
```
|
||||
Test Chain → Show Strategy → Ask User → User Decision:
|
||||
- ✓ Confirm → Continue to Phase 4
|
||||
- ⚙ Change Mode → Select Different Mode (back to Phase 2)
|
||||
- ✗ Cancel → Abort
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### Phase 4: Setup TODO Tracking & Status File
|
||||
|
||||
```
|
||||
Test Chain → Create Session Dir → Initialize Tracking → Tracking State
|
||||
```
|
||||
|
||||
**Session Structure**:
|
||||
```
|
||||
Session ID: CCWT-{target-module-slug}-{date}
|
||||
Session Dir: .workflow/.ccw-test/{session_id}/
|
||||
|
||||
TodoWrite:
|
||||
CCWT:{mode}: [1/n] /command1 [in_progress]
|
||||
CCWT:{mode}: [2/n] /command2 [pending]
|
||||
...
|
||||
|
||||
status.json:
|
||||
{
|
||||
"session_id": "CCWT-...",
|
||||
"mode": "gen|fix|verify|tdd",
|
||||
"status": "running",
|
||||
"testing": { description, target_module, framework, coverage_target },
|
||||
"command_chain": [...],
|
||||
"test_metrics": { total_tests, passed, failed, pass_rate, iteration_count, coverage }
|
||||
}
|
||||
```
|
||||
|
||||
**Output**:
|
||||
- TODO: `-> CCWT:fix: [1/2] /workflow:test-fix-gen | CCWT:fix: [2/2] /workflow:test-cycle-execute`
|
||||
- Status File: `.workflow/.ccw-test/{session_id}/status.json`
|
||||
|
||||
---
|
||||
|
||||
### Phase 5: Execute Test Chain
|
||||
|
||||
#### For All Modes (Sequential Execution)
|
||||
|
||||
```
|
||||
Start Command → Update status (running) → Execute via Skill → Result
|
||||
↓
|
||||
Update test_metrics → Next Command
|
||||
↓
|
||||
Error? → YES → Ask Action (Retry/Skip/Abort)
|
||||
→ NO → Continue
|
||||
```
|
||||
|
||||
#### For Fix Mode (Auto-Iteration)
|
||||
|
||||
```
|
||||
test-fix-gen completes → test-cycle-execute begins
|
||||
↓
|
||||
Check pass_rate ≥ 95%?
|
||||
↓ ↓
|
||||
YES → Complete NO → Check iteration < max?
|
||||
↓ ↓
|
||||
YES → Iteration NO → Complete
|
||||
| (analyze failures
|
||||
| generate fix
|
||||
| re-execute tests)
|
||||
|
|
||||
└→ Loop back to pass_rate check
|
||||
```
|
||||
|
||||
#### Error Handling Pattern
|
||||
|
||||
```
|
||||
Command Error → Update status (failed) → Ask User:
|
||||
- Retry → Re-execute (same index)
|
||||
- Skip → Continue next command
|
||||
- Abort → Stop execution
|
||||
```
|
||||
|
||||
#### Test Metrics Update
|
||||
|
||||
```
|
||||
After Each Execution → Collect test_metrics:
|
||||
- total_tests: number
|
||||
- passed/failed: count
|
||||
- pass_rate: percentage
|
||||
- iteration_count: increment (fix mode)
|
||||
- coverage: line/branch/function
|
||||
↓
|
||||
Update status.json → Update TODO with iteration info (if fix mode)
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Execution Flow Summary
|
||||
|
||||
```
|
||||
User Input
|
||||
|
|
||||
Phase 1: Analyze Testing Needs
|
||||
|-- Extract: description, testing_goal, target_module, existing_tests
|
||||
+-- If unclear -> Phase 1.5: Clarify Testing Needs
|
||||
|
|
||||
Phase 2: Select Test Strategy & Build Chain
|
||||
|-- Detect mode: gen | fix | verify | tdd
|
||||
|-- Build command chain based on mode
|
||||
+-- Configure iteration limits (fix mode)
|
||||
|
|
||||
Phase 3: User Confirmation (optional)
|
||||
|-- Show test strategy
|
||||
+-- Allow mode change
|
||||
|
|
||||
Phase 4: Setup TODO Tracking & Status File
|
||||
|-- Create todos with CCWT prefix
|
||||
+-- Initialize .workflow/.ccw-test/{session_id}/status.json
|
||||
|
|
||||
Phase 5: Execute Test Chain
|
||||
|-- For each command:
|
||||
| |-- Update status.json (current=running)
|
||||
| |-- Execute via Skill
|
||||
| |-- Test-fix cycle: iterate until ≥95% pass or max iterations
|
||||
| |-- Update test_metrics in status.json
|
||||
| +-- Update TODO status
|
||||
+-- Mark status.json as completed
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Test Pipeline Examples
|
||||
|
||||
| Input | Mode | Pipeline | Iteration |
|
||||
|-------|------|----------|-----------|
|
||||
| "Generate tests for auth module" | gen | test-fix-gen | No execution |
|
||||
| "Fix failing authentication tests" | fix | test-fix-gen → test-cycle-execute (iterate) | Max 3 iterations |
|
||||
| "Run existing test suite" | verify | execute-tests → coverage-report | One-time |
|
||||
| "Implement user profile with TDD" | tdd | tdd-plan → execute → tdd-verify | Red-Green-Refactor |
|
||||
|
||||
**Legend**: `(iterate)` = auto-iteration until ≥95% pass rate
|
||||
|
||||
---
|
||||
|
||||
## State Management
|
||||
|
||||
### Dual Tracking System
|
||||
|
||||
**1. TodoWrite-Based Tracking** (UI Display):
|
||||
|
||||
```
|
||||
// Initial state (fix mode)
|
||||
CCWT:fix: [1/2] /workflow:test-fix-gen [in_progress]
|
||||
CCWT:fix: [2/2] /workflow:test-cycle-execute [pending]
|
||||
|
||||
// During iteration (fix mode, iteration 2/3)
|
||||
CCWT:fix: [1/2] /workflow:test-fix-gen [completed]
|
||||
CCWT:fix: [2/2] /workflow:test-cycle-execute [in_progress] (iteration 2/3, pass rate: 78%)
|
||||
|
||||
// Gen mode (no execution)
|
||||
CCWT:gen: [1/1] /workflow:test-fix-gen [in_progress]
|
||||
|
||||
// Verify mode (one-time)
|
||||
CCWT:verify: [1/2] execute-existing-tests [in_progress]
|
||||
CCWT:verify: [2/2] generate-coverage-report [pending]
|
||||
|
||||
// TDD mode (Red-Green-Refactor)
|
||||
CCWT:tdd: [1/3] /workflow:tdd-plan [in_progress]
|
||||
CCWT:tdd: [2/3] /workflow:execute [pending]
|
||||
CCWT:tdd: [3/3] /workflow:tdd-verify [pending]
|
||||
```
|
||||
|
||||
**2. Status.json Tracking**: Persistent state for test monitoring.
|
||||
|
||||
**Location**: `.workflow/.ccw-test/{session_id}/status.json`
|
||||
|
||||
**Structure**:
|
||||
```json
|
||||
{
|
||||
"session_id": "CCWT-auth-module-2025-02-02",
|
||||
"mode": "fix",
|
||||
"status": "running|completed|failed",
|
||||
"created_at": "2025-02-02T10:00:00Z",
|
||||
"updated_at": "2025-02-02T10:05:00Z",
|
||||
"testing": {
|
||||
"description": "Fix failing authentication tests",
|
||||
"target_module": "src/auth/**/*.ts",
|
||||
"framework": "jest",
|
||||
"coverage_target": 80
|
||||
},
|
||||
"command_chain": [
|
||||
{ "index": 0, "command": "/workflow:test-fix-gen", "unit": "sequential", "status": "completed" },
|
||||
{ "index": 1, "command": "/workflow:test-cycle-execute", "unit": "test-fix-cycle", "max_iterations": 3, "status": "in_progress" }
|
||||
],
|
||||
"current_index": 1,
|
||||
"test_metrics": {
|
||||
"total_tests": 42,
|
||||
"passed": 38,
|
||||
"failed": 4,
|
||||
"pass_rate": 90.5,
|
||||
"iteration_count": 2,
|
||||
"coverage": {
|
||||
"line": 82.3,
|
||||
"branch": 75.6,
|
||||
"function": 88.1
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
**Status Values**:
|
||||
- `running`: Test workflow in progress
|
||||
- `completed`: Tests passing (≥95%) or generation complete
|
||||
- `failed`: Test workflow aborted
|
||||
|
||||
**Test Metrics** (updated during execution):
|
||||
- `total_tests`: Number of tests executed
|
||||
- `pass_rate`: Percentage of passing tests (target: ≥95%)
|
||||
- `iteration_count`: Number of test-fix iterations (fix mode)
|
||||
- `coverage`: Line/branch/function coverage percentages
|
||||
|
||||
---
|
||||
|
||||
## Key Design Principles
|
||||
|
||||
1. **Testing-Focused** - Pure test coordination, no implementation
|
||||
2. **Mode-Driven** - 4 test strategies for different needs
|
||||
3. **Auto-Iteration** - Fix mode iterates until ≥95% pass rate
|
||||
4. **Metrics Tracking** - Real-time test metrics in status.json
|
||||
5. **Coverage-Driven** - Coverage targets guide test generation
|
||||
6. **TODO Tracking** - Use CCWT prefix to isolate test todos
|
||||
7. **TDD Compliance** - TDD mode enforces Red-Green-Refactor cycle
|
||||
|
||||
---
|
||||
|
||||
## Usage
|
||||
|
||||
```bash
|
||||
# Auto-select mode
|
||||
/ccw-test "Test user authentication module"
|
||||
|
||||
# Explicit mode selection
|
||||
/ccw-test --mode gen "Generate tests for payment module"
|
||||
/ccw-test --mode fix "Fix failing authentication tests"
|
||||
/ccw-test --mode verify "Validate current test suite"
|
||||
/ccw-test --mode tdd "Implement user profile with TDD"
|
||||
|
||||
# Custom configuration
|
||||
/ccw-test --mode fix --max-iterations 5 --pass-threshold 98 "Fix all tests"
|
||||
/ccw-test --target "src/auth/**/*.ts" "Test authentication module"
|
||||
|
||||
# Auto mode (skip confirmations)
|
||||
/ccw-test --yes "Quick test validation"
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Mode Selection Decision Tree
|
||||
|
||||
```
|
||||
User calls: /ccw-test "test description"
|
||||
|
||||
├─ Keywords: "generate", "create", "write test"
|
||||
│ └─ Mode: Gen (generate only, no execution)
|
||||
│
|
||||
├─ Keywords: "fix", "repair", "failing"
|
||||
│ └─ Mode: Fix (auto-iterate until ≥95% pass)
|
||||
│
|
||||
├─ Keywords: "verify", "validate", "run test"
|
||||
│ └─ Mode: Verify (execute existing tests)
|
||||
│
|
||||
├─ Keywords: "tdd", "test-driven", "test first"
|
||||
│ └─ Mode: TDD (Red-Green-Refactor cycle)
|
||||
│
|
||||
└─ Default → Fix (most common: fix failing tests)
|
||||
```
|
||||
666
.claude/commands/ccw.md
Normal file
666
.claude/commands/ccw.md
Normal file
@@ -0,0 +1,666 @@
|
||||
---
|
||||
name: ccw
|
||||
description: Main workflow orchestrator - analyze intent, select workflow, execute command chain in main process
|
||||
argument-hint: "\"task description\""
|
||||
allowed-tools: Skill(*), TodoWrite(*), AskUserQuestion(*), Read(*), Grep(*), Glob(*)
|
||||
---
|
||||
|
||||
# CCW Command - Main Workflow Orchestrator
|
||||
|
||||
Main process orchestrator: intent analysis → workflow selection → command chain execution.
|
||||
|
||||
## Core Concept: Minimum Execution Units (最小执行单元)
|
||||
|
||||
**Definition**: A set of commands that must execute together as an atomic group to achieve a meaningful workflow milestone.
|
||||
|
||||
**Why This Matters**:
|
||||
- **Prevents Incomplete States**: Avoid stopping after task generation without execution
|
||||
- **User Experience**: User gets complete results, not intermediate artifacts requiring manual follow-up
|
||||
- **Workflow Integrity**: Maintains logical coherence of multi-step operations
|
||||
|
||||
**Key Units in CCW**:
|
||||
|
||||
| Unit Type | Pattern | Example |
|
||||
|-----------|---------|---------|
|
||||
| **Planning + Execution** | plan-cmd → execute-cmd | lite-plan → lite-execute |
|
||||
| **Testing** | test-gen-cmd → test-exec-cmd | test-fix-gen → test-cycle-execute |
|
||||
| **Review** | review-cmd → fix-cmd | review-session-cycle → review-cycle-fix |
|
||||
|
||||
**Atomic Rules**:
|
||||
1. CCW automatically groups commands into minimum units - never splits them
|
||||
2. Pipeline visualization shows units with `【 】` markers
|
||||
3. Error handling preserves unit boundaries (retry/skip affects whole unit)
|
||||
|
||||
## Execution Model
|
||||
|
||||
**Synchronous (Main Process)**: Commands execute via Skill in main process, blocking until complete.
|
||||
|
||||
```
|
||||
User Input → Analyze Intent → Select Workflow → [Confirm] → Execute Chain
|
||||
↓
|
||||
Skill (blocking)
|
||||
↓
|
||||
Update TodoWrite
|
||||
↓
|
||||
Next Command...
|
||||
```
|
||||
|
||||
**vs ccw-coordinator**: External CLI execution with background tasks and hook callbacks.
|
||||
|
||||
## 5-Phase Workflow
|
||||
|
||||
### Phase 1: Analyze Intent
|
||||
|
||||
```javascript
|
||||
function analyzeIntent(input) {
|
||||
return {
|
||||
goal: extractGoal(input),
|
||||
scope: extractScope(input),
|
||||
constraints: extractConstraints(input),
|
||||
task_type: detectTaskType(input), // bugfix|feature|tdd|review|exploration|...
|
||||
complexity: assessComplexity(input), // low|medium|high
|
||||
clarity_score: calculateClarity(input) // 0-3 (>=2 = clear)
|
||||
};
|
||||
}
|
||||
|
||||
// Task type detection (priority order)
|
||||
function detectTaskType(text) {
|
||||
const patterns = {
|
||||
'bugfix-hotfix': /urgent|production|critical/ && /fix|bug/,
|
||||
// With-File workflows (documented exploration with multi-CLI collaboration)
|
||||
'brainstorm': /brainstorm|ideation|头脑风暴|创意|发散思维|creative thinking|multi-perspective.*think|compare perspectives|探索.*可能/,
|
||||
'brainstorm-to-issue': /brainstorm.*issue|头脑风暴.*issue|idea.*issue|想法.*issue|从.*头脑风暴|convert.*brainstorm/,
|
||||
'debug-file': /debug.*document|hypothesis.*debug|troubleshoot.*track|investigate.*log|调试.*记录|假设.*验证|systematic debug|深度调试/,
|
||||
'analyze-file': /analyze.*document|explore.*concept|understand.*architecture|investigate.*discuss|collaborative analysis|分析.*讨论|深度.*理解|协作.*分析/,
|
||||
// Standard workflows
|
||||
'bugfix': /fix|bug|error|crash|fail|debug/,
|
||||
'issue-batch': /issues?|batch/ && /fix|resolve/,
|
||||
'issue-transition': /issue workflow|structured workflow|queue|multi-stage/,
|
||||
'exploration': /uncertain|explore|research|what if/,
|
||||
'quick-task': /quick|simple|small/ && /feature|function/,
|
||||
'ui-design': /ui|design|component|style/,
|
||||
'tdd': /tdd|test-driven|test first/,
|
||||
'test-fix': /test fail|fix test|failing test/,
|
||||
'review': /review|code review/,
|
||||
'documentation': /docs|documentation|readme/
|
||||
};
|
||||
for (const [type, pattern] of Object.entries(patterns)) {
|
||||
if (pattern.test(text)) return type;
|
||||
}
|
||||
return 'feature';
|
||||
}
|
||||
```
|
||||
|
||||
**Output**: `Type: [task_type] | Goal: [goal] | Complexity: [complexity] | Clarity: [clarity_score]/3`
|
||||
|
||||
---
|
||||
|
||||
### Phase 1.5: Requirement Clarification (if clarity_score < 2)
|
||||
|
||||
```javascript
|
||||
async function clarifyRequirements(analysis) {
|
||||
if (analysis.clarity_score >= 2) return analysis;
|
||||
|
||||
const questions = generateClarificationQuestions(analysis); // Goal, Scope, Constraints
|
||||
const answers = await AskUserQuestion({ questions });
|
||||
return updateAnalysis(analysis, answers);
|
||||
}
|
||||
```
|
||||
|
||||
**Questions**: Goal (Create/Fix/Optimize/Analyze), Scope (Single file/Module/Cross-module/System), Constraints (Backward compat/Skip tests/Urgent hotfix)
|
||||
|
||||
---
|
||||
|
||||
### Phase 2: Select Workflow & Build Command Chain
|
||||
|
||||
```javascript
|
||||
function selectWorkflow(analysis) {
|
||||
const levelMap = {
|
||||
'bugfix-hotfix': { level: 2, flow: 'bugfix.hotfix' },
|
||||
// With-File workflows (documented exploration with multi-CLI collaboration)
|
||||
'brainstorm': { level: 4, flow: 'brainstorm-with-file' }, // Multi-perspective ideation
|
||||
'brainstorm-to-issue': { level: 4, flow: 'brainstorm-to-issue' }, // Brainstorm → Issue workflow
|
||||
'debug-file': { level: 3, flow: 'debug-with-file' }, // Hypothesis-driven debugging
|
||||
'analyze-file': { level: 3, flow: 'analyze-with-file' }, // Collaborative analysis
|
||||
// Standard workflows
|
||||
'bugfix': { level: 2, flow: 'bugfix.standard' },
|
||||
'issue-batch': { level: 'Issue', flow: 'issue' },
|
||||
'issue-transition': { level: 2.5, flow: 'rapid-to-issue' }, // Bridge workflow
|
||||
'exploration': { level: 4, flow: 'full' },
|
||||
'quick-task': { level: 1, flow: 'lite-lite-lite' },
|
||||
'ui-design': { level: analysis.complexity === 'high' ? 4 : 3, flow: 'ui' },
|
||||
'tdd': { level: 3, flow: 'tdd' },
|
||||
'test-fix': { level: 3, flow: 'test-fix-gen' },
|
||||
'review': { level: 3, flow: 'review-cycle-fix' },
|
||||
'documentation': { level: 2, flow: 'docs' },
|
||||
'feature': { level: analysis.complexity === 'high' ? 3 : 2, flow: analysis.complexity === 'high' ? 'coupled' : 'rapid' }
|
||||
};
|
||||
|
||||
const selected = levelMap[analysis.task_type] || levelMap['feature'];
|
||||
return buildCommandChain(selected, analysis);
|
||||
}
|
||||
|
||||
// Build command chain (port-based matching with Minimum Execution Units)
|
||||
function buildCommandChain(workflow, analysis) {
|
||||
const chains = {
|
||||
// Level 1 - Rapid
|
||||
'lite-lite-lite': [
|
||||
{ cmd: '/workflow:lite-lite-lite', args: `"${analysis.goal}"` }
|
||||
],
|
||||
|
||||
// Level 2 - Lightweight
|
||||
'rapid': [
|
||||
// Unit: Quick Implementation【lite-plan → lite-execute】
|
||||
{ cmd: '/workflow:lite-plan', args: `"${analysis.goal}"`, unit: 'quick-impl' },
|
||||
{ cmd: '/workflow:lite-execute', args: '--in-memory', unit: 'quick-impl' },
|
||||
// Unit: Test Validation【test-fix-gen → test-cycle-execute】
|
||||
...(analysis.constraints?.includes('skip-tests') ? [] : [
|
||||
{ cmd: '/workflow:test-fix-gen', args: '', unit: 'test-validation' },
|
||||
{ cmd: '/workflow:test-cycle-execute', args: '', unit: 'test-validation' }
|
||||
])
|
||||
],
|
||||
|
||||
// Level 2 Bridge - Lightweight to Issue Workflow
|
||||
'rapid-to-issue': [
|
||||
// Unit: Quick Implementation【lite-plan → convert-to-plan】
|
||||
{ cmd: '/workflow:lite-plan', args: `"${analysis.goal}"`, unit: 'quick-impl-to-issue' },
|
||||
{ cmd: '/issue:convert-to-plan', args: '--latest-lite-plan -y', unit: 'quick-impl-to-issue' },
|
||||
// Auto-continue to issue workflow
|
||||
{ cmd: '/issue:queue', args: '' },
|
||||
{ cmd: '/issue:execute', args: '--queue auto' }
|
||||
],
|
||||
|
||||
'bugfix.standard': [
|
||||
// Unit: Bug Fix【lite-fix → lite-execute】
|
||||
{ cmd: '/workflow:lite-fix', args: `"${analysis.goal}"`, unit: 'bug-fix' },
|
||||
{ cmd: '/workflow:lite-execute', args: '--in-memory', unit: 'bug-fix' },
|
||||
// Unit: Test Validation【test-fix-gen → test-cycle-execute】
|
||||
...(analysis.constraints?.includes('skip-tests') ? [] : [
|
||||
{ cmd: '/workflow:test-fix-gen', args: '', unit: 'test-validation' },
|
||||
{ cmd: '/workflow:test-cycle-execute', args: '', unit: 'test-validation' }
|
||||
])
|
||||
],
|
||||
|
||||
'bugfix.hotfix': [
|
||||
{ cmd: '/workflow:lite-fix', args: `--hotfix "${analysis.goal}"` }
|
||||
],
|
||||
|
||||
'multi-cli-plan': [
|
||||
// Unit: Multi-CLI Planning【multi-cli-plan → lite-execute】
|
||||
{ cmd: '/workflow:multi-cli-plan', args: `"${analysis.goal}"`, unit: 'multi-cli' },
|
||||
{ cmd: '/workflow:lite-execute', args: '--in-memory', unit: 'multi-cli' },
|
||||
// Unit: Test Validation【test-fix-gen → test-cycle-execute】
|
||||
...(analysis.constraints?.includes('skip-tests') ? [] : [
|
||||
{ cmd: '/workflow:test-fix-gen', args: '', unit: 'test-validation' },
|
||||
{ cmd: '/workflow:test-cycle-execute', args: '', unit: 'test-validation' }
|
||||
])
|
||||
],
|
||||
|
||||
'docs': [
|
||||
// Unit: Quick Implementation【lite-plan → lite-execute】
|
||||
{ cmd: '/workflow:lite-plan', args: `"${analysis.goal}"`, unit: 'quick-impl' },
|
||||
{ cmd: '/workflow:lite-execute', args: '--in-memory', unit: 'quick-impl' }
|
||||
],
|
||||
|
||||
// With-File workflows (documented exploration with multi-CLI collaboration)
|
||||
'brainstorm-with-file': [
|
||||
{ cmd: '/workflow:brainstorm-with-file', args: `"${analysis.goal}"` }
|
||||
// Note: Has built-in post-completion options (create plan, create issue, deep analysis)
|
||||
],
|
||||
|
||||
// Brainstorm-to-Issue workflow (bridge from brainstorm to issue execution)
|
||||
'brainstorm-to-issue': [
|
||||
// Note: Assumes brainstorm session already exists, or run brainstorm first
|
||||
{ cmd: '/issue:from-brainstorm', args: `SESSION="${extractBrainstormSession(analysis)}" --auto` },
|
||||
{ cmd: '/issue:queue', args: '' },
|
||||
{ cmd: '/issue:execute', args: '--queue auto' }
|
||||
],
|
||||
|
||||
'debug-with-file': [
|
||||
{ cmd: '/workflow:debug-with-file', args: `"${analysis.goal}"` }
|
||||
// Note: Self-contained with hypothesis-driven iteration and Gemini validation
|
||||
],
|
||||
|
||||
'analyze-with-file': [
|
||||
{ cmd: '/workflow:analyze-with-file', args: `"${analysis.goal}"` }
|
||||
// Note: Self-contained with multi-round discussion and CLI exploration
|
||||
],
|
||||
|
||||
// Level 3 - Standard
|
||||
'coupled': [
|
||||
// Unit: Verified Planning【plan → plan-verify】
|
||||
{ cmd: '/workflow:plan', args: `"${analysis.goal}"`, unit: 'verified-planning' },
|
||||
{ cmd: '/workflow:plan-verify', args: '', unit: 'verified-planning' },
|
||||
// Execution
|
||||
{ cmd: '/workflow:execute', args: '' },
|
||||
// Unit: Code Review【review-session-cycle → review-cycle-fix】
|
||||
{ cmd: '/workflow:review-session-cycle', args: '', unit: 'code-review' },
|
||||
{ cmd: '/workflow:review-cycle-fix', args: '', unit: 'code-review' },
|
||||
// Unit: Test Validation【test-fix-gen → test-cycle-execute】
|
||||
...(analysis.constraints?.includes('skip-tests') ? [] : [
|
||||
{ cmd: '/workflow:test-fix-gen', args: '', unit: 'test-validation' },
|
||||
{ cmd: '/workflow:test-cycle-execute', args: '', unit: 'test-validation' }
|
||||
])
|
||||
],
|
||||
|
||||
'tdd': [
|
||||
// Unit: TDD Planning + Execution【tdd-plan → execute】
|
||||
{ cmd: '/workflow:tdd-plan', args: `"${analysis.goal}"`, unit: 'tdd-planning' },
|
||||
{ cmd: '/workflow:execute', args: '', unit: 'tdd-planning' },
|
||||
// TDD Verification
|
||||
{ cmd: '/workflow:tdd-verify', args: '' }
|
||||
],
|
||||
|
||||
'test-fix-gen': [
|
||||
// Unit: Test Validation【test-fix-gen → test-cycle-execute】
|
||||
{ cmd: '/workflow:test-fix-gen', args: `"${analysis.goal}"`, unit: 'test-validation' },
|
||||
{ cmd: '/workflow:test-cycle-execute', args: '', unit: 'test-validation' }
|
||||
],
|
||||
|
||||
'review-cycle-fix': [
|
||||
// Unit: Code Review【review-session-cycle → review-cycle-fix】
|
||||
{ cmd: '/workflow:review-session-cycle', args: '', unit: 'code-review' },
|
||||
{ cmd: '/workflow:review-cycle-fix', args: '', unit: 'code-review' },
|
||||
// Unit: Test Validation【test-fix-gen → test-cycle-execute】
|
||||
{ cmd: '/workflow:test-fix-gen', args: '', unit: 'test-validation' },
|
||||
{ cmd: '/workflow:test-cycle-execute', args: '', unit: 'test-validation' }
|
||||
],
|
||||
|
||||
'ui': [
|
||||
{ cmd: '/workflow:ui-design:explore-auto', args: `"${analysis.goal}"` },
|
||||
// Unit: Planning + Execution【plan → execute】
|
||||
{ cmd: '/workflow:plan', args: '', unit: 'plan-execute' },
|
||||
{ cmd: '/workflow:execute', args: '', unit: 'plan-execute' }
|
||||
],
|
||||
|
||||
// Level 4 - Brainstorm
|
||||
'full': [
|
||||
{ cmd: '/workflow:brainstorm:auto-parallel', args: `"${analysis.goal}"` },
|
||||
// Unit: Verified Planning【plan → plan-verify】
|
||||
{ cmd: '/workflow:plan', args: '', unit: 'verified-planning' },
|
||||
{ cmd: '/workflow:plan-verify', args: '', unit: 'verified-planning' },
|
||||
// Execution
|
||||
{ cmd: '/workflow:execute', args: '' },
|
||||
// Unit: Test Validation【test-fix-gen → test-cycle-execute】
|
||||
{ cmd: '/workflow:test-fix-gen', args: '', unit: 'test-validation' },
|
||||
{ cmd: '/workflow:test-cycle-execute', args: '', unit: 'test-validation' }
|
||||
],
|
||||
|
||||
// Issue Workflow
|
||||
'issue': [
|
||||
{ cmd: '/issue:discover', args: '' },
|
||||
{ cmd: '/issue:plan', args: '--all-pending' },
|
||||
{ cmd: '/issue:queue', args: '' },
|
||||
{ cmd: '/issue:execute', args: '' }
|
||||
]
|
||||
};
|
||||
|
||||
return chains[workflow.flow] || chains['rapid'];
|
||||
}
|
||||
```
|
||||
|
||||
**Output**: `Level [X] - [flow] | Pipeline: [...] | Commands: [1. /cmd1 2. /cmd2 ...]`
|
||||
|
||||
---
|
||||
|
||||
### Phase 3: User Confirmation
|
||||
|
||||
```javascript
|
||||
async function getUserConfirmation(chain) {
|
||||
const response = await AskUserQuestion({
|
||||
questions: [{
|
||||
question: "Execute this command chain?",
|
||||
header: "Confirm",
|
||||
options: [
|
||||
{ label: "Confirm", description: "Start" },
|
||||
{ label: "Adjust", description: "Modify" },
|
||||
{ label: "Cancel", description: "Abort" }
|
||||
]
|
||||
}]
|
||||
});
|
||||
|
||||
if (response.error === "Cancel") throw new Error("Cancelled");
|
||||
if (response.error === "Adjust") return await adjustChain(chain);
|
||||
return chain;
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### Phase 4: Setup TODO Tracking & Status File
|
||||
|
||||
```javascript
|
||||
function setupTodoTracking(chain, workflow, analysis) {
|
||||
const sessionId = `ccw-${Date.now()}`;
|
||||
const stateDir = `.workflow/.ccw/${sessionId}`;
|
||||
Bash(`mkdir -p "${stateDir}"`);
|
||||
|
||||
const todos = chain.map((step, i) => ({
|
||||
content: `CCW:${workflow}: [${i + 1}/${chain.length}] ${step.cmd}`,
|
||||
status: i === 0 ? 'in_progress' : 'pending',
|
||||
activeForm: `Executing ${step.cmd}`
|
||||
}));
|
||||
TodoWrite({ todos });
|
||||
|
||||
// Initialize status.json for hook tracking
|
||||
const state = {
|
||||
session_id: sessionId,
|
||||
workflow: workflow,
|
||||
status: 'running',
|
||||
created_at: new Date().toISOString(),
|
||||
updated_at: new Date().toISOString(),
|
||||
analysis: analysis,
|
||||
command_chain: chain.map((step, idx) => ({
|
||||
index: idx,
|
||||
command: step.cmd,
|
||||
status: idx === 0 ? 'running' : 'pending'
|
||||
})),
|
||||
current_index: 0
|
||||
};
|
||||
|
||||
Write(`${stateDir}/status.json`, JSON.stringify(state, null, 2));
|
||||
|
||||
return { sessionId, stateDir, state };
|
||||
}
|
||||
```
|
||||
|
||||
**Output**:
|
||||
- TODO: `-> CCW:rapid: [1/3] /workflow:lite-plan | CCW:rapid: [2/3] /workflow:lite-execute | ...`
|
||||
- Status File: `.workflow/.ccw/{session_id}/status.json`
|
||||
|
||||
---
|
||||
|
||||
### Phase 5: Execute Command Chain
|
||||
|
||||
```javascript
|
||||
async function executeCommandChain(chain, workflow, trackingState) {
|
||||
let previousResult = null;
|
||||
const { sessionId, stateDir, state } = trackingState;
|
||||
|
||||
for (let i = 0; i < chain.length; i++) {
|
||||
try {
|
||||
// Update status: mark current as running
|
||||
state.command_chain[i].status = 'running';
|
||||
state.current_index = i;
|
||||
state.updated_at = new Date().toISOString();
|
||||
Write(`${stateDir}/status.json`, JSON.stringify(state, null, 2));
|
||||
|
||||
const fullCommand = assembleCommand(chain[i], previousResult);
|
||||
const result = await Skill({ skill: fullCommand });
|
||||
|
||||
previousResult = { ...result, success: true };
|
||||
|
||||
// Update status: mark current as completed, next as running
|
||||
state.command_chain[i].status = 'completed';
|
||||
if (i + 1 < chain.length) {
|
||||
state.command_chain[i + 1].status = 'running';
|
||||
}
|
||||
state.updated_at = new Date().toISOString();
|
||||
Write(`${stateDir}/status.json`, JSON.stringify(state, null, 2));
|
||||
|
||||
updateTodoStatus(i, chain.length, workflow, 'completed');
|
||||
|
||||
} catch (error) {
|
||||
// Update status on error
|
||||
state.command_chain[i].status = 'failed';
|
||||
state.status = 'error';
|
||||
state.updated_at = new Date().toISOString();
|
||||
Write(`${stateDir}/status.json`, JSON.stringify(state, null, 2));
|
||||
|
||||
const action = await handleError(chain[i], error, i);
|
||||
if (action === 'retry') {
|
||||
state.command_chain[i].status = 'pending';
|
||||
state.status = 'running';
|
||||
i--; // Retry
|
||||
} else if (action === 'abort') {
|
||||
state.status = 'failed';
|
||||
Write(`${stateDir}/status.json`, JSON.stringify(state, null, 2));
|
||||
return { success: false, error: error.message };
|
||||
}
|
||||
// 'skip' - continue
|
||||
state.status = 'running';
|
||||
}
|
||||
}
|
||||
|
||||
// Mark workflow as completed
|
||||
state.status = 'completed';
|
||||
state.updated_at = new Date().toISOString();
|
||||
Write(`${stateDir}/status.json`, JSON.stringify(state, null, 2));
|
||||
|
||||
return { success: true, completed: chain.length, sessionId };
|
||||
}
|
||||
|
||||
// Assemble full command with session/plan parameters
|
||||
function assembleCommand(step, previousResult) {
|
||||
let command = step.cmd;
|
||||
if (step.args) {
|
||||
command += ` ${step.args}`;
|
||||
} else if (previousResult?.session_id) {
|
||||
command += ` --session="${previousResult.session_id}"`;
|
||||
}
|
||||
return command;
|
||||
}
|
||||
|
||||
// Update TODO: mark current as complete, next as in-progress
|
||||
function updateTodoStatus(index, total, workflow, status) {
|
||||
const todos = getAllCurrentTodos();
|
||||
const updated = todos.map(todo => {
|
||||
if (todo.content.startsWith(`CCW:${workflow}:`)) {
|
||||
const stepNum = extractStepIndex(todo.content);
|
||||
if (stepNum === index + 1) return { ...todo, status };
|
||||
if (stepNum === index + 2 && status === 'completed') return { ...todo, status: 'in_progress' };
|
||||
}
|
||||
return todo;
|
||||
});
|
||||
TodoWrite({ todos: updated });
|
||||
}
|
||||
|
||||
// Error handling: Retry/Skip/Abort
|
||||
async function handleError(step, error, index) {
|
||||
const response = await AskUserQuestion({
|
||||
questions: [{
|
||||
question: `${step.cmd} failed: ${error.message}`,
|
||||
header: "Error",
|
||||
options: [
|
||||
{ label: "Retry", description: "Re-execute" },
|
||||
{ label: "Skip", description: "Continue next" },
|
||||
{ label: "Abort", description: "Stop" }
|
||||
]
|
||||
}]
|
||||
});
|
||||
return { Retry: 'retry', Skip: 'skip', Abort: 'abort' }[response.Error] || 'abort';
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Execution Flow Summary
|
||||
|
||||
```
|
||||
User Input
|
||||
|
|
||||
Phase 1: Analyze Intent
|
||||
|-- Extract: goal, scope, constraints, task_type, complexity, clarity
|
||||
+-- If clarity < 2 -> Phase 1.5: Clarify Requirements
|
||||
|
|
||||
Phase 2: Select Workflow & Build Chain
|
||||
|-- Map task_type -> Level (1/2/3/4/Issue)
|
||||
|-- Select flow based on complexity
|
||||
+-- Build command chain (port-based)
|
||||
|
|
||||
Phase 3: User Confirmation (optional)
|
||||
|-- Show pipeline visualization
|
||||
+-- Allow adjustment
|
||||
|
|
||||
Phase 4: Setup TODO Tracking & Status File
|
||||
|-- Create todos with CCW prefix
|
||||
+-- Initialize .workflow/.ccw/{session_id}/status.json
|
||||
|
|
||||
Phase 5: Execute Command Chain
|
||||
|-- For each command:
|
||||
| |-- Update status.json (current=running)
|
||||
| |-- Assemble full command
|
||||
| |-- Execute via Skill
|
||||
| |-- Update status.json (current=completed, next=running)
|
||||
| |-- Update TODO status
|
||||
| +-- Handle errors (retry/skip/abort)
|
||||
+-- Mark status.json as completed
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Pipeline Examples (with Minimum Execution Units)
|
||||
|
||||
**Note**: `【 】` marks Minimum Execution Units - commands execute together as atomic groups.
|
||||
|
||||
| Input | Type | Level | Pipeline (with Units) |
|
||||
|-------|------|-------|-----------------------|
|
||||
| "Add API endpoint" | feature (low) | 2 |【lite-plan → lite-execute】→【test-fix-gen → test-cycle-execute】|
|
||||
| "Fix login timeout" | bugfix | 2 |【lite-fix → lite-execute】→【test-fix-gen → test-cycle-execute】|
|
||||
| "Use issue workflow" | issue-transition | 2.5 |【lite-plan → convert-to-plan】→ queue → execute |
|
||||
| "头脑风暴: 通知系统重构" | brainstorm | 4 | brainstorm-with-file → (built-in post-completion) |
|
||||
| "从头脑风暴创建 issue" | brainstorm-to-issue | 4 | from-brainstorm → queue → execute |
|
||||
| "深度调试 WebSocket 连接断开" | debug-file | 3 | debug-with-file → (hypothesis iteration) |
|
||||
| "协作分析: 认证架构优化" | analyze-file | 3 | analyze-with-file → (multi-round discussion) |
|
||||
| "OAuth2 system" | feature (high) | 3 |【plan → plan-verify】→ execute →【review-session-cycle → review-cycle-fix】→【test-fix-gen → test-cycle-execute】|
|
||||
| "Implement with TDD" | tdd | 3 |【tdd-plan → execute】→ tdd-verify |
|
||||
| "Uncertain: real-time arch" | exploration | 4 | brainstorm:auto-parallel →【plan → plan-verify】→ execute →【test-fix-gen → test-cycle-execute】|
|
||||
|
||||
---
|
||||
|
||||
## Key Design Principles
|
||||
|
||||
1. **Main Process Execution** - Use Skill in main process, no external CLI
|
||||
2. **Intent-Driven** - Auto-select workflow based on task intent
|
||||
3. **Port-Based Chaining** - Build command chain using port matching
|
||||
4. **Minimum Execution Units** - Commands grouped into atomic units, never split (e.g., lite-plan → lite-execute)
|
||||
5. **Progressive Clarification** - Low clarity triggers clarification phase
|
||||
6. **TODO Tracking** - Use CCW prefix to isolate workflow todos
|
||||
7. **Unit-Aware Error Handling** - Retry/skip/abort affects whole unit, not individual commands
|
||||
8. **User Control** - Optional user confirmation at each phase
|
||||
|
||||
---
|
||||
|
||||
## State Management
|
||||
|
||||
### Dual Tracking System
|
||||
|
||||
**1. TodoWrite-Based Tracking** (UI Display): All execution state tracked via TodoWrite with `CCW:` prefix.
|
||||
|
||||
```javascript
|
||||
// Initial state
|
||||
todos = [
|
||||
{ content: "CCW:rapid: [1/3] /workflow:lite-plan", status: "in_progress" },
|
||||
{ content: "CCW:rapid: [2/3] /workflow:lite-execute", status: "pending" },
|
||||
{ content: "CCW:rapid: [3/3] /workflow:test-cycle-execute", status: "pending" }
|
||||
];
|
||||
|
||||
// After command 1 completes
|
||||
todos = [
|
||||
{ content: "CCW:rapid: [1/3] /workflow:lite-plan", status: "completed" },
|
||||
{ content: "CCW:rapid: [2/3] /workflow:lite-execute", status: "in_progress" },
|
||||
{ content: "CCW:rapid: [3/3] /workflow:test-cycle-execute", status: "pending" }
|
||||
];
|
||||
```
|
||||
|
||||
**2. Status.json Tracking**: Persistent state file for workflow monitoring.
|
||||
|
||||
**Location**: `.workflow/.ccw/{session_id}/status.json`
|
||||
|
||||
**Structure**:
|
||||
```json
|
||||
{
|
||||
"session_id": "ccw-1706123456789",
|
||||
"workflow": "rapid",
|
||||
"status": "running|completed|failed|error",
|
||||
"created_at": "2025-02-01T10:30:00Z",
|
||||
"updated_at": "2025-02-01T10:35:00Z",
|
||||
"analysis": {
|
||||
"goal": "Add user authentication",
|
||||
"scope": ["auth"],
|
||||
"constraints": [],
|
||||
"task_type": "feature",
|
||||
"complexity": "medium"
|
||||
},
|
||||
"command_chain": [
|
||||
{
|
||||
"index": 0,
|
||||
"command": "/workflow:lite-plan",
|
||||
"status": "completed"
|
||||
},
|
||||
{
|
||||
"index": 1,
|
||||
"command": "/workflow:lite-execute",
|
||||
"status": "running"
|
||||
},
|
||||
{
|
||||
"index": 2,
|
||||
"command": "/workflow:test-cycle-execute",
|
||||
"status": "pending"
|
||||
}
|
||||
],
|
||||
"current_index": 1
|
||||
}
|
||||
```
|
||||
|
||||
**Status Values**:
|
||||
- `running`: Workflow executing commands
|
||||
- `completed`: All commands finished
|
||||
- `failed`: User aborted or unrecoverable error
|
||||
- `error`: Command execution failed (during error handling)
|
||||
|
||||
**Command Status Values**:
|
||||
- `pending`: Not started
|
||||
- `running`: Currently executing
|
||||
- `completed`: Successfully finished
|
||||
- `failed`: Execution failed
|
||||
|
||||
---
|
||||
|
||||
## With-File Workflows
|
||||
|
||||
**With-File workflows** provide documented exploration with multi-CLI collaboration. They are self-contained and generate comprehensive session artifacts.
|
||||
|
||||
| Workflow | Purpose | Key Features | Output Folder |
|
||||
|----------|---------|--------------|---------------|
|
||||
| **brainstorm-with-file** | Multi-perspective ideation | Gemini/Codex/Claude perspectives, diverge-converge cycles | `.workflow/.brainstorm/` |
|
||||
| **debug-with-file** | Hypothesis-driven debugging | Gemini validation, understanding evolution, NDJSON logging | `.workflow/.debug/` |
|
||||
| **analyze-with-file** | Collaborative analysis | Multi-round Q&A, CLI exploration, documented discussions | `.workflow/.analysis/` |
|
||||
|
||||
**Detection Keywords**:
|
||||
- **brainstorm**: 头脑风暴, 创意, 发散思维, multi-perspective, compare perspectives
|
||||
- **debug-file**: 深度调试, 假设验证, systematic debug, hypothesis debug
|
||||
- **analyze-file**: 协作分析, 深度理解, collaborative analysis, explore concept
|
||||
|
||||
**Characteristics**:
|
||||
1. **Self-Contained**: Each workflow handles its own iteration loop
|
||||
2. **Documented Process**: Creates evolving documents (brainstorm.md, understanding.md, discussion.md)
|
||||
3. **Multi-CLI**: Uses Gemini/Codex/Claude for different perspectives
|
||||
4. **Built-in Post-Completion**: Offers follow-up options (create plan, issue, etc.)
|
||||
|
||||
---
|
||||
|
||||
## Usage
|
||||
|
||||
```bash
|
||||
# Auto-select workflow
|
||||
/ccw "Add user authentication"
|
||||
|
||||
# Complex requirement (triggers clarification)
|
||||
/ccw "Optimize system performance"
|
||||
|
||||
# Bug fix
|
||||
/ccw "Fix memory leak in WebSocket handler"
|
||||
|
||||
# TDD development
|
||||
/ccw "Implement user registration with TDD"
|
||||
|
||||
# Exploratory task
|
||||
/ccw "Uncertain about architecture for real-time notifications"
|
||||
|
||||
# With-File workflows (documented exploration with multi-CLI collaboration)
|
||||
/ccw "头脑风暴: 用户通知系统重新设计" # → brainstorm-with-file
|
||||
/ccw "从头脑风暴 BS-通知系统-2025-01-28 创建 issue" # → brainstorm-to-issue (bridge)
|
||||
/ccw "深度调试: 系统随机崩溃问题" # → debug-with-file
|
||||
/ccw "协作分析: 理解现有认证架构的设计决策" # → analyze-with-file
|
||||
```
|
||||
@@ -1,516 +0,0 @@
|
||||
---
|
||||
name: clean
|
||||
description: Intelligent code cleanup with mainline detection, stale artifact discovery, and safe execution
|
||||
argument-hint: "[--dry-run] [\"focus area\"]"
|
||||
allowed-tools: TodoWrite(*), Task(*), AskUserQuestion(*), Read(*), Glob(*), Bash(*), Write(*)
|
||||
---
|
||||
|
||||
# Clean Command (/clean)
|
||||
|
||||
## Overview
|
||||
|
||||
Intelligent cleanup command that explores the codebase to identify the development mainline, discovers artifacts that have drifted from it, and safely removes stale sessions, abandoned documents, and dead code.
|
||||
|
||||
**Core capabilities:**
|
||||
- Mainline detection: Identify active development branches and core modules
|
||||
- Drift analysis: Find sessions, documents, and code that deviate from mainline
|
||||
- Intelligent discovery: cli-explore-agent based artifact scanning
|
||||
- Safe execution: Confirmation-based cleanup with dry-run preview
|
||||
|
||||
## Usage
|
||||
|
||||
```bash
|
||||
/clean # Full intelligent cleanup (explore → analyze → confirm → execute)
|
||||
/clean --dry-run # Explore and analyze only, no execution
|
||||
/clean "auth module" # Focus cleanup on specific area
|
||||
```
|
||||
|
||||
## Execution Process
|
||||
|
||||
```
|
||||
Phase 1: Mainline Detection
|
||||
├─ Analyze git history for development trends
|
||||
├─ Identify core modules (high commit frequency)
|
||||
├─ Map active vs stale branches
|
||||
└─ Build mainline profile
|
||||
|
||||
Phase 2: Drift Discovery (cli-explore-agent)
|
||||
├─ Scan workflow sessions for orphaned artifacts
|
||||
├─ Identify documents drifted from mainline
|
||||
├─ Detect dead code and unused exports
|
||||
└─ Generate cleanup manifest
|
||||
|
||||
Phase 3: Confirmation
|
||||
├─ Display cleanup summary by category
|
||||
├─ Show impact analysis (files, size, risk)
|
||||
└─ AskUserQuestion: Select categories to clean
|
||||
|
||||
Phase 4: Execution (unless --dry-run)
|
||||
├─ Execute cleanup by category
|
||||
├─ Update manifests and indexes
|
||||
└─ Report results
|
||||
```
|
||||
|
||||
## Implementation
|
||||
|
||||
### Phase 1: Mainline Detection
|
||||
|
||||
**Session Setup**:
|
||||
```javascript
|
||||
const getUtc8ISOString = () => new Date(Date.now() + 8 * 60 * 60 * 1000).toISOString()
|
||||
|
||||
const dateStr = getUtc8ISOString().substring(0, 10)
|
||||
const sessionId = `clean-${dateStr}`
|
||||
const sessionFolder = `.workflow/.clean/${sessionId}`
|
||||
|
||||
Bash(`mkdir -p ${sessionFolder}`)
|
||||
```
|
||||
|
||||
**Step 1.1: Git History Analysis**
|
||||
```bash
|
||||
# Get commit frequency by directory (last 30 days)
|
||||
bash(git log --since="30 days ago" --name-only --pretty=format: | grep -v "^$" | cut -d/ -f1-2 | sort | uniq -c | sort -rn | head -20)
|
||||
|
||||
# Get recent active branches
|
||||
bash(git for-each-ref --sort=-committerdate refs/heads/ --format='%(refname:short) %(committerdate:relative)' | head -10)
|
||||
|
||||
# Get files with most recent changes
|
||||
bash(git log --since="7 days ago" --name-only --pretty=format: | grep -v "^$" | sort | uniq -c | sort -rn | head -30)
|
||||
```
|
||||
|
||||
**Step 1.2: Build Mainline Profile**
|
||||
```javascript
|
||||
const mainlineProfile = {
|
||||
coreModules: [], // High-frequency directories
|
||||
activeFiles: [], // Recently modified files
|
||||
activeBranches: [], // Branches with recent commits
|
||||
staleThreshold: {
|
||||
sessions: 7, // Days
|
||||
branches: 30,
|
||||
documents: 14
|
||||
},
|
||||
timestamp: getUtc8ISOString()
|
||||
}
|
||||
|
||||
// Parse git log output to identify core modules
|
||||
// Modules with >5 commits in last 30 days = core
|
||||
// Modules with 0 commits in last 30 days = potentially stale
|
||||
|
||||
Write(`${sessionFolder}/mainline-profile.json`, JSON.stringify(mainlineProfile, null, 2))
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### Phase 2: Drift Discovery
|
||||
|
||||
**Launch cli-explore-agent for intelligent artifact scanning**:
|
||||
|
||||
```javascript
|
||||
Task(
|
||||
subagent_type="cli-explore-agent",
|
||||
run_in_background=false,
|
||||
description="Discover stale artifacts",
|
||||
prompt=`
|
||||
## Task Objective
|
||||
Discover artifacts that have drifted from the development mainline. Identify stale sessions, abandoned documents, and dead code for cleanup.
|
||||
|
||||
## Context
|
||||
- **Session Folder**: ${sessionFolder}
|
||||
- **Mainline Profile**: ${sessionFolder}/mainline-profile.json
|
||||
- **Focus Area**: ${focusArea || "全项目"}
|
||||
|
||||
## Discovery Categories
|
||||
|
||||
### Category 1: Stale Workflow Sessions
|
||||
Scan and analyze workflow session directories:
|
||||
|
||||
**Locations to scan**:
|
||||
- .workflow/active/WFS-* (active sessions)
|
||||
- .workflow/archives/WFS-* (archived sessions)
|
||||
- .workflow/.lite-plan/* (lite-plan sessions)
|
||||
- .workflow/.debug/DBG-* (debug sessions)
|
||||
|
||||
**Staleness criteria**:
|
||||
- Active sessions: No modification >7 days + no related git commits
|
||||
- Archives: >30 days old + no feature references in project.json
|
||||
- Lite-plan: >7 days old + plan.json not executed
|
||||
- Debug: >3 days old + issue not in recent commits
|
||||
|
||||
**Analysis steps**:
|
||||
1. List all session directories with modification times
|
||||
2. Cross-reference with git log (are session topics in recent commits?)
|
||||
3. Check manifest.json for orphan entries
|
||||
4. Identify sessions with .archiving marker (interrupted)
|
||||
|
||||
### Category 2: Drifted Documents
|
||||
Scan documentation that no longer aligns with code:
|
||||
|
||||
**Locations to scan**:
|
||||
- .claude/rules/tech/* (generated tech rules)
|
||||
- .workflow/.scratchpad/* (temporary notes)
|
||||
- **/CLAUDE.md (module documentation)
|
||||
- **/README.md (outdated descriptions)
|
||||
|
||||
**Drift criteria**:
|
||||
- Tech rules: Referenced files no longer exist
|
||||
- Scratchpad: Any file (always temporary)
|
||||
- Module docs: Describe functions/classes that were removed
|
||||
- READMEs: Reference deleted directories
|
||||
|
||||
**Analysis steps**:
|
||||
1. Parse document content for file/function references
|
||||
2. Verify referenced entities still exist in codebase
|
||||
3. Flag documents with >30% broken references
|
||||
|
||||
### Category 3: Dead Code
|
||||
Identify code that is no longer used:
|
||||
|
||||
**Scan patterns**:
|
||||
- Unused exports (exported but never imported)
|
||||
- Orphan files (not imported anywhere)
|
||||
- Commented-out code blocks (>10 lines)
|
||||
- TODO/FIXME comments >90 days old
|
||||
|
||||
**Analysis steps**:
|
||||
1. Build import graph using rg/grep
|
||||
2. Identify exports with no importers
|
||||
3. Find files not in import graph
|
||||
4. Scan for large comment blocks
|
||||
|
||||
## Output Format
|
||||
|
||||
Write to: ${sessionFolder}/cleanup-manifest.json
|
||||
|
||||
\`\`\`json
|
||||
{
|
||||
"generated_at": "ISO timestamp",
|
||||
"mainline_summary": {
|
||||
"core_modules": ["src/core", "src/api"],
|
||||
"active_branches": ["main", "feature/auth"],
|
||||
"health_score": 0.85
|
||||
},
|
||||
"discoveries": {
|
||||
"stale_sessions": [
|
||||
{
|
||||
"path": ".workflow/active/WFS-old-feature",
|
||||
"type": "active",
|
||||
"age_days": 15,
|
||||
"reason": "No related commits in 15 days",
|
||||
"size_kb": 1024,
|
||||
"risk": "low"
|
||||
}
|
||||
],
|
||||
"drifted_documents": [
|
||||
{
|
||||
"path": ".claude/rules/tech/deprecated-lib",
|
||||
"type": "tech_rules",
|
||||
"broken_references": 5,
|
||||
"total_references": 6,
|
||||
"drift_percentage": 83,
|
||||
"reason": "Referenced library removed",
|
||||
"risk": "low"
|
||||
}
|
||||
],
|
||||
"dead_code": [
|
||||
{
|
||||
"path": "src/utils/legacy.ts",
|
||||
"type": "orphan_file",
|
||||
"reason": "Not imported by any file",
|
||||
"last_modified": "2025-10-01",
|
||||
"risk": "medium"
|
||||
}
|
||||
]
|
||||
},
|
||||
"summary": {
|
||||
"total_items": 12,
|
||||
"total_size_mb": 45.2,
|
||||
"by_category": {
|
||||
"stale_sessions": 5,
|
||||
"drifted_documents": 4,
|
||||
"dead_code": 3
|
||||
},
|
||||
"by_risk": {
|
||||
"low": 8,
|
||||
"medium": 3,
|
||||
"high": 1
|
||||
}
|
||||
}
|
||||
}
|
||||
\`\`\`
|
||||
|
||||
## Execution Commands
|
||||
|
||||
\`\`\`bash
|
||||
# Session directories
|
||||
find .workflow -type d -name "WFS-*" -o -name "DBG-*" 2>/dev/null
|
||||
|
||||
# Check modification times (Linux/Mac)
|
||||
stat -c "%Y %n" .workflow/active/WFS-* 2>/dev/null
|
||||
|
||||
# Check modification times (Windows PowerShell via bash)
|
||||
powershell -Command "Get-ChildItem '.workflow/active/WFS-*' | ForEach-Object { Write-Output \"$($_.LastWriteTime) $($_.FullName)\" }"
|
||||
|
||||
# Find orphan exports (TypeScript)
|
||||
rg "export (const|function|class|interface|type)" --type ts -l
|
||||
|
||||
# Find imports
|
||||
rg "import.*from" --type ts
|
||||
|
||||
# Find large comment blocks
|
||||
rg "^\\s*/\\*" -A 10 --type ts
|
||||
|
||||
# Find old TODOs
|
||||
rg "TODO|FIXME" --type ts -n
|
||||
\`\`\`
|
||||
|
||||
## Success Criteria
|
||||
- [ ] All session directories scanned with age calculation
|
||||
- [ ] Documents cross-referenced with existing code
|
||||
- [ ] Dead code detection via import graph analysis
|
||||
- [ ] cleanup-manifest.json written with complete data
|
||||
- [ ] Each item has risk level and cleanup reason
|
||||
`
|
||||
)
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### Phase 3: Confirmation
|
||||
|
||||
**Step 3.1: Display Summary**
|
||||
```javascript
|
||||
const manifest = JSON.parse(Read(`${sessionFolder}/cleanup-manifest.json`))
|
||||
|
||||
console.log(`
|
||||
## Cleanup Discovery Report
|
||||
|
||||
**Mainline Health**: ${Math.round(manifest.mainline_summary.health_score * 100)}%
|
||||
**Core Modules**: ${manifest.mainline_summary.core_modules.join(', ')}
|
||||
|
||||
### Summary
|
||||
| Category | Count | Size | Risk |
|
||||
|----------|-------|------|------|
|
||||
| Stale Sessions | ${manifest.summary.by_category.stale_sessions} | - | ${getRiskSummary('sessions')} |
|
||||
| Drifted Documents | ${manifest.summary.by_category.drifted_documents} | - | ${getRiskSummary('documents')} |
|
||||
| Dead Code | ${manifest.summary.by_category.dead_code} | - | ${getRiskSummary('code')} |
|
||||
|
||||
**Total**: ${manifest.summary.total_items} items, ~${manifest.summary.total_size_mb} MB
|
||||
|
||||
### Stale Sessions
|
||||
${manifest.discoveries.stale_sessions.map(s =>
|
||||
`- ${s.path} (${s.age_days}d, ${s.risk}): ${s.reason}`
|
||||
).join('\n')}
|
||||
|
||||
### Drifted Documents
|
||||
${manifest.discoveries.drifted_documents.map(d =>
|
||||
`- ${d.path} (${d.drift_percentage}% broken, ${d.risk}): ${d.reason}`
|
||||
).join('\n')}
|
||||
|
||||
### Dead Code
|
||||
${manifest.discoveries.dead_code.map(c =>
|
||||
`- ${c.path} (${c.type}, ${c.risk}): ${c.reason}`
|
||||
).join('\n')}
|
||||
`)
|
||||
```
|
||||
|
||||
**Step 3.2: Dry-Run Exit**
|
||||
```javascript
|
||||
if (flags.includes('--dry-run')) {
|
||||
console.log(`
|
||||
---
|
||||
**Dry-run mode**: No changes made.
|
||||
Manifest saved to: ${sessionFolder}/cleanup-manifest.json
|
||||
|
||||
To execute cleanup: /clean
|
||||
`)
|
||||
return
|
||||
}
|
||||
```
|
||||
|
||||
**Step 3.3: User Confirmation**
|
||||
```javascript
|
||||
AskUserQuestion({
|
||||
questions: [
|
||||
{
|
||||
question: "Which categories to clean?",
|
||||
header: "Categories",
|
||||
multiSelect: true,
|
||||
options: [
|
||||
{
|
||||
label: "Sessions",
|
||||
description: `${manifest.summary.by_category.stale_sessions} stale workflow sessions`
|
||||
},
|
||||
{
|
||||
label: "Documents",
|
||||
description: `${manifest.summary.by_category.drifted_documents} drifted documents`
|
||||
},
|
||||
{
|
||||
label: "Dead Code",
|
||||
description: `${manifest.summary.by_category.dead_code} unused code files`
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
question: "Risk level to include?",
|
||||
header: "Risk",
|
||||
multiSelect: false,
|
||||
options: [
|
||||
{ label: "Low only", description: "Safest - only obviously stale items" },
|
||||
{ label: "Low + Medium", description: "Recommended - includes likely unused items" },
|
||||
{ label: "All", description: "Aggressive - includes high-risk items" }
|
||||
]
|
||||
}
|
||||
]
|
||||
})
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### Phase 4: Execution
|
||||
|
||||
**Step 4.1: Filter Items by Selection**
|
||||
```javascript
|
||||
const selectedCategories = userSelection.categories // ['Sessions', 'Documents', ...]
|
||||
const riskLevel = userSelection.risk // 'Low only', 'Low + Medium', 'All'
|
||||
|
||||
const riskFilter = {
|
||||
'Low only': ['low'],
|
||||
'Low + Medium': ['low', 'medium'],
|
||||
'All': ['low', 'medium', 'high']
|
||||
}[riskLevel]
|
||||
|
||||
const itemsToClean = []
|
||||
|
||||
if (selectedCategories.includes('Sessions')) {
|
||||
itemsToClean.push(...manifest.discoveries.stale_sessions.filter(s => riskFilter.includes(s.risk)))
|
||||
}
|
||||
if (selectedCategories.includes('Documents')) {
|
||||
itemsToClean.push(...manifest.discoveries.drifted_documents.filter(d => riskFilter.includes(d.risk)))
|
||||
}
|
||||
if (selectedCategories.includes('Dead Code')) {
|
||||
itemsToClean.push(...manifest.discoveries.dead_code.filter(c => riskFilter.includes(c.risk)))
|
||||
}
|
||||
|
||||
TodoWrite({
|
||||
todos: itemsToClean.map(item => ({
|
||||
content: `Clean: ${item.path}`,
|
||||
status: "pending",
|
||||
activeForm: `Cleaning ${item.path}`
|
||||
}))
|
||||
})
|
||||
```
|
||||
|
||||
**Step 4.2: Execute Cleanup**
|
||||
```javascript
|
||||
const results = { deleted: [], failed: [], skipped: [] }
|
||||
|
||||
for (const item of itemsToClean) {
|
||||
TodoWrite({ todos: [...] }) // Mark current as in_progress
|
||||
|
||||
try {
|
||||
if (item.type === 'orphan_file' || item.type === 'dead_export') {
|
||||
// Dead code: Delete file or remove export
|
||||
Bash({ command: `rm -rf "${item.path}"` })
|
||||
} else {
|
||||
// Sessions and documents: Delete directory/file
|
||||
Bash({ command: `rm -rf "${item.path}"` })
|
||||
}
|
||||
|
||||
results.deleted.push(item.path)
|
||||
TodoWrite({ todos: [...] }) // Mark as completed
|
||||
} catch (error) {
|
||||
results.failed.push({ path: item.path, error: error.message })
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
**Step 4.3: Update Manifests**
|
||||
```javascript
|
||||
// Update archives manifest if sessions were deleted
|
||||
if (selectedCategories.includes('Sessions')) {
|
||||
const archiveManifestPath = '.workflow/archives/manifest.json'
|
||||
if (fileExists(archiveManifestPath)) {
|
||||
const archiveManifest = JSON.parse(Read(archiveManifestPath))
|
||||
const deletedSessionIds = results.deleted
|
||||
.filter(p => p.includes('WFS-'))
|
||||
.map(p => p.split('/').pop())
|
||||
|
||||
const updatedManifest = archiveManifest.filter(entry =>
|
||||
!deletedSessionIds.includes(entry.session_id)
|
||||
)
|
||||
|
||||
Write(archiveManifestPath, JSON.stringify(updatedManifest, null, 2))
|
||||
}
|
||||
}
|
||||
|
||||
// Update project.json if features referenced deleted sessions
|
||||
const projectPath = '.workflow/project.json'
|
||||
if (fileExists(projectPath)) {
|
||||
const project = JSON.parse(Read(projectPath))
|
||||
const deletedPaths = new Set(results.deleted)
|
||||
|
||||
project.features = project.features.filter(f =>
|
||||
!deletedPaths.has(f.traceability?.archive_path)
|
||||
)
|
||||
|
||||
project.statistics.total_features = project.features.length
|
||||
project.statistics.last_updated = getUtc8ISOString()
|
||||
|
||||
Write(projectPath, JSON.stringify(project, null, 2))
|
||||
}
|
||||
```
|
||||
|
||||
**Step 4.4: Report Results**
|
||||
```javascript
|
||||
console.log(`
|
||||
## Cleanup Complete
|
||||
|
||||
**Deleted**: ${results.deleted.length} items
|
||||
**Failed**: ${results.failed.length} items
|
||||
**Skipped**: ${results.skipped.length} items
|
||||
|
||||
### Deleted Items
|
||||
${results.deleted.map(p => `- ${p}`).join('\n')}
|
||||
|
||||
${results.failed.length > 0 ? `
|
||||
### Failed Items
|
||||
${results.failed.map(f => `- ${f.path}: ${f.error}`).join('\n')}
|
||||
` : ''}
|
||||
|
||||
Cleanup manifest archived to: ${sessionFolder}/cleanup-manifest.json
|
||||
`)
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Session Folder Structure
|
||||
|
||||
```
|
||||
.workflow/.clean/{YYYY-MM-DD}/
|
||||
├── mainline-profile.json # Git history analysis
|
||||
└── cleanup-manifest.json # Discovery results
|
||||
```
|
||||
|
||||
## Risk Level Definitions
|
||||
|
||||
| Risk | Description | Examples |
|
||||
|------|-------------|----------|
|
||||
| **Low** | Safe to delete, no dependencies | Empty sessions, scratchpad files, 100% broken docs |
|
||||
| **Medium** | Likely unused, verify before delete | Orphan files, old archives, partially broken docs |
|
||||
| **High** | May have hidden dependencies | Files with some imports, recent modifications |
|
||||
|
||||
## Error Handling
|
||||
|
||||
| Situation | Action |
|
||||
|-----------|--------|
|
||||
| No git repository | Skip mainline detection, use file timestamps only |
|
||||
| Session in use (.archiving) | Skip with warning |
|
||||
| Permission denied | Report error, continue with others |
|
||||
| Manifest parse error | Regenerate from filesystem scan |
|
||||
| Empty discovery | Report "codebase is clean" |
|
||||
|
||||
## Related Commands
|
||||
|
||||
- `/workflow:session:complete` - Properly archive active sessions
|
||||
- `/memory:compact` - Save session memory before cleanup
|
||||
- `/workflow:status` - View current workflow state
|
||||
@@ -3,6 +3,7 @@ name: cli-init
|
||||
description: Generate .gemini/ and .qwen/ config directories with settings.json and ignore files based on workspace technology detection
|
||||
argument-hint: "[--tool gemini|qwen|all] [--output path] [--preview]"
|
||||
allowed-tools: Bash(*), Read(*), Write(*), Glob(*)
|
||||
group: cli
|
||||
---
|
||||
|
||||
# CLI Initialization Command (/cli:cli-init)
|
||||
|
||||
361
.claude/commands/cli/codex-review.md
Normal file
361
.claude/commands/cli/codex-review.md
Normal file
@@ -0,0 +1,361 @@
|
||||
---
|
||||
name: codex-review
|
||||
description: Interactive code review using Codex CLI via ccw endpoint with configurable review target, model, and custom instructions
|
||||
argument-hint: "[--uncommitted|--base <branch>|--commit <sha>] [--model <model>] [--title <title>] [prompt]"
|
||||
allowed-tools: Bash(*), AskUserQuestion(*), Read(*)
|
||||
---
|
||||
|
||||
# Codex Review Command (/cli:codex-review)
|
||||
|
||||
## Overview
|
||||
Interactive code review command that invokes `codex review` via ccw cli endpoint with guided parameter selection.
|
||||
|
||||
**Codex Review Parameters** (from `codex review --help`):
|
||||
| Parameter | Description |
|
||||
|-----------|-------------|
|
||||
| `[PROMPT]` | Custom review instructions (positional) |
|
||||
| `-c model=<model>` | Override model via config |
|
||||
| `--uncommitted` | Review staged, unstaged, and untracked changes |
|
||||
| `--base <BRANCH>` | Review changes against base branch |
|
||||
| `--commit <SHA>` | Review changes introduced by a commit |
|
||||
| `--title <TITLE>` | Optional commit title for review summary |
|
||||
|
||||
## Prompt Template Format
|
||||
|
||||
Follow the standard ccw cli prompt template:
|
||||
|
||||
```
|
||||
PURPOSE: [what] + [why] + [success criteria] + [constraints/scope]
|
||||
TASK: • [step 1] • [step 2] • [step 3]
|
||||
MODE: review
|
||||
CONTEXT: [review target description] | Memory: [relevant context]
|
||||
EXPECTED: [deliverable format] + [quality criteria]
|
||||
CONSTRAINTS: [focus constraints]
|
||||
```
|
||||
|
||||
## EXECUTION INSTRUCTIONS - START HERE
|
||||
|
||||
**When this command is triggered, follow these exact steps:**
|
||||
|
||||
### Step 1: Parse Arguments
|
||||
|
||||
Check if user provided arguments directly:
|
||||
- `--uncommitted` → Record target = uncommitted
|
||||
- `--base <branch>` → Record target = base, branch name
|
||||
- `--commit <sha>` → Record target = commit, sha value
|
||||
- `--model <model>` → Record model selection
|
||||
- `--title <title>` → Record title
|
||||
- Remaining text → Use as custom focus/prompt
|
||||
|
||||
If no target specified → Continue to Step 2 for interactive selection.
|
||||
|
||||
### Step 2: Interactive Parameter Selection
|
||||
|
||||
**2.1 Review Target Selection**
|
||||
|
||||
```javascript
|
||||
AskUserQuestion({
|
||||
questions: [{
|
||||
question: "What do you want to review?",
|
||||
header: "Review Target",
|
||||
options: [
|
||||
{ label: "Uncommitted changes (Recommended)", description: "Review staged, unstaged, and untracked changes" },
|
||||
{ label: "Compare to branch", description: "Review changes against a base branch (e.g., main)" },
|
||||
{ label: "Specific commit", description: "Review changes introduced by a specific commit" }
|
||||
],
|
||||
multiSelect: false
|
||||
}]
|
||||
})
|
||||
```
|
||||
|
||||
**2.2 Branch/Commit Input (if needed)**
|
||||
|
||||
If "Compare to branch" selected:
|
||||
```javascript
|
||||
AskUserQuestion({
|
||||
questions: [{
|
||||
question: "Which base branch to compare against?",
|
||||
header: "Base Branch",
|
||||
options: [
|
||||
{ label: "main", description: "Compare against main branch" },
|
||||
{ label: "master", description: "Compare against master branch" },
|
||||
{ label: "develop", description: "Compare against develop branch" }
|
||||
],
|
||||
multiSelect: false
|
||||
}]
|
||||
})
|
||||
```
|
||||
|
||||
If "Specific commit" selected:
|
||||
- Run `git log --oneline -10` to show recent commits
|
||||
- Ask user to provide commit SHA or select from list
|
||||
|
||||
**2.3 Model Selection (Optional)**
|
||||
|
||||
```javascript
|
||||
AskUserQuestion({
|
||||
questions: [{
|
||||
question: "Which model to use for review?",
|
||||
header: "Model",
|
||||
options: [
|
||||
{ label: "Default", description: "Use codex default model (gpt-5.2)" },
|
||||
{ label: "o3", description: "OpenAI o3 reasoning model" },
|
||||
{ label: "gpt-4.1", description: "GPT-4.1 model" },
|
||||
{ label: "o4-mini", description: "OpenAI o4-mini (faster)" }
|
||||
],
|
||||
multiSelect: false
|
||||
}]
|
||||
})
|
||||
```
|
||||
|
||||
**2.4 Review Focus Selection**
|
||||
|
||||
```javascript
|
||||
AskUserQuestion({
|
||||
questions: [{
|
||||
question: "What should the review focus on?",
|
||||
header: "Focus Area",
|
||||
options: [
|
||||
{ label: "General review (Recommended)", description: "Comprehensive review: correctness, style, bugs, docs" },
|
||||
{ label: "Security focus", description: "Security vulnerabilities, input validation, auth issues" },
|
||||
{ label: "Performance focus", description: "Performance bottlenecks, complexity, resource usage" },
|
||||
{ label: "Code quality", description: "Readability, maintainability, SOLID principles" }
|
||||
],
|
||||
multiSelect: false
|
||||
}]
|
||||
})
|
||||
```
|
||||
|
||||
### Step 3: Build Prompt and Command
|
||||
|
||||
**3.1 Construct Prompt Based on Focus**
|
||||
|
||||
**General Review Prompt:**
|
||||
```
|
||||
PURPOSE: Comprehensive code review to identify issues, improve quality, and ensure best practices; success = actionable feedback with clear priorities
|
||||
TASK: • Review code correctness and logic errors • Check coding standards and consistency • Identify potential bugs and edge cases • Evaluate documentation completeness
|
||||
MODE: review
|
||||
CONTEXT: {target_description} | Memory: Project conventions from CLAUDE.md
|
||||
EXPECTED: Structured review report with: severity levels (Critical/High/Medium/Low), file:line references, specific improvement suggestions, priority ranking
|
||||
CONSTRAINTS: Focus on actionable feedback
|
||||
```
|
||||
|
||||
**Security Focus Prompt:**
|
||||
```
|
||||
PURPOSE: Security-focused code review to identify vulnerabilities and security risks; success = all security issues documented with remediation
|
||||
TASK: • Scan for injection vulnerabilities (SQL, XSS, command) • Check authentication and authorization logic • Evaluate input validation and sanitization • Identify sensitive data exposure risks
|
||||
MODE: review
|
||||
CONTEXT: {target_description} | Memory: Security best practices, OWASP Top 10
|
||||
EXPECTED: Security report with: vulnerability classification, CVE references where applicable, remediation code snippets, risk severity matrix
|
||||
CONSTRAINTS: Security-first analysis | Flag all potential vulnerabilities
|
||||
```
|
||||
|
||||
**Performance Focus Prompt:**
|
||||
```
|
||||
PURPOSE: Performance-focused code review to identify bottlenecks and optimization opportunities; success = measurable improvement recommendations
|
||||
TASK: • Analyze algorithmic complexity (Big-O) • Identify memory allocation issues • Check for N+1 queries and blocking operations • Evaluate caching opportunities
|
||||
MODE: review
|
||||
CONTEXT: {target_description} | Memory: Performance patterns and anti-patterns
|
||||
EXPECTED: Performance report with: complexity analysis, bottleneck identification, optimization suggestions with expected impact, benchmark recommendations
|
||||
CONSTRAINTS: Performance optimization focus
|
||||
```
|
||||
|
||||
**Code Quality Focus Prompt:**
|
||||
```
|
||||
PURPOSE: Code quality review to improve maintainability and readability; success = cleaner, more maintainable code
|
||||
TASK: • Assess SOLID principles adherence • Identify code duplication and abstraction opportunities • Review naming conventions and clarity • Evaluate test coverage implications
|
||||
MODE: review
|
||||
CONTEXT: {target_description} | Memory: Project coding standards
|
||||
EXPECTED: Quality report with: principle violations, refactoring suggestions, naming improvements, maintainability score
|
||||
CONSTRAINTS: Code quality and maintainability focus
|
||||
```
|
||||
|
||||
**3.2 Build Target Description**
|
||||
|
||||
Based on selection, set `{target_description}`:
|
||||
- Uncommitted: `Reviewing uncommitted changes (staged + unstaged + untracked)`
|
||||
- Base branch: `Reviewing changes against {branch} branch`
|
||||
- Commit: `Reviewing changes introduced by commit {sha}`
|
||||
|
||||
### Step 4: Execute via CCW CLI
|
||||
|
||||
Build and execute the ccw cli command:
|
||||
|
||||
```bash
|
||||
# Base structure
|
||||
ccw cli -p "<PROMPT>" --tool codex --mode review [OPTIONS]
|
||||
```
|
||||
|
||||
**Command Construction:**
|
||||
|
||||
```bash
|
||||
# Variables from user selection
|
||||
TARGET_FLAG="" # --uncommitted | --base <branch> | --commit <sha>
|
||||
MODEL_FLAG="" # --model <model> (if not default)
|
||||
TITLE_FLAG="" # --title "<title>" (if provided)
|
||||
|
||||
# Build target flag
|
||||
if [ "$target" = "uncommitted" ]; then
|
||||
TARGET_FLAG="--uncommitted"
|
||||
elif [ "$target" = "base" ]; then
|
||||
TARGET_FLAG="--base $branch"
|
||||
elif [ "$target" = "commit" ]; then
|
||||
TARGET_FLAG="--commit $sha"
|
||||
fi
|
||||
|
||||
# Build model flag (only if not default)
|
||||
if [ "$model" != "default" ] && [ -n "$model" ]; then
|
||||
MODEL_FLAG="--model $model"
|
||||
fi
|
||||
|
||||
# Build title flag (if provided)
|
||||
if [ -n "$title" ]; then
|
||||
TITLE_FLAG="--title \"$title\""
|
||||
fi
|
||||
|
||||
# Execute
|
||||
ccw cli -p "$PROMPT" --tool codex --mode review $TARGET_FLAG $MODEL_FLAG $TITLE_FLAG
|
||||
```
|
||||
|
||||
**Full Example Commands:**
|
||||
|
||||
**Option 1: With custom prompt (reviews uncommitted by default):**
|
||||
```bash
|
||||
ccw cli -p "
|
||||
PURPOSE: Comprehensive code review to identify issues and improve quality; success = actionable feedback with priorities
|
||||
TASK: • Review correctness and logic • Check standards compliance • Identify bugs and edge cases • Evaluate documentation
|
||||
MODE: review
|
||||
CONTEXT: Reviewing uncommitted changes | Memory: Project conventions
|
||||
EXPECTED: Structured report with severity levels, file:line refs, improvement suggestions
|
||||
CONSTRAINTS: Actionable feedback
|
||||
" --tool codex --mode review --rule analysis-review-code-quality
|
||||
```
|
||||
|
||||
**Option 2: Target flag only (no prompt allowed):**
|
||||
```bash
|
||||
ccw cli --tool codex --mode review --uncommitted
|
||||
```
|
||||
|
||||
### Step 5: Execute and Display Results
|
||||
|
||||
```bash
|
||||
Bash({
|
||||
command: "ccw cli -p \"$PROMPT\" --tool codex --mode review $FLAGS",
|
||||
run_in_background: true
|
||||
})
|
||||
```
|
||||
|
||||
Wait for completion and display formatted results.
|
||||
|
||||
## Quick Usage Examples
|
||||
|
||||
### Direct Execution (No Interaction)
|
||||
|
||||
```bash
|
||||
# Review uncommitted changes with default settings
|
||||
/cli:codex-review --uncommitted
|
||||
|
||||
# Review against main branch
|
||||
/cli:codex-review --base main
|
||||
|
||||
# Review specific commit
|
||||
/cli:codex-review --commit abc123
|
||||
|
||||
# Review with custom model
|
||||
/cli:codex-review --uncommitted --model o3
|
||||
|
||||
# Review with security focus
|
||||
/cli:codex-review --uncommitted security
|
||||
|
||||
# Full options
|
||||
/cli:codex-review --base main --model o3 --title "Auth Feature" security
|
||||
```
|
||||
|
||||
### Interactive Mode
|
||||
|
||||
```bash
|
||||
# Start interactive selection (guided flow)
|
||||
/cli:codex-review
|
||||
```
|
||||
|
||||
## Focus Area Mapping
|
||||
|
||||
| User Selection | Prompt Focus | Key Checks |
|
||||
|----------------|--------------|------------|
|
||||
| General review | Comprehensive | Correctness, style, bugs, docs |
|
||||
| Security focus | Security-first | Injection, auth, validation, exposure |
|
||||
| Performance focus | Optimization | Complexity, memory, queries, caching |
|
||||
| Code quality | Maintainability | SOLID, duplication, naming, tests |
|
||||
|
||||
## Error Handling
|
||||
|
||||
### No Changes to Review
|
||||
```
|
||||
No changes found for review target. Suggestions:
|
||||
- For --uncommitted: Make some code changes first
|
||||
- For --base: Ensure branch exists and has diverged
|
||||
- For --commit: Verify commit SHA exists
|
||||
```
|
||||
|
||||
### Invalid Branch
|
||||
```bash
|
||||
# Show available branches
|
||||
git branch -a --list | head -20
|
||||
```
|
||||
|
||||
### Invalid Commit
|
||||
```bash
|
||||
# Show recent commits
|
||||
git log --oneline -10
|
||||
```
|
||||
|
||||
## Integration Notes
|
||||
|
||||
- Uses `ccw cli --tool codex --mode review` endpoint
|
||||
- Model passed via prompt (codex uses `-c model=` internally)
|
||||
- Target flags (`--uncommitted`, `--base`, `--commit`) passed through to codex
|
||||
- Prompt follows standard ccw cli template format for consistency
|
||||
|
||||
## Validation Constraints
|
||||
|
||||
**IMPORTANT: Target flags and prompt are mutually exclusive**
|
||||
|
||||
The codex CLI has a constraint where target flags (`--uncommitted`, `--base`, `--commit`) cannot be used with a positional `[PROMPT]` argument:
|
||||
|
||||
```
|
||||
error: the argument '--uncommitted' cannot be used with '[PROMPT]'
|
||||
error: the argument '--base <BRANCH>' cannot be used with '[PROMPT]'
|
||||
error: the argument '--commit <SHA>' cannot be used with '[PROMPT]'
|
||||
```
|
||||
|
||||
**Behavior:**
|
||||
- When ANY target flag is specified, ccw cli automatically skips template concatenation (systemRules/roles)
|
||||
- The review uses codex's default review behavior for the specified target
|
||||
- Custom prompts are only supported WITHOUT target flags (reviews uncommitted changes by default)
|
||||
|
||||
**Valid combinations:**
|
||||
| Command | Result |
|
||||
|---------|--------|
|
||||
| `codex review "Focus on security"` | ✓ Custom prompt, reviews uncommitted (default) |
|
||||
| `codex review --uncommitted` | ✓ No prompt, uses default review |
|
||||
| `codex review --base main` | ✓ No prompt, uses default review |
|
||||
| `codex review --commit abc123` | ✓ No prompt, uses default review |
|
||||
| `codex review --uncommitted "prompt"` | ✗ Invalid - mutually exclusive |
|
||||
| `codex review --base main "prompt"` | ✗ Invalid - mutually exclusive |
|
||||
| `codex review --commit abc123 "prompt"` | ✗ Invalid - mutually exclusive |
|
||||
|
||||
**Examples:**
|
||||
```bash
|
||||
# ✓ Valid: prompt only (reviews uncommitted by default)
|
||||
ccw cli -p "Focus on security" --tool codex --mode review
|
||||
|
||||
# ✓ Valid: target flag only (no prompt)
|
||||
ccw cli --tool codex --mode review --uncommitted
|
||||
ccw cli --tool codex --mode review --base main
|
||||
ccw cli --tool codex --mode review --commit abc123
|
||||
|
||||
# ✗ Invalid: target flag with prompt (will fail)
|
||||
ccw cli -p "Review this" --tool codex --mode review --uncommitted
|
||||
ccw cli -p "Review this" --tool codex --mode review --base main
|
||||
ccw cli -p "Review this" --tool codex --mode review --commit abc123
|
||||
```
|
||||
513
.claude/commands/codex-coordinator.md
Normal file
513
.claude/commands/codex-coordinator.md
Normal file
@@ -0,0 +1,513 @@
|
||||
---
|
||||
name: codex-coordinator
|
||||
description: Command orchestration tool for Codex - analyze requirements, recommend command chain, execute sequentially with state persistence
|
||||
argument-hint: "TASK=\"<task description>\" [--depth=standard|deep] [--auto-confirm] [--verbose]"
|
||||
---
|
||||
|
||||
# Codex Coordinator Command
|
||||
|
||||
Interactive orchestration tool for Codex commands: analyze task → discover commands → recommend chain → execute sequentially → track state.
|
||||
|
||||
**Execution Model**: Intelligent agent-driven workflow. Claude analyzes each phase and orchestrates command execution.
|
||||
|
||||
## Core Concept: Minimum Execution Units (最小执行单元)
|
||||
|
||||
### What is a Minimum Execution Unit?
|
||||
|
||||
**Definition**: A set of commands that must execute together as an atomic group to achieve a meaningful workflow milestone. Splitting these commands breaks the logical flow and creates incomplete states.
|
||||
|
||||
**Why This Matters**:
|
||||
- **Prevents Incomplete States**: Avoid stopping after task generation without execution
|
||||
- **User Experience**: User gets complete results, not intermediate artifacts requiring manual follow-up
|
||||
- **Workflow Integrity**: Maintains logical coherence of multi-step operations
|
||||
|
||||
### Codex Minimum Execution Units
|
||||
|
||||
**Planning + Execution Units** (规划+执行单元):
|
||||
|
||||
| Unit Name | Commands | Purpose | Output |
|
||||
|-----------|----------|---------|--------|
|
||||
| **Quick Implementation** | lite-plan-a → execute | Lightweight plan and immediate execution | Working code |
|
||||
| **Bug Fix** | lite-fix → execute | Quick bug diagnosis and fix execution | Fixed code |
|
||||
| **Issue Workflow** | issue-discover → issue-plan → issue-queue → issue-execute | Complete issue lifecycle | Completed issues |
|
||||
| **Discovery & Analysis** | issue-discover → issue-discover-by-prompt | Issue discovery with multiple perspectives | Generated issues |
|
||||
| **Brainstorm to Execution** | brainstorm-with-file → execute | Brainstorm ideas then implement | Working code |
|
||||
|
||||
**With-File Workflows** (文档化单元):
|
||||
|
||||
| Unit Name | Commands | Purpose | Output |
|
||||
|-----------|----------|---------|--------|
|
||||
| **Brainstorm With File** | brainstorm-with-file | Multi-perspective ideation with documentation | brainstorm.md |
|
||||
| **Debug With File** | debug-with-file | Hypothesis-driven debugging with documentation | understanding.md |
|
||||
| **Analyze With File** | analyze-with-file | Collaborative analysis with documentation | discussion.md |
|
||||
| **Clean & Analyze** | clean → analyze-with-file | Cleanup then analyze | Cleaned code + analysis |
|
||||
|
||||
### Command-to-Unit Mapping (命令与最小单元的映射)
|
||||
|
||||
| Command | Precedes | Atomic Units |
|
||||
|---------|----------|--------------|
|
||||
| lite-plan-a | execute, brainstorm-with-file | Quick Implementation |
|
||||
| lite-fix | execute | Bug Fix |
|
||||
| issue-discover | issue-plan | Issue Workflow |
|
||||
| issue-plan | issue-queue | Issue Workflow |
|
||||
| issue-queue | issue-execute | Issue Workflow |
|
||||
| brainstorm-with-file | execute, issue-execute | Brainstorm to Execution |
|
||||
| debug-with-file | execute | Debug With File |
|
||||
| analyze-with-file | (standalone) | Analyze With File |
|
||||
| clean | analyze-with-file, execute | Clean & Analyze |
|
||||
| quick-plan-with-file | execute | Quick Planning with File |
|
||||
| merge-plans-with-file | execute | Merge Multiple Plans |
|
||||
| unified-execute-with-file | (terminal) | Execute with File Tracking |
|
||||
|
||||
### Atomic Group Rules
|
||||
|
||||
1. **Never Split Units**: Coordinator must recommend complete units, not partial chains
|
||||
2. **Multi-Unit Participation**: Some commands can participate in multiple units
|
||||
3. **User Override**: User can explicitly request partial execution (advanced mode)
|
||||
4. **Visualization**: Pipeline view shows unit boundaries with 【 】markers
|
||||
5. **Validation**: Before execution, verify all unit commands are included
|
||||
|
||||
**Example Pipeline with Units**:
|
||||
```
|
||||
需求 → 【lite-plan-a → execute】→ 代码 → 【issue-discover → issue-plan → issue-queue → issue-execute】→ 完成
|
||||
└──── Quick Implementation ────┘ └────────── Issue Workflow ─────────┘
|
||||
```
|
||||
|
||||
## 3-Phase Workflow
|
||||
|
||||
### Phase 1: Analyze Requirements
|
||||
|
||||
Parse task to extract: goal, scope, complexity, and task type.
|
||||
|
||||
```javascript
|
||||
function analyzeRequirements(taskDescription) {
|
||||
return {
|
||||
goal: extractMainGoal(taskDescription), // e.g., "Fix login bug"
|
||||
scope: extractScope(taskDescription), // e.g., ["auth", "login"]
|
||||
complexity: determineComplexity(taskDescription), // 'simple' | 'medium' | 'complex'
|
||||
task_type: detectTaskType(taskDescription) // See task type patterns below
|
||||
};
|
||||
}
|
||||
|
||||
// Task Type Detection Patterns
|
||||
function detectTaskType(text) {
|
||||
// Priority order (first match wins)
|
||||
if (/fix|bug|error|crash|fail|debug|diagnose/.test(text)) return 'bugfix';
|
||||
if (/生成|generate|discover|找出|issue|问题/.test(text)) return 'discovery';
|
||||
if (/plan|规划|设计|design|analyze|分析/.test(text)) return 'analysis';
|
||||
if (/清理|cleanup|clean|refactor|重构/.test(text)) return 'cleanup';
|
||||
if (/头脑|brainstorm|创意|ideation/.test(text)) return 'brainstorm';
|
||||
if (/合并|merge|combine|batch/.test(text)) return 'batch-planning';
|
||||
return 'feature'; // Default
|
||||
}
|
||||
|
||||
// Complexity Assessment
|
||||
function determineComplexity(text) {
|
||||
let score = 0;
|
||||
if (/refactor|重构|migrate|迁移|architect|架构|system|系统/.test(text)) score += 2;
|
||||
if (/multiple|多个|across|跨|all|所有|entire|整个/.test(text)) score += 2;
|
||||
if (/integrate|集成|api|database|数据库/.test(text)) score += 1;
|
||||
if (/security|安全|performance|性能|scale|扩展/.test(text)) score += 1;
|
||||
return score >= 4 ? 'complex' : score >= 2 ? 'medium' : 'simple';
|
||||
}
|
||||
```
|
||||
|
||||
**Display to user**:
|
||||
```
|
||||
Analysis Complete:
|
||||
Goal: [extracted goal]
|
||||
Scope: [identified areas]
|
||||
Complexity: [level]
|
||||
Task Type: [detected type]
|
||||
```
|
||||
|
||||
### Phase 2: Discover Commands & Recommend Chain
|
||||
|
||||
Dynamic command chain assembly using task type and complexity matching.
|
||||
|
||||
#### Available Codex Commands (Discovery)
|
||||
|
||||
All commands from `~/.codex/prompts/`:
|
||||
- **Planning**: @~/.codex/prompts/lite-plan-a.md, @~/.codex/prompts/lite-plan-b.md, @~/.codex/prompts/lite-plan-c.md, @~/.codex/prompts/quick-plan-with-file.md, @~/.codex/prompts/merge-plans-with-file.md
|
||||
- **Execution**: @~/.codex/prompts/execute.md, @~/.codex/prompts/unified-execute-with-file.md
|
||||
- **Bug Fixes**: @~/.codex/prompts/lite-fix.md, @~/.codex/prompts/debug-with-file.md
|
||||
- **Discovery**: @~/.codex/prompts/issue-discover.md, @~/.codex/prompts/issue-discover-by-prompt.md, @~/.codex/prompts/issue-plan.md, @~/.codex/prompts/issue-queue.md, @~/.codex/prompts/issue-execute.md
|
||||
- **Analysis**: @~/.codex/prompts/analyze-with-file.md
|
||||
- **Brainstorming**: @~/.codex/prompts/brainstorm-with-file.md, @~/.codex/prompts/brainstorm-to-cycle.md
|
||||
- **Cleanup**: @~/.codex/prompts/clean.md, @~/.codex/prompts/compact.md
|
||||
|
||||
#### Recommendation Algorithm
|
||||
|
||||
```javascript
|
||||
async function recommendCommandChain(analysis) {
|
||||
// Step 1: 根据任务类型确定流程
|
||||
const { inputPort, outputPort } = determinePortFlow(analysis.task_type, analysis.complexity);
|
||||
|
||||
// Step 2: Claude 根据命令特性和任务特征,智能选择命令序列
|
||||
const chain = selectChainByTaskType(analysis);
|
||||
|
||||
return chain;
|
||||
}
|
||||
|
||||
// 任务类型对应的端口流
|
||||
function determinePortFlow(taskType, complexity) {
|
||||
const flows = {
|
||||
'bugfix': { flow: ['lite-fix', 'execute'], depth: complexity === 'complex' ? 'deep' : 'standard' },
|
||||
'discovery': { flow: ['issue-discover', 'issue-plan', 'issue-queue', 'issue-execute'], depth: 'standard' },
|
||||
'analysis': { flow: ['analyze-with-file'], depth: complexity === 'complex' ? 'deep' : 'standard' },
|
||||
'cleanup': { flow: ['clean'], depth: 'standard' },
|
||||
'brainstorm': { flow: ['brainstorm-with-file', 'execute'], depth: complexity === 'complex' ? 'deep' : 'standard' },
|
||||
'batch-planning': { flow: ['merge-plans-with-file', 'execute'], depth: 'standard' },
|
||||
'feature': { flow: complexity === 'complex' ? ['lite-plan-b'] : ['lite-plan-a', 'execute'], depth: complexity === 'complex' ? 'deep' : 'standard' }
|
||||
};
|
||||
return flows[taskType] || flows['feature'];
|
||||
}
|
||||
```
|
||||
|
||||
#### Display to User
|
||||
|
||||
```
|
||||
Recommended Command Chain:
|
||||
|
||||
Pipeline (管道视图):
|
||||
需求 → @~/.codex/prompts/lite-plan-a.md → 计划 → @~/.codex/prompts/execute.md → 代码完成
|
||||
|
||||
Commands (命令列表):
|
||||
1. @~/.codex/prompts/lite-plan-a.md
|
||||
2. @~/.codex/prompts/execute.md
|
||||
|
||||
Proceed? [Confirm / Show Details / Adjust / Cancel]
|
||||
```
|
||||
|
||||
### Phase 2b: Get User Confirmation
|
||||
|
||||
Ask user for confirmation before proceeding with execution.
|
||||
|
||||
```javascript
|
||||
async function getUserConfirmation(chain) {
|
||||
const response = await AskUserQuestion({
|
||||
questions: [{
|
||||
question: 'Proceed with this command chain?',
|
||||
header: 'Confirm Chain',
|
||||
multiSelect: false,
|
||||
options: [
|
||||
{ label: 'Confirm and execute', description: 'Proceed with commands' },
|
||||
{ label: 'Show details', description: 'View each command' },
|
||||
{ label: 'Adjust chain', description: 'Remove or reorder' },
|
||||
{ label: 'Cancel', description: 'Abort' }
|
||||
]
|
||||
}]
|
||||
});
|
||||
|
||||
return response;
|
||||
}
|
||||
```
|
||||
|
||||
### Phase 3: Execute Sequential Command Chain
|
||||
|
||||
```javascript
|
||||
async function executeCommandChain(chain, analysis) {
|
||||
const sessionId = `codex-coord-${Date.now()}`;
|
||||
const stateDir = `.workflow/.codex-coordinator/${sessionId}`;
|
||||
|
||||
// Create state directory
|
||||
const state = {
|
||||
session_id: sessionId,
|
||||
status: 'running',
|
||||
created_at: new Date().toISOString(),
|
||||
analysis: analysis,
|
||||
command_chain: chain.map((cmd, idx) => ({ ...cmd, index: idx, status: 'pending' })),
|
||||
execution_results: [],
|
||||
};
|
||||
|
||||
// Save initial state
|
||||
Write(`${stateDir}/state.json`, JSON.stringify(state, null, 2));
|
||||
|
||||
for (let i = 0; i < chain.length; i++) {
|
||||
const cmd = chain[i];
|
||||
console.log(`[${i+1}/${chain.length}] Executing: @~/.codex/prompts/${cmd.name}.md`);
|
||||
|
||||
// Update status to running
|
||||
state.command_chain[i].status = 'running';
|
||||
state.updated_at = new Date().toISOString();
|
||||
Write(`${stateDir}/state.json`, JSON.stringify(state, null, 2));
|
||||
|
||||
try {
|
||||
// Build command with parameters using full path
|
||||
let commandStr = `@~/.codex/prompts/${cmd.name}.md`;
|
||||
|
||||
// Add parameters based on previous results and task context
|
||||
if (i > 0 && state.execution_results.length > 0) {
|
||||
const lastResult = state.execution_results[state.execution_results.length - 1];
|
||||
commandStr += ` --resume="${lastResult.session_id || lastResult.artifact}"`;
|
||||
}
|
||||
|
||||
// For analysis-based commands, add depth parameter
|
||||
if (analysis.complexity === 'complex' && (cmd.name.includes('analyze') || cmd.name.includes('plan'))) {
|
||||
commandStr += ` --depth=deep`;
|
||||
}
|
||||
|
||||
// Add task description for planning commands
|
||||
if (cmd.type === 'planning' && i === 0) {
|
||||
commandStr += ` TASK="${analysis.goal}"`;
|
||||
}
|
||||
|
||||
// Execute command via Bash (spawning as background task)
|
||||
// Format: @~/.codex/prompts/command-name.md [] parameters
|
||||
// Note: This simulates the execution; actual implementation uses hook callbacks
|
||||
console.log(`Executing: ${commandStr}`);
|
||||
|
||||
// Save execution record
|
||||
state.execution_results.push({
|
||||
index: i,
|
||||
command: cmd.name,
|
||||
status: 'in-progress',
|
||||
started_at: new Date().toISOString(),
|
||||
session_id: null,
|
||||
artifact: null
|
||||
});
|
||||
|
||||
state.command_chain[i].status = 'completed';
|
||||
state.updated_at = new Date().toISOString();
|
||||
Write(`${stateDir}/state.json`, JSON.stringify(state, null, 2));
|
||||
|
||||
console.log(`[${i+1}/${chain.length}] ✓ Completed: @~/.codex/prompts/${cmd.name}.md`);
|
||||
|
||||
} catch (error) {
|
||||
state.command_chain[i].status = 'failed';
|
||||
state.updated_at = new Date().toISOString();
|
||||
Write(`${stateDir}/state.json`, JSON.stringify(state, null, 2));
|
||||
|
||||
console.log(`❌ Command failed: ${error.message}`);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
state.status = 'completed';
|
||||
state.updated_at = new Date().toISOString();
|
||||
Write(`${stateDir}/state.json`, JSON.stringify(state, null, 2));
|
||||
|
||||
console.log(`\n✅ Orchestration Complete: ${state.session_id}`);
|
||||
return state;
|
||||
}
|
||||
```
|
||||
|
||||
## State File Structure
|
||||
|
||||
**Location**: `.workflow/.codex-coordinator/{session_id}/state.json`
|
||||
|
||||
```json
|
||||
{
|
||||
"session_id": "codex-coord-20250129-143025",
|
||||
"status": "running|waiting|completed|failed",
|
||||
"created_at": "2025-01-29T14:30:25Z",
|
||||
"updated_at": "2025-01-29T14:35:45Z",
|
||||
"analysis": {
|
||||
"goal": "Fix login authentication bug",
|
||||
"scope": ["auth", "login"],
|
||||
"complexity": "medium",
|
||||
"task_type": "bugfix"
|
||||
},
|
||||
"command_chain": [
|
||||
{
|
||||
"index": 0,
|
||||
"name": "lite-fix",
|
||||
"type": "bugfix",
|
||||
"status": "completed"
|
||||
},
|
||||
{
|
||||
"index": 1,
|
||||
"name": "execute",
|
||||
"type": "execution",
|
||||
"status": "pending"
|
||||
}
|
||||
],
|
||||
"execution_results": [
|
||||
{
|
||||
"index": 0,
|
||||
"command": "lite-fix",
|
||||
"status": "completed",
|
||||
"started_at": "2025-01-29T14:30:25Z",
|
||||
"session_id": "fix-login-2025-01-29",
|
||||
"artifact": ".workflow/.lite-fix/fix-login-2025-01-29/fix-plan.json"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
### Status Values
|
||||
|
||||
- `running`: Orchestrator actively executing
|
||||
- `waiting`: Paused, waiting for external events
|
||||
- `completed`: All commands finished successfully
|
||||
- `failed`: Error occurred or user aborted
|
||||
|
||||
## Task Type Routing (Pipeline Summary)
|
||||
|
||||
**Note**: 【 】marks Minimum Execution Units (最小执行单元) - these commands must execute together.
|
||||
|
||||
| Task Type | Pipeline | Minimum Units |
|
||||
|-----------|----------|---|
|
||||
| **bugfix** | Bug报告 →【@~/.codex/prompts/lite-fix.md → @~/.codex/prompts/execute.md】→ 修复代码 | Bug Fix |
|
||||
| **discovery** | 需求 →【@~/.codex/prompts/issue-discover.md → @~/.codex/prompts/issue-plan.md → @~/.codex/prompts/issue-queue.md → @~/.codex/prompts/issue-execute.md】→ 完成 issues | Issue Workflow |
|
||||
| **analysis** | 需求 → @~/.codex/prompts/analyze-with-file.md → 分析报告 | Analyze With File |
|
||||
| **cleanup** | 代码库 → @~/.codex/prompts/clean.md → 清理完成 | Cleanup |
|
||||
| **brainstorm** | 主题 →【@~/.codex/prompts/brainstorm-with-file.md → @~/.codex/prompts/execute.md】→ 实现代码 | Brainstorm to Execution |
|
||||
| **batch-planning** | 需求集合 →【@~/.codex/prompts/merge-plans-with-file.md → @~/.codex/prompts/execute.md】→ 代码完成 | Merge Multiple Plans |
|
||||
| **feature** (simple) | 需求 →【@~/.codex/prompts/lite-plan-a.md → @~/.codex/prompts/execute.md】→ 代码 | Quick Implementation |
|
||||
| **feature** (complex) | 需求 → @~/.codex/prompts/lite-plan-b.md → 详细计划 → @~/.codex/prompts/execute.md → 代码 | Complex Planning |
|
||||
|
||||
## Available Commands Reference
|
||||
|
||||
### Planning Commands
|
||||
|
||||
| Command | Purpose | Usage | Output |
|
||||
|---------|---------|-------|--------|
|
||||
| **lite-plan-a** | Lightweight merged-mode planning | `@~/.codex/prompts/lite-plan-a.md TASK="..."` | plan.json |
|
||||
| **lite-plan-b** | Multi-angle exploration planning | `@~/.codex/prompts/lite-plan-b.md TASK="..."` | plan.json |
|
||||
| **lite-plan-c** | Parallel angle planning | `@~/.codex/prompts/lite-plan-c.md TASK="..."` | plan.json |
|
||||
| **quick-plan-with-file** | Quick planning with file tracking | `@~/.codex/prompts/quick-plan-with-file.md TASK="..."` | plan + docs |
|
||||
| **merge-plans-with-file** | Merge multiple plans | `@~/.codex/prompts/merge-plans-with-file.md PLANS="..."` | merged-plan.json |
|
||||
|
||||
### Execution Commands
|
||||
|
||||
| Command | Purpose | Usage | Output |
|
||||
|---------|---------|-------|--------|
|
||||
| **execute** | Execute tasks from plan | `@~/.codex/prompts/execute.md SESSION=".../plan/"` | Working code |
|
||||
| **unified-execute-with-file** | Execute with file tracking | `@~/.codex/prompts/unified-execute-with-file.md SESSION="..."` | Code + tracking |
|
||||
|
||||
### Bug Fix Commands
|
||||
|
||||
| Command | Purpose | Usage | Output |
|
||||
|---------|---------|-------|--------|
|
||||
| **lite-fix** | Quick bug diagnosis and planning | `@~/.codex/prompts/lite-fix.md BUG="..."` | fix-plan.json |
|
||||
| **debug-with-file** | Hypothesis-driven debugging | `@~/.codex/prompts/debug-with-file.md BUG="..."` | understanding.md |
|
||||
|
||||
### Discovery Commands
|
||||
|
||||
| Command | Purpose | Usage | Output |
|
||||
|---------|---------|-------|--------|
|
||||
| **issue-discover** | Multi-perspective issue discovery | `@~/.codex/prompts/issue-discover.md PATTERN="src/**"` | issues.jsonl |
|
||||
| **issue-discover-by-prompt** | Prompt-based discovery | `@~/.codex/prompts/issue-discover-by-prompt.md PROMPT="..."` | issues |
|
||||
| **issue-plan** | Plan issue solutions | `@~/.codex/prompts/issue-plan.md --all-pending` | issue-plans.json |
|
||||
| **issue-queue** | Form execution queue | `@~/.codex/prompts/issue-queue.md --from-plan` | queue.json |
|
||||
| **issue-execute** | Execute issue queue | `@~/.codex/prompts/issue-execute.md QUEUE="..."` | Completed |
|
||||
|
||||
### Analysis Commands
|
||||
|
||||
| Command | Purpose | Usage | Output |
|
||||
|---------|---------|-------|--------|
|
||||
| **analyze-with-file** | Collaborative analysis | `@~/.codex/prompts/analyze-with-file.md TOPIC="..."` | discussion.md |
|
||||
|
||||
### Brainstorm Commands
|
||||
|
||||
| Command | Purpose | Usage | Output |
|
||||
|---------|---------|-------|--------|
|
||||
| **brainstorm-with-file** | Multi-perspective brainstorming | `@~/.codex/prompts/brainstorm-with-file.md TOPIC="..."` | brainstorm.md |
|
||||
| **brainstorm-to-cycle** | Bridge brainstorm to execution | `@~/.codex/prompts/brainstorm-to-cycle.md` | Executable plan |
|
||||
|
||||
### Utility Commands
|
||||
|
||||
| Command | Purpose | Usage | Output |
|
||||
|---------|---------|-------|--------|
|
||||
| **clean** | Intelligent code cleanup | `@~/.codex/prompts/clean.md` | Cleaned code |
|
||||
| **compact** | Compact session memory | `@~/.codex/prompts/compact.md SESSION="..."` | Compressed state |
|
||||
|
||||
## Execution Flow
|
||||
|
||||
```
|
||||
User Input: TASK="..."
|
||||
↓
|
||||
Phase 1: analyzeRequirements(task)
|
||||
↓
|
||||
Phase 2: recommendCommandChain(analysis)
|
||||
Display pipeline and commands
|
||||
↓
|
||||
User Confirmation
|
||||
↓
|
||||
Phase 3: executeCommandChain(chain, analysis)
|
||||
├─ For each command:
|
||||
│ ├─ Update state to "running"
|
||||
│ ├─ Build command string with parameters
|
||||
│ ├─ Execute @command [] with parameters
|
||||
│ ├─ Save execution results
|
||||
│ └─ Update state to "completed"
|
||||
↓
|
||||
Output completion summary
|
||||
```
|
||||
|
||||
## Key Design Principles
|
||||
|
||||
1. **Atomic Execution** - Never split minimum execution units
|
||||
2. **State Persistence** - All state saved to JSON
|
||||
3. **User Control** - Confirmation before execution
|
||||
4. **Context Passing** - Parameters chain across commands
|
||||
5. **Resume Support** - Can resume from state.json
|
||||
6. **Intelligent Routing** - Task type determines command chain
|
||||
7. **Complexity Awareness** - Different paths for simple vs complex tasks
|
||||
|
||||
## Command Invocation Format
|
||||
|
||||
**Format**: `@~/.codex/prompts/<command-name>.md <parameters>`
|
||||
|
||||
**Examples**:
|
||||
```bash
|
||||
@~/.codex/prompts/lite-plan-a.md TASK="Implement user authentication"
|
||||
@~/.codex/prompts/execute.md SESSION=".workflow/.lite-plan/..."
|
||||
@~/.codex/prompts/lite-fix.md BUG="Login fails with 404 error"
|
||||
@~/.codex/prompts/issue-discover.md PATTERN="src/auth/**"
|
||||
@~/.codex/prompts/brainstorm-with-file.md TOPIC="Improve user onboarding"
|
||||
```
|
||||
|
||||
## Error Handling
|
||||
|
||||
| Situation | Action |
|
||||
|-----------|--------|
|
||||
| Unknown task type | Default to feature implementation |
|
||||
| Command not found | Error: command not available |
|
||||
| Execution fails | Report error, offer retry or skip |
|
||||
| Invalid parameters | Validate and ask for correction |
|
||||
| Circular dependency | Detect and report |
|
||||
| All commands fail | Report and suggest manual intervention |
|
||||
|
||||
## Session Management
|
||||
|
||||
**Resume Previous Session**:
|
||||
```
|
||||
1. Find session in .workflow/.codex-coordinator/
|
||||
2. Load state.json
|
||||
3. Identify last completed command
|
||||
4. Restart from next pending command
|
||||
```
|
||||
|
||||
**View Session Progress**:
|
||||
```
|
||||
cat .workflow/.codex-coordinator/{session-id}/state.json
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Execution Instructions
|
||||
|
||||
The coordinator workflow follows these steps:
|
||||
|
||||
1. **Parse Input**: Extract task description from TASK parameter
|
||||
2. **Analyze**: Determine goal, scope, complexity, and task type
|
||||
3. **Recommend**: Build optimal command chain based on analysis
|
||||
4. **Confirm**: Display pipeline and request user approval
|
||||
5. **Execute**: Run commands sequentially with state tracking
|
||||
6. **Report**: Display final results and artifacts
|
||||
|
||||
To use this coordinator, invoke it as a Claude Code command (not a Codex command):
|
||||
|
||||
From the Claude Code CLI, you would call Codex commands like:
|
||||
```bash
|
||||
@~/.codex/prompts/lite-plan-a.md TASK="Your task description"
|
||||
```
|
||||
|
||||
Or with options:
|
||||
```bash
|
||||
@~/.codex/prompts/lite-plan-a.md TASK="..." --depth=deep
|
||||
```
|
||||
|
||||
This coordinator orchestrates such Codex commands based on your task requirements.
|
||||
@@ -1,93 +0,0 @@
|
||||
---
|
||||
name: enhance-prompt
|
||||
description: Enhanced prompt transformation using session memory and intent analysis with --enhance flag detection
|
||||
argument-hint: "user input to enhance"
|
||||
---
|
||||
|
||||
## Overview
|
||||
|
||||
Systematically enhances user prompts by leveraging session memory context and intent analysis, translating ambiguous requests into actionable specifications.
|
||||
|
||||
## Core Protocol
|
||||
|
||||
**Enhancement Pipeline:**
|
||||
`Intent Translation` → `Context Integration` → `Structured Output`
|
||||
|
||||
**Context Sources:**
|
||||
- Session memory (conversation history, previous analysis)
|
||||
- Implicit technical requirements
|
||||
- User intent patterns
|
||||
|
||||
## Enhancement Rules
|
||||
|
||||
### Intent Translation
|
||||
|
||||
| User Says | Translate To | Focus |
|
||||
|-----------|--------------|-------|
|
||||
| "fix" | Debug and resolve | Root cause → preserve behavior |
|
||||
| "improve" | Enhance/optimize | Performance/readability |
|
||||
| "add" | Implement feature | Integration + edge cases |
|
||||
| "refactor" | Restructure quality | Maintain behavior |
|
||||
| "update" | Modernize | Version compatibility |
|
||||
|
||||
### Context Integration Strategy
|
||||
|
||||
**Session Memory:**
|
||||
- Reference recent conversation context
|
||||
- Reuse previously identified patterns
|
||||
- Build on established understanding
|
||||
- Infer technical requirements from discussion
|
||||
|
||||
**Example:**
|
||||
```bash
|
||||
# User: "add login"
|
||||
# Session Memory: Previous auth discussion, JWT mentioned
|
||||
# Inferred: JWT-based auth, integrate with existing session management
|
||||
# Action: Implement JWT authentication with session persistence
|
||||
```
|
||||
|
||||
## Output Structure
|
||||
|
||||
```bash
|
||||
INTENT: [Clear technical goal]
|
||||
CONTEXT: [Session memory + codebase patterns]
|
||||
ACTION: [Specific implementation steps]
|
||||
ATTENTION: [Critical constraints]
|
||||
```
|
||||
|
||||
### Output Examples
|
||||
|
||||
**Example 1:**
|
||||
```bash
|
||||
# Input: "fix login button"
|
||||
INTENT: Debug non-functional login button
|
||||
CONTEXT: From session - OAuth flow discussed, known state issue
|
||||
ACTION: Check event binding → verify state updates → test auth flow
|
||||
ATTENTION: Preserve existing OAuth integration
|
||||
```
|
||||
|
||||
**Example 2:**
|
||||
```bash
|
||||
# Input: "refactor payment code"
|
||||
INTENT: Restructure payment module for maintainability
|
||||
CONTEXT: Session memory - PCI compliance requirements, Stripe integration patterns
|
||||
ACTION: Extract reusable validators → isolate payment gateway logic → maintain adapter pattern
|
||||
ATTENTION: Zero behavior change, maintain PCI compliance, full test coverage
|
||||
```
|
||||
|
||||
## Enhancement Triggers
|
||||
|
||||
- Ambiguous language: "fix", "improve", "clean up"
|
||||
- Vague requests requiring clarification
|
||||
- Complex technical requirements
|
||||
- Architecture changes
|
||||
- Critical systems: auth, payment, security
|
||||
- Multi-step refactoring
|
||||
|
||||
## Key Principles
|
||||
|
||||
1. **Session Memory First**: Leverage conversation context and established understanding
|
||||
2. **Context Reuse**: Build on previous discussions and decisions
|
||||
3. **Clear Output**: Structured, actionable specifications
|
||||
4. **Intent Clarification**: Transform vague requests into specific technical goals
|
||||
5. **Avoid Duplication**: Reference existing context, don't repeat
|
||||
675
.claude/commands/flow-create.md
Normal file
675
.claude/commands/flow-create.md
Normal file
@@ -0,0 +1,675 @@
|
||||
# Flow Template Generator
|
||||
|
||||
Generate workflow templates for meta-skill/flow-coordinator.
|
||||
|
||||
## Usage
|
||||
|
||||
```
|
||||
/meta-skill:flow-create [template-name] [--output <path>]
|
||||
```
|
||||
|
||||
**Examples**:
|
||||
```bash
|
||||
/meta-skill:flow-create bugfix-v2
|
||||
/meta-skill:flow-create my-workflow --output ~/.claude/skills/my-skill/templates/
|
||||
```
|
||||
|
||||
## Execution Flow
|
||||
|
||||
```
|
||||
User Input → Phase 1: Template Design → Phase 2: Step Definition → Phase 3: Generate JSON
|
||||
↓ ↓ ↓
|
||||
Name + Description Define workflow steps Write template file
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Phase 1: Template Design
|
||||
|
||||
Gather basic template information:
|
||||
|
||||
```javascript
|
||||
async function designTemplate(input) {
|
||||
const templateName = parseTemplateName(input) || await askTemplateName();
|
||||
|
||||
const metadata = await AskUserQuestion({
|
||||
questions: [
|
||||
{
|
||||
question: "What is the purpose of this workflow template?",
|
||||
header: "Purpose",
|
||||
options: [
|
||||
{ label: "Feature Development", description: "Implement new features with planning and testing" },
|
||||
{ label: "Bug Fix", description: "Diagnose and fix bugs with verification" },
|
||||
{ label: "TDD Development", description: "Test-driven development workflow" },
|
||||
{ label: "Code Review", description: "Review cycle with findings and fixes" },
|
||||
{ label: "Testing", description: "Test generation and validation" },
|
||||
{ label: "Issue Workflow", description: "Complete issue lifecycle (discover → plan → queue → execute)" },
|
||||
{ label: "With-File Workflow", description: "Documented exploration (brainstorm/debug/analyze)" },
|
||||
{ label: "Custom", description: "Define custom workflow purpose" }
|
||||
],
|
||||
multiSelect: false
|
||||
},
|
||||
{
|
||||
question: "What complexity level?",
|
||||
header: "Level",
|
||||
options: [
|
||||
{ label: "Level 1 (Rapid)", description: "1-2 steps, ultra-lightweight (lite-lite-lite)" },
|
||||
{ label: "Level 2 (Lightweight)", description: "2-4 steps, quick implementation" },
|
||||
{ label: "Level 3 (Standard)", description: "4-6 steps, with verification and testing" },
|
||||
{ label: "Level 4 (Full)", description: "6+ steps, brainstorm + full workflow" }
|
||||
],
|
||||
multiSelect: false
|
||||
}
|
||||
]
|
||||
});
|
||||
|
||||
return {
|
||||
name: templateName,
|
||||
description: generateDescription(templateName, metadata.Purpose),
|
||||
level: parseLevel(metadata.Level),
|
||||
purpose: metadata.Purpose
|
||||
};
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Phase 2: Step Definition
|
||||
|
||||
### Step 2.1: Select Command Category
|
||||
|
||||
```javascript
|
||||
async function selectCommandCategory() {
|
||||
return await AskUserQuestion({
|
||||
questions: [{
|
||||
question: "Select command category",
|
||||
header: "Category",
|
||||
options: [
|
||||
{ label: "Planning", description: "lite-plan, plan, multi-cli-plan, tdd-plan, quick-plan-with-file" },
|
||||
{ label: "Execution", description: "lite-execute, execute, unified-execute-with-file" },
|
||||
{ label: "Testing", description: "test-fix-gen, test-cycle-execute, test-gen, tdd-verify" },
|
||||
{ label: "Review", description: "review-session-cycle, review-module-cycle, review-cycle-fix" },
|
||||
{ label: "Bug Fix", description: "lite-fix, debug-with-file" },
|
||||
{ label: "Brainstorm", description: "brainstorm-with-file, brainstorm:auto-parallel" },
|
||||
{ label: "Analysis", description: "analyze-with-file" },
|
||||
{ label: "Issue", description: "discover, plan, queue, execute, from-brainstorm, convert-to-plan" },
|
||||
{ label: "Utility", description: "clean, init, replan, status" }
|
||||
],
|
||||
multiSelect: false
|
||||
}]
|
||||
});
|
||||
}
|
||||
```
|
||||
|
||||
### Step 2.2: Select Specific Command
|
||||
|
||||
```javascript
|
||||
async function selectCommand(category) {
|
||||
const commandOptions = {
|
||||
'Planning': [
|
||||
{ label: "/workflow:lite-plan", description: "Lightweight merged-mode planning" },
|
||||
{ label: "/workflow:plan", description: "Full planning with architecture design" },
|
||||
{ label: "/workflow:multi-cli-plan", description: "Multi-CLI collaborative planning (Gemini+Codex+Claude)" },
|
||||
{ label: "/workflow:tdd-plan", description: "TDD workflow planning with Red-Green-Refactor" },
|
||||
{ label: "/workflow:quick-plan-with-file", description: "Rapid planning with minimal docs" },
|
||||
{ label: "/workflow:plan-verify", description: "Verify plan against requirements" },
|
||||
{ label: "/workflow:replan", description: "Update plan and execute changes" }
|
||||
],
|
||||
'Execution': [
|
||||
{ label: "/workflow:lite-execute", description: "Execute from in-memory plan" },
|
||||
{ label: "/workflow:execute", description: "Execute from planning session" },
|
||||
{ label: "/workflow:unified-execute-with-file", description: "Universal execution engine" },
|
||||
{ label: "/workflow:lite-lite-lite", description: "Ultra-lightweight multi-tool execution" }
|
||||
],
|
||||
'Testing': [
|
||||
{ label: "/workflow:test-fix-gen", description: "Generate test tasks for specific issues" },
|
||||
{ label: "/workflow:test-cycle-execute", description: "Execute iterative test-fix cycle (>=95% pass)" },
|
||||
{ label: "/workflow:test-gen", description: "Generate comprehensive test suite" },
|
||||
{ label: "/workflow:tdd-verify", description: "Verify TDD workflow compliance" }
|
||||
],
|
||||
'Review': [
|
||||
{ label: "/workflow:review-session-cycle", description: "Session-based multi-dimensional code review" },
|
||||
{ label: "/workflow:review-module-cycle", description: "Module-focused code review" },
|
||||
{ label: "/workflow:review-cycle-fix", description: "Fix review findings with prioritization" },
|
||||
{ label: "/workflow:review", description: "Post-implementation review" }
|
||||
],
|
||||
'Bug Fix': [
|
||||
{ label: "/workflow:lite-fix", description: "Lightweight bug diagnosis and fix" },
|
||||
{ label: "/workflow:debug-with-file", description: "Hypothesis-driven debugging with documentation" }
|
||||
],
|
||||
'Brainstorm': [
|
||||
{ label: "/workflow:brainstorm-with-file", description: "Multi-perspective ideation with documentation" },
|
||||
{ label: "/workflow:brainstorm:auto-parallel", description: "Parallel multi-role brainstorming" }
|
||||
],
|
||||
'Analysis': [
|
||||
{ label: "/workflow:analyze-with-file", description: "Collaborative analysis with documentation" }
|
||||
],
|
||||
'Issue': [
|
||||
{ label: "/issue:discover", description: "Multi-perspective issue discovery" },
|
||||
{ label: "/issue:discover-by-prompt", description: "Prompt-based issue discovery with Gemini" },
|
||||
{ label: "/issue:plan", description: "Plan issue solutions" },
|
||||
{ label: "/issue:queue", description: "Form execution queue with conflict analysis" },
|
||||
{ label: "/issue:execute", description: "Execute issue queue with DAG orchestration" },
|
||||
{ label: "/issue:from-brainstorm", description: "Convert brainstorm to issue" },
|
||||
{ label: "/issue:convert-to-plan", description: "Convert planning artifacts to issue solutions" }
|
||||
],
|
||||
'Utility': [
|
||||
{ label: "/workflow:clean", description: "Intelligent code cleanup" },
|
||||
{ label: "/workflow:init", description: "Initialize project-level state" },
|
||||
{ label: "/workflow:replan", description: "Interactive workflow replanning" },
|
||||
{ label: "/workflow:status", description: "Generate workflow status views" }
|
||||
]
|
||||
};
|
||||
|
||||
return await AskUserQuestion({
|
||||
questions: [{
|
||||
question: `Select ${category} command`,
|
||||
header: "Command",
|
||||
options: commandOptions[category] || commandOptions['Planning'],
|
||||
multiSelect: false
|
||||
}]
|
||||
});
|
||||
}
|
||||
```
|
||||
|
||||
### Step 2.3: Select Execution Unit
|
||||
|
||||
```javascript
|
||||
async function selectExecutionUnit() {
|
||||
return await AskUserQuestion({
|
||||
questions: [{
|
||||
question: "Select execution unit (atomic command group)",
|
||||
header: "Unit",
|
||||
options: [
|
||||
// Planning + Execution Units
|
||||
{ label: "quick-implementation", description: "【lite-plan → lite-execute】" },
|
||||
{ label: "multi-cli-planning", description: "【multi-cli-plan → lite-execute】" },
|
||||
{ label: "full-planning-execution", description: "【plan → execute】" },
|
||||
{ label: "verified-planning-execution", description: "【plan → plan-verify → execute】" },
|
||||
{ label: "replanning-execution", description: "【replan → execute】" },
|
||||
{ label: "tdd-planning-execution", description: "【tdd-plan → execute】" },
|
||||
// Testing Units
|
||||
{ label: "test-validation", description: "【test-fix-gen → test-cycle-execute】" },
|
||||
{ label: "test-generation-execution", description: "【test-gen → execute】" },
|
||||
// Review Units
|
||||
{ label: "code-review", description: "【review-*-cycle → review-cycle-fix】" },
|
||||
// Bug Fix Units
|
||||
{ label: "bug-fix", description: "【lite-fix → lite-execute】" },
|
||||
// Issue Units
|
||||
{ label: "issue-workflow", description: "【discover → plan → queue → execute】" },
|
||||
{ label: "rapid-to-issue", description: "【lite-plan → convert-to-plan → queue → execute】" },
|
||||
{ label: "brainstorm-to-issue", description: "【from-brainstorm → queue → execute】" },
|
||||
// With-File Units (self-contained)
|
||||
{ label: "brainstorm-with-file", description: "Self-contained brainstorming workflow" },
|
||||
{ label: "debug-with-file", description: "Self-contained debugging workflow" },
|
||||
{ label: "analyze-with-file", description: "Self-contained analysis workflow" },
|
||||
// Standalone
|
||||
{ label: "standalone", description: "Single command, no atomic grouping" }
|
||||
],
|
||||
multiSelect: false
|
||||
}]
|
||||
});
|
||||
}
|
||||
```
|
||||
|
||||
### Step 2.4: Select Execution Mode
|
||||
|
||||
```javascript
|
||||
async function selectExecutionMode() {
|
||||
return await AskUserQuestion({
|
||||
questions: [{
|
||||
question: "Execution mode for this step?",
|
||||
header: "Mode",
|
||||
options: [
|
||||
{ label: "mainprocess", description: "Run in main process (blocking, synchronous)" },
|
||||
{ label: "async", description: "Run asynchronously (background, hook callbacks)" }
|
||||
],
|
||||
multiSelect: false
|
||||
}]
|
||||
});
|
||||
}
|
||||
```
|
||||
|
||||
### Complete Step Definition Flow
|
||||
|
||||
```javascript
|
||||
async function defineSteps(templateDesign) {
|
||||
// Suggest steps based on purpose
|
||||
const suggestedSteps = getSuggestedSteps(templateDesign.purpose);
|
||||
|
||||
const customize = await AskUserQuestion({
|
||||
questions: [{
|
||||
question: "Use suggested steps or customize?",
|
||||
header: "Steps",
|
||||
options: [
|
||||
{ label: "Use Suggested", description: `Suggested: ${suggestedSteps.map(s => s.cmd).join(' → ')}` },
|
||||
{ label: "Customize", description: "Modify or add custom steps" },
|
||||
{ label: "Start Empty", description: "Define all steps from scratch" }
|
||||
],
|
||||
multiSelect: false
|
||||
}]
|
||||
});
|
||||
|
||||
if (customize.Steps === "Use Suggested") {
|
||||
return suggestedSteps;
|
||||
}
|
||||
|
||||
// Interactive step definition
|
||||
const steps = [];
|
||||
let addMore = true;
|
||||
while (addMore) {
|
||||
const category = await selectCommandCategory();
|
||||
const command = await selectCommand(category.Category);
|
||||
const unit = await selectExecutionUnit();
|
||||
const execMode = await selectExecutionMode();
|
||||
const contextHint = await askContextHint(command.Command);
|
||||
|
||||
steps.push({
|
||||
cmd: command.Command,
|
||||
args: command.Command.includes('plan') || command.Command.includes('fix') ? '"{{goal}}"' : undefined,
|
||||
unit: unit.Unit,
|
||||
execution: {
|
||||
type: "slash-command",
|
||||
mode: execMode.Mode
|
||||
},
|
||||
contextHint: contextHint
|
||||
});
|
||||
|
||||
const continueAdding = await AskUserQuestion({
|
||||
questions: [{
|
||||
question: `Added step ${steps.length}: ${command.Command}. Add another?`,
|
||||
header: "Continue",
|
||||
options: [
|
||||
{ label: "Add More", description: "Define another step" },
|
||||
{ label: "Done", description: "Finish step definition" }
|
||||
],
|
||||
multiSelect: false
|
||||
}]
|
||||
});
|
||||
addMore = continueAdding.Continue === "Add More";
|
||||
}
|
||||
|
||||
return steps;
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Suggested Step Templates
|
||||
|
||||
### Feature Development (Level 2 - Rapid)
|
||||
```json
|
||||
{
|
||||
"name": "rapid",
|
||||
"description": "Quick implementation with testing",
|
||||
"level": 2,
|
||||
"steps": [
|
||||
{ "cmd": "/workflow:lite-plan", "args": "\"{{goal}}\"", "unit": "quick-implementation", "execution": { "type": "slash-command", "mode": "mainprocess" }, "contextHint": "Create lightweight implementation plan" },
|
||||
{ "cmd": "/workflow:lite-execute", "args": "--in-memory", "unit": "quick-implementation", "execution": { "type": "slash-command", "mode": "mainprocess" }, "contextHint": "Execute implementation based on plan" },
|
||||
{ "cmd": "/workflow:test-fix-gen", "unit": "test-validation", "execution": { "type": "slash-command", "mode": "mainprocess" }, "contextHint": "Generate test tasks" },
|
||||
{ "cmd": "/workflow:test-cycle-execute", "unit": "test-validation", "execution": { "type": "slash-command", "mode": "async" }, "contextHint": "Execute test-fix cycle until pass rate >= 95%" }
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
### Feature Development (Level 3 - Coupled)
|
||||
```json
|
||||
{
|
||||
"name": "coupled",
|
||||
"description": "Full workflow with verification, review, and testing",
|
||||
"level": 3,
|
||||
"steps": [
|
||||
{ "cmd": "/workflow:plan", "args": "\"{{goal}}\"", "unit": "verified-planning-execution", "execution": { "type": "slash-command", "mode": "mainprocess" }, "contextHint": "Create detailed implementation plan" },
|
||||
{ "cmd": "/workflow:plan-verify", "unit": "verified-planning-execution", "execution": { "type": "slash-command", "mode": "mainprocess" }, "contextHint": "Verify plan against requirements" },
|
||||
{ "cmd": "/workflow:execute", "unit": "verified-planning-execution", "execution": { "type": "slash-command", "mode": "async" }, "contextHint": "Execute implementation" },
|
||||
{ "cmd": "/workflow:review-session-cycle", "unit": "code-review", "execution": { "type": "slash-command", "mode": "mainprocess" }, "contextHint": "Multi-dimensional code review" },
|
||||
{ "cmd": "/workflow:review-cycle-fix", "unit": "code-review", "execution": { "type": "slash-command", "mode": "mainprocess" }, "contextHint": "Fix review findings" },
|
||||
{ "cmd": "/workflow:test-fix-gen", "unit": "test-validation", "execution": { "type": "slash-command", "mode": "mainprocess" }, "contextHint": "Generate test tasks" },
|
||||
{ "cmd": "/workflow:test-cycle-execute", "unit": "test-validation", "execution": { "type": "slash-command", "mode": "async" }, "contextHint": "Execute test-fix cycle" }
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
### Bug Fix (Level 2)
|
||||
```json
|
||||
{
|
||||
"name": "bugfix",
|
||||
"description": "Bug diagnosis and fix with testing",
|
||||
"level": 2,
|
||||
"steps": [
|
||||
{ "cmd": "/workflow:lite-fix", "args": "\"{{goal}}\"", "unit": "bug-fix", "execution": { "type": "slash-command", "mode": "mainprocess" }, "contextHint": "Diagnose and plan bug fix" },
|
||||
{ "cmd": "/workflow:lite-execute", "args": "--in-memory", "unit": "bug-fix", "execution": { "type": "slash-command", "mode": "mainprocess" }, "contextHint": "Execute bug fix" },
|
||||
{ "cmd": "/workflow:test-fix-gen", "unit": "test-validation", "execution": { "type": "slash-command", "mode": "mainprocess" }, "contextHint": "Generate regression tests" },
|
||||
{ "cmd": "/workflow:test-cycle-execute", "unit": "test-validation", "execution": { "type": "slash-command", "mode": "async" }, "contextHint": "Verify fix with tests" }
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
### Bug Fix Hotfix (Level 2)
|
||||
```json
|
||||
{
|
||||
"name": "bugfix-hotfix",
|
||||
"description": "Urgent production bug fix (no tests)",
|
||||
"level": 2,
|
||||
"steps": [
|
||||
{ "cmd": "/workflow:lite-fix", "args": "--hotfix \"{{goal}}\"", "unit": "standalone", "execution": { "type": "slash-command", "mode": "mainprocess" }, "contextHint": "Emergency hotfix mode" }
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
### TDD Development (Level 3)
|
||||
```json
|
||||
{
|
||||
"name": "tdd",
|
||||
"description": "Test-driven development with Red-Green-Refactor",
|
||||
"level": 3,
|
||||
"steps": [
|
||||
{ "cmd": "/workflow:tdd-plan", "args": "\"{{goal}}\"", "unit": "tdd-planning-execution", "execution": { "type": "slash-command", "mode": "mainprocess" }, "contextHint": "Create TDD task chain" },
|
||||
{ "cmd": "/workflow:execute", "unit": "tdd-planning-execution", "execution": { "type": "slash-command", "mode": "async" }, "contextHint": "Execute TDD cycle" },
|
||||
{ "cmd": "/workflow:tdd-verify", "unit": "standalone", "execution": { "type": "slash-command", "mode": "mainprocess" }, "contextHint": "Verify TDD compliance" }
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
### Code Review (Level 3)
|
||||
```json
|
||||
{
|
||||
"name": "review",
|
||||
"description": "Code review cycle with fixes and testing",
|
||||
"level": 3,
|
||||
"steps": [
|
||||
{ "cmd": "/workflow:review-session-cycle", "unit": "code-review", "execution": { "type": "slash-command", "mode": "mainprocess" }, "contextHint": "Multi-dimensional code review" },
|
||||
{ "cmd": "/workflow:review-cycle-fix", "unit": "code-review", "execution": { "type": "slash-command", "mode": "mainprocess" }, "contextHint": "Fix review findings" },
|
||||
{ "cmd": "/workflow:test-fix-gen", "unit": "test-validation", "execution": { "type": "slash-command", "mode": "mainprocess" }, "contextHint": "Generate tests for fixes" },
|
||||
{ "cmd": "/workflow:test-cycle-execute", "unit": "test-validation", "execution": { "type": "slash-command", "mode": "async" }, "contextHint": "Verify fixes pass tests" }
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
### Test Fix (Level 3)
|
||||
```json
|
||||
{
|
||||
"name": "test-fix",
|
||||
"description": "Fix failing tests",
|
||||
"level": 3,
|
||||
"steps": [
|
||||
{ "cmd": "/workflow:test-fix-gen", "args": "\"{{goal}}\"", "unit": "test-validation", "execution": { "type": "slash-command", "mode": "mainprocess" }, "contextHint": "Generate test fix tasks" },
|
||||
{ "cmd": "/workflow:test-cycle-execute", "unit": "test-validation", "execution": { "type": "slash-command", "mode": "async" }, "contextHint": "Execute test-fix cycle" }
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
### Issue Workflow (Level Issue)
|
||||
```json
|
||||
{
|
||||
"name": "issue",
|
||||
"description": "Complete issue lifecycle",
|
||||
"level": "Issue",
|
||||
"steps": [
|
||||
{ "cmd": "/issue:discover", "unit": "issue-workflow", "execution": { "type": "slash-command", "mode": "mainprocess" }, "contextHint": "Discover issues from codebase" },
|
||||
{ "cmd": "/issue:plan", "args": "--all-pending", "unit": "issue-workflow", "execution": { "type": "slash-command", "mode": "mainprocess" }, "contextHint": "Plan issue solutions" },
|
||||
{ "cmd": "/issue:queue", "unit": "issue-workflow", "execution": { "type": "slash-command", "mode": "mainprocess" }, "contextHint": "Form execution queue" },
|
||||
{ "cmd": "/issue:execute", "unit": "issue-workflow", "execution": { "type": "slash-command", "mode": "async" }, "contextHint": "Execute issue queue" }
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
### Rapid to Issue (Level 2.5)
|
||||
```json
|
||||
{
|
||||
"name": "rapid-to-issue",
|
||||
"description": "Bridge lightweight planning to issue workflow",
|
||||
"level": 2,
|
||||
"steps": [
|
||||
{ "cmd": "/workflow:lite-plan", "args": "\"{{goal}}\"", "unit": "rapid-to-issue", "execution": { "type": "slash-command", "mode": "mainprocess" }, "contextHint": "Create lightweight plan" },
|
||||
{ "cmd": "/issue:convert-to-plan", "args": "--latest-lite-plan -y", "unit": "rapid-to-issue", "execution": { "type": "slash-command", "mode": "mainprocess" }, "contextHint": "Convert to issue plan" },
|
||||
{ "cmd": "/issue:queue", "unit": "rapid-to-issue", "execution": { "type": "slash-command", "mode": "mainprocess" }, "contextHint": "Form execution queue" },
|
||||
{ "cmd": "/issue:execute", "args": "--queue auto", "unit": "rapid-to-issue", "execution": { "type": "slash-command", "mode": "async" }, "contextHint": "Execute issue queue" }
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
### Brainstorm to Issue (Level 4)
|
||||
```json
|
||||
{
|
||||
"name": "brainstorm-to-issue",
|
||||
"description": "Bridge brainstorm session to issue workflow",
|
||||
"level": 4,
|
||||
"steps": [
|
||||
{ "cmd": "/issue:from-brainstorm", "args": "SESSION=\"{{session}}\" --auto", "unit": "brainstorm-to-issue", "execution": { "type": "slash-command", "mode": "mainprocess" }, "contextHint": "Convert brainstorm to issue" },
|
||||
{ "cmd": "/issue:queue", "unit": "brainstorm-to-issue", "execution": { "type": "slash-command", "mode": "mainprocess" }, "contextHint": "Form execution queue" },
|
||||
{ "cmd": "/issue:execute", "args": "--queue auto", "unit": "brainstorm-to-issue", "execution": { "type": "slash-command", "mode": "async" }, "contextHint": "Execute issue queue" }
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
### With-File: Brainstorm (Level 4)
|
||||
```json
|
||||
{
|
||||
"name": "brainstorm",
|
||||
"description": "Multi-perspective ideation with documentation",
|
||||
"level": 4,
|
||||
"steps": [
|
||||
{ "cmd": "/workflow:brainstorm-with-file", "args": "\"{{goal}}\"", "unit": "brainstorm-with-file", "execution": { "type": "slash-command", "mode": "mainprocess" }, "contextHint": "Multi-CLI brainstorming with documented diverge-converge cycles" }
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
### With-File: Debug (Level 3)
|
||||
```json
|
||||
{
|
||||
"name": "debug",
|
||||
"description": "Hypothesis-driven debugging with documentation",
|
||||
"level": 3,
|
||||
"steps": [
|
||||
{ "cmd": "/workflow:debug-with-file", "args": "\"{{goal}}\"", "unit": "debug-with-file", "execution": { "type": "slash-command", "mode": "mainprocess" }, "contextHint": "Hypothesis-driven debugging with Gemini validation" }
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
### With-File: Analyze (Level 3)
|
||||
```json
|
||||
{
|
||||
"name": "analyze",
|
||||
"description": "Collaborative analysis with documentation",
|
||||
"level": 3,
|
||||
"steps": [
|
||||
{ "cmd": "/workflow:analyze-with-file", "args": "\"{{goal}}\"", "unit": "analyze-with-file", "execution": { "type": "slash-command", "mode": "mainprocess" }, "contextHint": "Multi-round collaborative analysis with CLI exploration" }
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
### Full Workflow (Level 4)
|
||||
```json
|
||||
{
|
||||
"name": "full",
|
||||
"description": "Complete workflow: brainstorm → plan → execute → test",
|
||||
"level": 4,
|
||||
"steps": [
|
||||
{ "cmd": "/workflow:brainstorm:auto-parallel", "args": "\"{{goal}}\"", "unit": "standalone", "execution": { "type": "slash-command", "mode": "mainprocess" }, "contextHint": "Parallel multi-perspective brainstorming" },
|
||||
{ "cmd": "/workflow:plan", "unit": "verified-planning-execution", "execution": { "type": "slash-command", "mode": "mainprocess" }, "contextHint": "Create detailed plan from brainstorm" },
|
||||
{ "cmd": "/workflow:plan-verify", "unit": "verified-planning-execution", "execution": { "type": "slash-command", "mode": "mainprocess" }, "contextHint": "Verify plan quality" },
|
||||
{ "cmd": "/workflow:execute", "unit": "verified-planning-execution", "execution": { "type": "slash-command", "mode": "async" }, "contextHint": "Execute implementation" },
|
||||
{ "cmd": "/workflow:test-fix-gen", "unit": "test-validation", "execution": { "type": "slash-command", "mode": "mainprocess" }, "contextHint": "Generate comprehensive tests" },
|
||||
{ "cmd": "/workflow:test-cycle-execute", "unit": "test-validation", "execution": { "type": "slash-command", "mode": "async" }, "contextHint": "Execute test cycle" }
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
### Multi-CLI Planning (Level 3)
|
||||
```json
|
||||
{
|
||||
"name": "multi-cli-plan",
|
||||
"description": "Multi-CLI collaborative planning with cross-verification",
|
||||
"level": 3,
|
||||
"steps": [
|
||||
{ "cmd": "/workflow:multi-cli-plan", "args": "\"{{goal}}\"", "unit": "multi-cli-planning", "execution": { "type": "slash-command", "mode": "mainprocess" }, "contextHint": "Gemini+Codex+Claude collaborative planning" },
|
||||
{ "cmd": "/workflow:lite-execute", "args": "--in-memory", "unit": "multi-cli-planning", "execution": { "type": "slash-command", "mode": "mainprocess" }, "contextHint": "Execute converged plan" },
|
||||
{ "cmd": "/workflow:test-fix-gen", "unit": "test-validation", "execution": { "type": "slash-command", "mode": "mainprocess" }, "contextHint": "Generate tests" },
|
||||
{ "cmd": "/workflow:test-cycle-execute", "unit": "test-validation", "execution": { "type": "slash-command", "mode": "async" }, "contextHint": "Execute test cycle" }
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
### Ultra-Lightweight (Level 1)
|
||||
```json
|
||||
{
|
||||
"name": "lite-lite-lite",
|
||||
"description": "Ultra-lightweight multi-tool execution",
|
||||
"level": 1,
|
||||
"steps": [
|
||||
{ "cmd": "/workflow:lite-lite-lite", "args": "\"{{goal}}\"", "unit": "standalone", "execution": { "type": "slash-command", "mode": "mainprocess" }, "contextHint": "Direct execution with minimal overhead" }
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Command Port Reference
|
||||
|
||||
Each command has input/output ports for pipeline composition:
|
||||
|
||||
| Command | Input Port | Output Port | Atomic Unit |
|
||||
|---------|------------|-------------|-------------|
|
||||
| **Planning** |
|
||||
| lite-plan | requirement | plan | quick-implementation |
|
||||
| plan | requirement | detailed-plan | full-planning-execution |
|
||||
| plan-verify | detailed-plan | verified-plan | verified-planning-execution |
|
||||
| multi-cli-plan | requirement | multi-cli-plan | multi-cli-planning |
|
||||
| tdd-plan | requirement | tdd-tasks | tdd-planning-execution |
|
||||
| replan | session, feedback | replan | replanning-execution |
|
||||
| **Execution** |
|
||||
| lite-execute | plan, multi-cli-plan, lite-fix | code | (multiple) |
|
||||
| execute | detailed-plan, verified-plan, replan, tdd-tasks | code | (multiple) |
|
||||
| **Testing** |
|
||||
| test-fix-gen | failing-tests, session | test-tasks | test-validation |
|
||||
| test-cycle-execute | test-tasks | test-passed | test-validation |
|
||||
| test-gen | code, session | test-tasks | test-generation-execution |
|
||||
| tdd-verify | code | tdd-verified | standalone |
|
||||
| **Review** |
|
||||
| review-session-cycle | code, session | review-verified | code-review |
|
||||
| review-module-cycle | module-pattern | review-verified | code-review |
|
||||
| review-cycle-fix | review-findings | fixed-code | code-review |
|
||||
| **Bug Fix** |
|
||||
| lite-fix | bug-report | lite-fix | bug-fix |
|
||||
| debug-with-file | bug-report | understanding-document | debug-with-file |
|
||||
| **With-File** |
|
||||
| brainstorm-with-file | exploration-topic | brainstorm-document | brainstorm-with-file |
|
||||
| analyze-with-file | analysis-topic | discussion-document | analyze-with-file |
|
||||
| **Issue** |
|
||||
| issue:discover | codebase | pending-issues | issue-workflow |
|
||||
| issue:plan | pending-issues | issue-plans | issue-workflow |
|
||||
| issue:queue | issue-plans, converted-plan | execution-queue | issue-workflow |
|
||||
| issue:execute | execution-queue | completed-issues | issue-workflow |
|
||||
| issue:convert-to-plan | plan | converted-plan | rapid-to-issue |
|
||||
| issue:from-brainstorm | brainstorm-document | converted-plan | brainstorm-to-issue |
|
||||
|
||||
---
|
||||
|
||||
## Minimum Execution Units (最小执行单元)
|
||||
|
||||
**Definition**: Commands that must execute together as an atomic group.
|
||||
|
||||
| Unit Name | Commands | Purpose |
|
||||
|-----------|----------|---------|
|
||||
| **quick-implementation** | lite-plan → lite-execute | Lightweight plan and execution |
|
||||
| **multi-cli-planning** | multi-cli-plan → lite-execute | Multi-perspective planning and execution |
|
||||
| **bug-fix** | lite-fix → lite-execute | Bug diagnosis and fix |
|
||||
| **full-planning-execution** | plan → execute | Detailed planning and execution |
|
||||
| **verified-planning-execution** | plan → plan-verify → execute | Planning with verification |
|
||||
| **replanning-execution** | replan → execute | Update plan and execute |
|
||||
| **tdd-planning-execution** | tdd-plan → execute | TDD planning and execution |
|
||||
| **test-validation** | test-fix-gen → test-cycle-execute | Test generation and fix cycle |
|
||||
| **test-generation-execution** | test-gen → execute | Generate and execute tests |
|
||||
| **code-review** | review-*-cycle → review-cycle-fix | Review and fix findings |
|
||||
| **issue-workflow** | discover → plan → queue → execute | Complete issue lifecycle |
|
||||
| **rapid-to-issue** | lite-plan → convert-to-plan → queue → execute | Bridge to issue workflow |
|
||||
| **brainstorm-to-issue** | from-brainstorm → queue → execute | Brainstorm to issue bridge |
|
||||
| **brainstorm-with-file** | (self-contained) | Multi-perspective ideation |
|
||||
| **debug-with-file** | (self-contained) | Hypothesis-driven debugging |
|
||||
| **analyze-with-file** | (self-contained) | Collaborative analysis |
|
||||
|
||||
---
|
||||
|
||||
## Phase 3: Generate JSON
|
||||
|
||||
```javascript
|
||||
async function generateTemplate(design, steps, outputPath) {
|
||||
const template = {
|
||||
name: design.name,
|
||||
description: design.description,
|
||||
level: design.level,
|
||||
steps: steps
|
||||
};
|
||||
|
||||
const finalPath = outputPath || `~/.claude/skills/flow-coordinator/templates/${design.name}.json`;
|
||||
|
||||
// Write template
|
||||
Write(finalPath, JSON.stringify(template, null, 2));
|
||||
|
||||
// Validate
|
||||
const validation = validateTemplate(template);
|
||||
|
||||
console.log(`✅ Template created: ${finalPath}`);
|
||||
console.log(` Steps: ${template.steps.length}`);
|
||||
console.log(` Level: ${template.level}`);
|
||||
console.log(` Units: ${[...new Set(template.steps.map(s => s.unit))].join(', ')}`);
|
||||
|
||||
return { path: finalPath, template, validation };
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Output Format
|
||||
|
||||
```json
|
||||
{
|
||||
"name": "template-name",
|
||||
"description": "Template description",
|
||||
"level": 2,
|
||||
"steps": [
|
||||
{
|
||||
"cmd": "/workflow:command",
|
||||
"args": "\"{{goal}}\"",
|
||||
"unit": "unit-name",
|
||||
"execution": {
|
||||
"type": "slash-command",
|
||||
"mode": "mainprocess"
|
||||
},
|
||||
"contextHint": "Description of what this step does"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Examples
|
||||
|
||||
**Create a quick bugfix template**:
|
||||
```
|
||||
/meta-skill:flow-create hotfix-simple
|
||||
|
||||
→ Purpose: Bug Fix
|
||||
→ Level: 2 (Lightweight)
|
||||
→ Steps: Use Suggested
|
||||
→ Output: ~/.claude/skills/flow-coordinator/templates/hotfix-simple.json
|
||||
```
|
||||
|
||||
**Create a custom multi-stage workflow**:
|
||||
```
|
||||
/meta-skill:flow-create complex-feature --output ~/.claude/skills/my-project/templates/
|
||||
|
||||
→ Purpose: Feature Development
|
||||
→ Level: 3 (Standard)
|
||||
→ Steps: Customize
|
||||
→ Step 1: /workflow:brainstorm:auto-parallel (standalone, mainprocess)
|
||||
→ Step 2: /workflow:plan (verified-planning-execution, mainprocess)
|
||||
→ Step 3: /workflow:plan-verify (verified-planning-execution, mainprocess)
|
||||
→ Step 4: /workflow:execute (verified-planning-execution, async)
|
||||
→ Step 5: /workflow:review-session-cycle (code-review, mainprocess)
|
||||
→ Step 6: /workflow:review-cycle-fix (code-review, mainprocess)
|
||||
→ Done
|
||||
→ Output: ~/.claude/skills/my-project/templates/complex-feature.json
|
||||
```
|
||||
718
.claude/commands/issue/convert-to-plan.md
Normal file
718
.claude/commands/issue/convert-to-plan.md
Normal file
@@ -0,0 +1,718 @@
|
||||
---
|
||||
name: convert-to-plan
|
||||
description: Convert planning artifacts (lite-plan, workflow session, markdown) to issue solutions
|
||||
argument-hint: "[-y|--yes] [--issue <id>] [--supplement] <SOURCE>"
|
||||
allowed-tools: TodoWrite(*), Bash(*), Read(*), Write(*), Glob(*), AskUserQuestion(*)
|
||||
---
|
||||
|
||||
## Auto Mode
|
||||
|
||||
When `--yes` or `-y`: Skip confirmation, auto-create issue and bind solution.
|
||||
|
||||
# Issue Convert-to-Plan Command (/issue:convert-to-plan)
|
||||
|
||||
## Overview
|
||||
|
||||
Converts various planning artifact formats into issue workflow solutions with intelligent detection and automatic binding.
|
||||
|
||||
**Supported Sources** (auto-detected):
|
||||
- **lite-plan**: `.workflow/.lite-plan/{slug}/plan.json`
|
||||
- **workflow-session**: `WFS-xxx` ID or `.workflow/active/{session}/` folder
|
||||
- **markdown**: Any `.md` file with implementation/task content
|
||||
- **json**: Direct JSON files matching plan-json-schema
|
||||
|
||||
## Quick Reference
|
||||
|
||||
```bash
|
||||
# Convert lite-plan to new issue (auto-creates issue)
|
||||
/issue:convert-to-plan ".workflow/.lite-plan/implement-auth-2026-01-25"
|
||||
|
||||
# Convert workflow session to existing issue
|
||||
/issue:convert-to-plan WFS-auth-impl --issue GH-123
|
||||
|
||||
# Supplement existing solution with additional tasks
|
||||
/issue:convert-to-plan "./docs/additional-tasks.md" --issue ISS-001 --supplement
|
||||
|
||||
# Auto mode - skip confirmations
|
||||
/issue:convert-to-plan ".workflow/.lite-plan/my-plan" -y
|
||||
```
|
||||
|
||||
## Command Options
|
||||
|
||||
| Option | Description | Default |
|
||||
|--------|-------------|---------|
|
||||
| `<SOURCE>` | Planning artifact path or WFS-xxx ID | Required |
|
||||
| `--issue <id>` | Bind to existing issue instead of creating new | Auto-create |
|
||||
| `--supplement` | Add tasks to existing solution (requires --issue) | false |
|
||||
| `-y, --yes` | Skip all confirmations | false |
|
||||
|
||||
## Core Data Access Principle
|
||||
|
||||
**⚠️ Important**: Use CLI commands for all issue/solution operations.
|
||||
|
||||
| Operation | Correct | Incorrect |
|
||||
|-----------|---------|-----------|
|
||||
| Get issue | `ccw issue status <id> --json` | Read issues.jsonl directly |
|
||||
| Create issue | `ccw issue init <id> --title "..."` | Write to issues.jsonl |
|
||||
| Bind solution | `ccw issue bind <id> <sol-id>` | Edit issues.jsonl |
|
||||
| List solutions | `ccw issue solutions --issue <id> --brief` | Read solutions/*.jsonl |
|
||||
|
||||
## Solution Schema Reference
|
||||
|
||||
Target format for all extracted data (from solution-schema.json):
|
||||
|
||||
```typescript
|
||||
interface Solution {
|
||||
id: string; // SOL-{issue-id}-{4-char-uid}
|
||||
description?: string; // High-level summary
|
||||
approach?: string; // Technical strategy
|
||||
tasks: Task[]; // Required: at least 1 task
|
||||
exploration_context?: object; // Optional: source context
|
||||
analysis?: { risk, impact, complexity };
|
||||
score?: number; // 0.0-1.0
|
||||
is_bound: boolean;
|
||||
created_at: string;
|
||||
bound_at?: string;
|
||||
}
|
||||
|
||||
interface Task {
|
||||
id: string; // T1, T2, T3... (pattern: ^T[0-9]+$)
|
||||
title: string; // Required: action verb + target
|
||||
scope: string; // Required: module path or feature area
|
||||
action: Action; // Required: Create|Update|Implement|...
|
||||
description?: string;
|
||||
modification_points?: Array<{file, target, change}>;
|
||||
implementation: string[]; // Required: step-by-step guide
|
||||
test?: { unit?, integration?, commands?, coverage_target? };
|
||||
acceptance: { criteria: string[], verification: string[] }; // Required
|
||||
commit?: { type, scope, message_template, breaking? };
|
||||
depends_on?: string[];
|
||||
priority?: number; // 1-5 (default: 3)
|
||||
}
|
||||
|
||||
type Action = 'Create' | 'Update' | 'Implement' | 'Refactor' | 'Add' | 'Delete' | 'Configure' | 'Test' | 'Fix';
|
||||
```
|
||||
|
||||
## Implementation
|
||||
|
||||
### Phase 1: Parse Arguments & Detect Source Type
|
||||
|
||||
```javascript
|
||||
const input = userInput.trim();
|
||||
const flags = parseFlags(userInput); // --issue, --supplement, -y/--yes
|
||||
|
||||
// Extract source path (first non-flag argument)
|
||||
const source = extractSourceArg(input);
|
||||
|
||||
// Detect source type
|
||||
function detectSourceType(source) {
|
||||
// Check for WFS-xxx pattern (workflow session ID)
|
||||
if (source.match(/^WFS-[\w-]+$/)) {
|
||||
return { type: 'workflow-session-id', path: `.workflow/active/${source}` };
|
||||
}
|
||||
|
||||
// Check if directory
|
||||
const isDir = Bash(`test -d "${source}" && echo "dir" || echo "file"`).trim() === 'dir';
|
||||
|
||||
if (isDir) {
|
||||
// Check for lite-plan indicator
|
||||
const hasPlanJson = Bash(`test -f "${source}/plan.json" && echo "yes" || echo "no"`).trim() === 'yes';
|
||||
if (hasPlanJson) {
|
||||
return { type: 'lite-plan', path: source };
|
||||
}
|
||||
|
||||
// Check for workflow session indicator
|
||||
const hasSession = Bash(`test -f "${source}/workflow-session.json" && echo "yes" || echo "no"`).trim() === 'yes';
|
||||
if (hasSession) {
|
||||
return { type: 'workflow-session', path: source };
|
||||
}
|
||||
}
|
||||
|
||||
// Check file extensions
|
||||
if (source.endsWith('.json')) {
|
||||
return { type: 'json-file', path: source };
|
||||
}
|
||||
if (source.endsWith('.md')) {
|
||||
return { type: 'markdown-file', path: source };
|
||||
}
|
||||
|
||||
// Check if path exists at all
|
||||
const exists = Bash(`test -e "${source}" && echo "yes" || echo "no"`).trim() === 'yes';
|
||||
if (!exists) {
|
||||
throw new Error(`E001: Source not found: ${source}`);
|
||||
}
|
||||
|
||||
return { type: 'unknown', path: source };
|
||||
}
|
||||
|
||||
const sourceInfo = detectSourceType(source);
|
||||
if (sourceInfo.type === 'unknown') {
|
||||
throw new Error(`E002: Unable to detect source format for: ${source}`);
|
||||
}
|
||||
|
||||
console.log(`Detected source type: ${sourceInfo.type}`);
|
||||
```
|
||||
|
||||
### Phase 2: Extract Data Using Format-Specific Extractor
|
||||
|
||||
```javascript
|
||||
let extracted = { title: '', approach: '', tasks: [], metadata: {} };
|
||||
|
||||
switch (sourceInfo.type) {
|
||||
case 'lite-plan':
|
||||
extracted = extractFromLitePlan(sourceInfo.path);
|
||||
break;
|
||||
case 'workflow-session':
|
||||
case 'workflow-session-id':
|
||||
extracted = extractFromWorkflowSession(sourceInfo.path);
|
||||
break;
|
||||
case 'markdown-file':
|
||||
extracted = await extractFromMarkdownAI(sourceInfo.path);
|
||||
break;
|
||||
case 'json-file':
|
||||
extracted = extractFromJsonFile(sourceInfo.path);
|
||||
break;
|
||||
}
|
||||
|
||||
// Validate extraction
|
||||
if (!extracted.tasks || extracted.tasks.length === 0) {
|
||||
throw new Error('E006: No tasks extracted from source');
|
||||
}
|
||||
|
||||
// Ensure task IDs are normalized to T1, T2, T3...
|
||||
extracted.tasks = normalizeTaskIds(extracted.tasks);
|
||||
|
||||
console.log(`Extracted: ${extracted.tasks.length} tasks`);
|
||||
```
|
||||
|
||||
#### Extractor: Lite-Plan
|
||||
|
||||
```javascript
|
||||
function extractFromLitePlan(folderPath) {
|
||||
const planJson = Read(`${folderPath}/plan.json`);
|
||||
const plan = JSON.parse(planJson);
|
||||
|
||||
return {
|
||||
title: plan.summary?.split('.')[0]?.trim() || 'Untitled Plan',
|
||||
description: plan.summary,
|
||||
approach: plan.approach,
|
||||
tasks: plan.tasks.map(t => ({
|
||||
id: t.id,
|
||||
title: t.title,
|
||||
scope: t.scope || '',
|
||||
action: t.action || 'Implement',
|
||||
description: t.description || t.title,
|
||||
modification_points: t.modification_points || [],
|
||||
implementation: Array.isArray(t.implementation) ? t.implementation : [t.implementation || ''],
|
||||
test: t.verification ? {
|
||||
unit: t.verification.unit_tests,
|
||||
integration: t.verification.integration_tests,
|
||||
commands: t.verification.manual_checks
|
||||
} : {},
|
||||
acceptance: {
|
||||
criteria: Array.isArray(t.acceptance) ? t.acceptance : [t.acceptance || ''],
|
||||
verification: t.verification?.manual_checks || []
|
||||
},
|
||||
depends_on: t.depends_on || [],
|
||||
priority: 3
|
||||
})),
|
||||
metadata: {
|
||||
source_type: 'lite-plan',
|
||||
source_path: folderPath,
|
||||
complexity: plan.complexity,
|
||||
estimated_time: plan.estimated_time,
|
||||
exploration_angles: plan._metadata?.exploration_angles || [],
|
||||
original_timestamp: plan._metadata?.timestamp
|
||||
}
|
||||
};
|
||||
}
|
||||
```
|
||||
|
||||
#### Extractor: Workflow Session
|
||||
|
||||
```javascript
|
||||
function extractFromWorkflowSession(sessionPath) {
|
||||
// Load session metadata
|
||||
const sessionJson = Read(`${sessionPath}/workflow-session.json`);
|
||||
const session = JSON.parse(sessionJson);
|
||||
|
||||
// Load IMPL_PLAN.md for approach (if exists)
|
||||
let approach = '';
|
||||
const implPlanPath = `${sessionPath}/IMPL_PLAN.md`;
|
||||
const hasImplPlan = Bash(`test -f "${implPlanPath}" && echo "yes" || echo "no"`).trim() === 'yes';
|
||||
if (hasImplPlan) {
|
||||
const implPlan = Read(implPlanPath);
|
||||
// Extract overview/approach section
|
||||
const overviewMatch = implPlan.match(/##\s*(?:Overview|Approach|Strategy)\s*\n([\s\S]*?)(?=\n##|$)/i);
|
||||
approach = overviewMatch?.[1]?.trim() || implPlan.split('\n').slice(0, 10).join('\n');
|
||||
}
|
||||
|
||||
// Load all task JSONs from .task folder
|
||||
const taskFiles = Glob({ pattern: `${sessionPath}/.task/IMPL-*.json` });
|
||||
const tasks = taskFiles.map(f => {
|
||||
const taskJson = Read(f);
|
||||
const task = JSON.parse(taskJson);
|
||||
return {
|
||||
id: task.id?.replace(/^IMPL-0*/, 'T') || 'T1', // IMPL-001 → T1
|
||||
title: task.title,
|
||||
scope: task.scope || inferScopeFromTask(task),
|
||||
action: capitalizeAction(task.type) || 'Implement',
|
||||
description: task.description,
|
||||
modification_points: task.implementation?.modification_points || [],
|
||||
implementation: task.implementation?.steps || [],
|
||||
test: task.implementation?.test || {},
|
||||
acceptance: {
|
||||
criteria: task.acceptance_criteria || [],
|
||||
verification: task.verification_steps || []
|
||||
},
|
||||
commit: task.commit,
|
||||
depends_on: (task.depends_on || []).map(d => d.replace(/^IMPL-0*/, 'T')),
|
||||
priority: task.priority || 3
|
||||
};
|
||||
});
|
||||
|
||||
return {
|
||||
title: session.name || session.description?.split('.')[0] || 'Workflow Session',
|
||||
description: session.description || session.name,
|
||||
approach: approach || session.description,
|
||||
tasks: tasks,
|
||||
metadata: {
|
||||
source_type: 'workflow-session',
|
||||
source_path: sessionPath,
|
||||
session_id: session.id,
|
||||
created_at: session.created_at
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
function inferScopeFromTask(task) {
|
||||
if (task.implementation?.modification_points?.length) {
|
||||
const files = task.implementation.modification_points.map(m => m.file);
|
||||
// Find common directory prefix
|
||||
const dirs = files.map(f => f.split('/').slice(0, -1).join('/'));
|
||||
return [...new Set(dirs)][0] || '';
|
||||
}
|
||||
return '';
|
||||
}
|
||||
|
||||
function capitalizeAction(type) {
|
||||
if (!type) return 'Implement';
|
||||
const map = { feature: 'Implement', bugfix: 'Fix', refactor: 'Refactor', test: 'Test', docs: 'Update' };
|
||||
return map[type.toLowerCase()] || type.charAt(0).toUpperCase() + type.slice(1);
|
||||
}
|
||||
```
|
||||
|
||||
#### Extractor: Markdown (AI-Assisted via Gemini)
|
||||
|
||||
```javascript
|
||||
async function extractFromMarkdownAI(filePath) {
|
||||
const fileContent = Read(filePath);
|
||||
|
||||
// Use Gemini CLI for intelligent extraction
|
||||
const cliPrompt = `PURPOSE: Extract implementation plan from markdown document for issue solution conversion. Must output ONLY valid JSON.
|
||||
TASK: • Analyze document structure • Identify title/summary • Extract approach/strategy section • Parse tasks from any format (lists, tables, sections, code blocks) • Normalize each task to solution schema
|
||||
MODE: analysis
|
||||
CONTEXT: Document content provided below
|
||||
EXPECTED: Valid JSON object with format:
|
||||
{
|
||||
"title": "extracted title",
|
||||
"approach": "extracted approach/strategy",
|
||||
"tasks": [
|
||||
{
|
||||
"id": "T1",
|
||||
"title": "task title",
|
||||
"scope": "module or feature area",
|
||||
"action": "Implement|Update|Create|Fix|Refactor|Add|Delete|Configure|Test",
|
||||
"description": "what to do",
|
||||
"implementation": ["step 1", "step 2"],
|
||||
"acceptance": ["criteria 1", "criteria 2"]
|
||||
}
|
||||
]
|
||||
}
|
||||
CONSTRAINTS: Output ONLY valid JSON - no markdown, no explanation | Action must be one of: Create, Update, Implement, Refactor, Add, Delete, Configure, Test, Fix | Tasks must have id, title, scope, action, implementation (array), acceptance (array)
|
||||
|
||||
DOCUMENT CONTENT:
|
||||
${fileContent}`;
|
||||
|
||||
// Execute Gemini CLI
|
||||
const result = Bash(`ccw cli -p '${cliPrompt.replace(/'/g, "'\\''")}' --tool gemini --mode analysis`, { timeout: 120000 });
|
||||
|
||||
// Parse JSON from result (may be wrapped in markdown code block)
|
||||
let jsonText = result.trim();
|
||||
const jsonMatch = jsonText.match(/```(?:json)?\s*([\s\S]*?)```/);
|
||||
if (jsonMatch) {
|
||||
jsonText = jsonMatch[1].trim();
|
||||
}
|
||||
|
||||
try {
|
||||
const extracted = JSON.parse(jsonText);
|
||||
|
||||
// Normalize tasks
|
||||
const tasks = (extracted.tasks || []).map((t, i) => ({
|
||||
id: t.id || `T${i + 1}`,
|
||||
title: t.title || 'Untitled task',
|
||||
scope: t.scope || '',
|
||||
action: validateAction(t.action) || 'Implement',
|
||||
description: t.description || t.title,
|
||||
modification_points: t.modification_points || [],
|
||||
implementation: Array.isArray(t.implementation) ? t.implementation : [t.implementation || ''],
|
||||
test: t.test || {},
|
||||
acceptance: {
|
||||
criteria: Array.isArray(t.acceptance) ? t.acceptance : [t.acceptance || ''],
|
||||
verification: t.verification || []
|
||||
},
|
||||
depends_on: t.depends_on || [],
|
||||
priority: t.priority || 3
|
||||
}));
|
||||
|
||||
return {
|
||||
title: extracted.title || 'Extracted Plan',
|
||||
description: extracted.summary || extracted.title,
|
||||
approach: extracted.approach || '',
|
||||
tasks: tasks,
|
||||
metadata: {
|
||||
source_type: 'markdown',
|
||||
source_path: filePath,
|
||||
extraction_method: 'gemini-ai'
|
||||
}
|
||||
};
|
||||
} catch (e) {
|
||||
// Provide more context for debugging
|
||||
throw new Error(`E005: Failed to extract tasks from markdown. Gemini response was not valid JSON. Error: ${e.message}. Response preview: ${jsonText.substring(0, 200)}...`);
|
||||
}
|
||||
}
|
||||
|
||||
function validateAction(action) {
|
||||
const validActions = ['Create', 'Update', 'Implement', 'Refactor', 'Add', 'Delete', 'Configure', 'Test', 'Fix'];
|
||||
if (!action) return null;
|
||||
const normalized = action.charAt(0).toUpperCase() + action.slice(1).toLowerCase();
|
||||
return validActions.includes(normalized) ? normalized : null;
|
||||
}
|
||||
```
|
||||
|
||||
#### Extractor: JSON File
|
||||
|
||||
```javascript
|
||||
function extractFromJsonFile(filePath) {
|
||||
const content = Read(filePath);
|
||||
const plan = JSON.parse(content);
|
||||
|
||||
// Detect if it's already solution format or plan format
|
||||
if (plan.tasks && Array.isArray(plan.tasks)) {
|
||||
// Map tasks to normalized format
|
||||
const tasks = plan.tasks.map((t, i) => ({
|
||||
id: t.id || `T${i + 1}`,
|
||||
title: t.title,
|
||||
scope: t.scope || '',
|
||||
action: t.action || 'Implement',
|
||||
description: t.description || t.title,
|
||||
modification_points: t.modification_points || [],
|
||||
implementation: Array.isArray(t.implementation) ? t.implementation : [t.implementation || ''],
|
||||
test: t.test || t.verification || {},
|
||||
acceptance: normalizeAcceptance(t.acceptance),
|
||||
depends_on: t.depends_on || [],
|
||||
priority: t.priority || 3
|
||||
}));
|
||||
|
||||
return {
|
||||
title: plan.summary?.split('.')[0] || plan.title || 'JSON Plan',
|
||||
description: plan.summary || plan.description,
|
||||
approach: plan.approach,
|
||||
tasks: tasks,
|
||||
metadata: {
|
||||
source_type: 'json',
|
||||
source_path: filePath,
|
||||
complexity: plan.complexity,
|
||||
original_metadata: plan._metadata
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
throw new Error('E002: JSON file does not contain valid plan structure (missing tasks array)');
|
||||
}
|
||||
|
||||
function normalizeAcceptance(acceptance) {
|
||||
if (!acceptance) return { criteria: [], verification: [] };
|
||||
if (typeof acceptance === 'object' && acceptance.criteria) return acceptance;
|
||||
if (Array.isArray(acceptance)) return { criteria: acceptance, verification: [] };
|
||||
return { criteria: [String(acceptance)], verification: [] };
|
||||
}
|
||||
```
|
||||
|
||||
### Phase 3: Normalize Task IDs
|
||||
|
||||
```javascript
|
||||
function normalizeTaskIds(tasks) {
|
||||
return tasks.map((t, i) => ({
|
||||
...t,
|
||||
id: `T${i + 1}`,
|
||||
// Also normalize depends_on references
|
||||
depends_on: (t.depends_on || []).map(d => {
|
||||
// Handle various ID formats: IMPL-001, T1, 1, etc.
|
||||
const num = d.match(/\d+/)?.[0];
|
||||
return num ? `T${parseInt(num)}` : d;
|
||||
})
|
||||
}));
|
||||
}
|
||||
```
|
||||
|
||||
### Phase 4: Resolve Issue (Create or Find)
|
||||
|
||||
```javascript
|
||||
let issueId = flags.issue;
|
||||
let existingSolution = null;
|
||||
|
||||
if (issueId) {
|
||||
// Validate issue exists
|
||||
let issueCheck;
|
||||
try {
|
||||
issueCheck = Bash(`ccw issue status ${issueId} --json 2>/dev/null`).trim();
|
||||
if (!issueCheck || issueCheck === '') {
|
||||
throw new Error('empty response');
|
||||
}
|
||||
} catch (e) {
|
||||
throw new Error(`E003: Issue not found: ${issueId}`);
|
||||
}
|
||||
|
||||
const issue = JSON.parse(issueCheck);
|
||||
|
||||
// Check if issue already has bound solution
|
||||
if (issue.bound_solution_id && !flags.supplement) {
|
||||
throw new Error(`E004: Issue ${issueId} already has bound solution (${issue.bound_solution_id}). Use --supplement to add tasks.`);
|
||||
}
|
||||
|
||||
// Load existing solution for supplement mode
|
||||
if (flags.supplement && issue.bound_solution_id) {
|
||||
try {
|
||||
const solResult = Bash(`ccw issue solution ${issue.bound_solution_id} --json`).trim();
|
||||
existingSolution = JSON.parse(solResult);
|
||||
console.log(`Loaded existing solution with ${existingSolution.tasks.length} tasks`);
|
||||
} catch (e) {
|
||||
throw new Error(`Failed to load existing solution: ${e.message}`);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// Create new issue via ccw issue create (auto-generates correct ID)
|
||||
// Smart extraction: title from content, priority from complexity
|
||||
const title = extracted.title || 'Converted Plan';
|
||||
const context = extracted.description || extracted.approach || title;
|
||||
|
||||
// Auto-determine priority based on complexity
|
||||
const complexityMap = { high: 2, medium: 3, low: 4 };
|
||||
const priority = complexityMap[extracted.metadata.complexity?.toLowerCase()] || 3;
|
||||
|
||||
try {
|
||||
// Use heredoc to avoid shell escaping issues
|
||||
const createResult = Bash(`ccw issue create << 'EOF'
|
||||
{
|
||||
"title": ${JSON.stringify(title)},
|
||||
"context": ${JSON.stringify(context)},
|
||||
"priority": ${priority},
|
||||
"source": "converted"
|
||||
}
|
||||
EOF`).trim();
|
||||
|
||||
// Parse result to get created issue ID
|
||||
const created = JSON.parse(createResult);
|
||||
issueId = created.id;
|
||||
console.log(`Created issue: ${issueId} (priority: ${priority})`);
|
||||
} catch (e) {
|
||||
throw new Error(`Failed to create issue: ${e.message}`);
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### Phase 5: Generate Solution
|
||||
|
||||
```javascript
|
||||
// Generate solution ID
|
||||
function generateSolutionId(issueId) {
|
||||
const chars = 'abcdefghijklmnopqrstuvwxyz0123456789';
|
||||
let uid = '';
|
||||
for (let i = 0; i < 4; i++) {
|
||||
uid += chars[Math.floor(Math.random() * chars.length)];
|
||||
}
|
||||
return `SOL-${issueId}-${uid}`;
|
||||
}
|
||||
|
||||
let solution;
|
||||
const solutionId = generateSolutionId(issueId);
|
||||
|
||||
if (flags.supplement && existingSolution) {
|
||||
// Supplement mode: merge with existing solution
|
||||
const maxTaskId = Math.max(...existingSolution.tasks.map(t => parseInt(t.id.slice(1))));
|
||||
|
||||
const newTasks = extracted.tasks.map((t, i) => ({
|
||||
...t,
|
||||
id: `T${maxTaskId + i + 1}`
|
||||
}));
|
||||
|
||||
solution = {
|
||||
...existingSolution,
|
||||
tasks: [...existingSolution.tasks, ...newTasks],
|
||||
approach: existingSolution.approach + '\n\n[Supplementary] ' + (extracted.approach || ''),
|
||||
updated_at: new Date().toISOString()
|
||||
};
|
||||
|
||||
console.log(`Supplementing: ${existingSolution.tasks.length} existing + ${newTasks.length} new = ${solution.tasks.length} total tasks`);
|
||||
} else {
|
||||
// New solution
|
||||
solution = {
|
||||
id: solutionId,
|
||||
description: extracted.description || extracted.title,
|
||||
approach: extracted.approach,
|
||||
tasks: extracted.tasks,
|
||||
exploration_context: extracted.metadata.exploration_angles ? {
|
||||
exploration_angles: extracted.metadata.exploration_angles
|
||||
} : undefined,
|
||||
analysis: {
|
||||
risk: 'medium',
|
||||
impact: 'medium',
|
||||
complexity: extracted.metadata.complexity?.toLowerCase() || 'medium'
|
||||
},
|
||||
is_bound: false,
|
||||
created_at: new Date().toISOString(),
|
||||
_conversion_metadata: {
|
||||
source_type: extracted.metadata.source_type,
|
||||
source_path: extracted.metadata.source_path,
|
||||
converted_at: new Date().toISOString()
|
||||
}
|
||||
};
|
||||
}
|
||||
```
|
||||
|
||||
### Phase 6: Confirm & Persist
|
||||
|
||||
```javascript
|
||||
// Display preview
|
||||
console.log(`
|
||||
## Conversion Summary
|
||||
|
||||
**Issue**: ${issueId}
|
||||
**Solution**: ${flags.supplement ? existingSolution.id : solutionId}
|
||||
**Tasks**: ${solution.tasks.length}
|
||||
**Mode**: ${flags.supplement ? 'Supplement' : 'New'}
|
||||
|
||||
### Tasks:
|
||||
${solution.tasks.map(t => `- ${t.id}: ${t.title} [${t.action}]`).join('\n')}
|
||||
`);
|
||||
|
||||
// Confirm if not auto mode
|
||||
if (!flags.yes && !flags.y) {
|
||||
const confirm = AskUserQuestion({
|
||||
questions: [{
|
||||
question: `Create solution for issue ${issueId} with ${solution.tasks.length} tasks?`,
|
||||
header: 'Confirm',
|
||||
multiSelect: false,
|
||||
options: [
|
||||
{ label: 'Yes, create solution', description: 'Create and bind solution' },
|
||||
{ label: 'Cancel', description: 'Abort without changes' }
|
||||
]
|
||||
}]
|
||||
});
|
||||
|
||||
if (!confirm.answers?.['Confirm']?.includes('Yes')) {
|
||||
console.log('Cancelled.');
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// Persist solution (following issue-plan-agent pattern)
|
||||
Bash(`mkdir -p .workflow/issues/solutions`);
|
||||
|
||||
const solutionFile = `.workflow/issues/solutions/${issueId}.jsonl`;
|
||||
|
||||
if (flags.supplement) {
|
||||
// Supplement mode: update existing solution line atomically
|
||||
try {
|
||||
const existingContent = Read(solutionFile);
|
||||
const lines = existingContent.trim().split('\n').filter(l => l);
|
||||
const updatedLines = lines.map(line => {
|
||||
const sol = JSON.parse(line);
|
||||
if (sol.id === existingSolution.id) {
|
||||
return JSON.stringify(solution);
|
||||
}
|
||||
return line;
|
||||
});
|
||||
// Atomic write: write entire content at once
|
||||
Write({ file_path: solutionFile, content: updatedLines.join('\n') + '\n' });
|
||||
console.log(`✓ Updated solution: ${existingSolution.id}`);
|
||||
} catch (e) {
|
||||
throw new Error(`Failed to update solution: ${e.message}`);
|
||||
}
|
||||
|
||||
// Note: No need to rebind - solution is already bound to issue
|
||||
} else {
|
||||
// New solution: append to JSONL file (following issue-plan-agent pattern)
|
||||
try {
|
||||
const solutionLine = JSON.stringify(solution);
|
||||
|
||||
// Read existing content, append new line, write atomically
|
||||
const existing = Bash(`test -f "${solutionFile}" && cat "${solutionFile}" || echo ""`).trim();
|
||||
const newContent = existing ? existing + '\n' + solutionLine + '\n' : solutionLine + '\n';
|
||||
Write({ file_path: solutionFile, content: newContent });
|
||||
|
||||
console.log(`✓ Created solution: ${solutionId}`);
|
||||
} catch (e) {
|
||||
throw new Error(`Failed to write solution: ${e.message}`);
|
||||
}
|
||||
|
||||
// Bind solution to issue
|
||||
try {
|
||||
Bash(`ccw issue bind ${issueId} ${solutionId}`);
|
||||
console.log(`✓ Bound solution to issue`);
|
||||
} catch (e) {
|
||||
// Cleanup: remove solution file on bind failure
|
||||
try {
|
||||
Bash(`rm -f "${solutionFile}"`);
|
||||
} catch (cleanupError) {
|
||||
// Ignore cleanup errors
|
||||
}
|
||||
throw new Error(`Failed to bind solution: ${e.message}`);
|
||||
}
|
||||
|
||||
// Update issue status to planned
|
||||
try {
|
||||
Bash(`ccw issue update ${issueId} --status planned`);
|
||||
} catch (e) {
|
||||
throw new Error(`Failed to update issue status: ${e.message}`);
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### Phase 7: Summary
|
||||
|
||||
```javascript
|
||||
console.log(`
|
||||
## Done
|
||||
|
||||
**Issue**: ${issueId}
|
||||
**Solution**: ${flags.supplement ? existingSolution.id : solutionId}
|
||||
**Tasks**: ${solution.tasks.length}
|
||||
**Status**: planned
|
||||
|
||||
### Next Steps:
|
||||
- \`/issue:queue\` → Form execution queue
|
||||
- \`ccw issue status ${issueId}\` → View issue details
|
||||
- \`ccw issue solution ${flags.supplement ? existingSolution.id : solutionId}\` → View solution
|
||||
`);
|
||||
```
|
||||
|
||||
## Error Handling
|
||||
|
||||
| Error | Code | Resolution |
|
||||
|-------|------|------------|
|
||||
| Source not found | E001 | Check path exists |
|
||||
| Invalid source format | E002 | Verify file contains valid plan structure |
|
||||
| Issue not found | E003 | Check issue ID or omit --issue to create new |
|
||||
| Solution already bound | E004 | Use --supplement to add tasks |
|
||||
| AI extraction failed | E005 | Check markdown structure, try simpler format |
|
||||
| No tasks extracted | E006 | Source must contain at least 1 task |
|
||||
|
||||
## Related Commands
|
||||
|
||||
- `/issue:plan` - Generate solutions from issue exploration
|
||||
- `/issue:queue` - Form execution queue from bound solutions
|
||||
- `/issue:execute` - Execute queue with DAG parallelism
|
||||
- `ccw issue status <id>` - View issue details
|
||||
- `ccw issue solution <id>` - View solution details
|
||||
768
.claude/commands/issue/discover-by-prompt.md
Normal file
768
.claude/commands/issue/discover-by-prompt.md
Normal file
@@ -0,0 +1,768 @@
|
||||
---
|
||||
name: issue:discover-by-prompt
|
||||
description: Discover issues from user prompt with Gemini-planned iterative multi-agent exploration. Uses ACE semantic search for context gathering and supports cross-module comparison (e.g., frontend vs backend API contracts).
|
||||
argument-hint: "[-y|--yes] <prompt> [--scope=src/**] [--depth=standard|deep] [--max-iterations=5]"
|
||||
allowed-tools: Skill(*), TodoWrite(*), Read(*), Bash(*), Task(*), AskUserQuestion(*), Glob(*), Grep(*), mcp__ace-tool__search_context(*), mcp__exa__search(*)
|
||||
---
|
||||
|
||||
## Auto Mode
|
||||
|
||||
When `--yes` or `-y`: Auto-continue all iterations, skip confirmations.
|
||||
|
||||
# Issue Discovery by Prompt
|
||||
|
||||
## Quick Start
|
||||
|
||||
```bash
|
||||
# Discover issues based on user description
|
||||
/issue:discover-by-prompt "Check if frontend API calls match backend implementations"
|
||||
|
||||
# Compare specific modules
|
||||
/issue:discover-by-prompt "Verify auth flow consistency between mobile and web clients" --scope=src/auth/**,src/mobile/**
|
||||
|
||||
# Deep exploration with more iterations
|
||||
/issue:discover-by-prompt "Find all places where error handling is inconsistent" --depth=deep --max-iterations=8
|
||||
|
||||
# Focused backend-frontend contract check
|
||||
/issue:discover-by-prompt "Compare REST API definitions with frontend fetch calls"
|
||||
```
|
||||
|
||||
**Core Difference from `/issue:discover`**:
|
||||
- `discover`: Pre-defined perspectives (bug, security, etc.), parallel execution
|
||||
- `discover-by-prompt`: User-driven prompt, Gemini-planned strategy, iterative exploration
|
||||
|
||||
## What & Why
|
||||
|
||||
### Core Concept
|
||||
|
||||
Prompt-driven issue discovery with intelligent planning. Instead of fixed perspectives, this command:
|
||||
|
||||
1. **Analyzes user intent** via Gemini to understand what to find
|
||||
2. **Plans exploration strategy** dynamically based on codebase structure
|
||||
3. **Executes iterative multi-agent exploration** with feedback loops
|
||||
4. **Performs cross-module comparison** when detecting comparison intent
|
||||
|
||||
### Value Proposition
|
||||
|
||||
1. **Natural Language Input**: Describe what you want to find, not how to find it
|
||||
2. **Intelligent Planning**: Gemini designs optimal exploration strategy
|
||||
3. **Iterative Refinement**: Each round builds on previous discoveries
|
||||
4. **Cross-Module Analysis**: Compare frontend/backend, mobile/web, old/new implementations
|
||||
5. **Adaptive Exploration**: Adjusts direction based on findings
|
||||
|
||||
### Use Cases
|
||||
|
||||
| Scenario | Example Prompt |
|
||||
|----------|----------------|
|
||||
| API Contract | "Check if frontend calls match backend endpoints" |
|
||||
| Error Handling | "Find inconsistent error handling patterns" |
|
||||
| Migration Gap | "Compare old auth with new auth implementation" |
|
||||
| Feature Parity | "Verify mobile has all web features" |
|
||||
| Schema Drift | "Check if TypeScript types match API responses" |
|
||||
| Integration | "Find mismatches between service A and service B" |
|
||||
|
||||
## How It Works
|
||||
|
||||
### Execution Flow
|
||||
|
||||
```
|
||||
Phase 1: Prompt Analysis & Initialization
|
||||
├─ Parse user prompt and flags
|
||||
├─ Detect exploration intent (comparison/search/verification)
|
||||
└─ Initialize discovery session
|
||||
|
||||
Phase 1.5: ACE Context Gathering
|
||||
├─ Use ACE semantic search to understand codebase structure
|
||||
├─ Identify relevant modules based on prompt keywords
|
||||
├─ Collect architecture context for Gemini planning
|
||||
└─ Build initial context package
|
||||
|
||||
Phase 2: Gemini Strategy Planning
|
||||
├─ Feed ACE context + prompt to Gemini CLI
|
||||
├─ Gemini analyzes and generates exploration strategy
|
||||
├─ Create exploration dimensions with search targets
|
||||
├─ Define comparison matrix (if comparison intent)
|
||||
└─ Set success criteria and iteration limits
|
||||
|
||||
Phase 3: Iterative Agent Exploration (with ACE)
|
||||
├─ Iteration 1: Initial exploration by assigned agents
|
||||
│ ├─ Agent A: ACE search + explore dimension 1
|
||||
│ ├─ Agent B: ACE search + explore dimension 2
|
||||
│ └─ Collect findings, update shared context
|
||||
├─ Iteration 2-N: Refined exploration
|
||||
│ ├─ Analyze previous findings
|
||||
│ ├─ ACE search for related code paths
|
||||
│ ├─ Execute targeted exploration
|
||||
│ └─ Update cumulative findings
|
||||
└─ Termination: Max iterations or convergence
|
||||
|
||||
Phase 4: Cross-Analysis & Synthesis
|
||||
├─ Compare findings across dimensions
|
||||
├─ Identify discrepancies and issues
|
||||
├─ Calculate confidence scores
|
||||
└─ Generate issue candidates
|
||||
|
||||
Phase 5: Issue Generation & Summary
|
||||
├─ Convert findings to issue format
|
||||
├─ Write discovery outputs
|
||||
└─ Prompt user for next action
|
||||
```
|
||||
|
||||
### Exploration Dimensions
|
||||
|
||||
Dimensions are **dynamically generated by Gemini** based on the user prompt. Not limited to predefined categories.
|
||||
|
||||
**Examples**:
|
||||
|
||||
| Prompt | Generated Dimensions |
|
||||
|--------|---------------------|
|
||||
| "Check API contracts" | frontend-calls, backend-handlers |
|
||||
| "Find auth issues" | auth-module (single dimension) |
|
||||
| "Compare old/new implementations" | legacy-code, new-code |
|
||||
| "Audit payment flow" | payment-service, validation, logging |
|
||||
| "Find error handling gaps" | error-handlers, error-types, recovery-logic |
|
||||
|
||||
Gemini analyzes the prompt + ACE context to determine:
|
||||
- How many dimensions are needed (1 to N)
|
||||
- What each dimension should focus on
|
||||
- Whether comparison is needed between dimensions
|
||||
|
||||
### Iteration Strategy
|
||||
|
||||
```
|
||||
┌─────────────────────────────────────────────────────────────┐
|
||||
│ Iteration Loop │
|
||||
├─────────────────────────────────────────────────────────────┤
|
||||
│ 1. Plan: What to explore this iteration │
|
||||
│ └─ Based on: previous findings + unexplored areas │
|
||||
│ │
|
||||
│ 2. Execute: Launch agents for this iteration │
|
||||
│ └─ Each agent: explore → collect → return summary │
|
||||
│ │
|
||||
│ 3. Analyze: Process iteration results │
|
||||
│ └─ New findings? Gaps? Contradictions? │
|
||||
│ │
|
||||
│ 4. Decide: Continue or terminate │
|
||||
│ └─ Terminate if: max iterations OR convergence OR │
|
||||
│ high confidence on all questions │
|
||||
└─────────────────────────────────────────────────────────────┘
|
||||
```
|
||||
|
||||
## Core Responsibilities
|
||||
|
||||
### Phase 1: Prompt Analysis & Initialization
|
||||
|
||||
```javascript
|
||||
// Step 1: Parse arguments
|
||||
const { prompt, scope, depth, maxIterations } = parseArgs(args);
|
||||
|
||||
// Step 2: Generate discovery ID
|
||||
const discoveryId = `DBP-${formatDate(new Date(), 'YYYYMMDD-HHmmss')}`;
|
||||
|
||||
// Step 3: Create output directory
|
||||
const outputDir = `.workflow/issues/discoveries/${discoveryId}`;
|
||||
await mkdir(outputDir, { recursive: true });
|
||||
await mkdir(`${outputDir}/iterations`, { recursive: true });
|
||||
|
||||
// Step 4: Detect intent type from prompt
|
||||
const intentType = detectIntent(prompt);
|
||||
// Returns: 'comparison' | 'search' | 'verification' | 'audit'
|
||||
|
||||
// Step 5: Initialize discovery state
|
||||
await writeJson(`${outputDir}/discovery-state.json`, {
|
||||
discovery_id: discoveryId,
|
||||
type: 'prompt-driven',
|
||||
prompt: prompt,
|
||||
intent_type: intentType,
|
||||
scope: scope || '**/*',
|
||||
depth: depth || 'standard',
|
||||
max_iterations: maxIterations || 5,
|
||||
phase: 'initialization',
|
||||
created_at: new Date().toISOString(),
|
||||
iterations: [],
|
||||
cumulative_findings: [],
|
||||
comparison_matrix: null // filled for comparison intent
|
||||
});
|
||||
```
|
||||
|
||||
### Phase 1.5: ACE Context Gathering
|
||||
|
||||
**Purpose**: Use ACE semantic search to gather codebase context before Gemini planning.
|
||||
|
||||
```javascript
|
||||
// Step 1: Extract keywords from prompt for semantic search
|
||||
const keywords = extractKeywords(prompt);
|
||||
// e.g., "frontend API calls match backend" → ["frontend", "API", "backend", "endpoints"]
|
||||
|
||||
// Step 2: Use ACE to understand codebase structure
|
||||
const aceQueries = [
|
||||
`Project architecture and module structure for ${keywords.join(', ')}`,
|
||||
`Where are ${keywords[0]} implementations located?`,
|
||||
`How does ${keywords.slice(0, 2).join(' ')} work in this codebase?`
|
||||
];
|
||||
|
||||
const aceResults = [];
|
||||
for (const query of aceQueries) {
|
||||
const result = await mcp__ace-tool__search_context({
|
||||
project_root_path: process.cwd(),
|
||||
query: query
|
||||
});
|
||||
aceResults.push({ query, result });
|
||||
}
|
||||
|
||||
// Step 3: Build context package for Gemini (kept in memory)
|
||||
const aceContext = {
|
||||
prompt_keywords: keywords,
|
||||
codebase_structure: aceResults[0].result,
|
||||
relevant_modules: aceResults.slice(1).map(r => r.result),
|
||||
detected_patterns: extractPatterns(aceResults)
|
||||
};
|
||||
|
||||
// Step 4: Update state (no separate file)
|
||||
await updateDiscoveryState(outputDir, {
|
||||
phase: 'context-gathered',
|
||||
ace_context: {
|
||||
queries_executed: aceQueries.length,
|
||||
modules_identified: aceContext.relevant_modules.length
|
||||
}
|
||||
});
|
||||
|
||||
// aceContext passed to Phase 2 in memory
|
||||
```
|
||||
|
||||
**ACE Query Strategy by Intent Type**:
|
||||
|
||||
| Intent | ACE Queries |
|
||||
|--------|-------------|
|
||||
| **comparison** | "frontend API calls", "backend API handlers", "API contract definitions" |
|
||||
| **search** | "{keyword} implementations", "{keyword} usage patterns" |
|
||||
| **verification** | "expected behavior for {feature}", "test coverage for {feature}" |
|
||||
| **audit** | "all {category} patterns", "{category} security concerns" |
|
||||
|
||||
### Phase 2: Gemini Strategy Planning
|
||||
|
||||
**Purpose**: Gemini analyzes user prompt + ACE context to design optimal exploration strategy.
|
||||
|
||||
```javascript
|
||||
// Step 1: Load ACE context gathered in Phase 1.5
|
||||
const aceContext = await readJson(`${outputDir}/ace-context.json`);
|
||||
|
||||
// Step 2: Build Gemini planning prompt with ACE context
|
||||
const planningPrompt = `
|
||||
PURPOSE: Analyze discovery prompt and create exploration strategy based on codebase context
|
||||
TASK:
|
||||
• Parse user intent from prompt: "${prompt}"
|
||||
• Use codebase context to identify specific modules and files to explore
|
||||
• Create exploration dimensions with precise search targets
|
||||
• Define comparison matrix structure (if comparison intent)
|
||||
• Set success criteria and iteration strategy
|
||||
MODE: analysis
|
||||
CONTEXT: @${scope || '**/*'} | Discovery type: ${intentType}
|
||||
|
||||
## Codebase Context (from ACE semantic search)
|
||||
${JSON.stringify(aceContext, null, 2)}
|
||||
|
||||
EXPECTED: JSON exploration plan following exploration-plan-schema.json:
|
||||
{
|
||||
"intent_analysis": { "type": "${intentType}", "primary_question": "...", "sub_questions": [...] },
|
||||
"dimensions": [{ "name": "...", "description": "...", "search_targets": [...], "focus_areas": [...], "agent_prompt": "..." }],
|
||||
"comparison_matrix": { "dimension_a": "...", "dimension_b": "...", "comparison_points": [...] },
|
||||
"success_criteria": [...],
|
||||
"estimated_iterations": N,
|
||||
"termination_conditions": [...]
|
||||
}
|
||||
CONSTRAINTS: Use ACE context to inform targets | Focus on actionable plan
|
||||
`;
|
||||
|
||||
// Step 3: Execute Gemini planning
|
||||
Bash({
|
||||
command: `ccw cli -p "${planningPrompt}" --tool gemini --mode analysis`,
|
||||
run_in_background: true,
|
||||
timeout: 300000
|
||||
});
|
||||
|
||||
// Step 4: Parse Gemini output and validate against schema
|
||||
const explorationPlan = await parseGeminiPlanOutput(geminiResult);
|
||||
validateAgainstSchema(explorationPlan, 'exploration-plan-schema.json');
|
||||
|
||||
// Step 5: Enhance plan with ACE-discovered file paths
|
||||
explorationPlan.dimensions = explorationPlan.dimensions.map(dim => ({
|
||||
...dim,
|
||||
ace_suggested_files: aceContext.relevant_modules
|
||||
.filter(m => m.relevance_to === dim.name)
|
||||
.map(m => m.file_path)
|
||||
}));
|
||||
|
||||
// Step 6: Update state (plan kept in memory, not persisted)
|
||||
await updateDiscoveryState(outputDir, {
|
||||
phase: 'planned',
|
||||
exploration_plan: {
|
||||
dimensions_count: explorationPlan.dimensions.length,
|
||||
has_comparison_matrix: !!explorationPlan.comparison_matrix,
|
||||
estimated_iterations: explorationPlan.estimated_iterations
|
||||
}
|
||||
});
|
||||
|
||||
// explorationPlan passed to Phase 3 in memory
|
||||
```
|
||||
|
||||
**Gemini Planning Responsibilities**:
|
||||
|
||||
| Responsibility | Input | Output |
|
||||
|----------------|-------|--------|
|
||||
| Intent Analysis | User prompt | type, primary_question, sub_questions |
|
||||
| Dimension Design | ACE context + prompt | dimensions with search_targets |
|
||||
| Comparison Matrix | Intent type + modules | comparison_points (if applicable) |
|
||||
| Iteration Strategy | Depth setting | estimated_iterations, termination_conditions |
|
||||
|
||||
**Gemini Planning Output Schema**:
|
||||
|
||||
```json
|
||||
{
|
||||
"intent_analysis": {
|
||||
"type": "comparison|search|verification|audit",
|
||||
"primary_question": "string",
|
||||
"sub_questions": ["string"]
|
||||
},
|
||||
"dimensions": [
|
||||
{
|
||||
"name": "frontend",
|
||||
"description": "Client-side API calls and error handling",
|
||||
"search_targets": ["src/api/**", "src/hooks/**"],
|
||||
"focus_areas": ["fetch calls", "error boundaries", "response parsing"],
|
||||
"agent_prompt": "Explore frontend API consumption patterns..."
|
||||
},
|
||||
{
|
||||
"name": "backend",
|
||||
"description": "Server-side API implementations",
|
||||
"search_targets": ["src/server/**", "src/routes/**"],
|
||||
"focus_areas": ["endpoint handlers", "response schemas", "error responses"],
|
||||
"agent_prompt": "Explore backend API implementations..."
|
||||
}
|
||||
],
|
||||
"comparison_matrix": {
|
||||
"dimension_a": "frontend",
|
||||
"dimension_b": "backend",
|
||||
"comparison_points": [
|
||||
{"aspect": "endpoints", "frontend_check": "fetch URLs", "backend_check": "route paths"},
|
||||
{"aspect": "methods", "frontend_check": "HTTP methods used", "backend_check": "methods accepted"},
|
||||
{"aspect": "payloads", "frontend_check": "request body structure", "backend_check": "expected schema"},
|
||||
{"aspect": "responses", "frontend_check": "response parsing", "backend_check": "response format"},
|
||||
{"aspect": "errors", "frontend_check": "error handling", "backend_check": "error responses"}
|
||||
]
|
||||
},
|
||||
"success_criteria": [
|
||||
"All API endpoints mapped between frontend and backend",
|
||||
"Discrepancies identified with file:line references",
|
||||
"Each finding includes remediation suggestion"
|
||||
],
|
||||
"estimated_iterations": 3,
|
||||
"termination_conditions": [
|
||||
"All comparison points verified",
|
||||
"No new findings in last iteration",
|
||||
"Confidence > 0.8 on primary question"
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
### Phase 3: Iterative Agent Exploration (with ACE)
|
||||
|
||||
**Purpose**: Multi-agent iterative exploration using ACE for semantic search within each iteration.
|
||||
|
||||
```javascript
|
||||
let iteration = 0;
|
||||
let cumulativeFindings = [];
|
||||
let sharedContext = { aceDiscoveries: [], crossReferences: [] };
|
||||
let shouldContinue = true;
|
||||
|
||||
while (shouldContinue && iteration < maxIterations) {
|
||||
iteration++;
|
||||
const iterationDir = `${outputDir}/iterations/${iteration}`;
|
||||
await mkdir(iterationDir, { recursive: true });
|
||||
|
||||
// Step 1: ACE-assisted iteration planning
|
||||
// Use previous findings to guide ACE queries for this iteration
|
||||
const iterationAceQueries = iteration === 1
|
||||
? explorationPlan.dimensions.map(d => d.focus_areas[0]) // Initial queries from plan
|
||||
: deriveQueriesFromFindings(cumulativeFindings); // Follow-up queries from findings
|
||||
|
||||
// Execute ACE searches to find related code
|
||||
const iterationAceResults = [];
|
||||
for (const query of iterationAceQueries) {
|
||||
const result = await mcp__ace-tool__search_context({
|
||||
project_root_path: process.cwd(),
|
||||
query: `${query} in ${explorationPlan.scope}`
|
||||
});
|
||||
iterationAceResults.push({ query, result });
|
||||
}
|
||||
|
||||
// Update shared context with ACE discoveries
|
||||
sharedContext.aceDiscoveries.push(...iterationAceResults);
|
||||
|
||||
// Step 2: Plan this iteration based on ACE results
|
||||
const iterationPlan = planIteration(iteration, explorationPlan, cumulativeFindings, iterationAceResults);
|
||||
|
||||
// Step 3: Launch dimension agents with ACE context
|
||||
const agentPromises = iterationPlan.dimensions.map(dimension =>
|
||||
Task({
|
||||
subagent_type: "cli-explore-agent",
|
||||
run_in_background: false,
|
||||
description: `Explore ${dimension.name} (iteration ${iteration})`,
|
||||
prompt: buildDimensionPromptWithACE(dimension, iteration, cumulativeFindings, iterationAceResults, iterationDir)
|
||||
})
|
||||
);
|
||||
|
||||
// Wait for iteration agents
|
||||
const iterationResults = await Promise.all(agentPromises);
|
||||
|
||||
// Step 4: Collect and analyze iteration findings
|
||||
const iterationFindings = await collectIterationFindings(iterationDir, iterationPlan.dimensions);
|
||||
|
||||
// Step 5: Cross-reference findings between dimensions
|
||||
if (iterationPlan.dimensions.length > 1) {
|
||||
const crossRefs = findCrossReferences(iterationFindings, iterationPlan.dimensions);
|
||||
sharedContext.crossReferences.push(...crossRefs);
|
||||
}
|
||||
|
||||
cumulativeFindings.push(...iterationFindings);
|
||||
|
||||
// Step 6: Decide whether to continue
|
||||
const convergenceCheck = checkConvergence(iterationFindings, cumulativeFindings, explorationPlan);
|
||||
shouldContinue = !convergenceCheck.converged;
|
||||
|
||||
// Step 7: Update state (iteration summary embedded in state)
|
||||
await updateDiscoveryState(outputDir, {
|
||||
iterations: [...state.iterations, {
|
||||
number: iteration,
|
||||
findings_count: iterationFindings.length,
|
||||
ace_queries: iterationAceQueries.length,
|
||||
cross_references: sharedContext.crossReferences.length,
|
||||
new_discoveries: convergenceCheck.newDiscoveries,
|
||||
confidence: convergenceCheck.confidence,
|
||||
continued: shouldContinue
|
||||
}],
|
||||
cumulative_findings: cumulativeFindings
|
||||
});
|
||||
}
|
||||
```
|
||||
|
||||
**ACE in Iteration Loop**:
|
||||
|
||||
```
|
||||
Iteration N
|
||||
│
|
||||
├─→ ACE Search (based on previous findings)
|
||||
│ └─ Query: "related code paths for {finding.category}"
|
||||
│ └─ Result: Additional files to explore
|
||||
│
|
||||
├─→ Agent Exploration (with ACE context)
|
||||
│ └─ Agent receives: dimension targets + ACE suggestions
|
||||
│ └─ Agent can call ACE for deeper search
|
||||
│
|
||||
├─→ Cross-Reference Analysis
|
||||
│ └─ Compare findings between dimensions
|
||||
│ └─ Identify discrepancies
|
||||
│
|
||||
└─→ Convergence Check
|
||||
└─ New findings? Continue
|
||||
└─ No new findings? Terminate
|
||||
```
|
||||
|
||||
**Dimension Agent Prompt Template (with ACE)**:
|
||||
|
||||
```javascript
|
||||
function buildDimensionPromptWithACE(dimension, iteration, previousFindings, aceResults, outputDir) {
|
||||
// Filter ACE results relevant to this dimension
|
||||
const relevantAceResults = aceResults.filter(r =>
|
||||
r.query.includes(dimension.name) || dimension.focus_areas.some(fa => r.query.includes(fa))
|
||||
);
|
||||
|
||||
return `
|
||||
## Task Objective
|
||||
Explore ${dimension.name} dimension for issue discovery (Iteration ${iteration})
|
||||
|
||||
## Context
|
||||
- Dimension: ${dimension.name}
|
||||
- Description: ${dimension.description}
|
||||
- Search Targets: ${dimension.search_targets.join(', ')}
|
||||
- Focus Areas: ${dimension.focus_areas.join(', ')}
|
||||
|
||||
## ACE Semantic Search Results (Pre-gathered)
|
||||
The following files/code sections were identified by ACE as relevant to this dimension:
|
||||
${JSON.stringify(relevantAceResults.map(r => ({ query: r.query, files: r.result.slice(0, 5) })), null, 2)}
|
||||
|
||||
**Use ACE for deeper exploration**: You have access to mcp__ace-tool__search_context.
|
||||
When you find something interesting, use ACE to find related code:
|
||||
- mcp__ace-tool__search_context({ project_root_path: ".", query: "related to {finding}" })
|
||||
|
||||
${iteration > 1 ? `
|
||||
## Previous Findings to Build Upon
|
||||
${summarizePreviousFindings(previousFindings, dimension.name)}
|
||||
|
||||
## This Iteration Focus
|
||||
- Explore areas not yet covered (check ACE results for new files)
|
||||
- Verify/deepen previous findings
|
||||
- Follow leads from previous discoveries
|
||||
- Use ACE to find cross-references between dimensions
|
||||
` : ''}
|
||||
|
||||
## MANDATORY FIRST STEPS
|
||||
1. Read exploration plan: ${outputDir}/../exploration-plan.json
|
||||
2. Read schema: ~/.claude/workflows/cli-templates/schemas/discovery-finding-schema.json
|
||||
3. Review ACE results above for starting points
|
||||
4. Explore files identified by ACE
|
||||
|
||||
## Exploration Instructions
|
||||
${dimension.agent_prompt}
|
||||
|
||||
## ACE Usage Guidelines
|
||||
- Use ACE when you need to find:
|
||||
- Where a function/class is used
|
||||
- Related implementations in other modules
|
||||
- Cross-module dependencies
|
||||
- Similar patterns elsewhere in codebase
|
||||
- Query format: Natural language, be specific
|
||||
- Example: "Where is UserService.authenticate called from?"
|
||||
|
||||
## Output Requirements
|
||||
|
||||
**1. Write JSON file**: ${outputDir}/${dimension.name}.json
|
||||
Follow discovery-finding-schema.json:
|
||||
- findings: [{id, title, category, description, file, line, snippet, confidence, related_dimension}]
|
||||
- coverage: {files_explored, areas_covered, areas_remaining}
|
||||
- leads: [{description, suggested_search}] // for next iteration
|
||||
- ace_queries_used: [{query, result_count}] // track ACE usage
|
||||
|
||||
**2. Return summary**:
|
||||
- Total findings this iteration
|
||||
- Key discoveries
|
||||
- ACE queries that revealed important code
|
||||
- Recommended next exploration areas
|
||||
|
||||
## Success Criteria
|
||||
- [ ] JSON written to ${outputDir}/${dimension.name}.json
|
||||
- [ ] Each finding has file:line reference
|
||||
- [ ] ACE used for cross-references where applicable
|
||||
- [ ] Coverage report included
|
||||
- [ ] Leads for next iteration identified
|
||||
`;
|
||||
}
|
||||
```
|
||||
|
||||
### Phase 4: Cross-Analysis & Synthesis
|
||||
|
||||
```javascript
|
||||
// For comparison intent, perform cross-analysis
|
||||
if (intentType === 'comparison' && explorationPlan.comparison_matrix) {
|
||||
const comparisonResults = [];
|
||||
|
||||
for (const point of explorationPlan.comparison_matrix.comparison_points) {
|
||||
const dimensionAFindings = cumulativeFindings.filter(f =>
|
||||
f.related_dimension === explorationPlan.comparison_matrix.dimension_a &&
|
||||
f.category.includes(point.aspect)
|
||||
);
|
||||
|
||||
const dimensionBFindings = cumulativeFindings.filter(f =>
|
||||
f.related_dimension === explorationPlan.comparison_matrix.dimension_b &&
|
||||
f.category.includes(point.aspect)
|
||||
);
|
||||
|
||||
// Compare and find discrepancies
|
||||
const discrepancies = findDiscrepancies(dimensionAFindings, dimensionBFindings, point);
|
||||
|
||||
comparisonResults.push({
|
||||
aspect: point.aspect,
|
||||
dimension_a_count: dimensionAFindings.length,
|
||||
dimension_b_count: dimensionBFindings.length,
|
||||
discrepancies: discrepancies,
|
||||
match_rate: calculateMatchRate(dimensionAFindings, dimensionBFindings)
|
||||
});
|
||||
}
|
||||
|
||||
// Write comparison analysis
|
||||
await writeJson(`${outputDir}/comparison-analysis.json`, {
|
||||
matrix: explorationPlan.comparison_matrix,
|
||||
results: comparisonResults,
|
||||
summary: {
|
||||
total_discrepancies: comparisonResults.reduce((sum, r) => sum + r.discrepancies.length, 0),
|
||||
overall_match_rate: average(comparisonResults.map(r => r.match_rate)),
|
||||
critical_mismatches: comparisonResults.filter(r => r.match_rate < 0.5)
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// Prioritize all findings
|
||||
const prioritizedFindings = prioritizeFindings(cumulativeFindings, explorationPlan);
|
||||
```
|
||||
|
||||
### Phase 5: Issue Generation & Summary
|
||||
|
||||
```javascript
|
||||
// Convert high-confidence findings to issues
|
||||
const issueWorthy = prioritizedFindings.filter(f =>
|
||||
f.confidence >= 0.7 || f.priority === 'critical' || f.priority === 'high'
|
||||
);
|
||||
|
||||
const issues = issueWorthy.map(finding => ({
|
||||
id: `ISS-${discoveryId}-${finding.id}`,
|
||||
title: finding.title,
|
||||
description: finding.description,
|
||||
source: {
|
||||
discovery_id: discoveryId,
|
||||
finding_id: finding.id,
|
||||
dimension: finding.related_dimension
|
||||
},
|
||||
file: finding.file,
|
||||
line: finding.line,
|
||||
priority: finding.priority,
|
||||
category: finding.category,
|
||||
suggested_fix: finding.suggested_fix,
|
||||
confidence: finding.confidence,
|
||||
status: 'discovered',
|
||||
created_at: new Date().toISOString()
|
||||
}));
|
||||
|
||||
// Write issues
|
||||
await writeJsonl(`${outputDir}/discovery-issues.jsonl`, issues);
|
||||
|
||||
// Update final state (summary embedded in state, no separate file)
|
||||
await updateDiscoveryState(outputDir, {
|
||||
phase: 'complete',
|
||||
updated_at: new Date().toISOString(),
|
||||
results: {
|
||||
total_iterations: iteration,
|
||||
total_findings: cumulativeFindings.length,
|
||||
issues_generated: issues.length,
|
||||
comparison_match_rate: comparisonResults
|
||||
? average(comparisonResults.map(r => r.match_rate))
|
||||
: null
|
||||
}
|
||||
});
|
||||
|
||||
// Prompt user for next action
|
||||
await AskUserQuestion({
|
||||
questions: [{
|
||||
question: `Discovery complete: ${issues.length} issues from ${cumulativeFindings.length} findings across ${iteration} iterations. What next?`,
|
||||
header: "Next Step",
|
||||
multiSelect: false,
|
||||
options: [
|
||||
{ label: "Export to Issues (Recommended)", description: `Export ${issues.length} issues for planning` },
|
||||
{ label: "Review Details", description: "View comparison analysis and iteration details" },
|
||||
{ label: "Run Deeper", description: "Continue with more iterations" },
|
||||
{ label: "Skip", description: "Complete without exporting" }
|
||||
]
|
||||
}]
|
||||
});
|
||||
```
|
||||
|
||||
## Output File Structure
|
||||
|
||||
```
|
||||
.workflow/issues/discoveries/
|
||||
└── {DBP-YYYYMMDD-HHmmss}/
|
||||
├── discovery-state.json # Session state with iteration tracking
|
||||
├── iterations/
|
||||
│ ├── 1/
|
||||
│ │ └── {dimension}.json # Dimension findings
|
||||
│ ├── 2/
|
||||
│ │ └── {dimension}.json
|
||||
│ └── ...
|
||||
├── comparison-analysis.json # Cross-dimension comparison (if applicable)
|
||||
└── discovery-issues.jsonl # Generated issue candidates
|
||||
```
|
||||
|
||||
**Simplified Design**:
|
||||
- ACE context and Gemini plan kept in memory, not persisted
|
||||
- Iteration summaries embedded in state
|
||||
- No separate summary.md (state.json contains all needed info)
|
||||
|
||||
## Schema References
|
||||
|
||||
| Schema | Path | Used By |
|
||||
|--------|------|---------|
|
||||
| **Discovery State** | `discovery-state-schema.json` | Orchestrator (state tracking) |
|
||||
| **Discovery Finding** | `discovery-finding-schema.json` | Dimension agents (output) |
|
||||
| **Exploration Plan** | `exploration-plan-schema.json` | Gemini output validation (memory only) |
|
||||
|
||||
## Configuration Options
|
||||
|
||||
| Flag | Default | Description |
|
||||
|------|---------|-------------|
|
||||
| `--scope` | `**/*` | File pattern to explore |
|
||||
| `--depth` | `standard` | `standard` (3 iterations) or `deep` (5+ iterations) |
|
||||
| `--max-iterations` | 5 | Maximum exploration iterations |
|
||||
| `--tool` | `gemini` | Planning tool (gemini/qwen) |
|
||||
| `--plan-only` | `false` | Stop after Phase 2 (Gemini planning), show plan for user review |
|
||||
|
||||
## Examples
|
||||
|
||||
### Example 1: Single Module Deep Dive
|
||||
|
||||
```bash
|
||||
/issue:discover-by-prompt "Find all potential issues in the auth module" --scope=src/auth/**
|
||||
```
|
||||
|
||||
**Gemini plans** (single dimension):
|
||||
- Dimension: auth-module
|
||||
- Focus: security vulnerabilities, edge cases, error handling, test gaps
|
||||
|
||||
**Iterations**: 2-3 (until no new findings)
|
||||
|
||||
### Example 2: API Contract Comparison
|
||||
|
||||
```bash
|
||||
/issue:discover-by-prompt "Check if API calls match implementations" --scope=src/**
|
||||
```
|
||||
|
||||
**Gemini plans** (comparison):
|
||||
- Dimension 1: api-consumers (fetch calls, hooks, services)
|
||||
- Dimension 2: api-providers (handlers, routes, controllers)
|
||||
- Comparison matrix: endpoints, methods, payloads, responses
|
||||
|
||||
### Example 3: Multi-Module Audit
|
||||
|
||||
```bash
|
||||
/issue:discover-by-prompt "Audit the payment flow for issues" --scope=src/payment/**
|
||||
```
|
||||
|
||||
**Gemini plans** (multi-dimension):
|
||||
- Dimension 1: payment-logic (calculations, state transitions)
|
||||
- Dimension 2: validation (input checks, business rules)
|
||||
- Dimension 3: error-handling (failure modes, recovery)
|
||||
|
||||
### Example 4: Plan Only Mode
|
||||
|
||||
```bash
|
||||
/issue:discover-by-prompt "Find inconsistent patterns" --plan-only
|
||||
```
|
||||
|
||||
Stops after Gemini planning, outputs:
|
||||
```
|
||||
Gemini Plan:
|
||||
- Intent: search
|
||||
- Dimensions: 2 (pattern-definitions, pattern-usages)
|
||||
- Estimated iterations: 3
|
||||
|
||||
Continue with exploration? [Y/n]
|
||||
```
|
||||
|
||||
## Related Commands
|
||||
|
||||
```bash
|
||||
# After discovery, plan solutions
|
||||
/issue:plan DBP-001-01,DBP-001-02
|
||||
|
||||
# View all discoveries
|
||||
/issue:manage
|
||||
|
||||
# Standard perspective-based discovery
|
||||
/issue:discover src/auth/** --perspectives=security,bug
|
||||
```
|
||||
|
||||
## Best Practices
|
||||
|
||||
1. **Be Specific in Prompts**: More specific prompts lead to better Gemini planning
|
||||
2. **Scope Appropriately**: Narrow scope for focused comparison, wider for audits
|
||||
3. **Review Exploration Plan**: Check `exploration-plan.json` before long explorations
|
||||
4. **Use Standard Depth First**: Start with standard, go deep only if needed
|
||||
5. **Combine with `/issue:discover`**: Use prompt-based for comparisons, perspective-based for audits
|
||||
472
.claude/commands/issue/discover.md
Normal file
472
.claude/commands/issue/discover.md
Normal file
@@ -0,0 +1,472 @@
|
||||
---
|
||||
name: issue:discover
|
||||
description: Discover potential issues from multiple perspectives (bug, UX, test, quality, security, performance, maintainability, best-practices) using CLI explore. Supports Exa external research for security and best-practices perspectives.
|
||||
argument-hint: "[-y|--yes] <path-pattern> [--perspectives=bug,ux,...] [--external]"
|
||||
allowed-tools: Skill(*), TodoWrite(*), Read(*), Bash(*), Task(*), AskUserQuestion(*), Glob(*), Grep(*)
|
||||
---
|
||||
|
||||
## Auto Mode
|
||||
|
||||
When `--yes` or `-y`: Auto-select all perspectives, skip confirmations.
|
||||
|
||||
# Issue Discovery Command
|
||||
|
||||
## Quick Start
|
||||
|
||||
```bash
|
||||
# Discover issues in specific module (interactive perspective selection)
|
||||
/issue:discover src/auth/**
|
||||
|
||||
# Discover with specific perspectives
|
||||
/issue:discover src/payment/** --perspectives=bug,security,test
|
||||
|
||||
# Discover with external research for all perspectives
|
||||
/issue:discover src/api/** --external
|
||||
|
||||
# Discover in multiple modules
|
||||
/issue:discover src/auth/**,src/payment/**
|
||||
```
|
||||
|
||||
**Discovery Scope**: Specified modules/files only
|
||||
**Output Directory**: `.workflow/issues/discoveries/{discovery-id}/`
|
||||
**Available Perspectives**: bug, ux, test, quality, security, performance, maintainability, best-practices
|
||||
**Exa Integration**: Auto-enabled for security and best-practices perspectives
|
||||
**CLI Tools**: Gemini → Qwen → Codex (fallback chain)
|
||||
|
||||
## What & Why
|
||||
|
||||
### Core Concept
|
||||
Multi-perspective issue discovery orchestrator that explores code from different angles to identify potential bugs, UX improvements, test gaps, and other actionable items. Unlike code review (which assesses existing code quality), discovery focuses on **finding opportunities for improvement and potential problems**.
|
||||
|
||||
**vs Code Review**:
|
||||
- **Code Review** (`review-module-cycle`): Evaluates code quality against standards
|
||||
- **Issue Discovery** (`issue:discover`): Finds actionable issues, bugs, and improvement opportunities
|
||||
|
||||
### Value Proposition
|
||||
1. **Proactive Issue Detection**: Find problems before they become bugs
|
||||
2. **Multi-Perspective Analysis**: Each perspective surfaces different types of issues
|
||||
3. **External Benchmarking**: Compare against industry best practices via Exa
|
||||
4. **Direct Issue Integration**: Discoveries can be exported to issue tracker
|
||||
5. **Dashboard Management**: View, filter, and export discoveries via CCW dashboard
|
||||
|
||||
## How It Works
|
||||
|
||||
### Execution Flow
|
||||
|
||||
```
|
||||
Phase 1: Discovery & Initialization
|
||||
└─ Parse target pattern, create session, initialize output structure
|
||||
|
||||
Phase 2: Interactive Perspective Selection
|
||||
└─ AskUserQuestion for perspective selection (or use --perspectives)
|
||||
|
||||
Phase 3: Parallel Perspective Analysis
|
||||
├─ Launch N @cli-explore-agent instances (one per perspective)
|
||||
├─ Security & Best-Practices auto-trigger Exa research
|
||||
├─ Agent writes perspective JSON, returns summary
|
||||
└─ Update discovery-progress.json
|
||||
|
||||
Phase 4: Aggregation & Prioritization
|
||||
├─ Collect agent return summaries
|
||||
├─ Load perspective JSON files
|
||||
├─ Merge findings, deduplicate by file+line
|
||||
└─ Calculate priority scores
|
||||
|
||||
Phase 5: Issue Generation & Summary
|
||||
├─ Convert high-priority discoveries to issue format
|
||||
├─ Write to discovery-issues.jsonl
|
||||
├─ Generate single summary.md from agent returns
|
||||
└─ Update discovery-state.json to complete
|
||||
|
||||
Phase 6: User Action Prompt
|
||||
└─ AskUserQuestion for next step (export/dashboard/skip)
|
||||
```
|
||||
|
||||
## Perspectives
|
||||
|
||||
### Available Perspectives
|
||||
|
||||
| Perspective | Focus | Categories | Exa |
|
||||
|-------------|-------|------------|-----|
|
||||
| **bug** | Potential Bugs | edge-case, null-check, resource-leak, race-condition, boundary, exception-handling | - |
|
||||
| **ux** | User Experience | error-message, loading-state, feedback, accessibility, interaction, consistency | - |
|
||||
| **test** | Test Coverage | missing-test, edge-case-test, integration-gap, coverage-hole, assertion-quality | - |
|
||||
| **quality** | Code Quality | complexity, duplication, naming, documentation, code-smell, readability | - |
|
||||
| **security** | Security Issues | injection, auth, encryption, input-validation, data-exposure, access-control | ✓ |
|
||||
| **performance** | Performance | n-plus-one, memory-usage, caching, algorithm, blocking-operation, resource | - |
|
||||
| **maintainability** | Maintainability | coupling, cohesion, tech-debt, extensibility, module-boundary, interface-design | - |
|
||||
| **best-practices** | Best Practices | convention, pattern, framework-usage, anti-pattern, industry-standard | ✓ |
|
||||
|
||||
### Interactive Perspective Selection
|
||||
|
||||
When no `--perspectives` flag is provided, the command uses AskUserQuestion:
|
||||
|
||||
```javascript
|
||||
AskUserQuestion({
|
||||
questions: [{
|
||||
question: "Select primary discovery focus:",
|
||||
header: "Focus",
|
||||
multiSelect: false,
|
||||
options: [
|
||||
{ label: "Bug + Test + Quality", description: "Quick scan: potential bugs, test gaps, code quality (Recommended)" },
|
||||
{ label: "Security + Performance", description: "System audit: security issues, performance bottlenecks" },
|
||||
{ label: "Maintainability + Best-practices", description: "Long-term health: coupling, tech debt, conventions" },
|
||||
{ label: "Full analysis", description: "All 7 perspectives (comprehensive, takes longer)" }
|
||||
]
|
||||
}]
|
||||
})
|
||||
```
|
||||
|
||||
**Recommended Combinations**:
|
||||
- Quick scan: bug, test, quality
|
||||
- Full analysis: all perspectives
|
||||
- Security audit: security, bug, quality
|
||||
|
||||
## Core Responsibilities
|
||||
|
||||
### Orchestrator
|
||||
|
||||
**Phase 1: Discovery & Initialization**
|
||||
|
||||
```javascript
|
||||
// Step 1: Parse target pattern and resolve files
|
||||
const resolvedFiles = await expandGlobPattern(targetPattern);
|
||||
if (resolvedFiles.length === 0) {
|
||||
throw new Error(`No files matched pattern: ${targetPattern}`);
|
||||
}
|
||||
|
||||
// Step 2: Generate discovery ID
|
||||
const discoveryId = `DSC-${formatDate(new Date(), 'YYYYMMDD-HHmmss')}`;
|
||||
|
||||
// Step 3: Create output directory
|
||||
const outputDir = `.workflow/issues/discoveries/${discoveryId}`;
|
||||
await mkdir(outputDir, { recursive: true });
|
||||
await mkdir(`${outputDir}/perspectives`, { recursive: true });
|
||||
|
||||
// Step 4: Initialize unified discovery state (merged state+progress)
|
||||
await writeJson(`${outputDir}/discovery-state.json`, {
|
||||
discovery_id: discoveryId,
|
||||
target_pattern: targetPattern,
|
||||
phase: "initialization",
|
||||
created_at: new Date().toISOString(),
|
||||
updated_at: new Date().toISOString(),
|
||||
target: { files_count: { total: resolvedFiles.length }, project: {} },
|
||||
perspectives: [], // filled after selection: [{name, status, findings}]
|
||||
external_research: { enabled: false, completed: false },
|
||||
results: { total_findings: 0, issues_generated: 0, priority_distribution: {} }
|
||||
});
|
||||
```
|
||||
|
||||
**Phase 2: Perspective Selection**
|
||||
|
||||
```javascript
|
||||
// Check for --perspectives flag
|
||||
let selectedPerspectives = [];
|
||||
|
||||
if (args.perspectives) {
|
||||
selectedPerspectives = args.perspectives.split(',').map(p => p.trim());
|
||||
} else {
|
||||
// Interactive selection via AskUserQuestion
|
||||
const response = await AskUserQuestion({...});
|
||||
selectedPerspectives = parseSelectedPerspectives(response);
|
||||
}
|
||||
|
||||
// Validate and update state
|
||||
await updateDiscoveryState(outputDir, {
|
||||
'metadata.perspectives': selectedPerspectives,
|
||||
phase: 'parallel'
|
||||
});
|
||||
```
|
||||
|
||||
**Phase 3: Parallel Perspective Analysis**
|
||||
|
||||
Launch N agents in parallel (one per selected perspective):
|
||||
|
||||
```javascript
|
||||
// Launch agents in parallel - agents write JSON and return summary
|
||||
const agentPromises = selectedPerspectives.map(perspective =>
|
||||
Task({
|
||||
subagent_type: "cli-explore-agent",
|
||||
run_in_background: false,
|
||||
description: `Discover ${perspective} issues`,
|
||||
prompt: buildPerspectivePrompt(perspective, discoveryId, resolvedFiles, outputDir)
|
||||
})
|
||||
);
|
||||
|
||||
// Wait for all agents - collect their return summaries
|
||||
const results = await Promise.all(agentPromises);
|
||||
// results contain agent summaries for final report
|
||||
```
|
||||
|
||||
**Phase 4: Aggregation & Prioritization**
|
||||
|
||||
```javascript
|
||||
// Load all perspective JSON files written by agents
|
||||
const allFindings = [];
|
||||
for (const perspective of selectedPerspectives) {
|
||||
const jsonPath = `${outputDir}/perspectives/${perspective}.json`;
|
||||
if (await fileExists(jsonPath)) {
|
||||
const data = await readJson(jsonPath);
|
||||
allFindings.push(...data.findings.map(f => ({ ...f, perspective })));
|
||||
}
|
||||
}
|
||||
|
||||
// Deduplicate and prioritize
|
||||
const prioritizedFindings = deduplicateAndPrioritize(allFindings);
|
||||
|
||||
// Update unified state
|
||||
await updateDiscoveryState(outputDir, {
|
||||
phase: 'aggregation',
|
||||
'results.total_findings': prioritizedFindings.length,
|
||||
'results.priority_distribution': countByPriority(prioritizedFindings)
|
||||
});
|
||||
```
|
||||
|
||||
**Phase 5: Issue Generation & Summary**
|
||||
|
||||
```javascript
|
||||
// Convert high-priority findings to issues
|
||||
const issueWorthy = prioritizedFindings.filter(f =>
|
||||
f.priority === 'critical' || f.priority === 'high' || f.priority_score >= 0.7
|
||||
);
|
||||
|
||||
// Write discovery-issues.jsonl
|
||||
await writeJsonl(`${outputDir}/discovery-issues.jsonl`, issues);
|
||||
|
||||
// Generate single summary.md from agent return summaries
|
||||
// Orchestrator briefly summarizes what agents returned (NO detailed reports)
|
||||
await writeSummaryFromAgentReturns(outputDir, results, prioritizedFindings, issues);
|
||||
|
||||
// Update final state
|
||||
await updateDiscoveryState(outputDir, {
|
||||
phase: 'complete',
|
||||
updated_at: new Date().toISOString(),
|
||||
'results.issues_generated': issues.length
|
||||
});
|
||||
```
|
||||
|
||||
**Phase 6: User Action Prompt**
|
||||
|
||||
```javascript
|
||||
// Prompt user for next action based on discovery results
|
||||
const hasHighPriority = issues.some(i => i.priority === 'critical' || i.priority === 'high');
|
||||
const hasMediumFindings = prioritizedFindings.some(f => f.priority === 'medium');
|
||||
|
||||
await AskUserQuestion({
|
||||
questions: [{
|
||||
question: `Discovery complete: ${issues.length} issues generated, ${prioritizedFindings.length} total findings. What would you like to do next?`,
|
||||
header: "Next Step",
|
||||
multiSelect: false,
|
||||
options: hasHighPriority ? [
|
||||
{ label: "Export to Issues (Recommended)", description: `${issues.length} high-priority issues found - export to issue tracker for planning` },
|
||||
{ label: "Open Dashboard", description: "Review findings in ccw view before exporting" },
|
||||
{ label: "Skip", description: "Complete discovery without exporting" }
|
||||
] : hasMediumFindings ? [
|
||||
{ label: "Open Dashboard (Recommended)", description: "Review medium-priority findings in ccw view to decide which to export" },
|
||||
{ label: "Export to Issues", description: `Export ${issues.length} issues to tracker` },
|
||||
{ label: "Skip", description: "Complete discovery without exporting" }
|
||||
] : [
|
||||
{ label: "Skip (Recommended)", description: "No significant issues found - complete discovery" },
|
||||
{ label: "Open Dashboard", description: "Review all findings in ccw view" },
|
||||
{ label: "Export to Issues", description: `Export ${issues.length} issues anyway` }
|
||||
]
|
||||
}]
|
||||
});
|
||||
|
||||
// Handle response
|
||||
if (response === "Export to Issues") {
|
||||
// Append to issues.jsonl
|
||||
await appendJsonl('.workflow/issues/issues.jsonl', issues);
|
||||
console.log(`Exported ${issues.length} issues. Run /issue:plan to continue.`);
|
||||
} else if (response === "Open Dashboard") {
|
||||
console.log('Run `ccw view` and navigate to Issues > Discovery to manage findings.');
|
||||
}
|
||||
```
|
||||
|
||||
### Output File Structure
|
||||
|
||||
```
|
||||
.workflow/issues/discoveries/
|
||||
├── index.json # Discovery session index
|
||||
└── {discovery-id}/
|
||||
├── discovery-state.json # Unified state (merged state+progress)
|
||||
├── perspectives/
|
||||
│ └── {perspective}.json # Per-perspective findings
|
||||
├── external-research.json # Exa research results (if enabled)
|
||||
├── discovery-issues.jsonl # Generated candidate issues
|
||||
└── summary.md # Single summary (from agent returns)
|
||||
```
|
||||
|
||||
### Schema References
|
||||
|
||||
**External Schema Files** (agent MUST read and follow exactly):
|
||||
|
||||
| Schema | Path | Purpose |
|
||||
|--------|------|---------|
|
||||
| **Discovery State** | `~/.claude/workflows/cli-templates/schemas/discovery-state-schema.json` | Session state machine |
|
||||
| **Discovery Finding** | `~/.claude/workflows/cli-templates/schemas/discovery-finding-schema.json` | Perspective analysis results |
|
||||
|
||||
### Agent Invocation Template
|
||||
|
||||
**Perspective Analysis Agent**:
|
||||
|
||||
```javascript
|
||||
Task({
|
||||
subagent_type: "cli-explore-agent",
|
||||
run_in_background: false,
|
||||
description: `Discover ${perspective} issues`,
|
||||
prompt: `
|
||||
## Task Objective
|
||||
Discover potential ${perspective} issues in specified module files.
|
||||
|
||||
## Discovery Context
|
||||
- Discovery ID: ${discoveryId}
|
||||
- Perspective: ${perspective}
|
||||
- Target Pattern: ${targetPattern}
|
||||
- Resolved Files: ${resolvedFiles.length} files
|
||||
- Output Directory: ${outputDir}
|
||||
|
||||
## MANDATORY FIRST STEPS
|
||||
1. Read discovery state: ${outputDir}/discovery-state.json
|
||||
2. Read schema: ~/.claude/workflows/cli-templates/schemas/discovery-finding-schema.json
|
||||
3. Analyze target files for ${perspective} concerns
|
||||
|
||||
## Output Requirements
|
||||
|
||||
**1. Write JSON file**: ${outputDir}/perspectives/${perspective}.json
|
||||
- Follow discovery-finding-schema.json exactly
|
||||
- Each finding: id, title, priority, category, description, file, line, snippet, suggested_issue, confidence
|
||||
|
||||
**2. Return summary** (DO NOT write report file):
|
||||
- Return a brief text summary of findings
|
||||
- Include: total findings, priority breakdown, key issues
|
||||
- This summary will be used by orchestrator for final report
|
||||
|
||||
## Perspective-Specific Guidance
|
||||
${getPerspectiveGuidance(perspective)}
|
||||
|
||||
## Success Criteria
|
||||
- [ ] JSON written to ${outputDir}/perspectives/${perspective}.json
|
||||
- [ ] Summary returned with findings count and key issues
|
||||
- [ ] Each finding includes actionable suggested_issue
|
||||
- [ ] Priority uses lowercase enum: critical/high/medium/low
|
||||
`
|
||||
})
|
||||
```
|
||||
|
||||
**Exa Research Agent** (for security and best-practices):
|
||||
|
||||
```javascript
|
||||
Task({
|
||||
subagent_type: "cli-explore-agent",
|
||||
run_in_background: false,
|
||||
description: `External research for ${perspective} via Exa`,
|
||||
prompt: `
|
||||
## Task Objective
|
||||
Research industry best practices for ${perspective} using Exa search
|
||||
|
||||
## Research Steps
|
||||
1. Read project tech stack: .workflow/project-tech.json
|
||||
2. Use Exa to search for best practices
|
||||
3. Synthesize findings relevant to this project
|
||||
|
||||
## Output Requirements
|
||||
|
||||
**1. Write JSON file**: ${outputDir}/external-research.json
|
||||
- Include sources, key_findings, gap_analysis, recommendations
|
||||
|
||||
**2. Return summary** (DO NOT write report file):
|
||||
- Brief summary of external research findings
|
||||
- Key recommendations for the project
|
||||
|
||||
## Success Criteria
|
||||
- [ ] JSON written to ${outputDir}/external-research.json
|
||||
- [ ] Summary returned with key recommendations
|
||||
- [ ] Findings are relevant to project's tech stack
|
||||
`
|
||||
})
|
||||
```
|
||||
|
||||
### Perspective Guidance Reference
|
||||
|
||||
```javascript
|
||||
function getPerspectiveGuidance(perspective) {
|
||||
const guidance = {
|
||||
bug: `
|
||||
Focus: Null checks, edge cases, resource leaks, race conditions, boundary conditions, exception handling
|
||||
Priority: Critical=data corruption/crash, High=malfunction, Medium=edge case issues, Low=minor
|
||||
`,
|
||||
ux: `
|
||||
Focus: Error messages, loading states, feedback, accessibility, interaction patterns, form validation
|
||||
Priority: Critical=inaccessible, High=confusing, Medium=inconsistent, Low=cosmetic
|
||||
`,
|
||||
test: `
|
||||
Focus: Missing unit tests, edge case coverage, integration gaps, assertion quality, test isolation
|
||||
Priority: Critical=no security tests, High=no core logic tests, Medium=weak coverage, Low=minor gaps
|
||||
`,
|
||||
quality: `
|
||||
Focus: Complexity, duplication, naming, documentation, code smells, readability
|
||||
Priority: Critical=unmaintainable, High=significant issues, Medium=naming/docs, Low=minor refactoring
|
||||
`,
|
||||
security: `
|
||||
Focus: Input validation, auth/authz, injection, XSS/CSRF, data exposure, access control
|
||||
Priority: Critical=auth bypass/injection, High=missing authz, Medium=weak validation, Low=headers
|
||||
`,
|
||||
performance: `
|
||||
Focus: N+1 queries, memory leaks, caching, algorithm efficiency, blocking operations
|
||||
Priority: Critical=memory leaks, High=N+1/inefficient, Medium=missing cache, Low=minor optimization
|
||||
`,
|
||||
maintainability: `
|
||||
Focus: Coupling, interface design, tech debt, extensibility, module boundaries, configuration
|
||||
Priority: Critical=unrelated code changes, High=unclear boundaries, Medium=coupling, Low=refactoring
|
||||
`,
|
||||
'best-practices': `
|
||||
Focus: Framework conventions, language patterns, anti-patterns, deprecated APIs, coding standards
|
||||
Priority: Critical=anti-patterns causing bugs, High=convention violations, Medium=style, Low=cosmetic
|
||||
`
|
||||
};
|
||||
return guidance[perspective] || 'General code discovery analysis';
|
||||
}
|
||||
```
|
||||
|
||||
## Dashboard Integration
|
||||
|
||||
### Viewing Discoveries
|
||||
|
||||
Open CCW dashboard to manage discoveries:
|
||||
|
||||
```bash
|
||||
ccw view
|
||||
```
|
||||
|
||||
Navigate to **Issues > Discovery** to:
|
||||
- View all discovery sessions
|
||||
- Filter findings by perspective and priority
|
||||
- Preview finding details
|
||||
- Select and export findings as issues
|
||||
|
||||
### Exporting to Issues
|
||||
|
||||
From the dashboard, select findings and click "Export as Issues" to:
|
||||
1. Convert discoveries to standard issue format
|
||||
2. Append to `.workflow/issues/issues.jsonl`
|
||||
3. Set status to `registered`
|
||||
4. Continue with `/issue:plan` workflow
|
||||
|
||||
## Related Commands
|
||||
|
||||
```bash
|
||||
# After discovery, plan solutions for exported issues
|
||||
/issue:plan DSC-001,DSC-002,DSC-003
|
||||
|
||||
# Or use interactive management
|
||||
/issue:manage
|
||||
```
|
||||
|
||||
## Best Practices
|
||||
|
||||
1. **Start Focused**: Begin with specific modules rather than entire codebase
|
||||
2. **Use Quick Scan First**: Start with bug, test, quality for fast results
|
||||
3. **Review Before Export**: Not all discoveries warrant issues - use dashboard to filter
|
||||
4. **Combine Perspectives**: Run related perspectives together (e.g., security + bug)
|
||||
5. **Enable Exa for New Tech**: When using unfamiliar frameworks, enable external research
|
||||
580
.claude/commands/issue/execute.md
Normal file
580
.claude/commands/issue/execute.md
Normal file
@@ -0,0 +1,580 @@
|
||||
---
|
||||
name: execute
|
||||
description: Execute queue with DAG-based parallel orchestration (one commit per solution)
|
||||
argument-hint: "[-y|--yes] --queue <queue-id> [--worktree [<existing-path>]]"
|
||||
allowed-tools: TodoWrite(*), Bash(*), Read(*), AskUserQuestion(*)
|
||||
---
|
||||
|
||||
## Auto Mode
|
||||
|
||||
When `--yes` or `-y`: Auto-confirm execution, use recommended settings.
|
||||
|
||||
# Issue Execute Command (/issue:execute)
|
||||
|
||||
## Overview
|
||||
|
||||
Minimal orchestrator that dispatches **solution IDs** to executors. Each executor receives a complete solution with all its tasks.
|
||||
|
||||
**Design Principles:**
|
||||
- `queue dag` → returns parallel batches with solution IDs (S-1, S-2, ...)
|
||||
- `detail <id>` → READ-ONLY solution fetch (returns full solution with all tasks)
|
||||
- `done <id>` → update solution completion status
|
||||
- No race conditions: status changes only via `done`
|
||||
- **Executor handles all tasks within a solution sequentially**
|
||||
- **Single worktree for entire queue**: One worktree isolates ALL queue execution from main workspace
|
||||
|
||||
## Queue ID Requirement (MANDATORY)
|
||||
|
||||
**Queue ID is REQUIRED.** You MUST specify which queue to execute via `--queue <queue-id>`.
|
||||
|
||||
### If Queue ID Not Provided
|
||||
|
||||
When `--queue` parameter is missing, you MUST:
|
||||
|
||||
1. **List available queues** by running:
|
||||
```javascript
|
||||
const result = Bash('ccw issue queue list --brief --json');
|
||||
const index = JSON.parse(result);
|
||||
```
|
||||
|
||||
2. **Display available queues** to user:
|
||||
```
|
||||
Available Queues:
|
||||
ID Status Progress Issues
|
||||
-----------------------------------------------------------
|
||||
→ QUE-20251215-001 active 3/10 ISS-001, ISS-002
|
||||
QUE-20251210-002 active 0/5 ISS-003
|
||||
QUE-20251205-003 completed 8/8 ISS-004
|
||||
```
|
||||
|
||||
3. **Stop and ask user** to specify which queue to execute:
|
||||
```javascript
|
||||
AskUserQuestion({
|
||||
questions: [{
|
||||
question: "Which queue would you like to execute?",
|
||||
header: "Queue",
|
||||
multiSelect: false,
|
||||
options: index.queues
|
||||
.filter(q => q.status === 'active')
|
||||
.map(q => ({
|
||||
label: q.id,
|
||||
description: `${q.status}, ${q.completed_solutions || 0}/${q.total_solutions || 0} completed, Issues: ${q.issue_ids.join(', ')}`
|
||||
}))
|
||||
}]
|
||||
})
|
||||
```
|
||||
|
||||
4. **After user selection**, continue execution with the selected queue ID.
|
||||
|
||||
**DO NOT auto-select queues.** Explicit user confirmation is required to prevent accidental execution of wrong queue.
|
||||
|
||||
## Usage
|
||||
|
||||
```bash
|
||||
/issue:execute --queue QUE-xxx # Execute specific queue (REQUIRED)
|
||||
/issue:execute --queue QUE-xxx --worktree # Execute in isolated worktree
|
||||
/issue:execute --queue QUE-xxx --worktree /path/to/existing/worktree # Resume
|
||||
```
|
||||
|
||||
**Parallelism**: Determined automatically by task dependency DAG (no manual control)
|
||||
**Executor & Dry-run**: Selected via interactive prompt (AskUserQuestion)
|
||||
**Worktree**: Creates ONE worktree for the entire queue execution (not per-solution)
|
||||
|
||||
**⭐ Recommended Executor**: **Codex** - Best for long-running autonomous work (2hr timeout), supports background execution and full write access
|
||||
|
||||
**Worktree Options**:
|
||||
- `--worktree` - Create a new worktree with timestamp-based name
|
||||
- `--worktree <existing-path>` - Resume in an existing worktree (for recovery/continuation)
|
||||
|
||||
**Resume**: Use `git worktree list` to find existing worktrees from interrupted executions
|
||||
|
||||
## Execution Flow
|
||||
|
||||
```
|
||||
Phase 0: Validate Queue ID (REQUIRED)
|
||||
├─ If --queue provided → use specified queue
|
||||
├─ If --queue missing → list queues, prompt user to select
|
||||
└─ Store QUEUE_ID for all subsequent commands
|
||||
|
||||
Phase 0.5 (if --worktree): Setup Queue Worktree
|
||||
├─ Create ONE worktree for entire queue: .ccw/worktrees/queue-<timestamp>
|
||||
├─ All subsequent execution happens in this worktree
|
||||
└─ Main workspace remains clean and untouched
|
||||
|
||||
Phase 1: Get DAG & User Selection
|
||||
├─ ccw issue queue dag --queue ${QUEUE_ID} → { parallel_batches: [["S-1","S-2"], ["S-3"]] }
|
||||
└─ AskUserQuestion → executor type (codex|gemini|agent), dry-run mode, worktree mode
|
||||
|
||||
Phase 2: Dispatch Parallel Batch (DAG-driven)
|
||||
├─ Parallelism determined by DAG (no manual limit)
|
||||
├─ All executors work in the SAME worktree (or main if no worktree)
|
||||
├─ For each solution ID in batch (parallel - all at once):
|
||||
│ ├─ Executor calls: ccw issue detail <id> (READ-ONLY)
|
||||
│ ├─ Executor gets FULL SOLUTION with all tasks
|
||||
│ ├─ Executor implements all tasks sequentially (T1 → T2 → T3)
|
||||
│ ├─ Executor tests + verifies each task
|
||||
│ ├─ Executor commits ONCE per solution (with formatted summary)
|
||||
│ └─ Executor calls: ccw issue done <id>
|
||||
└─ Wait for batch completion
|
||||
|
||||
Phase 3: Next Batch (repeat Phase 2)
|
||||
└─ ccw issue queue dag → check for newly-ready solutions
|
||||
|
||||
Phase 4 (if --worktree): Worktree Completion
|
||||
├─ All batches complete → prompt for merge strategy
|
||||
└─ Options: Create PR / Merge to main / Keep branch
|
||||
```
|
||||
|
||||
## Implementation
|
||||
|
||||
### Phase 0: Validate Queue ID
|
||||
|
||||
```javascript
|
||||
// Check if --queue was provided
|
||||
let QUEUE_ID = args.queue;
|
||||
|
||||
if (!QUEUE_ID) {
|
||||
// List available queues
|
||||
const listResult = Bash('ccw issue queue list --brief --json').trim();
|
||||
const index = JSON.parse(listResult);
|
||||
|
||||
if (index.queues.length === 0) {
|
||||
console.log('No queues found. Use /issue:queue to create one first.');
|
||||
return;
|
||||
}
|
||||
|
||||
// Filter active queues only
|
||||
const activeQueues = index.queues.filter(q => q.status === 'active');
|
||||
|
||||
if (activeQueues.length === 0) {
|
||||
console.log('No active queues found.');
|
||||
console.log('Available queues:', index.queues.map(q => `${q.id} (${q.status})`).join(', '));
|
||||
return;
|
||||
}
|
||||
|
||||
// Display and prompt user
|
||||
console.log('\nAvailable Queues:');
|
||||
console.log('ID'.padEnd(22) + 'Status'.padEnd(12) + 'Progress'.padEnd(12) + 'Issues');
|
||||
console.log('-'.repeat(70));
|
||||
for (const q of index.queues) {
|
||||
const marker = q.id === index.active_queue_id ? '→ ' : ' ';
|
||||
console.log(marker + q.id.padEnd(20) + q.status.padEnd(12) +
|
||||
`${q.completed_solutions || 0}/${q.total_solutions || 0}`.padEnd(12) +
|
||||
q.issue_ids.join(', '));
|
||||
}
|
||||
|
||||
const answer = AskUserQuestion({
|
||||
questions: [{
|
||||
question: "Which queue would you like to execute?",
|
||||
header: "Queue",
|
||||
multiSelect: false,
|
||||
options: activeQueues.map(q => ({
|
||||
label: q.id,
|
||||
description: `${q.completed_solutions || 0}/${q.total_solutions || 0} completed, Issues: ${q.issue_ids.join(', ')}`
|
||||
}))
|
||||
}]
|
||||
});
|
||||
|
||||
QUEUE_ID = answer['Queue'];
|
||||
}
|
||||
|
||||
console.log(`\n## Executing Queue: ${QUEUE_ID}\n`);
|
||||
```
|
||||
|
||||
### Phase 1: Get DAG & User Selection
|
||||
|
||||
```javascript
|
||||
// Get dependency graph and parallel batches (QUEUE_ID required)
|
||||
const dagJson = Bash(`ccw issue queue dag --queue ${QUEUE_ID}`).trim();
|
||||
const dag = JSON.parse(dagJson);
|
||||
|
||||
if (dag.error || dag.ready_count === 0) {
|
||||
console.log(dag.error || 'No solutions ready for execution');
|
||||
console.log('Use /issue:queue to form a queue first');
|
||||
return;
|
||||
}
|
||||
|
||||
console.log(`
|
||||
## Queue DAG (Solution-Level)
|
||||
|
||||
- Total Solutions: ${dag.total}
|
||||
- Ready: ${dag.ready_count}
|
||||
- Completed: ${dag.completed_count}
|
||||
- Parallel in batch 1: ${dag.parallel_batches[0]?.length || 0}
|
||||
`);
|
||||
|
||||
// Interactive selection via AskUserQuestion
|
||||
const answer = AskUserQuestion({
|
||||
questions: [
|
||||
{
|
||||
question: 'Select executor type:',
|
||||
header: 'Executor',
|
||||
multiSelect: false,
|
||||
options: [
|
||||
{ label: 'Codex (Recommended)', description: 'Autonomous coding with full write access' },
|
||||
{ label: 'Gemini', description: 'Large context analysis and implementation' },
|
||||
{ label: 'Agent', description: 'Claude Code sub-agent for complex tasks' }
|
||||
]
|
||||
},
|
||||
{
|
||||
question: 'Execution mode:',
|
||||
header: 'Mode',
|
||||
multiSelect: false,
|
||||
options: [
|
||||
{ label: 'Execute (Recommended)', description: 'Run all ready solutions' },
|
||||
{ label: 'Dry-run', description: 'Show DAG and batches without executing' }
|
||||
]
|
||||
},
|
||||
{
|
||||
question: 'Use git worktree for queue isolation?',
|
||||
header: 'Worktree',
|
||||
multiSelect: false,
|
||||
options: [
|
||||
{ label: 'Yes (Recommended)', description: 'Create ONE worktree for entire queue - main stays clean' },
|
||||
{ label: 'No', description: 'Work directly in current directory' }
|
||||
]
|
||||
}
|
||||
]
|
||||
});
|
||||
|
||||
const executor = answer['Executor'].toLowerCase().split(' ')[0]; // codex|gemini|agent
|
||||
const isDryRun = answer['Mode'].includes('Dry-run');
|
||||
const useWorktree = answer['Worktree'].includes('Yes');
|
||||
|
||||
// Dry run mode
|
||||
if (isDryRun) {
|
||||
console.log('### Parallel Batches (Dry-run):\n');
|
||||
dag.parallel_batches.forEach((batch, i) => {
|
||||
console.log(`Batch ${i + 1}: ${batch.join(', ')}`);
|
||||
});
|
||||
return;
|
||||
}
|
||||
```
|
||||
|
||||
### Phase 0 & 2: Setup Queue Worktree & Dispatch
|
||||
|
||||
```javascript
|
||||
// Parallelism determined by DAG - no manual limit
|
||||
// All solutions in same batch have NO file conflicts and can run in parallel
|
||||
const batch = dag.parallel_batches[0] || [];
|
||||
|
||||
// Initialize TodoWrite
|
||||
TodoWrite({
|
||||
todos: batch.map(id => ({
|
||||
content: `Execute solution ${id}`,
|
||||
status: 'pending',
|
||||
activeForm: `Executing solution ${id}`
|
||||
}))
|
||||
});
|
||||
|
||||
console.log(`\n### Executing Solutions (DAG batch 1): ${batch.join(', ')}`);
|
||||
|
||||
// Parse existing worktree path from args if provided
|
||||
// Example: --worktree /path/to/existing/worktree
|
||||
const existingWorktree = args.worktree && typeof args.worktree === 'string' ? args.worktree : null;
|
||||
|
||||
// Setup ONE worktree for entire queue (not per-solution)
|
||||
let worktreePath = null;
|
||||
let worktreeBranch = null;
|
||||
|
||||
if (useWorktree) {
|
||||
const repoRoot = Bash('git rev-parse --show-toplevel').trim();
|
||||
const worktreeBase = `${repoRoot}/.ccw/worktrees`;
|
||||
Bash(`mkdir -p "${worktreeBase}"`);
|
||||
Bash('git worktree prune'); // Cleanup stale worktrees
|
||||
|
||||
if (existingWorktree) {
|
||||
// Resume mode: Use existing worktree
|
||||
worktreePath = existingWorktree;
|
||||
worktreeBranch = Bash(`git -C "${worktreePath}" branch --show-current`).trim();
|
||||
console.log(`Resuming in existing worktree: ${worktreePath} (branch: ${worktreeBranch})`);
|
||||
} else {
|
||||
// Create mode: ONE worktree for the entire queue
|
||||
const timestamp = new Date().toISOString().replace(/[-:T]/g, '').slice(0, 14);
|
||||
worktreeBranch = `queue-exec-${dag.queue_id || timestamp}`;
|
||||
worktreePath = `${worktreeBase}/${worktreeBranch}`;
|
||||
Bash(`git worktree add "${worktreePath}" -b "${worktreeBranch}"`);
|
||||
console.log(`Created queue worktree: ${worktreePath}`);
|
||||
}
|
||||
}
|
||||
|
||||
// Launch ALL solutions in batch in parallel (DAG guarantees no conflicts)
|
||||
// All executors work in the SAME worktree (or main if no worktree)
|
||||
const executions = batch.map(solutionId => {
|
||||
updateTodo(solutionId, 'in_progress');
|
||||
return dispatchExecutor(solutionId, executor, worktreePath);
|
||||
});
|
||||
|
||||
await Promise.all(executions);
|
||||
batch.forEach(id => updateTodo(id, 'completed'));
|
||||
```
|
||||
|
||||
### Executor Dispatch
|
||||
|
||||
```javascript
|
||||
// worktreePath: path to shared worktree (null if not using worktree)
|
||||
function dispatchExecutor(solutionId, executorType, worktreePath = null) {
|
||||
// If worktree is provided, executor works in that directory
|
||||
// No per-solution worktree creation - ONE worktree for entire queue
|
||||
|
||||
// Pre-defined values (replaced at dispatch time, NOT by executor)
|
||||
const SOLUTION_ID = solutionId;
|
||||
const WORK_DIR = worktreePath || null;
|
||||
|
||||
// Build prompt without markdown code blocks to avoid escaping issues
|
||||
const prompt = `
|
||||
## Execute Solution: ${SOLUTION_ID}
|
||||
${WORK_DIR ? `Working Directory: ${WORK_DIR}` : ''}
|
||||
|
||||
### Step 1: Get Solution Details
|
||||
Run this command to get the full solution with all tasks:
|
||||
ccw issue detail ${SOLUTION_ID}
|
||||
|
||||
### Step 2: Execute All Tasks Sequentially
|
||||
The detail command returns a FULL SOLUTION with all tasks.
|
||||
Execute each task in order (T1 → T2 → T3 → ...):
|
||||
|
||||
For each task:
|
||||
- Follow task.implementation steps
|
||||
- Run task.test commands
|
||||
- Verify task.acceptance criteria
|
||||
- Do NOT commit after each task
|
||||
|
||||
### Step 3: Commit Solution (Once)
|
||||
After ALL tasks pass, commit once with formatted summary.
|
||||
|
||||
Command:
|
||||
git add -A
|
||||
git commit -m "<type>(<scope>): <description>
|
||||
|
||||
Solution: ${SOLUTION_ID}
|
||||
Tasks completed: <list task IDs>
|
||||
|
||||
Changes:
|
||||
- <file1>: <what changed>
|
||||
- <file2>: <what changed>
|
||||
|
||||
Verified: all tests passed"
|
||||
|
||||
Replace <type> with: feat|fix|refactor|docs|test
|
||||
Replace <scope> with: affected module name
|
||||
Replace <description> with: brief summary from solution
|
||||
|
||||
### Step 4: Report Completion
|
||||
On success, run:
|
||||
ccw issue done ${SOLUTION_ID} --result '{"summary": "<brief>", "files_modified": ["<file1>", "<file2>"], "commit": {"hash": "<hash>", "type": "<type>"}, "tasks_completed": <N>}'
|
||||
|
||||
On failure, run:
|
||||
ccw issue done ${SOLUTION_ID} --fail --reason '{"task_id": "<TX>", "error_type": "<test_failure|build_error|other>", "message": "<error details>"}'
|
||||
|
||||
### Important Notes
|
||||
- Do NOT cleanup worktree - it is shared by all solutions in the queue
|
||||
- Replace all <placeholder> values with actual values from your execution
|
||||
`;
|
||||
|
||||
// For CLI tools, pass --cd to set working directory
|
||||
const cdOption = worktreePath ? ` --cd "${worktreePath}"` : '';
|
||||
|
||||
if (executorType === 'codex') {
|
||||
return Bash(
|
||||
`ccw cli -p "${escapePrompt(prompt)}" --tool codex --mode write --id exec-${solutionId}${cdOption}`,
|
||||
{ timeout: 7200000, run_in_background: true } // 2hr for full solution
|
||||
);
|
||||
} else if (executorType === 'gemini') {
|
||||
return Bash(
|
||||
`ccw cli -p "${escapePrompt(prompt)}" --tool gemini --mode write --id exec-${solutionId}${cdOption}`,
|
||||
{ timeout: 3600000, run_in_background: true }
|
||||
);
|
||||
} else {
|
||||
return Task({
|
||||
subagent_type: 'code-developer',
|
||||
run_in_background: false,
|
||||
description: `Execute solution ${solutionId}`,
|
||||
prompt: worktreePath ? `Working directory: ${worktreePath}\n\n${prompt}` : prompt
|
||||
});
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### Phase 3: Check Next Batch
|
||||
|
||||
```javascript
|
||||
// Refresh DAG after batch completes (use same QUEUE_ID)
|
||||
const refreshedDag = JSON.parse(Bash(`ccw issue queue dag --queue ${QUEUE_ID}`).trim());
|
||||
|
||||
console.log(`
|
||||
## Batch Complete
|
||||
|
||||
- Solutions Completed: ${refreshedDag.completed_count}/${refreshedDag.total}
|
||||
- Next ready: ${refreshedDag.ready_count}
|
||||
`);
|
||||
|
||||
if (refreshedDag.ready_count > 0) {
|
||||
console.log(`Run \`/issue:execute --queue ${QUEUE_ID}\` again for next batch.`);
|
||||
// Note: If resuming, pass existing worktree path:
|
||||
// /issue:execute --queue ${QUEUE_ID} --worktree <worktreePath>
|
||||
}
|
||||
```
|
||||
|
||||
### Phase 4: Worktree Completion (after ALL batches)
|
||||
|
||||
```javascript
|
||||
// Only run when ALL solutions completed AND using worktree
|
||||
if (useWorktree && refreshedDag.ready_count === 0 && refreshedDag.completed_count === refreshedDag.total) {
|
||||
console.log('\n## All Solutions Completed - Worktree Cleanup');
|
||||
|
||||
const answer = AskUserQuestion({
|
||||
questions: [{
|
||||
question: `Queue complete. What to do with worktree branch "${worktreeBranch}"?`,
|
||||
header: 'Merge',
|
||||
multiSelect: false,
|
||||
options: [
|
||||
{ label: 'Create PR (Recommended)', description: 'Push branch and create pull request' },
|
||||
{ label: 'Merge to main', description: 'Merge all commits and cleanup worktree' },
|
||||
{ label: 'Keep branch', description: 'Cleanup worktree, keep branch for manual handling' }
|
||||
]
|
||||
}]
|
||||
});
|
||||
|
||||
const repoRoot = Bash('git rev-parse --show-toplevel').trim();
|
||||
|
||||
if (answer['Merge'].includes('Create PR')) {
|
||||
Bash(`git -C "${worktreePath}" push -u origin "${worktreeBranch}"`);
|
||||
Bash(`gh pr create --title "Queue ${dag.queue_id}" --body "Issue queue execution - all solutions completed" --head "${worktreeBranch}"`);
|
||||
Bash(`git worktree remove "${worktreePath}"`);
|
||||
console.log(`PR created for branch: ${worktreeBranch}`);
|
||||
} else if (answer['Merge'].includes('Merge to main')) {
|
||||
// Check main is clean
|
||||
const mainDirty = Bash('git status --porcelain').trim();
|
||||
if (mainDirty) {
|
||||
console.log('Warning: Main has uncommitted changes. Falling back to PR.');
|
||||
Bash(`git -C "${worktreePath}" push -u origin "${worktreeBranch}"`);
|
||||
Bash(`gh pr create --title "Queue ${dag.queue_id}" --body "Issue queue execution (main had uncommitted changes)" --head "${worktreeBranch}"`);
|
||||
} else {
|
||||
Bash(`git merge --no-ff "${worktreeBranch}" -m "Merge queue ${dag.queue_id}"`);
|
||||
Bash(`git branch -d "${worktreeBranch}"`);
|
||||
}
|
||||
Bash(`git worktree remove "${worktreePath}"`);
|
||||
} else {
|
||||
Bash(`git worktree remove "${worktreePath}"`);
|
||||
console.log(`Branch ${worktreeBranch} kept for manual handling`);
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## Parallel Execution Model
|
||||
|
||||
```
|
||||
┌─────────────────────────────────────────────────────────────────┐
|
||||
│ Orchestrator │
|
||||
├─────────────────────────────────────────────────────────────────┤
|
||||
│ 0. Validate QUEUE_ID (required, or prompt user to select) │
|
||||
│ │
|
||||
│ 0.5 (if --worktree) Create ONE worktree for entire queue │
|
||||
│ → .ccw/worktrees/queue-exec-<queue-id> │
|
||||
│ │
|
||||
│ 1. ccw issue queue dag --queue ${QUEUE_ID} │
|
||||
│ → { parallel_batches: [["S-1","S-2"], ["S-3"]] } │
|
||||
│ │
|
||||
│ 2. Dispatch batch 1 (parallel, SAME worktree): │
|
||||
│ ┌──────────────────────────────────────────────────────┐ │
|
||||
│ │ Shared Queue Worktree (or main) │ │
|
||||
│ │ ┌──────────────────┐ ┌──────────────────┐ │ │
|
||||
│ │ │ Executor 1 │ │ Executor 2 │ │ │
|
||||
│ │ │ detail S-1 │ │ detail S-2 │ │ │
|
||||
│ │ │ [T1→T2→T3] │ │ [T1→T2] │ │ │
|
||||
│ │ │ commit S-1 │ │ commit S-2 │ │ │
|
||||
│ │ │ done S-1 │ │ done S-2 │ │ │
|
||||
│ │ └──────────────────┘ └──────────────────┘ │ │
|
||||
│ └──────────────────────────────────────────────────────┘ │
|
||||
│ │
|
||||
│ 3. ccw issue queue dag (refresh) │
|
||||
│ → S-3 now ready → dispatch batch 2 (same worktree) │
|
||||
│ │
|
||||
│ 4. (if --worktree) ALL batches complete → cleanup worktree │
|
||||
│ → Prompt: Create PR / Merge to main / Keep branch │
|
||||
└─────────────────────────────────────────────────────────────────┘
|
||||
```
|
||||
|
||||
**Why this works for parallel:**
|
||||
- **ONE worktree for entire queue** → all solutions share same isolated workspace
|
||||
- `detail <id>` is READ-ONLY → no race conditions
|
||||
- Each executor handles **all tasks within a solution** sequentially
|
||||
- **One commit per solution** with formatted summary (not per-task)
|
||||
- `done <id>` updates only its own solution status
|
||||
- `queue dag` recalculates ready solutions after each batch
|
||||
- Solutions in same batch have NO file conflicts (DAG guarantees)
|
||||
- **Main workspace stays clean** until merge/PR decision
|
||||
|
||||
## CLI Endpoint Contract
|
||||
|
||||
### `ccw issue queue list --brief --json`
|
||||
Returns queue index for selection (used when --queue not provided):
|
||||
```json
|
||||
{
|
||||
"active_queue_id": "QUE-20251215-001",
|
||||
"queues": [
|
||||
{ "id": "QUE-20251215-001", "status": "active", "issue_ids": ["ISS-001"], "total_solutions": 5, "completed_solutions": 2 }
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
### `ccw issue queue dag --queue <queue-id>`
|
||||
Returns dependency graph with parallel batches (solution-level, **--queue required**):
|
||||
```json
|
||||
{
|
||||
"queue_id": "QUE-...",
|
||||
"total": 3,
|
||||
"ready_count": 2,
|
||||
"completed_count": 0,
|
||||
"nodes": [
|
||||
{ "id": "S-1", "issue_id": "ISS-xxx", "status": "pending", "ready": true, "task_count": 3 },
|
||||
{ "id": "S-2", "issue_id": "ISS-yyy", "status": "pending", "ready": true, "task_count": 2 },
|
||||
{ "id": "S-3", "issue_id": "ISS-zzz", "status": "pending", "ready": false, "depends_on": ["S-1"] }
|
||||
],
|
||||
"parallel_batches": [["S-1", "S-2"], ["S-3"]]
|
||||
}
|
||||
```
|
||||
|
||||
### `ccw issue detail <item_id>`
|
||||
Returns FULL SOLUTION with all tasks (READ-ONLY):
|
||||
```json
|
||||
{
|
||||
"item_id": "S-1",
|
||||
"issue_id": "ISS-xxx",
|
||||
"solution_id": "SOL-xxx",
|
||||
"status": "pending",
|
||||
"solution": {
|
||||
"id": "SOL-xxx",
|
||||
"approach": "...",
|
||||
"tasks": [
|
||||
{ "id": "T1", "title": "...", "implementation": [...], "test": {...} },
|
||||
{ "id": "T2", "title": "...", "implementation": [...], "test": {...} },
|
||||
{ "id": "T3", "title": "...", "implementation": [...], "test": {...} }
|
||||
],
|
||||
"exploration_context": { "relevant_files": [...] }
|
||||
},
|
||||
"execution_hints": { "executor": "codex", "estimated_minutes": 180 }
|
||||
}
|
||||
```
|
||||
|
||||
### `ccw issue done <item_id>`
|
||||
Marks solution completed/failed, updates queue state, checks for queue completion.
|
||||
|
||||
## Error Handling
|
||||
|
||||
| Error | Resolution |
|
||||
|-------|------------|
|
||||
| No queue | Run /issue:queue first |
|
||||
| No ready solutions | Dependencies blocked, check DAG |
|
||||
| Executor timeout | Solution not marked done, can retry |
|
||||
| Solution failure | Use `ccw issue retry` to reset |
|
||||
| Partial task failure | Executor reports which task failed via `done --fail` |
|
||||
|
||||
## Related Commands
|
||||
|
||||
- `/issue:plan` - Plan issues with solutions
|
||||
- `/issue:queue` - Form execution queue
|
||||
- `ccw issue queue dag` - View dependency graph
|
||||
- `ccw issue detail <id>` - View task details
|
||||
- `ccw issue retry` - Reset failed tasks
|
||||
382
.claude/commands/issue/from-brainstorm.md
Normal file
382
.claude/commands/issue/from-brainstorm.md
Normal file
@@ -0,0 +1,382 @@
|
||||
---
|
||||
name: from-brainstorm
|
||||
description: Convert brainstorm session ideas into issue with executable solution for parallel-dev-cycle
|
||||
argument-hint: "SESSION=\"<session-id>\" [--idea=<index>] [--auto] [-y|--yes]"
|
||||
allowed-tools: TodoWrite(*), Bash(*), Read(*), Write(*), Glob(*), AskUserQuestion(*)
|
||||
---
|
||||
|
||||
## Auto Mode
|
||||
|
||||
When `--yes` or `-y`: Auto-select highest-scored idea, skip confirmations, create issue directly.
|
||||
|
||||
# Issue From-Brainstorm Command (/issue:from-brainstorm)
|
||||
|
||||
## Overview
|
||||
|
||||
Bridge command that converts **brainstorm-with-file** session output into executable **issue + solution** for parallel-dev-cycle consumption.
|
||||
|
||||
**Core workflow**: Load Session → Select Idea → Convert to Issue → Generate Solution → Bind & Ready
|
||||
|
||||
**Input sources**:
|
||||
- **synthesis.json** - Main brainstorm results with top_ideas
|
||||
- **perspectives.json** - Multi-CLI perspectives (creative/pragmatic/systematic)
|
||||
- **.brainstorming/** - Synthesis artifacts (clarifications, enhancements from role analyses)
|
||||
|
||||
**Output**:
|
||||
- **Issue** (ISS-YYYYMMDD-NNN) - Full context with clarifications
|
||||
- **Solution** (SOL-{issue-id}-{uid}) - Structured tasks for parallel-dev-cycle
|
||||
|
||||
## Quick Reference
|
||||
|
||||
```bash
|
||||
# Interactive mode - select idea, confirm before creation
|
||||
/issue:from-brainstorm SESSION="BS-rate-limiting-2025-01-28"
|
||||
|
||||
# Pre-select idea by index
|
||||
/issue:from-brainstorm SESSION="BS-auth-system-2025-01-28" --idea=0
|
||||
|
||||
# Auto mode - select highest scored, no confirmations
|
||||
/issue:from-brainstorm SESSION="BS-caching-2025-01-28" --auto -y
|
||||
```
|
||||
|
||||
## Arguments
|
||||
|
||||
| Argument | Required | Type | Default | Description |
|
||||
|----------|----------|------|---------|-------------|
|
||||
| SESSION | Yes | String | - | Session ID or path to `.workflow/.brainstorm/BS-xxx` |
|
||||
| --idea | No | Integer | - | Pre-select idea by index (0-based) |
|
||||
| --auto | No | Flag | false | Auto-select highest-scored idea |
|
||||
| -y, --yes | No | Flag | false | Skip all confirmations |
|
||||
|
||||
## Data Structures
|
||||
|
||||
### Issue Schema (Output)
|
||||
|
||||
```typescript
|
||||
interface Issue {
|
||||
id: string; // ISS-YYYYMMDD-NNN
|
||||
title: string; // From idea.title
|
||||
status: 'planned'; // Auto-set after solution binding
|
||||
priority: number; // 1-5 (derived from idea.score)
|
||||
context: string; // Full description with clarifications
|
||||
source: 'brainstorm';
|
||||
labels: string[]; // ['brainstorm', perspective, feasibility]
|
||||
|
||||
// Structured fields
|
||||
expected_behavior: string; // From key_strengths
|
||||
actual_behavior: string; // From main_challenges
|
||||
affected_components: string[]; // Extracted from description
|
||||
|
||||
_brainstorm_metadata: {
|
||||
session_id: string;
|
||||
idea_score: number;
|
||||
novelty: number;
|
||||
feasibility: string;
|
||||
clarifications_count: number;
|
||||
};
|
||||
}
|
||||
```
|
||||
|
||||
### Solution Schema (Output)
|
||||
|
||||
```typescript
|
||||
interface Solution {
|
||||
id: string; // SOL-{issue-id}-{4-char-uid}
|
||||
description: string; // idea.title
|
||||
approach: string; // idea.description
|
||||
tasks: Task[]; // Generated from idea.next_steps
|
||||
|
||||
analysis: {
|
||||
risk: 'low' | 'medium' | 'high';
|
||||
impact: 'low' | 'medium' | 'high';
|
||||
complexity: 'low' | 'medium' | 'high';
|
||||
};
|
||||
|
||||
is_bound: boolean; // true
|
||||
created_at: string;
|
||||
bound_at: string;
|
||||
}
|
||||
|
||||
interface Task {
|
||||
id: string; // T1, T2, T3...
|
||||
title: string; // Actionable task name
|
||||
scope: string; // design|implementation|testing|documentation
|
||||
action: string; // Implement|Design|Research|Test|Document
|
||||
description: string;
|
||||
|
||||
implementation: string[]; // Step-by-step guide
|
||||
acceptance: {
|
||||
criteria: string[]; // What defines success
|
||||
verification: string[]; // How to verify
|
||||
};
|
||||
|
||||
priority: number; // 1-5
|
||||
depends_on: string[]; // Task dependencies
|
||||
}
|
||||
```
|
||||
|
||||
## Execution Flow
|
||||
|
||||
```
|
||||
Phase 1: Session Loading
|
||||
├─ Validate session path
|
||||
├─ Load synthesis.json (required)
|
||||
├─ Load perspectives.json (optional - multi-CLI insights)
|
||||
├─ Load .brainstorming/** (optional - synthesis artifacts)
|
||||
└─ Validate top_ideas array exists
|
||||
|
||||
Phase 2: Idea Selection
|
||||
├─ Auto mode: Select highest scored idea
|
||||
├─ Pre-selected: Use --idea=N index
|
||||
└─ Interactive: Display table, ask user to select
|
||||
|
||||
Phase 3: Enrich Issue Context
|
||||
├─ Base: idea.description + key_strengths + main_challenges
|
||||
├─ Add: Relevant clarifications (Requirements/Architecture/Feasibility)
|
||||
├─ Add: Multi-perspective insights (creative/pragmatic/systematic)
|
||||
└─ Add: Session metadata (session_id, completion date, clarification count)
|
||||
|
||||
Phase 4: Create Issue
|
||||
├─ Generate issue data with enriched context
|
||||
├─ Calculate priority from idea.score (0-10 → 1-5)
|
||||
├─ Create via: ccw issue create (heredoc for JSON)
|
||||
└─ Returns: ISS-YYYYMMDD-NNN
|
||||
|
||||
Phase 5: Generate Solution Tasks
|
||||
├─ T1: Research & Validate (if main_challenges exist)
|
||||
├─ T2: Design & Specification (if key_strengths exist)
|
||||
├─ T3+: Implementation tasks (from idea.next_steps)
|
||||
└─ Each task includes: implementation steps + acceptance criteria
|
||||
|
||||
Phase 6: Bind Solution
|
||||
├─ Write solution to .workflow/issues/solutions/{issue-id}.jsonl
|
||||
├─ Bind via: ccw issue bind {issue-id} {solution-id}
|
||||
├─ Update issue status to 'planned'
|
||||
└─ Returns: SOL-{issue-id}-{uid}
|
||||
|
||||
Phase 7: Next Steps
|
||||
└─ Offer: Form queue | Convert another idea | View details | Done
|
||||
```
|
||||
|
||||
## Context Enrichment Logic
|
||||
|
||||
### Base Context (Always Included)
|
||||
|
||||
- **Description**: `idea.description`
|
||||
- **Why This Idea**: `idea.key_strengths[]`
|
||||
- **Challenges to Address**: `idea.main_challenges[]`
|
||||
- **Implementation Steps**: `idea.next_steps[]`
|
||||
|
||||
### Enhanced Context (If Available)
|
||||
|
||||
**From Synthesis Artifacts** (`.brainstorming/*/analysis*.md`):
|
||||
- Extract clarifications matching categories: Requirements, Architecture, Feasibility
|
||||
- Format: `**{Category}** ({role}): {question} → {answer}`
|
||||
- Limit: Top 3 most relevant
|
||||
|
||||
**From Perspectives** (`perspectives.json`):
|
||||
- **Creative**: First insight from `perspectives.creative.insights[0]`
|
||||
- **Pragmatic**: First blocker from `perspectives.pragmatic.blockers[0]`
|
||||
- **Systematic**: First pattern from `perspectives.systematic.patterns[0]`
|
||||
|
||||
**Session Metadata**:
|
||||
- Session ID, Topic, Completion Date
|
||||
- Clarifications count (if synthesis artifacts loaded)
|
||||
|
||||
## Task Generation Strategy
|
||||
|
||||
### Task 1: Research & Validation
|
||||
**Trigger**: `idea.main_challenges.length > 0`
|
||||
- **Title**: "Research & Validate Approach"
|
||||
- **Scope**: design
|
||||
- **Action**: Research
|
||||
- **Implementation**: Investigate blockers, review similar implementations, validate with team
|
||||
- **Acceptance**: Blockers documented, feasibility assessed, approach validated
|
||||
|
||||
### Task 2: Design & Specification
|
||||
**Trigger**: `idea.key_strengths.length > 0`
|
||||
- **Title**: "Design & Create Specification"
|
||||
- **Scope**: design
|
||||
- **Action**: Design
|
||||
- **Implementation**: Create design doc, define success criteria, plan phases
|
||||
- **Acceptance**: Design complete, metrics defined, plan outlined
|
||||
|
||||
### Task 3+: Implementation Tasks
|
||||
**Trigger**: `idea.next_steps[]`
|
||||
- **Title**: From `next_steps[i]` (max 60 chars)
|
||||
- **Scope**: Inferred from keywords (test→testing, api→backend, ui→frontend)
|
||||
- **Action**: Detected from verbs (implement, create, update, fix, test, document)
|
||||
- **Implementation**: Execute step + follow design + write tests
|
||||
- **Acceptance**: Step implemented + tests passing + code reviewed
|
||||
|
||||
### Fallback Task
|
||||
**Trigger**: No tasks generated from above
|
||||
- **Title**: `idea.title`
|
||||
- **Scope**: implementation
|
||||
- **Action**: Implement
|
||||
- **Generic implementation + acceptance criteria**
|
||||
|
||||
## Priority Calculation
|
||||
|
||||
### Issue Priority (1-5)
|
||||
```
|
||||
idea.score: 0-10
|
||||
priority = max(1, min(5, ceil((10 - score) / 2)))
|
||||
|
||||
Examples:
|
||||
score 9-10 → priority 1 (critical)
|
||||
score 7-8 → priority 2 (high)
|
||||
score 5-6 → priority 3 (medium)
|
||||
score 3-4 → priority 4 (low)
|
||||
score 0-2 → priority 5 (lowest)
|
||||
```
|
||||
|
||||
### Task Priority (1-5)
|
||||
- Research task: 1 (highest)
|
||||
- Design task: 2
|
||||
- Implementation tasks: 3 by default, decrement for later tasks
|
||||
- Testing/documentation: 4-5
|
||||
|
||||
### Complexity Analysis
|
||||
```
|
||||
risk: main_challenges.length > 2 ? 'high' : 'medium'
|
||||
impact: score >= 8 ? 'high' : score >= 6 ? 'medium' : 'low'
|
||||
complexity: main_challenges > 3 OR tasks > 5 ? 'high'
|
||||
tasks > 3 ? 'medium' : 'low'
|
||||
```
|
||||
|
||||
## CLI Integration
|
||||
|
||||
### Issue Creation
|
||||
```bash
|
||||
# Uses heredoc to avoid shell escaping
|
||||
ccw issue create << 'EOF'
|
||||
{
|
||||
"title": "...",
|
||||
"context": "...",
|
||||
"priority": 3,
|
||||
"source": "brainstorm",
|
||||
"labels": ["brainstorm", "creative", "feasibility-high"],
|
||||
...
|
||||
}
|
||||
EOF
|
||||
```
|
||||
|
||||
### Solution Binding
|
||||
```bash
|
||||
# Append solution to JSONL file
|
||||
echo '{"id":"SOL-xxx","tasks":[...]}' >> .workflow/issues/solutions/{issue-id}.jsonl
|
||||
|
||||
# Bind to issue
|
||||
ccw issue bind {issue-id} {solution-id}
|
||||
|
||||
# Update status
|
||||
ccw issue update {issue-id} --status planned
|
||||
```
|
||||
|
||||
## Error Handling
|
||||
|
||||
| Error | Message | Resolution |
|
||||
|-------|---------|------------|
|
||||
| Session not found | synthesis.json missing | Check session ID, list available sessions |
|
||||
| No ideas | top_ideas array empty | Complete brainstorm workflow first |
|
||||
| Invalid idea index | Index out of range | Check valid range 0 to N-1 |
|
||||
| Issue creation failed | ccw issue create error | Verify CLI endpoint working |
|
||||
| Solution binding failed | Bind error | Check issue exists, retry |
|
||||
|
||||
## Examples
|
||||
|
||||
### Interactive Mode
|
||||
|
||||
```bash
|
||||
/issue:from-brainstorm SESSION="BS-rate-limiting-2025-01-28"
|
||||
|
||||
# Output:
|
||||
# | # | Title | Score | Feasibility |
|
||||
# |---|-------|-------|-------------|
|
||||
# | 0 | Token Bucket Algorithm | 8.5 | High |
|
||||
# | 1 | Sliding Window Counter | 7.2 | Medium |
|
||||
# | 2 | Fixed Window | 6.1 | High |
|
||||
|
||||
# User selects: #0
|
||||
|
||||
# Result:
|
||||
# ✓ Created issue: ISS-20250128-001
|
||||
# ✓ Created solution: SOL-ISS-20250128-001-ab3d
|
||||
# ✓ Bound solution to issue
|
||||
# → Next: /issue:queue
|
||||
```
|
||||
|
||||
### Auto Mode
|
||||
|
||||
```bash
|
||||
/issue:from-brainstorm SESSION="BS-caching-2025-01-28" --auto
|
||||
|
||||
# Result:
|
||||
# Auto-selected: Redis Cache Layer (Score: 9.2/10)
|
||||
# ✓ Created issue: ISS-20250128-002
|
||||
# ✓ Solution with 4 tasks
|
||||
# → Status: planned
|
||||
```
|
||||
|
||||
## Integration Flow
|
||||
|
||||
```
|
||||
brainstorm-with-file
|
||||
│
|
||||
├─ synthesis.json
|
||||
├─ perspectives.json
|
||||
└─ .brainstorming/** (optional)
|
||||
│
|
||||
▼
|
||||
/issue:from-brainstorm ◄─── This command
|
||||
│
|
||||
├─ ISS-YYYYMMDD-NNN (enriched issue)
|
||||
└─ SOL-{issue-id}-{uid} (structured solution)
|
||||
│
|
||||
▼
|
||||
/issue:queue
|
||||
│
|
||||
▼
|
||||
/parallel-dev-cycle
|
||||
│
|
||||
▼
|
||||
RA → EP → CD → VAS
|
||||
```
|
||||
|
||||
## Session Files Reference
|
||||
|
||||
### Input Files
|
||||
|
||||
```
|
||||
.workflow/.brainstorm/BS-{slug}-{date}/
|
||||
├── synthesis.json # REQUIRED - Top ideas with scores
|
||||
├── perspectives.json # OPTIONAL - Multi-CLI insights
|
||||
├── brainstorm.md # Reference only
|
||||
└── .brainstorming/ # OPTIONAL - Synthesis artifacts
|
||||
├── system-architect/
|
||||
│ └── analysis.md # Contains clarifications + enhancements
|
||||
├── api-designer/
|
||||
│ └── analysis.md
|
||||
└── ...
|
||||
```
|
||||
|
||||
### Output Files
|
||||
|
||||
```
|
||||
.workflow/issues/
|
||||
├── solutions/
|
||||
│ └── ISS-YYYYMMDD-001.jsonl # Created solution (JSONL)
|
||||
└── (managed by ccw issue CLI)
|
||||
```
|
||||
|
||||
## Related Commands
|
||||
|
||||
- `/workflow:brainstorm-with-file` - Generate brainstorm sessions
|
||||
- `/workflow:brainstorm:synthesis` - Add clarifications to brainstorm
|
||||
- `/issue:new` - Create issues from GitHub or text
|
||||
- `/issue:plan` - Generate solutions via exploration
|
||||
- `/issue:queue` - Form execution queue
|
||||
- `/issue:execute` - Execute with parallel-dev-cycle
|
||||
- `ccw issue status <id>` - View issue
|
||||
- `ccw issue solution <id>` - View solution
|
||||
416
.claude/commands/issue/new.md
Normal file
416
.claude/commands/issue/new.md
Normal file
@@ -0,0 +1,416 @@
|
||||
---
|
||||
name: new
|
||||
description: Create structured issue from GitHub URL or text description
|
||||
argument-hint: "[-y|--yes] <github-url | text-description> [--priority 1-5]"
|
||||
allowed-tools: TodoWrite(*), Bash(*), Read(*), AskUserQuestion(*), mcp__ace-tool__search_context(*)
|
||||
---
|
||||
|
||||
## Auto Mode
|
||||
|
||||
When `--yes` or `-y`: Skip clarification questions, create issue with inferred details.
|
||||
|
||||
# Issue New Command (/issue:new)
|
||||
|
||||
## Core Principle
|
||||
|
||||
**Requirement Clarity Detection** → Ask only when needed
|
||||
|
||||
```
|
||||
Clear Input (GitHub URL, structured text) → Direct creation
|
||||
Unclear Input (vague description) → Minimal clarifying questions
|
||||
```
|
||||
|
||||
## Issue Structure
|
||||
|
||||
```typescript
|
||||
interface Issue {
|
||||
id: string; // GH-123 or ISS-YYYYMMDD-HHMMSS
|
||||
title: string;
|
||||
status: 'registered' | 'planned' | 'queued' | 'in_progress' | 'completed' | 'failed';
|
||||
priority: number; // 1 (critical) to 5 (low)
|
||||
context: string; // Problem description (single source of truth)
|
||||
source: 'github' | 'text' | 'discovery';
|
||||
source_url?: string;
|
||||
labels?: string[];
|
||||
|
||||
// GitHub binding (for non-GitHub sources that publish to GitHub)
|
||||
github_url?: string; // https://github.com/owner/repo/issues/123
|
||||
github_number?: number; // 123
|
||||
|
||||
// Optional structured fields
|
||||
expected_behavior?: string;
|
||||
actual_behavior?: string;
|
||||
affected_components?: string[];
|
||||
|
||||
// Feedback history (failures + human clarifications)
|
||||
feedback?: {
|
||||
type: 'failure' | 'clarification' | 'rejection';
|
||||
stage: string; // new/plan/execute
|
||||
content: string;
|
||||
created_at: string;
|
||||
}[];
|
||||
|
||||
// Solution binding
|
||||
bound_solution_id: string | null;
|
||||
|
||||
// Timestamps
|
||||
created_at: string;
|
||||
updated_at: string;
|
||||
}
|
||||
```
|
||||
|
||||
## Quick Reference
|
||||
|
||||
```bash
|
||||
# Clear inputs - direct creation
|
||||
/issue:new https://github.com/owner/repo/issues/123
|
||||
/issue:new "Login fails with special chars. Expected: success. Actual: 500 error"
|
||||
|
||||
# Vague input - will ask clarifying questions
|
||||
/issue:new "something wrong with auth"
|
||||
```
|
||||
|
||||
## Implementation
|
||||
|
||||
### Phase 1: Input Analysis & Clarity Detection
|
||||
|
||||
```javascript
|
||||
const input = userInput.trim();
|
||||
const flags = parseFlags(userInput); // --priority
|
||||
|
||||
// Detect input type and clarity
|
||||
const isGitHubUrl = input.match(/github\.com\/[\w-]+\/[\w-]+\/issues\/\d+/);
|
||||
const isGitHubShort = input.match(/^#(\d+)$/);
|
||||
const hasStructure = input.match(/(expected|actual|affects|steps):/i);
|
||||
|
||||
// Clarity score: 0-3
|
||||
let clarityScore = 0;
|
||||
if (isGitHubUrl || isGitHubShort) clarityScore = 3; // GitHub = fully clear
|
||||
else if (hasStructure) clarityScore = 2; // Structured text = clear
|
||||
else if (input.length > 50) clarityScore = 1; // Long text = somewhat clear
|
||||
else clarityScore = 0; // Vague
|
||||
|
||||
let issueData = {};
|
||||
```
|
||||
|
||||
### Phase 2: Data Extraction (GitHub or Text)
|
||||
|
||||
```javascript
|
||||
if (isGitHubUrl || isGitHubShort) {
|
||||
// GitHub - fetch via gh CLI
|
||||
const result = Bash(`gh issue view ${extractIssueRef(input)} --json number,title,body,labels,url`);
|
||||
const gh = JSON.parse(result);
|
||||
issueData = {
|
||||
id: `GH-${gh.number}`,
|
||||
title: gh.title,
|
||||
source: 'github',
|
||||
source_url: gh.url,
|
||||
labels: gh.labels.map(l => l.name),
|
||||
context: gh.body?.substring(0, 500) || gh.title,
|
||||
...parseMarkdownBody(gh.body)
|
||||
};
|
||||
} else {
|
||||
// Text description
|
||||
issueData = {
|
||||
id: `ISS-${new Date().toISOString().replace(/[-:T]/g, '').slice(0, 14)}`,
|
||||
source: 'text',
|
||||
...parseTextDescription(input)
|
||||
};
|
||||
}
|
||||
```
|
||||
|
||||
### Phase 3: Lightweight Context Hint (Conditional)
|
||||
|
||||
```javascript
|
||||
// ACE search ONLY for medium clarity (1-2) AND missing components
|
||||
// Skip for: GitHub (has context), vague (needs clarification first)
|
||||
// Note: Deep exploration happens in /issue:plan, this is just a quick hint
|
||||
|
||||
if (clarityScore >= 1 && clarityScore <= 2 && !issueData.affected_components?.length) {
|
||||
const keywords = extractKeywords(issueData.context);
|
||||
|
||||
if (keywords.length >= 2) {
|
||||
try {
|
||||
const aceResult = mcp__ace-tool__search_context({
|
||||
project_root_path: process.cwd(),
|
||||
query: keywords.slice(0, 3).join(' ')
|
||||
});
|
||||
issueData.affected_components = aceResult.files?.slice(0, 3) || [];
|
||||
} catch {
|
||||
// ACE failure is non-blocking
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### Phase 4: Conditional Clarification (Only if Unclear)
|
||||
|
||||
```javascript
|
||||
// ONLY ask questions if clarity is low - simple open-ended prompt
|
||||
if (clarityScore < 2 && (!issueData.context || issueData.context.length < 20)) {
|
||||
const answer = AskUserQuestion({
|
||||
questions: [{
|
||||
question: 'Please describe the issue in more detail:',
|
||||
header: 'Clarify',
|
||||
multiSelect: false,
|
||||
options: [
|
||||
{ label: 'Provide details', description: 'Describe what, where, and expected behavior' }
|
||||
]
|
||||
}]
|
||||
});
|
||||
|
||||
// Use custom text input (via "Other")
|
||||
if (answer.customText) {
|
||||
issueData.context = answer.customText;
|
||||
issueData.title = answer.customText.split(/[.\n]/)[0].substring(0, 60);
|
||||
issueData.feedback = [{
|
||||
type: 'clarification',
|
||||
stage: 'new',
|
||||
content: answer.customText,
|
||||
created_at: new Date().toISOString()
|
||||
}];
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### Phase 5: GitHub Publishing Decision (Non-GitHub Sources)
|
||||
|
||||
```javascript
|
||||
// For non-GitHub sources, ask if user wants to publish to GitHub
|
||||
let publishToGitHub = false;
|
||||
|
||||
if (issueData.source !== 'github') {
|
||||
const publishAnswer = AskUserQuestion({
|
||||
questions: [{
|
||||
question: 'Would you like to publish this issue to GitHub?',
|
||||
header: 'Publish',
|
||||
multiSelect: false,
|
||||
options: [
|
||||
{ label: 'Yes, publish to GitHub', description: 'Create issue on GitHub and link it' },
|
||||
{ label: 'No, keep local only', description: 'Store as local issue without GitHub sync' }
|
||||
]
|
||||
}]
|
||||
});
|
||||
|
||||
publishToGitHub = publishAnswer.answers?.['Publish']?.includes('Yes');
|
||||
}
|
||||
```
|
||||
|
||||
### Phase 6: Create Issue
|
||||
|
||||
**Summary Display:**
|
||||
- Show ID, title, source, affected files (if any)
|
||||
|
||||
**Confirmation** (only for vague inputs, clarityScore < 2):
|
||||
- Use `AskUserQuestion` to confirm before creation
|
||||
|
||||
**Issue Creation** (via CLI endpoint):
|
||||
```bash
|
||||
# Option 1: Pipe input (recommended for complex JSON - avoids shell escaping)
|
||||
echo '{"title":"...", "context":"...", "priority":3}' | ccw issue create
|
||||
|
||||
# Option 2: Heredoc (for multi-line JSON)
|
||||
ccw issue create << 'EOF'
|
||||
{"title":"...", "context":"含\"引号\"的内容", "priority":3}
|
||||
EOF
|
||||
|
||||
# Option 3: --data parameter (simple cases only)
|
||||
ccw issue create --data '{"title":"...", "priority":3}'
|
||||
```
|
||||
|
||||
**CLI Endpoint Features:**
|
||||
| Feature | Description |
|
||||
|---------|-------------|
|
||||
| Auto-increment ID | `ISS-YYYYMMDD-NNN` (e.g., `ISS-20251229-001`) |
|
||||
| Trailing newline | Proper JSONL format, no corruption |
|
||||
| JSON output | Returns created issue with all fields |
|
||||
|
||||
**Example:**
|
||||
```bash
|
||||
# Create issue via pipe (recommended)
|
||||
echo '{"title": "Login fails with special chars", "context": "500 error when password contains quotes", "priority": 2}' | ccw issue create
|
||||
|
||||
# Or with heredoc for complex JSON
|
||||
ccw issue create << 'EOF'
|
||||
{
|
||||
"title": "Login fails with special chars",
|
||||
"context": "500 error when password contains \"quotes\"",
|
||||
"priority": 2,
|
||||
"source": "text",
|
||||
"expected_behavior": "Login succeeds",
|
||||
"actual_behavior": "500 Internal Server Error"
|
||||
}
|
||||
EOF
|
||||
|
||||
# Output (JSON)
|
||||
{
|
||||
"id": "ISS-20251229-001",
|
||||
"title": "Login fails with special chars",
|
||||
"status": "registered",
|
||||
...
|
||||
}
|
||||
```
|
||||
|
||||
**GitHub Publishing** (if user opted in):
|
||||
```javascript
|
||||
// Step 1: Create local issue FIRST
|
||||
const localIssue = createLocalIssue(issueData); // ccw issue create
|
||||
|
||||
// Step 2: Publish to GitHub if requested
|
||||
if (publishToGitHub) {
|
||||
const ghResult = Bash(`gh issue create --title "${issueData.title}" --body "${issueData.context}"`);
|
||||
// Parse GitHub URL from output
|
||||
const ghUrl = ghResult.match(/https:\/\/github\.com\/[\w-]+\/[\w-]+\/issues\/\d+/)?.[0];
|
||||
const ghNumber = parseInt(ghUrl?.match(/\/issues\/(\d+)/)?.[1]);
|
||||
|
||||
if (ghNumber) {
|
||||
// Step 3: Update local issue with GitHub binding
|
||||
Bash(`ccw issue update ${localIssue.id} --github-url "${ghUrl}" --github-number ${ghNumber}`);
|
||||
// Or via pipe:
|
||||
// echo '{"github_url":"${ghUrl}","github_number":${ghNumber}}' | ccw issue update ${localIssue.id}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
**Workflow:**
|
||||
```
|
||||
1. Create local issue (ISS-YYYYMMDD-NNN) → stored in .workflow/issues.jsonl
|
||||
2. If publishToGitHub:
|
||||
a. gh issue create → returns GitHub URL
|
||||
b. Update local issue with github_url + github_number binding
|
||||
3. Both local and GitHub issues exist, linked together
|
||||
```
|
||||
|
||||
**Example with GitHub Publishing:**
|
||||
```bash
|
||||
# User creates text issue
|
||||
/issue:new "Login fails with special chars. Expected: success. Actual: 500"
|
||||
|
||||
# System asks: "Would you like to publish this issue to GitHub?"
|
||||
# User selects: "Yes, publish to GitHub"
|
||||
|
||||
# Output:
|
||||
# ✓ Local issue created: ISS-20251229-001
|
||||
# ✓ Published to GitHub: https://github.com/org/repo/issues/123
|
||||
# ✓ GitHub binding saved to local issue
|
||||
# → Next step: /issue:plan ISS-20251229-001
|
||||
|
||||
# Resulting issue JSON:
|
||||
{
|
||||
"id": "ISS-20251229-001",
|
||||
"title": "Login fails with special chars",
|
||||
"source": "text",
|
||||
"github_url": "https://github.com/org/repo/issues/123",
|
||||
"github_number": 123,
|
||||
...
|
||||
}
|
||||
```
|
||||
|
||||
**Completion:**
|
||||
- Display created issue ID
|
||||
- Show GitHub URL (if published)
|
||||
- Show next step: `/issue:plan <id>`
|
||||
|
||||
## Execution Flow
|
||||
|
||||
```
|
||||
Phase 1: Input Analysis
|
||||
└─ Detect clarity score (GitHub URL? Structured text? Keywords?)
|
||||
|
||||
Phase 2: Data Extraction (branched by clarity)
|
||||
┌────────────┬─────────────────┬──────────────┐
|
||||
│ Score 3 │ Score 1-2 │ Score 0 │
|
||||
│ GitHub │ Text + ACE │ Vague │
|
||||
├────────────┼─────────────────┼──────────────┤
|
||||
│ gh CLI │ Parse struct │ AskQuestion │
|
||||
│ → parse │ + quick hint │ (1 question) │
|
||||
│ │ (3 files max) │ → feedback │
|
||||
└────────────┴─────────────────┴──────────────┘
|
||||
|
||||
Phase 3: GitHub Publishing Decision (non-GitHub only)
|
||||
├─ Source = github: Skip (already from GitHub)
|
||||
└─ Source ≠ github: AskUserQuestion
|
||||
├─ Yes → publishToGitHub = true
|
||||
└─ No → publishToGitHub = false
|
||||
|
||||
Phase 4: Create Issue
|
||||
├─ Score ≥ 2: Direct creation
|
||||
└─ Score < 2: Confirm first → Create
|
||||
└─ If publishToGitHub: gh issue create → link URL
|
||||
|
||||
Note: Deep exploration & lifecycle deferred to /issue:plan
|
||||
```
|
||||
|
||||
## Helper Functions
|
||||
|
||||
```javascript
|
||||
function extractKeywords(text) {
|
||||
const stopWords = new Set(['the', 'a', 'an', 'is', 'are', 'was', 'were', 'not', 'with']);
|
||||
return text
|
||||
.toLowerCase()
|
||||
.split(/\W+/)
|
||||
.filter(w => w.length > 3 && !stopWords.has(w))
|
||||
.slice(0, 5);
|
||||
}
|
||||
|
||||
function parseTextDescription(text) {
|
||||
const result = { title: '', context: '' };
|
||||
const sentences = text.split(/\.(?=\s|$)/);
|
||||
|
||||
result.title = sentences[0]?.trim().substring(0, 60) || 'Untitled';
|
||||
result.context = text.substring(0, 500);
|
||||
|
||||
// Extract structured fields if present
|
||||
const expected = text.match(/expected:?\s*([^.]+)/i);
|
||||
const actual = text.match(/actual:?\s*([^.]+)/i);
|
||||
const affects = text.match(/affects?:?\s*([^.]+)/i);
|
||||
|
||||
if (expected) result.expected_behavior = expected[1].trim();
|
||||
if (actual) result.actual_behavior = actual[1].trim();
|
||||
if (affects) {
|
||||
result.affected_components = affects[1].split(/[,\s]+/).filter(c => c.includes('/') || c.includes('.'));
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
function parseMarkdownBody(body) {
|
||||
if (!body) return {};
|
||||
const result = {};
|
||||
|
||||
const problem = body.match(/##?\s*(problem|description)[:\s]*([\s\S]*?)(?=##|$)/i);
|
||||
const expected = body.match(/##?\s*expected[:\s]*([\s\S]*?)(?=##|$)/i);
|
||||
const actual = body.match(/##?\s*actual[:\s]*([\s\S]*?)(?=##|$)/i);
|
||||
|
||||
if (problem) result.context = problem[2].trim().substring(0, 500);
|
||||
if (expected) result.expected_behavior = expected[2].trim();
|
||||
if (actual) result.actual_behavior = actual[2].trim();
|
||||
|
||||
return result;
|
||||
}
|
||||
```
|
||||
|
||||
## Examples
|
||||
|
||||
### Clear Input (No Questions)
|
||||
|
||||
```bash
|
||||
/issue:new https://github.com/org/repo/issues/42
|
||||
# → Fetches, parses, creates immediately
|
||||
|
||||
/issue:new "Login fails with special chars. Expected: success. Actual: 500"
|
||||
# → Parses structure, creates immediately
|
||||
```
|
||||
|
||||
### Vague Input (1 Question)
|
||||
|
||||
```bash
|
||||
/issue:new "auth broken"
|
||||
# → Asks: "Input unclear. What is the issue about?"
|
||||
# → User provides details → saved to feedback[]
|
||||
# → Creates issue
|
||||
```
|
||||
|
||||
## Related Commands
|
||||
|
||||
- `/issue:plan` - Plan solution for issue
|
||||
335
.claude/commands/issue/plan.md
Normal file
335
.claude/commands/issue/plan.md
Normal file
@@ -0,0 +1,335 @@
|
||||
---
|
||||
name: plan
|
||||
description: Batch plan issue resolution using issue-plan-agent (explore + plan closed-loop)
|
||||
argument-hint: "[-y|--yes] --all-pending <issue-id>[,<issue-id>,...] [--batch-size 3]"
|
||||
allowed-tools: TodoWrite(*), Task(*), Skill(*), AskUserQuestion(*), Bash(*), Read(*), Write(*)
|
||||
---
|
||||
|
||||
## Auto Mode
|
||||
|
||||
When `--yes` or `-y`: Auto-bind solutions without confirmation, use recommended settings.
|
||||
|
||||
# Issue Plan Command (/issue:plan)
|
||||
|
||||
## Overview
|
||||
|
||||
Unified planning command using **issue-plan-agent** that combines exploration and planning into a single closed-loop workflow.
|
||||
|
||||
**Behavior:**
|
||||
- Single solution per issue → auto-bind
|
||||
- Multiple solutions → return for user selection
|
||||
- Agent handles file generation
|
||||
|
||||
## Core Guidelines
|
||||
|
||||
**⚠️ Data Access Principle**: Issues and solutions files can grow very large. To avoid context overflow:
|
||||
|
||||
| Operation | Correct | Incorrect |
|
||||
|-----------|---------|-----------|
|
||||
| List issues (brief) | `ccw issue list --status pending --brief` | `Read('issues.jsonl')` |
|
||||
| Read issue details | `ccw issue status <id> --json` | `Read('issues.jsonl')` |
|
||||
| Update status | `ccw issue update <id> --status ...` | Direct file edit |
|
||||
| Bind solution | `ccw issue bind <id> <sol-id>` | Direct file edit |
|
||||
|
||||
**Output Options**:
|
||||
- `--brief`: JSON with minimal fields (id, title, status, priority, tags)
|
||||
- `--json`: Full JSON (agent use only)
|
||||
|
||||
**Orchestration vs Execution**:
|
||||
- **Command (orchestrator)**: Use `--brief` for minimal context
|
||||
- **Agent (executor)**: Fetch full details → `ccw issue status <id> --json`
|
||||
|
||||
**ALWAYS** use CLI commands for CRUD operations. **NEVER** read entire `issues.jsonl` or `solutions/*.jsonl` directly.
|
||||
|
||||
## Usage
|
||||
|
||||
```bash
|
||||
/issue:plan [<issue-id>[,<issue-id>,...]] [FLAGS]
|
||||
|
||||
# Examples
|
||||
/issue:plan # Default: --all-pending
|
||||
/issue:plan GH-123 # Single issue
|
||||
/issue:plan GH-123,GH-124,GH-125 # Batch (up to 3)
|
||||
/issue:plan --all-pending # All pending issues (explicit)
|
||||
|
||||
# Flags
|
||||
--batch-size <n> Max issues per agent batch (default: 3)
|
||||
```
|
||||
|
||||
## Execution Process
|
||||
|
||||
```
|
||||
Phase 1: Issue Loading & Intelligent Grouping
|
||||
├─ Parse input (single, comma-separated, or --all-pending)
|
||||
├─ Fetch issue metadata (ID, title, tags)
|
||||
├─ Validate issues exist (create if needed)
|
||||
└─ Intelligent grouping via Gemini (semantic similarity, max 3 per batch)
|
||||
|
||||
Phase 2: Unified Explore + Plan (issue-plan-agent)
|
||||
├─ Launch issue-plan-agent per batch
|
||||
├─ Agent performs:
|
||||
│ ├─ ACE semantic search for each issue
|
||||
│ ├─ Codebase exploration (files, patterns, dependencies)
|
||||
│ ├─ Solution generation with task breakdown
|
||||
│ └─ Conflict detection across issues
|
||||
└─ Output: solution JSON per issue
|
||||
|
||||
Phase 3: Solution Registration & Binding
|
||||
├─ Append solutions to solutions/{issue-id}.jsonl
|
||||
├─ Single solution per issue → auto-bind
|
||||
├─ Multiple candidates → AskUserQuestion to select
|
||||
└─ Update issues.jsonl with bound_solution_id
|
||||
|
||||
Phase 4: Summary
|
||||
├─ Display bound solutions
|
||||
├─ Show task counts per issue
|
||||
└─ Display next steps (/issue:queue)
|
||||
```
|
||||
|
||||
## Implementation
|
||||
|
||||
### Phase 1: Issue Loading (Brief Info Only)
|
||||
|
||||
```javascript
|
||||
const batchSize = flags.batchSize || 3;
|
||||
let issues = []; // {id, title, tags} - brief info for grouping only
|
||||
|
||||
// Default to --all-pending if no input provided
|
||||
const useAllPending = flags.allPending || !userInput || userInput.trim() === '';
|
||||
|
||||
if (useAllPending) {
|
||||
// Get pending issues with brief metadata via CLI
|
||||
const result = Bash(`ccw issue list --status pending,registered --json`).trim();
|
||||
const parsed = result ? JSON.parse(result) : [];
|
||||
issues = parsed.map(i => ({ id: i.id, title: i.title || '', tags: i.tags || [] }));
|
||||
|
||||
if (issues.length === 0) {
|
||||
console.log('No pending issues found.');
|
||||
return;
|
||||
}
|
||||
console.log(`Found ${issues.length} pending issues`);
|
||||
} else {
|
||||
// Parse comma-separated issue IDs, fetch brief metadata
|
||||
const ids = userInput.includes(',')
|
||||
? userInput.split(',').map(s => s.trim())
|
||||
: [userInput.trim()];
|
||||
|
||||
for (const id of ids) {
|
||||
Bash(`ccw issue init ${id} --title "Issue ${id}" 2>/dev/null || true`);
|
||||
const info = Bash(`ccw issue status ${id} --json`).trim();
|
||||
const parsed = info ? JSON.parse(info) : {};
|
||||
issues.push({ id, title: parsed.title || '', tags: parsed.tags || [] });
|
||||
}
|
||||
}
|
||||
// Note: Agent fetches full issue content via `ccw issue status <id> --json`
|
||||
|
||||
// Intelligent grouping: Analyze issues by title/tags, group semantically similar ones
|
||||
// Strategy: Same module/component, related bugs, feature clusters
|
||||
// Constraint: Max ${batchSize} issues per batch
|
||||
|
||||
console.log(`Processing ${issues.length} issues in ${batches.length} batch(es)`);
|
||||
|
||||
TodoWrite({
|
||||
todos: batches.map((_, i) => ({
|
||||
content: `Plan batch ${i+1}`,
|
||||
status: 'pending',
|
||||
activeForm: `Planning batch ${i+1}`
|
||||
}))
|
||||
});
|
||||
```
|
||||
|
||||
### Phase 2: Unified Explore + Plan (issue-plan-agent) - PARALLEL
|
||||
|
||||
```javascript
|
||||
Bash(`mkdir -p .workflow/issues/solutions`);
|
||||
const pendingSelections = []; // Collect multi-solution issues for user selection
|
||||
const agentResults = []; // Collect all agent results for conflict aggregation
|
||||
|
||||
// Build prompts for all batches
|
||||
const agentTasks = batches.map((batch, batchIndex) => {
|
||||
const issueList = batch.map(i => `- ${i.id}: ${i.title}${i.tags.length ? ` [${i.tags.join(', ')}]` : ''}`).join('\n');
|
||||
const batchIds = batch.map(i => i.id);
|
||||
|
||||
const issuePrompt = `
|
||||
## Plan Issues
|
||||
|
||||
**Issues** (grouped by similarity):
|
||||
${issueList}
|
||||
|
||||
**Project Root**: ${process.cwd()}
|
||||
|
||||
### Project Context (MANDATORY)
|
||||
1. Read: .workflow/project-tech.json (technology stack, architecture)
|
||||
2. Read: .workflow/project-guidelines.json (constraints and conventions)
|
||||
|
||||
### Workflow
|
||||
1. Fetch issue details: ccw issue status <id> --json
|
||||
2. **Analyze failure history** (if issue.feedback exists):
|
||||
- Extract failure details from issue.feedback (type='failure', stage='execute')
|
||||
- Parse error_type, message, task_id, solution_id from content JSON
|
||||
- Identify failure patterns: repeated errors, root causes, blockers
|
||||
- **Constraint**: Avoid repeating failed approaches
|
||||
3. Load project context files
|
||||
4. Explore codebase (ACE semantic search)
|
||||
5. Plan solution with tasks (schema: solution-schema.json)
|
||||
- **If previous solution failed**: Reference failure analysis in solution.approach
|
||||
- Add explicit verification steps to prevent same failure mode
|
||||
6. **If github_url exists**: Add final task to comment on GitHub issue
|
||||
7. Write solution to: .workflow/issues/solutions/{issue-id}.jsonl
|
||||
8. **CRITICAL - Binding Decision**:
|
||||
- Single solution → **MUST execute**: ccw issue bind <issue-id> <solution-id>
|
||||
- Multiple solutions → Return pending_selection only (no bind)
|
||||
|
||||
### Failure-Aware Planning Rules
|
||||
- **Extract failure patterns**: Parse issue.feedback where type='failure' and stage='execute'
|
||||
- **Identify root causes**: Analyze error_type (test_failure, compilation, timeout, etc.)
|
||||
- **Design alternative approach**: Create solution that addresses root cause
|
||||
- **Add prevention steps**: Include explicit verification to catch same error earlier
|
||||
- **Document lessons**: Reference previous failures in solution.approach
|
||||
|
||||
### Rules
|
||||
- Solution ID format: SOL-{issue-id}-{uid} (uid: 4 random alphanumeric chars, e.g., a7x9)
|
||||
- Single solution per issue → auto-bind via ccw issue bind
|
||||
- Multiple solutions → register only, return pending_selection
|
||||
- Tasks must have quantified acceptance.criteria
|
||||
|
||||
### Return Summary
|
||||
{"bound":[{"issue_id":"...","solution_id":"...","task_count":N}],"pending_selection":[{"issue_id":"...","solutions":[{"id":"...","description":"...","task_count":N}]}]}
|
||||
`;
|
||||
|
||||
return { batchIndex, batchIds, issuePrompt, batch };
|
||||
});
|
||||
|
||||
// Launch agents in parallel (max 10 concurrent)
|
||||
const MAX_PARALLEL = 10;
|
||||
for (let i = 0; i < agentTasks.length; i += MAX_PARALLEL) {
|
||||
const chunk = agentTasks.slice(i, i + MAX_PARALLEL);
|
||||
const taskIds = [];
|
||||
|
||||
// Launch chunk in parallel
|
||||
for (const { batchIndex, batchIds, issuePrompt, batch } of chunk) {
|
||||
updateTodo(`Plan batch ${batchIndex + 1}`, 'in_progress');
|
||||
const taskId = Task(
|
||||
subagent_type="issue-plan-agent",
|
||||
run_in_background=true,
|
||||
description=`Explore & plan ${batch.length} issues: ${batchIds.join(', ')}`,
|
||||
prompt=issuePrompt
|
||||
);
|
||||
taskIds.push({ taskId, batchIndex });
|
||||
}
|
||||
|
||||
console.log(`Launched ${taskIds.length} agents (batch ${i/MAX_PARALLEL + 1}/${Math.ceil(agentTasks.length/MAX_PARALLEL)})...`);
|
||||
|
||||
// Collect results from this chunk
|
||||
for (const { taskId, batchIndex } of taskIds) {
|
||||
const result = TaskOutput(task_id=taskId, block=true);
|
||||
|
||||
// Extract JSON from potential markdown code blocks (agent may wrap in ```json...```)
|
||||
const jsonText = extractJsonFromMarkdown(result);
|
||||
let summary;
|
||||
try {
|
||||
summary = JSON.parse(jsonText);
|
||||
} catch (e) {
|
||||
console.log(`⚠ Batch ${batchIndex + 1}: Failed to parse agent result, skipping`);
|
||||
updateTodo(`Plan batch ${batchIndex + 1}`, 'completed');
|
||||
continue;
|
||||
}
|
||||
agentResults.push(summary); // Store for Phase 3 conflict aggregation
|
||||
|
||||
// Verify binding for bound issues (agent should have executed bind)
|
||||
for (const item of summary.bound || []) {
|
||||
const status = JSON.parse(Bash(`ccw issue status ${item.issue_id} --json`).trim());
|
||||
if (status.bound_solution_id === item.solution_id) {
|
||||
console.log(`✓ ${item.issue_id}: ${item.solution_id} (${item.task_count} tasks)`);
|
||||
} else {
|
||||
// Fallback: agent failed to bind, execute here
|
||||
Bash(`ccw issue bind ${item.issue_id} ${item.solution_id}`);
|
||||
console.log(`✓ ${item.issue_id}: ${item.solution_id} (${item.task_count} tasks) [recovered]`);
|
||||
}
|
||||
}
|
||||
// Collect pending selections for Phase 3
|
||||
for (const pending of summary.pending_selection || []) {
|
||||
pendingSelections.push(pending);
|
||||
}
|
||||
updateTodo(`Plan batch ${batchIndex + 1}`, 'completed');
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### Phase 3: Solution Selection (if pending)
|
||||
|
||||
```javascript
|
||||
// Handle multi-solution issues
|
||||
for (const pending of pendingSelections) {
|
||||
if (pending.solutions.length === 0) continue;
|
||||
|
||||
const options = pending.solutions.slice(0, 4).map(sol => ({
|
||||
label: `${sol.id} (${sol.task_count} tasks)`,
|
||||
description: sol.description || sol.approach || 'No description'
|
||||
}));
|
||||
|
||||
const answer = AskUserQuestion({
|
||||
questions: [{
|
||||
question: `Issue ${pending.issue_id}: which solution to bind?`,
|
||||
header: pending.issue_id,
|
||||
options: options,
|
||||
multiSelect: false
|
||||
}]
|
||||
});
|
||||
|
||||
const selected = answer[Object.keys(answer)[0]];
|
||||
if (!selected || selected === 'Other') continue;
|
||||
|
||||
const solId = selected.split(' ')[0];
|
||||
Bash(`ccw issue bind ${pending.issue_id} ${solId}`);
|
||||
console.log(`✓ ${pending.issue_id}: ${solId} bound`);
|
||||
}
|
||||
```
|
||||
|
||||
### Phase 4: Summary
|
||||
|
||||
```javascript
|
||||
// Count planned issues via CLI
|
||||
const planned = JSON.parse(Bash(`ccw issue list --status planned --brief`) || '[]');
|
||||
const plannedCount = planned.length;
|
||||
|
||||
console.log(`
|
||||
## Done: ${issues.length} issues → ${plannedCount} planned
|
||||
|
||||
Next: \`/issue:queue\` → \`/issue:execute\`
|
||||
`);
|
||||
```
|
||||
|
||||
## Error Handling
|
||||
|
||||
| Error | Resolution |
|
||||
|-------|------------|
|
||||
| Issue not found | Auto-create in issues.jsonl |
|
||||
| ACE search fails | Agent falls back to ripgrep |
|
||||
| No solutions generated | Display error, suggest manual planning |
|
||||
| User cancels selection | Skip issue, continue with others |
|
||||
| File conflicts | Agent detects and suggests resolution order |
|
||||
|
||||
## Bash Compatibility
|
||||
|
||||
**Avoid**: `$(cmd)`, `$var`, `for` loops — will be escaped incorrectly
|
||||
|
||||
**Use**: Simple commands + `&&` chains, quote comma params `"pending,registered"`
|
||||
|
||||
## Quality Checklist
|
||||
|
||||
Before completing, verify:
|
||||
|
||||
- [ ] All input issues have solutions in `solutions/{issue-id}.jsonl`
|
||||
- [ ] Single solution issues are auto-bound (`bound_solution_id` set)
|
||||
- [ ] Multi-solution issues returned in `pending_selection` for user choice
|
||||
- [ ] Each solution has executable tasks with `modification_points`
|
||||
- [ ] Task acceptance criteria are quantified (not vague)
|
||||
- [ ] Conflicts detected and reported (if multiple issues touch same files)
|
||||
- [ ] Issue status updated to `planned` after binding
|
||||
|
||||
## Related Commands
|
||||
|
||||
- `/issue:queue` - Form execution queue from bound solutions
|
||||
- `ccw issue list` - List all issues
|
||||
- `ccw issue status` - View issue and solution details
|
||||
445
.claude/commands/issue/queue.md
Normal file
445
.claude/commands/issue/queue.md
Normal file
@@ -0,0 +1,445 @@
|
||||
---
|
||||
name: queue
|
||||
description: Form execution queue from bound solutions using issue-queue-agent (solution-level)
|
||||
argument-hint: "[-y|--yes] [--queues <n>] [--issue <id>]"
|
||||
allowed-tools: TodoWrite(*), Task(*), Bash(*), Read(*), Write(*)
|
||||
---
|
||||
|
||||
## Auto Mode
|
||||
|
||||
When `--yes` or `-y`: Auto-confirm queue formation, use recommended conflict resolutions.
|
||||
|
||||
# Issue Queue Command (/issue:queue)
|
||||
|
||||
## Overview
|
||||
|
||||
Queue formation command using **issue-queue-agent** that analyzes all bound solutions, resolves **inter-solution** conflicts, and creates an ordered execution queue at **solution level**.
|
||||
|
||||
**Design Principle**: Queue items are **solutions**, not individual tasks. Each executor receives a complete solution with all its tasks.
|
||||
|
||||
## Core Capabilities
|
||||
|
||||
- **Agent-driven**: issue-queue-agent handles all ordering logic
|
||||
- **Solution-level granularity**: Queue items are solutions, not tasks
|
||||
- **Conflict clarification**: High-severity conflicts prompt user decision
|
||||
- Semantic priority calculation per solution (0.0-1.0)
|
||||
- Parallel/Sequential group assignment for solutions
|
||||
|
||||
## Core Guidelines
|
||||
|
||||
**⚠️ Data Access Principle**: Issues and queue files can grow very large. To avoid context overflow:
|
||||
|
||||
| Operation | Correct | Incorrect |
|
||||
|-----------|---------|-----------|
|
||||
| List issues (brief) | `ccw issue list --status planned --brief` | `Read('issues.jsonl')` |
|
||||
| **Batch solutions (NEW)** | `ccw issue solutions --status planned --brief` | Loop `ccw issue solution <id>` |
|
||||
| List queue (brief) | `ccw issue queue --brief` | `Read('queues/*.json')` |
|
||||
| Read issue details | `ccw issue status <id> --json` | `Read('issues.jsonl')` |
|
||||
| Get next item | `ccw issue next --json` | `Read('queues/*.json')` |
|
||||
| Update status | `ccw issue update <id> --status ...` | Direct file edit |
|
||||
| Sync from queue | `ccw issue update --from-queue` | Direct file edit |
|
||||
| Read solution (single) | `ccw issue solution <id> --brief` | `Read('solutions/*.jsonl')` |
|
||||
|
||||
**Output Options**:
|
||||
- `--brief`: JSON with minimal fields (id, status, counts)
|
||||
- `--json`: Full JSON (agent use only)
|
||||
|
||||
**Orchestration vs Execution**:
|
||||
- **Command (orchestrator)**: Use `--brief` for minimal context
|
||||
- **Agent (executor)**: Fetch full details → `ccw issue status <id> --json`
|
||||
|
||||
**ALWAYS** use CLI commands for CRUD operations. **NEVER** read entire `issues.jsonl` or `queues/*.json` directly.
|
||||
|
||||
|
||||
|
||||
## Usage
|
||||
|
||||
```bash
|
||||
/issue:queue [FLAGS]
|
||||
|
||||
# Examples
|
||||
/issue:queue # Form NEW queue from all bound solutions
|
||||
/issue:queue --queues 3 # Form 3 parallel queues (solutions distributed)
|
||||
/issue:queue --issue GH-123 # Form queue for specific issue only
|
||||
/issue:queue --append GH-124 # Append to active queue
|
||||
/issue:queue --list # List all queues (history)
|
||||
/issue:queue --switch QUE-xxx # Switch active queue
|
||||
/issue:queue --archive # Archive completed active queue
|
||||
|
||||
# Flags
|
||||
--queues <n> Number of parallel queues (default: 1)
|
||||
--issue <id> Form queue for specific issue only
|
||||
--append <id> Append issue to active queue (don't create new)
|
||||
--force Skip active queue check, always create new queue
|
||||
|
||||
# CLI subcommands (ccw issue queue ...)
|
||||
ccw issue queue list List all queues with status
|
||||
ccw issue queue add <issue-id> Add issue to queue (interactive if active queue exists)
|
||||
ccw issue queue add <issue-id> -f Add to new queue without prompt (force)
|
||||
ccw issue queue merge <src> --queue <target> Merge source queue into target queue
|
||||
ccw issue queue switch <queue-id> Switch active queue
|
||||
ccw issue queue archive Archive current queue
|
||||
ccw issue queue delete <queue-id> Delete queue from history
|
||||
```
|
||||
|
||||
## Execution Process
|
||||
|
||||
```
|
||||
Phase 1: Solution Loading & Distribution
|
||||
├─ Load issues.jsonl, filter by status='planned' + bound_solution_id
|
||||
├─ Read solutions/{issue-id}.jsonl, find bound solution
|
||||
├─ Extract files_touched from task modification_points
|
||||
├─ Build solution objects array
|
||||
└─ If --queues > 1: Partition solutions into N groups (minimize cross-group file conflicts)
|
||||
|
||||
Phase 2-4: Agent-Driven Queue Formation (issue-queue-agent)
|
||||
├─ Generate N queue IDs (QUE-xxx-1, QUE-xxx-2, ...)
|
||||
├─ If --queues == 1: Launch single issue-queue-agent
|
||||
├─ If --queues > 1: Launch N issue-queue-agents IN PARALLEL
|
||||
├─ Each agent performs:
|
||||
│ ├─ Conflict analysis (5 types via Gemini CLI)
|
||||
│ ├─ Build dependency DAG from conflicts
|
||||
│ ├─ Calculate semantic priority per solution
|
||||
│ └─ Assign execution groups (parallel/sequential)
|
||||
└─ Each agent writes: queue JSON + index update (NOT active yet)
|
||||
|
||||
Phase 5: Conflict Clarification (if needed)
|
||||
├─ Collect `clarifications` arrays from all agents
|
||||
├─ If clarifications exist → AskUserQuestion (batched)
|
||||
├─ Pass user decisions back to respective agents (resume)
|
||||
└─ Agents update queues with resolved conflicts
|
||||
|
||||
Phase 6: Status Update & Summary
|
||||
├─ Update issue statuses to 'queued'
|
||||
└─ Display new queue summary (N queues)
|
||||
|
||||
Phase 7: Active Queue Check & Decision (REQUIRED)
|
||||
├─ Read queue index: ccw issue queue list --brief
|
||||
├─ Get generated queue ID from agent output
|
||||
├─ If NO active queue exists:
|
||||
│ ├─ Set generated queue as active_queue_id
|
||||
│ ├─ Update index.json
|
||||
│ └─ Display: "Queue created and activated"
|
||||
│
|
||||
└─ If active queue exists with items:
|
||||
├─ Display both queues to user
|
||||
├─ Use AskUserQuestion to prompt:
|
||||
│ ├─ "Use new queue (keep existing)" → Set new as active, keep old inactive
|
||||
│ ├─ "Merge: add new items to existing" → Merge new → existing, delete new
|
||||
│ ├─ "Merge: add existing items to new" → Merge existing → new, archive old
|
||||
│ └─ "Cancel" → Delete new queue, keep existing active
|
||||
└─ Execute chosen action
|
||||
```
|
||||
|
||||
## Implementation
|
||||
|
||||
### Phase 1: Solution Loading & Distribution
|
||||
|
||||
**Data Loading:**
|
||||
- Use `ccw issue solutions --status planned --brief` to get all planned issues with solutions in **one call**
|
||||
- Returns: Array of `{ issue_id, solution_id, is_bound, task_count, files_touched[], priority }`
|
||||
- If no bound solutions found → display message, suggest `/issue:plan`
|
||||
|
||||
**Build Solution Objects:**
|
||||
```javascript
|
||||
// Single CLI call replaces N individual queries
|
||||
const result = Bash(`ccw issue solutions --status planned --brief`).trim();
|
||||
const solutions = result ? JSON.parse(result) : [];
|
||||
|
||||
if (solutions.length === 0) {
|
||||
console.log('No bound solutions found. Run /issue:plan first.');
|
||||
return;
|
||||
}
|
||||
|
||||
// solutions already in correct format:
|
||||
// { issue_id, solution_id, is_bound, task_count, files_touched[], priority }
|
||||
```
|
||||
|
||||
**Multi-Queue Distribution** (if `--queues > 1`):
|
||||
- Use `files_touched` from brief output for partitioning
|
||||
- Group solutions with overlapping files into same queue
|
||||
|
||||
**Output:** Array of solution objects (or N arrays if multi-queue)
|
||||
|
||||
### Phase 2-4: Agent-Driven Queue Formation
|
||||
|
||||
**Generate Queue IDs** (command layer, pass to agent):
|
||||
```javascript
|
||||
const timestamp = new Date().toISOString().replace(/[-:T]/g, '').slice(0, 14);
|
||||
const numQueues = args.queues || 1;
|
||||
const queueIds = numQueues === 1
|
||||
? [`QUE-${timestamp}`]
|
||||
: Array.from({length: numQueues}, (_, i) => `QUE-${timestamp}-${i + 1}`);
|
||||
```
|
||||
|
||||
**Agent Prompt** (same for each queue, with assigned solutions):
|
||||
```
|
||||
## Order Solutions into Execution Queue
|
||||
|
||||
**Queue ID**: ${queueId}
|
||||
**Solutions**: ${solutions.length} from ${issues.length} issues
|
||||
**Project Root**: ${cwd}
|
||||
**Queue Index**: ${queueIndex} of ${numQueues}
|
||||
|
||||
### Input
|
||||
${JSON.stringify(solutions)}
|
||||
// Each object: { issue_id, solution_id, task_count, files_touched[], priority }
|
||||
|
||||
### Workflow
|
||||
|
||||
Step 1: Build dependency graph from solutions (nodes=solutions, edges=file conflicts via files_touched)
|
||||
Step 2: Use Gemini CLI for conflict analysis (5 types: file, API, data, dependency, architecture)
|
||||
Step 3: For high-severity conflicts without clear resolution → add to `clarifications`
|
||||
Step 4: Calculate semantic priority (base from issue priority + task_count boost)
|
||||
Step 5: Assign execution groups: P* (parallel, no overlaps) / S* (sequential, shared files)
|
||||
Step 6: Write queue JSON + update index
|
||||
|
||||
### Output Requirements
|
||||
|
||||
**Write files** (exactly 2):
|
||||
- `.workflow/issues/queues/${queueId}.json` - Full queue with solutions, conflicts, groups
|
||||
- `.workflow/issues/queues/index.json` - Update with new queue entry
|
||||
|
||||
**Return JSON**:
|
||||
\`\`\`json
|
||||
{
|
||||
"queue_id": "${queueId}",
|
||||
"total_solutions": N,
|
||||
"total_tasks": N,
|
||||
"execution_groups": [{"id": "P1", "type": "parallel", "count": N}],
|
||||
"issues_queued": ["ISS-xxx"],
|
||||
"clarifications": [{"conflict_id": "CFT-1", "question": "...", "options": [...]}]
|
||||
}
|
||||
\`\`\`
|
||||
|
||||
### Rules
|
||||
- Solution granularity (NOT individual tasks)
|
||||
- Queue Item ID format: S-1, S-2, S-3, ...
|
||||
- Use provided Queue ID (do NOT generate new)
|
||||
- `clarifications` only present if high-severity unresolved conflicts exist
|
||||
- Use `files_touched` from input (already extracted by orchestrator)
|
||||
|
||||
### Done Criteria
|
||||
- [ ] Queue JSON written with all solutions ordered
|
||||
- [ ] Index updated with active_queue_id
|
||||
- [ ] No circular dependencies
|
||||
- [ ] Parallel groups have no file overlaps
|
||||
- [ ] Return JSON matches required shape
|
||||
```
|
||||
|
||||
**Launch Agents** (parallel if multi-queue):
|
||||
```javascript
|
||||
const numQueues = args.queues || 1;
|
||||
|
||||
if (numQueues === 1) {
|
||||
// Single queue: single agent call
|
||||
const result = Task(
|
||||
subagent_type="issue-queue-agent",
|
||||
prompt=buildPrompt(queueIds[0], solutions),
|
||||
description=`Order ${solutions.length} solutions`
|
||||
);
|
||||
} else {
|
||||
// Multi-queue: parallel agent calls (single message with N Task calls)
|
||||
const agentPromises = solutionGroups.map((group, i) =>
|
||||
Task(
|
||||
subagent_type="issue-queue-agent",
|
||||
prompt=buildPrompt(queueIds[i], group, i + 1, numQueues),
|
||||
description=`Queue ${i + 1}/${numQueues}: ${group.length} solutions`
|
||||
)
|
||||
);
|
||||
// All agents launched in parallel via single message with multiple Task tool calls
|
||||
}
|
||||
```
|
||||
|
||||
**Multi-Queue Index Update:**
|
||||
- First queue sets `active_queue_id`
|
||||
- All queues added to `queues` array with `queue_group` field linking them
|
||||
|
||||
### Phase 5: Conflict Clarification
|
||||
|
||||
**Collect Agent Results** (multi-queue):
|
||||
```javascript
|
||||
// Collect clarifications from all agents
|
||||
const allClarifications = results.flatMap((r, i) =>
|
||||
(r.clarifications || []).map(c => ({ ...c, queue_id: queueIds[i], agent_id: agentIds[i] }))
|
||||
);
|
||||
```
|
||||
|
||||
**Check Agent Return:**
|
||||
- Parse agent result JSON (or all results if multi-queue)
|
||||
- If any `clarifications` array exists and non-empty → user decision required
|
||||
|
||||
**Clarification Flow:**
|
||||
```javascript
|
||||
if (allClarifications.length > 0) {
|
||||
for (const clarification of allClarifications) {
|
||||
// Present to user via AskUserQuestion
|
||||
const answer = AskUserQuestion({
|
||||
questions: [{
|
||||
question: `[${clarification.queue_id}] ${clarification.question}`,
|
||||
header: clarification.conflict_id,
|
||||
options: clarification.options,
|
||||
multiSelect: false
|
||||
}]
|
||||
});
|
||||
|
||||
// Resume respective agent with user decision
|
||||
Task(
|
||||
subagent_type="issue-queue-agent",
|
||||
resume=clarification.agent_id,
|
||||
prompt=`Conflict ${clarification.conflict_id} resolved: ${answer.selected}`
|
||||
);
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### Phase 6: Status Update & Summary
|
||||
|
||||
**Status Update** (MUST use CLI command, NOT direct file operations):
|
||||
|
||||
```bash
|
||||
# Option 1: Batch update from queue (recommended)
|
||||
ccw issue update --from-queue [queue-id] --json
|
||||
ccw issue update --from-queue --json # Use active queue
|
||||
ccw issue update --from-queue QUE-xxx --json # Use specific queue
|
||||
|
||||
# Option 2: Individual issue update
|
||||
ccw issue update <issue-id> --status queued
|
||||
```
|
||||
|
||||
**⚠️ IMPORTANT**: Do NOT directly modify `issues.jsonl`. Always use CLI command to ensure proper validation and history tracking.
|
||||
|
||||
**Output** (JSON):
|
||||
```json
|
||||
{
|
||||
"success": true,
|
||||
"queue_id": "QUE-xxx",
|
||||
"queued": ["ISS-001", "ISS-002"],
|
||||
"queued_count": 2,
|
||||
"unplanned": ["ISS-003"],
|
||||
"unplanned_count": 1
|
||||
}
|
||||
```
|
||||
|
||||
**Behavior:**
|
||||
- Updates issues in queue to `status: 'queued'` (skips already queued/executing/completed)
|
||||
- Identifies planned issues with `bound_solution_id` NOT in queue → `unplanned` array
|
||||
- Optional `queue-id`: defaults to active queue if omitted
|
||||
|
||||
**Summary Output:**
|
||||
- Display queue ID, solution count, task count
|
||||
- Show unplanned issues (planned but NOT in queue)
|
||||
- Show next step: `/issue:execute`
|
||||
|
||||
### Phase 7: Active Queue Check & Decision
|
||||
|
||||
**After agent completes Phase 1-6, check for active queue:**
|
||||
|
||||
```bash
|
||||
ccw issue queue list --brief
|
||||
```
|
||||
|
||||
**Decision:**
|
||||
- If `active_queue_id` is null → `ccw issue queue switch <new-queue-id>` (activate new queue)
|
||||
- If active queue exists → Use **AskUserQuestion** to prompt user
|
||||
|
||||
**AskUserQuestion:**
|
||||
```javascript
|
||||
AskUserQuestion({
|
||||
questions: [{
|
||||
question: "Active queue exists. How would you like to proceed?",
|
||||
header: "Queue Action",
|
||||
options: [
|
||||
{ label: "Merge into existing queue", description: "Add new items to active queue, delete new queue" },
|
||||
{ label: "Use new queue", description: "Switch to new queue, keep existing in history" },
|
||||
{ label: "Cancel", description: "Delete new queue, keep existing active" }
|
||||
],
|
||||
multiSelect: false
|
||||
}]
|
||||
})
|
||||
```
|
||||
|
||||
**Action Commands:**
|
||||
|
||||
| User Choice | Commands |
|
||||
|-------------|----------|
|
||||
| **Merge into existing** | `ccw issue queue merge <new-queue-id> --queue <active-queue-id>` then `ccw issue queue delete <new-queue-id>` |
|
||||
| **Use new queue** | `ccw issue queue switch <new-queue-id>` |
|
||||
| **Cancel** | `ccw issue queue delete <new-queue-id>` |
|
||||
|
||||
## Storage Structure (Queue History)
|
||||
|
||||
```
|
||||
.workflow/issues/
|
||||
├── issues.jsonl # All issues (one per line)
|
||||
├── queues/ # Queue history directory
|
||||
│ ├── index.json # Queue index (active + history)
|
||||
│ ├── {queue-id}.json # Individual queue files
|
||||
│ └── ...
|
||||
└── solutions/
|
||||
├── {issue-id}.jsonl # Solutions for issue
|
||||
└── ...
|
||||
```
|
||||
|
||||
### Queue Index Schema
|
||||
|
||||
```json
|
||||
{
|
||||
"active_queue_id": "QUE-20251227-143000",
|
||||
"active_queue_group": "QGR-20251227-143000",
|
||||
"queues": [
|
||||
{
|
||||
"id": "QUE-20251227-143000-1",
|
||||
"queue_group": "QGR-20251227-143000",
|
||||
"queue_index": 1,
|
||||
"total_queues": 3,
|
||||
"status": "active",
|
||||
"issue_ids": ["ISS-xxx", "ISS-yyy"],
|
||||
"total_solutions": 3,
|
||||
"completed_solutions": 1,
|
||||
"created_at": "2025-12-27T14:30:00Z"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
**Multi-Queue Fields:**
|
||||
- `queue_group`: Links queues created in same batch (format: `QGR-{timestamp}`)
|
||||
- `queue_index`: Position in group (1-based)
|
||||
- `total_queues`: Total queues in group
|
||||
- `active_queue_group`: Current active group (for multi-queue execution)
|
||||
|
||||
**Note**: Queue file schema is produced by `issue-queue-agent`. See agent documentation for details.
|
||||
## Error Handling
|
||||
|
||||
| Error | Resolution |
|
||||
|-------|------------|
|
||||
| No bound solutions | Display message, suggest /issue:plan |
|
||||
| Circular dependency | List cycles, abort queue formation |
|
||||
| High-severity conflict | Return `clarifications`, prompt user decision |
|
||||
| User cancels clarification | Abort queue formation |
|
||||
| **index.json not updated** | Auto-fix: Set active_queue_id to new queue |
|
||||
| **Queue file missing solutions** | Abort with error, agent must regenerate |
|
||||
| **User cancels queue add** | Display message, return without changes |
|
||||
| **Merge with empty source** | Skip merge, display warning |
|
||||
| **All items duplicate** | Skip merge, display "All items already exist" |
|
||||
|
||||
## Quality Checklist
|
||||
|
||||
Before completing, verify:
|
||||
|
||||
- [ ] All planned issues with `bound_solution_id` are included
|
||||
- [ ] Queue JSON written to `queues/{queue-id}.json` (N files if multi-queue)
|
||||
- [ ] Index updated in `queues/index.json` with `active_queue_id`
|
||||
- [ ] Multi-queue: All queues share same `queue_group`
|
||||
- [ ] No circular dependencies in solution DAG
|
||||
- [ ] All conflicts resolved (auto or via user clarification)
|
||||
- [ ] Parallel groups have no file overlaps
|
||||
- [ ] Cross-queue: No file overlaps between queues
|
||||
- [ ] Issue statuses updated to `queued`
|
||||
|
||||
## Related Commands
|
||||
|
||||
- `/issue:execute` - Execute queue with codex
|
||||
- `ccw issue queue list` - View current queue
|
||||
- `ccw issue update --from-queue [queue-id]` - Sync issue statuses from queue
|
||||
@@ -1,687 +0,0 @@
|
||||
---
|
||||
name: code-map-memory
|
||||
description: 3-phase orchestrator: parse feature keyword → cli-explore-agent analyzes (Deep Scan dual-source) → orchestrator generates Mermaid docs + SKILL package (skips phase 2 if exists)
|
||||
argument-hint: "\"feature-keyword\" [--regenerate] [--tool <gemini|qwen>]"
|
||||
allowed-tools: SlashCommand(*), TodoWrite(*), Bash(*), Read(*), Write(*), Task(*)
|
||||
---
|
||||
|
||||
# Code Flow Mapping Generator
|
||||
|
||||
## Overview
|
||||
|
||||
**Pure Orchestrator with Agent Delegation**: Prepares context paths and delegates code flow analysis to specialized cli-explore-agent. Orchestrator transforms agent's JSON analysis into Mermaid documentation.
|
||||
|
||||
**Auto-Continue Workflow**: Runs fully autonomously once triggered. Each phase completes and automatically triggers the next phase.
|
||||
|
||||
**Execution Paths**:
|
||||
- **Full Path**: All 3 phases (no existing codemap OR `--regenerate` specified)
|
||||
- **Skip Path**: Phase 1 → Phase 3 (existing codemap found AND no `--regenerate` flag)
|
||||
- **Phase 3 Always Executes**: SKILL index is always generated or updated
|
||||
|
||||
**Agent Responsibility** (cli-explore-agent):
|
||||
- Deep code flow analysis using dual-source strategy (Bash + Gemini CLI)
|
||||
- Returns structured JSON with architecture, functions, data flow, conditionals, patterns
|
||||
- NO file writing - analysis only
|
||||
|
||||
**Orchestrator Responsibility**:
|
||||
- Provides feature keyword and analysis scope to agent
|
||||
- Transforms agent's JSON into Mermaid-enriched markdown documentation
|
||||
- Writes all files (5 docs + metadata.json + SKILL.md)
|
||||
|
||||
## Core Rules
|
||||
|
||||
1. **Start Immediately**: First action is TodoWrite initialization, second action is Phase 1 execution
|
||||
2. **Feature-Specific SKILL**: Each feature creates independent `.claude/skills/codemap-{feature}/` package
|
||||
3. **Specialized Agent**: Phase 2a uses cli-explore-agent for professional code analysis (Deep Scan mode)
|
||||
4. **Orchestrator Documentation**: Phase 2b transforms agent JSON into Mermaid markdown files
|
||||
5. **Auto-Continue**: After completing each phase, update TodoWrite and immediately execute next phase
|
||||
6. **No User Prompts**: Never ask user questions or wait for input between phases
|
||||
7. **Track Progress**: Update TodoWrite after EVERY phase completion before starting next phase
|
||||
8. **Multi-Level Detail**: Generate 4 levels: architecture → function → data → conditional
|
||||
|
||||
---
|
||||
|
||||
## 3-Phase Execution
|
||||
|
||||
### Phase 1: Parse Feature Keyword & Check Existing
|
||||
|
||||
**Goal**: Normalize feature keyword, check existing codemap, prepare for analysis
|
||||
|
||||
**Step 1: Parse Feature Keyword**
|
||||
```bash
|
||||
# Get feature keyword from argument
|
||||
FEATURE_KEYWORD="$1"
|
||||
|
||||
# Normalize: lowercase, spaces to hyphens
|
||||
normalized_feature=$(echo "$FEATURE_KEYWORD" | tr '[:upper:]' '[:lower:]' | tr ' ' '-' | tr '_' '-')
|
||||
|
||||
# Example: "User Authentication" → "user-authentication"
|
||||
# Example: "支付处理" → "支付处理" (keep non-ASCII)
|
||||
```
|
||||
|
||||
**Step 2: Set Tool Preference**
|
||||
```bash
|
||||
# Default to gemini unless --tool specified
|
||||
TOOL="${tool_flag:-gemini}"
|
||||
```
|
||||
|
||||
**Step 3: Check Existing Codemap**
|
||||
```bash
|
||||
# Define codemap directory
|
||||
CODEMAP_DIR=".claude/skills/codemap-${normalized_feature}"
|
||||
|
||||
# Check if codemap exists
|
||||
bash(test -d "$CODEMAP_DIR" && echo "exists" || echo "not_exists")
|
||||
|
||||
# Count existing files
|
||||
bash(find "$CODEMAP_DIR" -name "*.md" 2>/dev/null | wc -l || echo 0)
|
||||
```
|
||||
|
||||
**Step 4: Skip Decision**
|
||||
```javascript
|
||||
if (existing_files > 0 && !regenerate_flag) {
|
||||
SKIP_GENERATION = true
|
||||
message = "Codemap already exists, skipping Phase 2. Use --regenerate to force regeneration."
|
||||
} else if (regenerate_flag) {
|
||||
bash(rm -rf "$CODEMAP_DIR")
|
||||
SKIP_GENERATION = false
|
||||
message = "Regenerating codemap from scratch."
|
||||
} else {
|
||||
SKIP_GENERATION = false
|
||||
message = "No existing codemap found, generating new code flow analysis."
|
||||
}
|
||||
```
|
||||
|
||||
**Output Variables**:
|
||||
- `FEATURE_KEYWORD`: Original feature keyword
|
||||
- `normalized_feature`: Normalized feature name for directory
|
||||
- `CODEMAP_DIR`: `.claude/skills/codemap-{feature}`
|
||||
- `TOOL`: CLI tool to use (gemini or qwen)
|
||||
- `SKIP_GENERATION`: Boolean - whether to skip Phase 2
|
||||
|
||||
**TodoWrite**:
|
||||
- If skipping: Mark phase 1 completed, phase 2 completed, phase 3 in_progress
|
||||
- If not skipping: Mark phase 1 completed, phase 2 in_progress
|
||||
|
||||
---
|
||||
|
||||
### Phase 2: Code Flow Analysis & Documentation Generation
|
||||
|
||||
**Skip Condition**: Skipped if `SKIP_GENERATION = true`
|
||||
|
||||
**Goal**: Use cli-explore-agent for professional code analysis, then orchestrator generates Mermaid documentation
|
||||
|
||||
**Architecture**: Phase 2a (Agent Analysis) → Phase 2b (Orchestrator Documentation)
|
||||
|
||||
---
|
||||
|
||||
#### Phase 2a: cli-explore-agent Analysis
|
||||
|
||||
**Purpose**: Leverage specialized cli-explore-agent for deep code flow analysis
|
||||
|
||||
**Agent Task Specification**:
|
||||
|
||||
```
|
||||
Task(
|
||||
subagent_type: "cli-explore-agent",
|
||||
description: "Analyze code flow: {FEATURE_KEYWORD}",
|
||||
prompt: "
|
||||
Perform Deep Scan analysis for feature: {FEATURE_KEYWORD}
|
||||
|
||||
**Analysis Mode**: deep-scan (Dual-source: Bash structural scan + Gemini semantic analysis)
|
||||
|
||||
**Analysis Objectives**:
|
||||
1. **Module Architecture**: Identify high-level module organization, interactions, and entry points
|
||||
2. **Function Call Chains**: Trace execution paths, call sequences, and parameter flows
|
||||
3. **Data Transformations**: Map data structure changes and transformation stages
|
||||
4. **Conditional Paths**: Document decision trees, branches, and error handling strategies
|
||||
5. **Design Patterns**: Discover architectural patterns and extract design intent
|
||||
|
||||
**Scope**:
|
||||
- Feature: {FEATURE_KEYWORD}
|
||||
- CLI Tool: {TOOL} (gemini-2.5-pro or qwen coder-model)
|
||||
- File Discovery: MCP Code Index (preferred) + rg fallback
|
||||
- Target: 5-15 most relevant files
|
||||
|
||||
**MANDATORY FIRST STEP**:
|
||||
Read: ~/.claude/workflows/cli-templates/schemas/codemap-json-schema.json
|
||||
|
||||
**Output**: Return JSON following schema exactly. NO FILE WRITING - return JSON analysis only.
|
||||
|
||||
**Critical Requirements**:
|
||||
- Use Deep Scan mode: Bash (Phase 1 - precise locations) + Gemini CLI (Phase 2 - semantic understanding) + Synthesis (Phase 3 - merge with attribution)
|
||||
- Focus exclusively on {FEATURE_KEYWORD} feature flow
|
||||
- Include file:line references for ALL findings
|
||||
- Extract design intent from code structure and comments
|
||||
- NO FILE WRITING - return JSON analysis only
|
||||
- Handle tool failures gracefully (Gemini → Qwen fallback, MCP → rg fallback)
|
||||
"
|
||||
)
|
||||
```
|
||||
|
||||
**Agent Output**: JSON analysis result with architecture, functions, data flow, conditionals, and patterns
|
||||
|
||||
---
|
||||
|
||||
#### Phase 2b: Orchestrator Documentation Generation
|
||||
|
||||
**Purpose**: Transform cli-explore-agent JSON into Mermaid-enriched documentation
|
||||
|
||||
**Input**: Agent's JSON analysis result
|
||||
|
||||
**Process**:
|
||||
|
||||
1. **Parse Agent Analysis**:
|
||||
```javascript
|
||||
const analysis = JSON.parse(agentResult)
|
||||
const { feature, files_analyzed, architecture, function_calls, data_flow, conditional_logic, design_patterns } = analysis
|
||||
```
|
||||
|
||||
2. **Generate Mermaid Diagrams from Structured Data**:
|
||||
|
||||
**a) architecture-flow.md** (~3K tokens):
|
||||
```javascript
|
||||
// Convert architecture.modules + architecture.interactions → Mermaid graph TD
|
||||
const architectureMermaid = `
|
||||
graph TD
|
||||
${architecture.modules.map(m => ` ${m.name}[${m.name}]`).join('\n')}
|
||||
${architecture.interactions.map(i => ` ${i.from} -->|${i.type}| ${i.to}`).join('\n')}
|
||||
`
|
||||
|
||||
Write({
|
||||
file_path: `${CODEMAP_DIR}/architecture-flow.md`,
|
||||
content: `---
|
||||
feature: ${feature}
|
||||
level: architecture
|
||||
detail: high-level module interactions
|
||||
---
|
||||
# Architecture Flow: ${feature}
|
||||
|
||||
## Overview
|
||||
${architecture.overview}
|
||||
|
||||
## Module Architecture
|
||||
${architecture.modules.map(m => `### ${m.name}\n- **File**: ${m.file}\n- **Role**: ${m.responsibility}\n- **Dependencies**: ${m.dependencies.join(', ')}`).join('\n\n')}
|
||||
|
||||
## Flow Diagram
|
||||
\`\`\`mermaid
|
||||
${architectureMermaid}
|
||||
\`\`\`
|
||||
|
||||
## Key Interactions
|
||||
${architecture.interactions.map(i => `- **${i.from} → ${i.to}**: ${i.description}`).join('\n')}
|
||||
|
||||
## Entry Points
|
||||
${architecture.entry_points.map(e => `- **${e.function}** (${e.file}): ${e.description}`).join('\n')}
|
||||
`
|
||||
})
|
||||
```
|
||||
|
||||
**b) function-calls.md** (~5K tokens):
|
||||
```javascript
|
||||
// Convert function_calls.sequences → Mermaid sequenceDiagram
|
||||
const sequenceMermaid = `
|
||||
sequenceDiagram
|
||||
${function_calls.sequences.map(s => ` ${s.from}->>${s.to}: ${s.method}`).join('\n')}
|
||||
`
|
||||
|
||||
Write({
|
||||
file_path: `${CODEMAP_DIR}/function-calls.md`,
|
||||
content: `---
|
||||
feature: ${feature}
|
||||
level: function
|
||||
detail: function-level call sequences
|
||||
---
|
||||
# Function Call Chains: ${feature}
|
||||
|
||||
## Call Sequence Diagram
|
||||
\`\`\`mermaid
|
||||
${sequenceMermaid}
|
||||
\`\`\`
|
||||
|
||||
## Detailed Call Chains
|
||||
${function_calls.call_chains.map(chain => `
|
||||
### Chain ${chain.chain_id}: ${chain.description}
|
||||
${chain.sequence.map(fn => `- **${fn.function}** (${fn.file})\n - Calls: ${fn.calls.join(', ')}`).join('\n')}
|
||||
`).join('\n')}
|
||||
|
||||
## Parameters & Returns
|
||||
${function_calls.sequences.map(s => `- **${s.method}** → Returns: ${s.returns || 'void'}`).join('\n')}
|
||||
`
|
||||
})
|
||||
```
|
||||
|
||||
**c) data-flow.md** (~4K tokens):
|
||||
```javascript
|
||||
// Convert data_flow.transformations → Mermaid flowchart LR
|
||||
const dataFlowMermaid = `
|
||||
flowchart LR
|
||||
${data_flow.transformations.map((t, i) => ` Stage${i}[${t.from}] -->|${t.transformer}| Stage${i+1}[${t.to}]`).join('\n')}
|
||||
`
|
||||
|
||||
Write({
|
||||
file_path: `${CODEMAP_DIR}/data-flow.md`,
|
||||
content: `---
|
||||
feature: ${feature}
|
||||
level: data
|
||||
detail: data structure transformations
|
||||
---
|
||||
# Data Flow: ${feature}
|
||||
|
||||
## Data Transformation Diagram
|
||||
\`\`\`mermaid
|
||||
${dataFlowMermaid}
|
||||
\`\`\`
|
||||
|
||||
## Data Structures
|
||||
${data_flow.structures.map(s => `### ${s.name} (${s.stage})\n\`\`\`json\n${JSON.stringify(s.shape, null, 2)}\n\`\`\``).join('\n\n')}
|
||||
|
||||
## Transformations
|
||||
${data_flow.transformations.map(t => `- **${t.from} → ${t.to}** via \`${t.transformer}\` (${t.file})`).join('\n')}
|
||||
`
|
||||
})
|
||||
```
|
||||
|
||||
**d) conditional-paths.md** (~4K tokens):
|
||||
```javascript
|
||||
// Convert conditional_logic.branches → Mermaid flowchart TD
|
||||
const conditionalMermaid = `
|
||||
flowchart TD
|
||||
Start[Entry Point]
|
||||
${conditional_logic.branches.map((b, i) => `
|
||||
Start --> Check${i}{${b.condition}}
|
||||
Check${i} -->|Yes| Path${i}A[${b.true_path}]
|
||||
Check${i} -->|No| Path${i}B[${b.false_path}]
|
||||
`).join('\n')}
|
||||
`
|
||||
|
||||
Write({
|
||||
file_path: `${CODEMAP_DIR}/conditional-paths.md`,
|
||||
content: `---
|
||||
feature: ${feature}
|
||||
level: conditional
|
||||
detail: decision trees and error paths
|
||||
---
|
||||
# Conditional Paths: ${feature}
|
||||
|
||||
## Decision Tree
|
||||
\`\`\`mermaid
|
||||
${conditionalMermaid}
|
||||
\`\`\`
|
||||
|
||||
## Branch Conditions
|
||||
${conditional_logic.branches.map(b => `- **${b.condition}** (${b.file})\n - True: ${b.true_path}\n - False: ${b.false_path}`).join('\n')}
|
||||
|
||||
## Error Handling
|
||||
${conditional_logic.error_handling.map(e => `- **${e.error_type}**: Handler \`${e.handler}\` (${e.file}) - Recovery: ${e.recovery}`).join('\n')}
|
||||
`
|
||||
})
|
||||
```
|
||||
|
||||
**e) complete-flow.md** (~8K tokens):
|
||||
```javascript
|
||||
// Integrate all Mermaid diagrams
|
||||
Write({
|
||||
file_path: `${CODEMAP_DIR}/complete-flow.md`,
|
||||
content: `---
|
||||
feature: ${feature}
|
||||
level: complete
|
||||
detail: integrated multi-level view
|
||||
---
|
||||
# Complete Flow: ${feature}
|
||||
|
||||
## Integrated Flow Diagram
|
||||
\`\`\`mermaid
|
||||
graph TB
|
||||
subgraph Architecture
|
||||
${architecture.modules.map(m => ` ${m.name}[${m.name}]`).join('\n')}
|
||||
end
|
||||
|
||||
subgraph "Function Calls"
|
||||
${function_calls.call_chains[0]?.sequence.map(fn => ` ${fn.function}`).join('\n') || ''}
|
||||
end
|
||||
|
||||
subgraph "Data Flow"
|
||||
${data_flow.structures.map(s => ` ${s.name}[${s.name}]`).join('\n')}
|
||||
end
|
||||
\`\`\`
|
||||
|
||||
## Complete Trace
|
||||
[Comprehensive end-to-end documentation combining all analysis layers]
|
||||
|
||||
## Design Patterns Identified
|
||||
${design_patterns.map(p => `- **${p.pattern}** in ${p.location}: ${p.description}`).join('\n')}
|
||||
|
||||
## Recommendations
|
||||
${analysis.recommendations.map(r => `- ${r}`).join('\n')}
|
||||
|
||||
## Cross-References
|
||||
- [Architecture Flow](./architecture-flow.md) - High-level module structure
|
||||
- [Function Calls](./function-calls.md) - Detailed call chains
|
||||
- [Data Flow](./data-flow.md) - Data transformation stages
|
||||
- [Conditional Paths](./conditional-paths.md) - Decision trees and error handling
|
||||
`
|
||||
})
|
||||
```
|
||||
|
||||
3. **Write metadata.json**:
|
||||
```javascript
|
||||
Write({
|
||||
file_path: `${CODEMAP_DIR}/metadata.json`,
|
||||
content: JSON.stringify({
|
||||
feature: feature,
|
||||
normalized_name: normalized_feature,
|
||||
generated_at: new Date().toISOString(),
|
||||
tool_used: analysis.analysis_metadata.tool_used,
|
||||
files_analyzed: files_analyzed.map(f => f.file),
|
||||
analysis_summary: {
|
||||
total_files: files_analyzed.length,
|
||||
modules_traced: architecture.modules.length,
|
||||
functions_traced: function_calls.call_chains.reduce((sum, c) => sum + c.sequence.length, 0),
|
||||
patterns_discovered: design_patterns.length
|
||||
}
|
||||
}, null, 2)
|
||||
})
|
||||
```
|
||||
|
||||
4. **Report Phase 2 Completion**:
|
||||
```
|
||||
Phase 2 Complete: Code flow analysis and documentation generated
|
||||
|
||||
- Agent Analysis: cli-explore-agent with {TOOL}
|
||||
- Files Analyzed: {count}
|
||||
- Documentation Generated: 5 markdown files + metadata.json
|
||||
- Location: {CODEMAP_DIR}
|
||||
```
|
||||
|
||||
**Completion Criteria**:
|
||||
- cli-explore-agent task completed successfully with JSON result
|
||||
- 5 documentation files written with valid Mermaid diagrams
|
||||
- metadata.json written with analysis summary
|
||||
- All files properly formatted and cross-referenced
|
||||
|
||||
**TodoWrite**: Mark phase 2 completed, phase 3 in_progress
|
||||
|
||||
---
|
||||
|
||||
### Phase 3: Generate SKILL.md Index
|
||||
|
||||
**Note**: This phase **ALWAYS executes** - generates or updates the SKILL index.
|
||||
|
||||
**Goal**: Read generated flow documentation and create SKILL.md index with progressive loading
|
||||
|
||||
**Steps**:
|
||||
|
||||
1. **Verify Generated Files**:
|
||||
```bash
|
||||
bash(find "{CODEMAP_DIR}" -name "*.md" -type f | sort)
|
||||
```
|
||||
|
||||
2. **Read metadata.json**:
|
||||
```javascript
|
||||
Read({CODEMAP_DIR}/metadata.json)
|
||||
// Extract: feature, normalized_name, files_analyzed, analysis_summary
|
||||
```
|
||||
|
||||
3. **Read File Headers** (optional, first 30 lines):
|
||||
```javascript
|
||||
Read({CODEMAP_DIR}/architecture-flow.md, limit: 30)
|
||||
Read({CODEMAP_DIR}/function-calls.md, limit: 30)
|
||||
// Extract overview and diagram counts
|
||||
```
|
||||
|
||||
4. **Generate SKILL.md Index**:
|
||||
|
||||
Template structure:
|
||||
```yaml
|
||||
---
|
||||
name: codemap-{normalized_feature}
|
||||
description: Code flow mapping for {FEATURE_KEYWORD} feature (located at {project_path}). Load this SKILL when analyzing, tracing, or understanding {FEATURE_KEYWORD} execution flow, especially when no relevant context exists in memory.
|
||||
version: 1.0.0
|
||||
generated_at: {ISO_TIMESTAMP}
|
||||
---
|
||||
# Code Flow Map: {FEATURE_KEYWORD}
|
||||
|
||||
## Feature: `{FEATURE_KEYWORD}`
|
||||
|
||||
**Analysis Date**: {DATE}
|
||||
**Tool Used**: {TOOL}
|
||||
**Files Analyzed**: {COUNT}
|
||||
|
||||
## Progressive Loading
|
||||
|
||||
### Level 0: Quick Overview (~2K tokens)
|
||||
- [Architecture Flow](./architecture-flow.md) - High-level module interactions
|
||||
|
||||
### Level 1: Core Flows (~10K tokens)
|
||||
- [Architecture Flow](./architecture-flow.md) - Module architecture
|
||||
- [Function Calls](./function-calls.md) - Function call chains
|
||||
|
||||
### Level 2: Complete Analysis (~20K tokens)
|
||||
- [Architecture Flow](./architecture-flow.md)
|
||||
- [Function Calls](./function-calls.md)
|
||||
- [Data Flow](./data-flow.md) - Data transformations
|
||||
|
||||
### Level 3: Deep Dive (~30K tokens)
|
||||
- [Architecture Flow](./architecture-flow.md)
|
||||
- [Function Calls](./function-calls.md)
|
||||
- [Data Flow](./data-flow.md)
|
||||
- [Conditional Paths](./conditional-paths.md) - Branches and error handling
|
||||
- [Complete Flow](./complete-flow.md) - Integrated comprehensive view
|
||||
|
||||
## Usage
|
||||
|
||||
Load this SKILL package when:
|
||||
- Analyzing {FEATURE_KEYWORD} implementation
|
||||
- Tracing execution flow for debugging
|
||||
- Understanding code dependencies
|
||||
- Planning refactoring or enhancements
|
||||
|
||||
## Analysis Summary
|
||||
|
||||
- **Modules Traced**: {modules_traced}
|
||||
- **Functions Traced**: {functions_traced}
|
||||
- **Files Analyzed**: {total_files}
|
||||
|
||||
## Mermaid Diagrams Included
|
||||
|
||||
- Architecture flow diagram (graph TD)
|
||||
- Function call sequence diagram (sequenceDiagram)
|
||||
- Data transformation flowchart (flowchart LR)
|
||||
- Conditional decision tree (flowchart TD)
|
||||
- Complete integrated diagram (graph TB)
|
||||
```
|
||||
|
||||
5. **Write SKILL.md**:
|
||||
```javascript
|
||||
Write({
|
||||
file_path: `{CODEMAP_DIR}/SKILL.md`,
|
||||
content: generatedIndexMarkdown
|
||||
})
|
||||
```
|
||||
|
||||
**Completion Criteria**:
|
||||
- SKILL.md index written
|
||||
- All documentation files verified
|
||||
- Progressive loading levels (0-3) properly structured
|
||||
- Mermaid diagram references included
|
||||
|
||||
**TodoWrite**: Mark phase 3 completed
|
||||
|
||||
**Final Report**:
|
||||
```
|
||||
Code Flow Mapping Complete
|
||||
|
||||
Feature: {FEATURE_KEYWORD}
|
||||
Location: .claude/skills/codemap-{normalized_feature}/
|
||||
|
||||
Files Generated:
|
||||
- SKILL.md (index)
|
||||
- architecture-flow.md (with Mermaid diagram)
|
||||
- function-calls.md (with Mermaid sequence diagram)
|
||||
- data-flow.md (with Mermaid flowchart)
|
||||
- conditional-paths.md (with Mermaid decision tree)
|
||||
- complete-flow.md (with integrated Mermaid diagram)
|
||||
- metadata.json
|
||||
|
||||
Analysis:
|
||||
- Files analyzed: {count}
|
||||
- Modules traced: {count}
|
||||
- Functions traced: {count}
|
||||
|
||||
Usage: Skill(command: "codemap-{normalized_feature}")
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Implementation Details
|
||||
|
||||
### TodoWrite Patterns
|
||||
|
||||
**Initialization** (Before Phase 1):
|
||||
```javascript
|
||||
TodoWrite({todos: [
|
||||
{"content": "Parse feature keyword and check existing", "status": "in_progress", "activeForm": "Parsing feature keyword"},
|
||||
{"content": "Agent analyzes code flow and generates files", "status": "pending", "activeForm": "Analyzing code flow"},
|
||||
{"content": "Generate SKILL.md index", "status": "pending", "activeForm": "Generating SKILL index"}
|
||||
]})
|
||||
```
|
||||
|
||||
**Full Path** (SKIP_GENERATION = false):
|
||||
```javascript
|
||||
// After Phase 1
|
||||
TodoWrite({todos: [
|
||||
{"content": "Parse feature keyword and check existing", "status": "completed", ...},
|
||||
{"content": "Agent analyzes code flow and generates files", "status": "in_progress", ...},
|
||||
{"content": "Generate SKILL.md index", "status": "pending", ...}
|
||||
]})
|
||||
|
||||
// After Phase 2
|
||||
TodoWrite({todos: [
|
||||
{"content": "Parse feature keyword and check existing", "status": "completed", ...},
|
||||
{"content": "Agent analyzes code flow and generates files", "status": "completed", ...},
|
||||
{"content": "Generate SKILL.md index", "status": "in_progress", ...}
|
||||
]})
|
||||
|
||||
// After Phase 3
|
||||
TodoWrite({todos: [
|
||||
{"content": "Parse feature keyword and check existing", "status": "completed", ...},
|
||||
{"content": "Agent analyzes code flow and generates files", "status": "completed", ...},
|
||||
{"content": "Generate SKILL.md index", "status": "completed", ...}
|
||||
]})
|
||||
```
|
||||
|
||||
**Skip Path** (SKIP_GENERATION = true):
|
||||
```javascript
|
||||
// After Phase 1 (skip Phase 2)
|
||||
TodoWrite({todos: [
|
||||
{"content": "Parse feature keyword and check existing", "status": "completed", ...},
|
||||
{"content": "Agent analyzes code flow and generates files", "status": "completed", ...}, // Skipped
|
||||
{"content": "Generate SKILL.md index", "status": "in_progress", ...}
|
||||
]})
|
||||
```
|
||||
|
||||
### Execution Flow
|
||||
|
||||
**Full Path**:
|
||||
```
|
||||
User → TodoWrite Init → Phase 1 (parse) → Phase 2 (agent analyzes) → Phase 3 (write index) → Report
|
||||
```
|
||||
|
||||
**Skip Path**:
|
||||
```
|
||||
User → TodoWrite Init → Phase 1 (detect existing) → Phase 3 (update index) → Report
|
||||
```
|
||||
|
||||
### Error Handling
|
||||
|
||||
**Phase 1 Errors**:
|
||||
- Empty feature keyword: Report error, ask user to provide feature description
|
||||
- Invalid characters: Normalize and continue
|
||||
|
||||
**Phase 2 Errors (Agent)**:
|
||||
- Agent task fails: Retry once, report if fails again
|
||||
- No files discovered: Warn user, ask for more specific feature keyword
|
||||
- CLI failures: Agent handles internally with retries
|
||||
- Invalid Mermaid syntax: Agent validates before writing
|
||||
|
||||
**Phase 3 Errors**:
|
||||
- Write failures: Report which files failed
|
||||
- Missing files: Note in SKILL.md, suggest regeneration
|
||||
|
||||
---
|
||||
|
||||
## Parameters
|
||||
|
||||
```bash
|
||||
/memory:code-map-memory "feature-keyword" [--regenerate] [--tool <gemini|qwen>]
|
||||
```
|
||||
|
||||
**Arguments**:
|
||||
- **"feature-keyword"**: Feature or flow to analyze (required)
|
||||
- Examples: `"user authentication"`, `"payment processing"`, `"数据导入流程"`
|
||||
- Can be English, Chinese, or mixed
|
||||
- Spaces and underscores normalized to hyphens
|
||||
- **--regenerate**: Force regenerate existing codemap (deletes and recreates)
|
||||
- **--tool**: CLI tool for analysis (default: gemini)
|
||||
- `gemini`: Comprehensive flow analysis with gemini-2.5-pro
|
||||
- `qwen`: Alternative with coder-model
|
||||
|
||||
---
|
||||
|
||||
## Examples
|
||||
|
||||
**Generated File Structure** (for all examples):
|
||||
```
|
||||
.claude/skills/codemap-{feature}/
|
||||
├── SKILL.md # Index (Phase 3)
|
||||
├── architecture-flow.md # Agent (Phase 2) - High-level flow
|
||||
├── function-calls.md # Agent (Phase 2) - Function chains
|
||||
├── data-flow.md # Agent (Phase 2) - Data transformations
|
||||
├── conditional-paths.md # Agent (Phase 2) - Branches & errors
|
||||
├── complete-flow.md # Agent (Phase 2) - Integrated view
|
||||
└── metadata.json # Agent (Phase 2)
|
||||
```
|
||||
|
||||
### Example 1: User Authentication Flow
|
||||
|
||||
```bash
|
||||
/memory:code-map-memory "user authentication"
|
||||
```
|
||||
|
||||
**Workflow**:
|
||||
1. Phase 1: Normalizes to "user-authentication", checks existing codemap
|
||||
2. Phase 2: Agent discovers auth-related files, executes CLI analysis, generates 5 flow docs with Mermaid
|
||||
3. Phase 3: Generates SKILL.md index with progressive loading
|
||||
|
||||
**Output**: `.claude/skills/codemap-user-authentication/` with 6 files + metadata
|
||||
|
||||
|
||||
### Example 3: Regenerate with Qwen
|
||||
|
||||
```bash
|
||||
/memory:code-map-memory "payment processing" --regenerate --tool qwen
|
||||
```
|
||||
|
||||
**Workflow**:
|
||||
1. Phase 1: Deletes existing codemap due to --regenerate
|
||||
2. Phase 2: Agent uses qwen with coder-model for fresh analysis
|
||||
3. Phase 3: Generates updated SKILL.md
|
||||
|
||||
---
|
||||
|
||||
|
||||
## Architecture
|
||||
|
||||
```
|
||||
code-map-memory (orchestrator)
|
||||
├─ Phase 1: Parse & Check (bash commands, skip decision)
|
||||
├─ Phase 2: Code Analysis & Documentation (skippable)
|
||||
│ ├─ Phase 2a: cli-explore-agent Analysis
|
||||
│ │ └─ Deep Scan: Bash structural + Gemini semantic → JSON
|
||||
│ └─ Phase 2b: Orchestrator Documentation
|
||||
│ └─ Transform JSON → 5 Mermaid markdown files + metadata.json
|
||||
└─ Phase 3: Write SKILL.md (index generation, always runs)
|
||||
|
||||
Output: .claude/skills/codemap-{feature}/
|
||||
```
|
||||
@@ -1,615 +0,0 @@
|
||||
---
|
||||
name: docs
|
||||
description: Plan documentation workflow with dynamic grouping (≤10 docs/task), generates IMPL tasks for parallel module trees, README, ARCHITECTURE, and HTTP API docs
|
||||
argument-hint: "[path] [--tool <gemini|qwen|codex>] [--mode <full|partial>] [--cli-execute]"
|
||||
---
|
||||
|
||||
# Documentation Workflow (/memory:docs)
|
||||
|
||||
## Overview
|
||||
Lightweight planner that analyzes project structure, decomposes documentation work into tasks, and generates execution plans. Does NOT generate documentation content itself - delegates to doc-generator agent.
|
||||
|
||||
**Execution Strategy**:
|
||||
- **Dynamic Task Grouping**: Level 1 tasks grouped by top-level directories with document count limit
|
||||
- **Primary constraint**: Each task generates ≤10 documents (API.md + README.md count)
|
||||
- **Optimization goal**: Prefer grouping 2 top-level directories per task for context sharing
|
||||
- **Conflict resolution**: If 2 dirs exceed 10 docs, reduce to 1 dir/task; if 1 dir exceeds 10 docs, split by subdirectories
|
||||
- **Context benefit**: Same-task directories analyzed together via single Gemini call
|
||||
- **Parallel Execution**: Multiple Level 1 tasks execute concurrently for faster completion
|
||||
- **Pre-computed Analysis**: Phase 2 performs unified analysis once, stored in `.process/` for reuse
|
||||
- **Efficient Data Loading**: All existing docs loaded once in Phase 2, shared across tasks
|
||||
|
||||
**Path Mirroring**: Documentation structure mirrors source code under `.workflow/docs/{project_name}/`
|
||||
- Example: `my_app/src/core/` → `.workflow/docs/my_app/src/core/API.md`
|
||||
|
||||
**Two Execution Modes**:
|
||||
- **Default (Agent Mode)**: CLI analyzes in `pre_analysis` (MODE=analysis), agent writes docs
|
||||
- **--cli-execute (CLI Mode)**: CLI generates docs in `implementation_approach` (MODE=write), agent executes CLI commands
|
||||
|
||||
## Path Mirroring Strategy
|
||||
|
||||
**Principle**: Documentation structure **mirrors** source code structure under project-specific directory.
|
||||
|
||||
| Source Path | Project Name | Documentation Path |
|
||||
|------------|--------------|-------------------|
|
||||
| `my_app/src/core/` | `my_app` | `.workflow/docs/my_app/src/core/API.md` |
|
||||
| `my_app/src/modules/auth/` | `my_app` | `.workflow/docs/my_app/src/modules/auth/API.md` |
|
||||
| `another_project/lib/utils/` | `another_project` | `.workflow/docs/another_project/lib/utils/API.md` |
|
||||
|
||||
|
||||
## Parameters
|
||||
|
||||
```bash
|
||||
/memory:docs [path] [--tool <gemini|qwen|codex>] [--mode <full|partial>] [--cli-execute]
|
||||
```
|
||||
|
||||
- **path**: Source directory to analyze (default: current directory)
|
||||
- Specifies the source code directory to be documented
|
||||
- Documentation is generated in a separate `.workflow/docs/{project_name}/` directory at the workspace root, **not** within the source `path` itself
|
||||
- The source path's structure is mirrored within the project-specific documentation folder
|
||||
- Example: analyzing `src/modules` produces documentation at `.workflow/docs/{project_name}/src/modules/`
|
||||
- **--mode**: Documentation generation mode (default: full)
|
||||
- `full`: Complete documentation (modules + README + ARCHITECTURE + EXAMPLES + HTTP API)
|
||||
- `partial`: Module documentation only (API.md + README.md)
|
||||
- **--tool**: CLI tool selection (default: gemini)
|
||||
- `gemini`: Comprehensive documentation, pattern recognition
|
||||
- `qwen`: Architecture analysis, system design focus
|
||||
- `codex`: Implementation validation, code quality
|
||||
- **--cli-execute**: Enable CLI-based documentation generation (optional)
|
||||
|
||||
## Planning Workflow
|
||||
|
||||
### Phase 1: Initialize Session
|
||||
|
||||
```bash
|
||||
# Get target path, project name, and root
|
||||
bash(pwd && basename "$(pwd)" && git rev-parse --show-toplevel 2>/dev/null || pwd && date +%Y%m%d-%H%M%S)
|
||||
```
|
||||
|
||||
```javascript
|
||||
// Create docs session (type: docs)
|
||||
SlashCommand(command="/workflow:session:start --type docs --new \"{project_name}-docs-{timestamp}\"")
|
||||
// Parse output to get sessionId
|
||||
```
|
||||
|
||||
```bash
|
||||
# Update workflow-session.json with docs-specific fields
|
||||
bash(jq '. + {"target_path":"{target_path}","project_root":"{project_root}","project_name":"{project_name}","mode":"full","tool":"gemini","cli_execute":false}' .workflow/active/{sessionId}/workflow-session.json > tmp.json && mv tmp.json .workflow/active/{sessionId}/workflow-session.json)
|
||||
```
|
||||
|
||||
### Phase 2: Analyze Structure
|
||||
|
||||
**Smart filter**: Auto-detect and skip tests/build/config/vendor based on project tech stack.
|
||||
|
||||
**Commands** (collect data with simple bash):
|
||||
|
||||
```bash
|
||||
# 1. Run folder analysis
|
||||
bash(ccw tool exec get_modules_by_depth '{}' | ccw tool exec classify_folders '{}')
|
||||
|
||||
# 2. Get top-level directories (first 2 path levels)
|
||||
bash(ccw tool exec get_modules_by_depth '{}' | ccw tool exec classify_folders '{}' | awk -F'|' '{print $1}' | sed 's|^\./||' | awk -F'/' '{if(NF>=2) print $1"/"$2; else if(NF==1) print $1}' | sort -u)
|
||||
|
||||
# 3. Find existing docs (if directory exists)
|
||||
bash(if [ -d .workflow/docs/\${project_name} ]; then find .workflow/docs/\${project_name} -type f -name "*.md" ! -path "*/README.md" ! -path "*/ARCHITECTURE.md" ! -path "*/EXAMPLES.md" ! -path "*/api/*" 2>/dev/null; fi)
|
||||
|
||||
# 4. Read existing docs content (if files exist)
|
||||
bash(if [ -d .workflow/docs/\${project_name} ]; then find .workflow/docs/\${project_name} -type f -name "*.md" ! -path "*/README.md" ! -path "*/ARCHITECTURE.md" ! -path "*/EXAMPLES.md" ! -path "*/api/*" 2>/dev/null | xargs cat 2>/dev/null; fi)
|
||||
```
|
||||
|
||||
**Data Processing**: Parse bash outputs, calculate statistics, use **Write tool** to create `${session_dir}/.process/doc-planning-data.json` with structure:
|
||||
|
||||
```json
|
||||
{
|
||||
"metadata": {
|
||||
"generated_at": "2025-11-03T16:57:30.469669",
|
||||
"project_name": "project_name",
|
||||
"project_root": "/path/to/project"
|
||||
},
|
||||
"folder_analysis": [
|
||||
{"path": "./src/core", "type": "code", "code_count": 5, "dirs_count": 2}
|
||||
],
|
||||
"top_level_dirs": ["src/modules", "lib/core"],
|
||||
"existing_docs": {
|
||||
"file_list": [".workflow/docs/project/src/core/API.md"],
|
||||
"content": "... existing docs content ..."
|
||||
},
|
||||
"unified_analysis": [],
|
||||
"statistics": {
|
||||
"total": 15,
|
||||
"code": 8,
|
||||
"navigation": 7,
|
||||
"top_level": 3
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
**Then** use **Edit tool** to update `workflow-session.json` adding analysis field.
|
||||
|
||||
**Output**: Single `doc-planning-data.json` with all analysis data (no temp files or Python scripts).
|
||||
|
||||
**Auto-skipped**: Tests (`**/test/**`, `**/*.test.*`), Build (`**/node_modules/**`, `**/dist/**`), Config (root-level files), Vendor directories.
|
||||
|
||||
### Phase 3: Detect Update Mode
|
||||
|
||||
**Commands**:
|
||||
|
||||
```bash
|
||||
# Count existing docs from doc-planning-data.json
|
||||
bash(cat .workflow/active/WFS-docs-{timestamp}/.process/doc-planning-data.json | jq '.existing_docs.file_list | length')
|
||||
```
|
||||
|
||||
**Data Processing**: Use count result, then use **Edit tool** to update `workflow-session.json`:
|
||||
- Add `"update_mode": "update"` if count > 0, else `"create"`
|
||||
- Add `"existing_docs": <count>`
|
||||
|
||||
### Phase 4: Decompose Tasks
|
||||
|
||||
**Task Hierarchy** (Dynamic based on document count):
|
||||
|
||||
```
|
||||
Small Projects (total ≤10 docs):
|
||||
Level 1: IMPL-001 (all directories in single task, shared context)
|
||||
Level 2: IMPL-002 (README, full mode only)
|
||||
Level 3: IMPL-003 (ARCHITECTURE+EXAMPLES), IMPL-004 (HTTP API, optional)
|
||||
|
||||
Medium Projects (Example: 7 top-level dirs, 18 total docs):
|
||||
Step 1: Count docs per top-level dir
|
||||
├─ dir1: 3 docs, dir2: 4 docs → Group 1 (7 docs)
|
||||
├─ dir3: 5 docs, dir4: 3 docs → Group 2 (8 docs)
|
||||
├─ dir5: 2 docs → Group 3 (2 docs, can add more)
|
||||
|
||||
Step 2: Create tasks with ≤10 docs constraint
|
||||
Level 1: IMPL-001 to IMPL-003 (parallel groups)
|
||||
├─ IMPL-001: Group 1 (dir1 + dir2, 7 docs, shared context)
|
||||
├─ IMPL-002: Group 2 (dir3 + dir4, 8 docs, shared context)
|
||||
└─ IMPL-003: Group 3 (remaining dirs, ≤10 docs)
|
||||
Level 2: IMPL-004 (README, depends on Level 1, full mode only)
|
||||
Level 3: IMPL-005 (ARCHITECTURE+EXAMPLES), IMPL-006 (HTTP API, optional)
|
||||
|
||||
Large Projects (single dir >10 docs):
|
||||
Step 1: Detect oversized directory
|
||||
└─ src/modules/: 15 subdirs → 30 docs (exceeds limit)
|
||||
|
||||
Step 2: Split by subdirectories
|
||||
Level 1: IMPL-001 to IMPL-003 (split oversized dir)
|
||||
├─ IMPL-001: src/modules/ subdirs 1-5 (10 docs)
|
||||
├─ IMPL-002: src/modules/ subdirs 6-10 (10 docs)
|
||||
└─ IMPL-003: src/modules/ subdirs 11-15 (10 docs)
|
||||
```
|
||||
|
||||
**Grouping Algorithm**:
|
||||
1. Count total docs for each top-level directory
|
||||
2. Try grouping 2 directories (optimization for context sharing)
|
||||
3. If group exceeds 10 docs, split to 1 dir/task
|
||||
4. If single dir exceeds 10 docs, split by subdirectories
|
||||
5. Create parallel Level 1 tasks with ≤10 docs each
|
||||
|
||||
|
||||
**Commands**:
|
||||
|
||||
```bash
|
||||
# 1. Get top-level directories from doc-planning-data.json
|
||||
bash(cat .workflow/active/WFS-docs-{timestamp}/.process/doc-planning-data.json | jq -r '.top_level_dirs[]')
|
||||
|
||||
# 2. Get mode from workflow-session.json
|
||||
bash(cat .workflow/active/WFS-docs-{timestamp}/workflow-session.json | jq -r '.mode // "full"')
|
||||
|
||||
# 3. Check for HTTP API
|
||||
bash(grep -r "router\.|@Get\|@Post" src/ 2>/dev/null && echo "API_FOUND" || echo "NO_API")
|
||||
```
|
||||
|
||||
**Data Processing**:
|
||||
1. Count documents for each top-level directory (from folder_analysis):
|
||||
- Code folders: 2 docs each (API.md + README.md)
|
||||
- Navigation folders: 1 doc each (README.md only)
|
||||
2. Apply grouping algorithm with ≤10 docs constraint:
|
||||
- Try grouping 2 directories, calculate total docs
|
||||
- If total ≤10 docs: create group
|
||||
- If total >10 docs: split to 1 dir/group or subdivide
|
||||
- If single dir >10 docs: split by subdirectories
|
||||
3. Use **Edit tool** to update `doc-planning-data.json` adding groups field:
|
||||
```json
|
||||
"groups": {
|
||||
"count": 3,
|
||||
"assignments": [
|
||||
{"group_id": "001", "directories": ["src/modules", "src/utils"], "doc_count": 5},
|
||||
{"group_id": "002", "directories": ["lib/core"], "doc_count": 6},
|
||||
{"group_id": "003", "directories": ["lib/helpers"], "doc_count": 3}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
**Task ID Calculation**:
|
||||
```bash
|
||||
group_count=$(jq '.groups.count' .workflow/active/WFS-docs-{timestamp}/.process/doc-planning-data.json)
|
||||
readme_id=$((group_count + 1)) # Next ID after groups
|
||||
arch_id=$((group_count + 2))
|
||||
api_id=$((group_count + 3))
|
||||
```
|
||||
|
||||
### Phase 5: Generate Task JSONs
|
||||
|
||||
**CLI Strategy**:
|
||||
|
||||
| Mode | cli_execute | Placement | CLI MODE | Approval Flag | Agent Role |
|
||||
|------|-------------|-----------|----------|---------------|------------|
|
||||
| **Agent** | false | pre_analysis | analysis | (none) | Generate docs in implementation_approach |
|
||||
| **CLI** | true | implementation_approach | write | --mode write | Execute CLI commands, validate output |
|
||||
|
||||
**Command Patterns**:
|
||||
- Gemini/Qwen: `ccw cli -p "..." --tool gemini --mode analysis --cd dir`
|
||||
- CLI Mode: `ccw cli -p "..." --tool gemini --mode write --cd dir`
|
||||
- Codex: `ccw cli -p "..." --tool codex --mode write --cd dir`
|
||||
|
||||
**Generation Process**:
|
||||
1. Read configuration values (tool, cli_execute, mode) from workflow-session.json
|
||||
2. Read group assignments from doc-planning-data.json
|
||||
3. Generate Level 1 tasks (IMPL-001 to IMPL-N, one per group)
|
||||
4. Generate Level 2+ tasks if mode=full (README, ARCHITECTURE, HTTP API)
|
||||
|
||||
## Task Templates
|
||||
|
||||
### Level 1: Module Trees Group Task (Unified)
|
||||
|
||||
**Execution Model**: Each task processes assigned directory group (max 2 directories) using pre-analyzed data from Phase 2.
|
||||
|
||||
```json
|
||||
{
|
||||
"id": "IMPL-${group_number}",
|
||||
"title": "Document Module Trees Group ${group_number}",
|
||||
"status": "pending",
|
||||
"meta": {
|
||||
"type": "docs-tree-group",
|
||||
"agent": "@doc-generator",
|
||||
"tool": "gemini",
|
||||
"cli_execute": false,
|
||||
"group_number": "${group_number}",
|
||||
"total_groups": "${total_groups}"
|
||||
},
|
||||
"context": {
|
||||
"requirements": [
|
||||
"Process directories from group ${group_number} in doc-planning-data.json",
|
||||
"Generate docs to .workflow/docs/${project_name}/ (mirrored structure)",
|
||||
"Code folders: API.md + README.md; Navigation folders: README.md only",
|
||||
"Use pre-analyzed data from Phase 2 (no redundant analysis)"
|
||||
],
|
||||
"focus_paths": ["${group_dirs_from_json}"],
|
||||
"precomputed_data": {
|
||||
"phase2_analysis": "${session_dir}/.process/doc-planning-data.json"
|
||||
}
|
||||
},
|
||||
"flow_control": {
|
||||
"pre_analysis": [
|
||||
{
|
||||
"step": "load_precomputed_data",
|
||||
"action": "Load Phase 2 analysis and extract group directories",
|
||||
"commands": [
|
||||
"bash(cat ${session_dir}/.process/doc-planning-data.json)",
|
||||
"bash(jq '.groups.assignments[] | select(.group_id == \"${group_number}\") | .directories' ${session_dir}/.process/doc-planning-data.json)"
|
||||
],
|
||||
"output_to": "phase2_context",
|
||||
"note": "Single JSON file contains all Phase 2 analysis results"
|
||||
}
|
||||
],
|
||||
"implementation_approach": [
|
||||
{
|
||||
"step": 1,
|
||||
"title": "Generate documentation for assigned directory group",
|
||||
"description": "Process directories in Group ${group_number} using pre-analyzed data",
|
||||
"modification_points": [
|
||||
"Read group directories from [phase2_context].groups.assignments[${group_number}].directories",
|
||||
"For each directory: parse folder types from folder_analysis, parse structure from unified_analysis",
|
||||
"Map source_path to .workflow/docs/${project_name}/{path}",
|
||||
"Generate API.md for code folders, README.md for all folders",
|
||||
"Preserve user modifications from [phase2_context].existing_docs.content"
|
||||
],
|
||||
"logic_flow": [
|
||||
"phase2 = parse([phase2_context])",
|
||||
"dirs = phase2.groups.assignments[${group_number}].directories",
|
||||
"for dir in dirs:",
|
||||
" folder_info = find(dir, phase2.folder_analysis)",
|
||||
" outline = find(dir, phase2.unified_analysis)",
|
||||
" if folder_info.type == 'code': generate API.md + README.md",
|
||||
" elif folder_info.type == 'navigation': generate README.md only",
|
||||
" write to .workflow/docs/${project_name}/{dir}/"
|
||||
],
|
||||
"depends_on": [],
|
||||
"output": "group_module_docs"
|
||||
}
|
||||
],
|
||||
"target_files": [
|
||||
".workflow/docs/${project_name}/*/API.md",
|
||||
".workflow/docs/${project_name}/*/README.md"
|
||||
]
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
**CLI Execute Mode Note**: When `cli_execute=true`, add Step 2 in `implementation_approach`:
|
||||
```json
|
||||
{
|
||||
"step": 2,
|
||||
"title": "Batch generate documentation via CLI",
|
||||
"command": "ccw cli -p 'PURPOSE: Generate module docs\\nTASK: Create documentation\\nMODE: write\\nCONTEXT: @**/* [phase2_context]\\nEXPECTED: API.md and README.md\\nRULES: Mirror structure' --tool gemini --mode write --cd ${dirs_from_group}",
|
||||
"depends_on": [1],
|
||||
"output": "generated_docs"
|
||||
}
|
||||
```
|
||||
|
||||
### Level 2: Project README Task
|
||||
|
||||
**Task ID**: `IMPL-${readme_id}` (where `readme_id = group_count + 1`)
|
||||
**Dependencies**: Depends on all Level 1 tasks completing.
|
||||
|
||||
```json
|
||||
{
|
||||
"id": "IMPL-${readme_id}",
|
||||
"title": "Generate Project README",
|
||||
"status": "pending",
|
||||
"depends_on": ["IMPL-001", "...", "IMPL-${group_count}"],
|
||||
"meta": {"type": "docs", "agent": "@doc-generator", "tool": "gemini", "cli_execute": false},
|
||||
"flow_control": {
|
||||
"pre_analysis": [
|
||||
{
|
||||
"step": "load_existing_readme",
|
||||
"command": "bash(cat .workflow/docs/${project_name}/README.md 2>/dev/null || echo 'No existing README')",
|
||||
"output_to": "existing_readme"
|
||||
},
|
||||
{
|
||||
"step": "load_module_docs",
|
||||
"command": "bash(find .workflow/docs/${project_name} -type f -name '*.md' ! -path '.workflow/docs/${project_name}/README.md' ! -path '.workflow/docs/${project_name}/ARCHITECTURE.md' ! -path '.workflow/docs/${project_name}/EXAMPLES.md' ! -path '.workflow/docs/${project_name}/api/*' | xargs cat)",
|
||||
"output_to": "all_module_docs"
|
||||
},
|
||||
{
|
||||
"step": "analyze_project",
|
||||
"command": "bash(ccw cli -p \"PURPOSE: Analyze project structure\\nTASK: Extract overview from modules\\nMODE: analysis\\nCONTEXT: [all_module_docs]\\nEXPECTED: Project outline\" --tool gemini --mode analysis)",
|
||||
"output_to": "project_outline"
|
||||
}
|
||||
],
|
||||
"implementation_approach": [
|
||||
{
|
||||
"step": 1,
|
||||
"title": "Generate project README",
|
||||
"description": "Generate project README with navigation links while preserving user modifications",
|
||||
"modification_points": [
|
||||
"Parse [project_outline] and [all_module_docs]",
|
||||
"Generate README structure with navigation links",
|
||||
"Preserve [existing_readme] user modifications"
|
||||
],
|
||||
"logic_flow": ["Parse data", "Generate README with navigation", "Preserve modifications"],
|
||||
"depends_on": [],
|
||||
"output": "project_readme"
|
||||
}
|
||||
],
|
||||
"target_files": [".workflow/docs/${project_name}/README.md"]
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### Level 3: Architecture & Examples Documentation Task
|
||||
|
||||
**Task ID**: `IMPL-${arch_id}` (where `arch_id = group_count + 2`)
|
||||
**Dependencies**: Depends on Level 2 (Project README).
|
||||
|
||||
```json
|
||||
{
|
||||
"id": "IMPL-${arch_id}",
|
||||
"title": "Generate Architecture & Examples Documentation",
|
||||
"status": "pending",
|
||||
"depends_on": ["IMPL-${readme_id}"],
|
||||
"meta": {"type": "docs", "agent": "@doc-generator", "tool": "gemini", "cli_execute": false},
|
||||
"flow_control": {
|
||||
"pre_analysis": [
|
||||
{"step": "load_existing_docs", "command": "bash(cat .workflow/docs/${project_name}/{ARCHITECTURE,EXAMPLES}.md 2>/dev/null || echo 'No existing docs')", "output_to": "existing_arch_examples"},
|
||||
{"step": "load_all_docs", "command": "bash(cat .workflow/docs/${project_name}/README.md && find .workflow/docs/${project_name} -type f -name '*.md' ! -path '*/README.md' ! -path '*/ARCHITECTURE.md' ! -path '*/EXAMPLES.md' ! -path '*/api/*' | xargs cat)", "output_to": "all_docs"},
|
||||
{"step": "analyze_architecture", "command": "bash(ccw cli -p \"PURPOSE: Analyze system architecture\\nTASK: Synthesize architectural overview and examples\\nMODE: analysis\\nCONTEXT: [all_docs]\\nEXPECTED: Architecture + Examples outline\" --tool gemini --mode analysis)", "output_to": "arch_examples_outline"}
|
||||
],
|
||||
"implementation_approach": [
|
||||
{
|
||||
"step": 1,
|
||||
"title": "Generate architecture and examples documentation",
|
||||
"modification_points": [
|
||||
"Parse [arch_examples_outline] and [all_docs]",
|
||||
"Generate ARCHITECTURE.md (system design, patterns)",
|
||||
"Generate EXAMPLES.md (code snippets, usage)",
|
||||
"Preserve [existing_arch_examples] modifications"
|
||||
],
|
||||
"depends_on": [],
|
||||
"output": "arch_examples_docs"
|
||||
}
|
||||
],
|
||||
"target_files": [".workflow/docs/${project_name}/ARCHITECTURE.md", ".workflow/docs/${project_name}/EXAMPLES.md"]
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### Level 4: HTTP API Documentation Task (Optional)
|
||||
|
||||
**Task ID**: `IMPL-${api_id}` (where `api_id = group_count + 3`)
|
||||
**Dependencies**: Depends on Level 3.
|
||||
|
||||
```json
|
||||
{
|
||||
"id": "IMPL-${api_id}",
|
||||
"title": "Generate HTTP API Documentation",
|
||||
"status": "pending",
|
||||
"depends_on": ["IMPL-${arch_id}"],
|
||||
"meta": {"type": "docs", "agent": "@doc-generator", "tool": "gemini", "cli_execute": false},
|
||||
"flow_control": {
|
||||
"pre_analysis": [
|
||||
{"step": "discover_api", "command": "bash(rg 'router\\.| @(Get|Post)' -g '*.{ts,js}')", "output_to": "endpoint_discovery"},
|
||||
{"step": "load_existing_api", "command": "bash(cat .workflow/docs/${project_name}/api/README.md 2>/dev/null || echo 'No existing API docs')", "output_to": "existing_api_docs"},
|
||||
{"step": "analyze_api", "command": "bash(ccw cli -p \"PURPOSE: Document HTTP API\\nTASK: Analyze endpoints\\nMODE: analysis\\nCONTEXT: @src/api/**/* [endpoint_discovery]\\nEXPECTED: API outline\" --tool gemini --mode analysis)", "output_to": "api_outline"}
|
||||
],
|
||||
"implementation_approach": [
|
||||
{
|
||||
"step": 1,
|
||||
"title": "Generate HTTP API documentation",
|
||||
"modification_points": [
|
||||
"Parse [api_outline] and [endpoint_discovery]",
|
||||
"Document endpoints, request/response formats",
|
||||
"Preserve [existing_api_docs] modifications"
|
||||
],
|
||||
"depends_on": [],
|
||||
"output": "api_docs"
|
||||
}
|
||||
],
|
||||
"target_files": [".workflow/docs/${project_name}/api/README.md"]
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## Session Structure
|
||||
|
||||
**Unified Structure** (single JSON replaces multiple text files):
|
||||
|
||||
```
|
||||
.workflow/active/
|
||||
└── WFS-docs-{timestamp}/
|
||||
├── workflow-session.json # Session metadata
|
||||
├── IMPL_PLAN.md
|
||||
├── TODO_LIST.md
|
||||
├── .process/
|
||||
│ └── doc-planning-data.json # All Phase 2 analysis data (replaces 7+ files)
|
||||
└── .task/
|
||||
├── IMPL-001.json # Small: all modules | Large: group 1
|
||||
├── IMPL-00N.json # (Large only: groups 2-N)
|
||||
├── IMPL-{N+1}.json # README (full mode)
|
||||
├── IMPL-{N+2}.json # ARCHITECTURE+EXAMPLES (full mode)
|
||||
└── IMPL-{N+3}.json # HTTP API (optional)
|
||||
```
|
||||
|
||||
**doc-planning-data.json Structure**:
|
||||
```json
|
||||
{
|
||||
"metadata": {
|
||||
"generated_at": "2025-11-03T16:41:06+08:00",
|
||||
"project_name": "Claude_dms3",
|
||||
"project_root": "/d/Claude_dms3"
|
||||
},
|
||||
"folder_analysis": [
|
||||
{"path": "./src/core", "type": "code", "code_count": 5, "dirs_count": 2},
|
||||
{"path": "./src/utils", "type": "navigation", "code_count": 0, "dirs_count": 4}
|
||||
],
|
||||
"top_level_dirs": ["src/modules", "src/utils", "lib/core"],
|
||||
"existing_docs": {
|
||||
"file_list": [".workflow/docs/project/src/core/API.md"],
|
||||
"content": "... concatenated existing docs ..."
|
||||
},
|
||||
"unified_analysis": [
|
||||
{"module_path": "./src/core", "outline_summary": "Core functionality"}
|
||||
],
|
||||
"groups": {
|
||||
"count": 4,
|
||||
"assignments": [
|
||||
{"group_id": "001", "directories": ["src/modules", "src/utils"], "doc_count": 6},
|
||||
{"group_id": "002", "directories": ["lib/core", "lib/helpers"], "doc_count": 7}
|
||||
]
|
||||
},
|
||||
"statistics": {
|
||||
"total": 15,
|
||||
"code": 8,
|
||||
"navigation": 7,
|
||||
"top_level": 3
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
**Workflow Session Structure** (workflow-session.json):
|
||||
```json
|
||||
{
|
||||
"session_id": "WFS-docs-{timestamp}",
|
||||
"project": "{project_name} documentation",
|
||||
"status": "planning",
|
||||
"timestamp": "2024-01-20T14:30:22+08:00",
|
||||
"path": ".",
|
||||
"target_path": "/path/to/project",
|
||||
"project_root": "/path/to/project",
|
||||
"project_name": "{project_name}",
|
||||
"mode": "full",
|
||||
"tool": "gemini",
|
||||
"cli_execute": false,
|
||||
"update_mode": "update",
|
||||
"existing_docs": 5,
|
||||
"analysis": {
|
||||
"total": "15",
|
||||
"code": "8",
|
||||
"navigation": "7",
|
||||
"top_level": "3"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## Generated Documentation
|
||||
|
||||
**Structure mirrors project source directories under project-specific folder**:
|
||||
|
||||
```
|
||||
.workflow/docs/
|
||||
└── {project_name}/ # Project-specific root
|
||||
├── src/ # Mirrors src/ directory
|
||||
│ ├── modules/
|
||||
│ │ ├── README.md # Navigation
|
||||
│ │ ├── auth/
|
||||
│ │ │ ├── API.md # API signatures
|
||||
│ │ │ ├── README.md # Module docs
|
||||
│ │ │ └── middleware/
|
||||
│ │ │ ├── API.md
|
||||
│ │ │ └── README.md
|
||||
│ │ └── api/
|
||||
│ │ ├── API.md
|
||||
│ │ └── README.md
|
||||
│ └── utils/
|
||||
│ └── README.md
|
||||
├── lib/ # Mirrors lib/ directory
|
||||
│ └── core/
|
||||
│ ├── API.md
|
||||
│ └── README.md
|
||||
├── README.md # Project root
|
||||
├── ARCHITECTURE.md # System design
|
||||
├── EXAMPLES.md # Usage examples
|
||||
└── api/ # Optional
|
||||
└── README.md # HTTP API reference
|
||||
```
|
||||
|
||||
## Execution Commands
|
||||
|
||||
```bash
|
||||
# Execute entire workflow (auto-discovers active session)
|
||||
/workflow:execute
|
||||
|
||||
# Or specify session
|
||||
/workflow:execute --resume-session="WFS-docs-yyyymmdd-hhmmss"
|
||||
|
||||
# Individual task execution
|
||||
/task:execute IMPL-001
|
||||
```
|
||||
|
||||
## Template Reference
|
||||
|
||||
**Available Templates** (`~/.claude/workflows/cli-templates/prompts/documentation/`):
|
||||
- `api.txt`: Code API (Part A) + HTTP API (Part B)
|
||||
- `module-readme.txt`: Module purpose, usage, dependencies
|
||||
- `folder-navigation.txt`: Navigation README for folders with subdirectories
|
||||
- `project-readme.txt`: Project overview, getting started, navigation
|
||||
- `project-architecture.txt`: System structure, module map, design patterns
|
||||
- `project-examples.txt`: End-to-end usage examples
|
||||
|
||||
## Execution Mode Summary
|
||||
|
||||
| Mode | CLI Placement | CLI MODE | Approval Flag | Agent Role |
|
||||
|------|---------------|----------|---------------|------------|
|
||||
| **Agent (default)** | pre_analysis | analysis | (none) | Generates documentation content |
|
||||
| **CLI (--cli-execute)** | implementation_approach | write | --mode write | Executes CLI commands, validates output |
|
||||
|
||||
**Execution Flow**:
|
||||
- **Phase 2**: Unified analysis once, results in `.process/`
|
||||
- **Phase 4**: Dynamic grouping (max 2 dirs per group)
|
||||
- **Level 1**: Parallel processing for module tree groups
|
||||
- **Level 2+**: Sequential execution for project-level docs
|
||||
|
||||
## Related Commands
|
||||
- `/workflow:execute` - Execute documentation tasks
|
||||
- `/workflow:status` - View task progress
|
||||
- `/workflow:session:complete` - Mark session complete
|
||||
@@ -1,182 +0,0 @@
|
||||
---
|
||||
name: load-skill-memory
|
||||
description: Activate SKILL package (auto-detect from paths/keywords or manual) and intelligently load documentation based on task intent keywords
|
||||
argument-hint: "[skill_name] \"task intent description\""
|
||||
allowed-tools: Bash(*), Read(*), Skill(*)
|
||||
---
|
||||
|
||||
# Memory Load SKILL Command (/memory:load-skill-memory)
|
||||
|
||||
## 1. Overview
|
||||
|
||||
The `memory:load-skill-memory` command **activates SKILL package** (auto-detect from task or manual specification) and intelligently loads documentation based on user's task intent. The system automatically determines which documentation files to read based on the intent description.
|
||||
|
||||
**Core Philosophy**:
|
||||
- **Flexible Activation**: Auto-detect skill from task description/paths, or user explicitly specifies
|
||||
- **Intent-Driven Loading**: System analyzes task intent to determine documentation scope
|
||||
- **Intelligent Selection**: Automatically chooses appropriate documentation level and modules
|
||||
- **Direct Context Loading**: Loads selected documentation into conversation memory
|
||||
|
||||
**When to Use**:
|
||||
- Manually activate a known SKILL package for a specific task
|
||||
- Load SKILL context when system hasn't auto-triggered it
|
||||
- Force reload SKILL documentation with specific intent focus
|
||||
|
||||
**Note**: Normal SKILL activation happens automatically via description triggers or path mentions (system extracts skill name from file paths for intelligent triggering). Use this command only when manual activation is needed.
|
||||
|
||||
## 2. Parameters
|
||||
|
||||
- `[skill_name]` (Optional): Name of SKILL package to activate
|
||||
- If omitted: System auto-detects from task description or file paths
|
||||
- If specified: Direct activation of named SKILL package
|
||||
- Example: `my_project`, `api_service`
|
||||
- Must match directory name under `.claude/skills/`
|
||||
|
||||
- `"task intent description"` (Required): Description of what you want to do
|
||||
- Used for both: auto-detection (if skill_name omitted) and documentation scope selection
|
||||
- **Analysis tasks**: "分析builder pattern实现", "理解参数系统架构"
|
||||
- **Modification tasks**: "修改workflow逻辑", "增强thermal template功能"
|
||||
- **Learning tasks**: "学习接口设计模式", "了解测试框架使用"
|
||||
- **With paths**: "修改D:\projects\my_project\src\auth.py的认证逻辑" (auto-extracts `my_project`)
|
||||
|
||||
## 3. Execution Flow
|
||||
|
||||
### Step 1: Determine SKILL Name (if not provided)
|
||||
|
||||
**Auto-Detection Strategy** (when skill_name parameter is omitted):
|
||||
1. **Path Extraction**: Scan task description for file paths
|
||||
- Extract potential project names from path segments
|
||||
- Example: `"修改D:\projects\my_project\src\auth.py"` → extracts `my_project`
|
||||
2. **Keyword Matching**: Match task keywords against SKILL descriptions
|
||||
- Search for project-specific terms, domain keywords
|
||||
3. **Validation**: Check if extracted name matches `.claude/skills/{skill_name}/`
|
||||
|
||||
**Result**: Either uses provided skill_name or auto-detected name for activation
|
||||
|
||||
### Step 2: Activate SKILL and Analyze Intent
|
||||
|
||||
**Activate SKILL Package**:
|
||||
```javascript
|
||||
Skill(command: "${skill_name}") // Uses provided or auto-detected name
|
||||
```
|
||||
|
||||
**What Happens After Activation**:
|
||||
1. If SKILL exists in memory: System reads `.claude/skills/${skill_name}/SKILL.md`
|
||||
2. If SKILL not found in memory: Error - SKILL package doesn't exist
|
||||
3. SKILL description triggers are loaded into memory
|
||||
4. Progressive loading mechanism becomes available
|
||||
5. Documentation structure is now accessible
|
||||
|
||||
**Intent Analysis**:
|
||||
Based on task intent description, system determines:
|
||||
- **Action type**: analyzing, modifying, learning
|
||||
- **Scope**: specific module, architecture overview, complete system
|
||||
- **Depth**: quick reference, detailed API, full documentation
|
||||
|
||||
### Step 3: Intelligent Documentation Loading
|
||||
|
||||
**Loading Strategy**:
|
||||
|
||||
The system automatically selects documentation based on intent keywords:
|
||||
|
||||
1. **Quick Understanding** ("了解", "快速理解", "什么是"):
|
||||
- Load: Level 0 (README.md only, ~2K tokens)
|
||||
- Use case: Quick overview of capabilities
|
||||
|
||||
2. **Specific Module Analysis** ("分析XXX模块", "理解XXX实现"):
|
||||
- Load: Module-specific README.md + API.md (~5K tokens)
|
||||
- Use case: Deep dive into specific component
|
||||
|
||||
3. **Architecture Review** ("架构", "设计模式", "整体结构"):
|
||||
- Load: README.md + ARCHITECTURE.md (~10K tokens)
|
||||
- Use case: System design understanding
|
||||
|
||||
4. **Implementation/Modification** ("修改", "增强", "实现"):
|
||||
- Load: Relevant module docs + EXAMPLES.md (~15K tokens)
|
||||
- Use case: Code modification with examples
|
||||
|
||||
5. **Comprehensive Learning** ("学习", "完整了解", "深入理解"):
|
||||
- Load: Level 3 (All documentation, ~40K tokens)
|
||||
- Use case: Complete system mastery
|
||||
|
||||
**Documentation Loaded into Memory**:
|
||||
After loading, the selected documentation content is available in conversation memory for subsequent operations.
|
||||
|
||||
## 4. Usage Examples
|
||||
|
||||
### Example 1: Manual Specification
|
||||
|
||||
**User Command**:
|
||||
```bash
|
||||
/memory:load-skill-memory my_project "修改认证模块增加OAuth支持"
|
||||
```
|
||||
|
||||
**Execution**:
|
||||
```javascript
|
||||
// Step 1: Use provided skill_name
|
||||
skill_name = "my_project" // Directly from parameter
|
||||
|
||||
// Step 2: Activate SKILL
|
||||
Skill(command: "my_project")
|
||||
|
||||
// Step 3: Intent Analysis
|
||||
Keywords: ["修改", "认证模块", "增加", "OAuth"]
|
||||
Action: modifying (implementation)
|
||||
Scope: auth module + examples
|
||||
|
||||
// Load documentation based on intent
|
||||
Read(.workflow/docs/my_project/auth/README.md)
|
||||
Read(.workflow/docs/my_project/auth/API.md)
|
||||
Read(.workflow/docs/my_project/EXAMPLES.md)
|
||||
```
|
||||
|
||||
### Example 2: Auto-Detection from Path
|
||||
|
||||
**User Command**:
|
||||
```bash
|
||||
/memory:load-skill-memory "修改D:\projects\my_project\src\services\api.py的接口逻辑"
|
||||
```
|
||||
|
||||
**Execution**:
|
||||
```javascript
|
||||
// Step 1: Auto-detect skill_name from path
|
||||
Path detected: "D:\projects\my_project\src\services\api.py"
|
||||
Extracted: "my_project"
|
||||
Validated: .claude/skills/my_project/ exists ✓
|
||||
skill_name = "my_project"
|
||||
|
||||
// Step 2: Activate SKILL
|
||||
Skill(command: "my_project")
|
||||
|
||||
// Step 3: Intent Analysis
|
||||
Keywords: ["修改", "services", "接口逻辑"]
|
||||
Action: modifying (implementation)
|
||||
Scope: services module + examples
|
||||
|
||||
// Load documentation based on intent
|
||||
Read(.workflow/docs/my_project/services/README.md)
|
||||
Read(.workflow/docs/my_project/services/API.md)
|
||||
Read(.workflow/docs/my_project/EXAMPLES.md)
|
||||
```
|
||||
|
||||
## 5. Intent Keyword Mapping
|
||||
|
||||
**Quick Reference**:
|
||||
- **Triggers**: "了解", "快速", "什么是", "简介"
|
||||
- **Loads**: README.md only (~2K)
|
||||
|
||||
**Module-Specific**:
|
||||
- **Triggers**: "XXX模块", "XXX组件", "分析XXX"
|
||||
- **Loads**: Module README + API (~5K)
|
||||
|
||||
**Architecture**:
|
||||
- **Triggers**: "架构", "设计", "整体结构", "系统设计"
|
||||
- **Loads**: README + ARCHITECTURE (~10K)
|
||||
|
||||
**Implementation**:
|
||||
- **Triggers**: "修改", "增强", "实现", "开发", "集成"
|
||||
- **Loads**: Relevant module + EXAMPLES (~15K)
|
||||
|
||||
**Comprehensive**:
|
||||
- **Triggers**: "完整", "深入", "全面", "学习整个"
|
||||
- **Loads**: All documentation (~40K)
|
||||
@@ -1,525 +0,0 @@
|
||||
---
|
||||
name: skill-memory
|
||||
description: 4-phase autonomous orchestrator: check docs → /memory:docs planning → /workflow:execute → generate SKILL.md with progressive loading index (skips phases 2-3 if docs exist)
|
||||
argument-hint: "[path] [--tool <gemini|qwen|codex>] [--regenerate] [--mode <full|partial>] [--cli-execute]"
|
||||
allowed-tools: SlashCommand(*), TodoWrite(*), Bash(*), Read(*), Write(*)
|
||||
---
|
||||
|
||||
# Memory SKILL Package Generator
|
||||
|
||||
## Orchestrator Role
|
||||
|
||||
**Pure Orchestrator**: Execute documentation generation workflow, then generate SKILL.md index. Does NOT create task JSON files.
|
||||
|
||||
**Auto-Continue Workflow**: This command runs **fully autonomously** once triggered. Each phase completes and automatically triggers the next phase without user interaction.
|
||||
|
||||
**Execution Paths**:
|
||||
- **Full Path**: All 4 phases (no existing docs OR `--regenerate` specified)
|
||||
- **Skip Path**: Phase 1 → Phase 4 (existing docs found AND no `--regenerate` flag)
|
||||
- **Phase 4 Always Executes**: SKILL.md index is never skipped, always generated or updated
|
||||
|
||||
## Core Rules
|
||||
|
||||
1. **Start Immediately**: First action is TodoWrite initialization, second action is Phase 1 execution
|
||||
2. **No Task JSON**: This command does not create task JSON files - delegates to /memory:docs
|
||||
3. **Parse Every Output**: Extract required data from each command output (session_id, task_count, file paths)
|
||||
4. **Auto-Continue**: After completing each phase, update TodoWrite and immediately execute next phase
|
||||
5. **Track Progress**: Update TodoWrite after EVERY phase completion before starting next phase
|
||||
6. **Direct Generation**: Phase 4 directly generates SKILL.md using Write tool
|
||||
7. **No Manual Steps**: User should never be prompted for decisions between phases
|
||||
|
||||
---
|
||||
|
||||
## 4-Phase Execution
|
||||
|
||||
### Phase 1: Prepare Arguments
|
||||
|
||||
**Goal**: Parse command arguments and check existing documentation
|
||||
|
||||
**Step 1: Get Target Path and Project Name**
|
||||
```bash
|
||||
# Get current directory (or use provided path)
|
||||
bash(pwd)
|
||||
|
||||
# Get project name from directory
|
||||
bash(basename "$(pwd)")
|
||||
|
||||
# Get project root
|
||||
bash(git rev-parse --show-toplevel 2>/dev/null || pwd)
|
||||
```
|
||||
|
||||
**Output**:
|
||||
- `target_path`: `/d/my_project`
|
||||
- `project_name`: `my_project`
|
||||
- `project_root`: `/d/my_project`
|
||||
|
||||
**Step 2: Set Default Parameters**
|
||||
```bash
|
||||
# Default values (use these unless user specifies otherwise):
|
||||
# - tool: "gemini"
|
||||
# - mode: "full"
|
||||
# - regenerate: false (no --regenerate flag)
|
||||
# - cli_execute: false (no --cli-execute flag)
|
||||
```
|
||||
|
||||
**Step 3: Check Existing Documentation**
|
||||
```bash
|
||||
# Check if docs directory exists
|
||||
bash(test -d .workflow/docs/my_project && echo "exists" || echo "not_exists")
|
||||
|
||||
# Count existing documentation files
|
||||
bash(find .workflow/docs/my_project -name "*.md" 2>/dev/null | wc -l || echo 0)
|
||||
```
|
||||
|
||||
**Output**:
|
||||
- `docs_exists`: `exists` or `not_exists`
|
||||
- `existing_docs`: `5` (or `0` if no docs)
|
||||
|
||||
**Step 4: Determine Execution Path**
|
||||
|
||||
**Decision Logic**:
|
||||
```javascript
|
||||
if (existing_docs > 0 && !regenerate_flag) {
|
||||
// Documentation exists and no regenerate flag
|
||||
SKIP_DOCS_GENERATION = true
|
||||
message = "Documentation already exists, skipping Phase 2 and Phase 3. Use --regenerate to force regeneration."
|
||||
} else if (regenerate_flag) {
|
||||
// Force regeneration: delete existing docs
|
||||
bash(rm -rf .workflow/docs/my_project 2>/dev/null || true)
|
||||
SKIP_DOCS_GENERATION = false
|
||||
message = "Regenerating documentation from scratch."
|
||||
} else {
|
||||
// No existing docs
|
||||
SKIP_DOCS_GENERATION = false
|
||||
message = "No existing documentation found, generating new documentation."
|
||||
}
|
||||
```
|
||||
|
||||
**Summary Variables**:
|
||||
- `PROJECT_NAME`: `my_project`
|
||||
- `TARGET_PATH`: `/d/my_project`
|
||||
- `DOCS_PATH`: `.workflow/docs/my_project`
|
||||
- `TOOL`: `gemini` (default) or user-specified
|
||||
- `MODE`: `full` (default) or user-specified
|
||||
- `CLI_EXECUTE`: `false` (default) or `true` if --cli-execute flag
|
||||
- `REGENERATE`: `false` (default) or `true` if --regenerate flag
|
||||
- `EXISTING_DOCS`: Count of existing documentation files
|
||||
- `SKIP_DOCS_GENERATION`: `true` if skipping Phase 2/3, `false` otherwise
|
||||
|
||||
**Completion & TodoWrite**:
|
||||
- If `SKIP_DOCS_GENERATION = true`: Mark phase 1 completed, phase 2&3 completed (skipped), phase 4 in_progress
|
||||
- If `SKIP_DOCS_GENERATION = false`: Mark phase 1 completed, phase 2 in_progress
|
||||
|
||||
**Next Action**:
|
||||
- If skipping: Display skip message → Jump to Phase 4 (SKILL.md generation)
|
||||
- If not skipping: Display preparation results → Continue to Phase 2 (documentation planning)
|
||||
|
||||
---
|
||||
|
||||
### Phase 2: Call /memory:docs
|
||||
|
||||
**Skip Condition**: This phase is **skipped if SKIP_DOCS_GENERATION = true** (documentation already exists without --regenerate flag)
|
||||
|
||||
**Goal**: Trigger documentation generation workflow
|
||||
|
||||
**Command**:
|
||||
```bash
|
||||
SlashCommand(command="/memory:docs [targetPath] --tool [tool] --mode [mode] [--cli-execute]")
|
||||
```
|
||||
|
||||
**Example**:
|
||||
```bash
|
||||
/memory:docs /d/my_app --tool gemini --mode full
|
||||
/memory:docs /d/my_app --tool gemini --mode full --cli-execute
|
||||
```
|
||||
|
||||
**Note**: The `--regenerate` flag is handled in Phase 1 by deleting existing documentation. This command always calls `/memory:docs` without the regenerate flag, relying on docs.md's built-in update detection.
|
||||
|
||||
**Parse Output**:
|
||||
- Extract session ID: `WFS-docs-[timestamp]` (store as `docsSessionId`)
|
||||
- Extract task count (store as `taskCount`)
|
||||
|
||||
**Completion Criteria**:
|
||||
- `/memory:docs` command executed successfully
|
||||
- Session ID extracted and stored
|
||||
- Task count retrieved
|
||||
- Task files created in `.workflow/[docsSessionId]/.task/`
|
||||
- workflow-session.json exists
|
||||
|
||||
**TodoWrite**: Mark phase 2 completed, phase 3 in_progress
|
||||
|
||||
**Next Action**: Display docs planning results (session ID, task count) → Auto-continue to Phase 3
|
||||
|
||||
---
|
||||
|
||||
### Phase 3: Execute Documentation Generation
|
||||
|
||||
**Skip Condition**: This phase is **skipped if SKIP_DOCS_GENERATION = true** (documentation already exists without --regenerate flag)
|
||||
|
||||
**Goal**: Execute documentation generation tasks
|
||||
|
||||
**Command**:
|
||||
```bash
|
||||
SlashCommand(command="/workflow:execute")
|
||||
```
|
||||
|
||||
**Note**: `/workflow:execute` automatically discovers active session from Phase 2
|
||||
|
||||
**Completion Criteria**:
|
||||
- `/workflow:execute` command executed successfully
|
||||
- Documentation files generated in `.workflow/docs/[projectName]/`
|
||||
- All tasks marked as completed in session
|
||||
- At minimum: module documentation files exist (API.md and/or README.md)
|
||||
- For full mode: Project README, ARCHITECTURE, EXAMPLES files generated
|
||||
|
||||
**TodoWrite**: Mark phase 3 completed, phase 4 in_progress
|
||||
|
||||
**Next Action**: Display execution results (file count, module count) → Auto-continue to Phase 4
|
||||
|
||||
---
|
||||
|
||||
### Phase 4: Generate SKILL.md Index
|
||||
|
||||
**Note**: This phase is **NEVER skipped** - it always executes to generate or update the SKILL index.
|
||||
|
||||
**Step 1: Read Key Files** (Use Read tool)
|
||||
- `.workflow/docs/{project_name}/README.md` (required)
|
||||
- `.workflow/docs/{project_name}/ARCHITECTURE.md` (optional)
|
||||
|
||||
**Step 2: Discover Structure**
|
||||
```bash
|
||||
bash(find .workflow/docs/{project_name} -name "*.md" | sed 's|.workflow/docs/{project_name}/||' | awk -F'/' '{if(NF>=2) print $1"/"$2}' | sort -u)
|
||||
```
|
||||
|
||||
**Step 3: Generate Intelligent Description**
|
||||
|
||||
Extract from README + structure: Function (capabilities), Modules (names), Keywords (API/CLI/auth/etc.)
|
||||
|
||||
**Format**: `{Project} {core capabilities} (located at {project_path}). Load this SKILL when analyzing, modifying, or learning about {domain_description} or files under this path, especially when no relevant context exists in memory.`
|
||||
|
||||
**Key Elements**:
|
||||
- **Path Reference**: Use `TARGET_PATH` from Phase 1 for precise location identification
|
||||
- **Domain Description**: Extract human-readable domain/feature area from README (e.g., "workflow management", "thermal modeling")
|
||||
- **Trigger Optimization**: Include project path, emphasize "especially when no relevant context exists in memory"
|
||||
- **Action Coverage**: analyzing (分析), modifying (修改), learning (了解)
|
||||
|
||||
**Example**: "Workflow orchestration system with CLI tools and documentation generation (located at /d/Claude_dms3). Load this SKILL when analyzing, modifying, or learning about workflow management or files under this path, especially when no relevant context exists in memory."
|
||||
|
||||
**Step 4: Write SKILL.md** (Use Write tool)
|
||||
```bash
|
||||
bash(mkdir -p .claude/skills/{project_name})
|
||||
```
|
||||
|
||||
`.claude/skills/{project_name}/SKILL.md`:
|
||||
```yaml
|
||||
---
|
||||
name: {project_name}
|
||||
description: {intelligent description from Step 3}
|
||||
version: 1.0.0
|
||||
---
|
||||
# {Project Name} SKILL Package
|
||||
|
||||
## Documentation: `../../../.workflow/docs/{project_name}/`
|
||||
|
||||
## Progressive Loading
|
||||
### Level 0: Quick Start (~2K)
|
||||
- [README](../../../.workflow/docs/{project_name}/README.md)
|
||||
### Level 1: Core Modules (~8K)
|
||||
{Module READMEs}
|
||||
### Level 2: Complete (~25K)
|
||||
All modules + [Architecture](../../../.workflow/docs/{project_name}/ARCHITECTURE.md)
|
||||
### Level 3: Deep Dive (~40K)
|
||||
Everything + [Examples](../../../.workflow/docs/{project_name}/EXAMPLES.md)
|
||||
```
|
||||
|
||||
**Completion Criteria**:
|
||||
- SKILL.md file created at `.claude/skills/{project_name}/SKILL.md`
|
||||
- Intelligent description generated from documentation
|
||||
- Progressive loading levels (0-3) properly structured
|
||||
- Module index includes all documented modules
|
||||
- All file references use relative paths
|
||||
|
||||
**TodoWrite**: Mark phase 4 completed
|
||||
|
||||
**Final Action**: Report completion summary to user
|
||||
|
||||
**Return to User**:
|
||||
```
|
||||
SKILL Package Generation Complete
|
||||
|
||||
Project: {project_name}
|
||||
Documentation: .workflow/docs/{project_name}/ ({doc_count} files)
|
||||
SKILL Index: .claude/skills/{project_name}/SKILL.md
|
||||
|
||||
Generated:
|
||||
- {task_count} documentation tasks completed
|
||||
- SKILL.md with progressive loading (4 levels)
|
||||
- Module index with {module_count} modules
|
||||
|
||||
Usage:
|
||||
- Load Level 0: Quick project overview (~2K tokens)
|
||||
- Load Level 1: Core modules (~8K tokens)
|
||||
- Load Level 2: Complete docs (~25K tokens)
|
||||
- Load Level 3: Everything (~40K tokens)
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Implementation Details
|
||||
|
||||
### Critical Rules
|
||||
|
||||
1. **No User Prompts Between Phases**: Never ask user questions or wait for input between phases
|
||||
2. **Immediate Phase Transition**: After TodoWrite update, immediately execute next phase command
|
||||
3. **Status-Driven Execution**: Check TodoList status after each phase:
|
||||
- If next task is "pending" → Mark it "in_progress" and execute
|
||||
- If all tasks are "completed" → Report final summary
|
||||
4. **Phase Completion Pattern**:
|
||||
```
|
||||
Phase N completes → Update TodoWrite (N=completed, N+1=in_progress) → Execute Phase N+1
|
||||
```
|
||||
|
||||
### TodoWrite Patterns
|
||||
|
||||
#### Initialization (Before Phase 1)
|
||||
|
||||
**FIRST ACTION**: Create TodoList with all 4 phases
|
||||
```javascript
|
||||
TodoWrite({todos: [
|
||||
{"content": "Parse arguments and prepare", "status": "in_progress", "activeForm": "Parsing arguments"},
|
||||
{"content": "Call /memory:docs to plan documentation", "status": "pending", "activeForm": "Calling /memory:docs"},
|
||||
{"content": "Execute documentation generation", "status": "pending", "activeForm": "Executing documentation"},
|
||||
{"content": "Generate SKILL.md index", "status": "pending", "activeForm": "Generating SKILL.md"}
|
||||
]})
|
||||
```
|
||||
|
||||
**SECOND ACTION**: Execute Phase 1 immediately
|
||||
|
||||
#### Full Path (SKIP_DOCS_GENERATION = false)
|
||||
|
||||
**After Phase 1**:
|
||||
```javascript
|
||||
TodoWrite({todos: [
|
||||
{"content": "Parse arguments and prepare", "status": "completed", "activeForm": "Parsing arguments"},
|
||||
{"content": "Call /memory:docs to plan documentation", "status": "in_progress", "activeForm": "Calling /memory:docs"},
|
||||
{"content": "Execute documentation generation", "status": "pending", "activeForm": "Executing documentation"},
|
||||
{"content": "Generate SKILL.md index", "status": "pending", "activeForm": "Generating SKILL.md"}
|
||||
]})
|
||||
// Auto-continue to Phase 2
|
||||
```
|
||||
|
||||
**After Phase 2**:
|
||||
```javascript
|
||||
TodoWrite({todos: [
|
||||
{"content": "Parse arguments and prepare", "status": "completed", "activeForm": "Parsing arguments"},
|
||||
{"content": "Call /memory:docs to plan documentation", "status": "completed", "activeForm": "Calling /memory:docs"},
|
||||
{"content": "Execute documentation generation", "status": "in_progress", "activeForm": "Executing documentation"},
|
||||
{"content": "Generate SKILL.md index", "status": "pending", "activeForm": "Generating SKILL.md"}
|
||||
]})
|
||||
// Auto-continue to Phase 3
|
||||
```
|
||||
|
||||
**After Phase 3**:
|
||||
```javascript
|
||||
TodoWrite({todos: [
|
||||
{"content": "Parse arguments and prepare", "status": "completed", "activeForm": "Parsing arguments"},
|
||||
{"content": "Call /memory:docs to plan documentation", "status": "completed", "activeForm": "Calling /memory:docs"},
|
||||
{"content": "Execute documentation generation", "status": "completed", "activeForm": "Executing documentation"},
|
||||
{"content": "Generate SKILL.md index", "status": "in_progress", "activeForm": "Generating SKILL.md"}
|
||||
]})
|
||||
// Auto-continue to Phase 4
|
||||
```
|
||||
|
||||
**After Phase 4**:
|
||||
```javascript
|
||||
TodoWrite({todos: [
|
||||
{"content": "Parse arguments and prepare", "status": "completed", "activeForm": "Parsing arguments"},
|
||||
{"content": "Call /memory:docs to plan documentation", "status": "completed", "activeForm": "Calling /memory:docs"},
|
||||
{"content": "Execute documentation generation", "status": "completed", "activeForm": "Executing documentation"},
|
||||
{"content": "Generate SKILL.md index", "status": "completed", "activeForm": "Generating SKILL.md"}
|
||||
]})
|
||||
// Report completion summary to user
|
||||
```
|
||||
|
||||
#### Skip Path (SKIP_DOCS_GENERATION = true)
|
||||
|
||||
**After Phase 1** (detects existing docs, skips Phase 2 & 3):
|
||||
```javascript
|
||||
TodoWrite({todos: [
|
||||
{"content": "Parse arguments and prepare", "status": "completed", "activeForm": "Parsing arguments"},
|
||||
{"content": "Call /memory:docs to plan documentation", "status": "completed", "activeForm": "Calling /memory:docs"},
|
||||
{"content": "Execute documentation generation", "status": "completed", "activeForm": "Executing documentation"},
|
||||
{"content": "Generate SKILL.md index", "status": "in_progress", "activeForm": "Generating SKILL.md"}
|
||||
]})
|
||||
// Display skip message: "Documentation already exists, skipping Phase 2 and Phase 3. Use --regenerate to force regeneration."
|
||||
// Jump directly to Phase 4
|
||||
```
|
||||
|
||||
**After Phase 4**:
|
||||
```javascript
|
||||
TodoWrite({todos: [
|
||||
{"content": "Parse arguments and prepare", "status": "completed", "activeForm": "Parsing arguments"},
|
||||
{"content": "Call /memory:docs to plan documentation", "status": "completed", "activeForm": "Calling /memory:docs"},
|
||||
{"content": "Execute documentation generation", "status": "completed", "activeForm": "Executing documentation"},
|
||||
{"content": "Generate SKILL.md index", "status": "completed", "activeForm": "Generating SKILL.md"}
|
||||
]})
|
||||
// Report completion summary to user
|
||||
```
|
||||
|
||||
### Execution Flow Diagrams
|
||||
|
||||
#### Full Path Flow
|
||||
```
|
||||
User triggers command
|
||||
↓
|
||||
[TodoWrite] Initialize 4 phases (Phase 1 = in_progress)
|
||||
↓
|
||||
[Execute] Phase 1: Parse arguments
|
||||
↓
|
||||
[TodoWrite] Phase 1 = completed, Phase 2 = in_progress
|
||||
↓
|
||||
[Execute] Phase 2: Call /memory:docs
|
||||
↓
|
||||
[TodoWrite] Phase 2 = completed, Phase 3 = in_progress
|
||||
↓
|
||||
[Execute] Phase 3: Call /workflow:execute
|
||||
↓
|
||||
[TodoWrite] Phase 3 = completed, Phase 4 = in_progress
|
||||
↓
|
||||
[Execute] Phase 4: Generate SKILL.md
|
||||
↓
|
||||
[TodoWrite] Phase 4 = completed
|
||||
↓
|
||||
[Report] Display completion summary
|
||||
```
|
||||
|
||||
#### Skip Path Flow
|
||||
```
|
||||
User triggers command
|
||||
↓
|
||||
[TodoWrite] Initialize 4 phases (Phase 1 = in_progress)
|
||||
↓
|
||||
[Execute] Phase 1: Parse arguments, detect existing docs
|
||||
↓
|
||||
[TodoWrite] Phase 1 = completed, Phase 2&3 = completed (skipped), Phase 4 = in_progress
|
||||
↓
|
||||
[Display] Skip message: "Documentation already exists, skipping Phase 2 and Phase 3"
|
||||
↓
|
||||
[Execute] Phase 4: Generate SKILL.md (always runs)
|
||||
↓
|
||||
[TodoWrite] Phase 4 = completed
|
||||
↓
|
||||
[Report] Display completion summary
|
||||
```
|
||||
|
||||
### Error Handling
|
||||
|
||||
- If any phase fails, mark it as "in_progress" (not completed)
|
||||
- Report error details to user
|
||||
- Do NOT auto-continue to next phase on failure
|
||||
|
||||
---
|
||||
|
||||
## Parameters
|
||||
|
||||
```bash
|
||||
/memory:skill-memory [path] [--tool <gemini|qwen|codex>] [--regenerate] [--mode <full|partial>] [--cli-execute]
|
||||
```
|
||||
|
||||
- **path**: Target directory (default: current directory)
|
||||
- **--tool**: CLI tool for documentation (default: gemini)
|
||||
- `gemini`: Comprehensive documentation
|
||||
- `qwen`: Architecture analysis
|
||||
- `codex`: Implementation validation
|
||||
- **--regenerate**: Force regenerate all documentation
|
||||
- When enabled: Deletes existing `.workflow/docs/{project_name}/` before regeneration
|
||||
- Ensures fresh documentation from source code
|
||||
- **--mode**: Documentation mode (default: full)
|
||||
- `full`: Complete docs (modules + README + ARCHITECTURE + EXAMPLES)
|
||||
- `partial`: Module docs only
|
||||
- **--cli-execute**: Enable CLI-based documentation generation (optional)
|
||||
- When enabled: CLI generates docs directly in implementation_approach
|
||||
- When disabled (default): Agent generates documentation content
|
||||
|
||||
---
|
||||
|
||||
## Examples
|
||||
|
||||
### Example 1: Generate SKILL Package (Default)
|
||||
|
||||
```bash
|
||||
/memory:skill-memory
|
||||
```
|
||||
|
||||
**Workflow**:
|
||||
1. Phase 1: Detects current directory, checks existing docs
|
||||
2. Phase 2: Calls `/memory:docs . --tool gemini --mode full` (Agent Mode)
|
||||
3. Phase 3: Executes documentation generation via `/workflow:execute`
|
||||
4. Phase 4: Generates SKILL.md at `.claude/skills/{project_name}/SKILL.md`
|
||||
|
||||
### Example 2: Regenerate with Qwen
|
||||
|
||||
```bash
|
||||
/memory:skill-memory /d/my_app --tool qwen --regenerate
|
||||
```
|
||||
|
||||
**Workflow**:
|
||||
1. Phase 1: Parses target path, detects regenerate flag, deletes existing docs
|
||||
2. Phase 2: Calls `/memory:docs /d/my_app --tool qwen --mode full`
|
||||
3. Phase 3: Executes documentation regeneration
|
||||
4. Phase 4: Generates updated SKILL.md
|
||||
|
||||
### Example 3: Partial Mode (Modules Only)
|
||||
|
||||
```bash
|
||||
/memory:skill-memory --mode partial
|
||||
```
|
||||
|
||||
**Workflow**:
|
||||
1. Phase 1: Detects partial mode
|
||||
2. Phase 2: Calls `/memory:docs . --tool gemini --mode partial` (Agent Mode)
|
||||
3. Phase 3: Executes module documentation only
|
||||
4. Phase 4: Generates SKILL.md with module-only index
|
||||
|
||||
### Example 4: CLI Execute Mode
|
||||
|
||||
```bash
|
||||
/memory:skill-memory --cli-execute
|
||||
```
|
||||
|
||||
**Workflow**:
|
||||
1. Phase 1: Detects CLI execute mode
|
||||
2. Phase 2: Calls `/memory:docs . --tool gemini --mode full --cli-execute` (CLI Mode)
|
||||
3. Phase 3: Executes CLI-based documentation generation
|
||||
4. Phase 4: Generates SKILL.md at `.claude/skills/{project_name}/SKILL.md`
|
||||
|
||||
### Example 5: Skip Path (Existing Docs)
|
||||
|
||||
```bash
|
||||
/memory:skill-memory
|
||||
```
|
||||
|
||||
**Scenario**: Documentation already exists in `.workflow/docs/{project_name}/`
|
||||
|
||||
**Workflow**:
|
||||
1. Phase 1: Detects existing docs (5 files), sets SKIP_DOCS_GENERATION = true
|
||||
2. Display: "Documentation already exists, skipping Phase 2 and Phase 3. Use --regenerate to force regeneration."
|
||||
3. Phase 4: Generates or updates SKILL.md index only (~5-10x faster)
|
||||
|
||||
---
|
||||
|
||||
|
||||
|
||||
## Architecture
|
||||
|
||||
```
|
||||
skill-memory (orchestrator)
|
||||
├─ Phase 1: Prepare (bash commands, skip decision)
|
||||
├─ Phase 2: /memory:docs (task planning, skippable)
|
||||
├─ Phase 3: /workflow:execute (task execution, skippable)
|
||||
└─ Phase 4: Write SKILL.md (direct file generation, always runs)
|
||||
|
||||
No task JSON created by this command
|
||||
All documentation tasks managed by /memory:docs
|
||||
Smart skip logic: 5-10x faster when docs exist
|
||||
```
|
||||
@@ -1,310 +0,0 @@
|
||||
---
|
||||
name: tech-research-rules
|
||||
description: "3-phase orchestrator: extract tech stack → Exa research → generate path-conditional rules (auto-loaded by Claude Code)"
|
||||
argument-hint: "[session-id | tech-stack-name] [--regenerate] [--tool <gemini|qwen>]"
|
||||
allowed-tools: SlashCommand(*), TodoWrite(*), Bash(*), Read(*), Write(*), Task(*)
|
||||
---
|
||||
|
||||
# Tech Stack Rules Generator
|
||||
|
||||
## Overview
|
||||
|
||||
**Purpose**: Generate multi-layered, path-conditional rules that Claude Code automatically loads based on file context.
|
||||
|
||||
**Output Structure**:
|
||||
```
|
||||
.claude/rules/tech/{tech-stack}/
|
||||
├── core.md # paths: **/*.{ext} - Core principles
|
||||
├── patterns.md # paths: src/**/*.{ext} - Implementation patterns
|
||||
├── testing.md # paths: **/*.{test,spec}.{ext} - Testing rules
|
||||
├── config.md # paths: *.config.* - Configuration rules
|
||||
├── api.md # paths: **/api/**/* - API rules (backend only)
|
||||
├── components.md # paths: **/components/**/* - Component rules (frontend only)
|
||||
└── metadata.json # Generation metadata
|
||||
```
|
||||
|
||||
**Templates Location**: `~/.claude/workflows/cli-templates/prompts/rules/`
|
||||
|
||||
---
|
||||
|
||||
## Core Rules
|
||||
|
||||
1. **Start Immediately**: First action is TodoWrite initialization
|
||||
2. **Path-Conditional Output**: Every rule file includes `paths` frontmatter
|
||||
3. **Template-Driven**: Agent reads templates before generating content
|
||||
4. **Agent Produces Files**: Agent writes all rule files directly
|
||||
5. **No Manual Loading**: Rules auto-activate when Claude works with matching files
|
||||
|
||||
---
|
||||
|
||||
## 3-Phase Execution
|
||||
|
||||
### Phase 1: Prepare Context & Detect Tech Stack
|
||||
|
||||
**Goal**: Detect input mode, extract tech stack info, determine file extensions
|
||||
|
||||
**Input Mode Detection**:
|
||||
```bash
|
||||
input="$1"
|
||||
|
||||
if [[ "$input" == WFS-* ]]; then
|
||||
MODE="session"
|
||||
SESSION_ID="$input"
|
||||
# Read workflow-session.json to extract tech stack
|
||||
else
|
||||
MODE="direct"
|
||||
TECH_STACK_NAME="$input"
|
||||
fi
|
||||
```
|
||||
|
||||
**Tech Stack Analysis**:
|
||||
```javascript
|
||||
// Decompose composite tech stacks
|
||||
// "typescript-react-nextjs" → ["typescript", "react", "nextjs"]
|
||||
|
||||
const TECH_EXTENSIONS = {
|
||||
"typescript": "{ts,tsx}",
|
||||
"javascript": "{js,jsx}",
|
||||
"python": "py",
|
||||
"rust": "rs",
|
||||
"go": "go",
|
||||
"java": "java",
|
||||
"csharp": "cs",
|
||||
"ruby": "rb",
|
||||
"php": "php"
|
||||
};
|
||||
|
||||
const FRAMEWORK_TYPE = {
|
||||
"react": "frontend",
|
||||
"vue": "frontend",
|
||||
"angular": "frontend",
|
||||
"nextjs": "fullstack",
|
||||
"nuxt": "fullstack",
|
||||
"fastapi": "backend",
|
||||
"express": "backend",
|
||||
"django": "backend",
|
||||
"rails": "backend"
|
||||
};
|
||||
```
|
||||
|
||||
**Check Existing Rules**:
|
||||
```bash
|
||||
normalized_name=$(echo "$TECH_STACK_NAME" | tr '[:upper:]' '[:lower:]' | tr ' ' '-')
|
||||
rules_dir=".claude/rules/tech/${normalized_name}"
|
||||
existing_count=$(find "${rules_dir}" -name "*.md" 2>/dev/null | wc -l || echo 0)
|
||||
```
|
||||
|
||||
**Skip Decision**:
|
||||
- If `existing_count > 0` AND no `--regenerate` → `SKIP_GENERATION = true`
|
||||
- If `--regenerate` → Delete existing and regenerate
|
||||
|
||||
**Output Variables**:
|
||||
- `TECH_STACK_NAME`: Normalized name
|
||||
- `PRIMARY_LANG`: Primary language
|
||||
- `FILE_EXT`: File extension pattern
|
||||
- `FRAMEWORK_TYPE`: frontend | backend | fullstack | library
|
||||
- `COMPONENTS`: Array of tech components
|
||||
- `SKIP_GENERATION`: Boolean
|
||||
|
||||
**TodoWrite**: Mark phase 1 completed
|
||||
|
||||
---
|
||||
|
||||
### Phase 2: Agent Produces Path-Conditional Rules
|
||||
|
||||
**Skip Condition**: Skipped if `SKIP_GENERATION = true`
|
||||
|
||||
**Goal**: Delegate to agent for Exa research and rule file generation
|
||||
|
||||
**Template Files**:
|
||||
```
|
||||
~/.claude/workflows/cli-templates/prompts/rules/
|
||||
├── tech-rules-agent-prompt.txt # Agent instructions
|
||||
├── rule-core.txt # Core principles template
|
||||
├── rule-patterns.txt # Implementation patterns template
|
||||
├── rule-testing.txt # Testing rules template
|
||||
├── rule-config.txt # Configuration rules template
|
||||
├── rule-api.txt # API rules template (backend)
|
||||
└── rule-components.txt # Component rules template (frontend)
|
||||
```
|
||||
|
||||
**Agent Task**:
|
||||
|
||||
```javascript
|
||||
Task({
|
||||
subagent_type: "general-purpose",
|
||||
description: `Generate tech stack rules: ${TECH_STACK_NAME}`,
|
||||
prompt: `
|
||||
You are generating path-conditional rules for Claude Code.
|
||||
|
||||
## Context
|
||||
- Tech Stack: ${TECH_STACK_NAME}
|
||||
- Primary Language: ${PRIMARY_LANG}
|
||||
- File Extensions: ${FILE_EXT}
|
||||
- Framework Type: ${FRAMEWORK_TYPE}
|
||||
- Components: ${JSON.stringify(COMPONENTS)}
|
||||
- Output Directory: .claude/rules/tech/${TECH_STACK_NAME}/
|
||||
|
||||
## Instructions
|
||||
|
||||
Read the agent prompt template for detailed instructions:
|
||||
$(cat ~/.claude/workflows/cli-templates/prompts/rules/tech-rules-agent-prompt.txt)
|
||||
|
||||
## Execution Steps
|
||||
|
||||
1. Execute Exa research queries (see agent prompt)
|
||||
2. Read each rule template
|
||||
3. Generate rule files following template structure
|
||||
4. Write files to output directory
|
||||
5. Write metadata.json
|
||||
6. Report completion
|
||||
|
||||
## Variable Substitutions
|
||||
|
||||
Replace in templates:
|
||||
- {TECH_STACK_NAME} → ${TECH_STACK_NAME}
|
||||
- {PRIMARY_LANG} → ${PRIMARY_LANG}
|
||||
- {FILE_EXT} → ${FILE_EXT}
|
||||
- {FRAMEWORK_TYPE} → ${FRAMEWORK_TYPE}
|
||||
`
|
||||
})
|
||||
```
|
||||
|
||||
**Completion Criteria**:
|
||||
- 4-6 rule files written with proper `paths` frontmatter
|
||||
- metadata.json written
|
||||
- Agent reports files created
|
||||
|
||||
**TodoWrite**: Mark phase 2 completed
|
||||
|
||||
---
|
||||
|
||||
### Phase 3: Verify & Report
|
||||
|
||||
**Goal**: Verify generated files and provide usage summary
|
||||
|
||||
**Steps**:
|
||||
|
||||
1. **Verify Files**:
|
||||
```bash
|
||||
find ".claude/rules/tech/${TECH_STACK_NAME}" -name "*.md" -type f
|
||||
```
|
||||
|
||||
2. **Validate Frontmatter**:
|
||||
```bash
|
||||
head -5 ".claude/rules/tech/${TECH_STACK_NAME}/core.md"
|
||||
```
|
||||
|
||||
3. **Read Metadata**:
|
||||
```javascript
|
||||
Read(`.claude/rules/tech/${TECH_STACK_NAME}/metadata.json`)
|
||||
```
|
||||
|
||||
4. **Generate Summary Report**:
|
||||
```
|
||||
Tech Stack Rules Generated
|
||||
|
||||
Tech Stack: {TECH_STACK_NAME}
|
||||
Location: .claude/rules/tech/{TECH_STACK_NAME}/
|
||||
|
||||
Files Created:
|
||||
├── core.md → paths: **/*.{ext}
|
||||
├── patterns.md → paths: src/**/*.{ext}
|
||||
├── testing.md → paths: **/*.{test,spec}.{ext}
|
||||
├── config.md → paths: *.config.*
|
||||
├── api.md → paths: **/api/**/* (if backend)
|
||||
└── components.md → paths: **/components/**/* (if frontend)
|
||||
|
||||
Auto-Loading:
|
||||
- Rules apply automatically when editing matching files
|
||||
- No manual loading required
|
||||
|
||||
Example Activation:
|
||||
- Edit src/components/Button.tsx → core.md + patterns.md + components.md
|
||||
- Edit tests/api.test.ts → core.md + testing.md
|
||||
- Edit package.json → config.md
|
||||
```
|
||||
|
||||
**TodoWrite**: Mark phase 3 completed
|
||||
|
||||
---
|
||||
|
||||
## Path Pattern Reference
|
||||
|
||||
| Pattern | Matches |
|
||||
|---------|---------|
|
||||
| `**/*.ts` | All .ts files |
|
||||
| `src/**/*` | All files under src/ |
|
||||
| `*.config.*` | Config files in root |
|
||||
| `**/*.{ts,tsx}` | .ts and .tsx files |
|
||||
|
||||
| Tech Stack | Core Pattern | Test Pattern |
|
||||
|------------|--------------|--------------|
|
||||
| TypeScript | `**/*.{ts,tsx}` | `**/*.{test,spec}.{ts,tsx}` |
|
||||
| Python | `**/*.py` | `**/test_*.py, **/*_test.py` |
|
||||
| Rust | `**/*.rs` | `**/tests/**/*.rs` |
|
||||
| Go | `**/*.go` | `**/*_test.go` |
|
||||
|
||||
---
|
||||
|
||||
## Parameters
|
||||
|
||||
```bash
|
||||
/memory:tech-research [session-id | "tech-stack-name"] [--regenerate]
|
||||
```
|
||||
|
||||
**Arguments**:
|
||||
- **session-id**: `WFS-*` format - Extract from workflow session
|
||||
- **tech-stack-name**: Direct input - `"typescript"`, `"typescript-react"`
|
||||
- **--regenerate**: Force regenerate existing rules
|
||||
|
||||
---
|
||||
|
||||
## Examples
|
||||
|
||||
### Single Language
|
||||
|
||||
```bash
|
||||
/memory:tech-research "typescript"
|
||||
```
|
||||
|
||||
**Output**: `.claude/rules/tech/typescript/` with 4 rule files
|
||||
|
||||
### Frontend Stack
|
||||
|
||||
```bash
|
||||
/memory:tech-research "typescript-react"
|
||||
```
|
||||
|
||||
**Output**: `.claude/rules/tech/typescript-react/` with 5 rule files (includes components.md)
|
||||
|
||||
### Backend Stack
|
||||
|
||||
```bash
|
||||
/memory:tech-research "python-fastapi"
|
||||
```
|
||||
|
||||
**Output**: `.claude/rules/tech/python-fastapi/` with 5 rule files (includes api.md)
|
||||
|
||||
### From Session
|
||||
|
||||
```bash
|
||||
/memory:tech-research WFS-user-auth-20251104
|
||||
```
|
||||
|
||||
**Workflow**: Extract tech stack from session → Generate rules
|
||||
|
||||
---
|
||||
|
||||
## Comparison: Rules vs SKILL
|
||||
|
||||
| Aspect | SKILL Memory | Rules |
|
||||
|--------|--------------|-------|
|
||||
| Loading | Manual: `Skill("tech")` | Automatic by path |
|
||||
| Scope | All files when loaded | Only matching files |
|
||||
| Granularity | Monolithic packages | Per-file-type |
|
||||
| Context | Full package | Only relevant rules |
|
||||
|
||||
**When to Use**:
|
||||
- **Rules**: Tech stack conventions per file type
|
||||
- **SKILL**: Reference docs, APIs, examples for manual lookup
|
||||
332
.claude/commands/memory/tips.md
Normal file
332
.claude/commands/memory/tips.md
Normal file
@@ -0,0 +1,332 @@
|
||||
---
|
||||
name: tips
|
||||
description: Quick note-taking command to capture ideas, snippets, reminders, and insights for later reference
|
||||
argument-hint: "<note content> [--tag <tag1,tag2>] [--context <context>]"
|
||||
allowed-tools: mcp__ccw-tools__core_memory(*), Read(*)
|
||||
examples:
|
||||
- /memory:tips "Remember to use Redis for rate limiting"
|
||||
- /memory:tips "Auth pattern: JWT with refresh tokens" --tag architecture,auth
|
||||
- /memory:tips "Bug: memory leak in WebSocket handler after 24h" --context websocket-service
|
||||
- /memory:tips "Performance: lazy loading reduced bundle by 40%" --tag performance
|
||||
---
|
||||
|
||||
# Memory Tips Command (/memory:tips)
|
||||
|
||||
## 1. Overview
|
||||
|
||||
The `memory:tips` command provides **quick note-taking** for capturing:
|
||||
- Quick ideas and insights
|
||||
- Code snippets and patterns
|
||||
- Reminders and follow-ups
|
||||
- Bug notes and debugging hints
|
||||
- Performance observations
|
||||
- Architecture decisions
|
||||
- Library/tool recommendations
|
||||
|
||||
**Core Philosophy**:
|
||||
- **Speed First**: Minimal friction for capturing thoughts
|
||||
- **Searchable**: Tagged for easy retrieval
|
||||
- **Context-Aware**: Optional context linking
|
||||
- **Lightweight**: No complex session analysis
|
||||
|
||||
## 2. Parameters
|
||||
|
||||
- `<note content>` (Required): The tip/note content to save
|
||||
- `--tag <tags>` (Optional): Comma-separated tags for categorization
|
||||
- `--context <context>` (Optional): Related context (file, module, feature)
|
||||
|
||||
**Examples**:
|
||||
```bash
|
||||
/memory:tips "Use Zod for runtime validation - better DX than class-validator"
|
||||
/memory:tips "Redis connection pool: max 10, min 2" --tag config,redis
|
||||
/memory:tips "Fix needed: race condition in payment processor" --tag bug,payment --context src/payments
|
||||
```
|
||||
|
||||
## 3. Structured Output Format
|
||||
|
||||
```markdown
|
||||
## Tip ID
|
||||
TIP-YYYYMMDD-HHMMSS
|
||||
|
||||
## Timestamp
|
||||
YYYY-MM-DD HH:MM:SS
|
||||
|
||||
## Project Root
|
||||
[Absolute path to project root, e.g., D:\Claude_dms3]
|
||||
|
||||
## Content
|
||||
[The tip/note content exactly as provided]
|
||||
|
||||
## Tags
|
||||
[Comma-separated tags, or (none)]
|
||||
|
||||
## Context
|
||||
[Optional context linking - file, module, or feature reference]
|
||||
|
||||
## Session Link
|
||||
[WFS-ID if workflow session active, otherwise (none)]
|
||||
|
||||
## Auto-Detected Context
|
||||
[Files/topics from current conversation if relevant]
|
||||
```
|
||||
|
||||
## 4. Field Definitions
|
||||
|
||||
| Field | Purpose | Example |
|
||||
|-------|---------|---------|
|
||||
| **Tip ID** | Unique identifier with timestamp | TIP-20260128-143052 |
|
||||
| **Timestamp** | When tip was created | 2026-01-28 14:30:52 |
|
||||
| **Project Root** | Current project path | D:\Claude_dms3 |
|
||||
| **Content** | The actual tip/note | "Use Redis for rate limiting" |
|
||||
| **Tags** | Categorization labels | architecture, auth, performance |
|
||||
| **Context** | Related code/feature | src/auth/**, payment-module |
|
||||
| **Session Link** | Link to workflow session | WFS-auth-20260128 |
|
||||
| **Auto-Detected Context** | Files from conversation | src/api/handler.ts |
|
||||
|
||||
## 5. Execution Flow
|
||||
|
||||
### Step 1: Parse Arguments
|
||||
|
||||
```javascript
|
||||
const parseTipsCommand = (input) => {
|
||||
// Extract note content (everything before flags)
|
||||
const contentMatch = input.match(/^"([^"]+)"|^([^\s-]+)/);
|
||||
const content = contentMatch ? (contentMatch[1] || contentMatch[2]) : '';
|
||||
|
||||
// Extract tags
|
||||
const tagsMatch = input.match(/--tag\s+([^\s-]+)/);
|
||||
const tags = tagsMatch ? tagsMatch[1].split(',').map(t => t.trim()) : [];
|
||||
|
||||
// Extract context
|
||||
const contextMatch = input.match(/--context\s+([^\s-]+)/);
|
||||
const context = contextMatch ? contextMatch[1] : '';
|
||||
|
||||
return { content, tags, context };
|
||||
};
|
||||
```
|
||||
|
||||
### Step 2: Gather Context
|
||||
|
||||
```javascript
|
||||
const gatherTipContext = async () => {
|
||||
// Get project root
|
||||
const projectRoot = process.cwd(); // or detect from environment
|
||||
|
||||
// Get current session if active
|
||||
const manifest = await mcp__ccw-tools__session_manager({
|
||||
operation: "list",
|
||||
location: "active"
|
||||
});
|
||||
const sessionId = manifest.sessions?.[0]?.id || null;
|
||||
|
||||
// Auto-detect files from recent conversation
|
||||
const recentFiles = extractRecentFilesFromConversation(); // Last 5 messages
|
||||
|
||||
return {
|
||||
projectRoot,
|
||||
sessionId,
|
||||
autoDetectedContext: recentFiles
|
||||
};
|
||||
};
|
||||
```
|
||||
|
||||
### Step 3: Generate Structured Text
|
||||
|
||||
```javascript
|
||||
const generateTipText = (parsed, context) => {
|
||||
const timestamp = new Date().toISOString().replace('T', ' ').slice(0, 19);
|
||||
const tipId = `TIP-${new Date().toISOString().slice(0,10).replace(/-/g, '')}-${new Date().toTimeString().slice(0,8).replace(/:/g, '')}`;
|
||||
|
||||
return `## Tip ID
|
||||
${tipId}
|
||||
|
||||
## Timestamp
|
||||
${timestamp}
|
||||
|
||||
## Project Root
|
||||
${context.projectRoot}
|
||||
|
||||
## Content
|
||||
${parsed.content}
|
||||
|
||||
## Tags
|
||||
${parsed.tags.length > 0 ? parsed.tags.join(', ') : '(none)'}
|
||||
|
||||
## Context
|
||||
${parsed.context || '(none)'}
|
||||
|
||||
## Session Link
|
||||
${context.sessionId || '(none)'}
|
||||
|
||||
## Auto-Detected Context
|
||||
${context.autoDetectedContext.length > 0
|
||||
? context.autoDetectedContext.map(f => `- ${f}`).join('\n')
|
||||
: '(none)'}`;
|
||||
};
|
||||
```
|
||||
|
||||
### Step 4: Save to Core Memory
|
||||
|
||||
```javascript
|
||||
mcp__ccw-tools__core_memory({
|
||||
operation: "import",
|
||||
text: structuredText
|
||||
})
|
||||
```
|
||||
|
||||
**Response Format**:
|
||||
```json
|
||||
{
|
||||
"operation": "import",
|
||||
"id": "CMEM-YYYYMMDD-HHMMSS",
|
||||
"message": "Created memory: CMEM-YYYYMMDD-HHMMSS"
|
||||
}
|
||||
```
|
||||
|
||||
### Step 5: Confirm to User
|
||||
|
||||
```
|
||||
✓ Tip saved successfully
|
||||
|
||||
ID: CMEM-YYYYMMDD-HHMMSS
|
||||
Tags: architecture, auth
|
||||
Context: src/auth/**
|
||||
|
||||
To retrieve: /memory:search "auth patterns"
|
||||
Or via MCP: core_memory(operation="search", query="auth")
|
||||
```
|
||||
|
||||
## 6. Tag Categories (Suggested)
|
||||
|
||||
**Technical**:
|
||||
- `architecture` - Design decisions and patterns
|
||||
- `performance` - Optimization insights
|
||||
- `security` - Security considerations
|
||||
- `bug` - Bug notes and fixes
|
||||
- `config` - Configuration settings
|
||||
- `api` - API design patterns
|
||||
|
||||
**Development**:
|
||||
- `testing` - Test strategies and patterns
|
||||
- `debugging` - Debugging techniques
|
||||
- `refactoring` - Refactoring notes
|
||||
- `documentation` - Doc improvements
|
||||
|
||||
**Domain Specific**:
|
||||
- `auth` - Authentication/authorization
|
||||
- `database` - Database patterns
|
||||
- `frontend` - UI/UX patterns
|
||||
- `backend` - Backend logic
|
||||
- `devops` - Infrastructure and deployment
|
||||
|
||||
**Organizational**:
|
||||
- `reminder` - Follow-up items
|
||||
- `research` - Research findings
|
||||
- `idea` - Feature ideas
|
||||
- `review` - Code review notes
|
||||
|
||||
## 7. Search Integration
|
||||
|
||||
Tips can be retrieved using:
|
||||
|
||||
```bash
|
||||
# Via command (if /memory:search exists)
|
||||
/memory:search "rate limiting"
|
||||
|
||||
# Via MCP tool
|
||||
mcp__ccw-tools__core_memory({
|
||||
operation: "search",
|
||||
query: "rate limiting",
|
||||
source_type: "core_memory",
|
||||
top_k: 10
|
||||
})
|
||||
|
||||
# Via CLI
|
||||
ccw core-memory search --query "rate limiting" --top-k 10
|
||||
```
|
||||
|
||||
## 8. Quality Checklist
|
||||
|
||||
Before saving:
|
||||
- [ ] Content is clear and actionable
|
||||
- [ ] Tags are relevant and consistent
|
||||
- [ ] Context provides enough reference
|
||||
- [ ] Auto-detected context is accurate
|
||||
- [ ] Project root is absolute path
|
||||
- [ ] Timestamp is properly formatted
|
||||
|
||||
## 9. Best Practices
|
||||
|
||||
### Good Tips Examples
|
||||
|
||||
✅ **Specific and Actionable**:
|
||||
```
|
||||
"Use connection pooling for Redis: { max: 10, min: 2, acquireTimeoutMillis: 30000 }"
|
||||
--tag config,redis
|
||||
```
|
||||
|
||||
✅ **With Context**:
|
||||
```
|
||||
"Auth middleware must validate both access and refresh tokens"
|
||||
--tag security,auth --context src/middleware/auth.ts
|
||||
```
|
||||
|
||||
✅ **Problem + Solution**:
|
||||
```
|
||||
"Memory leak fixed by unsubscribing event listeners in componentWillUnmount"
|
||||
--tag bug,react --context src/components/Chat.tsx
|
||||
```
|
||||
|
||||
### Poor Tips Examples
|
||||
|
||||
❌ **Too Vague**:
|
||||
```
|
||||
"Fix the bug" --tag bug
|
||||
```
|
||||
|
||||
❌ **Too Long** (use /memory:compact instead):
|
||||
```
|
||||
"Here's the complete implementation plan for the entire auth system... [3 paragraphs]"
|
||||
```
|
||||
|
||||
❌ **No Context**:
|
||||
```
|
||||
"Remember to update this later"
|
||||
```
|
||||
|
||||
## 10. Use Cases
|
||||
|
||||
### During Development
|
||||
```bash
|
||||
/memory:tips "JWT secret must be 256-bit minimum" --tag security,auth
|
||||
/memory:tips "Use debounce (300ms) for search input" --tag performance,ux
|
||||
```
|
||||
|
||||
### After Bug Fixes
|
||||
```bash
|
||||
/memory:tips "Race condition in payment: lock with Redis SETNX" --tag bug,payment
|
||||
```
|
||||
|
||||
### Code Review Insights
|
||||
```bash
|
||||
/memory:tips "Prefer early returns over nested ifs" --tag style,readability
|
||||
```
|
||||
|
||||
### Architecture Decisions
|
||||
```bash
|
||||
/memory:tips "Chose PostgreSQL over MongoDB for ACID compliance" --tag architecture,database
|
||||
```
|
||||
|
||||
### Library Recommendations
|
||||
```bash
|
||||
/memory:tips "Zod > Yup for TypeScript validation - better type inference" --tag library,typescript
|
||||
```
|
||||
|
||||
## 11. Notes
|
||||
|
||||
- **Frequency**: Use liberally - capture all valuable insights
|
||||
- **Retrieval**: Search by tags, content, or context
|
||||
- **Lifecycle**: Tips persist across sessions
|
||||
- **Organization**: Tags enable filtering and categorization
|
||||
- **Integration**: Can reference tips in later workflows
|
||||
- **Lightweight**: No complex session analysis required
|
||||
@@ -1,517 +0,0 @@
|
||||
---
|
||||
name: workflow-skill-memory
|
||||
description: Process WFS-* archived sessions using universal-executor agents with Gemini analysis to generate workflow-progress SKILL package (sessions-timeline, lessons, conflicts)
|
||||
argument-hint: "session <session-id> | all"
|
||||
allowed-tools: Task(*), TodoWrite(*), Bash(*), Read(*), Write(*)
|
||||
---
|
||||
|
||||
# Workflow SKILL Memory Generator
|
||||
|
||||
## Overview
|
||||
|
||||
Generate SKILL package from archived workflow sessions using agent-driven analysis. Supports single-session incremental updates or parallel processing of all sessions.
|
||||
|
||||
**Scope**: Only processes WFS-* workflow sessions. Other session types (e.g., doc sessions) are automatically ignored.
|
||||
|
||||
## Usage
|
||||
|
||||
```bash
|
||||
/memory:workflow-skill-memory session WFS-<session-id> # Process single WFS session
|
||||
/memory:workflow-skill-memory all # Process all WFS sessions in parallel
|
||||
```
|
||||
|
||||
## Execution Modes
|
||||
|
||||
### Mode 1: Single Session (`session <session-id>`)
|
||||
|
||||
**Purpose**: Incremental update - process one archived session and merge into existing SKILL package
|
||||
|
||||
**Workflow**:
|
||||
1. **Validate session**: Check if session exists in `.workflow/.archives/{session-id}/`
|
||||
2. **Invoke agent**: Call `universal-executor` to analyze session and update SKILL documents
|
||||
3. **Agent tasks**:
|
||||
- Read session data from `.workflow/.archives/{session-id}/`
|
||||
- Extract lessons, conflicts, and outcomes
|
||||
- Use Gemini for intelligent aggregation (optional)
|
||||
- Update or create SKILL documents using templates
|
||||
- Regenerate SKILL.md index
|
||||
|
||||
**Command Example**:
|
||||
```bash
|
||||
/memory:workflow-skill-memory session WFS-user-auth
|
||||
```
|
||||
|
||||
**Expected Output**:
|
||||
```
|
||||
Session WFS-user-auth processed
|
||||
Updated:
|
||||
- sessions-timeline.md (1 session added)
|
||||
- lessons-learned.md (3 lessons merged)
|
||||
- conflict-patterns.md (1 conflict added)
|
||||
- SKILL.md (index regenerated)
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### Mode 2: All Sessions (`all`)
|
||||
|
||||
**Purpose**: Full regeneration - process all archived sessions in parallel for complete SKILL package
|
||||
|
||||
**Workflow**:
|
||||
1. **List sessions**: Read manifest.json to get all archived session IDs
|
||||
2. **Parallel invocation**: Launch multiple `universal-executor` agents in parallel (one per session)
|
||||
3. **Agent coordination**:
|
||||
- Each agent processes one session independently
|
||||
- Agents use Gemini for analysis
|
||||
- Agents collect data into JSON (no direct file writes)
|
||||
- Final aggregator agent merges results and generates SKILL documents
|
||||
|
||||
**Command Example**:
|
||||
```bash
|
||||
/memory:workflow-skill-memory all
|
||||
```
|
||||
|
||||
**Expected Output**:
|
||||
```
|
||||
All sessions processed in parallel
|
||||
Sessions: 8 total
|
||||
Updated:
|
||||
- sessions-timeline.md (8 sessions)
|
||||
- lessons-learned.md (24 lessons aggregated)
|
||||
- conflict-patterns.md (12 conflicts documented)
|
||||
- SKILL.md (index regenerated)
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Implementation Flow
|
||||
|
||||
### Phase 1: Validation and Setup
|
||||
|
||||
**Step 1.1: Parse Command Arguments**
|
||||
|
||||
Extract mode and session ID:
|
||||
```javascript
|
||||
if (args === "all") {
|
||||
mode = "all"
|
||||
} else if (args.startsWith("session ")) {
|
||||
mode = "session"
|
||||
session_id = args.replace("session ", "").trim()
|
||||
} else {
|
||||
ERROR = "Invalid arguments. Usage: session <session-id> | all"
|
||||
EXIT
|
||||
}
|
||||
```
|
||||
|
||||
**Step 1.2: Validate Archive Directory**
|
||||
```bash
|
||||
bash(test -d .workflow/.archives && echo "exists" || echo "missing")
|
||||
```
|
||||
|
||||
If missing, report error and exit.
|
||||
|
||||
**Step 1.3: Mode-Specific Validation**
|
||||
|
||||
**Single Session Mode**:
|
||||
```bash
|
||||
# Validate session ID format (must start with WFS-)
|
||||
if [[ ! "$session_id" =~ ^WFS- ]]; then
|
||||
ERROR = "Invalid session ID format. Only WFS-* sessions are supported"
|
||||
EXIT
|
||||
fi
|
||||
|
||||
# Check if session exists
|
||||
bash(test -d .workflow/.archives/{session_id} && echo "exists" || echo "missing")
|
||||
```
|
||||
|
||||
If missing, report error: "Session {session_id} not found in archives"
|
||||
|
||||
**All Sessions Mode**:
|
||||
```bash
|
||||
# Read manifest and filter only WFS- sessions
|
||||
bash(cat .workflow/.archives/manifest.json | jq -r '.archives[].session_id | select(startswith("WFS-"))')
|
||||
```
|
||||
|
||||
Store filtered session IDs in array. Ignore doc sessions and other non-WFS sessions.
|
||||
|
||||
**Step 1.4: TodoWrite Initialization**
|
||||
|
||||
**Single Session Mode**:
|
||||
```javascript
|
||||
TodoWrite({todos: [
|
||||
{"content": "Validate session existence", "status": "completed", "activeForm": "Validating session"},
|
||||
{"content": "Invoke agent to process session", "status": "in_progress", "activeForm": "Invoking agent"},
|
||||
{"content": "Verify SKILL package updated", "status": "pending", "activeForm": "Verifying update"}
|
||||
]})
|
||||
```
|
||||
|
||||
**All Sessions Mode**:
|
||||
```javascript
|
||||
TodoWrite({todos: [
|
||||
{"content": "Read manifest and list sessions", "status": "completed", "activeForm": "Reading manifest"},
|
||||
{"content": "Invoke agents in parallel", "status": "in_progress", "activeForm": "Invoking agents"},
|
||||
{"content": "Verify SKILL package regenerated", "status": "pending", "activeForm": "Verifying regeneration"}
|
||||
]})
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### Phase 2: Agent Invocation
|
||||
|
||||
#### Single Session Mode - Agent Task
|
||||
|
||||
Invoke `universal-executor` with session-specific task:
|
||||
|
||||
**Agent Prompt Structure**:
|
||||
```
|
||||
Task: Process Workflow Session for SKILL Package
|
||||
|
||||
Context:
|
||||
- Session ID: {session_id}
|
||||
- Session Path: .workflow/.archives/{session_id}/
|
||||
- Mode: Incremental update
|
||||
|
||||
Objectives:
|
||||
|
||||
1. Read session data:
|
||||
- workflow-session.json (metadata)
|
||||
- IMPL_PLAN.md (implementation summary)
|
||||
- TODO_LIST.md (if exists)
|
||||
- manifest.json entry for lessons
|
||||
|
||||
2. Extract key information:
|
||||
- Description, tags, metrics
|
||||
- Lessons (successes, challenges, watch_patterns)
|
||||
- Context package path (reference only)
|
||||
- Key outcomes from IMPL_PLAN
|
||||
|
||||
3. Use Gemini for aggregation (optional):
|
||||
Command pattern:
|
||||
ccw cli -p "
|
||||
PURPOSE: Extract lessons and conflicts from workflow session
|
||||
TASK:
|
||||
• Analyze IMPL_PLAN and lessons from manifest
|
||||
• Identify success patterns and challenges
|
||||
• Extract conflict patterns with resolutions
|
||||
• Categorize by functional domain
|
||||
MODE: analysis
|
||||
CONTEXT: @IMPL_PLAN.md @workflow-session.json
|
||||
EXPECTED: Structured lessons and conflicts in JSON format
|
||||
RULES: Template reference from skill-aggregation.txt
|
||||
" --tool gemini --mode analysis --cd .workflow/.archives/{session_id}
|
||||
|
||||
3.5. **Generate SKILL.md Description** (CRITICAL for auto-loading):
|
||||
|
||||
Read skill-index.txt template Section: "Description Field Generation"
|
||||
|
||||
Execute command to get project root:
|
||||
```bash
|
||||
git rev-parse --show-toplevel # Example output: /d/Claude_dms3
|
||||
```
|
||||
|
||||
Apply description format:
|
||||
```
|
||||
Progressive workflow development history (located at {project_root}).
|
||||
Load this SKILL when continuing development, analyzing past implementations,
|
||||
or learning from workflow history, especially when no relevant context exists in memory.
|
||||
```
|
||||
|
||||
**Validation**:
|
||||
- [ ] Path uses forward slashes (not backslashes)
|
||||
- [ ] All three use cases present
|
||||
- [ ] Trigger optimization phrase included
|
||||
- [ ] Path is absolute (starts with / or drive letter)
|
||||
|
||||
4. Read templates for formatting guidance:
|
||||
- ~/.claude/workflows/cli-templates/prompts/workflow/skill-sessions-timeline.txt
|
||||
- ~/.claude/workflows/cli-templates/prompts/workflow/skill-lessons-learned.txt
|
||||
- ~/.claude/workflows/cli-templates/prompts/workflow/skill-conflict-patterns.txt
|
||||
- ~/.claude/workflows/cli-templates/prompts/workflow/skill-index.txt
|
||||
|
||||
**CRITICAL**: From skill-index.txt, read these sections:
|
||||
- "Description Field Generation" - Rules for generating description
|
||||
- "Variable Substitution Guide" - All required variables
|
||||
- "Generation Instructions" - Step-by-step generation process
|
||||
- "Validation Checklist" - Final validation steps
|
||||
|
||||
5. Update SKILL documents:
|
||||
- sessions-timeline.md: Append new session, update domain grouping
|
||||
- lessons-learned.md: Merge lessons into categories, update frequencies
|
||||
- conflict-patterns.md: Add conflicts, update recurring pattern frequencies
|
||||
- SKILL.md: Regenerate index with updated counts
|
||||
|
||||
**For SKILL.md generation**:
|
||||
- Follow "Generation Instructions" from skill-index.txt (Steps 1-7)
|
||||
- Use git command for project_root: `git rev-parse --show-toplevel`
|
||||
- Apply "Description Field Generation" rules
|
||||
- Validate using "Validation Checklist"
|
||||
- Increment version (patch level)
|
||||
|
||||
6. Return result JSON:
|
||||
{
|
||||
"status": "success",
|
||||
"session_id": "{session_id}",
|
||||
"updates": {
|
||||
"sessions_added": 1,
|
||||
"lessons_merged": count,
|
||||
"conflicts_added": count
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
#### All Sessions Mode - Parallel Agent Tasks
|
||||
|
||||
**Step 2.1: Launch parallel session analyzers**
|
||||
|
||||
Invoke multiple agents in parallel (one message with multiple Task calls):
|
||||
|
||||
**Per-Session Agent Prompt**:
|
||||
```
|
||||
Task: Extract Session Data for SKILL Package
|
||||
|
||||
Context:
|
||||
- Session ID: {session_id}
|
||||
- Mode: Parallel analysis (no direct file writes)
|
||||
|
||||
Objectives:
|
||||
|
||||
1. Read session data (same as single mode)
|
||||
|
||||
2. Extract key information (same as single mode)
|
||||
|
||||
3. Use Gemini for analysis (same as single mode)
|
||||
|
||||
4. Return structured data JSON:
|
||||
{
|
||||
"status": "success",
|
||||
"session_id": "{session_id}",
|
||||
"data": {
|
||||
"metadata": {
|
||||
"description": "...",
|
||||
"archived_at": "...",
|
||||
"tags": [...],
|
||||
"metrics": {...}
|
||||
},
|
||||
"lessons": {
|
||||
"successes": [...],
|
||||
"challenges": [...],
|
||||
"watch_patterns": [...]
|
||||
},
|
||||
"conflicts": [
|
||||
{
|
||||
"type": "architecture|dependencies|testing|performance",
|
||||
"pattern": "...",
|
||||
"resolution": "...",
|
||||
"code_impact": [...]
|
||||
}
|
||||
],
|
||||
"impl_summary": "First 200 chars of IMPL_PLAN",
|
||||
"context_package_path": "..."
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
**Step 2.2: Aggregate results**
|
||||
|
||||
After all session agents complete, invoke aggregator agent:
|
||||
|
||||
**Aggregator Agent Prompt**:
|
||||
```
|
||||
Task: Aggregate Session Results and Generate SKILL Package
|
||||
|
||||
Context:
|
||||
- Mode: Full regeneration
|
||||
- Input: JSON results from {session_count} session agents
|
||||
|
||||
Objectives:
|
||||
|
||||
1. Aggregate all session data:
|
||||
- Collect metadata from all sessions
|
||||
- Merge lessons by category
|
||||
- Group conflicts by type
|
||||
- Sort sessions by date
|
||||
|
||||
2. Use Gemini for final aggregation:
|
||||
ccw cli -p "
|
||||
PURPOSE: Aggregate lessons and conflicts from all workflow sessions
|
||||
TASK:
|
||||
• Group successes by functional domain
|
||||
• Categorize challenges by severity (HIGH/MEDIUM/LOW)
|
||||
• Identify recurring conflict patterns
|
||||
• Calculate frequencies and prioritize
|
||||
MODE: analysis
|
||||
CONTEXT: [Provide aggregated JSON data]
|
||||
EXPECTED: Final aggregated structure for SKILL documents
|
||||
RULES: Template reference from skill-aggregation.txt
|
||||
" --tool gemini --mode analysis
|
||||
|
||||
3. Read templates for formatting (same 4 templates as single mode)
|
||||
|
||||
4. Generate all SKILL documents:
|
||||
- sessions-timeline.md (all sessions, sorted by date)
|
||||
- lessons-learned.md (aggregated lessons with frequencies)
|
||||
- conflict-patterns.md (recurring patterns with resolutions)
|
||||
- SKILL.md (index with progressive loading)
|
||||
|
||||
5. Write files to .claude/skills/workflow-progress/
|
||||
|
||||
6. Return result JSON:
|
||||
{
|
||||
"status": "success",
|
||||
"sessions_processed": count,
|
||||
"files_generated": ["SKILL.md", "sessions-timeline.md", ...],
|
||||
"summary": {
|
||||
"total_sessions": count,
|
||||
"functional_domains": [...],
|
||||
"date_range": "...",
|
||||
"lessons_count": count,
|
||||
"conflicts_count": count
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### Phase 3: Verification
|
||||
|
||||
**Step 3.1: Check SKILL Package Files**
|
||||
```bash
|
||||
bash(ls -lh .claude/skills/workflow-progress/)
|
||||
```
|
||||
|
||||
Verify all 4 files exist:
|
||||
- SKILL.md
|
||||
- sessions-timeline.md
|
||||
- lessons-learned.md
|
||||
- conflict-patterns.md
|
||||
|
||||
**Step 3.2: TodoWrite Completion**
|
||||
|
||||
Mark all tasks as completed.
|
||||
|
||||
**Step 3.3: Display Summary**
|
||||
|
||||
**Single Session Mode**:
|
||||
```
|
||||
Session {session_id} processed successfully
|
||||
|
||||
Updated:
|
||||
- sessions-timeline.md
|
||||
- lessons-learned.md
|
||||
- conflict-patterns.md
|
||||
- SKILL.md
|
||||
|
||||
SKILL Location: .claude/skills/workflow-progress/SKILL.md
|
||||
```
|
||||
|
||||
**All Sessions Mode**:
|
||||
```
|
||||
All sessions processed in parallel
|
||||
|
||||
Sessions: {count} total
|
||||
Functional Domains: {domain_list}
|
||||
Date Range: {earliest} - {latest}
|
||||
|
||||
Generated:
|
||||
- sessions-timeline.md ({count} sessions)
|
||||
- lessons-learned.md ({lessons_count} lessons)
|
||||
- conflict-patterns.md ({conflicts_count} conflicts)
|
||||
- SKILL.md (4-level progressive loading)
|
||||
|
||||
SKILL Location: .claude/skills/workflow-progress/SKILL.md
|
||||
|
||||
Usage:
|
||||
- Level 0: Quick refresh (~2K tokens)
|
||||
- Level 1: Recent history (~8K tokens)
|
||||
- Level 2: Complete analysis (~25K tokens)
|
||||
- Level 3: Deep dive (~40K tokens)
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Agent Guidelines
|
||||
|
||||
### Agent Capabilities
|
||||
|
||||
**universal-executor agents can**:
|
||||
- Read files from `.workflow/.archives/`
|
||||
- Execute bash commands
|
||||
- Call Gemini CLI for intelligent analysis
|
||||
- Read template files for formatting guidance
|
||||
- Write SKILL package files (single mode) or return JSON (parallel mode)
|
||||
- Return structured results
|
||||
|
||||
### Gemini Usage Pattern
|
||||
|
||||
**When to use Gemini**:
|
||||
- Aggregating lessons from multiple sources
|
||||
- Identifying recurring patterns
|
||||
- Classifying conflicts by type and severity
|
||||
- Extracting structured data from IMPL_PLAN
|
||||
|
||||
**Fallback Strategy**: If Gemini fails or times out, use direct file parsing with structured extraction logic.
|
||||
|
||||
---
|
||||
|
||||
## Template System
|
||||
|
||||
### Template Files
|
||||
|
||||
All templates located in: `~/.claude/workflows/cli-templates/prompts/workflow/`
|
||||
|
||||
1. **skill-sessions-timeline.txt**: Format for sessions-timeline.md
|
||||
2. **skill-lessons-learned.txt**: Format for lessons-learned.md
|
||||
3. **skill-conflict-patterns.txt**: Format for conflict-patterns.md
|
||||
4. **skill-index.txt**: Format for SKILL.md index
|
||||
5. **skill-aggregation.txt**: Rules for Gemini aggregation (existing)
|
||||
|
||||
### Template Usage in Agent
|
||||
|
||||
**Agents read templates to understand**:
|
||||
- File structure and markdown format
|
||||
- Data sources (which files to read)
|
||||
- Update strategy (incremental vs full)
|
||||
- Formatting rules and conventions
|
||||
- Aggregation logic (for Gemini)
|
||||
|
||||
**Templates are NOT shown in this command documentation** - agents read them directly as needed.
|
||||
|
||||
---
|
||||
|
||||
## Error Handling
|
||||
|
||||
### Validation Errors
|
||||
- **No archives directory**: "Error: No workflow archives found at .workflow/.archives/"
|
||||
- **Invalid session ID format**: "Error: Invalid session ID format. Only WFS-* sessions are supported"
|
||||
- **Session not found**: "Error: Session {session_id} not found in archives"
|
||||
- **No WFS sessions in manifest**: "Error: No WFS-* workflow sessions found in manifest.json"
|
||||
|
||||
### Agent Errors
|
||||
- If agent fails, report error message from agent result
|
||||
- If Gemini times out, agents use fallback direct parsing
|
||||
- If template read fails, agents use inline format
|
||||
|
||||
### Recovery
|
||||
- Single session mode: Can be retried without affecting other sessions
|
||||
- All sessions mode: If one agent fails, others continue; retry failed sessions individually
|
||||
|
||||
|
||||
|
||||
## Integration
|
||||
|
||||
### Called by `/workflow:session:complete`
|
||||
|
||||
Automatically invoked after session archival:
|
||||
```bash
|
||||
SlashCommand(command="/memory:workflow-skill-memory session {session_id}")
|
||||
```
|
||||
|
||||
### Manual Invocation
|
||||
|
||||
Users can manually process sessions:
|
||||
```bash
|
||||
/memory:workflow-skill-memory session WFS-custom-feature # Single session
|
||||
/memory:workflow-skill-memory all # Full regeneration
|
||||
```
|
||||
@@ -1,204 +0,0 @@
|
||||
---
|
||||
name: breakdown
|
||||
description: Decompose complex task into subtasks with dependency mapping, creates child task JSONs with parent references and execution order
|
||||
argument-hint: "task-id"
|
||||
---
|
||||
|
||||
# Task Breakdown Command (/task:breakdown)
|
||||
|
||||
## Overview
|
||||
Breaks down complex tasks into executable subtasks with context inheritance and agent assignment.
|
||||
|
||||
## Core Principles
|
||||
**File Cohesion:** Related files must stay in same task
|
||||
**10-Task Limit:** Total tasks cannot exceed 10 (triggers re-scoping)
|
||||
|
||||
## Core Features
|
||||
|
||||
**CRITICAL**: Manual breakdown with safety controls to prevent file conflicts and task limit violations.
|
||||
|
||||
### Breakdown Process
|
||||
1. **Session Check**: Verify active session contains parent task
|
||||
2. **Task Validation**: Ensure parent is `pending` status
|
||||
3. **10-Task Limit Check**: Verify breakdown won't exceed total limit
|
||||
4. **Manual Decomposition**: User defines subtasks with validation
|
||||
5. **File Conflict Detection**: Warn if same files appear in multiple subtasks
|
||||
6. **Similar Function Warning**: Alert if subtasks have overlapping functionality
|
||||
7. **Context Distribution**: Inherit parent requirements and scope
|
||||
8. **Agent Assignment**: Auto-assign agents based on subtask type
|
||||
9. **TODO_LIST Update**: Regenerate TODO_LIST.md with new structure
|
||||
|
||||
### Breakdown Rules
|
||||
- Only `pending` tasks can be broken down
|
||||
- **Manual breakdown only**: Automated breakdown disabled to prevent violations
|
||||
- Parent becomes `container` status (not executable)
|
||||
- Subtasks use format: IMPL-N.M (max 2 levels)
|
||||
- Context flows from parent to subtasks
|
||||
- All relationships tracked in JSON
|
||||
- **10-task limit enforced**: Breakdown rejected if total would exceed 10 tasks
|
||||
- **File cohesion preserved**: Same files cannot be split across subtasks
|
||||
|
||||
## Usage
|
||||
|
||||
### Basic Breakdown
|
||||
```bash
|
||||
/task:breakdown impl-1
|
||||
```
|
||||
|
||||
Interactive process:
|
||||
```
|
||||
Task: Build authentication module
|
||||
Current total tasks: 6/10
|
||||
|
||||
MANUAL BREAKDOWN REQUIRED
|
||||
Define subtasks manually (remaining capacity: 4 tasks):
|
||||
|
||||
1. Enter subtask title: User authentication core
|
||||
Focus files: models/User.js, routes/auth.js, middleware/auth.js
|
||||
|
||||
2. Enter subtask title: OAuth integration
|
||||
Focus files: services/OAuthService.js, routes/oauth.js
|
||||
|
||||
FILE CONFLICT DETECTED:
|
||||
- routes/auth.js appears in multiple subtasks
|
||||
- Recommendation: Merge related authentication routes
|
||||
|
||||
SIMILAR FUNCTIONALITY WARNING:
|
||||
- "User authentication" and "OAuth integration" both handle auth
|
||||
- Consider combining into single task
|
||||
|
||||
# Use AskUserQuestion for confirmation
|
||||
AskUserQuestion({
|
||||
questions: [{
|
||||
question: "File conflicts and/or similar functionality detected. How do you want to proceed?",
|
||||
header: "Confirm",
|
||||
options: [
|
||||
{ label: "Proceed with breakdown", description: "Accept the risks and create the subtasks as defined." },
|
||||
{ label: "Restart breakdown", description: "Discard current subtasks and start over." },
|
||||
{ label: "Cancel breakdown", description: "Abort the operation and leave the parent task as is." }
|
||||
],
|
||||
multiSelect: false
|
||||
}]
|
||||
})
|
||||
|
||||
User selected: "Proceed with breakdown"
|
||||
|
||||
Task IMPL-1 broken down:
|
||||
IMPL-1: Build authentication module (container)
|
||||
├── IMPL-1.1: User authentication core -> @code-developer
|
||||
└── IMPL-1.2: OAuth integration -> @code-developer
|
||||
|
||||
Files updated: .task/IMPL-1.json + 2 subtask files + TODO_LIST.md
|
||||
```
|
||||
|
||||
## Decomposition Logic
|
||||
|
||||
### Agent Assignment
|
||||
- **Design/Planning** → `@planning-agent`
|
||||
- **Implementation** → `@code-developer`
|
||||
- **Testing** → `@code-developer` (type: "test-gen")
|
||||
- **Test Validation** → `@test-fix-agent` (type: "test-fix")
|
||||
- **Review** → `@universal-executor` (optional)
|
||||
|
||||
### Context Inheritance
|
||||
- Subtasks inherit parent requirements
|
||||
- Scope refined for specific subtask
|
||||
- Implementation details distributed appropriately
|
||||
|
||||
## Safety Controls
|
||||
|
||||
### File Conflict Detection
|
||||
**Validates file cohesion across subtasks:**
|
||||
- Scans `focus_paths` in all subtasks
|
||||
- Warns if same file appears in multiple subtasks
|
||||
- Suggests merging subtasks with overlapping files
|
||||
- Blocks breakdown if critical conflicts detected
|
||||
|
||||
### Similar Functionality Detection
|
||||
**Prevents functional overlap:**
|
||||
- Analyzes subtask titles for similar keywords
|
||||
- Warns about potential functional redundancy
|
||||
- Suggests consolidation of related functionality
|
||||
- Examples: "user auth" + "login system" → merge recommendation
|
||||
|
||||
### 10-Task Limit Enforcement
|
||||
**Hard limit compliance:**
|
||||
- Counts current total tasks in session
|
||||
- Calculates breakdown impact on total
|
||||
- Rejects breakdown if would exceed 10 tasks
|
||||
- Suggests re-scoping if limit reached
|
||||
|
||||
### Manual Control Requirements
|
||||
**User-driven breakdown only:**
|
||||
- No automatic subtask generation
|
||||
- User must define each subtask title and scope
|
||||
- Real-time validation during input
|
||||
- Confirmation required before execution
|
||||
|
||||
## Implementation Details
|
||||
|
||||
- Complete task JSON schema
|
||||
- Implementation field structure
|
||||
- Context inheritance rules
|
||||
- Agent assignment logic
|
||||
|
||||
## Validation
|
||||
|
||||
### Pre-breakdown Checks
|
||||
1. Active session exists
|
||||
2. Task found in session
|
||||
3. Task status is `pending`
|
||||
4. Not already broken down
|
||||
5. **10-task limit compliance**: Total tasks + new subtasks ≤ 10
|
||||
6. **Manual mode enabled**: No automatic breakdown allowed
|
||||
|
||||
### Post-breakdown Actions
|
||||
1. Update parent to `container` status
|
||||
2. Create subtask JSON files
|
||||
3. Update parent subtasks list
|
||||
4. Update session stats
|
||||
5. **Regenerate TODO_LIST.md** with new hierarchy
|
||||
6. Validate file paths in focus_paths
|
||||
7. Update session task count
|
||||
|
||||
## Examples
|
||||
|
||||
### Basic Breakdown
|
||||
```bash
|
||||
/task:breakdown impl-1
|
||||
|
||||
impl-1: Build authentication (container)
|
||||
├── impl-1.1: Design schema -> @planning-agent
|
||||
├── impl-1.2: Implement logic + tests -> @code-developer
|
||||
└── impl-1.3: Execute & fix tests -> @test-fix-agent
|
||||
```
|
||||
|
||||
## Error Handling
|
||||
|
||||
```bash
|
||||
# Task not found
|
||||
Task IMPL-5 not found
|
||||
|
||||
# Already broken down
|
||||
Task IMPL-1 already has subtasks
|
||||
|
||||
# Wrong status
|
||||
Cannot breakdown completed task IMPL-2
|
||||
|
||||
# 10-task limit exceeded
|
||||
Breakdown would exceed 10-task limit (current: 8, proposed: 4)
|
||||
Suggestion: Re-scope project into smaller iterations
|
||||
|
||||
# File conflicts detected
|
||||
File conflict: routes/auth.js appears in IMPL-1.1 and IMPL-1.2
|
||||
Recommendation: Merge subtasks or redistribute files
|
||||
|
||||
# Similar functionality warning
|
||||
Similar functions detected: "user login" and "authentication"
|
||||
Consider consolidating related functionality
|
||||
|
||||
# Manual breakdown required
|
||||
Automatic breakdown disabled. Use manual breakdown process.
|
||||
```
|
||||
|
||||
**System ensures**: Manual breakdown control with file cohesion enforcement, similar functionality detection, and 10-task limit compliance
|
||||
@@ -1,152 +0,0 @@
|
||||
---
|
||||
name: create
|
||||
description: Generate task JSON from natural language description with automatic file pattern detection, scope inference, and dependency analysis
|
||||
argument-hint: "\"task title\""
|
||||
---
|
||||
|
||||
# Task Create Command (/task:create)
|
||||
|
||||
## Overview
|
||||
Creates new implementation tasks with automatic context awareness and ID generation.
|
||||
|
||||
## Core Principles
|
||||
**Task System:** @~/.claude/workflows/task-core.md
|
||||
|
||||
## Core Features
|
||||
|
||||
### Automatic Behaviors
|
||||
- **ID Generation**: Auto-generates IMPL-N format (max 2 levels)
|
||||
- **Context Inheritance**: Inherits from active workflow session
|
||||
- **JSON Creation**: Creates task JSON in active session
|
||||
- **Status Setting**: Initial status = "pending"
|
||||
- **Agent Assignment**: Suggests agent based on task type
|
||||
- **Session Integration**: Updates workflow session stats
|
||||
|
||||
### Context Awareness
|
||||
- Validates active workflow session exists
|
||||
- Avoids duplicate task IDs
|
||||
- Inherits session requirements and scope
|
||||
- Suggests task relationships
|
||||
|
||||
## Usage
|
||||
|
||||
### Basic Creation
|
||||
```bash
|
||||
/task:create "Build authentication module"
|
||||
```
|
||||
|
||||
Output:
|
||||
```
|
||||
Task created: IMPL-1
|
||||
Title: Build authentication module
|
||||
Type: feature
|
||||
Agent: code-developer
|
||||
Status: pending
|
||||
```
|
||||
|
||||
### Task Types
|
||||
- `feature` - New functionality (default)
|
||||
- `bugfix` - Bug fixes
|
||||
- `refactor` - Code improvements
|
||||
- `test` - Test implementation
|
||||
- `docs` - Documentation
|
||||
|
||||
## Task Creation Process
|
||||
|
||||
1. **Session Validation**: Check active workflow session
|
||||
2. **ID Generation**: Auto-increment IMPL-N
|
||||
3. **Context Inheritance**: Load workflow context
|
||||
4. **Implementation Setup**: Initialize implementation field
|
||||
5. **Agent Assignment**: Select appropriate agent
|
||||
6. **File Creation**: Save JSON to .task/ directory
|
||||
7. **Session Update**: Update workflow stats
|
||||
|
||||
**Task Schema**: See @~/.claude/workflows/task-core.md for complete JSON structure
|
||||
|
||||
## Implementation Field Setup
|
||||
|
||||
### Auto-Population Strategy
|
||||
- **Detailed info**: Extract from task description and scope
|
||||
- **Missing info**: Mark `pre_analysis` as multi-step array format for later pre-analysis
|
||||
- **Basic structure**: Initialize with standard template
|
||||
|
||||
### Analysis Triggers
|
||||
When implementation details incomplete:
|
||||
```bash
|
||||
Task requires analysis for implementation details
|
||||
Suggest running: gemini analysis for file locations and dependencies
|
||||
```
|
||||
|
||||
## File Management
|
||||
|
||||
### JSON Task File
|
||||
- **Location**: `.task/IMPL-[N].json` in active session
|
||||
- **Content**: Complete task with implementation field
|
||||
- **Updates**: Session stats only
|
||||
|
||||
### Simple Process
|
||||
1. Validate session and inputs
|
||||
2. Generate task JSON
|
||||
3. Update session stats
|
||||
4. Notify completion
|
||||
|
||||
## Context Inheritance
|
||||
|
||||
Tasks inherit from:
|
||||
1. **Active Session** - Requirements and scope from workflow-session.json
|
||||
2. **Planning Document** - Context from IMPL_PLAN.md
|
||||
3. **Parent Task** - For subtasks (IMPL-N.M format)
|
||||
|
||||
## Agent Assignment
|
||||
|
||||
Based on task type and title keywords:
|
||||
- **Build/Implement** → @code-developer
|
||||
- **Design/Plan** → @planning-agent
|
||||
- **Test Generation** → @code-developer (type: "test-gen")
|
||||
- **Test Execution/Fix** → @test-fix-agent (type: "test-fix")
|
||||
- **Review/Audit** → @universal-executor (optional, only when explicitly requested)
|
||||
|
||||
## Validation Rules
|
||||
|
||||
1. **Session Check** - Active workflow session required
|
||||
2. **Duplicate Check** - Avoid similar task titles
|
||||
3. **ID Uniqueness** - Auto-increment task IDs
|
||||
4. **Schema Validation** - Ensure proper JSON structure
|
||||
|
||||
## Error Handling
|
||||
|
||||
```bash
|
||||
# No workflow session
|
||||
No active workflow found
|
||||
Use: /workflow init "project name"
|
||||
|
||||
# Duplicate task
|
||||
Similar task exists: IMPL-3
|
||||
Continue anyway? (y/n)
|
||||
|
||||
# Max depth exceeded
|
||||
Cannot create IMPL-1.2.1 (max 2 levels)
|
||||
Use: IMPL-2 for new main task
|
||||
```
|
||||
|
||||
## Examples
|
||||
|
||||
### Feature Task
|
||||
```bash
|
||||
/task:create "Implement user authentication"
|
||||
|
||||
Created IMPL-1: Implement user authentication
|
||||
Type: feature
|
||||
Agent: code-developer
|
||||
Status: pending
|
||||
```
|
||||
|
||||
### Bug Fix
|
||||
```bash
|
||||
/task:create "Fix login validation bug" --type=bugfix
|
||||
|
||||
Created IMPL-2: Fix login validation bug
|
||||
Type: bugfix
|
||||
Agent: code-developer
|
||||
Status: pending
|
||||
```
|
||||
@@ -1,270 +0,0 @@
|
||||
---
|
||||
name: execute
|
||||
description: Execute task JSON using appropriate agent (@doc-generator/@implementation-agent/@test-agent) with pre-analysis context loading and status tracking
|
||||
argument-hint: "task-id"
|
||||
---
|
||||
|
||||
## Command Overview: /task:execute
|
||||
|
||||
**Purpose**: Executes tasks using intelligent agent selection, context preparation, and progress tracking.
|
||||
|
||||
|
||||
## Execution Modes
|
||||
|
||||
- **auto (Default)**
|
||||
- Fully autonomous execution with automatic agent selection.
|
||||
- Provides progress updates at each checkpoint.
|
||||
- Automatically completes the task when done.
|
||||
- **guided**
|
||||
- Executes step-by-step, requiring user confirmation at each checkpoint.
|
||||
- Allows for dynamic adjustments and manual review during the process.
|
||||
- **review**
|
||||
- Optional manual review using `@universal-executor`.
|
||||
- Used only when explicitly requested by user.
|
||||
|
||||
## Agent Selection Logic
|
||||
|
||||
The system determines the appropriate agent for a task using the following logic.
|
||||
|
||||
```pseudo
|
||||
FUNCTION select_agent(task, agent_override):
|
||||
// A manual override always takes precedence.
|
||||
// Corresponds to the --agent=<agent-type> flag.
|
||||
IF agent_override IS NOT NULL:
|
||||
RETURN agent_override
|
||||
|
||||
// If no override, select based on keywords in the task title.
|
||||
ELSE:
|
||||
CASE task.title:
|
||||
WHEN CONTAINS "Build API", "Implement":
|
||||
RETURN "@code-developer"
|
||||
WHEN CONTAINS "Design schema", "Plan":
|
||||
RETURN "@planning-agent"
|
||||
WHEN CONTAINS "Write tests", "Generate tests":
|
||||
RETURN "@code-developer" // type: test-gen
|
||||
WHEN CONTAINS "Execute tests", "Fix tests", "Validate":
|
||||
RETURN "@test-fix-agent" // type: test-fix
|
||||
WHEN CONTAINS "Review code":
|
||||
RETURN "@universal-executor" // Optional manual review
|
||||
DEFAULT:
|
||||
RETURN "@code-developer" // Default agent
|
||||
END CASE
|
||||
END FUNCTION
|
||||
```
|
||||
|
||||
## Core Execution Protocol
|
||||
|
||||
`Pre-Execution` -> `Execution` -> `Post-Execution`
|
||||
|
||||
### Pre-Execution Protocol
|
||||
|
||||
`Validate Task & Dependencies` **->** `Prepare Execution Context` **->** `Coordinate with TodoWrite`
|
||||
|
||||
- **Validation**: Checks for the task's JSON file in `.task/` and resolves its dependencies.
|
||||
- **Context Preparation**: Loads task and workflow context, preparing it for the selected agent.
|
||||
- **Session Context Injection**: Provides workflow directory paths to agents for TODO_LIST.md and summary management.
|
||||
- **TodoWrite Coordination**: Generates execution Todos and checkpoints, syncing with `TODO_LIST.md`.
|
||||
|
||||
### Post-Execution Protocol
|
||||
|
||||
`Update Task Status` **->** `Generate Summary` **->** `Save Artifacts` **->** `Sync All Progress` **->** `Validate File Integrity`
|
||||
|
||||
- Updates status in the task's JSON file and `TODO_LIST.md`.
|
||||
- Creates a summary in `.summaries/`.
|
||||
- Stores outputs and syncs progress across the entire workflow session.
|
||||
|
||||
### Task & Subtask Execution Logic
|
||||
|
||||
This logic defines how single, multiple, or parent tasks are handled.
|
||||
|
||||
```pseudo
|
||||
FUNCTION execute_task_command(task_id, mode, parallel_flag):
|
||||
// Handle parent tasks by executing their subtasks.
|
||||
IF is_parent_task(task_id):
|
||||
subtasks = get_subtasks(task_id)
|
||||
EXECUTE_SUBTASK_BATCH(subtasks, mode)
|
||||
|
||||
// Handle wildcard execution (e.g., IMPL-001.*)
|
||||
ELSE IF task_id CONTAINS "*":
|
||||
subtasks = find_matching_tasks(task_id)
|
||||
IF parallel_flag IS true:
|
||||
EXECUTE_IN_PARALLEL(subtasks)
|
||||
ELSE:
|
||||
FOR each subtask in subtasks:
|
||||
EXECUTE_SINGLE_TASK(subtask, mode)
|
||||
|
||||
// Default case for a single task ID.
|
||||
ELSE:
|
||||
EXECUTE_SINGLE_TASK(task_id, mode)
|
||||
END FUNCTION
|
||||
```
|
||||
|
||||
### Error Handling & Recovery Logic
|
||||
|
||||
```pseudo
|
||||
FUNCTION pre_execution_check(task):
|
||||
// Ensure dependencies are met before starting.
|
||||
IF task.dependencies ARE NOT MET:
|
||||
LOG_ERROR("Cannot execute " + task.id)
|
||||
LOG_INFO("Blocked by: " + unmet_dependencies)
|
||||
HALT_EXECUTION()
|
||||
|
||||
FUNCTION on_execution_failure(checkpoint):
|
||||
// Provide user with recovery options upon failure.
|
||||
LOG_WARNING("Execution failed at checkpoint " + checkpoint)
|
||||
PRESENT_OPTIONS([
|
||||
"Retry from checkpoint",
|
||||
"Retry from beginning",
|
||||
"Switch to guided mode",
|
||||
"Abort execution"
|
||||
])
|
||||
AWAIT user_input
|
||||
// System performs the selected action.
|
||||
END FUNCTION
|
||||
```
|
||||
|
||||
|
||||
### Simplified Context Structure (JSON)
|
||||
|
||||
This is the simplified data structure loaded to provide context for task execution.
|
||||
|
||||
```json
|
||||
{
|
||||
"task": {
|
||||
"id": "IMPL-1",
|
||||
"title": "Build authentication module",
|
||||
"type": "feature",
|
||||
"status": "active",
|
||||
"agent": "code-developer",
|
||||
"context": {
|
||||
"requirements": ["JWT authentication", "OAuth2 support"],
|
||||
"scope": ["src/auth/*", "tests/auth/*"],
|
||||
"acceptance": ["Module handles JWT tokens", "OAuth2 flow implemented"],
|
||||
"inherited_from": "WFS-user-auth"
|
||||
},
|
||||
"relations": {
|
||||
"parent": null,
|
||||
"subtasks": ["IMPL-1.1", "IMPL-1.2"],
|
||||
"dependencies": ["IMPL-0"]
|
||||
},
|
||||
"implementation": {
|
||||
"files": [
|
||||
{
|
||||
"path": "src/auth/login.ts",
|
||||
"location": {
|
||||
"function": "authenticateUser",
|
||||
"lines": "25-65",
|
||||
"description": "Main authentication logic"
|
||||
},
|
||||
"original_code": "// Code snippet extracted via gemini analysis",
|
||||
"modifications": {
|
||||
"current_state": "Basic password authentication only",
|
||||
"proposed_changes": [
|
||||
"Add JWT token generation",
|
||||
"Implement OAuth2 callback handling",
|
||||
"Add multi-factor authentication support"
|
||||
],
|
||||
"logic_flow": [
|
||||
"validateCredentials() ───► checkUserExists()",
|
||||
"◊─── if password ───► generateJWT() ───► return token",
|
||||
"◊─── if OAuth ───► validateOAuthCode() ───► exchangeForToken()",
|
||||
"◊─── if MFA ───► sendMFACode() ───► awaitVerification()"
|
||||
],
|
||||
"reason": "Support modern authentication standards and security requirements",
|
||||
"expected_outcome": "Comprehensive authentication system supporting multiple methods"
|
||||
}
|
||||
}
|
||||
],
|
||||
"context_notes": {
|
||||
"dependencies": ["jsonwebtoken", "passport", "speakeasy"],
|
||||
"affected_modules": ["user-session", "auth-middleware", "api-routes"],
|
||||
"risks": [
|
||||
"Breaking changes to existing login endpoints",
|
||||
"Token storage and rotation complexity",
|
||||
"OAuth provider configuration dependencies"
|
||||
],
|
||||
"performance_considerations": "JWT validation adds ~10ms per request, OAuth callbacks may timeout",
|
||||
"error_handling": "Ensure sensitive authentication errors don't leak user enumeration data"
|
||||
},
|
||||
"pre_analysis": [
|
||||
{
|
||||
"action": "analyze patterns",
|
||||
"template": "~/.claude/workflows/cli-templates/prompts/analysis/02-analyze-code-patterns.txt",
|
||||
"method": "gemini"
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"workflow": {
|
||||
"session": "WFS-user-auth",
|
||||
"phase": "IMPLEMENT",
|
||||
"session_context": {
|
||||
"workflow_directory": ".workflow/active/WFS-user-auth/",
|
||||
"todo_list_location": ".workflow/active/WFS-user-auth/TODO_LIST.md",
|
||||
"summaries_directory": ".workflow/active/WFS-user-auth/.summaries/",
|
||||
"task_json_location": ".workflow/active/WFS-user-auth/.task/"
|
||||
}
|
||||
},
|
||||
"execution": {
|
||||
"agent": "code-developer",
|
||||
"mode": "auto",
|
||||
"attempts": 0
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### Agent-Specific Context
|
||||
|
||||
Different agents receive context tailored to their function, including implementation details:
|
||||
|
||||
**`@code-developer`**:
|
||||
- Complete implementation.files array with file paths and locations
|
||||
- original_code snippets and proposed_changes for precise modifications
|
||||
- logic_flow diagrams for understanding data flow
|
||||
- Dependencies and affected modules for integration planning
|
||||
- Performance and error handling considerations
|
||||
|
||||
**`@planning-agent`**:
|
||||
- High-level requirements, constraints, success criteria
|
||||
- Implementation risks and mitigation strategies
|
||||
- Architecture implications from implementation.context_notes
|
||||
|
||||
**`@test-fix-agent`**:
|
||||
- Test files to execute from task.context.focus_paths
|
||||
- Source files to fix from implementation.files[].path
|
||||
- Expected behaviors from implementation.modifications.logic_flow
|
||||
- Error conditions to validate from implementation.context_notes.error_handling
|
||||
- Performance requirements from implementation.context_notes.performance_considerations
|
||||
|
||||
**`@universal-executor`**:
|
||||
- Used for optional manual reviews when explicitly requested
|
||||
- Code quality standards and implementation patterns
|
||||
- Security considerations from implementation.context_notes.risks
|
||||
- Dependency validation from implementation.context_notes.dependencies
|
||||
- Architecture compliance checks
|
||||
|
||||
### Simplified File Output
|
||||
|
||||
- **Task JSON File (`.task/<task-id>.json`)**: Updated with status and last attempt time only.
|
||||
- **Session File (`workflow-session.json`)**: Updated task stats (completed count).
|
||||
- **Summary File**: Generated in `.summaries/` upon completion (optional).
|
||||
|
||||
### Simplified Summary Template
|
||||
|
||||
Optional summary file generated at `.summaries/IMPL-[task-id]-summary.md`.
|
||||
|
||||
```markdown
|
||||
# Task Summary: IMPL-1 Build Authentication Module
|
||||
|
||||
## What Was Done
|
||||
- Created src/auth/login.ts with JWT validation
|
||||
- Added tests in tests/auth.test.ts
|
||||
|
||||
## Execution Results
|
||||
- **Agent**: code-developer
|
||||
- **Status**: completed
|
||||
|
||||
## Files Modified
|
||||
- `src/auth/login.ts` (created)
|
||||
- `tests/auth.test.ts` (created)
|
||||
```
|
||||
@@ -1,437 +0,0 @@
|
||||
---
|
||||
name: replan
|
||||
description: Update task JSON with new requirements or batch-update multiple tasks from verification report, tracks changes in task-changes.json
|
||||
argument-hint: "task-id [\"text\"|file.md] | --batch [verification-report.md]"
|
||||
allowed-tools: Read(*), Write(*), Edit(*), TodoWrite(*), Glob(*), Bash(*)
|
||||
---
|
||||
|
||||
# Task Replan Command (/task:replan)
|
||||
|
||||
> **⚠️ DEPRECATION NOTICE**: This command is maintained for backward compatibility. For new workflows, use `/workflow:replan` which provides:
|
||||
> - Session-level replanning with comprehensive artifact updates
|
||||
> - Interactive boundary clarification
|
||||
> - Updates to IMPL_PLAN.md, TODO_LIST.md, and session metadata
|
||||
> - Better integration with workflow sessions
|
||||
>
|
||||
> **Migration**: Replace `/task:replan IMPL-1 "changes"` with `/workflow:replan IMPL-1 "changes"`
|
||||
|
||||
## Overview
|
||||
Replans individual tasks or batch processes multiple tasks with change tracking and backup management.
|
||||
|
||||
**Modes**:
|
||||
- **Single Task Mode**: Replan one task with specific changes
|
||||
- **Batch Mode**: Process multiple tasks from action-plan verification report
|
||||
|
||||
## Key Features
|
||||
- **Single/Batch Operations**: Single task or multiple tasks from verification report
|
||||
- **Multiple Input Sources**: Text, files, or verification report
|
||||
- **Backup Management**: Automatic backup of previous versions
|
||||
- **Change Documentation**: Track all modifications
|
||||
- **Progress Tracking**: TodoWrite integration for batch operations
|
||||
|
||||
**CRITICAL**: Validates active session before replanning
|
||||
|
||||
## Operation Modes
|
||||
|
||||
### Single Task Mode
|
||||
|
||||
#### Direct Text (Default)
|
||||
```bash
|
||||
/task:replan IMPL-1 "Add OAuth2 authentication support"
|
||||
```
|
||||
|
||||
#### File-based Input
|
||||
```bash
|
||||
/task:replan IMPL-1 updated-specs.md
|
||||
```
|
||||
Supports: .md, .txt, .json, .yaml
|
||||
|
||||
#### Interactive Mode
|
||||
```bash
|
||||
/task:replan IMPL-1 --interactive
|
||||
```
|
||||
Guided step-by-step modification process with validation
|
||||
|
||||
### Batch Mode
|
||||
|
||||
#### From Verification Report
|
||||
```bash
|
||||
/task:replan --batch ACTION_PLAN_VERIFICATION.md
|
||||
```
|
||||
|
||||
**Workflow**:
|
||||
1. Parse verification report to extract replan recommendations
|
||||
2. Create TodoWrite task list for all modifications
|
||||
3. Process each task sequentially with confirmation
|
||||
4. Track progress and generate summary report
|
||||
|
||||
**Auto-detection**: If input file contains "Action Plan Verification Report" header, automatically enters batch mode
|
||||
|
||||
## Replanning Process
|
||||
|
||||
### Single Task Process
|
||||
|
||||
1. **Load & Validate**: Read task JSON and validate session
|
||||
2. **Parse Input**: Process changes from input source
|
||||
3. **Create Backup**: Save previous version to backup folder
|
||||
4. **Update Task**: Modify JSON structure and relationships
|
||||
5. **Save Changes**: Write updated task and increment version
|
||||
6. **Update Session**: Reflect changes in workflow stats
|
||||
|
||||
### Batch Process
|
||||
|
||||
1. **Parse Verification Report**: Extract all replan recommendations
|
||||
2. **Initialize TodoWrite**: Create task list for tracking
|
||||
3. **For Each Task**:
|
||||
- Mark todo as in_progress
|
||||
- Load and validate task JSON
|
||||
- Create backup
|
||||
- Apply recommended changes
|
||||
- Save updated task
|
||||
- Mark todo as completed
|
||||
4. **Generate Summary**: Report all changes and backup locations
|
||||
|
||||
## Backup Management
|
||||
|
||||
### Backup Tracking
|
||||
Tasks maintain backup history:
|
||||
```json
|
||||
{
|
||||
"id": "IMPL-1",
|
||||
"version": "1.2",
|
||||
"replan_history": [
|
||||
{
|
||||
"version": "1.2",
|
||||
"reason": "Add OAuth2 support",
|
||||
"input_source": "direct_text",
|
||||
"backup_location": ".task/backup/IMPL-1-v1.1.json",
|
||||
"timestamp": "2025-10-17T10:30:00Z"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
**Complete schema**: See @~/.claude/workflows/task-core.md
|
||||
|
||||
### File Structure
|
||||
```
|
||||
.task/
|
||||
├── IMPL-1.json # Current version
|
||||
├── backup/
|
||||
│ ├── IMPL-1-v1.0.json # Original version
|
||||
│ ├── IMPL-1-v1.1.json # Previous backup
|
||||
│ └── IMPL-1-v1.2.json # Latest backup
|
||||
└── [new subtasks as needed]
|
||||
```
|
||||
|
||||
**Backup Naming**: `{task-id}-v{version}.json`
|
||||
|
||||
## Implementation Updates
|
||||
|
||||
### Change Detection
|
||||
Tracks modifications to:
|
||||
- Files in implementation.files array
|
||||
- Dependencies and affected modules
|
||||
- Risk assessments and performance notes
|
||||
- Logic flows and code locations
|
||||
|
||||
### Analysis Triggers
|
||||
May require gemini re-analysis when:
|
||||
- New files need code extraction
|
||||
- Function locations change
|
||||
- Dependencies require re-evaluation
|
||||
|
||||
## Document Updates
|
||||
|
||||
### Planning Document
|
||||
May update IMPL_PLAN.md sections when task structure changes significantly
|
||||
|
||||
### TODO List Sync
|
||||
If TODO_LIST.md exists, synchronizes:
|
||||
- New subtasks (with [ ] checkbox)
|
||||
- Modified tasks (marked as updated)
|
||||
- Removed subtasks (deleted from list)
|
||||
|
||||
## Change Documentation
|
||||
|
||||
### Change Summary
|
||||
Generates brief change log with:
|
||||
- Version increment (1.1 → 1.2)
|
||||
- Input source and reason
|
||||
- Key modifications made
|
||||
- Files updated/created
|
||||
- Backup location
|
||||
|
||||
## Session Updates
|
||||
|
||||
Updates workflow-session.json with:
|
||||
- Modified task tracking
|
||||
- Task count changes (if subtasks added/removed)
|
||||
- Last modification timestamps
|
||||
|
||||
## Rollback Support
|
||||
|
||||
```bash
|
||||
/task:replan IMPL-1 --rollback v1.1
|
||||
|
||||
Rollback to version 1.1:
|
||||
- Restore task from backup/.../IMPL-1-v1.1.json
|
||||
- Remove new subtasks if any
|
||||
- Update session stats
|
||||
|
||||
# Use AskUserQuestion for confirmation
|
||||
AskUserQuestion({
|
||||
questions: [{
|
||||
question: "Are you sure you want to roll back this task to a previous version?",
|
||||
header: "Confirm",
|
||||
options: [
|
||||
{ label: "Yes, rollback", description: "Restore the task from the selected backup." },
|
||||
{ label: "No, cancel", description: "Keep the current version of the task." }
|
||||
],
|
||||
multiSelect: false
|
||||
}]
|
||||
})
|
||||
|
||||
User selected: "Yes, rollback"
|
||||
|
||||
Task rolled back to version 1.1
|
||||
```
|
||||
|
||||
## Batch Processing with TodoWrite
|
||||
|
||||
### Progress Tracking
|
||||
When processing multiple tasks, automatically creates TodoWrite task list:
|
||||
|
||||
```markdown
|
||||
**Batch Replan Progress**:
|
||||
- [x] IMPL-002: Add FR-12 draft saving acceptance criteria
|
||||
- [x] IMPL-003: Add FR-14 history tracking acceptance criteria
|
||||
- [ ] IMPL-004: Add FR-09 response surface explicit coverage
|
||||
- [ ] IMPL-008: Add NFR performance validation steps
|
||||
```
|
||||
|
||||
### Batch Report
|
||||
After completion, generates summary:
|
||||
```markdown
|
||||
## Batch Replan Summary
|
||||
|
||||
**Total Tasks**: 4
|
||||
**Successful**: 3
|
||||
**Failed**: 1
|
||||
**Skipped**: 0
|
||||
|
||||
### Changes Made
|
||||
- IMPL-002 v1.0 → v1.1: Added FR-12 acceptance criteria
|
||||
- IMPL-003 v1.0 → v1.1: Added FR-14 acceptance criteria
|
||||
- IMPL-004 v1.0 → v1.1: Added FR-09 explicit coverage
|
||||
|
||||
### Backups Created
|
||||
- .task/backup/IMPL-002-v1.0.json
|
||||
- .task/backup/IMPL-003-v1.0.json
|
||||
- .task/backup/IMPL-004-v1.0.json
|
||||
|
||||
### Errors
|
||||
- IMPL-008: File not found (task may have been renamed)
|
||||
```
|
||||
|
||||
## Examples
|
||||
|
||||
### Single Task - Text Input
|
||||
```bash
|
||||
/task:replan IMPL-1 "Add OAuth2 authentication support"
|
||||
|
||||
Processing changes...
|
||||
Proposed updates:
|
||||
+ Add OAuth2 integration
|
||||
+ Update authentication flow
|
||||
|
||||
# Use AskUserQuestion for confirmation
|
||||
AskUserQuestion({
|
||||
questions: [{
|
||||
question: "Do you want to apply these changes to the task?",
|
||||
header: "Apply",
|
||||
options: [
|
||||
{ label: "Yes, apply", description: "Create new version with these changes." },
|
||||
{ label: "No, cancel", description: "Discard changes and keep current version." }
|
||||
],
|
||||
multiSelect: false
|
||||
}]
|
||||
})
|
||||
|
||||
User selected: "Yes, apply"
|
||||
|
||||
Version 1.2 created
|
||||
Context updated
|
||||
Backup saved to .task/backup/IMPL-1-v1.1.json
|
||||
```
|
||||
|
||||
### Single Task - File Input
|
||||
```bash
|
||||
/task:replan IMPL-2 requirements.md
|
||||
|
||||
Loading requirements.md...
|
||||
Applying specification changes...
|
||||
|
||||
Task updated with new requirements
|
||||
Version 1.1 created
|
||||
Backup saved to .task/backup/IMPL-2-v1.0.json
|
||||
```
|
||||
|
||||
### Batch Mode - From Verification Report
|
||||
```bash
|
||||
/task:replan --batch .workflow/active/WFS-{session}/.process/ACTION_PLAN_VERIFICATION.md
|
||||
|
||||
Parsing verification report...
|
||||
Found 4 tasks requiring replanning:
|
||||
- IMPL-002: Add FR-12 draft saving acceptance criteria
|
||||
- IMPL-003: Add FR-14 history tracking acceptance criteria
|
||||
- IMPL-004: Add FR-09 response surface explicit coverage
|
||||
- IMPL-008: Add NFR performance validation steps
|
||||
|
||||
Creating task tracking list...
|
||||
|
||||
Processing IMPL-002...
|
||||
Backup created: .task/backup/IMPL-002-v1.0.json
|
||||
Updated to v1.1
|
||||
|
||||
Processing IMPL-003...
|
||||
Backup created: .task/backup/IMPL-003-v1.0.json
|
||||
Updated to v1.1
|
||||
|
||||
Processing IMPL-004...
|
||||
Backup created: .task/backup/IMPL-004-v1.0.json
|
||||
Updated to v1.1
|
||||
|
||||
Processing IMPL-008...
|
||||
Backup created: .task/backup/IMPL-008-v1.0.json
|
||||
Updated to v1.1
|
||||
|
||||
Batch replan completed: 4/4 successful
|
||||
Summary report saved
|
||||
```
|
||||
|
||||
### Batch Mode - Auto-detection
|
||||
```bash
|
||||
# If file contains "Action Plan Verification Report", auto-enters batch mode
|
||||
/task:replan ACTION_PLAN_VERIFICATION.md
|
||||
|
||||
Detected verification report format
|
||||
Entering batch mode...
|
||||
[same as above]
|
||||
```
|
||||
|
||||
## Error Handling
|
||||
|
||||
### Single Task Errors
|
||||
```bash
|
||||
# Task not found
|
||||
Task IMPL-5 not found
|
||||
Check task ID with /workflow:status
|
||||
|
||||
# Task completed
|
||||
Task IMPL-1 is completed (cannot replan)
|
||||
Create new task for additional work
|
||||
|
||||
# File not found
|
||||
File requirements.md not found
|
||||
Check file path
|
||||
|
||||
# No input provided
|
||||
Please specify changes needed
|
||||
Provide text, file, or verification report
|
||||
```
|
||||
|
||||
### Batch Mode Errors
|
||||
```bash
|
||||
# Invalid verification report
|
||||
File does not contain valid verification report format
|
||||
Check report structure or use single task mode
|
||||
|
||||
# Partial failures
|
||||
Batch completed with errors: 3/4 successful
|
||||
Review error details in summary report
|
||||
|
||||
# No replan recommendations found
|
||||
Verification report contains no replan recommendations
|
||||
Check report content or use /workflow:action-plan-verify first
|
||||
```
|
||||
|
||||
## Batch Mode Integration
|
||||
|
||||
### Input Format Expectations
|
||||
Batch mode parses verification reports looking for:
|
||||
|
||||
1. **Required Actions Section**: Commands like `/task:replan IMPL-X "changes"`
|
||||
2. **Findings Table**: Task IDs with recommendations
|
||||
3. **Next Actions Section**: Specific replan commands
|
||||
|
||||
**Example Patterns**:
|
||||
```markdown
|
||||
#### 1. HIGH Priority - Address FR Coverage Gaps
|
||||
/task:replan IMPL-004 "
|
||||
Add explicit acceptance criteria:
|
||||
- FR-09: Response surface 3D visualization
|
||||
"
|
||||
|
||||
#### 2. MEDIUM Priority - Enhance NFR Coverage
|
||||
/task:replan IMPL-008 "
|
||||
Add performance testing:
|
||||
- NFR-01: Load test API endpoints
|
||||
"
|
||||
```
|
||||
|
||||
### Extraction Logic
|
||||
1. Scan for `/task:replan` commands in report
|
||||
2. Extract task ID and change description
|
||||
3. Group by priority (HIGH, MEDIUM, LOW)
|
||||
4. Process in priority order with TodoWrite tracking
|
||||
|
||||
### Confirmation Behavior
|
||||
- **Default**: Confirm each task before applying
|
||||
- **With `--auto-confirm`**: Apply all changes without prompting
|
||||
```bash
|
||||
/task:replan --batch report.md --auto-confirm
|
||||
```
|
||||
|
||||
## Implementation Details
|
||||
|
||||
### Backup Management
|
||||
```typescript
|
||||
// Backup file naming convention
|
||||
const backupPath = `.task/backup/${taskId}-v${previousVersion}.json`;
|
||||
|
||||
// Backup metadata in task JSON
|
||||
{
|
||||
"replan_history": [
|
||||
{
|
||||
"version": "1.2",
|
||||
"timestamp": "2025-10-17T10:30:00Z",
|
||||
"reason": "Add FR-09 explicit coverage",
|
||||
"input_source": "batch_verification_report",
|
||||
"backup_location": ".task/backup/IMPL-004-v1.1.json"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
### TodoWrite Integration
|
||||
```typescript
|
||||
// Initialize tracking for batch mode
|
||||
TodoWrite({
|
||||
todos: taskList.map(task => ({
|
||||
content: `${task.id}: ${task.changeDescription}`,
|
||||
status: "pending",
|
||||
activeForm: `Replanning ${task.id}`
|
||||
}))
|
||||
});
|
||||
|
||||
// Update progress during processing
|
||||
TodoWrite({
|
||||
todos: updateTaskStatus(taskId, "in_progress")
|
||||
});
|
||||
|
||||
// Mark completed
|
||||
TodoWrite({
|
||||
todos: updateTaskStatus(taskId, "completed")
|
||||
});
|
||||
```
|
||||
@@ -1,254 +0,0 @@
|
||||
---
|
||||
name: version
|
||||
description: Display Claude Code version information and check for updates
|
||||
allowed-tools: Bash(*)
|
||||
---
|
||||
|
||||
# Version Command (/version)
|
||||
|
||||
## Purpose
|
||||
Display local and global installation versions, check for the latest updates from GitHub, and provide upgrade recommendations.
|
||||
|
||||
## Execution Flow
|
||||
1. **Local Version Check**: Read version information from `./.claude/version.json` if it exists.
|
||||
2. **Global Version Check**: Read version information from `~/.claude/version.json` if it exists.
|
||||
3. **Fetch Remote Versions**: Use GitHub API to get the latest stable release tag and the latest commit hash from the main branch.
|
||||
4. **Compare & Suggest**: Compare installed versions with the latest remote versions and provide upgrade suggestions if applicable.
|
||||
|
||||
## Step 1: Check Local Version
|
||||
|
||||
### Check if local version.json exists
|
||||
```bash
|
||||
bash(test -f ./.claude/version.json && echo "found" || echo "not_found")
|
||||
```
|
||||
|
||||
### Read local version (if exists)
|
||||
```bash
|
||||
bash(cat ./.claude/version.json)
|
||||
```
|
||||
|
||||
### Extract version with jq (preferred)
|
||||
```bash
|
||||
bash(cat ./.claude/version.json | grep -o '"version": *"[^"]*"' | cut -d'"' -f4)
|
||||
```
|
||||
|
||||
### Extract installation date
|
||||
```bash
|
||||
bash(cat ./.claude/version.json | grep -o '"installation_date_utc": *"[^"]*"' | cut -d'"' -f4)
|
||||
```
|
||||
|
||||
**Output Format**:
|
||||
```
|
||||
Local Version: 3.2.1
|
||||
Installed: 2025-10-03T12:00:00Z
|
||||
```
|
||||
|
||||
## Step 2: Check Global Version
|
||||
|
||||
### Check if global version.json exists
|
||||
```bash
|
||||
bash(test -f ~/.claude/version.json && echo "found" || echo "not_found")
|
||||
```
|
||||
|
||||
### Read global version
|
||||
```bash
|
||||
bash(cat ~/.claude/version.json)
|
||||
```
|
||||
|
||||
### Extract version
|
||||
```bash
|
||||
bash(cat ~/.claude/version.json | grep -o '"version": *"[^"]*"' | cut -d'"' -f4)
|
||||
```
|
||||
|
||||
### Extract installation date
|
||||
```bash
|
||||
bash(cat ~/.claude/version.json | grep -o '"installation_date_utc": *"[^"]*"' | cut -d'"' -f4)
|
||||
```
|
||||
|
||||
**Output Format**:
|
||||
```
|
||||
Global Version: 3.2.1
|
||||
Installed: 2025-10-03T12:00:00Z
|
||||
```
|
||||
|
||||
## Step 3: Fetch Latest Stable Release
|
||||
|
||||
### Call GitHub API for latest release (with timeout)
|
||||
```bash
|
||||
bash(curl -fsSL "https://api.github.com/repos/catlog22/Claude-Code-Workflow/releases/latest" 2>/dev/null, timeout: 30000)
|
||||
```
|
||||
|
||||
### Extract tag name (version)
|
||||
```bash
|
||||
bash(curl -fsSL "https://api.github.com/repos/catlog22/Claude-Code-Workflow/releases/latest" 2>/dev/null | grep -o '"tag_name": *"[^"]*"' | head -1 | cut -d'"' -f4, timeout: 30000)
|
||||
```
|
||||
|
||||
### Extract release name
|
||||
```bash
|
||||
bash(curl -fsSL "https://api.github.com/repos/catlog22/Claude-Code-Workflow/releases/latest" 2>/dev/null | grep -o '"name": *"[^"]*"' | head -1 | cut -d'"' -f4, timeout: 30000)
|
||||
```
|
||||
|
||||
### Extract published date
|
||||
```bash
|
||||
bash(curl -fsSL "https://api.github.com/repos/catlog22/Claude-Code-Workflow/releases/latest" 2>/dev/null | grep -o '"published_at": *"[^"]*"' | cut -d'"' -f4, timeout: 30000)
|
||||
```
|
||||
|
||||
**Output Format**:
|
||||
```
|
||||
Latest Stable: v3.2.2
|
||||
Release: v3.2.2: Independent Test-Gen Workflow with Cross-Session Context
|
||||
Published: 2025-10-03T04:10:08Z
|
||||
```
|
||||
|
||||
## Step 4: Fetch Latest Main Branch
|
||||
|
||||
### Call GitHub API for latest commit on main (with timeout)
|
||||
```bash
|
||||
bash(curl -fsSL "https://api.github.com/repos/catlog22/Claude-Code-Workflow/commits/main" 2>/dev/null, timeout: 30000)
|
||||
```
|
||||
|
||||
### Extract commit SHA (short)
|
||||
```bash
|
||||
bash(curl -fsSL "https://api.github.com/repos/catlog22/Claude-Code-Workflow/commits/main" 2>/dev/null | grep -o '"sha": *"[^"]*"' | head -1 | cut -d'"' -f4 | cut -c1-7, timeout: 30000)
|
||||
```
|
||||
|
||||
### Extract commit message (first line only)
|
||||
```bash
|
||||
bash(curl -fsSL "https://api.github.com/repos/catlog22/Claude-Code-Workflow/commits/main" 2>/dev/null | grep '"message":' | cut -d'"' -f4 | cut -d'\' -f1, timeout: 30000)
|
||||
```
|
||||
|
||||
### Extract commit date
|
||||
```bash
|
||||
bash(curl -fsSL "https://api.github.com/repos/catlog22/Claude-Code-Workflow/commits/main" 2>/dev/null | grep -o '"date": *"[^"]*"' | head -1 | cut -d'"' -f4, timeout: 30000)
|
||||
```
|
||||
|
||||
**Output Format**:
|
||||
```
|
||||
Latest Dev: a03415b
|
||||
Message: feat: Add version tracking and upgrade check system
|
||||
Date: 2025-10-03T04:46:44Z
|
||||
```
|
||||
|
||||
## Step 5: Compare Versions and Suggest Upgrade
|
||||
|
||||
### Normalize versions (remove 'v' prefix)
|
||||
```bash
|
||||
bash(echo "v3.2.1" | sed 's/^v//')
|
||||
```
|
||||
|
||||
### Compare two versions
|
||||
```bash
|
||||
bash(printf "%s\n%s" "3.2.1" "3.2.2" | sort -V | tail -n 1)
|
||||
```
|
||||
|
||||
### Check if versions are equal
|
||||
```bash
|
||||
# If equal: Up to date
|
||||
# If remote newer: Upgrade available
|
||||
# If local newer: Development version
|
||||
```
|
||||
|
||||
**Output Scenarios**:
|
||||
|
||||
**Scenario 1: Up to date**
|
||||
```
|
||||
You are on the latest stable version (3.2.1)
|
||||
```
|
||||
|
||||
**Scenario 2: Upgrade available**
|
||||
```
|
||||
A newer stable version is available: v3.2.2
|
||||
Your version: 3.2.1
|
||||
|
||||
To upgrade:
|
||||
PowerShell: iex (iwr -useb https://raw.githubusercontent.com/catlog22/Claude-Code-Workflow/main/install-remote.ps1)
|
||||
Bash: bash <(curl -fsSL https://raw.githubusercontent.com/catlog22/Claude-Code-Workflow/main/install-remote.sh)
|
||||
```
|
||||
|
||||
**Scenario 3: Development version**
|
||||
```
|
||||
You are running a development version (3.4.0-dev)
|
||||
This is newer than the latest stable release (v3.3.0)
|
||||
```
|
||||
|
||||
## Simple Bash Commands
|
||||
|
||||
### Basic Operations
|
||||
```bash
|
||||
# Check local version file
|
||||
bash(test -f ./.claude/version.json && cat ./.claude/version.json)
|
||||
|
||||
# Check global version file
|
||||
bash(test -f ~/.claude/version.json && cat ~/.claude/version.json)
|
||||
|
||||
# Extract version from JSON
|
||||
bash(cat version.json | grep -o '"version": *"[^"]*"' | cut -d'"' -f4)
|
||||
|
||||
# Extract date from JSON
|
||||
bash(cat version.json | grep -o '"installation_date_utc": *"[^"]*"' | cut -d'"' -f4)
|
||||
|
||||
# Fetch latest release (with timeout)
|
||||
bash(curl -fsSL "https://api.github.com/repos/catlog22/Claude-Code-Workflow/releases/latest" 2>/dev/null, timeout: 30000)
|
||||
|
||||
# Extract tag name
|
||||
bash(curl -fsSL "https://api.github.com/repos/catlog22/Claude-Code-Workflow/releases/latest" 2>/dev/null | grep -o '"tag_name": *"[^"]*"' | cut -d'"' -f4, timeout: 30000)
|
||||
|
||||
# Extract release name
|
||||
bash(curl -fsSL "https://api.github.com/repos/catlog22/Claude-Code-Workflow/releases/latest" 2>/dev/null | grep -o '"name": *"[^"]*"' | head -1 | cut -d'"' -f4, timeout: 30000)
|
||||
|
||||
# Fetch latest commit (with timeout)
|
||||
bash(curl -fsSL "https://api.github.com/repos/catlog22/Claude-Code-Workflow/commits/main" 2>/dev/null, timeout: 30000)
|
||||
|
||||
# Extract commit SHA
|
||||
bash(curl -fsSL "https://api.github.com/repos/catlog22/Claude-Code-Workflow/commits/main" 2>/dev/null | grep -o '"sha": *"[^"]*"' | head -1 | cut -d'"' -f4 | cut -c1-7, timeout: 30000)
|
||||
|
||||
# Extract commit message (first line)
|
||||
bash(curl -fsSL "https://api.github.com/repos/catlog22/Claude-Code-Workflow/commits/main" 2>/dev/null | grep '"message":' | cut -d'"' -f4 | cut -d'\' -f1, timeout: 30000)
|
||||
|
||||
# Compare versions
|
||||
bash(printf "%s\n%s" "3.2.1" "3.2.2" | sort -V | tail -n 1)
|
||||
|
||||
# Remove 'v' prefix
|
||||
bash(echo "v3.2.1" | sed 's/^v//')
|
||||
```
|
||||
|
||||
## Error Handling
|
||||
|
||||
### No installation found
|
||||
```
|
||||
WARNING: Claude Code Workflow not installed
|
||||
Install using:
|
||||
PowerShell: iex (iwr -useb https://raw.githubusercontent.com/catlog22/Claude-Code-Workflow/main/install-remote.ps1)
|
||||
```
|
||||
|
||||
### Network error
|
||||
```
|
||||
ERROR: Could not fetch latest version from GitHub
|
||||
Check your network connection
|
||||
```
|
||||
|
||||
### Invalid version.json
|
||||
```
|
||||
ERROR: version.json is invalid or corrupted
|
||||
```
|
||||
|
||||
## Design Notes
|
||||
|
||||
- Uses simple, direct bash commands instead of complex functions
|
||||
- Each step is independent and can be executed separately
|
||||
- Fallback to grep/sed for JSON parsing (no jq dependency required)
|
||||
- Network calls use curl with error suppression and 30-second timeout
|
||||
- Version comparison uses `sort -V` for accurate semantic versioning
|
||||
- Use `/commits/main` API instead of `/branches/main` for more reliable commit info
|
||||
- Extract first line of commit message using `cut -d'\' -f1` to handle JSON escape sequences
|
||||
|
||||
## API Endpoints
|
||||
|
||||
### GitHub API Used
|
||||
- **Latest Release**: `https://api.github.com/repos/catlog22/Claude-Code-Workflow/releases/latest`
|
||||
- Fields: `tag_name`, `name`, `published_at`
|
||||
- **Latest Commit**: `https://api.github.com/repos/catlog22/Claude-Code-Workflow/commits/main`
|
||||
- Fields: `sha`, `commit.message`, `commit.author.date`
|
||||
|
||||
### Timeout Configuration
|
||||
All network calls should use `timeout: 30000` (30 seconds) to handle slow connections.
|
||||
@@ -1,447 +0,0 @@
|
||||
---
|
||||
name: action-plan-verify
|
||||
description: Perform non-destructive cross-artifact consistency analysis between IMPL_PLAN.md and task JSONs with quality gate validation
|
||||
argument-hint: "[optional: --session session-id]"
|
||||
allowed-tools: Read(*), TodoWrite(*), Glob(*), Bash(*)
|
||||
---
|
||||
|
||||
## User Input
|
||||
|
||||
```text
|
||||
$ARGUMENTS
|
||||
```
|
||||
|
||||
You **MUST** consider the user input before proceeding (if not empty).
|
||||
|
||||
## Goal
|
||||
|
||||
Identify inconsistencies, duplications, ambiguities, and underspecified items between action planning artifacts (`IMPL_PLAN.md`, `task.json`) and brainstorming artifacts (`role analysis documents`) before implementation. This command MUST run only after `/workflow:plan` has successfully produced complete `IMPL_PLAN.md` and task JSON files.
|
||||
|
||||
## Operating Constraints
|
||||
|
||||
**STRICTLY READ-ONLY**: Do **not** modify any files. Output a structured analysis report. Offer an optional remediation plan (user must explicitly approve before any follow-up editing commands).
|
||||
|
||||
**Synthesis Authority**: The `role analysis documents` is **authoritative** for requirements and design decisions. Any conflicts between IMPL_PLAN/tasks and synthesis are automatically CRITICAL and require adjustment of the plan/tasks—not reinterpretation of requirements.
|
||||
|
||||
## Execution Steps
|
||||
|
||||
### 1. Initialize Analysis Context
|
||||
|
||||
```bash
|
||||
# Detect active workflow session
|
||||
IF --session parameter provided:
|
||||
session_id = provided session
|
||||
ELSE:
|
||||
# Auto-detect active session
|
||||
active_sessions = bash(find .workflow/active/ -name "WFS-*" -type d 2>/dev/null)
|
||||
IF active_sessions is empty:
|
||||
ERROR: "No active workflow session found. Use --session <session-id>"
|
||||
EXIT
|
||||
ELSE IF active_sessions has multiple entries:
|
||||
# Use most recently modified session
|
||||
session_id = bash(ls -td .workflow/active/WFS-*/ 2>/dev/null | head -1 | xargs basename)
|
||||
ELSE:
|
||||
session_id = basename(active_sessions[0])
|
||||
|
||||
# Derive absolute paths
|
||||
session_dir = .workflow/active/WFS-{session}
|
||||
brainstorm_dir = session_dir/.brainstorming
|
||||
task_dir = session_dir/.task
|
||||
|
||||
# Validate required artifacts
|
||||
# Note: "role analysis documents" refers to [role]/analysis.md files (e.g., product-manager/analysis.md)
|
||||
SYNTHESIS_DIR = brainstorm_dir # Contains role analysis files: */analysis.md
|
||||
IMPL_PLAN = session_dir/IMPL_PLAN.md
|
||||
TASK_FILES = Glob(task_dir/*.json)
|
||||
|
||||
# Abort if missing
|
||||
SYNTHESIS_FILES = Glob(brainstorm_dir/*/analysis.md)
|
||||
IF SYNTHESIS_FILES.count == 0:
|
||||
ERROR: "No role analysis documents found in .brainstorming/*/analysis.md. Run /workflow:brainstorm:synthesis first"
|
||||
EXIT
|
||||
|
||||
IF NOT EXISTS(IMPL_PLAN):
|
||||
ERROR: "IMPL_PLAN.md not found. Run /workflow:plan first"
|
||||
EXIT
|
||||
|
||||
IF TASK_FILES.count == 0:
|
||||
ERROR: "No task JSON files found. Run /workflow:plan first"
|
||||
EXIT
|
||||
```
|
||||
|
||||
### 2. Load Artifacts (Progressive Disclosure)
|
||||
|
||||
Load only minimal necessary context from each artifact:
|
||||
|
||||
**From workflow-session.json** (NEW - PRIMARY REFERENCE):
|
||||
- Original user prompt/intent (project or description field)
|
||||
- User's stated goals and objectives
|
||||
- User's scope definition
|
||||
|
||||
**From role analysis documents**:
|
||||
- Functional Requirements (IDs, descriptions, acceptance criteria)
|
||||
- Non-Functional Requirements (IDs, targets)
|
||||
- Business Requirements (IDs, success metrics)
|
||||
- Key Architecture Decisions
|
||||
- Risk factors and mitigation strategies
|
||||
- Implementation Roadmap (high-level phases)
|
||||
|
||||
**From IMPL_PLAN.md**:
|
||||
- Summary and objectives
|
||||
- Context Analysis
|
||||
- Implementation Strategy
|
||||
- Task Breakdown Summary
|
||||
- Success Criteria
|
||||
- Brainstorming Artifacts References (if present)
|
||||
|
||||
**From task.json files**:
|
||||
- Task IDs
|
||||
- Titles and descriptions
|
||||
- Status
|
||||
- Dependencies (depends_on, blocks)
|
||||
- Context (requirements, focus_paths, acceptance, artifacts)
|
||||
- Flow control (pre_analysis, implementation_approach)
|
||||
- Meta (complexity, priority)
|
||||
|
||||
### 3. Build Semantic Models
|
||||
|
||||
Create internal representations (do not include raw artifacts in output):
|
||||
|
||||
**Requirements inventory**:
|
||||
- Each functional/non-functional/business requirement with stable ID
|
||||
- Requirement text, acceptance criteria, priority
|
||||
|
||||
**Architecture decisions inventory**:
|
||||
- ADRs from synthesis
|
||||
- Technology choices
|
||||
- Data model references
|
||||
|
||||
**Task coverage mapping**:
|
||||
- Map each task to one or more requirements (by ID reference or keyword inference)
|
||||
- Map each requirement to covering tasks
|
||||
|
||||
**Dependency graph**:
|
||||
- Task-to-task dependencies (depends_on, blocks)
|
||||
- Requirement-level dependencies (from synthesis)
|
||||
|
||||
### 4. Detection Passes (Token-Efficient Analysis)
|
||||
|
||||
Focus on high-signal findings. Limit to 50 findings total; aggregate remainder in overflow summary.
|
||||
|
||||
#### A. User Intent Alignment (NEW - CRITICAL)
|
||||
|
||||
- **Goal Alignment**: IMPL_PLAN objectives match user's original intent
|
||||
- **Scope Drift**: Plan covers user's stated scope without unauthorized expansion
|
||||
- **Success Criteria Match**: Plan's success criteria reflect user's expectations
|
||||
- **Intent Conflicts**: Tasks contradicting user's original objectives
|
||||
|
||||
#### B. Requirements Coverage Analysis
|
||||
|
||||
- **Orphaned Requirements**: Requirements in synthesis with zero associated tasks
|
||||
- **Unmapped Tasks**: Tasks with no clear requirement linkage
|
||||
- **NFR Coverage Gaps**: Non-functional requirements (performance, security, scalability) not reflected in tasks
|
||||
|
||||
#### C. Consistency Validation
|
||||
|
||||
- **Requirement Conflicts**: Tasks contradicting synthesis requirements
|
||||
- **Architecture Drift**: IMPL_PLAN architecture not matching synthesis ADRs
|
||||
- **Terminology Drift**: Same concept named differently across IMPL_PLAN and tasks
|
||||
- **Data Model Inconsistency**: Tasks referencing entities/fields not in synthesis data model
|
||||
|
||||
#### D. Dependency Integrity
|
||||
|
||||
- **Circular Dependencies**: Task A depends on B, B depends on C, C depends on A
|
||||
- **Missing Dependencies**: Task requires outputs from another task but no explicit dependency
|
||||
- **Broken Dependencies**: Task depends on non-existent task ID
|
||||
- **Logical Ordering Issues**: Implementation tasks before foundational setup without dependency note
|
||||
|
||||
#### E. Synthesis Alignment
|
||||
|
||||
- **Priority Conflicts**: High-priority synthesis requirements mapped to low-priority tasks
|
||||
- **Success Criteria Mismatch**: IMPL_PLAN success criteria not covering synthesis acceptance criteria
|
||||
- **Risk Mitigation Gaps**: Critical risks in synthesis without corresponding mitigation tasks
|
||||
|
||||
#### F. Task Specification Quality
|
||||
|
||||
- **Ambiguous Focus Paths**: Tasks with vague or missing focus_paths
|
||||
- **Underspecified Acceptance**: Tasks without clear acceptance criteria
|
||||
- **Missing Artifacts References**: Tasks not referencing relevant brainstorming artifacts in context.artifacts
|
||||
- **Weak Flow Control**: Tasks without clear implementation_approach or pre_analysis steps
|
||||
- **Missing Target Files**: Tasks without flow_control.target_files specification
|
||||
|
||||
#### G. Duplication Detection
|
||||
|
||||
- **Overlapping Task Scope**: Multiple tasks with nearly identical descriptions
|
||||
- **Redundant Requirements Coverage**: Same requirement covered by multiple tasks without clear partitioning
|
||||
|
||||
#### H. Feasibility Assessment
|
||||
|
||||
- **Complexity Misalignment**: Task marked "simple" but requires multiple file modifications
|
||||
- **Resource Conflicts**: Parallel tasks requiring same resources/files
|
||||
- **Skill Gap Risks**: Tasks requiring skills not in team capability assessment (from synthesis)
|
||||
|
||||
### 5. Severity Assignment
|
||||
|
||||
Use this heuristic to prioritize findings:
|
||||
|
||||
- **CRITICAL**:
|
||||
- Violates user's original intent (goal misalignment, scope drift)
|
||||
- Violates synthesis authority (requirement conflict)
|
||||
- Core requirement with zero coverage
|
||||
- Circular dependencies
|
||||
- Broken dependencies
|
||||
|
||||
- **HIGH**:
|
||||
- NFR coverage gaps
|
||||
- Priority conflicts
|
||||
- Missing risk mitigation tasks
|
||||
- Ambiguous acceptance criteria
|
||||
|
||||
- **MEDIUM**:
|
||||
- Terminology drift
|
||||
- Missing artifacts references
|
||||
- Weak flow control
|
||||
- Logical ordering issues
|
||||
|
||||
- **LOW**:
|
||||
- Style/wording improvements
|
||||
- Minor redundancy not affecting execution
|
||||
|
||||
### 6. Produce Compact Analysis Report
|
||||
|
||||
**Report Generation**: Generate report content and save to file.
|
||||
|
||||
Output a Markdown report with the following structure:
|
||||
|
||||
```markdown
|
||||
## Action Plan Verification Report
|
||||
|
||||
**Session**: WFS-{session-id}
|
||||
**Generated**: {timestamp}
|
||||
**Artifacts Analyzed**: role analysis documents, IMPL_PLAN.md, {N} task files
|
||||
|
||||
---
|
||||
|
||||
### Executive Summary
|
||||
|
||||
- **Overall Risk Level**: CRITICAL | HIGH | MEDIUM | LOW
|
||||
- **Recommendation**: (See decision matrix below)
|
||||
- BLOCK_EXECUTION: Critical issues exist (must fix before proceeding)
|
||||
- PROCEED_WITH_FIXES: High issues exist, no critical (fix recommended before execution)
|
||||
- PROCEED_WITH_CAUTION: Medium issues only (proceed with awareness)
|
||||
- PROCEED: Low issues only or no issues (safe to execute)
|
||||
- **Critical Issues**: {count}
|
||||
- **High Issues**: {count}
|
||||
- **Medium Issues**: {count}
|
||||
- **Low Issues**: {count}
|
||||
|
||||
---
|
||||
|
||||
### Findings Summary
|
||||
|
||||
| ID | Category | Severity | Location(s) | Summary | Recommendation |
|
||||
|----|----------|----------|-------------|---------|----------------|
|
||||
| C1 | Coverage | CRITICAL | synthesis:FR-03 | Requirement "User auth" has zero task coverage | Add authentication implementation task |
|
||||
| H1 | Consistency | HIGH | IMPL-1.2 vs synthesis:ADR-02 | Task uses REST while synthesis specifies GraphQL | Align task with ADR-02 decision |
|
||||
| M1 | Specification | MEDIUM | IMPL-2.1 | Missing context.artifacts reference | Add @synthesis reference |
|
||||
| L1 | Duplication | LOW | IMPL-3.1, IMPL-3.2 | Similar scope | Consider merging |
|
||||
|
||||
(Add one row per finding; generate stable IDs prefixed by severity initial.)
|
||||
|
||||
---
|
||||
|
||||
### Requirements Coverage Analysis
|
||||
|
||||
| Requirement ID | Requirement Summary | Has Task? | Task IDs | Priority Match | Notes |
|
||||
|----------------|---------------------|-----------|----------|----------------|-------|
|
||||
| FR-01 | User authentication | Yes | IMPL-1.1, IMPL-1.2 | Match | Complete |
|
||||
| FR-02 | Data export | Yes | IMPL-2.3 | Mismatch | High req → Med priority task |
|
||||
| FR-03 | Profile management | No | - | - | **CRITICAL: Zero coverage** |
|
||||
| NFR-01 | Response time <200ms | No | - | - | **HIGH: No performance tasks** |
|
||||
|
||||
**Coverage Metrics**:
|
||||
- Functional Requirements: 85% (17/20 covered)
|
||||
- Non-Functional Requirements: 40% (2/5 covered)
|
||||
- Business Requirements: 100% (5/5 covered)
|
||||
|
||||
---
|
||||
|
||||
### Unmapped Tasks
|
||||
|
||||
| Task ID | Title | Issue | Recommendation |
|
||||
|---------|-------|-------|----------------|
|
||||
| IMPL-4.5 | Refactor utils | No requirement linkage | Link to technical debt or remove |
|
||||
|
||||
---
|
||||
|
||||
### Dependency Graph Issues
|
||||
|
||||
**Circular Dependencies**: None detected
|
||||
|
||||
**Broken Dependencies**:
|
||||
- IMPL-2.3 depends on "IMPL-2.4" (non-existent)
|
||||
|
||||
**Logical Ordering Issues**:
|
||||
- IMPL-5.1 (integration test) has no dependency on IMPL-1.* (implementation tasks)
|
||||
|
||||
---
|
||||
|
||||
### Synthesis Alignment Issues
|
||||
|
||||
| Issue Type | Synthesis Reference | IMPL_PLAN/Task | Impact | Recommendation |
|
||||
|------------|---------------------|----------------|--------|----------------|
|
||||
| Architecture Conflict | synthesis:ADR-01 (JWT auth) | IMPL_PLAN uses session cookies | HIGH | Update IMPL_PLAN to use JWT |
|
||||
| Priority Mismatch | synthesis:FR-02 (High) | IMPL-2.3 (Medium) | MEDIUM | Elevate task priority |
|
||||
| Missing Risk Mitigation | synthesis:Risk-03 (API rate limits) | No mitigation tasks | HIGH | Add rate limiting implementation task |
|
||||
|
||||
---
|
||||
|
||||
### Task Specification Quality Issues
|
||||
|
||||
**Missing Artifacts References**: 12 tasks lack context.artifacts
|
||||
**Weak Flow Control**: 5 tasks lack implementation_approach
|
||||
**Missing Target Files**: 8 tasks lack flow_control.target_files
|
||||
|
||||
**Sample Issues**:
|
||||
- IMPL-1.2: No context.artifacts reference to synthesis
|
||||
- IMPL-3.1: Missing flow_control.target_files specification
|
||||
- IMPL-4.2: Vague focus_paths ["src/"] - needs refinement
|
||||
|
||||
---
|
||||
|
||||
### Feasibility Concerns
|
||||
|
||||
| Concern | Tasks Affected | Issue | Recommendation |
|
||||
|---------|----------------|-------|----------------|
|
||||
| Skill Gap | IMPL-6.1, IMPL-6.2 | Requires Kubernetes expertise not in team | Add training task or external consultant |
|
||||
| Resource Conflict | IMPL-3.1, IMPL-3.2 | Both modify src/auth/service.ts in parallel | Add dependency or serialize |
|
||||
|
||||
---
|
||||
|
||||
### Metrics
|
||||
|
||||
- **Total Requirements**: 30 (20 functional, 5 non-functional, 5 business)
|
||||
- **Total Tasks**: 25
|
||||
- **Overall Coverage**: 77% (23/30 requirements with ≥1 task)
|
||||
- **Critical Issues**: 2
|
||||
- **High Issues**: 5
|
||||
- **Medium Issues**: 8
|
||||
- **Low Issues**: 3
|
||||
|
||||
---
|
||||
|
||||
### Next Actions
|
||||
|
||||
#### Action Recommendations
|
||||
|
||||
**Recommendation Decision Matrix**:
|
||||
|
||||
| Condition | Recommendation | Action |
|
||||
|-----------|----------------|--------|
|
||||
| Critical > 0 | BLOCK_EXECUTION | Must resolve all critical issues before proceeding |
|
||||
| Critical = 0, High > 0 | PROCEED_WITH_FIXES | Fix high-priority issues before execution |
|
||||
| Critical = 0, High = 0, Medium > 0 | PROCEED_WITH_CAUTION | Proceed with awareness of medium issues |
|
||||
| Only Low or None | PROCEED | Safe to execute workflow |
|
||||
|
||||
**If CRITICAL Issues Exist** (BLOCK_EXECUTION):
|
||||
- Resolve all critical issues before proceeding
|
||||
- Use TodoWrite to track required fixes
|
||||
- Fix broken dependencies and circular references first
|
||||
|
||||
**If HIGH Issues Exist** (PROCEED_WITH_FIXES):
|
||||
- Fix high-priority issues before execution
|
||||
- Use TodoWrite to systematically track and complete improvements
|
||||
|
||||
**If Only MEDIUM/LOW Issues** (PROCEED_WITH_CAUTION / PROCEED):
|
||||
- Can proceed with execution
|
||||
- Address issues during or after implementation
|
||||
|
||||
#### TodoWrite-Based Remediation Workflow
|
||||
|
||||
**Report Location**: `.workflow/active/WFS-{session}/.process/ACTION_PLAN_VERIFICATION.md`
|
||||
|
||||
**Recommended Workflow**:
|
||||
1. **Create TodoWrite Task List**: Extract all findings from report
|
||||
2. **Process by Priority**: CRITICAL → HIGH → MEDIUM → LOW
|
||||
3. **Complete Each Fix**: Mark tasks as in_progress/completed as you work
|
||||
4. **Validate Changes**: Verify each modification against requirements
|
||||
|
||||
**TodoWrite Task Structure Example**:
|
||||
```markdown
|
||||
Priority Order:
|
||||
1. Fix coverage gaps (CRITICAL)
|
||||
2. Resolve consistency conflicts (CRITICAL/HIGH)
|
||||
3. Add missing specifications (MEDIUM)
|
||||
4. Improve task quality (LOW)
|
||||
```
|
||||
|
||||
**Notes**:
|
||||
- TodoWrite provides real-time progress tracking
|
||||
- Each finding becomes a trackable todo item
|
||||
- User can monitor progress throughout remediation
|
||||
- Architecture drift in IMPL_PLAN requires manual editing
|
||||
```
|
||||
|
||||
### 7. Save Report and Execute TodoWrite-Based Remediation
|
||||
|
||||
**Step 7.1: Save Analysis Report**:
|
||||
```bash
|
||||
report_path = ".workflow/active/WFS-{session}/.process/ACTION_PLAN_VERIFICATION.md"
|
||||
Write(report_path, full_report_content)
|
||||
```
|
||||
|
||||
**Step 7.2: Display Report Summary to User**:
|
||||
- Show executive summary with counts
|
||||
- Display recommendation (BLOCK/PROCEED_WITH_FIXES/PROCEED_WITH_CAUTION/PROCEED)
|
||||
- List critical and high issues if any
|
||||
|
||||
**Step 7.3: After Report Generation**:
|
||||
|
||||
1. **Extract Findings**: Parse all issues by severity
|
||||
2. **Create TodoWrite Task List**: Convert findings to actionable todos
|
||||
3. **Execute Fixes**: Process each todo systematically
|
||||
4. **Update Task Files**: Apply modifications directly to task JSON files
|
||||
5. **Update IMPL_PLAN**: Apply strategic changes if needed
|
||||
|
||||
At end of report, provide remediation guidance:
|
||||
|
||||
```markdown
|
||||
### 🔧 Remediation Workflow
|
||||
|
||||
**Recommended Approach**:
|
||||
1. **Initialize TodoWrite**: Create comprehensive task list from all findings
|
||||
2. **Process by Severity**: Start with CRITICAL, then HIGH, MEDIUM, LOW
|
||||
3. **Apply Fixes Directly**: Modify task.json files and IMPL_PLAN.md as needed
|
||||
4. **Track Progress**: Mark todos as completed after each fix
|
||||
|
||||
**TodoWrite Execution Pattern**:
|
||||
```bash
|
||||
# Step 1: Create task list from verification report
|
||||
TodoWrite([
|
||||
{ content: "Fix FR-03 coverage gap - add authentication task", status: "pending", activeForm: "Fixing FR-03 coverage gap" },
|
||||
{ content: "Fix IMPL-1.2 consistency - align with ADR-02", status: "pending", activeForm: "Fixing IMPL-1.2 consistency" },
|
||||
{ content: "Add context.artifacts to IMPL-1.2", status: "pending", activeForm: "Adding context.artifacts to IMPL-1.2" },
|
||||
# ... additional todos for each finding
|
||||
])
|
||||
|
||||
# Step 2: Process each todo systematically
|
||||
# Mark as in_progress when starting
|
||||
# Apply fix using Read/Edit tools
|
||||
# Mark as completed when done
|
||||
# Move to next priority item
|
||||
```
|
||||
|
||||
**File Modification Workflow**:
|
||||
```bash
|
||||
# For task JSON modifications:
|
||||
1. Read(.workflow/active/WFS-{session}/.task/IMPL-X.Y.json)
|
||||
2. Edit() to apply fixes
|
||||
3. Mark todo as completed
|
||||
|
||||
# For IMPL_PLAN modifications:
|
||||
1. Read(.workflow/active/WFS-{session}/IMPL_PLAN.md)
|
||||
2. Edit() to apply strategic changes
|
||||
3. Mark todo as completed
|
||||
```
|
||||
|
||||
**Note**: All fixes execute immediately after user confirmation without additional commands.
|
||||
654
.claude/commands/workflow/analyze-with-file.md
Normal file
654
.claude/commands/workflow/analyze-with-file.md
Normal file
@@ -0,0 +1,654 @@
|
||||
---
|
||||
name: analyze-with-file
|
||||
description: Interactive collaborative analysis with documented discussions, CLI-assisted exploration, and evolving understanding
|
||||
argument-hint: "[-y|--yes] [-c|--continue] \"topic or question\""
|
||||
allowed-tools: TodoWrite(*), Task(*), AskUserQuestion(*), Read(*), Grep(*), Glob(*), Bash(*), Edit(*), Write(*)
|
||||
---
|
||||
|
||||
## Auto Mode
|
||||
|
||||
When `--yes` or `-y`: Auto-confirm exploration decisions, use recommended analysis angles.
|
||||
|
||||
# Workflow Analyze Command
|
||||
|
||||
## Quick Start
|
||||
|
||||
```bash
|
||||
# Basic usage
|
||||
/workflow:analyze-with-file "如何优化这个项目的认证架构"
|
||||
|
||||
# With options
|
||||
/workflow:analyze-with-file --continue "认证架构" # Continue existing session
|
||||
/workflow:analyze-with-file -y "性能瓶颈分析" # Auto mode
|
||||
```
|
||||
|
||||
**Context Source**: cli-explore-agent + Gemini/Codex analysis
|
||||
**Output Directory**: `.workflow/.analysis/{session-id}/`
|
||||
**Core Innovation**: Documented discussion timeline with evolving understanding
|
||||
|
||||
## Output Artifacts
|
||||
|
||||
### Phase 1: Topic Understanding
|
||||
|
||||
| Artifact | Description |
|
||||
|----------|-------------|
|
||||
| `discussion.md` | Evolution of understanding & discussions (initialized) |
|
||||
| Session variables | Dimensions, focus areas, analysis depth |
|
||||
|
||||
### Phase 2: CLI Exploration
|
||||
|
||||
| Artifact | Description |
|
||||
|----------|-------------|
|
||||
| `exploration-codebase.json` | Single codebase context from cli-explore-agent |
|
||||
| `explorations/*.json` | Multi-perspective codebase explorations (parallel, up to 4) |
|
||||
| `explorations.json` | Single perspective aggregated findings |
|
||||
| `perspectives.json` | Multi-perspective findings (up to 4 perspectives) with synthesis |
|
||||
| Updated `discussion.md` | Round 1 with exploration results |
|
||||
|
||||
### Phase 3: Interactive Discussion
|
||||
|
||||
| Artifact | Description |
|
||||
|----------|-------------|
|
||||
| Updated `discussion.md` | Round 2-N with user feedback and insights |
|
||||
| Corrected assumptions | Tracked in discussion timeline |
|
||||
|
||||
### Phase 4: Synthesis & Conclusion
|
||||
|
||||
| Artifact | Description |
|
||||
|----------|-------------|
|
||||
| `conclusions.json` | Final synthesis with recommendations |
|
||||
| Final `discussion.md` | ⭐ Complete analysis with conclusions |
|
||||
|
||||
## Overview
|
||||
|
||||
Interactive collaborative analysis workflow with **documented discussion process**. Records understanding evolution, facilitates multi-round Q&A, and uses CLI tools for deep exploration.
|
||||
|
||||
**Core workflow**: Topic → Explore → Discuss → Document → Refine → Conclude
|
||||
|
||||
```
|
||||
┌─────────────────────────────────────────────────────────────────────────┐
|
||||
│ INTERACTIVE ANALYSIS WORKFLOW │
|
||||
├─────────────────────────────────────────────────────────────────────────┤
|
||||
│ │
|
||||
│ Phase 1: Topic Understanding │
|
||||
│ ├─ Parse topic/question │
|
||||
│ ├─ Identify analysis dimensions (architecture, performance, etc.) │
|
||||
│ ├─ Initial scoping with user │
|
||||
│ └─ Initialize discussion.md │
|
||||
│ │
|
||||
│ Phase 2: CLI Exploration │
|
||||
│ ├─ Codebase Exploration (cli-explore-agent, supports parallel ≤4) │
|
||||
│ ├─ Multi-Perspective Analysis (AFTER exploration) │
|
||||
│ │ ├─ Single: Comprehensive analysis │
|
||||
│ │ └─ Multi (≤4): Parallel perspectives with synthesis │
|
||||
│ ├─ Aggregate findings │
|
||||
│ └─ Update discussion.md with Round 1 │
|
||||
│ │
|
||||
│ Phase 3: Interactive Discussion (Multi-Round) │
|
||||
│ ├─ Present exploration findings │
|
||||
│ ├─ Facilitate Q&A with user │
|
||||
│ ├─ Capture user insights and corrections │
|
||||
│ ├─ Actions: Deepen | Adjust direction | Answer questions │
|
||||
│ ├─ Update discussion.md with each round │
|
||||
│ └─ Repeat until clarity achieved (max 5 rounds) │
|
||||
│ │
|
||||
│ Phase 4: Synthesis & Conclusion │
|
||||
│ ├─ Consolidate all insights │
|
||||
│ ├─ Generate conclusions with recommendations │
|
||||
│ ├─ Update discussion.md with final synthesis │
|
||||
│ └─ Offer follow-up options (issue/task/report) │
|
||||
│ │
|
||||
└─────────────────────────────────────────────────────────────────────────┘
|
||||
```
|
||||
|
||||
## Output Structure
|
||||
|
||||
```
|
||||
.workflow/.analysis/ANL-{slug}-{date}/
|
||||
├── discussion.md # ⭐ Evolution of understanding & discussions
|
||||
├── exploration-codebase.json # Phase 2: Single codebase context
|
||||
├── explorations/ # Phase 2: Multi-perspective codebase explorations (if selected)
|
||||
│ ├── technical.json
|
||||
│ └── architectural.json
|
||||
├── explorations.json # Phase 2: Single perspective findings
|
||||
├── perspectives.json # Phase 2: Multi-perspective findings (if selected)
|
||||
└── conclusions.json # Phase 4: Final synthesis
|
||||
```
|
||||
|
||||
## Implementation
|
||||
|
||||
### Session Initialization
|
||||
|
||||
**Objective**: Create session context and directory structure for analysis.
|
||||
|
||||
**Required Actions**:
|
||||
1. Extract topic/question from `$ARGUMENTS`
|
||||
2. Generate session ID: `ANL-{slug}-{date}`
|
||||
- slug: lowercase, alphanumeric + Chinese, max 40 chars
|
||||
- date: YYYY-MM-DD (UTC+8)
|
||||
3. Define session folder: `.workflow/.analysis/{session-id}`
|
||||
4. Parse command options:
|
||||
- `-c` or `--continue` for session continuation
|
||||
- `-y` or `--yes` for auto-approval mode
|
||||
5. Auto-detect mode: If session folder + discussion.md exist → continue mode
|
||||
6. Create directory structure: `{session-folder}/`
|
||||
|
||||
**Session Variables**:
|
||||
- `sessionId`: Unique session identifier
|
||||
- `sessionFolder`: Base directory for all artifacts
|
||||
- `autoMode`: Boolean for auto-confirmation
|
||||
- `mode`: new | continue
|
||||
|
||||
### Phase 1: Topic Understanding
|
||||
|
||||
**Objective**: Analyze topic, identify dimensions, gather user input, initialize discussion.md.
|
||||
|
||||
**Prerequisites**:
|
||||
- Session initialized with valid sessionId and sessionFolder
|
||||
- Topic/question available from $ARGUMENTS
|
||||
|
||||
**Workflow Steps**:
|
||||
|
||||
1. **Parse Topic & Identify Dimensions**
|
||||
- Match topic keywords against ANALYSIS_DIMENSIONS
|
||||
- Identify relevant dimensions: architecture, implementation, performance, security, concept, comparison, decision
|
||||
- Default to "general" if no match
|
||||
|
||||
2. **Initial Scoping** (if new session + not auto mode)
|
||||
- **Focus**: Multi-select from directions generated by detected dimensions (see Dimension-Direction Mapping)
|
||||
- **Perspectives**: Multi-select up to 4 analysis perspectives (see Analysis Perspectives), default: single comprehensive view
|
||||
- **Depth**: Single-select from Quick Overview (10-15min) / Standard Analysis (30-60min) / Deep Dive (1-2hr)
|
||||
|
||||
3. **Initialize discussion.md**
|
||||
- Create discussion.md with session metadata
|
||||
- Add user context: focus areas, analysis depth
|
||||
- Add initial understanding: dimensions, scope, key questions
|
||||
- Create empty sections for discussion timeline
|
||||
|
||||
**Success Criteria**:
|
||||
- Session folder created with discussion.md initialized
|
||||
- Analysis dimensions identified
|
||||
- User preferences captured (focus, depth)
|
||||
|
||||
### Phase 2: CLI Exploration
|
||||
|
||||
**Objective**: Gather codebase context, then execute deep analysis via CLI tools.
|
||||
|
||||
**Prerequisites**:
|
||||
- Phase 1 completed successfully
|
||||
- discussion.md initialized
|
||||
- Dimensions identified
|
||||
|
||||
**Workflow Steps** (⚠️ Codebase exploration FIRST):
|
||||
|
||||
1. **Codebase Exploration via cli-explore-agent** (supports parallel up to 4)
|
||||
- Agent type: `cli-explore-agent`
|
||||
- Execution mode: parallel if multi-perspective selected, otherwise single (run_in_background: false for sequential, true for parallel)
|
||||
- **Single exploration**: General codebase analysis
|
||||
- **Multi-perspective**: Parallel explorations per perspective focus (max 4, each with specific angle)
|
||||
- **Common tasks**: Run `ccw tool exec get_modules_by_depth '{}'`, execute searches based on topic keywords, read `.workflow/project-tech.json`
|
||||
- **Output**: `{sessionFolder}/exploration-codebase.json` (single) or `{sessionFolder}/explorations/{perspective}.json` (multi)
|
||||
- **Purpose**: Enrich CLI prompts with codebase context for each perspective
|
||||
|
||||
**Single Exploration Example**:
|
||||
```javascript
|
||||
Task({
|
||||
subagent_type: "cli-explore-agent",
|
||||
run_in_background: false,
|
||||
description: `Explore codebase: ${topicSlug}`,
|
||||
prompt: `
|
||||
## Analysis Context
|
||||
Topic: ${topic_or_question}
|
||||
Dimensions: ${dimensions.join(', ')}
|
||||
Session: ${sessionFolder}
|
||||
|
||||
## MANDATORY FIRST STEPS
|
||||
1. Run: ccw tool exec get_modules_by_depth '{}'
|
||||
2. Execute relevant searches based on topic keywords
|
||||
3. Read: .workflow/project-tech.json (if exists)
|
||||
|
||||
## Exploration Focus
|
||||
${dimensions.map(d => `- ${d}: Identify relevant code patterns and structures`).join('\n')}
|
||||
|
||||
## Output
|
||||
Write findings to: ${sessionFolder}/exploration-codebase.json
|
||||
|
||||
Schema: {relevant_files, patterns, key_findings, questions_for_user, _metadata}
|
||||
`
|
||||
})
|
||||
```
|
||||
|
||||
**Multi-Perspective Parallel Example** (up to 4 agents):
|
||||
```javascript
|
||||
// Launch parallel explorations for each selected perspective
|
||||
selectedPerspectives.forEach(perspective => {
|
||||
Task({
|
||||
subagent_type: "cli-explore-agent",
|
||||
run_in_background: false, // Sequential execution, wait for each
|
||||
description: `Explore ${perspective.name}: ${topicSlug}`,
|
||||
prompt: `
|
||||
## Analysis Context
|
||||
Topic: ${topic_or_question}
|
||||
Perspective: ${perspective.name} - ${perspective.focus}
|
||||
Session: ${sessionFolder}
|
||||
|
||||
## MANDATORY FIRST STEPS
|
||||
1. Run: ccw tool exec get_modules_by_depth '{}'
|
||||
2. Execute searches focused on ${perspective.focus}
|
||||
3. Read: .workflow/project-tech.json (if exists)
|
||||
|
||||
## Exploration Focus (${perspective.name} angle)
|
||||
${perspective.exploration_tasks.map(t => `- ${t}`).join('\n')}
|
||||
|
||||
## Output
|
||||
Write findings to: ${sessionFolder}/explorations/${perspective.name}.json
|
||||
|
||||
Schema: {relevant_files, patterns, key_findings, perspective_insights, _metadata}
|
||||
`
|
||||
})
|
||||
})
|
||||
```
|
||||
|
||||
2. **Multi-Perspective CLI Analysis** (⚠️ AFTER exploration)
|
||||
- If user selected multiple perspectives (≤4): Launch CLI calls in parallel
|
||||
- If single/default perspective: Launch single comprehensive CLI analysis
|
||||
- **Shared context**: Include exploration-codebase.json findings in all prompts
|
||||
- **Execution**: Bash with run_in_background: true, wait for all results
|
||||
- **Output**: perspectives.json with analysis from each perspective
|
||||
|
||||
**Single Perspective Example**:
|
||||
```javascript
|
||||
Bash({
|
||||
command: `ccw cli -p "
|
||||
PURPOSE: Analyze topic '${topic_or_question}' from ${dimensions.join(', ')} perspectives
|
||||
Success: Actionable insights with clear reasoning
|
||||
|
||||
PRIOR EXPLORATION CONTEXT:
|
||||
- Key files: ${explorationResults.relevant_files.slice(0,5).map(f => f.path).join(', ')}
|
||||
- Patterns found: ${explorationResults.patterns.slice(0,3).join(', ')}
|
||||
- Key findings: ${explorationResults.key_findings.slice(0,3).join(', ')}
|
||||
|
||||
TASK:
|
||||
• Build on exploration findings above
|
||||
• Analyze common patterns and anti-patterns
|
||||
• Highlight potential issues or opportunities
|
||||
• Generate discussion points for user clarification
|
||||
|
||||
MODE: analysis
|
||||
CONTEXT: @**/* | Topic: ${topic_or_question}
|
||||
EXPECTED: Structured analysis with clear sections, specific insights tied to evidence, questions to deepen understanding, recommendations with rationale
|
||||
CONSTRAINTS: Focus on ${dimensions.join(', ')}
|
||||
" --tool gemini --mode analysis`,
|
||||
run_in_background: true
|
||||
})
|
||||
```
|
||||
|
||||
**Multi-Perspective Example** (parallel, up to 4):
|
||||
```javascript
|
||||
// Build shared context once
|
||||
const explorationContext = `
|
||||
PRIOR EXPLORATION CONTEXT:
|
||||
- Key files: ${explorationResults.relevant_files.slice(0,5).map(f => f.path).join(', ')}
|
||||
- Patterns found: ${explorationResults.patterns.slice(0,3).join(', ')}
|
||||
- Key findings: ${explorationResults.key_findings.slice(0,3).join(', ')}`
|
||||
|
||||
// Launch parallel CLI calls based on selected perspectives (max 4)
|
||||
selectedPerspectives.forEach(perspective => {
|
||||
Bash({
|
||||
command: `ccw cli -p "
|
||||
PURPOSE: ${perspective.purpose} for '${topic_or_question}'
|
||||
Success: ${perspective.success_criteria}
|
||||
|
||||
${explorationContext}
|
||||
|
||||
TASK:
|
||||
${perspective.tasks.map(t => `• ${t}`).join('\n')}
|
||||
|
||||
MODE: analysis
|
||||
CONTEXT: @**/* | Topic: ${topic_or_question}
|
||||
EXPECTED: ${perspective.expected_output}
|
||||
CONSTRAINTS: ${perspective.constraints}
|
||||
" --tool ${perspective.tool} --mode analysis`,
|
||||
run_in_background: true
|
||||
})
|
||||
})
|
||||
|
||||
// ⚠️ STOP POINT: Wait for hook callback to receive all results before continuing
|
||||
```
|
||||
|
||||
3. **Aggregate Findings**
|
||||
- Consolidate all codebase explorations (exploration-codebase.json or explorations/*.json) and CLI perspective findings
|
||||
- If multi-perspective: Extract synthesis from both explorations and analyses (convergent themes, conflicting views, unique contributions)
|
||||
- Extract aggregated findings, discussion points, open questions across all sources
|
||||
- Write to explorations.json (single) or perspectives.json (multi)
|
||||
|
||||
4. **Update discussion.md**
|
||||
- Append Round 1 section with exploration results
|
||||
- Single perspective: Include sources analyzed, key findings, discussion points, open questions
|
||||
- Multi-perspective: Include per-perspective findings + synthesis section
|
||||
|
||||
**explorations.json Schema** (single perspective):
|
||||
- `session_id`: Session identifier
|
||||
- `timestamp`: Exploration completion time
|
||||
- `topic`: Original topic/question
|
||||
- `dimensions[]`: Analysis dimensions
|
||||
- `sources[]`: {type, file/summary}
|
||||
- `key_findings[]`: Main insights
|
||||
- `discussion_points[]`: Questions for user
|
||||
- `open_questions[]`: Unresolved questions
|
||||
|
||||
**perspectives.json Schema** (multi-perspective):
|
||||
- `session_id`: Session identifier
|
||||
- `timestamp`: Exploration completion time
|
||||
- `topic`: Original topic/question
|
||||
- `dimensions[]`: Analysis dimensions
|
||||
- `perspectives[]`: [{name, tool, findings, insights, questions}]
|
||||
- `synthesis`: {convergent_themes, conflicting_views, unique_contributions}
|
||||
- `aggregated_findings[]`: Main insights across perspectives
|
||||
- `discussion_points[]`: Questions for user
|
||||
- `open_questions[]`: Unresolved questions
|
||||
|
||||
**Success Criteria**:
|
||||
- exploration-codebase.json (single) or explorations/*.json (multi) created with codebase context
|
||||
- explorations.json (single) or perspectives.json (multi) created with findings
|
||||
- discussion.md updated with Round 1 results
|
||||
- All agents and CLI calls completed successfully
|
||||
|
||||
### Phase 3: Interactive Discussion
|
||||
|
||||
**Objective**: Iteratively refine understanding through user-guided discussion cycles.
|
||||
|
||||
**Prerequisites**:
|
||||
- Phase 2 completed successfully
|
||||
- explorations.json contains initial findings
|
||||
- discussion.md has Round 1 results
|
||||
|
||||
**Guideline**: For complex tasks (code analysis, implementation, refactoring), delegate to agents via Task tool (cli-explore-agent, code-developer, universal-executor) or CLI calls (ccw cli). Avoid direct analysis/execution in main process.
|
||||
|
||||
**Workflow Steps**:
|
||||
|
||||
1. **Present Findings**
|
||||
- Display current findings from explorations.json
|
||||
- Show key points for user input
|
||||
|
||||
2. **Gather User Feedback** (AskUserQuestion)
|
||||
- **Question**: Feedback on current analysis
|
||||
- **Options** (single-select):
|
||||
- **同意,继续深入**: Analysis direction correct, deepen exploration
|
||||
- **需要调整方向**: Different understanding or focus
|
||||
- **分析完成**: Sufficient information obtained
|
||||
- **有具体问题**: Specific questions to ask
|
||||
|
||||
3. **Process User Response**
|
||||
|
||||
**Agree, Deepen**:
|
||||
- Continue analysis in current direction
|
||||
- Use CLI for deeper exploration
|
||||
|
||||
**Adjust Direction**:
|
||||
- AskUserQuestion for adjusted focus (code details / architecture / best practices)
|
||||
- Launch new CLI exploration with adjusted scope
|
||||
|
||||
**Specific Questions**:
|
||||
- Capture user questions
|
||||
- Use CLI or direct analysis to answer
|
||||
- Document Q&A in discussion.md
|
||||
|
||||
**Complete**:
|
||||
- Exit discussion loop, proceed to Phase 4
|
||||
|
||||
4. **Update discussion.md**
|
||||
- Append Round N section with:
|
||||
- User input summary
|
||||
- Direction adjustment (if any)
|
||||
- User questions & answers (if any)
|
||||
- Updated understanding
|
||||
- Corrected assumptions
|
||||
- New insights
|
||||
|
||||
5. **Repeat or Converge**
|
||||
- Continue loop (max 5 rounds) or exit to Phase 4
|
||||
|
||||
**Discussion Actions**:
|
||||
|
||||
| User Choice | Action | Tool | Description |
|
||||
|-------------|--------|------|-------------|
|
||||
| Deepen | Continue current direction | Gemini CLI | Deeper analysis in same focus |
|
||||
| Adjust | Change analysis angle | Selected CLI | New exploration with adjusted scope |
|
||||
| Questions | Answer specific questions | CLI or analysis | Address user inquiries |
|
||||
| Complete | Exit discussion loop | - | Proceed to synthesis |
|
||||
|
||||
**Success Criteria**:
|
||||
- User feedback processed for each round
|
||||
- discussion.md updated with all discussion rounds
|
||||
- Assumptions corrected and documented
|
||||
- Exit condition reached (user selects "完成" or max rounds)
|
||||
|
||||
### Phase 4: Synthesis & Conclusion
|
||||
|
||||
**Objective**: Consolidate insights, generate conclusions, offer next steps.
|
||||
|
||||
**Prerequisites**:
|
||||
- Phase 3 completed successfully
|
||||
- Multiple rounds of discussion documented
|
||||
- User ready to conclude
|
||||
|
||||
**Workflow Steps**:
|
||||
|
||||
1. **Consolidate Insights**
|
||||
- Extract all findings from discussion timeline
|
||||
- **Key conclusions**: Main points with evidence and confidence levels (high/medium/low)
|
||||
- **Recommendations**: Action items with rationale and priority (high/medium/low)
|
||||
- **Open questions**: Remaining unresolved questions
|
||||
- **Follow-up suggestions**: Issue/task creation suggestions
|
||||
- Write to conclusions.json
|
||||
|
||||
2. **Final discussion.md Update**
|
||||
- Append conclusions section:
|
||||
- **Summary**: High-level overview
|
||||
- **Key Conclusions**: Ranked with evidence and confidence
|
||||
- **Recommendations**: Prioritized action items
|
||||
- **Remaining Questions**: Unresolved items
|
||||
- Update "Current Understanding (Final)":
|
||||
- **What We Established**: Confirmed points
|
||||
- **What Was Clarified/Corrected**: Important corrections
|
||||
- **Key Insights**: Valuable learnings
|
||||
- Add session statistics: rounds, duration, sources, artifacts
|
||||
|
||||
3. **Post-Completion Options** (AskUserQuestion)
|
||||
- **创建Issue**: Launch issue:new with conclusions
|
||||
- **生成任务**: Launch workflow:lite-plan for implementation
|
||||
- **导出报告**: Generate standalone analysis report
|
||||
- **完成**: No further action
|
||||
|
||||
**conclusions.json Schema**:
|
||||
- `session_id`: Session identifier
|
||||
- `topic`: Original topic/question
|
||||
- `completed`: Completion timestamp
|
||||
- `total_rounds`: Number of discussion rounds
|
||||
- `summary`: Executive summary
|
||||
- `key_conclusions[]`: {point, evidence, confidence}
|
||||
- `recommendations[]`: {action, rationale, priority}
|
||||
- `open_questions[]`: Unresolved questions
|
||||
- `follow_up_suggestions[]`: {type, summary}
|
||||
|
||||
**Success Criteria**:
|
||||
- conclusions.json created with final synthesis
|
||||
- discussion.md finalized with conclusions
|
||||
- User offered next step options
|
||||
- Session complete
|
||||
|
||||
## Configuration
|
||||
|
||||
### Analysis Perspectives
|
||||
|
||||
Optional multi-perspective parallel exploration (single perspective is default, max 4):
|
||||
|
||||
| Perspective | Tool | Focus | Best For |
|
||||
|------------|------|-------|----------|
|
||||
| **Technical** | Gemini | Implementation, code patterns, technical feasibility | Understanding how and technical details |
|
||||
| **Architectural** | Claude | System design, scalability, component interactions | Understanding structure and organization |
|
||||
| **Business** | Codex | Value, ROI, stakeholder impact, strategy | Understanding business implications |
|
||||
| **Domain Expert** | Gemini | Domain-specific patterns, best practices, standards | Industry-specific knowledge and practices |
|
||||
|
||||
**Selection**: User can multi-select up to 4 perspectives in Phase 1, or default to single comprehensive view
|
||||
|
||||
### Dimension-Direction Mapping
|
||||
|
||||
When user selects focus areas, generate directions dynamically from detected dimensions (don't use static options):
|
||||
|
||||
| Dimension | Possible Directions |
|
||||
|-----------|-------------------|
|
||||
| architecture | System Design, Component Interactions, Technology Choices, Integration Points, Design Patterns, Scalability Strategy |
|
||||
| implementation | Code Structure, Implementation Details, Code Patterns, Error Handling, Testing Approach, Algorithm Analysis |
|
||||
| performance | Performance Bottlenecks, Optimization Opportunities, Resource Utilization, Caching Strategy, Concurrency Issues |
|
||||
| security | Security Vulnerabilities, Authentication/Authorization, Access Control, Data Protection, Input Validation |
|
||||
| concept | Conceptual Foundation, Core Mechanisms, Fundamental Patterns, Theory & Principles, Trade-offs & Reasoning |
|
||||
| comparison | Solution Comparison, Pros & Cons Analysis, Technology Evaluation, Approach Differences |
|
||||
| decision | Decision Criteria, Trade-off Analysis, Risk Assessment, Impact Analysis, Implementation Implications |
|
||||
|
||||
**Implementation**: Present 2-3 top dimension-related directions, allow user to multi-select and add custom directions.
|
||||
|
||||
### Analysis Dimensions
|
||||
|
||||
Dimensions matched against topic keywords to identify focus areas:
|
||||
|
||||
| Dimension | Keywords |
|
||||
|-----------|----------|
|
||||
| architecture | 架构, architecture, design, structure, 设计 |
|
||||
| implementation | 实现, implement, code, coding, 代码 |
|
||||
| performance | 性能, performance, optimize, bottleneck, 优化 |
|
||||
| security | 安全, security, auth, permission, 权限 |
|
||||
| concept | 概念, concept, theory, principle, 原理 |
|
||||
| comparison | 比较, compare, vs, difference, 区别 |
|
||||
| decision | 决策, decision, choice, tradeoff, 选择 |
|
||||
|
||||
### Consolidation Rules
|
||||
|
||||
When updating "Current Understanding":
|
||||
|
||||
| Rule | Description |
|
||||
|------|-------------|
|
||||
| Promote confirmed insights | Move validated findings to "What We Established" |
|
||||
| Track corrections | Keep important wrong→right transformations |
|
||||
| Focus on current state | What do we know NOW |
|
||||
| Avoid timeline repetition | Don't copy discussion details |
|
||||
| Preserve key learnings | Keep insights valuable for future reference |
|
||||
|
||||
**Example**:
|
||||
|
||||
❌ **Bad (cluttered)**:
|
||||
```markdown
|
||||
## Current Understanding
|
||||
In round 1 we discussed X, then in round 2 user said Y...
|
||||
```
|
||||
|
||||
✅ **Good (consolidated)**:
|
||||
```markdown
|
||||
## Current Understanding
|
||||
|
||||
### What We Established
|
||||
- The authentication flow uses JWT with refresh tokens
|
||||
- Rate limiting is implemented at API gateway level
|
||||
|
||||
### What Was Clarified
|
||||
- ~~Assumed Redis for sessions~~ → Actually uses database-backed sessions
|
||||
|
||||
### Key Insights
|
||||
- Current architecture supports horizontal scaling
|
||||
```
|
||||
|
||||
## Error Handling
|
||||
|
||||
| Error | Resolution |
|
||||
|-------|------------|
|
||||
| cli-explore-agent fails | Continue with available context, note limitation |
|
||||
| CLI timeout | Retry with shorter prompt, or skip perspective |
|
||||
| User timeout in discussion | Save state, show resume command |
|
||||
| Max rounds reached | Force synthesis, offer continuation option |
|
||||
| No relevant findings | Broaden search, ask user for clarification |
|
||||
| Session folder conflict | Append timestamp suffix |
|
||||
| Gemini unavailable | Fallback to Codex or manual analysis |
|
||||
|
||||
## Best Practices
|
||||
|
||||
1. **Clear Topic Definition**: Detailed topics → better dimension identification
|
||||
2. **Agent-First for Complex Tasks**: For code analysis, implementation, or refactoring tasks during discussion, delegate to agents via Task tool (cli-explore-agent, code-developer, universal-executor) or CLI calls (ccw cli). Avoid direct analysis/execution in main process
|
||||
3. **Review discussion.md**: Check understanding evolution before conclusions
|
||||
4. **Embrace Corrections**: Track wrong→right transformations as learnings
|
||||
5. **Document Evolution**: discussion.md captures full thinking process
|
||||
6. **Use Continue Mode**: Resume sessions to build on previous analysis
|
||||
|
||||
## Templates
|
||||
|
||||
### Discussion Document Structure
|
||||
|
||||
**discussion.md** contains:
|
||||
- **Header**: Session metadata (ID, topic, started, dimensions)
|
||||
- **User Context**: Focus areas, analysis depth
|
||||
- **Discussion Timeline**: Round-by-round findings
|
||||
- Round 1: Initial Understanding + Exploration Results
|
||||
- Round 2-N: User feedback, adjusted understanding, corrections, new insights
|
||||
- **Conclusions**: Summary, key conclusions, recommendations
|
||||
- **Current Understanding (Final)**: Consolidated insights
|
||||
- **Session Statistics**: Rounds, duration, sources, artifacts
|
||||
|
||||
Example sections:
|
||||
|
||||
```markdown
|
||||
### Round 2 - Discussion (timestamp)
|
||||
|
||||
#### User Input
|
||||
User agrees with current direction, wants deeper code analysis
|
||||
|
||||
#### Updated Understanding
|
||||
- Identified session management uses database-backed approach
|
||||
- Rate limiting applied at gateway, not application level
|
||||
|
||||
#### Corrected Assumptions
|
||||
- ~~Assumed Redis for sessions~~ → Database-backed sessions
|
||||
- Reason: User clarified architecture decision
|
||||
|
||||
#### New Insights
|
||||
- Current design allows horizontal scaling without session affinity
|
||||
```
|
||||
|
||||
## Usage Recommendations(Requires User Confirmation)
|
||||
|
||||
**When to Execute Directly :**
|
||||
- Short, focused analysis tasks (single module/component)
|
||||
- Clear, well-defined topics with limited scope
|
||||
- Quick information gathering without multi-round iteration
|
||||
- Follow-up analysis building on existing session
|
||||
|
||||
**Use `Skill(skill="workflow:analyze-with-file", args="\"topic\"")` when:**
|
||||
- Exploring a complex topic collaboratively
|
||||
- Need documented discussion trail
|
||||
- Decision-making requires multiple perspectives
|
||||
- Want to iterate on understanding with user input
|
||||
- Building shared understanding before implementation
|
||||
|
||||
**Use `Skill(skill="workflow:debug-with-file", args="\"bug description\"")` when:**
|
||||
- Diagnosing specific bugs
|
||||
- Need hypothesis-driven investigation
|
||||
- Focus on evidence and verification
|
||||
|
||||
**Use `Skill(skill="workflow:brainstorm-with-file", args="\"topic or question\"")` when:**
|
||||
- Generating new ideas or solutions
|
||||
- Need creative exploration
|
||||
- Want divergent thinking before convergence
|
||||
|
||||
**Use `Skill(skill="workflow:collaborative-plan-with-file", args="\"task description\"")` when:**
|
||||
- Complex planning requiring multiple perspectives
|
||||
- Large scope needing parallel sub-domain analysis
|
||||
- Want shared collaborative planning document
|
||||
- Need structured task breakdown with agent coordination
|
||||
|
||||
**Use `Skill(skill="workflow:lite-plan", args="\"task description\"")` when:**
|
||||
- Ready to implement (past analysis phase)
|
||||
- Need simple task breakdown
|
||||
- Focus on quick execution planning
|
||||
|
||||
---
|
||||
|
||||
**Now execute analyze-with-file for**: $ARGUMENTS
|
||||
779
.claude/commands/workflow/brainstorm-with-file.md
Normal file
779
.claude/commands/workflow/brainstorm-with-file.md
Normal file
@@ -0,0 +1,779 @@
|
||||
---
|
||||
name: brainstorm-with-file
|
||||
description: Interactive brainstorming with multi-CLI collaboration, idea expansion, and documented thought evolution
|
||||
argument-hint: "[-y|--yes] [-c|--continue] [-m|--mode creative|structured] \"idea or topic\""
|
||||
allowed-tools: TodoWrite(*), Task(*), AskUserQuestion(*), Read(*), Grep(*), Glob(*), Bash(*), Edit(*), Write(*)
|
||||
---
|
||||
|
||||
## Auto Mode
|
||||
|
||||
When `--yes` or `-y`: Auto-confirm decisions, use recommended roles, balanced exploration mode.
|
||||
|
||||
# Workflow Brainstorm Command
|
||||
|
||||
## Quick Start
|
||||
|
||||
```bash
|
||||
# Basic usage
|
||||
/workflow:brainstorm-with-file "如何重新设计用户通知系统"
|
||||
|
||||
# With options
|
||||
/workflow:brainstorm-with-file --continue "通知系统" # Continue existing
|
||||
/workflow:brainstorm-with-file -y -m creative "创新的AI辅助功能" # Creative auto mode
|
||||
/workflow:brainstorm-with-file -m structured "优化缓存策略" # Goal-oriented mode
|
||||
```
|
||||
|
||||
**Context Source**: cli-explore-agent + Multi-CLI perspectives (Gemini/Codex/Claude or Professional Roles)
|
||||
**Output Directory**: `.workflow/.brainstorm/{session-id}/`
|
||||
**Core Innovation**: Diverge-Converge cycles with documented thought evolution
|
||||
|
||||
## Output Artifacts
|
||||
|
||||
### Phase 1: Seed Understanding
|
||||
|
||||
| Artifact | Description |
|
||||
|----------|-------------|
|
||||
| `brainstorm.md` | Complete thought evolution timeline (initialized) |
|
||||
| Session variables | Dimensions, roles, exploration vectors |
|
||||
|
||||
### Phase 2: Divergent Exploration
|
||||
|
||||
| Artifact | Description |
|
||||
|----------|-------------|
|
||||
| `exploration-codebase.json` | Codebase context from cli-explore-agent |
|
||||
| `perspectives.json` | Multi-CLI perspective findings (creative/pragmatic/systematic) |
|
||||
| Updated `brainstorm.md` | Round 2 multi-perspective exploration |
|
||||
|
||||
### Phase 3: Interactive Refinement
|
||||
|
||||
| Artifact | Description |
|
||||
|----------|-------------|
|
||||
| `ideas/{idea-slug}.md` | Deep-dive analysis for selected ideas |
|
||||
| Updated `brainstorm.md` | Round 3-6 refinement cycles |
|
||||
|
||||
### Phase 4: Convergence & Crystallization
|
||||
|
||||
| Artifact | Description |
|
||||
|----------|-------------|
|
||||
| `synthesis.json` | Final synthesis with top ideas, recommendations |
|
||||
| Final `brainstorm.md` | ⭐ Complete thought evolution with conclusions |
|
||||
|
||||
## Overview
|
||||
|
||||
Interactive brainstorming workflow with **multi-CLI collaboration** and **documented thought evolution**. Expands initial ideas through questioning, multi-perspective analysis, and iterative refinement.
|
||||
|
||||
**Core workflow**: Seed Idea → Expand → Multi-CLI Discuss → Synthesize → Refine → Crystallize
|
||||
|
||||
```
|
||||
┌─────────────────────────────────────────────────────────────────────────┐
|
||||
│ INTERACTIVE BRAINSTORMING WORKFLOW │
|
||||
├─────────────────────────────────────────────────────────────────────────┤
|
||||
│ │
|
||||
│ Phase 1: Seed Understanding │
|
||||
│ ├─ Parse initial idea/topic │
|
||||
│ ├─ Identify dimensions (technical, UX, business, etc.) │
|
||||
│ ├─ Select roles (professional or simple perspectives) │
|
||||
│ ├─ Initial scoping questions │
|
||||
│ ├─ Expand into exploration vectors │
|
||||
│ └─ Initialize brainstorm.md │
|
||||
│ │
|
||||
│ Phase 2: Divergent Exploration │
|
||||
│ ├─ cli-explore-agent: Codebase context (FIRST) │
|
||||
│ ├─ Multi-CLI Perspectives (AFTER exploration) │
|
||||
│ │ ├─ Creative (Gemini): Innovation, cross-domain │
|
||||
│ │ ├─ Pragmatic (Codex): Implementation, feasibility │
|
||||
│ │ └─ Systematic (Claude): Architecture, structure │
|
||||
│ └─ Aggregate diverse viewpoints │
|
||||
│ │
|
||||
│ Phase 3: Interactive Refinement (Multi-Round) │
|
||||
│ ├─ Present multi-perspective findings │
|
||||
│ ├─ User selects promising directions │
|
||||
│ ├─ Actions: Deep dive | Generate more | Challenge | Merge │
|
||||
│ ├─ Update brainstorm.md with evolution │
|
||||
│ └─ Repeat diverge-converge cycles (max 6 rounds) │
|
||||
│ │
|
||||
│ Phase 4: Convergence & Crystallization │
|
||||
│ ├─ Synthesize best ideas │
|
||||
│ ├─ Resolve conflicts between perspectives │
|
||||
│ ├─ Generate actionable conclusions │
|
||||
│ ├─ Offer next steps (plan/issue/analyze/export) │
|
||||
│ └─ Final brainstorm.md update │
|
||||
│ │
|
||||
└─────────────────────────────────────────────────────────────────────────┘
|
||||
```
|
||||
|
||||
## Output Structure
|
||||
|
||||
```
|
||||
.workflow/.brainstorm/BS-{slug}-{date}/
|
||||
├── brainstorm.md # ⭐ Complete thought evolution timeline
|
||||
├── exploration-codebase.json # Phase 2: Codebase context
|
||||
├── perspectives.json # Phase 2: Multi-CLI findings
|
||||
├── synthesis.json # Phase 4: Final synthesis
|
||||
└── ideas/ # Phase 3: Individual idea deep-dives
|
||||
├── idea-1.md
|
||||
├── idea-2.md
|
||||
└── merged-idea-1.md
|
||||
```
|
||||
|
||||
## Implementation
|
||||
|
||||
### Session Initialization
|
||||
|
||||
**Objective**: Create session context and directory structure for brainstorming.
|
||||
|
||||
**Required Actions**:
|
||||
1. Extract idea/topic from `$ARGUMENTS`
|
||||
2. Generate session ID: `BS-{slug}-{date}`
|
||||
- slug: lowercase, alphanumeric + Chinese, max 40 chars
|
||||
- date: YYYY-MM-DD (UTC+8)
|
||||
3. Define session folder: `.workflow/.brainstorm/{session-id}`
|
||||
4. Parse command options:
|
||||
- `-c` or `--continue` for session continuation
|
||||
- `-m` or `--mode` for brainstorm mode (creative/structured/balanced)
|
||||
- `-y` or `--yes` for auto-approval mode
|
||||
5. Auto-detect mode: If session folder + brainstorm.md exist → continue mode
|
||||
6. Create directory structure: `{session-folder}/ideas/`
|
||||
|
||||
**Session Variables**:
|
||||
- `sessionId`: Unique session identifier
|
||||
- `sessionFolder`: Base directory for all artifacts
|
||||
- `brainstormMode`: creative | structured | balanced
|
||||
- `autoMode`: Boolean for auto-confirmation
|
||||
- `mode`: new | continue
|
||||
|
||||
### Phase 1: Seed Understanding
|
||||
|
||||
**Objective**: Analyze topic, select roles, gather user input, expand into exploration vectors.
|
||||
|
||||
**Prerequisites**:
|
||||
- Session initialized with valid sessionId and sessionFolder
|
||||
- Topic/idea available from $ARGUMENTS
|
||||
|
||||
**Workflow Steps**:
|
||||
|
||||
1. **Parse Seed & Identify Dimensions**
|
||||
- Match topic keywords against BRAINSTORM_DIMENSIONS
|
||||
- Identify relevant dimensions: technical, ux, business, innovation, feasibility, scalability, security
|
||||
- Default dimensions based on brainstormMode if no match
|
||||
|
||||
2. **Role Selection**
|
||||
- **Recommend roles** based on topic keywords (see Role Keywords mapping)
|
||||
- **Options**:
|
||||
- **Professional roles**: system-architect, product-manager, ui-designer, ux-expert, data-architect, test-strategist, subject-matter-expert, product-owner, scrum-master
|
||||
- **Simple perspectives**: creative/pragmatic/systematic (fallback)
|
||||
- **Auto mode**: Select top 3 recommended professional roles
|
||||
- **Manual mode**: AskUserQuestion with recommended roles + "Use simple perspectives" option
|
||||
|
||||
3. **Initial Scoping Questions** (if new session + not auto mode)
|
||||
- **Direction**: Multi-select from directions generated by detected dimensions (see Brainstorm Dimensions)
|
||||
- **Depth**: Single-select from quick/balanced/deep (15-20min / 30-60min / 1-2hr)
|
||||
- **Constraints**: Multi-select from existing architecture, time, resources, or no constraints
|
||||
|
||||
4. **Expand Seed into Exploration Vectors**
|
||||
- Launch Gemini CLI with analysis mode
|
||||
- Generate 5-7 exploration vectors:
|
||||
- Core question: Fundamental problem/opportunity
|
||||
- User perspective: Who benefits and how
|
||||
- Technical angle: What enables this
|
||||
- Alternative approaches: Other solutions
|
||||
- Challenges: Potential blockers
|
||||
- Innovation angle: 10x better approach
|
||||
- Integration: Fit with existing systems
|
||||
- Parse result into structured vectors
|
||||
|
||||
**CLI Call Example**:
|
||||
```javascript
|
||||
Bash({
|
||||
command: `ccw cli -p "
|
||||
Given the initial idea: '${idea_or_topic}'
|
||||
User focus areas: ${userFocusAreas.join(', ')}
|
||||
Constraints: ${constraints.join(', ')}
|
||||
|
||||
Generate 5-7 exploration vectors (questions/directions) to expand this idea:
|
||||
1. Core question: What is the fundamental problem/opportunity?
|
||||
2. User perspective: Who benefits and how?
|
||||
3. Technical angle: What enables this technically?
|
||||
4. Alternative approaches: What other ways could this be solved?
|
||||
5. Challenges: What could go wrong or block success?
|
||||
6. Innovation angle: What would make this 10x better?
|
||||
7. Integration: How does this fit with existing systems/processes?
|
||||
|
||||
Output as structured exploration vectors for multi-perspective analysis.
|
||||
" --tool gemini --mode analysis --model gemini-2.5-flash`,
|
||||
run_in_background: false
|
||||
})
|
||||
```
|
||||
|
||||
5. **Initialize brainstorm.md**
|
||||
- Create brainstorm.md with session metadata
|
||||
- Add initial context: user focus, depth, constraints
|
||||
- Add seed expansion: original idea + exploration vectors
|
||||
- Create empty sections for thought evolution timeline
|
||||
|
||||
**Success Criteria**:
|
||||
- Session folder created with brainstorm.md initialized
|
||||
- 1-3 roles selected (professional or simple perspectives)
|
||||
- 5-7 exploration vectors generated
|
||||
- User preferences captured (direction, depth, constraints)
|
||||
|
||||
### Phase 2: Divergent Exploration
|
||||
|
||||
**Objective**: Gather codebase context, then execute multi-perspective analysis in parallel.
|
||||
|
||||
**Prerequisites**:
|
||||
- Phase 1 completed successfully
|
||||
- Roles selected and stored
|
||||
- brainstorm.md initialized
|
||||
|
||||
**Workflow Steps**:
|
||||
|
||||
1. **Primary Codebase Exploration via cli-explore-agent** (⚠️ FIRST)
|
||||
- Agent type: `cli-explore-agent`
|
||||
- Execution mode: synchronous (run_in_background: false)
|
||||
- **Tasks**:
|
||||
- Run: `ccw tool exec get_modules_by_depth '{}'`
|
||||
- Search code related to topic keywords
|
||||
- Read: `.workflow/project-tech.json` if exists
|
||||
- **Output**: `{sessionFolder}/exploration-codebase.json`
|
||||
- relevant_files: [{path, relevance, rationale}]
|
||||
- existing_patterns: []
|
||||
- architecture_constraints: []
|
||||
- integration_points: []
|
||||
- inspiration_sources: []
|
||||
- **Purpose**: Enrich CLI prompts with codebase context
|
||||
|
||||
**Agent Call Example**:
|
||||
```javascript
|
||||
Task({
|
||||
subagent_type: "cli-explore-agent",
|
||||
run_in_background: false,
|
||||
description: `Explore codebase for brainstorm: ${topicSlug}`,
|
||||
prompt: `
|
||||
## Brainstorm Context
|
||||
Topic: ${idea_or_topic}
|
||||
Dimensions: ${dimensions.join(', ')}
|
||||
Mode: ${brainstormMode}
|
||||
Session: ${sessionFolder}
|
||||
|
||||
## MANDATORY FIRST STEPS
|
||||
1. Run: ccw tool exec get_modules_by_depth '{}'
|
||||
2. Search for code related to topic keywords
|
||||
3. Read: .workflow/project-tech.json (if exists)
|
||||
|
||||
## Exploration Focus
|
||||
- Identify existing implementations related to the topic
|
||||
- Find patterns that could inspire solutions
|
||||
- Map current architecture constraints
|
||||
- Locate integration points
|
||||
|
||||
## Output
|
||||
Write findings to: ${sessionFolder}/exploration-codebase.json
|
||||
|
||||
Schema:
|
||||
{
|
||||
"relevant_files": [{"path": "...", "relevance": "high|medium|low", "rationale": "..."}],
|
||||
"existing_patterns": [],
|
||||
"architecture_constraints": [],
|
||||
"integration_points": [],
|
||||
"inspiration_sources": [],
|
||||
"_metadata": { "exploration_type": "brainstorm-codebase", "timestamp": "..." }
|
||||
}
|
||||
`
|
||||
})
|
||||
|
||||
2. **Multi-CLI Perspective Analysis** (⚠️ AFTER exploration)
|
||||
- Launch 3 CLI calls in parallel (Gemini/Codex/Claude)
|
||||
- **Perspectives**:
|
||||
- **Creative (Gemini)**: Innovation, cross-domain inspiration, challenge assumptions
|
||||
- **Pragmatic (Codex)**: Implementation reality, feasibility, technical blockers
|
||||
- **Systematic (Claude)**: Architecture, decomposition, scalability
|
||||
- **Shared context**: Include exploration-codebase.json findings in prompts
|
||||
- **Execution**: Bash with run_in_background: true, wait for all results
|
||||
- **Output**: perspectives.json with creative/pragmatic/systematic sections
|
||||
|
||||
**Multi-CLI Call Example** (parallel execution):
|
||||
```javascript
|
||||
// Build shared context from exploration results
|
||||
const explorationContext = `
|
||||
PRIOR EXPLORATION CONTEXT (from cli-explore-agent):
|
||||
- Key files: ${explorationResults.relevant_files.slice(0,5).map(f => f.path).join(', ')}
|
||||
- Existing patterns: ${explorationResults.existing_patterns.slice(0,3).join(', ')}
|
||||
- Architecture constraints: ${explorationResults.architecture_constraints.slice(0,3).join(', ')}
|
||||
- Integration points: ${explorationResults.integration_points.slice(0,3).join(', ')}`
|
||||
|
||||
// Launch 3 CLI calls in parallel (single message, multiple Bash calls)
|
||||
Bash({
|
||||
command: `ccw cli -p "
|
||||
PURPOSE: Creative brainstorming for '${idea_or_topic}' - generate innovative ideas
|
||||
Success: 5+ unique creative solutions that push boundaries
|
||||
|
||||
${explorationContext}
|
||||
|
||||
TASK:
|
||||
• Build on existing patterns - how can they be extended creatively?
|
||||
• Think beyond obvious solutions - what would be surprising/delightful?
|
||||
• Explore cross-domain inspiration
|
||||
• Challenge assumptions - what if the opposite were true?
|
||||
• Generate 'moonshot' ideas alongside practical ones
|
||||
|
||||
MODE: analysis
|
||||
CONTEXT: @**/* | Topic: ${idea_or_topic}
|
||||
EXPECTED: 5+ creative ideas with novelty/impact ratings, challenged assumptions, cross-domain inspirations
|
||||
CONSTRAINTS: ${brainstormMode === 'structured' ? 'Keep ideas technically feasible' : 'No constraints - think freely'}
|
||||
" --tool gemini --mode analysis`,
|
||||
run_in_background: true
|
||||
})
|
||||
|
||||
Bash({
|
||||
command: `ccw cli -p "
|
||||
PURPOSE: Pragmatic brainstorming for '${idea_or_topic}' - focus on implementation reality
|
||||
Success: Actionable approaches with clear implementation paths
|
||||
|
||||
${explorationContext}
|
||||
|
||||
TASK:
|
||||
• Build on explored codebase - how to integrate with existing patterns?
|
||||
• Evaluate technical feasibility of core concept
|
||||
• Identify existing patterns/libraries that could help
|
||||
• Estimate implementation complexity
|
||||
• Highlight potential technical blockers
|
||||
• Suggest incremental implementation approach
|
||||
|
||||
MODE: analysis
|
||||
CONTEXT: @**/* | Topic: ${idea_or_topic}
|
||||
EXPECTED: 3-5 practical approaches with effort/risk ratings, dependencies, quick wins vs long-term
|
||||
CONSTRAINTS: Focus on what can actually be built with current tech stack
|
||||
" --tool codex --mode analysis`,
|
||||
run_in_background: true
|
||||
})
|
||||
|
||||
Bash({
|
||||
command: `ccw cli -p "
|
||||
PURPOSE: Systematic brainstorming for '${idea_or_topic}' - architectural thinking
|
||||
Success: Well-structured solution framework with clear tradeoffs
|
||||
|
||||
${explorationContext}
|
||||
|
||||
TASK:
|
||||
• Build on explored architecture - how to extend systematically?
|
||||
• Decompose the problem into sub-problems
|
||||
• Identify architectural patterns that apply
|
||||
• Map dependencies and interactions
|
||||
• Consider scalability implications
|
||||
• Propose systematic solution structure
|
||||
|
||||
MODE: analysis
|
||||
CONTEXT: @**/* | Topic: ${idea_or_topic}
|
||||
EXPECTED: Problem decomposition, 2-3 architectural approaches with tradeoffs, scalability assessment
|
||||
CONSTRAINTS: Consider existing system architecture
|
||||
" --tool claude --mode analysis`,
|
||||
run_in_background: true
|
||||
})
|
||||
|
||||
// ⚠️ STOP POINT: Wait for hook callback to receive all results before continuing
|
||||
```
|
||||
|
||||
3. **Aggregate Multi-Perspective Findings**
|
||||
- Consolidate creative/pragmatic/systematic results
|
||||
- Extract synthesis:
|
||||
- Convergent themes (all agree)
|
||||
- Conflicting views (need resolution)
|
||||
- Unique contributions (perspective-specific insights)
|
||||
- Write to perspectives.json
|
||||
|
||||
4. **Update brainstorm.md**
|
||||
- Append Round 2 section with multi-perspective exploration
|
||||
- Include creative/pragmatic/systematic findings
|
||||
- Add perspective synthesis
|
||||
|
||||
**CLI Prompt Template**:
|
||||
- **PURPOSE**: Role brainstorming for topic - focus description
|
||||
- **TASK**: Bullet list of specific actions
|
||||
- **MODE**: analysis
|
||||
- **CONTEXT**: @**/* | Topic + Exploration vectors + Codebase findings
|
||||
- **EXPECTED**: Output format requirements
|
||||
- **CONSTRAINTS**: Role-specific constraints
|
||||
|
||||
**Success Criteria**:
|
||||
- exploration-codebase.json created with codebase context
|
||||
- perspectives.json created with 3 perspective analyses
|
||||
- brainstorm.md updated with Round 2 findings
|
||||
- All CLI calls completed successfully
|
||||
|
||||
### Phase 3: Interactive Refinement
|
||||
|
||||
**Objective**: Iteratively refine ideas through user-guided exploration cycles.
|
||||
|
||||
**Prerequisites**:
|
||||
- Phase 2 completed successfully
|
||||
- perspectives.json contains initial ideas
|
||||
- brainstorm.md has Round 2 findings
|
||||
|
||||
**Guideline**: For complex tasks (code analysis, implementation, POC creation), delegate to agents via Task tool (cli-explore-agent, code-developer, universal-executor) or CLI calls (ccw cli). Avoid direct analysis/execution in main process.
|
||||
|
||||
**Workflow Steps**:
|
||||
|
||||
1. **Present Current State**
|
||||
- Extract top ideas from perspectives.json
|
||||
- Display with: title, source, brief description, novelty/feasibility ratings
|
||||
- List open questions
|
||||
|
||||
2. **Gather User Direction** (AskUserQuestion)
|
||||
- **Question 1**: Which ideas to explore (multi-select from top ideas)
|
||||
- **Question 2**: Next step (single-select):
|
||||
- **深入探索**: Deep dive on selected ideas
|
||||
- **继续发散**: Generate more ideas
|
||||
- **挑战验证**: Devil's advocate challenge
|
||||
- **合并综合**: Merge multiple ideas
|
||||
- **准备收敛**: Begin convergence (exit loop)
|
||||
|
||||
3. **Execute User-Selected Action**
|
||||
|
||||
**Deep Dive** (per selected idea):
|
||||
- Launch Gemini CLI with analysis mode
|
||||
- Tasks: Elaborate concept, implementation requirements, challenges, POC approach, metrics, dependencies
|
||||
- Output: `{sessionFolder}/ideas/{idea-slug}.md`
|
||||
|
||||
**Generate More Ideas**:
|
||||
- Launch CLI with new angles from unexplored vectors
|
||||
- Add results to perspectives.json
|
||||
|
||||
**Devil's Advocate Challenge**:
|
||||
- Launch Codex CLI with analysis mode
|
||||
- Tasks: Identify objections, challenge assumptions, failure scenarios, alternatives, survivability rating
|
||||
- Return challenge results for idea strengthening
|
||||
|
||||
**Merge Ideas**:
|
||||
- Launch Gemini CLI with analysis mode
|
||||
- Tasks: Identify complementary elements, resolve contradictions, create unified concept
|
||||
- Add merged idea to perspectives.json
|
||||
|
||||
4. **Update brainstorm.md**
|
||||
- Append Round N section with findings
|
||||
- Document user direction and action results
|
||||
|
||||
5. **Repeat or Converge**
|
||||
- Continue loop (max 6 rounds) or exit to Phase 4
|
||||
|
||||
**Refinement Actions**:
|
||||
|
||||
| Action | Tool | Output | Description |
|
||||
|--------|------|--------|-------------|
|
||||
| Deep Dive | Gemini CLI | ideas/{slug}.md | Comprehensive idea analysis |
|
||||
| Generate More | Selected CLI | Updated perspectives.json | Additional idea generation |
|
||||
| Challenge | Codex CLI | Challenge results | Critical weaknesses exposed |
|
||||
| Merge | Gemini CLI | Merged idea | Synthesized concept |
|
||||
|
||||
**CLI Call Examples for Refinement Actions**:
|
||||
|
||||
**1. Deep Dive on Selected Idea**:
|
||||
```javascript
|
||||
Bash({
|
||||
command: `ccw cli -p "
|
||||
PURPOSE: Deep dive analysis on idea '${idea.title}'
|
||||
Success: Comprehensive understanding with actionable next steps
|
||||
|
||||
TASK:
|
||||
• Elaborate the core concept in detail
|
||||
• Identify implementation requirements
|
||||
• List potential challenges and mitigations
|
||||
• Suggest proof-of-concept approach
|
||||
• Define success metrics
|
||||
• Map related/dependent features
|
||||
|
||||
MODE: analysis
|
||||
|
||||
CONTEXT: @**/*
|
||||
Original idea: ${idea.description}
|
||||
Source perspective: ${idea.source}
|
||||
User interest reason: ${idea.userReason || 'Selected for exploration'}
|
||||
|
||||
EXPECTED:
|
||||
- Detailed concept description
|
||||
- Technical requirements list
|
||||
- Risk/challenge matrix
|
||||
- MVP definition
|
||||
- Success criteria
|
||||
- Recommendation: pursue/pivot/park
|
||||
|
||||
CONSTRAINTS: Focus on actionability
|
||||
" --tool gemini --mode analysis`,
|
||||
run_in_background: false
|
||||
})
|
||||
```
|
||||
|
||||
**2. Devil's Advocate Challenge**:
|
||||
```javascript
|
||||
Bash({
|
||||
command: `ccw cli -p "
|
||||
PURPOSE: Devil's advocate - rigorously challenge these brainstorm ideas
|
||||
Success: Uncover hidden weaknesses and strengthen viable ideas
|
||||
|
||||
IDEAS TO CHALLENGE:
|
||||
${ideas.map((idea, i) => `${i+1}. ${idea.title}: ${idea.brief}`).join('\n')}
|
||||
|
||||
TASK:
|
||||
• For each idea, identify 3 strongest objections
|
||||
• Challenge core assumptions
|
||||
• Identify scenarios where this fails
|
||||
• Consider competitive/alternative solutions
|
||||
• Assess whether this solves the right problem
|
||||
• Rate survivability after challenge (1-5)
|
||||
|
||||
MODE: analysis
|
||||
|
||||
EXPECTED:
|
||||
- Per-idea challenge report
|
||||
- Critical weaknesses exposed
|
||||
- Counter-arguments to objections (if any)
|
||||
- Ideas that survive the challenge
|
||||
- Modified/strengthened versions
|
||||
|
||||
CONSTRAINTS: Be genuinely critical, not just contrarian
|
||||
" --tool codex --mode analysis`,
|
||||
run_in_background: false
|
||||
})
|
||||
```
|
||||
|
||||
**3. Merge Multiple Ideas**:
|
||||
```javascript
|
||||
Bash({
|
||||
command: `ccw cli -p "
|
||||
PURPOSE: Synthesize multiple ideas into unified concept
|
||||
Success: Coherent merged idea that captures best elements
|
||||
|
||||
IDEAS TO MERGE:
|
||||
${selectedIdeas.map((idea, i) => `
|
||||
${i+1}. ${idea.title} (${idea.source})
|
||||
${idea.description}
|
||||
Strengths: ${idea.strengths.join(', ')}
|
||||
`).join('\n')}
|
||||
|
||||
TASK:
|
||||
• Identify complementary elements
|
||||
• Resolve contradictions
|
||||
• Create unified concept
|
||||
• Preserve key strengths from each
|
||||
• Describe the merged solution
|
||||
• Assess viability of merged idea
|
||||
|
||||
MODE: analysis
|
||||
|
||||
EXPECTED:
|
||||
- Merged concept description
|
||||
- Elements taken from each source idea
|
||||
- Contradictions resolved (or noted as tradeoffs)
|
||||
- New combined strengths
|
||||
- Implementation considerations
|
||||
|
||||
CONSTRAINTS: Don't force incompatible ideas together
|
||||
" --tool gemini --mode analysis`,
|
||||
run_in_background: false
|
||||
})
|
||||
```
|
||||
|
||||
**Success Criteria**:
|
||||
- User-selected ideas processed
|
||||
- brainstorm.md updated with all refinement rounds
|
||||
- ideas/ folder contains deep-dive documents for selected ideas
|
||||
- Exit condition reached (user selects "准备收敛" or max rounds)
|
||||
|
||||
### Phase 4: Convergence & Crystallization
|
||||
|
||||
**Objective**: Synthesize final ideas, generate conclusions, offer next steps.
|
||||
|
||||
**Prerequisites**:
|
||||
- Phase 3 completed successfully
|
||||
- Multiple rounds of refinement documented
|
||||
- User ready to converge
|
||||
|
||||
**Workflow Steps**:
|
||||
|
||||
1. **Generate Final Synthesis**
|
||||
- Consolidate all ideas from perspectives.json and refinement rounds
|
||||
- **Top ideas**: Filter active ideas, sort by score, take top 5
|
||||
- Include: title, description, source_perspective, score, novelty, feasibility, strengths, challenges, next_steps
|
||||
- **Parked ideas**: Ideas marked as parked with reason and future trigger
|
||||
- **Key insights**: Process discoveries, challenged assumptions, unexpected connections
|
||||
- **Recommendations**: Primary recommendation, alternatives, not recommended
|
||||
- **Follow-up**: Implementation/research/validation summaries
|
||||
- Write to synthesis.json
|
||||
|
||||
2. **Final brainstorm.md Update**
|
||||
- Append synthesis & conclusions section
|
||||
- **Executive summary**: High-level overview
|
||||
- **Top ideas**: Ranked with descriptions, strengths, challenges, next steps
|
||||
- **Primary recommendation**: Best path forward with rationale
|
||||
- **Alternative approaches**: Other viable options with tradeoffs
|
||||
- **Parked ideas**: Future considerations
|
||||
- **Key insights**: Learnings from the process
|
||||
- **Session statistics**: Rounds, ideas generated/survived, duration
|
||||
|
||||
3. **Post-Completion Options** (AskUserQuestion)
|
||||
- **创建实施计划**: Launch workflow:plan with top idea
|
||||
- **创建Issue**: Launch issue:new for top 3 ideas
|
||||
- **深入分析**: Launch workflow:analyze-with-file for top idea
|
||||
- **导出分享**: Generate shareable report
|
||||
- **完成**: No further action
|
||||
|
||||
**synthesis.json Schema**:
|
||||
- `session_id`: Session identifier
|
||||
- `topic`: Original idea/topic
|
||||
- `completed`: Completion timestamp
|
||||
- `total_rounds`: Number of refinement rounds
|
||||
- `top_ideas[]`: Top 5 ranked ideas
|
||||
- `parked_ideas[]`: Ideas parked for future
|
||||
- `key_insights[]`: Process learnings
|
||||
- `recommendations`: Primary/alternatives/not_recommended
|
||||
- `follow_up[]`: Next step summaries
|
||||
|
||||
**Success Criteria**:
|
||||
- synthesis.json created with final synthesis
|
||||
- brainstorm.md finalized with conclusions
|
||||
- User offered next step options
|
||||
- Session complete
|
||||
|
||||
## Configuration
|
||||
|
||||
### Brainstorm Dimensions
|
||||
|
||||
Dimensions matched against topic keywords to identify focus areas:
|
||||
|
||||
| Dimension | Keywords |
|
||||
|-----------|----------|
|
||||
| technical | 技术, technical, implementation, code, 实现, architecture |
|
||||
| ux | 用户, user, experience, UX, UI, 体验, interaction |
|
||||
| business | 业务, business, value, ROI, 价值, market |
|
||||
| innovation | 创新, innovation, novel, creative, 新颖 |
|
||||
| feasibility | 可行, feasible, practical, realistic, 实际 |
|
||||
| scalability | 扩展, scale, growth, performance, 性能 |
|
||||
| security | 安全, security, risk, protection, 风险 |
|
||||
|
||||
### Role Selection
|
||||
|
||||
**Professional Roles** (recommended based on topic keywords):
|
||||
|
||||
| Role | CLI Tool | Focus Area | Keywords |
|
||||
|------|----------|------------|----------|
|
||||
| system-architect | Claude | Architecture, patterns | 架构, architecture, system, 系统, design pattern |
|
||||
| product-manager | Gemini | Business value, roadmap | 产品, product, feature, 功能, roadmap |
|
||||
| ui-designer | Gemini | Visual design, interaction | UI, 界面, interface, visual, 视觉 |
|
||||
| ux-expert | Codex | User research, usability | UX, 体验, experience, user, 用户 |
|
||||
| data-architect | Claude | Data modeling, storage | 数据, data, database, 存储, storage |
|
||||
| test-strategist | Codex | Quality, testing | 测试, test, quality, 质量, QA |
|
||||
| subject-matter-expert | Gemini | Domain knowledge | 领域, domain, industry, 行业, expert |
|
||||
| product-owner | Codex | Priority, scope | 优先, priority, scope, 范围, backlog |
|
||||
| scrum-master | Gemini | Process, collaboration | 敏捷, agile, scrum, sprint, 迭代 |
|
||||
|
||||
**Simple Perspectives** (fallback):
|
||||
|
||||
| Perspective | CLI Tool | Focus | Best For |
|
||||
|-------------|----------|-------|----------|
|
||||
| creative | Gemini | Innovation, cross-domain | Generating novel ideas |
|
||||
| pragmatic | Codex | Implementation, feasibility | Reality-checking ideas |
|
||||
| systematic | Claude | Architecture, structure | Organizing solutions |
|
||||
|
||||
**Selection Strategy**:
|
||||
1. **Auto mode** (`-y`): Choose top 3 recommended professional roles
|
||||
2. **Manual mode**: Present recommended roles + "Use simple perspectives" option
|
||||
3. **Continue mode**: Use roles from previous session
|
||||
|
||||
### Collaboration Patterns
|
||||
|
||||
| Pattern | Usage | Description |
|
||||
|---------|-------|-------------|
|
||||
| Parallel Divergence | New topic | All roles explore simultaneously from different angles |
|
||||
| Sequential Deep-Dive | Promising idea | One role expands, others critique/refine |
|
||||
| Debate Mode | Controversial approach | Roles argue for/against approaches |
|
||||
| Synthesis Mode | Ready to decide | Combine insights into actionable conclusion |
|
||||
|
||||
### Context Overflow Protection
|
||||
|
||||
**Per-Role Limits**:
|
||||
- Main analysis output: < 3000 words
|
||||
- Sub-document (if any): < 2000 words each
|
||||
- Maximum sub-documents: 5 per role
|
||||
|
||||
**Synthesis Protection**:
|
||||
- If total analysis > 100KB, synthesis reads only main analysis files (not sub-documents)
|
||||
- Large ideas automatically split into separate idea documents in ideas/ folder
|
||||
|
||||
**Recovery Steps**:
|
||||
1. Check CLI logs for context overflow errors
|
||||
2. Reduce scope: fewer roles or simpler topic
|
||||
3. Use `--mode structured` for more focused output
|
||||
4. Split complex topics into multiple sessions
|
||||
|
||||
**Prevention**:
|
||||
- Start with 3 roles (default), increase if needed
|
||||
- Use structured topic format: "GOAL: ... SCOPE: ... CONTEXT: ..."
|
||||
- Review output sizes before final synthesis
|
||||
|
||||
## Error Handling
|
||||
|
||||
| Error | Resolution |
|
||||
|-------|------------|
|
||||
| cli-explore-agent fails | Continue with empty exploration context |
|
||||
| CLI timeout | Retry with shorter prompt, or skip perspective |
|
||||
| No good ideas | Reframe problem, adjust constraints, try new angles |
|
||||
| User disengaged | Summarize progress, offer break point with resume |
|
||||
| Perspectives conflict | Present as tradeoff, let user decide |
|
||||
| Max rounds reached | Force synthesis, highlight unresolved questions |
|
||||
| All ideas fail challenge | Return to divergent phase with new constraints |
|
||||
|
||||
## Best Practices
|
||||
|
||||
1. **Clear Topic Definition**: Detailed topics → better role selection and exploration
|
||||
2. **Agent-First for Complex Tasks**: For code analysis, POC implementation, or technical validation during refinement, delegate to agents via Task tool (cli-explore-agent, code-developer, universal-executor) or CLI calls (ccw cli). Avoid direct analysis/execution in main process
|
||||
3. **Review brainstorm.md**: Check thought evolution before final decisions
|
||||
4. **Embrace Conflicts**: Perspective conflicts often reveal important tradeoffs
|
||||
5. **Document Evolution**: brainstorm.md captures full thinking process for team review
|
||||
6. **Use Continue Mode**: Resume sessions to build on previous exploration
|
||||
|
||||
## Templates
|
||||
|
||||
### Brainstorm Document Structure
|
||||
|
||||
**brainstorm.md** contains:
|
||||
- **Header**: Session metadata (ID, topic, started, mode, dimensions)
|
||||
- **Initial Context**: User focus, depth, constraints
|
||||
- **Seed Expansion**: Original idea + exploration vectors
|
||||
- **Thought Evolution Timeline**: Round-by-round findings
|
||||
- Round 1: Seed Understanding
|
||||
- Round 2: Multi-Perspective Exploration (creative/pragmatic/systematic)
|
||||
- Round 3-N: Interactive Refinement (deep-dive/challenge/merge)
|
||||
- **Synthesis & Conclusions**: Executive summary, top ideas, recommendations
|
||||
- **Session Statistics**: Rounds, ideas, duration, artifacts
|
||||
|
||||
See full markdown template in original file (lines 955-1161).
|
||||
|
||||
## Usage Recommendations (Requires User Confirmation)
|
||||
|
||||
**Use `Skill(skill="workflow:brainstorm-with-file", args="\"topic or question\"")` when:**
|
||||
- Starting a new feature/product without clear direction
|
||||
- Facing a complex problem with multiple possible solutions
|
||||
- Need to explore alternatives before committing
|
||||
- Want documented thinking process for team review
|
||||
- Combining multiple stakeholder perspectives
|
||||
|
||||
**Use `Skill(skill="workflow:analyze-with-file", args="\"topic\"")` when:**
|
||||
- Investigating existing code/system
|
||||
- Need factual analysis over ideation
|
||||
- Debugging or troubleshooting
|
||||
- Understanding current state
|
||||
|
||||
**Use `Skill(skill="workflow:collaborative-plan-with-file", args="\"task description\"")` when:**
|
||||
- Complex planning requiring multiple perspectives
|
||||
- Large scope needing parallel sub-domain analysis
|
||||
- Want shared collaborative planning document
|
||||
- Need structured task breakdown with agent coordination
|
||||
|
||||
**Use `Skill(skill="workflow:lite-plan", args="\"task description\"")` when:**
|
||||
- Direction is already clear
|
||||
- Ready to move from ideas to execution
|
||||
- Need simple implementation breakdown
|
||||
|
||||
---
|
||||
|
||||
**Now execute brainstorm-with-file for**: $ARGUMENTS
|
||||
@@ -1,587 +0,0 @@
|
||||
---
|
||||
name: api-designer
|
||||
description: Generate or update api-designer/analysis.md addressing guidance-specification discussion points for API design perspective
|
||||
argument-hint: "optional topic - uses existing framework if available"
|
||||
allowed-tools: Task(conceptual-planning-agent), TodoWrite(*), Read(*), Write(*)
|
||||
---
|
||||
|
||||
## 🔌 **API Designer Analysis Generator**
|
||||
|
||||
### Purpose
|
||||
**Specialized command for generating api-designer/analysis.md** that addresses guidance-specification.md discussion points from backend API design perspective. Creates or updates role-specific analysis with framework references.
|
||||
|
||||
### Core Function
|
||||
- **Framework-based Analysis**: Address each discussion point in guidance-specification.md
|
||||
- **API Design Focus**: RESTful/GraphQL API design, endpoint structure, and contract definition
|
||||
- **Update Mechanism**: Create new or update existing analysis.md
|
||||
- **Agent Delegation**: Use conceptual-planning-agent for analysis generation
|
||||
|
||||
### Analysis Scope
|
||||
- **API Architecture**: RESTful/GraphQL design patterns and best practices
|
||||
- **Endpoint Design**: Resource modeling, URL structure, and HTTP method selection
|
||||
- **Data Contracts**: Request/response schemas, validation rules, and data transformation
|
||||
- **API Documentation**: OpenAPI/Swagger specifications and developer experience
|
||||
|
||||
### Role Boundaries & Responsibilities
|
||||
|
||||
#### **What This Role OWNS (API Contract Within Architectural Framework)**
|
||||
- **API Contract Definition**: Specific endpoint paths, HTTP methods, and status codes
|
||||
- **Resource Modeling**: Mapping domain entities to RESTful resources or GraphQL types
|
||||
- **Request/Response Schemas**: Detailed data contracts, validation rules, and error formats
|
||||
- **API Versioning Strategy**: Version management, deprecation policies, and migration paths
|
||||
- **Developer Experience**: API documentation (OpenAPI/Swagger), code examples, and SDKs
|
||||
|
||||
#### **What This Role DOES NOT Own (Defers to Other Roles)**
|
||||
- **System Architecture Decisions**: Microservices vs monolithic, overall communication patterns → Defers to **System Architect**
|
||||
- **Canonical Data Model**: Underlying data schemas and entity relationships → Defers to **Data Architect**
|
||||
- **UI/Frontend Integration**: How clients consume the API → Defers to **UI Designer**
|
||||
|
||||
#### **Handoff Points**
|
||||
- **FROM System Architect**: Receives architectural constraints (REST vs GraphQL, sync vs async) that define the design space
|
||||
- **FROM Data Architect**: Receives canonical data model and translates it into public API data contracts (as projection/view)
|
||||
- **TO Frontend Teams**: Provides complete API specifications, documentation, and integration guides
|
||||
|
||||
## ⚙️ **Execution Protocol**
|
||||
|
||||
### Phase 1: Session & Framework Detection
|
||||
```bash
|
||||
# Check active session and framework
|
||||
CHECK: find .workflow/active/ -name "WFS-*" -type d
|
||||
IF active_session EXISTS:
|
||||
session_id = get_active_session()
|
||||
brainstorm_dir = .workflow/active/WFS-{session}/.brainstorming/
|
||||
|
||||
CHECK: brainstorm_dir/guidance-specification.md
|
||||
IF EXISTS:
|
||||
framework_mode = true
|
||||
load_framework = true
|
||||
ELSE:
|
||||
IF topic_provided:
|
||||
framework_mode = false # Create analysis without framework
|
||||
ELSE:
|
||||
ERROR: "No framework found and no topic provided"
|
||||
```
|
||||
|
||||
### Phase 2: Analysis Mode Detection
|
||||
```bash
|
||||
# Check existing analysis
|
||||
CHECK: brainstorm_dir/api-designer/analysis.md
|
||||
IF EXISTS:
|
||||
SHOW existing analysis summary
|
||||
ASK: "Analysis exists. Do you want to:"
|
||||
OPTIONS:
|
||||
1. "Update with new insights" → Update existing
|
||||
2. "Replace completely" → Generate new
|
||||
3. "Cancel" → Exit without changes
|
||||
ELSE:
|
||||
CREATE new analysis
|
||||
```
|
||||
|
||||
### Phase 3: Agent Task Generation
|
||||
**Framework-Based Analysis** (when guidance-specification.md exists):
|
||||
```bash
|
||||
Task(subagent_type="conceptual-planning-agent",
|
||||
run_in_background=false,
|
||||
prompt="Generate API designer analysis addressing topic framework
|
||||
|
||||
## Framework Integration Required
|
||||
**MANDATORY**: Load and address guidance-specification.md discussion points
|
||||
**Framework Reference**: @{session.brainstorm_dir}/guidance-specification.md
|
||||
**Output Location**: {session.brainstorm_dir}/api-designer/analysis.md
|
||||
|
||||
## Analysis Requirements
|
||||
1. **Load Topic Framework**: Read guidance-specification.md completely
|
||||
2. **Address Each Discussion Point**: Respond to all 5 framework sections from API design perspective
|
||||
3. **Include Framework Reference**: Start analysis.md with @../guidance-specification.md
|
||||
4. **API Design Focus**: Emphasize endpoint structure, data contracts, versioning strategies
|
||||
5. **Structured Response**: Use framework structure for analysis organization
|
||||
|
||||
## Framework Sections to Address
|
||||
- Core Requirements (from API design perspective)
|
||||
- Technical Considerations (detailed API architecture analysis)
|
||||
- User Experience Factors (developer experience and API usability)
|
||||
- Implementation Challenges (API design risks and solutions)
|
||||
- Success Metrics (API performance metrics and adoption tracking)
|
||||
|
||||
## Output Structure Required
|
||||
```markdown
|
||||
# API Designer Analysis: [Topic]
|
||||
|
||||
**Framework Reference**: @../guidance-specification.md
|
||||
**Role Focus**: Backend API Design and Contract Definition
|
||||
|
||||
## Core Requirements Analysis
|
||||
[Address framework requirements from API design perspective]
|
||||
|
||||
## Technical Considerations
|
||||
[Detailed API architecture and endpoint design analysis]
|
||||
|
||||
## Developer Experience Factors
|
||||
[API usability, documentation, and integration ease]
|
||||
|
||||
## Implementation Challenges
|
||||
[API design risks and mitigation strategies]
|
||||
|
||||
## Success Metrics
|
||||
[API performance metrics, adoption rates, and developer satisfaction]
|
||||
|
||||
## API Design-Specific Recommendations
|
||||
[Detailed API design recommendations and best practices]
|
||||
```",
|
||||
description="Generate API designer framework-based analysis")
|
||||
```
|
||||
|
||||
### Phase 4: Update Mechanism
|
||||
**Analysis Update Process**:
|
||||
```bash
|
||||
# For existing analysis updates
|
||||
IF update_mode = "incremental":
|
||||
Task(subagent_type="conceptual-planning-agent",
|
||||
run_in_background=false,
|
||||
prompt="Update existing API designer analysis
|
||||
|
||||
## Current Analysis Context
|
||||
**Existing Analysis**: @{session.brainstorm_dir}/api-designer/analysis.md
|
||||
**Framework Reference**: @{session.brainstorm_dir}/guidance-specification.md
|
||||
|
||||
## Update Requirements
|
||||
1. **Preserve Structure**: Maintain existing analysis structure
|
||||
2. **Add New Insights**: Integrate new API design insights and recommendations
|
||||
3. **Framework Alignment**: Ensure continued alignment with topic framework
|
||||
4. **API Updates**: Add new endpoint patterns, versioning strategies, documentation improvements
|
||||
5. **Maintain References**: Keep @../guidance-specification.md reference
|
||||
|
||||
## Update Instructions
|
||||
- Read existing analysis completely
|
||||
- Identify areas for enhancement or new insights
|
||||
- Add API design depth while preserving original structure
|
||||
- Update recommendations with new API design patterns and approaches
|
||||
- Maintain framework discussion point addressing",
|
||||
description="Update API designer analysis incrementally")
|
||||
```
|
||||
|
||||
## Document Structure
|
||||
|
||||
### Output Files
|
||||
```
|
||||
.workflow/active/WFS-[topic]/.brainstorming/
|
||||
├── guidance-specification.md # Input: Framework (if exists)
|
||||
└── api-designer/
|
||||
└── analysis.md # ★ OUTPUT: Framework-based analysis
|
||||
```
|
||||
|
||||
### Analysis Structure
|
||||
**Required Elements**:
|
||||
- **Framework Reference**: @../guidance-specification.md (if framework exists)
|
||||
- **Role Focus**: Backend API Design and Contract Definition perspective
|
||||
- **5 Framework Sections**: Address each framework discussion point
|
||||
- **API Design Recommendations**: Endpoint-specific insights and solutions
|
||||
|
||||
## ⚡ **Two-Step Execution Flow**
|
||||
|
||||
### ⚠️ Session Management - FIRST STEP
|
||||
Session detection and selection:
|
||||
```bash
|
||||
# Check for active sessions
|
||||
active_sessions=$(find .workflow/active/ -name "WFS-*" -type d 2>/dev/null)
|
||||
if [ multiple_sessions ]; then
|
||||
prompt_user_to_select_session()
|
||||
else
|
||||
use_existing_or_create_new()
|
||||
fi
|
||||
```
|
||||
|
||||
### Step 1: Context Gathering Phase
|
||||
**API Designer Perspective Questioning**
|
||||
|
||||
Before agent assignment, gather comprehensive API design context:
|
||||
|
||||
#### 📋 Role-Specific Questions
|
||||
1. **API Type & Architecture**
|
||||
- RESTful, GraphQL, or hybrid API approach?
|
||||
- Synchronous vs asynchronous communication patterns?
|
||||
- Real-time requirements (WebSocket, Server-Sent Events)?
|
||||
|
||||
2. **Resource Modeling & Endpoints**
|
||||
- What are the core domain resources/entities?
|
||||
- Expected CRUD operations for each resource?
|
||||
- Complex query requirements (filtering, sorting, pagination)?
|
||||
|
||||
3. **Data Contracts & Validation**
|
||||
- Request/response data format requirements (JSON, XML, Protocol Buffers)?
|
||||
- Input validation and sanitization requirements?
|
||||
- Data transformation and mapping needs?
|
||||
|
||||
4. **API Management & Governance**
|
||||
- API versioning strategy requirements?
|
||||
- Authentication and authorization mechanisms?
|
||||
- Rate limiting and throttling requirements?
|
||||
- API documentation and developer portal needs?
|
||||
|
||||
5. **Integration & Compatibility**
|
||||
- Client platforms consuming the API (web, mobile, third-party)?
|
||||
- Backward compatibility requirements?
|
||||
- External API integrations needed?
|
||||
|
||||
#### Context Validation
|
||||
- **Minimum Response**: Each answer must be ≥50 characters
|
||||
- **Re-prompting**: Insufficient detail triggers follow-up questions
|
||||
- **Context Storage**: Save responses to `.brainstorming/api-designer-context.md`
|
||||
|
||||
### Step 2: Agent Assignment with Flow Control
|
||||
**Dedicated Agent Execution**
|
||||
|
||||
```bash
|
||||
Task(conceptual-planning-agent): "
|
||||
[FLOW_CONTROL]
|
||||
|
||||
Execute dedicated api-designer conceptual analysis for: {topic}
|
||||
|
||||
ASSIGNED_ROLE: api-designer
|
||||
OUTPUT_LOCATION: .brainstorming/api-designer/
|
||||
USER_CONTEXT: {validated_responses_from_context_gathering}
|
||||
|
||||
Flow Control Steps:
|
||||
[
|
||||
{
|
||||
\"step\": \"load_role_template\",
|
||||
\"action\": \"Load api-designer planning template\",
|
||||
\"command\": \"bash($(cat ~/.claude/workflows/cli-templates/planning-roles/api-designer.md))\",
|
||||
\"output_to\": \"role_template\"
|
||||
}
|
||||
]
|
||||
|
||||
Conceptual Analysis Requirements:
|
||||
- Apply api-designer perspective to topic analysis
|
||||
- Focus on endpoint design, data contracts, and API governance
|
||||
- Use loaded role template framework for analysis structure
|
||||
- Generate role-specific deliverables in designated output location
|
||||
- Address all user context from questioning phase
|
||||
|
||||
Deliverables:
|
||||
- analysis.md: Main API design analysis
|
||||
- api-specification.md: Detailed endpoint specifications
|
||||
- data-contracts.md: Request/response schemas and validation rules
|
||||
- api-documentation.md: API documentation strategy and templates
|
||||
|
||||
Embody api-designer role expertise for comprehensive conceptual planning."
|
||||
```
|
||||
|
||||
### Progress Tracking
|
||||
TodoWrite tracking for two-step process:
|
||||
```json
|
||||
[
|
||||
{"content": "Gather API designer context through role-specific questioning", "status": "in_progress", "activeForm": "Gathering context"},
|
||||
{"content": "Validate context responses and save to api-designer-context.md", "status": "pending", "activeForm": "Validating context"},
|
||||
{"content": "Load api-designer planning template via flow control", "status": "pending", "activeForm": "Loading template"},
|
||||
{"content": "Execute dedicated conceptual-planning-agent for api-designer role", "status": "pending", "activeForm": "Executing agent"}
|
||||
]
|
||||
```
|
||||
|
||||
## 📊 **Output Specification**
|
||||
|
||||
### Output Location
|
||||
```
|
||||
.workflow/active/WFS-{topic-slug}/.brainstorming/api-designer/
|
||||
├── analysis.md # Primary API design analysis
|
||||
├── api-specification.md # Detailed endpoint specifications (OpenAPI/Swagger)
|
||||
├── data-contracts.md # Request/response schemas and validation rules
|
||||
├── versioning-strategy.md # API versioning and backward compatibility plan
|
||||
└── developer-guide.md # API usage documentation and integration examples
|
||||
```
|
||||
|
||||
### Document Templates
|
||||
|
||||
#### analysis.md Structure
|
||||
```markdown
|
||||
# API Design Analysis: {Topic}
|
||||
*Generated: {timestamp}*
|
||||
|
||||
## Executive Summary
|
||||
[Key API design findings and recommendations overview]
|
||||
|
||||
## API Architecture Overview
|
||||
### API Type Selection (REST/GraphQL/Hybrid)
|
||||
### Communication Patterns
|
||||
### Authentication & Authorization Strategy
|
||||
|
||||
## Resource Modeling
|
||||
### Core Domain Resources
|
||||
### Resource Relationships
|
||||
### URL Structure and Naming Conventions
|
||||
|
||||
## Endpoint Design
|
||||
### Resource Endpoints
|
||||
- GET /api/v1/resources
|
||||
- POST /api/v1/resources
|
||||
- GET /api/v1/resources/{id}
|
||||
- PUT /api/v1/resources/{id}
|
||||
- DELETE /api/v1/resources/{id}
|
||||
|
||||
### Query Parameters
|
||||
- Filtering: ?filter[field]=value
|
||||
- Sorting: ?sort=field,-field2
|
||||
- Pagination: ?page=1&limit=20
|
||||
|
||||
### HTTP Methods and Status Codes
|
||||
- Success responses (2xx)
|
||||
- Client errors (4xx)
|
||||
- Server errors (5xx)
|
||||
|
||||
## Data Contracts
|
||||
### Request Schemas
|
||||
[JSON Schema or OpenAPI definitions]
|
||||
|
||||
### Response Schemas
|
||||
[JSON Schema or OpenAPI definitions]
|
||||
|
||||
### Validation Rules
|
||||
- Required fields
|
||||
- Data types and formats
|
||||
- Business logic constraints
|
||||
|
||||
## API Versioning Strategy
|
||||
### Versioning Approach (URL/Header/Accept)
|
||||
### Version Lifecycle Management
|
||||
### Deprecation Policy
|
||||
### Migration Paths
|
||||
|
||||
## Security & Governance
|
||||
### Authentication Mechanisms
|
||||
- OAuth 2.0 / JWT / API Keys
|
||||
### Authorization Patterns
|
||||
- RBAC / ABAC / Resource-based
|
||||
### Rate Limiting & Throttling
|
||||
### CORS and Security Headers
|
||||
|
||||
## Error Handling
|
||||
### Standard Error Response Format
|
||||
```json
|
||||
{
|
||||
"error": {
|
||||
"code": "ERROR_CODE",
|
||||
"message": "Human-readable error message",
|
||||
"details": [],
|
||||
"trace_id": "uuid"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### Error Code Taxonomy
|
||||
### Validation Error Responses
|
||||
|
||||
## API Documentation
|
||||
### OpenAPI/Swagger Specification
|
||||
### Developer Portal Requirements
|
||||
### Code Examples and SDKs
|
||||
### Changelog and Migration Guides
|
||||
|
||||
## Performance Optimization
|
||||
### Response Caching Strategies
|
||||
### Compression (gzip, brotli)
|
||||
### Field Selection (sparse fieldsets)
|
||||
### Bulk Operations and Batch Endpoints
|
||||
|
||||
## Monitoring & Observability
|
||||
### API Metrics
|
||||
- Request count, latency, error rates
|
||||
- Endpoint usage analytics
|
||||
### Logging Strategy
|
||||
### Distributed Tracing
|
||||
|
||||
## Developer Experience
|
||||
### API Usability Assessment
|
||||
### Integration Complexity
|
||||
### SDK and Client Library Needs
|
||||
### Sandbox and Testing Environments
|
||||
```
|
||||
|
||||
#### api-specification.md Structure
|
||||
```markdown
|
||||
# API Specification: {Topic}
|
||||
*OpenAPI 3.0 Specification*
|
||||
|
||||
## API Information
|
||||
- **Title**: {API Name}
|
||||
- **Version**: 1.0.0
|
||||
- **Base URL**: https://api.example.com/v1
|
||||
- **Contact**: api-team@example.com
|
||||
|
||||
## Endpoints
|
||||
|
||||
### Users API
|
||||
|
||||
#### GET /users
|
||||
**Description**: Retrieve a list of users
|
||||
|
||||
**Parameters**:
|
||||
- `page` (query, integer): Page number (default: 1)
|
||||
- `limit` (query, integer): Items per page (default: 20, max: 100)
|
||||
- `sort` (query, string): Sort field (e.g., "created_at", "-updated_at")
|
||||
- `filter[status]` (query, string): Filter by user status
|
||||
|
||||
**Response 200**:
|
||||
```json
|
||||
{
|
||||
"data": [
|
||||
{
|
||||
"id": "uuid",
|
||||
"username": "string",
|
||||
"email": "string",
|
||||
"created_at": "2025-10-15T00:00:00Z"
|
||||
}
|
||||
],
|
||||
"meta": {
|
||||
"page": 1,
|
||||
"limit": 20,
|
||||
"total": 100
|
||||
},
|
||||
"links": {
|
||||
"self": "/users?page=1",
|
||||
"next": "/users?page=2",
|
||||
"prev": null
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
#### POST /users
|
||||
**Description**: Create a new user
|
||||
|
||||
**Request Body**:
|
||||
```json
|
||||
{
|
||||
"username": "string (required, 3-50 chars)",
|
||||
"email": "string (required, valid email)",
|
||||
"password": "string (required, min 8 chars)",
|
||||
"profile": {
|
||||
"first_name": "string (optional)",
|
||||
"last_name": "string (optional)"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
**Response 201**:
|
||||
```json
|
||||
{
|
||||
"data": {
|
||||
"id": "uuid",
|
||||
"username": "string",
|
||||
"email": "string",
|
||||
"created_at": "2025-10-15T00:00:00Z"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
**Response 400** (Validation Error):
|
||||
```json
|
||||
{
|
||||
"error": {
|
||||
"code": "VALIDATION_ERROR",
|
||||
"message": "Request validation failed",
|
||||
"details": [
|
||||
{
|
||||
"field": "email",
|
||||
"message": "Invalid email format"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
[Continue for all endpoints...]
|
||||
|
||||
## Authentication
|
||||
|
||||
### OAuth 2.0 Flow
|
||||
1. Client requests authorization
|
||||
2. User grants permission
|
||||
3. Client receives access token
|
||||
4. Client uses token in requests
|
||||
|
||||
**Header Format**:
|
||||
```
|
||||
Authorization: Bearer {access_token}
|
||||
```
|
||||
|
||||
## Rate Limiting
|
||||
|
||||
**Headers**:
|
||||
- `X-RateLimit-Limit`: 1000
|
||||
- `X-RateLimit-Remaining`: 999
|
||||
- `X-RateLimit-Reset`: 1634270400
|
||||
|
||||
**Response 429** (Too Many Requests):
|
||||
```json
|
||||
{
|
||||
"error": {
|
||||
"code": "RATE_LIMIT_EXCEEDED",
|
||||
"message": "API rate limit exceeded",
|
||||
"retry_after": 3600
|
||||
}
|
||||
}
|
||||
```
|
||||
```
|
||||
|
||||
## 🔄 **Session Integration**
|
||||
|
||||
### Status Synchronization
|
||||
Upon completion, update `workflow-session.json`:
|
||||
```json
|
||||
{
|
||||
"phases": {
|
||||
"BRAINSTORM": {
|
||||
"api_designer": {
|
||||
"status": "completed",
|
||||
"completed_at": "timestamp",
|
||||
"output_directory": ".workflow/active/WFS-{topic}/.brainstorming/api-designer/",
|
||||
"key_insights": ["endpoint_design", "versioning_strategy", "data_contracts"]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### Cross-Role Collaboration
|
||||
API designer perspective provides:
|
||||
- **API Contract Specifications** → Frontend Developer
|
||||
- **Data Schema Requirements** → Data Architect
|
||||
- **Security Requirements** → Security Expert
|
||||
- **Integration Endpoints** → System Architect
|
||||
- **Performance Constraints** → DevOps Engineer
|
||||
|
||||
## ✅ **Quality Assurance**
|
||||
|
||||
### Required Analysis Elements
|
||||
- [ ] Complete endpoint inventory with HTTP methods and paths
|
||||
- [ ] Detailed request/response schemas with validation rules
|
||||
- [ ] Clear versioning strategy and backward compatibility plan
|
||||
- [ ] Comprehensive error handling and status code usage
|
||||
- [ ] API documentation strategy (OpenAPI/Swagger)
|
||||
|
||||
### API Design Principles
|
||||
- [ ] **Consistency**: Uniform naming conventions and patterns across all endpoints
|
||||
- [ ] **Simplicity**: Intuitive resource modeling and URL structures
|
||||
- [ ] **Flexibility**: Support for filtering, sorting, pagination, and field selection
|
||||
- [ ] **Security**: Proper authentication, authorization, and input validation
|
||||
- [ ] **Performance**: Caching strategies, compression, and efficient data structures
|
||||
|
||||
### Developer Experience Validation
|
||||
- [ ] API is self-documenting with clear endpoint descriptions
|
||||
- [ ] Error messages are actionable and helpful for debugging
|
||||
- [ ] Response formats are consistent and predictable
|
||||
- [ ] Code examples and integration guides are provided
|
||||
- [ ] Sandbox environment available for testing
|
||||
|
||||
### Technical Completeness
|
||||
- [ ] **Resource Modeling**: All domain entities mapped to API resources
|
||||
- [ ] **CRUD Coverage**: Complete create, read, update, delete operations
|
||||
- [ ] **Query Capabilities**: Advanced filtering, sorting, and search functionality
|
||||
- [ ] **Versioning**: Clear version management and migration paths
|
||||
- [ ] **Monitoring**: API metrics, logging, and tracing strategies defined
|
||||
|
||||
### Integration Readiness
|
||||
- [ ] **Client Compatibility**: API works with all target client platforms
|
||||
- [ ] **External Integration**: Third-party API dependencies identified
|
||||
- [ ] **Backward Compatibility**: Changes don't break existing clients
|
||||
- [ ] **Migration Path**: Clear upgrade paths for API consumers
|
||||
- [ ] **SDK Support**: Client libraries and code generation considered
|
||||
@@ -1,10 +1,14 @@
|
||||
---
|
||||
name: artifacts
|
||||
description: Interactive clarification generating confirmed guidance specification through role-based analysis and synthesis
|
||||
argument-hint: "topic or challenge description [--count N]"
|
||||
argument-hint: "[-y|--yes] topic or challenge description [--count N]"
|
||||
allowed-tools: TodoWrite(*), Read(*), Write(*), Glob(*), AskUserQuestion(*)
|
||||
---
|
||||
|
||||
## Auto Mode
|
||||
|
||||
When `--yes` or `-y`: Auto-select recommended roles, skip all clarification questions, use default answers.
|
||||
|
||||
## Overview
|
||||
|
||||
Seven-phase workflow: **Context collection** → **Topic analysis** → **Role selection** → **Role questions** → **Conflict resolution** → **Final check** → **Generate specification**
|
||||
|
||||
@@ -1,19 +1,23 @@
|
||||
---
|
||||
name: auto-parallel
|
||||
description: Parallel brainstorming automation with dynamic role selection and concurrent execution across multiple perspectives
|
||||
argument-hint: "topic or challenge description" [--count N]
|
||||
allowed-tools: SlashCommand(*), Task(*), TodoWrite(*), Read(*), Write(*), Bash(*), Glob(*)
|
||||
argument-hint: "[-y|--yes] topic or challenge description [--count N]"
|
||||
allowed-tools: Skill(*), Task(*), TodoWrite(*), Read(*), Write(*), Bash(*), Glob(*)
|
||||
---
|
||||
|
||||
## Auto Mode
|
||||
|
||||
When `--yes` or `-y`: Auto-select recommended roles, skip all clarification questions, use default answers.
|
||||
|
||||
# Workflow Brainstorm Parallel Auto Command
|
||||
|
||||
## Coordinator Role
|
||||
|
||||
**This command is a pure orchestrator**: Dispatches 3 phases in sequence (interactive framework → parallel role analysis → synthesis), coordinating specialized commands/agents through task attachment model.
|
||||
**This command is a pure orchestrator**: Executes 3 phases in sequence (interactive framework → parallel role analysis → synthesis), coordinating specialized commands/agents through task attachment model.
|
||||
|
||||
**Task Attachment Model**:
|
||||
- SlashCommand dispatch **expands workflow** by attaching sub-tasks to current TodoWrite
|
||||
- Task agent dispatch **attaches analysis tasks** to orchestrator's TodoWrite
|
||||
- Skill execute **expands workflow** by attaching sub-tasks to current TodoWrite
|
||||
- Task agent execute **attaches analysis tasks** to orchestrator's TodoWrite
|
||||
- Phase 1: artifacts command attaches its internal tasks (Phase 1-5)
|
||||
- Phase 2: N conceptual-planning-agent tasks attached in parallel
|
||||
- Phase 3: synthesis command attaches its internal tasks
|
||||
@@ -26,9 +30,9 @@ allowed-tools: SlashCommand(*), Task(*), TodoWrite(*), Read(*), Write(*), Bash(*
|
||||
This workflow runs **fully autonomously** once triggered. Phase 1 (artifacts) handles user interaction, Phase 2 (role agents) runs in parallel.
|
||||
|
||||
1. **User triggers**: `/workflow:brainstorm:auto-parallel "topic" [--count N]`
|
||||
2. **Dispatch Phase 1** → artifacts command (tasks ATTACHED) → Auto-continues
|
||||
3. **Dispatch Phase 2** → Parallel role agents (N tasks ATTACHED concurrently) → Auto-continues
|
||||
4. **Dispatch Phase 3** → Synthesis command (tasks ATTACHED) → Reports final summary
|
||||
2. **Execute Phase 1** → artifacts command (tasks ATTACHED) → Auto-continues
|
||||
3. **Execute Phase 2** → Parallel role agents (N tasks ATTACHED concurrently) → Auto-continues
|
||||
4. **Execute Phase 3** → Synthesis command (tasks ATTACHED) → Reports final summary
|
||||
|
||||
**Auto-Continue Mechanism**:
|
||||
- TodoList tracks current phase status and dynamically manages task attachment/collapse
|
||||
@@ -38,13 +42,13 @@ This workflow runs **fully autonomously** once triggered. Phase 1 (artifacts) ha
|
||||
|
||||
## Core Rules
|
||||
|
||||
1. **Start Immediately**: First action is TodoWrite initialization, second action is dispatch Phase 1 command
|
||||
1. **Start Immediately**: First action is TodoWrite initialization, second action is execute Phase 1 command
|
||||
2. **No Preliminary Analysis**: Do not analyze topic before Phase 1 - artifacts handles all analysis
|
||||
3. **Parse Every Output**: Extract selected_roles from workflow-session.json after Phase 1
|
||||
4. **Auto-Continue via TodoList**: Check TodoList status to dispatch next pending phase automatically
|
||||
4. **Auto-Continue via TodoList**: Check TodoList status to execute next pending phase automatically
|
||||
5. **Track Progress**: Update TodoWrite dynamically with task attachment/collapse pattern
|
||||
6. **Task Attachment Model**: SlashCommand and Task dispatches **attach** sub-tasks to current workflow. Orchestrator **executes** these attached tasks itself, then **collapses** them after completion
|
||||
7. **⚠️ CRITICAL: DO NOT STOP**: Continuous multi-phase workflow. After executing all attached tasks, immediately collapse them and dispatch next phase
|
||||
6. **Task Attachment Model**: Skill and Task executes **attach** sub-tasks to current workflow. Orchestrator **executes** these attached tasks itself, then **collapses** them after completion
|
||||
7. **⚠️ CRITICAL: DO NOT STOP**: Continuous multi-phase workflow. After executing all attached tasks, immediately collapse them and execute next phase
|
||||
8. **Parallel Execution**: Phase 2 attaches multiple agent tasks simultaneously for concurrent execution
|
||||
|
||||
## Usage
|
||||
@@ -67,10 +71,10 @@ This workflow runs **fully autonomously** once triggered. Phase 1 (artifacts) ha
|
||||
|
||||
### Phase 1: Interactive Framework Generation
|
||||
|
||||
**Step 1: Dispatch** - Interactive framework generation via artifacts command
|
||||
**Step 1: Execute** - Interactive framework generation via artifacts command
|
||||
|
||||
```javascript
|
||||
SlashCommand(command="/workflow:brainstorm:artifacts \"{topic}\" --count {N}")
|
||||
Skill(skill="workflow:brainstorm:artifacts", args="\"{topic}\" --count {N}")
|
||||
```
|
||||
|
||||
**What It Does**:
|
||||
@@ -91,7 +95,7 @@ SlashCommand(command="/workflow:brainstorm:artifacts \"{topic}\" --count {N}")
|
||||
- workflow-session.json contains selected_roles[] (metadata only, no content duplication)
|
||||
- Session directory `.workflow/active/WFS-{topic}/.brainstorming/` exists
|
||||
|
||||
**TodoWrite Update (Phase 1 SlashCommand dispatched - tasks attached)**:
|
||||
**TodoWrite Update (Phase 1 Skill executed - tasks attached)**:
|
||||
```json
|
||||
[
|
||||
{"content": "Phase 0: Parameter Parsing", "status": "completed", "activeForm": "Parsing count parameter"},
|
||||
@@ -106,7 +110,7 @@ SlashCommand(command="/workflow:brainstorm:artifacts \"{topic}\" --count {N}")
|
||||
]
|
||||
```
|
||||
|
||||
**Note**: SlashCommand dispatch **attaches** artifacts' 5 internal tasks. Orchestrator **executes** these tasks sequentially.
|
||||
**Note**: Skill execute **attaches** artifacts' 5 internal tasks. Orchestrator **executes** these tasks sequentially.
|
||||
|
||||
**Next Action**: Tasks attached → **Execute Phase 1.1-1.5** sequentially
|
||||
|
||||
@@ -128,55 +132,30 @@ SlashCommand(command="/workflow:brainstorm:artifacts \"{topic}\" --count {N}")
|
||||
|
||||
### Phase 2: Parallel Role Analysis Execution
|
||||
|
||||
**For Each Selected Role**:
|
||||
**For Each Selected Role** (unified role-analysis command):
|
||||
```bash
|
||||
Task(conceptual-planning-agent): "
|
||||
[FLOW_CONTROL]
|
||||
|
||||
Execute {role-name} analysis for existing topic framework
|
||||
|
||||
## Context Loading
|
||||
ASSIGNED_ROLE: {role-name}
|
||||
OUTPUT_LOCATION: .workflow/active/WFS-{session}/.brainstorming/{role}/
|
||||
TOPIC: {user-provided-topic}
|
||||
|
||||
## Flow Control Steps
|
||||
1. load_topic_framework → .workflow/active/WFS-{session}/.brainstorming/guidance-specification.md
|
||||
2. load_role_template → ~/.claude/workflows/cli-templates/planning-roles/{role}.md
|
||||
3. load_session_metadata → .workflow/active/WFS-{session}/workflow-session.json
|
||||
4. load_style_skill (ui-designer only, if style_skill_package) → .claude/skills/style-{style_skill_package}/
|
||||
|
||||
## Analysis Requirements
|
||||
**Primary Reference**: Original user prompt from workflow-session.json is authoritative
|
||||
**Framework Source**: Address all discussion points in guidance-specification.md from {role-name} perspective
|
||||
**Role Focus**: {role-name} domain expertise aligned with user intent
|
||||
**Structured Approach**: Create analysis.md addressing framework discussion points
|
||||
**Template Integration**: Apply role template guidelines within framework structure
|
||||
|
||||
## Expected Deliverables
|
||||
1. **analysis.md** (optionally with analysis-{slug}.md sub-documents)
|
||||
2. **Framework Reference**: @../guidance-specification.md
|
||||
3. **User Intent Alignment**: Validate against session_context
|
||||
|
||||
## Completion Criteria
|
||||
- Address each discussion point from guidance-specification.md with {role-name} expertise
|
||||
- Provide actionable recommendations from {role-name} perspective within analysis files
|
||||
- All output files MUST start with `analysis` prefix (no recommendations.md or other naming)
|
||||
- Reference framework document using @ notation for integration
|
||||
- Update workflow-session.json with completion status
|
||||
"
|
||||
Skill(skill="workflow:brainstorm:role-analysis", args="{role-name} --session {session-id} --skip-questions")
|
||||
```
|
||||
|
||||
**Parallel Dispatch**:
|
||||
- Launch N agents simultaneously (one message with multiple Task calls)
|
||||
- Each agent task **attached** to orchestrator's TodoWrite
|
||||
- All agents execute concurrently, each attaching their own analysis sub-tasks
|
||||
- Each agent operates independently reading same guidance-specification.md
|
||||
**What It Does**:
|
||||
- Unified command execution for each role
|
||||
- Loads topic framework from guidance-specification.md
|
||||
- Applies role-specific template and context
|
||||
- Generates analysis.md addressing framework discussion points
|
||||
- Supports optional interactive context gathering (via --include-questions flag)
|
||||
|
||||
**Parallel Execution**:
|
||||
- Launch N Skill calls simultaneously (one message with multiple Skill invokes)
|
||||
- Each role command **attached** to orchestrator's TodoWrite
|
||||
- All roles execute concurrently, each reading same guidance-specification.md
|
||||
- Each role operates independently
|
||||
- For ui-designer only: append `--style-skill {style_skill_package}` if provided
|
||||
|
||||
**Input**:
|
||||
- `selected_roles[]` from Phase 1
|
||||
- `session_id` from Phase 1
|
||||
- guidance-specification.md path
|
||||
- `guidance-specification.md` (framework reference)
|
||||
- `style_skill_package` (for ui-designer only)
|
||||
|
||||
**Validation**:
|
||||
- Each role creates `.workflow/active/WFS-{topic}/.brainstorming/{role}/analysis.md`
|
||||
@@ -185,7 +164,8 @@ TOPIC: {user-provided-topic}
|
||||
- **FORBIDDEN**: `recommendations.md` or any non-`analysis` prefixed files
|
||||
- All N role analyses completed
|
||||
|
||||
**TodoWrite Update (Phase 2 agents dispatched - tasks attached in parallel)**:
|
||||
|
||||
**TodoWrite Update (Phase 2 agents executed - tasks attached in parallel)**:
|
||||
```json
|
||||
[
|
||||
{"content": "Phase 0: Parameter Parsing", "status": "completed", "activeForm": "Parsing count parameter"},
|
||||
@@ -198,7 +178,7 @@ TOPIC: {user-provided-topic}
|
||||
]
|
||||
```
|
||||
|
||||
**Note**: Multiple Task dispatches **attach** N role analysis tasks simultaneously. Orchestrator **executes** these tasks in parallel.
|
||||
**Note**: Multiple Task executes **attach** N role analysis tasks simultaneously. Orchestrator **executes** these tasks in parallel.
|
||||
|
||||
**Next Action**: Tasks attached → **Execute Phase 2.1-2.N** concurrently
|
||||
|
||||
@@ -220,10 +200,10 @@ TOPIC: {user-provided-topic}
|
||||
|
||||
### Phase 3: Synthesis Generation
|
||||
|
||||
**Step 3: Dispatch** - Synthesis integration via synthesis command
|
||||
**Step 3: Execute** - Synthesis integration via synthesis command
|
||||
|
||||
```javascript
|
||||
SlashCommand(command="/workflow:brainstorm:synthesis --session {sessionId}")
|
||||
Skill(skill="workflow:brainstorm:synthesis", args="--session {sessionId}")
|
||||
```
|
||||
|
||||
**What It Does**:
|
||||
@@ -238,7 +218,7 @@ SlashCommand(command="/workflow:brainstorm:synthesis --session {sessionId}")
|
||||
- `.workflow/active/WFS-{topic}/.brainstorming/synthesis-specification.md` exists
|
||||
- Synthesis references all role analyses
|
||||
|
||||
**TodoWrite Update (Phase 3 SlashCommand dispatched - tasks attached)**:
|
||||
**TodoWrite Update (Phase 3 Skill executed - tasks attached)**:
|
||||
```json
|
||||
[
|
||||
{"content": "Phase 0: Parameter Parsing", "status": "completed", "activeForm": "Parsing count parameter"},
|
||||
@@ -251,7 +231,7 @@ SlashCommand(command="/workflow:brainstorm:synthesis --session {sessionId}")
|
||||
]
|
||||
```
|
||||
|
||||
**Note**: SlashCommand dispatch **attaches** synthesis' internal tasks. Orchestrator **executes** these tasks sequentially.
|
||||
**Note**: Skill execute **attaches** synthesis' internal tasks. Orchestrator **executes** these tasks sequentially.
|
||||
|
||||
**Next Action**: Tasks attached → **Execute Phase 3.1-3.3** sequentially
|
||||
|
||||
@@ -284,7 +264,7 @@ Synthesis: .workflow/active/WFS-{topic}/.brainstorming/synthesis-specification.m
|
||||
|
||||
### Key Principles
|
||||
|
||||
1. **Task Attachment** (when SlashCommand/Task dispatched):
|
||||
1. **Task Attachment** (when Skill/Task executed):
|
||||
- Sub-command's or agent's internal tasks are **attached** to orchestrator's TodoWrite
|
||||
- Phase 1: `/workflow:brainstorm:artifacts` attaches 5 internal tasks (Phase 1.1-1.5)
|
||||
- Phase 2: Multiple `Task(conceptual-planning-agent)` calls attach N role analysis tasks simultaneously
|
||||
@@ -305,13 +285,13 @@ Synthesis: .workflow/active/WFS-{topic}/.brainstorming/synthesis-specification.m
|
||||
- No user intervention required between phases
|
||||
- TodoWrite dynamically reflects current execution state
|
||||
|
||||
**Lifecycle Summary**: Initial pending tasks → Phase 1 dispatched (artifacts tasks ATTACHED) → Artifacts sub-tasks executed → Phase 1 completed (tasks COLLAPSED) → Phase 2 dispatched (N role tasks ATTACHED in parallel) → Role analyses executed concurrently → Phase 2 completed (tasks COLLAPSED) → Phase 3 dispatched (synthesis tasks ATTACHED) → Synthesis sub-tasks executed → Phase 3 completed (tasks COLLAPSED) → Workflow complete.
|
||||
**Lifecycle Summary**: Initial pending tasks → Phase 1 executed (artifacts tasks ATTACHED) → Artifacts sub-tasks executed → Phase 1 completed (tasks COLLAPSED) → Phase 2 executed (N role tasks ATTACHED in parallel) → Role analyses executed concurrently → Phase 2 completed (tasks COLLAPSED) → Phase 3 executed (synthesis tasks ATTACHED) → Synthesis sub-tasks executed → Phase 3 completed (tasks COLLAPSED) → Workflow complete.
|
||||
|
||||
### Brainstorming Workflow Specific Features
|
||||
|
||||
- **Phase 1**: Interactive framework generation with user Q&A (SlashCommand attachment)
|
||||
- **Phase 1**: Interactive framework generation with user Q&A (Skill attachment)
|
||||
- **Phase 2**: Parallel role analysis execution with N concurrent agents (Task agent attachments)
|
||||
- **Phase 3**: Cross-role synthesis integration (SlashCommand attachment)
|
||||
- **Phase 3**: Cross-role synthesis integration (Skill attachment)
|
||||
- **Dynamic Role Count**: `--count N` parameter determines number of Phase 2 parallel tasks (default: 3, max: 9)
|
||||
- **Mixed Execution**: Sequential (Phase 1, 3) and Parallel (Phase 2) task execution
|
||||
|
||||
@@ -424,6 +404,17 @@ CONTEXT_VARS:
|
||||
- **Agent execution failure**: Agent-specific retry with minimal dependencies
|
||||
- **Template loading issues**: Agent handles graceful degradation
|
||||
- **Synthesis conflicts**: Synthesis highlights disagreements without resolution
|
||||
- **Context overflow protection**: See below for automatic context management
|
||||
|
||||
## Context Overflow Protection
|
||||
|
||||
**Per-role limits**: See `conceptual-planning-agent.md` (< 3000 words main, < 2000 words sub-docs, max 5 sub-docs)
|
||||
|
||||
**Synthesis protection**: If total analysis > 100KB, synthesis reads only `analysis.md` files (not sub-documents)
|
||||
|
||||
**Recovery**: Check logs → reduce scope (--count 2) → use --summary-only → manual synthesis
|
||||
|
||||
**Prevention**: Start with --count 3, use structured topic format, review output sizes before synthesis
|
||||
|
||||
## Reference Information
|
||||
|
||||
@@ -440,4 +431,3 @@ CONTEXT_VARS:
|
||||
```
|
||||
|
||||
**Template Source**: `~/.claude/workflows/cli-templates/planning-roles/`
|
||||
|
||||
|
||||
@@ -1,220 +0,0 @@
|
||||
---
|
||||
name: data-architect
|
||||
description: Generate or update data-architect/analysis.md addressing guidance-specification discussion points for data architecture perspective
|
||||
argument-hint: "optional topic - uses existing framework if available"
|
||||
allowed-tools: Task(conceptual-planning-agent), TodoWrite(*), Read(*), Write(*)
|
||||
---
|
||||
|
||||
## 📊 **Data Architect Analysis Generator**
|
||||
|
||||
### Purpose
|
||||
**Specialized command for generating data-architect/analysis.md** that addresses guidance-specification.md discussion points from data architecture perspective. Creates or updates role-specific analysis with framework references.
|
||||
|
||||
### Core Function
|
||||
- **Framework-based Analysis**: Address each discussion point in guidance-specification.md
|
||||
- **Data Architecture Focus**: Data models, pipelines, governance, and analytics perspective
|
||||
- **Update Mechanism**: Create new or update existing analysis.md
|
||||
- **Agent Delegation**: Use conceptual-planning-agent for analysis generation
|
||||
|
||||
### Analysis Scope
|
||||
- **Data Model Design**: Efficient and scalable data models and schemas
|
||||
- **Data Flow Design**: Data collection, processing, and storage workflows
|
||||
- **Data Quality Management**: Data accuracy, completeness, and consistency
|
||||
- **Analytics and Insights**: Data analysis and business intelligence solutions
|
||||
|
||||
### Role Boundaries & Responsibilities
|
||||
|
||||
#### **What This Role OWNS (Canonical Data Model - Source of Truth)**
|
||||
- **Canonical Data Model**: The authoritative, system-wide data schema representing domain entities and relationships
|
||||
- **Entity-Relationship Design**: Defining entities, attributes, relationships, and constraints
|
||||
- **Data Normalization & Optimization**: Ensuring data integrity, reducing redundancy, and optimizing storage
|
||||
- **Database Schema Design**: Physical database structures, indexes, partitioning strategies
|
||||
- **Data Pipeline Architecture**: ETL/ELT processes, data warehousing, and analytics pipelines
|
||||
- **Data Governance**: Data quality standards, retention policies, and compliance requirements
|
||||
|
||||
#### **What This Role DOES NOT Own (Defers to Other Roles)**
|
||||
- **API Data Contracts**: Public-facing request/response schemas exposed by APIs → Defers to **API Designer**
|
||||
- **System Integration Patterns**: How services communicate at the macro level → Defers to **System Architect**
|
||||
- **UI Data Presentation**: How data is displayed to users → Defers to **UI Designer**
|
||||
|
||||
#### **Handoff Points**
|
||||
- **TO API Designer**: Provides canonical data model that API Designer translates into public API data contracts (as projection/view)
|
||||
- **TO System Architect**: Provides data flow requirements and storage constraints to inform system design
|
||||
- **FROM System Architect**: Receives system-level integration requirements and scalability constraints
|
||||
|
||||
## ⚙️ **Execution Protocol**
|
||||
|
||||
### Phase 1: Session & Framework Detection
|
||||
```bash
|
||||
# Check active session and framework
|
||||
CHECK: find .workflow/active/ -name "WFS-*" -type d
|
||||
IF active_session EXISTS:
|
||||
session_id = get_active_session()
|
||||
brainstorm_dir = .workflow/active/WFS-{session}/.brainstorming/
|
||||
|
||||
CHECK: brainstorm_dir/guidance-specification.md
|
||||
IF EXISTS:
|
||||
framework_mode = true
|
||||
load_framework = true
|
||||
ELSE:
|
||||
IF topic_provided:
|
||||
framework_mode = false # Create analysis without framework
|
||||
ELSE:
|
||||
ERROR: "No framework found and no topic provided"
|
||||
```
|
||||
|
||||
### Phase 2: Analysis Mode Detection
|
||||
```bash
|
||||
# Determine execution mode
|
||||
IF framework_mode == true:
|
||||
mode = "framework_based_analysis"
|
||||
topic_ref = load_framework_topic()
|
||||
discussion_points = extract_framework_points()
|
||||
ELSE:
|
||||
mode = "standalone_analysis"
|
||||
topic_ref = provided_topic
|
||||
discussion_points = generate_basic_structure()
|
||||
```
|
||||
|
||||
### Phase 3: Agent Execution with Flow Control
|
||||
**Framework-Based Analysis Generation**
|
||||
|
||||
```bash
|
||||
Task(conceptual-planning-agent): "
|
||||
[FLOW_CONTROL]
|
||||
|
||||
Execute data-architect analysis for existing topic framework
|
||||
|
||||
## Context Loading
|
||||
ASSIGNED_ROLE: data-architect
|
||||
OUTPUT_LOCATION: .workflow/active/WFS-{session}/.brainstorming/data-architect/
|
||||
ANALYSIS_MODE: {framework_mode ? "framework_based" : "standalone"}
|
||||
|
||||
## Flow Control Steps
|
||||
1. **load_topic_framework**
|
||||
- Action: Load structured topic discussion framework
|
||||
- Command: Read(.workflow/active/WFS-{session}/.brainstorming/guidance-specification.md)
|
||||
- Output: topic_framework_content
|
||||
|
||||
2. **load_role_template**
|
||||
- Action: Load data-architect planning template
|
||||
- Command: bash($(cat ~/.claude/workflows/cli-templates/planning-roles/data-architect.md))
|
||||
- Output: role_template_guidelines
|
||||
|
||||
3. **load_session_metadata**
|
||||
- Action: Load session metadata and existing context
|
||||
- Command: Read(.workflow/active/WFS-{session}/workflow-session.json)
|
||||
- Output: session_context
|
||||
|
||||
## Analysis Requirements
|
||||
**Framework Reference**: Address all discussion points in guidance-specification.md from data architecture perspective
|
||||
**Role Focus**: Data models, pipelines, governance, analytics platforms
|
||||
**Structured Approach**: Create analysis.md addressing framework discussion points
|
||||
**Template Integration**: Apply role template guidelines within framework structure
|
||||
|
||||
## Expected Deliverables
|
||||
1. **analysis.md**: Comprehensive data architecture analysis addressing all framework discussion points
|
||||
2. **Framework Reference**: Include @../guidance-specification.md reference in analysis
|
||||
|
||||
## Completion Criteria
|
||||
- Address each discussion point from guidance-specification.md with data architecture expertise
|
||||
- Provide data model designs, pipeline architectures, and governance strategies
|
||||
- Include scalability, performance, and quality considerations
|
||||
- Reference framework document using @ notation for integration
|
||||
"
|
||||
```
|
||||
|
||||
## 📋 **TodoWrite Integration**
|
||||
|
||||
### Workflow Progress Tracking
|
||||
```javascript
|
||||
TodoWrite({
|
||||
todos: [
|
||||
{
|
||||
content: "Detect active session and locate topic framework",
|
||||
status: "in_progress",
|
||||
activeForm: "Detecting session and framework"
|
||||
},
|
||||
{
|
||||
content: "Load guidance-specification.md and session metadata for context",
|
||||
status: "pending",
|
||||
activeForm: "Loading framework and session context"
|
||||
},
|
||||
{
|
||||
content: "Execute data-architect analysis using conceptual-planning-agent with FLOW_CONTROL",
|
||||
status: "pending",
|
||||
activeForm: "Executing data-architect framework analysis"
|
||||
},
|
||||
{
|
||||
content: "Generate analysis.md addressing all framework discussion points",
|
||||
status: "pending",
|
||||
activeForm: "Generating structured data-architect analysis"
|
||||
},
|
||||
{
|
||||
content: "Update workflow-session.json with data-architect completion status",
|
||||
status: "pending",
|
||||
activeForm: "Updating session metadata"
|
||||
}
|
||||
]
|
||||
});
|
||||
```
|
||||
|
||||
## 📊 **Output Structure**
|
||||
|
||||
### Framework-Based Analysis
|
||||
```
|
||||
.workflow/active/WFS-{session}/.brainstorming/data-architect/
|
||||
└── analysis.md # Structured analysis addressing guidance-specification.md discussion points
|
||||
```
|
||||
|
||||
### Analysis Document Structure
|
||||
```markdown
|
||||
# Data Architect Analysis: [Topic from Framework]
|
||||
|
||||
## Framework Reference
|
||||
**Topic Framework**: @../guidance-specification.md
|
||||
**Role Focus**: Data Architecture perspective
|
||||
|
||||
## Discussion Points Analysis
|
||||
[Address each point from guidance-specification.md with data architecture expertise]
|
||||
|
||||
### Core Requirements (from framework)
|
||||
[Data architecture perspective on requirements]
|
||||
|
||||
### Technical Considerations (from framework)
|
||||
[Data model, pipeline, and storage considerations]
|
||||
|
||||
### User Experience Factors (from framework)
|
||||
[Data access patterns and analytics user experience]
|
||||
|
||||
### Implementation Challenges (from framework)
|
||||
[Data migration, quality, and governance challenges]
|
||||
|
||||
### Success Metrics (from framework)
|
||||
[Data quality metrics and analytics success criteria]
|
||||
|
||||
## Data Architecture Specific Recommendations
|
||||
[Role-specific data architecture recommendations and solutions]
|
||||
|
||||
---
|
||||
*Generated by data-architect analysis addressing structured framework*
|
||||
```
|
||||
|
||||
## 🔄 **Session Integration**
|
||||
|
||||
### Completion Status Update
|
||||
```json
|
||||
{
|
||||
"data_architect": {
|
||||
"status": "completed",
|
||||
"framework_addressed": true,
|
||||
"output_location": ".workflow/active/WFS-{session}/.brainstorming/data-architect/analysis.md",
|
||||
"framework_reference": "@../guidance-specification.md"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### Integration Points
|
||||
- **Framework Reference**: @../guidance-specification.md for structured discussion points
|
||||
- **Cross-Role Synthesis**: Data architecture insights available for synthesis-report.md integration
|
||||
- **Agent Autonomy**: Independent execution with framework guidance
|
||||
@@ -1,200 +0,0 @@
|
||||
---
|
||||
name: product-manager
|
||||
description: Generate or update product-manager/analysis.md addressing guidance-specification discussion points for product management perspective
|
||||
argument-hint: "optional topic - uses existing framework if available"
|
||||
allowed-tools: Task(conceptual-planning-agent), TodoWrite(*), Read(*), Write(*)
|
||||
---
|
||||
|
||||
## 🎯 **Product Manager Analysis Generator**
|
||||
|
||||
### Purpose
|
||||
**Specialized command for generating product-manager/analysis.md** that addresses guidance-specification.md discussion points from product strategy perspective. Creates or updates role-specific analysis with framework references.
|
||||
|
||||
### Core Function
|
||||
- **Framework-based Analysis**: Address each discussion point in guidance-specification.md
|
||||
- **Product Strategy Focus**: User needs, business value, and market positioning
|
||||
- **Update Mechanism**: Create new or update existing analysis.md
|
||||
- **Agent Delegation**: Use conceptual-planning-agent for analysis generation
|
||||
|
||||
### Analysis Scope
|
||||
- **User Needs Analysis**: Target users, problems, and value propositions
|
||||
- **Business Impact Assessment**: ROI, metrics, and commercial outcomes
|
||||
- **Market Positioning**: Competitive analysis and differentiation
|
||||
- **Product Strategy**: Roadmaps, priorities, and go-to-market approaches
|
||||
|
||||
## ⚙️ **Execution Protocol**
|
||||
|
||||
### Phase 1: Session & Framework Detection
|
||||
```bash
|
||||
# Check active session and framework
|
||||
CHECK: find .workflow/active/ -name "WFS-*" -type d
|
||||
IF active_session EXISTS:
|
||||
session_id = get_active_session()
|
||||
brainstorm_dir = .workflow/active/WFS-{session}/.brainstorming/
|
||||
|
||||
CHECK: brainstorm_dir/guidance-specification.md
|
||||
IF EXISTS:
|
||||
framework_mode = true
|
||||
load_framework = true
|
||||
ELSE:
|
||||
IF topic_provided:
|
||||
framework_mode = false # Create analysis without framework
|
||||
ELSE:
|
||||
ERROR: "No framework found and no topic provided"
|
||||
```
|
||||
|
||||
### Phase 2: Analysis Mode Detection
|
||||
```bash
|
||||
# Determine execution mode
|
||||
IF framework_mode == true:
|
||||
mode = "framework_based_analysis"
|
||||
topic_ref = load_framework_topic()
|
||||
discussion_points = extract_framework_points()
|
||||
ELSE:
|
||||
mode = "standalone_analysis"
|
||||
topic_ref = provided_topic
|
||||
discussion_points = generate_basic_structure()
|
||||
```
|
||||
|
||||
### Phase 3: Agent Execution with Flow Control
|
||||
**Framework-Based Analysis Generation**
|
||||
|
||||
```bash
|
||||
Task(conceptual-planning-agent): "
|
||||
[FLOW_CONTROL]
|
||||
|
||||
Execute product-manager analysis for existing topic framework
|
||||
|
||||
## Context Loading
|
||||
ASSIGNED_ROLE: product-manager
|
||||
OUTPUT_LOCATION: .workflow/active/WFS-{session}/.brainstorming/product-manager/
|
||||
ANALYSIS_MODE: {framework_mode ? "framework_based" : "standalone"}
|
||||
|
||||
## Flow Control Steps
|
||||
1. **load_topic_framework**
|
||||
- Action: Load structured topic discussion framework
|
||||
- Command: Read(.workflow/active/WFS-{session}/.brainstorming/guidance-specification.md)
|
||||
- Output: topic_framework_content
|
||||
|
||||
2. **load_role_template**
|
||||
- Action: Load product-manager planning template
|
||||
- Command: bash($(cat ~/.claude/workflows/cli-templates/planning-roles/product-manager.md))
|
||||
- Output: role_template_guidelines
|
||||
|
||||
3. **load_session_metadata**
|
||||
- Action: Load session metadata and existing context
|
||||
- Command: Read(.workflow/active/WFS-{session}/workflow-session.json)
|
||||
- Output: session_context
|
||||
|
||||
## Analysis Requirements
|
||||
**Framework Reference**: Address all discussion points in guidance-specification.md from product strategy perspective
|
||||
**Role Focus**: User value, business impact, market positioning, product strategy
|
||||
**Structured Approach**: Create analysis.md addressing framework discussion points
|
||||
**Template Integration**: Apply role template guidelines within framework structure
|
||||
|
||||
## Expected Deliverables
|
||||
1. **analysis.md**: Comprehensive product strategy analysis addressing all framework discussion points
|
||||
2. **Framework Reference**: Include @../guidance-specification.md reference in analysis
|
||||
|
||||
## Completion Criteria
|
||||
- Address each discussion point from guidance-specification.md with product management expertise
|
||||
- Provide actionable business strategies and user value propositions
|
||||
- Include market analysis and competitive positioning insights
|
||||
- Reference framework document using @ notation for integration
|
||||
"
|
||||
```
|
||||
|
||||
## 📋 **TodoWrite Integration**
|
||||
|
||||
### Workflow Progress Tracking
|
||||
```javascript
|
||||
TodoWrite({
|
||||
todos: [
|
||||
{
|
||||
content: "Detect active session and locate topic framework",
|
||||
status: "in_progress",
|
||||
activeForm: "Detecting session and framework"
|
||||
},
|
||||
{
|
||||
content: "Load guidance-specification.md and session metadata for context",
|
||||
status: "pending",
|
||||
activeForm: "Loading framework and session context"
|
||||
},
|
||||
{
|
||||
content: "Execute product-manager analysis using conceptual-planning-agent with FLOW_CONTROL",
|
||||
status: "pending",
|
||||
activeForm: "Executing product-manager framework analysis"
|
||||
},
|
||||
{
|
||||
content: "Generate analysis.md addressing all framework discussion points",
|
||||
status: "pending",
|
||||
activeForm: "Generating structured product-manager analysis"
|
||||
},
|
||||
{
|
||||
content: "Update workflow-session.json with product-manager completion status",
|
||||
status: "pending",
|
||||
activeForm: "Updating session metadata"
|
||||
}
|
||||
]
|
||||
});
|
||||
```
|
||||
|
||||
## 📊 **Output Structure**
|
||||
|
||||
### Framework-Based Analysis
|
||||
```
|
||||
.workflow/active/WFS-{session}/.brainstorming/product-manager/
|
||||
└── analysis.md # Structured analysis addressing guidance-specification.md discussion points
|
||||
```
|
||||
|
||||
### Analysis Document Structure
|
||||
```markdown
|
||||
# Product Manager Analysis: [Topic from Framework]
|
||||
|
||||
## Framework Reference
|
||||
**Topic Framework**: @../guidance-specification.md
|
||||
**Role Focus**: Product Strategy perspective
|
||||
|
||||
## Discussion Points Analysis
|
||||
[Address each point from guidance-specification.md with product management expertise]
|
||||
|
||||
### Core Requirements (from framework)
|
||||
[Product strategy perspective on user needs and requirements]
|
||||
|
||||
### Technical Considerations (from framework)
|
||||
[Business and technical feasibility considerations]
|
||||
|
||||
### User Experience Factors (from framework)
|
||||
[User value proposition and market positioning analysis]
|
||||
|
||||
### Implementation Challenges (from framework)
|
||||
[Business execution and go-to-market considerations]
|
||||
|
||||
### Success Metrics (from framework)
|
||||
[Product success metrics and business KPIs]
|
||||
|
||||
## Product Strategy Specific Recommendations
|
||||
[Role-specific product management strategies and business solutions]
|
||||
|
||||
---
|
||||
*Generated by product-manager analysis addressing structured framework*
|
||||
```
|
||||
|
||||
## 🔄 **Session Integration**
|
||||
|
||||
### Completion Status Update
|
||||
```json
|
||||
{
|
||||
"product_manager": {
|
||||
"status": "completed",
|
||||
"framework_addressed": true,
|
||||
"output_location": ".workflow/active/WFS-{session}/.brainstorming/product-manager/analysis.md",
|
||||
"framework_reference": "@../guidance-specification.md"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### Integration Points
|
||||
- **Framework Reference**: @../guidance-specification.md for structured discussion points
|
||||
- **Cross-Role Synthesis**: Product strategy insights available for synthesis-report.md integration
|
||||
- **Agent Autonomy**: Independent execution with framework guidance
|
||||
@@ -1,200 +0,0 @@
|
||||
---
|
||||
name: product-owner
|
||||
description: Generate or update product-owner/analysis.md addressing guidance-specification discussion points for product ownership perspective
|
||||
argument-hint: "optional topic - uses existing framework if available"
|
||||
allowed-tools: Task(conceptual-planning-agent), TodoWrite(*), Read(*), Write(*)
|
||||
---
|
||||
|
||||
## 🎯 **Product Owner Analysis Generator**
|
||||
|
||||
### Purpose
|
||||
**Specialized command for generating product-owner/analysis.md** that addresses guidance-specification.md discussion points from product backlog and feature prioritization perspective. Creates or updates role-specific analysis with framework references.
|
||||
|
||||
### Core Function
|
||||
- **Framework-based Analysis**: Address each discussion point in guidance-specification.md
|
||||
- **Product Backlog Focus**: Feature prioritization, user stories, and acceptance criteria
|
||||
- **Update Mechanism**: Create new or update existing analysis.md
|
||||
- **Agent Delegation**: Use conceptual-planning-agent for analysis generation
|
||||
|
||||
### Analysis Scope
|
||||
- **Backlog Management**: User story creation, refinement, and prioritization
|
||||
- **Stakeholder Alignment**: Requirements gathering, value definition, and expectation management
|
||||
- **Feature Prioritization**: ROI analysis, MoSCoW method, and value-driven delivery
|
||||
- **Acceptance Criteria**: Definition of Done, acceptance testing, and quality standards
|
||||
|
||||
## ⚙️ **Execution Protocol**
|
||||
|
||||
### Phase 1: Session & Framework Detection
|
||||
```bash
|
||||
# Check active session and framework
|
||||
CHECK: find .workflow/active/ -name "WFS-*" -type d
|
||||
IF active_session EXISTS:
|
||||
session_id = get_active_session()
|
||||
brainstorm_dir = .workflow/active/WFS-{session}/.brainstorming/
|
||||
|
||||
CHECK: brainstorm_dir/guidance-specification.md
|
||||
IF EXISTS:
|
||||
framework_mode = true
|
||||
load_framework = true
|
||||
ELSE:
|
||||
IF topic_provided:
|
||||
framework_mode = false # Create analysis without framework
|
||||
ELSE:
|
||||
ERROR: "No framework found and no topic provided"
|
||||
```
|
||||
|
||||
### Phase 2: Analysis Mode Detection
|
||||
```bash
|
||||
# Determine execution mode
|
||||
IF framework_mode == true:
|
||||
mode = "framework_based_analysis"
|
||||
topic_ref = load_framework_topic()
|
||||
discussion_points = extract_framework_points()
|
||||
ELSE:
|
||||
mode = "standalone_analysis"
|
||||
topic_ref = provided_topic
|
||||
discussion_points = generate_basic_structure()
|
||||
```
|
||||
|
||||
### Phase 3: Agent Execution with Flow Control
|
||||
**Framework-Based Analysis Generation**
|
||||
|
||||
```bash
|
||||
Task(conceptual-planning-agent): "
|
||||
[FLOW_CONTROL]
|
||||
|
||||
Execute product-owner analysis for existing topic framework
|
||||
|
||||
## Context Loading
|
||||
ASSIGNED_ROLE: product-owner
|
||||
OUTPUT_LOCATION: .workflow/active/WFS-{session}/.brainstorming/product-owner/
|
||||
ANALYSIS_MODE: {framework_mode ? "framework_based" : "standalone"}
|
||||
|
||||
## Flow Control Steps
|
||||
1. **load_topic_framework**
|
||||
- Action: Load structured topic discussion framework
|
||||
- Command: Read(.workflow/active/WFS-{session}/.brainstorming/guidance-specification.md)
|
||||
- Output: topic_framework_content
|
||||
|
||||
2. **load_role_template**
|
||||
- Action: Load product-owner planning template
|
||||
- Command: bash($(cat ~/.claude/workflows/cli-templates/planning-roles/product-owner.md))
|
||||
- Output: role_template_guidelines
|
||||
|
||||
3. **load_session_metadata**
|
||||
- Action: Load session metadata and existing context
|
||||
- Command: Read(.workflow/active/WFS-{session}/workflow-session.json)
|
||||
- Output: session_context
|
||||
|
||||
## Analysis Requirements
|
||||
**Framework Reference**: Address all discussion points in guidance-specification.md from product backlog and feature prioritization perspective
|
||||
**Role Focus**: Backlog management, stakeholder alignment, feature prioritization, acceptance criteria
|
||||
**Structured Approach**: Create analysis.md addressing framework discussion points
|
||||
**Template Integration**: Apply role template guidelines within framework structure
|
||||
|
||||
## Expected Deliverables
|
||||
1. **analysis.md**: Comprehensive product ownership analysis addressing all framework discussion points
|
||||
2. **Framework Reference**: Include @../guidance-specification.md reference in analysis
|
||||
|
||||
## Completion Criteria
|
||||
- Address each discussion point from guidance-specification.md with product ownership expertise
|
||||
- Provide actionable user stories and acceptance criteria definitions
|
||||
- Include feature prioritization and stakeholder alignment strategies
|
||||
- Reference framework document using @ notation for integration
|
||||
"
|
||||
```
|
||||
|
||||
## 📋 **TodoWrite Integration**
|
||||
|
||||
### Workflow Progress Tracking
|
||||
```javascript
|
||||
TodoWrite({
|
||||
todos: [
|
||||
{
|
||||
content: "Detect active session and locate topic framework",
|
||||
status: "in_progress",
|
||||
activeForm: "Detecting session and framework"
|
||||
},
|
||||
{
|
||||
content: "Load guidance-specification.md and session metadata for context",
|
||||
status: "pending",
|
||||
activeForm: "Loading framework and session context"
|
||||
},
|
||||
{
|
||||
content: "Execute product-owner analysis using conceptual-planning-agent with FLOW_CONTROL",
|
||||
status: "pending",
|
||||
activeForm: "Executing product-owner framework analysis"
|
||||
},
|
||||
{
|
||||
content: "Generate analysis.md addressing all framework discussion points",
|
||||
status: "pending",
|
||||
activeForm: "Generating structured product-owner analysis"
|
||||
},
|
||||
{
|
||||
content: "Update workflow-session.json with product-owner completion status",
|
||||
status: "pending",
|
||||
activeForm: "Updating session metadata"
|
||||
}
|
||||
]
|
||||
});
|
||||
```
|
||||
|
||||
## 📊 **Output Structure**
|
||||
|
||||
### Framework-Based Analysis
|
||||
```
|
||||
.workflow/active/WFS-{session}/.brainstorming/product-owner/
|
||||
└── analysis.md # Structured analysis addressing guidance-specification.md discussion points
|
||||
```
|
||||
|
||||
### Analysis Document Structure
|
||||
```markdown
|
||||
# Product Owner Analysis: [Topic from Framework]
|
||||
|
||||
## Framework Reference
|
||||
**Topic Framework**: @../guidance-specification.md
|
||||
**Role Focus**: Product Backlog & Feature Prioritization perspective
|
||||
|
||||
## Discussion Points Analysis
|
||||
[Address each point from guidance-specification.md with product ownership expertise]
|
||||
|
||||
### Core Requirements (from framework)
|
||||
[User story formulation and backlog refinement perspective]
|
||||
|
||||
### Technical Considerations (from framework)
|
||||
[Technical feasibility and implementation sequencing considerations]
|
||||
|
||||
### User Experience Factors (from framework)
|
||||
[User value definition and acceptance criteria analysis]
|
||||
|
||||
### Implementation Challenges (from framework)
|
||||
[Sprint planning, dependency management, and delivery strategies]
|
||||
|
||||
### Success Metrics (from framework)
|
||||
[Feature adoption, value delivery metrics, and stakeholder satisfaction indicators]
|
||||
|
||||
## Product Owner Specific Recommendations
|
||||
[Role-specific backlog management and feature prioritization strategies]
|
||||
|
||||
---
|
||||
*Generated by product-owner analysis addressing structured framework*
|
||||
```
|
||||
|
||||
## 🔄 **Session Integration**
|
||||
|
||||
### Completion Status Update
|
||||
```json
|
||||
{
|
||||
"product_owner": {
|
||||
"status": "completed",
|
||||
"framework_addressed": true,
|
||||
"output_location": ".workflow/active/WFS-{session}/.brainstorming/product-owner/analysis.md",
|
||||
"framework_reference": "@../guidance-specification.md"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### Integration Points
|
||||
- **Framework Reference**: @../guidance-specification.md for structured discussion points
|
||||
- **Cross-Role Synthesis**: Product ownership insights available for synthesis-report.md integration
|
||||
- **Agent Autonomy**: Independent execution with framework guidance
|
||||
705
.claude/commands/workflow/brainstorm/role-analysis.md
Normal file
705
.claude/commands/workflow/brainstorm/role-analysis.md
Normal file
@@ -0,0 +1,705 @@
|
||||
---
|
||||
name: role-analysis
|
||||
description: Unified role-specific analysis generation with interactive context gathering and incremental updates
|
||||
argument-hint: "[role-name] [--session session-id] [--update] [--include-questions] [--skip-questions]"
|
||||
allowed-tools: Task(conceptual-planning-agent), AskUserQuestion(*), TodoWrite(*), Read(*), Write(*), Edit(*), Glob(*)
|
||||
---
|
||||
|
||||
## 🎯 **Unified Role Analysis Generator**
|
||||
|
||||
### Purpose
|
||||
**Unified command for generating and updating role-specific analysis** with interactive context gathering, framework alignment, and incremental update support. Replaces 9 individual role commands with single parameterized workflow.
|
||||
|
||||
### Core Function
|
||||
- **Multi-Role Support**: Single command supports all 9 brainstorming roles
|
||||
- **Interactive Context**: Dynamic question generation based on role and framework
|
||||
- **Incremental Updates**: Merge new insights into existing analyses
|
||||
- **Framework Alignment**: Address guidance-specification.md discussion points
|
||||
- **Agent Delegation**: Use conceptual-planning-agent with role-specific templates
|
||||
|
||||
### Supported Roles
|
||||
|
||||
| Role ID | Title | Focus Area | Context Questions |
|
||||
|---------|-------|------------|-------------------|
|
||||
| `ux-expert` | UX专家 | User research, information architecture, user journey | 4 |
|
||||
| `ui-designer` | UI设计师 | Visual design, high-fidelity mockups, design systems | 4 |
|
||||
| `system-architect` | 系统架构师 | Technical architecture, scalability, integration patterns | 5 |
|
||||
| `product-manager` | 产品经理 | Product strategy, roadmap, prioritization | 4 |
|
||||
| `product-owner` | 产品负责人 | Backlog management, user stories, acceptance criteria | 4 |
|
||||
| `scrum-master` | 敏捷教练 | Process facilitation, impediment removal, team dynamics | 3 |
|
||||
| `subject-matter-expert` | 领域专家 | Domain knowledge, business rules, compliance | 4 |
|
||||
| `data-architect` | 数据架构师 | Data models, storage strategies, data flow | 5 |
|
||||
| `api-designer` | API设计师 | API contracts, versioning, integration patterns | 4 |
|
||||
|
||||
---
|
||||
|
||||
## 📋 **Usage**
|
||||
|
||||
```bash
|
||||
# Generate new analysis with interactive context
|
||||
/workflow:brainstorm:role-analysis ux-expert
|
||||
|
||||
# Generate with existing framework + context questions
|
||||
/workflow:brainstorm:role-analysis system-architect --session WFS-xxx --include-questions
|
||||
|
||||
# Update existing analysis (incremental merge)
|
||||
/workflow:brainstorm:role-analysis ui-designer --session WFS-xxx --update
|
||||
|
||||
# Quick generation (skip interactive context)
|
||||
/workflow:brainstorm:role-analysis product-manager --session WFS-xxx --skip-questions
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## ⚙️ **Execution Protocol**
|
||||
|
||||
### Phase 1: Detection & Validation
|
||||
|
||||
**Step 1.1: Role Validation**
|
||||
```bash
|
||||
VALIDATE role_name IN [
|
||||
ux-expert, ui-designer, system-architect, product-manager,
|
||||
product-owner, scrum-master, subject-matter-expert,
|
||||
data-architect, api-designer
|
||||
]
|
||||
IF invalid:
|
||||
ERROR: "Unknown role: {role_name}. Use one of: ux-expert, ui-designer, ..."
|
||||
EXIT
|
||||
```
|
||||
|
||||
**Step 1.2: Session Detection**
|
||||
```bash
|
||||
IF --session PROVIDED:
|
||||
session_id = --session
|
||||
brainstorm_dir = .workflow/active/{session_id}/.brainstorming/
|
||||
ELSE:
|
||||
FIND .workflow/active/WFS-*/
|
||||
IF multiple:
|
||||
PROMPT user to select
|
||||
ELSE IF single:
|
||||
USE existing
|
||||
ELSE:
|
||||
ERROR: "No active session. Run /workflow:brainstorm:artifacts first"
|
||||
EXIT
|
||||
|
||||
VALIDATE brainstorm_dir EXISTS
|
||||
```
|
||||
|
||||
**Step 1.3: Framework Detection**
|
||||
```bash
|
||||
framework_file = {brainstorm_dir}/guidance-specification.md
|
||||
IF framework_file EXISTS:
|
||||
framework_mode = true
|
||||
LOAD framework_content
|
||||
ELSE:
|
||||
WARN: "No framework found - will create standalone analysis"
|
||||
framework_mode = false
|
||||
```
|
||||
|
||||
**Step 1.4: Update Mode Detection**
|
||||
```bash
|
||||
existing_analysis = {brainstorm_dir}/{role_name}/analysis*.md
|
||||
IF --update FLAG OR existing_analysis EXISTS:
|
||||
update_mode = true
|
||||
IF --update NOT PROVIDED:
|
||||
ASK: "Analysis exists. Update or regenerate?"
|
||||
OPTIONS: ["Incremental update", "Full regenerate", "Cancel"]
|
||||
ELSE:
|
||||
update_mode = false
|
||||
```
|
||||
|
||||
### Phase 2: Interactive Context Gathering
|
||||
|
||||
**Trigger Conditions**:
|
||||
- Default: Always ask unless `--skip-questions` provided
|
||||
- `--include-questions`: Force context gathering even if analysis exists
|
||||
- `--skip-questions`: Skip all interactive questions
|
||||
|
||||
**Step 2.1: Load Role Configuration**
|
||||
```javascript
|
||||
const roleConfig = {
|
||||
'ux-expert': {
|
||||
title: 'UX专家',
|
||||
focus_area: 'User research, information architecture, user journey',
|
||||
question_categories: ['User Intent', 'Requirements', 'UX'],
|
||||
question_count: 4,
|
||||
template: '~/.claude/workflows/cli-templates/planning-roles/ux-expert.md'
|
||||
},
|
||||
'ui-designer': {
|
||||
title: 'UI设计师',
|
||||
focus_area: 'Visual design, high-fidelity mockups, design systems',
|
||||
question_categories: ['Requirements', 'UX', 'Feasibility'],
|
||||
question_count: 4,
|
||||
template: '~/.claude/workflows/cli-templates/planning-roles/ui-designer.md'
|
||||
},
|
||||
'system-architect': {
|
||||
title: '系统架构师',
|
||||
focus_area: 'Technical architecture, scalability, integration patterns',
|
||||
question_categories: ['Scale & Performance', 'Technical Constraints', 'Architecture Complexity', 'Non-Functional Requirements'],
|
||||
question_count: 5,
|
||||
template: '~/.claude/workflows/cli-templates/planning-roles/system-architect.md'
|
||||
},
|
||||
'product-manager': {
|
||||
title: '产品经理',
|
||||
focus_area: 'Product strategy, roadmap, prioritization',
|
||||
question_categories: ['User Intent', 'Requirements', 'Process'],
|
||||
question_count: 4,
|
||||
template: '~/.claude/workflows/cli-templates/planning-roles/product-manager.md'
|
||||
},
|
||||
'product-owner': {
|
||||
title: '产品负责人',
|
||||
focus_area: 'Backlog management, user stories, acceptance criteria',
|
||||
question_categories: ['Requirements', 'Decisions', 'Process'],
|
||||
question_count: 4,
|
||||
template: '~/.claude/workflows/cli-templates/planning-roles/product-owner.md'
|
||||
},
|
||||
'scrum-master': {
|
||||
title: '敏捷教练',
|
||||
focus_area: 'Process facilitation, impediment removal, team dynamics',
|
||||
question_categories: ['Process', 'Risk', 'Decisions'],
|
||||
question_count: 3,
|
||||
template: '~/.claude/workflows/cli-templates/planning-roles/scrum-master.md'
|
||||
},
|
||||
'subject-matter-expert': {
|
||||
title: '领域专家',
|
||||
focus_area: 'Domain knowledge, business rules, compliance',
|
||||
question_categories: ['Requirements', 'Feasibility', 'Terminology'],
|
||||
question_count: 4,
|
||||
template: '~/.claude/workflows/cli-templates/planning-roles/subject-matter-expert.md'
|
||||
},
|
||||
'data-architect': {
|
||||
title: '数据架构师',
|
||||
focus_area: 'Data models, storage strategies, data flow',
|
||||
question_categories: ['Architecture', 'Scale & Performance', 'Technical Constraints', 'Feasibility'],
|
||||
question_count: 5,
|
||||
template: '~/.claude/workflows/cli-templates/planning-roles/data-architect.md'
|
||||
},
|
||||
'api-designer': {
|
||||
title: 'API设计师',
|
||||
focus_area: 'API contracts, versioning, integration patterns',
|
||||
question_categories: ['Architecture', 'Requirements', 'Feasibility', 'Decisions'],
|
||||
question_count: 4,
|
||||
template: '~/.claude/workflows/cli-templates/planning-roles/api-designer.md'
|
||||
}
|
||||
};
|
||||
|
||||
config = roleConfig[role_name];
|
||||
```
|
||||
|
||||
**Step 2.2: Generate Role-Specific Questions**
|
||||
|
||||
**9-Category Taxonomy** (from synthesis.md):
|
||||
|
||||
| Category | Focus | Example Question Pattern |
|
||||
|----------|-------|--------------------------|
|
||||
| User Intent | 用户目标 | "该分析的核心目标是什么?" |
|
||||
| Requirements | 需求细化 | "需求的优先级如何排序?" |
|
||||
| Architecture | 架构决策 | "技术栈的选择考量?" |
|
||||
| UX | 用户体验 | "交互复杂度的取舍?" |
|
||||
| Feasibility | 可行性 | "资源约束下的实现范围?" |
|
||||
| Risk | 风险管理 | "风险容忍度是多少?" |
|
||||
| Process | 流程规范 | "开发迭代的节奏?" |
|
||||
| Decisions | 决策确认 | "冲突的解决方案?" |
|
||||
| Terminology | 术语统一 | "统一使用哪个术语?" |
|
||||
| Scale & Performance | 性能扩展 | "预期的负载和性能要求?" |
|
||||
| Technical Constraints | 技术约束 | "现有技术栈的限制?" |
|
||||
| Architecture Complexity | 架构复杂度 | "架构的复杂度权衡?" |
|
||||
| Non-Functional Requirements | 非功能需求 | "可用性和可维护性要求?" |
|
||||
|
||||
**Question Generation Algorithm**:
|
||||
```javascript
|
||||
async function generateQuestions(role_name, framework_content) {
|
||||
const config = roleConfig[role_name];
|
||||
const questions = [];
|
||||
|
||||
// Parse framework for keywords
|
||||
const keywords = extractKeywords(framework_content);
|
||||
|
||||
// Generate category-specific questions
|
||||
for (const category of config.question_categories) {
|
||||
const question = generateCategoryQuestion(category, keywords, role_name);
|
||||
questions.push(question);
|
||||
}
|
||||
|
||||
return questions.slice(0, config.question_count);
|
||||
}
|
||||
```
|
||||
|
||||
**Step 2.3: Multi-Round Question Execution**
|
||||
|
||||
```javascript
|
||||
const BATCH_SIZE = 4;
|
||||
const user_context = {};
|
||||
|
||||
for (let i = 0; i < questions.length; i += BATCH_SIZE) {
|
||||
const batch = questions.slice(i, i + BATCH_SIZE);
|
||||
const currentRound = Math.floor(i / BATCH_SIZE) + 1;
|
||||
const totalRounds = Math.ceil(questions.length / BATCH_SIZE);
|
||||
|
||||
console.log(`\n[Round ${currentRound}/${totalRounds}] ${config.title} 上下文询问\n`);
|
||||
|
||||
AskUserQuestion({
|
||||
questions: batch.map(q => ({
|
||||
question: q.question,
|
||||
header: q.category.substring(0, 12),
|
||||
multiSelect: false,
|
||||
options: q.options.map(opt => ({
|
||||
label: opt.label,
|
||||
description: opt.description
|
||||
}))
|
||||
}))
|
||||
});
|
||||
|
||||
// Store responses before next round
|
||||
for (const answer of responses) {
|
||||
user_context[answer.question] = {
|
||||
answer: answer.selected,
|
||||
category: answer.category,
|
||||
timestamp: new Date().toISOString()
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
// Save context to file
|
||||
Write(
|
||||
`${brainstorm_dir}/${role_name}/${role_name}-context.md`,
|
||||
formatUserContext(user_context)
|
||||
);
|
||||
```
|
||||
|
||||
**Question Quality Rules** (from artifacts.md):
|
||||
|
||||
**MUST Include**:
|
||||
- ✅ All questions in Chinese (用中文提问)
|
||||
- ✅ 业务场景作为问题前提
|
||||
- ✅ 技术选项的业务影响说明
|
||||
- ✅ 量化指标和约束条件
|
||||
|
||||
**MUST Avoid**:
|
||||
- ❌ 纯技术选型无业务上下文
|
||||
- ❌ 过度抽象的通用问题
|
||||
- ❌ 脱离框架的重复询问
|
||||
|
||||
### Phase 3: Agent Execution
|
||||
|
||||
**Step 3.1: Load Session Metadata**
|
||||
```bash
|
||||
session_metadata = Read(.workflow/active/{session_id}/workflow-session.json)
|
||||
original_topic = session_metadata.topic
|
||||
selected_roles = session_metadata.selected_roles
|
||||
```
|
||||
|
||||
**Step 3.2: Prepare Agent Context**
|
||||
```javascript
|
||||
const agentContext = {
|
||||
role_name: role_name,
|
||||
role_config: roleConfig[role_name],
|
||||
output_location: `${brainstorm_dir}/${role_name}/`,
|
||||
framework_mode: framework_mode,
|
||||
framework_path: framework_mode ? `${brainstorm_dir}/guidance-specification.md` : null,
|
||||
update_mode: update_mode,
|
||||
user_context: user_context,
|
||||
original_topic: original_topic,
|
||||
session_id: session_id
|
||||
};
|
||||
```
|
||||
|
||||
**Step 3.3: Execute Conceptual Planning Agent**
|
||||
|
||||
**Framework-Based Analysis** (when guidance-specification.md exists):
|
||||
```javascript
|
||||
Task(
|
||||
subagent_type="conceptual-planning-agent",
|
||||
run_in_background=false,
|
||||
description=`Generate ${role_name} analysis`,
|
||||
prompt=`
|
||||
[FLOW_CONTROL]
|
||||
|
||||
Execute ${role_name} analysis for existing topic framework
|
||||
|
||||
## Context Loading
|
||||
ASSIGNED_ROLE: ${role_name}
|
||||
OUTPUT_LOCATION: ${agentContext.output_location}
|
||||
ANALYSIS_MODE: ${framework_mode ? "framework_based" : "standalone"}
|
||||
UPDATE_MODE: ${update_mode}
|
||||
|
||||
## Flow Control Steps
|
||||
1. **load_topic_framework**
|
||||
- Action: Load structured topic discussion framework
|
||||
- Command: Read(${agentContext.framework_path})
|
||||
- Output: topic_framework_content
|
||||
|
||||
2. **load_role_template**
|
||||
- Action: Load ${role_name} planning template
|
||||
- Command: Read(${roleConfig[role_name].template})
|
||||
- Output: role_template_guidelines
|
||||
|
||||
3. **load_session_metadata**
|
||||
- Action: Load session metadata and user intent
|
||||
- Command: Read(.workflow/active/${session_id}/workflow-session.json)
|
||||
- Output: session_context
|
||||
|
||||
4. **load_user_context** (if exists)
|
||||
- Action: Load interactive context responses
|
||||
- Command: Read(${brainstorm_dir}/${role_name}/${role_name}-context.md)
|
||||
- Output: user_context_answers
|
||||
|
||||
5. **${update_mode ? 'load_existing_analysis' : 'skip'}**
|
||||
${update_mode ? `
|
||||
- Action: Load existing analysis for incremental update
|
||||
- Command: Read(${brainstorm_dir}/${role_name}/analysis.md)
|
||||
- Output: existing_analysis_content
|
||||
` : ''}
|
||||
|
||||
## Analysis Requirements
|
||||
**Primary Reference**: Original user prompt from workflow-session.json is authoritative
|
||||
**Framework Source**: Address all discussion points in guidance-specification.md from ${role_name} perspective
|
||||
**User Context Integration**: Incorporate interactive Q&A responses into analysis
|
||||
**Role Focus**: ${roleConfig[role_name].focus_area}
|
||||
**Template Integration**: Apply role template guidelines within framework structure
|
||||
|
||||
## Expected Deliverables
|
||||
1. **analysis.md** (main document, optionally with analysis-{slug}.md sub-documents)
|
||||
2. **Framework Reference**: @../guidance-specification.md (if framework_mode)
|
||||
3. **User Context Reference**: @./${role_name}-context.md (if user context exists)
|
||||
4. **User Intent Alignment**: Validate against session_context
|
||||
|
||||
## Update Requirements (if UPDATE_MODE)
|
||||
- **Preserve Structure**: Maintain existing analysis structure
|
||||
- **Add "Clarifications" Section**: Document new user context with timestamp
|
||||
- **Merge Insights**: Integrate new perspectives without removing existing content
|
||||
- **Resolve Conflicts**: If new context contradicts existing analysis, document both and recommend resolution
|
||||
|
||||
## Completion Criteria
|
||||
- Address each discussion point from guidance-specification.md with ${role_name} expertise
|
||||
- Provide actionable recommendations from ${role_name} perspective within analysis files
|
||||
- All output files MUST start with "analysis" prefix (no recommendations.md or other naming)
|
||||
- Reference framework document using @ notation for integration
|
||||
- Update workflow-session.json with completion status
|
||||
`
|
||||
);
|
||||
```
|
||||
|
||||
### Phase 4: Validation & Finalization
|
||||
|
||||
**Step 4.1: Validate Output**
|
||||
```bash
|
||||
VERIFY EXISTS: ${brainstorm_dir}/${role_name}/analysis.md
|
||||
VERIFY CONTAINS: "@../guidance-specification.md" (if framework_mode)
|
||||
IF user_context EXISTS:
|
||||
VERIFY CONTAINS: "@./${role_name}-context.md" OR "## Clarifications" section
|
||||
```
|
||||
|
||||
**Step 4.2: Update Session Metadata**
|
||||
```json
|
||||
{
|
||||
"phases": {
|
||||
"BRAINSTORM": {
|
||||
"${role_name}": {
|
||||
"status": "${update_mode ? 'updated' : 'completed'}",
|
||||
"completed_at": "timestamp",
|
||||
"framework_addressed": true,
|
||||
"context_gathered": user_context ? true : false,
|
||||
"output_location": "${brainstorm_dir}/${role_name}/analysis.md",
|
||||
"update_history": [
|
||||
{
|
||||
"timestamp": "ISO8601",
|
||||
"mode": "${update_mode ? 'incremental' : 'initial'}",
|
||||
"context_questions": question_count
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
**Step 4.3: Completion Report**
|
||||
```markdown
|
||||
✅ ${roleConfig[role_name].title} Analysis Complete
|
||||
|
||||
**Output**: ${brainstorm_dir}/${role_name}/analysis.md
|
||||
**Mode**: ${update_mode ? 'Incremental Update' : 'New Generation'}
|
||||
**Framework**: ${framework_mode ? '✓ Aligned' : '✗ Standalone'}
|
||||
**Context Questions**: ${question_count} answered
|
||||
|
||||
${update_mode ? '
|
||||
**Changes**:
|
||||
- Added "Clarifications" section with new user context
|
||||
- Merged new insights into existing sections
|
||||
- Resolved conflicts with framework alignment
|
||||
' : ''}
|
||||
|
||||
**Next Steps**:
|
||||
${selected_roles.length > 1 ? `
|
||||
- Continue with other roles: ${selected_roles.filter(r => r !== role_name).join(', ')}
|
||||
- Run synthesis: /workflow:brainstorm:synthesis --session ${session_id}
|
||||
` : `
|
||||
- Clarify insights: /workflow:brainstorm:synthesis --session ${session_id}
|
||||
- Generate plan: /workflow:plan --session ${session_id}
|
||||
`}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 📋 **TodoWrite Integration**
|
||||
|
||||
### Workflow Progress Tracking
|
||||
|
||||
```javascript
|
||||
TodoWrite({
|
||||
todos: [
|
||||
{
|
||||
content: "Phase 1: Detect session and validate role configuration",
|
||||
status: "in_progress",
|
||||
activeForm: "Detecting session and role"
|
||||
},
|
||||
{
|
||||
content: "Phase 2: Interactive context gathering with AskUserQuestion",
|
||||
status: "pending",
|
||||
activeForm: "Gathering user context"
|
||||
},
|
||||
{
|
||||
content: "Phase 3: Execute conceptual-planning-agent for role analysis",
|
||||
status: "pending",
|
||||
activeForm: "Executing agent analysis"
|
||||
},
|
||||
{
|
||||
content: "Phase 4: Validate output and update session metadata",
|
||||
status: "pending",
|
||||
activeForm: "Finalizing and validating"
|
||||
}
|
||||
]
|
||||
});
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 📊 **Output Structure**
|
||||
|
||||
### Directory Layout
|
||||
|
||||
```
|
||||
.workflow/active/WFS-{session}/.brainstorming/
|
||||
├── guidance-specification.md # Framework (if exists)
|
||||
└── {role-name}/
|
||||
├── {role-name}-context.md # Interactive Q&A responses
|
||||
├── analysis.md # Main analysis (REQUIRED)
|
||||
└── analysis-{slug}.md # Section documents (optional, max 5)
|
||||
```
|
||||
|
||||
### Analysis Document Structure (New Generation)
|
||||
|
||||
```markdown
|
||||
# ${roleConfig[role_name].title} Analysis: [Topic from Framework]
|
||||
|
||||
## Framework Reference
|
||||
**Topic Framework**: @../guidance-specification.md
|
||||
**Role Focus**: ${roleConfig[role_name].focus_area}
|
||||
**User Context**: @./${role_name}-context.md
|
||||
|
||||
## User Context Summary
|
||||
**Context Gathered**: ${question_count} questions answered
|
||||
**Categories**: ${question_categories.join(', ')}
|
||||
|
||||
${user_context ? formatContextSummary(user_context) : ''}
|
||||
|
||||
## Discussion Points Analysis
|
||||
[Address each point from guidance-specification.md with ${role_name} expertise]
|
||||
|
||||
### Core Requirements (from framework)
|
||||
[Role-specific perspective on requirements]
|
||||
|
||||
### Technical Considerations (from framework)
|
||||
[Role-specific technical analysis]
|
||||
|
||||
### User Experience Factors (from framework)
|
||||
[Role-specific UX considerations]
|
||||
|
||||
### Implementation Challenges (from framework)
|
||||
[Role-specific challenges and solutions]
|
||||
|
||||
### Success Metrics (from framework)
|
||||
[Role-specific metrics and KPIs]
|
||||
|
||||
## ${roleConfig[role_name].title} Specific Recommendations
|
||||
[Role-specific actionable strategies]
|
||||
|
||||
---
|
||||
*Generated by ${role_name} analysis addressing structured framework*
|
||||
*Context gathered: ${new Date().toISOString()}*
|
||||
```
|
||||
|
||||
### Analysis Document Structure (Incremental Update)
|
||||
|
||||
```markdown
|
||||
# ${roleConfig[role_name].title} Analysis: [Topic]
|
||||
|
||||
## Framework Reference
|
||||
[Existing content preserved]
|
||||
|
||||
## Clarifications
|
||||
### Session ${new Date().toISOString().split('T')[0]}
|
||||
${Object.entries(user_context).map(([q, a]) => `
|
||||
- **Q**: ${q} (Category: ${a.category})
|
||||
**A**: ${a.answer}
|
||||
`).join('\n')}
|
||||
|
||||
## User Context Summary
|
||||
[Updated with new context]
|
||||
|
||||
## Discussion Points Analysis
|
||||
[Existing content enhanced with new insights]
|
||||
|
||||
[Rest of sections updated based on clarifications]
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 🔄 **Integration with Other Commands**
|
||||
|
||||
### Called By
|
||||
- `/workflow:brainstorm:auto-parallel` (Phase 2 - parallel role execution)
|
||||
- Manual invocation for single-role analysis
|
||||
|
||||
### Calls To
|
||||
- `conceptual-planning-agent` (agent execution)
|
||||
- `AskUserQuestion` (interactive context gathering)
|
||||
|
||||
### Coordinates With
|
||||
- `/workflow:brainstorm:artifacts` (creates framework for role analysis)
|
||||
- `/workflow:brainstorm:synthesis` (reads role analyses for integration)
|
||||
|
||||
---
|
||||
|
||||
## ✅ **Quality Assurance**
|
||||
|
||||
### Required Analysis Elements
|
||||
- [ ] Framework discussion points addressed (if framework_mode)
|
||||
- [ ] User context integrated (if context gathered)
|
||||
- [ ] Role template guidelines applied
|
||||
- [ ] Output files follow naming convention (analysis*.md only)
|
||||
- [ ] Framework reference using @ notation
|
||||
- [ ] Session metadata updated
|
||||
|
||||
### Context Quality
|
||||
- [ ] Questions in Chinese with business context
|
||||
- [ ] Options include technical trade-offs
|
||||
- [ ] Categories aligned with role focus
|
||||
- [ ] No generic questions unrelated to framework
|
||||
|
||||
### Update Quality (if update_mode)
|
||||
- [ ] "Clarifications" section added with timestamp
|
||||
- [ ] New insights merged without content loss
|
||||
- [ ] Conflicts documented and resolved
|
||||
- [ ] Framework alignment maintained
|
||||
|
||||
---
|
||||
|
||||
## 🎛️ **Command Parameters**
|
||||
|
||||
### Required Parameters
|
||||
- `[role-name]`: Role identifier (ux-expert, ui-designer, system-architect, etc.)
|
||||
|
||||
### Optional Parameters
|
||||
- `--session [session-id]`: Specify brainstorming session (auto-detect if omitted)
|
||||
- `--update`: Force incremental update mode (auto-detect if analysis exists)
|
||||
- `--include-questions`: Force context gathering even if analysis exists
|
||||
- `--skip-questions`: Skip all interactive context gathering
|
||||
- `--style-skill [package]`: For ui-designer only, load style SKILL package
|
||||
|
||||
### Parameter Combinations
|
||||
|
||||
| Scenario | Command | Behavior |
|
||||
|----------|---------|----------|
|
||||
| New analysis | `role-analysis ux-expert` | Generate + ask context questions |
|
||||
| Quick generation | `role-analysis ux-expert --skip-questions` | Generate without context |
|
||||
| Update existing | `role-analysis ux-expert --update` | Ask clarifications + merge |
|
||||
| Force questions | `role-analysis ux-expert --include-questions` | Ask even if exists |
|
||||
| Specific session | `role-analysis ux-expert --session WFS-xxx` | Target specific session |
|
||||
|
||||
---
|
||||
|
||||
## 🚫 **Error Handling**
|
||||
|
||||
### Invalid Role Name
|
||||
```
|
||||
ERROR: Unknown role: "ui-expert"
|
||||
Valid roles: ux-expert, ui-designer, system-architect, product-manager,
|
||||
product-owner, scrum-master, subject-matter-expert,
|
||||
data-architect, api-designer
|
||||
```
|
||||
|
||||
### No Active Session
|
||||
```
|
||||
ERROR: No active brainstorming session found
|
||||
Run: /workflow:brainstorm:artifacts "[topic]" to create session
|
||||
```
|
||||
|
||||
### Missing Framework (with warning)
|
||||
```
|
||||
WARN: No guidance-specification.md found
|
||||
Generating standalone analysis without framework alignment
|
||||
Recommend: Run /workflow:brainstorm:artifacts first for better results
|
||||
```
|
||||
|
||||
### Agent Execution Failure
|
||||
```
|
||||
ERROR: Conceptual planning agent failed
|
||||
Check: ${brainstorm_dir}/${role_name}/error.log
|
||||
Action: Retry with --skip-questions or check framework validity
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 🔧 **Advanced Usage**
|
||||
|
||||
### Batch Role Generation (via auto-parallel)
|
||||
```bash
|
||||
# This command handles multiple roles in parallel
|
||||
/workflow:brainstorm:auto-parallel "topic" --count 3
|
||||
# → Internally calls role-analysis for each selected role
|
||||
```
|
||||
|
||||
### Manual Multi-Role Workflow
|
||||
```bash
|
||||
# 1. Create framework
|
||||
/workflow:brainstorm:artifacts "Build real-time collaboration platform" --count 3
|
||||
|
||||
# 2. Generate each role with context
|
||||
/workflow:brainstorm:role-analysis system-architect --include-questions
|
||||
/workflow:brainstorm:role-analysis ui-designer --include-questions
|
||||
/workflow:brainstorm:role-analysis product-manager --include-questions
|
||||
|
||||
# 3. Synthesize insights
|
||||
/workflow:brainstorm:synthesis --session WFS-xxx
|
||||
```
|
||||
|
||||
### Iterative Refinement
|
||||
```bash
|
||||
# Initial generation
|
||||
/workflow:brainstorm:role-analysis ux-expert
|
||||
|
||||
# User reviews and wants more depth
|
||||
/workflow:brainstorm:role-analysis ux-expert --update --include-questions
|
||||
# → Asks clarification questions, merges new insights
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 📚 **Reference Information**
|
||||
|
||||
### Role Template Locations
|
||||
- Templates: `~/.claude/workflows/cli-templates/planning-roles/`
|
||||
- Format: `{role-name}.md` (e.g., `ux-expert.md`, `system-architect.md`)
|
||||
|
||||
### Related Commands
|
||||
- `/workflow:brainstorm:artifacts` - Create framework and select roles
|
||||
- `/workflow:brainstorm:auto-parallel` - Parallel multi-role execution
|
||||
- `/workflow:brainstorm:synthesis` - Integrate role analyses
|
||||
- `/workflow:plan` - Generate implementation plan from synthesis
|
||||
|
||||
### Context Package
|
||||
- Location: `.workflow/active/WFS-{session}/.process/context-package.json`
|
||||
- Used by: `context-search-agent` (Phase 0 of artifacts)
|
||||
- Contains: Project context, tech stack, conflict risks
|
||||
@@ -1,200 +0,0 @@
|
||||
---
|
||||
name: scrum-master
|
||||
description: Generate or update scrum-master/analysis.md addressing guidance-specification discussion points for Agile process perspective
|
||||
argument-hint: "optional topic - uses existing framework if available"
|
||||
allowed-tools: Task(conceptual-planning-agent), TodoWrite(*), Read(*), Write(*)
|
||||
---
|
||||
|
||||
## 🎯 **Scrum Master Analysis Generator**
|
||||
|
||||
### Purpose
|
||||
**Specialized command for generating scrum-master/analysis.md** that addresses guidance-specification.md discussion points from agile process and team collaboration perspective. Creates or updates role-specific analysis with framework references.
|
||||
|
||||
### Core Function
|
||||
- **Framework-based Analysis**: Address each discussion point in guidance-specification.md
|
||||
- **Agile Process Focus**: Sprint planning, team dynamics, and delivery optimization
|
||||
- **Update Mechanism**: Create new or update existing analysis.md
|
||||
- **Agent Delegation**: Use conceptual-planning-agent for analysis generation
|
||||
|
||||
### Analysis Scope
|
||||
- **Sprint Planning**: Task breakdown, estimation, and iteration planning
|
||||
- **Team Collaboration**: Communication patterns, impediment removal, and facilitation
|
||||
- **Process Optimization**: Agile ceremonies, retrospectives, and continuous improvement
|
||||
- **Delivery Management**: Velocity tracking, burndown analysis, and release planning
|
||||
|
||||
## ⚙️ **Execution Protocol**
|
||||
|
||||
### Phase 1: Session & Framework Detection
|
||||
```bash
|
||||
# Check active session and framework
|
||||
CHECK: find .workflow/active/ -name "WFS-*" -type d
|
||||
IF active_session EXISTS:
|
||||
session_id = get_active_session()
|
||||
brainstorm_dir = .workflow/active/WFS-{session}/.brainstorming/
|
||||
|
||||
CHECK: brainstorm_dir/guidance-specification.md
|
||||
IF EXISTS:
|
||||
framework_mode = true
|
||||
load_framework = true
|
||||
ELSE:
|
||||
IF topic_provided:
|
||||
framework_mode = false # Create analysis without framework
|
||||
ELSE:
|
||||
ERROR: "No framework found and no topic provided"
|
||||
```
|
||||
|
||||
### Phase 2: Analysis Mode Detection
|
||||
```bash
|
||||
# Determine execution mode
|
||||
IF framework_mode == true:
|
||||
mode = "framework_based_analysis"
|
||||
topic_ref = load_framework_topic()
|
||||
discussion_points = extract_framework_points()
|
||||
ELSE:
|
||||
mode = "standalone_analysis"
|
||||
topic_ref = provided_topic
|
||||
discussion_points = generate_basic_structure()
|
||||
```
|
||||
|
||||
### Phase 3: Agent Execution with Flow Control
|
||||
**Framework-Based Analysis Generation**
|
||||
|
||||
```bash
|
||||
Task(conceptual-planning-agent): "
|
||||
[FLOW_CONTROL]
|
||||
|
||||
Execute scrum-master analysis for existing topic framework
|
||||
|
||||
## Context Loading
|
||||
ASSIGNED_ROLE: scrum-master
|
||||
OUTPUT_LOCATION: .workflow/active/WFS-{session}/.brainstorming/scrum-master/
|
||||
ANALYSIS_MODE: {framework_mode ? "framework_based" : "standalone"}
|
||||
|
||||
## Flow Control Steps
|
||||
1. **load_topic_framework**
|
||||
- Action: Load structured topic discussion framework
|
||||
- Command: Read(.workflow/active/WFS-{session}/.brainstorming/guidance-specification.md)
|
||||
- Output: topic_framework_content
|
||||
|
||||
2. **load_role_template**
|
||||
- Action: Load scrum-master planning template
|
||||
- Command: bash($(cat ~/.claude/workflows/cli-templates/planning-roles/scrum-master.md))
|
||||
- Output: role_template_guidelines
|
||||
|
||||
3. **load_session_metadata**
|
||||
- Action: Load session metadata and existing context
|
||||
- Command: Read(.workflow/active/WFS-{session}/workflow-session.json)
|
||||
- Output: session_context
|
||||
|
||||
## Analysis Requirements
|
||||
**Framework Reference**: Address all discussion points in guidance-specification.md from agile process and team collaboration perspective
|
||||
**Role Focus**: Sprint planning, team dynamics, process optimization, delivery management
|
||||
**Structured Approach**: Create analysis.md addressing framework discussion points
|
||||
**Template Integration**: Apply role template guidelines within framework structure
|
||||
|
||||
## Expected Deliverables
|
||||
1. **analysis.md**: Comprehensive agile process analysis addressing all framework discussion points
|
||||
2. **Framework Reference**: Include @../guidance-specification.md reference in analysis
|
||||
|
||||
## Completion Criteria
|
||||
- Address each discussion point from guidance-specification.md with scrum mastery expertise
|
||||
- Provide actionable sprint planning and team facilitation strategies
|
||||
- Include process optimization and impediment removal insights
|
||||
- Reference framework document using @ notation for integration
|
||||
"
|
||||
```
|
||||
|
||||
## 📋 **TodoWrite Integration**
|
||||
|
||||
### Workflow Progress Tracking
|
||||
```javascript
|
||||
TodoWrite({
|
||||
todos: [
|
||||
{
|
||||
content: "Detect active session and locate topic framework",
|
||||
status: "in_progress",
|
||||
activeForm: "Detecting session and framework"
|
||||
},
|
||||
{
|
||||
content: "Load guidance-specification.md and session metadata for context",
|
||||
status: "pending",
|
||||
activeForm: "Loading framework and session context"
|
||||
},
|
||||
{
|
||||
content: "Execute scrum-master analysis using conceptual-planning-agent with FLOW_CONTROL",
|
||||
status: "pending",
|
||||
activeForm: "Executing scrum-master framework analysis"
|
||||
},
|
||||
{
|
||||
content: "Generate analysis.md addressing all framework discussion points",
|
||||
status: "pending",
|
||||
activeForm: "Generating structured scrum-master analysis"
|
||||
},
|
||||
{
|
||||
content: "Update workflow-session.json with scrum-master completion status",
|
||||
status: "pending",
|
||||
activeForm: "Updating session metadata"
|
||||
}
|
||||
]
|
||||
});
|
||||
```
|
||||
|
||||
## 📊 **Output Structure**
|
||||
|
||||
### Framework-Based Analysis
|
||||
```
|
||||
.workflow/active/WFS-{session}/.brainstorming/scrum-master/
|
||||
└── analysis.md # Structured analysis addressing guidance-specification.md discussion points
|
||||
```
|
||||
|
||||
### Analysis Document Structure
|
||||
```markdown
|
||||
# Scrum Master Analysis: [Topic from Framework]
|
||||
|
||||
## Framework Reference
|
||||
**Topic Framework**: @../guidance-specification.md
|
||||
**Role Focus**: Agile Process & Team Collaboration perspective
|
||||
|
||||
## Discussion Points Analysis
|
||||
[Address each point from guidance-specification.md with scrum mastery expertise]
|
||||
|
||||
### Core Requirements (from framework)
|
||||
[Sprint planning and iteration breakdown perspective]
|
||||
|
||||
### Technical Considerations (from framework)
|
||||
[Technical debt management and process considerations]
|
||||
|
||||
### User Experience Factors (from framework)
|
||||
[User story refinement and acceptance criteria analysis]
|
||||
|
||||
### Implementation Challenges (from framework)
|
||||
[Impediment identification and removal strategies]
|
||||
|
||||
### Success Metrics (from framework)
|
||||
[Velocity tracking, burndown metrics, and team performance indicators]
|
||||
|
||||
## Scrum Master Specific Recommendations
|
||||
[Role-specific agile process optimization and team facilitation strategies]
|
||||
|
||||
---
|
||||
*Generated by scrum-master analysis addressing structured framework*
|
||||
```
|
||||
|
||||
## 🔄 **Session Integration**
|
||||
|
||||
### Completion Status Update
|
||||
```json
|
||||
{
|
||||
"scrum_master": {
|
||||
"status": "completed",
|
||||
"framework_addressed": true,
|
||||
"output_location": ".workflow/active/WFS-{session}/.brainstorming/scrum-master/analysis.md",
|
||||
"framework_reference": "@../guidance-specification.md"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### Integration Points
|
||||
- **Framework Reference**: @../guidance-specification.md for structured discussion points
|
||||
- **Cross-Role Synthesis**: Agile process insights available for synthesis-report.md integration
|
||||
- **Agent Autonomy**: Independent execution with framework guidance
|
||||
@@ -1,200 +0,0 @@
|
||||
---
|
||||
name: subject-matter-expert
|
||||
description: Generate or update subject-matter-expert/analysis.md addressing guidance-specification discussion points for domain expertise perspective
|
||||
argument-hint: "optional topic - uses existing framework if available"
|
||||
allowed-tools: Task(conceptual-planning-agent), TodoWrite(*), Read(*), Write(*)
|
||||
---
|
||||
|
||||
## 🎯 **Subject Matter Expert Analysis Generator**
|
||||
|
||||
### Purpose
|
||||
**Specialized command for generating subject-matter-expert/analysis.md** that addresses guidance-specification.md discussion points from domain knowledge and technical expertise perspective. Creates or updates role-specific analysis with framework references.
|
||||
|
||||
### Core Function
|
||||
- **Framework-based Analysis**: Address each discussion point in guidance-specification.md
|
||||
- **Domain Expertise Focus**: Deep technical knowledge, industry standards, and best practices
|
||||
- **Update Mechanism**: Create new or update existing analysis.md
|
||||
- **Agent Delegation**: Use conceptual-planning-agent for analysis generation
|
||||
|
||||
### Analysis Scope
|
||||
- **Domain Knowledge**: Industry-specific expertise, regulatory requirements, and compliance
|
||||
- **Technical Standards**: Best practices, design patterns, and architectural guidelines
|
||||
- **Risk Assessment**: Technical debt, scalability concerns, and maintenance implications
|
||||
- **Knowledge Transfer**: Documentation strategies, training requirements, and expertise sharing
|
||||
|
||||
## ⚙️ **Execution Protocol**
|
||||
|
||||
### Phase 1: Session & Framework Detection
|
||||
```bash
|
||||
# Check active session and framework
|
||||
CHECK: find .workflow/active/ -name "WFS-*" -type d
|
||||
IF active_session EXISTS:
|
||||
session_id = get_active_session()
|
||||
brainstorm_dir = .workflow/active/WFS-{session}/.brainstorming/
|
||||
|
||||
CHECK: brainstorm_dir/guidance-specification.md
|
||||
IF EXISTS:
|
||||
framework_mode = true
|
||||
load_framework = true
|
||||
ELSE:
|
||||
IF topic_provided:
|
||||
framework_mode = false # Create analysis without framework
|
||||
ELSE:
|
||||
ERROR: "No framework found and no topic provided"
|
||||
```
|
||||
|
||||
### Phase 2: Analysis Mode Detection
|
||||
```bash
|
||||
# Determine execution mode
|
||||
IF framework_mode == true:
|
||||
mode = "framework_based_analysis"
|
||||
topic_ref = load_framework_topic()
|
||||
discussion_points = extract_framework_points()
|
||||
ELSE:
|
||||
mode = "standalone_analysis"
|
||||
topic_ref = provided_topic
|
||||
discussion_points = generate_basic_structure()
|
||||
```
|
||||
|
||||
### Phase 3: Agent Execution with Flow Control
|
||||
**Framework-Based Analysis Generation**
|
||||
|
||||
```bash
|
||||
Task(conceptual-planning-agent): "
|
||||
[FLOW_CONTROL]
|
||||
|
||||
Execute subject-matter-expert analysis for existing topic framework
|
||||
|
||||
## Context Loading
|
||||
ASSIGNED_ROLE: subject-matter-expert
|
||||
OUTPUT_LOCATION: .workflow/active/WFS-{session}/.brainstorming/subject-matter-expert/
|
||||
ANALYSIS_MODE: {framework_mode ? "framework_based" : "standalone"}
|
||||
|
||||
## Flow Control Steps
|
||||
1. **load_topic_framework**
|
||||
- Action: Load structured topic discussion framework
|
||||
- Command: Read(.workflow/active/WFS-{session}/.brainstorming/guidance-specification.md)
|
||||
- Output: topic_framework_content
|
||||
|
||||
2. **load_role_template**
|
||||
- Action: Load subject-matter-expert planning template
|
||||
- Command: bash($(cat ~/.claude/workflows/cli-templates/planning-roles/subject-matter-expert.md))
|
||||
- Output: role_template_guidelines
|
||||
|
||||
3. **load_session_metadata**
|
||||
- Action: Load session metadata and existing context
|
||||
- Command: Read(.workflow/active/WFS-{session}/workflow-session.json)
|
||||
- Output: session_context
|
||||
|
||||
## Analysis Requirements
|
||||
**Framework Reference**: Address all discussion points in guidance-specification.md from domain expertise and technical standards perspective
|
||||
**Role Focus**: Domain knowledge, technical standards, risk assessment, knowledge transfer
|
||||
**Structured Approach**: Create analysis.md addressing framework discussion points
|
||||
**Template Integration**: Apply role template guidelines within framework structure
|
||||
|
||||
## Expected Deliverables
|
||||
1. **analysis.md**: Comprehensive domain expertise analysis addressing all framework discussion points
|
||||
2. **Framework Reference**: Include @../guidance-specification.md reference in analysis
|
||||
|
||||
## Completion Criteria
|
||||
- Address each discussion point from guidance-specification.md with subject matter expertise
|
||||
- Provide actionable technical standards and best practices recommendations
|
||||
- Include risk assessment and compliance considerations
|
||||
- Reference framework document using @ notation for integration
|
||||
"
|
||||
```
|
||||
|
||||
## 📋 **TodoWrite Integration**
|
||||
|
||||
### Workflow Progress Tracking
|
||||
```javascript
|
||||
TodoWrite({
|
||||
todos: [
|
||||
{
|
||||
content: "Detect active session and locate topic framework",
|
||||
status: "in_progress",
|
||||
activeForm: "Detecting session and framework"
|
||||
},
|
||||
{
|
||||
content: "Load guidance-specification.md and session metadata for context",
|
||||
status: "pending",
|
||||
activeForm: "Loading framework and session context"
|
||||
},
|
||||
{
|
||||
content: "Execute subject-matter-expert analysis using conceptual-planning-agent with FLOW_CONTROL",
|
||||
status: "pending",
|
||||
activeForm: "Executing subject-matter-expert framework analysis"
|
||||
},
|
||||
{
|
||||
content: "Generate analysis.md addressing all framework discussion points",
|
||||
status: "pending",
|
||||
activeForm: "Generating structured subject-matter-expert analysis"
|
||||
},
|
||||
{
|
||||
content: "Update workflow-session.json with subject-matter-expert completion status",
|
||||
status: "pending",
|
||||
activeForm: "Updating session metadata"
|
||||
}
|
||||
]
|
||||
});
|
||||
```
|
||||
|
||||
## 📊 **Output Structure**
|
||||
|
||||
### Framework-Based Analysis
|
||||
```
|
||||
.workflow/active/WFS-{session}/.brainstorming/subject-matter-expert/
|
||||
└── analysis.md # Structured analysis addressing guidance-specification.md discussion points
|
||||
```
|
||||
|
||||
### Analysis Document Structure
|
||||
```markdown
|
||||
# Subject Matter Expert Analysis: [Topic from Framework]
|
||||
|
||||
## Framework Reference
|
||||
**Topic Framework**: @../guidance-specification.md
|
||||
**Role Focus**: Domain Expertise & Technical Standards perspective
|
||||
|
||||
## Discussion Points Analysis
|
||||
[Address each point from guidance-specification.md with subject matter expertise]
|
||||
|
||||
### Core Requirements (from framework)
|
||||
[Domain-specific requirements and industry standards perspective]
|
||||
|
||||
### Technical Considerations (from framework)
|
||||
[Deep technical analysis, architectural patterns, and best practices]
|
||||
|
||||
### User Experience Factors (from framework)
|
||||
[Domain-specific usability standards and industry conventions]
|
||||
|
||||
### Implementation Challenges (from framework)
|
||||
[Technical risks, scalability concerns, and maintenance implications]
|
||||
|
||||
### Success Metrics (from framework)
|
||||
[Domain-specific KPIs, compliance metrics, and quality standards]
|
||||
|
||||
## Subject Matter Expert Specific Recommendations
|
||||
[Role-specific technical expertise and industry best practices]
|
||||
|
||||
---
|
||||
*Generated by subject-matter-expert analysis addressing structured framework*
|
||||
```
|
||||
|
||||
## 🔄 **Session Integration**
|
||||
|
||||
### Completion Status Update
|
||||
```json
|
||||
{
|
||||
"subject_matter_expert": {
|
||||
"status": "completed",
|
||||
"framework_addressed": true,
|
||||
"output_location": ".workflow/active/WFS-{session}/.brainstorming/subject-matter-expert/analysis.md",
|
||||
"framework_reference": "@../guidance-specification.md"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### Integration Points
|
||||
- **Framework Reference**: @../guidance-specification.md for structured discussion points
|
||||
- **Cross-Role Synthesis**: Domain expertise insights available for synthesis-report.md integration
|
||||
- **Agent Autonomy**: Independent execution with framework guidance
|
||||
@@ -1,10 +1,14 @@
|
||||
---
|
||||
name: synthesis
|
||||
description: Clarify and refine role analyses through intelligent Q&A and targeted updates with synthesis agent
|
||||
argument-hint: "[optional: --session session-id]"
|
||||
argument-hint: "[-y|--yes] [optional: --session session-id]"
|
||||
allowed-tools: Task(conceptual-planning-agent), TodoWrite(*), Read(*), Write(*), Edit(*), Glob(*), AskUserQuestion(*)
|
||||
---
|
||||
|
||||
## Auto Mode
|
||||
|
||||
When `--yes` or `-y`: Auto-select all enhancements, skip clarification questions, use default answers.
|
||||
|
||||
## Overview
|
||||
|
||||
Six-phase workflow to eliminate ambiguities and enhance conceptual depth in role analyses:
|
||||
|
||||
@@ -1,389 +0,0 @@
|
||||
---
|
||||
name: system-architect
|
||||
description: Generate or update system-architect/analysis.md addressing guidance-specification discussion points for system architecture perspective
|
||||
argument-hint: "optional topic - uses existing framework if available"
|
||||
allowed-tools: Task(conceptual-planning-agent), TodoWrite(*), Read(*), Write(*)
|
||||
---
|
||||
|
||||
## 🏗️ **System Architect Analysis Generator**
|
||||
|
||||
### Purpose
|
||||
**Specialized command for generating system-architect/analysis.md** that addresses guidance-specification.md discussion points from system architecture perspective. Creates or updates role-specific analysis with framework references.
|
||||
|
||||
### Core Function
|
||||
- **Framework-based Analysis**: Address each discussion point in guidance-specification.md
|
||||
- **Architecture Focus**: Technical architecture, scalability, and system design perspective
|
||||
- **Update Mechanism**: Create new or update existing analysis.md
|
||||
- **Agent Delegation**: Use conceptual-planning-agent for analysis generation
|
||||
|
||||
### Analysis Scope
|
||||
- **Technical Architecture**: Scalable and maintainable system design
|
||||
- **Technology Selection**: Stack evaluation and architectural decisions
|
||||
- **Performance & Scalability**: Capacity planning and optimization strategies
|
||||
- **Integration Patterns**: System communication and data flow design
|
||||
|
||||
### Role Boundaries & Responsibilities
|
||||
|
||||
#### **What This Role OWNS (Macro-Architecture)**
|
||||
- **System-Level Architecture**: Service boundaries, deployment topology, and system composition
|
||||
- **Cross-Service Communication Patterns**: Choosing between microservices/monolithic, event-driven/request-response, sync/async patterns
|
||||
- **Technology Stack Decisions**: Language, framework, database, and infrastructure choices
|
||||
- **Non-Functional Requirements**: Scalability, performance, availability, disaster recovery, and monitoring strategies
|
||||
- **Integration Planning**: How systems and services connect at the macro level (not specific API contracts)
|
||||
|
||||
#### **What This Role DOES NOT Own (Defers to Other Roles)**
|
||||
- **API Contract Details**: Specific endpoint definitions, URL structures, HTTP methods → Defers to **API Designer**
|
||||
- **Data Schemas**: Detailed data model design and entity relationships → Defers to **Data Architect**
|
||||
- **UI/UX Design**: Interface design and user experience → Defers to **UX Expert** and **UI Designer**
|
||||
|
||||
#### **Handoff Points**
|
||||
- **TO API Designer**: Provides architectural constraints (REST vs GraphQL, sync vs async) that define the API design space
|
||||
- **TO Data Architect**: Provides system-level data flow requirements and integration patterns
|
||||
- **FROM Data Architect**: Receives canonical data model to inform system integration design
|
||||
|
||||
## ⚙️ **Execution Protocol**
|
||||
|
||||
### Phase 1: Session & Framework Detection
|
||||
```bash
|
||||
# Check active session and framework
|
||||
CHECK: find .workflow/active/ -name "WFS-*" -type d
|
||||
IF active_session EXISTS:
|
||||
session_id = get_active_session()
|
||||
brainstorm_dir = .workflow/active/WFS-{session}/.brainstorming/
|
||||
|
||||
CHECK: brainstorm_dir/guidance-specification.md
|
||||
IF EXISTS:
|
||||
framework_mode = true
|
||||
load_framework = true
|
||||
ELSE:
|
||||
IF topic_provided:
|
||||
framework_mode = false # Create analysis without framework
|
||||
ELSE:
|
||||
ERROR: "No framework found and no topic provided"
|
||||
```
|
||||
|
||||
### Phase 2: Analysis Mode Detection
|
||||
```bash
|
||||
# Check existing analysis
|
||||
CHECK: brainstorm_dir/system-architect/analysis.md
|
||||
IF EXISTS:
|
||||
SHOW existing analysis summary
|
||||
ASK: "Analysis exists. Do you want to:"
|
||||
OPTIONS:
|
||||
1. "Update with new insights" → Update existing
|
||||
2. "Replace completely" → Generate new
|
||||
3. "Cancel" → Exit without changes
|
||||
ELSE:
|
||||
CREATE new analysis
|
||||
```
|
||||
|
||||
### Phase 3: Agent Task Generation
|
||||
**Framework-Based Analysis** (when guidance-specification.md exists):
|
||||
```bash
|
||||
Task(subagent_type="conceptual-planning-agent",
|
||||
run_in_background=false,
|
||||
prompt="Generate system architect analysis addressing topic framework
|
||||
|
||||
## Framework Integration Required
|
||||
**MANDATORY**: Load and address guidance-specification.md discussion points
|
||||
**Framework Reference**: @{session.brainstorm_dir}/guidance-specification.md
|
||||
**Output Location**: {session.brainstorm_dir}/system-architect/analysis.md
|
||||
|
||||
## Analysis Requirements
|
||||
1. **Load Topic Framework**: Read guidance-specification.md completely
|
||||
2. **Address Each Discussion Point**: Respond to all 5 framework sections from system architecture perspective
|
||||
3. **Include Framework Reference**: Start analysis.md with @../guidance-specification.md
|
||||
4. **Technical Focus**: Emphasize scalability, architecture patterns, technology decisions
|
||||
5. **Structured Response**: Use framework structure for analysis organization
|
||||
|
||||
## Framework Sections to Address
|
||||
- Core Requirements (from architecture perspective)
|
||||
- Technical Considerations (detailed architectural analysis)
|
||||
- User Experience Factors (technical UX considerations)
|
||||
- Implementation Challenges (architecture risks and solutions)
|
||||
- Success Metrics (technical metrics and monitoring)
|
||||
|
||||
## Output Structure Required
|
||||
```markdown
|
||||
# System Architect Analysis: [Topic]
|
||||
|
||||
**Framework Reference**: @../guidance-specification.md
|
||||
**Role Focus**: System Architecture and Technical Design
|
||||
|
||||
## Core Requirements Analysis
|
||||
[Address framework requirements from architecture perspective]
|
||||
|
||||
## Technical Considerations
|
||||
[Detailed architectural analysis]
|
||||
|
||||
## User Experience Factors
|
||||
[Technical aspects of UX implementation]
|
||||
|
||||
## Implementation Challenges
|
||||
[Architecture risks and mitigation strategies]
|
||||
|
||||
## Success Metrics
|
||||
[Technical metrics and system monitoring]
|
||||
|
||||
## Architecture-Specific Recommendations
|
||||
[Detailed technical recommendations]
|
||||
```",
|
||||
description="Generate system architect framework-based analysis")
|
||||
```
|
||||
|
||||
### Phase 4: Update Mechanism
|
||||
**Analysis Update Process**:
|
||||
```bash
|
||||
# For existing analysis updates
|
||||
IF update_mode = "incremental":
|
||||
Task(subagent_type="conceptual-planning-agent",
|
||||
run_in_background=false,
|
||||
prompt="Update existing system architect analysis
|
||||
|
||||
## Current Analysis Context
|
||||
**Existing Analysis**: @{session.brainstorm_dir}/system-architect/analysis.md
|
||||
**Framework Reference**: @{session.brainstorm_dir}/guidance-specification.md
|
||||
|
||||
## Update Requirements
|
||||
1. **Preserve Structure**: Maintain existing analysis structure
|
||||
2. **Add New Insights**: Integrate new technical insights and recommendations
|
||||
3. **Framework Alignment**: Ensure continued alignment with topic framework
|
||||
4. **Technical Updates**: Add new architecture patterns, technology considerations
|
||||
5. **Maintain References**: Keep @../guidance-specification.md reference
|
||||
|
||||
## Update Instructions
|
||||
- Read existing analysis completely
|
||||
- Identify areas for enhancement or new insights
|
||||
- Add technical depth while preserving original structure
|
||||
- Update recommendations with new architectural approaches
|
||||
- Maintain framework discussion point addressing",
|
||||
description="Update system architect analysis incrementally")
|
||||
```
|
||||
|
||||
## Document Structure
|
||||
|
||||
### Output Files
|
||||
```
|
||||
.workflow/active/WFS-[topic]/.brainstorming/
|
||||
├── guidance-specification.md # Input: Framework (if exists)
|
||||
└── system-architect/
|
||||
└── analysis.md # ★ OUTPUT: Framework-based analysis
|
||||
```
|
||||
|
||||
### Analysis Structure
|
||||
**Required Elements**:
|
||||
- **Framework Reference**: @../guidance-specification.md (if framework exists)
|
||||
- **Role Focus**: System Architecture and Technical Design perspective
|
||||
- **5 Framework Sections**: Address each framework discussion point
|
||||
- **Technical Recommendations**: Architecture-specific insights and solutions
|
||||
- How should we design APIs and manage versioning?
|
||||
|
||||
**4. Performance and Scalability**
|
||||
- Where are the current system performance bottlenecks?
|
||||
- How should we handle traffic growth and scaling demands?
|
||||
- What database scaling and optimization strategies are needed?
|
||||
|
||||
## ⚡ **Two-Step Execution Flow**
|
||||
|
||||
### ⚠️ Session Management - FIRST STEP
|
||||
Session detection and selection:
|
||||
```bash
|
||||
# Check for existing sessions
|
||||
existing_sessions=$(find .workflow/active/ -name "WFS-*" -type d 2>/dev/null)
|
||||
if [ multiple_sessions ]; then
|
||||
prompt_user_to_select_session()
|
||||
else
|
||||
use_existing_or_create_new()
|
||||
fi
|
||||
```
|
||||
|
||||
### Step 1: Context Gathering Phase
|
||||
**System Architect Perspective Questioning**
|
||||
|
||||
Before agent assignment, gather comprehensive system architecture context:
|
||||
|
||||
#### 📋 Role-Specific Questions
|
||||
1. **Scale & Performance Requirements**
|
||||
- Expected user load and traffic patterns?
|
||||
- Performance requirements (latency, throughput)?
|
||||
- Data volume and growth projections?
|
||||
|
||||
2. **Technical Constraints & Environment**
|
||||
- Existing technology stack and constraints?
|
||||
- Integration requirements with external systems?
|
||||
- Infrastructure and deployment environment?
|
||||
|
||||
3. **Architecture Complexity & Patterns**
|
||||
- Microservices vs monolithic considerations?
|
||||
- Data consistency and transaction requirements?
|
||||
- Event-driven vs request-response patterns?
|
||||
|
||||
4. **Non-Functional Requirements**
|
||||
- High availability and disaster recovery needs?
|
||||
- Security and compliance requirements?
|
||||
- Monitoring and observability expectations?
|
||||
|
||||
#### Context Validation
|
||||
- **Minimum Response**: Each answer must be ≥50 characters
|
||||
- **Re-prompting**: Insufficient detail triggers follow-up questions
|
||||
- **Context Storage**: Save responses to `.brainstorming/system-architect-context.md`
|
||||
|
||||
### Step 2: Agent Assignment with Flow Control
|
||||
**Dedicated Agent Execution**
|
||||
|
||||
```bash
|
||||
Task(conceptual-planning-agent): "
|
||||
[FLOW_CONTROL]
|
||||
|
||||
Execute dedicated system-architect conceptual analysis for: {topic}
|
||||
|
||||
ASSIGNED_ROLE: system-architect
|
||||
OUTPUT_LOCATION: .brainstorming/system-architect/
|
||||
USER_CONTEXT: {validated_responses_from_context_gathering}
|
||||
|
||||
Flow Control Steps:
|
||||
[
|
||||
{
|
||||
\"step\": \"load_role_template\",
|
||||
\"action\": \"Load system-architect planning template\",
|
||||
\"command\": \"bash($(cat ~/.claude/workflows/cli-templates/planning-roles/system-architect.md))\",
|
||||
\"output_to\": \"role_template\"
|
||||
}
|
||||
]
|
||||
|
||||
Conceptual Analysis Requirements:
|
||||
- Apply system-architect perspective to topic analysis
|
||||
- Focus on architectural patterns, scalability, and integration points
|
||||
- Use loaded role template framework for analysis structure
|
||||
- Generate role-specific deliverables in designated output location
|
||||
- Address all user context from questioning phase
|
||||
|
||||
Deliverables:
|
||||
- analysis.md: Main system architecture analysis
|
||||
- recommendations.md: Architecture recommendations
|
||||
- deliverables/: Architecture-specific outputs as defined in role template
|
||||
|
||||
Embody system-architect role expertise for comprehensive conceptual planning."
|
||||
```
|
||||
|
||||
### Progress Tracking
|
||||
TodoWrite tracking for two-step process:
|
||||
```json
|
||||
[
|
||||
{"content": "Gather system architect context through role-specific questioning", "status": "in_progress", "activeForm": "Gathering context"},
|
||||
{"content": "Validate context responses and save to system-architect-context.md", "status": "pending", "activeForm": "Validating context"},
|
||||
{"content": "Load system-architect planning template via flow control", "status": "pending", "activeForm": "Loading template"},
|
||||
{"content": "Execute dedicated conceptual-planning-agent for system-architect role", "status": "pending", "activeForm": "Executing agent"}
|
||||
]
|
||||
```
|
||||
|
||||
## 📊 **Output Specification**
|
||||
|
||||
### Output Location
|
||||
```
|
||||
.workflow/active/WFS-{topic-slug}/.brainstorming/system-architect/
|
||||
├── analysis.md # Primary architecture analysis
|
||||
├── architecture-design.md # Detailed system design and diagrams
|
||||
├── technology-stack.md # Technology stack recommendations and justifications
|
||||
└── integration-plan.md # System integration and API strategies
|
||||
```
|
||||
|
||||
### Document Templates
|
||||
|
||||
#### analysis.md Structure
|
||||
```markdown
|
||||
# System Architecture Analysis: {Topic}
|
||||
*Generated: {timestamp}*
|
||||
|
||||
## Executive Summary
|
||||
[Key architectural findings and recommendations overview]
|
||||
|
||||
## Current State Assessment
|
||||
### Existing Architecture Overview
|
||||
### Technical Stack Analysis
|
||||
### Performance Bottlenecks
|
||||
### Technical Debt Assessment
|
||||
|
||||
## Requirements Analysis
|
||||
### Functional Requirements
|
||||
### Non-Functional Requirements
|
||||
- Performance: [Response time, throughput requirements]
|
||||
- Scalability: [User growth, data volume expectations]
|
||||
- Availability: [Uptime requirements]
|
||||
- Security: [Security requirements]
|
||||
|
||||
## Proposed Architecture
|
||||
### High-Level Architecture Design
|
||||
### Component Breakdown
|
||||
### Data Flow Diagrams
|
||||
### Technology Stack Recommendations
|
||||
|
||||
## Implementation Strategy
|
||||
### Migration Planning
|
||||
### Risk Mitigation
|
||||
### Performance Optimization
|
||||
### Security Considerations
|
||||
|
||||
## Scalability and Maintenance
|
||||
### Horizontal Scaling Strategy
|
||||
### Monitoring and Observability
|
||||
### Deployment Strategy
|
||||
### Long-term Maintenance Plan
|
||||
```
|
||||
|
||||
## 🔄 **Session Integration**
|
||||
|
||||
### Status Synchronization
|
||||
Upon completion, update `workflow-session.json`:
|
||||
```json
|
||||
{
|
||||
"phases": {
|
||||
"BRAINSTORM": {
|
||||
"system_architect": {
|
||||
"status": "completed",
|
||||
"completed_at": "timestamp",
|
||||
"output_directory": ".workflow/active/WFS-{topic}/.brainstorming/system-architect/",
|
||||
"key_insights": ["scalability_bottleneck", "architecture_pattern", "technology_recommendation"]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### Cross-Role Collaboration
|
||||
System architect perspective provides:
|
||||
- **Technical Constraints and Possibilities** → Product Manager
|
||||
- **Architecture Requirements and Limitations** → UI Designer
|
||||
- **Data Architecture Requirements** → Data Architect
|
||||
- **Security Architecture Framework** → Security Expert
|
||||
- **Technical Implementation Framework** → Feature Planner
|
||||
|
||||
## ✅ **Quality Assurance**
|
||||
|
||||
### Required Analysis Elements
|
||||
- [ ] Clear architecture diagrams and component designs
|
||||
- [ ] Detailed technology stack evaluation and recommendations
|
||||
- [ ] Scalability and performance analysis with metrics
|
||||
- [ ] System integration and API design specifications
|
||||
- [ ] Comprehensive risk assessment and mitigation strategies
|
||||
|
||||
### Architecture Design Principles
|
||||
- [ ] **Scalability**: System can handle growth in users and data
|
||||
- [ ] **Maintainability**: Clear code structure, easy to modify and extend
|
||||
- [ ] **Reliability**: Built-in fault tolerance and recovery mechanisms
|
||||
- [ ] **Security**: Integrated security controls and protection measures
|
||||
- [ ] **Performance**: Meets response time and throughput requirements
|
||||
|
||||
### Technical Decision Validation
|
||||
- [ ] Technology choices have thorough justification and comparison analysis
|
||||
- [ ] Architectural patterns align with business requirements and constraints
|
||||
- [ ] Integration solutions consider compatibility and maintenance costs
|
||||
- [ ] Deployment strategies are feasible with acceptable risk levels
|
||||
- [ ] Monitoring and operations strategies are comprehensive and actionable
|
||||
|
||||
### Implementation Readiness
|
||||
- [ ] **Technical Feasibility**: All proposed solutions are technically achievable
|
||||
- [ ] **Resource Planning**: Resource requirements clearly defined and realistic
|
||||
- [ ] **Risk Management**: Technical risks identified with mitigation plans
|
||||
- [ ] **Performance Validation**: Architecture can meet performance requirements
|
||||
- [ ] **Evolution Strategy**: Design allows for future growth and changes
|
||||
@@ -1,221 +0,0 @@
|
||||
---
|
||||
name: ui-designer
|
||||
description: Generate or update ui-designer/analysis.md addressing guidance-specification discussion points for UI design perspective
|
||||
argument-hint: "optional topic - uses existing framework if available"
|
||||
allowed-tools: Task(conceptual-planning-agent), TodoWrite(*), Read(*), Write(*)
|
||||
---
|
||||
|
||||
## 🎨 **UI Designer Analysis Generator**
|
||||
|
||||
### Purpose
|
||||
**Specialized command for generating ui-designer/analysis.md** that addresses guidance-specification.md discussion points from UI/UX design perspective. Creates or updates role-specific analysis with framework references.
|
||||
|
||||
### Core Function
|
||||
- **Framework-based Analysis**: Address each discussion point in guidance-specification.md
|
||||
- **UI/UX Focus**: User experience, interface design, and accessibility perspective
|
||||
- **Update Mechanism**: Create new or update existing analysis.md
|
||||
- **Agent Delegation**: Use conceptual-planning-agent for analysis generation
|
||||
|
||||
### Analysis Scope
|
||||
- **Visual Design**: Color palettes, typography, spacing, and visual hierarchy implementation
|
||||
- **High-Fidelity Mockups**: Polished, pixel-perfect interface designs
|
||||
- **Design System Implementation**: Component libraries, design tokens, and style guides
|
||||
- **Micro-Interactions & Animations**: Transition effects, loading states, and interactive feedback
|
||||
- **Responsive Design**: Layout adaptations for different screen sizes and devices
|
||||
|
||||
### Role Boundaries & Responsibilities
|
||||
|
||||
#### **What This Role OWNS (Concrete Visual Interface Implementation)**
|
||||
- **Visual Design Language**: Colors, typography, iconography, spacing, and overall aesthetic
|
||||
- **High-Fidelity Mockups**: Polished designs showing exactly how the interface will look
|
||||
- **Design System Components**: Building and documenting reusable UI components (buttons, inputs, cards, etc.)
|
||||
- **Design Tokens**: Defining variables for colors, spacing, typography that can be used in code
|
||||
- **Micro-Interactions**: Hover states, transitions, animations, and interactive feedback details
|
||||
- **Responsive Layouts**: Adapting designs for mobile, tablet, and desktop breakpoints
|
||||
|
||||
#### **What This Role DOES NOT Own (Defers to Other Roles)**
|
||||
- **User Research & Personas**: User behavior analysis and needs assessment → Defers to **UX Expert**
|
||||
- **Information Architecture**: Content structure and navigation strategy → Defers to **UX Expert**
|
||||
- **Low-Fidelity Wireframes**: Structural layouts without visual design → Defers to **UX Expert**
|
||||
|
||||
#### **Handoff Points**
|
||||
- **FROM UX Expert**: Receives wireframes, user flows, and information architecture as the foundation for visual design
|
||||
- **TO Frontend Developers**: Provides design specifications, component libraries, and design tokens for implementation
|
||||
- **WITH API Designer**: Coordinates on data presentation and form validation feedback (visual aspects only)
|
||||
|
||||
## ⚙️ **Execution Protocol**
|
||||
|
||||
### Phase 1: Session & Framework Detection
|
||||
```bash
|
||||
# Check active session and framework
|
||||
CHECK: find .workflow/active/ -name "WFS-*" -type d
|
||||
IF active_session EXISTS:
|
||||
session_id = get_active_session()
|
||||
brainstorm_dir = .workflow/active/WFS-{session}/.brainstorming/
|
||||
|
||||
CHECK: brainstorm_dir/guidance-specification.md
|
||||
IF EXISTS:
|
||||
framework_mode = true
|
||||
load_framework = true
|
||||
ELSE:
|
||||
IF topic_provided:
|
||||
framework_mode = false # Create analysis without framework
|
||||
ELSE:
|
||||
ERROR: "No framework found and no topic provided"
|
||||
```
|
||||
|
||||
### Phase 2: Analysis Mode Detection
|
||||
```bash
|
||||
# Determine execution mode
|
||||
IF framework_mode == true:
|
||||
mode = "framework_based_analysis"
|
||||
topic_ref = load_framework_topic()
|
||||
discussion_points = extract_framework_points()
|
||||
ELSE:
|
||||
mode = "standalone_analysis"
|
||||
topic_ref = provided_topic
|
||||
discussion_points = generate_basic_structure()
|
||||
```
|
||||
|
||||
### Phase 3: Agent Execution with Flow Control
|
||||
**Framework-Based Analysis Generation**
|
||||
|
||||
```bash
|
||||
Task(conceptual-planning-agent): "
|
||||
[FLOW_CONTROL]
|
||||
|
||||
Execute ui-designer analysis for existing topic framework
|
||||
|
||||
## Context Loading
|
||||
ASSIGNED_ROLE: ui-designer
|
||||
OUTPUT_LOCATION: .workflow/active/WFS-{session}/.brainstorming/ui-designer/
|
||||
ANALYSIS_MODE: {framework_mode ? "framework_based" : "standalone"}
|
||||
|
||||
## Flow Control Steps
|
||||
1. **load_topic_framework**
|
||||
- Action: Load structured topic discussion framework
|
||||
- Command: Read(.workflow/active/WFS-{session}/.brainstorming/guidance-specification.md)
|
||||
- Output: topic_framework_content
|
||||
|
||||
2. **load_role_template**
|
||||
- Action: Load ui-designer planning template
|
||||
- Command: bash($(cat ~/.claude/workflows/cli-templates/planning-roles/ui-designer.md))
|
||||
- Output: role_template_guidelines
|
||||
|
||||
3. **load_session_metadata**
|
||||
- Action: Load session metadata and existing context
|
||||
- Command: Read(.workflow/active/WFS-{session}/workflow-session.json)
|
||||
- Output: session_context
|
||||
|
||||
## Analysis Requirements
|
||||
**Framework Reference**: Address all discussion points in guidance-specification.md from UI/UX perspective
|
||||
**Role Focus**: User experience design, interface optimization, accessibility compliance
|
||||
**Structured Approach**: Create analysis.md addressing framework discussion points
|
||||
**Template Integration**: Apply role template guidelines within framework structure
|
||||
|
||||
## Expected Deliverables
|
||||
1. **analysis.md**: Comprehensive UI/UX analysis addressing all framework discussion points
|
||||
2. **Framework Reference**: Include @../guidance-specification.md reference in analysis
|
||||
|
||||
## Completion Criteria
|
||||
- Address each discussion point from guidance-specification.md with UI/UX design expertise
|
||||
- Provide actionable design recommendations and interface solutions
|
||||
- Include accessibility considerations and WCAG compliance planning
|
||||
- Reference framework document using @ notation for integration
|
||||
"
|
||||
```
|
||||
|
||||
## 📋 **TodoWrite Integration**
|
||||
|
||||
### Workflow Progress Tracking
|
||||
```javascript
|
||||
TodoWrite({
|
||||
todos: [
|
||||
{
|
||||
content: "Detect active session and locate topic framework",
|
||||
status: "in_progress",
|
||||
activeForm: "Detecting session and framework"
|
||||
},
|
||||
{
|
||||
content: "Load guidance-specification.md and session metadata for context",
|
||||
status: "pending",
|
||||
activeForm: "Loading framework and session context"
|
||||
},
|
||||
{
|
||||
content: "Execute ui-designer analysis using conceptual-planning-agent with FLOW_CONTROL",
|
||||
status: "pending",
|
||||
activeForm: "Executing ui-designer framework analysis"
|
||||
},
|
||||
{
|
||||
content: "Generate analysis.md addressing all framework discussion points",
|
||||
status: "pending",
|
||||
activeForm: "Generating structured ui-designer analysis"
|
||||
},
|
||||
{
|
||||
content: "Update workflow-session.json with ui-designer completion status",
|
||||
status: "pending",
|
||||
activeForm: "Updating session metadata"
|
||||
}
|
||||
]
|
||||
});
|
||||
```
|
||||
|
||||
## 📊 **Output Structure**
|
||||
|
||||
### Framework-Based Analysis
|
||||
```
|
||||
.workflow/active/WFS-{session}/.brainstorming/ui-designer/
|
||||
└── analysis.md # Structured analysis addressing guidance-specification.md discussion points
|
||||
```
|
||||
|
||||
### Analysis Document Structure
|
||||
```markdown
|
||||
# UI Designer Analysis: [Topic from Framework]
|
||||
|
||||
## Framework Reference
|
||||
**Topic Framework**: @../guidance-specification.md
|
||||
**Role Focus**: UI/UX Design perspective
|
||||
|
||||
## Discussion Points Analysis
|
||||
[Address each point from guidance-specification.md with UI/UX expertise]
|
||||
|
||||
### Core Requirements (from framework)
|
||||
[UI/UX perspective on requirements]
|
||||
|
||||
### Technical Considerations (from framework)
|
||||
[Interface and design system considerations]
|
||||
|
||||
### User Experience Factors (from framework)
|
||||
[Detailed UX analysis and recommendations]
|
||||
|
||||
### Implementation Challenges (from framework)
|
||||
[Design implementation and accessibility considerations]
|
||||
|
||||
### Success Metrics (from framework)
|
||||
[UX metrics and usability success criteria]
|
||||
|
||||
## UI/UX Specific Recommendations
|
||||
[Role-specific design recommendations and solutions]
|
||||
|
||||
---
|
||||
*Generated by ui-designer analysis addressing structured framework*
|
||||
```
|
||||
|
||||
## 🔄 **Session Integration**
|
||||
|
||||
### Completion Status Update
|
||||
```json
|
||||
{
|
||||
"ui_designer": {
|
||||
"status": "completed",
|
||||
"framework_addressed": true,
|
||||
"output_location": ".workflow/active/WFS-{session}/.brainstorming/ui-designer/analysis.md",
|
||||
"framework_reference": "@../guidance-specification.md"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### Integration Points
|
||||
- **Framework Reference**: @../guidance-specification.md for structured discussion points
|
||||
- **Cross-Role Synthesis**: UI/UX insights available for synthesis-report.md integration
|
||||
- **Agent Autonomy**: Independent execution with framework guidance
|
||||
@@ -1,221 +0,0 @@
|
||||
---
|
||||
name: ux-expert
|
||||
description: Generate or update ux-expert/analysis.md addressing guidance-specification discussion points for UX perspective
|
||||
argument-hint: "optional topic - uses existing framework if available"
|
||||
allowed-tools: Task(conceptual-planning-agent), TodoWrite(*), Read(*), Write(*)
|
||||
---
|
||||
|
||||
## 🎯 **UX Expert Analysis Generator**
|
||||
|
||||
### Purpose
|
||||
**Specialized command for generating ux-expert/analysis.md** that addresses guidance-specification.md discussion points from user experience and interface design perspective. Creates or updates role-specific analysis with framework references.
|
||||
|
||||
### Core Function
|
||||
- **Framework-based Analysis**: Address each discussion point in guidance-specification.md
|
||||
- **UX Design Focus**: User interface, interaction patterns, and usability optimization
|
||||
- **Update Mechanism**: Create new or update existing analysis.md
|
||||
- **Agent Delegation**: Use conceptual-planning-agent for analysis generation
|
||||
|
||||
### Analysis Scope
|
||||
- **User Research**: User personas, behavioral analysis, and needs assessment
|
||||
- **Information Architecture**: Content structure, navigation hierarchy, and mental models
|
||||
- **User Journey Mapping**: User flows, task analysis, and interaction models
|
||||
- **Usability Strategy**: Accessibility planning, cognitive load reduction, and user testing frameworks
|
||||
- **Wireframing**: Low-fidelity layouts and structural prototypes (not visual design)
|
||||
|
||||
### Role Boundaries & Responsibilities
|
||||
|
||||
#### **What This Role OWNS (Abstract User Experience & Research)**
|
||||
- **User Research & Personas**: Understanding target users, their goals, pain points, and behaviors
|
||||
- **Information Architecture**: Organizing content and defining navigation structures at a conceptual level
|
||||
- **User Journey Mapping**: Defining user flows, task sequences, and interaction models
|
||||
- **Wireframes & Low-Fidelity Prototypes**: Structural layouts showing information hierarchy (boxes and arrows, not colors/fonts)
|
||||
- **Usability Testing Strategy**: Planning user testing, A/B tests, and validation methods
|
||||
- **Accessibility Planning**: WCAG compliance strategy and inclusive design principles
|
||||
|
||||
#### **What This Role DOES NOT Own (Defers to Other Roles)**
|
||||
- **Visual Design**: Colors, typography, spacing, visual style → Defers to **UI Designer**
|
||||
- **High-Fidelity Mockups**: Polished, pixel-perfect designs → Defers to **UI Designer**
|
||||
- **Component Implementation**: Design system components, CSS, animations → Defers to **UI Designer**
|
||||
|
||||
#### **Handoff Points**
|
||||
- **TO UI Designer**: Provides wireframes, user flows, and information architecture that UI Designer will transform into high-fidelity visual designs
|
||||
- **FROM User Research**: May receive external research data to inform UX decisions
|
||||
- **TO Product Owner**: Provides user insights and validation results to inform feature prioritization
|
||||
|
||||
## ⚙️ **Execution Protocol**
|
||||
|
||||
### Phase 1: Session & Framework Detection
|
||||
```bash
|
||||
# Check active session and framework
|
||||
CHECK: find .workflow/active/ -name "WFS-*" -type d
|
||||
IF active_session EXISTS:
|
||||
session_id = get_active_session()
|
||||
brainstorm_dir = .workflow/active/WFS-{session}/.brainstorming/
|
||||
|
||||
CHECK: brainstorm_dir/guidance-specification.md
|
||||
IF EXISTS:
|
||||
framework_mode = true
|
||||
load_framework = true
|
||||
ELSE:
|
||||
IF topic_provided:
|
||||
framework_mode = false # Create analysis without framework
|
||||
ELSE:
|
||||
ERROR: "No framework found and no topic provided"
|
||||
```
|
||||
|
||||
### Phase 2: Analysis Mode Detection
|
||||
```bash
|
||||
# Determine execution mode
|
||||
IF framework_mode == true:
|
||||
mode = "framework_based_analysis"
|
||||
topic_ref = load_framework_topic()
|
||||
discussion_points = extract_framework_points()
|
||||
ELSE:
|
||||
mode = "standalone_analysis"
|
||||
topic_ref = provided_topic
|
||||
discussion_points = generate_basic_structure()
|
||||
```
|
||||
|
||||
### Phase 3: Agent Execution with Flow Control
|
||||
**Framework-Based Analysis Generation**
|
||||
|
||||
```bash
|
||||
Task(conceptual-planning-agent): "
|
||||
[FLOW_CONTROL]
|
||||
|
||||
Execute ux-expert analysis for existing topic framework
|
||||
|
||||
## Context Loading
|
||||
ASSIGNED_ROLE: ux-expert
|
||||
OUTPUT_LOCATION: .workflow/active/WFS-{session}/.brainstorming/ux-expert/
|
||||
ANALYSIS_MODE: {framework_mode ? "framework_based" : "standalone"}
|
||||
|
||||
## Flow Control Steps
|
||||
1. **load_topic_framework**
|
||||
- Action: Load structured topic discussion framework
|
||||
- Command: Read(.workflow/active/WFS-{session}/.brainstorming/guidance-specification.md)
|
||||
- Output: topic_framework_content
|
||||
|
||||
2. **load_role_template**
|
||||
- Action: Load ux-expert planning template
|
||||
- Command: bash($(cat ~/.claude/workflows/cli-templates/planning-roles/ux-expert.md))
|
||||
- Output: role_template_guidelines
|
||||
|
||||
3. **load_session_metadata**
|
||||
- Action: Load session metadata and existing context
|
||||
- Command: Read(.workflow/active/WFS-{session}/workflow-session.json)
|
||||
- Output: session_context
|
||||
|
||||
## Analysis Requirements
|
||||
**Framework Reference**: Address all discussion points in guidance-specification.md from user experience and interface design perspective
|
||||
**Role Focus**: UI design, interaction patterns, usability optimization, design systems
|
||||
**Structured Approach**: Create analysis.md addressing framework discussion points
|
||||
**Template Integration**: Apply role template guidelines within framework structure
|
||||
|
||||
## Expected Deliverables
|
||||
1. **analysis.md**: Comprehensive UX design analysis addressing all framework discussion points
|
||||
2. **Framework Reference**: Include @../guidance-specification.md reference in analysis
|
||||
|
||||
## Completion Criteria
|
||||
- Address each discussion point from guidance-specification.md with UX design expertise
|
||||
- Provide actionable interface design and usability optimization strategies
|
||||
- Include accessibility considerations and interaction pattern recommendations
|
||||
- Reference framework document using @ notation for integration
|
||||
"
|
||||
```
|
||||
|
||||
## 📋 **TodoWrite Integration**
|
||||
|
||||
### Workflow Progress Tracking
|
||||
```javascript
|
||||
TodoWrite({
|
||||
todos: [
|
||||
{
|
||||
content: "Detect active session and locate topic framework",
|
||||
status: "in_progress",
|
||||
activeForm: "Detecting session and framework"
|
||||
},
|
||||
{
|
||||
content: "Load guidance-specification.md and session metadata for context",
|
||||
status: "pending",
|
||||
activeForm: "Loading framework and session context"
|
||||
},
|
||||
{
|
||||
content: "Execute ux-expert analysis using conceptual-planning-agent with FLOW_CONTROL",
|
||||
status: "pending",
|
||||
activeForm: "Executing ux-expert framework analysis"
|
||||
},
|
||||
{
|
||||
content: "Generate analysis.md addressing all framework discussion points",
|
||||
status: "pending",
|
||||
activeForm: "Generating structured ux-expert analysis"
|
||||
},
|
||||
{
|
||||
content: "Update workflow-session.json with ux-expert completion status",
|
||||
status: "pending",
|
||||
activeForm: "Updating session metadata"
|
||||
}
|
||||
]
|
||||
});
|
||||
```
|
||||
|
||||
## 📊 **Output Structure**
|
||||
|
||||
### Framework-Based Analysis
|
||||
```
|
||||
.workflow/active/WFS-{session}/.brainstorming/ux-expert/
|
||||
└── analysis.md # Structured analysis addressing guidance-specification.md discussion points
|
||||
```
|
||||
|
||||
### Analysis Document Structure
|
||||
```markdown
|
||||
# UX Expert Analysis: [Topic from Framework]
|
||||
|
||||
## Framework Reference
|
||||
**Topic Framework**: @../guidance-specification.md
|
||||
**Role Focus**: User Experience & Interface Design perspective
|
||||
|
||||
## Discussion Points Analysis
|
||||
[Address each point from guidance-specification.md with UX design expertise]
|
||||
|
||||
### Core Requirements (from framework)
|
||||
[User interface and interaction design requirements perspective]
|
||||
|
||||
### Technical Considerations (from framework)
|
||||
[Design system implementation and technical feasibility considerations]
|
||||
|
||||
### User Experience Factors (from framework)
|
||||
[Usability optimization, accessibility, and user-centered design analysis]
|
||||
|
||||
### Implementation Challenges (from framework)
|
||||
[Design implementation challenges and progressive enhancement strategies]
|
||||
|
||||
### Success Metrics (from framework)
|
||||
[UX metrics including usability testing, user satisfaction, and design KPIs]
|
||||
|
||||
## UX Expert Specific Recommendations
|
||||
[Role-specific interface design patterns and usability optimization strategies]
|
||||
|
||||
---
|
||||
*Generated by ux-expert analysis addressing structured framework*
|
||||
```
|
||||
|
||||
## 🔄 **Session Integration**
|
||||
|
||||
### Completion Status Update
|
||||
```json
|
||||
{
|
||||
"ux_expert": {
|
||||
"status": "completed",
|
||||
"framework_addressed": true,
|
||||
"output_location": ".workflow/active/WFS-{session}/.brainstorming/ux-expert/analysis.md",
|
||||
"framework_reference": "@../guidance-specification.md"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### Integration Points
|
||||
- **Framework Reference**: @../guidance-specification.md for structured discussion points
|
||||
- **Cross-Role Synthesis**: UX design insights available for synthesis-report.md integration
|
||||
- **Agent Autonomy**: Independent execution with framework guidance
|
||||
548
.claude/commands/workflow/clean.md
Normal file
548
.claude/commands/workflow/clean.md
Normal file
@@ -0,0 +1,548 @@
|
||||
---
|
||||
name: clean
|
||||
description: Intelligent code cleanup with mainline detection, stale artifact discovery, and safe execution
|
||||
argument-hint: "[-y|--yes] [--dry-run] [\"focus area\"]"
|
||||
allowed-tools: TodoWrite(*), Task(*), AskUserQuestion(*), Read(*), Glob(*), Bash(*), Write(*)
|
||||
---
|
||||
|
||||
# Clean Command (/workflow:clean)
|
||||
|
||||
## Overview
|
||||
|
||||
Intelligent cleanup command that explores the codebase to identify the development mainline, discovers artifacts that have drifted from it, and safely removes stale sessions, abandoned documents, and dead code.
|
||||
|
||||
**Core capabilities:**
|
||||
- Mainline detection: Identify active development branches and core modules
|
||||
- Drift analysis: Find sessions, documents, and code that deviate from mainline
|
||||
- Intelligent discovery: cli-explore-agent based artifact scanning
|
||||
- Safe execution: Confirmation-based cleanup with dry-run preview
|
||||
|
||||
## Usage
|
||||
|
||||
```bash
|
||||
/workflow:clean # Full intelligent cleanup (explore → analyze → confirm → execute)
|
||||
/workflow:clean --yes # Auto mode (use safe defaults, no confirmation)
|
||||
/workflow:clean --dry-run # Explore and analyze only, no execution
|
||||
/workflow:clean -y "auth module" # Auto mode with focus area
|
||||
```
|
||||
|
||||
## Auto Mode Defaults
|
||||
|
||||
When `--yes` or `-y` flag is used:
|
||||
- **Categories to Clean**: Auto-selects `["Sessions"]` only (safest - only workflow sessions)
|
||||
- **Risk Level**: Auto-selects `"Low only"` (only low-risk items)
|
||||
- All confirmations skipped, proceeds directly to execution
|
||||
|
||||
**Flag Parsing**:
|
||||
```javascript
|
||||
const autoYes = $ARGUMENTS.includes('--yes') || $ARGUMENTS.includes('-y')
|
||||
const dryRun = $ARGUMENTS.includes('--dry-run')
|
||||
```
|
||||
|
||||
## Execution Process
|
||||
|
||||
```
|
||||
Phase 1: Mainline Detection
|
||||
├─ Analyze git history for development trends
|
||||
├─ Identify core modules (high commit frequency)
|
||||
├─ Map active vs stale branches
|
||||
└─ Build mainline profile
|
||||
|
||||
Phase 2: Drift Discovery (cli-explore-agent)
|
||||
├─ Scan workflow sessions for orphaned artifacts
|
||||
├─ Identify documents drifted from mainline
|
||||
├─ Detect dead code and unused exports
|
||||
└─ Generate cleanup manifest
|
||||
|
||||
Phase 3: Confirmation
|
||||
├─ Display cleanup summary by category
|
||||
├─ Show impact analysis (files, size, risk)
|
||||
└─ AskUserQuestion: Select categories to clean
|
||||
|
||||
Phase 4: Execution (unless --dry-run)
|
||||
├─ Execute cleanup by category
|
||||
├─ Update manifests and indexes
|
||||
└─ Report results
|
||||
```
|
||||
|
||||
## Implementation
|
||||
|
||||
### Phase 1: Mainline Detection
|
||||
|
||||
**Session Setup**:
|
||||
```javascript
|
||||
const getUtc8ISOString = () => new Date(Date.now() + 8 * 60 * 60 * 1000).toISOString()
|
||||
|
||||
const dateStr = getUtc8ISOString().substring(0, 10)
|
||||
const sessionId = `clean-${dateStr}`
|
||||
const sessionFolder = `.workflow/.clean/${sessionId}`
|
||||
|
||||
Bash(`mkdir -p ${sessionFolder}`)
|
||||
```
|
||||
|
||||
**Step 1.1: Git History Analysis**
|
||||
```bash
|
||||
# Get commit frequency by directory (last 30 days)
|
||||
bash(git log --since="30 days ago" --name-only --pretty=format: | grep -v "^$" | cut -d/ -f1-2 | sort | uniq -c | sort -rn | head -20)
|
||||
|
||||
# Get recent active branches
|
||||
bash(git for-each-ref --sort=-committerdate refs/heads/ --format='%(refname:short) %(committerdate:relative)' | head -10)
|
||||
|
||||
# Get files with most recent changes
|
||||
bash(git log --since="7 days ago" --name-only --pretty=format: | grep -v "^$" | sort | uniq -c | sort -rn | head -30)
|
||||
```
|
||||
|
||||
**Step 1.2: Build Mainline Profile**
|
||||
```javascript
|
||||
const mainlineProfile = {
|
||||
coreModules: [], // High-frequency directories
|
||||
activeFiles: [], // Recently modified files
|
||||
activeBranches: [], // Branches with recent commits
|
||||
staleThreshold: {
|
||||
sessions: 7, // Days
|
||||
branches: 30,
|
||||
documents: 14
|
||||
},
|
||||
timestamp: getUtc8ISOString()
|
||||
}
|
||||
|
||||
// Parse git log output to identify core modules
|
||||
// Modules with >5 commits in last 30 days = core
|
||||
// Modules with 0 commits in last 30 days = potentially stale
|
||||
|
||||
Write(`${sessionFolder}/mainline-profile.json`, JSON.stringify(mainlineProfile, null, 2))
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### Phase 2: Drift Discovery
|
||||
|
||||
**Launch cli-explore-agent for intelligent artifact scanning**:
|
||||
|
||||
```javascript
|
||||
Task(
|
||||
subagent_type="cli-explore-agent",
|
||||
run_in_background=false,
|
||||
description="Discover stale artifacts",
|
||||
prompt=`
|
||||
## Task Objective
|
||||
Discover artifacts that have drifted from the development mainline. Identify stale sessions, abandoned documents, and dead code for cleanup.
|
||||
|
||||
## Context
|
||||
- **Session Folder**: ${sessionFolder}
|
||||
- **Mainline Profile**: ${sessionFolder}/mainline-profile.json
|
||||
- **Focus Area**: ${focusArea || "全项目"}
|
||||
|
||||
## Discovery Categories
|
||||
|
||||
### Category 1: Stale Workflow Sessions
|
||||
Scan and analyze workflow session directories:
|
||||
|
||||
**Locations to scan**:
|
||||
- .workflow/active/WFS-* (active sessions)
|
||||
- .workflow/archives/WFS-* (archived sessions)
|
||||
- .workflow/.lite-plan/* (lite-plan sessions)
|
||||
- .workflow/.debug/DBG-* (debug sessions)
|
||||
|
||||
**Staleness criteria**:
|
||||
- Active sessions: No modification >7 days + no related git commits
|
||||
- Archives: >30 days old + no feature references in project-tech.json
|
||||
- Lite-plan: >7 days old + plan.json not executed
|
||||
- Debug: >3 days old + issue not in recent commits
|
||||
|
||||
**Analysis steps**:
|
||||
1. List all session directories with modification times
|
||||
2. Cross-reference with git log (are session topics in recent commits?)
|
||||
3. Check manifest.json for orphan entries
|
||||
4. Identify sessions with .archiving marker (interrupted)
|
||||
|
||||
### Category 2: Drifted Documents
|
||||
Scan documentation that no longer aligns with code:
|
||||
|
||||
**Locations to scan**:
|
||||
- .claude/rules/tech/* (generated tech rules)
|
||||
- .workflow/.scratchpad/* (temporary notes)
|
||||
- **/CLAUDE.md (module documentation)
|
||||
- **/README.md (outdated descriptions)
|
||||
|
||||
**Drift criteria**:
|
||||
- Tech rules: Referenced files no longer exist
|
||||
- Scratchpad: Any file (always temporary)
|
||||
- Module docs: Describe functions/classes that were removed
|
||||
- READMEs: Reference deleted directories
|
||||
|
||||
**Analysis steps**:
|
||||
1. Parse document content for file/function references
|
||||
2. Verify referenced entities still exist in codebase
|
||||
3. Flag documents with >30% broken references
|
||||
|
||||
### Category 3: Dead Code
|
||||
Identify code that is no longer used:
|
||||
|
||||
**Scan patterns**:
|
||||
- Unused exports (exported but never imported)
|
||||
- Orphan files (not imported anywhere)
|
||||
- Commented-out code blocks (>10 lines)
|
||||
- TODO/FIXME comments >90 days old
|
||||
|
||||
**Analysis steps**:
|
||||
1. Build import graph using rg/grep
|
||||
2. Identify exports with no importers
|
||||
3. Find files not in import graph
|
||||
4. Scan for large comment blocks
|
||||
|
||||
## Output Format
|
||||
|
||||
Write to: ${sessionFolder}/cleanup-manifest.json
|
||||
|
||||
\`\`\`json
|
||||
{
|
||||
"generated_at": "ISO timestamp",
|
||||
"mainline_summary": {
|
||||
"core_modules": ["src/core", "src/api"],
|
||||
"active_branches": ["main", "feature/auth"],
|
||||
"health_score": 0.85
|
||||
},
|
||||
"discoveries": {
|
||||
"stale_sessions": [
|
||||
{
|
||||
"path": ".workflow/active/WFS-old-feature",
|
||||
"type": "active",
|
||||
"age_days": 15,
|
||||
"reason": "No related commits in 15 days",
|
||||
"size_kb": 1024,
|
||||
"risk": "low"
|
||||
}
|
||||
],
|
||||
"drifted_documents": [
|
||||
{
|
||||
"path": ".claude/rules/tech/deprecated-lib",
|
||||
"type": "tech_rules",
|
||||
"broken_references": 5,
|
||||
"total_references": 6,
|
||||
"drift_percentage": 83,
|
||||
"reason": "Referenced library removed",
|
||||
"risk": "low"
|
||||
}
|
||||
],
|
||||
"dead_code": [
|
||||
{
|
||||
"path": "src/utils/legacy.ts",
|
||||
"type": "orphan_file",
|
||||
"reason": "Not imported by any file",
|
||||
"last_modified": "2025-10-01",
|
||||
"risk": "medium"
|
||||
}
|
||||
]
|
||||
},
|
||||
"summary": {
|
||||
"total_items": 12,
|
||||
"total_size_mb": 45.2,
|
||||
"by_category": {
|
||||
"stale_sessions": 5,
|
||||
"drifted_documents": 4,
|
||||
"dead_code": 3
|
||||
},
|
||||
"by_risk": {
|
||||
"low": 8,
|
||||
"medium": 3,
|
||||
"high": 1
|
||||
}
|
||||
}
|
||||
}
|
||||
\`\`\`
|
||||
|
||||
## Execution Commands
|
||||
|
||||
\`\`\`bash
|
||||
# Session directories
|
||||
find .workflow -type d -name "WFS-*" -o -name "DBG-*" 2>/dev/null
|
||||
|
||||
# Check modification times (Linux/Mac)
|
||||
stat -c "%Y %n" .workflow/active/WFS-* 2>/dev/null
|
||||
|
||||
# Check modification times (Windows PowerShell via bash)
|
||||
powershell -Command "Get-ChildItem '.workflow/active/WFS-*' | ForEach-Object { Write-Output \"$($_.LastWriteTime) $($_.FullName)\" }"
|
||||
|
||||
# Find orphan exports (TypeScript)
|
||||
rg "export (const|function|class|interface|type)" --type ts -l
|
||||
|
||||
# Find imports
|
||||
rg "import.*from" --type ts
|
||||
|
||||
# Find large comment blocks
|
||||
rg "^\\s*/\\*" -A 10 --type ts
|
||||
|
||||
# Find old TODOs
|
||||
rg "TODO|FIXME" --type ts -n
|
||||
\`\`\`
|
||||
|
||||
## Success Criteria
|
||||
- [ ] All session directories scanned with age calculation
|
||||
- [ ] Documents cross-referenced with existing code
|
||||
- [ ] Dead code detection via import graph analysis
|
||||
- [ ] cleanup-manifest.json written with complete data
|
||||
- [ ] Each item has risk level and cleanup reason
|
||||
`
|
||||
)
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### Phase 3: Confirmation
|
||||
|
||||
**Step 3.1: Display Summary**
|
||||
```javascript
|
||||
const manifest = JSON.parse(Read(`${sessionFolder}/cleanup-manifest.json`))
|
||||
|
||||
console.log(`
|
||||
## Cleanup Discovery Report
|
||||
|
||||
**Mainline Health**: ${Math.round(manifest.mainline_summary.health_score * 100)}%
|
||||
**Core Modules**: ${manifest.mainline_summary.core_modules.join(', ')}
|
||||
|
||||
### Summary
|
||||
| Category | Count | Size | Risk |
|
||||
|----------|-------|------|------|
|
||||
| Stale Sessions | ${manifest.summary.by_category.stale_sessions} | - | ${getRiskSummary('sessions')} |
|
||||
| Drifted Documents | ${manifest.summary.by_category.drifted_documents} | - | ${getRiskSummary('documents')} |
|
||||
| Dead Code | ${manifest.summary.by_category.dead_code} | - | ${getRiskSummary('code')} |
|
||||
|
||||
**Total**: ${manifest.summary.total_items} items, ~${manifest.summary.total_size_mb} MB
|
||||
|
||||
### Stale Sessions
|
||||
${manifest.discoveries.stale_sessions.map(s =>
|
||||
`- ${s.path} (${s.age_days}d, ${s.risk}): ${s.reason}`
|
||||
).join('\n')}
|
||||
|
||||
### Drifted Documents
|
||||
${manifest.discoveries.drifted_documents.map(d =>
|
||||
`- ${d.path} (${d.drift_percentage}% broken, ${d.risk}): ${d.reason}`
|
||||
).join('\n')}
|
||||
|
||||
### Dead Code
|
||||
${manifest.discoveries.dead_code.map(c =>
|
||||
`- ${c.path} (${c.type}, ${c.risk}): ${c.reason}`
|
||||
).join('\n')}
|
||||
`)
|
||||
```
|
||||
|
||||
**Step 3.2: Dry-Run Exit**
|
||||
```javascript
|
||||
if (flags.includes('--dry-run')) {
|
||||
console.log(`
|
||||
---
|
||||
**Dry-run mode**: No changes made.
|
||||
Manifest saved to: ${sessionFolder}/cleanup-manifest.json
|
||||
|
||||
To execute cleanup: /workflow:clean
|
||||
`)
|
||||
return
|
||||
}
|
||||
```
|
||||
|
||||
**Step 3.3: User Confirmation**
|
||||
```javascript
|
||||
// Parse --yes flag
|
||||
const autoYes = $ARGUMENTS.includes('--yes') || $ARGUMENTS.includes('-y')
|
||||
|
||||
let userSelection
|
||||
|
||||
if (autoYes) {
|
||||
// Auto mode: Use safe defaults
|
||||
console.log(`[--yes] Auto-selecting safe cleanup defaults:`)
|
||||
console.log(` - Categories: Sessions only`)
|
||||
console.log(` - Risk level: Low only`)
|
||||
|
||||
userSelection = {
|
||||
categories: ["Sessions"],
|
||||
risk: "Low only"
|
||||
}
|
||||
} else {
|
||||
// Interactive mode: Ask user
|
||||
userSelection = AskUserQuestion({
|
||||
questions: [
|
||||
{
|
||||
question: "Which categories to clean?",
|
||||
header: "Categories",
|
||||
multiSelect: true,
|
||||
options: [
|
||||
{
|
||||
label: "Sessions",
|
||||
description: `${manifest.summary.by_category.stale_sessions} stale workflow sessions`
|
||||
},
|
||||
{
|
||||
label: "Documents",
|
||||
description: `${manifest.summary.by_category.drifted_documents} drifted documents`
|
||||
},
|
||||
{
|
||||
label: "Dead Code",
|
||||
description: `${manifest.summary.by_category.dead_code} unused code files`
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
question: "Risk level to include?",
|
||||
header: "Risk",
|
||||
multiSelect: false,
|
||||
options: [
|
||||
{ label: "Low only", description: "Safest - only obviously stale items" },
|
||||
{ label: "Low + Medium", description: "Recommended - includes likely unused items" },
|
||||
{ label: "All", description: "Aggressive - includes high-risk items" }
|
||||
]
|
||||
}
|
||||
]
|
||||
})
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### Phase 4: Execution
|
||||
|
||||
**Step 4.1: Filter Items by Selection**
|
||||
```javascript
|
||||
const selectedCategories = userSelection.categories // ['Sessions', 'Documents', ...]
|
||||
const riskLevel = userSelection.risk // 'Low only', 'Low + Medium', 'All'
|
||||
|
||||
const riskFilter = {
|
||||
'Low only': ['low'],
|
||||
'Low + Medium': ['low', 'medium'],
|
||||
'All': ['low', 'medium', 'high']
|
||||
}[riskLevel]
|
||||
|
||||
const itemsToClean = []
|
||||
|
||||
if (selectedCategories.includes('Sessions')) {
|
||||
itemsToClean.push(...manifest.discoveries.stale_sessions.filter(s => riskFilter.includes(s.risk)))
|
||||
}
|
||||
if (selectedCategories.includes('Documents')) {
|
||||
itemsToClean.push(...manifest.discoveries.drifted_documents.filter(d => riskFilter.includes(d.risk)))
|
||||
}
|
||||
if (selectedCategories.includes('Dead Code')) {
|
||||
itemsToClean.push(...manifest.discoveries.dead_code.filter(c => riskFilter.includes(c.risk)))
|
||||
}
|
||||
|
||||
TodoWrite({
|
||||
todos: itemsToClean.map(item => ({
|
||||
content: `Clean: ${item.path}`,
|
||||
status: "pending",
|
||||
activeForm: `Cleaning ${item.path}`
|
||||
}))
|
||||
})
|
||||
```
|
||||
|
||||
**Step 4.2: Execute Cleanup**
|
||||
```javascript
|
||||
const results = { deleted: [], failed: [], skipped: [] }
|
||||
|
||||
for (const item of itemsToClean) {
|
||||
TodoWrite({ todos: [...] }) // Mark current as in_progress
|
||||
|
||||
try {
|
||||
if (item.type === 'orphan_file' || item.type === 'dead_export') {
|
||||
// Dead code: Delete file or remove export
|
||||
Bash({ command: `rm -rf "${item.path}"` })
|
||||
} else {
|
||||
// Sessions and documents: Delete directory/file
|
||||
Bash({ command: `rm -rf "${item.path}"` })
|
||||
}
|
||||
|
||||
results.deleted.push(item.path)
|
||||
TodoWrite({ todos: [...] }) // Mark as completed
|
||||
} catch (error) {
|
||||
results.failed.push({ path: item.path, error: error.message })
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
**Step 4.3: Update Manifests**
|
||||
```javascript
|
||||
// Update archives manifest if sessions were deleted
|
||||
if (selectedCategories.includes('Sessions')) {
|
||||
const archiveManifestPath = '.workflow/archives/manifest.json'
|
||||
if (fileExists(archiveManifestPath)) {
|
||||
const archiveManifest = JSON.parse(Read(archiveManifestPath))
|
||||
const deletedSessionIds = results.deleted
|
||||
.filter(p => p.includes('WFS-'))
|
||||
.map(p => p.split('/').pop())
|
||||
|
||||
const updatedManifest = archiveManifest.filter(entry =>
|
||||
!deletedSessionIds.includes(entry.session_id)
|
||||
)
|
||||
|
||||
Write(archiveManifestPath, JSON.stringify(updatedManifest, null, 2))
|
||||
}
|
||||
}
|
||||
|
||||
// Update project-tech.json if features referenced deleted sessions
|
||||
const projectPath = '.workflow/project-tech.json'
|
||||
if (fileExists(projectPath)) {
|
||||
const project = JSON.parse(Read(projectPath))
|
||||
const deletedPaths = new Set(results.deleted)
|
||||
|
||||
project.features = project.features.filter(f =>
|
||||
!deletedPaths.has(f.traceability?.archive_path)
|
||||
)
|
||||
|
||||
project.statistics.total_features = project.features.length
|
||||
project.statistics.last_updated = getUtc8ISOString()
|
||||
|
||||
Write(projectPath, JSON.stringify(project, null, 2))
|
||||
}
|
||||
```
|
||||
|
||||
**Step 4.4: Report Results**
|
||||
```javascript
|
||||
console.log(`
|
||||
## Cleanup Complete
|
||||
|
||||
**Deleted**: ${results.deleted.length} items
|
||||
**Failed**: ${results.failed.length} items
|
||||
**Skipped**: ${results.skipped.length} items
|
||||
|
||||
### Deleted Items
|
||||
${results.deleted.map(p => `- ${p}`).join('\n')}
|
||||
|
||||
${results.failed.length > 0 ? `
|
||||
### Failed Items
|
||||
${results.failed.map(f => `- ${f.path}: ${f.error}`).join('\n')}
|
||||
` : ''}
|
||||
|
||||
Cleanup manifest archived to: ${sessionFolder}/cleanup-manifest.json
|
||||
`)
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Session Folder Structure
|
||||
|
||||
```
|
||||
.workflow/.clean/{YYYY-MM-DD}/
|
||||
├── mainline-profile.json # Git history analysis
|
||||
└── cleanup-manifest.json # Discovery results
|
||||
```
|
||||
|
||||
## Risk Level Definitions
|
||||
|
||||
| Risk | Description | Examples |
|
||||
|------|-------------|----------|
|
||||
| **Low** | Safe to delete, no dependencies | Empty sessions, scratchpad files, 100% broken docs |
|
||||
| **Medium** | Likely unused, verify before delete | Orphan files, old archives, partially broken docs |
|
||||
| **High** | May have hidden dependencies | Files with some imports, recent modifications |
|
||||
|
||||
## Error Handling
|
||||
|
||||
| Situation | Action |
|
||||
|-----------|--------|
|
||||
| No git repository | Skip mainline detection, use file timestamps only |
|
||||
| Session in use (.archiving) | Skip with warning |
|
||||
| Permission denied | Report error, continue with others |
|
||||
| Manifest parse error | Regenerate from filesystem scan |
|
||||
| Empty discovery | Report "codebase is clean" |
|
||||
|
||||
## Related Commands
|
||||
|
||||
- `/workflow:session:complete` - Properly archive active sessions
|
||||
- `/memory:compact` - Save session memory before cleanup
|
||||
- `/workflow:status` - View current workflow state
|
||||
617
.claude/commands/workflow/collaborative-plan-with-file.md
Normal file
617
.claude/commands/workflow/collaborative-plan-with-file.md
Normal file
@@ -0,0 +1,617 @@
|
||||
---
|
||||
name: workflow:collaborative-plan-with-file
|
||||
description: Collaborative planning with Plan Note - Understanding agent creates shared plan-note.md template, parallel agents fill pre-allocated sections, conflict detection without merge. Outputs executable plan-note.md.
|
||||
argument-hint: "[-y|--yes] <task description> [--max-agents=5]"
|
||||
allowed-tools: TodoWrite(*), Task(*), AskUserQuestion(*), Read(*), Bash(*), Write(*), Glob(*), Grep(*), mcp__ace-tool__search_context(*)
|
||||
---
|
||||
|
||||
## Auto Mode
|
||||
|
||||
When `--yes` or `-y`: Auto-approve splits, skip confirmations.
|
||||
|
||||
# Collaborative Planning Command
|
||||
|
||||
## Quick Start
|
||||
|
||||
```bash
|
||||
# Basic usage
|
||||
/workflow:collaborative-plan-with-file "Implement real-time notification system"
|
||||
|
||||
# With options
|
||||
/workflow:collaborative-plan-with-file "Refactor authentication module" --max-agents=4
|
||||
/workflow:collaborative-plan-with-file "Add payment gateway support" -y
|
||||
```
|
||||
|
||||
**Context Source**: Understanding-Agent + Per-agent exploration
|
||||
**Output Directory**: `.workflow/.planning/{session-id}/`
|
||||
**Default Max Agents**: 5 (actual count based on requirement complexity)
|
||||
**Core Innovation**: Plan Note - shared collaborative document, no merge needed
|
||||
|
||||
## Output Artifacts
|
||||
|
||||
### Phase 1: Understanding Agent
|
||||
|
||||
| Artifact | Description |
|
||||
|----------|-------------|
|
||||
| `plan-note.md` | Shared collaborative document with pre-allocated sections |
|
||||
| `requirement-analysis.json` | Sub-domain assignments and TASK ID ranges |
|
||||
|
||||
### Phase 2: Per Sub-Agent
|
||||
|
||||
| Artifact | Description |
|
||||
|----------|-------------|
|
||||
| `planning-context.md` | Evidence paths + synthesized understanding |
|
||||
| `plan.json` | Complete agent plan (detailed implementation) |
|
||||
| Updates to `plan-note.md` | Agent fills pre-allocated sections |
|
||||
|
||||
### Phase 3: Final Output
|
||||
|
||||
| Artifact | Description |
|
||||
|----------|-------------|
|
||||
| `plan-note.md` | ⭐ Executable plan with conflict markers |
|
||||
| `conflicts.json` | Detected conflicts with resolution options |
|
||||
| `plan.md` | Human-readable summary |
|
||||
|
||||
## Overview
|
||||
|
||||
Unified collaborative planning workflow using **Plan Note** architecture:
|
||||
|
||||
1. **Understanding**: Agent analyzes requirements and creates plan-note.md template with pre-allocated sections
|
||||
2. **Parallel Planning**: Each agent generates plan.json + fills their pre-allocated section in plan-note.md
|
||||
3. **Conflict Detection**: Scan plan-note.md for conflicts (no merge needed)
|
||||
4. **Completion**: Generate plan.md summary, ready for execution
|
||||
|
||||
```
|
||||
┌─────────────────────────────────────────────────────────────────────────┐
|
||||
│ PLAN NOTE COLLABORATIVE PLANNING │
|
||||
├─────────────────────────────────────────────────────────────────────────┤
|
||||
│ │
|
||||
│ Phase 1: Understanding & Template Creation │
|
||||
│ ├─ Understanding-Agent analyzes requirements │
|
||||
│ ├─ Identify 2-5 sub-domains (focus areas) │
|
||||
│ ├─ Create plan-note.md with pre-allocated sections │
|
||||
│ └─ Assign TASK ID ranges (no conflicts) │
|
||||
│ │
|
||||
│ Phase 2: Parallel Agent Execution (No Locks Needed) │
|
||||
│ ┌──────────────┬──────────────┬──────────────┐ │
|
||||
│ │ Agent 1 │ Agent 2 │ Agent N │ │
|
||||
│ ├──────────────┼──────────────┼──────────────┤ │
|
||||
│ │ Own Section │ Own Section │ Own Section │ ← Pre-allocated │
|
||||
│ │ plan.json │ plan.json │ plan.json │ ← Detailed plans │
|
||||
│ └──────────────┴──────────────┴──────────────┘ │
|
||||
│ │
|
||||
│ Phase 3: Conflict Detection (Single Source) │
|
||||
│ ├─ Parse plan-note.md (all sections) │
|
||||
│ ├─ Detect file/dependency/strategy conflicts │
|
||||
│ └─ Update plan-note.md conflict section │
|
||||
│ │
|
||||
│ Phase 4: Completion (No Merge) │
|
||||
│ ├─ Generate plan.md (human-readable) │
|
||||
│ └─ Ready for execution │
|
||||
│ │
|
||||
└─────────────────────────────────────────────────────────────────────────┘
|
||||
```
|
||||
|
||||
## Output Structure
|
||||
|
||||
```
|
||||
.workflow/.planning/{CPLAN-slug-YYYY-MM-DD}/
|
||||
├── plan-note.md # ⭐ Core: Requirements + Tasks + Conflicts
|
||||
├── requirement-analysis.json # Phase 1: Sub-domain assignments
|
||||
├── agents/ # Phase 2: Per-agent detailed plans
|
||||
│ ├── {focus-area-1}/
|
||||
│ │ ├── planning-context.md # Evidence + understanding
|
||||
│ │ └── plan.json # Complete agent plan
|
||||
│ ├── {focus-area-2}/
|
||||
│ │ └── ...
|
||||
│ └── {focus-area-N}/
|
||||
│ └── ...
|
||||
├── conflicts.json # Phase 3: Conflict details
|
||||
└── plan.md # Phase 4: Human-readable summary
|
||||
```
|
||||
|
||||
## Implementation
|
||||
|
||||
### Session Initialization
|
||||
|
||||
**Objective**: Create session context and directory structure for collaborative planning.
|
||||
|
||||
**Required Actions**:
|
||||
1. Extract task description from `$ARGUMENTS`
|
||||
2. Generate session ID with format: `CPLAN-{slug}-{date}`
|
||||
- slug: lowercase, alphanumeric, max 30 chars
|
||||
- date: YYYY-MM-DD (UTC+8)
|
||||
3. Define session folder: `.workflow/.planning/{session-id}`
|
||||
4. Parse command options:
|
||||
- `--max-agents=N` (default: 5)
|
||||
- `-y` or `--yes` for auto-approval mode
|
||||
5. Create directory structure: `{session-folder}/agents/`
|
||||
|
||||
**Session Variables**:
|
||||
- `sessionId`: Unique session identifier
|
||||
- `sessionFolder`: Base directory for all artifacts
|
||||
- `maxAgents`: Maximum number of parallel agents
|
||||
- `autoMode`: Boolean for auto-confirmation
|
||||
|
||||
### Phase 1: Understanding & Template Creation
|
||||
|
||||
**Objective**: Analyze requirements and create the plan-note.md template with pre-allocated sections for parallel agents.
|
||||
|
||||
**Prerequisites**:
|
||||
- Session initialized with valid sessionId and sessionFolder
|
||||
- Task description available from $ARGUMENTS
|
||||
|
||||
**Guideline**: In Understanding phase, prioritize identifying latest documentation (README, design docs, architecture guides). When ambiguities exist, ask user for clarification instead of assuming interpretations.
|
||||
|
||||
**Workflow Steps**:
|
||||
|
||||
1. **Initialize Progress Tracking**
|
||||
- Create 4 todo items for workflow phases
|
||||
- Set Phase 1 status to `in_progress`
|
||||
|
||||
2. **Launch Understanding Agent**
|
||||
- Agent type: `cli-lite-planning-agent`
|
||||
- Execution mode: synchronous (run_in_background: false)
|
||||
|
||||
3. **Agent Tasks**:
|
||||
- **Identify Latest Documentation**: Search for and prioritize latest README, design docs, architecture guides
|
||||
- **Understand Requirements**: Extract core objective, key points, constraints from task description and latest docs
|
||||
- **Identify Ambiguities**: List any unclear points or multiple possible interpretations
|
||||
- **Form Clarification Checklist**: Prepare questions for user if ambiguities found (use AskUserQuestion)
|
||||
- **Split Sub-Domains**: Identify 2-{maxAgents} parallelizable focus areas
|
||||
- **Create Plan Note**: Generate plan-note.md with pre-allocated sections
|
||||
|
||||
**Output Files**:
|
||||
|
||||
| File | Purpose |
|
||||
|------|---------|
|
||||
| `{sessionFolder}/plan-note.md` | Collaborative template with pre-allocated sections per agent |
|
||||
| `{sessionFolder}/requirement-analysis.json` | Sub-domain assignments and TASK ID ranges |
|
||||
|
||||
**requirement-analysis.json Schema**:
|
||||
- `session_id`: Session identifier
|
||||
- `original_requirement`: Task description
|
||||
- `complexity`: Low | Medium | High
|
||||
- `sub_domains[]`: Array of focus areas with task_id_range and estimated_effort
|
||||
- `total_agents`: Number of agents to spawn
|
||||
|
||||
**Success Criteria**:
|
||||
- Latest documentation identified and referenced (if available)
|
||||
- Ambiguities resolved via user clarification (if any found)
|
||||
- 2-{maxAgents} clear sub-domains identified
|
||||
- Each sub-domain can be planned independently
|
||||
- Plan Note template includes all pre-allocated sections
|
||||
- TASK ID ranges have no overlap (100 IDs per agent)
|
||||
- Requirements understanding is comprehensive
|
||||
|
||||
**Completion**:
|
||||
- Log created artifacts
|
||||
- Update Phase 1 todo status to `completed`
|
||||
|
||||
**Agent Call**:
|
||||
```javascript
|
||||
Task(
|
||||
subagent_type="cli-lite-planning-agent",
|
||||
run_in_background=false,
|
||||
description="Understand requirements and create plan template",
|
||||
prompt=`
|
||||
## Mission: Create Plan Note Template
|
||||
|
||||
### Key Guidelines
|
||||
1. **Prioritize Latest Documentation**: Search for and reference latest README, design docs, architecture guides when available
|
||||
2. **Handle Ambiguities**: When requirement ambiguities exist, ask user for clarification (use AskUserQuestion) instead of assuming interpretations
|
||||
|
||||
### Input Requirements
|
||||
${taskDescription}
|
||||
|
||||
### Tasks
|
||||
1. **Understand Requirements**: Extract core objective, key points, constraints (reference latest docs when available)
|
||||
2. **Identify Ambiguities**: List any unclear points or multiple possible interpretations
|
||||
3. **Form Clarification Checklist**: Prepare questions for user if ambiguities found
|
||||
4. **Split Sub-Domains**: Identify 2-${maxAgents} parallelizable focus areas
|
||||
5. **Create Plan Note**: Generate plan-note.md with pre-allocated sections
|
||||
|
||||
### Output Files
|
||||
|
||||
**File 1**: ${sessionFolder}/plan-note.md
|
||||
|
||||
Structure Requirements:
|
||||
- YAML frontmatter: session_id, original_requirement, created_at, contributors, sub_domains, agent_sections, agent_task_id_ranges, status
|
||||
- Section: ## 需求理解 (Core objectives, key points, constraints, split strategy)
|
||||
- Section: ## 任务池 - {Focus Area 1} (Pre-allocated task section for agent 1, TASK-001 ~ TASK-100)
|
||||
- Section: ## 任务池 - {Focus Area 2} (Pre-allocated task section for agent 2, TASK-101 ~ TASK-200)
|
||||
- ... (One task pool section per sub-domain)
|
||||
- Section: ## 依赖关系 (Auto-generated after all agents complete)
|
||||
- Section: ## 冲突标记 (Populated in Phase 3)
|
||||
- Section: ## 上下文证据 - {Focus Area 1} (Evidence for agent 1)
|
||||
- Section: ## 上下文证据 - {Focus Area 2} (Evidence for agent 2)
|
||||
- ... (One evidence section per sub-domain)
|
||||
|
||||
**File 2**: ${sessionFolder}/requirement-analysis.json
|
||||
- session_id, original_requirement, complexity, sub_domains[], total_agents
|
||||
|
||||
### Success Criteria
|
||||
- [ ] 2-${maxAgents} clear sub-domains identified
|
||||
- [ ] Each sub-domain can be planned independently
|
||||
- [ ] Plan Note template includes all pre-allocated sections
|
||||
- [ ] TASK ID ranges have no overlap (100 IDs per agent)
|
||||
`
|
||||
)
|
||||
```
|
||||
|
||||
### Phase 2: Parallel Sub-Agent Execution
|
||||
|
||||
**Objective**: Launch parallel planning agents to fill their pre-allocated sections in plan-note.md.
|
||||
|
||||
**Prerequisites**:
|
||||
- Phase 1 completed successfully
|
||||
- `{sessionFolder}/requirement-analysis.json` exists with sub-domain definitions
|
||||
- `{sessionFolder}/plan-note.md` template created
|
||||
|
||||
**Workflow Steps**:
|
||||
|
||||
1. **Load Sub-Domain Configuration**
|
||||
- Read `{sessionFolder}/requirement-analysis.json`
|
||||
- Extract sub-domains array with focus_area, description, task_id_range
|
||||
|
||||
2. **Update Progress Tracking**
|
||||
- Set Phase 2 status to `in_progress`
|
||||
- Add sub-todo for each agent
|
||||
|
||||
3. **User Confirmation** (unless autoMode)
|
||||
- Display identified sub-domains with descriptions
|
||||
- Options: "开始规划" / "调整拆分" / "取消"
|
||||
- Skip if autoMode enabled
|
||||
|
||||
4. **Create Agent Directories**
|
||||
- For each sub-domain: `{sessionFolder}/agents/{focus-area}/`
|
||||
|
||||
5. **Launch Parallel Agents**
|
||||
- Agent type: `cli-lite-planning-agent`
|
||||
- Execution mode: synchronous (run_in_background: false)
|
||||
- Launch ALL agents in parallel (single message with multiple Task calls)
|
||||
|
||||
**Per-Agent Context**:
|
||||
- Focus area name and description
|
||||
- Assigned TASK ID range (no overlap with other agents)
|
||||
- Session ID and folder path
|
||||
|
||||
**Per-Agent Tasks**:
|
||||
|
||||
| Task | Output | Description |
|
||||
|------|--------|-------------|
|
||||
| Generate plan.json | `{sessionFolder}/agents/{focus-area}/plan.json` | Complete detailed plan following schema |
|
||||
| Update plan-note.md | Sync to shared file | Fill pre-allocated "任务池" and "上下文证据" sections |
|
||||
|
||||
**Task Summary Format** (for plan-note.md):
|
||||
- Task header: `### TASK-{ID}: {Title} [{focus-area}]`
|
||||
- Status, Complexity, Dependencies
|
||||
- Scope description
|
||||
- Modification points with file:line references
|
||||
- Conflict risk assessment
|
||||
|
||||
**Evidence Format** (for plan-note.md):
|
||||
- Related files with relevance scores
|
||||
- Existing patterns identified
|
||||
- Constraints discovered
|
||||
|
||||
**Agent Execution Rules**:
|
||||
- Each agent modifies ONLY its pre-allocated sections
|
||||
- Use assigned TASK ID range exclusively
|
||||
- No locking needed (exclusive sections)
|
||||
- Include conflict_risk assessment for each task
|
||||
|
||||
**Completion**:
|
||||
- Wait for all agents to complete
|
||||
- Log generated artifacts for each agent
|
||||
- Update Phase 2 todo status to `completed`
|
||||
|
||||
**User Confirmation** (unless autoMode):
|
||||
```javascript
|
||||
if (!autoMode) {
|
||||
AskUserQuestion({
|
||||
questions: [{
|
||||
question: `已识别 ${subDomains.length} 个子领域:\n${subDomains.map((s, i) => `${i+1}. ${s.focus_area}: ${s.description}`).join('\n')}\n\n确认开始并行规划?`,
|
||||
header: "Confirm Split",
|
||||
multiSelect: false,
|
||||
options: [
|
||||
{ label: "开始规划", description: "启动并行sub-agent" },
|
||||
{ label: "调整拆分", description: "修改子领域划分" },
|
||||
{ label: "取消", description: "退出规划" }
|
||||
]
|
||||
}]
|
||||
})
|
||||
}
|
||||
```
|
||||
|
||||
**Launch Parallel Agents** (single message, multiple Task calls):
|
||||
```javascript
|
||||
// Create agent directories
|
||||
subDomains.forEach(sub => {
|
||||
Bash(`mkdir -p ${sessionFolder}/agents/${sub.focus_area}`)
|
||||
})
|
||||
|
||||
// Launch all agents in parallel
|
||||
subDomains.map(sub =>
|
||||
Task(
|
||||
subagent_type="cli-lite-planning-agent",
|
||||
run_in_background=false,
|
||||
description=`Plan: ${sub.focus_area}`,
|
||||
prompt=`
|
||||
## Sub-Agent Context
|
||||
|
||||
**Focus Area**: ${sub.focus_area}
|
||||
**Description**: ${sub.description}
|
||||
**TASK ID Range**: ${sub.task_id_range[0]}-${sub.task_id_range[1]}
|
||||
**Session**: ${sessionId}
|
||||
|
||||
## Dual Output Tasks
|
||||
|
||||
### Task 1: Generate Complete plan.json
|
||||
Output: ${sessionFolder}/agents/${sub.focus_area}/plan.json
|
||||
Schema: ~/.claude/workflows/cli-templates/schemas/plan-json-schema.json
|
||||
|
||||
### Task 2: Sync Summary to plan-note.md
|
||||
|
||||
**Locate Your Sections**:
|
||||
- Task Pool: "## 任务池 - ${toTitleCase(sub.focus_area)}"
|
||||
- Evidence: "## 上下文证据 - ${toTitleCase(sub.focus_area)}"
|
||||
|
||||
**Task Summary Format**:
|
||||
- Task header: ### TASK-${sub.task_id_range[0]}: Task Title [${sub.focus_area}]
|
||||
- Fields: 状态, 复杂度, 依赖, 范围, 修改点, 冲突风险
|
||||
|
||||
**Evidence Format**:
|
||||
- 相关文件, 现有模式, 约束
|
||||
|
||||
## Execution Steps
|
||||
1. Generate complete plan.json
|
||||
2. Extract summary from plan.json
|
||||
3. Read ${sessionFolder}/plan-note.md
|
||||
4. Locate and replace your task pool section
|
||||
5. Locate and replace your evidence section
|
||||
6. Write back plan-note.md
|
||||
|
||||
## Important
|
||||
- Only modify your pre-allocated sections
|
||||
- Use assigned TASK ID range: ${sub.task_id_range[0]}-${sub.task_id_range[1]}
|
||||
`
|
||||
)
|
||||
)
|
||||
```
|
||||
|
||||
### Phase 3: Conflict Detection
|
||||
|
||||
**Objective**: Analyze plan-note.md for conflicts across all agent contributions without merging files.
|
||||
|
||||
**Prerequisites**:
|
||||
- Phase 2 completed successfully
|
||||
- All agents have updated plan-note.md with their sections
|
||||
- `{sessionFolder}/plan-note.md` contains all task and evidence sections
|
||||
|
||||
**Workflow Steps**:
|
||||
|
||||
1. **Update Progress Tracking**
|
||||
- Set Phase 3 status to `in_progress`
|
||||
|
||||
2. **Parse Plan Note**
|
||||
- Read `{sessionFolder}/plan-note.md`
|
||||
- Extract YAML frontmatter (session metadata)
|
||||
- Parse markdown sections by heading levels
|
||||
- Identify all "任务池" sections
|
||||
|
||||
3. **Extract All Tasks**
|
||||
- For each "任务池" section:
|
||||
- Extract tasks matching pattern: `### TASK-{ID}: {Title} [{author}]`
|
||||
- Parse task details: status, complexity, dependencies, modification points, conflict risk
|
||||
- Consolidate into single task list
|
||||
|
||||
4. **Detect Conflicts**
|
||||
|
||||
**File Conflicts**:
|
||||
- Group modification points by file:location
|
||||
- Identify locations modified by multiple agents
|
||||
- Record: severity=high, tasks involved, agents involved, suggested resolution
|
||||
|
||||
**Dependency Cycles**:
|
||||
- Build dependency graph from task dependencies
|
||||
- Detect cycles using depth-first search
|
||||
- Record: severity=critical, cycle path, suggested resolution
|
||||
|
||||
**Strategy Conflicts**:
|
||||
- Group tasks by files they modify
|
||||
- Identify files with high/medium conflict risk from multiple agents
|
||||
- Record: severity=medium, tasks involved, agents involved, suggested resolution
|
||||
|
||||
5. **Generate Conflict Artifacts**
|
||||
|
||||
**conflicts.json**:
|
||||
- Write to `{sessionFolder}/conflicts.json`
|
||||
- Include: detected_at, total_tasks, total_agents, conflicts array
|
||||
- Each conflict: type, severity, tasks_involved, description, suggested_resolution
|
||||
|
||||
**Update plan-note.md**:
|
||||
- Locate "## 冲突标记" section
|
||||
- Generate markdown summary of conflicts
|
||||
- Replace section content with conflict markdown
|
||||
|
||||
6. **Completion**
|
||||
- Log conflict detection summary
|
||||
- Display conflict details if any found
|
||||
- Update Phase 3 todo status to `completed`
|
||||
|
||||
**Conflict Types**:
|
||||
|
||||
| Type | Severity | Detection Logic |
|
||||
|------|----------|-----------------|
|
||||
| file_conflict | high | Same file:location modified by multiple agents |
|
||||
| dependency_cycle | critical | Circular dependencies in task graph |
|
||||
| strategy_conflict | medium | Multiple high-risk tasks in same file from different agents |
|
||||
|
||||
**Conflict Detection Functions**:
|
||||
|
||||
**parsePlanNote(markdown)**:
|
||||
- Input: Raw markdown content of plan-note.md
|
||||
- Process:
|
||||
- Extract YAML frontmatter between `---` markers
|
||||
- Parse frontmatter as YAML to get session metadata
|
||||
- Scan for heading patterns `^(#{2,})\s+(.+)$`
|
||||
- Build sections array with: level, heading, start position, content
|
||||
- Output: `{ frontmatter: object, sections: array }`
|
||||
|
||||
**extractTasksFromSection(content, sectionHeading)**:
|
||||
- Input: Section content text, section heading for attribution
|
||||
- Process:
|
||||
- Match task pattern: `### (TASK-\d+):\s+(.+?)\s+\[(.+?)\]`
|
||||
- For each match: extract taskId, title, author
|
||||
- Call parseTaskDetails for additional fields
|
||||
- Output: Array of task objects with id, title, author, source_section, ...details
|
||||
|
||||
**parseTaskDetails(content)**:
|
||||
- Input: Task content block
|
||||
- Process:
|
||||
- Extract fields via regex patterns:
|
||||
- `**状态**:\s*(.+)` → status
|
||||
- `**复杂度**:\s*(.+)` → complexity
|
||||
- `**依赖**:\s*(.+)` → depends_on (extract TASK-\d+ references)
|
||||
- `**冲突风险**:\s*(.+)` → conflict_risk
|
||||
- Extract modification points: `-\s+\`([^`]+):\s*([^`]+)\`:\s*(.+)` → file, location, summary
|
||||
- Output: Details object with status, complexity, depends_on[], modification_points[], conflict_risk
|
||||
|
||||
**detectFileConflicts(tasks)**:
|
||||
- Input: All tasks array
|
||||
- Process:
|
||||
- Build fileMap: `{ "file:location": [{ task_id, task_title, source_agent, change }] }`
|
||||
- For each location with multiple modifications from different agents:
|
||||
- Create conflict with type='file_conflict', severity='high'
|
||||
- Include: location, tasks_involved, agents_involved, modifications
|
||||
- Suggested resolution: 'Coordinate modification order or merge changes'
|
||||
- Output: Array of file conflict objects
|
||||
|
||||
**detectDependencyCycles(tasks)**:
|
||||
- Input: All tasks array
|
||||
- Process:
|
||||
- Build dependency graph: `{ taskId: [dependsOn_taskIds] }`
|
||||
- Use DFS with recursion stack to detect cycles
|
||||
- For each cycle found:
|
||||
- Create conflict with type='dependency_cycle', severity='critical'
|
||||
- Include: cycle path as tasks_involved
|
||||
- Suggested resolution: 'Remove or reorganize dependencies'
|
||||
- Output: Array of dependency cycle conflict objects
|
||||
|
||||
**detectStrategyConflicts(tasks)**:
|
||||
- Input: All tasks array
|
||||
- Process:
|
||||
- Group tasks by files they modify
|
||||
- For each file with tasks from multiple agents:
|
||||
- Filter for high/medium conflict_risk tasks
|
||||
- If >1 high-risk tasks from different agents:
|
||||
- Create conflict with type='strategy_conflict', severity='medium'
|
||||
- Include: file, tasks_involved, agents_involved
|
||||
- Suggested resolution: 'Review approaches and align on single strategy'
|
||||
- Output: Array of strategy conflict objects
|
||||
|
||||
**generateConflictMarkdown(conflicts)**:
|
||||
- Input: Array of conflict objects
|
||||
- Process:
|
||||
- If empty: return '✅ 无冲突检测到'
|
||||
- For each conflict:
|
||||
- Generate header: `### CONFLICT-{padded_index}: {description}`
|
||||
- Add fields: 严重程度, 涉及任务, 涉及Agent
|
||||
- Add 问题详情 based on conflict type
|
||||
- Add 建议解决方案
|
||||
- Add 决策状态: [ ] 待解决
|
||||
- Output: Markdown string for plan-note.md "## 冲突标记" section
|
||||
|
||||
**replaceSectionContent(markdown, sectionHeading, newContent)**:
|
||||
- Input: Original markdown, target section heading, new content
|
||||
- Process:
|
||||
- Find section heading position via regex
|
||||
- Find next heading of same or higher level
|
||||
- Replace content between heading and next section
|
||||
- If section not found: append at end
|
||||
- Output: Updated markdown string
|
||||
|
||||
### Phase 4: Completion
|
||||
|
||||
**Objective**: Generate human-readable plan summary and finalize workflow.
|
||||
|
||||
**Prerequisites**:
|
||||
- Phase 3 completed successfully
|
||||
- Conflicts detected and documented in plan-note.md
|
||||
- All artifacts generated
|
||||
|
||||
**Workflow Steps**:
|
||||
|
||||
1. **Update Progress Tracking**
|
||||
- Set Phase 4 status to `in_progress`
|
||||
|
||||
2. **Read Final State**
|
||||
- Read `{sessionFolder}/plan-note.md`
|
||||
- Extract frontmatter metadata
|
||||
- Load conflicts from Phase 3
|
||||
|
||||
3. **Generate plan.md**
|
||||
- Create human-readable summary including:
|
||||
- Session metadata
|
||||
- Requirements understanding
|
||||
- Sub-domain breakdown
|
||||
- Task overview by focus area
|
||||
- Conflict report
|
||||
- Execution instructions
|
||||
|
||||
4. **Write Summary File**
|
||||
- Write to `{sessionFolder}/plan.md`
|
||||
|
||||
5. **Display Completion Summary**
|
||||
- Session statistics
|
||||
- File structure
|
||||
- Execution command
|
||||
- Conflict status
|
||||
|
||||
6. **Update Todo**
|
||||
- Set Phase 4 status to `completed`
|
||||
|
||||
**plan.md Structure**:
|
||||
|
||||
| Section | Content |
|
||||
|---------|---------|
|
||||
| Header | Session ID, created time, original requirement |
|
||||
| Requirements | Copy from plan-note.md "## 需求理解" section |
|
||||
| Sub-Domain Split | List each focus area with description and task ID range |
|
||||
| Task Overview | Tasks grouped by focus area with complexity and dependencies |
|
||||
| Conflict Report | Summary of detected conflicts or "无冲突" |
|
||||
| Execution | Command to execute the plan |
|
||||
|
||||
**Required Function** (semantic description):
|
||||
- **generateHumanReadablePlan**: Extract sections from plan-note.md and format as readable plan.md with session info, requirements, tasks, and conflicts
|
||||
|
||||
## Configuration
|
||||
|
||||
| Flag | Default | Description |
|
||||
|------|---------|-------------|
|
||||
| `--max-agents` | 5 | Maximum sub-agents to spawn |
|
||||
| `-y, --yes` | false | Auto-confirm all decisions |
|
||||
|
||||
## Error Handling
|
||||
|
||||
| Error | Resolution |
|
||||
|-------|------------|
|
||||
| Understanding agent fails | Retry once, provide more context |
|
||||
| Planning agent fails | Skip failed agent, continue with others |
|
||||
| Section not found in plan-note | Agent creates section (defensive) |
|
||||
| Conflict detection fails | Continue with empty conflicts |
|
||||
|
||||
|
||||
## Best Practices
|
||||
|
||||
1. **Clear Requirements**: Detailed requirements → better sub-domain splitting
|
||||
2. **Reference Latest Documentation**: Understanding agent should prioritize identifying and referencing latest docs (README, design docs, architecture guides)
|
||||
3. **Ask When Uncertain**: When ambiguities or multiple interpretations exist, ask user for clarification instead of assuming
|
||||
4. **Review Plan Note**: Check plan-note.md before execution
|
||||
5. **Resolve Conflicts**: Address high/critical conflicts before execution
|
||||
6. **Inspect Details**: Use agents/{focus-area}/plan.json for deep dive
|
||||
|
||||
---
|
||||
|
||||
**Now execute collaborative-plan-with-file for**: $ARGUMENTS
|
||||
672
.claude/commands/workflow/debug-with-file.md
Normal file
672
.claude/commands/workflow/debug-with-file.md
Normal file
@@ -0,0 +1,672 @@
|
||||
---
|
||||
name: debug-with-file
|
||||
description: Interactive hypothesis-driven debugging with documented exploration, understanding evolution, and Gemini-assisted correction
|
||||
argument-hint: "[-y|--yes] \"bug description or error message\""
|
||||
allowed-tools: TodoWrite(*), Task(*), AskUserQuestion(*), Read(*), Grep(*), Glob(*), Bash(*), Edit(*), Write(*)
|
||||
---
|
||||
|
||||
## Auto Mode
|
||||
|
||||
When `--yes` or `-y`: Auto-confirm all decisions (hypotheses, fixes, iteration), use recommended settings.
|
||||
|
||||
# Workflow Debug-With-File Command (/workflow:debug-with-file)
|
||||
|
||||
## Overview
|
||||
|
||||
Enhanced evidence-based debugging with **documented exploration process**. Records understanding evolution, consolidates insights, and uses Gemini to correct misunderstandings.
|
||||
|
||||
**Core workflow**: Explore → Document → Log → Analyze → Correct Understanding → Fix → Verify
|
||||
|
||||
**Scope**: Adds temporary debug logging to observe program state; cleans up all instrumentation after resolution. Does NOT execute code injection, security testing, or modify program behavior.
|
||||
|
||||
**Key enhancements over /workflow:debug**:
|
||||
- **understanding.md**: Timeline of exploration and learning
|
||||
- **Gemini-assisted correction**: Validates and corrects hypotheses
|
||||
- **Consolidation**: Simplifies proven-wrong understanding to avoid clutter
|
||||
- **Learning retention**: Preserves what was learned, even from failed attempts
|
||||
|
||||
## Usage
|
||||
|
||||
```bash
|
||||
/workflow:debug-with-file <BUG_DESCRIPTION>
|
||||
|
||||
# Arguments
|
||||
<bug-description> Bug description, error message, or stack trace (required)
|
||||
```
|
||||
|
||||
## Execution Process
|
||||
|
||||
```
|
||||
Session Detection:
|
||||
├─ Check if debug session exists for this bug
|
||||
├─ EXISTS + understanding.md exists → Continue mode
|
||||
└─ NOT_FOUND → Explore mode
|
||||
|
||||
Explore Mode:
|
||||
├─ Locate error source in codebase
|
||||
├─ Document initial understanding in understanding.md
|
||||
├─ Generate testable hypotheses with Gemini validation
|
||||
├─ Add NDJSON debug logging statements
|
||||
└─ Output: Hypothesis list + await user reproduction
|
||||
|
||||
Analyze Mode:
|
||||
├─ Parse debug.log, validate each hypothesis
|
||||
├─ Use Gemini to analyze evidence and correct understanding
|
||||
├─ Update understanding.md with:
|
||||
│ ├─ New evidence
|
||||
│ ├─ Corrected misunderstandings (strikethrough + correction)
|
||||
│ └─ Consolidated current understanding
|
||||
└─ Decision:
|
||||
├─ Confirmed → Fix root cause
|
||||
├─ Inconclusive → Add more logging, iterate
|
||||
└─ All rejected → Gemini-assisted new hypotheses
|
||||
|
||||
Fix & Cleanup:
|
||||
├─ Apply fix based on confirmed hypothesis
|
||||
├─ User verifies
|
||||
├─ Document final understanding + lessons learned
|
||||
├─ Remove debug instrumentation
|
||||
└─ If not fixed → Return to Analyze mode
|
||||
```
|
||||
|
||||
## Implementation
|
||||
|
||||
### Session Setup & Mode Detection
|
||||
|
||||
```javascript
|
||||
const getUtc8ISOString = () => new Date(Date.now() + 8 * 60 * 60 * 1000).toISOString()
|
||||
|
||||
const bugSlug = bug_description.toLowerCase().replace(/[^a-z0-9]+/g, '-').substring(0, 30)
|
||||
const dateStr = getUtc8ISOString().substring(0, 10)
|
||||
|
||||
const sessionId = `DBG-${bugSlug}-${dateStr}`
|
||||
const sessionFolder = `.workflow/.debug/${sessionId}`
|
||||
const debugLogPath = `${sessionFolder}/debug.log`
|
||||
const understandingPath = `${sessionFolder}/understanding.md`
|
||||
const hypothesesPath = `${sessionFolder}/hypotheses.json`
|
||||
|
||||
// Auto-detect mode
|
||||
const sessionExists = fs.existsSync(sessionFolder)
|
||||
const hasUnderstanding = sessionExists && fs.existsSync(understandingPath)
|
||||
const logHasContent = sessionExists && fs.existsSync(debugLogPath) && fs.statSync(debugLogPath).size > 0
|
||||
|
||||
const mode = logHasContent ? 'analyze' : (hasUnderstanding ? 'continue' : 'explore')
|
||||
|
||||
if (!sessionExists) {
|
||||
bash(`mkdir -p ${sessionFolder}`)
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### Explore Mode
|
||||
|
||||
**Step 1.1: Locate Error Source**
|
||||
|
||||
```javascript
|
||||
// Extract keywords from bug description
|
||||
const keywords = extractErrorKeywords(bug_description)
|
||||
|
||||
// Search codebase for error locations
|
||||
const searchResults = []
|
||||
for (const keyword of keywords) {
|
||||
const results = Grep({ pattern: keyword, path: ".", output_mode: "content", "-C": 3 })
|
||||
searchResults.push({ keyword, results })
|
||||
}
|
||||
|
||||
// Identify affected files and functions
|
||||
const affectedLocations = analyzeSearchResults(searchResults)
|
||||
```
|
||||
|
||||
**Step 1.2: Document Initial Understanding**
|
||||
|
||||
Create `understanding.md` with exploration timeline:
|
||||
|
||||
```markdown
|
||||
# Understanding Document
|
||||
|
||||
**Session ID**: ${sessionId}
|
||||
**Bug Description**: ${bug_description}
|
||||
**Started**: ${getUtc8ISOString()}
|
||||
|
||||
---
|
||||
|
||||
## Exploration Timeline
|
||||
|
||||
### Iteration 1 - Initial Exploration (${timestamp})
|
||||
|
||||
#### Current Understanding
|
||||
|
||||
Based on bug description and initial code search:
|
||||
|
||||
- Error pattern: ${errorPattern}
|
||||
- Affected areas: ${affectedLocations.map(l => l.file).join(', ')}
|
||||
- Initial hypothesis: ${initialThoughts}
|
||||
|
||||
#### Evidence from Code Search
|
||||
|
||||
${searchResults.map(r => `
|
||||
**Keyword: "${r.keyword}"**
|
||||
- Found in: ${r.results.files.join(', ')}
|
||||
- Key findings: ${r.insights}
|
||||
`).join('\n')}
|
||||
|
||||
#### Next Steps
|
||||
|
||||
- Generate testable hypotheses
|
||||
- Add instrumentation
|
||||
- Await reproduction
|
||||
|
||||
---
|
||||
|
||||
## Current Consolidated Understanding
|
||||
|
||||
${initialConsolidatedUnderstanding}
|
||||
```
|
||||
|
||||
**Step 1.3: Gemini-Assisted Hypothesis Generation**
|
||||
|
||||
```bash
|
||||
ccw cli -p "
|
||||
PURPOSE: Generate debugging hypotheses for: ${bug_description}
|
||||
Success criteria: Testable hypotheses with clear evidence criteria
|
||||
|
||||
TASK:
|
||||
• Analyze error pattern and code search results
|
||||
• Identify 3-5 most likely root causes
|
||||
• For each hypothesis, specify:
|
||||
- What might be wrong
|
||||
- What evidence would confirm/reject it
|
||||
- Where to add instrumentation
|
||||
• Rank by likelihood
|
||||
|
||||
MODE: analysis
|
||||
|
||||
CONTEXT: @${sessionFolder}/understanding.md | Search results in understanding.md
|
||||
|
||||
EXPECTED:
|
||||
- Structured hypothesis list (JSON format)
|
||||
- Each hypothesis with: id, description, testable_condition, logging_point, evidence_criteria
|
||||
- Likelihood ranking (1=most likely)
|
||||
|
||||
CONSTRAINTS: Focus on testable conditions
|
||||
" --tool gemini --mode analysis --rule analysis-diagnose-bug-root-cause
|
||||
```
|
||||
|
||||
Save Gemini output to `hypotheses.json`:
|
||||
|
||||
```json
|
||||
{
|
||||
"iteration": 1,
|
||||
"timestamp": "2025-01-21T10:00:00+08:00",
|
||||
"hypotheses": [
|
||||
{
|
||||
"id": "H1",
|
||||
"description": "Data structure mismatch - expected key not present",
|
||||
"testable_condition": "Check if target key exists in dict",
|
||||
"logging_point": "file.py:func:42",
|
||||
"evidence_criteria": {
|
||||
"confirm": "data shows missing key",
|
||||
"reject": "key exists with valid value"
|
||||
},
|
||||
"likelihood": 1,
|
||||
"status": "pending"
|
||||
}
|
||||
],
|
||||
"gemini_insights": "...",
|
||||
"corrected_assumptions": []
|
||||
}
|
||||
```
|
||||
|
||||
**Step 1.4: Add NDJSON Debug Logging**
|
||||
|
||||
For each hypothesis, add temporary logging statements to observe program state at key execution points. Use NDJSON format for structured log parsing. These are read-only observations that do not modify program behavior.
|
||||
|
||||
**Step 1.5: Update understanding.md**
|
||||
|
||||
Append hypothesis section:
|
||||
|
||||
```markdown
|
||||
#### Hypotheses Generated (Gemini-Assisted)
|
||||
|
||||
${hypotheses.map(h => `
|
||||
**${h.id}** (Likelihood: ${h.likelihood}): ${h.description}
|
||||
- Logging at: ${h.logging_point}
|
||||
- Testing: ${h.testable_condition}
|
||||
- Evidence to confirm: ${h.evidence_criteria.confirm}
|
||||
- Evidence to reject: ${h.evidence_criteria.reject}
|
||||
`).join('\n')}
|
||||
|
||||
**Gemini Insights**: ${geminiInsights}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### Analyze Mode
|
||||
|
||||
**Step 2.1: Parse Debug Log**
|
||||
|
||||
```javascript
|
||||
// Parse NDJSON log
|
||||
const entries = Read(debugLogPath).split('\n')
|
||||
.filter(l => l.trim())
|
||||
.map(l => JSON.parse(l))
|
||||
|
||||
// Group by hypothesis
|
||||
const byHypothesis = groupBy(entries, 'hid')
|
||||
```
|
||||
|
||||
**Step 2.2: Gemini-Assisted Evidence Analysis**
|
||||
|
||||
```bash
|
||||
ccw cli -p "
|
||||
PURPOSE: Analyze debug log evidence to validate/correct hypotheses for: ${bug_description}
|
||||
Success criteria: Clear verdict per hypothesis + corrected understanding
|
||||
|
||||
TASK:
|
||||
• Parse log entries by hypothesis
|
||||
• Evaluate evidence against expected criteria
|
||||
• Determine verdict: confirmed | rejected | inconclusive
|
||||
• Identify incorrect assumptions from previous understanding
|
||||
• Suggest corrections to understanding
|
||||
|
||||
MODE: analysis
|
||||
|
||||
CONTEXT:
|
||||
@${debugLogPath}
|
||||
@${understandingPath}
|
||||
@${hypothesesPath}
|
||||
|
||||
EXPECTED:
|
||||
- Per-hypothesis verdict with reasoning
|
||||
- Evidence summary
|
||||
- List of incorrect assumptions with corrections
|
||||
- Updated consolidated understanding
|
||||
- Root cause if confirmed, or next investigation steps
|
||||
|
||||
CONSTRAINTS: Evidence-based reasoning only, no speculation
|
||||
" --tool gemini --mode analysis --rule analysis-diagnose-bug-root-cause
|
||||
```
|
||||
|
||||
**Step 2.3: Update Understanding with Corrections**
|
||||
|
||||
Append new iteration to `understanding.md`:
|
||||
|
||||
```markdown
|
||||
### Iteration ${n} - Evidence Analysis (${timestamp})
|
||||
|
||||
#### Log Analysis Results
|
||||
|
||||
${results.map(r => `
|
||||
**${r.id}**: ${r.verdict.toUpperCase()}
|
||||
- Evidence: ${JSON.stringify(r.evidence)}
|
||||
- Reasoning: ${r.reason}
|
||||
`).join('\n')}
|
||||
|
||||
#### Corrected Understanding
|
||||
|
||||
Previous misunderstandings identified and corrected:
|
||||
|
||||
${corrections.map(c => `
|
||||
- ~~${c.wrong}~~ → ${c.corrected}
|
||||
- Why wrong: ${c.reason}
|
||||
- Evidence: ${c.evidence}
|
||||
`).join('\n')}
|
||||
|
||||
#### New Insights
|
||||
|
||||
${newInsights.join('\n- ')}
|
||||
|
||||
#### Gemini Analysis
|
||||
|
||||
${geminiAnalysis}
|
||||
|
||||
${confirmedHypothesis ? `
|
||||
#### Root Cause Identified
|
||||
|
||||
**${confirmedHypothesis.id}**: ${confirmedHypothesis.description}
|
||||
|
||||
Evidence supporting this conclusion:
|
||||
${confirmedHypothesis.supportingEvidence}
|
||||
` : `
|
||||
#### Next Steps
|
||||
|
||||
${nextSteps}
|
||||
`}
|
||||
|
||||
---
|
||||
|
||||
## Current Consolidated Understanding (Updated)
|
||||
|
||||
${consolidatedUnderstanding}
|
||||
```
|
||||
|
||||
**Step 2.4: Consolidate Understanding**
|
||||
|
||||
At the bottom of `understanding.md`, update the consolidated section:
|
||||
|
||||
- Remove or simplify proven-wrong assumptions
|
||||
- Keep them in strikethrough for reference
|
||||
- Focus on current valid understanding
|
||||
- Avoid repeating details from timeline
|
||||
|
||||
```markdown
|
||||
## Current Consolidated Understanding
|
||||
|
||||
### What We Know
|
||||
|
||||
- ${validUnderstanding1}
|
||||
- ${validUnderstanding2}
|
||||
|
||||
### What Was Disproven
|
||||
|
||||
- ~~Initial assumption: ${wrongAssumption}~~ (Evidence: ${disproofEvidence})
|
||||
|
||||
### Current Investigation Focus
|
||||
|
||||
${currentFocus}
|
||||
|
||||
### Remaining Questions
|
||||
|
||||
- ${openQuestion1}
|
||||
- ${openQuestion2}
|
||||
```
|
||||
|
||||
**Step 2.5: Update hypotheses.json**
|
||||
|
||||
```json
|
||||
{
|
||||
"iteration": 2,
|
||||
"timestamp": "2025-01-21T10:15:00+08:00",
|
||||
"hypotheses": [
|
||||
{
|
||||
"id": "H1",
|
||||
"status": "rejected",
|
||||
"verdict_reason": "Evidence shows key exists with valid value",
|
||||
"evidence": {...}
|
||||
},
|
||||
{
|
||||
"id": "H2",
|
||||
"status": "confirmed",
|
||||
"verdict_reason": "Log data confirms timing issue",
|
||||
"evidence": {...}
|
||||
}
|
||||
],
|
||||
"gemini_corrections": [
|
||||
{
|
||||
"wrong_assumption": "...",
|
||||
"corrected_to": "...",
|
||||
"reason": "..."
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### Fix & Verification
|
||||
|
||||
**Step 3.1: Apply Fix**
|
||||
|
||||
(Same as original debug command)
|
||||
|
||||
**Step 3.2: Document Resolution**
|
||||
|
||||
Append to `understanding.md`:
|
||||
|
||||
```markdown
|
||||
### Iteration ${n} - Resolution (${timestamp})
|
||||
|
||||
#### Fix Applied
|
||||
|
||||
- Modified files: ${modifiedFiles.join(', ')}
|
||||
- Fix description: ${fixDescription}
|
||||
- Root cause addressed: ${rootCause}
|
||||
|
||||
#### Verification Results
|
||||
|
||||
${verificationResults}
|
||||
|
||||
#### Lessons Learned
|
||||
|
||||
What we learned from this debugging session:
|
||||
|
||||
1. ${lesson1}
|
||||
2. ${lesson2}
|
||||
3. ${lesson3}
|
||||
|
||||
#### Key Insights for Future
|
||||
|
||||
- ${insight1}
|
||||
- ${insight2}
|
||||
```
|
||||
|
||||
**Step 3.3: Cleanup**
|
||||
|
||||
Remove all temporary debug logging statements added during investigation. Verify no instrumentation code remains in production code.
|
||||
|
||||
---
|
||||
|
||||
## Session Folder Structure
|
||||
|
||||
```
|
||||
.workflow/.debug/DBG-{slug}-{date}/
|
||||
├── debug.log # NDJSON log (execution evidence)
|
||||
├── understanding.md # NEW: Exploration timeline + consolidated understanding
|
||||
├── hypotheses.json # NEW: Hypothesis history with verdicts
|
||||
└── resolution.md # Optional: Final summary
|
||||
```
|
||||
|
||||
## Understanding Document Template
|
||||
|
||||
```markdown
|
||||
# Understanding Document
|
||||
|
||||
**Session ID**: DBG-xxx-2025-01-21
|
||||
**Bug Description**: [original description]
|
||||
**Started**: 2025-01-21T10:00:00+08:00
|
||||
|
||||
---
|
||||
|
||||
## Exploration Timeline
|
||||
|
||||
### Iteration 1 - Initial Exploration (2025-01-21 10:00)
|
||||
|
||||
#### Current Understanding
|
||||
...
|
||||
|
||||
#### Evidence from Code Search
|
||||
...
|
||||
|
||||
#### Hypotheses Generated (Gemini-Assisted)
|
||||
...
|
||||
|
||||
### Iteration 2 - Evidence Analysis (2025-01-21 10:15)
|
||||
|
||||
#### Log Analysis Results
|
||||
...
|
||||
|
||||
#### Corrected Understanding
|
||||
- ~~[wrong]~~ → [corrected]
|
||||
|
||||
#### Gemini Analysis
|
||||
...
|
||||
|
||||
---
|
||||
|
||||
## Current Consolidated Understanding
|
||||
|
||||
### What We Know
|
||||
- [valid understanding points]
|
||||
|
||||
### What Was Disproven
|
||||
- ~~[disproven assumptions]~~
|
||||
|
||||
### Current Investigation Focus
|
||||
[current focus]
|
||||
|
||||
### Remaining Questions
|
||||
- [open questions]
|
||||
```
|
||||
|
||||
## Iteration Flow
|
||||
|
||||
```
|
||||
First Call (/workflow:debug-with-file "error"):
|
||||
├─ No session exists → Explore mode
|
||||
├─ Extract error keywords, search codebase
|
||||
├─ Document initial understanding in understanding.md
|
||||
├─ Use Gemini to generate hypotheses
|
||||
├─ Add logging instrumentation
|
||||
└─ Await user reproduction
|
||||
|
||||
After Reproduction (/workflow:debug-with-file "error"):
|
||||
├─ Session exists + debug.log has content → Analyze mode
|
||||
├─ Parse log, use Gemini to evaluate hypotheses
|
||||
├─ Update understanding.md with:
|
||||
│ ├─ Evidence analysis results
|
||||
│ ├─ Corrected misunderstandings (strikethrough)
|
||||
│ ├─ New insights
|
||||
│ └─ Updated consolidated understanding
|
||||
├─ Update hypotheses.json with verdicts
|
||||
└─ Decision:
|
||||
├─ Confirmed → Fix → Document resolution
|
||||
├─ Inconclusive → Add logging, document next steps
|
||||
└─ All rejected → Gemini-assisted new hypotheses
|
||||
|
||||
Output:
|
||||
├─ .workflow/.debug/DBG-{slug}-{date}/debug.log
|
||||
├─ .workflow/.debug/DBG-{slug}-{date}/understanding.md (evolving document)
|
||||
└─ .workflow/.debug/DBG-{slug}-{date}/hypotheses.json (history)
|
||||
```
|
||||
|
||||
## Gemini Integration Points
|
||||
|
||||
### 1. Hypothesis Generation (Explore Mode)
|
||||
|
||||
**Purpose**: Generate evidence-based, testable hypotheses
|
||||
|
||||
**Prompt Pattern**:
|
||||
```
|
||||
PURPOSE: Generate debugging hypotheses + evidence criteria
|
||||
TASK: Analyze error + code → testable hypotheses with clear pass/fail criteria
|
||||
CONTEXT: @understanding.md (search results)
|
||||
EXPECTED: JSON with hypotheses, likelihood ranking, evidence criteria
|
||||
```
|
||||
|
||||
### 2. Evidence Analysis (Analyze Mode)
|
||||
|
||||
**Purpose**: Validate hypotheses and correct misunderstandings
|
||||
|
||||
**Prompt Pattern**:
|
||||
```
|
||||
PURPOSE: Analyze debug log evidence + correct understanding
|
||||
TASK: Evaluate each hypothesis → identify wrong assumptions → suggest corrections
|
||||
CONTEXT: @debug.log @understanding.md @hypotheses.json
|
||||
EXPECTED: Verdicts + corrections + updated consolidated understanding
|
||||
```
|
||||
|
||||
### 3. New Hypothesis Generation (After All Rejected)
|
||||
|
||||
**Purpose**: Generate new hypotheses based on what was disproven
|
||||
|
||||
**Prompt Pattern**:
|
||||
```
|
||||
PURPOSE: Generate new hypotheses given disproven assumptions
|
||||
TASK: Review rejected hypotheses → identify knowledge gaps → new investigation angles
|
||||
CONTEXT: @understanding.md (with disproven section) @hypotheses.json
|
||||
EXPECTED: New hypotheses avoiding previously rejected paths
|
||||
```
|
||||
|
||||
## Error Correction Mechanism
|
||||
|
||||
### Correction Format in understanding.md
|
||||
|
||||
```markdown
|
||||
#### Corrected Understanding
|
||||
|
||||
- ~~Assumed dict key "config" was missing~~ → Key exists, but value is None
|
||||
- Why wrong: Only checked existence, not value validity
|
||||
- Evidence: H1 log shows {"config": null, "exists": true}
|
||||
|
||||
- ~~Thought error occurred in initialization~~ → Error happens during runtime update
|
||||
- Why wrong: Stack trace misread as init code
|
||||
- Evidence: H2 timestamp shows 30s after startup
|
||||
```
|
||||
|
||||
### Consolidation Rules
|
||||
|
||||
When updating "Current Consolidated Understanding":
|
||||
|
||||
1. **Simplify disproven items**: Move to "What Was Disproven" with single-line summary
|
||||
2. **Keep valid insights**: Promote confirmed findings to "What We Know"
|
||||
3. **Avoid duplication**: Don't repeat timeline details in consolidated section
|
||||
4. **Focus on current state**: What do we know NOW, not the journey
|
||||
5. **Preserve key corrections**: Keep important wrong→right transformations for learning
|
||||
|
||||
**Bad (cluttered)**:
|
||||
```markdown
|
||||
## Current Consolidated Understanding
|
||||
|
||||
In iteration 1 we thought X, but in iteration 2 we found Y, then in iteration 3...
|
||||
Also we checked A and found B, and then we checked C...
|
||||
```
|
||||
|
||||
**Good (consolidated)**:
|
||||
```markdown
|
||||
## Current Consolidated Understanding
|
||||
|
||||
### What We Know
|
||||
- Error occurs during runtime update, not initialization
|
||||
- Config value is None (not missing key)
|
||||
|
||||
### What Was Disproven
|
||||
- ~~Initialization error~~ (Timing evidence)
|
||||
- ~~Missing key hypothesis~~ (Key exists)
|
||||
|
||||
### Current Investigation Focus
|
||||
Why is config value None during update?
|
||||
```
|
||||
|
||||
## Post-Completion Expansion
|
||||
|
||||
完成后询问用户是否扩展为issue(test/enhance/refactor/doc),选中项调用 `/issue:new "{summary} - {dimension}"`
|
||||
|
||||
---
|
||||
|
||||
## Error Handling
|
||||
|
||||
| Situation | Action |
|
||||
|-----------|--------|
|
||||
| Empty debug.log | Verify reproduction triggered the code path |
|
||||
| All hypotheses rejected | Use Gemini to generate new hypotheses based on disproven assumptions |
|
||||
| Fix doesn't work | Document failed fix attempt, iterate with refined understanding |
|
||||
| >5 iterations | Review consolidated understanding, escalate to `/workflow:lite-fix` with full context |
|
||||
| Gemini unavailable | Fallback to manual hypothesis generation, document without Gemini insights |
|
||||
| Understanding too long | Consolidate aggressively, archive old iterations to separate file |
|
||||
|
||||
## Comparison with /workflow:debug
|
||||
|
||||
| Feature | /workflow:debug | /workflow:debug-with-file |
|
||||
|---------|-----------------|---------------------------|
|
||||
| NDJSON debug logging | ✅ | ✅ |
|
||||
| Hypothesis generation | Manual | Gemini-assisted |
|
||||
| Exploration documentation | ❌ | ✅ understanding.md |
|
||||
| Understanding evolution | ❌ | ✅ Timeline + corrections |
|
||||
| Error correction | ❌ | ✅ Strikethrough + reasoning |
|
||||
| Consolidated learning | ❌ | ✅ Current understanding section |
|
||||
| Hypothesis history | ❌ | ✅ hypotheses.json |
|
||||
| Gemini validation | ❌ | ✅ At key decision points |
|
||||
|
||||
## Usage Recommendations (Requires User Confirmation)
|
||||
|
||||
**Use `Skill(skill="workflow:debug-with-file", args="\"bug description\"")` when:**
|
||||
- Complex bugs requiring multiple investigation rounds
|
||||
- Learning from debugging process is valuable
|
||||
- Team needs to understand debugging rationale
|
||||
- Bug might recur, documentation helps prevention
|
||||
|
||||
**Use `Skill(skill="ccw-debug", args="--mode cli \"issue\"")` when:**
|
||||
- Simple, quick bugs
|
||||
- One-off issues
|
||||
- Documentation overhead not needed
|
||||
@@ -1,321 +0,0 @@
|
||||
---
|
||||
name: debug
|
||||
description: Interactive hypothesis-driven debugging with NDJSON logging, iterative until resolved
|
||||
argument-hint: "\"bug description or error message\""
|
||||
allowed-tools: TodoWrite(*), Task(*), AskUserQuestion(*), Read(*), Grep(*), Glob(*), Bash(*), Edit(*), Write(*)
|
||||
---
|
||||
|
||||
# Workflow Debug Command (/workflow:debug)
|
||||
|
||||
## Overview
|
||||
|
||||
Evidence-based interactive debugging command. Systematically identifies root causes through hypothesis-driven logging and iterative verification.
|
||||
|
||||
**Core workflow**: Explore → Add Logging → Reproduce → Analyze Log → Fix → Verify
|
||||
|
||||
## Usage
|
||||
|
||||
```bash
|
||||
/workflow:debug <BUG_DESCRIPTION>
|
||||
|
||||
# Arguments
|
||||
<bug-description> Bug description, error message, or stack trace (required)
|
||||
```
|
||||
|
||||
## Execution Process
|
||||
|
||||
```
|
||||
Session Detection:
|
||||
├─ Check if debug session exists for this bug
|
||||
├─ EXISTS + debug.log has content → Analyze mode
|
||||
└─ NOT_FOUND or empty log → Explore mode
|
||||
|
||||
Explore Mode:
|
||||
├─ Locate error source in codebase
|
||||
├─ Generate testable hypotheses (dynamic count)
|
||||
├─ Add NDJSON logging instrumentation
|
||||
└─ Output: Hypothesis list + await user reproduction
|
||||
|
||||
Analyze Mode:
|
||||
├─ Parse debug.log, validate each hypothesis
|
||||
└─ Decision:
|
||||
├─ Confirmed → Fix root cause
|
||||
├─ Inconclusive → Add more logging, iterate
|
||||
└─ All rejected → Generate new hypotheses
|
||||
|
||||
Fix & Cleanup:
|
||||
├─ Apply fix based on confirmed hypothesis
|
||||
├─ User verifies
|
||||
├─ Remove debug instrumentation
|
||||
└─ If not fixed → Return to Analyze mode
|
||||
```
|
||||
|
||||
## Implementation
|
||||
|
||||
### Session Setup & Mode Detection
|
||||
|
||||
```javascript
|
||||
const getUtc8ISOString = () => new Date(Date.now() + 8 * 60 * 60 * 1000).toISOString()
|
||||
|
||||
const bugSlug = bug_description.toLowerCase().replace(/[^a-z0-9]+/g, '-').substring(0, 30)
|
||||
const dateStr = getUtc8ISOString().substring(0, 10)
|
||||
|
||||
const sessionId = `DBG-${bugSlug}-${dateStr}`
|
||||
const sessionFolder = `.workflow/.debug/${sessionId}`
|
||||
const debugLogPath = `${sessionFolder}/debug.log`
|
||||
|
||||
// Auto-detect mode
|
||||
const sessionExists = fs.existsSync(sessionFolder)
|
||||
const logHasContent = sessionExists && fs.existsSync(debugLogPath) && fs.statSync(debugLogPath).size > 0
|
||||
|
||||
const mode = logHasContent ? 'analyze' : 'explore'
|
||||
|
||||
if (!sessionExists) {
|
||||
bash(`mkdir -p ${sessionFolder}`)
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### Explore Mode
|
||||
|
||||
**Step 1.1: Locate Error Source**
|
||||
|
||||
```javascript
|
||||
// Extract keywords from bug description
|
||||
const keywords = extractErrorKeywords(bug_description)
|
||||
// e.g., ['Stack Length', '未找到', 'registered 0']
|
||||
|
||||
// Search codebase for error locations
|
||||
for (const keyword of keywords) {
|
||||
Grep({ pattern: keyword, path: ".", output_mode: "content", "-C": 3 })
|
||||
}
|
||||
|
||||
// Identify affected files and functions
|
||||
const affectedLocations = [...] // from search results
|
||||
```
|
||||
|
||||
**Step 1.2: Generate Hypotheses (Dynamic)**
|
||||
|
||||
```javascript
|
||||
// Hypothesis categories based on error pattern
|
||||
const HYPOTHESIS_PATTERNS = {
|
||||
"not found|missing|undefined|未找到": "data_mismatch",
|
||||
"0|empty|zero|registered 0": "logic_error",
|
||||
"timeout|connection|sync": "integration_issue",
|
||||
"type|format|parse": "type_mismatch"
|
||||
}
|
||||
|
||||
// Generate hypotheses based on actual issue (NOT fixed count)
|
||||
function generateHypotheses(bugDescription, affectedLocations) {
|
||||
const hypotheses = []
|
||||
|
||||
// Analyze bug and create targeted hypotheses
|
||||
// Each hypothesis has:
|
||||
// - id: H1, H2, ... (dynamic count)
|
||||
// - description: What might be wrong
|
||||
// - testable_condition: What to log
|
||||
// - logging_point: Where to add instrumentation
|
||||
|
||||
return hypotheses // Could be 1, 3, 5, or more
|
||||
}
|
||||
|
||||
const hypotheses = generateHypotheses(bug_description, affectedLocations)
|
||||
```
|
||||
|
||||
**Step 1.3: Add NDJSON Instrumentation**
|
||||
|
||||
For each hypothesis, add logging at the relevant location:
|
||||
|
||||
**Python template**:
|
||||
```python
|
||||
# region debug [H{n}]
|
||||
try:
|
||||
import json, time
|
||||
_dbg = {
|
||||
"sid": "{sessionId}",
|
||||
"hid": "H{n}",
|
||||
"loc": "{file}:{line}",
|
||||
"msg": "{testable_condition}",
|
||||
"data": {
|
||||
# Capture relevant values here
|
||||
},
|
||||
"ts": int(time.time() * 1000)
|
||||
}
|
||||
with open(r"{debugLogPath}", "a", encoding="utf-8") as _f:
|
||||
_f.write(json.dumps(_dbg, ensure_ascii=False) + "\n")
|
||||
except: pass
|
||||
# endregion
|
||||
```
|
||||
|
||||
**JavaScript/TypeScript template**:
|
||||
```javascript
|
||||
// region debug [H{n}]
|
||||
try {
|
||||
require('fs').appendFileSync("{debugLogPath}", JSON.stringify({
|
||||
sid: "{sessionId}",
|
||||
hid: "H{n}",
|
||||
loc: "{file}:{line}",
|
||||
msg: "{testable_condition}",
|
||||
data: { /* Capture relevant values */ },
|
||||
ts: Date.now()
|
||||
}) + "\n");
|
||||
} catch(_) {}
|
||||
// endregion
|
||||
```
|
||||
|
||||
**Output to user**:
|
||||
```
|
||||
## Hypotheses Generated
|
||||
|
||||
Based on error "{bug_description}", generated {n} hypotheses:
|
||||
|
||||
{hypotheses.map(h => `
|
||||
### ${h.id}: ${h.description}
|
||||
- Logging at: ${h.logging_point}
|
||||
- Testing: ${h.testable_condition}
|
||||
`).join('')}
|
||||
|
||||
**Debug log**: ${debugLogPath}
|
||||
|
||||
**Next**: Run reproduction steps, then come back for analysis.
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### Analyze Mode
|
||||
|
||||
```javascript
|
||||
// Parse NDJSON log
|
||||
const entries = Read(debugLogPath).split('\n')
|
||||
.filter(l => l.trim())
|
||||
.map(l => JSON.parse(l))
|
||||
|
||||
// Group by hypothesis
|
||||
const byHypothesis = groupBy(entries, 'hid')
|
||||
|
||||
// Validate each hypothesis
|
||||
for (const [hid, logs] of Object.entries(byHypothesis)) {
|
||||
const hypothesis = hypotheses.find(h => h.id === hid)
|
||||
const latestLog = logs[logs.length - 1]
|
||||
|
||||
// Check if evidence confirms or rejects hypothesis
|
||||
const verdict = evaluateEvidence(hypothesis, latestLog.data)
|
||||
// Returns: 'confirmed' | 'rejected' | 'inconclusive'
|
||||
}
|
||||
```
|
||||
|
||||
**Output**:
|
||||
```
|
||||
## Evidence Analysis
|
||||
|
||||
Analyzed ${entries.length} log entries.
|
||||
|
||||
${results.map(r => `
|
||||
### ${r.id}: ${r.description}
|
||||
- **Status**: ${r.verdict}
|
||||
- **Evidence**: ${JSON.stringify(r.evidence)}
|
||||
- **Reason**: ${r.reason}
|
||||
`).join('')}
|
||||
|
||||
${confirmedHypothesis ? `
|
||||
## Root Cause Identified
|
||||
|
||||
**${confirmedHypothesis.id}**: ${confirmedHypothesis.description}
|
||||
|
||||
Ready to fix.
|
||||
` : `
|
||||
## Need More Evidence
|
||||
|
||||
Add more logging or refine hypotheses.
|
||||
`}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### Fix & Cleanup
|
||||
|
||||
```javascript
|
||||
// Apply fix based on confirmed hypothesis
|
||||
// ... Edit affected files
|
||||
|
||||
// After user verifies fix works:
|
||||
|
||||
// Remove debug instrumentation (search for region markers)
|
||||
const instrumentedFiles = Grep({
|
||||
pattern: "# region debug|// region debug",
|
||||
output_mode: "files_with_matches"
|
||||
})
|
||||
|
||||
for (const file of instrumentedFiles) {
|
||||
// Remove content between region markers
|
||||
removeDebugRegions(file)
|
||||
}
|
||||
|
||||
console.log(`
|
||||
## Debug Complete
|
||||
|
||||
- Root cause: ${confirmedHypothesis.description}
|
||||
- Fix applied to: ${modifiedFiles.join(', ')}
|
||||
- Debug instrumentation removed
|
||||
`)
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Debug Log Format (NDJSON)
|
||||
|
||||
Each line is a JSON object:
|
||||
|
||||
```json
|
||||
{"sid":"DBG-xxx-2025-12-18","hid":"H1","loc":"file.py:func:42","msg":"Check dict keys","data":{"keys":["a","b"],"target":"c","found":false},"ts":1734567890123}
|
||||
```
|
||||
|
||||
| Field | Description |
|
||||
|-------|-------------|
|
||||
| `sid` | Session ID |
|
||||
| `hid` | Hypothesis ID (H1, H2, ...) |
|
||||
| `loc` | Code location |
|
||||
| `msg` | What's being tested |
|
||||
| `data` | Captured values |
|
||||
| `ts` | Timestamp (ms) |
|
||||
|
||||
## Session Folder
|
||||
|
||||
```
|
||||
.workflow/.debug/DBG-{slug}-{date}/
|
||||
├── debug.log # NDJSON log (main artifact)
|
||||
└── resolution.md # Summary after fix (optional)
|
||||
```
|
||||
|
||||
## Iteration Flow
|
||||
|
||||
```
|
||||
First Call (/workflow:debug "error"):
|
||||
├─ No session exists → Explore mode
|
||||
├─ Extract error keywords, search codebase
|
||||
├─ Generate hypotheses, add logging
|
||||
└─ Await user reproduction
|
||||
|
||||
After Reproduction (/workflow:debug "error"):
|
||||
├─ Session exists + debug.log has content → Analyze mode
|
||||
├─ Parse log, evaluate hypotheses
|
||||
└─ Decision:
|
||||
├─ Confirmed → Fix → User verify
|
||||
│ ├─ Fixed → Cleanup → Done
|
||||
│ └─ Not fixed → Add logging → Iterate
|
||||
├─ Inconclusive → Add logging → Iterate
|
||||
└─ All rejected → New hypotheses → Iterate
|
||||
|
||||
Output:
|
||||
└─ .workflow/.debug/DBG-{slug}-{date}/debug.log
|
||||
```
|
||||
|
||||
## Error Handling
|
||||
|
||||
| Situation | Action |
|
||||
|-----------|--------|
|
||||
| Empty debug.log | Verify reproduction triggered the code path |
|
||||
| All hypotheses rejected | Generate new hypotheses with broader scope |
|
||||
| Fix doesn't work | Iterate with more granular logging |
|
||||
| >5 iterations | Escalate to `/workflow:lite-fix` with evidence |
|
||||
@@ -1,7 +1,7 @@
|
||||
---
|
||||
name: execute
|
||||
description: Coordinate agent execution for workflow tasks with automatic session discovery, parallel task processing, and status tracking
|
||||
argument-hint: "[--resume-session=\"session-id\"]"
|
||||
argument-hint: "[-y|--yes] [--resume-session=\"session-id\"] [--with-commit]"
|
||||
---
|
||||
|
||||
# Workflow Execute Command
|
||||
@@ -11,6 +11,41 @@ Orchestrates autonomous workflow execution through systematic task discovery, ag
|
||||
|
||||
**Resume Mode**: When called with `--resume-session` flag, skips discovery phase and directly enters TodoWrite generation and agent execution for the specified session.
|
||||
|
||||
## Usage
|
||||
|
||||
```bash
|
||||
# Interactive mode (with confirmations)
|
||||
/workflow:execute
|
||||
/workflow:execute --resume-session="WFS-auth"
|
||||
|
||||
# Auto mode (skip confirmations, use defaults)
|
||||
/workflow:execute --yes
|
||||
/workflow:execute -y
|
||||
/workflow:execute -y --resume-session="WFS-auth"
|
||||
|
||||
# With auto-commit (commit after each task completion)
|
||||
/workflow:execute --with-commit
|
||||
/workflow:execute -y --with-commit
|
||||
/workflow:execute -y --with-commit --resume-session="WFS-auth"
|
||||
```
|
||||
|
||||
## Auto Mode Defaults
|
||||
|
||||
When `--yes` or `-y` flag is used:
|
||||
- **Session Selection**: Automatically selects the first (most recent) active session
|
||||
- **Completion Choice**: Automatically completes session (runs `/workflow:session:complete --yes`)
|
||||
|
||||
When `--with-commit` flag is used:
|
||||
- **Auto-Commit**: After each agent task completes, commit changes based on summary document
|
||||
- **Commit Principle**: Minimal commits - only commit files modified by the completed task
|
||||
- **Commit Message**: Generated from task summary with format: "feat/fix/refactor: {task-title} - {summary}"
|
||||
|
||||
**Flag Parsing**:
|
||||
```javascript
|
||||
const autoYes = $ARGUMENTS.includes('--yes') || $ARGUMENTS.includes('-y')
|
||||
const withCommit = $ARGUMENTS.includes('--with-commit')
|
||||
```
|
||||
|
||||
## Performance Optimization Strategy
|
||||
|
||||
**Lazy Loading**: Task JSONs read **on-demand** during execution, not upfront. TODO_LIST.md + IMPL_PLAN.md provide metadata for planning.
|
||||
@@ -23,7 +58,7 @@ Orchestrates autonomous workflow execution through systematic task discovery, ag
|
||||
## Core Rules
|
||||
**Complete entire workflow autonomously without user interruption, using TodoWrite for comprehensive progress tracking.**
|
||||
**Execute all discovered pending tasks until workflow completion or blocking dependency.**
|
||||
**Auto-complete session when all tasks finished: Call `/workflow:session:complete` upon workflow completion.**
|
||||
**User-choice completion: When all tasks finished, ask user to choose review or complete.**
|
||||
**ONE AGENT = ONE TASK JSON: Each agent instance executes exactly one task JSON file - never batch multiple tasks into single agent execution.**
|
||||
|
||||
## Core Responsibilities
|
||||
@@ -33,7 +68,7 @@ Orchestrates autonomous workflow execution through systematic task discovery, ag
|
||||
- **Agent Orchestration**: Coordinate specialized agents with complete context
|
||||
- **Status Synchronization**: Update task JSON files and workflow state
|
||||
- **Autonomous Completion**: Continue execution until all tasks complete or reach blocking state
|
||||
- **Session Auto-Complete**: Call `/workflow:session:complete` when all workflow tasks finished
|
||||
- **Session User-Choice Completion**: Ask user to choose review or complete when all tasks finished
|
||||
|
||||
## Execution Philosophy
|
||||
- **Progress tracking**: Continuous TodoWrite updates throughout entire workflow execution
|
||||
@@ -71,12 +106,19 @@ Phase 4: Execution Strategy & Task Execution
|
||||
├─ Mark task completed (update IMPL-*.json status)
|
||||
│ # Quick fix: Update task status for ccw dashboard
|
||||
│ # TS=$(date -Iseconds) && jq --arg ts "$TS" '.status="completed" | .status_history=(.status_history // [])+[{"from":"in_progress","to":"completed","changed_at":$ts}]' IMPL-X.json > tmp.json && mv tmp.json IMPL-X.json
|
||||
├─ [with-commit] Commit changes based on summary (minimal principle)
|
||||
│ # Read summary from .summaries/IMPL-X-summary.md
|
||||
│ # Extract changed files from summary's "Files Modified" section
|
||||
│ # Generate commit message: "feat/fix/refactor: {task-title} - {summary}"
|
||||
│ # git add <changed-files> && git commit -m "<commit-message>"
|
||||
└─ Advance to next task
|
||||
|
||||
Phase 5: Completion
|
||||
├─ Update task statuses in JSON files
|
||||
├─ Generate summaries
|
||||
└─ Auto-call /workflow:session:complete
|
||||
└─ AskUserQuestion: Choose next step
|
||||
├─ "Enter Review" → /workflow:review
|
||||
└─ "Complete Session" → /workflow:session:complete
|
||||
|
||||
Resume Mode (--resume-session):
|
||||
├─ Skip Phase 1 & Phase 2
|
||||
@@ -117,34 +159,41 @@ Auto-select and continue to Phase 2.
|
||||
|
||||
List sessions with metadata and prompt user selection:
|
||||
```bash
|
||||
bash(for dir in .workflow/active/WFS-*/; do
|
||||
session=$(basename "$dir")
|
||||
project=$(jq -r '.project // "Unknown"' "$dir/workflow-session.json" 2>/dev/null)
|
||||
total=$(grep -c "^- \[" "$dir/TODO_LIST.md" 2>/dev/null || echo "0")
|
||||
completed=$(grep -c "^- \[x\]" "$dir/TODO_LIST.md" 2>/dev/null || echo "0")
|
||||
[ "$total" -gt 0 ] && progress=$((completed * 100 / total)) || progress=0
|
||||
echo "${session} | ${project} | ${completed}/${total} tasks (${progress}%)"
|
||||
done)
|
||||
bash(for dir in .workflow/active/WFS-*/; do [ -d "$dir" ] || continue; session=$(basename "$dir"); project=$(jq -r '.project // "Unknown"' "${dir}workflow-session.json" 2>/dev/null || echo "Unknown"); total=$(grep -c '^\- \[' "${dir}TODO_LIST.md" 2>/dev/null || echo 0); completed=$(grep -c '^\- \[x\]' "${dir}TODO_LIST.md" 2>/dev/null || echo 0); if [ "$total" -gt 0 ]; then progress=$((completed * 100 / total)); else progress=0; fi; echo "$session | $project | $completed/$total tasks ($progress%)"; done)
|
||||
```
|
||||
|
||||
Use AskUserQuestion to present formatted options (max 4 options shown):
|
||||
**Parse --yes flag**:
|
||||
```javascript
|
||||
// If more than 4 sessions, show most recent 4 with "Other" option for manual input
|
||||
const sessions = getActiveSessions() // sorted by last modified
|
||||
const displaySessions = sessions.slice(0, 4)
|
||||
const autoYes = $ARGUMENTS.includes('--yes') || $ARGUMENTS.includes('-y')
|
||||
```
|
||||
|
||||
AskUserQuestion({
|
||||
questions: [{
|
||||
question: "Multiple active sessions detected. Select one:",
|
||||
header: "Session",
|
||||
multiSelect: false,
|
||||
options: displaySessions.map(s => ({
|
||||
label: s.id,
|
||||
description: `${s.project} | ${s.progress}`
|
||||
}))
|
||||
// Note: User can select "Other" to manually enter session ID
|
||||
}]
|
||||
})
|
||||
**Conditional Selection**:
|
||||
```javascript
|
||||
if (autoYes) {
|
||||
// Auto mode: Select first session (most recent)
|
||||
const firstSession = sessions[0]
|
||||
console.log(`[--yes] Auto-selecting session: ${firstSession.id}`)
|
||||
selectedSessionId = firstSession.id
|
||||
// Continue to Phase 2
|
||||
} else {
|
||||
// Interactive mode: Use AskUserQuestion to present formatted options (max 4 options shown)
|
||||
// If more than 4 sessions, show most recent 4 with "Other" option for manual input
|
||||
const sessions = getActiveSessions() // sorted by last modified
|
||||
const displaySessions = sessions.slice(0, 4)
|
||||
|
||||
AskUserQuestion({
|
||||
questions: [{
|
||||
question: "Multiple active sessions detected. Select one:",
|
||||
header: "Session",
|
||||
multiSelect: false,
|
||||
options: displaySessions.map(s => ({
|
||||
label: s.id,
|
||||
description: `${s.project} | ${s.progress}`
|
||||
}))
|
||||
// Note: User can select "Other" to manually enter session ID
|
||||
}]
|
||||
})
|
||||
}
|
||||
```
|
||||
|
||||
**Input Validation**:
|
||||
@@ -240,7 +289,13 @@ while (TODO_LIST.md has pending tasks) {
|
||||
4. **Launch Agent**: Invoke specialized agent with complete context including flow control steps
|
||||
5. **Monitor Progress**: Track agent execution and handle errors without user interruption
|
||||
6. **Collect Results**: Gather implementation results and outputs
|
||||
7. **Continue Workflow**: Identify next pending task from TODO_LIST.md and repeat
|
||||
7. **[with-commit] Auto-Commit**: If `--with-commit` flag enabled, commit changes based on summary
|
||||
- Read summary from `.summaries/{task-id}-summary.md`
|
||||
- Extract changed files from summary's "Files Modified" section
|
||||
- Determine commit type from `meta.type` (feature→feat, bugfix→fix, refactor→refactor)
|
||||
- Generate commit message: "{type}: {task-title} - {summary-first-line}"
|
||||
- Commit only modified files (minimal principle): `git add <files> && git commit -m "<message>"`
|
||||
8. **Continue Workflow**: Identify next pending task from TODO_LIST.md and repeat
|
||||
|
||||
**Note**: TODO_LIST.md updates are handled by agents (e.g., code-developer.md), not by the orchestrator.
|
||||
|
||||
@@ -254,7 +309,45 @@ while (TODO_LIST.md has pending tasks) {
|
||||
3. **Update TodoWrite**: Mark current task complete, advance to next
|
||||
4. **Synchronize State**: Update session state and workflow status
|
||||
5. **Check Workflow Complete**: Verify all tasks are completed
|
||||
6. **Auto-Complete Session**: Call `/workflow:session:complete` when all tasks finished
|
||||
6. **User Choice**: When all tasks finished, ask user to choose next step:
|
||||
|
||||
```javascript
|
||||
// Parse --yes flag
|
||||
const autoYes = $ARGUMENTS.includes('--yes') || $ARGUMENTS.includes('-y')
|
||||
|
||||
if (autoYes) {
|
||||
// Auto mode: Complete session automatically
|
||||
console.log(`[--yes] Auto-selecting: Complete Session`)
|
||||
Skill(skill="workflow:session:complete", args="--yes")
|
||||
} else {
|
||||
// Interactive mode: Ask user
|
||||
AskUserQuestion({
|
||||
questions: [{
|
||||
question: "All tasks completed. What would you like to do next?",
|
||||
header: "Next Step",
|
||||
multiSelect: false,
|
||||
options: [
|
||||
{
|
||||
label: "Enter Review",
|
||||
description: "Run specialized review (security/architecture/quality/action-items)"
|
||||
},
|
||||
{
|
||||
label: "Complete Session",
|
||||
description: "Archive session and update manifest"
|
||||
}
|
||||
]
|
||||
}]
|
||||
})
|
||||
}
|
||||
```
|
||||
|
||||
**Based on user selection**:
|
||||
- **"Enter Review"**: Execute `/workflow:review`
|
||||
- **"Complete Session"**: Execute `/workflow:session:complete`
|
||||
|
||||
### Post-Completion Expansion
|
||||
|
||||
完成后询问用户是否扩展为issue(test/enhance/refactor/doc),选中项调用 `/issue:new "{summary} - {dimension}"`
|
||||
|
||||
## Execution Strategy (IMPL_PLAN-Driven)
|
||||
|
||||
@@ -330,7 +423,7 @@ blocked → skip until dependencies clear
|
||||
- **Continuous Tracking**: Maintain TodoWrite throughout entire workflow execution until completion
|
||||
|
||||
**Rule 4: Workflow Completion Check**
|
||||
- When all tasks marked `completed`, auto-call `/workflow:session:complete`
|
||||
- When all tasks marked `completed`, prompt user to choose review or complete session
|
||||
|
||||
### TodoWrite Tool Usage
|
||||
|
||||
@@ -388,40 +481,42 @@ TodoWrite({
|
||||
**Note**: Orchestrator does NOT execute flow control steps - Agent interprets and executes them autonomously.
|
||||
|
||||
### Agent Prompt Template
|
||||
**Dynamic Generation**: Before agent invocation, read task JSON and extract key requirements.
|
||||
**Path-Based Invocation**: Pass paths and trigger markers, let agent parse task JSON autonomously.
|
||||
|
||||
```bash
|
||||
Task(subagent_type="{meta.agent}",
|
||||
run_in_background=false,
|
||||
prompt="Execute task: {task.title}
|
||||
prompt="Implement task {task.id}: {task.title}
|
||||
|
||||
{[FLOW_CONTROL]}
|
||||
[FLOW_CONTROL]
|
||||
|
||||
**Task Objectives** (from task JSON):
|
||||
{task.context.objective}
|
||||
|
||||
**Expected Deliverables** (from task JSON):
|
||||
{task.context.deliverables}
|
||||
|
||||
**Quality Standards** (from task JSON):
|
||||
{task.context.acceptance_criteria}
|
||||
|
||||
**MANDATORY FIRST STEPS**:
|
||||
1. Read complete task JSON: {session.task_json_path}
|
||||
2. Load context package: {session.context_package_path}
|
||||
|
||||
Follow complete execution guidelines in @.claude/agents/{meta.agent}.md
|
||||
|
||||
**Session Paths**:
|
||||
- Workflow Dir: {session.workflow_dir}
|
||||
- TODO List: {session.todo_list_path}
|
||||
- Summaries Dir: {session.summaries_dir}
|
||||
**Input**:
|
||||
- Task JSON: {session.task_json_path}
|
||||
- Context Package: {session.context_package_path}
|
||||
|
||||
**Success Criteria**: Complete all objectives, meet all quality standards, deliver all outputs as specified above.",
|
||||
description="Executing: {task.title}")
|
||||
**Output Location**:
|
||||
- Workflow: {session.workflow_dir}
|
||||
- TODO List: {session.todo_list_path}
|
||||
- Summaries: {session.summaries_dir}
|
||||
|
||||
**Execution**: Read task JSON → Execute pre_analysis → Check execution_config.method → (CLI: handoff to CLI tool | Agent: direct implementation) → Update TODO_LIST.md → Generate summary",
|
||||
description="Implement: {task.id}")
|
||||
```
|
||||
|
||||
**Key Markers**:
|
||||
- `Implement` keyword: Triggers tech stack detection and guidelines loading
|
||||
- `[FLOW_CONTROL]`: Triggers flow_control.pre_analysis execution
|
||||
|
||||
**Why Path-Based**: Agent (code-developer.md) autonomously:
|
||||
- Reads and parses task JSON (requirements, acceptance, flow_control, execution_config)
|
||||
- Executes pre_analysis steps (Phase 1: context gathering)
|
||||
- Checks execution_config.method (Phase 2: determine mode)
|
||||
- CLI mode: Builds handoff prompt and executes via ccw cli with resume strategy
|
||||
- Agent mode: Directly implements using modification_points and logic_flow
|
||||
- Generates structured summary with integration points
|
||||
|
||||
Embedding task content in prompt creates duplication and conflicts with agent's parsing logic.
|
||||
|
||||
### Agent Assignment Rules
|
||||
```
|
||||
meta.agent specified → Use specified agent
|
||||
@@ -473,3 +568,26 @@ meta.agent missing → Infer from meta.type:
|
||||
- **Dependency Validation**: Check all depends_on references exist
|
||||
- **Context Verification**: Ensure all required context is available
|
||||
|
||||
## Auto-Commit Mode (--with-commit)
|
||||
|
||||
**Behavior**: After each agent task completes, automatically commit changes based on summary document.
|
||||
|
||||
**Minimal Principle**: Only commit files modified by the completed task.
|
||||
|
||||
**Commit Message Format**: `{type}: {task-title} - {summary}`
|
||||
|
||||
**Type Mapping** (from `meta.type`):
|
||||
- `feature` → `feat` | `bugfix` → `fix` | `refactor` → `refactor`
|
||||
- `test-gen` → `test` | `docs` → `docs` | `review` → `chore`
|
||||
|
||||
**Implementation**:
|
||||
```bash
|
||||
# 1. Read summary from .summaries/{task-id}-summary.md
|
||||
# 2. Extract files from "Files Modified" section
|
||||
# 3. Commit: git add <files> && git commit -m "{type}: {title} - {summary}"
|
||||
```
|
||||
|
||||
**Error Handling**: Skip commit on no changes/missing summary, log errors, continue workflow.
|
||||
|
||||
|
||||
|
||||
|
||||
408
.claude/commands/workflow/init-guidelines.md
Normal file
408
.claude/commands/workflow/init-guidelines.md
Normal file
@@ -0,0 +1,408 @@
|
||||
---
|
||||
name: init-guidelines
|
||||
description: Interactive wizard to fill project-guidelines.json based on project analysis
|
||||
argument-hint: "[--reset]"
|
||||
examples:
|
||||
- /workflow:init-guidelines
|
||||
- /workflow:init-guidelines --reset
|
||||
---
|
||||
|
||||
# Workflow Init Guidelines Command (/workflow:init-guidelines)
|
||||
|
||||
## Overview
|
||||
|
||||
Interactive multi-round wizard that analyzes the current project (via `project-tech.json`) and asks targeted questions to populate `.workflow/project-guidelines.json` with coding conventions, constraints, and quality rules.
|
||||
|
||||
**Design Principle**: Questions are dynamically generated based on the project's tech stack, architecture, and patterns — not generic boilerplate.
|
||||
|
||||
**Note**: This command may be called by `/workflow:init` after initialization. Upon completion, return to the calling workflow if applicable.
|
||||
|
||||
## Usage
|
||||
```bash
|
||||
/workflow:init-guidelines # Fill guidelines interactively (skip if already populated)
|
||||
/workflow:init-guidelines --reset # Reset and re-fill guidelines from scratch
|
||||
```
|
||||
|
||||
## Execution Process
|
||||
|
||||
```
|
||||
Input Parsing:
|
||||
└─ Parse --reset flag → reset = true | false
|
||||
|
||||
Step 1: Check Prerequisites
|
||||
├─ project-tech.json must exist (run /workflow:init first)
|
||||
├─ project-guidelines.json: check if populated or scaffold-only
|
||||
└─ If populated + no --reset → Ask: "Guidelines already exist. Overwrite or append?"
|
||||
|
||||
Step 2: Load Project Context
|
||||
└─ Read project-tech.json → extract tech stack, architecture, patterns
|
||||
|
||||
Step 3: Multi-Round Interactive Questionnaire
|
||||
├─ Round 1: Coding Conventions (coding_style, naming_patterns)
|
||||
├─ Round 2: File & Documentation Conventions (file_structure, documentation)
|
||||
├─ Round 3: Architecture & Tech Constraints (architecture, tech_stack)
|
||||
├─ Round 4: Performance & Security Constraints (performance, security)
|
||||
└─ Round 5: Quality Rules (quality_rules)
|
||||
|
||||
Step 4: Write project-guidelines.json
|
||||
|
||||
Step 5: Display Summary
|
||||
```
|
||||
|
||||
## Implementation
|
||||
|
||||
### Step 1: Check Prerequisites
|
||||
|
||||
```bash
|
||||
bash(test -f .workflow/project-tech.json && echo "TECH_EXISTS" || echo "TECH_NOT_FOUND")
|
||||
bash(test -f .workflow/project-guidelines.json && echo "GUIDELINES_EXISTS" || echo "GUIDELINES_NOT_FOUND")
|
||||
```
|
||||
|
||||
**If TECH_NOT_FOUND**: Exit with message
|
||||
```
|
||||
Project tech analysis not found. Run /workflow:init first.
|
||||
```
|
||||
|
||||
**Parse --reset flag**:
|
||||
```javascript
|
||||
const reset = $ARGUMENTS.includes('--reset')
|
||||
```
|
||||
|
||||
**If GUIDELINES_EXISTS and not --reset**: Check if guidelines are populated (not just scaffold)
|
||||
|
||||
```javascript
|
||||
const guidelines = JSON.parse(Read('.workflow/project-guidelines.json'))
|
||||
const isPopulated =
|
||||
guidelines.conventions.coding_style.length > 0 ||
|
||||
guidelines.conventions.naming_patterns.length > 0 ||
|
||||
guidelines.constraints.architecture.length > 0 ||
|
||||
guidelines.constraints.tech_stack.length > 0
|
||||
|
||||
if (isPopulated) {
|
||||
AskUserQuestion({
|
||||
questions: [{
|
||||
question: "Project guidelines already contain entries. How would you like to proceed?",
|
||||
header: "Mode",
|
||||
multiSelect: false,
|
||||
options: [
|
||||
{ label: "Append", description: "Keep existing entries and add new ones from the wizard" },
|
||||
{ label: "Reset", description: "Clear all existing entries and start fresh" },
|
||||
{ label: "Cancel", description: "Exit without changes" }
|
||||
]
|
||||
}]
|
||||
})
|
||||
// If Cancel → exit
|
||||
// If Reset → clear all arrays before proceeding
|
||||
// If Append → keep existing, wizard adds to them
|
||||
}
|
||||
```
|
||||
|
||||
### Step 2: Load Project Context
|
||||
|
||||
```javascript
|
||||
const projectTech = JSON.parse(Read('.workflow/project-tech.json'))
|
||||
|
||||
// Extract key info for generating smart questions
|
||||
const languages = projectTech.technology_analysis?.technology_stack?.languages
|
||||
|| projectTech.overview?.technology_stack?.languages || []
|
||||
const primaryLang = languages.find(l => l.primary)?.name || languages[0]?.name || 'Unknown'
|
||||
const frameworks = projectTech.technology_analysis?.technology_stack?.frameworks
|
||||
|| projectTech.overview?.technology_stack?.frameworks || []
|
||||
const testFrameworks = projectTech.technology_analysis?.technology_stack?.test_frameworks
|
||||
|| projectTech.overview?.technology_stack?.test_frameworks || []
|
||||
const archStyle = projectTech.technology_analysis?.architecture?.style
|
||||
|| projectTech.overview?.architecture?.style || 'Unknown'
|
||||
const archPatterns = projectTech.technology_analysis?.architecture?.patterns
|
||||
|| projectTech.overview?.architecture?.patterns || []
|
||||
const buildTools = projectTech.technology_analysis?.technology_stack?.build_tools
|
||||
|| projectTech.overview?.technology_stack?.build_tools || []
|
||||
```
|
||||
|
||||
### Step 3: Multi-Round Interactive Questionnaire
|
||||
|
||||
Each round uses `AskUserQuestion` with project-aware options. The user can always select "Other" to provide custom input.
|
||||
|
||||
**⚠️ CRITICAL**: After each round, collect the user's answers and convert them into guideline entries. Do NOT batch all rounds — process each round's answers before proceeding to the next.
|
||||
|
||||
---
|
||||
|
||||
#### Round 1: Coding Conventions
|
||||
|
||||
Generate options dynamically based on detected language/framework:
|
||||
|
||||
```javascript
|
||||
// Build language-specific coding style options
|
||||
const codingStyleOptions = []
|
||||
|
||||
if (['TypeScript', 'JavaScript'].includes(primaryLang)) {
|
||||
codingStyleOptions.push(
|
||||
{ label: "Strict TypeScript", description: "Use strict mode, no 'any' type, explicit return types for public APIs" },
|
||||
{ label: "Functional style", description: "Prefer pure functions, immutability, avoid class-based patterns where possible" },
|
||||
{ label: "Const over let", description: "Always use const; only use let when reassignment is truly needed" }
|
||||
)
|
||||
} else if (primaryLang === 'Python') {
|
||||
codingStyleOptions.push(
|
||||
{ label: "Type hints", description: "Use type hints for all function signatures and class attributes" },
|
||||
{ label: "Functional style", description: "Prefer pure functions, list comprehensions, avoid mutable state" },
|
||||
{ label: "PEP 8 strict", description: "Strict PEP 8 compliance with max line length 88 (Black formatter)" }
|
||||
)
|
||||
} else if (primaryLang === 'Go') {
|
||||
codingStyleOptions.push(
|
||||
{ label: "Error wrapping", description: "Always wrap errors with context using fmt.Errorf with %w" },
|
||||
{ label: "Interface first", description: "Define interfaces at the consumer side, not the provider" },
|
||||
{ label: "Table-driven tests", description: "Use table-driven test pattern for all unit tests" }
|
||||
)
|
||||
}
|
||||
// Add universal options
|
||||
codingStyleOptions.push(
|
||||
{ label: "Early returns", description: "Prefer early returns / guard clauses over deep nesting" }
|
||||
)
|
||||
|
||||
AskUserQuestion({
|
||||
questions: [
|
||||
{
|
||||
question: `Your project uses ${primaryLang}. Which coding style conventions do you follow?`,
|
||||
header: "Coding Style",
|
||||
multiSelect: true,
|
||||
options: codingStyleOptions.slice(0, 4) // Max 4 options
|
||||
},
|
||||
{
|
||||
question: `What naming conventions does your ${primaryLang} project use?`,
|
||||
header: "Naming",
|
||||
multiSelect: true,
|
||||
options: [
|
||||
{ label: "camelCase variables", description: "Variables and functions use camelCase (e.g., getUserName)" },
|
||||
{ label: "PascalCase types", description: "Classes, interfaces, type aliases use PascalCase (e.g., UserService)" },
|
||||
{ label: "UPPER_SNAKE constants", description: "Constants use UPPER_SNAKE_CASE (e.g., MAX_RETRIES)" },
|
||||
{ label: "Prefix interfaces", description: "Prefix interfaces with 'I' (e.g., IUserService)" }
|
||||
]
|
||||
}
|
||||
]
|
||||
})
|
||||
```
|
||||
|
||||
**Process Round 1 answers** → add to `conventions.coding_style` and `conventions.naming_patterns` arrays.
|
||||
|
||||
---
|
||||
|
||||
#### Round 2: File Structure & Documentation
|
||||
|
||||
```javascript
|
||||
AskUserQuestion({
|
||||
questions: [
|
||||
{
|
||||
question: `Your project has a ${archStyle} architecture. What file organization rules apply?`,
|
||||
header: "File Structure",
|
||||
multiSelect: true,
|
||||
options: [
|
||||
{ label: "Co-located tests", description: "Test files live next to source files (e.g., foo.ts + foo.test.ts)" },
|
||||
{ label: "Separate test dir", description: "Tests in a dedicated __tests__ or tests/ directory" },
|
||||
{ label: "One export per file", description: "Each file exports a single main component/class/function" },
|
||||
{ label: "Index barrels", description: "Use index.ts barrel files for clean imports from directories" }
|
||||
]
|
||||
},
|
||||
{
|
||||
question: "What documentation standards does your project follow?",
|
||||
header: "Documentation",
|
||||
multiSelect: true,
|
||||
options: [
|
||||
{ label: "JSDoc/docstring public APIs", description: "All public functions and classes must have JSDoc/docstrings" },
|
||||
{ label: "README per module", description: "Each major module/package has its own README" },
|
||||
{ label: "Inline comments for why", description: "Comments explain 'why', not 'what' — code should be self-documenting" },
|
||||
{ label: "No comment requirement", description: "Code should be self-explanatory; comments only for non-obvious logic" }
|
||||
]
|
||||
}
|
||||
]
|
||||
})
|
||||
```
|
||||
|
||||
**Process Round 2 answers** → add to `conventions.file_structure` and `conventions.documentation`.
|
||||
|
||||
---
|
||||
|
||||
#### Round 3: Architecture & Tech Stack Constraints
|
||||
|
||||
```javascript
|
||||
// Build architecture-specific options
|
||||
const archOptions = []
|
||||
|
||||
if (archStyle.toLowerCase().includes('monolith')) {
|
||||
archOptions.push(
|
||||
{ label: "No circular deps", description: "Modules must not have circular dependencies" },
|
||||
{ label: "Layer boundaries", description: "Strict layer separation: UI → Service → Data (no skipping layers)" }
|
||||
)
|
||||
} else if (archStyle.toLowerCase().includes('microservice')) {
|
||||
archOptions.push(
|
||||
{ label: "Service isolation", description: "Services must not share databases or internal state" },
|
||||
{ label: "API contracts", description: "All inter-service communication through versioned API contracts" }
|
||||
)
|
||||
}
|
||||
archOptions.push(
|
||||
{ label: "Stateless services", description: "Service/business logic must be stateless (state in DB/cache only)" },
|
||||
{ label: "Dependency injection", description: "Use dependency injection for testability, no hardcoded dependencies" }
|
||||
)
|
||||
|
||||
AskUserQuestion({
|
||||
questions: [
|
||||
{
|
||||
question: `Your ${archStyle} architecture uses ${archPatterns.join(', ') || 'various'} patterns. What architecture constraints apply?`,
|
||||
header: "Architecture",
|
||||
multiSelect: true,
|
||||
options: archOptions.slice(0, 4)
|
||||
},
|
||||
{
|
||||
question: `Tech stack: ${frameworks.join(', ')}. What technology constraints apply?`,
|
||||
header: "Tech Stack",
|
||||
multiSelect: true,
|
||||
options: [
|
||||
{ label: "No new deps without review", description: "Adding new dependencies requires explicit justification and review" },
|
||||
{ label: "Pin dependency versions", description: "All dependencies must use exact versions, not ranges" },
|
||||
{ label: "Prefer native APIs", description: "Use built-in/native APIs over third-party libraries when possible" },
|
||||
{ label: "Framework conventions", description: `Follow official ${frameworks[0] || 'framework'} conventions and best practices` }
|
||||
]
|
||||
}
|
||||
]
|
||||
})
|
||||
```
|
||||
|
||||
**Process Round 3 answers** → add to `constraints.architecture` and `constraints.tech_stack`.
|
||||
|
||||
---
|
||||
|
||||
#### Round 4: Performance & Security Constraints
|
||||
|
||||
```javascript
|
||||
AskUserQuestion({
|
||||
questions: [
|
||||
{
|
||||
question: "What performance requirements does your project have?",
|
||||
header: "Performance",
|
||||
multiSelect: true,
|
||||
options: [
|
||||
{ label: "API response time", description: "API endpoints must respond within 200ms (p95)" },
|
||||
{ label: "Bundle size limit", description: "Frontend bundle size must stay under 500KB gzipped" },
|
||||
{ label: "Lazy loading", description: "Large modules/routes must use lazy loading / code splitting" },
|
||||
{ label: "No N+1 queries", description: "Database access must avoid N+1 query patterns" }
|
||||
]
|
||||
},
|
||||
{
|
||||
question: "What security requirements does your project enforce?",
|
||||
header: "Security",
|
||||
multiSelect: true,
|
||||
options: [
|
||||
{ label: "Input sanitization", description: "All user input must be validated and sanitized before use" },
|
||||
{ label: "No secrets in code", description: "No API keys, passwords, or tokens in source code — use env vars" },
|
||||
{ label: "Auth on all endpoints", description: "All API endpoints require authentication unless explicitly public" },
|
||||
{ label: "Parameterized queries", description: "All database queries must use parameterized/prepared statements" }
|
||||
]
|
||||
}
|
||||
]
|
||||
})
|
||||
```
|
||||
|
||||
**Process Round 4 answers** → add to `constraints.performance` and `constraints.security`.
|
||||
|
||||
---
|
||||
|
||||
#### Round 5: Quality Rules
|
||||
|
||||
```javascript
|
||||
AskUserQuestion({
|
||||
questions: [
|
||||
{
|
||||
question: `Testing with ${testFrameworks.join(', ') || 'your test framework'}. What quality rules apply?`,
|
||||
header: "Quality",
|
||||
multiSelect: true,
|
||||
options: [
|
||||
{ label: "Min test coverage", description: "Minimum 80% code coverage for new code; no merging below threshold" },
|
||||
{ label: "No skipped tests", description: "Tests must not be skipped (.skip/.only) in committed code" },
|
||||
{ label: "Lint must pass", description: "All code must pass linter checks before commit (enforced by pre-commit)" },
|
||||
{ label: "Type check must pass", description: "Full type checking (tsc --noEmit) must pass with zero errors" }
|
||||
]
|
||||
}
|
||||
]
|
||||
})
|
||||
```
|
||||
|
||||
**Process Round 5 answers** → add to `quality_rules` array as `{ rule, scope, enforced_by }` objects.
|
||||
|
||||
### Step 4: Write project-guidelines.json
|
||||
|
||||
```javascript
|
||||
// Build the final guidelines object
|
||||
const finalGuidelines = {
|
||||
conventions: {
|
||||
coding_style: existingCodingStyle.concat(newCodingStyle),
|
||||
naming_patterns: existingNamingPatterns.concat(newNamingPatterns),
|
||||
file_structure: existingFileStructure.concat(newFileStructure),
|
||||
documentation: existingDocumentation.concat(newDocumentation)
|
||||
},
|
||||
constraints: {
|
||||
architecture: existingArchitecture.concat(newArchitecture),
|
||||
tech_stack: existingTechStack.concat(newTechStack),
|
||||
performance: existingPerformance.concat(newPerformance),
|
||||
security: existingSecurity.concat(newSecurity)
|
||||
},
|
||||
quality_rules: existingQualityRules.concat(newQualityRules),
|
||||
learnings: existingLearnings, // Preserve existing learnings
|
||||
_metadata: {
|
||||
created_at: existingMetadata?.created_at || new Date().toISOString(),
|
||||
version: "1.0.0",
|
||||
last_updated: new Date().toISOString(),
|
||||
updated_by: "workflow:init-guidelines"
|
||||
}
|
||||
}
|
||||
|
||||
Write('.workflow/project-guidelines.json', JSON.stringify(finalGuidelines, null, 2))
|
||||
```
|
||||
|
||||
### Step 5: Display Summary
|
||||
|
||||
```javascript
|
||||
const countConventions = finalGuidelines.conventions.coding_style.length
|
||||
+ finalGuidelines.conventions.naming_patterns.length
|
||||
+ finalGuidelines.conventions.file_structure.length
|
||||
+ finalGuidelines.conventions.documentation.length
|
||||
|
||||
const countConstraints = finalGuidelines.constraints.architecture.length
|
||||
+ finalGuidelines.constraints.tech_stack.length
|
||||
+ finalGuidelines.constraints.performance.length
|
||||
+ finalGuidelines.constraints.security.length
|
||||
|
||||
const countQuality = finalGuidelines.quality_rules.length
|
||||
|
||||
console.log(`
|
||||
✓ Project guidelines configured
|
||||
|
||||
## Summary
|
||||
- Conventions: ${countConventions} rules (coding: ${cs}, naming: ${np}, files: ${fs}, docs: ${doc})
|
||||
- Constraints: ${countConstraints} rules (arch: ${ar}, tech: ${ts}, perf: ${pf}, security: ${sc})
|
||||
- Quality rules: ${countQuality}
|
||||
|
||||
File: .workflow/project-guidelines.json
|
||||
|
||||
Next steps:
|
||||
- Use /workflow:session:solidify to add individual rules later
|
||||
- Guidelines will be auto-loaded by /workflow:plan for task generation
|
||||
`)
|
||||
```
|
||||
|
||||
## Answer Processing Rules
|
||||
|
||||
When converting user selections to guideline entries:
|
||||
|
||||
1. **Selected option** → Use the option's `description` as the guideline string (it's more precise than the label)
|
||||
2. **"Other" with custom text** → Use the user's text directly as the guideline string
|
||||
3. **Deduplication** → Skip entries that already exist in the guidelines (exact string match)
|
||||
4. **Quality rules** → Convert to `{ rule: description, scope: "all", enforced_by: "code-review" }` format
|
||||
|
||||
## Error Handling
|
||||
|
||||
- **No project-tech.json**: Exit with instruction to run `/workflow:init` first
|
||||
- **User cancels mid-wizard**: Save whatever was collected so far (partial is better than nothing)
|
||||
- **File write failure**: Report error, suggest manual edit
|
||||
|
||||
## Related Commands
|
||||
|
||||
- `/workflow:init` - Creates scaffold; optionally calls this command
|
||||
- `/workflow:session:solidify` - Add individual rules one at a time
|
||||
@@ -10,7 +10,11 @@ examples:
|
||||
# Workflow Init Command (/workflow:init)
|
||||
|
||||
## Overview
|
||||
Initialize `.workflow/project.json` with comprehensive project understanding by delegating analysis to **cli-explore-agent**.
|
||||
Initialize `.workflow/project-tech.json` and `.workflow/project-guidelines.json` with comprehensive project understanding by delegating analysis to **cli-explore-agent**.
|
||||
|
||||
**Dual File System**:
|
||||
- `project-tech.json`: Auto-generated technical analysis (stack, architecture, components)
|
||||
- `project-guidelines.json`: User-maintained rules and constraints (created as scaffold)
|
||||
|
||||
**Note**: This command may be called by other workflow commands. Upon completion, return immediately to continue the calling workflow without interrupting the task flow.
|
||||
|
||||
@@ -27,7 +31,7 @@ Input Parsing:
|
||||
└─ Parse --regenerate flag → regenerate = true | false
|
||||
|
||||
Decision:
|
||||
├─ EXISTS + no --regenerate → Exit: "Already initialized"
|
||||
├─ BOTH_EXIST + no --regenerate → Exit: "Already initialized"
|
||||
├─ EXISTS + --regenerate → Backup existing → Continue analysis
|
||||
└─ NOT_FOUND → Continue analysis
|
||||
|
||||
@@ -37,11 +41,19 @@ Analysis Flow:
|
||||
│ ├─ Structural scan (get_modules_by_depth.sh, find, wc)
|
||||
│ ├─ Semantic analysis (Gemini CLI)
|
||||
│ ├─ Synthesis and merge
|
||||
│ └─ Write .workflow/project.json
|
||||
└─ Display summary
|
||||
│ └─ Write .workflow/project-tech.json
|
||||
├─ Create guidelines scaffold (if not exists)
|
||||
│ └─ Write .workflow/project-guidelines.json (empty structure)
|
||||
├─ Display summary
|
||||
└─ Ask about guidelines configuration
|
||||
├─ If guidelines empty → Ask user: "Configure now?" or "Skip"
|
||||
│ ├─ Configure now → Skill(skill="workflow:init-guidelines")
|
||||
│ └─ Skip → Show next steps
|
||||
└─ If guidelines populated → Show next steps only
|
||||
|
||||
Output:
|
||||
└─ .workflow/project.json (+ .backup if regenerate)
|
||||
├─ .workflow/project-tech.json (+ .backup if regenerate)
|
||||
└─ .workflow/project-guidelines.json (scaffold or configured)
|
||||
```
|
||||
|
||||
## Implementation
|
||||
@@ -56,13 +68,18 @@ const regenerate = $ARGUMENTS.includes('--regenerate')
|
||||
**Check existing state**:
|
||||
|
||||
```bash
|
||||
bash(test -f .workflow/project.json && echo "EXISTS" || echo "NOT_FOUND")
|
||||
bash(test -f .workflow/project-tech.json && echo "TECH_EXISTS" || echo "TECH_NOT_FOUND")
|
||||
bash(test -f .workflow/project-guidelines.json && echo "GUIDELINES_EXISTS" || echo "GUIDELINES_NOT_FOUND")
|
||||
```
|
||||
|
||||
**If EXISTS and no --regenerate**: Exit early
|
||||
**If BOTH_EXIST and no --regenerate**: Exit early
|
||||
```
|
||||
Project already initialized at .workflow/project.json
|
||||
Use /workflow:init --regenerate to rebuild
|
||||
Project already initialized:
|
||||
- Tech analysis: .workflow/project-tech.json
|
||||
- Guidelines: .workflow/project-guidelines.json
|
||||
|
||||
Use /workflow:init --regenerate to rebuild tech analysis
|
||||
Use /workflow:session:solidify to add guidelines
|
||||
Use /workflow:status --project to view state
|
||||
```
|
||||
|
||||
@@ -78,7 +95,7 @@ bash(mkdir -p .workflow)
|
||||
|
||||
**For --regenerate**: Backup and preserve existing data
|
||||
```bash
|
||||
bash(cp .workflow/project.json .workflow/project.json.backup)
|
||||
bash(cp .workflow/project-tech.json .workflow/project-tech.json.backup)
|
||||
```
|
||||
|
||||
**Delegate analysis to agent**:
|
||||
@@ -89,21 +106,31 @@ Task(
|
||||
run_in_background=false,
|
||||
description="Deep project analysis",
|
||||
prompt=`
|
||||
Analyze project for workflow initialization and generate .workflow/project.json.
|
||||
Analyze project for workflow initialization and generate .workflow/project-tech.json.
|
||||
|
||||
## MANDATORY FIRST STEPS
|
||||
1. Execute: cat ~/.claude/workflows/cli-templates/schemas/project-json-schema.json (get schema reference)
|
||||
1. Execute: cat ~/.claude/workflows/cli-templates/schemas/project-tech-schema.json (get schema reference)
|
||||
2. Execute: ccw tool exec get_modules_by_depth '{}' (get project structure)
|
||||
|
||||
## Task
|
||||
Generate complete project.json with:
|
||||
- project_name: ${projectName}
|
||||
- initialized_at: current ISO timestamp
|
||||
- overview: {description, technology_stack, architecture, key_components}
|
||||
- features: ${regenerate ? 'preserve from backup' : '[] (empty)'}
|
||||
Generate complete project-tech.json following the schema structure:
|
||||
- project_name: "${projectName}"
|
||||
- initialized_at: ISO 8601 timestamp
|
||||
- overview: {
|
||||
description: "Brief project description",
|
||||
technology_stack: {
|
||||
languages: [{name, file_count, primary}],
|
||||
frameworks: ["string"],
|
||||
build_tools: ["string"],
|
||||
test_frameworks: ["string"]
|
||||
},
|
||||
architecture: {style, layers: [], patterns: []},
|
||||
key_components: [{name, path, description, importance}]
|
||||
}
|
||||
- features: []
|
||||
- development_index: ${regenerate ? 'preserve from backup' : '{feature: [], enhancement: [], bugfix: [], refactor: [], docs: []}'}
|
||||
- statistics: ${regenerate ? 'preserve from backup' : '{total_features: 0, total_sessions: 0, last_updated}'}
|
||||
- _metadata: {initialized_by: "cli-explore-agent", analysis_timestamp, analysis_mode}
|
||||
- statistics: ${regenerate ? 'preserve from backup' : '{total_features: 0, total_sessions: 0, last_updated: ISO timestamp}'}
|
||||
- _metadata: {initialized_by: "cli-explore-agent", analysis_timestamp: ISO timestamp, analysis_mode: "deep-scan"}
|
||||
|
||||
## Analysis Requirements
|
||||
|
||||
@@ -123,8 +150,8 @@ Generate complete project.json with:
|
||||
1. Structural scan: get_modules_by_depth.sh, find, wc -l
|
||||
2. Semantic analysis: Gemini for patterns/architecture
|
||||
3. Synthesis: Merge findings
|
||||
4. ${regenerate ? 'Merge with preserved features/development_index/statistics from .workflow/project.json.backup' : ''}
|
||||
5. Write JSON: Write('.workflow/project.json', jsonContent)
|
||||
4. ${regenerate ? 'Merge with preserved development_index and statistics from .workflow/project-tech.json.backup' : ''}
|
||||
5. Write JSON: Write('.workflow/project-tech.json', jsonContent)
|
||||
6. Report: Return brief completion summary
|
||||
|
||||
Project root: ${projectRoot}
|
||||
@@ -132,34 +159,130 @@ Project root: ${projectRoot}
|
||||
)
|
||||
```
|
||||
|
||||
### Step 3.5: Create Guidelines Scaffold (if not exists)
|
||||
|
||||
```javascript
|
||||
// Only create if not exists (never overwrite user guidelines)
|
||||
if (!file_exists('.workflow/project-guidelines.json')) {
|
||||
const guidelinesScaffold = {
|
||||
conventions: {
|
||||
coding_style: [],
|
||||
naming_patterns: [],
|
||||
file_structure: [],
|
||||
documentation: []
|
||||
},
|
||||
constraints: {
|
||||
architecture: [],
|
||||
tech_stack: [],
|
||||
performance: [],
|
||||
security: []
|
||||
},
|
||||
quality_rules: [],
|
||||
learnings: [],
|
||||
_metadata: {
|
||||
created_at: new Date().toISOString(),
|
||||
version: "1.0.0"
|
||||
}
|
||||
};
|
||||
|
||||
Write('.workflow/project-guidelines.json', JSON.stringify(guidelinesScaffold, null, 2));
|
||||
}
|
||||
```
|
||||
|
||||
### Step 4: Display Summary
|
||||
|
||||
```javascript
|
||||
const projectJson = JSON.parse(Read('.workflow/project.json'));
|
||||
const projectTech = JSON.parse(Read('.workflow/project-tech.json'));
|
||||
const guidelinesExists = file_exists('.workflow/project-guidelines.json');
|
||||
|
||||
console.log(`
|
||||
✓ Project initialized successfully
|
||||
|
||||
## Project Overview
|
||||
Name: ${projectJson.project_name}
|
||||
Description: ${projectJson.overview.description}
|
||||
Name: ${projectTech.project_name}
|
||||
Description: ${projectTech.overview.description}
|
||||
|
||||
### Technology Stack
|
||||
Languages: ${projectJson.overview.technology_stack.languages.map(l => l.name).join(', ')}
|
||||
Frameworks: ${projectJson.overview.technology_stack.frameworks.join(', ')}
|
||||
Languages: ${projectTech.overview.technology_stack.languages.map(l => l.name).join(', ')}
|
||||
Frameworks: ${projectTech.overview.technology_stack.frameworks.join(', ')}
|
||||
|
||||
### Architecture
|
||||
Style: ${projectJson.overview.architecture.style}
|
||||
Components: ${projectJson.overview.key_components.length} core modules
|
||||
Style: ${projectTech.overview.architecture.style}
|
||||
Components: ${projectTech.overview.key_components.length} core modules
|
||||
|
||||
---
|
||||
Project state: .workflow/project.json
|
||||
${regenerate ? 'Backup: .workflow/project.json.backup' : ''}
|
||||
Files created:
|
||||
- Tech analysis: .workflow/project-tech.json
|
||||
- Guidelines: .workflow/project-guidelines.json ${guidelinesExists ? '(scaffold)' : ''}
|
||||
${regenerate ? '- Backup: .workflow/project-tech.json.backup' : ''}
|
||||
`);
|
||||
```
|
||||
|
||||
### Step 5: Ask About Guidelines Configuration
|
||||
|
||||
After displaying the summary, ask the user if they want to configure project guidelines interactively.
|
||||
|
||||
```javascript
|
||||
// Check if guidelines are just a scaffold (empty) or already populated
|
||||
const guidelines = JSON.parse(Read('.workflow/project-guidelines.json'));
|
||||
const isGuidelinesPopulated =
|
||||
guidelines.conventions.coding_style.length > 0 ||
|
||||
guidelines.conventions.naming_patterns.length > 0 ||
|
||||
guidelines.constraints.architecture.length > 0 ||
|
||||
guidelines.constraints.security.length > 0;
|
||||
|
||||
// Only ask if guidelines are not yet populated
|
||||
if (!isGuidelinesPopulated) {
|
||||
const userChoice = AskUserQuestion({
|
||||
questions: [{
|
||||
question: "Would you like to configure project guidelines now? The wizard will ask targeted questions based on your tech stack.",
|
||||
header: "Guidelines",
|
||||
multiSelect: false,
|
||||
options: [
|
||||
{
|
||||
label: "Configure now (Recommended)",
|
||||
description: "Interactive wizard to set up coding conventions, constraints, and quality rules"
|
||||
},
|
||||
{
|
||||
label: "Skip for now",
|
||||
description: "You can run /workflow:init-guidelines later or use /workflow:session:solidify to add rules individually"
|
||||
}
|
||||
]
|
||||
}]
|
||||
});
|
||||
|
||||
if (userChoice.answers["Guidelines"] === "Configure now (Recommended)") {
|
||||
console.log("\n🔧 Starting guidelines configuration wizard...\n");
|
||||
Skill(skill="workflow:init-guidelines");
|
||||
} else {
|
||||
console.log(`
|
||||
Next steps:
|
||||
- Use /workflow:init-guidelines to configure guidelines interactively
|
||||
- Use /workflow:session:solidify to add individual rules
|
||||
- Use /workflow:plan to start planning
|
||||
`);
|
||||
}
|
||||
} else {
|
||||
console.log(`
|
||||
Guidelines already configured (${guidelines.conventions.coding_style.length + guidelines.constraints.architecture.length}+ rules).
|
||||
|
||||
Next steps:
|
||||
- Use /workflow:init-guidelines --reset to reconfigure
|
||||
- Use /workflow:session:solidify to add individual rules
|
||||
- Use /workflow:plan to start planning
|
||||
`);
|
||||
}
|
||||
```
|
||||
|
||||
## Error Handling
|
||||
|
||||
**Agent Failure**: Fall back to basic initialization with placeholder overview
|
||||
**Missing Tools**: Agent uses Qwen fallback or bash-only
|
||||
**Empty Project**: Create minimal JSON with all gaps identified
|
||||
|
||||
## Related Commands
|
||||
|
||||
- `/workflow:init-guidelines` - Interactive wizard to configure project guidelines (called after init)
|
||||
- `/workflow:session:solidify` - Add individual rules/constraints one at a time
|
||||
- `/workflow:plan` - Start planning with initialized project context
|
||||
- `/workflow:status --project` - View project state and guidelines
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
---
|
||||
name: lite-execute
|
||||
description: Execute tasks based on in-memory plan, prompt description, or file content
|
||||
argument-hint: "[--in-memory] [\"task description\"|file-path]"
|
||||
argument-hint: "[-y|--yes] [--in-memory] [\"task description\"|file-path]"
|
||||
allowed-tools: TodoWrite(*), Task(*), Bash(*)
|
||||
---
|
||||
|
||||
@@ -62,30 +62,49 @@ Flexible task execution command supporting three input modes: in-memory plan (fr
|
||||
|
||||
**User Interaction**:
|
||||
```javascript
|
||||
AskUserQuestion({
|
||||
questions: [
|
||||
{
|
||||
question: "Select execution method:",
|
||||
header: "Execution",
|
||||
multiSelect: false,
|
||||
options: [
|
||||
{ label: "Agent", description: "@code-developer agent" },
|
||||
{ label: "Codex", description: "codex CLI tool" },
|
||||
{ label: "Auto", description: "Auto-select based on complexity" }
|
||||
]
|
||||
},
|
||||
{
|
||||
question: "Enable code review after execution?",
|
||||
header: "Code Review",
|
||||
multiSelect: false,
|
||||
options: [
|
||||
{ label: "Skip", description: "No review" },
|
||||
{ label: "Gemini Review", description: "Gemini CLI tool" },
|
||||
{ label: "Agent Review", description: "Current agent review" }
|
||||
]
|
||||
}
|
||||
]
|
||||
})
|
||||
// Parse --yes flag
|
||||
const autoYes = $ARGUMENTS.includes('--yes') || $ARGUMENTS.includes('-y')
|
||||
|
||||
let userSelection
|
||||
|
||||
if (autoYes) {
|
||||
// Auto mode: Use defaults
|
||||
console.log(`[--yes] Auto-confirming execution:`)
|
||||
console.log(` - Execution method: Auto`)
|
||||
console.log(` - Code review: Skip`)
|
||||
|
||||
userSelection = {
|
||||
execution_method: "Auto",
|
||||
code_review_tool: "Skip"
|
||||
}
|
||||
} else {
|
||||
// Interactive mode: Ask user
|
||||
userSelection = AskUserQuestion({
|
||||
questions: [
|
||||
{
|
||||
question: "Select execution method:",
|
||||
header: "Execution",
|
||||
multiSelect: false,
|
||||
options: [
|
||||
{ label: "Agent", description: "@code-developer agent" },
|
||||
{ label: "Codex", description: "codex CLI tool" },
|
||||
{ label: "Auto", description: "Auto-select based on complexity" }
|
||||
]
|
||||
},
|
||||
{
|
||||
question: "Enable code review after execution?",
|
||||
header: "Code Review",
|
||||
multiSelect: false,
|
||||
options: [
|
||||
{ label: "Skip", description: "No review" },
|
||||
{ label: "Gemini Review", description: "Gemini CLI tool" },
|
||||
{ label: "Codex Review", description: "Git-aware review (prompt OR --uncommitted)" },
|
||||
{ label: "Agent Review", description: "Current agent review" }
|
||||
]
|
||||
}
|
||||
]
|
||||
})
|
||||
}
|
||||
```
|
||||
|
||||
### Mode 3: File Content
|
||||
@@ -171,10 +190,23 @@ Output:
|
||||
**Operations**:
|
||||
- Initialize result tracking for multi-execution scenarios
|
||||
- Set up `previousExecutionResults` array for context continuity
|
||||
- **In-Memory Mode**: Echo execution strategy from lite-plan for transparency
|
||||
|
||||
```javascript
|
||||
// Initialize result tracking
|
||||
previousExecutionResults = []
|
||||
|
||||
// In-Memory Mode: Echo execution strategy (transparency before execution)
|
||||
if (executionContext) {
|
||||
console.log(`
|
||||
📋 Execution Strategy (from lite-plan):
|
||||
Method: ${executionContext.executionMethod}
|
||||
Review: ${executionContext.codeReviewTool}
|
||||
Tasks: ${executionContext.planObject.tasks.length}
|
||||
Complexity: ${executionContext.planObject.complexity}
|
||||
${executionContext.executorAssignments ? ` Assignments: ${JSON.stringify(executionContext.executorAssignments)}` : ''}
|
||||
`)
|
||||
}
|
||||
```
|
||||
|
||||
### Step 2: Task Grouping & Batch Creation
|
||||
@@ -307,6 +339,85 @@ for (const call of sequential) {
|
||||
}
|
||||
```
|
||||
|
||||
### Unified Task Prompt Builder
|
||||
|
||||
**Task Formatting Principle**: Each task is a self-contained checklist. The executor only needs to know what THIS task requires. Same template for Agent and CLI.
|
||||
|
||||
```javascript
|
||||
function buildExecutionPrompt(batch) {
|
||||
// Task template (6 parts: Modification Points → Why → How → Reference → Risks → Done)
|
||||
const formatTask = (t) => `
|
||||
## ${t.title}
|
||||
|
||||
**Scope**: \`${t.scope}\` | **Action**: ${t.action}
|
||||
|
||||
### Modification Points
|
||||
${t.modification_points.map(p => `- **${p.file}** → \`${p.target}\`: ${p.change}`).join('\n')}
|
||||
|
||||
${t.rationale ? `
|
||||
### Why this approach (Medium/High)
|
||||
${t.rationale.chosen_approach}
|
||||
${t.rationale.decision_factors?.length > 0 ? `\nKey factors: ${t.rationale.decision_factors.join(', ')}` : ''}
|
||||
${t.rationale.tradeoffs ? `\nTradeoffs: ${t.rationale.tradeoffs}` : ''}
|
||||
` : ''}
|
||||
|
||||
### How to do it
|
||||
${t.description}
|
||||
|
||||
${t.implementation.map(step => `- ${step}`).join('\n')}
|
||||
|
||||
${t.code_skeleton ? `
|
||||
### Code skeleton (High)
|
||||
${t.code_skeleton.interfaces?.length > 0 ? `**Interfaces**: ${t.code_skeleton.interfaces.map(i => `\`${i.name}\` - ${i.purpose}`).join(', ')}` : ''}
|
||||
${t.code_skeleton.key_functions?.length > 0 ? `\n**Functions**: ${t.code_skeleton.key_functions.map(f => `\`${f.signature}\` - ${f.purpose}`).join(', ')}` : ''}
|
||||
${t.code_skeleton.classes?.length > 0 ? `\n**Classes**: ${t.code_skeleton.classes.map(c => `\`${c.name}\` - ${c.purpose}`).join(', ')}` : ''}
|
||||
` : ''}
|
||||
|
||||
### Reference
|
||||
- Pattern: ${t.reference?.pattern || 'N/A'}
|
||||
- Files: ${t.reference?.files?.join(', ') || 'N/A'}
|
||||
${t.reference?.examples ? `- Notes: ${t.reference.examples}` : ''}
|
||||
|
||||
${t.risks?.length > 0 ? `
|
||||
### Risk mitigations (High)
|
||||
${t.risks.map(r => `- ${r.description} → **${r.mitigation}**`).join('\n')}
|
||||
` : ''}
|
||||
|
||||
### Done when
|
||||
${t.acceptance.map(c => `- [ ] ${c}`).join('\n')}
|
||||
${t.verification?.success_metrics?.length > 0 ? `\n**Success metrics**: ${t.verification.success_metrics.join(', ')}` : ''}`
|
||||
|
||||
// Build prompt
|
||||
const sections = []
|
||||
|
||||
if (originalUserInput) sections.push(`## Goal\n${originalUserInput}`)
|
||||
|
||||
sections.push(`## Tasks\n${batch.tasks.map(formatTask).join('\n\n---\n')}`)
|
||||
|
||||
// Context (reference only)
|
||||
const context = []
|
||||
if (previousExecutionResults.length > 0) {
|
||||
context.push(`### Previous Work\n${previousExecutionResults.map(r => `- ${r.tasksSummary}: ${r.status}`).join('\n')}`)
|
||||
}
|
||||
if (clarificationContext) {
|
||||
context.push(`### Clarifications\n${Object.entries(clarificationContext).map(([q, a]) => `- ${q}: ${a}`).join('\n')}`)
|
||||
}
|
||||
if (executionContext?.planObject?.data_flow?.diagram) {
|
||||
context.push(`### Data Flow\n${executionContext.planObject.data_flow.diagram}`)
|
||||
}
|
||||
if (executionContext?.session?.artifacts?.plan) {
|
||||
context.push(`### Artifacts\nPlan: ${executionContext.session.artifacts.plan}`)
|
||||
}
|
||||
// Project guidelines (user-defined constraints from /workflow:session:solidify)
|
||||
context.push(`### Project Guidelines\n@.workflow/project-guidelines.json`)
|
||||
if (context.length > 0) sections.push(`## Context\n${context.join('\n\n')}`)
|
||||
|
||||
sections.push(`Complete each task according to its "Done when" checklist.`)
|
||||
|
||||
return sections.join('\n\n')
|
||||
}
|
||||
```
|
||||
|
||||
**Option A: Agent Execution**
|
||||
|
||||
When to use:
|
||||
@@ -314,113 +425,13 @@ When to use:
|
||||
- 或 `executionMethod = "Agent"` (全局 fallback)
|
||||
- 或 `executionMethod = "Auto" AND complexity = "Low"` (全局 fallback)
|
||||
|
||||
**Task Formatting Principle**: Each task is a self-contained checklist. The agent only needs to know what THIS task requires, not its position or relation to other tasks.
|
||||
|
||||
Agent call format:
|
||||
```javascript
|
||||
// Format single task as self-contained checklist
|
||||
function formatTaskChecklist(task) {
|
||||
return `
|
||||
## ${task.title}
|
||||
|
||||
**Target**: \`${task.file}\`
|
||||
**Action**: ${task.action}
|
||||
|
||||
### What to do
|
||||
${task.description}
|
||||
|
||||
### How to do it
|
||||
${task.implementation.map(step => `- ${step}`).join('\n')}
|
||||
|
||||
### Reference
|
||||
- Pattern: ${task.reference.pattern}
|
||||
- Examples: ${task.reference.files.join(', ')}
|
||||
- Notes: ${task.reference.examples}
|
||||
|
||||
### Done when
|
||||
${task.acceptance.map(c => `- [ ] ${c}`).join('\n')}
|
||||
`
|
||||
}
|
||||
|
||||
// For batch execution: aggregate tasks without numbering
|
||||
function formatBatchPrompt(batch) {
|
||||
const tasksSection = batch.tasks.map(t => formatTaskChecklist(t)).join('\n---\n')
|
||||
|
||||
return `
|
||||
${originalUserInput ? `## Goal\n${originalUserInput}\n` : ''}
|
||||
|
||||
## Tasks
|
||||
|
||||
${tasksSection}
|
||||
|
||||
${batch.context ? `## Context\n${batch.context}` : ''}
|
||||
|
||||
Complete each task according to its "Done when" checklist.
|
||||
`
|
||||
}
|
||||
|
||||
Task(
|
||||
subagent_type="code-developer",
|
||||
run_in_background=false,
|
||||
description=batch.taskSummary,
|
||||
prompt=formatBatchPrompt({
|
||||
tasks: batch.tasks,
|
||||
context: buildRelevantContext(batch.tasks)
|
||||
})
|
||||
prompt=buildExecutionPrompt(batch)
|
||||
)
|
||||
|
||||
// Helper: Build relevant context for batch
|
||||
// Context serves as REFERENCE ONLY - helps agent understand existing state
|
||||
function buildRelevantContext(tasks) {
|
||||
const sections = []
|
||||
|
||||
// 1. Previous work completion - what's already done (reference for continuity)
|
||||
if (previousExecutionResults.length > 0) {
|
||||
sections.push(`### Previous Work (Reference)
|
||||
Use this to understand what's already completed. Avoid duplicating work.
|
||||
|
||||
${previousExecutionResults.map(r => `**${r.tasksSummary}**
|
||||
- Status: ${r.status}
|
||||
- Outputs: ${r.keyOutputs || 'See git diff'}
|
||||
${r.notes ? `- Notes: ${r.notes}` : ''}`
|
||||
).join('\n\n')}`)
|
||||
}
|
||||
|
||||
// 2. Related files - files that may need to be read/referenced
|
||||
const relatedFiles = extractRelatedFiles(tasks)
|
||||
if (relatedFiles.length > 0) {
|
||||
sections.push(`### Related Files (Reference)
|
||||
These files may contain patterns, types, or utilities relevant to your tasks:
|
||||
|
||||
${relatedFiles.map(f => `- \`${f}\``).join('\n')}`)
|
||||
}
|
||||
|
||||
// 3. Clarifications from user
|
||||
if (clarificationContext) {
|
||||
sections.push(`### User Clarifications
|
||||
${Object.entries(clarificationContext).map(([q, a]) => `- **${q}**: ${a}`).join('\n')}`)
|
||||
}
|
||||
|
||||
// 4. Artifact files (for deeper context if needed)
|
||||
if (executionContext?.session?.artifacts?.plan) {
|
||||
sections.push(`### Artifacts
|
||||
For detailed planning context, read: ${executionContext.session.artifacts.plan}`)
|
||||
}
|
||||
|
||||
return sections.join('\n\n')
|
||||
}
|
||||
|
||||
// Extract related files from task references
|
||||
function extractRelatedFiles(tasks) {
|
||||
const files = new Set()
|
||||
tasks.forEach(task => {
|
||||
// Add reference example files
|
||||
if (task.reference?.files) {
|
||||
task.reference.files.forEach(f => files.add(f))
|
||||
}
|
||||
})
|
||||
return [...files]
|
||||
}
|
||||
```
|
||||
|
||||
**Result Collection**: After completion, collect result following `executionResult` structure (see Data Structures section)
|
||||
@@ -432,92 +443,14 @@ When to use:
|
||||
- 或 `executionMethod = "Codex"` (全局 fallback)
|
||||
- 或 `executionMethod = "Auto" AND complexity = "Medium/High"` (全局 fallback)
|
||||
|
||||
**Task Formatting Principle**: Same as Agent - each task is a self-contained checklist. No task numbering or position awareness.
|
||||
|
||||
Command format:
|
||||
```bash
|
||||
// Format single task as compact checklist for CLI
|
||||
function formatTaskForCLI(task) {
|
||||
return `
|
||||
## ${task.title}
|
||||
File: ${task.file}
|
||||
Action: ${task.action}
|
||||
|
||||
What: ${task.description}
|
||||
|
||||
How:
|
||||
${task.implementation.map(step => `- ${step}`).join('\n')}
|
||||
|
||||
Reference: ${task.reference.pattern} (see ${task.reference.files.join(', ')})
|
||||
Notes: ${task.reference.examples}
|
||||
|
||||
Done when:
|
||||
${task.acceptance.map(c => `- [ ] ${c}`).join('\n')}
|
||||
`
|
||||
}
|
||||
|
||||
// Build CLI prompt for batch
|
||||
// Context provides REFERENCE information - not requirements to fulfill
|
||||
function buildCLIPrompt(batch) {
|
||||
const tasksSection = batch.tasks.map(t => formatTaskForCLI(t)).join('\n---\n')
|
||||
|
||||
let prompt = `${originalUserInput ? `## Goal\n${originalUserInput}\n\n` : ''}`
|
||||
prompt += `## Tasks\n\n${tasksSection}\n`
|
||||
|
||||
// Context section - reference information only
|
||||
const contextSections = []
|
||||
|
||||
// 1. Previous work - what's already completed
|
||||
if (previousExecutionResults.length > 0) {
|
||||
contextSections.push(`### Previous Work (Reference)
|
||||
Already completed - avoid duplicating:
|
||||
${previousExecutionResults.map(r => `- ${r.tasksSummary}: ${r.status}${r.keyOutputs ? ` (${r.keyOutputs})` : ''}`).join('\n')}`)
|
||||
}
|
||||
|
||||
// 2. Related files from task references
|
||||
const relatedFiles = [...new Set(batch.tasks.flatMap(t => t.reference?.files || []))]
|
||||
if (relatedFiles.length > 0) {
|
||||
contextSections.push(`### Related Files (Reference)
|
||||
Patterns and examples to follow:
|
||||
${relatedFiles.map(f => `- ${f}`).join('\n')}`)
|
||||
}
|
||||
|
||||
// 3. User clarifications
|
||||
if (clarificationContext) {
|
||||
contextSections.push(`### Clarifications
|
||||
${Object.entries(clarificationContext).map(([q, a]) => `- ${q}: ${a}`).join('\n')}`)
|
||||
}
|
||||
|
||||
// 4. Plan artifact for deeper context
|
||||
if (executionContext?.session?.artifacts?.plan) {
|
||||
contextSections.push(`### Artifacts
|
||||
Detailed plan: ${executionContext.session.artifacts.plan}`)
|
||||
}
|
||||
|
||||
if (contextSections.length > 0) {
|
||||
prompt += `\n## Context\n${contextSections.join('\n\n')}\n`
|
||||
}
|
||||
|
||||
prompt += `\nComplete each task according to its "Done when" checklist.`
|
||||
|
||||
return prompt
|
||||
}
|
||||
|
||||
ccw cli -p "${buildCLIPrompt(batch)}" --tool codex --mode write
|
||||
ccw cli -p "${buildExecutionPrompt(batch)}" --tool codex --mode write
|
||||
```
|
||||
|
||||
**Execution with fixed IDs** (predictable ID pattern):
|
||||
```javascript
|
||||
// Launch CLI in foreground (NOT background)
|
||||
// Timeout based on complexity: Low=40min, Medium=60min, High=100min
|
||||
const timeoutByComplexity = {
|
||||
"Low": 2400000, // 40 minutes
|
||||
"Medium": 3600000, // 60 minutes
|
||||
"High": 6000000 // 100 minutes
|
||||
}
|
||||
|
||||
// Launch CLI in background, wait for task hook callback
|
||||
// Generate fixed execution ID: ${sessionId}-${groupId}
|
||||
// This enables predictable ID lookup without relying on resume context chains
|
||||
const sessionId = executionContext?.session?.id || 'standalone'
|
||||
const fixedExecutionId = `${sessionId}-${batch.groupId}` // e.g., "implement-auth-2025-12-13-P1"
|
||||
|
||||
@@ -526,19 +459,15 @@ const previousCliId = batch.resumeFromCliId || null
|
||||
|
||||
// Build command with fixed ID (and optional resume for continuation)
|
||||
const cli_command = previousCliId
|
||||
? `ccw cli -p "${buildCLIPrompt(batch)}" --tool codex --mode write --id ${fixedExecutionId} --resume ${previousCliId}`
|
||||
: `ccw cli -p "${buildCLIPrompt(batch)}" --tool codex --mode write --id ${fixedExecutionId}`
|
||||
? `ccw cli -p "${buildExecutionPrompt(batch)}" --tool codex --mode write --id ${fixedExecutionId} --resume ${previousCliId}`
|
||||
: `ccw cli -p "${buildExecutionPrompt(batch)}" --tool codex --mode write --id ${fixedExecutionId}`
|
||||
|
||||
bash_result = Bash(
|
||||
// Execute in background, stop output and wait for task hook callback
|
||||
Bash(
|
||||
command=cli_command,
|
||||
timeout=timeoutByComplexity[planObject.complexity] || 3600000
|
||||
run_in_background=true
|
||||
)
|
||||
|
||||
// Execution ID is now predictable: ${fixedExecutionId}
|
||||
// Can also extract from output: "ID: implement-auth-2025-12-13-P1"
|
||||
const cliExecutionId = fixedExecutionId
|
||||
|
||||
// Update TodoWrite when execution completes
|
||||
// STOP HERE - CLI executes in background, task hook will notify on completion
|
||||
```
|
||||
|
||||
**Resume on Failure** (with fixed ID):
|
||||
@@ -564,8 +493,8 @@ if (bash_result.status === 'failed' || bash_result.status === 'timeout') {
|
||||
When to use: `getTaskExecutor(task) === "gemini"` (分析类任务)
|
||||
|
||||
```bash
|
||||
# 使用与 Option B 相同的 formatBatchPrompt,切换 tool 和 mode
|
||||
ccw cli -p "${formatBatchPrompt(batch)}" --tool gemini --mode analysis --id ${sessionId}-${batch.groupId}
|
||||
# 使用统一的 buildExecutionPrompt,切换 tool 和 mode
|
||||
ccw cli -p "${buildExecutionPrompt(batch)}" --tool gemini --mode analysis --id ${sessionId}-${batch.groupId}
|
||||
```
|
||||
|
||||
### Step 4: Progress Tracking
|
||||
@@ -576,32 +505,41 @@ Progress tracked at batch level (not individual task level). Icons: ⚡ (paralle
|
||||
|
||||
**Skip Condition**: Only run if `codeReviewTool ≠ "Skip"`
|
||||
|
||||
**Review Focus**: Verify implementation against plan acceptance criteria
|
||||
- Read plan.json for task acceptance criteria
|
||||
**Review Focus**: Verify implementation against plan acceptance criteria and verification requirements
|
||||
- Read plan.json for task acceptance criteria and verification checklist
|
||||
- Check each acceptance criterion is fulfilled
|
||||
- Verify success metrics from verification field (Medium/High complexity)
|
||||
- Run unit/integration tests specified in verification field
|
||||
- Validate code quality and identify issues
|
||||
- Ensure alignment with planned approach
|
||||
- Ensure alignment with planned approach and risk mitigations
|
||||
|
||||
**Operations**:
|
||||
- Agent Review: Current agent performs direct review
|
||||
- Gemini Review: Execute gemini CLI with review prompt
|
||||
- Custom tool: Execute specified CLI tool (qwen, codex, etc.)
|
||||
- Codex Review: Two options - (A) with prompt for complex reviews, (B) `--uncommitted` flag only for quick reviews
|
||||
- Custom tool: Execute specified CLI tool (qwen, etc.)
|
||||
|
||||
**Unified Review Template** (All tools use same standard):
|
||||
|
||||
**Review Criteria**:
|
||||
- **Acceptance Criteria**: Verify each criterion from plan.tasks[].acceptance
|
||||
- **Verification Checklist** (Medium/High): Check unit_tests, integration_tests, success_metrics from plan.tasks[].verification
|
||||
- **Code Quality**: Analyze quality, identify issues, suggest improvements
|
||||
- **Plan Alignment**: Validate implementation matches planned approach
|
||||
- **Plan Alignment**: Validate implementation matches planned approach and risk mitigations
|
||||
|
||||
**Shared Prompt Template** (used by all CLI tools):
|
||||
```
|
||||
PURPOSE: Code review for implemented changes against plan acceptance criteria
|
||||
TASK: • Verify plan acceptance criteria fulfillment • Analyze code quality • Identify issues • Suggest improvements • Validate plan adherence
|
||||
PURPOSE: Code review for implemented changes against plan acceptance criteria and verification requirements
|
||||
TASK: • Verify plan acceptance criteria fulfillment • Check verification requirements (unit tests, success metrics) • Analyze code quality • Identify issues • Suggest improvements • Validate plan adherence and risk mitigations
|
||||
MODE: analysis
|
||||
CONTEXT: @**/* @{plan.json} [@{exploration.json}] | Memory: Review lite-execute changes against plan requirements
|
||||
EXPECTED: Quality assessment with acceptance criteria verification, issue identification, and recommendations. Explicitly check each acceptance criterion from plan.json tasks.
|
||||
RULES: $(cat ~/.claude/workflows/cli-templates/prompts/analysis/02-review-code-quality.txt) | Focus on plan acceptance criteria and plan adherence | analysis=READ-ONLY
|
||||
CONTEXT: @**/* @{plan.json} [@{exploration.json}] | Memory: Review lite-execute changes against plan requirements including verification checklist
|
||||
EXPECTED: Quality assessment with:
|
||||
- Acceptance criteria verification (all tasks)
|
||||
- Verification checklist validation (Medium/High: unit_tests, integration_tests, success_metrics)
|
||||
- Issue identification
|
||||
- Recommendations
|
||||
Explicitly check each acceptance criterion and verification item from plan.json tasks.
|
||||
CONSTRAINTS: Focus on plan acceptance criteria, verification requirements, and plan adherence | analysis=READ-ONLY
|
||||
```
|
||||
|
||||
**Tool-Specific Execution** (Apply shared prompt template above):
|
||||
@@ -620,8 +558,17 @@ ccw cli -p "[Shared Prompt Template with artifacts]" --tool gemini --mode analys
|
||||
ccw cli -p "[Shared Prompt Template with artifacts]" --tool qwen --mode analysis
|
||||
# Same prompt as Gemini, different execution engine
|
||||
|
||||
# Method 4: Codex Review (autonomous)
|
||||
ccw cli -p "[Verify plan acceptance criteria at ${plan.json}]" --tool codex --mode write
|
||||
# Method 4: Codex Review (git-aware) - Two mutually exclusive options:
|
||||
|
||||
# Option A: With custom prompt (reviews uncommitted by default)
|
||||
ccw cli -p "[Shared Prompt Template with artifacts]" --tool codex --mode review
|
||||
# Use for complex reviews with specific focus areas
|
||||
|
||||
# Option B: Target flag only (no prompt allowed)
|
||||
ccw cli --tool codex --mode review --uncommitted
|
||||
# Quick review of uncommitted changes without custom instructions
|
||||
|
||||
# ⚠️ IMPORTANT: -p prompt and target flags (--uncommitted/--base/--commit) are MUTUALLY EXCLUSIVE
|
||||
```
|
||||
|
||||
**Multi-Round Review with Fixed IDs**:
|
||||
@@ -647,11 +594,11 @@ if (hasUnresolvedIssues(reviewResult)) {
|
||||
|
||||
**Trigger**: After all executions complete (regardless of code review)
|
||||
|
||||
**Skip Condition**: Skip if `.workflow/project.json` does not exist
|
||||
**Skip Condition**: Skip if `.workflow/project-tech.json` does not exist
|
||||
|
||||
**Operations**:
|
||||
```javascript
|
||||
const projectJsonPath = '.workflow/project.json'
|
||||
const projectJsonPath = '.workflow/project-tech.json'
|
||||
if (!fileExists(projectJsonPath)) return // Silent skip
|
||||
|
||||
const projectJson = JSON.parse(Read(projectJsonPath))
|
||||
@@ -780,6 +727,10 @@ Collected after each execution call completes:
|
||||
|
||||
Appended to `previousExecutionResults` array for context continuity in multi-execution scenarios.
|
||||
|
||||
## Post-Completion Expansion
|
||||
|
||||
完成后询问用户是否扩展为issue(test/enhance/refactor/doc),选中项调用 `/issue:new "{summary} - {dimension}"`
|
||||
|
||||
**Fixed ID Pattern**: `${sessionId}-${groupId}` enables predictable lookup without auto-generated timestamps.
|
||||
|
||||
**Resume Usage**: If `status` is "partial" or "failed", use `fixedCliId` to resume:
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
---
|
||||
name: lite-fix
|
||||
description: Lightweight bug diagnosis and fix workflow with intelligent severity assessment and optional hotfix mode for production incidents
|
||||
argument-hint: "[--hotfix] \"bug description or issue reference\""
|
||||
allowed-tools: TodoWrite(*), Task(*), SlashCommand(*), AskUserQuestion(*)
|
||||
argument-hint: "[-y|--yes] [--hotfix] \"bug description or issue reference\""
|
||||
allowed-tools: TodoWrite(*), Task(*), Skill(*), AskUserQuestion(*)
|
||||
---
|
||||
|
||||
# Workflow Lite-Fix Command (/workflow:lite-fix)
|
||||
@@ -17,7 +17,7 @@ Intelligent lightweight bug fixing command with dynamic workflow adaptation base
|
||||
- Interactive clarification after diagnosis to gather missing information
|
||||
- Adaptive fix planning strategy (direct Claude vs cli-lite-planning-agent) based on complexity
|
||||
- Two-step confirmation: fix-plan display -> multi-dimensional input collection
|
||||
- Execution dispatch with complete context handoff to lite-execute
|
||||
- Execution execute with complete context handoff to lite-execute
|
||||
|
||||
## Usage
|
||||
|
||||
@@ -25,10 +25,49 @@ Intelligent lightweight bug fixing command with dynamic workflow adaptation base
|
||||
/workflow:lite-fix [FLAGS] <BUG_DESCRIPTION>
|
||||
|
||||
# Flags
|
||||
-y, --yes Skip all confirmations (auto mode)
|
||||
--hotfix, -h Production hotfix mode (minimal diagnosis, fast fix)
|
||||
|
||||
# Arguments
|
||||
<bug-description> Bug description, error message, or path to .md file (required)
|
||||
|
||||
# Examples
|
||||
/workflow:lite-fix "用户登录失败" # Interactive mode
|
||||
/workflow:lite-fix --yes "用户登录失败" # Auto mode (no confirmations)
|
||||
/workflow:lite-fix -y --hotfix "生产环境数据库连接失败" # Auto + hotfix mode
|
||||
```
|
||||
|
||||
## Output Artifacts
|
||||
|
||||
| Artifact | Description |
|
||||
|----------|-------------|
|
||||
| `diagnosis-{angle}.json` | Per-angle diagnosis results (1-4 files based on severity) |
|
||||
| `diagnoses-manifest.json` | Index of all diagnosis files |
|
||||
| `planning-context.md` | Evidence paths + synthesized understanding |
|
||||
| `fix-plan.json` | Structured fix plan (fix-plan-json-schema.json) |
|
||||
|
||||
**Output Directory**: `.workflow/.lite-fix/{bug-slug}-{YYYY-MM-DD}/`
|
||||
|
||||
**Agent Usage**:
|
||||
- Low/Medium severity → Direct Claude planning (no agent)
|
||||
- High/Critical severity → `cli-lite-planning-agent` generates `fix-plan.json`
|
||||
|
||||
**Schema Reference**: `~/.claude/workflows/cli-templates/schemas/fix-plan-json-schema.json`
|
||||
|
||||
## Auto Mode Defaults
|
||||
|
||||
When `--yes` or `-y` flag is used:
|
||||
- **Clarification Questions**: Skipped (no clarification phase)
|
||||
- **Fix Plan Confirmation**: Auto-selected "Allow"
|
||||
- **Execution Method**: Auto-selected "Auto"
|
||||
- **Code Review**: Auto-selected "Skip"
|
||||
- **Severity**: Uses auto-detected severity (no manual override)
|
||||
- **Hotfix Mode**: Respects --hotfix flag if present, otherwise normal mode
|
||||
|
||||
**Flag Parsing**:
|
||||
```javascript
|
||||
const autoYes = $ARGUMENTS.includes('--yes') || $ARGUMENTS.includes('-y')
|
||||
const hotfixMode = $ARGUMENTS.includes('--hotfix') || $ARGUMENTS.includes('-h')
|
||||
```
|
||||
|
||||
## Execution Process
|
||||
@@ -62,9 +101,9 @@ Phase 4: Confirmation & Selection
|
||||
|- Execution: Agent / Codex / Auto
|
||||
+- Review: Gemini / Agent / Skip
|
||||
|
||||
Phase 5: Dispatch
|
||||
Phase 5: Execute
|
||||
|- Build executionContext (fix-plan + diagnoses + clarifications + selections)
|
||||
+- SlashCommand("/workflow:lite-execute --in-memory --mode bugfix")
|
||||
+- Skill(skill="workflow:lite-execute", args="--in-memory --mode bugfix")
|
||||
```
|
||||
|
||||
## Implementation
|
||||
@@ -170,17 +209,23 @@ const diagnosisTasks = selectedAngles.map((angle, index) =>
|
||||
## Task Objective
|
||||
Execute **${angle}** diagnosis for bug root cause analysis. Analyze codebase from this specific angle to discover root cause, affected paths, and fix hints.
|
||||
|
||||
## Output Location
|
||||
|
||||
**Session Folder**: ${sessionFolder}
|
||||
**Output File**: ${sessionFolder}/diagnosis-${angle}.json
|
||||
|
||||
## Assigned Context
|
||||
- **Diagnosis Angle**: ${angle}
|
||||
- **Bug Description**: ${bug_description}
|
||||
- **Diagnosis Index**: ${index + 1} of ${selectedAngles.length}
|
||||
- **Output File**: ${sessionFolder}/diagnosis-${angle}.json
|
||||
|
||||
## MANDATORY FIRST STEPS (Execute by Agent)
|
||||
**You (cli-explore-agent) MUST execute these steps in order:**
|
||||
1. Run: ccw tool exec get_modules_by_depth '{}' (project structure)
|
||||
2. Run: rg -l "{error_keyword_from_bug}" --type ts (locate relevant files)
|
||||
3. Execute: cat ~/.claude/workflows/cli-templates/schemas/diagnosis-json-schema.json (get output schema reference)
|
||||
4. Read: .workflow/project-tech.json (technology stack and architecture context)
|
||||
5. Read: .workflow/project-guidelines.json (user-defined constraints and conventions)
|
||||
|
||||
## Diagnosis Strategy (${angle} focus)
|
||||
|
||||
@@ -201,8 +246,6 @@ Execute **${angle}** diagnosis for bug root cause analysis. Analyze codebase fro
|
||||
|
||||
## Expected Output
|
||||
|
||||
**File**: ${sessionFolder}/diagnosis-${angle}.json
|
||||
|
||||
**Schema Reference**: Schema obtained in MANDATORY FIRST STEPS step 3, follow schema exactly
|
||||
|
||||
**Required Fields** (all ${angle} focused):
|
||||
@@ -231,9 +274,9 @@ Execute **${angle}** diagnosis for bug root cause analysis. Analyze codebase fro
|
||||
- [ ] JSON output follows schema exactly
|
||||
- [ ] clarification_needs includes options + recommended
|
||||
|
||||
## Output
|
||||
Write: ${sessionFolder}/diagnosis-${angle}.json
|
||||
Return: 2-3 sentence summary of ${angle} diagnosis findings
|
||||
## Execution
|
||||
**Write**: \`${sessionFolder}/diagnosis-${angle}.json\`
|
||||
**Return**: 2-3 sentence summary of ${angle} diagnosis findings
|
||||
`
|
||||
)
|
||||
)
|
||||
@@ -330,9 +373,17 @@ function deduplicateClarifications(clarifications) {
|
||||
|
||||
const uniqueClarifications = deduplicateClarifications(allClarifications)
|
||||
|
||||
// Multi-round clarification: batch questions (max 4 per round)
|
||||
// ⚠️ MUST execute ALL rounds until uniqueClarifications exhausted
|
||||
if (uniqueClarifications.length > 0) {
|
||||
// Parse --yes flag
|
||||
const autoYes = $ARGUMENTS.includes('--yes') || $ARGUMENTS.includes('-y')
|
||||
|
||||
if (autoYes) {
|
||||
// Auto mode: Skip clarification phase
|
||||
console.log(`[--yes] Skipping ${uniqueClarifications.length} clarification questions`)
|
||||
console.log(`Proceeding to fix planning with diagnosis results...`)
|
||||
// Continue to Phase 3
|
||||
} else if (uniqueClarifications.length > 0) {
|
||||
// Interactive mode: Multi-round clarification
|
||||
// ⚠️ MUST execute ALL rounds until uniqueClarifications exhausted
|
||||
const BATCH_SIZE = 4
|
||||
const totalRounds = Math.ceil(uniqueClarifications.length / BATCH_SIZE)
|
||||
|
||||
@@ -378,6 +429,7 @@ if (uniqueClarifications.length > 0) {
|
||||
const schema = Bash(`cat ~/.claude/workflows/cli-templates/schemas/fix-plan-json-schema.json`)
|
||||
|
||||
// Step 2: Generate fix-plan following schema (Claude directly, no agent)
|
||||
// For Medium complexity: include rationale + verification (optional, but recommended)
|
||||
const fixPlan = {
|
||||
summary: "...",
|
||||
root_cause: "...",
|
||||
@@ -387,13 +439,67 @@ const fixPlan = {
|
||||
recommended_execution: "Agent",
|
||||
severity: severity,
|
||||
risk_level: "...",
|
||||
_metadata: { timestamp: getUtc8ISOString(), source: "direct-planning", planning_mode: "direct" }
|
||||
|
||||
// Medium complexity fields (optional for direct planning, auto-filled for Low)
|
||||
...(severity === "Medium" ? {
|
||||
design_decisions: [
|
||||
{
|
||||
decision: "Use immediate_patch strategy for minimal risk",
|
||||
rationale: "Keeps changes localized and quick to review",
|
||||
tradeoff: "Defers comprehensive refactoring"
|
||||
}
|
||||
],
|
||||
tasks_with_rationale: {
|
||||
// Each task gets rationale if Medium
|
||||
task_rationale_example: {
|
||||
rationale: {
|
||||
chosen_approach: "Direct fix approach",
|
||||
alternatives_considered: ["Workaround", "Refactor"],
|
||||
decision_factors: ["Minimal impact", "Quick turnaround"],
|
||||
tradeoffs: "Doesn't address underlying issue"
|
||||
},
|
||||
verification: {
|
||||
unit_tests: ["test_bug_fix_basic"],
|
||||
integration_tests: [],
|
||||
manual_checks: ["Reproduce issue", "Verify fix"],
|
||||
success_metrics: ["Issue resolved", "No regressions"]
|
||||
}
|
||||
}
|
||||
}
|
||||
} : {}),
|
||||
|
||||
_metadata: {
|
||||
timestamp: getUtc8ISOString(),
|
||||
source: "direct-planning",
|
||||
planning_mode: "direct",
|
||||
complexity: severity === "Medium" ? "Medium" : "Low"
|
||||
}
|
||||
}
|
||||
|
||||
// Step 3: Write fix-plan to session folder
|
||||
// Step 3: Merge task rationale into tasks array
|
||||
if (severity === "Medium") {
|
||||
fixPlan.tasks = fixPlan.tasks.map(task => ({
|
||||
...task,
|
||||
rationale: fixPlan.tasks_with_rationale[task.id]?.rationale || {
|
||||
chosen_approach: "Standard fix",
|
||||
alternatives_considered: [],
|
||||
decision_factors: ["Correctness", "Simplicity"],
|
||||
tradeoffs: "None"
|
||||
},
|
||||
verification: fixPlan.tasks_with_rationale[task.id]?.verification || {
|
||||
unit_tests: [`test_${task.id}_basic`],
|
||||
integration_tests: [],
|
||||
manual_checks: ["Verify fix works"],
|
||||
success_metrics: ["Test pass"]
|
||||
}
|
||||
}))
|
||||
delete fixPlan.tasks_with_rationale // Clean up temp field
|
||||
}
|
||||
|
||||
// Step 4: Write fix-plan to session folder
|
||||
Write(`${sessionFolder}/fix-plan.json`, JSON.stringify(fixPlan, null, 2))
|
||||
|
||||
// Step 4: MUST continue to Phase 4 (Confirmation) - DO NOT execute code here
|
||||
// Step 5: MUST continue to Phase 4 (Confirmation) - DO NOT execute code here
|
||||
```
|
||||
|
||||
**High/Critical Severity** - Invoke cli-lite-planning-agent:
|
||||
@@ -406,9 +512,22 @@ Task(
|
||||
prompt=`
|
||||
Generate fix plan and write fix-plan.json.
|
||||
|
||||
## Output Location
|
||||
|
||||
**Session Folder**: ${sessionFolder}
|
||||
**Output Files**:
|
||||
- ${sessionFolder}/planning-context.md (evidence + understanding)
|
||||
- ${sessionFolder}/fix-plan.json (fix plan)
|
||||
|
||||
## Output Schema Reference
|
||||
Execute: cat ~/.claude/workflows/cli-templates/schemas/fix-plan-json-schema.json (get schema reference before generating plan)
|
||||
|
||||
## Project Context (MANDATORY - Read Both Files)
|
||||
1. Read: .workflow/project-tech.json (technology stack, architecture, key components)
|
||||
2. Read: .workflow/project-guidelines.json (user-defined constraints and conventions)
|
||||
|
||||
**CRITICAL**: All fix tasks MUST comply with constraints in project-guidelines.json
|
||||
|
||||
## Bug Description
|
||||
${bug_description}
|
||||
|
||||
@@ -443,11 +562,41 @@ Generate fix-plan.json with:
|
||||
- description
|
||||
- modification_points: ALL files to modify for this fix (group related changes)
|
||||
- implementation (2-5 steps covering all modification_points)
|
||||
- verification (test criteria)
|
||||
- acceptance: Quantified acceptance criteria
|
||||
- depends_on: task IDs this task depends on (use sparingly)
|
||||
|
||||
**High/Critical complexity fields per task** (REQUIRED):
|
||||
- rationale:
|
||||
- chosen_approach: Why this fix approach (not alternatives)
|
||||
- alternatives_considered: Other approaches evaluated
|
||||
- decision_factors: Key factors influencing choice
|
||||
- tradeoffs: Known tradeoffs of this approach
|
||||
- verification:
|
||||
- unit_tests: Test names to add/verify
|
||||
- integration_tests: Integration test names
|
||||
- manual_checks: Manual verification steps
|
||||
- success_metrics: Quantified success criteria
|
||||
- risks:
|
||||
- description: Risk description
|
||||
- probability: Low|Medium|High
|
||||
- impact: Low|Medium|High
|
||||
- mitigation: How to mitigate
|
||||
- fallback: Fallback if fix fails
|
||||
- code_skeleton (optional): Key interfaces/functions to implement
|
||||
- interfaces: [{name, definition, purpose}]
|
||||
- key_functions: [{signature, purpose, returns}]
|
||||
|
||||
**Top-level High/Critical fields** (REQUIRED):
|
||||
- data_flow: How data flows through affected code
|
||||
- diagram: "A → B → C" style flow
|
||||
- stages: [{stage, input, output, component}]
|
||||
- design_decisions: Global fix decisions
|
||||
- [{decision, rationale, tradeoff}]
|
||||
|
||||
- estimated_time, recommended_execution, severity, risk_level
|
||||
- _metadata:
|
||||
- timestamp, source, planning_mode
|
||||
- complexity: "High" | "Critical"
|
||||
- diagnosis_angles: ${JSON.stringify(manifest.diagnoses.map(d => d.angle))}
|
||||
|
||||
## Task Grouping Rules
|
||||
@@ -459,11 +608,22 @@ Generate fix-plan.json with:
|
||||
|
||||
## Execution
|
||||
1. Read ALL diagnosis files for comprehensive context
|
||||
2. Execute CLI planning using Gemini (Qwen fallback)
|
||||
2. Execute CLI planning using Gemini (Qwen fallback) with --rule planning-fix-strategy template
|
||||
3. Synthesize findings from multiple diagnosis angles
|
||||
4. Parse output and structure fix-plan
|
||||
5. Write JSON: Write('${sessionFolder}/fix-plan.json', jsonContent)
|
||||
6. Return brief completion summary
|
||||
4. Generate fix-plan with:
|
||||
- For High/Critical: REQUIRED new fields (rationale, verification, risks, code_skeleton, data_flow, design_decisions)
|
||||
- Each task MUST have rationale (why this fix), verification (how to verify success), and risks (potential issues)
|
||||
5. Parse output and structure fix-plan
|
||||
6. **Write**: \`${sessionFolder}/planning-context.md\` (evidence paths + understanding)
|
||||
7. **Write**: \`${sessionFolder}/fix-plan.json\`
|
||||
8. Return brief completion summary
|
||||
|
||||
## Output Format for CLI
|
||||
Include these sections in your fix-plan output:
|
||||
- Summary, Root Cause, Strategy (existing)
|
||||
- Data Flow: Diagram showing affected code paths
|
||||
- Design Decisions: Key architectural choices in the fix
|
||||
- Tasks: Each with rationale (Medium/High), verification (Medium/High), risks (High), code_skeleton (High)
|
||||
`
|
||||
)
|
||||
```
|
||||
@@ -497,45 +657,65 @@ ${fixPlan.tasks.map((t, i) => `${i+1}. ${t.title} (${t.scope})`).join('\n')}
|
||||
|
||||
**Step 4.2: Collect Confirmation**
|
||||
```javascript
|
||||
AskUserQuestion({
|
||||
questions: [
|
||||
{
|
||||
question: `Confirm fix plan? (${fixPlan.tasks.length} tasks, ${fixPlan.severity} severity)`,
|
||||
header: "Confirm",
|
||||
multiSelect: true,
|
||||
options: [
|
||||
{ label: "Allow", description: "Proceed as-is" },
|
||||
{ label: "Modify", description: "Adjust before execution" },
|
||||
{ label: "Cancel", description: "Abort workflow" }
|
||||
]
|
||||
},
|
||||
{
|
||||
question: "Execution method:",
|
||||
header: "Execution",
|
||||
multiSelect: false,
|
||||
options: [
|
||||
{ label: "Agent", description: "@code-developer agent" },
|
||||
{ label: "Codex", description: "codex CLI tool" },
|
||||
{ label: "Auto", description: `Auto: ${fixPlan.severity === 'Low' ? 'Agent' : 'Codex'}` }
|
||||
]
|
||||
},
|
||||
{
|
||||
question: "Code review after fix?",
|
||||
header: "Review",
|
||||
multiSelect: false,
|
||||
options: [
|
||||
{ label: "Gemini Review", description: "Gemini CLI" },
|
||||
{ label: "Agent Review", description: "@code-reviewer" },
|
||||
{ label: "Skip", description: "No review" }
|
||||
]
|
||||
}
|
||||
]
|
||||
})
|
||||
// Parse --yes flag
|
||||
const autoYes = $ARGUMENTS.includes('--yes') || $ARGUMENTS.includes('-y')
|
||||
|
||||
let userSelection
|
||||
|
||||
if (autoYes) {
|
||||
// Auto mode: Use defaults
|
||||
console.log(`[--yes] Auto-confirming fix plan:`)
|
||||
console.log(` - Confirmation: Allow`)
|
||||
console.log(` - Execution: Auto`)
|
||||
console.log(` - Review: Skip`)
|
||||
|
||||
userSelection = {
|
||||
confirmation: "Allow",
|
||||
execution_method: "Auto",
|
||||
code_review_tool: "Skip"
|
||||
}
|
||||
} else {
|
||||
// Interactive mode: Ask user
|
||||
userSelection = AskUserQuestion({
|
||||
questions: [
|
||||
{
|
||||
question: `Confirm fix plan? (${fixPlan.tasks.length} tasks, ${fixPlan.severity} severity)`,
|
||||
header: "Confirm",
|
||||
multiSelect: false,
|
||||
options: [
|
||||
{ label: "Allow", description: "Proceed as-is" },
|
||||
{ label: "Modify", description: "Adjust before execution" },
|
||||
{ label: "Cancel", description: "Abort workflow" }
|
||||
]
|
||||
},
|
||||
{
|
||||
question: "Execution method:",
|
||||
header: "Execution",
|
||||
multiSelect: false,
|
||||
options: [
|
||||
{ label: "Agent", description: "@code-developer agent" },
|
||||
{ label: "Codex", description: "codex CLI tool" },
|
||||
{ label: "Auto", description: `Auto: ${fixPlan.severity === 'Low' ? 'Agent' : 'Codex'}` }
|
||||
]
|
||||
},
|
||||
{
|
||||
question: "Code review after fix?",
|
||||
header: "Review",
|
||||
multiSelect: false,
|
||||
options: [
|
||||
{ label: "Gemini Review", description: "Gemini CLI" },
|
||||
{ label: "Agent Review", description: "@code-reviewer" },
|
||||
{ label: "Skip", description: "No review" }
|
||||
]
|
||||
}
|
||||
]
|
||||
})
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### Phase 5: Dispatch to Execution
|
||||
### Phase 5: Execute to Execution
|
||||
|
||||
**CRITICAL**: lite-fix NEVER executes code directly. ALL execution MUST go through lite-execute.
|
||||
|
||||
@@ -557,7 +737,11 @@ const fixPlan = JSON.parse(Read(`${sessionFolder}/fix-plan.json`))
|
||||
executionContext = {
|
||||
mode: "bugfix",
|
||||
severity: fixPlan.severity,
|
||||
planObject: fixPlan,
|
||||
planObject: {
|
||||
...fixPlan,
|
||||
// Ensure complexity is set based on severity for new field consumption
|
||||
complexity: fixPlan.complexity || (fixPlan.severity === 'Critical' ? 'High' : (fixPlan.severity === 'High' ? 'High' : 'Medium'))
|
||||
},
|
||||
diagnosisContext: diagnoses,
|
||||
diagnosisAngles: manifest.diagnoses.map(d => d.angle),
|
||||
diagnosisManifest: manifest,
|
||||
@@ -580,32 +764,34 @@ executionContext = {
|
||||
}
|
||||
```
|
||||
|
||||
**Step 5.2: Dispatch**
|
||||
**Step 5.2: Execute**
|
||||
|
||||
```javascript
|
||||
SlashCommand(command="/workflow:lite-execute --in-memory --mode bugfix")
|
||||
Skill(skill="workflow:lite-execute", args="--in-memory --mode bugfix")
|
||||
```
|
||||
|
||||
## Session Folder Structure
|
||||
|
||||
```
|
||||
.workflow/.lite-fix/{bug-slug}-{YYYY-MM-DD}/
|
||||
|- diagnosis-{angle1}.json # Diagnosis angle 1
|
||||
|- diagnosis-{angle2}.json # Diagnosis angle 2
|
||||
|- diagnosis-{angle3}.json # Diagnosis angle 3 (if applicable)
|
||||
|- diagnosis-{angle4}.json # Diagnosis angle 4 (if applicable)
|
||||
|- diagnoses-manifest.json # Diagnosis index
|
||||
+- fix-plan.json # Fix plan
|
||||
├── diagnosis-{angle1}.json # Diagnosis angle 1
|
||||
├── diagnosis-{angle2}.json # Diagnosis angle 2
|
||||
├── diagnosis-{angle3}.json # Diagnosis angle 3 (if applicable)
|
||||
├── diagnosis-{angle4}.json # Diagnosis angle 4 (if applicable)
|
||||
├── diagnoses-manifest.json # Diagnosis index
|
||||
├── planning-context.md # Evidence + understanding
|
||||
└── fix-plan.json # Fix plan
|
||||
```
|
||||
|
||||
**Example**:
|
||||
```
|
||||
.workflow/.lite-fix/user-avatar-upload-fails-413-2025-11-25-14-30-25/
|
||||
|- diagnosis-error-handling.json
|
||||
|- diagnosis-dataflow.json
|
||||
|- diagnosis-validation.json
|
||||
|- diagnoses-manifest.json
|
||||
+- fix-plan.json
|
||||
.workflow/.lite-fix/user-avatar-upload-fails-413-2025-11-25/
|
||||
├── diagnosis-error-handling.json
|
||||
├── diagnosis-dataflow.json
|
||||
├── diagnosis-validation.json
|
||||
├── diagnoses-manifest.json
|
||||
├── planning-context.md
|
||||
└── fix-plan.json
|
||||
```
|
||||
|
||||
## Error Handling
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
---
|
||||
name: lite-plan
|
||||
description: Lightweight interactive planning workflow with in-memory planning, code exploration, and execution dispatch to lite-execute after user confirmation
|
||||
argument-hint: "[-e|--explore] \"task description\"|file.md"
|
||||
allowed-tools: TodoWrite(*), Task(*), SlashCommand(*), AskUserQuestion(*)
|
||||
description: Lightweight interactive planning workflow with in-memory planning, code exploration, and execution execute to lite-execute after user confirmation
|
||||
argument-hint: "[-y|--yes] [-e|--explore] \"task description\"|file.md"
|
||||
allowed-tools: TodoWrite(*), Task(*), Skill(*), AskUserQuestion(*)
|
||||
---
|
||||
|
||||
# Workflow Lite-Plan Command (/workflow:lite-plan)
|
||||
@@ -15,9 +15,9 @@ Intelligent lightweight planning command with dynamic workflow adaptation based
|
||||
- Intelligent task analysis with automatic exploration detection
|
||||
- Dynamic code exploration (cli-explore-agent) when codebase understanding needed
|
||||
- Interactive clarification after exploration to gather missing information
|
||||
- Adaptive planning strategy (direct Claude vs cli-lite-planning-agent) based on complexity
|
||||
- Adaptive planning: Low complexity → Direct Claude; Medium/High → cli-lite-planning-agent
|
||||
- Two-step confirmation: plan display → multi-dimensional input collection
|
||||
- Execution dispatch with complete context handoff to lite-execute
|
||||
- Execution execute with complete context handoff to lite-execute
|
||||
|
||||
## Usage
|
||||
|
||||
@@ -25,10 +25,47 @@ Intelligent lightweight planning command with dynamic workflow adaptation based
|
||||
/workflow:lite-plan [FLAGS] <TASK_DESCRIPTION>
|
||||
|
||||
# Flags
|
||||
-y, --yes Skip all confirmations (auto mode)
|
||||
-e, --explore Force code exploration phase (overrides auto-detection)
|
||||
|
||||
# Arguments
|
||||
<task-description> Task description or path to .md file (required)
|
||||
|
||||
# Examples
|
||||
/workflow:lite-plan "实现JWT认证" # Interactive mode
|
||||
/workflow:lite-plan --yes "实现JWT认证" # Auto mode (no confirmations)
|
||||
/workflow:lite-plan -y -e "优化数据库查询性能" # Auto mode + force exploration
|
||||
```
|
||||
|
||||
## Output Artifacts
|
||||
|
||||
| Artifact | Description |
|
||||
|----------|-------------|
|
||||
| `exploration-{angle}.json` | Per-angle exploration results (1-4 files based on complexity) |
|
||||
| `explorations-manifest.json` | Index of all exploration files |
|
||||
| `planning-context.md` | Evidence paths + synthesized understanding |
|
||||
| `plan.json` | Structured implementation plan (plan-json-schema.json) |
|
||||
|
||||
**Output Directory**: `.workflow/.lite-plan/{task-slug}-{YYYY-MM-DD}/`
|
||||
|
||||
**Agent Usage**:
|
||||
- Low complexity → Direct Claude planning (no agent)
|
||||
- Medium/High complexity → `cli-lite-planning-agent` generates `plan.json`
|
||||
|
||||
**Schema Reference**: `~/.claude/workflows/cli-templates/schemas/plan-json-schema.json`
|
||||
|
||||
## Auto Mode Defaults
|
||||
|
||||
When `--yes` or `-y` flag is used:
|
||||
- **Clarification Questions**: Skipped (no clarification phase)
|
||||
- **Plan Confirmation**: Auto-selected "Allow"
|
||||
- **Execution Method**: Auto-selected "Auto"
|
||||
- **Code Review**: Auto-selected "Skip"
|
||||
|
||||
**Flag Parsing**:
|
||||
```javascript
|
||||
const autoYes = $ARGUMENTS.includes('--yes') || $ARGUMENTS.includes('-y')
|
||||
const forceExplore = $ARGUMENTS.includes('--explore') || $ARGUMENTS.includes('-e')
|
||||
```
|
||||
|
||||
## Execution Process
|
||||
@@ -38,7 +75,7 @@ Phase 1: Task Analysis & Exploration
|
||||
├─ Parse input (description or .md file)
|
||||
├─ intelligent complexity assessment (Low/Medium/High)
|
||||
├─ Exploration decision (auto-detect or --explore flag)
|
||||
├─ ⚠️ Context protection: If file reading ≥50k chars → force cli-explore-agent
|
||||
├─ Context protection: If file reading ≥50k chars → force cli-explore-agent
|
||||
└─ Decision:
|
||||
├─ needsExploration=true → Launch parallel cli-explore-agents (1-4 based on complexity)
|
||||
└─ needsExploration=false → Skip to Phase 2/3
|
||||
@@ -52,8 +89,8 @@ Phase 2: Clarification (optional, multi-round)
|
||||
|
||||
Phase 3: Planning (NO CODE EXECUTION - planning only)
|
||||
└─ Decision (based on Phase 1 complexity):
|
||||
├─ Low → Load schema: cat ~/.claude/workflows/cli-templates/schemas/plan-json-schema.json → Direct Claude planning (following schema) → plan.json → MUST proceed to Phase 4
|
||||
└─ Medium/High → cli-lite-planning-agent → plan.json → MUST proceed to Phase 4
|
||||
├─ Low → Load schema: cat ~/.claude/workflows/cli-templates/schemas/plan-json-schema.json → Direct Claude planning (following schema) → plan.json
|
||||
└─ Medium/High → cli-lite-planning-agent → plan.json (agent internally executes quality check)
|
||||
|
||||
Phase 4: Confirmation & Selection
|
||||
├─ Display plan summary (tasks, complexity, estimated time)
|
||||
@@ -62,9 +99,9 @@ Phase 4: Confirmation & Selection
|
||||
├─ Execution: Agent / Codex / Auto
|
||||
└─ Review: Gemini / Agent / Skip
|
||||
|
||||
Phase 5: Dispatch
|
||||
Phase 5: Execute
|
||||
├─ Build executionContext (plan + explorations + clarifications + selections)
|
||||
└─ SlashCommand("/workflow:lite-execute --in-memory")
|
||||
└─ Skill(skill="workflow:lite-execute", args="--in-memory")
|
||||
```
|
||||
|
||||
## Implementation
|
||||
@@ -140,11 +177,17 @@ function selectAngles(taskDescription, count) {
|
||||
|
||||
const selectedAngles = selectAngles(task_description, complexity === 'High' ? 4 : (complexity === 'Medium' ? 3 : 1))
|
||||
|
||||
// Planning strategy determination
|
||||
const planningStrategy = complexity === 'Low'
|
||||
? 'Direct Claude Planning'
|
||||
: 'cli-lite-planning-agent'
|
||||
|
||||
console.log(`
|
||||
## Exploration Plan
|
||||
|
||||
Task Complexity: ${complexity}
|
||||
Selected Angles: ${selectedAngles.join(', ')}
|
||||
Planning Strategy: ${planningStrategy}
|
||||
|
||||
Launching ${selectedAngles.length} parallel explorations...
|
||||
`)
|
||||
@@ -167,17 +210,23 @@ const explorationTasks = selectedAngles.map((angle, index) =>
|
||||
## Task Objective
|
||||
Execute **${angle}** exploration for task planning context. Analyze codebase from this specific angle to discover relevant structure, patterns, and constraints.
|
||||
|
||||
## Output Location
|
||||
|
||||
**Session Folder**: ${sessionFolder}
|
||||
**Output File**: ${sessionFolder}/exploration-${angle}.json
|
||||
|
||||
## Assigned Context
|
||||
- **Exploration Angle**: ${angle}
|
||||
- **Task Description**: ${task_description}
|
||||
- **Exploration Index**: ${index + 1} of ${selectedAngles.length}
|
||||
- **Output File**: ${sessionFolder}/exploration-${angle}.json
|
||||
|
||||
## MANDATORY FIRST STEPS (Execute by Agent)
|
||||
**You (cli-explore-agent) MUST execute these steps in order:**
|
||||
1. Run: ccw tool exec get_modules_by_depth '{}' (project structure)
|
||||
2. Run: rg -l "{keyword_from_task}" --type ts (locate relevant files)
|
||||
3. Execute: cat ~/.claude/workflows/cli-templates/schemas/explore-json-schema.json (get output schema reference)
|
||||
4. Read: .workflow/project-tech.json (technology stack and architecture context)
|
||||
5. Read: .workflow/project-guidelines.json (user-defined constraints and conventions)
|
||||
|
||||
## Exploration Strategy (${angle} focus)
|
||||
|
||||
@@ -197,8 +246,6 @@ Execute **${angle}** exploration for task planning context. Analyze codebase fro
|
||||
|
||||
## Expected Output
|
||||
|
||||
**File**: ${sessionFolder}/exploration-${angle}.json
|
||||
|
||||
**Schema Reference**: Schema obtained in MANDATORY FIRST STEPS step 3, follow schema exactly
|
||||
|
||||
**Required Fields** (all ${angle} focused):
|
||||
@@ -224,9 +271,9 @@ Execute **${angle}** exploration for task planning context. Analyze codebase fro
|
||||
- [ ] JSON output follows schema exactly
|
||||
- [ ] clarification_needs includes options + recommended
|
||||
|
||||
## Output
|
||||
Write: ${sessionFolder}/exploration-${angle}.json
|
||||
Return: 2-3 sentence summary of ${angle} findings
|
||||
## Execution
|
||||
**Write**: \`${sessionFolder}/exploration-${angle}.json\`
|
||||
**Return**: 2-3 sentence summary of ${angle} findings
|
||||
`
|
||||
)
|
||||
)
|
||||
@@ -315,8 +362,16 @@ explorations.forEach(exp => {
|
||||
// - Produce dedupedClarifications with unique intents only
|
||||
const dedupedClarifications = intelligentMerge(allClarifications)
|
||||
|
||||
// Multi-round clarification: batch questions (max 4 per round)
|
||||
if (dedupedClarifications.length > 0) {
|
||||
// Parse --yes flag
|
||||
const autoYes = $ARGUMENTS.includes('--yes') || $ARGUMENTS.includes('-y')
|
||||
|
||||
if (autoYes) {
|
||||
// Auto mode: Skip clarification phase
|
||||
console.log(`[--yes] Skipping ${dedupedClarifications.length} clarification questions`)
|
||||
console.log(`Proceeding to planning with exploration results...`)
|
||||
// Continue to Phase 3
|
||||
} else if (dedupedClarifications.length > 0) {
|
||||
// Interactive mode: Multi-round clarification
|
||||
const BATCH_SIZE = 4
|
||||
const totalRounds = Math.ceil(dedupedClarifications.length / BATCH_SIZE)
|
||||
|
||||
@@ -358,10 +413,7 @@ if (dedupedClarifications.length > 0) {
|
||||
```javascript
|
||||
// 分配规则(优先级从高到低):
|
||||
// 1. 用户明确指定:"用 gemini 分析..." → gemini, "codex 实现..." → codex
|
||||
// 2. 任务类型推断:
|
||||
// - 分析|审查|评估|探索 → gemini
|
||||
// - 实现|创建|修改|修复 → codex (复杂) 或 agent (简单)
|
||||
// 3. 默认 → agent
|
||||
// 2. 默认 → agent
|
||||
|
||||
const executorAssignments = {} // { taskId: { executor: 'gemini'|'codex'|'agent', reason: string } }
|
||||
plan.tasks.forEach(task => {
|
||||
@@ -410,9 +462,22 @@ Task(
|
||||
prompt=`
|
||||
Generate implementation plan and write plan.json.
|
||||
|
||||
## Output Location
|
||||
|
||||
**Session Folder**: ${sessionFolder}
|
||||
**Output Files**:
|
||||
- ${sessionFolder}/planning-context.md (evidence + understanding)
|
||||
- ${sessionFolder}/plan.json (implementation plan)
|
||||
|
||||
## Output Schema Reference
|
||||
Execute: cat ~/.claude/workflows/cli-templates/schemas/plan-json-schema.json (get schema reference before generating plan)
|
||||
|
||||
## Project Context (MANDATORY - Read Both Files)
|
||||
1. Read: .workflow/project-tech.json (technology stack, architecture, key components)
|
||||
2. Read: .workflow/project-guidelines.json (user-defined constraints and conventions)
|
||||
|
||||
**CRITICAL**: All generated tasks MUST comply with constraints in project-guidelines.json
|
||||
|
||||
## Task Description
|
||||
${task_description}
|
||||
|
||||
@@ -453,8 +518,9 @@ Generate plan.json following the schema obtained above. Key constraints:
|
||||
2. Execute CLI planning using Gemini (Qwen fallback)
|
||||
3. Read ALL exploration files for comprehensive context
|
||||
4. Synthesize findings and generate plan following schema
|
||||
5. Write JSON: Write('${sessionFolder}/plan.json', jsonContent)
|
||||
6. Return brief completion summary
|
||||
5. **Write**: \`${sessionFolder}/planning-context.md\` (evidence paths + understanding)
|
||||
6. **Write**: \`${sessionFolder}/plan.json\`
|
||||
7. Return brief completion summary
|
||||
`
|
||||
)
|
||||
```
|
||||
@@ -486,45 +552,67 @@ ${plan.tasks.map((t, i) => `${i+1}. ${t.title} (${t.file})`).join('\n')}
|
||||
|
||||
**Step 4.2: Collect Confirmation**
|
||||
```javascript
|
||||
AskUserQuestion({
|
||||
questions: [
|
||||
{
|
||||
question: `Confirm plan? (${plan.tasks.length} tasks, ${plan.complexity})`,
|
||||
header: "Confirm",
|
||||
multiSelect: true,
|
||||
options: [
|
||||
{ label: "Allow", description: "Proceed as-is" },
|
||||
{ label: "Modify", description: "Adjust before execution" },
|
||||
{ label: "Cancel", description: "Abort workflow" }
|
||||
]
|
||||
},
|
||||
{
|
||||
question: "Execution method:",
|
||||
header: "Execution",
|
||||
multiSelect: false,
|
||||
options: [
|
||||
{ label: "Agent", description: "@code-developer agent" },
|
||||
{ label: "Codex", description: "codex CLI tool" },
|
||||
{ label: "Auto", description: `Auto: ${plan.complexity === 'Low' ? 'Agent' : 'Codex'}` }
|
||||
]
|
||||
},
|
||||
{
|
||||
question: "Code review after execution?",
|
||||
header: "Review",
|
||||
multiSelect: false,
|
||||
options: [
|
||||
{ label: "Gemini Review", description: "Gemini CLI" },
|
||||
{ label: "Agent Review", description: "@code-reviewer" },
|
||||
{ label: "Skip", description: "No review" }
|
||||
]
|
||||
}
|
||||
]
|
||||
})
|
||||
// Parse --yes flag
|
||||
const autoYes = $ARGUMENTS.includes('--yes') || $ARGUMENTS.includes('-y')
|
||||
|
||||
let userSelection
|
||||
|
||||
if (autoYes) {
|
||||
// Auto mode: Use defaults
|
||||
console.log(`[--yes] Auto-confirming plan:`)
|
||||
console.log(` - Confirmation: Allow`)
|
||||
console.log(` - Execution: Auto`)
|
||||
console.log(` - Review: Skip`)
|
||||
|
||||
userSelection = {
|
||||
confirmation: "Allow",
|
||||
execution_method: "Auto",
|
||||
code_review_tool: "Skip"
|
||||
}
|
||||
} else {
|
||||
// Interactive mode: Ask user
|
||||
// Note: Execution "Other" option allows specifying CLI tools from ~/.claude/cli-tools.json
|
||||
userSelection = AskUserQuestion({
|
||||
questions: [
|
||||
{
|
||||
question: `Confirm plan? (${plan.tasks.length} tasks, ${plan.complexity})`,
|
||||
header: "Confirm",
|
||||
multiSelect: false,
|
||||
options: [
|
||||
{ label: "Allow", description: "Proceed as-is" },
|
||||
{ label: "Modify", description: "Adjust before execution" },
|
||||
{ label: "Cancel", description: "Abort workflow" }
|
||||
]
|
||||
},
|
||||
{
|
||||
question: "Execution method:",
|
||||
header: "Execution",
|
||||
multiSelect: false,
|
||||
options: [
|
||||
{ label: "Agent", description: "@code-developer agent" },
|
||||
{ label: "Codex", description: "codex CLI tool" },
|
||||
{ label: "Auto", description: `Auto: ${plan.complexity === 'Low' ? 'Agent' : 'Codex'}` }
|
||||
]
|
||||
},
|
||||
{
|
||||
question: "Code review after execution?",
|
||||
header: "Review",
|
||||
multiSelect: false,
|
||||
options: [
|
||||
{ label: "Gemini Review", description: "Gemini CLI review" },
|
||||
{ label: "Codex Review", description: "Git-aware review (prompt OR --uncommitted)" },
|
||||
{ label: "Agent Review", description: "@code-reviewer agent" },
|
||||
{ label: "Skip", description: "No review" }
|
||||
]
|
||||
}
|
||||
]
|
||||
})
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### Phase 5: Dispatch to Execution
|
||||
### Phase 5: Execute to Execution
|
||||
|
||||
**CRITICAL**: lite-plan NEVER executes code directly. ALL execution MUST go through lite-execute.
|
||||
|
||||
@@ -571,10 +659,10 @@ executionContext = {
|
||||
}
|
||||
```
|
||||
|
||||
**Step 5.2: Dispatch**
|
||||
**Step 5.2: Execute**
|
||||
|
||||
```javascript
|
||||
SlashCommand(command="/workflow:lite-execute --in-memory")
|
||||
Skill(skill="workflow:lite-execute", args="--in-memory")
|
||||
```
|
||||
|
||||
## Session Folder Structure
|
||||
|
||||
579
.claude/commands/workflow/multi-cli-plan.md
Normal file
579
.claude/commands/workflow/multi-cli-plan.md
Normal file
@@ -0,0 +1,579 @@
|
||||
---
|
||||
name: workflow:multi-cli-plan
|
||||
description: Multi-CLI collaborative planning workflow with ACE context gathering and iterative cross-verification. Uses cli-discuss-agent for Gemini+Codex+Claude analysis to converge on optimal execution plan.
|
||||
argument-hint: "[-y|--yes] <task description> [--max-rounds=3] [--tools=gemini,codex] [--mode=parallel|serial]"
|
||||
allowed-tools: TodoWrite(*), Task(*), AskUserQuestion(*), Read(*), Bash(*), Write(*), mcp__ace-tool__search_context(*)
|
||||
---
|
||||
|
||||
## Auto Mode
|
||||
|
||||
When `--yes` or `-y`: Auto-approve plan, use recommended solution and execution method (Agent, Skip review).
|
||||
|
||||
# Multi-CLI Collaborative Planning Command
|
||||
|
||||
## Quick Start
|
||||
|
||||
```bash
|
||||
# Basic usage
|
||||
/workflow:multi-cli-plan "Implement user authentication"
|
||||
|
||||
# With options
|
||||
/workflow:multi-cli-plan "Add dark mode support" --max-rounds=3
|
||||
/workflow:multi-cli-plan "Refactor payment module" --tools=gemini,codex,claude
|
||||
/workflow:multi-cli-plan "Fix memory leak" --mode=serial
|
||||
```
|
||||
|
||||
**Context Source**: ACE semantic search + Multi-CLI analysis
|
||||
**Output Directory**: `.workflow/.multi-cli-plan/{session-id}/`
|
||||
**Default Max Rounds**: 3 (convergence may complete earlier)
|
||||
**CLI Tools**: @cli-discuss-agent (analysis), @cli-lite-planning-agent (plan generation)
|
||||
**Execution**: Auto-hands off to `/workflow:lite-execute --in-memory` after plan approval
|
||||
|
||||
## What & Why
|
||||
|
||||
### Core Concept
|
||||
|
||||
Multi-CLI collaborative planning with **three-phase architecture**: ACE context gathering → Iterative multi-CLI discussion → Plan generation. Orchestrator delegates analysis to agents, only handles user decisions and session management.
|
||||
|
||||
**Process**:
|
||||
- **Phase 1**: ACE semantic search gathers codebase context
|
||||
- **Phase 2**: cli-discuss-agent orchestrates Gemini/Codex/Claude for cross-verified analysis
|
||||
- **Phase 3-5**: User decision → Plan generation → Execution handoff
|
||||
|
||||
**vs Single-CLI Planning**:
|
||||
- **Single**: One model perspective, potential blind spots
|
||||
- **Multi-CLI**: Cross-verification catches inconsistencies, builds consensus on solutions
|
||||
|
||||
### Value Proposition
|
||||
|
||||
1. **Multi-Perspective Analysis**: Gemini + Codex + Claude analyze from different angles
|
||||
2. **Cross-Verification**: Identify agreements/disagreements, build confidence
|
||||
3. **User-Driven Decisions**: Every round ends with user decision point
|
||||
4. **Iterative Convergence**: Progressive refinement until consensus reached
|
||||
|
||||
### Orchestrator Boundary (CRITICAL)
|
||||
|
||||
- **ONLY command** for multi-CLI collaborative planning
|
||||
- Manages: Session state, user decisions, agent delegation, phase transitions
|
||||
- Delegates: CLI execution to @cli-discuss-agent, plan generation to @cli-lite-planning-agent
|
||||
|
||||
### Execution Flow
|
||||
|
||||
```
|
||||
Phase 1: Context Gathering
|
||||
└─ ACE semantic search, extract keywords, build context package
|
||||
|
||||
Phase 2: Multi-CLI Discussion (Iterative, via @cli-discuss-agent)
|
||||
├─ Round N: Agent executes Gemini + Codex + Claude
|
||||
├─ Cross-verify findings, synthesize solutions
|
||||
├─ Write synthesis.json to rounds/{N}/
|
||||
└─ Loop until convergence or max rounds
|
||||
|
||||
Phase 3: Present Options
|
||||
└─ Display solutions with trade-offs from agent output
|
||||
|
||||
Phase 4: User Decision
|
||||
├─ Select solution approach
|
||||
├─ Select execution method (Agent/Codex/Auto)
|
||||
├─ Select code review tool (Skip/Gemini/Codex/Agent)
|
||||
└─ Route:
|
||||
├─ Approve → Phase 5
|
||||
├─ Need More Analysis → Return to Phase 2
|
||||
└─ Cancel → Save session
|
||||
|
||||
Phase 5: Plan Generation & Execution Handoff
|
||||
├─ Generate plan.json (via @cli-lite-planning-agent)
|
||||
├─ Build executionContext with user selections
|
||||
└─ Execute to /workflow:lite-execute --in-memory
|
||||
```
|
||||
|
||||
### Agent Roles
|
||||
|
||||
| Agent | Responsibility |
|
||||
|-------|---------------|
|
||||
| **Orchestrator** | Session management, ACE context, user decisions, phase transitions, executionContext assembly |
|
||||
| **@cli-discuss-agent** | Multi-CLI execution (Gemini/Codex/Claude), cross-verification, solution synthesis, synthesis.json output |
|
||||
| **@cli-lite-planning-agent** | Task decomposition, plan.json generation following schema |
|
||||
|
||||
## Core Responsibilities
|
||||
|
||||
### Phase 1: Context Gathering
|
||||
|
||||
**Session Initialization**:
|
||||
```javascript
|
||||
const sessionId = `MCP-${taskSlug}-${date}`
|
||||
const sessionFolder = `.workflow/.multi-cli-plan/${sessionId}`
|
||||
Bash(`mkdir -p ${sessionFolder}/rounds`)
|
||||
```
|
||||
|
||||
**ACE Context Queries**:
|
||||
```javascript
|
||||
const aceQueries = [
|
||||
`Project architecture related to ${keywords}`,
|
||||
`Existing implementations of ${keywords[0]}`,
|
||||
`Code patterns for ${keywords} features`,
|
||||
`Integration points for ${keywords[0]}`
|
||||
]
|
||||
// Execute via mcp__ace-tool__search_context
|
||||
```
|
||||
|
||||
**Context Package** (passed to agent):
|
||||
- `relevant_files[]` - Files identified by ACE
|
||||
- `detected_patterns[]` - Code patterns found
|
||||
- `architecture_insights` - Structure understanding
|
||||
|
||||
### Phase 2: Agent Delegation
|
||||
|
||||
**Core Principle**: Orchestrator only delegates and reads output - NO direct CLI execution.
|
||||
|
||||
**⚠️ CRITICAL - CLI EXECUTION REQUIREMENT**:
|
||||
- **MUST** execute CLI calls via `Bash` with `run_in_background: true`
|
||||
- **MUST** wait for hook callback to receive complete results
|
||||
- **MUST NOT** proceed with next phase until CLI execution fully completes
|
||||
- Do NOT use `TaskOutput` polling during CLI execution - wait passively for results
|
||||
- Minimize scope: Proceed only when 100% result available
|
||||
|
||||
**Agent Invocation**:
|
||||
```javascript
|
||||
Task({
|
||||
subagent_type: "cli-discuss-agent",
|
||||
run_in_background: false,
|
||||
description: `Discussion round ${currentRound}`,
|
||||
prompt: `
|
||||
## Input Context
|
||||
- task_description: ${taskDescription}
|
||||
- round_number: ${currentRound}
|
||||
- session: { id: "${sessionId}", folder: "${sessionFolder}" }
|
||||
- ace_context: ${JSON.stringify(contextPackageage)}
|
||||
- previous_rounds: ${JSON.stringify(analysisResults)}
|
||||
- user_feedback: ${userFeedback || 'None'}
|
||||
- cli_config: { tools: ["gemini", "codex"], mode: "parallel", fallback_chain: ["gemini", "codex", "claude"] }
|
||||
|
||||
## Execution Process
|
||||
1. Parse input context (handle JSON strings)
|
||||
2. Check if ACE supplementary search needed
|
||||
3. Build CLI prompts with context
|
||||
4. Execute CLIs (parallel or serial per cli_config.mode)
|
||||
5. Parse CLI outputs, handle failures with fallback
|
||||
6. Perform cross-verification between CLI results
|
||||
7. Synthesize solutions, calculate scores
|
||||
8. Calculate convergence, generate clarification questions
|
||||
9. Write synthesis.json
|
||||
|
||||
## Output
|
||||
Write: ${sessionFolder}/rounds/${currentRound}/synthesis.json
|
||||
|
||||
## Completion Checklist
|
||||
- [ ] All configured CLI tools executed (or fallback triggered)
|
||||
- [ ] Cross-verification completed with agreements/disagreements
|
||||
- [ ] 2-3 solutions generated with file:line references
|
||||
- [ ] Convergence score calculated (0.0-1.0)
|
||||
- [ ] synthesis.json written with all Primary Fields
|
||||
`
|
||||
})
|
||||
```
|
||||
|
||||
**Read Agent Output**:
|
||||
```javascript
|
||||
const synthesis = JSON.parse(Read(`${sessionFolder}/rounds/${round}/synthesis.json`))
|
||||
// Access top-level fields: solutions, convergence, cross_verification, clarification_questions
|
||||
```
|
||||
|
||||
**Convergence Decision**:
|
||||
```javascript
|
||||
if (synthesis.convergence.recommendation === 'converged') {
|
||||
// Proceed to Phase 3
|
||||
} else if (synthesis.convergence.recommendation === 'user_input_needed') {
|
||||
// Collect user feedback, return to Phase 2
|
||||
} else {
|
||||
// Continue to next round if new_insights && round < maxRounds
|
||||
}
|
||||
```
|
||||
|
||||
### Phase 3: Present Options
|
||||
|
||||
**Display from Agent Output** (no processing):
|
||||
```javascript
|
||||
console.log(`
|
||||
## Solution Options
|
||||
|
||||
${synthesis.solutions.map((s, i) => `
|
||||
**Option ${i+1}: ${s.name}**
|
||||
Source: ${s.source_cli.join(' + ')}
|
||||
Effort: ${s.effort} | Risk: ${s.risk}
|
||||
|
||||
Pros: ${s.pros.join(', ')}
|
||||
Cons: ${s.cons.join(', ')}
|
||||
|
||||
Files: ${s.affected_files.slice(0,3).map(f => `${f.file}:${f.line}`).join(', ')}
|
||||
`).join('\n')}
|
||||
|
||||
## Cross-Verification
|
||||
Agreements: ${synthesis.cross_verification.agreements.length}
|
||||
Disagreements: ${synthesis.cross_verification.disagreements.length}
|
||||
`)
|
||||
```
|
||||
|
||||
### Phase 4: User Decision
|
||||
|
||||
**Decision Options**:
|
||||
```javascript
|
||||
AskUserQuestion({
|
||||
questions: [
|
||||
{
|
||||
question: "Which solution approach?",
|
||||
header: "Solution",
|
||||
multiSelect: false,
|
||||
options: solutions.map((s, i) => ({
|
||||
label: `Option ${i+1}: ${s.name}`,
|
||||
description: `${s.effort} effort, ${s.risk} risk`
|
||||
})).concat([
|
||||
{ label: "Need More Analysis", description: "Return to Phase 2" }
|
||||
])
|
||||
},
|
||||
{
|
||||
question: "Execution method:",
|
||||
header: "Execution",
|
||||
multiSelect: false,
|
||||
options: [
|
||||
{ label: "Agent", description: "@code-developer agent" },
|
||||
{ label: "Codex", description: "codex CLI tool" },
|
||||
{ label: "Auto", description: "Auto-select based on complexity" }
|
||||
]
|
||||
},
|
||||
{
|
||||
question: "Code review after execution?",
|
||||
header: "Review",
|
||||
multiSelect: false,
|
||||
options: [
|
||||
{ label: "Skip", description: "No review" },
|
||||
{ label: "Gemini Review", description: "Gemini CLI tool" },
|
||||
{ label: "Codex Review", description: "codex review --uncommitted" },
|
||||
{ label: "Agent Review", description: "Current agent review" }
|
||||
]
|
||||
}
|
||||
]
|
||||
})
|
||||
```
|
||||
|
||||
**Routing**:
|
||||
- Approve + execution method → Phase 5
|
||||
- Need More Analysis → Phase 2 with feedback
|
||||
- Cancel → Save session for resumption
|
||||
|
||||
### Phase 5: Plan Generation & Execution Handoff
|
||||
|
||||
**Step 1: Build Context-Package** (Orchestrator responsibility):
|
||||
```javascript
|
||||
// Extract key information from user decision and synthesis
|
||||
const contextPackage = {
|
||||
// Core solution details
|
||||
solution: {
|
||||
name: selectedSolution.name,
|
||||
source_cli: selectedSolution.source_cli,
|
||||
feasibility: selectedSolution.feasibility,
|
||||
effort: selectedSolution.effort,
|
||||
risk: selectedSolution.risk,
|
||||
summary: selectedSolution.summary
|
||||
},
|
||||
// Implementation plan (tasks, flow, milestones)
|
||||
implementation_plan: selectedSolution.implementation_plan,
|
||||
// Dependencies
|
||||
dependencies: selectedSolution.dependencies || { internal: [], external: [] },
|
||||
// Technical concerns
|
||||
technical_concerns: selectedSolution.technical_concerns || [],
|
||||
// Consensus from cross-verification
|
||||
consensus: {
|
||||
agreements: synthesis.cross_verification.agreements,
|
||||
resolved_conflicts: synthesis.cross_verification.resolution
|
||||
},
|
||||
// User constraints (from Phase 4 feedback)
|
||||
constraints: userConstraints || [],
|
||||
// Task context
|
||||
task_description: taskDescription,
|
||||
session_id: sessionId
|
||||
}
|
||||
|
||||
// Write context-package for traceability
|
||||
Write(`${sessionFolder}/context-package.json`, JSON.stringify(contextPackage, null, 2))
|
||||
```
|
||||
|
||||
**Context-Package Schema**:
|
||||
|
||||
| Field | Type | Description |
|
||||
|-------|------|-------------|
|
||||
| `solution` | object | User-selected solution from synthesis |
|
||||
| `solution.name` | string | Solution identifier |
|
||||
| `solution.feasibility` | number | Viability score (0-1) |
|
||||
| `solution.summary` | string | Brief analysis summary |
|
||||
| `implementation_plan` | object | Task breakdown with flow and dependencies |
|
||||
| `implementation_plan.approach` | string | High-level technical strategy |
|
||||
| `implementation_plan.tasks[]` | array | Discrete tasks with id, name, depends_on, files |
|
||||
| `implementation_plan.execution_flow` | string | Task sequence (e.g., "T1 → T2 → T3") |
|
||||
| `implementation_plan.milestones` | string[] | Key checkpoints |
|
||||
| `dependencies` | object | Module and package dependencies |
|
||||
| `technical_concerns` | string[] | Risks and blockers |
|
||||
| `consensus` | object | Cross-verified agreements from multi-CLI |
|
||||
| `constraints` | string[] | User-specified constraints from Phase 4 |
|
||||
|
||||
```json
|
||||
{
|
||||
"solution": {
|
||||
"name": "Strategy Pattern Refactoring",
|
||||
"source_cli": ["gemini", "codex"],
|
||||
"feasibility": 0.88,
|
||||
"effort": "medium",
|
||||
"risk": "low",
|
||||
"summary": "Extract payment gateway interface, implement strategy pattern for multi-gateway support"
|
||||
},
|
||||
"implementation_plan": {
|
||||
"approach": "Define interface → Create concrete strategies → Implement factory → Migrate existing code",
|
||||
"tasks": [
|
||||
{"id": "T1", "name": "Define PaymentGateway interface", "depends_on": [], "files": [{"file": "src/types/payment.ts", "line": 1, "action": "create"}], "key_point": "Include all existing Stripe methods"},
|
||||
{"id": "T2", "name": "Implement StripeGateway", "depends_on": ["T1"], "files": [{"file": "src/payment/stripe.ts", "line": 1, "action": "create"}], "key_point": "Wrap existing logic"},
|
||||
{"id": "T3", "name": "Create GatewayFactory", "depends_on": ["T1"], "files": [{"file": "src/payment/factory.ts", "line": 1, "action": "create"}], "key_point": null},
|
||||
{"id": "T4", "name": "Migrate processor to use factory", "depends_on": ["T2", "T3"], "files": [{"file": "src/payment/processor.ts", "line": 45, "action": "modify"}], "key_point": "Backward compatible"}
|
||||
],
|
||||
"execution_flow": "T1 → (T2 | T3) → T4",
|
||||
"milestones": ["Interface defined", "Gateway implementations complete", "Migration done"]
|
||||
},
|
||||
"dependencies": {
|
||||
"internal": ["@/lib/payment-gateway", "@/types/payment"],
|
||||
"external": ["stripe@^14.0.0"]
|
||||
},
|
||||
"technical_concerns": ["Existing tests must pass", "No breaking API changes"],
|
||||
"consensus": {
|
||||
"agreements": ["Use strategy pattern", "Keep existing API"],
|
||||
"resolved_conflicts": "Factory over DI for simpler integration"
|
||||
},
|
||||
"constraints": ["backward compatible", "no breaking changes to PaymentResult type"],
|
||||
"task_description": "Refactor payment processing for multi-gateway support",
|
||||
"session_id": "MCP-payment-refactor-2026-01-14"
|
||||
}
|
||||
```
|
||||
|
||||
**Step 2: Invoke Planning Agent**:
|
||||
```javascript
|
||||
Task({
|
||||
subagent_type: "cli-lite-planning-agent",
|
||||
run_in_background: false,
|
||||
description: "Generate implementation plan",
|
||||
prompt: `
|
||||
## Schema Reference
|
||||
Execute: cat ~/.claude/workflows/cli-templates/schemas/plan-json-schema.json
|
||||
|
||||
## Context-Package (from orchestrator)
|
||||
${JSON.stringify(contextPackage, null, 2)}
|
||||
|
||||
## Execution Process
|
||||
1. Read plan-json-schema.json for output structure
|
||||
2. Read project-tech.json and project-guidelines.json
|
||||
3. Parse context-package fields:
|
||||
- solution: name, feasibility, summary
|
||||
- implementation_plan: tasks[], execution_flow, milestones
|
||||
- dependencies: internal[], external[]
|
||||
- technical_concerns: risks/blockers
|
||||
- consensus: agreements, resolved_conflicts
|
||||
- constraints: user requirements
|
||||
4. Use implementation_plan.tasks[] as task foundation
|
||||
5. Preserve task dependencies (depends_on) and execution_flow
|
||||
6. Expand tasks with detailed acceptance criteria
|
||||
7. Generate plan.json following schema exactly
|
||||
|
||||
## Output
|
||||
- ${sessionFolder}/plan.json
|
||||
|
||||
## Completion Checklist
|
||||
- [ ] plan.json preserves task dependencies from implementation_plan
|
||||
- [ ] Task execution order follows execution_flow
|
||||
- [ ] Key_points reflected in task descriptions
|
||||
- [ ] User constraints applied to implementation
|
||||
- [ ] Acceptance criteria are testable
|
||||
- [ ] Schema fields match plan-json-schema.json exactly
|
||||
`
|
||||
})
|
||||
```
|
||||
|
||||
**Step 3: Build executionContext**:
|
||||
```javascript
|
||||
// After plan.json is generated by cli-lite-planning-agent
|
||||
const plan = JSON.parse(Read(`${sessionFolder}/plan.json`))
|
||||
|
||||
// Build executionContext (same structure as lite-plan)
|
||||
executionContext = {
|
||||
planObject: plan,
|
||||
explorationsContext: null, // Multi-CLI doesn't use exploration files
|
||||
explorationAngles: [], // No exploration angles
|
||||
explorationManifest: null, // No manifest
|
||||
clarificationContext: null, // Store user feedback from Phase 2 if exists
|
||||
executionMethod: userSelection.execution_method, // From Phase 4
|
||||
codeReviewTool: userSelection.code_review_tool, // From Phase 4
|
||||
originalUserInput: taskDescription,
|
||||
|
||||
// Optional: Task-level executor assignments
|
||||
executorAssignments: null, // Could be enhanced in future
|
||||
|
||||
session: {
|
||||
id: sessionId,
|
||||
folder: sessionFolder,
|
||||
artifacts: {
|
||||
explorations: [], // No explorations in multi-CLI workflow
|
||||
explorations_manifest: null,
|
||||
plan: `${sessionFolder}/plan.json`,
|
||||
synthesis_rounds: Array.from({length: currentRound}, (_, i) =>
|
||||
`${sessionFolder}/rounds/${i+1}/synthesis.json`
|
||||
),
|
||||
context_package: `${sessionFolder}/context-package.json`
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
**Step 4: Hand off to Execution**:
|
||||
```javascript
|
||||
// Execute to lite-execute with in-memory context
|
||||
Skill(skill="workflow:lite-execute", args="--in-memory")
|
||||
```
|
||||
|
||||
## Output File Structure
|
||||
|
||||
```
|
||||
.workflow/.multi-cli-plan/{MCP-task-slug-YYYY-MM-DD}/
|
||||
├── session-state.json # Session tracking (orchestrator)
|
||||
├── rounds/
|
||||
│ ├── 1/synthesis.json # Round 1 analysis (cli-discuss-agent)
|
||||
│ ├── 2/synthesis.json # Round 2 analysis (cli-discuss-agent)
|
||||
│ └── .../
|
||||
├── context-package.json # Extracted context for planning (orchestrator)
|
||||
└── plan.json # Structured plan (cli-lite-planning-agent)
|
||||
```
|
||||
|
||||
**File Producers**:
|
||||
|
||||
| File | Producer | Content |
|
||||
|------|----------|---------|
|
||||
| `session-state.json` | Orchestrator | Session metadata, rounds, decisions |
|
||||
| `rounds/*/synthesis.json` | cli-discuss-agent | Solutions, convergence, cross-verification |
|
||||
| `context-package.json` | Orchestrator | Extracted solution, dependencies, consensus for planning |
|
||||
| `plan.json` | cli-lite-planning-agent | Structured tasks for lite-execute |
|
||||
|
||||
## synthesis.json Schema
|
||||
|
||||
```json
|
||||
{
|
||||
"round": 1,
|
||||
"solutions": [{
|
||||
"name": "Solution Name",
|
||||
"source_cli": ["gemini", "codex"],
|
||||
"feasibility": 0.85,
|
||||
"effort": "low|medium|high",
|
||||
"risk": "low|medium|high",
|
||||
"summary": "Brief analysis summary",
|
||||
"implementation_plan": {
|
||||
"approach": "High-level technical approach",
|
||||
"tasks": [
|
||||
{"id": "T1", "name": "Task", "depends_on": [], "files": [], "key_point": "..."}
|
||||
],
|
||||
"execution_flow": "T1 → T2 → T3",
|
||||
"milestones": ["Checkpoint 1", "Checkpoint 2"]
|
||||
},
|
||||
"dependencies": {"internal": [], "external": []},
|
||||
"technical_concerns": ["Risk 1", "Blocker 2"]
|
||||
}],
|
||||
"convergence": {
|
||||
"score": 0.85,
|
||||
"new_insights": false,
|
||||
"recommendation": "converged|continue|user_input_needed"
|
||||
},
|
||||
"cross_verification": {
|
||||
"agreements": [],
|
||||
"disagreements": [],
|
||||
"resolution": "..."
|
||||
},
|
||||
"clarification_questions": []
|
||||
}
|
||||
```
|
||||
|
||||
**Key Planning Fields**:
|
||||
|
||||
| Field | Purpose |
|
||||
|-------|---------|
|
||||
| `feasibility` | Viability score (0-1) |
|
||||
| `implementation_plan.tasks[]` | Discrete tasks with dependencies |
|
||||
| `implementation_plan.execution_flow` | Task sequence visualization |
|
||||
| `implementation_plan.milestones` | Key checkpoints |
|
||||
| `technical_concerns` | Risks and blockers |
|
||||
|
||||
**Note**: Solutions ranked by internal scoring (array order = priority)
|
||||
|
||||
## TodoWrite Structure
|
||||
|
||||
**Initialization**:
|
||||
```javascript
|
||||
TodoWrite({ todos: [
|
||||
{ content: "Phase 1: Context Gathering", status: "in_progress", activeForm: "Gathering context" },
|
||||
{ content: "Phase 2: Multi-CLI Discussion", status: "pending", activeForm: "Running discussion" },
|
||||
{ content: "Phase 3: Present Options", status: "pending", activeForm: "Presenting options" },
|
||||
{ content: "Phase 4: User Decision", status: "pending", activeForm: "Awaiting decision" },
|
||||
{ content: "Phase 5: Plan Generation", status: "pending", activeForm: "Generating plan" }
|
||||
]})
|
||||
```
|
||||
|
||||
**During Discussion Rounds**:
|
||||
```javascript
|
||||
TodoWrite({ todos: [
|
||||
{ content: "Phase 1: Context Gathering", status: "completed", activeForm: "Gathering context" },
|
||||
{ content: "Phase 2: Multi-CLI Discussion", status: "in_progress", activeForm: "Running discussion" },
|
||||
{ content: " → Round 1: Initial analysis", status: "completed", activeForm: "Analyzing" },
|
||||
{ content: " → Round 2: Deep verification", status: "in_progress", activeForm: "Verifying" },
|
||||
{ content: "Phase 3: Present Options", status: "pending", activeForm: "Presenting options" },
|
||||
// ...
|
||||
]})
|
||||
```
|
||||
|
||||
## Error Handling
|
||||
|
||||
| Error | Resolution |
|
||||
|-------|------------|
|
||||
| ACE search fails | Fall back to Glob/Grep for file discovery |
|
||||
| Agent fails | Retry once, then present partial results |
|
||||
| CLI timeout (in agent) | Agent uses fallback: gemini → codex → claude |
|
||||
| No convergence | Present best options, flag uncertainty |
|
||||
| synthesis.json parse error | Request agent retry |
|
||||
| User cancels | Save session for later resumption |
|
||||
|
||||
## Configuration
|
||||
|
||||
| Flag | Default | Description |
|
||||
|------|---------|-------------|
|
||||
| `--max-rounds` | 3 | Maximum discussion rounds |
|
||||
| `--tools` | gemini,codex | CLI tools for analysis |
|
||||
| `--mode` | parallel | Execution mode: parallel or serial |
|
||||
| `--auto-execute` | false | Auto-execute after approval |
|
||||
|
||||
## Best Practices
|
||||
|
||||
1. **Be Specific**: Detailed task descriptions improve ACE context quality
|
||||
2. **Provide Feedback**: Use clarification rounds to refine requirements
|
||||
3. **Trust Cross-Verification**: Multi-CLI consensus indicates high confidence
|
||||
4. **Review Trade-offs**: Consider pros/cons before selecting solution
|
||||
5. **Check synthesis.json**: Review agent output for detailed analysis
|
||||
6. **Iterate When Needed**: Don't hesitate to request more analysis
|
||||
|
||||
## Related Commands
|
||||
|
||||
```bash
|
||||
# Simpler single-round planning
|
||||
/workflow:lite-plan "task description"
|
||||
|
||||
# Issue-driven discovery
|
||||
/issue:discover-by-prompt "find issues"
|
||||
|
||||
# View session files
|
||||
cat .workflow/.multi-cli-plan/{session-id}/plan.json
|
||||
cat .workflow/.multi-cli-plan/{session-id}/rounds/1/synthesis.json
|
||||
cat .workflow/.multi-cli-plan/{session-id}/context-package.json
|
||||
|
||||
# Direct execution (if you have plan.json)
|
||||
/workflow:lite-execute plan.json
|
||||
```
|
||||
377
.claude/commands/workflow/plan-verify.md
Normal file
377
.claude/commands/workflow/plan-verify.md
Normal file
@@ -0,0 +1,377 @@
|
||||
---
|
||||
name: plan-verify
|
||||
description: Perform READ-ONLY verification analysis between IMPL_PLAN.md, task JSONs, and brainstorming artifacts. Generates structured report with quality gate recommendation. Does NOT modify any files.
|
||||
argument-hint: "[optional: --session session-id]"
|
||||
allowed-tools: Read(*), Write(*), Glob(*), Bash(*)
|
||||
---
|
||||
|
||||
## User Input
|
||||
|
||||
```text
|
||||
$ARGUMENTS
|
||||
```
|
||||
|
||||
You **MUST** consider the user input before proceeding (if not empty).
|
||||
|
||||
## Goal
|
||||
|
||||
Generate a comprehensive verification report that identifies inconsistencies, duplications, ambiguities, and underspecified items between action planning artifacts (`IMPL_PLAN.md`, `task.json`) and brainstorming artifacts (`role analysis documents`). This command MUST run only after `/workflow:plan` has successfully produced complete `IMPL_PLAN.md` and task JSON files.
|
||||
|
||||
**Output**: A structured Markdown report saved to `.workflow/active/WFS-{session}/.process/PLAN_VERIFICATION.md` containing:
|
||||
- Executive summary with quality gate recommendation
|
||||
- Detailed findings by severity (CRITICAL/HIGH/MEDIUM/LOW)
|
||||
- Requirements coverage analysis
|
||||
- Dependency integrity check
|
||||
- Synthesis alignment validation
|
||||
- Actionable remediation recommendations
|
||||
|
||||
## Operating Constraints
|
||||
|
||||
**STRICTLY READ-ONLY FOR SOURCE ARTIFACTS**:
|
||||
- **MUST NOT** modify `IMPL_PLAN.md`, any `task.json` files, or brainstorming artifacts
|
||||
- **MUST NOT** create or delete task files
|
||||
- **MUST ONLY** write the verification report to `.process/PLAN_VERIFICATION.md`
|
||||
|
||||
**Synthesis Authority**: The `role analysis documents` are **authoritative** for requirements and design decisions. Any conflicts between IMPL_PLAN/tasks and synthesis are automatically CRITICAL and require adjustment of the plan/tasks—not reinterpretation of requirements.
|
||||
|
||||
**Quality Gate Authority**: The verification report provides a binding recommendation (BLOCK_EXECUTION / PROCEED_WITH_FIXES / PROCEED_WITH_CAUTION / PROCEED) based on objective severity criteria. User MUST review critical/high issues before proceeding with implementation.
|
||||
|
||||
## Execution Steps
|
||||
|
||||
### 1. Initialize Analysis Context
|
||||
|
||||
```bash
|
||||
# Detect active workflow session
|
||||
IF --session parameter provided:
|
||||
session_id = provided session
|
||||
ELSE:
|
||||
# Auto-detect active session
|
||||
active_sessions = bash(find .workflow/active/ -name "WFS-*" -type d 2>/dev/null)
|
||||
IF active_sessions is empty:
|
||||
ERROR: "No active workflow session found. Use --session <session-id>"
|
||||
EXIT
|
||||
ELSE IF active_sessions has multiple entries:
|
||||
# Use most recently modified session
|
||||
session_id = bash(ls -td .workflow/active/WFS-*/ 2>/dev/null | head -1 | xargs basename)
|
||||
ELSE:
|
||||
session_id = basename(active_sessions[0])
|
||||
|
||||
# Derive absolute paths
|
||||
session_dir = .workflow/active/WFS-{session}
|
||||
brainstorm_dir = session_dir/.brainstorming
|
||||
task_dir = session_dir/.task
|
||||
process_dir = session_dir/.process
|
||||
session_file = session_dir/workflow-session.json
|
||||
|
||||
# Create .process directory if not exists (report output location)
|
||||
IF NOT EXISTS(process_dir):
|
||||
bash(mkdir -p "{process_dir}")
|
||||
|
||||
# Validate required artifacts
|
||||
# Note: "role analysis documents" refers to [role]/analysis.md files (e.g., product-manager/analysis.md)
|
||||
SYNTHESIS_DIR = brainstorm_dir # Contains role analysis files: */analysis.md
|
||||
IMPL_PLAN = session_dir/IMPL_PLAN.md
|
||||
TASK_FILES = Glob(task_dir/*.json)
|
||||
PLANNING_NOTES = session_dir/planning-notes.md # N+1 context and constraints
|
||||
|
||||
# Abort if missing - in order of dependency
|
||||
SESSION_FILE_EXISTS = EXISTS(session_file)
|
||||
IF NOT SESSION_FILE_EXISTS:
|
||||
WARNING: "workflow-session.json not found. User intent alignment verification will be skipped."
|
||||
# Continue execution - this is optional context, not blocking
|
||||
|
||||
PLANNING_NOTES_EXISTS = EXISTS(PLANNING_NOTES)
|
||||
IF NOT PLANNING_NOTES_EXISTS:
|
||||
WARNING: "planning-notes.md not found. Constraints/N+1 context verification will be skipped."
|
||||
# Continue execution - optional context
|
||||
|
||||
SYNTHESIS_FILES = Glob(brainstorm_dir/*/analysis.md)
|
||||
IF SYNTHESIS_FILES.count == 0:
|
||||
ERROR: "No role analysis documents found in .brainstorming/*/analysis.md. Run /workflow:brainstorm:synthesis first"
|
||||
EXIT
|
||||
|
||||
IF NOT EXISTS(IMPL_PLAN):
|
||||
ERROR: "IMPL_PLAN.md not found. Run /workflow:plan first"
|
||||
EXIT
|
||||
|
||||
IF TASK_FILES.count == 0:
|
||||
ERROR: "No task JSON files found. Run /workflow:plan first"
|
||||
EXIT
|
||||
```
|
||||
|
||||
### 2. Load Artifacts (Progressive Disclosure)
|
||||
|
||||
Load only minimal necessary context from each artifact:
|
||||
|
||||
**From workflow-session.json** (OPTIONAL - Primary Reference for User Intent):
|
||||
- **ONLY IF EXISTS**: Load user intent context
|
||||
- Original user prompt/intent (project or description field)
|
||||
- User's stated goals and objectives
|
||||
- User's scope definition
|
||||
- **IF MISSING**: Set user_intent_analysis = "SKIPPED: workflow-session.json not found"
|
||||
|
||||
**From planning-notes.md** (OPTIONAL - Constraints & N+1 Context):
|
||||
- **ONLY IF EXISTS**: Load planning context
|
||||
- Consolidated Constraints (numbered list from Phase 1-3)
|
||||
- N+1 Context: Decisions table (Decision | Rationale | Revisit?)
|
||||
- N+1 Context: Deferred items list
|
||||
- **IF MISSING**: Set planning_notes_analysis = "SKIPPED: planning-notes.md not found"
|
||||
|
||||
**From role analysis documents** (AUTHORITATIVE SOURCE):
|
||||
- Functional Requirements (IDs, descriptions, acceptance criteria)
|
||||
- Non-Functional Requirements (IDs, targets)
|
||||
- Business Requirements (IDs, success metrics)
|
||||
- Key Architecture Decisions
|
||||
- Risk factors and mitigation strategies
|
||||
- Implementation Roadmap (high-level phases)
|
||||
|
||||
**From IMPL_PLAN.md**:
|
||||
- Summary and objectives
|
||||
- Context Analysis
|
||||
- Implementation Strategy
|
||||
- Task Breakdown Summary
|
||||
- Success Criteria
|
||||
- Brainstorming Artifacts References (if present)
|
||||
|
||||
**From task.json files**:
|
||||
- Task IDs
|
||||
- Titles and descriptions
|
||||
- Status
|
||||
- Dependencies (depends_on, blocks)
|
||||
- Context (requirements, focus_paths, acceptance, artifacts)
|
||||
- Flow control (pre_analysis, implementation_approach)
|
||||
- Meta (complexity, priority)
|
||||
|
||||
### 3. Build Semantic Models
|
||||
|
||||
Create internal representations (do not include raw artifacts in output):
|
||||
|
||||
**Requirements inventory**:
|
||||
- Each functional/non-functional/business requirement with stable ID
|
||||
- Requirement text, acceptance criteria, priority
|
||||
|
||||
**Architecture decisions inventory**:
|
||||
- ADRs from synthesis
|
||||
- Technology choices
|
||||
- Data model references
|
||||
|
||||
**Task coverage mapping**:
|
||||
- Map each task to one or more requirements (by ID reference or keyword inference)
|
||||
- Map each requirement to covering tasks
|
||||
|
||||
**Dependency graph**:
|
||||
- Task-to-task dependencies (depends_on, blocks)
|
||||
- Requirement-level dependencies (from synthesis)
|
||||
|
||||
### 4. Detection Passes (Agent-Driven Multi-Dimensional Analysis)
|
||||
|
||||
**Execution Strategy**:
|
||||
- Single `cli-explore-agent` invocation
|
||||
- Agent executes multiple CLI analyses internally (different dimensions: A-H)
|
||||
- Token Budget: 50 findings maximum (aggregate remainder in overflow summary)
|
||||
- Priority Allocation: CRITICAL (unlimited) → HIGH (15) → MEDIUM (20) → LOW (15)
|
||||
- Early Exit: If CRITICAL findings > 0 in User Intent/Requirements Coverage, skip LOW/MEDIUM checks
|
||||
|
||||
**Execution Order** (Agent orchestrates internally):
|
||||
|
||||
1. **Tier 1 (CRITICAL Path)**: A, B, C, I - User intent, coverage, consistency, constraints compliance (full analysis)
|
||||
2. **Tier 2 (HIGH Priority)**: D, E, J - Dependencies, synthesis alignment, N+1 context validation (limit 15 findings)
|
||||
3. **Tier 3 (MEDIUM Priority)**: F - Specification quality (limit 20 findings)
|
||||
4. **Tier 4 (LOW Priority)**: G, H - Duplication, feasibility (limit 15 findings)
|
||||
|
||||
---
|
||||
|
||||
#### Phase 4.1: Launch Unified Verification Agent
|
||||
|
||||
```javascript
|
||||
Task(
|
||||
subagent_type="cli-explore-agent",
|
||||
run_in_background=false,
|
||||
description="Multi-dimensional plan verification",
|
||||
prompt=`
|
||||
## Plan Verification Task
|
||||
|
||||
### MANDATORY FIRST STEPS
|
||||
1. Read: ~/.claude/workflows/cli-templates/schemas/plan-verify-agent-schema.json (dimensions & rules)
|
||||
2. Read: ~/.claude/workflows/cli-templates/schemas/verify-json-schema.json (output schema)
|
||||
3. Read: ${session_file} (user intent)
|
||||
4. Read: ${PLANNING_NOTES} (constraints & N+1 context)
|
||||
5. Read: ${IMPL_PLAN} (implementation plan)
|
||||
6. Glob: ${task_dir}/*.json (task files)
|
||||
7. Glob: ${SYNTHESIS_DIR}/*/analysis.md (role analyses)
|
||||
|
||||
### Execution Flow
|
||||
|
||||
**Load schema → Execute tiered CLI analysis → Aggregate findings → Write JSON**
|
||||
|
||||
FOR each tier in [1, 2, 3, 4]:
|
||||
- Load tier config from plan-verify-agent-schema.json
|
||||
- Execute: ccw cli -p "PURPOSE: Verify dimensions {tier.dimensions}
|
||||
TASK: {tier.checks from schema}
|
||||
CONTEXT: @${session_dir}/**/*
|
||||
EXPECTED: Findings JSON with dimension, severity, location, summary, recommendation
|
||||
CONSTRAINTS: Limit {tier.limit} findings
|
||||
" --tool gemini --mode analysis --rule {tier.rule}
|
||||
- Parse findings, check early exit condition
|
||||
- IF tier == 1 AND critical_count > 0: skip tier 3-4
|
||||
|
||||
### Output
|
||||
Write: ${process_dir}/verification-findings.json (follow verify-json-schema.json)
|
||||
Return: Quality gate decision + 2-3 sentence summary
|
||||
`
|
||||
)
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
#### Phase 4.2: Load and Organize Findings
|
||||
|
||||
```javascript
|
||||
// Load findings (single parse for all subsequent use)
|
||||
const data = JSON.parse(Read(`${process_dir}/verification-findings.json`))
|
||||
const { session_id, timestamp, verification_tiers_completed, findings, summary } = data
|
||||
const { critical_count, high_count, medium_count, low_count, total_findings, coverage_percentage, recommendation } = summary
|
||||
|
||||
// Group by severity and dimension
|
||||
const bySeverity = Object.groupBy(findings, f => f.severity)
|
||||
const byDimension = Object.groupBy(findings, f => f.dimension)
|
||||
|
||||
// Dimension metadata (from schema)
|
||||
const DIMS = {
|
||||
A: "User Intent Alignment", B: "Requirements Coverage", C: "Consistency Validation",
|
||||
D: "Dependency Integrity", E: "Synthesis Alignment", F: "Task Specification Quality",
|
||||
G: "Duplication Detection", H: "Feasibility Assessment",
|
||||
I: "Constraints Compliance", J: "N+1 Context Validation"
|
||||
}
|
||||
```
|
||||
|
||||
### 5. Generate Report
|
||||
|
||||
```javascript
|
||||
// Helper: render dimension section
|
||||
const renderDimension = (dim) => {
|
||||
const items = byDimension[dim] || []
|
||||
return items.length > 0
|
||||
? items.map(f => `### ${f.id}: ${f.summary}\n- **Severity**: ${f.severity}\n- **Location**: ${f.location.join(', ')}\n- **Recommendation**: ${f.recommendation}`).join('\n\n')
|
||||
: `> ✅ No ${DIMS[dim]} issues detected.`
|
||||
}
|
||||
|
||||
// Helper: render severity section
|
||||
const renderSeverity = (severity, impact) => {
|
||||
const items = bySeverity[severity] || []
|
||||
return items.length > 0
|
||||
? items.map(f => `#### ${f.id}: ${f.summary}\n- **Dimension**: ${f.dimension_name}\n- **Location**: ${f.location.join(', ')}\n- **Impact**: ${impact}\n- **Recommendation**: ${f.recommendation}`).join('\n\n')
|
||||
: `> ✅ No ${severity.toLowerCase()}-severity issues detected.`
|
||||
}
|
||||
|
||||
// Build Markdown report
|
||||
const fullReport = `
|
||||
# Plan Verification Report
|
||||
|
||||
**Session**: WFS-${session_id} | **Generated**: ${timestamp}
|
||||
**Tiers Completed**: ${verification_tiers_completed.join(', ')}
|
||||
|
||||
---
|
||||
|
||||
## Executive Summary
|
||||
|
||||
| Metric | Value | Status |
|
||||
|--------|-------|--------|
|
||||
| Risk Level | ${critical_count > 0 ? 'CRITICAL' : high_count > 0 ? 'HIGH' : medium_count > 0 ? 'MEDIUM' : 'LOW'} | ${critical_count > 0 ? '🔴' : high_count > 0 ? '🟠' : medium_count > 0 ? '🟡' : '🟢'} |
|
||||
| Critical/High/Medium/Low | ${critical_count}/${high_count}/${medium_count}/${low_count} | |
|
||||
| Coverage | ${coverage_percentage}% | ${coverage_percentage >= 90 ? '🟢' : coverage_percentage >= 75 ? '🟡' : '🔴'} |
|
||||
|
||||
**Recommendation**: **${recommendation}**
|
||||
|
||||
---
|
||||
|
||||
## Findings Summary
|
||||
|
||||
| ID | Dimension | Severity | Location | Summary |
|
||||
|----|-----------|----------|----------|---------|
|
||||
${findings.map(f => `| ${f.id} | ${f.dimension_name} | ${f.severity} | ${f.location.join(', ')} | ${f.summary} |`).join('\n')}
|
||||
|
||||
---
|
||||
|
||||
## Analysis by Dimension
|
||||
|
||||
${['A','B','C','D','E','F','G','H','I','J'].map(d => `### ${d}. ${DIMS[d]}\n\n${renderDimension(d)}`).join('\n\n---\n\n')}
|
||||
|
||||
---
|
||||
|
||||
## Findings by Severity
|
||||
|
||||
### CRITICAL (${critical_count})
|
||||
${renderSeverity('CRITICAL', 'Blocks execution')}
|
||||
|
||||
### HIGH (${high_count})
|
||||
${renderSeverity('HIGH', 'Fix before execution recommended')}
|
||||
|
||||
### MEDIUM (${medium_count})
|
||||
${renderSeverity('MEDIUM', 'Address during/after implementation')}
|
||||
|
||||
### LOW (${low_count})
|
||||
${renderSeverity('LOW', 'Optional improvement')}
|
||||
|
||||
---
|
||||
|
||||
## Next Steps
|
||||
|
||||
${recommendation === 'BLOCK_EXECUTION' ? '🛑 **BLOCK**: Fix critical issues → Re-verify' :
|
||||
recommendation === 'PROCEED_WITH_FIXES' ? '⚠️ **FIX RECOMMENDED**: Address high issues → Re-verify or Execute' :
|
||||
'✅ **READY**: Proceed to /workflow:execute'}
|
||||
|
||||
Re-verify: \`/workflow:plan-verify --session ${session_id}\`
|
||||
Execute: \`/workflow:execute --resume-session="${session_id}"\`
|
||||
`
|
||||
|
||||
// Write report
|
||||
Write(`${process_dir}/PLAN_VERIFICATION.md`, fullReport)
|
||||
console.log(`✅ Report: ${process_dir}/PLAN_VERIFICATION.md\n📊 ${recommendation} | C:${critical_count} H:${high_count} M:${medium_count} L:${low_count} | Coverage:${coverage_percentage}%`)
|
||||
```
|
||||
|
||||
### 6. Next Step Selection
|
||||
|
||||
```javascript
|
||||
const autoYes = $ARGUMENTS.includes('--yes') || $ARGUMENTS.includes('-y')
|
||||
const canExecute = recommendation !== 'BLOCK_EXECUTION'
|
||||
|
||||
// Auto mode
|
||||
if (autoYes) {
|
||||
if (canExecute) {
|
||||
Skill(skill="workflow:execute", args="--yes --resume-session=\"${session_id}\"")
|
||||
} else {
|
||||
console.log(`[--yes] BLOCK_EXECUTION - Fix ${critical_count} critical issues first.`)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// Interactive mode - build options based on quality gate
|
||||
const options = canExecute
|
||||
? [
|
||||
{ label: canExecute && recommendation === 'PROCEED_WITH_FIXES' ? "Execute Anyway" : "Execute (Recommended)",
|
||||
description: "Proceed to /workflow:execute" },
|
||||
{ label: "Review Report", description: "Review findings before deciding" },
|
||||
{ label: "Re-verify", description: "Re-run after manual fixes" }
|
||||
]
|
||||
: [
|
||||
{ label: "Review Report", description: "Review critical issues" },
|
||||
{ label: "Re-verify", description: "Re-run after fixing issues" }
|
||||
]
|
||||
|
||||
const selection = AskUserQuestion({
|
||||
questions: [{
|
||||
question: `Quality gate: ${recommendation}. Next step?`,
|
||||
header: "Action",
|
||||
multiSelect: false,
|
||||
options
|
||||
}]
|
||||
})
|
||||
|
||||
// Handle selection
|
||||
if (selection.includes("Execute")) {
|
||||
Skill(skill="workflow:execute", args="--resume-session=\"${session_id}\"")
|
||||
} else if (selection === "Re-verify") {
|
||||
Skill(skill="workflow:plan-verify", args="--session ${session_id}")
|
||||
}
|
||||
```
|
||||
@@ -1,15 +1,20 @@
|
||||
---
|
||||
name: plan
|
||||
description: 5-phase planning workflow with action-planning-agent task generation, outputs IMPL_PLAN.md and task JSONs
|
||||
argument-hint: "\"text description\"|file.md"
|
||||
allowed-tools: SlashCommand(*), TodoWrite(*), Read(*), Bash(*)
|
||||
argument-hint: "[-y|--yes] \"text description\"|file.md"
|
||||
allowed-tools: Skill(*), TodoWrite(*), Read(*), Bash(*)
|
||||
group: workflow
|
||||
---
|
||||
|
||||
## Auto Mode
|
||||
|
||||
When `--yes` or `-y`: Auto-continue all phases (skip confirmations), use recommended conflict resolutions.
|
||||
|
||||
# Workflow Plan Command (/workflow:plan)
|
||||
|
||||
## Coordinator Role
|
||||
|
||||
**This command is a pure orchestrator**: Dispatch 5 slash commands in sequence (including a quality gate), parse their outputs, pass context between them, and ensure complete execution through **automatic continuation**.
|
||||
**This command is a pure orchestrator**: Execute 5 slash commands in sequence (including a quality gate), parse their outputs, pass context between them, and ensure complete execution through **automatic continuation**.
|
||||
|
||||
**Execution Model - Auto-Continue Workflow with Quality Gate**:
|
||||
|
||||
@@ -17,14 +22,14 @@ This workflow runs **fully autonomously** once triggered. Phase 3 (conflict reso
|
||||
|
||||
|
||||
1. **User triggers**: `/workflow:plan "task"`
|
||||
2. **Phase 1 dispatches** → Session discovery → Auto-continues
|
||||
3. **Phase 2 dispatches** → Context gathering → Auto-continues
|
||||
4. **Phase 3 dispatches** (optional, if conflict_risk ≥ medium) → Conflict resolution → Auto-continues
|
||||
5. **Phase 4 dispatches** → Task generation (task-generate-agent) → Reports final summary
|
||||
2. **Phase 1 executes** → Session discovery → Auto-continues
|
||||
3. **Phase 2 executes** → Context gathering → Auto-continues
|
||||
4. **Phase 3 executes** (optional, if conflict_risk ≥ medium) → Conflict resolution → Auto-continues
|
||||
5. **Phase 4 executes** → Task generation (task-generate-agent) → Reports final summary
|
||||
|
||||
**Task Attachment Model**:
|
||||
- SlashCommand dispatch **expands workflow** by attaching sub-tasks to current TodoWrite
|
||||
- When a sub-command is dispatched (e.g., `/workflow:tools:context-gather`), its internal tasks are attached to the orchestrator's TodoWrite
|
||||
- Skill execute **expands workflow** by attaching sub-tasks to current TodoWrite
|
||||
- When a sub-command is executed (e.g., `/workflow:tools:context-gather`), its internal tasks are attached to the orchestrator's TodoWrite
|
||||
- Orchestrator **executes these attached tasks** sequentially
|
||||
- After completion, attached tasks are **collapsed** back to high-level phase summary
|
||||
- This is **task expansion**, not external delegation
|
||||
@@ -43,7 +48,7 @@ This workflow runs **fully autonomously** once triggered. Phase 3 (conflict reso
|
||||
3. **Parse Every Output**: Extract required data from each command/agent output for next phase
|
||||
4. **Auto-Continue via TodoList**: Check TodoList status to execute next pending phase automatically
|
||||
5. **Track Progress**: Update TodoWrite dynamically with task attachment/collapse pattern
|
||||
6. **Task Attachment Model**: SlashCommand dispatch **attaches** sub-tasks to current workflow. Orchestrator **executes** these attached tasks itself, then **collapses** them after completion
|
||||
6. **Task Attachment Model**: Skill execute **attaches** sub-tasks to current workflow. Orchestrator **executes** these attached tasks itself, then **collapses** them after completion
|
||||
7. **⚠️ CRITICAL: DO NOT STOP**: Continuous multi-phase workflow. After executing all attached tasks, immediately collapse them and execute next phase
|
||||
|
||||
## Execution Process
|
||||
@@ -80,10 +85,10 @@ Return:
|
||||
|
||||
### Phase 1: Session Discovery
|
||||
|
||||
**Step 1.1: Dispatch** - Create or discover workflow session
|
||||
**Step 1.1: Execute** - Create or discover workflow session
|
||||
|
||||
```javascript
|
||||
SlashCommand(command="/workflow:session:start --auto \"[structured-task-description]\"")
|
||||
Skill(skill="workflow:session:start", args="--auto \"[structured-task-description]\"")
|
||||
```
|
||||
|
||||
**Task Description Structure**:
|
||||
@@ -111,16 +116,60 @@ CONTEXT: Existing user database schema, REST API endpoints
|
||||
|
||||
**TodoWrite**: Mark phase 1 completed, phase 2 in_progress
|
||||
|
||||
**After Phase 1**: Return to user showing Phase 1 results, then auto-continue to Phase 2
|
||||
**After Phase 1**: Initialize planning-notes.md with user intent
|
||||
|
||||
```javascript
|
||||
// Create planning notes document with N+1 context support
|
||||
const planningNotesPath = `.workflow/active/${sessionId}/planning-notes.md`
|
||||
const userGoal = structuredDescription.goal
|
||||
const userConstraints = structuredDescription.context || "None specified"
|
||||
|
||||
Write(planningNotesPath, `# Planning Notes
|
||||
|
||||
**Session**: ${sessionId}
|
||||
**Created**: ${new Date().toISOString()}
|
||||
|
||||
## User Intent (Phase 1)
|
||||
|
||||
- **GOAL**: ${userGoal}
|
||||
- **KEY_CONSTRAINTS**: ${userConstraints}
|
||||
|
||||
---
|
||||
|
||||
## Context Findings (Phase 2)
|
||||
(To be filled by context-gather)
|
||||
|
||||
## Conflict Decisions (Phase 3)
|
||||
(To be filled if conflicts detected)
|
||||
|
||||
## Consolidated Constraints (Phase 4 Input)
|
||||
1. ${userConstraints}
|
||||
|
||||
---
|
||||
|
||||
## Task Generation (Phase 4)
|
||||
(To be filled by action-planning-agent)
|
||||
|
||||
## N+1 Context
|
||||
### Decisions
|
||||
| Decision | Rationale | Revisit? |
|
||||
|----------|-----------|----------|
|
||||
|
||||
### Deferred
|
||||
- [ ] (For N+1)
|
||||
`)
|
||||
```
|
||||
|
||||
Return to user showing Phase 1 results, then auto-continue to Phase 2
|
||||
|
||||
---
|
||||
|
||||
### Phase 2: Context Gathering
|
||||
|
||||
**Step 2.1: Dispatch** - Gather project context and analyze codebase
|
||||
**Step 2.1: Execute** - Gather project context and analyze codebase
|
||||
|
||||
```javascript
|
||||
SlashCommand(command="/workflow:tools:context-gather --session [sessionId] \"[structured-task-description]\"")
|
||||
Skill(skill="workflow:tools:context-gather", args="--session [sessionId] \"[structured-task-description]\"")
|
||||
```
|
||||
|
||||
**Use Same Structured Description**: Pass the same structured format from Phase 1
|
||||
@@ -134,10 +183,11 @@ SlashCommand(command="/workflow:tools:context-gather --session [sessionId] \"[st
|
||||
**Validation**:
|
||||
- Context package path extracted
|
||||
- File exists and is valid JSON
|
||||
- `prioritized_context` field exists
|
||||
|
||||
<!-- TodoWrite: When context-gather dispatched, INSERT 3 context-gather tasks, mark first as in_progress -->
|
||||
<!-- TodoWrite: When context-gather executed, INSERT 3 context-gather tasks, mark first as in_progress -->
|
||||
|
||||
**TodoWrite Update (Phase 2 SlashCommand dispatched - tasks attached)**:
|
||||
**TodoWrite Update (Phase 2 Skill executed - tasks attached)**:
|
||||
```json
|
||||
[
|
||||
{"content": "Phase 1: Session Discovery", "status": "completed", "activeForm": "Executing session discovery"},
|
||||
@@ -149,7 +199,7 @@ SlashCommand(command="/workflow:tools:context-gather --session [sessionId] \"[st
|
||||
]
|
||||
```
|
||||
|
||||
**Note**: SlashCommand dispatch **attaches** context-gather's 3 tasks. Orchestrator **executes** these tasks sequentially.
|
||||
**Note**: Skill execute **attaches** context-gather's 3 tasks. Orchestrator **executes** these tasks sequentially.
|
||||
|
||||
<!-- TodoWrite: After Phase 2 tasks complete, REMOVE Phase 2.1-2.3, restore to orchestrator view -->
|
||||
|
||||
@@ -164,7 +214,37 @@ SlashCommand(command="/workflow:tools:context-gather --session [sessionId] \"[st
|
||||
|
||||
**Note**: Phase 2 tasks completed and collapsed to summary.
|
||||
|
||||
**After Phase 2**: Return to user showing Phase 2 results, then auto-continue to Phase 3/4 (depending on conflict_risk)
|
||||
**After Phase 2**: Update planning-notes.md with context findings, then auto-continue
|
||||
|
||||
```javascript
|
||||
// Read context-package to extract key findings
|
||||
const contextPackage = JSON.parse(Read(contextPath))
|
||||
const conflictRisk = contextPackage.conflict_detection?.risk_level || 'low'
|
||||
const criticalFiles = (contextPackage.exploration_results?.aggregated_insights?.critical_files || [])
|
||||
.slice(0, 5).map(f => f.path)
|
||||
const archPatterns = contextPackage.project_context?.architecture_patterns || []
|
||||
const constraints = contextPackage.exploration_results?.aggregated_insights?.constraints || []
|
||||
|
||||
// Append Phase 2 findings to planning-notes.md
|
||||
Edit(planningNotesPath, {
|
||||
old: '## Context Findings (Phase 2)\n(To be filled by context-gather)',
|
||||
new: `## Context Findings (Phase 2)
|
||||
|
||||
- **CRITICAL_FILES**: ${criticalFiles.join(', ') || 'None identified'}
|
||||
- **ARCHITECTURE**: ${archPatterns.join(', ') || 'Not detected'}
|
||||
- **CONFLICT_RISK**: ${conflictRisk}
|
||||
- **CONSTRAINTS**: ${constraints.length > 0 ? constraints.join('; ') : 'None'}`
|
||||
})
|
||||
|
||||
// Append Phase 2 constraints to consolidated list
|
||||
Edit(planningNotesPath, {
|
||||
old: '## Consolidated Constraints (Phase 4 Input)',
|
||||
new: `## Consolidated Constraints (Phase 4 Input)
|
||||
${constraints.map((c, i) => `${i + 2}. [Context] ${c}`).join('\n')}`
|
||||
})
|
||||
```
|
||||
|
||||
Return to user showing Phase 2 results, then auto-continue to Phase 3/4 (depending on conflict_risk)
|
||||
|
||||
---
|
||||
|
||||
@@ -172,10 +252,10 @@ SlashCommand(command="/workflow:tools:context-gather --session [sessionId] \"[st
|
||||
|
||||
**Trigger**: Only execute when context-package.json indicates conflict_risk is "medium" or "high"
|
||||
|
||||
**Step 3.1: Dispatch** - Detect and resolve conflicts with CLI analysis
|
||||
**Step 3.1: Execute** - Detect and resolve conflicts with CLI analysis
|
||||
|
||||
```javascript
|
||||
SlashCommand(command="/workflow:tools:conflict-resolution --session [sessionId] --context [contextPath]")
|
||||
Skill(skill="workflow:tools:conflict-resolution", args="--session [sessionId] --context [contextPath]")
|
||||
```
|
||||
|
||||
**Input**:
|
||||
@@ -196,7 +276,7 @@ SlashCommand(command="/workflow:tools:conflict-resolution --session [sessionId]
|
||||
|
||||
<!-- TodoWrite: If conflict_risk ≥ medium, INSERT 3 conflict-resolution tasks -->
|
||||
|
||||
**TodoWrite Update (Phase 3 SlashCommand dispatched - tasks attached, if conflict_risk ≥ medium)**:
|
||||
**TodoWrite Update (Phase 3 Skill executed - tasks attached, if conflict_risk ≥ medium)**:
|
||||
```json
|
||||
[
|
||||
{"content": "Phase 1: Session Discovery", "status": "completed", "activeForm": "Executing session discovery"},
|
||||
@@ -209,7 +289,7 @@ SlashCommand(command="/workflow:tools:conflict-resolution --session [sessionId]
|
||||
]
|
||||
```
|
||||
|
||||
**Note**: SlashCommand dispatch **attaches** conflict-resolution's 3 tasks. Orchestrator **executes** these tasks sequentially.
|
||||
**Note**: Skill execute **attaches** conflict-resolution's 3 tasks. Orchestrator **executes** these tasks sequentially.
|
||||
|
||||
<!-- TodoWrite: After Phase 3 tasks complete, REMOVE Phase 3.1-3.3, restore to orchestrator view -->
|
||||
|
||||
@@ -225,16 +305,54 @@ SlashCommand(command="/workflow:tools:conflict-resolution --session [sessionId]
|
||||
|
||||
**Note**: Phase 3 tasks completed and collapsed to summary.
|
||||
|
||||
**After Phase 3**: Return to user showing conflict resolution results (if executed) and selected strategies, then auto-continue to Phase 3.5
|
||||
**After Phase 3**: Update planning-notes.md with conflict decisions (if executed), then auto-continue
|
||||
|
||||
```javascript
|
||||
// If Phase 3 was executed, update planning-notes.md
|
||||
if (conflictRisk >= 'medium') {
|
||||
const conflictResPath = `.workflow/active/${sessionId}/.process/conflict-resolution.json`
|
||||
|
||||
if (fs.existsSync(conflictResPath)) {
|
||||
const conflictRes = JSON.parse(Read(conflictResPath))
|
||||
const resolved = conflictRes.resolved_conflicts || []
|
||||
const modifiedArtifacts = conflictRes.modified_artifacts || []
|
||||
const planningConstraints = conflictRes.planning_constraints || []
|
||||
|
||||
// Update Phase 3 section
|
||||
Edit(planningNotesPath, {
|
||||
old: '## Conflict Decisions (Phase 3)\n(To be filled if conflicts detected)',
|
||||
new: `## Conflict Decisions (Phase 3)
|
||||
|
||||
- **RESOLVED**: ${resolved.map(r => `${r.type} → ${r.strategy}`).join('; ') || 'None'}
|
||||
- **MODIFIED_ARTIFACTS**: ${modifiedArtifacts.join(', ') || 'None'}
|
||||
- **CONSTRAINTS**: ${planningConstraints.join('; ') || 'None'}`
|
||||
})
|
||||
|
||||
// Append Phase 3 constraints to consolidated list
|
||||
if (planningConstraints.length > 0) {
|
||||
const currentNotes = Read(planningNotesPath)
|
||||
const constraintCount = (currentNotes.match(/^\d+\./gm) || []).length
|
||||
|
||||
Edit(planningNotesPath, {
|
||||
old: '## Consolidated Constraints (Phase 4 Input)',
|
||||
new: `## Consolidated Constraints (Phase 4 Input)
|
||||
${planningConstraints.map((c, i) => `${constraintCount + i + 1}. [Conflict] ${c}`).join('\n')}`
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Return to user showing conflict resolution results (if executed) and selected strategies, then auto-continue to Phase 3.5
|
||||
|
||||
**Memory State Check**:
|
||||
- Evaluate current context window usage and memory state
|
||||
- If memory usage is high (>120K tokens or approaching context limits):
|
||||
|
||||
**Step 3.2: Dispatch** - Optimize memory before proceeding
|
||||
**Step 3.2: Execute** - Optimize memory before proceeding
|
||||
|
||||
```javascript
|
||||
SlashCommand(command="/compact")
|
||||
Skill(skill="compact")
|
||||
```
|
||||
|
||||
- Memory compaction is particularly important after analysis phase which may generate extensive documentation
|
||||
@@ -270,24 +388,29 @@ SlashCommand(command="/workflow:tools:conflict-resolution --session [sessionId]
|
||||
- Task generation translates high-level role analyses into concrete, actionable work items
|
||||
- **Intent priority**: Current user prompt > role analysis.md files > guidance-specification.md
|
||||
|
||||
**Step 4.1: Dispatch** - Generate implementation plan and task JSONs
|
||||
**Step 4.1: Execute** - Generate implementation plan and task JSONs
|
||||
|
||||
```javascript
|
||||
SlashCommand(command="/workflow:tools:task-generate-agent --session [sessionId]")
|
||||
Skill(skill="workflow:tools:task-generate-agent", args="--session [sessionId]")
|
||||
```
|
||||
|
||||
**CLI Execution Note**: CLI tool usage is now determined semantically by action-planning-agent based on user's task description. If user specifies "use Codex/Gemini/Qwen for X", the agent embeds `command` fields in relevant `implementation_approach` steps.
|
||||
|
||||
**Input**: `sessionId` from Phase 1
|
||||
**Input**:
|
||||
- `sessionId` from Phase 1
|
||||
- **planning-notes.md**: Consolidated constraints from all phases (Phase 1-3)
|
||||
- Path: `.workflow/active/[sessionId]/planning-notes.md`
|
||||
- Contains: User intent, context findings, conflict decisions, consolidated constraints
|
||||
- **Purpose**: Provides structured, minimal context summary to action-planning-agent
|
||||
|
||||
**Validation**:
|
||||
- `.workflow/active/[sessionId]/IMPL_PLAN.md` exists
|
||||
- `.workflow/active/[sessionId]/.task/IMPL-*.json` exists (at least one)
|
||||
- `.workflow/active/[sessionId]/TODO_LIST.md` exists
|
||||
|
||||
<!-- TodoWrite: When task-generate-agent dispatched, ATTACH 1 agent task -->
|
||||
<!-- TodoWrite: When task-generate-agent executed, ATTACH 1 agent task -->
|
||||
|
||||
**TodoWrite Update (Phase 4 SlashCommand dispatched - agent task attached)**:
|
||||
**TodoWrite Update (Phase 4 Skill executed - agent task attached)**:
|
||||
```json
|
||||
[
|
||||
{"content": "Phase 1: Session Discovery", "status": "completed", "activeForm": "Executing session discovery"},
|
||||
@@ -311,27 +434,62 @@ SlashCommand(command="/workflow:tools:task-generate-agent --session [sessionId]"
|
||||
|
||||
**Note**: Agent task completed. No collapse needed (single task).
|
||||
|
||||
**Return to User**:
|
||||
```
|
||||
Planning complete for session: [sessionId]
|
||||
Tasks generated: [count]
|
||||
Plan: .workflow/active/[sessionId]/IMPL_PLAN.md
|
||||
**Step 4.2: User Decision** - Choose next action
|
||||
|
||||
Recommended Next Steps:
|
||||
1. /workflow:action-plan-verify --session [sessionId] # Verify plan quality before execution
|
||||
2. /workflow:status # Review task breakdown
|
||||
3. /workflow:execute # Start implementation (after verification)
|
||||
After Phase 4 completes, present user with action choices:
|
||||
|
||||
Quality Gate: Consider running /workflow:action-plan-verify to catch issues early
|
||||
```javascript
|
||||
console.log(`
|
||||
✅ Planning complete for session: ${sessionId}
|
||||
📊 Tasks generated: ${taskCount}
|
||||
📋 Plan: .workflow/active/${sessionId}/IMPL_PLAN.md
|
||||
`);
|
||||
|
||||
// Ask user for next action
|
||||
const userChoice = AskUserQuestion({
|
||||
questions: [{
|
||||
question: "Planning complete. What would you like to do next?",
|
||||
header: "Next Action",
|
||||
multiSelect: false,
|
||||
options: [
|
||||
{
|
||||
label: "Verify Plan Quality (Recommended)",
|
||||
description: "Run quality verification to catch issues before execution. Checks plan structure, task dependencies, and completeness."
|
||||
},
|
||||
{
|
||||
label: "Start Execution",
|
||||
description: "Begin implementing tasks immediately. Use this if you've already reviewed the plan or want to start quickly."
|
||||
},
|
||||
{
|
||||
label: "Review Status Only",
|
||||
description: "View task breakdown and session status without taking further action. You can decide what to do next manually."
|
||||
}
|
||||
]
|
||||
}]
|
||||
});
|
||||
|
||||
// Execute based on user choice
|
||||
if (userChoice.answers["Next Action"] === "Verify Plan Quality (Recommended)") {
|
||||
console.log("\n🔍 Starting plan verification...\n");
|
||||
Skill(skill="workflow:plan-verify", args="--session " + sessionId);
|
||||
} else if (userChoice.answers["Next Action"] === "Start Execution") {
|
||||
console.log("\n🚀 Starting task execution...\n");
|
||||
Skill(skill="workflow:execute", args="--session " + sessionId);
|
||||
} else if (userChoice.answers["Next Action"] === "Review Status Only") {
|
||||
console.log("\n📊 Displaying session status...\n");
|
||||
Skill(skill="workflow:status", args="--session " + sessionId);
|
||||
}
|
||||
```
|
||||
|
||||
**Return to User**: Based on user's choice, execute the corresponding workflow command.
|
||||
|
||||
## TodoWrite Pattern
|
||||
|
||||
**Core Concept**: Dynamic task attachment and collapse for real-time visibility into workflow execution.
|
||||
|
||||
### Key Principles
|
||||
|
||||
1. **Task Attachment** (when SlashCommand dispatched):
|
||||
1. **Task Attachment** (when Skill executed):
|
||||
- Sub-command's internal tasks are **attached** to orchestrator's TodoWrite
|
||||
- **Phase 2, 3**: Multiple sub-tasks attached (e.g., Phase 2.1, 2.2, 2.3)
|
||||
- **Phase 4**: Single agent task attached (e.g., "Execute task-generate-agent")
|
||||
@@ -350,7 +508,7 @@ Quality Gate: Consider running /workflow:action-plan-verify to catch issues earl
|
||||
- No user intervention required between phases
|
||||
- TodoWrite dynamically reflects current execution state
|
||||
|
||||
**Lifecycle Summary**: Initial pending tasks → Phase dispatched (tasks ATTACHED) → Sub-tasks executed sequentially → Phase completed (tasks COLLAPSED to summary for Phase 2/3, or marked completed for Phase 4) → Next phase begins → Repeat until all phases complete.
|
||||
**Lifecycle Summary**: Initial pending tasks → Phase executed (tasks ATTACHED) → Sub-tasks executed sequentially → Phase completed (tasks COLLAPSED to summary for Phase 2/3, or marked completed for Phase 4) → Next phase begins → Repeat until all phases complete.
|
||||
|
||||
|
||||
|
||||
@@ -400,26 +558,21 @@ User Input (task description)
|
||||
↓
|
||||
Phase 1: session:start --auto "structured-description"
|
||||
↓ Output: sessionId
|
||||
↓ Session Memory: Previous tasks, context, artifacts
|
||||
↓ Write: planning-notes.md (User Intent section)
|
||||
↓
|
||||
Phase 2: context-gather --session sessionId "structured-description"
|
||||
↓ Input: sessionId + session memory + structured description
|
||||
↓ Output: contextPath (context-package.json) + conflict_risk
|
||||
↓ Input: sessionId + structured description
|
||||
↓ Output: contextPath (context-package.json with prioritized_context) + conflict_risk
|
||||
↓ Update: planning-notes.md (Context Findings + Consolidated Constraints)
|
||||
↓
|
||||
Phase 3: conflict-resolution [AUTO-TRIGGERED if conflict_risk ≥ medium]
|
||||
↓ Input: sessionId + contextPath + conflict_risk
|
||||
↓ CLI-powered conflict detection (JSON output)
|
||||
↓ AskUserQuestion: Present conflicts + resolution strategies
|
||||
↓ User selects strategies (or skip)
|
||||
↓ Apply modifications via Edit tool:
|
||||
↓ - Update guidance-specification.md
|
||||
↓ - Update role analyses (*.md)
|
||||
↓ - Mark context-package.json as "resolved"
|
||||
↓ Output: Modified brainstorm artifacts (NO report file)
|
||||
↓ Output: Modified brainstorm artifacts
|
||||
↓ Update: planning-notes.md (Conflict Decisions + Consolidated Constraints)
|
||||
↓ Skip if conflict_risk is none/low → proceed directly to Phase 4
|
||||
↓
|
||||
Phase 4: task-generate-agent --session sessionId
|
||||
↓ Input: sessionId + resolved brainstorm artifacts + session memory
|
||||
↓ Input: sessionId + planning-notes.md + context-package.json + brainstorm artifacts
|
||||
↓ Output: IMPL_PLAN.md, task JSONs, TODO_LIST.md
|
||||
↓
|
||||
Return summary to user
|
||||
@@ -442,7 +595,7 @@ User triggers: /workflow:plan "Build authentication system"
|
||||
Phase 1: Session Discovery
|
||||
→ sessionId extracted
|
||||
↓
|
||||
Phase 2: Context Gathering (SlashCommand dispatched)
|
||||
Phase 2: Context Gathering (Skill executed)
|
||||
→ ATTACH 3 sub-tasks: ← ATTACHED
|
||||
- → Analyze codebase structure
|
||||
- → Identify integration points
|
||||
@@ -453,7 +606,7 @@ Phase 2: Context Gathering (SlashCommand dispatched)
|
||||
↓
|
||||
Conditional Branch: Check conflict_risk
|
||||
├─ IF conflict_risk ≥ medium:
|
||||
│ Phase 3: Conflict Resolution (SlashCommand dispatched)
|
||||
│ Phase 3: Conflict Resolution (Skill executed)
|
||||
│ → ATTACH 3 sub-tasks: ← ATTACHED
|
||||
│ - → Detect conflicts with CLI analysis
|
||||
│ - → Present conflicts to user
|
||||
@@ -463,7 +616,7 @@ Conditional Branch: Check conflict_risk
|
||||
│
|
||||
└─ ELSE: Skip Phase 3, proceed to Phase 4
|
||||
↓
|
||||
Phase 4: Task Generation (SlashCommand dispatched)
|
||||
Phase 4: Task Generation (Skill executed)
|
||||
→ Single agent task (no sub-tasks)
|
||||
→ Agent autonomously completes internally:
|
||||
(discovery → planning → output)
|
||||
@@ -473,12 +626,12 @@ Return summary to user
|
||||
```
|
||||
|
||||
**Key Points**:
|
||||
- **← ATTACHED**: Tasks attached to TodoWrite when SlashCommand dispatched
|
||||
- **← ATTACHED**: Tasks attached to TodoWrite when Skill executed
|
||||
- Phase 2, 3: Multiple sub-tasks
|
||||
- Phase 4: Single agent task
|
||||
- **← COLLAPSED**: Sub-tasks collapsed to summary after completion (Phase 2, 3 only)
|
||||
- **Phase 4**: Single agent task, no collapse (just mark completed)
|
||||
- **Conditional Branch**: Phase 3 only dispatches if conflict_risk ≥ medium
|
||||
- **Conditional Branch**: Phase 3 only executes if conflict_risk ≥ medium
|
||||
- **Continuous Flow**: No user intervention between phases
|
||||
|
||||
## Error Handling
|
||||
@@ -546,6 +699,6 @@ CONSTRAINTS: [Limitations or boundaries]
|
||||
- `/workflow:tools:task-generate-agent` - Phase 4: Generate task JSON files with agent-driven approach
|
||||
|
||||
**Follow-up Commands**:
|
||||
- `/workflow:action-plan-verify` - Recommended: Verify plan quality and catch issues before execution
|
||||
- `/workflow:plan-verify` - Recommended: Verify plan quality and catch issues before execution
|
||||
- `/workflow:status` - Review task breakdown and current progress
|
||||
- `/workflow:execute` - Begin implementation of generated tasks
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
---
|
||||
name: replan
|
||||
description: Interactive workflow replanning with session-level artifact updates and boundary clarification through guided questioning
|
||||
argument-hint: "[--session session-id] [task-id] \"requirements\"|file.md [--interactive]"
|
||||
argument-hint: "[-y|--yes] [--session session-id] [task-id] \"requirements\"|file.md [--interactive]"
|
||||
allowed-tools: Read(*), Write(*), Edit(*), TodoWrite(*), Glob(*), Bash(*)
|
||||
---
|
||||
|
||||
@@ -113,7 +113,59 @@ const taskId = taskIdMatch?.[1]
|
||||
- List existing tasks
|
||||
- Read `IMPL_PLAN.md` and `TODO_LIST.md`
|
||||
|
||||
**Output**: Session validated, context loaded, mode determined
|
||||
4. **Parse Execution Intent** (from requirements text):
|
||||
```javascript
|
||||
// Dynamic tool detection from cli-tools.json
|
||||
// Read enabled tools: ["gemini", "qwen", "codex", ...]
|
||||
const enabledTools = loadEnabledToolsFromConfig(); // See ~/.claude/cli-tools.json
|
||||
|
||||
// Build dynamic patterns from enabled tools
|
||||
function buildExecPatterns(tools) {
|
||||
const patterns = {
|
||||
agent: /改为\s*Agent\s*执行|使用\s*Agent\s*执行/i
|
||||
};
|
||||
tools.forEach(tool => {
|
||||
// Pattern: "使用 {tool} 执行" or "改用 {tool}"
|
||||
patterns[`cli_${tool}`] = new RegExp(
|
||||
`使用\\s*(${tool})\\s*执行|改用\\s*(${tool})`, 'i'
|
||||
);
|
||||
});
|
||||
return patterns;
|
||||
}
|
||||
|
||||
const execPatterns = buildExecPatterns(enabledTools);
|
||||
|
||||
let executionIntent = null
|
||||
for (const [key, pattern] of Object.entries(execPatterns)) {
|
||||
if (pattern.test(requirements)) {
|
||||
executionIntent = key.startsWith('cli_')
|
||||
? { method: 'cli', cli_tool: key.replace('cli_', '') }
|
||||
: { method: 'agent', cli_tool: null }
|
||||
break
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
**Output**: Session validated, context loaded, mode determined, **executionIntent parsed**
|
||||
|
||||
---
|
||||
|
||||
### Auto Mode Support
|
||||
|
||||
When `--yes` or `-y` flag is used, the command skips interactive clarification and uses safe defaults:
|
||||
|
||||
```javascript
|
||||
const autoYes = $ARGUMENTS.includes('--yes') || $ARGUMENTS.includes('-y')
|
||||
```
|
||||
|
||||
**Auto Mode Defaults**:
|
||||
- **Modification Scope**: `tasks_only` (safest - only update task details)
|
||||
- **Affected Modules**: All modules related to the task
|
||||
- **Task Changes**: `update_only` (no structural changes)
|
||||
- **Dependency Changes**: `no` (preserve existing dependencies)
|
||||
- **User Confirmation**: Auto-confirm execution
|
||||
|
||||
**Note**: `--interactive` flag overrides `--yes` flag (forces interactive mode).
|
||||
|
||||
---
|
||||
|
||||
@@ -121,6 +173,25 @@ const taskId = taskIdMatch?.[1]
|
||||
|
||||
**Purpose**: Define modification scope through guided questioning
|
||||
|
||||
**Auto Mode Check**:
|
||||
```javascript
|
||||
if (autoYes && !interactive) {
|
||||
// Use defaults and skip to Phase 3
|
||||
console.log(`[--yes] Using safe defaults for replan:`)
|
||||
console.log(` - Scope: tasks_only`)
|
||||
console.log(` - Changes: update_only`)
|
||||
console.log(` - Dependencies: preserve existing`)
|
||||
|
||||
userSelections = {
|
||||
scope: 'tasks_only',
|
||||
modules: 'all_affected',
|
||||
task_changes: 'update_only',
|
||||
dependency_changes: false
|
||||
}
|
||||
// Proceed to Phase 3
|
||||
}
|
||||
```
|
||||
|
||||
#### Session Mode Questions
|
||||
|
||||
**Q1: Modification Scope**
|
||||
@@ -228,10 +299,29 @@ interface ImpactAnalysis {
|
||||
**Step 3.3: User Confirmation**
|
||||
|
||||
```javascript
|
||||
Options:
|
||||
- 确认执行: 开始应用所有修改
|
||||
- 调整计划: 重新回答问题调整范围
|
||||
- 取消操作: 放弃本次重规划
|
||||
// Parse --yes flag
|
||||
const autoYes = $ARGUMENTS.includes('--yes') || $ARGUMENTS.includes('-y')
|
||||
|
||||
if (autoYes) {
|
||||
// Auto mode: Auto-confirm execution
|
||||
console.log(`[--yes] Auto-confirming replan execution`)
|
||||
userConfirmation = '确认执行'
|
||||
// Proceed to Phase 4
|
||||
} else {
|
||||
// Interactive mode: Ask user
|
||||
AskUserQuestion({
|
||||
questions: [{
|
||||
question: "修改计划已生成,请确认操作:",
|
||||
header: "Confirm",
|
||||
options: [
|
||||
{ label: "确认执行", description: "开始应用所有修改" },
|
||||
{ label: "调整计划", description: "重新回答问题调整范围" },
|
||||
{ label: "取消操作", description: "放弃本次重规划" }
|
||||
],
|
||||
multiSelect: false
|
||||
}]
|
||||
})
|
||||
}
|
||||
```
|
||||
|
||||
**Output**: Modification plan confirmed or adjusted
|
||||
@@ -299,7 +389,18 @@ const updated_task = {
|
||||
flow_control: {
|
||||
...task.flow_control,
|
||||
implementation_approach: [...updated_steps]
|
||||
}
|
||||
},
|
||||
// Update execution config if intent detected
|
||||
...(executionIntent && {
|
||||
meta: {
|
||||
...task.meta,
|
||||
execution_config: {
|
||||
method: executionIntent.method,
|
||||
cli_tool: executionIntent.cli_tool,
|
||||
enable_resume: executionIntent.method !== 'agent'
|
||||
}
|
||||
}
|
||||
})
|
||||
};
|
||||
|
||||
Write({
|
||||
@@ -308,6 +409,8 @@ Write({
|
||||
});
|
||||
```
|
||||
|
||||
**Note**: Implementation approach steps are NO LONGER modified. CLI execution is controlled by task-level `meta.execution_config` only.
|
||||
|
||||
**Step 5.4: Create New Tasks** (if needed)
|
||||
|
||||
Generate complete task JSON with all required fields:
|
||||
@@ -513,3 +616,33 @@ A: 是,需要同步更新依赖任务
|
||||
|
||||
任务重规划完成! 更新 2 个任务
|
||||
```
|
||||
|
||||
### Task Replan - Change Execution Method
|
||||
|
||||
```bash
|
||||
/workflow:replan IMPL-001 "改用 Codex 执行"
|
||||
|
||||
# Semantic parsing detects executionIntent:
|
||||
# { method: 'cli', cli_tool: 'codex' }
|
||||
|
||||
# Execution (no interactive questions needed)
|
||||
✓ 创建备份
|
||||
✓ 更新 IMPL-001.json
|
||||
- meta.execution_config = { method: 'cli', cli_tool: 'codex', enable_resume: true }
|
||||
|
||||
任务执行方式已更新: Agent → CLI (codex)
|
||||
```
|
||||
|
||||
```bash
|
||||
/workflow:replan IMPL-002 "改为 Agent 执行"
|
||||
|
||||
# Semantic parsing detects executionIntent:
|
||||
# { method: 'agent', cli_tool: null }
|
||||
|
||||
# Execution
|
||||
✓ 创建备份
|
||||
✓ 更新 IMPL-002.json
|
||||
- meta.execution_config = { method: 'agent', cli_tool: null }
|
||||
|
||||
任务执行方式已更新: CLI → Agent
|
||||
```
|
||||
|
||||
765
.claude/commands/workflow/review-cycle-fix.md
Normal file
765
.claude/commands/workflow/review-cycle-fix.md
Normal file
@@ -0,0 +1,765 @@
|
||||
---
|
||||
name: review-cycle-fix
|
||||
description: Automated fixing of code review findings with AI-powered planning and coordinated execution. Uses intelligent grouping, multi-stage timeline coordination, and test-driven verification.
|
||||
argument-hint: "<export-file|review-dir> [--resume] [--max-iterations=N] [--batch-size=N]"
|
||||
allowed-tools: Skill(*), TodoWrite(*), Read(*), Bash(*), Task(*), Edit(*), Write(*)
|
||||
---
|
||||
|
||||
# Workflow Review-Cycle-Fix Command
|
||||
|
||||
## Quick Start
|
||||
|
||||
```bash
|
||||
# Fix from exported findings file (session-based path)
|
||||
/workflow:review-cycle-fix .workflow/active/WFS-123/.review/fix-export-1706184622000.json
|
||||
|
||||
# Fix from review directory (auto-discovers latest export)
|
||||
/workflow:review-cycle-fix .workflow/active/WFS-123/.review/
|
||||
|
||||
# Resume interrupted fix session
|
||||
/workflow:review-cycle-fix --resume
|
||||
|
||||
# Custom max retry attempts per finding
|
||||
/workflow:review-cycle-fix .workflow/active/WFS-123/.review/ --max-iterations=5
|
||||
|
||||
# Custom batch size for parallel planning (default: 5 findings per batch)
|
||||
/workflow:review-cycle-fix .workflow/active/WFS-123/.review/ --batch-size=3
|
||||
```
|
||||
|
||||
**Fix Source**: Exported findings from review cycle dashboard
|
||||
**Output Directory**: `{review-dir}/fixes/{fix-session-id}/` (within session .review/)
|
||||
**Default Max Iterations**: 3 (per finding, adjustable)
|
||||
**Default Batch Size**: 5 (findings per planning batch, adjustable)
|
||||
**Max Parallel Agents**: 10 (concurrent planning agents)
|
||||
**CLI Tools**: @cli-planning-agent (planning), @cli-execute-agent (fixing)
|
||||
|
||||
## What & Why
|
||||
|
||||
### Core Concept
|
||||
Automated fix orchestrator with **parallel planning architecture**: Multiple AI agents analyze findings concurrently in batches, then coordinate parallel/serial execution. Generates fix timeline with intelligent grouping and dependency analysis, executes fixes with conservative test verification.
|
||||
|
||||
**Fix Process**:
|
||||
- **Batching Phase (1.5)**: Orchestrator groups findings by file+dimension similarity, creates batches
|
||||
- **Planning Phase (2)**: Up to 10 agents plan batches in parallel, generate partial plans, orchestrator aggregates
|
||||
- **Execution Phase (3)**: Main orchestrator coordinates agents per aggregated timeline stages
|
||||
- **Parallel Efficiency**: Customizable batch size (default: 5), MAX_PARALLEL=10 agents
|
||||
- **No rigid structure**: Adapts to task requirements, not bound to fixed JSON format
|
||||
|
||||
**vs Manual Fixing**:
|
||||
- **Manual**: Developer reviews findings one-by-one, fixes sequentially
|
||||
- **Automated**: AI groups related issues, multiple agents plan in parallel, executes in optimal parallel/serial order with automatic test verification
|
||||
|
||||
### Value Proposition
|
||||
1. **Parallel Planning**: Multiple agents analyze findings concurrently, reducing planning time for large batches (10+ findings)
|
||||
2. **Intelligent Batching**: Semantic similarity grouping ensures related findings are analyzed together
|
||||
3. **Multi-stage Coordination**: Supports complex parallel + serial execution with cross-batch dependency management
|
||||
4. **Conservative Safety**: Mandatory test verification with automatic rollback on failure
|
||||
5. **Resume Support**: Checkpoint-based recovery for interrupted sessions
|
||||
|
||||
### Orchestrator Boundary (CRITICAL)
|
||||
- **ONLY command** for automated review finding fixes
|
||||
- Manages: Intelligent batching (Phase 1.5), parallel planning coordination (launch N agents), plan aggregation, stage-based execution, agent scheduling, progress tracking
|
||||
- Delegates: Batch planning to @cli-planning-agent, fix execution to @cli-execute-agent
|
||||
|
||||
|
||||
### Execution Flow
|
||||
|
||||
```
|
||||
Phase 1: Discovery & Initialization
|
||||
└─ Validate export file, create fix session structure, initialize state files
|
||||
|
||||
Phase 1.5: Intelligent Grouping & Batching
|
||||
├─ Analyze findings metadata (file, dimension, severity)
|
||||
├─ Group by semantic similarity (file proximity + dimension affinity)
|
||||
├─ Create batches respecting --batch-size (default: 5)
|
||||
└─ Output: Finding batches for parallel planning
|
||||
|
||||
Phase 2: Parallel Planning Coordination (@cli-planning-agent × N)
|
||||
├─ Launch MAX_PARALLEL planning agents concurrently (default: 10)
|
||||
├─ Each agent processes one batch:
|
||||
│ ├─ Analyze findings for patterns and dependencies
|
||||
│ ├─ Group by file + dimension + root cause similarity
|
||||
│ ├─ Determine execution strategy (parallel/serial/hybrid)
|
||||
│ ├─ Generate fix timeline with stages
|
||||
│ └─ Output: partial-plan-{batch-id}.json
|
||||
├─ Collect results from all agents
|
||||
└─ Aggregate: Merge partial plans → fix-plan.json (resolve cross-batch dependencies)
|
||||
|
||||
Phase 3: Execution Orchestration (Stage-based)
|
||||
For each timeline stage:
|
||||
├─ Load groups for this stage
|
||||
├─ If parallel: Launch all group agents simultaneously
|
||||
├─ If serial: Execute groups sequentially
|
||||
├─ Each agent:
|
||||
│ ├─ Analyze code context
|
||||
│ ├─ Apply fix per strategy
|
||||
│ ├─ Run affected tests
|
||||
│ ├─ On test failure: Rollback, retry up to max_iterations
|
||||
│ └─ On success: Commit, update fix-progress-{N}.json
|
||||
└─ Advance to next stage
|
||||
|
||||
Phase 4: Completion & Aggregation
|
||||
└─ Aggregate results → Generate fix-summary.md → Update history → Output summary
|
||||
|
||||
Phase 5: Session Completion (Optional)
|
||||
└─ If all fixes successful → Prompt to complete workflow session
|
||||
```
|
||||
|
||||
### Agent Roles
|
||||
|
||||
| Agent | Responsibility |
|
||||
|-------|---------------|
|
||||
| **Orchestrator** | Input validation, session management, intelligent batching (Phase 1.5), parallel planning coordination (launch N agents), plan aggregation (merge partial plans, resolve cross-batch dependencies), stage-based execution scheduling, progress tracking, result aggregation |
|
||||
| **@cli-planning-agent** | Batch findings analysis, intelligent grouping (file+dimension+root cause), execution strategy determination (parallel/serial/hybrid), timeline generation with dependency mapping, partial plan output |
|
||||
| **@cli-execute-agent** | Fix execution per group, code context analysis, Edit tool operations, test verification, git rollback on failure, completion JSON generation |
|
||||
|
||||
## Enhanced Features
|
||||
|
||||
### 1. Parallel Planning Architecture
|
||||
|
||||
**Batch Processing Strategy**:
|
||||
|
||||
| Phase | Agent Count | Input | Output | Purpose |
|
||||
|-------|-------------|-------|--------|---------|
|
||||
| **Batching (1.5)** | Orchestrator | All findings | Finding batches | Semantic grouping by file+dimension, respecting --batch-size |
|
||||
| **Planning (2)** | N agents (≤10) | 1 batch each | partial-plan-{batch-id}.json | Analyze batch in parallel, generate execution groups and timeline |
|
||||
| **Aggregation (2)** | Orchestrator | All partial plans | fix-plan.json | Merge timelines, resolve cross-batch dependencies |
|
||||
| **Execution (3)** | M agents (dynamic) | 1 group each | fix-progress-{N}.json | Execute fixes per aggregated plan with test verification |
|
||||
|
||||
**Benefits**:
|
||||
- **Speed**: N agents plan concurrently, reducing planning time for large batches
|
||||
- **Scalability**: MAX_PARALLEL=10 prevents resource exhaustion
|
||||
- **Flexibility**: Batch size customizable via --batch-size (default: 5)
|
||||
- **Isolation**: Each planning agent focuses on related findings (semantic grouping)
|
||||
- **Reusable**: Aggregated plan can be re-executed without re-planning
|
||||
|
||||
### 2. Intelligent Grouping Strategy
|
||||
|
||||
**Three-Level Grouping**:
|
||||
|
||||
```javascript
|
||||
// Level 1: Primary grouping by file + dimension
|
||||
{file: "auth.ts", dimension: "security"} → Group A
|
||||
{file: "auth.ts", dimension: "quality"} → Group B
|
||||
{file: "query-builder.ts", dimension: "security"} → Group C
|
||||
|
||||
// Level 2: Secondary grouping by root cause similarity
|
||||
Group A findings → Semantic similarity analysis (threshold 0.7)
|
||||
→ Sub-group A1: "missing-input-validation" (findings 1, 2)
|
||||
→ Sub-group A2: "insecure-crypto" (finding 3)
|
||||
|
||||
// Level 3: Dependency analysis
|
||||
Sub-group A1 creates validation utilities
|
||||
Sub-group C4 depends on those utilities
|
||||
→ A1 must execute before C4 (serial stage dependency)
|
||||
```
|
||||
|
||||
**Similarity Computation**:
|
||||
- Combine: `description + recommendation + category`
|
||||
- Vectorize: TF-IDF or LLM embedding
|
||||
- Cluster: Greedy algorithm with cosine similarity > 0.7
|
||||
|
||||
### 3. Execution Strategy Determination
|
||||
|
||||
**Strategy Types**:
|
||||
|
||||
| Strategy | When to Use | Stage Structure |
|
||||
|----------|-------------|-----------------|
|
||||
| **Parallel** | All groups independent, different files | Single stage, all groups in parallel |
|
||||
| **Serial** | Strong dependencies, shared resources | Multiple stages, one group per stage |
|
||||
| **Hybrid** | Mixed dependencies | Multiple stages, parallel within stages |
|
||||
|
||||
**Dependency Detection**:
|
||||
- Shared file modifications
|
||||
- Utility creation + usage patterns
|
||||
- Test dependency chains
|
||||
- Risk level clustering (high-risk groups isolated)
|
||||
|
||||
### 4. Conservative Test Verification
|
||||
|
||||
**Test Strategy** (per fix):
|
||||
|
||||
```javascript
|
||||
// 1. Identify affected tests
|
||||
const testPattern = identifyTestPattern(finding.file);
|
||||
// e.g., "tests/auth/**/*.test.*" for src/auth/service.ts
|
||||
|
||||
// 2. Run tests
|
||||
const result = await runTests(testPattern);
|
||||
|
||||
// 3. Evaluate
|
||||
if (result.passRate < 100%) {
|
||||
// Rollback
|
||||
await gitCheckout(finding.file);
|
||||
|
||||
// Retry with failure context
|
||||
if (attempts < maxIterations) {
|
||||
const fixContext = analyzeFailure(result.stderr);
|
||||
regenerateFix(finding, fixContext);
|
||||
retry();
|
||||
} else {
|
||||
markFailed(finding.id);
|
||||
}
|
||||
} else {
|
||||
// Commit
|
||||
await gitCommit(`Fix: ${finding.title} [${finding.id}]`);
|
||||
markFixed(finding.id);
|
||||
}
|
||||
```
|
||||
|
||||
**Pass Criteria**: 100% test pass rate (no partial fixes)
|
||||
|
||||
## Core Responsibilities
|
||||
|
||||
### Orchestrator
|
||||
|
||||
**Phase 1: Discovery & Initialization**
|
||||
- Input validation: Check export file exists and is valid JSON
|
||||
- Auto-discovery: If review-dir provided, find latest `*-fix-export.json`
|
||||
- Session creation: Generate fix-session-id (`fix-{timestamp}`)
|
||||
- Directory structure: Create `{review-dir}/fixes/{fix-session-id}/` with subdirectories
|
||||
- State files: Initialize active-fix-session.json (session marker)
|
||||
- TodoWrite initialization: Set up 5-phase tracking (including Phase 1.5)
|
||||
|
||||
**Phase 1.5: Intelligent Grouping & Batching**
|
||||
- Load all findings metadata (id, file, dimension, severity, title)
|
||||
- Semantic similarity analysis:
|
||||
- Primary: Group by file proximity (same file or related modules)
|
||||
- Secondary: Group by dimension affinity (same review dimension)
|
||||
- Tertiary: Analyze title/description similarity (root cause clustering)
|
||||
- Create batches respecting --batch-size (default: 5 findings per batch)
|
||||
- Balance workload: Distribute high-severity findings across batches
|
||||
- Output: Array of finding batches for parallel planning
|
||||
|
||||
**Phase 2: Parallel Planning Coordination**
|
||||
- Determine concurrency: MIN(batch_count, MAX_PARALLEL=10)
|
||||
- For each batch chunk (≤10 batches):
|
||||
- Launch all agents in parallel with run_in_background=true
|
||||
- Pass batch findings + project context + batch_id to each agent
|
||||
- Each agent outputs: partial-plan-{batch-id}.json
|
||||
- Collect results via TaskOutput (blocking until all complete)
|
||||
- Aggregate partial plans:
|
||||
- Merge execution groups (renumber group_ids sequentially: G1, G2, ...)
|
||||
- Merge timelines (detect cross-batch dependencies, adjust stages)
|
||||
- Resolve conflicts (same file in multiple batches → serialize)
|
||||
- Generate final fix-plan.json with aggregated metadata
|
||||
- TodoWrite update: Mark planning complete, start execution
|
||||
|
||||
**Phase 3: Execution Orchestration**
|
||||
- Load fix-plan.json timeline stages
|
||||
- For each stage:
|
||||
- If parallel mode: Launch all group agents via `Promise.all()`
|
||||
- If serial mode: Execute groups sequentially with `await`
|
||||
- Assign agent IDs (agents update their fix-progress-{N}.json)
|
||||
- Handle agent failures gracefully (mark group as failed, continue)
|
||||
- Advance to next stage only when current stage complete
|
||||
|
||||
**Phase 4: Completion & Aggregation**
|
||||
- Collect final status from all fix-progress-{N}.json files
|
||||
- Generate fix-summary.md with timeline and results
|
||||
- Update fix-history.json with new session entry
|
||||
- Remove active-fix-session.json
|
||||
- TodoWrite completion: Mark all phases done
|
||||
- Output summary to user
|
||||
|
||||
**Phase 5: Session Completion (Optional)**
|
||||
- If all findings fixed successfully (no failures):
|
||||
- Prompt user: "All fixes complete. Complete workflow session? [Y/n]"
|
||||
- If confirmed: Execute `/workflow:session:complete` to archive session with lessons learned
|
||||
- If partial success (some failures):
|
||||
- Output: "Some findings failed. Review fix-summary.md before completing session."
|
||||
- Do NOT auto-complete session
|
||||
|
||||
### Output File Structure
|
||||
|
||||
```
|
||||
.workflow/active/WFS-{session-id}/.review/
|
||||
├── fix-export-{timestamp}.json # Exported findings (input)
|
||||
└── fixes/{fix-session-id}/
|
||||
├── partial-plan-1.json # Batch 1 partial plan (planning agent 1 output)
|
||||
├── partial-plan-2.json # Batch 2 partial plan (planning agent 2 output)
|
||||
├── partial-plan-N.json # Batch N partial plan (planning agent N output)
|
||||
├── fix-plan.json # Aggregated execution plan (orchestrator merges partials)
|
||||
├── fix-progress-1.json # Group 1 progress (planning agent init → agent updates)
|
||||
├── fix-progress-2.json # Group 2 progress (planning agent init → agent updates)
|
||||
├── fix-progress-3.json # Group 3 progress (planning agent init → agent updates)
|
||||
├── fix-summary.md # Final report (orchestrator generates)
|
||||
├── active-fix-session.json # Active session marker
|
||||
└── fix-history.json # All sessions history
|
||||
```
|
||||
|
||||
**File Producers**:
|
||||
- **Orchestrator**: Batches findings (Phase 1.5), aggregates partial plans → `fix-plan.json` (Phase 2), launches parallel planning agents
|
||||
- **Planning Agents (N)**: Each outputs `partial-plan-{batch-id}.json` + initializes `fix-progress-*.json` for assigned groups
|
||||
- **Execution Agents (M)**: Update assigned `fix-progress-{N}.json` in real-time
|
||||
|
||||
|
||||
### Agent Invocation Template
|
||||
|
||||
**Phase 1.5: Intelligent Batching** (Orchestrator):
|
||||
```javascript
|
||||
// Load findings
|
||||
const findings = JSON.parse(Read(exportFile));
|
||||
const batchSize = flags.batchSize || 5;
|
||||
|
||||
// Semantic similarity analysis: group by file+dimension
|
||||
const batches = [];
|
||||
const grouped = new Map(); // key: "${file}:${dimension}"
|
||||
|
||||
for (const finding of findings) {
|
||||
const key = `${finding.file || 'unknown'}:${finding.dimension || 'general'}`;
|
||||
if (!grouped.has(key)) grouped.set(key, []);
|
||||
grouped.get(key).push(finding);
|
||||
}
|
||||
|
||||
// Create batches respecting batchSize
|
||||
for (const [key, group] of grouped) {
|
||||
while (group.length > 0) {
|
||||
const batch = group.splice(0, batchSize);
|
||||
batches.push({
|
||||
batch_id: batches.length + 1,
|
||||
findings: batch,
|
||||
metadata: { primary_file: batch[0].file, primary_dimension: batch[0].dimension }
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
console.log(`Created ${batches.length} batches (${batchSize} findings per batch)`);
|
||||
```
|
||||
|
||||
**Phase 2: Parallel Planning** (Orchestrator launches N agents):
|
||||
```javascript
|
||||
const MAX_PARALLEL = 10;
|
||||
const partialPlans = [];
|
||||
|
||||
// Process batches in chunks of MAX_PARALLEL
|
||||
for (let i = 0; i < batches.length; i += MAX_PARALLEL) {
|
||||
const chunk = batches.slice(i, i + MAX_PARALLEL);
|
||||
const taskIds = [];
|
||||
|
||||
// Launch agents in parallel (run_in_background=true)
|
||||
for (const batch of chunk) {
|
||||
const taskId = Task({
|
||||
subagent_type: "cli-planning-agent",
|
||||
run_in_background: true,
|
||||
description: `Plan batch ${batch.batch_id}: ${batch.findings.length} findings`,
|
||||
prompt: planningPrompt(batch) // See Planning Agent template below
|
||||
});
|
||||
taskIds.push({ taskId, batch });
|
||||
}
|
||||
|
||||
console.log(`Launched ${taskIds.length} planning agents...`);
|
||||
|
||||
// Collect results from this chunk (blocking)
|
||||
for (const { taskId, batch } of taskIds) {
|
||||
const result = TaskOutput({ task_id: taskId, block: true });
|
||||
const partialPlan = JSON.parse(Read(`${sessionDir}/partial-plan-${batch.batch_id}.json`));
|
||||
partialPlans.push(partialPlan);
|
||||
updateTodo(`Batch ${batch.batch_id}`, 'completed');
|
||||
}
|
||||
}
|
||||
|
||||
// Aggregate partial plans → fix-plan.json
|
||||
let groupCounter = 1;
|
||||
const groupIdMap = new Map();
|
||||
|
||||
for (const partial of partialPlans) {
|
||||
for (const group of partial.groups) {
|
||||
const newGroupId = `G${groupCounter}`;
|
||||
groupIdMap.set(`${partial.batch_id}:${group.group_id}`, newGroupId);
|
||||
aggregatedPlan.groups.push({ ...group, group_id: newGroupId, progress_file: `fix-progress-${groupCounter}.json` });
|
||||
groupCounter++;
|
||||
}
|
||||
}
|
||||
|
||||
// Merge timelines, resolve cross-batch conflicts (shared files → serialize)
|
||||
let stageCounter = 1;
|
||||
for (const partial of partialPlans) {
|
||||
for (const stage of partial.timeline) {
|
||||
aggregatedPlan.timeline.push({
|
||||
...stage, stage_id: stageCounter,
|
||||
groups: stage.groups.map(gid => groupIdMap.get(`${partial.batch_id}:${gid}`))
|
||||
});
|
||||
stageCounter++;
|
||||
}
|
||||
}
|
||||
|
||||
// Write aggregated plan + initialize progress files
|
||||
Write(`${sessionDir}/fix-plan.json`, JSON.stringify(aggregatedPlan, null, 2));
|
||||
for (let i = 1; i <= aggregatedPlan.groups.length; i++) {
|
||||
Write(`${sessionDir}/fix-progress-${i}.json`, JSON.stringify(initProgressFile(aggregatedPlan.groups[i-1]), null, 2));
|
||||
}
|
||||
```
|
||||
|
||||
**Planning Agent (Batch Mode - Partial Plan Only)**:
|
||||
```javascript
|
||||
Task({
|
||||
subagent_type: "cli-planning-agent",
|
||||
run_in_background: true,
|
||||
description: `Plan batch ${batch.batch_id}: ${batch.findings.length} findings`,
|
||||
prompt: `
|
||||
## Task Objective
|
||||
Analyze code review findings in batch ${batch.batch_id} and generate **partial** execution plan.
|
||||
|
||||
## Input Data
|
||||
Review Session: ${reviewId}
|
||||
Fix Session ID: ${fixSessionId}
|
||||
Batch ID: ${batch.batch_id}
|
||||
Batch Findings: ${batch.findings.length}
|
||||
|
||||
Findings:
|
||||
${JSON.stringify(batch.findings, null, 2)}
|
||||
|
||||
Project Context:
|
||||
- Structure: ${projectStructure}
|
||||
- Test Framework: ${testFramework}
|
||||
- Git Status: ${gitStatus}
|
||||
|
||||
## Output Requirements
|
||||
|
||||
### 1. partial-plan-${batch.batch_id}.json
|
||||
Generate partial execution plan with structure:
|
||||
{
|
||||
"batch_id": ${batch.batch_id},
|
||||
"groups": [...], // Groups created from batch findings (use local IDs: G1, G2, ...)
|
||||
"timeline": [...], // Local timeline for this batch only
|
||||
"metadata": {
|
||||
"findings_count": ${batch.findings.length},
|
||||
"groups_count": N,
|
||||
"created_at": "ISO-8601-timestamp"
|
||||
}
|
||||
}
|
||||
|
||||
**Key Generation Rules**:
|
||||
- **Groups**: Create groups with local IDs (G1, G2, ...) using intelligent grouping (file+dimension+root cause)
|
||||
- **Timeline**: Define stages for this batch only (local dependencies within batch)
|
||||
- **Progress Files**: DO NOT generate fix-progress-*.json here (orchestrator handles after aggregation)
|
||||
|
||||
## Analysis Requirements
|
||||
|
||||
### Intelligent Grouping Strategy
|
||||
Group findings using these criteria (in priority order):
|
||||
|
||||
1. **File Proximity**: Findings in same file or related files
|
||||
2. **Dimension Affinity**: Same dimension (security, performance, etc.)
|
||||
3. **Root Cause Similarity**: Similar underlying issues
|
||||
4. **Fix Approach Commonality**: Can be fixed with similar approach
|
||||
|
||||
**Grouping Guidelines**:
|
||||
- Optimal group size: 2-5 findings per group
|
||||
- Avoid cross-cutting concerns in same group
|
||||
- Consider test isolation (different test suites → different groups)
|
||||
- Balance workload across groups for parallel execution
|
||||
|
||||
### Execution Strategy Determination (Local Only)
|
||||
|
||||
**Parallel Mode**: Use when groups are independent, no shared files
|
||||
**Serial Mode**: Use when groups have dependencies or shared resources
|
||||
**Hybrid Mode**: Use for mixed dependency graphs (recommended for most cases)
|
||||
|
||||
**Dependency Analysis**:
|
||||
- Identify shared files between groups
|
||||
- Detect test dependency chains
|
||||
- Evaluate risk of concurrent modifications
|
||||
|
||||
### Risk Assessment
|
||||
|
||||
For each group, evaluate:
|
||||
- **Complexity**: Based on code structure, file size, existing tests
|
||||
- **Impact Scope**: Number of files affected, API surface changes
|
||||
- **Rollback Feasibility**: Ease of reverting changes if tests fail
|
||||
|
||||
### Test Strategy
|
||||
|
||||
For each group, determine:
|
||||
- **Test Pattern**: Glob pattern matching affected tests
|
||||
- **Pass Criteria**: All tests must pass (100% pass rate)
|
||||
- **Test Command**: Infer from project (package.json, pytest.ini, etc.)
|
||||
|
||||
## Output Files
|
||||
|
||||
Write to ${sessionDir}:
|
||||
- ./partial-plan-${batch.batch_id}.json
|
||||
|
||||
## Quality Checklist
|
||||
|
||||
Before finalizing outputs:
|
||||
- ✅ All batch findings assigned to exactly one group
|
||||
- ✅ Group dependencies (within batch) correctly identified
|
||||
- ✅ Timeline stages respect local dependencies
|
||||
- ✅ Test patterns are valid and specific
|
||||
- ✅ Risk assessments are realistic
|
||||
`
|
||||
})
|
||||
```
|
||||
|
||||
**Execution Agent** (per group):
|
||||
```javascript
|
||||
Task({
|
||||
subagent_type: "cli-execute-agent",
|
||||
description: `Fix ${group.findings.length} issues: ${group.group_name}`,
|
||||
prompt: `
|
||||
## Task Objective
|
||||
Execute fixes for code review findings in group ${group.group_id}. Update progress file in real-time with flow control tracking.
|
||||
|
||||
## Assignment
|
||||
- Group ID: ${group.group_id}
|
||||
- Group Name: ${group.group_name}
|
||||
- Progress File: ${sessionDir}/${group.progress_file}
|
||||
- Findings Count: ${group.findings.length}
|
||||
- Max Iterations: ${maxIterations} (per finding)
|
||||
|
||||
## Fix Strategy
|
||||
${JSON.stringify(group.fix_strategy, null, 2)}
|
||||
|
||||
## Risk Assessment
|
||||
${JSON.stringify(group.risk_assessment, null, 2)}
|
||||
|
||||
## Execution Flow
|
||||
|
||||
### Initialization (Before Starting)
|
||||
|
||||
1. Read ${group.progress_file} to load initial state
|
||||
2. Update progress file:
|
||||
- assigned_agent: "${agentId}"
|
||||
- status: "in-progress"
|
||||
- started_at: Current ISO 8601 timestamp
|
||||
- last_update: Current ISO 8601 timestamp
|
||||
3. Write updated state back to ${group.progress_file}
|
||||
|
||||
### Main Execution Loop
|
||||
|
||||
For EACH finding in ${group.progress_file}.findings:
|
||||
|
||||
#### Step 1: Analyze Context
|
||||
|
||||
**Before Step**:
|
||||
- Update finding: status→"in-progress", started_at→now()
|
||||
- Update current_finding: Populate with finding details, status→"analyzing", action→"Reading file and understanding code structure"
|
||||
- Update phase→"analyzing"
|
||||
- Update flow_control: Add "analyze_context" step to implementation_approach (status→"in-progress"), set current_step→"analyze_context"
|
||||
- Update last_update→now(), write to ${group.progress_file}
|
||||
|
||||
**Action**:
|
||||
- Read file: finding.file
|
||||
- Understand code structure around line: finding.line
|
||||
- Analyze surrounding context (imports, dependencies, related functions)
|
||||
- Review recommendations: finding.recommendations
|
||||
|
||||
**After Step**:
|
||||
- Update flow_control: Mark "analyze_context" step as "completed" with completed_at→now()
|
||||
- Update last_update→now(), write to ${group.progress_file}
|
||||
|
||||
#### Step 2: Apply Fix
|
||||
|
||||
**Before Step**:
|
||||
- Update current_finding: status→"fixing", action→"Applying code changes per recommendations"
|
||||
- Update phase→"fixing"
|
||||
- Update flow_control: Add "apply_fix" step to implementation_approach (status→"in-progress"), set current_step→"apply_fix"
|
||||
- Update last_update→now(), write to ${group.progress_file}
|
||||
|
||||
**Action**:
|
||||
- Use Edit tool to implement code changes per finding.recommendations
|
||||
- Follow fix_strategy.approach
|
||||
- Maintain code style and existing patterns
|
||||
|
||||
**After Step**:
|
||||
- Update flow_control: Mark "apply_fix" step as "completed" with completed_at→now()
|
||||
- Update last_update→now(), write to ${group.progress_file}
|
||||
|
||||
#### Step 3: Test Verification
|
||||
|
||||
**Before Step**:
|
||||
- Update current_finding: status→"testing", action→"Running test suite to verify fix"
|
||||
- Update phase→"testing"
|
||||
- Update flow_control: Add "run_tests" step to implementation_approach (status→"in-progress"), set current_step→"run_tests"
|
||||
- Update last_update→now(), write to ${group.progress_file}
|
||||
|
||||
**Action**:
|
||||
- Run tests using fix_strategy.test_pattern
|
||||
- Require 100% pass rate
|
||||
- Capture test output
|
||||
|
||||
**On Test Failure**:
|
||||
- Git rollback: \`git checkout -- \${finding.file}\`
|
||||
- Increment finding.attempts
|
||||
- Update flow_control: Mark "run_tests" step as "failed" with completed_at→now()
|
||||
- Update errors: Add entry (finding_id, error_type→"test_failure", message, timestamp)
|
||||
- If finding.attempts < ${maxIterations}:
|
||||
- Reset flow_control: implementation_approach→[], current_step→null
|
||||
- Retry from Step 1
|
||||
- Else:
|
||||
- Update finding: status→"completed", result→"failed", error_message→"Max iterations reached", completed_at→now()
|
||||
- Update summary counts, move to next finding
|
||||
|
||||
**On Test Success**:
|
||||
- Update flow_control: Mark "run_tests" step as "completed" with completed_at→now()
|
||||
- Update last_update→now(), write to ${group.progress_file}
|
||||
- Proceed to Step 4
|
||||
|
||||
#### Step 4: Commit Changes
|
||||
|
||||
**Before Step**:
|
||||
- Update current_finding: status→"committing", action→"Creating git commit for successful fix"
|
||||
- Update phase→"committing"
|
||||
- Update flow_control: Add "commit_changes" step to implementation_approach (status→"in-progress"), set current_step→"commit_changes"
|
||||
- Update last_update→now(), write to ${group.progress_file}
|
||||
|
||||
**Action**:
|
||||
- Git commit: \`git commit -m "fix(${finding.dimension}): ${finding.title} [${finding.id}]"\`
|
||||
- Capture commit hash
|
||||
|
||||
**After Step**:
|
||||
- Update finding: status→"completed", result→"fixed", commit_hash→<captured>, test_passed→true, completed_at→now()
|
||||
- Update flow_control: Mark "commit_changes" step as "completed" with completed_at→now()
|
||||
- Update last_update→now(), write to ${group.progress_file}
|
||||
|
||||
#### After Each Finding
|
||||
|
||||
- Update summary: Recalculate counts (pending/in_progress/fixed/failed) and percent_complete
|
||||
- If all findings completed: Clear current_finding, reset flow_control
|
||||
- Update last_update→now(), write to ${group.progress_file}
|
||||
|
||||
### Final Completion
|
||||
|
||||
When all findings processed:
|
||||
- Update status→"completed", phase→"done", summary.percent_complete→100.0
|
||||
- Update last_update→now(), write final state to ${group.progress_file}
|
||||
|
||||
## Critical Requirements
|
||||
|
||||
### Progress File Updates
|
||||
- **MUST update after every significant action** (before/after each step)
|
||||
- **Always maintain complete structure** - never write partial updates
|
||||
- **Use ISO 8601 timestamps** - e.g., "2025-01-25T14:36:00Z"
|
||||
|
||||
### Flow Control Format
|
||||
Follow action-planning-agent flow_control.implementation_approach format:
|
||||
- step: Identifier (e.g., "analyze_context", "apply_fix")
|
||||
- action: Human-readable description
|
||||
- status: "pending" | "in-progress" | "completed" | "failed"
|
||||
- started_at: ISO 8601 timestamp or null
|
||||
- completed_at: ISO 8601 timestamp or null
|
||||
|
||||
### Error Handling
|
||||
- Capture all errors in errors[] array
|
||||
- Never leave progress file in invalid state
|
||||
- Always write complete updates, never partial
|
||||
- On unrecoverable error: Mark group as failed, preserve state
|
||||
|
||||
## Test Patterns
|
||||
Use fix_strategy.test_pattern to run affected tests:
|
||||
- Pattern: ${group.fix_strategy.test_pattern}
|
||||
- Command: Infer from project (npm test, pytest, etc.)
|
||||
- Pass Criteria: 100% pass rate required
|
||||
`
|
||||
})
|
||||
```
|
||||
|
||||
|
||||
|
||||
### Error Handling
|
||||
|
||||
**Batching Failures (Phase 1.5)**:
|
||||
- Invalid findings data → Abort with error message
|
||||
- Empty batches after grouping → Warn and skip empty batches
|
||||
|
||||
**Planning Failures (Phase 2)**:
|
||||
- Planning agent timeout → Mark batch as failed, continue with other batches
|
||||
- Partial plan missing → Skip batch, warn user
|
||||
- Agent crash → Collect available partial plans, proceed with aggregation
|
||||
- All agents fail → Abort entire fix session with error
|
||||
- Aggregation conflicts → Apply conflict resolution (serialize conflicting groups)
|
||||
|
||||
**Execution Failures (Phase 3)**:
|
||||
- Agent crash → Mark group as failed, continue with other groups
|
||||
- Test command not found → Skip test verification, warn user
|
||||
- Git operations fail → Abort with error, preserve state
|
||||
|
||||
**Rollback Scenarios**:
|
||||
- Test failure after fix → Automatic `git checkout` rollback
|
||||
- Max iterations reached → Leave file unchanged, mark as failed
|
||||
- Unrecoverable error → Rollback entire group, save checkpoint
|
||||
|
||||
### TodoWrite Structure
|
||||
|
||||
**Initialization (after Phase 1.5 batching)**:
|
||||
```javascript
|
||||
TodoWrite({
|
||||
todos: [
|
||||
{content: "Phase 1: Discovery & Initialization", status: "completed", activeForm: "Discovering"},
|
||||
{content: "Phase 1.5: Intelligent Batching", status: "completed", activeForm: "Batching"},
|
||||
{content: "Phase 2: Parallel Planning", status: "in_progress", activeForm: "Planning"},
|
||||
{content: " → Batch 1: 4 findings (auth.ts:security)", status: "pending", activeForm: "Planning batch 1"},
|
||||
{content: " → Batch 2: 3 findings (query.ts:security)", status: "pending", activeForm: "Planning batch 2"},
|
||||
{content: " → Batch 3: 2 findings (config.ts:quality)", status: "pending", activeForm: "Planning batch 3"},
|
||||
{content: "Phase 3: Execution", status: "pending", activeForm: "Executing"},
|
||||
{content: "Phase 4: Completion", status: "pending", activeForm: "Completing"}
|
||||
]
|
||||
});
|
||||
```
|
||||
|
||||
**During Planning (parallel agents running)**:
|
||||
```javascript
|
||||
TodoWrite({
|
||||
todos: [
|
||||
{content: "Phase 1: Discovery & Initialization", status: "completed", activeForm: "Discovering"},
|
||||
{content: "Phase 1.5: Intelligent Batching", status: "completed", activeForm: "Batching"},
|
||||
{content: "Phase 2: Parallel Planning", status: "in_progress", activeForm: "Planning"},
|
||||
{content: " → Batch 1: 4 findings (auth.ts:security)", status: "completed", activeForm: "Planning batch 1"},
|
||||
{content: " → Batch 2: 3 findings (query.ts:security)", status: "in_progress", activeForm: "Planning batch 2"},
|
||||
{content: " → Batch 3: 2 findings (config.ts:quality)", status: "in_progress", activeForm: "Planning batch 3"},
|
||||
{content: "Phase 3: Execution", status: "pending", activeForm: "Executing"},
|
||||
{content: "Phase 4: Completion", status: "pending", activeForm: "Completing"}
|
||||
]
|
||||
});
|
||||
```
|
||||
|
||||
**During Execution**:
|
||||
```javascript
|
||||
TodoWrite({
|
||||
todos: [
|
||||
{content: "Phase 1: Discovery & Initialization", status: "completed", activeForm: "Discovering"},
|
||||
{content: "Phase 1.5: Intelligent Batching", status: "completed", activeForm: "Batching"},
|
||||
{content: "Phase 2: Parallel Planning (3 batches → 5 groups)", status: "completed", activeForm: "Planning"},
|
||||
{content: "Phase 3: Execution", status: "in_progress", activeForm: "Executing"},
|
||||
{content: " → Stage 1: Parallel execution (3 groups)", status: "completed", activeForm: "Executing stage 1"},
|
||||
{content: " • Group G1: Auth validation (2 findings)", status: "completed", activeForm: "Fixing G1"},
|
||||
{content: " • Group G2: Query security (3 findings)", status: "completed", activeForm: "Fixing G2"},
|
||||
{content: " • Group G3: Config quality (1 finding)", status: "completed", activeForm: "Fixing G3"},
|
||||
{content: " → Stage 2: Serial execution (1 group)", status: "in_progress", activeForm: "Executing stage 2"},
|
||||
{content: " • Group G4: Dependent fixes (2 findings)", status: "in_progress", activeForm: "Fixing G4"},
|
||||
{content: "Phase 4: Completion", status: "pending", activeForm: "Completing"}
|
||||
]
|
||||
});
|
||||
```
|
||||
|
||||
**Update Rules**:
|
||||
- Add batch items dynamically during Phase 1.5
|
||||
- Mark batch items completed as parallel agents return results
|
||||
- Add stage/group items dynamically after Phase 2 plan aggregation
|
||||
- Mark completed immediately after each group finishes
|
||||
- Update parent phase status when all child items complete
|
||||
|
||||
## Post-Completion Expansion
|
||||
|
||||
完成后询问用户是否扩展为issue(test/enhance/refactor/doc),选中项调用 `/issue:new "{summary} - {dimension}"`
|
||||
|
||||
## Best Practices
|
||||
|
||||
1. **Leverage Parallel Planning**: For 10+ findings, parallel batching significantly reduces planning time
|
||||
2. **Tune Batch Size**: Use `--batch-size` to control granularity (smaller batches = more parallelism, larger = better grouping context)
|
||||
3. **Conservative Approach**: Test verification is mandatory - no fixes kept without passing tests
|
||||
4. **Parallel Efficiency**: MAX_PARALLEL=10 for planning agents, 3 concurrent execution agents per stage
|
||||
5. **Resume Support**: Fix sessions can resume from checkpoints after interruption
|
||||
6. **Manual Review**: Always review failed fixes manually - may require architectural changes
|
||||
7. **Incremental Fixing**: Start with small batches (5-10 findings) before large-scale fixes
|
||||
|
||||
## Related Commands
|
||||
|
||||
### View Fix Progress
|
||||
Use `ccw view` to open the workflow dashboard in browser:
|
||||
|
||||
```bash
|
||||
ccw view
|
||||
```
|
||||
@@ -1,606 +0,0 @@
|
||||
---
|
||||
name: review-fix
|
||||
description: Automated fixing of code review findings with AI-powered planning and coordinated execution. Uses intelligent grouping, multi-stage timeline coordination, and test-driven verification.
|
||||
argument-hint: "<export-file|review-dir> [--resume] [--max-iterations=N]"
|
||||
allowed-tools: SlashCommand(*), TodoWrite(*), Read(*), Bash(*), Task(*), Edit(*), Write(*)
|
||||
---
|
||||
|
||||
# Workflow Review-Fix Command
|
||||
|
||||
## Quick Start
|
||||
|
||||
```bash
|
||||
# Fix from exported findings file (session-based path)
|
||||
/workflow:review-fix .workflow/active/WFS-123/.review/fix-export-1706184622000.json
|
||||
|
||||
# Fix from review directory (auto-discovers latest export)
|
||||
/workflow:review-fix .workflow/active/WFS-123/.review/
|
||||
|
||||
# Resume interrupted fix session
|
||||
/workflow:review-fix --resume
|
||||
|
||||
# Custom max retry attempts per finding
|
||||
/workflow:review-fix .workflow/active/WFS-123/.review/ --max-iterations=5
|
||||
```
|
||||
|
||||
**Fix Source**: Exported findings from review cycle dashboard
|
||||
**Output Directory**: `{review-dir}/fixes/{fix-session-id}/` (within session .review/)
|
||||
**Default Max Iterations**: 3 (per finding, adjustable)
|
||||
**CLI Tools**: @cli-planning-agent (planning), @cli-execute-agent (fixing)
|
||||
|
||||
## What & Why
|
||||
|
||||
### Core Concept
|
||||
Automated fix orchestrator with **two-phase architecture**: AI-powered planning followed by coordinated parallel/serial execution. Generates fix timeline with intelligent grouping and dependency analysis, then executes fixes with conservative test verification.
|
||||
|
||||
**Fix Process**:
|
||||
- **Planning Phase**: AI analyzes findings, generates fix plan with grouping and execution strategy
|
||||
- **Execution Phase**: Main orchestrator coordinates agents per timeline stages
|
||||
- **No rigid structure**: Adapts to task requirements, not bound to fixed JSON format
|
||||
|
||||
**vs Manual Fixing**:
|
||||
- **Manual**: Developer reviews findings one-by-one, fixes sequentially
|
||||
- **Automated**: AI groups related issues, executes in optimal parallel/serial order with automatic test verification
|
||||
|
||||
### Value Proposition
|
||||
1. **Intelligent Planning**: AI-powered analysis identifies optimal grouping and execution strategy
|
||||
2. **Multi-stage Coordination**: Supports complex parallel + serial execution with dependency management
|
||||
3. **Conservative Safety**: Mandatory test verification with automatic rollback on failure
|
||||
4. **Resume Support**: Checkpoint-based recovery for interrupted sessions
|
||||
|
||||
### Orchestrator Boundary (CRITICAL)
|
||||
- **ONLY command** for automated review finding fixes
|
||||
- Manages: Planning phase coordination, stage-based execution, agent scheduling, progress tracking
|
||||
- Delegates: Fix planning to @cli-planning-agent, fix execution to @cli-execute-agent
|
||||
|
||||
|
||||
### Execution Flow
|
||||
|
||||
```
|
||||
Phase 1: Discovery & Initialization
|
||||
└─ Validate export file, create fix session structure, initialize state files
|
||||
|
||||
Phase 2: Planning Coordination (@cli-planning-agent)
|
||||
├─ Analyze findings for patterns and dependencies
|
||||
├─ Group by file + dimension + root cause similarity
|
||||
├─ Determine execution strategy (parallel/serial/hybrid)
|
||||
├─ Generate fix timeline with stages
|
||||
└─ Output: fix-plan.json
|
||||
|
||||
Phase 3: Execution Orchestration (Stage-based)
|
||||
For each timeline stage:
|
||||
├─ Load groups for this stage
|
||||
├─ If parallel: Launch all group agents simultaneously
|
||||
├─ If serial: Execute groups sequentially
|
||||
├─ Each agent:
|
||||
│ ├─ Analyze code context
|
||||
│ ├─ Apply fix per strategy
|
||||
│ ├─ Run affected tests
|
||||
│ ├─ On test failure: Rollback, retry up to max_iterations
|
||||
│ └─ On success: Commit, update fix-progress-{N}.json
|
||||
└─ Advance to next stage
|
||||
|
||||
Phase 4: Completion & Aggregation
|
||||
└─ Aggregate results → Generate fix-summary.md → Update history → Output summary
|
||||
|
||||
Phase 5: Session Completion (Optional)
|
||||
└─ If all fixes successful → Prompt to complete workflow session
|
||||
```
|
||||
|
||||
### Agent Roles
|
||||
|
||||
| Agent | Responsibility |
|
||||
|-------|---------------|
|
||||
| **Orchestrator** | Input validation, session management, planning coordination, stage-based execution scheduling, progress tracking, aggregation |
|
||||
| **@cli-planning-agent** | Findings analysis, intelligent grouping (file+dimension+root cause), execution strategy determination (parallel/serial/hybrid), timeline generation with dependency mapping |
|
||||
| **@cli-execute-agent** | Fix execution per group, code context analysis, Edit tool operations, test verification, git rollback on failure, completion JSON generation |
|
||||
|
||||
## Enhanced Features
|
||||
|
||||
### 1. Two-Phase Architecture
|
||||
|
||||
**Phase Separation**:
|
||||
|
||||
| Phase | Agent | Output | Purpose |
|
||||
|-------|-------|--------|---------|
|
||||
| **Planning** | @cli-planning-agent | fix-plan.json | Analyze findings, group intelligently, determine optimal execution strategy |
|
||||
| **Execution** | @cli-execute-agent | completions/*.json | Execute fixes per plan with test verification and rollback |
|
||||
|
||||
**Benefits**:
|
||||
- Clear separation of concerns (analysis vs execution)
|
||||
- Reusable plans (can re-execute without re-planning)
|
||||
- Better error isolation (planning failures vs execution failures)
|
||||
|
||||
### 2. Intelligent Grouping Strategy
|
||||
|
||||
**Three-Level Grouping**:
|
||||
|
||||
```javascript
|
||||
// Level 1: Primary grouping by file + dimension
|
||||
{file: "auth.ts", dimension: "security"} → Group A
|
||||
{file: "auth.ts", dimension: "quality"} → Group B
|
||||
{file: "query-builder.ts", dimension: "security"} → Group C
|
||||
|
||||
// Level 2: Secondary grouping by root cause similarity
|
||||
Group A findings → Semantic similarity analysis (threshold 0.7)
|
||||
→ Sub-group A1: "missing-input-validation" (findings 1, 2)
|
||||
→ Sub-group A2: "insecure-crypto" (finding 3)
|
||||
|
||||
// Level 3: Dependency analysis
|
||||
Sub-group A1 creates validation utilities
|
||||
Sub-group C4 depends on those utilities
|
||||
→ A1 must execute before C4 (serial stage dependency)
|
||||
```
|
||||
|
||||
**Similarity Computation**:
|
||||
- Combine: `description + recommendation + category`
|
||||
- Vectorize: TF-IDF or LLM embedding
|
||||
- Cluster: Greedy algorithm with cosine similarity > 0.7
|
||||
|
||||
### 3. Execution Strategy Determination
|
||||
|
||||
**Strategy Types**:
|
||||
|
||||
| Strategy | When to Use | Stage Structure |
|
||||
|----------|-------------|-----------------|
|
||||
| **Parallel** | All groups independent, different files | Single stage, all groups in parallel |
|
||||
| **Serial** | Strong dependencies, shared resources | Multiple stages, one group per stage |
|
||||
| **Hybrid** | Mixed dependencies | Multiple stages, parallel within stages |
|
||||
|
||||
**Dependency Detection**:
|
||||
- Shared file modifications
|
||||
- Utility creation + usage patterns
|
||||
- Test dependency chains
|
||||
- Risk level clustering (high-risk groups isolated)
|
||||
|
||||
### 4. Conservative Test Verification
|
||||
|
||||
**Test Strategy** (per fix):
|
||||
|
||||
```javascript
|
||||
// 1. Identify affected tests
|
||||
const testPattern = identifyTestPattern(finding.file);
|
||||
// e.g., "tests/auth/**/*.test.*" for src/auth/service.ts
|
||||
|
||||
// 2. Run tests
|
||||
const result = await runTests(testPattern);
|
||||
|
||||
// 3. Evaluate
|
||||
if (result.passRate < 100%) {
|
||||
// Rollback
|
||||
await gitCheckout(finding.file);
|
||||
|
||||
// Retry with failure context
|
||||
if (attempts < maxIterations) {
|
||||
const fixContext = analyzeFailure(result.stderr);
|
||||
regenerateFix(finding, fixContext);
|
||||
retry();
|
||||
} else {
|
||||
markFailed(finding.id);
|
||||
}
|
||||
} else {
|
||||
// Commit
|
||||
await gitCommit(`Fix: ${finding.title} [${finding.id}]`);
|
||||
markFixed(finding.id);
|
||||
}
|
||||
```
|
||||
|
||||
**Pass Criteria**: 100% test pass rate (no partial fixes)
|
||||
|
||||
## Core Responsibilities
|
||||
|
||||
### Orchestrator
|
||||
|
||||
**Phase 1: Discovery & Initialization**
|
||||
- Input validation: Check export file exists and is valid JSON
|
||||
- Auto-discovery: If review-dir provided, find latest `*-fix-export.json`
|
||||
- Session creation: Generate fix-session-id (`fix-{timestamp}`)
|
||||
- Directory structure: Create `{review-dir}/fixes/{fix-session-id}/` with subdirectories
|
||||
- State files: Initialize active-fix-session.json (session marker)
|
||||
- TodoWrite initialization: Set up 4-phase tracking
|
||||
|
||||
**Phase 2: Planning Coordination**
|
||||
- Launch @cli-planning-agent with findings data and project context
|
||||
- Validate fix-plan.json output (schema conformance, includes metadata with session status)
|
||||
- Load plan into memory for execution phase
|
||||
- TodoWrite update: Mark planning complete, start execution
|
||||
|
||||
**Phase 3: Execution Orchestration**
|
||||
- Load fix-plan.json timeline stages
|
||||
- For each stage:
|
||||
- If parallel mode: Launch all group agents via `Promise.all()`
|
||||
- If serial mode: Execute groups sequentially with `await`
|
||||
- Assign agent IDs (agents update their fix-progress-{N}.json)
|
||||
- Handle agent failures gracefully (mark group as failed, continue)
|
||||
- Advance to next stage only when current stage complete
|
||||
|
||||
**Phase 4: Completion & Aggregation**
|
||||
- Collect final status from all fix-progress-{N}.json files
|
||||
- Generate fix-summary.md with timeline and results
|
||||
- Update fix-history.json with new session entry
|
||||
- Remove active-fix-session.json
|
||||
- TodoWrite completion: Mark all phases done
|
||||
- Output summary to user
|
||||
|
||||
**Phase 5: Session Completion (Optional)**
|
||||
- If all findings fixed successfully (no failures):
|
||||
- Prompt user: "All fixes complete. Complete workflow session? [Y/n]"
|
||||
- If confirmed: Execute `/workflow:session:complete` to archive session with lessons learned
|
||||
- If partial success (some failures):
|
||||
- Output: "Some findings failed. Review fix-summary.md before completing session."
|
||||
- Do NOT auto-complete session
|
||||
|
||||
### Output File Structure
|
||||
|
||||
```
|
||||
.workflow/active/WFS-{session-id}/.review/
|
||||
├── fix-export-{timestamp}.json # Exported findings (input)
|
||||
└── fixes/{fix-session-id}/
|
||||
├── fix-plan.json # Planning agent output (execution plan with metadata)
|
||||
├── fix-progress-1.json # Group 1 progress (planning agent init → agent updates)
|
||||
├── fix-progress-2.json # Group 2 progress (planning agent init → agent updates)
|
||||
├── fix-progress-3.json # Group 3 progress (planning agent init → agent updates)
|
||||
├── fix-summary.md # Final report (orchestrator generates)
|
||||
├── active-fix-session.json # Active session marker
|
||||
└── fix-history.json # All sessions history
|
||||
```
|
||||
|
||||
**File Producers**:
|
||||
- **Planning Agent**: `fix-plan.json` (with metadata), all `fix-progress-*.json` (initial state)
|
||||
- **Execution Agents**: Update assigned `fix-progress-{N}.json` in real-time
|
||||
|
||||
|
||||
### Agent Invocation Template
|
||||
|
||||
**Planning Agent**:
|
||||
```javascript
|
||||
Task({
|
||||
subagent_type: "cli-planning-agent",
|
||||
description: `Generate fix plan and initialize progress files for ${findings.length} findings`,
|
||||
prompt: `
|
||||
## Task Objective
|
||||
Analyze ${findings.length} code review findings and generate execution plan with intelligent grouping and timeline coordination.
|
||||
|
||||
## Input Data
|
||||
Review Session: ${reviewId}
|
||||
Fix Session ID: ${fixSessionId}
|
||||
Total Findings: ${findings.length}
|
||||
|
||||
Findings:
|
||||
${JSON.stringify(findings, null, 2)}
|
||||
|
||||
Project Context:
|
||||
- Structure: ${projectStructure}
|
||||
- Test Framework: ${testFramework}
|
||||
- Git Status: ${gitStatus}
|
||||
|
||||
## Output Requirements
|
||||
|
||||
### 1. fix-plan.json
|
||||
Execute: cat ~/.claude/workflows/cli-templates/fix-plan-template.json
|
||||
|
||||
Generate execution plan following template structure:
|
||||
|
||||
**Key Generation Rules**:
|
||||
- **Metadata**: Populate fix_session_id, review_session_id, status ("planning"), created_at, started_at timestamps
|
||||
- **Execution Strategy**: Choose approach (parallel/serial/hybrid) based on dependency analysis, set parallel_limit and stages count
|
||||
- **Groups**: Create groups (G1, G2, ...) with intelligent grouping (see Analysis Requirements below), assign progress files (fix-progress-1.json, ...), populate fix_strategy with approach/complexity/test_pattern, assess risks, identify dependencies
|
||||
- **Timeline**: Define stages respecting dependencies, set execution_mode per stage, map groups to stages, calculate critical path
|
||||
|
||||
### 2. fix-progress-{N}.json (one per group)
|
||||
Execute: cat ~/.claude/workflows/cli-templates/fix-progress-template.json
|
||||
|
||||
For each group (G1, G2, G3, ...), generate fix-progress-{N}.json following template structure:
|
||||
|
||||
**Initial State Requirements**:
|
||||
- Status: "pending", phase: "waiting"
|
||||
- Timestamps: Set last_update to now, others null
|
||||
- Findings: Populate from review findings with status "pending", all operation fields null
|
||||
- Summary: Initialize all counters to zero
|
||||
- Flow control: Empty implementation_approach array
|
||||
- Errors: Empty array
|
||||
|
||||
**CRITICAL**: Ensure complete template structure - all fields must be present.
|
||||
|
||||
## Analysis Requirements
|
||||
|
||||
### Intelligent Grouping Strategy
|
||||
Group findings using these criteria (in priority order):
|
||||
|
||||
1. **File Proximity**: Findings in same file or related files
|
||||
2. **Dimension Affinity**: Same dimension (security, performance, etc.)
|
||||
3. **Root Cause Similarity**: Similar underlying issues
|
||||
4. **Fix Approach Commonality**: Can be fixed with similar approach
|
||||
|
||||
**Grouping Guidelines**:
|
||||
- Optimal group size: 2-5 findings per group
|
||||
- Avoid cross-cutting concerns in same group
|
||||
- Consider test isolation (different test suites → different groups)
|
||||
- Balance workload across groups for parallel execution
|
||||
|
||||
### Execution Strategy Determination
|
||||
|
||||
**Parallel Mode**: Use when groups are independent, no shared files
|
||||
**Serial Mode**: Use when groups have dependencies or shared resources
|
||||
**Hybrid Mode**: Use for mixed dependency graphs (recommended for most cases)
|
||||
|
||||
**Dependency Analysis**:
|
||||
- Identify shared files between groups
|
||||
- Detect test dependency chains
|
||||
- Evaluate risk of concurrent modifications
|
||||
|
||||
### Risk Assessment
|
||||
|
||||
For each group, evaluate:
|
||||
- **Complexity**: Based on code structure, file size, existing tests
|
||||
- **Impact Scope**: Number of files affected, API surface changes
|
||||
- **Rollback Feasibility**: Ease of reverting changes if tests fail
|
||||
|
||||
### Test Strategy
|
||||
|
||||
For each group, determine:
|
||||
- **Test Pattern**: Glob pattern matching affected tests
|
||||
- **Pass Criteria**: All tests must pass (100% pass rate)
|
||||
- **Test Command**: Infer from project (package.json, pytest.ini, etc.)
|
||||
|
||||
## Output Files
|
||||
|
||||
Write to ${sessionDir}:
|
||||
- ./fix-plan.json
|
||||
- ./fix-progress-1.json
|
||||
- ./fix-progress-2.json
|
||||
- ./fix-progress-{N}.json (as many as groups created)
|
||||
|
||||
## Quality Checklist
|
||||
|
||||
Before finalizing outputs:
|
||||
- ✅ All findings assigned to exactly one group
|
||||
- ✅ Group dependencies correctly identified
|
||||
- ✅ Timeline stages respect dependencies
|
||||
- ✅ All progress files have complete initial structure
|
||||
- ✅ Test patterns are valid and specific
|
||||
- ✅ Risk assessments are realistic
|
||||
- ✅ Estimated times are reasonable
|
||||
`
|
||||
})
|
||||
```
|
||||
|
||||
**Execution Agent** (per group):
|
||||
```javascript
|
||||
Task({
|
||||
subagent_type: "cli-execute-agent",
|
||||
description: `Fix ${group.findings.length} issues: ${group.group_name}`,
|
||||
prompt: `
|
||||
## Task Objective
|
||||
Execute fixes for code review findings in group ${group.group_id}. Update progress file in real-time with flow control tracking.
|
||||
|
||||
## Assignment
|
||||
- Group ID: ${group.group_id}
|
||||
- Group Name: ${group.group_name}
|
||||
- Progress File: ${sessionDir}/${group.progress_file}
|
||||
- Findings Count: ${group.findings.length}
|
||||
- Max Iterations: ${maxIterations} (per finding)
|
||||
|
||||
## Fix Strategy
|
||||
${JSON.stringify(group.fix_strategy, null, 2)}
|
||||
|
||||
## Risk Assessment
|
||||
${JSON.stringify(group.risk_assessment, null, 2)}
|
||||
|
||||
## Execution Flow
|
||||
|
||||
### Initialization (Before Starting)
|
||||
|
||||
1. Read ${group.progress_file} to load initial state
|
||||
2. Update progress file:
|
||||
- assigned_agent: "${agentId}"
|
||||
- status: "in-progress"
|
||||
- started_at: Current ISO 8601 timestamp
|
||||
- last_update: Current ISO 8601 timestamp
|
||||
3. Write updated state back to ${group.progress_file}
|
||||
|
||||
### Main Execution Loop
|
||||
|
||||
For EACH finding in ${group.progress_file}.findings:
|
||||
|
||||
#### Step 1: Analyze Context
|
||||
|
||||
**Before Step**:
|
||||
- Update finding: status→"in-progress", started_at→now()
|
||||
- Update current_finding: Populate with finding details, status→"analyzing", action→"Reading file and understanding code structure"
|
||||
- Update phase→"analyzing"
|
||||
- Update flow_control: Add "analyze_context" step to implementation_approach (status→"in-progress"), set current_step→"analyze_context"
|
||||
- Update last_update→now(), write to ${group.progress_file}
|
||||
|
||||
**Action**:
|
||||
- Read file: finding.file
|
||||
- Understand code structure around line: finding.line
|
||||
- Analyze surrounding context (imports, dependencies, related functions)
|
||||
- Review recommendations: finding.recommendations
|
||||
|
||||
**After Step**:
|
||||
- Update flow_control: Mark "analyze_context" step as "completed" with completed_at→now()
|
||||
- Update last_update→now(), write to ${group.progress_file}
|
||||
|
||||
#### Step 2: Apply Fix
|
||||
|
||||
**Before Step**:
|
||||
- Update current_finding: status→"fixing", action→"Applying code changes per recommendations"
|
||||
- Update phase→"fixing"
|
||||
- Update flow_control: Add "apply_fix" step to implementation_approach (status→"in-progress"), set current_step→"apply_fix"
|
||||
- Update last_update→now(), write to ${group.progress_file}
|
||||
|
||||
**Action**:
|
||||
- Use Edit tool to implement code changes per finding.recommendations
|
||||
- Follow fix_strategy.approach
|
||||
- Maintain code style and existing patterns
|
||||
|
||||
**After Step**:
|
||||
- Update flow_control: Mark "apply_fix" step as "completed" with completed_at→now()
|
||||
- Update last_update→now(), write to ${group.progress_file}
|
||||
|
||||
#### Step 3: Test Verification
|
||||
|
||||
**Before Step**:
|
||||
- Update current_finding: status→"testing", action→"Running test suite to verify fix"
|
||||
- Update phase→"testing"
|
||||
- Update flow_control: Add "run_tests" step to implementation_approach (status→"in-progress"), set current_step→"run_tests"
|
||||
- Update last_update→now(), write to ${group.progress_file}
|
||||
|
||||
**Action**:
|
||||
- Run tests using fix_strategy.test_pattern
|
||||
- Require 100% pass rate
|
||||
- Capture test output
|
||||
|
||||
**On Test Failure**:
|
||||
- Git rollback: \`git checkout -- \${finding.file}\`
|
||||
- Increment finding.attempts
|
||||
- Update flow_control: Mark "run_tests" step as "failed" with completed_at→now()
|
||||
- Update errors: Add entry (finding_id, error_type→"test_failure", message, timestamp)
|
||||
- If finding.attempts < ${maxIterations}:
|
||||
- Reset flow_control: implementation_approach→[], current_step→null
|
||||
- Retry from Step 1
|
||||
- Else:
|
||||
- Update finding: status→"completed", result→"failed", error_message→"Max iterations reached", completed_at→now()
|
||||
- Update summary counts, move to next finding
|
||||
|
||||
**On Test Success**:
|
||||
- Update flow_control: Mark "run_tests" step as "completed" with completed_at→now()
|
||||
- Update last_update→now(), write to ${group.progress_file}
|
||||
- Proceed to Step 4
|
||||
|
||||
#### Step 4: Commit Changes
|
||||
|
||||
**Before Step**:
|
||||
- Update current_finding: status→"committing", action→"Creating git commit for successful fix"
|
||||
- Update phase→"committing"
|
||||
- Update flow_control: Add "commit_changes" step to implementation_approach (status→"in-progress"), set current_step→"commit_changes"
|
||||
- Update last_update→now(), write to ${group.progress_file}
|
||||
|
||||
**Action**:
|
||||
- Git commit: \`git commit -m "fix(${finding.dimension}): ${finding.title} [${finding.id}]"\`
|
||||
- Capture commit hash
|
||||
|
||||
**After Step**:
|
||||
- Update finding: status→"completed", result→"fixed", commit_hash→<captured>, test_passed→true, completed_at→now()
|
||||
- Update flow_control: Mark "commit_changes" step as "completed" with completed_at→now()
|
||||
- Update last_update→now(), write to ${group.progress_file}
|
||||
|
||||
#### After Each Finding
|
||||
|
||||
- Update summary: Recalculate counts (pending/in_progress/fixed/failed) and percent_complete
|
||||
- If all findings completed: Clear current_finding, reset flow_control
|
||||
- Update last_update→now(), write to ${group.progress_file}
|
||||
|
||||
### Final Completion
|
||||
|
||||
When all findings processed:
|
||||
- Update status→"completed", phase→"done", summary.percent_complete→100.0
|
||||
- Update last_update→now(), write final state to ${group.progress_file}
|
||||
|
||||
## Critical Requirements
|
||||
|
||||
### Progress File Updates
|
||||
- **MUST update after every significant action** (before/after each step)
|
||||
- **Always maintain complete structure** - never write partial updates
|
||||
- **Use ISO 8601 timestamps** - e.g., "2025-01-25T14:36:00Z"
|
||||
|
||||
### Flow Control Format
|
||||
Follow action-planning-agent flow_control.implementation_approach format:
|
||||
- step: Identifier (e.g., "analyze_context", "apply_fix")
|
||||
- action: Human-readable description
|
||||
- status: "pending" | "in-progress" | "completed" | "failed"
|
||||
- started_at: ISO 8601 timestamp or null
|
||||
- completed_at: ISO 8601 timestamp or null
|
||||
|
||||
### Error Handling
|
||||
- Capture all errors in errors[] array
|
||||
- Never leave progress file in invalid state
|
||||
- Always write complete updates, never partial
|
||||
- On unrecoverable error: Mark group as failed, preserve state
|
||||
|
||||
## Test Patterns
|
||||
Use fix_strategy.test_pattern to run affected tests:
|
||||
- Pattern: ${group.fix_strategy.test_pattern}
|
||||
- Command: Infer from project (npm test, pytest, etc.)
|
||||
- Pass Criteria: 100% pass rate required
|
||||
`
|
||||
})
|
||||
```
|
||||
|
||||
|
||||
|
||||
### Error Handling
|
||||
|
||||
**Planning Failures**:
|
||||
- Invalid template → Abort with error message
|
||||
- Insufficient findings data → Request complete export
|
||||
- Planning timeout → Retry once, then fail gracefully
|
||||
|
||||
**Execution Failures**:
|
||||
- Agent crash → Mark group as failed, continue with other groups
|
||||
- Test command not found → Skip test verification, warn user
|
||||
- Git operations fail → Abort with error, preserve state
|
||||
|
||||
**Rollback Scenarios**:
|
||||
- Test failure after fix → Automatic `git checkout` rollback
|
||||
- Max iterations reached → Leave file unchanged, mark as failed
|
||||
- Unrecoverable error → Rollback entire group, save checkpoint
|
||||
|
||||
### TodoWrite Structure
|
||||
|
||||
**Initialization**:
|
||||
```javascript
|
||||
TodoWrite({
|
||||
todos: [
|
||||
{content: "Phase 1: Discovery & Initialization", status: "completed"},
|
||||
{content: "Phase 2: Planning", status: "in_progress"},
|
||||
{content: "Phase 3: Execution", status: "pending"},
|
||||
{content: "Phase 4: Completion", status: "pending"}
|
||||
]
|
||||
});
|
||||
```
|
||||
|
||||
**During Execution**:
|
||||
```javascript
|
||||
TodoWrite({
|
||||
todos: [
|
||||
{content: "Phase 1: Discovery & Initialization", status: "completed"},
|
||||
{content: "Phase 2: Planning", status: "completed"},
|
||||
{content: "Phase 3: Execution", status: "in_progress"},
|
||||
{content: " → Stage 1: Parallel execution (3 groups)", status: "completed"},
|
||||
{content: " • Group G1: Auth validation (2 findings)", status: "completed"},
|
||||
{content: " • Group G2: Query security (3 findings)", status: "completed"},
|
||||
{content: " • Group G3: Config quality (1 finding)", status: "completed"},
|
||||
{content: " → Stage 2: Serial execution (1 group)", status: "in_progress"},
|
||||
{content: " • Group G4: Dependent fixes (2 findings)", status: "in_progress"},
|
||||
{content: "Phase 4: Completion", status: "pending"}
|
||||
]
|
||||
});
|
||||
```
|
||||
|
||||
**Update Rules**:
|
||||
- Add stage items dynamically based on fix-plan.json timeline
|
||||
- Add group items per stage
|
||||
- Mark completed immediately after each group finishes
|
||||
- Update parent phase status when all child items complete
|
||||
|
||||
## Best Practices
|
||||
|
||||
1. **Trust AI Planning**: Planning agent's grouping and execution strategy are based on dependency analysis
|
||||
2. **Conservative Approach**: Test verification is mandatory - no fixes kept without passing tests
|
||||
3. **Parallel Efficiency**: Default 3 concurrent agents balances speed and resource usage
|
||||
4. **Resume Support**: Fix sessions can resume from checkpoints after interruption
|
||||
5. **Manual Review**: Always review failed fixes manually - may require architectural changes
|
||||
6. **Incremental Fixing**: Start with small batches (5-10 findings) before large-scale fixes
|
||||
|
||||
## Related Commands
|
||||
|
||||
### View Fix Progress
|
||||
Use `ccw view` to open the workflow dashboard in browser:
|
||||
|
||||
```bash
|
||||
ccw view
|
||||
```
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
name: review-module-cycle
|
||||
description: Independent multi-dimensional code review for specified modules/files. Analyzes specific code paths across 7 dimensions with hybrid parallel-iterative execution, independent of workflow sessions.
|
||||
argument-hint: "<path-pattern> [--dimensions=security,architecture,...] [--max-iterations=N]"
|
||||
allowed-tools: SlashCommand(*), TodoWrite(*), Read(*), Bash(*), Task(*)
|
||||
allowed-tools: Skill(*), TodoWrite(*), Read(*), Bash(*), Task(*)
|
||||
---
|
||||
|
||||
# Workflow Review-Module-Cycle Command
|
||||
@@ -187,7 +187,7 @@ const CATEGORIES = {
|
||||
**Step 1: Session Creation**
|
||||
```javascript
|
||||
// Create workflow session for this review (type: review)
|
||||
SlashCommand(command="/workflow:session:start --type review \"Code review for [target_pattern]\"")
|
||||
Skill(skill="workflow:session:start", args="--type review \"Code review for [target_pattern]\"")
|
||||
|
||||
// Parse output
|
||||
const sessionId = output.match(/SESSION_ID: (WFS-[^\s]+)/)[1];
|
||||
@@ -409,6 +409,8 @@ Task(
|
||||
2. Get target files: Read resolved_files from review-state.json
|
||||
3. Validate file access: bash(ls -la ${targetFiles.join(' ')})
|
||||
4. Execute: cat ~/.claude/workflows/cli-templates/schemas/review-dimension-results-schema.json (get output schema reference)
|
||||
5. Read: .workflow/project-tech.json (technology stack and architecture context)
|
||||
6. Read: .workflow/project-guidelines.json (user-defined constraints and conventions to validate against)
|
||||
|
||||
## Review Context
|
||||
- Review Type: module (independent)
|
||||
@@ -511,6 +513,8 @@ Task(
|
||||
3. Identify related code: bash(grep -r "import.*${basename(file)}" ${projectDir}/src --include="*.ts")
|
||||
4. Read test files: bash(find ${projectDir}/tests -name "*${basename(file, '.ts')}*" -type f)
|
||||
5. Execute: cat ~/.claude/workflows/cli-templates/schemas/review-deep-dive-results-schema.json (get output schema reference)
|
||||
6. Read: .workflow/project-tech.json (technology stack and architecture context)
|
||||
7. Read: .workflow/project-guidelines.json (user-defined constraints for remediation compliance)
|
||||
|
||||
## CLI Configuration
|
||||
- Tool Priority: gemini → qwen → codex
|
||||
@@ -760,8 +764,8 @@ After completing a module review, use the generated findings JSON for automated
|
||||
/workflow:review-module-cycle src/auth/**
|
||||
|
||||
# Step 2: Run automated fixes using dimension findings
|
||||
/workflow:review-fix .workflow/active/WFS-{session-id}/.review/
|
||||
/workflow:review-cycle-fix .workflow/active/WFS-{session-id}/.review/
|
||||
```
|
||||
|
||||
See `/workflow:review-fix` for automated fixing with smart grouping, parallel execution, and test verification.
|
||||
See `/workflow:review-cycle-fix` for automated fixing with smart grouping, parallel execution, and test verification.
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
name: review-session-cycle
|
||||
description: Session-based comprehensive multi-dimensional code review. Analyzes git changes from workflow session across 7 dimensions with hybrid parallel-iterative execution, aggregates findings, and performs focused deep-dives on critical issues until quality gates met.
|
||||
argument-hint: "[session-id] [--dimensions=security,architecture,...] [--max-iterations=N]"
|
||||
allowed-tools: SlashCommand(*), TodoWrite(*), Read(*), Bash(*), Task(*)
|
||||
allowed-tools: Skill(*), TodoWrite(*), Read(*), Bash(*), Task(*)
|
||||
---
|
||||
|
||||
# Workflow Review-Session-Cycle Command
|
||||
@@ -420,6 +420,8 @@ Task(
|
||||
3. Get changed files: bash(cd ${workflowDir} && git log --since="${sessionCreatedAt}" --name-only --pretty=format: | sort -u)
|
||||
4. Read review state: ${reviewStateJsonPath}
|
||||
5. Execute: cat ~/.claude/workflows/cli-templates/schemas/review-dimension-results-schema.json (get output schema reference)
|
||||
6. Read: .workflow/project-tech.json (technology stack and architecture context)
|
||||
7. Read: .workflow/project-guidelines.json (user-defined constraints and conventions to validate against)
|
||||
|
||||
## Session Context
|
||||
- Session ID: ${sessionId}
|
||||
@@ -522,6 +524,8 @@ Task(
|
||||
3. Identify related code: bash(grep -r "import.*${basename(file)}" ${workflowDir}/src --include="*.ts")
|
||||
4. Read test files: bash(find ${workflowDir}/tests -name "*${basename(file, '.ts')}*" -type f)
|
||||
5. Execute: cat ~/.claude/workflows/cli-templates/schemas/review-deep-dive-results-schema.json (get output schema reference)
|
||||
6. Read: .workflow/project-tech.json (technology stack and architecture context)
|
||||
7. Read: .workflow/project-guidelines.json (user-defined constraints for remediation compliance)
|
||||
|
||||
## CLI Configuration
|
||||
- Tool Priority: gemini → qwen → codex
|
||||
@@ -771,8 +775,8 @@ After completing a review, use the generated findings JSON for automated fixing:
|
||||
/workflow:review-session-cycle
|
||||
|
||||
# Step 2: Run automated fixes using dimension findings
|
||||
/workflow:review-fix .workflow/active/WFS-{session-id}/.review/
|
||||
/workflow:review-cycle-fix .workflow/active/WFS-{session-id}/.review/
|
||||
```
|
||||
|
||||
See `/workflow:review-fix` for automated fixing with smart grouping, parallel execution, and test verification.
|
||||
See `/workflow:review-cycle-fix` for automated fixing with smart grouping, parallel execution, and test verification.
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
---
|
||||
name: review
|
||||
description: Post-implementation review with specialized types (security/architecture/action-items/quality) using analysis agents and Gemini
|
||||
argument-hint: "[--type=security|architecture|action-items|quality] [optional: session-id]"
|
||||
argument-hint: "[--type=security|architecture|action-items|quality] [--archived] [optional: session-id]"
|
||||
---
|
||||
|
||||
## Command Overview: /workflow:review
|
||||
@@ -34,15 +34,17 @@ argument-hint: "[--type=security|architecture|action-items|quality] [optional: s
|
||||
```
|
||||
Input Parsing:
|
||||
├─ Parse --type flag (default: quality)
|
||||
├─ Parse --archived flag (search in archives)
|
||||
└─ Parse session-id argument (optional)
|
||||
|
||||
Step 1: Session Resolution
|
||||
└─ Decision:
|
||||
├─ session-id provided → Use provided session
|
||||
├─ session-id provided + --archived → Search .workflow/archives/
|
||||
├─ session-id provided → Search .workflow/active/ first, then archives
|
||||
└─ Not provided → Auto-detect from .workflow/active/
|
||||
|
||||
Step 2: Validation
|
||||
├─ Check session directory exists
|
||||
├─ Check session directory exists (active or archived)
|
||||
└─ Check for completed implementation (.summaries/IMPL-*.md exists)
|
||||
|
||||
Step 3: Type Check
|
||||
@@ -68,21 +70,29 @@ Step 5: Generate Report
|
||||
#!/bin/bash
|
||||
# Optional specialized review for completed implementation
|
||||
|
||||
# Step 1: Session ID resolution
|
||||
# Step 1: Session ID resolution and location detection
|
||||
if [ -n "$SESSION_ARG" ]; then
|
||||
sessionId="$SESSION_ARG"
|
||||
else
|
||||
sessionId=$(find .workflow/active/ -name "WFS-*" -type d | head -1 | xargs basename)
|
||||
fi
|
||||
|
||||
# Step 2: Validation
|
||||
if [ ! -d ".workflow/active/${sessionId}" ]; then
|
||||
echo "Session ${sessionId} not found"
|
||||
# Step 2: Resolve session path (active or archived)
|
||||
# Priority: --archived flag → active → archives
|
||||
if [ -n "$ARCHIVED_FLAG" ]; then
|
||||
sessionPath=".workflow/archives/${sessionId}"
|
||||
elif [ -d ".workflow/active/${sessionId}" ]; then
|
||||
sessionPath=".workflow/active/${sessionId}"
|
||||
elif [ -d ".workflow/archives/${sessionId}" ]; then
|
||||
sessionPath=".workflow/archives/${sessionId}"
|
||||
echo "Note: Session found in archives, running review on archived session"
|
||||
else
|
||||
echo "Session ${sessionId} not found in active or archives"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Check for completed tasks
|
||||
if [ ! -d ".workflow/active/${sessionId}/.summaries" ] || [ -z "$(find .workflow/active/${sessionId}/.summaries/ -name "IMPL-*.md" -type f 2>/dev/null)" ]; then
|
||||
if [ ! -d "${sessionPath}/.summaries" ] || [ -z "$(find ${sessionPath}/.summaries/ -name "IMPL-*.md" -type f 2>/dev/null)" ]; then
|
||||
echo "No completed implementation found. Complete implementation first"
|
||||
exit 1
|
||||
fi
|
||||
@@ -113,17 +123,17 @@ After bash validation, the model takes control to:
|
||||
1. **Load Context**: Read completed task summaries and changed files
|
||||
```bash
|
||||
# Load implementation summaries (iterate through .summaries/ directory)
|
||||
for summary in .workflow/active/${sessionId}/.summaries/*.md; do
|
||||
for summary in ${sessionPath}/.summaries/*.md; do
|
||||
cat "$summary"
|
||||
done
|
||||
|
||||
# Load test results (if available)
|
||||
for test_summary in .workflow/active/${sessionId}/.summaries/TEST-FIX-*.md 2>/dev/null; do
|
||||
for test_summary in ${sessionPath}/.summaries/TEST-FIX-*.md 2>/dev/null; do
|
||||
cat "$test_summary"
|
||||
done
|
||||
|
||||
# Get changed files
|
||||
git log --since="$(cat .workflow/active/${sessionId}/workflow-session.json | jq -r .created_at)" --name-only --pretty=format: | sort -u
|
||||
git log --since="$(cat ${sessionPath}/workflow-session.json | jq -r .created_at)" --name-only --pretty=format: | sort -u
|
||||
```
|
||||
|
||||
2. **Perform Specialized Review**: Based on `review_type`
|
||||
@@ -139,10 +149,10 @@ After bash validation, the model takes control to:
|
||||
ccw cli -p "
|
||||
PURPOSE: Security audit of completed implementation
|
||||
TASK: Review code for security vulnerabilities, insecure patterns, auth/authz issues
|
||||
CONTEXT: @.summaries/IMPL-*.md,../.. @../../CLAUDE.md
|
||||
CONTEXT: @.summaries/IMPL-*.md,../.. @../../project-tech.json @../../project-guidelines.json
|
||||
EXPECTED: Security findings report with severity levels
|
||||
RULES: Focus on OWASP Top 10, authentication, authorization, data validation, injection risks
|
||||
" --tool gemini --mode write --cd .workflow/active/${sessionId}
|
||||
" --tool gemini --mode write --cd ${sessionPath}
|
||||
```
|
||||
|
||||
**Architecture Review** (`--type=architecture`):
|
||||
@@ -151,10 +161,10 @@ After bash validation, the model takes control to:
|
||||
ccw cli -p "
|
||||
PURPOSE: Architecture compliance review
|
||||
TASK: Evaluate adherence to architectural patterns, identify technical debt, review design decisions
|
||||
CONTEXT: @.summaries/IMPL-*.md,../.. @../../CLAUDE.md
|
||||
CONTEXT: @.summaries/IMPL-*.md,../.. @../../project-tech.json @../../project-guidelines.json
|
||||
EXPECTED: Architecture assessment with recommendations
|
||||
RULES: Check for patterns, separation of concerns, modularity, scalability
|
||||
" --tool qwen --mode write --cd .workflow/active/${sessionId}
|
||||
" --tool qwen --mode write --cd ${sessionPath}
|
||||
```
|
||||
|
||||
**Quality Review** (`--type=quality`):
|
||||
@@ -163,17 +173,17 @@ After bash validation, the model takes control to:
|
||||
ccw cli -p "
|
||||
PURPOSE: Code quality and best practices review
|
||||
TASK: Assess code readability, maintainability, adherence to best practices
|
||||
CONTEXT: @.summaries/IMPL-*.md,../.. @../../CLAUDE.md
|
||||
CONTEXT: @.summaries/IMPL-*.md,../.. @../../project-tech.json @../../project-guidelines.json
|
||||
EXPECTED: Quality assessment with improvement suggestions
|
||||
RULES: Check for code smells, duplication, complexity, naming conventions
|
||||
" --tool gemini --mode write --cd .workflow/active/${sessionId}
|
||||
" --tool gemini --mode write --cd ${sessionPath}
|
||||
```
|
||||
|
||||
**Action Items Review** (`--type=action-items`):
|
||||
- Verify all requirements and acceptance criteria met:
|
||||
```bash
|
||||
# Load task requirements and acceptance criteria
|
||||
for task_file in .workflow/active/${sessionId}/.task/*.json; do
|
||||
for task_file in ${sessionPath}/.task/*.json; do
|
||||
cat "$task_file" | jq -r '
|
||||
"Task: " + .id + "\n" +
|
||||
"Requirements: " + (.context.requirements | join(", ")) + "\n" +
|
||||
@@ -185,7 +195,7 @@ After bash validation, the model takes control to:
|
||||
ccw cli -p "
|
||||
PURPOSE: Verify all requirements and acceptance criteria are met
|
||||
TASK: Cross-check implementation summaries against original requirements
|
||||
CONTEXT: @.task/IMPL-*.json,.summaries/IMPL-*.md,../.. @../../CLAUDE.md
|
||||
CONTEXT: @.task/IMPL-*.json,.summaries/IMPL-*.md,../.. @../../project-tech.json @../../project-guidelines.json
|
||||
EXPECTED:
|
||||
- Requirements coverage matrix
|
||||
- Acceptance criteria verification
|
||||
@@ -196,7 +206,7 @@ After bash validation, the model takes control to:
|
||||
- Verify all acceptance criteria are met
|
||||
- Flag any incomplete or missing action items
|
||||
- Assess deployment readiness
|
||||
" --tool gemini --mode write --cd .workflow/active/${sessionId}
|
||||
" --tool gemini --mode write --cd ${sessionPath}
|
||||
```
|
||||
|
||||
|
||||
@@ -234,7 +244,7 @@ After bash validation, the model takes control to:
|
||||
4. **Output Files**:
|
||||
```bash
|
||||
# Save review report
|
||||
Write(.workflow/active/${sessionId}/REVIEW-${review_type}.md)
|
||||
Write(${sessionPath}/REVIEW-${review_type}.md)
|
||||
|
||||
# Update session metadata
|
||||
# (optional) Update workflow-session.json with review status
|
||||
@@ -261,6 +271,12 @@ After bash validation, the model takes control to:
|
||||
# Architecture review for specific session
|
||||
/workflow:review --type=architecture WFS-payment-integration
|
||||
|
||||
# Review an archived session (auto-detects if not in active)
|
||||
/workflow:review --type=security WFS-old-feature
|
||||
|
||||
# Explicitly review archived session
|
||||
/workflow:review --archived --type=quality WFS-completed-feature
|
||||
|
||||
# Documentation review
|
||||
/workflow:review --type=docs
|
||||
```
|
||||
@@ -270,6 +286,7 @@ After bash validation, the model takes control to:
|
||||
- **Simple Validation**: Check session exists and has completed tasks
|
||||
- **No Complex Orchestration**: Direct analysis, no multi-phase pipeline
|
||||
- **Specialized Reviews**: Different prompts and tools for different review types
|
||||
- **Archived Session Support**: Review archived sessions with `--archived` flag or auto-detection
|
||||
- **MCP Integration**: Fast code search for security and architecture patterns
|
||||
- **CLI Tool Integration**: Gemini for analysis, Qwen for architecture
|
||||
- **Structured Output**: Markdown reports with severity levels and action items
|
||||
@@ -295,3 +312,11 @@ Optional Review (when needed):
|
||||
- Regular development (tests are sufficient)
|
||||
- Simple bug fixes (test-fix-agent handles it)
|
||||
- Minor changes (update-memory-related is enough)
|
||||
|
||||
## Post-Review Action
|
||||
|
||||
After review completion, prompt user:
|
||||
```
|
||||
Review complete. Would you like to complete and archive this session?
|
||||
→ Run /workflow:session:complete to archive with lessons learned
|
||||
```
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
---
|
||||
name: complete
|
||||
description: Mark active workflow session as complete, archive with lessons learned, update manifest, remove active flag
|
||||
argument-hint: "[-y|--yes] [--detailed]"
|
||||
examples:
|
||||
- /workflow:session:complete
|
||||
- /workflow:session:complete --yes
|
||||
- /workflow:session:complete --detailed
|
||||
---
|
||||
|
||||
@@ -107,13 +109,13 @@ rm -f .workflow/archives/$SESSION_ID/.archiving
|
||||
Manifest: Updated with N total sessions
|
||||
```
|
||||
|
||||
### Phase 4: Update project.json (Optional)
|
||||
### Phase 4: Update project-tech.json (Optional)
|
||||
|
||||
**Skip if**: `.workflow/project.json` doesn't exist
|
||||
**Skip if**: `.workflow/project-tech.json` doesn't exist
|
||||
|
||||
```bash
|
||||
# Check
|
||||
test -f .workflow/project.json || echo "SKIP"
|
||||
test -f .workflow/project-tech.json || echo "SKIP"
|
||||
```
|
||||
|
||||
**If exists**, add feature entry:
|
||||
@@ -134,6 +136,53 @@ test -f .workflow/project.json || echo "SKIP"
|
||||
✓ Feature added to project registry
|
||||
```
|
||||
|
||||
### Phase 5: Ask About Solidify (Always)
|
||||
|
||||
After successful archival, prompt user to capture learnings:
|
||||
|
||||
```javascript
|
||||
// Parse --yes flag
|
||||
const autoYes = $ARGUMENTS.includes('--yes') || $ARGUMENTS.includes('-y')
|
||||
|
||||
if (autoYes) {
|
||||
// Auto mode: Skip solidify
|
||||
console.log(`[--yes] Auto-selecting: Skip solidify`)
|
||||
console.log(`Session archived successfully.`)
|
||||
// Done - no solidify
|
||||
} else {
|
||||
// Interactive mode: Ask user
|
||||
AskUserQuestion({
|
||||
questions: [{
|
||||
question: "Would you like to solidify learnings from this session into project guidelines?",
|
||||
header: "Solidify",
|
||||
options: [
|
||||
{ label: "Yes, solidify now", description: "Extract learnings and update project-guidelines.json" },
|
||||
{ label: "Skip", description: "Archive complete, no learnings to capture" }
|
||||
],
|
||||
multiSelect: false
|
||||
}]
|
||||
})
|
||||
|
||||
// **If "Yes, solidify now"**: Execute `/workflow:session:solidify` with the archived session ID.
|
||||
}
|
||||
```
|
||||
|
||||
## Auto Mode Defaults
|
||||
|
||||
When `--yes` or `-y` flag is used:
|
||||
- **Solidify Learnings**: Auto-selected "Skip" (archive only, no solidify)
|
||||
|
||||
**Flag Parsing**:
|
||||
```javascript
|
||||
const autoYes = $ARGUMENTS.includes('--yes') || $ARGUMENTS.includes('-y')
|
||||
```
|
||||
|
||||
**Output**:
|
||||
```
|
||||
Session archived successfully.
|
||||
→ Run /workflow:session:solidify to capture learnings (recommended)
|
||||
```
|
||||
|
||||
## Error Recovery
|
||||
|
||||
| Phase | Symptom | Recovery |
|
||||
@@ -149,5 +198,6 @@ test -f .workflow/project.json || echo "SKIP"
|
||||
Phase 1: find session → create .archiving marker
|
||||
Phase 2: read key files → build manifest entry (no writes)
|
||||
Phase 3: mkdir → mv → update manifest.json → rm marker
|
||||
Phase 4: update project.json features array (optional)
|
||||
Phase 4: update project-tech.json features array (optional)
|
||||
Phase 5: ask user → solidify learnings (optional)
|
||||
```
|
||||
|
||||
303
.claude/commands/workflow/session/solidify.md
Normal file
303
.claude/commands/workflow/session/solidify.md
Normal file
@@ -0,0 +1,303 @@
|
||||
---
|
||||
name: solidify
|
||||
description: Crystallize session learnings and user-defined constraints into permanent project guidelines
|
||||
argument-hint: "[-y|--yes] [--type <convention|constraint|learning>] [--category <category>] \"rule or insight\""
|
||||
examples:
|
||||
- /workflow:session:solidify "Use functional components for all React code" --type convention
|
||||
- /workflow:session:solidify -y "No direct DB access from controllers" --type constraint --category architecture
|
||||
- /workflow:session:solidify "Cache invalidation requires event sourcing" --type learning --category architecture
|
||||
- /workflow:session:solidify --interactive
|
||||
---
|
||||
|
||||
## Auto Mode
|
||||
|
||||
When `--yes` or `-y`: Auto-categorize and add guideline without confirmation.
|
||||
|
||||
# Session Solidify Command (/workflow:session:solidify)
|
||||
|
||||
## Overview
|
||||
|
||||
Crystallizes ephemeral session context (insights, decisions, constraints) into permanent project guidelines stored in `.workflow/project-guidelines.json`. This ensures valuable learnings persist across sessions and inform future planning.
|
||||
|
||||
## Use Cases
|
||||
|
||||
1. **During Session**: Capture important decisions as they're made
|
||||
2. **After Session**: Reflect on lessons learned before archiving
|
||||
3. **Proactive**: Add team conventions or architectural rules
|
||||
|
||||
## Parameters
|
||||
|
||||
| Parameter | Type | Required | Description |
|
||||
|-----------|------|----------|-------------|
|
||||
| `rule` | string | ✅ (unless --interactive) | The rule, convention, or insight to solidify |
|
||||
| `--type` | enum | ❌ | Type: `convention`, `constraint`, `learning` (default: auto-detect) |
|
||||
| `--category` | string | ❌ | Category for organization (see categories below) |
|
||||
| `--interactive` | flag | ❌ | Launch guided wizard for adding rules |
|
||||
|
||||
### Type Categories
|
||||
|
||||
**convention** → Coding style preferences (goes to `conventions` section)
|
||||
- Subcategories: `coding_style`, `naming_patterns`, `file_structure`, `documentation`
|
||||
|
||||
**constraint** → Hard rules that must not be violated (goes to `constraints` section)
|
||||
- Subcategories: `architecture`, `tech_stack`, `performance`, `security`
|
||||
|
||||
**learning** → Session-specific insights (goes to `learnings` array)
|
||||
- Subcategories: `architecture`, `performance`, `security`, `testing`, `process`, `other`
|
||||
|
||||
## Execution Process
|
||||
|
||||
```
|
||||
Input Parsing:
|
||||
├─ Parse: rule text (required unless --interactive)
|
||||
├─ Parse: --type (convention|constraint|learning)
|
||||
├─ Parse: --category (subcategory)
|
||||
└─ Parse: --interactive (flag)
|
||||
|
||||
Step 1: Ensure Guidelines File Exists
|
||||
└─ If not exists → Create with empty structure
|
||||
|
||||
Step 2: Auto-detect Type (if not specified)
|
||||
└─ Analyze rule text for keywords
|
||||
|
||||
Step 3: Validate and Format Entry
|
||||
└─ Build entry object based on type
|
||||
|
||||
Step 4: Update Guidelines File
|
||||
└─ Add entry to appropriate section
|
||||
|
||||
Step 5: Display Confirmation
|
||||
└─ Show what was added and where
|
||||
```
|
||||
|
||||
## Implementation
|
||||
|
||||
### Step 1: Ensure Guidelines File Exists
|
||||
|
||||
```bash
|
||||
bash(test -f .workflow/project-guidelines.json && echo "EXISTS" || echo "NOT_FOUND")
|
||||
```
|
||||
|
||||
**If NOT_FOUND**, create scaffold:
|
||||
|
||||
```javascript
|
||||
const scaffold = {
|
||||
conventions: {
|
||||
coding_style: [],
|
||||
naming_patterns: [],
|
||||
file_structure: [],
|
||||
documentation: []
|
||||
},
|
||||
constraints: {
|
||||
architecture: [],
|
||||
tech_stack: [],
|
||||
performance: [],
|
||||
security: []
|
||||
},
|
||||
quality_rules: [],
|
||||
learnings: [],
|
||||
_metadata: {
|
||||
created_at: new Date().toISOString(),
|
||||
version: "1.0.0"
|
||||
}
|
||||
};
|
||||
|
||||
Write('.workflow/project-guidelines.json', JSON.stringify(scaffold, null, 2));
|
||||
```
|
||||
|
||||
### Step 2: Auto-detect Type (if not specified)
|
||||
|
||||
```javascript
|
||||
function detectType(ruleText) {
|
||||
const text = ruleText.toLowerCase();
|
||||
|
||||
// Constraint indicators
|
||||
if (/\b(no|never|must not|forbidden|prohibited|always must)\b/.test(text)) {
|
||||
return 'constraint';
|
||||
}
|
||||
|
||||
// Learning indicators
|
||||
if (/\b(learned|discovered|realized|found that|turns out)\b/.test(text)) {
|
||||
return 'learning';
|
||||
}
|
||||
|
||||
// Default to convention
|
||||
return 'convention';
|
||||
}
|
||||
|
||||
function detectCategory(ruleText, type) {
|
||||
const text = ruleText.toLowerCase();
|
||||
|
||||
if (type === 'constraint' || type === 'learning') {
|
||||
if (/\b(architecture|layer|module|dependency|circular)\b/.test(text)) return 'architecture';
|
||||
if (/\b(security|auth|permission|sanitize|xss|sql)\b/.test(text)) return 'security';
|
||||
if (/\b(performance|cache|lazy|async|sync|slow)\b/.test(text)) return 'performance';
|
||||
if (/\b(test|coverage|mock|stub)\b/.test(text)) return 'testing';
|
||||
}
|
||||
|
||||
if (type === 'convention') {
|
||||
if (/\b(name|naming|prefix|suffix|camel|pascal)\b/.test(text)) return 'naming_patterns';
|
||||
if (/\b(file|folder|directory|structure|organize)\b/.test(text)) return 'file_structure';
|
||||
if (/\b(doc|comment|jsdoc|readme)\b/.test(text)) return 'documentation';
|
||||
return 'coding_style';
|
||||
}
|
||||
|
||||
return type === 'constraint' ? 'tech_stack' : 'other';
|
||||
}
|
||||
```
|
||||
|
||||
### Step 3: Build Entry
|
||||
|
||||
```javascript
|
||||
function buildEntry(rule, type, category, sessionId) {
|
||||
if (type === 'learning') {
|
||||
return {
|
||||
date: new Date().toISOString().split('T')[0],
|
||||
session_id: sessionId || null,
|
||||
insight: rule,
|
||||
category: category,
|
||||
context: null
|
||||
};
|
||||
}
|
||||
|
||||
// For conventions and constraints, just return the rule string
|
||||
return rule;
|
||||
}
|
||||
```
|
||||
|
||||
### Step 4: Update Guidelines File
|
||||
|
||||
```javascript
|
||||
const guidelines = JSON.parse(Read('.workflow/project-guidelines.json'));
|
||||
|
||||
if (type === 'convention') {
|
||||
if (!guidelines.conventions[category]) {
|
||||
guidelines.conventions[category] = [];
|
||||
}
|
||||
if (!guidelines.conventions[category].includes(rule)) {
|
||||
guidelines.conventions[category].push(rule);
|
||||
}
|
||||
} else if (type === 'constraint') {
|
||||
if (!guidelines.constraints[category]) {
|
||||
guidelines.constraints[category] = [];
|
||||
}
|
||||
if (!guidelines.constraints[category].includes(rule)) {
|
||||
guidelines.constraints[category].push(rule);
|
||||
}
|
||||
} else if (type === 'learning') {
|
||||
guidelines.learnings.push(buildEntry(rule, type, category, sessionId));
|
||||
}
|
||||
|
||||
guidelines._metadata.updated_at = new Date().toISOString();
|
||||
guidelines._metadata.last_solidified_by = sessionId;
|
||||
|
||||
Write('.workflow/project-guidelines.json', JSON.stringify(guidelines, null, 2));
|
||||
```
|
||||
|
||||
### Step 5: Display Confirmation
|
||||
|
||||
```
|
||||
✓ Guideline solidified
|
||||
|
||||
Type: ${type}
|
||||
Category: ${category}
|
||||
Rule: "${rule}"
|
||||
|
||||
Location: .workflow/project-guidelines.json → ${type}s.${category}
|
||||
|
||||
Total ${type}s in ${category}: ${count}
|
||||
```
|
||||
|
||||
## Interactive Mode
|
||||
|
||||
When `--interactive` flag is provided:
|
||||
|
||||
```javascript
|
||||
AskUserQuestion({
|
||||
questions: [
|
||||
{
|
||||
question: "What type of guideline are you adding?",
|
||||
header: "Type",
|
||||
multiSelect: false,
|
||||
options: [
|
||||
{ label: "Convention", description: "Coding style preference (e.g., use functional components)" },
|
||||
{ label: "Constraint", description: "Hard rule that must not be violated (e.g., no direct DB access)" },
|
||||
{ label: "Learning", description: "Insight from this session (e.g., cache invalidation needs events)" }
|
||||
]
|
||||
}
|
||||
]
|
||||
});
|
||||
|
||||
// Follow-up based on type selection...
|
||||
```
|
||||
|
||||
## Examples
|
||||
|
||||
### Add a Convention
|
||||
```bash
|
||||
/workflow:session:solidify "Use async/await instead of callbacks" --type convention --category coding_style
|
||||
```
|
||||
|
||||
Result in `project-guidelines.json`:
|
||||
```json
|
||||
{
|
||||
"conventions": {
|
||||
"coding_style": ["Use async/await instead of callbacks"]
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### Add an Architectural Constraint
|
||||
```bash
|
||||
/workflow:session:solidify "No direct DB access from controllers" --type constraint --category architecture
|
||||
```
|
||||
|
||||
Result:
|
||||
```json
|
||||
{
|
||||
"constraints": {
|
||||
"architecture": ["No direct DB access from controllers"]
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### Capture a Session Learning
|
||||
```bash
|
||||
/workflow:session:solidify "Cache invalidation requires event sourcing for consistency" --type learning
|
||||
```
|
||||
|
||||
Result:
|
||||
```json
|
||||
{
|
||||
"learnings": [
|
||||
{
|
||||
"date": "2024-12-28",
|
||||
"session_id": "WFS-auth-feature",
|
||||
"insight": "Cache invalidation requires event sourcing for consistency",
|
||||
"category": "architecture"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
## Integration with Planning
|
||||
|
||||
The `project-guidelines.json` is consumed by:
|
||||
|
||||
1. **`/workflow:tools:context-gather`**: Loads guidelines into context-package.json
|
||||
2. **`/workflow:plan`**: Passes guidelines to task generation agent
|
||||
3. **`task-generate-agent`**: Includes guidelines as "CRITICAL CONSTRAINTS" in system prompt
|
||||
|
||||
This ensures all future planning respects solidified rules without users needing to re-state them.
|
||||
|
||||
## Error Handling
|
||||
|
||||
- **Duplicate Rule**: Warn and skip if exact rule already exists
|
||||
- **Invalid Category**: Suggest valid categories for the type
|
||||
- **File Corruption**: Backup existing file before modification
|
||||
|
||||
## Related Commands
|
||||
|
||||
- `/workflow:session:start` - Start a session (may prompt for solidify at end)
|
||||
- `/workflow:session:complete` - Complete session (prompts for learnings to solidify)
|
||||
- `/workflow:init` - Creates project-guidelines.json scaffold if missing
|
||||
@@ -16,7 +16,7 @@ examples:
|
||||
Manages workflow sessions with three operation modes: discovery (manual), auto (intelligent), and force-new.
|
||||
|
||||
**Dual Responsibility**:
|
||||
1. **Project-level initialization** (first-time only): Creates `.workflow/project.json` for feature registry
|
||||
1. **Project-level initialization** (first-time only): Creates `.workflow/project-tech.json` for feature registry
|
||||
2. **Session-level initialization** (always): Creates session directory structure
|
||||
|
||||
## Session Types
|
||||
@@ -38,26 +38,29 @@ ERROR: Invalid session type. Valid types: workflow, review, tdd, test, docs
|
||||
|
||||
## Step 0: Initialize Project State (First-time Only)
|
||||
|
||||
**Executed before all modes** - Ensures project-level state file exists by calling `/workflow:init`.
|
||||
**Executed before all modes** - Ensures project-level state files exist by calling `/workflow:init`.
|
||||
|
||||
### Check and Initialize
|
||||
```bash
|
||||
# Check if project state exists
|
||||
bash(test -f .workflow/project.json && echo "EXISTS" || echo "NOT_FOUND")
|
||||
# Check if project state exists (both files required)
|
||||
bash(test -f .workflow/project-tech.json && echo "TECH_EXISTS" || echo "TECH_NOT_FOUND")
|
||||
bash(test -f .workflow/project-guidelines.json && echo "GUIDELINES_EXISTS" || echo "GUIDELINES_NOT_FOUND")
|
||||
```
|
||||
|
||||
**If NOT_FOUND**, delegate to `/workflow:init`:
|
||||
**If either NOT_FOUND**, delegate to `/workflow:init`:
|
||||
```javascript
|
||||
// Call workflow:init for intelligent project analysis
|
||||
SlashCommand({command: "/workflow:init"});
|
||||
Skill(skill="workflow:init");
|
||||
|
||||
// Wait for init completion
|
||||
// project.json will be created with comprehensive project overview
|
||||
// project-tech.json and project-guidelines.json will be created
|
||||
```
|
||||
|
||||
**Output**:
|
||||
- If EXISTS: `PROJECT_STATE: initialized`
|
||||
- If NOT_FOUND: Calls `/workflow:init` → creates `.workflow/project.json` with full project analysis
|
||||
- If BOTH_EXIST: `PROJECT_STATE: initialized`
|
||||
- If NOT_FOUND: Calls `/workflow:init` → creates:
|
||||
- `.workflow/project-tech.json` with full technical analysis
|
||||
- `.workflow/project-guidelines.json` with empty scaffold
|
||||
|
||||
**Note**: `/workflow:init` uses cli-explore-agent to build comprehensive project understanding (technology stack, architecture, key components). This step runs once per project. Subsequent executions skip initialization.
|
||||
|
||||
|
||||
@@ -2,49 +2,87 @@
|
||||
name: tdd-plan
|
||||
description: TDD workflow planning with Red-Green-Refactor task chain generation, test-first development structure, and cycle tracking
|
||||
argument-hint: "\"feature description\"|file.md"
|
||||
allowed-tools: SlashCommand(*), TodoWrite(*), Read(*), Bash(*)
|
||||
allowed-tools: Skill(*), TodoWrite(*), Read(*), Bash(*)
|
||||
---
|
||||
|
||||
# TDD Workflow Plan Command (/workflow:tdd-plan)
|
||||
|
||||
## Coordinator Role
|
||||
|
||||
**This command is a pure orchestrator**: Dispatches 6 slash commands in sequence, parse outputs, pass context, and ensure complete TDD workflow creation with Red-Green-Refactor task generation.
|
||||
**This command is a pure orchestrator**: Executes 6 slash commands in sequence, parse outputs, pass context, and ensure complete TDD workflow creation with Red-Green-Refactor task generation.
|
||||
|
||||
**CLI Tool Selection**: CLI tool usage is determined semantically from user's task description. Include "use Codex/Gemini/Qwen" in your request for CLI execution.
|
||||
|
||||
**Task Attachment Model**:
|
||||
- SlashCommand dispatch **expands workflow** by attaching sub-tasks to current TodoWrite
|
||||
- When dispatching a sub-command (e.g., `/workflow:tools:test-context-gather`), its internal tasks are attached to the orchestrator's TodoWrite
|
||||
- Skill execute **expands workflow** by attaching sub-tasks to current TodoWrite
|
||||
- When executing a sub-command (e.g., `/workflow:tools:test-context-gather`), its internal tasks are attached to the orchestrator's TodoWrite
|
||||
- Orchestrator **executes these attached tasks** sequentially
|
||||
- After completion, attached tasks are **collapsed** back to high-level phase summary
|
||||
- This is **task expansion**, not external delegation
|
||||
|
||||
**Auto-Continue Mechanism**:
|
||||
- TodoList tracks current phase status and dynamically manages task attachment/collapse
|
||||
- When each phase finishes executing, automatically dispatch next pending phase
|
||||
- When each phase finishes executing, automatically execute next pending phase
|
||||
- All phases run autonomously without user interaction
|
||||
- **⚠️ CONTINUOUS EXECUTION** - Do not stop until all phases complete
|
||||
|
||||
## Core Rules
|
||||
|
||||
1. **Start Immediately**: First action is TodoWrite initialization, second action is dispatch Phase 1
|
||||
1. **Start Immediately**: First action is TodoWrite initialization, second action is execute Phase 1
|
||||
2. **No Preliminary Analysis**: Do not read files before Phase 1
|
||||
3. **Parse Every Output**: Extract required data for next phase
|
||||
4. **Auto-Continue via TodoList**: Check TodoList status to dispatch next pending phase automatically
|
||||
4. **Auto-Continue via TodoList**: Check TodoList status to execute next pending phase automatically
|
||||
5. **Track Progress**: Update TodoWrite dynamically with task attachment/collapse pattern
|
||||
6. **TDD Context**: All descriptions include "TDD:" prefix
|
||||
7. **Task Attachment Model**: SlashCommand dispatch **attaches** sub-tasks to current workflow. Orchestrator **executes** these attached tasks itself, then **collapses** them after completion
|
||||
8. **⚠️ CRITICAL: DO NOT STOP**: Continuous multi-phase workflow. After executing all attached tasks, immediately collapse them and dispatch next phase
|
||||
7. **Task Attachment Model**: Skill execute **attaches** sub-tasks to current workflow. Orchestrator **executes** these attached tasks itself, then **collapses** them after completion
|
||||
8. **⚠️ CRITICAL: DO NOT STOP**: Continuous multi-phase workflow. After executing all attached tasks, immediately collapse them and execute next phase
|
||||
|
||||
## TDD Compliance Requirements
|
||||
|
||||
### The Iron Law
|
||||
|
||||
```
|
||||
NO PRODUCTION CODE WITHOUT A FAILING TEST FIRST
|
||||
```
|
||||
|
||||
**Enforcement Method**:
|
||||
- Phase 5: `implementation_approach` includes test-first steps (Red → Green → Refactor)
|
||||
- Green phase: Includes test-fix-cycle configuration (max 3 iterations)
|
||||
- Auto-revert: Triggered when max iterations reached without passing tests
|
||||
|
||||
**Verification**: Phase 6 validates Red-Green-Refactor structure in all generated tasks
|
||||
|
||||
### TDD Compliance Checkpoint
|
||||
|
||||
| Checkpoint | Validation Phase | Evidence Required |
|
||||
|------------|------------------|-------------------|
|
||||
| Test-first structure | Phase 5 | `implementation_approach` has 3 steps |
|
||||
| Red phase exists | Phase 6 | Step 1: `tdd_phase: "red"` |
|
||||
| Green phase with test-fix | Phase 6 | Step 2: `tdd_phase: "green"` + test-fix-cycle |
|
||||
| Refactor phase exists | Phase 6 | Step 3: `tdd_phase: "refactor"` |
|
||||
|
||||
### Core TDD Principles (from ref skills)
|
||||
|
||||
**Red Flags - STOP and Reassess**:
|
||||
- Code written before test
|
||||
- Test passes immediately (no Red phase witnessed)
|
||||
- Cannot explain why test should fail
|
||||
- "Just this once" rationalization
|
||||
- "Tests after achieve same goals" thinking
|
||||
|
||||
**Why Order Matters**:
|
||||
- Tests written after code pass immediately → proves nothing
|
||||
- Test-first forces edge case discovery before implementation
|
||||
- Tests-after verify what was built, not what's required
|
||||
|
||||
## 6-Phase Execution (with Conflict Resolution)
|
||||
|
||||
### Phase 1: Session Discovery
|
||||
|
||||
**Step 1.1: Dispatch** - Session discovery and initialization
|
||||
**Step 1.1: Execute** - Session discovery and initialization
|
||||
|
||||
```javascript
|
||||
SlashCommand(command="/workflow:session:start --type tdd --auto \"TDD: [structured-description]\"")
|
||||
Skill(skill="workflow:session:start", args="--type tdd --auto \"TDD: [structured-description]\"")
|
||||
```
|
||||
|
||||
**TDD Structured Format**:
|
||||
@@ -66,10 +104,10 @@ TEST_FOCUS: [Test scenarios]
|
||||
|
||||
### Phase 2: Context Gathering
|
||||
|
||||
**Step 2.1: Dispatch** - Context gathering and analysis
|
||||
**Step 2.1: Execute** - Context gathering and analysis
|
||||
|
||||
```javascript
|
||||
SlashCommand(command="/workflow:tools:context-gather --session [sessionId] \"TDD: [structured-description]\"")
|
||||
Skill(skill="workflow:tools:context-gather", args="--session [sessionId] \"TDD: [structured-description]\"")
|
||||
```
|
||||
|
||||
**Use Same Structured Description**: Pass the same structured format from Phase 1
|
||||
@@ -92,10 +130,10 @@ SlashCommand(command="/workflow:tools:context-gather --session [sessionId] \"TDD
|
||||
|
||||
### Phase 3: Test Coverage Analysis
|
||||
|
||||
**Step 3.1: Dispatch** - Test coverage analysis and framework detection
|
||||
**Step 3.1: Execute** - Test coverage analysis and framework detection
|
||||
|
||||
```javascript
|
||||
SlashCommand(command="/workflow:tools:test-context-gather --session [sessionId]")
|
||||
Skill(skill="workflow:tools:test-context-gather", args="--session [sessionId]")
|
||||
```
|
||||
|
||||
**Purpose**: Analyze existing codebase for:
|
||||
@@ -108,9 +146,9 @@ SlashCommand(command="/workflow:tools:test-context-gather --session [sessionId]"
|
||||
|
||||
|
||||
|
||||
<!-- TodoWrite: When test-context-gather dispatched, INSERT 3 test-context-gather tasks -->
|
||||
<!-- TodoWrite: When test-context-gather executed, INSERT 3 test-context-gather tasks -->
|
||||
|
||||
**TodoWrite Update (Phase 3 SlashCommand dispatched - tasks attached)**:
|
||||
**TodoWrite Update (Phase 3 Skill executed - tasks attached)**:
|
||||
```json
|
||||
[
|
||||
{"content": "Phase 1: Session Discovery", "status": "completed", "activeForm": "Executing session discovery"},
|
||||
@@ -124,7 +162,7 @@ SlashCommand(command="/workflow:tools:test-context-gather --session [sessionId]"
|
||||
]
|
||||
```
|
||||
|
||||
**Note**: SlashCommand dispatch **attaches** test-context-gather's 3 tasks. Orchestrator **executes** these tasks.
|
||||
**Note**: Skill execute **attaches** test-context-gather's 3 tasks. Orchestrator **executes** these tasks.
|
||||
|
||||
**Next Action**: Tasks attached → **Execute Phase 3.1-3.3** sequentially
|
||||
|
||||
@@ -151,10 +189,10 @@ SlashCommand(command="/workflow:tools:test-context-gather --session [sessionId]"
|
||||
|
||||
**Trigger**: Only execute when context-package.json indicates conflict_risk is "medium" or "high"
|
||||
|
||||
**Step 4.1: Dispatch** - Conflict detection and resolution
|
||||
**Step 4.1: Execute** - Conflict detection and resolution
|
||||
|
||||
```javascript
|
||||
SlashCommand(command="/workflow:tools:conflict-resolution --session [sessionId] --context [contextPath]")
|
||||
Skill(skill="workflow:tools:conflict-resolution", args="--session [sessionId] --context [contextPath]")
|
||||
```
|
||||
|
||||
**Input**:
|
||||
@@ -173,9 +211,9 @@ SlashCommand(command="/workflow:tools:conflict-resolution --session [sessionId]
|
||||
- If conflict_risk is "none" or "low", skip directly to Phase 5
|
||||
- Display: "No significant conflicts detected, proceeding to TDD task generation"
|
||||
|
||||
<!-- TodoWrite: If conflict_risk ≥ medium, INSERT 3 conflict-resolution tasks when dispatched -->
|
||||
<!-- TodoWrite: If conflict_risk ≥ medium, INSERT 3 conflict-resolution tasks when executed -->
|
||||
|
||||
**TodoWrite Update (Phase 4 SlashCommand dispatched - tasks attached, if conflict_risk ≥ medium)**:
|
||||
**TodoWrite Update (Phase 4 Skill executed - tasks attached, if conflict_risk ≥ medium)**:
|
||||
```json
|
||||
[
|
||||
{"content": "Phase 1: Session Discovery", "status": "completed", "activeForm": "Executing session discovery"},
|
||||
@@ -183,14 +221,14 @@ SlashCommand(command="/workflow:tools:conflict-resolution --session [sessionId]
|
||||
{"content": "Phase 3: Test Coverage Analysis", "status": "completed", "activeForm": "Executing test coverage analysis"},
|
||||
{"content": "Phase 4: Conflict Resolution", "status": "in_progress", "activeForm": "Executing conflict resolution"},
|
||||
{"content": " → Detect conflicts with CLI analysis", "status": "in_progress", "activeForm": "Detecting conflicts"},
|
||||
{"content": " → Present conflicts to user", "status": "pending", "activeForm": "Presenting conflicts"},
|
||||
{"content": " → Log and analyze detected conflicts", "status": "pending", "activeForm": "Analyzing conflicts"},
|
||||
{"content": " → Apply resolution strategies", "status": "pending", "activeForm": "Applying resolution strategies"},
|
||||
{"content": "Phase 5: TDD Task Generation", "status": "pending", "activeForm": "Executing TDD task generation"},
|
||||
{"content": "Phase 6: TDD Structure Validation", "status": "pending", "activeForm": "Validating TDD structure"}
|
||||
]
|
||||
```
|
||||
|
||||
**Note**: SlashCommand dispatch **attaches** conflict-resolution's 3 tasks. Orchestrator **executes** these tasks.
|
||||
**Note**: Skill execute **attaches** conflict-resolution's 3 tasks. Orchestrator **executes** these tasks.
|
||||
|
||||
**Next Action**: Tasks attached → **Execute Phase 4.1-4.3** sequentially
|
||||
|
||||
@@ -216,10 +254,10 @@ SlashCommand(command="/workflow:tools:conflict-resolution --session [sessionId]
|
||||
- Evaluate current context window usage and memory state
|
||||
- If memory usage is high (>110K tokens or approaching context limits):
|
||||
|
||||
**Step 4.5: Dispatch** - Memory compaction
|
||||
**Step 4.5: Execute** - Memory compaction
|
||||
|
||||
```javascript
|
||||
SlashCommand(command="/compact")
|
||||
Skill(skill="compact")
|
||||
```
|
||||
|
||||
- This optimizes memory before proceeding to Phase 5
|
||||
@@ -230,15 +268,19 @@ SlashCommand(command="/workflow:tools:conflict-resolution --session [sessionId]
|
||||
|
||||
### Phase 5: TDD Task Generation
|
||||
|
||||
**Step 5.1: Dispatch** - TDD task generation via action-planning-agent
|
||||
**Step 5.1: Execute** - TDD task generation via action-planning-agent with Phase 0 user configuration
|
||||
|
||||
```javascript
|
||||
SlashCommand(command="/workflow:tools:task-generate-tdd --session [sessionId]")
|
||||
Skill(skill="workflow:tools:task-generate-tdd", args="--session [sessionId]")
|
||||
```
|
||||
|
||||
**Note**: CLI tool usage is determined semantically from user's task description.
|
||||
**Note**: Phase 0 now includes:
|
||||
- Supplementary materials collection (file paths or inline content)
|
||||
- Execution method preference (Agent/Hybrid/CLI)
|
||||
- CLI tool preference (Codex/Gemini/Qwen/Auto)
|
||||
- These preferences are passed to agent for task generation
|
||||
|
||||
**Parse**: Extract feature count, task count (not chain count - tasks now contain internal TDD cycles)
|
||||
**Parse**: Extract feature count, task count (not chain count - tasks now contain internal TDD cycles), CLI execution IDs assigned
|
||||
|
||||
**Validate**:
|
||||
- IMPL_PLAN.md exists (unified plan with TDD Implementation Tasks section)
|
||||
@@ -246,14 +288,30 @@ SlashCommand(command="/workflow:tools:task-generate-tdd --session [sessionId]")
|
||||
- TODO_LIST.md exists with internal TDD phase indicators
|
||||
- Each IMPL task includes:
|
||||
- `meta.tdd_workflow: true`
|
||||
- `flow_control.implementation_approach` with 3 steps (red/green/refactor)
|
||||
- `meta.cli_execution_id: {session_id}-{task_id}`
|
||||
- `meta.cli_execution: { "strategy": "new|resume|fork|merge_fork", ... }`
|
||||
- `flow_control.implementation_approach` with exactly 3 steps (red/green/refactor)
|
||||
- Green phase includes test-fix-cycle configuration
|
||||
- `context.focus_paths`: absolute or clear relative paths (enhanced with exploration critical_files)
|
||||
- `flow_control.pre_analysis`: includes exploration integration_points analysis
|
||||
- IMPL_PLAN.md contains workflow_type: "tdd" in frontmatter
|
||||
- Task count ≤10 (compliance with task limit)
|
||||
- User configuration applied:
|
||||
- If executionMethod == "cli" or "hybrid": command field added to steps
|
||||
- CLI tool preference reflected in execution guidance
|
||||
- Task count ≤18 (compliance with hard limit)
|
||||
|
||||
<!-- TodoWrite: When task-generate-tdd dispatched, INSERT 3 task-generate-tdd tasks -->
|
||||
**Red Flag Detection** (Non-Blocking Warnings):
|
||||
- Task count >18: `⚠️ Task count exceeds hard limit - request re-scope`
|
||||
- Missing cli_execution_id: `⚠️ Task lacks CLI execution ID for resume support`
|
||||
- Missing test-fix-cycle: `⚠️ Green phase lacks auto-revert configuration`
|
||||
- Generic task names: `⚠️ Vague task names suggest unclear TDD cycles`
|
||||
- Missing focus_paths: `⚠️ Task lacks clear file scope for implementation`
|
||||
|
||||
**TodoWrite Update (Phase 5 SlashCommand dispatched - tasks attached)**:
|
||||
**Action**: Log warnings to `.workflow/active/[sessionId]/.process/tdd-warnings.log` (non-blocking)
|
||||
|
||||
<!-- TodoWrite: When task-generate-tdd executed, INSERT 3 task-generate-tdd tasks -->
|
||||
|
||||
**TodoWrite Update (Phase 5 Skill executed - tasks attached)**:
|
||||
```json
|
||||
[
|
||||
{"content": "Phase 1: Session Discovery", "status": "completed", "activeForm": "Executing session discovery"},
|
||||
@@ -267,7 +325,7 @@ SlashCommand(command="/workflow:tools:task-generate-tdd --session [sessionId]")
|
||||
]
|
||||
```
|
||||
|
||||
**Note**: SlashCommand dispatch **attaches** task-generate-tdd's 3 tasks. Orchestrator **executes** these tasks. Each generated IMPL task will contain internal Red-Green-Refactor cycle.
|
||||
**Note**: Skill execute **attaches** task-generate-tdd's 3 tasks. Orchestrator **executes** these tasks. Each generated IMPL task will contain internal Red-Green-Refactor cycle.
|
||||
|
||||
**Next Action**: Tasks attached → **Execute Phase 5.1-5.3** sequentially
|
||||
|
||||
@@ -293,14 +351,59 @@ SlashCommand(command="/workflow:tools:task-generate-tdd --session [sessionId]")
|
||||
1. Each task contains complete TDD workflow (Red-Green-Refactor internally)
|
||||
2. Task structure validation:
|
||||
- `meta.tdd_workflow: true` in all IMPL tasks
|
||||
- `meta.cli_execution_id` present (format: {session_id}-{task_id})
|
||||
- `meta.cli_execution` strategy assigned (new/resume/fork/merge_fork)
|
||||
- `flow_control.implementation_approach` has exactly 3 steps
|
||||
- Each step has correct `tdd_phase`: "red", "green", "refactor"
|
||||
- `context.focus_paths` are absolute or clear relative paths
|
||||
- `flow_control.pre_analysis` includes exploration integration analysis
|
||||
3. Dependency validation:
|
||||
- Sequential features: IMPL-N depends_on ["IMPL-(N-1)"] if needed
|
||||
- Complex features: IMPL-N.M depends_on ["IMPL-N.(M-1)"] for subtasks
|
||||
- CLI execution strategies correctly assigned based on dependency graph
|
||||
4. Agent assignment: All IMPL tasks use @code-developer
|
||||
5. Test-fix cycle: Green phase step includes test-fix-cycle logic with max_iterations
|
||||
6. Task count: Total tasks ≤10 (simple + subtasks)
|
||||
6. Task count: Total tasks ≤18 (simple + subtasks hard limit)
|
||||
7. User configuration:
|
||||
- Execution method choice reflected in task structure
|
||||
- CLI tool preference documented in implementation guidance (if CLI selected)
|
||||
|
||||
**Red Flag Checklist** (from TDD best practices):
|
||||
- [ ] No tasks skip Red phase (`tdd_phase: "red"` exists in step 1)
|
||||
- [ ] Test files referenced in Red phase (explicit paths, not placeholders)
|
||||
- [ ] Green phase has test-fix-cycle with `max_iterations` configured
|
||||
- [ ] Refactor phase has clear completion criteria
|
||||
|
||||
**Non-Compliance Warning Format**:
|
||||
```
|
||||
⚠️ TDD Red Flag: [issue description]
|
||||
Task: [IMPL-N]
|
||||
Recommendation: [action to fix]
|
||||
```
|
||||
|
||||
**Evidence Gathering** (Before Completion Claims):
|
||||
|
||||
```bash
|
||||
# Verify session artifacts exist
|
||||
ls -la .workflow/active/[sessionId]/{IMPL_PLAN.md,TODO_LIST.md}
|
||||
ls -la .workflow/active/[sessionId]/.task/IMPL-*.json
|
||||
|
||||
# Count generated artifacts
|
||||
echo "IMPL tasks: $(ls .workflow/active/[sessionId]/.task/IMPL-*.json 2>/dev/null | wc -l)"
|
||||
|
||||
# Sample task structure verification (first task)
|
||||
jq '{id, tdd: .meta.tdd_workflow, cli_id: .meta.cli_execution_id, phases: [.flow_control.implementation_approach[].tdd_phase]}' \
|
||||
"$(ls .workflow/active/[sessionId]/.task/IMPL-*.json | head -1)"
|
||||
```
|
||||
|
||||
**Evidence Required Before Summary**:
|
||||
| Evidence Type | Verification Method | Pass Criteria |
|
||||
|---------------|---------------------|---------------|
|
||||
| File existence | `ls -la` artifacts | All files present |
|
||||
| Task count | Count IMPL-*.json | Count matches claims (≤18) |
|
||||
| TDD structure | jq sample extraction | Shows red/green/refactor + cli_execution_id |
|
||||
| CLI execution IDs | jq extraction | All tasks have cli_execution_id assigned |
|
||||
| Warning log | Check tdd-warnings.log | Logged (may be empty) |
|
||||
|
||||
**Return Summary**:
|
||||
```
|
||||
@@ -312,7 +415,7 @@ Total tasks: [M] (1 task per simple feature + subtasks for complex features)
|
||||
Task breakdown:
|
||||
- Simple features: [K] tasks (IMPL-1 to IMPL-K)
|
||||
- Complex features: [L] features with [P] subtasks
|
||||
- Total task count: [M] (within 10-task limit)
|
||||
- Total task count: [M] (within 18-task hard limit)
|
||||
|
||||
Structure:
|
||||
- IMPL-1: {Feature 1 Name} (Internal: Red → Green → Refactor)
|
||||
@@ -326,19 +429,31 @@ Plans generated:
|
||||
- Unified Implementation Plan: .workflow/active/[sessionId]/IMPL_PLAN.md
|
||||
(includes TDD Implementation Tasks section with workflow_type: "tdd")
|
||||
- Task List: .workflow/active/[sessionId]/TODO_LIST.md
|
||||
(with internal TDD phase indicators)
|
||||
(with internal TDD phase indicators and CLI execution strategies)
|
||||
- Task JSONs: .workflow/active/[sessionId]/.task/IMPL-*.json
|
||||
(with cli_execution_id and execution strategies for resume support)
|
||||
|
||||
TDD Configuration:
|
||||
- Each task contains complete Red-Green-Refactor cycle
|
||||
- Green phase includes test-fix cycle (max 3 iterations)
|
||||
- Auto-revert on max iterations reached
|
||||
- CLI execution strategies: new/resume/fork/merge_fork based on dependency graph
|
||||
|
||||
User Configuration Applied:
|
||||
- Execution Method: [agent|hybrid|cli]
|
||||
- CLI Tool Preference: [codex|gemini|qwen|auto]
|
||||
- Supplementary Materials: [included|none]
|
||||
- Task generation follows cli-tools-usage.md guidelines
|
||||
|
||||
⚠️ ACTION REQUIRED: Before execution, ensure you understand WHY each Red phase test is expected to fail.
|
||||
This is crucial for valid TDD - if you don't know why the test fails, you can't verify it tests the right thing.
|
||||
|
||||
Recommended Next Steps:
|
||||
1. /workflow:action-plan-verify --session [sessionId] # Verify TDD plan quality and dependencies
|
||||
2. /workflow:execute --session [sessionId] # Start TDD execution
|
||||
1. /workflow:plan-verify --session [sessionId] # Verify TDD plan quality and dependencies
|
||||
2. /workflow:execute --session [sessionId] # Start TDD execution with CLI strategies
|
||||
3. /workflow:tdd-verify [sessionId] # Post-execution TDD compliance check
|
||||
|
||||
Quality Gate: Consider running /workflow:action-plan-verify to validate TDD task structure and dependencies
|
||||
Quality Gate: Consider running /workflow:plan-verify to validate TDD task structure, dependencies, and CLI execution strategies
|
||||
```
|
||||
|
||||
## TodoWrite Pattern
|
||||
@@ -347,7 +462,7 @@ Quality Gate: Consider running /workflow:action-plan-verify to validate TDD task
|
||||
|
||||
### Key Principles
|
||||
|
||||
1. **Task Attachment** (when SlashCommand dispatched):
|
||||
1. **Task Attachment** (when Skill executed):
|
||||
- Sub-command's internal tasks are **attached** to orchestrator's TodoWrite
|
||||
- Example: `/workflow:tools:test-context-gather` attaches 3 sub-tasks (Phase 3.1, 3.2, 3.3)
|
||||
- First attached task marked as `in_progress`, others as `pending`
|
||||
@@ -364,7 +479,7 @@ Quality Gate: Consider running /workflow:action-plan-verify to validate TDD task
|
||||
- No user intervention required between phases
|
||||
- TodoWrite dynamically reflects current execution state
|
||||
|
||||
**Lifecycle Summary**: Initial pending tasks → Phase dispatched (tasks ATTACHED) → Sub-tasks executed sequentially → Phase completed (tasks COLLAPSED to summary) → Next phase begins (conditional Phase 4 if conflict_risk ≥ medium) → Repeat until all phases complete.
|
||||
**Lifecycle Summary**: Initial pending tasks → Phase executed (tasks ATTACHED) → Sub-tasks executed sequentially → Phase completed (tasks COLLAPSED to summary) → Next phase begins (conditional Phase 4 if conflict_risk ≥ medium) → Repeat until all phases complete.
|
||||
|
||||
### TDD-Specific Features
|
||||
|
||||
@@ -400,7 +515,7 @@ TDD Workflow Orchestrator
|
||||
│ IF conflict_risk ≥ medium:
|
||||
│ └─ /workflow:tools:conflict-resolution ← ATTACHED (3 tasks)
|
||||
│ ├─ Phase 4.1: Detect conflicts with CLI
|
||||
│ ├─ Phase 4.2: Present conflicts to user
|
||||
│ ├─ Phase 4.2: Log and analyze detected conflicts
|
||||
│ └─ Phase 4.3: Apply resolution strategies
|
||||
│ └─ Returns: conflict-resolution.json ← COLLAPSED
|
||||
│ ELSE:
|
||||
@@ -416,10 +531,10 @@ TDD Workflow Orchestrator
|
||||
│
|
||||
└─ Phase 6: TDD Structure Validation
|
||||
└─ Internal validation + summary returned
|
||||
└─ Recommend: /workflow:action-plan-verify
|
||||
└─ Recommend: /workflow:plan-verify
|
||||
|
||||
Key Points:
|
||||
• ← ATTACHED: SlashCommand attaches sub-tasks to orchestrator TodoWrite
|
||||
• ← ATTACHED: Skill attaches sub-tasks to orchestrator TodoWrite
|
||||
• ← COLLAPSED: Sub-tasks executed and collapsed to phase summary
|
||||
• TDD-specific: Each generated IMPL task contains complete Red-Green-Refactor cycle
|
||||
```
|
||||
@@ -439,6 +554,36 @@ Convert user input to TDD-structured format:
|
||||
- **Command failure**: Keep phase in_progress, report error
|
||||
- **TDD validation failure**: Report incomplete chains or wrong dependencies
|
||||
|
||||
### TDD Warning Patterns
|
||||
|
||||
| Pattern | Warning Message | Recommended Action |
|
||||
|---------|----------------|-------------------|
|
||||
| Task count >10 | High task count detected | Consider splitting into multiple sessions |
|
||||
| Missing test-fix-cycle | Green phase lacks auto-revert | Add `max_iterations: 3` to task config |
|
||||
| Red phase missing test path | Test file path not specified | Add explicit test file paths |
|
||||
| Generic task names | Vague names like "Add feature" | Use specific behavior descriptions |
|
||||
| No refactor criteria | Refactor phase lacks completion criteria | Define clear refactor scope |
|
||||
|
||||
### Non-Blocking Warning Policy
|
||||
|
||||
**All warnings are advisory** - they do not halt execution:
|
||||
1. Warnings logged to `.process/tdd-warnings.log`
|
||||
2. Summary displayed in Phase 6 output
|
||||
3. User decides whether to address before `/workflow:execute`
|
||||
|
||||
### Error Handling Quick Reference
|
||||
|
||||
| Error Type | Detection | Recovery Action |
|
||||
|------------|-----------|-----------------|
|
||||
| Parsing failure | Empty/malformed output | Retry once, then report |
|
||||
| Missing context-package | File read error | Re-run `/workflow:tools:context-gather` |
|
||||
| Invalid task JSON | jq parse error | Report malformed file path |
|
||||
| Task count exceeds 18 | Count validation ≥19 | Request re-scope, split into multiple sessions |
|
||||
| Missing cli_execution_id | All tasks lack ID | Regenerate tasks with phase 0 user config |
|
||||
| Test-context missing | File not found | Re-run `/workflow:tools:test-context-gather` |
|
||||
| Phase timeout | No response | Retry phase, check CLI connectivity |
|
||||
| CLI tool not available | Tool not in cli-tools.json | Fall back to alternative preferred tool |
|
||||
|
||||
## Related Commands
|
||||
|
||||
**Prerequisite Commands**:
|
||||
@@ -453,8 +598,33 @@ Convert user input to TDD-structured format:
|
||||
- `/workflow:tools:task-generate-tdd` - Phase 5: Generate TDD tasks (CLI tool usage determined semantically)
|
||||
|
||||
**Follow-up Commands**:
|
||||
- `/workflow:action-plan-verify` - Recommended: Verify TDD plan quality and structure before execution
|
||||
- `/workflow:plan-verify` - Recommended: Verify TDD plan quality and structure before execution
|
||||
- `/workflow:status` - Review TDD task breakdown
|
||||
- `/workflow:execute` - Begin TDD implementation
|
||||
- `/workflow:tdd-verify` - Post-execution: Verify TDD compliance and generate quality report
|
||||
|
||||
## Next Steps Decision Table
|
||||
|
||||
| Situation | Recommended Command | Purpose |
|
||||
|-----------|---------------------|---------|
|
||||
| First time planning | `/workflow:plan-verify` | Validate task structure before execution |
|
||||
| Warnings in tdd-warnings.log | Review log, refine tasks | Address Red Flags before proceeding |
|
||||
| High task count warning | Consider `/workflow:session:start` | Split into focused sub-sessions |
|
||||
| Ready to implement | `/workflow:execute` | Begin TDD Red-Green-Refactor cycles |
|
||||
| After implementation | `/workflow:tdd-verify` | Generate TDD compliance report |
|
||||
| Need to review tasks | `/workflow:status --session [id]` | Inspect current task breakdown |
|
||||
| Plan needs changes | `/task:replan` | Update task JSON with new requirements |
|
||||
|
||||
### TDD Workflow State Transitions
|
||||
|
||||
```
|
||||
/workflow:tdd-plan
|
||||
↓
|
||||
[Planning Complete] ──→ /workflow:plan-verify (recommended)
|
||||
↓
|
||||
[Verified/Ready] ─────→ /workflow:execute
|
||||
↓
|
||||
[Implementation] ─────→ /workflow:tdd-verify (post-execution)
|
||||
↓
|
||||
[Quality Report] ─────→ Done or iterate
|
||||
```
|
||||
|
||||
@@ -1,214 +1,301 @@
|
||||
---
|
||||
name: tdd-verify
|
||||
description: Verify TDD workflow compliance against Red-Green-Refactor cycles, generate quality report with coverage analysis
|
||||
|
||||
argument-hint: "[optional: WFS-session-id]"
|
||||
allowed-tools: SlashCommand(*), TodoWrite(*), Read(*), Bash(gemini:*)
|
||||
description: Verify TDD workflow compliance against Red-Green-Refactor cycles. Generates quality report with coverage analysis and quality gate recommendation. Orchestrates sub-commands for comprehensive validation.
|
||||
argument-hint: "[optional: --session WFS-session-id]"
|
||||
allowed-tools: Skill(*), TodoWrite(*), Read(*), Write(*), Bash(*), Glob(*)
|
||||
---
|
||||
|
||||
# TDD Verification Command (/workflow:tdd-verify)
|
||||
|
||||
## Goal
|
||||
|
||||
Verify TDD workflow execution quality by validating Red-Green-Refactor cycle compliance, test coverage completeness, and task chain structure integrity. This command orchestrates multiple analysis phases and generates a comprehensive compliance report with quality gate recommendation.
|
||||
|
||||
**Output**: A structured Markdown report saved to `.workflow/active/WFS-{session}/TDD_COMPLIANCE_REPORT.md` containing:
|
||||
- Executive summary with compliance score and quality gate recommendation
|
||||
- Task chain validation (TEST → IMPL → REFACTOR structure)
|
||||
- Test coverage metrics (line, branch, function)
|
||||
- Red-Green-Refactor cycle verification
|
||||
- Best practices adherence assessment
|
||||
- Actionable improvement recommendations
|
||||
|
||||
## Operating Constraints
|
||||
|
||||
**ORCHESTRATOR MODE**:
|
||||
- This command coordinates multiple sub-commands (`/workflow:tools:tdd-coverage-analysis`, `ccw cli`)
|
||||
- MAY write output files: TDD_COMPLIANCE_REPORT.md (primary report), .process/*.json (intermediate artifacts)
|
||||
- MUST NOT modify source task files or implementation code
|
||||
- MUST NOT create or delete tasks in the workflow
|
||||
|
||||
**Quality Gate Authority**: The compliance report provides a binding recommendation (BLOCK_MERGE / REQUIRE_FIXES / PROCEED_WITH_CAVEATS / APPROVED) based on objective compliance criteria.
|
||||
|
||||
## Coordinator Role
|
||||
|
||||
**This command is a pure orchestrator**: Execute 4 phases to verify TDD workflow compliance, test coverage, and Red-Green-Refactor cycle execution.
|
||||
|
||||
## Core Responsibilities
|
||||
- Verify TDD task chain structure
|
||||
- Analyze test coverage
|
||||
- Validate TDD cycle execution
|
||||
- Generate compliance report
|
||||
- Verify TDD task chain structure (TEST → IMPL → REFACTOR)
|
||||
- Analyze test coverage metrics
|
||||
- Validate TDD cycle execution quality
|
||||
- Generate compliance report with quality gate recommendation
|
||||
|
||||
## Execution Process
|
||||
|
||||
```
|
||||
Input Parsing:
|
||||
└─ Decision (session argument):
|
||||
├─ session-id provided → Use provided session
|
||||
└─ No session-id → Auto-detect active session
|
||||
├─ --session provided → Use provided session
|
||||
└─ No session → Auto-detect active session
|
||||
|
||||
Phase 1: Session Discovery
|
||||
├─ Validate session directory exists
|
||||
└─ TodoWrite: Mark phase 1 completed
|
||||
Phase 1: Session Discovery & Validation
|
||||
├─ Detect or validate session directory
|
||||
├─ Check required artifacts exist (.task/*.json, .summaries/*)
|
||||
└─ ERROR if invalid or incomplete
|
||||
|
||||
Phase 2: Task Chain Validation
|
||||
Phase 2: Task Chain Structure Validation
|
||||
├─ Load all task JSONs from .task/
|
||||
├─ Extract task IDs and group by feature
|
||||
├─ Validate TDD structure:
|
||||
│ ├─ TEST-N.M → IMPL-N.M → REFACTOR-N.M chain
|
||||
│ ├─ Dependency verification
|
||||
│ └─ Meta field validation (tdd_phase, agent)
|
||||
└─ TodoWrite: Mark phase 2 completed
|
||||
├─ Validate TDD structure: TEST-N.M → IMPL-N.M → REFACTOR-N.M
|
||||
├─ Verify dependencies (depends_on)
|
||||
├─ Validate meta fields (tdd_phase, agent)
|
||||
└─ Extract chain validation data
|
||||
|
||||
Phase 3: Test Execution Analysis
|
||||
└─ /workflow:tools:tdd-coverage-analysis
|
||||
├─ Coverage metrics extraction
|
||||
├─ TDD cycle verification
|
||||
└─ Compliance score calculation
|
||||
Phase 3: Coverage & Cycle Analysis
|
||||
├─ Call: /workflow:tools:tdd-coverage-analysis
|
||||
├─ Parse: test-results.json, coverage-report.json, tdd-cycle-report.md
|
||||
└─ Extract coverage metrics and TDD cycle verification
|
||||
|
||||
Phase 4: Compliance Report Generation
|
||||
├─ Gemini analysis for comprehensive report
|
||||
├─ Aggregate findings from Phases 1-3
|
||||
├─ Calculate compliance score (0-100)
|
||||
├─ Determine quality gate recommendation
|
||||
├─ Generate TDD_COMPLIANCE_REPORT.md
|
||||
└─ Return summary to user
|
||||
└─ Display summary to user
|
||||
```
|
||||
|
||||
## 4-Phase Execution
|
||||
|
||||
### Phase 1: Session Discovery
|
||||
**Auto-detect or use provided session**
|
||||
### Phase 1: Session Discovery & Validation
|
||||
|
||||
**Step 1.1: Detect Session**
|
||||
```bash
|
||||
# If session-id provided
|
||||
sessionId = argument
|
||||
IF --session parameter provided:
|
||||
session_id = provided session
|
||||
ELSE:
|
||||
# Auto-detect active session
|
||||
active_sessions = bash(find .workflow/active/ -name "WFS-*" -type d 2>/dev/null)
|
||||
IF active_sessions is empty:
|
||||
ERROR: "No active workflow session found. Use --session <session-id>"
|
||||
EXIT
|
||||
ELSE IF active_sessions has multiple entries:
|
||||
# Use most recently modified session
|
||||
session_id = bash(ls -td .workflow/active/WFS-*/ 2>/dev/null | head -1 | xargs basename)
|
||||
ELSE:
|
||||
session_id = basename(active_sessions[0])
|
||||
|
||||
# Else auto-detect active session
|
||||
find .workflow/active/ -name "WFS-*" -type d | head -1 | sed 's/.*\///'
|
||||
# Derive paths
|
||||
session_dir = .workflow/active/WFS-{session_id}
|
||||
task_dir = session_dir/.task
|
||||
summaries_dir = session_dir/.summaries
|
||||
process_dir = session_dir/.process
|
||||
```
|
||||
|
||||
**Extract**: sessionId
|
||||
**Step 1.2: Validate Required Artifacts**
|
||||
```bash
|
||||
# Check task files exist
|
||||
task_files = Glob(task_dir/*.json)
|
||||
IF task_files.count == 0:
|
||||
ERROR: "No task JSON files found. Run /workflow:tdd-plan first"
|
||||
EXIT
|
||||
|
||||
**Validation**: Session directory exists
|
||||
# Check summaries exist (optional but recommended for full analysis)
|
||||
summaries_exist = EXISTS(summaries_dir)
|
||||
IF NOT summaries_exist:
|
||||
WARNING: "No .summaries/ directory found. Some analysis may be limited."
|
||||
```
|
||||
|
||||
**TodoWrite**: Mark phase 1 completed, phase 2 in_progress
|
||||
**Output**: session_id, session_dir, task_files list
|
||||
|
||||
---
|
||||
|
||||
### Phase 2: Task Chain Validation
|
||||
**Validate TDD structure using bash commands**
|
||||
### Phase 2: Task Chain Structure Validation
|
||||
|
||||
**Step 2.1: Load and Parse Task JSONs**
|
||||
```bash
|
||||
# Load all task JSONs
|
||||
for task_file in .workflow/active/{sessionId}/.task/*.json; do
|
||||
cat "$task_file"
|
||||
done
|
||||
# Single-pass JSON extraction using jq
|
||||
validation_data = bash("""
|
||||
# Load all tasks and extract structured data
|
||||
cd '{session_dir}/.task'
|
||||
|
||||
# Extract task IDs
|
||||
for task_file in .workflow/active/{sessionId}/.task/*.json; do
|
||||
cat "$task_file" | jq -r '.id'
|
||||
done
|
||||
# Extract all task IDs
|
||||
task_ids=$(jq -r '.id' *.json 2>/dev/null | sort)
|
||||
|
||||
# Check dependencies - read tasks and filter for IMPL/REFACTOR
|
||||
for task_file in .workflow/active/{sessionId}/.task/IMPL-*.json; do
|
||||
cat "$task_file" | jq -r '.context.depends_on[]?'
|
||||
done
|
||||
# Extract dependencies for IMPL tasks
|
||||
impl_deps=$(jq -r 'select(.id | startswith("IMPL")) | .id + ":" + (.context.depends_on[]? // "none")' *.json 2>/dev/null)
|
||||
|
||||
for task_file in .workflow/active/{sessionId}/.task/REFACTOR-*.json; do
|
||||
cat "$task_file" | jq -r '.context.depends_on[]?'
|
||||
done
|
||||
# Extract dependencies for REFACTOR tasks
|
||||
refactor_deps=$(jq -r 'select(.id | startswith("REFACTOR")) | .id + ":" + (.context.depends_on[]? // "none")' *.json 2>/dev/null)
|
||||
|
||||
# Check meta fields
|
||||
for task_file in .workflow/active/{sessionId}/.task/*.json; do
|
||||
cat "$task_file" | jq -r '.meta.tdd_phase'
|
||||
done
|
||||
# Extract meta fields
|
||||
meta_tdd=$(jq -r '.id + ":" + (.meta.tdd_phase // "missing")' *.json 2>/dev/null)
|
||||
meta_agent=$(jq -r '.id + ":" + (.meta.agent // "missing")' *.json 2>/dev/null)
|
||||
|
||||
for task_file in .workflow/active/{sessionId}/.task/*.json; do
|
||||
cat "$task_file" | jq -r '.meta.agent'
|
||||
done
|
||||
# Output as JSON
|
||||
jq -n --arg ids "$task_ids" \\
|
||||
--arg impl "$impl_deps" \\
|
||||
--arg refactor "$refactor_deps" \\
|
||||
--arg tdd "$meta_tdd" \\
|
||||
--arg agent "$meta_agent" \\
|
||||
'{ids: $ids, impl_deps: $impl, refactor_deps: $refactor, tdd: $tdd, agent: $agent}'
|
||||
""")
|
||||
```
|
||||
|
||||
**Validation**:
|
||||
- For each feature N, verify TEST-N.M → IMPL-N.M → REFACTOR-N.M exists
|
||||
- IMPL-N.M.context.depends_on includes TEST-N.M
|
||||
- REFACTOR-N.M.context.depends_on includes IMPL-N.M
|
||||
- TEST tasks have tdd_phase="red" and agent="@code-review-test-agent"
|
||||
- IMPL/REFACTOR tasks have tdd_phase="green"/"refactor" and agent="@code-developer"
|
||||
**Step 2.2: Validate TDD Chain Structure**
|
||||
```
|
||||
Parse validation_data JSON and validate:
|
||||
|
||||
**Extract**: Chain validation report
|
||||
For each feature N (extracted from task IDs):
|
||||
1. TEST-N.M exists?
|
||||
2. IMPL-N.M exists?
|
||||
3. REFACTOR-N.M exists? (optional but recommended)
|
||||
4. IMPL-N.M.context.depends_on contains TEST-N.M?
|
||||
5. REFACTOR-N.M.context.depends_on contains IMPL-N.M?
|
||||
6. TEST-N.M.meta.tdd_phase == "red"?
|
||||
7. TEST-N.M.meta.agent == "@code-review-test-agent"?
|
||||
8. IMPL-N.M.meta.tdd_phase == "green"?
|
||||
9. IMPL-N.M.meta.agent == "@code-developer"?
|
||||
10. REFACTOR-N.M.meta.tdd_phase == "refactor"?
|
||||
|
||||
**TodoWrite**: Mark phase 2 completed, phase 3 in_progress
|
||||
Calculate:
|
||||
- chain_completeness_score = (complete_chains / total_chains) * 100
|
||||
- dependency_accuracy = (correct_deps / total_deps) * 100
|
||||
- meta_field_accuracy = (correct_meta / total_meta) * 100
|
||||
```
|
||||
|
||||
**Output**: chain_validation_report (JSON structure with validation results)
|
||||
|
||||
---
|
||||
|
||||
### Phase 3: Test Execution Analysis
|
||||
**Command**: `SlashCommand(command="/workflow:tools:tdd-coverage-analysis --session [sessionId]")`
|
||||
### Phase 3: Coverage & Cycle Analysis
|
||||
|
||||
**Input**: sessionId from Phase 1
|
||||
**Step 3.1: Call Coverage Analysis Sub-command**
|
||||
```bash
|
||||
Skill(skill="workflow:tools:tdd-coverage-analysis", args="--session {session_id}")
|
||||
```
|
||||
|
||||
**Parse Output**:
|
||||
- Coverage metrics (line, branch, function percentages)
|
||||
- TDD cycle verification results
|
||||
- Compliance score
|
||||
**Step 3.2: Parse Output Files**
|
||||
```bash
|
||||
# Check required outputs exist
|
||||
IF NOT EXISTS(process_dir/test-results.json):
|
||||
WARNING: "test-results.json not found. Coverage analysis incomplete."
|
||||
coverage_data = null
|
||||
ELSE:
|
||||
coverage_data = Read(process_dir/test-results.json)
|
||||
|
||||
**Validation**:
|
||||
- `.workflow/active/{sessionId}/.process/test-results.json` exists
|
||||
- `.workflow/active/{sessionId}/.process/coverage-report.json` exists
|
||||
- `.workflow/active/{sessionId}/.process/tdd-cycle-report.md` exists
|
||||
IF NOT EXISTS(process_dir/coverage-report.json):
|
||||
WARNING: "coverage-report.json not found. Coverage metrics incomplete."
|
||||
metrics = null
|
||||
ELSE:
|
||||
metrics = Read(process_dir/coverage-report.json)
|
||||
|
||||
**TodoWrite**: Mark phase 3 completed, phase 4 in_progress
|
||||
IF NOT EXISTS(process_dir/tdd-cycle-report.md):
|
||||
WARNING: "tdd-cycle-report.md not found. Cycle validation incomplete."
|
||||
cycle_data = null
|
||||
ELSE:
|
||||
cycle_data = Read(process_dir/tdd-cycle-report.md)
|
||||
```
|
||||
|
||||
**Step 3.3: Extract Coverage Metrics**
|
||||
```
|
||||
If coverage_data exists:
|
||||
- line_coverage_percent
|
||||
- branch_coverage_percent
|
||||
- function_coverage_percent
|
||||
- uncovered_files (list)
|
||||
- uncovered_lines (map: file -> line ranges)
|
||||
|
||||
If cycle_data exists:
|
||||
- red_phase_compliance (tests failed initially?)
|
||||
- green_phase_compliance (tests pass after impl?)
|
||||
- refactor_phase_compliance (tests stay green during refactor?)
|
||||
- minimal_implementation_score (was impl minimal?)
|
||||
```
|
||||
|
||||
**Output**: coverage_analysis, cycle_analysis
|
||||
|
||||
---
|
||||
|
||||
### Phase 4: Compliance Report Generation
|
||||
**Gemini analysis for comprehensive TDD compliance report**
|
||||
|
||||
**Step 4.1: Calculate Compliance Score**
|
||||
```
|
||||
Base Score: 100 points
|
||||
|
||||
Deductions:
|
||||
Chain Structure:
|
||||
- Missing TEST task: -30 points per feature
|
||||
- Missing IMPL task: -30 points per feature
|
||||
- Missing REFACTOR task: -10 points per feature
|
||||
- Wrong dependency: -15 points per error
|
||||
- Wrong agent: -5 points per error
|
||||
- Wrong tdd_phase: -5 points per error
|
||||
|
||||
TDD Cycle Compliance:
|
||||
- Test didn't fail initially: -10 points per feature
|
||||
- Tests didn't pass after IMPL: -20 points per feature
|
||||
- Tests broke during REFACTOR: -15 points per feature
|
||||
- Over-engineered IMPL: -10 points per feature
|
||||
|
||||
Coverage Quality:
|
||||
- Line coverage < 80%: -5 points
|
||||
- Branch coverage < 70%: -5 points
|
||||
- Function coverage < 80%: -5 points
|
||||
- Critical paths uncovered: -10 points
|
||||
|
||||
Final Score: Max(0, Base Score - Total Deductions)
|
||||
```
|
||||
|
||||
**Step 4.2: Determine Quality Gate**
|
||||
```
|
||||
IF score >= 90 AND no_critical_violations:
|
||||
recommendation = "APPROVED"
|
||||
ELSE IF score >= 70 AND critical_violations == 0:
|
||||
recommendation = "PROCEED_WITH_CAVEATS"
|
||||
ELSE IF score >= 50:
|
||||
recommendation = "REQUIRE_FIXES"
|
||||
ELSE:
|
||||
recommendation = "BLOCK_MERGE"
|
||||
```
|
||||
|
||||
**Step 4.3: Generate Report**
|
||||
```bash
|
||||
ccw cli -p "
|
||||
PURPOSE: Generate TDD compliance report
|
||||
TASK: Analyze TDD workflow execution and generate quality report
|
||||
CONTEXT: @{.workflow/active/{sessionId}/.task/*.json,.workflow/active/{sessionId}/.summaries/*,.workflow/active/{sessionId}/.process/tdd-cycle-report.md}
|
||||
EXPECTED:
|
||||
- TDD compliance score (0-100)
|
||||
- Chain completeness verification
|
||||
- Test coverage analysis summary
|
||||
- Quality recommendations
|
||||
- Red-Green-Refactor cycle validation
|
||||
- Best practices adherence assessment
|
||||
RULES: Focus on TDD best practices and workflow adherence. Be specific about violations and improvements.
|
||||
" --tool gemini --mode analysis --cd project-root > .workflow/active/{sessionId}/TDD_COMPLIANCE_REPORT.md
|
||||
report_content = Generate markdown report (see structure below)
|
||||
report_path = "{session_dir}/TDD_COMPLIANCE_REPORT.md"
|
||||
Write(report_path, report_content)
|
||||
```
|
||||
|
||||
**Output**: TDD_COMPLIANCE_REPORT.md
|
||||
|
||||
**TodoWrite**: Mark phase 4 completed
|
||||
|
||||
**Return to User**:
|
||||
```
|
||||
TDD Verification Report - Session: {sessionId}
|
||||
|
||||
## Chain Validation
|
||||
[COMPLETE] Feature 1: TEST-1.1 → IMPL-1.1 → REFACTOR-1.1 (Complete)
|
||||
[COMPLETE] Feature 2: TEST-2.1 → IMPL-2.1 → REFACTOR-2.1 (Complete)
|
||||
[INCOMPLETE] Feature 3: TEST-3.1 → IMPL-3.1 (Missing REFACTOR phase)
|
||||
|
||||
## Test Execution
|
||||
All TEST tasks produced failing tests
|
||||
All IMPL tasks made tests pass
|
||||
All REFACTOR tasks maintained green tests
|
||||
|
||||
## Coverage Metrics
|
||||
Line Coverage: {percentage}%
|
||||
Branch Coverage: {percentage}%
|
||||
Function Coverage: {percentage}%
|
||||
|
||||
## Compliance Score: {score}/100
|
||||
|
||||
Detailed report: .workflow/active/{sessionId}/TDD_COMPLIANCE_REPORT.md
|
||||
|
||||
Recommendations:
|
||||
- Complete missing REFACTOR-3.1 task
|
||||
- Consider additional edge case tests for Feature 2
|
||||
- Improve test failure message clarity in Feature 1
|
||||
**Step 4.4: Display Summary to User**
|
||||
```bash
|
||||
echo "=== TDD Verification Complete ==="
|
||||
echo "Session: {session_id}"
|
||||
echo "Report: {report_path}"
|
||||
echo ""
|
||||
echo "Quality Gate: {recommendation}"
|
||||
echo "Compliance Score: {score}/100"
|
||||
echo ""
|
||||
echo "Chain Validation: {chain_completeness_score}%"
|
||||
echo "Line Coverage: {line_coverage}%"
|
||||
echo "Branch Coverage: {branch_coverage}%"
|
||||
echo ""
|
||||
echo "Next: Review full report for detailed findings"
|
||||
```
|
||||
|
||||
## TodoWrite Pattern
|
||||
## TodoWrite Pattern (Optional)
|
||||
|
||||
**Note**: As an orchestrator command, TodoWrite tracking is optional and primarily useful for long-running verification processes. For most cases, the 4-phase execution is fast enough that progress tracking adds noise without value.
|
||||
|
||||
```javascript
|
||||
// Initialize (before Phase 1)
|
||||
TodoWrite({todos: [
|
||||
{"content": "Identify target session", "status": "in_progress", "activeForm": "Identifying target session"},
|
||||
{"content": "Validate task chain structure", "status": "pending", "activeForm": "Validating task chain structure"},
|
||||
{"content": "Analyze test execution", "status": "pending", "activeForm": "Analyzing test execution"},
|
||||
{"content": "Generate compliance report", "status": "pending", "activeForm": "Generating compliance report"}
|
||||
]})
|
||||
|
||||
// After Phase 1
|
||||
TodoWrite({todos: [
|
||||
{"content": "Identify target session", "status": "completed", "activeForm": "Identifying target session"},
|
||||
{"content": "Validate task chain structure", "status": "in_progress", "activeForm": "Validating task chain structure"},
|
||||
{"content": "Analyze test execution", "status": "pending", "activeForm": "Analyzing test execution"},
|
||||
{"content": "Generate compliance report", "status": "pending", "activeForm": "Generating compliance report"}
|
||||
]})
|
||||
|
||||
// Continue pattern for Phase 2, 3, 4...
|
||||
// Only use TodoWrite for complex multi-session verification
|
||||
// Skip for single-session verification
|
||||
```
|
||||
|
||||
## Validation Logic
|
||||
@@ -229,27 +316,24 @@ TodoWrite({todos: [
|
||||
5. Report incomplete or invalid chains
|
||||
```
|
||||
|
||||
### Compliance Scoring
|
||||
```
|
||||
Base Score: 100 points
|
||||
### Quality Gate Criteria
|
||||
|
||||
Deductions:
|
||||
- Missing TEST task: -30 points per feature
|
||||
- Missing IMPL task: -30 points per feature
|
||||
- Missing REFACTOR task: -10 points per feature
|
||||
- Wrong dependency: -15 points per error
|
||||
- Wrong agent: -5 points per error
|
||||
- Wrong tdd_phase: -5 points per error
|
||||
- Test didn't fail initially: -10 points per feature
|
||||
- Tests didn't pass after IMPL: -20 points per feature
|
||||
- Tests broke during REFACTOR: -15 points per feature
|
||||
| Recommendation | Score Range | Critical Violations | Action |
|
||||
|----------------|-------------|---------------------|--------|
|
||||
| **APPROVED** | ≥90 | 0 | Safe to merge |
|
||||
| **PROCEED_WITH_CAVEATS** | ≥70 | 0 | Can proceed, address minor issues |
|
||||
| **REQUIRE_FIXES** | ≥50 | Any | Must fix before merge |
|
||||
| **BLOCK_MERGE** | <50 | Any | Block merge until resolved |
|
||||
|
||||
Final Score: Max(0, Base Score - Deductions)
|
||||
```
|
||||
**Critical Violations**:
|
||||
- Missing TEST or IMPL task for any feature
|
||||
- Tests didn't fail initially (Red phase violation)
|
||||
- Tests didn't pass after IMPL (Green phase violation)
|
||||
- Tests broke during REFACTOR (Refactor phase violation)
|
||||
|
||||
## Output Files
|
||||
```
|
||||
.workflow/active/{session-id}/
|
||||
.workflow/active/WFS-{session-id}/
|
||||
├── TDD_COMPLIANCE_REPORT.md # Comprehensive compliance report ⭐
|
||||
└── .process/
|
||||
├── test-results.json # From tdd-coverage-analysis
|
||||
@@ -262,14 +346,14 @@ Final Score: Max(0, Base Score - Deductions)
|
||||
### Session Discovery Errors
|
||||
| Error | Cause | Resolution |
|
||||
|-------|-------|------------|
|
||||
| No active session | No WFS-* directories | Provide session-id explicitly |
|
||||
| Multiple active sessions | Multiple WFS-* directories | Provide session-id explicitly |
|
||||
| No active session | No WFS-* directories | Provide --session explicitly |
|
||||
| Multiple active sessions | Multiple WFS-* directories | Provide --session explicitly |
|
||||
| Session not found | Invalid session-id | Check available sessions |
|
||||
|
||||
### Validation Errors
|
||||
| Error | Cause | Resolution |
|
||||
|-------|-------|------------|
|
||||
| Task files missing | Incomplete planning | Run tdd-plan first |
|
||||
| Task files missing | Incomplete planning | Run /workflow:tdd-plan first |
|
||||
| Invalid JSON | Corrupted task files | Regenerate tasks |
|
||||
| Missing summaries | Tasks not executed | Execute tasks before verify |
|
||||
|
||||
@@ -278,13 +362,13 @@ Final Score: Max(0, Base Score - Deductions)
|
||||
|-------|-------|------------|
|
||||
| Coverage tool missing | No test framework | Configure testing first |
|
||||
| Tests fail to run | Code errors | Fix errors before verify |
|
||||
| Gemini analysis fails | Token limit / API error | Retry or reduce context |
|
||||
| Sub-command fails | tdd-coverage-analysis error | Check sub-command logs |
|
||||
|
||||
## Integration & Usage
|
||||
|
||||
### Command Chain
|
||||
- **Called After**: `/workflow:execute` (when TDD tasks completed)
|
||||
- **Calls**: `/workflow:tools:tdd-coverage-analysis`, Gemini CLI
|
||||
- **Calls**: `/workflow:tools:tdd-coverage-analysis`
|
||||
- **Related**: `/workflow:tdd-plan`, `/workflow:status`
|
||||
|
||||
### Basic Usage
|
||||
@@ -293,7 +377,7 @@ Final Score: Max(0, Base Score - Deductions)
|
||||
/workflow:tdd-verify
|
||||
|
||||
# Specify session
|
||||
/workflow:tdd-verify WFS-auth
|
||||
/workflow:tdd-verify --session WFS-auth
|
||||
```
|
||||
|
||||
### When to Use
|
||||
@@ -308,61 +392,125 @@ Final Score: Max(0, Base Score - Deductions)
|
||||
# TDD Compliance Report - {Session ID}
|
||||
|
||||
**Generated**: {timestamp}
|
||||
**Session**: {sessionId}
|
||||
**Session**: WFS-{sessionId}
|
||||
**Workflow Type**: TDD
|
||||
|
||||
---
|
||||
|
||||
## Executive Summary
|
||||
Overall Compliance Score: {score}/100
|
||||
Status: {EXCELLENT | GOOD | NEEDS IMPROVEMENT | FAILED}
|
||||
|
||||
### Quality Gate Decision
|
||||
|
||||
| Metric | Value | Status |
|
||||
|--------|-------|--------|
|
||||
| Compliance Score | {score}/100 | {status_emoji} |
|
||||
| Chain Completeness | {percentage}% | {status} |
|
||||
| Line Coverage | {percentage}% | {status} |
|
||||
| Branch Coverage | {percentage}% | {status} |
|
||||
| Function Coverage | {percentage}% | {status} |
|
||||
|
||||
### Recommendation
|
||||
|
||||
**{RECOMMENDATION}**
|
||||
|
||||
**Decision Rationale**:
|
||||
{brief explanation based on score and violations}
|
||||
|
||||
**Quality Gate Criteria**:
|
||||
- **APPROVED**: Score ≥90, no critical violations
|
||||
- **PROCEED_WITH_CAVEATS**: Score ≥70, no critical violations
|
||||
- **REQUIRE_FIXES**: Score ≥50 or critical violations exist
|
||||
- **BLOCK_MERGE**: Score <50
|
||||
|
||||
---
|
||||
|
||||
## Chain Analysis
|
||||
|
||||
### Feature 1: {Feature Name}
|
||||
**Status**: Complete
|
||||
**Status**: ✅ Complete
|
||||
**Chain**: TEST-1.1 → IMPL-1.1 → REFACTOR-1.1
|
||||
|
||||
- **Red Phase**: Test created and failed with clear message
|
||||
- **Green Phase**: Minimal implementation made test pass
|
||||
- **Refactor Phase**: Code improved, tests remained green
|
||||
| Phase | Task | Status | Details |
|
||||
|-------|------|--------|---------|
|
||||
| Red | TEST-1.1 | ✅ Pass | Test created and failed with clear message |
|
||||
| Green | IMPL-1.1 | ✅ Pass | Minimal implementation made test pass |
|
||||
| Refactor | REFACTOR-1.1 | ✅ Pass | Code improved, tests remained green |
|
||||
|
||||
### Feature 2: {Feature Name}
|
||||
**Status**: Incomplete
|
||||
**Status**: ⚠️ Incomplete
|
||||
**Chain**: TEST-2.1 → IMPL-2.1 (Missing REFACTOR-2.1)
|
||||
|
||||
- **Red Phase**: Test created and failed
|
||||
- **Green Phase**: Implementation seems over-engineered
|
||||
- **Refactor Phase**: Missing
|
||||
| Phase | Task | Status | Details |
|
||||
|-------|------|--------|---------|
|
||||
| Red | TEST-2.1 | ✅ Pass | Test created and failed |
|
||||
| Green | IMPL-2.1 | ⚠️ Warning | Implementation seems over-engineered |
|
||||
| Refactor | REFACTOR-2.1 | ❌ Missing | Task not completed |
|
||||
|
||||
**Issues**:
|
||||
- REFACTOR-2.1 task not completed
|
||||
- IMPL-2.1 implementation exceeded minimal scope
|
||||
- REFACTOR-2.1 task not completed (-10 points)
|
||||
- IMPL-2.1 implementation exceeded minimal scope (-10 points)
|
||||
|
||||
[Repeat for all features]
|
||||
### Chain Validation Summary
|
||||
|
||||
| Metric | Value |
|
||||
|--------|-------|
|
||||
| Total Features | {count} |
|
||||
| Complete Chains | {count} ({percent}%) |
|
||||
| Incomplete Chains | {count} |
|
||||
| Missing TEST | {count} |
|
||||
| Missing IMPL | {count} |
|
||||
| Missing REFACTOR | {count} |
|
||||
| Dependency Errors | {count} |
|
||||
| Meta Field Errors | {count} |
|
||||
|
||||
---
|
||||
|
||||
## Test Coverage Analysis
|
||||
|
||||
### Coverage Metrics
|
||||
- Line Coverage: {percentage}% {status}
|
||||
- Branch Coverage: {percentage}% {status}
|
||||
- Function Coverage: {percentage}% {status}
|
||||
|
||||
| Metric | Coverage | Target | Status |
|
||||
|--------|----------|--------|--------|
|
||||
| Line Coverage | {percentage}% | ≥80% | {status} |
|
||||
| Branch Coverage | {percentage}% | ≥70% | {status} |
|
||||
| Function Coverage | {percentage}% | ≥80% | {status} |
|
||||
|
||||
### Coverage Gaps
|
||||
- {file}:{lines} - Uncovered error handling
|
||||
- {file}:{lines} - Uncovered edge case
|
||||
|
||||
| File | Lines | Issue | Priority |
|
||||
|------|-------|-------|----------|
|
||||
| src/auth/service.ts | 45-52 | Uncovered error handling | HIGH |
|
||||
| src/utils/parser.ts | 78-85 | Uncovered edge case | MEDIUM |
|
||||
|
||||
---
|
||||
|
||||
## TDD Cycle Validation
|
||||
|
||||
### Red Phase (Write Failing Test)
|
||||
- {N}/{total} features had failing tests initially
|
||||
- Feature 3: No evidence of initial test failure
|
||||
- {N}/{total} features had failing tests initially ({percent}%)
|
||||
- ✅ Compliant features: {list}
|
||||
- ❌ Non-compliant features: {list}
|
||||
|
||||
**Violations**:
|
||||
- Feature 3: No evidence of initial test failure (-10 points)
|
||||
|
||||
### Green Phase (Make Test Pass)
|
||||
- {N}/{total} implementations made tests pass
|
||||
- All implementations minimal and focused
|
||||
- {N}/{total} implementations made tests pass ({percent}%)
|
||||
- ✅ Compliant features: {list}
|
||||
- ❌ Non-compliant features: {list}
|
||||
|
||||
**Violations**:
|
||||
- Feature 2: Implementation over-engineered (-10 points)
|
||||
|
||||
### Refactor Phase (Improve Quality)
|
||||
- {N}/{total} features completed refactoring
|
||||
- Feature 2, 4: Refactoring step skipped
|
||||
- {N}/{total} features completed refactoring ({percent}%)
|
||||
- ✅ Compliant features: {list}
|
||||
- ❌ Non-compliant features: {list}
|
||||
|
||||
**Violations**:
|
||||
- Feature 2, 4: Refactoring step skipped (-20 points total)
|
||||
|
||||
---
|
||||
|
||||
## Best Practices Assessment
|
||||
|
||||
@@ -377,24 +525,61 @@ Status: {EXCELLENT | GOOD | NEEDS IMPROVEMENT | FAILED}
|
||||
- Missing refactoring steps
|
||||
- Test failure messages could be more descriptive
|
||||
|
||||
---
|
||||
|
||||
## Detailed Findings by Severity
|
||||
|
||||
### Critical Issues ({count})
|
||||
{List of critical issues with impact and remediation}
|
||||
|
||||
### High Priority Issues ({count})
|
||||
{List of high priority issues with impact and remediation}
|
||||
|
||||
### Medium Priority Issues ({count})
|
||||
{List of medium priority issues with impact and remediation}
|
||||
|
||||
### Low Priority Issues ({count})
|
||||
{List of low priority issues with impact and remediation}
|
||||
|
||||
---
|
||||
|
||||
## Recommendations
|
||||
|
||||
### High Priority
|
||||
### Required Fixes (Before Merge)
|
||||
1. Complete missing REFACTOR tasks (Features 2, 4)
|
||||
2. Verify initial test failures for Feature 3
|
||||
3. Simplify over-engineered implementations
|
||||
3. Fix tests that broke during refactoring
|
||||
|
||||
### Medium Priority
|
||||
1. Add edge case tests for Features 1, 3
|
||||
2. Improve test failure message clarity
|
||||
3. Increase branch coverage to >85%
|
||||
### Recommended Improvements
|
||||
1. Simplify over-engineered implementations
|
||||
2. Add edge case tests for Features 1, 3
|
||||
3. Improve test failure message clarity
|
||||
4. Increase branch coverage to >85%
|
||||
|
||||
### Low Priority
|
||||
### Optional Enhancements
|
||||
1. Add more descriptive test names
|
||||
2. Consider parameterized tests for similar scenarios
|
||||
3. Document TDD process learnings
|
||||
|
||||
## Conclusion
|
||||
{Summary of compliance status and next steps}
|
||||
---
|
||||
|
||||
## Metrics Summary
|
||||
|
||||
| Metric | Value |
|
||||
|--------|-------|
|
||||
| Total Features | {count} |
|
||||
| Complete Chains | {count} ({percent}%) |
|
||||
| Compliance Score | {score}/100 |
|
||||
| Critical Issues | {count} |
|
||||
| High Issues | {count} |
|
||||
| Medium Issues | {count} |
|
||||
| Low Issues | {count} |
|
||||
| Line Coverage | {percent}% |
|
||||
| Branch Coverage | {percent}% |
|
||||
| Function Coverage | {percent}% |
|
||||
|
||||
---
|
||||
|
||||
**Report End**
|
||||
```
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
name: test-cycle-execute
|
||||
description: Execute test-fix workflow with dynamic task generation and iterative fix cycles until test pass rate >= 95% or max iterations reached. Uses @cli-planning-agent for failure analysis and task generation.
|
||||
argument-hint: "[--resume-session=\"session-id\"] [--max-iterations=N]"
|
||||
allowed-tools: SlashCommand(*), TodoWrite(*), Read(*), Bash(*), Task(*)
|
||||
allowed-tools: Skill(*), TodoWrite(*), Read(*), Bash(*), Task(*)
|
||||
---
|
||||
|
||||
# Workflow Test-Cycle-Execute Command
|
||||
@@ -491,6 +491,10 @@ The orchestrator automatically creates git commits at key checkpoints to enable
|
||||
|
||||
**Note**: Final session completion creates additional commit with full summary.
|
||||
|
||||
## Post-Completion Expansion
|
||||
|
||||
完成后询问用户是否扩展为issue(test/enhance/refactor/doc),选中项调用 `/issue:new "{summary} - {dimension}"`
|
||||
|
||||
## Best Practices
|
||||
|
||||
1. **Default Settings Work**: 10 iterations sufficient for most cases
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,529 +0,0 @@
|
||||
---
|
||||
name: test-gen
|
||||
description: Create independent test-fix workflow session from completed implementation session, analyzes code to generate test tasks
|
||||
argument-hint: "source-session-id"
|
||||
allowed-tools: SlashCommand(*), TodoWrite(*), Read(*), Bash(*)
|
||||
---
|
||||
|
||||
# Workflow Test Generation Command (/workflow:test-gen)
|
||||
|
||||
## Coordinator Role
|
||||
|
||||
**This command is a pure orchestrator**: Creates an independent test-fix workflow session for validating a completed implementation. It reuses the standard planning toolchain with automatic cross-session context gathering.
|
||||
|
||||
**Core Principles**:
|
||||
- **Session Isolation**: Creates new `WFS-test-[source]` session to keep verification separate from implementation
|
||||
- **Context-First**: Prioritizes gathering code changes and summaries from source session
|
||||
- **Format Reuse**: Creates standard `IMPL-*.json` task, using `meta.type: "test-fix"` for agent assignment
|
||||
- **Parameter Simplification**: Tools auto-detect test session type via metadata, no manual cross-session parameters needed
|
||||
- **Semantic CLI Selection**: CLI tool usage is determined by user's task description (e.g., "use Codex for fixes")
|
||||
|
||||
**Task Attachment Model**:
|
||||
- SlashCommand dispatch **expands workflow** by attaching sub-tasks to current TodoWrite
|
||||
- When a sub-command is dispatched (e.g., `/workflow:tools:test-context-gather`), its internal tasks are attached to the orchestrator's TodoWrite
|
||||
- Orchestrator **executes these attached tasks** sequentially
|
||||
- After completion, attached tasks are **collapsed** back to high-level phase summary
|
||||
- This is **task expansion**, not external delegation
|
||||
|
||||
**Auto-Continue Mechanism**:
|
||||
- TodoList tracks current phase status and dynamically manages task attachment/collapse
|
||||
- When each phase finishes executing, automatically execute next pending phase
|
||||
- All phases run autonomously without user interaction
|
||||
- **⚠️ CONTINUOUS EXECUTION** - Do not stop until all phases complete
|
||||
|
||||
**Execution Flow**:
|
||||
1. Initialize TodoWrite → Create test session → Parse session ID
|
||||
2. Gather cross-session context (automatic) → Parse context path
|
||||
3. Analyze implementation with concept-enhanced → Parse ANALYSIS_RESULTS.md
|
||||
4. Generate test task from analysis → Return summary
|
||||
|
||||
**Command Scope**: This command ONLY prepares test workflow artifacts. It does NOT execute tests or implementation. Task execution requires separate user action.
|
||||
|
||||
## Core Rules
|
||||
|
||||
1. **Start Immediately**: First action is TodoWrite initialization, second action is Phase 1 test session creation
|
||||
2. **No Preliminary Analysis**: Do not read files or analyze before Phase 1
|
||||
3. **Parse Every Output**: Extract required data from each phase for next phase
|
||||
4. **Sequential Execution**: Each phase depends on previous phase's output
|
||||
5. **Complete All Phases**: Do not return to user until Phase 5 completes (summary returned)
|
||||
6. **Track Progress**: Update TodoWrite dynamically with task attachment/collapse pattern
|
||||
7. **Automatic Detection**: context-gather auto-detects test session and gathers source session context
|
||||
8. **Semantic CLI Selection**: CLI tool usage determined from user's task description, passed to Phase 4
|
||||
9. **Command Boundary**: This command ends at Phase 5 summary. Test execution is NOT part of this command.
|
||||
10. **Task Attachment Model**: SlashCommand dispatch **attaches** sub-tasks to current workflow. Orchestrator **executes** these attached tasks itself, then **collapses** them after completion
|
||||
11. **⚠️ CRITICAL: DO NOT STOP**: Continuous multi-phase workflow. After executing all attached tasks, immediately collapse them and execute next phase
|
||||
|
||||
## 5-Phase Execution
|
||||
|
||||
### Phase 1: Create Test Session
|
||||
|
||||
**Step 1.0: Load Source Session Intent** - Preserve user's original task description for semantic CLI selection
|
||||
|
||||
```javascript
|
||||
// Read source session metadata to get original task description
|
||||
Read(".workflow/active/[sourceSessionId]/workflow-session.json")
|
||||
// OR if context-package exists:
|
||||
Read(".workflow/active/[sourceSessionId]/.process/context-package.json")
|
||||
|
||||
// Extract: metadata.task_description or project/description field
|
||||
// This preserves user's CLI tool preferences (e.g., "use Codex for fixes")
|
||||
```
|
||||
|
||||
**Step 1.1: Dispatch** - Create new test workflow session with preserved intent
|
||||
|
||||
```javascript
|
||||
// Include original task description to enable semantic CLI selection
|
||||
SlashCommand(command="/workflow:session:start --new \"Test validation for [sourceSessionId]: [originalTaskDescription]\"")
|
||||
```
|
||||
|
||||
**Input**:
|
||||
- `sourceSessionId` from user argument (e.g., `WFS-user-auth`)
|
||||
- `originalTaskDescription` from source session metadata (preserves CLI tool preferences)
|
||||
|
||||
**Expected Behavior**:
|
||||
- Creates new session with pattern `WFS-test-[source-slug]` (e.g., `WFS-test-user-auth`)
|
||||
- Writes metadata to `workflow-session.json`:
|
||||
- `workflow_type: "test_session"`
|
||||
- `source_session_id: "[sourceSessionId]"`
|
||||
- Description includes original user intent for semantic CLI selection
|
||||
- Returns new session ID for subsequent phases
|
||||
|
||||
**Parse Output**:
|
||||
- Extract: new test session ID (store as `testSessionId`)
|
||||
- Pattern: `WFS-test-[slug]`
|
||||
|
||||
**Validation**:
|
||||
- Source session `.workflow/[sourceSessionId]/` exists
|
||||
- Source session has completed IMPL tasks (`.summaries/IMPL-*-summary.md`)
|
||||
- New test session directory created
|
||||
- Metadata includes `workflow_type` and `source_session_id`
|
||||
|
||||
**TodoWrite**: Mark phase 1 completed, phase 2 in_progress
|
||||
|
||||
---
|
||||
|
||||
### Phase 2: Gather Test Context
|
||||
|
||||
**Step 2.1: Dispatch** - Gather test coverage context from source session
|
||||
|
||||
```javascript
|
||||
SlashCommand(command="/workflow:tools:test-context-gather --session [testSessionId]")
|
||||
```
|
||||
|
||||
**Input**: `testSessionId` from Phase 1 (e.g., `WFS-test-user-auth`)
|
||||
|
||||
**Expected Behavior**:
|
||||
- Load source session implementation context and summaries
|
||||
- Analyze test coverage using MCP tools (find existing tests)
|
||||
- Identify files requiring tests (coverage gaps)
|
||||
- Detect test framework and conventions
|
||||
- Generate `test-context-package.json`
|
||||
|
||||
**Parse Output**:
|
||||
- Extract: test context package path (store as `testContextPath`)
|
||||
- Pattern: `.workflow/[testSessionId]/.process/test-context-package.json`
|
||||
|
||||
**Validation**:
|
||||
- Test context package created
|
||||
- Contains source session summaries
|
||||
- Includes coverage gap analysis
|
||||
- Test framework detected
|
||||
- Test conventions documented
|
||||
|
||||
<!-- TodoWrite: When test-context-gather dispatched, INSERT 3 test-context-gather tasks -->
|
||||
|
||||
**TodoWrite Update (Phase 2 SlashCommand dispatched - tasks attached)**:
|
||||
```json
|
||||
[
|
||||
{"content": "Create independent test session", "status": "completed", "activeForm": "Creating test session"},
|
||||
{"content": "Phase 2.1: Load source session summaries (test-context-gather)", "status": "in_progress", "activeForm": "Loading source session summaries"},
|
||||
{"content": "Phase 2.2: Analyze test coverage with MCP tools (test-context-gather)", "status": "pending", "activeForm": "Analyzing test coverage"},
|
||||
{"content": "Phase 2.3: Identify coverage gaps and framework (test-context-gather)", "status": "pending", "activeForm": "Identifying coverage gaps"},
|
||||
{"content": "Analyze test requirements with Gemini", "status": "pending", "activeForm": "Analyzing test requirements"},
|
||||
{"content": "Generate test generation and execution tasks", "status": "pending", "activeForm": "Generating test tasks"},
|
||||
{"content": "Return workflow summary", "status": "pending", "activeForm": "Returning workflow summary"}
|
||||
]
|
||||
```
|
||||
|
||||
**Note**: SlashCommand dispatch **attaches** test-context-gather's 3 tasks. Orchestrator **executes** these tasks.
|
||||
|
||||
**Next Action**: Tasks attached → **Execute Phase 2.1-2.3** sequentially
|
||||
|
||||
<!-- TodoWrite: After Phase 2 tasks complete, REMOVE Phase 2.1-2.3, restore to orchestrator view -->
|
||||
|
||||
**TodoWrite Update (Phase 2 completed - tasks collapsed)**:
|
||||
```json
|
||||
[
|
||||
{"content": "Create independent test session", "status": "completed", "activeForm": "Creating test session"},
|
||||
{"content": "Gather test coverage context", "status": "completed", "activeForm": "Gathering test coverage context"},
|
||||
{"content": "Analyze test requirements with Gemini", "status": "pending", "activeForm": "Analyzing test requirements"},
|
||||
{"content": "Generate test generation and execution tasks", "status": "pending", "activeForm": "Generating test tasks"},
|
||||
{"content": "Return workflow summary", "status": "pending", "activeForm": "Returning workflow summary"}
|
||||
]
|
||||
```
|
||||
|
||||
**Note**: Phase 2 tasks completed and collapsed to summary.
|
||||
|
||||
---
|
||||
|
||||
### Phase 3: Test Generation Analysis
|
||||
|
||||
**Step 3.1: Dispatch** - Analyze test requirements with Gemini
|
||||
|
||||
```javascript
|
||||
SlashCommand(command="/workflow:tools:test-concept-enhanced --session [testSessionId] --context [testContextPath]")
|
||||
```
|
||||
|
||||
**Input**:
|
||||
- `testSessionId` from Phase 1
|
||||
- `testContextPath` from Phase 2
|
||||
|
||||
**Expected Behavior**:
|
||||
- Use Gemini to analyze coverage gaps and implementation context
|
||||
- Study existing test patterns and conventions
|
||||
- Generate test requirements for each missing test file
|
||||
- Design test generation strategy
|
||||
- Generate `TEST_ANALYSIS_RESULTS.md`
|
||||
|
||||
**Parse Output**:
|
||||
- Verify `.workflow/[testSessionId]/.process/TEST_ANALYSIS_RESULTS.md` created
|
||||
- Contains test requirements and generation strategy
|
||||
- Lists test files to create with specifications
|
||||
|
||||
**Validation**:
|
||||
- TEST_ANALYSIS_RESULTS.md exists with complete sections:
|
||||
- Coverage Assessment
|
||||
- Test Framework & Conventions
|
||||
- Test Requirements by File
|
||||
- Test Generation Strategy
|
||||
- Implementation Targets (test files to create)
|
||||
- Success Criteria
|
||||
|
||||
<!-- TodoWrite: When test-concept-enhanced dispatched, INSERT 3 concept-enhanced tasks -->
|
||||
|
||||
**TodoWrite Update (Phase 3 SlashCommand dispatched - tasks attached)**:
|
||||
```json
|
||||
[
|
||||
{"content": "Create independent test session", "status": "completed", "activeForm": "Creating test session"},
|
||||
{"content": "Gather test coverage context", "status": "completed", "activeForm": "Gathering test coverage context"},
|
||||
{"content": "Phase 3.1: Analyze coverage gaps with Gemini (test-concept-enhanced)", "status": "in_progress", "activeForm": "Analyzing coverage gaps"},
|
||||
{"content": "Phase 3.2: Study existing test patterns (test-concept-enhanced)", "status": "pending", "activeForm": "Studying test patterns"},
|
||||
{"content": "Phase 3.3: Generate test generation strategy (test-concept-enhanced)", "status": "pending", "activeForm": "Generating test strategy"},
|
||||
{"content": "Generate test generation and execution tasks", "status": "pending", "activeForm": "Generating test tasks"},
|
||||
{"content": "Return workflow summary", "status": "pending", "activeForm": "Returning workflow summary"}
|
||||
]
|
||||
```
|
||||
|
||||
**Note**: SlashCommand dispatch **attaches** test-concept-enhanced's 3 tasks. Orchestrator **executes** these tasks.
|
||||
|
||||
**Next Action**: Tasks attached → **Execute Phase 3.1-3.3** sequentially
|
||||
|
||||
<!-- TodoWrite: After Phase 3 tasks complete, REMOVE Phase 3.1-3.3, restore to orchestrator view -->
|
||||
|
||||
**TodoWrite Update (Phase 3 completed - tasks collapsed)**:
|
||||
```json
|
||||
[
|
||||
{"content": "Create independent test session", "status": "completed", "activeForm": "Creating test session"},
|
||||
{"content": "Gather test coverage context", "status": "completed", "activeForm": "Gathering test coverage context"},
|
||||
{"content": "Analyze test requirements with Gemini", "status": "completed", "activeForm": "Analyzing test requirements"},
|
||||
{"content": "Generate test generation and execution tasks", "status": "pending", "activeForm": "Generating test tasks"},
|
||||
{"content": "Return workflow summary", "status": "pending", "activeForm": "Returning workflow summary"}
|
||||
]
|
||||
```
|
||||
|
||||
**Note**: Phase 3 tasks completed and collapsed to summary.
|
||||
|
||||
---
|
||||
|
||||
### Phase 4: Generate Test Tasks
|
||||
|
||||
**Step 4.1: Dispatch** - Generate test task JSON files and planning documents
|
||||
|
||||
```javascript
|
||||
SlashCommand(command="/workflow:tools:test-task-generate --session [testSessionId]")
|
||||
```
|
||||
|
||||
**Input**:
|
||||
- `testSessionId` from Phase 1
|
||||
|
||||
**Note**: CLI tool usage for fixes is determined semantically from user's task description (e.g., "use Codex for automated fixes").
|
||||
|
||||
**Expected Behavior**:
|
||||
- Parse TEST_ANALYSIS_RESULTS.md from Phase 3
|
||||
- Extract test requirements and generation strategy
|
||||
- Generate **TWO task JSON files**:
|
||||
- **IMPL-001.json**: Test Generation task (calls @code-developer)
|
||||
- **IMPL-002.json**: Test Execution and Fix Cycle task (calls @test-fix-agent)
|
||||
- Generate IMPL_PLAN.md with test generation and execution strategy
|
||||
- Generate TODO_LIST.md with both tasks
|
||||
|
||||
**Parse Output**:
|
||||
- Verify `.workflow/[testSessionId]/.task/IMPL-001.json` exists (test generation)
|
||||
- Verify `.workflow/[testSessionId]/.task/IMPL-002.json` exists (test execution & fix)
|
||||
- Verify `.workflow/[testSessionId]/IMPL_PLAN.md` created
|
||||
- Verify `.workflow/[testSessionId]/TODO_LIST.md` created
|
||||
|
||||
**Validation - IMPL-001.json (Test Generation)**:
|
||||
- Task ID: `IMPL-001`
|
||||
- `meta.type: "test-gen"`
|
||||
- `meta.agent: "@code-developer"`
|
||||
- `context.requirements`: Generate tests based on TEST_ANALYSIS_RESULTS.md
|
||||
- `flow_control.pre_analysis`: Load TEST_ANALYSIS_RESULTS.md and test context
|
||||
- `flow_control.implementation_approach`: Test generation steps
|
||||
- `flow_control.target_files`: Test files to create from analysis section 5
|
||||
|
||||
**Validation - IMPL-002.json (Test Execution & Fix)**:
|
||||
- Task ID: `IMPL-002`
|
||||
- `meta.type: "test-fix"`
|
||||
- `meta.agent: "@test-fix-agent"`
|
||||
- `context.depends_on: ["IMPL-001"]`
|
||||
- `context.requirements`: Execute and fix tests
|
||||
- `flow_control.implementation_approach.test_fix_cycle`: Complete cycle specification
|
||||
- **Cycle pattern**: test → gemini_diagnose → fix (agent or CLI based on `command` field) → retest
|
||||
- **Tools configuration**: Gemini for analysis with bug-fix template, agent or CLI for fixes
|
||||
- **Exit conditions**: Success (all pass) or failure (max iterations)
|
||||
- `flow_control.implementation_approach.modification_points`: 3-phase execution flow
|
||||
- Phase 1: Initial test execution
|
||||
- Phase 2: Iterative Gemini diagnosis + fixes (agent or CLI based on step's `command` field)
|
||||
- Phase 3: Final validation and certification
|
||||
|
||||
<!-- TodoWrite: When test-task-generate dispatched, INSERT 3 test-task-generate tasks -->
|
||||
|
||||
**TodoWrite Update (Phase 4 SlashCommand dispatched - tasks attached)**:
|
||||
```json
|
||||
[
|
||||
{"content": "Create independent test session", "status": "completed", "activeForm": "Creating test session"},
|
||||
{"content": "Gather test coverage context", "status": "completed", "activeForm": "Gathering test coverage context"},
|
||||
{"content": "Analyze test requirements with Gemini", "status": "completed", "activeForm": "Analyzing test requirements"},
|
||||
{"content": "Phase 4.1: Parse TEST_ANALYSIS_RESULTS.md (test-task-generate)", "status": "in_progress", "activeForm": "Parsing test analysis"},
|
||||
{"content": "Phase 4.2: Generate IMPL-001.json and IMPL-002.json (test-task-generate)", "status": "pending", "activeForm": "Generating task JSONs"},
|
||||
{"content": "Phase 4.3: Generate IMPL_PLAN.md and TODO_LIST.md (test-task-generate)", "status": "pending", "activeForm": "Generating plan documents"},
|
||||
{"content": "Return workflow summary", "status": "pending", "activeForm": "Returning workflow summary"}
|
||||
]
|
||||
```
|
||||
|
||||
**Note**: SlashCommand dispatch **attaches** test-task-generate's 3 tasks. Orchestrator **executes** these tasks.
|
||||
|
||||
**Next Action**: Tasks attached → **Execute Phase 4.1-4.3** sequentially
|
||||
|
||||
<!-- TodoWrite: After Phase 4 tasks complete, REMOVE Phase 4.1-4.3, restore to orchestrator view -->
|
||||
|
||||
**TodoWrite Update (Phase 4 completed - tasks collapsed)**:
|
||||
```json
|
||||
[
|
||||
{"content": "Create independent test session", "status": "completed", "activeForm": "Creating test session"},
|
||||
{"content": "Gather test coverage context", "status": "completed", "activeForm": "Gathering test coverage context"},
|
||||
{"content": "Analyze test requirements with Gemini", "status": "completed", "activeForm": "Analyzing test requirements"},
|
||||
{"content": "Generate test generation and execution tasks", "status": "completed", "activeForm": "Generating test tasks"},
|
||||
{"content": "Return workflow summary", "status": "in_progress", "activeForm": "Returning workflow summary"}
|
||||
]
|
||||
```
|
||||
|
||||
**Note**: Phase 4 tasks completed and collapsed to summary.
|
||||
|
||||
---
|
||||
|
||||
### Phase 5: Return Summary (Command Ends Here)
|
||||
|
||||
**Important**: This is the final phase of `/workflow:test-gen`. The command completes and returns control to the user. No automatic execution occurs.
|
||||
|
||||
**Return to User**:
|
||||
```
|
||||
Test workflow preparation complete!
|
||||
|
||||
Source Session: [sourceSessionId]
|
||||
Test Session: [testSessionId]
|
||||
|
||||
Artifacts Created:
|
||||
- Test context analysis
|
||||
- Test generation strategy
|
||||
- Task definitions (IMPL-001, IMPL-002)
|
||||
- Implementation plan
|
||||
|
||||
Test Framework: [detected framework]
|
||||
Test Files to Generate: [count]
|
||||
Fix Mode: [Agent|CLI] (based on `command` field in implementation_approach steps)
|
||||
|
||||
Review Generated Artifacts:
|
||||
- Test plan: .workflow/[testSessionId]/IMPL_PLAN.md
|
||||
- Task list: .workflow/[testSessionId]/TODO_LIST.md
|
||||
- Analysis: .workflow/[testSessionId]/.process/TEST_ANALYSIS_RESULTS.md
|
||||
|
||||
Ready for execution. Use appropriate workflow commands to proceed.
|
||||
```
|
||||
|
||||
**TodoWrite**: Mark phase 5 completed
|
||||
|
||||
**Command Boundary**: After this phase, the command terminates and returns to user prompt.
|
||||
|
||||
---
|
||||
|
||||
## TodoWrite Pattern
|
||||
|
||||
**Core Concept**: Dynamic task attachment and collapse for test-gen workflow with cross-session context gathering and test generation strategy.
|
||||
|
||||
### Key Principles
|
||||
|
||||
1. **Task Attachment** (when SlashCommand dispatched):
|
||||
- Sub-command's internal tasks are **attached** to orchestrator's TodoWrite
|
||||
- Example: `/workflow:tools:test-context-gather` attaches 3 sub-tasks (Phase 2.1, 2.2, 2.3)
|
||||
- First attached task marked as `in_progress`, others as `pending`
|
||||
- Orchestrator **executes** these attached tasks sequentially
|
||||
|
||||
2. **Task Collapse** (after sub-tasks complete):
|
||||
- Remove detailed sub-tasks from TodoWrite
|
||||
- **Collapse** to high-level phase summary
|
||||
- Example: Phase 2.1-2.3 collapse to "Gather test coverage context: completed"
|
||||
- Maintains clean orchestrator-level view
|
||||
|
||||
3. **Continuous Execution**:
|
||||
- After collapse, automatically proceed to next pending phase
|
||||
- No user intervention required between phases
|
||||
- TodoWrite dynamically reflects current execution state
|
||||
|
||||
**Lifecycle Summary**: Initial pending tasks → Phase dispatched (tasks ATTACHED) → Sub-tasks executed sequentially → Phase completed (tasks COLLAPSED to summary) → Next phase begins → Repeat until all phases complete.
|
||||
|
||||
### Test-Gen Specific Features
|
||||
|
||||
- **Phase 2**: Cross-session context gathering from source implementation session
|
||||
- **Phase 3**: Test requirements analysis with Gemini for generation strategy
|
||||
- **Phase 4**: Dual-task generation (IMPL-001 for test generation, IMPL-002 for test execution)
|
||||
- **Fix Mode Configuration**: CLI tool usage determined semantically from user's task description
|
||||
|
||||
|
||||
|
||||
**Note**: See individual Phase descriptions (Phase 2, 3, 4) for detailed TodoWrite Update examples with full JSON structures.
|
||||
|
||||
## Execution Flow Diagram
|
||||
|
||||
```
|
||||
Test-Gen Workflow Orchestrator
|
||||
│
|
||||
├─ Phase 1: Create Test Session
|
||||
│ └─ /workflow:session:start --new
|
||||
│ └─ Returns: testSessionId (WFS-test-[source])
|
||||
│
|
||||
├─ Phase 2: Gather Test Context ← ATTACHED (3 tasks)
|
||||
│ └─ /workflow:tools:test-context-gather
|
||||
│ ├─ Phase 2.1: Load source session summaries
|
||||
│ ├─ Phase 2.2: Analyze test coverage with MCP tools
|
||||
│ └─ Phase 2.3: Identify coverage gaps and framework
|
||||
│ └─ Returns: test-context-package.json ← COLLAPSED
|
||||
│
|
||||
├─ Phase 3: Test Generation Analysis ← ATTACHED (3 tasks)
|
||||
│ └─ /workflow:tools:test-concept-enhanced
|
||||
│ ├─ Phase 3.1: Analyze coverage gaps with Gemini
|
||||
│ ├─ Phase 3.2: Study existing test patterns
|
||||
│ └─ Phase 3.3: Generate test generation strategy
|
||||
│ └─ Returns: TEST_ANALYSIS_RESULTS.md ← COLLAPSED
|
||||
│
|
||||
├─ Phase 4: Generate Test Tasks ← ATTACHED (3 tasks)
|
||||
│ └─ /workflow:tools:test-task-generate
|
||||
│ ├─ Phase 4.1: Parse TEST_ANALYSIS_RESULTS.md
|
||||
│ ├─ Phase 4.2: Generate IMPL-001.json and IMPL-002.json
|
||||
│ └─ Phase 4.3: Generate IMPL_PLAN.md and TODO_LIST.md
|
||||
│ └─ Returns: Task JSONs and plans ← COLLAPSED
|
||||
│
|
||||
└─ Phase 5: Return Summary
|
||||
└─ Command ends, control returns to user
|
||||
|
||||
Artifacts Created:
|
||||
├── .workflow/active/WFS-test-[session]/
|
||||
│ ├── workflow-session.json
|
||||
│ ├── IMPL_PLAN.md
|
||||
│ ├── TODO_LIST.md
|
||||
│ ├── .task/
|
||||
│ │ ├── IMPL-001.json (test generation task)
|
||||
│ │ └── IMPL-002.json (test execution task)
|
||||
│ └── .process/
|
||||
│ ├── test-context-package.json
|
||||
│ └── TEST_ANALYSIS_RESULTS.md
|
||||
|
||||
Key Points:
|
||||
• ← ATTACHED: SlashCommand attaches sub-tasks to orchestrator TodoWrite
|
||||
• ← COLLAPSED: Sub-tasks executed and collapsed to phase summary
|
||||
```
|
||||
|
||||
## Session Metadata
|
||||
|
||||
Test session includes `workflow_type: "test_session"` and `source_session_id` for automatic context gathering.
|
||||
|
||||
## Task Output
|
||||
|
||||
Generates two task definition files:
|
||||
- **IMPL-001.json**: Test generation task specification
|
||||
- Agent: @code-developer
|
||||
- Input: TEST_ANALYSIS_RESULTS.md
|
||||
- Output: Test files based on analysis
|
||||
- **IMPL-002.json**: Test execution and fix cycle specification
|
||||
- Agent: @test-fix-agent
|
||||
- Dependency: IMPL-001 must complete first
|
||||
- Max iterations: 5
|
||||
- Fix mode: Agent or CLI (based on `command` field in implementation_approach)
|
||||
|
||||
See `/workflow:tools:test-task-generate` for complete task JSON schemas.
|
||||
|
||||
## Error Handling
|
||||
|
||||
| Phase | Error | Action |
|
||||
|-------|-------|--------|
|
||||
| 1 | Source session not found | Return error with source session ID |
|
||||
| 1 | No completed IMPL tasks | Return error, source incomplete |
|
||||
| 2 | Context gathering failed | Return error, check source artifacts |
|
||||
| 3 | Analysis failed | Return error, check context package |
|
||||
| 4 | Task generation failed | Retry once, then error with details |
|
||||
|
||||
## Output Files
|
||||
|
||||
Created in `.workflow/active/WFS-test-[session]/`:
|
||||
- `workflow-session.json` - Session metadata
|
||||
- `.process/test-context-package.json` - Coverage analysis
|
||||
- `.process/TEST_ANALYSIS_RESULTS.md` - Test requirements
|
||||
- `.task/IMPL-001.json` - Test generation task
|
||||
- `.task/IMPL-002.json` - Test execution & fix task
|
||||
- `IMPL_PLAN.md` - Test plan
|
||||
- `TODO_LIST.md` - Task checklist
|
||||
|
||||
## Task Specifications
|
||||
|
||||
**IMPL-001.json Structure**:
|
||||
- `meta.type: "test-gen"`
|
||||
- `meta.agent: "@code-developer"`
|
||||
- `context.requirements`: Generate tests based on TEST_ANALYSIS_RESULTS.md
|
||||
- `flow_control.target_files`: Test files to create
|
||||
- `flow_control.implementation_approach`: Test generation strategy
|
||||
|
||||
**IMPL-002.json Structure**:
|
||||
- `meta.type: "test-fix"`
|
||||
- `meta.agent: "@test-fix-agent"`
|
||||
- `context.depends_on: ["IMPL-001"]`
|
||||
- `flow_control.implementation_approach.test_fix_cycle`: Complete cycle specification
|
||||
- Gemini diagnosis template
|
||||
- Fix application mode (agent or CLI based on `command` field)
|
||||
- Max iterations: 5
|
||||
- `flow_control.implementation_approach.modification_points`: 3-phase flow
|
||||
|
||||
See `/workflow:tools:test-task-generate` for complete JSON schemas.
|
||||
|
||||
## Best Practices
|
||||
|
||||
1. **Prerequisites**: Ensure source session has completed IMPL tasks with summaries
|
||||
2. **Clean State**: Commit implementation changes before running test-gen
|
||||
3. **Review Artifacts**: Check generated IMPL_PLAN.md and TODO_LIST.md before proceeding
|
||||
4. **Understand Scope**: This command only prepares artifacts; it does not execute tests
|
||||
|
||||
## Related Commands
|
||||
|
||||
**Prerequisite Commands**:
|
||||
- `/workflow:plan` or `/workflow:execute` - Complete implementation session that needs test validation
|
||||
|
||||
**Dispatched by This Command** (4 phases):
|
||||
- `/workflow:session:start` - Phase 1: Create independent test workflow session
|
||||
- `/workflow:tools:test-context-gather` - Phase 2: Analyze test coverage and gather source session context
|
||||
- `/workflow:tools:test-concept-enhanced` - Phase 3: Generate test requirements and strategy using Gemini
|
||||
- `/workflow:tools:test-task-generate` - Phase 4: Generate test task JSONs (CLI tool usage determined semantically)
|
||||
|
||||
**Follow-up Commands**:
|
||||
- `/workflow:status` - Review generated test tasks
|
||||
- `/workflow:test-cycle-execute` - Execute test generation and fix cycles
|
||||
- `/workflow:execute` - Execute generated test tasks
|
||||
391
.claude/commands/workflow/tools/code-validation-gate.md
Normal file
391
.claude/commands/workflow/tools/code-validation-gate.md
Normal file
@@ -0,0 +1,391 @@
|
||||
---
|
||||
name: code-validation-gate
|
||||
description: Validate AI-generated code for common errors (imports, variables, types) before test execution
|
||||
argument-hint: "--session WFS-test-session-id [--fix] [--strict]"
|
||||
examples:
|
||||
- /workflow:tools:code-validation-gate --session WFS-test-auth
|
||||
- /workflow:tools:code-validation-gate --session WFS-test-auth --fix
|
||||
- /workflow:tools:code-validation-gate --session WFS-test-auth --strict
|
||||
---
|
||||
|
||||
# Code Validation Gate Command
|
||||
|
||||
## Overview
|
||||
|
||||
Pre-test validation gate that checks AI-generated code for common errors before test execution. This prevents wasted test cycles on code with fundamental issues like import errors, variable conflicts, and type mismatches.
|
||||
|
||||
## Core Philosophy
|
||||
|
||||
- **Fail Fast**: Catch fundamental errors before expensive test execution
|
||||
- **AI-Aware**: Specifically targets common AI code generation mistakes
|
||||
- **Auto-Remediation**: Attempt safe fixes before failing
|
||||
- **Clear Feedback**: Provide actionable fix suggestions for manual intervention
|
||||
|
||||
## Target Error Categories
|
||||
|
||||
### L0.1: Compilation Errors
|
||||
- TypeScript compilation failures
|
||||
- Syntax errors
|
||||
- Module resolution failures
|
||||
|
||||
### L0.2: Import Errors
|
||||
- Unresolved module imports (hallucinated packages)
|
||||
- Circular dependencies
|
||||
- Duplicate imports
|
||||
- Unused imports
|
||||
|
||||
### L0.3: Variable Errors
|
||||
- Variable redeclaration
|
||||
- Scope conflicts (shadowing)
|
||||
- Undefined variable usage
|
||||
- Unused variables
|
||||
|
||||
### L0.4: Type Errors (TypeScript)
|
||||
- Type mismatches
|
||||
- Missing type definitions
|
||||
- Excessive `any` usage
|
||||
- Implicit `any` types
|
||||
|
||||
### L0.5: AI-Specific Patterns
|
||||
- Placeholder code (`// TODO: implement`)
|
||||
- Hallucinated package imports
|
||||
- Mock code in production files
|
||||
- Inconsistent naming patterns
|
||||
|
||||
## Execution Process
|
||||
|
||||
```
|
||||
Input Parsing:
|
||||
├─ Parse flags: --session (required), --fix, --strict
|
||||
└─ Load test-quality-config.json
|
||||
|
||||
Phase 1: Context Loading
|
||||
├─ Load session metadata
|
||||
├─ Identify target files (from IMPL-001 output or context-package)
|
||||
└─ Detect project configuration (tsconfig, eslint, etc.)
|
||||
|
||||
Phase 2: Validation Execution
|
||||
├─ L0.1: Run TypeScript compilation check
|
||||
├─ L0.2: Run import validation
|
||||
├─ L0.3: Run variable validation
|
||||
├─ L0.4: Run type validation
|
||||
└─ L0.5: Run AI-specific checks
|
||||
|
||||
Phase 3: Result Analysis
|
||||
├─ Aggregate all findings by severity
|
||||
├─ Calculate pass/fail status
|
||||
└─ Generate fix suggestions
|
||||
|
||||
Phase 4: Auto-Fix (if --fix enabled)
|
||||
├─ Apply safe auto-fixes (imports, formatting)
|
||||
├─ Re-run validation
|
||||
└─ Report remaining issues
|
||||
|
||||
Phase 5: Gate Decision
|
||||
├─ PASS: Proceed to IMPL-001.5
|
||||
├─ SOFT_FAIL: Auto-fix applied, needs re-validation
|
||||
└─ HARD_FAIL: Block with detailed report
|
||||
```
|
||||
|
||||
## Execution Lifecycle
|
||||
|
||||
### Phase 1: Context Loading
|
||||
|
||||
**Load session and identify validation targets.**
|
||||
|
||||
```javascript
|
||||
// Load session metadata
|
||||
Read(".workflow/active/{session_id}/workflow-session.json")
|
||||
|
||||
// Load context package for target files
|
||||
Read(".workflow/active/{session_id}/.process/context-package.json")
|
||||
// OR
|
||||
Read(".workflow/active/{session_id}/.process/test-context-package.json")
|
||||
|
||||
// Identify files to validate:
|
||||
// 1. Source files from context.implementation_files
|
||||
// 2. Test files from IMPL-001 output (if exists)
|
||||
// 3. All modified files since session start
|
||||
```
|
||||
|
||||
**Target File Discovery**:
|
||||
- Source files: `context.focus_paths` from context-package
|
||||
- Generated tests: `.workflow/active/{session_id}/.task/IMPL-001-output/`
|
||||
- All TypeScript/JavaScript in target directories
|
||||
|
||||
### Phase 2: Validation Execution
|
||||
|
||||
**Execute validation checks in order of dependency.**
|
||||
|
||||
#### L0.1: TypeScript Compilation
|
||||
|
||||
```bash
|
||||
# Primary check - catches most fundamental errors
|
||||
npx tsc --noEmit --skipLibCheck --project tsconfig.json 2>&1
|
||||
|
||||
# Parse output for errors
|
||||
# Critical: Any compilation error blocks further validation
|
||||
```
|
||||
|
||||
**Error Patterns**:
|
||||
```
|
||||
error TS2307: Cannot find module 'xxx'
|
||||
error TS2451: Cannot redeclare block-scoped variable 'xxx'
|
||||
error TS2322: Type 'xxx' is not assignable to type 'yyy'
|
||||
```
|
||||
|
||||
#### L0.2: Import Validation
|
||||
|
||||
```bash
|
||||
# Check for circular dependencies
|
||||
npx madge --circular --extensions ts,tsx,js,jsx {target_dirs}
|
||||
|
||||
# ESLint import rules
|
||||
npx eslint --rule 'import/no-duplicates: error' --rule 'import/no-unresolved: error' {files}
|
||||
```
|
||||
|
||||
**Hallucinated Package Check**:
|
||||
```javascript
|
||||
// Extract all imports from files
|
||||
// Verify each package exists in package.json or node_modules
|
||||
// Flag any unresolvable imports as "hallucinated"
|
||||
```
|
||||
|
||||
#### L0.3: Variable Validation
|
||||
|
||||
```bash
|
||||
# ESLint variable rules
|
||||
npx eslint --rule 'no-shadow: error' --rule 'no-undef: error' --rule 'no-redeclare: error' {files}
|
||||
```
|
||||
|
||||
#### L0.4: Type Validation
|
||||
|
||||
```bash
|
||||
# TypeScript strict checks
|
||||
npx tsc --noEmit --strict {files}
|
||||
|
||||
# Check for any abuse
|
||||
npx eslint --rule '@typescript-eslint/no-explicit-any: warn' {files}
|
||||
```
|
||||
|
||||
#### L0.5: AI-Specific Checks
|
||||
|
||||
```bash
|
||||
# Check for placeholder code
|
||||
grep -rn "// TODO: implement\|// Add your code here\|throw new Error.*Not implemented" {files}
|
||||
|
||||
# Check for mock code in production files
|
||||
grep -rn "jest\.mock\|sinon\.\|vi\.mock" {source_files_only}
|
||||
```
|
||||
|
||||
### Phase 3: Result Analysis
|
||||
|
||||
**Aggregate and categorize findings.**
|
||||
|
||||
```javascript
|
||||
const findings = {
|
||||
critical: [], // Blocks all progress
|
||||
error: [], // Blocks with threshold
|
||||
warning: [] // Advisory only
|
||||
};
|
||||
|
||||
// Apply thresholds from config
|
||||
const config = loadConfig("test-quality-config.json");
|
||||
const thresholds = config.code_validation.severity_thresholds;
|
||||
|
||||
// Gate decision
|
||||
if (findings.critical.length > thresholds.critical) {
|
||||
decision = "HARD_FAIL";
|
||||
} else if (findings.error.length > thresholds.error) {
|
||||
decision = "SOFT_FAIL"; // Try auto-fix
|
||||
} else {
|
||||
decision = "PASS";
|
||||
}
|
||||
```
|
||||
|
||||
### Phase 4: Auto-Fix (Optional)
|
||||
|
||||
**Apply safe automatic fixes when --fix flag provided.**
|
||||
|
||||
```bash
|
||||
# Safe fixes only
|
||||
npx eslint --fix --rule 'import/no-duplicates: error' --rule 'unused-imports/no-unused-imports: error' {files}
|
||||
|
||||
# Re-run validation after fixes
|
||||
# Report what was fixed vs what remains
|
||||
```
|
||||
|
||||
**Safe Fix Categories**:
|
||||
- Remove unused imports
|
||||
- Remove duplicate imports
|
||||
- Fix import ordering
|
||||
- Remove unused variables (with caution)
|
||||
- Formatting fixes
|
||||
|
||||
**Unsafe (Manual Only)**:
|
||||
- Missing imports (need to determine correct package)
|
||||
- Type errors (need to understand intent)
|
||||
- Variable shadowing (need to understand scope intent)
|
||||
|
||||
### Phase 5: Gate Decision
|
||||
|
||||
**Determine next action based on results.**
|
||||
|
||||
| Decision | Condition | Action |
|
||||
|----------|-----------|--------|
|
||||
| **PASS** | critical=0, error<=3, warning<=10 | Proceed to IMPL-001.5 |
|
||||
| **SOFT_FAIL** | critical=0, error>3 OR fixable issues | Auto-fix and retry (max 2) |
|
||||
| **HARD_FAIL** | critical>0 OR max retries exceeded | Block with report |
|
||||
|
||||
## Output Artifacts
|
||||
|
||||
### Validation Report
|
||||
|
||||
**File**: `.workflow/active/{session_id}/.process/code-validation-report.md`
|
||||
|
||||
```markdown
|
||||
# Code Validation Report
|
||||
|
||||
**Session**: {session_id}
|
||||
**Timestamp**: {timestamp}
|
||||
**Status**: PASS | SOFT_FAIL | HARD_FAIL
|
||||
|
||||
## Summary
|
||||
- Files Validated: {count}
|
||||
- Critical Issues: {count}
|
||||
- Errors: {count}
|
||||
- Warnings: {count}
|
||||
|
||||
## Critical Issues (Must Fix)
|
||||
### Import Errors
|
||||
- `src/auth/service.ts:5` - Cannot find module 'non-existent-package'
|
||||
- **Suggestion**: Check if package exists, may be hallucinated by AI
|
||||
|
||||
### Variable Conflicts
|
||||
- `src/utils/helper.ts:12` - Cannot redeclare block-scoped variable 'config'
|
||||
- **Suggestion**: Rename one of the variables or merge declarations
|
||||
|
||||
## Errors (Should Fix)
|
||||
...
|
||||
|
||||
## Warnings (Consider Fixing)
|
||||
...
|
||||
|
||||
## Auto-Fix Applied
|
||||
- Removed 3 unused imports in `src/auth/service.ts`
|
||||
- Fixed import ordering in `src/utils/index.ts`
|
||||
|
||||
## Remaining Issues Requiring Manual Fix
|
||||
...
|
||||
|
||||
## Next Steps
|
||||
- [ ] Fix critical issues before proceeding
|
||||
- [ ] Review error suggestions
|
||||
- [ ] Re-run validation: `/workflow:tools:code-validation-gate --session {session_id}`
|
||||
```
|
||||
|
||||
### JSON Report (Machine-Readable)
|
||||
|
||||
**File**: `.workflow/active/{session_id}/.process/code-validation-report.json`
|
||||
|
||||
```json
|
||||
{
|
||||
"session_id": "WFS-test-xxx",
|
||||
"timestamp": "2025-01-30T10:00:00Z",
|
||||
"status": "HARD_FAIL",
|
||||
"summary": {
|
||||
"files_validated": 15,
|
||||
"critical": 2,
|
||||
"error": 5,
|
||||
"warning": 8
|
||||
},
|
||||
"findings": {
|
||||
"critical": [
|
||||
{
|
||||
"category": "import",
|
||||
"file": "src/auth/service.ts",
|
||||
"line": 5,
|
||||
"message": "Cannot find module 'non-existent-package'",
|
||||
"suggestion": "Check if package exists in package.json",
|
||||
"auto_fixable": false
|
||||
}
|
||||
],
|
||||
"error": [...],
|
||||
"warning": [...]
|
||||
},
|
||||
"auto_fixes_applied": [...],
|
||||
"gate_decision": "HARD_FAIL",
|
||||
"retry_count": 0,
|
||||
"max_retries": 2
|
||||
}
|
||||
```
|
||||
|
||||
## Command Options
|
||||
|
||||
| Option | Description | Default |
|
||||
|--------|-------------|---------|
|
||||
| `--session` | Test session ID (required) | - |
|
||||
| `--fix` | Enable auto-fix for safe issues | false |
|
||||
| `--strict` | Use strict thresholds (0 errors allowed) | false |
|
||||
| `--files` | Specific files to validate (comma-separated) | All target files |
|
||||
| `--skip-types` | Skip TypeScript type checks | false |
|
||||
|
||||
## Integration
|
||||
|
||||
### Command Chain
|
||||
|
||||
- **Called By**: `/workflow:test-fix-gen` (after IMPL-001)
|
||||
- **Requires**: IMPL-001 output OR context-package.json
|
||||
- **Followed By**: IMPL-001.5 (Test Quality Gate) on PASS
|
||||
|
||||
### Task JSON Integration
|
||||
|
||||
When used in test-fix workflow, generates task:
|
||||
|
||||
```json
|
||||
{
|
||||
"id": "IMPL-001.3-validation",
|
||||
"meta": {
|
||||
"type": "code-validation",
|
||||
"agent": "@test-fix-agent"
|
||||
},
|
||||
"context": {
|
||||
"depends_on": ["IMPL-001"],
|
||||
"requirements": "Validate generated code for AI common errors"
|
||||
},
|
||||
"flow_control": {
|
||||
"validation_config": "~/.claude/workflows/test-quality-config.json",
|
||||
"max_retries": 2,
|
||||
"auto_fix_enabled": true
|
||||
},
|
||||
"acceptance_criteria": [
|
||||
"Zero critical issues",
|
||||
"Maximum 3 error issues",
|
||||
"All imports resolvable",
|
||||
"No variable redeclarations"
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
## Error Handling
|
||||
|
||||
| Error | Resolution |
|
||||
|-------|------------|
|
||||
| tsconfig.json not found | Use default compiler options |
|
||||
| ESLint not installed | Skip ESLint checks, use tsc only |
|
||||
| madge not installed | Skip circular dependency check |
|
||||
| No files to validate | Return PASS (nothing to check) |
|
||||
|
||||
## Best Practices
|
||||
|
||||
1. **Run Early**: Execute validation immediately after code generation
|
||||
2. **Use --fix First**: Let auto-fix resolve trivial issues
|
||||
3. **Review Suggestions**: AI fix suggestions may need human judgment
|
||||
4. **Don't Skip Critical**: Never proceed with critical errors
|
||||
5. **Track Patterns**: Common failures indicate prompt improvement opportunities
|
||||
|
||||
## Related Commands
|
||||
|
||||
- `/workflow:test-fix-gen` - Parent workflow that invokes this command
|
||||
- `/workflow:tools:test-quality-gate` - Next phase (IMPL-001.5) for test quality
|
||||
- `/workflow:test-cycle-execute` - Execute tests after validation passes
|
||||
@@ -1,12 +1,16 @@
|
||||
---
|
||||
name: conflict-resolution
|
||||
description: Detect and resolve conflicts between plan and existing codebase using CLI-powered analysis with Gemini/Qwen
|
||||
argument-hint: "--session WFS-session-id --context path/to/context-package.json"
|
||||
argument-hint: "[-y|--yes] --session WFS-session-id --context path/to/context-package.json"
|
||||
examples:
|
||||
- /workflow:tools:conflict-resolution --session WFS-auth --context .workflow/active/WFS-auth/.process/context-package.json
|
||||
- /workflow:tools:conflict-resolution --session WFS-payment --context .workflow/active/WFS-payment/.process/context-package.json
|
||||
- /workflow:tools:conflict-resolution -y --session WFS-payment --context .workflow/active/WFS-payment/.process/context-package.json
|
||||
---
|
||||
|
||||
## Auto Mode
|
||||
|
||||
When `--yes` or `-y`: Auto-select recommended strategy for each conflict, skip clarification questions.
|
||||
|
||||
# Conflict Resolution Command
|
||||
|
||||
## Purpose
|
||||
@@ -21,10 +25,10 @@ Analyzes conflicts between implementation plans and existing codebase, **includi
|
||||
| Responsibility | Description |
|
||||
|---------------|-------------|
|
||||
| **Detect Conflicts** | Analyze plan vs existing code inconsistencies |
|
||||
| **Scenario Uniqueness** | **NEW**: Search and compare new modules with existing modules for functional overlaps |
|
||||
| **Scenario Uniqueness** | Search and compare new modules with existing modules for functional overlaps |
|
||||
| **Generate Strategies** | Provide 2-4 resolution options per conflict |
|
||||
| **Iterative Clarification** | **NEW**: Ask unlimited questions until scenario boundaries are clear and unique |
|
||||
| **Agent Re-analysis** | **NEW**: Dynamically update strategies based on user clarifications |
|
||||
| **Iterative Clarification** | Ask unlimited questions until scenario boundaries are clear and unique |
|
||||
| **Agent Re-analysis** | Dynamically update strategies based on user clarifications |
|
||||
| **CLI Analysis** | Use Gemini/Qwen (Claude fallback) |
|
||||
| **User Decision** | Present options ONE BY ONE, never auto-apply |
|
||||
| **Direct Text Output** | Output questions via text directly, NEVER use bash echo/printf |
|
||||
@@ -53,7 +57,7 @@ Analyzes conflicts between implementation plans and existing codebase, **includi
|
||||
- Breaking updates
|
||||
|
||||
### 5. Module Scenario Overlap
|
||||
- **NEW**: Functional overlap between new and existing modules
|
||||
- Functional overlap between new and existing modules
|
||||
- Scenario boundary ambiguity
|
||||
- Duplicate responsibility detection
|
||||
- Module merge/split decisions
|
||||
@@ -124,10 +128,13 @@ Task(subagent_type="cli-execution-agent", run_in_background=false, prompt=`
|
||||
|
||||
## Analysis Steps
|
||||
|
||||
### 0. Load Output Schema (MANDATORY)
|
||||
Execute: cat ~/.claude/workflows/cli-templates/schemas/conflict-resolution-schema.json
|
||||
|
||||
### 1. Load Context
|
||||
- Read existing files from conflict_detection.existing_files
|
||||
- Load plan from .workflow/active/{session_id}/.process/context-package.json
|
||||
- **NEW**: Load exploration_results and use aggregated_insights for enhanced analysis
|
||||
- Load exploration_results and use aggregated_insights for enhanced analysis
|
||||
- Extract role analyses and requirements
|
||||
|
||||
### 2. Execute CLI Analysis (Enhanced with Exploration + Scenario Uniqueness)
|
||||
@@ -151,8 +158,8 @@ Task(subagent_type="cli-execution-agent", run_in_background=false, prompt=`
|
||||
- Validation of exploration conflict_indicators
|
||||
- ModuleOverlap conflicts with overlap_analysis
|
||||
- Targeted clarification questions
|
||||
RULES: $(cat ~/.claude/workflows/cli-templates/prompts/analysis/02-analyze-code-patterns.txt) | Focus on breaking changes, migration needs, and functional overlaps | Prioritize exploration-identified conflicts | analysis=READ-ONLY
|
||||
" --tool gemini --mode analysis --cd {project_root}
|
||||
CONSTRAINTS: Focus on breaking changes, migration needs, and functional overlaps | Prioritize exploration-identified conflicts | analysis=READ-ONLY
|
||||
" --tool gemini --mode analysis --rule analysis-code-patterns --cd {project_root}
|
||||
|
||||
Fallback: Qwen (same prompt) → Claude (manual analysis)
|
||||
|
||||
@@ -171,284 +178,115 @@ Task(subagent_type="cli-execution-agent", run_in_background=false, prompt=`
|
||||
|
||||
⚠️ Output to conflict-resolution.json (generated in Phase 4)
|
||||
|
||||
Return JSON format for programmatic processing:
|
||||
**Schema Reference**: Execute \`cat ~/.claude/workflows/cli-templates/schemas/conflict-resolution-schema.json\` to get full schema
|
||||
|
||||
\`\`\`json
|
||||
{
|
||||
"conflicts": [
|
||||
{
|
||||
"id": "CON-001",
|
||||
"brief": "一行中文冲突摘要",
|
||||
"severity": "Critical|High|Medium",
|
||||
"category": "Architecture|API|Data|Dependency|ModuleOverlap",
|
||||
"affected_files": [
|
||||
".workflow/active/{session}/.brainstorm/guidance-specification.md",
|
||||
".workflow/active/{session}/.brainstorm/system-architect/analysis.md"
|
||||
],
|
||||
"description": "详细描述冲突 - 什么不兼容",
|
||||
"impact": {
|
||||
"scope": "影响的模块/组件",
|
||||
"compatibility": "Yes|No|Partial",
|
||||
"migration_required": true|false,
|
||||
"estimated_effort": "人天估计"
|
||||
},
|
||||
"overlap_analysis": {
|
||||
"// NOTE": "仅当 category=ModuleOverlap 时需要此字段",
|
||||
"new_module": {
|
||||
"name": "新模块名称",
|
||||
"scenarios": ["场景1", "场景2", "场景3"],
|
||||
"responsibilities": "职责描述"
|
||||
},
|
||||
"existing_modules": [
|
||||
{
|
||||
"file": "src/existing/module.ts",
|
||||
"name": "现有模块名称",
|
||||
"scenarios": ["场景A", "场景B"],
|
||||
"overlap_scenarios": ["重叠场景1", "重叠场景2"],
|
||||
"responsibilities": "现有模块职责"
|
||||
}
|
||||
]
|
||||
},
|
||||
"strategies": [
|
||||
{
|
||||
"name": "策略名称(中文)",
|
||||
"approach": "实现方法简述",
|
||||
"complexity": "Low|Medium|High",
|
||||
"risk": "Low|Medium|High",
|
||||
"effort": "时间估计",
|
||||
"pros": ["优点1", "优点2"],
|
||||
"cons": ["缺点1", "缺点2"],
|
||||
"clarification_needed": [
|
||||
"// NOTE: 仅当需要用户进一步澄清时需要此字段(尤其是 ModuleOverlap)",
|
||||
"新模块的核心职责边界是什么?",
|
||||
"如何与现有模块 X 协作?",
|
||||
"哪些场景应该由新模块处理?"
|
||||
],
|
||||
"modifications": [
|
||||
{
|
||||
"file": ".workflow/active/{session}/.brainstorm/guidance-specification.md",
|
||||
"section": "## 2. System Architect Decisions",
|
||||
"change_type": "update",
|
||||
"old_content": "原始内容片段(用于定位)",
|
||||
"new_content": "修改后的内容",
|
||||
"rationale": "为什么这样改"
|
||||
},
|
||||
{
|
||||
"file": ".workflow/active/{session}/.brainstorm/system-architect/analysis.md",
|
||||
"section": "## Design Decisions",
|
||||
"change_type": "update",
|
||||
"old_content": "原始内容片段",
|
||||
"new_content": "修改后的内容",
|
||||
"rationale": "修改理由"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "策略2名称",
|
||||
"approach": "...",
|
||||
"complexity": "Medium",
|
||||
"risk": "Low",
|
||||
"effort": "1-2天",
|
||||
"pros": ["优点"],
|
||||
"cons": ["缺点"],
|
||||
"modifications": [...]
|
||||
}
|
||||
],
|
||||
"recommended": 0,
|
||||
"modification_suggestions": [
|
||||
"建议1:具体的修改方向或注意事项",
|
||||
"建议2:可能需要考虑的边界情况",
|
||||
"建议3:相关的最佳实践或模式"
|
||||
]
|
||||
}
|
||||
],
|
||||
"summary": {
|
||||
"total": 2,
|
||||
"critical": 1,
|
||||
"high": 1,
|
||||
"medium": 0
|
||||
}
|
||||
}
|
||||
\`\`\`
|
||||
|
||||
⚠️ CRITICAL Requirements for modifications field:
|
||||
- old_content: Must be exact text from target file (20-100 chars for unique match)
|
||||
- new_content: Complete replacement text (maintains formatting)
|
||||
- change_type: "update" (replace), "add" (insert), "remove" (delete)
|
||||
- file: Full path relative to project root
|
||||
- section: Markdown heading for context (helps locate position)
|
||||
Return JSON following the schema above. Key requirements:
|
||||
- Minimum 2 strategies per conflict, max 4
|
||||
- All text in Chinese for user-facing fields (brief, name, pros, cons)
|
||||
- modification_suggestions: 2-5 actionable suggestions for custom handling (Chinese)
|
||||
- All text in Chinese for user-facing fields (brief, name, pros, cons, modification_suggestions)
|
||||
- modifications.old_content: 20-100 chars for unique Edit tool matching
|
||||
- modifications.new_content: preserves markdown formatting
|
||||
- modification_suggestions: 2-5 actionable suggestions for custom handling
|
||||
|
||||
Quality Standards:
|
||||
- Each strategy must have actionable modifications
|
||||
- old_content must be precise enough for Edit tool matching
|
||||
- new_content preserves markdown formatting and structure
|
||||
- Recommended strategy (index) based on lowest complexity + risk
|
||||
- modification_suggestions must be specific, actionable, and context-aware
|
||||
- Each suggestion should address a specific aspect (compatibility, migration, testing, etc.)
|
||||
### 5. Planning Notes Record (REQUIRED)
|
||||
After analysis complete, append a brief execution record to planning-notes.md:
|
||||
|
||||
**File**: .workflow/active/{session_id}/planning-notes.md
|
||||
**Location**: Under "## Conflict Decisions (Phase 3)" section
|
||||
**Format**:
|
||||
\`\`\`
|
||||
### [Conflict-Resolution Agent] YYYY-MM-DD
|
||||
- **Note**: [智能补充:简短总结冲突类型、解决策略、关键决策等]
|
||||
\`\`\`
|
||||
`)
|
||||
```
|
||||
|
||||
**Agent Internal Flow** (Enhanced):
|
||||
```
|
||||
1. Load context package
|
||||
2. Check conflict_risk (exit if none/low)
|
||||
3. Read existing files + plan artifacts
|
||||
4. Run CLI analysis (Gemini→Qwen→Claude) with enhanced tasks:
|
||||
- Standard conflict detection (Architecture/API/Data/Dependency)
|
||||
- **NEW: Module scenario uniqueness detection**
|
||||
* Extract new module functionality from plan
|
||||
* Search all existing modules with similar keywords/functionality
|
||||
* Compare scenario coverage and responsibilities
|
||||
* Identify functional overlaps and boundary ambiguities
|
||||
* Generate ModuleOverlap conflicts with overlap_analysis
|
||||
5. Parse conflict findings (including ModuleOverlap category)
|
||||
6. Generate 2-4 strategies per conflict:
|
||||
- Include modifications for each strategy
|
||||
- **For ModuleOverlap**: Add clarification_needed questions for boundary definition
|
||||
7. Return JSON to stdout (NOT file write)
|
||||
8. Return execution log path
|
||||
```
|
||||
### Phase 3: User Interaction Loop
|
||||
|
||||
### Phase 3: Iterative User Interaction with Clarification Loop
|
||||
```javascript
|
||||
const autoYes = $ARGUMENTS.includes('--yes') || $ARGUMENTS.includes('-y')
|
||||
|
||||
**Execution Flow**:
|
||||
```
|
||||
FOR each conflict (逐个处理,无数量限制):
|
||||
clarified = false
|
||||
round = 0
|
||||
userClarifications = []
|
||||
FOR each conflict:
|
||||
round = 0, clarified = false, userClarifications = []
|
||||
|
||||
WHILE (!clarified && round < 10):
|
||||
round++
|
||||
WHILE (!clarified && round++ < 10):
|
||||
// 1. Display conflict info (text output for context)
|
||||
displayConflictSummary(conflict) // id, brief, severity, overlap_analysis if ModuleOverlap
|
||||
|
||||
// 1. Display conflict (包含所有关键字段)
|
||||
- category, id, brief, severity, description
|
||||
- IF ModuleOverlap: 展示 overlap_analysis
|
||||
* new_module: {name, scenarios, responsibilities}
|
||||
* existing_modules[]: {file, name, scenarios, overlap_scenarios, responsibilities}
|
||||
|
||||
// 2. Display strategies (2-4个策略 + 自定义选项)
|
||||
- FOR each strategy: {name, approach, complexity, risk, effort, pros, cons}
|
||||
* IF clarification_needed: 展示待澄清问题列表
|
||||
- 自定义选项: {suggestions: modification_suggestions[]}
|
||||
|
||||
// 3. User selects strategy
|
||||
userChoice = readInput()
|
||||
|
||||
IF userChoice == "自定义":
|
||||
customConflicts.push({id, brief, category, suggestions, overlap_analysis})
|
||||
clarified = true
|
||||
BREAK
|
||||
|
||||
selectedStrategy = strategies[userChoice]
|
||||
|
||||
// 4. Clarification loop
|
||||
IF selectedStrategy.clarification_needed.length > 0:
|
||||
// 收集澄清答案
|
||||
FOR each question:
|
||||
answer = readInput()
|
||||
userClarifications.push({question, answer})
|
||||
|
||||
// Agent 重新分析
|
||||
reanalysisResult = Task(cli-execution-agent, prompt={
|
||||
冲突信息: {id, brief, category, 策略}
|
||||
用户澄清: userClarifications[]
|
||||
场景分析: overlap_analysis (if ModuleOverlap)
|
||||
|
||||
输出: {
|
||||
uniqueness_confirmed: bool,
|
||||
rationale: string,
|
||||
updated_strategy: {name, approach, complexity, risk, effort, modifications[]},
|
||||
remaining_questions: [] (如果仍有歧义)
|
||||
}
|
||||
// 2. Strategy selection
|
||||
if (autoYes) {
|
||||
console.log(`[--yes] Auto-selecting recommended strategy`)
|
||||
selectedStrategy = conflict.strategies[conflict.recommended || 0]
|
||||
clarified = true // Skip clarification loop
|
||||
} else {
|
||||
AskUserQuestion({
|
||||
questions: [{
|
||||
question: formatStrategiesForDisplay(conflict.strategies),
|
||||
header: "策略选择",
|
||||
multiSelect: false,
|
||||
options: [
|
||||
...conflict.strategies.map((s, i) => ({
|
||||
label: `${s.name}${i === conflict.recommended ? ' (推荐)' : ''}`,
|
||||
description: `${s.complexity}复杂度 | ${s.risk}风险${s.clarification_needed?.length ? ' | ⚠️需澄清' : ''}`
|
||||
})),
|
||||
{ label: "自定义修改", description: `建议: ${conflict.modification_suggestions?.slice(0,2).join('; ')}` }
|
||||
]
|
||||
}]
|
||||
})
|
||||
|
||||
IF reanalysisResult.uniqueness_confirmed:
|
||||
selectedStrategy = updated_strategy
|
||||
selectedStrategy.clarifications = userClarifications
|
||||
clarified = true
|
||||
ELSE:
|
||||
// 更新澄清问题,继续下一轮
|
||||
selectedStrategy.clarification_needed = remaining_questions
|
||||
ELSE:
|
||||
clarified = true
|
||||
// 3. Handle selection
|
||||
if (userChoice === "自定义修改") {
|
||||
customConflicts.push({ id, brief, category, suggestions, overlap_analysis })
|
||||
break
|
||||
}
|
||||
|
||||
resolvedConflicts.push({conflict, strategy: selectedStrategy})
|
||||
selectedStrategy = findStrategyByName(userChoice)
|
||||
}
|
||||
|
||||
// 4. Clarification (if needed) - batched max 4 per call
|
||||
if (!autoYes && selectedStrategy.clarification_needed?.length > 0) {
|
||||
for (batch of chunk(selectedStrategy.clarification_needed, 4)) {
|
||||
AskUserQuestion({
|
||||
questions: batch.map((q, i) => ({
|
||||
question: q, header: `澄清${i+1}`, multiSelect: false,
|
||||
options: [{ label: "详细说明", description: "提供答案" }]
|
||||
}))
|
||||
})
|
||||
userClarifications.push(...collectAnswers(batch))
|
||||
}
|
||||
|
||||
// 5. Agent re-analysis
|
||||
reanalysisResult = Task({
|
||||
subagent_type: "cli-execution-agent",
|
||||
run_in_background: false,
|
||||
prompt: `Conflict: ${conflict.id}, Strategy: ${selectedStrategy.name}
|
||||
User Clarifications: ${JSON.stringify(userClarifications)}
|
||||
Output: { uniqueness_confirmed, rationale, updated_strategy, remaining_questions }`
|
||||
})
|
||||
|
||||
if (reanalysisResult.uniqueness_confirmed) {
|
||||
selectedStrategy = { ...reanalysisResult.updated_strategy, clarifications: userClarifications }
|
||||
clarified = true
|
||||
} else {
|
||||
selectedStrategy.clarification_needed = reanalysisResult.remaining_questions
|
||||
}
|
||||
} else {
|
||||
clarified = true
|
||||
}
|
||||
|
||||
if (clarified) resolvedConflicts.push({ conflict, strategy: selectedStrategy })
|
||||
END WHILE
|
||||
END FOR
|
||||
|
||||
// Build output
|
||||
selectedStrategies = resolvedConflicts.map(r => ({
|
||||
conflict_id, strategy, clarifications[]
|
||||
conflict_id: r.conflict.id, strategy: r.strategy, clarifications: r.strategy.clarifications || []
|
||||
}))
|
||||
```
|
||||
|
||||
**Key Data Structures**:
|
||||
|
||||
```javascript
|
||||
// Custom conflict tracking
|
||||
customConflicts[] = {
|
||||
id, brief, category,
|
||||
suggestions: modification_suggestions[],
|
||||
overlap_analysis: { new_module{}, existing_modules[] } // ModuleOverlap only
|
||||
}
|
||||
|
||||
// Agent re-analysis prompt output
|
||||
{
|
||||
uniqueness_confirmed: bool,
|
||||
rationale: string,
|
||||
updated_strategy: {
|
||||
name, approach, complexity, risk, effort,
|
||||
modifications: [{file, section, change_type, old_content, new_content, rationale}]
|
||||
},
|
||||
remaining_questions: string[]
|
||||
}
|
||||
```
|
||||
|
||||
**Text Output Example** (展示关键字段):
|
||||
|
||||
```markdown
|
||||
============================================================
|
||||
冲突 1/3 - 第 1 轮
|
||||
============================================================
|
||||
【ModuleOverlap】CON-001: 新增用户认证服务与现有模块功能重叠
|
||||
严重程度: High | 描述: 计划中的 UserAuthService 与现有 AuthManager 场景重叠
|
||||
|
||||
--- 场景重叠分析 ---
|
||||
新模块: UserAuthService | 场景: 登录, Token验证, 权限, MFA
|
||||
现有模块: AuthManager (src/auth/AuthManager.ts) | 重叠: 登录, Token验证
|
||||
|
||||
--- 解决策略 ---
|
||||
1) 合并 (Low复杂度 | Low风险 | 2-3天)
|
||||
⚠️ 需澄清: AuthManager是否能承担MFA?
|
||||
|
||||
2) 拆分边界 (Medium复杂度 | Medium风险 | 4-5天)
|
||||
⚠️ 需澄清: 基础/高级认证边界? Token验证归谁?
|
||||
|
||||
3) 自定义修改
|
||||
建议: 评估扩展性; 策略模式分离; 定义接口边界
|
||||
|
||||
请选择 (1-3): > 2
|
||||
|
||||
--- 澄清问答 (第1轮) ---
|
||||
Q: 基础/高级认证边界?
|
||||
A: 基础=密码登录+token验证, 高级=MFA+OAuth+SSO
|
||||
|
||||
Q: Token验证归谁?
|
||||
A: 统一由 AuthManager 负责
|
||||
|
||||
🔄 重新分析...
|
||||
✅ 唯一性已确认 | 理由: 边界清晰 - AuthManager(基础+token), UserAuthService(MFA+OAuth+SSO)
|
||||
|
||||
============================================================
|
||||
冲突 2/3 - 第 1 轮 [下一个冲突]
|
||||
============================================================
|
||||
```
|
||||
|
||||
**Loop Characteristics**: 逐个处理 | 无限轮次(max 10) | 动态问题生成 | Agent重新分析判断唯一性 | ModuleOverlap场景边界澄清
|
||||
**Key Points**:
|
||||
- AskUserQuestion: max 4 questions/call, batch if more
|
||||
- Strategy options: 2-4 strategies + "自定义修改"
|
||||
- Clarification loop: max 10 rounds, agent判断 uniqueness_confirmed
|
||||
- Custom conflicts: 记录 overlap_analysis 供后续手动处理
|
||||
|
||||
### Phase 4: Apply Modifications
|
||||
|
||||
|
||||
@@ -15,7 +15,6 @@ allowed-tools: Task(*), Read(*), Glob(*)
|
||||
|
||||
Orchestrator command that invokes `context-search-agent` to gather comprehensive project context for implementation planning. Generates standardized `context-package.json` with codebase analysis, dependencies, and conflict detection.
|
||||
|
||||
**Agent**: `context-search-agent` (`.claude/agents/context-search-agent.md`)
|
||||
|
||||
## Core Philosophy
|
||||
|
||||
@@ -36,7 +35,7 @@ Step 1: Context-Package Detection
|
||||
├─ Valid package exists → Return existing (skip execution)
|
||||
└─ No valid package → Continue to Step 2
|
||||
|
||||
Step 2: Complexity Assessment & Parallel Explore (NEW)
|
||||
Step 2: Complexity Assessment & Parallel Explore
|
||||
├─ Analyze task_description → classify Low/Medium/High
|
||||
├─ Select exploration angles (1-4 based on complexity)
|
||||
├─ Launch N cli-explore-agents in parallel
|
||||
@@ -214,19 +213,37 @@ Write(`${sessionFolder}/explorations-manifest.json`, JSON.stringify(explorationM
|
||||
**Only execute after Step 2 completes**
|
||||
|
||||
```javascript
|
||||
// Load user intent from planning-notes.md (from Phase 1)
|
||||
const planningNotesPath = `.workflow/active/${session_id}/planning-notes.md`;
|
||||
let userIntent = { goal: task_description, key_constraints: "None specified" };
|
||||
|
||||
if (file_exists(planningNotesPath)) {
|
||||
const notesContent = Read(planningNotesPath);
|
||||
const goalMatch = notesContent.match(/\*\*GOAL\*\*:\s*(.+)/);
|
||||
const constraintsMatch = notesContent.match(/\*\*KEY_CONSTRAINTS\*\*:\s*(.+)/);
|
||||
if (goalMatch) userIntent.goal = goalMatch[1].trim();
|
||||
if (constraintsMatch) userIntent.key_constraints = constraintsMatch[1].trim();
|
||||
}
|
||||
|
||||
Task(
|
||||
subagent_type="context-search-agent",
|
||||
run_in_background=false,
|
||||
description="Gather comprehensive context for plan",
|
||||
prompt=`
|
||||
## Execution Mode
|
||||
**PLAN MODE** (Comprehensive) - Full Phase 1-3 execution
|
||||
**PLAN MODE** (Comprehensive) - Full Phase 1-3 execution with priority sorting
|
||||
|
||||
## Session Information
|
||||
- **Session ID**: ${session_id}
|
||||
- **Task Description**: ${task_description}
|
||||
- **Output Path**: .workflow/${session_id}/.process/context-package.json
|
||||
|
||||
## User Intent (from Phase 1 - Planning Notes)
|
||||
**GOAL**: ${userIntent.goal}
|
||||
**KEY_CONSTRAINTS**: ${userIntent.key_constraints}
|
||||
|
||||
This is the PRIMARY context source - all subsequent analysis must align with user intent.
|
||||
|
||||
## Exploration Input (from Step 2)
|
||||
- **Manifest**: ${sessionFolder}/explorations-manifest.json
|
||||
- **Exploration Count**: ${explorationManifest.exploration_count}
|
||||
@@ -237,13 +254,22 @@ Task(
|
||||
Execute complete context-search-agent workflow for implementation planning:
|
||||
|
||||
### Phase 1: Initialization & Pre-Analysis
|
||||
1. **Project State Loading**: Read and parse `.workflow/project.json`. Use its `overview` section as the foundational `project_context`. This is your primary source for architecture, tech stack, and key components. If file doesn't exist, proceed with fresh analysis.
|
||||
1. **Project State Loading**:
|
||||
- Read and parse `.workflow/project-tech.json`. Use its `overview` section as the foundational `project_context`. This is your primary source for architecture, tech stack, and key components.
|
||||
- Read and parse `.workflow/project-guidelines.json`. Load `conventions`, `constraints`, and `learnings` into a `project_guidelines` section.
|
||||
- If files don't exist, proceed with fresh analysis.
|
||||
2. **Detection**: Check for existing context-package (early exit if valid)
|
||||
3. **Foundation**: Initialize CodexLens, get project structure, load docs
|
||||
4. **Analysis**: Extract keywords, determine scope, classify complexity based on task description and project state
|
||||
|
||||
### Phase 2: Multi-Source Context Discovery
|
||||
Execute all discovery tracks:
|
||||
Execute all discovery tracks (WITH USER INTENT INTEGRATION):
|
||||
- **Track -1**: User Intent & Priority Foundation (EXECUTE FIRST)
|
||||
- Load user intent (GOAL, KEY_CONSTRAINTS) from session input
|
||||
- Map user requirements to codebase entities (files, modules, patterns)
|
||||
- Establish baseline priority scores based on user goal alignment
|
||||
- Output: user_intent_mapping.json with preliminary priority scores
|
||||
|
||||
- **Track 0**: Exploration Synthesis (load ${sessionFolder}/explorations-manifest.json, prioritize critical_files, deduplicate patterns/integration_points)
|
||||
- **Track 1**: Historical archive analysis (query manifest.json for lessons learned)
|
||||
- **Track 2**: Reference documentation (CLAUDE.md, architecture docs)
|
||||
@@ -252,22 +278,57 @@ Execute all discovery tracks:
|
||||
|
||||
### Phase 3: Synthesis, Assessment & Packaging
|
||||
1. Apply relevance scoring and build dependency graph
|
||||
2. **Synthesize 4-source data**: Merge findings from all sources (archive > docs > code > web). **Prioritize the context from `project.json`** for architecture and tech stack unless code analysis reveals it's outdated.
|
||||
3. **Populate `project_context`**: Directly use the `overview` from `project.json` to fill the `project_context` section of the output `context-package.json`. Include description, technology_stack, architecture, and key_components.
|
||||
4. Integrate brainstorm artifacts (if .brainstorming/ exists, read content)
|
||||
5. Perform conflict detection with risk assessment
|
||||
6. **Inject historical conflicts** from archive analysis into conflict_detection
|
||||
7. Generate and validate context-package.json
|
||||
2. **Synthesize 5-source data** (including Track -1): Merge findings from all sources
|
||||
- Priority order: User Intent > Archive > Docs > Exploration > Code > Web
|
||||
- **Prioritize the context from `project-tech.json`** for architecture and tech stack unless code analysis reveals it's outdated
|
||||
3. **Context Priority Sorting**:
|
||||
a. Combine scores from Track -1 (user intent alignment) + relevance scores + exploration critical_files
|
||||
b. Classify files into priority tiers:
|
||||
- **Critical** (score ≥ 0.85): Directly mentioned in user goal OR exploration critical_files
|
||||
- **High** (0.70-0.84): Key dependencies, patterns required for goal
|
||||
- **Medium** (0.50-0.69): Supporting files, indirect dependencies
|
||||
- **Low** (< 0.50): Contextual awareness only
|
||||
c. Generate dependency_order: Based on dependency graph + user goal sequence
|
||||
d. Document sorting_rationale: Explain prioritization logic
|
||||
|
||||
4. **Populate `project_context`**: Directly use the `overview` from `project-tech.json` to fill the `project_context` section. Include description, technology_stack, architecture, and key_components.
|
||||
5. **Populate `project_guidelines`**: Load conventions, constraints, and learnings from `project-guidelines.json` into a dedicated section.
|
||||
6. Integrate brainstorm artifacts (if .brainstorming/ exists, read content)
|
||||
7. Perform conflict detection with risk assessment
|
||||
8. **Inject historical conflicts** from archive analysis into conflict_detection
|
||||
9. **Generate prioritized_context section**:
|
||||
```json
|
||||
{
|
||||
"prioritized_context": {
|
||||
"user_intent": {
|
||||
"goal": "...",
|
||||
"scope": "...",
|
||||
"key_constraints": ["..."]
|
||||
},
|
||||
"priority_tiers": {
|
||||
"critical": [{ "path": "...", "relevance": 0.95, "rationale": "..." }],
|
||||
"high": [...],
|
||||
"medium": [...],
|
||||
"low": [...]
|
||||
},
|
||||
"dependency_order": ["module1", "module2", "module3"],
|
||||
"sorting_rationale": "Based on user goal alignment (Track -1), exploration critical files, and dependency graph analysis"
|
||||
}
|
||||
}
|
||||
```
|
||||
10. Generate and validate context-package.json with prioritized_context field
|
||||
|
||||
## Output Requirements
|
||||
Complete context-package.json with:
|
||||
- **metadata**: task_description, keywords, complexity, tech_stack, session_id
|
||||
- **project_context**: description, technology_stack, architecture, key_components (sourced from `project.json` overview)
|
||||
- **project_context**: description, technology_stack, architecture, key_components (sourced from `project-tech.json`)
|
||||
- **project_guidelines**: {conventions, constraints, quality_rules, learnings} (sourced from `project-guidelines.json`)
|
||||
- **assets**: {documentation[], source_code[], config[], tests[]} with relevance scores
|
||||
- **dependencies**: {internal[], external[]} with dependency graph
|
||||
- **brainstorm_artifacts**: {guidance_specification, role_analyses[], synthesis_output} with content
|
||||
- **conflict_detection**: {risk_level, risk_factors, affected_modules[], mitigation_strategy, historical_conflicts[]}
|
||||
- **exploration_results**: {manifest_path, exploration_count, angles, explorations[], aggregated_insights} (from Track 0)
|
||||
- **prioritized_context**: {user_intent, priority_tiers{critical, high, medium, low}, dependency_order[], sorting_rationale}
|
||||
|
||||
## Quality Validation
|
||||
Before completion verify:
|
||||
@@ -278,6 +339,17 @@ Before completion verify:
|
||||
- [ ] No sensitive data exposed
|
||||
- [ ] Total files ≤50 (prioritize high-relevance)
|
||||
|
||||
## Planning Notes Record (REQUIRED)
|
||||
After completing context-package.json, append a brief execution record to planning-notes.md:
|
||||
|
||||
**File**: .workflow/active/${session_id}/planning-notes.md
|
||||
**Location**: Under "## Context Findings (Phase 2)" section
|
||||
**Format**:
|
||||
\`\`\`
|
||||
### [Context-Search Agent] YYYY-MM-DD
|
||||
- **Note**: [智能补充:简短总结关键发现,如探索角度、关键文件、冲突风险等]
|
||||
\`\`\`
|
||||
|
||||
Execute autonomously following agent documentation.
|
||||
Report completion with statistics.
|
||||
`
|
||||
@@ -315,122 +387,18 @@ Refer to `context-search-agent.md` Phase 3.7 for complete `context-package.json`
|
||||
|
||||
**Key Sections**:
|
||||
- **metadata**: Session info, keywords, complexity, tech stack
|
||||
- **project_context**: Architecture patterns, conventions, tech stack (populated from `project.json` overview)
|
||||
- **project_context**: Architecture patterns, conventions, tech stack (populated from `project-tech.json`)
|
||||
- **project_guidelines**: Conventions, constraints, quality rules, learnings (populated from `project-guidelines.json`)
|
||||
- **assets**: Categorized files with relevance scores (documentation, source_code, config, tests)
|
||||
- **dependencies**: Internal and external dependency graphs
|
||||
- **brainstorm_artifacts**: Brainstorm documents with full content (if exists)
|
||||
- **conflict_detection**: Risk assessment with mitigation strategies and historical conflicts
|
||||
- **exploration_results**: Aggregated exploration insights (from parallel explore phase)
|
||||
|
||||
## Historical Archive Analysis
|
||||
|
||||
### Track 1: Query Archive Manifest
|
||||
|
||||
The context-search-agent MUST perform historical archive analysis as Track 1 in Phase 2:
|
||||
|
||||
**Step 1: Check for Archive Manifest**
|
||||
```bash
|
||||
# Check if archive manifest exists
|
||||
if [[ -f .workflow/archives/manifest.json ]]; then
|
||||
# Manifest available for querying
|
||||
fi
|
||||
```
|
||||
|
||||
**Step 2: Extract Task Keywords**
|
||||
```javascript
|
||||
// From current task description, extract key entities and operations
|
||||
const keywords = extractKeywords(task_description);
|
||||
// Examples: ["User", "model", "authentication", "JWT", "reporting"]
|
||||
```
|
||||
|
||||
**Step 3: Search Archive for Relevant Sessions**
|
||||
```javascript
|
||||
// Query manifest for sessions with matching tags or descriptions
|
||||
const relevantArchives = archives.filter(archive => {
|
||||
return archive.tags.some(tag => keywords.includes(tag)) ||
|
||||
keywords.some(kw => archive.description.toLowerCase().includes(kw.toLowerCase()));
|
||||
});
|
||||
```
|
||||
|
||||
**Step 4: Extract Watch Patterns**
|
||||
```javascript
|
||||
// For each relevant archive, check watch_patterns for applicability
|
||||
const historicalConflicts = [];
|
||||
|
||||
relevantArchives.forEach(archive => {
|
||||
archive.lessons.watch_patterns?.forEach(pattern => {
|
||||
// Check if pattern trigger matches current task
|
||||
if (isPatternRelevant(pattern.pattern, task_description)) {
|
||||
historicalConflicts.push({
|
||||
source_session: archive.session_id,
|
||||
pattern: pattern.pattern,
|
||||
action: pattern.action,
|
||||
files_to_check: pattern.related_files,
|
||||
archived_at: archive.archived_at
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
```
|
||||
|
||||
**Step 5: Inject into Context Package**
|
||||
```json
|
||||
{
|
||||
"conflict_detection": {
|
||||
"risk_level": "medium",
|
||||
"risk_factors": ["..."],
|
||||
"affected_modules": ["..."],
|
||||
"mitigation_strategy": "...",
|
||||
"historical_conflicts": [
|
||||
{
|
||||
"source_session": "WFS-auth-feature",
|
||||
"pattern": "When modifying User model",
|
||||
"action": "Check reporting-service and auditing-service dependencies",
|
||||
"files_to_check": ["src/models/User.ts", "src/services/reporting.ts"],
|
||||
"archived_at": "2025-09-16T09:00:00Z"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### Risk Level Escalation
|
||||
|
||||
If `historical_conflicts` array is not empty, minimum risk level should be "medium":
|
||||
|
||||
```javascript
|
||||
if (historicalConflicts.length > 0 && currentRisk === "low") {
|
||||
conflict_detection.risk_level = "medium";
|
||||
conflict_detection.risk_factors.push(
|
||||
`${historicalConflicts.length} historical conflict pattern(s) detected from past sessions`
|
||||
);
|
||||
}
|
||||
```
|
||||
|
||||
### Archive Query Algorithm
|
||||
|
||||
```markdown
|
||||
1. IF .workflow/archives/manifest.json does NOT exist → Skip Track 1, continue to Track 2
|
||||
2. IF manifest exists:
|
||||
a. Load manifest.json
|
||||
b. Extract keywords from task_description (nouns, verbs, technical terms)
|
||||
c. Filter archives where:
|
||||
- ANY tag matches keywords (case-insensitive) OR
|
||||
- description contains keywords (case-insensitive substring match)
|
||||
d. For each relevant archive:
|
||||
- Read lessons.watch_patterns array
|
||||
- Check if pattern.pattern keywords overlap with task_description
|
||||
- If relevant: Add to historical_conflicts array
|
||||
e. IF historical_conflicts.length > 0:
|
||||
- Set risk_level = max(current_risk, "medium")
|
||||
- Add to risk_factors
|
||||
3. Continue to Track 2 (reference documentation)
|
||||
```
|
||||
- **prioritized_context**: Pre-sorted context with user intent and priority tiers (critical/high/medium/low)
|
||||
|
||||
## Notes
|
||||
|
||||
- **Detection-first**: Always check for existing package before invoking agent
|
||||
- **Project.json integration**: Agent reads `.workflow/project.json` as primary source for project context, avoiding redundant analysis
|
||||
- **Agent autonomy**: Agent handles all discovery logic per `.claude/agents/context-search-agent.md`
|
||||
- **No redundancy**: This command is a thin orchestrator, all logic in agent
|
||||
- **User intent integration**: Load user intent from planning-notes.md (Phase 1 output)
|
||||
- **Output**: Generates `context-package.json` with `prioritized_context` field
|
||||
- **Plan-specific**: Use this for implementation planning; brainstorm mode uses direct agent call
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user