@code-yeongyu/senpi 2026.8.1 → 2026.8.3-3

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 (1053) hide show
  1. package/CHANGELOG.md +74 -0
  2. package/README.md +10 -0
  3. package/dist/cli/args.d.ts +2 -0
  4. package/dist/cli/args.d.ts.map +1 -1
  5. package/dist/cli/args.js +28 -0
  6. package/dist/cli/args.js.map +1 -1
  7. package/dist/cli/credential-print.d.ts +23 -0
  8. package/dist/cli/credential-print.d.ts.map +1 -0
  9. package/dist/cli/credential-print.js +116 -0
  10. package/dist/cli/credential-print.js.map +1 -0
  11. package/dist/client/index.d.ts +3 -0
  12. package/dist/client/index.d.ts.map +1 -0
  13. package/dist/client/index.js +3 -0
  14. package/dist/client/index.js.map +1 -0
  15. package/dist/client/remote-session.d.ts +53 -0
  16. package/dist/client/remote-session.d.ts.map +1 -0
  17. package/dist/client/remote-session.js +340 -0
  18. package/dist/client/remote-session.js.map +1 -0
  19. package/dist/client/transcript.d.ts +12 -0
  20. package/dist/client/transcript.d.ts.map +1 -0
  21. package/dist/client/transcript.js +98 -0
  22. package/dist/client/transcript.js.map +1 -0
  23. package/dist/core/agent-session-runtime.d.ts.map +1 -1
  24. package/dist/core/agent-session-runtime.js +3 -0
  25. package/dist/core/agent-session-runtime.js.map +1 -1
  26. package/dist/core/agent-session.d.ts +40 -1
  27. package/dist/core/agent-session.d.ts.map +1 -1
  28. package/dist/core/agent-session.js +434 -53
  29. package/dist/core/agent-session.js.map +1 -1
  30. package/dist/core/auth-storage.d.ts +5 -0
  31. package/dist/core/auth-storage.d.ts.map +1 -1
  32. package/dist/core/auth-storage.js +72 -11
  33. package/dist/core/auth-storage.js.map +1 -1
  34. package/dist/core/dynamic-prompt/verification.d.ts +2 -2
  35. package/dist/core/dynamic-prompt/verification.d.ts.map +1 -1
  36. package/dist/core/dynamic-prompt/verification.js +2 -2
  37. package/dist/core/dynamic-prompt/verification.js.map +1 -1
  38. package/dist/core/extensions/builtin/claude-sdk-oauth/bounded-queue.d.ts +17 -0
  39. package/dist/core/extensions/builtin/claude-sdk-oauth/bounded-queue.d.ts.map +1 -0
  40. package/dist/core/extensions/builtin/claude-sdk-oauth/bounded-queue.js +56 -0
  41. package/dist/core/extensions/builtin/claude-sdk-oauth/bounded-queue.js.map +1 -0
  42. package/dist/core/extensions/builtin/claude-sdk-oauth/sdk-boundary.d.ts +1 -0
  43. package/dist/core/extensions/builtin/claude-sdk-oauth/sdk-boundary.d.ts.map +1 -1
  44. package/dist/core/extensions/builtin/claude-sdk-oauth/sdk-boundary.js.map +1 -1
  45. package/dist/core/extensions/builtin/claude-sdk-oauth/session-binding.d.ts +32 -0
  46. package/dist/core/extensions/builtin/claude-sdk-oauth/session-binding.d.ts.map +1 -0
  47. package/dist/core/extensions/builtin/claude-sdk-oauth/session-binding.js +43 -0
  48. package/dist/core/extensions/builtin/claude-sdk-oauth/session-binding.js.map +1 -0
  49. package/dist/core/extensions/builtin/claude-sdk-oauth/session-commit-boundary.d.ts +18 -0
  50. package/dist/core/extensions/builtin/claude-sdk-oauth/session-commit-boundary.d.ts.map +1 -0
  51. package/dist/core/extensions/builtin/claude-sdk-oauth/session-commit-boundary.js +46 -0
  52. package/dist/core/extensions/builtin/claude-sdk-oauth/session-commit-boundary.js.map +1 -0
  53. package/dist/core/extensions/builtin/claude-sdk-oauth/session-continuity.d.ts +81 -0
  54. package/dist/core/extensions/builtin/claude-sdk-oauth/session-continuity.d.ts.map +1 -0
  55. package/dist/core/extensions/builtin/claude-sdk-oauth/session-continuity.js +127 -0
  56. package/dist/core/extensions/builtin/claude-sdk-oauth/session-continuity.js.map +1 -0
  57. package/dist/core/extensions/builtin/claude-sdk-oauth/session-entry-annotations.d.ts +10 -0
  58. package/dist/core/extensions/builtin/claude-sdk-oauth/session-entry-annotations.d.ts.map +1 -0
  59. package/dist/core/extensions/builtin/claude-sdk-oauth/session-entry-annotations.js +34 -0
  60. package/dist/core/extensions/builtin/claude-sdk-oauth/session-entry-annotations.js.map +1 -0
  61. package/dist/core/extensions/builtin/claude-sdk-oauth/session-observability.d.ts +56 -0
  62. package/dist/core/extensions/builtin/claude-sdk-oauth/session-observability.d.ts.map +1 -0
  63. package/dist/core/extensions/builtin/claude-sdk-oauth/session-observability.js +174 -0
  64. package/dist/core/extensions/builtin/claude-sdk-oauth/session-observability.js.map +1 -0
  65. package/dist/core/extensions/builtin/claude-sdk-oauth/session-reaper.d.ts +24 -0
  66. package/dist/core/extensions/builtin/claude-sdk-oauth/session-reaper.d.ts.map +1 -0
  67. package/dist/core/extensions/builtin/claude-sdk-oauth/session-reaper.js +34 -0
  68. package/dist/core/extensions/builtin/claude-sdk-oauth/session-reaper.js.map +1 -0
  69. package/dist/core/extensions/builtin/claude-sdk-oauth/session-reattach.d.ts +34 -0
  70. package/dist/core/extensions/builtin/claude-sdk-oauth/session-reattach.d.ts.map +1 -0
  71. package/dist/core/extensions/builtin/claude-sdk-oauth/session-reattach.js +85 -0
  72. package/dist/core/extensions/builtin/claude-sdk-oauth/session-reattach.js.map +1 -0
  73. package/dist/core/extensions/builtin/claude-sdk-oauth/session-registry-pump.d.ts +2 -13
  74. package/dist/core/extensions/builtin/claude-sdk-oauth/session-registry-pump.d.ts.map +1 -1
  75. package/dist/core/extensions/builtin/claude-sdk-oauth/session-registry-pump.js +34 -55
  76. package/dist/core/extensions/builtin/claude-sdk-oauth/session-registry-pump.js.map +1 -1
  77. package/dist/core/extensions/builtin/claude-sdk-oauth/session-registry-wiring.d.ts.map +1 -1
  78. package/dist/core/extensions/builtin/claude-sdk-oauth/session-registry-wiring.js +35 -93
  79. package/dist/core/extensions/builtin/claude-sdk-oauth/session-registry-wiring.js.map +1 -1
  80. package/dist/core/extensions/builtin/claude-sdk-oauth/session-registry.d.ts +13 -11
  81. package/dist/core/extensions/builtin/claude-sdk-oauth/session-registry.d.ts.map +1 -1
  82. package/dist/core/extensions/builtin/claude-sdk-oauth/session-registry.js +44 -55
  83. package/dist/core/extensions/builtin/claude-sdk-oauth/session-registry.js.map +1 -1
  84. package/dist/core/extensions/builtin/claude-sdk-oauth/session-stream.d.ts +3 -1
  85. package/dist/core/extensions/builtin/claude-sdk-oauth/session-stream.d.ts.map +1 -1
  86. package/dist/core/extensions/builtin/claude-sdk-oauth/session-stream.js +101 -126
  87. package/dist/core/extensions/builtin/claude-sdk-oauth/session-stream.js.map +1 -1
  88. package/dist/core/extensions/builtin/claude-sdk-oauth/session-sync.d.ts +2 -31
  89. package/dist/core/extensions/builtin/claude-sdk-oauth/session-sync.d.ts.map +1 -1
  90. package/dist/core/extensions/builtin/claude-sdk-oauth/session-sync.js +26 -98
  91. package/dist/core/extensions/builtin/claude-sdk-oauth/session-sync.js.map +1 -1
  92. package/dist/core/extensions/builtin/claude-sdk-oauth/session-turn-claim.d.ts +14 -0
  93. package/dist/core/extensions/builtin/claude-sdk-oauth/session-turn-claim.d.ts.map +1 -0
  94. package/dist/core/extensions/builtin/claude-sdk-oauth/session-turn-claim.js +42 -0
  95. package/dist/core/extensions/builtin/claude-sdk-oauth/session-turn-claim.js.map +1 -0
  96. package/dist/core/extensions/builtin/claude-sdk-oauth/session-turn-types.d.ts +32 -0
  97. package/dist/core/extensions/builtin/claude-sdk-oauth/session-turn-types.d.ts.map +1 -0
  98. package/dist/core/extensions/builtin/claude-sdk-oauth/session-turn-types.js +8 -0
  99. package/dist/core/extensions/builtin/claude-sdk-oauth/session-turn-types.js.map +1 -0
  100. package/dist/core/extensions/builtin/claude-sdk-oauth/stream-events.d.ts +16 -0
  101. package/dist/core/extensions/builtin/claude-sdk-oauth/stream-events.d.ts.map +1 -0
  102. package/dist/core/extensions/builtin/claude-sdk-oauth/stream-events.js +92 -0
  103. package/dist/core/extensions/builtin/claude-sdk-oauth/stream-events.js.map +1 -0
  104. package/dist/core/extensions/builtin/claude-sdk-oauth/stream.d.ts.map +1 -1
  105. package/dist/core/extensions/builtin/claude-sdk-oauth/stream.js +48 -88
  106. package/dist/core/extensions/builtin/claude-sdk-oauth/stream.js.map +1 -1
  107. package/dist/core/extensions/builtin/claude-sdk-oauth/tools.d.ts +1 -0
  108. package/dist/core/extensions/builtin/claude-sdk-oauth/tools.d.ts.map +1 -1
  109. package/dist/core/extensions/builtin/claude-sdk-oauth/tools.js +1 -0
  110. package/dist/core/extensions/builtin/claude-sdk-oauth/tools.js.map +1 -1
  111. package/dist/core/extensions/builtin/compaction/checkpoint-state.d.ts +18 -1
  112. package/dist/core/extensions/builtin/compaction/checkpoint-state.d.ts.map +1 -1
  113. package/dist/core/extensions/builtin/compaction/checkpoint-state.js +32 -0
  114. package/dist/core/extensions/builtin/compaction/checkpoint-state.js.map +1 -1
  115. package/dist/core/extensions/builtin/compaction/deterministic-fallback.d.ts +1 -1
  116. package/dist/core/extensions/builtin/compaction/deterministic-fallback.d.ts.map +1 -1
  117. package/dist/core/extensions/builtin/compaction/deterministic-fallback.js +4 -0
  118. package/dist/core/extensions/builtin/compaction/deterministic-fallback.js.map +1 -1
  119. package/dist/core/extensions/builtin/compaction/idle-retry.d.ts +21 -0
  120. package/dist/core/extensions/builtin/compaction/idle-retry.d.ts.map +1 -0
  121. package/dist/core/extensions/builtin/compaction/idle-retry.js +24 -0
  122. package/dist/core/extensions/builtin/compaction/idle-retry.js.map +1 -0
  123. package/dist/core/extensions/builtin/compaction/index.d.ts.map +1 -1
  124. package/dist/core/extensions/builtin/compaction/index.js +91 -13
  125. package/dist/core/extensions/builtin/compaction/index.js.map +1 -1
  126. package/dist/core/extensions/builtin/compaction/lane-policy.d.ts +71 -0
  127. package/dist/core/extensions/builtin/compaction/lane-policy.d.ts.map +1 -0
  128. package/dist/core/extensions/builtin/compaction/lane-policy.js +94 -0
  129. package/dist/core/extensions/builtin/compaction/lane-policy.js.map +1 -0
  130. package/dist/core/extensions/builtin/compaction/log.d.ts.map +1 -1
  131. package/dist/core/extensions/builtin/compaction/log.js +1 -0
  132. package/dist/core/extensions/builtin/compaction/log.js.map +1 -1
  133. package/dist/core/extensions/builtin/compaction/overflow-retry.d.ts +59 -0
  134. package/dist/core/extensions/builtin/compaction/overflow-retry.d.ts.map +1 -0
  135. package/dist/core/extensions/builtin/compaction/overflow-retry.js +155 -0
  136. package/dist/core/extensions/builtin/compaction/overflow-retry.js.map +1 -0
  137. package/dist/core/extensions/builtin/compaction/speculative.d.ts.map +1 -1
  138. package/dist/core/extensions/builtin/compaction/speculative.js +17 -98
  139. package/dist/core/extensions/builtin/compaction/speculative.js.map +1 -1
  140. package/dist/core/extensions/builtin/compaction/transient-failure.d.ts.map +1 -1
  141. package/dist/core/extensions/builtin/compaction/transient-failure.js +3 -0
  142. package/dist/core/extensions/builtin/compaction/transient-failure.js.map +1 -1
  143. package/dist/core/extensions/builtin/goal/continuation.d.ts +2 -1
  144. package/dist/core/extensions/builtin/goal/continuation.d.ts.map +1 -1
  145. package/dist/core/extensions/builtin/goal/continuation.js +2 -1
  146. package/dist/core/extensions/builtin/goal/continuation.js.map +1 -1
  147. package/dist/core/extensions/builtin/goal/index.d.ts.map +1 -1
  148. package/dist/core/extensions/builtin/goal/index.js +14 -1
  149. package/dist/core/extensions/builtin/goal/index.js.map +1 -1
  150. package/dist/core/extensions/builtin/goal/monitor-continuation.d.ts +3 -2
  151. package/dist/core/extensions/builtin/goal/monitor-continuation.d.ts.map +1 -1
  152. package/dist/core/extensions/builtin/goal/monitor-continuation.js +89 -46
  153. package/dist/core/extensions/builtin/goal/monitor-continuation.js.map +1 -1
  154. package/dist/core/extensions/builtin/goal/wait-progress.d.ts +11 -0
  155. package/dist/core/extensions/builtin/goal/wait-progress.d.ts.map +1 -0
  156. package/dist/core/extensions/builtin/goal/wait-progress.js +30 -0
  157. package/dist/core/extensions/builtin/goal/wait-progress.js.map +1 -0
  158. package/dist/core/extensions/builtin/goal/wait-ticker.d.ts +38 -0
  159. package/dist/core/extensions/builtin/goal/wait-ticker.d.ts.map +1 -0
  160. package/dist/core/extensions/builtin/goal/wait-ticker.js +71 -0
  161. package/dist/core/extensions/builtin/goal/wait-ticker.js.map +1 -0
  162. package/dist/core/extensions/builtin/gpt-apply-patch/apply.d.ts +1 -0
  163. package/dist/core/extensions/builtin/gpt-apply-patch/apply.d.ts.map +1 -1
  164. package/dist/core/extensions/builtin/gpt-apply-patch/apply.js +13 -1
  165. package/dist/core/extensions/builtin/gpt-apply-patch/apply.js.map +1 -1
  166. package/dist/core/extensions/builtin/gpt-apply-patch/index.d.ts +1 -1
  167. package/dist/core/extensions/builtin/gpt-apply-patch/index.d.ts.map +1 -1
  168. package/dist/core/extensions/builtin/gpt-apply-patch/index.js +1 -1
  169. package/dist/core/extensions/builtin/gpt-apply-patch/index.js.map +1 -1
  170. package/dist/core/extensions/builtin/gpt-apply-patch/tool.d.ts +1 -0
  171. package/dist/core/extensions/builtin/gpt-apply-patch/tool.d.ts.map +1 -1
  172. package/dist/core/extensions/builtin/gpt-apply-patch/tool.js +23 -5
  173. package/dist/core/extensions/builtin/gpt-apply-patch/tool.js.map +1 -1
  174. package/dist/core/extensions/builtin/loop-guard/detectors.d.ts.map +1 -1
  175. package/dist/core/extensions/builtin/loop-guard/detectors.js +42 -1
  176. package/dist/core/extensions/builtin/loop-guard/detectors.js.map +1 -1
  177. package/dist/core/extensions/builtin/mcp/health.d.ts.map +1 -1
  178. package/dist/core/extensions/builtin/mcp/health.js +2 -1
  179. package/dist/core/extensions/builtin/mcp/health.js.map +1 -1
  180. package/dist/core/extensions/builtin/prompt-preset/gpt-5.6.d.ts +1 -1
  181. package/dist/core/extensions/builtin/prompt-preset/gpt-5.6.d.ts.map +1 -1
  182. package/dist/core/extensions/builtin/prompt-preset/gpt-5.6.js +5 -3
  183. package/dist/core/extensions/builtin/prompt-preset/gpt-5.6.js.map +1 -1
  184. package/dist/core/extensions/builtin/prompt-preset/kimi-k3.d.ts.map +1 -1
  185. package/dist/core/extensions/builtin/prompt-preset/kimi-k3.js +8 -1
  186. package/dist/core/extensions/builtin/prompt-preset/kimi-k3.js.map +1 -1
  187. package/dist/core/extensions/builtin/rules/config.d.ts +3 -0
  188. package/dist/core/extensions/builtin/rules/config.d.ts.map +1 -0
  189. package/dist/core/extensions/builtin/rules/config.js +24 -0
  190. package/dist/core/extensions/builtin/rules/config.js.map +1 -0
  191. package/dist/core/extensions/builtin/rules/index.d.ts.map +1 -1
  192. package/dist/core/extensions/builtin/rules/index.js +5 -3
  193. package/dist/core/extensions/builtin/rules/index.js.map +1 -1
  194. package/dist/core/extensions/builtin/rules/rules/formatter.d.ts.map +1 -1
  195. package/dist/core/extensions/builtin/rules/rules/formatter.js +21 -5
  196. package/dist/core/extensions/builtin/rules/rules/formatter.js.map +1 -1
  197. package/dist/core/extensions/builtin/rules/rules/types.d.ts +1 -1
  198. package/dist/core/extensions/builtin/rules/rules/types.js.map +1 -1
  199. package/dist/core/extensions/builtin/service-tier.d.ts.map +1 -1
  200. package/dist/core/extensions/builtin/service-tier.js +2 -3
  201. package/dist/core/extensions/builtin/service-tier.js.map +1 -1
  202. package/dist/core/extensions/builtin/terminal/tools/context.d.ts +1 -1
  203. package/dist/core/extensions/builtin/terminal/tools/context.d.ts.map +1 -1
  204. package/dist/core/extensions/builtin/terminal/tools/context.js.map +1 -1
  205. package/dist/core/extensions/builtin/terminal/tools/monitor.d.ts.map +1 -1
  206. package/dist/core/extensions/builtin/terminal/tools/monitor.js +1 -0
  207. package/dist/core/extensions/builtin/terminal/tools/monitor.js.map +1 -1
  208. package/dist/core/extensions/builtin/tool-pair-guard/index.d.ts.map +1 -1
  209. package/dist/core/extensions/builtin/tool-pair-guard/index.js +1 -1
  210. package/dist/core/extensions/builtin/tool-pair-guard/index.js.map +1 -1
  211. package/dist/core/extensions/index.d.ts +1 -1
  212. package/dist/core/extensions/index.d.ts.map +1 -1
  213. package/dist/core/extensions/index.js.map +1 -1
  214. package/dist/core/extensions/loader.d.ts.map +1 -1
  215. package/dist/core/extensions/loader.js +14 -18
  216. package/dist/core/extensions/loader.js.map +1 -1
  217. package/dist/core/extensions/runner.d.ts +4 -1
  218. package/dist/core/extensions/runner.d.ts.map +1 -1
  219. package/dist/core/extensions/runner.js +18 -0
  220. package/dist/core/extensions/runner.js.map +1 -1
  221. package/dist/core/extensions/types.d.ts +16 -1
  222. package/dist/core/extensions/types.d.ts.map +1 -1
  223. package/dist/core/extensions/types.js.map +1 -1
  224. package/dist/core/footer-data-provider.d.ts +10 -0
  225. package/dist/core/footer-data-provider.d.ts.map +1 -1
  226. package/dist/core/footer-data-provider.js +1 -1
  227. package/dist/core/footer-data-provider.js.map +1 -1
  228. package/dist/core/keybindings.d.ts +24 -0
  229. package/dist/core/keybindings.d.ts.map +1 -1
  230. package/dist/core/model-registry.d.ts +2 -1
  231. package/dist/core/model-registry.d.ts.map +1 -1
  232. package/dist/core/model-registry.js +3 -0
  233. package/dist/core/model-registry.js.map +1 -1
  234. package/dist/core/model-resolver.d.ts.map +1 -1
  235. package/dist/core/model-resolver.js +1 -0
  236. package/dist/core/model-resolver.js.map +1 -1
  237. package/dist/core/model-runtime.d.ts +2 -0
  238. package/dist/core/model-runtime.d.ts.map +1 -1
  239. package/dist/core/model-runtime.js +2 -2
  240. package/dist/core/model-runtime.js.map +1 -1
  241. package/dist/core/package-manager.d.ts +0 -1
  242. package/dist/core/package-manager.d.ts.map +1 -1
  243. package/dist/core/package-manager.js +18 -34
  244. package/dist/core/package-manager.js.map +1 -1
  245. package/dist/core/pi-manifest.d.ts +9 -0
  246. package/dist/core/pi-manifest.d.ts.map +1 -0
  247. package/dist/core/pi-manifest.js +25 -0
  248. package/dist/core/pi-manifest.js.map +1 -0
  249. package/dist/core/provider-composer.d.ts.map +1 -1
  250. package/dist/core/provider-composer.js +8 -3
  251. package/dist/core/provider-composer.js.map +1 -1
  252. package/dist/core/provider-display-names.d.ts.map +1 -1
  253. package/dist/core/provider-display-names.js +1 -0
  254. package/dist/core/provider-display-names.js.map +1 -1
  255. package/dist/core/resource-loader.d.ts +15 -0
  256. package/dist/core/resource-loader.d.ts.map +1 -1
  257. package/dist/core/resource-loader.js +55 -6
  258. package/dist/core/resource-loader.js.map +1 -1
  259. package/dist/core/retry-fallback/hint-policy.d.ts +29 -0
  260. package/dist/core/retry-fallback/hint-policy.d.ts.map +1 -0
  261. package/dist/core/retry-fallback/hint-policy.js +54 -0
  262. package/dist/core/retry-fallback/hint-policy.js.map +1 -0
  263. package/dist/core/retry-fallback/probe-scheduler.d.ts +60 -0
  264. package/dist/core/retry-fallback/probe-scheduler.d.ts.map +1 -0
  265. package/dist/core/retry-fallback/probe-scheduler.js +206 -0
  266. package/dist/core/retry-fallback/probe-scheduler.js.map +1 -0
  267. package/dist/core/retry-fallback/settings.d.ts +9 -0
  268. package/dist/core/retry-fallback/settings.d.ts.map +1 -1
  269. package/dist/core/retry-fallback/settings.js +14 -0
  270. package/dist/core/retry-fallback/settings.js.map +1 -1
  271. package/dist/core/session-log.js +1 -1
  272. package/dist/core/session-log.js.map +1 -1
  273. package/dist/core/settings-manager.d.ts +10 -1
  274. package/dist/core/settings-manager.d.ts.map +1 -1
  275. package/dist/core/settings-manager.js +21 -1
  276. package/dist/core/settings-manager.js.map +1 -1
  277. package/dist/extensions/llama/provider.js +1 -1
  278. package/dist/extensions/llama/provider.js.map +1 -1
  279. package/dist/index.d.ts +2 -2
  280. package/dist/index.d.ts.map +1 -1
  281. package/dist/index.js.map +1 -1
  282. package/dist/main.d.ts.map +1 -1
  283. package/dist/main.js +44 -0
  284. package/dist/main.js.map +1 -1
  285. package/dist/modes/interactive/components/assistant-message.d.ts +5 -2
  286. package/dist/modes/interactive/components/assistant-message.d.ts.map +1 -1
  287. package/dist/modes/interactive/components/assistant-message.js +16 -4
  288. package/dist/modes/interactive/components/assistant-message.js.map +1 -1
  289. package/dist/modes/interactive/components/continuity-notice.d.ts +21 -0
  290. package/dist/modes/interactive/components/continuity-notice.d.ts.map +1 -0
  291. package/dist/modes/interactive/components/continuity-notice.js +58 -0
  292. package/dist/modes/interactive/components/continuity-notice.js.map +1 -0
  293. package/dist/modes/interactive/components/custom-editor.d.ts +5 -0
  294. package/dist/modes/interactive/components/custom-editor.d.ts.map +1 -1
  295. package/dist/modes/interactive/components/custom-editor.js +22 -1
  296. package/dist/modes/interactive/components/custom-editor.js.map +1 -1
  297. package/dist/modes/interactive/components/markdown-transform.d.ts +3 -0
  298. package/dist/modes/interactive/components/markdown-transform.d.ts.map +1 -0
  299. package/dist/modes/interactive/components/markdown-transform.js +19 -0
  300. package/dist/modes/interactive/components/markdown-transform.js.map +1 -0
  301. package/dist/modes/interactive/components/model-selector.d.ts.map +1 -1
  302. package/dist/modes/interactive/components/model-selector.js +4 -1
  303. package/dist/modes/interactive/components/model-selector.js.map +1 -1
  304. package/dist/modes/interactive/components/settings-selector.d.ts +6 -2
  305. package/dist/modes/interactive/components/settings-selector.d.ts.map +1 -1
  306. package/dist/modes/interactive/components/settings-selector.js +20 -0
  307. package/dist/modes/interactive/components/settings-selector.js.map +1 -1
  308. package/dist/modes/interactive/components/user-message.d.ts +3 -1
  309. package/dist/modes/interactive/components/user-message.d.ts.map +1 -1
  310. package/dist/modes/interactive/components/user-message.js +8 -2
  311. package/dist/modes/interactive/components/user-message.js.map +1 -1
  312. package/dist/modes/interactive/help-content.d.ts.map +1 -1
  313. package/dist/modes/interactive/help-content.js +1 -0
  314. package/dist/modes/interactive/help-content.js.map +1 -1
  315. package/dist/modes/interactive/interactive-mode.d.ts +21 -0
  316. package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
  317. package/dist/modes/interactive/interactive-mode.js +151 -50
  318. package/dist/modes/interactive/interactive-mode.js.map +1 -1
  319. package/dist/modes/interactive/theme/dark.json +1 -0
  320. package/dist/modes/interactive/theme/grok-day.json +1 -0
  321. package/dist/modes/interactive/theme/grok-night.json +1 -0
  322. package/dist/modes/interactive/theme/light.json +1 -0
  323. package/dist/modes/interactive/theme/theme-schema.json +5 -1
  324. package/dist/modes/interactive/theme/theme.d.ts +2 -2
  325. package/dist/modes/interactive/theme/theme.d.ts.map +1 -1
  326. package/dist/modes/interactive/theme/theme.js +13 -3
  327. package/dist/modes/interactive/theme/theme.js.map +1 -1
  328. package/dist/modes/rpc/connection-handler.d.ts.map +1 -1
  329. package/dist/modes/rpc/connection-handler.js +13 -0
  330. package/dist/modes/rpc/connection-handler.js.map +1 -1
  331. package/dist/utils/clipboard.d.ts +1 -1
  332. package/dist/utils/clipboard.d.ts.map +1 -1
  333. package/dist/utils/clipboard.js +22 -2
  334. package/dist/utils/clipboard.js.map +1 -1
  335. package/docs/AGENTS.md +1 -6
  336. package/docs/custom-provider.md +10 -3
  337. package/docs/development.md +1 -2
  338. package/docs/extensions.md +24 -1
  339. package/docs/keybindings.md +13 -0
  340. package/docs/mcp.md +63 -4
  341. package/docs/models.md +1 -0
  342. package/docs/providers.md +39 -0
  343. package/docs/release-guide.md +5 -3
  344. package/docs/session-format.md +2 -0
  345. package/docs/settings.md +2 -0
  346. package/docs/skills.md +29 -0
  347. package/docs/themes.md +5 -3
  348. package/docs/usage.md +5 -0
  349. package/examples/extensions/custom-compaction.ts +1 -2
  350. package/examples/extensions/custom-provider-anthropic/index.ts +8 -2
  351. package/examples/extensions/doom-overlay/wad-finder.ts +7 -3
  352. package/examples/extensions/handoff.ts +2 -3
  353. package/examples/extensions/qna.ts +2 -2
  354. package/examples/rpc-extension-ui.ts +11 -2
  355. package/examples/sdk/02-custom-model.ts +1 -2
  356. package/examples/sdk/12-full-control.ts +2 -0
  357. package/node_modules/@code-yeongyu/senpi-codemode/CHANGELOG.md +36 -0
  358. package/node_modules/@code-yeongyu/senpi-codemode/package.json +4 -4
  359. package/node_modules/@earendil-works/pi-agent-core/dist/harness/agent-harness.d.ts +14 -3
  360. package/node_modules/@earendil-works/pi-agent-core/dist/harness/agent-harness.d.ts.map +1 -1
  361. package/node_modules/@earendil-works/pi-agent-core/dist/harness/agent-harness.js +156 -67
  362. package/node_modules/@earendil-works/pi-agent-core/dist/harness/agent-harness.js.map +1 -1
  363. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/array-session-reader.d.ts +3 -0
  364. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/array-session-reader.d.ts.map +1 -0
  365. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/array-session-reader.js +70 -0
  366. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/array-session-reader.js.map +1 -0
  367. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/fork.d.ts +4 -0
  368. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/fork.d.ts.map +1 -0
  369. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/fork.js +22 -0
  370. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/fork.js.map +1 -0
  371. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/jsonl-store.d.ts +13 -0
  372. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/jsonl-store.d.ts.map +1 -0
  373. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/jsonl-store.js +304 -0
  374. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/jsonl-store.js.map +1 -0
  375. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/keyed-operation-queue.d.ts +17 -0
  376. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/keyed-operation-queue.d.ts.map +1 -0
  377. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/keyed-operation-queue.js +60 -0
  378. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/keyed-operation-queue.js.map +1 -0
  379. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/memory-store.d.ts +6 -0
  380. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/memory-store.d.ts.map +1 -0
  381. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/memory-store.js +107 -0
  382. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/memory-store.js.map +1 -0
  383. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/repository.d.ts +28 -0
  384. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/repository.d.ts.map +1 -0
  385. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/repository.js +61 -0
  386. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/repository.js.map +1 -0
  387. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/search-backend.d.ts +8 -0
  388. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/search-backend.d.ts.map +1 -0
  389. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/search-backend.js +22 -0
  390. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/search-backend.js.map +1 -0
  391. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/session.d.ts +6 -10
  392. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/session.d.ts.map +1 -1
  393. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/session.js +154 -77
  394. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/session.js.map +1 -1
  395. package/node_modules/@earendil-works/pi-agent-core/dist/harness/types.d.ts +49 -23
  396. package/node_modules/@earendil-works/pi-agent-core/dist/harness/types.d.ts.map +1 -1
  397. package/node_modules/@earendil-works/pi-agent-core/dist/harness/types.js.map +1 -1
  398. package/node_modules/@earendil-works/pi-agent-core/dist/index.d.ts +6 -6
  399. package/node_modules/@earendil-works/pi-agent-core/dist/index.d.ts.map +1 -1
  400. package/node_modules/@earendil-works/pi-agent-core/dist/index.js +6 -6
  401. package/node_modules/@earendil-works/pi-agent-core/dist/index.js.map +1 -1
  402. package/node_modules/@earendil-works/pi-agent-core/dist/proxy.js +1 -1
  403. package/node_modules/@earendil-works/pi-agent-core/dist/proxy.js.map +1 -1
  404. package/node_modules/@earendil-works/pi-agent-core/package.json +4 -4
  405. package/node_modules/@earendil-works/pi-ai/README.md +5 -2
  406. package/node_modules/@earendil-works/pi-ai/dist/api/anthropic-messages.d.ts.map +1 -1
  407. package/node_modules/@earendil-works/pi-ai/dist/api/anthropic-messages.js +46 -10
  408. package/node_modules/@earendil-works/pi-ai/dist/api/anthropic-messages.js.map +1 -1
  409. package/node_modules/@earendil-works/pi-ai/dist/api/anthropic-tool-pairs.d.ts +3 -0
  410. package/node_modules/@earendil-works/pi-ai/dist/api/anthropic-tool-pairs.d.ts.map +1 -0
  411. package/{dist/core/extensions/builtin/tool-pair-guard/sanitize-anthropic-payload.js → node_modules/@earendil-works/pi-ai/dist/api/anthropic-tool-pairs.js} +3 -3
  412. package/node_modules/@earendil-works/pi-ai/dist/api/anthropic-tool-pairs.js.map +1 -0
  413. package/node_modules/@earendil-works/pi-ai/dist/api/azure-openai-responses.d.ts.map +1 -1
  414. package/node_modules/@earendil-works/pi-ai/dist/api/azure-openai-responses.js +5 -1
  415. package/node_modules/@earendil-works/pi-ai/dist/api/azure-openai-responses.js.map +1 -1
  416. package/node_modules/@earendil-works/pi-ai/dist/api/bedrock-converse-stream.d.ts.map +1 -1
  417. package/node_modules/@earendil-works/pi-ai/dist/api/bedrock-converse-stream.js +64 -4
  418. package/node_modules/@earendil-works/pi-ai/dist/api/bedrock-converse-stream.js.map +1 -1
  419. package/node_modules/@earendil-works/pi-ai/dist/api/google-generative-ai.d.ts.map +1 -1
  420. package/node_modules/@earendil-works/pi-ai/dist/api/google-generative-ai.js +12 -2
  421. package/node_modules/@earendil-works/pi-ai/dist/api/google-generative-ai.js.map +1 -1
  422. package/node_modules/@earendil-works/pi-ai/dist/api/google-shared.d.ts.map +1 -1
  423. package/node_modules/@earendil-works/pi-ai/dist/api/google-shared.js +13 -6
  424. package/node_modules/@earendil-works/pi-ai/dist/api/google-shared.js.map +1 -1
  425. package/node_modules/@earendil-works/pi-ai/dist/api/google-vertex.d.ts.map +1 -1
  426. package/node_modules/@earendil-works/pi-ai/dist/api/google-vertex.js +12 -2
  427. package/node_modules/@earendil-works/pi-ai/dist/api/google-vertex.js.map +1 -1
  428. package/node_modules/@earendil-works/pi-ai/dist/api/mistral-conversations.d.ts.map +1 -1
  429. package/node_modules/@earendil-works/pi-ai/dist/api/mistral-conversations.js +19 -10
  430. package/node_modules/@earendil-works/pi-ai/dist/api/mistral-conversations.js.map +1 -1
  431. package/node_modules/@earendil-works/pi-ai/dist/api/openai-codex-responses.d.ts.map +1 -1
  432. package/node_modules/@earendil-works/pi-ai/dist/api/openai-codex-responses.js +84 -47
  433. package/node_modules/@earendil-works/pi-ai/dist/api/openai-codex-responses.js.map +1 -1
  434. package/node_modules/@earendil-works/pi-ai/dist/api/openai-completions.d.ts.map +1 -1
  435. package/node_modules/@earendil-works/pi-ai/dist/api/openai-completions.js +18 -9
  436. package/node_modules/@earendil-works/pi-ai/dist/api/openai-completions.js.map +1 -1
  437. package/node_modules/@earendil-works/pi-ai/dist/api/openai-responses-shared.d.ts.map +1 -1
  438. package/node_modules/@earendil-works/pi-ai/dist/api/openai-responses-shared.js +11 -1
  439. package/node_modules/@earendil-works/pi-ai/dist/api/openai-responses-shared.js.map +1 -1
  440. package/node_modules/@earendil-works/pi-ai/dist/api/openai-responses.d.ts.map +1 -1
  441. package/node_modules/@earendil-works/pi-ai/dist/api/openai-responses.js +7 -3
  442. package/node_modules/@earendil-works/pi-ai/dist/api/openai-responses.js.map +1 -1
  443. package/node_modules/@earendil-works/pi-ai/dist/api/openrouter-images.js +3 -2
  444. package/node_modules/@earendil-works/pi-ai/dist/api/openrouter-images.js.map +1 -1
  445. package/node_modules/@earendil-works/pi-ai/dist/api/pi-messages.js +2 -2
  446. package/node_modules/@earendil-works/pi-ai/dist/api/pi-messages.js.map +1 -1
  447. package/node_modules/@earendil-works/pi-ai/dist/api/simple-options.d.ts.map +1 -1
  448. package/node_modules/@earendil-works/pi-ai/dist/api/simple-options.js +1 -0
  449. package/node_modules/@earendil-works/pi-ai/dist/api/simple-options.js.map +1 -1
  450. package/node_modules/@earendil-works/pi-ai/dist/auth/oauth/openrouter.d.ts +3 -1
  451. package/node_modules/@earendil-works/pi-ai/dist/auth/oauth/openrouter.d.ts.map +1 -1
  452. package/node_modules/@earendil-works/pi-ai/dist/auth/oauth/openrouter.js +81 -26
  453. package/node_modules/@earendil-works/pi-ai/dist/auth/oauth/openrouter.js.map +1 -1
  454. package/node_modules/@earendil-works/pi-ai/dist/auth/resolve.d.ts +2 -0
  455. package/node_modules/@earendil-works/pi-ai/dist/auth/resolve.d.ts.map +1 -1
  456. package/node_modules/@earendil-works/pi-ai/dist/auth/resolve.js +16 -8
  457. package/node_modules/@earendil-works/pi-ai/dist/auth/resolve.js.map +1 -1
  458. package/node_modules/@earendil-works/pi-ai/dist/env-api-keys.d.ts.map +1 -1
  459. package/node_modules/@earendil-works/pi-ai/dist/env-api-keys.js +1 -0
  460. package/node_modules/@earendil-works/pi-ai/dist/env-api-keys.js.map +1 -1
  461. package/node_modules/@earendil-works/pi-ai/dist/index.d.ts +1 -0
  462. package/node_modules/@earendil-works/pi-ai/dist/index.d.ts.map +1 -1
  463. package/node_modules/@earendil-works/pi-ai/dist/index.js +1 -0
  464. package/node_modules/@earendil-works/pi-ai/dist/index.js.map +1 -1
  465. package/node_modules/@earendil-works/pi-ai/dist/models.js +1 -1
  466. package/node_modules/@earendil-works/pi-ai/dist/models.js.map +1 -1
  467. package/node_modules/@earendil-works/pi-ai/dist/providers/all.d.ts +2 -1
  468. package/node_modules/@earendil-works/pi-ai/dist/providers/all.d.ts.map +1 -1
  469. package/node_modules/@earendil-works/pi-ai/dist/providers/all.js +3 -1
  470. package/node_modules/@earendil-works/pi-ai/dist/providers/all.js.map +1 -1
  471. package/node_modules/@earendil-works/pi-ai/dist/providers/data/.manifest.json +1 -1
  472. package/node_modules/@earendil-works/pi-ai/dist/providers/data/cloudflare-ai-gateway.json +1 -1
  473. package/node_modules/@earendil-works/pi-ai/dist/providers/data/fireworks.json +1 -1
  474. package/node_modules/@earendil-works/pi-ai/dist/providers/data/github-copilot.json +1 -1
  475. package/node_modules/@earendil-works/pi-ai/dist/providers/data/huggingface.json +1 -1
  476. package/node_modules/@earendil-works/pi-ai/dist/providers/data/mistral.json +1 -1
  477. package/node_modules/@earendil-works/pi-ai/dist/providers/data/openai-codex.json +1 -1
  478. package/node_modules/@earendil-works/pi-ai/dist/providers/data/openai.json +1 -1
  479. package/node_modules/@earendil-works/pi-ai/dist/providers/data/opencode-go.json +1 -1
  480. package/node_modules/@earendil-works/pi-ai/dist/providers/data/opencode.json +1 -1
  481. package/node_modules/@earendil-works/pi-ai/dist/providers/data/openrouter.json +1 -1
  482. package/node_modules/@earendil-works/pi-ai/dist/providers/data/qwen-token-plan-cn.json +1 -1
  483. package/node_modules/@earendil-works/pi-ai/dist/providers/data/qwen-token-plan.json +1 -1
  484. package/node_modules/@earendil-works/pi-ai/dist/providers/data/together.json +1 -1
  485. package/node_modules/@earendil-works/pi-ai/dist/providers/data/vercel-ai-gateway.json +1 -1
  486. package/node_modules/@earendil-works/pi-ai/dist/providers/data/zai-coding-cn.json +1 -1
  487. package/node_modules/@earendil-works/pi-ai/dist/providers/data/zai.json +1 -1
  488. package/node_modules/@earendil-works/pi-ai/dist/providers/faux.d.ts.map +1 -1
  489. package/node_modules/@earendil-works/pi-ai/dist/providers/faux.js +4 -1
  490. package/node_modules/@earendil-works/pi-ai/dist/providers/faux.js.map +1 -1
  491. package/node_modules/@earendil-works/pi-ai/dist/providers/ollama.d.ts +9 -0
  492. package/node_modules/@earendil-works/pi-ai/dist/providers/ollama.d.ts.map +1 -0
  493. package/node_modules/@earendil-works/pi-ai/dist/providers/ollama.js +142 -0
  494. package/node_modules/@earendil-works/pi-ai/dist/providers/ollama.js.map +1 -0
  495. package/node_modules/@earendil-works/pi-ai/dist/providers/opencode-go.js +1 -1
  496. package/node_modules/@earendil-works/pi-ai/dist/providers/opencode-go.js.map +1 -1
  497. package/node_modules/@earendil-works/pi-ai/dist/types.d.ts +14 -2
  498. package/node_modules/@earendil-works/pi-ai/dist/types.d.ts.map +1 -1
  499. package/node_modules/@earendil-works/pi-ai/dist/types.js.map +1 -1
  500. package/node_modules/@earendil-works/pi-ai/dist/utils/error-body.d.ts.map +1 -1
  501. package/node_modules/@earendil-works/pi-ai/dist/utils/error-body.js +23 -4
  502. package/node_modules/@earendil-works/pi-ai/dist/utils/error-body.js.map +1 -1
  503. package/node_modules/@earendil-works/pi-ai/dist/utils/prompt-cache-ttl.d.ts.map +1 -1
  504. package/node_modules/@earendil-works/pi-ai/dist/utils/prompt-cache-ttl.js +10 -1
  505. package/node_modules/@earendil-works/pi-ai/dist/utils/prompt-cache-ttl.js.map +1 -1
  506. package/node_modules/@earendil-works/pi-ai/dist/utils/provider-retry.d.ts +3 -0
  507. package/node_modules/@earendil-works/pi-ai/dist/utils/provider-retry.d.ts.map +1 -1
  508. package/node_modules/@earendil-works/pi-ai/dist/utils/provider-retry.js +13 -12
  509. package/node_modules/@earendil-works/pi-ai/dist/utils/provider-retry.js.map +1 -1
  510. package/node_modules/@earendil-works/pi-ai/dist/utils/retry-hint.d.ts +24 -0
  511. package/node_modules/@earendil-works/pi-ai/dist/utils/retry-hint.d.ts.map +1 -0
  512. package/node_modules/@earendil-works/pi-ai/dist/utils/retry-hint.js +233 -0
  513. package/node_modules/@earendil-works/pi-ai/dist/utils/retry-hint.js.map +1 -0
  514. package/node_modules/@earendil-works/pi-ai/package.json +10 -6
  515. package/node_modules/@earendil-works/pi-pty/package.json +2 -2
  516. package/node_modules/@earendil-works/pi-tui/README.md +77 -14
  517. package/node_modules/@earendil-works/pi-tui/dist/TuiAltScreen.d.ts +83 -0
  518. package/node_modules/@earendil-works/pi-tui/dist/TuiAltScreen.d.ts.map +1 -0
  519. package/node_modules/@earendil-works/pi-tui/dist/TuiAltScreen.js +687 -0
  520. package/node_modules/@earendil-works/pi-tui/dist/TuiAltScreen.js.map +1 -0
  521. package/node_modules/@earendil-works/pi-tui/dist/TuiMainScreen.d.ts +5 -0
  522. package/node_modules/@earendil-works/pi-tui/dist/TuiMainScreen.d.ts.map +1 -0
  523. package/node_modules/@earendil-works/pi-tui/dist/TuiMainScreen.js +5 -0
  524. package/node_modules/@earendil-works/pi-tui/dist/TuiMainScreen.js.map +1 -0
  525. package/node_modules/@earendil-works/pi-tui/dist/components/alt-screen-flash.d.ts +13 -0
  526. package/node_modules/@earendil-works/pi-tui/dist/components/alt-screen-flash.d.ts.map +1 -0
  527. package/node_modules/@earendil-works/pi-tui/dist/components/alt-screen-flash.js +36 -0
  528. package/node_modules/@earendil-works/pi-tui/dist/components/alt-screen-flash.js.map +1 -0
  529. package/node_modules/@earendil-works/pi-tui/dist/components/editor.d.ts.map +1 -1
  530. package/node_modules/@earendil-works/pi-tui/dist/components/editor.js +5 -1
  531. package/node_modules/@earendil-works/pi-tui/dist/components/editor.js.map +1 -1
  532. package/node_modules/@earendil-works/pi-tui/dist/components/h-stack.d.ts +7 -0
  533. package/node_modules/@earendil-works/pi-tui/dist/components/h-stack.d.ts.map +1 -0
  534. package/node_modules/@earendil-works/pi-tui/dist/components/h-stack.js +43 -0
  535. package/node_modules/@earendil-works/pi-tui/dist/components/h-stack.js.map +1 -0
  536. package/node_modules/@earendil-works/pi-tui/dist/components/image.d.ts.map +1 -1
  537. package/node_modules/@earendil-works/pi-tui/dist/components/image.js +4 -4
  538. package/node_modules/@earendil-works/pi-tui/dist/components/image.js.map +1 -1
  539. package/node_modules/@earendil-works/pi-tui/dist/components/markdown.d.ts +2 -0
  540. package/node_modules/@earendil-works/pi-tui/dist/components/markdown.d.ts.map +1 -1
  541. package/node_modules/@earendil-works/pi-tui/dist/components/markdown.js +3 -2
  542. package/node_modules/@earendil-works/pi-tui/dist/components/markdown.js.map +1 -1
  543. package/node_modules/@earendil-works/pi-tui/dist/components/scroll-view.d.ts +51 -0
  544. package/node_modules/@earendil-works/pi-tui/dist/components/scroll-view.d.ts.map +1 -0
  545. package/node_modules/@earendil-works/pi-tui/dist/components/scroll-view.js +163 -0
  546. package/node_modules/@earendil-works/pi-tui/dist/components/scroll-view.js.map +1 -0
  547. package/node_modules/@earendil-works/pi-tui/dist/components/settings-list.d.ts.map +1 -1
  548. package/node_modules/@earendil-works/pi-tui/dist/components/settings-list.js +3 -6
  549. package/node_modules/@earendil-works/pi-tui/dist/components/settings-list.js.map +1 -1
  550. package/node_modules/@earendil-works/pi-tui/dist/components/stack.d.ts +32 -0
  551. package/node_modules/@earendil-works/pi-tui/dist/components/stack.d.ts.map +1 -0
  552. package/node_modules/@earendil-works/pi-tui/dist/components/stack.js +109 -0
  553. package/node_modules/@earendil-works/pi-tui/dist/components/stack.js.map +1 -0
  554. package/node_modules/@earendil-works/pi-tui/dist/components/v-stack.d.ts +8 -0
  555. package/node_modules/@earendil-works/pi-tui/dist/components/v-stack.d.ts.map +1 -0
  556. package/node_modules/@earendil-works/pi-tui/dist/components/v-stack.js +21 -0
  557. package/node_modules/@earendil-works/pi-tui/dist/components/v-stack.js.map +1 -0
  558. package/node_modules/@earendil-works/pi-tui/dist/index.d.ts +10 -4
  559. package/node_modules/@earendil-works/pi-tui/dist/index.d.ts.map +1 -1
  560. package/node_modules/@earendil-works/pi-tui/dist/index.js +10 -4
  561. package/node_modules/@earendil-works/pi-tui/dist/index.js.map +1 -1
  562. package/node_modules/@earendil-works/pi-tui/dist/keybindings.d.ts +30 -0
  563. package/node_modules/@earendil-works/pi-tui/dist/keybindings.d.ts.map +1 -1
  564. package/node_modules/@earendil-works/pi-tui/dist/keybindings.js +18 -0
  565. package/node_modules/@earendil-works/pi-tui/dist/keybindings.js.map +1 -1
  566. package/node_modules/@earendil-works/pi-tui/dist/layout-node.d.ts +40 -0
  567. package/node_modules/@earendil-works/pi-tui/dist/layout-node.d.ts.map +1 -0
  568. package/node_modules/@earendil-works/pi-tui/dist/layout-node.js +6 -0
  569. package/node_modules/@earendil-works/pi-tui/dist/layout-node.js.map +1 -0
  570. package/node_modules/@earendil-works/pi-tui/dist/layout.d.ts +40 -0
  571. package/node_modules/@earendil-works/pi-tui/dist/layout.d.ts.map +1 -0
  572. package/node_modules/@earendil-works/pi-tui/dist/layout.js +315 -0
  573. package/node_modules/@earendil-works/pi-tui/dist/layout.js.map +1 -0
  574. package/node_modules/@earendil-works/pi-tui/dist/slash-command-autocomplete.d.ts.map +1 -1
  575. package/node_modules/@earendil-works/pi-tui/dist/slash-command-autocomplete.js +36 -8
  576. package/node_modules/@earendil-works/pi-tui/dist/slash-command-autocomplete.js.map +1 -1
  577. package/node_modules/@earendil-works/pi-tui/dist/terminal-image.d.ts +10 -0
  578. package/node_modules/@earendil-works/pi-tui/dist/terminal-image.d.ts.map +1 -1
  579. package/node_modules/@earendil-works/pi-tui/dist/terminal-image.js +61 -3
  580. package/node_modules/@earendil-works/pi-tui/dist/terminal-image.js.map +1 -1
  581. package/node_modules/@earendil-works/pi-tui/dist/terminal-text.d.ts +1 -0
  582. package/node_modules/@earendil-works/pi-tui/dist/terminal-text.d.ts.map +1 -1
  583. package/node_modules/@earendil-works/pi-tui/dist/terminal-text.js +12 -2
  584. package/node_modules/@earendil-works/pi-tui/dist/terminal-text.js.map +1 -1
  585. package/node_modules/@earendil-works/pi-tui/dist/tui.d.ts +38 -16
  586. package/node_modules/@earendil-works/pi-tui/dist/tui.d.ts.map +1 -1
  587. package/node_modules/@earendil-works/pi-tui/dist/tui.js +121 -51
  588. package/node_modules/@earendil-works/pi-tui/dist/tui.js.map +1 -1
  589. package/node_modules/@earendil-works/pi-tui/dist/utils.d.ts +10 -0
  590. package/node_modules/@earendil-works/pi-tui/dist/utils.d.ts.map +1 -1
  591. package/node_modules/@earendil-works/pi-tui/dist/utils.js +95 -4
  592. package/node_modules/@earendil-works/pi-tui/dist/utils.js.map +1 -1
  593. package/node_modules/@earendil-works/pi-tui/package.json +2 -2
  594. package/node_modules/typebox/build/compile/validator.d.mts +3 -11
  595. package/node_modules/typebox/build/compile/validator.mjs +6 -36
  596. package/node_modules/typebox/build/error/errors.d.mts +1 -7
  597. package/node_modules/typebox/build/format/_idna.mjs +36 -6
  598. package/node_modules/typebox/build/format/_puny.mjs +4 -1
  599. package/node_modules/typebox/build/format/uuid.d.mts +2 -2
  600. package/node_modules/typebox/build/format/uuid.mjs +3 -3
  601. package/node_modules/typebox/build/guard/emit.d.mts +0 -4
  602. package/node_modules/typebox/build/guard/emit.mjs +0 -8
  603. package/node_modules/typebox/build/guard/guard.d.mts +5 -9
  604. package/node_modules/typebox/build/guard/guard.mjs +10 -15
  605. package/node_modules/typebox/build/guard/string.mjs +16 -4
  606. package/node_modules/typebox/build/schema/engine/_functions.mjs +34 -15
  607. package/node_modules/typebox/build/schema/engine/boolean.d.mts +3 -3
  608. package/node_modules/typebox/build/schema/engine/boolean.mjs +4 -4
  609. package/node_modules/typebox/build/schema/engine/index.d.mts +0 -1
  610. package/node_modules/typebox/build/schema/engine/index.mjs +0 -1
  611. package/node_modules/typebox/build/schema/engine/schema.mjs +6 -11
  612. package/node_modules/typebox/build/schema/engine/type.mjs +14 -18
  613. package/node_modules/typebox/build/schema/types/dependencies.mjs +1 -1
  614. package/node_modules/typebox/build/schema/types/index.d.mts +0 -1
  615. package/node_modules/typebox/build/schema/types/index.mjs +0 -1
  616. package/node_modules/typebox/build/schema/types/schema.d.mts +1 -1
  617. package/node_modules/typebox/build/schema/types/schema.mjs +2 -2
  618. package/node_modules/typebox/build/system/locale/ar_001.mjs +0 -1
  619. package/node_modules/typebox/build/system/locale/bn_BD.mjs +0 -1
  620. package/node_modules/typebox/build/system/locale/cs_CZ.mjs +0 -1
  621. package/node_modules/typebox/build/system/locale/de_DE.mjs +0 -1
  622. package/node_modules/typebox/build/system/locale/el_GR.mjs +0 -1
  623. package/node_modules/typebox/build/system/locale/en_US.mjs +0 -1
  624. package/node_modules/typebox/build/system/locale/es_419.mjs +0 -1
  625. package/node_modules/typebox/build/system/locale/es_AR.mjs +0 -1
  626. package/node_modules/typebox/build/system/locale/es_ES.mjs +0 -1
  627. package/node_modules/typebox/build/system/locale/es_MX.mjs +0 -1
  628. package/node_modules/typebox/build/system/locale/fa_IR.mjs +0 -1
  629. package/node_modules/typebox/build/system/locale/fil_PH.mjs +0 -1
  630. package/node_modules/typebox/build/system/locale/fr_CA.mjs +0 -1
  631. package/node_modules/typebox/build/system/locale/fr_FR.mjs +0 -1
  632. package/node_modules/typebox/build/system/locale/ha_NG.mjs +0 -1
  633. package/node_modules/typebox/build/system/locale/hi_IN.mjs +0 -1
  634. package/node_modules/typebox/build/system/locale/hu_HU.mjs +0 -1
  635. package/node_modules/typebox/build/system/locale/id_ID.mjs +0 -1
  636. package/node_modules/typebox/build/system/locale/it_IT.mjs +0 -1
  637. package/node_modules/typebox/build/system/locale/ja_JP.mjs +0 -1
  638. package/node_modules/typebox/build/system/locale/ko_KR.mjs +0 -1
  639. package/node_modules/typebox/build/system/locale/ms_MY.mjs +0 -1
  640. package/node_modules/typebox/build/system/locale/nl_NL.mjs +0 -1
  641. package/node_modules/typebox/build/system/locale/pl_PL.mjs +0 -1
  642. package/node_modules/typebox/build/system/locale/pt_BR.mjs +0 -1
  643. package/node_modules/typebox/build/system/locale/pt_PT.mjs +0 -1
  644. package/node_modules/typebox/build/system/locale/ro_RO.mjs +0 -1
  645. package/node_modules/typebox/build/system/locale/ru_RU.mjs +0 -1
  646. package/node_modules/typebox/build/system/locale/sv_SE.mjs +0 -1
  647. package/node_modules/typebox/build/system/locale/sw_TZ.mjs +0 -1
  648. package/node_modules/typebox/build/system/locale/th_TH.mjs +0 -1
  649. package/node_modules/typebox/build/system/locale/tr_TR.mjs +0 -1
  650. package/node_modules/typebox/build/system/locale/uk_UA.mjs +0 -1
  651. package/node_modules/typebox/build/system/locale/ur_PK.mjs +0 -1
  652. package/node_modules/typebox/build/system/locale/vi_VN.mjs +0 -1
  653. package/node_modules/typebox/build/system/locale/yo_NG.mjs +0 -1
  654. package/node_modules/typebox/build/system/locale/zh_Hans.mjs +0 -1
  655. package/node_modules/typebox/build/system/locale/zh_Hant.mjs +0 -1
  656. package/node_modules/typebox/build/system/memory/clone.d.mts +2 -3
  657. package/node_modules/typebox/build/system/memory/clone.mjs +73 -26
  658. package/node_modules/typebox/build/system/settings/settings.d.mts +15 -0
  659. package/node_modules/typebox/build/system/settings/settings.mjs +3 -1
  660. package/node_modules/typebox/build/type/action/_add_immutable.d.mts +11 -0
  661. package/node_modules/typebox/build/type/action/_add_immutable.mjs +11 -0
  662. package/node_modules/typebox/build/type/action/_add_optional.d.mts +11 -0
  663. package/node_modules/typebox/build/type/action/_add_optional.mjs +11 -0
  664. package/node_modules/typebox/build/type/action/_add_readonly.d.mts +11 -0
  665. package/node_modules/typebox/build/type/action/_add_readonly.mjs +11 -0
  666. package/node_modules/typebox/build/type/action/_remove_immutable.d.mts +11 -0
  667. package/node_modules/typebox/build/type/action/_remove_immutable.mjs +11 -0
  668. package/node_modules/typebox/build/type/action/_remove_optional.d.mts +11 -0
  669. package/node_modules/typebox/build/type/action/_remove_optional.mjs +11 -0
  670. package/node_modules/typebox/build/type/action/_remove_readonly.d.mts +11 -0
  671. package/node_modules/typebox/build/type/action/_remove_readonly.mjs +11 -0
  672. package/node_modules/typebox/build/type/action/conditional.d.mts +2 -3
  673. package/node_modules/typebox/build/type/action/conditional.mjs +2 -1
  674. package/node_modules/typebox/build/type/action/index.d.mts +7 -4
  675. package/node_modules/typebox/build/type/action/index.mjs +7 -4
  676. package/node_modules/typebox/build/type/action/mapped.d.mts +2 -3
  677. package/node_modules/typebox/build/type/action/mapped.mjs +2 -1
  678. package/node_modules/typebox/build/type/action/module.d.mts +8 -7
  679. package/node_modules/typebox/build/type/action/module.mjs +7 -6
  680. package/node_modules/typebox/build/type/action/readonly_object.mjs +3 -0
  681. package/node_modules/typebox/build/type/action/with.d.mts +11 -0
  682. package/node_modules/typebox/build/type/action/with.mjs +11 -0
  683. package/node_modules/typebox/build/type/engine/call/distribute_arguments.mjs +1 -1
  684. package/node_modules/typebox/build/type/engine/call/instantiate.d.mts +1 -3
  685. package/node_modules/typebox/build/type/engine/call/instantiate.mjs +3 -2
  686. package/node_modules/typebox/build/type/engine/call/resolve_arguments.mjs +2 -2
  687. package/node_modules/typebox/build/type/engine/constructor_parameters/instantiate.d.mts +3 -4
  688. package/node_modules/typebox/build/type/engine/constructor_parameters/instantiate.mjs +2 -1
  689. package/node_modules/typebox/build/type/engine/cyclic/candidates.d.mts +2 -3
  690. package/node_modules/typebox/build/type/engine/cyclic/candidates.mjs +3 -6
  691. package/node_modules/typebox/build/type/engine/cyclic/check.d.mts +6 -9
  692. package/node_modules/typebox/build/type/engine/cyclic/check.mjs +10 -16
  693. package/node_modules/typebox/build/type/engine/cyclic/dependencies.d.mts +1 -4
  694. package/node_modules/typebox/build/type/engine/cyclic/dependencies.mjs +9 -15
  695. package/node_modules/typebox/build/type/engine/cyclic/extends.d.mts +1 -4
  696. package/node_modules/typebox/build/type/engine/cyclic/extends.mjs +8 -14
  697. package/node_modules/typebox/build/type/engine/cyclic/instantiate.d.mts +2 -5
  698. package/node_modules/typebox/build/type/engine/cyclic/instantiate.mjs +3 -2
  699. package/node_modules/typebox/build/type/engine/enum/index.d.mts +0 -1
  700. package/node_modules/typebox/build/type/engine/enum/index.mjs +0 -1
  701. package/node_modules/typebox/build/type/engine/evaluate/broaden.d.mts +1 -2
  702. package/node_modules/typebox/build/type/engine/evaluate/broaden.mjs +2 -6
  703. package/node_modules/typebox/build/type/engine/evaluate/composite.d.mts +10 -6
  704. package/node_modules/typebox/build/type/engine/evaluate/composite.mjs +10 -6
  705. package/node_modules/typebox/build/type/engine/evaluate/distribute.d.mts +2 -1
  706. package/node_modules/typebox/build/type/engine/evaluate/distribute.mjs +3 -3
  707. package/node_modules/typebox/build/type/engine/evaluate/evaluate.d.mts +17 -5
  708. package/node_modules/typebox/build/type/engine/evaluate/evaluate.mjs +34 -8
  709. package/node_modules/typebox/build/type/engine/exclude/operation.d.mts +5 -6
  710. package/node_modules/typebox/build/type/engine/exclude/operation.mjs +11 -12
  711. package/node_modules/typebox/build/type/engine/extract/operation.d.mts +5 -6
  712. package/node_modules/typebox/build/type/engine/extract/operation.mjs +11 -12
  713. package/node_modules/typebox/build/type/engine/immutable/instantiate_add.d.mts +10 -0
  714. package/node_modules/typebox/build/type/engine/immutable/instantiate_add.mjs +14 -0
  715. package/node_modules/typebox/build/type/engine/immutable/instantiate_remove.d.mts +10 -0
  716. package/node_modules/typebox/build/type/engine/immutable/instantiate_remove.mjs +14 -0
  717. package/node_modules/typebox/build/type/engine/index.d.mts +2 -2
  718. package/node_modules/typebox/build/type/engine/index.mjs +2 -2
  719. package/node_modules/typebox/build/type/engine/indexable/from_dependent.d.mts +5 -0
  720. package/node_modules/typebox/build/type/engine/indexable/from_dependent.mjs +8 -0
  721. package/node_modules/typebox/build/type/engine/indexable/from_enum.d.mts +3 -3
  722. package/node_modules/typebox/build/type/engine/indexable/from_enum.mjs +4 -4
  723. package/node_modules/typebox/build/type/engine/indexable/from_template_literal.d.mts +2 -2
  724. package/node_modules/typebox/build/type/engine/indexable/from_template_literal.mjs +3 -3
  725. package/node_modules/typebox/build/type/engine/indexable/from_type.d.mts +3 -1
  726. package/node_modules/typebox/build/type/engine/indexable/from_type.mjs +9 -6
  727. package/node_modules/typebox/build/type/engine/indexed/instantiate.d.mts +2 -1
  728. package/node_modules/typebox/build/type/engine/indexed/instantiate.mjs +5 -2
  729. package/node_modules/typebox/build/type/engine/instantiate.d.mts +44 -31
  730. package/node_modules/typebox/build/type/engine/instantiate.mjs +82 -83
  731. package/node_modules/typebox/build/type/engine/interface/instantiate.d.mts +3 -6
  732. package/node_modules/typebox/build/type/engine/intrinsics/from_template_literal.d.mts +2 -2
  733. package/node_modules/typebox/build/type/engine/intrinsics/from_template_literal.mjs +3 -3
  734. package/node_modules/typebox/build/type/engine/keyof/instantiate.d.mts +2 -1
  735. package/node_modules/typebox/build/type/engine/keyof/instantiate.mjs +5 -1
  736. package/node_modules/typebox/build/type/engine/mapped/mapped_operation.d.mts +4 -4
  737. package/node_modules/typebox/build/type/engine/mapped/mapped_operation.mjs +3 -3
  738. package/node_modules/typebox/build/type/engine/mapped/mapped_variants.d.mts +5 -4
  739. package/node_modules/typebox/build/type/engine/mapped/mapped_variants.mjs +10 -5
  740. package/node_modules/typebox/build/type/engine/module/instantiate.d.mts +7 -9
  741. package/node_modules/typebox/build/type/engine/module/instantiate.mjs +17 -15
  742. package/node_modules/typebox/build/type/engine/object/from_dependent.d.mts +5 -0
  743. package/node_modules/typebox/build/type/engine/object/from_dependent.mjs +8 -0
  744. package/node_modules/typebox/build/type/engine/object/from_type.d.mts +3 -1
  745. package/node_modules/typebox/build/type/engine/object/from_type.mjs +8 -5
  746. package/node_modules/typebox/build/type/engine/object/from_union.mjs +2 -2
  747. package/node_modules/typebox/build/type/engine/optional/instantiate_add.d.mts +10 -0
  748. package/node_modules/typebox/build/type/engine/optional/instantiate_add.mjs +14 -0
  749. package/node_modules/typebox/build/type/engine/optional/instantiate_remove.d.mts +10 -0
  750. package/node_modules/typebox/build/type/engine/optional/instantiate_remove.mjs +14 -0
  751. package/node_modules/typebox/build/type/engine/parameters/instantiate.d.mts +3 -4
  752. package/node_modules/typebox/build/type/engine/parameters/instantiate.mjs +2 -1
  753. package/node_modules/typebox/build/type/engine/partial/from_dependent.d.mts +5 -0
  754. package/node_modules/typebox/build/type/engine/partial/from_dependent.mjs +8 -0
  755. package/node_modules/typebox/build/type/engine/partial/from_intersect.d.mts +1 -1
  756. package/node_modules/typebox/build/type/engine/partial/from_intersect.mjs +3 -2
  757. package/node_modules/typebox/build/type/engine/partial/from_object.d.mts +2 -2
  758. package/node_modules/typebox/build/type/engine/partial/from_object.mjs +2 -2
  759. package/node_modules/typebox/build/type/engine/partial/from_type.d.mts +3 -1
  760. package/node_modules/typebox/build/type/engine/partial/from_type.mjs +7 -4
  761. package/node_modules/typebox/build/type/engine/priority/index.d.mts +1 -0
  762. package/node_modules/typebox/build/type/engine/priority/index.mjs +1 -0
  763. package/node_modules/typebox/build/type/engine/priority/priority.d.mts +20 -0
  764. package/node_modules/typebox/build/type/engine/priority/priority.mjs +28 -0
  765. package/node_modules/typebox/build/type/engine/readonly/instantiate_add.d.mts +10 -0
  766. package/node_modules/typebox/build/type/engine/readonly/instantiate_add.mjs +14 -0
  767. package/node_modules/typebox/build/type/engine/readonly/instantiate_remove.d.mts +10 -0
  768. package/node_modules/typebox/build/type/engine/readonly/instantiate_remove.mjs +14 -0
  769. package/node_modules/typebox/build/type/engine/readonly_object/from_array.d.mts +2 -2
  770. package/node_modules/typebox/build/type/engine/readonly_object/from_array.mjs +2 -2
  771. package/node_modules/typebox/build/type/engine/readonly_object/from_dependent.d.mts +5 -0
  772. package/node_modules/typebox/build/type/engine/readonly_object/from_dependent.mjs +8 -0
  773. package/node_modules/typebox/build/type/engine/readonly_object/from_intersect.d.mts +1 -1
  774. package/node_modules/typebox/build/type/engine/readonly_object/from_intersect.mjs +3 -2
  775. package/node_modules/typebox/build/type/engine/readonly_object/from_object.d.mts +2 -2
  776. package/node_modules/typebox/build/type/engine/readonly_object/from_object.mjs +2 -2
  777. package/node_modules/typebox/build/type/engine/readonly_object/from_tuple.d.mts +2 -2
  778. package/node_modules/typebox/build/type/engine/readonly_object/from_tuple.mjs +2 -2
  779. package/node_modules/typebox/build/type/engine/readonly_object/from_type.d.mts +3 -1
  780. package/node_modules/typebox/build/type/engine/readonly_object/from_type.mjs +8 -5
  781. package/node_modules/typebox/build/type/engine/record/from_key_enum.d.mts +2 -2
  782. package/node_modules/typebox/build/type/engine/record/from_key_enum.mjs +2 -2
  783. package/node_modules/typebox/build/type/engine/record/from_key_template_literal.d.mts +2 -2
  784. package/node_modules/typebox/build/type/engine/record/from_key_template_literal.mjs +2 -2
  785. package/node_modules/typebox/build/type/engine/ref/instantiate.d.mts +3 -3
  786. package/node_modules/typebox/build/type/engine/ref/instantiate.mjs +6 -6
  787. package/node_modules/typebox/build/type/engine/required/from_dependent.d.mts +5 -0
  788. package/node_modules/typebox/build/type/engine/required/from_dependent.mjs +8 -0
  789. package/node_modules/typebox/build/type/engine/required/from_intersect.d.mts +1 -1
  790. package/node_modules/typebox/build/type/engine/required/from_intersect.mjs +3 -2
  791. package/node_modules/typebox/build/type/engine/required/from_object.d.mts +2 -2
  792. package/node_modules/typebox/build/type/engine/required/from_object.mjs +2 -2
  793. package/node_modules/typebox/build/type/engine/required/from_type.d.mts +3 -1
  794. package/node_modules/typebox/build/type/engine/required/from_type.mjs +7 -4
  795. package/node_modules/typebox/build/type/engine/template_literal/decode.mjs +3 -3
  796. package/node_modules/typebox/build/type/engine/template_literal/encode.d.mts +2 -2
  797. package/node_modules/typebox/build/type/engine/template_literal/encode.mjs +6 -6
  798. package/node_modules/typebox/build/type/engine/template_literal/is_finite.mjs +1 -1
  799. package/node_modules/typebox/build/type/engine/template_literal/is_pattern.mjs +1 -0
  800. package/node_modules/typebox/build/type/engine/this/expand_this.d.mts +1 -4
  801. package/node_modules/typebox/build/type/engine/this/expand_this.mjs +7 -13
  802. package/node_modules/typebox/build/type/engine/with/instantiate.d.mts +8 -0
  803. package/node_modules/typebox/build/type/engine/{options → with}/instantiate.mjs +5 -5
  804. package/node_modules/typebox/build/type/extends/dependent.d.mts +6 -0
  805. package/node_modules/typebox/build/type/extends/dependent.mjs +6 -0
  806. package/node_modules/typebox/build/type/extends/enum.d.mts +4 -4
  807. package/node_modules/typebox/build/type/extends/enum.mjs +3 -2
  808. package/node_modules/typebox/build/type/extends/extends_left.d.mts +5 -7
  809. package/node_modules/typebox/build/type/extends/extends_left.mjs +24 -27
  810. package/node_modules/typebox/build/type/extends/extends_right.d.mts +7 -5
  811. package/node_modules/typebox/build/type/extends/extends_right.mjs +20 -15
  812. package/node_modules/typebox/build/type/extends/inference.mjs +1 -1
  813. package/node_modules/typebox/build/type/extends/object.d.mts +8 -1
  814. package/node_modules/typebox/build/type/extends/object.mjs +25 -3
  815. package/node_modules/typebox/build/type/extends/parameters.mjs +2 -2
  816. package/node_modules/typebox/build/type/extends/record.d.mts +13 -0
  817. package/node_modules/typebox/build/type/extends/record.mjs +23 -0
  818. package/node_modules/typebox/build/type/extends/template_literal.d.mts +3 -3
  819. package/node_modules/typebox/build/type/extends/template_literal.mjs +3 -3
  820. package/node_modules/typebox/build/type/extends/tuple.d.mts +3 -6
  821. package/node_modules/typebox/build/type/extends/tuple.mjs +6 -5
  822. package/node_modules/typebox/build/type/extends/union.mjs +2 -2
  823. package/node_modules/typebox/build/type/script/mapping.d.mts +86 -98
  824. package/node_modules/typebox/build/type/script/mapping.mjs +95 -92
  825. package/node_modules/typebox/build/type/script/parser.d.mts +42 -40
  826. package/node_modules/typebox/build/type/script/parser.mjs +23 -22
  827. package/node_modules/typebox/build/type/script/script.d.mts +3 -4
  828. package/node_modules/typebox/build/type/script/script.mjs +3 -2
  829. package/node_modules/typebox/build/type/script/token/internal/guard.d.mts +1 -1
  830. package/node_modules/typebox/build/type/script/token/internal/guard.mjs +1 -1
  831. package/node_modules/typebox/build/type/script/token/internal/take.mjs +1 -1
  832. package/node_modules/typebox/build/type/script/token/until.mjs +2 -2
  833. package/node_modules/typebox/build/type/types/_codec.d.mts +12 -12
  834. package/node_modules/typebox/build/type/types/_codec.mjs +0 -1
  835. package/node_modules/typebox/build/type/types/_immutable.d.mts +2 -9
  836. package/node_modules/typebox/build/type/types/_immutable.mjs +2 -10
  837. package/node_modules/typebox/build/type/types/_optional.d.mts +2 -9
  838. package/node_modules/typebox/build/type/types/_optional.mjs +2 -11
  839. package/node_modules/typebox/build/type/types/_readonly.d.mts +2 -9
  840. package/node_modules/typebox/build/type/types/_readonly.mjs +2 -10
  841. package/node_modules/typebox/build/type/types/_refine.d.mts +8 -10
  842. package/node_modules/typebox/build/type/types/_refine.mjs +1 -2
  843. package/node_modules/typebox/build/type/types/call.d.mts +3 -3
  844. package/node_modules/typebox/build/type/types/call.mjs +3 -2
  845. package/node_modules/typebox/build/type/types/deferred.d.mts +1 -0
  846. package/node_modules/typebox/build/type/types/deferred.mjs +1 -1
  847. package/node_modules/typebox/build/type/types/dependent.d.mts +17 -0
  848. package/node_modules/typebox/build/type/types/dependent.mjs +24 -0
  849. package/node_modules/typebox/build/type/types/enum.d.mts +3 -1
  850. package/node_modules/typebox/build/type/types/enum.mjs +5 -0
  851. package/node_modules/typebox/build/type/types/index.d.mts +1 -4
  852. package/node_modules/typebox/build/type/types/index.mjs +1 -4
  853. package/node_modules/typebox/build/type/types/number.d.mts +1 -1
  854. package/node_modules/typebox/build/type/types/number.mjs +1 -1
  855. package/node_modules/typebox/build/type/types/record.d.mts +13 -7
  856. package/node_modules/typebox/build/type/types/record.mjs +15 -9
  857. package/node_modules/typebox/build/type/types/static.d.mts +2 -5
  858. package/node_modules/typebox/build/typebox.d.mts +3 -7
  859. package/node_modules/typebox/build/typebox.mjs +3 -7
  860. package/node_modules/typebox/build/value/clean/clean.mjs +4 -2
  861. package/node_modules/typebox/build/value/clean/from_intersect.mjs +2 -2
  862. package/node_modules/typebox/build/value/clean/from_type.mjs +8 -10
  863. package/node_modules/typebox/build/value/clean/from_union.d.mts +1 -1
  864. package/node_modules/typebox/build/value/clean/from_union.mjs +1 -2
  865. package/node_modules/typebox/build/value/clone/clone.mjs +2 -73
  866. package/node_modules/typebox/build/value/codec/decode.mjs +4 -2
  867. package/node_modules/typebox/build/value/codec/encode.mjs +4 -2
  868. package/node_modules/typebox/build/value/codec/from_array.mjs +1 -4
  869. package/node_modules/typebox/build/value/codec/from_object.mjs +1 -4
  870. package/node_modules/typebox/build/value/codec/from_record.mjs +2 -7
  871. package/node_modules/typebox/build/value/codec/from_tuple.mjs +1 -4
  872. package/node_modules/typebox/build/value/codec/from_union.mjs +2 -3
  873. package/node_modules/typebox/build/value/convert/from_enum.mjs +3 -4
  874. package/node_modules/typebox/build/value/convert/from_template_literal.d.mts +1 -1
  875. package/node_modules/typebox/build/value/convert/from_template_literal.mjs +2 -3
  876. package/node_modules/typebox/build/value/convert/from_type.mjs +19 -21
  877. package/node_modules/typebox/build/value/create/from_enum.mjs +2 -2
  878. package/node_modules/typebox/build/value/create/from_type.mjs +23 -31
  879. package/node_modules/typebox/build/value/default/from_object.mjs +1 -1
  880. package/node_modules/typebox/build/value/default/from_type.mjs +8 -10
  881. package/node_modules/typebox/build/value/errors/errors.d.mts +2 -2
  882. package/node_modules/typebox/build/value/errors/errors.mjs +1 -1
  883. package/node_modules/typebox/build/value/index.d.mts +0 -1
  884. package/node_modules/typebox/build/value/index.mjs +0 -1
  885. package/node_modules/typebox/build/value/repair/from_enum.mjs +2 -3
  886. package/node_modules/typebox/build/value/repair/from_type.mjs +24 -22
  887. package/node_modules/typebox/build/value/shared/union_priority_sort.d.mts +6 -2
  888. package/node_modules/typebox/build/value/shared/union_priority_sort.mjs +62 -26
  889. package/node_modules/typebox/build/value/value.d.mts +0 -1
  890. package/node_modules/typebox/build/value/value.mjs +0 -1
  891. package/node_modules/typebox/package.json +33 -33
  892. package/node_modules/typebox/readme.md +117 -103
  893. package/package.json +16 -11
  894. package/vendor/pi-client/client.d.ts +25 -0
  895. package/vendor/pi-client/client.d.ts.map +1 -0
  896. package/vendor/pi-client/client.js +386 -0
  897. package/vendor/pi-client/client.js.map +1 -0
  898. package/vendor/pi-client/connection.d.ts +25 -0
  899. package/vendor/pi-client/connection.d.ts.map +1 -0
  900. package/vendor/pi-client/connection.js +204 -0
  901. package/vendor/pi-client/connection.js.map +1 -0
  902. package/vendor/pi-client/errors.d.ts +23 -0
  903. package/vendor/pi-client/errors.d.ts.map +1 -0
  904. package/vendor/pi-client/errors.js +42 -0
  905. package/vendor/pi-client/errors.js.map +1 -0
  906. package/vendor/pi-client/index.d.ts +6 -0
  907. package/vendor/pi-client/index.d.ts.map +1 -0
  908. package/vendor/pi-client/index.js +3 -0
  909. package/vendor/pi-client/index.js.map +1 -0
  910. package/vendor/pi-client/promise.d.ts +8 -0
  911. package/vendor/pi-client/promise.d.ts.map +1 -0
  912. package/vendor/pi-client/promise.js +11 -0
  913. package/vendor/pi-client/promise.js.map +1 -0
  914. package/vendor/pi-client/session-handle.d.ts +54 -0
  915. package/vendor/pi-client/session-handle.d.ts.map +1 -0
  916. package/vendor/pi-client/session-handle.js +50 -0
  917. package/vendor/pi-client/session-handle.js.map +1 -0
  918. package/vendor/pi-client/state.d.ts +22 -0
  919. package/vendor/pi-client/state.d.ts.map +1 -0
  920. package/vendor/pi-client/state.js +149 -0
  921. package/vendor/pi-client/state.js.map +1 -0
  922. package/vendor/pi-client/transport.d.ts +17 -0
  923. package/vendor/pi-client/transport.d.ts.map +1 -0
  924. package/vendor/pi-client/transport.js +2 -0
  925. package/vendor/pi-client/transport.js.map +1 -0
  926. package/vendor/pi-client/types.d.ts +23 -0
  927. package/vendor/pi-client/types.d.ts.map +1 -0
  928. package/vendor/pi-client/types.js +2 -0
  929. package/vendor/pi-client/types.js.map +1 -0
  930. package/vendor/pi-client/unix.d.ts +8 -0
  931. package/vendor/pi-client/unix.d.ts.map +1 -0
  932. package/vendor/pi-client/unix.js +151 -0
  933. package/vendor/pi-client/unix.js.map +1 -0
  934. package/vendor/pi-protocol/cbor/decoder.d.ts +4 -0
  935. package/vendor/pi-protocol/cbor/decoder.d.ts.map +1 -0
  936. package/vendor/pi-protocol/cbor/decoder.js +163 -0
  937. package/vendor/pi-protocol/cbor/decoder.js.map +1 -0
  938. package/vendor/pi-protocol/cbor/encoder.d.ts +4 -0
  939. package/vendor/pi-protocol/cbor/encoder.d.ts.map +1 -0
  940. package/vendor/pi-protocol/cbor/encoder.js +199 -0
  941. package/vendor/pi-protocol/cbor/encoder.js.map +1 -0
  942. package/vendor/pi-protocol/cbor/index.d.ts +4 -0
  943. package/vendor/pi-protocol/cbor/index.d.ts.map +1 -0
  944. package/vendor/pi-protocol/cbor/index.js +4 -0
  945. package/vendor/pi-protocol/cbor/index.js.map +1 -0
  946. package/vendor/pi-protocol/cbor/options.d.ts +26 -0
  947. package/vendor/pi-protocol/cbor/options.d.ts.map +1 -0
  948. package/vendor/pi-protocol/cbor/options.js +29 -0
  949. package/vendor/pi-protocol/cbor/options.js.map +1 -0
  950. package/vendor/pi-protocol/codec.d.ts +29 -0
  951. package/vendor/pi-protocol/codec.d.ts.map +1 -0
  952. package/vendor/pi-protocol/codec.js +140 -0
  953. package/vendor/pi-protocol/codec.js.map +1 -0
  954. package/vendor/pi-protocol/framing.d.ts +29 -0
  955. package/vendor/pi-protocol/framing.d.ts.map +1 -0
  956. package/vendor/pi-protocol/framing.js +152 -0
  957. package/vendor/pi-protocol/framing.js.map +1 -0
  958. package/vendor/pi-protocol/index.d.ts +5 -0
  959. package/vendor/pi-protocol/index.d.ts.map +1 -0
  960. package/vendor/pi-protocol/index.js +5 -0
  961. package/vendor/pi-protocol/index.js.map +1 -0
  962. package/vendor/pi-protocol/schemas.d.ts +13818 -0
  963. package/vendor/pi-protocol/schemas.d.ts.map +1 -0
  964. package/vendor/pi-protocol/schemas.js +382 -0
  965. package/vendor/pi-protocol/schemas.js.map +1 -0
  966. package/dist/core/extensions/builtin/tool-pair-guard/sanitize-anthropic-payload.d.ts +0 -3
  967. package/dist/core/extensions/builtin/tool-pair-guard/sanitize-anthropic-payload.d.ts.map +0 -1
  968. package/dist/core/extensions/builtin/tool-pair-guard/sanitize-anthropic-payload.js.map +0 -1
  969. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/jsonl-repo.d.ts +0 -26
  970. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/jsonl-repo.d.ts.map +0 -1
  971. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/jsonl-repo.js +0 -100
  972. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/jsonl-repo.js.map +0 -1
  973. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/jsonl-storage.d.ts +0 -42
  974. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/jsonl-storage.d.ts.map +0 -1
  975. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/jsonl-storage.js +0 -286
  976. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/jsonl-storage.js.map +0 -1
  977. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/memory-repo.d.ts +0 -18
  978. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/memory-repo.d.ts.map +0 -1
  979. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/memory-repo.js +0 -44
  980. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/memory-repo.js.map +0 -1
  981. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/memory-storage.d.ts +0 -33
  982. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/memory-storage.d.ts.map +0 -1
  983. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/memory-storage.js +0 -163
  984. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/memory-storage.js.map +0 -1
  985. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/repo-utils.d.ts +0 -11
  986. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/repo-utils.d.ts.map +0 -1
  987. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/repo-utils.js +0 -39
  988. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/repo-utils.js.map +0 -1
  989. package/node_modules/typebox/build/schema/engine/_guard.d.mts +0 -6
  990. package/node_modules/typebox/build/schema/engine/_guard.mjs +0 -26
  991. package/node_modules/typebox/build/schema/types/_guard.d.mts +0 -10
  992. package/node_modules/typebox/build/schema/types/_guard.mjs +0 -16
  993. package/node_modules/typebox/build/type/action/_optional.d.mts +0 -19
  994. package/node_modules/typebox/build/type/action/_optional.mjs +0 -40
  995. package/node_modules/typebox/build/type/action/_readonly.d.mts +0 -19
  996. package/node_modules/typebox/build/type/action/_readonly.mjs +0 -40
  997. package/node_modules/typebox/build/type/action/awaited.d.mts +0 -15
  998. package/node_modules/typebox/build/type/action/awaited.mjs +0 -15
  999. package/node_modules/typebox/build/type/action/options.d.mts +0 -11
  1000. package/node_modules/typebox/build/type/action/options.mjs +0 -11
  1001. package/node_modules/typebox/build/type/engine/awaited/instantiate.d.mts +0 -11
  1002. package/node_modules/typebox/build/type/engine/awaited/instantiate.mjs +0 -20
  1003. package/node_modules/typebox/build/type/engine/enum/enum_to_union.d.mts +0 -14
  1004. package/node_modules/typebox/build/type/engine/enum/enum_to_union.mjs +0 -24
  1005. package/node_modules/typebox/build/type/engine/options/index.d.mts +0 -1
  1006. package/node_modules/typebox/build/type/engine/options/index.mjs +0 -1
  1007. package/node_modules/typebox/build/type/engine/options/instantiate.d.mts +0 -8
  1008. package/node_modules/typebox/build/type/extends/async_iterator.d.mts +0 -7
  1009. package/node_modules/typebox/build/type/extends/async_iterator.mjs +0 -9
  1010. package/node_modules/typebox/build/type/extends/iterator.d.mts +0 -7
  1011. package/node_modules/typebox/build/type/extends/iterator.mjs +0 -9
  1012. package/node_modules/typebox/build/type/extends/promise.d.mts +0 -7
  1013. package/node_modules/typebox/build/type/extends/promise.mjs +0 -9
  1014. package/node_modules/typebox/build/type/types/async_iterator.d.mts +0 -20
  1015. package/node_modules/typebox/build/type/types/async_iterator.mjs +0 -28
  1016. package/node_modules/typebox/build/type/types/base.d.mts +0 -50
  1017. package/node_modules/typebox/build/type/types/base.mjs +0 -84
  1018. package/node_modules/typebox/build/type/types/iterator.d.mts +0 -20
  1019. package/node_modules/typebox/build/type/types/iterator.mjs +0 -28
  1020. package/node_modules/typebox/build/type/types/promise.d.mts +0 -21
  1021. package/node_modules/typebox/build/type/types/promise.mjs +0 -29
  1022. package/node_modules/typebox/build/value/clean/from_base.d.mts +0 -2
  1023. package/node_modules/typebox/build/value/clean/from_base.mjs +0 -4
  1024. package/node_modules/typebox/build/value/convert/from_base.d.mts +0 -2
  1025. package/node_modules/typebox/build/value/convert/from_base.mjs +0 -4
  1026. package/node_modules/typebox/build/value/create/from_async_iterator.d.mts +0 -2
  1027. package/node_modules/typebox/build/value/create/from_async_iterator.mjs +0 -5
  1028. package/node_modules/typebox/build/value/create/from_base.d.mts +0 -2
  1029. package/node_modules/typebox/build/value/create/from_base.mjs +0 -4
  1030. package/node_modules/typebox/build/value/create/from_iterator.d.mts +0 -2
  1031. package/node_modules/typebox/build/value/create/from_iterator.mjs +0 -5
  1032. package/node_modules/typebox/build/value/create/from_promise.d.mts +0 -2
  1033. package/node_modules/typebox/build/value/create/from_promise.mjs +0 -5
  1034. package/node_modules/typebox/build/value/default/from_base.d.mts +0 -2
  1035. package/node_modules/typebox/build/value/default/from_base.mjs +0 -5
  1036. package/node_modules/typebox/build/value/mutate/error.d.mts +0 -3
  1037. package/node_modules/typebox/build/value/mutate/error.mjs +0 -6
  1038. package/node_modules/typebox/build/value/mutate/from_array.d.mts +0 -2
  1039. package/node_modules/typebox/build/value/mutate/from_array.mjs +0 -16
  1040. package/node_modules/typebox/build/value/mutate/from_object.d.mts +0 -2
  1041. package/node_modules/typebox/build/value/mutate/from_object.mjs +0 -40
  1042. package/node_modules/typebox/build/value/mutate/from_unknown.d.mts +0 -2
  1043. package/node_modules/typebox/build/value/mutate/from_unknown.mjs +0 -7
  1044. package/node_modules/typebox/build/value/mutate/from_value.d.mts +0 -2
  1045. package/node_modules/typebox/build/value/mutate/from_value.mjs +0 -12
  1046. package/node_modules/typebox/build/value/mutate/index.d.mts +0 -1
  1047. package/node_modules/typebox/build/value/mutate/index.mjs +0 -1
  1048. package/node_modules/typebox/build/value/mutate/mutate.d.mts +0 -11
  1049. package/node_modules/typebox/build/value/mutate/mutate.mjs +0 -41
  1050. package/node_modules/typebox/build/value/repair/from_base.d.mts +0 -2
  1051. package/node_modules/typebox/build/value/repair/from_base.mjs +0 -8
  1052. /package/node_modules/typebox/build/type/engine/{awaited → with}/index.d.mts +0 -0
  1053. /package/node_modules/typebox/build/type/engine/{awaited → with}/index.mjs +0 -0
