|
1 | 1 | # CLAUDE.md |
2 | 2 |
|
3 | | -This file provides guidance to Claude Code when working with code in this repository. |
| 3 | +This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository. |
4 | 4 |
|
5 | 5 | ## Project Overview |
6 | 6 |
|
7 | 7 | ChatGPT MD is an Obsidian plugin that integrates multiple AI providers (OpenAI, OpenRouter, Anthropic, Gemini, Ollama, LM Studio) into Obsidian for seamless chat interactions within markdown notes. Users can have AI conversations directly in their notes, with support for note linking, streaming responses, and per-note configuration via frontmatter. |
8 | 8 |
|
9 | | -## v3.0.0 Release - Privacy-First AI Tool Calling |
| 9 | +## v3.0.0 - Privacy-First AI Tool Calling |
10 | 10 |
|
11 | | -**Latest Release**: v3.0.0 (December 2025) |
12 | | - |
13 | | -Major new feature: **Privacy-first AI tool calling** with human-in-the-loop approval: |
| 11 | +Major feature: **Privacy-first AI tool calling** with human-in-the-loop approval: |
14 | 12 |
|
15 | 13 | - **Vault Search**: AI can search your notes (you approve which files to share) |
16 | 14 | - **File Reading**: AI can request access to specific files (you select which ones) |
17 | 15 | - **Web Search**: AI can search the web via Brave Search API (1,000 free queries/month) |
18 | 16 | - **Three-Layer Approval**: Approve execution → Review results → Select what to share |
19 | | -- **All tools disabled by default** (opt-in feature only) |
20 | | - |
21 | | -See [`planning/code-review/`](planning/code-review/) for comprehensive code review and implementation guidance. |
| 17 | +- **All tools disabled by default** (opt-in via Settings → ChatGPT MD → Tool Calling) |
22 | 18 |
|
23 | 19 | ## Quick Reference |
24 | 20 |
|
25 | 21 | **Entry point**: `src/main.ts` → `main.js` |
26 | 22 |
|
27 | | -**Common commands**: |
| 23 | +**Commands**: |
28 | 24 |
|
29 | 25 | ```bash |
30 | 26 | npm run dev # Development with watch mode |
31 | 27 | npm run build # Production build with TypeScript checks |
32 | 28 | npm run lint # Check code quality |
33 | 29 | npm run lint:fix # Auto-fix linting issues |
| 30 | +npm run analyze # Bundle size analysis |
34 | 31 | ``` |
35 | 32 |
|
| 33 | +**No test suite**: This project does not currently have automated tests. |
| 34 | + |
36 | 35 | ## Architecture Overview |
37 | 36 |
|
38 | | -The plugin uses **Service Locator pattern** for dependency injection: |
| 37 | +The plugin uses **constructor injection** via `ServiceContainer`: |
39 | 38 |
|
40 | | -- `src/core/ServiceLocator.ts` - Central DI container |
41 | | -- `src/core/CommandRegistry.ts` - Manages all Obsidian commands |
42 | | -- AI services implement `IAiApiService` interface |
| 39 | +- `src/core/ServiceContainer.ts` - DI container with readonly service instances |
| 40 | +- `src/Commands/` - Command handlers (extracted from old CommandRegistry) |
| 41 | +- `src/Services/AiProviderService.ts` - Unified AI service with adapter pattern |
43 | 42 |
|
44 | | -**Message flow**: User command → EditorService extracts messages → MessageService parses → AI service calls API → Response streamed to editor |
| 43 | +**AI SDK**: Uses Vercel AI SDK (`ai` package) with provider-specific adapters (`@ai-sdk/openai`, `@ai-sdk/anthropic`, `@ai-sdk/google`, `@openrouter/ai-sdk-provider`). |
| 44 | + |
| 45 | +**Message flow**: User command → EditorService extracts messages → MessageService parses → AiProviderService calls API → Response streamed to editor |
45 | 46 |
|
46 | 47 | ## Code Organization |
47 | 48 |
|
48 | | -Each directory has its own CLAUDE.md with detailed context that auto-loads when you work in that area: |
| 49 | +Each directory has its own CLAUDE.md with detailed context: |
49 | 50 |
|
50 | | -- `src/core/` - Core infrastructure (ServiceLocator, CommandRegistry) |
51 | | -- `src/Services/` - Service implementations |
52 | | -- `src/Views/` - UI components |
| 51 | +- `src/core/` - ServiceContainer (DI) |
| 52 | +- `src/Commands/` - Obsidian command handlers |
| 53 | +- `src/Services/` - Service implementations + `Adapters/` subdirectory |
| 54 | +- `src/Views/` - UI components and modals |
53 | 55 | - `src/Models/` - TypeScript interfaces |
| 56 | +- `src/Types/` - AI service type definitions |
| 57 | +- `src/Utilities/` - Pure helper functions |
54 | 58 |
|
55 | 59 | ## Cross-cutting Documentation |
56 | 60 |
|
57 | | -For topics that span multiple areas: |
58 | | - |
59 | 61 | - **[docs/development.md](docs/development.md)** - Build process, tooling, esbuild setup |
60 | 62 | - **[docs/message-flow.md](docs/message-flow.md)** - Complete flow from user input to AI response |
61 | 63 |
|
62 | 64 | ## Key Design Patterns |
63 | 65 |
|
64 | | -1. **Service Locator** - Centralized dependency injection |
65 | | -2. **Strategy Pattern** - Different AI services, same interface |
| 66 | +1. **Constructor Injection** - Dependencies passed via ServiceContainer |
| 67 | +2. **Adapter Pattern** - Provider-specific adapters implement common interface |
66 | 68 | 3. **Frontmatter-driven config** - Per-note settings override globals |
67 | | -4. **Streaming responses** - Real-time AI output with SSE |
| 69 | +4. **Streaming responses** - Real-time AI output via Vercel AI SDK |
68 | 70 | 5. **Link context injection** - Auto-include `[[Wiki Links]]` in prompts |
0 commit comments