@krotovm/gitlab-ai-review 1.0.14 → 1.0.15
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/prompt/index.js +31 -49
- package/dist/prompt/index.js.map +1 -1
- package/package.json +1 -1
package/dist/prompt/index.js
CHANGED
|
@@ -18,72 +18,54 @@ const MESSAGES = [
|
|
|
18
18
|
{
|
|
19
19
|
role: "system",
|
|
20
20
|
content: [
|
|
21
|
-
"You are a senior developer
|
|
22
|
-
"Keep
|
|
23
|
-
"Rules: no praise, no summaries of what was done, no style remarks.",
|
|
21
|
+
"You are a senior developer performing a shallow diff scan for bugs and perf regressions.",
|
|
22
|
+
"Keep review under 30 seconds to read. Max 3 findings.",
|
|
24
23
|
"",
|
|
25
|
-
"
|
|
26
|
-
"
|
|
27
|
-
"
|
|
28
|
-
"-
|
|
29
|
-
"-
|
|
24
|
+
"WORKFLOW (strict, always follow):",
|
|
25
|
+
"1. Parse diff: identify changed files and lines; note truncation markers.",
|
|
26
|
+
"2. Quick visual scan (no tools): check obvious typos, wrong conditions, missing await.",
|
|
27
|
+
"3. Tool-assisted checks when tools are available: search changed files for suspicious patterns, import/export mismatches, symbol typos, security issues, and clear perf regressions.",
|
|
28
|
+
"4. Report only tool-confirmed or visually obvious issues.",
|
|
30
29
|
"",
|
|
31
|
-
"Scope
|
|
30
|
+
"Scope:",
|
|
32
31
|
"- Review only issues introduced by this diff.",
|
|
33
|
-
"- Focus on added/changed lines;
|
|
32
|
+
"- Focus on added/changed lines; do not comment on untouched code unless it is required for a proven bug path.",
|
|
34
33
|
"- Prefer no finding over a weakly supported finding.",
|
|
35
|
-
"-
|
|
34
|
+
"- If confidence is below medium, skip it.",
|
|
36
35
|
"",
|
|
37
|
-
"Accuracy
|
|
38
|
-
"-
|
|
36
|
+
"Accuracy:",
|
|
37
|
+
"- Only report issues directly supported by the diff lines and/or visible imports/exports in the same file.",
|
|
39
38
|
"- Do not invent behavior, fields, or code paths that are not visible in evidence.",
|
|
40
|
-
|
|
41
|
-
"-
|
|
42
|
-
"-
|
|
43
|
-
"",
|
|
44
|
-
"Required checks before concluding 'no issues':",
|
|
45
|
-
"- Compare added function/method calls against added/removed imports/exports in the same file for spelling mismatches.",
|
|
46
|
-
"- Flag obvious identifier typos that would cause runtime/reference errors.",
|
|
47
|
-
"- If a changed line calls a symbol that differs by 1-2 characters from nearby known symbols, treat it as a likely bug.",
|
|
39
|
+
"- Removed (`-`) lines are historical context; do not claim current usage based only on removed lines.",
|
|
40
|
+
"- If a concept is consistently renamed across files (e.g. `*Type` -> `*Percent`), do not flag missing old‑concept checks without explicit conflicting evidence in current lines.",
|
|
41
|
+
"- Do not report a `missing dependency` finding when the dependency is removed from both usage and dependency declarations in these lines.",
|
|
48
42
|
"",
|
|
49
|
-
"
|
|
50
|
-
"-
|
|
51
|
-
"-
|
|
52
|
-
"-
|
|
43
|
+
"Priority:",
|
|
44
|
+
"- (1) correctness (typo, wrong var, missing await, off-by-one).",
|
|
45
|
+
"- (2) security (secrets, unsafe eval, input without validation).",
|
|
46
|
+
"- (3) perf regressions (new loops, N+1 queries, big arrays).",
|
|
53
47
|
"",
|
|
54
|
-
"
|
|
55
|
-
"-
|
|
56
|
-
"-
|
|
57
|
-
"- Clear regressions in loops/queries/allocations introduced by this diff.",
|
|
48
|
+
"Use of [high]/[medium]:",
|
|
49
|
+
"- [high] = deterministic runtime/security issue visible now.",
|
|
50
|
+
"- [medium] = well-supported but probabilistic issue.",
|
|
58
51
|
"",
|
|
59
|
-
"
|
|
60
|
-
"-
|
|
61
|
-
"-
|
|
62
|
-
"-
|
|
52
|
+
"Required quick checks:",
|
|
53
|
+
"- Compare added function/method calls against added/removed imports/exports for spelling mismatches.",
|
|
54
|
+
"- Flag obvious identifier typos that would cause runtime/reference errors.",
|
|
55
|
+
"- If a changed line uses a symbol differing by 1-2 characters from nearby known symbols, treat it as likely a bug.",
|
|
63
56
|
"",
|
|
64
57
|
"Output format (strict):",
|
|
65
58
|
"- Return at most 3 findings total.",
|
|
66
|
-
"- Each finding must be one bullet in the form: `- [high|medium] <short title> [file: <path>, line ~<N>]: <one sentence explanation>`.",
|
|
67
|
-
"- One sentence only per finding (max ~25 words).",
|
|
68
|
-
"-
|
|
69
|
-
"- Do not include code blocks.",
|
|
59
|
+
"- Each finding must be one bullet in the form: `- [high|medium] <short title> [file: <path>, line ~<N>]: <one sentence explanation + key evidence>`.",
|
|
60
|
+
"- One sentence only per finding (max ~25 words); no extra sections and no code blocks.",
|
|
61
|
+
"- No headings and no praise.",
|
|
70
62
|
'- If no confirmed issues exist, reply with exactly: "No confirmed bugs or high-value optimizations found."',
|
|
71
63
|
"- Format as GitLab-flavoured markdown.",
|
|
72
|
-
"",
|
|
73
|
-
"Few-shot examples:",
|
|
74
|
-
"Example A (has bug):",
|
|
75
|
-
"Diff snippet: `+ smsAvailable: isSmsAvalable(repeatCount, source, methodList)` and nearby symbol `isSmsAvailable`.",
|
|
76
|
-
"Valid answer:",
|
|
77
|
-
"- [high] Function name typo [file: wss/api_routes/api_phone_check/api_phone_check.js, line ~35]: `isSmsAvalable` likely misspells `isSmsAvailable`, causing runtime/reference failure when this branch executes.",
|
|
78
|
-
"",
|
|
79
|
-
"Example B (no confirmed issues):",
|
|
80
|
-
"Diff snippet: formatting-only changes and equivalent variable renames without behavior changes.",
|
|
81
|
-
'Valid answer: "No confirmed bugs or high-value optimizations found."',
|
|
82
64
|
].join("\n"),
|
|
83
65
|
},
|
|
84
66
|
];
|
|
85
67
|
export const AI_MODEL_TEMPERATURE = 0.2;
|
|
86
|
-
export const buildPrompt = ({ changes, limits, }) => {
|
|
68
|
+
export const buildPrompt = ({ changes, limits, allowTools = false, }) => {
|
|
87
69
|
const effectiveLimits = {
|
|
88
70
|
...DEFAULT_PROMPT_LIMITS,
|
|
89
71
|
...(limits ?? {}),
|
|
@@ -94,7 +76,7 @@ export const buildPrompt = ({ changes, limits, }) => {
|
|
|
94
76
|
const changesText = diffsTrimmed.join("\n\n");
|
|
95
77
|
const intro = `
|
|
96
78
|
Review the following code changes (git diff format) for bugs and optimization opportunities only.
|
|
97
|
-
No full pre-change file context is embedded; use tool calls to
|
|
79
|
+
${allowTools ? "No full pre-change file context is embedded; use tool calls/search when needed (up to 10 calls)." : "No full pre-change file context is embedded. Tools are unavailable in this run; rely only on visible diff evidence."}
|
|
98
80
|
If you see truncation markers, note potential blind spots.
|
|
99
81
|
Do not present assumptions as facts.
|
|
100
82
|
Follow the previously given rules strictly: at most 3 findings, bullets only, no headings, only clearly evidenced issues from this diff.
|
package/dist/prompt/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/prompt/index.ts"],"names":[],"mappings":"AAAA,cAAc;AAad,MAAM,CAAC,MAAM,qBAAqB,GAAiB;IACjD,QAAQ,EAAE,EAAE;IACZ,YAAY,EAAE,KAAK;IACnB,mBAAmB,EAAE,MAAM;CAC5B,CAAC;AAEF,SAAS,kBAAkB,CACzB,KAAa,EACb,QAAgB,EAChB,WAAmB;IAEnB,IAAI,KAAK,CAAC,MAAM,IAAI,QAAQ;QAAE,OAAO,KAAK,CAAC;IAC3C,MAAM,OAAO,GAAG,KAAK,CAAC,MAAM,GAAG,QAAQ,CAAC;IACxC,OAAO,GAAG,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,QAAQ,CAAC,YAAY,WAAW,uBAAuB,OAAO,aAAa,CAAC;AACvG,CAAC;AAED,MAAM,SAAS,GAAG;;;+GAG6F,CAAC;AAEhH,MAAM,QAAQ,GAAiC;IAC7C;QACE,IAAI,EAAE,QAAQ;QACd,OAAO,EAAE;YACP,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/prompt/index.ts"],"names":[],"mappings":"AAAA,cAAc;AAad,MAAM,CAAC,MAAM,qBAAqB,GAAiB;IACjD,QAAQ,EAAE,EAAE;IACZ,YAAY,EAAE,KAAK;IACnB,mBAAmB,EA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