fix(graceful-handoff): model-aware context window detection (v2.1.0)

Stop hook fallback antok 200K-vindu. På Opus 4.7 (faktisk 1M) kunne
auto-handoff fyre 5–7x for tidlig — estimert 70% når reell bruk var
~14%. Erstatter enkel fallback med 4-stegs resolution-kjede:

  1. payload.context_window.used_percentage  (autoritativ)
  2. payload.context_window.context_window_size + transcript-estimat
  3. MODEL_WINDOWS[payload.model.id] + estimat
  4. FALLBACK_WINDOW=1_000_000 + estimat (2026-default)

additionalContext-meldinger inkluderer nå [kilde: <source>] for innsyn.
Brief som kilde-artefakt i docs/brief-context-window-detection.md.
6 nye tester (57 totalt). Ingen regresjoner.
This commit is contained in:
Kjell Tore Guttormsen 2026-05-01 09:08:24 +02:00
commit 40a82ccdb4
10 changed files with 347 additions and 34 deletions

View file

@ -1,4 +1,4 @@
// plugin-manifest.test.mjs — verify plugin.json schema for v2.0
// plugin-manifest.test.mjs — verify plugin.json schema for v2.1
import { test } from 'node:test';
import { strict as assert } from 'node:assert';
@ -10,9 +10,17 @@ const __dirname = dirname(fileURLToPath(import.meta.url));
const MANIFEST = join(__dirname, '..', '.claude-plugin', 'plugin.json');
const CHANGELOG = join(__dirname, '..', 'CHANGELOG.md');
test('plugin.json version is 2.0.0', () => {
test('plugin.json version is 2.1.0', () => {
const m = JSON.parse(readFileSync(MANIFEST, 'utf-8'));
assert.equal(m.version, '2.0.0');
assert.equal(m.version, '2.1.0');
});
test('CHANGELOG has [2.1.0] entry mentioning model-aware fix', () => {
const c = readFileSync(CHANGELOG, 'utf-8');
assert.match(c, /## \[2\.1\.0\]/);
const match = c.match(/## \[2\.1\.0\][\s\S]*?(?=## \[2\.0\.0\]|$)/);
assert.ok(match, '[2.1.0] section missing');
assert.match(match[0], /modell-bevisst|model-aware|resolveContextSource/i);
});
test('plugin.json does NOT include auto_discover (not in documented schema)', () => {