pi-harness-runtime 1.1.439 → 1.1.441

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 (359) hide show
  1. package/harness/e2e/auto-test-loop.ts +8 -2
  2. package/harness/e2e/browser-scrapers/base-browser-scraper.ts +2 -0
  3. package/harness/e2e/browser-scrapers/chrome-profile-manager.ts +2 -0
  4. package/harness/e2e/browser-scrapers/codex-browser-scraper.ts +2 -0
  5. package/harness/e2e/tools-detector.ts +2 -0
  6. package/harness/index.ts +2 -1
  7. package/harness/key-loader.ts +2 -0
  8. package/harness/langchain/checkpointer.ts +2 -0
  9. package/harness/langchain/cron-cli.ts +2 -0
  10. package/harness/langchain/graph.ts +2 -0
  11. package/harness/master-planner.ts +1 -1
  12. package/harness/notification-center.ts +2 -0
  13. package/harness/output-limit-handler.ts +1 -1
  14. package/harness/project-detector/detector.ts +2 -4
  15. package/harness/secret-provider.ts +2 -0
  16. package/harness/task-graph.ts +460 -113
  17. package/index.ts +16 -7
  18. package/package.json +7 -1
  19. package/packages/a2a-adapter/package.json +1 -1
  20. package/packages/agent-policy/dist/extension.d.ts.map +1 -1
  21. package/packages/agent-policy/dist/extension.js +2 -0
  22. package/packages/agent-policy/dist/extension.js.map +1 -1
  23. package/packages/agent-policy/package.json +1 -1
  24. package/packages/agent-policy/src/extension.ts +2 -0
  25. package/packages/architecture-generator/package.json +1 -1
  26. package/packages/auth/dist/minimax-browser-auth.d.ts.map +1 -1
  27. package/packages/auth/dist/minimax-browser-auth.js +23 -1
  28. package/packages/auth/dist/minimax-browser-auth.js.map +1 -1
  29. package/packages/auth/package.json +1 -1
  30. package/packages/auth/src/minimax-browser-auth.ts +30 -5
  31. package/packages/autonomous-refactor/package.json +1 -1
  32. package/packages/autonomous-runtime/dist/inbox.d.ts.map +1 -1
  33. package/packages/autonomous-runtime/dist/inbox.js +2 -0
  34. package/packages/autonomous-runtime/dist/inbox.js.map +1 -1
  35. package/packages/autonomous-runtime/package.json +1 -1
  36. package/packages/autonomous-runtime/src/inbox.ts +2 -0
  37. package/packages/cache-strategy/package.json +1 -1
  38. package/packages/capability-registry/package.json +1 -1
  39. package/packages/checkpoint/package.json +1 -1
  40. package/packages/cli-plugin-sdk/package.json +1 -1
  41. package/packages/clipboard/dist/src/clipboard.d.ts.map +1 -1
  42. package/packages/clipboard/dist/src/clipboard.js +2 -0
  43. package/packages/clipboard/dist/src/clipboard.js.map +1 -1
  44. package/packages/clipboard/dist/src/copy-sync.d.ts.map +1 -1
  45. package/packages/clipboard/dist/src/copy-sync.js +2 -0
  46. package/packages/clipboard/dist/src/copy-sync.js.map +1 -1
  47. package/packages/clipboard/dist/src/gist-relay.d.ts.map +1 -1
  48. package/packages/clipboard/dist/src/gist-relay.js +2 -0
  49. package/packages/clipboard/dist/src/gist-relay.js.map +1 -1
  50. package/packages/clipboard/package.json +1 -1
  51. package/packages/clipboard/src/clipboard.ts +2 -0
  52. package/packages/clipboard/src/copy-sync.ts +2 -0
  53. package/packages/clipboard/src/gist-relay.ts +2 -0
  54. package/packages/clipboard-plugin/dist/types.d.ts +9 -2
  55. package/packages/clipboard-plugin/dist/types.d.ts.map +1 -1
  56. package/packages/clipboard-plugin/package.json +1 -1
  57. package/packages/clipboard-plugin/src/types.ts +9 -2
  58. package/packages/code-generation/package.json +1 -1
  59. package/packages/code-review/package.json +1 -1
  60. package/packages/codex-adapter/package.json +1 -1
  61. package/packages/codex-watcher/package.json +1 -1
  62. package/packages/config-capture/package.json +1 -1
  63. package/packages/connection-runtime/package.json +1 -1
  64. package/packages/context-compiler/package.json +1 -1
  65. package/packages/context-discovery/package.json +1 -1
  66. package/packages/context-manager/package.json +1 -1
  67. package/packages/contracts/dist/delegation-store.js +1 -4
  68. package/packages/contracts/dist/workspace-env.js +28 -1
  69. package/packages/contracts/package.json +1 -1
  70. package/packages/contracts/src/delegation-store.ts +9 -4
  71. package/packages/contracts/src/workspace-env.ts +29 -4
  72. package/packages/cookie-sanitizer/package.json +1 -1
  73. package/packages/cost-optimizer/package.json +1 -1
  74. package/packages/dependency-analyzer/package.json +1 -1
  75. package/packages/django-plugin/package.json +1 -1
  76. package/packages/doc-generator/package.json +1 -1
  77. package/packages/durable-review/package.json +1 -1
  78. package/packages/e2e-tester/package.json +1 -1
  79. package/packages/evaluation-engine/package.json +1 -1
  80. package/packages/evaluation-runner/package.json +1 -1
  81. package/packages/event-bus/package.json +1 -1
  82. package/packages/event-sink/package.json +1 -1
  83. package/packages/event-store/dist/src/store.d.ts.map +1 -1
  84. package/packages/event-store/dist/src/store.js +2 -0
  85. package/packages/event-store/dist/src/store.js.map +1 -1
  86. package/packages/event-store/package.json +1 -1
  87. package/packages/event-store/src/store.ts +3 -0
  88. package/packages/experience-replay/package.json +1 -1
  89. package/packages/feedback-collector/package.json +1 -1
  90. package/packages/file-copy-helper/package.json +1 -1
  91. package/packages/framework-detector/package.json +1 -1
  92. package/packages/framework-plugin-sdk/package.json +1 -1
  93. package/packages/frappe-plugin/package.json +1 -1
  94. package/packages/generic-web-plugin/dist/analyzer.d.ts.map +1 -1
  95. package/packages/generic-web-plugin/dist/analyzer.js +2 -0
  96. package/packages/generic-web-plugin/dist/analyzer.js.map +1 -1
  97. package/packages/generic-web-plugin/package.json +1 -1
  98. package/packages/generic-web-plugin/src/analyzer.ts +3 -0
  99. package/packages/health-monitor/package.json +1 -1
  100. package/packages/intent-analyzer/package.json +1 -1
  101. package/packages/jev-judge/package.json +1 -1
  102. package/packages/knowledge-graph/package.json +1 -1
  103. package/packages/knowledge-retrieval/dist/mcp-client.d.ts.map +1 -1
  104. package/packages/knowledge-retrieval/dist/mcp-client.js +0 -1
  105. package/packages/knowledge-retrieval/dist/mcp-client.js.map +1 -1
  106. package/packages/knowledge-retrieval/package.json +1 -4
  107. package/packages/knowledge-retrieval/src/mcp-client.ts +0 -1
  108. package/packages/laravel-plugin/package.json +1 -1
  109. package/packages/learning-engine/package.json +1 -1
  110. package/packages/logging/package.json +1 -1
  111. package/packages/mcp-adapter/dist/server.d.ts.map +1 -1
  112. package/packages/mcp-adapter/dist/server.js +2 -0
  113. package/packages/mcp-adapter/dist/server.js.map +1 -1
  114. package/packages/mcp-adapter/package.json +1 -1
  115. package/packages/mcp-adapter/src/server.ts +3 -0
  116. package/packages/memory-engine/package.json +1 -1
  117. package/packages/milestone-manager/package.json +1 -1
  118. package/packages/model-registry/package.json +1 -1
  119. package/packages/nextjs-plugin/package.json +1 -1
  120. package/packages/notification/package.json +1 -1
  121. package/packages/observability/package.json +1 -1
  122. package/packages/okf-indexer/package.json +1 -1
  123. package/packages/paperclip-integration/dist/index.d.ts.map +1 -1
  124. package/packages/paperclip-integration/dist/index.js +2 -0
  125. package/packages/paperclip-integration/dist/index.js.map +1 -1
  126. package/packages/paperclip-integration/package.json +1 -1
  127. package/packages/paperclip-integration/src/index.ts +2 -0
  128. package/packages/performance-optimizer/package.json +1 -1
  129. package/packages/permission-mode/package.json +1 -1
  130. package/packages/privilege-broker/dist/audit.d.ts.map +1 -1
  131. package/packages/privilege-broker/dist/audit.js +2 -0
  132. package/packages/privilege-broker/dist/audit.js.map +1 -1
  133. package/packages/privilege-broker/package.json +1 -1
  134. package/packages/privilege-broker/src/audit.ts +2 -0
  135. package/packages/project-analyzer/package.json +1 -1
  136. package/packages/project-bootstrap/package.json +1 -1
  137. package/packages/projection-engine/package.json +1 -1
  138. package/packages/prompt-compiler/dist/compiler.d.ts.map +1 -1
  139. package/packages/prompt-compiler/dist/compiler.js +2 -0
  140. package/packages/prompt-compiler/dist/compiler.js.map +1 -1
  141. package/packages/prompt-compiler/package.json +1 -1
  142. package/packages/prompt-compiler/src/compiler.ts +2 -0
  143. package/packages/prompt-versioning/package.json +1 -1
  144. package/packages/provider-adapter-sdk/package.json +1 -1
  145. package/packages/provider-router/package.json +1 -1
  146. package/packages/provider-selector/package.json +1 -1
  147. package/packages/providers/package.json +1 -1
  148. package/packages/qdrant-skills/package.json +1 -1
  149. package/packages/quota-manager/package.json +1 -1
  150. package/packages/rate-limiter/package.json +1 -1
  151. package/packages/react-vite-plugin/package.json +1 -1
  152. package/packages/relay/package.json +1 -1
  153. package/packages/release-manager/package.json +1 -1
  154. package/packages/requirement-compiler/package.json +1 -1
  155. package/packages/runtime/package.json +1 -1
  156. package/packages/scheduler/package.json +1 -1
  157. package/packages/scheduler-adapter/package.json +1 -1
  158. package/packages/session/package.json +1 -1
  159. package/packages/session-api/package.json +1 -1
  160. package/packages/session-export/package.json +1 -1
  161. package/packages/shared-context/package.json +1 -1
  162. package/packages/skill-mcp-client/dist/client.d.ts.map +1 -1
  163. package/packages/skill-mcp-client/dist/client.js +0 -1
  164. package/packages/skill-mcp-client/dist/client.js.map +1 -1
  165. package/packages/skill-mcp-client/package.json +1 -4
  166. package/packages/skill-mcp-client/src/client.ts +0 -1
  167. package/packages/skill-registry/package.json +1 -1
  168. package/packages/skills/dist/parser.d.ts.map +1 -1
  169. package/packages/skills/dist/parser.js +2 -0
  170. package/packages/skills/dist/parser.js.map +1 -1
  171. package/packages/skills/dist/skill-versioning.d.ts.map +1 -1
  172. package/packages/skills/dist/skill-versioning.js +2 -0
  173. package/packages/skills/dist/skill-versioning.js.map +1 -1
  174. package/packages/skills/package.json +1 -1
  175. package/packages/skills/src/parser.ts +3 -0
  176. package/packages/skills/src/skill-versioning.ts +2 -0
  177. package/packages/sprint-planner/package.json +1 -1
  178. package/packages/subscription-engine/package.json +1 -1
  179. package/packages/task-compiler/package.json +1 -1
  180. package/packages/tencentdb-memory/package.json +1 -1
  181. package/packages/tencentdb-sync/package.json +1 -1
  182. package/packages/test-data-generator/package.json +1 -1
  183. package/packages/test-generator/package.json +1 -1
  184. package/packages/todo-bd-sync/package.json +1 -1
  185. package/packages/token-estimation/package.json +1 -1
  186. package/packages/token-optimizer/package.json +1 -1
  187. package/packages/tooling-preference/package.json +1 -1
  188. package/packages/trajectory/package.json +1 -1
  189. package/packages/tui/package.json +1 -1
  190. package/packages/two-phase-review/package.json +1 -1
  191. package/packages/types/package.json +1 -1
  192. package/packages/voice-api/package.json +1 -1
  193. package/packages/webmcp-tester/dist/index.js +0 -2
  194. package/packages/webmcp-tester/package.json +1 -1
  195. package/packages/webmcp-tester/src/index.ts +0 -3
  196. package/packages/wiki/package.json +1 -1
  197. package/packages/workflow-events/package.json +1 -1
  198. package/packages/workspace-scanner/package.json +1 -1
  199. package/packages/worktree/package.json +1 -1
  200. package/packages/write-review/dist/trigger.d.ts.map +1 -1
  201. package/packages/write-review/dist/trigger.js +1 -2
  202. package/packages/write-review/dist/trigger.js.map +1 -1
  203. package/packages/write-review/package.json +1 -1
  204. package/packages/write-review/src/trigger.ts +1 -2
  205. package/scripts/lib/runtime-imports.ts +189 -3
  206. package/scripts/release-all.ts +5 -3
  207. package/scripts/telegram-webhook-server.ts +2 -0
  208. package/scripts/typecheck-packages.mjs +7 -4
  209. package/scripts/verify-package-contents.ts +161 -2
  210. package/harness/e2e/tools-detector.test.ts +0 -156
  211. package/harness/glm-quota-countdown.test.ts +0 -323
  212. package/harness/langchain/agents.test.ts +0 -39
  213. package/harness/langchain/checkpointer.test.ts +0 -243
  214. package/harness/langchain/daemon.test.ts +0 -459
  215. package/harness/langchain/model-router.test.ts +0 -191
  216. package/harness/langchain/ping-pong-middleware.test.ts +0 -69
  217. package/harness/langchain/scoreboard.test.ts +0 -245
  218. package/harness/langchain/status-line.test.ts +0 -106
  219. package/harness/langchain/surge.test.ts +0 -467
  220. package/harness/langchain/widget.test.ts +0 -251
  221. package/harness/skill-sync.test.ts +0 -57
  222. package/harness/ssh-detach-interceptor.test.ts +0 -263
  223. package/harness/ssh-hang-recovery.test.ts +0 -86
  224. package/packages/a2a-adapter/test/a2a.test.ts +0 -151
  225. package/packages/agent-policy/test/interlock.test.ts +0 -101
  226. package/packages/agent-policy/test/policy-retention.test.ts +0 -380
  227. package/packages/agent-policy/test/policy.test.ts +0 -387
  228. package/packages/auth/test/auth.test.ts +0 -238
  229. package/packages/autonomous-refactor/test/refactor.test.ts +0 -202
  230. package/packages/autonomous-runtime/test/types.test.ts +0 -95
  231. package/packages/cache-strategy/test/cache.test.ts +0 -137
  232. package/packages/capability-registry/test/registry.test.ts +0 -204
  233. package/packages/checkpoint/test/engine.test.ts +0 -265
  234. package/packages/cli-plugin-sdk/test/cli.test.ts +0 -45
  235. package/packages/code-generation/test/generator.test.ts +0 -238
  236. package/packages/code-review/test/engine.test.ts +0 -302
  237. package/packages/codex-adapter/test/provider.test.ts +0 -142
  238. package/packages/codex-watcher/test/watch.test.ts +0 -453
  239. package/packages/context-compiler/test/context-compiler.test.ts +0 -746
  240. package/packages/context-manager/test/context.test.ts +0 -198
  241. package/packages/contracts/test/delegation.test.ts +0 -350
  242. package/packages/contracts/test/workspace-env.test.ts +0 -802
  243. package/packages/cookie-sanitizer/test/infer.test.ts +0 -110
  244. package/packages/cookie-sanitizer/test/normalize.test.ts +0 -113
  245. package/packages/cookie-sanitizer/test/parse.test.ts +0 -204
  246. package/packages/cookie-sanitizer/test/sync.test.ts +0 -237
  247. package/packages/cookie-sanitizer/test/watcher.test.ts +0 -27
  248. package/packages/cost-optimizer/test/cost-optimizer.test.ts +0 -438
  249. package/packages/dependency-analyzer/test/analyzer.test.ts +0 -49
  250. package/packages/django-plugin/test/analyzer.test.ts +0 -195
  251. package/packages/doc-generator/test/docs.test.ts +0 -168
  252. package/packages/durable-review/test/acceptance.test.ts +0 -357
  253. package/packages/durable-review/test/smoke.test.ts +0 -107
  254. package/packages/evaluation-engine/test/engine.test.ts +0 -277
  255. package/packages/evaluation-runner/test/runner.test.ts +0 -168
  256. package/packages/event-bus/test/bus.test.ts +0 -100
  257. package/packages/event-store/test/store.test.ts +0 -115
  258. package/packages/experience-replay/test/replay.test.ts +0 -267
  259. package/packages/feedback-collector/test/collector.test.ts +0 -142
  260. package/packages/framework-detector/test/detector.test.ts +0 -75
  261. package/packages/framework-plugin-sdk/test/manager.test.ts +0 -320
  262. package/packages/frappe-plugin/test/analyzer.test.ts +0 -250
  263. package/packages/generic-web-plugin/test/analyzer.test.ts +0 -134
  264. package/packages/health-monitor/test/health.test.ts +0 -231
  265. package/packages/intent-analyzer/test/analyzer.test.ts +0 -72
  266. package/packages/intent-analyzer/test/ping-pong.test.ts +0 -96
  267. package/packages/jev-judge/tests/auto-continue-context.test.ts +0 -280
  268. package/packages/jev-judge/tests/continuation-controller.test.ts +0 -1396
  269. package/packages/jev-judge/tests/jev-provider-chain.test.ts +0 -536
  270. package/packages/jev-judge/tests/outcome-application.test.ts +0 -132
  271. package/packages/jev-judge/tests/question-risk.test.ts +0 -129
  272. package/packages/jev-judge/tests/typesafe-provider.test.ts +0 -640
  273. package/packages/jev-judge/tests/validation-ledger.test.ts +0 -181
  274. package/packages/jev-judge/tests/validation-plan.test.ts +0 -170
  275. package/packages/jev-judge/tests/validation-tie-breaker.test.ts +0 -88
  276. package/packages/laravel-plugin/test/analyzer.test.ts +0 -220
  277. package/packages/learning-engine/test/engine.test.ts +0 -331
  278. package/packages/logging/test/buffer.test.ts +0 -44
  279. package/packages/logging/test/classification.test.ts +0 -137
  280. package/packages/logging/test/config.test.ts +0 -97
  281. package/packages/logging/test/fanout.test.ts +0 -186
  282. package/packages/logging/test/identity-transport.test.ts +0 -197
  283. package/packages/logging/test/incidents.test.ts +0 -404
  284. package/packages/logging/test/ingest-schema.test.ts +0 -184
  285. package/packages/logging/test/integration.test.ts +0 -140
  286. package/packages/logging/test/log-http.test.ts +0 -246
  287. package/packages/logging/test/redact.test.ts +0 -109
  288. package/packages/logging/test/sampler.test.ts +0 -57
  289. package/packages/logging/test/server.test.ts +0 -444
  290. package/packages/logging/test/shipper.test.ts +0 -152
  291. package/packages/logging/test/spool.test.ts +0 -96
  292. package/packages/mcp-adapter/test/server.test.ts +0 -91
  293. package/packages/memory-engine/test/engine.test.ts +0 -456
  294. package/packages/model-registry/test/registry.test.ts +0 -342
  295. package/packages/nextjs-plugin/test/analyzer.test.ts +0 -149
  296. package/packages/notification/test/approval-payload.test.ts +0 -269
  297. package/packages/notification/test/detail-format.test.ts +0 -106
  298. package/packages/notification/test/notification.test.ts +0 -375
  299. package/packages/notification/test/pending-question-lifecycle.test.ts +0 -195
  300. package/packages/notification/test/pending-question.test.ts +0 -331
  301. package/packages/notification/test/tooling-proposal-payload.test.ts +0 -212
  302. package/packages/observability/test/observability.test.ts +0 -1350
  303. package/packages/performance-optimizer/test/optimizer.test.ts +0 -267
  304. package/packages/project-analyzer/test/index.test.ts +0 -1719
  305. package/packages/prompt-compiler/test/prompt-compiler.test.ts +0 -813
  306. package/packages/prompt-versioning/test/versioning.test.ts +0 -112
  307. package/packages/provider-adapter-sdk/test/sdk.test.ts +0 -220
  308. package/packages/provider-router/test/provider-router.test.ts +0 -405
  309. package/packages/provider-selector/test/selector.test.ts +0 -192
  310. package/packages/providers/test/providers.test.ts +0 -225
  311. package/packages/qdrant-skills/test/collection-info.test.ts +0 -165
  312. package/packages/qdrant-skills/test/embedder-batch.test.ts +0 -184
  313. package/packages/qdrant-skills/test/embedder.test.ts +0 -97
  314. package/packages/quota-manager/test/quota.test.ts +0 -432
  315. package/packages/rate-limiter/test/limiter.test.ts +0 -128
  316. package/packages/react-vite-plugin/test/analyzer.test.ts +0 -139
  317. package/packages/relay/test/client.test.ts +0 -446
  318. package/packages/relay/test/relay-e2e.test.ts +0 -299
  319. package/packages/relay/test/relay-endpoint.test.ts +0 -278
  320. package/packages/release-manager/test/release.test.ts +0 -215
  321. package/packages/requirement-compiler/test/requirement-compiler.test.ts +0 -743
  322. package/packages/runtime/test/runtime-api.test.ts +0 -169
  323. package/packages/runtime/test/runtime.test.ts +0 -297
  324. package/packages/scheduler/test/scheduler.test.ts +0 -125
  325. package/packages/session/test/manager.test.ts +0 -233
  326. package/packages/shared-context/test/shared-context.test.ts +0 -114
  327. package/packages/skill-registry/test/registry.test.ts +0 -508
  328. package/packages/skills/test/init-skills.test.ts +0 -114
  329. package/packages/skills/test/remote-skills.test.ts +0 -360
  330. package/packages/skills/test/remote-source.test.ts +0 -248
  331. package/packages/skills/test/sanitize.test.ts +0 -250
  332. package/packages/skills/test/vector-indexing.test.ts +0 -205
  333. package/packages/skills/test/vector-schema.test.ts +0 -180
  334. package/packages/skills/test/vector-threshold.test.ts +0 -108
  335. package/packages/sprint-planner/test/planner.test.ts +0 -187
  336. package/packages/task-compiler/test/task-compiler.test.ts +0 -628
  337. package/packages/test-data-generator/test/generator.test.ts +0 -265
  338. package/packages/test-generator/test/generator.test.ts +0 -156
  339. package/packages/token-estimation/test/token-estimation.test.ts +0 -207
  340. package/packages/token-optimizer/test/optimizer.test.ts +0 -141
  341. package/packages/tooling-preference/tests/changed-files.test.ts +0 -124
  342. package/packages/tooling-preference/tests/detect.test.ts +0 -188
  343. package/packages/tooling-preference/tests/proposal.test.ts +0 -107
  344. package/packages/tooling-preference/tests/quality-check.test.ts +0 -272
  345. package/packages/tooling-preference/tests/registry.test.ts +0 -51
  346. package/packages/tooling-preference/tests/store.test.ts +0 -99
  347. package/packages/trajectory/test/store.test.ts +0 -250
  348. package/packages/tui/test/harness-footer.test.ts +0 -559
  349. package/packages/tui/test/harness-header.test.ts +0 -590
  350. package/packages/two-phase-review/test/classify.test.ts +0 -102
  351. package/packages/two-phase-review/test/helpers.ts +0 -72
  352. package/packages/two-phase-review/test/rules.test.ts +0 -150
  353. package/packages/two-phase-review/test/runtime.test.ts +0 -362
  354. package/packages/two-phase-review/test/scope.test.ts +0 -186
  355. package/packages/two-phase-review/test/signals.test.ts +0 -183
  356. package/packages/two-phase-review/test/state.test.ts +0 -201
  357. package/packages/wiki/test/basic.test.ts +0 -242
  358. package/packages/workspace-scanner/test/scanner.test.ts +0 -43
  359. package/packages/worktree/test/worktree.test.ts +0 -163
