diff --git a/.github/workflows/context7-refresh.yml b/.github/workflows/context7-refresh.yml new file mode 100644 index 0000000..761aa52 --- /dev/null +++ b/.github/workflows/context7-refresh.yml @@ -0,0 +1,39 @@ +name: Refresh Context7 index + +on: + push: + workflow_dispatch: + +permissions: {} + +concurrency: + group: context7-refresh-${{ github.ref }} + cancel-in-progress: true + +jobs: + refresh: + name: Request library refresh + if: >- + github.ref_name == github.event.repository.default_branch && + vars.CONTEXT7_REFRESH_ENABLED == 'true' + runs-on: ubuntu-latest + timeout-minutes: 5 + steps: + - name: Request Context7 refresh + env: + CONTEXT7_API_KEY: ${{ secrets.CONTEXT7_API_KEY }} + CONTEXT7_LIBRARY_NAME: /${{ github.repository }} + run: | + if [ -z "$CONTEXT7_API_KEY" ]; then + echo "::error::Set the CONTEXT7_API_KEY repository secret." + exit 1 + fi + printf -v authorization "Authorization: %s %s" "Bearer" "$CONTEXT7_API_KEY" + + curl --fail-with-body --retry 3 --retry-all-errors \ + --silent --show-error --max-time 60 \ + --request POST \ + --url https://context7.com/api/v1/refresh \ + --header "$authorization" \ + --header "Content-Type: application/json" \ + --data "{\"libraryName\":\"$CONTEXT7_LIBRARY_NAME\"}" diff --git a/CHANGELOG.md b/CHANGELOG.md index 9622ea6..40afb76 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,9 @@ The format follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/). ### Added +- Add project-neutral Context7 configuration, opt-in index refresh automation, + and setup guidance for generated projects. + ### Changed ### Fixed diff --git a/MANIFEST.in b/MANIFEST.in index be60802..2009289 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -7,6 +7,7 @@ include .pre-commit-config.yaml include .python-version include AGENTS.md include CHANGELOG.md +include context7.json include LICENSE include README.md include CODE_OF_CONDUCT.md diff --git a/TEMPLATE_SETUP.md b/TEMPLATE_SETUP.md index 621ba68..49bcb2a 100644 --- a/TEMPLATE_SETUP.md +++ b/TEMPLATE_SETUP.md @@ -19,6 +19,29 @@ Complete this checklist before the first release. - [ ] Configure S3 deployment through the protected `docs-production` environment, AWS OIDC variables, and `DOCS_DEPLOY_ENABLED=true`. +## Context7 + +The root `context7.json` uses the current schema, indexes `docs/` and the +root-level README, and excludes the template's operational files. It omits +project metadata, branch names, versions, and usage rules so Context7 can infer +safe defaults without template-specific placeholders. Adjust its paths if the +project's user documentation lives elsewhere. + +- [ ] Publish useful documentation, then [submit the public repository to + Context7](https://context7.com/add-library). +- [ ] Claim ownership from the library's Context7 admin page. Add the generated + `url` and `public_key` values to `context7.json`, push them to the default + branch, and complete the claim. +- [ ] After claiming, use **Apply for Verification** on the admin page and + provide the requested project and documentation details if the automatic + quality check does not approve it. +- [ ] Rely on Context7's usage-based automatic refreshes, refresh manually after + important releases, or enable `.github/workflows/context7-refresh.yml`. + Once enabled with a `CONTEXT7_API_KEY` repository secret and the + `CONTEXT7_REFRESH_ENABLED=true` repository variable, it refreshes after + each default-branch push so moving documentation files or folders in + `context7.json` does not silently disable automated refreshes. + ## Continuous Integration - [ ] Set the `PACKAGE_IMPORT_NAME` repository variable to the package import diff --git a/context7.json b/context7.json new file mode 100644 index 0000000..e5874d8 --- /dev/null +++ b/context7.json @@ -0,0 +1,25 @@ +{ + "$schema": "https://context7.com/schema/context7.json", + "folders": ["docs"], + "excludeFiles": [ + "AGENTS.md", + "CHANGELOG.md", + "CHANGELOG.mdx", + "CODE_OF_CONDUCT.md", + "CONTRIBUTING.md", + "LICENSE", + "LICENSE.md", + "RELEASING.md", + "SECURITY.md", + "TEMPLATE_SETUP.md", + "agents.md", + "changelog.md", + "changelog.mdx", + "code_of_conduct.md", + "contributing.md", + "license.md", + "releasing.md", + "security.md", + "template_setup.md" + ] +}