- Database: Migrate column export_name to name in tools table - Prisma schema: Update Tool model to use name field - Sync routes: Update keyword and changes sync to use name - Railway executor: Update API endpoints to use name parameter - API routes: Update all tool routes to use name field - Web app: Update all pages and components - Playground: Update tool loader and sidebar - create-basic-tools: Update types and generators - Scripts: Update sync and test scripts Database migration was done via direct SQL: ALTER TABLE tools RENAME COLUMN export_name TO name; The unique constraint remains on (package_id, name). 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
147 lines
5.6 KiB
TypeScript
147 lines
5.6 KiB
TypeScript
import { manualTools } from './manual-tools.js';
|
|
import { prisma } from './packages/db/src/index.js';
|
|
import { fetchLatestPackageWithMetadata } from './packages/npm-client/src/package.js';
|
|
|
|
async function syncManualTools() {
|
|
console.log('\n🔧 Starting manual tools sync...\n');
|
|
|
|
let processed = 0;
|
|
const skipped = 0;
|
|
let errors = 0;
|
|
|
|
for (const manualTool of manualTools) {
|
|
try {
|
|
console.log(`Processing: ${manualTool.npmPackageName} (${manualTool.name})`);
|
|
|
|
// Fetch package metadata from npm
|
|
const npmData = await fetchLatestPackageWithMetadata(manualTool.npmPackageName);
|
|
|
|
if (!npmData) {
|
|
console.error(` ❌ Package not found on npm: ${manualTool.npmPackageName}`);
|
|
errors++;
|
|
continue;
|
|
}
|
|
|
|
// Use manual version if specified, otherwise use latest from npm
|
|
const version = manualTool.npmVersion || npmData.version;
|
|
|
|
// Get published date
|
|
const publishedAt =
|
|
npmData.time?.[version] || npmData.time?.modified || new Date().toISOString();
|
|
|
|
// Upsert Package record
|
|
const packageRecord = await prisma.package.upsert({
|
|
where: { npmPackageName: manualTool.npmPackageName },
|
|
create: {
|
|
npmPackageName: manualTool.npmPackageName,
|
|
npmVersion: version,
|
|
npmPublishedAt: new Date(publishedAt),
|
|
npmDescription: npmData.description || null,
|
|
npmRepository: npmData.repository || null,
|
|
npmHomepage: npmData.homepage || manualTool.websiteUrl || null,
|
|
npmLicense: npmData.license || null,
|
|
npmKeywords: npmData.keywords || [],
|
|
npmReadme: npmData.readme || null,
|
|
npmAuthor: npmData.author || null,
|
|
npmMaintainers: npmData.maintainers || null,
|
|
category: manualTool.category,
|
|
// biome-ignore lint/suspicious/noExplicitAny: Prisma Json type compatibility
|
|
env: manualTool.env ? (manualTool.env as any) : null,
|
|
frameworks: manualTool.frameworks,
|
|
tier: calculateTier(manualTool),
|
|
discoveryMethod: 'manual',
|
|
isOfficial: manualTool.npmPackageName.startsWith('@tpmjs/'),
|
|
npmDownloadsLastMonth: 0,
|
|
},
|
|
update: {
|
|
npmVersion: version,
|
|
npmPublishedAt: new Date(publishedAt),
|
|
npmDescription: npmData.description || null,
|
|
npmRepository: npmData.repository || null,
|
|
npmHomepage: npmData.homepage || manualTool.websiteUrl || null,
|
|
npmLicense: npmData.license || null,
|
|
npmKeywords: npmData.keywords || [],
|
|
npmReadme: npmData.readme || null,
|
|
npmAuthor: npmData.author || null,
|
|
npmMaintainers: npmData.maintainers || null,
|
|
category: manualTool.category,
|
|
// biome-ignore lint/suspicious/noExplicitAny: Prisma Json type compatibility
|
|
env: manualTool.env ? (manualTool.env as any) : null,
|
|
frameworks: manualTool.frameworks,
|
|
tier: calculateTier(manualTool),
|
|
isOfficial: manualTool.npmPackageName.startsWith('@tpmjs/'),
|
|
},
|
|
});
|
|
|
|
console.log(` ✅ Package upserted: ${packageRecord.id}`);
|
|
|
|
// Get existing tools for this package
|
|
const existingTools = await prisma.tool.findMany({
|
|
where: { packageId: packageRecord.id },
|
|
});
|
|
|
|
// Upsert the tool
|
|
const tool = await prisma.tool.upsert({
|
|
where: {
|
|
packageId_name: {
|
|
packageId: packageRecord.id,
|
|
name: manualTool.name,
|
|
},
|
|
},
|
|
create: {
|
|
packageId: packageRecord.id,
|
|
name: manualTool.name,
|
|
description: manualTool.description,
|
|
// biome-ignore lint/suspicious/noExplicitAny: Prisma Json type compatibility
|
|
parameters: manualTool.parameters ? (manualTool.parameters as any) : null,
|
|
// biome-ignore lint/suspicious/noExplicitAny: Prisma Json type compatibility
|
|
returns: manualTool.returns ? (manualTool.returns as any) : null,
|
|
// biome-ignore lint/suspicious/noExplicitAny: Prisma Json type compatibility
|
|
aiAgent: manualTool.aiAgent ? (manualTool.aiAgent as any) : null,
|
|
},
|
|
update: {
|
|
description: manualTool.description,
|
|
// biome-ignore lint/suspicious/noExplicitAny: Prisma Json type compatibility
|
|
parameters: manualTool.parameters ? (manualTool.parameters as any) : null,
|
|
// biome-ignore lint/suspicious/noExplicitAny: Prisma Json type compatibility
|
|
returns: manualTool.returns ? (manualTool.returns as any) : null,
|
|
// biome-ignore lint/suspicious/noExplicitAny: Prisma Json type compatibility
|
|
aiAgent: manualTool.aiAgent ? (manualTool.aiAgent as any) : null,
|
|
},
|
|
});
|
|
|
|
console.log(` ✅ Tool upserted: ${tool.name} (${tool.id})`);
|
|
processed++;
|
|
} catch (error) {
|
|
console.error(
|
|
` ❌ Error processing ${manualTool.npmPackageName} (${manualTool.name}):`,
|
|
error
|
|
);
|
|
errors++;
|
|
}
|
|
}
|
|
|
|
console.log('\n📊 Manual sync complete!');
|
|
console.log(` Processed: ${processed}`);
|
|
console.log(` Skipped: ${skipped}`);
|
|
console.log(` Errors: ${errors}`);
|
|
console.log(` Total manual tools: ${manualTools.length}\n`);
|
|
}
|
|
|
|
function calculateTier(tool: (typeof manualTools)[0]): 'minimal' | 'rich' {
|
|
// Tier is 'rich' if tool has parameters OR returns OR aiAgent
|
|
if (tool.parameters || tool.returns || tool.aiAgent) {
|
|
return 'rich';
|
|
}
|
|
return 'minimal';
|
|
}
|
|
|
|
syncManualTools()
|
|
.then(() => process.exit(0))
|
|
.catch((error) => {
|
|
console.error('❌ Manual sync failed:', error);
|
|
process.exit(1);
|
|
})
|
|
.finally(() => {
|
|
prisma.$disconnect();
|
|
});
|