tpmjs/packages/tools/official/IMPLEMENTATION_SUMMARY.md
Ajax Davis 5d2096fb5d feat: add 100+ official TPMJS tools
Implements a comprehensive suite of AI SDK v6 tools across multiple categories:

- Research (5): page-brief, compare-pages, source-credibility, claim-checklist, timeline-from-text
- Web (10): fetch-text, links-catalog, extract-meta, extract-json-ld, redirect-trace, sitemap-read, rss-read, table-extract, robots-policy, url-normalize
- Data (15): csv-parse, csv-stringify, json-repair, json-schema-validate, yaml-parse, yaml-stringify, text-chunk, normalize-whitespace, dedupe-by-key, pivot, rows-filter, rows-sort, rows-group-aggregate, rows-join, schema-infer
- Doc (12): toc-generate, glossary-build, faq-from-text, executive-brief, decision-record-adr, prd-outline, acceptance-criteria, style-rewrite
- Eng (12): diff-text-unified, env-var-docs-generate, dependency-audit-lite, conventional-commit-suggest, markdown-lint-basic, test-case-generate, stacktrace-parse, release-notes, changelog-entry, release-checklist
- Security (7): redact-secrets, secret-scan-text, url-risk-heuristic, csp-compose, hardening-checklist-web, access-control-matrix, data-classification-heuristic
- Stats (9): effect-size-suite, bootstrap-ci, permutation-test, multiple-testing-adjust, linear-regression-ols, logistic-regression, time-series-decompose-lite, anomaly-detect-mad
- Ops (7): slo-draft, runbook-draft, postmortem-draft, postmortem-action-extractor, error-log-triage, coverage-tracker, monitoring-gap-analysis
- Agent (15): prompt-to-workflow-skeleton, workflow-validate-io, workflow-explain, workflow-cost-estimate, tool-call-accuracy-score, eval-fixture-build, guardrail-policy-draft, workflow-auto-repair, tool-selection-plan, novelty-score-workflow, workflow-variant-generate, config-normalize, recipe-*
- Utility (8): base64-encode, base64-decode, hash-text, regex-extract, template-render, date-parse, json-path-query, url-parse
- HTML (3): html-sanitize, html-to-markdown, markdown-to-html

All tools follow AI SDK v6 pattern with tool() and jsonSchema<T>().

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-31 22:55:56 +10:00

8.9 KiB

Implementation Summary: 4 New TPMJS Tools

Overview

Successfully implemented 4 new tools for the TPMJS official tools collection:

  1. doc.styleRewrite - Text style guide enforcement
  2. doc.meetingMinutesFormat - Meeting minutes formatter
  3. doc.testPlanMatrix - Test coverage matrix generator
  4. eng.openapiSnippetBuild - OpenAPI code snippet generator

All tools follow the established pattern from page-brief and are production-ready with:

  • Working TypeScript implementation
  • AI SDK v6 integration
  • Full type definitions
  • Built and verified
  • Type-checked successfully

1. doc.styleRewrite

Path: /packages/tools/official/style-rewrite/

Purpose: Rewrites text to match a style guide using find/replace rules.

Key Features:

  • Supports simple string replacement (find/replace)
  • Supports regex patterns (pattern/replacement)
  • Tracks all changes applied
  • Returns before/after length statistics

Input:

{
  text: string;
  rules: Array<{
    find?: string;
    replace?: string;
    pattern?: string;
    replacement?: string;
  }>;
}

Output:

{
  rewritten: string;
  changesApplied: Array<{
    rule: string;
    matches: number;
    preview: string;
  }>;
  originalLength: number;
  newLength: number;
}

Example Usage:

import { styleRewriteTool } from '@tpmjs/tools-style-rewrite';

const result = await styleRewriteTool.execute({
  text: "The colour is grey. Programme the API.",
  rules: [
    { find: "colour", replace: "color" },
    { find: "grey", replace: "gray" },
    { find: "Programme", replace: "Program" }
  ]
});
// result.rewritten: "The color is gray. Program the API."
// result.changesApplied: [{ rule: "Find: colour → Replace: color", matches: 1, ... }, ...]

2. doc.meetingMinutesFormat

Path: /packages/tools/official/meeting-minutes-format/

Purpose: Formats meeting minutes from structured input into professional markdown.

Key Features:

  • Professional markdown formatting
  • Automatic action item extraction
  • Attendee tracking
  • Numbered discussion sections

Input:

{
  title: string;
  date: string;
  attendees: string[];
  items: Array<{
    topic: string;
    discussion: string;
    action?: string;
  }>;
}

Output:

{
  minutes: string;        // Formatted markdown
  actionItems: Array<{
    topic: string;
    action: string;
  }>;
  attendeeCount: number;
}

Example Usage:

import { meetingMinutesFormatTool } from '@tpmjs/tools-meeting-minutes-format';

const result = await meetingMinutesFormatTool.execute({
  title: "Q1 Planning Meeting",
  date: "2025-01-15",
  attendees: ["Alice", "Bob", "Carol"],
  items: [
    {
      topic: "Budget Review",
      discussion: "Discussed Q1 budget allocation and approved spending plan.",
      action: "Alice to send final budget spreadsheet by Friday"
    },
    {
      topic: "Launch Timeline",
      discussion: "Reviewed product launch timeline and identified risks."
    }
  ]
});
// result.minutes: "# Q1 Planning Meeting\n\n**Date:** 2025-01-15\n\n..."
// result.actionItems: [{ topic: "Budget Review", action: "Alice to send..." }]

3. doc.testPlanMatrix

Path: /packages/tools/official/test-plan-matrix/

Purpose: Creates a test coverage matrix showing which features are covered by which test types.

