generated from ztimson/template
Fixed misc bugs
This commit is contained in:
@@ -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()}`);
|
||||
|
||||
Reference in New Issue
Block a user