diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 5b1e8df..1810ef9 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -23,8 +23,8 @@ "ghcr.io/devcontainers-contrib/features/starship:1": {}, // https://github.com/devcontainers/features/blob/main/src/dotnet/README.md "ghcr.io/devcontainers/features/dotnet:2": { - "version": "9.0", - "additionalVersions": "8.0" + "version": "10.0", + "additionalVersions": "9.0,8.0" } }, "overrideFeatureInstallOrder": [ diff --git a/.github/copilot-instructions.md b/.github/copilot-instructions.md index 8690c43..e30222f 100644 --- a/.github/copilot-instructions.md +++ b/.github/copilot-instructions.md @@ -1,10 +1,75 @@ -We prefer the latest F# 9 features over the old syntax +# Copilot Instructions -Prefer `voption` over `option` +## Project Details -Prefer `task` CE over `async` CE +* .NET SDK pinned in #file:'global.json' +* Common parameters specified in #file:'Directory.Build.props' +* Central NuGet package version management – versions go in #file:'Directory.Packages.props', not in `.fsproj` files +* Build: `dotnet build FSharp.Azure.Cosmos.slnx` +* Test: `dotnet test FSharp.Azure.Cosmos.slnx` (requires Azure Cosmos DB Emulator – see below) + +## Solution Structure + +```text +/ +├── src/Cosmos/ – main library (FSharp.Azure.Cosmos) +│ ├── Cosmos.fs – core types and container extensions +│ ├── Create.fs – item creation operations +│ ├── Read.fs – single-item read operations +│ ├── ReadMany.fs – multi-item read operations +│ ├── Replace.fs – item replace operations +│ ├── Upsert.fs – item upsert operations +│ ├── Patch.fs – item patch operations +│ ├── Delete.fs – item delete operations +│ ├── CosmosResponse.fs – response type wrappers +│ ├── TaskSeq.fs – TaskSeq integration +│ └── UniqueKey.fs – unique key helpers +├── tests/Cosmos.Tests/ – MSTest integration test project +├── build/ – FAKE build scripts +└── docsSrc/ – FSharp.Formatting documentation source +``` + +## Libraries in Use + +* [`Microsoft.Azure.Cosmos`](https://github.com/Azure/azure-cosmos-dotnet-v3) – Azure Cosmos DB SDK v3 +* [`FSharp.Control.TaskSeq`](https://github.com/fsprojects/FSharp.Control.TaskSeq) – `IAsyncEnumerable` / `taskSeq` support +* [`FSharp.Control.Reactive`](https://github.com/fsprojects/FSharp.Reactive) – Rx extensions for F# +* [`FsToolkit.ErrorHandling`](https://github.com/demystifyfp/FsToolkit.ErrorHandling) – `taskResult`, `Result`, `voption` CEs +* [`Unquote`](https://github.com/SwensenSoftware/unquote) – test assertions +* [`MSTest`](https://github.com/microsoft/testfx) – test framework + +Use GitHub MCP tools for code search in these repositories when needed. + +## F# Coding Guidelines + +### Language Preferences + +* Always use the latest F# 10 features over old syntax. +* Prefer `voption` over `option`. +* Prefer `task` CE over `async` CE. +* Prefer underscore lambda syntax like `Seq.map _.Name` over `Seq.map (fun x -> x.Name)`, but only when the expression is a simple member access. Complex expressions like `Seq.where (fun x -> x.Name = name)` or `Seq.map (fun x -> x.Field1, x.Field2)` cannot be simplified. +* Simplify `Seq.map (fun x -> someFunction x)` to `Seq.map someFunction`. +* When pipe operators are used on a materializable collection multiple times in a row, prefer `Seq` module for the chain and materialize at the end. +* Prefer interpolated strings over `printf` functions for string formatting. +* Use `withNull` for null checks instead of boxing delegates/functions (avoid `isNull (box value)`). + +### Nullable Reference Types + +* Declare variables non-nullable; check for `null` at entry points only. +* Trust the SDK null annotations – do not add null checks when the type system says a value cannot be null. +* Prefer `match` on `null` over `if isNull`: + + ```fsharp + // Preferred + match someObject with + | null -> () + | someObject -> someObject.SomeProperty + ``` + +### Class Constructors + +This is how to define a non-default F# class constructor: -This is how you define a non-default F# class constructor: ```fsharp type DerivedClass = inherit BaseClass @@ -24,10 +89,13 @@ type DerivedClass = val mutable otherField : FieldType ``` +### Class Instantiation + Always prefer F# class initializers over property assignment! **You absolutely must use F# class initializers instead of property assignment**! Class declaration: -``` F# + +```fsharp type MyClass (someConstructorParam : string) = member ReadOnlyProperty = someConstructorParam @@ -36,14 +104,16 @@ type MyClass (someConstructorParam : string) = ``` Wrong: -``` F# + +```fsharp let myClass = MyClass("some value") myClass.MutableProperty1 <- "new value" myClass.MutableProperty2 <- "new value" ``` Right: -``` F# + +```fsharp let myClass = MyClass( // constructor parameters go first without names @@ -55,3 +125,47 @@ let myClass = (5 |> string) ) ``` + +### C#-Consumable Extension Members + +```fsharp +// AutoOpen makes the module automatically available without an explicit open statement +// Extension makes the members visible to C# +[] +module MyTypeExtensions = + + type MyType with + + // Extension is visible to C# + // CompiledName makes the method name friendly to C# + [] + member this.ExtensionMethod (param1 : string) : ReturnType = + () +``` + +## Naming Conventions + +* Use PascalCase for modules, types, and public members. +* Use camelCase for `let` bindings, functions, private fields, and local variables. +* Prefix interface names with `I` (e.g., `ICosmosContext`). +* Do not prefix type parameters with `T` (e.g., use `'Result` instead of `'TResult`). + +## Testing + +* Tests use MSTest 4. +* Integration tests run against the **Azure Cosmos DB Emulator**. +* The emulator must be running locally or installed via the `copilot-setup-steps.yml` workflow. +* Emulator endpoint: `https://127.0.0.1:8081` +* Emulator primary key: `C2y6yDjf5/R+ob0N8A7Cgv30VRDJIWEHLM+4QDU5DE2nQ9nDuVTqobD4b8mGGyPMbIZnqyMsEcaGQy67XIw/Jw==` +* `CollectionAssert` cannot work with F# lists – use F# array syntax (`[| ... |]`) instead. +* Use Unquote only for complex object/hierarchy assertions; for simple scalar checks prefer standard `Assert.*` APIs. +* Every `Assert.*` call **must include a failure message** so output is self-explanatory. +* Async tests must return `Task`, not `Async` or `Task` – always declare `) : Task = task {`. + +## General + +* Make only high-confidence suggestions when reviewing code changes. +* Write code with good maintainability practices, including comments on why certain design decisions were made. +* Handle edge cases and write clear exception handling. +* Never duplicate code unless explicitly allowed. +* All comments, documentation, README files, and markdown files must be written in **English only**. diff --git a/.github/prompts/create-pr-description.prompt.md b/.github/prompts/create-pr-description.prompt.md new file mode 100644 index 0000000..d5e52da --- /dev/null +++ b/.github/prompts/create-pr-description.prompt.md @@ -0,0 +1,53 @@ +--- +mode: agent +description: Generates a pull request description for FSharp.Azure.Cosmos by analyzing the current branch's changes and filling in the project's PR template. +--- + +# Create PR Description + +## Context + +#file:'.github/PULL_REQUEST_TEMPLATE.md' + +> If the `#file:` reference above cannot be resolved, run `Get-Content .github/PULL_REQUEST_TEMPLATE.md` in PowerShell from the repository root to read the template. + +## Task + +Analyze the current branch's git diff and commit history relative to the remote base branch (`origin/main`), then produce a fully filled-in PR description that conforms to the project's `PULL_REQUEST_TEMPLATE.md`. + +## Steps + +1. Read `#file:'.github/PULL_REQUEST_TEMPLATE.md'` to identify the exact section structure, checkbox labels, and required ordering. +2. Run `git diff origin/main...HEAD --stat`, `git diff origin/main...HEAD`, and `git log origin/main...HEAD --oneline` to determine exactly what changed in the current branch. +3. Fill `## Proposed Changes` with a concise 3–6 sentence summary of the concrete behavior, API, test, or documentation changes visible in the diff. +4. Set `## Types of changes` checkboxes strictly from evidence in commits and diff: + - mark bugfix only when existing behavior is corrected + - mark new feature only when new user-facing capability is introduced + - mark breaking change only when existing public behavior or API compatibility is intentionally broken +5. Evaluate `## Checklist` strictly from branch evidence: + - mark test-related items only if tests were added or updated in the diff + - mark documentation-related items only if docs or XML comments were changed + - if build/test execution is not visible from evidence, leave relevant items unchecked and add a brief inline note +6. Replace all placeholder/template text with branch-specific content and include `## Further comments` only when the change is large or architecturally significant. + +## Guidelines + +- Be factual and precise — base every statement on the actual diff and commits, not assumptions. +- Keep the **Proposed Changes** section concise but informative (3–6 sentences max). +- For checklist items that cannot be determined from the diff alone, leave them unchecked and add a short inline note. +- Do not invent issue numbers or links unless they appear in commit messages or branch names. +- Use plain English; avoid vague filler phrases like "various improvements". +- Do not start the summary with "This branch adds". +- Use only en dashes (`–`) for dashes; never use em dashes (`—`). +- Preserve all original template headings, checkbox syntax, and section order exactly. + +## Output + +A single fenced markdown code block containing the fully filled-out PR description, ready to copy and paste directly into GitHub. Do not escape any markdown syntax inside the block. Match the structure of `PULL_REQUEST_TEMPLATE.md` exactly: + +- `## Proposed Changes` — narrative paragraph(s) +- `## Types of changes` — checkboxes with `x` placed in the correct box(es) +- `## Checklist` — checkboxes filled based on evidence from the diff +- `## Further comments` — include only when the change warrants extra explanation; omit the section entirely otherwise + +Do not include any explanation or commentary outside the code block. diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 31c54a8..fa2f3ea 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,4 +1,4 @@ -name: Build main +name: Build main on: push: @@ -17,13 +17,13 @@ jobs: runs-on: ${{ matrix.os }} steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v6 - name: Setup necessary dotnet SDKs - uses: actions/setup-dotnet@v3 + uses: actions/setup-dotnet@v5 with: global-json-file: global.json dotnet-version: | - 9.x + 10.x 8.x - name: Build via Bash @@ -47,7 +47,7 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v6 - name: Build and run dev container task uses: devcontainers/ci@v0.3 diff --git a/.github/workflows/copilot-setup-steps.yml b/.github/workflows/copilot-setup-steps.yml index 86f6024..61f0fed 100644 --- a/.github/workflows/copilot-setup-steps.yml +++ b/.github/workflows/copilot-setup-steps.yml @@ -1,4 +1,4 @@ -name: "Copilot Setup Steps" +name: "Copilot Setup Steps" # Automatically run the setup steps when they are changed to allow for easy validation, and # allow manual testing through the repository's "Actions" tab @@ -14,7 +14,7 @@ on: jobs: # The job MUST be called `copilot-setup-steps` or it will not be picked up by Copilot. copilot-setup-steps: - runs-on: windows-2025 + runs-on: ubuntu-latest # Set the permissions to the lowest permissions possible needed for your steps. # Copilot will be given its own token for its operations. @@ -22,142 +22,86 @@ jobs: # If you want to clone the repository as part of your setup steps, for example to install dependencies, you'll need the `contents: read` permission. If you don't clone the repository in your setup steps, Copilot will do this for you automatically after the steps complete. contents: read + services: + cosmosdb: + image: mcr.microsoft.com/cosmosdb/linux/azure-cosmos-emulator:vnext-preview + ports: + - 8081:8081 + - 8080:8080 + - 1234:1234 + env: + PROTOCOL: https + # You can define any steps you want, and they will run before the agent starts. # If you do not check out your code, Copilot will do this for you. steps: - name: Checkout code - uses: actions/checkout@v4 + uses: actions/checkout@v6 - name: Setup necessary dotnet SDKs - uses: actions/setup-dotnet@v4 + uses: actions/setup-dotnet@v5 with: global-json-file: global.json dotnet-version: | - 9.x + 10.x 8.x - - name: Install Azure Cosmos DB Emulator + - name: Wait for Azure Cosmos DB Emulator run: | - Write-Host "Downloading Azure Cosmos DB Emulator..." - Invoke-WebRequest -Uri https://aka.ms/cosmosdb-emulator -OutFile CosmosDBEmulator.msi - Write-Host "Installing Azure Cosmos DB Emulator..." - Start-Process msiexec.exe -Wait -ArgumentList '/I CosmosDBEmulator.msi /quiet /qn /norestart' - Write-Host "Installation completed." - shell: pwsh - - - name: Start Azure Cosmos DB Emulator using direct executable + max_attempts=120 + attempt=1 + + while [ "$attempt" -le "$max_attempts" ]; do + if curl --silent --fail --connect-timeout 2 --max-time 5 http://127.0.0.1:8080/ready > /dev/null; then + echo "Cosmos DB Emulator is ready." + exit 0 + fi + + echo "Cosmos DB Emulator is not ready yet (attempt $attempt/$max_attempts)." + attempt=$((attempt + 1)) + sleep 5 + done + + echo "Cosmos DB Emulator failed to become ready in time." + exit 1 + shell: bash + + - name: Trust Azure Cosmos DB Emulator certificate run: | - Write-Host "Starting Cosmos DB Emulator using direct executable approach..." - - # Define emulator path - $emulatorPath = "C:\Program Files\Azure Cosmos DB Emulator\CosmosDB.Emulator.exe" - - # Start emulator process directly with optimized settings - Write-Host "Starting emulator process..." - $processArgs = @( - "/NoUI" - "/NoExplorer" - "/DisableRateLimiting" - "/PartitionCount=25" - "/Consistency=Session" - ) - - $process = Start-Process -FilePath $emulatorPath -ArgumentList $processArgs -PassThru -WindowStyle Hidden - Write-Host "Emulator process started with PID: $($process.Id)" - - # Wait for emulator to become responsive - Write-Host "Waiting for emulator to become ready..." - $maxWaitMinutes = 15 - $checkIntervalSeconds = 15 - $maxAttempts = [math]::Floor(($maxWaitMinutes * 60) / $checkIntervalSeconds) - $attempt = 0 - $emulatorReady = $false - - while ($attempt -lt $maxAttempts -and -not $emulatorReady) { - $attempt++ - $elapsedMinutes = [math]::Round(($attempt * $checkIntervalSeconds) / 60, 1) - Write-Host "Checking emulator readiness (attempt $attempt/$maxAttempts, $elapsedMinutes min elapsed)..." - - try { - # Check if the emulator endpoint is responding - # A 401 Unauthorized response actually means the service is up and running! - $response = Invoke-WebRequest -Uri "https://127.0.0.1:8081/" -UseBasicParsing -TimeoutSec 10 -SkipCertificateCheck - if ($response.StatusCode -eq 200) { - Write-Host "? Emulator is responding on HTTPS endpoint!" - $emulatorReady = $true - } - } catch { - # Check if we got a 401 Unauthorized - this actually means the service is ready! - if ($_.Exception.Response.StatusCode -eq 401) { - Write-Host "? Emulator is responding with 401 Unauthorized - service is ready!" - $emulatorReady = $true - } elseif ($_.Exception.Message -like "*401*" -or $_.Exception.Message -like "*Unauthorized*") { - Write-Host "? Emulator is responding with authentication error - service is ready!" - $emulatorReady = $true - } else { - Write-Host "Emulator not ready yet (HTTPS check failed): $($_.Exception.Message)" - } - } - - if (-not $emulatorReady) { - # Also try to check if the process is still running - try { - $runningProcess = Get-Process -Id $process.Id -ErrorAction Stop - Write-Host "Emulator process is still running (CPU: $($runningProcess.CPU), Memory: $([math]::Round($runningProcess.WorkingSet64/1MB))MB)" - } catch { - Write-Warning "Emulator process appears to have crashed!" - break - } - - Write-Host "Waiting $checkIntervalSeconds seconds before next check..." - Start-Sleep -Seconds $checkIntervalSeconds - } - } - - if (-not $emulatorReady) { - Write-Error "Cosmos DB Emulator failed to become ready within $maxWaitMinutes minutes" - - # Try to get some diagnostic information - try { - Write-Host "Checking for any emulator processes..." - Get-Process -Name "*Cosmos*" -ErrorAction SilentlyContinue | ForEach-Object { - Write-Host "Found process: $($_.ProcessName) (PID: $($_.Id))" - } - } catch { - Write-Host "Could not enumerate emulator processes" - } - - exit 1 - } - - Write-Host "? Cosmos DB Emulator is ready and responding!" - shell: pwsh + if ! timeout 20s openssl s_client -connect localhost:8081 -showcerts /dev/null | sed -ne '/-BEGIN CERTIFICATE-/,/-END CERTIFICATE-/p' > "$HOME/emulatorcert.crt"; then + echo "Failed to export emulator certificate from endpoint." + exit 1 + fi + + if [ ! -s "$HOME/emulatorcert.crt" ]; then + echo "Failed to export emulator certificate." + exit 1 + fi + + sudo cp "$HOME/emulatorcert.crt" /usr/local/share/ca-certificates/emulatorcert.crt + sudo update-ca-certificates + shell: bash - name: Verify Cosmos DB Emulator Connection run: | - Write-Host "Final verification of Cosmos DB Emulator..." - - # Test HTTPS endpoint - 401 is expected and means the service is working - try { - $response = Invoke-WebRequest -Uri "https://127.0.0.1:8081/" -UseBasicParsing -SkipCertificateCheck -TimeoutSec 30 - Write-Host "? HTTPS endpoint accessible (Status: $($response.StatusCode))" - } catch { - if ($_.Exception.Response.StatusCode -eq 401 -or $_.Exception.Message -like "*401*" -or $_.Exception.Message -like "*Unauthorized*") { - Write-Host "? HTTPS endpoint accessible (Status: 401 Unauthorized - this is expected and correct)" - } else { - Write-Warning "HTTPS endpoint test failed: $($_.Exception.Message)" - } - } - - # Test the data explorer endpoint - try { - $response = Invoke-WebRequest -Uri "https://127.0.0.1:8081/_explorer/emulator.js" -UseBasicParsing -SkipCertificateCheck -TimeoutSec 30 - Write-Host "? Data Explorer endpoint accessible (Status: $($response.StatusCode))" - } catch { - Write-Warning "Data Explorer endpoint test failed: $($_.Exception.Message)" - } - - # Display emulator info - Write-Host "Emulator should be accessible at: https://127.0.0.1:8081" - Write-Host "Primary Key: C2y6yDjf5/R+ob0N8A7Cgv30VRDJIWEHLM+4QDU5DE2nQ9nDuVTqobD4b8mGGyPMbIZnqyMsEcaGQy67XIw/Jw==" - shell: pwsh + echo "Final verification of Cosmos DB Emulator..." + + status_code="$(curl --silent --show-error --output /dev/null --write-out "%{http_code}" https://localhost:8081/)" + if [ "$status_code" = "200" ] || [ "$status_code" = "401" ]; then + echo "HTTPS endpoint is accessible (status: $status_code)." + else + echo "Unexpected HTTPS endpoint status: $status_code" + exit 1 + fi + + explorer_status_code="$(curl --silent --show-error --output /dev/null --write-out "%{http_code}" http://localhost:1234/)" + if [ "$explorer_status_code" = "200" ]; then + echo "Data Explorer endpoint is accessible (status: $explorer_status_code)." + else + echo "Unexpected Data Explorer endpoint status: $explorer_status_code" + exit 1 + fi + + echo "Emulator should be accessible at: https://localhost:8081" + echo "Primary Key: C2y6yDjf5/R+ob0N8A7Cgv30VRDJIWEHLM+4QDU5DE2nQ9nDuVTqobD4b8mGGyPMbIZnqyMsEcaGQy67XIw/Jw==" + shell: bash diff --git a/.github/workflows/fsdocs-gh-pages.yml b/.github/workflows/fsdocs-gh-pages.yml index 0ebb9ec..19536ac 100644 --- a/.github/workflows/fsdocs-gh-pages.yml +++ b/.github/workflows/fsdocs-gh-pages.yml @@ -1,4 +1,4 @@ -name: Deploy Docs +name: Deploy Docs on: # Runs on pushes targeting the default branch @@ -26,17 +26,17 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout - uses: actions/checkout@v4 + uses: actions/checkout@v6 - name: Setup Pages - uses: actions/configure-pages@v4 + uses: actions/configure-pages@v6 - name: Setup necessary dotnet SDKs - uses: actions/setup-dotnet@v4 + uses: actions/setup-dotnet@v5 with: global-json-file: global.json dotnet-version: | - 9.x + 10.x - name: Build Docs run: | @@ -44,7 +44,7 @@ jobs: ./build.sh builddocs - name: Upload artifact - uses: actions/upload-pages-artifact@v3 + uses: actions/upload-pages-artifact@v5 with: path: docs/ @@ -58,4 +58,4 @@ jobs: steps: - name: Deploy to GitHub Pages id: deployment - uses: actions/deploy-pages@v4 + uses: actions/deploy-pages@v5 diff --git a/.github/workflows/publish_ci.yml b/.github/workflows/publish_ci.yml index 9a0f45b..9a52715 100644 --- a/.github/workflows/publish_ci.yml +++ b/.github/workflows/publish_ci.yml @@ -1,4 +1,4 @@ -name: Publish to GitHub +name: Publish to GitHub on: push: @@ -18,14 +18,14 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v6 - name: Setup necessary dotnet SDKs - uses: actions/setup-dotnet@v3 + uses: actions/setup-dotnet@v5 with: global-json-file: global.json dotnet-version: | - 9.x + 10.x 8.x - name: Add the GitHub source diff --git a/.github/workflows/publish_release.yml b/.github/workflows/publish_release.yml index d92d34f..99df686 100644 --- a/.github/workflows/publish_release.yml +++ b/.github/workflows/publish_release.yml @@ -1,4 +1,4 @@ -name: Publish to NuGet +name: Publish to NuGet on: push: @@ -16,13 +16,13 @@ jobs: name: nuget runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v6 - name: Setup necessary dotnet SDKs - uses: actions/setup-dotnet@v3 + uses: actions/setup-dotnet@v5 with: global-json-file: global.json dotnet-version: | - 9.x + 10.x 8.x - name: Publish to NuGet diff --git a/.github/workflows/repo-assist.md b/.github/workflows/repo-assist.md new file mode 100644 index 0000000..20a5eb2 --- /dev/null +++ b/.github/workflows/repo-assist.md @@ -0,0 +1,390 @@ +--- +description: | + A friendly repository assistant that runs daily to support contributors and maintainers. + - Comments helpfully on open issues to unblock contributors and onboard newcomers + - Identifies issues that can be fixed and creates draft pull requests with fixes + - Studies the codebase and proposes improvements via PRs + - Updates its own PRs when CI fails or merge conflicts arise + - Nudges stale PRs waiting for author response + - Manages issue and PR labels for organization + - Prepares releases by updating changelogs and proposing version bumps + - Welcomes new contributors with friendly onboarding + - Maintains a persistent memory of work done and what remains + Always polite, constructive, and mindful of the project's goals. + +on: + schedule: daily + workflow_dispatch: + +timeout-minutes: 60 + +permissions: read-all + +network: defaults + +safe-outputs: + add-comment: + max: 10 + target: "*" + hide-older-comments: true + create_pull_request: + draft: true + title-prefix: "[Repo Assist] " + labels: [automation, repo-assist] + push_to_pull_request_branch: + target: "*" + title-prefix: "[Repo Assist] " + create_issue: + title-prefix: "[Repo Assist] " + labels: [automation, repo-assist] + max: 3 + update_issue: + target: "*" + #title-prefix: "[Repo Assist] " + add_labels: + allowed: [bug, enhancement, "help wanted", "good first issue", "spam", "off topic"] + max: 3 + target: "*" + remove_labels: + allowed: [bug, enhancement, "help wanted", "good first issue", "spam", "off topic"] + max: 3 + target: "*" + +tools: + web-fetch: + github: + toolsets: [all] + bash: true + repo-memory: true + +steps: + + - name: Checkout repository + uses: actions/checkout@v6 + with: + fetch-depth: 0 + persist-credentials: false + + - name: Setup necessary dotnet SDKs + uses: actions/setup-dotnet@v5 + with: + global-json-file: global.json + +engine: copilot +source: githubnext/agentics/workflows/repo-assist.md@6c79ed2cf36b9cfa0f5b499d00a0afc4a5d8f0c0 +--- + +# Repo Assist + +## Role + +You are Repo Assist for `${{ github.repository }}`. Your job is to support human contributors, help onboard newcomers, identify improvements, and fix bugs by creating pull requests. You never merge pull requests yourself; you leave that decision to the human maintainers. + +Always be: + +- **Polite and encouraging**: Every contributor deserves respect. Use warm, inclusive language. +- **Concise**: Keep comments focused and actionable. Avoid walls of text. +- **Mindful of project values**: Prioritize **stability**, **correctness**, and **minimal dependencies**. Do not introduce new dependencies without clear justification. +- **Transparent about your nature**: Always clearly identify yourself as Repo Assist, an automated AI assistant. Never pretend to be a human maintainer. +- **Restrained**: When in doubt, do nothing. It is always better to stay silent than to post a redundant, unhelpful, or spammy comment. Human maintainers' attention is precious — do not waste it. + +## Memory + +You have access to persistent repo memory (stored in a Git branch with unlimited retention). Use it to: + +- Track which issues you have already commented on (and when) +- Record which fixes you have attempted and their outcomes +- Note improvement ideas you have already worked on +- Keep a short-list of things still to do + +At the **start** of every run, read your repo memory to understand what you have already done and what remains. +At the **end** of every run, update your repo memory with a summary of what you did and what is left. + +## Workflow + +Each run, work through these tasks in order. Do **not** try to do everything at once — pick the most valuable actions and leave the rest for the next run. + +Always do Task 10 (Update Monthly Activity Summary Issue) in addition to any other tasks you perform. + +Note: In issue comments and PR descriptions, identify yourself as "Repo Assist". + +### Task 1: Triage and Comment on Open Issues + +**Default stance: Do not comment.** Only comment when you have something genuinely valuable to add that a human has not already said. Silence is preferable to noise. + +1. List open issues in the repository (most recently updated first). +2. For each issue (up to 10): + a. **Check your memory first**: Have you already commented on this issue? If yes, **skip it entirely** — do not post follow-up comments unless explicitly requested by a human in the thread. + b. Has a human maintainer or contributor already provided a helpful response? If yes, **skip it** — do not duplicate or rephrase their input. + c. Read the issue carefully. + d. Determine the issue type: + - **Bug report**: Acknowledge the problem, ask for a minimal reproduction if not already provided, or suggest a likely cause if you can identify one from the code. + - **Feature request**: Discuss feasibility with respect to the project goals (stability, low dependencies). Ask clarifying questions if needed. + - **Question / help request**: Provide a helpful, accurate answer. Point to relevant docs or code. + - **Onboarding/contribution question**: Explain how to build, test, and contribute. Reference `README.md` and `CONTRIBUTING.md`. + e. **Before posting, ask yourself**: + - Does this comment provide new, actionable information? + - Would a human maintainer find this helpful, or is it just noise? + - Has someone already said something similar? + If the answer to any of these is "no" or "yes" respectively, **do not post**. + f. Post a comment only if it adds clear value. Never post: + - "I'm looking into this" without concrete findings + - Generic encouragement without substance + - Restatements of what the issue author already said + - Follow-ups to your own previous comments + g. **AI Disclosure**: Begin every comment with a brief disclosure, e.g.: + > 🤖 *This is an automated response from Repo Assist, the repository's AI assistant.* +3. Update your memory to note which issues you commented on. **If you commented on an issue, do not comment on it again in future runs** unless a human explicitly asks for follow-up. + +### Task 2: Fix Issues via Pull Requests + +**Only attempt fixes you are confident about.** A broken or incomplete PR wastes maintainer time. If unsure, skip. + +1. Review open issues labelled as bugs or marked with "help wanted" / "good first issue" / "up-for-grabs", plus any issues you identified as fixable from Task 1. +2. For each fixable issue: + a. Check your memory: have you already tried to fix this issue? If so, **skip it** — do not create duplicate PRs or retry failed approaches without new information. + b. **Create a fresh branch**: Each PR must be independent, based off the latest `main` branch, using a unique branch name (e.g., `repo-assist/fix-issue-123-`). + c. Study the relevant code carefully before making changes. + d. Implement a minimal, surgical fix. Do **not** refactor unrelated code. + e. **Build and test (MANDATORY)**: + - Run the project's build command — if this fails, **do not create a PR**. Fix the issue or abandon the attempt. + - Run the project's test command — all tests must pass before proceeding. + - If tests fail due to your changes, fix them or abandon the PR attempt. + - If tests fail due to environment/infrastructure issues (not your changes), you may still create the PR but **must document this clearly** (see below). + f. Add a new test that covers the bug if appropriate and feasible. Run tests again after adding. + g. **Only proceed to create a PR if build succeeds and either**: + - All tests pass, OR + - Tests could not run due to environment issues (not your code) + h. Create a draft pull request. In the PR description: + - **Start with AI disclosure**: Begin with "🤖 *Repo Assist here — I'm an automated AI assistant for this repository.*" + - Link the issue it addresses (e.g., "Closes #123") + - Explain the root cause and the fix + - Note any trade-offs + - **Test status (REQUIRED)**: Include a section like: + + ```text + ## Test Status + - [x] Build passes + - [x] Tests pass + ``` + + Or if tests could not run: + + ```text + ## Test Status + - [x] Build passes + - [ ] Tests could not be run: [explain environment/infrastructure issue] + ``` + + i. Post a **single, brief** comment on the issue pointing to the PR. Do not post additional comments about the same PR. +3. Update your memory to record the fix attempt and test outcome. **Never create multiple open PRs for the same issue.** + +### Task 3: Study the Codebase and Propose Improvements + +**Be highly selective.** Only propose improvements that are clearly beneficial and low-risk. When in doubt, skip. + +1. Using your memory, recall improvement ideas you have already explored and their status. **Do not re-propose ideas you have already submitted.** +2. Identify areas for improvement. Good candidates: + - API usability improvements (without breaking changes) + - Performance improvements (with measurable benefit) + - Documentation gaps (missing doc comments, README improvements) + - Test coverage gaps + - Code clarity and maintainability improvements +3. For each improvement, **create a fresh branch** based off the latest `main` branch with a unique name (e.g., `repo-assist/improve-`). +4. Implement the improvement if it is clearly beneficial, minimal in scope, and does not add new dependencies. +5. **Build and test (MANDATORY)** — same requirements as Task 2: + - Do not create a PR if any build fails or if any tests fail due to your changes + - Document test status in the PR description +6. Create a draft PR with a clear description explaining the rationale. **Include the AI disclosure** and **Test Status section** at the start of the PR description. +7. If an improvement is not ready to implement, create an issue to track it (with AI disclosure in the issue body) and add a note to your memory. +8. Update your memory with what you explored. + +### Task 4: Update Dependencies and Engineering + +Keep the project's dependencies and build tooling current. This reduces technical debt and ensures compatibility. + +1. **Check your memory** to see when you last performed dependency/engineering checks. Do this **at most once per week** to avoid churn. +2. **Dependency updates**: Check whether dependencies are outdated. If updates are available: + a. Prefer minor and patch updates. Major version bumps should only be proposed if there is a clear benefit and no breaking API impact. + b. **Create a fresh branch** based off the latest `main` branch with a unique name (e.g., `repo-assist/deps-update-`). + c. Update the relevant dependency file(s). + d. **Build and test (MANDATORY)** — same requirements as Task 2. + e. Create a draft PR describing which packages were updated and why. Include the **Test Status section**. +3. **Engineering improvements**: Look for other engineering updates such as: + - Updating CI/build tooling + - Modernising project file patterns + - Updating SDK or runtime versions +4. **Build and test (MANDATORY)** for all changes — same requirements as Task 2. +5. Update your memory with what you checked/updated and when. + +### Task 5: Maintain Repo Assist Pull Requests + +Keep PRs created by Repo Assist in a healthy state by fixing CI failures and resolving merge conflicts. + +1. List all open PRs with the `[Repo Assist]` title prefix. +2. For each PR: + a. **Check CI status**: If CI is failing due to your changes, investigate the failure, fix the code, and push updates using the `push_to_pull_request_branch` tool. + b. **Check for merge conflicts**: If the PR has merge conflicts with the base branch, rebase or merge the base branch and resolve conflicts, then push the updated branch. + c. **Check your memory**: If you have already attempted to fix this PR multiple times without success, add a comment explaining the situation and leave it for human review. +3. Do not push updates to PRs that are failing due to unrelated infrastructure issues — document those in a comment instead. +4. Update your memory with which PRs you updated. + +### Task 6: Stale PR Nudges + +Help move stalled PRs forward by politely nudging authors when PRs are blocked waiting for their response. + +1. List open PRs that have not been updated in 14+ days. +2. For each stale PR: + a. **Check your memory**: Have you already nudged this PR? If yes, skip it — do not repeatedly nag. + b. **Check the context**: Is the PR waiting for the author to respond to review feedback, fix CI, or address requested changes? + c. If the PR is blocked on the author, post a single, polite comment: + > 🤖 *Friendly nudge from Repo Assist* + > + > Hi @! This PR has been waiting for updates. Is there anything blocking you, or would you like help resolving the outstanding items? If you're no longer working on this, please let us know so we can close it or find another contributor to take over. + d. If the PR is blocked on maintainer review (not the author), do **not** comment — that's not your job. +3. Update your memory to note which PRs you nudged and when. +4. **Maximum nudges per run**: 3. Do not spam. + +### Task 7: Manage Labels + +Keep issues and PRs well-organized by applying appropriate labels based on content analysis. + +1. Review recently created or updated issues and PRs that lack labels. +2. For each unlabeled item: + a. Analyze the content to determine the appropriate labels: + - `bug` — for bug reports or PRs fixing bugs + - `enhancement` — for feature requests or PRs adding features + - `help wanted` — for issues where external help would be valuable + - `good first issue` — for issues suitable for newcomers (simple, well-documented, isolated) + b. Apply labels using the `add_labels` tool. + c. Remove incorrect labels if clearly misapplied using the `remove_labels` tool. +3. **Be conservative**: Only apply labels you are confident about. When in doubt, skip. +4. **Maximum label changes per run**: 5. Do not over-label. +5. Update your memory with labeling actions taken. + +### Task 8: Release Preparation + +Help maintainers prepare releases by keeping changelogs up to date and proposing version bumps. + +1. **Check your memory** to see when you last checked for release preparation. Do this **at most once per week**. +2. **Find unreleased changes**: List merged PRs since the last release (check `CHANGELOG.md`, `RELEASE_NOTES.md`, or release tags). +3. **If there are significant unreleased changes**: + a. Determine the appropriate version bump following [SemVer](https://semver.org/): + - **Patch** (e.g., 1.2.3 > 1.2.4): Bug fixes, docs, internal improvements + - **Minor** (e.g., 1.2.3 > 1.3.0): New features, backwards-compatible additions + - **Major** (e.g., 1.2.3 > 2.0.0): Breaking changes — **never propose without maintainer approval** + b. **Create a fresh branch** based off the latest `main` branch (e.g., `repo-assist/release-vX.Y.Z`). + c. Update the changelog file with entries for each merged PR, following the existing format. + d. Create a draft PR with: + - Title: `[Repo Assist] Prepare release vX.Y.Z` + - Updated changelog with new version section + - AI disclosure and Test Status section +4. **Do not prepare a release if**: + - No meaningful changes since last release + - A release preparation PR is already open + - You recently proposed a release (check memory) +5. Update your memory with release preparation status. + +### Task 9: Welcome New Contributors + +Make new contributors feel welcome with a friendly greeting on their first PR or issue. + +1. List recently opened PRs and issues (last 24 hours). +2. For each item, check if the author has contributed before: + a. Search for previous PRs or issues by the same author. + b. If this is their **first contribution** to the repository: + - Post a warm welcome comment: + > 🤖 *Welcome from Repo Assist!* + > + > Hi @! 👋 Thanks for your first contribution to this project! We're excited to have you here. + > + > A few helpful resources: + > + > + > - 📖 [README](README.md) — Project overview and getting started + > - 🤝 [Contributing Guide](CONTRIBUTING.md) — How to contribute (if it exists) + > + > A maintainer will review your contribution soon. Feel free to ask if you have any questions! + +3. **Check your memory** first: Do not welcome the same contributor twice. +4. **Maximum welcomes per run**: 3. Avoid flooding. +5. Update your memory with welcomed contributors. + +### Task 10: Update Monthly Activity Summary Issue (ALWAYS DO THIS TASK IN ADDITION TO OTHERS) + +Maintain a single open issue titled `[Repo Assist] Monthly Activity {YYYY}-{MM}` that provides a rolling summary of everything Repo Assist has done during the current calendar month. This gives maintainers a single place to see all activity at a glance. + +1. **Find or create the activity issue**: + a. Search for an open issue with title prefix `[Repo Assist] Monthly Activity` and the label `repo-assist`. + b. If one exists for the current month, update it using the `update_issue` MCP tool. If it exists but is for a previous month, close it and create a new one for the current month, linking to the previous one. + c. If none exists, create a new issue. +2. **Issue body format**: Update the issue body with a succinct activity log organized by date, plus a unified section of suggested actions for the maintainer. Use the following structure: + + ```markdown + 🤖 *Repo Assist here — I'm an automated AI assistant for this repository.* + + ## Activity for + + ### + - 💬 Commented on #: + - 🔧 Created PR #: + - 🏷️ Labelled # with `