Key Features:

  • Visual test coverage matrix
  • Coverage percentage calculation
  • Gap identification (missing test types)
  • Validates coverage mappings

Input:

{
  features: string[];
  testTypes: string[];
  coverage?: Record<string, string[]>;
}

Output:

{
  matrix: Array<Array<{
    feature: string;
    testType: string;
    covered: boolean;
  }>>;
  coverage: Array<{
    feature: string;
    coveredTypes: string[];
    coveragePercentage: number;
  }>;
  gaps: Array<{
    feature: string;
    missingTestTypes: string[];
  }>;
}

Example Usage:

import { testPlanMatrixTool } from '@tpmjs/tools-test-plan-matrix';

const result = await testPlanMatrixTool.execute({
  features: ["Login", "Checkout", "Search"],
  testTypes: ["unit", "integration", "e2e"],
  coverage: {
    "Login": ["unit", "e2e"],
    "Checkout": ["integration", "e2e"],
    "Search": ["unit"]
  }
});
// result.coverage[0]: { feature: "Login", coveredTypes: ["unit", "e2e"], coveragePercentage: 67 }
// result.gaps[0]: { feature: "Login", missingTestTypes: ["integration"] }

4. eng.openapiSnippetBuild

Path: /packages/tools/official/openapi-snippet-build/

Purpose: Generates code snippets from OpenAPI operation definitions.

Key Features:

  • Supports JavaScript, TypeScript, Python, cURL, and Go
  • Handles path/query/header parameters
  • Request body support
  • Automatic import detection

Input:

{
  operation: {
    method: string;
    path: string;
    parameters?: Array<{
      name: string;
      in: 'path' | 'query' | 'header' | 'body';
      required?: boolean;
      type?: string;
      example?: any;
    }>;
    requestBody?: {
      required?: boolean;
      content?: Record<string, { example?: any }>;
    };
  };
  language: 'javascript' | 'typescript' | 'python' | 'curl' | 'go';
}

Output:

{
  snippet: string;
  language: string;
  imports: string[];
}

Example Usage:

import { openapiSnippetBuildTool } from '@tpmjs/tools-openapi-snippet-build';

const result = await openapiSnippetBuildTool.execute({
  operation: {
    method: "POST",
    path: "/api/users/{id}",
    parameters: [
      { name: "id", in: "path", example: "123" },
      { name: "Authorization", in: "header", example: "Bearer token" }
    ],
    requestBody: {
      content: {
        "application/json": {
          example: { name: "John Doe", email: "john@example.com" }
        }
      }
    }
  },
  language: "javascript"
});
// result.snippet: "const response = await fetch('https://api.example.com/api/users/123', {\n  method: 'POST',\n  ..."

Python Example:

response = requests.post(
    'https://api.example.com/api/users/123',
    headers={"Authorization":"Bearer token"},
    json={
      "name": "John Doe",
      "email": "john@example.com"
    }
)

data = response.json()

cURL Example:

curl -X POST 'https://api.example.com/api/users/123' \
  -H 'Authorization: Bearer token' \
  -H 'Content-Type: application/json' \
  -d '{ "name": "John Doe", "email": "john@example.com" }'

Build Verification

All tools have been successfully built and verified:

# Type-check all tools
✅ style-rewrite: pnpm type-check (PASSED)
✅ meeting-minutes-format: pnpm type-check (PASSED)
✅ test-plan-matrix: pnpm type-check (PASSED)
✅ openapi-snippet-build: pnpm type-check (PASSED)

# Build all tools
✅ style-rewrite: pnpm build (SUCCESS - 3.5KB JS, 1.0KB .d.ts)
✅ meeting-minutes-format: pnpm build (SUCCESS - 3.4KB JS, 1.0KB .d.ts)
✅ test-plan-matrix: pnpm build (SUCCESS - 3.6KB JS, 1.2KB .d.ts)
✅ openapi-snippet-build: pnpm build (SUCCESS - 7.9KB JS, 1.2KB .d.ts)

Package Metadata

Each tool includes proper tpmjs metadata in package.json:

  • Category: documentation (tools 1-3), engineering (tool 4)
  • Frameworks: vercel-ai
  • Keywords: Appropriate tags for discoverability
  • Repository: Links to GitHub repository
  • License: MIT

Dependencies

All tools use minimal dependencies:

  • ai: 6.0.0-beta.124 (AI SDK v6)
  • No external runtime dependencies (except AI SDK)
  • Dev dependencies: @tpmjs/tsconfig, tsup, typescript

File Structure

Each tool follows the standard structure:

tool-name/
├── src/
│   └── index.ts          # Main implementation
├── dist/                 # Build output (generated)
│   ├── index.js         # ESM JavaScript
│   └── index.d.ts       # TypeScript definitions
├── package.json         # Package metadata with tpmjs config
├── tsconfig.json        # TypeScript configuration
└── tsup.config.ts       # Build configuration

Next Steps

The tools are ready for use. To add them to the blocks registry:

  1. Update blocks.yml to include the new tools (as requested, this was NOT done automatically)
  2. Publish to npm via changesets workflow
  3. Update documentation/website to showcase the new tools

Implementation Notes

Code Quality:

  • All code includes comprehensive JSDoc comments
  • Full TypeScript type safety
  • Error handling with descriptive messages
  • Input validation for all parameters
  • Follows existing codebase patterns

Testing:

  • Type-checked with strict TypeScript settings
  • Builds successfully with tsup
  • No external dependencies to manage
  • Self-contained implementations

AI SDK Integration:

  • Uses tool() from AI SDK v6
  • Uses jsonSchema() for input validation
  • Proper async/await patterns
  • Returns strongly-typed results