Ship Assistent 0.14.1: Exact generate params and cheap park/warm.

Client always merges Exact turbo|raw steps/cfg/sigma before Generate so sparse LLM omissions and leftover SD 20/7 cannot stick; Ollama park/warm skip no-op /api/ps round-trips when the chat model is already unloaded or resident.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
Leonid Pershin
2026-08-23 06:50:08 +03:00
co-authored by Cursor
parent 9d2cbca8f2
commit 5f33130381
17 changed files with 1005 additions and 50 deletions
+84
View File
@@ -0,0 +1,84 @@
import { describe, it } from 'node:test';
import assert from 'node:assert/strict';
import {
detectKreaProfileName,
profileParamDefaults,
liveMatchesExactProfile,
exactKeysToForce,
numClose,
} from '../src/kreaProfile.js';
const PROFILES = {
turbo: { steps: 8, cfg: 1, sigma_shift: 1.15 },
raw: { steps: 28, cfg: 4.5, sigma_shift: 1.15 },
};
describe('kreaProfile', () => {
it('detectKreaProfileName: turbo token wins', () => {
assert.equal(detectKreaProfileName('realismByStableYogi_v25INT8Turbo', 'raw'), 'turbo');
assert.equal(detectKreaProfileName('Krea2 Turbo fp8', 'raw'), 'turbo');
});
it('detectKreaProfileName: raw token without turbo', () => {
assert.equal(detectKreaProfileName('Krea2 RAW Base', 'turbo'), 'raw');
});
it('detectKreaProfileName: unlabeled Yogi is not fake turbo', () => {
assert.equal(detectKreaProfileName('realismByStableYogi_v25', 'turbo'), 'raw');
assert.equal(detectKreaProfileName('realismByStableYogi', null), 'raw');
});
it('liveMatchesExactProfile rejects SD leftovers under turbo', () => {
const turbo = profileParamDefaults(PROFILES, 'turbo');
assert.equal(liveMatchesExactProfile({ steps: 20, cfg: 7, sigma_shift: 1.15 }, turbo), false);
assert.equal(liveMatchesExactProfile({ steps: 8, cfg: 1, sigma_shift: 1.15 }, turbo), true);
});
it('exactKeysToForce overwrites 20/7 unless intentional non-Exact patch or user session', () => {
const turbo = profileParamDefaults(PROFILES, 'turbo');
assert.deepEqual(
exactKeysToForce({ steps: 20, cfg: 7, sigma_shift: 1 }, turbo, {}),
['steps', 'cfg', 'sigma_shift'],
);
// Injected Exact values in the patch still force live leftovers.
assert.deepEqual(
exactKeysToForce(
{ steps: 20, cfg: 7, sigma_shift: 1 },
turbo,
{ patch: { steps: 8, cfg: 1, sigma_shift: 1.15 } },
),
['steps', 'cfg', 'sigma_shift'],
);
// Stale sessionExact without user intent must not block Exact.
assert.deepEqual(
exactKeysToForce(
{ steps: 20, cfg: 7, sigma_shift: 1.15 },
turbo,
{ sessionExact: { steps: 20 }, userParamIntent: false },
),
['steps', 'cfg'],
);
assert.deepEqual(
exactKeysToForce(
{ steps: 20, cfg: 7, sigma_shift: 1.15 },
turbo,
{ sessionExact: { steps: 20 }, userParamIntent: true },
),
['cfg'],
);
// Intentional non-Exact patch value is kept.
assert.deepEqual(
exactKeysToForce({ steps: 20, cfg: 7, sigma_shift: 1.15 }, turbo, { patch: { cfg: 7 } }),
['steps'],
);
assert.deepEqual(
exactKeysToForce({ steps: 8, cfg: 1, sigma_shift: 1.15 }, turbo, {}),
[],
);
});
it('numClose', () => {
assert.equal(numClose(1.15, 1.14), true);
assert.equal(numClose(1, 7), false);
});
});
+65
View File
@@ -13,6 +13,8 @@ import {
sessionFromLegacyParams,
toPersistParams,
resolveTurnIntent,
mergeExactParamsForGenerate,
resolveExactProfileDefaults,
} from '../src/session.js';
describe('patch.js', () => {
@@ -74,4 +76,67 @@ describe('session.js', () => {
assert.equal(intent.generate, false);
assert.equal(intent.vetoed, true);
});
it('mergeExactParamsForGenerate fills turbo profile when LLM omits steps/cfg', () => {
const exact = {
generation: { profile: 'turbo', steps: 8, cfg: 1, sigma_shift: 1.15 },
profiles: {
turbo: { steps: 8, cfg: 1, sigma_shift: 1.15 },
raw: { steps: 28, cfg: 4.5, sigma_shift: 1.15 },
},
};
const { patch, clearSessionKeys, profile } = mergeExactParamsForGenerate(
{ prompt: 'a fox', generate: true },
{
exact,
profiles: exact.profiles,
profileName: 'turbo',
sessionExact: { steps: 20, cfg: 7 },
userParamIntent: false,
},
);
assert.equal(profile, 'turbo');
assert.equal(patch.steps, 8);
assert.equal(patch.cfg, 1);
assert.equal(patch.sigma_shift, 1.15);
assert.deepEqual(clearSessionKeys.sort(), ['cfg', 'steps']);
});
it('mergeExactParamsForGenerate keeps user-intent sessionExact and explicit patch', () => {
const exact = {
generation: { steps: 8, cfg: 1 },
profiles: { raw: { steps: 28, cfg: 4.5, sigma_shift: 1.15 } },
};
const kept = mergeExactParamsForGenerate(
{ generate: true, actions: ['generate'] },
{
exact,
profiles: exact.profiles,
profileName: 'raw',
sessionExact: { steps: 20 },
userParamIntent: true,
},
);
assert.equal(kept.patch.steps, 20);
assert.equal(kept.patch.cfg, 4.5);
assert.deepEqual(kept.clearSessionKeys, []);
const explicit = mergeExactParamsForGenerate(
{ generate: true, steps: 12, cfg: 2 },
{ exact, profiles: exact.profiles, profileName: 'turbo' },
);
assert.equal(explicit.patch.steps, 12);
assert.equal(explicit.patch.cfg, 2);
});
it('resolveExactProfileDefaults picks raw over generation defaults', () => {
const d = resolveExactProfileDefaults({
exact: { generation: { steps: 8, cfg: 1, sigma_shift: 1.15 } },
profiles: { raw: { steps: 28, cfg: 4.5 } },
profileName: 'raw',
});
assert.equal(d.steps, 28);
assert.equal(d.cfg, 4.5);
assert.equal(d.sigma_shift, 1.15);
});
});