Back to .md Directory

Implementation Plan - NanoBanana PRO Obsidian Plugin

Specifies converting a QuickAdd script into an Obsidian plugin that generates AI-powered infographic posters from notes.

May 2, 2026
0 downloads
1 views
ai prompt openai gemini
View source

What this file does

Specifies converting a QuickAdd script into an Obsidian plugin that generates AI-powered infographic posters from notes.

When to use it

  • Building an Obsidian plugin that calls multiple AI APIs
  • Implementing a multi-step generation workflow with progress feedback
  • Adding retry logic and error handling for API calls in Obsidian
  • Structuring a plugin with settings, modals, and file operations

Assumes this stack

TypeScriptObsidian APIGoogle GeminiOpenAIAnthropicxAI

Implementation Plan - NanoBanana PRO Obsidian Plugin

Goal Description

Convert the existing nanoBananaInfographic.js QuickAdd script into a full-featured Obsidian Community Plugin named nanobanana-pro-obsidian. The plugin will generate "Knowledge Posters" (infographics) from Obsidian notes using AI.

Core Features

Three-Step Process

  1. Prompt Generation: Analyze the note content and generate a detailed image prompt
    • Configurable providers: OpenAI, Gemini, Anthropic, XAI
  2. Image Generation: Generate the infographic using Google's Gemini model
    • Default: gemini-2.0-flash-exp (with image generation capability)
  3. Embed: Save the image locally and embed it at the top of the note

Plugin Structure

nanobanana-pro-obsidian/
├── manifest.json           # Plugin metadata
├── package.json            # NPM configuration
├── tsconfig.json           # TypeScript configuration
├── esbuild.config.mjs      # Build configuration
├── README.md               # Documentation
├── SPEC.md                 # This file
├── styles.css              # Plugin styles
└── src/
    ├── main.ts             # Main plugin class
    ├── types.ts            # Type definitions
    ├── settings.ts         # Settings tab UI
    ├── settingsData.ts     # Default settings
    ├── progressModal.ts    # Progress modal UI
    ├── previewModal.ts     # Prompt preview modal
    └── services/
        ├── promptService.ts    # AI prompt generation
        ├── imageService.ts     # Image generation
        └── fileService.ts      # File operations

Settings Configuration

API Keys Section

SettingTypeDescription
googleApiKeystringGoogle AI API key (for image generation)
openaiApiKeystringOpenAI API key
anthropicApiKeystringAnthropic API key
xaiApiKeystringxAI API key

Prompt Generation Section

SettingTypeDefaultDescription
selectedProviderenum'google'AI provider for prompt generation
promptModelstring'gemini-2.0-flash-exp'Model name for prompt generation

Image Generation Section

SettingTypeDefaultDescription
imageModelstring'gemini-2.0-flash-exp'Model for image generation
imageStyleenum'infographic'Style preset

UX Settings

SettingTypeDefaultDescription
showPreviewBeforeGenerationbooleantrueShow prompt preview before generating
attachmentFolderstring'999-Attachments'Folder to save images
autoRetryCountnumber2Auto-retry on failure
showProgressModalbooleantrueShow progress during generation

UX Enhancement Features

1. Progress Modal

Real-time feedback during the generation process:

┌─────────────────────────────────────────┐
│  🎨 Knowledge Poster 생성 중...          │
│                                         │
│  ████████████░░░░░░░░ 60%              │
│                                         │
│  ✅ 1. 노트 분석 완료                    │
│  ✅ 2. 프롬프트 생성 완료                 │
│  🔄 3. 이미지 생성 중...                 │
│  ⏳ 4. 파일 저장 대기                    │
│                                         │
│  예상 소요 시간: 약 15-30초              │
│                                         │
│  [취소]                                 │
└─────────────────────────────────────────┘

2. Prompt Preview Modal

Optional preview and edit before image generation:

┌─────────────────────────────────────────┐
│  📝 프롬프트 미리보기                     │
│                                         │
│  ┌─────────────────────────────────┐   │
│  │ Create a visually stunning     │   │
│  │ infographic poster about...    │   │
│  │ [editable text area]           │   │
│  └─────────────────────────────────┘   │
│                                         │
│  🤖 모델: gemini-2.0-flash-exp          │
│  📊 스타일: Infographic                  │
│                                         │
│  [이미지 생성] [다시 생성] [취소]          │
└─────────────────────────────────────────┘

3. Error Handling System

Error Types & User Messages

