From 90f0192fb031119e0fcfe19b5caef046fa16939e Mon Sep 17 00:00:00 2001 From: Lucas Carlson Date: Thu, 8 Oct 2026 01:31:23 -0700 Subject: [PATCH 1/2] ci: index the docs on Context7 and refresh on push Context7 has no classifier library yet, so agents that use it cannot retrieve the current API. context7.json limits indexing to the README and docs/, leaves out the maintainer files, and gives agents rules taken from the docs. It also carries the url and public_key that Context7 reads to verify the maintainer's claim on the library. The refresh workflow asks Context7 to refresh the index after a push to master that changes the README, context7.json, or docs/. Context7 allows one refresh every 10 days for one library and answers too-early before then, so that answer ends the job with a notice. Any other non-200 answer fails the job. No CHANGELOG entry: the change does not reach gem users. --- .github/workflows/context7-refresh.yml | 40 ++++++++++++++++++++++++++ context7.json | 22 ++++++++++++++ 2 files changed, 62 insertions(+) create mode 100644 .github/workflows/context7-refresh.yml create mode 100644 context7.json diff --git a/.github/workflows/context7-refresh.yml b/.github/workflows/context7-refresh.yml new file mode 100644 index 00000000..241415a6 --- /dev/null +++ b/.github/workflows/context7-refresh.yml @@ -0,0 +1,40 @@ +name: Context7 refresh + +on: + push: + branches: + - master + paths: + - "README.md" + - "context7.json" + - "docs/**" + +permissions: + contents: read + +jobs: + refresh: + runs-on: ubuntu-latest + timeout-minutes: 5 + steps: + - name: Trigger a Context7 refresh + env: + CONTEXT7_API_KEY: ${{ secrets.CONTEXT7_API_KEY }} + LIBRARY_NAME: /${{ github.repository }} + run: | + status=$(curl --silent --show-error --max-time 180 --output response.json --write-out '%{http_code}' \ + -X POST https://context7.com/api/v1/refresh \ + -H "Content-Type: application/json" \ + -H "Authorization: Bearer $CONTEXT7_API_KEY" \ + -d "{\"libraryName\": \"$LIBRARY_NAME\"}") + cat response.json + echo + if [ "$status" = "200" ]; then + exit 0 + fi + if [ "$status" = "400" ] && jq -e '.error == "too-early"' response.json > /dev/null; then + echo "::notice::Context7 refreshed $LIBRARY_NAME recently, so it skipped this refresh." + exit 0 + fi + echo "::error::Context7 refresh failed with HTTP $status." + exit 1 diff --git a/context7.json b/context7.json new file mode 100644 index 00000000..9a650c57 --- /dev/null +++ b/context7.json @@ -0,0 +1,22 @@ +{ + "$schema": "https://context7.com/schema/context7.json", + "url": "https://context7.com/cardmagic/classifier", + "public_key": "pk_veEo2smPvGYMwP1MncN1A", + "projectTitle": "Classifier (Ruby gem)", + "description": "Text classification in Ruby: Naive Bayes, Logistic Regression, LSI (Latent Semantic Indexing), k-Nearest Neighbors, and TF-IDF vectorization, with a native C extension, streaming training, pluggable persistence, and the classifier and keywords command-line tools. Requires Ruby 3.1+.", + "folders": [ + "docs" + ], + "excludeFiles": [ + "AGENTS.md", + "CLAUDE.md", + "CONTRIBUTING.md" + ], + "rules": [ + "Install with gem 'classifier' in the Gemfile, or brew install classifier for the command-line tools only. The gem requires Ruby 3.1 or newer.", + "Start with Classifier::Bayes for text classification. Use Classifier::LogisticRegression for calibrated probabilities, Classifier::LSI for semantic search and related documents, and Classifier::KNN for nearest-example votes.", + "Classifier::TFIDF must be fitted on a corpus before it transforms text; transform raises Classifier::NotFittedError before a fit. The keywords command fits a vocabulary first and reads that model in later commands.", + "Save and load trained models with the JSON persistence API. Prefer it to Marshal, and load a marshalled model only from a source you trust.", + "Train on data larger than memory with the streaming API, such as train_from_stream and train_batch." + ] +} From 4f8e225250eebc65e73ca9897d66909780243ad6 Mon Sep 17 00:00:00 2001 From: Lucas Carlson Date: Thu, 8 Oct 2026 01:36:54 -0700 Subject: [PATCH 2/2] ci: describe batch training as in-memory Review feedback on #178. The rule listed train_batch as a way to train on data larger than memory, but docs/streaming.md says that train_batch takes documents already in memory. The rule now names train_from_stream for data larger than memory, fit_from_stream for TF-IDF, and train_batch, or add_batch for LSI and KNN, for documents in memory, as docs/streaming.md describes. --- context7.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/context7.json b/context7.json index 9a650c57..b55f755f 100644 --- a/context7.json +++ b/context7.json @@ -17,6 +17,6 @@ "Start with Classifier::Bayes for text classification. Use Classifier::LogisticRegression for calibrated probabilities, Classifier::LSI for semantic search and related documents, and Classifier::KNN for nearest-example votes.", "Classifier::TFIDF must be fitted on a corpus before it transforms text; transform raises Classifier::NotFittedError before a fit. The keywords command fits a vocabulary first and reads that model in later commands.", "Save and load trained models with the JSON persistence API. Prefer it to Marshal, and load a marshalled model only from a source you trust.", - "Train on data larger than memory with the streaming API, such as train_from_stream and train_batch." + "For data larger than memory, use train_from_stream, which reads one document per line from an IO stream. Classifier::TFIDF uses fit_from_stream. Use train_batch only for documents already in memory; Classifier::LSI and Classifier::KNN name it add_batch." ] }