Files
deepseek-harness/examples/desktop/test/deepseek-config-workspace-context.test.js
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

91 lines
3.9 KiB
JavaScript

// deepseek-*.yml agent-core must carry an explicit workspaceContext
//
// The upstream agent-spine-demo schema (packages/examples/agent-spine-demo/
// src/index.ts) declares `workspaceContext: Config | false` as required —
// no default. If the runtime yml omits it, cordis fails config resolution
// at plugin load with `ValidationError: $.workspaceContext missing required
// value`, the child dies before initialize completes, and the desktop
// shell shows a generic "Runtime warning" banner (the real cause never
// reaches the classifier). This regressed the default-profile-real batch:
// team-lead flagged the probe was staring at the schema-drift banner and
// mistaking it for the missing-key banner.
//
// Lock the required field in both deepseek configs so a future edit that
// drops it fails a fast static test rather than a real-machine repro.
// Also lock the echo configs' absence-by-design: echo doesn't load
// agent-spine-demo (mock-llm path), so it must NOT carry workspaceContext
// or a schema-drift symptom would masquerade as a config bug.
'use strict'
const test = require('node:test')
const assert = require('node:assert/strict')
const fs = require('node:fs')
const path = require('node:path')
const CFG = path.join(__dirname, '..', 'config')
function readConfig(name) {
return fs.readFileSync(path.join(CFG, name), 'utf8')
}
// A very simple line-oriented reader — we only care that:
// - the file has an `- id: agent-core` entry
// - within that entry's config block, `workspaceContext` is present
// A full YAML parse would drag in a dep just for the assertion; the regex
// window is enough because these files follow the flat "- id: … name: …
// config: …" shape.
function agentCoreConfigWindow(src) {
const startIdx = src.indexOf('- id: agent-core')
if (startIdx === -1) return null
// The next `- id:` (or EOF) bounds this entry.
const rest = src.slice(startIdx + 1)
const nextIdx = rest.indexOf('\n- id:')
const end = nextIdx === -1 ? src.length : startIdx + 1 + nextIdx
return src.slice(startIdx, end)
}
test('deepseek-jsonrpc.yml agent-core has an explicit workspaceContext', () => {
const src = readConfig('deepseek-jsonrpc.yml')
const window = agentCoreConfigWindow(src)
assert.ok(window, 'deepseek-jsonrpc.yml must have an agent-core entry')
assert.match(
window,
/workspaceContext\s*:/,
'agent-core must carry an explicit workspaceContext — dropping this makes the runtime fatal on load and hides the api-key error behind a generic banner',
)
})
test('deepseek-vibe.yml agent-core has an explicit workspaceContext', () => {
const src = readConfig('deepseek-vibe.yml')
const window = agentCoreConfigWindow(src)
assert.ok(window, 'deepseek-vibe.yml must have an agent-core entry')
assert.match(
window,
/workspaceContext\s*:/,
'vibe deepseek profile shares the same schema requirement',
)
})
test('top-level agent-spine-demo entries always carry workspaceContext', () => {
// Belt-and-suspenders across every config that DOES compose the spine at
// top level. Anything that does must supply the required field or reload
// will fatal. daemon-echo.yml composes the daemon-demo bundle which
// internally embeds the spine on the mock path — no top-level
// agent-spine-demo entry there, and it's exempt.
const dir = path.join(__dirname, '..', 'config')
for (const name of fs.readdirSync(dir).filter((f) => f.endsWith('.yml'))) {
const src = fs.readFileSync(path.join(dir, name), 'utf8')
const window = agentCoreConfigWindow(src)
if (!window) continue
// Only assert when the entry actually names the spine plugin — some
// configs might have an `agent-core` id pointing at a different plugin.
if (!/@deepseek-ai\/dsh-agent-spine-demo/.test(window)) continue
assert.match(
window,
/workspaceContext\s*:/,
`${name} composes agent-spine-demo at top level and must supply workspaceContext`,
)
}
})