npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

@tpmjs/create-basic-tools

v1.0.6

Published

CLI generator for scaffolding production-ready TPMJS tool packages

Readme

@tpmjs/create-basic-tools

CLI generator for scaffolding production-ready TPMJS tool packages. Just enter your package name and you're done!

Features

  • Super fast: Just asks for your package name, generates everything else
  • 🎯 2 example tools: Start with working examples you can customize
  • 🔧 Zod 4 schemas: Uses Zod directly (not jsonSchema wrapper)
  • AI SDK v6: Full compatibility with the latest AI SDK
  • 📦 One file per tool: Clean src/tools/<toolName>.ts structure
  • TPMJS validated: Auto-validates against official TPMJS schemas
  • 📝 Complete setup: Generates package.json, tsconfig, tsup config, README, and more
  • 🚀 Publish ready: Generated packages are ready to publish to npm immediately

Usage

Interactive Mode (Recommended)

pnpmx @tpmjs/create-basic-tools

The CLI asks for just your package name and uses sensible defaults for everything else:

  • Description: Auto-generated from package name
  • Tools: 2 example tools you can customize
  • Category: ai-ml (generic)
  • License: MIT
  • Output: Derived from package name

Example Session

$ pnpmx @tpmjs/create-basic-tools

┌  create-tpmjs-tool
│
◇  Package name
│  @myorg/content-tools
│
◆  Generating package...
│
└  ✓ Success! Created @myorg/content-tools at ./content-tools

   Files created:
     src/tools/exampleTool.ts
     src/tools/anotherTool.ts
     src/index.ts
     package.json

   Next steps:
     cd ./content-tools
     pnpm install
     pnpm build
     pnpm type-check
     pnpm publish

That's it! The generator creates 2 example tools you can rename and customize for your use case.

Generated Package Structure

content-tools/
├── src/
│   ├── tools/                # One file per tool
│   │   ├── exampleTool.ts
│   │   └── anotherTool.ts
│   └── index.ts              # Re-exports all tools
├── dist/                     # Build output (after pnpm build)
│   ├── index.js
│   └── index.d.ts
├── package.json              # With complete tpmjs field
├── tsconfig.json
├── tsup.config.ts
├── README.md
├── .gitignore
├── .npmignore
└── LICENSE

Simply rename exampleTool.ts and anotherTool.ts to match your use case, then customize the implementation.

Generated Tool File Example

Each tool file follows this Zod-first pattern:

import { tool } from 'ai';
import { z } from 'zod';

const ExampleToolSchema = z.object({
  text: z.string().min(1, 'Text cannot be empty').describe('The input text to process.'),
  options: z.object({
    language: z.string().default('en').describe('Language code (e.g., en, es, fr).'),
    maxLength: z.number().int().positive().default(100).describe('Maximum length of output.'),
  }).default({ language: 'en', maxLength: 100 }).describe('Optional configuration.'),
});

export const exampleTool = tool({
  description: 'An example tool - customize this for your use case',
  inputSchema: ExampleToolSchema,
  async execute(input: z.infer<typeof ExampleToolSchema>) {
    // Defensive check: Validate required parameters
    // This prevents crashes when tools are called with missing/empty params
    if (!input.text || input.text.trim().length === 0) {
      return {
        success: false,
        error: 'Missing required parameter: text',
        message: 'The "text" parameter is required and cannot be empty.',
      };
    }

    // TODO: Implement the tool logic here
    console.log('exampleTool called with:', input);

    return {
      success: true,
      message: 'Tool executed successfully. Replace this with your implementation.',
      input,
    };
  },
});

Why Defensive Parameter Validation?

Generated tools include defensive checks for required parameters. While Zod validates the schema, these checks prevent crashes in edge cases where:

  • Tools are called with empty/missing parameters during AI exploration
  • Parameters are undefined due to serialization issues
  • The LLM makes initial "probe" calls to understand tool capabilities

Best Practice: Always validate critical required parameters before using them, especially when:

  • The parameter is used in string operations (.toLowerCase(), .trim(), etc.)
  • The parameter is required for the tool's core functionality
  • Missing the parameter would cause a runtime error

This defensive approach ensures tools return helpful error messages instead of crashing.

After Generation

Once the package is generated:

cd content-tools

# Install dependencies
pnpm install

# Build the package
pnpm build

# Type-check
pnpm type-check

# Publish to npm
pnpm publish --access public

Your tools will appear on tpmjs.com within 2-15 minutes after publishing!

TPMJS Categories

The generator validates against these official TPMJS categories:

  • web-scraping
  • data-processing
  • file-operations
  • communication
  • database
  • api-integration
  • image-processing
  • text-analysis
  • automation
  • ai-ml
  • security
  • monitoring

Requirements

  • Node.js 18+
  • pnpm (recommended)

Development

This is a generator package itself. To work on it:

# Install dependencies
pnpm install

# Build
pnpm build

# Type-check
pnpm type-check

# Test locally
node dist/index.js

License

MIT