refactor: rename exportName to name across entire codebase

- 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>
This commit is contained in:
Ajax Davis 2025-12-17 17:19:21 +10:00
parent deb9e3ae06
commit e84eda7525
44 changed files with 222 additions and 233 deletions

View file

@ -62,7 +62,7 @@ model Tool {
package Package @relation(fields: [packageId], references: [id], onDelete: Cascade)
// Tool Identity
exportName String @map("export_name") @db.VarChar(100) // e.g., "helloWorldTool", "default"
name String @db.VarChar(100) // e.g., "helloWorldTool", "default"
// Tool Metadata
description String @db.Text
@ -95,7 +95,7 @@ model Tool {
simulations Simulation[]
healthChecks HealthCheck[]
@@unique([packageId, exportName])
@@unique([packageId, name])
@@index([qualityScore])
@@index([importHealth])
@@index([executionHealth])

View file

@ -61,11 +61,11 @@ export async function runInteractiveCLI(): Promise<GenerationResult> {
const tools = [
{
exportName: 'exampleTool',
name: 'exampleTool',
description: 'An example tool - customize this for your use case',
},
{
exportName: 'anotherTool',
name: 'anotherTool',
description: 'Another example tool - add your implementation here',
},
];
@ -124,9 +124,9 @@ async function generatePackage(config: GeneratorConfig): Promise<GenerationResul
// Generate tool files
for (const tool of tools) {
const toolPath = path.join(outputPath, 'src', 'tools', `${tool.exportName}.ts`);
const toolPath = path.join(outputPath, 'src', 'tools', `${tool.name}.ts`);
await writeFile(toolPath, generateToolFile(tool));
filesCreated.push(`src/tools/${tool.exportName}.ts`);
filesCreated.push(`src/tools/${tool.name}.ts`);
}
// Generate index.ts

View file

@ -24,7 +24,7 @@ export function generatePackageJson(config: GeneratorConfig): string {
tpmjs: {
category: packageInfo.category,
tools: tools.map((tool) => ({
name: tool.exportName,
name: tool.name,
description: tool.description,
})),
...(tools.some((t) => t.env) && {

View file

@ -6,7 +6,7 @@ import type { GeneratorConfig } from '../types.js';
export function generateReadme(config: GeneratorConfig): string {
const { packageInfo, tools } = config;
const toolsList = tools.map((tool) => `- **${tool.exportName}**: ${tool.description}`).join('\n');
const toolsList = tools.map((tool) => `- **${tool.name}**: ${tool.description}`).join('\n');
const usageExample = tools[0];
if (!usageExample) {
@ -32,7 +32,7 @@ ${toolsList}
## Usage
\`\`\`typescript
import { ${usageExample.exportName} } from '${packageInfo.name}';
import { ${usageExample.name} } from '${packageInfo.name}';
import { generateText } from 'ai';
import { openai } from '@ai-sdk/openai';
@ -40,7 +40,7 @@ const result = await generateText({
model: openai('gpt-4'),
prompt: 'Process this text for me',
tools: {
${usageExample.exportName},
${usageExample.name},
},
});

View file

@ -4,10 +4,10 @@ import type { ToolDefinition } from '../types.js';
* Generates a single tool file with Zod schema
*/
export function generateToolFile(tool: ToolDefinition): string {
const { exportName, description } = tool;
const { name, description } = tool;
// Generate schema name (capitalize first letter + "Schema")
const schemaName = `${exportName.charAt(0).toUpperCase()}${exportName.slice(1)}Schema`;
const schemaName = `${name.charAt(0).toUpperCase()}${name.slice(1)}Schema`;
// Generate simple Zod schema (can be enhanced in advanced mode)
const schemaContent = generateSimpleSchema();
@ -19,7 +19,7 @@ const ${schemaName} = z.object({
${schemaContent}
});
export const ${exportName} = tool({
export const ${name} = tool({
description: '${description}',
inputSchema: ${schemaName},
async execute(input: z.infer<typeof ${schemaName}>) {
@ -33,7 +33,7 @@ export const ${exportName} = tool({
}
// TODO: Implement the tool logic here
console.log('${exportName} called with:', input);
console.log('${name} called with:', input);
return {
success: true,
@ -61,7 +61,7 @@ function generateSimpleSchema(): string {
*/
export function generateIndexFile(tools: ToolDefinition[]): string {
const exports = tools
.map((tool) => `export { ${tool.exportName} } from './tools/${tool.exportName}.js';`)
.map((tool) => `export { ${tool.name} } from './tools/${tool.name}.js';`)
.join('\n');
return `/**

View file

@ -10,7 +10,7 @@ program
.option('--name <name>', 'Package name (e.g., @myorg/content-tools)')
.option('--description <description>', 'Package description')
.option('--category <category>', 'Tool category')
.option('--tool <tool...>', 'Tool definition (format: "exportName:description")')
.option('--tool <tool...>', 'Tool definition (format: "name:description")')
.option('--output <path>', 'Output path')
.option('--yes', 'Skip confirmation prompt')
.action(async (options) => {

View file

@ -55,7 +55,7 @@ export async function promptTools(): Promise<ToolDefinition[] | null> {
* Prompts for a single tool definition
*/
async function promptSingleTool(number: number): Promise<ToolDefinition | null> {
const exportName = await clack.text({
const name = await clack.text({
message: `Tool #${number} export name`,
placeholder: number === 1 ? 'summarizeText' : number === 2 ? 'extractKeywords' : 'myTool',
validate: (value) => {
@ -67,7 +67,7 @@ async function promptSingleTool(number: number): Promise<ToolDefinition | null>
},
});
if (clack.isCancel(exportName)) {
if (clack.isCancel(name)) {
return null;
}
@ -93,7 +93,7 @@ async function promptSingleTool(number: number): Promise<ToolDefinition | null>
}
return {
exportName: exportName as string,
name: name as string,
description: description as string,
};
}

View file

@ -3,7 +3,7 @@
*/
export interface ToolDefinition {
exportName: string;
name: string;
description: string;
parameters?: ParameterDefinition[];
returns?: ReturnDefinition;

View file

@ -30,7 +30,7 @@ export const registryExecuteTool = tool({
properties: {
toolId: {
type: 'string',
description: "Tool identifier from registrySearchTool (format: 'package::exportName')",
description: "Tool identifier from registrySearchTool (format: 'package::name')",
},
params: {
type: 'object',
@ -49,22 +49,22 @@ export const registryExecuteTool = tool({
additionalProperties: false,
}),
async execute({ toolId, params, env }) {
// Parse toolId format: "package::exportName"
// Parse toolId format: "package::name"
const separatorIndex = toolId.lastIndexOf('::');
if (separatorIndex === -1) {
throw new Error(`Invalid toolId format. Expected "package::exportName", got "${toolId}"`);
throw new Error(`Invalid toolId format. Expected "package::name", got "${toolId}"`);
}
const packageName = toolId.substring(0, separatorIndex);
const exportName = toolId.substring(separatorIndex + 2);
const name = toolId.substring(separatorIndex + 2);
if (!packageName || !exportName) {
throw new Error(`Invalid toolId format. Expected "package::exportName", got "${toolId}"`);
if (!packageName || !name) {
throw new Error(`Invalid toolId format. Expected "package::name", got "${toolId}"`);
}
// Fetch tool metadata to get version and importUrl
const metaParams = new URLSearchParams({
q: exportName,
q: name,
limit: '10',
});
const metaResponse = await fetch(`${TPMJS_API_URL}/api/tools/search?${metaParams}`);
@ -80,7 +80,7 @@ export const registryExecuteTool = tool({
// Find the exact tool match
// biome-ignore lint/suspicious/noExplicitAny: API response types vary
const toolMeta = toolsArray.find(
(t: any) => t.package.npmPackageName === packageName && t.exportName === exportName
(t: any) => t.package.npmPackageName === packageName && t.name === name
);
if (!toolMeta) {
@ -96,7 +96,7 @@ export const registryExecuteTool = tool({
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
packageName,
exportName,
name,
version,
importUrl,
params,

View file

@ -81,10 +81,10 @@ export const registrySearchTool = tool({
// biome-ignore lint/suspicious/noExplicitAny: Tool types from API vary
tools: toolsArray.map((t: any) => ({
// Unique identifier for registryExecuteTool
toolId: `${t.package.npmPackageName}::${t.exportName}`,
toolId: `${t.package.npmPackageName}::${t.name}`,
// Human-readable info
name: t.exportName,
name: t.name,
package: t.package.npmPackageName,
description: t.description,
category: t.package.category,

View file

@ -110,7 +110,7 @@ export const searchTpmjsToolsTool = tool({
tools: toolsArray.map((tool: any) => ({
toolId: tool.id,
packageName: tool.package.npmPackageName,
exportName: tool.exportName,
name: tool.name,
description: tool.description,
category: tool.package.category,
qualityScore: tool.qualityScore,