Composio powers 1000+ toolkits, tool search, context management, authentication, and a sandboxed workbench to help you build AI agents that turn intent into action.
Mirrored from https://github.com/Camo67/composio.git
Synced Nov 21, 03:37 UTC
| 1 | import { z } from 'zod'; |
| 2 | import { readFileSync } from 'node:fs'; |
| 3 | import { assertPageFacts, parityPages } from '../tests/fixtures/semantic-parity'; |
| 4 | |
| 5 | // Accept retrieved text or an exported index, with chunks in their source order. |
| 6 | const snapshotSchema = z.object({ |
| 7 | surface: z.string().min(1), |
| 8 | capturedAt: z.string().datetime(), |
| 9 | includesLegacy: z.boolean(), |
| 10 | pages: z.array(z.object({ |
| 11 | url: z.string().refine(value => { |
| 12 | try { |
| 13 | return new URL(value, 'https://docs.composio.dev').origin === 'https://docs.composio.dev'; |
| 14 | } catch { |
| 15 | return false; |
| 16 | } |
| 17 | }, 'Expected a canonical docs.composio.dev URL or site path'), |
| 18 | content: z.string(), |
| 19 | })).min(1), |
| 20 | }); |
| 21 | |
| 22 | const path = process.argv[2]; |
| 23 | if (!path) throw new Error('Usage: bun scripts/check-docs-parity.ts <snapshot.json>'); |
| 24 | const snapshot = snapshotSchema.parse(JSON.parse(readFileSync(path, 'utf8'))); |
| 25 | const pages = new Map<string, string>(); |
| 26 | for (const page of snapshot.pages) { |
| 27 | const url = new URL(page.url, 'https://docs.composio.dev').pathname.replace(/\.mdx?$/, '').replace(/\/$/, ''); |
| 28 | pages.set(url, [pages.get(url), page.content].filter(Boolean).join('\n\n')); |
| 29 | } |
| 30 | |
| 31 | const failures: string[] = []; |
| 32 | for (const page of parityPages) { |
| 33 | if (!snapshot.includesLegacy && page.url.startsWith('/reference/v3/')) continue; |
| 34 | try { |
| 35 | assertPageFacts(pages.get(page.url) ?? '', page, snapshot.surface); |
| 36 | } catch (error) { |
| 37 | failures.push(error instanceof Error ? error.message : String(error)); |
| 38 | } |
| 39 | } |
| 40 | if (failures.length) throw new Error(failures.join('\n')); |
| 41 | console.log(`${snapshot.surface}: parity passed for snapshot captured ${snapshot.capturedAt}`); |