Skip to content

feat(dictionary): add dictionary search, synonyms, and examples adapters#241

Open
vkop007 wants to merge 1 commit intojackwener:mainfrom
vkop007:feat/dictionary-adapter
Open

feat(dictionary): add dictionary search, synonyms, and examples adapters#241
vkop007 wants to merge 1 commit intojackwener:mainfrom
vkop007:feat/dictionary-adapter

Conversation

@vkop007
Copy link
Contributor

@vkop007 vkop007 commented Mar 22, 2026

Description

This PR introduces the powerful new Dictionary adapter to OpenCLI. It leverages the completely free, public api.dictionaryapi.dev robust JSON endpoint to bring a reliable spell checker, dictionary, and thesaurus straight into the developer terminal.

Commands Added (opencli dictionary):

  • search - Get the phonetic pronunciation, part of speech, and primary definition of any word (e.g., opencli dictionary search --word "serendipity").
  • synonyms - Extract up to 5 related synonyms for a given word by scrubbing the entire JSON definitions tree.
  • examples - Find real-world sentence usage examples for complex vocabulary (falls back elegantly if a word lacks examples).

Implementation Note: The YAML dataset extraction mappings were custom-built using recursive ES6 IIFEs to safely traverse variable-depth JSON nodes. This guarantees 100% crash protection against unpredictable empty arrays in the Dictionary API.

Related issue: N/A

Type of Change

  • 🐛 Bug fix
  • ✨ New feature
  • 🌐 New site adapter
  • 📝 Documentation
  • ♻️ Refactor
  • 🔧 CI / build / tooling

Checklist

  • I ran the checks relevant to this PR (opencli validate)
  • I updated tests or docs if needed (README integration and VitePress docs)
  • I included output or screenshots when useful

Documentation (if adding/modifying an adapter)

  • Added doc page under docs/adapters/ (docs/adapters/browser/dictionary.md)
  • Updated docs/adapters/index.md table
  • Updated sidebar in docs/.vitepress/config.mts

Screenshots / Output

$ opencli dictionary search --word serendipity

  dictionary/search
┌─────────────┬─────────────────────┬──────┬──────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
│ Word        │ Phonetic            │ Type │ Definition                                                                                                   │
├─────────────┼─────────────────────┼──────┼──────────────────────────────────────────────────────────────────────────────────────────────────────────────┤
│ serendipity │ /ˌsɛ.ɹən.ˈdɪ.pɪ.ti/ │ noun │ A combination of events which have come together by chance to make a surprisingly good or wonderful outcome. │
└─────────────┴─────────────────────┴──────┴──────────────────────────────────────────────────────────────────────────────────────────────────────────────┘
1 items · 0.8s · dictionary/search
$ opencli dictionary synonyms --word serendipity

  dictionary/synonyms
┌─────────────┬──────────────┐
│ Word        │ Synonyms     │
├─────────────┼──────────────┤
│ serendipity │ chance, luck │
└─────────────┴──────────────┘
1 items · 0.6s · dictionary/synonyms
$ opencli dictionary examples --word perfect

  dictionary/examples
┌─────────┬──────────────────┐
│ Word    │ Example          │
├─────────┼──────────────────┤
│ perfect │ a perfect circle │
└─────────┴──────────────────┘
1 items · 0.8s · dictionary/examples

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant