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,168 +0,0 @@
1
- /**
2
- * Doc Generator Tests (RFC-0014)
3
- */
4
-
5
- import { describe, it, expect } from "bun:test";
6
- import {
7
- detectProjectType,
8
- parseSignals,
9
- detectSymbols,
10
- generateDocs,
11
- } from "../src/index.js";
12
- import type { SourceFile } from "../src/index.js";
13
-
14
- const src = (content: string, path = "src/utils.ts"): SourceFile => ({
15
- path,
16
- content,
17
- language: "typescript",
18
- });
19
-
20
- describe("detectProjectType", () => {
21
- it("detects Frappe/ERPNext", () => {
22
- const signals = ["frappe-bench/apps/myapp/hooks.py", "doctype/CRM"];
23
- const result = detectProjectType(signals);
24
- expect(result.projectType).toBe("frappe_erpnext");
25
- expect(result.signals).toContain("frappe-bench/apps/myapp/hooks.py");
26
- });
27
-
28
- it("detects Next.js", () => {
29
- const signals = ["next.config.js", "app/layout.tsx", "pages/index.ts"];
30
- const result = detectProjectType(signals);
31
- expect(result.projectType).toBe("nextjs");
32
- });
33
-
34
- it("detects React/Vite", () => {
35
- const signals = ["vite.config.ts", "src/main.tsx", "index.html"];
36
- const result = detectProjectType(signals);
37
- expect(result.projectType).toBe("react_vite");
38
- });
39
-
40
- it("detects Django", () => {
41
- const signals = ["manage.py", "settings.py"];
42
- const result = detectProjectType(signals);
43
- expect(result.projectType).toBe("django");
44
- });
45
-
46
- it("detects Laravel", () => {
47
- const signals = ["artisan", "database/seeders/UserSeeder.php"];
48
- const result = detectProjectType(signals);
49
- expect(result.projectType).toBe("laravel");
50
- });
51
-
52
- it("returns unknown for empty signals", () => {
53
- const result = detectProjectType([]);
54
- expect(result.projectType).toBe("unknown");
55
- expect(result.confidence).toBe(0);
56
- });
57
-
58
- it("returns generic_web for package.json", () => {
59
- const result = detectProjectType(["package.json", "index.js"]);
60
- expect(result.projectType).toBe("generic_web");
61
- });
62
-
63
- it("includes recommended seed strategy", () => {
64
- const result = detectProjectType(["manage.py"]);
65
- expect(result.recommendedSeedStrategy).toBe("django_migrations");
66
- });
67
-
68
- it("includes recommended e2e strategy", () => {
69
- const result = detectProjectType(["next.config.js"]);
70
- expect(result.recommendedE2EStrategy).toBe("nextjs_dev_server_flow");
71
- });
72
-
73
- it("confidence is 0-1", () => {
74
- const result = detectProjectType(["doctype/CRM"]);
75
- expect(result.confidence).toBeGreaterThanOrEqual(0);
76
- expect(result.confidence).toBeLessThanOrEqual(1);
77
- });
78
- });
79
-
80
- describe("parseSignals", () => {
81
- it("filters paths with dots or slashes", () => {
82
- const entries = ["frappe-bench", "doctype", "README.md", "apps/main.py"];
83
- const signals = parseSignals(entries);
84
- expect(signals).toContain("README.md");
85
- expect(signals).toContain("apps/main.py");
86
- expect(signals).not.toContain("doctype");
87
- });
88
- });
89
-
90
- describe("detectSymbols", () => {
91
- it("detects function declarations", () => {
92
- const s = src(
93
- "export function add(a: number, b: number): number { return a + b; }",
94
- );
95
- const symbols = detectSymbols(s);
96
- const fn = symbols.find((sym) => sym.kind === "function");
97
- expect(fn).toBeDefined();
98
- expect(fn!.name).toBe("add");
99
- expect(fn!.signature).toContain("add");
100
- });
101
-
102
- it("detects async functions", () => {
103
- const s = src("async function fetchData(): Promise<string> { return ''; }");
104
- const symbols = detectSymbols(s);
105
- expect(symbols.some((sym) => sym.kind === "function")).toBe(true);
106
- });
107
-
108
- it("detects class declarations", () => {
109
- const s = src("export class UserService { }");
110
- const symbols = detectSymbols(s);
111
- expect(symbols.some((sym) => sym.kind === "class")).toBe(true);
112
- });
113
-
114
- it("detects interface declarations", () => {
115
- const s = src("export interface Config { port: number; }");
116
- const symbols = detectSymbols(s);
117
- expect(symbols.some((sym) => sym.kind === "interface")).toBe(true);
118
- });
119
-
120
- it("detects type aliases", () => {
121
- const s = src("export type ID = string | number;");
122
- const symbols = detectSymbols(s);
123
- expect(symbols.some((sym) => sym.kind === "type")).toBe(true);
124
- });
125
-
126
- it("detects const exports", () => {
127
- const s = src("export const MAX_RETRIES = 3;");
128
- const symbols = detectSymbols(s);
129
- expect(symbols.some((sym) => sym.kind === "constant")).toBe(true);
130
- });
131
-
132
- it("includes file and line number", () => {
133
- const s = src("function a() {}\nfunction b() {}");
134
- const symbols = detectSymbols(s);
135
- const b = symbols.find((sym) => sym.name === "b");
136
- expect(b!.line).toBe(2);
137
- });
138
- });
139
-
140
- describe("generateDocs", () => {
141
- it("generates overview section", () => {
142
- const sources = [
143
- src("export function hello() {}", "src/a.ts"),
144
- src("export type Config = {}", "src/b.ts"),
145
- ];
146
- const docs = generateDocs(sources, ["next.config.js"]);
147
- expect(docs.sections.some((s) => s.heading === "Overview")).toBe(true);
148
- expect(docs.sections.some((s) => s.heading === "Functions")).toBe(true);
149
- });
150
-
151
- it("sets project type from signals", () => {
152
- const docs = generateDocs([], ["vite.config.ts", "src/main.tsx"]);
153
- expect(docs.projectType).toBe("react_vite");
154
- });
155
-
156
- it("lists exported symbols", () => {
157
- const sources = [src("export function fn() {}")];
158
- const docs = generateDocs(sources, []);
159
- expect(docs.symbols.length).toBeGreaterThan(0);
160
- });
161
-
162
- it("includes exported functions in sections", () => {
163
- const sources = [src("export function publicFn() {}")];
164
- const docs = generateDocs(sources, []);
165
- const fnSection = docs.sections.find((s) => s.heading === "Functions");
166
- expect(fnSection!.content).toContain("publicFn");
167
- });
168
- });
@@ -1,357 +0,0 @@
1
- /// <reference types="node" />
2
- /**
3
- * Durable Review Acceptance Tests
4
- *
5
- * Tests per wiki/pi-durable-reviewer-minimax-plan.md acceptance criteria.
6
- */
7
-
8
- import { describe, it, before, after, mock } from "node:test";
9
- import assert from "node:assert";
10
- import { randomUUID } from "node:crypto";
11
- import { existsSync, mkdirSync, unlinkSync, rmdirSync, writeFileSync, readFileSync } from "node:fs";
12
- import { join } from "node:path";
13
- import { validateAndHashRequest, hashWorkspaceKey, getWorkspaceDir } from "../dist/service.js";
14
- import { validateReviewRequest } from "../dist/types.js";
15
- import {
16
- tryAcquireOwnership,
17
- releaseOwnership,
18
- startWorker,
19
- stopWorker,
20
- checkWorkerReady,
21
- } from "../dist/worker.js";
22
- import { handleReviewRequest, cancelJob, getJobStatus } from "../dist/worker.js";
23
-
24
- // Test workspace path
25
- const TEST_WORKSPACE = "/tmp/durable-review-test-" + Date.now();
26
- const TEST_DB_DIR = join(process.env.HOME || "/tmp", ".pi-harness-runtime", "durable");
27
-
28
- /**
29
- * The storage of the worker is SQLite, which needs `node:sqlite`.
30
- *
31
- * Node has that module, Bun does not. Without it the worker cannot start, so
32
- * the tests that need a running worker are skipped with a reason instead of
33
- * failing with a module error.
34
- */
35
- const sqliteAvailable = await (async () => {
36
- try {
37
- await import("node:sqlite");
38
- return true;
39
- } catch {
40
- return false;
41
- }
42
- })();
43
-
44
- const SKIP_WITHOUT_SQLITE = sqliteAvailable
45
- ? false
46
- : "node:sqlite is not available in this runtime";
47
- const describeWorker = sqliteAvailable ? describe : describe.skip;
48
-
49
- describe("Acceptance Tests", () => {
50
- // Setup
51
- before(() => {
52
- mkdirSync(TEST_WORKSPACE, { recursive: true });
53
- });
54
-
55
- after(() => {
56
- // Cleanup test workspace
57
- try {
58
- const workspaceKey = hashWorkspaceKey(TEST_WORKSPACE);
59
- const testDir = getWorkspaceDir(workspaceKey);
60
- const lockPath = join(testDir, ".worker.lock");
61
- if (existsSync(lockPath)) unlinkSync(lockPath);
62
- } catch {
63
- // ignore cleanup errors
64
- }
65
- });
66
-
67
- // --- Feature Disabled ---
68
- describe("Feature disabled", () => {
69
- it("validateReviewRequest works without HARNESS_DURABLE_REVIEW flag", () => {
70
- const request = {
71
- requestId: "test-1",
72
- input: { workspacePath: TEST_WORKSPACE },
73
- };
74
- const validation = validateReviewRequest(request);
75
- assert.strictEqual(validation.valid, true);
76
- });
77
- });
78
-
79
- // --- Duplicate Admission ---
80
- describe("Duplicate admission", () => {
81
- it("same request returns same input hash", () => {
82
- const request1 = {
83
- requestId: "test-dup",
84
- input: { workspacePath: TEST_WORKSPACE, diff: "test diff" },
85
- };
86
- const request2 = {
87
- requestId: "test-dup",
88
- input: { workspacePath: TEST_WORKSPACE, diff: "test diff" },
89
- };
90
-
91
- const val1 = validateAndHashRequest(request1);
92
- const val2 = validateAndHashRequest(request2);
93
-
94
- assert.strictEqual(val1.valid, true);
95
- assert.strictEqual(val2.valid, true);
96
- assert.strictEqual(val1.inputHash, val2.inputHash);
97
- });
98
-
99
- it("different input returns different hash", () => {
100
- const request1 = {
101
- requestId: "test-1",
102
- input: { workspacePath: TEST_WORKSPACE, diff: "diff 1" },
103
- };
104
- const request2 = {
105
- requestId: "test-2",
106
- input: { workspacePath: TEST_WORKSPACE, diff: "diff 2" },
107
- };
108
-
109
- const val1 = validateAndHashRequest(request1);
110
- const val2 = validateAndHashRequest(request2);
111
-
112
- assert.strictEqual(val1.valid, true);
113
- assert.strictEqual(val2.valid, true);
114
- assert.notStrictEqual(val1.inputHash, val2.inputHash);
115
- });
116
- });
117
-
118
- // --- Ownership ---
119
- describe("Ownership race", () => {
120
- it("first worker acquires ownership", async () => {
121
- const workspaceKey = hashWorkspaceKey(TEST_WORKSPACE);
122
- const workerId1 = "worker-1-" + randomUUID().slice(0, 8);
123
-
124
- const result = await tryAcquireOwnership(workspaceKey, workerId1);
125
- assert.strictEqual(result.acquired, true);
126
-
127
- // Cleanup
128
- await releaseOwnership(workspaceKey, workerId1);
129
- });
130
-
131
- it("second worker cannot acquire if first holds lock", async () => {
132
- const workspaceKey = hashWorkspaceKey(TEST_WORKSPACE);
133
- const workerId1 = "worker-1-" + randomUUID().slice(0, 8);
134
- const workerId2 = "worker-2-" + randomUUID().slice(0, 8);
135
-
136
- // First acquires
137
- const result1 = await tryAcquireOwnership(workspaceKey, workerId1);
138
- assert.strictEqual(result1.acquired, true);
139
-
140
- // Second should fail
141
- const result2 = await tryAcquireOwnership(workspaceKey, workerId2);
142
- assert.strictEqual(result2.acquired, false);
143
- assert.ok(result2.existingOwner);
144
-
145
- // Cleanup
146
- await releaseOwnership(workspaceKey, workerId1);
147
- });
148
-
149
- it("stale owner is recoverable", async () => {
150
- const workspaceKey = hashWorkspaceKey(TEST_WORKSPACE);
151
- const workerId1 = "stale-worker-" + randomUUID().slice(0, 8);
152
- const workerId2 = "new-worker-" + randomUUID().slice(0, 8);
153
-
154
- // First acquires
155
- const result1 = await tryAcquireOwnership(workspaceKey, workerId1);
156
- assert.strictEqual(result1.acquired, true);
157
-
158
- // Simulate stale lock by directly writing old timestamp
159
- const lockPath = join(getWorkspaceDir(workspaceKey), ".worker.lock");
160
- const staleLock = {
161
- workerId: workerId1,
162
- pid: 99999,
163
- startedAt: Date.now() - 120_000, // 2 minutes ago
164
- };
165
- writeFileSync(lockPath, JSON.stringify(staleLock));
166
-
167
- // New worker should be able to acquire
168
- const result2 = await tryAcquireOwnership(workspaceKey, workerId2);
169
- assert.strictEqual(result2.acquired, true);
170
-
171
- // Cleanup
172
- await releaseOwnership(workspaceKey, workerId2);
173
- });
174
- });
175
-
176
- // --- Worker Lifecycle ---
177
- describeWorker("Worker lifecycle", () => {
178
- it("startWorker succeeds", async () => {
179
- const result = await startWorker(TEST_WORKSPACE);
180
- assert.strictEqual(result.success, true);
181
- assert.ok(result.workerId);
182
- assert.ok(result.workspaceKey);
183
- });
184
-
185
- it("checkWorkerReady returns ready", async () => {
186
- const ready = await checkWorkerReady();
187
- assert.strictEqual(ready.ready, true);
188
- assert.ok(ready.workerId);
189
- });
190
-
191
- it("stopWorker succeeds", async () => {
192
- await stopWorker();
193
- const ready = await checkWorkerReady();
194
- assert.strictEqual(ready.ready, false);
195
- });
196
- });
197
-
198
- // --- Request Handling ---
199
- describeWorker("Request handling", () => {
200
- before(async () => {
201
- await startWorker(TEST_WORKSPACE);
202
- });
203
-
204
- after(async () => {
205
- await stopWorker();
206
- });
207
-
208
- it("handleReviewRequest creates job", async () => {
209
- const request = {
210
- requestId: "test-review-" + randomUUID().slice(0, 8),
211
- input: { workspacePath: TEST_WORKSPACE },
212
- };
213
-
214
- const result = await handleReviewRequest(request);
215
- assert.ok(result.jobId);
216
- assert.strictEqual(result.status.status, "queued");
217
- });
218
-
219
- it("handleReviewRequest rejects invalid request", async () => {
220
- const invalidRequest = {
221
- requestId: "",
222
- input: { workspacePath: TEST_WORKSPACE },
223
- };
224
-
225
- await assert.rejects(
226
- async () => handleReviewRequest(invalidRequest as any),
227
- /requestId is required/
228
- );
229
- });
230
-
231
- it("getJobStatus returns null for unknown job", async () => {
232
- const status = await getJobStatus("unknown-job-id");
233
- assert.strictEqual(status, null);
234
- });
235
-
236
- it("cancelJob returns false for unknown job", async () => {
237
- const cancelled = await cancelJob("unknown-job-id");
238
- assert.strictEqual(cancelled, false);
239
- });
240
- });
241
-
242
- // --- Input Stability ---
243
- describe("Input stability", () => {
244
- it("validateAndHashRequest produces stable hash", () => {
245
- const request = {
246
- requestId: "test-hash",
247
- input: { workspacePath: TEST_WORKSPACE, diff: "stable diff content" },
248
- };
249
-
250
- const result1 = validateAndHashRequest(request);
251
- const result2 = validateAndHashRequest(request);
252
-
253
- assert.strictEqual(result1.inputHash, result2.inputHash);
254
- });
255
-
256
- it("different content produces different hash", () => {
257
- const request1 = {
258
- requestId: "test",
259
- input: { workspacePath: TEST_WORKSPACE, diff: "content A" },
260
- };
261
- const request2 = {
262
- requestId: "test",
263
- input: { workspacePath: TEST_WORKSPACE, diff: "content B" },
264
- };
265
-
266
- const result1 = validateAndHashRequest(request1);
267
- const result2 = validateAndHashRequest(request2);
268
-
269
- assert.notStrictEqual(result1.inputHash, result2.inputHash);
270
- });
271
- });
272
-
273
- // --- Workspace Path ---
274
- describe("Workspace path handling", () => {
275
- it("hashWorkspaceKey produces consistent hash", () => {
276
- const hash1 = hashWorkspaceKey("/some/path");
277
- const hash2 = hashWorkspaceKey("/some/path");
278
- assert.strictEqual(hash1, hash2);
279
- });
280
-
281
- it("different paths produce different hashes", () => {
282
- const hash1 = hashWorkspaceKey("/path/a");
283
- const hash2 = hashWorkspaceKey("/path/b");
284
- assert.notStrictEqual(hash1, hash2);
285
- });
286
-
287
- it("getWorkspaceDir creates directory", () => {
288
- const workspaceKey = hashWorkspaceKey(TEST_WORKSPACE);
289
- const dir = getWorkspaceDir(workspaceKey);
290
- assert.ok(existsSync(dir));
291
- });
292
- });
293
-
294
- // --- Validation ---
295
- describe("Request validation", () => {
296
- it("rejects missing requestId", () => {
297
- const result = validateReviewRequest({
298
- requestId: "",
299
- input: { workspacePath: TEST_WORKSPACE },
300
- });
301
- assert.strictEqual(result.valid, false);
302
- assert.ok(result.error?.includes("requestId"));
303
- });
304
-
305
- it("rejects missing workspacePath", () => {
306
- const result = validateReviewRequest({
307
- requestId: "test",
308
- input: { workspacePath: "" },
309
- });
310
- assert.strictEqual(result.valid, false);
311
- assert.ok(result.error?.includes("workspacePath"));
312
- });
313
-
314
- it("accepts valid request", () => {
315
- const result = validateReviewRequest({
316
- requestId: "test",
317
- input: { workspacePath: TEST_WORKSPACE },
318
- });
319
- assert.strictEqual(result.valid, true);
320
- assert.ok(result.request);
321
- });
322
-
323
- it("applies default maxPasses and maxToolCalls", () => {
324
- const result = validateReviewRequest({
325
- requestId: "test",
326
- input: { workspacePath: TEST_WORKSPACE },
327
- });
328
- assert.strictEqual(result.valid, true);
329
- assert.strictEqual(result.request?.maxPasses, 5);
330
- assert.strictEqual(result.request?.maxToolCalls, 100);
331
- });
332
-
333
- it("respects provided maxPasses and maxToolCalls", () => {
334
- const result = validateReviewRequest({
335
- requestId: "test",
336
- input: { workspacePath: TEST_WORKSPACE },
337
- maxPasses: 10,
338
- maxToolCalls: 200,
339
- });
340
- assert.strictEqual(result.valid, true);
341
- assert.strictEqual(result.request?.maxPasses, 10);
342
- assert.strictEqual(result.request?.maxToolCalls, 200);
343
- });
344
- });
345
-
346
- // --- Storage Failure ---
347
- describe("Storage failure handling", () => {
348
- it("validateAndHashRequest handles missing workspace path gracefully", () => {
349
- const result = validateAndHashRequest({
350
- requestId: "test",
351
- input: { workspacePath: "/nonexistent/path/that/cannot/exist" },
352
- });
353
- assert.strictEqual(result.valid, true); // Validation passes, hash is computed
354
- assert.ok(result.workspaceKey);
355
- });
356
- });
357
- });
@@ -1,107 +0,0 @@
1
- /// <reference types="node" />
2
- /**
3
- * SQLite Smoke Test
4
- *
5
- * Verifies SQLite storage works correctly with Node's built-in sqlite.
6
- *
7
- * The storage needs `node:sqlite`. Node has that module, Bun does not, so
8
- * the tests are skipped with a reason where the module is missing.
9
- */
10
-
11
- import { describe, it, before, after } from "node:test";
12
- import assert from "node:assert";
13
- import { BACKGROUND_CONTEXT } from "@earendil-works/chord/context";
14
- import { join } from "node:path";
15
- import { mkdirSync, unlinkSync, existsSync } from "node:fs";
16
-
17
- const TEST_DB_PATH = join(process.env.HOME || "/tmp", ".pi-harness-runtime", "test", "smoke.sqlite");
18
-
19
- /** Whether this runtime has the SQLite module of Node. */
20
- const sqliteAvailable = await (async () => {
21
- try {
22
- await import("node:sqlite");
23
- return true;
24
- } catch {
25
- return false;
26
- }
27
- })();
28
-
29
- const SKIP_WITHOUT_SQLITE = sqliteAvailable
30
- ? false
31
- : "node:sqlite is not available in this runtime";
32
- const itSqlite = sqliteAvailable ? it : it.skip;
33
-
34
- /** Open the storage of the test database. */
35
- async function openStorage(): Promise<{
36
- close: (ctx: unknown) => Promise<void>;
37
- }> {
38
- const { openNodeSqliteStorage } = await import(
39
- "@earendil-works/pi-durable/storage/sqlite/node"
40
- );
41
- return (await openNodeSqliteStorage(TEST_DB_PATH)) as {
42
- close: (ctx: unknown) => Promise<void>;
43
- };
44
- }
45
-
46
- describe("SQLite Smoke Test", () => {
47
- before(() => {
48
- // Ensure directory exists
49
- const dir = TEST_DB_PATH.replace(/\/[^/]+$/, "");
50
- mkdirSync(dir, { recursive: true });
51
- // Clean up any existing test db
52
- if (existsSync(TEST_DB_PATH)) {
53
- try {
54
- unlinkSync(TEST_DB_PATH);
55
- } catch {
56
- // ignore
57
- }
58
- }
59
- });
60
-
61
- after(() => {
62
- // Cleanup
63
- if (existsSync(TEST_DB_PATH)) {
64
- try {
65
- unlinkSync(TEST_DB_PATH);
66
- } catch {
67
- // ignore
68
- }
69
- }
70
- });
71
-
72
- itSqlite("opens SQLite storage", { skip: SKIP_WITHOUT_SQLITE }, async () => {
73
- const storage = await openStorage();
74
- assert.ok(storage, "Storage should be defined");
75
- await storage.close(BACKGROUND_CONTEXT);
76
- });
77
-
78
- itSqlite(
79
- "creates and reopens database",
80
- { skip: SKIP_WITHOUT_SQLITE },
81
- async () => {
82
- // First open
83
- const storage1 = await openStorage();
84
- await storage1.close(BACKGROUND_CONTEXT);
85
-
86
- // Second open - should work
87
- const storage2 = await openStorage();
88
- assert.ok(storage2, "Storage should be reopened");
89
- await storage2.close(BACKGROUND_CONTEXT);
90
- },
91
- );
92
-
93
- itSqlite(
94
- "persists data across reopen",
95
- { skip: SKIP_WITHOUT_SQLITE },
96
- async () => {
97
- // Open and write
98
- const storage1 = await openStorage();
99
- await storage1.close(BACKGROUND_CONTEXT);
100
-
101
- // Reopen and verify
102
- const storage2 = await openStorage();
103
- assert.ok(storage2, "Storage should be reopened with data");
104
- await storage2.close(BACKGROUND_CONTEXT);
105
- },
106
- );
107
- });