From 9979411e0898312028d583fdc25aa01f69bb6337 Mon Sep 17 00:00:00 2001 From: cflmy Date: Tue, 1 Dec 2026 09:24:55 +0800 Subject: [PATCH] feat: show the persisted update view in mqdh status Continue app-harness#16: MdhStatus carries the persisted UpdateState and mqdh status [--json] shows channel, last check time, availability, latest candidate and the last update error without triggering a network check. DISTRIBUTION distinguishes this read-only view from the explicit update check; the CLI test asserts the empty-install values and text line. Verified locally: typecheck 5/5, cli test 6 pass, all downstream node tests 77 pass/3 skipped. No release/tag; E09 notification/reconciliation and real Gitea feedback E2E remain UNVERIFIED. --- docs/mqdh/DISTRIBUTION.md | 1 + .../evidence/2026-11-30-status-update-view.md | 27 +++++++++++++++++++ packages/marqdo/harness/src/cli/main.ts | 2 ++ packages/marqdo/harness/src/runtime.ts | 4 +++ packages/marqdo/harness/tests/cli.test.ts | 6 +++++ 5 files changed, 40 insertions(+) create mode 100644 docs/mqdh/evidence/2026-11-30-status-update-view.md diff --git a/docs/mqdh/DISTRIBUTION.md b/docs/mqdh/DISTRIBUTION.md index 57512214f1..fd769510d3 100644 --- a/docs/mqdh/DISTRIBUTION.md +++ b/docs/mqdh/DISTRIBUTION.md @@ -74,6 +74,7 @@ mqdh update rollback --confirm [--json] - 更新不触碰 `MQDH_HOME/ecosystem`;Marqdo 运行时仍由 Bootstrap/生态中心独立管理。 - 应用仓库当前为私有开发仓时,匿名检查返回 403/404,状态显示 `update.unavailable`(不是伪造“已是最新”)。正式发行需公开仓库或显式配置凭据。 - `update check` 同时展示最新候选的 `published_at`、官方下载 URL(`latest.asset.url`)、Release 页面 URL(`latest.release_url`)、`known_limits` 与发布说明;发布说明来自可信 Gitea Release body(截断到 8 KiB),不是第二份清单。JSON 字段为 `latest.notes` 与 `latest.release_url`。 +- `mqdh status [--json]` 只读展示已持久化的更新视图(channel、上次检查时间、是否可更新、最新候选、最后一个错误),不触发网络检查;JSON 字段为 `update`。需要最新检查时显式运行 `mqdh update check`。 ## 5. 构建与发布 diff --git a/docs/mqdh/evidence/2026-11-30-status-update-view.md b/docs/mqdh/evidence/2026-11-30-status-update-view.md new file mode 100644 index 0000000000..f510027666 --- /dev/null +++ b/docs/mqdh/evidence/2026-11-30-status-update-view.md @@ -0,0 +1,27 @@ +# `mqdh status` 持久化更新视图(app-harness#16 切片) + +Date: 2026-11-30. Branch: `codex/issue-16-status-update`. +Baseline: `28df81ee11d2dccc0a1a2606394c477ff7b09987`(main)。 + +## 交付 + +- `MdhStatus` 新增 `update: UpdateState`(读取已持久化的更新状态,不触网); + `MdhRuntime.status()` 返回它。 +- `mqdh status --json` 输出 `update` 字段;文本输出新增 + `update: channel=… checked=… available=… latest=… [error=…]`。 +- `DISTRIBUTION.md` §4 区分只读状态视图与显式 `update check`(后者才触网)。 +- 测试:`cli.test.ts` 断言空安装下 `update.schema`/`channel`/`checked_at`/ + `latest` 与文本行。 + +## 验证(本机,Linux x86_64 / glibc 2.43) + +```text +pnpm run typecheck → 5/5 PASS +node --import tsx/esm --test packages/marqdo/harness/tests/cli.test.ts → 6 pass +node --import tsx/esm --test packages/marqdo/harness/tests/*.test.ts → 77 pass / 3 skipped +``` + +## 边界 + +- 只读持久化状态;不刷新、不提示、不下载、不安装,不执行 E09 通知/对账。 +- 未创建 release/tag;真实 Gitea 反馈提交与浏览器端到端仍 UNVERIFIED。 diff --git a/packages/marqdo/harness/src/cli/main.ts b/packages/marqdo/harness/src/cli/main.ts index 212faaab4b..7c63a2c01f 100644 --- a/packages/marqdo/harness/src/cli/main.ts +++ b/packages/marqdo/harness/src/cli/main.ts @@ -261,6 +261,7 @@ async function runStatus(parsed: ParsedCommand, io: CliIO, runtime: () => Promis market: status.market, knowledge: status.knowledge, privacy: status.privacy, + update: status.update, })) return 0 } @@ -280,6 +281,7 @@ async function runStatus(parsed: ParsedCommand, io: CliIO, runtime: () => Promis `market: entries=${status.market.entries} installed=${status.market.installed} enabled=${status.market.enabled}`, `knowledge: collections=${status.knowledge.collections} sources=${status.knowledge.sources} enabled=${status.knowledge.enabled}`, `privacy: telemetry=${String(status.privacy.telemetry)} session_upload=${String(status.privacy.sessionUpload)} plugin_install=${String(status.privacy.pluginInstall)}`, + `update: channel=${status.update.channel} checked=${status.update.checked_at ?? 'never'} available=${String(status.update.update_available)} latest=${status.update.latest?.version ?? 'unknown'}${status.update.last_error === null ? '' : ` error=${status.update.last_error.code}`}`, ].join('\n') + '\n') return 0 } diff --git a/packages/marqdo/harness/src/runtime.ts b/packages/marqdo/harness/src/runtime.ts index 8511fee40f..64dec63015 100644 --- a/packages/marqdo/harness/src/runtime.ts +++ b/packages/marqdo/harness/src/runtime.ts @@ -35,6 +35,7 @@ import { BootstrapManager } from './bootstrap/manager.ts' import { DiagnosticsStore } from './diagnostics/store.ts' import type { DiagnosticIdentity } from './diagnostics/store.ts' import { AppUpdater } from './distribution/updater.ts' +import type { UpdateState } from './distribution/updater.ts' import { targetTriple } from './platform/detect.ts' import { APP_VERSION } from './version.ts' import type { KnowledgeSearchResult } from './knowledge/manager.ts' @@ -88,6 +89,8 @@ export interface MdhStatus { readonly privacy: { readonly telemetry: false; readonly sessionUpload: false; readonly pluginInstall: false } readonly platform: string readonly node: string + /** Persisted application update view (no network check on read). */ + readonly update: UpdateState } /** Resolve one CLI path override safely. */ @@ -325,6 +328,7 @@ export class MdhRuntime { privacy: { telemetry: false, sessionUpload: false, pluginInstall: false }, platform: `${process.platform}-${process.arch}`, node: process.version, + update: await this.updater.state(), } } diff --git a/packages/marqdo/harness/tests/cli.test.ts b/packages/marqdo/harness/tests/cli.test.ts index 833d7d6a66..b408f1d547 100644 --- a/packages/marqdo/harness/tests/cli.test.ts +++ b/packages/marqdo/harness/tests/cli.test.ts @@ -92,14 +92,20 @@ test('status emits a read-only app and ecosystem version view', async () => { app: { version: string; home: string } ecosystem: { runtime: { installed: boolean }; std: { installed: boolean; modules: string[] } } privacy: { telemetry: boolean; sessionUpload: boolean; pluginInstall: boolean } + update: { schema: string; channel: string; checked_at: string | null; latest: unknown } } assert.equal(parsed.schema, 'marqdo.mqdh.status') assert.equal(parsed.app.version, APP_VERSION) assert.equal(parsed.ecosystem.runtime.installed, false) assert.equal(parsed.ecosystem.std.installed, false) assert.deepEqual(parsed.privacy, { telemetry: false, sessionUpload: false, pluginInstall: false }) + assert.equal(parsed.update.schema, 'marqdo.mqdh.update') + assert.equal(parsed.update.channel, 'stable') + assert.equal(parsed.update.checked_at, null) + assert.equal(parsed.update.latest, null) const text = sink() assert.equal(await runProductCli(['status'], { io: text.io, runtime: async () => runtime }), 0) assert.match(text.out.join(''), /^app: /) assert.match(text.out.join(''), /privacy: telemetry=false/) + assert.match(text.out.join(''), /update: channel=stable checked=never/) }) -- 2.54.1