plugin-git-manager 1.2.10 → 1.2.12
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/dist/server/actions/review.js +41 -12
- package/package.json +1 -1
- package/src/server/actions/review.ts +1263 -1221
|
@@ -589,7 +589,7 @@ async function reviewReject(ctx, next) {
|
|
|
589
589
|
await next();
|
|
590
590
|
}
|
|
591
591
|
async function runReview(app, args) {
|
|
592
|
-
var _a, _b, _c, _d;
|
|
592
|
+
var _a, _b, _c, _d, _e, _f;
|
|
593
593
|
const db = app.db;
|
|
594
594
|
const reviewsRepo = db.getRepository("gitCodeReviews");
|
|
595
595
|
const startedAt = /* @__PURE__ */ new Date();
|
|
@@ -622,13 +622,22 @@ async function runReview(app, args) {
|
|
|
622
622
|
values: { sessionId }
|
|
623
623
|
});
|
|
624
624
|
const prompt = buildReviewPrompt(args);
|
|
625
|
+
const currentRoles = await resolveBackgroundReviewRoles(db, args.userId);
|
|
626
|
+
const currentUser = args.userId ? {
|
|
627
|
+
id: args.userId,
|
|
628
|
+
roles: currentRoles.map((name) => ({ name }))
|
|
629
|
+
} : null;
|
|
625
630
|
const syntheticCtx = {
|
|
626
631
|
app,
|
|
627
632
|
db,
|
|
628
633
|
isBackgroundReview: true,
|
|
629
634
|
reviewTargetRepositoryId: args.repo.get("id"),
|
|
630
|
-
state: {
|
|
631
|
-
|
|
635
|
+
state: {
|
|
636
|
+
currentUser,
|
|
637
|
+
currentRole: currentRoles[0],
|
|
638
|
+
currentRoles
|
|
639
|
+
},
|
|
640
|
+
auth: { user: currentUser || { id: null } },
|
|
632
641
|
req: { headers: { "x-timezone": "+00:00", "x-locale": "en-US" } },
|
|
633
642
|
// AIEmployee.getSystemPrompt reads ctx.action.params.values.important
|
|
634
643
|
action: { params: { values: {} } },
|
|
@@ -678,16 +687,16 @@ async function runReview(app, args) {
|
|
|
678
687
|
const llmService = args.flow.get("llmService");
|
|
679
688
|
const model = args.flow.get("model");
|
|
680
689
|
const modelRef = llmService && model ? { llmService, model } : void 0;
|
|
681
|
-
const aiEmployee = new AIEmployee(
|
|
682
|
-
syntheticCtx,
|
|
683
|
-
employeeRecord,
|
|
690
|
+
const aiEmployee = new AIEmployee({
|
|
691
|
+
ctx: syntheticCtx,
|
|
692
|
+
employee: employeeRecord,
|
|
684
693
|
sessionId,
|
|
685
|
-
void 0,
|
|
686
|
-
void 0,
|
|
687
|
-
false,
|
|
688
|
-
modelRef,
|
|
689
|
-
false
|
|
690
|
-
);
|
|
694
|
+
systemMessage: void 0,
|
|
695
|
+
skillSettings: void 0,
|
|
696
|
+
webSearch: false,
|
|
697
|
+
model: modelRef,
|
|
698
|
+
legacy: false
|
|
699
|
+
});
|
|
691
700
|
const REVIEW_TIMEOUT_MS = 5 * 60 * 1e3;
|
|
692
701
|
const result = await Promise.race([
|
|
693
702
|
aiEmployee.invoke({
|
|
@@ -755,6 +764,7 @@ async function runReview(app, args) {
|
|
|
755
764
|
} catch (err) {
|
|
756
765
|
const finishedAt = /* @__PURE__ */ new Date();
|
|
757
766
|
const safeMessage = (0, import_redact.redactPat)((err == null ? void 0 : err.message) || String(err));
|
|
767
|
+
(_f = (_e = app.log) == null ? void 0 : _e.error) == null ? void 0 : _f.call(_e, `git review ${args.reviewId} failed: ${safeMessage}`, err);
|
|
758
768
|
await reviewsRepo.update({
|
|
759
769
|
filterByTk: args.reviewId,
|
|
760
770
|
values: {
|
|
@@ -769,6 +779,25 @@ async function runReview(app, args) {
|
|
|
769
779
|
}
|
|
770
780
|
}
|
|
771
781
|
}
|
|
782
|
+
async function resolveBackgroundReviewRoles(db, userId) {
|
|
783
|
+
if (!userId) return ["admin"];
|
|
784
|
+
try {
|
|
785
|
+
const roles = await db.getRepository("users.roles", userId).find({ raw: true });
|
|
786
|
+
const roleNames = (Array.isArray(roles) ? roles : []).map((role) => role == null ? void 0 : role.name).filter((name) => typeof name === "string" && !!name);
|
|
787
|
+
if (roleNames.length) return roleNames;
|
|
788
|
+
} catch {
|
|
789
|
+
}
|
|
790
|
+
try {
|
|
791
|
+
const mappings = await db.getRepository("rolesUsers").find({
|
|
792
|
+
filter: { userId },
|
|
793
|
+
raw: true
|
|
794
|
+
});
|
|
795
|
+
const roleNames = (Array.isArray(mappings) ? mappings : []).map((mapping) => mapping == null ? void 0 : mapping.roleName).filter((name) => typeof name === "string" && !!name);
|
|
796
|
+
if (roleNames.length) return roleNames;
|
|
797
|
+
} catch {
|
|
798
|
+
}
|
|
799
|
+
return ["admin"];
|
|
800
|
+
}
|
|
772
801
|
function buildReviewPrompt(args) {
|
|
773
802
|
const lines = [];
|
|
774
803
|
lines.push(`You are performing a code review on repository "${args.repo.get("name")}" (id=${args.repo.get("id")}).`);
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"displayName": "Git Manager",
|
|
4
4
|
"displayName.zh-CN": "Git 管理器",
|
|
5
5
|
"description": "Manage Git repositories with PAT authentication - pull, push, fetch, diff, file browsing",
|
|
6
|
-
"version": "1.2.
|
|
6
|
+
"version": "1.2.12",
|
|
7
7
|
"license": "Apache-2.0",
|
|
8
8
|
"main": "dist/server/index.js",
|
|
9
9
|
"files": [
|