Public Beta
Not set

Experience

Changes how pages explain things, never what you can do.

More

Experience

Changes how pages explain things, never what you can do.

Sign inGet started

Meeting Prep v0.1.2 · claude-code

Archive SHA-256 eafdea234608114ab77a8244acc1b89bfab9ed7e98d14a7480108ea04b7332c3 · 30.1 KB · built Nov 27, 2026

tests/meeting-prep.test.ts

import { describe, it, expect } from "vitest";
// @ts-expect-error -- plain JavaScript agent module without type declarations
import agent, { handleMcpMessage, manifest, validateManifest } from "../src/index.js";

const NOW = () => new Date("2026-11-25T12:00:00Z");

const EVENTS = [
  { uid: "past-1", summary: "Old sync", start: "2026-11-20T15:00:00Z", end: "2026-11-20T15:30:00Z" },
  {
    uid: "weekly-42",
    summary: "Weekly product sync",
    start: "2026-11-26T10:00:00-05:00",
    end: "2026-11-26T11:00:00-05:00",
    timezone: "America/New_York",
    location: "https://meet.example.com/abc",
    attendees: ["Alice <alice@example.com>", { name: "Bob", email: "bob@example.com" }],
  },
  { uid: "later", summary: "Planning", start: "2026-11-27T15:00:00Z", end: "2026-11-27T16:00:00Z" },
];

const NOTES = [
  "# Weekly product sync notes",
  "",
  "Attendees: Alice, Carol",
  "",
  "## Agenda",
  "- Launch checklist review (15 min) @alice",
  "- Pricing page copy",
  "- Hiring update [10m]",
  "",
  "## Prep",
  "- Read the Q4 metrics doc",
  "",
  "## Action items from last week",
  "- [ ] @bob Send the vendor contract to legal (due 2026-11-20)",
  "- [ ] Update the onboarding FAQ",
  "- [x] Book the offsite venue",
  "",
  "```",
  "- [ ] not an action item (inside code)",
  "```",
  "",
].join("\n");

type Item = { topic: string; minutes: number; owner?: string; source: string; start: string; local_start: string; offset_minutes: number };
const sum = (items: Item[]) => items.reduce((a, i) => a + i.minutes, 0);
const build = (input: Record<string, unknown>) => agent.call("build_agenda", input, { now: NOW });

describe("meeting-prep manifest", () => {
  it("passes validateManifest with no permissions", () => {
    expect(validateManifest(manifest)).toEqual([]);
    expect(manifest.id).toBe("agentrove.meeting-prep");
    expect(manifest.permissions).toEqual({ filesystem: "none", network: [], credentials: [] });
  });
});