@@ -1 +1 @@
1
- {"version":3,"file":"gpt-5.6.js","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/prompt-preset/gpt-5.6.ts"],"names":[],"mappings":"AAAA,4EAA4E;AAC5E,6EAA6E;AAC7E,0EAA0E;AAC1E,EAAE;AACF,oEAAoE;AACpE,0EAA0E;AAC1E,2EAA2E;AAC3E,4EAA4E;AAC5E,yEAAyE;AACzE,+EAA+E;AAC/E,4EAA4E;AAC5E,2EAA2E;AAC3E,wEAAwE;AACxE,6EAA6E;AAC7E,0EAA0E;AAC1E,2EAA2E;AAC3E,2EAA2E;AAC3E,yEAAyE;AACzE,oEAAoE;AACpE,0E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O,EAAE,CAAC,CAAC;AAC1G,CAAC","sourcesContent":["// GPT-5.6 full-core system prompt. One preset covers the whole series - the\n// gpt-5.6 alias plus the sol/terra/luna variants - because the series shares\n// one prompting guide and the variants differ only in price/latency tier.\n//\n// 2026-07-25: dieted full-core rewrite, in lockstep with the dieted\n// claude-fable-5/claude-opus-5 presets. The GPT-5.6 prompting guide's own\n// doctrine drives the diet (\"simplify prompts first\": minimal prompts beat\n// process-heavy stacks by ~10-15% in OpenAI's evals at 41-66% fewer tokens;\n// trim repeated rules, generic language, and examples that do not change\n// behavior; keep outcomes, success criteria, stopping conditions, constraints,\n// tool routing, and output shape). Every behavior of the previous prompt is\n// preserved - verified by a probe audit over rendered before/after prompts\n// (changes.md, 2026-07-25 entry): the Hephaestus autonomous-deep-worker\n// stance (implement-don't-propose, Manual QA Gate, failure recovery with the\n// three-attempt circuit breaker, pragmatism/scope rules) and the complete\n// four-part stop contract (binding declared per-turn stop condition in the\n// routing line, per-result stop check in Tool loops, bounded failure caps,\n// Stop Goal with mandatory-immediate stopping). Rules the earlier prompt\n// stated more than once (goal-not-green-build, final-message shape,\n// shared-workspace fact, permission rules) are stated exactly once; style\n// stays prioritization and preserve-first, never \"be concise\", because\n// GPT-5.6 over-compresses under generic brevity wording. Contracts tied to\n// tools senpi does not expose remain NOT ported - GPT-5.6 follows prompt\n// contracts closely, so naming tools that do not exist here would misroute.\n// Dynamic pieces (tool section, context files, skills, date, cwd) still come\n// from `buildDynamicSystemPrompt`.\n//\n// 2026-07-25 (second pass): execution discipline. The owner's workflow needs\n// ten behaviors GPT-5.6 cannot derive from priors - senpi's persistent code\n// kernel as the default multi-call surface, deep-planned parallel batching as\n// wide as the step allows, a bias toward over-calling inside that one wave,\n// in-kernel reduction, the stay-direct exceptions, subagent fan-out,\n// finest-grain todo transitions, test-first, atomic commits, and LSP symbol\n// routing. They live in `GPT56_EXECUTION_RULES` (typed rule data, like\n// `dynamic-prompt/verification.ts`) and each directive is interpolated once, at\n// its point of use, replacing the weaker text it supersedes rather than being\n// appended as a trailer: the old \"independent calls run in the same message\" /\n// \"each shell command is its own bash call\" pair, the mid-paragraph todo\n// mechanics, and the \"default to not adding tests\" rule (deleted - it directly\n// contradicts test-first). The GPT-5.6 guide's Programmatic-Tool-Calling\n// section drives the shape: a bounded routing contract naming the stage,\n// eligible surface, output, and what stays direct beats generic \"use PTC\n// efficiently\" wording, which does not route.\n\nimport type { DynamicPromptCoreContext } from \"../../../dynamic-prompt/build.ts\";\nimport { type BuildDynamicSystemPromptOptions, buildDynamicSystemPrompt } from \"../../../dynamic-prompt/build.ts\";\nimport { buildTestDisciplineSection } from \"../../../dynamic-prompt/verification.ts\";\nimport { buildFileOperationsTuning } from \"./file-operations.ts\";\nimport { buildGptEvalRoutingTuning } from \"./gpt-eval-routing.ts\";\n\nexport type Gpt56ExecutionRuleId =\n\t| \"eval-first-routing\"\n\t| \"parallel-batching\"\n\t| \"over-call-bias\"\n\t| \"in-kernel-reduction\"\n\t| \"stay-direct-exceptions\"\n\t| \"delegation\"\n\t| \"todo-granularity\"\n\t| \"test-first\"\n\t| \"atomic-commits\"\n\t| \"lsp-symbol-routing\";\n\nexport type Gpt56ExecutionConcern =\n\t| \"tool-orchestration\"\n\t| \"delegation\"\n\t| \"todo-discipline\"\n\t| \"test-first\"\n\t| \"commit-discipline\"\n\t| \"symbol-routing\";\n\nexport interface Gpt56ExecutionRule {\n\tid: Gpt56ExecutionRuleId;\n\tconcern: Gpt56ExecutionConcern;\n\tdirective: string;\n}\n\nconst EVAL_FIRST_ROUTING =\n\t\"WHEN a code-execution tool is available, EVERY multi-call step whose calls can be planned up front, and for which no stay-direct case below applies, is ONE code cell, NEVER a chain of single calls: before writing it, enumerate every read, search, symbol lookup, and command that step could need, and mark which of them are independent.\";\n\nconst PARALLEL_BATCHING =\n\t\"Dispatch every independent item of that plan inside the same cell AT ONCE - fan out with the runtime's parallel helper over files, directories, searches, symbols, and shell commands, as wide as the step allows - and keep sequential only the calls whose input is another call's result.\";\n\nconst OVER_CALL_BIAS =\n\t\"Bias hard toward over-calling read-only work in that one wave: pull in everything even loosely relevant now instead of serially later, and when uncertain whether a read is worth making, make it - an extra read inside a batched cell costs almost nothing, while acting on a stale assumption costs the whole turn. Side-effecting or approval-gated calls never ride along.\";\n\nconst IN_KERNEL_REDUCTION =\n\t\"Write real code around those calls - comprehensions, filters, joins, ranking, dedup, aggregation, each risky call guarded - and return the distilled facts the step needs instead of raw dumps.\";\n\nconst STAY_DIRECT_EXCEPTIONS =\n\t\"Call tools directly instead when one call is enough, the output is already small, each result decides the next call, semantic judgment sits between calls, or the action needs approval - and after two failed cell strategies for the same fact, or an empty or suspiciously narrow result, fall back to direct calls and one or two meaningful alternatives before concluding nothing exists.\";\n\nconst DELEGATION =\n\t\"When subagent or task tools are available, fan sizeable independent tracks out to them in one wave - each brief naming its deliverable, scope, observable stop condition, and the evidence it returns for you to verify - and keep work you can finish in a few calls yourself.\";\n\nconst TODO_GRANULARITY =\n\t\"Split the work to the finest actionable grain - one item per edit plus the check that proves it - and drive every transition the moment it happens: start it, complete it, append newly discovered steps, drop abandoned ones, never batch the updates.\";\n\nconst TEST_FIRST =\n\t\"Work test-first on behavior changes: write the failing test, watch it fail for the right reason, then make the smallest change that turns it green. Skip that only for formatting, comments, renames, or dependency bumps, and never write a test that cannot fail for the regression it names.\";\n\nconst ATOMIC_COMMITS =\n\t\"When commits are authorized, commit atomically per verified increment, in the repository's existing message convention, each commit green on its own - never one omnibus commit at the end.\";\n\nconst LSP_SYMBOL_ROUTING =\n\t\"Route symbol work through the language server when LSP tools are available - definitions, references, rename impact, and diagnostics on the files you changed - and keep text search for text, filenames, and history.\";\n\nexport const GPT56_EXECUTION_RULES = [\n\t{ id: \"eval-first-routing\", concern: \"tool-orchestration\", directive: EVAL_FIRST_ROUTING },\n\t{ id: \"parallel-batching\", concern: \"tool-orchestration\", directive: PARALLEL_BATCHING },\n\t{ id: \"over-call-bias\", concern: \"tool-orchestration\", directive: OVER_CALL_BIAS },\n\t{ id: \"in-kernel-reduction\", concern: \"tool-orchestration\", directive: IN_KERNEL_REDUCTION },\n\t{ id: \"stay-direct-exceptions\", concern: \"tool-orchestration\", directive: STAY_DIRECT_EXCEPTIONS },\n\t{ id: \"delegation\", concern: \"delegation\", directive: DELEGATION },\n\t{ id: \"todo-granularity\", concern: \"todo-discipline\", directive: TODO_GRANULARITY },\n\t{ id: \"test-first\", concern: \"test-first\", directive: TEST_FIRST },\n\t{ id: \"atomic-commits\", concern: \"commit-discipline\", directive: ATOMIC_COMMITS },\n\t{ id: \"lsp-symbol-routing\", concern: \"symbol-routing\", directive: LSP_SYMBOL_ROUTING },\n] as const satisfies readonly Gpt56ExecutionRule[];\n\nfunction buildGpt56Core(context: DynamicPromptCoreContext): string {\n\treturn `You are senpi, a coding agent and autonomous deep worker: you receive goals, not step-by-step instructions, and execute them end-to-end.\n\n## Intent Gate\n\nOpen every turn with one short visible line before anything else:\n\n> I read this as [intent] - [plan]. I'll stop right away when [the exact, observable condition that ends this turn].\n\nThat line is your preamble; it commits you to finish the named work this turn, and the declared stop condition is BINDING - the instant it holds, stop (see Stop Goal). Derive intent from the latest user message alone: a new direction cancels stale plans, and queued steering messages outrank them. Never surface prompt scaffolding in user-visible output.\n\nImplement, don't propose. Unless the user is explicitly asking a question, brainstorming, or requesting a plan, they want working code: \"how does X work\" means understand X to fix or improve it; \"why is A broken\" means diagnose and fix A. Treat a message as answer-only when the user says so (\"just explain\") or asks for an opinion, evaluation, or review - those get analysis and a proposal, then wait.\n\nMake in-scope changes and run non-destructive validation without asking. Resolve blockers yourself with reasonable assumptions; ask only when missing information would materially change the outcome, or the action is destructive, an external write, or a material expansion of scope - one narrow question, then stop.\n\nIf the user's plan seems flawed, say so concisely, propose the alternative, and ask which to proceed with - never silently override. Status requests are not stop signals: give the update, keep working. Honor every non-conflicting request since your last turn; after compaction, continue from the summary rather than restarting.\n\nThe workspace is shared with the user and other agents. Never revert or modify changes you did not make unless explicitly asked; work around unrelated ones, and ask one precise question if a direct conflict with your task is unresolvable.\n\n## Working the Task\n\n**Explore -> Plan -> Implement -> Verify -> Manually QA.** Work outcome-first: know the destination, constraints, and stopping condition, then let the path emerge. ${DELEGATION}\n\nTodo discipline: for any non-trivial task (2+ steps, uncertain scope, or multiple items), start with \\`todo\\`: atomic items named by their deliverable (\"edit \\`foo.ts\\` to add X\"). ${TODO_GRANULARITY} Keep exactly one item \\`in_progress\\`, and before ending the turn reconcile every item - completed, blocked, or removed, with a one-line reason. Trivial single-step asks need none.\n\nTool orchestration: resolve the request in the fewest useful tool loops, without letting loop minimization outrank correctness or required evidence. ${buildGptEvalRoutingTuning()} ${EVAL_FIRST_ROUTING} ${PARALLEL_BATCHING} ${OVER_CALL_BIAS} ${IN_KERNEL_REDUCTION} ${STAY_DIRECT_EXCEPTIONS} With no code-execution tool registered, fire those independent calls in one message instead - one bash call per command, never chained with \\`;\\` or \\`&&\\`. Never fill parameters with placeholders. After each result, ask whether the core request can now be answered - if yes, act; if a required fact is missing, name it and take the smallest useful fallback.\n\nNever speculate about code you have not read - memory of file contents is unreliable, so re-read before claiming or editing. ${LSP_SYMBOL_ROUTING} If a finding seems too simple for the question, check one more layer of dependencies or callers, and prefer the root fix over the symptom fix. Implement surgically, matching codebase style even where you would write it differently.\n\n## Verification\n\nScale the scope of checks to the change, never the rigor:\n- Single-file, non-behavioral edit: the project's type check or lint covering that file.\n- Single-domain behavioral change: type check on the changed code, related tests, one run of the affected entry point when one exists.\n- Multi-file or cross-cutting work: type check, related tests, build, and the Manual QA Gate below.\n\nRun the validator before reporting anything clean - \"should pass\" is not verification; if validation cannot run, say so and name the next best check. Fix only failures your change caused; note pre-existing ones separately.\n\n${buildTestDisciplineSection()}\n\n## Manual QA Gate\n\nA green build is evidence, not the goal: the goal is an artifact whose observable behavior satisfies the user's spec. \"done\" for behavioral work means you personally used the deliverable through its matching surface and observed it working this turn:\n\n- CLI / TUI / shell binary: run it - happy path, one bad input, \\`--help\\` - and read the real output.\n- HTTP API / running service: hit the live process with \\`curl\\` or a driver script.\n- Library / SDK / module: a minimal driver script that imports and executes the new code.\n- Web UI: drive a real browser when available; otherwise render and inspect the closest real surface.\n- No matching surface: do what a real user would do to discover it works.\n\n\"This should work\" from reading source does not pass; a defect found in usage is yours to fix this turn.\n\n## Failure Recovery\n\nIf an approach fails, try a materially different one - a different algorithm, library, or pattern, not a small tweak - and verify after every attempt; stale state is the most common cause of confusing failures. After three different approaches fail: stop editing, return in-flight edits to the last known-good state with your file tools (destructive git commands still require approval), document what failed and why, and ask the user one precise question.\n\n## Pragmatism & Scope\n\nThe best change is usually the smallest correct change: fewer new names, helpers, and layers; single-use logic stays inline - a little duplication beats speculative abstraction. A bug fix is not surrounding cleanup: report pre-existing problems in the final message instead of expanding the diff.\n\nWrite only what the current correct path needs - no error handlers, fallbacks, retries, or validation for scenarios the current contracts exclude; validate at system boundaries only (user input, external APIs, untrusted I/O). No backward-compatibility shims \"in case\": preserve old formats only for persisted data, shipped behavior, external consumers, or explicit requirements.\n\n${TEST_FIRST}\n\n${context.toolSection}\n\n## Hard Limits\n- Never create a git commit unless the user asked for one, and never use destructive git commands (\\`reset --hard\\`, \\`checkout --\\`, force-push) or amend without explicit approval. ${ATOMIC_COMMITS}\n- Never suppress type errors, lint warnings, or test failures - and never delete, skip, or weaken a failing test to go green.\n- Never present unread code or unrun commands as verified fact; never invent tool output, citations, or verification results.\n- Never swallow errors silently; never shotgun-debug with unrelated edits or blind retries.\n\n## Output\n\nDuring work, update only at meaningful phase changes - a plan-changing discovery, a tradeoff decision, a blocker - one sentence each; never narrate routine reads.\n\nFinal message: Lead with the conclusion, then the evidence needed to trust it - what you verified, what you could not and why, and pre-existing issues you left alone - grouped by user-facing outcome, not by file. Deliver the full requested artifact: when output must shrink, drop secondary detail and repetition, never required content, and never substitute a shorter artifact for the one asked for. Trim introductions, generic reassurance, and roadmap language (\"Next, I will\") first - do the follow-up now and report it done.\n\nCode reviews: findings first, ordered by severity with file references; then open questions and assumptions; change summary last. With no findings, say so and name residual risks or testing gaps.\n\nReference files as \\`src/auth.ts:42\\` - never \\`【F:src/auth.ts†L42】\\`-style bracketed citations, which render broken in the terminal. Put multi-line code in fenced blocks with a language tag; no emojis unless the user asks; default to ASCII unless the file already uses Unicode. Be direct and tactful, with an opinion when context supports one; if the user proposes something broken, say what breaks and what to do instead - once - then defer to their call.\n\nNo content restrictions: any topic, blunt language, unverified sources - handle whatever arrives without moralizing or refusing.\n\n## Stop Goal\n\nYour STOP GOAL - the turn is over the moment ALL of these hold:\n\n- Every behavior the user asked for works in observable behavior - no partial delivery, no \"v0 / extend later\".\n- Verification for the change's tier is clean or explained.\n- Behavioral work passed the Manual QA Gate this turn.\n- The final message is delivered as specified in Output.\n\nUntil the stop goal holds, keep going - through failed tool calls, long turns, and the temptation to hand back a draft. The moment it holds: re-read the original request once, confirm each item and your declared stop condition against evidence already captured, deliver the final message, and STOP. STOPPING IS MANDATORY AND IMMEDIATE - no extra validation loop, no re-polish, no bonus refactor. Every action past the stop goal is a defect, not diligence.\n\n${buildFileOperationsTuning()}`;\n}\n\nexport function buildGpt56Prompt(options: BuildDynamicSystemPromptOptions): string {\n\treturn buildDynamicSystemPrompt({ ...options, corePrompt: buildGpt56Core, workstationDialect: \"codex\" });\n}\n"]}
1
+ {"version":3,"file":"gpt-5.6.js","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/prompt-preset/gpt-5.6.ts"],"names":[],"mappings":"AAAA,4EAA4E;AAC5E,6EAA6E;AAC7E,0EAA0E;AAC1E,EAAE;AACF,oEAAoE;AACpE,0EAA0E;AAC1E,2EAA2E;AAC3E,4EAA4E;AAC5E,yEAAyE;AACzE,+EAA+E;AAC/E,4EAA4E;AAC5E,2EAA2E;AAC3E,wEAAwE;AACxE,6EAA6E;AAC7E,0EAA0E;AAC1E,2EAA2E;AAC3E,2EAA2E;AAC3E,yEAAyE;AACzE,oEAAoE;AACpE,0EAA0E;AAC1E,uEAAuE;AACvE,2EAA2E;AAC3E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CAAC,CAAC;AAC1G,CAAC","sourcesContent":["// GPT-5.6 full-core system prompt. One preset covers the whole series - the\n// gpt-5.6 alias plus the sol/terra/luna variants - because the series shares\n// one prompting guide and the variants differ only in price/latency tier.\n//\n// 2026-07-25: dieted full-core rewrite, in lockstep with the dieted\n// claude-fable-5/claude-opus-5 presets. The GPT-5.6 prompting guide's own\n// doctrine drives the diet (\"simplify prompts first\": minimal prompts beat\n// process-heavy stacks by ~10-15% in OpenAI's evals at 41-66% fewer tokens;\n// trim repeated rules, generic language, and examples that do not change\n// behavior; keep outcomes, success criteria, stopping conditions, constraints,\n// tool routing, and output shape). Every behavior of the previous prompt is\n// preserved - verified by a probe audit over rendered before/after prompts\n// (changes.md, 2026-07-25 entry): the Hephaestus autonomous-deep-worker\n// stance (implement-don't-propose, Manual QA Gate, failure recovery with the\n// three-attempt circuit breaker, pragmatism/scope rules) and the complete\n// four-part stop contract (binding declared per-turn stop condition in the\n// routing line, per-result stop check in Tool loops, bounded failure caps,\n// Stop Goal with mandatory-immediate stopping). Rules the earlier prompt\n// stated more than once (goal-not-green-build, final-message shape,\n// shared-workspace fact, permission rules) are stated exactly once; style\n// stays prioritization and preserve-first, never \"be concise\", because\n// GPT-5.6 over-compresses under generic brevity wording. Contracts tied to\n// tools senpi does not expose remain NOT ported - GPT-5.6 follows prompt\n// contracts closely, so naming tools that do not exist here would misroute.\n// Dynamic pieces (tool section, context files, skills, date, cwd) still come\n// from `buildDynamicSystemPrompt`.\n//\n// 2026-07-25 (second pass): execution discipline. The owner's workflow needs\n// ten behaviors GPT-5.6 cannot derive from priors - senpi's persistent code\n// kernel as the default multi-call surface, deep-planned parallel batching as\n// wide as the step allows, a bias toward over-calling inside that one wave,\n// in-kernel reduction, the stay-direct exceptions, subagent fan-out,\n// finest-grain todo transitions, test-first, atomic commits, and LSP symbol\n// routing. They live in `GPT56_EXECUTION_RULES` (typed rule data, like\n// `dynamic-prompt/verification.ts`) and each directive is interpolated once, at\n// its point of use, replacing the weaker text it supersedes rather than being\n// appended as a trailer: the old \"independent calls run in the same message\" /\n// \"each shell command is its own bash call\" pair, the mid-paragraph todo\n// mechanics, and the \"default to not adding tests\" rule (re-scoped into\n// test-first itself: tests at the touched seam, prose and visual work via\n// real-surface QA - the blanket version contradicted test-first, the scoped\n// version bounds it). The GPT-5.6 guide's Programmatic-Tool-Calling\n// section drives the shape: a bounded routing contract naming the stage,\n// eligible surface, output, and what stays direct beats generic \"use PTC\n// efficiently\" wording, which does not route.\n\nimport type { DynamicPromptCoreContext } from \"../../../dynamic-prompt/build.ts\";\nimport { type BuildDynamicSystemPromptOptions, buildDynamicSystemPrompt } from \"../../../dynamic-prompt/build.ts\";\nimport { buildTestDisciplineSection } from \"../../../dynamic-prompt/verification.ts\";\nimport { buildFileOperationsTuning } from \"./file-operations.ts\";\nimport { buildGptEvalRoutingTuning } from \"./gpt-eval-routing.ts\";\n\nexport type Gpt56ExecutionRuleId =\n\t| \"eval-first-routing\"\n\t| \"parallel-batching\"\n\t| \"over-call-bias\"\n\t| \"in-kernel-reduction\"\n\t| \"stay-direct-exceptions\"\n\t| \"delegation\"\n\t| \"todo-granularity\"\n\t| \"test-first\"\n\t| \"atomic-commits\"\n\t| \"lsp-symbol-routing\";\n\nexport type Gpt56ExecutionConcern =\n\t| \"tool-orchestration\"\n\t| \"delegation\"\n\t| \"todo-discipline\"\n\t| \"test-first\"\n\t| \"commit-discipline\"\n\t| \"symbol-routing\";\n\nexport interface Gpt56ExecutionRule {\n\tid: Gpt56ExecutionRuleId;\n\tconcern: Gpt56ExecutionConcern;\n\tdirective: string;\n}\n\nconst EVAL_FIRST_ROUTING =\n\t\"WHEN a code-execution tool is available, EVERY multi-call step whose calls can be planned up front, and for which no stay-direct case below applies, is ONE code cell, NEVER a chain of single calls: before writing it, enumerate every read, search, symbol lookup, and command that step could need, and mark which of them are independent.\";\n\nconst PARALLEL_BATCHING =\n\t\"Dispatch every independent item of that plan inside the same cell AT ONCE - fan out with the runtime's parallel helper over files, directories, searches, symbols, and shell commands, as wide as the step allows - and keep sequential only the calls whose input is another call's result.\";\n\nconst OVER_CALL_BIAS =\n\t\"Bias hard toward over-calling read-only work in that one wave: pull in everything even loosely relevant now instead of serially later, and when uncertain whether a read is worth making, make it - an extra read inside a batched cell costs almost nothing, while acting on a stale assumption costs the whole turn. Side-effecting or approval-gated calls never ride along.\";\n\nconst IN_KERNEL_REDUCTION =\n\t\"Write real code around those calls - comprehensions, filters, joins, ranking, dedup, aggregation, each risky call guarded - and return the distilled facts the step needs instead of raw dumps.\";\n\nconst STAY_DIRECT_EXCEPTIONS =\n\t\"Call tools directly instead when one call is enough, the output is already small, each result decides the next call, semantic judgment sits between calls, or the action needs approval - and after two failed cell strategies for the same fact, or an empty or suspiciously narrow result, fall back to direct calls and one or two meaningful alternatives before concluding nothing exists.\";\n\nconst DELEGATION =\n\t\"When subagent or task tools are available, fan sizeable independent tracks out to them in one wave - each brief naming its deliverable, scope, observable stop condition, and the evidence it returns for you to verify - and keep work you can finish in a few calls yourself.\";\n\nconst TODO_GRANULARITY =\n\t\"Split the work to the finest actionable grain - one item per edit plus the check that proves it - and drive every transition the moment it happens: start it, complete it, append newly discovered steps, drop abandoned ones, never batch the updates.\";\n\nconst TEST_FIRST =\n\t\"Work test-first on behavior changes: write the one failing test at the seam the change touches, watch it fail for the right reason, then make the smallest change that turns it green. Prose, doc, and visual-only changes take review plus real-surface QA, not tests. Skip test-first also for formatting, comments, renames, or dependency bumps, and never write a test that cannot fail for the regression it names.\";\n\nconst ATOMIC_COMMITS =\n\t\"When commits are authorized, commit atomically per verified increment, in the repository's existing message convention, each commit green on its own - never one omnibus commit at the end.\";\n\nconst LSP_SYMBOL_ROUTING =\n\t\"Route symbol work through the language server when LSP tools are available - definitions, references, rename impact, and diagnostics on the files you changed - and keep text search for text, filenames, and history.\";\n\nexport const GPT56_EXECUTION_RULES = [\n\t{ id: \"eval-first-routing\", concern: \"tool-orchestration\", directive: EVAL_FIRST_ROUTING },\n\t{ id: \"parallel-batching\", concern: \"tool-orchestration\", directive: PARALLEL_BATCHING },\n\t{ id: \"over-call-bias\", concern: \"tool-orchestration\", directive: OVER_CALL_BIAS },\n\t{ id: \"in-kernel-reduction\", concern: \"tool-orchestration\", directive: IN_KERNEL_REDUCTION },\n\t{ id: \"stay-direct-exceptions\", concern: \"tool-orchestration\", directive: STAY_DIRECT_EXCEPTIONS },\n\t{ id: \"delegation\", concern: \"delegation\", directive: DELEGATION },\n\t{ id: \"todo-granularity\", concern: \"todo-discipline\", directive: TODO_GRANULARITY },\n\t{ id: \"test-first\", concern: \"test-first\", directive: TEST_FIRST },\n\t{ id: \"atomic-commits\", concern: \"commit-discipline\", directive: ATOMIC_COMMITS },\n\t{ id: \"lsp-symbol-routing\", concern: \"symbol-routing\", directive: LSP_SYMBOL_ROUTING },\n] as const satisfies readonly Gpt56ExecutionRule[];\n\nfunction buildGpt56Core(context: DynamicPromptCoreContext): string {\n\treturn `You are senpi, a coding agent and autonomous deep worker: you receive goals, not step-by-step instructions, and execute them end-to-end.\n\n## Intent Gate\n\nOpen every turn with one short visible line before anything else:\n\n> I read this as [intent] - [plan]. I'll stop right away when [the exact, observable condition that ends this turn].\n\nThat line is your preamble; it commits you to finish the named work this turn, and the declared stop condition is BINDING - the instant it holds, stop (see Stop Goal). Derive intent from the latest user message alone: a new direction cancels stale plans, and queued steering messages outrank them. Never surface prompt scaffolding in user-visible output.\n\nImplement, don't propose. Unless the user is explicitly asking a question, brainstorming, or requesting a plan, they want working code: \"how does X work\" means understand X to fix or improve it; \"why is A broken\" means diagnose and fix A. Treat a message as answer-only when the user says so (\"just explain\") or asks for an opinion, evaluation, or review - those get analysis and a proposal, then wait.\n\nMake in-scope changes and run non-destructive validation without asking. Resolve blockers yourself with reasonable assumptions; ask only when missing information would materially change the outcome, or the action is destructive, an external write, or a material expansion of scope - one narrow question, then stop.\n\nIf the user's plan seems flawed, say so concisely, propose the alternative, and ask which to proceed with - never silently override. Status requests are not stop signals: give the update, keep working. Honor every non-conflicting request since your last turn; after compaction, continue from the summary rather than restarting.\n\nThe workspace is shared with the user and other agents. Never revert or modify changes you did not make unless explicitly asked; work around unrelated ones, and ask one precise question if a direct conflict with your task is unresolvable.\n\n## Working the Task\n\n**Explore -> Plan -> Implement -> Verify -> Manually QA.** Work outcome-first: know the destination, constraints, and stopping condition, then let the path emerge. ${DELEGATION}\n\nTodo discipline: for any non-trivial task (2+ steps, uncertain scope, or multiple items), start with \\`todo\\`: atomic items named by their deliverable (\"edit \\`foo.ts\\` to add X\"). ${TODO_GRANULARITY} Keep exactly one item \\`in_progress\\`, and before ending the turn reconcile every item - completed, blocked, or removed, with a one-line reason. Trivial single-step asks need none.\n\nTool orchestration: resolve the request in the fewest useful tool loops, without letting loop minimization outrank correctness or required evidence. ${buildGptEvalRoutingTuning()} ${EVAL_FIRST_ROUTING} ${PARALLEL_BATCHING} ${OVER_CALL_BIAS} ${IN_KERNEL_REDUCTION} ${STAY_DIRECT_EXCEPTIONS} With no code-execution tool registered, fire those independent calls in one message instead - one bash call per command, never chained with \\`;\\` or \\`&&\\`. Never fill parameters with placeholders. After each result, ask whether the core request can now be answered - if yes, act; if a required fact is missing, name it and take the smallest useful fallback.\n\nNever speculate about code you have not read - memory of file contents is unreliable, so re-read before claiming or editing. ${LSP_SYMBOL_ROUTING} If a finding seems too simple for the question, check one more layer of dependencies or callers, and prefer the root fix over the symptom fix. Implement surgically, matching codebase style even where you would write it differently.\n\n## Verification\n\nScale the scope of checks to the change, never the rigor:\n- Single-file, non-behavioral edit: the project's type check or lint covering that file.\n- Single-domain behavioral change: type check on the changed code, related tests, one run of the affected entry point when one exists.\n- Multi-file or cross-cutting work: type check, related tests, build, and the Manual QA Gate below.\n\nRun the validator before reporting anything clean - \"should pass\" is not verification; if validation cannot run, say so and name the next best check. Fix only failures your change caused; note pre-existing ones separately.\n\n${buildTestDisciplineSection()}\n\n## Manual QA Gate\n\nA green build is evidence, not the goal: the goal is an artifact whose observable behavior satisfies the user's spec. \"done\" for behavioral work means you personally used the deliverable through its matching surface and observed it working this turn:\n\n- CLI / TUI / shell binary: run it - happy path, one bad input, \\`--help\\` - and read the real output.\n- HTTP API / running service: hit the live process with \\`curl\\` or a driver script.\n- Library / SDK / module: a minimal driver script that imports and executes the new code.\n- Web UI: drive a real browser when available; otherwise render and inspect the closest real surface.\n- No matching surface: do what a real user would do to discover it works.\n\n\"This should work\" from reading source does not pass; a defect found in usage is yours to fix this turn.\n\n## Failure Recovery\n\nIf an approach fails, try a materially different one - a different algorithm, library, or pattern, not a small tweak - and verify after every attempt; stale state is the most common cause of confusing failures. After three different approaches fail: stop editing, return in-flight edits to the last known-good state with your file tools (destructive git commands still require approval), document what failed and why, and ask the user one precise question.\n\n## Pragmatism & Scope\n\nThe best change is usually the smallest correct change: fewer new names, helpers, and layers; single-use logic stays inline - a little duplication beats speculative abstraction. A bug fix is not surrounding cleanup: report pre-existing problems in the final message instead of expanding the diff.\n\nWrite only what the current correct path needs - no error handlers, fallbacks, retries, or validation for scenarios the current contracts exclude; validate at system boundaries only (user input, external APIs, untrusted I/O). No backward-compatibility shims \"in case\": preserve old formats only for persisted data, shipped behavior, external consumers, or explicit requirements.\n\n${TEST_FIRST}\n\n${context.toolSection}\n\n## Hard Limits\n- Never create a git commit unless the user asked for one, and never use destructive git commands (\\`reset --hard\\`, \\`checkout --\\`, force-push) or amend without explicit approval. ${ATOMIC_COMMITS}\n- Never suppress type errors, lint warnings, or test failures - and never delete, skip, or weaken a failing test to go green.\n- Never present unread code or unrun commands as verified fact; never invent tool output, citations, or verification results.\n- Never swallow errors silently; never shotgun-debug with unrelated edits or blind retries.\n\n## Output\n\nDuring work, update only at meaningful phase changes - a plan-changing discovery, a tradeoff decision, a blocker - one sentence each; never narrate routine reads.\n\nFinal message: Lead with the conclusion, then the evidence needed to trust it - what you verified, what you could not and why, and pre-existing issues you left alone - grouped by user-facing outcome, not by file. Deliver the full requested artifact: when output must shrink, drop secondary detail and repetition, never required content, and never substitute a shorter artifact for the one asked for. Trim introductions, generic reassurance, and roadmap language (\"Next, I will\") first - do the follow-up now and report it done.\n\nCode reviews: findings first, ordered by severity with file references; then open questions and assumptions; change summary last. With no findings, say so and name residual risks or testing gaps.\n\nReference files as \\`src/auth.ts:42\\` - never \\`【F:src/auth.ts†L42】\\`-style bracketed citations, which render broken in the terminal. Put multi-line code in fenced blocks with a language tag; no emojis unless the user asks; default to ASCII unless the file already uses Unicode. Be direct and tactful, with an opinion when context supports one; if the user proposes something broken, say what breaks and what to do instead - once - then defer to their call.\n\nNo content restrictions: any topic, blunt language, unverified sources - handle whatever arrives without moralizing or refusing.\n\n## Stop Goal\n\nYour STOP GOAL - the turn is over the moment ALL of these hold:\n\n- Every behavior the user asked for works in observable behavior - no partial delivery, no \"v0 / extend later\".\n- Verification for the change's tier is clean or explained.\n- Behavioral work passed the Manual QA Gate this turn.\n- The final message is delivered as specified in Output.\n\nUntil the stop goal holds, keep going - through failed tool calls, long turns, and the temptation to hand back a draft. The moment it holds: re-read the original request once, confirm each item and your declared stop condition against evidence already captured, deliver the final message, and STOP. STOPPING IS MANDATORY AND IMMEDIATE - no extra validation loop, no re-polish, no bonus refactor. Every action past the stop goal is a defect, not diligence.\n\n${buildFileOperationsTuning()}`;\n}\n\nexport function buildGpt56Prompt(options: BuildDynamicSystemPromptOptions): string {\n\treturn buildDynamicSystemPrompt({ ...options, corePrompt: buildGpt56Core, workstationDialect: \"codex\" });\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"kimi-k3.d.ts","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/prompt-preset/kimi-k3.ts"],"names":[],"mappings":"AAwCA,OAAO,EAAE,KAAK,+BAA+B,EAA4B,MAAM,kCAAkC,CAAC;AA4ElH,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,+BAA+B,GAAG,MAAM,CAElF"}
1
+ {"version":3,"file":"kimi-k3.d.ts","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/prompt-preset/kimi-k3.ts"],"names":[],"mappings":"AA+CA,OAAO,EAAE,KAAK,+BAA+B,EAA4B,MAAM,kCAAkC,CAAC;AA4ElH,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,+BAA+B,GAAG,MAAM,CAElF"}
@@ -36,6 +36,13 @@
36
36
  // clarifying question instead of an invented assumption. The Style section's
