A team of long-lived bots for DeepSeek Harness, with main bots, bot-to-bot messages and group chats.
Keep a typed call when it matches a referenced chat's label
FeiZhuLulu079d4622025e
diff --git a/ds-bot/src/host/groups.js b/ds-bot/src/host/groups.jsindex c8a4052a..dddc6167 100644--- a/ds-bot/src/host/groups.js+++ b/ds-bot/src/host/groups.js@@ -75,12 +75,21 @@ export const mentionsIn = (text, members) => {return { all, found }}-// DSH writes a referenced conversation into the message as "@label"; that is not a-// call, even when the label starts with a member's name.+// DSH writes each referenced conversation into the message as one "@label"; that is not+// a call, even when the label starts with a member's name. Only that one "@label" goes,+// so a "@Name" the user typed with the same text still calls.+const dropMention = (text, label) => {+ const mention = `@${label}`+ for (let at = text.indexOf(mention); at !== -1; at = text.indexOf(mention, at + 1)) {+ const end = at + mention.length+ if ((at === 0 || !/[a-z0-9_.]/i.test(text[at - 1])) && !NAME_GOES_ON.test(text.slice(end))) return text.slice(0, at) + text.slice(end)+ }+ return text+}export const withoutReferences = (text, references = []) => references.flatMap(reference => reference.labels).sort((a, b) => b.length - a.length)- .reduce((rest, label) => rest.split(`@${label}`).join(''), text)+ .reduce(dropMention, text)// What the user referenced in this round, for a member that has not been shown it yet.export const referenceNote = references => (references?.lengthdiff --git a/ds-bot/test/groups.test.js b/ds-bot/test/groups.test.jsindex 31001831..e56f68c0 100644--- a/ds-bot/test/groups.test.js+++ b/ds-bot/test/groups.test.js@@ -47,3 +47,13 @@ test('a reference label is not a call, even when it starts with a member\'s nameassert.equal(referenceNote([]), '')assert.equal(referenceNote([{ text: 'A' }, { text: 'B' }]), 'Conversations the user referenced in this round:\n\nA\n\nB')})++test('a reference takes out only its own "@label", so a typed call with the same text stays', () => {+ const writer = [{ labels: ['Writer'] }]+ assert.deepEqual(names(mentionsIn(withoutReferences('Read @Writer, then @Writer please answer.', writer), members)), { all: false, found: ['Writer'] })+ assert.deepEqual(names(mentionsIn(withoutReferences('see @Writer', writer), members)), { all: false, found: [] })+ assert.deepEqual(names(mentionsIn(withoutReferences('see @Writer and @Writer', [...writer, ...writer]), members)), { all: false, found: [] })+ // "@Kate" is not the reference "K", so the "@K" after it is the one taken out.+ assert.deepEqual(names(mentionsIn(withoutReferences('@Kate, @K', [{ labels: ['K'] }]), [...members, { name: 'Kate' }])), { all: false, found: ['Kate'] })+ assert.deepEqual(names(mentionsIn(withoutReferences('@K notes and @K', [{ labels: ['K notes'] }]), members)), { all: false, found: ['K'] })+})