describe("build_agenda", () => {
  it("selects the next event and time-boxes topics from notes to fill it exactly", async () => {
    const a = await build({ events: EVENTS, notes: NOTES });
    expect(a.event_uid).toBe("weekly-42");
    expect(a.title).toBe("Weekly product sync");
    expect(a.start).toBe("2026-11-26T15:00:00Z");
    expect(a.duration_minutes).toBe(60);
    expect(a.timezone).toBe("America/New_York");
    expect(a.items.map((i: Item) => [i.topic, i.minutes, i.source])).toEqual([
      ["Review open action items (2)", 4, "action_items"],
      ["Launch checklist review", 15, "notes"],
      ["Pricing page copy", 26, "notes"],
      ["Hiring update", 10, "notes"],
      ["Wrap-up: decisions, owners and next steps", 5, "wrap_up"],
    ]);
    expect(sum(a.items)).toBe(60);
    expect(a.items[1].owner).toBe("alice");
    expect(a.items[2]).toMatchObject({ offset_minutes: 19, start: "2026-11-26T15:19:00Z", local_start: "2026-11-26T10:19:00-05:00" });
    expect(a.attendees).toEqual(["Alice <alice@example.com>", "Bob <bob@example.com>", "Carol"]);
    expect(a.carried_over_actions).toEqual([
      { text: "@bob Send the vendor contract to legal (due 2026-11-20)", owner: "bob", due: "2026-11-20", line: 14, section: "Action items from last week" },
      { text: "Update the onboarding FAQ", line: 15, section: "Action items from last week" },
    ]);
    expect(a.completed_actions_in_notes).toBe(1);
    expect(a.prep).toEqual([
      "From your notes: Read the Q4 metrics doc",
      "Check the status of 2 open action item(s) before the meeting",
      "Ask bob for an update: @bob Send the vendor contract to legal (due 2026-11-20) (overdue since 2026-11-20)",
      "Find an owner for: Update the onboarding FAQ",
      "Send the agenda to 3 attendee(s) before 2026-11-26T10:00:00-05:00",
      "Test the meeting link: https://meet.example.com/abc",
      'Confirm alice is ready to lead "Launch checklist review" (15 min)',
    ]);
    expect(a.parking_lot).toEqual([]);
    expect(await build({ events: EVENTS, notes: NOTES })).toEqual(a);
  });

  it("honours explicit topics, scales them when overbooked and parks what does not fit", async () => {
    const ev = [{ uid: "e", summary: "Short", start: "2026-12-01T09:00:00Z", end: "2026-12-01T09:30:00Z" }];
    const a = await build({ events: ev, topics: [{ topic: "A", minutes: 20 }, { topic: "B", minutes: 20, owner: "Dee" }, { topic: "C" }] });
    expect(a.items.map((i: Item) => [i.topic, i.minutes])).toEqual([["A", 13], ["B", 12], ["Wrap-up: decisions, owners and next steps", 5]]);
    expect(a.parking_lot).toEqual(["C"]);
    expect(a.warnings.join(" ")).toMatch(/exceeds the 25 min available/);
    expect(a.prep).toContain("1 topic(s) did not fit: decide whether to drop, defer or extend the meeting");
    expect(a.prep).toContain("The event has no location or meeting link; add one before the meeting");

    const roomy = await build({ events: ev, topics: [{ topic: "Only", minutes: 10 }], wrap_up_minutes: 0 });
    expect(roomy.items.map((i: Item) => [i.topic, i.minutes, i.source])).toEqual([["Only", 10, "input"], ["Open discussion / buffer", 20, "buffer"]]);
  });

  it("always sums to the meeting length with at least one minute per item", async () => {
    for (const minutes of [1, 2, 5, 9, 14, 15, 29, 30, 45, 61, 90, 180]) {
      const end = new Date(Date.parse("2026-12-01T09:00:00Z") + minutes * 60000).toISOString();
      const ev = [{ uid: "e", summary: "S", start: "2026-12-01T09:00:00Z", end }];
      const topics = Array.from({ length: 12 }, (_, i) => ({ topic: `T${i}`, ...(i % 3 === 0 ? { minutes: 7 } : {}) }));
      const notes = "- [ ] one\n- [ ] two\n- [ ] three";
      const a = await build({ events: ev, topics, notes });
      expect(sum(a.items)).toBe(minutes);
      expect(a.items.every((i: Item) => i.minutes >= 1)).toBe(true);
      expect(a.items.length + a.parking_lot.length).toBeGreaterThanOrEqual(Math.min(12, minutes));
    }
  });

  it("strips owner labels from topic names and does not read money or counts as minutes", async () => {
    const notes = [
      "## Agenda",
      "- Pricing experiment results [10m] owner: Dev",
      "- Launch (owner: Ana, 10 min)",
      "- Hit $10m ARR plan",
      "- Grow to 2m users",
      "- Budget review 20 minutes",
    ].join("\n");
    const a = await build({ events: [{ uid: "m", summary: "Plan", start: "2026-12-01T15:00:00Z", end: "2026-12-01T16:00:00Z" }], notes });
    const byTopic = Object.fromEntries(a.items.map((i: Item) => [i.topic, i]));
    expect(byTopic["Pricing experiment results"]).toMatchObject({ minutes: 10, owner: "Dev" });
    expect(byTopic["Launch"]).toMatchObject({ minutes: 10, owner: "Ana" });
    expect(byTopic["Budget review"]).toMatchObject({ minutes: 20 });
    // "$10m" and "2m" are not durations: these topics share the remaining 15 minutes (60 - 40 - 5 wrap-up).
    expect([byTopic["Hit $10m ARR plan"].minutes, byTopic["Grow to 2m users"].minutes]).toEqual([8, 7]);
    expect(sum(a.items)).toBe(60);
  });

  it("removes a trailing `owner: Name` marker from the topic the same way as @mentions", async () => {
    const notes = ["## Topics", "- Review last week's launches @sam", "- Hiring plan owner: Alex", "- Roadmap - owner: Dev"].join("\n");
    const a = await build({ events: [{ uid: "w", summary: "Weekly", start: "2026-12-01T15:00:00Z", end: "2026-12-01T15:45:00Z" }], notes });
    const topics = a.items.map((i: Item) => [i.topic, i.owner]);
    expect(topics).toEqual(expect.arrayContaining([["Review last week's launches", "sam"], ["Hiring plan", "Alex"], ["Roadmap", "Dev"]]));
    expect(a.items.some((i: Item) => /owner:/i.test(i.topic))).toBe(false);
  });

  it("uses a labelled placeholder when no topics exist", async () => {
    const a = await build({ events: [EVENTS[2]] });
    expect(a.items.map((i: Item) => [i.topic, i.minutes])).toEqual([["Discussion: Planning", 55], ["Wrap-up: decisions, owners and next steps", 5]]);
    expect(a.prep).toContain("No agenda topics were given (topics input or an Agenda/Topics section in the notes); add topics to replace the open discussion slot");
    expect(a.prep).toContain("No attendees are listed on the event or in the notes; confirm who should attend");
  });

  it("computes durations from absolute instants across a DST change (no local-time arithmetic)", async () => {
    // US DST starts 2026-03-08 02:00 local: 01:30 PST to 03:30 PDT is one hour.
    const ev = [{ uid: "dst", summary: "DST", start: "2026-03-08T01:30:00-08:00", end: "2026-03-08T03:30:00-07:00" }];
    const a = await build({ events: ev, topics: [{ topic: "X", minutes: 30 }] });
    expect(a.duration_minutes).toBe(60);
    expect(a.start).toBe("2026-03-08T09:30:00Z");
    expect(a.end).toBe("2026-03-08T10:30:00Z");
    expect(a.items[1]).toMatchObject({ topic: "Open discussion / buffer", start: "2026-03-08T10:00:00Z", local_start: "2026-03-08T02:00:00-08:00" });
    expect(a.warnings.join(" ")).toMatch(/different UTC offsets/);
    const offset = await build({ events: [{ uid: "k", summary: "K", start: "2026-06-01T09:00:00+05:45", end: "2026-06-01T09:20:00+05:45" }] });
    expect(offset.start).toBe("2026-06-01T03:15:00Z");
    expect(offset.items[0].local_start).toBe("2026-06-01T09:00:00+05:45");
  });

  it("rejects floating, all-day, inverted and unknown events", async () => {
    const one = (start: string, end: string) => build({ events: [{ uid: "x", summary: "x", start, end }] });
    await expect(one("2026-11-26T10:00:00", "2026-11-26T11:00:00")).rejects.toMatchObject({ code: "invalid_input", message: expect.stringMatching(/UTC offset/) });
    await expect(one("2026-11-26", "2026-11-27")).rejects.toMatchObject({ code: "invalid_input", message: expect.stringMatching(/all-day/) });
    await expect(one("2026-11-26T11:00:00Z", "2026-11-26T10:00:00Z")).rejects.toMatchObject({ code: "invalid_input", message: expect.stringMatching(/ends before it starts/) });
    await expect(one("2026-02-30T10:00:00Z", "2026-02-30T11:00:00Z")).rejects.toMatchObject({ code: "invalid_input" });
    await expect(build({ events: EVENTS, event_uid: "nope" })).rejects.toMatchObject({ code: "invalid_input" });
    await expect(build({ events: [] })).rejects.toMatchObject({ code: "invalid_input" });
    await expect(build({ events: [EVENTS[0], EVENTS[2]], now: "2027-01-01T00:00:00Z" })).rejects.toMatchObject({ message: expect.stringMatching(/No upcoming/) });
    await expect(build({ events: EVENTS, topics: [{ topic: "x", minutes: 0 }] })).rejects.toMatchObject({ code: "invalid_input" });
    await expect(build({})).rejects.toMatchObject({ code: "invalid_input" });
  });
});

