@herbertgao/pi-extensions 2026.10.19 → 2026.11.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (261) hide show
  1. package/README.md +19 -4
  2. package/THIRD_PARTY_NOTICES.md +53 -2
  3. package/node_modules/@herbertgao/pi-subagents/CHANGELOG.md +6 -0
  4. package/node_modules/@herbertgao/pi-subagents/README.md +142 -45
  5. package/node_modules/@herbertgao/pi-subagents/docs/rpc.md +17 -7
  6. package/node_modules/@herbertgao/pi-subagents/package.json +4 -4
  7. package/node_modules/@herbertgao/pi-subagents/src/agent-manager.ts +111 -59
  8. package/node_modules/@herbertgao/pi-subagents/src/agent-runner.ts +135 -117
  9. package/node_modules/@herbertgao/pi-subagents/src/cross-extension-rpc.ts +41 -14
  10. package/node_modules/@herbertgao/pi-subagents/src/index.ts +110 -19
  11. package/node_modules/@herbertgao/pi-subagents/src/nested-tools.ts +8 -0
  12. package/node_modules/@herbertgao/pi-subagents/src/prompts.ts +31 -0
  13. package/node_modules/@tintinweb/pi-tasks/CHANGELOG.md +270 -0
  14. package/node_modules/@tintinweb/pi-tasks/CONTRIBUTING.md +67 -0
  15. package/node_modules/@tintinweb/pi-tasks/CUSTOMIZING.md +289 -0
  16. package/node_modules/@tintinweb/pi-tasks/LICENSE +21 -0
  17. package/node_modules/@tintinweb/pi-tasks/README.md +417 -0
  18. package/node_modules/@tintinweb/pi-tasks/SECURITY.md +107 -0
  19. package/node_modules/@tintinweb/pi-tasks/dist/auto-clear.d.ts +64 -0
  20. package/node_modules/@tintinweb/pi-tasks/dist/auto-clear.js +129 -0
  21. package/node_modules/@tintinweb/pi-tasks/dist/index.d.ts +17 -0
  22. package/node_modules/@tintinweb/pi-tasks/dist/index.js +1338 -0
  23. package/node_modules/@tintinweb/pi-tasks/dist/process-tracker.d.ts +29 -0
  24. package/node_modules/@tintinweb/pi-tasks/dist/process-tracker.js +121 -0
  25. package/node_modules/@tintinweb/pi-tasks/dist/reminder-cadence.d.ts +39 -0
  26. package/node_modules/@tintinweb/pi-tasks/dist/reminder-cadence.js +61 -0
  27. package/node_modules/@tintinweb/pi-tasks/dist/task-glyphs.d.ts +48 -0
  28. package/node_modules/@tintinweb/pi-tasks/dist/task-glyphs.js +68 -0
  29. package/node_modules/@tintinweb/pi-tasks/dist/task-paths.d.ts +44 -0
  30. package/node_modules/@tintinweb/pi-tasks/dist/task-paths.js +60 -0
  31. package/node_modules/@tintinweb/pi-tasks/dist/task-sort.d.ts +23 -0
  32. package/node_modules/@tintinweb/pi-tasks/dist/task-sort.js +69 -0
  33. package/node_modules/@tintinweb/pi-tasks/dist/task-store.d.ts +61 -0
  34. package/node_modules/@tintinweb/pi-tasks/dist/task-store.js +397 -0
  35. package/node_modules/@tintinweb/pi-tasks/dist/tasks-config.d.ts +16 -0
  36. package/node_modules/@tintinweb/pi-tasks/dist/tasks-config.js +51 -0
  37. package/node_modules/@tintinweb/pi-tasks/dist/types.d.ts +36 -0
  38. package/node_modules/@tintinweb/pi-tasks/dist/types.js +4 -0
  39. package/node_modules/@tintinweb/pi-tasks/dist/ui/settings-menu.d.ts +15 -0
  40. package/node_modules/@tintinweb/pi-tasks/dist/ui/settings-menu.js +140 -0
  41. package/node_modules/@tintinweb/pi-tasks/dist/ui/task-widget.d.ts +69 -0
  42. package/node_modules/@tintinweb/pi-tasks/dist/ui/task-widget.js +278 -0
  43. package/node_modules/@tintinweb/pi-tasks/package.json +57 -0
  44. package/node_modules/@tintinweb/pi-tasks/src/auto-clear.ts +134 -0
  45. package/node_modules/@tintinweb/pi-tasks/src/index.ts +1417 -0
  46. package/node_modules/@tintinweb/pi-tasks/src/process-tracker.ts +140 -0
  47. package/node_modules/@tintinweb/pi-tasks/src/reminder-cadence.ts +90 -0
  48. package/node_modules/@tintinweb/pi-tasks/src/task-glyphs.ts +110 -0
  49. package/node_modules/@tintinweb/pi-tasks/src/task-paths.ts +65 -0
  50. package/node_modules/@tintinweb/pi-tasks/src/task-sort.ts +90 -0
  51. package/node_modules/@tintinweb/pi-tasks/src/task-store.ts +402 -0
  52. package/node_modules/@tintinweb/pi-tasks/src/tasks-config.ts +77 -0
  53. package/node_modules/@tintinweb/pi-tasks/src/types.ts +40 -0
  54. package/node_modules/@tintinweb/pi-tasks/src/ui/settings-menu.ts +174 -0
  55. package/node_modules/@tintinweb/pi-tasks/src/ui/task-widget.ts +325 -0
  56. package/node_modules/pi-commandcode-provider/CHANGELOG.md +330 -0
  57. package/node_modules/pi-commandcode-provider/CONTRIBUTING.md +192 -0
  58. package/node_modules/pi-commandcode-provider/LICENSE +21 -0
  59. package/node_modules/pi-commandcode-provider/README.md +243 -0
  60. package/node_modules/pi-commandcode-provider/RELEASE.md +194 -0
  61. package/node_modules/pi-commandcode-provider/index.ts +309 -0
  62. package/node_modules/pi-commandcode-provider/package.json +91 -0
  63. package/node_modules/pi-commandcode-provider/scripts/live-e2e-profile.mjs +87 -0
  64. package/node_modules/pi-commandcode-provider/scripts/pi-authenticated.mjs +50 -0
  65. package/node_modules/pi-commandcode-provider/scripts/pi-isolated.mjs +79 -0
  66. package/node_modules/pi-commandcode-provider/src/api-key.ts +69 -0
  67. package/node_modules/pi-commandcode-provider/src/auth-server.ts +229 -0
  68. package/node_modules/pi-commandcode-provider/src/commandcode-catalog-overrides.ts +28 -0
  69. package/node_modules/pi-commandcode-provider/src/commandcode-catalog.ts +260 -0
  70. package/node_modules/pi-commandcode-provider/src/converters.ts +477 -0
  71. package/node_modules/pi-commandcode-provider/src/core.ts +836 -0
  72. package/node_modules/pi-commandcode-provider/src/cost.ts +76 -0
  73. package/node_modules/pi-commandcode-provider/src/json-schema.ts +417 -0
  74. package/node_modules/pi-commandcode-provider/src/models.ts +515 -0
  75. package/node_modules/pi-commandcode-provider/src/oauth.ts +229 -0
  76. package/node_modules/pi-commandcode-provider/src/overflow.ts +120 -0
  77. package/node_modules/pi-commandcode-provider/src/pricing.ts +370 -0
  78. package/node_modules/pi-commandcode-provider/src/quota-command.ts +66 -0
  79. package/node_modules/pi-commandcode-provider/src/quota-format.ts +143 -0
  80. package/node_modules/pi-commandcode-provider/src/quota-types.ts +47 -0
  81. package/node_modules/pi-commandcode-provider/src/quota.ts +357 -0
  82. package/node_modules/pi-commandcode-provider/src/responses-stream.ts +249 -0
  83. package/node_modules/pi-commandcode-provider/src/runtime.ts +330 -0
  84. package/node_modules/pi-commandcode-provider/src/transcript.ts +56 -0
  85. package/node_modules/pi-commandcode-provider/src/transport.ts +147 -0
  86. package/node_modules/pi-commandcode-provider/src/types.ts +212 -0
  87. package/node_modules/pi-commandcode-provider/src/usage.ts +261 -0
  88. package/node_modules/pi-lens/CHANGELOG.md +149 -0
  89. package/node_modules/pi-lens/README.md +12 -2
  90. package/node_modules/pi-lens/config/markdownlint/run-no-fix.mjs +36 -0
  91. package/node_modules/pi-lens/dist/{chunk-WME2OQST.js → chunk-2453RRJ2.js} +11 -6
  92. package/node_modules/pi-lens/dist/{chunk-FZKFVUEC.js → chunk-2BKUFQKR.js} +276 -208
  93. package/node_modules/pi-lens/dist/chunk-2TS4GLOJ.js +31 -0
  94. package/node_modules/pi-lens/dist/{chunk-QHSNL7B2.js → chunk-2ZE3AUJQ.js} +12 -14
  95. package/node_modules/pi-lens/dist/{chunk-MPKRJBPK.js → chunk-35WKJWO5.js} +28 -30
  96. package/node_modules/pi-lens/dist/chunk-3JAHQBSY.js +27 -0
  97. package/node_modules/pi-lens/dist/{chunk-4LM3VAZH.js → chunk-3O5EII3W.js} +2 -2
  98. package/node_modules/pi-lens/dist/chunk-447YZL4S.js +25 -0
  99. package/node_modules/pi-lens/dist/{chunk-H7OR7DFZ.js → chunk-4B2YFN4U.js} +25 -21
  100. package/node_modules/pi-lens/dist/{chunk-OSTKYB55.js → chunk-4BKU7PV3.js} +1 -1
  101. package/node_modules/pi-lens/dist/{chunk-RRV3FNNM.js → chunk-4LL2VRNY.js} +27 -28
  102. package/node_modules/pi-lens/dist/{chunk-BZARLRJW.js → chunk-4NBWFYWW.js} +9 -9
  103. package/node_modules/pi-lens/dist/{chunk-KKCK636N.js → chunk-4QG55RRC.js} +12 -12
  104. package/node_modules/pi-lens/dist/{chunk-RQS4QQSD.js → chunk-4W52ZKZX.js} +2 -2
  105. package/node_modules/pi-lens/dist/{chunk-Z2XAOKHK.js → chunk-565VRUP4.js} +2 -2
  106. package/node_modules/pi-lens/dist/{chunk-HWDAVBFU.js → chunk-57X2CDRX.js} +23 -23
  107. package/node_modules/pi-lens/dist/{chunk-MB6PXBUA.js → chunk-5F3XF3SX.js} +7 -15
  108. package/node_modules/pi-lens/dist/{chunk-O4BJFESU.js → chunk-5RNB4HVK.js} +1 -1
  109. package/node_modules/pi-lens/dist/{chunk-ZMAUPOMG.js → chunk-5T5A6YAJ.js} +35 -34
  110. package/node_modules/pi-lens/dist/{chunk-4ZYJHQMB.js → chunk-6FIRFP6A.js} +12 -12
  111. package/node_modules/pi-lens/dist/{chunk-4YHYPW2G.js → chunk-6GMGEKQN.js} +9 -5
  112. package/node_modules/pi-lens/dist/{chunk-4LOE5R5P.js → chunk-6LJOJ6EO.js} +20 -15
  113. package/node_modules/pi-lens/dist/{chunk-3YY7IXIL.js → chunk-6YUNI7B5.js} +3 -3
  114. package/node_modules/pi-lens/dist/{chunk-PKES3ISE.js → chunk-7ANZ7XDD.js} +2 -2
  115. package/node_modules/pi-lens/dist/{chunk-FB5SCCPT.js → chunk-7CGIDRIK.js} +16 -15
  116. package/node_modules/pi-lens/dist/{chunk-L3CMBQMH.js → chunk-7MAD5ZAY.js} +16 -17
  117. package/node_modules/pi-lens/dist/{chunk-WDBICWH3.js → chunk-7TNILKGY.js} +1 -1
  118. package/node_modules/pi-lens/dist/{chunk-RORGS5II.js → chunk-A5GRLYPZ.js} +9 -9
  119. package/node_modules/pi-lens/dist/{chunk-MNJIXFX4.js → chunk-AGGUWKRK.js} +1 -1
  120. package/node_modules/pi-lens/dist/{chunk-ABPKUVA4.js → chunk-BBET6HD6.js} +1 -1
  121. package/node_modules/pi-lens/dist/{chunk-L5JYIU47.js → chunk-BHWW6FAX.js} +14 -13
  122. package/node_modules/pi-lens/dist/{chunk-URCQWAQ4.js → chunk-BOPDQ7AZ.js} +23 -21
  123. package/node_modules/pi-lens/dist/{chunk-KDX35VXP.js → chunk-BQG2QFVO.js} +158 -133
  124. package/node_modules/pi-lens/dist/{chunk-CB4WHS4H.js → chunk-BUZIQDFS.js} +3 -3
  125. package/node_modules/pi-lens/dist/{chunk-2PHMIAKO.js → chunk-CM73PPGD.js} +4 -4
  126. package/node_modules/pi-lens/dist/{chunk-DH5JPM3K.js → chunk-CUDD35TW.js} +10 -9
  127. package/node_modules/pi-lens/dist/{chunk-AWDSEDER.js → chunk-CZL44WFN.js} +2 -2
  128. package/node_modules/pi-lens/dist/{chunk-N5WSK2K7.js → chunk-DIWK3LBC.js} +12 -15
  129. package/node_modules/pi-lens/dist/{chunk-24BILSZW.js → chunk-DYRZGUMA.js} +2 -2
  130. package/node_modules/pi-lens/dist/{chunk-PR6PO3ES.js → chunk-FHEV6T4L.js} +22 -18
  131. package/node_modules/pi-lens/dist/{chunk-DQZFQSR5.js → chunk-FRLAUP2B.js} +4 -4
  132. package/node_modules/pi-lens/dist/{chunk-RZOXUSPC.js → chunk-G5GV2Q7K.js} +2 -2
  133. package/node_modules/pi-lens/dist/{chunk-EKWX4WD3.js → chunk-G6JKM4O7.js} +7 -7
  134. package/node_modules/pi-lens/dist/chunk-GGYOZWHW.js +27 -0
  135. package/node_modules/pi-lens/dist/{chunk-XT2HTCJ5.js → chunk-GIRBSBGL.js} +6 -5
  136. package/node_modules/pi-lens/dist/{chunk-PQJFG24Z.js → chunk-GMROJJRN.js} +1292 -946
  137. package/node_modules/pi-lens/dist/{chunk-U6VN4NVL.js → chunk-HHR7WGCI.js} +3 -3
  138. package/node_modules/pi-lens/dist/{chunk-TIQJPRDD.js → chunk-HKIL6DCL.js} +3 -2
  139. package/node_modules/pi-lens/dist/{chunk-SNDXCFRS.js → chunk-HUAM7QG3.js} +11 -11
  140. package/node_modules/pi-lens/dist/{chunk-QOE342SU.js → chunk-HXFUTMX2.js} +2 -2
  141. package/node_modules/pi-lens/dist/{chunk-U7BD2QL7.js → chunk-I22THIHI.js} +12 -12
  142. package/node_modules/pi-lens/dist/chunk-IE5D3RA5.js +58 -0
  143. package/node_modules/pi-lens/dist/{chunk-DPGEAHZT.js → chunk-IYVYZQRL.js} +10 -16
  144. package/node_modules/pi-lens/dist/{chunk-3F6BMY53.js → chunk-JBP7KESM.js} +1 -1
  145. package/node_modules/pi-lens/dist/{chunk-U5HPROLA.js → chunk-JE6HKLC7.js} +2 -2
  146. package/node_modules/pi-lens/dist/{chunk-ZE3KXHS7.js → chunk-JPRDTY5S.js} +85 -3
  147. package/node_modules/pi-lens/dist/{chunk-HO6LWE2E.js → chunk-JYLOYTZD.js} +17 -1
  148. package/node_modules/pi-lens/dist/{chunk-KW5JQPO5.js → chunk-JZRP4DGP.js} +2 -2
  149. package/node_modules/pi-lens/dist/{chunk-CPSR3AVL.js → chunk-KZ4ALBCH.js} +2 -2
  150. package/node_modules/pi-lens/dist/{chunk-6IR3ZYIB.js → chunk-L3CLUGDY.js} +3 -3
  151. package/node_modules/pi-lens/dist/{chunk-LV4UMYVH.js → chunk-L4NEVZ4T.js} +28 -27
  152. package/node_modules/pi-lens/dist/chunk-LPYTPNOJ.js +22 -0
  153. package/node_modules/pi-lens/dist/{chunk-WGRJOXED.js → chunk-LSFXZLPW.js} +1016 -636
  154. package/node_modules/pi-lens/dist/{chunk-LBLBAFG3.js → chunk-MC6VB2E5.js} +4 -4
  155. package/node_modules/pi-lens/dist/{chunk-U2SDMG7C.js → chunk-NM2NWH55.js} +5 -5
  156. package/node_modules/pi-lens/dist/{chunk-T7A2HK2B.js → chunk-NSPVR3FN.js} +19 -18
  157. package/node_modules/pi-lens/dist/{chunk-ZGSJDWQU.js → chunk-O2ARHQKF.js} +2 -2
  158. package/node_modules/pi-lens/dist/{chunk-OXOI55RU.js → chunk-O4N5BQ3T.js} +10 -10
  159. package/node_modules/pi-lens/dist/{chunk-3FRLWYBG.js → chunk-OC7VWJBZ.js} +39 -40
  160. package/node_modules/pi-lens/dist/chunk-OFNMHPBT.js +89 -0
  161. package/node_modules/pi-lens/dist/{chunk-HR3OJ3TH.js → chunk-OWTG6UMO.js} +21 -21
  162. package/node_modules/pi-lens/dist/{chunk-75GAYVNO.js → chunk-OY7WZI7Q.js} +6 -6
  163. package/node_modules/pi-lens/dist/{chunk-ZJTT47IG.js → chunk-OZWXLJMX.js} +2 -2
  164. package/node_modules/pi-lens/dist/{chunk-F6X3YJWD.js → chunk-PIQQM32Y.js} +2 -2
  165. package/node_modules/pi-lens/dist/chunk-PKLB2XJL.js +8 -0
  166. package/node_modules/pi-lens/dist/{chunk-EAOK7MIZ.js → chunk-PKSUMEPT.js} +17 -4
  167. package/node_modules/pi-lens/dist/{chunk-YISME6ON.js → chunk-PPKECBPP.js} +1 -1
  168. package/node_modules/pi-lens/dist/{chunk-4L36HG27.js → chunk-R2QQC33W.js} +14 -14
  169. package/node_modules/pi-lens/dist/{chunk-LUBPZN36.js → chunk-R4QWJQ2H.js} +11 -11
  170. package/node_modules/pi-lens/dist/{chunk-V63BC55Q.js → chunk-RGGH6M34.js} +1 -1
  171. package/node_modules/pi-lens/dist/{chunk-Y7F7IEE3.js → chunk-RZG472YW.js} +65 -7
  172. package/node_modules/pi-lens/dist/{chunk-PUZ3E2J4.js → chunk-SDFKOLSF.js} +6 -6
  173. package/node_modules/pi-lens/dist/{chunk-YHC2O2WO.js → chunk-SFLHSL5R.js} +9 -9
  174. package/node_modules/pi-lens/dist/{chunk-CCV2EU7T.js → chunk-SP4TFY5F.js} +14 -13
  175. package/node_modules/pi-lens/dist/{chunk-J6JP25XU.js → chunk-SQC7K3SP.js} +4 -3
  176. package/node_modules/pi-lens/dist/{chunk-3K2F6UDZ.js → chunk-T2S3FNNJ.js} +44 -42
  177. package/node_modules/pi-lens/dist/{chunk-2TF6RXWB.js → chunk-TV6RXRYH.js} +10 -10
  178. package/node_modules/pi-lens/dist/{chunk-GNSIWBAT.js → chunk-U3AS2FR6.js} +3 -3
  179. package/node_modules/pi-lens/dist/{chunk-F7K5IBZG.js → chunk-UHHLR2VY.js} +40 -40
  180. package/node_modules/pi-lens/dist/chunk-UYXV5NIS.js +20 -0
  181. package/node_modules/pi-lens/dist/{chunk-VSFLRN5Y.js → chunk-VLQ7UKZH.js} +1 -1
  182. package/node_modules/pi-lens/dist/{chunk-VUZWQ7UG.js → chunk-VN3L2JWZ.js} +46 -72
  183. package/node_modules/pi-lens/dist/{chunk-NA7SEXHE.js → chunk-VOP4PJKA.js} +7 -7
  184. package/node_modules/pi-lens/dist/{chunk-F5Z6URKM.js → chunk-VOXTCULR.js} +2 -2
  185. package/node_modules/pi-lens/dist/{chunk-LLS45EWB.js → chunk-VPLBLWFO.js} +6 -8
  186. package/node_modules/pi-lens/dist/chunk-W3BGKBBK.js +27 -0
  187. package/node_modules/pi-lens/dist/{chunk-ZKXQKGWZ.js → chunk-WC6WRNQT.js} +4 -3
  188. package/node_modules/pi-lens/dist/{chunk-YVHBNSME.js → chunk-WMDUT4KH.js} +1148 -1132
  189. package/node_modules/pi-lens/dist/{chunk-KXF5R4UN.js → chunk-WQV6BI4Q.js} +1 -1
  190. package/node_modules/pi-lens/dist/chunk-WXUDRAG6.js +24 -0
  191. package/node_modules/pi-lens/dist/{chunk-KPPJTH44.js → chunk-X35S7HSB.js} +28 -10
  192. package/node_modules/pi-lens/dist/{chunk-JMEKXFOL.js → chunk-X66YJ2SS.js} +40 -34
  193. package/node_modules/pi-lens/dist/{chunk-CE6VMBCB.js → chunk-XOMGO63G.js} +22 -21
  194. package/node_modules/pi-lens/dist/{chunk-LS3QJRUB.js → chunk-XWIME22V.js} +13 -13
  195. package/node_modules/pi-lens/dist/{chunk-R5MOQM2H.js → chunk-XYLC35E4.js} +119 -87
  196. package/node_modules/pi-lens/dist/{chunk-OE5ZBP7F.js → chunk-YHGYAEFH.js} +18 -18
  197. package/node_modules/pi-lens/dist/{chunk-7E2563GA.js → chunk-ZFORSIED.js} +13 -13
  198. package/node_modules/pi-lens/dist/{chunk-E7HJ56Y7.js → chunk-ZKLTNLAW.js} +64 -73
  199. package/node_modules/pi-lens/dist/chunk-ZONZ6YY3.js +74 -0
  200. package/node_modules/pi-lens/dist/chunk-ZSM35JF4.js +30 -0
  201. package/node_modules/pi-lens/dist/{chunk-RC2Z6K47.js → chunk-ZZDIOAAJ.js} +15 -6
  202. package/node_modules/pi-lens/dist/index.js +6993 -5396
  203. package/node_modules/pi-lens/dist/mcp/analyze-cli.js +10 -10
  204. package/node_modules/pi-lens/dist/mcp/cli.js +44 -42
  205. package/node_modules/pi-lens/dist/mcp/server.js +1627 -504
  206. package/node_modules/pi-lens/dist/mcp/worker.js +62 -61
  207. package/node_modules/pi-lens/dist/probes/installer.js +20 -19
  208. package/node_modules/pi-lens/docs/adr/0003-git-guard-latch-writer.md +11 -6
  209. package/node_modules/pi-lens/docs/agent-tools.md +18 -8
  210. package/node_modules/pi-lens/docs/alignment-families.md +29 -0
  211. package/node_modules/pi-lens/docs/ast-grep_rules_catalog.md +6 -4
  212. package/node_modules/pi-lens/docs/ci-bot-pr-checks.md +126 -0
  213. package/node_modules/pi-lens/docs/configuration.md +99 -3
  214. package/node_modules/pi-lens/docs/defect-shapes.md +55 -12
  215. package/node_modules/pi-lens/docs/engineering-principles.md +27 -2
  216. package/node_modules/pi-lens/docs/features.md +2 -2
  217. package/node_modules/pi-lens/docs/invariants/git-guard-host.md +7 -3
  218. package/node_modules/pi-lens/docs/invariants/language-config.md +15 -4
  219. package/node_modules/pi-lens/docs/invariants/lsp-trust-exec.md +16 -2
  220. package/node_modules/pi-lens/docs/invariants/paths-os.md +4 -2
  221. package/node_modules/pi-lens/docs/lsp-capability-matrix.md +119 -39
  222. package/node_modules/pi-lens/docs/merge-queue-rollout.md +1 -1
  223. package/node_modules/pi-lens/docs/pi-lens-fixer.md +24 -17
  224. package/node_modules/pi-lens/docs/pi-lens-merge-policy.md +20 -11
  225. package/node_modules/pi-lens/docs/pi-lens-monitor.md +9 -0
  226. package/node_modules/pi-lens/docs/pi-lens-orchestration.md +4 -1
  227. package/node_modules/pi-lens/docs/pi-lens-reviewer.md +5 -5
  228. package/node_modules/pi-lens/docs/pi-lens-subagent.md +6 -3
  229. package/node_modules/pi-lens/docs/public-api-stability.md +18 -2
  230. package/node_modules/pi-lens/docs/schema/pi-lens-config-v1.json +10 -0
  231. package/node_modules/pi-lens/docs/settings.md +10 -6
  232. package/node_modules/pi-lens/docs/word-index.md +17 -5
  233. package/node_modules/pi-lens/package.json +5 -3
  234. package/node_modules/pi-lens/rules/ast-grep-rules/rule-tests/no-accumulating-spread-js-test.yml +37 -0
  235. package/node_modules/pi-lens/rules/ast-grep-rules/rule-tests/ts-redundant-filter-map-test.yml +12 -1
  236. package/node_modules/pi-lens/rules/ast-grep-rules/rule-tests-disabled/filter-then-map-js-test.yml +12 -0
  237. package/node_modules/pi-lens/rules/ast-grep-rules/rule-tests-disabled/filter-then-map-test.yml +25 -0
  238. package/node_modules/pi-lens/rules/ast-grep-rules/rules/no-accumulating-spread-js.yml +49 -1
  239. package/node_modules/pi-lens/rules/ast-grep-rules/rules/ts-redundant-filter-map.yml +9 -1
  240. package/node_modules/pi-lens/rules/ast-grep-rules/rules-disabled/filter-then-map-js.yml +17 -0
  241. package/node_modules/pi-lens/rules/ast-grep-rules/rules-disabled/filter-then-map.yml +36 -0
  242. package/node_modules/pi-lens/rules/ast-grep-rules/self-scan-baseline.json +1 -1
  243. package/node_modules/pi-provider-qoder/README.md +22 -0
  244. package/node_modules/pi-provider-qoder/dist/index.js +370 -11
  245. package/node_modules/pi-provider-qoder/package.json +5 -2
  246. package/package.json +11 -8
  247. package/node_modules/@tifan/pi-preferred-thinking/README.md +0 -54
  248. package/node_modules/@tifan/pi-preferred-thinking/package.json +0 -43
  249. package/node_modules/@tifan/pi-preferred-thinking/src/index.ts +0 -236
  250. package/node_modules/pi-lens/dist/chunk-46TNM7XZ.js +0 -88
  251. package/node_modules/pi-lens/dist/chunk-72OKUXSD.js +0 -31
  252. package/node_modules/pi-lens/dist/chunk-7GLOLOSH.js +0 -57
  253. package/node_modules/pi-lens/dist/chunk-AKUUMGD5.js +0 -26
  254. package/node_modules/pi-lens/dist/chunk-ASUXV767.js +0 -22
  255. package/node_modules/pi-lens/dist/chunk-CTADOKYM.js +0 -25
  256. package/node_modules/pi-lens/dist/chunk-JJ2RRESP.js +0 -58
  257. package/node_modules/pi-lens/dist/chunk-LSC3VADM.js +0 -23
  258. package/node_modules/pi-lens/dist/chunk-SHLDT3OI.js +0 -27
  259. package/node_modules/pi-lens/dist/chunk-UF7RTZSO.js +0 -27
  260. package/node_modules/pi-lens/dist/chunk-W4WP2ERB.js +0 -30
  261. package/node_modules/pi-lens/dist/chunk-YES5CACN.js +0 -73