Error TypeUser MessageAction
INVALID_API_KEY"API 키가 유효하지 않습니다. 설정을 확인해주세요."Open settings
RATE_LIMIT"API 요청 한도 초과. 잠시 후 다시 시도해주세요."Auto-retry
NETWORK_ERROR"네트워크 연결 오류. 인터넷 연결을 확인해주세요."Retry button
GENERATION_FAILED"이미지 생성 실패. 다른 스타일로 시도해보세요."Suggest alternatives
CONTENT_FILTERED"콘텐츠 정책으로 인해 생성할 수 없습니다."Modify prompt

Auto-Retry Logic

async function executeWithRetry<T>(
  operation: () => Promise<T>,
  maxRetries: number = 2,
  delay: number = 1000
): Promise<T> {
  for (let attempt = 0; attempt <= maxRetries; attempt++) {
    try {
      return await operation();
    } catch (error) {
      if (attempt === maxRetries) throw error;
      if (!isRetryableError(error)) throw error;
      await sleep(delay * Math.pow(2, attempt)); // Exponential backoff
    }
  }
}

4. Success Notification

┌─────────────────────────────────────┐
│ ✅ Knowledge Poster 생성 완료!       │
│                                     │
│ 📁 저장 위치: 999-Attachments/      │
│ 📄 파일명: note-poster-2025.png     │
│                                     │
│ [노트 보기] [갤러리 열기]            │
└─────────────────────────────────────┘

Commands

CommandDescription
Generate Knowledge PosterFull generation process
Generate Prompt OnlyGenerate and copy prompt to clipboard
Regenerate Last PosterRetry last generation
Open SettingsOpen plugin settings

API Integration

Prompt Generation Endpoints

ProviderEndpointAuth Header
OpenAIhttps://api.openai.com/v1/chat/completionsAuthorization: Bearer {key}
Googlehttps://generativelanguage.googleapis.com/v1beta/models/{model}:generateContentx-goog-api-key: {key}
Anthropichttps://api.anthropic.com/v1/messagesx-api-key: {key}
xAIhttps://api.x.ai/v1/chat/completionsAuthorization: Bearer {key}

Image Generation

Google Gemini with image output:

const response = await fetch(
  `https://generativelanguage.googleapis.com/v1beta/models/${model}:generateContent`,
  {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json',
      'x-goog-api-key': apiKey
    },
    body: JSON.stringify({
      contents: [{ parts: [{ text: prompt }] }],
      generationConfig: {
        responseModalities: ["TEXT", "IMAGE"]
      }
    })
  }
);

File Operations

Image Saving

  1. Parse base64 image from API response
  2. Generate unique filename: {noteBasename}-poster-{timestamp}.png
  3. Save to configured attachment folder
  4. Return relative path for embedding

Note Modification

  1. Read current note content
  2. Check for existing poster embed
  3. Insert/replace image embed at top of note
  4. Preserve frontmatter if exists

Verification Plan

Build Verification

npm install
npm run build
# Should produce main.js without errors

Manual Testing Checklist

  • Plugin loads in Obsidian without errors
  • Settings tab displays all options correctly
  • API key validation works for each provider
  • Progress modal shows during generation
  • Prompt preview modal works correctly
  • Image saves to correct folder
  • Image embeds at top of note
  • Error messages display appropriately
  • Auto-retry works on transient failures
  • Cancel button stops generation

Distribution

GitHub Repository Structure

nanobanana-pro-obsidian/
├── .github/
│   └── workflows/
│       └── release.yml     # Auto-release workflow
├── src/                    # Source files
├── manifest.json
├── package.json
├── README.md
└── ...

BRAT Installation

Users can install via BRAT by adding:

username/nanobanana-pro-obsidian

Release Files

  • main.js - Compiled plugin
  • manifest.json - Plugin metadata
  • styles.css - Plugin styles

Version History

VersionChanges
1.0.0Initial release with core features

Note: Model names like gemini-2.0-flash-exp may change. The plugin allows manual model name input for future compatibility.

What's inside

14 sections covering goal, features, structure, settings, UX, commands, APIs, file ops, verification, distribution, and version history

Change this for your project

  • Replace reallygood83/nanobanana-pro-obsidian with your own GitHub username and repo name
  • Replace gemini-2.0-flash-exp with the actual model you intend to use
  • Replace 999-Attachments with your preferred default attachment folder
  • Replace nanoBananaInfographic.js with your own source script name

Where it goes

Keep in docs/ or alongside the feature. Agents read it to implement against a defined contract.

Worth borrowing

  • Exponential backoff retry logic for transient API failures
  • Separating prompt generation and image generation into distinct services
  • Using a progress modal with step-by-step status updates

Related Documents