import { z } from "zod";
/**
* Product Tools - Requirements gathering, user analysis, and product definition
*/
// ============================================
// Define User Stories
// ============================================
export const defineUserStoriesSchema = {
name: "define_user_stories",
description: "Generates user stories with acceptance criteria (Gherkin format)",
inputSchema: z.object({
feature: z.string().describe("Feature description"),
role: z.string().optional().default("user").describe("User role"),
format: z.enum(["simple", "gherkin", "detailed"]).optional().default("simple")
})
};
export function defineUserStoriesHandler(args: { feature: string; role: string; format: string }) {
const { feature, role, format } = args;
const story = `As a ${role}, I want to ${feature}, so that [value/benefit].`;
let content = "";
if (format === "gherkin") {
content = `Feature: ${feature}\n\n Scenario: Successful usage\n Given I am a logged in ${role}\n When I ${feature}\n Then I should see [result]`;
} else if (format === "detailed") {
content = `### User Story\n${story}\n\n### Acceptance Criteria\n- [ ] Verify happy path\n- [ ] Verify error states\n- [ ] Check performance`;
} else {
content = story;
}
return {
content: [{
type: "text",
text: `# User Story: ${feature}\n\n${content}`
}]
};
}
// ============================================
// Create Personas
// ============================================
export const createPersonasSchema = {
name: "create_personas",
description: "Generates detailed user personas for the project",
inputSchema: z.object({
appType: z.string().describe("Type of application (e.g. 'Fitness App', 'Dev Tool')"),
targetAudience: z.array(z.string()).describe("Target audience segments")
})
};
export function createPersonasHandler(args: { appType: string; targetAudience: string[] }) {
const { appType, targetAudience } = args;
return {
content: [{
type: "text",
text: `# User Personas for ${appType}\n\n${targetAudience.map((audience, i) => `## Persona ${i + 1}: ${audience} User\n- **Goals**: [Goal 1], [Goal 2]\n- **Frustrations**: [Pain point 1]\n- **Tech Savviness**: [Low/Med/High]\n- **Scenario**: Needs to use ${appType} to...`).join('\n\n')}`
}]
};
}
// ============================================
// Market Analysis (SWOT)
// ============================================
export const marketAnalysisSchema = {
name: "perform_market_analysis",
description: "Generates a SWOT analysis template for a product idea",
inputSchema: z.object({
idea: z.string().describe("Product idea or feature"),
competitors: z.array(z.string()).optional()
})
};
export function marketAnalysisHandler(args: { idea: string; competitors?: string[] }) {
return {
content: [{
type: "text",
text: `# Market Analysis (SWOT): ${args.idea}\n\n| Strengths | Weaknesses |\n|-----------|------------|\n| - [Internal strength] | - [Internal weakness] |\n\n| Opportunities | Threats |\n|---------------|---------|\n| - [Market gap] | - [Competitor movement] |\n\n**Competitors**: ${args.competitors ? args.competitors.join(", ") : "None specified"}`
}]
};
}
// Export all
export const productTools = {
defineUserStoriesSchema, defineUserStoriesHandler,
createPersonasSchema, createPersonasHandler,
marketAnalysisSchema, marketAnalysisHandler
};