The coordinator's last two replies ended with [suggestion:11] and [suggestion:12], refs the model wrote itself after seeing a real [suggestion:10] in an earlier message. Neither run called suggest_next_steps, so no rows existed and the user read "next steps 11 (not available)". The reply review checked file, task and setting refs but not the cards the app adds itself. The review now faults any [suggestion:ID], [question:ID] or [plan:ID] found in the model's raw answer: the app appends those refs after the review, from the tool that made the card, so one already in the text is made up or copied. The fault note tells the bot to take the ref out and call suggest_next_steps, ask_user or create_plan if the card should be there (AppCardRefTools, pinned to the declared tools by tool-name-lists.test.ts). A [graphic:ID] is a ref the model is told to write, so only one that doesn't exist for the user is faulted, through grabBotGraphic. Tests: a new review-bot-reply.test.ts covers each fault and the passing cases; reply-ref-ids and reply-claim-problems tests grew with the new kinds. The run-text-loop review test now mocks logError, so its "db down" case stops writing error rows into the dev database.
25 lines
1.1 KiB
TypeScript
25 lines
1.1 KiB
TypeScript
import { describe, expect, test } from "bun:test";
|
|
import replyRefIds from "./reply-ref-ids";
|
|
|
|
describe("replyRefIds", () => {
|
|
test("reads each ref of the kind once, links and code spans included", () => {
|
|
const text = "Notes in [file:294](99designs/notes.md), scan in `[file:301]`, again [file:294]; [task:20] and [ task:21 ].";
|
|
|
|
expect(replyRefIds({ text, kind: "file" })).toEqual([294, 301]);
|
|
expect(replyRefIds({ text, kind: "task" })).toEqual([20]);
|
|
});
|
|
|
|
test("finds nothing in plain text", () => {
|
|
expect(replyRefIds({ text: "file 301 and task #20", kind: "file" })).toEqual([]);
|
|
});
|
|
|
|
test("reads the card refs the app adds and the graphic refs the model writes", () => {
|
|
const text = "Next steps: [suggestion:11]. Questions in [question:4], the plan in [plan:7], the chart in [graphic:2] and [graphic:2] again.";
|
|
|
|
expect(replyRefIds({ text, kind: "suggestion" })).toEqual([11]);
|
|
expect(replyRefIds({ text, kind: "question" })).toEqual([4]);
|
|
expect(replyRefIds({ text, kind: "plan" })).toEqual([7]);
|
|
expect(replyRefIds({ text, kind: "graphic" })).toEqual([2]);
|
|
});
|
|
});
|