@blxzer/pactile 0.5.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 (903) hide show
  1. package/CHANGELOG.md +602 -0
  2. package/LICENSE +235 -0
  3. package/README.md +115 -0
  4. package/README.zh-CN.md +115 -0
  5. package/bin/compat-warning.js +11 -0
  6. package/bin/cstl.js +6 -0
  7. package/bin/pactile.js +3 -0
  8. package/bin/smart-search.js +38 -0
  9. package/dist/cli/index.d.ts +3 -0
  10. package/dist/cli/index.d.ts.map +1 -0
  11. package/dist/cli/index.js +362 -0
  12. package/dist/cli/index.js.map +1 -0
  13. package/dist/commands/capability-smoke.d.ts +24 -0
  14. package/dist/commands/capability-smoke.d.ts.map +1 -0
  15. package/dist/commands/capability-smoke.js +83 -0
  16. package/dist/commands/capability-smoke.js.map +1 -0
  17. package/dist/commands/channel/adapters/claude.d.ts +29 -0
  18. package/dist/commands/channel/adapters/claude.d.ts.map +1 -0
  19. package/dist/commands/channel/adapters/claude.js +203 -0
  20. package/dist/commands/channel/adapters/claude.js.map +1 -0
  21. package/dist/commands/channel/adapters/codex.d.ts +85 -0
  22. package/dist/commands/channel/adapters/codex.d.ts.map +1 -0
  23. package/dist/commands/channel/adapters/codex.js +505 -0
  24. package/dist/commands/channel/adapters/codex.js.map +1 -0
  25. package/dist/commands/channel/adapters/index.d.ts +84 -0
  26. package/dist/commands/channel/adapters/index.d.ts.map +1 -0
  27. package/dist/commands/channel/adapters/index.js +115 -0
  28. package/dist/commands/channel/adapters/index.js.map +1 -0
  29. package/dist/commands/channel/adapters/types.d.ts +33 -0
  30. package/dist/commands/channel/adapters/types.d.ts.map +1 -0
  31. package/dist/commands/channel/adapters/types.js +2 -0
  32. package/dist/commands/channel/adapters/types.js.map +1 -0
  33. package/dist/commands/channel/agent-loader.d.ts +32 -0
  34. package/dist/commands/channel/agent-loader.d.ts.map +1 -0
  35. package/dist/commands/channel/agent-loader.js +154 -0
  36. package/dist/commands/channel/agent-loader.js.map +1 -0
  37. package/dist/commands/channel/context-loader.d.ts +26 -0
  38. package/dist/commands/channel/context-loader.d.ts.map +1 -0
  39. package/dist/commands/channel/context-loader.js +290 -0
  40. package/dist/commands/channel/context-loader.js.map +1 -0
  41. package/dist/commands/channel/context.d.ts +16 -0
  42. package/dist/commands/channel/context.d.ts.map +1 -0
  43. package/dist/commands/channel/context.js +83 -0
  44. package/dist/commands/channel/context.js.map +1 -0
  45. package/dist/commands/channel/create.d.ts +27 -0
  46. package/dist/commands/channel/create.d.ts.map +1 -0
  47. package/dist/commands/channel/create.js +39 -0
  48. package/dist/commands/channel/create.js.map +1 -0
  49. package/dist/commands/channel/dev-parse-trace.d.ts +14 -0
  50. package/dist/commands/channel/dev-parse-trace.d.ts.map +1 -0
  51. package/dist/commands/channel/dev-parse-trace.js +70 -0
  52. package/dist/commands/channel/dev-parse-trace.js.map +1 -0
  53. package/dist/commands/channel/guard.d.ts +150 -0
  54. package/dist/commands/channel/guard.d.ts.map +1 -0
  55. package/dist/commands/channel/guard.js +475 -0
  56. package/dist/commands/channel/guard.js.map +1 -0
  57. package/dist/commands/channel/index.d.ts +3 -0
  58. package/dist/commands/channel/index.d.ts.map +1 -0
  59. package/dist/commands/channel/index.js +531 -0
  60. package/dist/commands/channel/index.js.map +1 -0
  61. package/dist/commands/channel/interrupt.d.ts +10 -0
  62. package/dist/commands/channel/interrupt.d.ts.map +1 -0
  63. package/dist/commands/channel/interrupt.js +22 -0
  64. package/dist/commands/channel/interrupt.js.map +1 -0
  65. package/dist/commands/channel/kill.d.ts +7 -0
  66. package/dist/commands/channel/kill.d.ts.map +1 -0
  67. package/dist/commands/channel/kill.js +121 -0
  68. package/dist/commands/channel/kill.js.map +1 -0
  69. package/dist/commands/channel/list.d.ts +17 -0
  70. package/dist/commands/channel/list.d.ts.map +1 -0
  71. package/dist/commands/channel/list.js +233 -0
  72. package/dist/commands/channel/list.js.map +1 -0
  73. package/dist/commands/channel/messages.d.ts +15 -0
  74. package/dist/commands/channel/messages.d.ts.map +1 -0
  75. package/dist/commands/channel/messages.js +245 -0
  76. package/dist/commands/channel/messages.js.map +1 -0
  77. package/dist/commands/channel/rm.d.ts +27 -0
  78. package/dist/commands/channel/rm.d.ts.map +1 -0
  79. package/dist/commands/channel/rm.js +216 -0
  80. package/dist/commands/channel/rm.js.map +1 -0
  81. package/dist/commands/channel/run.d.ts +30 -0
  82. package/dist/commands/channel/run.d.ts.map +1 -0
  83. package/dist/commands/channel/run.js +130 -0
  84. package/dist/commands/channel/run.js.map +1 -0
  85. package/dist/commands/channel/send.d.ts +11 -0
  86. package/dist/commands/channel/send.d.ts.map +1 -0
  87. package/dist/commands/channel/send.js +24 -0
  88. package/dist/commands/channel/send.js.map +1 -0
  89. package/dist/commands/channel/spawn.d.ts +40 -0
  90. package/dist/commands/channel/spawn.d.ts.map +1 -0
  91. package/dist/commands/channel/spawn.js +242 -0
  92. package/dist/commands/channel/spawn.js.map +1 -0
  93. package/dist/commands/channel/store/events.d.ts +39 -0
  94. package/dist/commands/channel/store/events.d.ts.map +1 -0
  95. package/dist/commands/channel/store/events.js +87 -0
  96. package/dist/commands/channel/store/events.js.map +1 -0
  97. package/dist/commands/channel/store/filter.d.ts +3 -0
  98. package/dist/commands/channel/store/filter.d.ts.map +1 -0
  99. package/dist/commands/channel/store/filter.js +2 -0
  100. package/dist/commands/channel/store/filter.js.map +1 -0
  101. package/dist/commands/channel/store/lock.d.ts +23 -0
  102. package/dist/commands/channel/store/lock.d.ts.map +1 -0
  103. package/dist/commands/channel/store/lock.js +99 -0
  104. package/dist/commands/channel/store/lock.js.map +1 -0
  105. package/dist/commands/channel/store/paths.d.ts +63 -0
  106. package/dist/commands/channel/store/paths.d.ts.map +1 -0
  107. package/dist/commands/channel/store/paths.js +247 -0
  108. package/dist/commands/channel/store/paths.js.map +1 -0
  109. package/dist/commands/channel/store/schema.d.ts +27 -0
  110. package/dist/commands/channel/store/schema.d.ts.map +1 -0
  111. package/dist/commands/channel/store/schema.js +34 -0
  112. package/dist/commands/channel/store/schema.js.map +1 -0
  113. package/dist/commands/channel/store/thread-state.d.ts +5 -0
  114. package/dist/commands/channel/store/thread-state.d.ts.map +1 -0
  115. package/dist/commands/channel/store/thread-state.js +16 -0
  116. package/dist/commands/channel/store/thread-state.js.map +1 -0
  117. package/dist/commands/channel/store/watch.d.ts +19 -0
  118. package/dist/commands/channel/store/watch.d.ts.map +1 -0
  119. package/dist/commands/channel/store/watch.js +146 -0
  120. package/dist/commands/channel/store/watch.js.map +1 -0
  121. package/dist/commands/channel/supervisor/idle.d.ts +46 -0
  122. package/dist/commands/channel/supervisor/idle.d.ts.map +1 -0
  123. package/dist/commands/channel/supervisor/idle.js +72 -0
  124. package/dist/commands/channel/supervisor/idle.js.map +1 -0
  125. package/dist/commands/channel/supervisor/inbox.d.ts +30 -0
  126. package/dist/commands/channel/supervisor/inbox.d.ts.map +1 -0
  127. package/dist/commands/channel/supervisor/inbox.js +160 -0
  128. package/dist/commands/channel/supervisor/inbox.js.map +1 -0
  129. package/dist/commands/channel/supervisor/shutdown.d.ts +68 -0
  130. package/dist/commands/channel/supervisor/shutdown.d.ts.map +1 -0
  131. package/dist/commands/channel/supervisor/shutdown.js +146 -0
  132. package/dist/commands/channel/supervisor/shutdown.js.map +1 -0
  133. package/dist/commands/channel/supervisor/stdout.d.ts +51 -0
  134. package/dist/commands/channel/supervisor/stdout.d.ts.map +1 -0
  135. package/dist/commands/channel/supervisor/stdout.js +121 -0
  136. package/dist/commands/channel/supervisor/stdout.js.map +1 -0
  137. package/dist/commands/channel/supervisor/turns.d.ts +31 -0
  138. package/dist/commands/channel/supervisor/turns.d.ts.map +1 -0
  139. package/dist/commands/channel/supervisor/turns.js +45 -0
  140. package/dist/commands/channel/supervisor/turns.js.map +1 -0
  141. package/dist/commands/channel/supervisor/warning.d.ts +48 -0
  142. package/dist/commands/channel/supervisor/warning.d.ts.map +1 -0
  143. package/dist/commands/channel/supervisor/warning.js +77 -0
  144. package/dist/commands/channel/supervisor/warning.js.map +1 -0
  145. package/dist/commands/channel/supervisor.d.ts +59 -0
  146. package/dist/commands/channel/supervisor.d.ts.map +1 -0
  147. package/dist/commands/channel/supervisor.js +345 -0
  148. package/dist/commands/channel/supervisor.js.map +1 -0
  149. package/dist/commands/channel/text-body.d.ts +13 -0
  150. package/dist/commands/channel/text-body.d.ts.map +1 -0
  151. package/dist/commands/channel/text-body.js +47 -0
  152. package/dist/commands/channel/text-body.js.map +1 -0
  153. package/dist/commands/channel/threads.d.ts +39 -0
  154. package/dist/commands/channel/threads.d.ts.map +1 -0
  155. package/dist/commands/channel/threads.js +106 -0
  156. package/dist/commands/channel/threads.js.map +1 -0
  157. package/dist/commands/channel/title.d.ts +12 -0
  158. package/dist/commands/channel/title.d.ts.map +1 -0
  159. package/dist/commands/channel/title.js +24 -0
  160. package/dist/commands/channel/title.js.map +1 -0
  161. package/dist/commands/channel/wait.d.ts +17 -0
  162. package/dist/commands/channel/wait.d.ts.map +1 -0
  163. package/dist/commands/channel/wait.js +75 -0
  164. package/dist/commands/channel/wait.js.map +1 -0
  165. package/dist/commands/detach.d.ts +7 -0
  166. package/dist/commands/detach.d.ts.map +1 -0
  167. package/dist/commands/detach.js +31 -0
  168. package/dist/commands/detach.js.map +1 -0
  169. package/dist/commands/init.d.ts +51 -0
  170. package/dist/commands/init.d.ts.map +1 -0
  171. package/dist/commands/init.js +1660 -0
  172. package/dist/commands/init.js.map +1 -0
  173. package/dist/commands/migrate.d.ts +10 -0
  174. package/dist/commands/migrate.d.ts.map +1 -0
  175. package/dist/commands/migrate.js +38 -0
  176. package/dist/commands/migrate.js.map +1 -0
  177. package/dist/commands/purge.d.ts +9 -0
  178. package/dist/commands/purge.d.ts.map +1 -0
  179. package/dist/commands/purge.js +29 -0
  180. package/dist/commands/purge.js.map +1 -0
  181. package/dist/commands/rollback.d.ts +7 -0
  182. package/dist/commands/rollback.d.ts.map +1 -0
  183. package/dist/commands/rollback.js +27 -0
  184. package/dist/commands/rollback.js.map +1 -0
  185. package/dist/commands/rollout.d.ts +34 -0
  186. package/dist/commands/rollout.d.ts.map +1 -0
  187. package/dist/commands/rollout.js +102 -0
  188. package/dist/commands/rollout.js.map +1 -0
  189. package/dist/commands/uninstall.d.ts +23 -0
  190. package/dist/commands/uninstall.d.ts.map +1 -0
  191. package/dist/commands/uninstall.js +68 -0
  192. package/dist/commands/uninstall.js.map +1 -0
  193. package/dist/commands/update.d.ts +139 -0
  194. package/dist/commands/update.d.ts.map +1 -0
  195. package/dist/commands/update.js +2459 -0
  196. package/dist/commands/update.js.map +1 -0
  197. package/dist/commands/upgrade.d.ts +28 -0
  198. package/dist/commands/upgrade.d.ts.map +1 -0
  199. package/dist/commands/upgrade.js +84 -0
  200. package/dist/commands/upgrade.js.map +1 -0
  201. package/dist/commands/validate-rules.d.ts +6 -0
  202. package/dist/commands/validate-rules.d.ts.map +1 -0
  203. package/dist/commands/validate-rules.js +33 -0
  204. package/dist/commands/validate-rules.js.map +1 -0
  205. package/dist/commands/workflow.d.ts +35 -0
  206. package/dist/commands/workflow.d.ts.map +1 -0
  207. package/dist/commands/workflow.js +220 -0
  208. package/dist/commands/workflow.js.map +1 -0
  209. package/dist/configurators/cursor.d.ts +21 -0
  210. package/dist/configurators/cursor.d.ts.map +1 -0
  211. package/dist/configurators/cursor.js +51 -0
  212. package/dist/configurators/cursor.js.map +1 -0
  213. package/dist/configurators/index.d.ts +68 -0
  214. package/dist/configurators/index.d.ts.map +1 -0
  215. package/dist/configurators/index.js +170 -0
  216. package/dist/configurators/index.js.map +1 -0
  217. package/dist/configurators/shared.d.ts +200 -0
  218. package/dist/configurators/shared.d.ts.map +1 -0
  219. package/dist/configurators/shared.js +602 -0
  220. package/dist/configurators/shared.js.map +1 -0
  221. package/dist/configurators/workflow.d.ts +45 -0
  222. package/dist/configurators/workflow.d.ts.map +1 -0
  223. package/dist/configurators/workflow.js +256 -0
  224. package/dist/configurators/workflow.js.map +1 -0
  225. package/dist/constants/paths.d.ts +93 -0
  226. package/dist/constants/paths.d.ts.map +1 -0
  227. package/dist/constants/paths.js +106 -0
  228. package/dist/constants/paths.js.map +1 -0
  229. package/dist/constants/version.d.ts +9 -0
  230. package/dist/constants/version.d.ts.map +1 -0
  231. package/dist/constants/version.js +15 -0
  232. package/dist/constants/version.js.map +1 -0
  233. package/dist/index.d.ts +10 -0
  234. package/dist/index.d.ts.map +1 -0
  235. package/dist/index.js +10 -0
  236. package/dist/index.js.map +1 -0
  237. package/dist/migrations/index.d.ts +62 -0
  238. package/dist/migrations/index.d.ts.map +1 -0
  239. package/dist/migrations/index.js +187 -0
  240. package/dist/migrations/index.js.map +1 -0
  241. package/dist/migrations/manifests/0.1.0.json +9 -0
  242. package/dist/migrations/manifests/0.1.1.json +9 -0
  243. package/dist/migrations/manifests/0.1.2.json +9 -0
  244. package/dist/migrations/manifests/0.1.3.json +9 -0
  245. package/dist/migrations/manifests/0.1.4.json +9 -0
  246. package/dist/migrations/manifests/0.2.1.json +9 -0
  247. package/dist/migrations/manifests/0.2.10.json +374 -0
  248. package/dist/migrations/manifests/0.2.2.json +9 -0
  249. package/dist/migrations/manifests/0.2.3.json +9 -0
  250. package/dist/migrations/manifests/0.2.4.json +9 -0
  251. package/dist/migrations/manifests/0.2.5.json +9 -0
  252. package/dist/migrations/manifests/0.2.6.json +9 -0
  253. package/dist/migrations/manifests/0.2.7.json +9 -0
  254. package/dist/migrations/manifests/0.2.8.json +9 -0
  255. package/dist/migrations/manifests/0.2.9.json +9 -0
  256. package/dist/migrations/manifests/0.3.0.json +89 -0
  257. package/dist/migrations/manifests/0.3.1.json +32 -0
  258. package/dist/migrations/manifests/0.3.2.json +16 -0
  259. package/dist/migrations/manifests/0.3.3.json +9 -0
  260. package/dist/migrations/manifests/0.3.4.json +9 -0
  261. package/dist/migrations/manifests/0.3.5.json +9 -0
  262. package/dist/migrations/manifests/0.3.6.json +9 -0
  263. package/dist/migrations/manifests/0.4.0.json +9 -0
  264. package/dist/migrations/manifests/0.4.1.json +9 -0
  265. package/dist/migrations/manifests/0.4.2.json +9 -0
  266. package/dist/migrations/manifests/0.4.3.json +9 -0
  267. package/dist/migrations/manifests/0.5.0-beta.0.json +9 -0
  268. package/dist/migrations/manifests/0.5.0-beta.1.json +9 -0
  269. package/dist/migrations/manifests/0.5.0-beta.2.json +9 -0
  270. package/dist/migrations/manifests/0.5.0-beta.3.json +9 -0
  271. package/dist/migrations/manifests/0.5.0-beta.4.json +9 -0
  272. package/dist/migrations/manifests/0.5.0-beta.5.json +9 -0
  273. package/dist/pactile/adapters/codex/index.d.ts +75 -0
  274. package/dist/pactile/adapters/codex/index.d.ts.map +1 -0
  275. package/dist/pactile/adapters/codex/index.js +269 -0
  276. package/dist/pactile/adapters/codex/index.js.map +1 -0
  277. package/dist/pactile/adapters/cursor/index.d.ts +60 -0
  278. package/dist/pactile/adapters/cursor/index.d.ts.map +1 -0
  279. package/dist/pactile/adapters/cursor/index.js +186 -0
  280. package/dist/pactile/adapters/cursor/index.js.map +1 -0
  281. package/dist/pactile/adapters/index.d.ts +4 -0
  282. package/dist/pactile/adapters/index.d.ts.map +1 -0
  283. package/dist/pactile/adapters/index.js +4 -0
  284. package/dist/pactile/adapters/index.js.map +1 -0
  285. package/dist/pactile/adoption/bindings.d.ts +20 -0
  286. package/dist/pactile/adoption/bindings.d.ts.map +1 -0
  287. package/dist/pactile/adoption/bindings.js +99 -0
  288. package/dist/pactile/adoption/bindings.js.map +1 -0
  289. package/dist/pactile/adoption/discovery.d.ts +8 -0
  290. package/dist/pactile/adoption/discovery.d.ts.map +1 -0
  291. package/dist/pactile/adoption/discovery.js +159 -0
  292. package/dist/pactile/adoption/discovery.js.map +1 -0
  293. package/dist/pactile/adoption/inventory.d.ts +28 -0
  294. package/dist/pactile/adoption/inventory.d.ts.map +1 -0
  295. package/dist/pactile/adoption/inventory.js +261 -0
  296. package/dist/pactile/adoption/inventory.js.map +1 -0
  297. package/dist/pactile/adoption/safety.d.ts +19 -0
  298. package/dist/pactile/adoption/safety.d.ts.map +1 -0
  299. package/dist/pactile/adoption/safety.js +88 -0
  300. package/dist/pactile/adoption/safety.js.map +1 -0
  301. package/dist/pactile/adoption/workflow.d.ts +31 -0
  302. package/dist/pactile/adoption/workflow.d.ts.map +1 -0
  303. package/dist/pactile/adoption/workflow.js +259 -0
  304. package/dist/pactile/adoption/workflow.js.map +1 -0
  305. package/dist/pactile/compat/cli-options.d.ts +9 -0
  306. package/dist/pactile/compat/cli-options.d.ts.map +1 -0
  307. package/dist/pactile/compat/cli-options.js +9 -0
  308. package/dist/pactile/compat/cli-options.js.map +1 -0
  309. package/dist/pactile/compat/init-context.d.ts +16 -0
  310. package/dist/pactile/compat/init-context.d.ts.map +1 -0
  311. package/dist/pactile/compat/init-context.js +87 -0
  312. package/dist/pactile/compat/init-context.js.map +1 -0
  313. package/dist/pactile/compat/legacy-migrations.d.ts +8 -0
  314. package/dist/pactile/compat/legacy-migrations.d.ts.map +1 -0
  315. package/dist/pactile/compat/legacy-migrations.js +17 -0
  316. package/dist/pactile/compat/legacy-migrations.js.map +1 -0
  317. package/dist/pactile/compat/retired-alternate-client.d.ts +42 -0
  318. package/dist/pactile/compat/retired-alternate-client.d.ts.map +1 -0
  319. package/dist/pactile/compat/retired-alternate-client.js +153 -0
  320. package/dist/pactile/compat/retired-alternate-client.js.map +1 -0
  321. package/dist/pactile/compat/update-residue.d.ts +4 -0
  322. package/dist/pactile/compat/update-residue.d.ts.map +1 -0
  323. package/dist/pactile/compat/update-residue.js +55 -0
  324. package/dist/pactile/compat/update-residue.js.map +1 -0
  325. package/dist/pactile/exit/index.d.ts +3 -0
  326. package/dist/pactile/exit/index.d.ts.map +1 -0
  327. package/dist/pactile/exit/index.js +3 -0
  328. package/dist/pactile/exit/index.js.map +1 -0
  329. package/dist/pactile/exit/receipt.d.ts +23 -0
  330. package/dist/pactile/exit/receipt.d.ts.map +1 -0
  331. package/dist/pactile/exit/receipt.js +64 -0
  332. package/dist/pactile/exit/receipt.js.map +1 -0
  333. package/dist/pactile/exit/service.d.ts +107 -0
  334. package/dist/pactile/exit/service.d.ts.map +1 -0
  335. package/dist/pactile/exit/service.js +774 -0
  336. package/dist/pactile/exit/service.js.map +1 -0
  337. package/dist/pactile/index.d.ts +26 -0
  338. package/dist/pactile/index.d.ts.map +1 -0
  339. package/dist/pactile/index.js +22 -0
  340. package/dist/pactile/index.js.map +1 -0
  341. package/dist/pactile/lifecycle/command-runner.d.ts +26 -0
  342. package/dist/pactile/lifecycle/command-runner.d.ts.map +1 -0
  343. package/dist/pactile/lifecycle/command-runner.js +129 -0
  344. package/dist/pactile/lifecycle/command-runner.js.map +1 -0
  345. package/dist/pactile/lifecycle/default-adapters.d.ts +5 -0
  346. package/dist/pactile/lifecycle/default-adapters.d.ts.map +1 -0
  347. package/dist/pactile/lifecycle/default-adapters.js +136 -0
  348. package/dist/pactile/lifecycle/default-adapters.js.map +1 -0
  349. package/dist/pactile/lifecycle/index.d.ts +6 -0
  350. package/dist/pactile/lifecycle/index.d.ts.map +1 -0
  351. package/dist/pactile/lifecycle/index.js +6 -0
  352. package/dist/pactile/lifecycle/index.js.map +1 -0
  353. package/dist/pactile/lifecycle/legacy-import.d.ts +16 -0
  354. package/dist/pactile/lifecycle/legacy-import.d.ts.map +1 -0
  355. package/dist/pactile/lifecycle/legacy-import.js +228 -0
  356. package/dist/pactile/lifecycle/legacy-import.js.map +1 -0
  357. package/dist/pactile/lifecycle/orchestrator.d.ts +109 -0
  358. package/dist/pactile/lifecycle/orchestrator.d.ts.map +1 -0
  359. package/dist/pactile/lifecycle/orchestrator.js +1030 -0
  360. package/dist/pactile/lifecycle/orchestrator.js.map +1 -0
  361. package/dist/pactile/lifecycle/project-files.d.ts +28 -0
  362. package/dist/pactile/lifecycle/project-files.d.ts.map +1 -0
  363. package/dist/pactile/lifecycle/project-files.js +297 -0
  364. package/dist/pactile/lifecycle/project-files.js.map +1 -0
  365. package/dist/pactile/middleware/index.d.ts +3 -0
  366. package/dist/pactile/middleware/index.d.ts.map +1 -0
  367. package/dist/pactile/middleware/index.js +2 -0
  368. package/dist/pactile/middleware/index.js.map +1 -0
  369. package/dist/pactile/middleware/manifest-loader.d.ts +22 -0
  370. package/dist/pactile/middleware/manifest-loader.d.ts.map +1 -0
  371. package/dist/pactile/middleware/manifest-loader.js +228 -0
  372. package/dist/pactile/middleware/manifest-loader.js.map +1 -0
  373. package/dist/pactile/migration/index.d.ts +2 -0
  374. package/dist/pactile/migration/index.d.ts.map +1 -0
  375. package/dist/pactile/migration/index.js +2 -0
  376. package/dist/pactile/migration/index.js.map +1 -0
  377. package/dist/pactile/migration/transaction.d.ts +54 -0
  378. package/dist/pactile/migration/transaction.d.ts.map +1 -0
  379. package/dist/pactile/migration/transaction.js +445 -0
  380. package/dist/pactile/migration/transaction.js.map +1 -0
  381. package/dist/pactile/projection/managed-block.d.ts +32 -0
  382. package/dist/pactile/projection/managed-block.d.ts.map +1 -0
  383. package/dist/pactile/projection/managed-block.js +78 -0
  384. package/dist/pactile/projection/managed-block.js.map +1 -0
  385. package/dist/pactile/projection/planner.d.ts +65 -0
  386. package/dist/pactile/projection/planner.d.ts.map +1 -0
  387. package/dist/pactile/projection/planner.js +349 -0
  388. package/dist/pactile/projection/planner.js.map +1 -0
  389. package/dist/pactile/projection/shared/index.d.ts +38 -0
  390. package/dist/pactile/projection/shared/index.d.ts.map +1 -0
  391. package/dist/pactile/projection/shared/index.js +186 -0
  392. package/dist/pactile/projection/shared/index.js.map +1 -0
  393. package/dist/pactile/projection/store.d.ts +72 -0
  394. package/dist/pactile/projection/store.d.ts.map +1 -0
  395. package/dist/pactile/projection/store.js +669 -0
  396. package/dist/pactile/projection/store.js.map +1 -0
  397. package/dist/pactile/projection/structured-merge.d.ts +11 -0
  398. package/dist/pactile/projection/structured-merge.d.ts.map +1 -0
  399. package/dist/pactile/projection/structured-merge.js +347 -0
  400. package/dist/pactile/projection/structured-merge.js.map +1 -0
  401. package/dist/pactile/providers/index.d.ts +3 -0
  402. package/dist/pactile/providers/index.d.ts.map +1 -0
  403. package/dist/pactile/providers/index.js +3 -0
  404. package/dist/pactile/providers/index.js.map +1 -0
  405. package/dist/pactile/providers/probes.d.ts +55 -0
  406. package/dist/pactile/providers/probes.d.ts.map +1 -0
  407. package/dist/pactile/providers/probes.js +164 -0
  408. package/dist/pactile/providers/probes.js.map +1 -0
  409. package/dist/pactile/registry.d.ts +64 -0
  410. package/dist/pactile/registry.d.ts.map +1 -0
  411. package/dist/pactile/registry.js +196 -0
  412. package/dist/pactile/registry.js.map +1 -0
  413. package/dist/pactile/retrieval/boundary.d.ts +18 -0
  414. package/dist/pactile/retrieval/boundary.d.ts.map +1 -0
  415. package/dist/pactile/retrieval/boundary.js +113 -0
  416. package/dist/pactile/retrieval/boundary.js.map +1 -0
  417. package/dist/pactile/retrieval/evidence.d.ts +9 -0
  418. package/dist/pactile/retrieval/evidence.d.ts.map +1 -0
  419. package/dist/pactile/retrieval/evidence.js +327 -0
  420. package/dist/pactile/retrieval/evidence.js.map +1 -0
  421. package/dist/pactile/retrieval/index.d.ts +4 -0
  422. package/dist/pactile/retrieval/index.d.ts.map +1 -0
  423. package/dist/pactile/retrieval/index.js +4 -0
  424. package/dist/pactile/retrieval/index.js.map +1 -0
  425. package/dist/pactile/retrieval/planner.d.ts +23 -0
  426. package/dist/pactile/retrieval/planner.d.ts.map +1 -0
  427. package/dist/pactile/retrieval/planner.js +702 -0
  428. package/dist/pactile/retrieval/planner.js.map +1 -0
  429. package/dist/pactile/retrieval/types.d.ts +108 -0
  430. package/dist/pactile/retrieval/types.d.ts.map +1 -0
  431. package/dist/pactile/retrieval/types.js +36 -0
  432. package/dist/pactile/retrieval/types.js.map +1 -0
  433. package/dist/pactile/runtime/case-fold.d.ts +2 -0
  434. package/dist/pactile/runtime/case-fold.d.ts.map +1 -0
  435. package/dist/pactile/runtime/case-fold.js +31 -0
  436. package/dist/pactile/runtime/case-fold.js.map +1 -0
  437. package/dist/pactile/runtime/index.d.ts +8 -0
  438. package/dist/pactile/runtime/index.d.ts.map +1 -0
  439. package/dist/pactile/runtime/index.js +5 -0
  440. package/dist/pactile/runtime/index.js.map +1 -0
  441. package/dist/pactile/runtime/json-api.d.ts +15 -0
  442. package/dist/pactile/runtime/json-api.d.ts.map +1 -0
  443. package/dist/pactile/runtime/json-api.js +68 -0
  444. package/dist/pactile/runtime/json-api.js.map +1 -0
  445. package/dist/pactile/runtime/paths.d.ts +59 -0
  446. package/dist/pactile/runtime/paths.d.ts.map +1 -0
  447. package/dist/pactile/runtime/paths.js +201 -0
  448. package/dist/pactile/runtime/paths.js.map +1 -0
  449. package/dist/pactile/runtime/stores.d.ts +54 -0
  450. package/dist/pactile/runtime/stores.d.ts.map +1 -0
  451. package/dist/pactile/runtime/stores.js +375 -0
  452. package/dist/pactile/runtime/stores.js.map +1 -0
  453. package/dist/pactile/runtime/unicode-nfc-data.d.ts +12 -0
  454. package/dist/pactile/runtime/unicode-nfc-data.d.ts.map +1 -0
  455. package/dist/pactile/runtime/unicode-nfc-data.js +8 -0
  456. package/dist/pactile/runtime/unicode-nfc-data.js.map +1 -0
  457. package/dist/pactile/runtime/unicode-nfc.d.ts +3 -0
  458. package/dist/pactile/runtime/unicode-nfc.d.ts.map +1 -0
  459. package/dist/pactile/runtime/unicode-nfc.js +77 -0
  460. package/dist/pactile/runtime/unicode-nfc.js.map +1 -0
  461. package/dist/pactile/tiles/catalog.d.ts +35 -0
  462. package/dist/pactile/tiles/catalog.d.ts.map +1 -0
  463. package/dist/pactile/tiles/catalog.js +235 -0
  464. package/dist/pactile/tiles/catalog.js.map +1 -0
  465. package/dist/pactile/tiles/compiler.d.ts +54 -0
  466. package/dist/pactile/tiles/compiler.d.ts.map +1 -0
  467. package/dist/pactile/tiles/compiler.js +270 -0
  468. package/dist/pactile/tiles/compiler.js.map +1 -0
  469. package/dist/pactile/tiles/content/baseline/index.d.ts +5 -0
  470. package/dist/pactile/tiles/content/baseline/index.d.ts.map +1 -0
  471. package/dist/pactile/tiles/content/baseline/index.js +115 -0
  472. package/dist/pactile/tiles/content/baseline/index.js.map +1 -0
  473. package/dist/pactile/tiles/content/index.d.ts +4 -0
  474. package/dist/pactile/tiles/content/index.d.ts.map +1 -0
  475. package/dist/pactile/tiles/content/index.js +4 -0
  476. package/dist/pactile/tiles/content/index.js.map +1 -0
  477. package/dist/pactile/tiles/content/ondemand/index.d.ts +5 -0
  478. package/dist/pactile/tiles/content/ondemand/index.d.ts.map +1 -0
  479. package/dist/pactile/tiles/content/ondemand/index.js +184 -0
  480. package/dist/pactile/tiles/content/ondemand/index.js.map +1 -0
  481. package/dist/pactile/tiles/content/source.d.ts +29 -0
  482. package/dist/pactile/tiles/content/source.d.ts.map +1 -0
  483. package/dist/pactile/tiles/content/source.js +86 -0
  484. package/dist/pactile/tiles/content/source.js.map +1 -0
  485. package/dist/pactile/tiles/loader.d.ts +31 -0
  486. package/dist/pactile/tiles/loader.d.ts.map +1 -0
  487. package/dist/pactile/tiles/loader.js +139 -0
  488. package/dist/pactile/tiles/loader.js.map +1 -0
  489. package/dist/pactile/tiles/safe-yaml.d.ts +11 -0
  490. package/dist/pactile/tiles/safe-yaml.d.ts.map +1 -0
  491. package/dist/pactile/tiles/safe-yaml.js +212 -0
  492. package/dist/pactile/tiles/safe-yaml.js.map +1 -0
  493. package/dist/templates/common/bundled-skills/pactile-check/SKILL.md +161 -0
  494. package/dist/templates/common/bundled-skills/pactile-check/references/fowler-12-smells.md +28 -0
  495. package/dist/templates/common/bundled-skills/pactile-handoff/SKILL.md +117 -0
  496. package/dist/templates/common/bundled-skills/pactile-meta/SKILL.md +75 -0
  497. package/dist/templates/common/bundled-skills/pactile-meta/references/customize-local/add-project-local-conventions.md +83 -0
  498. package/dist/templates/common/bundled-skills/pactile-meta/references/customize-local/change-agents.md +47 -0
  499. package/dist/templates/common/bundled-skills/pactile-meta/references/customize-local/change-context-loading.md +84 -0
  500. package/dist/templates/common/bundled-skills/pactile-meta/references/customize-local/change-hooks.md +57 -0
  501. package/dist/templates/common/bundled-skills/pactile-meta/references/customize-local/change-skills-or-commands.md +77 -0
  502. package/dist/templates/common/bundled-skills/pactile-meta/references/customize-local/change-spec-structure.md +83 -0
  503. package/dist/templates/common/bundled-skills/pactile-meta/references/customize-local/change-task-lifecycle.md +88 -0
  504. package/dist/templates/common/bundled-skills/pactile-meta/references/customize-local/change-workflow.md +65 -0
  505. package/dist/templates/common/bundled-skills/pactile-meta/references/customize-local/overview.md +55 -0
  506. package/dist/templates/common/bundled-skills/pactile-meta/references/local-architecture/context-injection.md +68 -0
  507. package/dist/templates/common/bundled-skills/pactile-meta/references/local-architecture/generated-files.md +83 -0
  508. package/dist/templates/common/bundled-skills/pactile-meta/references/local-architecture/overview.md +51 -0
  509. package/dist/templates/common/bundled-skills/pactile-meta/references/local-architecture/spec-system.md +102 -0
  510. package/dist/templates/common/bundled-skills/pactile-meta/references/local-architecture/task-system.md +133 -0
  511. package/dist/templates/common/bundled-skills/pactile-meta/references/local-architecture/workflow.md +75 -0
  512. package/dist/templates/common/bundled-skills/pactile-meta/references/local-architecture/workspace-memory.md +71 -0
  513. package/dist/templates/common/bundled-skills/pactile-meta/references/platform-files/agents.md +69 -0
  514. package/dist/templates/common/bundled-skills/pactile-meta/references/platform-files/hooks-and-settings.md +59 -0
  515. package/dist/templates/common/bundled-skills/pactile-meta/references/platform-files/overview.md +45 -0
  516. package/dist/templates/common/bundled-skills/pactile-meta/references/platform-files/platform-map.md +45 -0
  517. package/dist/templates/common/bundled-skills/pactile-meta/references/platform-files/skills-and-commands.md +108 -0
  518. package/dist/templates/common/bundled-skills/pactile-micro-grill/SKILL.md +68 -0
  519. package/dist/templates/common/bundled-skills/pactile-skill-creator/SKILL.md +47 -0
  520. package/dist/templates/common/bundled-skills/pactile-skill-creator/references/authoring-rules.md +171 -0
  521. package/dist/templates/common/bundled-skills/pactile-skill-creator/references/general-authoring.md +189 -0
  522. package/dist/templates/common/bundled-skills/pactile-skill-creator/references/pactile-skill-locations.md +52 -0
  523. package/dist/templates/common/bundled-skills/pactile-skill-creator/references/review-checklist.md +52 -0
  524. package/dist/templates/common/bundled-skills/pactile-spec-bootstrap/SKILL.md +41 -0
  525. package/dist/templates/common/bundled-skills/pactile-spec-bootstrap/references/mcp-setup.md +90 -0
  526. package/dist/templates/common/bundled-skills/pactile-spec-bootstrap/references/repository-analysis.md +59 -0
  527. package/dist/templates/common/bundled-skills/pactile-spec-bootstrap/references/spec-task-planning.md +61 -0
  528. package/dist/templates/common/bundled-skills/pactile-spec-bootstrap/references/spec-writing.md +70 -0
  529. package/dist/templates/common/bundled-skills/smart-search-cli/SKILL.md +393 -0
  530. package/dist/templates/common/bundled-skills/smart-search-cli/agents/openai.yaml +3 -0
  531. package/dist/templates/common/bundled-skills/smart-search-cli/examples/batch-search.md +98 -0
  532. package/dist/templates/common/bundled-skills/smart-search-cli/examples/evidence-gathering.md +89 -0
  533. package/dist/templates/common/bundled-skills/smart-search-cli/references/cli-contract.md +323 -0
  534. package/dist/templates/common/commands/continue.md +62 -0
  535. package/dist/templates/common/commands/finish-work.md +82 -0
  536. package/dist/templates/common/commands/start.md +66 -0
  537. package/dist/templates/common/index.d.ts +68 -0
  538. package/dist/templates/common/index.d.ts.map +1 -0
  539. package/dist/templates/common/index.js +123 -0
  540. package/dist/templates/common/index.js.map +1 -0
  541. package/dist/templates/common/optional-skills/chrome-cdp/SKILL.md +179 -0
  542. package/dist/templates/common/optional-skills/chrome-cdp/examples/fetch-hook-api-capture.md +149 -0
  543. package/dist/templates/common/optional-skills/chrome-cdp/scripts/cdp.mjs +904 -0
  544. package/dist/templates/common/skills/before-dev.md +35 -0
  545. package/dist/templates/common/skills/brainstorm.md +204 -0
  546. package/dist/templates/common/skills/break-loop.md +125 -0
  547. package/dist/templates/common/skills/update-spec.md +364 -0
  548. package/dist/templates/cursor/agents/pactile-check.md +58 -0
  549. package/dist/templates/cursor/agents/pactile-implement.md +56 -0
  550. package/dist/templates/cursor/agents/pactile-research.md +51 -0
  551. package/dist/templates/cursor/commands/handoff.md +101 -0
  552. package/dist/templates/cursor/fixtures/expected-rules.d.ts +14 -0
  553. package/dist/templates/cursor/fixtures/expected-rules.d.ts.map +1 -0
  554. package/dist/templates/cursor/fixtures/expected-rules.js +20 -0
  555. package/dist/templates/cursor/fixtures/expected-rules.js.map +1 -0
  556. package/dist/templates/cursor/hooks.json +52 -0
  557. package/dist/templates/cursor/index.d.ts +19 -0
  558. package/dist/templates/cursor/index.d.ts.map +1 -0
  559. package/dist/templates/cursor/index.js +19 -0
  560. package/dist/templates/cursor/index.js.map +1 -0
  561. package/dist/templates/cursor/rules/pactile-bootstrap.mdc +18 -0
  562. package/dist/templates/cursor/worktrees.json +11 -0
  563. package/dist/templates/extract.d.ts +38 -0
  564. package/dist/templates/extract.d.ts.map +1 -0
  565. package/dist/templates/extract.js +120 -0
  566. package/dist/templates/extract.js.map +1 -0
  567. package/dist/templates/markdown/agents.md +14 -0
  568. package/dist/templates/markdown/framework/artifact-locale-guide.md.txt +93 -0
  569. package/dist/templates/markdown/framework/cursor-context-injection-guide.md.txt +85 -0
  570. package/dist/templates/markdown/framework/cursor-native-modes-guide.md.txt +239 -0
  571. package/dist/templates/markdown/framework/cursor-semantic-compliance.md.txt +41 -0
  572. package/dist/templates/markdown/framework/cursor-subagent-policy.md.txt +90 -0
  573. package/dist/templates/markdown/framework/dogfood-only-surfaces.md.txt +28 -0
  574. package/dist/templates/markdown/framework/execution-strategy.md.txt +45 -0
  575. package/dist/templates/markdown/framework/index.md.txt +31 -0
  576. package/dist/templates/markdown/framework/injection-budget-guide.md.txt +111 -0
  577. package/dist/templates/markdown/framework/internal-skills-cursor-reachability.md.txt +45 -0
  578. package/dist/templates/markdown/framework/middleware-protocol.md.txt +238 -0
  579. package/dist/templates/markdown/framework/parallel-first-execution.md.txt +116 -0
  580. package/dist/templates/markdown/framework/prd-grill-frontier.md.txt +105 -0
  581. package/dist/templates/markdown/framework/release-boundary.md.txt +30 -0
  582. package/dist/templates/markdown/framework/retrieval-daily-guide.md.txt +199 -0
  583. package/dist/templates/markdown/framework/upgrade.md.txt +15 -0
  584. package/dist/templates/markdown/framework/verification-strength-guide.md.txt +185 -0
  585. package/dist/templates/markdown/gitignore.txt +15 -0
  586. package/dist/templates/markdown/index.d.ts +59 -0
  587. package/dist/templates/markdown/index.d.ts.map +1 -0
  588. package/dist/templates/markdown/index.js +144 -0
  589. package/dist/templates/markdown/index.js.map +1 -0
  590. package/dist/templates/markdown/prompts/run-semantic-slice-12.md.txt +25 -0
  591. package/dist/templates/markdown/spec/backend/database-guidelines.md.txt +51 -0
  592. package/dist/templates/markdown/spec/backend/directory-structure.md.txt +54 -0
  593. package/dist/templates/markdown/spec/backend/error-handling.md.txt +51 -0
  594. package/dist/templates/markdown/spec/backend/index.md.txt +38 -0
  595. package/dist/templates/markdown/spec/backend/logging-guidelines.md.txt +51 -0
  596. package/dist/templates/markdown/spec/backend/quality-guidelines.md.txt +51 -0
  597. package/dist/templates/markdown/spec/frontend/component-guidelines.md.txt +59 -0
  598. package/dist/templates/markdown/spec/frontend/directory-structure.md.txt +54 -0
  599. package/dist/templates/markdown/spec/frontend/hook-guidelines.md.txt +51 -0
  600. package/dist/templates/markdown/spec/frontend/index.md.txt +39 -0
  601. package/dist/templates/markdown/spec/frontend/quality-guidelines.md.txt +51 -0
  602. package/dist/templates/markdown/spec/frontend/state-management.md.txt +51 -0
  603. package/dist/templates/markdown/spec/frontend/type-safety.md.txt +51 -0
  604. package/dist/templates/markdown/spec/guides/code-reuse-thinking-guide.md.txt +174 -0
  605. package/dist/templates/markdown/spec/guides/cross-layer-thinking-guide.md.txt +162 -0
  606. package/dist/templates/markdown/spec/guides/cross-platform-thinking-guide.md.txt +634 -0
  607. package/dist/templates/markdown/spec/guides/debug-loop-guide.md.txt +227 -0
  608. package/dist/templates/markdown/spec/guides/durable-learning-decision-guide.md.txt +76 -0
  609. package/dist/templates/markdown/spec/guides/e2e-walkthrough-guide.md.txt +93 -0
  610. package/dist/templates/markdown/spec/guides/index.md.txt +131 -0
  611. package/dist/templates/markdown/spec/guides/prototype-guide.md.txt +139 -0
  612. package/dist/templates/markdown/spec/guides/test-discipline-guide.md.txt +179 -0
  613. package/dist/templates/markdown/workspace-index.md +125 -0
  614. package/dist/templates/markdown/worktree.yaml.txt +58 -0
  615. package/dist/templates/pactile/CONTEXT.md +113 -0
  616. package/dist/templates/pactile/config/execution-strategy-rules.json +31 -0
  617. package/dist/templates/pactile/config.yaml +130 -0
  618. package/dist/templates/pactile/docs/adr/README.md +21 -0
  619. package/dist/templates/pactile/gitignore.txt +35 -0
  620. package/dist/templates/pactile/index.d.ts +134 -0
  621. package/dist/templates/pactile/index.d.ts.map +1 -0
  622. package/dist/templates/pactile/index.js +316 -0
  623. package/dist/templates/pactile/index.js.map +1 -0
  624. package/dist/templates/pactile/modules/approval-personal/contract.md +43 -0
  625. package/dist/templates/pactile/modules/candidate-pool/contract.md +37 -0
  626. package/dist/templates/pactile/modules/catalog.d.ts +32 -0
  627. package/dist/templates/pactile/modules/catalog.d.ts.map +1 -0
  628. package/dist/templates/pactile/modules/catalog.js +46 -0
  629. package/dist/templates/pactile/modules/catalog.js.map +1 -0
  630. package/dist/templates/pactile/modules/close-basic/contract.md +38 -0
  631. package/dist/templates/pactile/modules/context-progressive/contract.md +44 -0
  632. package/dist/templates/pactile/modules/debug-recovery/contract.md +44 -0
  633. package/dist/templates/pactile/modules/define-basic/contract.md +39 -0
  634. package/dist/templates/pactile/modules/define-extended/contract.md +45 -0
  635. package/dist/templates/pactile/modules/execute-agent/contract.md +38 -0
  636. package/dist/templates/pactile/modules/independent-check/contract.md +35 -0
  637. package/dist/templates/pactile/modules/index.json +133 -0
  638. package/dist/templates/pactile/modules/intake-basic/contract.md +34 -0
  639. package/dist/templates/pactile/modules/observability-local/contract.md +31 -0
  640. package/dist/templates/pactile/modules/parent-child/contract.md +45 -0
  641. package/dist/templates/pactile/modules/personal-memory/contract.md +56 -0
  642. package/dist/templates/pactile/modules/retention-storage/contract.md +43 -0
  643. package/dist/templates/pactile/modules/retrieval-extended/contract.md +77 -0
  644. package/dist/templates/pactile/modules/session-transfer/contract.md +41 -0
  645. package/dist/templates/pactile/modules/spec-learning/contract.md +50 -0
  646. package/dist/templates/pactile/modules/vcs-integration/contract.md +46 -0
  647. package/dist/templates/pactile/modules/verify-basic/contract.md +38 -0
  648. package/dist/templates/pactile/modules/worker-orchestration/contract.md +47 -0
  649. package/dist/templates/pactile/pool/README.md +149 -0
  650. package/dist/templates/pactile/pool/items/.gitkeep +0 -0
  651. package/dist/templates/pactile/pool/plan.md +50 -0
  652. package/dist/templates/pactile/scripts/__init__.py +5 -0
  653. package/dist/templates/pactile/scripts/add_session.py +547 -0
  654. package/dist/templates/pactile/scripts/build_context_pack.py +17 -0
  655. package/dist/templates/pactile/scripts/build_retrieval_pack.py +376 -0
  656. package/dist/templates/pactile/scripts/codegraph_session_smoke.py +76 -0
  657. package/dist/templates/pactile/scripts/common/__init__.py +103 -0
  658. package/dist/templates/pactile/scripts/common/active_task.py +576 -0
  659. package/dist/templates/pactile/scripts/common/adapter_middleware.py +1373 -0
  660. package/dist/templates/pactile/scripts/common/artifact_locale.py +303 -0
  661. package/dist/templates/pactile/scripts/common/artifact_search.py +587 -0
  662. package/dist/templates/pactile/scripts/common/cli_adapter.py +135 -0
  663. package/dist/templates/pactile/scripts/common/cli_environment.py +155 -0
  664. package/dist/templates/pactile/scripts/common/codebase_retrieval_router.py +1339 -0
  665. package/dist/templates/pactile/scripts/common/config.py +497 -0
  666. package/dist/templates/pactile/scripts/common/context_pack.py +371 -0
  667. package/dist/templates/pactile/scripts/common/cursor_retrieval_env.py +31 -0
  668. package/dist/templates/pactile/scripts/common/developer.py +190 -0
  669. package/dist/templates/pactile/scripts/common/execution_strategy.py +268 -0
  670. package/dist/templates/pactile/scripts/common/full_quality.py +237 -0
  671. package/dist/templates/pactile/scripts/common/git.py +37 -0
  672. package/dist/templates/pactile/scripts/common/git_context.py +198 -0
  673. package/dist/templates/pactile/scripts/common/injection_budget.py +317 -0
  674. package/dist/templates/pactile/scripts/common/io.py +37 -0
  675. package/dist/templates/pactile/scripts/common/kernel_command.py +369 -0
  676. package/dist/templates/pactile/scripts/common/lite_context.py +280 -0
  677. package/dist/templates/pactile/scripts/common/log.py +45 -0
  678. package/dist/templates/pactile/scripts/common/ondemand_topology.py +419 -0
  679. package/dist/templates/pactile/scripts/common/packages_context.py +239 -0
  680. package/dist/templates/pactile/scripts/common/pactile_config.py +131 -0
  681. package/dist/templates/pactile/scripts/common/parallel_declaration.py +369 -0
  682. package/dist/templates/pactile/scripts/common/parent_orchestration.py +1198 -0
  683. package/dist/templates/pactile/scripts/common/paths.py +756 -0
  684. package/dist/templates/pactile/scripts/common/pool_refs.py +119 -0
  685. package/dist/templates/pactile/scripts/common/pool_slice.py +269 -0
  686. package/dist/templates/pactile/scripts/common/pool_store.py +766 -0
  687. package/dist/templates/pactile/scripts/common/project_file_stats.py +91 -0
  688. package/dist/templates/pactile/scripts/common/retrieval_adapter_metadata.py +943 -0
  689. package/dist/templates/pactile/scripts/common/retrieval_agent_instructions.py +123 -0
  690. package/dist/templates/pactile/scripts/common/retrieval_evidence.py +915 -0
  691. package/dist/templates/pactile/scripts/common/retrieval_pack.py +422 -0
  692. package/dist/templates/pactile/scripts/common/retrieval_pack_context.py +122 -0
  693. package/dist/templates/pactile/scripts/common/retrieval_plan_gate.py +61 -0
  694. package/dist/templates/pactile/scripts/common/retrieval_result_ranking.py +104 -0
  695. package/dist/templates/pactile/scripts/common/retrieval_tool_classification.py +166 -0
  696. package/dist/templates/pactile/scripts/common/safe_commit.py +285 -0
  697. package/dist/templates/pactile/scripts/common/semantic_plan_gate.py +53 -0
  698. package/dist/templates/pactile/scripts/common/session_context.py +1213 -0
  699. package/dist/templates/pactile/scripts/common/session_memory.py +386 -0
  700. package/dist/templates/pactile/scripts/common/session_pack.py +886 -0
  701. package/dist/templates/pactile/scripts/common/smart_search_evidence.py +514 -0
  702. package/dist/templates/pactile/scripts/common/smart_search_resolve.py +150 -0
  703. package/dist/templates/pactile/scripts/common/subagent_dispatch.py +592 -0
  704. package/dist/templates/pactile/scripts/common/task_context.py +241 -0
  705. package/dist/templates/pactile/scripts/common/task_dashboard.py +286 -0
  706. package/dist/templates/pactile/scripts/common/task_dependencies.py +648 -0
  707. package/dist/templates/pactile/scripts/common/task_gates.py +2478 -0
  708. package/dist/templates/pactile/scripts/common/task_map.py +703 -0
  709. package/dist/templates/pactile/scripts/common/task_queue.py +188 -0
  710. package/dist/templates/pactile/scripts/common/task_store.py +2252 -0
  711. package/dist/templates/pactile/scripts/common/task_utils.py +274 -0
  712. package/dist/templates/pactile/scripts/common/tasks.py +231 -0
  713. package/dist/templates/pactile/scripts/common/test_adapter_middleware.py +199 -0
  714. package/dist/templates/pactile/scripts/common/test_depends_mode_block.py +509 -0
  715. package/dist/templates/pactile/scripts/common/test_full_quality.py +197 -0
  716. package/dist/templates/pactile/scripts/common/test_kernel_command.py +336 -0
  717. package/dist/templates/pactile/scripts/common/test_lite_path.py +190 -0
  718. package/dist/templates/pactile/scripts/common/test_observable_defaults.py +141 -0
  719. package/dist/templates/pactile/scripts/common/test_ondemand_topology.py +237 -0
  720. package/dist/templates/pactile/scripts/common/test_parallel_declaration.py +264 -0
  721. package/dist/templates/pactile/scripts/common/test_pool_slice.py +198 -0
  722. package/dist/templates/pactile/scripts/common/test_pool_store.py +452 -0
  723. package/dist/templates/pactile/scripts/common/test_retrieval_arbitration.py +331 -0
  724. package/dist/templates/pactile/scripts/common/test_task_dashboard.py +155 -0
  725. package/dist/templates/pactile/scripts/common/test_task_dependencies.py +329 -0
  726. package/dist/templates/pactile/scripts/common/test_task_store_kernel_patch.py +163 -0
  727. package/dist/templates/pactile/scripts/common/types.py +110 -0
  728. package/dist/templates/pactile/scripts/common/workflow_phase.py +194 -0
  729. package/dist/templates/pactile/scripts/compile_session_pack.py +15 -0
  730. package/dist/templates/pactile/scripts/cursor_retrieval_probe.py +64 -0
  731. package/dist/templates/pactile/scripts/cursor_retrieval_probe_prompt.md +33 -0
  732. package/dist/templates/pactile/scripts/generate_dispatch_prompt.py +182 -0
  733. package/dist/templates/pactile/scripts/get_context.py +19 -0
  734. package/dist/templates/pactile/scripts/get_developer.py +26 -0
  735. package/dist/templates/pactile/scripts/hooks/linear_sync.py +243 -0
  736. package/dist/templates/pactile/scripts/init_developer.py +51 -0
  737. package/dist/templates/pactile/scripts/injection_budget_probe.py +69 -0
  738. package/dist/templates/pactile/scripts/pool.py +237 -0
  739. package/dist/templates/pactile/scripts/rank_retrieval_candidates.py +98 -0
  740. package/dist/templates/pactile/scripts/retrieval_probe_matrix_template.json +43 -0
  741. package/dist/templates/pactile/scripts/route_codebase_retrieval.py +72 -0
  742. package/dist/templates/pactile/scripts/run_smart_search.py +12 -0
  743. package/dist/templates/pactile/scripts/score_evidence.py +131 -0
  744. package/dist/templates/pactile/scripts/search_artifacts.py +13 -0
  745. package/dist/templates/pactile/scripts/search_memory.py +12 -0
  746. package/dist/templates/pactile/scripts/spec_health_outcomes.py +160 -0
  747. package/dist/templates/pactile/scripts/task.py +1118 -0
  748. package/dist/templates/pactile/scripts/verify_evidence_probe.py +138 -0
  749. package/dist/templates/pactile/tasks/.gitkeep +0 -0
  750. package/dist/templates/pactile/tasks/locale/en/default-prd.md +27 -0
  751. package/dist/templates/pactile/tasks/locale/zh/default-prd.md +27 -0
  752. package/dist/templates/pactile/tasks/templates/release-execution/design.md +61 -0
  753. package/dist/templates/pactile/tasks/templates/release-execution/handoff-template.md +29 -0
  754. package/dist/templates/pactile/tasks/templates/release-execution/implement.md +29 -0
  755. package/dist/templates/pactile/tasks/templates/release-execution/prd.md +31 -0
  756. package/dist/templates/pactile/tasks/templates/release-readiness/design.md +50 -0
  757. package/dist/templates/pactile/tasks/templates/release-readiness/handoff-template.md +39 -0
  758. package/dist/templates/pactile/tasks/templates/release-readiness/implement.md +29 -0
  759. package/dist/templates/pactile/tasks/templates/release-readiness/prd.md +31 -0
  760. package/dist/templates/pactile/workflow.md +64 -0
  761. package/dist/templates/shared-hooks/event-bridge.py +121 -0
  762. package/dist/templates/shared-hooks/index.d.ts +50 -0
  763. package/dist/templates/shared-hooks/index.d.ts.map +1 -0
  764. package/dist/templates/shared-hooks/index.js +96 -0
  765. package/dist/templates/shared-hooks/index.js.map +1 -0
  766. package/dist/templates/shared-hooks/inject-retrieval-plan.py +217 -0
  767. package/dist/templates/shared-hooks/inject-shell-session-context.py +183 -0
  768. package/dist/templates/shared-hooks/inject-subagent-context.py +267 -0
  769. package/dist/templates/shared-hooks/inject-workflow-state.py +106 -0
  770. package/dist/templates/shared-hooks/rename-session-for-task.py +231 -0
  771. package/dist/templates/shared-hooks/research-end-retrieval-pack.py +345 -0
  772. package/dist/templates/shared-hooks/session-start.py +355 -0
  773. package/dist/templates/shared-hooks/spec-write-audit.py +173 -0
  774. package/dist/templates/template-utils.d.ts +28 -0
  775. package/dist/templates/template-utils.d.ts.map +1 -0
  776. package/dist/templates/template-utils.js +83 -0
  777. package/dist/templates/template-utils.js.map +1 -0
  778. package/dist/types/ai-tools.d.ts +102 -0
  779. package/dist/types/ai-tools.d.ts.map +1 -0
  780. package/dist/types/ai-tools.js +60 -0
  781. package/dist/types/ai-tools.js.map +1 -0
  782. package/dist/types/migration.d.ts +125 -0
  783. package/dist/types/migration.d.ts.map +1 -0
  784. package/dist/types/migration.js +8 -0
  785. package/dist/types/migration.js.map +1 -0
  786. package/dist/utils/agents-md.d.ts +27 -0
  787. package/dist/utils/agents-md.d.ts.map +1 -0
  788. package/dist/utils/agents-md.js +70 -0
  789. package/dist/utils/agents-md.js.map +1 -0
  790. package/dist/utils/codebase-retrieval-router.d.ts +31 -0
  791. package/dist/utils/codebase-retrieval-router.d.ts.map +1 -0
  792. package/dist/utils/codebase-retrieval-router.js +88 -0
  793. package/dist/utils/codebase-retrieval-router.js.map +1 -0
  794. package/dist/utils/compare-versions.d.ts +12 -0
  795. package/dist/utils/compare-versions.d.ts.map +1 -0
  796. package/dist/utils/compare-versions.js +86 -0
  797. package/dist/utils/compare-versions.js.map +1 -0
  798. package/dist/utils/cursor-retrieval-env.d.ts +17 -0
  799. package/dist/utils/cursor-retrieval-env.d.ts.map +1 -0
  800. package/dist/utils/cursor-retrieval-env.js +19 -0
  801. package/dist/utils/cursor-retrieval-env.js.map +1 -0
  802. package/dist/utils/cwd-guard.d.ts +38 -0
  803. package/dist/utils/cwd-guard.d.ts.map +1 -0
  804. package/dist/utils/cwd-guard.js +63 -0
  805. package/dist/utils/cwd-guard.js.map +1 -0
  806. package/dist/utils/file-writer.d.ts +36 -0
  807. package/dist/utils/file-writer.d.ts.map +1 -0
  808. package/dist/utils/file-writer.js +203 -0
  809. package/dist/utils/file-writer.js.map +1 -0
  810. package/dist/utils/manifest-prune.d.ts +59 -0
  811. package/dist/utils/manifest-prune.d.ts.map +1 -0
  812. package/dist/utils/manifest-prune.js +176 -0
  813. package/dist/utils/manifest-prune.js.map +1 -0
  814. package/dist/utils/mirror-check.d.ts +22 -0
  815. package/dist/utils/mirror-check.d.ts.map +1 -0
  816. package/dist/utils/mirror-check.js +90 -0
  817. package/dist/utils/mirror-check.js.map +1 -0
  818. package/dist/utils/normalize-text.d.ts +7 -0
  819. package/dist/utils/normalize-text.d.ts.map +1 -0
  820. package/dist/utils/normalize-text.js +16 -0
  821. package/dist/utils/normalize-text.js.map +1 -0
  822. package/dist/utils/p36-upgrade.d.ts +62 -0
  823. package/dist/utils/p36-upgrade.d.ts.map +1 -0
  824. package/dist/utils/p36-upgrade.js +165 -0
  825. package/dist/utils/p36-upgrade.js.map +1 -0
  826. package/dist/utils/posix.d.ts +13 -0
  827. package/dist/utils/posix.d.ts.map +1 -0
  828. package/dist/utils/posix.js +15 -0
  829. package/dist/utils/posix.js.map +1 -0
  830. package/dist/utils/post-update-smoke.d.ts +7 -0
  831. package/dist/utils/post-update-smoke.d.ts.map +1 -0
  832. package/dist/utils/post-update-smoke.js +40 -0
  833. package/dist/utils/post-update-smoke.js.map +1 -0
  834. package/dist/utils/project-capabilities.d.ts +82 -0
  835. package/dist/utils/project-capabilities.d.ts.map +1 -0
  836. package/dist/utils/project-capabilities.js +691 -0
  837. package/dist/utils/project-capabilities.js.map +1 -0
  838. package/dist/utils/project-detector.d.ts +46 -0
  839. package/dist/utils/project-detector.d.ts.map +1 -0
  840. package/dist/utils/project-detector.js +666 -0
  841. package/dist/utils/project-detector.js.map +1 -0
  842. package/dist/utils/proxy.d.ts +25 -0
  843. package/dist/utils/proxy.d.ts.map +1 -0
  844. package/dist/utils/proxy.js +60 -0
  845. package/dist/utils/proxy.js.map +1 -0
  846. package/dist/utils/readiness.d.ts +40 -0
  847. package/dist/utils/readiness.d.ts.map +1 -0
  848. package/dist/utils/readiness.js +491 -0
  849. package/dist/utils/readiness.js.map +1 -0
  850. package/dist/utils/retrieval-agent-instructions.d.ts +10 -0
  851. package/dist/utils/retrieval-agent-instructions.d.ts.map +1 -0
  852. package/dist/utils/retrieval-agent-instructions.js +97 -0
  853. package/dist/utils/retrieval-agent-instructions.js.map +1 -0
  854. package/dist/utils/retrieval-execution-telemetry.d.ts +53 -0
  855. package/dist/utils/retrieval-execution-telemetry.d.ts.map +1 -0
  856. package/dist/utils/retrieval-execution-telemetry.js +116 -0
  857. package/dist/utils/retrieval-execution-telemetry.js.map +1 -0
  858. package/dist/utils/retrieval-result-ranking.d.ts +34 -0
  859. package/dist/utils/retrieval-result-ranking.d.ts.map +1 -0
  860. package/dist/utils/retrieval-result-ranking.js +71 -0
  861. package/dist/utils/retrieval-result-ranking.js.map +1 -0
  862. package/dist/utils/retrieval-tool-classification.d.ts +18 -0
  863. package/dist/utils/retrieval-tool-classification.d.ts.map +1 -0
  864. package/dist/utils/retrieval-tool-classification.js +118 -0
  865. package/dist/utils/retrieval-tool-classification.js.map +1 -0
  866. package/dist/utils/semantic-plan-gate.d.ts +8 -0
  867. package/dist/utils/semantic-plan-gate.d.ts.map +1 -0
  868. package/dist/utils/semantic-plan-gate.js +24 -0
  869. package/dist/utils/semantic-plan-gate.js.map +1 -0
  870. package/dist/utils/task-json.d.ts +13 -0
  871. package/dist/utils/task-json.d.ts.map +1 -0
  872. package/dist/utils/task-json.js +12 -0
  873. package/dist/utils/task-json.js.map +1 -0
  874. package/dist/utils/template-fetcher.d.ts +150 -0
  875. package/dist/utils/template-fetcher.d.ts.map +1 -0
  876. package/dist/utils/template-fetcher.js +907 -0
  877. package/dist/utils/template-fetcher.js.map +1 -0
  878. package/dist/utils/template-hash.d.ts +123 -0
  879. package/dist/utils/template-hash.d.ts.map +1 -0
  880. package/dist/utils/template-hash.js +375 -0
  881. package/dist/utils/template-hash.js.map +1 -0
  882. package/dist/utils/uninstall-scrubbers.d.ts +30 -0
  883. package/dist/utils/uninstall-scrubbers.d.ts.map +1 -0
  884. package/dist/utils/uninstall-scrubbers.js +196 -0
  885. package/dist/utils/uninstall-scrubbers.js.map +1 -0
  886. package/dist/utils/update-rollout-report.d.ts +171 -0
  887. package/dist/utils/update-rollout-report.d.ts.map +1 -0
  888. package/dist/utils/update-rollout-report.js +126 -0
  889. package/dist/utils/update-rollout-report.js.map +1 -0
  890. package/dist/utils/validate-rules.d.ts +21 -0
  891. package/dist/utils/validate-rules.d.ts.map +1 -0
  892. package/dist/utils/validate-rules.js +88 -0
  893. package/dist/utils/validate-rules.js.map +1 -0
  894. package/dist/utils/workflow-dir.d.ts +15 -0
  895. package/dist/utils/workflow-dir.d.ts.map +1 -0
  896. package/dist/utils/workflow-dir.js +33 -0
  897. package/dist/utils/workflow-dir.js.map +1 -0
  898. package/dist/utils/workflow-resolver.d.ts +86 -0
  899. package/dist/utils/workflow-resolver.d.ts.map +1 -0
  900. package/dist/utils/workflow-resolver.js +265 -0
  901. package/dist/utils/workflow-resolver.js.map +1 -0
  902. package/package.json +117 -0
  903. package/scripts/postinstall.js +6 -0
