-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Expand file tree
/
Copy pathralph-adapter.ts
More file actions
110 lines (84 loc) · 2.95 KB
/
ralph-adapter.ts
File metadata and controls
110 lines (84 loc) · 2.95 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
/**
* RALPH Stage Adapter
*
* Wraps the existing ralph verification module into the pipeline stage adapter interface.
*
* The ralph stage performs iterative verification of the implementation:
* - Functional completeness review
* - Security review
* - Code quality review
* - Fixes issues found and re-verifies
*/
import type { PipelineStageAdapter, PipelineConfig, PipelineContext } from '../pipeline-types.js';
export const RALPH_COMPLETION_SIGNAL = 'PIPELINE_RALPH_COMPLETE';
export const ralphAdapter: PipelineStageAdapter = {
id: 'ralph',
name: 'Verification (RALPH)',
completionSignal: RALPH_COMPLETION_SIGNAL,
shouldSkip(config: PipelineConfig): boolean {
return config.verification === false;
},
getPrompt(context: PipelineContext): string {
const specPath = context.specPath || '.omc/autopilot/spec.md';
const maxIterations = context.config.verification !== false
? context.config.verification.maxIterations
: 100;
return `## PIPELINE STAGE: RALPH (Verification)
Verify the implementation against the specification using the Ralph verification loop.
**Max Iterations:** ${maxIterations}
### Verification Process
Spawn parallel verification reviewers:
Each reviewer must return ONLY a concise review summary under 100 words covering verdict, evidence highlights, files checked, and blockers. Avoid dumping long logs or transcripts into the main session.
\`\`\`
// Functional Completeness Review
Task(
subagent_type="oh-my-claudecode:architect",
model="opus",
prompt="FUNCTIONAL COMPLETENESS REVIEW
Read the original spec at: ${specPath}
Verify:
1. All functional requirements are implemented
2. All non-functional requirements are addressed
3. All acceptance criteria from the plan are met
4. No missing features or incomplete implementations
Verdict: APPROVED (all requirements met) or REJECTED (with specific gaps)"
)
// Security Review
Task(
subagent_type="oh-my-claudecode:security-reviewer",
model="opus",
prompt="SECURITY REVIEW
Check the implementation for:
1. OWASP Top 10 vulnerabilities
2. Input validation and sanitization
3. Authentication/authorization issues
4. Sensitive data exposure
5. Injection vulnerabilities (SQL, command, XSS)
6. Hardcoded secrets or credentials
Verdict: APPROVED (no vulnerabilities) or REJECTED (with specific issues)"
)
// Code Quality Review
Task(
subagent_type="oh-my-claudecode:code-reviewer",
model="opus",
prompt="CODE QUALITY REVIEW
Review the implementation for:
1. Code organization and structure
2. Design patterns and best practices
3. Error handling completeness
4. Test coverage adequacy
5. Maintainability and readability
Verdict: APPROVED (high quality) or REJECTED (with specific issues)"
)
\`\`\`
### Fix and Re-verify Loop
If any reviewer rejects:
1. Collect all rejection reasons
2. Fix each issue identified
3. Re-run verification (up to ${maxIterations} iterations)
### Completion
When all reviewers approve:
Signal: ${RALPH_COMPLETION_SIGNAL}
`;
},
};