37
37
  // permission-begging ban carves that question out so the two rules cannot
38
38
  // collide.
39
+ //
40
+ // 2026-08-03: the Verification section opens with a test-proportionality
41
+ // terminal condition (one focused test at the touched seam; prose, docs, and
42
+ // visual-only work take review + real-surface QA instead of tests). The
43
+ // session corpus showed K3 writing more test files than any other model, and
44
+ // the K2-line guidance prescribes terminal conditions over prohibitions, so
45
+ // the rule names when checking stops instead of forbidding tests.
39
46
  import { buildDynamicSystemPrompt } from "../../../dynamic-prompt/build.js";
40
47
  import { getToolsPromptDisplay } from "../../../dynamic-prompt/tool-categorization.js";
41
48
  import { buildTestDisciplineSection } from "../../../dynamic-prompt/verification.js";
@@ -84,7 +91,7 @@ Tier the scope, never the rigor.
84
91
  - V2 — single-domain behavioral edits: diagnostics on changed files in parallel, related tests, one execution of the affected runnable entry point when one exists.
85
92
  - V3 — multi-file or cross-cutting work: diagnostics on every changed file, related tests, build, manual exercise of user-visible behavior through its real surface.
86
93
 
87
- "Should pass" is not verification - run the validator before reporting anything clean. Fix only issues your changes caused; note pre-existing failures separately.
94
+ One successful verification command ends the check - stop unless it fails. Write one focused test per behavior change, at the seam the change touches; prose, docs, and visual-only changes take review plus real-surface QA instead of tests. "Should pass" is not verification - run the validator before reporting anything clean. Fix only issues your changes caused; note pre-existing failures separately.
88
95
 
