From fd1d129e00f8ba18cd63e45753405fb6e7012b8b Mon Sep 17 00:00:00 2001 From: cflmy Date: Mon, 30 Nov 2026 20:21:33 +0800 Subject: [PATCH] feat: add a read-only mqdh status ecosystem view Start the app-harness#16 version-visibility slice with `mqdh status [--json]`: one read-only report of the application version/home/workspace, platform and Node, ecosystem candidate/version, Bundle version/modules/digest, installed tool versions, market/knowledge counts and the privacy constants. JSON uses the stable schema marqdo.mqdh.status. The launcher product-command set and HELP include status; ARCHITECTURE records the command. The CLI test covers JSON and text output for an empty install and asserts the honest "not installed"/false values. This is not the full latest version/release-notes/download view from #16; that remains UNVERIFIED. Verified locally: all downstream node tests 77 pass/3 skipped; typecheck gates 5/5 pass. --- docs/mqdh/ARCHITECTURE.md | 2 +- .../evidence/2026-11-30-status-command.md | 22 ++++++++++ packages/marqdo/harness/src/cli/main.ts | 43 +++++++++++++++++++ packages/marqdo/harness/tests/cli.test.ts | 23 ++++++++++ scripts/mqdh.mjs | 2 +- 5 files changed, 90 insertions(+), 2 deletions(-) create mode 100644 docs/mqdh/evidence/2026-11-30-status-command.md diff --git a/docs/mqdh/ARCHITECTURE.md b/docs/mqdh/ARCHITECTURE.md index 66a8e2e8ea..3dbd93eaf8 100644 --- a/docs/mqdh/ARCHITECTURE.md +++ b/docs/mqdh/ARCHITECTURE.md @@ -40,7 +40,7 @@ apps/harness/ # 独立应用仓库(父仓 gitlink:apps │ ├── src/diagnostics/ # 脱敏报告、去重、Gitea Issue 提交 │ ├── src/knowledge/ # 私人知识集合、导入、索引适配、检索 │ ├── src/execution/ # Analysis 3、CLI argv、审批、证据 -│ ├── src/cli/ # 产品命令(bootstrap/doctor/repair/report/update/network) +│ ├── src/cli/ # 产品命令(bootstrap/status/doctor/repair/report/update/network) │ ├── src/tools/ # 面向模型的六个操作 │ ├── src/web/ # /mqdh 页面与同源只读/受控写 API │ └── tests/ # node:test 单元与真实 CLI/Release 集成 diff --git a/docs/mqdh/evidence/2026-11-30-status-command.md b/docs/mqdh/evidence/2026-11-30-status-command.md new file mode 100644 index 0000000000..d4dc17b0fc --- /dev/null +++ b/docs/mqdh/evidence/2026-11-30-status-command.md @@ -0,0 +1,22 @@ +# `mqdh status` 生态版本视图(app-harness#16 切片) + +Date: 2026-11-30. Branch: `codex/issue-16-status-view`. +Baseline: `a1517652c29ac51357275661a59e7814b596efc8`(main)。 + +## 交付 + +- 新增只读产品命令 `mqdh status [--json]`:一次输出应用版本/home/workspace、平台与 Node、运行时候选版本、生态环境 id、Bundle 版本/模块数/摘要、已安装 Tool 版本、market/knowledge 计数与 privacy 常量;JSON schema `marqdo.mqdh.status`(`schema_version: 1`)。 +- `scripts/mqdh.mjs` 的产品命令集合加入 `status`(避免落到 DSH 转发);HELP 更新。 +- `docs/mqdh/ARCHITECTURE.md` 产品命令列表更新。 +- 测试:`packages/marqdo/harness/tests/cli.test.ts` 新增 `status` JSON/文本断言(未安装生态时如实显示 not installed/false)。 + +## 验证(本机,Linux x86_64 / glibc 2.43) + +```text +$ node --import tsx/esm --test packages/marqdo/harness/tests/cli.test.ts +6 pass, 0 fail +``` + +该命令只读现有 `MdhRuntime.status()` 状态,不触发安装/网络/更新;不是 #16 的 +“最新版本/发布说明/下载入口”完整生态版本检查,那部分保持 UNVERIFIED。未运行 +完整组件测试,组件 CI 结果以平台为准。 diff --git a/packages/marqdo/harness/src/cli/main.ts b/packages/marqdo/harness/src/cli/main.ts index 564fa288f5..b46678af26 100644 --- a/packages/marqdo/harness/src/cli/main.ts +++ b/packages/marqdo/harness/src/cli/main.ts @@ -146,6 +146,7 @@ Usage: mqdh [options] Commands: bootstrap [--channel stable|beta] [--offline ] [--force] [--json] + status [--json] doctor [--json] repair [--json] report list|show|export|submit|delete|token [...] @@ -187,6 +188,8 @@ export async function runProductCli(argv: readonly string[], options: CliOptions switch (parsed.command) { case 'bootstrap': return await runBootstrap(parsed, io, runtime) + case 'status': + return await runStatus(parsed, io, runtime) case 'doctor': return await runDoctor(parsed, io, runtime) case 'repair': @@ -241,6 +244,46 @@ async function runBootstrap(parsed: ParsedCommand, io: CliIO, runtime: () => Pro return state.status === 'failed' ? 1 : 0 } +/** `mqdh status`: one read-only ecosystem/app version view. */ +async function runStatus(parsed: ParsedCommand, io: CliIO, runtime: () => Promise): Promise { + expectNoSubcommand(parsed) + allowFlags(parsed, ['json']) + const app = await runtime() + const status = await app.status() + if (booleanFlag(parsed, 'json')) { + io.stdout(json({ + schema: 'marqdo.mqdh.status', + schema_version: 1, + app: { version: APP_VERSION, home: status.home, workspace: status.workspace }, + platform: status.platform, + node: status.node, + ecosystem: status.ecosystem, + market: status.market, + knowledge: status.knowledge, + privacy: status.privacy, + })) + return 0 + } + const environment = status.ecosystem.current + const version = environment ? `${environment.version} (${environment.id})` : 'not installed' + const tools = status.ecosystem.tools.length === 0 + ? 'none' + : status.ecosystem.tools.map(tool => `${tool.command} ${tool.version ?? 'unknown'}`).join(', ') + io.stdout([ + `app: ${APP_VERSION} home: ${status.home}`, + `workspace: ${status.workspace}`, + `platform: ${status.platform} node: ${status.node}`, + `runtime: ${status.ecosystem.runtime.version ?? 'not installed'}`, + `environment: ${version}`, + `bundle: ${status.ecosystem.std.version ?? 'not installed'} modules=${status.ecosystem.std.modules.length} digest=${status.ecosystem.std.digest ?? 'n/a'}`, + `tools: ${tools}`, + `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)}`, + ].join('\n') + '\n') + return 0 +} + /** `mqdh doctor`. */ async function runDoctor(parsed: ParsedCommand, io: CliIO, runtime: () => Promise): Promise { expectNoSubcommand(parsed) diff --git a/packages/marqdo/harness/tests/cli.test.ts b/packages/marqdo/harness/tests/cli.test.ts index e18ea5f8a5..833d7d6a66 100644 --- a/packages/marqdo/harness/tests/cli.test.ts +++ b/packages/marqdo/harness/tests/cli.test.ts @@ -80,3 +80,26 @@ test('a token is read from stdin and stored without appearing in output', async assert.doesNotMatch(output.out.join(''), new RegExp(token)) assert.equal(await runtime.diagnostics.hasToken(), true) }) + +test('status emits a read-only app and ecosystem version view', async () => { + const root = await mkdtemp(join(tmpdir(), 'mqdh-cli-')) + const runtime = await MdhRuntime.create({ home: join(root, 'home'), workspace: join(root, 'ws') }) + const view = sink() + const code = await runProductCli(['status', '--json'], { io: view.io, runtime: async () => runtime }) + assert.equal(code, 0) + const parsed = JSON.parse(view.out.join('')) as { + schema: string + app: { version: string; home: string } + ecosystem: { runtime: { installed: boolean }; std: { installed: boolean; modules: string[] } } + privacy: { telemetry: boolean; sessionUpload: boolean; pluginInstall: boolean } + } + 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 }) + 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/) +}) diff --git a/scripts/mqdh.mjs b/scripts/mqdh.mjs index b1823ac471..8d49be3f0c 100755 --- a/scripts/mqdh.mjs +++ b/scripts/mqdh.mjs @@ -19,7 +19,7 @@ import { spawn } from 'node:child_process' const here = dirname(fileURLToPath(import.meta.url)) const root = resolve(here, '..') -const productCommands = new Set(['bootstrap', 'doctor', 'repair', 'report', 'update', 'network', 'uninstall', 'help']) +const productCommands = new Set(['bootstrap', 'status', 'doctor', 'repair', 'report', 'update', 'network', 'uninstall', 'help']) /** Resolve the application home without touching the user's `~/.dsh`. */ function resolveHome() { -- 2.54.1