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.
114 lines
5.0 KiB
JavaScript
114 lines
5.0 KiB
JavaScript
// Pure-fn tests for the PR page filter + chip-count helpers.
|
|
//
|
|
// The renderer file registers a `window.__dshPRs` handle when window is
|
|
// present, so we run it under a minimal stub — enough to let the IIFE
|
|
// evaluate — and then read the helpers off the module.exports seam.
|
|
|
|
'use strict'
|
|
|
|
const test = require('node:test')
|
|
const assert = require('node:assert/strict')
|
|
|
|
function loadModule() {
|
|
const p = require.resolve('../src/renderer/pr-page.js')
|
|
delete require.cache[p]
|
|
// The IIFE checks `typeof window !== 'undefined'` before touching the DOM
|
|
// handle. Leaving window undefined here means the module goes straight to
|
|
// the module.exports seam without ever calling document.getElementById.
|
|
return require('../src/renderer/pr-page.js')
|
|
}
|
|
|
|
const { _internal } = loadModule()
|
|
const { matchesFilter, matchesQuery, computeChipCounts } = _internal
|
|
|
|
// Row factory — mirrors the shape gh-prs.js emits.
|
|
function row(overrides) {
|
|
return {
|
|
number: 1, title: 'sample', state: 'OPEN', stateDot: 'open',
|
|
headRefName: 'feature/x', baseRefName: 'master',
|
|
authorLogin: 'zi', additions: 10, deletions: 2,
|
|
url: 'https://example', updatedAt: new Date().toISOString(),
|
|
dropped: false,
|
|
...overrides,
|
|
}
|
|
}
|
|
|
|
// ---- matchesFilter ---------------------------------------------------------
|
|
|
|
test('matchesFilter: all keeps every non-dropped row regardless of state', () => {
|
|
assert.equal(matchesFilter(row({ state: 'OPEN' }), 'all', 'zi'), true)
|
|
assert.equal(matchesFilter(row({ state: 'MERGED' }), 'all', 'zi'), true)
|
|
assert.equal(matchesFilter(row({ state: 'CLOSED' }), 'all', 'zi'), true)
|
|
})
|
|
|
|
test('matchesFilter: dropped rows are always excluded', () => {
|
|
assert.equal(matchesFilter(row({ dropped: true }), 'all', ''), false)
|
|
assert.equal(matchesFilter(row({ dropped: true }), 'open', ''), false)
|
|
assert.equal(matchesFilter(row({ dropped: true }), 'mine', 'zi'), false)
|
|
})
|
|
|
|
test('matchesFilter: open keeps only OPEN rows', () => {
|
|
assert.equal(matchesFilter(row({ state: 'OPEN' }), 'open', ''), true)
|
|
assert.equal(matchesFilter(row({ state: 'MERGED' }), 'open', ''), false)
|
|
assert.equal(matchesFilter(row({ state: 'CLOSED' }), 'open', ''), false)
|
|
assert.equal(matchesFilter(row({ state: 'DRAFT' }), 'open', ''), false)
|
|
})
|
|
|
|
test('matchesFilter: mine requires a viewer and exact case-insensitive match', () => {
|
|
assert.equal(matchesFilter(row({ authorLogin: 'zi' }), 'mine', ''), false, 'no viewer ⇒ nothing is "mine"')
|
|
assert.equal(matchesFilter(row({ authorLogin: 'zi' }), 'mine', 'zi'), true)
|
|
assert.equal(matchesFilter(row({ authorLogin: 'ZI' }), 'mine', 'zi'), true, 'case-insensitive')
|
|
assert.equal(matchesFilter(row({ authorLogin: 'other' }), 'mine', 'zi'), false)
|
|
})
|
|
|
|
// ---- matchesQuery ----------------------------------------------------------
|
|
|
|
test('matchesQuery: empty query matches everything', () => {
|
|
assert.equal(matchesQuery(row({}), ''), true)
|
|
})
|
|
|
|
test('matchesQuery: hits on title / branch / author / #number', () => {
|
|
const r = row({
|
|
number: 42, title: 'RFC: gui host integration',
|
|
headRefName: 'rfc/gui-host', authorLogin: 'tianyi',
|
|
})
|
|
assert.equal(matchesQuery(r, 'gui'), true, 'title')
|
|
assert.equal(matchesQuery(r, 'rfc/'), true, 'branch')
|
|
assert.equal(matchesQuery(r, 'tianyi'), true, 'author')
|
|
assert.equal(matchesQuery(r, '42'), true, 'number substring')
|
|
assert.equal(matchesQuery(r, 'nowhere'), false)
|
|
})
|
|
|
|
// ---- computeChipCounts -----------------------------------------------------
|
|
|
|
test('computeChipCounts: pill counts reflect current query', () => {
|
|
const rows = [
|
|
row({ state: 'OPEN', authorLogin: 'zi', title: 'runtime seam' }),
|
|
row({ state: 'OPEN', authorLogin: 'other', title: 'seam docs' }),
|
|
row({ state: 'MERGED', authorLogin: 'zi', title: 'runtime tests' }),
|
|
row({ state: 'CLOSED', authorLogin: 'zi', title: 'other' }),
|
|
row({ dropped: true, authorLogin: 'zi', title: 'runtime x' }),
|
|
]
|
|
assert.deepEqual(computeChipCounts(rows, 'zi', ''), { all: 4, open: 2, mine: 3 })
|
|
assert.deepEqual(computeChipCounts(rows, 'zi', 'runtime'), { all: 2, open: 1, mine: 2 })
|
|
assert.deepEqual(computeChipCounts(rows, '', ''), { all: 4, open: 2, mine: 0 },
|
|
'no viewer ⇒ mine=0 even for rows whose author matches nothing')
|
|
})
|
|
|
|
test('computeChipCounts: chip-count math matches filterRows post-hoc', () => {
|
|
// The count next to a chip must equal what pressing that chip would show.
|
|
// This test rebuilds that expectation manually and pins the invariant.
|
|
const rows = [
|
|
row({ state: 'OPEN', authorLogin: 'zi' }),
|
|
row({ state: 'OPEN', authorLogin: 'other' }),
|
|
row({ state: 'MERGED', authorLogin: 'zi' }),
|
|
]
|
|
const q = ''
|
|
const counts = computeChipCounts(rows, 'zi', q)
|
|
const bucket = (filter) =>
|
|
rows.filter((r) => matchesFilter(r, filter, 'zi') && matchesQuery(r, q)).length
|
|
assert.equal(counts.all, bucket('all'))
|
|
assert.equal(counts.open, bucket('open'))
|
|
assert.equal(counts.mine, bucket('mine'))
|
|
})
|