@@ -0,0 +1,69 @@
1
+ /**
2
+ * task-widget.ts — Persistent widget showing task list with status glyphs and progress.
3
+ *
4
+ * Display style matches Claude Code's task list:
5
+ * ✔ completed tasks (strikethrough + dim)
6
+ * ◼ in_progress tasks
7
+ * ◻ pending tasks
8
+ * ✳/✽ actively executing task (star spinner with activeForm text)
9
+ *
10
+ * Every glyph on screen is a default that `glyphs` in tasks-config.json can
11
+ * replace — see task-glyphs.ts.
12
+ */
13
+ import type { TaskStore } from "../task-store.js";
14
+ import type { TasksConfig } from "../tasks-config.js";
15
+ export type Theme = {
16
+ fg(color: string, text: string): string;
17
+ bold(text: string): string;
18
+ strikethrough(text: string): string;
19
+ };
20
+ export type UICtx = {
21
+ setStatus(key: string, text: string | undefined): void;
22
+ setWidget(key: string, content: undefined | ((tui: any, theme: Theme) => {
23
+ render(): string[];
24
+ invalidate(): void;
25
+ }), options?: {
26
+ placement?: "aboveEditor" | "belowEditor";
27
+ }): void;
28
+ };
29
+ /** Per-task runtime metrics (elapsed time, token usage). */
30
+ export interface TaskMetrics {
31
+ startedAt: number;
32
+ inputTokens: number;
33
+ outputTokens: number;
34
+ }
35
+ export declare class TaskWidget {
36
+ private store;
37
+ private config;
38
+ private uiCtx;
39
+ private widgetFrame;
40
+ private widgetInterval;
41
+ /** IDs of tasks currently being actively executed (show spinner). */
42
+ private activeTaskIds;
43
+ /** Per-task runtime metrics keyed by task ID. */
44
+ private metrics;
45
+ /** Cached TUI instance for requestRender() calls. */
46
+ private tui;
47
+ /** Whether the widget callback is currently registered. */
48
+ private widgetRegistered;
49
+ constructor(store: TaskStore, config?: TasksConfig);
50
+ setStore(store: TaskStore): void;
51
+ setUICtx(ctx: UICtx): void;
52
+ /** Add or remove a task from the active spinner set. */
53
+ setActiveTask(taskId: string | undefined, active?: boolean): void;
54
+ /** Record token usage for the currently active task(s). */
55
+ addTokenUsage(inputTokens: number, outputTokens: number): void;
56
+ /** Ensure the widget update timer is running. The spinner advances here and
57
+ * nowhere else: `update()` also runs on every task mutation and tool execution,
58
+ * so incrementing there tied the animation speed to how busy the agent was. */
59
+ ensureTimer(): void;
60
+ /** Render callback entry point. Guarded so a render error can never escape to
61
+ * the TUI timer and crash the whole host process — worst case the widget is
62
+ * empty for one frame. */
63
+ private renderWidget;
64
+ /** Build widget lines from current live state. */
65
+ private buildWidgetLines;
66
+ /** Force an immediate widget update. */
67
+ update(): void;
68
+ dispose(): void;
69
+ }
@@ -0,0 +1,278 @@
1
+ /**
2
+ * task-widget.ts — Persistent widget showing task list with status glyphs and progress.
3
+ *
4
+ * Display style matches Claude Code's task list:
5
+ * ✔ completed tasks (strikethrough + dim)
6
+ * ◼ in_progress tasks
7
+ * ◻ pending tasks
8
+ * ✳/✽ actively executing task (star spinner with activeForm text)
9
+ *
10
+ * Every glyph on screen is a default that `glyphs` in tasks-config.json can
11
+ * replace — see task-glyphs.ts.
12
+ */
13
+ import { truncateToWidth } from "@earendil-works/pi-tui";
14
+ import { resolveTaskGlyphs } from "../task-glyphs.js";
15
+ function truncateFromTop(tasks, limit) {
16
+ return tasks.slice(-limit);
17
+ }
18
+ function truncateFromBottom(tasks, limit) {
19
+ return tasks.slice(0, limit);
20
+ }
21
+ const TRUNCATE_FNS = { top: truncateFromTop, bottom: truncateFromBottom };
22
+ const DEFAULT_MAX_VISIBLE_TASKS = 10;
23
+ /** Format milliseconds as a human-readable duration (e.g., "2m 49s", "1h 3m"). */
24
+ function formatDuration(ms) {
25
+ const totalSec = Math.floor(ms / 1000);
26
+ if (totalSec < 60)
27
+ return `${totalSec}s`;
28
+ const min = Math.floor(totalSec / 60);
29
+ const sec = totalSec % 60;
30
+ if (min < 60)
31
+ return sec > 0 ? `${min}m ${sec}s` : `${min}m`;
32
+ const hr = Math.floor(min / 60);
33
+ const remMin = min % 60;
34
+ return remMin > 0 ? `${hr}h ${remMin}m` : `${hr}h`;
35
+ }
36
+ /** Format token count with k suffix (e.g., "4.1k", "850"). */
37
+ function formatTokens(n) {
38
+ if (n < 1000)
39
+ return String(n);
40
+ return (n / 1000).toFixed(1).replace(/\.0$/, "") + "k";
41
+ }
42
+ // ---- Widget ----
43
+ export class TaskWidget {
44
+ store;
45
+ config;
46
+ uiCtx;
47
+ widgetFrame = 0;
48
+ widgetInterval;
49
+ /** IDs of tasks currently being actively executed (show spinner). */
50
+ activeTaskIds = new Set();
51
+ /** Per-task runtime metrics keyed by task ID. */
52
+ metrics = new Map();
53
+ /** Cached TUI instance for requestRender() calls. */
54
+ tui;
55
+ /** Whether the widget callback is currently registered. */
56
+ widgetRegistered = false;
57
+ constructor(store, config = {}) {
58
+ this.store = store;
59
+ this.config = config;
60
+ }
61
+ setStore(store) {
62
+ this.store = store;
63
+ }
64
+ setUICtx(ctx) {
65
+ this.uiCtx = ctx;
66
+ }
67
+ /** Add or remove a task from the active spinner set. */
68
+ setActiveTask(taskId, active = true) {
69
+ if (taskId && active) {
70
+ this.activeTaskIds.add(taskId);
71
+ if (!this.metrics.has(taskId)) {
72
+ this.metrics.set(taskId, { startedAt: Date.now(), inputTokens: 0, outputTokens: 0 });
73
+ }
74
+ this.ensureTimer();
75
+ }
76
+ else if (taskId) {
77
+ this.activeTaskIds.delete(taskId);
78
+ }
79
+ this.update();
80
+ }
81
+ /** Record token usage for the currently active task(s). */
82
+ addTokenUsage(inputTokens, outputTokens) {
83
+ // Distribute to all currently active tasks
84
+ for (const id of this.activeTaskIds) {
85
+ const m = this.metrics.get(id);
86
+ if (m) {
87
+ m.inputTokens += inputTokens;
88
+ m.outputTokens += outputTokens;
89
+ }
90
+ }
91
+ }
92
+ /** Ensure the widget update timer is running. The spinner advances here and
93
+ * nowhere else: `update()` also runs on every task mutation and tool execution,
94
+ * so incrementing there tied the animation speed to how busy the agent was. */
95
+ ensureTimer() {
96
+ if (!this.widgetInterval) {
97
+ this.widgetInterval = setInterval(() => {
98
+ this.widgetFrame++;
99
+ this.update();
100
+ }, 150);
101
+ }
102
+ }
103
+ /** Render callback entry point. Guarded so a render error can never escape to
104
+ * the TUI timer and crash the whole host process — worst case the widget is
105
+ * empty for one frame. */
106
+ renderWidget(tui, theme) {
107
+ try {
108
+ return this.buildWidgetLines(tui, theme);
109
+ }
110
+ catch {
111
+ return [];
112
+ }
113
+ }
114
+ /** Build widget lines from current live state. */
115
+ buildWidgetLines(tui, theme) {
116
+ const sortOrder = this.config.sortOrder ?? "id";
117
+ // Resolved per render, not cached: the extension swaps this config object's
118
+ // contents when the host moves to a session in another workspace.
119
+ const glyphs = resolveTaskGlyphs(this.config.glyphs);
120
+ const tasks = this.store.list(sortOrder);
121
+ const w = tui.terminal.columns;
122
+ const truncate = (line) => truncateToWidth(line, w, glyphs.truncation);
123
+ if (tasks.length === 0)
124
+ return [];
125
+ const completed = tasks.filter(t => t.status === "completed");
126
+ const inProgress = tasks.filter(t => t.status === "in_progress");
127
+ const pending = tasks.filter(t => t.status === "pending");
128
+ const parts = [];
129
+ if (completed.length > 0)
130
+ parts.push(`${completed.length} done`);
131
+ if (inProgress.length > 0)
132
+ parts.push(`${inProgress.length} in progress`);
133
+ if (pending.length > 0)
134
+ parts.push(`${pending.length} open`);
135
+ const statusText = `${tasks.length} tasks (${parts.join(", ")})`;
136
+ const spinnerFrame = glyphs.spinner[this.widgetFrame % glyphs.spinner.length];
137
+ const lines = [truncate(theme.fg("accent", glyphs.header) + " " + theme.fg("accent", statusText))];
138
+ // Collapsing only decides what goes in the list; the visible-limit logic below
139
+ // then runs unchanged over whatever remains.
140
+ const collapseCompleted = this.config.collapseCompleted ?? false;
141
+ const listed = collapseCompleted ? tasks.filter(t => t.status !== "completed") : tasks;
142
+ const showAll = this.config.showAll ?? false;
143
+ const limit = this.config.maxVisible ?? DEFAULT_MAX_VISIBLE_TASKS;
144
+ // Narrowed rather than defaulted: config is hand-editable JSON, and an
145
+ // unrecognised value would index TRUNCATE_FNS to undefined and blank the widget.
146
+ const hiddenAt = this.config.hiddenAt === "top" ? "top" : "bottom";
147
+ const visible = showAll ? listed : TRUNCATE_FNS[hiddenAt](listed, limit);
148
+ const hiddenCount = listed.length - visible.length;
149
+ const overflowLine = hiddenCount > 0
150
+ ? truncate(theme.fg("dim", ` ${glyphs.overflow} and ${hiddenCount} more`))
151
+ : undefined;
152
+ if (overflowLine && hiddenAt === "top") {
153
+ lines.push(overflowLine);
154
+ }
155
+ for (let i = 0; i < visible.length; i++) {
156
+ const task = visible[i];
157
+ const isActive = this.activeTaskIds.has(task.id) && task.status === "in_progress";
158
+ let statusGlyph;
159
+ if (isActive) {
160
+ statusGlyph = theme.fg("accent", spinnerFrame);
161
+ }
162
+ else if (task.status === "completed") {
163
+ statusGlyph = theme.fg("success", glyphs.completed);
164
+ }
165
+ else if (task.status === "in_progress") {
166
+ statusGlyph = theme.fg("accent", glyphs.inProgress);
167
+ }
168
+ else {
169
+ statusGlyph = glyphs.pending;
170
+ }
171
+ let suffix = "";
172
+ if (task.status === "pending" && task.blockedBy.length > 0) {
173
+ const openBlockers = task.blockedBy.filter(bid => {
174
+ const blocker = this.store.get(bid);
175
+ return blocker && blocker.status !== "completed";
176
+ });
177
+ if (openBlockers.length > 0) {
178
+ suffix = theme.fg("dim", ` ${glyphs.blocked} blocked by ${openBlockers.map(id => "#" + id).join(", ")}`);
179
+ }
180
+ }
181
+ let text;
182
+ if (isActive) {
183
+ const form = task.activeForm || task.subject;
184
+ const agentId = task.metadata?.agentId;
185
+ const agentLabel = agentId ? ` (agent ${agentId.slice(0, 5)})` : "";
186
+ const m = this.metrics.get(task.id);
187
+ let stats = "";
188
+ if (m) {
189
+ const elapsed = formatDuration(Date.now() - m.startedAt);
190
+ const tokenParts = [];
191
+ if (m.inputTokens > 0)
192
+ tokenParts.push(`${glyphs.inputTokens} ${formatTokens(m.inputTokens)}`);
193
+ if (m.outputTokens > 0)
194
+ tokenParts.push(`${glyphs.outputTokens} ${formatTokens(m.outputTokens)}`);
195
+ stats = tokenParts.length > 0
196
+ ? ` ${theme.fg("dim", `(${elapsed} ${glyphs.statsSeparator} ${tokenParts.join(" ")})`)}`
197
+ : ` ${theme.fg("dim", `(${elapsed})`)}`;
198
+ }
199
+ text = ` ${statusGlyph} ${theme.fg("dim", "#" + task.id)} ${theme.fg("accent", form + agentLabel + glyphs.trailingEllipsis)}${stats}`;
200
+ }
201
+ else if (task.status === "completed") {
202
+ text = ` ${statusGlyph} ${theme.fg("dim", theme.strikethrough("#" + task.id + " " + task.subject))}`;
203
+ }
204
+ else {
205
+ const agentSuffix = task.status === "in_progress" && task.metadata?.agentId
206
+ ? theme.fg("dim", ` (agent ${task.metadata.agentId.slice(0, 5)})`)
207
+ : "";
208
+ text = ` ${statusGlyph} ${theme.fg("dim", "#" + task.id)} ${task.subject}${agentSuffix}`;
209
+ }
210
+ lines.push(truncate(text + suffix));
211
+ }
212
+ if (overflowLine && hiddenAt !== "top") {
213
+ lines.push(overflowLine);
214
+ }
215
+ if (collapseCompleted && completed.length > 0) {
216
+ lines.push(truncate(` ${theme.fg("success", glyphs.completedSummary)} ${theme.fg("dim", `${completed.length} completed`)}`));
217
+ }
218
+ return lines;
219
+ }
220
+ /** Force an immediate widget update. */
221
+ update() {
222
+ if (!this.uiCtx)
223
+ return;
224
+ const tasks = this.store.list();
225
+ // Transition: visible → hidden
226
+ if (tasks.length === 0) {
227
+ if (this.widgetRegistered) {
228
+ this.uiCtx.setWidget("tasks", undefined);
229
+ this.widgetRegistered = false;
230
+ }
231
+ if (this.widgetInterval) {
232
+ clearInterval(this.widgetInterval);
233
+ this.widgetInterval = undefined;
234
+ }
235
+ return;
236
+ }
237
+ // Prune stale active IDs (deleted or no longer in_progress)
238
+ for (const id of this.activeTaskIds) {
239
+ const t = this.store.get(id);
240
+ if (!t || t.status !== "in_progress") {
241
+ this.activeTaskIds.delete(id);
242
+ this.metrics.delete(id);
243
+ }
244
+ }
245
+ // Check if any task needs animation
246
+ const hasActiveSpinner = tasks.some(t => this.activeTaskIds.has(t.id) && t.status === "in_progress");
247
+ if (hasActiveSpinner) {
248
+ this.ensureTimer();
249
+ }
250
+ else if (!hasActiveSpinner && this.widgetInterval) {
251
+ clearInterval(this.widgetInterval);
252
+ this.widgetInterval = undefined;
253
+ }
254
+ // Transition: hidden → visible — register widget callback once
255
+ if (!this.widgetRegistered) {
256
+ this.uiCtx.setWidget("tasks", (tui, theme) => {
257
+ this.tui = tui;
258
+ return { render: () => this.renderWidget(tui, theme), invalidate: () => { } };
259
+ }, { placement: "aboveEditor" });
260
+ this.widgetRegistered = true;
261
+ }
262
+ else if (this.tui) {
263
+ // Widget already registered — just request a re-render
264
+ this.tui.requestRender();
265
+ }
266
+ }
267
+ dispose() {
268
+ if (this.widgetInterval) {
269
+ clearInterval(this.widgetInterval);
270
+ this.widgetInterval = undefined;
271
+ }
272
+ if (this.uiCtx) {
273
+ this.uiCtx.setWidget("tasks", undefined);
274
+ }
275
+ this.widgetRegistered = false;
276
+ this.tui = undefined;
277
+ }
278
+ }
@@ -0,0 +1,57 @@
1
+ {
2
+ "name": "@tintinweb/pi-tasks",
3
+ "version": "0.9.1",
4
+ "description": "A pi extension that brings Claude Code-style task tracking and coordination to pi.",
5
+ "author": "tintinweb",
6
+ "license": "MIT",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "https://github.com/tintinweb/pi-tasks.git"
10
+ },
11
+ "homepage": "https://github.com/tintinweb/pi-tasks#readme",
12
+ "bugs": {
13
+ "url": "https://github.com/tintinweb/pi-tasks/issues"
14
+ },
15
+ "publishConfig": {
16
+ "access": "public"
17
+ },
18
+ "keywords": [
19
+ "pi-package",
20
+ "pi",
21
+ "pi-extension",
22
+ "task",
23
+ "tasks",
24
+ "todo",
25
+ "coordination"
26
+ ],
27
+ "peerDependencies": {
28
+ "@earendil-works/pi-coding-agent": "*",
29
+ "@earendil-works/pi-tui": "*",
30
+ "typebox": "*"
31
+ },
32
+ "scripts": {
33
+ "build": "node -e \"require('fs').rmSync('dist',{recursive:true,force:true})\" && tsc",
34
+ "prepublishOnly": "npm run lint && npm run typecheck && npm run test && npm run build",
35
+ "test": "vitest run",
36
+ "test:watch": "vitest",
37
+ "typecheck": "tsc --noEmit",
38
+ "lint": "biome check src/ test/",
39
+ "lint:fix": "biome check --fix src/ test/"
40
+ },
41
+ "devDependencies": {
42
+ "@biomejs/biome": "^2.4.13",
43
+ "@earendil-works/pi-coding-agent": "0.84.2",
44
+ "@earendil-works/pi-tui": "0.84.2",
45
+ "@types/node": "^25.0.0",
46
+ "typebox": "^1.1.34",
47
+ "typescript": "^6.0.0",
48
+ "vitest": "^4.1.5"
49
+ },
50
+ "pi": {
51
+ "extensions": [
52
+ "./src/index.ts"
53
+ ],
54
+ "video": "https://github.com/tintinweb/pi-tasks/raw/master/media/demo.mp4",
55
+ "image": "https://github.com/tintinweb/pi-tasks/raw/master/media/screenshot.png"
56
+ }
57
+ }
@@ -0,0 +1,134 @@
1
+ /**
2
+ * auto-clear.ts — Turn-based auto-clearing of completed tasks.
3
+ *
4
+ * Two modes:
5
+ * - "on_task_complete": each completed task gets its own REMINDER_INTERVAL countdown, deleted individually
6
+ * - "on_list_complete": countdown starts when ALL tasks are completed, cleared as a batch
7
+ *
8
+ * Both use the same turn delay (REMINDER_INTERVAL) for consistency.
9
+ *
10
+ * Both countdowns are measured in turns and only tick at `turn_start`, so they stop
11
+ * the moment the agent does. That is fine while the conversation continues — the
12
+ * turns keep coming — but a run that ends right after its last completion, which is
13
+ * the usual shape, leaves the finished list sitting there with its countdown frozen,
14
+ * and the next batch of work is then added to it.
15
+ *
16
+ * `startNewBatch()` covers that case. It has to tell a new batch from the same batch
17
+ * still being built, and the store cannot: an agent adding its next task to a list it
18
+ * has just finished looks identical either way. The run boundary is what separates
19
+ * them — work added within the run that completed the list belongs to it, work added
20
+ * after that run ended does not — so the sweep is armed by `onRunEnded()`.
21
+ */
22
+
23
+ import type { TaskStore } from "./task-store.js";
24
+
25
+ export type AutoClearMode = "never" | "on_list_complete" | "on_task_complete";
26
+
27
+ export class AutoClearManager {
28
+ /** Per-task: turn when task was marked completed ("on_task_complete" mode). */
29
+ private completedAtTurn = new Map<string, number>();
30
+ /** Turn when ALL tasks became completed ("on_list_complete" mode). */
31
+ private allCompletedAtTurn: number | null = null;
32
+ /** An agent run has ended since the current list was last added to. */
33
+ private runEnded = false;
34
+
35
+ constructor(
36
+ private getStore: () => TaskStore,
37
+ private getMode: () => AutoClearMode,
38
+ /** How many turns completed tasks linger before auto-clearing. */
39
+ private clearDelayTurns = 4,
40
+ ) {}
41
+
42
+ /** Record a task completion. Call AFTER cascade logic. */
43
+ trackCompletion(taskId: string, currentTurn: number): void {
44
+ const mode = this.getMode();
45
+ if (mode === "never") return;
46
+
47
+ if (mode === "on_task_complete") {
48
+ this.completedAtTurn.set(taskId, currentTurn);
49
+ } else if (mode === "on_list_complete") {
50
+ this.checkAllCompleted(currentTurn);
51
+ }
52
+ }
53
+
54
+ /** Check if all tasks are completed and start/reset the batch countdown. */
55
+ private checkAllCompleted(currentTurn: number): void {
56
+ const tasks = this.getStore().list();
57
+ if (tasks.length > 0 && tasks.every(t => t.status === "completed")) {
58
+ if (this.allCompletedAtTurn === null) this.allCompletedAtTurn = currentTurn;
59
+ } else {
60
+ this.allCompletedAtTurn = null;
61
+ }
62
+ }
63
+
64
+ /** Reset batch countdown (e.g., when a new task is created or task goes non-completed). */
65
+ resetBatchCountdown(): void {
66
+ this.allCompletedAtTurn = null;
67
+ }
68
+
69
+ /** No automatic retry, compaction or queued continuation is coming, so the list as
70
+ * it stands is this run's final one. Also true of a list carried into a resumed or
71
+ * forked session: the run that produced it ended with the session before. */
72
+ onRunEnded(): void {
73
+ this.runEnded = true;
74
+ }
75
+
76
+ /** A task is about to be created. If a run has ended since this list was last added
77
+ * to and there is nothing left to do on it, the list belongs to the batch before
78
+ * this one — retire it, so the new task starts on a clean list instead of being
79
+ * appended to rows the user already saw finished.
80
+ *
81
+ * Left alone otherwise: a list with unfinished work in it, and a list the agent is
82
+ * still building inside the same run (create, complete, create again), which would
83
+ * otherwise lose every step as soon as the next one was added. */
84
+ startNewBatch(): void {
85
+ this.allCompletedAtTurn = null;
86
+ const afterFinishedRun = this.runEnded;
87
+ this.runEnded = false;
88
+ // Cheap-first: list() re-reads the file on a file-backed store.
89
+ if (!afterFinishedRun || this.getMode() === "never") return;
90
+ const tasks = this.getStore().list();
91
+ if (tasks.length > 0 && tasks.every(t => t.status === "completed")) {
92
+ this.getStore().clearCompleted();
93
+ this.completedAtTurn.clear();
94
+ }
95
+ }
96
+
97
+ /** Reset all tracking state (e.g., on new session). */
98
+ reset(): void {
99
+ this.completedAtTurn.clear();
100
+ this.allCompletedAtTurn = null;
101
+ this.runEnded = false;
102
+ }
103
+
104
+ /**
105
+ * Called on each turn start. Deletes tasks whose linger period has expired.
106
+ * Returns true if any tasks were cleared.
107
+ */
108
+ onTurnStart(currentTurn: number): boolean {
109
+ const mode = this.getMode();
110
+ let cleared = false;
111
+
112
+ if (mode === "on_task_complete") {
113
+ for (const [taskId, turn] of this.completedAtTurn) {
114
+ const task = this.getStore().get(taskId);
115
+ if (!task || task.status !== "completed") {
116
+ // Task was deleted or reverted — drop stale tracking entry
117
+ this.completedAtTurn.delete(taskId);
118
+ } else if (currentTurn - turn >= this.clearDelayTurns) {
119
+ this.getStore().delete(taskId);
120
+ this.completedAtTurn.delete(taskId);
121
+ cleared = true;
122
+ }
123
+ }
124
+ } else if (mode === "on_list_complete" && this.allCompletedAtTurn !== null) {
125
+ if (currentTurn - this.allCompletedAtTurn >= this.clearDelayTurns) {
126
+ this.getStore().clearCompleted();
127
+ this.allCompletedAtTurn = null;
128
+ cleared = true;
129
+ }
130
+ }
131
+
132
+ return cleared;
133
+ }
134
+ }