describe("prep_checklist and follow_up_template", () => {
  it("returns sourced checklist items", async () => {
    const out = await agent.call("prep_checklist", { events: EVENTS, notes: NOTES, event_uid: "weekly-42" });
    expect(out.title).toBe("Weekly product sync");
    expect(out.checklist[0]).toEqual({ task: "From your notes: Read the Q4 metrics doc", source: "notes" });
    expect(out.checklist.filter((c: { source: string }) => c.source === "action_items")).toHaveLength(3);
  });

  it("renders a markdown template with placeholders and carried-over actions (no invented content)", async () => {
    const agenda = await build({ events: EVENTS, notes: NOTES });
    const out = await agent.call("follow_up_template", { agenda });
    expect(out.format).toBe("markdown");
    const md: string = out.markdown;
    expect(md.startsWith("# Follow-up: Weekly product sync\n")).toBe(true);
    expect(md).toContain("- **When:** 2026-11-26T10:00:00-05:00 (60 min)");
    expect(md).toContain("- **Attendees:** Alice \\<alice@example.com\\>, Bob \\<bob@example.com\\>, Carol");
    expect(md).toContain("| [ ] | @bob Send the vendor contract to legal (due 2026-11-20) (carried over) | bob | 2026-11-20 |");
    expect(md).toContain("| [ ] | _(fill in)_ | _(fill in)_ | _(fill in)_ |");
    expect(md).toContain("3. **Pricing page copy** (26 min)");
    const fromEvents = await agent.call("follow_up_template", { events: EVENTS, notes: NOTES }, { now: NOW });
    expect(fromEvents.markdown).toBe(md);
    await expect(agent.call("follow_up_template", {})).rejects.toMatchObject({ code: "invalid_input" });
  });
});

describe("MCP stdio protocol", () => {
  it("lists and calls tools", async () => {
    const list = await handleMcpMessage(agent, { jsonrpc: "2.0", id: 1, method: "tools/list" });
    expect(list.result.tools.map((t: { name: string }) => t.name)).toEqual(["build_agenda", "prep_checklist", "follow_up_template"]);
    const res = await handleMcpMessage(agent, { jsonrpc: "2.0", id: 2, method: "tools/call", params: { name: "build_agenda", arguments: { events: [EVENTS[2]] } } });
    expect(res.result.isError).toBe(false);
    expect(res.result.structuredContent.duration_minutes).toBe(60);
    const bad = await handleMcpMessage(agent, { jsonrpc: "2.0", id: 3, method: "tools/call", params: { name: "build_agenda", arguments: { events: [{ uid: "x", summary: "x", start: "soon", end: "later" }] } } });
    expect(bad.result.isError).toBe(true);
    expect(bad.result.content[0].text).toMatch(/^invalid_input: .*UTC offset/);
  });
});

Find an agent

Do not include passwords, keys, customer data or other confidential details.
Rule-based matching is free during the public beta (fair use).