simplify tool contribution

This commit is contained in:
overcuriousity
2025-07-25 22:52:21 +02:00
parent d80a4d85eb
commit 6892aaf7de
4 changed files with 875 additions and 1302 deletions

View File

@@ -115,17 +115,6 @@ async function validateToolData(tool: any, action: string): Promise<{ valid: boo
}
}
// Validate related concepts exist
if (tool.related_concepts && tool.related_concepts.length > 0) {
const existingConcepts = new Set(
existingData.tools.filter((t: any) => t.type === 'concept').map((t: any) => t.name)
);
const invalidConcepts = tool.related_concepts.filter((c: string) => !existingConcepts.has(c));
if (invalidConcepts.length > 0) {
errors.push(`Referenced concepts not found: ${invalidConcepts.join(', ')}`);
}
}
return { valid: errors.length === 0, errors };
} catch (error) {
@@ -199,23 +188,21 @@ export const POST: APIRoute = async ({ request }) => {
// CRITICAL FIX: Enhanced error handling for Git operations
try {
// Submit contribution via Git (now creates issue instead of PR)
const gitManager = new GitContributionManager();
const result = await gitManager.submitContribution(contributionData);
if (result.success) {
// Log successful contribution
console.log(`[CONTRIBUTION SUCCESS] ${validatedData.action} "${validatedData.tool.name}" by ${userEmail} - PR: ${result.prUrl}`);
console.log(`[CONTRIBUTION] Issue created for "${validatedData.tool.name}" by ${userEmail} - Issue: ${result.issueUrl}`);
// ENSURE proper success response
return apiResponse.created({
success: true,
message: result.message,
prUrl: result.prUrl,
branchName: result.branchName
issueUrl: result.issueUrl,
issueNumber: result.issueNumber
});
} else {
// Log failed contribution
console.error(`[CONTRIBUTION FAILED] ${validatedData.action} "${validatedData.tool.name}" by ${userEmail}: ${result.message}`);
console.error(`[CONTRIBUTION FAILED] "${validatedData.tool.name}" by ${userEmail}: ${result.message}`);
return apiServerError.internal(`Contribution failed: ${result.message}`);
}