hataraku
Version:
An autonomous coding agent for building AI-powered development tools. The name "Hataraku" (働く) means "to work" in Japanese.
139 lines (128 loc) • 4.79 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.createCodeAnalysisTask = createCodeAnalysisTask;
exports.createBugAnalysisTask = createBugAnalysisTask;
exports.createPRReviewTask = createPRReviewTask;
exports.createRefactoringPlanTask = createRefactoringPlanTask;
const zod_1 = require("zod");
const task_1 = require("../task");
// Schema definitions
const codeAnalysisSchema = zod_1.z.object({
summary: zod_1.z.string(),
complexity: zod_1.z.number().min(1).max(10),
suggestions: zod_1.z.array(zod_1.z.string()),
risks: zod_1.z.array(zod_1.z.string())
});
const bugAnalysisSchema = zod_1.z.object({
rootCause: zod_1.z.string(),
severity: zod_1.z.enum(['low', 'medium', 'high', 'critical']),
suggestedFix: zod_1.z.string(),
preventionTips: zod_1.z.array(zod_1.z.string())
});
const prReviewSchema = zod_1.z.object({
summary: zod_1.z.string(),
changes: zod_1.z.array(zod_1.z.object({
file: zod_1.z.string(),
impact: zod_1.z.string(),
suggestions: zod_1.z.array(zod_1.z.string())
})),
overallImpact: zod_1.z.string(),
testingSuggestions: zod_1.z.array(zod_1.z.string())
});
const refactoringPlanSchema = zod_1.z.object({
goals: zod_1.z.array(zod_1.z.string()),
steps: zod_1.z.array(zod_1.z.object({
description: zod_1.z.string(),
effort: zod_1.z.enum(['small', 'medium', 'large']),
risks: zod_1.z.array(zod_1.z.string())
})),
testingStrategy: zod_1.z.string()
});
// Task factory functions
function createCodeAnalysisTask(agent) {
return (0, task_1.createTask)({
name: 'Analyze Code',
description: 'Analyze code for complexity, potential issues, and improvement suggestions',
agent,
outputSchema: codeAnalysisSchema,
task: (input) => `
Analyze the following code and provide detailed feedback:
${input}
Focus on:
1. Code complexity and maintainability
2. Potential issues or risks
3. Suggestions for improvement
4. Best practices adherence
Provide a structured analysis with specific, actionable feedback.
`
});
}
function createBugAnalysisTask(agent) {
return (0, task_1.createTask)({
name: 'Debug Issue',
description: 'Analyze bug reports and provide root cause analysis with fix suggestions',
agent,
outputSchema: bugAnalysisSchema,
task: (input) => `
Analyze the following bug report and provide a detailed analysis:
Description:
${input}
Provide:
1. Root cause analysis
2. Severity assessment
3. Suggested fix with code examples if applicable
4. Prevention tips for similar issues
`
});
}
function createPRReviewTask(agent) {
return (0, task_1.createTask)({
name: 'Review Pull Request',
description: 'Review code changes and provide structured feedback',
agent,
outputSchema: prReviewSchema,
task: (input) => `
Review the following pull request and provide detailed feedback:
PR Description:
${input}
Provide a thorough review focusing on:
1. Code quality and best practices
2. Potential issues or risks
3. Test coverage
4. Performance implications
5. Security considerations
Structure your review to be constructive and actionable.
`
});
}
function createRefactoringPlanTask(agent) {
return (0, task_1.createTask)({
name: 'Plan Refactoring',
description: 'Create a structured plan for code refactoring',
agent,
outputSchema: refactoringPlanSchema,
task: (input) => `
Create a refactoring plan for the following code:
Code:
${input}
Provide a detailed plan including:
1. Clear, achievable steps
2. Effort estimation for each step
3. Potential risks and mitigation strategies
4. Testing approach
Focus on maintaining functionality while improving code quality.
`
});
}
// Additional task types that could be implemented:
// - Documentation Generator
// - Test Case Generator
// - Performance Optimization Advisor
// - Security Audit
// - Dependency Analysis
// - API Documentation Review
// - Code Style Enforcement
// - Database Query Optimization
// - Infrastructure as Code Review
// - Accessibility Compliance Check
//# sourceMappingURL=index.js.map