@brinda_yawa/tasks-generator
v1.0.2
Published
An AI-powered tasks generator using Google GenAI.
Maintainers
Readme
📋 @brinda_yawa/tasks-generator
A powerful Node.js package for automatically generating structured task lists from project titles and descriptions using AI-powered generation with Google's Gemini models.
✨ Features
- 🤖 AI-Powered Generation - Uses Google's Gemini AI for intelligent task creation
- 📋 Structured Output - Returns clean, structured JSON task arrays
- 🎯 Context-Aware - Generates relevant tasks tailored to your project description
- ⚙️ Configurable - Choose your Gemini model and generation parameters
- 🔒 Singleton Pattern - Efficient resource management across your application
📦 Installation
npm install @brinda_yawa/tasks-generator🚀 Quick Start
import TasksGenerator from '@brinda_yawa/tasks-generator';
// Initialize the singleton instance
const generator = TasksGenerator;
generator.init({ apiKey: 'YOUR_API_KEY', model: 'gemini-2.5-flash' });
// Generate tasks from a title and description
const tasks = await generator.generateTasks(
'Flat Tire',
'Roadside assistance following a flat tire. Diagnose the affected wheel, check tire condition, repair with plug or replace if necessary, check pressure and balance the wheel.'
);
console.log(tasks);📖 API Reference
TasksGenerator.init(options)
Initializes the singleton instance with your API credentials.
Parameters:
options.apiKey(string, required) — Your Google Gemini API keyoptions.model(string, optional) — The Gemini model to use. Default:'gemini-2.5-flash'
Example:
import TasksGenerator from '@brinda_yawa/tasks-generator';
const generator = TasksGenerator;
generator.init({
apiKey: process.env.GEMINI_API_KEY,
model: 'gemini-2.5-flash'
});generator.generateTasks(title, description)
Generates a structured list of tasks from a title and description.
Parameters:
title(string, required) — The title of the project or interventiondescription(string, required) — A detailed description of what needs to be done
Returns: Promise<Array<Object>> — An array of structured task objects
Example:
const tasks = await generator.generateTasks(
'Flat Tire',
'Roadside assistance following a flat tire. Diagnose the affected wheel, check tire condition, repair with plug or replace if necessary, check pressure and balance the wheel.'
);
// Returns:
[
{
"title": "Diagnose affected wheel",
"description": "Inspect the flat tire to identify the cause of deflation",
"priority": "high"
},
{
"title": "Assess tire condition",
"description": "Determine whether the tire can be repaired or needs replacing",
"priority": "high"
},
{
"title": "Repair or replace tire",
"description": "Apply plug repair or mount a replacement tire as needed",
"priority": "high"
},
{
"title": "Check pressure and balance",
"description": "Verify correct inflation pressure and wheel balance after intervention",
"priority": "medium"
}
// ... more tasks
]🌍 Environment Variables
Create a .env file at the root of your project:
GEMINI_API_KEY=your_api_key_hereRecommendation: Use gemini-2.5-flash for both development and production for the best speed/quality balance.
💡 Advanced Usage
Handling Multiple Projects
import TasksGenerator from '@brinda_yawa/tasks-generator';
import dotenv from 'dotenv';
dotenv.config();
const generator = TasksGenerator;
generator.init({ apiKey: process.env.GEMINI_API_KEY });
const projects = [
{
title: 'Flat Tire',
description: 'Roadside assistance for a flat tire. Inspect, repair or replace, and verify pressure.'
},
{
title: 'Battery Replacement',
description: 'Replace a dead car battery. Diagnose charge level, disconnect old battery, install new one, test electrical system.'
}
];
async function generateAllTasks(projects) {
const results = [];
for (const project of projects) {
const tasks = await generator.generateTasks(project.title, project.description);
if (tasks) {
results.push({ project: project.title, tasks });
}
}
return results;
}
const allTasks = await generateAllTasks(projects);
console.log(`Generated tasks for ${allTasks.length} projects`);Error Handling
import TasksGenerator from '@brinda_yawa/tasks-generator';
const generator = TasksGenerator;
generator.init({ apiKey: process.env.GEMINI_API_KEY });
try {
const tasks = await generator.generateTasks(
'Oil Change',
'Standard vehicle oil change: drain old oil, replace filter, fill with new oil, check levels.'
);
if (!tasks || tasks.length === 0) {
console.error('No tasks were generated.');
} else {
console.log('Tasks generated successfully:', tasks);
}
} catch (error) {
if (error.message.includes('quota')) {
console.error('API quota exceeded. Please wait or upgrade your plan.');
} else if (error.message.includes('API key')) {
console.error('Invalid API key. Please check your credentials.');
} else if (error.message.includes('obligatoires')) {
console.error('Title and description are required fields.');
} else {
console.error('Generation error:', error.message);
}
}Using with Express.js
import express from 'express';
import TasksGenerator from '@brinda_yawa/tasks-generator';
const app = express();
app.use(express.json());
const generator = TasksGenerator;
generator.init({ apiKey: process.env.GEMINI_API_KEY });
app.post('/generate-tasks', async (req, res) => {
try {
const { title, description } = req.body;
if (!title || !description) {
return res.status(400).json({ error: 'Title and description are required.' });
}
const tasks = await generator.generateTasks(title, description);
if (!tasks) {
return res.status(500).json({ error: 'Task generation failed.' });
}
res.json({ success: true, tasks });
} catch (error) {
res.status(500).json({ error: error.message });
}
});
app.listen(3000, () => console.log('Server running on port 3000'));