9 Commits
Author SHA1 Message Date
Jarvis 39c9578ebc chore: release 1.1.1
🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-09-21 08:03:50 +02:00
Jarvis 143097a973 fix: improve TypeScript type safety
- Replace any types with proper Obsidian API types
- Add App type import for better type safety
- Add ButtonComponent type for settings button parameter
- Add null safety for button text content
- Remove redundant "Settings" from settings tab heading

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-09-21 08:02:16 +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 8147662d61 Adds plugin combination recommendations
Recommends complementary plugins to enhance the freewriting workflow, suggesting specific usage patterns and benefits.
2025-09-20 14:21:11 +02:00
Jarvis 6729851cb4 chore: release 1.1.0
- Enhanced staggered prompts with ultra-short, direct prompts
- Improved notification timing to prevent overlap
- Fixed Obsidian compliance issues
- Better TypeScript type safety

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-09-20 11:09:31 +02:00
AlexKucera c34ee2edd6 Enhances prompt generation with type-specific instructions
Refines prompt generation by incorporating modifiers based on the prompt type.

This ensures that staggered prompts are short and direct, while also enforcing a consistent output format across all prompt types by appending specific instructions to the system prompt.

The user message is also updated to ensure the model returns only the numbered prompts, nothing else.
2025-09-20 10:55:06 +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 eaab2012db Improves staggered prompt display timing
Ensures prompt notifications display correctly
by adjusting the notification duration based
on the configured delay. Prevents potential overlap
between successive prompts.
2025-09-20 10:52:41 +02:00
Jarvis 49e3f5523c fix: address Obsidian review bot issues
- Move inline styles from TypeScript to CSS for better theme compatibility
- Remove "Freewriting" from command names to follow Obsidian conventions
- Fix TypeScript type casting by properly typing model as AnthropicModel
- Update to latest Claude models including Opus 4.1 and Sonnet 4

Changes:
• commands/staggeredPrompts.ts: Replace inline styles with CSS class
• main.ts: Rename commands to "Show Staggered Prompts" and "Add Note Prompts"
• settings.ts: Remove 'as any' cast and update default model
• styles.css: Add .freewriting-prompt-notice class with proper styling
• types.ts: Change model field type from string to AnthropicModel

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-09-20 10:32:35 +02:00
13 changed files with 182 additions and 108 deletions

No files matched your search

