mirror of
https://github.com/deepseek-ai/deepseek-harness
synced 2026-08-15 21:04:50 +00:00
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.
109 lines
3.3 KiB
JavaScript
109 lines
3.3 KiB
JavaScript
// Unit tests for src/renderer/compare-history.js — B4 helpers.
|
|
|
|
'use strict'
|
|
|
|
const test = require('node:test')
|
|
const assert = require('node:assert/strict')
|
|
|
|
const C = require('../src/renderer/compare-history.js')
|
|
|
|
test('extractText: scalar text wins', () => {
|
|
assert.equal(C.extractText({ text: 'hello' }), 'hello')
|
|
})
|
|
|
|
test('extractText: v2 content blocks concatenated in order, non-text dropped', () => {
|
|
const e = {
|
|
content: [
|
|
{ type: 'text', text: 'foo' },
|
|
{ type: 'image', data: '...' },
|
|
{ type: 'text', text: ' bar' },
|
|
],
|
|
}
|
|
assert.equal(C.extractText(e), 'foo bar')
|
|
})
|
|
|
|
test('extractText: null/undefined/empty → empty string', () => {
|
|
assert.equal(C.extractText(null), '')
|
|
assert.equal(C.extractText(undefined), '')
|
|
assert.equal(C.extractText({}), '')
|
|
})
|
|
|
|
test('findFirstUserMessage: v2 message/user with content block', () => {
|
|
const events = [
|
|
{ type: 'session/start' },
|
|
{ type: 'message/user', content: [{ type: 'text', text: 'why?' }] },
|
|
{ type: 'message/assistant', content: [{ type: 'text', text: 'because.' }] },
|
|
]
|
|
const hit = C.findFirstUserMessage(events)
|
|
assert.ok(hit)
|
|
assert.equal(hit.text, 'why?')
|
|
assert.equal(hit.index, 1)
|
|
})
|
|
|
|
test('findFirstUserMessage: legacy user/message with scalar text', () => {
|
|
const events = [
|
|
{ kind: 'user/message', text: 'legacy' },
|
|
]
|
|
const hit = C.findFirstUserMessage(events)
|
|
assert.ok(hit)
|
|
assert.equal(hit.text, 'legacy')
|
|
})
|
|
|
|
test('findFirstUserMessage: returns first, not last', () => {
|
|
const events = [
|
|
{ type: 'message/user', text: 'first' },
|
|
{ type: 'message/user', text: 'second' },
|
|
]
|
|
const hit = C.findFirstUserMessage(events)
|
|
assert.equal(hit.text, 'first')
|
|
assert.equal(hit.index, 0)
|
|
})
|
|
|
|
test('findFirstUserMessage: empty content skipped, next real user message wins', () => {
|
|
const events = [
|
|
{ type: 'message/user', content: [] },
|
|
{ type: 'message/user', text: 'the real one' },
|
|
]
|
|
const hit = C.findFirstUserMessage(events)
|
|
assert.equal(hit.text, 'the real one')
|
|
})
|
|
|
|
test('findFirstUserMessage: no user message → null', () => {
|
|
const events = [
|
|
{ type: 'message/assistant', text: 'hi' },
|
|
{ type: 'tool/call' },
|
|
]
|
|
assert.equal(C.findFirstUserMessage(events), null)
|
|
})
|
|
|
|
test('findFirstUserMessage: non-array input → null', () => {
|
|
assert.equal(C.findFirstUserMessage(null), null)
|
|
assert.equal(C.findFirstUserMessage(undefined), null)
|
|
assert.equal(C.findFirstUserMessage({}), null)
|
|
})
|
|
|
|
test('normaliseEventsResponse: plain array passthrough (fresh copy)', () => {
|
|
const src = [{ type: 'x' }]
|
|
const out = C.normaliseEventsResponse(src)
|
|
assert.deepEqual(out, src)
|
|
assert.notEqual(out, src) // must be a new array so mutation on either side is safe
|
|
})
|
|
|
|
test('normaliseEventsResponse: v2 wire shape', () => {
|
|
const out = C.normaliseEventsResponse({ events: [{ type: 'a' }, { type: 'b' }] })
|
|
assert.equal(out.length, 2)
|
|
assert.equal(out[0].type, 'a')
|
|
})
|
|
|
|
test('normaliseEventsResponse: legacy items shape', () => {
|
|
const out = C.normaliseEventsResponse({ items: [{ type: 'z' }] })
|
|
assert.equal(out.length, 1)
|
|
assert.equal(out[0].type, 'z')
|
|
})
|
|
|
|
test('normaliseEventsResponse: null/undefined/unknown → empty array', () => {
|
|
assert.deepEqual(C.normaliseEventsResponse(null), [])
|
|
assert.deepEqual(C.normaliseEventsResponse(undefined), [])
|
|
assert.deepEqual(C.normaliseEventsResponse({ foo: 'bar' }), [])
|
|
})
|