Commit Graph
10 Commits
Author SHA1 Message Date
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 de98d4a52d Handles model changes when current model unavailable
Improves model selection logic to automatically switch to the first available model when the current model is no longer valid

Adds fallback mechanism to prevent potential configuration errors
Logs model switching for debugging and transparency
2025-10-24 11:05:45 +02:00
AlexKucera 5c8314a986 Enhances model loading in settings display
Modifies display method to load models asynchronously in the background

Improves user experience by:
- Removing async modifier from display method
- Handling model loading as a background task
- Adding error handling for model loading
- Preparing to update UI dynamically when models are loaded
2025-10-24 11:04:35 +02:00
AlexKucera fcc495aa8f Enhances model service fallback and caching logic
Improves model retrieval strategy for scenarios with invalid/missing API keys

Adds immediate fallback model generation when API key is invalid
Ensures consistent model caching for both API and fallback scenarios
Sorts model options alphabetically for improved user experience

Introduces new getFallbackOptions() method for direct fallback access
Refactors model refresh and error handling to provide more robust model selection
2025-10-24 11:00:42 +02:00
AlexKucera eae48521c5 Refactors confirmation modal with Obsidian integration
Replaces custom modal implementation with Obsidian's Modal class for improved consistency and accessibility

Enhances API key management with dynamic model refreshing and fallback handling
Improves event handling and modal interaction patterns
2025-10-24 10:44:53 +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 13b2567672 Avoids potential null reference error
Ensures that the modal element is not null before attempting to append it to the document body or remove it from its parent node. This prevents potential errors if the modal element is not properly initialized.
2025-09-26 08:58:23 +02:00
Jarvis 178a9e6618 security: fix innerHTML usage in settings to prevent XSS vulnerabilities
Replaces innerHTML usage with Obsidian's safe DOM manipulation methods:
- Line 150: Use createEl() and appendText() for commentary style display
- Lines 159-168: Build usage instructions with createEl() instead of innerHTML

This addresses the Obsidian Review Bot security warning and follows
the official guidelines: https://docs.obsidian.md/Plugins/User+interface/HTML+elements

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-09-21 07:40:39 +02:00
Jarvis 809fce9c89 refactor: prepare plugin for Obsidian community submission
- Fix command name from "Clean Up Freewriting" to "Clean up text" to follow Obsidian guidelines (no plugin name in command)
- Replace inline JavaScript styles with CSS classes for better theme compatibility
- Add proper CSS styles in styles.css for textarea and description elements
- Correct license information in README from MIT to GPL v3 to match actual LICENSE file
- Update README documentation to reflect new command name

These changes address common Obsidian plugin review feedback:
- Avoid assigning styles via JavaScript
- Command names should not include plugin name
- Maintain consistency between documentation and actual license

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-09-20 12:34:09 +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