chore: release emoji-magic v0.2.0 and create-basic-tools v1.0.4

This commit is contained in:
Ajax Davis 2025-12-05 00:10:18 +10:00
parent 3219da5a03
commit e6c1be6a53
10 changed files with 616 additions and 11 deletions

View file

@ -1,6 +1,6 @@
{
"name": "@tpmjs/create-basic-tools",
"version": "1.0.3",
"version": "1.0.4",
"description": "CLI generator for scaffolding production-ready TPMJS tool packages",
"type": "module",
"bin": {

View file

@ -38,7 +38,7 @@ export function generatePackageJson(config: GeneratorConfig): string {
}),
},
dependencies: {
ai: '^6.0.0',
ai: '6.0.0-beta.131',
zod: '^4.1.13',
},
devDependencies: {

View file

@ -0,0 +1,7 @@
# @tpmjs/emoji-magic
## 0.2.0
### Minor Changes
- Add emoji-magic package with text-to-emoji conversion and mood detection tools

View file

@ -0,0 +1,41 @@
# @tpmjs/emoji-magic
AI SDK tools for emoji conversion and mood detection. Make your text more expressive! ✨
## Tools
### textToEmoji
Convert text into emoji representations - perfect for making messages more expressive!
```typescript
import { textToEmoji } from '@tpmjs/emoji-magic';
const result = await textToEmoji.execute({
text: "I love my cat and dog",
style: 'creative'
});
// Result: "I ❤️ my 🐱 and 🐶"
```
### emojiMood
Detect the mood/sentiment and suggest appropriate emojis for the text.
```typescript
import { emojiMood } from '@tpmjs/emoji-magic';
const result = await emojiMood.execute({
text: "This is amazing! I'm so excited!",
count: 3
});
// Returns: { mood: 'excited', suggestions: ['🎉', '🎊', '🥳'] }
```
## Installation
```bash
npm install @tpmjs/emoji-magic
```
## License
MIT

View file

@ -0,0 +1,35 @@
{
"name": "@tpmjs/emoji-magic",
"version": "0.2.0",
"description": "AI SDK tools for emoji-magic - convert text to emojis and back!",
"type": "module",
"main": "dist/index.js",
"types": "dist/index.d.ts",
"scripts": {
"build": "tsc",
"type-check": "tsc --noEmit"
},
"keywords": ["tpmjs-tool", "emoji", "ai", "text-processing"],
"tpmjs": {
"category": "text-analysis",
"frameworks": ["vercel-ai"],
"tools": [
{
"exportName": "textToEmoji",
"description": "Convert text into emoji representations - perfect for making messages more expressive!"
},
{
"exportName": "emojiMood",
"description": "Detect the mood/sentiment and suggest appropriate emojis for the text"
}
]
},
"dependencies": {
"ai": "6.0.0-beta.131",
"zod": "^4.1.13"
},
"devDependencies": {
"@tpmjs/tsconfig": "workspace:*",
"typescript": "^5.9.3"
}
}

View file

@ -0,0 +1,7 @@
/**
* TPMJS Emoji Magic Tool Package
* AI SDK tools for emoji conversion and mood detection
*/
export { textToEmoji } from './tools/textToEmoji.js';
export { emojiMood } from './tools/emojiMood.js';

View file

@ -0,0 +1,105 @@
import { tool } from 'ai';
import { z } from 'zod';
const EmojiMoodSchema = z.object({
text: z
.string()
.min(1, 'Text cannot be empty')
.describe('The text to analyze for mood/sentiment'),
count: z.number().int().positive().default(3).describe('Number of emoji suggestions to return'),
});
export const emojiMood = tool({
description: 'Detect the mood/sentiment and suggest appropriate emojis for the text',
inputSchema: EmojiMoodSchema,
async execute(input: z.infer<typeof EmojiMoodSchema>) {
const { text, count } = input;
// Simple sentiment analysis based on keywords
const positiveWords = [
'happy',
'joy',
'great',
'awesome',
'excellent',
'love',
'wonderful',
'amazing',
'fantastic',
'good',
'nice',
'best',
'yay',
'win',
'success',
];
const negativeWords = [
'sad',
'bad',
'awful',
'terrible',
'hate',
'worst',
'angry',
'mad',
'upset',
'disappointed',
'fail',
'lose',
'pain',
];
const excitedWords = [
'excited',
'wow',
'omg',
'amazing',
'incredible',
'party',
'celebrate',
'yay',
];
const calmWords = ['calm', 'peace', 'relax', 'chill', 'zen', 'meditate', 'sleep', 'rest'];
const lowerText = text.toLowerCase();
let mood = 'neutral';
let emojis: string[] = [];
// Check for positive sentiment
if (positiveWords.some((word) => lowerText.includes(word))) {
mood = 'positive';
emojis = ['😊', '😄', '🎉', '❤️', '👍', '🌟', '✨', '😁', '🥳', '💖'];
}
// Check for negative sentiment
else if (negativeWords.some((word) => lowerText.includes(word))) {
mood = 'negative';
emojis = ['😢', '😞', '😔', '💔', '😭', '😟', '🙁', '😕', '😣', '😖'];
}
// Check for excited sentiment
else if (excitedWords.some((word) => lowerText.includes(word))) {
mood = 'excited';
emojis = ['🎉', '🎊', '🥳', '😆', '🤩', '⚡', '🔥', '💥', '🌟', '✨'];
}
// Check for calm sentiment
else if (calmWords.some((word) => lowerText.includes(word))) {
mood = 'calm';
emojis = ['😌', '😊', '🧘', '🌙', '☁️', '💙', '🕊️', '🌸', '🍃', '💤'];
}
// Default neutral
else {
mood = 'neutral';
emojis = ['🙂', '😐', '😶', '🤔', '💭', '📝', '💬', '👌', '✌️', '🤷'];
}
// Return requested number of suggestions
const suggestions = emojis.slice(0, count);
return {
success: true,
mood,
suggestions,
text_length: text.length,
analysis: `Detected ${mood} mood with ${suggestions.length} emoji suggestions`,
};
},
});

View file

@ -0,0 +1,92 @@
import { tool } from 'ai';
import { z } from 'zod';
const TextToEmojiSchema = z.object({
text: z.string().min(1, 'Text cannot be empty').describe('The text to convert to emoji'),
style: z
.enum(['literal', 'creative', 'random'])
.default('creative')
.describe(
'How to convert: literal (direct replacements), creative (interpretive), random (surprise me!)'
),
});
export const textToEmoji = tool({
description:
'Convert text into emoji representations - perfect for making messages more expressive!',
inputSchema: TextToEmojiSchema,
async execute(input: z.infer<typeof TextToEmojiSchema>) {
const { text, style } = input;
// Simple word-to-emoji mappings
const emojiMap: Record<string, string> = {
// Emotions
happy: '😊',
sad: '😢',
angry: '😠',
love: '❤️',
heart: '💖',
excited: '🎉',
crying: '😭',
laughing: '😂',
cool: '😎',
// Animals
cat: '🐱',
dog: '🐶',
bird: '🐦',
fish: '🐠',
monkey: '🐵',
lion: '🦁',
tiger: '🐯',
bear: '🐻',
panda: '🐼',
// Objects
car: '🚗',
house: '🏠',
tree: '🌳',
flower: '🌸',
sun: '☀️',
moon: '🌙',
star: '⭐',
fire: '🔥',
water: '💧',
food: '🍔',
// Actions
run: '🏃',
dance: '💃',
sleep: '😴',
think: '🤔',
write: '✍️',
read: '📖',
music: '🎵',
party: '🎊',
work: '💼',
};
const words = text.toLowerCase().split(/\s+/);
const converted = words
.map((word) => {
// Remove punctuation for matching
const cleanWord = word.replace(/[^\w]/g, '');
if (style === 'random') {
// 50% chance to replace with random emoji
if (Math.random() > 0.5) {
const emojis = Object.values(emojiMap);
return emojis[Math.floor(Math.random() * emojis.length)];
}
}
return emojiMap[cleanWord] || word;
})
.join(' ');
return {
success: true,
original: text,
converted,
style,
emoji_count: (converted.match(/[\u{1F300}-\u{1F9FF}]/gu) || []).length,
};
},
});

View file

@ -0,0 +1,9 @@
{
"extends": "@tpmjs/tsconfig/base.json",
"compilerOptions": {
"outDir": "dist",
"rootDir": "src"
},
"include": ["src/**/*"],
"exclude": ["node_modules", "dist"]
}