Commit Graph
11 Commits
Author SHA1 Message Date
AlexKucera 1f69c568bb Refines settings UI and error handling
Simplifies commentary prompt assignments and streamlines
the Freewriting Cleanup Plugin command registration.

Improves consistency and readability in the settings interface
by standardizing heading and button labels. Removes redundant
model selection logging.

This enhances user experience by making the interface
more intuitive and declutters the codebase for easier maintenance.
2025-11-09 17:17:37 +01:00
AlexKucera ab5e134a12 Improves API error handling and response parsing
Enhances error handling for Anthropic API client:
- Adds specific handling for 429 (rate limit) errors
- Improves authentication error detection
- Modifies text extraction to capture multiple response blocks

Provides more robust and informative error responses during API interactions
2025-10-24 16:28:57 +02:00
AlexKucera 306e6819a3 Improves API retry logic with selective retries
Enhances request retry mechanism to avoid unnecessary retries on non-transient errors

Adds specific error handling to prevent retrying:
- API key configuration errors
- Client-side API errors (4xx status codes)

Ensures more efficient and targeted retry strategy that avoids wasting API quota
2025-10-24 16:08:05 +02:00
AlexKucera e29539c8eb Adds robust error handling for API interactions
Introduces a comprehensive custom error hierarchy for more precise error management in API calls

Replaces generic error throwing with specific error types:
- Adds custom error classes for various API-related scenarios
- Improves error handling in cleanup and API client components
- Enables more informative and type-safe error tracking

Enhances error reporting and debugging capabilities for Anthropic API interactions
2025-10-24 15:52:34 +02:00
AlexKucera 5e77136370 Improves custom commentary error message clarity
Enhances error messaging for custom commentary style to provide more specific guidance

Clarifies that a custom prompt is required when selecting custom commentary style, making the error message more informative and user-friendly
2025-10-24 15:38:45 +02:00
AlexKucera ee892b3231 Adds validation for custom commentary style
Enforces requirement of custom commentary prompt when custom style is selected

Prevents potential runtime errors by throwing an explicit error if custom commentary style is chosen without providing a custom prompt
2025-10-24 15:16:23 +02:00
AlexKucera 0f3d6ec7a3 Enhances code documentation and structure for plugin
Adds comprehensive documentation for all major classes and methods in the Freewriting Cleanup plugin

Improves code readability by:
- Adding detailed JSDoc comments explaining purpose and functionality
- Clarifying method behaviors and input/output expectations
- Providing inline context for complex operations

Standardizes error handling and adds more robust validation across services
2025-10-24 13:16:42 +02:00
AlexKucera 4db5639160 Adds token usage tracking for text cleanup requests
Enhances Anthropic API client to return token usage information

Modifies cleanup service to capture and store input and output token counts from API responses
Refactors request and response handling to extract and pass usage metrics
Provides more detailed tracking of API request resource consumption
2025-10-24 10:55:54 +02:00
Jarvis 7b23ed6615 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
- FreewritingCleanupData 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:25:22 +02:00
AlexKucera 565cddf86c Updates Anthropic API to use structured content
Adapts the Anthropic client to use the new structured content format
for messages and system prompts, ensuring compatibility with the API's
expected input structure. This change modifies both the standard
request and the test request within the Anthropic client.
2025-09-26 08:52:24 +02:00
AlexKucera a63d184448 Implements freewriting cleanup plugin
Adds a plugin to clean up freewriting text using the Anthropic API.

This initial commit introduces core functionality, including:
- API client for interacting with Anthropic's Claude models.
- Service for orchestrating cleanup operations and managing API calls.
- Command for executing the cleanup process on selected text within Obsidian editor.
- Settings tab for configuring the API key, model, prompts, and commentary preferences.
- Type definitions for settings, API requests/responses, and cleanup results.

The plugin provides a command to clean up selected text, apply custom prompts, and optionally generate commentary on the freewriting session.
2025-09-20 12:14:55 +02:00