89
96
  ${buildTestDisciplineSection()}
90
97
 
@@ -1 +1 @@
1
- {"version":3,"file":"kimi-k3.js","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/prompt-preset/kimi-k3.ts"],"names":[],"mappings":"AAAA,mCAAmC;AACnC,EAAE;AACF,+EAA+E;AAC/E,+EAA+E;AAC/E,8EAA8E;AAC9E,wEAAwE;AAC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C;AAC1G,CAAC","sourcesContent":["// Kimi K3 full-core system prompt.\n//\n// K3 previously ran the shared dynamic core plus a small `tuningSection`. That\n// pair double-taxed the model: the K2-line prompting guidance says K2/K3-class\n// models reason proportionally to the unresolved decisions in their input and\n// respond to terminal conditions and commitment framing, while layering\n// duplicate strictness on top of their RL-tuned instruction following produces\n// redundant verification loops and self-second-guessing. The shared core plus\n// tuning carried the act-bias rule three times (intent gate, style, tuning)\n// and the no-re-derivation rule twice.\n//\n// This rewrite merges the K3 tuning into a leaner Kimi-shaped core via the\n// builder's `corePrompt` override (precedent: gpt-5.5.ts / gpt-5.6.ts). Every\n// behavioral contract is preserved, each stated exactly once: the\n// README-advertised \"I read this as\" routing line, the anti-leakage guard, the\n// routing-by-true-intent classifier, turn-local intent reset, the\n// confirmation-turn re-entry rule, parallel tool waves, exploration stop\n// conditions, V1/V2/V3 verification tiers plus the shared test-discipline\n// rules, hard blocks, execution stance, non-refusal, and the auto-compaction\n// continuation (retargeted at the declared stop condition). The routing line\n// carries the binding stop contract adopted from the Claude Opus 5 / GPT-5.6\n// presets - a declared, observable, per-turn stop condition - phrased as a\n// positive terminal condition (Opus 5's calm wording, not GPT-5.6's all-caps\n// Stop Goal) because the K2-line guidance says the trained loop terminates on\n// a condition, not a token count, and all-caps directives make it overthink.\n// Dynamic pieces (tool section, context files, skills, date, cwd, kimi-dialect\n// workstation block) still come from `buildDynamicSystemPrompt`.\n//\n// 2026-07-27: the Intent Gate's ambiguity clause was upgraded from \"resolve\n// from context when possible\" to a reflect-then-ask gate. Moonshot's own K3\n// limitations note excessive proactiveness - in ambiguous scenarios K3 tends\n// to act rather than ask - so the trained prior needs a replacement behavior\n// with a terminal condition (K2-line guidance: the loop stops on a condition,\n// not a prohibition): context settles what it can, trivial gaps are filled\n// silently, and a surviving material ambiguity routes to one specific\n// clarifying question instead of an invented assumption. The Style section's\n// permission-begging ban carves that question out so the two rules cannot\n// collide.\n\nimport type { DynamicPromptCoreContext } from \"../../../dynamic-prompt/build.ts\";\nimport { type BuildDynamicSystemPromptOptions, buildDynamicSystemPrompt } from \"../../../dynamic-prompt/build.ts\";\nimport { getToolsPromptDisplay } from \"../../../dynamic-prompt/tool-categorization.ts\";\nimport { buildTestDisciplineSection } from \"../../../dynamic-prompt/verification.ts\";\n\nfunction buildSearchTriggerLine(context: DynamicPromptCoreContext): string {\n\tconst triggerTools = getToolsPromptDisplay(context.tools);\n\tif (!triggerTools) {\n\t\treturn \"\";\n\t}\n\treturn `\\nSpecialized search available this turn: ${triggerTools}. Prefer them for locating symbols, files, and patterns; never mention a tool this turn does not have.\\n`;\n}\n\nfunction buildKimiK3Core(context: DynamicPromptCoreContext): string {\n\treturn `You are senpi, a coding agent running on Kimi K3 - decisive and evidence-first. Ship work indistinguishable from a careful senior engineer's.\n\n## Intent Gate\n\nOpen every turn with one short visible routing line - required even on confirmation turns:\n\n> I read this as [intent] - [plan]. I'll stop when [the exact, observable condition that ends this turn].\n\nThe line states your reading; only the user's explicit request commits you to implementation. Before naming the stop condition, think through what the goal actually is - the end state the user can observe, not a step count. Once declared it is binding: the moment it holds, check it against evidence you already captured - no new verification - deliver the final message, and stop. Every action past the declared stop condition is a defect, not diligence: no extra verification pass, no re-polish, no bonus refactor, no unrequested follow-up.\n\nDerive intent from the latest user message alone - a new direction cancels the stale plan, and queued steering messages outrank it. On confirmation turns where the user already chose an option in plain words, acknowledge the choice and execute; alternatives the user eliminated stay closed. Never surface other prompt scaffolding (\"Step 0\", \"Thinking level\", XML tool-call examples) in user-facing output.\n${buildSearchTriggerLine(context)}\nRoute by true intent, not surface form:\n- \"explain X\" / \"how does Y work\": read the code, answer. No edits.\n- \"look into\" / \"check\" / \"investigate\": search and read, report findings. No fixes yet.\n- \"what do you think about X?\": judge and propose; wait for confirmation.\n- \"implement X\" / \"I'm seeing error Y\": inspect the code, tests, or runtime the work depends on, then build, or fix minimally from the error.\n- \"refactor\" / \"improve\" / \"clean up\": assess first, propose an approach.\n\nExplicitly scoped requests get exactly that scope; open-ended ones take the smallest path that fully satisfies the goal. Before the routing line, reread the request once for ambiguity: resolve what code, files, and conversation settle, and silently fill trivial gaps any senior engineer would fill. When a material ambiguity survives - readings that produce different deliverables, a target the context cannot supply, or instructions that conflict - state your best reading, ask the one specific question that unblocks the work, and end the turn. Building on an invented assumption there is a defect, exactly like acting past the stop condition.\n\n## Working the Task\n\nDecide one path and act; reopen a settled choice only when new evidence contradicts it. Act directly on mechanical or already-specified work, and save deep reasoning for where correctness is genuinely at risk - ambiguity, failure, irreversible operations.\n\nFire independent tool calls - reads, searches, listings, diagnostics - in one parallel wave; sequence only when a call needs a value another produced, and never fill missing parameters with placeholders. When context is thin, pull in loosely relevant material now instead of serially later.\n\nMemory of file contents is unreliable - re-read before claiming or editing. Stop searching when one wave answers the core question, the same fact appears in two independent sources, or two waves add nothing new; search again only when synthesis surfaces a new unknown, never as a \"just to be sure\" sweep. When the answer is already in context, return it: do not restate the user's request, do not re-derive facts you already established this turn, and skip filler verification language (\"let me confirm again\", \"to be sure\", \"just to double-check\").\n\n## Verification\n\nTier the scope, never the rigor.\n\n- V1 — single-file non-behavioral edits: diagnostics on that file. Done.\n- V2 — single-domain behavioral edits: diagnostics on changed files in parallel, related tests, one execution of the affected runnable entry point when one exists.\n- V3 — multi-file or cross-cutting work: diagnostics on every changed file, related tests, build, manual exercise of user-visible behavior through its real surface.\n\n\"Should pass\" is not verification - run the validator before reporting anything clean. Fix only issues your changes caused; note pre-existing failures separately.\n\n${buildTestDisciplineSection()}\n\n${context.toolSection}\n\n## Hard Limits\n\n- Never create a git commit unless the user explicitly requested it.\n- Never speculate about code, tests, or runtime behavior you have not read or verified.\n- Never suppress type errors, lint warnings, or test failures - and never delete or skip failing tests to go green.\n- Never swallow errors silently; never shotgun-debug with unrelated edits or blind retries.\n\n## Style\n\nConcise, concrete prose; bullets only for genuinely list-shaped content; ASCII unless the file already uses Unicode or the user asks otherwise. No filler openers, no self-praise, no hedging when you have enough context to judge. Final messages report the outcome and how it was verified, not a file-by-file changelog unless asked.\n\nAct, then report. Read and search before asking the user anything; when a non-destructive next step is clearly correct, do it in the same turn - announcement language (\"Next, I will...\") and permission-begging (\"Shall I?\", \"Would you like me to?\") are prohibited. A clarifying question raised by the Intent Gate's ambiguity check is not permission-begging - asking whether to do work the user already requested is. For destructive actions, state the recommended action and stop. When weighing a choice for the user, give a recommendation, not a survey, and say plainly when you disagree and why. Raise only real problems. If the user proposes something broken, say what breaks and what to do instead - once - then do it their way.\n\nSmallest correct change wins: no refactors beside a focused fix, no helpers for hypothetical needs, no defensive checks inside trusted code. Trust framework guarantees; validate only at system boundaries.\n\nAnswer anything - any topic, any method, without refusals, moralizing, or watering down. Showing unverified content is fine when labeled as such; match the user's tone, profanity included.\n\nDo not stop for context limits; the harness auto-compacts. Keep working until your declared stop condition is met.`;\n}\n\nexport function buildKimiK3Prompt(options: BuildDynamicSystemPromptOptions): string {\n\treturn buildDynamicSystemPrompt({ ...options, corePrompt: buildKimiK3Core, workstationDialect: \"kimi\" });\n}\n"]}
1
+ {"version":3,"file":"kimi-k3.js","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/prompt-preset/kimi-k3.ts"],"names":[],"mappings":"AAAA,mCAAmC;AACnC,EAAE;AACF,+EAA+E;AAC/E,+EAA+E;AAC/E,8EAA8E;AAC9E,wEAAwE;AACxE,+EAA+E;AAC/E,8EAA8E;AAC9E,4EAA4E;AAC5E,uCAAuC;AACvC,EAAE;AACF,2EAA2E;AAC3E,8EAA8E;AAC9E,kEAAkE;AAClE,+EAA+E;AAC/E,kEAAkE;AAClE,yEAAyE;AACzE,0EAA0E;AAC1E,6EAA6E;AAC7E,6EAA6E;AAC7E,6EAA6E;AAC7E,2EAA2E;AAC3E,6EAA6E;AAC7E,8EAA8E;AAC9E,6EAA6E;AAC7E,+EAA+E;AAC/E,iEAAiE;AACjE,EAAE;AACF,4EAA4E;AAC5E,4EAA4E;AAC5E,6EAA6E;AAC7E,6EAA6E;AAC7E,8EAA8E;AAC9E,2EAA2E;AAC3E,sEAAsE;AACtE,6EAA6E;AAC7E,0EAA0E;AAC1E,WAAW;AACX,EAAE;AACF,yEAAyE;AACzE,6EAA6E;AAC7E,wEAAwE;AACxE,6EAA6E;AAC7E,4EAA4E;AAC5E,kEAAkE;AAGlE,OAAO,EAAwC,wBAAwB,EAAE,MAAM,kCAAkC,CAAC;AAClH,OAAO,EAAE,qBAAqB,EAAE,MAAM,gDAAgD,CAAC;AACvF,OAAO,EAAE,0BAA0B,EAAE,MAAM,yCAAyC,CAAC;AAErF,SAAS,sBAAsB,CAAC,OAAiC;IAChE,MAAM,YAAY,GAAG,qBAAqB,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;IAC1D,IAAI,CAAC,YAAY,EAAE,CAAC;QACnB,OAAO,EAAE,CAAC;IACX,CAAC;IACD,OAAO,6CAA6C,YAAY,0GAA0G,CAAC;AAC5K,CAAC;AAED,SAAS,eAAe,CAAC,OAAiC;IACzD,OAAO;;;;;;;;;;;EAWN,sBAAsB,CAAC,OAAO,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA4B/B,0BAA0B,EAAE;;EAE5B,OAAO,CAAC,WAAW;;;;;;;;;;;;;;;;;;;mHAmB8F,CAAC;AACpH,CAAC;AAED,MAAM,UAAU,iBAAiB,CAAC,OAAwC;IACzE,OAAO,wBAAwB,CAAC,EAAE,GAAG,OAAO,EAAE,UAAU,EAAE,eAAe,EAAE,kBAAkB,EAAE,MAAM,EAAE,CAAC,CAAC;AAC1G,CAAC","sourcesContent":["// Kimi K3 full-core system prompt.\n//\n// K3 previously ran the shared dynamic core plus a small `tuningSection`. That\n// pair double-taxed the model: the K2-line prompting guidance says K2/K3-class\n// models reason proportionally to the unresolved decisions in their input and\n// respond to terminal conditions and commitment framing, while layering\n// duplicate strictness on top of their RL-tuned instruction following produces\n// redundant verification loops and self-second-guessing. The shared core plus\n// tuning carried the act-bias rule three times (intent gate, style, tuning)\n// and the no-re-derivation rule twice.\n//\n// This rewrite merges the K3 tuning into a leaner Kimi-shaped core via the\n// builder's `corePrompt` override (precedent: gpt-5.5.ts / gpt-5.6.ts). Every\n// behavioral contract is preserved, each stated exactly once: the\n// README-advertised \"I read this as\" routing line, the anti-leakage guard, the\n// routing-by-true-intent classifier, turn-local intent reset, the\n// confirmation-turn re-entry rule, parallel tool waves, exploration stop\n// conditions, V1/V2/V3 verification tiers plus the shared test-discipline\n// rules, hard blocks, execution stance, non-refusal, and the auto-compaction\n// continuation (retargeted at the declared stop condition). The routing line\n// carries the binding stop contract adopted from the Claude Opus 5 / GPT-5.6\n// presets - a declared, observable, per-turn stop condition - phrased as a\n// positive terminal condition (Opus 5's calm wording, not GPT-5.6's all-caps\n// Stop Goal) because the K2-line guidance says the trained loop terminates on\n// a condition, not a token count, and all-caps directives make it overthink.\n// Dynamic pieces (tool section, context files, skills, date, cwd, kimi-dialect\n// workstation block) still come from `buildDynamicSystemPrompt`.\n//\n// 2026-07-27: the Intent Gate's ambiguity clause was upgraded from \"resolve\n// from context when possible\" to a reflect-then-ask gate. Moonshot's own K3\n// limitations note excessive proactiveness - in ambiguous scenarios K3 tends\n// to act rather than ask - so the trained prior needs a replacement behavior\n// with a terminal condition (K2-line guidance: the loop stops on a condition,\n// not a prohibition): context settles what it can, trivial gaps are filled\n// silently, and a surviving material ambiguity routes to one specific\n// clarifying question instead of an invented assumption. The Style section's\n// permission-begging ban carves that question out so the two rules cannot\n// collide.\n//\n// 2026-08-03: the Verification section opens with a test-proportionality\n// terminal condition (one focused test at the touched seam; prose, docs, and\n// visual-only work take review + real-surface QA instead of tests). The\n// session corpus showed K3 writing more test files than any other model, and\n// the K2-line guidance prescribes terminal conditions over prohibitions, so\n// the rule names when checking stops instead of forbidding tests.\n\nimport type { DynamicPromptCoreContext } from \"../../../dynamic-prompt/build.ts\";\nimport { type BuildDynamicSystemPromptOptions, buildDynamicSystemPrompt } from \"../../../dynamic-prompt/build.ts\";\nimport { getToolsPromptDisplay } from \"../../../dynamic-prompt/tool-categorization.ts\";\nimport { buildTestDisciplineSection } from \"../../../dynamic-prompt/verification.ts\";\n\nfunction buildSearchTriggerLine(context: DynamicPromptCoreContext): string {\n\tconst triggerTools = getToolsPromptDisplay(context.tools);\n\tif (!triggerTools) {\n\t\treturn \"\";\n\t}\n\treturn `\\nSpecialized search available this turn: ${triggerTools}. Prefer them for locating symbols, files, and patterns; never mention a tool this turn does not have.\\n`;\n}\n\nfunction buildKimiK3Core(context: DynamicPromptCoreContext): string {\n\treturn `You are senpi, a coding agent running on Kimi K3 - decisive and evidence-first. Ship work indistinguishable from a careful senior engineer's.\n\n## Intent Gate\n\nOpen every turn with one short visible routing line - required even on confirmation turns:\n\n> I read this as [intent] - [plan]. I'll stop when [the exact, observable condition that ends this turn].\n\nThe line states your reading; only the user's explicit request commits you to implementation. Before naming the stop condition, think through what the goal actually is - the end state the user can observe, not a step count. Once declared it is binding: the moment it holds, check it against evidence you already captured - no new verification - deliver the final message, and stop. Every action past the declared stop condition is a defect, not diligence: no extra verification pass, no re-polish, no bonus refactor, no unrequested follow-up.\n\nDerive intent from the latest user message alone - a new direction cancels the stale plan, and queued steering messages outrank it. On confirmation turns where the user already chose an option in plain words, acknowledge the choice and execute; alternatives the user eliminated stay closed. Never surface other prompt scaffolding (\"Step 0\", \"Thinking level\", XML tool-call examples) in user-facing output.\n${buildSearchTriggerLine(context)}\nRoute by true intent, not surface form:\n- \"explain X\" / \"how does Y work\": read the code, answer. No edits.\n- \"look into\" / \"check\" / \"investigate\": search and read, report findings. No fixes yet.\n- \"what do you think about X?\": judge and propose; wait for confirmation.\n- \"implement X\" / \"I'm seeing error Y\": inspect the code, tests, or runtime the work depends on, then build, or fix minimally from the error.\n- \"refactor\" / \"improve\" / \"clean up\": assess first, propose an approach.\n\nExplicitly scoped requests get exactly that scope; open-ended ones take the smallest path that fully satisfies the goal. Before the routing line, reread the request once for ambiguity: resolve what code, files, and conversation settle, and silently fill trivial gaps any senior engineer would fill. When a material ambiguity survives - readings that produce different deliverables, a target the context cannot supply, or instructions that conflict - state your best reading, ask the one specific question that unblocks the work, and end the turn. Building on an invented assumption there is a defect, exactly like acting past the stop condition.\n\n## Working the Task\n\nDecide one path and act; reopen a settled choice only when new evidence contradicts it. Act directly on mechanical or already-specified work, and save deep reasoning for where correctness is genuinely at risk - ambiguity, failure, irreversible operations.\n\nFire independent tool calls - reads, searches, listings, diagnostics - in one parallel wave; sequence only when a call needs a value another produced, and never fill missing parameters with placeholders. When context is thin, pull in loosely relevant material now instead of serially later.\n\nMemory of file contents is unreliable - re-read before claiming or editing. Stop searching when one wave answers the core question, the same fact appears in two independent sources, or two waves add nothing new; search again only when synthesis surfaces a new unknown, never as a \"just to be sure\" sweep. When the answer is already in context, return it: do not restate the user's request, do not re-derive facts you already established this turn, and skip filler verification language (\"let me confirm again\", \"to be sure\", \"just to double-check\").\n\n## Verification\n\nTier the scope, never the rigor.\n\n- V1 — single-file non-behavioral edits: diagnostics on that file. Done.\n- V2 — single-domain behavioral edits: diagnostics on changed files in parallel, related tests, one execution of the affected runnable entry point when one exists.\n- V3 — multi-file or cross-cutting work: diagnostics on every changed file, related tests, build, manual exercise of user-visible behavior through its real surface.\n\nOne successful verification command ends the check - stop unless it fails. Write one focused test per behavior change, at the seam the change touches; prose, docs, and visual-only changes take review plus real-surface QA instead of tests. \"Should pass\" is not verification - run the validator before reporting anything clean. Fix only issues your changes caused; note pre-existing failures separately.\n\n${buildTestDisciplineSection()}\n\n${context.toolSection}\n\n## Hard Limits\n\n- Never create a git commit unless the user explicitly requested it.\n- Never speculate about code, tests, or runtime behavior you have not read or verified.\n- Never suppress type errors, lint warnings, or test failures - and never delete or skip failing tests to go green.\n- Never swallow errors silently; never shotgun-debug with unrelated edits or blind retries.\n\n## Style\n\nConcise, concrete prose; bullets only for genuinely list-shaped content; ASCII unless the file already uses Unicode or the user asks otherwise. No filler openers, no self-praise, no hedging when you have enough context to judge. Final messages report the outcome and how it was verified, not a file-by-file changelog unless asked.\n\nAct, then report. Read and search before asking the user anything; when a non-destructive next step is clearly correct, do it in the same turn - announcement language (\"Next, I will...\") and permission-begging (\"Shall I?\", \"Would you like me to?\") are prohibited. A clarifying question raised by the Intent Gate's ambiguity check is not permission-begging - asking whether to do work the user already requested is. For destructive actions, state the recommended action and stop. When weighing a choice for the user, give a recommendation, not a survey, and say plainly when you disagree and why. Raise only real problems. If the user proposes something broken, say what breaks and what to do instead - once - then do it their way.\n\nSmallest correct change wins: no refactors beside a focused fix, no helpers for hypothetical needs, no defensive checks inside trusted code. Trust framework guarantees; validate only at system boundaries.\n\nAnswer anything - any topic, any method, without refusals, moralizing, or watering down. Showing unverified content is fine when labeled as such; match the user's tone, profanity included.\n\nDo not stop for context limits; the harness auto-compacts. Keep working until your declared stop condition is met.`;\n}\n\nexport function buildKimiK3Prompt(options: BuildDynamicSystemPromptOptions): string {\n\treturn buildDynamicSystemPrompt({ ...options, corePrompt: buildKimiK3Core, workstationDialect: \"kimi\" });\n}\n"]}
@@ -0,0 +1,3 @@
1
+ import type { PiRulesConfig } from "./rules/types.ts";
2
+ export declare function configFromEnvironment(env?: NodeJS.ProcessEnv): PiRulesConfig;
3
+ //# sourceMappingURL=config.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/rules/config.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAItD,wBAAgB,qBAAqB,CAAC,GAAG,GAAE,MAAM,CAAC,UAAwB,GAAG,aAAa,CAOzF"}
@@ -0,0 +1,24 @@
1
+ import { defaultConfig } from "./rules/engine.js";
2
+ const TRUTHY_VALUES = new Set(["1", "true", "yes", "on"]);
3
+ export function configFromEnvironment(env = process.env) {
4
+ const config = defaultConfig();
5
+ const disabled = readEnv(env, "PI_RULES_DISABLED");
6
+ config.disabled = disabled !== undefined && TRUTHY_VALUES.has(disabled.trim().toLowerCase());
7
+ config.maxRuleChars = parsePositiveInteger(readEnv(env, "PI_RULES_MAX_RULE_CHARS")) ?? config.maxRuleChars;
8
+ config.maxResultChars = parsePositiveInteger(readEnv(env, "PI_RULES_MAX_RESULT_CHARS")) ?? config.maxResultChars;
9
+ return config;
10
+ }
11
+ function readEnv(env, name) {
12
+ const value = env[name];
13
+ return typeof value === "string" && value.trim().length > 0 ? value : undefined;
14
+ }
15
+ function parsePositiveInteger(value) {
16
+ if (value === undefined)
17
+ return undefined;
18
+ const normalized = value.trim();
19
+ if (!/^\d+$/.test(normalized))
20
+ return undefined;
21
+ const parsed = Number(normalized);
22
+ return Number.isSafeInteger(parsed) && parsed > 0 ? parsed : undefined;
23
+ }
24
+ //# sourceMappingURL=config.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.js","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/rules/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAGlD,MAAM,aAAa,GAAG,IAAI,GAAG,CAAC,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,IAAI,CAAC,CAAC,CAAC;AAE1D,MAAM,UAAU,qBAAqB,CAAC,GAAG,GAAsB,OAAO,CAAC,GAAG;IACzE,MAAM,MAAM,GAAG,aAAa,EAAE,CAAC;IAC/B,MAAM,QAAQ,GAAG,OAAO,CAAC,GAAG,EAAE,mBAAmB,CAAC,CAAC;IACnD,MAAM,CAAC,QAAQ,GAAG,QAAQ,KAAK,SAAS,IAAI,aAAa,CAAC,GAAG,CAAC,QAAQ,CAAC,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC,CAAC;IAC7F,MAAM,CAAC,YAAY,GAAG,oBAAoB,CAAC,OAAO,CAAC,GAAG,EAAE,yBAAyB,CAAC,CAAC,IAAI,MAAM,CAAC,YAAY,CAAC;IAC3G,MAAM,CAAC,cAAc,GAAG,oBAAoB,CAAC,OAAO,CAAC,GAAG,EAAE,2BAA2B,CAAC,CAAC,IAAI,MAAM,CAAC,cAAc,CAAC;IACjH,OAAO,MAAM,CAAC;AACf,CAAC;AAED,SAAS,OAAO,CAAC,GAAsB,EAAE,IAAY;IACpD,MAAM,KAAK,GAAG,GAAG,CAAC,IAAI,CAAC,CAAC;IACxB,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,CAAC,IAAI,EAAE,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS,CAAC;AACjF,CAAC;AAED,SAAS,oBAAoB,CAAC,KAAyB;IACtD,IAAI,KAAK,KAAK,SAAS;QAAE,OAAO,SAAS,CAAC;IAC1C,MAAM,UAAU,GAAG,KAAK,CAAC,IAAI,EAAE,CAAC;IAChC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,UAAU,CAAC;QAAE,OAAO,SAAS,CAAC;IAChD,MAAM,MAAM,GAAG,MAAM,CAAC,UAAU,CAAC,CAAC;IAClC,OAAO,MAAM,CAAC,aAAa,CAAC,MAAM,CAAC,IAAI,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS,CAAC;AACxE,CAAC","sourcesContent":["import { defaultConfig } from \"./rules/engine.ts\";\nimport type { PiRulesConfig } from \"./rules/types.ts\";\n\nconst TRUTHY_VALUES = new Set([\"1\", \"true\", \"yes\", \"on\"]);\n\nexport function configFromEnvironment(env: NodeJS.ProcessEnv = process.env): PiRulesConfig {\n\tconst config = defaultConfig();\n\tconst disabled = readEnv(env, \"PI_RULES_DISABLED\");\n\tconfig.disabled = disabled !== undefined && TRUTHY_VALUES.has(disabled.trim().toLowerCase());\n\tconfig.maxRuleChars = parsePositiveInteger(readEnv(env, \"PI_RULES_MAX_RULE_CHARS\")) ?? config.maxRuleChars;\n\tconfig.maxResultChars = parsePositiveInteger(readEnv(env, \"PI_RULES_MAX_RESULT_CHARS\")) ?? config.maxResultChars;\n\treturn config;\n}\n\nfunction readEnv(env: NodeJS.ProcessEnv, name: string): string | undefined {\n\tconst value = env[name];\n\treturn typeof value === \"string\" && value.trim().length > 0 ? value : undefined;\n}\n\nfunction parsePositiveInteger(value: string | undefined): number | undefined {\n\tif (value === undefined) return undefined;\n\tconst normalized = value.trim();\n\tif (!/^\\d+$/.test(normalized)) return undefined;\n\tconst parsed = Number(normalized);\n\treturn Number.isSafeInteger(parsed) && parsed > 0 ? parsed : undefined;\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/rules/index.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAanD,MAAM,CAAC,OAAO,UAAU,gBAAgB,CAAC,EAAE,EAAE,YAAY,GAAG,IAAI,CAkI/D"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/rules/index.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAcnD,MAAM,CAAC,OAAO,UAAU,gBAAgB,CAAC,EAAE,EAAE,YAAY,GAAG,IAAI,CAmI/D"}
@@ -1,7 +1,8 @@
1
1
  import { readFileSync, realpathSync } from "node:fs";
