A team of long-lived bots for DeepSeek Harness, with main bots, bot-to-bot messages and group chats.
Run the tests and the linter in CI against DSH from npm
Fei2411b9fe79aa9ec5
diff --git a/.github/workflows/test.yml b/.github/workflows/test.ymlnew file mode 100644index 00000000..a451f591--- /dev/null+++ b/.github/workflows/test.yml@@ -0,0 +1,41 @@+name: Test++on:+ push:+ branches: [main]+ pull_request:++permissions:+ contents: read++concurrency:+ group: test-${{ github.ref }}+ cancel-in-progress: true++jobs:+ test:+ name: ${{ matrix.os }} · Node ${{ matrix.node }} · DSH ${{ matrix.dsh }}+ runs-on: ${{ matrix.os }}+ strategy:+ fail-fast: false+ matrix:+ include:+ - { os: ubuntu-latest, node: 24, dsh: 0.2.0-rc.2 }+ - { os: windows-latest, node: 24, dsh: 0.2.0-rc.2 }+ - { os: ubuntu-latest, node: 22, dsh: 0.2.0-rc.2 }+ - { os: ubuntu-latest, node: 24, dsh: 0.2.1-alpha.1 }+ defaults:+ run:+ shell: bash+ working-directory: ds-bot+ steps:+ - uses: actions/checkout@v4+ - uses: actions/setup-node@v4+ with:+ node-version: ${{ matrix.node }}+ - run: npm ci --no-fund --no-audit+ - name: Install DSH ${{ matrix.dsh }}+ run: npm run harness -- --no-save "@deepseek-ai/dsh@${{ matrix.dsh }}"+ - run: npm test+ - run: node scripts/build-client.mjs --check+ - run: npm run lintdiff --git a/AGENTS.md b/AGENTS.mdindex dd14d01a..9647175a 100644--- a/AGENTS.md+++ b/AGENTS.md@@ -22,25 +22,27 @@ DS Bot (`ds-bot/`) is a plugin for DeepSeek Harness (DSH). It turns DSH Desktop## Commands-Run in `ds-bot/`. The tests need a DeepSeek Harness checkout at `../deepseek-harness` (or `DSH_HARNESS`), at the DSH version in the README.+Run in `ds-bot/`. The unit tests and the linter load the `@deepseek-ai/*` packages from `dev/harness/`, which `npm run harness` installs from npm at the DSH version in `dev/harness/package.json`. `DSH_HARNESS` points them at another install or at a DeepSeek Harness checkout instead. The test bench needs a checkout at `../deepseek-harness` (or `DSH_HARNESS`), at the DSH version in the README.```shnpm ci # build tool only (esbuild)+npm run harness # once: the DSH packages for the tests and the linternpm run build # src/client → client.jsnpm test # unit tests; also fail if client.js is stalenode scripts/build-client.mjs --check # client.js matches src/client+npm run lint # oxlintCONTEXT_WINDOW=100000 CHECK_RATIO=0.45 dev/bench.sh smoke 3096 8796 reset && node dev/smoke.mjs smoke 3096 # smoke testdev/bench.sh smoke 3096 8796 stop```-A change is done when `npm test` and the `--check` pass. Run the smoke test as well for changes to `index.js` or `src/host/`. Use a free port for each bench, and stop every bench and process that you started.+A change is done when `npm test`, the `--check` and `npm run lint` pass; CI runs them on every pull request. Run the smoke test as well for changes to `index.js` or `src/host/`. Use a free port for each bench, and stop every bench and process that you started.## Layout- `ds-bot/index.js` and `ds-bot/src/host/`: the server side (roster and store, tools, turns and delivery, groups, conversation parts and the search index, images, the browser bridge, the `api/bot` channel).- `ds-bot/src/client/`: the browser side (sidebar, chat, panels, themes, characters, the Bot browser panel).- `ds-bot/web-search.js`: the `auto` web-search provider, independent of the Bot team code.-- `ds-bot/test/`: unit tests and fixtures. `ds-bot/dev/`: mock model, test bench, smoke test, character generator, Desktop scripts for Linux.+- `ds-bot/test/`: unit tests and fixtures. `ds-bot/dev/`: the DSH packages for the tests (`harness/`), mock model, test bench, smoke test, character generator, Desktop scripts for Linux.## Stylediff --git a/CONTRIBUTING.md b/CONTRIBUTING.mdindex ecca1a24..ce10da49 100644--- a/CONTRIBUTING.md+++ b/CONTRIBUTING.md@@ -18,25 +18,31 @@ Thank you for your interest in improving DS Bot. The project is still changing qYou need:-- Node.js `22.19` or later (or `24` and later), and pnpm `11`.+- Node.js `22.19` or later (or `24` and later).- Git.-- A checkout of DeepSeek Harness at the DSH version that the plugin is tested with. The unit tests and the test bench load the `@deepseek-ai/*` packages from it.+- For the test bench only: pnpm `11` and a checkout of DeepSeek Harness at the DSH version that the plugin is tested with.```shgit clone https://github.com/Fei2411/DeepSeek-Bot.git ds-bot-repo-cd ds-bot-repo+cd ds-bot-repo/ds-bot-# DeepSeek Harness, next to the plugin folder (this folder is ignored by Git).+# The plugin's own build tool (esbuild only).+npm ci++# The DSH packages that the unit tests and the linter load, from npm, into dev/harness/.+npm run harness+```++For the test bench, add the DeepSeek Harness checkout next to the plugin folder (this folder is ignored by Git):++```sh+cd ..git clone https://github.com/deepseek-ai/deepseek-harness.gitgit -C deepseek-harness checkout dsh-v0.2.1-alpha.1(cd deepseek-harness && pnpm install)--# The plugin's own build tool (esbuild only).-cd ds-bot-npm ci```-If your DeepSeek Harness checkout is somewhere else, set `DSH_HARNESS` to its path for the tests and the test bench.+If your DeepSeek Harness checkout is somewhere else, set `DSH_HARNESS` to its path. `DSH_HARNESS` also takes the place of `dev/harness/` for the unit tests and the linter.The `@deepseek-ai/*` packages are peer dependencies: in a real install, the DSH profile supplies them. `ds-bot/.npmrc` keeps npm from installing them into the plugin folder.@@ -50,7 +56,7 @@ The `@deepseek-ai/*` packages are peer dependencies: in a real install, the DSH| `ds-bot/web-search.js` | The `auto` web-search provider. It does not depend on the Bot team code || `ds-bot/cordis.patch.yml` | The profile patch that the plugin brings || `ds-bot/test/` | Unit tests and fixtures |-| `ds-bot/dev/` | The mock model, the test bench, the smoke test, the character generator, the Desktop scripts for Linux, and two tools for real models: the steward evaluation and a logging pass-through |+| `ds-bot/dev/` | The DSH packages for the unit tests (`harness/`), the mock model, the test bench, the smoke test, the character generator, the Desktop scripts for Linux, and two tools for real models: the steward evaluation and a logging pass-through |## Test a change@@ -60,8 +66,11 @@ Run these in `ds-bot/`:npm run build # src/client → client.jsnpm test # unit tests; they also fail if client.js is stalenode scripts/build-client.mjs --check # client.js matches src/client+npm run lint # oxlint```+CI runs the same three checks on every pull request, on Linux and Windows.+For a change to the server side (`index.js`, `src/host/`), also run the smoke test. It starts the mock model and a DSH Web with the plugin linked from your checkout, and walks through the main flows (Bots, group chats, conversation parts, condensing, settings). `CONTEXT_WINDOW` and `CHECK_RATIO` give the mock models a small window, so a few long replies reach the check line:```shdiff --git a/ds-bot/dev/harness/package.json b/ds-bot/dev/harness/package.jsonnew file mode 100644index 00000000..ed7ae6b3--- /dev/null+++ b/ds-bot/dev/harness/package.json@@ -0,0 +1,10 @@+{+ "name": "ds-bot-test-harness",+ "private": true,+ "description": "The DeepSeek Harness packages that the unit tests and the linter run against. Install with npm run harness in ds-bot/.",+ "dependencies": {+ "@deepseek-ai/dsh": "0.2.0-rc.2",+ "jsdom": "29.1.1",+ "oxlint": "1.76.0"+ }+}diff --git a/ds-bot/package.json b/ds-bot/package.jsonindex a8a3d9bc..45035a56 100644--- a/ds-bot/package.json+++ b/ds-bot/package.json@@ -42,6 +42,7 @@"build": "node scripts/build-client.mjs","test": "node --import ./test/harness-resolve.mjs --test \"test/*.test.js\"","lint": "node scripts/lint.mjs",+ "harness": "npm install --prefix dev/harness --legacy-peer-deps=false --no-package-lock --no-fund --no-audit","check": "sh dev/check.sh"},"peerDependencies": {diff --git a/ds-bot/scripts/lint.mjs b/ds-bot/scripts/lint.mjsindex 501f72fa..ff9376e6 100644--- a/ds-bot/scripts/lint.mjs+++ b/ds-bot/scripts/lint.mjs@@ -1,21 +1,25 @@-// Lint with the oxlint that the deepseek-harness checkout installs, so ds-bot needs no-// copy of its own. The checkout is DSH_HARNESS, else beside this checkout, else beside-// the main worktree (a git worktree has no deepseek-harness of its own).+// Lint with the oxlint that `npm run harness` installs in dev/harness, or that a+// deepseek-harness checkout installs, so ds-bot needs no copy of its own. The places are+// DSH_HARNESS, else dev/harness, else a checkout beside this checkout, else beside the main+// worktree (a git worktree has no deepseek-harness of its own).// Usage: npm run lint [-- <oxlint options>]import { execFileSync, spawnSync } from 'node:child_process'import { existsSync } from 'node:fs'import { dirname, join, resolve } from 'node:path'const plugin = resolve(import.meta.dirname, '..')-const candidates = [process.env.DSH_HARNESS, join(plugin, '..', 'deepseek-harness')]+const candidates = [process.env.DSH_HARNESS, join(plugin, 'dev', 'harness'), join(plugin, '..', 'deepseek-harness')]try {const common = execFileSync('git', ['-C', plugin, 'rev-parse', '--path-format=absolute', '--git-common-dir'], { encoding: 'utf8' }).trim()candidates.push(join(dirname(common), 'deepseek-harness'))} catch {}-const bin = candidates.filter(Boolean).map(dir => join(dir, 'node_modules', '.bin', process.platform === 'win32' ? 'oxlint.cmd' : 'oxlint')).find(existsSync)+// Node runs oxlint's own script: on Windows it cannot spawn the .cmd shim in node_modules/.bin+// without a shell.+const bin = candidates.filter(Boolean).map(dir => join(dir, 'node_modules', 'oxlint', 'bin', 'oxlint')).find(existsSync)if (!bin) {- console.error('lint: no oxlint found; install the deepseek-harness checkout or set DSH_HARNESS')+ console.error('lint: no oxlint found; run npm run harness, or set DSH_HARNESS to a deepseek-harness checkout')process.exit(2)}-const result = spawnSync(bin, ['-c', '.oxlintrc.json', ...process.argv.slice(2), 'index.js', 'web-search.js', 'src', 'dev', 'scripts', 'test'], { cwd: plugin, stdio: 'inherit' })+const result = spawnSync(process.execPath, [bin, '-c', '.oxlintrc.json', ...process.argv.slice(2), 'index.js', 'web-search.js', 'src', 'dev', 'scripts', 'test'], { cwd: plugin, stdio: 'inherit' })+if (result.error) console.error(`lint: ${result.error.message}`)process.exit(result.status ?? 1)diff --git a/ds-bot/test/harness-resolve.mjs b/ds-bot/test/harness-resolve.mjsindex c303f327..1baaad0d 100644--- a/ds-bot/test/harness-resolve.mjs+++ b/ds-bot/test/harness-resolve.mjs@@ -1,7 +1,8 @@-// Tests import web-search.js outside a dsh profile, so its @deepseek-ai peers resolve from the-// deepseek-harness checkout, as a profile would supply them: DSH_HARNESS, else the nearest-// deepseek-harness/ in a folder above ds-bot, else the same search from ds-bot's place in the-// main worktree (a git worktree has no checkout of its own).+// Tests import web-search.js outside a dsh profile, so its @deepseek-ai peers resolve from a+// DeepSeek Harness, as a profile would supply them: DSH_HARNESS, else the packages that+// `npm run harness` installs in dev/harness, else the nearest deepseek-harness/ checkout in a+// folder above ds-bot, else the same search from ds-bot's place in the main worktree (a git+// worktree has no checkout of its own).import { execFileSync } from 'node:child_process'import { existsSync } from 'node:fs'import { registerHooks } from 'node:module'@@ -15,8 +16,10 @@ const above = (start) => {if (dirname(dir) === dir) return undefined}}+const installed = join(plugin, 'dev', 'harness')const findHarness = () => {if (process.env.DSH_HARNESS) return process.env.DSH_HARNESS+ if (existsSync(join(installed, 'node_modules'))) return installedconst near = above(dirname(plugin))if (near) return nearconst beside = resolve(plugin, '../deepseek-harness')@@ -30,7 +33,9 @@ const findHarness = () => {const harness = findHarness()// Tests that load other harness packages (jsdom) read the same checkout.process.env.DSH_HARNESS = harness-const anchor = pathToFileURL(resolve(harness, 'packages/bundle/base/package.json')).href+// A checkout links the packages into its base bundle; an npm install has them at its root.+const base = resolve(harness, 'packages/bundle/base/package.json')+const anchor = pathToFileURL(existsSync(base) ? base : resolve(harness, 'package.json')).hrefconst pluginUrl = `${pathToFileURL(plugin).href}/`registerHooks({