@@ -0,0 +1,1213 @@
1
+ #!/usr/bin/env python3
2
+ """
3
+ Session context generation (default + record modes).
4
+
5
+ Provides:
6
+ get_context_json - JSON output for default mode
7
+ get_context_text - Text output for default mode
8
+ get_context_record_json - JSON for record mode
9
+ get_context_text_record - Text for record mode
10
+ output_json - Print JSON
11
+ output_text - Print text
12
+ """
13
+
14
+ from __future__ import annotations
15
+
16
+ import json
17
+ import os
18
+ import re
19
+ import subprocess
20
+ from pathlib import Path
21
+
22
+ from .active_task import resolve_context_key
23
+ from .artifact_locale import artifact_locale_summary, resolve_artifact_locale
24
+ from .config import get_git_packages, get_journal_snippet_enabled
25
+ from .git import run_git
26
+ from .packages_context import get_packages_section
27
+ from .tasks import iter_active_tasks, load_task, get_all_statuses, children_progress
28
+ from .task_dashboard import render_task_dashboard
29
+ from .paths import (
30
+ DIR_SCRIPTS,
31
+ DIR_SPEC,
32
+ DIR_TASKS,
33
+ DIR_WORKFLOW,
34
+ DIR_WORKSPACE,
35
+ count_lines,
36
+ get_active_journal_file,
37
+ get_selected_task,
38
+ get_selected_task_source,
39
+ get_developer,
40
+ get_repo_root,
41
+ get_tasks_dir,
42
+ )
43
+
44
+
45
+ # =============================================================================
46
+ # Helpers
47
+ # =============================================================================
48
+
49
+ _PACKAGE_NAME = "@blxzer/pactile"
50
+
51
+
52
+ def _resolve_python_command() -> str:
53
+ """Pick the platform-appropriate python command.
54
+
55
+ Mirrors test resolvePython() (win32 prefers python, POSIX prefers
56
+ python3) so rendered guidance matches what integration tests assert.
57
+ """
58
+ candidates = ["python", "python3"] if os.name == "nt" else ["python3", "python"]
59
+ for exe in candidates:
60
+ try:
61
+ subprocess.run(
62
+ [exe, "--version"],
63
+ capture_output=True,
64
+ timeout=2,
65
+ check=True,
66
+ )
67
+ return exe
68
+ except (OSError, subprocess.SubprocessError):
69
+ continue
70
+ return "python"
71
+
72
+
73
+ _PYTHON_CMD = _resolve_python_command()
74
+ _UPDATE_CHECK_TIMEOUT_SECONDS = 1.0
75
+ _VERSION_RE = re.compile(
76
+ r"^\s*(\d+)(?:\.(\d+))?(?:\.(\d+))?(?:-([0-9A-Za-z.-]+))?\s*$"
77
+ )
78
+ _VERSION_TOKEN_RE = re.compile(r"\b\d+(?:\.\d+){1,2}(?:-[0-9A-Za-z.-]+)?\b")
79
+ _POLYREPO_IGNORED_DIRS = {
80
+ "node_modules",
81
+ "target",
82
+ "dist",
83
+ "build",
84
+ "out",
85
+ "bin",
86
+ "obj",
87
+ "vendor",
88
+ "coverage",
89
+ "tmp",
90
+ "__pycache__",
91
+ }
92
+ _POLYREPO_SCAN_MAX_DEPTH = 2
93
+
94
+
95
+ def _is_git_worktree(path: Path) -> bool:
96
+ """Return True when path is inside a Git worktree."""
97
+ rc, out, _ = run_git(["rev-parse", "--is-inside-work-tree"], cwd=path)
98
+ return rc == 0 and out.strip().lower() == "true"
99
+
100
+
101
+ def _parse_recent_commits(log_output: str) -> list[dict]:
102
+ """Parse `git log --oneline` output into structured commit entries."""
103
+ commits = []
104
+ for line in log_output.splitlines():
105
+ if not line.strip():
106
+ continue
107
+ parts = line.split(" ", 1)
108
+ if len(parts) >= 2:
109
+ commits.append({"hash": parts[0], "message": parts[1]})
110
+ elif len(parts) == 1:
111
+ commits.append({"hash": parts[0], "message": ""})
112
+ return commits
113
+
114
+
115
+ def _collect_git_repo_info(name: str, rel_path: str, repo_dir: Path) -> dict | None:
116
+ """Collect Git status for one known repository directory."""
117
+ if not (repo_dir / ".git").exists():
118
+ return None
119
+
120
+ _, branch_out, _ = run_git(["branch", "--show-current"], cwd=repo_dir)
121
+ branch = branch_out.strip() or "unknown"
122
+
123
+ _, status_out, _ = run_git(["status", "--porcelain"], cwd=repo_dir)
124
+ changes = len([l for l in status_out.splitlines() if l.strip()])
125
+
126
+ _, log_out, _ = run_git(["log", "--oneline", "-5"], cwd=repo_dir)
127
+
128
+ return {
129
+ "name": name,
130
+ "path": rel_path,
131
+ "branch": branch,
132
+ "isClean": changes == 0,
133
+ "uncommittedChanges": changes,
134
+ "recentCommits": _parse_recent_commits(log_out),
135
+ }
136
+
137
+
138
+ def _collect_root_git_info(repo_root: Path) -> dict:
139
+ """Collect root Git info without pretending a non-Git root is clean."""
140
+ if not _is_git_worktree(repo_root):
141
+ return {
142
+ "isRepo": False,
143
+ "branch": "",
144
+ "isClean": False,
145
+ "uncommittedChanges": 0,
146
+ "recentCommits": [],
147
+ }
148
+
149
+ _, branch_out, _ = run_git(["branch", "--show-current"], cwd=repo_root)
150
+ branch = branch_out.strip() or "unknown"
151
+
152
+ _, status_out, _ = run_git(["status", "--porcelain"], cwd=repo_root)
153
+ status_lines = [line for line in status_out.splitlines() if line.strip()]
154
+
155
+ _, short_out, _ = run_git(["status", "--short"], cwd=repo_root)
156
+
157
+ _, log_out, _ = run_git(["log", "--oneline", "-5"], cwd=repo_root)
158
+
159
+ return {
160
+ "isRepo": True,
161
+ "branch": branch,
162
+ "isClean": len(status_lines) == 0,
163
+ "uncommittedChanges": len(status_lines),
164
+ "statusShort": short_out.splitlines(),
165
+ "recentCommits": _parse_recent_commits(log_out),
166
+ }
167
+
168
+
169
+ def _discover_child_git_repos(repo_root: Path) -> list[tuple[str, str]]:
170
+ """Discover child Git repositories using the init-time polyrepo heuristic."""
171
+ found: list[str] = []
172
+
173
+ def is_candidate_dir(path: Path) -> bool:
174
+ name = path.name
175
+ return not name.startswith(".") and name not in _POLYREPO_IGNORED_DIRS
176
+
177
+ def scan(rel_dir: Path, depth: int) -> None:
178
+ if depth >= _POLYREPO_SCAN_MAX_DEPTH:
179
+ return
180
+ abs_dir = repo_root / rel_dir
181
+ try:
182
+ children = sorted(abs_dir.iterdir(), key=lambda p: p.name)
183
+ except OSError:
184
+ return
185
+
186
+ for child in children:
187
+ if not child.is_dir() or not is_candidate_dir(child):
188
+ continue
189
+
190
+ child_rel = (
191
+ rel_dir / child.name if rel_dir != Path(".") else Path(child.name)
192
+ )
193
+ if (child / ".git").exists():
194
+ found.append(child_rel.as_posix())
195
+ continue
196
+ scan(child_rel, depth + 1)
197
+
198
+ scan(Path("."), 0)
199
+ if len(found) < 2:
200
+ return []
201
+ return [(path.replace("/", "_"), path) for path in sorted(found)]
202
+
203
+
204
+ def _collect_package_git_info(
205
+ repo_root: Path,
206
+ discover_unconfigured: bool = False,
207
+ ) -> list[dict]:
208
+ """Collect Git status for independent package repositories.
209
+
210
+ Packages marked with ``git: true`` in config.yaml are authoritative.
211
+ When the Pactile root is not a Git repo and no configured package repos are
212
+ available, optionally fall back to the bounded polyrepo child scan.
213
+
214
+ Returns:
215
+ List of dicts with keys: name, path, branch, isClean,
216
+ uncommittedChanges, recentCommits.
217
+ Empty list if no git-repo packages are configured.
218
+ """
219
+ git_pkgs = get_git_packages(repo_root)
220
+ result = []
221
+ for pkg_name, pkg_path in git_pkgs.items():
222
+ pkg_dir = repo_root / pkg_path
223
+ info = _collect_git_repo_info(pkg_name, pkg_path, pkg_dir)
224
+ if info is not None:
225
+ result.append(info)
226
+
227
+ if result or not discover_unconfigured:
228
+ return result
229
+
230
+ discovered = []
231
+ for pkg_name, pkg_path in _discover_child_git_repos(repo_root):
232
+ info = _collect_git_repo_info(pkg_name, pkg_path, repo_root / pkg_path)
233
+ if info is not None:
234
+ discovered.append(info)
235
+ return discovered
236
+
237
+
238
+ def _append_root_git_context(lines: list[str], root_git_info: dict) -> None:
239
+ """Append root Git status without misleading non-Git roots."""
240
+ lines.append("## GIT STATUS")
241
+ if not root_git_info["isRepo"]:
242
+ lines.append("Root is not a Git repository.")
243
+ lines.append("Run Git commands from the package repository paths listed below.")
244
+ else:
245
+ lines.append(f"Branch: {root_git_info['branch']}")
246
+ if root_git_info["isClean"]:
247
+ lines.append("Working directory: Clean")
248
+ else:
249
+ lines.append(
250
+ f"Working directory: {root_git_info['uncommittedChanges']} "
251
+ "uncommitted change(s)"
252
+ )
253
+ lines.append("")
254
+ lines.append("Changes:")
255
+ for line in root_git_info.get("statusShort", [])[:10]:
256
+ lines.append(line)
257
+ lines.append("")
258
+
259
+ lines.append("## RECENT COMMITS")
260
+ if not root_git_info["isRepo"]:
261
+ lines.append(
262
+ "Root has no Git commit history because it is not a Git repository."
263
+ )
264
+ elif root_git_info["recentCommits"]:
265
+ for commit in root_git_info["recentCommits"]:
266
+ lines.append(f"{commit['hash']} {commit['message']}")
267
+ else:
268
+ lines.append("(no commits)")
269
+ lines.append("")
270
+
271
+
272
+ def _append_package_git_context(lines: list[str], package_git_info: list[dict]) -> None:
273
+ """Append Git status and recent commits for package repositories."""
274
+ for pkg in package_git_info:
275
+ lines.append(f"## GIT STATUS ({pkg['name']}: {pkg['path']})")
276
+ lines.append(f"Branch: {pkg['branch']}")
277
+ if pkg["isClean"]:
278
+ lines.append("Working directory: Clean")
279
+ else:
280
+ lines.append(
281
+ f"Working directory: {pkg['uncommittedChanges']} uncommitted change(s)"
282
+ )
283
+ lines.append("")
284
+ lines.append(f"## RECENT COMMITS ({pkg['name']}: {pkg['path']})")
285
+ if pkg["recentCommits"]:
286
+ for commit in pkg["recentCommits"]:
287
+ lines.append(f"{commit['hash']} {commit['message']}")
288
+ else:
289
+ lines.append("(no commits)")
290
+ lines.append("")
291
+
292
+
293
+ def _read_project_version(repo_root: Path) -> str | None:
294
+ try:
295
+ version = (repo_root / DIR_WORKFLOW / ".version").read_text(
296
+ encoding="utf-8"
297
+ ).strip()
298
+ except OSError:
299
+ return None
300
+ return version or None
301
+
302
+
303
+ def _fetch_pactile_version_output() -> str | None:
304
+ try:
305
+ result = subprocess.run(
306
+ ["pactile", "--version"],
307
+ capture_output=True,
308
+ text=True,
309
+ encoding="utf-8",
310
+ errors="replace",
311
+ timeout=_UPDATE_CHECK_TIMEOUT_SECONDS,
312
+ )
313
+ except (OSError, subprocess.SubprocessError, TimeoutError):
314
+ return None
315
+
316
+ if result.returncode != 0:
317
+ return None
318
+ output = f"{result.stdout}\n{result.stderr}".strip()
319
+ return output or None
320
+
321
+
322
+ def _extract_available_update_version(output: str) -> str | None:
323
+ update_match = re.search(
324
+ r"Pactile update available:\s*"
325
+ r"(?P<current>\S+)\s*(?:→|->)\s*(?P<latest>\S+)",
326
+ output,
327
+ )
328
+ if update_match:
329
+ return update_match.group("latest").strip()
330
+ candidates = _VERSION_TOKEN_RE.findall(output)
331
+ return candidates[-1] if candidates else None
332
+
333
+
334
+ def _resolve_available_update_version() -> str | None:
335
+ output = _fetch_pactile_version_output()
336
+ if not output:
337
+ return None
338
+ return _extract_available_update_version(output)
339
+
340
+
341
+ def _parse_version(version: str) -> tuple[tuple[int, int, int], tuple[str, ...] | None] | None:
342
+ match = _VERSION_RE.match(version)
343
+ if not match:
344
+ return None
345
+ major, minor, patch, prerelease = match.groups()
346
+ numbers = (int(major), int(minor or "0"), int(patch or "0"))
347
+ prerelease_parts = tuple(prerelease.split(".")) if prerelease else None
348
+ return numbers, prerelease_parts
349
+
350
+
351
+ def _compare_prerelease(
352
+ left: tuple[str, ...] | None,
353
+ right: tuple[str, ...] | None,
354
+ ) -> int:
355
+ if left is None and right is None:
356
+ return 0
357
+ if left is None:
358
+ return 1
359
+ if right is None:
360
+ return -1
361
+
362
+ for left_part, right_part in zip(left, right):
363
+ if left_part == right_part:
364
+ continue
365
+ left_numeric = left_part.isdigit()
366
+ right_numeric = right_part.isdigit()
367
+ if left_numeric and right_numeric:
368
+ left_int = int(left_part)
369
+ right_int = int(right_part)
370
+ return (left_int > right_int) - (left_int < right_int)
371
+ if left_numeric:
372
+ return -1
373
+ if right_numeric:
374
+ return 1
375
+ return (left_part > right_part) - (left_part < right_part)
376
+
377
+ return (len(left) > len(right)) - (len(left) < len(right))
378
+
379
+
380
+ def _compare_versions(left: str, right: str) -> int | None:
381
+ parsed_left = _parse_version(left)
382
+ parsed_right = _parse_version(right)
383
+ if parsed_left is None or parsed_right is None:
384
+ return None
385
+
386
+ left_numbers, left_prerelease = parsed_left
387
+ right_numbers, right_prerelease = parsed_right
388
+ if left_numbers != right_numbers:
389
+ return (left_numbers > right_numbers) - (left_numbers < right_numbers)
390
+ return _compare_prerelease(left_prerelease, right_prerelease)
391
+
392
+
393
+ def _update_marker_path(repo_root: Path) -> Path:
394
+ context_key = resolve_context_key()
395
+ if not context_key:
396
+ terminal_key = os.environ.get("TERM_SESSION_ID", "").strip()
397
+ context_key = terminal_key or f"ppid-{os.getppid()}"
398
+ safe_key = re.sub(r"[^A-Za-z0-9._-]+", "_", context_key).strip("._-")
399
+ if not safe_key:
400
+ safe_key = "session"
401
+ return (
402
+ repo_root
403
+ / DIR_WORKFLOW
404
+ / ".runtime"
405
+ / f"update-check-{safe_key[:160]}.marker"
406
+ )
407
+
408
+
409
+ def _mark_update_check_attempted(repo_root: Path) -> bool:
410
+ marker_path = _update_marker_path(repo_root)
411
+ if marker_path.exists():
412
+ return False
413
+ try:
414
+ marker_path.parent.mkdir(parents=True, exist_ok=True)
415
+ marker_path.write_text("checked\n", encoding="utf-8")
416
+ except OSError:
417
+ pass
418
+ return True
419
+
420
+
421
+ def _get_update_hint(repo_root: Path) -> str | None:
422
+ marker_path = _update_marker_path(repo_root)
423
+ if marker_path.exists():
424
+ return None
425
+
426
+ current_version = _read_project_version(repo_root)
427
+ if not current_version:
428
+ return None
429
+
430
+ latest_version = _resolve_available_update_version()
431
+ if not latest_version:
432
+ return None
433
+
434
+ _mark_update_check_attempted(repo_root)
435
+ comparison = _compare_versions(current_version, latest_version)
436
+ if comparison is None or comparison >= 0:
437
+ return None
438
+
439
+ return (
440
+ f"Pactile update available: {current_version} -> {latest_version}, "
441
+ "run pactile upgrade"
442
+ )
443
+
444
+
445
+ def _quote_command_value(value: str) -> str:
446
+ return value.replace("\\", "\\\\").replace('"', '\\"')
447
+
448
+
449
+ def _artifact_search_command(query: str = "<topic>") -> str:
450
+ return (
451
+ f"{_PYTHON_CMD} ./{DIR_WORKFLOW}/{DIR_SCRIPTS}/search_artifacts.py "
452
+ f'--query "{_quote_command_value(query)}" --json'
453
+ )
454
+
455
+
456
+ def _session_memory_command(query: str = "<topic>") -> str:
457
+ return (
458
+ f"{_PYTHON_CMD} ./{DIR_WORKFLOW}/{DIR_SCRIPTS}/search_memory.py "
459
+ f'--query "{_quote_command_value(query)}" --json'
460
+ )
461
+
462
+
463
+ def _smart_search_evidence_command(question: str = "<question>") -> str:
464
+ return (
465
+ f"{_PYTHON_CMD} ./{DIR_WORKFLOW}/{DIR_SCRIPTS}/run_smart_search.py "
466
+ f'"{_quote_command_value(question)}" --intent deep-research --json'
467
+ )
468
+
469
+
470
+ def _query_tokens(*values: object) -> list[str]:
471
+ tokens: list[str] = []
472
+ seen: set[str] = set()
473
+ for value in values:
474
+ if not value:
475
+ continue
476
+ for raw_token in re.findall(r"[\w.-]+", str(value)):
477
+ token = raw_token.strip("._-")
478
+ if not token:
479
+ continue
480
+ key = token.lower()
481
+ if key in seen:
482
+ continue
483
+ seen.add(key)
484
+ tokens.append(token)
485
+ if len(tokens) >= 8:
486
+ return tokens
487
+ return tokens
488
+
489
+
490
+ def _selected_task_query(selected_task: str, task_info: object | None) -> str:
491
+ if task_info:
492
+ tokens = _query_tokens(
493
+ getattr(task_info, "title", ""),
494
+ getattr(task_info, "name", ""),
495
+ getattr(task_info, "package", ""),
496
+ getattr(task_info, "description", ""),
497
+ )
498
+ else:
499
+ tokens = _query_tokens(Path(selected_task).name)
500
+ return " ".join(tokens) if tokens else selected_task
501
+
502
+
503
+ def _recommendation(
504
+ source: str,
505
+ priority: int,
506
+ confidence: str,
507
+ reason: str,
508
+ action: str,
509
+ reference: str,
510
+ ) -> dict[str, object]:
511
+ return {
512
+ "source": source,
513
+ "priority": priority,
514
+ "confidence": confidence,
515
+ "reason": reason,
516
+ "action": action,
517
+ "reference": reference,
518
+ }
519
+
520
+
521
+ def _resolve_selected_task_dir(repo_root: Path, selected_task: str) -> Path:
522
+ task_path = Path(selected_task)
523
+ if task_path.is_absolute():
524
+ return task_path
525
+ return repo_root / task_path
526
+
527
+
528
+ def _selected_task_artifacts(
529
+ repo_root: Path,
530
+ selected_task: str | None,
531
+ ) -> dict[str, object] | None:
532
+ if not selected_task:
533
+ return None
534
+
535
+ task_dir = _resolve_selected_task_dir(repo_root, selected_task)
536
+ research_dir = task_dir / "research"
537
+ research_count = 0
538
+ if research_dir.is_dir():
539
+ research_count = len([p for p in research_dir.glob("*.md") if p.is_file()])
540
+
541
+ return {
542
+ "taskPath": selected_task,
543
+ "prd": (task_dir / "prd.md").is_file(),
544
+ "design": (task_dir / "design.md").is_file(),
545
+ "implement": (task_dir / "implement.md").is_file(),
546
+ "research": research_dir.is_dir(),
547
+ "researchCount": research_count,
548
+ "verify": (task_dir / "verify.md").is_file(),
549
+ }
550
+
551
+
552
+ def _get_retrieval_guide(
553
+ repo_root: Path,
554
+ selected_task: str | None,
555
+ ) -> dict[str, object]:
556
+ guide: dict[str, object] = {
557
+ "artifactSearch": {
558
+ "command": _artifact_search_command(),
559
+ "purpose": (
560
+ "Find durable Pactile specs, tasks, research, verification "
561
+ "notes, and workspace journals."
562
+ ),
563
+ },
564
+ "sessionMemory": {
565
+ "command": _session_memory_command(),
566
+ "purpose": (
567
+ "Find reusable session history, prior decisions, and recent "
568
+ "work context from local workspace journals."
569
+ ),
570
+ },
571
+ "smartSearchEvidence": {
572
+ "command": _smart_search_evidence_command(),
573
+ "purpose": (
574
+ "Explicitly run Smart Search and save a task-local evidence "
575
+ "manifest for source-backed research."
576
+ ),
577
+ },
578
+ "codebaseEvidence": (
579
+ "Treat adapter output as candidate evidence until current source, "
580
+ "Git, or validation confirms it."
581
+ ),
582
+ "evidenceSinks": {
583
+ "exploratory": "selected task research/*.md",
584
+ "final": "selected task verify.md",
585
+ },
586
+ }
587
+ selected_artifacts = _selected_task_artifacts(repo_root, selected_task)
588
+ if selected_artifacts is not None:
589
+ guide["selectedTaskArtifacts"] = selected_artifacts
590
+ guide["recommendations"] = _get_retrieval_recommendations(
591
+ repo_root,
592
+ selected_task,
593
+ selected_artifacts,
594
+ )
595
+ return guide
596
+
597
+
598
+ def _get_retrieval_recommendations(
599
+ repo_root: Path,
600
+ selected_task: str | None,
601
+ selected_artifacts: dict[str, object] | None = None,
602
+ ) -> list[dict[str, object]]:
603
+ if not selected_task:
604
+ return []
605
+
606
+ task_dir = _resolve_selected_task_dir(repo_root, selected_task)
607
+ task_info = load_task(task_dir)
608
+ artifacts = (
609
+ selected_artifacts
610
+ or _selected_task_artifacts(repo_root, selected_task)
611
+ or {}
612
+ )
613
+ query = _selected_task_query(selected_task, task_info)
614
+ recommendations: list[dict[str, object]] = []
615
+
616
+ has_local_artifacts = any(
617
+ bool(artifacts.get(key))
618
+ for key in ("prd", "design", "implement", "research", "verify")
619
+ )
620
+ if has_local_artifacts:
621
+ recommendations.append(
622
+ _recommendation(
623
+ "task-artifacts",
624
+ 100,
625
+ "high",
626
+ "Selected task has local planning or evidence artifacts; read them first.",
627
+ "Read selected task prd.md, design.md, implement.md, research/*.md, and verify.md as present.",
628
+ selected_task,
629
+ )
630
+ )
631
+
632
+ recommendations.extend(
633
+ [
634
+ _recommendation(
635
+ "artifact-search",
636
+ 90,
637
+ "high",
638
+ "Search durable Pactile specs, tasks, research, and verification notes for related context.",
639
+ _artifact_search_command(query),
640
+ selected_task,
641
+ ),
642
+ _recommendation(
643
+ "session-memory",
644
+ 80,
645
+ "medium",
646
+ "Search local session history for prior decisions and recent related work.",
647
+ _session_memory_command(query),
648
+ f"{DIR_WORKFLOW}/{DIR_WORKSPACE}/",
649
+ ),
650
+ ]
651
+ )
652
+
653
+ if bool(artifacts.get("research")):
654
+ smart_priority = 55
655
+ smart_confidence = "low"
656
+ smart_reason = (
657
+ "Research artifacts already exist; run Smart Search only for current external source gaps."
658
+ )
659
+ else:
660
+ smart_priority = 70
661
+ smart_confidence = "medium"
662
+ smart_reason = (
663
+ "No selected-task research artifacts are present; capture explicit external evidence when needed."
664
+ )
665
+
666
+ recommendations.extend(
667
+ [
668
+ _recommendation(
669
+ "smart-search",
670
+ smart_priority,
671
+ smart_confidence,
672
+ smart_reason,
673
+ _smart_search_evidence_command(query),
674
+ f"{selected_task}/research/smart-search/",
675
+ ),
676
+ _recommendation(
677
+ "codebase-evidence",
678
+ 60,
679
+ "medium",
680
+ "Confirm candidate codebase evidence against current source, Git state, or validation.",
681
+ "Inspect current source and run focused validation before treating codebase retrieval as proof.",
682
+ "current source tree",
683
+ ),
684
+ ]
685
+ )
686
+
687
+ recommendations.sort(
688
+ key=lambda item: (-int(item["priority"]), str(item["source"]))
689
+ )
690
+ return recommendations
691
+
692
+
693
+ def _present_missing(value: object) -> str:
694
+ return "present" if bool(value) else "missing"
695
+
696
+
697
+ def _append_retrieval_recommendations(
698
+ lines: list[str],
699
+ recommendations: list[dict[str, object]],
700
+ ) -> None:
701
+ if not recommendations:
702
+ return
703
+ lines.append("Retrieval recommendations:")
704
+ for index, recommendation in enumerate(recommendations, start=1):
705
+ source = recommendation.get("source", "")
706
+ confidence = recommendation.get("confidence", "")
707
+ priority = recommendation.get("priority", "")
708
+ reason = recommendation.get("reason", "")
709
+ lines.append(f"{index}. {source} [{confidence}] priority {priority}: {reason}")
710
+ lines.append(f" Action: {recommendation.get('action', '')}")
711
+ lines.append(f" Reference: {recommendation.get('reference', '')}")
712
+
713
+
714
+ def _append_retrieval_guide(
715
+ lines: list[str],
716
+ repo_root: Path,
717
+ selected_task: str | None,
718
+ ) -> None:
719
+ lines.append("## RETRIEVAL GUIDE")
720
+ lines.append(f"Artifact search: {_artifact_search_command()}")
721
+ lines.append(f"Session memory: {_session_memory_command()}")
722
+ lines.append(f"Smart Search evidence: {_smart_search_evidence_command()}")
723
+ lines.append(
724
+ "Use artifact search for durable Pactile specs, tasks, research, "
725
+ "verification notes, and workspace journals."
726
+ )
727
+ lines.append(
728
+ "Use session memory for reusable prior decisions and recent work "
729
+ "recorded in local workspace journals."
730
+ )
731
+ lines.append(
732
+ "Run Smart Search evidence only when external/current source evidence is "
733
+ "needed; it writes a task-local manifest under research/smart-search/."
734
+ )
735
+ lines.append(
736
+ "Codebase evidence: adapter output is candidate evidence until current "
737
+ "source, Git, or validation confirms it."
738
+ )
739
+
740
+ if selected_task:
741
+ lines.append(
742
+ f"Evidence sinks: {selected_task}/research/*.md for exploratory "
743
+ f"chains; {selected_task}/verify.md for final proof."
744
+ )
745
+ artifacts = _selected_task_artifacts(repo_root, selected_task)
746
+ if artifacts:
747
+ research_count = int(artifacts.get("researchCount", 0))
748
+ research_state = (
749
+ f"{research_count} markdown file(s)"
750
+ if research_count
751
+ else _present_missing(artifacts.get("research"))
752
+ )
753
+ lines.append("Selected-task artifacts:")
754
+ lines.append(f"- prd.md: {_present_missing(artifacts.get('prd'))}")
755
+ lines.append(f"- design.md: {_present_missing(artifacts.get('design'))}")
756
+ lines.append(
757
+ f"- implement.md: {_present_missing(artifacts.get('implement'))}"
758
+ )
759
+ lines.append(f"- research/: {research_state}")
760
+ lines.append(f"- verify.md: {_present_missing(artifacts.get('verify'))}")
761
+ _append_retrieval_recommendations(
762
+ lines,
763
+ _get_retrieval_recommendations(repo_root, selected_task, artifacts),
764
+ )
765
+ else:
766
+ lines.append(
767
+ "Evidence sinks: task research/*.md for exploratory chains; task "
768
+ "verify.md for final proof."
769
+ )
770
+ lines.append("")
771
+
772
+
773
+ # =============================================================================
774
+ # JSON Output
775
+ # =============================================================================
776
+
777
+ def get_context_json(repo_root: Path | None = None) -> dict:
778
+ """Get context as a dictionary.
779
+
780
+ Args:
781
+ repo_root: Repository root path. Defaults to auto-detected.
782
+
783
+ Returns:
784
+ Context dictionary.
785
+ """
786
+ if repo_root is None:
787
+ repo_root = get_repo_root()
788
+
789
+ developer = get_developer(repo_root)
790
+ tasks_dir = get_tasks_dir(repo_root)
791
+ journal_file = get_active_journal_file(repo_root)
792
+
793
+ journal_lines = 0
794
+ journal_relative = ""
795
+ if journal_file and developer:
796
+ journal_lines = count_lines(journal_file)
797
+ journal_relative = (
798
+ f"{DIR_WORKFLOW}/{DIR_WORKSPACE}/{developer}/{journal_file.name}"
799
+ )
800
+
801
+ root_git_info = _collect_root_git_info(repo_root)
802
+
803
+ # Tasks
804
+ tasks = [
805
+ {
806
+ "dir": t.dir_name,
807
+ "name": t.name,
808
+ "status": t.status,
809
+ "children": list(t.children),
810
+ "parent": t.parent,
811
+ }
812
+ for t in iter_active_tasks(tasks_dir)
813
+ ]
814
+
815
+ # Package git repos (independent sub-repositories)
816
+ pkg_git_info = _collect_package_git_info(
817
+ repo_root,
818
+ discover_unconfigured=not root_git_info["isRepo"],
819
+ )
820
+ selected_task = get_selected_task(repo_root)
821
+
822
+ result = {
823
+ "developer": developer or "",
824
+ "artifactLocale": resolve_artifact_locale(
825
+ repo_root / selected_task if selected_task else None,
826
+ repo_root,
827
+ ),
828
+ "git": {
829
+ "isRepo": root_git_info["isRepo"],
830
+ "branch": root_git_info["branch"],
831
+ "isClean": root_git_info["isClean"],
832
+ "uncommittedChanges": root_git_info["uncommittedChanges"],
833
+ "recentCommits": root_git_info["recentCommits"],
834
+ },
835
+ "tasks": {
836
+ "active": tasks,
837
+ "directory": f"{DIR_WORKFLOW}/{DIR_TASKS}",
838
+ },
839
+ "journal": {
840
+ "file": journal_relative,
841
+ "lines": journal_lines,
842
+ "nearLimit": journal_lines > 1800,
843
+ },
844
+ "retrievalGuide": _get_retrieval_guide(repo_root, selected_task),
845
+ }
846
+
847
+ if pkg_git_info:
848
+ result["packageGit"] = pkg_git_info
849
+
850
+ if get_journal_snippet_enabled(repo_root):
851
+ result["journal"]["snippet"] = _resolve_journal_snippet(
852
+ repo_root,
853
+ journal_file,
854
+ developer,
855
+ )
856
+
857
+ return result
858
+
859
+
860
+ def _resolve_journal_snippet(
861
+ repo_root: Path,
862
+ journal_file: Path | None,
863
+ developer: str | None,
864
+ ) -> str:
865
+ if not journal_file or not developer:
866
+ return ""
867
+ try:
868
+ from .session_memory import get_latest_journal_summary
869
+ except ImportError:
870
+ return ""
871
+ return get_latest_journal_summary(journal_file, repo_root, developer)
872
+
873
+
874
+ def output_json(repo_root: Path | None = None) -> None:
875
+ """Output context in JSON format.
876
+
877
+ Args:
878
+ repo_root: Repository root path. Defaults to auto-detected.
879
+ """
880
+ context = get_context_json(repo_root)
881
+ print(json.dumps(context, indent=2, ensure_ascii=False))
882
+
883
+
884
+ # =============================================================================
885
+ # Text Output
886
+ # =============================================================================
887
+
888
+ def get_context_text(repo_root: Path | None = None) -> str:
889
+ """Get context as formatted text.
890
+
891
+ Args:
892
+ repo_root: Repository root path. Defaults to auto-detected.
893
+
894
+ Returns:
895
+ Formatted text output.
896
+ """
897
+ if repo_root is None:
898
+ repo_root = get_repo_root()
899
+
900
+ lines = []
901
+ lines.append("========================================")
902
+ lines.append("SESSION CONTEXT")
903
+ lines.append("========================================")
904
+ lines.append("")
905
+
906
+ developer = get_developer(repo_root)
907
+
908
+ # Developer section
909
+ lines.append("## DEVELOPER")
910
+ if not developer:
911
+ lines.append(
912
+ f"ERROR: Not initialized. Run: python ./{DIR_WORKFLOW}/{DIR_SCRIPTS}/init_developer.py <name>"
913
+ )
914
+ return "\n".join(lines)
915
+
916
+ lines.append(f"Name: {developer}")
917
+ lines.append(artifact_locale_summary(repo_root))
918
+ lines.append("")
919
+
920
+ root_git_info = _collect_root_git_info(repo_root)
921
+ _append_root_git_context(lines, root_git_info)
922
+
923
+ # Package git repos — independent sub-repositories
924
+ _append_package_git_context(
925
+ lines,
926
+ _collect_package_git_info(
927
+ repo_root,
928
+ discover_unconfigured=not root_git_info["isRepo"],
929
+ ),
930
+ )
931
+
932
+ # Selected task
933
+ lines.append("## SELECTED TASK")
934
+ selected_task = get_selected_task(repo_root)
935
+ if selected_task:
936
+ selected_task_dir = repo_root / selected_task
937
+ source_type, context_key, _ = get_selected_task_source(repo_root)
938
+ lines.append(f"Path: {selected_task}")
939
+ lines.append(
940
+ f"Source: {source_type}" + (f":{context_key}" if context_key else "")
941
+ )
942
+
943
+ ct = load_task(selected_task_dir)
944
+ if ct:
945
+ lines.append(f"Name: {ct.name}")
946
+ lines.append(f"Status: {ct.status}")
947
+ lines.append(f"Created: {ct.raw.get('createdAt', 'unknown')}")
948
+ if ct.description:
949
+ lines.append(f"Description: {ct.description}")
950
+
951
+ # Check for prd.md
952
+ prd_file = selected_task_dir / "prd.md"
953
+ if prd_file.is_file():
954
+ lines.append("")
955
+ lines.append("[!] This task has prd.md - read it for task details")
956
+ else:
957
+ lines.append("(none)")
958
+ lines.append("")
959
+
960
+ _append_retrieval_guide(lines, repo_root, selected_task)
961
+
962
+ lines.append("## TASK DASHBOARD")
963
+ lines.extend(render_task_dashboard(repo_root).splitlines())
964
+ lines.append("")
965
+
966
+ # Active tasks
967
+ lines.append("## ACTIVE TASKS")
968
+ tasks_dir = get_tasks_dir(repo_root)
969
+ task_count = 0
970
+
971
+ # Collect all task data for hierarchy display
972
+ all_tasks = {t.dir_name: t for t in iter_active_tasks(tasks_dir)}
973
+ all_statuses = {name: t.status for name, t in all_tasks.items()}
974
+
975
+ def _print_task_tree(name: str, indent: int = 0) -> None:
976
+ nonlocal task_count
977
+ t = all_tasks[name]
978
+ progress = children_progress(t.children, all_statuses)
979
+ prefix = " " * indent
980
+ lines.append(f"{prefix}- {name}/ ({t.status}){progress} @{t.assignee or '-'}")
981
+ task_count += 1
982
+ for child in t.children:
983
+ if child in all_tasks:
984
+ _print_task_tree(child, indent + 1)
985
+
986
+ for dir_name in sorted(all_tasks.keys()):
987
+ if not all_tasks[dir_name].parent:
988
+ _print_task_tree(dir_name)
989
+
990
+ if task_count == 0:
991
+ lines.append("(no active tasks)")
992
+ lines.append(f"Total: {task_count} active task(s)")
993
+ lines.append("")
994
+
995
+ # My tasks
996
+ lines.append("## MY TASKS (Assigned to me)")
997
+ my_task_count = 0
998
+
999
+ for t in all_tasks.values():
1000
+ if t.assignee == developer and t.status != "done":
1001
+ progress = children_progress(t.children, all_statuses)
1002
+ lines.append(f"- [{t.priority}] {t.title} ({t.status}){progress}")
1003
+ my_task_count += 1
1004
+
1005
+ if my_task_count == 0:
1006
+ lines.append("(no tasks assigned to you)")
1007
+ lines.append("")
1008
+
1009
+ # Journal file
1010
+ lines.append("## JOURNAL FILE")
1011
+ journal_file = get_active_journal_file(repo_root)
1012
+ if journal_file:
1013
+ journal_lines = count_lines(journal_file)
1014
+ relative = f"{DIR_WORKFLOW}/{DIR_WORKSPACE}/{developer}/{journal_file.name}"
1015
+ lines.append(f"Active file: {relative}")
1016
+ lines.append(f"Line count: {journal_lines} / 2000")
1017
+ if journal_lines > 1800:
1018
+ lines.append("[!] WARNING: Approaching 2000 line limit!")
1019
+ if get_journal_snippet_enabled(repo_root):
1020
+ snippet = _resolve_journal_snippet(repo_root, journal_file, developer)
1021
+ if snippet:
1022
+ lines.append(f"Recent snippet: {snippet}")
1023
+ else:
1024
+ lines.append("No journal file found")
1025
+ lines.append("")
1026
+
1027
+ # Packages
1028
+ packages_text = get_packages_section(repo_root)
1029
+ if packages_text:
1030
+ lines.append(packages_text)
1031
+ lines.append("")
1032
+
1033
+ # Paths
1034
+ lines.append("## PATHS")
1035
+ lines.append(f"Workspace: {DIR_WORKFLOW}/{DIR_WORKSPACE}/{developer}/")
1036
+ lines.append(f"Tasks: {DIR_WORKFLOW}/{DIR_TASKS}/")
1037
+ lines.append(f"Spec: {DIR_WORKFLOW}/{DIR_SPEC}/")
1038
+ lines.append("")
1039
+
1040
+ lines.append("========================================")
1041
+
1042
+ return "\n".join(lines)
1043
+
1044
+
1045
+ # =============================================================================
1046
+ # Record Mode
1047
+ # =============================================================================
1048
+
1049
+ def get_context_record_json(repo_root: Path | None = None) -> dict:
1050
+ """Get record-mode context as a dictionary.
1051
+
1052
+ Focused on: my active tasks, git status, selected task.
1053
+ """
1054
+ if repo_root is None:
1055
+ repo_root = get_repo_root()
1056
+
1057
+ developer = get_developer(repo_root)
1058
+ tasks_dir = get_tasks_dir(repo_root)
1059
+
1060
+ root_git_info = _collect_root_git_info(repo_root)
1061
+
1062
+ # My tasks (single pass — collect statuses and filter by assignee)
1063
+ all_tasks_list = list(iter_active_tasks(tasks_dir))
1064
+ all_statuses = {t.dir_name: t.status for t in all_tasks_list}
1065
+
1066
+ my_tasks = []
1067
+ for t in all_tasks_list:
1068
+ if t.assignee == developer:
1069
+ done = sum(
1070
+ 1 for c in t.children
1071
+ if all_statuses.get(c) in ("completed", "done")
1072
+ )
1073
+ my_tasks.append({
1074
+ "dir": t.dir_name,
1075
+ "title": t.title,
1076
+ "status": t.status,
1077
+ "priority": t.priority,
1078
+ "children": list(t.children),
1079
+ "childrenDone": done,
1080
+ "parent": t.parent,
1081
+ "meta": t.meta,
1082
+ })
1083
+
1084
+ # Selected task
1085
+ selected_task_info = None
1086
+ selected_task = get_selected_task(repo_root)
1087
+ if selected_task:
1088
+ source_type, context_key, _ = get_selected_task_source(repo_root)
1089
+ ct = load_task(repo_root / selected_task)
1090
+ if ct:
1091
+ selected_task_info = {
1092
+ "path": selected_task,
1093
+ "name": ct.name,
1094
+ "status": ct.status,
1095
+ "source": source_type,
1096
+ "contextKey": context_key,
1097
+ }
1098
+
1099
+ # Package git repos
1100
+ pkg_git_info = _collect_package_git_info(
1101
+ repo_root,
1102
+ discover_unconfigured=not root_git_info["isRepo"],
1103
+ )
1104
+
1105
+ result = {
1106
+ "developer": developer or "",
1107
+ "git": {
1108
+ "isRepo": root_git_info["isRepo"],
1109
+ "branch": root_git_info["branch"],
1110
+ "isClean": root_git_info["isClean"],
1111
+ "uncommittedChanges": root_git_info["uncommittedChanges"],
1112
+ "recentCommits": root_git_info["recentCommits"],
1113
+ },
1114
+ "myTasks": my_tasks,
1115
+ "selectedTask": selected_task_info,
1116
+ }
1117
+
1118
+ if pkg_git_info:
1119
+ result["packageGit"] = pkg_git_info
1120
+
1121
+ return result
1122
+
1123
+
1124
+ def get_context_text_record(repo_root: Path | None = None) -> str:
1125
+ """Get context as formatted text for record-session mode.
1126
+
1127
+ Focused output: MY ACTIVE TASKS first (with [!!!] emphasis),
1128
+ then GIT STATUS, RECENT COMMITS, SELECTED TASK.
1129
+ """
1130
+ if repo_root is None:
1131
+ repo_root = get_repo_root()
1132
+
1133
+ lines: list[str] = []
1134
+ lines.append("========================================")
1135
+ lines.append("SESSION CONTEXT (RECORD MODE)")
1136
+ lines.append("========================================")
1137
+ lines.append("")
1138
+
1139
+ developer = get_developer(repo_root)
1140
+ if not developer:
1141
+ lines.append(
1142
+ f"ERROR: Not initialized. Run: python ./{DIR_WORKFLOW}/{DIR_SCRIPTS}/init_developer.py <name>"
1143
+ )
1144
+ return "\n".join(lines)
1145
+
1146
+ # MY ACTIVE TASKS — first and prominent
1147
+ lines.append(f"## [!!!] MY ACTIVE TASKS (Assigned to {developer})")
1148
+ lines.append("[!] Review whether any should be archived before recording this session.")
1149
+ lines.append("")
1150
+
1151
+ tasks_dir = get_tasks_dir(repo_root)
1152
+ my_task_count = 0
1153
+
1154
+ # Single pass — collect all tasks and filter by assignee
1155
+ all_statuses = get_all_statuses(tasks_dir)
1156
+
1157
+ for t in iter_active_tasks(tasks_dir):
1158
+ if t.assignee == developer:
1159
+ progress = children_progress(t.children, all_statuses)
1160
+ lines.append(f"- [{t.priority}] {t.title} ({t.status}){progress} — {t.dir_name}")
1161
+ my_task_count += 1
1162
+
1163
+ if my_task_count == 0:
1164
+ lines.append("(no active tasks assigned to you)")
1165
+ lines.append("")
1166
+
1167
+ root_git_info = _collect_root_git_info(repo_root)
1168
+ _append_root_git_context(lines, root_git_info)
1169
+
1170
+ # Package git repos — independent sub-repositories
1171
+ _append_package_git_context(
1172
+ lines,
1173
+ _collect_package_git_info(
1174
+ repo_root,
1175
+ discover_unconfigured=not root_git_info["isRepo"],
1176
+ ),
1177
+ )
1178
+
1179
+ # SELECTED TASK
1180
+ lines.append("## SELECTED TASK")
1181
+ selected_task = get_selected_task(repo_root)
1182
+ if selected_task:
1183
+ source_type, context_key, _ = get_selected_task_source(repo_root)
1184
+ lines.append(f"Path: {selected_task}")
1185
+ lines.append(
1186
+ f"Source: {source_type}" + (f":{context_key}" if context_key else "")
1187
+ )
1188
+ ct = load_task(repo_root / selected_task)
1189
+ if ct:
1190
+ lines.append(f"Name: {ct.name}")
1191
+ lines.append(f"Status: {ct.status}")
1192
+ else:
1193
+ lines.append("(none)")
1194
+ lines.append("")
1195
+
1196
+ lines.append("========================================")
1197
+
1198
+ return "\n".join(lines)
1199
+
1200
+
1201
+ def output_text(repo_root: Path | None = None) -> None:
1202
+ """Output context in text format.
1203
+
1204
+ Args:
1205
+ repo_root: Repository root path. Defaults to auto-detected.
1206
+ """
1207
+ if repo_root is None:
1208
+ repo_root = get_repo_root()
1209
+ update_hint = _get_update_hint(repo_root)
1210
+ if update_hint:
1211
+ print(update_hint)
1212
+ print("")
1213
+ print(get_context_text(repo_root))