Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ Notely is built with Electron + React and is designed for project notes, meeting
- Preview Mermaid diagrams and rendered Markdown content.
- Create and edit structured technical diagrams with **Draw.io integration** directly from markdown previews, supporting drag-and-drop import for `.drawio` and `.drawio.xml` files, image export, and offline drawing.
- Visualize the workspace as an interactive note graph.
- Use built-in AI features powered by Vercel AI SDK (Gemini, Groq, OpenAI) with a 3-Brain Architecture (`WorkspaceBrain`, `ReasoningBrain`, `ActionBrain`), autonomous multi-step Planner, semantic domain tools, local-first Embeddings Engine (`BGE-small-en-v1.5` ONNX model), recursive SQLite Knowledge Graph, strict read-only note immutability safeguards, ReAct self-correction engine (`SelfCorrectionEngine`), and an automated diagnostic evaluation harness (`AgentHarness`).
- Use built-in AI features powered by Vercel AI SDK (Gemini, Groq, OpenAI / OpenAI-compatible endpoints) with a 3-Brain Architecture (`WorkspaceBrain`, `ReasoningBrain`, `ActionBrain`), autonomous multi-step Planner, semantic domain tools, local-first ONNX Embeddings Engine (`BGE-small-en-v1.5`), zero-latency Context Compaction (`CompactionEngine`), local GLiNER2 ONNX Knowledge Graph Engine, strict read-only note immutability safeguards, ReAct self-correction engine (`SelfCorrectionEngine`), and an automated diagnostic evaluation harness (`AgentHarness`).
- Aggregate tasks across notes with **Open Tasks** and **All Tasks** panels.
- Open Tasks focuses on unchecked items.
- All Tasks includes open + closed items with filtering and note grouping.
Expand All @@ -61,7 +61,7 @@ Notely is built with Electron + React and is designed for project notes, meeting
- Optional `.notes-app` metadata inclusion (default off)
- View note statistics (word count, line count, reading time estimate) in the status bar.
- Copy note content as HTML or plain text directly from the editor toolbar.
- Execute JavaScript (`js`/`javascript`) and Python (`py`/`python`) code blocks locally with the interactive ▶ Run (Play) button in both Markdown Previews and the popup Code Editor modal. Outputs (stdout/stderr) are rendered in an integrated high-contrast dark terminal output pane.
- Execute JavaScript (`js`/`javascript`), Python (`py`/`python`), Bash (`bash`/`sh`), PowerShell (`powershell`/`ps1`), and HTML live-preview code blocks locally with the interactive ▶ Run (Play) button in both Markdown Previews and the popup Code Editor modal. Outputs (stdout/stderr) are rendered in an integrated high-contrast dark terminal output pane.
- Navigate nested folders with breadcrumb links for easy folder traversal.
- Navigate active note tabs using **Ctrl+Tab** (next tab) and **Ctrl+Shift+Tab** (previous tab) standard shortcuts.
- Copy note link paths relative to the current workspace root from right-click context menus on tabs and dashboard document list items.
Expand Down
2 changes: 2 additions & 0 deletions docs-site/.vitepress/config.mts
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ export default withMermaid(
{ text: "Home", link: "/" },
{ text: "Getting Started", link: "/getting-started/" },
{ text: "Editor", link: "/editor/" },
{ text: "Workspace", link: "/workspace/" },
{ text: "Git", link: "/git/" },
{ text: "AI", link: "/ai/" },
{
Expand Down Expand Up @@ -92,6 +93,7 @@ export default withMermaid(
items: [
{ text: "Workspace Overview", link: "/workspace/" },
{ text: "Tasks", link: "/workspace/tasks" },
{ text: "Calendar", link: "/workspace/calendar" },
{ text: "Media", link: "/workspace/media" },
{ text: "Screen Capture", link: "/workspace/screen-capture" },
{ text: "Workspace Graph", link: "/workspace/graph" },
Expand Down
13 changes: 6 additions & 7 deletions docs/ai/setup.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
title: Setting Up AI Providers
description: Configure AI settings, API keys, local endpoints, and feature flags.
keywords: AI settings, API key, Ollama, OpenAI, Gemini, Groq, HuggingFace, ONNX, BGE embeddings
keywords: AI settings, API key, OpenAI, Gemini, Groq, HuggingFace, ONNX, BGE embeddings
category: AI
---

Expand All @@ -13,12 +13,11 @@ Configure LLM provider models, API tokens, and local vector index settings insid

## 1. Text Generation Providers

Notely uses the **Vercel AI SDK** and local bindings to connect to multiple LLM APIs:
- **Local (Qwen2.5-0.5B)**: Runs completely on-device and offline. Requires downloading local GGUF weights (~400MB) via the settings dashboard.
- **Google Gemini**: Requires a Gemini API key. Highly recommended for rich tool calling.
- **Groq**: Requires a Groq API key (supports models like `llama-3.3-70b-specdec`).
- **OpenAI Compatible**: Connect to OpenAI or local servers (Ollama, LM Studio) by setting a custom Base URL and Model name.
- **Connection Diagnostics**: Click the **Test** button next to any configured provider to run a diagnostic round-trip test.
Notely connects to cloud and custom LLM providers using the **Vercel AI SDK**:
- **Google Gemini**: Requires a Gemini API key. Default provider (`gemini-2.0-flash`), recommended for rich tool calling.
- **Groq**: Requires a Groq API key (supports models like `llama-3.3-70b-versatile`, `llama-3.1-8b-instant`, `deepseek-r1-distill-llama-70b`).
- **OpenAI / OpenAI-Compatible**: Connect to OpenAI (`gpt-4o`, `gpt-4o-mini`) or custom compatible endpoints by setting an API Key and custom Base URL.
- **Connection Diagnostics**: Click the **Test** button next to any configured provider in **AI Settings** to verify connection status.

---

Expand Down
9 changes: 7 additions & 2 deletions docs/architecture.md
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ The Electron main process (`electron/main.cjs` & `electron/lib/`) coordinates ap
* **Vector Embeddings Engine (`EmbeddingDB.js`)**: Stores 384-dimensional `BGE-small` vector chunks in `{workspace}/.notes-app/ai-embeddings.db`. Features physical vector dimension validation (`verifyModelDimensions`) to prevent dimension mismatches.
* **Knowledge Graph Subsystem (`GraphService.js`, `GraphDB.js`)**: Maps note relations, tags, mentions, Wikilinks, Images, Local Documents, and External URLs in `{workspace}/.notes-app/ai-graph.db`. Executes relation traversals via SQLite **Recursive Common Table Expressions (CTEs)**.
* **Agent & Tool Orchestration**: Integrates with a local embedding runtime and cloud LLMs (Gemini, Groq, OpenAI) using the Vercel AI SDK.
* **Local GGUF Engines**: Supports local text generation and offline graph extraction via `node-llama-cpp`. `LocalModelManager` handles shared runtime loads of the Qwen GGUF model to prevent CPU/RAM overheads.
* **Local ONNX Neural Models**: Vector embeddings (`BGE-small-en-v1.5`) and Knowledge Graph entity/relationship extraction (`gliner2-multi-v1-onnx`) run 100% on-device and offline using `onnxruntime-node`.

#### AI Layer Architecture

Expand Down Expand Up @@ -235,9 +235,11 @@ graph TD
end

subgraph CacheDir ["📁 .notes-app (Hidden Cache Folder)"]
TDB[("task-db.sqlite<br/>(Task DB & Bi-directional Sync)")]
VECDB[("ai-embeddings.db<br/>(384-dim Vector BLOBs)")]
GDB[("ai-graph.db<br/>(Entities & CTE Edges)")]
LDB[("ai-logs.db<br/>(System & App Logs)")]
STATE["app-state.json / metadata"]
end
end

Expand All @@ -261,7 +263,10 @@ graph TD
* Video & Audio recordings (`.mp4`, `.webm`, `.mp3`, `.wav`, `.m4a`).
* Document attachments (`.pdf`).
* Excalidraw drawing files (`.excalidraw`).
* **Hidden Subsystem Folder (`{workspace}/.notes-app/`)**: Internal SQLite caches for AI and system features:
* **Hidden Subsystem Folder (`{workspace}/.notes-app/`)**: Internal SQLite caches for AI, tasks, and system features:
* `task-db.sqlite`: Stores workspace-wide task metadata, priorities, due dates, assignee tags, source note hashes, and line indices for bi-directional checklist synchronization.
* `ai-embeddings.db`: Stores chunk text, line offsets, hashes, and 384-dimensional binary vector `BLOB`s.
* `ai-graph.db`: Stores extracted Knowledge Graph entity nodes, Wikilinks, media links, and relationship edges.
* `ai-logs.db`: Stores multitenant application, git, embedding, graph, and AI log entries.
* `app-state.json`: Caches workspace UI state, last opened note handles, and view preferences.

91 changes: 78 additions & 13 deletions docs/developer/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,25 +9,90 @@ category: Developer

Notely is built with Electron, React, and Vite.

## Architecture
## 1. Core Architecture & Process Model

```mermaid
graph TD
A[Electron Main Process] -->|IPC Bridges| B[Electron Preload Script]
B -->|Services| C[React Renderer Frontend]
D[Local Filesystem] <--> A
E[Git Binary] <--> A
A[Electron Main Process main.cjs] -->|ContextBridge| B[Preload Bridge preload.cjs]
B -->|React Hooks & Services| C[React Renderer Process src/]
A -->|UtilityProcess| D[AI Background Worker workerProcess.cjs]
A -->|Node.js child_process| E[Native Git & PTY Terminals]
A <--> F[(SQLite & Markdown Storage)]
```

- **Main Process (`electron/main.cjs`)**: Handles system calls, window lifecycle, local file input/output, Git operations via `simple-git`, and local network pairing processes.
- **Preload (`electron/preload.cjs`)**: Exposes structured API handles safely to the renderer context using `contextBridge`.
- **Renderer (`src/`)**: Built using React, CodeMirror for the editor canvas, and Lucide for icons.
- **Main Process (`electron/main.cjs`)**: Handles window lifecycle, file I/O, IPC handler registration, menu creation, and system integrations.
- **Background Utility Process (`workerManager.cjs` / `workerProcess.cjs`)**: Spawns an isolated Node.js `UtilityProcess` for asynchronous vector embedding generation and Knowledge Graph indexing. This keeps background indexing CPU spikes off the main thread.
- **Preload Bridge (`electron/preload.cjs`)**: Exposes safe, validated IPC invocation methods to `window.electronAPI`.
- **Renderer Process (`src/`)**: React 18 frontend with Vite, CodeMirror 6 editor canvas, KaTeX rendering, and Lucide icons.

---

## Build Tasks
## 2. IPC Channel Security Guard Pattern

All `ipcMain.handle` endpoints MUST enforce IPC security guards and payload validation:

1. **Sender Authentication (`assertTrustedIpcSender`)**: Enforces that IPC invocation events originate strictly from verified internal application renderer windows, rejecting unauthorized external or injected frame messages:
```javascript
const { assertTrustedIpcSender } = require("./ipcSecurity.cjs");
ipcMain.handle("myChannel", async (event, rawPayload) => {
assertTrustedIpcSender(BrowserWindow, event, "myChannel");
// ...
});
```
2. **Payload Schema Validation (`ipcSchemas.cjs`)**: Validate raw payloads against strict schema contracts (`validatePayload`) to ensure type safety before processing file paths or commands.

---

## 3. Development Workflow & Commands

### Development Server
```bash
npm run dev
```
Launches Vite HMR server and Electron wrapper simultaneously.

### Build Production Bundle
```bash
npm run build
```
Compiles Vite frontend assets and validates CommonJS Electron main scripts.

### Documentation Site
```bash
npm run docs:dev # Launch VitePress live preview server
npm run docs:build # Build static production docs site
```

---

## 4. Test Suite Execution

Notely uses **Vitest** for comprehensive unit, integration, and IPC service testing:

```bash
# Run all unit and integration tests
npm test

# Run tests in watch mode
npm run test:watch

# Run P2P network integration test harness
npm run test:p2p
```

### Key Test Directories
- `tests/ai/`: Core AI orchestration, 5-stage `AIFlow`, 4-layer planning, compaction, and facade integrity tests.
- `tests/golden_workspace.test.js`: Workspace creation, note CRUD, task database sync, and file watcher tests.
- `electron/lib/ipc/codeExecutorIpc.test.js`: Code execution runner tests.
- `electron/p2p/p2pLive.test.js`: Peer-to-peer discovery and encrypted handshake tests.

---

## 5. Build & Packaging Scripts

For generating standalone distribution packages:

- **Windows Executable Build Script (`build-windows-exe.sh`)**: Compiles and bundles a standalone Windows executable.
- **Release Packaging Script (`release.sh`)**: Automates version stamping, package archive creation, and release checksum generation.
- **Icon Generation (`scripts/generate-icon.cjs`)**: Generates app icons from source image assets (`process.env.NOTELY_ICON_SOURCE`).

- **`npm run dev`**: Starts Vite dev server and runs the Electron wrapper.
- **`npm run build`**: Compiles assets for distribution.
- **`npm run docs:dev`**: Launch VitePress development site.
- **`npm run docs:build`**: Builds the static documentation site.
16 changes: 11 additions & 5 deletions docs/editor/code-blocks.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,18 +67,24 @@ Click **Save** to write changes back to the note, or **Cancel** to discard.
You can run code snippets directly from your notes:

1. Hover over a code block in **Preview** mode.
2. If the block is written in JavaScript (`js`, `javascript`) or Python (`py`, `python`), the **▶ Run** button in the hover toolbar will be active.
3. Click **▶ Run** to execute the script locally.
4. The output is displayed in a collapsible, high-contrast dark terminal output frame beneath the code block.
2. If the block is written in a supported language, the **▶ Run** button in the hover toolbar will be active.
3. Supported execution languages include:
- **JavaScript** (`js`, `javascript`): runs locally via `node`.
- **Python** (`py`, `python`): runs locally via system `python` / `python3`.
- **Bash** (`sh`, `bash`): runs shell scripts locally via `bash` or `sh`.
- **PowerShell** (`ps1`, `powershell`): runs scripts via `powershell` or `pwsh`.
- **HTML** (`html`): renders live HTML DOM output inside an interactive preview drawer.
4. Click **▶ Run** to execute the script or preview output.
5. Command outputs (stdout/stderr) are displayed in a collapsible, high-contrast dark terminal output frame beneath the code block.

You can also execute code from inside the **Dedicated Code Editor** modal using the **Execute** button in the top toolbar.

::: warning Security Note
Running code execution spawns a local process on your machine using your local `node` or `python`/`python3` installation. Only run code from trusted workspaces and sources.
Running code execution spawns a local process on your machine using your local system environment. Only run code from trusted workspaces and sources.
:::

::: info Execution Limits & Loops
Code execution terminates automatically after 10 seconds. If your code hangs or enters an infinite loop, the runner will kill the subprocess safely and report a timeout error.
Code execution terminates automatically after 10 seconds. If your code hangs or enters an infinite loop, the runner will kill the subprocess safely and report a timeout error. Buffer sizes are capped at 64KB.
:::

## Supported Languages
Expand Down
2 changes: 1 addition & 1 deletion docs/editor/diagrams.md
Original file line number Diff line number Diff line change
Expand Up @@ -128,5 +128,5 @@ Drop any existing `.drawio` or `.drawio.xml` file directly into the Markdown Edi
|---|---|---|---|
| **Best for** | Fast text-based flows, timelines | Casual sketching, wireframes | Engineering schematics, network charts |
| **Editing** | Text syntax | Visual canvas | Visual canvas |
| **Storage** | Plain Markdown text | XML drawing + PNG preview | XML drawing + PNG preview |
| **Storage** | Plain Markdown text | JSON `.excalidraw` + SVG preview | XML `.drawio` + PNG preview |
| **Offline** | ✓ | ✓ | ✓ |
2 changes: 1 addition & 1 deletion docs/feature-reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ Notely provides a rich experience for working with code snippets:
- **Auto-detection**: Paste a snippet without a language tag and Notely will automatically detect it (e.g., JavaScript, Python, HTML).
- **Auto-formatting**: Use the 🪄 Format button in the preview hover toolbar or inside the editor to instantly auto-indent and format your code using Prettier.
- **Dedicated Editor**: Click the ✎ Edit button on any code block in Preview mode to open a distraction-free Code Editor popup with syntax highlighting, search, and language selection.
- **Code Execution**: Click the ▶ Run button in the hover toolbar or inside the popup editor to execute JavaScript (`js`, `javascript`) and Python (`py`, `python`) snippets locally. Output is displayed in an integrated high-contrast dark terminal output drawer (with exit status and a "Clear" button). Execution times out automatically after 10 seconds to prevent hanging. For other languages, the run button is disabled with a helpful tooltip.
- **Code Execution**: Click the ▶ Run button in the hover toolbar or inside the popup editor to execute JavaScript (`js`), Python (`py`), Bash (`sh`), PowerShell (`ps1`), and HTML live-preview snippets locally. Output is displayed in an integrated high-contrast dark terminal output drawer (with exit status and a "Clear" button). Execution times out automatically after 10 seconds to prevent hanging. For unsupported languages, the run button is disabled with a helpful tooltip.

### Find and replace

Expand Down
2 changes: 1 addition & 1 deletion docs/git/branches.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ Configure an upstream remote (like GitHub, GitLab, or a self-hosted Git server)
- **Pull**: Fetch and merge changes from the remote repository to update your local workspace.
- **Push**: Upload your local commits to the remote repository.

Credentials are saved securely within your system keychain.
Authentication uses Personal Access Tokens (PAT). When performing remote actions with a PAT, Notely temporarily injects the token into the git remote URL for the operation and immediately restores the clean original URL afterwards, keeping plain-text credentials out of persistent repository settings.

---

Expand Down
Loading
Loading