Open History to see the last commit
1import { createHash } from 'node:crypto';
2import { mkdir, writeFile } from 'node:fs/promises';
3import { dirname, resolve } from 'node:path';
4
5const revision = 'd3601d9e1f9398b96a1ee25047bafba5f04199eb';
6const names = new Set(['neon', 'neon-postgres', 'neon-object-storage', 'neon-realtime']);
7const root = resolve(import.meta.dirname, '../services/agent/resources/neon');
8const response = await fetch(`https://api.github.com/repos/neondatabase/agent-skills/git/trees/${revision}?recursive=1`);
9if (!response.ok) throw new Error(`Skill catalog returned ${response.status}`);
10const tree = await response.json() as { tree: { path: string; type: string }[] };
11const files = tree.tree.filter(entry => entry.type === 'blob' && (entry.path === 'LICENSE' || entry.path === 'NOTICE' || (names.has(entry.path.split('/')[1]) && entry.path.startsWith('skills/') && entry.path.endsWith('.md'))));
12const manifest: Record<string, string> = {};
13for (const file of files) {
14 if (file.path.includes('..') || file.path.startsWith('/')) throw new Error('Invalid upstream path');
15 const response = await fetch(`https://raw.githubusercontent.com/neondatabase/agent-skills/${revision}/${file.path}`);
16 if (!response.ok) throw new Error(`Skill resource ${file.path} returned ${response.status}`);
17 const bytes = Buffer.from(await response.arrayBuffer());
18 if (bytes.length > 500_000) throw new Error('Skill resource exceeds its byte budget');
19 const target = resolve(root, file.path);
20 await mkdir(dirname(target), { recursive: true });
21 await writeFile(target, bytes);
22 manifest[file.path] = createHash('sha256').update(bytes).digest('hex');
23}
24await writeFile(resolve(root, 'manifest.json'), JSON.stringify({ revision, files: manifest }, null, 2) + '\n');
25console.log(`Pinned ${files.length} official Neon knowledge files. No scripts or extensions were installed.`);