tpmjs/.github/workflows/sync-manual.yml
Ajax Davis 0612eac5e2 feat: implement multi-tool package architecture with manual tool registry
BREAKING CHANGE: Complete refactoring from single-tool to multi-tool package support

Database Schema:
- Split Tool model into Package (1) and Tool (many) with one-to-many relationship
- Package stores npm metadata and package-level tpmjs fields (category, env, frameworks, tier)
- Tool stores individual tool exports with tool-level metadata (exportName, description, parameters, returns, aiAgent)
- Unique constraint on (packageId, exportName) to prevent duplicate tools
- Cascade deletes when packages are removed

Type System:
- Updated tpmjs field schema to support tools array
- Each tool has exportName, description, parameters, returns, aiAgent
- Package-level fields: category, env, frameworks shared across all tools
- Backward compatible with legacy single-tool format (auto-migrates to exportName: "default")

API Updates:
- Updated all /api/tools routes to query Tool model with Package relations
- Updated /api/tools/[slug] to accept package/export path segments
- Updated tool-executor-agent to use actual exportName instead of hardcoded "default"
- Updated metrics sync to calculate quality scores per Tool

Frontend Updates:
- Updated tool search page to display exportName as primary heading
- Updated tool detail pages to show package name as secondary info
- Removed tag-based filtering (tags moved to package level)

Manual Tool Registry:
- Added manual-tools.ts with 23 curated tools from major providers
- Created sync-manual-tools.ts script to sync manual tools to database
- Added MANUAL_TOOLS.md documentation for manual tool system
- Added GitHub workflow for automated daily sync
- Includes tools from: Vercel, Exa, Firecrawl, AWS Bedrock, Perplexity, Tavily, Superagent, Valyu

Playground Updates:
- Updated tool loader to load multiple tools per package
- Added sanitizeToolName for OpenAI API compatibility

Sync System Updates:
- Updated changes feed sync to handle multi-tool packages
- Updated keyword sync to upsert multiple tools per package
- Added orphaned tool deletion when tools removed from package.json

Migration Strategy:
- Database uses same Neon instance for dev and prod
- Schema updated via prisma db push (no migration files yet)
- All data repopulates from npm via sync system

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-04 06:39:58 +10:00

97 lines
3.3 KiB
YAML

name: Sync Manual Tools
on:
schedule:
# Run daily at midnight UTC
- cron: '0 0 * * *'
workflow_dispatch:
# Run on pushes to main that modify manual-tools.ts
push:
branches:
- main
paths:
- 'manual-tools.ts'
- 'sync-manual-tools.ts'
jobs:
sync-manual:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup pnpm
uses: pnpm/action-setup@v2
with:
version: 8
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'pnpm'
- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: Generate Prisma Client
run: pnpm --filter=@tpmjs/db db:generate
- name: Run manual tools sync
id: sync
run: |
# Run the sync script and capture output
output=$(pnpm tsx sync-manual-tools.ts 2>&1)
echo "$output"
# Extract statistics from output
processed=$(echo "$output" | grep "Processed:" | awk '{print $2}')
skipped=$(echo "$output" | grep "Skipped:" | awk '{print $2}')
errors=$(echo "$output" | grep "Errors:" | awk '{print $2}')
total=$(echo "$output" | grep "Total manual tools:" | awk '{print $4}')
# Set outputs for Discord notification
echo "processed=${processed:-0}" >> $GITHUB_OUTPUT
echo "skipped=${skipped:-0}" >> $GITHUB_OUTPUT
echo "errors=${errors:-0}" >> $GITHUB_OUTPUT
echo "total=${total:-0}" >> $GITHUB_OUTPUT
# Determine status
if [ "${errors:-0}" -gt 0 ]; then
echo "status_emoji=⚠️" >> $GITHUB_OUTPUT
echo "status_color=16776960" >> $GITHUB_OUTPUT # Yellow
else
echo "status_emoji=✅" >> $GITHUB_OUTPUT
echo "status_color=5763719" >> $GITHUB_OUTPUT # Green
fi
env:
DATABASE_URL: ${{ secrets.DATABASE_URL }}
- name: Send Discord notification
if: always()
run: |
# Build Discord payload
payload=$(jq -n \
--arg title "${{ steps.sync.outputs.status_emoji }} Manual Tools Sync" \
--argjson color ${{ steps.sync.outputs.status_color }} \
--arg timestamp "$(date -u +%Y-%m-%dT%H:%M:%S.000Z)" \
'
{
embeds: [{
title: $title,
color: $color,
fields: [
{ name: "📦 Total Tools", value: "${{ steps.sync.outputs.total }}", inline: true },
{ name: "✨ Processed", value: "${{ steps.sync.outputs.processed }}", inline: true },
{ name: "⏭️ Skipped", value: "${{ steps.sync.outputs.skipped }}", inline: true },
{ name: "❌ Errors", value: "${{ steps.sync.outputs.errors }}", inline: true },
{ name: "🔗 Run", value: "[View Logs](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }})", inline: true }
],
timestamp: $timestamp
}]
}')
# Send to Discord
curl -X POST "${{ secrets.DISCORD_WEBHOOK }}" \
-H "Content-Type: application/json" \
-d "$payload"