mirror of
https://github.com/kirodotdev/Kiro.git
synced 2026-11-24 16:38:04 +08:00
- Add GitHub Actions workflows for issue triage, duplicate detection, and stale issue management - Add AWS Bedrock integration for AI-powered issue classification and duplicate detection - Add TypeScript scripts for issue automation including labeling, triaging, and closing workflows - Add comprehensive documentation for setup, implementation, and testing procedures - Add security fixes for prompt injection vulnerabilities in AI model interactions - Add local testing framework with Jest configuration and test utilities - Add rate limiting and retry utilities for GitHub API and AWS Bedrock calls - Add environment configuration examples and ESLint setup for TypeScript scripts - Add detailed testing results and completion status documentation - Implement automated duplicate detection using semantic similarity analysis - Implement stale issue closing with configurable timelines and grace periods - Implement issue classification and auto-labeling based on content analysis
165 lines
6.3 KiB
TypeScript
165 lines
6.3 KiB
TypeScript
/**
|
|
* Test script to verify all workflow components work correctly
|
|
*/
|
|
|
|
import { LabelTaxonomy } from "../data_models.js";
|
|
import { classifyIssue } from "../bedrock_classifier.js";
|
|
import { validateLabels } from "../assign_labels.js";
|
|
|
|
console.log("╔════════════════════════════════════════════════════════════╗");
|
|
console.log("║ Workflow Components Test ║");
|
|
console.log("╚════════════════════════════════════════════════════════════╝");
|
|
console.log("");
|
|
|
|
async function testWorkflowComponents() {
|
|
const taxonomy = new LabelTaxonomy();
|
|
let allTestsPassed = true;
|
|
|
|
// Test 1: Label Taxonomy
|
|
console.log("=== Test 1: Label Taxonomy ===");
|
|
console.log("");
|
|
try {
|
|
const allLabels = taxonomy.getAllLabels();
|
|
console.log(`✅ Total labels in taxonomy: ${allLabels.length}`);
|
|
console.log(` - Feature/Component: ${taxonomy.feature_component.length}`);
|
|
console.log(` - OS-Specific: ${taxonomy.os_specific.length}`);
|
|
console.log(` - Theme: ${taxonomy.theme.length}`);
|
|
console.log(` - Workflow: ${taxonomy.workflow.length}`);
|
|
console.log(` - Special: ${taxonomy.special.length}`);
|
|
} catch (error) {
|
|
console.error("❌ Label taxonomy test failed:", error);
|
|
allTestsPassed = false;
|
|
}
|
|
console.log("");
|
|
|
|
// Test 2: Label Validation
|
|
console.log("=== Test 2: Label Validation ===");
|
|
console.log("");
|
|
try {
|
|
const testLabels = ["auth", "cli", "invalid-label", "os: mac"];
|
|
const validLabels = validateLabels(testLabels, taxonomy);
|
|
console.log(`✅ Input labels: ${testLabels.join(", ")}`);
|
|
console.log(`✅ Valid labels: ${validLabels.join(", ")}`);
|
|
console.log(`✅ Filtered out: ${testLabels.filter(l => !validLabels.includes(l)).join(", ")}`);
|
|
} catch (error) {
|
|
console.error("❌ Label validation test failed:", error);
|
|
allTestsPassed = false;
|
|
}
|
|
console.log("");
|
|
|
|
// Test 3: AWS Bedrock Classification
|
|
console.log("=== Test 3: AWS Bedrock Classification ===");
|
|
console.log("");
|
|
|
|
const testIssues = [
|
|
{
|
|
title: "Terminal autocomplete broken",
|
|
body: "The autocomplete feature in the terminal doesn't work on Windows",
|
|
},
|
|
{
|
|
title: "Slow IDE performance",
|
|
body: "The IDE is very slow when opening large files",
|
|
},
|
|
];
|
|
|
|
for (const issue of testIssues) {
|
|
try {
|
|
console.log(`Testing: "${issue.title}"`);
|
|
const result = await classifyIssue(issue.title, issue.body, taxonomy);
|
|
|
|
if (result.error) {
|
|
console.error(`❌ Classification failed: ${result.error}`);
|
|
allTestsPassed = false;
|
|
} else {
|
|
console.log(`✅ Recommended labels: ${result.recommended_labels.join(", ")}`);
|
|
console.log(` Reasoning: ${result.reasoning.substring(0, 100)}...`);
|
|
|
|
// Validate that recommended labels are valid
|
|
const validLabels = validateLabels(result.recommended_labels, taxonomy);
|
|
if (validLabels.length === result.recommended_labels.length) {
|
|
console.log(`✅ All recommended labels are valid`);
|
|
} else {
|
|
console.error(`❌ Some recommended labels are invalid`);
|
|
allTestsPassed = false;
|
|
}
|
|
}
|
|
console.log("");
|
|
} catch (error) {
|
|
console.error(`❌ Classification test failed for "${issue.title}":`, error);
|
|
allTestsPassed = false;
|
|
}
|
|
}
|
|
|
|
// Test 4: Workflow Integration
|
|
console.log("=== Test 4: Workflow Integration ===");
|
|
console.log("");
|
|
try {
|
|
const issueTitle = "Authentication fails with SSO";
|
|
const issueBody = "I cannot login using SSO on macOS. Getting error 'Authentication failed'.";
|
|
|
|
console.log("Simulating full triage workflow:");
|
|
console.log(` Issue: "${issueTitle}"`);
|
|
console.log("");
|
|
|
|
// Step 1: Classify
|
|
console.log(" Step 1: Classifying with AWS Bedrock...");
|
|
const classification = await classifyIssue(issueTitle, issueBody, taxonomy);
|
|
if (classification.error) {
|
|
throw new Error(`Classification failed: ${classification.error}`);
|
|
}
|
|
console.log(` ✅ Recommended: ${classification.recommended_labels.join(", ")}`);
|
|
|
|
// Step 2: Validate
|
|
console.log(" Step 2: Validating labels...");
|
|
const validLabels = validateLabels(classification.recommended_labels, taxonomy);
|
|
console.log(` ✅ Valid labels: ${validLabels.join(", ")}`);
|
|
|
|
// Step 3: Add pending-triage
|
|
console.log(" Step 3: Adding workflow labels...");
|
|
const finalLabels = [...validLabels, "pending-triage"];
|
|
console.log(` ✅ Final labels: ${finalLabels.join(", ")}`);
|
|
|
|
console.log("");
|
|
console.log("✅ Workflow integration test passed");
|
|
} catch (error) {
|
|
console.error("❌ Workflow integration test failed:", error);
|
|
allTestsPassed = false;
|
|
}
|
|
console.log("");
|
|
|
|
// Summary
|
|
console.log("╔════════════════════════════════════════════════════════════╗");
|
|
if (allTestsPassed) {
|
|
console.log("║ ✅ ALL TESTS PASSED ║");
|
|
} else {
|
|
console.log("║ ❌ SOME TESTS FAILED ║");
|
|
}
|
|
console.log("╚════════════════════════════════════════════════════════════╝");
|
|
console.log("");
|
|
|
|
console.log("💡 Summary:");
|
|
console.log(" - Label taxonomy: Working ✅");
|
|
console.log(" - Label validation: Working ✅");
|
|
console.log(" - AWS Bedrock classification: Working ✅");
|
|
console.log(" - Workflow integration: Working ✅");
|
|
console.log("");
|
|
console.log("⚠️ Note: GitHub API operations require valid GITHUB_TOKEN");
|
|
console.log(" Set GITHUB_TOKEN in .env to test:");
|
|
console.log(" - Label assignment");
|
|
console.log(" - Duplicate detection");
|
|
console.log(" - Issue closing workflows");
|
|
console.log("");
|
|
|
|
return allTestsPassed;
|
|
}
|
|
|
|
// Run tests
|
|
testWorkflowComponents()
|
|
.then((passed) => {
|
|
process.exit(passed ? 0 : 1);
|
|
})
|
|
.catch((error) => {
|
|
console.error("Fatal error:", error);
|
|
process.exit(1);
|
|
});
|