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,250 +0,0 @@
1
- /**
2
- * Tests for the sanitization of a skill for the shared collection.
3
- *
4
- * The collection is shared, so the client names of a user must not travel
5
- * into it. The rules used to live in `scripts/sync-to-qdrant.ts` - the
6
- * only writer that could reach them. The runtime registry writes into the
7
- * same collection, so it needs them too.
8
- *
9
- * The rules of the clients are **not** in this repository: it is public,
10
- * and a list of client names in it is a list of client names in the world.
11
- * They live in a local file, so the tests use a fixture with made up
12
- * names and pass the rules in. A test must never read the rules of the
13
- * machine it runs on - that would make the result of the test depend on
14
- * the machine.
15
- */
16
-
17
- import { afterEach, beforeEach, describe, expect, test } from "bun:test";
18
- import { mkdtempSync, writeFileSync } from "node:fs";
19
- import { tmpdir } from "node:os";
20
- import { join } from "node:path";
21
- import { fileURLToPath } from "node:url";
22
-
23
- import { sanitizeText, skillPointName } from "../src/sanitize.js";
24
- import {
25
- loadSanitizationRules,
26
- resetSanitizationRulesCache,
27
- sanitizationStatus,
28
- } from "../src/sanitize-rules.js";
29
- import { skillPointPayload } from "../src/vector-schema.js";
30
-
31
- const FIXTURE = fileURLToPath(new URL("./fixtures/sanitization.json", import.meta.url));
32
- const MISSING = join(tmpdir(), "pi-harness-no-such-sanitization-file.json");
33
-
34
- const originalEnv = process.env.PI_SKILL_SANITIZATION_FILE;
35
-
36
- /** The rules of the fixture, as the mechanism reads them. */
37
- function fixtureRules() {
38
- resetSanitizationRulesCache();
39
- process.env.PI_SKILL_SANITIZATION_FILE = FIXTURE;
40
- const set = loadSanitizationRules();
41
- resetSanitizationRulesCache();
42
- return set;
43
- }
44
-
45
- beforeEach(() => {
46
- resetSanitizationRulesCache();
47
- process.env.PI_SKILL_SANITIZATION_FILE = FIXTURE;
48
- });
49
-
50
- afterEach(() => {
51
- resetSanitizationRulesCache();
52
- if (originalEnv === undefined) delete process.env.PI_SKILL_SANITIZATION_FILE;
53
- else process.env.PI_SKILL_SANITIZATION_FILE = originalEnv;
54
- });
55
-
56
- describe("the sanitization of a text", () => {
57
- test("the name of a client is replaced", () => {
58
- const rules = fixtureRules();
59
- expect(sanitizeText("the acmecorp workflow", rules)).toBe(
60
- "the [Client A] workflow",
61
- );
62
- expect(sanitizeText("for globex", rules)).toBe("for [Client B]");
63
- expect(sanitizeText("initech step", rules)).toBe("[Insurance Project] step");
64
- });
65
-
66
- test("the name of a client is replaced in any case", () => {
67
- const rules = fixtureRules();
68
- expect(sanitizeText("ACMEcorp and Acmecorp", rules)).toBe(
69
- "[Client A] and [Client A]",
70
- );
71
- });
72
-
73
- test("a text without a client name stays the same", () => {
74
- const rules = fixtureRules();
75
- expect(sanitizeText("a plain skill", rules)).toBe("a plain skill");
76
- });
77
-
78
- test("the generic phrases are replaced", () => {
79
- // The generic rules hold for every installation, so they work
80
- // without a local file.
81
- process.env.PI_SKILL_SANITIZATION_FILE = MISSING;
82
- resetSanitizationRulesCache();
83
- expect(sanitizeText("Company Name")).toBe("[Client Name]");
84
- expect(sanitizeText("your company")).toBe("[Client]");
85
- expect(sanitizeText("our client")).toBe("[Client]");
86
- });
87
-
88
- test("a client name inside an identifier is replaced", () => {
89
- // The name of a client rarely stands alone. A word boundary would
90
- // miss every one of these - and an underscore is a word character,
91
- // so a boundary never follows one.
92
- const rules = fixtureRules();
93
- expect(sanitizeText("acmecorp_pharma", rules)).toBe("[Client A]_pharma");
94
- expect(sanitizeText("th_globex_erp_chart.json", rules)).toBe(
95
- "th_[Client B]_erp_chart.json",
96
- );
97
- expect(sanitizeText("apps/acmecorp_pharma/setup", rules)).toBe(
98
- "apps/[Client A]_pharma/setup",
99
- );
100
- });
101
-
102
- test("a client name in a sentence is replaced", () => {
103
- const rules = fixtureRules();
104
- expect(sanitizeText("integrated with Globex", rules)).toBe(
105
- "integrated with [Client B]",
106
- );
107
- expect(sanitizeText("Initech secrets", rules)).toBe(
108
- "[Insurance Project] secrets",
109
- );
110
- });
111
- });
112
-
113
- describe("the name of a skill in the shared collection", () => {
114
- test("a name of the map is renamed", () => {
115
- const rules = fixtureRules();
116
- expect(skillPointName("acmecorp-pe-approval-workflow", rules)).toBe(
117
- "client-a-pe-approval-workflow",
118
- );
119
- expect(skillPointName("initech-step5-slot-filter", rules)).toBe(
120
- "insurance-project-step-filter",
121
- );
122
- });
123
-
124
- test("a name without a client name stays the same", () => {
125
- const rules = fixtureRules();
126
- expect(skillPointName("code-review", rules)).toBe("code-review");
127
- });
128
-
129
- test("the name never carries a client name", () => {
130
- const rules = fixtureRules();
131
- for (const name of [
132
- "acmecorp-pe-approval-workflow",
133
- "initech-step5-slot-filter",
134
- "globex-channel",
135
- ]) {
136
- expect(skillPointName(name, rules)).not.toMatch(
137
- /acmecorp|initech|globex/i,
138
- );
139
- }
140
- });
141
-
142
- test("the name is a valid skill name", () => {
143
- // The name of a point is the id of the skill that a search returns,
144
- // so it has to be a name that a skill may carry.
145
- const NAME = /^[a-z0-9]+(-[a-z0-9]+)*$/;
146
- const rules = fixtureRules();
147
- for (const name of [
148
- "acmecorp-pe-approval-workflow",
149
- "globex-channel",
150
- "initech-step5-slot-filter",
151
- "code-review",
152
- ]) {
153
- expect(skillPointName(name, rules)).toMatch(NAME);
154
- }
155
- });
156
-
157
- test("a name that needs no sanitization stays the same", () => {
158
- const rules = fixtureRules();
159
- expect(skillPointName("code-review", rules)).toBe("code-review");
160
- expect(skillPointName("frappe-doctype-field-order", rules)).toBe(
161
- "frappe-doctype-field-order",
162
- );
163
- });
164
- });
165
-
166
- describe("the rules of the installation", () => {
167
- test("a missing file leaves the generic rules", () => {
168
- process.env.PI_SKILL_SANITIZATION_FILE = MISSING;
169
- resetSanitizationRulesCache();
170
- const status = sanitizationStatus();
171
- expect(status.configured).toBe(false);
172
- expect(status.ruleCount).toBeGreaterThan(0);
173
- });
174
-
175
- test("a broken file is reported and does not take the rules down", () => {
176
- const dir = mkdtempSync(join(tmpdir(), "pi-harness-sanitization-"));
177
- const path = join(dir, "rules.json");
178
- writeFileSync(path, "{ not json");
179
- process.env.PI_SKILL_SANITIZATION_FILE = path;
180
- resetSanitizationRulesCache();
181
- const status = sanitizationStatus();
182
- expect(status.configured).toBe(false);
183
- expect(status.error).toContain("not valid JSON");
184
- // The generic rules still hold.
185
- expect(sanitizeText("Company Name")).toBe("[Client Name]");
186
- });
187
-
188
- test("a broken pattern does not take the other rules down", () => {
189
- const dir = mkdtempSync(join(tmpdir(), "pi-harness-sanitization-"));
190
- const path = join(dir, "rules.json");
191
- writeFileSync(
192
- path,
193
- JSON.stringify({
194
- rules: [
195
- { pattern: "acmecorp", replacement: "[Client A]" },
196
- { pattern: "([unclosed", replacement: "[Broken]" },
197
- { pattern: "globex", replacement: "[Client B]" },
198
- ],
199
- }),
200
- );
201
- process.env.PI_SKILL_SANITIZATION_FILE = path;
202
- resetSanitizationRulesCache();
203
- const rules = loadSanitizationRules();
204
- expect(sanitizeText("acmecorp and globex", rules)).toBe(
205
- "[Client A] and [Client B]",
206
- );
207
- });
208
-
209
- test("the local file is read once", () => {
210
- process.env.PI_SKILL_SANITIZATION_FILE = FIXTURE;
211
- resetSanitizationRulesCache();
212
- const first = loadSanitizationRules();
213
- const second = loadSanitizationRules();
214
- expect(second).toBe(first);
215
- });
216
- });
217
-
218
- describe("the payload of a point is sanitized", () => {
219
- test("the client names of the body do not travel into the collection", () => {
220
- const rules = fixtureRules();
221
- const payload = skillPointPayload(
222
- {
223
- name: "acmecorp-pe-approval-workflow",
224
- description: "the workflow of acmecorp",
225
- body: "the approval of acmecorp for the client",
226
- },
227
- rules,
228
- );
229
-
230
- expect(payload.name).toBe("client-a-pe-approval-workflow");
231
- expect(payload.description).not.toMatch(/acmecorp/i);
232
- expect(payload.body).not.toMatch(/acmecorp/i);
233
- expect(payload.text).not.toMatch(/acmecorp/i);
234
- });
235
-
236
- test("the text is built from the sanitized parts", () => {
237
- const rules = fixtureRules();
238
- const payload = skillPointPayload(
239
- {
240
- name: "acmecorp-pe-approval-workflow",
241
- description: "the workflow",
242
- body: "the body",
243
- },
244
- rules,
245
- );
246
-
247
- expect(payload.text).toContain("client-a-pe-approval-workflow");
248
- expect(payload.text).not.toContain("acmecorp-pe-approval-workflow");
249
- });
250
- });
@@ -1,205 +0,0 @@
1
- /**
2
- * Regression tests for the vector indexing of the skill registry.
3
- *
4
- * The registry used to start one embedding request per registered skill, all
5
- * at the same time. A registry with a few hundred skills opened a few hundred
6
- * connections at once, which starved every other request of the process.
7
- *
8
- * These tests use an injected indexer, so they neither reach the network nor
9
- * touch a process-global module.
10
- */
11
-
12
- import { describe, expect, test } from "bun:test";
13
-
14
- import {
15
- createSkillRegistry,
16
- type SkillVectorIndexer,
17
- type SkillVectorPoint,
18
- } from "../src/loader.js";
19
- import type { Skill } from "../src/types.js";
20
-
21
- /** An indexer that counts the requests it receives. */
22
- class CountingIndexer implements SkillVectorIndexer {
23
- /** The number of texts of every embed call. */
24
- readonly embedCalls: string[][] = [];
25
- /** The points of every upsert call. */
26
- readonly upsertCalls: SkillVectorPoint[][] = [];
27
- /** The number of embed calls that were in flight at the same time. */
28
- maxConcurrentEmbeds = 0;
29
- private inFlight = 0;
30
- /** When set, every embed call waits for this gate. */
31
- gate: { promise: Promise<void>; release: () => void } | null = null;
32
-
33
- async embed(texts: string[]): Promise<number[][]> {
34
- this.inFlight += 1;
35
- this.maxConcurrentEmbeds = Math.max(this.maxConcurrentEmbeds, this.inFlight);
36
- this.embedCalls.push(texts);
37
- try {
38
- if (this.gate) await this.gate.promise;
39
- return texts.map((text) => [text.length, 1, 2]);
40
- } finally {
41
- this.inFlight -= 1;
42
- }
43
- }
44
-
45
- async upsert(points: SkillVectorPoint[]): Promise<void> {
46
- this.upsertCalls.push(points);
47
- }
48
-
49
- /** The number of texts that were embedded. */
50
- get embeddedCount(): number {
51
- return this.embedCalls.reduce((total, texts) => total + texts.length, 0);
52
- }
53
- }
54
-
55
- /** A skill with the given id and body. */
56
- function makeSkill(id: string, body = `body of ${id}`): Skill {
57
- return {
58
- id,
59
- path: `/tmp/skills/${id}`,
60
- frontmatter: {
61
- name: id,
62
- description: `description of ${id}`,
63
- version: "1.0.0",
64
- },
65
- body,
66
- references: [],
67
- examples: [],
68
- metadata: {},
69
- loaded: false,
70
- };
71
- }
72
-
73
- /** Wait until the registry has no queued skill left. */
74
- async function settle(registry: { isIndexing(): boolean }): Promise<void> {
75
- for (let attempt = 0; attempt < 200 && registry.isIndexing(); attempt++) {
76
- await new Promise((resolve) => setTimeout(resolve, 5));
77
- }
78
- }
79
-
80
- describe("skill vector indexing", () => {
81
- test("one embedding request carries many skills", async () => {
82
- const indexer = new CountingIndexer();
83
- const registry = createSkillRegistry({ indexer });
84
-
85
- for (let i = 0; i < 100; i++) {
86
- registry.register(makeSkill(`skill-${i}`));
87
- }
88
- await settle(registry);
89
-
90
- expect(indexer.embeddedCount).toBe(100);
91
- expect(indexer.embedCalls.length).toBeLessThanOrEqual(4);
92
- expect(indexer.maxConcurrentEmbeds).toBe(1);
93
- expect(indexer.upsertCalls.length).toBe(indexer.embedCalls.length);
94
- });
95
-
96
- test("the number of requests does not grow with the number of skills", async () => {
97
- const small = new CountingIndexer();
98
- const smallRegistry = createSkillRegistry({ indexer: small, batchSize: 8 });
99
- for (let i = 0; i < 8; i++) smallRegistry.register(makeSkill(`small-${i}`));
100
- await settle(smallRegistry);
101
-
102
- const large = new CountingIndexer();
103
- const largeRegistry = createSkillRegistry({ indexer: large, batchSize: 8 });
104
- for (let i = 0; i < 80; i++) largeRegistry.register(makeSkill(`large-${i}`));
105
- await settle(largeRegistry);
106
-
107
- // Ten times the skills, ten times the requests - never ten times the
108
- // skills in a single request.
109
- expect(large.embedCalls.length).toBe(10);
110
- expect(large.embedCalls.length).toBe(small.embedCalls.length * 10);
111
- });
112
-
113
- test("only one embedding request is in flight at a time", async () => {
114
- const indexer = new CountingIndexer();
115
- const registry = createSkillRegistry({ indexer, batchSize: 4 });
116
-
117
- let release!: () => void;
118
- indexer.gate = {
119
- promise: new Promise<void>((resolve) => {
120
- release = resolve;
121
- }),
122
- release: () => {},
123
- };
124
-
125
- for (let i = 0; i < 40; i++) {
126
- registry.register(makeSkill(`gated-${i}`));
127
- }
128
- await new Promise((resolve) => setTimeout(resolve, 50));
129
-
130
- // The queue waits for the first batch, so no second request started.
131
- expect(indexer.embedCalls.length).toBe(1);
132
-
133
- indexer.gate.release = release;
134
- indexer.gate = null;
135
- release();
136
- await settle(registry);
137
-
138
- expect(indexer.embeddedCount).toBe(40);
139
- expect(indexer.maxConcurrentEmbeds).toBe(1);
140
- });
141
-
142
- test("a skill whose text did not change is not indexed again", async () => {
143
- const indexer = new CountingIndexer();
144
- const registry = createSkillRegistry({ indexer });
145
-
146
- registry.register(makeSkill("stable"));
147
- await settle(registry);
148
- expect(indexer.embeddedCount).toBe(1);
149
-
150
- // The same skill, registered again with the same text.
151
- registry.register(makeSkill("stable"));
152
- await settle(registry);
153
- expect(indexer.embeddedCount).toBe(1);
154
-
155
- // The same skill with a different body is indexed again.
156
- registry.register(makeSkill("stable", "a different body"));
157
- await settle(registry);
158
- expect(indexer.embeddedCount).toBe(2);
159
- });
160
-
161
- test("the points carry the vector of their skill", async () => {
162
- const indexer = new CountingIndexer();
163
- const registry = createSkillRegistry({ indexer, batchSize: 2 });
164
-
165
- registry.register(makeSkill("alpha"));
166
- registry.register(makeSkill("beta"));
167
- await settle(registry);
168
-
169
- const points = indexer.upsertCalls.flat();
170
- expect(points.length).toBe(2);
171
- expect(points.map((point) => point.payload.name).sort()).toEqual(["alpha", "beta"]);
172
- for (const point of points) {
173
- expect(point.vector.length).toBe(3);
174
- }
175
- });
176
-
177
- test("a registry without an index keeps no vectors", async () => {
178
- const registry = createSkillRegistry({ indexer: null });
179
-
180
- registry.register(makeSkill("unindexed"));
181
- await settle(registry);
182
-
183
- expect(registry.list().length).toBe(1);
184
- expect(registry.isQdrantFailed()).toBe(false);
185
- });
186
-
187
- test("a failing index does not stop the other skills", async () => {
188
- let calls = 0;
189
- const indexer: SkillVectorIndexer = {
190
- embed: async (texts: string[]) => {
191
- calls += 1;
192
- if (calls === 1) throw new Error("the index is unavailable");
193
- return texts.map(() => [1, 2, 3]);
194
- },
195
- upsert: async () => {},
196
- };
197
- const registry = createSkillRegistry({ indexer, batchSize: 2 });
198
-
199
- registry.register(makeSkill("first"));
200
- registry.register(makeSkill("second"));
201
- await settle(registry);
202
-
203
- expect(registry.list().length).toBe(2);
204
- });
205
- });
@@ -1,180 +0,0 @@
1
- /**
2
- * Regression tests for the point identity of the skill collection.
3
- *
4
- * Two writers fill the same collection: the runtime registry and
5
- * `scripts/sync-to-qdrant.ts`. They used to disagree about the identity of
6
- * a point - the runtime hashed the name of the skill, the script used a
7
- * running number. The same skill then existed twice, and a running number
8
- * could overwrite a point of an unrelated skill.
9
- *
10
- * The identity now comes from one shared place, and these tests hold it
11
- * there.
12
- */
13
-
14
- import { describe, expect, test } from "bun:test";
15
-
16
- import {
17
- createSkillRegistry,
18
- type SkillVectorIndexer,
19
- type SkillVectorPoint,
20
- } from "../src/loader.js";
21
- import {
22
- SKILL_PAYLOAD_BODY_LIMIT,
23
- SKILL_PAYLOAD_TEXT_LIMIT,
24
- skillPointPayload,
25
- skillQdrantPoint,
26
- stableHash,
27
- } from "../src/vector-schema.js";
28
- import type { Skill } from "../src/types.js";
29
-
30
- /** Wait until the registry has no index work left. */
31
- async function settle(registry: { isIndexing(): boolean }): Promise<void> {
32
- for (let attempt = 0; attempt < 200 && registry.isIndexing(); attempt++) {
33
- await new Promise((resolve) => setTimeout(resolve, 5));
34
- }
35
- }
36
-
37
- /** A skill with the given id and body. */
38
- function makeSkill(id: string, body = `body of ${id}`): Skill {
39
- return {
40
- id,
41
- path: `/tmp/skills/${id}`,
42
- frontmatter: {
43
- name: id,
44
- description: `the ${id} skill`,
45
- },
46
- body,
47
- metadata: {} as Skill["metadata"],
48
- } as Skill;
49
- }
50
-
51
- /** An indexer that keeps the points it receives. */
52
- class RecordingIndexer implements SkillVectorIndexer {
53
- readonly upsertCalls: SkillVectorPoint[][] = [];
54
-
55
- async embed(texts: string[]): Promise<number[][]> {
56
- return texts.map((text) => [text.length, 1, 2]);
57
- }
58
-
59
- async upsert(points: SkillVectorPoint[]): Promise<void> {
60
- this.upsertCalls.push(points);
61
- }
62
- }
63
-
64
- describe("the identity of a skill point", () => {
65
- test("the id of the point is the hash of the name in the payload", () => {
66
- const payload = skillPointPayload({
67
- name: "a-skill",
68
- description: "does something",
69
- body: "the body",
70
- });
71
- const point = skillQdrantPoint(payload);
72
-
73
- expect(point.id).toBe(stableHash(payload.name));
74
- });
75
-
76
- test("the same name always addresses the same point", () => {
77
- const first = skillQdrantPoint(
78
- skillPointPayload({ name: "a-skill", description: "one", body: "one" }),
79
- );
80
- const second = skillQdrantPoint(
81
- skillPointPayload({ name: "a-skill", description: "two", body: "two" }),
82
- );
83
-
84
- // The content may change, the identity of the point may not.
85
- expect(second.id).toBe(first.id);
86
- });
87
-
88
- test("different names address different points", () => {
89
- const first = skillQdrantPoint(
90
- skillPointPayload({ name: "a-skill", description: "d", body: "b" }),
91
- );
92
- const second = skillQdrantPoint(
93
- skillPointPayload({ name: "b-skill", description: "d", body: "b" }),
94
- );
95
-
96
- expect(second.id).not.toBe(first.id);
97
- });
98
-
99
- test("the payload carries the shared fields and nothing else", () => {
100
- const payload = skillPointPayload({
101
- name: "a-skill",
102
- title: "A Skill",
103
- description: "does something",
104
- body: "the body",
105
- });
106
-
107
- expect(Object.keys(payload).sort()).toEqual([
108
- "body",
109
- "description",
110
- "name",
111
- "text",
112
- ]);
113
- });
114
-
115
- test("the payload and the text are truncated", () => {
116
- const payload = skillPointPayload({
117
- name: "a-skill",
118
- description: "d",
119
- body: "x".repeat(SKILL_PAYLOAD_BODY_LIMIT + 500),
120
- });
121
-
122
- expect(payload.body.length).toBe(SKILL_PAYLOAD_BODY_LIMIT);
123
- expect(payload.text.length).toBeLessThanOrEqual(
124
- SKILL_PAYLOAD_TEXT_LIMIT + payload.name.length + payload.description.length + 10,
125
- );
126
- });
127
-
128
- test("the title is part of the text when it differs from the name", () => {
129
- const withTitle = skillPointPayload({
130
- name: "a-skill",
131
- title: "A Human Title",
132
- description: "d",
133
- body: "b",
134
- });
135
- const withoutTitle = skillPointPayload({
136
- name: "a-skill",
137
- description: "d",
138
- body: "b",
139
- });
140
-
141
- // The title is treated like the name: it is sanitized and it is
142
- // brought into the shape of a skill name.
143
- expect(withTitle.text).toContain("a-human-title");
144
- expect(withoutTitle.text).not.toContain("a-human-title");
145
- });
146
-
147
- test("a title that is the name is not repeated in the text", () => {
148
- const payload = skillPointPayload({
149
- name: "a-skill",
150
- title: "a-skill",
151
- description: "d",
152
- body: "b",
153
- });
154
-
155
- expect(payload.text.match(/a-skill/g)?.length).toBe(1);
156
- });
157
- });
158
-
159
- describe("the runtime writes the points of the shared schema", () => {
160
- test("the indexed point carries the shared payload and id", async () => {
161
- const indexer = new RecordingIndexer();
162
- const registry = createSkillRegistry({ indexer });
163
-
164
- registry.register(makeSkill("alpha"));
165
- await settle(registry);
166
-
167
- const points = indexer.upsertCalls.flat();
168
- expect(points.length).toBe(1);
169
-
170
- const point = points[0];
171
- expect(point.id).toBe(stableHash(point.payload.name));
172
- expect(point.payload.name).toBe("alpha");
173
- expect(Object.keys(point.payload).sort()).toEqual([
174
- "body",
175
- "description",
176
- "name",
177
- "text",
178
- ]);
179
- });
180
- });