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.
- package/README.md +55 -44
- package/assets/agents/gentle-ai-explore.md +3 -3
- package/assets/agents/gentle-ai-verify.md +20 -6
- package/assets/agents/gentle-ai-worker.md +6 -6
- package/assets/agents/jd-judge-a.md +1 -3
- package/assets/agents/jd-judge-b.md +1 -3
- package/assets/agents/review-readability.md +1 -5
- package/assets/agents/review-reliability.md +1 -5
- package/assets/agents/review-resilience.md +1 -5
- package/assets/agents/review-risk.md +1 -5
- package/assets/design-canvas/canvas-api.js +45 -0
- package/assets/design-canvas/canvas-boards.js +456 -0
- package/assets/design-canvas/canvas-boot.js +217 -0
- package/assets/design-canvas/canvas-checks.js +491 -0
- package/assets/design-canvas/canvas-comments.js +315 -0
- package/assets/design-canvas/canvas-compare.js +159 -0
- package/assets/design-canvas/canvas-events.js +75 -0
- package/assets/design-canvas/canvas-export.js +393 -0
- package/assets/design-canvas/canvas-focus.js +203 -0
- package/assets/design-canvas/canvas-handoffs.js +150 -0
- package/assets/design-canvas/canvas-i18n-es.js +392 -0
- package/assets/design-canvas/canvas-i18n.js +108 -0
- package/assets/design-canvas/canvas-layout.js +526 -0
- package/assets/design-canvas/canvas-menu.js +213 -0
- package/assets/design-canvas/canvas-messages.js +86 -0
- package/assets/design-canvas/canvas-minimap.js +163 -0
- package/assets/design-canvas/canvas-parts.js +401 -0
- package/assets/design-canvas/canvas-popover.js +234 -0
- package/assets/design-canvas/canvas-rail.js +348 -0
- package/assets/design-canvas/canvas-sizes.js +524 -0
- package/assets/design-canvas/canvas-store.js +164 -0
- package/assets/design-canvas/canvas-tokens.js +674 -0
- package/assets/design-canvas/canvas-ui.js +24 -0
- package/assets/design-canvas/canvas-view.js +184 -0
- package/assets/design-canvas/canvas.css +746 -15
- package/assets/design-canvas/canvas.js +2 -1506
- package/assets/design-canvas/index.html +117 -36
- package/assets/design-canvas/inspector.js +546 -16
- package/assets/install-wizard/wizard.js +5 -1
- package/assets/migrations/agent-body-history.json +24 -0
- package/assets/orchestrator-delegation-reference.md +8 -14
- package/assets/orchestrator-delegation.md +4 -4
- package/assets/orchestrator-full-delegation-card.md +4 -5
- package/assets/orchestrator-full-delegation.md +8 -8
- package/assets/orchestrator-memory.md +2 -2
- package/assets/orchestrator-prompts.md +1 -1
- package/assets/orchestrator-quota-recovery.md +5 -0
- package/assets/orchestrator-skills.md +13 -12
- package/assets/orchestrator-tracking.md +10 -14
- package/assets/orchestrator-verification.md +10 -8
- package/assets/orchestrator-writer.md +4 -4
- package/assets/orchestrator.md +18 -22
- package/bin/gentle-shell.mjs +128 -9
- package/contracts/review-provider-contract-mirror/provider-contract.lock.json +8 -9
- package/contracts/review-provider-contract-mirror/{v1.4.0 → v1.5.0}/bundle/manifest.json +3 -3
- package/contracts/review-provider-contract-mirror/{v1.4.0 → v1.5.0}/bundle/orchestration/pi.md +1 -0
- package/contracts/review-provider-contract-mirror/{v1.4.0 → v1.5.0}/bundle/routing/pi.md +6 -6
- package/contracts/review-provider-contract-mirror/{v1.4.0 → v1.5.0}/generated/provider-capabilities.baseline.json +3 -3
- package/contracts/review-provider-contract-mirror/{v1.4.0 → v1.5.0}/generated/provider-roles.baseline.json +1 -1
- package/docs/assets/brand/sponsor-banner.svg +60 -0
- package/docs/bundled-install.md +14 -6
- package/docs/delegated-verification.md +18 -2
- package/docs/desktop-rpc.md +1253 -0
- package/docs/gentle-agents-activity.md +26 -0
- package/docs/gentle-shell.md +39 -16
- package/docs/install-wizard.md +30 -21
- package/docs/odd-preparation-continuity.md +24 -0
- package/docs/permission-modes.md +9 -1
- package/docs/prompt-budget.md +12 -0
- package/docs/rdd-odd-friction-triage-2026-11-07.md +57 -0
- package/docs/readme-reference.md +76 -24
- package/docs/review-coordinator.md +29 -9
- package/docs/review-delivery-preflight.md +22 -0
- package/docs/work-continuity.md +11 -1
- package/extensions/ask-user-question.ts +2 -2
- package/extensions/child-context.ts +21 -7
- package/extensions/gentle-agents.ts +234 -33
- package/extensions/gentle-ai.ts +576 -135
- package/extensions/gentle-design.ts +69 -3
- package/extensions/gentle-desktop-rpc.ts +143 -0
- package/extensions/gentle-guide.ts +3 -0
- package/extensions/gentle-shell.ts +105 -52
- package/extensions/gentle-todo.ts +48 -25
- package/extensions/skill-registry.ts +248 -223
- package/lib/agent-assets.ts +30 -6
- package/lib/agent-tool-overlay.ts +117 -0
- package/lib/agents-config.ts +47 -6
- package/lib/agents-message-delivery.ts +17 -0
- package/lib/agents-messaging.ts +8 -2
- package/lib/agents-protocol.ts +15 -0
- package/lib/agents-report-cap.ts +115 -0
- package/lib/agents-runner.ts +91 -6
- package/lib/agents-session-transport.ts +17 -1
- package/lib/background-jobs-tools.ts +9 -4
- package/lib/bounded-writer-admission.ts +184 -31
- package/lib/child-context-files.ts +21 -6
- package/lib/codemode-renderer.ts +1 -0
- package/lib/delivery-conflict-markers.ts +349 -0
- package/lib/design-canvas-assets.ts +36 -0
- package/lib/design-canvas-server.ts +241 -23
- package/lib/design-comments.ts +94 -4
- package/lib/design-handoffs.ts +2 -1
- package/lib/design-layout.ts +125 -0
- package/lib/design-parts.ts +281 -0
- package/lib/design-system-tokens.ts +111 -0
- package/lib/desktop-agents-service.ts +294 -0
- package/lib/desktop-design-service.ts +233 -0
- package/lib/desktop-jobs-service.ts +263 -0
- package/lib/desktop-rpc-agents.ts +294 -0
- package/lib/desktop-rpc-config.ts +731 -0
- package/lib/desktop-rpc-design.ts +138 -0
- package/lib/desktop-rpc-jobs.ts +181 -0
- package/lib/desktop-rpc-permissions.ts +177 -0
- package/lib/desktop-rpc-profiles.ts +196 -0
- package/lib/desktop-rpc-usage.ts +229 -0
- package/lib/desktop-rpc.ts +225 -0
- package/lib/desktop-usage-service.ts +310 -0
- package/lib/destructive-command-guard.ts +188 -13
- package/lib/gentle-ai-renderer.ts +13 -1
- package/lib/gentle-design.ts +201 -14
- package/lib/gentle-shell-bundled.ts +100 -9
- package/lib/hidden-tools.ts +35 -0
- package/lib/inprocess-reviewer.ts +96 -12
- package/lib/model-fallback-policy.ts +9 -0
- package/lib/model-routing-authority.ts +9 -0
- package/lib/nan-provider.ts +42 -28
- package/lib/native-review-cli.ts +79 -4
- package/lib/orchestrator-discovery.ts +39 -2
- package/lib/reply-language-anchor.ts +27 -2
- package/lib/request-context-placement.ts +53 -0
- package/lib/review-candidate-view.ts +11 -1
- package/lib/review-continuation-registry.ts +17 -0
- package/lib/review-coordinator.ts +252 -8
- package/lib/review-delivery-preflight.ts +85 -0
- package/lib/review-host-relay.ts +5 -1
- package/lib/review-integration-v2.ts +56 -3
- package/lib/reviewer-stream.ts +87 -0
- package/lib/shell-prompt.ts +16 -3
- package/lib/shell-usage.ts +10 -0
- package/lib/vim-editor-adapter.ts +9 -2
- package/lib/writer-batch-admission.ts +55 -0
- package/lib/yolo-session-policy.ts +6 -1
- package/package.json +2 -2
- package/prompts/skill-creation.md +1 -10
- package/runtime/design-canvas-assets.mjs +37 -0
- package/runtime/gentle-shell-bundled.mjs +100 -9
- package/runtime/native-review-cli.mjs +79 -4
- package/runtime/review-integration-v2.mjs +56 -3
- package/scripts/bootstrap.cmd +2 -2
- package/scripts/bootstrap.sh +41 -4
- package/scripts/build-full-delegation-card.mjs +4 -0
- package/scripts/build-runtime-modules.mjs +1 -0
- package/scripts/gentle-ai-installer.mjs +10 -10
- package/scripts/gentle-ai-proxy.mjs +1 -1
- package/scripts/installer-downloads.mjs +34 -8
- package/scripts/installer-preflight.mjs +28 -17
- package/scripts/installer-probes.mjs +25 -5
- package/scripts/installer-server.mjs +38 -9
- package/scripts/installer-windows.mjs +2 -2
- package/scripts/pi-update.mjs +166 -27
- package/scripts/prepare-verifier.mjs +107 -0
- package/scripts/update-agent-body-history.mjs +55 -8
- package/scripts/verify-package-files.mjs +40 -19
- package/skills/branch-pr/SKILL.md +16 -16
- package/skills/comment-writer/SKILL.md +1 -1
- package/skills/design/SKILL.md +6 -6
- package/skills/gentle-ai/SKILL.md +5 -5
- package/skills/judgment-day/SKILL.md +2 -2
- package/skills/judgment-day/references/prompts-and-formats.md +1 -1
- package/skills/rdd-defect-workflow/SKILL.md +6 -6
- package/skills/skill-improver/SKILL.md +2 -2
- package/skills/skill-registry/SKILL.md +11 -13
- package/skills/tui-design/SKILL.md +1 -1
- package/skills/work-unit-commits/SKILL.md +5 -5
- package/tests/agent-prompt-diet-contract.test.ts +101 -0
- package/tests/agent-tool-overlay-acceptance.test.ts +158 -0
- package/tests/agent-tool-overlay.test.ts +89 -0
- package/tests/agents-config.test.ts +10 -1
- package/tests/agents-message-delivery.test.ts +36 -0
- package/tests/agents-queries.test.ts +144 -4
- package/tests/agents-report-cap.test.ts +126 -0
- package/tests/agents-runner.test.ts +37 -1
- package/tests/agents-session-transport.test.ts +34 -0
- package/tests/always-on-prompt-verdicts-contract.test.ts +188 -0
- package/tests/append-system-prompt-route.test.ts +10 -2
- package/tests/approved-text-leftovers-contract.test.ts +136 -0
- package/tests/artifact-language.test.ts +1 -1
- package/tests/ask-user-question.test.ts +2 -1
- package/tests/audit-leftovers-contract.test.ts +51 -0
- package/tests/bounded-stop-contract.test.ts +9 -1
- package/tests/branch-pr-skill.test.ts +10 -1
- package/tests/bundled-install.test.ts +1 -1
- package/tests/child-context-files.test.ts +64 -8
- package/tests/child-skills-catalog.test.ts +56 -0
- package/tests/codemode-rendering.test.ts +4 -1
- package/tests/delegate-for-reason-contract.test.ts +30 -8
- package/tests/delivery-conflict-markers.test.ts +348 -0
- package/tests/design-canvas-all-sizes.test.ts +631 -0
- package/tests/design-canvas-allowlist.test.ts +32 -0
- package/tests/design-canvas-assets.test.ts +11 -878
- package/tests/design-canvas-boards.test.ts +77 -0
- package/tests/design-canvas-checks.test.ts +655 -0
- package/tests/design-canvas-compare.test.ts +79 -0
- package/tests/design-canvas-events.test.ts +59 -0
- package/tests/design-canvas-export.test.ts +1168 -0
- package/tests/design-canvas-focus.test.ts +113 -0
- package/tests/design-canvas-handoffs.test.ts +59 -0
- package/tests/design-canvas-i18n-review.test.ts +513 -0
- package/tests/design-canvas-i18n-views.test.ts +259 -0
- package/tests/design-canvas-i18n.test.ts +526 -0
- package/tests/design-canvas-inspector.test.ts +937 -0
- package/tests/design-canvas-layout.test.ts +1222 -0
- package/tests/design-canvas-minimap.test.ts +413 -0
- package/tests/design-canvas-modules.test.ts +90 -0
- package/tests/design-canvas-parts.test.ts +721 -0
- package/tests/design-canvas-rail.test.ts +799 -0
- package/tests/design-canvas-server.test.ts +855 -17
- package/tests/design-canvas-sizes.test.ts +548 -0
- package/tests/design-canvas-store.test.ts +180 -0
- package/tests/design-canvas-tokens.test.ts +965 -0
- package/tests/design-canvas-view.test.ts +299 -0
- package/tests/design-comments.test.ts +201 -1
- package/tests/design-handoffs.test.ts +20 -0
- package/tests/design-layout.test.ts +100 -0
- package/tests/design-parts.test.ts +260 -0
- package/tests/design-system-tokens.test.ts +215 -0
- package/tests/desktop-rpc-agents.test.ts +893 -0
- package/tests/desktop-rpc-config.test.ts +1452 -0
- package/tests/desktop-rpc-design.test.ts +662 -0
- package/tests/desktop-rpc-jobs.test.ts +796 -0
- package/tests/desktop-rpc-permissions.test.ts +311 -0
- package/tests/desktop-rpc-profiles.test.ts +140 -0
- package/tests/desktop-rpc-safety.test.ts +119 -0
- package/tests/desktop-rpc-usage.test.ts +697 -0
- package/tests/desktop-rpc.test.ts +252 -0
- package/tests/devbinary/pi-host-relay.devtest.ts +149 -80
- package/tests/devbinary/review-session-consent.devtest.ts +84 -0
- package/tests/engram-safety.test.ts +111 -0
- package/tests/fixtures/devbinary/status-v9-escalated-non-blocking.captured.json +92 -0
- package/tests/fixtures/devbinary/status-v9-escalated-non-blocking.provenance.md +3 -0
- package/tests/fixtures/primary-session-prompt/gentleman.golden.md +20 -29
- package/tests/fixtures/refusal-identity.probe.mjs +139 -0
- package/tests/full-delegation-closure.test.ts +29 -0
- package/tests/gentle-agents.test.ts +329 -4
- package/tests/gentle-ai-binary.test.ts +1 -1
- package/tests/gentle-ai-child-guards.test.ts +1 -0
- package/tests/gentle-ai-installer.test.ts +52 -51
- package/tests/gentle-ai-renderer.test.ts +36 -2
- package/tests/gentle-ai.test.ts +121 -6
- package/tests/gentle-design.test.ts +365 -1
- package/tests/gentle-shell-bundled.test.ts +91 -5
- package/tests/gentle-shell-launcher.test.ts +1 -1
- package/tests/gentle-shell.test.ts +118 -87
- package/tests/gentle-todo.test.ts +32 -9
- package/tests/hidden-tools.test.ts +188 -0
- package/tests/independent-recovery-delivery.test.ts +19 -5
- package/tests/inprocess-reviewer.test.ts +73 -0
- package/tests/install-wizard.test.ts +27 -1
- package/tests/installer-downloads.test.ts +30 -1
- package/tests/installer-posix-bootstrap.test.ts +114 -13
- package/tests/installer-preflight.test.ts +49 -1
- package/tests/installer-probes.test.ts +146 -0
- package/tests/installer-server.test.ts +203 -4
- package/tests/installer-windows-bootstrap.test.ts +19 -1
- package/tests/judgment-day-severity-admission.test.ts +46 -0
- package/tests/lazy-module-contradictions-contract.test.ts +158 -0
- package/tests/maintainer/desktop-rpc.maintest.ts +632 -0
- package/tests/maintainer/pi-update-source.maintest.ts +48 -18
- package/tests/model-fallback-policy.test.ts +26 -7
- package/tests/nan-provider-runtime.test.ts +17 -3
- package/tests/nan-provider.test.ts +111 -56
- package/tests/native-review-capability-contract.test.ts +11 -1
- package/tests/native-review-cli-nonblocking-findings.test.ts +165 -0
- package/tests/native-review-parity.test.ts +24 -5
- package/tests/native-review-refusal-identity.test.ts +25 -0
- package/tests/no-self-pause-contract.test.ts +11 -3
- package/tests/odd-integration.test.ts +11 -3
- package/tests/odd-routing-contract.test.ts +80 -28
- package/tests/orchestrator-budget.test.ts +30 -5
- package/tests/orchestrator-consultation-sdk.test.ts +32 -6
- package/tests/orchestrator-delegation-mode.test.ts +2 -1
- package/tests/orchestrator-discovery.test.ts +28 -0
- package/tests/orchestrator-prompt-budget.test.ts +11 -2
- package/tests/orchestrator-prompt-diet-contract.test.ts +221 -0
- package/tests/orchestrator-rdd-ownership.test.ts +2 -1
- package/tests/orchestrator-work-search.test.ts +4 -2
- package/tests/package-files.test.ts +25 -1
- package/tests/package-manifest.test.ts +11 -10
- package/tests/parallel-reason-contract.test.ts +6 -3
- package/tests/permission-allowlist.test.ts +200 -30
- package/tests/persona-neutral-voseo.test.ts +4 -4
- package/tests/persona-reply-language.test.ts +1 -1
- package/tests/persona-single-channel.test.ts +13 -5
- package/tests/pi-update-launcher.test.ts +17 -7
- package/tests/pi-update-source.test.ts +113 -6
- package/tests/pi-update.test.ts +294 -19
- package/tests/pnpm-workspace-policy.test.ts +47 -0
- package/tests/primary-context-files.test.ts +233 -0
- package/tests/primary-context-three-files.test.ts +174 -0
- package/tests/provider-defect-handoff.test.ts +9 -2
- package/tests/rdd-aware-verification-contract.test.ts +1 -1
- package/tests/rdd-status-line.test.ts +94 -1
- package/tests/reply-language-anchor-placement.test.ts +184 -0
- package/tests/reply-language-anchor.test.ts +17 -1
- package/tests/request-context-append-only.test.ts +218 -0
- package/tests/request-context-placement.test.ts +148 -0
- package/tests/review-agent-end-preflight.test.ts +79 -1
- package/tests/review-candidate-view.test.ts +65 -0
- package/tests/review-continuation-registry.test.ts +31 -0
- package/tests/review-contract-prompt.test.ts +1 -1
- package/tests/review-controller.test.ts +2 -1
- package/tests/review-coordinator-correction-gate.test.ts +105 -0
- package/tests/review-coordinator-findings.test.ts +206 -0
- package/tests/review-coordinator-nonblocking-scope.test.ts +169 -0
- package/tests/review-coordinator.test.ts +271 -4
- package/tests/review-delivery-preflight.test.ts +462 -0
- package/tests/review-due-compaction.test.ts +31 -0
- package/tests/review-due-public-boundary.test.ts +26 -0
- package/tests/review-integration-nonblocking-findings.test.ts +108 -0
- package/tests/review-json-arguments.test.ts +41 -2
- package/tests/review-ledger-contract.test.ts +19 -40
- package/tests/review-loadout-rdd-off-sdk.test.ts +30 -1
- package/tests/review-one-call-findings.test.ts +131 -0
- package/tests/review-one-call-followups.test.ts +308 -0
- package/tests/review-one-call-reviewer-requests.test.ts +207 -0
- package/tests/review-one-call.test.ts +452 -0
- package/tests/review-relay-transport-agent.test.ts +28 -1
- package/tests/review-reviewer-evidence.test.ts +41 -1
- package/tests/review-risk-assessment.test.ts +52 -5
- package/tests/review-run-statement-guidance-independent.test.ts +54 -0
- package/tests/review-session-standing-permission-controller.test.ts +32 -2
- package/tests/review-tool-prose-budget.test.ts +1 -0
- package/tests/reviewer-stream.test.ts +149 -0
- package/tests/session-profile-extension.test.ts +2 -2
- package/tests/shell-prompt.test.ts +17 -0
- package/tests/shell-usage.test.ts +59 -10
- package/tests/skill-contradictions-contract.test.ts +122 -0
- package/tests/skill-registry-watcher.test.ts +216 -2
- package/tests/skill-registry.test.ts +929 -306
- package/tests/support/design-canvas-dom.ts +369 -0
- package/tests/support/review-coordinator-runtime.ts +212 -17
- package/tests/task-size-routing-contract.test.ts +42 -11
- package/tests/test-strength-contract.test.ts +2 -1
- package/tests/todo-request-append-only.test.ts +214 -0
- package/tests/tool-batching-contract.test.ts +3 -1
- package/tests/update-agent-body-history.test.ts +138 -0
- package/tests/verification-tiers-contract.test.ts +229 -0
- package/tests/verifier-preparation.test.ts +229 -0
- package/tests/verify-agent-contract.test.ts +20 -2
- package/tests/verify-first-launch-contract.test.ts +87 -11
- package/tests/vim-editor-adapter.test.ts +2 -2
- package/tests/work-continuity-contract.test.ts +54 -11
- package/tests/writer-admission-messages.test.ts +232 -0
- package/tests/writer-batch-admission.test.ts +66 -0
- package/tests/writer-edit-surface-scope.test.ts +52 -20
- package/tests/writer-feature-document-admission.test.ts +184 -0
- package/tests/yolo-mode.test.ts +39 -0
- package/skills/_shared/review-ledger-contract.md +0 -106
- /package/contracts/review-provider-contract-mirror/{v1.4.0 → v1.5.0}/bundle/README.md +0 -0
- /package/contracts/review-provider-contract-mirror/{v1.4.0 → v1.5.0}/bundle/schemas/lens.schema.json +0 -0
- /package/contracts/review-provider-contract-mirror/{v1.4.0 → v1.5.0}/bundle/schemas/refuter.schema.json +0 -0
- /package/contracts/review-provider-contract-mirror/{v1.4.0 → v1.5.0}/bundle/schemas/targeted-validator.schema.json +0 -0
- /package/contracts/review-provider-contract-mirror/{v1.4.0 → v1.5.0}/bundle/vectors/lens.json +0 -0
- /package/contracts/review-provider-contract-mirror/{v1.4.0 → v1.5.0}/bundle/vectors/refuter.json +0 -0
- /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
|
-
|
|
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
|
-
|
|
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' :
|
|
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,
|
|
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' :
|
|
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
|
-
|
|
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
|
-
|
|
91
|
-
|
|
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
|
-
|
|
95
|
-
|
|
96
|
-
|
|
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].
|
|
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(
|
|
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
|
|
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: "
|
|
59
|
-
assert.equal(cooldown.available("
|
|
60
|
-
assert.equal(cooldown.available("
|
|
61
|
-
assert.equal(cooldown.available("
|
|
62
|
-
syncUsageCooldown({ provider: "
|
|
63
|
-
assert.equal(cooldown.available("
|
|
64
|
-
assert.equal(cooldown.available("
|
|
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
|
|
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,
|
|
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
|
|
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,
|
|
195
|
-
assert.equal(model?.maxTokens,
|
|
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("
|
|
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,
|
|
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,
|
|
218
|
-
assert.equal(model
|
|
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
|
|
228
|
-
model
|
|
229
|
-
assert.equal(provider.getModels().find((candidate) => candidate.id === model.id)
|
|
230
|
-
assert.equal(createNativeProvider().getModels().find((model) => model.id === "deepseek-v4-flash")
|
|
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
|
-
|
|
235
|
-
|
|
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
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
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
|
-
|
|
256
|
-
|
|
257
|
-
|
|
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("
|
|
262
|
-
|
|
263
|
-
assert.
|
|
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
|
-
|
|
284
|
-
|
|
285
|
-
|
|
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
|
-
|
|
293
|
-
|
|
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"],
|
|
351
|
-
["glm5.3-flash", 1_000_000, ["text", "image"],
|
|
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
|
});
|