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.
115 lines
5.4 KiB
JavaScript
115 lines
5.4 KiB
JavaScript
// HARNESS_DEV candidate-ordering lock (2026-07-18, P0-1 in-repo detection).
|
|
//
|
|
// Fresh clones of the official repo don't have a sibling
|
|
// `deepseek-harness-dev/`, so the previous sibling-only resolver handed
|
|
// the runtime spawner a phantom path and preflight refused to boot.
|
|
// `resolveHarnessDev` now tries three candidates in order:
|
|
//
|
|
// 1. env `DSH_DEV_ROOT` — explicit override.
|
|
// 2. walk-up in-repo — first ancestor of the startDir that contains
|
|
// `packages/examples/jsonrpc-demo/src/bin.ts`. This is the shape a
|
|
// user hits when this shell ships inside deepseek-harness at
|
|
// `examples/desktop/`.
|
|
// 3. sibling `deepseek-harness-dev/` (with `.worktrees/integration`
|
|
// preference) — the original dev-workflow layout.
|
|
//
|
|
// These tests drive the resolver against a mock filesystem so the
|
|
// ordering is locked without needing either real layout on disk.
|
|
|
|
'use strict'
|
|
|
|
const test = require('node:test')
|
|
const assert = require('node:assert/strict')
|
|
const path = require('node:path')
|
|
|
|
const { resolveHarnessDev } = require('../src/main/profiles.js')
|
|
|
|
function mockFsWith(existing) {
|
|
// A minimal `accessSync` shim that throws unless the queried path
|
|
// matches one of the entries in `existing` (a Set of absolute paths).
|
|
const set = existing instanceof Set ? existing : new Set(existing)
|
|
return {
|
|
accessSync(p) {
|
|
if (!set.has(p)) {
|
|
const err = new Error(`ENOENT: no such file or directory, access '${p}'`)
|
|
err.code = 'ENOENT'
|
|
throw err
|
|
}
|
|
},
|
|
}
|
|
}
|
|
|
|
test('candidate 1 wins: DSH_DEV_ROOT env overrides everything else', () => {
|
|
// Even if the in-repo marker exists AND a sibling clone exists, the
|
|
// env override takes precedence and gets resolved to an absolute path.
|
|
const start = '/repo/examples/desktop/src/main'
|
|
const fs = mockFsWith([
|
|
// in-repo marker (would win candidate 2 otherwise)
|
|
'/repo/packages/examples/jsonrpc-demo/src/bin.ts',
|
|
// integration daemon dir (would win candidate 3 otherwise)
|
|
'/other/deepseek-harness-dev/.worktrees/integration/packages/examples/daemon-demo',
|
|
])
|
|
const got = resolveHarnessDev(start, { DSH_DEV_ROOT: '/custom/checkout' }, fs)
|
|
assert.equal(got, path.resolve('/custom/checkout'))
|
|
})
|
|
|
|
test('candidate 2 wins: in-repo marker on the ancestor chain when no env', () => {
|
|
// Startdir is examples/desktop/src/main; repo root two levels up
|
|
// holds the jsonrpc-demo marker. The walk-up should return that root
|
|
// before falling through to the sibling candidate.
|
|
const start = '/repo/examples/desktop/src/main'
|
|
const marker = '/repo/packages/examples/jsonrpc-demo/src/bin.ts'
|
|
const fs = mockFsWith([marker])
|
|
const got = resolveHarnessDev(start, {}, fs)
|
|
assert.equal(got, '/repo')
|
|
})
|
|
|
|
test('candidate 2 walks up at most 6 levels, then gives up', () => {
|
|
// Bury the marker 7 levels up — beyond the cap. Resolver must NOT
|
|
// find it; it should fall through to candidate 3 (sibling) which
|
|
// itself doesn't exist here, so the resolver returns the base sibling
|
|
// path unchanged (no exception).
|
|
const start = '/a/b/c/d/e/f/g/src/main'
|
|
const marker = '/a/packages/examples/jsonrpc-demo/src/bin.ts' // 8 levels up from start
|
|
const fs = mockFsWith([marker])
|
|
const got = resolveHarnessDev(start, {}, fs)
|
|
// Sibling fallback: __dirname's ../../../deepseek-harness-dev
|
|
const expectedBase = path.resolve(start, '..', '..', '..', 'deepseek-harness-dev')
|
|
assert.equal(got, expectedBase, 'walk-up must not reach past the 6-level cap; falls through to sibling')
|
|
})
|
|
|
|
test('candidate 3 wins: sibling deepseek-harness-dev is the fallback when no marker on chain', () => {
|
|
// No in-repo marker anywhere, and no integration daemon-demo either
|
|
// — the resolver returns the base sibling path.
|
|
const start = '/ws/dsh-desktop-demo/src/main'
|
|
const fs = mockFsWith([]) // nothing exists
|
|
const got = resolveHarnessDev(start, {}, fs)
|
|
assert.equal(got, path.resolve('/ws/dsh-desktop-demo/src/main', '..', '..', '..', 'deepseek-harness-dev'))
|
|
assert.equal(got, '/ws/deepseek-harness-dev', 'sibling one directory up from the demo root')
|
|
})
|
|
|
|
test('candidate 3 prefers .worktrees/integration when daemon-demo is materialized there', () => {
|
|
// Sibling `deepseek-harness-dev` exists with the integration worktree
|
|
// materialized (Phase-2 daemon lives there until it lands on master),
|
|
// so the resolver returns the integration path over the base clone.
|
|
const start = '/ws/dsh-desktop-demo/src/main'
|
|
const base = '/ws/deepseek-harness-dev'
|
|
const integration = path.join(base, '.worktrees', 'integration')
|
|
const daemonDir = path.join(integration, 'packages', 'examples', 'daemon-demo')
|
|
const fs = mockFsWith([daemonDir])
|
|
const got = resolveHarnessDev(start, {}, fs)
|
|
assert.equal(got, integration, 'integration worktree preferred over base clone when daemon-demo is there')
|
|
})
|
|
|
|
test('official-repo shape end-to-end: startDir inside examples/desktop resolves to repo root', () => {
|
|
// The failure the P0-1 fix was written for: user clones
|
|
// deepseek-harness fresh, launches from examples/desktop. Resolver
|
|
// must NOT hand back `deepseek-harness/examples/deepseek-harness-dev`
|
|
// (which doesn't exist). It must return the repo root itself.
|
|
const start = '/Users/downloader/deepseek-harness/examples/desktop/src/main'
|
|
const marker = '/Users/downloader/deepseek-harness/packages/examples/jsonrpc-demo/src/bin.ts'
|
|
const fs = mockFsWith([marker])
|
|
const got = resolveHarnessDev(start, {}, fs)
|
|
assert.equal(got, '/Users/downloader/deepseek-harness')
|
|
})
|