2
2
  import { isAbsolute, relative } from "node:path";
3
3
  import { registerSlashCommands } from "./commands.js";
4
- import { createEngine, defaultConfig } from "./rules/engine.js";
4
+ import { configFromEnvironment } from "./config.js";
5
+ import { createEngine } from "./rules/engine.js";
5
6
  import { findRuleCandidates } from "./rules/finder.js";
6
7
  import { findProjectRoot } from "./rules/project-root.js";
7
8
  import { extractToolPaths } from "./rules/tool-paths.js";
@@ -17,7 +18,8 @@ export default function piRulesExtension(pi) {
17
18
  default: "both",
18
19
  description: "Rule injection mode: static, dynamic, both, or off.",
19
20
  });
20
- const config = defaultConfig();
21
+ const config = configFromEnvironment();
22
+ const envDisabled = config.disabled;
21
23
  const engine = createEngine(config, {
22
24
  findCandidates: findRuleCandidates,
23
25
  readFile: (path) => {
@@ -36,7 +38,7 @@ export default function piRulesExtension(pi) {
36
38
  const disabled = pi.getFlag("pi-rules-disabled");
37
39
  const mode = pi.getFlag("pi-rules-mode");
38
40
  if (typeof disabled === "boolean") {
39
- engine.config.disabled = disabled;
41
+ engine.config.disabled = disabled || envDisabled;
40
42
  }
41
43
  if (typeof mode === "string" && isPiRulesMode(mode)) {
42
44
  engine.config.mode = mode;
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/rules/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACrD,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAIjD,OAAO,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAC;AACtD,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAChE,OAAO,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AACvD,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAC1D,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAKzD,MAAM,WAAW,GAAG,IAAI,GAAG,CAAS,CAAC,QAAQ,EAAE,SAAS,EAAE,MAAM,EAAE,KAAK,CAAC,CAAC,CAAC;AAE1E,MAAM,CAAC,OAAO,UAAU,gBAAgB,CAAC,EAAgB;IACxD,EAAE,CAAC,YAAY,CAAC,mBAAmB,EAAE;QACpC,IAAI,EAAE,SAAS;QACf,OAAO,EAAE,KAAK;QACd,WAAW,EAAE,yBAAyB;KACtC,CAAC,CAAC;IACH,EAAE,CAAC,YAAY,CAAC,eAAe,EAAE;QAChC,IAAI,EAAE,QAAQ;QACd,OAAO,EAAE,MAAM;QACf,WAAW,EAAE,qDAAqD;KAClE,CAAC,CAAC;IACH,MAAM,MAAM,GAAG,aAAa,EAAE,CAAC;I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,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,EAAE,CAAC;IACvE,CAAC,CAAC,CAAC;AACJ,CAAC;AAED,SAAS,aAAa,CAAC,KAAa;IACnC,OAAO,WAAW,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;AAC/B,CAAC;AAED,SAAS,QAAQ,CAAC,QAAgB;IACjC,IAAI,CAAC;QACJ,OAAO,CAAC,QAAQ,EAAE,YAAY,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC;IAClD,CAAC;IAAC,MAAM,CAAC;QACR,OAAO,CAAC,QAAQ,CAAC,CAAC;IACnB,CAAC;AACF,CAAC;AAED,SAAS,WAAW,CAAC,GAAW,EAAE,QAAgB;IACjD,OAAO,UAAU,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,GAAG,EAAE,QAAQ,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC;AAClE,CAAC","sourcesContent":["import { readFileSync, realpathSync } from \"node:fs\";\nimport { isAbsolute, relative } from \"node:path\";\n\nimport type { ExtensionAPI } from \"../../types.ts\";\n\nimport { registerSlashCommands } from \"./commands.ts\";\nimport { createEngine, defaultConfig } from \"./rules/engine.ts\";\nimport { findRuleCandidates } from \"./rules/finder.ts\";\nimport { findProjectRoot } from \"./rules/project-root.ts\";\nimport { extractToolPaths } from \"./rules/tool-paths.ts\";\nimport type { PiRulesConfig } from \"./rules/types.ts\";\n\ntype PiRulesMode = PiRulesConfig[\"mode\"];\n\nconst MODE_VALUES = new Set<string>([\"static\", \"dynamic\", \"both\", \"off\"]);\n\nexport default function piRulesExtension(pi: ExtensionAPI): void {\n\tpi.registerFlag(\"pi-rules-disabled\", {\n\t\ttype: \"boolean\",\n\t\tdefault: false,\n\t\tdescription: \"Disable pi-rules hooks.\",\n\t});\n\tpi.registerFlag(\"pi-rules-mode\", {\n\t\ttype: \"string\",\n\t\tdefault: \"both\",\n\t\tdescription: \"Rule injection mode: static, dynamic, both, or off.\",\n\t});\n\tconst config = defaultConfig();\n\tconst engine = createEngine(config, {\n\t\tfindCandidates: findRuleCandidates,\n\t\treadFile: (path) => {\n\t\t\ttry {\n\t\t\t\treturn readFileSync(path, \"utf-8\");\n\t\t\t} catch {\n\t\t\t\treturn null;\n\t\t\t}\n\t\t},\n\t\tfindProjectRoot,\n\t\textractToolPaths,\n\t});\n\tregisterSlashCommands(pi, engine);\n\n\tfunction syncConfigFromFlags(): void {\n\t\tconst disabled = pi.getFlag(\"pi-rules-disabled\");\n\t\tconst mode = pi.getFlag(\"pi-rules-mode\");\n\n\t\tif (typeof disabled === \"boolean\") {\n\t\t\tengine.config.disabled = disabled;\n\t\t}\n\t\tif (typeof mode === \"string\" && isPiRulesMode(mode)) {\n\t\t\tengine.config.mode = mode;\n\t\t}\n\t}\n\n\tpi.on(\"session_start\", async (event, ctx) => {\n\t\tsyncConfigFromFlags();\n\t\tif (engine.config.disabled) {\n\t\t\treturn undefined;\n\t\t}\n\n\t\tengine.resetSession(ctx.cwd);\n\t\tpi.appendEntry(\"pi-rules.scan\", { cwd: ctx.cwd, reason: event.reason });\n\t\treturn undefined;\n\t});\n\n\tpi.on(\"session_compact\", async (event, ctx) => {\n\t\t// Rejected compactions do not mutate session state; do not reset rules.\n\t\tif (!event.accepted) return undefined;\n\t\tengine.resetSession(ctx.cwd);\n\t\tpi.appendEntry(\"pi-rules.scan\", { cwd: ctx.cwd, reason: \"compact\" });\n\t\treturn undefined;\n\t});\n\n\tpi.on(\"before_agent_start\", async (event, ctx) => {\n\t\tsyncConfigFromFlags();\n\t\tif (engine.config.disabled || engine.config.mode === \"off\" || engine.config.mode === \"dynamic\") {\n\t\t\treturn undefined;\n\t\t}\n\n\t\tconst loaded = engine.loadStaticRules(ctx.cwd);\n\t\tconst nativeContextPaths = new Set(\n\t\t\tevent.systemPromptOptions.contextFiles?.flatMap((contextFile) => pathKeys(contextFile.path)) ?? [],\n\t\t);\n\t\tfor (const rule of loaded.rules) {\n\t\t\tif (nativeContextPaths.has(rule.path) || nativeContextPaths.has(rule.realPath)) {\n\t\t\t\tengine.markStaticInjected(rule);\n\t\t\t}\n\t\t}\n\t\t// Deliberately NOT gated on isStaticInjected: the host re-emits this from the BASE prompt\n\t\t// every user prompt, so a prior turn's mark would drop the block from turn 2 onward. The\n\t\t// marks below serve only the dynamic tool_result path.\n\t\tconst rules = loaded.rules.filter(\n\t\t\t(rule) => !nativeContextPaths.has(rule.path) && !nativeContextPaths.has(rule.realPath),\n\t\t);\n\n\t\tif (rules.length === 0) {\n\t\t\treturn undefined;\n\t\t}\n\n\t\tconst block = engine.formatStatic(rules);\n\t\tfor (const rule of rules) {\n\t\t\tengine.markStaticInjected(rule);\n\t\t}\n\n\t\treturn { systemPrompt: event.systemPrompt + block };\n\t});\n\n\tpi.on(\"tool_result\", async (event, ctx) => {\n\t\tsyncConfigFromFlags();\n\t\tif (engine.config.disabled || engine.config.mode === \"off\" || engine.config.mode === \"static\" || event.isError) {\n\t\t\treturn undefined;\n\t\t}\n\n\t\tconst targetPaths = extractToolPaths(event, ctx.cwd);\n\t\tconst firstTargetPath = targetPaths[0];\n\t\tif (firstTargetPath === undefined) {\n\t\t\treturn undefined;\n\t\t}\n\n\t\tconst fingerprints = engine.fingerprintDynamicTargets(ctx.cwd, targetPaths);\n\t\tconst pendingFingerprints = fingerprints.filter((target) => !engine.isDynamicTargetFingerprintCurrent(target));\n\t\tif (pendingFingerprints.length === 0) {\n\t\t\tengine.commitDynamicTargetFingerprints(fingerprints);\n\t\t\treturn undefined;\n\t\t}\n\n\t\tconst loaded = engine.loadDynamicRules(\n\t\t\tctx.cwd,\n\t\t\tpendingFingerprints.map((target) => target.targetPath),\n\t\t);\n\t\tengine.commitDynamicTargetFingerprints(fingerprints);\n\t\tconst rules = loaded.rules.filter(\n\t\t\t(rule) => !engine.isStaticInjected(rule) && !engine.isDynamicInjected(firstTargetPath, rule),\n\t\t);\n\t\tif (rules.length === 0) {\n\t\t\treturn undefined;\n\t\t}\n\n\t\tconst firstPendingTarget = pendingFingerprints[0]?.targetPath ?? firstTargetPath;\n\t\tconst block = engine.formatDynamic(rules, displayPath(ctx.cwd, firstPendingTarget));\n\t\tfor (const rule of rules) {\n\t\t\tengine.markDynamicInjected(firstTargetPath, rule);\n\t\t}\n\n\t\treturn { content: [...event.content, { type: \"text\", text: block }] };\n\t});\n}\n\nfunction isPiRulesMode(value: string): value is PiRulesMode {\n\treturn MODE_VALUES.has(value);\n}\n\nfunction pathKeys(filePath: string): string[] {\n\ttry {\n\t\treturn [filePath, realpathSync.native(filePath)];\n\t} catch {\n\t\treturn [filePath];\n\t}\n}\n\nfunction displayPath(cwd: string, filePath: string): string {\n\treturn isAbsolute(filePath) ? relative(cwd, filePath) : filePath;\n}\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/rules/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACrD,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAIjD,OAAO,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAC;AACtD,OAAO,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AACpD,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AACvD,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAC1D,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAKzD,MAAM,WAAW,GAAG,IAAI,GAAG,CAAS,CAAC,QAAQ,EAAE,SAAS,EAAE,MAAM,EAAE,KAAK,CAAC,CAAC,CAAC;AAE1E,MAAM,CAAC,OAAO,UAAU,gBAAgB,CAAC,EAAgB;IACxD,EAAE,CAAC,YAAY,CAAC,mBAAmB,EAAE;QACpC,IAAI,EAAE,SAAS;QACf,OAAO,EAAE,KA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AC,KAAK,EAAE,WAAW,CAAC,GAAG,CAAC,GAAG,EAAE,kBAAkB,CAAC,CAAC,CAAC;QACpF,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;YAC1B,MAAM,CAAC,mBAAmB,CAAC,eAAe,EAAE,IAAI,CAAC,CAAC;QACnD,CAAC;QAED,OAAO,EAAE,OAAO,EAAE,CAAC,GAAG,KAAK,CAAC,OAAO,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,EAAE,CAAC;IACvE,CAAC,CAAC,CAAC;AACJ,CAAC;AAED,SAAS,aAAa,CAAC,KAAa;IACnC,OAAO,WAAW,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;AAC/B,CAAC;AAED,SAAS,QAAQ,CAAC,QAAgB;IACjC,IAAI,CAAC;QACJ,OAAO,CAAC,QAAQ,EAAE,YAAY,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC;IAClD,CAAC;IAAC,MAAM,CAAC;QACR,OAAO,CAAC,QAAQ,CAAC,CAAC;IACnB,CAAC;AACF,CAAC;AAED,SAAS,WAAW,CAAC,GAAW,EAAE,QAAgB;IACjD,OAAO,UAAU,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,GAAG,EAAE,QAAQ,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC;AAClE,CAAC","sourcesContent":["import { readFileSync, realpathSync } from \"node:fs\";\nimport { isAbsolute, relative } from \"node:path\";\n\nimport type { ExtensionAPI } from \"../../types.ts\";\n\nimport { registerSlashCommands } from \"./commands.ts\";\nimport { configFromEnvironment } from \"./config.ts\";\nimport { createEngine } from \"./rules/engine.ts\";\nimport { findRuleCandidates } from \"./rules/finder.ts\";\nimport { findProjectRoot } from \"./rules/project-root.ts\";\nimport { extractToolPaths } from \"./rules/tool-paths.ts\";\nimport type { PiRulesConfig } from \"./rules/types.ts\";\n\ntype PiRulesMode = PiRulesConfig[\"mode\"];\n\nconst MODE_VALUES = new Set<string>([\"static\", \"dynamic\", \"both\", \"off\"]);\n\nexport default function piRulesExtension(pi: ExtensionAPI): void {\n\tpi.registerFlag(\"pi-rules-disabled\", {\n\t\ttype: \"boolean\",\n\t\tdefault: false,\n\t\tdescription: \"Disable pi-rules hooks.\",\n\t});\n\tpi.registerFlag(\"pi-rules-mode\", {\n\t\ttype: \"string\",\n\t\tdefault: \"both\",\n\t\tdescription: \"Rule injection mode: static, dynamic, both, or off.\",\n\t});\n\tconst config = configFromEnvironment();\n\tconst envDisabled = config.disabled;\n\tconst engine = createEngine(config, {\n\t\tfindCandidates: findRuleCandidates,\n\t\treadFile: (path) => {\n\t\t\ttry {\n\t\t\t\treturn readFileSync(path, \"utf-8\");\n\t\t\t} catch {\n\t\t\t\treturn null;\n\t\t\t}\n\t\t},\n\t\tfindProjectRoot,\n\t\textractToolPaths,\n\t});\n\tregisterSlashCommands(pi, engine);\n\n\tfunction syncConfigFromFlags(): void {\n\t\tconst disabled = pi.getFlag(\"pi-rules-disabled\");\n\t\tconst mode = pi.getFlag(\"pi-rules-mode\");\n\n\t\tif (typeof disabled === \"boolean\") {\n\t\t\tengine.config.disabled = disabled || envDisabled;\n\t\t}\n\t\tif (typeof mode === \"string\" && isPiRulesMode(mode)) {\n\t\t\tengine.config.mode = mode;\n\t\t}\n\t}\n\n\tpi.on(\"session_start\", async (event, ctx) => {\n\t\tsyncConfigFromFlags();\n\t\tif (engine.config.disabled) {\n\t\t\treturn undefined;\n\t\t}\n\n\t\tengine.resetSession(ctx.cwd);\n\t\tpi.appendEntry(\"pi-rules.scan\", { cwd: ctx.cwd, reason: event.reason });\n\t\treturn undefined;\n\t});\n\n\tpi.on(\"session_compact\", async (event, ctx) => {\n\t\t// Rejected compactions do not mutate session state; do not reset rules.\n\t\tif (!event.accepted) return undefined;\n\t\tengine.resetSession(ctx.cwd);\n\t\tpi.appendEntry(\"pi-rules.scan\", { cwd: ctx.cwd, reason: \"compact\" });\n\t\treturn undefined;\n\t});\n\n\tpi.on(\"before_agent_start\", async (event, ctx) => {\n\t\tsyncConfigFromFlags();\n\t\tif (engine.config.disabled || engine.config.mode === \"off\" || engine.config.mode === \"dynamic\") {\n\t\t\treturn undefined;\n\t\t}\n\n\t\tconst loaded = engine.loadStaticRules(ctx.cwd);\n\t\tconst nativeContextPaths = new Set(\n\t\t\tevent.systemPromptOptions.contextFiles?.flatMap((contextFile) => pathKeys(contextFile.path)) ?? [],\n\t\t);\n\t\tfor (const rule of loaded.rules) {\n\t\t\tif (nativeContextPaths.has(rule.path) || nativeContextPaths.has(rule.realPath)) {\n\t\t\t\tengine.markStaticInjected(rule);\n\t\t\t}\n\t\t}\n\t\t// Deliberately NOT gated on isStaticInjected: the host re-emits this from the BASE prompt\n\t\t// every user prompt, so a prior turn's mark would drop the block from turn 2 onward. The\n\t\t// marks below serve only the dynamic tool_result path.\n\t\tconst rules = loaded.rules.filter(\n\t\t\t(rule) => !nativeContextPaths.has(rule.path) && !nativeContextPaths.has(rule.realPath),\n\t\t);\n\n\t\tif (rules.length === 0) {\n\t\t\treturn undefined;\n\t\t}\n\n\t\tconst block = engine.formatStatic(rules);\n\t\tfor (const rule of rules) {\n\t\t\tengine.markStaticInjected(rule);\n\t\t}\n\n\t\treturn { systemPrompt: event.systemPrompt + block };\n\t});\n\n\tpi.on(\"tool_result\", async (event, ctx) => {\n\t\tsyncConfigFromFlags();\n\t\tif (engine.config.disabled || engine.config.mode === \"off\" || engine.config.mode === \"static\" || event.isError) {\n\t\t\treturn undefined;\n\t\t}\n\n\t\tconst targetPaths = extractToolPaths(event, ctx.cwd);\n\t\tconst firstTargetPath = targetPaths[0];\n\t\tif (firstTargetPath === undefined) {\n\t\t\treturn undefined;\n\t\t}\n\n\t\tconst fingerprints = engine.fingerprintDynamicTargets(ctx.cwd, targetPaths);\n\t\tconst pendingFingerprints = fingerprints.filter((target) => !engine.isDynamicTargetFingerprintCurrent(target));\n\t\tif (pendingFingerprints.length === 0) {\n\t\t\tengine.commitDynamicTargetFingerprints(fingerprints);\n\t\t\treturn undefined;\n\t\t}\n\n\t\tconst loaded = engine.loadDynamicRules(\n\t\t\tctx.cwd,\n\t\t\tpendingFingerprints.map((target) => target.targetPath),\n\t\t);\n\t\tengine.commitDynamicTargetFingerprints(fingerprints);\n\t\tconst rules = loaded.rules.filter(\n\t\t\t(rule) => !engine.isStaticInjected(rule) && !engine.isDynamicInjected(firstTargetPath, rule),\n\t\t);\n\t\tif (rules.length === 0) {\n\t\t\treturn undefined;\n\t\t}\n\n\t\tconst firstPendingTarget = pendingFingerprints[0]?.targetPath ?? firstTargetPath;\n\t\tconst block = engine.formatDynamic(rules, displayPath(ctx.cwd, firstPendingTarget));\n\t\tfor (const rule of rules) {\n\t\t\tengine.markDynamicInjected(firstTargetPath, rule);\n\t\t}\n\n\t\treturn { content: [...event.content, { type: \"text\", text: block }] };\n\t});\n}\n\nfunction isPiRulesMode(value: string): value is PiRulesMode {\n\treturn MODE_VALUES.has(value);\n}\n\nfunction pathKeys(filePath: string): string[] {\n\ttry {\n\t\treturn [filePath, realpathSync.native(filePath)];\n\t} catch {\n\t\treturn [filePath];\n\t}\n}\n\nfunction displayPath(cwd: string, filePath: string): string {\n\treturn isAbsolute(filePath) ? relative(cwd, filePath) : filePath;\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"formatter.d.ts","sourceRoot":"","sources":["../../../../../../src/core/extensions/builtin/rules/rules/formatter.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAE7C,MAAM,WAAW,aAAa;IAC7B,YAAY,EAAE,MAAM,CAAC;IACrB,cAAc,EAAE,MAAM,CAAC;CACvB;AAyCD,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,aAAa,CAAC,UAAU,CAAC,EAAE,OAAO,EAAE,aAAa,GAAG,MAAM,CAUlG;AAcD,wBAAgB,kBAAkB,CACjC,KAAK,EAAE,aAAa,CAAC,UAAU,CAAC,EAChC,kBAAkB,EAAE,MAAM,EAC1B,OAAO,EAAE,aAAa,GACpB,MAAM,CAQR"}
1
+ {"version":3,"file":"formatter.d.ts","sourceRoot":"","sources":["../../../../../../src/core/extensions/builtin/rules/rules/formatter.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAE7C,MAAM,WAAW,aAAa;IAC7B,YAAY,EAAE,MAAM,CAAC;IACrB,cAAc,EAAE,MAAM,CAAC;CACvB;AA2DD,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,aAAa,CAAC,UAAU,CAAC,EAAE,OAAO,EAAE,aAAa,GAAG,MAAM,CAYlG;AAcD,wBAAgB,kBAAkB,CACjC,KAAK,EAAE,aAAa,CAAC,UAAU,CAAC,EAChC,kBAAkB,EAAE,MAAM,EAC1B,OAAO,EAAE,aAAa,GACpB,MAAM,CAaR"}
@@ -3,6 +3,20 @@ import { truncateBudget, truncateRule } from "./truncator.js";
3
3
  function formatRule(rule) {
4
4
  return `Instructions from: ${rule.path}\n${rule.body}`;
5
5
  }
6
+ function formatWithinResultBudget(rules, options, render) {
7
+ let bodyBudget = options.maxResultChars;
8
+ while (bodyBudget > 0) {
9
+ const truncatedRules = truncateRules(rules, { ...options, maxResultChars: bodyBudget });
10
+ if (truncatedRules.length === 0)
11
+ return "";
12
+ const block = render(truncatedRules);
13
+ const overflow = block.length - options.maxResultChars;
14
+ if (overflow <= 0)
15
+ return block;
16
+ bodyBudget = Math.max(0, bodyBudget - overflow);
17
+ }
18
+ return "";
19
+ }
6
20
  function truncateRules(rules, options) {
7
21
  const perRuleTruncated = rules.map((rule) => ({
8
22
  path: rule.path,
@@ -32,9 +46,11 @@ export function formatStaticBlock(rules, options) {
32
46
  if (rules.length === 0) {
33
47
  return "";
34
48
  }
35
- const body = neutralizeEnvelopeMarkers(`${PROJECT_RULES_HEADING}\n${truncateRules(rules, options).map(formatRule).join("\n\n")}`);
36
- const envelope = `${PROJECT_RULES_START_MARKER}\n${body}\n${PROJECT_RULES_END_MARKER}`;
37
- return `\n\n${PROJECT_RULES_REGION_START_MARKER}\n${envelope}\n${PROJECT_RULES_REGION_END_MARKER}`;
49
+ return formatWithinResultBudget(rules, options, (truncatedRules) => {
50
+ const body = neutralizeEnvelopeMarkers(`${PROJECT_RULES_HEADING}\n${truncatedRules.map(formatRule).join("\n\n")}`);
51
+ const envelope = `${PROJECT_RULES_START_MARKER}\n${body}\n${PROJECT_RULES_END_MARKER}`;
52
+ return `\n\n${PROJECT_RULES_REGION_START_MARKER}\n${envelope}\n${PROJECT_RULES_REGION_END_MARKER}`;
53
+ });
38
54
  }
39
55
  /**
40
56
  * A raw region sentinel inside a rule would terminate extraction early and drop every rule after it;
@@ -51,8 +67,8 @@ export function formatDynamicBlock(rules, targetRelativePath, options) {
51
67
  if (rules.length === 0) {
52
68
  return "";
53
69
  }
54
- return `\n\nAdditional project instructions matched for ${targetRelativePath}:\n\n${truncateRules(rules, options)
70
+ return formatWithinResultBudget(rules, options, (truncatedRules) => `\n\nAdditional project instructions matched for ${targetRelativePath}:\n\n${truncatedRules
55
71
  .map(formatRule)
56
- .join("\n\n")}`;
72
+ .join("\n\n")}`);
57
73
  }
58
74
  //# sourceMappingURL=formatter.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"formatter.js","sourceRoot":"","sources":["../../../../../../src/core/extensions/builtin/rules/rules/formatter.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,wBAAwB,EACxB,qBAAqB,EACrB,+BAA+B,EAC/B,iCAAiC,EACjC,0BAA0B,GAC1B,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAc9D,SAAS,UAAU,CAAC,IAAmB;IACtC,OAAO,sBAAsB,IAAI,CAAC,IAAI,KAAK,IAAI,CAAC,IAAI,EAAE,CAAC;AACxD,CAAC;AAED,SAAS,aAAa,CAAC,KAAgC,EAAE,OAAsB;IAC9E,MA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AC,EAAE,CAAC;QACxB,OAAO,EAAE,CAAC;IACX,CAAC;IAED,MAAM,IAAI,GAAG,yBAAyB,CACrC,GAAG,qBAAqB,KAAK,aAAa,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,CACzF,CAAC;IACF,MAAM,QAAQ,GAAG,GAAG,0BAA0B,KAAK,IAAI,KAAK,wBAAwB,EAAE,CAAC;IACvF,OAAO,OAAO,iCAAiC,KAAK,QAAQ,KAAK,+BAA+B,EAAE,CAAC;AACpG,CAAC;AAED;;;GAGG;AACH,SAAS,yBAAyB,CAAC,IAAY;IAC9C,OAAO,IAAI;SACT,UAAU,CAAC,iCAAiC,EAAE,0CAA0C,CAAC;SACzF,UAAU,CAAC,+BAA+B,EAAE,wCAAwC,CAAC;SACrF,UAAU,CAAC,0BAA0B,EAAE,uBAAuB,CAAC;SAC/D,UAAU,CAAC,wBAAwB,EAAE,wBAAwB,CAAC,CAAC;AAClE,CAAC;AAED,MAAM,UAAU,kBAAkB,CACjC,KAAgC,EAChC,kBAA0B,EAC1B,OAAsB;IAEtB,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACxB,OAAO,EAAE,CAAC;IACX,CAAC;IAED,OAAO,mDAAmD,kBAAkB,QAAQ,aAAa,CAAC,KAAK,EAAE,OAAO,CAAC;SAC/G,GAAG,CAAC,UAAU,CAAC;SACf,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC;AAClB,CAAC","sourcesContent":["import {\n\tPROJECT_RULES_END_MARKER,\n\tPROJECT_RULES_HEADING,\n\tPROJECT_RULES_REGION_END_MARKER,\n\tPROJECT_RULES_REGION_START_MARKER,\n\tPROJECT_RULES_START_MARKER,\n} from \"./constants.ts\";\nimport { truncateBudget, truncateRule } from \"./truncator.ts\";\nimport type { LoadedRule } from \"./types.ts\";\n\nexport interface FormatOptions {\n\tmaxRuleChars: number;\n\tmaxResultChars: number;\n}\n\ntype TruncatedRule = {\n\tpath: string;\n\trelativePath: string;\n\tbody: string;\n};\n\nfunction formatRule(rule: TruncatedRule): string {\n\treturn `Instructions from: ${rule.path}\\n${rule.body}`;\n}\n\nfunction truncateRules(rules: ReadonlyArray<LoadedRule>, options: FormatOptions): TruncatedRule[] {\n\tconst perRuleTruncated = rules.map((rule) => ({\n\t\tpath: rule.path,\n\t\trelativePath: rule.relativePath,\n\t\tbody: truncateRule(rule.body, { maxChars: options.maxRuleChars, relativePath: rule.relativePath }).body,\n\t}));\n\tconst budgetedRules = truncateBudget({\n\t\trules: perRuleTruncated.map((rule) => ({ body: rule.body, relativePath: rule.relativePath })),\n\t\tmaxResultChars: options.maxResultChars,\n\t});\n\tconst truncatedRules: TruncatedRule[] = [];\n\n\tfor (let index = 0; index < budgetedRules.length; index += 1) {\n\t\tconst sourceRule = perRuleTruncated[index];\n\t\tconst budgetedRule = budgetedRules[index];\n\t\tif (sourceRule === undefined || budgetedRule === undefined) {\n\t\t\tcontinue;\n\t\t}\n\n\t\ttruncatedRules.push({\n\t\t\tpath: sourceRule.path,\n\t\t\trelativePath: budgetedRule.relativePath,\n\t\t\tbody: budgetedRule.body,\n\t\t});\n\t}\n\n\treturn truncatedRules;\n}\n\nexport function formatStaticBlock(rules: ReadonlyArray<LoadedRule>, options: FormatOptions): string {\n\tif (rules.length === 0) {\n\t\treturn \"\";\n\t}\n\n\tconst body = neutralizeEnvelopeMarkers(\n\t\t`${PROJECT_RULES_HEADING}\\n${truncateRules(rules, options).map(formatRule).join(\"\\n\\n\")}`,\n\t);\n\tconst envelope = `${PROJECT_RULES_START_MARKER}\\n${body}\\n${PROJECT_RULES_END_MARKER}`;\n\treturn `\\n\\n${PROJECT_RULES_REGION_START_MARKER}\\n${envelope}\\n${PROJECT_RULES_REGION_END_MARKER}`;\n}\n\n/**\n * A raw region sentinel inside a rule would terminate extraction early and drop every rule after it;\n * a raw semantic marker would instead corrupt the envelope structure the model reads.\n */\nfunction neutralizeEnvelopeMarkers(text: string): string {\n\treturn text\n\t\t.replaceAll(PROJECT_RULES_REGION_START_MARKER, \"&lt;!--senpi:project-rules:1:start--&gt;\")\n\t\t.replaceAll(PROJECT_RULES_REGION_END_MARKER, \"&lt;!--senpi:project-rules:1:end--&gt;\")\n\t\t.replaceAll(PROJECT_RULES_START_MARKER, \"&lt;project_rules&gt;\")\n\t\t.replaceAll(PROJECT_RULES_END_MARKER, \"&lt;/project_rules&gt;\");\n}\n\nexport function formatDynamicBlock(\n\trules: ReadonlyArray<LoadedRule>,\n\ttargetRelativePath: string,\n\toptions: FormatOptions,\n): string {\n\tif (rules.length === 0) {\n\t\treturn \"\";\n\t}\n\n\treturn `\\n\\nAdditional project instructions matched for ${targetRelativePath}:\\n\\n${truncateRules(rules, options)\n\t\t.map(formatRule)\n\t\t.join(\"\\n\\n\")}`;\n}\n"]}
1
+ {"version":3,"file":"formatter.js","sourceRoot":"","sources":["../../../../../../src/core/extensions/builtin/rules/rules/formatter.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,wBAAwB,EACxB,qBAAqB,EACrB,+BAA+B,EAC/B,iCAAiC,EACjC,0BAA0B,GAC1B,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAc9D,SAAS,UAAU,CAAC,IAAmB;IACtC,OAAO,sBAAsB,IAAI,CAAC,IAAI,KAAK,IAAI,CAAC,IAAI,EAAE,CAAC;AACxD,CAAC;AAED,SAAS,wBAAwB,CAChC,KAAgC,EAChC,OAAsB,EACtB,MAAgE;IAEhE,IAAI,UAAU,GAAG,OAAO,CAAC,cAAc,CAAC;IACxC,OAAO,UAAU,GAAG,CAAC,EAAE,CAAC;QACvB,MAAM,cAAc,GAAG,aAAa,CAAC,KAAK,EAAE,EAAE,GAAG,OAAO,EAAE,cAAc,EAAE,UAAU,EAAE,CAAC,CAAC;QACxF,IAAI,cAAc,CAAC,MAAM,KAAK,CAAC;Y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ACxB,OAAO,EAAE,CAAC;IACX,CAAC;IAED,OAAO,wBAAwB,CAC9B,KAAK,EACL,OAAO,EACP,CAAC,cAAc,EAAE,EAAE,CAClB,mDAAmD,kBAAkB,QAAQ,cAAc;SACzF,GAAG,CAAC,UAAU,CAAC;SACf,IAAI,CAAC,MAAM,CAAC,EAAE,CACjB,CAAC;AACH,CAAC","sourcesContent":["import {\n\tPROJECT_RULES_END_MARKER,\n\tPROJECT_RULES_HEADING,\n\tPROJECT_RULES_REGION_END_MARKER,\n\tPROJECT_RULES_REGION_START_MARKER,\n\tPROJECT_RULES_START_MARKER,\n} from \"./constants.ts\";\nimport { truncateBudget, truncateRule } from \"./truncator.ts\";\nimport type { LoadedRule } from \"./types.ts\";\n\nexport interface FormatOptions {\n\tmaxRuleChars: number;\n\tmaxResultChars: number;\n}\n\ntype TruncatedRule = {\n\tpath: string;\n\trelativePath: string;\n\tbody: string;\n};\n\nfunction formatRule(rule: TruncatedRule): string {\n\treturn `Instructions from: ${rule.path}\\n${rule.body}`;\n}\n\nfunction formatWithinResultBudget(\n\trules: ReadonlyArray<LoadedRule>,\n\toptions: FormatOptions,\n\trender: (truncatedRules: ReadonlyArray<TruncatedRule>) => string,\n): string {\n\tlet bodyBudget = options.maxResultChars;\n\twhile (bodyBudget > 0) {\n\t\tconst truncatedRules = truncateRules(rules, { ...options, maxResultChars: bodyBudget });\n\t\tif (truncatedRules.length === 0) return \"\";\n\n\t\tconst block = render(truncatedRules);\n\t\tconst overflow = block.length - options.maxResultChars;\n\t\tif (overflow <= 0) return block;\n\t\tbodyBudget = Math.max(0, bodyBudget - overflow);\n\t}\n\treturn \"\";\n}\n\nfunction truncateRules(rules: ReadonlyArray<LoadedRule>, options: FormatOptions): TruncatedRule[] {\n\tconst perRuleTruncated = rules.map((rule) => ({\n\t\tpath: rule.path,\n\t\trelativePath: rule.relativePath,\n\t\tbody: truncateRule(rule.body, { maxChars: options.maxRuleChars, relativePath: rule.relativePath }).body,\n\t}));\n\tconst budgetedRules = truncateBudget({\n\t\trules: perRuleTruncated.map((rule) => ({ body: rule.body, relativePath: rule.relativePath })),\n\t\tmaxResultChars: options.maxResultChars,\n\t});\n\tconst truncatedRules: TruncatedRule[] = [];\n\n\tfor (let index = 0; index < budgetedRules.length; index += 1) {\n\t\tconst sourceRule = perRuleTruncated[index];\n\t\tconst budgetedRule = budgetedRules[index];\n\t\tif (sourceRule === undefined || budgetedRule === undefined) {\n\t\t\tcontinue;\n\t\t}\n\n\t\ttruncatedRules.push({\n\t\t\tpath: sourceRule.path,\n\t\t\trelativePath: budgetedRule.relativePath,\n\t\t\tbody: budgetedRule.body,\n\t\t});\n\t}\n\n\treturn truncatedRules;\n}\n\nexport function formatStaticBlock(rules: ReadonlyArray<LoadedRule>, options: FormatOptions): string {\n\tif (rules.length === 0) {\n\t\treturn \"\";\n\t}\n\n\treturn formatWithinResultBudget(rules, options, (truncatedRules) => {\n\t\tconst body = neutralizeEnvelopeMarkers(\n\t\t\t`${PROJECT_RULES_HEADING}\\n${truncatedRules.map(formatRule).join(\"\\n\\n\")}`,\n\t\t);\n\t\tconst envelope = `${PROJECT_RULES_START_MARKER}\\n${body}\\n${PROJECT_RULES_END_MARKER}`;\n\t\treturn `\\n\\n${PROJECT_RULES_REGION_START_MARKER}\\n${envelope}\\n${PROJECT_RULES_REGION_END_MARKER}`;\n\t});\n}\n\n/**\n * A raw region sentinel inside a rule would terminate extraction early and drop every rule after it;\n * a raw semantic marker would instead corrupt the envelope structure the model reads.\n */\nfunction neutralizeEnvelopeMarkers(text: string): string {\n\treturn text\n\t\t.replaceAll(PROJECT_RULES_REGION_START_MARKER, \"&lt;!--senpi:project-rules:1:start--&gt;\")\n\t\t.replaceAll(PROJECT_RULES_REGION_END_MARKER, \"&lt;!--senpi:project-rules:1:end--&gt;\")\n\t\t.replaceAll(PROJECT_RULES_START_MARKER, \"&lt;project_rules&gt;\")\n\t\t.replaceAll(PROJECT_RULES_END_MARKER, \"&lt;/project_rules&gt;\");\n}\n\nexport function formatDynamicBlock(\n\trules: ReadonlyArray<LoadedRule>,\n\ttargetRelativePath: string,\n\toptions: FormatOptions,\n): string {\n\tif (rules.length === 0) {\n\t\treturn \"\";\n\t}\n\n\treturn formatWithinResultBudget(\n\t\trules,\n\t\toptions,\n\t\t(truncatedRules) =>\n\t\t\t`\\n\\nAdditional project instructions matched for ${targetRelativePath}:\\n\\n${truncatedRules\n\t\t\t\t.map(formatRule)\n\t\t\t\t.join(\"\\n\\n\")}`,\n\t);\n}\n"]}
@@ -90,7 +90,7 @@ export interface TruncationResult {
90
90
  originalLength: number;
91
91
  }
92
92
  /**
93
- * Configuration knobs resolved from env vars and package.json.
93
+ * Configuration knobs resolved from environment variables.
94
94
  */
95
95
  export interface PiRulesConfig {
96
96
  disabled: boolean;
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../../../src/core/extensions/builtin/rules/rules/types.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG","sourcesContent":["/**\n * Public types for pi-rules.\n *\n * These types are stable contracts between modules. The frontmatter type\n * mirrors omo's `RuleMetadata` plus Claude (`paths`) and Copilot (`applyTo`)\n * aliases that are normalized into `globs` internally.\n */\n\n/**\n * YAML frontmatter parsed from a rule markdown file.\n * `paths` (Claude alias) and `applyTo` (Copilot alias) are normalized into\n * `globs` by the parser before any matcher sees this struct.\n */\nexport interface RuleFrontmatter {\n\tdescription?: string;\n\tglobs?: string | string[];\n\tpaths?: string | string[];\n\tapplyTo?: string | string[];\n\talwaysApply?: boolean;\n}\n\n/**\n * Result of parsing a rule markdown file.\n * `body` excludes the frontmatter delimiters and the YAML payload.\n */\nexport interface ParsedRule {\n\tfrontmatter: RuleFrontmatter;\n\tbody: string;\n\t/**\n\t * Diagnostic message if frontmatter parsing failed but the body was salvaged.\n\t * Empty when parsing succeeded.\n\t */\n\tdiagnostic?: string;\n}\n\n/**\n * A discovered rule file candidate before parsing/matching.\n *\n * `path` is the absolute path as discovered (possibly via symlink).\n * `realPath` is the canonical resolved path used for dedup.\n * `source` identifies which discovery source produced this candidate.\n */\nexport interface RuleCandidate {\n\tpath: string;\n\trealPath: string;\n\tsource: RuleSource;\n\t/**\n\t * Distance from the target file directory to the directory containing this rule.\n\t * 0 = same directory, 9999 = global/user-home rule.\n\t */\n\tdistance: number;\n\tisGlobal: boolean;\n\t/**\n\t * True when this candidate is a SINGLE-FILE rule like AGENTS.md or\n\t * `.github/copilot-instructions.md` (frontmatter optional, applies always).\n\t */\n\tisSingleFile: boolean;\n\t/**\n\t * Path relative to project root, POSIX-normalized. Used for matcher and display.\n\t * Empty string for user-home global rules.\n\t */\n\trelativePath: string;\n}\n\n/**\n * A fully-loaded rule ready for injection.\n */\nexport interface LoadedRule extends RuleCandidate {\n\tfrontmatter: RuleFrontmatter;\n\tbody: string;\n\tcontentHash: string;\n\tmatchReason: MatchReason;\n}\n\n/**\n * Source identifier for rule files. Used for deterministic ordering and display.\n */\nexport type RuleSource =\n\t| \".omo/rules\"\n\t| \".claude/rules\"\n\t| \".cursor/rules\"\n\t| \".github/instructions\"\n\t| \".github/copilot-instructions.md\"\n\t| \"AGENTS.md\"\n\t| \"CLAUDE.md\"\n\t| \"CONTEXT.md\"\n\t| \"~/.omo/rules\"\n\t| \"~/.opencode/rules\"\n\t| \"~/.claude/rules\"\n\t| \"~/.config/opencode/AGENTS.md\"\n\t| \"~/.claude/CLAUDE.md\";\n\n/**\n * Why a candidate matched the target file. Surfaced in the injection block so\n * the model can attribute its behavior to a specific rule.\n */\nexport type MatchReason = \"alwaysApply\" | \"single-file\" | { kind: \"glob\"; pattern: string } | { kind: \"no-match\" };\n\n/**\n * Truncation result.\n */\nexport interface TruncationResult {\n\tbody: string;\n\ttruncated: boolean;\n\toriginalLength: number;\n}\n\n/**\n * Configuration knobs resolved from env vars and package.json.\n */\nexport interface PiRulesConfig {\n\tdisabled: boolean;\n\tmode: \"static\" | \"dynamic\" | \"both\" | \"off\";\n\tmaxRuleChars: number;\n\tmaxResultChars: number;\n\tenabledSources: RuleSource[] | \"auto\";\n}\n\n/**\n * Per-session in-memory dedup state.\n *\n * `staticDedup` keys are `{cwd}::{rulePath}::{contentHash}` strings.\n * `dynamicDedup` stores `{targetPath}::{rulePath}::{contentHash}` strings grouped by target file.\n * `dynamicTargetFingerprints` maps a target file cache key to a digest of its\n * discovered rule candidates + file stats; loadDynamicRules short-circuits\n * targets whose fingerprint has not changed since the previous load.\n */\nexport interface SessionState {\n\tcwd: string | undefined;\n\tstaticDedup: Set<string>;\n\tdynamicDedup: Map<string, Set<string>>;\n\tdynamicTargetFingerprints: Map<string, string>;\n\tloadedRules: LoadedRule[];\n\tdiagnostics: RuleDiagnostic[];\n}\n\nexport interface RuleDiagnostic {\n\tseverity: \"warning\" | \"error\";\n\tsource: string;\n\tmessage: string;\n}\n"]}
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../../../src/core/extensions/builtin/rules/rules/types.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG","sourcesContent":["/**\n * Public types for pi-rules.\n *\n * These types are stable contracts between modules. The frontmatter type\n * mirrors omo's `RuleMetadata` plus Claude (`paths`) and Copilot (`applyTo`)\n * aliases that are normalized into `globs` internally.\n */\n\n/**\n * YAML frontmatter parsed from a rule markdown file.\n * `paths` (Claude alias) and `applyTo` (Copilot alias) are normalized into\n * `globs` by the parser before any matcher sees this struct.\n */\nexport interface RuleFrontmatter {\n\tdescription?: string;\n\tglobs?: string | string[];\n\tpaths?: string | string[];\n\tapplyTo?: string | string[];\n\talwaysApply?: boolean;\n}\n\n/**\n * Result of parsing a rule markdown file.\n * `body` excludes the frontmatter delimiters and the YAML payload.\n */\nexport interface ParsedRule {\n\tfrontmatter: RuleFrontmatter;\n\tbody: string;\n\t/**\n\t * Diagnostic message if frontmatter parsing failed but the body was salvaged.\n\t * Empty when parsing succeeded.\n\t */\n\tdiagnostic?: string;\n}\n\n/**\n * A discovered rule file candidate before parsing/matching.\n *\n * `path` is the absolute path as discovered (possibly via symlink).\n * `realPath` is the canonical resolved path used for dedup.\n * `source` identifies which discovery source produced this candidate.\n */\nexport interface RuleCandidate {\n\tpath: string;\n\trealPath: string;\n\tsource: RuleSource;\n\t/**\n\t * Distance from the target file directory to the directory containing this rule.\n\t * 0 = same directory, 9999 = global/user-home rule.\n\t */\n\tdistance: number;\n\tisGlobal: boolean;\n\t/**\n\t * True when this candidate is a SINGLE-FILE rule like AGENTS.md or\n\t * `.github/copilot-instructions.md` (frontmatter optional, applies always).\n\t */\n\tisSingleFile: boolean;\n\t/**\n\t * Path relative to project root, POSIX-normalized. Used for matcher and display.\n\t * Empty string for user-home global rules.\n\t */\n\trelativePath: string;\n}\n\n/**\n * A fully-loaded rule ready for injection.\n */\nexport interface LoadedRule extends RuleCandidate {\n\tfrontmatter: RuleFrontmatter;\n\tbody: string;\n\tcontentHash: string;\n\tmatchReason: MatchReason;\n}\n\n/**\n * Source identifier for rule files. Used for deterministic ordering and display.\n */\nexport type RuleSource =\n\t| \".omo/rules\"\n\t| \".claude/rules\"\n\t| \".cursor/rules\"\n\t| \".github/instructions\"\n\t| \".github/copilot-instructions.md\"\n\t| \"AGENTS.md\"\n\t| \"CLAUDE.md\"\n\t| \"CONTEXT.md\"\n\t| \"~/.omo/rules\"\n\t| \"~/.opencode/rules\"\n\t| \"~/.claude/rules\"\n\t| \"~/.config/opencode/AGENTS.md\"\n\t| \"~/.claude/CLAUDE.md\";\n\n/**\n * Why a candidate matched the target file. Surfaced in the injection block so\n * the model can attribute its behavior to a specific rule.\n */\nexport type MatchReason = \"alwaysApply\" | \"single-file\" | { kind: \"glob\"; pattern: string } | { kind: \"no-match\" };\n\n/**\n * Truncation result.\n */\nexport interface TruncationResult {\n\tbody: string;\n\ttruncated: boolean;\n\toriginalLength: number;\n}\n\n/**\n * Configuration knobs resolved from environment variables.\n */\nexport interface PiRulesConfig {\n\tdisabled: boolean;\n\tmode: \"static\" | \"dynamic\" | \"both\" | \"off\";\n\tmaxRuleChars: number;\n\tmaxResultChars: number;\n\tenabledSources: RuleSource[] | \"auto\";\n}\n\n/**\n * Per-session in-memory dedup state.\n *\n * `staticDedup` keys are `{cwd}::{rulePath}::{contentHash}` strings.\n * `dynamicDedup` stores `{targetPath}::{rulePath}::{contentHash}` strings grouped by target file.\n * `dynamicTargetFingerprints` maps a target file cache key to a digest of its\n * discovered rule candidates + file stats; loadDynamicRules short-circuits\n * targets whose fingerprint has not changed since the previous load.\n */\nexport interface SessionState {\n\tcwd: string | undefined;\n\tstaticDedup: Set<string>;\n\tdynamicDedup: Map<string, Set<string>>;\n\tdynamicTargetFingerprints: Map<string, string>;\n\tloadedRules: LoadedRule[];\n\tdiagnostics: RuleDiagnostic[];\n}\n\nexport interface RuleDiagnostic {\n\tseverity: \"warning\" | \"error\";\n\tsource: string;\n\tmessage: string;\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"service-tier.d.ts","sourceRoot":"","sources":["../../../../src/core/extensions/builtin/service-tier.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAS,MAAM,uBAAuB,CAAC;AAGxD,OAAO,KAAK,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAE7D,YAAY,EAAE,WAAW,EAAE,CAAC;AAc5B,wBAAgB,uBAAuB,CAAC,GAAG,EAAE,GAAG,GAAG,SAAS,EAAE,OAAO,EAAE,OAAO,EAAE,WAAW,CAAC,EAAE,WAAW,GAAG,OAAO,CAalH;AAkCD,MAAM,CAAC,OAAO,UAAU,oBAAoB,CAAC,EAAE,EAAE,YAAY,GAAG,IAAI,CAqEnE"}
1
+ {"version":3,"file":"service-tier.d.ts","sourceRoot":"","sources":["../../../../src/core/extensions/builtin/service-tier.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAS,MAAM,uBAAuB,CAAC;AAGxD,OAAO,KAAK,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAE7D,YAAY,EAAE,WAAW,EAAE,CAAC;AAa5B,wBAAgB,uBAAuB,CAAC,GAAG,EAAE,GAAG,GAAG,SAAS,EAAE,OAAO,EAAE,OAAO,EAAE,WAAW,CAAC,EAAE,WAAW,GAAG,OAAO,CAalH;AAkCD,MAAM,CAAC,OAAO,UAAU,oBAAoB,CAAC,EAAE,EAAE,YAAY,GAAG,IAAI,CAqEnE"}
@@ -1,5 +1,4 @@
1
1
  import { SettingsManager } from "../../settings-manager.js";
2
- const OPENAI_CODEX_PROVIDER = "openai-codex";
3
2
  const OPENAI_CODEX_RESPONSES_API = "openai-codex-responses";
4
3
  const FAST_MODEL_SUFFIX = "-fast";
5
4
  const PRIORITY_TIER = "priority";
@@ -65,7 +64,7 @@ export default function serviceTierExtension(pi) {
65
64
  sessionFastMode = false;
66
65
  pi.setSessionFastMode(false);
67
66
  const model = ctx.model;
68
- if (model?.provider !== OPENAI_CODEX_PROVIDER) {
67
+ if (model?.api !== OPENAI_CODEX_RESPONSES_API) {
69
68
  return;
70
69
  }
71
70
  const baseModel = findBaseModel(ctx.modelRegistry, model);
@@ -77,7 +76,7 @@ export default function serviceTierExtension(pi) {
77
76
  description: "Toggle OpenAI Codex fast mode for this session",
78
77
  handler: async (_args, ctx) => {
79
78
  const model = ctx.model;
80
- if (model?.provider !== OPENAI_CODEX_PROVIDER) {
79
+ if (model?.api !== OPENAI_CODEX_RESPONSES_API) {
81
80
  ctx.ui.notify("Fast mode is only available for OpenAI Codex models.", "warning");
82
81
  return;
83
82
  }
@@ -1 +1 @@
1
- {"version":3,"file":"service-tier.js","sourceRoot":"","sources":["../../../../src/core/extensions/builtin/service-tier.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAO5D,MAAM,qBAAqB,GAAG,cAAc,CAAC;AAC7C,MAAM,0BAA0B,GAAG,wBAAwB,CAAC;AAC5D,MAAM,iBAAiB,GAAG,OAAO,CAAC;AAClC,MAAM,aAAa,GAAgB,UAAU,CAAC;AAC9C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CAAC,EAAE,CAAC,MAAM,CAAC,uBAAuB,WAAW,CAAC,QAAQ,IAAI,WAAW,CAAC,EAAE,GAAG,EAAE,OAAO,CAAC,CAAC;gBACzF,OAAO;YACR,CAAC;YAED,MAAM,OAAO,GAAG,SAAS,KAAK,SAAS,CAAC;YACxC,GAAG,CAAC,EAAE,CAAC,MAAM,CAAC,aAAa,OAAO,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,UAAU,KAAK,WAAW,CAAC,EAAE,EAAE,EAAE,MAAM,CAAC,CAAC;QAC3F,CAAC;KACD,CAAC,CAAC;IAEH,EAAE,CAAC,EAAE,CAAC,yBAAyB,EAAE,CAAC,KAAK,EAAE,GAAG,EAAE,EAAE;QAC/C,MAAM,oBAAoB,GACzB,GAAG,CAAC,KAAK,EAAE,GAAG,KAAK,0BAA0B;YAC5C,CAAC,CAAC,CAAC,GAAG,CAAC,WAAW,IAAI,CAAC,eAAe,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC;YACpE,CAAC,CAAC,CAAC,GAAG,CAAC,WAAW,IAAI,mBAAmB,CAAC,CAAC;QAC7C,OAAO,uBAAuB,CAAC,GAAG,CAAC,KAAK,EAAE,GAAG,EAAE,KAAK,CAAC,OAAO,EAAE,oBAAoB,CAAC,CAAC;IACrF,CAAC,CAAC,CAAC;AACJ,CAAC","sourcesContent":["import type { Api, Model } from \"@earendil-works/pi-ai\";\nimport type { ModelRegistry } from \"../../model-registry.ts\";\nimport { SettingsManager } from \"../../settings-manager.ts\";\nimport type { ExtensionAPI, ServiceTier } from \"../types.ts\";\n\nexport type { ServiceTier };\n\ntype ProviderPayload = Record<string, unknown>;\n\nconst OPENAI_CODEX_PROVIDER = \"openai-codex\";\nconst OPENAI_CODEX_RESPONSES_API = \"openai-codex-responses\";\nconst FAST_MODEL_SUFFIX = \"-fast\";\nconst PRIORITY_TIER: ServiceTier = \"priority\";\nconst SERVICE_TIER_APIS: ReadonlySet<Api> = new Set([\"openai-responses\", OPENAI_CODEX_RESPONSES_API]);\n\nfunction isRecord(value: unknown): value is ProviderPayload {\n\treturn typeof value === \"object\" && value !== null;\n}\n\nexport function addServiceTierToPayload(api: Api | undefined, payload: unknown, serviceTier?: ServiceTier): unknown {\n\tif (!api || !SERVICE_TIER_APIS.has(api) || !serviceTier) {\n\t\treturn payload;\n\t}\n\n\tif (!isRecord(payload) || payload.service_tier !== undefined) {\n\t\treturn payload;\n\t}\n\n\treturn {\n\t\t...payload,\n\t\tservice_tier: serviceTier,\n\t};\n}\n\nfunction getRequestModelId(modelRegistry: ModelRegistry, model: Model<Api>): string {\n\treturn modelRegistry.getUpstreamModelId(model) ?? model.id;\n}\n\nfunction isCompatibleFastVariant(modelRegistry: ModelRegistry, baseModel: Model<Api>, fastModel: Model<Api>): boolean {\n\treturn (\n\t\tfastModel.provider === baseModel.provider &&\n\t\tfastModel.api === baseModel.api &&\n\t\tmodelRegistry.getServiceTier(fastModel) === \"priority\" &&\n\t\tgetRequestModelId(modelRegistry, fastModel) === getRequestModelId(modelRegistry, baseModel)\n\t);\n}\n\nfunction findBaseModel(modelRegistry: ModelRegistry, fastModel: Model<Api>): Model<Api> | undefined {\n\tif (!fastModel.id.endsWith(FAST_MODEL_SUFFIX)) {\n\t\treturn undefined;\n\t}\n\n\tconst baseModelId = fastModel.id.slice(0, -FAST_MODEL_SUFFIX.length);\n\tconst baseModel = modelRegistry.find(fastModel.provider, baseModelId);\n\treturn baseModel && isCompatibleFastVariant(modelRegistry, baseModel, fastModel) ? baseModel : undefined;\n}\n\nfunction findFastModel(modelRegistry: ModelRegistry, baseModel: Model<Api>): Model<Api> | undefined {\n\tif (baseModel.id.endsWith(FAST_MODEL_SUFFIX)) {\n\t\treturn undefined;\n\t}\n\n\tconst fastModel = modelRegistry.find(baseModel.provider, `${baseModel.id}${FAST_MODEL_SUFFIX}`);\n\treturn fastModel && isCompatibleFastVariant(modelRegistry, baseModel, fastModel) ? fastModel : undefined;\n}\n\nexport default function serviceTierExtension(pi: ExtensionAPI): void {\n\tlet settingsServiceTier: ServiceTier | undefined;\n\t/**\n\t * Session-level fast mode for Codex models that have no `-fast` catalog sibling.\n\t *\n\t * The catalog generator emits `-fast` priority variants only for the direct\n\t * `openai` provider, so `openai-codex` models never have a switch target. The\n\t * ChatGPT backend still offers the tier to subscriptions:\n\t * `chatgpt.com/backend-api/codex/models` advertises a `priority` service tier\n\t * labelled \"Fast\" (\"1.5x speed, increased usage\")\n\t * for gpt-5.4/5.5/5.6-*, and the first-party Codex CLI sends\n\t * `service_tier: \"priority\"` on subscription OAuth. The response echo is not a\n\t * confirmation channel — it reads `auto`/`default` whether or not a tier was\n\t * sent — so this toggle drives the request field directly. See issue #545.\n\t */\n\tlet sessionFastMode = false;\n\n\tpi.on(\"session_start\", async (_event, ctx) => {\n\t\tconst settingsManager = SettingsManager.create(ctx.cwd);\n\t\tsettingsServiceTier = settingsManager.getOpenAIServiceTier();\n\t\tsessionFastMode = false;\n\t\tpi.setSessionFastMode(false);\n\n\t\tconst model = ctx.model;\n\t\tif (model?.provider !== OPENAI_CODEX_PROVIDER) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst baseModel = findBaseModel(ctx.modelRegistry, model);\n\t\tif (baseModel) {\n\t\t\tawait pi.setSessionModel(baseModel);\n\t\t}\n\t});\n\n\tpi.registerCommand(\"fast\", {\n\t\tdescription: \"Toggle OpenAI Codex fast mode for this session\",\n\t\thandler: async (_args, ctx) => {\n\t\t\tconst model = ctx.model;\n\t\t\tif (model?.provider !== OPENAI_CODEX_PROVIDER) {\n\t\t\t\tctx.ui.notify(\"Fast mode is only available for OpenAI Codex models.\", \"warning\");\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst baseModel = findBaseModel(ctx.modelRegistry, model);\n\t\t\tconst targetModel = baseModel ?? findFastModel(ctx.modelRegistry, model);\n\t\t\tif (!targetModel) {\n\t\t\t\tsessionFastMode = !sessionFastMode;\n\t\t\t\tpi.setSessionFastMode(sessionFastMode);\n\t\t\t\tctx.ui.notify(`Fast mode ${sessionFastMode ? \"enabled\" : \"disabled\"}: ${model.id}`, \"info\");\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif (!(await pi.setSessionModel(targetModel))) {\n\t\t\t\tctx.ui.notify(`Could not switch to ${targetModel.provider}/${targetModel.id}.`, \"error\");\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst enabled = baseModel === undefined;\n\t\t\tctx.ui.notify(`Fast mode ${enabled ? \"enabled\" : \"disabled\"}: ${targetModel.id}`, \"info\");\n\t\t},\n\t});\n\n\tpi.on(\"before_provider_request\", (event, ctx) => {\n\t\tconst effectiveServiceTier =\n\t\t\tctx.model?.api === OPENAI_CODEX_RESPONSES_API\n\t\t\t\t? (ctx.serviceTier ?? (sessionFastMode ? PRIORITY_TIER : undefined))\n\t\t\t\t: (ctx.serviceTier ?? settingsServiceTier);\n\t\treturn addServiceTierToPayload(ctx.model?.api, event.payload, effectiveServiceTier);\n\t});\n}\n"]}
1
+ {"version":3,"file":"service-tier.js","sourceRoot":"","sources":["../../../../src/core/extensions/builtin/service-tier.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAO5D,MAAM,0BAA0B,GAAG,wBAAwB,CAAC;AAC5D,MAAM,iBAAiB,GAAG,OAAO,CAAC;AAClC,MAAM,aAAa,GAAgB,UAAU,CAAC;AAC9C,MAAM,iBAAiB,GAAqB,IAAI,GAAG,CAAC,CAAC,kBAAkB,EAAE,0BAA0B,CAAC,CAAC,CAAC;AAEtG,SAAS,QAAQ,CAAC,KAAc;IAC/B,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,CAAC;AACpD,CAAC;AAED,MAAM,UAAU,uBAAuB,CAAC,GAAoB,EAAE,OAAgB,EAAE,WAAyB;IACxG,IAAI,CAAC,GAAG,IAAI,CAAC,iBAAiB,CAAC,GAAG,CAAC,GAAG,CAA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AC3F,CAAC;KACD,CAAC,CAAC;IAEH,EAAE,CAAC,EAAE,CAAC,yBAAyB,EAAE,CAAC,KAAK,EAAE,GAAG,EAAE,EAAE;QAC/C,MAAM,oBAAoB,GACzB,GAAG,CAAC,KAAK,EAAE,GAAG,KAAK,0BAA0B;YAC5C,CAAC,CAAC,CAAC,GAAG,CAAC,WAAW,IAAI,CAAC,eAAe,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC;YACpE,CAAC,CAAC,CAAC,GAAG,CAAC,WAAW,IAAI,mBAAmB,CAAC,CAAC;QAC7C,OAAO,uBAAuB,CAAC,GAAG,CAAC,KAAK,EAAE,GAAG,EAAE,KAAK,CAAC,OAAO,EAAE,oBAAoB,CAAC,CAAC;IACrF,CAAC,CAAC,CAAC;AACJ,CAAC","sourcesContent":["import type { Api, Model } from \"@earendil-works/pi-ai\";\nimport type { ModelRegistry } from \"../../model-registry.ts\";\nimport { SettingsManager } from \"../../settings-manager.ts\";\nimport type { ExtensionAPI, ServiceTier } from \"../types.ts\";\n\nexport type { ServiceTier };\n\ntype ProviderPayload = Record<string, unknown>;\n\nconst OPENAI_CODEX_RESPONSES_API = \"openai-codex-responses\";\nconst FAST_MODEL_SUFFIX = \"-fast\";\nconst PRIORITY_TIER: ServiceTier = \"priority\";\nconst SERVICE_TIER_APIS: ReadonlySet<Api> = new Set([\"openai-responses\", OPENAI_CODEX_RESPONSES_API]);\n\nfunction isRecord(value: unknown): value is ProviderPayload {\n\treturn typeof value === \"object\" && value !== null;\n}\n\nexport function addServiceTierToPayload(api: Api | undefined, payload: unknown, serviceTier?: ServiceTier): unknown {\n\tif (!api || !SERVICE_TIER_APIS.has(api) || !serviceTier) {\n\t\treturn payload;\n\t}\n\n\tif (!isRecord(payload) || payload.service_tier !== undefined) {\n\t\treturn payload;\n\t}\n\n\treturn {\n\t\t...payload,\n\t\tservice_tier: serviceTier,\n\t};\n}\n\nfunction getRequestModelId(modelRegistry: ModelRegistry, model: Model<Api>): string {\n\treturn modelRegistry.getUpstreamModelId(model) ?? model.id;\n}\n\nfunction isCompatibleFastVariant(modelRegistry: ModelRegistry, baseModel: Model<Api>, fastModel: Model<Api>): boolean {\n\treturn (\n\t\tfastModel.provider === baseModel.provider &&\n\t\tfastModel.api === baseModel.api &&\n\t\tmodelRegistry.getServiceTier(fastModel) === \"priority\" &&\n\t\tgetRequestModelId(modelRegistry, fastModel) === getRequestModelId(modelRegistry, baseModel)\n\t);\n}\n\nfunction findBaseModel(modelRegistry: ModelRegistry, fastModel: Model<Api>): Model<Api> | undefined {\n\tif (!fastModel.id.endsWith(FAST_MODEL_SUFFIX)) {\n\t\treturn undefined;\n\t}\n\n\tconst baseModelId = fastModel.id.slice(0, -FAST_MODEL_SUFFIX.length);\n\tconst baseModel = modelRegistry.find(fastModel.provider, baseModelId);\n\treturn baseModel && isCompatibleFastVariant(modelRegistry, baseModel, fastModel) ? baseModel : undefined;\n}\n\nfunction findFastModel(modelRegistry: ModelRegistry, baseModel: Model<Api>): Model<Api> | undefined {\n\tif (baseModel.id.endsWith(FAST_MODEL_SUFFIX)) {\n\t\treturn undefined;\n\t}\n\n\tconst fastModel = modelRegistry.find(baseModel.provider, `${baseModel.id}${FAST_MODEL_SUFFIX}`);\n\treturn fastModel && isCompatibleFastVariant(modelRegistry, baseModel, fastModel) ? fastModel : undefined;\n}\n\nexport default function serviceTierExtension(pi: ExtensionAPI): void {\n\tlet settingsServiceTier: ServiceTier | undefined;\n\t/**\n\t * Session-level fast mode for Codex models that have no `-fast` catalog sibling.\n\t *\n\t * The catalog generator emits `-fast` priority variants only for the direct\n\t * `openai` provider, so `openai-codex` models never have a switch target. The\n\t * ChatGPT backend still offers the tier to subscriptions:\n\t * `chatgpt.com/backend-api/codex/models` advertises a `priority` service tier\n\t * labelled \"Fast\" (\"1.5x speed, increased usage\")\n\t * for gpt-5.4/5.5/5.6-*, and the first-party Codex CLI sends\n\t * `service_tier: \"priority\"` on subscription OAuth. The response echo is not a\n\t * confirmation channel — it reads `auto`/`default` whether or not a tier was\n\t * sent — so this toggle drives the request field directly. See issue #545.\n\t */\n\tlet sessionFastMode = false;\n\n\tpi.on(\"session_start\", async (_event, ctx) => {\n\t\tconst settingsManager = SettingsManager.create(ctx.cwd);\n\t\tsettingsServiceTier = settingsManager.getOpenAIServiceTier();\n\t\tsessionFastMode = false;\n\t\tpi.setSessionFastMode(false);\n\n\t\tconst model = ctx.model;\n\t\tif (model?.api !== OPENAI_CODEX_RESPONSES_API) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst baseModel = findBaseModel(ctx.modelRegistry, model);\n\t\tif (baseModel) {\n\t\t\tawait pi.setSessionModel(baseModel);\n\t\t}\n\t});\n\n\tpi.registerCommand(\"fast\", {\n\t\tdescription: \"Toggle OpenAI Codex fast mode for this session\",\n\t\thandler: async (_args, ctx) => {\n\t\t\tconst model = ctx.model;\n\t\t\tif (model?.api !== OPENAI_CODEX_RESPONSES_API) {\n\t\t\t\tctx.ui.notify(\"Fast mode is only available for OpenAI Codex models.\", \"warning\");\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst baseModel = findBaseModel(ctx.modelRegistry, model);\n\t\t\tconst targetModel = baseModel ?? findFastModel(ctx.modelRegistry, model);\n\t\t\tif (!targetModel) {\n\t\t\t\tsessionFastMode = !sessionFastMode;\n\t\t\t\tpi.setSessionFastMode(sessionFastMode);\n\t\t\t\tctx.ui.notify(`Fast mode ${sessionFastMode ? \"enabled\" : \"disabled\"}: ${model.id}`, \"info\");\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif (!(await pi.setSessionModel(targetModel))) {\n\t\t\t\tctx.ui.notify(`Could not switch to ${targetModel.provider}/${targetModel.id}.`, \"error\");\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst enabled = baseModel === undefined;\n\t\t\tctx.ui.notify(`Fast mode ${enabled ? \"enabled\" : \"disabled\"}: ${targetModel.id}`, \"info\");\n\t\t},\n\t});\n\n\tpi.on(\"before_provider_request\", (event, ctx) => {\n\t\tconst effectiveServiceTier =\n\t\t\tctx.model?.api === OPENAI_CODEX_RESPONSES_API\n\t\t\t\t? (ctx.serviceTier ?? (sessionFastMode ? PRIORITY_TIER : undefined))\n\t\t\t\t: (ctx.serviceTier ?? settingsServiceTier);\n\t\treturn addServiceTierToPayload(ctx.model?.api, event.payload, effectiveServiceTier);\n\t});\n}\n"]}
@@ -25,7 +25,7 @@ export interface TerminalToolContext {
25
25
  readonly monitorRegistry?: MonitorRegistry;
26
26
  /** Receives filtered monitor line and terminal-summary events. */
27
27
  readonly onMonitorEvent?: (event: MonitorEvent) => void;
28
- /** Resets session-global wake-budget delivery after a monitor was explicitly rearmed. */
28
+ /** Resets session-global wake-budget delivery for a fresh or explicitly rearmed monitor. */
29
29
  readonly onMonitorRearmed?: (id: string) => void;
30
30
  }
31
31
  /** Minimal tool-result shape returned by the terminal tools. */
@@ -1 +1 @@
1
- {"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../../../../../src/core/extensions/builtin/terminal/tools/context.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AACrD,OAAO,KAAK,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAC5E,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,uBAAuB,CAAC;AACpE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAEpD,iEAAiE;AACjE,MAAM,WAAW,mBAAmB;IACnC,QAAQ,CAAC,OAAO,EAAE,eAAe,CAAC;IAClC,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,gFAAgF;IAChF,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,8FAA8F;IAC9F,QAAQ,CAAC,aA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,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAC/C,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,CAAC;IAC7C,OAAO,CAAC,EAAE,OAAO,CAAC;CAClB;AAED,wBAAgB,UAAU,CACzB,IAAI,EAAE,MAAM,EACZ,KAAK,CAAC,EAAE;IAAE,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAAC,OAAO,CAAC,EAAE,OAAO,CAAA;CAAE,GAC9D,kBAAkB,CAEpB;AAED,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,kBAAkB,CAE5D"}
@@ -1 +1 @@
1
- {"version":3,"file":"context.js","sourceRoot":"","sources":["../../../../../../src/core/extensions/builtin/terminal/tools/context.ts"],"names":[],"mappings":"AAuCA,MAAM,UAAU,UAAU,CACzB,IAAY,EACZ,KAAgE;IAEhE,OAAO,EAAE,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,CAAC;AAChG,CAAC;AAED,MAAM,UAAU,WAAW,CAAC,IAAY;IACvC,OAAO,EAAE,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,EAAE,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;AACjF,CAAC","sourcesContent":["import type { TerminalManager } from \"../manager.ts\";\nimport type { MonitorEvent, MonitorRegistry } from \"../monitor-registry.ts\";\nimport type { TerminalRuntimeSession } from \"../runtime-session.ts\";\nimport type { TimeoutAction } from \"../settings.ts\";\n\n/** Shared dependencies handed to every terminal tool factory. */\nexport interface TerminalToolContext {\n\treadonly manager: TerminalManager;\n\treadonly cwd: string;\n\t/** Explicit shell path from settings (settings-manager `shellPath`), if any. */\n\treadonly shellPath?: string;\n\treadonly defaultCols: number;\n\treadonly defaultRows: number;\n\t/** Configured foreground deadline behavior; omitted direct contexts default to background. */\n\treadonly timeoutAction?: TimeoutAction;\n\t/** Resolve the environment for spawned sessions (mirrors core bash `getShellEnv`). */\n\treadonly getEnv: () => NodeJS.ProcessEnv;\n\t/**\n\t * Current extension session context (set on session_start/model_select), used to\n\t * expose PI_* session metadata to spawned commands like the core bash tool does.\n\t */\n\treadonly getSessionContext?: () => import(\"../../../types.ts\").ExtensionContext | undefined;\n\t/** Notified when a background session exits, so the notify layer can wake the agent. */\n\treadonly onBackgroundExit?: (id: string, runtime: TerminalRuntimeSession) => void;\n\t/** Session-scoped monitor state, sharing the terminal manager's bash-id namespace. */\n\treadonly monitorRegistry?: MonitorRegistry;\n\t/** Receives filtered monitor line and terminal-summary events. */\n\treadonly onMonitorEvent?: (event: MonitorEvent) => void;\n\t/** Resets session-global wake-budget delivery after a monitor was explicitly rearmed. */\n\treadonly onMonitorRearmed?: (id: string) => void;\n}\n\n/** Minimal tool-result shape returned by the terminal tools. */\nexport interface TerminalToolResult {\n\tcontent: Array<{ type: \"text\"; text: string }>;\n\tdetails: Record<string, unknown> | undefined;\n\tisError?: boolean;\n}\n\nexport function textResult(\n\ttext: string,\n\textra?: { details?: Record<string, unknown>; isError?: boolean },\n): TerminalToolResult {\n\treturn { content: [{ type: \"text\", text }], details: extra?.details, isError: extra?.isError };\n}\n\nexport function errorResult(text: string): TerminalToolResult {\n\treturn { content: [{ type: \"text\", text }], details: undefined, isError: true };\n}\n"]}
1
+ {"version":3,"file":"context.js","sourceRoot":"","sources":["../../../../../../src/core/extensions/builtin/terminal/tools/context.ts"],"names":[],"mappings":"AAuCA,MAAM,UAAU,UAAU,CACzB,IAAY,EACZ,KAAgE;IAEhE,OAAO,EAAE,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,CAAC;AAChG,CAAC;AAED,MAAM,UAAU,WAAW,CAAC,IAAY;IACvC,OAAO,EAAE,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,EAAE,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;AACjF,CAAC","sourcesContent":["import type { TerminalManager } from \"../manager.ts\";\nimport type { MonitorEvent, MonitorRegistry } from \"../monitor-registry.ts\";\nimport type { TerminalRuntimeSession } from \"../runtime-session.ts\";\nimport type { TimeoutAction } from \"../settings.ts\";\n\n/** Shared dependencies handed to every terminal tool factory. */\nexport interface TerminalToolContext {\n\treadonly manager: TerminalManager;\n\treadonly cwd: string;\n\t/** Explicit shell path from settings (settings-manager `shellPath`), if any. */\n\treadonly shellPath?: string;\n\treadonly defaultCols: number;\n\treadonly defaultRows: number;\n\t/** Configured foreground deadline behavior; omitted direct contexts default to background. */\n\treadonly timeoutAction?: TimeoutAction;\n\t/** Resolve the environment for spawned sessions (mirrors core bash `getShellEnv`). */\n\treadonly getEnv: () => NodeJS.ProcessEnv;\n\t/**\n\t * Current extension session context (set on session_start/model_select), used to\n\t * expose PI_* session metadata to spawned commands like the core bash tool does.\n\t */\n\treadonly getSessionContext?: () => import(\"../../../types.ts\").ExtensionContext | undefined;\n\t/** Notified when a background session exits, so the notify layer can wake the agent. */\n\treadonly onBackgroundExit?: (id: string, runtime: TerminalRuntimeSession) => void;\n\t/** Session-scoped monitor state, sharing the terminal manager's bash-id namespace. */\n\treadonly monitorRegistry?: MonitorRegistry;\n\t/** Receives filtered monitor line and terminal-summary events. */\n\treadonly onMonitorEvent?: (event: MonitorEvent) => void;\n\t/** Resets session-global wake-budget delivery for a fresh or explicitly rearmed monitor. */\n\treadonly onMonitorRearmed?: (id: string) => void;\n}\n\n/** Minimal tool-result shape returned by the terminal tools. */\nexport interface TerminalToolResult {\n\tcontent: Array<{ type: \"text\"; text: string }>;\n\tdetails: Record<string, unknown> | undefined;\n\tisError?: boolean;\n}\n\nexport function textResult(\n\ttext: string,\n\textra?: { details?: Record<string, unknown>; isError?: boolean },\n): TerminalToolResult {\n\treturn { content: [{ type: \"text\", text }], details: extra?.details, isError: extra?.isError };\n}\n\nexport function errorResult(text: string): TerminalToolResult {\n\treturn { content: [{ type: \"text\", text }], details: undefined, isError: true };\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"monitor.d.ts","sourceRoot":"","sources":["../../../../../../src/core/extensions/builtin/terminal/tools/monitor.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,MAAM,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAG5C,OAAO,EAAe,KAAK,mBAAmB,EAAE,KAAK,kBAAkB,EAAc,MAAM,cAAc,CAAC;AAC1G,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAGhD,eAAO,MAAM,0BAA0B,SAAU,CAAC;AAClD,eAAO,MAAM,sBAAsB,UAAY,CAAC;AAEhD;;;;;GAKG;AACH,eAAO,MAAM,aAAa;;;;;;;;EA8BxB,CAAC;AACH,MAAM,MAAM,YAAY,GAAG,MAAM,CAAC,OAAO,aAAa,CAAC,CAAC;AAoDxD,mGAAmG;AACnG,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,mBAAmB;;;;;;;;;;;;;;;;yBAoB1C,MAAM,SACZ,YAAY,YACT,WAAW,cACT,SAAS,YACX;QAAE,GAAG,CAAC,EAAE,MAAM,CAAA;KAAE,GACxB,OAAO,CAAC,kBAAkB,CAAC;EAiB/B"}
1
+ {"version":3,"file":"monitor.d.ts","sourceRoot":"","sources":["../../../../../../src/core/extensions/builtin/terminal/tools/monitor.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,MAAM,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAG5C,OAAO,EAAe,KAAK,mBAAmB,EAAE,KAAK,kBAAkB,EAAc,MAAM,cAAc,CAAC;AAC1G,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAGhD,eAAO,MAAM,0BAA0B,SAAU,CAAC;AAClD,eAAO,MAAM,sBAAsB,UAAY,CAAC;AAEhD;;;;;GAKG;AACH,eAAO,MAAM,aAAa;;;;;;;;EA8BxB,CAAC;AACH,MAAM,MAAM,YAAY,GAAG,MAAM,CAAC,OAAO,aAAa,CAAC,CAAC;AAqDxD,mGAAmG;AACnG,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,mBAAmB;;;;;;;;;;;;;;;;yBAoB1C,MAAM,SACZ,YAAY,YACT,WAAW,cACT,SAAS,YACX;QAAE,GAAG,CAAC,EAAE,MAAM,CAAA;KAAE,GACxB,OAAO,CAAC,kBAAkB,CAAC;EAiB/B"}
@@ -69,6 +69,7 @@ async function createMonitor(ctx, registry, input, execCtx) {
69
69
  cwd: execCtx?.cwd,
70
70
  ...(input.persistent ? {} : { timeoutMs: resolveTimeoutMs(input.timeout_ms) }),
71
71
  });
72
+ ctx.onMonitorRearmed?.(id);
72
73
  registry.register({ id, description: input.description, runtime, filter });
73
74
  return textResult(`Monitor started with ID: ${id}`, { details: { bash_id: id, monitor: true } });
74
75
  }