Files
marqdo-app-harness/packages/marqdo/harness/tests/bundle.test.ts
T
cflmy 25fc24eea4 feat: add Marqdo Harness product services and workbench
Implement the downstream product in `packages/marqdo`:

- `@marqdo/mdh-harness`: application home layout, atomic writes, locks,
  bounded fixed-argv processes, safe tar extraction, Observation 1 and
  ValueWire validation;
- trusted Gitea release discovery, SHA-256/platform/Bundle verification,
  transactional environment install, rollback and cleanup, CLI Tool changes;
- private knowledge collections with strict import policy, the official
  `marqdo-knowledge` compile/query adapter and a disclosed locator fallback;
- Analysis 3 parsing, approved run/call execution, evidence and staleness;
- the six model operations (find/read/check/program/ecosystem/knowledge_search);
- the `/mdh` workbench over the existing web server with a same-origin fence;
- `mdh` launcher, CI/package/upstream scripts and a Woodpecker pipeline.

Tests: 28 node:test cases (27 PASS, one network-gated install test also PASS
with MDH_TEST_INSTALL=1). Product install/workbench evidence is recorded in
docs/mdh/evidence.

Part of marqdo#25 (MDH-03..MDH-08).
2026-11-28 10:41:39 +08:00

66 lines
2.7 KiB
TypeScript

/**
* Product composition tests over the real bundle patches. They apply the same
* patch algorithm the launcher uses, so a row that silently disappears or an
* upstream rename fails here rather than at boot.
*/
import assert from 'node:assert/strict'
import { dirname, join, resolve } from 'node:path'
import { fileURLToPath } from 'node:url'
import { test } from 'node:test'
import { loadOverlayPatches } from '../../../boot/app-boot/src/index.ts'
import { applyEntryPatches } from '@deepseek-ai/cordis-plugin-include'
import { TOOL_NAMES } from '../src/tools/index.ts'
const here = dirname(fileURLToPath(import.meta.url))
const repo = resolve(here, '../../../..')
/** Apply the shipped bundle layers in profile order. */
function compose(): { id: string; disabled?: boolean; config?: Record<string, unknown> }[] {
const files = [
'packages/bundle/base/cordis.patch.yml',
'packages/bundle/web-app/cordis.patch.yml',
'packages/bundle/web-app/presets/standard.patch.yml',
'packages/bundle/web-app/presets/ptc.patch.yml',
'packages/bundle/web-app/presets/minimal.patch.yml',
'packages/bundle/web-app/presets/cordis.patch.yml',
'packages/marqdo/bundle/cordis.patch.yml',
]
let tree: unknown[] = []
for (const relative of files) {
const patches = loadOverlayPatches('test', join(repo, relative))
const result = applyEntryPatches(tree as never, patches as never, () => undefined) as unknown as { data: unknown[] }
tree = result.data
}
return tree as never
}
test('the product bundle disables the Node PTC preset and plugin installation', () => {
const rows = compose()
const byId = new Map(rows.map(row => [row.id, row]))
assert.equal(byId.get('preset-ptc')?.disabled, true)
assert.equal(byId.get('plugin-manager')?.disabled, true)
assert.equal(byId.get('tool-plugin-manager')?.disabled, true)
assert.equal(byId.get('session-log-deepseek')?.disabled, true)
assert.equal(byId.get('session-telemetry-otel')?.disabled, true)
assert.equal(byId.get('message-feedback')?.disabled, true)
assert.equal(byId.get('web-fetch-http')?.disabled, true)
assert.equal(byId.get('web-search-deepseek')?.disabled, true)
})
test('the product bundle inserts exactly the Marqdo rows and persona', () => {
const rows = compose()
const harness = rows.find(row => row.id === 'mdh-harness')
const web = rows.find(row => row.id === 'mdh-web')
assert.ok(harness)
assert.ok(web)
assert.equal(harness.config?.maxRunMs, 300000)
const prompt = rows.find(row => row.id === 'system-prompt')
assert.match(String(prompt?.config?.personaPrefix), /Marqdo Harness/)
assert.equal(TOOL_NAMES.length, 6)
assert.deepEqual([...TOOL_NAMES], [
'marqdo_find', 'marqdo_read', 'marqdo_check', 'marqdo_program', 'marqdo_ecosystem', 'knowledge_search',
])
})