gentle-pi 4.7.0 → 4.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (365) hide show
  1. package/README.md +55 -44
  2. package/assets/agents/gentle-ai-explore.md +3 -3
  3. package/assets/agents/gentle-ai-verify.md +20 -6
  4. package/assets/agents/gentle-ai-worker.md +6 -6
  5. package/assets/agents/jd-judge-a.md +1 -3
  6. package/assets/agents/jd-judge-b.md +1 -3
  7. package/assets/agents/review-readability.md +1 -5
  8. package/assets/agents/review-reliability.md +1 -5
  9. package/assets/agents/review-resilience.md +1 -5
  10. package/assets/agents/review-risk.md +1 -5
  11. package/assets/design-canvas/canvas-api.js +45 -0
  12. package/assets/design-canvas/canvas-boards.js +456 -0
  13. package/assets/design-canvas/canvas-boot.js +217 -0
  14. package/assets/design-canvas/canvas-checks.js +491 -0
  15. package/assets/design-canvas/canvas-comments.js +315 -0
  16. package/assets/design-canvas/canvas-compare.js +159 -0
  17. package/assets/design-canvas/canvas-events.js +75 -0
  18. package/assets/design-canvas/canvas-export.js +393 -0
  19. package/assets/design-canvas/canvas-focus.js +203 -0
  20. package/assets/design-canvas/canvas-handoffs.js +150 -0
  21. package/assets/design-canvas/canvas-i18n-es.js +392 -0
  22. package/assets/design-canvas/canvas-i18n.js +108 -0
  23. package/assets/design-canvas/canvas-layout.js +526 -0
  24. package/assets/design-canvas/canvas-menu.js +213 -0
  25. package/assets/design-canvas/canvas-messages.js +86 -0
  26. package/assets/design-canvas/canvas-minimap.js +163 -0
  27. package/assets/design-canvas/canvas-parts.js +401 -0
  28. package/assets/design-canvas/canvas-popover.js +234 -0
  29. package/assets/design-canvas/canvas-rail.js +348 -0
  30. package/assets/design-canvas/canvas-sizes.js +524 -0
  31. package/assets/design-canvas/canvas-store.js +164 -0
  32. package/assets/design-canvas/canvas-tokens.js +674 -0
  33. package/assets/design-canvas/canvas-ui.js +24 -0
  34. package/assets/design-canvas/canvas-view.js +184 -0
  35. package/assets/design-canvas/canvas.css +746 -15
  36. package/assets/design-canvas/canvas.js +2 -1506
  37. package/assets/design-canvas/index.html +117 -36
  38. package/assets/design-canvas/inspector.js +546 -16
  39. package/assets/install-wizard/wizard.js +5 -1
  40. package/assets/migrations/agent-body-history.json +24 -0
  41. package/assets/orchestrator-delegation-reference.md +8 -14
  42. package/assets/orchestrator-delegation.md +4 -4
  43. package/assets/orchestrator-full-delegation-card.md +4 -5
  44. package/assets/orchestrator-full-delegation.md +8 -8
  45. package/assets/orchestrator-memory.md +2 -2
  46. package/assets/orchestrator-prompts.md +1 -1
  47. package/assets/orchestrator-quota-recovery.md +5 -0
  48. package/assets/orchestrator-skills.md +13 -12
  49. package/assets/orchestrator-tracking.md +10 -14
  50. package/assets/orchestrator-verification.md +10 -8
  51. package/assets/orchestrator-writer.md +4 -4
  52. package/assets/orchestrator.md +18 -22
  53. package/bin/gentle-shell.mjs +128 -9
  54. package/contracts/review-provider-contract-mirror/provider-contract.lock.json +8 -9
  55. package/contracts/review-provider-contract-mirror/{v1.4.0 → v1.5.0}/bundle/manifest.json +3 -3
  56. package/contracts/review-provider-contract-mirror/{v1.4.0 → v1.5.0}/bundle/orchestration/pi.md +1 -0
  57. package/contracts/review-provider-contract-mirror/{v1.4.0 → v1.5.0}/bundle/routing/pi.md +6 -6
  58. package/contracts/review-provider-contract-mirror/{v1.4.0 → v1.5.0}/generated/provider-capabilities.baseline.json +3 -3
  59. package/contracts/review-provider-contract-mirror/{v1.4.0 → v1.5.0}/generated/provider-roles.baseline.json +1 -1
  60. package/docs/assets/brand/sponsor-banner.svg +60 -0
  61. package/docs/bundled-install.md +14 -6
  62. package/docs/delegated-verification.md +18 -2
  63. package/docs/desktop-rpc.md +1253 -0
  64. package/docs/gentle-agents-activity.md +26 -0
  65. package/docs/gentle-shell.md +39 -16
  66. package/docs/install-wizard.md +30 -21
  67. package/docs/odd-preparation-continuity.md +24 -0
  68. package/docs/permission-modes.md +9 -1
  69. package/docs/prompt-budget.md +12 -0
  70. package/docs/rdd-odd-friction-triage-2026-11-07.md +57 -0
  71. package/docs/readme-reference.md +76 -24
  72. package/docs/review-coordinator.md +29 -9
  73. package/docs/review-delivery-preflight.md +22 -0
  74. package/docs/work-continuity.md +11 -1
  75. package/extensions/ask-user-question.ts +2 -2
  76. package/extensions/child-context.ts +21 -7
  77. package/extensions/gentle-agents.ts +234 -33
  78. package/extensions/gentle-ai.ts +576 -135
  79. package/extensions/gentle-design.ts +69 -3
  80. package/extensions/gentle-desktop-rpc.ts +143 -0
  81. package/extensions/gentle-guide.ts +3 -0
  82. package/extensions/gentle-shell.ts +105 -52
  83. package/extensions/gentle-todo.ts +48 -25
  84. package/extensions/skill-registry.ts +248 -223
  85. package/lib/agent-assets.ts +30 -6
  86. package/lib/agent-tool-overlay.ts +117 -0
  87. package/lib/agents-config.ts +47 -6
  88. package/lib/agents-message-delivery.ts +17 -0
  89. package/lib/agents-messaging.ts +8 -2
  90. package/lib/agents-protocol.ts +15 -0
  91. package/lib/agents-report-cap.ts +115 -0
  92. package/lib/agents-runner.ts +91 -6
  93. package/lib/agents-session-transport.ts +17 -1
  94. package/lib/background-jobs-tools.ts +9 -4
  95. package/lib/bounded-writer-admission.ts +184 -31
  96. package/lib/child-context-files.ts +21 -6
  97. package/lib/codemode-renderer.ts +1 -0
  98. package/lib/delivery-conflict-markers.ts +349 -0
  99. package/lib/design-canvas-assets.ts +36 -0
  100. package/lib/design-canvas-server.ts +241 -23
  101. package/lib/design-comments.ts +94 -4
  102. package/lib/design-handoffs.ts +2 -1
  103. package/lib/design-layout.ts +125 -0
  104. package/lib/design-parts.ts +281 -0
  105. package/lib/design-system-tokens.ts +111 -0
  106. package/lib/desktop-agents-service.ts +294 -0
  107. package/lib/desktop-design-service.ts +233 -0
  108. package/lib/desktop-jobs-service.ts +263 -0
  109. package/lib/desktop-rpc-agents.ts +294 -0
  110. package/lib/desktop-rpc-config.ts +731 -0
  111. package/lib/desktop-rpc-design.ts +138 -0
  112. package/lib/desktop-rpc-jobs.ts +181 -0
  113. package/lib/desktop-rpc-permissions.ts +177 -0
  114. package/lib/desktop-rpc-profiles.ts +196 -0
  115. package/lib/desktop-rpc-usage.ts +229 -0
  116. package/lib/desktop-rpc.ts +225 -0
  117. package/lib/desktop-usage-service.ts +310 -0
  118. package/lib/destructive-command-guard.ts +188 -13
  119. package/lib/gentle-ai-renderer.ts +13 -1
  120. package/lib/gentle-design.ts +201 -14
  121. package/lib/gentle-shell-bundled.ts +100 -9
  122. package/lib/hidden-tools.ts +35 -0
  123. package/lib/inprocess-reviewer.ts +96 -12
  124. package/lib/model-fallback-policy.ts +9 -0
  125. package/lib/model-routing-authority.ts +9 -0
  126. package/lib/nan-provider.ts +42 -28
  127. package/lib/native-review-cli.ts +79 -4
  128. package/lib/orchestrator-discovery.ts +39 -2
  129. package/lib/reply-language-anchor.ts +27 -2
  130. package/lib/request-context-placement.ts +53 -0
  131. package/lib/review-candidate-view.ts +11 -1
  132. package/lib/review-continuation-registry.ts +17 -0
  133. package/lib/review-coordinator.ts +252 -8
  134. package/lib/review-delivery-preflight.ts +85 -0
  135. package/lib/review-host-relay.ts +5 -1
  136. package/lib/review-integration-v2.ts +56 -3
  137. package/lib/reviewer-stream.ts +87 -0
  138. package/lib/shell-prompt.ts +16 -3
  139. package/lib/shell-usage.ts +10 -0
  140. package/lib/vim-editor-adapter.ts +9 -2
  141. package/lib/writer-batch-admission.ts +55 -0
  142. package/lib/yolo-session-policy.ts +6 -1
  143. package/package.json +2 -2
  144. package/prompts/skill-creation.md +1 -10
  145. package/runtime/design-canvas-assets.mjs +37 -0
  146. package/runtime/gentle-shell-bundled.mjs +100 -9
  147. package/runtime/native-review-cli.mjs +79 -4
  148. package/runtime/review-integration-v2.mjs +56 -3
  149. package/scripts/bootstrap.cmd +2 -2
  150. package/scripts/bootstrap.sh +41 -4
  151. package/scripts/build-full-delegation-card.mjs +4 -0
  152. package/scripts/build-runtime-modules.mjs +1 -0
  153. package/scripts/gentle-ai-installer.mjs +10 -10
  154. package/scripts/gentle-ai-proxy.mjs +1 -1
  155. package/scripts/installer-downloads.mjs +34 -8
  156. package/scripts/installer-preflight.mjs +28 -17
  157. package/scripts/installer-probes.mjs +25 -5
  158. package/scripts/installer-server.mjs +38 -9
  159. package/scripts/installer-windows.mjs +2 -2
  160. package/scripts/pi-update.mjs +166 -27
  161. package/scripts/prepare-verifier.mjs +107 -0
  162. package/scripts/update-agent-body-history.mjs +55 -8
  163. package/scripts/verify-package-files.mjs +40 -19
  164. package/skills/branch-pr/SKILL.md +16 -16
  165. package/skills/comment-writer/SKILL.md +1 -1
  166. package/skills/design/SKILL.md +6 -6
  167. package/skills/gentle-ai/SKILL.md +5 -5
  168. package/skills/judgment-day/SKILL.md +2 -2
  169. package/skills/judgment-day/references/prompts-and-formats.md +1 -1
  170. package/skills/rdd-defect-workflow/SKILL.md +6 -6
  171. package/skills/skill-improver/SKILL.md +2 -2
  172. package/skills/skill-registry/SKILL.md +11 -13
  173. package/skills/tui-design/SKILL.md +1 -1
  174. package/skills/work-unit-commits/SKILL.md +5 -5
  175. package/tests/agent-prompt-diet-contract.test.ts +101 -0
  176. package/tests/agent-tool-overlay-acceptance.test.ts +158 -0
  177. package/tests/agent-tool-overlay.test.ts +89 -0
  178. package/tests/agents-config.test.ts +10 -1
  179. package/tests/agents-message-delivery.test.ts +36 -0
  180. package/tests/agents-queries.test.ts +144 -4
  181. package/tests/agents-report-cap.test.ts +126 -0
  182. package/tests/agents-runner.test.ts +37 -1
  183. package/tests/agents-session-transport.test.ts +34 -0
  184. package/tests/always-on-prompt-verdicts-contract.test.ts +188 -0
  185. package/tests/append-system-prompt-route.test.ts +10 -2
  186. package/tests/approved-text-leftovers-contract.test.ts +136 -0
  187. package/tests/artifact-language.test.ts +1 -1
  188. package/tests/ask-user-question.test.ts +2 -1
  189. package/tests/audit-leftovers-contract.test.ts +51 -0
  190. package/tests/bounded-stop-contract.test.ts +9 -1
  191. package/tests/branch-pr-skill.test.ts +10 -1
  192. package/tests/bundled-install.test.ts +1 -1
  193. package/tests/child-context-files.test.ts +64 -8
  194. package/tests/child-skills-catalog.test.ts +56 -0
  195. package/tests/codemode-rendering.test.ts +4 -1
  196. package/tests/delegate-for-reason-contract.test.ts +30 -8
  197. package/tests/delivery-conflict-markers.test.ts +348 -0
  198. package/tests/design-canvas-all-sizes.test.ts +631 -0
  199. package/tests/design-canvas-allowlist.test.ts +32 -0
  200. package/tests/design-canvas-assets.test.ts +11 -878
  201. package/tests/design-canvas-boards.test.ts +77 -0
  202. package/tests/design-canvas-checks.test.ts +655 -0
  203. package/tests/design-canvas-compare.test.ts +79 -0
  204. package/tests/design-canvas-events.test.ts +59 -0
  205. package/tests/design-canvas-export.test.ts +1168 -0
  206. package/tests/design-canvas-focus.test.ts +113 -0
  207. package/tests/design-canvas-handoffs.test.ts +59 -0
  208. package/tests/design-canvas-i18n-review.test.ts +513 -0
  209. package/tests/design-canvas-i18n-views.test.ts +259 -0
  210. package/tests/design-canvas-i18n.test.ts +526 -0
  211. package/tests/design-canvas-inspector.test.ts +937 -0
  212. package/tests/design-canvas-layout.test.ts +1222 -0
  213. package/tests/design-canvas-minimap.test.ts +413 -0
  214. package/tests/design-canvas-modules.test.ts +90 -0
  215. package/tests/design-canvas-parts.test.ts +721 -0
  216. package/tests/design-canvas-rail.test.ts +799 -0
  217. package/tests/design-canvas-server.test.ts +855 -17
  218. package/tests/design-canvas-sizes.test.ts +548 -0
  219. package/tests/design-canvas-store.test.ts +180 -0
  220. package/tests/design-canvas-tokens.test.ts +965 -0
  221. package/tests/design-canvas-view.test.ts +299 -0
  222. package/tests/design-comments.test.ts +201 -1
  223. package/tests/design-handoffs.test.ts +20 -0
  224. package/tests/design-layout.test.ts +100 -0
  225. package/tests/design-parts.test.ts +260 -0
  226. package/tests/design-system-tokens.test.ts +215 -0
  227. package/tests/desktop-rpc-agents.test.ts +893 -0
  228. package/tests/desktop-rpc-config.test.ts +1452 -0
  229. package/tests/desktop-rpc-design.test.ts +662 -0
  230. package/tests/desktop-rpc-jobs.test.ts +796 -0
  231. package/tests/desktop-rpc-permissions.test.ts +311 -0
  232. package/tests/desktop-rpc-profiles.test.ts +140 -0
  233. package/tests/desktop-rpc-safety.test.ts +119 -0
  234. package/tests/desktop-rpc-usage.test.ts +697 -0
  235. package/tests/desktop-rpc.test.ts +252 -0
  236. package/tests/devbinary/pi-host-relay.devtest.ts +149 -80
  237. package/tests/devbinary/review-session-consent.devtest.ts +84 -0
  238. package/tests/engram-safety.test.ts +111 -0
  239. package/tests/fixtures/devbinary/status-v9-escalated-non-blocking.captured.json +92 -0
  240. package/tests/fixtures/devbinary/status-v9-escalated-non-blocking.provenance.md +3 -0
  241. package/tests/fixtures/primary-session-prompt/gentleman.golden.md +20 -29
  242. package/tests/fixtures/refusal-identity.probe.mjs +139 -0
  243. package/tests/full-delegation-closure.test.ts +29 -0
  244. package/tests/gentle-agents.test.ts +329 -4
  245. package/tests/gentle-ai-binary.test.ts +1 -1
  246. package/tests/gentle-ai-child-guards.test.ts +1 -0
  247. package/tests/gentle-ai-installer.test.ts +52 -51
  248. package/tests/gentle-ai-renderer.test.ts +36 -2
  249. package/tests/gentle-ai.test.ts +121 -6
  250. package/tests/gentle-design.test.ts +365 -1
  251. package/tests/gentle-shell-bundled.test.ts +91 -5
  252. package/tests/gentle-shell-launcher.test.ts +1 -1
  253. package/tests/gentle-shell.test.ts +118 -87
  254. package/tests/gentle-todo.test.ts +32 -9
  255. package/tests/hidden-tools.test.ts +188 -0
  256. package/tests/independent-recovery-delivery.test.ts +19 -5
  257. package/tests/inprocess-reviewer.test.ts +73 -0
  258. package/tests/install-wizard.test.ts +27 -1
  259. package/tests/installer-downloads.test.ts +30 -1
  260. package/tests/installer-posix-bootstrap.test.ts +114 -13
  261. package/tests/installer-preflight.test.ts +49 -1
  262. package/tests/installer-probes.test.ts +146 -0
  263. package/tests/installer-server.test.ts +203 -4
  264. package/tests/installer-windows-bootstrap.test.ts +19 -1
  265. package/tests/judgment-day-severity-admission.test.ts +46 -0
  266. package/tests/lazy-module-contradictions-contract.test.ts +158 -0
  267. package/tests/maintainer/desktop-rpc.maintest.ts +632 -0
  268. package/tests/maintainer/pi-update-source.maintest.ts +48 -18
  269. package/tests/model-fallback-policy.test.ts +26 -7
  270. package/tests/nan-provider-runtime.test.ts +17 -3
  271. package/tests/nan-provider.test.ts +111 -56
  272. package/tests/native-review-capability-contract.test.ts +11 -1
  273. package/tests/native-review-cli-nonblocking-findings.test.ts +165 -0
  274. package/tests/native-review-parity.test.ts +24 -5
  275. package/tests/native-review-refusal-identity.test.ts +25 -0
  276. package/tests/no-self-pause-contract.test.ts +11 -3
  277. package/tests/odd-integration.test.ts +11 -3
  278. package/tests/odd-routing-contract.test.ts +80 -28
  279. package/tests/orchestrator-budget.test.ts +30 -5
  280. package/tests/orchestrator-consultation-sdk.test.ts +32 -6
  281. package/tests/orchestrator-delegation-mode.test.ts +2 -1
  282. package/tests/orchestrator-discovery.test.ts +28 -0
  283. package/tests/orchestrator-prompt-budget.test.ts +11 -2
  284. package/tests/orchestrator-prompt-diet-contract.test.ts +221 -0
  285. package/tests/orchestrator-rdd-ownership.test.ts +2 -1
  286. package/tests/orchestrator-work-search.test.ts +4 -2
  287. package/tests/package-files.test.ts +25 -1
  288. package/tests/package-manifest.test.ts +11 -10
  289. package/tests/parallel-reason-contract.test.ts +6 -3
  290. package/tests/permission-allowlist.test.ts +200 -30
  291. package/tests/persona-neutral-voseo.test.ts +4 -4
  292. package/tests/persona-reply-language.test.ts +1 -1
  293. package/tests/persona-single-channel.test.ts +13 -5
  294. package/tests/pi-update-launcher.test.ts +17 -7
  295. package/tests/pi-update-source.test.ts +113 -6
  296. package/tests/pi-update.test.ts +294 -19
  297. package/tests/pnpm-workspace-policy.test.ts +47 -0
  298. package/tests/primary-context-files.test.ts +233 -0
  299. package/tests/primary-context-three-files.test.ts +174 -0
  300. package/tests/provider-defect-handoff.test.ts +9 -2
  301. package/tests/rdd-aware-verification-contract.test.ts +1 -1
  302. package/tests/rdd-status-line.test.ts +94 -1
  303. package/tests/reply-language-anchor-placement.test.ts +184 -0
  304. package/tests/reply-language-anchor.test.ts +17 -1
  305. package/tests/request-context-append-only.test.ts +218 -0
  306. package/tests/request-context-placement.test.ts +148 -0
  307. package/tests/review-agent-end-preflight.test.ts +79 -1
  308. package/tests/review-candidate-view.test.ts +65 -0
  309. package/tests/review-continuation-registry.test.ts +31 -0
  310. package/tests/review-contract-prompt.test.ts +1 -1
  311. package/tests/review-controller.test.ts +2 -1
  312. package/tests/review-coordinator-correction-gate.test.ts +105 -0
  313. package/tests/review-coordinator-findings.test.ts +206 -0
  314. package/tests/review-coordinator-nonblocking-scope.test.ts +169 -0
  315. package/tests/review-coordinator.test.ts +271 -4
  316. package/tests/review-delivery-preflight.test.ts +462 -0
  317. package/tests/review-due-compaction.test.ts +31 -0
  318. package/tests/review-due-public-boundary.test.ts +26 -0
  319. package/tests/review-integration-nonblocking-findings.test.ts +108 -0
  320. package/tests/review-json-arguments.test.ts +41 -2
  321. package/tests/review-ledger-contract.test.ts +19 -40
  322. package/tests/review-loadout-rdd-off-sdk.test.ts +30 -1
  323. package/tests/review-one-call-findings.test.ts +131 -0
  324. package/tests/review-one-call-followups.test.ts +308 -0
  325. package/tests/review-one-call-reviewer-requests.test.ts +207 -0
  326. package/tests/review-one-call.test.ts +452 -0
  327. package/tests/review-relay-transport-agent.test.ts +28 -1
  328. package/tests/review-reviewer-evidence.test.ts +41 -1
  329. package/tests/review-risk-assessment.test.ts +52 -5
  330. package/tests/review-run-statement-guidance-independent.test.ts +54 -0
  331. package/tests/review-session-standing-permission-controller.test.ts +32 -2
  332. package/tests/review-tool-prose-budget.test.ts +1 -0
  333. package/tests/reviewer-stream.test.ts +149 -0
  334. package/tests/session-profile-extension.test.ts +2 -2
  335. package/tests/shell-prompt.test.ts +17 -0
  336. package/tests/shell-usage.test.ts +59 -10
  337. package/tests/skill-contradictions-contract.test.ts +122 -0
  338. package/tests/skill-registry-watcher.test.ts +216 -2
  339. package/tests/skill-registry.test.ts +929 -306
  340. package/tests/support/design-canvas-dom.ts +369 -0
  341. package/tests/support/review-coordinator-runtime.ts +212 -17
  342. package/tests/task-size-routing-contract.test.ts +42 -11
  343. package/tests/test-strength-contract.test.ts +2 -1
  344. package/tests/todo-request-append-only.test.ts +214 -0
  345. package/tests/tool-batching-contract.test.ts +3 -1
  346. package/tests/update-agent-body-history.test.ts +138 -0
  347. package/tests/verification-tiers-contract.test.ts +229 -0
  348. package/tests/verifier-preparation.test.ts +229 -0
  349. package/tests/verify-agent-contract.test.ts +20 -2
  350. package/tests/verify-first-launch-contract.test.ts +87 -11
  351. package/tests/vim-editor-adapter.test.ts +2 -2
  352. package/tests/work-continuity-contract.test.ts +54 -11
  353. package/tests/writer-admission-messages.test.ts +232 -0
  354. package/tests/writer-batch-admission.test.ts +66 -0
  355. package/tests/writer-edit-surface-scope.test.ts +52 -20
  356. package/tests/writer-feature-document-admission.test.ts +184 -0
  357. package/tests/yolo-mode.test.ts +39 -0
  358. package/skills/_shared/review-ledger-contract.md +0 -106
  359. /package/contracts/review-provider-contract-mirror/{v1.4.0 → v1.5.0}/bundle/README.md +0 -0
  360. /package/contracts/review-provider-contract-mirror/{v1.4.0 → v1.5.0}/bundle/schemas/lens.schema.json +0 -0
  361. /package/contracts/review-provider-contract-mirror/{v1.4.0 → v1.5.0}/bundle/schemas/refuter.schema.json +0 -0
  362. /package/contracts/review-provider-contract-mirror/{v1.4.0 → v1.5.0}/bundle/schemas/targeted-validator.schema.json +0 -0
  363. /package/contracts/review-provider-contract-mirror/{v1.4.0 → v1.5.0}/bundle/vectors/lens.json +0 -0
  364. /package/contracts/review-provider-contract-mirror/{v1.4.0 → v1.5.0}/bundle/vectors/refuter.json +0 -0
  365. /package/contracts/review-provider-contract-mirror/{v1.4.0 → v1.5.0}/bundle/vectors/targeted-validator.json +0 -0
