From 49d4042e5b40dbb3892c973378fea6ffaf83654b Mon Sep 17 00:00:00 2001 From: yetone Date: Sat, 7 Nov 2026 22:25:07 +0800 Subject: [PATCH] workbuddy 0.2.25: Hide DeepSeek Harness's name leaves the user's words and paths alone (liby233) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit liby233 on Discord: in DeepSeek Harness on DeepSeek-V4.1-Flash · WorkBuddy, a user asked the model to repeat "/root/DSH/Work/OC-182.92.66.95/" word for word and got "/root/the agent harness/Work/OC-182.92.66.95/" back; another model was fine. hide_dsh (0.2.23, on by default) ran /\bDSH\b(?!_)/ and the bare "DeepSeek Harness" rule over every user and assistant text, so a path's DSH segment went to WorkBuddy rewritten. The switch's own description already promised "Paths ... stay as they are". - The bare name is taken out only where dsh wrote it: system/developer messages, Messages' system, tools' descriptions (DSH_PROSE). - User and assistant text get dsh's own lines alone (DSH_LINES: the opener, the checkout and Web GUI lines, "DSH itself"), so the runtime context dsh sends as a user message still loses the name. - Even in the system prompt, a name in a path, file name or identifier (/root/DSH/, C:\DSH\, ~/DSH, DSH.md, DSH-2, @DSH, file:DSH, "/srv/DeepSeek Harness/bin") is left: IN_PATH_BEFORE/AFTER guards. - Siblings: FLAGGED and OPENERS rewrite whole known lines (a comma), not a bare word; no other plugin has a DSH scrub (git grep). - README updated. Run on mote at this tree (mote-run): HOME=$(mktemp -d) bun test packages/workbuddy: 334 pass, 0 fail; bun scripts/check.mjs: all ok. New tests use the reporter's literal path. Broken by hand, each red: user/assistant text through DSH_PROSE again (5 fail, the reporter's case among them); IN_PATH_BEFORE as \b (the path test fails). Not tried: a real dsh request on a real WorkBuddy account. Whether the narrower hide still matters for a ban is unknown, as before. Reported-by: liby233 --- packages/workbuddy/README.md | 13 +++++---- packages/workbuddy/hidedsh.test.mjs | 45 +++++++++++++++++++++++++++-- packages/workbuddy/index.mjs | 41 +++++++++++++++++++------- packages/workbuddy/package.json | 2 +- 4 files changed, 83 insertions(+), 18 deletions(-) diff --git a/packages/workbuddy/README.md b/packages/workbuddy/README.md index 75ad950..81b0522 100644 --- a/packages/workbuddy/README.md +++ b/packages/workbuddy/README.md @@ -345,11 +345,14 @@ Since 0.2.23 each site also has a "Hide DeepSeek Harness's name" switch, on by default, and on in OpenCode, which has no switches. A user reported a WorkBuddy account banned after use from DeepSeek Harness, with a reply saying its built-in prompt is recognised. With the switch on, the harness's name is -taken out of the system prompt, the user's and assistant's text and the -tools' descriptions: "You are an AI agent powered by DeepSeek Harness." -becomes "You are an AI agent.", and the runtime lines naming its checkout and -Web GUI say "agent implementation checkout" and "Web GUI". Tools' results, -paths, commands and names such as `DSH_HOME` or `~/.dsh` go as they were. +taken out of the system prompt and the tools' descriptions: "You are an AI +agent powered by DeepSeek Harness." becomes "You are an AI agent.", and the +runtime lines naming its checkout and Web GUI say "agent implementation +checkout" and "Web GUI", wherever they are. Since 0.2.25 the user's and the +assistant's own words go as written (a path such as `/root/DSH/Work/` was +sent as `/root/the agent harness/Work/` before), and so does the name in a +path or a file name anywhere. Tools' results, commands and names such as +`DSH_HOME` or `~/.dsh` go as they were. Whether this keeps an account from being banned is not known. ## Credits in magpie diff --git a/packages/workbuddy/hidedsh.test.mjs b/packages/workbuddy/hidedsh.test.mjs index beb3a14..85fe05d 100644 --- a/packages/workbuddy/hidedsh.test.mjs +++ b/packages/workbuddy/hidedsh.test.mjs @@ -112,13 +112,14 @@ for (const [plugin, site, url] of [ const opts = await h.auth.loader(async () => ({ type: "api", key: KEY }), {}) await opts.fetch(url, { method: "POST", body: JSON.stringify(chatBody()) }) const out = JSON.parse(sent.at(-1).body) - const said = JSON.stringify({ messages: out.messages.filter((m) => m.role !== "tool"), tools: out.tools }) + const said = JSON.stringify({ messages: out.messages.filter((m) => m.role !== "tool" && m.role !== "assistant"), tools: out.tools }) expect(named(said)).toBe(false) + // the assistant's own words go as it said them + expect(out.messages.find((m) => m.role === "assistant").content).toBe("I run in DeepSeek Harness; DSH_HOME is ~/.dsh.") expect(out.messages[0].content).toStartWith("You are an AI agent.") // a tool's result is what a file said, and goes as it came expect(out.messages.find((m) => m.role === "tool").content).toBe("README: DeepSeek Harness (DSH) is …") expect(said).toContain("~/.dsh/profiles") - expect(said).toContain("DSH_HOME") }) } @@ -132,3 +133,43 @@ for (const [plugin, site, url] of [ expect(out.messages[0].content).toContain("extend DSH itself") }) } + +// liby233 on Discord: in dsh on WorkBuddy, a path the user asked to have +// repeated word for word came back as "/root/the agent harness/Work/…". +const ASKED = "Bash 绝对路径: /root/DSH/Work/OC-182.92.66.95/ 请原样复述这个路径" + +test("hideDsh: the user's and the assistant's own words go as written; dsh's lines in them don't", () => { + const chat = { + messages: [ + { role: "system", content: OPENER + "\nWorking directory: /root/DSH/Work/OC-182.92.66.95/" }, + { role: "user", content: [{ type: "text", text: CONTEXT }, { type: "text", text: ASKED }] }, + { role: "assistant", content: "/root/DSH/Work/OC-182.92.66.95/ — DSH says hi" }, + { role: "user", content: "I like DSH and DeepSeek Harness" }, + ], + } + expect(_internal.hideDsh(chat)).toBe(true) + expect(chat.messages[0].content).toBe("You are an AI agent.\nWorking directory: /root/DSH/Work/OC-182.92.66.95/") + expect(named(chat.messages[1].content[0].text)).toBe(false) + expect(chat.messages[1].content[1].text).toBe(ASKED) + expect(chat.messages[2].content).toBe("/root/DSH/Work/OC-182.92.66.95/ — DSH says hi") + expect(chat.messages[3].content).toBe("I like DSH and DeepSeek Harness") + // Messages' user turns too + const m = { system: [{ type: "text", text: OPENER }], messages: [{ role: "user", content: [{ type: "text", text: ASKED }] }] } + _internal.hideDsh(m) + expect(m.messages[0].content[0].text).toBe(ASKED) +}) + +test("dshHidden: in dsh's own text, a name in a path, a file or an identifier stays", () => { + const h = _internal.dshHidden + for (const s of [ + "/root/DSH/Work/OC-182.92.66.95/", + "C:\\Users\\me\\DSH\\x", + "see DSH.md", + "~/DSH", + "/srv/DeepSeek Harness/bin", + "DSH-2 DSH_HOME @DSH", + "file:DSH", + ]) + expect(h(s)).toBe(s) + expect(h("Use DSH. It runs (DSH), and DSH, too")).toBe("Use the agent harness. It runs (the agent harness), and the agent harness, too") +}) diff --git a/packages/workbuddy/index.mjs b/packages/workbuddy/index.mjs index 88e0045..f1d7197 100644 --- a/packages/workbuddy/index.mjs +++ b/packages/workbuddy/index.mjs @@ -3498,18 +3498,38 @@ function replyAfterToolsOn(b) { // URIs (dsh-session:) and skills the agent calls, stays, as does a tool's // result, which is what a file or command said. Case counts, so the name // in an identifier (DSH_HOME) is left too. +// +// The bare name is taken out only where dsh wrote it: the system prompt and +// the tools' descriptions (DSH_PROSE). The user's and the assistant's text +// get dsh's own lines alone (DSH_LINES: its runtime context comes as a user +// message, and the model can quote a line back); a bare DSH or "DeepSeek +// Harness" there is the user's own word. liby233 on Discord: a user asked +// for "/root/DSH/Work/OC-182.92.66.95/" word for word and got +// "/root/the agent harness/Work/…" back. Even in the system prompt a name +// in a path or a file name (/root/DSH/, C:\DSH\, DSH.md) is never prose +// (IN_PATH_BEFORE, IN_PATH_AFTER), so a working directory dsh writes there stays as it is. const HIDE_DSH = "hide_dsh" -const DSH_NAMED = [ +const DSH_LINES = [ [/You are an AI agent,? powered by DeepSeek Harness\.?/g, "You are an AI agent."], [/DeepSeek Harness (Web GUI)/g, "$1"], [/DeepSeek Harness (implementation checkout)/g, "agent $1"], [/\bDSH itself\b/g, "the agent itself"], - [/\b([Tt]he )?DeepSeek Harness\b/g, (_, the) => (the ?? "the ") + "agent harness"], - [/\bDSH\b(?!_)/g, "the agent harness"], +] +// before and after a name, what makes it part of a path, a file's name or +// an identifier rather than a word of prose +const IN_PATH_BEFORE = String.raw`(? (the ?? "the ") + "agent harness"], + [new RegExp(IN_PATH_BEFORE + "DSH" + IN_PATH_AFTER, "g"), "the agent harness"], ] -function dshHidden(text) { - for (const [re, to] of DSH_NAMED) text = text.replace(re, to) +// dshHidden takes the name out of text dsh wrote (the system prompt, a +// tool's description); in the user's or the assistant's text (said) only +// dsh's own lines are reworded. +function dshHidden(text, said = false) { + for (const [re, to] of said ? DSH_LINES : DSH_PROSE) text = text.replace(re, to) return text } @@ -3520,24 +3540,25 @@ function dshHidden(text) { function hideDsh(chat) { if (!chat || typeof chat !== "object") return false let changed = false - const parts = (content) => { + const parts = (content, said) => { if (typeof content === "string") { - const t = dshHidden(content) + const t = dshHidden(content, said) if (t !== content) changed = true return t } if (!Array.isArray(content)) return content return content.map((p) => { if (!p || typeof p.text !== "string" || (p.type !== undefined && p.type !== "text")) return p - const t = dshHidden(p.text) + const t = dshHidden(p.text, said) if (t === p.text) return p changed = true return { ...p, text: t } }) } if (Array.isArray(chat.messages)) - for (const m of chat.messages) if (m && typeof m === "object" && m.role !== "tool") m.content = parts(m.content) - if (chat.system !== undefined) chat.system = parts(chat.system) + for (const m of chat.messages) + if (m && typeof m === "object" && m.role !== "tool") m.content = parts(m.content, m.role !== "system" && m.role !== "developer") + if (chat.system !== undefined) chat.system = parts(chat.system, false) const described = (o) => { if (!o || typeof o !== "object") return if (Array.isArray(o)) return o.forEach(described) diff --git a/packages/workbuddy/package.json b/packages/workbuddy/package.json index 59a680b..da2e423 100644 --- a/packages/workbuddy/package.json +++ b/packages/workbuddy/package.json @@ -1,6 +1,6 @@ { "name": "@magpie-community/opencode-workbuddy-auth", - "version": "0.2.24", + "version": "0.2.25", "description": "OpenCode provider plugins for WorkBuddy's plans: WorkBuddy (CodeBuddy, copilot.tencent.com) and WorkBuddy AI (www.workbuddy.ai)", "type": "module", "main": "./opencode.mjs",