@juspay/yama 2.4.2 → 2.5.0
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/CHANGELOG.md +7 -0
- package/dist/cli/cli.js +74 -3
- package/dist/index.js +4 -0
- package/dist/v2/config/ConfigLoader.d.ts +7 -2
- package/dist/v2/config/ConfigLoader.js +29 -10
- package/dist/v2/config/DefaultConfig.js +13 -0
- package/dist/v2/core/LearningOrchestrator.js +21 -5
- package/dist/v2/core/MCPServerManager.d.ts +36 -3
- package/dist/v2/core/MCPServerManager.js +173 -6
- package/dist/v2/core/YamaV2Orchestrator.d.ts +20 -1
- package/dist/v2/core/YamaV2Orchestrator.js +168 -58
- package/dist/v2/exploration/ContextExplorerService.d.ts +9 -0
- package/dist/v2/exploration/ContextExplorerService.js +50 -9
- package/dist/v2/exploration/types.d.ts +1 -0
- package/dist/v2/learning/types.d.ts +2 -0
- package/dist/v2/memory/MemoryManager.d.ts +20 -4
- package/dist/v2/memory/MemoryManager.js +30 -5
- package/dist/v2/prompts/PromptBuilder.d.ts +10 -2
- package/dist/v2/prompts/PromptBuilder.js +70 -59
- package/dist/v2/prompts/ReviewSystemPrompt.d.ts +29 -1
- package/dist/v2/prompts/ReviewSystemPrompt.js +34 -43
- package/dist/v2/providers/ProviderToolset.d.ts +54 -0
- package/dist/v2/providers/ProviderToolset.js +389 -0
- package/dist/v2/types/config.types.d.ts +40 -9
- package/dist/v2/types/mcp.types.d.ts +105 -193
- package/dist/v2/types/mcp.types.js +9 -2
- package/dist/v2/types/v2.types.d.ts +7 -2
- package/dist/v2/utils/ProviderDetector.d.ts +57 -0
- package/dist/v2/utils/ProviderDetector.js +187 -0
- package/package.json +2 -1
|
@@ -8,14 +8,22 @@
|
|
|
8
8
|
import { YamaConfig } from "../types/config.types.js";
|
|
9
9
|
import { LocalReviewRequest, ReviewRequest } from "../types/v2.types.js";
|
|
10
10
|
import type { LocalDiffContext } from "../core/LocalDiffSource.js";
|
|
11
|
+
import { type VCSProviderName } from "../providers/ProviderToolset.js";
|
|
11
12
|
export declare class PromptBuilder {
|
|
12
13
|
private langfuseManager;
|
|
13
14
|
constructor();
|
|
15
|
+
/**
|
|
16
|
+
* Build the provider-agnostic params object the ProviderToolset consumes.
|
|
17
|
+
* Carries both Bitbucket (workspace/repository/pullRequestId) and GitHub
|
|
18
|
+
* (owner/repo/prNumber) identifiers plus the shared branch; each toolset
|
|
19
|
+
* reads only the fields it needs.
|
|
20
|
+
*/
|
|
21
|
+
private toToolsetParams;
|
|
14
22
|
/**
|
|
15
23
|
* Build complete review instructions for AI
|
|
16
24
|
* Combines generic base prompt + project-specific config
|
|
17
25
|
*/
|
|
18
|
-
buildReviewInstructions(request: ReviewRequest, config: YamaConfig, bootstrapStandards
|
|
26
|
+
buildReviewInstructions(request: ReviewRequest, config: YamaConfig, bootstrapStandards: string | null | undefined, provider: VCSProviderName): Promise<string>;
|
|
19
27
|
/**
|
|
20
28
|
* Per-PR workflow block. Standards-first, file-by-file, explore-on-uncertainty.
|
|
21
29
|
* The agent stays autonomous; this just choreographs the order it should follow.
|
|
@@ -54,7 +62,7 @@ export declare class PromptBuilder {
|
|
|
54
62
|
/**
|
|
55
63
|
* Build description enhancement prompt separately (for description-only operations)
|
|
56
64
|
*/
|
|
57
|
-
buildDescriptionEnhancementInstructions(request: ReviewRequest, config: YamaConfig): Promise<string>;
|
|
65
|
+
buildDescriptionEnhancementInstructions(request: ReviewRequest, config: YamaConfig, provider: VCSProviderName): Promise<string>;
|
|
58
66
|
/**
|
|
59
67
|
* Build local SDK review instructions.
|
|
60
68
|
* Produces strict JSON output for local diff quality analysis.
|
|
@@ -9,19 +9,73 @@ import { readFile } from "fs/promises";
|
|
|
9
9
|
import { existsSync } from "fs";
|
|
10
10
|
import { join } from "path";
|
|
11
11
|
import { LangfusePromptManager } from "./LangfusePromptManager.js";
|
|
12
|
+
import { buildReviewSystemPrompt } from "./ReviewSystemPrompt.js";
|
|
12
13
|
import { KnowledgeBaseManager } from "../learning/KnowledgeBaseManager.js";
|
|
14
|
+
import { getProviderToolset, } from "../providers/ProviderToolset.js";
|
|
13
15
|
export class PromptBuilder {
|
|
14
16
|
langfuseManager;
|
|
15
17
|
constructor() {
|
|
16
18
|
this.langfuseManager = new LangfusePromptManager();
|
|
17
19
|
}
|
|
20
|
+
/**
|
|
21
|
+
* Build the provider-agnostic params object the ProviderToolset consumes.
|
|
22
|
+
* Carries both Bitbucket (workspace/repository/pullRequestId) and GitHub
|
|
23
|
+
* (owner/repo/prNumber) identifiers plus the shared branch; each toolset
|
|
24
|
+
* reads only the fields it needs.
|
|
25
|
+
*/
|
|
26
|
+
toToolsetParams(request) {
|
|
27
|
+
const params = {};
|
|
28
|
+
const workspace = (request.workspace || "").trim();
|
|
29
|
+
const repository = (request.repository || "").trim();
|
|
30
|
+
const branch = (request.branch || "N/A").trim();
|
|
31
|
+
params.workspace = workspace;
|
|
32
|
+
params.repository = repository;
|
|
33
|
+
params.branch = branch;
|
|
34
|
+
// Coalesce the PR identifier across both field names so the toolset always
|
|
35
|
+
// receives the PR number regardless of which one the caller populated.
|
|
36
|
+
// GitHub's identifierXml reads params.prNumber while Bitbucket's reads
|
|
37
|
+
// params.pullRequestId; CLI callers set request.pullRequestId even for
|
|
38
|
+
// GitHub, so without this a GitHub run would lose the PR number and fall
|
|
39
|
+
// back to 'find-by-branch'. No-op for existing Bitbucket behavior.
|
|
40
|
+
const resolvedPrNumber = request.prNumber ??
|
|
41
|
+
(typeof request.pullRequestId === "number"
|
|
42
|
+
? request.pullRequestId
|
|
43
|
+
: undefined);
|
|
44
|
+
const resolvedPullRequestId = request.pullRequestId ?? request.prNumber;
|
|
45
|
+
if (resolvedPullRequestId !== undefined) {
|
|
46
|
+
params.pullRequestId = resolvedPullRequestId;
|
|
47
|
+
}
|
|
48
|
+
if (request.owner !== undefined) {
|
|
49
|
+
params.owner = request.owner.trim();
|
|
50
|
+
}
|
|
51
|
+
// Coalesce the repo name across the GitHub-specific 'repo' field and the
|
|
52
|
+
// shared 'repository' field, mirroring the prNumber<->pullRequestId
|
|
53
|
+
// coalescing above. A GitHub caller may populate the shared 'repository'
|
|
54
|
+
// field instead of 'repo'; without this the toolset would receive GitHub
|
|
55
|
+
// identifiers with no repo name. No-op for existing Bitbucket behavior,
|
|
56
|
+
// which never sets request.repo.
|
|
57
|
+
const resolvedRepo = request.repo ?? request.repository;
|
|
58
|
+
if (resolvedRepo !== undefined) {
|
|
59
|
+
params.repo = resolvedRepo.trim();
|
|
60
|
+
}
|
|
61
|
+
if (resolvedPrNumber !== undefined) {
|
|
62
|
+
params.prNumber = resolvedPrNumber;
|
|
63
|
+
}
|
|
64
|
+
return params;
|
|
65
|
+
}
|
|
18
66
|
/**
|
|
19
67
|
* Build complete review instructions for AI
|
|
20
68
|
* Combines generic base prompt + project-specific config
|
|
21
69
|
*/
|
|
22
|
-
async buildReviewInstructions(request, config, bootstrapStandards) {
|
|
23
|
-
|
|
24
|
-
|
|
70
|
+
async buildReviewInstructions(request, config, bootstrapStandards, provider) {
|
|
71
|
+
const toolset = getProviderToolset(provider);
|
|
72
|
+
// Base system prompt. Prefer a Langfuse-managed prompt when one is
|
|
73
|
+
// configured (provider-agnostic remote override); otherwise fall back to
|
|
74
|
+
// the provider-aware local prompt so the <tool-usage> section matches the
|
|
75
|
+
// active provider's tool idiom.
|
|
76
|
+
const basePromptRaw = this.langfuseManager.isEnabled()
|
|
77
|
+
? await this.langfuseManager.getReviewPrompt()
|
|
78
|
+
: buildReviewSystemPrompt(toolset);
|
|
25
79
|
// Project-specific configuration in XML format
|
|
26
80
|
const projectConfig = this.buildProjectConfigXML(config, request);
|
|
27
81
|
// Project-specific standards (if available)
|
|
@@ -31,7 +85,8 @@ export class PromptBuilder {
|
|
|
31
85
|
const exploreEnabled = config.ai.explore.enabled;
|
|
32
86
|
// Strip explore_context references when the subagent is disabled.
|
|
33
87
|
const basePrompt = PromptBuilder.stripDisabledSections(basePromptRaw, exploreEnabled);
|
|
34
|
-
const
|
|
88
|
+
const toolsetParams = this.toToolsetParams(request);
|
|
89
|
+
const workflowBlock = PromptBuilder.stripDisabledSections(this.buildReviewWorkflow(request, toolset, toolsetParams), exploreEnabled);
|
|
35
90
|
const bootstrapBlock = bootstrapStandards && bootstrapStandards.trim().length > 0
|
|
36
91
|
? `<bootstrapped-standards>
|
|
37
92
|
<!--
|
|
@@ -59,10 +114,7 @@ ${bootstrapBlock}
|
|
|
59
114
|
${knowledgeBase ? `<learned-knowledge>\n${knowledgeBase}\n</learned-knowledge>` : ""}
|
|
60
115
|
|
|
61
116
|
<review-task>
|
|
62
|
-
|
|
63
|
-
<repository>${this.escapeXML(request.repository)}</repository>
|
|
64
|
-
<pull_request_id>${request.pullRequestId || "find-by-branch"}</pull_request_id>
|
|
65
|
-
<branch>${this.escapeXML(request.branch || "N/A")}</branch>
|
|
117
|
+
${toolset.identifierXml(toolsetParams)}
|
|
66
118
|
<mode>${request.dryRun ? "dry-run" : "live"}</mode>
|
|
67
119
|
|
|
68
120
|
${workflowBlock}
|
|
@@ -73,47 +125,18 @@ ${workflowBlock}
|
|
|
73
125
|
* Per-PR workflow block. Standards-first, file-by-file, explore-on-uncertainty.
|
|
74
126
|
* The agent stays autonomous; this just choreographs the order it should follow.
|
|
75
127
|
*/
|
|
76
|
-
buildReviewWorkflow(request) {
|
|
128
|
+
buildReviewWorkflow(request, toolset, params) {
|
|
77
129
|
const modeLine = request.dryRun
|
|
78
130
|
? "DRY RUN MODE: simulate actions only, do not post real comments or change PR state."
|
|
79
131
|
: "LIVE MODE: post real comments and make real decisions.";
|
|
80
132
|
const additional = request.prompt
|
|
81
133
|
? `\n ADDITIONAL INSTRUCTIONS: ${this.escapeXML(request.prompt)}`
|
|
82
134
|
: "";
|
|
135
|
+
// The numbered review steps (tool names + workflow prose) come from the
|
|
136
|
+
// provider toolset; the <instructions> wrapper and the dynamic mode/
|
|
137
|
+
// additional tail stay here so they apply to every provider unchanged.
|
|
83
138
|
return ` <instructions>
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
STEP 1 — Read project standards
|
|
87
|
-
Read the <project-standards> block above carefully. Treat any reviewer-expectation
|
|
88
|
-
entry with severity=BLOCKING as a blocking criterion for this PR. If the block is
|
|
89
|
-
missing or empty, fall back to <focus-areas> and <blocking-criteria>.
|
|
90
|
-
|
|
91
|
-
STEP 2 — Read the PR shell
|
|
92
|
-
Call get_pull_request once to get changed files, branch info, and existing comments.
|
|
93
|
-
Build a mental map of which files exist and which already have comments.
|
|
94
|
-
Do NOT request the full PR diff.
|
|
95
|
-
|
|
96
|
-
STEP 3 — Walk files one at a time
|
|
97
|
-
For each changed file, in order:
|
|
98
|
-
a. Call get_pull_request_diff(file_path=<this file>).
|
|
99
|
-
b. Cross-check the diff against project-standards and existing comments on this file.
|
|
100
|
-
c. If anything is non-trivial — multi-file impact, unfamiliar pattern, unclear intent,
|
|
101
|
-
history-dependent behavior — <!-- EXPLORE_BEGIN -->call explore_context with a precise
|
|
102
|
-
task and wait for its evidence before commenting<!-- EXPLORE_END --><!-- EXPLORE_DISABLED_BEGIN -->use search_code or get_file_content to verify before commenting<!-- EXPLORE_DISABLED_END -->.
|
|
103
|
-
d. For every confirmed issue, call add_comment immediately with line_number and
|
|
104
|
-
line_type from the diff JSON. Include a real-code suggestion for CRITICAL/MAJOR.
|
|
105
|
-
e. Move to the next file. Never request another file's diff before finishing the
|
|
106
|
-
current one. Never request a multi-file diff.
|
|
107
|
-
|
|
108
|
-
STEP 4 — Decision
|
|
109
|
-
After the last file, count issues by severity, apply <blocking-criteria>, and call
|
|
110
|
-
set_pr_approval(approved=true) OR set_review_status(request_changes=true).
|
|
111
|
-
|
|
112
|
-
STEP 5 — Summary comment
|
|
113
|
-
Post one summary comment with file count, issue counts by severity, and next steps.
|
|
114
|
-
|
|
115
|
-
Budget guidance: roughly 10 tool calls per file in the main loop. If you exceed
|
|
116
|
-
that on a single file, <!-- EXPLORE_BEGIN -->delegate the rest to explore_context<!-- EXPLORE_END --><!-- EXPLORE_DISABLED_BEGIN -->stop investigating<!-- EXPLORE_DISABLED_END --> and move on.
|
|
139
|
+
${toolset.reviewWorkflowInstructions(params)}
|
|
117
140
|
|
|
118
141
|
${modeLine}${additional}
|
|
119
142
|
</instructions>`;
|
|
@@ -298,7 +321,9 @@ ${loadedStandards.join("\n\n---\n\n")}
|
|
|
298
321
|
/**
|
|
299
322
|
* Build description enhancement prompt separately (for description-only operations)
|
|
300
323
|
*/
|
|
301
|
-
async buildDescriptionEnhancementInstructions(request, config) {
|
|
324
|
+
async buildDescriptionEnhancementInstructions(request, config, provider) {
|
|
325
|
+
const toolset = getProviderToolset(provider);
|
|
326
|
+
const toolsetParams = this.toToolsetParams(request);
|
|
302
327
|
// Base enhancement prompt - fetched from Langfuse or local fallback
|
|
303
328
|
const basePrompt = await this.langfuseManager.getEnhancementPrompt();
|
|
304
329
|
// Project-specific enhancement configuration
|
|
@@ -311,25 +336,11 @@ ${enhancementConfigXML}
|
|
|
311
336
|
</project-configuration>
|
|
312
337
|
|
|
313
338
|
<enhancement-task>
|
|
314
|
-
|
|
315
|
-
<repository>${this.escapeXML(request.repository)}</repository>
|
|
316
|
-
<pull_request_id>${request.pullRequestId || "find-by-branch"}</pull_request_id>
|
|
317
|
-
<branch>${this.escapeXML(request.branch || "N/A")}</branch>
|
|
339
|
+
${toolset.identifierXml(toolsetParams)}
|
|
318
340
|
<mode>${request.dryRun ? "dry-run" : "live"}</mode>
|
|
319
341
|
|
|
320
342
|
<instructions>
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
1. Call get_pull_request() to read current PR and description
|
|
324
|
-
2. Call get_pull_request_diff() to analyze code changes
|
|
325
|
-
3. Use search_code() to find configuration patterns, API changes
|
|
326
|
-
4. Extract information for each required section
|
|
327
|
-
5. Build enhanced description following section structure
|
|
328
|
-
6. Call update_pull_request() with enhanced description
|
|
329
|
-
|
|
330
|
-
CRITICAL: Return ONLY the enhanced description markdown.
|
|
331
|
-
Do NOT include meta-commentary or explanations.
|
|
332
|
-
Start directly with section content.
|
|
343
|
+
${toolset.descriptionEnhancementInstructions(toolsetParams)}
|
|
333
344
|
|
|
334
345
|
${request.dryRun ? "DRY RUN MODE: Simulate only, do not actually update PR." : "LIVE MODE: Update the actual PR description."}
|
|
335
346
|
${request.prompt ? `ADDITIONAL INSTRUCTIONS: ${this.escapeXML(request.prompt)}` : ""}
|
|
@@ -7,7 +7,35 @@
|
|
|
7
7
|
*
|
|
8
8
|
* Sections wrapped in <!-- EXPLORE_BEGIN --> ... <!-- EXPLORE_END --> markers
|
|
9
9
|
* are stripped by PromptBuilder when config.ai.explore.enabled is false.
|
|
10
|
+
*
|
|
11
|
+
* The <tool-usage> section is the ONLY provider-specific part of this prompt.
|
|
12
|
+
* It is supplied by the ProviderToolset so the same review philosophy, severity
|
|
13
|
+
* rules and anti-patterns drive both Bitbucket and GitHub. For
|
|
14
|
+
* provider === "bitbucket" the rendered output is byte-identical to the
|
|
15
|
+
* historical hardcoded prompt (the toolset's Bitbucket strings were copied
|
|
16
|
+
* verbatim).
|
|
17
|
+
*/
|
|
18
|
+
import { type ProviderToolset, type VCSProviderName } from "../providers/ProviderToolset.js";
|
|
19
|
+
/**
|
|
20
|
+
* Render the base review system prompt for a given provider.
|
|
21
|
+
*
|
|
22
|
+
* Accepts either a provider name (the common case) or an already-resolved
|
|
23
|
+
* ProviderToolset. Only the <tool-usage> section varies by provider; every
|
|
24
|
+
* other block (identity, core rules, severity levels, anti-patterns) is shared
|
|
25
|
+
* verbatim.
|
|
26
|
+
*/
|
|
27
|
+
export declare function buildReviewSystemPrompt(provider: VCSProviderName | ProviderToolset): string;
|
|
28
|
+
/**
|
|
29
|
+
* Provider-aware alias matching the pinned signature `build(provider)`.
|
|
30
|
+
*/
|
|
31
|
+
export declare const build: typeof buildReviewSystemPrompt;
|
|
32
|
+
/**
|
|
33
|
+
* Bitbucket-rendered base review system prompt.
|
|
34
|
+
*
|
|
35
|
+
* Kept as a named constant for backward compatibility with consumers that
|
|
36
|
+
* expect a static fallback (e.g. LangfusePromptManager's Bitbucket fallback).
|
|
37
|
+
* This is byte-identical to the historical hardcoded prompt.
|
|
10
38
|
*/
|
|
11
|
-
export declare const REVIEW_SYSTEM_PROMPT
|
|
39
|
+
export declare const REVIEW_SYSTEM_PROMPT: string;
|
|
12
40
|
export default REVIEW_SYSTEM_PROMPT;
|
|
13
41
|
//# sourceMappingURL=ReviewSystemPrompt.d.ts.map
|
|
@@ -7,8 +7,27 @@
|
|
|
7
7
|
*
|
|
8
8
|
* Sections wrapped in <!-- EXPLORE_BEGIN --> ... <!-- EXPLORE_END --> markers
|
|
9
9
|
* are stripped by PromptBuilder when config.ai.explore.enabled is false.
|
|
10
|
+
*
|
|
11
|
+
* The <tool-usage> section is the ONLY provider-specific part of this prompt.
|
|
12
|
+
* It is supplied by the ProviderToolset so the same review philosophy, severity
|
|
13
|
+
* rules and anti-patterns drive both Bitbucket and GitHub. For
|
|
14
|
+
* provider === "bitbucket" the rendered output is byte-identical to the
|
|
15
|
+
* historical hardcoded prompt (the toolset's Bitbucket strings were copied
|
|
16
|
+
* verbatim).
|
|
17
|
+
*/
|
|
18
|
+
import { getProviderToolset, } from "../providers/ProviderToolset.js";
|
|
19
|
+
/**
|
|
20
|
+
* Render the base review system prompt for a given provider.
|
|
21
|
+
*
|
|
22
|
+
* Accepts either a provider name (the common case) or an already-resolved
|
|
23
|
+
* ProviderToolset. Only the <tool-usage> section varies by provider; every
|
|
24
|
+
* other block (identity, core rules, severity levels, anti-patterns) is shared
|
|
25
|
+
* verbatim.
|
|
10
26
|
*/
|
|
11
|
-
export
|
|
27
|
+
export function buildReviewSystemPrompt(provider) {
|
|
28
|
+
const toolset = typeof provider === "string" ? getProviderToolset(provider) : provider;
|
|
29
|
+
const toolUsageSection = toolset.systemPromptToolsSection();
|
|
30
|
+
return `
|
|
12
31
|
<yama-review-system>
|
|
13
32
|
<identity>
|
|
14
33
|
<role>Autonomous Code Review Agent</role>
|
|
@@ -24,48 +43,7 @@ export const REVIEW_SYSTEM_PROMPT = `
|
|
|
24
43
|
<rule id="avoid-duplicates">Check existing comments before posting. If a developer's reply is wrong, reply to it instead of duplicating.</rule>
|
|
25
44
|
</core-rules>
|
|
26
45
|
|
|
27
|
-
|
|
28
|
-
<tool name="get_pull_request">
|
|
29
|
-
<use-when>Once at the start, to read PR metadata and existing comments.</use-when>
|
|
30
|
-
</tool>
|
|
31
|
-
|
|
32
|
-
<tool name="get_pull_request_diff">
|
|
33
|
-
<use-when>For ONE file at a time, immediately before reviewing it.</use-when>
|
|
34
|
-
<do-not-use-when>Never call this without a file_path argument. Never request the full PR diff.</do-not-use-when>
|
|
35
|
-
</tool>
|
|
36
|
-
|
|
37
|
-
<tool name="search_code">
|
|
38
|
-
<use-when>A single direct lookup answers your question (function definition, single file).</use-when>
|
|
39
|
-
<do-not-use-when>The investigation needs more than one call or spans multiple files — delegate to explore_context instead.</do-not-use-when>
|
|
40
|
-
</tool>
|
|
41
|
-
|
|
42
|
-
<tool name="get_file_content">
|
|
43
|
-
<use-when>You already know the path and need the file's contents.</use-when>
|
|
44
|
-
</tool>
|
|
45
|
-
|
|
46
|
-
<!-- EXPLORE_BEGIN -->
|
|
47
|
-
<tool name="explore_context">
|
|
48
|
-
<use-when>Multi-step research, multi-file tracing, history lookup, ambiguous behavior, or anything that would otherwise need 3+ tool calls in the main loop.</use-when>
|
|
49
|
-
<do-not-use-when>A single search_code or get_file_content would answer it. Delegating cheap lookups wastes a turn.</do-not-use-when>
|
|
50
|
-
<how>Pass a one-sentence research question as task and optional file paths/PR refs as focus. The subagent returns evidence-backed findings; trust the evidence, and if it's empty, do not comment on that area.</how>
|
|
51
|
-
<example positive>Diff adds a retry guard in PaymentProcessor → explore_context(task="Is this retry guard consistent with how other payment handlers retry, and does it match the convention from PR 842?", focus=["src/payments/", "PR 842"])</example>
|
|
52
|
-
<example negative>Don't: explore_context(task="What does validatePayment do?"). Do: search_code(search_query="function validatePayment").</example>
|
|
53
|
-
</tool>
|
|
54
|
-
<!-- EXPLORE_END -->
|
|
55
|
-
|
|
56
|
-
<tool name="add_comment">
|
|
57
|
-
<fields>file_path, line_number, line_type (ADDED|REMOVED|CONTEXT), comment_text, and suggestion (required for CRITICAL and MAJOR — must be real, executable code).</fields>
|
|
58
|
-
<do-not-use-when>You only have a code_snippet but no line_number/line_type from the diff JSON.</do-not-use-when>
|
|
59
|
-
</tool>
|
|
60
|
-
|
|
61
|
-
<tool name="set_pr_approval">
|
|
62
|
-
<use-when>No blocking issues found. Pass approved=true.</use-when>
|
|
63
|
-
</tool>
|
|
64
|
-
|
|
65
|
-
<tool name="set_review_status">
|
|
66
|
-
<use-when>Blocking criteria met. Pass request_changes=true.</use-when>
|
|
67
|
-
</tool>
|
|
68
|
-
</tool-usage>
|
|
46
|
+
${toolUsageSection}
|
|
69
47
|
|
|
70
48
|
<severity-levels>
|
|
71
49
|
<level name="CRITICAL" emoji="🔒">Blocks the PR. MUST include a real-code suggestion. Security, data loss, auth flaws, hardcoded secrets.</level>
|
|
@@ -84,5 +62,18 @@ export const REVIEW_SYSTEM_PROMPT = `
|
|
|
84
62
|
</anti-patterns>
|
|
85
63
|
</yama-review-system>
|
|
86
64
|
`;
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Provider-aware alias matching the pinned signature `build(provider)`.
|
|
68
|
+
*/
|
|
69
|
+
export const build = buildReviewSystemPrompt;
|
|
70
|
+
/**
|
|
71
|
+
* Bitbucket-rendered base review system prompt.
|
|
72
|
+
*
|
|
73
|
+
* Kept as a named constant for backward compatibility with consumers that
|
|
74
|
+
* expect a static fallback (e.g. LangfusePromptManager's Bitbucket fallback).
|
|
75
|
+
* This is byte-identical to the historical hardcoded prompt.
|
|
76
|
+
*/
|
|
77
|
+
export const REVIEW_SYSTEM_PROMPT = buildReviewSystemPrompt("bitbucket");
|
|
87
78
|
export default REVIEW_SYSTEM_PROMPT;
|
|
88
79
|
//# sourceMappingURL=ReviewSystemPrompt.js.map
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ProviderToolset — the single source of truth for everything that differs
|
|
3
|
+
* between VCS providers (Bitbucket vs GitHub) when Yama drives an AI review.
|
|
4
|
+
*
|
|
5
|
+
* Every provider-specific string the AI sees (the <available_tools> section,
|
|
6
|
+
* the numbered review workflow, the PR-context identifier block, the
|
|
7
|
+
* description-enhancement steps) and every provider-specific signal Yama reads
|
|
8
|
+
* back (which tool call is a comment, a diff fetch, a repo mutation, or an
|
|
9
|
+
* approve/block decision) lives behind this interface.
|
|
10
|
+
*
|
|
11
|
+
* The Bitbucket toolset reproduces the CURRENT prompt wording verbatim, so
|
|
12
|
+
* behaviour for Bitbucket stays byte-identical. The GitHub toolset teaches the
|
|
13
|
+
* official github/github-mcp-server consolidated API and pending-review flow,
|
|
14
|
+
* keeping the same review philosophy and severity rules.
|
|
15
|
+
*/
|
|
16
|
+
export type VCSProviderName = "github" | "bitbucket";
|
|
17
|
+
export interface ReviewPromptParams {
|
|
18
|
+
workspace?: string;
|
|
19
|
+
repository?: string;
|
|
20
|
+
pullRequestId?: number | string;
|
|
21
|
+
owner?: string;
|
|
22
|
+
repo?: string;
|
|
23
|
+
prNumber?: number;
|
|
24
|
+
branch?: string;
|
|
25
|
+
}
|
|
26
|
+
export interface ProviderToolCall {
|
|
27
|
+
toolName?: string;
|
|
28
|
+
args?: Record<string, unknown>;
|
|
29
|
+
}
|
|
30
|
+
export interface ProviderToolset {
|
|
31
|
+
readonly provider: VCSProviderName;
|
|
32
|
+
/** Tool name the AI calls to read a PR's metadata/comments
|
|
33
|
+
* (Bitbucket: get_pull_request; GitHub: pull_request_read). */
|
|
34
|
+
readonly prReadToolName: string;
|
|
35
|
+
/** <pr_context> identifier block injected into review/enhancement prompts */
|
|
36
|
+
identifierXml(params: ReviewPromptParams): string;
|
|
37
|
+
/** The <available_tools> section listing the tools the AI may call (provider idiom) */
|
|
38
|
+
systemPromptToolsSection(): string;
|
|
39
|
+
/** Provider-specific numbered review workflow instructions (prose the AI follows) */
|
|
40
|
+
reviewWorkflowInstructions(params: ReviewPromptParams): string;
|
|
41
|
+
/** Provider-specific PR-description-enhancement workflow instructions */
|
|
42
|
+
descriptionEnhancementInstructions(params: ReviewPromptParams): string;
|
|
43
|
+
/** Tool names whose calls represent an inline/PR comment (statistics counting) */
|
|
44
|
+
readonly commentToolNames: string[];
|
|
45
|
+
/** Tool names representing diff/file retrieval (statistics counting) */
|
|
46
|
+
readonly diffToolNames: string[];
|
|
47
|
+
/** Plain tool names that mutate PR/repo state (explore_context block list) */
|
|
48
|
+
readonly mutationToolNames: string[];
|
|
49
|
+
/** Interpret a single tool call as an approve/block decision signal, else null.
|
|
50
|
+
* Bitbucket: set_pr_approval/set_review_status (+ args). GitHub: pull_request_review_write with args.event. */
|
|
51
|
+
interpretDecision(call: ProviderToolCall): "APPROVED" | "BLOCKED" | null;
|
|
52
|
+
}
|
|
53
|
+
export declare function getProviderToolset(provider: VCSProviderName): ProviderToolset;
|
|
54
|
+
//# sourceMappingURL=ProviderToolset.d.ts.map
|