dsh-context-compression-improved 0.2.4 → 0.2.5

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 (127) hide show
  1. package/.gitattributes +2 -1
  2. package/.githooks/pre-push +37 -0
  3. package/.github/workflows/ci.yml +8 -8
  4. package/CHANGELOG.ja.md +169 -39
  5. package/CHANGELOG.ko.md +167 -39
  6. package/CHANGELOG.md +212 -16
  7. package/CHANGELOG.zh.md +152 -39
  8. package/CONTRIBUTING.md +22 -22
  9. package/README.ja.md +85 -104
  10. package/README.ko.md +85 -103
  11. package/README.md +1 -19
  12. package/README.zh.md +85 -101
  13. package/THIRD_PARTY_NOTICES.md +14 -14
  14. package/docs/compat-0.1.5-report.md +77 -0
  15. package/docs/installation.ja.md +78 -76
  16. package/docs/installation.ko.md +78 -76
  17. package/docs/installation.md +103 -76
  18. package/docs/installation.zh.md +100 -76
  19. package/docs/repair-log.md +657 -582
  20. package/eslint.config.js +30 -30
  21. package/package.json +75 -54
  22. package/packages/selector/README.md +7 -12
  23. package/packages/selector/README.zh.md +6 -13
  24. package/packages/selector/THIRD_PARTY_NOTICES.md +32 -38
  25. package/packages/selector/cordis.patch.yml +27 -19
  26. package/packages/selector/dsh.plugin.json +16 -16
  27. package/packages/selector/lib/client.d.ts +97 -5
  28. package/packages/selector/lib/client.js +1884 -92
  29. package/packages/selector/lib/config.js +863 -6
  30. package/packages/selector/lib/index.d.ts +29 -21
  31. package/packages/selector/lib/index.js +424 -18
  32. package/packages/selector/lib/invariant.js +4 -4
  33. package/packages/selector/lib/pruner.d.ts +179 -4
  34. package/packages/selector/lib/pruner.js +1406 -371
  35. package/packages/selector/lib/style.css +42 -0
  36. package/packages/selector/lib/tail-trim.js +13 -4
  37. package/packages/selector/package.json +18 -27
  38. package/packages/selector/screenshots.json +3 -6
  39. package/packages/selector/src/client/CompressionProfileControls.tsx +293 -229
  40. package/packages/selector/src/client/CompressionProfileSelector.module.css +199 -170
  41. package/packages/selector/src/client/CompressionProfileSelector.tsx +85 -79
  42. package/packages/selector/src/client/EstimatorControls.tsx +277 -281
  43. package/packages/selector/src/client/decode.ts +57 -49
  44. package/packages/selector/src/client/index.ts +200 -62
  45. package/packages/selector/src/client/locales/de.ts +141 -0
  46. package/packages/selector/src/client/locales/es.ts +141 -0
  47. package/packages/selector/src/client/locales/fr.ts +141 -0
  48. package/packages/selector/src/client/locales/it.ts +141 -0
  49. package/packages/selector/src/client/locales/ja.ts +141 -0
  50. package/packages/selector/src/client/locales/ko.ts +141 -0
  51. package/packages/selector/src/client/locales/ru.ts +141 -0
  52. package/packages/selector/src/client/locales.ts +282 -198
  53. package/packages/selector/src/client/monitor-fab.ts +336 -0
  54. package/packages/selector/src/client/preset-options.ts +88 -70
  55. package/packages/selector/src/client/savings-card.tsx +150 -0
  56. package/packages/selector/src/client/settings-section.tsx +140 -126
  57. package/packages/selector/src/deepseek-v4-tokenizer.ts +205 -210
  58. package/packages/selector/src/index.ts +671 -327
  59. package/packages/selector/src/invariant.ts +113 -113
  60. package/packages/selector/src/profiles.ts +431 -342
  61. package/packages/selector/src/pruner/state.ts +57 -43
  62. package/packages/selector/src/pruner.ts +2736 -2154
  63. package/packages/selector/src/runtime/audit.ts +303 -231
  64. package/packages/selector/src/runtime/config.ts +756 -642
  65. package/packages/selector/src/runtime/measurement.ts +436 -432
  66. package/packages/selector/src/runtime/monitor.ts +235 -0
  67. package/packages/selector/src/runtime/retrieve.ts +479 -457
  68. package/packages/selector/src/runtime/savings.ts +337 -0
  69. package/packages/selector/src/runtime/session-events.ts +30 -17
  70. package/packages/selector/src/runtime/summary-command.ts +127 -0
  71. package/packages/selector/src/runtime/tail-trim.ts +166 -166
  72. package/packages/selector/src/runtime/tokenpilot/advisor-prompt.ts +233 -0
  73. package/packages/selector/src/runtime/tokenpilot/advisor-state.ts +204 -0
  74. package/packages/selector/src/runtime/tokenpilot/advisor.ts +419 -0
  75. package/packages/selector/src/runtime/tokenpilot/benefit.ts +200 -0
  76. package/packages/selector/src/runtime/tokenpilot/estimator.ts +151 -183
  77. package/packages/selector/src/runtime/tokenpilot/intent-fold.ts +53 -0
  78. package/packages/selector/src/runtime/tokenpilot/intent-gate.ts +65 -0
  79. package/packages/selector/src/runtime/tokenpilot/intent-input-mask.ts +125 -0
  80. package/packages/selector/src/runtime/tokenpilot/intent-range.ts +37 -0
  81. package/packages/selector/src/runtime/tokenpilot/sidechannel.ts +303 -275
  82. package/packages/selector/src/runtime/types.ts +365 -325
  83. package/packages/selector/tests/advisor-report.host.spec.ts +223 -0
  84. package/packages/selector/tests/auto-compact.client.spec.tsx +214 -226
  85. package/packages/selector/tests/built/client-artifact.spec.ts +59 -51
  86. package/packages/selector/tests/code-skeleton.client.spec.ts +91 -88
  87. package/packages/selector/tests/custom-contract.client.spec.ts +205 -202
  88. package/packages/selector/tests/estimator-channel.client.spec.tsx +253 -247
  89. package/packages/selector/tests/estimator-route-registration.host.spec.ts +194 -176
  90. package/packages/selector/tests/host-preset-overlay.host.spec.ts +206 -204
  91. package/packages/selector/tests/monitor-fab.client.spec.ts +138 -0
  92. package/packages/selector/tests/preset-options-write.client.spec.ts +207 -181
  93. package/packages/selector/tests/preset-overlay-loader.e2e.host.spec.ts +201 -196
  94. package/packages/selector/tests/preset-overlay.host.spec.ts +8 -18
  95. package/packages/selector/tests/profiles.client.spec.tsx +436 -434
  96. package/packages/selector/tests/public/package-contract.client.spec.ts +78 -33
  97. package/packages/selector/tests/runtime/advice-never-withholds.host.spec.ts +232 -0
  98. package/packages/selector/tests/runtime/advisor-invariant.spec.ts +272 -0
  99. package/packages/selector/tests/runtime/advisor.spec.ts +226 -0
  100. package/packages/selector/tests/runtime/audit.spec.ts +275 -172
  101. package/packages/selector/tests/runtime/deprecated-preset-options.spec.ts +96 -0
  102. package/packages/selector/tests/runtime/intent-gate.spec.ts +62 -0
  103. package/packages/selector/tests/runtime/intent-summary.spec.ts +156 -0
  104. package/packages/selector/tests/runtime/monitor.spec.ts +301 -0
  105. package/packages/selector/tests/runtime/public/public-runtime.spec.ts +2724 -2702
  106. package/packages/selector/tests/runtime/savings.spec.ts +120 -0
  107. package/packages/selector/tests/runtime/session-events.spec.ts +27 -27
  108. package/packages/selector/tests/runtime/summary-command.spec.ts +154 -0
  109. package/packages/selector/tests/runtime/tokenpilot/benefit.spec.ts +217 -0
  110. package/packages/selector/tests/runtime/tokenpilot/estimator.spec.ts +79 -56
  111. package/packages/selector/tests/runtime/tokenpilot/profile-baseline.spec.ts +116 -100
  112. package/packages/selector/tests/settings-seat.client.spec.ts +130 -0
  113. package/packages/selector/tests/standing-generation.host.spec.ts +142 -87
  114. package/packages/selector/tests/subagent-cache-reuse.host.spec.ts +253 -250
  115. package/pnpm-workspace.yaml +66 -19
  116. package/scripts/capture-profile-baseline.mjs +42 -0
  117. package/scripts/generate-tokenizer-fixtures.py +81 -81
  118. package/scripts/generate-vision-fixtures.py +208 -208
  119. package/scripts/{packed-components-smoke.ts → packed-components-smoke.mjs} +732 -713
  120. package/scripts/{packed-install-e2e.ts → packed-install-e2e.mjs} +1273 -1072
  121. package/scripts/toolclass-corpus-replay.mjs +281 -273
  122. package/scripts/{verify-release.ts → verify-release.mjs} +318 -300
  123. package/tests/TEST_INVENTORY.md +41 -42
  124. package/scripts/capture-profile-baseline.ts +0 -80
  125. package/tsconfig.scripts.json +0 -13
  126. /package/{packages/selector/assets/screenshots → docs/assets}/context-compression-selector-profiles.jpg +0 -0
  127. /package/{packages/selector/assets/screenshots → docs/assets}/context-compression-selector-settings.png +0 -0
