feat: read-only mqdh status ecosystem view (#16 slice) #19

Merged
cflmy merged 1 commits from codex/issue-16-status-view into main 2026-11-30 20:44:30 +08:00
5 changed files with 90 additions and 2 deletions

No files matched your search

+1 -1
View File
@@ -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 集成
@@ -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 结果以平台为准。
+43
View File
@@ -146,6 +146,7 @@ Usage: mqdh <command> [options]
Commands:
bootstrap [--channel stable|beta] [--offline <dir>] [--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<MdhRuntime>): Promise<number> {
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<MdhRuntime>): Promise<number> {
expectNoSubcommand(parsed)
+23
View File
@@ -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/)
})
+1 -1
View File
@@ -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() {