Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6729851cb4 | ||
|
|
c34ee2edd6 | ||
|
|
2fbe582c4d | ||
|
|
eaab2012db | ||
|
|
49e3f5523c |
No files matched your search
+20
-2
@@ -7,6 +7,23 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||||||
|
|
||||||
## [Unreleased]
|
## [Unreleased]
|
||||||
|
|
||||||
|
## [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
|
## [1.0.0] - 2025-01-20
|
||||||
|
|
||||||
### Added
|
### Added
|
||||||
@@ -52,5 +69,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||||||
- Input validation for all user settings
|
- Input validation for all user settings
|
||||||
- Rate limiting awareness with appropriate error handling
|
- Rate limiting awareness with appropriate error handling
|
||||||
|
|
||||||
[Unreleased]: https://github.com/alexanderkucera/obsidian-freewriting-prompts/compare/v1.0.0...HEAD
|
[Unreleased]: https://github.com/alexanderkucera/obsidian-freewriting-prompts/compare/1.1.0...HEAD
|
||||||
[1.0.0]: https://github.com/alexanderkucera/obsidian-freewriting-prompts/releases/tag/v1.0.0
|
[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
|
||||||
+17
-5
@@ -7,6 +7,9 @@ import { AnthropicRequest, AnthropicResponse, AnthropicModel } from '../types';
|
|||||||
export class AnthropicClient {
|
export class AnthropicClient {
|
||||||
private apiKey: string;
|
private apiKey: string;
|
||||||
private baseUrl = 'https://api.anthropic.com/v1/messages';
|
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 STAGGERED_PROMPT_MODIFIER = '\n\nFOR STAGGERED 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) {
|
constructor(apiKey: string) {
|
||||||
this.apiKey = apiKey;
|
this.apiKey = apiKey;
|
||||||
@@ -18,7 +21,8 @@ export class AnthropicClient {
|
|||||||
count: number,
|
count: number,
|
||||||
model: AnthropicModel,
|
model: AnthropicModel,
|
||||||
systemPrompt: string,
|
systemPrompt: string,
|
||||||
examplePrompt: string
|
examplePrompt: string,
|
||||||
|
type: 'staggered' | 'note'
|
||||||
): Promise<string[]> {
|
): Promise<string[]> {
|
||||||
if (!this.apiKey) {
|
if (!this.apiKey) {
|
||||||
throw new Error('API key is required');
|
throw new Error('API key is required');
|
||||||
@@ -26,11 +30,19 @@ export class AnthropicClient {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
const userMessage = this.createUserMessage(count, examplePrompt);
|
const userMessage = this.createUserMessage(count, examplePrompt);
|
||||||
|
|
||||||
|
// Build system prompt with type-specific modifiers
|
||||||
|
let finalSystemPrompt = systemPrompt;
|
||||||
|
if (type === 'staggered') {
|
||||||
|
finalSystemPrompt += this.STAGGERED_PROMPT_MODIFIER;
|
||||||
|
}
|
||||||
|
finalSystemPrompt += this.SYSTEM_PROMPT_SUFFIX;
|
||||||
|
|
||||||
const request: AnthropicRequest = {
|
const request: AnthropicRequest = {
|
||||||
model,
|
model,
|
||||||
max_tokens: 1000,
|
max_tokens: 1000,
|
||||||
messages: [{ role: 'user', content: userMessage }],
|
messages: [{ role: 'user', content: userMessage }],
|
||||||
system: systemPrompt
|
system: finalSystemPrompt
|
||||||
};
|
};
|
||||||
|
|
||||||
const response = await this.makeRequest(request);
|
const response = await this.makeRequest(request);
|
||||||
@@ -48,13 +60,13 @@ export class AnthropicClient {
|
|||||||
// MARK: - Private Methods
|
// MARK: - Private Methods
|
||||||
|
|
||||||
private createUserMessage(count: number, examplePrompt: string): string {
|
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()) {
|
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> {
|
private async makeRequest(request: AnthropicRequest): Promise<AnthropicResponse> {
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ export class StaggeredPromptsCommand {
|
|||||||
this.currentIndex = 0;
|
this.currentIndex = 0;
|
||||||
|
|
||||||
// Show the first prompt immediately
|
// Show the first prompt immediately
|
||||||
this.showCurrentPrompt();
|
this.showCurrentPrompt(settings.delaySeconds);
|
||||||
|
|
||||||
// If there are more prompts, start the interval
|
// If there are more prompts, start the interval
|
||||||
if (prompts.length > 1) {
|
if (prompts.length > 1) {
|
||||||
@@ -65,7 +65,7 @@ export class StaggeredPromptsCommand {
|
|||||||
this.currentIndex++;
|
this.currentIndex++;
|
||||||
|
|
||||||
if (this.currentIndex < this.promptQueue.length) {
|
if (this.currentIndex < this.promptQueue.length) {
|
||||||
this.showCurrentPrompt();
|
this.showCurrentPrompt(delaySeconds);
|
||||||
} else {
|
} else {
|
||||||
// We've shown all prompts, stop the interval
|
// We've shown all prompts, stop the interval
|
||||||
this.stop();
|
this.stop();
|
||||||
@@ -74,25 +74,24 @@ export class StaggeredPromptsCommand {
|
|||||||
}, delaySeconds * 1000);
|
}, delaySeconds * 1000);
|
||||||
}
|
}
|
||||||
|
|
||||||
private showCurrentPrompt(): void {
|
private showCurrentPrompt(delaySeconds: number): void {
|
||||||
if (this.currentIndex < this.promptQueue.length) {
|
if (this.currentIndex < this.promptQueue.length) {
|
||||||
const prompt = this.promptQueue[this.currentIndex];
|
const prompt = this.promptQueue[this.currentIndex];
|
||||||
const promptNumber = this.currentIndex + 1;
|
const promptNumber = this.currentIndex + 1;
|
||||||
const totalPrompts = this.promptQueue.length;
|
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(
|
const notice = new Notice(
|
||||||
`Writing Prompt ${promptNumber}/${totalPrompts}:\n\n${prompt}`,
|
`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;
|
const noticeEl = notice.noticeEl;
|
||||||
if (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');
|
noticeEl.addClass('freewriting-prompt-notice');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -59,19 +59,19 @@ export default class FreewritingPromptsPlugin extends Plugin {
|
|||||||
// MARK: - Command Registration
|
// MARK: - Command Registration
|
||||||
|
|
||||||
private registerCommands() {
|
private registerCommands() {
|
||||||
// Staggered Freewriting Prompts command
|
// Staggered prompts command
|
||||||
this.addCommand({
|
this.addCommand({
|
||||||
id: 'staggered-freewriting-prompts',
|
id: 'staggered-prompts',
|
||||||
name: 'Staggered Freewriting Prompts',
|
name: 'Show Staggered Prompts',
|
||||||
callback: async () => {
|
callback: async () => {
|
||||||
await this.executeStaggeredPrompts();
|
await this.executeStaggeredPrompts();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// Freewriting Prompt command (editor-based)
|
// Note prompt command (editor-based)
|
||||||
this.addCommand({
|
this.addCommand({
|
||||||
id: 'freewriting-prompt',
|
id: 'note-prompts',
|
||||||
name: 'Freewriting Prompt',
|
name: 'Add Note Prompts',
|
||||||
editorCallback: async (editor: Editor, view: MarkdownView) => {
|
editorCallback: async (editor: Editor, view: MarkdownView) => {
|
||||||
await this.executeNotePrompts(editor, view);
|
await this.executeNotePrompts(editor, view);
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"id": "freewriting-prompts",
|
"id": "freewriting-prompts",
|
||||||
"name": "Freewriting Prompts",
|
"name": "Freewriting Prompts",
|
||||||
"version": "1.0.0",
|
"version": "1.1.0",
|
||||||
"minAppVersion": "1.9.12",
|
"minAppVersion": "1.9.12",
|
||||||
"description": "Generate AI-powered writing prompts for freewriting sessions using Anthropic's Claude.",
|
"description": "Generate AI-powered writing prompts for freewriting sessions using Anthropic's Claude.",
|
||||||
"author": "Alexander Kucera",
|
"author": "Alexander Kucera",
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ export class PromptGeneratorService {
|
|||||||
async generateStaggeredPrompts(settings: FreewritingPromptsSettings): Promise<string[]> {
|
async generateStaggeredPrompts(settings: FreewritingPromptsSettings): Promise<string[]> {
|
||||||
return this.generatePrompts(
|
return this.generatePrompts(
|
||||||
settings.staggeredCount,
|
settings.staggeredCount,
|
||||||
settings.model as AnthropicModel,
|
settings.model,
|
||||||
settings.systemPrompt,
|
settings.systemPrompt,
|
||||||
settings.staggeredExamplePrompt,
|
settings.staggeredExamplePrompt,
|
||||||
'staggered'
|
'staggered'
|
||||||
@@ -34,7 +34,7 @@ export class PromptGeneratorService {
|
|||||||
async generateNotePrompts(settings: FreewritingPromptsSettings): Promise<string[]> {
|
async generateNotePrompts(settings: FreewritingPromptsSettings): Promise<string[]> {
|
||||||
return this.generatePrompts(
|
return this.generatePrompts(
|
||||||
settings.noteCount,
|
settings.noteCount,
|
||||||
settings.model as AnthropicModel,
|
settings.model,
|
||||||
settings.systemPrompt,
|
settings.systemPrompt,
|
||||||
settings.freewritingExamplePrompt,
|
settings.freewritingExamplePrompt,
|
||||||
'note'
|
'note'
|
||||||
@@ -73,7 +73,7 @@ export class PromptGeneratorService {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
new Notice('Generating prompts...');
|
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 => ({
|
const generatedPrompts: GeneratedPrompt[] = prompts.map(text => ({
|
||||||
text,
|
text,
|
||||||
|
|||||||
+4
-4
@@ -3,11 +3,11 @@
|
|||||||
|
|
||||||
import { App, Notice, PluginSettingTab, Setting } from 'obsidian';
|
import { App, Notice, PluginSettingTab, Setting } from 'obsidian';
|
||||||
import FreewritingPromptsPlugin from './main';
|
import FreewritingPromptsPlugin from './main';
|
||||||
import { FreewritingPromptsSettings, ANTHROPIC_MODELS } from './types';
|
import { FreewritingPromptsSettings, ANTHROPIC_MODELS, AnthropicModel } from './types';
|
||||||
|
|
||||||
export const DEFAULT_SETTINGS: FreewritingPromptsSettings = {
|
export const DEFAULT_SETTINGS: FreewritingPromptsSettings = {
|
||||||
apiKey: '',
|
apiKey: '',
|
||||||
model: 'claude-3-haiku-20240307',
|
model: 'claude-3-5-haiku-latest' as const,
|
||||||
staggeredCount: 10,
|
staggeredCount: 10,
|
||||||
delaySeconds: 6,
|
delaySeconds: 6,
|
||||||
noteCount: 3,
|
noteCount: 3,
|
||||||
@@ -69,7 +69,7 @@ export class FreewritingPromptsSettingTab extends PluginSettingTab {
|
|||||||
dropdown
|
dropdown
|
||||||
.setValue(this.plugin.settings.model)
|
.setValue(this.plugin.settings.model)
|
||||||
.onChange(async (value) => {
|
.onChange(async (value) => {
|
||||||
this.plugin.settings.model = value;
|
this.plugin.settings.model = value as AnthropicModel;
|
||||||
await this.plugin.saveSettings();
|
await this.plugin.saveSettings();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@@ -194,7 +194,7 @@ export class FreewritingPromptsSettingTab extends PluginSettingTab {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
const client = this.plugin.promptGenerator.anthropicClient;
|
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) {
|
if (result.success) {
|
||||||
// Success - show detailed information
|
// Success - show detailed information
|
||||||
|
|||||||
+9
-6
@@ -1,8 +1,11 @@
|
|||||||
/*
|
/*
|
||||||
|
Freewriting Prompts Plugin Styles
|
||||||
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.
|
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/* Styling for staggered prompt notifications */
|
||||||
|
.freewriting-prompt-notice {
|
||||||
|
max-width: 400px !important;
|
||||||
|
white-space: pre-wrap !important;
|
||||||
|
font-size: 14px !important;
|
||||||
|
line-height: 1.4 !important;
|
||||||
|
}
|
||||||
@@ -3,7 +3,7 @@
|
|||||||
|
|
||||||
export interface FreewritingPromptsSettings {
|
export interface FreewritingPromptsSettings {
|
||||||
apiKey: string;
|
apiKey: string;
|
||||||
model: string;
|
model: AnthropicModel;
|
||||||
staggeredCount: number;
|
staggeredCount: number;
|
||||||
delaySeconds: number;
|
delaySeconds: number;
|
||||||
noteCount: number;
|
noteCount: number;
|
||||||
@@ -47,11 +47,12 @@ export interface GeneratedPrompt {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export const ANTHROPIC_MODELS = [
|
export const ANTHROPIC_MODELS = [
|
||||||
'claude-3-haiku-20240307',
|
'claude-opus-4-1-20250805',
|
||||||
'claude-3-sonnet-20240229',
|
'claude-opus-4-20250514',
|
||||||
'claude-3-opus-20240229',
|
'claude-sonnet-4-20250514',
|
||||||
'claude-3-5-sonnet-20241022',
|
'claude-3-7-sonnet-latest',
|
||||||
'claude-3-5-haiku-20241022'
|
'claude-3-5-haiku-latest',
|
||||||
|
'claude-3-haiku-20240307'
|
||||||
] as const;
|
] as const;
|
||||||
|
|
||||||
export type AnthropicModel = typeof ANTHROPIC_MODELS[number];
|
export type AnthropicModel = typeof ANTHROPIC_MODELS[number];
|
||||||
Reference in new issue
Block a user