tpmjs/packages/tools/create-basic-tools/src/generators
Ajax Davis 38c85bd904 feat: add @tpmjs/create-basic-tools CLI generator
- Interactive CLI generator for scaffolding TPMJS tool packages
- Generates packages with minimum 2 tools (ideally 2-3)
- Zod 4 schemas - uses Zod directly (not jsonSchema wrapper)
- One file per tool in src/tools/<toolName>.ts
- TPMJS validated against official schemas from @tpmjs/types
- Complete package generation ready to publish to npm
- Works both standalone and in monorepo packages/ folders

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-04 23:34:37 +10:00
..
config-files.ts feat: add @tpmjs/create-basic-tools CLI generator 2025-12-04 23:34:37 +10:00
package-json.ts feat: add @tpmjs/create-basic-tools CLI generator 2025-12-04 23:34:37 +10:00
readme.ts feat: add @tpmjs/create-basic-tools CLI generator 2025-12-04 23:34:37 +10:00
source-code.ts feat: add @tpmjs/create-basic-tools CLI generator 2025-12-04 23:34:37 +10:00

import type { GeneratorConfig } from '../types.js';

/**
 * Generates README.md content for the tool package
 */
export function generateReadme(config: GeneratorConfig): string {
  const { packageInfo, tools } = config;

  const toolsList = tools.map((tool) => `- **${tool.exportName}**: ${tool.description}`).join('\n');

  const usageExample = tools[0];
  if (!usageExample) {
    throw new Error('At least one tool is required');
  }

  return `# ${packageInfo.name}

${packageInfo.description}

## Installation

\`\`\`bash
pnpm add ${packageInfo.name}
\`\`\`

## Tools

This package provides ${tools.length} tool${tools.length > 1 ? 's' : ''} for the AI SDK:

${toolsList}

## Usage

\`\`\`typescript
import { ${usageExample.exportName} } from '${packageInfo.name}';
import { generateText } from 'ai';
import { openai } from '@ai-sdk/openai';

const result = await generateText({
  model: openai('gpt-4'),
  prompt: 'Process this text for me',
  tools: {
    ${usageExample.exportName},
  },
});

console.log(result.text);
\`\`\`

## Development

\`\`\`bash
# Install dependencies
pnpm install

# Build the package
pnpm build

# Type-check
pnpm type-check

# Watch mode
pnpm dev
\`\`\`

## Publishing

1. Update the version in \`package.json\`
2. Build the package: \`pnpm build\`
3. Publish to npm: \`pnpm publish --access public\`
4. Your tools will appear on [tpmjs.com](https://tpmjs.com) within 2-15 minutes

## License

${packageInfo.license}
`;
}