Fixed misc bugs
All checks were successful
Publish Library / Build NPM Project (push) Successful in 4s
Publish Library / Tag Version (push) Successful in 13s
Code review / review (pull_request) Successful in 1m0s

This commit is contained in:
2025-12-30 14:15:40 -05:00
parent 6bb78d0862
commit 1f48b5a872
3 changed files with 11 additions and 7 deletions

View File

@@ -11,7 +11,7 @@ dotenv.config({path: '.env.local', override: true, quiet: true});
(async () => {
let p = process.argv[process.argv.length - 1];
if(p === 'review' || p.endsWith('review.mjs')) p = null;
if(p === 'refine' || p.endsWith('refine.mjs')) p = null;
if(!/(\/|[A-Z]:)/.test(p)) p = path.join(process.cwd(), p);
if(!p || !fs.existsSync(p)) throw new Error('Please provide a template');
@@ -81,10 +81,14 @@ ${template.trim()}
\`\`\`
Output ONLY the formatted ticket, no explanation.`
});
})
const messages = await ai.language.ask(`Title: ${issueData.title}\n\nDescription:\n${issueData.body || 'No description provided'}`);
const content = messages.pop().content;
const messages = await ai.language.ask(`Title: ${issueData.title}\n\nDescription:\n${issueData.body || 'No description provided'}`).catch(() => []);;
const content = messages?.pop()?.content;
if(!content) {
console.log('Invalid response from AI');
return process.exit(1);
}
const title = /^# (.+)$/m.exec(content)?.[1] || issueData.title;
const typeMatch = /^## Type:\s*(.+)$/m.exec(content);
const type = typeMatch?.[1]?.split('/')[0]?.trim() || 'Unassigned';
@@ -98,7 +102,7 @@ Output ONLY the formatted ticket, no explanation.`
body: JSON.stringify({
title,
body,
labels: [`Type/${type[0].toUpperCase() + type.slice(1).toLowerCase()}`]
labels: type?.length ? [`Kind/${type[0].toUpperCase() + type.slice(1).toLowerCase()}`] : []
})
});
if(!updateRes.ok) throw new Error(`${updateRes.status} ${await updateRes.text()}`);