Skip to content

A team of long-lived bots for DeepSeek Harness, with main bots, bot-to-bot messages and group chats.

Stop a test run from hanging and merge dev without hand-fixing client.js

Fei2411a41c63820c3f
diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml
index a56edbad..df1d1622 100644
--- a/.github/workflows/test.yml
+++ b/.github/workflows/test.yml
@@ -16,6 +16,9 @@ jobs:
test:
name: ${{ matrix.os }} · Node ${{ matrix.node }} · DSH ${{ matrix.dsh }}
runs-on: ${{ matrix.os }}
+ # The suite takes a few minutes; a test that never settles used to hold the job for the
+ # runner's six-hour limit.
+ timeout-minutes: 25
strategy:
fail-fast: false
matrix:
diff --git a/AGENTS.md b/AGENTS.md
index 0dc7bc28..1a0c927d 100644
--- a/AGENTS.md
+++ b/AGENTS.md
@@ -47,7 +47,7 @@ A change is done when `npm test`, the `--check` and `npm run lint` pass; CI runs
The full workflow is in [CONTRIBUTING.md](CONTRIBUTING.md#how-we-work). The parts that an agent must follow:
- Start work from the latest `dev` on a branch named `fix/<issue>-<name>`, `feat/<issue>-<name>`, `docs/<name>` or `chore/<name>`. Never start a branch name with `dev/`. Open the pull request into `dev`, not `main`; only releases and hotfixes go into `main`.
-- Bring a branch up to date with `git merge dev`. Never rebase a pushed branch and never force-push.
+- Bring a branch up to date with `scripts/merge-dev.sh`: it merges `origin/dev`, takes a conflicting `ds-bot/client.js` from dev and rebuilds it. Never rebase a pushed branch and never force-push.
- Fill in the pull request template. Link the issue with `Fixes #<number>`; a bug fix names the bug it fixes. Write the user-visible change in the Changelog field, and do not edit `CHANGELOG.md`.
- Do not start work on an issue or pull request with the `maintainer` label; it waits for the maintainer. Do not take an issue that someone else is assigned to.
- Before you change behavior, read the design for it in `docs/plans/` (and `docs/vision.md`); for interface work also `docs/design/ui-standard.md`. A change to a decided design needs the maintainer; a new large feature adds its design note to the same pull request.
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index d432c721..4e8a7b1a 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -29,7 +29,7 @@ Anyone on the team can do any kind of work: triage, bug fixes, features, the int
| `fix/<issue>-<name>`, `feat/<issue>-<name>`, `docs/<name>`, `chore/<name>` | Your work. Start it from the latest `dev` | — |
- Do not start a branch name with `dev/`. Git cannot create `dev/<name>` while the branch `dev` exists.
-- To bring your branch up to date, run `git merge dev` (on a hotfix branch, `git merge main`). Do not rebase a pushed branch and do not force-push.
+- To bring your branch up to date, run `scripts/merge-dev.sh`: it merges `origin/dev`, and a conflict in the generated `ds-bot/client.js` is taken from dev and rebuilt (on a hotfix branch, `git merge main`). Do not rebase a pushed branch and do not force-push.
- `main` is the default branch, so GitHub suggests `main` as the base of a new pull request. Change the base to `dev`.
### Issues
diff --git a/CONTRIBUTING.zh.md b/CONTRIBUTING.zh.md
index 9047171a..43a0389d 100644
--- a/CONTRIBUTING.zh.md
+++ b/CONTRIBUTING.zh.md
@@ -29,7 +29,7 @@
| `fix/<Issue 号>-<短名>`、`feat/<Issue 号>-<短名>`、`docs/<短名>`、`chore/<短名>` | 你的工作分支。从最新的 `dev` 切出 | — |
- 分支名不要以 `dev/` 开头。有 `dev` 分支时,Git 建不了 `dev/<名字>`。
-- 同步分支用 `git merge dev`(热修分支用 `git merge main`)。已推送的分支不要 rebase,也不要强推。
+- 同步分支用 `scripts/merge-dev.sh`:合入 `origin/dev`,生成文件 `ds-bot/client.js` 冲突时取 dev 的版本再重新生成(热修分支用 `git merge main`)。已推送的分支不要 rebase,也不要强推。
- 默认分支是 `main`,所以 GitHub 新建 Pull Request 时默认的 base 是 `main`。请改成 `dev`。
### Issue
diff --git a/ds-bot/package.json b/ds-bot/package.json
index f0f93acc..8c22fe66 100644
--- a/ds-bot/package.json
+++ b/ds-bot/package.json
@@ -43,7 +43,7 @@
],
"scripts": {
"build": "node scripts/build-client.mjs",
- "test": "node --import ./test/harness-resolve.mjs --test \"test/*.test.js\"",
+ "test": "node --import ./test/harness-resolve.mjs --test --test-timeout=120000 --test-force-exit \"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"
diff --git a/ds-bot/src/host/feed.js b/ds-bot/src/host/feed.js
index 6ff1e6c5..396baac4 100644
--- a/ds-bot/src/host/feed.js
+++ b/ds-bot/src/host/feed.js
@@ -76,8 +76,13 @@ export function install(rt) {
}
})
+ // A Request built on a caller's signal only follows it while the Request is reachable;
+ // once collected, its abort never fires and the feed stays open. Each open feed keeps
+ // its Request until it leaves.
+ const requests = new Map()
const leave = (controller) => {
clients.delete(controller)
+ requests.delete(controller)
if (clients.size === 0) writing.clear()
try { controller.close() } catch { /* already closed or errored */ }
}
@@ -96,6 +101,7 @@ export function install(rt) {
},
cancel() { leave(controller) },
})
+ requests.set(controller, request)
request.signal.addEventListener('abort', () => leave(controller), { once: true })
return new Response(body, { status: 200, headers: { 'content-type': 'text/event-stream; charset=utf-8', 'cache-control': 'no-store' } })
},
diff --git a/scripts/merge-dev.sh b/scripts/merge-dev.sh
new file mode 100755
index 00000000..e311c0de
--- /dev/null
+++ b/scripts/merge-dev.sh
@@ -0,0 +1,48 @@
+#!/bin/sh
+# Bring the current branch up to date with origin/dev.
+#
+# scripts/merge-dev.sh
+#
+# ds-bot/client.js is built from ds-bot/src/client, so a conflict in it is never
+# resolved by hand: it is taken from dev and rebuilt once the sources are merged.
+# Any other conflict stops the script with the merge still open, to be resolved
+# and committed as usual.
+set -eu
+
+root="$(git rev-parse --show-toplevel)"
+cd "$root"
+
+if [ -n "$(git status --porcelain --untracked-files=no)" ]; then
+ echo "merge-dev: commit or stash your changes first" >&2
+ exit 1
+fi
+
+git fetch origin dev
+if git merge --no-edit origin/dev; then
+ merged=1
+else
+ merged=0
+fi
+
+if [ "$merged" -eq 0 ]; then
+ if git diff --name-only --diff-filter=U | grep -qx 'ds-bot/client.js'; then
+ git checkout --theirs -- ds-bot/client.js
+ git add ds-bot/client.js
+ fi
+ left="$(git diff --name-only --diff-filter=U)"
+ if [ -n "$left" ]; then
+ echo "merge-dev: resolve these, then run 'npm run build' in ds-bot and commit:" >&2
+ echo "$left" >&2
+ exit 1
+ fi
+fi
+
+# The merged sources may differ from both sides' bundles even without a conflict.
+(cd ds-bot && npm run build >/dev/null)
+git add ds-bot/client.js
+if [ "$merged" -eq 0 ]; then
+ git commit --no-edit
+elif ! git diff --cached --quiet; then
+ git commit -m "Rebuild client.js after merging dev"
+fi
+echo "merge-dev: up to date with origin/dev"