@yuriai/web 0.2.0-beta.1 → 0.2.0-beta.3

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 (92) hide show
  1. package/README.md +1 -1
  2. package/dist/assets/{AssistantView-CKSBN9HQ.js → AssistantView-CLKNSmK0.js} +3 -3
  3. package/dist/assets/{DiagramView-RmE0gXVx.js → DiagramView-C_urOuXu.js} +1 -1
  4. package/dist/assets/{GuiPluginSurface-DWGYdQLr.js → GuiPluginSurface-736HcjIN.js} +1 -1
  5. package/dist/assets/{GuiPluginWindow-CLgceKTX.js → GuiPluginWindow-BHbqKl7P.js} +1 -1
  6. package/dist/assets/{MarkdownRenderer-7zj1J9EY.js → MarkdownRenderer-CRYQRJ6O.js} +2 -2
  7. package/dist/assets/{MarkdownRendererImpl-lXwdc-kG.js → MarkdownRendererImpl-DJcRI0hT.js} +1 -1
  8. package/dist/assets/{MarkstreamRendererImpl-B5or38qI.js → MarkstreamRendererImpl-BffzWk4G.js} +1 -1
  9. package/dist/assets/{MobileDetailNavigation-K8AyOZUE.js → MobileDetailNavigation-BEB3hlJ1.js} +1 -1
  10. package/dist/assets/{MobileShareBridge-9RP7ni2F.js → MobileShareBridge-9gdwpoAb.js} +1 -1
  11. package/dist/assets/{MobileTabPageHeader-ZZTO3phT.js → MobileTabPageHeader-Dh5mqOcK.js} +1 -1
  12. package/dist/assets/{MultiRunWindow-CLGnrnLn.js → MultiRunWindow-Bi3aly9b.js} +1 -1
  13. package/dist/assets/{SettingsView-BlruenEQ.js → SettingsView-CIPoAFnD.js} +1 -1
  14. package/dist/assets/{SettingsWindow-B-z25PVS.js → SettingsWindow-B24JgZnf.js} +1 -1
  15. package/dist/assets/{TerminalView-CRyh7cpp.js → TerminalView-BWutwGtP.js} +1 -1
  16. package/dist/assets/{ToolOutputDialog-CMiPmx7q.js → ToolOutputDialog-gcD1fSaB.js} +1 -1
  17. package/dist/assets/{appThemeRegistry-e1zU7R2C.js → appThemeRegistry-ktbSDOFk.js} +1 -1
  18. package/dist/assets/{capgoAdapter-CEzjhZ15.js → capgoAdapter-3Uy_m4Za.js} +1 -1
  19. package/dist/assets/{device-CCFr0Aht.js → device-B-trKdcC.js} +1 -1
  20. package/dist/assets/{dropdown-menu.styles-4tACRbYU.js → dropdown-menu.styles-B-E_v3QZ.js} +1 -1
  21. package/dist/assets/{fileMentionTouchSelection-BCTXha9_.js → fileMentionTouchSelection-bVnePHdS.js} +1 -1
  22. package/dist/assets/{fileReferenceActions-B0iaTe0c.js → fileReferenceActions-Ca5wtvOa.js} +1 -1
  23. package/dist/assets/{gitApi-DIwsfb2k.js → gitApi-DccSJMYl.js} +1 -1
  24. package/dist/assets/gui-DpIvy9qB.js +1 -0
  25. package/dist/assets/host-u2MH0QSP.js +1 -0
  26. package/dist/assets/{insertionBoundaries-CFDcBxaK.js → insertionBoundaries-BZgMtXXz.js} +1 -1
  27. package/dist/assets/{main-XMhFdW0K.js → main-DSa1W5SA.js} +2 -2
  28. package/dist/assets/{main-DBJ19laz.js → main-HBpfFsY-.js} +4 -4
  29. package/dist/assets/{mcpQueries-f0cDQQKu.js → mcpQueries-CFR_danB.js} +1 -1
  30. package/dist/assets/{miniChat-BVTtOggs.js → miniChat-DcG2PyMu.js} +2 -2
  31. package/dist/assets/{mobile-0X6dYZAB.js → mobile-DGUDmzLl.js} +2 -2
  32. package/dist/assets/{mobileBackNavigation-htjL23a2.js → mobileBackNavigation-i40NmwxE.js} +1 -1
  33. package/dist/assets/{multirun-mBD1Y3Eb.js → multirun-D-E3RJbf.js} +1 -1
  34. package/dist/assets/{native-config-B9V18QgV.js → native-config-BU8ochmh.js} +1 -1
  35. package/dist/assets/{platform-HIkm-CHn.js → platform-CxNhofMC.js} +3 -3
  36. package/dist/assets/{projectMeta-tXx77gZG.js → projectMeta-Ddp_NxcI.js} +1 -1
  37. package/dist/assets/{readiness-Da7jHHss.js → readiness-CydU25xC.js} +1 -1
  38. package/dist/assets/{renderElectronMiniChatApp-DwIydDUm.js → renderElectronMiniChatApp-C11y4O8g.js} +2 -2
  39. package/dist/assets/{renderMobileApp-TNkNM5Zx.js → renderMobileApp-BeJqGLid.js} +4 -4
  40. package/dist/assets/{runtimeConfig-ChR1FQv1.js → runtimeConfig-xiF5snk3.js} +1 -1
  41. package/dist/assets/{runtimeEndpointReset-CxMEqgDx.js → runtimeEndpointReset-CWOI8alW.js} +3 -3
  42. package/dist/assets/{scheduledTaskNavigation-B71VHwFK.js → scheduledTaskNavigation-CE4sIXxf.js} +1 -1
  43. package/dist/assets/{sessionChangeSummary-DDbB-N5p.js → sessionChangeSummary-DA1ZMfkC.js} +1 -1
  44. package/dist/assets/{sessionLookup-CsJ8Vrq8.js → sessionLookup-Mz6LvD5p.js} +1 -1
  45. package/dist/assets/{sortable-tabs-strip-CnaQoAAB.js → sortable-tabs-strip-dKp0SH4C.js} +1 -1
  46. package/dist/assets/{speechSettingsQueries-X0jStYkm.js → speechSettingsQueries-CYiiOuya.js} +1 -1
  47. package/dist/assets/{terminalApi-DVZUO2Uv.js → terminalApi-Bs5skvIp.js} +1 -1
  48. package/dist/assets/{types-Dfj_Rn0L.js → types-DoaGaihV.js} +1 -1
  49. package/dist/assets/{useAppFontEffects-DDdQeaoM.js → useAppFontEffects-sz1UI2pZ.js} +5 -5
  50. package/dist/assets/{useDesktopWindowControlsLayout-BFyKfmUX.js → useDesktopWindowControlsLayout-D_0gn_5u.js} +1 -1
  51. package/dist/assets/{useEffectiveDirectory-CST6AXTm.js → useEffectiveDirectory-Ct1Akmfw.js} +1 -1
  52. package/dist/assets/{useFontPreferences-D-XYUHOV.js → useFontPreferences-n13Q1-rH.js} +1 -1
  53. package/dist/assets/{useMobileNavigationStore-BdWv0Da4.js → useMobileNavigationStore-BdTMlKQU.js} +5 -5
  54. package/dist/assets/{useWorkerHighlightedLines-OsRfq7LD.js → useWorkerHighlightedLines-B3R3cGBi.js} +1 -1
  55. package/dist/assets/vendor-opencode-client-BcpAhe9I.js +12 -0
  56. package/dist/assets/{vendor-opencode-plugin-DhwD3Tat.js → vendor-opencode-plugin-BglYYlJt.js} +1 -1
  57. package/dist/assets/vendor-solid-js-B2FO7pdm.js +1 -0
  58. package/dist/index.html +8 -8
  59. package/dist/mini-chat.html +8 -8
  60. package/dist/mobile.html +8 -8
  61. package/package.json +3 -3
  62. package/server/lib/content-search/DOCUMENTATION.md +17 -11
  63. package/server/lib/content-search/index.js +1 -0
  64. package/server/lib/content-search/runtime.js +50 -9
  65. package/server/lib/content-search/runtime.test.js +72 -1
  66. package/server/lib/content-search/service.js +12 -1
  67. package/server/lib/opencode/DOCUMENTATION.md +9 -9
  68. package/server/lib/opencode/ensure-cli.js +12 -14
  69. package/server/lib/opencode/ensure-cli.test.js +8 -8
  70. package/server/lib/opencode/env-runtime.test.js +1 -1
  71. package/server/lib/opencode/opencode2-pin.js +3 -4
  72. package/server/lib/opencode/opencode2-pin.test.js +5 -4
  73. package/server/lib/opencode/owned-runtime-upgrade.js +4 -11
  74. package/server/lib/opencode/owned-runtime-upgrade.test.js +4 -0
  75. package/server/lib/opencode/routes.js +2 -1
  76. package/server/lib/opencode/routes.test.js +1 -1
  77. package/server/lib/opencode/runtime-contract.js +3 -4
  78. package/server/lib/opencode/session-directory-runtime.js +2 -13
  79. package/server/lib/opencode/session-directory-runtime.test.js +69 -4
  80. package/server/lib/opencode/upgrade-screen.js +9 -5
  81. package/server/lib/opencode/upgrade-screen.test.js +20 -0
  82. package/server/lib/opencode/version-alignment.test.js +6 -6
  83. package/server/lib/session-index/DOCUMENTATION.md +18 -8
  84. package/server/lib/session-index/routes.js +3 -1
  85. package/server/lib/session-index/routes.test.js +2 -0
  86. package/server/lib/session-index/service.js +23 -0
  87. package/server/lib/session-index/sync-runtime.js +75 -20
  88. package/server/lib/session-index/sync-runtime.test.js +5 -5
  89. package/dist/assets/gui-CTnzY_cr.js +0 -1
  90. package/dist/assets/host-CEMl6ZlP.js +0 -1
  91. package/dist/assets/vendor-opencode-client-Eb-_7KbZ.js +0 -23
  92. package/dist/assets/vendor-solid-js-CXSXbuQO.js +0 -1
@@ -5,7 +5,7 @@ import path from 'node:path';
5
5
  import { createOpenCodeUpdateDiscovery } from './update-discovery.js';
6
6
  import { configureOpenCodeTerminalPath } from './terminal-path.js';
7
7
  import {
8
- PINNED_OPENCODE2_VERSION,
8
+ MINIMUM_OPENCODE2_VERSION,
9
9
  compareOpenCode2Versions,
10
10
  isAcceptableOpenCode2HealthVersion,
11
11
  isOpenCode2VersionAtLeast,
@@ -54,7 +54,7 @@ export function resolveYuriDataDir(env = process.env, homedir = os.homedir) {
54
54
  return path.join(home, '.config', 'yuri');
55
55
  }
56
56
 
57
- export function installedOpenCode2BinaryPath(version = PINNED_OPENCODE2_VERSION, options = {}) {
57
+ export function installedOpenCode2BinaryPath(version = MINIMUM_OPENCODE2_VERSION, options = {}) {
58
58
  const dataDir = options.dataDir || resolveYuriDataDir(options.env, options.homedir);
59
59
  return path.join(dataDir, 'opencode-cli', version, openCodeBinaryName(options.platform));
60
60
  }
@@ -160,7 +160,10 @@ const findBinary = (root, binaryName) => {
160
160
  };
161
161
 
162
162
  export async function installPinnedOpenCode2Cli(options = {}) {
163
- const version = options.version || PINNED_OPENCODE2_VERSION;
163
+ const version = options.version || await discoverLatestVersion();
164
+ if (!/^2\.\d+\.\d+$/.test(version) || (!options.version && !isOpenCode2VersionAtLeast(version))) {
165
+ throw new Error(`Invalid stable OpenCode installation target: ${version}`);
166
+ }
164
167
  const platform = options.platform || process.platform;
165
168
  const arch = options.arch || process.arch;
166
169
  const dataDir = options.dataDir || resolveYuriDataDir(options.env, options.homedir);
@@ -239,10 +242,10 @@ export async function installPinnedOpenCode2Cli(options = {}) {
239
242
 
240
243
  /**
241
244
  * Reuse any discovered acceptable 2.x CLI. Fresh installs resolve stable 2.x;
242
- * an explicit pin or an unavailable registry uses the tested version instead.
245
+ * registry failures remain errors when no usable local installation exists.
243
246
  */
244
247
  export async function ensurePinnedOpenCode2Cli(input = {}) {
245
- const pin = input.pin || PINNED_OPENCODE2_VERSION;
248
+ const pin = input.pin || MINIMUM_OPENCODE2_VERSION;
246
249
  const discoveredPath = typeof input.discoveredPath === 'string' ? input.discoveredPath.trim() : '';
247
250
  const autoInstall = input.autoInstall ?? isOpenCode2AutoInstallEnabled(input.env);
248
251
  const readVersion = typeof input.readVersion === 'function'
@@ -276,20 +279,15 @@ export async function ensurePinnedOpenCode2Cli(input = {}) {
276
279
 
277
280
  if (!autoInstall) {
278
281
  const error = new Error(
279
- `Unable to locate opencode ${pin}. Set OPENCODE_BINARY or install @opencode/cli@${pin}.`,
282
+ 'Unable to locate OpenCode 2. Set OPENCODE_BINARY or install @opencode/cli@2.',
280
283
  );
281
284
  error.code = 'OPENCODE_CLI_MISSING';
282
285
  throw error;
283
286
  }
284
287
 
285
- let target = pin;
286
- if (!input.pin) {
287
- try {
288
- const latest = await (input.resolveLatestVersion || discoverLatestVersion)();
289
- if (/^2\.\d+\.\d+$/.test(latest) && isOpenCode2VersionAtLeast(latest, pin)) target = latest;
290
- } catch {
291
- console.warn('[OpenCode] Latest version lookup failed; using the tested fallback version.');
292
- }
288
+ const target = input.pin || await (input.resolveLatestVersion || discoverLatestVersion)();
289
+ if (!/^2\.\d+\.\d+$/.test(target) || !isOpenCode2VersionAtLeast(target)) {
290
+ throw new Error(`Invalid stable OpenCode installation target: ${target}`);
293
291
  }
294
292
  const installedPath = await install({ ...input, version: target });
295
293
  const version = readVersion(installedPath);
@@ -2,7 +2,7 @@ import fs from 'node:fs';
2
2
  import os from 'node:os';
3
3
  import path from 'node:path';
4
4
  import { afterEach, describe, expect, it, vi } from 'vitest';
5
- import { PINNED_OPENCODE2_VERSION } from './opencode2-pin.js';
5
+ const PINNED_OPENCODE2_VERSION = '2.0.23';
6
6
  import { configureOpenCodeTerminalPath } from './terminal-path.js';
7
7
  import {
8
8
  ensurePinnedOpenCode2Cli,
@@ -45,11 +45,11 @@ describe('ensurePinnedOpenCode2Cli', () => {
45
45
 
46
46
  it.each(['1.18.4', '3.0.0', '2.9.1-beta.1', '2.0.1'])('never chooses an unsuitable fresh-install target %s', async (latest) => {
47
47
  const install = vi.fn(async () => '/installed/opencode');
48
- await ensurePinnedOpenCode2Cli({ dataDir: createTempDir('yuri-invalid-cli-'), install,
48
+ await expect(ensurePinnedOpenCode2Cli({ dataDir: createTempDir('yuri-invalid-cli-'), install,
49
49
  resolveLatestVersion: async () => latest,
50
50
  readVersion: (file) => file === '/installed/opencode' ? PINNED_OPENCODE2_VERSION : '',
51
- });
52
- expect(install).toHaveBeenCalledWith(expect.objectContaining({ version: PINNED_OPENCODE2_VERSION }));
51
+ })).rejects.toThrow('Invalid stable OpenCode installation target');
52
+ expect(install).not.toHaveBeenCalled();
53
53
  });
54
54
 
55
55
  it('reuses the newest verified cache offline instead of reinstalling the pin', async () => {
@@ -67,14 +67,14 @@ describe('ensurePinnedOpenCode2Cli', () => {
67
67
  expect(resolveLatestVersion).not.toHaveBeenCalled();
68
68
  });
69
69
 
70
- it('uses the tested pin when the registry is unavailable', async () => {
70
+ it('reports registry failure without installing an obsolete fallback', async () => {
71
71
  const dataDir = createTempDir('yuri-offline-cli-');
72
72
  const install = vi.fn(async () => '/installed/opencode');
73
- await ensurePinnedOpenCode2Cli({ dataDir, install,
73
+ await expect(ensurePinnedOpenCode2Cli({ dataDir, install,
74
74
  resolveLatestVersion: async () => { throw new Error('offline'); },
75
75
  readVersion: (file) => file === '/installed/opencode' ? PINNED_OPENCODE2_VERSION : '',
76
- });
77
- expect(install).toHaveBeenCalledWith(expect.objectContaining({ version: PINNED_OPENCODE2_VERSION }));
76
+ })).rejects.toThrow('offline');
77
+ expect(install).not.toHaveBeenCalled();
78
78
  });
79
79
 
80
80
  it('runs upgrade through the selected launch target and preserves its CLI entry path', async () => {
@@ -4,7 +4,7 @@ import os from 'node:os';
4
4
  import path from 'node:path';
5
5
  import { afterEach, describe, expect, it } from 'vitest';
6
6
  import { createOpenCodeEnvRuntime } from './env-runtime.js';
7
- import { PINNED_OPENCODE2_VERSION } from './opencode2-pin.js';
7
+ const PINNED_OPENCODE2_VERSION = '2.0.23';
8
8
 
9
9
  const originalOpencodeBinary = process.env.OPENCODE_BINARY;
10
10
  const originalComSpec = process.env.ComSpec;
@@ -1,5 +1,4 @@
1
- // Pinned desktop/runtime opencode2. Upgrade and prepare must not fall back to 1.18.x.
2
- export const PINNED_OPENCODE2_VERSION = '2.0.23';
1
+ // Runtime compatibility floor, independent of the latest stable installation target.
3
2
  export const MINIMUM_OPENCODE2_VERSION = '2.0.20';
4
3
 
5
4
  // Global npm/bun package that installs the opencode v2 binary (not 1.x opencode-ai).
@@ -66,7 +65,7 @@ export function resolveOpenCode2UpgradeTarget(target) {
66
65
  rejectOpenCode1xUpgradeTarget(trimmed);
67
66
  return trimmed;
68
67
  }
69
- return PINNED_OPENCODE2_VERSION;
68
+ throw new Error('Resolve a stable OpenCode 2.x version before upgrading');
70
69
  }
71
70
 
72
71
  /**
@@ -134,7 +133,7 @@ export function compareOpenCode2Versions(left, right) {
134
133
  return 0;
135
134
  }
136
135
 
137
- export function isOpenCode2VersionAtLeast(version, minimum = PINNED_OPENCODE2_VERSION) {
136
+ export function isOpenCode2VersionAtLeast(version, minimum = MINIMUM_OPENCODE2_VERSION) {
138
137
  if (!isAcceptableOpenCode2HealthVersion(version)) return false;
139
138
  return compareOpenCode2Versions(version, minimum) >= 0;
140
139
  }
@@ -1,7 +1,6 @@
1
1
  import { describe, expect, it } from 'vitest';
2
2
  import {
3
3
  OPENCODE2_NPM_PACKAGE,
4
- PINNED_OPENCODE2_VERSION,
5
4
  compareOpenCode2Versions,
6
5
  evaluateOpenCodeHealthBody,
7
6
  isAcceptableOpenCode2HealthVersion,
@@ -13,6 +12,8 @@ import {
13
12
  resolveOpenCode2UpgradeTarget,
14
13
  } from './opencode2-pin.js';
15
14
 
15
+ const PINNED_OPENCODE2_VERSION = '2.0.23';
16
+
16
17
  describe('opencode2 pin (ticket 12)', () => {
17
18
  it('rejects 1.x version strings and accepts the pinned v2', () => {
18
19
  expect(isOpenCode1xVersion('1.18.4')).toBe(true);
@@ -25,11 +26,11 @@ describe('opencode2 pin (ticket 12)', () => {
25
26
  expect(isOpenCode1xVersion(null)).toBe(false);
26
27
  });
27
28
 
28
- it('throws on 1.x upgrade targets and defaults empty to the pin', () => {
29
+ it('throws on 1.x or unresolved upgrade targets', () => {
29
30
  expect(() => rejectOpenCode1xUpgradeTarget('1.18.4')).toThrow(/1\.x/);
30
31
  expect(() => rejectOpenCode1xUpgradeTarget('1.18.4')).toThrow(expect.objectContaining({ code: 'OPENCODE_UPGRADE_1X_REFUSED' }));
31
- expect(resolveOpenCode2UpgradeTarget(undefined)).toBe(PINNED_OPENCODE2_VERSION);
32
- expect(resolveOpenCode2UpgradeTarget('')).toBe(PINNED_OPENCODE2_VERSION);
32
+ expect(() => resolveOpenCode2UpgradeTarget(undefined)).toThrow('Resolve a stable');
33
+ expect(() => resolveOpenCode2UpgradeTarget('')).toThrow('Resolve a stable');
33
34
  expect(resolveOpenCode2UpgradeTarget(PINNED_OPENCODE2_VERSION)).toBe(PINNED_OPENCODE2_VERSION);
34
35
  expect(() => resolveOpenCode2UpgradeTarget('1.18.18')).toThrow(/1\.x/);
35
36
  });
@@ -14,7 +14,6 @@
14
14
 
15
15
  import path from 'node:path';
16
16
  import {
17
- PINNED_OPENCODE2_VERSION,
18
17
  compareOpenCode2Versions,
19
18
  isOpenCode1xVersion,
20
19
  resolveOpenCode2UpgradeTarget,
@@ -176,15 +175,9 @@ export function buildUpgradeStatusSnapshot(input) {
176
175
  const serveVersion = normalizeRuntimeVersion(input.serveVersion);
177
176
  const cliVersion = normalizeRuntimeVersion(input.cliVersion);
178
177
  const currentVersion = serveVersion || cliVersion;
179
- let targetVersion = null;
180
- try {
181
- targetVersion = resolveOpenCode2UpgradeTarget(input.targetVersion ?? PINNED_OPENCODE2_VERSION);
182
- } catch {
183
- targetVersion = PINNED_OPENCODE2_VERSION;
184
- }
185
- if (isOpenCode1xVersion(targetVersion)) {
186
- targetVersion = PINNED_OPENCODE2_VERSION;
187
- }
178
+ const targetVersion = input.targetVersion
179
+ ? resolveOpenCode2UpgradeTarget(input.targetVersion)
180
+ : null;
188
181
 
189
182
  const contract = input.contract || evaluateRuntimeContract({
190
183
  serveVersion,
@@ -201,7 +194,7 @@ export function buildUpgradeStatusSnapshot(input) {
201
194
  && !isOpenCode1xVersion(currentVersion)
202
195
  && compareOpenCode2Versions(targetVersion, currentVersion) > 0,
203
196
  );
204
- const available = canManage && newerTarget ? true : (canManage ? false : null);
197
+ const available = canManage && targetVersion ? newerTarget : null;
205
198
 
206
199
  /** @type {string | null} */
207
200
  let reason = ownership.reason;
@@ -56,6 +56,10 @@ describe('owned runtime upgrade (ticket 12)', () => {
56
56
  });
57
57
 
58
58
  it('upgrade-status exposes manage rights and manual guidance', () => {
59
+ expect(buildUpgradeStatusSnapshot({
60
+ ownership: classifyRuntimeOwnership({ binarySource: 'installed', binaryPath: ownedBinary, dataDir }),
61
+ serveVersion: '2.2.0',
62
+ })).toMatchObject({ available: null, targetVersion: null });
59
63
  const globalStatus = buildUpgradeStatusSnapshot({
60
64
  ownership: classifyRuntimeOwnership({ isExternal: false, binarySource: 'path' }),
61
65
  serveVersion: '2.0.12',
@@ -285,6 +285,7 @@ export const registerOpenCodeRoutes = (app, dependencies) => {
285
285
  isSharedService: () => getIsSharedOpenCodeService() === true,
286
286
  install: (options) => installPinnedOpenCode2Cli({ ...options, dataDir: resolveDataDir() }),
287
287
  upgradeCli: upgradeOpenCodeCli,
288
+ resolveLatestVersion: discoverOpenCodeUpdate,
288
289
  readBinaryVersion: readOpenCode2BinaryVersion,
289
290
  });
290
291
 
@@ -343,7 +344,7 @@ export const registerOpenCodeRoutes = (app, dependencies) => {
343
344
  if (isOpenCode1xVersion(rawTarget)) {
344
345
  return res.status(400).json({
345
346
  success: false,
346
- error: 'OpenCode upgrade refuses 1.x targets. Only pinned opencode2 is allowed.',
347
+ error: 'OpenCode upgrade refuses 1.x targets. Only OpenCode 2.x is allowed.',
347
348
  errorCode: 'OPENCODE_UPGRADE_1X_REFUSED',
348
349
  });
349
350
  }
@@ -365,7 +365,7 @@ describe('opencode2 upgrade pin (ticket 12)', () => {
365
365
  getIsExternalOpenCode: () => true,
366
366
  getIsSharedOpenCodeService: () => true,
367
367
  getActiveSessionCount: () => 1,
368
- discoverOpenCodeUpdate: async () => ({ version: '2.0.23' }),
368
+ discoverOpenCodeUpdate: async () => '2.0.23',
369
369
  upgradeOpenCodeCli,
370
370
  forceResolvedOpenCodeBinary: vi.fn(),
371
371
  restartOpenCode,
@@ -13,7 +13,6 @@
13
13
  */
14
14
 
15
15
  import {
16
- PINNED_OPENCODE2_VERSION,
17
16
  MINIMUM_OPENCODE2_VERSION,
18
17
  compareOpenCode2Versions,
19
18
  isAcceptableOpenCode2HealthVersion,
@@ -239,7 +238,7 @@ export function evaluateRuntimeContract(input = {}) {
239
238
  versionMismatch,
240
239
  minVerifiedVersion: RUNTIME_CONTRACT_MIN_VERIFIED,
241
240
  maxVerifiedVersion: null,
242
- pinnedVersion: PINNED_OPENCODE2_VERSION,
241
+ pinnedVersion: null,
243
242
  capabilities,
244
243
  reasons,
245
244
  };
@@ -358,7 +357,7 @@ export function shouldBlockRuntimeContractExecution(method, pathWithQuery, contr
358
357
  export function formatRuntimeContractBlockedError(contract) {
359
358
  const serve = contract?.serveVersion ?? null;
360
359
  const min = contract?.minVerifiedVersion ?? RUNTIME_CONTRACT_MIN_VERIFIED;
361
- const pinned = contract?.pinnedVersion ?? PINNED_OPENCODE2_VERSION;
360
+ const pinned = 'latest stable 2.x';
362
361
  const reasons = Array.isArray(contract?.reasons) ? contract.reasons : [];
363
362
 
364
363
  if (reasons.includes('below-min-verified')) {
@@ -396,7 +395,7 @@ export function runtimeContractExecutionBlockedBody(contract) {
396
395
  serveVersion: contract?.serveVersion ?? null,
397
396
  minVerifiedVersion: contract?.minVerifiedVersion ?? null,
398
397
  maxVerifiedVersion: contract?.maxVerifiedVersion ?? null,
399
- pinnedVersion: contract?.pinnedVersion ?? PINNED_OPENCODE2_VERSION,
398
+ pinnedVersion: null,
400
399
  contract: contract ?? null,
401
400
  };
402
401
  }
@@ -79,8 +79,8 @@ export const createSessionDirectoryRuntime = ({
79
79
  return typeof data.id === 'string' ? { ...event, [field]: projectSession(data) } : event;
80
80
  };
81
81
 
82
- // v2 directory filters are lexical SQL equality. Query the owning project
83
- // instead, then retain only the same physical directory (not other worktrees).
82
+ // v2 directory filters are lexical SQL equality. Read session pages without
83
+ // booting a Location, then retain only the same physical directory.
84
84
  // This also finds old aliases absent from Yuri's bounded index.
85
85
  const fetchSessionList = async (input, init) => {
86
86
  const url = new URL(input);
@@ -90,17 +90,6 @@ export const createSessionDirectoryRuntime = ({
90
90
  if (!target || url.searchParams.has('project')) {
91
91
  return fetchFn(input, init);
92
92
  }
93
- if (!url.searchParams.has('cursor')) {
94
- const locationUrl = new URL(url);
95
- locationUrl.pathname = locationUrl.pathname.replace(/\/session\/?$/, '/location');
96
- locationUrl.search = '';
97
- locationUrl.searchParams.set('location[directory]', target);
98
- const response = await fetchFn(locationUrl, init);
99
- if (!response.ok) return response;
100
- const location = await response.json();
101
- if (typeof location?.project?.id !== 'string') throw new Error('Invalid OpenCode location payload');
102
- url.searchParams.set('project', location.project.id);
103
- }
104
93
  url.searchParams.delete('directory');
105
94
  init?.signal?.throwIfAborted();
106
95
  const response = await fetchFn(url, init);
@@ -24,6 +24,71 @@ const session = (id, directory, updated = 1) => ({ id, title: id, location: { di
24
24
  const json = (value, status = 200) => new Response(JSON.stringify(value), { status, headers: { 'content-type': 'application/json' } });
25
25
 
26
26
  describe('physical session directory identity', () => {
27
+ it('backfills only 30 days once per runtime, resumes failed pages, and never boots locations', async () => {
28
+ const { real } = fixture();
29
+ const dbPath = path.join(real, 'index.sqlite');
30
+ const now = 100 * 24 * 60 * 60 * 1000;
31
+ let fail = true;
32
+ let runtimeKey = 'http://localhost:4000';
33
+ const requests = [];
34
+ const fetchFn = vi.fn(async (input) => {
35
+ const url = new URL(input);
36
+ requests.push(url);
37
+ expect(url.pathname).toBe('/api/session');
38
+ expect(url.searchParams.has('directory')).toBe(false);
39
+ expect(url.searchParams.has('location[directory]')).toBe(false);
40
+ if (!url.searchParams.has('cursor')) return json({ data: [session('recent', real, now)], cursor: { next: 'second' } });
41
+ if (fail) return json({}, 503);
42
+ return json({ data: [session('older', real, now - 31 * 24 * 60 * 60 * 1000)], cursor: { next: 'never-read' } });
43
+ });
44
+ const open = () => {
45
+ const service = createSessionIndexService({ dbPath, getRuntimeConfig: () => ({ apiBaseUrl: runtimeKey }) });
46
+ const sync = createSessionIndexSyncRuntime({ sessionIndexService: service, now: () => now,
47
+ buildOpenCodeUrl: (route) => `http://localhost/api${route}`, getOpenCodeAuthHeaders: () => ({}), fetchFn });
48
+ return { service, sync };
49
+ };
50
+ let { service, sync } = open();
51
+ try {
52
+ sync.enqueue(Array.from({ length: 31 }, (_, i) => `/unused/${i}`), { startup: true });
53
+ sync.enqueue([], { startup: true });
54
+ await vi.waitFor(() => expect(sync.snapshot().sync.active).toBe(false));
55
+ expect(fetchFn).toHaveBeenCalledTimes(2);
56
+ expect(service.getHistoryBackfill()).toMatchObject({ cursor: 'second', complete: false });
57
+ expect(service.findBySessionId('recent')).toBeTruthy();
58
+ sync.stop(); service.close();
59
+ ({ service, sync } = open());
60
+ fail = false;
61
+ sync.enqueue([], { startup: true });
62
+ await vi.waitFor(() => expect(sync.snapshot().sync.active).toBe(false));
63
+ expect(fetchFn).toHaveBeenCalledTimes(3);
64
+ expect(requests[2].searchParams.get('cursor')).toBe('second');
65
+ expect(service.getHistoryBackfill().complete).toBe(true);
66
+ expect(service.findBySessionId('older')).toBeNull();
67
+ sync.stop(); service.close();
68
+ ({ service, sync } = open());
69
+ sync.enqueue([], { startup: true });
70
+ expect(sync.snapshot().sync.active).toBe(false);
71
+ expect(fetchFn).toHaveBeenCalledTimes(3);
72
+ runtimeKey = 'https://other.example';
73
+ expect(service.getHistoryBackfill()).toBeNull();
74
+ } finally { sync.stop(); service.close(); }
75
+ });
76
+
77
+ it('records an empty backfill as complete and preserves spaces in session directories', async () => {
78
+ const service = createSessionIndexService({ dbPath: ':memory:' });
79
+ const fetchFn = vi.fn(async () => json({ data: [], cursor: {} }));
80
+ const sync = createSessionIndexSyncRuntime({ sessionIndexService: service,
81
+ buildOpenCodeUrl: (route) => `http://localhost/api${route}`, getOpenCodeAuthHeaders: () => ({}), fetchFn });
82
+ try {
83
+ sync.enqueue([], { startup: true });
84
+ await vi.waitFor(() => expect(sync.snapshot().sync.active).toBe(false));
85
+ sync.enqueue([], { startup: true });
86
+ expect(fetchFn).toHaveBeenCalledTimes(1);
87
+ service.upsert(session('spaces', '/home/example/Library/Mobile Documents/project', Date.now()));
88
+ expect(service.findBySessionId('spaces').directory).toBe('/home/example/Library/Mobile Documents/project');
89
+ } finally { sync.stop(); service.close(); }
90
+ });
91
+
27
92
  it('checks deletion only on the owning local runtime and preserves uncertain failures', async () => {
28
93
  let url = 'http://127.0.0.1:4000';
29
94
  const stat = vi.fn(async () => { throw Object.assign(new Error('missing'), { code: 'ENOENT' }); });
@@ -67,6 +132,7 @@ describe('physical session directory identity', () => {
67
132
  fetchFn,
68
133
  });
69
134
  try {
135
+ runtime.enqueue([missing]);
70
136
  await vi.waitFor(() => expect(service.snapshot().directories.map(x => x.directory)).not.toContain(missing));
71
137
  expect(service.snapshot().directories.map(x => x.directory)).toEqual(expect.arrayContaining([real, history, partial, child]));
72
138
  runtime.enqueue([missing, history, partial, child]);
@@ -95,10 +161,10 @@ describe('physical session directory identity', () => {
95
161
  requests.push(url);
96
162
  expect(init.signal).toBe(controller.signal);
97
163
  expect(init.headers).toEqual({ Authorization: 'test-only' });
98
- if (url.pathname === '/api/location') return json({ project: { id: 'project-repo' } });
164
+ expect(url.pathname).toBe('/api/session');
99
165
  expect(url.searchParams.has('directory')).toBe(false);
100
166
  if (!url.searchParams.has('cursor')) {
101
- expect(url.searchParams.get('project')).toBe('project-repo');
167
+ expect(url.searchParams.has('project')).toBe(false);
102
168
  return json({ data: [session('other', other, 30)], cursor: { next: 'page-2' } });
103
169
  }
104
170
  return json({ data: [session('old-alias', alias, 20), session('real', real, 10)], cursor: { next: 'page-3' } });
@@ -117,8 +183,7 @@ describe('physical session directory identity', () => {
117
183
  expect(payload.data.map((row) => row.id)).toEqual(['old-alias', 'real']);
118
184
  expect(payload.data.every((row) => row.directory === real && row.location.directory === real)).toBe(true);
119
185
  expect(payload.cursor.next).toBe('page-3');
120
- expect(requests).toHaveLength(3);
121
- expect(requests[0].searchParams.get('location[directory]')).toBe(real);
186
+ expect(requests).toHaveLength(2);
122
187
  });
123
188
 
124
189
  it('uses the same physical directory for cold sync and later native live events', async () => {
@@ -8,13 +8,15 @@
8
8
  */
9
9
 
10
10
  import {
11
- PINNED_OPENCODE2_VERSION,
12
11
  MINIMUM_OPENCODE2_VERSION,
13
12
  isAcceptableOpenCode2HealthVersion,
14
13
  isOpenCode1xVersion,
15
14
  isOpenCode2VersionAtLeast,
16
15
  npmPackageForOpenCode2,
17
16
  } from './opencode2-pin.js';
17
+ import { createOpenCodeUpdateDiscovery } from './update-discovery.js';
18
+
19
+ const discoverLatestVersion = createOpenCodeUpdateDiscovery();
18
20
 
19
21
  /** Oldest OpenCode this Yuri build will enter a session against. */
20
22
  export const REQUIRED_OPENCODE_VERSION = MINIMUM_OPENCODE2_VERSION;
@@ -26,11 +28,10 @@ const normalizeVersion = (value) => {
26
28
  };
27
29
 
28
30
  /**
29
- * Install target is the pin when the pin already satisfies the screen, otherwise
30
- * the screen minimum. A pin still at 2.0.12 must not be what this screen installs.
31
+ * Describe the minimum until an installation resolves its remote stable target.
31
32
  * @param {string} [pin]
32
33
  */
33
- export function resolveUpgradeScreenTarget(pin = PINNED_OPENCODE2_VERSION) {
34
+ export function resolveUpgradeScreenTarget(pin = REQUIRED_OPENCODE_VERSION) {
34
35
  if (isOpenCode2VersionAtLeast(pin, REQUIRED_OPENCODE_VERSION)) return pin;
35
36
  return REQUIRED_OPENCODE_VERSION;
36
37
  }
@@ -181,7 +182,10 @@ export async function installRequiredOpenCode(deps) {
181
182
  409,
182
183
  );
183
184
  }
184
- const target = status.targetVersion;
185
+ const target = await (deps.resolveLatestVersion || discoverLatestVersion)();
186
+ if (!/^2\.\d+\.\d+$/.test(target) || !isUpgradeScreenSatisfied(target)) {
187
+ throw failure('No compatible stable OpenCode release was found.', 'UPGRADE_TARGET_INVALID');
188
+ }
185
189
  const previousBinary = typeof deps.getResolvedBinary === 'function' ? deps.getResolvedBinary() : null;
186
190
  const previousSource = typeof deps.getResolvedBinarySource === 'function' ? deps.getResolvedBinarySource() : null;
187
191
  const ownership = typeof deps.resolveOwnership === 'function' ? await deps.resolveOwnership() : null;
@@ -108,12 +108,31 @@ describe('installRequiredOpenCode', () => {
108
108
  calls.push('ready');
109
109
  }),
110
110
  readConfiguredBinary: async () => null,
111
+ resolveLatestVersion: async () => '2.0.23',
111
112
  isSharedService: () => false,
112
113
  ...overrides,
113
114
  };
114
115
  return { deps, calls };
115
116
  };
116
117
 
118
+ it('resolves a newer stable release instead of installing a compiled-in pin', async () => {
119
+ const { deps } = createDeps({
120
+ resolveLatestVersion: vi.fn(async () => '2.2.0'),
121
+ readBinaryVersion: () => '2.2.0',
122
+ readServeVersion: vi.fn().mockResolvedValueOnce('2.0.14').mockResolvedValueOnce('2.2.0'),
123
+ });
124
+ await expect(installRequiredOpenCode(deps)).resolves.toMatchObject({ upgraded: true, version: '2.2.0' });
125
+ expect(deps.install).toHaveBeenCalledWith({ version: '2.2.0' });
126
+ });
127
+
128
+ it('does not mutate installation or selection when release discovery fails', async () => {
129
+ const { deps } = createDeps({ resolveLatestVersion: async () => { throw new Error('offline'); } });
130
+ await expect(installRequiredOpenCode(deps)).rejects.toThrow('offline');
131
+ expect(deps.install).not.toHaveBeenCalled();
132
+ expect(deps.persistBinary).not.toHaveBeenCalled();
133
+ expect(deps.restart).not.toHaveBeenCalled();
134
+ });
135
+
117
136
  it('installs 2.0.23 and only succeeds after the running serve is verified', async () => {
118
137
  const { deps, calls } = createDeps({
119
138
  readServeVersion: vi.fn()
@@ -190,6 +209,7 @@ describe('upgrade screen routes', () => {
190
209
  resolveOwnership: async () => ({ ownership: 'owned-cache', guidance: null }),
191
210
  readServeVersion,
192
211
  readCliVersion: () => '2.0.12',
212
+ resolveLatestVersion: async () => '2.0.23',
193
213
  platformCanInstall: true,
194
214
  install: vi.fn(async () => {
195
215
  throw new Error('registry unreachable');
@@ -1,5 +1,5 @@
1
1
  import { describe, expect, it, vi } from 'vitest';
2
- import { MINIMUM_OPENCODE2_VERSION, PINNED_OPENCODE2_VERSION } from './opencode2-pin.js';
2
+ import { MINIMUM_OPENCODE2_VERSION } from './opencode2-pin.js';
3
3
  import { evaluateRuntimeContract } from './runtime-contract.js';
4
4
  import { describeUpgradeScreen, installRequiredOpenCode, resolveUpgradeScreenTarget } from './upgrade-screen.js';
5
5
  import { ensurePinnedOpenCode2Cli } from './ensure-cli.js';
@@ -13,24 +13,24 @@ describe('v2 version alignment', () => {
13
13
  expect(evaluateRuntimeContract({ serveVersion: version, cliVersion: '2.0.15', reachable: true, authenticated: true })).toMatchObject({ executionAllowed: true, versionMismatch: true, minVerifiedVersion: '2.0.20' });
14
14
  expect(describeUpgradeScreen({ version }).state).toBe('compatible');
15
15
  });
16
- it('installs the audited pin on first install and preserves newer discovered CLIs', async () => {
16
+ it('installs the discovered stable release and preserves existing CLIs', async () => {
17
17
  expect(MINIMUM_OPENCODE2_VERSION).toBe('2.0.20');
18
- expect(PINNED_OPENCODE2_VERSION).toBe('2.0.23');
19
- expect(resolveUpgradeScreenTarget()).toBe('2.0.23');
18
+ expect(resolveUpgradeScreenTarget()).toBe(MINIMUM_OPENCODE2_VERSION);
20
19
  const install = vi.fn(async () => '/owned/opencode');
21
- await expect(ensurePinnedOpenCode2Cli({ readVersion: (path) => path === '/owned/opencode' ? '2.0.23' : '', install })).resolves.toMatchObject({ version: '2.0.23', installed: true });
20
+ await expect(ensurePinnedOpenCode2Cli({ resolveLatestVersion: async () => '2.0.23', readVersion: (path) => path === '/owned/opencode' ? '2.0.23' : '', install })).resolves.toMatchObject({ version: '2.0.23', installed: true });
22
21
  expect(install).toHaveBeenCalledWith(expect.objectContaining({ version: '2.0.23' }));
23
22
  install.mockClear();
24
23
  await expect(ensurePinnedOpenCode2Cli({ discoveredPath: '/global/opencode', readVersion: () => '2.1.0', install })).resolves.toMatchObject({ version: '2.1.0', installed: false });
25
24
  expect(install).not.toHaveBeenCalled();
26
25
  });
27
26
  it('does not infer a successful installation from an unreadable binary', async () => {
28
- await expect(ensurePinnedOpenCode2Cli({ readVersion: () => '', install: async () => '/owned/opencode' })).rejects.toThrow('got unknown');
27
+ await expect(ensurePinnedOpenCode2Cli({ resolveLatestVersion: async () => '2.2.0', readVersion: () => '', install: async () => '/owned/opencode' })).rejects.toThrow('got unknown');
29
28
  });
30
29
  it('verifies the live service after explicit install, and rolls selection back on failure', async () => {
31
30
  const persistBinary = vi.fn();
32
31
  const restart = vi.fn();
33
32
  const deps = { resolveOwnership: async () => ({ ownership: 'shared-service', binaryOwnership: 'owned-cache' }), readServeVersion: vi.fn().mockResolvedValueOnce('2.0.19').mockResolvedValueOnce('2.0.23'), readCliVersion: () => '2.0.23', platformCanInstall: true, install: async () => '/owned/opencode', readBinaryVersion: () => '2.0.23', persistBinary, restart, isSharedService: () => true };
33
+ deps.resolveLatestVersion = async () => '2.0.23';
34
34
  await expect(installRequiredOpenCode(deps)).resolves.toMatchObject({ upgraded: true, version: '2.0.23' });
35
35
  expect(restart).toHaveBeenCalledWith({ binaryPath: '/owned/opencode' });
36
36
  deps.readServeVersion.mockResolvedValue('2.0.19');
@@ -8,15 +8,15 @@ with an empty result. Remote upstreams never use the Host filesystem as evidence
8
8
  permission and I/O errors are not deletion. Checks are not negatively cached, so
9
9
  a recreated directory participates in the next requested sync.
10
10
 
11
- Once at startup, the sync runtime checks empty, exhausted indexed
12
- directories. It removes only directory shells with no summary rows, no child rows,
11
+ Startup does not probe indexed directories. An explicitly requested directory
12
+ refresh removes only missing directory shells with no summary rows, no child rows,
13
13
  and no more pages, using one conditional SQLite deletion. Session history and pins
14
14
  are preserved. This maintenance does not touch code files or upstream projects.
15
15
  Runtime switches and shutdown discard pending checks; successful cleanup publishes
16
16
  a revision tip. Snapshot GETs do not perform filesystem scans. Old project paths
17
17
  may still be submitted by clients, but pre-scan checks prevent recreating empty
18
18
  shells for missing paths. App or external worktree deletion is picked up by the
19
- next requested sync or startup pass; there is no periodic filesystem polling.
19
+ next requested sync; there is no startup or periodic filesystem polling.
20
20
 
21
21
  ## Physical directory identity
22
22
 
@@ -33,8 +33,8 @@ child membership follows the directory, and the merged head stays bounded to 20.
33
33
  Reconciliation failure rolls back the entire index conversion. Rechecking on reads
34
34
  also recovers paths unavailable during startup.
35
35
 
36
- Directory lists resolve the upstream location/project, fetch project-scoped pages
37
- and retain only records whose physical directory matches the requested directory.
36
+ Explicit directory lists fetch session pages without initializing an upstream
37
+ Location and retain only records whose physical directory matches the request.
38
38
  This discovers old aliases outside the index without admitting sibling worktrees.
39
39
  Opaque next/previous cursors stay upstream-owned; filtered short/empty pages with
40
40
  a continuation are partial, not exhausted. The existing five-page sync budget and
@@ -121,9 +121,19 @@ Repeated session summary events whose bounded root summary or child membership
121
121
  is unchanged leave directory recency and the public revision unchanged. Root
122
122
  events that remain outside the newest-20 bound follow the same no-op path.
123
123
 
124
- `sync-runtime.js` owns cold-start synchronization. The renderer submits all
125
- known project directories once to `POST /api/yuri/session-index/sync`.
126
- The runtime processes them sequentially. OpenCode 2.x list is cursor-only (no
124
+ `sync-runtime.js` owns cold-start synchronization. The renderer sends
125
+ `{ startup: true }` to `POST /api/yuri/session-index/sync`, without project paths.
126
+ The Host backfills sessions updated within the last 30 days using a single global
127
+ descending session-list cursor, stopping at the time boundary. It never requests
128
+ Location/config/plugin APIs or probes project paths. Each page and its cursor are
129
+ committed atomically in SQLite under the runtime key; empty success also records
130
+ completion. Subsequent launches perform no upstream history reads after completion.
131
+ Failure/shutdown preserves the last committed cursor for retry. Existing summaries
132
+ win over backfill, and normal create/update/archive/delete events maintain the index.
133
+ Existing databases without this marker receive one bounded backfill without being
134
+ cleared. Manual directory refresh remains a separate explicit operation.
135
+
136
+ The runtime processes explicit directory refreshes sequentially. OpenCode 2.x list is cursor-only (no
127
137
  `start` incremental); each directory fetches active-only pages (`limit=20`)
128
138
  after optional Host `projectSessions` overlay. Consecutive archived rows may
129
139
  consume further pages within a small page budget so the newest-20 **active**
@@ -55,7 +55,9 @@ export const registerSessionIndexRoutes = (app, {
55
55
  app.post('/api/yuri/session-index/sync', async (req, res) => {
56
56
  if (!sessionIndexSyncRuntime) return unsupported(res);
57
57
  const directories = Array.isArray(req.body?.directories) ? req.body.directories : [];
58
- const base = sessionIndexSyncRuntime.enqueue(directories);
58
+ const base = req.body?.startup === true
59
+ ? sessionIndexSyncRuntime.enqueue([], { startup: true })
60
+ : sessionIndexSyncRuntime.enqueue(directories);
59
61
  if (!hostStoreWired) return res.status(202).json(base);
60
62
  // Clients apply this body as a snapshot: same Host archive gate as GET.
61
63
  const host = await readHostMap();
@@ -79,6 +79,8 @@ describe('session index routes', () => {
79
79
  expect(res.statusCode).toBe(202);
80
80
  expect(enqueue).toHaveBeenCalledWith(['/repo/a', '/repo/b']);
81
81
  expect(res.body).toMatchObject({ revision: 1, sync: { active: true } });
82
+ route('POST', '/api/yuri/session-index/sync')({ body: { startup: true, directories: ['/ignored'] } }, res);
83
+ expect(enqueue).toHaveBeenLastCalledWith([], { startup: true });
82
84
  });
83
85
 
84
86
  it('does not register a long-poll changes route', () => {