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.
124 lines
4.9 KiB
JavaScript
124 lines
4.9 KiB
JavaScript
// Tests for the Rubrics-page Create-from-scratch form (typed rubric
|
|
// primitive). The form is a script-tag IIFE that installs
|
|
// `window.__dshRubrics` at runtime; under `node --test` we `require()`
|
|
// it, which runs the IIFE with `typeof window === 'undefined'` — so the
|
|
// state + internals live on the CommonJS module.exports handle.
|
|
//
|
|
// We stub just enough of `document` so the module loads cleanly.
|
|
|
|
'use strict'
|
|
|
|
const test = require('node:test')
|
|
const assert = require('node:assert/strict')
|
|
|
|
global.document = {
|
|
addEventListener() {},
|
|
readyState: 'complete',
|
|
querySelector() { return null },
|
|
createElement() {
|
|
// Minimal element used only if openCreateForm's scroll-into-view path
|
|
// fires. We short-circuit by returning `null` from querySelector
|
|
// above; this stub is a defensive fallback.
|
|
return { style: {}, appendChild() {}, addEventListener() {} }
|
|
},
|
|
getElementById() { return null },
|
|
}
|
|
global.requestAnimationFrame = () => {}
|
|
|
|
const page = require('../src/renderer/rubrics-page.js')
|
|
const model = require('../src/renderer/rubrics-model.js')
|
|
const { state, draftAsMarkdown, buildDraftDimensionLine, slug, openCreateForm, closeCreateForm, saveCreateForm } = page._internal
|
|
|
|
function reset() {
|
|
state.rubrics = []
|
|
state.catalog = []
|
|
state.active = null
|
|
state.editMode = false
|
|
state.createForm = null
|
|
}
|
|
|
|
test('openCreateForm seeds a draft; closeCreateForm clears it', () => {
|
|
reset()
|
|
openCreateForm('llm-judge')
|
|
assert.ok(state.createForm, 'form draft present after open')
|
|
assert.equal(state.createForm.executor, 'llm-judge')
|
|
assert.equal(state.createForm.dimType, 'continuous', 'continuous is the default type')
|
|
closeCreateForm()
|
|
assert.equal(state.createForm, null)
|
|
})
|
|
|
|
test('slug produces filename-safe ids', () => {
|
|
assert.equal(slug('Feedback Tag'), 'feedback-tag')
|
|
assert.equal(slug('bad!!/name'), 'bad-name')
|
|
assert.equal(slug(''), 'unnamed')
|
|
assert.equal(slug(' '), 'unnamed')
|
|
})
|
|
|
|
test('buildDraftDimensionLine emits parseable syntax for each primitive', () => {
|
|
const cont = buildDraftDimensionLine({ dimName: 'quality', dimType: 'continuous', min: 0, max: 10 })
|
|
assert.match(cont, /^quality :: continuous :: 0-10 :: quality$/)
|
|
const cat = buildDraftDimensionLine({ dimName: 'verdict', dimType: 'categorical', values: ['red', 'green'] })
|
|
assert.match(cat, /categorical :: red,green/)
|
|
const bool = buildDraftDimensionLine({ dimName: 'passes bench', dimType: 'boolean', labels: { true: 'pass', false: 'fail' } })
|
|
assert.match(bool, /^passes-bench :: boolean :: pass\/fail/)
|
|
})
|
|
|
|
test('draftAsMarkdown round-trips through parseRubricFile for each primitive', () => {
|
|
const drafts = [
|
|
{ dimName: 'quality', dimType: 'continuous', min: 0, max: 10, group: 'code-gen', executor: 'llm-judge' },
|
|
{ dimName: 'verdict', dimType: 'categorical', values: ['red', 'green', 'blue'], group: 'code-gen', executor: 'llm-judge' },
|
|
{ dimName: 'passes', dimType: 'boolean', labels: { true: 'pass', false: 'fail' }, group: 'code-gen', executor: 'llm-judge' },
|
|
]
|
|
const wantTypes = ['continuous', 'categorical', 'boolean']
|
|
for (let i = 0; i < drafts.length; i++) {
|
|
const md = draftAsMarkdown(drafts[i])
|
|
const parsed = model.parseRubricFile(md)
|
|
assert.ok(parsed, drafts[i].dimType + ' parses')
|
|
assert.equal(parsed.dimensions.length, 1, drafts[i].dimType + ' emits one dim')
|
|
assert.equal(parsed.dimensions[0].type, wantTypes[i])
|
|
}
|
|
})
|
|
|
|
test('saveCreateForm inserts a parsed rubric into state; upsert on same name', () => {
|
|
reset()
|
|
openCreateForm('llm-judge')
|
|
state.createForm = {
|
|
...state.createForm,
|
|
dimName: 'quality',
|
|
dimType: 'continuous',
|
|
min: 0,
|
|
max: 10,
|
|
}
|
|
saveCreateForm()
|
|
assert.equal(state.rubrics.length, 1)
|
|
assert.equal(state.rubrics[0].name, 'quality')
|
|
assert.equal(state.rubrics[0].dimensions[0].type, 'continuous')
|
|
// Second save with same slug replaces, not duplicates.
|
|
openCreateForm('llm-judge')
|
|
state.createForm = { ...state.createForm, dimName: 'quality', dimType: 'boolean', labels: { true: 'y', false: 'n' } }
|
|
saveCreateForm()
|
|
assert.equal(state.rubrics.length, 1, 'upsert by slug, no duplicate')
|
|
assert.equal(state.rubrics[0].dimensions[0].type, 'boolean')
|
|
})
|
|
|
|
test('saveCreateForm fires dsh:rubric-created for lane consumers', () => {
|
|
reset()
|
|
const events = []
|
|
const prevWin = global.window
|
|
global.window = {
|
|
__dshAnnotation: null,
|
|
dispatchEvent(ev) { events.push(ev); return true },
|
|
}
|
|
global.CustomEvent = class { constructor(type, init = {}) { this.type = type; this.detail = init.detail } }
|
|
try {
|
|
openCreateForm('llm-judge')
|
|
state.createForm = { ...state.createForm, dimName: 'signal', dimType: 'continuous', min: 0, max: 1 }
|
|
saveCreateForm()
|
|
const ev = events.find(e => e.type === 'dsh:rubric-created')
|
|
assert.ok(ev, 'dsh:rubric-created fires')
|
|
assert.equal(ev.detail.rubricId, 'signal')
|
|
} finally {
|
|
global.window = prevWin
|
|
}
|
|
})
|