@devries-cameron20 / composio Mirror · read-only
Fork 0

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

next
ts 80 lines 2.89 KB
Raw
1 #!/usr/bin/env bun
2 import { readFileSync } from 'node:fs';
3 import path from 'node:path';
4
5 const root = path.resolve(import.meta.dir, '../..');
6 const references = [
7 '.agents/skills/effect-v4/references/cli-surface.md',
8 '.agents/skills/cli-command/references/command-example.md',
9 ];
10
11 /** Linked excerpts must still occur in the source that the compiler and behavior tests exercise. */
12 export const checkLinkedExamples = (
13 markdown: string,
14 readSource: (file: string) => string
15 ): number => {
16 const blocks = [
17 ...markdown.matchAll(/^```(?:ts|typescript) no-check repo-file=(\S+)\n([\s\S]*?)^```/gm),
18 ];
19 if (blocks.length === 0) throw new Error('Expected at least one repo-linked TypeScript example');
20 for (const [, file, code] of blocks) {
21 if (!file || path.isAbsolute(file) || file.split('/').includes('..')) {
22 throw new Error(`Invalid example source path: ${file}`);
23 }
24 const normalize = (text: string) =>
25 text
26 .split('\n')
27 .map(line => line.trim())
28 .join('\n')
29 .trim();
30 if (!code?.trim()) throw new Error(`Empty example from ${file}`);
31 if (!normalize(readSource(file)).includes(normalize(code))) {
32 throw new Error(`Example differs from ${file}`);
33 }
34 }
35 return blocks.length;
36 };
37
38 if (import.meta.main) {
39 let count = 0;
40 for (const file of references) {
41 count += checkLinkedExamples(readFileSync(path.join(root, file), 'utf8'), source =>
42 readFileSync(path.join(root, source), 'utf8')
43 );
44 }
45 console.log(`${count} CLI skill excerpts match repo source`);
46 const commands = [
47 ['node', '.agents/skills/effect-v4/scripts/check-examples.mjs'],
48 ['pnpm', 'exec', 'turbo', 'run', 'typecheck', '--filter=@composio/cli'],
49 [
50 'pnpm',
51 '--filter',
52 '@composio/cli',
53 'exec',
54 'vitest',
55 'run',
56 'test/skills/command-example.test.ts',
57 'test/src/commands/registration.test.ts',
58 'test/src/commands/surface.test.ts',
59 'test/src/commands/surface.acting-user.test.ts',
60 'test/src/invocation/invocation.test.ts',
61 'test/src/invocation/command-identity.test.ts',
62 'test/src/services/composio-client-singleton.test.ts',
63 'test/src/services/terminal-ui.test.ts',
64 'test/src/run-main.test.ts',
65 'test/src/services/shutdown-signal.test.ts',
66 'test/src/commands/triggers/sink-failures.test.ts',
67 'test/src/commands/listen/listen.cmd.test.ts',
68 'test/src/commands/triggers/triggers.listen.cmd.test.ts',
69 ],
70 ['pnpm', '--filter', '@composio/cli', 'run', 'lint:effect'],
71 ];
72 for (const cmd of commands) {
73 console.log(`Checking: ${cmd.join(' ')}`);
74 const result = Bun.spawnSync(cmd, { cwd: root, stdout: 'inherit', stderr: 'inherit' });
75 if (result.exitCode !== 0) process.exit(result.exitCode || 1);
76 }
77 console.log(
78 'CLI skill examples compile and satisfy the selected invocation contracts. Agent task performance is not measured.'
79 );
80 }