@@ -1,141 +0,0 @@
1
- /**
2
- * Token Optimizer Tests (RFC-0011)
3
- */
4
-
5
- import { describe, it, expect } from "bun:test";
6
- import {
7
- estimateTokens,
8
- estimateMessageTokens,
9
- buildBudget,
10
- splitByPriority,
11
- optimizeBudget,
12
- calculateCost,
13
- trimToTokens,
14
- DEFAULT_PRICING,
15
- } from "../src/index.js";
16
- import type { PromptMessage } from "../src/index.js";
17
-
18
- const makeMsg = (overrides?: Partial<PromptMessage>): PromptMessage => ({
19
- role: "user",
20
- content: "Hello world",
21
- priority: 5,
22
- ...overrides,
23
- });
24
-
25
- describe("DEFAULT_PRICING", () => {
26
- it("has gpt-4o pricing", () => {
27
- expect(DEFAULT_PRICING["gpt-4o"].inputPer1M).toBe(2.5);
28
- expect(DEFAULT_PRICING["gpt-4o"].outputPer1M).toBe(10.0);
29
- });
30
- it("has claude pricing", () => {
31
- expect(DEFAULT_PRICING["claude-haiku"].inputPer1M).toBe(0.25);
32
- });
33
- });
34
-
35
- describe("estimateTokens", () => {
36
- it("estimates 1 token per 4 chars", () => {
37
- expect(estimateTokens("01234")).toBe(2);
38
- });
39
- it("empty string returns 0", () => expect(estimateTokens("")).toBe(0));
40
- });
41
-
42
- describe("estimateMessageTokens", () => {
43
- it("sums messages plus overhead", () => {
44
- const msgs = [makeMsg({ content: "hello" }), makeMsg({ content: "world" })];
45
- expect(estimateMessageTokens(msgs)).toBeGreaterThan(
46
- estimateTokens("hello") + estimateTokens("world"),
47
- );
48
- });
49
- it("empty returns 0", () => expect(estimateMessageTokens([])).toBe(0));
50
- });
51
-
52
- describe("buildBudget", () => {
53
- it("calculates available tokens", () => {
54
- const b = buildBudget(1000, 100, 50);
55
- expect(b.maxTokens).toBe(1000);
56
- expect(b.systemTokens).toBe(100);
57
- expect(b.reservedTokens).toBe(50);
58
- expect(b.availableTokens).toBe(850);
59
- });
60
-
61
- it("available never negative", () => {
62
- const b = buildBudget(100, 200, 0);
63
- expect(b.availableTokens).toBe(0);
64
- });
65
- });
66
-
67
- describe("splitByPriority", () => {
68
- it("splits into three groups", () => {
69
- const msgs = Array.from({ length: 9 }, (_, i) =>
70
- makeMsg({ content: `msg${i}`, priority: i + 1 }),
71
- );
72
- const { high, medium, low } = splitByPriority(msgs);
73
- expect(high.length).toBeGreaterThan(0);
74
- expect(medium.length).toBeGreaterThan(0);
75
- expect(low.length).toBeGreaterThan(0);
76
- expect(high[0].priority).toBeLessThanOrEqual(medium[0].priority);
77
- });
78
-
79
- it("handles single item", () => {
80
- const { high } = splitByPriority([makeMsg({ priority: 1 })]);
81
- expect(high.length).toBe(1);
82
- });
83
- });
84
-
85
- describe("optimizeBudget", () => {
86
- it("keeps high priority", () => {
87
- const msgs = [
88
- makeMsg({ content: "high", priority: 1 }),
89
- makeMsg({ content: "low", priority: 9 }),
90
- ];
91
- const budget = buildBudget(1000, 0, 0);
92
- const result = optimizeBudget(msgs, budget);
93
- expect(result.kept.some((m) => m.content === "high")).toBe(true);
94
- });
95
-
96
- it("removes when over budget", () => {
97
- const longMsg = makeMsg({ content: "x".repeat(1000), priority: 5 });
98
- const budget = buildBudget(100, 0, 0);
99
- const result = optimizeBudget([longMsg], budget);
100
- expect(result.kept.length).toBeLessThan(1);
101
- });
102
-
103
- it("zero available keeps nothing", () => {
104
- const result = optimizeBudget([makeMsg()], buildBudget(100, 100, 0));
105
- expect(result.kept).toEqual([]);
106
- expect(result.compressionRatio).toBe(1);
107
- });
108
- });
109
-
110
- describe("calculateCost", () => {
111
- it("calculates total cost", () => {
112
- const msgs = [makeMsg({ content: "hello world" })];
113
- const cost = calculateCost(msgs, 50, "gpt-4o-mini");
114
- expect(cost.inputTokens).toBeGreaterThan(0);
115
- expect(cost.outputTokens).toBe(50);
116
- expect(cost.totalCost).toBeGreaterThan(0);
117
- expect(cost.currency).toBe("USD");
118
- });
119
-
120
- it("uses default pricing", () => {
121
- const cost = calculateCost([], 0, "unknown-model");
122
- expect(cost.totalCost).toBe(0);
123
- });
124
- });
125
-
126
- describe("trimToTokens", () => {
127
- it("trims to max tokens", () => {
128
- const text = "one two three four five";
129
- const trimmed = trimToTokens(text, 3);
130
- expect(trimmed.split(" ").length).toBeLessThanOrEqual(3);
131
- });
132
-
133
- it("returns empty for zero", () => {
134
- expect(trimToTokens("hello", 0)).toBe("");
135
- });
136
-
137
- it("handles text shorter than limit", () => {
138
- const result = trimToTokens("hi", 10);
139
- expect(result).toBe("hi");
140
- });
141
- });
@@ -1,124 +0,0 @@
1
- /**
2
- * The changed JavaScript/TypeScript files of a workspace.
3
- *
4
- * The detection reads the worktree of the session: a file that changed is
5
- * a file the check may read. A workspace without git yields nothing - the
6
- * harness never guesses which files belong to the session.
7
- */
8
-
9
- import { describe, it, expect, beforeEach, afterEach } from "bun:test";
10
- import { execFileSync } from "node:child_process";
11
- import { mkdtempSync, mkdirSync, rmSync, writeFileSync } from "node:fs";
12
- import { tmpdir } from "node:os";
13
- import { join } from "node:path";
14
- import {
15
- detectChangedJsTsFiles,
16
- isIgnoredPath,
17
- isJsTsFile,
18
- parseGitStatus,
19
- } from "../src/changed-files.js";
20
-
21
- let root = "";
22
-
23
- function git(...args: string[]): void {
24
- execFileSync("git", args, { cwd: root, stdio: "ignore" });
25
- }
26
-
27
- beforeEach(() => {
28
- root = mkdtempSync(join(tmpdir(), "tooling-changed-"));
29
- git("init", "-q");
30
- git("config", "user.email", "test@example.com");
31
- git("config", "user.name", "Test");
32
- });
33
-
34
- afterEach(() => {
35
- rmSync(root, { recursive: true, force: true });
36
- });
37
-
38
- describe("the changed file detection", () => {
39
- it("finds the JavaScript and TypeScript files of the worktree", () => {
40
- mkdirSync(join(root, "src"), { recursive: true });
41
- writeFileSync(join(root, "src", "app.ts"), "export const a = 1;\n");
42
- writeFileSync(join(root, "src", "app.tsx"), "export const B = 1;\n");
43
- writeFileSync(join(root, "src", "notes.md"), "# notes\n");
44
- writeFileSync(join(root, "src", "styles.css"), "body {}\n");
45
-
46
- const result = detectChangedJsTsFiles(root);
47
-
48
- expect(result.detected).toBe(true);
49
- expect(result.files).toEqual(["src/app.ts", "src/app.tsx"]);
50
- });
51
-
52
- it("finds the files that were changed after the commit", () => {
53
- writeFileSync(join(root, "a.ts"), "export const a = 1;\n");
54
- git("add", ".");
55
- git("commit", "-q", "-m", "first");
56
- writeFileSync(join(root, "a.ts"), "export const a = 2;\n");
57
-
58
- const result = detectChangedJsTsFiles(root);
59
-
60
- expect(result.files).toEqual(["a.ts"]);
61
- });
62
-
63
- it("finds a file that was renamed", () => {
64
- writeFileSync(join(root, "old.ts"), "export const a = 1;\n");
65
- git("add", ".");
66
- git("commit", "-q", "-m", "first");
67
- git("mv", "old.ts", "new.ts");
68
-
69
- const result = detectChangedJsTsFiles(root);
70
-
71
- expect(result.files).toEqual(["new.ts"]);
72
- });
73
-
74
- it("ignores the files of a build directory", () => {
75
- mkdirSync(join(root, "dist"), { recursive: true });
76
- writeFileSync(join(root, "dist", "bundle.js"), "// built\n");
77
-
78
- const result = detectChangedJsTsFiles(root);
79
-
80
- expect(result.files).toEqual([]);
81
- });
82
-
83
- it("yields nothing in a workspace that is not a repository", () => {
84
- const plain = mkdtempSync(join(tmpdir(), "tooling-plain-"));
85
- try {
86
- writeFileSync(join(plain, "app.ts"), "export const a = 1;\n");
87
-
88
- const result = detectChangedJsTsFiles(plain);
89
-
90
- expect(result.detected).toBe(false);
91
- expect(result.files).toEqual([]);
92
- } finally {
93
- rmSync(plain, { recursive: true, force: true });
94
- }
95
- });
96
- });
97
-
98
- describe("the git status parser", () => {
99
- it("reads the path of every record", () => {
100
- const output = " M src/app.ts\0?? src/new.ts\0";
101
- expect(parseGitStatus(output)).toEqual(["src/app.ts", "src/new.ts"]);
102
- });
103
-
104
- it("skips the original path of a rename", () => {
105
- const output = "R src/new.ts\0src/old.ts\0";
106
- expect(parseGitStatus(output)).toEqual(["src/new.ts"]);
107
- });
108
- });
109
-
110
- describe("the file filters", () => {
111
- it("knows the JavaScript and TypeScript extensions", () => {
112
- expect(isJsTsFile("src/app.ts")).toBe(true);
113
- expect(isJsTsFile("src/app.tsx")).toBe(true);
114
- expect(isJsTsFile("src/app.mjs")).toBe(true);
115
- expect(isJsTsFile("src/app.json")).toBe(false);
116
- expect(isJsTsFile("README.md")).toBe(false);
117
- });
118
-
119
- it("knows the directories that hold no source", () => {
120
- expect(isIgnoredPath("node_modules/pkg/index.js")).toBe(true);
121
- expect(isIgnoredPath("dist/bundle.js")).toBe(true);
122
- expect(isIgnoredPath("src/app.ts")).toBe(false);
123
- });
124
- });
@@ -1,188 +0,0 @@
1
- import { describe, expect, it } from "bun:test";
2
- import { mkdtempSync, mkdirSync, rmSync, writeFileSync } from "node:fs";
3
- import { tmpdir } from "node:os";
4
- import { join } from "node:path";
5
- import {
6
- detectToolingContext,
7
- evaluateBiomeProposalEligibility,
8
- } from "../src/detect.ts";
9
-
10
- function workspace(files: Record<string, string>): string {
11
- const root = mkdtempSync(join(tmpdir(), "tooling-preference-"));
12
- for (const [name, content] of Object.entries(files)) {
13
- const path = join(root, name);
14
- mkdirSync(join(path, ".."), { recursive: true });
15
- writeFileSync(path, content, "utf8");
16
- }
17
- return root;
18
- }
19
-
20
- function cleanup(root: string): void {
21
- rmSync(root, { recursive: true, force: true });
22
- }
23
-
24
- describe("detectToolingContext", () => {
25
- it("detects a Next.js + React + TypeScript workspace with ESLint and Prettier", () => {
26
- const root = workspace({
27
- "package.json": JSON.stringify({
28
- name: "web",
29
- dependencies: { next: "15.0.0", react: "19.0.0" },
30
- devDependencies: { eslint: "^9.0.0", prettier: "^3.0.0", typescript: "^5.7.0" },
31
- }),
32
- "tsconfig.json": "{}",
33
- ".eslintrc.json": "{}",
34
- ".prettierrc": "{}",
35
- "src/app/page.tsx": "export const x = 1;",
36
- });
37
- try {
38
- const context = detectToolingContext(root);
39
- expect(context.hasPackageJson).toBe(true);
40
- expect(context.isJavaScriptTypeScript).toBe(true);
41
- expect(context.isNextJs).toBe(true);
42
- expect(context.isReact).toBe(true);
43
- expect(context.usesBiome).toBe(false);
44
- expect(context.usesEslint).toBe(true);
45
- expect(context.usesPrettier).toBe(true);
46
- expect(context.frameworks).toContain("next");
47
- } finally {
48
- cleanup(root);
49
- }
50
- });
51
-
52
- it("reports a workspace that already uses Biome", () => {
53
- const root = workspace({
54
- "package.json": JSON.stringify({ name: "web", devDependencies: { eslint: "^9.0.0" } }),
55
- "biome.json": "{}",
56
- "tsconfig.json": "{}",
57
- });
58
- try {
59
- const context = detectToolingContext(root);
60
- expect(context.usesBiome).toBe(true);
61
- } finally {
62
- cleanup(root);
63
- }
64
- });
65
-
66
- it("detects Biome through the dependency alone", () => {
67
- const root = workspace({
68
- "package.json": JSON.stringify({
69
- name: "web",
70
- devDependencies: { "@biomejs/biome": "^2.4.7" },
71
- }),
72
- "tsconfig.json": "{}",
73
- });
74
- try {
75
- expect(detectToolingContext(root).usesBiome).toBe(true);
76
- } finally {
77
- cleanup(root);
78
- }
79
- });
80
-
81
- it("detects the package manager through the lockfile", () => {
82
- const root = workspace({
83
- "package.json": JSON.stringify({ name: "web" }),
84
- "pnpm-lock.yaml": "",
85
- });
86
- try {
87
- expect(detectToolingContext(root).packageManager).toBe("pnpm");
88
- } finally {
89
- cleanup(root);
90
- }
91
- });
92
-
93
- it("prefers the declared package manager", () => {
94
- const root = workspace({
95
- "package.json": JSON.stringify({ name: "web", packageManager: "bun@1.3.0" }),
96
- "package-lock.json": "{}",
97
- });
98
- try {
99
- expect(detectToolingContext(root).packageManager).toBe("bun");
100
- } finally {
101
- cleanup(root);
102
- }
103
- });
104
-
105
- it("finds a source file without a tsconfig", () => {
106
- const root = workspace({
107
- "package.json": JSON.stringify({ name: "web" }),
108
- "src/index.ts": "export const x = 1;",
109
- });
110
- try {
111
- expect(detectToolingContext(root).isJavaScriptTypeScript).toBe(true);
112
- } finally {
113
- cleanup(root);
114
- }
115
- });
116
-
117
- it("does not walk into a dependency directory for sources", () => {
118
- const root = workspace({
119
- "package.json": JSON.stringify({ name: "web" }),
120
- "node_modules/some-package/index.js": "module.exports = 1;",
121
- });
122
- try {
123
- expect(detectToolingContext(root).isJavaScriptTypeScript).toBe(false);
124
- } finally {
125
- cleanup(root);
126
- }
127
- });
128
- });
129
-
130
- describe("evaluateBiomeProposalEligibility", () => {
131
- it("offers the proposal for a JS/TS workspace with ESLint or Prettier", () => {
132
- const root = workspace({
133
- "package.json": JSON.stringify({ name: "web", devDependencies: { eslint: "^9.0.0" } }),
134
- "tsconfig.json": "{}",
135
- });
136
- try {
137
- const decision = evaluateBiomeProposalEligibility(detectToolingContext(root));
138
- expect(decision.eligible).toBe(true);
139
- } finally {
140
- cleanup(root);
141
- }
142
- });
143
-
144
- it("never asks a workspace that already uses Biome", () => {
145
- const root = workspace({
146
- "package.json": JSON.stringify({
147
- name: "web",
148
- devDependencies: { eslint: "^9.0.0", "@biomejs/biome": "^2.4.7" },
149
- }),
150
- "tsconfig.json": "{}",
151
- });
152
- try {
153
- const decision = evaluateBiomeProposalEligibility(detectToolingContext(root));
154
- expect(decision.eligible).toBe(false);
155
- expect(decision.reason).toContain("Biome");
156
- } finally {
157
- cleanup(root);
158
- }
159
- });
160
-
161
- it("never asks a workspace without ESLint and Prettier", () => {
162
- const root = workspace({
163
- "package.json": JSON.stringify({ name: "web" }),
164
- "tsconfig.json": "{}",
165
- });
166
- try {
167
- const decision = evaluateBiomeProposalEligibility(detectToolingContext(root));
168
- expect(decision.eligible).toBe(false);
169
- expect(decision.reason).toContain("neither ESLint nor Prettier");
170
- } finally {
171
- cleanup(root);
172
- }
173
- });
174
-
175
- it("never asks a workspace that is not JavaScript/TypeScript", () => {
176
- const root = workspace({
177
- "package.json": JSON.stringify({ name: "docs" }),
178
- "README.md": "# docs",
179
- });
180
- try {
181
- const decision = evaluateBiomeProposalEligibility(detectToolingContext(root));
182
- expect(decision.eligible).toBe(false);
183
- expect(decision.reason).toContain("not a JavaScript/TypeScript project");
184
- } finally {
185
- cleanup(root);
186
- }
187
- });
188
- });
@@ -1,107 +0,0 @@
1
- import { describe, expect, it } from "bun:test";
2
- import {
3
- buildToolingButtons,
4
- buildToolingImplementationPrompt,
5
- buildToolingProposalMessage,
6
- buildToolingRequestId,
7
- parseToolingTarget,
8
- TOOLING_ACTION,
9
- } from "../src/proposal.ts";
10
- import type { ToolingContext } from "../src/detect.ts";
11
-
12
- const context: ToolingContext = {
13
- root: "/work/web",
14
- hasPackageJson: true,
15
- isJavaScriptTypeScript: true,
16
- isNextJs: true,
17
- isReact: true,
18
- usesBiome: false,
19
- usesEslint: true,
20
- usesPrettier: true,
21
- packageManager: "pnpm",
22
- frameworks: ["next"],
23
- };
24
-
25
- describe("buildToolingRequestId", () => {
26
- it("is stable for the same user and workspace", () => {
27
- const first = buildToolingRequestId("user-1", "/work/web");
28
- const second = buildToolingRequestId("user-1", "/work/web");
29
- expect(first).toBe(second);
30
- });
31
-
32
- it("differs per user and per workspace", () => {
33
- expect(buildToolingRequestId("user-1", "/work/web")).not.toBe(
34
- buildToolingRequestId("user-2", "/work/web"),
35
- );
36
- expect(buildToolingRequestId("user-1", "/work/web")).not.toBe(
37
- buildToolingRequestId("user-1", "/work/other"),
38
- );
39
- });
40
-
41
- it("holds no underscore, so the callback parser keeps it intact", () => {
42
- const requestId = buildToolingRequestId("user-1", "/work/web");
43
- expect(requestId).not.toContain("_");
44
- expect(requestId.startsWith("biome-")).toBe(true);
45
- });
46
- });
47
-
48
- describe("buildToolingButtons", () => {
49
- it("sends one action with a choice per button", () => {
50
- const requestId = buildToolingRequestId("user-1", "/work/web");
51
- const buttons = buildToolingButtons(requestId);
52
- expect(buttons).toHaveLength(2);
53
- for (const button of buttons) {
54
- expect(button.action).toBe(TOOLING_ACTION);
55
- expect(button.targetId).toContain(requestId);
56
- }
57
- expect(buttons[0].targetId.startsWith("yes-")).toBe(true);
58
- expect(buttons[1].targetId.startsWith("no-")).toBe(true);
59
- });
60
-
61
- it("keeps the action a single token", () => {
62
- expect(TOOLING_ACTION).not.toContain("_");
63
- });
64
- });
65
-
66
- describe("parseToolingTarget", () => {
67
- it("reads the choice and the request ID back", () => {
68
- const requestId = buildToolingRequestId("user-1", "/work/web");
69
- const [yes, no] = buildToolingButtons(requestId);
70
- expect(parseToolingTarget(yes.targetId)).toEqual({ choice: "yes", requestId });
71
- expect(parseToolingTarget(no.targetId)).toEqual({ choice: "no", requestId });
72
- });
73
-
74
- it("refuses a target that is not part of the proposal", () => {
75
- expect(parseToolingTarget("q-123")).toBeNull();
76
- expect(parseToolingTarget("maybe-biome-abc")).toBeNull();
77
- expect(parseToolingTarget("")).toBeNull();
78
- expect(parseToolingTarget(undefined)).toBeNull();
79
- });
80
-
81
- it("survives the callback data round trip", () => {
82
- const requestId = buildToolingRequestId("user-1", "/work/web");
83
- const [yes] = buildToolingButtons(requestId);
84
- const data = `${yes.action}_${yes.targetId}`;
85
- const [action, targetId] = data.split("_");
86
- expect(action).toBe(TOOLING_ACTION);
87
- expect(parseToolingTarget(targetId)?.requestId).toBe(requestId);
88
- });
89
- });
90
-
91
- describe("the wording", () => {
92
- it("names the detected tools and the frameworks", () => {
93
- const message = buildToolingProposalMessage(context);
94
- expect(message).toContain("Next.js");
95
- expect(message).toContain("ESLint");
96
- expect(message).toContain("Prettier");
97
- expect(message).toContain("Biome");
98
- });
99
-
100
- it("asks the agent to implement Biome after a yes", () => {
101
- const prompt = buildToolingImplementationPrompt(context, "/work/web");
102
- expect(prompt).toContain("/work/web");
103
- expect(prompt).toContain("@biomejs/biome");
104
- expect(prompt).toContain("pnpm add --save-dev");
105
- expect(prompt).toContain("Next.js");
106
- });
107
- });