This commit is contained in:
2026-03-11 15:38:59 +08:00
parent 8379be1630
commit fc6a5bd73c
5 changed files with 482 additions and 295 deletions

View File

@@ -1,3 +1,38 @@
import { app } from './index.ts';
import { getN } from '../src/index.ts'
import { useIssueEnv, useCommentEnv, useRepoInfoEnv } from '../src/index.ts'
import { pick } from 'es-toolkit';
const main = async () => {
const repoInfoEnv = useRepoInfoEnv();
const commentEnv = useCommentEnv();
const issueEnv = useIssueEnv();
const pickCommentEnv = pick(commentEnv, ['commentId', 'commentIdLabel']);
const pickIssueEnv = pick(issueEnv, ['issueId', 'issueIdLabel', 'issueIid', 'issueIidLabel', 'issueTitle', 'issueTitleLabel', 'issueDescription', 'issueDescriptionLabel']);
const pickRepoInfoEnv = pick(repoInfoEnv, ['repoId', 'repoIdLabel', 'repoName', 'repoNameLabel', 'repoSlug', 'repoSlugLabel']);
const messages = [
{
role: 'system',
content: `你是一个智能的代码助手, 根据用户提供的上下文信息提供有用的建议和帮助。并把最后的结果提交一个评论到对应的issue中。用户提供的上下文信息如下`
},
{
role: 'system',
content: `相关变量:${JSON.stringify({ ...pickCommentEnv, ...pickIssueEnv, ...pickRepoInfoEnv })}`
}, {
role: 'user',
content: commentEnv.commentBody || pickIssueEnv.issueDescription || '无'
}
]
const result = await app.run({
path: 'cnb',
key: 'chat',
payload: {
messages
}
})
if (result.code === 200) {
console.log('执行完成')
}
}
main();