@@ -15,11 +15,11 @@ import CommandRuntime from '@deepseek-ai/dsh-commands'
15
15
  import LlmRuntime from '@deepseek-ai/dsh-llm'
16
16
  import SessionStore from '@deepseek-ai/dsh-session'
17
17
  import SystemPrompt from '@deepseek-ai/dsh-system-prompt'
18
+ import SessionProjectionRegistry from '@deepseek-ai/dsh-session-projection'
18
19
  import TokenMeter from '@deepseek-ai/dsh-token-meter'
19
20
  import ToolRuntime from '@deepseek-ai/dsh-tools'
20
21
  import {
21
22
  SettingsProvider,
22
- settingsNamespace,
23
23
  type SettingsNamespace,
24
24
  } from '@deepseek-ai/dsh-settings'
25
25
  import { pathToFileURL } from 'node:url'
@@ -37,6 +37,9 @@ import type {
37
37
  PresetOverlayMetadataIo,
38
38
  } from '../src/preset-overlay.ts'
39
39
 
40
+ // 0.1.5 removed the settingsNamespace() wrapper; namespaces are validated at runtime.
41
+ const nsBrand = (value: string): SettingsNamespace => value as unknown as SettingsNamespace
42
+
40
43
  let root: string | undefined
41
44
  let ctx: Context | undefined
