Semantic Function Clustering¶
Analyze code for semantic function clustering and refactoring opportunities.
How it works¶
Scans source files (by language or custom glob) to find semantically related functions that live in different files, duplicate implementations of the same logic, and functions that belong in a different module. Files a report with specific refactoring recommendations.
Quick Install¶
mkdir -p .github/workflows && curl -sL \
https://raw.githubusercontent.com/elastic/ai-github-actions/v0/gh-agent-workflows/semantic-function-clustering/example.yml \
-o .github/workflows/semantic-function-clustering.yml
Trigger¶
| Event | Schedule |
|---|---|
schedule |
Weekdays |
workflow_dispatch |
Manual |
Inputs¶
| Input | Description | Required | Default |
|---|---|---|---|
languages |
Comma-separated languages to analyze (ignored if file-globs is set) |
No | "go" |
file-globs |
Comma-separated file globs to analyze (overrides languages) |
No | "" |
additional-instructions |
Repo-specific instructions appended to the agent prompt | No | "" |
setup-commands |
Shell commands run before the agent starts | No | "" |
allowed-bot-users |
Allowlisted bot actor usernames (comma-separated) | No | github-actions[bot] |
Safe Outputs¶
create-issue— file a refactoring report (max 1, auto-closes older reports)
Example Workflow¶
name: Semantic Function Clustering
on:
schedule:
- cron: "0 12 * * 1-5"
workflow_dispatch:
permissions:
contents: read
issues: write
pull-requests: read
jobs:
run:
uses: elastic/ai-github-actions/.github/workflows/gh-aw-semantic-function-clustering.lock.yml@v0
with:
languages: "go,python,typescript"
secrets:
COPILOT_GITHUB_TOKEN: ${{ secrets.COPILOT_GITHUB_TOKEN }}