15 Commits
Author SHA1 Message Date
AlexKucera 4c03bed948 Refactors model fetching with deduplication strategy
Extracts common model fetching logic into shared method to prevent duplicate API calls

Improves error handling and caching for model retrieval by:
- Creating a centralized fetchWithDeduplication method
- Adding model type filtering in cache update
- Resetting fallback notice flag during cache clearing

Enhances reliability of model list retrieval across multiple service methods
2025-10-25 10:44:53 +02:00
AlexKucera b57fe8cd89 Adds deduplication for concurrent prompt generation
Prevents duplicate API calls by tracking in-flight requests
Ensures consistent prompt generation under high concurrency
Mitigates potential race conditions in prompt retrieval

Improves performance and reliability of prompt generation service
2025-10-24 16:55:05 +02:00
AlexKucera c9adf05a82 Improves model fetching resilience and performance
Adds deduplication of concurrent API calls to prevent redundant requests

Enhances error handling by preferring stale cache over hardcoded fallback models
Introduces new getStaleCacheModels method to provide more robust model retrieval
Prevents multiple simultaneous model fetch attempts with in-flight request tracking
2025-10-24 16:37:45 +02:00
AlexKucera 61788b39ad Enforces precise prompt generation count
Trims generated prompts to requested count

Ensures consistent user experience by slicing array if model over-generates
Prevents potential cache key mismatches due to inconsistent prompt counts
2025-10-24 13:41:44 +02:00
AlexKucera b76f085137 Improves model fetching with deduplication and notice control
Adds a session-based flag to prevent repeated fallback notices during API failures

Implements model list deduplication to handle potential duplicate entries
Prevents spamming users with repeated error notifications
Resets notice flag on successful model fetches to allow future warnings
2025-10-24 13:40:42 +02:00
AlexKucera e96ef65200 Added DocStrings 2025-10-24 13:09:10 +02:00
AlexKucera e06b07eb26 Adds API key validation and model sorting
Improves model retrieval by adding API key validation check for both model fetching methods

Adds fallback to predefined models when no API key is present
Sorts model lists alphabetically by display name for consistent presentation

Enhances robustness of model service handling
2025-10-24 11:26:48 +02:00
AlexKucera 7932663d2a Adds type refinement for dynamic model selection
Introduces ModelId type alias to clarify model ID intent
Refines prompt generator type to support specific prompt types
Improves type safety for model and prompt configuration
2025-10-24 11:25:36 +02:00
AlexKucera 435af4ccab Adds required Claude model validation check
Enforces Claude model selection as a mandatory setting

Prevents configuration submission without specifying a valid Claude model to ensure proper API interaction and prevent potential errors
2025-10-24 11:24:09 +02:00
AlexKucera 766eb26df3 Improves model fetch error notification message
Updates error notification to provide clearer feedback when API model retrieval fails

Enhances user experience by making the fallback model list error message more descriptive and informative
2025-10-24 11:22:33 +02:00
Jarvis 20530142e4 feat: add dynamic model fetching from Anthropic API
Replace hardcoded model list with dynamic API-based model fetching
that queries the Anthropic models endpoint. Implements 24-hour caching
with automatic fallback to hardcoded models if API is unavailable.

Changes:
- Add ModelService to fetch and cache available models from API
- Implement 24-hour TTL cache persisted in plugin data
- Update AnthropicClient with fetchModels() method
- Modify settings UI to load models asynchronously with loading states
- Auto-refresh models when API key is entered or changed
- Display model names using display_name field from API
- Preserve user's selected model across updates and restarts
- Show notice when falling back to hardcoded model list
- Change model type from strict enum to string for dynamic support

Technical details:
- New ModelInfo and ModelsListResponse interfaces for API response
- ModelCache interface with timestamp for TTL validation
- FreewritingPromptsData extends settings to include cache
- Settings dropdown disabled during model fetch/refresh
- Fallback to ANTHROPIC_MODELS constant on API failure

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-23 10:17:30 +02:00
AlexKucera ac20fadef6 Guards against empty cache arrays
Prevents errors when attempting to process an empty cache.

Deletes the cache entry if it is empty to avoid repeatedly
attempting to process an invalid cache entry.
2025-09-26 08:11:44 +02:00
Jarvis 4786e7647d refactor: rename "Staggered Prompts" to "Timed Prompts" for clarity
Renames command terminology throughout codebase to better reflect
regular interval delivery rather than irregular/staggered timing.

Changes:
- Rename staggeredPrompts.ts → timedPrompts.ts
- Update class StaggeredPromptsCommand → TimedPromptsCommand
- Update command IDs: staggered-prompts → timed-prompts
- Update user-facing labels in settings and README
- Update property names: staggeredCount → timedCount
- Update method names: generateStaggeredPrompts → generateTimedPrompts
- Update API constants and type annotations

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-09-21 07:53:48 +02:00
AlexKucera 2fbe582c4d Simplifies prompt generation model usage
Updates prompt generation to use the model type directly, removing the need for casting.

This change streamlines the prompt generation process and enhances type safety.
2025-09-20 10:53:36 +02:00
AlexKucera 44936775cd Implements freewriting prompts plugin
Initial implementation of the Freewriting Prompts plugin.

This commit introduces the core functionality for generating
AI-powered writing prompts using Anthropic's Claude API.

It includes:
- API client for interacting with the Anthropic API
- Services for generating and caching prompts
- Commands for displaying staggered prompts and appending prompts to notes
- Settings tab for configuring the plugin
2025-09-19 18:51:48 +02:00