@yuriai/web 0.1.22 → 0.1.24
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 +1 -1
- package/dist/assets/{AssistantView-B-vEm0jN.js → AssistantView-C6Kq4IeV.js} +3 -3
- package/dist/assets/{DiagramView-DT5CPdtn.js → DiagramView-BWNMrLgm.js} +1 -1
- package/dist/assets/{MarkdownRenderer-kDYymiH3.js → MarkdownRenderer-AHl_m1Rf.js} +2 -2
- package/dist/assets/{MarkdownRendererImpl-cS5FXxon.js → MarkdownRendererImpl-B3bYtK9r.js} +1 -1
- package/dist/assets/{MarkstreamRendererImpl-CO1AzJsB.js → MarkstreamRendererImpl-B5rxhwTp.js} +1 -1
- package/dist/assets/{MobileDetailNavigation-RLH6AQBN.js → MobileDetailNavigation-CkdmjMHv.js} +1 -1
- package/dist/assets/{MobileShareBridge-CijqYDMo.js → MobileShareBridge-D4h2_ZOI.js} +1 -1
- package/dist/assets/{MobileTabPageHeader-BZKymEeY.js → MobileTabPageHeader-CgwEhDEc.js} +1 -1
- package/dist/assets/{MultiRunWindow-BBADn01m.js → MultiRunWindow-C8ifF6MX.js} +1 -1
- package/dist/assets/{OverlayScrollbar-Dxdkid6A.js → OverlayScrollbar-eBG-DXgX.js} +1 -1
- package/dist/assets/{SettingsView-BDw1UGgS.js → SettingsView-DinNQMES.js} +1 -1
- package/dist/assets/{SettingsWindow-DQz1f-kO.js → SettingsWindow-BqQxUO8Z.js} +1 -1
- package/dist/assets/{TerminalView-CpGeHiw4.js → TerminalView-LwaxVKh2.js} +1 -1
- package/dist/assets/{ToolOutputDialog-qF2onmML.js → ToolOutputDialog-CrMx7040.js} +1 -1
- package/dist/assets/{appThemeRegistry-DmRKfJL3.js → appThemeRegistry-BrxlsRZv.js} +1 -1
- package/dist/assets/{capgoAdapter-BmTEnR2_.js → capgoAdapter-DjiN4gU-.js} +1 -1
- package/dist/assets/{dropdown-menu.styles-BXRbrWW5.js → dropdown-menu.styles-BqAI_N66.js} +1 -1
- package/dist/assets/{fileMentionTouchSelection-FDObhofW.js → fileMentionTouchSelection-BSbG3aaI.js} +1 -1
- package/dist/assets/{gitApi-D8IPglEo.js → gitApi-BrFpwjIz.js} +1 -1
- package/dist/assets/{insertionBoundaries-DE8RyJf4.js → insertionBoundaries-jA5oY6Eg.js} +1 -1
- package/dist/assets/{main-BLMeK7Ed.js → main-Vmy68zzS.js} +4 -4
- package/dist/assets/{main-Bh0kUjiw.js → main-sy9tIrXv.js} +2 -2
- package/dist/assets/{mcpQueries-BFkB-7V_.js → mcpQueries-B6p3UNY7.js} +1 -1
- package/dist/assets/{miniChat-Ciy0u8ci.js → miniChat-D9RYlfJj.js} +2 -2
- package/dist/assets/{mobile-Bm0sCDXq.js → mobile-DJ8Ongip.js} +2 -2
- package/dist/assets/{mobileBackNavigation-BwxOTY4b.js → mobileBackNavigation-B8L0Vy1I.js} +1 -1
- package/dist/assets/{multirun-CyHj2_Qf.js → multirun-COWU8JRo.js} +1 -1
- package/dist/assets/{native-config-BDst1Okm.js → native-config-DYPGnxUZ.js} +1 -1
- package/dist/assets/{platform-7bX6qtBV.js → platform-CCTs9UKZ.js} +1 -1
- package/dist/assets/{projectMeta-C75m7wMM.js → projectMeta-BKzhp80G.js} +1 -1
- package/dist/assets/{renderElectronMiniChatApp-BSX59NyD.js → renderElectronMiniChatApp-DmmSvxer.js} +2 -2
- package/dist/assets/{renderMobileApp-BM8Bg3sb.js → renderMobileApp-B6mlgiIP.js} +4 -4
- package/dist/assets/{runtimeConfig-D0UDGecm.js → runtimeConfig-D-qLdzVy.js} +1 -1
- package/dist/assets/{runtimeEndpointReset-Df4Jlmne.js → runtimeEndpointReset-C2av6bqy.js} +1 -1
- package/dist/assets/{scheduledTaskNavigation-BE3Okq7X.js → scheduledTaskNavigation-FME9NQYP.js} +1 -1
- package/dist/assets/{sessionChangeSummary-DkIJkqeG.js → sessionChangeSummary-DKOy397B.js} +1 -1
- package/dist/assets/{sessionLookup-DhcUVJQR.js → sessionLookup-BxxDvke8.js} +1 -1
- package/dist/assets/{sortable-tabs-strip-CQR5TsUS.js → sortable-tabs-strip-DiXAHgws.js} +1 -1
- package/dist/assets/{speechSettingsQueries-BWIoMe5c.js → speechSettingsQueries-B3JrnqTj.js} +1 -1
- package/dist/assets/{terminalApi-BHXvha-U.js → terminalApi-DhXTmxps.js} +1 -1
- package/dist/assets/{textarea-pQCq-iLS.js → textarea-BZhmG_bD.js} +1 -1
- package/dist/assets/{types-2CUEL3Ja.js → types-D4VbzvCO.js} +1 -1
- package/dist/assets/{useAppFontEffects-C9CPKD-1.js → useAppFontEffects-lFrC_5Vj.js} +5 -5
- package/dist/assets/{useDesktopWindowControlsLayout-Cw3ZRPXc.js → useDesktopWindowControlsLayout-BPujMjYn.js} +1 -1
- package/dist/assets/{useEffectiveDirectory-Cw-vfohq.js → useEffectiveDirectory-DfD8BFNR.js} +1 -1
- package/dist/assets/{useFontPreferences-D9PX5t6Y.js → useFontPreferences-CMyrMAmq.js} +1 -1
- package/dist/assets/{useMobileNavigationStore-K23K6qFK.js → useMobileNavigationStore-DllieJnH.js} +5 -5
- package/dist/assets/{useWorkerHighlightedLines-U3DE5CRZ.js → useWorkerHighlightedLines-mc6QKH2H.js} +1 -1
- package/dist/assets/vendor-opencode-client-XDI8AfPJ.js +12 -0
- package/dist/index.html +8 -8
- package/dist/mini-chat.html +8 -8
- package/dist/mobile.html +8 -8
- package/package.json +3 -3
- package/server/lib/content-search/DOCUMENTATION.md +17 -11
- package/server/lib/content-search/index.js +1 -0
- package/server/lib/content-search/runtime.js +50 -9
- package/server/lib/content-search/runtime.test.js +72 -1
- package/server/lib/content-search/service.js +12 -1
- package/server/lib/opencode/DOCUMENTATION.md +9 -9
- package/server/lib/opencode/ensure-cli.js +12 -14
- package/server/lib/opencode/ensure-cli.test.js +8 -8
- package/server/lib/opencode/env-runtime.test.js +1 -1
- package/server/lib/opencode/opencode2-pin.js +3 -4
- package/server/lib/opencode/opencode2-pin.test.js +5 -4
- package/server/lib/opencode/owned-runtime-upgrade.js +4 -11
- package/server/lib/opencode/owned-runtime-upgrade.test.js +4 -0
- package/server/lib/opencode/routes.js +2 -1
- package/server/lib/opencode/routes.test.js +1 -1
- package/server/lib/opencode/runtime-contract.js +3 -4
- package/server/lib/opencode/session-directory-runtime.js +2 -13
- package/server/lib/opencode/session-directory-runtime.test.js +69 -4
- package/server/lib/opencode/upgrade-screen.js +9 -5
- package/server/lib/opencode/upgrade-screen.test.js +20 -0
- package/server/lib/opencode/version-alignment.test.js +6 -6
- package/server/lib/session-index/DOCUMENTATION.md +18 -8
- package/server/lib/session-index/routes.js +3 -1
- package/server/lib/session-index/routes.test.js +2 -0
- package/server/lib/session-index/service.js +23 -0
- package/server/lib/session-index/sync-runtime.js +75 -20
- package/server/lib/session-index/sync-runtime.test.js +5 -5
- package/dist/assets/vendor-opencode-client-MF2GBrFx.js +0 -12
|
@@ -20,7 +20,7 @@ This module provides OpenCode server integration utilities for the web server ru
|
|
|
20
20
|
connection shortcuts to exclude themselves without changing management lists.
|
|
21
21
|
- `plugins.js`: config entries and plugin-directory files are inventory, not compatibility checks. They do not synthesize `compatibility` or `compatible` fields; Settings uses the OpenCode runtime inventory for actual load status and errors.
|
|
22
22
|
- Reads native V2 `plugins` (strings or `{ package, options }`) with legacy `plugin`/tuple fallback. A native array, including an empty one, wins within each document. Entry mutations write only `plugins`, convert retained legacy tuples, and remove the shadowed legacy key in the touched source file. Options, ordering, unrelated configuration and JSONC comments are preserved through the shared atomic config writer; malformed entries or write failures do not replace the original file. Web, Electron and mobile use this host implementation; VS Code mirrors the same persistence contract.
|
|
23
|
-
- `session-directory-runtime.js`: Host-side physical directory identity for session index/list/detail/live projection. Uses a runtime-scoped, bounded 256-entry cache (60s success / 5s failed resolution), cleared when the upstream URL changes. Local directory lists use
|
|
23
|
+
- `session-directory-runtime.js`: Host-side physical directory identity for session index/list/detail/live projection. Uses a runtime-scoped, bounded 256-entry cache (60s success / 5s failed resolution), cleared when the upstream URL changes. Local directory lists use session pages and physical-directory filtering to include legacy symlink sessions without mixing worktrees; they never request `/location` to discover project identity. Startup backfill reads one global session stream rather than one stream per project. One request reads one page and preserves opaque cursors; consumers must follow continuations even after filtered-empty pages. Non-loopback upstreams keep their own path namespace.
|
|
24
24
|
- `packages/web/server/lib/opencode/index.js`: public entrypoint (currently baseline placeholder).
|
|
25
25
|
- `packages/web/server/lib/opencode/auth.js`: host-only authoritative provider credential API reads and deletion.
|
|
26
26
|
- `packages/web/server/lib/opencode/auth-state-runtime.js`: managed OpenCode server auth password/header runtime.
|
|
@@ -32,8 +32,8 @@ This module provides OpenCode server integration utilities for the web server ru
|
|
|
32
32
|
- `packages/web/server/lib/opencode/v1-migration-gate.js`: pure V1→v2 migration admission gate (`GET /api/experimental/migration/v1` → whether transcript may be fetched).
|
|
33
33
|
- `packages/web/server/lib/opencode/managed-capabilities-runtime.js`: managed-child scheduled-task resources, config injection, rotating bridge identity, and bridge authorization.
|
|
34
34
|
- `packages/web/server/lib/opencode/env-runtime.js`: OpenCode CLI/binary resolution and shell environment runtime.
|
|
35
|
-
- `packages/web/server/lib/opencode/ensure-cli.js`: detect local `opencode` version and install the latest stable official V2 into the Yuri data dir when no usable CLI exists
|
|
36
|
-
- `packages/web/server/lib/opencode/upgrade-screen.js`: startup gate for the running OpenCode below `2.0.20`. Client/schema dependencies
|
|
35
|
+
- `packages/web/server/lib/opencode/ensure-cli.js`: detect local `opencode` version and install the latest stable official V2 into the Yuri data dir when no usable CLI exists. Registry lookup failures remain errors; verified cached installations can be reused offline. Never uses a packaged/bundled binary.
|
|
36
|
+
- `packages/web/server/lib/opencode/upgrade-screen.js`: startup gate for the running OpenCode below `2.0.20`. Client/schema dependencies accept compatible 2.x updates; fresh installations and required upgrades resolve latest stable 2.x at installation time. The compatible execution floor is independently `2.0.20` (credential API). An unreadable running version is unavailable even when the local CLI is compatible. `POST /api/opencode/install-required` upgrades the selected shared global CLI in place; other supported local installations use the owned-cache installer. Global upgrades do not persist a binary override, so subsequent launches still follow shell discovery. Success requires the running service to meet both the floor and selected target. External services are not replaced; compatible newer shared services are not automatically downgraded. Failure restores binary selection and reports `upgraded: false`, without claiming process or package-manager rollback.
|
|
37
37
|
- `packages/web/server/lib/opencode/env-config.js`: OpenCode-related environment variable parsing and validation (host/port/hostname).
|
|
38
38
|
- `packages/web/server/lib/opencode/hmr-state-runtime.js`: HMR-persistent runtime state initialization, auth-state bootstrap, and HMR sync helpers.
|
|
39
39
|
- `packages/web/server/lib/opencode/bootstrap-runtime.js`: base app bootstrap runtime for status/auth/tts/notification/Yuri route wiring.
|
|
@@ -111,8 +111,8 @@ This module provides OpenCode server integration utilities for the web server ru
|
|
|
111
111
|
- `POST /api/opencode/upgrade` (ticket 12): upgrades the remote latest or explicitly targeted version. Shared services using a global CLI invoke that selected installation's `upgrade <version>` and verify its disk version; owned-cache installations download into `~/.config/yuri/opencode-cli/<version>/`. Shared services restart through the selected CLI entry path and adopt its registration again. Success requires fresh CLI/service version probes and runtime contract verification. Global upgrades never switch to an owned cache on failure. Arbitrary external servers, private processes using global CLI, and private bundled binaries return HTTP 409. Concurrent upgrades are single-flight (`operation` state). Active sessions do not block an explicitly requested upgrade or require additional confirmation. Failure restores binary selection and reports the failed phase; it cannot undo package-manager changes and does not claim process restoration.
|
|
112
112
|
- `GET /api/opencode/upgrade-status`: returns `currentVersion`/`serveVersion`/`cliVersion`, `targetVersion`/`latestVersion` (official npm `@opencode/cli` latest stable 2.x release), `supplySource`, `ownership`, `canManage`, `management`, `guidance`, `contract`, and `operation`. Official shared services report `ownership: 'shared-service'`, `processOwnership: 'shared'`, and `canManage: true`. `available` is true only when `canManage` and target > current; unmanaged global/external runtimes report `available: null` plus manual guidance. `update-discovery.js` shares one in-flight registry request per host, caches successful checks for five minutes and failed checks for thirty seconds, with a five-second request deadline. Failed registry checks return HTTP 500 with `available: null`, never a false up-to-date result. An upgrade without an explicit target resolves this same remote release. Shared Web/Electron/hosted-mobile/Capacitor clients check after startup, every five minutes while visible, on focus/reconnect, and on runtime changes; query results and dismissed notifications are scoped to the host. Successful upgrade already includes process restart and live version verification, so no second reload is needed.
|
|
113
113
|
- `GET /api/opencode/compatibility`: startup upgrade-screen status. `compatible` requires the running OpenCode 2.x at `2.0.20` or newer; older/invalid versions are `incompatible`; unreadable running versions are `unavailable`. External serves are not replaced.
|
|
114
|
-
|
|
115
|
-
|
|
114
|
+
- `POST /api/opencode/install-required`: resolves the latest stable 2.x release (never below the `2.0.20` floor), upgrades the selected shared global CLI or owned cache, and restarts through the existing lifecycle. Discovery failure does not install a historical fallback. `upgraded: true` requires live version verification. Concurrent installs are single-flight; failures remain errors. Compatibility status reports the minimum before installation resolves its actual target.
|
|
115
|
+
- `GET /api/opencode/contract`: runtime contract admission for the **running serve**. Reachability, auth, execution, migration, and CLI↔serve mismatch are separate. The `2.0.20` floor is independent of installation targets; compatible newer 2.x services remain admitted. The legacy `pinnedVersion` response field is null.
|
|
116
116
|
- `GET /api/opencode/health`: probes managed OpenCode `GET /api/info` (Basic auth, 4s timeout). `healthy` is reachability/version shape via `evaluateOpenCodeHealthBody` (admits official 2.x `ServerInfo` and classic `{ healthy: true, version }`; rejects 1.x / missing / `healthy: false`). Response also includes `executionAllowed`, `protocolCompatible`, and `contract` so clients do not treat health success as full execution semantics. Upstream non-OK responses pass through status with `{ healthy: false, error, contract }`; transport failures return HTTP 503.
|
|
117
117
|
- `GET /api/opencode/version`: serve + CLI versions, mismatch flag, and contract snapshot
|
|
118
118
|
- `POST /api/opencode/directory`
|
|
@@ -145,12 +145,12 @@ This module provides OpenCode server integration utilities for the web server ru
|
|
|
145
145
|
- Native `session.execution.started/succeeded/failed/interrupted` and `session.retry.scheduled` feed the same status/activity/attention transitions. Shutdown interruption retains busy ownership; other terminal events settle idle. `extractSessionStatusUpdate` is shared by Host forwarding, index ingestion and Goal timer handling so retry metadata and shutdown semantics stay aligned.
|
|
146
146
|
|
|
147
147
|
## Public exports (opencode2-pin.js)
|
|
148
|
-
- `
|
|
148
|
+
- `MINIMUM_OPENCODE2_VERSION`: compatibility floor, not an installation pin.
|
|
149
149
|
- `OPENCODE2_NPM_PACKAGE`: `@opencode/cli` (global install that ships the official `opencode` v2 binary; not 1.x `opencode-ai`).
|
|
150
150
|
- `parseOpenCode2VersionOutput(stdout)` / `compareOpenCode2Versions(left, right)` / `isOpenCode2VersionAtLeast(version, minimum)`: CLI `--version` parse and pin comparison.
|
|
151
151
|
- `openCode2BinaryName(platform)` / `npmPackageForOpenCode2(platform, arch)`: staged binary name `opencode` (`opencode.exe` on Windows) and official platform package `@opencode/cli-<os>-<arch>[-baseline]`.
|
|
152
152
|
- `isOpenCode1xVersion(value)` / `isAcceptableOpenCode2HealthVersion(value)` / `evaluateOpenCodeHealthBody(body)`: health admission accepts only 2.x. 1.x, `0.x` pre-2 binaries, and missing/unknown versions are rejected even when `healthy: true`.
|
|
153
|
-
- `resolveOpenCode2UpgradeTarget(target)` / `rejectOpenCode1xUpgradeTarget(target)`:
|
|
153
|
+
- `resolveOpenCode2UpgradeTarget(target)` / `rejectOpenCode1xUpgradeTarget(target)`: require a resolved upgrade target and refuse 1.x; no historical default.
|
|
154
154
|
|
|
155
155
|
## Public exports (runtime-contract.js)
|
|
156
156
|
- Pure admission matrix. `RUNTIME_CONTRACT_MIN_VERIFIED` (`2.0.20`) is the documented 2.x floor, shared with the startup gate through `MINIMUM_OPENCODE2_VERSION`; the VS Code sidecar mirrors this floor. Capabilities include `core.protocol`, `session.prompt`, `session.queuedInput`, `session.background`, `session.generationFallback`, `migration.v1Read`.
|
|
@@ -167,8 +167,8 @@ This module provides OpenCode server integration utilities for the web server ru
|
|
|
167
167
|
- `buildUpgradeStatusSnapshot` / `evaluateOwnedUpgradeResult` / `createUpgradeOperationState` / `resolveOwnedCacheBinaryPath`.
|
|
168
168
|
|
|
169
169
|
## Public exports (ensure-cli.js)
|
|
170
|
-
- `ensurePinnedOpenCode2Cli({ discoveredPath, pin, autoInstall, install, readVersion })`: reuse any discovered acceptable 2.x CLI (official name `opencode`), then the newest verified owned cache. Only a fresh installation queries the stable 2.x release via `update-discovery.js`;
|
|
171
|
-
- `installPinnedOpenCode2Cli(options)`: download `@opencode/cli-<os>-<arch
|
|
170
|
+
- `ensurePinnedOpenCode2Cli({ discoveredPath, pin, autoInstall, install, readVersion })`: reuse any discovered acceptable 2.x CLI (official name `opencode`), then the newest verified owned cache. Only a fresh installation queries the stable 2.x release via `update-discovery.js`; the optional explicit `pin` remains an override, not a product default. Registry errors propagate without a historical fallback. Downloads stay under `~/.config/yuri/opencode-cli/<version>/opencode`. `YURI_OPENCODE2_AUTO_INSTALL=0` disables download (`OPENCODE_CLI_MISSING`).
|
|
171
|
+
- `installPinnedOpenCode2Cli(options)`: resolve latest stable 2.x unless a concrete version was supplied, download its `@opencode/cli-<os>-<arch>` package, extract, copy as `opencode`, chmod, verify `--version` against the resolved version.
|
|
172
172
|
- `installedOpenCode2BinaryPath(version)` / `installedOpenCode2BinaryCandidates(options)` / `readOpenCode2BinaryVersion(path)` / `isOpenCode2AutoInstallEnabled()`. Cache candidates are stable 2.x directories ordered by numeric version, so an offline restart discovers a newer installation rather than reverting to the packaged pin.
|
|
173
173
|
- `terminal-path.js` exposes owned-cache CLIs to new terminals on installation/reuse. It writes an idempotent source line to zsh `.zprofile`/`.zshrc` (including `ZDOTDIR`), bash `.bashrc` and the active login profile, POSIX `.profile`, or fish `config.fish`. The sourced file in the Yuri data directory selects the verified executable directory. Windows updates only user PATH, retaining unrelated entries, broadcasts the environment change, and records `opencode-path.windows` in the data directory. Subsequent owned-cache upgrades refresh an existing terminal integration after binary verification. Existing global installations do not trigger shell edits. PATH-setup failure warns and keeps the working Yuri runtime; a later startup retries. Existing terminal processes need a new shell, and shell-file changes already completed before a failure are retained.
|
|
174
174
|
- `upgradeSelectedOpenCodeCli({ binaryPath, version, launchSpec, env })`: runs the selected CLI's official `upgrade <version>` without a shell, with a five-minute deadline and bounded captured output. Returns the original CLI entry path, preserving Homebrew symlinks. Windows launch specs unwrap native/runtime shims; unresolved batch wrappers require terminal upgrade instead of spawning console grandchildren. Child output is not returned or logged. Package-manager failures never fall back to another installation; callers verify the original entry's version before restarting. Package-manager file changes cannot be rolled back by restoring Yuri's binary selection.
|
|
@@ -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
|
-
|
|
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 =
|
|
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 ||
|
|
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
|
-
*
|
|
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 ||
|
|
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
|
-
|
|
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
|
-
|
|
286
|
-
if (!
|
|
287
|
-
|
|
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
|
-
|
|
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).
|
|
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('
|
|
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).
|
|
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
|
-
|
|
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
|
-
//
|
|
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
|
-
|
|
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 =
|
|
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
|
|
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)).
|
|
32
|
-
expect(resolveOpenCode2UpgradeTarget('')).
|
|
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
|
-
|
|
180
|
-
|
|
181
|
-
|
|
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 &&
|
|
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
|
|
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 () =>
|
|
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:
|
|
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 =
|
|
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:
|
|
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.
|
|
83
|
-
//
|
|
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
|
-
|
|
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.
|
|
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(
|
|
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
|
-
*
|
|
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 =
|
|
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 =
|
|
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
|
|
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
|
|
16
|
+
it('installs the discovered stable release and preserves existing CLIs', async () => {
|
|
17
17
|
expect(MINIMUM_OPENCODE2_VERSION).toBe('2.0.20');
|
|
18
|
-
expect(
|
|
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');
|