42
45
 
@@ -98,6 +101,37 @@ async function overlayFiles(sourceMarker: string): Promise<{ path: string, rende
98
101
  return files
99
102
  }
100
103
 
104
+ /**
105
+ * The mtime this platform actually persists for one given stamp.
106
+ *
107
+ * `node:fs` `utimes` writes the seconds component through a 32-bit field on
108
+ * Windows: on node v22 win32, `utimes(file, 4677832452 s)` reads back as
109
+ * `382865156 s` — exactly `seconds >>> 0` — while sub-second precision
110
+ * survives. The standing stamp deliberately parks identities around year 2162
111
+ * (`STANDING_MTIME_EPOCH_SECONDS + 0xffffffff`, src/preset-overlay.ts), so its
112
+ * seconds component sits past that 2^32-second horizon (max year 2106) and the
113
+ * persisted literal differs on that platform. Deterministically so: the wrap is
114
+ * a pure function of the identity stamp, which is why identity → mtime stays
115
+ * stable and the collision escalation still absorbs any merge.
116
+ *
117
+ * Instead of hardcoding the platform or weakening the assertion, calibrate:
118
+ * ask the filesystem what it stores for exactly this stamp, then require the
119
+ * overlay to persist that same value. On a platform with a full-width seconds
120
+ * field this collapses to the stamp itself, so the assertion stays strict.
121
+ */
122
+ async function platformPersistedMs(stampMs: number): Promise<number> {
123
+ const directory = await mkdtemp(join(tmpdir(), 'dsh-selector-mtime-probe-'))
124
+ const probe = join(directory, 'probe')
125
+ try {
126
+ await writeFile(probe, 'probe')
127
+ const stamp = new Date(stampMs)
128
+ await utimes(probe, stamp, stamp)
129
+ return (await stat(probe)).mtimeMs
130
+ } finally {
131
+ await rm(directory, { recursive: true, force: true })
132
+ }
133
+ }
134
+
101
135
  let sourceRoot: string | undefined
