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:
parent
deb9e3ae06
commit
e84eda7525
44 changed files with 222 additions and 233 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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) && {
|
||||
|
|
|
|||
|
|
@ -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},
|
||||
},
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -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 `/**
|
||||
|
|
|
|||
|
|
@ -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) => {
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
*/
|
||||
|
||||
export interface ToolDefinition {
|
||||
exportName: string;
|
||||
name: string;
|
||||
description: string;
|
||||
parameters?: ParameterDefinition[];
|
||||
returns?: ReturnDefinition;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue