Files
deepseek-harness/examples/desktop/test/plugin-probe.test.js
T
ZiyaZhang e8f5c0b51b feat(desktop): DSH Electron desktop shell — harness internals visualized
Minimal Electron shell over the DSH JSON-RPC runtime — a first-look at
what a ChatGPT.app-style host on top of the DeepSeek Harness looks
like, with the harness's normally-invisible internals (trace timeline,
context surface, subagent tree, compaction, plugin registry, rubrics)
brought forward as first-class UI surfaces so plugin authors and
researchers can see what the agent is actually doing.

Runs against three keyless-to-live profiles (stdio-echo works on
master out of the box; daemon-echo / daemon-vibe-echo activate once
the daemon-demo lands; stdio-deepseek and daemon-vibe hit the real
DeepSeek API when you supply a key). HARNESS_DEV auto-resolves to the
in-repo runtime when this shell ships under examples/desktop/, so a
fresh clone launches without config; env DSH_DEV_ROOT overrides for
custom layouts, and a sibling deepseek-harness-dev/ checkout is the
original dev workflow.

Cold-clone gate (P0 fixes for first-time-clone usability):
- HARNESS_DEV: 3-candidate resolver (env → walk-up in-repo marker →
  sibling), unit-tested via mock fs so ordering is locked without
  needing either real layout on disk.
- config yml leaves rewritten at assemble time so the sibling-clone
  paths (../../deepseek-harness-dev/examples/echo-agent/…) become
  the in-repo paths (../../echo-agent/…) in the released tree —
  source yml stays usable for local dev, released tree ships a
  working shape.
- pnpm-workspace.yaml allowBuilds.electron = true (was placeholder).
- missing-key card in stdio-deepseek offers a one-click switch to
  stdio-echo (the keyless profile that works on master) rather than
  daemon-echo (blocked on the not-yet-shipped daemon-demo).
- assemble-oss-release.sh rewrites the source-side breadcrumb name
  'dsh-desktop-demo' → 'dsh-desktop' for the released package.json.

FOUC guard on the onboarding gate (41fc5df carried) keeps the
first-launch splash from flashing before the runtime probe finishes.

Test suite (1634 tests in source, 3990 in the runtime repo) covers
resolver ordering, renderer classifiers, trace timeline shape,
compaction diff rendering, rubric parity, and the missing-key
onboarding paths.
2026-07-18 12:59:34 -07:00

82 lines
3.1 KiB
JavaScript

// Unit tests for src/main/plugin-probe.js. The pure parts — pattern
// matching, anchor-to-row — are covered here; the full boot path is
// exercised by the README manual verification (booting a daemon in a
// unit-test loop is flaky enough that the smoke script is the right
// venue).
'use strict'
const test = require('node:test')
const assert = require('node:assert/strict')
const P = require('../src/main/plugin-probe.js')
test('parseFailLoudLines: recognises missing-module errors', () => {
const stderr = [
'ready',
"Error: Cannot find module '@deepseek-ai/dsh-does-not-exist'",
" at ...",
].join('\n')
const findings = P.parseFailLoudLines(stderr)
const match = findings.find((f) => f.kind === 'package')
assert.ok(match)
assert.equal(match.value, '@deepseek-ai/dsh-does-not-exist')
})
test('parseFailLoudLines: recognises plugin failed-to-load', () => {
const stderr = 'plugin "session-query" failed to load: something'
const findings = P.parseFailLoudLines(stderr)
const match = findings.find((f) => f.kind === 'id')
assert.ok(match)
assert.equal(match.value, 'session-query')
})
test('parseFailLoudLines: recognises service-not-found', () => {
const stderr = 'Error: service "sessionQuery" not found for daemon-agent'
const findings = P.parseFailLoudLines(stderr)
const match = findings.find((f) => f.kind === 'service')
assert.ok(match)
assert.equal(match.value, 'sessionQuery')
})
test('parseFailLoudLines: catchall keeps error-ish lines even without a pattern hit', () => {
const stderr = 'random error line about something else'
const findings = P.parseFailLoudLines(stderr)
assert.equal(findings.length, 1)
assert.equal(findings[0].kind, 'unknown')
assert.equal(findings[0].value, null)
})
test('parseFailLoudLines: empty input → empty findings', () => {
assert.deepEqual(P.parseFailLoudLines(''), [])
assert.deepEqual(P.parseFailLoudLines(null), [])
})
test('anchorFindings: package-kind matches by name to a base entry', () => {
const baseEntries = [
{ id: 'bash', name: '@deepseek-ai/dsh-bash-local' },
{ id: 'fs', name: '@deepseek-ai/dsh-fs-local' },
]
const findings = [{ kind: 'package', value: '@deepseek-ai/dsh-bash-local', message: 'Cannot find module …' }]
const diags = P.anchorFindings(findings, baseEntries, [])
assert.equal(diags.length, 1)
assert.equal(diags[0].scope, 'entry')
assert.equal(diags[0].id, 'bash')
assert.match(diags[0].message, /Cannot find module/)
})
test('anchorFindings: id-kind matches to an overlay patch that introduces a new entry', () => {
const findings = [{ kind: 'id', value: 'custom', message: 'plugin "custom" failed to load' }]
const overlay = [{ id: 'custom', name: '@x/y' }]
const diags = P.anchorFindings(findings, [], overlay)
assert.equal(diags[0].id, 'custom')
assert.equal(diags[0].scope, 'entry')
})
test('anchorFindings: unknown findings fall through to overall diagnostics', () => {
const findings = [{ kind: 'unknown', value: null, message: 'something bad happened' }]
const diags = P.anchorFindings(findings, [], [])
assert.equal(diags[0].scope, 'overall')
assert.match(diags[0].message, /something bad happened/)
})