|
3 | 3 | """ |
4 | 4 |
|
5 | 5 | RULE_FEASIBILITY_PROMPT = """ |
6 | | -You are an expert in Watchflow rules and GitHub automation. Analyze whether a natural language rule description is feasible to implement using Watchflow. |
| 6 | +You are an expert in Watchflow rules and GitHub automation. Analyze whether a natural language rule description is feasible to implement using Watchflow’s existing validator catalog. Do NOT invent custom logic; choose from the provided validators. If none fit, mark as not feasible. |
7 | 7 |
|
8 | | -Rule Description: {rule_description} |
| 8 | +Rule Description: |
| 9 | +{rule_description} |
9 | 10 |
|
10 | | -Analyze this rule and determine: |
11 | | -1. Is it feasible to implement with Watchflow's rule system? |
12 | | -2. What type of rule is it? |
13 | | -3. Provide concise feedback on implementation considerations |
| 11 | +Available validators (name, event_types, parameter_patterns, description): |
| 12 | +{validator_catalog} |
14 | 13 |
|
15 | | -Available rule types: |
16 | | -- label_requirement: Rules requiring specific labels |
17 | | -- time_restriction: Rules about when actions can occur (weekends, hours, days) |
18 | | -- approval_requirement: Rules about required approvals |
19 | | -- title_pattern: Rules about PR title formatting |
20 | | -- branch_pattern: Rules about branch naming conventions |
21 | | -- file_size: Rules about file size limits |
22 | | -- commit_message: Rules about commit message format |
23 | | -- branch_protection: Rules about protected branches |
24 | | -
|
25 | | -Focus on: |
26 | | -- Practical implementation with Watchflow |
27 | | -- Key configuration considerations |
28 | | -- Severity and enforcement level recommendations |
29 | | -- Keep feedback under 150 words |
| 14 | +Decide: |
| 15 | +1) is_feasible (true/false) |
| 16 | +2) rule_type (short label you infer) |
| 17 | +3) chosen_validators (list of validator names from the catalog that can implement this rule; empty if not feasible) |
| 18 | +4) feedback (practical, under 120 words) |
| 19 | +5) analysis_steps (succinct bullets) |
30 | 20 | """ |
31 | 21 |
|
32 | 22 | YAML_GENERATION_PROMPT = """ |
33 | | -Generate a complete Watchflow rule configuration for the following rule: |
| 23 | +Generate a complete Watchflow rules.yaml for the rule below using ONLY the selected validators. Do not introduce parameters that the chosen validators do not support. |
34 | 24 |
|
35 | 25 | Rule Type: {rule_type} |
36 | 26 | Description: {rule_description} |
| 27 | +Chosen Validators: {chosen_validators} |
37 | 28 |
|
38 | | -Generate a complete rules.yaml file that follows this EXACT structure: |
39 | | -
|
| 29 | +Rules YAML format: |
40 | 30 | ```yaml |
41 | 31 | rules: |
42 | | - - description: "Clear description of what this rule does" |
| 32 | + - description: "<concise description>" |
43 | 33 | enabled: true |
44 | 34 | severity: "medium" |
45 | 35 | event_types: ["pull_request"] |
46 | 36 | parameters: |
47 | | - required_labels: ["security", "review"] |
| 37 | + <validator-appropriate-parameters> |
48 | 38 | ``` |
49 | 39 |
|
50 | | -IMPORTANT REQUIREMENTS: |
51 | | -- Generate the COMPLETE rules.yaml file including the "rules:" wrapper |
52 | | -- Use the rule description as the primary identifier |
53 | | -- Include enabled: true (allows rule activation/deactivation) |
54 | | -- Set appropriate severity (low, medium, high, critical) |
55 | | -- Include relevant event_types |
56 | | -- Add correct parameters based on rule type |
57 | | -- For regex patterns, use single quotes to avoid YAML parsing issues |
58 | | -
|
59 | | -Rule type parameters: |
60 | | -- label_requirement: use "required_labels" with array of labels |
61 | | -- time_restriction: use "days" for restricted days or "allowed_hours" for restricted hours |
62 | | -- approval_requirement: use "min_approvals" with number |
63 | | -- title_pattern: use "title_pattern" with regex pattern (use single quotes for regex) |
64 | | -- file_size: use "max_file_size_mb" with number |
65 | | -- commit_message: use "pattern" with regex pattern (use single quotes for regex) |
66 | | -- branch_protection: use "protected_branches" with array of branch names |
67 | | -
|
68 | | -Examples of proper regex patterns: |
69 | | -- title_pattern: '^feat|^fix|^docs' # Use single quotes |
70 | | -- pattern: '^[A-Z]+-\\d+' # Use single quotes for regex |
71 | | -
|
72 | | -Return the complete YAML file content. |
| 40 | +Guidelines: |
| 41 | +- Keep severity appropriate (low/medium/high/critical). |
| 42 | +- event_types must align with the validators chosen. |
| 43 | +- For regex, use single quotes. |
| 44 | +- If no validators fit, return an empty yaml_content. |
| 45 | +Return only the YAML content. |
73 | 46 | """ |
0 commit comments