+38 -2
View File
@@ -7,6 +7,41 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased]
## [1.1.1] - 2025-01-21
### Added
- Plugin combination recommendations for enhanced writing workflow
### Changed
- **Command Naming**: Renamed "Staggered Prompts" to "Timed Prompts" for better clarity
- Command now called "Show Timed Prompts" instead of "Show Staggered Prompts"
- Settings renamed from "Staggered Count" to "Timed Count"
- All user-facing text updated to reflect regular interval timing rather than staggered/irregular timing
### Fixed
- **Type Safety**: Improved TypeScript type safety throughout codebase
- Replaced `any` types with proper Obsidian API types (App, ButtonComponent)
- Added null safety for button text content
- Enhanced code quality and maintainability
- **Settings UI**: Removed redundant "Settings" text from settings tab heading
## [1.1.0] - 2025-01-20
### Changed
- **Enhanced Staggered Prompts**: Now generates ultra-short, direct prompts perfect for quick responses (1-5 words or single sentence)
- **Improved Timing**: Fixed staggered prompt display timing to prevent notification overlap with smooth fade transitions
- **Better Type Safety**: Simplified prompt generation model usage with proper TypeScript typing
### Fixed
- **Obsidian Compliance**: Moved inline styles to CSS for better theme compatibility
- **Command Naming**: Updated command names to follow Obsidian conventions ("Show Staggered Prompts", "Add Note Prompts")
- **Code Quality**: Removed TypeScript type casting issues and improved code structure
### Technical Details
- Type-specific prompt generation (staggered vs note prompts use different instructions)
- Dynamic notification duration based on user delay settings
- Enhanced Claude model support including latest Opus 4.1 and Sonnet models
## [1.0.0] - 2025-01-20
### Added
@@ -52,5 +87,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Input validation for all user settings
- Rate limiting awareness with appropriate error handling
[Unreleased]: https://github.com/alexanderkucera/obsidian-freewriting-prompts/compare/v1.0.0...HEAD
[1.0.0]: https://github.com/alexanderkucera/obsidian-freewriting-prompts/releases/tag/v1.0.0
[Unreleased]: https://github.com/alexanderkucera/obsidian-freewriting-prompts/compare/1.1.0...HEAD
[1.1.0]: https://github.com/alexanderkucera/obsidian-freewriting-prompts/compare/1.0.0...1.1.0
[1.0.0]: https://github.com/alexanderkucera/obsidian-freewriting-prompts/releases/tag/1.0.0
+30 -8
View File
@@ -21,7 +21,7 @@ Generate AI-powered writing prompts for freewriting sessions using Anthropic's C
## Key Features
- **🎯 Two Prompt Modes**: Staggered notifications for timed writing sessions, or direct note insertion
- **🎯 Two Prompt Modes**: Timed notifications for writing sessions, or direct note insertion
- **🤖 AI-Powered**: Uses Anthropic's Claude models for creative, diverse prompt generation
- **⚡ Customizable Timing**: Configure prompt count and delay intervals for your writing rhythm
- **🎨 Personalized Prompts**: System prompts and examples to match your writing style
@@ -41,6 +41,28 @@ Writer's block is real, and sometimes you need external inspiration to get the c
Rather than browsing random prompt websites or books, get personalized, AI-generated prompts delivered right in your writing environment.
## Perfect Plugin Combination
This plugin works exceptionally well with other freewriting tools to create a complete writing workflow:
### ✍️ [Freewriting Cleanup](https://github.com/AlexKucera/freewriting-cleanup)
Transform your messy freewriting into polished prose using AI. Perfect companion to this plugin:
1. **Generate inspiration** with creative prompts from this plugin
2. **Write freely** without worrying about mistakes
3. **Clean up the output** with Freewriting Cleanup to polish your raw writing
### 📝 [Digital Paper](https://github.com/danferns/digital-paper-obsidian-plugin)
Write without the ability to delete or edit - just like pen on paper. Perfect for true freewriting sessions:
1. **Enable Digital Paper mode** to disable all delete functions (backspace, delete key, Ctrl+X)
2. **Use this plugin** to generate writing prompts for inspiration
3. **Write continuously** without stopping to edit or second-guess yourself
4. **Clean up afterwards** using Freewriting Cleanup to polish the unedited output
**Recommended Workflow:**
- Generate prompts with this plugin when you need inspiration
- Enable Digital Paper mode for uninterrupted freewriting sessions
- Use Freewriting Cleanup to polish your raw, unedited writing into readable text
## Installation
### Method 1: Community Plugin Store (Recommended)
@@ -84,7 +106,7 @@ Rather than browsing random prompt websites or books, get personalized, AI-gener
### 3. Start Using Prompts
**For Timed Writing Sessions:**
1. Use `Ctrl/Cmd + P` → "Staggered Freewriting Prompts"
1. Use `Ctrl/Cmd + P` → "Show Timed Prompts"
2. Prompts will appear as notifications at your configured intervals
**For Note Integration:**
@@ -105,19 +127,19 @@ Rather than browsing random prompt websites or books, get personalized, AI-gener
| Setting | Description | Default | Range |
|---------|-------------|---------|-------|
| **Staggered Count** | Number of timed prompts | 10 | 1-50 |
| **Timed Count** | Number of timed prompts | 10 | 1-50 |
| **Delay Seconds** | Seconds between prompts | 6 | 1-300 |
| **Note Count** | Prompts inserted in notes | 3 | 1-20 |
### Prompt Customization
- **System Prompt**: Instructions for the AI on how to generate prompts
- **Staggered Example**: Example prompt for timed sessions
- **Timed Example**: Example prompt for timed sessions
- **Freewriting Example**: Example prompt for note insertion
## Commands
### Staggered Freewriting Prompts
### Timed Freewriting Prompts
Delivers prompts as timed notifications perfect for writing sprints:
@@ -147,9 +169,9 @@ Inserts prompts directly into your current note:
- Creating prompt libraries
- Inspiration gathering
### Stop Staggered Prompts
### Stop Timed Prompts
Cancels any running staggered prompt sequence.
Cancels any running timed prompt sequence.
## Settings
@@ -228,7 +250,7 @@ freewriting-prompts/
├── api/
│ └── anthropicClient.ts # Anthropic API integration
├── commands/
│ ├── staggeredPrompts.ts # Timed notification prompts
│ ├── timedPrompts.ts # Timed notification prompts
│ └── notePrompts.ts # Note insertion prompts
├── services/
│ └── promptGenerator.ts # Prompt generation service
+17 -5
View File
@@ -7,6 +7,9 @@ import { AnthropicRequest, AnthropicResponse, AnthropicModel } from '../types';
export class AnthropicClient {
private apiKey: string;
private baseUrl = 'https://api.anthropic.com/v1/messages';
private readonly SYSTEM_PROMPT_SUFFIX = '\n\nIMPORTANT OUTPUT REQUIREMENTS:\n- Return ONLY the numbered writing prompts, nothing else\n- Do not include any explanations, questions, or additional commentary\n- Do not ask if the user wants more prompts or different styles\n- Format: numbered list with one prompt per line (1. [prompt], 2. [prompt], etc.)';
private readonly TIMED_PROMPT_MODIFIER = '\n\nFOR TIMED PROMPTS - MAKE THEM EXTREMELY SHORT AND DIRECT:\n- Each prompt should be answerable in 1-5 words or a single sentence\n- Focus on immediate, concrete observations or quick thoughts\n- Avoid complex scenarios or deep philosophical questions\n- Examples: "What color is closest to you?", "Your favorite word today:", "First sound you hear:", "Describe your mood in one word", "Name something soft"\n- Keep prompts simple, immediate, and concrete';
constructor(apiKey: string) {
this.apiKey = apiKey;
@@ -18,7 +21,8 @@ export class AnthropicClient {
count: number,
model: AnthropicModel,
systemPrompt: string,
examplePrompt: string
examplePrompt: string,
type: 'timed' | 'note'
): Promise<string[]> {
if (!this.apiKey) {
throw new Error('API key is required');
@@ -26,11 +30,19 @@ export class AnthropicClient {
try {
const userMessage = this.createUserMessage(count, examplePrompt);
// Build system prompt with type-specific modifiers
let finalSystemPrompt = systemPrompt;
if (type === 'timed') {
finalSystemPrompt += this.TIMED_PROMPT_MODIFIER;
}
finalSystemPrompt += this.SYSTEM_PROMPT_SUFFIX;
const request: AnthropicRequest = {
model,
max_tokens: 1000,
messages: [{ role: 'user', content: userMessage }],
system: systemPrompt
system: finalSystemPrompt
};
const response = await this.makeRequest(request);
@@ -48,13 +60,13 @@ export class AnthropicClient {
// MARK: - Private Methods
private createUserMessage(count: number, examplePrompt: string): string {
const baseMessage = `Please generate ${count} creative writing prompts.`;
const baseMessage = `Generate exactly ${count} creative writing prompts. Return ONLY the numbered prompts with no additional text or commentary.`;
if (examplePrompt.trim()) {
return `${baseMessage} Here's an example of the style I'm looking for:\n\n"${examplePrompt}"\n\nPlease provide ${count} similar prompts, each on a new line, numbered 1-${count}.`;
return `${baseMessage}\n\nExample style: "${examplePrompt}"\n\nProvide ${count} similar prompts in this exact format:\n1. [prompt]\n2. [prompt]\n(etc.)`;
}
return `${baseMessage} Please provide ${count} diverse and engaging writing prompts, each on a new line, numbered 1-${count}.`;
return `${baseMessage}\n\nProvide ${count} diverse writing prompts in this exact format:\n1. [prompt]\n2. [prompt]\n(etc.)`;
}
private async makeRequest(request: AnthropicRequest): Promise<AnthropicResponse> {
+2 -2
View File
@@ -1,7 +1,7 @@
// ABOUTME: Note prompts command implementation that appends prompts to the current note
// ABOUTME: Handles editor interaction, cursor positioning, and prompt formatting
import { Editor, MarkdownView, Notice } from 'obsidian';
import { App, Editor, MarkdownView, Notice } from 'obsidian';
import { PromptGeneratorService } from '../services/promptGenerator';
import { FreewritingPromptsSettings } from '../types';
@@ -107,7 +107,7 @@ export class NotePromptsCommand {
return !!(editor && view && view.file);
}
static getExecutionContext(app: any): { editor: Editor | null; view: MarkdownView | null } {
static getExecutionContext(app: App): { editor: Editor | null; view: MarkdownView | null } {
const activeView = app.workspace.getActiveViewOfType(MarkdownView);
if (!activeView) {
@@ -1,11 +1,11 @@
// ABOUTME: Staggered prompts command implementation that shows prompts as timed notifications
// ABOUTME: Timed prompts command implementation that shows prompts as timed notifications
// ABOUTME: Manages interval-based prompt display with proper cleanup and error handling
import { Notice } from 'obsidian';
import { PromptGeneratorService } from '../services/promptGenerator';
import { FreewritingPromptsSettings } from '../types';
export class StaggeredPromptsCommand {
export class TimedPromptsCommand {
private activeInterval: number | null = null;
private promptQueue: string[] = [];
private currentIndex = 0;
@@ -15,12 +15,12 @@ export class StaggeredPromptsCommand {
// MARK: - Public Methods
async execute(settings: FreewritingPromptsSettings): Promise<void> {
// Stop any existing staggered sequence
// Stop any existing timed sequence
this.stop();
try {
// Generate prompts
const prompts = await this.promptGenerator.generateStaggeredPrompts(settings);
const prompts = await this.promptGenerator.generateTimedPrompts(settings);
if (prompts.length === 0) {
new Notice('No prompts were generated');
@@ -32,7 +32,7 @@ export class StaggeredPromptsCommand {
this.currentIndex = 0;
// Show the first prompt immediately
this.showCurrentPrompt();
this.showCurrentPrompt(settings.delaySeconds);
// If there are more prompts, start the interval
if (prompts.length > 1) {
@@ -40,7 +40,7 @@ export class StaggeredPromptsCommand {
}
} catch (error) {
console.error('Error executing staggered prompts command:', error);
console.error('Error executing timed prompts command:', error);
// Error handling is done in the service layer
}
}
@@ -65,7 +65,7 @@ export class StaggeredPromptsCommand {
this.currentIndex++;
if (this.currentIndex < this.promptQueue.length) {
this.showCurrentPrompt();
this.showCurrentPrompt(delaySeconds);
} else {
// We've shown all prompts, stop the interval
this.stop();
@@ -74,25 +74,24 @@ export class StaggeredPromptsCommand {
}, delaySeconds * 1000);
}
private showCurrentPrompt(): void {
private showCurrentPrompt(delaySeconds: number): void {
if (this.currentIndex < this.promptQueue.length) {
const prompt = this.promptQueue[this.currentIndex];
const promptNumber = this.currentIndex + 1;
const totalPrompts = this.promptQueue.length;
// Create a longer-lasting notice for the prompt
// Calculate notification duration: slightly less than delay to avoid overlap
// Subtract 500ms to allow for fade-out before next prompt appears
const notificationDuration = Math.max(1000, (delaySeconds * 1000) - 500);
const notice = new Notice(
`Writing Prompt ${promptNumber}/${totalPrompts}:\n\n${prompt}`,
8000 // Show for 8 seconds
notificationDuration
);
// Add some styling to make it more prominent
// Add CSS class for styling
const noticeEl = notice.noticeEl;
if (noticeEl) {
noticeEl.style.maxWidth = '400px';
noticeEl.style.whiteSpace = 'pre-wrap';
noticeEl.style.fontSize = '14px';
noticeEl.style.lineHeight = '1.4';
noticeEl.addClass('freewriting-prompt-notice');
}
}
+30 -30
View File
@@ -5,13 +5,13 @@ import { Editor, MarkdownView, Notice, Plugin } from 'obsidian';
import { FreewritingPromptsSettings } from './types';
import { DEFAULT_SETTINGS, FreewritingPromptsSettingTab } from './settings';
import { PromptGeneratorService } from './services/promptGenerator';
import { StaggeredPromptsCommand } from './commands/staggeredPrompts';
import { TimedPromptsCommand } from './commands/timedPrompts';
import { NotePromptsCommand } from './commands/notePrompts';
export default class FreewritingPromptsPlugin extends Plugin {
settings: FreewritingPromptsSettings;
promptGenerator: PromptGeneratorService;
staggeredCommand: StaggeredPromptsCommand;
timedCommand: TimedPromptsCommand;
noteCommand: NotePromptsCommand;
async onload() {
@@ -19,7 +19,7 @@ export default class FreewritingPromptsPlugin extends Plugin {
// Initialize services
this.promptGenerator = new PromptGeneratorService(this.settings);
this.staggeredCommand = new StaggeredPromptsCommand(this.promptGenerator);
this.timedCommand = new TimedPromptsCommand(this.promptGenerator);
this.noteCommand = new NotePromptsCommand(this.promptGenerator);
// Register commands
@@ -30,9 +30,9 @@ export default class FreewritingPromptsPlugin extends Plugin {
}
onunload() {
// Stop any running staggered prompts
if (this.staggeredCommand) {
this.staggeredCommand.stop();
// Stop any running timed prompts
if (this.timedCommand) {
this.timedCommand.stop();
}
// Clear prompt cache
@@ -59,40 +59,40 @@ export default class FreewritingPromptsPlugin extends Plugin {
// MARK: - Command Registration
private registerCommands() {
// Staggered Freewriting Prompts command
// Timed prompts command
this.addCommand({
id: 'staggered-freewriting-prompts',
name: 'Staggered Freewriting Prompts',
id: 'timed-prompts',
name: 'Show Timed Prompts',
callback: async () => {
await this.executeStaggeredPrompts();
await this.executeTimedPrompts();
}
});
// Freewriting Prompt command (editor-based)
// Note prompt command (editor-based)
this.addCommand({
id: 'freewriting-prompt',
name: 'Freewriting Prompt',
id: 'note-prompts',
name: 'Add Note Prompts',
editorCallback: async (editor: Editor, view: MarkdownView) => {
await this.executeNotePrompts(editor, view);
}
});
// Stop staggered prompts command
// Stop timed prompts command
this.addCommand({
id: 'stop-staggered-prompts',
name: 'Stop Staggered Prompts',
id: 'stop-timed-prompts',
name: 'Stop Timed Prompts',
callback: () => {
this.stopStaggeredPrompts();
this.stopTimedPrompts();
}
});
}
// MARK: - Command Implementations
private async executeStaggeredPrompts(): Promise<void> {
// Check if staggered prompts are already running
if (this.staggeredCommand.isRunning()) {
new Notice('Staggered prompts are already running. Use "Stop Staggered Prompts" to stop them first.');
private async executeTimedPrompts(): Promise<void> {
// Check if timed prompts are already running
if (this.timedCommand.isRunning()) {
new Notice('Timed prompts are already running. Use "Stop Timed Prompts" to stop them first.');
return;
}
@@ -104,9 +104,9 @@ export default class FreewritingPromptsPlugin extends Plugin {
}
try {
await this.staggeredCommand.execute(this.settings);
await this.timedCommand.execute(this.settings);
} catch (error) {
console.error('Error executing staggered prompts:', error);
console.error('Error executing timed prompts:', error);
// Error handling is done in the command layer
}
}
@@ -133,18 +133,18 @@ export default class FreewritingPromptsPlugin extends Plugin {
}
}
private stopStaggeredPrompts(): void {
if (this.staggeredCommand.isRunning()) {
this.staggeredCommand.stop();
new Notice('Staggered prompts stopped');
private stopTimedPrompts(): void {
if (this.timedCommand.isRunning()) {
this.timedCommand.stop();
new Notice('Timed prompts stopped');
} else {
new Notice('No staggered prompts are currently running');
new Notice('No timed prompts are currently running');
}
}
// MARK: - Public API for Settings
getStaggeredStatus(): { isRunning: boolean; currentPrompt: number; totalPrompts: number } {
return this.staggeredCommand.getStatus();
getTimedStatus(): { isRunning: boolean; currentPrompt: number; totalPrompts: number } {
return this.timedCommand.getStatus();
}
}
+1 -1
View File
@@ -1,7 +1,7 @@
{
"id": "freewriting-prompts",
"name": "Freewriting Prompts",
"version": "1.0.0",
"version": "1.1.1",
"minAppVersion": "1.9.12",
"description": "Generate AI-powered writing prompts for freewriting sessions using Anthropic's Claude.",
"author": "Alexander Kucera",
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "obsidian-freewriting-prompts",
"version": "1.0.0",
"version": "1.1.1",
"description": "Generate AI-powered writing prompts for freewriting sessions using Anthropic's Claude.",
"main": "main.js",
"scripts": {
+10 -10
View File
@@ -21,20 +21,20 @@ export class PromptGeneratorService {
// MARK: - Public Methods
async generateStaggeredPrompts(settings: FreewritingPromptsSettings): Promise<string[]> {
async generateTimedPrompts(settings: FreewritingPromptsSettings): Promise<string[]> {
return this.generatePrompts(
settings.staggeredCount,
settings.model as AnthropicModel,
settings.timedCount,
settings.model,
settings.systemPrompt,
settings.staggeredExamplePrompt,
'staggered'
settings.timedExamplePrompt,
'timed'
);
}
async generateNotePrompts(settings: FreewritingPromptsSettings): Promise<string[]> {
return this.generatePrompts(
settings.noteCount,
settings.model as AnthropicModel,
settings.model,
settings.systemPrompt,
settings.freewritingExamplePrompt,
'note'
@@ -57,7 +57,7 @@ export class PromptGeneratorService {
model: AnthropicModel,
systemPrompt: string,
examplePrompt: string,
type: 'staggered' | 'note'
type: 'timed' | 'note'
): Promise<string[]> {
if (!this.client.validateApiKey()) {
new Notice('Please configure your Anthropic API key in settings');
@@ -73,7 +73,7 @@ export class PromptGeneratorService {
try {
new Notice('Generating prompts...');
const prompts = await this.client.generatePrompts(count, model, systemPrompt, examplePrompt);
const prompts = await this.client.generatePrompts(count, model, systemPrompt, examplePrompt, type);
const generatedPrompts: GeneratedPrompt[] = prompts.map(text => ({
text,
@@ -138,8 +138,8 @@ export class PromptGeneratorService {
errors.push('API key is required');
}
if (settings.staggeredCount < 1 || settings.staggeredCount > 50) {
errors.push('Staggered count must be between 1 and 50');
if (settings.timedCount < 1 || settings.timedCount > 50) {
errors.push('Timed count must be between 1 and 50');
}
if (settings.delaySeconds < 1 || settings.delaySeconds > 300) {
+19 -19
View File
@@ -1,18 +1,18 @@
// ABOUTME: Settings interface and SettingTab implementation for the Freewriting Prompts plugin
// ABOUTME: Handles user configuration including API key, model selection, and prompt customization
import { App, Notice, PluginSettingTab, Setting } from 'obsidian';
import { App, ButtonComponent, Notice, PluginSettingTab, Setting } from 'obsidian';
import FreewritingPromptsPlugin from './main';
import { FreewritingPromptsSettings, ANTHROPIC_MODELS } from './types';
import { FreewritingPromptsSettings, ANTHROPIC_MODELS, AnthropicModel } from './types';
export const DEFAULT_SETTINGS: FreewritingPromptsSettings = {
apiKey: '',
model: 'claude-3-haiku-20240307',
staggeredCount: 10,
model: 'claude-3-5-haiku-latest' as const,
timedCount: 10,
delaySeconds: 6,
noteCount: 3,
systemPrompt: 'You are a creative writing assistant. Generate engaging, thought-provoking writing prompts that inspire creativity and help writers overcome blocks. Focus on variety, originality, and emotional depth.',
staggeredExamplePrompt: 'The interesting thing about a rose is…',
timedExamplePrompt: 'The interesting thing about a rose is…',
freewritingExamplePrompt: 'Describe a world where colors have been outlawed and only exist in secret underground galleries.'
};
@@ -28,7 +28,7 @@ export class FreewritingPromptsSettingTab extends PluginSettingTab {
const { containerEl } = this;
containerEl.empty();
containerEl.createEl('h2', { text: 'Freewriting Prompts Settings' });
containerEl.createEl('h2', { text: 'Freewriting Prompts' });
// MARK: - API Configuration
@@ -69,7 +69,7 @@ export class FreewritingPromptsSettingTab extends PluginSettingTab {
dropdown
.setValue(this.plugin.settings.model)
.onChange(async (value) => {
this.plugin.settings.model = value;
this.plugin.settings.model = value as AnthropicModel;
await this.plugin.saveSettings();
});
});
@@ -79,22 +79,22 @@ export class FreewritingPromptsSettingTab extends PluginSettingTab {
containerEl.createEl('h3', { text: 'Command Configuration' });
new Setting(containerEl)
.setName('Staggered Prompts Count')
.setDesc('Number of prompts to generate for staggered notifications (1-50)')
.setName('Timed Prompts Count')
.setDesc('Number of prompts to generate for timed notifications (1-50)')
.addText(text => text
.setPlaceholder('10')
.setValue(this.plugin.settings.staggeredCount.toString())
.setValue(this.plugin.settings.timedCount.toString())
.onChange(async (value) => {
const count = parseInt(value);
if (!isNaN(count) && count >= 1 && count <= 50) {
this.plugin.settings.staggeredCount = count;
this.plugin.settings.timedCount = count;
await this.plugin.saveSettings();
}
}));
new Setting(containerEl)
.setName('Delay Between Prompts')
.setDesc('Seconds to wait between each staggered prompt notification (1-300)')
.setDesc('Seconds to wait between each timed prompt notification (1-300)')
.addText(text => text
.setPlaceholder('6')
.setValue(this.plugin.settings.delaySeconds.toString())
@@ -139,13 +139,13 @@ export class FreewritingPromptsSettingTab extends PluginSettingTab {
});
new Setting(containerEl)
.setName('Staggered Prompts Example')
.setDesc('Example prompt to guide the style for staggered notifications')
.setName('Timed Prompts Example')
.setDesc('Example prompt to guide the style for timed notifications')
.addTextArea(text => text
.setPlaceholder('Write about a character who...')
.setValue(this.plugin.settings.staggeredExamplePrompt)
.setValue(this.plugin.settings.timedExamplePrompt)
.onChange(async (value) => {
this.plugin.settings.staggeredExamplePrompt = value;
this.plugin.settings.timedExamplePrompt = value;
await this.plugin.saveSettings();
}))
.then(setting => {
@@ -185,8 +185,8 @@ export class FreewritingPromptsSettingTab extends PluginSettingTab {
// MARK: - API Testing
private async testApiKey(button: any): Promise<void> {
const originalText = button.buttonEl.textContent;
private async testApiKey(button: ButtonComponent): Promise<void> {
const originalText = button.buttonEl.textContent || 'Test Connection';
// Update button to show loading state
button.setButtonText('Testing...');
@@ -194,7 +194,7 @@ export class FreewritingPromptsSettingTab extends PluginSettingTab {
try {
const client = this.plugin.promptGenerator.anthropicClient;
const result = await client.testApiKey(this.plugin.settings.model as any);
const result = await client.testApiKey(this.plugin.settings.model);
if (result.success) {
// Success - show detailed information
+9 -6
View File
@@ -1,8 +1,11 @@
/*
This CSS file will be included with your plugin, and
available in the app when your plugin is enabled.
If your plugin does not need CSS, delete this file.
Freewriting Prompts Plugin Styles
*/
/* Styling for timed prompt notifications */
.freewriting-prompt-notice {
max-width: 400px !important;
white-space: pre-wrap !important;
font-size: 14px !important;
line-height: 1.4 !important;
}
+9 -8
View File
@@ -3,12 +3,12 @@
export interface FreewritingPromptsSettings {
apiKey: string;
model: string;
staggeredCount: number;
model: AnthropicModel;
timedCount: number;
delaySeconds: number;
noteCount: number;
systemPrompt: string;
staggeredExamplePrompt: string;
timedExamplePrompt: string;
freewritingExamplePrompt: string;
}
@@ -47,11 +47,12 @@ export interface GeneratedPrompt {
}
export const ANTHROPIC_MODELS = [
'claude-3-haiku-20240307',
'claude-3-sonnet-20240229',
'claude-3-opus-20240229',
'claude-3-5-sonnet-20241022',
'claude-3-5-haiku-20241022'
'claude-opus-4-1-20250805',
'claude-opus-4-20250514',
'claude-sonnet-4-20250514',
'claude-3-7-sonnet-latest',
'claude-3-5-haiku-latest',
'claude-3-haiku-20240307'
] as const;
export type AnthropicModel = typeof ANTHROPIC_MODELS[number];
+2 -1
View File
@@ -1,3 +1,4 @@
{
"1.0.0": "0.15.0"
"1.0.0": "0.15.0",
"1.1.1": "1.9.12"
}