@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,29 @@
1
+ /**
2
+ * process-tracker.ts — Background process management for tasks.
3
+ *
4
+ * Tracks spawned child processes, buffers their output, and supports
5
+ * blocking wait and graceful stop (SIGTERM → 5s → SIGKILL).
6
+ */
7
+ import type { ChildProcess } from "node:child_process";
8
+ import type { BackgroundProcess } from "./types.js";
9
+ export interface ProcessOutput {
10
+ output: string;
11
+ status: BackgroundProcess["status"];
12
+ exitCode?: number;
13
+ startedAt: number;
14
+ completedAt?: number;
15
+ command?: string;
16
+ }
17
+ export declare class ProcessTracker {
18
+ private processes;
19
+ /** Register a spawned process for a task. */
20
+ track(taskId: string, proc: ChildProcess, command?: string): void;
21
+ /** Get current output and status for a task's process. */
22
+ getOutput(taskId: string): ProcessOutput | undefined;
23
+ /** Wait for a task's process to complete, with timeout. */
24
+ waitForCompletion(taskId: string, timeout: number, signal?: AbortSignal): Promise<ProcessOutput | undefined>;
25
+ /** Stop a task's background process. SIGTERM → 5s → SIGKILL. */
26
+ stop(taskId: string): Promise<boolean>;
27
+ /** Get the process record for a task. */
28
+ getProcess(taskId: string): BackgroundProcess | undefined;
29
+ }
@@ -0,0 +1,121 @@
1
+ /**
2
+ * process-tracker.ts — Background process management for tasks.
3
+ *
4
+ * Tracks spawned child processes, buffers their output, and supports
5
+ * blocking wait and graceful stop (SIGTERM → 5s → SIGKILL).
6
+ */
7
+ export class ProcessTracker {
8
+ processes = new Map();
9
+ /** Register a spawned process for a task. */
10
+ track(taskId, proc, command) {
11
+ const bp = {
12
+ taskId,
13
+ pid: proc.pid,
14
+ command,
15
+ output: [],
16
+ status: "running",
17
+ startedAt: Date.now(),
18
+ proc,
19
+ abortController: new AbortController(),
20
+ waiters: [],
21
+ };
22
+ // Buffer stdout
23
+ proc.stdout?.on("data", (data) => {
24
+ bp.output.push(data.toString());
25
+ });
26
+ // Buffer stderr
27
+ proc.stderr?.on("data", (data) => {
28
+ bp.output.push(data.toString());
29
+ });
30
+ // Handle process exit
31
+ proc.on("close", (code, _signal) => {
32
+ if (bp.status === "running") {
33
+ bp.status = code === 0 ? "completed" : "error";
34
+ }
35
+ bp.exitCode = code ?? undefined;
36
+ bp.completedAt = Date.now();
37
+ // Notify all waiters
38
+ for (const resolve of bp.waiters)
39
+ resolve();
40
+ bp.waiters = [];
41
+ });
42
+ proc.on("error", (err) => {
43
+ if (bp.status === "running") {
44
+ bp.status = "error";
45
+ bp.output.push(`Process error: ${err.message}`);
46
+ bp.completedAt = Date.now();
47
+ for (const resolve of bp.waiters)
48
+ resolve();
49
+ bp.waiters = [];
50
+ }
51
+ });
52
+ this.processes.set(taskId, bp);
53
+ }
54
+ /** Get current output and status for a task's process. */
55
+ getOutput(taskId) {
56
+ const bp = this.processes.get(taskId);
57
+ if (!bp)
58
+ return undefined;
59
+ return {
60
+ output: bp.output.join(""),
61
+ status: bp.status,
62
+ exitCode: bp.exitCode,
63
+ startedAt: bp.startedAt,
64
+ completedAt: bp.completedAt,
65
+ command: bp.command,
66
+ };
67
+ }
68
+ /** Wait for a task's process to complete, with timeout. */
69
+ waitForCompletion(taskId, timeout, signal) {
70
+ const bp = this.processes.get(taskId);
71
+ if (!bp)
72
+ return Promise.resolve(undefined);
73
+ if (bp.status !== "running")
74
+ return Promise.resolve(this.getOutput(taskId));
75
+ return new Promise((resolve) => {
76
+ let settled = false;
77
+ const timer = setTimeout(finish, timeout);
78
+ function finish() {
79
+ if (settled)
80
+ return;
81
+ settled = true;
82
+ clearTimeout(timer);
83
+ resolve(self.getOutput(taskId));
84
+ }
85
+ const self = this;
86
+ bp.waiters.push(finish);
87
+ signal?.addEventListener("abort", finish, { once: true });
88
+ });
89
+ }
90
+ /** Stop a task's background process. SIGTERM → 5s → SIGKILL. */
91
+ async stop(taskId) {
92
+ const bp = this.processes.get(taskId);
93
+ if (!bp || bp.status !== "running")
94
+ return false;
95
+ bp.status = "stopped";
96
+ bp.proc.kill("SIGTERM");
97
+ // Wait up to 5s for graceful exit
98
+ await new Promise((resolve) => {
99
+ const timer = setTimeout(() => {
100
+ try {
101
+ bp.proc.kill("SIGKILL");
102
+ }
103
+ catch { /* already dead */ }
104
+ resolve();
105
+ }, 5000);
106
+ bp.proc.on("close", () => {
107
+ clearTimeout(timer);
108
+ resolve();
109
+ });
110
+ });
111
+ bp.completedAt = Date.now();
112
+ for (const resolve of bp.waiters)
113
+ resolve();
114
+ bp.waiters = [];
115
+ return true;
116
+ }
117
+ /** Get the process record for a task. */
118
+ getProcess(taskId) {
119
+ return this.processes.get(taskId);
120
+ }
121
+ }
@@ -0,0 +1,39 @@
1
+ /**
2
+ * Pure cadence logic for the system-reminder injection.
3
+ *
4
+ * Decisions are made here as plain functions so they're easy to unit-test
5
+ * without spinning up the whole extension. The default export of the
6
+ * extension wires these into the `tool_result` and `context` hooks.
7
+ */
8
+ /** Internal cadence state. Plain object so it round-trips through tests. */
9
+ export interface CadenceState {
10
+ currentTurn: number;
11
+ lastTaskToolUseTurn: number;
12
+ reminderInjectedThisCycle: boolean;
13
+ reminderDue: boolean;
14
+ }
15
+ export interface CadenceConfig {
16
+ /** Turns without a task-tool call before a reminder is considered due. */
17
+ reminderInterval: number;
18
+ /** Set of tool names that count as "task tool usage" and reset cadence. */
19
+ taskToolNames: ReadonlySet<string>;
20
+ }
21
+ export declare function createCadenceState(): CadenceState;
22
+ export declare function resetCadenceState(state: CadenceState): void;
23
+ /** Increment the turn counter at `turn_start`. */
24
+ export declare function onTurnStart(state: CadenceState): void;
25
+ export interface ToolResultDecision {
26
+ /** True when caller should mark `reminderDue` for the next `context` event. */
27
+ markDue: boolean;
28
+ }
29
+ /**
30
+ * Decide what cadence change a tool_result implies. Mutates `state` in place
31
+ * (resets the timer when a task tool was used) and returns whether the
32
+ * reminder should be queued for the next LLM call.
33
+ */
34
+ export declare function evaluateToolResult(state: CadenceState, toolName: string, hasTasks: boolean, config: CadenceConfig): ToolResultDecision;
35
+ /**
36
+ * Drain the pending reminder when `context` fires. Returns true if the
37
+ * caller should inject the reminder into the upcoming LLM call's messages.
38
+ */
39
+ export declare function drainReminderForContext(state: CadenceState): boolean;
@@ -0,0 +1,61 @@
1
+ /**
2
+ * Pure cadence logic for the system-reminder injection.
3
+ *
4
+ * Decisions are made here as plain functions so they're easy to unit-test
5
+ * without spinning up the whole extension. The default export of the
6
+ * extension wires these into the `tool_result` and `context` hooks.
7
+ */
8
+ export function createCadenceState() {
9
+ return {
10
+ currentTurn: 0,
11
+ lastTaskToolUseTurn: 0,
12
+ reminderInjectedThisCycle: false,
13
+ reminderDue: false,
14
+ };
15
+ }
16
+ export function resetCadenceState(state) {
17
+ state.currentTurn = 0;
18
+ state.lastTaskToolUseTurn = 0;
19
+ state.reminderInjectedThisCycle = false;
20
+ state.reminderDue = false;
21
+ }
22
+ /** Increment the turn counter at `turn_start`. */
23
+ export function onTurnStart(state) {
24
+ state.currentTurn++;
25
+ }
26
+ /**
27
+ * Decide what cadence change a tool_result implies. Mutates `state` in place
28
+ * (resets the timer when a task tool was used) and returns whether the
29
+ * reminder should be queued for the next LLM call.
30
+ */
31
+ export function evaluateToolResult(state, toolName, hasTasks, config) {
32
+ // Task tool usage resets cadence and clears any pending reminder.
33
+ if (config.taskToolNames.has(toolName)) {
34
+ state.lastTaskToolUseTurn = state.currentTurn;
35
+ state.reminderInjectedThisCycle = false;
36
+ state.reminderDue = false;
37
+ return { markDue: false };
38
+ }
39
+ // Cheap guards first.
40
+ if (state.currentTurn - state.lastTaskToolUseTurn < config.reminderInterval) {
41
+ return { markDue: false };
42
+ }
43
+ if (state.reminderInjectedThisCycle)
44
+ return { markDue: false };
45
+ if (!hasTasks)
46
+ return { markDue: false };
47
+ state.reminderDue = true;
48
+ return { markDue: true };
49
+ }
50
+ /**
51
+ * Drain the pending reminder when `context` fires. Returns true if the
52
+ * caller should inject the reminder into the upcoming LLM call's messages.
53
+ */
54
+ export function drainReminderForContext(state) {
55
+ if (!state.reminderDue)
56
+ return false;
57
+ state.reminderDue = false;
58
+ state.reminderInjectedThisCycle = true;
59
+ state.lastTaskToolUseTurn = state.currentTurn;
60
+ return true;
61
+ }
@@ -0,0 +1,48 @@
1
+ /**
2
+ * task-glyphs.ts — The glyphs the task widget and the /tasks menu are drawn with.
3
+ *
4
+ * Glyphs are pure data — there is deliberately no executable config file, because
5
+ * `.pi/` lives inside cloned repositories. A hand-edited config must never break
6
+ * the widget, so anything unrecognised falls back to the built-in glyph.
7
+ */
8
+ /** A fully resolved glyph set — what the render sites consume. */
9
+ export interface TaskGlyphs {
10
+ /** Completed task rows, in the widget and the /tasks list. */
11
+ completed: string;
12
+ /** In-progress rows that are not being executed right now. */
13
+ inProgress: string;
14
+ /** Rows not started yet. */
15
+ pending: string;
16
+ /** Frames for the actively-executing row, one per widget tick. */
17
+ spinner: readonly string[];
18
+ /** The `N completed` line that `collapseCompleted` puts in place of the rows. */
19
+ completedSummary: string;
20
+ /** The bullet on the widget's summary line. */
21
+ header: string;
22
+ /** The `and N more` line standing in for rows the visible limit hid. */
23
+ overflow: string;
24
+ /** Introduces the `blocked by #1, #2` suffix on a blocked row. */
25
+ blocked: string;
26
+ /** Precedes the input token count on the active row. */
27
+ inputTokens: string;
28
+ /** Precedes the output token count on the active row. */
29
+ outputTokens: string;
30
+ /** Between elapsed time and token counts: `(2m 49s · ↑ 4.1k)`. */
31
+ statsSeparator: string;
32
+ /** Closes the active row's text, marking the action as still running. */
33
+ trailingEllipsis: string;
34
+ /** Marks a line clipped at the terminal's right edge. */
35
+ truncation: string;
36
+ }
37
+ /** Glyphs as written in `tasks-config.json`: every resolved glyph, all optional.
38
+ * Derived rather than restated, so a glyph cannot be added to one list and
39
+ * forgotten in the other. `spinner` is respelled because the resolved form is
40
+ * readonly while JSON hands us a plain array. */
41
+ export type TaskGlyphsConfig = Partial<Omit<TaskGlyphs, "spinner">> & {
42
+ spinner?: string[];
43
+ };
44
+ /** Resolve configured glyphs against the defaults. Never throws and never rejects
45
+ * loudly: config files are hand-edited, and a malformed one must not break the
46
+ * widget. Each glyph falls back on its own; the spinner falls back as a whole,
47
+ * because half a frame sequence is not an animation. */
48
+ export declare function resolveTaskGlyphs(glyphs: TaskGlyphsConfig | undefined): TaskGlyphs;
@@ -0,0 +1,68 @@
1
+ /**
2
+ * task-glyphs.ts — The glyphs the task widget and the /tasks menu are drawn with.
3
+ *
4
+ * Glyphs are pure data — there is deliberately no executable config file, because
5
+ * `.pi/` lives inside cloned repositories. A hand-edited config must never break
6
+ * the widget, so anything unrecognised falls back to the built-in glyph.
7
+ */
8
+ /** Every glyph's built-in default. `completedSummary` is deliberately absent: it has
9
+ * no literal of its own and inherits whatever `completed` resolves to.
10
+ *
11
+ * The spinner walks the dingbat block. Claude Code's own spinner is a shorter
12
+ * mirrored sequence (`· ✢ ✳ ✶ ✻ ✽` and its reverse, with a ghostty variant);
13
+ * this one is deliberately ours.
14
+ *
15
+ * `truncation` is three ASCII dots rather than `…` because that is pi-tui's own
16
+ * default, and the widget has always clipped with it. */
17
+ const DEFAULT_GLYPHS = {
18
+ completed: "✔",
19
+ inProgress: "◼",
20
+ pending: "◻",
21
+ spinner: ["✳", "✴", "✵", "✶", "✷", "✸", "✹", "✺", "✻", "✼", "✽"],
22
+ header: "●",
23
+ overflow: "…",
24
+ blocked: "›",
25
+ inputTokens: "↑",
26
+ outputTokens: "↓",
27
+ statsSeparator: "·",
28
+ trailingEllipsis: "…",
29
+ truncation: "...",
30
+ };
31
+ /** Control characters would break the widget's one-line-per-entry contract or steer
32
+ * the terminal itself (a glyph carrying `ESC ]0;…` retitles the window), and bidi
33
+ * overrides reorder the line around the glyph. A `tasks-config.json` that arrived
34
+ * with a cloned repository must not be able to do either. */
35
+ const UNSAFE_GLYPH = /[\p{Cc}\u200E\u200F\u202A-\u202E\u2066-\u2069]/u;
36
+ /** A glyph may be any non-empty string, not just one character — `[x]`, `⣾⣾` and an
37
+ * emoji with a variation selector are all valid, as glyphs and as spinner frames. */
38
+ const isGlyph = (value) => typeof value === "string" && value.length > 0 && !UNSAFE_GLYPH.test(value);
39
+ function isSpinner(value) {
40
+ return Array.isArray(value) && value.length > 0 && value.every(isGlyph);
41
+ }
42
+ /** Resolve configured glyphs against the defaults. Never throws and never rejects
43
+ * loudly: config files are hand-edited, and a malformed one must not break the
44
+ * widget. Each glyph falls back on its own; the spinner falls back as a whole,
45
+ * because half a frame sequence is not an animation. */
46
+ export function resolveTaskGlyphs(glyphs) {
47
+ const glyph = (value, fallback) => isGlyph(value) ? value : fallback;
48
+ const completed = glyph(glyphs?.completed, DEFAULT_GLYPHS.completed);
49
+ const spinner = glyphs?.spinner;
50
+ return {
51
+ completed,
52
+ inProgress: glyph(glyphs?.inProgress, DEFAULT_GLYPHS.inProgress),
53
+ pending: glyph(glyphs?.pending, DEFAULT_GLYPHS.pending),
54
+ spinner: isSpinner(spinner) ? spinner : DEFAULT_GLYPHS.spinner,
55
+ // Falls back to the resolved `completed` rather than to a literal of its own:
56
+ // a config that sets only `completed` should not leave the line that stands in
57
+ // for those rows marked with a different glyph.
58
+ completedSummary: glyph(glyphs?.completedSummary, completed),
59
+ header: glyph(glyphs?.header, DEFAULT_GLYPHS.header),
60
+ overflow: glyph(glyphs?.overflow, DEFAULT_GLYPHS.overflow),
61
+ blocked: glyph(glyphs?.blocked, DEFAULT_GLYPHS.blocked),
62
+ inputTokens: glyph(glyphs?.inputTokens, DEFAULT_GLYPHS.inputTokens),
63
+ outputTokens: glyph(glyphs?.outputTokens, DEFAULT_GLYPHS.outputTokens),
64
+ statsSeparator: glyph(glyphs?.statsSeparator, DEFAULT_GLYPHS.statsSeparator),
65
+ trailingEllipsis: glyph(glyphs?.trailingEllipsis, DEFAULT_GLYPHS.trailingEllipsis),
66
+ truncation: glyph(glyphs?.truncation, DEFAULT_GLYPHS.truncation),
67
+ };
68
+ }
@@ -0,0 +1,44 @@
1
+ /**
2
+ * task-paths.ts — Where session task files live.
3
+ *
4
+ * `session` scope keeps them in the workspace, as it always has. `session-global`
5
+ * keeps them under pi's agent directory instead, beside pi's own per-workspace
6
+ * session logs, for people who would rather their repositories stayed clean.
7
+ *
8
+ * The choice only ever decides where a *new* file is created. A session already
9
+ * holding a file in the workspace keeps using it under either setting, so opting
10
+ * in moves nothing and opting back out strands nothing.
11
+ */
12
+ import type { TasksConfig } from "./tasks-config.js";
13
+ type TaskScope = NonNullable<TasksConfig["taskScope"]>;
14
+ /**
15
+ * Directory name standing for one workspace.
16
+ *
17
+ * Mirrors the encoding pi uses for its own session logs
18
+ * (`<agent-dir>/sessions/--Users-me-work-repo--/<timestamp>_<id>.jsonl`), so a
19
+ * workspace's task files are named the same way as its transcripts and can be
20
+ * found by eye.
21
+ */
22
+ export declare function projectKey(cwd: string): string;
23
+ /** Where `session-global` collects one workspace's session files.
24
+ * Resolved per call, never captured: `getAgentDir()` reads the environment. */
25
+ export declare function globalSessionTasksDir(cwd: string): string;
26
+ /** The in-workspace location, unchanged since session scope was introduced. */
27
+ export declare function workspaceSessionTaskFile(cwd: string, sessionId: string): string;
28
+ /**
29
+ * File backing one persisted session.
30
+ *
31
+ * Under `session-global` the workspace is still consulted first: a session that
32
+ * already has a file there is still that file's session, and reading it is the
33
+ * whole reason no migration is needed.
34
+ */
35
+ export declare function sessionTaskFile(cwd: string, sessionId: string, scope: TaskScope): string;
36
+ /**
37
+ * Remove a workspace's global session directory once it holds nothing.
38
+ *
39
+ * Only the global tree is ever reclaimed. `<workspace>/.pi/tasks/` is left alone
40
+ * even when it empties, because that is what every release so far has done and
41
+ * `.pi/` holds project config that is not ours.
42
+ */
43
+ export declare function reclaimGlobalSessionTasksDir(cwd: string): void;
44
+ export {};
@@ -0,0 +1,60 @@
1
+ /**
2
+ * task-paths.ts — Where session task files live.
3
+ *
4
+ * `session` scope keeps them in the workspace, as it always has. `session-global`
5
+ * keeps them under pi's agent directory instead, beside pi's own per-workspace
6
+ * session logs, for people who would rather their repositories stayed clean.
7
+ *
8
+ * The choice only ever decides where a *new* file is created. A session already
9
+ * holding a file in the workspace keeps using it under either setting, so opting
10
+ * in moves nothing and opting back out strands nothing.
11
+ */
12
+ import { existsSync, rmdirSync } from "node:fs";
13
+ import { join, resolve } from "node:path";
14
+ import { getAgentDir } from "@earendil-works/pi-coding-agent";
15
+ /**
16
+ * Directory name standing for one workspace.
17
+ *
18
+ * Mirrors the encoding pi uses for its own session logs
19
+ * (`<agent-dir>/sessions/--Users-me-work-repo--/<timestamp>_<id>.jsonl`), so a
20
+ * workspace's task files are named the same way as its transcripts and can be
21
+ * found by eye.
22
+ */
23
+ export function projectKey(cwd) {
24
+ return `--${resolve(cwd).replace(/^[/\\]/, "").replace(/[/\\:]/g, "-")}--`;
25
+ }
26
+ /** Where `session-global` collects one workspace's session files.
27
+ * Resolved per call, never captured: `getAgentDir()` reads the environment. */
28
+ export function globalSessionTasksDir(cwd) {
29
+ return join(getAgentDir(), "tasks", "sessions", projectKey(cwd));
30
+ }
31
+ /** The in-workspace location, unchanged since session scope was introduced. */
32
+ export function workspaceSessionTaskFile(cwd, sessionId) {
33
+ return join(cwd, ".pi", "tasks", `tasks-${sessionId}.json`);
34
+ }
35
+ /**
36
+ * File backing one persisted session.
37
+ *
38
+ * Under `session-global` the workspace is still consulted first: a session that
39
+ * already has a file there is still that file's session, and reading it is the
40
+ * whole reason no migration is needed.
41
+ */
42
+ export function sessionTaskFile(cwd, sessionId, scope) {
43
+ const inWorkspace = workspaceSessionTaskFile(cwd, sessionId);
44
+ if (scope !== "session-global")
45
+ return inWorkspace;
46
+ return existsSync(inWorkspace) ? inWorkspace : join(globalSessionTasksDir(cwd), `tasks-${sessionId}.json`);
47
+ }
48
+ /**
49
+ * Remove a workspace's global session directory once it holds nothing.
50
+ *
51
+ * Only the global tree is ever reclaimed. `<workspace>/.pi/tasks/` is left alone
52
+ * even when it empties, because that is what every release so far has done and
53
+ * `.pi/` holds project config that is not ours.
54
+ */
55
+ export function reclaimGlobalSessionTasksDir(cwd) {
56
+ try {
57
+ rmdirSync(globalSessionTasksDir(cwd));
58
+ }
59
+ catch { /* other sessions still stored */ }
60
+ }
@@ -0,0 +1,23 @@
1
+ /**
2
+ * task-sort.ts — Task ordering for the widget.
3
+ *
4
+ * `sortOrder` is either a built-in preset name or a sort spec: an ordered list of
5
+ * comparison keys. Specs are pure data — there is deliberately no executable config
6
+ * file, because `.pi/` lives inside cloned repositories.
7
+ */
8
+ import type { Task, TaskStatus } from "./types.js";
9
+ export type SortField = "id" | "status" | "updatedAt";
10
+ export type SortDirection = "asc" | "desc";
11
+ export interface SortKey {
12
+ field: SortField;
13
+ /** Default "asc". Reverses this key only, status rank included. */
14
+ direction?: SortDirection;
15
+ /** `status` only. Statuses left out of the rank sort last and tie. */
16
+ rank?: TaskStatus[];
17
+ }
18
+ export type SortSpec = SortKey[];
19
+ export type BuiltInSortOrder = "id" | "status" | "active" | "recent" | "oldest";
20
+ export type TaskSortOrder = BuiltInSortOrder | SortSpec;
21
+ export declare const BUILT_IN_SORT_ORDERS: BuiltInSortOrder[];
22
+ /** Return a sorted copy, leaving the input untouched. */
23
+ export declare function sortTasks(tasks: readonly Task[], order?: TaskSortOrder): Task[];
@@ -0,0 +1,69 @@
1
+ /**
2
+ * task-sort.ts — Task ordering for the widget.
3
+ *
4
+ * `sortOrder` is either a built-in preset name or a sort spec: an ordered list of
5
+ * comparison keys. Specs are pure data — there is deliberately no executable config
6
+ * file, because `.pi/` lives inside cloned repositories.
7
+ */
8
+ const SORT_FIELDS = ["id", "status", "updatedAt"];
9
+ const STATUSES = ["pending", "in_progress", "completed"];
10
+ /** Also used when a status key omits `rank`. */
11
+ const DEFAULT_STATUS_RANK = ["completed", "in_progress", "pending"];
12
+ /** Built-in presets, expressed as specs. All but `active` reproduce the original
13
+ * comparators exactly, tie-breaks included. */
14
+ const PRESETS = {
15
+ id: [{ field: "id" }],
16
+ status: [{ field: "status", rank: DEFAULT_STATUS_RANK }, { field: "id" }],
17
+ active: [{ field: "status", rank: ["in_progress", "pending", "completed"] }, { field: "id" }],
18
+ recent: [{ field: "updatedAt", direction: "desc" }, { field: "id", direction: "desc" }],
19
+ oldest: [{ field: "updatedAt" }, { field: "id" }],
20
+ };
21
+ export const BUILT_IN_SORT_ORDERS = Object.keys(PRESETS);
22
+ function isSortKey(value) {
23
+ if (value === null || typeof value !== "object" || Array.isArray(value))
24
+ return false;
25
+ const { field, direction, rank } = value;
26
+ if (!SORT_FIELDS.includes(field))
27
+ return false;
28
+ if (direction !== undefined && direction !== "asc" && direction !== "desc")
29
+ return false;
30
+ if (rank !== undefined && (!Array.isArray(rank) || !rank.every(s => STATUSES.includes(s))))
31
+ return false;
32
+ return true;
33
+ }
34
+ /** Resolve a configured order to a spec. Never throws and never rejects loudly:
35
+ * config files are hand-edited, and a malformed one must not break the widget. */
36
+ function toSpec(order) {
37
+ if (typeof order === "string") {
38
+ // hasOwn, not `in` — "toString" is on the prototype chain.
39
+ return Object.hasOwn(PRESETS, order) ? PRESETS[order] : PRESETS.id;
40
+ }
41
+ if (Array.isArray(order) && order.length > 0 && order.every(isSortKey))
42
+ return order;
43
+ return PRESETS.id;
44
+ }
45
+ function statusIndex(status, rank) {
46
+ const index = rank.indexOf(status);
47
+ return index === -1 ? rank.length : index;
48
+ }
49
+ function compareKey(a, b, key) {
50
+ if (key.field === "status") {
51
+ const rank = key.rank ?? DEFAULT_STATUS_RANK;
52
+ return statusIndex(a.status, rank) - statusIndex(b.status, rank);
53
+ }
54
+ return key.field === "id" ? Number(a.id) - Number(b.id) : a.updatedAt - b.updatedAt;
55
+ }
56
+ function buildComparator(spec) {
57
+ return (a, b) => {
58
+ for (const key of spec) {
59
+ const delta = compareKey(a, b, key);
60
+ if (delta !== 0)
61
+ return key.direction === "desc" ? -delta : delta;
62
+ }
63
+ return 0;
64
+ };
65
+ }
66
+ /** Return a sorted copy, leaving the input untouched. */
67
+ export function sortTasks(tasks, order = "id") {
68
+ return [...tasks].sort(buildComparator(toSpec(order)));
69
+ }
@@ -0,0 +1,61 @@
1
+ /**
2
+ * task-store.ts — File-backed task store with CRUD, dependency management, and file locking.
3
+ *
4
+ * Session-scoped (default): in-memory Map — no disk I/O.
5
+ * Shared (PI_TASK_LIST_ID set): ~/.pi/tasks/<listId>.json with file locking.
6
+ */
7
+ import { type TaskSortOrder } from "./task-sort.js";
8
+ import type { Task, TaskStatus, TaskStoreData } from "./types.js";
9
+ export declare class TaskStore {
10
+ private filePath;
11
+ private lockPath;
12
+ private nextId;
13
+ private tasks;
14
+ constructor(listIdOrPath?: string);
15
+ /**
16
+ * Read store from disk (file-backed mode only).
17
+ *
18
+ * `normalizeTask` hardens each record; this hardens the envelope around them.
19
+ * A truncated write, a bad merge or a hand edit can leave a file that parses
20
+ * but has no `tasks` array or no usable `nextId`, and both used to corrupt the
21
+ * store: the missing array threw mid-load and left it wiped, and the missing
22
+ * counter produced the task ID "NaN", then IDs restarting at "0" and colliding
23
+ * with live tasks. Anything unusable now leaves the current state alone.
24
+ */
25
+ private load;
26
+ /** Write store to disk atomically (file-backed mode only). */
27
+ private save;
28
+ /** Execute a mutation with file locking (if file-backed). */
29
+ private withLock;
30
+ create(subject: string, description: string, activeForm?: string, metadata?: Record<string, any>): Task;
31
+ get(id: string): Task | undefined;
32
+ /** List all tasks, sorted by the given order (defaults to ID ascending). */
33
+ list(sortOrder?: TaskSortOrder): Task[];
34
+ update(id: string, fields: {
35
+ status?: TaskStatus | "deleted";
36
+ subject?: string;
37
+ description?: string;
38
+ activeForm?: string;
39
+ owner?: string;
40
+ metadata?: Record<string, any>;
41
+ addBlocks?: string[];
42
+ addBlockedBy?: string[];
43
+ }): {
44
+ task: Task | undefined;
45
+ changedFields: string[];
46
+ warnings: string[];
47
+ };
48
+ /** Delete a task by ID. Returns true if deleted. */
49
+ delete(id: string): boolean;
50
+ /** Remove all tasks. */
51
+ clearAll(): number;
52
+ /** Capture full store state — used to carry tasks into a forked session. */
53
+ snapshot(): TaskStoreData;
54
+ /** Seed an empty store from a snapshot. No-op if the store already has tasks,
55
+ * so re-pointing to an already-seeded fork file never duplicates. */
56
+ seed(data: TaskStoreData): void;
57
+ /** Delete the backing file (if file-backed and empty). */
58
+ deleteFileIfEmpty(): boolean;
59
+ /** Remove all completed tasks. */
60
+ clearCompleted(): number;
61
+ }