@@ -12,6 +12,13 @@ import { updateSelectedPi } from '../../scripts/pi-update.mjs';
12
12
 
13
13
  const exec = promisify(execFile);
14
14
  const PI = '@earendil-works/pi-coding-agent';
15
+ // Co-published with Pi and pinned exactly by it: no older version can satisfy it.
16
+ const SIBLING = '@earendil-works/pi-ai';
17
+ // A Pi-scope dependency with a range must stay age-filtered like any other.
18
+ const RANGED = '@earendil-works/pi-ranged-fixture';
19
+ // Pinned exactly by SIBLING, not by Pi: only a transitive closure finds it.
20
+ const GRAND = '@earendil-works/pi-grand-fixture';
21
+ const fresh = (name: string) => name === PI || name === SIBLING || name === GRAND;
15
22
  for (const manager of ['npm', 'pnpm']) test(`real ${manager} source update preserves ranges, unrelated pins, Shell link and lifecycle safety`, {skip: process.platform === 'win32'}, async t => {
16
23
  const temp = await fs.realpath(await fs.mkdtemp(join(tmpdir(), 'pi-real-')));
17
24
  t.after(() => fs.rm(temp, {recursive:true, force:true}));
@@ -19,7 +26,8 @@ for (const manager of ['npm', 'pnpm']) test(`real ${manager} source update prese
19
26
  Object.assign(env, {HOME:temp, USERPROFILE:temp, XDG_CONFIG_HOME:temp, XDG_CACHE_HOME:join(temp,'cache'), npm_config_cache:join(temp,'cache'), npm_config_userconfig:join(temp,'user.npmrc'), npm_config_globalconfig:join(temp,'global.npmrc'), npm_config_update_notifier:'false', COREPACK_ENABLE_PROJECT_SPEC:'0', COREPACK_ENABLE_NETWORK:'0', COREPACK_HOME:join(temp,'corepack'), PNPM_HOME:join(temp,'pnpm-home')});
20
27
  await fs.writeFile(env.npm_config_userconfig!, '');
21
28
  await fs.writeFile(env.npm_config_globalconfig!, '');
22
- const command = (await exec('which', [manager], {env})).stdout.trim();
29
+ // GENTLE_PI_MAINTEST_PNPM selects another real pnpm (for example a user's newer global one).
30
+ const command = manager === 'pnpm' && process.env.GENTLE_PI_MAINTEST_PNPM ? process.env.GENTLE_PI_MAINTEST_PNPM : (await exec('which', [manager], {env})).stdout.trim();
23
31
  const version = (await exec(command, ['--version'], {cwd:temp, env})).stdout.trim();
24
32
  const files = new Map<string, Buffer>();
25
33
  const manifests: Record<string, any> = {};
@@ -35,7 +43,8 @@ for (const manager of ['npm', 'pnpm']) test(`real ${manager} source update prese
35
43
  const name = path.slice(1);
36
44
  if (!manifests[name]) {res.statusCode = 404; res.end('{}'); return;}
37
45
  res.setHeader('content-type', 'application/json');
38
- res.end(JSON.stringify({name, 'dist-tags':{latest:updated ? '1.1.0' : '1.0.0'}, time:{'1.0.0':'2020-01-01T00:00:00Z','1.1.0':'2020-01-02T00:00:00Z'}, versions:updated ? manifests[name] : {'1.0.0':manifests[name]['1.0.0']}}));
46
+ const latest = fresh(name) ? '2.0.0' : '1.1.0';
47
+ res.end(JSON.stringify({name, 'dist-tags':{latest:updated ? latest : '1.0.0'}, time:{'1.0.0':'2020-01-01T00:00:00Z',[latest]:new Date().toISOString(), ...(name === PI ? {'3.0.0':new Date().toISOString()} : {})}, versions:updated ? manifests[name] : {'1.0.0':manifests[name]['1.0.0']}}));
39
48
  });
40
49
  await new Promise<void>(resolve => server.listen(0, '127.0.0.1', resolve));
41
50
  t.after(() => new Promise<void>((resolve, reject) => server.close(error => error ? reject(error) : resolve())));
@@ -46,18 +55,21 @@ for (const manager of ['npm', 'pnpm']) test(`real ${manager} source update prese
46
55
  // pnpm 11 does not honor npm's registry environment variable. Bind both
47
56
  // install and update explicitly to the fixture registry and private store.
48
57
  const registryFlags = ['--registry', registry, ...(manager === 'pnpm' ? ['--store-dir', join(temp,'store'), '--config.update-notifier=false'] : [])];
49
- for (const name of [PI, 'unrelated-fixture']) {
58
+ for (const name of [PI, SIBLING, GRAND, RANGED, 'unrelated-fixture', 'age-filtered-fixture', 'pre-excluded-fixture']) {
50
59
  manifests[name] = {};
51
- for (const version of ['1.0.0', '1.1.0']) {
52
- const pack = join(temp, `pack-${name === PI ? 'pi' : 'other'}-${version}`);
60
+ for (const version of name === PI ? ['1.0.0', '2.0.0', '3.0.0'] : fresh(name) ? ['1.0.0', '2.0.0'] : ['1.0.0', '1.1.0']) {
61
+ const pack = join(temp, `pack-${name === PI ? 'pi' : name}-${version}`);
53
62
  await fs.mkdir(join(pack, 'package', 'dist', 'bundle'), {recursive:true});
54
- const manifest = {name, version, bin:name === PI ? {pi:'dist/bundle/cli.js'} : undefined, scripts:{postinstall:'node -e "require(\'fs\').writeFileSync(\'LIFECYCLE_RAN\', \'bad\')"'}};
63
+ const manifest = {name, version, bin:name === PI ? {pi:'dist/bundle/cli.js'} : undefined,
64
+ dependencies:name === PI && version === '2.0.0' ? {'age-filtered-fixture':'^1.0.0', 'pre-excluded-fixture':'^1.0.0', [SIBLING]:'2.0.0', [RANGED]:'^1.0.0'}
65
+ : name === SIBLING && version === '2.0.0' ? {[GRAND]:'2.0.0'} : undefined,
66
+ scripts:{postinstall:'node -e "require(\'fs\').writeFileSync(\'LIFECYCLE_RAN\', \'bad\')"'}};
55
67
  await fs.writeFile(join(pack, 'package', 'package.json'), JSON.stringify(manifest));
56
68
  await fs.writeFile(join(pack, 'package', 'dist', 'bundle', 'cli.js'), `console.log('${version}');`);
57
69
  const archive = join(pack, 'p.tgz');
58
70
  await exec('tar', ['-czf', archive, '-C', pack, 'package'], {env});
59
71
  const bytes = await fs.readFile(archive);
60
- const path = `/tar/${name === PI ? 'pi' : 'other'}-${version}.tgz`;
72
+ const path = `/tar/${name === PI ? 'pi' : name}-${version}.tgz`;
61
73
  files.set(path, bytes);
62
74
  manifests[name][version] = {...manifest, dist:{tarball:registry + path, shasum:createHash('sha1').update(bytes).digest('hex')}};
63
75
  }
@@ -68,7 +80,8 @@ for (const manager of ['npm', 'pnpm']) test(`real ${manager} source update prese
68
80
  t.diagnostic(`${manager} runtime ${version}; project declaration ${declaredVersion}`);
69
81
  const manifest = JSON.stringify({name:'gentle-pi', version:'4.4.0', packageManager:`${manager}@${declaredVersion}`, devDependencies:{[PI]:'^1.0.0', 'unrelated-fixture':'^1.0.0'}});
70
82
  await fs.writeFile(join(root, 'package.json'), manifest);
71
- const policy = 'minimumReleaseAge: 4320\n';
83
+ // Versioned entries for the siblings shadow any later CLI entry for the same name.
84
+ const policy = `minimumReleaseAge: 4320\nminimumReleaseAgeExclude:\n - pre-excluded-fixture\n - '${SIBLING}@1.0.0'\n - '${GRAND}@1.0.0'\n`;
72
85
  if (manager === 'pnpm') await fs.writeFile(join(root,'pnpm-workspace.yaml'), policy);
73
86
  const common = ['--ignore-scripts', '--global=false', ...(manager === 'pnpm' ? ['--ignore-pnpmfile', '--pm-on-fail=ignore'] : ['--no-audit', '--no-fund'])];
74
87
  await exec(command, ['install', ...common, ...registryFlags], {cwd:root, env, maxBuffer:1024*1024});
@@ -87,19 +100,24 @@ for (const manager of ['npm', 'pnpm']) test(`real ${manager} source update prese
87
100
  run:async (_cmd: string, args: string[], options: {cwd?: string,env?: Record<string,string>}) => {
88
101
  if (args.includes('list') && args.includes('-g')) return {code:0, stdout:JSON.stringify([{path:temp, dependencies:{}}])};
89
102
  if (args.includes('ls') && args.includes('-g')) return {code:0, stdout:JSON.stringify({path:temp, dependencies:{'gentle-pi':{path:link, resolved:'file:../../checkout'}}})};
90
- if (args[0] === 'update') mutations.push(args);
91
- // The second phase models an already-published release, not a newly
92
- // backdated version hidden behind install's fresh metadata-age cache.
103
+ const mutation = ['update', 'add', 'install'].includes(args[0]);
104
+ if (mutation) mutations.push(args);
93
105
  const selectedEnv = options.env ?? env;
94
- const runEnv = manager === 'pnpm' && args[0] === 'update' ? {...selectedEnv, XDG_CACHE_HOME:join(temp,'update-cache')} : selectedEnv;
95
- try {const result = await exec(command, args[0] === 'update' ? [...args, ...registryFlags] : args, {cwd:options.cwd, env:runEnv, maxBuffer:1024*1024}); managerRuns.push({args, stdout:result.stdout, stderr:result.stderr}); return {code:0, stdout:result.stdout, stderrTail:result.stderr};}
96
- catch (error: any) {return {code:error.code, stdout:error.stdout, stderrTail:error.stderr};}
106
+ // A fresh cache ensures that the new publication is visible to the manager.
107
+ const runEnv = manager === 'pnpm' ? {...selectedEnv, XDG_CACHE_HOME:join(temp,'update-cache')} : selectedEnv;
108
+ const extra = mutation ? registryFlags : args.includes('view') ? ['--registry', registry] : [];
109
+ try {const result = await exec(command, [...args, ...extra], {cwd:options.cwd, env:runEnv, maxBuffer:1024*1024}); managerRuns.push({args, stdout:result.stdout, stderr:result.stderr}); return {code:0, stdout:result.stdout, stderrTail:result.stderr};}
110
+ catch (error: any) {t.diagnostic(JSON.stringify({args, code:error.code, stdout:error.stdout, stderr:error.stderr})); return {code:error.code, stdout:error.stdout, stderrTail:error.stderr};}
97
111
  },
98
112
  }}), 0);
99
113
  assert.equal(mutations.length, 1);
100
- assert.ok(mutations[0].includes(PI));
114
+ assert.ok(mutations[0].some(arg => arg === PI || arg.startsWith(`${PI}@`)));
101
115
  assert.ok(registryRequests.some(request => request.phase === 'update' && request.path === `/${PI}`), JSON.stringify(registryRequests));
102
116
  assert.ok(!mutations[0].includes('-g'));
117
+ if (manager === 'pnpm') {
118
+ const exclusions = mutations[0].filter(arg => arg.startsWith('--config.minimum-release-age-exclude=')).map(arg => arg.slice(arg.indexOf('=') + 1));
119
+ assert.deepEqual(exclusions, ['pre-excluded-fixture', `${SIBLING}@1.0.0 || 2.0.0`, `${GRAND}@1.0.0 || 2.0.0`, PI]);
120
+ }
103
121
  assert.equal(await fs.realpath(link), root);
104
122
  assert.equal(await fs.readFile(join(root, 'package.json'), 'utf8'), manifest);
105
123
  if (manager === 'pnpm') {
@@ -107,10 +125,22 @@ for (const manager of ['npm', 'pnpm']) test(`real ${manager} source update prese
107
125
  assert.ok(managerRuns.filter(run => run.args.includes('config') || run.args.includes('--recursive') || run.args[0] === 'update').every(run => run.args.includes('--pm-on-fail=ignore')));
108
126
  assert.ok(!registryRequests.some(request => request.path === '/pnpm' || request.path.startsWith('/@pnpm/')), 'no project-pinned manager acquired');
109
127
  }
110
- assert.notEqual(await fs.readFile(lockPath, 'utf8'), oldLock, JSON.stringify({output, installed:JSON.parse(await fs.readFile(join(root,'node_modules',PI,'package.json'),'utf8')).version, managerRuns, registryRequests}));
111
- assert.equal(JSON.parse(await fs.readFile(join(root,'node_modules',PI,'package.json'),'utf8')).version, '1.1.0');
128
+ if (manager === 'pnpm') assert.notEqual(await fs.readFile(lockPath, 'utf8'), oldLock, JSON.stringify({output, installed:JSON.parse(await fs.readFile(join(root,'node_modules',PI,'package.json'),'utf8')).version, managerRuns, registryRequests}));
129
+ else assert.equal(await fs.readFile(lockPath, 'utf8'), oldLock, 'npm --no-save leaves the lockfile unchanged');
130
+ assert.equal(JSON.parse(await fs.readFile(join(root,'node_modules',PI,'package.json'),'utf8')).version, '2.0.0');
112
131
  assert.equal(JSON.parse(await fs.readFile(join(root,'node_modules','unrelated-fixture','package.json'),'utf8')).version, '1.0.0');
132
+ const { createRequire } = await import('node:module');
133
+ const resolveFromPi = createRequire(join(await fs.realpath(join(root,'node_modules',PI)), 'package.json'));
134
+ const installedVersion = async (name: string) => JSON.parse(await fs.readFile(resolveFromPi.resolve(`${name}/package.json`), 'utf8')).version;
135
+ if (manager === 'pnpm') {
136
+ assert.equal(await installedVersion('age-filtered-fixture'), '1.0.0', 'a fresh unrelated dependency remains age-filtered');
137
+ assert.equal(await installedVersion('pre-excluded-fixture'), '1.1.0', 'the existing exclusion remains effective');
138
+ assert.equal(await installedVersion(RANGED), '1.0.0', 'a ranged Pi-scope dependency remains age-filtered');
139
+ }
140
+ assert.equal(await installedVersion(SIBLING), '2.0.0', 'the exact co-published sibling is installed');
141
+ const resolveFromSibling = createRequire(join(await fs.realpath(join(await fs.realpath(resolveFromPi.resolve(`${SIBLING}/package.json`)), '..')), 'package.json'));
142
+ assert.equal(JSON.parse(await fs.readFile(resolveFromSibling.resolve(`${GRAND}/package.json`), 'utf8')).version, '2.0.0', 'the transitively pinned sibling is installed');
113
143
  await assert.rejects(fs.access(join(root,'node_modules',PI,'LIFECYCLE_RAN')));
114
144
  assert.equal(output.length, 1);
115
- assert.match(output[0], /the selected Pi is now 1\.1\.0 \(was 1\.0\.0\)/);
145
+ assert.match(output[0], /the selected Pi is now 2\.0\.0 \(was 1\.0\.0\)/);
116
146
  });
