Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 40 additions & 0 deletions .github/workflows/context7-refresh.yml
Original file line number Diff line number Diff line change
@@ -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
22 changes: 22 additions & 0 deletions context7.json
Original file line number Diff line number Diff line change
@@ -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.",
"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."

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 TF-IDF guidance omits memory limits

The rule now presents fit_from_stream as the Classifier::TFIDF option for data larger than memory. However, it collects every document in an array before calling fit. Agents following this advice can generate code that runs out of memory on large corpora. State that fit_from_stream still requires the full corpus to fit in memory.

Suggested change
"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."
"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, but it collects all documents in memory before fitting, so the corpus must fit in memory. Use train_batch only for documents already in memory; Classifier::LSI and Classifier::KNN name it add_batch."

Knowledge Base Used: Streaming processing

Prompt To Fix With AI
This is a comment left during a code review.
Path: context7.json
Line: 20

Comment:
**TF-IDF guidance omits memory limits**

The rule now presents `fit_from_stream` as the `Classifier::TFIDF` option for data larger than memory. However, it collects every document in an array before calling `fit`. Agents following this advice can generate code that runs out of memory on large corpora. State that `fit_from_stream` still requires the full corpus to fit in memory.

```suggestion
    "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, but it collects all documents in memory before fitting, so the corpus must fit in memory. Use train_batch only for documents already in memory; Classifier::LSI and Classifier::KNN name it add_batch."
```

**Knowledge Base Used:** [Streaming processing](https://app.greptile.com/craftsmanfounder/-/custom-context/knowledge-base/cardmagic/classifier/-/docs/streaming-processing.md)

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

]
}
Loading