Skip to content

Commit d36b653

Browse files
authored
Merge branch 'main' into conservation_metrics_blog_post
2 parents bbda43d + c1adfcc commit d36b653

File tree

28 files changed

+797
-727
lines changed

28 files changed

+797
-727
lines changed

.cursor/rules/docs.mdc

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,52 +3,58 @@ description:
33
globs: docs/*
44
alwaysApply: false
55
---
6-
# Cursor Rules for Windmill Documentation
6+
# Cursor rules for Windmill documentation
77

88
These guidelines ensure consistency and quality when writing or modifying Windmill documentation.
99

10-
## File Structure and Naming
10+
## Content
11+
- The doc should focus on the user experience, not on the engineering behind it, unless it's important (e.g. feature related to performance)
12+
13+
## File structure and naming
1114

1215
- Use `.mdx` extension for documentation files
1316
- Main section pages should be named `index.mdx`
1417
- Folders should follow numeric prefixing for ordering (e.g., `0_scripts_quickstart`, `1_typescript_quickstart`)
1518
- Use underscores to separate words in file and folder names
1619

17-
## Markdown Formatting
20+
## Markdown formatting
1821

19-
- Start each main page with appropriate frontmatter (title and slug)
2022
- Use proper heading hierarchy (# for main title, ## for sections, etc.)
2123
- Include relevant imports at the top of the file
2224
- Use code blocks with appropriate language specification (`ts, `python, etc.)
25+
- Avoid bold font, unless already used in the document
26+
- Titles, subtiles and docs in general follow sentence case ('Like this')
2327

24-
## Component Usage
28+
## Component usage
2529

2630
- Import and use DocCard components for navigation links
2731
- Follow the grid layout pattern for card navigation (typically 2 columns)
28-
- Include appropriate icons when using DocCard components
2932
- Use video elements with proper className for tutorials
3033

31-
## Media and Assets
34+
## Media and assets
3235

3336
- Store images in the same directory as the related MDX file
3437
- Include both PNG and optimized WebP versions of images
3538
- Use meaningful names for image files that describe their content
3639
- Apply proper className to media elements for consistent styling
40+
- If a file / illustration / video would be useful but you don't have it, add a placeholder in comment to the file
3741

38-
## Content Organization
42+
## Content organization
3943

4044
- Each major feature has its own directory
4145
- Content progresses from basic to advanced concepts
4246
- Quickstart guides should be concise and focused on immediate results
4347
- Link to related documentation using relative paths
48+
- If a new page is added, make sure it appears in sidebars.js and check if its worth adding to core_concepts/index.mdx
4449

45-
## Cross-Referencing
50+
## Cross-referencing
4651

4752
- Use relative paths for internal links (e.g., `../../8_triggers/index.mdx`)
48-
- Include "Related Documents" sections using DocCard components
53+
- Reference to useful pages using DocCard components
4954
- Maintain consistent linking patterns throughout documentation
55+
- Also when adding a feature, you can reference its dedicated page from related pages, using backink
5056

51-
## Code Examples
57+
## Code examples
5258

5359
- Include complete, working code examples that can be copied directly
5460
- Add explanatory comments to complex code sections
@@ -57,6 +63,6 @@ These guidelines ensure consistency and quality when writing or modifying Windmi
5763

5864
## Metadata and SEO
5965

60-
- Include appropriate frontmatter with title and slug
66+
- URLs are derived from the file or folder name
6167
- Use descriptive titles that include keywords
62-
- Keep URLs clean and descriptive
68+
- If a new page is to be created, keep URLs clean and descriptive

.github/workflows/aider-after-review.yaml

Lines changed: 60 additions & 184 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,40 @@ on:
55
types: [submitted]
66

77
jobs:
8-
auto-fix-review:
8+
check-membership:
99
if: github.event.review.state == 'changes_requested' && contains(github.event.pull_request.title, '[Aider PR]')
10-
runs-on: ubicloud-standard-8
10+
runs-on: ubicloud-standard-2
11+
outputs:
12+
is_member: ${{ steps.check-membership.outputs.is_member }}
13+
steps:
14+
- name: Check organization membership
15+
id: check-membership
16+
env:
17+
REVIEWER: ${{ github.event.review.user.login }}
18+
ORG_ACCESS_TOKEN: ${{ secrets.ORG_ACCESS_TOKEN }}
19+
run: |
20+
ORG="windmill-labs"
21+
STATUS=$(curl -s -o /dev/null -w "%{http_code}" \
22+
-H "Authorization: token $ORG_ACCESS_TOKEN" \
23+
-H "Accept: application/vnd.github+json" \
24+
-H "X-GitHub-Api-Version: 2022-11-28" \
25+
"https://api.github.com/orgs/$ORG/members/$REVIEWER")
26+
27+
if [ "$STATUS" -eq 204 ]; then
28+
echo "is_member=true" >> $GITHUB_OUTPUT
29+
else
30+
echo "is_member=false" >> $GITHUB_OUTPUT
31+
fi
32+
33+
check-and-prepare:
34+
needs: check-membership
35+
if: github.event.review.state == 'changes_requested' && contains(github.event.pull_request.title, '[Aider PR]') && needs.check-membership.outputs.is_member == 'true'
36+
runs-on: ubicloud-standard-2
1137
permissions:
1238
contents: write
1339
pull-requests: write
40+
outputs:
41+
prompt_content: ${{ steps.prepare_prompt.outputs.prompt_content }}
1442
env:
1543
GEMINI_API_KEY: ${{ secrets.GOOGLE_API_KEY }}
1644
GOOGLE_API_KEY: ${{ secrets.GOOGLE_API_KEY }}
@@ -19,198 +47,46 @@ jobs:
1947
WINDMILL_TOKEN: ${{ secrets.WINDMILL_TOKEN }}
2048

2149
steps:
22-
- name: Harden Runner
23-
uses: step-security/harden-runner@v2
24-
with:
25-
egress-policy: audit
26-
27-
- name: Check out code
28-
uses: actions/checkout@v4
29-
with:
30-
fetch-depth: 0
31-
32-
- name: Configure Git User
33-
run: |
34-
git config --global user.name "github-actions[bot]"
35-
git config --global user.email "github-actions[bot]@users.noreply.github.com"
36-
37-
- name: Checkout PR Branch
50+
- name: Acknowledge Request
3851
env:
3952
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
53+
GITHUB_REPOSITORY: ${{ github.repository }}
4054
run: |
41-
echo "PR review trigger: Checking out PR branch..."
42-
PR_NUMBER=${{ github.event.pull_request.number }}
43-
PR_HEAD_REF=$(gh pr view $PR_NUMBER --json headRefName -q .headRefName --repo $GITHUB_REPOSITORY)
44-
if [[ -z "$PR_HEAD_REF" || "$PR_HEAD_REF" == "null" ]]; then
45-
echo "::error::Could not determine PR head branch for PR #$PR_NUMBER via gh CLI."
46-
exit 1
47-
fi
48-
echo "Checking out PR head branch: $PR_HEAD_REF for PR #$PR_NUMBER"
49-
git fetch origin "refs/heads/${PR_HEAD_REF}:refs/remotes/origin/${PR_HEAD_REF}" --no-tags
50-
git checkout "$PR_HEAD_REF"
51-
echo "Successfully checked out branch $(git rev-parse --abbrev-ref HEAD)"
52-
53-
- name: Set up Python
54-
uses: actions/setup-python@v5
55-
with:
56-
python-version: '3.12'
57-
58-
- name: Install Aider and Dependencies
59-
run: |
60-
python -m pip install aider-install; aider-install
61-
pip install -U google-generativeai
62-
sudo apt-get update && sudo apt-get install -y jq
55+
echo "Commenting on PR #${{ github.event.pull_request.number }} to acknowledge the /aider command."
56+
gh pr comment ${{ github.event.pull_request.number }} --body "🤖 Aider is starting to work on your request. Please be patient, this might take a few minutes." --repo $GITHUB_REPOSITORY
6357
64-
- name: Generate Prompt from Review
65-
id: generate_prompt
58+
- name: Prepare prompt for Aider
59+
id: prepare_prompt
6660
shell: bash
61+
env:
62+
GITHUB_REPOSITORY: ${{ github.repository }}
63+
PR_NUMBER: ${{ github.event.pull_request.number }}
64+
REVIEW_BODY: ${{ github.event.review.body }}
6765
run: |
68-
mkdir -p .github/aider
69-
PROMPT_FILE_PATH=".github/aider/review-prompt.txt"
70-
71-
# Get PR review body
72-
REVIEW_BODY="${{ github.event.review.body }}"
73-
REVIEW_BODY_Q=$(printf '%q' "$REVIEW_BODY")
74-
75-
PR_NUMBER="${{ github.event.pull_request.number }}"
76-
77-
# Get PR description for context NOT USED FOR NOW
78-
# PR_DETAILS=$(gh pr view $PR_NUMBER --json title,body --repo $GITHUB_REPOSITORY)
79-
# PR_TITLE=$(echo "$PR_DETAILS" | jq -r .title)
80-
# PR_BODY=$(echo "$PR_DETAILS" | jq -r .body)
66+
REVIEW_BODY_ESCAPED="${REVIEW_BODY//\\/\\\\}"
67+
REVIEW_BODY_ESCAPED="${REVIEW_BODY_ESCAPED//\"/\\\"}"
8168
82-
# Get all PR review comments
8369
ALL_REVIEW_COMMENTS=$(gh api \
8470
-H "Accept: application/vnd.github+json" \
8571
-H "X-GitHub-Api-Version: 2022-11-28" \
86-
/repos/$GITHUB_REPOSITORY/pulls/$PR_NUMBER/comments \
87-
| jq '[.[] | {diff_hunk: .diff_hunk, path: .path, body: .body}]')
88-
89-
BASE_PROMPT="Fix the following issues in the PR based on the review feedback. The review body is prepended with REVIEW. The review comments are prepended with REVIEW_COMMENTS. The review body and comments are separated by a blank line."
90-
COMPLETE_PROMPT=$(printf "%s\nREVIEW:\n%s\nREVIEW_COMMENTS:\n%s" \
91-
"$BASE_PROMPT" "$REVIEW_BODY_Q" "$ALL_REVIEW_COMMENTS")
92-
echo "$COMPLETE_PROMPT" > "$PROMPT_FILE_PATH"
93-
echo "PROMPT_FILE_PATH=$PROMPT_FILE_PATH" >> $GITHUB_OUTPUT
94-
95-
- name: Probe Chat for Relevant Files
96-
id: probe_files
97-
env:
98-
PROMPT_CONTENT_FILE: ${{ steps.generate_prompt.outputs.PROMPT_FILE_PATH }}
99-
run: |
100-
echo "Running probe-chat to find relevant files..."
101-
if [[ ! -f "$PROMPT_CONTENT_FILE" ]]; then
102-
echo "::error::Prompt file $PROMPT_CONTENT_FILE not found!"
103-
exit 1
104-
fi
105-
PROMPT_CONTENT=$(cat "$PROMPT_CONTENT_FILE")
106-
if [ -z "$PROMPT_CONTENT" ]; then
107-
echo "::error::Prompt content is empty!"
108-
exit 1
109-
fi
72+
/repos/$GITHUB_REPOSITORY/pulls/$PR_NUMBER/comments)
11073
111-
PROMPT_ESCAPED=$(jq -Rs . <<< "$PROMPT_CONTENT")
74+
FORMATTED_COMMENTS=$(jq '[.[] | {diff_hunk: .diff_hunk, path: .path, body: .body}]' <<< "$ALL_REVIEW_COMMENTS")
11275
113-
MESSAGE_FOR_PROBE=$(jq -n --arg prompt_escaped "$PROMPT_ESCAPED" \
114-
'{ "message": "I'\''m giving you a request that needs to be implemented. Your role is ONLY to give me the files that are relevant to the request and nothing else. The request is prepended with the word REQUEST.\\nREQUEST: \($prompt_escaped). Give me all the files relevant to this request. Your output MUST be a single json array that can be parsed with programatic json parsing, with the relevant files. Files can be rust or typescript or javascript files. DO NOT INCLUDE ANY OTHER TEXT IN YOUR OUTPUT. ONLY THE JSON ARRAY. Example of output: [\"file1.py\", \"file2.py\"]" }' | jq -r .message)
115-
116-
set -o pipefail
117-
PROBE_OUTPUT=$(npx --yes @buger/probe-chat@latest --max-iterations 50 --model-name gemini-2.5-pro-preview-05-06 --message "$MESSAGE_FOR_PROBE") || {
118-
echo "::error::probe-chat command failed. Output:"
119-
echo "$PROBE_OUTPUT"
120-
exit 1
121-
}
122-
set +o pipefail
123-
echo "Probe-chat raw output:"
124-
echo "$PROBE_OUTPUT"
125-
126-
JSON_FILES=$(echo "$PROBE_OUTPUT" | sed -n '/^\s*\[/,$p' | sed '/^\s*\]/q')
127-
echo "Extracted JSON block:"
128-
echo "$JSON_FILES"
129-
130-
FILES_LIST=$(echo "$JSON_FILES" | jq -e -r '[.[] | select(type == "string" and . != "" and . != null and (endswith("/") | not))] | map(@sh) | join(" ")' || echo "")
131-
132-
if [[ -z "$FILES_LIST" ]]; then
133-
echo "::warning::probe-chat did not identify any relevant files."
134-
exit 1
135-
fi
136-
137-
echo "Formatted files list for aider: $FILES_LIST"
138-
echo "FILES_TO_EDIT=$FILES_LIST" >> $GITHUB_ENV
139-
140-
- name: Run Aider with review prompt
141-
run: |
142-
aider \
143-
--read CLAUDE.md \
144-
${{ env.FILES_TO_EDIT }} \
145-
--model gemini/gemini-2.5-pro-preview-05-06 \
146-
--message-file .github/aider/review-prompt.txt \
147-
--yes \
148-
--no-check-update \
149-
--auto-commits \
150-
--no-analytics \
151-
--no-gitignore \
152-
| tee .github/aider/aider-output.txt || true
153-
echo "Aider command completed. Output saved to .github/aider/aider-output.txt"
154-
# Check if there are any changes to commit
155-
if [[ -z "$(git status --porcelain)" ]]; then
156-
echo "No changes detected after running Aider."
157-
echo "HAS_CHANGES=false" >> $GITHUB_OUTPUT
158-
exit 0
159-
fi
160-
161-
- name: Clean up prompt file
162-
if: always()
163-
run: rm -f .github/aider/review-prompt.txt
164-
165-
- name: Commit and Push Changes
166-
id: commit_and_push
167-
if: ${{ success() }}
168-
run: |
169-
CURRENT_BRANCH_NAME=$(git rev-parse --abbrev-ref HEAD)
170-
echo "Attempting to push changes to PR branch $CURRENT_BRANCH_NAME for PR #${{ github.event.pull_request.number }}"
171-
172-
# Pull latest changes to avoid rejection due to non-fast-forward
173-
git config pull.rebase true
174-
git pull origin $CURRENT_BRANCH_NAME
175-
176-
if git push origin $CURRENT_BRANCH_NAME; then
177-
echo "Push to $CURRENT_BRANCH_NAME successful."
178-
echo "CHANGES_APPLIED=true" >> $GITHUB_OUTPUT
179-
else
180-
echo "::warning::Push to PR branch $CURRENT_BRANCH_NAME failed."
181-
echo "CHANGES_APPLIED=false" >> $GITHUB_OUTPUT
182-
fi
183-
184-
- name: Comment on PR
185-
if: success()
186-
env:
187-
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
188-
PR_NUM: ${{ github.event.pull_request.number }}
189-
run: |
190-
# Create comment body in a temporary file to avoid command line length limits
191-
if [[ "${{ steps.commit_and_push.outputs.CHANGES_APPLIED }}" == "true" ]]; then
192-
cat > /tmp/pr-comment.md << EOL
193-
🤖 I've automatically addressed the feedback based on the review.
194-
195-
## Aider Output
196-
\`\`\`
197-
$(cat .github/aider/aider-output.txt || echo 'No output available')
198-
\`\`\`
199-
200-
Please review the changes and let me know if further adjustments are needed.
201-
EOL
202-
else
203-
cat > /tmp/pr-comment.md << EOL
204-
🤖 I attempted to address the review feedback, but no modifications were made.
205-
206-
## Aider Output
207-
\`\`\`
208-
$(cat .github/aider/aider-output.txt || echo 'No output available')
209-
\`\`\`
210-
211-
Please review the output and provide additional guidance if needed.
212-
EOL
213-
fi
76+
BASE_PROMPT="Fix the following issues in the PR based on the review feedback. The review body is prepended with REVIEW. The review comments are prepended with REVIEW_COMMENTS. The review body and comments are separated by a blank line."
21477
215-
# Use the file for comment body
216-
gh pr comment $PR_NUM --body-file /tmp/pr-comment.md
78+
COMPLETE_PROMPT="${BASE_PROMPT}"$'\n'"REVIEW:"$'\n'"${REVIEW_BODY_ESCAPED}"$'\n'"REVIEW_COMMENTS:"$'\n'"${FORMATTED_COMMENTS}"
79+
80+
echo "prompt_content<<EOF" >> $GITHUB_OUTPUT
81+
echo "$COMPLETE_PROMPT" >> $GITHUB_OUTPUT
82+
echo "EOF" >> $GITHUB_OUTPUT
83+
84+
run-aider:
85+
needs: [check-membership, check-and-prepare]
86+
if: github.event.review.state == 'changes_requested' && contains(github.event.pull_request.title, '[Aider PR]') && needs.check-membership.outputs.is_member == 'true'
87+
uses: windmill-labs/windmill/.github/workflows/aider-common.yml@main
88+
with:
89+
needs_processing: false
90+
base_prompt: ${{ needs.check-and-prepare.outputs.prompt_content }}
91+
rules_files: 'CLAUDE.md'
92+
secrets: inherit

0 commit comments

Comments
 (0)