it("strips a sentence-ending token and keeps trailing punctuation", () => {
expect(
stripHeartbeatToken(`I should not respond ${HEARTBEAT_TOKEN}.`, {
mode: "message",
}),
).toEqual({
shouldSkip: false,
text: `I should not respond.`,
didStrip: true,
});
});
it("strips sentence-ending token with emphasis punctuation in heartbeat mode", () => {
expect(
stripHeartbeatToken(
`There is nothing todo, so i should respond with ${HEARTBEAT_TOKEN} !!!`,
{
mode: "heartbeat",
},
),
).toEqual({
shouldSkip: true,
text: "",
didStrip: true,
});
});
it("preserves trailing punctuation on text before the token", () => {
expect(stripHeartbeatToken(`All clear. ${HEARTBEAT_TOKEN}`, { mode: "message" })).toEqual({
shouldSkip: false,
text: "All clear.",
didStrip: true,
});
});
});
describe("isHeartbeatContentEffectivelyEmpty", () => {
it("returns false for undefined/null (missing file should not skip)", () => {
expect(isHeartbeatContentEffectivelyEmpty(undefined)).toBe(false);
expect(isHeartbeatContentEffectivelyEmpty(null)).toBe(false);
});
it("returns true for empty string", () => {
expect(isHeartbeatContentEffectivelyEmpty("")).toBe(true);
});
it("returns true for comments only", () => {
expect(isHeartbeatContentEffectivelyEmpty("# Header\n# Another comment")).toBe(true);
expect(isHeartbeatContentEffectivelyEmpty("## Subheader\n### Another")).toBe(true);
});
it("returns false when a template includes plain instructional prose", () => { const defaultTemplate = `# HEARTBEAT.md
Keep this file empty unless you want a tiny checklist. Keep it small.
`;
expect(isHeartbeatContentEffectivelyEmpty(defaultTemplate)).toBe(false);
});
it("returns true for the current fenced heartbeat template body (#61690)", () => { const content = `# HEARTBEAT.md Template
\`\`\`markdown
# Keep this file empty (or with only comments) to skip heartbeat API calls.
# Add tasks below when you want the agent to check something periodically.
\`\`\`
`;
expect(isHeartbeatContentEffectivelyEmpty(content)).toBe(true);
});
it("returns false when fenced heartbeat content includes a real task", () => { const content = `\`\`\`markdown
# Keep this file empty when you want to skip.
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.