Skip to content

Garry's Opinionated OpenClaw/Hermes Agent Brain

TypeScript
1.8 KB
Raw Blame
/**
 * #7932 — daily-task-manager names the task page by its slug, `ops/tasks`, in
 * every page-tool call. The page tools do an exact slug lookup, so
 * `get_page("ops/tasks.md")` missed the existing `ops/tasks` page, and the
 * skill's first-run rule could then start a second list at slug
 * `ops/tasks.md` that sync, `resolveTodayTasks()` and `gbrain get ops/tasks`
 * never read. Checked in the source skill and both generated copies.
 * Brains where the old skill already saved tasks at `ops/tasks.md` keep them:
 * the first-run rule carries that page's tasks over instead of starting an
 * empty list, and leaves the old page in place.
 */
import { describe, expect, test } from 'bun:test';
import { readFileSync } from 'fs';
import { join } from 'path';

const ROOT = join(import.meta.dir, '..');
const COPIES = [
  'skills/daily-task-manager/SKILL.md',
  'plugin/skills/daily-task-manager/SKILL.md',
  'plugin-variants/gbrain-daily/skills/daily-task-manager/SKILL.md',
];

describe('#7932: daily-task-manager page-tool calls use the slug ops/tasks', () => {
  for (const rel of COPIES) {
    test(rel, () => {
      const text = readFileSync(join(ROOT, rel), 'utf8');
      expect(text).not.toMatch(/(?:get_page|put_page)\(\s*"[^"]*\.md"/);
      expect(text).toContain('get_page("ops/tasks")');
      expect(text).toContain('put_page("ops/tasks"');
      expect(text).toContain('page: "ops/tasks"');
      expect(text).not.toMatch(/always `ops\/tasks\.md` \(with extension\) in tool calls/);
      for (const rule of text.split('\n').filter(l => l.includes('**First run:**'))) {
        expect(rule).toContain('`ops/tasks.md`');
        expect(rule).toContain('leave the old page in place');
      }
      expect(text.split('\n').filter(l => l.includes('**First run:**')).length).toBe(2);
    });
  }
});