@@ -55,13 +55,24 @@ test("a full /gentle:usage window cools a whole provider until it resets, and a
55
55
  test("a provider that reports one limit per model only cools the exhausted model; the provider waits only when every limit is spent", () => {
56
56
  const cooldown = new ModelCooldown();
57
57
  const limit = (name: string, usedPercent: number, reached: boolean, resetAt: number | null) => ({ name, limitReached: reached, windows: [{ usedPercent, resetAt }] });
58
- syncUsageCooldown({ provider: "nan", limits: [limit("glm5.2", 100, true, 90_000), limit("deepseek-v4-flash", 10, false, 90_000)] }, cooldown, 1_000);
59
- assert.equal(cooldown.available("nan/glm5.2", 2_000), false, "the spent model waits");
60
- assert.equal(cooldown.available("nan/deepseek-v4-flash", 2_000), true, "its siblings keep working");
61
- assert.equal(cooldown.available("nan/glm5.2", 90_000), true, "until its own window resets");
62
- syncUsageCooldown({ provider: "nan", limits: [limit("glm5.2", 100, true, 50_000), limit("deepseek-v4-flash", 100, true, 60_000)] }, cooldown, 1_000);
63
- assert.equal(cooldown.available("nan/other", 49_999), false, "every limit spent: the whole provider waits");
64
- assert.equal(cooldown.available("nan/other", 50_000), true, "until the earliest reset");
58
+ syncUsageCooldown({ provider: "acme", limits: [limit("model-a", 100, true, 90_000), limit("model-b", 10, false, 90_000)] }, cooldown, 1_000);
59
+ assert.equal(cooldown.available("acme/model-a", 2_000), false, "the spent model waits");
60
+ assert.equal(cooldown.available("acme/model-b", 2_000), true, "its siblings keep working");
61
+ assert.equal(cooldown.available("acme/model-a", 90_000), true, "until its own window resets");
62
+ syncUsageCooldown({ provider: "acme", limits: [limit("model-a", 100, true, 50_000), limit("model-b", 100, true, 60_000)] }, cooldown, 1_000);
63
+ assert.equal(cooldown.available("acme/other", 49_999), false, "every limit spent: the whole provider waits");
64
+ assert.equal(cooldown.available("acme/other", 50_000), true, "until the earliest reset");
65
+ });
66
+
67
+ test("NaN's per-model quota snapshot is advisory and never cools a NaN model or the provider", () => {
68
+ const cooldown = new ModelCooldown();
69
+ const limit = (name: string, resetAt: number) => ({ name, limitReached: true, windows: [{ usedPercent: 100, resetAt }] });
70
+ syncUsageCooldown({ provider: "nan", limits: [limit("glm5.3", 90_000), limit("deepseek-v4-flash", 90_000)] }, cooldown, 1_000);
71
+ assert.equal(cooldown.available("nan/glm5.3", 2_000), true, "a spent quota row blocks nothing");
72
+ assert.equal(cooldown.available("nan/deepseek-v4-flash", 2_000), true, "every row spent still blocks no NaN model");
73
+ cooldown.mark("nan/glm5.3", C.QUOTA, 2_000);
74
+ syncUsageCooldown({ provider: "nan", limits: [] }, cooldown, 3_000);
75
+ assert.equal(cooldown.available("nan/glm5.3", 3_000), false, "a real quota error from NaN still cools the model");
65
76
  });
66
77
 
67
78
  test("a full window whose reset already passed is a stale reading and blocks nothing", () => {
@@ -81,3 +92,11 @@ test("a spent provider-wide limit (Codex's main one) skips every model; an extra
81
92
  assert.equal(extras.available("openai-codex/gpt-5.3-codex-spark", 2_000), false, "display names are matched in id form");
82
93
  assert.equal(extras.available("openai-codex/gpt-5.5", 2_000), true);
83
94
  });
95
+
96
+ test("a NaN quota reading never releases a model cooled by a real NaN error", () => {
97
+ const cooldown = new ModelCooldown();
98
+ cooldown.mark("nan/hy4", C.QUOTA, 1_000);
99
+ syncUsageCooldown({ provider: "nan", limits: [{ name: "hy4", limitReached: false, windows: [{ usedPercent: 5, resetAt: 90_000 }] }] }, cooldown, 1_500);
100
+ assert.equal(cooldown.available("nan/hy4", 2_000), false);
101
+ assert.equal(cooldown.reason("nan/hy4", 2_000), C.QUOTA);
102
+ });
@@ -48,7 +48,14 @@ try {
48
48
  assert.equal(registrations.length, 1);
49
49
  const { provider } = registrations[0];
50
50
  assert.equal(provider.id, "nan");
51
- const model = provider.getModels().find(m => m.id === "deepseek-v4-flash");
51
+ const effortCase = {
52
+ "kimi-high": { id: "kimi-k3.1-pro", effort: "high", expected: "high" },
53
+ "deepseek-pro-max": { id: "deepseek-v4-pro", effort: "max", expected: "max" },
54
+ "hy4-off": { id: "hy4", effort: "off", expected: "none" },
55
+ "hy4-high": { id: "hy4", effort: "high", expected: "high" },
56
+ }[scenario];
57
+ const modelId = effortCase?.id ?? "deepseek-v4-flash";
58
+ const model = provider.getModels().find(m => m.id === modelId);
52
59
  assert.ok(model);
53
60
  const fakeFetch = async (input, init) => {
54
61
  requests++;
@@ -56,8 +63,14 @@ try {
56
63
  assert.equal(url, "https://api.nan.builders/v1/chat/completions");
57
64
  assert.equal(init.method, "POST");
58
65
  const body = JSON.parse(init.body);
59
- assert.equal(body.model, "deepseek-v4-flash");
66
+ assert.equal(body.model, modelId);
60
67
  assert.equal(body.stream, true);
68
+ if (effortCase) {
69
+ assert.equal(body.reasoning_effort, effortCase.expected);
70
+ assert.equal(Object.hasOwn(body, "thinking"), false);
71
+ assert.equal(body.max_completion_tokens, 16);
72
+ assert.equal(Object.hasOwn(body, "max_tokens"), false);
73
+ }
61
74
  if (scenario === "http-error") {
62
75
  return new Response(JSON.stringify({ error: { message: "synthetic unavailable" } }), {
63
76
  status: 503, headers: { "content-type": "application/json" },
@@ -90,6 +103,7 @@ try {
90
103
  } }] });
91
104
  const stream = provider.streamSimple(model, { messages }, {
92
105
  apiKey: "synthetic-key", fetch: fakeFetch, maxRetries: 0, maxTokens: 16, timeoutMs: 5000,
106
+ ...(effortCase ? { reasoning: effortCase.effort } : {}),
93
107
  });
94
108
  const events = [];
95
109
  for await (const event of stream) events.push(event);
@@ -132,7 +146,7 @@ try {
132
146
  `;
133
147
 
134
148
  for (const cache of ["default filesystem-cache env", "JITI_FS_CACHE=false"] as const) {
135
- for (const scenario of ["text", "http-error", "tool"] as const) {
149
+ for (const scenario of ["text", "http-error", "tool", "kimi-high", "deepseek-pro-max", "hy4-off", "hy4-high"] as const) {
136
150
  test(`NaN real loader → ${scenario} stream (${sdkLayout} SDK, cache ${cache})`, { timeout: 30_000 }, async (t) => {
137
151
  const workspace = await mkdtemp(join(tmpdir(), "nan-runtime-test-"));
138
152
  try {
@@ -5,7 +5,7 @@ import { clampThinkingLevel, createModels, getSupportedThinkingLevels, InMemoryC
5
5
  import type { Provider } from "@earendil-works/pi-ai";
6
6
  import { completeSimple } from "@earendil-works/pi-ai/compat";
7
7
  import nanProviderExtension from "../extensions/nan-provider.ts";
8
- import { createNanProviderConfig as createNativeProvider, isNanAdaptiveReasoningModel, NAN_PROVIDER_BASE_URL, NAN_PROVIDER_ID } from "../lib/nan-provider.ts";
8
+ import { createNanProviderConfig as createNativeProvider, isNanAdaptiveReasoningModel, NAN_ADAPTIVE_REASONING_MODEL_IDS, NAN_PROVIDER_BASE_URL, NAN_PROVIDER_ID } from "../lib/nan-provider.ts";
9
9
 
10
10
  // Keep catalog assertions independent of the native refresh's void return contract.
11
11
  function createNanProviderConfig(options: Parameters<typeof createNativeProvider>[0] = {}) {
@@ -23,8 +23,17 @@ function createNanProviderConfig(options: Parameters<typeof createNativeProvider
23
23
  const DOCUMENTED_CHAT_IDS = [
24
24
  "glm5.3", "deepseek-v4-flash", "glm5.3-flash", "qwen3.8-flash",
25
25
  "mimo-v2.6-flash", "gemma4", "qwen3.6",
26
+ "kimi-k3.1-pro", "qwen3.8-max", "deepseek-v4-pro", "hy4",
26
27
  ];
27
28
 
29
+ // Pi 1.5 derives the compat and thinking-map types through pi-schema's Static, which
30
+ // collapses all-optional objects to `unknown` under this repository's `strict: false`.
31
+ // Both Pi 1.4 and 1.5 still read `compat.maxTokensField` at run time; these views name
32
+ // the fields the tests read and write.
33
+ type CatalogModel = ReturnType<ReturnType<typeof createNativeProvider>["getModels"]>[number];
34
+ const capCompat = (model: CatalogModel) => model.compat as { maxTokensField?: "max_tokens" | "max_completion_tokens" } | undefined;
35
+ const levelMap = (model: CatalogModel) => model.thinkingLevelMap as Record<string, string | null> | undefined;
36
+
28
37
  function jsonResponse(body: unknown, status = 200): Response {
29
38
  return new Response(JSON.stringify(body), {
30
39
  status,
@@ -182,7 +191,7 @@ test("offline and already-aborted refreshes invalidate keys without publication"
182
191
  }
183
192
  });
184
193
 
185
- test("initial catalog contains all seven documented chat models with configured output caps", () => {
194
+ test("initial catalog contains all eleven documented chat models with configured output caps", () => {
186
195
  const models = createNanProviderConfig().models;
187
196
  assert.deepEqual(models.map((model) => model.id), DOCUMENTED_CHAT_IDS);
188
197
  const model = models.find((model) => model.id === "deepseek-v4-flash");
@@ -191,12 +200,12 @@ test("initial catalog contains all seven documented chat models with configured
191
200
  assert.equal(model?.reasoning, true);
192
201
  assert.deepEqual(model?.input, ["text", "image"]);
193
202
  assert.equal(model?.contextWindow, 1_000_000);
194
- assert.equal(models.length, 7);
195
- assert.equal(model?.maxTokens, 131_072);
203
+ assert.equal(models.length, 11);
204
+ assert.equal(model?.maxTokens, 393_216);
196
205
  assert.deepEqual(model?.cost, { input: 0, output: 0, cacheRead: 0, cacheWrite: 0 });
197
206
  });
198
207
 
199
- test("only NaN DeepSeek serializes its unchanged output cap as max_tokens", async () => {
208
+ test("DeepSeek Flash keeps max_tokens as its configured output field", async () => {
200
209
  const models = createNativeProvider().getModels();
201
210
  const model = models.find((model) => model.id === "deepseek-v4-flash")!;
202
211
  let body: Record<string, unknown> | undefined;
@@ -211,11 +220,11 @@ test("only NaN DeepSeek serializes its unchanged output cap as max_tokens", asyn
211
220
  },
212
221
  });
213
222
  assert.equal(result.stopReason, "stop");
214
- assert.equal(body?.max_tokens, 131_072);
223
+ assert.equal(body?.max_tokens, 393_216);
215
224
  assert.ok(!Object.hasOwn(body!, "max_completion_tokens"));
216
225
  assert.equal(body?.reasoning_effort, "minimal");
217
- assert.equal(model.maxTokens, 131_072);
218
- assert.equal(model.compat?.maxTokensField, "max_tokens");
226
+ assert.equal(model.maxTokens, 393_216);
227
+ assert.equal(capCompat(model)?.maxTokensField, "max_tokens");
219
228
  assert.ok(models.filter((candidate) => candidate.id !== model.id).every((candidate) => candidate.compat === undefined));
220
229
  });
221
230
 
@@ -224,52 +233,75 @@ test("DeepSeek compat is isolated across snapshots, providers, and live refreshe
224
233
  for (const live of [false, true]) {
225
234
  if (live) await provider.refreshModels!(refreshContext({ type: "api_key", key: "synthetic-key" }));
226
235
  const model = provider.getModels().find((model) => model.id === "deepseek-v4-flash")!;
227
- assert.equal(model.compat?.maxTokensField, "max_tokens");
228
- model.compat!.maxTokensField = "max_completion_tokens";
229
- assert.equal(provider.getModels().find((candidate) => candidate.id === model.id)!.compat?.maxTokensField, "max_tokens");
230
- assert.equal(createNativeProvider().getModels().find((model) => model.id === "deepseek-v4-flash")!.compat?.maxTokensField, "max_tokens");
236
+ assert.equal(capCompat(model)?.maxTokensField, "max_tokens");
237
+ capCompat(model)!.maxTokensField = "max_completion_tokens";
238
+ assert.equal(capCompat(provider.getModels().find((candidate) => candidate.id === model.id)!)?.maxTokensField, "max_tokens");
239
+ assert.equal(capCompat(createNativeProvider().getModels().find((model) => model.id === "deepseek-v4-flash")!)?.maxTokensField, "max_tokens");
231
240
  }
232
241
  });
233
242
 
234
- test("GLM models expose exactly NaN's four efforts and no off", () => {
235
- const models = createNativeProvider().getModels();
236
- for (const id of ["glm5.3", "glm5.3-flash"]) {
237
- const model = models.find((model) => model.id === id);
238
- assert.ok(model);
239
- assert.deepEqual(model.thinkingLevelMap, { off: null, minimal: null, xhigh: null, max: "max" });
240
- assert.deepEqual(getSupportedThinkingLevels(model), ["low", "medium", "high", "max"]);
241
- // Pi levels NaN does not declare clamp onto the nearest declared effort.
242
- assert.equal(clampThinkingLevel(model, "off"), "low");
243
- assert.equal(clampThinkingLevel(model, "minimal"), "low");
244
- assert.equal(clampThinkingLevel(model, "xhigh"), "max");
245
- }
246
- });
243
+ const ALL_EFFORTS = ["off", "minimal", "low", "medium", "high", "xhigh", "max"] as const;
244
+ type Effort = (typeof ALL_EFFORTS)[number];
247
245
 
248
- test("models with none and minimal expose exactly NaN's six efforts", () => {
249
- const models = createNativeProvider().getModels();
250
- // Qwen 3.6 and Gemma 4 honor these values as depth controls; DeepSeek V4 Flash,
251
- // Qwen 3.8 Flash, and MiMo accept them while NaN manages depth itself.
252
- for (const id of ["qwen3.6", "gemma4", "deepseek-v4-flash", "qwen3.8-flash", "mimo-v2.6-flash"]) {
253
- const model = models.find((model) => model.id === id);
246
+ async function chatPayload(model: ReturnType<ReturnType<typeof createNativeProvider>["getModels"]>[number], reasoning?: Effort) {
247
+ let body: Record<string, unknown> | undefined;
248
+ const result = await completeSimple(model, { messages: [{ role: "user", content: "offline probe", timestamp: 0 }] }, {
249
+ // Pi's simple stream represents the model's off level by omitting reasoning.
250
+ apiKey: "synthetic-key", reasoning: reasoning === "off" ? undefined : reasoning,
251
+ fetch: async (input, init) => {
252
+ assert.equal(String(input), `${NAN_PROVIDER_BASE_URL}/chat/completions`);
253
+ body = JSON.parse(String(init?.body));
254
+ return new Response('data: {"id":"offline","choices":[{"index":0,"delta":{"role":"assistant","content":"ok"},"finish_reason":"stop"}]}\n\ndata: [DONE]\n\n', {
255
+ headers: { "content-type": "text/event-stream" },
256
+ });
257
+ },
258
+ });
259
+ assert.equal(result.stopReason, "stop");
260
+ assert.ok(body);
261
+ return body;
262
+ }
263
+
264
+ // Assert the public Pi level list and actual OpenAI-compatible wire payload, not
265
+ // just the map: ordinary levels pass through, while off and MiMo use aliases.
266
+ for (const id of DOCUMENTED_CHAT_IDS) {
267
+ test(`${id} exposes and serializes NaN's accepted reasoning efforts`, async () => {
268
+ const model = createNativeProvider().getModels().find((candidate) => candidate.id === id);
254
269
  assert.ok(model);
255
- assert.deepEqual(model.thinkingLevelMap, { off: "none", xhigh: null, max: "max" });
256
- assert.deepEqual(getSupportedThinkingLevels(model), ["off", "minimal", "low", "medium", "high", "max"]);
257
- assert.equal(clampThinkingLevel(model, "xhigh"), "max");
258
- }
270
+ const glm = id === "glm5.3" || id === "glm5.3-flash";
271
+ const mimo = id === "mimo-v2.6-flash";
272
+ const supported = glm ? ALL_EFFORTS.slice(1) : [...ALL_EFFORTS];
273
+ assert.deepEqual(getSupportedThinkingLevels(model), supported);
274
+ if (glm) assert.equal(clampThinkingLevel(model, "off"), "minimal");
275
+ for (const effort of supported) {
276
+ const body = await chatPayload(model, effort);
277
+ const expected = effort === "off" ? "none" : mimo && effort === "minimal" ? "low" : mimo && effort === "xhigh" ? "max" : effort;
278
+ assert.equal(body.model, id);
279
+ assert.equal(body.reasoning_effort, expected, `${id} ${effort}`);
280
+ assert.equal(Object.hasOwn(body, "thinking"), false, `${id} ${effort} must use reasoning_effort`);
281
+ const capField = id === "deepseek-v4-flash" ? "max_tokens" : "max_completion_tokens";
282
+ const otherField = capField === "max_tokens" ? "max_completion_tokens" : "max_tokens";
283
+ // Pi clamps the configured cap to the context window minus its 4,096-token
284
+ // safety reserve and this probe's 4 estimated tokens. Only Kimi K3.1 Pro
285
+ // (Max answer 1M == context window) hits that clamp: 1,000,000 - 4,100.
286
+ const expectedCap = model.maxTokens >= model.contextWindow ? 995_900 : model.maxTokens;
287
+ assert.equal(body[capField], expectedCap, `${id} ${effort} output cap`);
288
+ assert.equal(Object.hasOwn(body, otherField), false, `${id} ${effort} alternate cap`);
289
+ }
290
+ });
291
+ }
292
+
293
+ test("Hy4 forwards explicit effort; Pi's off mapping does not invent its server default", async () => {
294
+ const model = createNativeProvider().getModels().find((candidate) => candidate.id === "hy4");
295
+ assert.ok(model);
296
+ assert.equal((await chatPayload(model, "high")).reasoning_effort, "high");
297
+ assert.equal((await chatPayload(model, "off")).reasoning_effort, "none");
298
+ // Pi's simple stream also uses the off map when no option was supplied.
299
+ assert.equal((await chatPayload(model)).reasoning_effort, "none");
259
300
  });
260
301
 
261
- test("only the self-managing models carry the adaptive reasoning marker", () => {
262
- const models = createNativeProvider().getModels();
263
- assert.deepEqual(
264
- models.filter((model) => isNanAdaptiveReasoningModel(model)).map((model) => model.id),
265
- ["deepseek-v4-flash", "qwen3.8-flash", "mimo-v2.6-flash"],
266
- );
267
- // Qwen 3.6 and Gemma 4 share the same map but honor the level as a depth budget.
268
- for (const id of ["qwen3.6", "gemma4", "glm5.3", "glm5.3-flash"]) {
269
- const model = models.find((model) => model.id === id);
270
- assert.ok(model);
271
- assert.equal(isNanAdaptiveReasoningModel(model), false);
272
- }
302
+ test("the legacy adaptive marker is retained but no longer classifies NaN models", () => {
303
+ assert.deepEqual([...NAN_ADAPTIVE_REASONING_MODEL_IDS], []);
304
+ for (const model of createNativeProvider().getModels()) assert.equal(isNanAdaptiveReasoningModel(model), false);
273
305
  assert.equal(isNanAdaptiveReasoningModel(undefined), false);
274
306
  assert.equal(isNanAdaptiveReasoningModel({ provider: "openai", id: "deepseek-v4-flash" }), false);
275
307
  });
@@ -280,17 +312,19 @@ test("thinking maps are isolated across snapshots, providers, and live catalog r
280
312
  });
281
313
  const baseline = provider.getModels();
282
314
  for (const model of provider.getModels()) {
283
- assert.ok(model.thinkingLevelMap);
284
- model.thinkingLevelMap.off = "mutated";
285
- model.thinkingLevelMap.medium = null;
315
+ const map = levelMap(model);
316
+ assert.ok(map);
317
+ map.off = "mutated";
318
+ map.medium = null;
286
319
  }
287
320
  assert.deepEqual(provider.getModels(), baseline);
288
321
  assert.deepEqual(createNativeProvider().getModels(), baseline);
289
322
  await provider.refreshModels!(refreshContext({ type: "api_key", key: "map-key" }));
290
323
  assert.deepEqual(provider.getModels(), baseline);
291
324
  for (const model of provider.getModels()) {
292
- assert.ok(model.thinkingLevelMap);
293
- model.thinkingLevelMap.xhigh = "mutated";
325
+ const map = levelMap(model);
326
+ assert.ok(map);
327
+ map.xhigh = "mutated";
294
328
  }
295
329
  assert.deepEqual(provider.getModels(), baseline);
296
330
  await provider.refreshModels!(refreshContext({ type: "api_key", key: "map-key" }));
@@ -320,7 +354,7 @@ test("live discovery uses the key-scoped endpoint and replaces the fallback with
320
354
  const config = createNanProviderConfig({
321
355
  fetchImpl: async (input, init) => {
322
356
  request = { url: String(input), init };
323
- return jsonResponse({ data: [{ id: " glm5.3 " }, { id: "glm5.3" }, { id: "unknown-chat" }, { id: "embedding" }, { id: "image" }, { id: "speech" }, { id: "rerank" }] });
357
+ return jsonResponse({ data: [{ id: " glm5.3 " }, { id: "glm5.3" }, { id: "hy4" }, { id: "qwen3.8-max" }, { id: "deepseek-v4-pro" }, { id: "kimi-k3.1-pro" }, { id: "unknown-chat" }, { id: "embedding" }, { id: "image" }, { id: "speech" }, { id: "rerank" }] });
324
358
  },
325
359
  });
326
360
  const fallbackId = "deepseek-v4-flash";
@@ -332,7 +366,7 @@ test("live discovery uses the key-scoped endpoint and replaces the fallback with
332
366
  assert.equal(request?.init?.method, "GET");
333
367
  assert.equal(new Headers(request?.init?.headers).get("authorization"), "Bearer test-secret");
334
368
  assert.equal(request?.init?.redirect, "error");
335
- assert.deepEqual(models?.map((model) => model.id), ["glm5.3"]);
369
+ assert.deepEqual(models?.map((model) => model.id), ["glm5.3", "hy4", "qwen3.8-max", "deepseek-v4-pro", "kimi-k3.1-pro"]);
336
370
  assert.ok(!models?.some((model) => model.id === fallbackId));
337
371
 
338
372
  const known = models?.[0];
@@ -347,12 +381,16 @@ test("live discovery uses the key-scoped endpoint and replaces the fallback with
347
381
  test("known chat models retain documented capabilities without advertising audio", async () => {
348
382
  const expected = [
349
383
  ["glm5.3", 1_000_000, ["text", "image"], 32_768],
350
- ["deepseek-v4-flash", 1_000_000, ["text", "image"], 131_072],
351
- ["glm5.3-flash", 1_000_000, ["text", "image"], 32_768],
384
+ ["deepseek-v4-flash", 1_000_000, ["text", "image"], 393_216],
385
+ ["glm5.3-flash", 1_000_000, ["text", "image"], 131_072],
352
386
  ["qwen3.8-flash", 1_048_576, ["text", "image"], 131_000],
353
387
  ["mimo-v2.6-flash", 1_000_000, ["text", "image"], 32_768],
354
388
  ["gemma4", 262_000, ["text", "image"], 65_536],
355
389
  ["qwen3.6", 262_000, ["text", "image"], 65_536],
390
+ ["kimi-k3.1-pro", 1_000_000, ["text", "image"], 1_000_000],
391
+ ["qwen3.8-max", 1_000_000, ["text", "image"], 131_000],
392
+ ["deepseek-v4-pro", 1_000_000, ["text"], 393_000],
393
+ ["hy4", 1_000_000, ["text", "image"], 64_000],
356
394
  ] as const;
357
395
  const config = createNanProviderConfig({
358
396
  fetchImpl: async () => jsonResponse({ data: expected.map(([id]) => ({ id })) }),
@@ -363,9 +401,12 @@ test("known chat models retain documented capabilities without advertising audio
363
401
  const model = models?.[index];
364
402
  assert.equal(model?.id, id);
365
403
  assert.equal(model?.reasoning, true);
404
+ assert.equal(model?.api, "openai-completions");
366
405
  assert.equal(model?.contextWindow, contextWindow);
367
406
  assert.deepEqual(model?.input, input);
368
407
  assert.equal(model?.maxTokens, maxTokens);
408
+ assert.deepEqual(model?.cost, { input: 0, output: 0, cacheRead: 0, cacheWrite: 0 });
409
+ assert.deepEqual(model?.compat, id === "deepseek-v4-flash" ? { maxTokensField: "max_tokens" } : undefined);
369
410
  }
370
411
  });
371
412
 
@@ -515,3 +556,17 @@ test("an old in-flight discovery cannot overwrite a changed credential's catalog
515
556
  ...refreshContext({ type: "api_key", key: "second-key" }), allowNetwork: false,
516
557
  }), []);
517
558
  });
559
+
560
+ test("NaN effort levels per model follow the reasoning contract", () => {
561
+ const models = createNativeProvider().getModels();
562
+ const levels = Object.fromEntries(models.map((model) => [model.id, getSupportedThinkingLevels(model).join(",")]));
563
+ const full = "off,minimal,low,medium,high,xhigh,max";
564
+ const glm = "minimal,low,medium,high,xhigh,max";
565
+ assert.deepEqual(levels, {
566
+ "glm5.3": glm, "glm5.3-flash": glm,
567
+ "deepseek-v4-flash": full, "qwen3.8-flash": full, "mimo-v2.6-flash": full, gemma4: full, "qwen3.6": full,
568
+ "kimi-k3.1-pro": full, "qwen3.8-max": full, "deepseek-v4-pro": full, hy4: full,
569
+ });
570
+ const mimo = models.find((model) => model.id === "mimo-v2.6-flash");
571
+ assert.deepEqual(mimo?.thinkingLevelMap, { off: "none", minimal: "low", xhigh: "max", max: "max" });
572
+ });
@@ -398,11 +398,21 @@ test("4.4.0 explicitly repeats 4.3.1 because capabilities/v2.6 and provider cont
398
398
  assert.deepEqual(contract, NATIVE_CLI_CONTRACTS["4.3.1"] as Record<string, boolean>);
399
399
  });
400
400
 
401
+ test("4.5.0 explicitly repeats 4.4.0 because capabilities/v2.6 still carries the negotiated surface", () => {
402
+ // Ground truth from the published v4.5.0 darwin/arm64 binary:
403
+ // `review capabilities --contract gentle-ai.review-integration/v2` reports
404
+ // schema/feature identity capabilities/v2.6 (protocol minor 6), and the
405
+ // additive provider contract 1.5.0 changes no negotiated START/STATUS field.
406
+ const contract = NATIVE_CLI_CONTRACTS["4.5.0"] as Record<string, boolean>;
407
+ assert.ok(contract);
408
+ assert.deepEqual(contract, NATIVE_CLI_CONTRACTS["4.4.0"] as Record<string, boolean>);
409
+ });
410
+
401
411
  test("no shipped version key was added beyond the pin bump", () => {
402
412
  // Rows are promises to consumers, so a new key only ever appears in a
403
413
  // dedicated commit alongside a pin bump, never as a side effect. v2.2.4 and
404
414
  // v2.3.0 shipped upstream while Pi stayed on 2.2.3 and were never pinned,
405
415
  // so they get no row: a row asserts ground truth measured against a binary
406
416
  // Pi actually ran, and the table only has to be ascending, not gapless.
407
- assert.deepEqual(Object.keys(NATIVE_CLI_CONTRACTS), [...DARK_VERSIONS, "2.2.0", "2.2.1", "2.2.2", "2.2.3", "2.4.0", "2.5.0-rc.3", "2.5.0", "2.6.0", "2.7.0", "2.8.0", "2.8.1", "2.8.2", "2.9.0", "2.9.1", "3.0.0", "3.0.1", "3.1.0", "3.2.1", "3.4.0", "3.5.0", "3.6.0", "3.6.1", "3.7.0", "4.0.0", "4.1.1", "4.2.0", "4.3.1", "4.4.0"]);
417
+ assert.deepEqual(Object.keys(NATIVE_CLI_CONTRACTS), [...DARK_VERSIONS, "2.2.0", "2.2.1", "2.2.2", "2.2.3", "2.4.0", "2.5.0-rc.3", "2.5.0", "2.6.0", "2.7.0", "2.8.0", "2.8.1", "2.8.2", "2.9.0", "2.9.1", "3.0.0", "3.0.1", "3.1.0", "3.2.1", "3.4.0", "3.5.0", "3.6.0", "3.6.1", "3.7.0", "4.0.0", "4.1.1", "4.2.0", "4.3.1", "4.4.0", "4.5.0"]);
408
418
  });