Skip to content

Commit 969736c

Browse files
run stylecheck (#191)
* don't run both EkLine and stylecheck * modify source file directly if running locally * avoid future * Update style/style-common.md * Update style/style-common.md * instructions for stylecheck * proactively skip suggestions if env vars not set * future and Latin --------- Co-authored-by: Atul-Butola <[email protected]>
1 parent 5d48a57 commit 969736c

File tree

6 files changed

+45
-17
lines changed

6 files changed

+45
-17
lines changed

.github/workflows/ekline.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ on:
88
permissions: write-all
99
jobs:
1010
test-pr-review:
11-
if: github.event_name == 'pull_request' && contains(github.event.pull_request.labels.*.name, 'No EkLine') == false
11+
if: github.event_name == 'pull_request' && !contains(github.event.pull_request.labels.*.name, 'No EkLine') && !contains(github.event.pull_request.labels.*.name, 'stylecheck')
1212
name: runner / EkLine Reviewer (github-pr-review)
1313
runs-on: ubuntu-latest
1414
steps:

README.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,3 +42,18 @@ fern docs dev
4242
### Troubleshooting
4343

4444
If you run into errors, you can add the ` --log-level debug` flag to get more information.
45+
46+
## Stylecheck (Beta)
47+
48+
The `stylecheck.py` script sends a markdown file to Claude Sonnet for revision according to defined style, structure, and terminology rules.
49+
50+
### GitHub action
51+
If a PR has the label `stylecheck` and not the label `stylecheck-complete`, the `stylecheck.py` script runs on any `.md(x)` files changed in the PR. A summary of changes is posted as a comment on the timeline. Suggestions for the diff context are added. If there are any proposed revisions outside the diff context, the full text of the revision is included in the summary comment.
52+
53+
When the action completes, it adds the `stylecheck-complete` tag. If you want stylecheck to run on new changes on a PR where it has already run, remove the `stylecheck-complete` label before pushing the new changes.
54+
55+
### Local execution
56+
To run the script locally and not as part of a PR, set your environment variable `LLM_TOKEN` to your PAT from [OpenWebUI](https://openwebui.dev.devrev-eng.ai/) > **Settings** > **Account** > API Keys. Include the supplemental developer style rules with the `--style` option.
57+
```
58+
python stylecheck.py --style=style/developer.md <path/to/file.mdx>
59+
```

llm_client.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
def get_response(prompt):
66

7-
auth = os.environ.get('LLM_JWT')
7+
auth = os.environ.get('LLM_TOKEN')
88
if auth:
99
headers = {"Content-Type": "application/json", "Authorization": f"Bearer {auth}"}
1010
payload = {

style/sample-common.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
# DataDog Snap-in
22

3-
This integration links Datadog's monitoring system with Devrev's incident management, simplifying the process of managing RevOrg incidents triggered by Datadog alerts. It automatically generates new incidents and updates existing incidents in DevRev using data from Datadog, allowing your organisation to address issues efficiently without manual tracking.
3+
This integration links Datadog's monitoring system with Devrev's incident management, simplifying the process of managing RevOrg incidents triggered by Datadog alerts e.g. system failures etc. It automatically generates new incidents and updates existing incidents in DevRev using data from Datadog, allowing your organisation to address issues efficiently without manual tracking.
44

55
### System Features
66

7-
- Automated Incident Creation: When an incident is triggered in Datadog, the snap-in automatically creates a corresponding incident in DevRev.
7+
- Automated Incident Creation: When an incident is triggered in Datadog, the snap-in will automatically create a corresponding incident in DevRev.
88
- Automated Incident Updation: When an incident is updated in Datadog, the changes are reflected in DevRev.
99
- Real-time Synchronization: The snap-in ensures that incidents are created or updated in real-time, reducing delays between detection and resolution. DevRev captures the necessary incident details from the Datadog payload, allowing teams to address and mitigate issues.
1010
- Seamless integration: The snap-in is built to streamline workflows, minimizing the need for manual intervention.

style/style-common.md

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
## Rules
22

3-
For the writing style, apply the following descriptive keywords to analyzing the draft document:
3+
For the writing style, apply the following descriptive keywords to revising the draft document:
44

55
- Writing style: authoritative, comprehensive, helpful
66
- Sentence structure: varied, complex, cohesive
@@ -14,13 +14,14 @@ There are also some very specific style rules that need to be followed:
1414
- Use sentence case (only capitalize the first word and proper nouns) in any type of heading, including in two-level lists.
1515
- Ensure that any list is in parallel structure (use the same syntax for every entry).
1616
- Instructions or how-to guides:
17-
- They may use two levels; both should be ordered (numbered) lists, not unordered (bulleted).
17+
- They may use two levels; both should be ordered (numbered) lists, not unordered (bulleted) lists.
1818
- Instructions should be in imperative mood.
19-
- If there is a location or condition in a step, it should be at the front of the sentence, which must still be in imperative.
20-
- Steps should be more than a single click; combine steps if needed to make them more meaningful.
19+
- If there is a location or condition in a step, it should be at the front of the main clause, which must still be in imperative mood.
20+
- Steps should be more than a single "click"; combine steps if needed to make them more meaningful. If there is an outcome of the step stated, it should be part of the same step, not a new step.
2121
- End each list item with a period or other appropriate sentence-ending punctuation, except in the following cases:
2222
- If the item consists of a single word, don't add end punctuation.
2323
- If the item doesn't include a verb, don't add end punctuation.
2424
- If the item is entirely in code font, don't add end punctuation.
2525
- If the item is entirely link text or a document title, don't add end punctuation.
26-
- Titles of instructions or how-to guides should be a verb in the infinitive form without “to”, not a gerund (ending in -ing). Titles of any other type of section should be noun phrases.
26+
- Titles of instructions or how-to guides should be a verb in the infinitive form without “to”, not a gerund (ending in -ing). Titles of any other type of section should be noun phrases.
27+
- Avoid future tense when describing the behavior of the product. Use simple present instead.

stylecheck.py

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,8 @@ def gen_prompt(args):
6565
prompt += "\n\n"
6666

6767
with open('style/term-common.csv', 'r', encoding="utf-8") as infile:
68-
prompt += "\n\n<terminology>\n"
69-
prompt += infile.read()
68+
prompt += "\n\n<terminology>\n"
69+
prompt += infile.read()
7070

7171
if args.term and os.path.exists(args.term):
7272
with open(args.style, 'r', encoding="utf-8") as infile:
@@ -172,10 +172,18 @@ def main(args):
172172
print(f"Checking style for {args.doc}")
173173
doc_name, ext = os.path.splitext(os.path.basename(args.doc))
174174

175+
required_vars = ['REPO_OWNER', 'REPO_NAME', 'PR_NUMBER']
176+
missing_vars = [var for var in required_vars if not os.environ.get(var)]
177+
if args.suggest and missing_vars:
178+
print(f"Skipping pull request suggestions. Missing required environment variables: {', '.join(missing_vars)}")
179+
args.suggest = False
180+
175181
prompt = gen_prompt(args)
176182
my_writer(prompt, f"temp/{doc_name}_prompt.md", 'prompt')
183+
177184
response_file = f"temp/{doc_name}_response.md"
178185
if args.llm:
186+
print("Requesting revision from LLM.")
179187
response = llm_client.get_response(prompt)
180188
my_writer(response, response_file, 'response')
181189
else:
@@ -190,15 +198,19 @@ def main(args):
190198
comment_text = "✨ Comment from AI reviewer ✨\n\n" + comment_text
191199
revision = llm_client.get_lines_between_tags(response, 'document')
192200
revision = restore_title(args.doc, revision)
193-
revision_file = f"temp/{doc_name}_revision{ext}"
201+
202+
if args.suggest:
203+
revision_file = f"temp/{doc_name}_revision{ext}"
204+
else:
205+
revision_file = args.doc
194206
my_writer(revision, revision_file, 'revision')
195-
diff = create_line_diff(args.doc, revision_file)
196-
my_writer(diff, f"temp/{doc_name}.diff", 'diff')
197207

198-
suggestions = parse_diff_hunks(diff)
199-
my_writer(suggestions, f"temp/{doc_name}_suggestions.json", 'suggestions')
200-
failures = 0
201208
if (args.suggest):
209+
diff = create_line_diff(args.doc, revision_file)
210+
my_writer(diff, f"temp/{doc_name}.diff", 'diff')
211+
suggestions = parse_diff_hunks(diff)
212+
my_writer(suggestions, f"temp/{doc_name}_suggestions.json", 'suggestions')
213+
failures = 0
202214
for suggestion in suggestions:
203215
time.sleep(1)
204216
failures += post_review_comment(suggestion)

0 commit comments

Comments
 (0)