mcp-sampling-index-enrich.test.mjs
sha256:65ccb454656ea5acdea0a10e559b78bcde1eb6ff753ecc2911bc99d1c3d7cadd
feat(calendar): enforce agent context tiers in retrieval AP…
Human
minor
⚠ breaking
1 day ago
| 1 | import { describe, it, mock, beforeEach } from 'node:test'; |
| 2 | import assert from 'node:assert/strict'; |
| 3 | |
| 4 | describe('enrichIndexedNotes', () => { |
| 5 | const mockNotes = [ |
| 6 | { path: 'inbox/note1.md', body: 'Content of note 1', frontmatter: {} }, |
| 7 | { path: 'inbox/note2.md', body: 'Content of note 2', frontmatter: {} }, |
| 8 | { path: 'inbox/note3.md', body: 'Already enriched', frontmatter: { ai_summary: 'exists' } }, |
| 9 | { path: 'inbox/empty.md', body: '', frontmatter: {} }, |
| 10 | ]; |
| 11 | |
| 12 | function makeMockServer({ response = 'Summary text', sampling = true } = {}) { |
| 13 | return { |
| 14 | server: { |
| 15 | getClientCapabilities: () => (sampling ? { sampling: {} } : {}), |
| 16 | createMessage: async () => ({ |
| 17 | content: { type: 'text', text: response }, |
| 18 | model: 'mock', |
| 19 | role: 'assistant', |
| 20 | }), |
| 21 | }, |
| 22 | }; |
| 23 | } |
| 24 | |
| 25 | it('skips notes with existing ai_summary', async () => { |
| 26 | const enrichableNotes = mockNotes.filter((n) => n.body && !n.frontmatter?.ai_summary); |
| 27 | assert.equal(enrichableNotes.length, 2); |
| 28 | const skippedNote = mockNotes.find((n) => n.frontmatter?.ai_summary); |
| 29 | assert.ok(skippedNote); |
| 30 | assert.equal(skippedNote.path, 'inbox/note3.md'); |
| 31 | }); |
| 32 | |
| 33 | it('skips notes with empty body', async () => { |
| 34 | const enrichable = mockNotes.filter((n) => n.path && n.body && !n.frontmatter?.ai_summary); |
| 35 | assert.equal(enrichable.length, 2); |
| 36 | assert.ok(!enrichable.find((n) => n.path === 'inbox/empty.md')); |
| 37 | }); |
| 38 | |
| 39 | it('reports progress correctly', async () => { |
| 40 | const progressCalls = []; |
| 41 | const onProgress = async (done, total) => { |
| 42 | progressCalls.push({ done, total }); |
| 43 | }; |
| 44 | |
| 45 | const notes = [ |
| 46 | { path: 'a.md', body: 'content a', frontmatter: {} }, |
| 47 | { path: 'b.md', body: 'content b', frontmatter: {} }, |
| 48 | ]; |
| 49 | |
| 50 | for (let i = 0; i < notes.length; i++) { |
| 51 | await onProgress(i + 1, notes.length); |
| 52 | } |
| 53 | |
| 54 | assert.equal(progressCalls.length, 2); |
| 55 | assert.deepEqual(progressCalls[0], { done: 1, total: 2 }); |
| 56 | assert.deepEqual(progressCalls[1], { done: 2, total: 2 }); |
| 57 | }); |
| 58 | |
| 59 | it('limits to max 200 notes', () => { |
| 60 | const limit = Math.min(300, 200); |
| 61 | assert.equal(limit, 200); |
| 62 | }); |
| 63 | }); |
File History
2 commits
sha256:65ccb454656ea5acdea0a10e559b78bcde1eb6ff753ecc2911bc99d1c3d7cadd
feat(calendar): enforce agent context tiers in retrieval AP…
Human
minor
⚠
1 day ago
sha256:9103f98c89257ed2b01c237cea895dabb3e85ea337dccb1161c175e4422355b6
docs: accept Calendar Events v0 spec with Phase 0 security …
Human
2 days ago