102
136
 
103
137
  /** Rewrite the source preset to an equal-length marker module. */
@@ -165,17 +199,6 @@ function coarseCollisionFixture(
165
199
  throw new Error('failed to find a deterministic 32-bit standing-stamp collision')
166
200
  }
167
201
 
168
- /**
169
- * Whole seconds as the filesystem observes them. Windows' utimes stores
170
- * timestamps as unsigned 32-bit seconds, so deterministic identity stamps
171
- * beyond 2106-02-07 (2^32 s) are observed there modulo 2^32 seconds; POSIX
172
- * filesystems observe the full stamp range.
173
- */
174
- function observableStampSeconds(stampMs: number): number {
175
- const seconds = Math.floor(stampMs / 1000)
176
- return process.platform === 'win32' ? seconds % 2 ** 32 : seconds
177
- }
178
-
179
202
  /**
180
203
  * Mount the full real stack, run `arrange`, capture the standing key and
181
204
  * generated file, run `act`, and assert the generation moved.
@@ -187,22 +210,24 @@ async function assertStandingSwitch(
187
210
  sourceRoot = rootPath
188
211
  ctx = new Context()
189
212
  ctx.baseUrl = `${pathToFileURL(rootPath).href}/`
190
- await ctx.plugin(Loader)
213
+ await ctx.plugin(Loader).await()
191
214
  ctx.loader.builtins.include = Include
192
215
  ctx.loader.builtins.group = Group
193
- await ctx.plugin(LlmRuntime)
194
- await ctx.plugin(SessionStore)
195
- await ctx.plugin(SystemPrompt, { persona: '' })
196
- await ctx.plugin(ToolRuntime)
197
- await ctx.plugin(AgentRegistry)
198
- await ctx.plugin(AgentLoop, { agents: [] })
199
- await ctx.plugin(CommandRuntime)
200
- await ctx.plugin(TokenMeter)
216
+ await ctx.plugin(LlmRuntime).await()
217
+ await ctx.plugin(SessionStore).await()
218
+ await ctx.plugin(SystemPrompt).await()
219
+ await ctx.plugin(ToolRuntime).await()
220
+ await ctx.plugin(AgentRegistry).await()
221
+ await ctx.plugin(AgentLoop).await()
222
+ await ctx.plugin(CommandRuntime).await()
223
+ await ctx.plugin(SessionProjectionRegistry).await()
224
+ await ctx.plugin(TokenMeter).await()
201
225
  await ctx.plugin(MemorySettings).await()
202
226
  await ctx.plugin({ apply }).await()
203
227
  await ctx.plugin(AgentPresets, {
204
228
  default: 'standard',
205
229
  roots: [{ path: rootPath, trust: 'system' }],
230
+ includeShippedRoot: false,
206
231
  includeUserRoot: false,
207
232
  }).await()
208
233
  const act = await arrange()
@@ -274,20 +299,22 @@ describe('real AgentPresets standing generations with the overlay threshold', ()
274
299
 
275
300
  ctx = new Context()
276
301
  ctx.baseUrl = `${pathToFileURL(rootPath).href}/`
277
- await ctx.plugin(Loader)
302
+ await ctx.plugin(Loader).await()
278
303
  ctx.loader.builtins.include = Include
279
304
  ctx.loader.builtins.group = Group
280
- await ctx.plugin(LlmRuntime)
281
- await ctx.plugin(SessionStore)
282
- await ctx.plugin(SystemPrompt, { persona: '' })
283
- await ctx.plugin(ToolRuntime)
284
- await ctx.plugin(AgentRegistry)
285
- await ctx.plugin(AgentLoop, { agents: [] })
286
- await ctx.plugin(CommandRuntime)
287
- await ctx.plugin(TokenMeter)
305
+ await ctx.plugin(LlmRuntime).await()
306
+ await ctx.plugin(SessionStore).await()
307
+ await ctx.plugin(SystemPrompt).await()
308
+ await ctx.plugin(ToolRuntime).await()
309
+ await ctx.plugin(AgentRegistry).await()
310
+ await ctx.plugin(AgentLoop).await()
311
+ await ctx.plugin(CommandRuntime).await()
312
+ await ctx.plugin(SessionProjectionRegistry).await()
313
+ await ctx.plugin(TokenMeter).await()
288
314
  await ctx.plugin(AgentPresets, {
289
315
  default: 'standard',
290
316
  roots: [{ path: rootPath, trust: 'system' }],
317
+ includeShippedRoot: false,
291
318
  includeUserRoot: false,
292
319
  }).await()
293
320
 
@@ -333,8 +360,17 @@ describe('real AgentPresets standing generations with the overlay threshold', ()
333
360
  expect(firstStat.size).toBe(secondStat.size)
334
361
  expect(firstStat.mtimeMs % 1000).toBe(0)
335
362
  expect(secondStat.mtimeMs % 1000).toBe(0)
336
- expect(firstStat.mtimeMs).toBe(observableStampSeconds(standingStampMsAtWindow(collision.firstIdentity, 0)) * 1000)
337
- expect(secondStat.mtimeMs).toBe(observableStampSeconds(standingStampMsAtWindow(collision.secondIdentity, 1)) * 1000)
363
+ // The coarse metadata surface floors both stamps to a whole second, and the
364
+ // platform may additionally wrap the seconds field (platformPersistedMs),
365
+ // so require exactly what the filesystem stores for those identity stamps.
366
+ const firstStamp = await platformPersistedMs(
367
+ Math.floor(standingStampMsAtWindow(collision.firstIdentity, 0) / 1000) * 1000,
368
+ )
369
+ const secondStamp = await platformPersistedMs(
370
+ Math.floor(standingStampMsAtWindow(collision.secondIdentity, 1) / 1000) * 1000,
371
+ )
372
+ expect(Math.floor(firstStat.mtimeMs / 1000)).toBe(Math.floor(firstStamp / 1000))
373
+ expect(Math.floor(secondStat.mtimeMs / 1000)).toBe(Math.floor(secondStamp / 1000))
338
374
 
339
375
  await installation.dispose()
340
376
  })
@@ -344,25 +380,27 @@ describe('real AgentPresets standing generations with the overlay threshold', ()
344
380
  sourceRoot = rootPath
345
381
  ctx = new Context()
346
382
  ctx.baseUrl = `${pathToFileURL(rootPath).href}/`
347
- await ctx.plugin(Loader)
383
+ await ctx.plugin(Loader).await()
348
384
  ctx.loader.builtins.include = Include
349
385
  ctx.loader.builtins.group = Group
350
- await ctx.plugin(LlmRuntime)
351
- await ctx.plugin(SessionStore)
352
- await ctx.plugin(SystemPrompt, { persona: '' })
353
- await ctx.plugin(ToolRuntime)
354
- await ctx.plugin(AgentRegistry)
355
- await ctx.plugin(AgentLoop, { agents: [] })
356
- await ctx.plugin(CommandRuntime)
357
- await ctx.plugin(TokenMeter)
386
+ await ctx.plugin(LlmRuntime).await()
387
+ await ctx.plugin(SessionStore).await()
388
+ await ctx.plugin(SystemPrompt).await()
389
+ await ctx.plugin(ToolRuntime).await()
390
+ await ctx.plugin(AgentRegistry).await()
391
+ await ctx.plugin(AgentLoop).await()
392
+ await ctx.plugin(CommandRuntime).await()
393
+ await ctx.plugin(SessionProjectionRegistry).await()
394
+ await ctx.plugin(TokenMeter).await()
358
395
  await ctx.plugin(MemorySettings).await()
359
396
  await ctx.plugin({ apply }).await()
360
397
  await ctx.plugin(AgentPresets, {
361
398
  default: 'standard',
362
399
  roots: [{ path: rootPath, trust: 'system' }],
400
+ includeShippedRoot: false,
363
401
  includeUserRoot: false,
364
402
  }).await()
365
- const namespace = settingsNamespace('context-compression')
403
+ const namespace = nsBrand('context-compression')
366
404
  await ctx.settings.update(namespace, { autoCompact: { thresholdPercent: 80 } })
367
405
  const bundle = ctx.plugin({ apply: (child) => {
368
406
  apply(child, { presetOverlay: true })
@@ -384,11 +422,19 @@ describe('real AgentPresets standing generations with the overlay threshold', ()
384
422
  expect(files.length).toBeGreaterThanOrEqual(3)
385
423
  const buckets = await Promise.all(files.map(async file => Math.floor((await stat(file.path)).mtimeMs / 1000)))
386
424
  expect(new Set(buckets).size).toBe(buckets.length)
387
- // No staging leftovers survive a publish.
425
+ // No staging leftovers survive a publish. A spec file running in parallel
426
+ // disposes its own store while this scan runs, so a vanished directory means
427
+ // "no leftovers to find" rather than a failure (mirrors overlayFiles).
388
428
  const storeDirs = await Promise.all(
389
429
  (await readdir(tmpdir(), { withFileTypes: true }))
390
430
  .filter(entry => entry.isDirectory() && entry.name.startsWith('dsh-context-compression-presets-'))
391
- .map(async entry => readdir(join(tmpdir(), entry.name))),
431
+ .map(async entry => {
432
+ try {
433
+ return await readdir(join(tmpdir(), entry.name))
434
+ } catch {
435
+ return []
436
+ }
437
+ }),
392
438
  )
393
439
  expect(storeDirs.flat().some(name => name.endsWith('.tmp'))).toBe(false)
394
440
 
@@ -399,25 +445,27 @@ describe('real AgentPresets standing generations with the overlay threshold', ()
399
445
  const rootPath = await presetsRoot()
400
446
  ctx = new Context()
401
447
  ctx.baseUrl = `${pathToFileURL(rootPath).href}/`
402
- await ctx.plugin(Loader)
448
+ await ctx.plugin(Loader).await()
403
449
  ctx.loader.builtins.include = Include
404
450
  ctx.loader.builtins.group = Group
405
- await ctx.plugin(LlmRuntime)
406
- await ctx.plugin(SessionStore)
407
- await ctx.plugin(SystemPrompt, { persona: '' })
408
- await ctx.plugin(ToolRuntime)
409
- await ctx.plugin(AgentRegistry)
410
- await ctx.plugin(AgentLoop, { agents: [] })
411
- await ctx.plugin(CommandRuntime)
412
- await ctx.plugin(TokenMeter)
451
+ await ctx.plugin(LlmRuntime).await()
452
+ await ctx.plugin(SessionStore).await()
453
+ await ctx.plugin(SystemPrompt).await()
454
+ await ctx.plugin(ToolRuntime).await()
455
+ await ctx.plugin(AgentRegistry).await()
456
+ await ctx.plugin(AgentLoop).await()
457
+ await ctx.plugin(CommandRuntime).await()
458
+ await ctx.plugin(SessionProjectionRegistry).await()
459
+ await ctx.plugin(TokenMeter).await()
413
460
  await ctx.plugin(MemorySettings).await()
414
461
  await ctx.plugin({ apply }).await()
415
462
  await ctx.plugin(AgentPresets, {
416
463
  default: 'standard',
417
464
  roots: [{ path: rootPath, trust: 'system' }],
465
+ includeShippedRoot: false,
418
466
  includeUserRoot: false,
419
467
  }).await()
420
- const namespace = settingsNamespace('context-compression')
468
+ const namespace = nsBrand('context-compression')
421
469
  await ctx.settings.update(namespace, { autoCompact: { thresholdPercent: 73 } })
422
470
  const bundle = ctx.plugin({ apply: (child) => {
423
471
  apply(child, { presetOverlay: true })
@@ -451,8 +499,9 @@ describe('real AgentPresets standing generations with the overlay threshold', ()
451
499
  ? /standard-([0-9a-f]+)\.agent\.cordis\.yml$/u.exec(files[0]!.path)?.[1]
452
500
  : undefined
453
501
  expect(identity).toBeDefined()
502
+ const persistedStamp = await platformPersistedMs(standingStampMs(identity as string))
454
503
  expect(Math.floor(details.mtimeMs / 1000))
455
- .toBe(observableStampSeconds(standingStampMs(identity as string)))
504
+ .toBe(Math.floor(persistedStamp / 1000))
456
505
  const observedSubSecond = details.mtimeMs % 1000
457
506
  const expectedSubSecond = standingStampMs(identity as string) % 1000
458
507
  expect(observedSubSecond === 0 || Math.abs(observedSubSecond - expectedSubSecond) < 1).toBe(true)
@@ -462,7 +511,7 @@ describe('real AgentPresets standing generations with the overlay threshold', ()
462
511
 
463
512
  it('switches the standing generation for an equal-length threshold change', async () => {
464
513
  await assertStandingSwitch(async () => {
465
- const namespace = settingsNamespace('context-compression')
514
+ const namespace = nsBrand('context-compression')
466
515
  await ctx!.settings.update(namespace, { autoCompact: { thresholdPercent: 70 } })
467
516
  return async () => ctx!.settings.update(namespace, { autoCompact: { thresholdPercent: 80 } })
468
517
  })
@@ -470,7 +519,7 @@ describe('real AgentPresets standing generations with the overlay threshold', ()
470
519
 
471
520
  it('switches the standing generation for an equal-length source change at a fixed threshold', async () => {
472
521
  await assertStandingSwitch(async () => {
473
- const namespace = settingsNamespace('context-compression')
522
+ const namespace = nsBrand('context-compression')
474
523
  await ctx!.settings.update(namespace, { autoCompact: { thresholdPercent: 80 } })
475
524
  return async () => {
476
525
  await rewriteSourceMarker('marker-bbbbbbbbbb.mjs')
@@ -483,25 +532,27 @@ describe('real AgentPresets standing generations with the overlay threshold', ()
483
532
  sourceRoot = rootPath
484
533
  ctx = new Context()
485
534
  ctx.baseUrl = `${pathToFileURL(rootPath).href}/`
486
- await ctx.plugin(Loader)
535
+ await ctx.plugin(Loader).await()
487
536
  ctx.loader.builtins.include = Include
488
537
  ctx.loader.builtins.group = Group
489
- await ctx.plugin(LlmRuntime)
490
- await ctx.plugin(SessionStore)
491
- await ctx.plugin(SystemPrompt, { persona: '' })
492
- await ctx.plugin(ToolRuntime)
493
- await ctx.plugin(AgentRegistry)
494
- await ctx.plugin(AgentLoop, { agents: [] })
495
- await ctx.plugin(CommandRuntime)
496
- await ctx.plugin(TokenMeter)
538
+ await ctx.plugin(LlmRuntime).await()
539
+ await ctx.plugin(SessionStore).await()
540
+ await ctx.plugin(SystemPrompt).await()
541
+ await ctx.plugin(ToolRuntime).await()
542
+ await ctx.plugin(AgentRegistry).await()
543
+ await ctx.plugin(AgentLoop).await()
544
+ await ctx.plugin(CommandRuntime).await()
545
+ await ctx.plugin(SessionProjectionRegistry).await()
546
+ await ctx.plugin(TokenMeter).await()
497
547
  await ctx.plugin(MemorySettings).await()
498
548
  await ctx.plugin({ apply }).await()
499
549
  await ctx.plugin(AgentPresets, {
500
550
  default: 'standard',
501
551
  roots: [{ path: rootPath, trust: 'system' }],
552
+ includeShippedRoot: false,
502
553
  includeUserRoot: false,
503
554
  }).await()
504
- const namespace = settingsNamespace('context-compression')
555
+ const namespace = nsBrand('context-compression')
505
556
  await ctx.settings.update(namespace, { autoCompact: { thresholdPercent: 80 } })
506
557
 
507
558
  const presets = ctx.agentPresets as unknown as OverlayableAgentPresets
@@ -547,25 +598,27 @@ describe('real AgentPresets standing generations with the overlay threshold', ()
547
598
  const rootPath = await presetsRoot()
548
599
  ctx = new Context()
549
600
  ctx.baseUrl = `${pathToFileURL(rootPath).href}/`
550
- await ctx.plugin(Loader)
601
+ await ctx.plugin(Loader).await()
551
602
  ctx.loader.builtins.include = Include
552
603
  ctx.loader.builtins.group = Group
553
- await ctx.plugin(LlmRuntime)
554
- await ctx.plugin(SessionStore)
555
- await ctx.plugin(SystemPrompt, { persona: '' })
556
- await ctx.plugin(ToolRuntime)
557
- await ctx.plugin(AgentRegistry)
558
- await ctx.plugin(AgentLoop, { agents: [] })
559
- await ctx.plugin(CommandRuntime)
560
- await ctx.plugin(TokenMeter)
604
+ await ctx.plugin(LlmRuntime).await()
605
+ await ctx.plugin(SessionStore).await()
606
+ await ctx.plugin(SystemPrompt).await()
607
+ await ctx.plugin(ToolRuntime).await()
608
+ await ctx.plugin(AgentRegistry).await()
609
+ await ctx.plugin(AgentLoop).await()
610
+ await ctx.plugin(CommandRuntime).await()
611
+ await ctx.plugin(SessionProjectionRegistry).await()
612
+ await ctx.plugin(TokenMeter).await()
561
613
  await ctx.plugin(MemorySettings).await()
562
614
  await ctx.plugin({ apply }).await()
563
615
  await ctx.plugin(AgentPresets, {
564
616
  default: 'standard',
565
617
  roots: [{ path: rootPath, trust: 'system' }],
618
+ includeShippedRoot: false,
566
619
  includeUserRoot: false,
567
620
  }).await()
568
- const namespace = settingsNamespace('context-compression')
621
+ const namespace = nsBrand('context-compression')
569
622
  await ctx.settings.update(namespace, { autoCompact: { thresholdPercent: 73 } })
570
623
  const bundle = ctx.plugin({ apply: (child) => {
571
624
  apply(child, { presetOverlay: true })
@@ -592,25 +645,27 @@ describe('real AgentPresets standing generations with the overlay threshold', ()
592
645
  const rootPath = await presetsRoot()
593
646
  ctx = new Context()
594
647
  ctx.baseUrl = `${pathToFileURL(rootPath).href}/`
595
- await ctx.plugin(Loader)
648
+ await ctx.plugin(Loader).await()
596
649
  ctx.loader.builtins.include = Include
597
650
  ctx.loader.builtins.group = Group
598
- await ctx.plugin(LlmRuntime)
599
- await ctx.plugin(SessionStore)
600
- await ctx.plugin(SystemPrompt, { persona: '' })
601
- await ctx.plugin(ToolRuntime)
602
- await ctx.plugin(AgentRegistry)
603
- await ctx.plugin(AgentLoop, { agents: [] })
604
- await ctx.plugin(CommandRuntime)
605
- await ctx.plugin(TokenMeter)
651
+ await ctx.plugin(LlmRuntime).await()
652
+ await ctx.plugin(SessionStore).await()
653
+ await ctx.plugin(SystemPrompt).await()
654
+ await ctx.plugin(ToolRuntime).await()
655
+ await ctx.plugin(AgentRegistry).await()
656
+ await ctx.plugin(AgentLoop).await()
657
+ await ctx.plugin(CommandRuntime).await()
658
+ await ctx.plugin(SessionProjectionRegistry).await()
659
+ await ctx.plugin(TokenMeter).await()
606
660
  await ctx.plugin(MemorySettings).await()
607
661
  await ctx.plugin({ apply }).await()
608
662
  await ctx.plugin(AgentPresets, {
609
663
  default: 'standard',
610
664
  roots: [{ path: rootPath, trust: 'system' }],
665
+ includeShippedRoot: false,
611
666
  includeUserRoot: false,
612
667
  }).await()
613
- const namespace = settingsNamespace('context-compression')
668
+ const namespace = nsBrand('context-compression')
614
669
  await ctx.settings.update(namespace, { autoCompact: { thresholdPercent: 70 } })
615
670
  const bundle = ctx.plugin({ apply: (child) => {
616
671
  apply(child, { presetOverlay: true })