@bastani/atomic 0.5.33 → 0.5.34
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/sdk/workflows/builtin/ralph/copilot/index.d.ts.map +1 -1
- package/dist/sdk/workflows/builtin/ralph/helpers/copilot-reviewer.d.ts +25 -0
- package/dist/sdk/workflows/builtin/ralph/helpers/copilot-reviewer.d.ts.map +1 -0
- package/dist/services/config/scm-sync.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/sdk/workflows/builtin/ralph/copilot/index.ts +22 -4
- package/src/sdk/workflows/builtin/ralph/helpers/copilot-reviewer.ts +105 -0
- package/src/services/config/scm-sync.ts +15 -4
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../src/sdk/workflows/builtin/ralph/copilot/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../src/sdk/workflows/builtin/ralph/copilot/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;;;;;;;;;;;;AA+DH,wBAqMa"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Inline reviewer `CustomAgentConfig` for the Copilot ralph workflow.
|
|
3
|
+
*
|
|
4
|
+
* Why this exists instead of reusing `.github/agents/reviewer.md`: Copilot
|
|
5
|
+
* CLI parses the disk agent's `tools:` frontmatter against its built-in
|
|
6
|
+
* alias registry at load time. Custom tool names (like `submit_review`
|
|
7
|
+
* registered via `defineTool` at session creation) are unknown at that
|
|
8
|
+
* moment and get silently dropped. Defining the agent inline in
|
|
9
|
+
* `customAgents` runs the tool-allowlist check against the session's live
|
|
10
|
+
* tool registry, so `submit_review` is actually exposed to the subagent.
|
|
11
|
+
*
|
|
12
|
+
* This is a ralph-specific fork — the disk reviewer stays general-purpose
|
|
13
|
+
* for non-ralph invocations.
|
|
14
|
+
*/
|
|
15
|
+
import type { CustomAgentConfig } from "@github/copilot-sdk";
|
|
16
|
+
/**
|
|
17
|
+
* Build the ralph-specific reviewer `CustomAgentConfig`.
|
|
18
|
+
*
|
|
19
|
+
* Pass the session-level custom tool name(s) (e.g. `"submit_review"`) via
|
|
20
|
+
* `submitReviewToolName` so the reviewer subagent's tool allowlist
|
|
21
|
+
* includes it. Session-level tools named here are visible to the subagent;
|
|
22
|
+
* omitted names are filtered out.
|
|
23
|
+
*/
|
|
24
|
+
export declare function buildRalphReviewerAgent(submitReviewToolName: string): CustomAgentConfig;
|
|
25
|
+
//# sourceMappingURL=copilot-reviewer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"copilot-reviewer.d.ts","sourceRoot":"","sources":["../../../../../../src/sdk/workflows/builtin/ralph/helpers/copilot-reviewer.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AA+D7D;;;;;;;GAOG;AACH,wBAAgB,uBAAuB,CACrC,oBAAoB,EAAE,MAAM,GAC3B,iBAAiB,CAgBnB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"scm-sync.d.ts","sourceRoot":"","sources":["../../../src/services/config/scm-sync.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAIH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"scm-sync.d.ts","sourceRoot":"","sources":["../../../src/services/config/scm-sync.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAIH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AA0BtD;;;;;;;GAOG;AACH,wBAAgB,sBAAsB,CAAC,GAAG,EAAE,WAAW,GAAG,SAAS,GAAG,MAAM,EAAE,CAM7E;AAED;;;GAGG;AACH,wBAAsB,yBAAyB,CAC7C,WAAW,EAAE,MAAM,GAClB,OAAO,CAAC,MAAM,EAAE,CAAC,CAOnB;AA4FD;;;;GAIG;AACH,wBAAsB,iBAAiB,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAc1E"}
|
package/package.json
CHANGED
|
@@ -38,6 +38,9 @@ import {
|
|
|
38
38
|
} from "../helpers/prompts.ts";
|
|
39
39
|
import { hasActionableFindings } from "../helpers/review.ts";
|
|
40
40
|
import { captureBranchChangeset } from "../helpers/git.ts";
|
|
41
|
+
import { buildRalphReviewerAgent } from "../helpers/copilot-reviewer.ts";
|
|
42
|
+
|
|
43
|
+
const SUBMIT_REVIEW_TOOL_NAME = "submit_review";
|
|
41
44
|
|
|
42
45
|
const DEFAULT_MAX_LOOPS = 10;
|
|
43
46
|
|
|
@@ -198,7 +201,7 @@ export default defineWorkflow({
|
|
|
198
201
|
let captureA: ReviewResult | null = null;
|
|
199
202
|
let captureB: ReviewResult | null = null;
|
|
200
203
|
|
|
201
|
-
const toolA = defineTool(
|
|
204
|
+
const toolA = defineTool(SUBMIT_REVIEW_TOOL_NAME, {
|
|
202
205
|
description: SUBMIT_REVIEW_DESCRIPTION,
|
|
203
206
|
parameters: ReviewResultSchema,
|
|
204
207
|
skipPermission: true,
|
|
@@ -208,7 +211,7 @@ export default defineWorkflow({
|
|
|
208
211
|
},
|
|
209
212
|
});
|
|
210
213
|
|
|
211
|
-
const toolB = defineTool(
|
|
214
|
+
const toolB = defineTool(SUBMIT_REVIEW_TOOL_NAME, {
|
|
212
215
|
description: SUBMIT_REVIEW_DESCRIPTION,
|
|
213
216
|
parameters: ReviewResultSchema,
|
|
214
217
|
skipPermission: true,
|
|
@@ -218,11 +221,22 @@ export default defineWorkflow({
|
|
|
218
221
|
},
|
|
219
222
|
});
|
|
220
223
|
|
|
224
|
+
// Inline reviewer agent config overrides the disk-based
|
|
225
|
+
// `.github/agents/reviewer.md`. Defining it here lets the tool
|
|
226
|
+
// allowlist include `submit_review` — disk-loaded agents filter the
|
|
227
|
+
// frontmatter `tools:` list against Copilot's built-in alias
|
|
228
|
+
// registry at parse time, so session-level custom tools are dropped.
|
|
229
|
+
const ralphReviewer = buildRalphReviewerAgent(SUBMIT_REVIEW_TOOL_NAME);
|
|
230
|
+
|
|
221
231
|
const [reviewA, reviewB] = await Promise.all([
|
|
222
232
|
ctx.stage(
|
|
223
233
|
{ name: `reviewer-${iteration}-a` },
|
|
224
234
|
{},
|
|
225
|
-
{
|
|
235
|
+
{
|
|
236
|
+
agent: "reviewer",
|
|
237
|
+
tools: [toolA],
|
|
238
|
+
customAgents: [ralphReviewer],
|
|
239
|
+
},
|
|
226
240
|
async (s) => {
|
|
227
241
|
await s.session.send({ prompt: reviewPrompt });
|
|
228
242
|
const messages = await s.session.getMessages();
|
|
@@ -236,7 +250,11 @@ export default defineWorkflow({
|
|
|
236
250
|
ctx.stage(
|
|
237
251
|
{ name: `reviewer-${iteration}-b` },
|
|
238
252
|
{},
|
|
239
|
-
{
|
|
253
|
+
{
|
|
254
|
+
agent: "reviewer",
|
|
255
|
+
tools: [toolB],
|
|
256
|
+
customAgents: [ralphReviewer],
|
|
257
|
+
},
|
|
240
258
|
async (s) => {
|
|
241
259
|
await s.session.send({ prompt: reviewPrompt });
|
|
242
260
|
const messages = await s.session.getMessages();
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Inline reviewer `CustomAgentConfig` for the Copilot ralph workflow.
|
|
3
|
+
*
|
|
4
|
+
* Why this exists instead of reusing `.github/agents/reviewer.md`: Copilot
|
|
5
|
+
* CLI parses the disk agent's `tools:` frontmatter against its built-in
|
|
6
|
+
* alias registry at load time. Custom tool names (like `submit_review`
|
|
7
|
+
* registered via `defineTool` at session creation) are unknown at that
|
|
8
|
+
* moment and get silently dropped. Defining the agent inline in
|
|
9
|
+
* `customAgents` runs the tool-allowlist check against the session's live
|
|
10
|
+
* tool registry, so `submit_review` is actually exposed to the subagent.
|
|
11
|
+
*
|
|
12
|
+
* This is a ralph-specific fork — the disk reviewer stays general-purpose
|
|
13
|
+
* for non-ralph invocations.
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
import type { CustomAgentConfig } from "@github/copilot-sdk";
|
|
17
|
+
|
|
18
|
+
const REVIEWER_PROMPT = `# Review guidelines:
|
|
19
|
+
|
|
20
|
+
You are acting as a reviewer for a proposed code change made by another engineer.
|
|
21
|
+
|
|
22
|
+
Below are some default guidelines for determining whether the original author would appreciate the issue being flagged.
|
|
23
|
+
|
|
24
|
+
These are not the final word in determining whether an issue is a bug. In many cases, you will encounter other, more specific guidelines. These may be present elsewhere in a developer message, a user message, a file, or even elsewhere in this system message.
|
|
25
|
+
Those guidelines should be considered to override these general instructions.
|
|
26
|
+
|
|
27
|
+
Here are the general guidelines for determining whether something is a bug and should be flagged.
|
|
28
|
+
|
|
29
|
+
1. It meaningfully impacts the accuracy, performance, security, or maintainability of the code.
|
|
30
|
+
2. The bug is discrete and actionable (i.e. not a general issue with the codebase or a combination of multiple issues).
|
|
31
|
+
3. Fixing the bug does not demand a level of rigor that is not present in the rest of the codebase (e.g. one doesn't need very detailed comments and input validation in a repository of one-off scripts in personal projects)
|
|
32
|
+
4. The bug was introduced in the commit (pre-existing bugs should not be flagged).
|
|
33
|
+
5. The author of the original PR would likely fix the issue if they were made aware of it.
|
|
34
|
+
6. The bug does not rely on unstated assumptions about the codebase or author's intent.
|
|
35
|
+
7. It is not enough to speculate that a change may disrupt another part of the codebase, to be considered a bug, one must identify the other parts of the code that are provably affected.
|
|
36
|
+
8. The bug is clearly not just an intentional change by the original author.
|
|
37
|
+
9. Use the repository's \`AGENTS.md\` and/or \`CLAUDE.md\` files (if present) for guidance on style, conventions, testing expectations, and architectural patterns. Your review should respect these project-level norms — flag deviations only when they conflict with correctness or security, not personal preference.
|
|
38
|
+
|
|
39
|
+
When flagging a bug, you will also provide an accompanying comment. Once again, these guidelines are not the final word on how to construct a comment -- defer to any subsequent guidelines that you encounter.
|
|
40
|
+
|
|
41
|
+
1. The comment should be clear about why the issue is a bug.
|
|
42
|
+
2. The comment should appropriately communicate the severity of the issue. It should not claim that an issue is more severe than it actually is.
|
|
43
|
+
3. The comment should be brief. The body should be at most 1 paragraph. It should not introduce line breaks within the natural language flow unless it is necessary for the code fragment.
|
|
44
|
+
4. The comment should not include any chunks of code longer than 3 lines. Any code chunks should be wrapped in markdown inline code tags or a code block.
|
|
45
|
+
5. The comment should clearly and explicitly communicate the scenarios, environments, or inputs that are necessary for the bug to arise. The comment should immediately indicate that the issue's severity depends on these factors.
|
|
46
|
+
6. The comment's tone should be matter-of-fact and not accusatory or overly positive. It should read as a helpful AI assistant suggestion without sounding too much like a human reviewer.
|
|
47
|
+
7. The comment should be written such that the original author can immediately grasp the idea without close reading.
|
|
48
|
+
8. The comment should avoid excessive flattery and comments that are not helpful to the original author. The comment should avoid phrasing like "Great job ...", "Thanks for ...".
|
|
49
|
+
|
|
50
|
+
Below are some more detailed guidelines that you should apply to this specific review.
|
|
51
|
+
|
|
52
|
+
HOW MANY FINDINGS TO RETURN:
|
|
53
|
+
|
|
54
|
+
Output all findings that the original author would fix if they knew about it. If there is no finding that a person would definitely love to see and fix, prefer outputting no findings. Do not stop at the first qualifying finding. Continue until you've listed every qualifying finding.
|
|
55
|
+
|
|
56
|
+
GUIDELINES:
|
|
57
|
+
|
|
58
|
+
- Ignore trivial style unless it obscures meaning or violates documented standards.
|
|
59
|
+
- Use one comment per distinct issue (or a multi-line range if necessary).
|
|
60
|
+
- Use \`\`\`suggestion blocks ONLY for concrete replacement code (minimal lines; no commentary inside the block).
|
|
61
|
+
- In every \`\`\`suggestion block, preserve the exact leading whitespace of the replaced lines (spaces vs tabs, number of spaces).
|
|
62
|
+
- Do NOT introduce or remove outer indentation levels unless that is the actual fix.
|
|
63
|
+
|
|
64
|
+
The comments will be presented in the code review as inline comments. You should avoid providing unnecessary location details in the comment body. Always keep the line range as short as possible for interpreting the issue. Avoid ranges longer than 5–10 lines; instead, choose the most suitable subrange that pinpoints the problem.
|
|
65
|
+
|
|
66
|
+
At the beginning of the finding title, tag the bug with priority level. For example "[P1] Un-padding slices along wrong tensor dimensions". [P0] – Drop everything to fix. Blocking release, operations, or major usage. Only use for universal issues that do not depend on any assumptions about the inputs. · [P1] – Urgent. Should be addressed in the next cycle · [P2] – Normal. To be fixed eventually · [P3] – Low. Nice to have.
|
|
67
|
+
|
|
68
|
+
Additionally, include a numeric priority field in the JSON output for each finding: set "priority" to 0 for P0, 1 for P1, 2 for P2, or 3 for P3. If a priority cannot be determined, omit the field or use null.
|
|
69
|
+
|
|
70
|
+
At the end of your findings, output an "overall correctness" verdict of whether or not the patch should be considered "correct".
|
|
71
|
+
Correct implies that existing code and tests will not break, and the patch is free of bugs and other blocking issues.
|
|
72
|
+
Ignore non-blocking issues such as style, formatting, typos, documentation, and other nits.
|
|
73
|
+
|
|
74
|
+
FORMATTING GUIDELINES:
|
|
75
|
+
The finding description should be one paragraph.
|
|
76
|
+
|
|
77
|
+
OUTPUT: You MUST submit your review by calling the \`submit_review\` tool exactly once with the complete structured review. Do NOT output the review as plain text — the tool enforces the required schema.`;
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* Build the ralph-specific reviewer `CustomAgentConfig`.
|
|
81
|
+
*
|
|
82
|
+
* Pass the session-level custom tool name(s) (e.g. `"submit_review"`) via
|
|
83
|
+
* `submitReviewToolName` so the reviewer subagent's tool allowlist
|
|
84
|
+
* includes it. Session-level tools named here are visible to the subagent;
|
|
85
|
+
* omitted names are filtered out.
|
|
86
|
+
*/
|
|
87
|
+
export function buildRalphReviewerAgent(
|
|
88
|
+
submitReviewToolName: string,
|
|
89
|
+
): CustomAgentConfig {
|
|
90
|
+
return {
|
|
91
|
+
name: "reviewer",
|
|
92
|
+
displayName: "reviewer",
|
|
93
|
+
description: "Code reviewer for proposed code changes.",
|
|
94
|
+
tools: [
|
|
95
|
+
"execute",
|
|
96
|
+
"agent",
|
|
97
|
+
"search",
|
|
98
|
+
"read",
|
|
99
|
+
"web_fetch",
|
|
100
|
+
"sql",
|
|
101
|
+
submitReviewToolName,
|
|
102
|
+
],
|
|
103
|
+
prompt: REVIEWER_PROMPT,
|
|
104
|
+
};
|
|
105
|
+
}
|
|
@@ -29,6 +29,19 @@ function enabledServersFor(scm: ScmProvider): Set<ScmMcpServer> {
|
|
|
29
29
|
return new Set();
|
|
30
30
|
}
|
|
31
31
|
|
|
32
|
+
/**
|
|
33
|
+
* Copilot CLI servers to disable per scm selection. Copilot ships with a
|
|
34
|
+
* built-in `github-mcp-server`; when scm is `github` the user's own
|
|
35
|
+
* `github` MCP is redundant with it, so we keep the built-in and disable
|
|
36
|
+
* the user's. For `azure-devops` we keep the user's `azure-devops` and
|
|
37
|
+
* disable both GitHub variants. Sapling disables everything.
|
|
38
|
+
*/
|
|
39
|
+
const COPILOT_DISABLE_BY_SCM: Record<ScmProvider, readonly string[]> = {
|
|
40
|
+
github: ["github", "azure-devops"],
|
|
41
|
+
"azure-devops": ["github", "github-mcp-server"],
|
|
42
|
+
sapling: ["github", "azure-devops", "github-mcp-server"],
|
|
43
|
+
};
|
|
44
|
+
|
|
32
45
|
/**
|
|
33
46
|
* Pure helper: returns the `--disable-mcp-server <name>` flag sequence to
|
|
34
47
|
* append when spawning Copilot CLI, given a selected scm provider.
|
|
@@ -39,11 +52,9 @@ function enabledServersFor(scm: ScmProvider): Set<ScmMcpServer> {
|
|
|
39
52
|
*/
|
|
40
53
|
export function copilotScmDisableFlags(scm: ScmProvider | undefined): string[] {
|
|
41
54
|
if (!scm) return [];
|
|
42
|
-
const
|
|
55
|
+
const names = COPILOT_DISABLE_BY_SCM[scm] ?? [];
|
|
43
56
|
const flags: string[] = [];
|
|
44
|
-
for (const name of
|
|
45
|
-
if (!enabled.has(name)) flags.push("--disable-mcp-server", name);
|
|
46
|
-
}
|
|
57
|
+
for (const name of names) flags.push("--disable-mcp-server", name);
|
|
47
58
|
return flags;
|
|
48
59
|
}
|
|
49
60
|
|