🌊 The original agent harness. Deploy intelligent multi-player swarms, coordinate autonomous workflows, and build conversational AI systems. Features adaptive memory, self-learning intelligence, federation, vector RAG integration, and native Claude Code / Codex / Hermes and many more Integrated
TypeScript agentic-aiagentic-frameworkagentic-workflowagentsai-agentsai-assistantai-skillsautonomous-agentsclaudecodexdsh-pluginharnessmcp-servermulti-agentmulti-agent-systemsnpmskillsswarmswarm-intelligencetypescript
fix(ruflo-console): updater re-checks in a long session and updates every install that applies (0.28.1)
ruv1bdafd1f3eb7
diff --git a/plugins/ruflo-console/.claude-plugin/plugin.json b/plugins/ruflo-console/.claude-plugin/plugin.jsonindex 67d5f289f9..280c50344c 100644--- a/plugins/ruflo-console/.claude-plugin/plugin.json+++ b/plugins/ruflo-console/.claude-plugin/plugin.json@@ -1,7 +1,7 @@{"name": "ruflo-console","description": "ruflo's cockpit inside Claude Code and the one /ruflo command for every ruflo mod (function hooks, early access). Views: overview with health alerts, swarm topology graph, claims flow with TTL rings, federation map, plugin health matrix, learning curve and pipeline, MetaHarness radar and audit trend, memory, cost gauge, agent timeline, approvals queue, event stream, a main menu, an x.ruv.io federation board, an AI terminal (codex, claude or both in remembered sessions, streamed), Skills (npx skills), a Hive-Mind view, a MetaHarness lab, agent drill-down; a command palette for confirm-gated actions through the ruflo CLI; a band above the prompt. Reads ruflo's files and the CLI's local JSON; anything not measured reads n/a. The one network call it makes by itself is a daily read of the published plugin.json at github.com/ruvnet/ruflo to offer an update (Settings → Updates: ask, auto, or off); it installs only through Claude Code's own claude plugin update, and never a new major version without asking.",- "version": "0.28.0",+ "version": "0.28.1","author": {"name": "ruvnet","url": "https://github.com/ruvnet"diff --git a/plugins/ruflo-console/hooks/register.ts b/plugins/ruflo-console/hooks/register.tsindex 924b3df7bf..ed058ab8ef 100644--- a/plugins/ruflo-console/hooks/register.ts+++ b/plugins/ruflo-console/hooks/register.ts@@ -13,7 +13,7 @@ import { BAR_KEY, barView } from './views/bar'import { setBootChecks } from './boot-checks'import { buildOf, isOurCheckout, setBuild } from './build'import { runUpdateCheck } from './update-flow'-import { parseMode, UPDATES_KEY } from './updates'+import { parseMode, RECHECK_EVERY_MS, UPDATES_KEY } from './updates'import { selfCheckResults } from './self-check'import type { Kit } from './views/common'import { picturesOf } from './views/frames'@@ -161,7 +161,11 @@ export const register: Register = (on, raw: PluginOptions) => {)void Promise.all([built, moded]).then(() => {- if (state.isInteractive) here.after(2_500, () => void runUpdateCheck(state, here))+ if (!state.isInteractive) return++ here.after(2_500, () => void runUpdateCheck(state, here))+ // A session left open for days re-asks too, quietly (no dialog mid-work); the daily gate keeps the network to once a day.+ state.timers.set('update-recheck', here.every(RECHECK_EVERY_MS, () => void runUpdateCheck(state, here, { quiet: true })))})const bound = hostdiff --git a/plugins/ruflo-console/hooks/update-flow.ts b/plugins/ruflo-console/hooks/update-flow.tsindex 3eab01f157..0d2f4aa552 100644--- a/plugins/ruflo-console/hooks/update-flow.ts+++ b/plugins/ruflo-console/hooks/update-flow.ts@@ -14,13 +14,14 @@ import {decide,firstLine,INSTALLED_KEY,- installedEntry,+ installedEntries,isBeingApplied,isDue,LABEL,MANIFEST_URL,MANUAL_COMMAND,needsConfirmation,+ NOTIFIED_KEY,PLUGIN_ID,MARKET,promptOf,@@ -40,6 +41,8 @@ export type UpdateDeps = {after: Host['after']/** The version this session is running. */local: string+ /** The folder this session works in: which project-scope installs apply to it. */+ cwd: stringisInteractive: boolean/** A development checkout (a session loaded from a git worktree) manages itself with git: it is never offered an update. */isDevCheckout: () => boolean@@ -79,10 +82,11 @@ const fetched = (deps: UpdateDeps): Promise<{ ok: boolean; status: number; text:)})+/** Every install that applies to this session (the user one and this project's), or null when the list could not be read. */async function listInstalled(deps: UpdateDeps) {const listed = await deps.run(['claude', 'plugin', 'list', '--json'], LIST_TIMEOUT_MS).catch(() => null)- return listed === null || listed.exitCode !== 0 ? null : installedEntry(listed.stdout)+ return listed === null || listed.exitCode !== 0 ? null : installedEntries(listed.stdout, deps.cwd)}/** Installs `remote` with Claude Code's own commands, then reads back what is installed. Never throws. */@@ -92,28 +96,36 @@ export async function applyUpdate(deps: UpdateDeps, remote: string): Promise<Updtry {const before = await listInstalled(deps)- if (before === null) return { outcome: 'failed', remote, detail: `${PLUGIN_ID} is not installed from the ruflo marketplace here (a session loaded with --plugin-dir has nothing to update)` }+ if (before === null || before.length === 0) return { outcome: 'failed', remote, detail: `${PLUGIN_ID} is not installed from the ruflo marketplace here (a session loaded with --plugin-dir has nothing to update)` }const market = await deps.run(['claude', 'plugin', 'marketplace', 'update', MARKET], STEP_TIMEOUT_MS).catch(() => null)if (market === null || market.exitCode !== 0) return { outcome: 'failed', remote, detail: `the marketplace did not update: ${firstLine(`${market?.stderr ?? ''}\n${market?.stdout ?? ''}`) || 'no answer'}` }- // No -y and no --accept-command, ever: a marketplace-declared command is Claude Code's to confirm with a person.- const updated = await deps.run(['claude', 'plugin', 'update', PLUGIN_ID, '--scope', before.scope], STEP_TIMEOUT_MS).catch(() => null)- const output = `${updated?.stderr ?? ''}\n${updated?.stdout ?? ''}`+ // Every install that applies here and is behind: the user copy alone is not enough when this project has its own, which is the one+ // that loads. One that is already at `remote` is left alone (it only needs the restart).+ const behind = before.filter(entry => bumpKind(entry.version, remote) !== null)+ const scopes = [...new Set(behind.map(entry => entry.scope))]- if (updated !== null && updated.exitCode !== 0 && needsConfirmation(output)) return { outcome: 'failed', remote, detail: `Claude Code wants you to confirm this update itself: run \`${MANUAL_COMMAND}\` in a terminal` }- if (updated === null || updated.exitCode !== 0) return { outcome: 'failed', remote, detail: `claude plugin update failed: ${firstLine(output) || 'no answer'}` }+ for (const scope of scopes) {+ // No -y and no --accept-command, ever: a marketplace-declared command is Claude Code's to confirm with a person.+ const updated = await deps.run(['claude', 'plugin', 'update', PLUGIN_ID, '--scope', scope], STEP_TIMEOUT_MS).catch(() => null)+ const output = `${updated?.stderr ?? ''}\n${updated?.stdout ?? ''}`++ if (updated !== null && updated.exitCode !== 0 && needsConfirmation(output)) return { outcome: 'failed', remote, detail: `Claude Code wants you to confirm this update itself: run \`${MANUAL_COMMAND}\` in a terminal` }+ if (updated === null || updated.exitCode !== 0) return { outcome: 'failed', remote, detail: `claude plugin update (${scope} scope) failed: ${firstLine(output) || 'no answer'}` }+ }const after = await listInstalled(deps)+ const lagging = (after ?? []).filter(entry => bumpKind(entry.version, remote) !== null)- if (after !== null && after.version === remote) {+ if (after !== null && after.length > 0 && lagging.length === 0) {await deps.set(INSTALLED_KEY, remote)return { outcome: 'installed', remote, detail: `${remote} installed: restart Claude Code, or run /reload-plugins, to load it` }}- return { outcome: 'unverified', remote, detail: `the update ran, but Claude Code lists ${after?.version ?? 'no version'} (expected ${remote}): check /plugin, then restart` }+ return { outcome: 'unverified', remote, detail: `the update ran, but Claude Code lists ${(after ?? []).map(entry => `${entry.scope} ${entry.version}`).join(', ') || 'no version'} (expected ${remote}): check /plugin, then restart` }} finally {await deps.set(APPLYING_KEY, 0).catch(() => undefined)}@@ -121,9 +133,10 @@ export async function applyUpdate(deps: UpdateDeps, remote: string): Promise<Upd/*** One check. `force` is the person's own "check now": it ignores the daily gate and an off setting (they asked), but not a development- * checkout. Never throws: every failure is a result, and the console starts whatever happens here.+ * checkout. `quiet` is the re-check of a session left open: it never opens a dialog mid-work, so a newer version it would have asked about+ * is only noted (once, as a toast, and as the link to Settings), and the daily gate is left open so the next session start asks properly. Never throws: every failure is a result, and the console starts whatever happens here.*/-export async function checkForUpdate(deps: UpdateDeps, options: { force?: boolean } = {}): Promise<UpdateResult> {+export async function checkForUpdate(deps: UpdateDeps, options: { force?: boolean; quiet?: boolean } = {}): Promise<UpdateResult> {try {const force = options.force === trueconst mode = deps.mode()@@ -145,13 +158,23 @@ export async function checkForUpdate(deps: UpdateDeps, options: { force?: booleaif (remote === null) return { outcome: 'failed', detail: 'the published manifest is not one of ours' }- await deps.set(CHECKED_KEY, now)-const kind = bumpKind(deps.local, remote)+ const isQuietNote = options.quiet === true && kind !== null && decide(mode === 'off' ? 'ask' : mode, kind) === 'ask'++ if (!isQuietNote) await deps.set(CHECKED_KEY, now)if (kind === null) return { outcome: 'current', remote, detail: `${deps.local} is the newest published` }if ((await deps.get(INSTALLED_KEY)) === remote) return skipped(`${remote} is installed: restart Claude Code to load it`)+ if (isQuietNote) {+ if ((await deps.get(NOTIFIED_KEY)) !== remote) {+ await deps.set(NOTIFIED_KEY, remote)+ deps.toast(`ruflo-console ${remote} is available: Settings → Updates, or restart Claude Code`, 10_000)+ }++ return { outcome: 'declined', remote, detail: `${remote} is available; Settings → Updates installs it` }+ }+// "Check now" with checks off still asks: the person asked, but off means nothing is installed without them.const decision = decide(mode === 'off' ? 'ask' : mode, kind)@@ -181,6 +204,7 @@ export function updateDeps(state: State, host: Host): UpdateDeps {nowMs: () => Date.now(),after: (ms, fn) => host.after(ms, fn),local: CONSOLE_VERSION,+ cwd: state.cwd,isInteractive: state.isInteractive,isDevCheckout: () => getBuild() !== '',mode: () => state.updates,@@ -203,7 +227,7 @@ export function updateDeps(state: State, host: Host): UpdateDeps {}/** Runs a check with the real dependencies and leaves its outcome in a line for Settings. */-export async function runUpdateCheck(state: State, host: Host, options: { force?: boolean } = {}): Promise<UpdateResult> {+export async function runUpdateCheck(state: State, host: Host, options: { force?: boolean; quiet?: boolean } = {}): Promise<UpdateResult> {const result = await checkForUpdate(updateDeps(state, host), options)state.updateNote = result.detaildiff --git a/plugins/ruflo-console/hooks/updates.ts b/plugins/ruflo-console/hooks/updates.tsindex 0436e3ced5..5378ccb7be 100644--- a/plugins/ruflo-console/hooks/updates.ts+++ b/plugins/ruflo-console/hooks/updates.ts@@ -26,6 +26,10 @@ export const PLUGIN_ID = `${PLUGIN_NAME}@${MARKET}`export const MANIFEST_URL = 'https://raw.githubusercontent.com/ruvnet/ruflo/main/plugins/ruflo-console/.claude-plugin/plugin.json'/** How often a session checks (the answer is cached across sessions), and how long one session's "I am updating" holds the others off. */export const CHECK_EVERY_MS = 24 * 60 * 60_000+/** A session left open re-asks on this timer; the daily gate above still decides whether the network is touched. */+export const RECHECK_EVERY_MS = 6 * 60 * 60_000+/** The newest version a quiet re-check already told this person about, so a long session toasts once, not every tick. */+export const NOTIFIED_KEY = 'ruflo-console/update-notified'export const APPLYING_HOLD_MS = 10 * 60_000export const LABEL = { now: 'Update now', always: 'Always auto-update', later: 'Not now' } as const@@ -99,6 +103,32 @@ export function promptOf(local: string, remote: string, kind: Bump): { question:export type Installed = { version: string; scope: string }+/**+ * Every install of ours that applies to a session working in `cwd`: the user-scope one, and a project or local one whose project is+ * `cwd` or holds it. An install for another project does not load here, so it is never touched. If none of those is found but the plugin+ * is listed, the single entry `installedEntry` would pick stands in (an unusual layout still gets an update, not a refusal).+ */+export function installedEntries(listJson: string, cwd: string, id: string = PLUGIN_ID): Installed[] {+ try {+ const list = JSON.parse(listJson) as unknown++ if (!Array.isArray(list)) return []++ const ours = list.filter((entry): entry is { id: string; version?: unknown; scope?: unknown; projectPath?: unknown } => typeof entry === 'object' && entry !== null && (entry as { id?: unknown }).id === id)+ const here = (entry: { projectPath?: unknown }) => typeof entry.projectPath === 'string' && entry.projectPath !== '' && (cwd === entry.projectPath || cwd.startsWith(`${entry.projectPath.replace(/\/+$/, '')}/`))+ const applies = ours.filter(entry => entry.scope === 'user' || ((entry.scope === 'project' || entry.scope === 'local') && here(entry)))+ const valid = applies.flatMap(entry => (typeof entry.version === 'string' && typeof entry.scope === 'string' ? [{ version: entry.version, scope: entry.scope }] : []))++ if (valid.length > 0) return valid++ const single = installedEntry(listJson, id)++ return single === null ? [] : [single]+ } catch {+ return []+ }+}+/*** Our plugin in `claude plugin list --json`: the user-scope entry if there is one, else an enabled one, else the first. Null when it is* not installed from the marketplace (a session loaded with --plugin-dir has nothing to update) or the output is not the list.diff --git a/plugins/ruflo-console/hooks/version.ts b/plugins/ruflo-console/hooks/version.tsindex ca5c7689a9..6eb4fb183b 100644--- a/plugins/ruflo-console/hooks/version.ts+++ b/plugins/ruflo-console/hooks/version.ts@@ -2,4 +2,4 @@* The console's version, shown on the header so a person can tell which build is running. Kept equal to the plugin's manifest* (`.claude-plugin/plugin.json`); tests/version.spec.ts fails if the two drift.*/-export const CONSOLE_VERSION = '0.28.0'+export const CONSOLE_VERSION = '0.28.1'diff --git a/plugins/ruflo-console/scripts/smoke.sh b/plugins/ruflo-console/scripts/smoke.shindex 22644a8f11..24616492f1 100755--- a/plugins/ruflo-console/scripts/smoke.sh+++ b/plugins/ruflo-console/scripts/smoke.sh@@ -11,9 +11,9 @@ step() { printf "→ %s ... " "$1"; }ok() { printf "PASS\n"; PASS=$((PASS+1)); }bad() { printf "FAIL: %s\n" "$1"; FAIL=$((FAIL+1)); }-step "1. plugin.json declares ruflo-console 0.28.0"+step "1. plugin.json declares ruflo-console 0.28.1"grep -q '"name": "ruflo-console"' "$ROOT/.claude-plugin/plugin.json" \- && grep -q '"version": "0.28.0"' "$ROOT/.claude-plugin/plugin.json" && ok || bad "name/version"+ && grep -q '"version": "0.28.1"' "$ROOT/.claude-plugin/plugin.json" && ok || bad "name/version"step "2. hooks.json names exactly one module and no classic hook commands"grep -q '"modules": \["./register.ts"\]' "$HOOKS/hooks.json" && ! grep -q '"command"' "$HOOKS/hooks.json" \diff --git a/plugins/ruflo-console/tests/fixtures/update-session.ts b/plugins/ruflo-console/tests/fixtures/update-session.tsnew file mode 100644index 0000000000..03bd6c7c8f--- /dev/null+++ b/plugins/ruflo-console/tests/fixtures/update-session.ts@@ -0,0 +1,80 @@+import type { RunResult, UpdateDeps } from '../../hooks/update-flow'+import { INSTALLED_KEY, PLUGIN_ID } from '../../hooks/updates'++export const NOW = 1_800_000_000_000+export { INSTALLED_KEY, PLUGIN_ID }++/** A scripted session: what the store holds, what GitHub says, what the person picks, and how each command answers. */+export type Script = {+ mode?: UpdateDeps['mode'] extends () => infer M ? M : never+ store?: Record<string, unknown>+ manifest?: string | 'reject' | 'hang'+ published?: string+ choice?: string | 'reject'+ listed?: string[]+ isDev?: boolean+ interactive?: boolean+ marketExit?: number+ updateExit?: number+ updateOut?: string+ cwd?: string+}++export function session(script: Script = {}) {+ const store = new Map<string, unknown>(Object.entries(script.store ?? {}))+ let mode = script.mode ?? 'ask'+ const log = { fetches: 0, asked: [] as { question: string; options: readonly string[] }[], ran: [] as string[][], toasts: [] as string[], writes: [] as [string, unknown][] }+ const lists = [...(script.listed ?? [JSON.stringify([{ id: PLUGIN_ID, version: '0.26.0', scope: 'user', enabled: true }]), JSON.stringify([{ id: PLUGIN_ID, version: script.published ?? '0.27.0', scope: 'user', enabled: true }])])]+ const run = async (argv: readonly string[]): Promise<RunResult> => {+ log.ran.push([...argv])++ const text = argv.join(' ')++ if (text === 'claude plugin list --json') return { exitCode: 0, stdout: lists.length > 1 ? (lists.shift() as string) : (lists[0] as string), stderr: '' }+ if (text.startsWith('claude plugin marketplace update')) return { exitCode: script.marketExit ?? 0, stdout: 'updated', stderr: script.marketExit ? 'git: could not resolve host' : '' }++ return { exitCode: script.updateExit ?? 0, stdout: script.updateOut ?? 'updated', stderr: '' }+ }+ const deps: UpdateDeps = {+ nowMs: () => NOW,+ after: (_ms, fn) => {+ if (script.manifest === 'hang') fn()++ return { cancel: () => undefined } as never+ },+ local: '0.26.0',+ cwd: script.cwd ?? '/work/app',+ isInteractive: script.interactive ?? true,+ isDevCheckout: () => script.isDev ?? false,+ mode: () => mode,+ setMode: async next => {+ mode = next+ log.writes.push(['updates', next])+ },+ get: async key => store.get(key),+ set: async (key, value) => {+ store.set(key, value)+ log.writes.push([key, value])+ },+ fetchText: async () => {+ log.fetches++++ if (script.manifest === 'reject') throw new Error('network down')+ if (script.manifest === 'hang') return new Promise(() => undefined)++ return { ok: true, status: 200, text: script.manifest ?? JSON.stringify({ name: 'ruflo-console', version: script.published ?? '0.27.0' }) }+ },+ ask: async (question, options) => {+ log.asked.push({ question, options })++ if (script.choice === 'reject' || script.choice === undefined) throw new Error('dismissed')++ return script.choice+ },+ run,+ toast: text => void log.toasts.push(text),+ }++ return { deps, log, store, modeNow: () => mode }+}+diff --git a/plugins/ruflo-console/tests/updates-scope.spec.ts b/plugins/ruflo-console/tests/updates-scope.spec.tsnew file mode 100644index 0000000000..6a989f6a62--- /dev/null+++ b/plugins/ruflo-console/tests/updates-scope.spec.ts@@ -0,0 +1,107 @@+/**+ * The updater's scope rule and its quiet re-check: it updates every install that applies to the session (the user copy and this+ * project's), reads each back before calling it installed, and a session left open re-asks without opening a dialog.+ */+import { describe, expect, it } from 'vitest'++import { applyUpdate, checkForUpdate } from '../hooks/update-flow'+import { CHECK_EVERY_MS, CHECKED_KEY, installedEntries, LABEL, NOTIFIED_KEY, RECHECK_EVERY_MS } from '../hooks/updates'+import { INSTALLED_KEY, NOW, PLUGIN_ID, session } from './fixtures/update-session'++describe('every install that applies to the session', () => {+ const at = (scope: string, version: string, projectPath?: string) => ({ id: PLUGIN_ID, version, scope, enabled: true, ...(projectPath !== undefined && { projectPath }) })+ const list = (...entries: object[]) => JSON.stringify(entries)++ it('lists the user install and this project\'s, not another project\'s, and a folder inside the project counts as the project', () => {+ const json = list(at('user', '0.26.1'), at('project', '0.26.1', '/work/app'), at('project', '0.6.0', '/work/other'), at('local', '0.7.0', '/work/app-two'))++ expect(installedEntries(json, '/work/app')).toEqual([{ version: '0.26.1', scope: 'user' }, { version: '0.26.1', scope: 'project' }])+ expect(installedEntries(json, '/work/app/packages/ui').map(entry => entry.scope)).toEqual(['user', 'project'])+ expect(installedEntries(json, '/work/app-two').map(entry => `${entry.scope}@${entry.version}`)).toEqual(['[email protected]', '[email protected]'])+ expect(installedEntries(json, '/elsewhere').map(entry => entry.scope)).toEqual(['user'])+ })++ it('falls back to the single entry the old rule would pick, rather than refusing, when only other projects have it', () => {+ expect(installedEntries(list(at('project', '0.6.0', '/work/other')), '/work/app')).toEqual([{ version: '0.6.0', scope: 'project' }])+ for (const bad of ['', 'not json', '{}', '[]']) expect(installedEntries(bad, '/work/app')).toEqual([])+ })++ it('updates the project copy that loads here, not just the user copy, and reads both back', async () => {+ const s = session({ listed: [list(at('user', '0.27.0'), at('project', '0.26.0', '/work/app')), list(at('user', '0.27.0'), at('project', '0.27.0', '/work/app'))] })+ const result = await applyUpdate(s.deps, '0.27.0')++ expect(s.log.ran.filter(argv => argv[2] === 'update' && argv[1] === 'plugin' && argv[3] === PLUGIN_ID)).toEqual([['claude', 'plugin', 'update', PLUGIN_ID, '--scope', 'project']])+ expect(result.outcome).toBe('installed')+ })++ it('updates every scope that is behind, once each', async () => {+ const s = session({ listed: [list(at('user', '0.26.0'), at('project', '0.26.0', '/work/app')), list(at('user', '0.27.0'), at('project', '0.27.0', '/work/app'))] })+ const result = await applyUpdate(s.deps, '0.27.0')++ expect(s.log.ran.filter(argv => argv[3] === PLUGIN_ID).map(argv => argv[5])).toEqual(['user', 'project'])+ expect(result.outcome).toBe('installed')+ })++ it('does not call it installed while the copy that loads here is still behind', async () => {+ const stuck = list(at('user', '0.27.0'), at('project', '0.26.0', '/work/app'))+ const s = session({ listed: [stuck, stuck] })+ const result = await applyUpdate(s.deps, '0.27.0')++ expect(result.outcome).toBe('unverified')+ expect(result.detail).toContain('project 0.26.0')+ expect(s.store.get(INSTALLED_KEY)).toBeUndefined()+ })++ it('names the scope whose update failed', async () => {+ const s = session({ listed: [list(at('user', '0.26.0'))], updateExit: 1, updateOut: 'boom' })+ const result = await applyUpdate(s.deps, '0.27.0')++ expect(result.outcome).toBe('failed')+ expect(result.detail).toContain('user scope')+ })++ it('leaves an install that is already current alone and says to restart', async () => {+ const s = session({ listed: [list(at('user', '0.27.0'))] })+ const result = await applyUpdate(s.deps, '0.27.0')++ expect(s.log.ran.some(argv => argv[3] === PLUGIN_ID)).toBe(false)+ expect(result.outcome).toBe('installed')+ })+})++describe('the quiet re-check of a session left open', () => {+ it('re-asks more often than it touches the network, which the daily gate still limits', () => {+ expect(RECHECK_EVERY_MS).toBeLessThan(CHECK_EVERY_MS)+ })++ it('opens no dialog, toasts once, leaves the daily gate open, and still offers the version in Settings', async () => {+ const s = session({ choice: LABEL.now })+ const first = await checkForUpdate(s.deps, { quiet: true })++ expect(s.log.asked).toEqual([])+ expect(first).toMatchObject({ outcome: 'declined', remote: '0.27.0' })+ expect(s.log.toasts).toHaveLength(1)+ expect(s.store.get(CHECKED_KEY)).toBeUndefined()+ expect(s.store.get(NOTIFIED_KEY)).toBe('0.27.0')+ expect(s.log.ran).toEqual([])++ await checkForUpdate(s.deps, { quiet: true })+ expect(s.log.toasts).toHaveLength(1)+ })++ it('does not stop an install the person chose to be automatic', async () => {+ const s = session({ mode: 'auto' })+ const result = await checkForUpdate(s.deps, { quiet: true })++ expect(result.outcome).toBe('installed')+ expect(s.log.asked).toEqual([])+ })++ it('still marks the day as checked when nothing newer exists, and never installs while checks are off', async () => {+ const current = session({ published: '0.26.0' })++ expect((await checkForUpdate(current.deps, { quiet: true })).outcome).toBe('current')+ expect(current.store.get(CHECKED_KEY)).toBe(NOW)+ expect((await checkForUpdate(session({ mode: 'off' }).deps, { quiet: true })).outcome).toBe('skipped')+ })+})diff --git a/plugins/ruflo-console/tests/updates.spec.ts b/plugins/ruflo-console/tests/updates.spec.tsindex 84d9cb6c31..3c5f44d3ea 100644--- a/plugins/ruflo-console/tests/updates.spec.ts+++ b/plugins/ruflo-console/tests/updates.spec.ts@@ -6,7 +6,8 @@*/import { describe, expect, it } from 'vitest'-import { applyUpdate, checkForUpdate, type RunResult, type UpdateDeps } from '../hooks/update-flow'+import { applyUpdate, checkForUpdate, type UpdateDeps } from '../hooks/update-flow'+import { NOW, session } from './fixtures/update-session'import {APPLYING_HOLD_MS,APPLYING_KEY,@@ -16,7 +17,10 @@ import {decide,firstLine,INSTALLED_KEY,+ installedEntries,installedEntry,+ NOTIFIED_KEY,+ RECHECK_EVERY_MS,isBeingApplied,isDue,LABEL,@@ -28,7 +32,6 @@ import {versionFromManifest,} from '../hooks/updates'-const NOW = 1_800_000_000_000describe('versions', () => {it('reads major.minor.patch and nothing else', () => {@@ -145,78 +148,6 @@ describe('a line of output', () => {})})-/** A scripted session: what the store holds, what GitHub says, what the person picks, and how each command answers. */-type Script = {- mode?: UpdateDeps['mode'] extends () => infer M ? M : never- store?: Record<string, unknown>- manifest?: string | 'reject' | 'hang'- published?: string- choice?: string | 'reject'- listed?: string[]- isDev?: boolean- interactive?: boolean- marketExit?: number- updateExit?: number- updateOut?: string-}--function session(script: Script = {}) {- const store = new Map<string, unknown>(Object.entries(script.store ?? {}))- let mode = script.mode ?? 'ask'- const log = { fetches: 0, asked: [] as { question: string; options: readonly string[] }[], ran: [] as string[][], toasts: [] as string[], writes: [] as [string, unknown][] }- const lists = [...(script.listed ?? [JSON.stringify([{ id: PLUGIN_ID, version: '0.26.0', scope: 'user', enabled: true }]), JSON.stringify([{ id: PLUGIN_ID, version: script.published ?? '0.27.0', scope: 'user', enabled: true }])])]- const run = async (argv: readonly string[]): Promise<RunResult> => {- log.ran.push([...argv])-- const text = argv.join(' ')-- if (text === 'claude plugin list --json') return { exitCode: 0, stdout: lists.length > 1 ? (lists.shift() as string) : (lists[0] as string), stderr: '' }- if (text.startsWith('claude plugin marketplace update')) return { exitCode: script.marketExit ?? 0, stdout: 'updated', stderr: script.marketExit ? 'git: could not resolve host' : '' }-- return { exitCode: script.updateExit ?? 0, stdout: script.updateOut ?? 'updated', stderr: '' }- }- const deps: UpdateDeps = {- nowMs: () => NOW,- after: (_ms, fn) => {- if (script.manifest === 'hang') fn()-- return { cancel: () => undefined } as never- },- local: '0.26.0',- isInteractive: script.interactive ?? true,- isDevCheckout: () => script.isDev ?? false,- mode: () => mode,- setMode: async next => {- mode = next- log.writes.push(['updates', next])- },- get: async key => store.get(key),- set: async (key, value) => {- store.set(key, value)- log.writes.push([key, value])- },- fetchText: async () => {- log.fetches++-- if (script.manifest === 'reject') throw new Error('network down')- if (script.manifest === 'hang') return new Promise(() => undefined)-- return { ok: true, status: 200, text: script.manifest ?? JSON.stringify({ name: 'ruflo-console', version: script.published ?? '0.27.0' }) }- },- ask: async (question, options) => {- log.asked.push({ question, options })-- if (script.choice === 'reject' || script.choice === undefined) throw new Error('dismissed')-- return script.choice- },- run,- toast: text => void log.toasts.push(text),- }-- return { deps, log, store, modeNow: () => mode }-}-describe('the flow: when it does not even look', () => {it('does nothing when updates are off, in a non-interactive run, or in a development checkout', async () => {for (const script of [{ mode: 'off' as const }, { interactive: false }, { isDev: true }]) {