job51-gitlab-cr-node-jt-1 2.1.4 → 2.1.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.js +3 -10
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -119,7 +119,7 @@ class GitLabCodeReviewer {
|
|
|
119
119
|
const processBlock = async (diffObject, blockIndex) => {
|
|
120
120
|
// 创建临时文件存储diff内容,文件地址选择当前文件夹下,避免权限问题
|
|
121
121
|
const fileName = `temp-diff-block-${Date.now()}-${blockIndex}.diff`;
|
|
122
|
-
const tmpFileName = path.join(
|
|
122
|
+
const tmpFileName = path.join(process.cwd(), fileName);
|
|
123
123
|
|
|
124
124
|
try {
|
|
125
125
|
// 构造包含元数据的 diff 内容
|
|
@@ -137,13 +137,6 @@ ${diffObject.diff}`;
|
|
|
137
137
|
const review_result = await this.reviewDiffWithClaudeUsingFile(tmpFileName);
|
|
138
138
|
const blockObj = { ...diffObject, review_result, temp_file_path: tmpFileName };
|
|
139
139
|
|
|
140
|
-
// 立即发布评论
|
|
141
|
-
debugLog(`🤖 AI 代码审查结果: ${blockObj.review_result}`);
|
|
142
|
-
await this.postSingleCommentToGitLab(projectId, mergeRequestIid, {
|
|
143
|
-
diff_info: blockObj,
|
|
144
|
-
block_index: blockObj.block_index,
|
|
145
|
-
review_result: blockObj.review_result,
|
|
146
|
-
});
|
|
147
140
|
// 检查审查结果中是否包含严重问题,只有包含严重问题才发布评论
|
|
148
141
|
if (blockObj.review_result && blockObj.review_result.includes('🔴 严重问题')) {
|
|
149
142
|
// 立即发布评论
|
|
@@ -542,8 +535,8 @@ async function main() {
|
|
|
542
535
|
function runClaudeCommand(promptContent) {
|
|
543
536
|
return new Promise((resolve, reject) => {
|
|
544
537
|
|
|
545
|
-
//
|
|
546
|
-
const projectDir = process.
|
|
538
|
+
// 使用当前工作目录,确保 Claude 能访问临时文件和项目代码
|
|
539
|
+
const projectDir = process.cwd();
|
|
547
540
|
debugLog("AI review命令开始时间, 工作目录:" + projectDir);
|
|
548
541
|
|
|
549
542
|
// 使用spawn替代exec,更安全地处理命令执行并实现环境隔离
|