commit 53078c351aab844e8426ae6ae0c977804cff0a97 Author: Jacob Schmidt Date: Sat Feb 21 02:01:00 2026 -0600 Initial commit: Journal.Core library + Sidecar console app diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..960e0be --- /dev/null +++ b/.editorconfig @@ -0,0 +1,5 @@ +[*.cs] +# Prefer expression body for single-line constructors/methods/properties +csharp_style_expression_bodied_constructors = when_on_single_line:suggestion +csharp_style_expression_bodied_methods = when_on_single_line:suggestion +csharp_style_expression_bodied_properties = true:suggestion \ No newline at end of file diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..f9e8871 --- /dev/null +++ b/.gitignore @@ -0,0 +1,52 @@ +# Build output +bin/ +obj/ + +# Visual Studio +.vs/ +*.user +*.suo +*.userosscache +*.sln.docstates + +# Rider +.idea/ +*.sln.iml + +# VS Code +.vscode/ + +# NuGet +*.nupkg +**/packages/ +project.lock.json +project.fragment.lock.json +.nuget/ +.dotnet_home/ +.journal-sidecar/ +.tmp +.npm +output/ + +# Publish output +publish/ + +# User secrets +secrets.json + +# Windows +Thumbs.db +desktop.ini + +# Runtime journal data (created by sidecar at repo root) +journal/ +logs/ + +# macOS +.DS_Store + +# OTHER +.just/ +journalapp.exe +Journal.App/node_modules.old/@rollup/.rollup-win32-x64-msvc-IjiZshxL/rollup.win32-x64-msvc.node +journalapp(1).exe diff --git a/Journal.App/.gitignore b/Journal.App/.gitignore new file mode 100644 index 0000000..6635cf5 --- /dev/null +++ b/Journal.App/.gitignore @@ -0,0 +1,10 @@ +.DS_Store +node_modules +/build +/.svelte-kit +/package +.env +.env.* +!.env.example +vite.config.js.timestamp-* +vite.config.ts.timestamp-* diff --git a/Journal.App/README.md b/Journal.App/README.md new file mode 100644 index 0000000..d5f55d0 --- /dev/null +++ b/Journal.App/README.md @@ -0,0 +1,77 @@ +# Journal.App + +SvelteKit 5 + Tauri 2 desktop application for Project Journal. + +## Tech Stack + +- **Frontend**: SvelteKit 5, TypeScript, Vite 6 +- **Tauri shell**: Rust (Tauri 2), `tokio` async runtime +- **Backend bridge**: `Journal.Sidecar.exe` managed as a persistent long-lived child process + +## Dev Setup + +```powershell +npm install +npm run dev # SvelteKit dev server at http://localhost:1420 +npm run tauri dev # Tauri desktop window (connects to dev server) +``` + +## Build Targets + +| Command | Output | Use case | +|---------|--------|----------| +| `npm run build` | `Journal.App/build/` | Web bundle for `Journal.WebGateway` | +| `.\scripts\publish-app.ps1 -Target web` | `Journal.App/build/` | Same, via script | +| `.\scripts\publish-app.ps1 -Target tauri -TauriBundles none` | `src-tauri/target/release/journalapp.exe` | Raw desktop exe | +| `.\scripts\publish-app.ps1 -Target tauri -TauriBundles nsis` | NSIS installer | Packaged installer | + +## Frontend State Management + +Svelte stores are the source of truth for all feature state. + +### Current Stores + +| Store file | State exports | Notes | +|-----------|---------------|-------| +| `src/lib/stores/entries.ts` | `entriesStore` | Entry list, `getDefaultEntry`, `createEntryDraft` | +| `src/lib/stores/fragments.ts` | `fragmentsStore` | Fragment CRUD + parse/serialize helpers | +| `src/lib/stores/todos.ts` | `todoListsStore`, `todosStore` | Todo list and item CRUD | +| `src/lib/stores/lists.ts` | `listsStore` | Generic list CRUD, `createListDraft` | +| `src/lib/stores/settings.ts` | `settingsTags`, `settingsFragmentTypes` | Tag/type config | + +### Store-First Rule + +- Components call **store helper functions** for CRUD operations — not inline mutations. +- Components should focus on rendering, local form state, and invoking store operations. +- Backend calls (`sendCommand`) belong inside store/service helpers, not components. + +## Tauri Commands (Rust → Frontend) + +| Command | Description | +|---------|-------------| +| `sidecar_command` | Forward a `CommandEnvelope` to `Journal.Sidecar` stdin/stdout and return parsed JSON | +| `get_sidecar_root` | Get currently resolved sidecar root path | +| `set_sidecar_root` | Override root path (saved to `settings.json`, restarts sidecar) | +| `get_ui_settings` | Load tag/fragment-type settings | +| `set_ui_settings` | Persist tag/fragment-type settings | +| `shutdown` | Stop sidecar, exit app | + +## Sidecar Path Resolution + +The Rust shell looks for `Journal.Sidecar.exe` starting from the auto-detected repository root: + +1. `/Journal.Sidecar.exe` +2. `/publish/Journal.Sidecar.exe` +3. `/Journal.Sidecar/bin/Debug/net10.0/Journal.Sidecar.exe` +4. `/Journal.Sidecar/bin/Release/net10.0/win-x64/publish/Journal.Sidecar.exe` +5. Recursive scan of `/Journal.Sidecar/` + +Build the sidecar before running the Tauri app: + +```powershell +.\scripts\publish-sidecar.ps1 -Configuration Release -Runtime win-x64 +``` + +## Recommended IDE Setup + +[VS Code](https://code.visualstudio.com/) + [Svelte](https://marketplace.visualstudio.com/items?itemName=svelte.svelte-vscode) + [Tauri](https://marketplace.visualstudio.com/items?itemName=tauri-apps.tauri-vscode) + [rust-analyzer](https://marketplace.visualstudio.com/items?itemName=rust-lang.rust-analyzer) diff --git a/Journal.App/package-lock.json b/Journal.App/package-lock.json new file mode 100644 index 0000000..c9c5ff0 --- /dev/null +++ b/Journal.App/package-lock.json @@ -0,0 +1,1886 @@ +{ + "name": "journalapp", + "version": "0.1.0", + "lockfileVersion": 3, + "requires": true, + "packages": { + "": { + "name": "journalapp", + "version": "0.1.0", + "license": "MIT", + "dependencies": { + "@tauri-apps/api": "^2", + "@tauri-apps/plugin-dialog": "^2.6.0", + "@tauri-apps/plugin-opener": "^2" + }, + "devDependencies": { + "@sveltejs/adapter-static": "^3.0.6", + "@sveltejs/kit": "^2.9.0", + "@sveltejs/vite-plugin-svelte": "^5.0.0", + "@tauri-apps/cli": "^2", + "svelte": "^5.0.0", + "svelte-check": "^4.0.0", + "typescript": "~5.6.2", + "vite": "^6.0.3" + } + }, + "node_modules/@esbuild/aix-ppc64": { + "version": "0.25.12", + "resolved": "https://registry.npmjs.org/@esbuild/aix-ppc64/-/aix-ppc64-0.25.12.tgz", + "integrity": "sha512-Hhmwd6CInZ3dwpuGTF8fJG6yoWmsToE+vYgD4nytZVxcu1ulHpUQRAB1UJ8+N1Am3Mz4+xOByoQoSZf4D+CpkA==", + "cpu": [ + "ppc64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "aix" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/android-arm": { + "version": "0.25.12", + "resolved": "https://registry.npmjs.org/@esbuild/android-arm/-/android-arm-0.25.12.tgz", + "integrity": "sha512-VJ+sKvNA/GE7Ccacc9Cha7bpS8nyzVv0jdVgwNDaR4gDMC/2TTRc33Ip8qrNYUcpkOHUT5OZ0bUcNNVZQ9RLlg==", + "cpu": [ + "arm" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/android-arm64": { + "version": "0.25.12", + "resolved": "https://registry.npmjs.org/@esbuild/android-arm64/-/android-arm64-0.25.12.tgz", + "integrity": "sha512-6AAmLG7zwD1Z159jCKPvAxZd4y/VTO0VkprYy+3N2FtJ8+BQWFXU+OxARIwA46c5tdD9SsKGZ/1ocqBS/gAKHg==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/android-x64": { + "version": "0.25.12", + "resolved": "https://registry.npmjs.org/@esbuild/android-x64/-/android-x64-0.25.12.tgz", + "integrity": "sha512-5jbb+2hhDHx5phYR2By8GTWEzn6I9UqR11Kwf22iKbNpYrsmRB18aX/9ivc5cabcUiAT/wM+YIZ6SG9QO6a8kg==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/darwin-arm64": { + "version": "0.25.12", + "resolved": "https://registry.npmjs.org/@esbuild/darwin-arm64/-/darwin-arm64-0.25.12.tgz", + "integrity": "sha512-N3zl+lxHCifgIlcMUP5016ESkeQjLj/959RxxNYIthIg+CQHInujFuXeWbWMgnTo4cp5XVHqFPmpyu9J65C1Yg==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/darwin-x64": { + "version": "0.25.12", + "resolved": "https://registry.npmjs.org/@esbuild/darwin-x64/-/darwin-x64-0.25.12.tgz", + "integrity": "sha512-HQ9ka4Kx21qHXwtlTUVbKJOAnmG1ipXhdWTmNXiPzPfWKpXqASVcWdnf2bnL73wgjNrFXAa3yYvBSd9pzfEIpA==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/freebsd-arm64": { + "version": "0.25.12", + "resolved": "https://registry.npmjs.org/@esbuild/freebsd-arm64/-/freebsd-arm64-0.25.12.tgz", + "integrity": "sha512-gA0Bx759+7Jve03K1S0vkOu5Lg/85dou3EseOGUes8flVOGxbhDDh/iZaoek11Y8mtyKPGF3vP8XhnkDEAmzeg==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "freebsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/freebsd-x64": { + "version": "0.25.12", + "resolved": "https://registry.npmjs.org/@esbuild/freebsd-x64/-/freebsd-x64-0.25.12.tgz", + "integrity": "sha512-TGbO26Yw2xsHzxtbVFGEXBFH0FRAP7gtcPE7P5yP7wGy7cXK2oO7RyOhL5NLiqTlBh47XhmIUXuGciXEqYFfBQ==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "freebsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-arm": { + "version": "0.25.12", + "resolved": "https://registry.npmjs.org/@esbuild/linux-arm/-/linux-arm-0.25.12.tgz", + "integrity": "sha512-lPDGyC1JPDou8kGcywY0YILzWlhhnRjdof3UlcoqYmS9El818LLfJJc3PXXgZHrHCAKs/Z2SeZtDJr5MrkxtOw==", + "cpu": [ + "arm" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-arm64": { + "version": "0.25.12", + "resolved": "https://registry.npmjs.org/@esbuild/linux-arm64/-/linux-arm64-0.25.12.tgz", + "integrity": "sha512-8bwX7a8FghIgrupcxb4aUmYDLp8pX06rGh5HqDT7bB+8Rdells6mHvrFHHW2JAOPZUbnjUpKTLg6ECyzvas2AQ==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-ia32": { + "version": "0.25.12", + "resolved": "https://registry.npmjs.org/@esbuild/linux-ia32/-/linux-ia32-0.25.12.tgz", + "integrity": "sha512-0y9KrdVnbMM2/vG8KfU0byhUN+EFCny9+8g202gYqSSVMonbsCfLjUO+rCci7pM0WBEtz+oK/PIwHkzxkyharA==", + "cpu": [ + "ia32" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-loong64": { + "version": "0.25.12", + "resolved": "https://registry.npmjs.org/@esbuild/linux-loong64/-/linux-loong64-0.25.12.tgz", + "integrity": "sha512-h///Lr5a9rib/v1GGqXVGzjL4TMvVTv+s1DPoxQdz7l/AYv6LDSxdIwzxkrPW438oUXiDtwM10o9PmwS/6Z0Ng==", + "cpu": [ + "loong64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-mips64el": { + "version": "0.25.12", + "resolved": "https://registry.npmjs.org/@esbuild/linux-mips64el/-/linux-mips64el-0.25.12.tgz", + "integrity": "sha512-iyRrM1Pzy9GFMDLsXn1iHUm18nhKnNMWscjmp4+hpafcZjrr2WbT//d20xaGljXDBYHqRcl8HnxbX6uaA/eGVw==", + "cpu": [ + "mips64el" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-ppc64": { + "version": "0.25.12", + "resolved": "https://registry.npmjs.org/@esbuild/linux-ppc64/-/linux-ppc64-0.25.12.tgz", + "integrity": "sha512-9meM/lRXxMi5PSUqEXRCtVjEZBGwB7P/D4yT8UG/mwIdze2aV4Vo6U5gD3+RsoHXKkHCfSxZKzmDssVlRj1QQA==", + "cpu": [ + "ppc64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-riscv64": { + "version": "0.25.12", + "resolved": "https://registry.npmjs.org/@esbuild/linux-riscv64/-/linux-riscv64-0.25.12.tgz", + "integrity": "sha512-Zr7KR4hgKUpWAwb1f3o5ygT04MzqVrGEGXGLnj15YQDJErYu/BGg+wmFlIDOdJp0PmB0lLvxFIOXZgFRrdjR0w==", + "cpu": [ + "riscv64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-s390x": { + "version": "0.25.12", + "resolved": "https://registry.npmjs.org/@esbuild/linux-s390x/-/linux-s390x-0.25.12.tgz", + "integrity": "sha512-MsKncOcgTNvdtiISc/jZs/Zf8d0cl/t3gYWX8J9ubBnVOwlk65UIEEvgBORTiljloIWnBzLs4qhzPkJcitIzIg==", + "cpu": [ + "s390x" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-x64": { + "version": "0.25.12", + "resolved": "https://registry.npmjs.org/@esbuild/linux-x64/-/linux-x64-0.25.12.tgz", + "integrity": "sha512-uqZMTLr/zR/ed4jIGnwSLkaHmPjOjJvnm6TVVitAa08SLS9Z0VM8wIRx7gWbJB5/J54YuIMInDquWyYvQLZkgw==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/netbsd-arm64": { + "version": "0.25.12", + "resolved": "https://registry.npmjs.org/@esbuild/netbsd-arm64/-/netbsd-arm64-0.25.12.tgz", + "integrity": "sha512-xXwcTq4GhRM7J9A8Gv5boanHhRa/Q9KLVmcyXHCTaM4wKfIpWkdXiMog/KsnxzJ0A1+nD+zoecuzqPmCRyBGjg==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "netbsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/netbsd-x64": { + "version": "0.25.12", + "resolved": "https://registry.npmjs.org/@esbuild/netbsd-x64/-/netbsd-x64-0.25.12.tgz", + "integrity": "sha512-Ld5pTlzPy3YwGec4OuHh1aCVCRvOXdH8DgRjfDy/oumVovmuSzWfnSJg+VtakB9Cm0gxNO9BzWkj6mtO1FMXkQ==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "netbsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/openbsd-arm64": { + "version": "0.25.12", + "resolved": "https://registry.npmjs.org/@esbuild/openbsd-arm64/-/openbsd-arm64-0.25.12.tgz", + "integrity": "sha512-fF96T6KsBo/pkQI950FARU9apGNTSlZGsv1jZBAlcLL1MLjLNIWPBkj5NlSz8aAzYKg+eNqknrUJ24QBybeR5A==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "openbsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/openbsd-x64": { + "version": "0.25.12", + "resolved": "https://registry.npmjs.org/@esbuild/openbsd-x64/-/openbsd-x64-0.25.12.tgz", + "integrity": "sha512-MZyXUkZHjQxUvzK7rN8DJ3SRmrVrke8ZyRusHlP+kuwqTcfWLyqMOE3sScPPyeIXN/mDJIfGXvcMqCgYKekoQw==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "openbsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/openharmony-arm64": { + "version": "0.25.12", + "resolved": "https://registry.npmjs.org/@esbuild/openharmony-arm64/-/openharmony-arm64-0.25.12.tgz", + "integrity": "sha512-rm0YWsqUSRrjncSXGA7Zv78Nbnw4XL6/dzr20cyrQf7ZmRcsovpcRBdhD43Nuk3y7XIoW2OxMVvwuRvk9XdASg==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "openharmony" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/sunos-x64": { + "version": "0.25.12", + "resolved": "https://registry.npmjs.org/@esbuild/sunos-x64/-/sunos-x64-0.25.12.tgz", + "integrity": "sha512-3wGSCDyuTHQUzt0nV7bocDy72r2lI33QL3gkDNGkod22EsYl04sMf0qLb8luNKTOmgF/eDEDP5BFNwoBKH441w==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "sunos" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/win32-arm64": { + "version": "0.25.12", + "resolved": "https://registry.npmjs.org/@esbuild/win32-arm64/-/win32-arm64-0.25.12.tgz", + "integrity": "sha512-rMmLrur64A7+DKlnSuwqUdRKyd3UE7oPJZmnljqEptesKM8wx9J8gx5u0+9Pq0fQQW8vqeKebwNXdfOyP+8Bsg==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/win32-ia32": { + "version": "0.25.12", + "resolved": "https://registry.npmjs.org/@esbuild/win32-ia32/-/win32-ia32-0.25.12.tgz", + "integrity": "sha512-HkqnmmBoCbCwxUKKNPBixiWDGCpQGVsrQfJoVGYLPT41XWF8lHuE5N6WhVia2n4o5QK5M4tYr21827fNhi4byQ==", + "cpu": [ + "ia32" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/win32-x64": { + "version": "0.25.12", + "resolved": "https://registry.npmjs.org/@esbuild/win32-x64/-/win32-x64-0.25.12.tgz", + "integrity": "sha512-alJC0uCZpTFrSL0CCDjcgleBXPnCrEAhTBILpeAp7M/OFgoqtAetfBzX0xM00MUsVVPpVjlPuMbREqnZCXaTnA==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@jridgewell/gen-mapping": { + "version": "0.3.13", + "resolved": "https://registry.npmjs.org/@jridgewell/gen-mapping/-/gen-mapping-0.3.13.tgz", + "integrity": "sha512-2kkt/7niJ6MgEPxF0bYdQ6etZaA+fQvDcLKckhy1yIQOzaoKjBBjSj63/aLVjYE3qhRt5dvM+uUyfCg6UKCBbA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@jridgewell/sourcemap-codec": "^1.5.0", + "@jridgewell/trace-mapping": "^0.3.24" + } + }, + "node_modules/@jridgewell/remapping": { + "version": "2.3.5", + "resolved": "https://registry.npmjs.org/@jridgewell/remapping/-/remapping-2.3.5.tgz", + "integrity": "sha512-LI9u/+laYG4Ds1TDKSJW2YPrIlcVYOwi2fUC6xB43lueCjgxV4lffOCZCtYFiH6TNOX+tQKXx97T4IKHbhyHEQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@jridgewell/gen-mapping": "^0.3.5", + "@jridgewell/trace-mapping": "^0.3.24" + } + }, + "node_modules/@jridgewell/resolve-uri": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/@jridgewell/resolve-uri/-/resolve-uri-3.1.2.tgz", + "integrity": "sha512-bRISgCIjP20/tbWSPWMEi54QVPRZExkuD9lJL+UIxUKtwVJA8wW1Trb1jMs1RFXo1CBTNZ/5hpC9QvmKWdopKw==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6.0.0" + } + }, + "node_modules/@jridgewell/sourcemap-codec": { + "version": "1.5.5", + "resolved": "https://registry.npmjs.org/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.5.5.tgz", + "integrity": "sha512-cYQ9310grqxueWbl+WuIUIaiUaDcj7WOq5fVhEljNVgRfOUhY9fy2zTvfoqWsnebh8Sl70VScFbICvJnLKB0Og==", + "dev": true, + "license": "MIT" + }, + "node_modules/@jridgewell/trace-mapping": { + "version": "0.3.31", + "resolved": "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.31.tgz", + "integrity": "sha512-zzNR+SdQSDJzc8joaeP8QQoCQr8NuYx2dIIytl1QeBEZHJ9uW6hebsrYgbz8hJwUQao3TWCMtmfV8Nu1twOLAw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@jridgewell/resolve-uri": "^3.1.0", + "@jridgewell/sourcemap-codec": "^1.4.14" + } + }, + "node_modules/@polka/url": { + "version": "1.0.0-next.29", + "resolved": "https://registry.npmjs.org/@polka/url/-/url-1.0.0-next.29.tgz", + "integrity": "sha512-wwQAWhWSuHaag8c4q/KN/vCoeOJYshAIvMQwD4GpSb3OiZklFfvAgmj0VCBBImRpuF/aFgIRzllXlVX93Jevww==", + "dev": true, + "license": "MIT" + }, + "node_modules/@rollup/rollup-android-arm-eabi": { + "version": "4.59.0", + "resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm-eabi/-/rollup-android-arm-eabi-4.59.0.tgz", + "integrity": "sha512-upnNBkA6ZH2VKGcBj9Fyl9IGNPULcjXRlg0LLeaioQWueH30p6IXtJEbKAgvyv+mJaMxSm1l6xwDXYjpEMiLMg==", + "cpu": [ + "arm" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "android" + ] + }, + "node_modules/@rollup/rollup-android-arm64": { + "version": "4.59.0", + "resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm64/-/rollup-android-arm64-4.59.0.tgz", + "integrity": "sha512-hZ+Zxj3SySm4A/DylsDKZAeVg0mvi++0PYVceVyX7hemkw7OreKdCvW2oQ3T1FMZvCaQXqOTHb8qmBShoqk69Q==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "android" + ] + }, + "node_modules/@rollup/rollup-darwin-arm64": { + "version": "4.59.0", + "resolved": "https://registry.npmjs.org/@rollup/rollup-darwin-arm64/-/rollup-darwin-arm64-4.59.0.tgz", + "integrity": "sha512-W2Psnbh1J8ZJw0xKAd8zdNgF9HRLkdWwwdWqubSVk0pUuQkoHnv7rx4GiF9rT4t5DIZGAsConRE3AxCdJ4m8rg==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ] + }, + "node_modules/@rollup/rollup-darwin-x64": { + "version": "4.59.0", + "resolved": "https://registry.npmjs.org/@rollup/rollup-darwin-x64/-/rollup-darwin-x64-4.59.0.tgz", + "integrity": "sha512-ZW2KkwlS4lwTv7ZVsYDiARfFCnSGhzYPdiOU4IM2fDbL+QGlyAbjgSFuqNRbSthybLbIJ915UtZBtmuLrQAT/w==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ] + }, + "node_modules/@rollup/rollup-freebsd-arm64": { + "version": "4.59.0", + "resolved": "https://registry.npmjs.org/@rollup/rollup-freebsd-arm64/-/rollup-freebsd-arm64-4.59.0.tgz", + "integrity": "sha512-EsKaJ5ytAu9jI3lonzn3BgG8iRBjV4LxZexygcQbpiU0wU0ATxhNVEpXKfUa0pS05gTcSDMKpn3Sx+QB9RlTTA==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "freebsd" + ] + }, + "node_modules/@rollup/rollup-freebsd-x64": { + "version": "4.59.0", + "resolved": "https://registry.npmjs.org/@rollup/rollup-freebsd-x64/-/rollup-freebsd-x64-4.59.0.tgz", + "integrity": "sha512-d3DuZi2KzTMjImrxoHIAODUZYoUUMsuUiY4SRRcJy6NJoZ6iIqWnJu9IScV9jXysyGMVuW+KNzZvBLOcpdl3Vg==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "freebsd" + ] + }, + "node_modules/@rollup/rollup-linux-arm-gnueabihf": { + "version": "4.59.0", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm-gnueabihf/-/rollup-linux-arm-gnueabihf-4.59.0.tgz", + "integrity": "sha512-t4ONHboXi/3E0rT6OZl1pKbl2Vgxf9vJfWgmUoCEVQVxhW6Cw/c8I6hbbu7DAvgp82RKiH7TpLwxnJeKv2pbsw==", + "cpu": [ + "arm" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-arm-musleabihf": { + "version": "4.59.0", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm-musleabihf/-/rollup-linux-arm-musleabihf-4.59.0.tgz", + "integrity": "sha512-CikFT7aYPA2ufMD086cVORBYGHffBo4K8MQ4uPS/ZnY54GKj36i196u8U+aDVT2LX4eSMbyHtyOh7D7Zvk2VvA==", + "cpu": [ + "arm" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-arm64-gnu": { + "version": "4.59.0", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm64-gnu/-/rollup-linux-arm64-gnu-4.59.0.tgz", + "integrity": "sha512-jYgUGk5aLd1nUb1CtQ8E+t5JhLc9x5WdBKew9ZgAXg7DBk0ZHErLHdXM24rfX+bKrFe+Xp5YuJo54I5HFjGDAA==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-arm64-musl": { + "version": "4.59.0", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm64-musl/-/rollup-linux-arm64-musl-4.59.0.tgz", + "integrity": "sha512-peZRVEdnFWZ5Bh2KeumKG9ty7aCXzzEsHShOZEFiCQlDEepP1dpUl/SrUNXNg13UmZl+gzVDPsiCwnV1uI0RUA==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-loong64-gnu": { + "version": "4.59.0", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-loong64-gnu/-/rollup-linux-loong64-gnu-4.59.0.tgz", + "integrity": "sha512-gbUSW/97f7+r4gHy3Jlup8zDG190AuodsWnNiXErp9mT90iCy9NKKU0Xwx5k8VlRAIV2uU9CsMnEFg/xXaOfXg==", + "cpu": [ + "loong64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-loong64-musl": { + "version": "4.59.0", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-loong64-musl/-/rollup-linux-loong64-musl-4.59.0.tgz", + "integrity": "sha512-yTRONe79E+o0FWFijasoTjtzG9EBedFXJMl888NBEDCDV9I2wGbFFfJQQe63OijbFCUZqxpHz1GzpbtSFikJ4Q==", + "cpu": [ + "loong64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-ppc64-gnu": { + "version": "4.59.0", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-ppc64-gnu/-/rollup-linux-ppc64-gnu-4.59.0.tgz", + "integrity": "sha512-sw1o3tfyk12k3OEpRddF68a1unZ5VCN7zoTNtSn2KndUE+ea3m3ROOKRCZxEpmT9nsGnogpFP9x6mnLTCaoLkA==", + "cpu": [ + "ppc64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-ppc64-musl": { + "version": "4.59.0", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-ppc64-musl/-/rollup-linux-ppc64-musl-4.59.0.tgz", + "integrity": "sha512-+2kLtQ4xT3AiIxkzFVFXfsmlZiG5FXYW7ZyIIvGA7Bdeuh9Z0aN4hVyXS/G1E9bTP/vqszNIN/pUKCk/BTHsKA==", + "cpu": [ + "ppc64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-riscv64-gnu": { + "version": "4.59.0", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-riscv64-gnu/-/rollup-linux-riscv64-gnu-4.59.0.tgz", + "integrity": "sha512-NDYMpsXYJJaj+I7UdwIuHHNxXZ/b/N2hR15NyH3m2qAtb/hHPA4g4SuuvrdxetTdndfj9b1WOmy73kcPRoERUg==", + "cpu": [ + "riscv64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-riscv64-musl": { + "version": "4.59.0", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-riscv64-musl/-/rollup-linux-riscv64-musl-4.59.0.tgz", + "integrity": "sha512-nLckB8WOqHIf1bhymk+oHxvM9D3tyPndZH8i8+35p/1YiVoVswPid2yLzgX7ZJP0KQvnkhM4H6QZ5m0LzbyIAg==", + "cpu": [ + "riscv64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-s390x-gnu": { + "version": "4.59.0", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-s390x-gnu/-/rollup-linux-s390x-gnu-4.59.0.tgz", + "integrity": "sha512-oF87Ie3uAIvORFBpwnCvUzdeYUqi2wY6jRFWJAy1qus/udHFYIkplYRW+wo+GRUP4sKzYdmE1Y3+rY5Gc4ZO+w==", + "cpu": [ + "s390x" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-x64-gnu": { + "version": "4.59.0", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-x64-gnu/-/rollup-linux-x64-gnu-4.59.0.tgz", + "integrity": "sha512-3AHmtQq/ppNuUspKAlvA8HtLybkDflkMuLK4DPo77DfthRb71V84/c4MlWJXixZz4uruIH4uaa07IqoAkG64fg==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-x64-musl": { + "version": "4.59.0", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-x64-musl/-/rollup-linux-x64-musl-4.59.0.tgz", + "integrity": "sha512-2UdiwS/9cTAx7qIUZB/fWtToJwvt0Vbo0zmnYt7ED35KPg13Q0ym1g442THLC7VyI6JfYTP4PiSOWyoMdV2/xg==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-openbsd-x64": { + "version": "4.59.0", + "resolved": "https://registry.npmjs.org/@rollup/rollup-openbsd-x64/-/rollup-openbsd-x64-4.59.0.tgz", + "integrity": "sha512-M3bLRAVk6GOwFlPTIxVBSYKUaqfLrn8l0psKinkCFxl4lQvOSz8ZrKDz2gxcBwHFpci0B6rttydI4IpS4IS/jQ==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "openbsd" + ] + }, + "node_modules/@rollup/rollup-openharmony-arm64": { + "version": "4.59.0", + "resolved": "https://registry.npmjs.org/@rollup/rollup-openharmony-arm64/-/rollup-openharmony-arm64-4.59.0.tgz", + "integrity": "sha512-tt9KBJqaqp5i5HUZzoafHZX8b5Q2Fe7UjYERADll83O4fGqJ49O1FsL6LpdzVFQcpwvnyd0i+K/VSwu/o/nWlA==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "openharmony" + ] + }, + "node_modules/@rollup/rollup-win32-arm64-msvc": { + "version": "4.59.0", + "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-arm64-msvc/-/rollup-win32-arm64-msvc-4.59.0.tgz", + "integrity": "sha512-V5B6mG7OrGTwnxaNUzZTDTjDS7F75PO1ae6MJYdiMu60sq0CqN5CVeVsbhPxalupvTX8gXVSU9gq+Rx1/hvu6A==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ] + }, + "node_modules/@rollup/rollup-win32-ia32-msvc": { + "version": "4.59.0", + "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-ia32-msvc/-/rollup-win32-ia32-msvc-4.59.0.tgz", + "integrity": "sha512-UKFMHPuM9R0iBegwzKF4y0C4J9u8C6MEJgFuXTBerMk7EJ92GFVFYBfOZaSGLu6COf7FxpQNqhNS4c4icUPqxA==", + "cpu": [ + "ia32" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ] + }, + "node_modules/@rollup/rollup-win32-x64-gnu": { + "version": "4.59.0", + "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-x64-gnu/-/rollup-win32-x64-gnu-4.59.0.tgz", + "integrity": "sha512-laBkYlSS1n2L8fSo1thDNGrCTQMmxjYY5G0WFWjFFYZkKPjsMBsgJfGf4TLxXrF6RyhI60L8TMOjBMvXiTcxeA==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ] + }, + "node_modules/@rollup/rollup-win32-x64-msvc": { + "version": "4.59.0", + "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-x64-msvc/-/rollup-win32-x64-msvc-4.59.0.tgz", + "integrity": "sha512-2HRCml6OztYXyJXAvdDXPKcawukWY2GpR5/nxKp4iBgiO3wcoEGkAaqctIbZcNB6KlUQBIqt8VYkNSj2397EfA==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ] + }, + "node_modules/@standard-schema/spec": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/@standard-schema/spec/-/spec-1.1.0.tgz", + "integrity": "sha512-l2aFy5jALhniG5HgqrD6jXLi/rUWrKvqN/qJx6yoJsgKhblVd+iqqU4RCXavm/jPityDo5TCvKMnpjKnOriy0w==", + "dev": true, + "license": "MIT" + }, + "node_modules/@sveltejs/acorn-typescript": { + "version": "1.0.9", + "resolved": "https://registry.npmjs.org/@sveltejs/acorn-typescript/-/acorn-typescript-1.0.9.tgz", + "integrity": "sha512-lVJX6qEgs/4DOcRTpo56tmKzVPtoWAaVbL4hfO7t7NVwl9AAXzQR6cihesW1BmNMPl+bK6dreu2sOKBP2Q9CIA==", + "dev": true, + "license": "MIT", + "peerDependencies": { + "acorn": "^8.9.0" + } + }, + "node_modules/@sveltejs/adapter-static": { + "version": "3.0.10", + "resolved": "https://registry.npmjs.org/@sveltejs/adapter-static/-/adapter-static-3.0.10.tgz", + "integrity": "sha512-7D9lYFWJmB7zxZyTE/qxjksvMqzMuYrrsyh1f4AlZqeZeACPRySjbC3aFiY55wb1tWUaKOQG9PVbm74JcN2Iew==", + "dev": true, + "license": "MIT", + "peerDependencies": { + "@sveltejs/kit": "^2.0.0" + } + }, + "node_modules/@sveltejs/kit": { + "version": "2.53.1", + "resolved": "https://registry.npmjs.org/@sveltejs/kit/-/kit-2.53.1.tgz", + "integrity": "sha512-NXsZLvalgI3HrHG6ogoEVzjyV7bSFQNqQeekfU7nNufQFrRyV3EBDfQKEwxx50peu7spZR42JuC1PFhwxuvBrg==", + "dev": true, + "license": "MIT", + "peer": true, + "dependencies": { + "@standard-schema/spec": "^1.0.0", + "@sveltejs/acorn-typescript": "^1.0.5", + "@types/cookie": "^0.6.0", + "acorn": "^8.14.1", + "cookie": "^0.6.0", + "devalue": "^5.6.3", + "esm-env": "^1.2.2", + "kleur": "^4.1.5", + "magic-string": "^0.30.5", + "mrmime": "^2.0.0", + "set-cookie-parser": "^3.0.0", + "sirv": "^3.0.0" + }, + "bin": { + "svelte-kit": "svelte-kit.js" + }, + "engines": { + "node": ">=18.13" + }, + "peerDependencies": { + "@opentelemetry/api": "^1.0.0", + "@sveltejs/vite-plugin-svelte": "^3.0.0 || ^4.0.0-next.1 || ^5.0.0 || ^6.0.0-next.0 || ^7.0.0", + "svelte": "^4.0.0 || ^5.0.0-next.0", + "typescript": "^5.3.3", + "vite": "^5.0.3 || ^6.0.0 || ^7.0.0-beta.0 || ^8.0.0" + }, + "peerDependenciesMeta": { + "@opentelemetry/api": { + "optional": true + }, + "typescript": { + "optional": true + } + } + }, + "node_modules/@sveltejs/vite-plugin-svelte": { + "version": "5.1.1", + "resolved": "https://registry.npmjs.org/@sveltejs/vite-plugin-svelte/-/vite-plugin-svelte-5.1.1.tgz", + "integrity": "sha512-Y1Cs7hhTc+a5E9Va/xwKlAJoariQyHY+5zBgCZg4PFWNYQ1nMN9sjK1zhw1gK69DuqVP++sht/1GZg1aRwmAXQ==", + "dev": true, + "license": "MIT", + "peer": true, + "dependencies": { + "@sveltejs/vite-plugin-svelte-inspector": "^4.0.1", + "debug": "^4.4.1", + "deepmerge": "^4.3.1", + "kleur": "^4.1.5", + "magic-string": "^0.30.17", + "vitefu": "^1.0.6" + }, + "engines": { + "node": "^18.0.0 || ^20.0.0 || >=22" + }, + "peerDependencies": { + "svelte": "^5.0.0", + "vite": "^6.0.0" + } + }, + "node_modules/@sveltejs/vite-plugin-svelte-inspector": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/@sveltejs/vite-plugin-svelte-inspector/-/vite-plugin-svelte-inspector-4.0.1.tgz", + "integrity": "sha512-J/Nmb2Q2y7mck2hyCX4ckVHcR5tu2J+MtBEQqpDrrgELZ2uvraQcK/ioCV61AqkdXFgriksOKIceDcQmqnGhVw==", + "dev": true, + "license": "MIT", + "dependencies": { + "debug": "^4.3.7" + }, + "engines": { + "node": "^18.0.0 || ^20.0.0 || >=22" + }, + "peerDependencies": { + "@sveltejs/vite-plugin-svelte": "^5.0.0", + "svelte": "^5.0.0", + "vite": "^6.0.0" + } + }, + "node_modules/@tauri-apps/api": { + "version": "2.10.1", + "resolved": "https://registry.npmjs.org/@tauri-apps/api/-/api-2.10.1.tgz", + "integrity": "sha512-hKL/jWf293UDSUN09rR69hrToyIXBb8CjGaWC7gfinvnQrBVvnLr08FeFi38gxtugAVyVcTa5/FD/Xnkb1siBw==", + "license": "Apache-2.0 OR MIT", + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/tauri" + } + }, + "node_modules/@tauri-apps/cli": { + "version": "2.10.0", + "resolved": "https://registry.npmjs.org/@tauri-apps/cli/-/cli-2.10.0.tgz", + "integrity": "sha512-ZwT0T+7bw4+DPCSWzmviwq5XbXlM0cNoleDKOYPFYqcZqeKY31KlpoMW/MOON/tOFBPgi31a2v3w9gliqwL2+Q==", + "dev": true, + "license": "Apache-2.0 OR MIT", + "bin": { + "tauri": "tauri.js" + }, + "engines": { + "node": ">= 10" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/tauri" + }, + "optionalDependencies": { + "@tauri-apps/cli-darwin-arm64": "2.10.0", + "@tauri-apps/cli-darwin-x64": "2.10.0", + "@tauri-apps/cli-linux-arm-gnueabihf": "2.10.0", + "@tauri-apps/cli-linux-arm64-gnu": "2.10.0", + "@tauri-apps/cli-linux-arm64-musl": "2.10.0", + "@tauri-apps/cli-linux-riscv64-gnu": "2.10.0", + "@tauri-apps/cli-linux-x64-gnu": "2.10.0", + "@tauri-apps/cli-linux-x64-musl": "2.10.0", + "@tauri-apps/cli-win32-arm64-msvc": "2.10.0", + "@tauri-apps/cli-win32-ia32-msvc": "2.10.0", + "@tauri-apps/cli-win32-x64-msvc": "2.10.0" + } + }, + "node_modules/@tauri-apps/cli-darwin-arm64": { + "version": "2.10.0", + "resolved": "https://registry.npmjs.org/@tauri-apps/cli-darwin-arm64/-/cli-darwin-arm64-2.10.0.tgz", + "integrity": "sha512-avqHD4HRjrMamE/7R/kzJPcAJnZs0IIS+1nkDP5b+TNBn3py7N2aIo9LIpy+VQq0AkN8G5dDpZtOOBkmWt/zjA==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "Apache-2.0 OR MIT", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">= 10" + } + }, + "node_modules/@tauri-apps/cli-darwin-x64": { + "version": "2.10.0", + "resolved": "https://registry.npmjs.org/@tauri-apps/cli-darwin-x64/-/cli-darwin-x64-2.10.0.tgz", + "integrity": "sha512-keDmlvJRStzVFjZTd0xYkBONLtgBC9eMTpmXnBXzsHuawV2q9PvDo2x6D5mhuoMVrJ9QWjgaPKBBCFks4dK71Q==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "Apache-2.0 OR MIT", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">= 10" + } + }, + "node_modules/@tauri-apps/cli-linux-arm-gnueabihf": { + "version": "2.10.0", + "resolved": "https://registry.npmjs.org/@tauri-apps/cli-linux-arm-gnueabihf/-/cli-linux-arm-gnueabihf-2.10.0.tgz", + "integrity": "sha512-e5u0VfLZsMAC9iHaOEANumgl6lfnJx0Dtjkd8IJpysZ8jp0tJ6wrIkto2OzQgzcYyRCKgX72aKE0PFgZputA8g==", + "cpu": [ + "arm" + ], + "dev": true, + "license": "Apache-2.0 OR MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">= 10" + } + }, + "node_modules/@tauri-apps/cli-linux-arm64-gnu": { + "version": "2.10.0", + "resolved": "https://registry.npmjs.org/@tauri-apps/cli-linux-arm64-gnu/-/cli-linux-arm64-gnu-2.10.0.tgz", + "integrity": "sha512-YrYYk2dfmBs5m+OIMCrb+JH/oo+4FtlpcrTCgiFYc7vcs6m3QDd1TTyWu0u01ewsCtK2kOdluhr/zKku+KP7HA==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "Apache-2.0 OR MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">= 10" + } + }, + "node_modules/@tauri-apps/cli-linux-arm64-musl": { + "version": "2.10.0", + "resolved": "https://registry.npmjs.org/@tauri-apps/cli-linux-arm64-musl/-/cli-linux-arm64-musl-2.10.0.tgz", + "integrity": "sha512-GUoPdVJmrJRIXFfW3Rkt+eGK9ygOdyISACZfC/bCSfOnGt8kNdQIQr5WRH9QUaTVFIwxMlQyV3m+yXYP+xhSVA==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "Apache-2.0 OR MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">= 10" + } + }, + "node_modules/@tauri-apps/cli-linux-riscv64-gnu": { + "version": "2.10.0", + "resolved": "https://registry.npmjs.org/@tauri-apps/cli-linux-riscv64-gnu/-/cli-linux-riscv64-gnu-2.10.0.tgz", + "integrity": "sha512-JO7s3TlSxshwsoKNCDkyvsx5gw2QAs/Y2GbR5UE2d5kkU138ATKoPOtxn8G1fFT1aDW4LH0rYAAfBpGkDyJJnw==", + "cpu": [ + "riscv64" + ], + "dev": true, + "license": "Apache-2.0 OR MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">= 10" + } + }, + "node_modules/@tauri-apps/cli-linux-x64-gnu": { + "version": "2.10.0", + "resolved": "https://registry.npmjs.org/@tauri-apps/cli-linux-x64-gnu/-/cli-linux-x64-gnu-2.10.0.tgz", + "integrity": "sha512-Uvh4SUUp4A6DVRSMWjelww0GnZI3PlVy7VS+DRF5napKuIehVjGl9XD0uKoCoxwAQBLctvipyEK+pDXpJeoHng==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "Apache-2.0 OR MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">= 10" + } + }, + "node_modules/@tauri-apps/cli-linux-x64-musl": { + "version": "2.10.0", + "resolved": "https://registry.npmjs.org/@tauri-apps/cli-linux-x64-musl/-/cli-linux-x64-musl-2.10.0.tgz", + "integrity": "sha512-AP0KRK6bJuTpQ8kMNWvhIpKUkQJfcPFeba7QshOQZjJ8wOS6emwTN4K5g/d3AbCMo0RRdnZWwu67MlmtJyxC1Q==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "Apache-2.0 OR MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">= 10" + } + }, + "node_modules/@tauri-apps/cli-win32-arm64-msvc": { + "version": "2.10.0", + "resolved": "https://registry.npmjs.org/@tauri-apps/cli-win32-arm64-msvc/-/cli-win32-arm64-msvc-2.10.0.tgz", + "integrity": "sha512-97DXVU3dJystrq7W41IX+82JEorLNY+3+ECYxvXWqkq7DBN6FsA08x/EFGE8N/b0LTOui9X2dvpGGoeZKKV08g==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "Apache-2.0 OR MIT", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">= 10" + } + }, + "node_modules/@tauri-apps/cli-win32-ia32-msvc": { + "version": "2.10.0", + "resolved": "https://registry.npmjs.org/@tauri-apps/cli-win32-ia32-msvc/-/cli-win32-ia32-msvc-2.10.0.tgz", + "integrity": "sha512-EHyQ1iwrWy1CwMalEm9z2a6L5isQ121pe7FcA2xe4VWMJp+GHSDDGvbTv/OPdkt2Lyr7DAZBpZHM6nvlHXEc4A==", + "cpu": [ + "ia32" + ], + "dev": true, + "license": "Apache-2.0 OR MIT", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">= 10" + } + }, + "node_modules/@tauri-apps/cli-win32-x64-msvc": { + "version": "2.10.0", + "resolved": "https://registry.npmjs.org/@tauri-apps/cli-win32-x64-msvc/-/cli-win32-x64-msvc-2.10.0.tgz", + "integrity": "sha512-NTpyQxkpzGmU6ceWBTY2xRIEaS0ZLbVx1HE1zTA3TY/pV3+cPoPPOs+7YScr4IMzXMtOw7tLw5LEXo5oIG3qaQ==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "Apache-2.0 OR MIT", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">= 10" + } + }, + "node_modules/@tauri-apps/plugin-dialog": { + "version": "2.6.0", + "resolved": "https://registry.npmjs.org/@tauri-apps/plugin-dialog/-/plugin-dialog-2.6.0.tgz", + "integrity": "sha512-q4Uq3eY87TdcYzXACiYSPhmpBA76shgmQswGkSVio4C82Sz2W4iehe9TnKYwbq7weHiL88Yw19XZm7v28+Micg==", + "license": "MIT OR Apache-2.0", + "dependencies": { + "@tauri-apps/api": "^2.8.0" + } + }, + "node_modules/@tauri-apps/plugin-opener": { + "version": "2.5.3", + "resolved": "https://registry.npmjs.org/@tauri-apps/plugin-opener/-/plugin-opener-2.5.3.tgz", + "integrity": "sha512-CCcUltXMOfUEArbf3db3kCE7Ggy1ExBEBl51Ko2ODJ6GDYHRp1nSNlQm5uNCFY5k7/ufaK5Ib3Du/Zir19IYQQ==", + "license": "MIT OR Apache-2.0", + "dependencies": { + "@tauri-apps/api": "^2.8.0" + } + }, + "node_modules/@types/cookie": { + "version": "0.6.0", + "resolved": "https://registry.npmjs.org/@types/cookie/-/cookie-0.6.0.tgz", + "integrity": "sha512-4Kh9a6B2bQciAhf7FSuMRRkUWecJgJu9nPnx3yzpsfXX/c50REIqpHY4C82bXP90qrLtXtkDxTZosYO3UpOwlA==", + "dev": true, + "license": "MIT" + }, + "node_modules/@types/estree": { + "version": "1.0.8", + "resolved": "https://registry.npmjs.org/@types/estree/-/estree-1.0.8.tgz", + "integrity": "sha512-dWHzHa2WqEXI/O1E9OjrocMTKJl2mSrEolh1Iomrv6U+JuNwaHXsXx9bLu5gG7BUWFIN0skIQJQ/L1rIex4X6w==", + "dev": true, + "license": "MIT" + }, + "node_modules/@types/trusted-types": { + "version": "2.0.7", + "resolved": "https://registry.npmjs.org/@types/trusted-types/-/trusted-types-2.0.7.tgz", + "integrity": "sha512-ScaPdn1dQczgbl0QFTeTOmVHFULt394XJgOQNoyVhZ6r2vLnMLJfBPd53SB52T/3G36VI1/g2MZaX0cwDuXsfw==", + "dev": true, + "license": "MIT" + }, + "node_modules/acorn": { + "version": "8.16.0", + "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.16.0.tgz", + "integrity": "sha512-UVJyE9MttOsBQIDKw1skb9nAwQuR5wuGD3+82K6JgJlm/Y+KI92oNsMNGZCYdDsVtRHSak0pcV5Dno5+4jh9sw==", + "dev": true, + "license": "MIT", + "peer": true, + "bin": { + "acorn": "bin/acorn" + }, + "engines": { + "node": ">=0.4.0" + } + }, + "node_modules/aria-query": { + "version": "5.3.1", + "resolved": "https://registry.npmjs.org/aria-query/-/aria-query-5.3.1.tgz", + "integrity": "sha512-Z/ZeOgVl7bcSYZ/u/rh0fOpvEpq//LZmdbkXyc7syVzjPAhfOa9ebsdTSjEBDU4vs5nC98Kfduj1uFo0qyET3g==", + "dev": true, + "license": "Apache-2.0", + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/axobject-query": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/axobject-query/-/axobject-query-4.1.0.tgz", + "integrity": "sha512-qIj0G9wZbMGNLjLmg1PT6v2mE9AH2zlnADJD/2tC6E00hgmhUOfEB6greHPAfLRSufHqROIUTkw6E+M3lH0PTQ==", + "dev": true, + "license": "Apache-2.0", + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/chokidar": { + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-4.0.3.tgz", + "integrity": "sha512-Qgzu8kfBvo+cA4962jnP1KkS6Dop5NS6g7R5LFYJr4b8Ub94PPQXUksCw9PvXoeXPRRddRNC5C1JQUR2SMGtnA==", + "dev": true, + "license": "MIT", + "dependencies": { + "readdirp": "^4.0.1" + }, + "engines": { + "node": ">= 14.16.0" + }, + "funding": { + "url": "https://paulmillr.com/funding/" + } + }, + "node_modules/clsx": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/clsx/-/clsx-2.1.1.tgz", + "integrity": "sha512-eYm0QWBtUrBWZWG0d386OGAw16Z995PiOVo2B7bjWSbHedGl5e0ZWaq65kOGgUSNesEIDkB9ISbTg/JK9dhCZA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6" + } + }, + "node_modules/cookie": { + "version": "0.6.0", + "resolved": "https://registry.npmjs.org/cookie/-/cookie-0.6.0.tgz", + "integrity": "sha512-U71cyTamuh1CRNCfpGY6to28lxvNwPG4Guz/EVjgf3Jmzv0vlDp1atT9eS5dDjMYHucpHbWns6Lwf3BKz6svdw==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/debug": { + "version": "4.4.3", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.4.3.tgz", + "integrity": "sha512-RGwwWnwQvkVfavKVt22FGLw+xYSdzARwm0ru6DhTVA3umU5hZc28V3kO4stgYryrTlLpuvgI9GiijltAjNbcqA==", + "dev": true, + "license": "MIT", + "dependencies": { + "ms": "^2.1.3" + }, + "engines": { + "node": ">=6.0" + }, + "peerDependenciesMeta": { + "supports-color": { + "optional": true + } + } + }, + "node_modules/deepmerge": { + "version": "4.3.1", + "resolved": "https://registry.npmjs.org/deepmerge/-/deepmerge-4.3.1.tgz", + "integrity": "sha512-3sUqbMEc77XqpdNO7FRyRog+eW3ph+GYCbj+rK+uYyRMuwsVy0rMiVtPn+QJlKFvWP/1PYpapqYn0Me2knFn+A==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/devalue": { + "version": "5.6.3", + "resolved": "https://registry.npmjs.org/devalue/-/devalue-5.6.3.tgz", + "integrity": "sha512-nc7XjUU/2Lb+SvEFVGcWLiKkzfw8+qHI7zn8WYXKkLMgfGSHbgCEaR6bJpev8Cm6Rmrb19Gfd/tZvGqx9is3wg==", + "dev": true, + "license": "MIT" + }, + "node_modules/esbuild": { + "version": "0.25.12", + "resolved": "https://registry.npmjs.org/esbuild/-/esbuild-0.25.12.tgz", + "integrity": "sha512-bbPBYYrtZbkt6Os6FiTLCTFxvq4tt3JKall1vRwshA3fdVztsLAatFaZobhkBC8/BrPetoa0oksYoKXoG4ryJg==", + "dev": true, + "hasInstallScript": true, + "license": "MIT", + "bin": { + "esbuild": "bin/esbuild" + }, + "engines": { + "node": ">=18" + }, + "optionalDependencies": { + "@esbuild/aix-ppc64": "0.25.12", + "@esbuild/android-arm": "0.25.12", + "@esbuild/android-arm64": "0.25.12", + "@esbuild/android-x64": "0.25.12", + "@esbuild/darwin-arm64": "0.25.12", + "@esbuild/darwin-x64": "0.25.12", + "@esbuild/freebsd-arm64": "0.25.12", + "@esbuild/freebsd-x64": "0.25.12", + "@esbuild/linux-arm": "0.25.12", + "@esbuild/linux-arm64": "0.25.12", + "@esbuild/linux-ia32": "0.25.12", + "@esbuild/linux-loong64": "0.25.12", + "@esbuild/linux-mips64el": "0.25.12", + "@esbuild/linux-ppc64": "0.25.12", + "@esbuild/linux-riscv64": "0.25.12", + "@esbuild/linux-s390x": "0.25.12", + "@esbuild/linux-x64": "0.25.12", + "@esbuild/netbsd-arm64": "0.25.12", + "@esbuild/netbsd-x64": "0.25.12", + "@esbuild/openbsd-arm64": "0.25.12", + "@esbuild/openbsd-x64": "0.25.12", + "@esbuild/openharmony-arm64": "0.25.12", + "@esbuild/sunos-x64": "0.25.12", + "@esbuild/win32-arm64": "0.25.12", + "@esbuild/win32-ia32": "0.25.12", + "@esbuild/win32-x64": "0.25.12" + } + }, + "node_modules/esm-env": { + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/esm-env/-/esm-env-1.2.2.tgz", + "integrity": "sha512-Epxrv+Nr/CaL4ZcFGPJIYLWFom+YeV1DqMLHJoEd9SYRxNbaFruBwfEX/kkHUJf55j2+TUbmDcmuilbP1TmXHA==", + "dev": true, + "license": "MIT" + }, + "node_modules/esrap": { + "version": "2.2.3", + "resolved": "https://registry.npmjs.org/esrap/-/esrap-2.2.3.tgz", + "integrity": "sha512-8fOS+GIGCQZl/ZIlhl59htOlms6U8NvX6ZYgYHpRU/b6tVSh3uHkOHZikl3D4cMbYM0JlpBe+p/BkZEi8J9XIQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@jridgewell/sourcemap-codec": "^1.4.15" + } + }, + "node_modules/fdir": { + "version": "6.5.0", + "resolved": "https://registry.npmjs.org/fdir/-/fdir-6.5.0.tgz", + "integrity": "sha512-tIbYtZbucOs0BRGqPJkshJUYdL+SDH7dVM8gjy+ERp3WAUjLEFJE+02kanyHtwjWOnwrKYBiwAmM0p4kLJAnXg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=12.0.0" + }, + "peerDependencies": { + "picomatch": "^3 || ^4" + }, + "peerDependenciesMeta": { + "picomatch": { + "optional": true + } + } + }, + "node_modules/fsevents": { + "version": "2.3.3", + "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.3.tgz", + "integrity": "sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw==", + "dev": true, + "hasInstallScript": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": "^8.16.0 || ^10.6.0 || >=11.0.0" + } + }, + "node_modules/is-reference": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/is-reference/-/is-reference-3.0.3.tgz", + "integrity": "sha512-ixkJoqQvAP88E6wLydLGGqCJsrFUnqoH6HnaczB8XmDH1oaWU+xxdptvikTgaEhtZ53Ky6YXiBuUI2WXLMCwjw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@types/estree": "^1.0.6" + } + }, + "node_modules/kleur": { + "version": "4.1.5", + "resolved": "https://registry.npmjs.org/kleur/-/kleur-4.1.5.tgz", + "integrity": "sha512-o+NO+8WrRiQEE4/7nwRJhN1HWpVmJm511pBHUxPLtp0BUISzlBplORYSmTclCnJvQq2tKu/sgl3xVpkc7ZWuQQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6" + } + }, + "node_modules/locate-character": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/locate-character/-/locate-character-3.0.0.tgz", + "integrity": "sha512-SW13ws7BjaeJ6p7Q6CO2nchbYEc3X3J6WrmTTDto7yMPqVSZTUyY5Tjbid+Ab8gLnATtygYtiDIJGQRRn2ZOiA==", + "dev": true, + "license": "MIT" + }, + "node_modules/magic-string": { + "version": "0.30.21", + "resolved": "https://registry.npmjs.org/magic-string/-/magic-string-0.30.21.tgz", + "integrity": "sha512-vd2F4YUyEXKGcLHoq+TEyCjxueSeHnFxyyjNp80yg0XV4vUhnDer/lvvlqM/arB5bXQN5K2/3oinyCRyx8T2CQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@jridgewell/sourcemap-codec": "^1.5.5" + } + }, + "node_modules/mri": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/mri/-/mri-1.2.0.tgz", + "integrity": "sha512-tzzskb3bG8LvYGFF/mDTpq3jpI6Q9wc3LEmBaghu+DdCssd1FakN7Bc0hVNmEyGq1bq3RgfkCb3cmQLpNPOroA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=4" + } + }, + "node_modules/mrmime": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/mrmime/-/mrmime-2.0.1.tgz", + "integrity": "sha512-Y3wQdFg2Va6etvQ5I82yUhGdsKrcYox6p7FfL1LbK2J4V01F9TGlepTIhnK24t7koZibmg82KGglhA1XK5IsLQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=10" + } + }, + "node_modules/ms": { + "version": "2.1.3", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", + "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==", + "dev": true, + "license": "MIT" + }, + "node_modules/nanoid": { + "version": "3.3.11", + "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.11.tgz", + "integrity": "sha512-N8SpfPUnUp1bK+PMYW8qSWdl9U+wwNWI4QKxOYDy9JAro3WMX7p2OeVRF9v+347pnakNevPmiHhNmZ2HbFA76w==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/ai" + } + ], + "license": "MIT", + "bin": { + "nanoid": "bin/nanoid.cjs" + }, + "engines": { + "node": "^10 || ^12 || ^13.7 || ^14 || >=15.0.1" + } + }, + "node_modules/picocolors": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/picocolors/-/picocolors-1.1.1.tgz", + "integrity": "sha512-xceH2snhtb5M9liqDsmEw56le376mTZkEX/jEb/RxNFyegNul7eNslCXP9FDj/Lcu0X8KEyMceP2ntpaHrDEVA==", + "dev": true, + "license": "ISC" + }, + "node_modules/picomatch": { + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-4.0.3.tgz", + "integrity": "sha512-5gTmgEY/sqK6gFXLIsQNH19lWb4ebPDLA4SdLP7dsWkIXHWlG66oPuVvXSGFPppYZz8ZDZq0dYYrbHfBCVUb1Q==", + "dev": true, + "license": "MIT", + "peer": true, + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/sponsors/jonschlinkert" + } + }, + "node_modules/postcss": { + "version": "8.5.6", + "resolved": "https://registry.npmjs.org/postcss/-/postcss-8.5.6.tgz", + "integrity": "sha512-3Ybi1tAuwAP9s0r1UQ2J4n5Y0G05bJkpUIO0/bI9MhwmD70S5aTWbXGBwxHrelT+XM1k6dM0pk+SwNkpTRN7Pg==", + "dev": true, + "funding": [ + { + "type": "opencollective", + "url": "https://opencollective.com/postcss/" + }, + { + "type": "tidelift", + "url": "https://tidelift.com/funding/github/npm/postcss" + }, + { + "type": "github", + "url": "https://github.com/sponsors/ai" + } + ], + "license": "MIT", + "dependencies": { + "nanoid": "^3.3.11", + "picocolors": "^1.1.1", + "source-map-js": "^1.2.1" + }, + "engines": { + "node": "^10 || ^12 || >=14" + } + }, + "node_modules/readdirp": { + "version": "4.1.2", + "resolved": "https://registry.npmjs.org/readdirp/-/readdirp-4.1.2.tgz", + "integrity": "sha512-GDhwkLfywWL2s6vEjyhri+eXmfH6j1L7JE27WhqLeYzoh/A3DBaYGEj2H/HFZCn/kMfim73FXxEJTw06WtxQwg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 14.18.0" + }, + "funding": { + "type": "individual", + "url": "https://paulmillr.com/funding/" + } + }, + "node_modules/rollup": { + "version": "4.59.0", + "resolved": "https://registry.npmjs.org/rollup/-/rollup-4.59.0.tgz", + "integrity": "sha512-2oMpl67a3zCH9H79LeMcbDhXW/UmWG/y2zuqnF2jQq5uq9TbM9TVyXvA4+t+ne2IIkBdrLpAaRQAvo7YI/Yyeg==", + "dev": true, + "license": "MIT", + "dependencies": { + "@types/estree": "1.0.8" + }, + "bin": { + "rollup": "dist/bin/rollup" + }, + "engines": { + "node": ">=18.0.0", + "npm": ">=8.0.0" + }, + "optionalDependencies": { + "@rollup/rollup-android-arm-eabi": "4.59.0", + "@rollup/rollup-android-arm64": "4.59.0", + "@rollup/rollup-darwin-arm64": "4.59.0", + "@rollup/rollup-darwin-x64": "4.59.0", + "@rollup/rollup-freebsd-arm64": "4.59.0", + "@rollup/rollup-freebsd-x64": "4.59.0", + "@rollup/rollup-linux-arm-gnueabihf": "4.59.0", + "@rollup/rollup-linux-arm-musleabihf": "4.59.0", + "@rollup/rollup-linux-arm64-gnu": "4.59.0", + "@rollup/rollup-linux-arm64-musl": "4.59.0", + "@rollup/rollup-linux-loong64-gnu": "4.59.0", + "@rollup/rollup-linux-loong64-musl": "4.59.0", + "@rollup/rollup-linux-ppc64-gnu": "4.59.0", + "@rollup/rollup-linux-ppc64-musl": "4.59.0", + "@rollup/rollup-linux-riscv64-gnu": "4.59.0", + "@rollup/rollup-linux-riscv64-musl": "4.59.0", + "@rollup/rollup-linux-s390x-gnu": "4.59.0", + "@rollup/rollup-linux-x64-gnu": "4.59.0", + "@rollup/rollup-linux-x64-musl": "4.59.0", + "@rollup/rollup-openbsd-x64": "4.59.0", + "@rollup/rollup-openharmony-arm64": "4.59.0", + "@rollup/rollup-win32-arm64-msvc": "4.59.0", + "@rollup/rollup-win32-ia32-msvc": "4.59.0", + "@rollup/rollup-win32-x64-gnu": "4.59.0", + "@rollup/rollup-win32-x64-msvc": "4.59.0", + "fsevents": "~2.3.2" + } + }, + "node_modules/sade": { + "version": "1.8.1", + "resolved": "https://registry.npmjs.org/sade/-/sade-1.8.1.tgz", + "integrity": "sha512-xal3CZX1Xlo/k4ApwCFrHVACi9fBqJ7V+mwhBsuf/1IOKbBy098Fex+Wa/5QMubw09pSZ/u8EY8PWgevJsXp1A==", + "dev": true, + "license": "MIT", + "dependencies": { + "mri": "^1.1.0" + }, + "engines": { + "node": ">=6" + } + }, + "node_modules/set-cookie-parser": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/set-cookie-parser/-/set-cookie-parser-3.0.1.tgz", + "integrity": "sha512-n7Z7dXZhJbwuAHhNzkTti6Aw9QDDjZtm3JTpTGATIdNzdQz5GuFs22w90BcvF4INfnrL5xrX3oGsuqO5Dx3A1Q==", + "dev": true, + "license": "MIT" + }, + "node_modules/sirv": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/sirv/-/sirv-3.0.2.tgz", + "integrity": "sha512-2wcC/oGxHis/BoHkkPwldgiPSYcpZK3JU28WoMVv55yHJgcZ8rlXvuG9iZggz+sU1d4bRgIGASwyWqjxu3FM0g==", + "dev": true, + "license": "MIT", + "dependencies": { + "@polka/url": "^1.0.0-next.24", + "mrmime": "^2.0.0", + "totalist": "^3.0.0" + }, + "engines": { + "node": ">=18" + } + }, + "node_modules/source-map-js": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/source-map-js/-/source-map-js-1.2.1.tgz", + "integrity": "sha512-UXWMKhLOwVKb728IUtQPXxfYU+usdybtUrK/8uGE8CQMvrhOpwvzDBwj0QhSL7MQc7vIsISBG8VQ8+IDQxpfQA==", + "dev": true, + "license": "BSD-3-Clause", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/svelte": { + "version": "5.53.3", + "resolved": "https://registry.npmjs.org/svelte/-/svelte-5.53.3.tgz", + "integrity": "sha512-pRUBr6j6uQDgBi208gHnGRMykw0Rf2Yr1HmLyRucsvcaYgIUxswJkT93WZJflsmezu5s8Lq+q78EoyLv2yaFCg==", + "dev": true, + "license": "MIT", + "peer": true, + "dependencies": { + "@jridgewell/remapping": "^2.3.4", + "@jridgewell/sourcemap-codec": "^1.5.0", + "@sveltejs/acorn-typescript": "^1.0.5", + "@types/estree": "^1.0.5", + "@types/trusted-types": "^2.0.7", + "acorn": "^8.12.1", + "aria-query": "5.3.1", + "axobject-query": "^4.1.0", + "clsx": "^2.1.1", + "devalue": "^5.6.3", + "esm-env": "^1.2.1", + "esrap": "^2.2.2", + "is-reference": "^3.0.3", + "locate-character": "^3.0.0", + "magic-string": "^0.30.11", + "zimmerframe": "^1.1.2" + }, + "engines": { + "node": ">=18" + } + }, + "node_modules/svelte-check": { + "version": "4.4.3", + "resolved": "https://registry.npmjs.org/svelte-check/-/svelte-check-4.4.3.tgz", + "integrity": "sha512-4HtdEv2hOoLCEsSXI+RDELk9okP/4sImWa7X02OjMFFOWeSdFF3NFy3vqpw0z+eH9C88J9vxZfUXz/Uv2A1ANw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@jridgewell/trace-mapping": "^0.3.25", + "chokidar": "^4.0.1", + "fdir": "^6.2.0", + "picocolors": "^1.0.0", + "sade": "^1.7.4" + }, + "bin": { + "svelte-check": "bin/svelte-check" + }, + "engines": { + "node": ">= 18.0.0" + }, + "peerDependencies": { + "svelte": "^4.0.0 || ^5.0.0-next.0", + "typescript": ">=5.0.0" + } + }, + "node_modules/tinyglobby": { + "version": "0.2.15", + "resolved": "https://registry.npmjs.org/tinyglobby/-/tinyglobby-0.2.15.tgz", + "integrity": "sha512-j2Zq4NyQYG5XMST4cbs02Ak8iJUdxRM0XI5QyxXuZOzKOINmWurp3smXu3y5wDcJrptwpSjgXHzIQxR0omXljQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "fdir": "^6.5.0", + "picomatch": "^4.0.3" + }, + "engines": { + "node": ">=12.0.0" + }, + "funding": { + "url": "https://github.com/sponsors/SuperchupuDev" + } + }, + "node_modules/totalist": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/totalist/-/totalist-3.0.1.tgz", + "integrity": "sha512-sf4i37nQ2LBx4m3wB74y+ubopq6W/dIzXg0FDGjsYnZHVa1Da8FH853wlL2gtUhg+xJXjfk3kUZS3BRoQeoQBQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6" + } + }, + "node_modules/typescript": { + "version": "5.6.3", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.6.3.tgz", + "integrity": "sha512-hjcS1mhfuyi4WW8IWtjP7brDrG2cuDZukyrYrSauoXGNgx0S7zceP07adYkJycEr56BOUTNPzbInooiN3fn1qw==", + "dev": true, + "license": "Apache-2.0", + "peer": true, + "bin": { + "tsc": "bin/tsc", + "tsserver": "bin/tsserver" + }, + "engines": { + "node": ">=14.17" + } + }, + "node_modules/vite": { + "version": "6.4.1", + "resolved": "https://registry.npmjs.org/vite/-/vite-6.4.1.tgz", + "integrity": "sha512-+Oxm7q9hDoLMyJOYfUYBuHQo+dkAloi33apOPP56pzj+vsdJDzr+j1NISE5pyaAuKL4A3UD34qd0lx5+kfKp2g==", + "dev": true, + "license": "MIT", + "peer": true, + "dependencies": { + "esbuild": "^0.25.0", + "fdir": "^6.4.4", + "picomatch": "^4.0.2", + "postcss": "^8.5.3", + "rollup": "^4.34.9", + "tinyglobby": "^0.2.13" + }, + "bin": { + "vite": "bin/vite.js" + }, + "engines": { + "node": "^18.0.0 || ^20.0.0 || >=22.0.0" + }, + "funding": { + "url": "https://github.com/vitejs/vite?sponsor=1" + }, + "optionalDependencies": { + "fsevents": "~2.3.3" + }, + "peerDependencies": { + "@types/node": "^18.0.0 || ^20.0.0 || >=22.0.0", + "jiti": ">=1.21.0", + "less": "*", + "lightningcss": "^1.21.0", + "sass": "*", + "sass-embedded": "*", + "stylus": "*", + "sugarss": "*", + "terser": "^5.16.0", + "tsx": "^4.8.1", + "yaml": "^2.4.2" + }, + "peerDependenciesMeta": { + "@types/node": { + "optional": true + }, + "jiti": { + "optional": true + }, + "less": { + "optional": true + }, + "lightningcss": { + "optional": true + }, + "sass": { + "optional": true + }, + "sass-embedded": { + "optional": true + }, + "stylus": { + "optional": true + }, + "sugarss": { + "optional": true + }, + "terser": { + "optional": true + }, + "tsx": { + "optional": true + }, + "yaml": { + "optional": true + } + } + }, + "node_modules/vitefu": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/vitefu/-/vitefu-1.1.2.tgz", + "integrity": "sha512-zpKATdUbzbsycPFBN71nS2uzBUQiVnFoOrr2rvqv34S1lcAgMKKkjWleLGeiJlZ8lwCXvtWaRn7R3ZC16SYRuw==", + "dev": true, + "license": "MIT", + "workspaces": [ + "tests/deps/*", + "tests/projects/*", + "tests/projects/workspace/packages/*" + ], + "peerDependencies": { + "vite": "^3.0.0 || ^4.0.0 || ^5.0.0 || ^6.0.0 || ^7.0.0 || ^8.0.0-beta.0" + }, + "peerDependenciesMeta": { + "vite": { + "optional": true + } + } + }, + "node_modules/zimmerframe": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/zimmerframe/-/zimmerframe-1.1.4.tgz", + "integrity": "sha512-B58NGBEoc8Y9MWWCQGl/gq9xBCe4IiKM0a2x7GZdQKOW5Exr8S1W24J6OgM1njK8xCRGvAJIL/MxXHf6SkmQKQ==", + "dev": true, + "license": "MIT" + } + } +} diff --git a/Journal.App/package.json b/Journal.App/package.json new file mode 100644 index 0000000..bdca238 --- /dev/null +++ b/Journal.App/package.json @@ -0,0 +1,30 @@ +{ + "name": "journalapp", + "version": "0.1.0", + "description": "", + "type": "module", + "scripts": { + "dev": "vite dev", + "build": "vite build", + "preview": "vite preview", + "check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json", + "check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch", + "tauri": "tauri" + }, + "license": "MIT", + "dependencies": { + "@tauri-apps/api": "^2", + "@tauri-apps/plugin-dialog": "^2.6.0", + "@tauri-apps/plugin-opener": "^2" + }, + "devDependencies": { + "@sveltejs/adapter-static": "^3.0.6", + "@sveltejs/kit": "^2.9.0", + "@sveltejs/vite-plugin-svelte": "^5.0.0", + "@tauri-apps/cli": "^2", + "svelte": "^5.0.0", + "svelte-check": "^4.0.0", + "typescript": "~5.6.2", + "vite": "^6.0.3" + } +} diff --git a/Journal.App/src-tauri/.gitignore b/Journal.App/src-tauri/.gitignore new file mode 100644 index 0000000..b21bd68 --- /dev/null +++ b/Journal.App/src-tauri/.gitignore @@ -0,0 +1,7 @@ +# Generated by Cargo +# will have compiled files and executables +/target/ + +# Generated by Tauri +# will have schema files for capabilities auto-completion +/gen/schemas diff --git a/Journal.App/src-tauri/Cargo.lock b/Journal.App/src-tauri/Cargo.lock new file mode 100644 index 0000000..2191152 --- /dev/null +++ b/Journal.App/src-tauri/Cargo.lock @@ -0,0 +1,5375 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 4 + +[[package]] +name = "adler2" +version = "2.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "320119579fcad9c21884f5c4861d16174d0e06250625266f50fe6898340abefa" + +[[package]] +name = "aho-corasick" +version = "1.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ddd31a130427c27518df266943a5308ed92d4b226cc639f5a8f1002816174301" +dependencies = [ + "memchr", +] + +[[package]] +name = "alloc-no-stdlib" +version = "2.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cc7bb162ec39d46ab1ca8c77bf72e890535becd1751bb45f64c597edb4c8c6b3" + +[[package]] +name = "alloc-stdlib" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "94fb8275041c72129eb51b7d0322c29b8387a0386127718b096429201a5d6ece" +dependencies = [ + "alloc-no-stdlib", +] + +[[package]] +name = "android_system_properties" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "819e7219dbd41043ac279b19830f2efc897156490d7fd6ea916720117ee66311" +dependencies = [ + "libc", +] + +[[package]] +name = "anyhow" +version = "1.0.102" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f202df86484c868dbad7eaa557ef785d5c66295e41b460ef922eca0723b842c" + +[[package]] +name = "async-broadcast" +version = "0.7.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "435a87a52755b8f27fcf321ac4f04b2802e337c8c4872923137471ec39c37532" +dependencies = [ + "event-listener", + "event-listener-strategy", + "futures-core", + "pin-project-lite", +] + +[[package]] +name = "async-channel" +version = "2.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "924ed96dd52d1b75e9c1a3e6275715fd320f5f9439fb5a4a11fa51f4221158d2" +dependencies = [ + "concurrent-queue", + "event-listener-strategy", + "futures-core", + "pin-project-lite", +] + +[[package]] +name = "async-executor" +version = "1.14.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c96bf972d85afc50bf5ab8fe2d54d1586b4e0b46c97c50a0c9e71e2f7bcd812a" +dependencies = [ + "async-task", + "concurrent-queue", + "fastrand", + "futures-lite", + "pin-project-lite", + "slab", +] + +[[package]] +name = "async-io" +version = "2.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "456b8a8feb6f42d237746d4b3e9a178494627745c3c56c6ea55d92ba50d026fc" +dependencies = [ + "autocfg", + "cfg-if", + "concurrent-queue", + "futures-io", + "futures-lite", + "parking", + "polling", + "rustix", + "slab", + "windows-sys 0.61.2", +] + +[[package]] +name = "async-lock" +version = "3.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "290f7f2596bd5b78a9fec8088ccd89180d7f9f55b94b0576823bbbdc72ee8311" +dependencies = [ + "event-listener", + "event-listener-strategy", + "pin-project-lite", +] + +[[package]] +name = "async-process" +version = "2.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fc50921ec0055cdd8a16de48773bfeec5c972598674347252c0399676be7da75" +dependencies = [ + "async-channel", + "async-io", + "async-lock", + "async-signal", + "async-task", + "blocking", + "cfg-if", + "event-listener", + "futures-lite", + "rustix", +] + +[[package]] +name = "async-recursion" +version = "1.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3b43422f69d8ff38f95f1b2bb76517c91589a924d1559a0e935d7c8ce0274c11" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.117", +] + +[[package]] +name = "async-signal" +version = "0.2.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "43c070bbf59cd3570b6b2dd54cd772527c7c3620fce8be898406dd3ed6adc64c" +dependencies = [ + "async-io", + "async-lock", + "atomic-waker", + "cfg-if", + "futures-core", + "futures-io", + "rustix", + "signal-hook-registry", + "slab", + "windows-sys 0.61.2", +] + +[[package]] +name = "async-task" +version = "4.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8b75356056920673b02621b35afd0f7dda9306d03c79a30f5c56c44cf256e3de" + +[[package]] +name = "async-trait" +version = "0.1.89" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9035ad2d096bed7955a320ee7e2230574d28fd3c3a0f186cbea1ff3c7eed5dbb" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.117", +] + +[[package]] +name = "atk" +version = "0.18.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "241b621213072e993be4f6f3a9e4b45f65b7e6faad43001be957184b7bb1824b" +dependencies = [ + "atk-sys", + "glib", + "libc", +] + +[[package]] +name = "atk-sys" +version = "0.18.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c5e48b684b0ca77d2bbadeef17424c2ea3c897d44d566a1617e7e8f30614d086" +dependencies = [ + "glib-sys", + "gobject-sys", + "libc", + "system-deps", +] + +[[package]] +name = "atomic-waker" +version = "1.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1505bd5d3d116872e7271a6d4e16d81d0c8570876c8de68093a09ac269d8aac0" + +[[package]] +name = "autocfg" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c08606f8c3cbf4ce6ec8e28fb0014a2c086708fe954eaa885384a6165172e7e8" + +[[package]] +name = "base64" +version = "0.21.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9d297deb1925b89f2ccc13d7635fa0714f12c87adce1c75356b39ca9b7178567" + +[[package]] +name = "base64" +version = "0.22.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72b3254f16251a8381aa12e40e3c4d2f0199f8c6508fbecb9d91f575e0fbb8c6" + +[[package]] +name = "bitflags" +version = "1.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" + +[[package]] +name = "bitflags" +version = "2.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "843867be96c8daad0d758b57df9392b6d8d271134fce549de6ce169ff98a92af" +dependencies = [ + "serde_core", +] + +[[package]] +name = "block-buffer" +version = "0.10.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3078c7629b62d3f0439517fa394996acacc5cbc91c5a20d8c658e77abd503a71" +dependencies = [ + "generic-array", +] + +[[package]] +name = "block2" +version = "0.6.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cdeb9d870516001442e364c5220d3574d2da8dc765554b4a617230d33fa58ef5" +dependencies = [ + "objc2", +] + +[[package]] +name = "blocking" +version = "1.6.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e83f8d02be6967315521be875afa792a316e28d57b5a2d401897e2a7921b7f21" +dependencies = [ + "async-channel", + "async-task", + "futures-io", + "futures-lite", + "piper", +] + +[[package]] +name = "brotli" +version = "8.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4bd8b9603c7aa97359dbd97ecf258968c95f3adddd6db2f7e7a5bef101c84560" +dependencies = [ + "alloc-no-stdlib", + "alloc-stdlib", + "brotli-decompressor", +] + +[[package]] +name = "brotli-decompressor" +version = "5.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "874bb8112abecc98cbd6d81ea4fa7e94fb9449648c93cc89aa40c81c24d7de03" +dependencies = [ + "alloc-no-stdlib", + "alloc-stdlib", +] + +[[package]] +name = "bumpalo" +version = "3.20.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5d20789868f4b01b2f2caec9f5c4e0213b41e3e5702a50157d699ae31ced2fcb" + +[[package]] +name = "bytemuck" +version = "1.25.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c8efb64bd706a16a1bdde310ae86b351e4d21550d98d056f22f8a7f7a2183fec" + +[[package]] +name = "byteorder" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" + +[[package]] +name = "bytes" +version = "1.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e748733b7cbc798e1434b6ac524f0c1ff2ab456fe201501e6497c8417a4fc33" +dependencies = [ + "serde", +] + +[[package]] +name = "cairo-rs" +version = "0.18.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8ca26ef0159422fb77631dc9d17b102f253b876fe1586b03b803e63a309b4ee2" +dependencies = [ + "bitflags 2.11.0", + "cairo-sys-rs", + "glib", + "libc", + "once_cell", + "thiserror 1.0.69", +] + +[[package]] +name = "cairo-sys-rs" +version = "0.18.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "685c9fa8e590b8b3d678873528d83411db17242a73fccaed827770ea0fedda51" +dependencies = [ + "glib-sys", + "libc", + "system-deps", +] + +[[package]] +name = "camino" +version = "1.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e629a66d692cb9ff1a1c664e41771b3dcaf961985a9774c0eb0bd1b51cf60a48" +dependencies = [ + "serde_core", +] + +[[package]] +name = "cargo-platform" +version = "0.1.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e35af189006b9c0f00a064685c727031e3ed2d8020f7ba284d78cc2671bd36ea" +dependencies = [ + "serde", +] + +[[package]] +name = "cargo_metadata" +version = "0.19.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dd5eb614ed4c27c5d706420e4320fbe3216ab31fa1c33cd8246ac36dae4479ba" +dependencies = [ + "camino", + "cargo-platform", + "semver", + "serde", + "serde_json", + "thiserror 2.0.18", +] + +[[package]] +name = "cargo_toml" +version = "0.22.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "374b7c592d9c00c1f4972ea58390ac6b18cbb6ab79011f3bdc90a0b82ca06b77" +dependencies = [ + "serde", + "toml 0.9.12+spec-1.1.0", +] + +[[package]] +name = "cc" +version = "1.2.56" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aebf35691d1bfb0ac386a69bac2fde4dd276fb618cf8bf4f5318fe285e821bb2" +dependencies = [ + "find-msvc-tools", + "shlex", +] + +[[package]] +name = "cesu8" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6d43a04d8753f35258c91f8ec639f792891f748a1edbd759cf1dcea3382ad83c" + +[[package]] +name = "cfb" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d38f2da7a0a2c4ccf0065be06397cc26a81f4e528be095826eee9d4adbb8c60f" +dependencies = [ + "byteorder", + "fnv", + "uuid", +] + +[[package]] +name = "cfg-expr" +version = "0.15.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d067ad48b8650848b989a59a86c6c36a995d02d2bf778d45c3c5d57bc2718f02" +dependencies = [ + "smallvec", + "target-lexicon", +] + +[[package]] +name = "cfg-if" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9330f8b2ff13f34540b44e946ef35111825727b38d33286ef986142615121801" + +[[package]] +name = "chrono" +version = "0.4.44" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c673075a2e0e5f4a1dde27ce9dee1ea4558c7ffe648f576438a20ca1d2acc4b0" +dependencies = [ + "iana-time-zone", + "num-traits", + "serde", + "windows-link 0.2.1", +] + +[[package]] +name = "combine" +version = "4.6.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ba5a308b75df32fe02788e748662718f03fde005016435c444eea572398219fd" +dependencies = [ + "bytes", + "memchr", +] + +[[package]] +name = "concurrent-queue" +version = "2.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4ca0197aee26d1ae37445ee532fefce43251d24cc7c166799f4d46817f1d3973" +dependencies = [ + "crossbeam-utils", +] + +[[package]] +name = "convert_case" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6245d59a3e82a7fc217c5828a6692dbc6dfb63a0c8c90495621f7b9d79704a0e" + +[[package]] +name = "cookie" +version = "0.18.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4ddef33a339a91ea89fb53151bd0a4689cfce27055c291dfa69945475d22c747" +dependencies = [ + "time", + "version_check", +] + +[[package]] +name = "core-foundation" +version = "0.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b2a6cd9ae233e7f62ba4e9353e81a88df7fc8a5987b8d445b4d90c879bd156f6" +dependencies = [ + "core-foundation-sys", + "libc", +] + +[[package]] +name = "core-foundation-sys" +version = "0.8.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "773648b94d0e5d620f64f280777445740e61fe701025087ec8b57f45c791888b" + +[[package]] +name = "core-graphics" +version = "0.24.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fa95a34622365fa5bbf40b20b75dba8dfa8c94c734aea8ac9a5ca38af14316f1" +dependencies = [ + "bitflags 2.11.0", + "core-foundation", + "core-graphics-types", + "foreign-types", + "libc", +] + +[[package]] +name = "core-graphics-types" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3d44a101f213f6c4cdc1853d4b78aef6db6bdfa3468798cc1d9912f4735013eb" +dependencies = [ + "bitflags 2.11.0", + "core-foundation", + "libc", +] + +[[package]] +name = "cpufeatures" +version = "0.2.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "59ed5838eebb26a2bb2e58f6d5b5316989ae9d08bab10e0e6d103e656d1b0280" +dependencies = [ + "libc", +] + +[[package]] +name = "crc32fast" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9481c1c90cbf2ac953f07c8d4a58aa3945c425b7185c9154d67a65e4230da511" +dependencies = [ + "cfg-if", +] + +[[package]] +name = "crossbeam-channel" +version = "0.5.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "82b8f8f868b36967f9606790d1903570de9ceaf870a7bf9fbbd3016d636a2cb2" +dependencies = [ + "crossbeam-utils", +] + +[[package]] +name = "crossbeam-utils" +version = "0.8.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d0a5c400df2834b80a4c3327b3aad3a4c4cd4de0629063962b03235697506a28" + +[[package]] +name = "crypto-common" +version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "78c8292055d1c1df0cce5d180393dc8cce0abec0a7102adb6c7b1eef6016d60a" +dependencies = [ + "generic-array", + "typenum", +] + +[[package]] +name = "cssparser" +version = "0.29.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f93d03419cb5950ccfd3daf3ff1c7a36ace64609a1a8746d493df1ca0afde0fa" +dependencies = [ + "cssparser-macros", + "dtoa-short", + "itoa", + "matches", + "phf 0.10.1", + "proc-macro2", + "quote", + "smallvec", + "syn 1.0.109", +] + +[[package]] +name = "cssparser-macros" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "13b588ba4ac1a99f7f2964d24b3d896ddc6bf847ee3855dbd4366f058cfcd331" +dependencies = [ + "quote", + "syn 2.0.117", +] + +[[package]] +name = "ctor" +version = "0.2.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "32a2785755761f3ddc1492979ce1e48d2c00d09311c39e4466429188f3dd6501" +dependencies = [ + "quote", + "syn 2.0.117", +] + +[[package]] +name = "darling" +version = "0.21.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9cdf337090841a411e2a7f3deb9187445851f91b309c0c0a29e05f74a00a48c0" +dependencies = [ + "darling_core", + "darling_macro", +] + +[[package]] +name = "darling_core" +version = "0.21.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1247195ecd7e3c85f83c8d2a366e4210d588e802133e1e355180a9870b517ea4" +dependencies = [ + "fnv", + "ident_case", + "proc-macro2", + "quote", + "strsim", + "syn 2.0.117", +] + +[[package]] +name = "darling_macro" +version = "0.21.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d38308df82d1080de0afee5d069fa14b0326a88c14f15c5ccda35b4a6c414c81" +dependencies = [ + "darling_core", + "quote", + "syn 2.0.117", +] + +[[package]] +name = "deranged" +version = "0.5.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7cd812cc2bc1d69d4764bd80df88b4317eaef9e773c75226407d9bc0876b211c" +dependencies = [ + "powerfmt", + "serde_core", +] + +[[package]] +name = "derive_more" +version = "0.99.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6edb4b64a43d977b8e99788fe3a04d483834fba1215a7e02caa415b626497f7f" +dependencies = [ + "convert_case", + "proc-macro2", + "quote", + "rustc_version", + "syn 2.0.117", +] + +[[package]] +name = "digest" +version = "0.10.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292" +dependencies = [ + "block-buffer", + "crypto-common", +] + +[[package]] +name = "dirs" +version = "6.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c3e8aa94d75141228480295a7d0e7feb620b1a5ad9f12bc40be62411e38cce4e" +dependencies = [ + "dirs-sys", +] + +[[package]] +name = "dirs-sys" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e01a3366d27ee9890022452ee61b2b63a67e6f13f58900b651ff5665f0bb1fab" +dependencies = [ + "libc", + "option-ext", + "redox_users", + "windows-sys 0.61.2", +] + +[[package]] +name = "dispatch" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bd0c93bb4b0c6d9b77f4435b0ae98c24d17f1c45b2ff844c6151a07256ca923b" + +[[package]] +name = "dispatch2" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "89a09f22a6c6069a18470eb92d2298acf25463f14256d24778e1230d789a2aec" +dependencies = [ + "bitflags 2.11.0", + "block2", + "libc", + "objc2", +] + +[[package]] +name = "displaydoc" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "97369cbbc041bc366949bc74d34658d6cda5621039731c6310521892a3a20ae0" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.117", +] + +[[package]] +name = "dlopen2" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5e2c5bd4158e66d1e215c49b837e11d62f3267b30c92f1d171c4d3105e3dc4d4" +dependencies = [ + "dlopen2_derive", + "libc", + "once_cell", + "winapi", +] + +[[package]] +name = "dlopen2_derive" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0fbbb781877580993a8707ec48672673ec7b81eeba04cfd2310bd28c08e47c8f" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.117", +] + +[[package]] +name = "dpi" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d8b14ccef22fc6f5a8f4d7d768562a182c04ce9a3b3157b91390b52ddfdf1a76" +dependencies = [ + "serde", +] + +[[package]] +name = "dtoa" +version = "1.0.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4c3cf4824e2d5f025c7b531afcb2325364084a16806f6d47fbc1f5fbd9960590" + +[[package]] +name = "dtoa-short" +version = "0.3.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cd1511a7b6a56299bd043a9c167a6d2bfb37bf84a6dfceaba651168adfb43c87" +dependencies = [ + "dtoa", +] + +[[package]] +name = "dunce" +version = "1.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "92773504d58c093f6de2459af4af33faa518c13451eb8f2b5698ed3d36e7c813" + +[[package]] +name = "dyn-clone" +version = "1.0.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d0881ea181b1df73ff77ffaaf9c7544ecc11e82fba9b5f27b262a3c73a332555" + +[[package]] +name = "embed-resource" +version = "3.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "55a075fc573c64510038d7ee9abc7990635863992f83ebc52c8b433b8411a02e" +dependencies = [ + "cc", + "memchr", + "rustc_version", + "toml 0.9.12+spec-1.1.0", + "vswhom", + "winreg", +] + +[[package]] +name = "embed_plist" +version = "1.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4ef6b89e5b37196644d8796de5268852ff179b44e96276cf4290264843743bb7" + +[[package]] +name = "endi" +version = "1.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "66b7e2430c6dff6a955451e2cfc438f09cea1965a9d6f87f7e3b90decc014099" + +[[package]] +name = "enumflags2" +version = "0.7.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1027f7680c853e056ebcec683615fb6fbbc07dbaa13b4d5d9442b146ded4ecef" +dependencies = [ + "enumflags2_derive", + "serde", +] + +[[package]] +name = "enumflags2_derive" +version = "0.7.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "67c78a4d8fdf9953a5c9d458f9efe940fd97a0cab0941c075a813ac594733827" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.117", +] + +[[package]] +name = "equivalent" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "877a4ace8713b0bcf2a4e7eec82529c029f1d0619886d18145fea96c3ffe5c0f" + +[[package]] +name = "erased-serde" +version = "0.4.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "89e8918065695684b2b0702da20382d5ae6065cf3327bc2d6436bd49a71ce9f3" +dependencies = [ + "serde", + "serde_core", + "typeid", +] + +[[package]] +name = "errno" +version = "0.3.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "39cab71617ae0d63f51a36d69f866391735b51691dbda63cf6f96d042b63efeb" +dependencies = [ + "libc", + "windows-sys 0.61.2", +] + +[[package]] +name = "event-listener" +version = "5.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e13b66accf52311f30a0db42147dadea9850cb48cd070028831ae5f5d4b856ab" +dependencies = [ + "concurrent-queue", + "parking", + "pin-project-lite", +] + +[[package]] +name = "event-listener-strategy" +version = "0.5.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8be9f3dfaaffdae2972880079a491a1a8bb7cbed0b8dd7a347f668b4150a3b93" +dependencies = [ + "event-listener", + "pin-project-lite", +] + +[[package]] +name = "fastrand" +version = "2.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "37909eebbb50d72f9059c3b6d82c0463f2ff062c9e95845c43a6c9c0355411be" + +[[package]] +name = "fdeflate" +version = "0.3.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e6853b52649d4ac5c0bd02320cddc5ba956bdb407c4b75a2c6b75bf51500f8c" +dependencies = [ + "simd-adler32", +] + +[[package]] +name = "field-offset" +version = "0.3.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "38e2275cc4e4fc009b0669731a1e5ab7ebf11f469eaede2bab9309a5b4d6057f" +dependencies = [ + "memoffset", + "rustc_version", +] + +[[package]] +name = "find-msvc-tools" +version = "0.1.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5baebc0774151f905a1a2cc41989300b1e6fbb29aff0ceffa1064fdd3088d582" + +[[package]] +name = "flate2" +version = "1.1.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "843fba2746e448b37e26a819579957415c8cef339bf08564fe8b7ddbd959573c" +dependencies = [ + "crc32fast", + "miniz_oxide", +] + +[[package]] +name = "fnv" +version = "1.0.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" + +[[package]] +name = "foldhash" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d9c4f5dac5e15c24eb999c26181a6ca40b39fe946cbe4c263c7209467bc83af2" + +[[package]] +name = "foreign-types" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d737d9aa519fb7b749cbc3b962edcf310a8dd1f4b67c91c4f83975dbdd17d965" +dependencies = [ + "foreign-types-macros", + "foreign-types-shared", +] + +[[package]] +name = "foreign-types-macros" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1a5c6c585bc94aaf2c7b51dd4c2ba22680844aba4c687be581871a6f518c5742" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.117", +] + +[[package]] +name = "foreign-types-shared" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aa9a19cbb55df58761df49b23516a86d432839add4af60fc256da840f66ed35b" + +[[package]] +name = "form_urlencoded" +version = "1.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cb4cb245038516f5f85277875cdaa4f7d2c9a0fa0468de06ed190163b1581fcf" +dependencies = [ + "percent-encoding", +] + +[[package]] +name = "futf" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "df420e2e84819663797d1ec6544b13c5be84629e7bb00dc960d6917db2987843" +dependencies = [ + "mac", + "new_debug_unreachable", +] + +[[package]] +name = "futures-channel" +version = "0.3.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "07bbe89c50d7a535e539b8c17bc0b49bdb77747034daa8087407d655f3f7cc1d" +dependencies = [ + "futures-core", +] + +[[package]] +name = "futures-core" +version = "0.3.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7e3450815272ef58cec6d564423f6e755e25379b217b0bc688e295ba24df6b1d" + +[[package]] +name = "futures-executor" +version = "0.3.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "baf29c38818342a3b26b5b923639e7b1f4a61fc5e76102d4b1981c6dc7a7579d" +dependencies = [ + "futures-core", + "futures-task", + "futures-util", +] + +[[package]] +name = "futures-io" +version = "0.3.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cecba35d7ad927e23624b22ad55235f2239cfa44fd10428eecbeba6d6a717718" + +[[package]] +name = "futures-lite" +version = "2.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f78e10609fe0e0b3f4157ffab1876319b5b0db102a2c60dc4626306dc46b44ad" +dependencies = [ + "fastrand", + "futures-core", + "futures-io", + "parking", + "pin-project-lite", +] + +[[package]] +name = "futures-macro" +version = "0.3.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e835b70203e41293343137df5c0664546da5745f82ec9b84d40be8336958447b" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.117", +] + +[[package]] +name = "futures-sink" +version = "0.3.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c39754e157331b013978ec91992bde1ac089843443c49cbc7f46150b0fad0893" + +[[package]] +name = "futures-task" +version = "0.3.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "037711b3d59c33004d3856fbdc83b99d4ff37a24768fa1be9ce3538a1cde4393" + +[[package]] +name = "futures-util" +version = "0.3.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "389ca41296e6190b48053de0321d02a77f32f8a5d2461dd38762c0593805c6d6" +dependencies = [ + "futures-core", + "futures-io", + "futures-macro", + "futures-sink", + "futures-task", + "memchr", + "pin-project-lite", + "slab", +] + +[[package]] +name = "fxhash" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c31b6d751ae2c7f11320402d34e41349dd1016f8d5d45e48c4312bc8625af50c" +dependencies = [ + "byteorder", +] + +[[package]] +name = "gdk" +version = "0.18.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d9f245958c627ac99d8e529166f9823fb3b838d1d41fd2b297af3075093c2691" +dependencies = [ + "cairo-rs", + "gdk-pixbuf", + "gdk-sys", + "gio", + "glib", + "libc", + "pango", +] + +[[package]] +name = "gdk-pixbuf" +version = "0.18.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "50e1f5f1b0bfb830d6ccc8066d18db35c487b1b2b1e8589b5dfe9f07e8defaec" +dependencies = [ + "gdk-pixbuf-sys", + "gio", + "glib", + "libc", + "once_cell", +] + +[[package]] +name = "gdk-pixbuf-sys" +version = "0.18.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f9839ea644ed9c97a34d129ad56d38a25e6756f99f3a88e15cd39c20629caf7" +dependencies = [ + "gio-sys", + "glib-sys", + "gobject-sys", + "libc", + "system-deps", +] + +[[package]] +name = "gdk-sys" +version = "0.18.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c2d13f38594ac1e66619e188c6d5a1adb98d11b2fcf7894fc416ad76aa2f3f7" +dependencies = [ + "cairo-sys-rs", + "gdk-pixbuf-sys", + "gio-sys", + "glib-sys", + "gobject-sys", + "libc", + "pango-sys", + "pkg-config", + "system-deps", +] + +[[package]] +name = "gdkwayland-sys" +version = "0.18.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "140071d506d223f7572b9f09b5e155afbd77428cd5cc7af8f2694c41d98dfe69" +dependencies = [ + "gdk-sys", + "glib-sys", + "gobject-sys", + "libc", + "pkg-config", + "system-deps", +] + +[[package]] +name = "gdkx11" +version = "0.18.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3caa00e14351bebbc8183b3c36690327eb77c49abc2268dd4bd36b856db3fbfe" +dependencies = [ + "gdk", + "gdkx11-sys", + "gio", + "glib", + "libc", + "x11", +] + +[[package]] +name = "gdkx11-sys" +version = "0.18.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6e2e7445fe01ac26f11601db260dd8608fe172514eb63b3b5e261ea6b0f4428d" +dependencies = [ + "gdk-sys", + "glib-sys", + "libc", + "system-deps", + "x11", +] + +[[package]] +name = "generic-array" +version = "0.14.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "85649ca51fd72272d7821adaf274ad91c288277713d9c18820d8499a7ff69e9a" +dependencies = [ + "typenum", + "version_check", +] + +[[package]] +name = "getrandom" +version = "0.1.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8fc3cb4d91f53b50155bdcfd23f6a4c39ae1969c2ae85982b135750cccaf5fce" +dependencies = [ + "cfg-if", + "libc", + "wasi 0.9.0+wasi-snapshot-preview1", +] + +[[package]] +name = "getrandom" +version = "0.2.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ff2abc00be7fca6ebc474524697ae276ad847ad0a6b3faa4bcb027e9a4614ad0" +dependencies = [ + "cfg-if", + "libc", + "wasi 0.11.1+wasi-snapshot-preview1", +] + +[[package]] +name = "getrandom" +version = "0.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "899def5c37c4fd7b2664648c28120ecec138e4d395b459e5ca34f9cce2dd77fd" +dependencies = [ + "cfg-if", + "libc", + "r-efi", + "wasip2", +] + +[[package]] +name = "getrandom" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "139ef39800118c7683f2fd3c98c1b23c09ae076556b435f8e9064ae108aaeeec" +dependencies = [ + "cfg-if", + "libc", + "r-efi", + "wasip2", + "wasip3", +] + +[[package]] +name = "gio" +version = "0.18.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d4fc8f532f87b79cbc51a79748f16a6828fb784be93145a322fa14d06d354c73" +dependencies = [ + "futures-channel", + "futures-core", + "futures-io", + "futures-util", + "gio-sys", + "glib", + "libc", + "once_cell", + "pin-project-lite", + "smallvec", + "thiserror 1.0.69", +] + +[[package]] +name = "gio-sys" +version = "0.18.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "37566df850baf5e4cb0dfb78af2e4b9898d817ed9263d1090a2df958c64737d2" +dependencies = [ + "glib-sys", + "gobject-sys", + "libc", + "system-deps", + "winapi", +] + +[[package]] +name = "glib" +version = "0.18.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "233daaf6e83ae6a12a52055f568f9d7cf4671dabb78ff9560ab6da230ce00ee5" +dependencies = [ + "bitflags 2.11.0", + "futures-channel", + "futures-core", + "futures-executor", + "futures-task", + "futures-util", + "gio-sys", + "glib-macros", + "glib-sys", + "gobject-sys", + "libc", + "memchr", + "once_cell", + "smallvec", + "thiserror 1.0.69", +] + +[[package]] +name = "glib-macros" +version = "0.18.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0bb0228f477c0900c880fd78c8759b95c7636dbd7842707f49e132378aa2acdc" +dependencies = [ + "heck 0.4.1", + "proc-macro-crate 2.0.2", + "proc-macro-error", + "proc-macro2", + "quote", + "syn 2.0.117", +] + +[[package]] +name = "glib-sys" +version = "0.18.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "063ce2eb6a8d0ea93d2bf8ba1957e78dbab6be1c2220dd3daca57d5a9d869898" +dependencies = [ + "libc", + "system-deps", +] + +[[package]] +name = "glob" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0cc23270f6e1808e30a928bdc84dea0b9b4136a8bc82338574f23baf47bbd280" + +[[package]] +name = "gobject-sys" +version = "0.18.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0850127b514d1c4a4654ead6dedadb18198999985908e6ffe4436f53c785ce44" +dependencies = [ + "glib-sys", + "libc", + "system-deps", +] + +[[package]] +name = "gtk" +version = "0.18.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fd56fb197bfc42bd5d2751f4f017d44ff59fbb58140c6b49f9b3b2bdab08506a" +dependencies = [ + "atk", + "cairo-rs", + "field-offset", + "futures-channel", + "gdk", + "gdk-pixbuf", + "gio", + "glib", + "gtk-sys", + "gtk3-macros", + "libc", + "pango", + "pkg-config", +] + +[[package]] +name = "gtk-sys" +version = "0.18.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f29a1c21c59553eb7dd40e918be54dccd60c52b049b75119d5d96ce6b624414" +dependencies = [ + "atk-sys", + "cairo-sys-rs", + "gdk-pixbuf-sys", + "gdk-sys", + "gio-sys", + "glib-sys", + "gobject-sys", + "libc", + "pango-sys", + "system-deps", +] + +[[package]] +name = "gtk3-macros" +version = "0.18.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "52ff3c5b21f14f0736fed6dcfc0bfb4225ebf5725f3c0209edeec181e4d73e9d" +dependencies = [ + "proc-macro-crate 1.3.1", + "proc-macro-error", + "proc-macro2", + "quote", + "syn 2.0.117", +] + +[[package]] +name = "hashbrown" +version = "0.12.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" + +[[package]] +name = "hashbrown" +version = "0.15.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9229cfe53dfd69f0609a49f65461bd93001ea1ef889cd5529dd176593f5338a1" +dependencies = [ + "foldhash", +] + +[[package]] +name = "hashbrown" +version = "0.16.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "841d1cc9bed7f9236f321df977030373f4a4163ae1a7dbfe1a51a2c1a51d9100" + +[[package]] +name = "heck" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8" + +[[package]] +name = "heck" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea" + +[[package]] +name = "hermit-abi" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fc0fef456e4baa96da950455cd02c081ca953b141298e41db3fc7e36b1da849c" + +[[package]] +name = "hex" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" + +[[package]] +name = "html5ever" +version = "0.29.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3b7410cae13cbc75623c98ac4cbfd1f0bedddf3227afc24f370cf0f50a44a11c" +dependencies = [ + "log", + "mac", + "markup5ever", + "match_token", +] + +[[package]] +name = "http" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e3ba2a386d7f85a81f119ad7498ebe444d2e22c2af0b86b069416ace48b3311a" +dependencies = [ + "bytes", + "itoa", +] + +[[package]] +name = "http-body" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1efedce1fb8e6913f23e0c92de8e62cd5b772a67e7b3946df930a62566c93184" +dependencies = [ + "bytes", + "http", +] + +[[package]] +name = "http-body-util" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b021d93e26becf5dc7e1b75b1bed1fd93124b374ceb73f43d4d4eafec896a64a" +dependencies = [ + "bytes", + "futures-core", + "http", + "http-body", + "pin-project-lite", +] + +[[package]] +name = "httparse" +version = "1.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6dbf3de79e51f3d586ab4cb9d5c3e2c14aa28ed23d180cf89b4df0454a69cc87" + +[[package]] +name = "hyper" +version = "1.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2ab2d4f250c3d7b1c9fcdff1cece94ea4e2dfbec68614f7b87cb205f24ca9d11" +dependencies = [ + "atomic-waker", + "bytes", + "futures-channel", + "futures-core", + "http", + "http-body", + "httparse", + "itoa", + "pin-project-lite", + "pin-utils", + "smallvec", + "tokio", + "want", +] + +[[package]] +name = "hyper-util" +version = "0.1.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "96547c2556ec9d12fb1578c4eaf448b04993e7fb79cbaad930a656880a6bdfa0" +dependencies = [ + "base64 0.22.1", + "bytes", + "futures-channel", + "futures-util", + "http", + "http-body", + "hyper", + "ipnet", + "libc", + "percent-encoding", + "pin-project-lite", + "socket2", + "tokio", + "tower-service", + "tracing", +] + +[[package]] +name = "iana-time-zone" +version = "0.1.65" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e31bc9ad994ba00e440a8aa5c9ef0ec67d5cb5e5cb0cc7f8b744a35b389cc470" +dependencies = [ + "android_system_properties", + "core-foundation-sys", + "iana-time-zone-haiku", + "js-sys", + "log", + "wasm-bindgen", + "windows-core 0.62.2", +] + +[[package]] +name = "iana-time-zone-haiku" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f31827a206f56af32e590ba56d5d2d085f558508192593743f16b2306495269f" +dependencies = [ + "cc", +] + +[[package]] +name = "ico" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3e795dff5605e0f04bff85ca41b51a96b83e80b281e96231bcaaf1ac35103371" +dependencies = [ + "byteorder", + "png", +] + +[[package]] +name = "icu_collections" +version = "2.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4c6b649701667bbe825c3b7e6388cb521c23d88644678e83c0c4d0a621a34b43" +dependencies = [ + "displaydoc", + "potential_utf", + "yoke", + "zerofrom", + "zerovec", +] + +[[package]] +name = "icu_locale_core" +version = "2.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "edba7861004dd3714265b4db54a3c390e880ab658fec5f7db895fae2046b5bb6" +dependencies = [ + "displaydoc", + "litemap", + "tinystr", + "writeable", + "zerovec", +] + +[[package]] +name = "icu_normalizer" +version = "2.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5f6c8828b67bf8908d82127b2054ea1b4427ff0230ee9141c54251934ab1b599" +dependencies = [ + "icu_collections", + "icu_normalizer_data", + "icu_properties", + "icu_provider", + "smallvec", + "zerovec", +] + +[[package]] +name = "icu_normalizer_data" +version = "2.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7aedcccd01fc5fe81e6b489c15b247b8b0690feb23304303a9e560f37efc560a" + +[[package]] +name = "icu_properties" +version = "2.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "020bfc02fe870ec3a66d93e677ccca0562506e5872c650f893269e08615d74ec" +dependencies = [ + "icu_collections", + "icu_locale_core", + "icu_properties_data", + "icu_provider", + "zerotrie", + "zerovec", +] + +[[package]] +name = "icu_properties_data" +version = "2.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "616c294cf8d725c6afcd8f55abc17c56464ef6211f9ed59cccffe534129c77af" + +[[package]] +name = "icu_provider" +version = "2.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "85962cf0ce02e1e0a629cc34e7ca3e373ce20dda4c4d7294bbd0bf1fdb59e614" +dependencies = [ + "displaydoc", + "icu_locale_core", + "writeable", + "yoke", + "zerofrom", + "zerotrie", + "zerovec", +] + +[[package]] +name = "id-arena" +version = "2.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3d3067d79b975e8844ca9eb072e16b31c3c1c36928edf9c6789548c524d0d954" + +[[package]] +name = "ident_case" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39" + +[[package]] +name = "idna" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3b0875f23caa03898994f6ddc501886a45c7d3d62d04d2d90788d47be1b1e4de" +dependencies = [ + "idna_adapter", + "smallvec", + "utf8_iter", +] + +[[package]] +name = "idna_adapter" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3acae9609540aa318d1bc588455225fb2085b9ed0c4f6bd0d9d5bcd86f1a0344" +dependencies = [ + "icu_normalizer", + "icu_properties", +] + +[[package]] +name = "indexmap" +version = "1.9.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bd070e393353796e801d209ad339e89596eb4c8d430d18ede6a1cced8fafbd99" +dependencies = [ + "autocfg", + "hashbrown 0.12.3", + "serde", +] + +[[package]] +name = "indexmap" +version = "2.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7714e70437a7dc3ac8eb7e6f8df75fd8eb422675fc7678aff7364301092b1017" +dependencies = [ + "equivalent", + "hashbrown 0.16.1", + "serde", + "serde_core", +] + +[[package]] +name = "infer" +version = "0.19.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a588916bfdfd92e71cacef98a63d9b1f0d74d6599980d11894290e7ddefffcf7" +dependencies = [ + "cfb", +] + +[[package]] +name = "ipnet" +version = "2.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "469fb0b9cefa57e3ef31275ee7cacb78f2fdca44e4765491884a2b119d4eb130" + +[[package]] +name = "iri-string" +version = "0.7.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c91338f0783edbd6195decb37bae672fd3b165faffb89bf7b9e6942f8b1a731a" +dependencies = [ + "memchr", + "serde", +] + +[[package]] +name = "is-docker" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "928bae27f42bc99b60d9ac7334e3a21d10ad8f1835a4e12ec3ec0464765ed1b3" +dependencies = [ + "once_cell", +] + +[[package]] +name = "is-wsl" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "173609498df190136aa7dea1a91db051746d339e18476eed5ca40521f02d7aa5" +dependencies = [ + "is-docker", + "once_cell", +] + +[[package]] +name = "itoa" +version = "1.0.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "92ecc6618181def0457392ccd0ee51198e065e016d1d527a7ac1b6dc7c1f09d2" + +[[package]] +name = "javascriptcore-rs" +version = "1.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ca5671e9ffce8ffba57afc24070e906da7fc4b1ba66f2cabebf61bf2ea257fcc" +dependencies = [ + "bitflags 1.3.2", + "glib", + "javascriptcore-rs-sys", +] + +[[package]] +name = "javascriptcore-rs-sys" +version = "1.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "af1be78d14ffa4b75b66df31840478fef72b51f8c2465d4ca7c194da9f7a5124" +dependencies = [ + "glib-sys", + "gobject-sys", + "libc", + "system-deps", +] + +[[package]] +name = "jni" +version = "0.21.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1a87aa2bb7d2af34197c04845522473242e1aa17c12f4935d5856491a7fb8c97" +dependencies = [ + "cesu8", + "cfg-if", + "combine", + "jni-sys", + "log", + "thiserror 1.0.69", + "walkdir", + "windows-sys 0.45.0", +] + +[[package]] +name = "jni-sys" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8eaf4bc02d17cbdd7ff4c7438cafcdf7fb9a4613313ad11b4f8fefe7d3fa0130" + +[[package]] +name = "journalapp" +version = "0.1.0" +dependencies = [ + "serde", + "serde_json", + "tauri", + "tauri-build", + "tauri-plugin-dialog", + "tauri-plugin-opener", + "tokio", +] + +[[package]] +name = "js-sys" +version = "0.3.90" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "14dc6f6450b3f6d4ed5b16327f38fed626d375a886159ca555bd7822c0c3a5a6" +dependencies = [ + "once_cell", + "wasm-bindgen", +] + +[[package]] +name = "json-patch" +version = "3.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "863726d7afb6bc2590eeff7135d923545e5e964f004c2ccf8716c25e70a86f08" +dependencies = [ + "jsonptr", + "serde", + "serde_json", + "thiserror 1.0.69", +] + +[[package]] +name = "jsonptr" +version = "0.6.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5dea2b27dd239b2556ed7a25ba842fe47fd602e7fc7433c2a8d6106d4d9edd70" +dependencies = [ + "serde", + "serde_json", +] + +[[package]] +name = "keyboard-types" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b750dcadc39a09dbadd74e118f6dd6598df77fa01df0cfcdc52c28dece74528a" +dependencies = [ + "bitflags 2.11.0", + "serde", + "unicode-segmentation", +] + +[[package]] +name = "kuchikiki" +version = "0.8.8-speedreader" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "02cb977175687f33fa4afa0c95c112b987ea1443e5a51c8f8ff27dc618270cc2" +dependencies = [ + "cssparser", + "html5ever", + "indexmap 2.13.0", + "selectors", +] + +[[package]] +name = "lazy_static" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" + +[[package]] +name = "leb128fmt" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09edd9e8b54e49e587e4f6295a7d29c3ea94d469cb40ab8ca70b288248a81db2" + +[[package]] +name = "libappindicator" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "03589b9607c868cc7ae54c0b2a22c8dc03dd41692d48f2d7df73615c6a95dc0a" +dependencies = [ + "glib", + "gtk", + "gtk-sys", + "libappindicator-sys", + "log", +] + +[[package]] +name = "libappindicator-sys" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6e9ec52138abedcc58dc17a7c6c0c00a2bdb4f3427c7f63fa97fd0d859155caf" +dependencies = [ + "gtk-sys", + "libloading", + "once_cell", +] + +[[package]] +name = "libc" +version = "0.2.182" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6800badb6cb2082ffd7b6a67e6125bb39f18782f793520caee8cb8846be06112" + +[[package]] +name = "libloading" +version = "0.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b67380fd3b2fbe7527a606e18729d21c6f3951633d0500574c4dc22d2d638b9f" +dependencies = [ + "cfg-if", + "winapi", +] + +[[package]] +name = "libredox" +version = "0.1.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3d0b95e02c851351f877147b7deea7b1afb1df71b63aa5f8270716e0c5720616" +dependencies = [ + "bitflags 2.11.0", + "libc", +] + +[[package]] +name = "linux-raw-sys" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "32a66949e030da00e8c7d4434b251670a91556f4144941d37452769c25d58a53" + +[[package]] +name = "litemap" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6373607a59f0be73a39b6fe456b8192fcc3585f602af20751600e974dd455e77" + +[[package]] +name = "lock_api" +version = "0.4.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "224399e74b87b5f3557511d98dff8b14089b3dadafcab6bb93eab67d3aace965" +dependencies = [ + "scopeguard", +] + +[[package]] +name = "log" +version = "0.4.29" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5e5032e24019045c762d3c0f28f5b6b8bbf38563a65908389bf7978758920897" + +[[package]] +name = "mac" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c41e0c4fef86961ac6d6f8a82609f55f31b05e4fce149ac5710e439df7619ba4" + +[[package]] +name = "markup5ever" +version = "0.14.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c7a7213d12e1864c0f002f52c2923d4556935a43dec5e71355c2760e0f6e7a18" +dependencies = [ + "log", + "phf 0.11.3", + "phf_codegen 0.11.3", + "string_cache", + "string_cache_codegen", + "tendril", +] + +[[package]] +name = "match_token" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "88a9689d8d44bf9964484516275f5cd4c9b59457a6940c1d5d0ecbb94510a36b" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.117", +] + +[[package]] +name = "matches" +version = "0.1.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2532096657941c2fea9c289d370a250971c689d4f143798ff67113ec042024a5" + +[[package]] +name = "memchr" +version = "2.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f8ca58f447f06ed17d5fc4043ce1b10dd205e060fb3ce5b979b8ed8e59ff3f79" + +[[package]] +name = "memoffset" +version = "0.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "488016bfae457b036d996092f6cb448677611ce4449e970ceaf42695203f218a" +dependencies = [ + "autocfg", +] + +[[package]] +name = "mime" +version = "0.3.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6877bb514081ee2a7ff5ef9de3281f14a4dd4bceac4c09388074a6b5df8a139a" + +[[package]] +name = "miniz_oxide" +version = "0.8.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1fa76a2c86f704bdb222d66965fb3d63269ce38518b83cb0575fca855ebb6316" +dependencies = [ + "adler2", + "simd-adler32", +] + +[[package]] +name = "mio" +version = "1.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a69bcab0ad47271a0234d9422b131806bf3968021e5dc9328caf2d4cd58557fc" +dependencies = [ + "libc", + "wasi 0.11.1+wasi-snapshot-preview1", + "windows-sys 0.61.2", +] + +[[package]] +name = "muda" +version = "0.17.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "01c1738382f66ed56b3b9c8119e794a2e23148ac8ea214eda86622d4cb9d415a" +dependencies = [ + "crossbeam-channel", + "dpi", + "gtk", + "keyboard-types", + "objc2", + "objc2-app-kit", + "objc2-core-foundation", + "objc2-foundation", + "once_cell", + "png", + "serde", + "thiserror 2.0.18", + "windows-sys 0.60.2", +] + +[[package]] +name = "ndk" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c3f42e7bbe13d351b6bead8286a43aac9534b82bd3cc43e47037f012ebfd62d4" +dependencies = [ + "bitflags 2.11.0", + "jni-sys", + "log", + "ndk-sys", + "num_enum", + "raw-window-handle", + "thiserror 1.0.69", +] + +[[package]] +name = "ndk-context" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "27b02d87554356db9e9a873add8782d4ea6e3e58ea071a9adb9a2e8ddb884a8b" + +[[package]] +name = "ndk-sys" +version = "0.6.0+11769913" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ee6cda3051665f1fb8d9e08fc35c96d5a244fb1be711a03b71118828afc9a873" +dependencies = [ + "jni-sys", +] + +[[package]] +name = "new_debug_unreachable" +version = "1.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "650eef8c711430f1a879fdd01d4745a7deea475becfb90269c06775983bbf086" + +[[package]] +name = "nodrop" +version = "0.1.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72ef4a56884ca558e5ddb05a1d1e7e1bfd9a68d9ed024c21704cc98872dae1bb" + +[[package]] +name = "num-conv" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cf97ec579c3c42f953ef76dbf8d55ac91fb219dde70e49aa4a6b7d74e9919050" + +[[package]] +name = "num-traits" +version = "0.2.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841" +dependencies = [ + "autocfg", +] + +[[package]] +name = "num_enum" +version = "0.7.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b1207a7e20ad57b847bbddc6776b968420d38292bbfe2089accff5e19e82454c" +dependencies = [ + "num_enum_derive", + "rustversion", +] + +[[package]] +name = "num_enum_derive" +version = "0.7.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ff32365de1b6743cb203b710788263c44a03de03802daf96092f2da4fe6ba4d7" +dependencies = [ + "proc-macro-crate 3.4.0", + "proc-macro2", + "quote", + "syn 2.0.117", +] + +[[package]] +name = "objc2" +version = "0.6.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b7c2599ce0ec54857b29ce62166b0ed9b4f6f1a70ccc9a71165b6154caca8c05" +dependencies = [ + "objc2-encode", + "objc2-exception-helper", +] + +[[package]] +name = "objc2-app-kit" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d49e936b501e5c5bf01fda3a9452ff86dc3ea98ad5f283e1455153142d97518c" +dependencies = [ + "bitflags 2.11.0", + "block2", + "libc", + "objc2", + "objc2-cloud-kit", + "objc2-core-data", + "objc2-core-foundation", + "objc2-core-graphics", + "objc2-core-image", + "objc2-core-text", + "objc2-core-video", + "objc2-foundation", + "objc2-quartz-core", +] + +[[package]] +name = "objc2-cloud-kit" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "73ad74d880bb43877038da939b7427bba67e9dd42004a18b809ba7d87cee241c" +dependencies = [ + "bitflags 2.11.0", + "objc2", + "objc2-foundation", +] + +[[package]] +name = "objc2-core-data" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b402a653efbb5e82ce4df10683b6b28027616a2715e90009947d50b8dd298fa" +dependencies = [ + "bitflags 2.11.0", + "objc2", + "objc2-foundation", +] + +[[package]] +name = "objc2-core-foundation" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2a180dd8642fa45cdb7dd721cd4c11b1cadd4929ce112ebd8b9f5803cc79d536" +dependencies = [ + "bitflags 2.11.0", + "dispatch2", + "objc2", +] + +[[package]] +name = "objc2-core-graphics" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e022c9d066895efa1345f8e33e584b9f958da2fd4cd116792e15e07e4720a807" +dependencies = [ + "bitflags 2.11.0", + "dispatch2", + "objc2", + "objc2-core-foundation", + "objc2-io-surface", +] + +[[package]] +name = "objc2-core-image" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e5d563b38d2b97209f8e861173de434bd0214cf020e3423a52624cd1d989f006" +dependencies = [ + "objc2", + "objc2-foundation", +] + +[[package]] +name = "objc2-core-text" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0cde0dfb48d25d2b4862161a4d5fcc0e3c24367869ad306b0c9ec0073bfed92d" +dependencies = [ + "bitflags 2.11.0", + "objc2", + "objc2-core-foundation", + "objc2-core-graphics", +] + +[[package]] +name = "objc2-core-video" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d425caf1df73233f29fd8a5c3e5edbc30d2d4307870f802d18f00d83dc5141a6" +dependencies = [ + "bitflags 2.11.0", + "objc2", + "objc2-core-foundation", + "objc2-core-graphics", + "objc2-io-surface", +] + +[[package]] +name = "objc2-encode" +version = "4.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ef25abbcd74fb2609453eb695bd2f860d389e457f67dc17cafc8b8cbc89d0c33" + +[[package]] +name = "objc2-exception-helper" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c7a1c5fbb72d7735b076bb47b578523aedc40f3c439bea6dfd595c089d79d98a" +dependencies = [ + "cc", +] + +[[package]] +name = "objc2-foundation" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e3e0adef53c21f888deb4fa59fc59f7eb17404926ee8a6f59f5df0fd7f9f3272" +dependencies = [ + "bitflags 2.11.0", + "block2", + "libc", + "objc2", + "objc2-core-foundation", +] + +[[package]] +name = "objc2-io-surface" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "180788110936d59bab6bd83b6060ffdfffb3b922ba1396b312ae795e1de9d81d" +dependencies = [ + "bitflags 2.11.0", + "objc2", + "objc2-core-foundation", +] + +[[package]] +name = "objc2-javascript-core" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2a1e6550c4caed348956ce3370c9ffeca70bb1dbed4fa96112e7c6170e074586" +dependencies = [ + "objc2", + "objc2-core-foundation", +] + +[[package]] +name = "objc2-quartz-core" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "96c1358452b371bf9f104e21ec536d37a650eb10f7ee379fff67d2e08d537f1f" +dependencies = [ + "bitflags 2.11.0", + "objc2", + "objc2-core-foundation", + "objc2-foundation", +] + +[[package]] +name = "objc2-security" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "709fe137109bd1e8b5a99390f77a7d8b2961dafc1a1c5db8f2e60329ad6d895a" +dependencies = [ + "bitflags 2.11.0", + "objc2", + "objc2-core-foundation", +] + +[[package]] +name = "objc2-ui-kit" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d87d638e33c06f577498cbcc50491496a3ed4246998a7fbba7ccb98b1e7eab22" +dependencies = [ + "bitflags 2.11.0", + "objc2", + "objc2-core-foundation", + "objc2-foundation", +] + +[[package]] +name = "objc2-web-kit" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b2e5aaab980c433cf470df9d7af96a7b46a9d892d521a2cbbb2f8a4c16751e7f" +dependencies = [ + "bitflags 2.11.0", + "block2", + "objc2", + "objc2-app-kit", + "objc2-core-foundation", + "objc2-foundation", + "objc2-javascript-core", + "objc2-security", +] + +[[package]] +name = "once_cell" +version = "1.21.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "42f5e15c9953c5e4ccceeb2e7382a716482c34515315f7b03532b8b4e8393d2d" + +[[package]] +name = "open" +version = "5.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "43bb73a7fa3799b198970490a51174027ba0d4ec504b03cd08caf513d40024bc" +dependencies = [ + "dunce", + "is-wsl", + "libc", + "pathdiff", +] + +[[package]] +name = "option-ext" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "04744f49eae99ab78e0d5c0b603ab218f515ea8cfe5a456d7629ad883a3b6e7d" + +[[package]] +name = "ordered-stream" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9aa2b01e1d916879f73a53d01d1d6cee68adbb31d6d9177a8cfce093cced1d50" +dependencies = [ + "futures-core", + "pin-project-lite", +] + +[[package]] +name = "pango" +version = "0.18.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7ca27ec1eb0457ab26f3036ea52229edbdb74dee1edd29063f5b9b010e7ebee4" +dependencies = [ + "gio", + "glib", + "libc", + "once_cell", + "pango-sys", +] + +[[package]] +name = "pango-sys" +version = "0.18.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "436737e391a843e5933d6d9aa102cb126d501e815b83601365a948a518555dc5" +dependencies = [ + "glib-sys", + "gobject-sys", + "libc", + "system-deps", +] + +[[package]] +name = "parking" +version = "2.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f38d5652c16fde515bb1ecef450ab0f6a219d619a7274976324d5e377f7dceba" + +[[package]] +name = "parking_lot" +version = "0.12.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "93857453250e3077bd71ff98b6a65ea6621a19bb0f559a85248955ac12c45a1a" +dependencies = [ + "lock_api", + "parking_lot_core", +] + +[[package]] +name = "parking_lot_core" +version = "0.9.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2621685985a2ebf1c516881c026032ac7deafcda1a2c9b7850dc81e3dfcb64c1" +dependencies = [ + "cfg-if", + "libc", + "redox_syscall", + "smallvec", + "windows-link 0.2.1", +] + +[[package]] +name = "pathdiff" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "df94ce210e5bc13cb6651479fa48d14f601d9858cfe0467f43ae157023b938d3" + +[[package]] +name = "percent-encoding" +version = "2.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b4f627cb1b25917193a259e49bdad08f671f8d9708acfd5fe0a8c1455d87220" + +[[package]] +name = "phf" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3dfb61232e34fcb633f43d12c58f83c1df82962dcdfa565a4e866ffc17dafe12" +dependencies = [ + "phf_shared 0.8.0", +] + +[[package]] +name = "phf" +version = "0.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fabbf1ead8a5bcbc20f5f8b939ee3f5b0f6f281b6ad3468b84656b658b455259" +dependencies = [ + "phf_macros 0.10.0", + "phf_shared 0.10.0", + "proc-macro-hack", +] + +[[package]] +name = "phf" +version = "0.11.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1fd6780a80ae0c52cc120a26a1a42c1ae51b247a253e4e06113d23d2c2edd078" +dependencies = [ + "phf_macros 0.11.3", + "phf_shared 0.11.3", +] + +[[package]] +name = "phf_codegen" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cbffee61585b0411840d3ece935cce9cb6321f01c45477d30066498cd5e1a815" +dependencies = [ + "phf_generator 0.8.0", + "phf_shared 0.8.0", +] + +[[package]] +name = "phf_codegen" +version = "0.11.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aef8048c789fa5e851558d709946d6d79a8ff88c0440c587967f8e94bfb1216a" +dependencies = [ + "phf_generator 0.11.3", + "phf_shared 0.11.3", +] + +[[package]] +name = "phf_generator" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "17367f0cc86f2d25802b2c26ee58a7b23faeccf78a396094c13dced0d0182526" +dependencies = [ + "phf_shared 0.8.0", + "rand 0.7.3", +] + +[[package]] +name = "phf_generator" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5d5285893bb5eb82e6aaf5d59ee909a06a16737a8970984dd7746ba9283498d6" +dependencies = [ + "phf_shared 0.10.0", + "rand 0.8.5", +] + +[[package]] +name = "phf_generator" +version = "0.11.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3c80231409c20246a13fddb31776fb942c38553c51e871f8cbd687a4cfb5843d" +dependencies = [ + "phf_shared 0.11.3", + "rand 0.8.5", +] + +[[package]] +name = "phf_macros" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "58fdf3184dd560f160dd73922bea2d5cd6e8f064bf4b13110abd81b03697b4e0" +dependencies = [ + "phf_generator 0.10.0", + "phf_shared 0.10.0", + "proc-macro-hack", + "proc-macro2", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "phf_macros" +version = "0.11.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f84ac04429c13a7ff43785d75ad27569f2951ce0ffd30a3321230db2fc727216" +dependencies = [ + "phf_generator 0.11.3", + "phf_shared 0.11.3", + "proc-macro2", + "quote", + "syn 2.0.117", +] + +[[package]] +name = "phf_shared" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c00cf8b9eafe68dde5e9eaa2cef8ee84a9336a47d566ec55ca16589633b65af7" +dependencies = [ + "siphasher 0.3.11", +] + +[[package]] +name = "phf_shared" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6796ad771acdc0123d2a88dc428b5e38ef24456743ddb1744ed628f9815c096" +dependencies = [ + "siphasher 0.3.11", +] + +[[package]] +name = "phf_shared" +version = "0.11.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "67eabc2ef2a60eb7faa00097bd1ffdb5bd28e62bf39990626a582201b7a754e5" +dependencies = [ + "siphasher 1.0.2", +] + +[[package]] +name = "pin-project-lite" +version = "0.2.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3b3cff922bd51709b605d9ead9aa71031d81447142d828eb4a6eba76fe619f9b" + +[[package]] +name = "pin-utils" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" + +[[package]] +name = "piper" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "96c8c490f422ef9a4efd2cb5b42b76c8613d7e7dfc1caf667b8a3350a5acc066" +dependencies = [ + "atomic-waker", + "fastrand", + "futures-io", +] + +[[package]] +name = "pkg-config" +version = "0.3.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7edddbd0b52d732b21ad9a5fab5c704c14cd949e5e9a1ec5929a24fded1b904c" + +[[package]] +name = "plist" +version = "1.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "740ebea15c5d1428f910cd1a5f52cebf8d25006245ed8ade92702f4943d91e07" +dependencies = [ + "base64 0.22.1", + "indexmap 2.13.0", + "quick-xml", + "serde", + "time", +] + +[[package]] +name = "png" +version = "0.17.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "82151a2fc869e011c153adc57cf2789ccb8d9906ce52c0b39a6b5697749d7526" +dependencies = [ + "bitflags 1.3.2", + "crc32fast", + "fdeflate", + "flate2", + "miniz_oxide", +] + +[[package]] +name = "polling" +version = "3.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5d0e4f59085d47d8241c88ead0f274e8a0cb551f3625263c05eb8dd897c34218" +dependencies = [ + "cfg-if", + "concurrent-queue", + "hermit-abi", + "pin-project-lite", + "rustix", + "windows-sys 0.61.2", +] + +[[package]] +name = "potential_utf" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b73949432f5e2a09657003c25bca5e19a0e9c84f8058ca374f49e0ebe605af77" +dependencies = [ + "zerovec", +] + +[[package]] +name = "powerfmt" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "439ee305def115ba05938db6eb1644ff94165c5ab5e9420d1c1bcedbba909391" + +[[package]] +name = "ppv-lite86" +version = "0.2.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "85eae3c4ed2f50dcfe72643da4befc30deadb458a9b590d720cde2f2b1e97da9" +dependencies = [ + "zerocopy", +] + +[[package]] +name = "precomputed-hash" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "925383efa346730478fb4838dbe9137d2a47675ad789c546d150a6e1dd4ab31c" + +[[package]] +name = "prettyplease" +version = "0.2.37" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "479ca8adacdd7ce8f1fb39ce9ecccbfe93a3f1344b3d0d97f20bc0196208f62b" +dependencies = [ + "proc-macro2", + "syn 2.0.117", +] + +[[package]] +name = "proc-macro-crate" +version = "1.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f4c021e1093a56626774e81216a4ce732a735e5bad4868a03f3ed65ca0c3919" +dependencies = [ + "once_cell", + "toml_edit 0.19.15", +] + +[[package]] +name = "proc-macro-crate" +version = "2.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b00f26d3400549137f92511a46ac1cd8ce37cb5598a96d382381458b992a5d24" +dependencies = [ + "toml_datetime 0.6.3", + "toml_edit 0.20.2", +] + +[[package]] +name = "proc-macro-crate" +version = "3.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "219cb19e96be00ab2e37d6e299658a0cfa83e52429179969b0f0121b4ac46983" +dependencies = [ + "toml_edit 0.23.10+spec-1.0.0", +] + +[[package]] +name = "proc-macro-error" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "da25490ff9892aab3fcf7c36f08cfb902dd3e71ca0f9f9517bea02a73a5ce38c" +dependencies = [ + "proc-macro-error-attr", + "proc-macro2", + "quote", + "syn 1.0.109", + "version_check", +] + +[[package]] +name = "proc-macro-error-attr" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a1be40180e52ecc98ad80b184934baf3d0d29f979574e439af5a55274b35f869" +dependencies = [ + "proc-macro2", + "quote", + "version_check", +] + +[[package]] +name = "proc-macro-hack" +version = "0.5.20+deprecated" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc375e1527247fe1a97d8b7156678dfe7c1af2fc075c9a4db3690ecd2a148068" + +[[package]] +name = "proc-macro2" +version = "1.0.106" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8fd00f0bb2e90d81d1044c2b32617f68fcb9fa3bb7640c23e9c748e53fb30934" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "quick-xml" +version = "0.38.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b66c2058c55a409d601666cffe35f04333cf1013010882cec174a7467cd4e21c" +dependencies = [ + "memchr", +] + +[[package]] +name = "quote" +version = "1.0.44" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "21b2ebcf727b7760c461f091f9f0f539b77b8e87f2fd88131e7f1b433b3cece4" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "r-efi" +version = "5.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "69cdb34c158ceb288df11e18b4bd39de994f6657d83847bdffdbd7f346754b0f" + +[[package]] +name = "rand" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6a6b1679d49b24bbfe0c803429aa1874472f50d9b363131f0e89fc356b544d03" +dependencies = [ + "getrandom 0.1.16", + "libc", + "rand_chacha 0.2.2", + "rand_core 0.5.1", + "rand_hc", + "rand_pcg", +] + +[[package]] +name = "rand" +version = "0.8.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" +dependencies = [ + "libc", + "rand_chacha 0.3.1", + "rand_core 0.6.4", +] + +[[package]] +name = "rand_chacha" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f4c8ed856279c9737206bf725bf36935d8666ead7aa69b52be55af369d193402" +dependencies = [ + "ppv-lite86", + "rand_core 0.5.1", +] + +[[package]] +name = "rand_chacha" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" +dependencies = [ + "ppv-lite86", + "rand_core 0.6.4", +] + +[[package]] +name = "rand_core" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "90bde5296fc891b0cef12a6d03ddccc162ce7b2aff54160af9338f8d40df6d19" +dependencies = [ + "getrandom 0.1.16", +] + +[[package]] +name = "rand_core" +version = "0.6.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" +dependencies = [ + "getrandom 0.2.17", +] + +[[package]] +name = "rand_hc" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ca3129af7b92a17112d59ad498c6f81eaf463253766b90396d39ea7a39d6613c" +dependencies = [ + "rand_core 0.5.1", +] + +[[package]] +name = "rand_pcg" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "16abd0c1b639e9eb4d7c50c0b8100b0d0f849be2349829c740fe8e6eb4816429" +dependencies = [ + "rand_core 0.5.1", +] + +[[package]] +name = "raw-window-handle" +version = "0.6.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "20675572f6f24e9e76ef639bc5552774ed45f1c30e2951e1e99c59888861c539" + +[[package]] +name = "redox_syscall" +version = "0.5.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ed2bf2547551a7053d6fdfafda3f938979645c44812fbfcda098faae3f1a362d" +dependencies = [ + "bitflags 2.11.0", +] + +[[package]] +name = "redox_users" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a4e608c6638b9c18977b00b475ac1f28d14e84b27d8d42f70e0bf1e3dec127ac" +dependencies = [ + "getrandom 0.2.17", + "libredox", + "thiserror 2.0.18", +] + +[[package]] +name = "ref-cast" +version = "1.0.25" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f354300ae66f76f1c85c5f84693f0ce81d747e2c3f21a45fef496d89c960bf7d" +dependencies = [ + "ref-cast-impl", +] + +[[package]] +name = "ref-cast-impl" +version = "1.0.25" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b7186006dcb21920990093f30e3dea63b7d6e977bf1256be20c3563a5db070da" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.117", +] + +[[package]] +name = "regex" +version = "1.12.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e10754a14b9137dd7b1e3e5b0493cc9171fdd105e0ab477f51b72e7f3ac0e276" +dependencies = [ + "aho-corasick", + "memchr", + "regex-automata", + "regex-syntax", +] + +[[package]] +name = "regex-automata" +version = "0.4.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6e1dd4122fc1595e8162618945476892eefca7b88c52820e74af6262213cae8f" +dependencies = [ + "aho-corasick", + "memchr", + "regex-syntax", +] + +[[package]] +name = "regex-syntax" +version = "0.8.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc897dd8d9e8bd1ed8cdad82b5966c3e0ecae09fb1907d58efaa013543185d0a" + +[[package]] +name = "reqwest" +version = "0.13.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ab3f43e3283ab1488b624b44b0e988d0acea0b3214e694730a055cb6b2efa801" +dependencies = [ + "base64 0.22.1", + "bytes", + "futures-core", + "futures-util", + "http", + "http-body", + "http-body-util", + "hyper", + "hyper-util", + "js-sys", + "log", + "percent-encoding", + "pin-project-lite", + "serde", + "serde_json", + "sync_wrapper", + "tokio", + "tokio-util", + "tower", + "tower-http", + "tower-service", + "url", + "wasm-bindgen", + "wasm-bindgen-futures", + "wasm-streams", + "web-sys", +] + +[[package]] +name = "rfd" +version = "0.16.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a15ad77d9e70a92437d8f74c35d99b4e4691128df018833e99f90bcd36152672" +dependencies = [ + "block2", + "dispatch2", + "glib-sys", + "gobject-sys", + "gtk-sys", + "js-sys", + "log", + "objc2", + "objc2-app-kit", + "objc2-core-foundation", + "objc2-foundation", + "raw-window-handle", + "wasm-bindgen", + "wasm-bindgen-futures", + "web-sys", + "windows-sys 0.60.2", +] + +[[package]] +name = "rustc_version" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cfcb3a22ef46e85b45de6ee7e79d063319ebb6594faafcf1c225ea92ab6e9b92" +dependencies = [ + "semver", +] + +[[package]] +name = "rustix" +version = "1.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6fe4565b9518b83ef4f91bb47ce29620ca828bd32cb7e408f0062e9930ba190" +dependencies = [ + "bitflags 2.11.0", + "errno", + "libc", + "linux-raw-sys", + "windows-sys 0.61.2", +] + +[[package]] +name = "rustversion" +version = "1.0.22" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b39cdef0fa800fc44525c84ccb54a029961a8215f9619753635a9c0d2538d46d" + +[[package]] +name = "same-file" +version = "1.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "93fc1dc3aaa9bfed95e02e6eadabb4baf7e3078b0bd1b4d7b6b0b68378900502" +dependencies = [ + "winapi-util", +] + +[[package]] +name = "schemars" +version = "0.8.22" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3fbf2ae1b8bc8e02df939598064d22402220cd5bbcca1c76f7d6a310974d5615" +dependencies = [ + "dyn-clone", + "indexmap 1.9.3", + "schemars_derive", + "serde", + "serde_json", + "url", + "uuid", +] + +[[package]] +name = "schemars" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4cd191f9397d57d581cddd31014772520aa448f65ef991055d7f61582c65165f" +dependencies = [ + "dyn-clone", + "ref-cast", + "serde", + "serde_json", +] + +[[package]] +name = "schemars" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a2b42f36aa1cd011945615b92222f6bf73c599a102a300334cd7f8dbeec726cc" +dependencies = [ + "dyn-clone", + "ref-cast", + "serde", + "serde_json", +] + +[[package]] +name = "schemars_derive" +version = "0.8.22" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "32e265784ad618884abaea0600a9adf15393368d840e0222d101a072f3f7534d" +dependencies = [ + "proc-macro2", + "quote", + "serde_derive_internals", + "syn 2.0.117", +] + +[[package]] +name = "scopeguard" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" + +[[package]] +name = "selectors" +version = "0.24.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0c37578180969d00692904465fb7f6b3d50b9a2b952b87c23d0e2e5cb5013416" +dependencies = [ + "bitflags 1.3.2", + "cssparser", + "derive_more", + "fxhash", + "log", + "phf 0.8.0", + "phf_codegen 0.8.0", + "precomputed-hash", + "servo_arc", + "smallvec", +] + +[[package]] +name = "semver" +version = "1.0.27" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d767eb0aabc880b29956c35734170f26ed551a859dbd361d140cdbeca61ab1e2" +dependencies = [ + "serde", + "serde_core", +] + +[[package]] +name = "serde" +version = "1.0.228" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9a8e94ea7f378bd32cbbd37198a4a91436180c5bb472411e48b5ec2e2124ae9e" +dependencies = [ + "serde_core", + "serde_derive", +] + +[[package]] +name = "serde-untagged" +version = "0.1.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f9faf48a4a2d2693be24c6289dbe26552776eb7737074e6722891fadbe6c5058" +dependencies = [ + "erased-serde", + "serde", + "serde_core", + "typeid", +] + +[[package]] +name = "serde_core" +version = "1.0.228" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "41d385c7d4ca58e59fc732af25c3983b67ac852c1a25000afe1175de458b67ad" +dependencies = [ + "serde_derive", +] + +[[package]] +name = "serde_derive" +version = "1.0.228" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d540f220d3187173da220f885ab66608367b6574e925011a9353e4badda91d79" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.117", +] + +[[package]] +name = "serde_derive_internals" +version = "0.29.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "18d26a20a969b9e3fdf2fc2d9f21eda6c40e2de84c9408bb5d3b05d499aae711" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.117", +] + +[[package]] +name = "serde_json" +version = "1.0.149" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "83fc039473c5595ace860d8c4fafa220ff474b3fc6bfdb4293327f1a37e94d86" +dependencies = [ + "itoa", + "memchr", + "serde", + "serde_core", + "zmij", +] + +[[package]] +name = "serde_repr" +version = "0.1.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "175ee3e80ae9982737ca543e96133087cbd9a485eecc3bc4de9c1a37b47ea59c" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.117", +] + +[[package]] +name = "serde_spanned" +version = "0.6.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bf41e0cfaf7226dca15e8197172c295a782857fcb97fad1808a166870dee75a3" +dependencies = [ + "serde", +] + +[[package]] +name = "serde_spanned" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f8bbf91e5a4d6315eee45e704372590b30e260ee83af6639d64557f51b067776" +dependencies = [ + "serde_core", +] + +[[package]] +name = "serde_with" +version = "3.17.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "381b283ce7bc6b476d903296fb59d0d36633652b633b27f64db4fb46dcbfc3b9" +dependencies = [ + "base64 0.22.1", + "chrono", + "hex", + "indexmap 1.9.3", + "indexmap 2.13.0", + "schemars 0.9.0", + "schemars 1.2.1", + "serde_core", + "serde_json", + "serde_with_macros", + "time", +] + +[[package]] +name = "serde_with_macros" +version = "3.17.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a6d4e30573c8cb306ed6ab1dca8423eec9a463ea0e155f45399455e0368b27e0" +dependencies = [ + "darling", + "proc-macro2", + "quote", + "syn 2.0.117", +] + +[[package]] +name = "serialize-to-javascript" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "04f3666a07a197cdb77cdf306c32be9b7f598d7060d50cfd4d5aa04bfd92f6c5" +dependencies = [ + "serde", + "serde_json", + "serialize-to-javascript-impl", +] + +[[package]] +name = "serialize-to-javascript-impl" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "772ee033c0916d670af7860b6e1ef7d658a4629a6d0b4c8c3e67f09b3765b75d" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.117", +] + +[[package]] +name = "servo_arc" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d52aa42f8fdf0fed91e5ce7f23d8138441002fa31dca008acf47e6fd4721f741" +dependencies = [ + "nodrop", + "stable_deref_trait", +] + +[[package]] +name = "sha2" +version = "0.10.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a7507d819769d01a365ab707794a4084392c824f54a7a6a7862f8c3d0892b283" +dependencies = [ + "cfg-if", + "cpufeatures", + "digest", +] + +[[package]] +name = "shlex" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64" + +[[package]] +name = "signal-hook-registry" +version = "1.4.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c4db69cba1110affc0e9f7bcd48bbf87b3f4fc7c61fc9155afd4c469eb3d6c1b" +dependencies = [ + "errno", + "libc", +] + +[[package]] +name = "simd-adler32" +version = "0.3.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e320a6c5ad31d271ad523dcf3ad13e2767ad8b1cb8f047f75a8aeaf8da139da2" + +[[package]] +name = "siphasher" +version = "0.3.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "38b58827f4464d87d377d175e90bf58eb00fd8716ff0a62f80356b5e61555d0d" + +[[package]] +name = "siphasher" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b2aa850e253778c88a04c3d7323b043aeda9d3e30d5971937c1855769763678e" + +[[package]] +name = "slab" +version = "0.4.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0c790de23124f9ab44544d7ac05d60440adc586479ce501c1d6d7da3cd8c9cf5" + +[[package]] +name = "smallvec" +version = "1.15.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "67b1b7a3b5fe4f1376887184045fcf45c69e92af734b7aaddc05fb777b6fbd03" + +[[package]] +name = "socket2" +version = "0.6.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "86f4aa3ad99f2088c990dfa82d367e19cb29268ed67c574d10d0a4bfe71f07e0" +dependencies = [ + "libc", + "windows-sys 0.60.2", +] + +[[package]] +name = "softbuffer" +version = "0.4.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aac18da81ebbf05109ab275b157c22a653bb3c12cf884450179942f81bcbf6c3" +dependencies = [ + "bytemuck", + "js-sys", + "ndk", + "objc2", + "objc2-core-foundation", + "objc2-core-graphics", + "objc2-foundation", + "objc2-quartz-core", + "raw-window-handle", + "redox_syscall", + "tracing", + "wasm-bindgen", + "web-sys", + "windows-sys 0.61.2", +] + +[[package]] +name = "soup3" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "471f924a40f31251afc77450e781cb26d55c0b650842efafc9c6cbd2f7cc4f9f" +dependencies = [ + "futures-channel", + "gio", + "glib", + "libc", + "soup3-sys", +] + +[[package]] +name = "soup3-sys" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7ebe8950a680a12f24f15ebe1bf70db7af98ad242d9db43596ad3108aab86c27" +dependencies = [ + "gio-sys", + "glib-sys", + "gobject-sys", + "libc", + "system-deps", +] + +[[package]] +name = "stable_deref_trait" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6ce2be8dc25455e1f91df71bfa12ad37d7af1092ae736f3a6cd0e37bc7810596" + +[[package]] +name = "string_cache" +version = "0.8.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bf776ba3fa74f83bf4b63c3dcbbf82173db2632ed8452cb2d891d33f459de70f" +dependencies = [ + "new_debug_unreachable", + "parking_lot", + "phf_shared 0.11.3", + "precomputed-hash", + "serde", +] + +[[package]] +name = "string_cache_codegen" +version = "0.5.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c711928715f1fe0fe509c53b43e993a9a557babc2d0a3567d0a3006f1ac931a0" +dependencies = [ + "phf_generator 0.11.3", + "phf_shared 0.11.3", + "proc-macro2", + "quote", +] + +[[package]] +name = "strsim" +version = "0.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f" + +[[package]] +name = "swift-rs" +version = "1.0.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4057c98e2e852d51fdcfca832aac7b571f6b351ad159f9eda5db1655f8d0c4d7" +dependencies = [ + "base64 0.21.7", + "serde", + "serde_json", +] + +[[package]] +name = "syn" +version = "1.0.109" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "syn" +version = "2.0.117" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e665b8803e7b1d2a727f4023456bbbbe74da67099c585258af0ad9c5013b9b99" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "sync_wrapper" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0bf256ce5efdfa370213c1dabab5935a12e49f2c58d15e9eac2870d3b4f27263" +dependencies = [ + "futures-core", +] + +[[package]] +name = "synstructure" +version = "0.13.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "728a70f3dbaf5bab7f0c4b1ac8d7ae5ea60a4b5549c8a5914361c99147a709d2" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.117", +] + +[[package]] +name = "system-deps" +version = "6.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a3e535eb8dded36d55ec13eddacd30dec501792ff23a0b1682c38601b8cf2349" +dependencies = [ + "cfg-expr", + "heck 0.5.0", + "pkg-config", + "toml 0.8.2", + "version-compare", +] + +[[package]] +name = "tao" +version = "0.34.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f3a753bdc39c07b192151523a3f77cd0394aa75413802c883a0f6f6a0e5ee2e7" +dependencies = [ + "bitflags 2.11.0", + "block2", + "core-foundation", + "core-graphics", + "crossbeam-channel", + "dispatch", + "dlopen2", + "dpi", + "gdkwayland-sys", + "gdkx11-sys", + "gtk", + "jni", + "lazy_static", + "libc", + "log", + "ndk", + "ndk-context", + "ndk-sys", + "objc2", + "objc2-app-kit", + "objc2-foundation", + "once_cell", + "parking_lot", + "raw-window-handle", + "scopeguard", + "tao-macros", + "unicode-segmentation", + "url", + "windows", + "windows-core 0.61.2", + "windows-version", + "x11-dl", +] + +[[package]] +name = "tao-macros" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f4e16beb8b2ac17db28eab8bca40e62dbfbb34c0fcdc6d9826b11b7b5d047dfd" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.117", +] + +[[package]] +name = "target-lexicon" +version = "0.12.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "61c41af27dd6d1e27b1b16b489db798443478cef1f06a660c96db617ba5de3b1" + +[[package]] +name = "tauri" +version = "2.10.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "463ae8677aa6d0f063a900b9c41ecd4ac2b7ca82f0b058cc4491540e55b20129" +dependencies = [ + "anyhow", + "bytes", + "cookie", + "dirs", + "dunce", + "embed_plist", + "getrandom 0.3.4", + "glob", + "gtk", + "heck 0.5.0", + "http", + "jni", + "libc", + "log", + "mime", + "muda", + "objc2", + "objc2-app-kit", + "objc2-foundation", + "objc2-ui-kit", + "objc2-web-kit", + "percent-encoding", + "plist", + "raw-window-handle", + "reqwest", + "serde", + "serde_json", + "serde_repr", + "serialize-to-javascript", + "swift-rs", + "tauri-build", + "tauri-macros", + "tauri-runtime", + "tauri-runtime-wry", + "tauri-utils", + "thiserror 2.0.18", + "tokio", + "tray-icon", + "url", + "webkit2gtk", + "webview2-com", + "window-vibrancy", + "windows", +] + +[[package]] +name = "tauri-build" +version = "2.5.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ca7bd893329425df750813e95bd2b643d5369d929438da96d5bbb7cc2c918f74" +dependencies = [ + "anyhow", + "cargo_toml", + "dirs", + "glob", + "heck 0.5.0", + "json-patch", + "schemars 0.8.22", + "semver", + "serde", + "serde_json", + "tauri-utils", + "tauri-winres", + "toml 0.9.12+spec-1.1.0", + "walkdir", +] + +[[package]] +name = "tauri-codegen" +version = "2.5.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aac423e5859d9f9ccdd32e3cf6a5866a15bedbf25aa6630bcb2acde9468f6ae3" +dependencies = [ + "base64 0.22.1", + "brotli", + "ico", + "json-patch", + "plist", + "png", + "proc-macro2", + "quote", + "semver", + "serde", + "serde_json", + "sha2", + "syn 2.0.117", + "tauri-utils", + "thiserror 2.0.18", + "time", + "url", + "uuid", + "walkdir", +] + +[[package]] +name = "tauri-macros" +version = "2.5.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1b6a1bd2861ff0c8766b1d38b32a6a410f6dc6532d4ef534c47cfb2236092f59" +dependencies = [ + "heck 0.5.0", + "proc-macro2", + "quote", + "syn 2.0.117", + "tauri-codegen", + "tauri-utils", +] + +[[package]] +name = "tauri-plugin" +version = "2.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "692a77abd8b8773e107a42ec0e05b767b8d2b7ece76ab36c6c3947e34df9f53f" +dependencies = [ + "anyhow", + "glob", + "plist", + "schemars 0.8.22", + "serde", + "serde_json", + "tauri-utils", + "toml 0.9.12+spec-1.1.0", + "walkdir", +] + +[[package]] +name = "tauri-plugin-dialog" +version = "2.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9204b425d9be8d12aa60c2a83a289cf7d1caae40f57f336ed1155b3a5c0e359b" +dependencies = [ + "log", + "raw-window-handle", + "rfd", + "serde", + "serde_json", + "tauri", + "tauri-plugin", + "tauri-plugin-fs", + "thiserror 2.0.18", + "url", +] + +[[package]] +name = "tauri-plugin-fs" +version = "2.4.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ed390cc669f937afeb8b28032ce837bac8ea023d975a2e207375ec05afaf1804" +dependencies = [ + "anyhow", + "dunce", + "glob", + "percent-encoding", + "schemars 0.8.22", + "serde", + "serde_json", + "serde_repr", + "tauri", + "tauri-plugin", + "tauri-utils", + "thiserror 2.0.18", + "toml 0.9.12+spec-1.1.0", + "url", +] + +[[package]] +name = "tauri-plugin-opener" +version = "2.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fc624469b06f59f5a29f874bbc61a2ed737c0f9c23ef09855a292c389c42e83f" +dependencies = [ + "dunce", + "glob", + "objc2-app-kit", + "objc2-foundation", + "open", + "schemars 0.8.22", + "serde", + "serde_json", + "tauri", + "tauri-plugin", + "thiserror 2.0.18", + "url", + "windows", + "zbus", +] + +[[package]] +name = "tauri-runtime" +version = "2.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b885ffeac82b00f1f6fd292b6e5aabfa7435d537cef57d11e38a489956535651" +dependencies = [ + "cookie", + "dpi", + "gtk", + "http", + "jni", + "objc2", + "objc2-ui-kit", + "objc2-web-kit", + "raw-window-handle", + "serde", + "serde_json", + "tauri-utils", + "thiserror 2.0.18", + "url", + "webkit2gtk", + "webview2-com", + "windows", +] + +[[package]] +name = "tauri-runtime-wry" +version = "2.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5204682391625e867d16584fedc83fc292fb998814c9f7918605c789cd876314" +dependencies = [ + "gtk", + "http", + "jni", + "log", + "objc2", + "objc2-app-kit", + "objc2-foundation", + "once_cell", + "percent-encoding", + "raw-window-handle", + "softbuffer", + "tao", + "tauri-runtime", + "tauri-utils", + "url", + "webkit2gtk", + "webview2-com", + "windows", + "wry", +] + +[[package]] +name = "tauri-utils" +version = "2.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fcd169fccdff05eff2c1033210b9b94acd07a47e6fa9a3431cf09cfd4f01c87e" +dependencies = [ + "anyhow", + "brotli", + "cargo_metadata", + "ctor", + "dunce", + "glob", + "html5ever", + "http", + "infer", + "json-patch", + "kuchikiki", + "log", + "memchr", + "phf 0.11.3", + "proc-macro2", + "quote", + "regex", + "schemars 0.8.22", + "semver", + "serde", + "serde-untagged", + "serde_json", + "serde_with", + "swift-rs", + "thiserror 2.0.18", + "toml 0.9.12+spec-1.1.0", + "url", + "urlpattern", + "uuid", + "walkdir", +] + +[[package]] +name = "tauri-winres" +version = "0.3.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1087b111fe2b005e42dbdc1990fc18593234238d47453b0c99b7de1c9ab2c1e0" +dependencies = [ + "dunce", + "embed-resource", + "toml 0.9.12+spec-1.1.0", +] + +[[package]] +name = "tempfile" +version = "3.26.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "82a72c767771b47409d2345987fda8628641887d5466101319899796367354a0" +dependencies = [ + "fastrand", + "getrandom 0.4.1", + "once_cell", + "rustix", + "windows-sys 0.61.2", +] + +[[package]] +name = "tendril" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d24a120c5fc464a3458240ee02c299ebcb9d67b5249c8848b09d639dca8d7bb0" +dependencies = [ + "futf", + "mac", + "utf-8", +] + +[[package]] +name = "thiserror" +version = "1.0.69" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6aaf5339b578ea85b50e080feb250a3e8ae8cfcdff9a461c9ec2904bc923f52" +dependencies = [ + "thiserror-impl 1.0.69", +] + +[[package]] +name = "thiserror" +version = "2.0.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4288b5bcbc7920c07a1149a35cf9590a2aa808e0bc1eafaade0b80947865fbc4" +dependencies = [ + "thiserror-impl 2.0.18", +] + +[[package]] +name = "thiserror-impl" +version = "1.0.69" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4fee6c4efc90059e10f81e6d42c60a18f76588c3d74cb83a0b242a2b6c7504c1" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.117", +] + +[[package]] +name = "thiserror-impl" +version = "2.0.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ebc4ee7f67670e9b64d05fa4253e753e016c6c95ff35b89b7941d6b856dec1d5" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.117", +] + +[[package]] +name = "time" +version = "0.3.47" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "743bd48c283afc0388f9b8827b976905fb217ad9e647fae3a379a9283c4def2c" +dependencies = [ + "deranged", + "itoa", + "num-conv", + "powerfmt", + "serde_core", + "time-core", + "time-macros", +] + +[[package]] +name = "time-core" +version = "0.1.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7694e1cfe791f8d31026952abf09c69ca6f6fa4e1a1229e18988f06a04a12dca" + +[[package]] +name = "time-macros" +version = "0.2.27" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2e70e4c5a0e0a8a4823ad65dfe1a6930e4f4d756dcd9dd7939022b5e8c501215" +dependencies = [ + "num-conv", + "time-core", +] + +[[package]] +name = "tinystr" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "42d3e9c45c09de15d06dd8acf5f4e0e399e85927b7f00711024eb7ae10fa4869" +dependencies = [ + "displaydoc", + "zerovec", +] + +[[package]] +name = "tokio" +version = "1.49.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72a2903cd7736441aac9df9d7688bd0ce48edccaadf181c3b90be801e81d3d86" +dependencies = [ + "bytes", + "libc", + "mio", + "pin-project-lite", + "signal-hook-registry", + "socket2", + "windows-sys 0.61.2", +] + +[[package]] +name = "tokio-util" +version = "0.7.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9ae9cec805b01e8fc3fd2fe289f89149a9b66dd16786abd8b19cfa7b48cb0098" +dependencies = [ + "bytes", + "futures-core", + "futures-sink", + "pin-project-lite", + "tokio", +] + +[[package]] +name = "toml" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "185d8ab0dfbb35cf1399a6344d8484209c088f75f8f68230da55d48d95d43e3d" +dependencies = [ + "serde", + "serde_spanned 0.6.9", + "toml_datetime 0.6.3", + "toml_edit 0.20.2", +] + +[[package]] +name = "toml" +version = "0.9.12+spec-1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cf92845e79fc2e2def6a5d828f0801e29a2f8acc037becc5ab08595c7d5e9863" +dependencies = [ + "indexmap 2.13.0", + "serde_core", + "serde_spanned 1.0.4", + "toml_datetime 0.7.5+spec-1.1.0", + "toml_parser", + "toml_writer", + "winnow 0.7.14", +] + +[[package]] +name = "toml_datetime" +version = "0.6.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7cda73e2f1397b1262d6dfdcef8aafae14d1de7748d66822d3bfeeb6d03e5e4b" +dependencies = [ + "serde", +] + +[[package]] +name = "toml_datetime" +version = "0.7.5+spec-1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "92e1cfed4a3038bc5a127e35a2d360f145e1f4b971b551a2ba5fd7aedf7e1347" +dependencies = [ + "serde_core", +] + +[[package]] +name = "toml_edit" +version = "0.19.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1b5bb770da30e5cbfde35a2d7b9b8a2c4b8ef89548a7a6aeab5c9a576e3e7421" +dependencies = [ + "indexmap 2.13.0", + "toml_datetime 0.6.3", + "winnow 0.5.40", +] + +[[package]] +name = "toml_edit" +version = "0.20.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "396e4d48bbb2b7554c944bde63101b5ae446cff6ec4a24227428f15eb72ef338" +dependencies = [ + "indexmap 2.13.0", + "serde", + "serde_spanned 0.6.9", + "toml_datetime 0.6.3", + "winnow 0.5.40", +] + +[[package]] +name = "toml_edit" +version = "0.23.10+spec-1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "84c8b9f757e028cee9fa244aea147aab2a9ec09d5325a9b01e0a49730c2b5269" +dependencies = [ + "indexmap 2.13.0", + "toml_datetime 0.7.5+spec-1.1.0", + "toml_parser", + "winnow 0.7.14", +] + +[[package]] +name = "toml_parser" +version = "1.0.9+spec-1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "702d4415e08923e7e1ef96cd5727c0dfed80b4d2fa25db9647fe5eb6f7c5a4c4" +dependencies = [ + "winnow 0.7.14", +] + +[[package]] +name = "toml_writer" +version = "1.0.6+spec-1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ab16f14aed21ee8bfd8ec22513f7287cd4a91aa92e44edfe2c17ddd004e92607" + +[[package]] +name = "tower" +version = "0.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ebe5ef63511595f1344e2d5cfa636d973292adc0eec1f0ad45fae9f0851ab1d4" +dependencies = [ + "futures-core", + "futures-util", + "pin-project-lite", + "sync_wrapper", + "tokio", + "tower-layer", + "tower-service", +] + +[[package]] +name = "tower-http" +version = "0.6.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d4e6559d53cc268e5031cd8429d05415bc4cb4aefc4aa5d6cc35fbf5b924a1f8" +dependencies = [ + "bitflags 2.11.0", + "bytes", + "futures-util", + "http", + "http-body", + "iri-string", + "pin-project-lite", + "tower", + "tower-layer", + "tower-service", +] + +[[package]] +name = "tower-layer" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "121c2a6cda46980bb0fcd1647ffaf6cd3fc79a013de288782836f6df9c48780e" + +[[package]] +name = "tower-service" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8df9b6e13f2d32c91b9bd719c00d1958837bc7dec474d94952798cc8e69eeec3" + +[[package]] +name = "tracing" +version = "0.1.44" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "63e71662fa4b2a2c3a26f570f037eb95bb1f85397f3cd8076caed2f026a6d100" +dependencies = [ + "pin-project-lite", + "tracing-attributes", + "tracing-core", +] + +[[package]] +name = "tracing-attributes" +version = "0.1.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7490cfa5ec963746568740651ac6781f701c9c5ea257c58e057f3ba8cf69e8da" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.117", +] + +[[package]] +name = "tracing-core" +version = "0.1.36" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "db97caf9d906fbde555dd62fa95ddba9eecfd14cb388e4f491a66d74cd5fb79a" +dependencies = [ + "once_cell", +] + +[[package]] +name = "tray-icon" +version = "0.21.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a5e85aa143ceb072062fc4d6356c1b520a51d636e7bc8e77ec94be3608e5e80c" +dependencies = [ + "crossbeam-channel", + "dirs", + "libappindicator", + "muda", + "objc2", + "objc2-app-kit", + "objc2-core-foundation", + "objc2-core-graphics", + "objc2-foundation", + "once_cell", + "png", + "serde", + "thiserror 2.0.18", + "windows-sys 0.60.2", +] + +[[package]] +name = "try-lock" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e421abadd41a4225275504ea4d6566923418b7f05506fbc9c0fe86ba7396114b" + +[[package]] +name = "typeid" +version = "1.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bc7d623258602320d5c55d1bc22793b57daff0ec7efc270ea7d55ce1d5f5471c" + +[[package]] +name = "typenum" +version = "1.19.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "562d481066bde0658276a35467c4af00bdc6ee726305698a55b86e61d7ad82bb" + +[[package]] +name = "uds_windows" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "89daebc3e6fd160ac4aa9fc8b3bf71e1f74fbf92367ae71fb83a037e8bf164b9" +dependencies = [ + "memoffset", + "tempfile", + "winapi", +] + +[[package]] +name = "unic-char-property" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a8c57a407d9b6fa02b4795eb81c5b6652060a15a7903ea981f3d723e6c0be221" +dependencies = [ + "unic-char-range", +] + +[[package]] +name = "unic-char-range" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0398022d5f700414f6b899e10b8348231abf9173fa93144cbc1a43b9793c1fbc" + +[[package]] +name = "unic-common" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "80d7ff825a6a654ee85a63e80f92f054f904f21e7d12da4e22f9834a4aaa35bc" + +[[package]] +name = "unic-ucd-ident" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e230a37c0381caa9219d67cf063aa3a375ffed5bf541a452db16e744bdab6987" +dependencies = [ + "unic-char-property", + "unic-char-range", + "unic-ucd-version", +] + +[[package]] +name = "unic-ucd-version" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "96bd2f2237fe450fcd0a1d2f5f4e91711124f7857ba2e964247776ebeeb7b0c4" +dependencies = [ + "unic-common", +] + +[[package]] +name = "unicode-ident" +version = "1.0.24" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6e4313cd5fcd3dad5cafa179702e2b244f760991f45397d14d4ebf38247da75" + +[[package]] +name = "unicode-segmentation" +version = "1.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f6ccf251212114b54433ec949fd6a7841275f9ada20dddd2f29e9ceea4501493" + +[[package]] +name = "unicode-xid" +version = "0.2.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ebc1c04c71510c7f702b52b7c350734c9ff1295c464a03335b00bb84fc54f853" + +[[package]] +name = "url" +version = "2.5.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ff67a8a4397373c3ef660812acab3268222035010ab8680ec4215f38ba3d0eed" +dependencies = [ + "form_urlencoded", + "idna", + "percent-encoding", + "serde", + "serde_derive", +] + +[[package]] +name = "urlpattern" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "70acd30e3aa1450bc2eece896ce2ad0d178e9c079493819301573dae3c37ba6d" +dependencies = [ + "regex", + "serde", + "unic-ucd-ident", + "url", +] + +[[package]] +name = "utf-8" +version = "0.7.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09cc8ee72d2a9becf2f2febe0205bbed8fc6615b7cb429ad062dc7b7ddd036a9" + +[[package]] +name = "utf8_iter" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6c140620e7ffbb22c2dee59cafe6084a59b5ffc27a8859a5f0d494b5d52b6be" + +[[package]] +name = "uuid" +version = "1.21.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b672338555252d43fd2240c714dc444b8c6fb0a5c5335e65a07bba7742735ddb" +dependencies = [ + "getrandom 0.4.1", + "js-sys", + "serde_core", + "wasm-bindgen", +] + +[[package]] +name = "version-compare" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "03c2856837ef78f57382f06b2b8563a2f512f7185d732608fd9176cb3b8edf0e" + +[[package]] +name = "version_check" +version = "0.9.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a" + +[[package]] +name = "vswhom" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "be979b7f07507105799e854203b470ff7c78a1639e330a58f183b5fea574608b" +dependencies = [ + "libc", + "vswhom-sys", +] + +[[package]] +name = "vswhom-sys" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fb067e4cbd1ff067d1df46c9194b5de0e98efd2810bbc95c5d5e5f25a3231150" +dependencies = [ + "cc", + "libc", +] + +[[package]] +name = "walkdir" +version = "2.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "29790946404f91d9c5d06f9874efddea1dc06c5efe94541a7d6863108e3a5e4b" +dependencies = [ + "same-file", + "winapi-util", +] + +[[package]] +name = "want" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bfa7760aed19e106de2c7c0b581b509f2f25d3dacaf737cb82ac61bc6d760b0e" +dependencies = [ + "try-lock", +] + +[[package]] +name = "wasi" +version = "0.9.0+wasi-snapshot-preview1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cccddf32554fecc6acb585f82a32a72e28b48f8c4c1883ddfeeeaa96f7d8e519" + +[[package]] +name = "wasi" +version = "0.11.1+wasi-snapshot-preview1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ccf3ec651a847eb01de73ccad15eb7d99f80485de043efb2f370cd654f4ea44b" + +[[package]] +name = "wasip2" +version = "1.0.2+wasi-0.2.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9517f9239f02c069db75e65f174b3da828fe5f5b945c4dd26bd25d89c03ebcf5" +dependencies = [ + "wit-bindgen", +] + +[[package]] +name = "wasip3" +version = "0.4.0+wasi-0.3.0-rc-2026-01-06" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5428f8bf88ea5ddc08faddef2ac4a67e390b88186c703ce6dbd955e1c145aca5" +dependencies = [ + "wit-bindgen", +] + +[[package]] +name = "wasm-bindgen" +version = "0.2.113" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "60722a937f594b7fde9adb894d7c092fc1bb6612897c46368d18e7a20208eff2" +dependencies = [ + "cfg-if", + "once_cell", + "rustversion", + "wasm-bindgen-macro", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-futures" +version = "0.4.63" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8a89f4650b770e4521aa6573724e2aed4704372151bd0de9d16a3bbabb87441a" +dependencies = [ + "cfg-if", + "futures-util", + "js-sys", + "once_cell", + "wasm-bindgen", + "web-sys", +] + +[[package]] +name = "wasm-bindgen-macro" +version = "0.2.113" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0fac8c6395094b6b91c4af293f4c79371c163f9a6f56184d2c9a85f5a95f3950" +dependencies = [ + "quote", + "wasm-bindgen-macro-support", +] + +[[package]] +name = "wasm-bindgen-macro-support" +version = "0.2.113" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ab3fabce6159dc20728033842636887e4877688ae94382766e00b180abac9d60" +dependencies = [ + "bumpalo", + "proc-macro2", + "quote", + "syn 2.0.117", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-shared" +version = "0.2.113" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "de0e091bdb824da87dc01d967388880d017a0a9bc4f3bdc0d86ee9f9336e3bb5" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "wasm-encoder" +version = "0.244.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "990065f2fe63003fe337b932cfb5e3b80e0b4d0f5ff650e6985b1048f62c8319" +dependencies = [ + "leb128fmt", + "wasmparser", +] + +[[package]] +name = "wasm-metadata" +version = "0.244.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bb0e353e6a2fbdc176932bbaab493762eb1255a7900fe0fea1a2f96c296cc909" +dependencies = [ + "anyhow", + "indexmap 2.13.0", + "wasm-encoder", + "wasmparser", +] + +[[package]] +name = "wasm-streams" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9d1ec4f6517c9e11ae630e200b2b65d193279042e28edd4a2cda233e46670bbb" +dependencies = [ + "futures-util", + "js-sys", + "wasm-bindgen", + "wasm-bindgen-futures", + "web-sys", +] + +[[package]] +name = "wasmparser" +version = "0.244.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "47b807c72e1bac69382b3a6fb3dbe8ea4c0ed87ff5629b8685ae6b9a611028fe" +dependencies = [ + "bitflags 2.11.0", + "hashbrown 0.15.5", + "indexmap 2.13.0", + "semver", +] + +[[package]] +name = "web-sys" +version = "0.3.90" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "705eceb4ce901230f8625bd1d665128056ccbe4b7408faa625eec1ba80f59a97" +dependencies = [ + "js-sys", + "wasm-bindgen", +] + +[[package]] +name = "webkit2gtk" +version = "2.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a1027150013530fb2eaf806408df88461ae4815a45c541c8975e61d6f2fc4793" +dependencies = [ + "bitflags 1.3.2", + "cairo-rs", + "gdk", + "gdk-sys", + "gio", + "gio-sys", + "glib", + "glib-sys", + "gobject-sys", + "gtk", + "gtk-sys", + "javascriptcore-rs", + "libc", + "once_cell", + "soup3", + "webkit2gtk-sys", +] + +[[package]] +name = "webkit2gtk-sys" +version = "2.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "916a5f65c2ef0dfe12fff695960a2ec3d4565359fdbb2e9943c974e06c734ea5" +dependencies = [ + "bitflags 1.3.2", + "cairo-sys-rs", + "gdk-sys", + "gio-sys", + "glib-sys", + "gobject-sys", + "gtk-sys", + "javascriptcore-rs-sys", + "libc", + "pkg-config", + "soup3-sys", + "system-deps", +] + +[[package]] +name = "webview2-com" +version = "0.38.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7130243a7a5b33c54a444e54842e6a9e133de08b5ad7b5861cd8ed9a6a5bc96a" +dependencies = [ + "webview2-com-macros", + "webview2-com-sys", + "windows", + "windows-core 0.61.2", + "windows-implement", + "windows-interface", +] + +[[package]] +name = "webview2-com-macros" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "67a921c1b6914c367b2b823cd4cde6f96beec77d30a939c8199bb377cf9b9b54" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.117", +] + +[[package]] +name = "webview2-com-sys" +version = "0.38.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "381336cfffd772377d291702245447a5251a2ffa5bad679c99e61bc48bacbf9c" +dependencies = [ + "thiserror 2.0.18", + "windows", + "windows-core 0.61.2", +] + +[[package]] +name = "winapi" +version = "0.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" +dependencies = [ + "winapi-i686-pc-windows-gnu", + "winapi-x86_64-pc-windows-gnu", +] + +[[package]] +name = "winapi-i686-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" + +[[package]] +name = "winapi-util" +version = "0.1.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c2a7b1c03c876122aa43f3020e6c3c3ee5c05081c9a00739faf7503aeba10d22" +dependencies = [ + "windows-sys 0.61.2", +] + +[[package]] +name = "winapi-x86_64-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" + +[[package]] +name = "window-vibrancy" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d9bec5a31f3f9362f2258fd0e9c9dd61a9ca432e7306cc78c444258f0dce9a9c" +dependencies = [ + "objc2", + "objc2-app-kit", + "objc2-core-foundation", + "objc2-foundation", + "raw-window-handle", + "windows-sys 0.59.0", + "windows-version", +] + +[[package]] +name = "windows" +version = "0.61.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9babd3a767a4c1aef6900409f85f5d53ce2544ccdfaa86dad48c91782c6d6893" +dependencies = [ + "windows-collections", + "windows-core 0.61.2", + "windows-future", + "windows-link 0.1.3", + "windows-numerics", +] + +[[package]] +name = "windows-collections" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3beeceb5e5cfd9eb1d76b381630e82c4241ccd0d27f1a39ed41b2760b255c5e8" +dependencies = [ + "windows-core 0.61.2", +] + +[[package]] +name = "windows-core" +version = "0.61.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c0fdd3ddb90610c7638aa2b3a3ab2904fb9e5cdbecc643ddb3647212781c4ae3" +dependencies = [ + "windows-implement", + "windows-interface", + "windows-link 0.1.3", + "windows-result 0.3.4", + "windows-strings 0.4.2", +] + +[[package]] +name = "windows-core" +version = "0.62.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b8e83a14d34d0623b51dce9581199302a221863196a1dde71a7663a4c2be9deb" +dependencies = [ + "windows-implement", + "windows-interface", + "windows-link 0.2.1", + "windows-result 0.4.1", + "windows-strings 0.5.1", +] + +[[package]] +name = "windows-future" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fc6a41e98427b19fe4b73c550f060b59fa592d7d686537eebf9385621bfbad8e" +dependencies = [ + "windows-core 0.61.2", + "windows-link 0.1.3", + "windows-threading", +] + +[[package]] +name = "windows-implement" +version = "0.60.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "053e2e040ab57b9dc951b72c264860db7eb3b0200ba345b4e4c3b14f67855ddf" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.117", +] + +[[package]] +name = "windows-interface" +version = "0.59.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f316c4a2570ba26bbec722032c4099d8c8bc095efccdc15688708623367e358" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.117", +] + +[[package]] +name = "windows-link" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5e6ad25900d524eaabdbbb96d20b4311e1e7ae1699af4fb28c17ae66c80d798a" + +[[package]] +name = "windows-link" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f0805222e57f7521d6a62e36fa9163bc891acd422f971defe97d64e70d0a4fe5" + +[[package]] +name = "windows-numerics" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9150af68066c4c5c07ddc0ce30421554771e528bde427614c61038bc2c92c2b1" +dependencies = [ + "windows-core 0.61.2", + "windows-link 0.1.3", +] + +[[package]] +name = "windows-result" +version = "0.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "56f42bd332cc6c8eac5af113fc0c1fd6a8fd2aa08a0119358686e5160d0586c6" +dependencies = [ + "windows-link 0.1.3", +] + +[[package]] +name = "windows-result" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7781fa89eaf60850ac3d2da7af8e5242a5ea78d1a11c49bf2910bb5a73853eb5" +dependencies = [ + "windows-link 0.2.1", +] + +[[package]] +name = "windows-strings" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "56e6c93f3a0c3b36176cb1327a4958a0353d5d166c2a35cb268ace15e91d3b57" +dependencies = [ + "windows-link 0.1.3", +] + +[[package]] +name = "windows-strings" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7837d08f69c77cf6b07689544538e017c1bfcf57e34b4c0ff58e6c2cd3b37091" +dependencies = [ + "windows-link 0.2.1", +] + +[[package]] +name = "windows-sys" +version = "0.45.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "75283be5efb2831d37ea142365f009c02ec203cd29a3ebecbc093d52315b66d0" +dependencies = [ + "windows-targets 0.42.2", +] + +[[package]] +name = "windows-sys" +version = "0.59.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e38bc4d79ed67fd075bcc251a1c39b32a1776bbe92e5bef1f0bf1f8c531853b" +dependencies = [ + "windows-targets 0.52.6", +] + +[[package]] +name = "windows-sys" +version = "0.60.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f2f500e4d28234f72040990ec9d39e3a6b950f9f22d3dba18416c35882612bcb" +dependencies = [ + "windows-targets 0.53.5", +] + +[[package]] +name = "windows-sys" +version = "0.61.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ae137229bcbd6cdf0f7b80a31df61766145077ddf49416a728b02cb3921ff3fc" +dependencies = [ + "windows-link 0.2.1", +] + +[[package]] +name = "windows-targets" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e5180c00cd44c9b1c88adb3693291f1cd93605ded80c250a75d472756b4d071" +dependencies = [ + "windows_aarch64_gnullvm 0.42.2", + "windows_aarch64_msvc 0.42.2", + "windows_i686_gnu 0.42.2", + "windows_i686_msvc 0.42.2", + "windows_x86_64_gnu 0.42.2", + "windows_x86_64_gnullvm 0.42.2", + "windows_x86_64_msvc 0.42.2", +] + +[[package]] +name = "windows-targets" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973" +dependencies = [ + "windows_aarch64_gnullvm 0.52.6", + "windows_aarch64_msvc 0.52.6", + "windows_i686_gnu 0.52.6", + "windows_i686_gnullvm 0.52.6", + "windows_i686_msvc 0.52.6", + "windows_x86_64_gnu 0.52.6", + "windows_x86_64_gnullvm 0.52.6", + "windows_x86_64_msvc 0.52.6", +] + +[[package]] +name = "windows-targets" +version = "0.53.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4945f9f551b88e0d65f3db0bc25c33b8acea4d9e41163edf90dcd0b19f9069f3" +dependencies = [ + "windows-link 0.2.1", + "windows_aarch64_gnullvm 0.53.1", + "windows_aarch64_msvc 0.53.1", + "windows_i686_gnu 0.53.1", + "windows_i686_gnullvm 0.53.1", + "windows_i686_msvc 0.53.1", + "windows_x86_64_gnu 0.53.1", + "windows_x86_64_gnullvm 0.53.1", + "windows_x86_64_msvc 0.53.1", +] + +[[package]] +name = "windows-threading" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b66463ad2e0ea3bbf808b7f1d371311c80e115c0b71d60efc142cafbcfb057a6" +dependencies = [ + "windows-link 0.1.3", +] + +[[package]] +name = "windows-version" +version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e4060a1da109b9d0326b7262c8e12c84df67cc0dbc9e33cf49e01ccc2eb63631" +dependencies = [ + "windows-link 0.2.1", +] + +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "597a5118570b68bc08d8d59125332c54f1ba9d9adeedeef5b99b02ba2b0698f8" + +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" + +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.53.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a9d8416fa8b42f5c947f8482c43e7d89e73a173cead56d044f6a56104a6d1b53" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e08e8864a60f06ef0d0ff4ba04124db8b0fb3be5776a5cd47641e942e58c4d43" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.53.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b9d782e804c2f632e395708e99a94275910eb9100b2114651e04744e9b125006" + +[[package]] +name = "windows_i686_gnu" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c61d927d8da41da96a81f029489353e68739737d3beca43145c8afec9a31a84f" + +[[package]] +name = "windows_i686_gnu" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b" + +[[package]] +name = "windows_i686_gnu" +version = "0.53.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "960e6da069d81e09becb0ca57a65220ddff016ff2d6af6a223cf372a506593a3" + +[[package]] +name = "windows_i686_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" + +[[package]] +name = "windows_i686_gnullvm" +version = "0.53.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fa7359d10048f68ab8b09fa71c3daccfb0e9b559aed648a8f95469c27057180c" + +[[package]] +name = "windows_i686_msvc" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "44d840b6ec649f480a41c8d80f9c65108b92d89345dd94027bfe06ac444d1060" + +[[package]] +name = "windows_i686_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" + +[[package]] +name = "windows_i686_msvc" +version = "0.53.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e7ac75179f18232fe9c285163565a57ef8d3c89254a30685b57d83a38d326c2" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8de912b8b8feb55c064867cf047dda097f92d51efad5b491dfb98f6bbb70cb36" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.53.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c3842cdd74a865a8066ab39c8a7a473c0778a3f29370b5fd6b4b9aa7df4a499" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "26d41b46a36d453748aedef1486d5c7a85db22e56aff34643984ea85514e94a3" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.53.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0ffa179e2d07eee8ad8f57493436566c7cc30ac536a3379fdf008f47f6bb7ae1" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9aec5da331524158c6d1a4ac0ab1541149c0b9505fde06423b02f5ef0106b9f0" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.53.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d6bbff5f0aada427a1e5a6da5f1f98158182f26556f345ac9e04d36d0ebed650" + +[[package]] +name = "winnow" +version = "0.5.40" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f593a95398737aeed53e489c785df13f3618e41dbcd6718c6addbf1395aa6876" +dependencies = [ + "memchr", +] + +[[package]] +name = "winnow" +version = "0.7.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5a5364e9d77fcdeeaa6062ced926ee3381faa2ee02d3eb83a5c27a8825540829" +dependencies = [ + "memchr", +] + +[[package]] +name = "winreg" +version = "0.55.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cb5a765337c50e9ec252c2069be9bf91c7df47afb103b642ba3a53bf8101be97" +dependencies = [ + "cfg-if", + "windows-sys 0.59.0", +] + +[[package]] +name = "wit-bindgen" +version = "0.51.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d7249219f66ced02969388cf2bb044a09756a083d0fab1e566056b04d9fbcaa5" +dependencies = [ + "wit-bindgen-rust-macro", +] + +[[package]] +name = "wit-bindgen-core" +version = "0.51.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ea61de684c3ea68cb082b7a88508a8b27fcc8b797d738bfc99a82facf1d752dc" +dependencies = [ + "anyhow", + "heck 0.5.0", + "wit-parser", +] + +[[package]] +name = "wit-bindgen-rust" +version = "0.51.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b7c566e0f4b284dd6561c786d9cb0142da491f46a9fbed79ea69cdad5db17f21" +dependencies = [ + "anyhow", + "heck 0.5.0", + "indexmap 2.13.0", + "prettyplease", + "syn 2.0.117", + "wasm-metadata", + "wit-bindgen-core", + "wit-component", +] + +[[package]] +name = "wit-bindgen-rust-macro" +version = "0.51.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0c0f9bfd77e6a48eccf51359e3ae77140a7f50b1e2ebfe62422d8afdaffab17a" +dependencies = [ + "anyhow", + "prettyplease", + "proc-macro2", + "quote", + "syn 2.0.117", + "wit-bindgen-core", + "wit-bindgen-rust", +] + +[[package]] +name = "wit-component" +version = "0.244.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9d66ea20e9553b30172b5e831994e35fbde2d165325bec84fc43dbf6f4eb9cb2" +dependencies = [ + "anyhow", + "bitflags 2.11.0", + "indexmap 2.13.0", + "log", + "serde", + "serde_derive", + "serde_json", + "wasm-encoder", + "wasm-metadata", + "wasmparser", + "wit-parser", +] + +[[package]] +name = "wit-parser" +version = "0.244.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ecc8ac4bc1dc3381b7f59c34f00b67e18f910c2c0f50015669dde7def656a736" +dependencies = [ + "anyhow", + "id-arena", + "indexmap 2.13.0", + "log", + "semver", + "serde", + "serde_derive", + "serde_json", + "unicode-xid", + "wasmparser", +] + +[[package]] +name = "writeable" +version = "0.6.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9edde0db4769d2dc68579893f2306b26c6ecfbe0ef499b013d731b7b9247e0b9" + +[[package]] +name = "wry" +version = "0.54.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bb26159b420aa77684589a744ae9a9461a95395b848764ad12290a14d960a11a" +dependencies = [ + "base64 0.22.1", + "block2", + "cookie", + "crossbeam-channel", + "dirs", + "dpi", + "dunce", + "gdkx11", + "gtk", + "html5ever", + "http", + "javascriptcore-rs", + "jni", + "kuchikiki", + "libc", + "ndk", + "objc2", + "objc2-app-kit", + "objc2-core-foundation", + "objc2-foundation", + "objc2-ui-kit", + "objc2-web-kit", + "once_cell", + "percent-encoding", + "raw-window-handle", + "sha2", + "soup3", + "tao-macros", + "thiserror 2.0.18", + "url", + "webkit2gtk", + "webkit2gtk-sys", + "webview2-com", + "windows", + "windows-core 0.61.2", + "windows-version", + "x11-dl", +] + +[[package]] +name = "x11" +version = "2.21.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "502da5464ccd04011667b11c435cb992822c2c0dbde1770c988480d312a0db2e" +dependencies = [ + "libc", + "pkg-config", +] + +[[package]] +name = "x11-dl" +version = "2.21.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "38735924fedd5314a6e548792904ed8c6de6636285cb9fec04d5b1db85c1516f" +dependencies = [ + "libc", + "once_cell", + "pkg-config", +] + +[[package]] +name = "yoke" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72d6e5c6afb84d73944e5cedb052c4680d5657337201555f9f2a16b7406d4954" +dependencies = [ + "stable_deref_trait", + "yoke-derive", + "zerofrom", +] + +[[package]] +name = "yoke-derive" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b659052874eb698efe5b9e8cf382204678a0086ebf46982b79d6ca3182927e5d" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.117", + "synstructure", +] + +[[package]] +name = "zbus" +version = "5.14.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ca82f95dbd3943a40a53cfded6c2d0a2ca26192011846a1810c4256ef92c60bc" +dependencies = [ + "async-broadcast", + "async-executor", + "async-io", + "async-lock", + "async-process", + "async-recursion", + "async-task", + "async-trait", + "blocking", + "enumflags2", + "event-listener", + "futures-core", + "futures-lite", + "hex", + "libc", + "ordered-stream", + "rustix", + "serde", + "serde_repr", + "tracing", + "uds_windows", + "uuid", + "windows-sys 0.61.2", + "winnow 0.7.14", + "zbus_macros", + "zbus_names", + "zvariant", +] + +[[package]] +name = "zbus_macros" +version = "5.14.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "897e79616e84aac4b2c46e9132a4f63b93105d54fe8c0e8f6bffc21fa8d49222" +dependencies = [ + "proc-macro-crate 3.4.0", + "proc-macro2", + "quote", + "syn 2.0.117", + "zbus_names", + "zvariant", + "zvariant_utils", +] + +[[package]] +name = "zbus_names" +version = "4.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ffd8af6d5b78619bab301ff3c560a5bd22426150253db278f164d6cf3b72c50f" +dependencies = [ + "serde", + "winnow 0.7.14", + "zvariant", +] + +[[package]] +name = "zerocopy" +version = "0.8.39" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "db6d35d663eadb6c932438e763b262fe1a70987f9ae936e60158176d710cae4a" +dependencies = [ + "zerocopy-derive", +] + +[[package]] +name = "zerocopy-derive" +version = "0.8.39" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4122cd3169e94605190e77839c9a40d40ed048d305bfdc146e7df40ab0f3e517" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.117", +] + +[[package]] +name = "zerofrom" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "50cc42e0333e05660c3587f3bf9d0478688e15d870fab3346451ce7f8c9fbea5" +dependencies = [ + "zerofrom-derive", +] + +[[package]] +name = "zerofrom-derive" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d71e5d6e06ab090c67b5e44993ec16b72dcbaabc526db883a360057678b48502" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.117", + "synstructure", +] + +[[package]] +name = "zerotrie" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2a59c17a5562d507e4b54960e8569ebee33bee890c70aa3fe7b97e85a9fd7851" +dependencies = [ + "displaydoc", + "yoke", + "zerofrom", +] + +[[package]] +name = "zerovec" +version = "0.11.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6c28719294829477f525be0186d13efa9a3c602f7ec202ca9e353d310fb9a002" +dependencies = [ + "yoke", + "zerofrom", + "zerovec-derive", +] + +[[package]] +name = "zerovec-derive" +version = "0.11.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eadce39539ca5cb3985590102671f2567e659fca9666581ad3411d59207951f3" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.117", +] + +[[package]] +name = "zmij" +version = "1.0.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b8848ee67ecc8aedbaf3e4122217aff892639231befc6a1b58d29fff4c2cabaa" + +[[package]] +name = "zvariant" +version = "5.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5708299b21903bbe348e94729f22c49c55d04720a004aa350f1f9c122fd2540b" +dependencies = [ + "endi", + "enumflags2", + "serde", + "winnow 0.7.14", + "zvariant_derive", + "zvariant_utils", +] + +[[package]] +name = "zvariant_derive" +version = "5.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5b59b012ebe9c46656f9cc08d8da8b4c726510aef12559da3e5f1bf72780752c" +dependencies = [ + "proc-macro-crate 3.4.0", + "proc-macro2", + "quote", + "syn 2.0.117", + "zvariant_utils", +] + +[[package]] +name = "zvariant_utils" +version = "3.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f75c23a64ef8f40f13a6989991e643554d9bef1d682a281160cf0c1bc389c5e9" +dependencies = [ + "proc-macro2", + "quote", + "serde", + "syn 2.0.117", + "winnow 0.7.14", +] diff --git a/Journal.App/src-tauri/Cargo.toml b/Journal.App/src-tauri/Cargo.toml new file mode 100644 index 0000000..ccc2244 --- /dev/null +++ b/Journal.App/src-tauri/Cargo.toml @@ -0,0 +1,26 @@ +[package] +name = "journalapp" +version = "0.1.0" +description = "A Tauri App" +authors = ["Stan"] +edition = "2021" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[lib] +# The `_lib` suffix may seem redundant but it is necessary +# to make the lib name unique and wouldn't conflict with the bin name. +# This seems to be only an issue on Windows, see https://github.com/rust-lang/cargo/issues/8519 +name = "journalapp_lib" +crate-type = ["staticlib", "cdylib", "rlib"] + +[build-dependencies] +tauri-build = { version = "2", features = [] } + +[dependencies] +tauri = { version = "2", features = [] } +tauri-plugin-dialog = "2" +tauri-plugin-opener = "2" +serde = { version = "1", features = ["derive"] } +serde_json = "1" +tokio = { version = "1", features = ["process", "io-util", "sync"] } diff --git a/Journal.App/src-tauri/build.rs b/Journal.App/src-tauri/build.rs new file mode 100644 index 0000000..d860e1e --- /dev/null +++ b/Journal.App/src-tauri/build.rs @@ -0,0 +1,3 @@ +fn main() { + tauri_build::build() +} diff --git a/Journal.App/src-tauri/capabilities/default.json b/Journal.App/src-tauri/capabilities/default.json new file mode 100644 index 0000000..01a4101 --- /dev/null +++ b/Journal.App/src-tauri/capabilities/default.json @@ -0,0 +1,11 @@ +{ + "$schema": "../gen/schemas/desktop-schema.json", + "identifier": "default", + "description": "Capability for the main window", + "windows": ["main"], + "permissions": [ + "core:default", + "dialog:default", + "opener:default" + ] +} diff --git a/Journal.App/src-tauri/icons/128x128.png b/Journal.App/src-tauri/icons/128x128.png new file mode 100644 index 0000000..6be5e50 Binary files /dev/null and b/Journal.App/src-tauri/icons/128x128.png differ diff --git a/Journal.App/src-tauri/icons/128x128@2x.png b/Journal.App/src-tauri/icons/128x128@2x.png new file mode 100644 index 0000000..e81bece Binary files /dev/null and b/Journal.App/src-tauri/icons/128x128@2x.png differ diff --git a/Journal.App/src-tauri/icons/32x32.png b/Journal.App/src-tauri/icons/32x32.png new file mode 100644 index 0000000..a437dd5 Binary files /dev/null and b/Journal.App/src-tauri/icons/32x32.png differ diff --git a/Journal.App/src-tauri/icons/Square107x107Logo.png b/Journal.App/src-tauri/icons/Square107x107Logo.png new file mode 100644 index 0000000..0ca4f27 Binary files /dev/null and b/Journal.App/src-tauri/icons/Square107x107Logo.png differ diff --git a/Journal.App/src-tauri/icons/Square142x142Logo.png b/Journal.App/src-tauri/icons/Square142x142Logo.png new file mode 100644 index 0000000..b81f820 Binary files /dev/null and b/Journal.App/src-tauri/icons/Square142x142Logo.png differ diff --git a/Journal.App/src-tauri/icons/Square150x150Logo.png b/Journal.App/src-tauri/icons/Square150x150Logo.png new file mode 100644 index 0000000..624c7bf Binary files /dev/null and b/Journal.App/src-tauri/icons/Square150x150Logo.png differ diff --git a/Journal.App/src-tauri/icons/Square284x284Logo.png b/Journal.App/src-tauri/icons/Square284x284Logo.png new file mode 100644 index 0000000..c021d2b Binary files /dev/null and b/Journal.App/src-tauri/icons/Square284x284Logo.png differ diff --git a/Journal.App/src-tauri/icons/Square30x30Logo.png b/Journal.App/src-tauri/icons/Square30x30Logo.png new file mode 100644 index 0000000..6219700 Binary files /dev/null and b/Journal.App/src-tauri/icons/Square30x30Logo.png differ diff --git a/Journal.App/src-tauri/icons/Square310x310Logo.png b/Journal.App/src-tauri/icons/Square310x310Logo.png new file mode 100644 index 0000000..f9bc048 Binary files /dev/null and b/Journal.App/src-tauri/icons/Square310x310Logo.png differ diff --git a/Journal.App/src-tauri/icons/Square44x44Logo.png b/Journal.App/src-tauri/icons/Square44x44Logo.png new file mode 100644 index 0000000..d5fbfb2 Binary files /dev/null and b/Journal.App/src-tauri/icons/Square44x44Logo.png differ diff --git a/Journal.App/src-tauri/icons/Square71x71Logo.png b/Journal.App/src-tauri/icons/Square71x71Logo.png new file mode 100644 index 0000000..63440d7 Binary files /dev/null and b/Journal.App/src-tauri/icons/Square71x71Logo.png differ diff --git a/Journal.App/src-tauri/icons/Square89x89Logo.png b/Journal.App/src-tauri/icons/Square89x89Logo.png new file mode 100644 index 0000000..f3f705a Binary files /dev/null and b/Journal.App/src-tauri/icons/Square89x89Logo.png differ diff --git a/Journal.App/src-tauri/icons/StoreLogo.png b/Journal.App/src-tauri/icons/StoreLogo.png new file mode 100644 index 0000000..4556388 Binary files /dev/null and b/Journal.App/src-tauri/icons/StoreLogo.png differ diff --git a/Journal.App/src-tauri/icons/icon.icns b/Journal.App/src-tauri/icons/icon.icns new file mode 100644 index 0000000..12a5bce Binary files /dev/null and b/Journal.App/src-tauri/icons/icon.icns differ diff --git a/Journal.App/src-tauri/icons/icon.ico b/Journal.App/src-tauri/icons/icon.ico new file mode 100644 index 0000000..b3636e4 Binary files /dev/null and b/Journal.App/src-tauri/icons/icon.ico differ diff --git a/Journal.App/src-tauri/icons/icon.png b/Journal.App/src-tauri/icons/icon.png new file mode 100644 index 0000000..e1cd261 Binary files /dev/null and b/Journal.App/src-tauri/icons/icon.png differ diff --git a/Journal.App/src-tauri/src/lib.rs b/Journal.App/src-tauri/src/lib.rs new file mode 100644 index 0000000..49dfa3a --- /dev/null +++ b/Journal.App/src-tauri/src/lib.rs @@ -0,0 +1,478 @@ +use serde::{Deserialize, Serialize}; +use serde_json::Value; +use std::collections::HashSet; +use std::env; +use std::fs; +use std::path::{Path, PathBuf}; +use std::process::Stdio; +use tauri::Manager; +use tokio::io::{AsyncBufReadExt, AsyncWriteExt, BufReader}; +use tokio::process::{Child, ChildStdin, ChildStdout, Command}; +use tokio::sync::Mutex; + +#[derive(Deserialize, Serialize)] +#[serde(rename_all = "camelCase")] +struct CommandEnvelope { + action: String, + #[serde(default)] + correlation_id: Option, + #[serde(default)] + id: Option, + #[serde(default)] + r#type: Option, + #[serde(default)] + tag: Option, + #[serde(default)] + payload: Option, +} + +const DEFAULT_SETTINGS_TAGS: &[&str] = &["Personal", "Work", "Ideas", "Journal"]; +const DEFAULT_FRAGMENT_TYPES: &[&str] = &["Quote", "Snippet", "Reference"]; +const DEFAULT_STARTUP_VIEW: &str = "entries"; + +#[derive(Deserialize, Serialize)] +struct AppSettings { + #[serde(default, skip_serializing_if = "Option::is_none")] + sidecar_root: Option, + #[serde(default = "default_settings_tags")] + tags: Vec, + #[serde(default = "default_fragment_types")] + fragment_types: Vec, + #[serde(default = "default_startup_view")] + default_startup_view: String, +} + +impl Default for AppSettings { + fn default() -> Self { + Self { + sidecar_root: None, + tags: default_settings_tags(), + fragment_types: default_fragment_types(), + default_startup_view: default_startup_view(), + } + } +} + +fn default_settings_tags() -> Vec { + DEFAULT_SETTINGS_TAGS + .iter() + .map(|v| (*v).to_string()) + .collect() +} + +fn default_fragment_types() -> Vec { + DEFAULT_FRAGMENT_TYPES + .iter() + .map(|v| (*v).to_string()) + .collect() +} + +fn default_startup_view() -> String { + DEFAULT_STARTUP_VIEW.to_string() +} + +fn normalize_items(values: Vec, fallback: &[&str]) -> Vec { + let mut seen = HashSet::new(); + let mut normalized = Vec::new(); + for item in values { + let trimmed = item.trim(); + if trimmed.is_empty() { + continue; + } + let key = trimmed.to_lowercase(); + if seen.insert(key) { + normalized.push(trimmed.to_string()); + } + } + + if normalized.is_empty() { + return fallback.iter().map(|v| (*v).to_string()).collect(); + } + + normalized +} + +fn normalize_startup_view(value: Option) -> String { + let normalized = value + .unwrap_or_else(default_startup_view) + .trim() + .to_lowercase(); + match normalized.as_str() { + "entries" | "calendar" | "fragments" | "todos" | "lists" => normalized, + _ => default_startup_view(), + } +} + +struct ManagedSidecar { + child: Child, + stdin: ChildStdin, + stdout: BufReader, +} + +impl ManagedSidecar { + fn start(root: &Path) -> Result { + let sidecar_path = resolve_sidecar_path(root)?; + let mut cmd = Command::new(sidecar_path); + cmd.stdin(Stdio::piped()) + .stdout(Stdio::piped()) + .stderr(Stdio::inherit()) + .current_dir(root) + .env("JOURNAL_PROJECT_ROOT", root) + .kill_on_drop(true); + #[cfg(windows)] + cmd.creation_flags(0x08000000); // CREATE_NO_WINDOW + let mut child = cmd + .spawn() + .map_err(|err| format!("Failed to start sidecar process: {err}"))?; + + let stdin = child + .stdin + .take() + .ok_or_else(|| "Unable to open sidecar stdin.".to_string())?; + let stdout = child + .stdout + .take() + .ok_or_else(|| "Unable to open sidecar stdout.".to_string())?; + + Ok(Self { + child, + stdin, + stdout: BufReader::new(stdout), + }) + } + + fn is_running(&mut self) -> bool { + match self.child.try_wait() { + Ok(None) => true, + Ok(Some(_)) => false, + Err(_) => false, + } + } + + async fn send_command_line(&mut self, input_line: &str) -> Result { + self.stdin + .write_all(format!("{input_line}\n").as_bytes()) + .await + .map_err(|err| format!("Failed writing to sidecar stdin: {err}"))?; + self.stdin + .flush() + .await + .map_err(|err| format!("Failed flushing sidecar stdin: {err}"))?; + + let mut response_line = String::new(); + let read = self + .stdout + .read_line(&mut response_line) + .await + .map_err(|err| format!("Failed reading sidecar stdout: {err}"))?; + if read == 0 { + return Err("Sidecar stdout closed unexpectedly.".to_string()); + } + + let trimmed = response_line.trim().to_string(); + if trimmed.is_empty() { + return Err("Sidecar returned an empty response line.".to_string()); + } + + Ok(trimmed) + } +} + +impl Drop for ManagedSidecar { + fn drop(&mut self) {} +} + +struct SidecarState { + process: Mutex>, + root_override: Mutex>, + config_path: PathBuf, +} + +fn load_settings(path: &Path) -> AppSettings { + fs::read_to_string(path) + .ok() + .and_then(|s| serde_json::from_str(&s).ok()) + .unwrap_or_default() +} + +fn save_settings(path: &Path, settings: &AppSettings) -> Result<(), String> { + let json = serde_json::to_string_pretty(settings) + .map_err(|e| format!("Failed to serialize settings: {e}"))?; + fs::write(path, json).map_err(|e| format!("Failed to save settings: {e}")) +} + +fn auto_detect_root() -> Result { + let mut current = + env::current_dir().map_err(|err| format!("Unable to read current dir: {err}"))?; + loop { + if current.join("Journal.Sidecar").exists() { + return Ok(current); + } + if !current.pop() { + return Err("Unable to locate repository root containing Journal.Sidecar.".to_string()); + } + } +} + +fn effective_root(root_override: &Option) -> Result { + if let Some(root) = root_override { + return Ok(root.clone()); + } + auto_detect_root() +} + +fn resolve_sidecar_path(root: &Path) -> Result { + let root_exe_path = root.join("Journal.Sidecar.exe"); + if root_exe_path.exists() { + return Ok(root_exe_path); + } + + let root_publish_exe_path = root.join("publish").join("Journal.Sidecar.exe"); + if root_publish_exe_path.exists() { + return Ok(root_publish_exe_path); + } + + let debug_path = root.join("Journal.Sidecar/bin/Debug/net10.0/Journal.Sidecar.exe"); + if debug_path.exists() { + return Ok(debug_path); + } + + let release_path = + root.join("Journal.Sidecar/bin/Release/net10.0/win-x64/publish/Journal.Sidecar.exe"); + if release_path.exists() { + return Ok(release_path); + } + + let sidecar_root = root.join("Journal.Sidecar"); + if let Some(path) = find_sidecar_executable(&sidecar_root) { + return Ok(path); + } + + Err("Journal.Sidecar.exe not found. Build Journal.Sidecar first.".to_string()) +} + +fn find_sidecar_executable(search_root: &Path) -> Option { + if !search_root.exists() { + return None; + } + + let mut stack = vec![search_root.to_path_buf()]; + while let Some(dir) = stack.pop() { + let Ok(entries) = fs::read_dir(&dir) else { + continue; + }; + + for entry in entries { + let Ok(entry) = entry else { + continue; + }; + let path = entry.path(); + if path.is_dir() { + stack.push(path); + continue; + } + + let is_sidecar_exe = path + .file_name() + .and_then(|name| name.to_str()) + .map(|name| name.eq_ignore_ascii_case("Journal.Sidecar.exe")) + .unwrap_or(false); + if is_sidecar_exe { + return Some(path); + } + } + } + + None +} + +async fn send_with_managed_sidecar( + state: &SidecarState, + input_line: &str, +) -> Result { + let root = { + let root_override = state.root_override.lock().await; + effective_root(&root_override)? + }; + let mut guard = state.process.lock().await; + + for attempt in 1..=2 { + let should_start = match guard.as_mut() { + Some(existing) => !existing.is_running(), + None => true, + }; + if should_start { + *guard = Some(ManagedSidecar::start(&root)?); + } + + let Some(process) = guard.as_mut() else { + return Err("Sidecar process unavailable.".to_string()); + }; + + match process.send_command_line(input_line).await { + Ok(line) => return Ok(line), + Err(err) => { + *guard = None; + if attempt == 2 { + return Err(err); + } + } + } + } + + Err("Failed to send command to sidecar.".to_string()) +} + +async fn stop_managed_sidecar(state: &SidecarState) { + let mut guard = state.process.lock().await; + guard.take(); +} + +#[tauri::command] +async fn get_sidecar_root(state: tauri::State<'_, SidecarState>) -> Result { + let root_override = state.root_override.lock().await.clone(); + let root = effective_root(&root_override)?; + Ok(serde_json::json!({ + "root": root.to_string_lossy(), + "isCustom": root_override.is_some() + })) +} + +#[tauri::command] +async fn set_sidecar_root( + state: tauri::State<'_, SidecarState>, + path: String, +) -> Result { + let (new_override, root) = if path.trim().is_empty() { + let detected = auto_detect_root()?; + (None, detected) + } else { + let new_root = PathBuf::from(&path); + if !new_root.exists() { + return Err(format!( + "Directory '{}' does not exist.", + new_root.display() + )); + } + resolve_sidecar_path(&new_root)?; + (Some(new_root.clone()), new_root) + }; + + // Stop the current sidecar so it restarts with new root + { + let mut guard = state.process.lock().await; + guard.take(); + } + + let is_custom = new_override.is_some(); + *state.root_override.lock().await = new_override.clone(); + + let mut settings = load_settings(&state.config_path); + settings.sidecar_root = new_override.map(|p| p.to_string_lossy().into_owned()); + save_settings(&state.config_path, &settings)?; + + Ok(serde_json::json!({ + "root": root.to_string_lossy(), + "isCustom": is_custom + })) +} + +#[tauri::command] +async fn get_ui_settings(state: tauri::State<'_, SidecarState>) -> Result { + let settings = load_settings(&state.config_path); + let tags = normalize_items(settings.tags, DEFAULT_SETTINGS_TAGS); + let fragment_types = normalize_items(settings.fragment_types, DEFAULT_FRAGMENT_TYPES); + let startup_view = normalize_startup_view(Some(settings.default_startup_view)); + + Ok(serde_json::json!({ + "tags": tags, + "fragmentTypes": fragment_types, + "defaultStartupView": startup_view + })) +} + +#[tauri::command] +async fn set_ui_settings( + state: tauri::State<'_, SidecarState>, + tags: Vec, + fragment_types: Vec, + default_startup_view: Option, +) -> Result { + let mut settings = load_settings(&state.config_path); + settings.tags = normalize_items(tags, DEFAULT_SETTINGS_TAGS); + settings.fragment_types = normalize_items(fragment_types, DEFAULT_FRAGMENT_TYPES); + settings.default_startup_view = normalize_startup_view(default_startup_view); + save_settings(&state.config_path, &settings)?; + + Ok(serde_json::json!({ + "tags": settings.tags, + "fragmentTypes": settings.fragment_types, + "defaultStartupView": settings.default_startup_view + })) +} + +#[tauri::command] +async fn shutdown( + state: tauri::State<'_, SidecarState>, + app_handle: tauri::AppHandle, +) -> Result<(), String> { + stop_managed_sidecar(state.inner()).await; + app_handle.exit(0); + Ok(()) +} + +#[tauri::command] +async fn sidecar_command( + state: tauri::State<'_, SidecarState>, + command: CommandEnvelope, +) -> Result { + if command.action.trim().is_empty() { + return Err("Missing action".to_string()); + } + + let input_line = serde_json::to_string(&command) + .map_err(|err| format!("Serialize command failed: {err}"))?; + let response_line = send_with_managed_sidecar(state.inner(), &input_line).await?; + serde_json::from_str::(&response_line) + .map_err(|err| format!("Invalid sidecar JSON response: {err}")) +} + +#[cfg_attr(mobile, tauri::mobile_entry_point)] +pub fn run() { + let app = tauri::Builder::default() + .plugin(tauri_plugin_dialog::init()) + .plugin(tauri_plugin_opener::init()) + .invoke_handler(tauri::generate_handler![ + sidecar_command, + shutdown, + get_sidecar_root, + set_sidecar_root, + get_ui_settings, + set_ui_settings, + ]) + .setup(|app| { + let config_dir = app.path().app_config_dir()?; + fs::create_dir_all(&config_dir).ok(); + let config_path = config_dir.join("settings.json"); + let settings = load_settings(&config_path); + let root_override = settings.sidecar_root.map(PathBuf::from); + + app.manage(SidecarState { + process: Mutex::new(None), + root_override: Mutex::new(root_override), + config_path, + }); + Ok(()) + }) + .build(tauri::generate_context!()) + .expect("error while building tauri application"); + + app.run(|app_handle, event| { + if let tauri::RunEvent::ExitRequested { .. } = event { + let state = app_handle.state::(); + if let Ok(mut guard) = state.process.try_lock() { + guard.take(); + }; + } + }); +} diff --git a/Journal.App/src-tauri/src/main.rs b/Journal.App/src-tauri/src/main.rs new file mode 100644 index 0000000..2c417cb --- /dev/null +++ b/Journal.App/src-tauri/src/main.rs @@ -0,0 +1,6 @@ +// Prevents additional console window on Windows in release, DO NOT REMOVE!! +#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")] + +fn main() { + journalapp_lib::run() +} diff --git a/Journal.App/src-tauri/tauri.conf.json b/Journal.App/src-tauri/tauri.conf.json new file mode 100644 index 0000000..ffc904b --- /dev/null +++ b/Journal.App/src-tauri/tauri.conf.json @@ -0,0 +1,35 @@ +{ + "$schema": "https://schema.tauri.app/config/2", + "productName": "Project Journal", + "version": "0.1.0", + "identifier": "com.stan.journal", + "build": { + "beforeDevCommand": "npm run dev", + "devUrl": "http://localhost:1420", + "beforeBuildCommand": "npm run build", + "frontendDist": "../build" + }, + "app": { + "windows": [ + { + "title": "Project Journal", + "width": 1366, + "height": 768 + } + ], + "security": { + "csp": null + } + }, + "bundle": { + "active": true, + "targets": "all", + "icon": [ + "icons/32x32.png", + "icons/128x128.png", + "icons/128x128@2x.png", + "icons/icon.icns", + "icons/icon.ico" + ] + } +} \ No newline at end of file diff --git a/Journal.App/src/app.html b/Journal.App/src/app.html new file mode 100644 index 0000000..ef938e9 --- /dev/null +++ b/Journal.App/src/app.html @@ -0,0 +1,15 @@ + + + + + + + + + Journal + %sveltekit.head% + + +
%sveltekit.body%
+ + diff --git a/Journal.App/src/lib/backend/auth.ts b/Journal.App/src/lib/backend/auth.ts new file mode 100644 index 0000000..b3f8697 --- /dev/null +++ b/Journal.App/src/lib/backend/auth.ts @@ -0,0 +1,89 @@ +import { sendCommand } from "./client"; +import { pickCase } from "./normalize"; + +export function hydrateWorkspace(password: string): Promise { + return sendCommand({ + action: "db.hydrate_workspace", + payload: { password } + }); +} + +type RuntimeConfigRaw = { + dataDirectory?: string; + vaultDirectory?: string; + DataDirectory?: string; + VaultDirectory?: string; +}; + +type RuntimeConfig = { + dataDirectory: string; + vaultDirectory: string; +}; + +type PersistOptions = { + keepalive?: boolean; +}; + +async function getRuntimeConfig(options: PersistOptions = {}): Promise { + const data = await sendCommand( + { + action: "config.get" + }, + options + ); + + return { + dataDirectory: pickCase(data, "dataDirectory", "DataDirectory", ""), + vaultDirectory: pickCase(data, "vaultDirectory", "VaultDirectory", "") + }; +} + +export async function unlockVaultWorkspace(password: string): Promise { + const config = await getRuntimeConfig(); + const loaded = await sendCommand({ + action: "vault.load_all", + payload: { + password, + vaultDirectory: config.vaultDirectory, + dataDirectory: config.dataDirectory + } + }); + + if (!loaded) { + throw new Error("Incorrect vault password."); + } + + await sendCommand({ + action: "db.hydrate_workspace", + payload: { + password, + dataDirectory: config.dataDirectory + } + }); +} + +export async function persistAndClearVault(password: string, options: PersistOptions = {}): Promise { + const config = await getRuntimeConfig(options); + + await sendCommand( + { + action: "vault.rebuild_all", + payload: { + password, + vaultDirectory: config.vaultDirectory, + dataDirectory: config.dataDirectory + } + }, + options + ); + + await sendCommand( + { + action: "vault.clear_data_directory", + payload: { + dataDirectory: config.dataDirectory + } + }, + options + ); +} diff --git a/Journal.App/src/lib/backend/client.ts b/Journal.App/src/lib/backend/client.ts new file mode 100644 index 0000000..1ab887b --- /dev/null +++ b/Journal.App/src/lib/backend/client.ts @@ -0,0 +1,27 @@ +import { invoke } from "$lib/runtime/invoke"; +import type { BackendCommand, BackendResponse } from "./types"; + +function newCorrelationId(): string { + return `ui-${Date.now()}-${Math.random().toString(16).slice(2)}`; +} + +type SendCommandOptions = { + keepalive?: boolean; +}; + +export async function sendCommand(command: BackendCommand, options: SendCommandOptions = {}): Promise { + const envelope: BackendCommand = { + ...command, + correlationId: command.correlationId ?? newCorrelationId() + }; + const response = await invoke>("sidecar_command", { + command: envelope, + keepalive: options.keepalive === true + }); + + if (!response.ok) { + throw new Error(response.error || "Backend command failed"); + } + + return response.data; +} diff --git a/Journal.App/src/lib/backend/entries.ts b/Journal.App/src/lib/backend/entries.ts new file mode 100644 index 0000000..a4dd4c3 --- /dev/null +++ b/Journal.App/src/lib/backend/entries.ts @@ -0,0 +1,219 @@ +import { sendCommand } from "./client"; +import { normalizeFragment, type FragmentDto, type FragmentDtoRaw } from "./fragments"; +import { pickCase } from "./normalize"; + +export type ParsedSectionDto = { + title: string; + content: string[]; + checkboxes: Record; +}; + +export type JournalEntryDto = { + date: string; + fragments: FragmentDto[]; + rawContent: string; + sections: Record; +}; + +export type EntryListItemDto = { + fileName: string; + filePath: string; +}; + +export type EntryLoadResultDto = { + fileName: string; + filePath: string; + entry: JournalEntryDto; +}; + +export type EntrySaveResultDto = { + filePath: string; +}; + +export type EntrySearchRequestDto = { + dataDirectory: string; + query?: string; + section?: string; + startDate?: string; + endDate?: string; + tags?: string[]; + types?: string[]; + checked?: string[]; + unchecked?: string[]; +}; + +export type EntrySearchResultDto = { + fileName: string; + entry: JournalEntryDto; +}; + +type ParsedSectionDtoRaw = { + title?: string; + content?: string[]; + checkboxes?: Record; + Title?: string; + Content?: string[]; + Checkboxes?: Record; +}; + +type JournalEntryDtoRaw = { + date?: string; + fragments?: FragmentDtoRaw[]; + rawContent?: string; + sections?: Record; + Date?: string; + Fragments?: FragmentDtoRaw[]; + RawContent?: string; + Sections?: Record; +}; + +type EntryListItemDtoRaw = { + fileName?: string; + filePath?: string; + FileName?: string; + FilePath?: string; +}; + +type EntryLoadResultDtoRaw = { + fileName?: string; + filePath?: string; + entry?: JournalEntryDtoRaw; + date?: string; + rawContent?: string; + FileName?: string; + FilePath?: string; + Entry?: JournalEntryDtoRaw; + Date?: string; + RawContent?: string; +}; + +type EntrySaveResultDtoRaw = { + filePath?: string; + FilePath?: string; +}; + +type EntrySearchResultDtoRaw = { + fileName?: string; + entry?: JournalEntryDtoRaw; + date?: string; + rawContent?: string; + FileName?: string; + Entry?: JournalEntryDtoRaw; + Date?: string; + RawContent?: string; +}; + +function normalizeSection(raw: ParsedSectionDtoRaw): ParsedSectionDto { + return { + title: pickCase(raw, "title", "Title", ""), + content: pickCase(raw, "content", "Content", [] as string[]), + checkboxes: pickCase(raw, "checkboxes", "Checkboxes", {} as Record) + }; +} + +function normalizeJournalEntry(raw: JournalEntryDtoRaw | undefined): JournalEntryDto { + const fragments = pickCase(raw, "fragments", "Fragments", [] as FragmentDtoRaw[]); + const sections = pickCase(raw, "sections", "Sections", {} as Record); + return { + date: pickCase(raw, "date", "Date", ""), + fragments: fragments.map(normalizeFragment), + rawContent: pickCase(raw, "rawContent", "RawContent", ""), + sections: Object.fromEntries( + Object.entries(sections).map(([key, value]) => [key, normalizeSection(value)]) + ) + }; +} + +function normalizeEntryListItem(raw: EntryListItemDtoRaw): EntryListItemDto { + return { + fileName: pickCase(raw, "fileName", "FileName", ""), + filePath: pickCase(raw, "filePath", "FilePath", "") + }; +} + +function normalizeEntryLoadResult(raw: EntryLoadResultDtoRaw): EntryLoadResultDto { + const nestedEntry = pickCase(raw, "entry", "Entry", undefined as JournalEntryDtoRaw | undefined); + const entry = + nestedEntry + ? normalizeJournalEntry(nestedEntry) + : normalizeJournalEntry({ + date: pickCase(raw, "date", "Date", undefined as string | undefined), + rawContent: pickCase(raw, "rawContent", "RawContent", undefined as string | undefined), + fragments: [], + sections: {} + }); + + return { + fileName: pickCase(raw, "fileName", "FileName", ""), + filePath: pickCase(raw, "filePath", "FilePath", ""), + entry + }; +} + +function normalizeEntrySearchResult(raw: EntrySearchResultDtoRaw): EntrySearchResultDto { + const nestedEntry = pickCase(raw, "entry", "Entry", undefined as JournalEntryDtoRaw | undefined); + const entry = + nestedEntry + ? normalizeJournalEntry(nestedEntry) + : normalizeJournalEntry({ + date: pickCase(raw, "date", "Date", undefined as string | undefined), + rawContent: pickCase(raw, "rawContent", "RawContent", undefined as string | undefined), + fragments: [], + sections: {} + }); + + return { + fileName: pickCase(raw, "fileName", "FileName", ""), + entry + }; +} + +export async function listEntries(dataDirectory?: string): Promise { + const data = await sendCommand({ + action: "entries.list", + payload: { dataDirectory } + }); + + return data.map(normalizeEntryListItem).filter((item) => Boolean(item.filePath)); +} + +export async function loadEntry(filePath: string): Promise { + const data = await sendCommand({ + action: "entries.load", + payload: { filePath } + }); + + return normalizeEntryLoadResult(data); +} + +export async function saveEntry(payload: { + content: string; + filePath?: string; + mode?: string; + fileName?: string; +}): Promise { + const data = await sendCommand({ + action: "entries.save", + payload + }); + + return { + filePath: pickCase(data, "filePath", "FilePath", "") + }; +} + +export async function deleteEntry(filePath: string): Promise { + return sendCommand({ + action: "entries.delete", + payload: { filePath } + }); +} + +export async function searchEntries(payload: EntrySearchRequestDto): Promise { + const data = await sendCommand({ + action: "search.entries", + payload + }); + + return data.map(normalizeEntrySearchResult).filter((item) => Boolean(item.fileName)); +} diff --git a/Journal.App/src/lib/backend/fragments.ts b/Journal.App/src/lib/backend/fragments.ts new file mode 100644 index 0000000..dc0f26f --- /dev/null +++ b/Journal.App/src/lib/backend/fragments.ts @@ -0,0 +1,86 @@ +import { sendCommand } from "./client"; +import { pickCase } from "./normalize"; + +export type FragmentDto = { + id: string; + type: string; + description: string; + time: string; + tags: string[]; +}; + +export type CreateFragmentPayload = { + type: string; + description: string; + tags?: string[]; +}; + +export type UpdateFragmentPayload = { + type?: string; + description?: string; + tags?: string[]; + time?: string; +}; + +export type FragmentDtoRaw = { + id?: string; + type?: string; + description?: string; + time?: string; + tags?: string[]; + Id?: string; + Type?: string; + Description?: string; + Time?: string; + Tags?: string[]; +}; + +export function normalizeFragment(raw: FragmentDtoRaw): FragmentDto { + return { + id: pickCase(raw, "id", "Id", ""), + type: pickCase(raw, "type", "Type", ""), + description: pickCase(raw, "description", "Description", ""), + time: pickCase(raw, "time", "Time", ""), + tags: pickCase(raw, "tags", "Tags", [] as string[]) + }; +} + +export async function listFragments(): Promise { + const data = await sendCommand({ + action: "fragments.list" + }); + return data.map(normalizeFragment).filter((item) => Boolean(item.id)); +} + +export async function getFragment(id: string): Promise { + const data = await sendCommand({ + action: "fragments.get", + id + }); + if (!data) return null; + const normalized = normalizeFragment(data); + return normalized.id ? normalized : null; +} + +export async function createFragment(payload: CreateFragmentPayload): Promise { + const data = await sendCommand({ + action: "fragments.create", + payload + }); + return normalizeFragment(data); +} + +export function updateFragment(id: string, payload: UpdateFragmentPayload): Promise { + return sendCommand({ + action: "fragments.update", + id, + payload + }); +} + +export function deleteFragment(id: string): Promise { + return sendCommand({ + action: "fragments.delete", + id + }); +} diff --git a/Journal.App/src/lib/backend/lists.ts b/Journal.App/src/lib/backend/lists.ts new file mode 100644 index 0000000..74ec4d8 --- /dev/null +++ b/Journal.App/src/lib/backend/lists.ts @@ -0,0 +1,83 @@ +import { sendCommand } from "./client"; +import { pickCase } from "./normalize"; + +export type ListDocumentDto = { + id: string; + label: string; + content: string; + createdAt: string; + updatedAt: string; +}; + +export type CreateListPayload = { + label: string; + content?: string; +}; + +export type UpdateListPayload = { + label?: string; + content?: string; +}; + +type ListDocumentDtoRaw = { + id?: string; + label?: string; + content?: string; + createdAt?: string; + updatedAt?: string; + Id?: string; + Label?: string; + Content?: string; + CreatedAt?: string; + UpdatedAt?: string; +}; + +export function normalizeList(raw: ListDocumentDtoRaw): ListDocumentDto { + return { + id: pickCase(raw, "id", "Id", ""), + label: pickCase(raw, "label", "Label", ""), + content: pickCase(raw, "content", "Content", ""), + createdAt: pickCase(raw, "createdAt", "CreatedAt", ""), + updatedAt: pickCase(raw, "updatedAt", "UpdatedAt", "") + }; +} + +export async function listLists(): Promise { + const data = await sendCommand({ + action: "lists.list" + }); + return data.map(normalizeList).filter((item) => Boolean(item.id)); +} + +export async function getList(id: string): Promise { + const data = await sendCommand({ + action: "lists.get", + id + }); + if (!data) return null; + const normalized = normalizeList(data); + return normalized.id ? normalized : null; +} + +export async function createList(payload: CreateListPayload): Promise { + const data = await sendCommand({ + action: "lists.create", + payload + }); + return normalizeList(data); +} + +export function updateList(id: string, payload: UpdateListPayload): Promise { + return sendCommand({ + action: "lists.update", + id, + payload + }); +} + +export function deleteList(id: string): Promise { + return sendCommand({ + action: "lists.delete", + id + }); +} diff --git a/Journal.App/src/lib/backend/normalize.ts b/Journal.App/src/lib/backend/normalize.ts new file mode 100644 index 0000000..6dded60 --- /dev/null +++ b/Journal.App/src/lib/backend/normalize.ts @@ -0,0 +1,18 @@ +type UnknownObject = Record; + +function asObject(value: unknown): UnknownObject | undefined { + return value && typeof value === "object" ? (value as UnknownObject) : undefined; +} + +export function pickCase( + source: unknown, + camelKey: string, + pascalKey: string, + fallback: T +): T { + const obj = asObject(source); + if (!obj) return fallback; + + const value = obj[camelKey] ?? obj[pascalKey]; + return (value as T | undefined) ?? fallback; +} diff --git a/Journal.App/src/lib/backend/templates.ts b/Journal.App/src/lib/backend/templates.ts new file mode 100644 index 0000000..79bf828 --- /dev/null +++ b/Journal.App/src/lib/backend/templates.ts @@ -0,0 +1,90 @@ +import { sendCommand } from "./client"; +import { pickCase } from "./normalize"; + +export type EntryTemplateItemDto = { + fileName: string; + filePath: string; +}; + +export type EntryTemplateLoadResultDto = { + fileName: string; + filePath: string; + content: string; +}; + +export type EntryTemplateSaveResultDto = { + filePath: string; +}; + +type EntryTemplateItemDtoRaw = { + fileName?: string; + filePath?: string; + FileName?: string; + FilePath?: string; +}; + +type EntryTemplateLoadResultDtoRaw = { + fileName?: string; + filePath?: string; + content?: string; + FileName?: string; + FilePath?: string; + Content?: string; +}; + +type EntryTemplateSaveResultDtoRaw = { + filePath?: string; + FilePath?: string; +}; + +function normalizeTemplateItem(raw: EntryTemplateItemDtoRaw): EntryTemplateItemDto { + return { + fileName: pickCase(raw, "fileName", "FileName", ""), + filePath: pickCase(raw, "filePath", "FilePath", "") + }; +} + +export async function listEntryTemplates(dataDirectory?: string): Promise { + const data = await sendCommand({ + action: "templates.list", + payload: { dataDirectory } + }); + + return data.map(normalizeTemplateItem).filter((item) => Boolean(item.filePath)); +} + +export async function loadEntryTemplate(filePath: string): Promise { + const data = await sendCommand({ + action: "templates.load", + payload: { filePath } + }); + + return { + fileName: pickCase(data, "fileName", "FileName", ""), + filePath: pickCase(data, "filePath", "FilePath", ""), + content: pickCase(data, "content", "Content", "") + }; +} + +export async function saveEntryTemplate(payload: { + name: string; + content: string; + filePath?: string; + dataDirectory?: string; +}): Promise { + const data = await sendCommand({ + action: "templates.save", + payload + }); + + return { + filePath: pickCase(data, "filePath", "FilePath", "") + }; +} + +export async function deleteEntryTemplate(filePath: string): Promise { + return sendCommand({ + action: "templates.delete", + payload: { filePath } + }); +} diff --git a/Journal.App/src/lib/backend/todos.ts b/Journal.App/src/lib/backend/todos.ts new file mode 100644 index 0000000..1802e9e --- /dev/null +++ b/Journal.App/src/lib/backend/todos.ts @@ -0,0 +1,144 @@ +import { sendCommand } from "./client"; +import { pickCase } from "./normalize"; + +export type TodoItemDto = { + id: string; + listId: string; + text: string; + done: boolean; + sortOrder: number; +}; + +export type TodoListDto = { + id: string; + label: string; + createdAt: string; + items: TodoItemDto[]; +}; + +export type CreateTodoListPayload = { + label: string; +}; + +export type UpdateTodoListPayload = { + label?: string; +}; + +export type CreateTodoItemPayload = { + listId: string; + text: string; + sortOrder?: number; +}; + +export type UpdateTodoItemPayload = { + text?: string; + done?: boolean; + sortOrder?: number; +}; + +type TodoItemDtoRaw = { + id?: string; + listId?: string; + text?: string; + done?: boolean; + sortOrder?: number; + Id?: string; + ListId?: string; + Text?: string; + Done?: boolean; + SortOrder?: number; +}; + +type TodoListDtoRaw = { + id?: string; + label?: string; + createdAt?: string; + items?: TodoItemDtoRaw[]; + Id?: string; + Label?: string; + CreatedAt?: string; + Items?: TodoItemDtoRaw[]; +}; + +function normalizeItem(raw: TodoItemDtoRaw): TodoItemDto { + return { + id: pickCase(raw, "id", "Id", ""), + listId: pickCase(raw, "listId", "ListId", ""), + text: pickCase(raw, "text", "Text", ""), + done: pickCase(raw, "done", "Done", false), + sortOrder: pickCase(raw, "sortOrder", "SortOrder", 0) + }; +} + +function normalizeList(raw: TodoListDtoRaw): TodoListDto { + const rawItems = pickCase(raw, "items", "Items", [] as TodoItemDtoRaw[]); + return { + id: pickCase(raw, "id", "Id", ""), + label: pickCase(raw, "label", "Label", ""), + createdAt: pickCase(raw, "createdAt", "CreatedAt", ""), + items: rawItems.map(normalizeItem) + }; +} + +export async function listTodoLists(): Promise { + const data = await sendCommand({ + action: "todos.list" + }); + return data.map(normalizeList).filter((item) => Boolean(item.id)); +} + +export async function getTodoList(id: string): Promise { + const data = await sendCommand({ + action: "todos.get", + id + }); + if (!data) return null; + const normalized = normalizeList(data); + return normalized.id ? normalized : null; +} + +export async function createTodoList(payload: CreateTodoListPayload): Promise { + const data = await sendCommand({ + action: "todos.create", + payload + }); + return normalizeList(data); +} + +export function updateTodoList(id: string, payload: UpdateTodoListPayload): Promise { + return sendCommand({ + action: "todos.update", + id, + payload + }); +} + +export function deleteTodoList(id: string): Promise { + return sendCommand({ + action: "todos.delete", + id + }); +} + +export async function createTodoItem(payload: CreateTodoItemPayload): Promise { + const data = await sendCommand({ + action: "todos.items.create", + payload + }); + return normalizeItem(data); +} + +export function updateTodoItem(id: string, payload: UpdateTodoItemPayload): Promise { + return sendCommand({ + action: "todos.items.update", + id, + payload + }); +} + +export function deleteTodoItem(id: string): Promise { + return sendCommand({ + action: "todos.items.delete", + id + }); +} diff --git a/Journal.App/src/lib/backend/types.ts b/Journal.App/src/lib/backend/types.ts new file mode 100644 index 0000000..87644cf --- /dev/null +++ b/Journal.App/src/lib/backend/types.ts @@ -0,0 +1,13 @@ +export type BackendCommand = { + action: string; + correlationId?: string; + id?: string; + type?: string; + tag?: string; + payload?: unknown; +}; + +export type BackendOk = { ok: true; data: T }; +export type BackendErr = { ok: false; error: string }; +export type BackendResponse = BackendOk | BackendErr; + diff --git a/Journal.App/src/lib/components/AppModal.svelte b/Journal.App/src/lib/components/AppModal.svelte new file mode 100644 index 0000000..2ced0ef --- /dev/null +++ b/Journal.App/src/lib/components/AppModal.svelte @@ -0,0 +1,158 @@ + + + + +{#if open} + +{/if} + + diff --git a/Journal.App/src/lib/components/CalendarWidget.svelte b/Journal.App/src/lib/components/CalendarWidget.svelte new file mode 100644 index 0000000..ae436a9 --- /dev/null +++ b/Journal.App/src/lib/components/CalendarWidget.svelte @@ -0,0 +1,260 @@ + + +
+
+ + +
+

{monthLabel}

+ {currentYear} +
+ + +
+ +
+ {#each weekdays as weekday} + {weekday} + {/each} +
+ +
+ {#each cells as cell} + + {/each} +
+
+ + diff --git a/Journal.App/src/lib/components/EditorPanel.svelte b/Journal.App/src/lib/components/EditorPanel.svelte new file mode 100644 index 0000000..b58a529 --- /dev/null +++ b/Journal.App/src/lib/components/EditorPanel.svelte @@ -0,0 +1,339 @@ + + +
+ {#if showLinkedBackButton} +
+ +
+ {/if} + + {#if activeSection === "calendar"} +
+
+

Filtered Entries

+
+ {#if calendarBusy} +

Loading timeline...

+ {:else if calendarError} +

{calendarError}

+ {:else if calendarItems.length === 0} +

No entries matched the current filters.

+ {:else} +
    + {#each calendarCards as item} +
  • + +
  • + {/each} +
+ {/if} +
+ {:else if !openDocumentId} +
+ edit_note +

Select or create an item to get started

+
+ {:else if activeSection === "fragments"} + + {:else if activeSection === "todos"} + + {:else if activeSection === "lists"} + + {:else} + + {/if} +
+ + diff --git a/Journal.App/src/lib/components/Navbar.svelte b/Journal.App/src/lib/components/Navbar.svelte new file mode 100644 index 0000000..a614253 --- /dev/null +++ b/Journal.App/src/lib/components/Navbar.svelte @@ -0,0 +1,183 @@ + + + + + diff --git a/Journal.App/src/lib/components/SidePanel.svelte b/Journal.App/src/lib/components/SidePanel.svelte new file mode 100644 index 0000000..8a82600 --- /dev/null +++ b/Journal.App/src/lib/components/SidePanel.svelte @@ -0,0 +1,1278 @@ + + +
+
+

{panelTitle}

+
+ {#if activeSection === "calendar"} + + {/if} + {#if activeSection === "entries"} + + + {/if} + +
+
+ + {#if isCalendarSection} +
+
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ + +
+ +
+

Saved Views

+
+ {#each builtInViews as view} + + {/each} + +
+ {#if showSaveViewInput} +
+ { + if (event.key === "Enter") saveCurrentView(); + if (event.key === "Escape") { + showSaveViewInput = false; + saveViewName = ""; + } + }} + on:blur={saveCurrentView} + /> +
+ {/if} + {#if calendarSavedViews.length > 0} +
    + {#each calendarSavedViews as view} +
  • + + +
  • + {/each} +
+ {/if} +
+
+ + + +
+

{calendarMonthLabel} {calendarYear} Timeline

+

Last refreshed: {calendarLastRefreshedAt || "Not yet"}

+
+ {:else} + + + {#if showNewItemInput} +
+ +
+ {/if} + + {#if activeSection === "entries"} +
+

Entries

+ {#if $entriesBusyStore} +

Loading entries...

+ {:else} +
    + {#each entryItems as item} +
  • + +
    + + +
    +
  • + {/each} +
+ {#if !entryItems.length} +

No entries found.

+ {/if} + {/if} +
+ +
+

Templates

+ {#if templatesBusy} +

Loading templates...

+ {:else} +
    + {#each allTemplateItems as item} +
  • + +
    + + +
    +
  • + {/each} +
+ {#if !allTemplateItems.length} +

No templates found.

+ {/if} + {/if} + {#if templateError} +

{templateError}

+ {/if} +
+ {:else} +
    + {#each items as item} +
  • + + {#if showItemActions} +
    + + +
    + {/if} +
  • + {/each} +
+ {/if} + {/if} +
+ + + diff --git a/Journal.App/src/lib/components/editor/FragmentEditor.svelte b/Journal.App/src/lib/components/editor/FragmentEditor.svelte new file mode 100644 index 0000000..163e54c --- /dev/null +++ b/Journal.App/src/lib/components/editor/FragmentEditor.svelte @@ -0,0 +1,406 @@ + + +
+ {#if fragmentMode === "view"} +
+ {@html renderMarkdown(openDocumentContent)} +
+ {:else} +
+

{fragmentMode === "create" ? "New Fragment" : "Edit Fragment"}

+ +
+ + {#if fragmentType === customTypeValue} + + {:else} + + {/if} +
+
+ + +
+ +
+ + +
+
+ {/if} +
+ + diff --git a/Journal.App/src/lib/components/editor/ListEditor.svelte b/Journal.App/src/lib/components/editor/ListEditor.svelte new file mode 100644 index 0000000..5f34b21 --- /dev/null +++ b/Journal.App/src/lib/components/editor/ListEditor.svelte @@ -0,0 +1,278 @@ + + +
+
+
+ + +
+ +
    + {#each items as item} +
  • + {#if editingItemId === item.id} + { + if (event.key === "Enter") saveEditItem(); + if (event.key === "Escape") cancelEditItem(); + }} + /> +
    + + +
    + {:else} + {item.text} +
    + + +
    + {/if} +
  • + {/each} +
+
+
+ + diff --git a/Journal.App/src/lib/components/editor/MarkdownEditor.svelte b/Journal.App/src/lib/components/editor/MarkdownEditor.svelte new file mode 100644 index 0000000..10b9336 --- /dev/null +++ b/Journal.App/src/lib/components/editor/MarkdownEditor.svelte @@ -0,0 +1,575 @@ + + +
+

{editorTitle}

+
+ +
+ {#if !previewOnly} + void applyTemplateByPath(filePath)} + onAttachFragment={(option) => attachReference("Fragment", option)} + onAttachList={(option) => attachReference("List", option)} + onAttachTodo={(option) => attachReference("To-Do", option)} + onBold={() => applyWrap("**")} + onItalic={() => applyWrap("*")} + onLink={insertLink} + onToggleUl={() => toggleListMode("ul")} + onToggleOl={() => toggleListMode("ol")} + onCode={() => applyWrap("`")} + /> + {#if templateError} +

{templateError}

+ {/if} + {/if} + +
+ {#if previewOnly} +
+ {@html renderedHtml} +
+ {:else} + + {/if} +
+
+ + diff --git a/Journal.App/src/lib/components/editor/MarkdownToolbar.svelte b/Journal.App/src/lib/components/editor/MarkdownToolbar.svelte new file mode 100644 index 0000000..a45e300 --- /dev/null +++ b/Journal.App/src/lib/components/editor/MarkdownToolbar.svelte @@ -0,0 +1,236 @@ + + +
+
+ + {#if isEntryDocument} + + + + + + + + {/if} +
+ +
+ + + + + + +
+
+ + diff --git a/Journal.App/src/lib/components/editor/TodoEditor.svelte b/Journal.App/src/lib/components/editor/TodoEditor.svelte new file mode 100644 index 0000000..47c00f7 --- /dev/null +++ b/Journal.App/src/lib/components/editor/TodoEditor.svelte @@ -0,0 +1,306 @@ + + +
+
+
+ + +
+ +
    + {#each todoItems as todo} +
  • + + + {#if editingTodoId === todo.id} + { + if (event.key === "Enter") saveEditTodo(); + if (event.key === "Escape") cancelEditTodo(); + }} + /> +
    + + +
    + {:else} + {todo.text} +
    + + +
    + {/if} +
  • + {/each} +
+
+
+ + diff --git a/Journal.App/src/lib/runtime/invoke.ts b/Journal.App/src/lib/runtime/invoke.ts new file mode 100644 index 0000000..200bb40 --- /dev/null +++ b/Journal.App/src/lib/runtime/invoke.ts @@ -0,0 +1,150 @@ +import type { BackendCommand } from "$lib/backend/types"; + +type InvokeArgs = Record | undefined; + +type WindowWithTauri = Window & { + __TAURI_INTERNALS__?: unknown; +}; + +type UiSettingsPayload = { + tags?: string[]; + fragmentTypes?: string[]; + defaultStartupView?: string; +}; + +type FetchJsonOptions = { + keepalive?: boolean; +}; + +const UI_SETTINGS_KEY = "journal.ui.settings"; + +function normalizedApiBase(): string { + const configured = import.meta.env.VITE_JOURNAL_API_BASE?.trim(); + if (!configured) { + return "/api"; + } + + return configured.endsWith("/") ? configured.slice(0, -1) : configured; +} + +export function isTauriRuntime(): boolean { + if (typeof window === "undefined") { + return false; + } + + return Object.prototype.hasOwnProperty.call(window as WindowWithTauri, "__TAURI_INTERNALS__"); +} + +function readUiSettingsFromLocalStorage(): UiSettingsPayload { + if (typeof window === "undefined") { + return {}; + } + + const raw = window.localStorage.getItem(UI_SETTINGS_KEY); + if (!raw) { + return {}; + } + + try { + const parsed = JSON.parse(raw) as UiSettingsPayload; + return { + tags: Array.isArray(parsed.tags) ? parsed.tags : undefined, + fragmentTypes: Array.isArray(parsed.fragmentTypes) ? parsed.fragmentTypes : undefined, + defaultStartupView: typeof parsed.defaultStartupView === "string" ? parsed.defaultStartupView : undefined + }; + } catch { + return {}; + } +} + +function writeUiSettingsToLocalStorage(payload: UiSettingsPayload): void { + if (typeof window === "undefined") { + return; + } + + const safePayload: UiSettingsPayload = { + tags: Array.isArray(payload.tags) ? payload.tags : undefined, + fragmentTypes: Array.isArray(payload.fragmentTypes) ? payload.fragmentTypes : undefined, + defaultStartupView: typeof payload.defaultStartupView === "string" ? payload.defaultStartupView : undefined + }; + + window.localStorage.setItem(UI_SETTINGS_KEY, JSON.stringify(safePayload)); +} + +async function fetchJson(path: string, init: RequestInit = {}, options: FetchJsonOptions = {}): Promise { + const response = await fetch(`${normalizedApiBase()}${path}`, { + ...init, + keepalive: options.keepalive === true, + headers: { + "Content-Type": "application/json", + ...(init.headers ?? {}) + } + }); + + if (!response.ok) { + const text = await response.text(); + throw new Error(text || `Request failed (${response.status})`); + } + + if (response.status === 204) { + return undefined as T; + } + + return (await response.json()) as T; +} + +export async function invoke(command: string, args?: InvokeArgs): Promise { + if (isTauriRuntime()) { + const tauriCore = await import("@tauri-apps/api/core"); + return tauriCore.invoke(command, args); + } + + switch (command) { + case "sidecar_command": { + const envelope = args?.command; + if (!envelope || typeof envelope !== "object") { + throw new Error("Missing command payload."); + } + + const keepalive = args?.keepalive === true; + + return fetchJson( + "/command", + { + method: "POST", + body: JSON.stringify(envelope as BackendCommand) + }, + { keepalive } + ); + } + case "get_sidecar_root": + return fetchJson("/sidecar/root"); + case "set_sidecar_root": { + const path = typeof args?.path === "string" ? args.path : ""; + return fetchJson("/sidecar/root", { + method: "POST", + body: JSON.stringify({ path }) + }); + } + case "get_ui_settings": + return readUiSettingsFromLocalStorage() as T; + case "set_ui_settings": { + const tags = Array.isArray(args?.tags) ? (args?.tags as string[]) : undefined; + const fragmentTypes = + Array.isArray(args?.fragmentTypes) ? (args?.fragmentTypes as string[]) : + Array.isArray(args?.fragment_types) ? (args?.fragment_types as string[]) : + undefined; + const defaultStartupView = + typeof args?.defaultStartupView === "string" ? args.defaultStartupView : + typeof args?.default_startup_view === "string" ? args.default_startup_view : + undefined; + + writeUiSettingsToLocalStorage({ tags, fragmentTypes, defaultStartupView }); + return undefined as T; + } + case "shutdown": + return undefined as T; + default: + throw new Error(`Unsupported command in web runtime: ${command}`); + } +} diff --git a/Journal.App/src/lib/stores/entries.ts b/Journal.App/src/lib/stores/entries.ts new file mode 100644 index 0000000..8b11d85 --- /dev/null +++ b/Journal.App/src/lib/stores/entries.ts @@ -0,0 +1,185 @@ +import { get, writable } from "svelte/store"; +import { + deleteEntry as deleteEntryCommand, + listEntries as listEntriesCommand, + loadEntry as loadEntryCommand, + saveEntry as saveEntryCommand, + searchEntries as searchEntriesCommand, + type EntryListItemDto, + type EntrySearchRequestDto +} from "$lib/backend/entries"; + +export type EntryItem = { + id: string; + label: string; + initialContent: string; + filePath?: string; + date?: string; +}; + +const initialEntries: EntryItem[] = []; + +export const entriesStore = writable(initialEntries); +export const entriesBusyStore = writable(false); + +function toStoreId(filePath: string): string { + return `entries/file/${encodeURIComponent(filePath)}`; +} + +function toBackendPath(id: string): string | null { + const prefix = "entries/file/"; + if (!id.startsWith(prefix)) return null; + const encoded = id.slice(prefix.length).trim(); + if (!encoded) return null; + + try { + const decoded = decodeURIComponent(encoded); + return decoded || null; + } catch { + return null; + } +} + +function toLabel(fileName: string): string { + const normalized = fileName.trim(); + if (!normalized) return "Untitled Entry"; + return normalized.replace(/\.md$/i, ""); +} + +function upsertById(items: EntryItem[], next: EntryItem): EntryItem[] { + const idx = items.findIndex((item) => item.id === next.id); + if (idx === -1) return [next, ...items]; + const clone = [...items]; + clone[idx] = next; + return clone; +} + +function fromListDto(dto: EntryListItemDto): EntryItem { + return { + id: toStoreId(dto.filePath), + label: toLabel(dto.fileName), + initialContent: "", + filePath: dto.filePath + }; +} + +function fromLoadResult(result: Awaited>): EntryItem { + return { + id: toStoreId(result.filePath), + label: toLabel(result.fileName), + initialContent: result.entry.rawContent, + filePath: result.filePath, + date: result.entry.date + }; +} + +export function getDefaultEntry(items: EntryItem[]): EntryItem | undefined { + return items[0]; +} + +export function createEntryDraft(): EntryItem { + const id = `entries/draft-${Date.now()}`; + return { + id, + label: "Untitled Entry", + initialContent: "# Untitled Entry\n\nStart writing..." + }; +} + +export async function hydrateEntries(dataDirectory?: string): Promise { + entriesBusyStore.set(true); + try { + const items = await listEntriesCommand(dataDirectory); + const mapped = items.map(fromListDto); + entriesStore.set(mapped); + } catch (error) { + console.error("[entries] hydrate:error", error); + throw error; + } finally { + entriesBusyStore.set(false); + } +} + +export async function loadEntryByStoreId(storeId: string): Promise { + const filePath = toBackendPath(storeId); + if (!filePath) return null; + + try { + const loaded = await loadEntryCommand(filePath); + const item = fromLoadResult(loaded); + entriesStore.update((items) => upsertById(items, item)); + return item; + } catch (error) { + console.error("[entries] load:error", { storeId, filePath, error }); + throw error; + } +} + +export async function saveEntryFromStore(storeId: string, content: string, mode?: string): Promise { + const trimmed = content?.trim(); + if (!trimmed) return null; + + const existingPath = toBackendPath(storeId); + let payload: { content: string; filePath?: string; mode?: string; fileName?: string }; + + if (existingPath) { + payload = { content: trimmed, filePath: existingPath, mode }; + } else { + const draft = get(entriesStore).find((item) => item.id === storeId); + payload = { content: trimmed, mode, fileName: draft?.label }; + } + try { + const saved = await saveEntryCommand(payload); + const loaded = await loadEntryCommand(saved.filePath); + const item = fromLoadResult(loaded); + entriesStore.update((items) => { + const filtered = existingPath ? items : items.filter((i) => i.id !== storeId); + return upsertById(filtered, item); + }); + return item; + } catch (error) { + console.error("[entries] save:error", { storeId, error }); + throw error; + } +} + +export async function searchEntriesAsItems(payload: EntrySearchRequestDto): Promise { + const results = await searchEntriesCommand(payload); + const dataDirectory = payload.dataDirectory?.trim() ?? ""; + const separator = dataDirectory.includes("\\") ? "\\" : "/"; + const basePath = dataDirectory.replace(/[\\/]+$/, ""); + const mapped = results.map((result) => ({ + id: basePath + ? toStoreId(`${basePath}${separator}${result.fileName}`) + : `entries/search/${encodeURIComponent(result.fileName)}`, + label: toLabel(result.fileName), + initialContent: result.entry.rawContent, + filePath: basePath ? `${basePath}${separator}${result.fileName}` : undefined, + date: result.entry.date + })); + return mapped; +} + +export async function deleteEntryByStoreId(storeId: string): Promise { + if (storeId.startsWith("entries/draft-")) { + entriesStore.update((items) => items.filter((item) => item.id !== storeId)); + return true; + } + + const filePath = toBackendPath(storeId); + if (!filePath) return false; + + try { + const ok = await deleteEntryCommand(filePath); + if (!ok) return false; + entriesStore.update((items) => items.filter((item) => item.id !== storeId)); + return true; + } catch (error) { + console.error("[entries] delete:error", { storeId, error }); + return false; + } +} + +export function hasEntry(storeId: string): boolean { + return get(entriesStore).some((item) => item.id === storeId); +} diff --git a/Journal.App/src/lib/stores/fragments.ts b/Journal.App/src/lib/stores/fragments.ts new file mode 100644 index 0000000..2945308 --- /dev/null +++ b/Journal.App/src/lib/stores/fragments.ts @@ -0,0 +1,215 @@ +import { get, writable } from "svelte/store"; +import { + createFragment as createFragmentCommand, + deleteFragment as deleteFragmentCommand, + listFragments, + updateFragment as updateFragmentCommand, + type FragmentDto +} from "$lib/backend/fragments"; + +export type FragmentItem = { + id: string; + label: string; + initialContent: string; +}; + +export type ParsedFragment = { + title: string; + type: string; + tags: string[]; + body: string; +}; + +const initialFragments: FragmentItem[] = []; + +export const fragmentsStore = writable(initialFragments); +export const fragmentsBusyStore = writable(false); + +function toStoreId(id: string): string { + return `fragments/${id}`; +} + +function toBackendId(id: string): string | null { + const prefix = "fragments/"; + if (!id.startsWith(prefix)) return null; + const backendId = id.slice(prefix.length).trim(); + return backendId || null; +} + +function splitDescription(description: string): { title: string; body: string } { + const normalized = description.trim(); + if (!normalized) { + return { title: "Untitled Fragment", body: "" }; + } + + const separator = normalized.indexOf("\n\n"); + if (separator === -1) { + return { title: normalized, body: "" }; + } + + const title = normalized.slice(0, separator).trim() || "Untitled Fragment"; + const body = normalized.slice(separator + 2).trim(); + return { title, body }; +} + +function composeDescription(title: string, body: string): string { + const resolvedTitle = title.trim() || "Untitled Fragment"; + const resolvedBody = body.trim() || "Add details for this fragment."; + return `${resolvedTitle}\n\n${resolvedBody}`; +} + +function dtoToItem(dto: FragmentDto): FragmentItem { + const parsed = splitDescription(dto.description); + return { + id: toStoreId(dto.id), + label: parsed.title, + initialContent: serializeFragment({ + title: parsed.title, + type: dto.type, + tags: dto.tags ?? [], + body: parsed.body + }) + }; +} + +function upsertById(items: FragmentItem[], next: FragmentItem): FragmentItem[] { + const idx = items.findIndex((item) => item.id === next.id); + if (idx === -1) { + return [next, ...items]; + } + const clone = [...items]; + clone[idx] = next; + return clone; +} + +export function createFragmentId(title: string): string { + const slug = title + .trim() + .toLowerCase() + .replace(/[^a-z0-9]+/g, "-") + .replace(/^-+|-+$/g, "") + .slice(0, 40); + return `fragments/${slug || "fragment"}-${Date.now()}`; +} + +export function serializeFragment(payload: ParsedFragment): string { + const title = payload.title.trim() || "Untitled Fragment"; + const type = payload.type.trim(); + const tagsLine = payload.tags.length ? payload.tags.map((tag) => `#${tag}`).join(" ") : "(none)"; + const body = payload.body.trim() || "Add details for this fragment."; + return `# ${title}\n\nType: ${type}\nTags: ${tagsLine}\n\n${body}`; +} + +export function parseFragmentContent(content: string, fallbackTitle = "Untitled Fragment"): ParsedFragment { + const headingMatch = content.match(/^#\s+(.+)$/m); + const typeMatch = content.match(/^Type:\s*(.+)$/m); + const tagsMatch = content.match(/^Tags:\s*(.+)$/m); + const bodyMatch = content.match(/^#.*\n\nType:.*\nTags:.*\n\n([\s\S]*)$/); + + const rawTags = tagsMatch?.[1]?.trim() ?? "(none)"; + const tags = + rawTags.toLowerCase() === "(none)" + ? [] + : rawTags + .split(/\s+/) + .map((tag) => tag.replace(/^#/, "").trim()) + .filter(Boolean); + + return { + title: headingMatch?.[1]?.trim() || fallbackTitle, + type: typeMatch?.[1]?.trim() || "", + tags, + body: bodyMatch?.[1]?.trim() || "" + }; +} + +export function createFragmentDraft(): FragmentItem { + const id = `fragments/new-${Date.now()}`; + return { + id, + label: "New Fragment", + initialContent: "# New Fragment\n\nType: \nTags: (none)\n\n" + }; +} + +export function createFragmentItem(title: string, content: string): FragmentItem { + return { + id: createFragmentId(title), + label: title.trim() || "Untitled Fragment", + initialContent: content + }; +} + +export function updateFragmentItem(items: FragmentItem[], id: string, title: string, content: string): FragmentItem[] { + return items.map((item) => + item.id === id + ? { ...item, label: title.trim() || "Untitled Fragment", initialContent: content } + : item + ); +} + +export function prependFragmentItem(items: FragmentItem[], item: FragmentItem): FragmentItem[] { + return [item, ...items]; +} + +export function removeFragmentItem(items: FragmentItem[], id: string): FragmentItem[] { + return items.filter((item) => item.id !== id); +} + +export async function hydrateFragments(): Promise { + fragmentsBusyStore.set(true); + try { + const items = await listFragments(); + fragmentsStore.set(items.map(dtoToItem)); + } catch (error) { + console.error("[fragments] hydrate:error", error); + throw error; + } finally { + fragmentsBusyStore.set(false); + } +} + +export async function createFragmentFromParsed(payload: ParsedFragment): Promise { + const created = await createFragmentCommand({ + type: payload.type.trim(), + description: composeDescription(payload.title, payload.body), + tags: payload.tags + }); + const item = dtoToItem(created); + fragmentsStore.update((items) => prependFragmentItem(items, item)); + return item; +} + +export async function updateFragmentFromParsed(storeId: string, payload: ParsedFragment): Promise { + const backendId = toBackendId(storeId); + if (!backendId) return null; + + const ok = await updateFragmentCommand(backendId, { + type: payload.type.trim(), + description: composeDescription(payload.title, payload.body), + tags: payload.tags + }); + if (!ok) return null; + + const item: FragmentItem = { + id: storeId, + label: payload.title.trim() || "Untitled Fragment", + initialContent: serializeFragment(payload) + }; + fragmentsStore.update((items) => upsertById(items, item)); + return item; +} + +export async function deleteFragmentByStoreId(storeId: string): Promise { + const backendId = toBackendId(storeId); + if (!backendId) return false; + + const ok = await deleteFragmentCommand(backendId); + if (!ok) return false; + fragmentsStore.update((items) => removeFragmentItem(items, storeId)); + return true; +} + +export function hasFragment(storeId: string): boolean { + return get(fragmentsStore).some((item) => item.id === storeId); +} diff --git a/Journal.App/src/lib/stores/lists.ts b/Journal.App/src/lib/stores/lists.ts new file mode 100644 index 0000000..6213776 --- /dev/null +++ b/Journal.App/src/lib/stores/lists.ts @@ -0,0 +1,118 @@ +import { get, writable } from "svelte/store"; +import { + createList as createListCommand, + deleteList as deleteListCommand, + listLists, + updateList as updateListCommand, + type ListDocumentDto +} from "$lib/backend/lists"; + +export type ListItem = { + id: string; + label: string; + initialContent: string; +}; + +export const listsStore = writable([]); +export const listsBusyStore = writable(false); + +function toStoreId(id: string): string { + return `lists/${id}`; +} + +function toBackendId(id: string): string | null { + const prefix = "lists/"; + if (!id.startsWith(prefix)) return null; + const backendId = id.slice(prefix.length).trim(); + return backendId || null; +} + +function dtoToItem(dto: ListDocumentDto): ListItem { + return { + id: toStoreId(dto.id), + label: dto.label, + initialContent: dto.content || `# ${dto.label}\n\n` + }; +} + +function upsertById(items: ListItem[], next: ListItem): ListItem[] { + const idx = items.findIndex((item) => item.id === next.id); + if (idx === -1) return [next, ...items]; + const clone = [...items]; + clone[idx] = next; + return clone; +} + +export function createListDraft(): ListItem { + const id = `lists/draft-${Date.now()}`; + return { + id, + label: "Untitled List", + initialContent: "# Untitled List\n\n- Item 1" + }; +} + +export async function hydrateLists(): Promise { + listsBusyStore.set(true); + try { + const items = await listLists(); + listsStore.set(items.map(dtoToItem)); + } catch (error) { + console.error("[lists] hydrate:error", error); + throw error; + } finally { + listsBusyStore.set(false); + } +} + +export async function createListFromLabel(label: string, content = ""): Promise { + const resolvedLabel = label.trim() || "Untitled List"; + const resolvedContent = content || `# ${resolvedLabel}\n\n`; + const created = await createListCommand({ label: resolvedLabel, content: resolvedContent }); + const item = dtoToItem(created); + listsStore.update((items) => [item, ...items]); + return item; +} + +export async function updateListByStoreId( + storeId: string, + label?: string, + content?: string +): Promise { + const backendId = toBackendId(storeId); + if (!backendId) return false; + + const payload: { label?: string; content?: string } = {}; + if (label !== undefined) payload.label = label; + if (content !== undefined) payload.content = content; + + const ok = await updateListCommand(backendId, payload); + if (!ok) return false; + + listsStore.update((items) => + items.map((item) => + item.id === storeId + ? { + ...item, + label: label ?? item.label, + initialContent: content ?? item.initialContent + } + : item + ) + ); + return true; +} + +export async function deleteListByStoreId(storeId: string): Promise { + const backendId = toBackendId(storeId); + if (!backendId) return false; + + const ok = await deleteListCommand(backendId); + if (!ok) return false; + listsStore.update((items) => items.filter((item) => item.id !== storeId)); + return true; +} + +export function hasList(storeId: string): boolean { + return get(listsStore).some((item) => item.id === storeId); +} diff --git a/Journal.App/src/lib/stores/session.ts b/Journal.App/src/lib/stores/session.ts new file mode 100644 index 0000000..0d5c803 --- /dev/null +++ b/Journal.App/src/lib/stores/session.ts @@ -0,0 +1,34 @@ +import { writable, get } from "svelte/store"; + +const _password = writable(null); +const _unlocked = writable(false); + +export const vaultUnlocked = { subscribe: _unlocked.subscribe }; + +export function isVaultReady(): boolean { + return get(_unlocked); +} + +export function getSessionPassword(): string | null { + return get(_password); +} + +export function setVaultSession(password: string): void { + _password.set(password); + _unlocked.set(true); +} + +export function clearVaultSession(): void { + _password.set(null); + _unlocked.set(false); +} + +let _flushCallback: (() => Promise) | null = null; + +export function setFlushCallback(fn: () => Promise): void { + _flushCallback = fn; +} + +export async function flushBeforeClose(): Promise { + if (_flushCallback) await _flushCallback(); +} diff --git a/Journal.App/src/lib/stores/settings.ts b/Journal.App/src/lib/stores/settings.ts new file mode 100644 index 0000000..b9b705b --- /dev/null +++ b/Journal.App/src/lib/stores/settings.ts @@ -0,0 +1,160 @@ +import { writable } from "svelte/store"; +import { get } from "svelte/store"; +import { invoke } from "$lib/runtime/invoke"; + +const defaultTags = ["Personal", "Work", "Ideas", "Journal"]; +const defaultFragmentTypes = ["Quote", "Snippet", "Reference"]; +const startupViews = ["entries", "calendar", "fragments", "todos", "lists"] as const; +const defaultStartupView = "entries"; +export type StartupView = typeof startupViews[number]; + +export const settingsTags = writable([...defaultTags]); +export const settingsFragmentTypes = writable([...defaultFragmentTypes]); +export const settingsDefaultStartupView = writable(defaultStartupView); + +let hydrationComplete = false; +let hydrating = false; + +type UiSettingsPayload = { + tags?: string[]; + fragmentTypes?: string[]; + defaultStartupView?: string; +}; + +function normalize(value: string): string { + return value.trim().toLowerCase(); +} + +function hasDuplicate(values: string[], candidate: string, excludeIndex?: number): boolean { + const normalized = normalize(candidate); + return values.some((value, index) => index !== excludeIndex && normalize(value) === normalized); +} + +function normalizeValues(values: string[], fallback: string[]): string[] { + const seen = new Set(); + const result: string[] = []; + for (const value of values) { + const trimmed = value.trim(); + if (!trimmed) continue; + const key = normalize(trimmed); + if (seen.has(key)) continue; + seen.add(key); + result.push(trimmed); + } + return result.length ? result : [...fallback]; +} + +function normalizeStartupView(value: string | undefined): StartupView { + const normalized = (value ?? "").trim().toLowerCase(); + if (startupViews.includes(normalized as StartupView)) { + return normalized as StartupView; + } + return defaultStartupView; +} + +export async function hydrateUiSettings(): Promise { + if (hydrating || hydrationComplete) return; + hydrating = true; + try { + const payload = await invoke("get_ui_settings"); + settingsTags.set(normalizeValues(payload.tags ?? [], defaultTags)); + settingsFragmentTypes.set(normalizeValues(payload.fragmentTypes ?? [], defaultFragmentTypes)); + settingsDefaultStartupView.set(normalizeStartupView(payload.defaultStartupView)); + } catch (error) { + console.error("[settings] hydrate failed", error); + } finally { + hydrating = false; + hydrationComplete = true; + } +} + +export async function persistUiSettings(): Promise { + const tags = normalizeValues(get(settingsTags), defaultTags); + const fragmentTypes = normalizeValues(get(settingsFragmentTypes), defaultFragmentTypes); + const startupView = normalizeStartupView(get(settingsDefaultStartupView)); + settingsTags.set(tags); + settingsFragmentTypes.set(fragmentTypes); + settingsDefaultStartupView.set(startupView); + + await invoke("set_ui_settings", { + tags, + fragmentTypes, + fragment_types: fragmentTypes, + defaultStartupView: startupView, + default_startup_view: startupView + }); +} + +function queuePersist(): void { + if (!hydrationComplete || hydrating) return; + void persistUiSettings().catch((error) => { + console.error("[settings] persist failed", error); + }); +} + +export function addSettingsTag(value: string): boolean { + const next = value.trim(); + if (!next) return false; + const tags = get(settingsTags); + if (hasDuplicate(tags, next)) return false; + settingsTags.set([...tags, next]); + queuePersist(); + return true; +} + +export function updateSettingsTag(index: number, value: string): boolean { + const next = value.trim(); + if (!next) return false; + const tags = get(settingsTags); + if (index < 0 || index >= tags.length) return false; + if (hasDuplicate(tags, next, index)) return false; + settingsTags.set(tags.map((tag, idx) => (idx === index ? next : tag))); + queuePersist(); + return true; +} + +export function removeSettingsTag(index: number): boolean { + const tags = get(settingsTags); + if (index < 0 || index >= tags.length) return false; + settingsTags.set(tags.filter((_, idx) => idx !== index)); + queuePersist(); + return true; +} + +export function addFragmentType(value: string): boolean { + const next = value.trim(); + if (!next) return false; + const types = get(settingsFragmentTypes); + if (hasDuplicate(types, next)) return false; + settingsFragmentTypes.set([...types, next]); + queuePersist(); + return true; +} + +export function updateFragmentType(index: number, value: string): boolean { + const next = value.trim(); + if (!next) return false; + const types = get(settingsFragmentTypes); + if (index < 0 || index >= types.length) return false; + if (hasDuplicate(types, next, index)) return false; + settingsFragmentTypes.set(types.map((type, idx) => (idx === index ? next : type))); + queuePersist(); + return true; +} + +export function removeFragmentType(index: number): boolean { + const types = get(settingsFragmentTypes); + if (index < 0 || index >= types.length) return false; + settingsFragmentTypes.set(types.filter((_, idx) => idx !== index)); + queuePersist(); + return true; +} + +export function setDefaultStartupView(value: string): boolean { + const next = normalizeStartupView(value); + if (get(settingsDefaultStartupView) === next) return false; + settingsDefaultStartupView.set(next); + queuePersist(); + return true; +} + diff --git a/Journal.App/src/lib/stores/todos.ts b/Journal.App/src/lib/stores/todos.ts new file mode 100644 index 0000000..20c4d43 --- /dev/null +++ b/Journal.App/src/lib/stores/todos.ts @@ -0,0 +1,267 @@ +import { get, writable } from "svelte/store"; +import { + createTodoItem as createTodoItemCommand, + createTodoList as createTodoListCommand, + deleteTodoItem as deleteTodoItemCommand, + deleteTodoList as deleteTodoListCommand, + listTodoLists, + updateTodoItem as updateTodoItemCommand, + updateTodoList as updateTodoListCommand, + type TodoListDto +} from "$lib/backend/todos"; + +// TodoItem keeps a numeric `id` for local array operations (used by EditorPanel) +// plus a `backendId` (guid string) for backend persistence. +export type TodoItem = { id: number; text: string; done: boolean; backendId?: string }; +export type TodoListMeta = { id: string; label: string; backendId?: string }; + +export const todoListsStore = writable([]); +export const todosStore = writable>({}); +export const todosBusyStore = writable(false); + +// ── ID helpers ─────────────────────────────────────────────────── + +function toStoreId(guid: string): string { + return `todos/${guid}`; +} + +function toBackendId(storeId: string): string | null { + const prefix = "todos/"; + if (!storeId.startsWith(prefix)) return null; + const backendId = storeId.slice(prefix.length).trim(); + return backendId || null; +} + +export function createTodoId(): number { + return Date.now() + Math.floor(Math.random() * 1000); +} + +// ── DTO mapping ────────────────────────────────────────────────── + +function dtoToMeta(dto: TodoListDto): TodoListMeta { + return { + id: toStoreId(dto.id), + label: dto.label, + backendId: dto.id + }; +} + +function dtoToItems(dto: TodoListDto): TodoItem[] { + return dto.items.map((item, index) => ({ + id: createTodoId() + index, + text: item.text, + done: item.done, + backendId: item.id + })); +} + +// ── Hydration ──────────────────────────────────────────────────── + +export async function hydrateTodos(): Promise { + todosBusyStore.set(true); + try { + const lists = await listTodoLists(); + + const metas: TodoListMeta[] = lists.map(dtoToMeta); + const items: Record = {}; + for (const dto of lists) { + items[toStoreId(dto.id)] = dtoToItems(dto); + } + + todoListsStore.set(metas); + todosStore.set(items); + } catch (error) { + console.error("[todos] hydrate:error", error); + throw error; + } finally { + todosBusyStore.set(false); + } +} + +// ── List CRUD ──────────────────────────────────────────────────── + +export async function createTodoListFromLabel( + label: string +): Promise<{ meta: TodoListMeta; items: TodoItem[] }> { + const resolvedLabel = label.trim() || "New List"; + const created = await createTodoListCommand({ label: resolvedLabel }); + + const meta = dtoToMeta(created); + todoListsStore.update((metas) => [meta, ...metas]); + todosStore.update((lists) => ({ ...lists, [meta.id]: [] })); + return { meta, items: [] }; +} + +export async function deleteTodoListByStoreId(storeId: string): Promise { + const backendId = toBackendId(storeId); + if (!backendId) return false; + + const ok = await deleteTodoListCommand(backendId); + if (!ok) return false; + + todoListsStore.update((metas) => metas.filter((m) => m.id !== storeId)); + todosStore.update((lists) => { + const { [storeId]: _, ...rest } = lists; + return rest; + }); + return true; +} + +// ── Item CRUD (backend-backed) ─────────────────────────────────── + +export async function addTodoItemBackend( + storeId: string, + text: string +): Promise { + const backendListId = toBackendId(storeId); + if (!backendListId || !text.trim()) return null; + + const items = get(todosStore)[storeId] ?? []; + const sortOrder = items.length; + + const created = await createTodoItemCommand({ + listId: backendListId, + text: text.trim(), + sortOrder + }); + + const item: TodoItem = { + id: createTodoId(), + text: created.text, + done: created.done, + backendId: created.id + }; + + todosStore.update((lists) => ({ + ...lists, + [storeId]: [item, ...(lists[storeId] ?? [])] + })); + return item; +} + +export async function toggleTodoItemBackend( + storeId: string, + localId: number +): Promise { + const items = get(todosStore)[storeId]; + const todo = items?.find((t) => t.id === localId); + if (!todo?.backendId) return false; + + const ok = await updateTodoItemCommand(todo.backendId, { done: !todo.done }); + if (!ok) return false; + + todosStore.update((lists) => ({ + ...lists, + [storeId]: (lists[storeId] ?? []).map((t) => + t.id === localId ? { ...t, done: !t.done } : t + ) + })); + return true; +} + +export async function updateTodoItemTextBackend( + storeId: string, + localId: number, + text: string +): Promise { + const items = get(todosStore)[storeId]; + const todo = items?.find((t) => t.id === localId); + if (!todo?.backendId || !text.trim()) return false; + + const ok = await updateTodoItemCommand(todo.backendId, { text: text.trim() }); + if (!ok) return false; + + todosStore.update((lists) => ({ + ...lists, + [storeId]: (lists[storeId] ?? []).map((t) => + t.id === localId ? { ...t, text: text.trim() } : t + ) + })); + return true; +} + +export async function removeTodoItemBackend( + storeId: string, + localId: number +): Promise { + const items = get(todosStore)[storeId]; + const todo = items?.find((t) => t.id === localId); + if (!todo?.backendId) return false; + + const ok = await deleteTodoItemCommand(todo.backendId); + if (!ok) return false; + + todosStore.update((lists) => ({ + ...lists, + [storeId]: (lists[storeId] ?? []).filter((t) => t.id !== localId) + })); + return true; +} + +// ── Pure helpers (used by EditorPanel for local state) ─────────── + +export function serializeTodoList(title: string, todos: TodoItem[]): string { + const heading = title?.trim() ? `# ${title}` : "# To-Do List"; + const lines = todos.map((todo) => `- [${todo.done ? "x" : " "}] ${todo.text}`); + return `${heading}\n\n${lines.join("\n")}`; +} + +export function parseTodoList(content: string): TodoItem[] { + const lines = content.replace(/\r\n/g, "\n").split("\n"); + const parsed: TodoItem[] = []; + for (const line of lines) { + const match = line.match(/^- \[( |x)\]\s+(.+)$/i); + if (!match) continue; + parsed.push({ + id: createTodoId(), + text: match[2].trim(), + done: match[1].toLowerCase() === "x" + }); + } + return parsed; +} + +export function getOrCreateTodoList( + lists: Record, + documentId: string, + fallbackContent: string +): { lists: Record; todos: TodoItem[] } { + const existing = lists[documentId]; + if (existing) { + return { lists, todos: existing }; + } + const parsed = parseTodoList(fallbackContent); + return { lists: { ...lists, [documentId]: parsed }, todos: parsed }; +} + +export function setTodoList( + lists: Record, + documentId: string, + todos: TodoItem[] +): Record { + return { ...lists, [documentId]: todos }; +} + +export function addTodoItem(todos: TodoItem[], text: string): TodoItem[] { + return [{ id: createTodoId(), text: text.trim(), done: false }, ...todos]; +} + +export function toggleTodoItem(todos: TodoItem[], id: number): TodoItem[] { + return todos.map((todo) => (todo.id === id ? { ...todo, done: !todo.done } : todo)); +} + +export function updateTodoItemText(todos: TodoItem[], id: number, text: string): TodoItem[] { + return todos.map((todo) => (todo.id === id ? { ...todo, text: text.trim() } : todo)); +} + +export function removeTodoItem(todos: TodoItem[], id: number): TodoItem[] { + return todos.filter((todo) => todo.id !== id); +} + +export function createTodoListDraft(): { meta: TodoListMeta; items: TodoItem[] } { + const id = `todos/draft-${Date.now()}`; + return { + meta: { id, label: "New List" }, + items: [] + }; +} diff --git a/Journal.App/src/lib/utils/markdown.ts b/Journal.App/src/lib/utils/markdown.ts new file mode 100644 index 0000000..a1377c7 --- /dev/null +++ b/Journal.App/src/lib/utils/markdown.ts @@ -0,0 +1,119 @@ +export function escapeHtml(input: string): string { + return input + .replaceAll("&", "&") + .replaceAll("<", "<") + .replaceAll(">", ">") + .replaceAll('"', """) + .replaceAll("'", "'"); +} + +export function parseInline(input: string): string { + let value = escapeHtml(input); + value = value.replace(/`([^`]+)`/g, "$1"); + value = value.replace(/\*\*([^*]+)\*\*/g, "$1"); + value = value.replace(/\*([^*]+)\*/g, "$1"); + value = value.replace( + /\[([^\]]+)\]\((journal:[^\s)]+)\)/g, + '$1' + ); + value = value.replace( + /\[([^\]]+)\]\((https?:\/\/[^\s)]+)\)/g, + '$1' + ); + return value; +} + +export function renderMarkdown(markdown: string): string { + const lines = markdown.replace(/\r\n/g, "\n").split("\n"); + const output: string[] = []; + let i = 0; + let inCode = false; + let codeLines: string[] = []; + + while (i < lines.length) { + const line = lines[i]; + const trimmed = line.trim(); + + if (trimmed.startsWith("```")) { + if (inCode) { + output.push(`
${escapeHtml(codeLines.join("\n"))}
`); + codeLines = []; + inCode = false; + } else { + inCode = true; + } + i += 1; + continue; + } + + if (inCode) { + codeLines.push(line); + i += 1; + continue; + } + + if (!trimmed) { + i += 1; + continue; + } + + const heading = trimmed.match(/^(#{1,6})\s+(.*)$/); + if (heading) { + const level = heading[1].length; + output.push(`${parseInline(heading[2])}`); + i += 1; + continue; + } + + if (/^[-*+]\s+/.test(trimmed)) { + const items: string[] = []; + while (i < lines.length && /^[-*+]\s+/.test(lines[i].trim())) { + items.push(`
  • ${parseInline(lines[i].trim().replace(/^[-*+]\s+/, ""))}
  • `); + i += 1; + } + output.push(`
      ${items.join("")}
    `); + continue; + } + + if (/^\d+\.\s+/.test(trimmed)) { + const items: string[] = []; + while (i < lines.length && /^\d+\.\s+/.test(lines[i].trim())) { + items.push(`
  • ${parseInline(lines[i].trim().replace(/^\d+\.\s+/, ""))}
  • `); + i += 1; + } + output.push(`
      ${items.join("")}
    `); + continue; + } + + if (/^>\s+/.test(trimmed)) { + output.push(`
    ${parseInline(trimmed.replace(/^>\s+/, ""))}
    `); + i += 1; + continue; + } + + if (/^(-{3,}|\*{3,})$/.test(trimmed)) { + output.push("
    "); + i += 1; + continue; + } + + const paragraph: string[] = []; + while (i < lines.length && lines[i].trim()) { + paragraph.push(lines[i].trim()); + i += 1; + } + output.push(`

    ${parseInline(paragraph.join(" "))}

    `); + } + + if (inCode) { + output.push(`
    ${escapeHtml(codeLines.join("\n"))}
    `); + } + + return output.join(""); +} + +export function extractEditorTitle(markdown: string, fallback: string): string { + const firstLine = markdown.replace(/\r\n/g, "\n").split("\n")[0]?.trim() ?? ""; + const headingMatch = firstLine.match(/^#\s+(.+)$/); + return headingMatch ? headingMatch[1] : fallback; +} diff --git a/Journal.App/src/routes/+layout.svelte b/Journal.App/src/routes/+layout.svelte new file mode 100644 index 0000000..8e2ee39 --- /dev/null +++ b/Journal.App/src/routes/+layout.svelte @@ -0,0 +1,72 @@ + + + diff --git a/Journal.App/src/routes/+layout.ts b/Journal.App/src/routes/+layout.ts new file mode 100644 index 0000000..9d24899 --- /dev/null +++ b/Journal.App/src/routes/+layout.ts @@ -0,0 +1,5 @@ +// Tauri doesn't have a Node.js server to do proper SSR +// so we use adapter-static with a fallback to index.html to put the site in SPA mode +// See: https://svelte.dev/docs/kit/single-page-apps +// See: https://v2.tauri.app/start/frontend/sveltekit/ for more info +export const ssr = false; diff --git a/Journal.App/src/routes/+page.svelte b/Journal.App/src/routes/+page.svelte new file mode 100644 index 0000000..7ad2b5c --- /dev/null +++ b/Journal.App/src/routes/+page.svelte @@ -0,0 +1,575 @@ + + +
    + + {#if panelOpen} + { + calendarPanelState = state; + }} + /> + {/if} + +
    + + + + diff --git a/Journal.App/src/routes/settings/+page.svelte b/Journal.App/src/routes/settings/+page.svelte new file mode 100644 index 0000000..38490d7 --- /dev/null +++ b/Journal.App/src/routes/settings/+page.svelte @@ -0,0 +1,675 @@ + + +
    + + +
    +
    +
    +

    Settings

    +

    Configure app behavior and interface options.

    +
    + +
    + +
    +
    +
    +

    + + Startup +

    +
    + +
    + +
    +
    +

    + + Tags +

    +

    Add and manage tags used for notes and entries.

    +
    + +
    + event.key === "Enter" && addTag()} + /> + +
    + +
      + {#each $settingsTags as tag, index} +
    • + {#if editingTagIndex === index} + { + if (event.key === "Enter") saveEditTag(); + if (event.key === "Escape") cancelEditTag(); + }} + /> +
      + + +
      + {:else} + {tag} +
      + + +
      + {/if} +
    • + {/each} +
    +
    + +
    +
    +

    + + Fragment Types +

    +

    Configure custom fragment types for the Fragments section.

    +
    + +
    + event.key === "Enter" && addFragmentTypeLocal()} + /> + +
    + +
      + {#each $settingsFragmentTypes as type, index} +
    • + {#if editingFragmentTypeIndex === index} + { + if (event.key === "Enter") saveEditFragmentType(); + if (event.key === "Escape") cancelEditFragmentType(); + }} + /> +
      + + +
      + {:else} + {type} +
      + + +
      + {/if} +
    • + {/each} +
    +
    + +
    +
    +

    + + Sidecar +

    +

    Root directory containing the Journal.Sidecar project.

    +
    + +
    + event.key === "Enter" && saveSidecarRoot()} + /> + + {#if sidecarRootIsCustom} + + {/if} +
    + + {#if sidecarRootError} +

    {sidecarRootError}

    + {/if} +
    +
    +
    +
    + + + + + diff --git a/Journal.App/static/favicon.png b/Journal.App/static/favicon.png new file mode 100644 index 0000000..825b9e6 Binary files /dev/null and b/Journal.App/static/favicon.png differ diff --git a/Journal.App/static/style.css b/Journal.App/static/style.css new file mode 100644 index 0000000..6ee04e3 --- /dev/null +++ b/Journal.App/static/style.css @@ -0,0 +1,98 @@ +:root { + font-family: "Segoe UI Variable", "Segoe UI", Inter, Roboto, Helvetica, Arial, sans-serif; + font-size: 15px; + line-height: 1.45; + font-weight: 400; + + --zinc-50: #fafafa; + --zinc-100: #f4f4f5; + --zinc-200: #e4e4e7; + --zinc-300: #d4d4d8; + --zinc-400: #a1a1aa; + --zinc-500: #71717a; + --zinc-600: #52525b; + --zinc-700: #3f3f46; + --zinc-800: #27272a; + --zinc-900: #18181b; + --zinc-950: #09090b; + + --bg-app: var(--zinc-950); + --bg-navbar: var(--zinc-900); + --bg-panel: var(--zinc-800); + --bg-editor: var(--zinc-900); + --bg-hover: var(--zinc-800); + --bg-active: var(--zinc-700); + + --surface-1: var(--zinc-900); + --surface-2: var(--zinc-800); + --surface-3: var(--zinc-700); + + --border-soft: var(--zinc-700); + --border-strong: var(--zinc-600); + + --text-primary: var(--zinc-100); + --text-muted: var(--zinc-300); + --text-dim: var(--zinc-500); + --accent: var(--zinc-200); + + color: var(--text-primary); + background-color: var(--bg-app); + + font-synthesis: none; + text-rendering: optimizeLegibility; + -webkit-font-smoothing: antialiased; + -moz-osx-font-smoothing: grayscale; + -webkit-text-size-adjust: 100%; +} + +html, +body { + min-height: 100%; +} + +body { + background: radial-gradient(circle at 15% -10%, var(--zinc-800) 0%, var(--bg-app) 42%); + color: var(--text-primary); +} + +* { + margin: 0; + padding: 0; + box-sizing: border-box; + font-family: inherit; +} + +button, +input { + border: none; + outline: none; + background: none; + color: inherit; +} + +.app-shell { + min-height: 100vh; + display: grid; + grid-template-columns: 72px 300px minmax(0, 1fr); +} + +.app-shell.panel-closed { + grid-template-columns: 72px minmax(0, 1fr); +} + +@media (max-width: 980px) { + .app-shell { + grid-template-columns: 64px minmax(0, 1fr); + grid-template-rows: 280px minmax(0, 1fr); + } + + .app-shell:not(.panel-closed) > .side-panel { + grid-column: 2; + grid-row: 1; + } + + .app-shell:not(.panel-closed) > .editor-panel { + grid-column: 2; + grid-row: 2; + } +} diff --git a/Journal.App/static/svelte.svg b/Journal.App/static/svelte.svg new file mode 100644 index 0000000..c5e0848 --- /dev/null +++ b/Journal.App/static/svelte.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/Journal.App/static/tauri.svg b/Journal.App/static/tauri.svg new file mode 100644 index 0000000..31b62c9 --- /dev/null +++ b/Journal.App/static/tauri.svg @@ -0,0 +1,6 @@ + + + + + + diff --git a/Journal.App/static/vite.svg b/Journal.App/static/vite.svg new file mode 100644 index 0000000..e7b8dfb --- /dev/null +++ b/Journal.App/static/vite.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/Journal.App/svelte.config.js b/Journal.App/svelte.config.js new file mode 100644 index 0000000..a7830ea --- /dev/null +++ b/Journal.App/svelte.config.js @@ -0,0 +1,18 @@ +// Tauri doesn't have a Node.js server to do proper SSR +// so we use adapter-static with a fallback to index.html to put the site in SPA mode +// See: https://svelte.dev/docs/kit/single-page-apps +// See: https://v2.tauri.app/start/frontend/sveltekit/ for more info +import adapter from "@sveltejs/adapter-static"; +import { vitePreprocess } from "@sveltejs/vite-plugin-svelte"; + +/** @type {import('@sveltejs/kit').Config} */ +const config = { + preprocess: vitePreprocess(), + kit: { + adapter: adapter({ + fallback: "index.html", + }), + }, +}; + +export default config; diff --git a/Journal.App/tsconfig.json b/Journal.App/tsconfig.json new file mode 100644 index 0000000..f4d0a0e --- /dev/null +++ b/Journal.App/tsconfig.json @@ -0,0 +1,19 @@ +{ + "extends": "./.svelte-kit/tsconfig.json", + "compilerOptions": { + "allowJs": true, + "checkJs": true, + "esModuleInterop": true, + "forceConsistentCasingInFileNames": true, + "resolveJsonModule": true, + "skipLibCheck": true, + "sourceMap": true, + "strict": true, + "moduleResolution": "bundler" + } + // Path aliases are handled by https://svelte.dev/docs/kit/configuration#alias + // except $lib which is handled by https://svelte.dev/docs/kit/configuration#files + // + // If you want to overwrite includes/excludes, make sure to copy over the relevant includes/excludes + // from the referenced tsconfig.json - TypeScript does not merge them in +} diff --git a/Journal.App/vite.config.js b/Journal.App/vite.config.js new file mode 100644 index 0000000..3ecfa0a --- /dev/null +++ b/Journal.App/vite.config.js @@ -0,0 +1,32 @@ +import { defineConfig } from "vite"; +import { sveltekit } from "@sveltejs/kit/vite"; + +// @ts-expect-error process is a nodejs global +const host = process.env.TAURI_DEV_HOST; + +// https://vite.dev/config/ +export default defineConfig(async () => ({ + plugins: [sveltekit()], + + // Vite options tailored for Tauri development and only applied in `tauri dev` or `tauri build` + // + // 1. prevent Vite from obscuring rust errors + clearScreen: false, + // 2. tauri expects a fixed port, fail if that port is not available + server: { + port: 1420, + strictPort: true, + host: host || false, + hmr: host + ? { + protocol: "ws", + host, + port: 1421, + } + : undefined, + watch: { + // 3. tell Vite to ignore watching `src-tauri` + ignored: ["**/src-tauri/**"], + }, + }, +})); diff --git a/Journal.Core/Dtos/AiDtos.cs b/Journal.Core/Dtos/AiDtos.cs new file mode 100644 index 0000000..964498e --- /dev/null +++ b/Journal.Core/Dtos/AiDtos.cs @@ -0,0 +1,7 @@ +namespace Journal.Core.Dtos; + +public sealed record AiHealthDto( + string Provider, + bool Enabled, + bool Healthy, + string Message); diff --git a/Journal.Core/Dtos/CommandDtos.cs b/Journal.Core/Dtos/CommandDtos.cs new file mode 100644 index 0000000..e84f832 --- /dev/null +++ b/Journal.Core/Dtos/CommandDtos.cs @@ -0,0 +1,41 @@ +namespace Journal.Core.Dtos; + +internal sealed record VaultInitializePayload(string Password, string VaultDirectory); +internal sealed record VaultPayload(string Password, string VaultDirectory, string DataDirectory, string? NowUtc = null); +internal sealed record ClearDataPayload(string DataDirectory); +internal sealed record EntryListPayload(string? DataDirectory = null); +internal sealed record EntryLoadPayload(string FilePath); +public sealed record EntrySavePayload(string Content, string? FilePath = null, string? Mode = null, string? FileName = null); +public sealed record EntryListItem(string FileName, string FilePath); +public sealed record EntryLoadResult(string FileName, string FilePath, JournalEntryDto Entry); +public sealed record EntrySaveResult(string FilePath); +internal sealed record EntryDeletePayload(string FilePath); +internal sealed record EntryTemplateListPayload(string? DataDirectory = null); +internal sealed record EntryTemplateLoadPayload(string FilePath); +internal sealed record EntryTemplateDeletePayload(string FilePath); +public sealed record EntryTemplateLoadResult(string FileName, string FilePath, string Content); +public sealed record EntryTemplateSavePayload(string Name, string Content, string? FilePath = null, string? DataDirectory = null); +internal sealed record DatabasePayload(string Password, string? DataDirectory = null); +internal sealed record AiSummarizeEntryPayload(string Content, string? FileStem = null); +internal sealed record AiSummarizeAllPayload(List? Entries); +internal sealed record AiChatPayload(string Prompt); +internal sealed record AiEmbedPayload(string Content); +internal sealed record SpeechTranscribePayload( + string? AudioBase64 = null, + string? Audio_Base64 = null, + string? Engine = null, + string? WhisperModel = null, + string? Whisper_Model = null, + string? Text = null, + int? SimulateDelayMs = null, + int? Simulate_Delay_Ms = null); +internal sealed record SearchEntriesPayload( + string DataDirectory, + string? Query = null, + string? Section = null, + string? StartDate = null, + string? EndDate = null, + List? Tags = null, + List? Types = null, + List? Checked = null, + List? Unchecked = null); diff --git a/Journal.Core/Dtos/DatabaseDtos.cs b/Journal.Core/Dtos/DatabaseDtos.cs new file mode 100644 index 0000000..3c587e7 --- /dev/null +++ b/Journal.Core/Dtos/DatabaseDtos.cs @@ -0,0 +1,18 @@ +namespace Journal.Core.Dtos; + +public sealed record JournalDatabaseStatus( + string DatabasePath, + int KeyLengthBytes, + int Iterations, + string KeyDerivation, + IReadOnlyList SchemaTables, + string SchemaBootstrapPath, + bool RuntimeReady, + string RuntimeMessage); + +public sealed record JournalDatabaseHydrationResult( + string DatabasePath, + string SchemaBootstrapPath, + int EntryFilesProcessed, + bool RuntimeReady, + string Message); diff --git a/Journal.Core/Dtos/EntrySearchDtos.cs b/Journal.Core/Dtos/EntrySearchDtos.cs new file mode 100644 index 0000000..7330901 --- /dev/null +++ b/Journal.Core/Dtos/EntrySearchDtos.cs @@ -0,0 +1,16 @@ +namespace Journal.Core.Dtos; + +public sealed record EntrySearchRequestDto( + string DataDirectory, + string? Query = null, + string? Section = null, + string? StartDate = null, + string? EndDate = null, + IReadOnlyList? Tags = null, + IReadOnlyList? Types = null, + IReadOnlyList? Checked = null, + IReadOnlyList? Unchecked = null); + +public sealed record EntrySearchResultDto( + string FileName, + JournalEntryDto Entry); diff --git a/Journal.Core/Dtos/FragmentDtos.cs b/Journal.Core/Dtos/FragmentDtos.cs new file mode 100644 index 0000000..aace939 --- /dev/null +++ b/Journal.Core/Dtos/FragmentDtos.cs @@ -0,0 +1,24 @@ +using System.ComponentModel.DataAnnotations; + +namespace Journal.Core.Dtos; + +public record FragmentDto( + Guid Id, + string Type, + string Description, + DateTimeOffset Time, + List Tags +); + +public record CreateFragmentDto( + [property: Required(AllowEmptyStrings = false)] string Type, + [property: Required(AllowEmptyStrings = false)] string Description, + List? Tags = null +); + +public record UpdateFragmentDto( + string? Type = null, + string? Description = null, + List? Tags = null, + DateTimeOffset? Time = null +); diff --git a/Journal.Core/Dtos/JournalEntryDtos.cs b/Journal.Core/Dtos/JournalEntryDtos.cs new file mode 100644 index 0000000..4011700 --- /dev/null +++ b/Journal.Core/Dtos/JournalEntryDtos.cs @@ -0,0 +1,12 @@ +namespace Journal.Core.Dtos; + +public sealed record ParsedSectionDto( + string Title, + IReadOnlyList Content, + IReadOnlyDictionary Checkboxes); + +public sealed record JournalEntryDto( + string Date, + IReadOnlyList Fragments, + string RawContent, + IReadOnlyDictionary Sections); diff --git a/Journal.Core/Dtos/ListDtos.cs b/Journal.Core/Dtos/ListDtos.cs new file mode 100644 index 0000000..ef742bc --- /dev/null +++ b/Journal.Core/Dtos/ListDtos.cs @@ -0,0 +1,21 @@ +using System.ComponentModel.DataAnnotations; + +namespace Journal.Core.Dtos; + +public record ListDocumentDto( + Guid Id, + string Label, + string Content, + DateTimeOffset CreatedAt, + DateTimeOffset UpdatedAt +); + +public record CreateListDto( + [property: Required(AllowEmptyStrings = false)] string Label, + string? Content = null +); + +public record UpdateListDto( + string? Label = null, + string? Content = null +); diff --git a/Journal.Core/Dtos/SpeechDtos.cs b/Journal.Core/Dtos/SpeechDtos.cs new file mode 100644 index 0000000..aa3d1c9 --- /dev/null +++ b/Journal.Core/Dtos/SpeechDtos.cs @@ -0,0 +1,21 @@ +namespace Journal.Core.Dtos; + +public sealed record SpeechDeviceDto( + int Index, + string Name); + +public sealed record SpeechDevicesResultDto( + IReadOnlyList Devices, + string? Warning = null); + +public sealed record SpeechTranscribeRequestDto( + string? AudioBase64 = null, + string? Engine = null, + string? WhisperModel = null, + string? Text = null, + int? SimulateDelayMs = null); + +public sealed record SpeechTranscribeResultDto( + string Text, + string Engine, + string? Warning = null); diff --git a/Journal.Core/Dtos/TodoDtos.cs b/Journal.Core/Dtos/TodoDtos.cs new file mode 100644 index 0000000..c84a140 --- /dev/null +++ b/Journal.Core/Dtos/TodoDtos.cs @@ -0,0 +1,38 @@ +using System.ComponentModel.DataAnnotations; + +namespace Journal.Core.Dtos; + +public record TodoListDto( + Guid Id, + string Label, + DateTimeOffset CreatedAt, + List Items +); + +public record TodoItemDto( + Guid Id, + Guid ListId, + string Text, + bool Done, + int SortOrder +); + +public record CreateTodoListDto( + [property: Required(AllowEmptyStrings = false)] string Label +); + +public record UpdateTodoListDto( + string? Label = null +); + +public record CreateTodoItemDto( + [property: Required] Guid ListId, + [property: Required(AllowEmptyStrings = false)] string Text, + int? SortOrder = null +); + +public record UpdateTodoItemDto( + string? Text = null, + bool? Done = null, + int? SortOrder = null +); diff --git a/Journal.Core/Entry.cs b/Journal.Core/Entry.cs new file mode 100644 index 0000000..6430c2f --- /dev/null +++ b/Journal.Core/Entry.cs @@ -0,0 +1,494 @@ +using System.ComponentModel.DataAnnotations; +using System.Globalization; +using System.Text.Json; +using Journal.Core.Dtos; +using Journal.Core.Models; +using Journal.Core.Services.Ai; +using Journal.Core.Services.Config; +using Journal.Core.Services.Database; +using Journal.Core.Services.Entries; +using Journal.Core.Services.Fragments; +using Journal.Core.Services.Lists; +using Journal.Core.Services.Logging; +using Journal.Core.Services.Speech; +using Journal.Core.Services.Todos; +using Journal.Core.Services.Vault; + +namespace Journal.Core; + +public class Entry( + IFragmentService fragments, + IEntrySearchService entrySearch, + IVaultStorageService vaultStorage, + IJournalDatabaseService database, + IDatabaseSessionService databaseSession, + IJournalConfigService config, + IAiService ai, + ISpeechBridgeService speech, + IEntryFileService entryFiles, + IListService lists, + ITodoService todos, + CommandLogger logger) +{ + private readonly IFragmentService _fragments = fragments; + private readonly IEntrySearchService _entrySearch = entrySearch; + private readonly IVaultStorageService _vaultStorage = vaultStorage; + private readonly IJournalDatabaseService _database = database; + private readonly IDatabaseSessionService _databaseSession = databaseSession; + private readonly IJournalConfigService _config = config; + private readonly IAiService _ai = ai; + private readonly ISpeechBridgeService _speech = speech; + private readonly IEntryFileService _entryFiles = entryFiles; + private readonly IListService _lists = lists; + private readonly ITodoService _todos = todos; + private readonly CommandLogger _logger = logger; + private static readonly HashSet VaultSyncActions = new(StringComparer.Ordinal) + { + "entries.save", + "entries.delete", + "templates.save", + "templates.delete", + "fragments.create", + "fragments.update", + "fragments.delete", + "lists.create", + "lists.update", + "lists.delete", + "todos.create", + "todos.update", + "todos.delete", + "todos.items.create", + "todos.items.update", + "todos.items.delete" + }; + private static readonly JsonSerializerOptions JsonOptions = new() + { + PropertyNameCaseInsensitive = true + }; + + public async Task RunAsync() + { + string? line; + while ((line = Console.ReadLine()) is not null) + { + var response = await HandleCommandAsync(line); + Console.WriteLine(response); + } + } + + public async Task HandleCommandAsync(string json) + { + if (string.IsNullOrWhiteSpace(json)) + return Error("Invalid command"); + + Command? cmd; + try + { + cmd = JsonSerializer.Deserialize(json, JsonOptions); + } + catch (JsonException) + { + return Error("Invalid command JSON"); + } + + if (cmd is null || string.IsNullOrWhiteSpace(cmd.Action)) + return Error("Invalid command"); + + var action = cmd.Action.Trim(); + var correlationId = string.IsNullOrWhiteSpace(cmd.CorrelationId) + ? Guid.NewGuid().ToString("N") + : cmd.CorrelationId.Trim(); + CommandLogger.LogStart(action, correlationId, cmd.Payload); + object? result; + + try + { + switch (action) + { + case "fragments.list": + result = _fragments.GetAll(); + break; + case "fragments.get": + if (!Guid.TryParse(cmd.Id, out var getId)) + return Error("Invalid or missing id"); + result = _fragments.GetById(getId); + break; + case "fragments.create": + var createDto = DeserializePayload(cmd.Payload); + if (createDto is null) + return Error("Missing or invalid payload"); + result = _fragments.Create(createDto); + break; + case "fragments.update": + if (!Guid.TryParse(cmd.Id, out var updateId)) + return Error("Invalid or missing id"); + var updateDto = DeserializePayload(cmd.Payload); + if (updateDto is null) + return Error("Missing or invalid payload"); + result = _fragments.Update(updateId, updateDto); + break; + case "fragments.delete": + if (!Guid.TryParse(cmd.Id, out var deleteId)) + return Error("Invalid or missing id"); + result = _fragments.Remove(deleteId); + break; + case "fragments.search": + result = _fragments.Search(cmd.Type, cmd.Tag); + break; + + // ── Lists ──────────────────────────────────────── + case "lists.list": + result = _lists.GetAll(); + break; + case "lists.get": + if (!Guid.TryParse(cmd.Id, out var getListId)) + return Error("Invalid or missing id"); + result = _lists.GetById(getListId); + break; + case "lists.create": + var createListDto = DeserializePayload(cmd.Payload); + if (createListDto is null) + return Error("Missing or invalid payload"); + result = _lists.Create(createListDto); + break; + case "lists.update": + if (!Guid.TryParse(cmd.Id, out var updateListId)) + return Error("Invalid or missing id"); + var updateListDto = DeserializePayload(cmd.Payload); + if (updateListDto is null) + return Error("Missing or invalid payload"); + result = _lists.Update(updateListId, updateListDto); + break; + case "lists.delete": + if (!Guid.TryParse(cmd.Id, out var deleteListId)) + return Error("Invalid or missing id"); + result = _lists.Remove(deleteListId); + break; + + // ── Todos ──────────────────────────────────────── + case "todos.list": + result = _todos.GetAllLists(); + break; + case "todos.get": + if (!Guid.TryParse(cmd.Id, out var getTodoListId)) + return Error("Invalid or missing id"); + result = _todos.GetListById(getTodoListId); + break; + case "todos.create": + var createTodoListDto = DeserializePayload(cmd.Payload); + if (createTodoListDto is null) + return Error("Missing or invalid payload"); + result = _todos.CreateList(createTodoListDto); + break; + case "todos.update": + if (!Guid.TryParse(cmd.Id, out var updateTodoListId)) + return Error("Invalid or missing id"); + var updateTodoListDto = DeserializePayload(cmd.Payload); + if (updateTodoListDto is null) + return Error("Missing or invalid payload"); + result = _todos.UpdateList(updateTodoListId, updateTodoListDto); + break; + case "todos.delete": + if (!Guid.TryParse(cmd.Id, out var deleteTodoListId)) + return Error("Invalid or missing id"); + result = _todos.RemoveList(deleteTodoListId); + break; + case "todos.items.create": + var createItemDto = DeserializePayload(cmd.Payload); + if (createItemDto is null) + return Error("Missing or invalid payload"); + result = _todos.CreateItem(createItemDto); + break; + case "todos.items.update": + if (!Guid.TryParse(cmd.Id, out var updateItemId)) + return Error("Invalid or missing id"); + var updateItemDto = DeserializePayload(cmd.Payload); + if (updateItemDto is null) + return Error("Missing or invalid payload"); + result = _todos.UpdateItem(updateItemId, updateItemDto); + break; + case "todos.items.delete": + if (!Guid.TryParse(cmd.Id, out var deleteItemId)) + return Error("Invalid or missing id"); + result = _todos.RemoveItem(deleteItemId); + break; + case "search.entries": + var searchPayload = DeserializePayload(cmd.Payload); + if (searchPayload is null || string.IsNullOrWhiteSpace(searchPayload.DataDirectory)) + return Error("Missing or invalid payload"); + var searchRequest = new EntrySearchRequestDto( + DataDirectory: searchPayload.DataDirectory, + Query: searchPayload.Query, + Section: searchPayload.Section, + StartDate: searchPayload.StartDate, + EndDate: searchPayload.EndDate, + Tags: searchPayload.Tags, + Types: searchPayload.Types, + Checked: searchPayload.Checked, + Unchecked: searchPayload.Unchecked); + result = await _entrySearch.SearchEntriesAsync(searchRequest); + break; + case "entries.list": + var listPayload = DeserializePayload(cmd.Payload); + var listDataDirectory = !string.IsNullOrWhiteSpace(listPayload?.DataDirectory) + ? listPayload.DataDirectory + : _config.Current.DataDirectory; + result = _entryFiles.ListEntries(listDataDirectory); + break; + case "templates.list": + var templateListPayload = DeserializePayload(cmd.Payload); + var templateListDirectory = !string.IsNullOrWhiteSpace(templateListPayload?.DataDirectory) + ? templateListPayload.DataDirectory + : _config.Current.DataDirectory; + result = _entryFiles.ListTemplates(templateListDirectory); + break; + case "entries.load": + var loadEntryPayload = DeserializePayload(cmd.Payload); + if (loadEntryPayload is null || string.IsNullOrWhiteSpace(loadEntryPayload.FilePath)) + return Error("Missing or invalid payload"); + result = _entryFiles.LoadEntry(loadEntryPayload.FilePath); + break; + case "templates.load": + var loadTemplatePayload = DeserializePayload(cmd.Payload); + if (loadTemplatePayload is null || string.IsNullOrWhiteSpace(loadTemplatePayload.FilePath)) + return Error("Missing or invalid payload"); + result = _entryFiles.LoadTemplate(loadTemplatePayload.FilePath); + break; + case "entries.save": + var saveEntryPayload = DeserializePayload(cmd.Payload); + if (saveEntryPayload is null || string.IsNullOrWhiteSpace(saveEntryPayload.Content)) + return Error("Missing or invalid payload"); + result = _entryFiles.SaveEntry(saveEntryPayload, _config.Current.DataDirectory); + break; + case "templates.save": + var saveTemplatePayload = DeserializePayload(cmd.Payload); + if (saveTemplatePayload is null || string.IsNullOrWhiteSpace(saveTemplatePayload.Name)) + return Error("Missing or invalid payload"); + result = _entryFiles.SaveTemplate(saveTemplatePayload, _config.Current.DataDirectory); + break; + case "entries.delete": + var deleteEntryPayload = DeserializePayload(cmd.Payload); + if (deleteEntryPayload is null || string.IsNullOrWhiteSpace(deleteEntryPayload.FilePath)) + return Error("Missing or invalid payload"); + result = _entryFiles.DeleteEntry(deleteEntryPayload.FilePath); + break; + case "templates.delete": + var deleteTemplatePayload = DeserializePayload(cmd.Payload); + if (deleteTemplatePayload is null || string.IsNullOrWhiteSpace(deleteTemplatePayload.FilePath)) + return Error("Missing or invalid payload"); + result = _entryFiles.DeleteTemplate(deleteTemplatePayload.FilePath); + break; + case "config.get": + result = _config.Current; + break; + case "ai.health": + result = await _ai.HealthAsync(); + break; + case "ai.summarize_entry": + var summarizeEntryPayload = DeserializePayload(cmd.Payload); + if (summarizeEntryPayload is null || string.IsNullOrWhiteSpace(summarizeEntryPayload.Content)) + return Error("Missing or invalid payload"); + result = await _ai.SummarizeEntryAsync(summarizeEntryPayload.Content, summarizeEntryPayload.FileStem); + break; + case "ai.summarize_all": + var summarizeAllPayload = DeserializePayload(cmd.Payload); + if (summarizeAllPayload is null) + return Error("Missing or invalid payload"); + result = await _ai.SummarizeAllAsync(summarizeAllPayload.Entries ?? []); + break; + case "ai.chat": + var chatPayload = DeserializePayload(cmd.Payload); + if (chatPayload is null || string.IsNullOrWhiteSpace(chatPayload.Prompt)) + return Error("Missing or invalid payload"); + result = await _ai.ChatAsync(chatPayload.Prompt); + break; + case "ai.embed": + var embedPayload = DeserializePayload(cmd.Payload); + if (embedPayload is null || string.IsNullOrWhiteSpace(embedPayload.Content)) + return Error("Missing or invalid payload"); + result = await _ai.EmbedAsync(embedPayload.Content); + break; + case "speech.devices.list": + result = await _speech.ListDevicesAsync(); + break; + case "speech.transcribe": + var speechPayload = DeserializePayload(cmd.Payload); + if (speechPayload is null) + return Error("Missing or invalid payload"); + var audioBase64 = !string.IsNullOrWhiteSpace(speechPayload.AudioBase64) + ? speechPayload.AudioBase64 + : speechPayload.Audio_Base64; + var text = speechPayload.Text; + var whisperModel = !string.IsNullOrWhiteSpace(speechPayload.WhisperModel) + ? speechPayload.WhisperModel + : speechPayload.Whisper_Model; + var simulateDelayMs = speechPayload.SimulateDelayMs ?? speechPayload.Simulate_Delay_Ms; + if (string.IsNullOrWhiteSpace(audioBase64) && string.IsNullOrWhiteSpace(text)) + return Error("Missing or invalid payload"); + result = await _speech.TranscribeAsync(new SpeechTranscribeRequestDto( + AudioBase64: audioBase64, + Engine: speechPayload.Engine, + WhisperModel: whisperModel, + Text: text, + SimulateDelayMs: simulateDelayMs)); + break; + case "vault.initialize": + var initPayload = DeserializePayload(cmd.Payload); + if (initPayload is null || string.IsNullOrWhiteSpace(initPayload.Password) || string.IsNullOrWhiteSpace(initPayload.VaultDirectory)) + return Error("Missing or invalid payload"); + Directory.CreateDirectory(initPayload.VaultDirectory); + result = true; + break; + case "vault.load_all": + var loadPayload = DeserializePayload(cmd.Payload); + if (loadPayload is null) + return Error("Missing or invalid payload"); + var loaded = _vaultStorage.LoadAllVaults(loadPayload.Password, loadPayload.VaultDirectory, loadPayload.DataDirectory); + if (loaded) + _databaseSession.SetPassword(loadPayload.Password, loadPayload.DataDirectory); + result = loaded; + break; + case "vault.save_current_month": + var saveCurrentPayload = DeserializePayload(cmd.Payload); + if (saveCurrentPayload is null) + return Error("Missing or invalid payload"); + result = _vaultStorage.SaveCurrentMonthVault( + saveCurrentPayload.Password, + saveCurrentPayload.VaultDirectory, + saveCurrentPayload.DataDirectory, + ParseNowOrDefault(saveCurrentPayload.NowUtc)); + break; + case "vault.rebuild_all": + var rebuildPayload = DeserializePayload(cmd.Payload); + if (rebuildPayload is null) + return Error("Missing or invalid payload"); + _databaseSession.CloseConnection(); + _vaultStorage.RebuildAllVaults(rebuildPayload.Password, rebuildPayload.VaultDirectory, rebuildPayload.DataDirectory); + result = true; + break; + case "vault.clear_data_directory": + var clearPayload = DeserializePayload(cmd.Payload); + if (clearPayload is null || string.IsNullOrWhiteSpace(clearPayload.DataDirectory)) + return Error("Missing or invalid payload"); + if (_databaseSession is IDisposable disposableSession) + disposableSession.Dispose(); + _vaultStorage.ClearDataDirectory(clearPayload.DataDirectory); + result = true; + break; + case "db.status": + var dbStatusPayload = DeserializePayload(cmd.Payload); + if (dbStatusPayload is null || string.IsNullOrWhiteSpace(dbStatusPayload.Password)) + return Error("Missing or invalid payload"); + result = _database.GetStatus(dbStatusPayload.Password, dbStatusPayload.DataDirectory); + break; + case "db.initialize_schema": + var dbInitPayload = DeserializePayload(cmd.Payload); + if (dbInitPayload is null) + return Error("Missing or invalid payload"); + var schemaPath = _database.WriteSchemaBootstrap(dbInitPayload.DataDirectory); + result = new { schemaPath }; + break; + case "db.hydrate_workspace": + var dbHydratePayload = DeserializePayload(cmd.Payload); + if (dbHydratePayload is null || string.IsNullOrWhiteSpace(dbHydratePayload.Password)) + return Error("Missing or invalid payload"); + result = _database.HydrateWorkspace(dbHydratePayload.Password, dbHydratePayload.DataDirectory); + _databaseSession.SetPassword(dbHydratePayload.Password, dbHydratePayload.DataDirectory); + break; + default: + CommandLogger.LogFailure(action, correlationId, "unknown_action"); + return Error($"Unknown action: {action}"); + } + } + catch (JsonException) + { + CommandLogger.LogFailure(action, correlationId, "invalid_payload_json"); + return Error("Missing or invalid payload"); + } + catch (ValidationException ex) + { + CommandLogger.LogFailure(action, correlationId, "validation", ex.Message); + return Error(ex.Message); + } + catch (ArgumentException ex) + { + CommandLogger.LogFailure(action, correlationId, "argument", ex.Message); + return Error(ex.Message); + } + catch (TimeoutException ex) + { + CommandLogger.LogFailure(action, correlationId, "timeout", ex.Message); + return Error(ex.Message); + } + catch (InvalidOperationException ex) + { + CommandLogger.LogFailure(action, correlationId, "invalid_operation", ex.Message); + return Error(ex.Message); + } + catch (FileNotFoundException ex) + { + CommandLogger.LogFailure(action, correlationId, "not_found", ex.Message); + return Error(ex.Message); + } + catch + { + CommandLogger.LogFailure(action, correlationId, "internal_error"); + return Error("Internal error"); + } + + TryAutoSyncVault(action, correlationId); + CommandLogger.LogSuccess(action, correlationId); + return JsonSerializer.Serialize(new { ok = true, data = result }); + } + + private static string Error(string message) + => JsonSerializer.Serialize(new { ok = false, error = message }); + + private static T? DeserializePayload(JsonElement? payload) + { + if (payload is null) + return default; + return payload.Value.Deserialize(JsonOptions); + } + + private static DateTime ParseNowOrDefault(string? nowUtc) + { + if (string.IsNullOrWhiteSpace(nowUtc)) + return DateTime.UtcNow; + + if (DateTime.TryParse( + nowUtc, + CultureInfo.InvariantCulture, + DateTimeStyles.AssumeUniversal | DateTimeStyles.AdjustToUniversal, + out var parsed)) + { + return parsed; + } + + throw new ArgumentException("Invalid nowUtc value. Expected ISO date/time."); + } + + private void TryAutoSyncVault(string action, string correlationId) + { + if (!VaultSyncActions.Contains(action)) + return; + + if (!_databaseSession.TryGetSession(out var password, out var sessionDataDirectory)) + return; + + try + { + var config = _config.Current; + var dataDirectory = string.IsNullOrWhiteSpace(sessionDataDirectory) + ? config.DataDirectory + : sessionDataDirectory; + + _databaseSession.CloseConnection(); + _vaultStorage.RebuildAllVaults(password, config.VaultDirectory, dataDirectory); + } + catch (Exception ex) + { + CommandLogger.LogFailure(action, correlationId, "vault_auto_sync_failed", ex.Message); + } + } +} diff --git a/Journal.Core/Journal.Core.csproj b/Journal.Core/Journal.Core.csproj new file mode 100644 index 0000000..7e67750 --- /dev/null +++ b/Journal.Core/Journal.Core.csproj @@ -0,0 +1,15 @@ + + + + net10.0 + enable + enable + + + + + + + + + diff --git a/Journal.Core/Models/Command.cs b/Journal.Core/Models/Command.cs new file mode 100644 index 0000000..ac44027 --- /dev/null +++ b/Journal.Core/Models/Command.cs @@ -0,0 +1,13 @@ +using System.Text.Json; + +namespace Journal.Core.Models; + +public class Command +{ + public string Action { get; set; } = ""; + public string? CorrelationId { get; set; } + public string? Id { get; set; } + public string? Type { get; set; } + public string? Tag { get; set; } + public JsonElement? Payload { get; set; } +} diff --git a/Journal.Core/Models/Fragment.cs b/Journal.Core/Models/Fragment.cs new file mode 100644 index 0000000..6b67db7 --- /dev/null +++ b/Journal.Core/Models/Fragment.cs @@ -0,0 +1,42 @@ +namespace Journal.Core.Models; + +public class Fragment +{ + public Guid Id { get; } + public string Type { get; set; } + public string Description { get; set; } + public DateTimeOffset Time { get; set; } + public List Tags { get; set; } = []; + + public Fragment(string type, string description) + { + Validate(type, description); + + Id = Guid.NewGuid(); + Type = type.Trim(); + Description = description.Trim(); + Time = DateTimeOffset.Now; + } + + public Fragment(Guid id, string type, string description, DateTimeOffset time, IEnumerable? tags = null) + { + if (id == Guid.Empty) + throw new ArgumentException("Id is required", nameof(id)); + Validate(type, description); + + Id = id; + Type = type.Trim(); + Description = description.Trim(); + Time = time; + if (tags is not null) + Tags = [.. tags.Where(t => !string.IsNullOrWhiteSpace(t)).Select(t => t.Trim())]; + } + + private static void Validate(string type, string description) + { + if (string.IsNullOrWhiteSpace(type)) + throw new ArgumentException("Type is required", nameof(type)); + if (string.IsNullOrWhiteSpace(description)) + throw new ArgumentException("Description is required", nameof(description)); + } +} diff --git a/Journal.Core/Models/JournalConfig.cs b/Journal.Core/Models/JournalConfig.cs new file mode 100644 index 0000000..f540a41 --- /dev/null +++ b/Journal.Core/Models/JournalConfig.cs @@ -0,0 +1,29 @@ +namespace Journal.Core.Models; + +public sealed record JournalConfig( + string ProjectRoot, + string AppDirectory, + string DataDirectory, + string VaultDirectory, + string LogDirectory, + string PidFile, + string ServerControlFile, + string DatabaseFilename, + string MonthlyVaultFormat, + string CloudAiApiKey, + string CloudAiApiUrl, + string LlamaCppUrl, + string LlamaCppModel, + int LlamaCppTimeout, + string EmbeddingApiUrl, + string EmbeddingModelName, + int ModelContextTokens, + int ChunkTokenBudget, + int? MicrophoneDeviceIndex, + string SpeechRecognitionEngine, + string WhisperModelSize, + string NlpBackend, + string AiProvider, + string PythonExecutable, + string PythonAiSidecarPath, + int AiSidecarTimeoutMs); diff --git a/Journal.Core/Models/JournalEntry.cs b/Journal.Core/Models/JournalEntry.cs new file mode 100644 index 0000000..e647c55 --- /dev/null +++ b/Journal.Core/Models/JournalEntry.cs @@ -0,0 +1,98 @@ +namespace Journal.Core.Models; + +public class JournalEntry +{ + public string Date { get; set; } + public List Fragments { get; set; } + public string RawContent { get; set; } + public Dictionary Sections { get; set; } + + public JournalEntry( + string date, + IEnumerable? fragments = null, + string rawContent = "", + IDictionary? sections = null) + { + if (string.IsNullOrWhiteSpace(date)) + throw new ArgumentException("Date is required", nameof(date)); + + Date = date.Trim(); + Fragments = fragments is null ? [] : [.. fragments]; + RawContent = rawContent ?? ""; + Sections = sections is null ? [] : new Dictionary(sections); + } + + public string GetSection(string sectionTitle) + { + if (string.IsNullOrWhiteSpace(sectionTitle)) + return ""; + if (!Sections.TryGetValue(sectionTitle, out var section)) + return ""; + return string.Join("\n", section.Content); + } + + public bool? GetCheckboxState(string sectionTitle, string checkboxText) + { + if (string.IsNullOrWhiteSpace(sectionTitle) || string.IsNullOrWhiteSpace(checkboxText)) + return null; + if (!Sections.TryGetValue(sectionTitle, out var section)) + return null; + return section.Checkboxes.TryGetValue(checkboxText, out var checkedState) ? checkedState : null; + } + + public void MergeWith(JournalEntry otherEntry) + { + ArgumentNullException.ThrowIfNull(otherEntry); + + foreach (var (title, newSection) in otherEntry.Sections) + { + if (newSection.Content.Any(line => !string.IsNullOrWhiteSpace(line))) + Sections[title] = newSection; + } + + var existingFragmentDescriptions = Fragments + .Select(fragment => fragment.Description) + .ToHashSet(StringComparer.Ordinal); + + foreach (var newFragment in otherEntry.Fragments) + { + if (!existingFragmentDescriptions.Contains(newFragment.Description)) + Fragments.Add(newFragment); + } + } + + public string ToMarkdown() + { + var lines = new List + { + "---", + "type: journal", + "---", + $"**Date:** {Date}\n" + }; + + foreach (var title in SectionTitles.Canonical) + { + if (!Sections.TryGetValue(title, out var section)) + continue; + + lines.Add($"## {section.Title}\n"); + lines.AddRange(section.Content); + lines.Add(""); + } + + if (Fragments.Count > 0) + { + lines.Add("# Fragments\n"); + foreach (var fragment in Fragments) + { + var timeStr = fragment.Time != default ? $"@{fragment.Time:O}" : ""; + var tagsStr = string.Join(" ", fragment.Tags.Select(tag => $"#{tag}")); + var header = $"{fragment.Type} {timeStr} {tagsStr}".Trim(); + lines.Add($"{header}\n{fragment.Description}\n"); + } + } + + return string.Join("\n", lines); + } +} diff --git a/Journal.Core/Models/ListDocument.cs b/Journal.Core/Models/ListDocument.cs new file mode 100644 index 0000000..c61a9c7 --- /dev/null +++ b/Journal.Core/Models/ListDocument.cs @@ -0,0 +1,40 @@ +namespace Journal.Core.Models; + +public class ListDocument +{ + public Guid Id { get; } + public string Label { get; set; } + public string Content { get; set; } + public DateTimeOffset CreatedAt { get; set; } + public DateTimeOffset UpdatedAt { get; set; } + + public ListDocument(string label, string content = "") + { + Validate(label); + + Id = Guid.NewGuid(); + Label = label.Trim(); + Content = content; + CreatedAt = DateTimeOffset.Now; + UpdatedAt = CreatedAt; + } + + public ListDocument(Guid id, string label, string content, DateTimeOffset createdAt, DateTimeOffset updatedAt) + { + if (id == Guid.Empty) + throw new ArgumentException("Id is required", nameof(id)); + Validate(label); + + Id = id; + Label = label.Trim(); + Content = content; + CreatedAt = createdAt; + UpdatedAt = updatedAt; + } + + private static void Validate(string label) + { + if (string.IsNullOrWhiteSpace(label)) + throw new ArgumentException("Label is required", nameof(label)); + } +} diff --git a/Journal.Core/Models/ParsedSection.cs b/Journal.Core/Models/ParsedSection.cs new file mode 100644 index 0000000..bc9ff3c --- /dev/null +++ b/Journal.Core/Models/ParsedSection.cs @@ -0,0 +1,21 @@ +namespace Journal.Core.Models; + +public class ParsedSection +{ + public string Title { get; set; } + public List Content { get; set; } + public Dictionary Checkboxes { get; set; } + + public ParsedSection( + string title, + IEnumerable? content = null, + IDictionary? checkboxes = null) + { + if (string.IsNullOrWhiteSpace(title)) + throw new ArgumentException("Section title is required", nameof(title)); + + Title = title.Trim(); + Content = content is null ? [] : [.. content]; + Checkboxes = checkboxes is null ? [] : new Dictionary(checkboxes); + } +} diff --git a/Journal.Core/Models/SectionTitles.cs b/Journal.Core/Models/SectionTitles.cs new file mode 100644 index 0000000..3aaf666 --- /dev/null +++ b/Journal.Core/Models/SectionTitles.cs @@ -0,0 +1,20 @@ +namespace Journal.Core.Models; + +public static class SectionTitles +{ + public static readonly IReadOnlyList Canonical = + [ + "Summary", + "Cognitive State", + "Mental / Emotional Snapshot", + "Memory / Mind Failures", + "Events / Triggers", + "Communication / Expression Log", + "Coping / Tools Used", + "Reflection", + "Core Events or Memories", + "Autism/ADHD-Related Elements", + "Emotional & Bodily Reactions", + "Truth to Anchor Myself To", + ]; +} diff --git a/Journal.Core/Models/TodoItem.cs b/Journal.Core/Models/TodoItem.cs new file mode 100644 index 0000000..f225aa0 --- /dev/null +++ b/Journal.Core/Models/TodoItem.cs @@ -0,0 +1,44 @@ +namespace Journal.Core.Models; + +public class TodoItem +{ + public Guid Id { get; } + public Guid ListId { get; } + public string Text { get; set; } + public bool Done { get; set; } + public int SortOrder { get; set; } + + public TodoItem(Guid listId, string text, int sortOrder = 0) + { + Validate(text); + if (listId == Guid.Empty) + throw new ArgumentException("ListId is required", nameof(listId)); + + Id = Guid.NewGuid(); + ListId = listId; + Text = text.Trim(); + Done = false; + SortOrder = sortOrder; + } + + public TodoItem(Guid id, Guid listId, string text, bool done, int sortOrder) + { + if (id == Guid.Empty) + throw new ArgumentException("Id is required", nameof(id)); + if (listId == Guid.Empty) + throw new ArgumentException("ListId is required", nameof(listId)); + Validate(text); + + Id = id; + ListId = listId; + Text = text.Trim(); + Done = done; + SortOrder = sortOrder; + } + + private static void Validate(string text) + { + if (string.IsNullOrWhiteSpace(text)) + throw new ArgumentException("Text is required", nameof(text)); + } +} diff --git a/Journal.Core/Models/TodoList.cs b/Journal.Core/Models/TodoList.cs new file mode 100644 index 0000000..6fa533e --- /dev/null +++ b/Journal.Core/Models/TodoList.cs @@ -0,0 +1,34 @@ +namespace Journal.Core.Models; + +public class TodoList +{ + public Guid Id { get; } + public string Label { get; set; } + public DateTimeOffset CreatedAt { get; set; } + + public TodoList(string label) + { + Validate(label); + + Id = Guid.NewGuid(); + Label = label.Trim(); + CreatedAt = DateTimeOffset.Now; + } + + public TodoList(Guid id, string label, DateTimeOffset createdAt) + { + if (id == Guid.Empty) + throw new ArgumentException("Id is required", nameof(id)); + Validate(label); + + Id = id; + Label = label.Trim(); + CreatedAt = createdAt; + } + + private static void Validate(string label) + { + if (string.IsNullOrWhiteSpace(label)) + throw new ArgumentException("Label is required", nameof(label)); + } +} diff --git a/Journal.Core/Repositories/DiskEntryFileRepository.cs b/Journal.Core/Repositories/DiskEntryFileRepository.cs new file mode 100644 index 0000000..d24c4d8 --- /dev/null +++ b/Journal.Core/Repositories/DiskEntryFileRepository.cs @@ -0,0 +1,35 @@ +namespace Journal.Core.Repositories; + +public sealed class DiskEntryFileRepository : IEntryFileRepository +{ + public IReadOnlyList ListMarkdownFiles(string dataDirectory) + { + if (!Directory.Exists(dataDirectory)) + return []; + + return [.. Directory.GetFiles(dataDirectory, "*.md").OrderBy(Path.GetFileName, StringComparer.Ordinal)]; + } + + public string ReadFile(string filePath) => File.ReadAllText(filePath); + + public void WriteFile(string filePath, string content) => File.WriteAllText(filePath, content); + + public void AppendFile(string filePath, string content) => File.AppendAllText(filePath, content); + + public bool FileExists(string filePath) => File.Exists(filePath); + + public string GetFullPath(string filePath) => Path.GetFullPath(filePath); + + public string GetFileName(string filePath) => Path.GetFileName(filePath); + + public string GetFileNameWithoutExtension(string filePath) => Path.GetFileNameWithoutExtension(filePath); + + public void EnsureDirectory(string path) + { + var dir = Path.GetDirectoryName(path); + if (!string.IsNullOrWhiteSpace(dir)) + Directory.CreateDirectory(dir); + } + + public void DeleteFile(string filePath) => File.Delete(filePath); +} diff --git a/Journal.Core/Repositories/IEntryFileRepository.cs b/Journal.Core/Repositories/IEntryFileRepository.cs new file mode 100644 index 0000000..ac93437 --- /dev/null +++ b/Journal.Core/Repositories/IEntryFileRepository.cs @@ -0,0 +1,15 @@ +namespace Journal.Core.Repositories; + +public interface IEntryFileRepository +{ + IReadOnlyList ListMarkdownFiles(string dataDirectory); + string ReadFile(string filePath); + void WriteFile(string filePath, string content); + void AppendFile(string filePath, string content); + bool FileExists(string filePath); + string GetFullPath(string filePath); + string GetFileName(string filePath); + string GetFileNameWithoutExtension(string filePath); + void EnsureDirectory(string path); + void DeleteFile(string filePath); +} diff --git a/Journal.Core/Repositories/IFragmentRepository.cs b/Journal.Core/Repositories/IFragmentRepository.cs new file mode 100644 index 0000000..bb05f0d --- /dev/null +++ b/Journal.Core/Repositories/IFragmentRepository.cs @@ -0,0 +1,15 @@ +using Journal.Core.Models; + +namespace Journal.Core.Repositories; + +public interface IFragmentRepository +{ + List GetAll(); + Fragment? GetById(Guid id); + void Add(Fragment fragment); + bool Remove(Guid id); + bool Update(Guid id, string? type = null, string? description = null, IEnumerable? tags = null, DateTimeOffset? time = null); + List GetByTag(string tag); + List GetByType(string type); + List Search(string? type = null, string? tag = null, DateTimeOffset? timeAfter = null); +} diff --git a/Journal.Core/Repositories/IListRepository.cs b/Journal.Core/Repositories/IListRepository.cs new file mode 100644 index 0000000..5191443 --- /dev/null +++ b/Journal.Core/Repositories/IListRepository.cs @@ -0,0 +1,12 @@ +using Journal.Core.Models; + +namespace Journal.Core.Repositories; + +public interface IListRepository +{ + List GetAll(); + ListDocument? GetById(Guid id); + void Add(ListDocument list); + bool Update(Guid id, string? label = null, string? content = null); + bool Remove(Guid id); +} diff --git a/Journal.Core/Repositories/ITodoRepository.cs b/Journal.Core/Repositories/ITodoRepository.cs new file mode 100644 index 0000000..87fcb58 --- /dev/null +++ b/Journal.Core/Repositories/ITodoRepository.cs @@ -0,0 +1,18 @@ +using Journal.Core.Models; + +namespace Journal.Core.Repositories; + +public interface ITodoRepository +{ + List GetAllLists(); + TodoList? GetListById(Guid id); + void AddList(TodoList list); + bool UpdateList(Guid id, string? label = null); + bool RemoveList(Guid id); + + List GetItemsByListId(Guid listId); + TodoItem? GetItemById(Guid id); + void AddItem(TodoItem item); + bool UpdateItem(Guid id, string? text = null, bool? done = null, int? sortOrder = null); + bool RemoveItem(Guid id); +} diff --git a/Journal.Core/Repositories/InMemoryFragmentRepository.cs b/Journal.Core/Repositories/InMemoryFragmentRepository.cs new file mode 100644 index 0000000..22bf26a --- /dev/null +++ b/Journal.Core/Repositories/InMemoryFragmentRepository.cs @@ -0,0 +1,125 @@ +using Journal.Core.Models; + +namespace Journal.Core.Repositories; + +public class InMemoryFragmentRepository : IFragmentRepository +{ + private readonly List _store = []; + private readonly Lock _lock = new(); + + public List GetAll() + { + lock (_lock) + { + return [.. _store]; + } + } + + public Fragment? GetById(Guid id) + { + lock (_lock) + { + return _store.FirstOrDefault(f => f.Id == id); + } + } + + public void Add(Fragment fragment) + { + if (fragment is null) throw new ArgumentNullException(nameof(fragment)); + lock (_lock) + { + if (fragment.Tags != null) + { + fragment.Tags = [.. fragment.Tags + .Where(t => !string.IsNullOrWhiteSpace(t)) + .Select(t => t!.Trim())]; + } + if (!string.IsNullOrWhiteSpace(fragment.Type)) fragment.Type = fragment.Type.Trim(); + if (!string.IsNullOrWhiteSpace(fragment.Description)) fragment.Description = fragment.Description.Trim(); + + _store.Add(fragment); + } + } + + public bool Remove(Guid id) + { + lock (_lock) + { + var item = _store.FirstOrDefault(f => f.Id == id); + if (item is null) return false; + return _store.Remove(item); + } + } + + public bool Update(Guid id, string? type = null, string? description = null, IEnumerable? tags = null, DateTimeOffset? time = null) + { + lock (_lock) + { + var item = _store.FirstOrDefault(f => f.Id == id); + if (item is null) return false; + + if (type != null) + { + if (string.IsNullOrWhiteSpace(type)) throw new ArgumentException("Type cannot be empty", nameof(type)); + item.Type = type.Trim(); + } + + if (description != null) + { + if (string.IsNullOrWhiteSpace(description)) throw new ArgumentException("Description cannot be empty", nameof(description)); + item.Description = description.Trim(); + } + + if (tags != null) + { + item.Tags = [.. tags + .Where(t => !string.IsNullOrWhiteSpace(t)) + .Select(t => t!.Trim())]; + } + + if (time.HasValue) + item.Time = time.Value; + + return true; + } + } + + public List GetByTag(string tag) + { + var q = tag?.Trim(); + if (string.IsNullOrWhiteSpace(q)) return []; + lock (_lock) + { + return [.. _store.Where(f => f.Tags?.Any(t => !string.IsNullOrWhiteSpace(t) && t.Contains(q, StringComparison.OrdinalIgnoreCase)) == true)]; + } + } + + public List GetByType(string type) + { + var q = type?.Trim(); + if (string.IsNullOrWhiteSpace(q)) return []; + lock (_lock) + { + return [.. _store.Where(f => !string.IsNullOrWhiteSpace(f.Type) && f.Type.Trim().Contains(q, StringComparison.OrdinalIgnoreCase))]; + } + } + + public List Search(string? type = null, string? tag = null, DateTimeOffset? timeAfter = null) + { + var results = _store.AsEnumerable(); + var qType = type?.Trim(); + var qTag = tag?.Trim(); + + lock (_lock) + { + if (!string.IsNullOrWhiteSpace(qType)) + results = results.Where(f => !string.IsNullOrWhiteSpace(f.Type) && f.Type.Trim().Contains(qType, StringComparison.OrdinalIgnoreCase)); + if (!string.IsNullOrWhiteSpace(qTag)) + results = results.Where(f => f.Tags?.Any(t => !string.IsNullOrWhiteSpace(t) && t.Contains(qTag, StringComparison.OrdinalIgnoreCase)) == true); + if (timeAfter.HasValue) + results = results.Where(f => f.Time > timeAfter.Value); + + return [.. results]; + } + } +} diff --git a/Journal.Core/Repositories/SqliteFragmentRepository.cs b/Journal.Core/Repositories/SqliteFragmentRepository.cs new file mode 100644 index 0000000..52e7d3a --- /dev/null +++ b/Journal.Core/Repositories/SqliteFragmentRepository.cs @@ -0,0 +1,310 @@ +using Journal.Core.Models; +using Journal.Core.Services.Database; +using Microsoft.Data.Sqlite; + +namespace Journal.Core.Repositories; + +public sealed class SqliteFragmentRepository(IDatabaseSessionService session) : IFragmentRepository +{ + private readonly IDatabaseSessionService _session = session; + + public List GetAll() + { + var conn = _session.GetConnection(); + return ReadAllFragments(conn); + } + + public Fragment? GetById(Guid id) + { + var conn = _session.GetConnection(); + return ReadFragment(conn, id); + } + + public void Add(Fragment fragment) + { + ArgumentNullException.ThrowIfNull(fragment); + Normalize(fragment); + var conn = _session.GetConnection(); + InsertFragment(conn, fragment); + } + + public bool Remove(Guid id) + { + var conn = _session.GetConnection(); + return DeleteFragment(conn, id); + } + + public bool Update( + Guid id, + string? type = null, + string? description = null, + IEnumerable? tags = null, + DateTimeOffset? time = null) + { + var conn = _session.GetConnection(); + var existing = ReadFragment(conn, id); + if (existing is null) + return false; + + if (type != null) + { + if (string.IsNullOrWhiteSpace(type)) + throw new ArgumentException("Type cannot be empty", nameof(type)); + existing.Type = type.Trim(); + } + + if (description != null) + { + if (string.IsNullOrWhiteSpace(description)) + throw new ArgumentException("Description cannot be empty", nameof(description)); + existing.Description = description.Trim(); + } + + if (tags != null) + { + existing.Tags = [.. + tags.Where(t => !string.IsNullOrWhiteSpace(t)) + .Select(t => t.Trim())]; + } + + if (time.HasValue) + existing.Time = time.Value; + + UpdateFragmentRow(conn, existing); + return true; + } + + public List GetByTag(string tag) + { + var q = tag?.Trim(); + if (string.IsNullOrWhiteSpace(q)) + return []; + + var conn = _session.GetConnection(); + var all = ReadAllFragments(conn); + return [.. all.Where(f => f.Tags.Any(t => t.Contains(q, StringComparison.OrdinalIgnoreCase)))]; + } + + public List GetByType(string type) + { + var q = type?.Trim(); + if (string.IsNullOrWhiteSpace(q)) + return []; + + var conn = _session.GetConnection(); + var all = ReadAllFragments(conn); + return [.. all.Where(f => f.Type.Contains(q, StringComparison.OrdinalIgnoreCase))]; + } + + public List Search(string? type = null, string? tag = null, DateTimeOffset? timeAfter = null) + { + var conn = _session.GetConnection(); + IEnumerable results = ReadAllFragments(conn); + + var qType = type?.Trim(); + var qTag = tag?.Trim(); + + if (!string.IsNullOrWhiteSpace(qType)) + results = results.Where(f => f.Type.Contains(qType, StringComparison.OrdinalIgnoreCase)); + if (!string.IsNullOrWhiteSpace(qTag)) + results = results.Where(f => f.Tags.Any(t => t.Contains(qTag, StringComparison.OrdinalIgnoreCase))); + if (timeAfter.HasValue) + results = results.Where(f => f.Time > timeAfter.Value); + + return [.. results]; + } + + // ── Private helpers ────────────────────────────────────────────── + + private static void InsertFragment(SqliteConnection conn, Fragment f) + { + using var tx = conn.BeginTransaction(); + + using var cmd = conn.CreateCommand(); + cmd.CommandText = """ + INSERT INTO fragments (guid, entry_id, type, description, time) + VALUES (@guid, NULL, @type, @description, @time); + """; + cmd.Parameters.AddWithValue("@guid", f.Id.ToString("D")); + cmd.Parameters.AddWithValue("@type", f.Type); + cmd.Parameters.AddWithValue("@description", f.Description); + cmd.Parameters.AddWithValue("@time", f.Time.ToString("O")); + cmd.ExecuteNonQuery(); + + var fragmentRowId = GetFragmentRowId(conn, f.Id); + if (fragmentRowId.HasValue) + InsertTags(conn, fragmentRowId.Value, f.Tags); + + tx.Commit(); + } + + private static void UpdateFragmentRow(SqliteConnection conn, Fragment f) + { + using var tx = conn.BeginTransaction(); + + using var upd = conn.CreateCommand(); + upd.CommandText = """ + UPDATE fragments SET type = @type, description = @description, time = @time + WHERE guid = @guid AND entry_id IS NULL; + """; + upd.Parameters.AddWithValue("@guid", f.Id.ToString("D")); + upd.Parameters.AddWithValue("@type", f.Type); + upd.Parameters.AddWithValue("@description", f.Description); + upd.Parameters.AddWithValue("@time", f.Time.ToString("O")); + upd.ExecuteNonQuery(); + + var fragmentRowId = GetFragmentRowId(conn, f.Id); + if (fragmentRowId.HasValue) + { + using var del = conn.CreateCommand(); + del.CommandText = "DELETE FROM fragment_tags WHERE fragment_id = @id;"; + del.Parameters.AddWithValue("@id", fragmentRowId.Value); + del.ExecuteNonQuery(); + + InsertTags(conn, fragmentRowId.Value, f.Tags); + } + + tx.Commit(); + } + + private static bool DeleteFragment(SqliteConnection conn, Guid id) + { + using var tx = conn.BeginTransaction(); + + var fragmentRowId = GetFragmentRowId(conn, id); + if (fragmentRowId.HasValue) + { + using var delTags = conn.CreateCommand(); + delTags.CommandText = "DELETE FROM fragment_tags WHERE fragment_id = @id;"; + delTags.Parameters.AddWithValue("@id", fragmentRowId.Value); + delTags.ExecuteNonQuery(); + } + + using var delFrag = conn.CreateCommand(); + delFrag.CommandText = "DELETE FROM fragments WHERE guid = @guid AND entry_id IS NULL;"; + delFrag.Parameters.AddWithValue("@guid", id.ToString("D")); + var rows = delFrag.ExecuteNonQuery(); + + tx.Commit(); + return rows > 0; + } + + private static Fragment? ReadFragment(SqliteConnection conn, Guid id) + { + using var cmd = conn.CreateCommand(); + cmd.CommandText = """ + SELECT id, guid, type, description, time + FROM fragments WHERE guid = @guid AND entry_id IS NULL; + """; + cmd.Parameters.AddWithValue("@guid", id.ToString("D")); + + using var reader = cmd.ExecuteReader(); + if (!reader.Read()) + return null; + + var fragment = MapRow(reader); + fragment.Tags = ReadTags(conn, reader.GetInt64(0)); + return fragment; + } + + private static List ReadAllFragments(SqliteConnection conn) + { + var fragments = new List(); + var rowIds = new List(); + + using var cmd = conn.CreateCommand(); + cmd.CommandText = """ + SELECT id, guid, type, description, time + FROM fragments WHERE guid IS NOT NULL AND entry_id IS NULL + ORDER BY time; + """; + + using var reader = cmd.ExecuteReader(); + while (reader.Read()) + { + fragments.Add(MapRow(reader)); + rowIds.Add(reader.GetInt64(0)); + } + + for (var i = 0; i < fragments.Count; i++) + fragments[i].Tags = ReadTags(conn, rowIds[i]); + + return fragments; + } + + private static List ReadTags(SqliteConnection conn, long fragmentRowId) + { + using var cmd = conn.CreateCommand(); + cmd.CommandText = """ + SELECT t.name FROM tags t + INNER JOIN fragment_tags ft ON ft.tag_id = t.id + WHERE ft.fragment_id = @id + ORDER BY t.name; + """; + cmd.Parameters.AddWithValue("@id", fragmentRowId); + + var tags = new List(); + using var reader = cmd.ExecuteReader(); + while (reader.Read()) + tags.Add(reader.GetString(0)); + + return tags; + } + + private static long? GetFragmentRowId(SqliteConnection conn, Guid guid) + { + using var cmd = conn.CreateCommand(); + cmd.CommandText = "SELECT id FROM fragments WHERE guid = @guid;"; + cmd.Parameters.AddWithValue("@guid", guid.ToString("D")); + var result = cmd.ExecuteScalar(); + return result is long id ? id : null; + } + + private static void InsertTags(SqliteConnection conn, long fragmentRowId, List tags) + { + if (tags.Count == 0) return; + + foreach (var tag in tags) + { + // Upsert into tags table + using var upsert = conn.CreateCommand(); + upsert.CommandText = "INSERT OR IGNORE INTO tags (name) VALUES (@name);"; + upsert.Parameters.AddWithValue("@name", tag); + upsert.ExecuteNonQuery(); + + // Get tag id + using var getTagId = conn.CreateCommand(); + getTagId.CommandText = "SELECT id FROM tags WHERE name = @name;"; + getTagId.Parameters.AddWithValue("@name", tag); + var tagId = (long)getTagId.ExecuteScalar()!; + + // Link fragment to tag + using var link = conn.CreateCommand(); + link.CommandText = "INSERT OR IGNORE INTO fragment_tags (fragment_id, tag_id) VALUES (@fid, @tid);"; + link.Parameters.AddWithValue("@fid", fragmentRowId); + link.Parameters.AddWithValue("@tid", tagId); + link.ExecuteNonQuery(); + } + } + + private static Fragment MapRow(SqliteDataReader reader) + { + // columns: id (int), guid (text), type (text), description (text), time (text) + var guid = Guid.Parse(reader.GetString(1)); + var type = reader.GetString(2); + var description = reader.IsDBNull(3) ? "" : reader.GetString(3); + var time = reader.IsDBNull(4) + ? DateTimeOffset.MinValue + : DateTimeOffset.Parse(reader.GetString(4)); + return new Fragment(guid, type, description, time); + } + + private static void Normalize(Fragment fragment) + { + fragment.Type = fragment.Type.Trim(); + fragment.Description = fragment.Description.Trim(); + fragment.Tags = [.. + fragment.Tags.Where(t => !string.IsNullOrWhiteSpace(t)) + .Select(t => t.Trim())]; + } +} diff --git a/Journal.Core/Repositories/SqliteListRepository.cs b/Journal.Core/Repositories/SqliteListRepository.cs new file mode 100644 index 0000000..4a51225 --- /dev/null +++ b/Journal.Core/Repositories/SqliteListRepository.cs @@ -0,0 +1,129 @@ +using Journal.Core.Models; +using Journal.Core.Services.Database; +using Microsoft.Data.Sqlite; + +namespace Journal.Core.Repositories; + +public sealed class SqliteListRepository(IDatabaseSessionService session) : IListRepository +{ + private readonly IDatabaseSessionService _session = session; + + public List GetAll() + { + var conn = _session.GetConnection(); + return ReadAll(conn); + } + + public ListDocument? GetById(Guid id) + { + var conn = _session.GetConnection(); + return ReadById(conn, id); + } + + public void Add(ListDocument list) + { + ArgumentNullException.ThrowIfNull(list); + var conn = _session.GetConnection(); + Insert(conn, list); + } + + public bool Update(Guid id, string? label = null, string? content = null) + { + var conn = _session.GetConnection(); + var existing = ReadById(conn, id); + if (existing is null) + return false; + + if (label is not null) + { + if (string.IsNullOrWhiteSpace(label)) + throw new ArgumentException("Label cannot be empty", nameof(label)); + existing.Label = label.Trim(); + } + + if (content is not null) + existing.Content = content; + + existing.UpdatedAt = DateTimeOffset.Now; + UpdateRow(conn, existing); + return true; + } + + public bool Remove(Guid id) + { + var conn = _session.GetConnection(); + return Delete(conn, id); + } + + // ── Private helpers ────────────────────────────────────────────── + + private static void Insert(SqliteConnection conn, ListDocument list) + { + using var cmd = conn.CreateCommand(); + cmd.CommandText = """ + INSERT INTO lists (guid, label, content, created_at, updated_at) + VALUES (@guid, @label, @content, @createdAt, @updatedAt); + """; + cmd.Parameters.AddWithValue("@guid", list.Id.ToString("D")); + cmd.Parameters.AddWithValue("@label", list.Label); + cmd.Parameters.AddWithValue("@content", list.Content); + cmd.Parameters.AddWithValue("@createdAt", list.CreatedAt.ToString("O")); + cmd.Parameters.AddWithValue("@updatedAt", list.UpdatedAt.ToString("O")); + cmd.ExecuteNonQuery(); + } + + private static void UpdateRow(SqliteConnection conn, ListDocument list) + { + using var cmd = conn.CreateCommand(); + cmd.CommandText = """ + UPDATE lists SET label = @label, content = @content, updated_at = @updatedAt + WHERE guid = @guid; + """; + cmd.Parameters.AddWithValue("@guid", list.Id.ToString("D")); + cmd.Parameters.AddWithValue("@label", list.Label); + cmd.Parameters.AddWithValue("@content", list.Content); + cmd.Parameters.AddWithValue("@updatedAt", list.UpdatedAt.ToString("O")); + cmd.ExecuteNonQuery(); + } + + private static bool Delete(SqliteConnection conn, Guid id) + { + using var cmd = conn.CreateCommand(); + cmd.CommandText = "DELETE FROM lists WHERE guid = @guid;"; + cmd.Parameters.AddWithValue("@guid", id.ToString("D")); + return cmd.ExecuteNonQuery() > 0; + } + + private static ListDocument? ReadById(SqliteConnection conn, Guid id) + { + using var cmd = conn.CreateCommand(); + cmd.CommandText = "SELECT guid, label, content, created_at, updated_at FROM lists WHERE guid = @guid;"; + cmd.Parameters.AddWithValue("@guid", id.ToString("D")); + + using var reader = cmd.ExecuteReader(); + return reader.Read() ? MapRow(reader) : null; + } + + private static List ReadAll(SqliteConnection conn) + { + var results = new List(); + using var cmd = conn.CreateCommand(); + cmd.CommandText = "SELECT guid, label, content, created_at, updated_at FROM lists ORDER BY created_at;"; + + using var reader = cmd.ExecuteReader(); + while (reader.Read()) + results.Add(MapRow(reader)); + + return results; + } + + private static ListDocument MapRow(SqliteDataReader reader) + { + var guid = Guid.Parse(reader.GetString(0)); + var label = reader.GetString(1); + var content = reader.IsDBNull(2) ? "" : reader.GetString(2); + var createdAt = reader.IsDBNull(3) ? DateTimeOffset.MinValue : DateTimeOffset.Parse(reader.GetString(3)); + var updatedAt = reader.IsDBNull(4) ? createdAt : DateTimeOffset.Parse(reader.GetString(4)); + return new ListDocument(guid, label, content, createdAt, updatedAt); + } +} diff --git a/Journal.Core/Repositories/SqliteTodoRepository.cs b/Journal.Core/Repositories/SqliteTodoRepository.cs new file mode 100644 index 0000000..725dfe8 --- /dev/null +++ b/Journal.Core/Repositories/SqliteTodoRepository.cs @@ -0,0 +1,279 @@ +using Journal.Core.Models; +using Journal.Core.Services.Database; +using Microsoft.Data.Sqlite; + +namespace Journal.Core.Repositories; + +public sealed class SqliteTodoRepository(IDatabaseSessionService session) : ITodoRepository +{ + private readonly IDatabaseSessionService _session = session; + + // ── Lists ──────────────────────────────────────────────────────── + + public List GetAllLists() + { + var conn = _session.GetConnection(); + return ReadAllLists(conn); + } + + public TodoList? GetListById(Guid id) + { + var conn = _session.GetConnection(); + return ReadListById(conn, id); + } + + public void AddList(TodoList list) + { + ArgumentNullException.ThrowIfNull(list); + var conn = _session.GetConnection(); + InsertList(conn, list); + } + + public bool UpdateList(Guid id, string? label = null) + { + var conn = _session.GetConnection(); + var existing = ReadListById(conn, id); + if (existing is null) + return false; + + if (label is not null) + { + if (string.IsNullOrWhiteSpace(label)) + throw new ArgumentException("Label cannot be empty", nameof(label)); + existing.Label = label.Trim(); + } + + UpdateListRow(conn, existing); + return true; + } + + public bool RemoveList(Guid id) + { + var conn = _session.GetConnection(); + return DeleteList(conn, id); + } + + // ── Items ──────────────────────────────────────────────────────── + + public List GetItemsByListId(Guid listId) + { + var conn = _session.GetConnection(); + return ReadItemsByListId(conn, listId); + } + + public TodoItem? GetItemById(Guid id) + { + var conn = _session.GetConnection(); + return ReadItemById(conn, id); + } + + public void AddItem(TodoItem item) + { + ArgumentNullException.ThrowIfNull(item); + var conn = _session.GetConnection(); + InsertItem(conn, item); + } + + public bool UpdateItem(Guid id, string? text = null, bool? done = null, int? sortOrder = null) + { + var conn = _session.GetConnection(); + var existing = ReadItemById(conn, id); + if (existing is null) + return false; + + if (text is not null) + { + if (string.IsNullOrWhiteSpace(text)) + throw new ArgumentException("Text cannot be empty", nameof(text)); + existing.Text = text.Trim(); + } + + if (done.HasValue) + existing.Done = done.Value; + + if (sortOrder.HasValue) + existing.SortOrder = sortOrder.Value; + + UpdateItemRow(conn, existing); + return true; + } + + public bool RemoveItem(Guid id) + { + var conn = _session.GetConnection(); + return DeleteItem(conn, id); + } + + // ── Private list helpers ───────────────────────────────────────── + + private static void InsertList(SqliteConnection conn, TodoList list) + { + using var cmd = conn.CreateCommand(); + cmd.CommandText = """ + INSERT INTO todo_lists (guid, label, created_at) + VALUES (@guid, @label, @createdAt); + """; + cmd.Parameters.AddWithValue("@guid", list.Id.ToString("D")); + cmd.Parameters.AddWithValue("@label", list.Label); + cmd.Parameters.AddWithValue("@createdAt", list.CreatedAt.ToString("O")); + cmd.ExecuteNonQuery(); + } + + private static void UpdateListRow(SqliteConnection conn, TodoList list) + { + using var cmd = conn.CreateCommand(); + cmd.CommandText = "UPDATE todo_lists SET label = @label WHERE guid = @guid;"; + cmd.Parameters.AddWithValue("@guid", list.Id.ToString("D")); + cmd.Parameters.AddWithValue("@label", list.Label); + cmd.ExecuteNonQuery(); + } + + private static bool DeleteList(SqliteConnection conn, Guid id) + { + using var tx = conn.BeginTransaction(); + + var rowId = GetListRowId(conn, id); + if (rowId.HasValue) + { + using var delItems = conn.CreateCommand(); + delItems.CommandText = "DELETE FROM todo_items WHERE list_id = @listId;"; + delItems.Parameters.AddWithValue("@listId", rowId.Value); + delItems.ExecuteNonQuery(); + } + + using var delList = conn.CreateCommand(); + delList.CommandText = "DELETE FROM todo_lists WHERE guid = @guid;"; + delList.Parameters.AddWithValue("@guid", id.ToString("D")); + var rows = delList.ExecuteNonQuery(); + + tx.Commit(); + return rows > 0; + } + + private static TodoList? ReadListById(SqliteConnection conn, Guid id) + { + using var cmd = conn.CreateCommand(); + cmd.CommandText = "SELECT guid, label, created_at FROM todo_lists WHERE guid = @guid;"; + cmd.Parameters.AddWithValue("@guid", id.ToString("D")); + + using var reader = cmd.ExecuteReader(); + return reader.Read() ? MapListRow(reader) : null; + } + + private static List ReadAllLists(SqliteConnection conn) + { + var results = new List(); + using var cmd = conn.CreateCommand(); + cmd.CommandText = "SELECT guid, label, created_at FROM todo_lists ORDER BY created_at;"; + + using var reader = cmd.ExecuteReader(); + while (reader.Read()) + results.Add(MapListRow(reader)); + + return results; + } + + private static long? GetListRowId(SqliteConnection conn, Guid guid) + { + using var cmd = conn.CreateCommand(); + cmd.CommandText = "SELECT id FROM todo_lists WHERE guid = @guid;"; + cmd.Parameters.AddWithValue("@guid", guid.ToString("D")); + var result = cmd.ExecuteScalar(); + return result is long id ? id : null; + } + + private static TodoList MapListRow(SqliteDataReader reader) + { + var guid = Guid.Parse(reader.GetString(0)); + var label = reader.GetString(1); + var createdAt = reader.IsDBNull(2) ? DateTimeOffset.MinValue : DateTimeOffset.Parse(reader.GetString(2)); + return new TodoList(guid, label, createdAt); + } + + // ── Private item helpers ───────────────────────────────────────── + + private static void InsertItem(SqliteConnection conn, TodoItem item) + { + var listRowId = GetListRowId(conn, item.ListId) + ?? throw new InvalidOperationException($"Todo list {item.ListId} not found"); + + using var cmd = conn.CreateCommand(); + cmd.CommandText = """ + INSERT INTO todo_items (guid, list_id, text, done, sort_order) + VALUES (@guid, @listId, @text, @done, @sortOrder); + """; + cmd.Parameters.AddWithValue("@guid", item.Id.ToString("D")); + cmd.Parameters.AddWithValue("@listId", listRowId); + cmd.Parameters.AddWithValue("@text", item.Text); + cmd.Parameters.AddWithValue("@done", item.Done ? 1 : 0); + cmd.Parameters.AddWithValue("@sortOrder", item.SortOrder); + cmd.ExecuteNonQuery(); + } + + private static void UpdateItemRow(SqliteConnection conn, TodoItem item) + { + using var cmd = conn.CreateCommand(); + cmd.CommandText = """ + UPDATE todo_items SET text = @text, done = @done, sort_order = @sortOrder + WHERE guid = @guid; + """; + cmd.Parameters.AddWithValue("@guid", item.Id.ToString("D")); + cmd.Parameters.AddWithValue("@text", item.Text); + cmd.Parameters.AddWithValue("@done", item.Done ? 1 : 0); + cmd.Parameters.AddWithValue("@sortOrder", item.SortOrder); + cmd.ExecuteNonQuery(); + } + + private static bool DeleteItem(SqliteConnection conn, Guid id) + { + using var cmd = conn.CreateCommand(); + cmd.CommandText = "DELETE FROM todo_items WHERE guid = @guid;"; + cmd.Parameters.AddWithValue("@guid", id.ToString("D")); + return cmd.ExecuteNonQuery() > 0; + } + + private static TodoItem? ReadItemById(SqliteConnection conn, Guid id) + { + using var cmd = conn.CreateCommand(); + cmd.CommandText = """ + SELECT ti.guid, tl.guid, ti.text, ti.done, ti.sort_order + FROM todo_items ti + INNER JOIN todo_lists tl ON tl.id = ti.list_id + WHERE ti.guid = @guid; + """; + cmd.Parameters.AddWithValue("@guid", id.ToString("D")); + + using var reader = cmd.ExecuteReader(); + return reader.Read() ? MapItemRow(reader) : null; + } + + private static List ReadItemsByListId(SqliteConnection conn, Guid listId) + { + var results = new List(); + using var cmd = conn.CreateCommand(); + cmd.CommandText = """ + SELECT ti.guid, tl.guid, ti.text, ti.done, ti.sort_order + FROM todo_items ti + INNER JOIN todo_lists tl ON tl.id = ti.list_id + WHERE tl.guid = @listGuid + ORDER BY ti.sort_order, ti.guid; + """; + cmd.Parameters.AddWithValue("@listGuid", listId.ToString("D")); + + using var reader = cmd.ExecuteReader(); + while (reader.Read()) + results.Add(MapItemRow(reader)); + + return results; + } + + private static TodoItem MapItemRow(SqliteDataReader reader) + { + var guid = Guid.Parse(reader.GetString(0)); + var listGuid = Guid.Parse(reader.GetString(1)); + var text = reader.GetString(2); + var done = !reader.IsDBNull(3) && reader.GetInt64(3) != 0; + var sortOrder = reader.IsDBNull(4) ? 0 : (int)reader.GetInt64(4); + return new TodoItem(guid, listGuid, text, done, sortOrder); + } +} diff --git a/Journal.Core/ServiceCollectionExtensions.cs b/Journal.Core/ServiceCollectionExtensions.cs new file mode 100644 index 0000000..649d8a3 --- /dev/null +++ b/Journal.Core/ServiceCollectionExtensions.cs @@ -0,0 +1,71 @@ +using Microsoft.Extensions.DependencyInjection; +using Journal.Core.Repositories; +using Journal.Core.Services.Ai; +using Journal.Core.Services.Config; +using Journal.Core.Services.Database; +using Journal.Core.Services.Entries; +using Journal.Core.Services.Fragments; +using Journal.Core.Services.Lists; +using Journal.Core.Services.Logging; +using Journal.Core.Services.Sidecar; +using Journal.Core.Services.Speech; +using Journal.Core.Services.Todos; +using Journal.Core.Services.Vault; + +namespace Journal.Core; + +public static class ServiceCollectionExtensions +{ + public static IServiceCollection AddFragmentServices(this IServiceCollection services) + { + services.AddSingleton(); + services.AddSingleton(); + services.AddSingleton(); + services.AddSingleton(); + services.AddTransient(); + services.AddSingleton(); + services.AddSingleton(); + services.AddSingleton(); + services.AddSingleton(provider => + { + var config = provider.GetRequiredService().Current; + if (!string.Equals(config.AiProvider, "python-sidecar", StringComparison.OrdinalIgnoreCase)) + return new DisabledAiService(config.AiProvider); + + try + { + return new PythonSidecarAiService(config); + } + catch (Exception ex) + { + return new DisabledAiService( + provider: "python-sidecar", + message: $"Python AI sidecar unavailable: {ex.Message}", + healthy: false); + } + }); + services.AddSingleton(provider => + { + var config = provider.GetRequiredService().Current; + try + { + return new PythonSidecarSpeechService(config); + } + catch (Exception ex) + { + return new DisabledSpeechBridgeService( + provider: "python-sidecar", + message: $"Python speech sidecar unavailable: {ex.Message}"); + } + }); + services.AddSingleton(); + services.AddSingleton(); + services.AddSingleton(); + services.AddSingleton(); + services.AddSingleton(); + services.AddSingleton(); + services.AddSingleton(); + services.AddSingleton(); + return services; + } +} diff --git a/Journal.Core/Services/Ai/DisabledAiService.cs b/Journal.Core/Services/Ai/DisabledAiService.cs new file mode 100644 index 0000000..d5a7ad6 --- /dev/null +++ b/Journal.Core/Services/Ai/DisabledAiService.cs @@ -0,0 +1,25 @@ +using Journal.Core.Dtos; + +namespace Journal.Core.Services.Ai; + +public sealed class DisabledAiService(string provider, string message = "AI provider disabled.", bool healthy = true) : IAiService +{ + private readonly string _provider = string.IsNullOrWhiteSpace(provider) ? "none" : provider.Trim(); + private readonly string _message = string.IsNullOrWhiteSpace(message) ? "AI provider disabled." : message.Trim(); + private readonly bool _healthy = healthy; + + public Task HealthAsync(CancellationToken cancellationToken = default) => + Task.FromResult(new AiHealthDto(_provider, Enabled: false, Healthy: _healthy, Message: _message)); + + public Task SummarizeEntryAsync(string content, string? fileStem = null, CancellationToken cancellationToken = default) => + Task.FromResult(_message); + + public Task SummarizeAllAsync(IReadOnlyList entries, CancellationToken cancellationToken = default) => + Task.FromResult(_message); + + public Task ChatAsync(string prompt, CancellationToken cancellationToken = default) => + Task.FromResult(_message); + + public Task> EmbedAsync(string content, CancellationToken cancellationToken = default) => + Task.FromResult>([]); +} diff --git a/Journal.Core/Services/Ai/IAiService.cs b/Journal.Core/Services/Ai/IAiService.cs new file mode 100644 index 0000000..5300641 --- /dev/null +++ b/Journal.Core/Services/Ai/IAiService.cs @@ -0,0 +1,12 @@ +using Journal.Core.Dtos; + +namespace Journal.Core.Services.Ai; + +public interface IAiService +{ + Task HealthAsync(CancellationToken cancellationToken = default); + Task SummarizeEntryAsync(string content, string? fileStem = null, CancellationToken cancellationToken = default); + Task SummarizeAllAsync(IReadOnlyList entries, CancellationToken cancellationToken = default); + Task ChatAsync(string prompt, CancellationToken cancellationToken = default); + Task> EmbedAsync(string content, CancellationToken cancellationToken = default); +} diff --git a/Journal.Core/Services/Ai/PythonSidecarAiService.cs b/Journal.Core/Services/Ai/PythonSidecarAiService.cs new file mode 100644 index 0000000..daba179 --- /dev/null +++ b/Journal.Core/Services/Ai/PythonSidecarAiService.cs @@ -0,0 +1,86 @@ +using System.Text.Json; +using Journal.Core.Dtos; +using Journal.Core.Models; +using Journal.Core.Services.Sidecar; + +namespace Journal.Core.Services.Ai; + +public sealed class PythonSidecarAiService : IAiService +{ + private readonly PythonSidecarClient _client; + + public PythonSidecarAiService(JournalConfig config) + { + if (string.IsNullOrWhiteSpace(config.PythonAiSidecarPath)) + throw new ArgumentException("Python AI sidecar path is required."); + if (!File.Exists(config.PythonAiSidecarPath)) + throw new FileNotFoundException($"Python AI sidecar not found: {config.PythonAiSidecarPath}"); + _client = new PythonSidecarClient(config); + } + + public async Task HealthAsync(CancellationToken cancellationToken = default) + { + var data = await _client.SendAsync("health", payload: new { }, cancellationToken); + if (data is not JsonElement payload || payload.ValueKind != JsonValueKind.Object) + return new AiHealthDto("python-sidecar", Enabled: true, Healthy: true, Message: "ok"); + + var provider = payload.TryGetProperty("provider", out var providerNode) + ? providerNode.GetString() ?? "python-sidecar" + : "python-sidecar"; + var message = payload.TryGetProperty("message", out var messageNode) + ? messageNode.GetString() ?? "ok" + : "ok"; + var healthy = !payload.TryGetProperty("healthy", out var healthyNode) || + healthyNode.ValueKind is JsonValueKind.True || + (healthyNode.ValueKind is not JsonValueKind.False); + return new AiHealthDto(provider, Enabled: true, Healthy: healthy, Message: message); + } + + public async Task SummarizeEntryAsync(string content, string? fileStem = null, CancellationToken cancellationToken = default) + { + if (string.IsNullOrWhiteSpace(content)) + throw new ArgumentException("Entry content is required.", nameof(content)); + + var data = await _client.SendAsync("summarize_entry", new { content, file_stem = fileStem }, cancellationToken); + return data?.GetString() ?? ""; + } + + public async Task SummarizeAllAsync(IReadOnlyList entries, CancellationToken cancellationToken = default) + { + entries ??= []; + var data = await _client.SendAsync("summarize_all", new { entries }, cancellationToken); + return data?.GetString() ?? ""; + } + + public async Task ChatAsync(string prompt, CancellationToken cancellationToken = default) + { + if (string.IsNullOrWhiteSpace(prompt)) + throw new ArgumentException("Prompt is required.", nameof(prompt)); + + var data = await _client.SendAsync("chat", new { prompt }, cancellationToken); + return data?.GetString() ?? ""; + } + + public async Task> EmbedAsync(string content, CancellationToken cancellationToken = default) + { + if (string.IsNullOrWhiteSpace(content)) + throw new ArgumentException("Content is required.", nameof(content)); + + var data = await _client.SendAsync("embed", new { content }, cancellationToken); + if (data is null || data.Value.ValueKind == JsonValueKind.Null) + return []; + + if (data.Value.ValueKind != JsonValueKind.Array) + throw new InvalidOperationException("Python AI sidecar embed response must be a numeric array."); + + var values = new List(); + foreach (var item in data.Value.EnumerateArray()) + { + if (item.ValueKind != JsonValueKind.Number) + throw new InvalidOperationException("Python AI sidecar embed response contains a non-numeric value."); + values.Add(item.GetDouble()); + } + + return values; + } +} diff --git a/Journal.Core/Services/Config/IJournalConfigService.cs b/Journal.Core/Services/Config/IJournalConfigService.cs new file mode 100644 index 0000000..5da1f33 --- /dev/null +++ b/Journal.Core/Services/Config/IJournalConfigService.cs @@ -0,0 +1,8 @@ +using Journal.Core.Models; + +namespace Journal.Core.Services.Config; + +public interface IJournalConfigService +{ + JournalConfig Current { get; } +} diff --git a/Journal.Core/Services/Config/JournalConfigService.cs b/Journal.Core/Services/Config/JournalConfigService.cs new file mode 100644 index 0000000..f33a9c1 --- /dev/null +++ b/Journal.Core/Services/Config/JournalConfigService.cs @@ -0,0 +1,108 @@ +using Journal.Core.Models; + +namespace Journal.Core.Services.Config; + +public sealed class JournalConfigService : IJournalConfigService +{ + public JournalConfig Current => BuildConfig(); + + private static JournalConfig BuildConfig() + { + var projectRoot = ResolveProjectRoot(); + var appDirectory = ResolvePath("JOURNAL_APP_DIR", Path.Combine(projectRoot, "journal")); + + var dataDirectory = ResolvePath("JOURNAL_DATA_DIR", Path.Combine(appDirectory, "data")); + var vaultDirectory = ResolvePath("JOURNAL_VAULT_DIR", Path.Combine(appDirectory, "vault")); + var logDirectory = ResolvePath("JOURNAL_LOG_DIR", Path.Combine(projectRoot, "logs")); + + var pidFile = ResolvePath("JOURNAL_PID_FILE", Path.Combine(logDirectory, "nicegui_server.pid")); + var serverControlFile = ResolvePath("JOURNAL_SERVER_CONTROL_FILE", Path.Combine(logDirectory, "server_control.action")); + + var nlpBackend = (Environment.GetEnvironmentVariable("JOURNAL_NLP_BACKEND") ?? "auto").Trim().ToLowerInvariant(); + if (nlpBackend is not ("auto" or "spacy" or "fallback")) + nlpBackend = "auto"; + + var aiProvider = (Environment.GetEnvironmentVariable("JOURNAL_AI_PROVIDER") ?? "none").Trim().ToLowerInvariant(); + if (aiProvider is not ("none" or "python-sidecar")) + aiProvider = "none"; + + var pythonExecutable = Environment.GetEnvironmentVariable("JOURNAL_PYTHON_EXE"); + if (string.IsNullOrWhiteSpace(pythonExecutable)) + pythonExecutable = "python"; + + var defaultAiSidecarPath = Path.Combine(projectRoot, "journal", "ai", "sidecar.py"); + var pythonAiSidecarPath = ResolvePath("JOURNAL_AI_SIDECAR_PATH", defaultAiSidecarPath); + var aiSidecarTimeoutMs = ParseInt("JOURNAL_AI_TIMEOUT_MS", 45000); + + return new JournalConfig( + ProjectRoot: projectRoot, + AppDirectory: appDirectory, + DataDirectory: dataDirectory, + VaultDirectory: vaultDirectory, + LogDirectory: logDirectory, + PidFile: pidFile, + ServerControlFile: serverControlFile, + DatabaseFilename: Environment.GetEnvironmentVariable("JOURNAL_DATABASE_FILENAME") ?? "journal_cache.db", + MonthlyVaultFormat: Environment.GetEnvironmentVariable("JOURNAL_MONTHLY_VAULT_FORMAT") ?? "%Y-%m.vault", + CloudAiApiKey: Environment.GetEnvironmentVariable("CLOUDAI_API_KEY") ?? "", + CloudAiApiUrl: Environment.GetEnvironmentVariable("CLOUDAI_API_URL") ?? "", + LlamaCppUrl: Environment.GetEnvironmentVariable("LLAMA_CPP_URL") ?? "http://127.0.0.1:8085/v1/completions", + LlamaCppModel: Environment.GetEnvironmentVariable("LLAMA_CPP_MODEL") ?? "qwen/qwen3-4b", + LlamaCppTimeout: ParseInt("LLAMA_CPP_TIMEOUT", 6000), + EmbeddingApiUrl: Environment.GetEnvironmentVariable("EMBEDDING_API_URL") ?? "http://127.0.0.1:8086/v1/embeddings", + EmbeddingModelName: Environment.GetEnvironmentVariable("EMBEDDING_MODEL_NAME") ?? "text-embedding-nomic-embed-text-v2-moe", + ModelContextTokens: ParseInt("MODEL_CONTEXT_TOKENS", 131072), + ChunkTokenBudget: ParseInt("CHUNK_TOKEN_BUDGET", 120000), + MicrophoneDeviceIndex: ParseNullableInt("MICROPHONE_DEVICE_INDEX"), + SpeechRecognitionEngine: Environment.GetEnvironmentVariable("SPEECH_RECOGNITION_ENGINE") ?? "whisper", + WhisperModelSize: Environment.GetEnvironmentVariable("WHISPER_MODEL_SIZE") ?? "base", + NlpBackend: nlpBackend, + AiProvider: aiProvider, + PythonExecutable: pythonExecutable, + PythonAiSidecarPath: pythonAiSidecarPath, + AiSidecarTimeoutMs: aiSidecarTimeoutMs); + } + + private static string ResolveProjectRoot() + { + var envRoot = Environment.GetEnvironmentVariable("JOURNAL_PROJECT_ROOT"); + if (!string.IsNullOrWhiteSpace(envRoot)) + return Path.GetFullPath(envRoot); + + var cwd = Directory.GetCurrentDirectory(); + if (Directory.Exists(Path.Combine(cwd, "journal"))) + return Path.GetFullPath(cwd); + + var upOne = Path.GetFullPath(Path.Combine(cwd, "..")); + if (Directory.Exists(Path.Combine(upOne, "journal"))) + return upOne; + + var upTwo = Path.GetFullPath(Path.Combine(cwd, "..", "..")); + if (Directory.Exists(Path.Combine(upTwo, "journal"))) + return upTwo; + + return Path.GetFullPath(cwd); + } + + private static string ResolvePath(string envVar, string defaultPath) + { + var value = Environment.GetEnvironmentVariable(envVar); + var raw = string.IsNullOrWhiteSpace(value) ? defaultPath : value; + return Path.GetFullPath(raw); + } + + private static int ParseInt(string envVar, int defaultValue) + { + var value = Environment.GetEnvironmentVariable(envVar); + return int.TryParse(value, out var parsed) ? parsed : defaultValue; + } + + private static int? ParseNullableInt(string envVar) + { + var value = Environment.GetEnvironmentVariable(envVar); + if (string.IsNullOrWhiteSpace(value)) + return null; + return int.TryParse(value, out var parsed) ? parsed : null; + } +} + diff --git a/Journal.Core/Services/Database/DatabaseSessionService.cs b/Journal.Core/Services/Database/DatabaseSessionService.cs new file mode 100644 index 0000000..67e3f11 --- /dev/null +++ b/Journal.Core/Services/Database/DatabaseSessionService.cs @@ -0,0 +1,87 @@ +using Microsoft.Data.Sqlite; + +namespace Journal.Core.Services.Database; + +public sealed class DatabaseSessionService(IJournalDatabaseService database) : IDatabaseSessionService, IDisposable +{ + private readonly IJournalDatabaseService _database = database; + private readonly Lock _lock = new(); + private string? _password; + private string? _dataDirectory; + private SqliteConnection? _connection; + + public bool IsUnlocked + { + get + { + lock (_lock) { return _password is not null; } + } + } + + public void SetPassword(string password, string? dataDirectory = null) + { + if (string.IsNullOrWhiteSpace(password)) + throw new ArgumentException("Password cannot be empty.", nameof(password)); + + lock (_lock) + { + if (_connection is not null && + (_password != password || _dataDirectory != dataDirectory)) + { + _connection.Dispose(); + _connection = null; + } + + _password = password; + _dataDirectory = dataDirectory; + } + } + + public bool TryGetSession(out string password, out string? dataDirectory) + { + lock (_lock) + { + if (string.IsNullOrWhiteSpace(_password)) + { + password = ""; + dataDirectory = null; + return false; + } + + password = _password; + dataDirectory = _dataDirectory; + return true; + } + } + + public SqliteConnection GetConnection() + { + lock (_lock) + { + if (_password is null) + throw new InvalidOperationException( + "Database is locked. Authenticate first (e.g. vault.load_all or db.hydrate_workspace)."); + + if (_connection is not null) + return _connection; + + _connection = _database.OpenEncryptedConnection(_password, _dataDirectory); + _database.EnsureSchema(_connection); + return _connection; + } + } + + public void CloseConnection() + { + lock (_lock) + { + _connection?.Dispose(); + _connection = null; + } + } + + public void Dispose() + { + CloseConnection(); + } +} diff --git a/Journal.Core/Services/Database/IDatabaseSessionService.cs b/Journal.Core/Services/Database/IDatabaseSessionService.cs new file mode 100644 index 0000000..6c29e85 --- /dev/null +++ b/Journal.Core/Services/Database/IDatabaseSessionService.cs @@ -0,0 +1,12 @@ +using Microsoft.Data.Sqlite; + +namespace Journal.Core.Services.Database; + +public interface IDatabaseSessionService +{ + bool IsUnlocked { get; } + void SetPassword(string password, string? dataDirectory = null); + bool TryGetSession(out string password, out string? dataDirectory); + SqliteConnection GetConnection(); + void CloseConnection(); +} diff --git a/Journal.Core/Services/Database/IJournalDatabaseService.cs b/Journal.Core/Services/Database/IJournalDatabaseService.cs new file mode 100644 index 0000000..8d240fd --- /dev/null +++ b/Journal.Core/Services/Database/IJournalDatabaseService.cs @@ -0,0 +1,17 @@ +using Journal.Core.Dtos; +using Microsoft.Data.Sqlite; + +namespace Journal.Core.Services.Database; + +public interface IJournalDatabaseService +{ + string GetDatabasePath(string? dataDirectory = null); + byte[] DeriveDatabaseKey(string password); + string BuildPragmaKeyStatement(string password); + IReadOnlyDictionary GetSchemaStatements(); + SqliteConnection OpenEncryptedConnection(string password, string? dataDirectory = null); + void EnsureSchema(SqliteConnection connection); + string WriteSchemaBootstrap(string? dataDirectory = null); + JournalDatabaseStatus GetStatus(string password, string? dataDirectory = null); + JournalDatabaseHydrationResult HydrateWorkspace(string password, string? dataDirectory = null); +} diff --git a/Journal.Core/Services/Database/JournalDatabaseService.cs b/Journal.Core/Services/Database/JournalDatabaseService.cs new file mode 100644 index 0000000..ae0c147 --- /dev/null +++ b/Journal.Core/Services/Database/JournalDatabaseService.cs @@ -0,0 +1,260 @@ +using System.Security.Cryptography; +using System.Text; +using Journal.Core.Dtos; +using Journal.Core.Services.Config; +using Microsoft.Data.Sqlite; + +namespace Journal.Core.Services.Database; + +public sealed class JournalDatabaseService(IJournalConfigService config) : IJournalDatabaseService +{ + public const int KeySize = 32; + public const int Iterations = 600_000; + private static readonly byte[] DatabaseKeySalt = Encoding.UTF8.GetBytes("a_fixed_salt_for_the_db_key_deriv"); + private static readonly Lock SqliteInitLock = new(); + private static bool _sqliteInitialized; + private static readonly IReadOnlyList RequiredSchemaTables = + ["entries", "sections", "fragments", "tags", "fragment_tags", "lists", "todo_lists", "todo_items"]; + + private readonly IJournalConfigService _config = config; + + public string GetDatabasePath(string? dataDirectory = null) + { + var directory = string.IsNullOrWhiteSpace(dataDirectory) + ? _config.Current.DataDirectory + : dataDirectory; + + Directory.CreateDirectory(directory); + return Path.GetFullPath(Path.Combine(directory, _config.Current.DatabaseFilename)); + } + + public byte[] DeriveDatabaseKey(string password) + { + if (string.IsNullOrWhiteSpace(password)) + throw new ArgumentException("Password cannot be empty.", nameof(password)); + + return Rfc2898DeriveBytes.Pbkdf2( + Encoding.UTF8.GetBytes(password), + DatabaseKeySalt, + Iterations, + HashAlgorithmName.SHA256, + KeySize); + } + + public string BuildPragmaKeyStatement(string password) + { + var dbKeyHex = Convert.ToHexString(DeriveDatabaseKey(password)).ToLowerInvariant(); + return $"PRAGMA key = \"x'{dbKeyHex}'\""; + } + + public IReadOnlyDictionary GetSchemaStatements() + { + return new Dictionary(StringComparer.Ordinal) + { + ["entries"] = """ + CREATE TABLE IF NOT EXISTS entries ( + id INTEGER PRIMARY KEY AUTOINCREMENT, + date TEXT NOT NULL UNIQUE + ); + """, + ["sections"] = """ + CREATE TABLE IF NOT EXISTS sections ( + id INTEGER PRIMARY KEY AUTOINCREMENT, + entry_id INTEGER NOT NULL, + title TEXT NOT NULL, + content TEXT, + FOREIGN KEY (entry_id) REFERENCES entries (id) + ); + """, + ["fragments"] = """ + CREATE TABLE IF NOT EXISTS fragments ( + id INTEGER PRIMARY KEY AUTOINCREMENT, + guid TEXT UNIQUE, + entry_id INTEGER, + type TEXT NOT NULL, + description TEXT, + time TEXT, + FOREIGN KEY (entry_id) REFERENCES entries (id) + ); + """, + ["tags"] = """ + CREATE TABLE IF NOT EXISTS tags ( + id INTEGER PRIMARY KEY AUTOINCREMENT, + name TEXT NOT NULL UNIQUE + ); + """, + ["fragment_tags"] = """ + CREATE TABLE IF NOT EXISTS fragment_tags ( + fragment_id INTEGER NOT NULL, + tag_id INTEGER NOT NULL, + PRIMARY KEY (fragment_id, tag_id), + FOREIGN KEY (fragment_id) REFERENCES fragments (id), + FOREIGN KEY (tag_id) REFERENCES tags (id) + ); + """, + ["lists"] = """ + CREATE TABLE IF NOT EXISTS lists ( + id INTEGER PRIMARY KEY AUTOINCREMENT, + guid TEXT UNIQUE, + label TEXT NOT NULL, + content TEXT, + created_at TEXT, + updated_at TEXT + ); + """, + ["todo_lists"] = """ + CREATE TABLE IF NOT EXISTS todo_lists ( + id INTEGER PRIMARY KEY AUTOINCREMENT, + guid TEXT UNIQUE, + label TEXT NOT NULL, + created_at TEXT + ); + """, + ["todo_items"] = """ + CREATE TABLE IF NOT EXISTS todo_items ( + id INTEGER PRIMARY KEY AUTOINCREMENT, + guid TEXT UNIQUE, + list_id INTEGER NOT NULL, + text TEXT NOT NULL, + done INTEGER DEFAULT 0, + sort_order INTEGER DEFAULT 0, + FOREIGN KEY (list_id) REFERENCES todo_lists (id) + ); + """ + }; + } + + public string WriteSchemaBootstrap(string? dataDirectory = null) + { + var directory = string.IsNullOrWhiteSpace(dataDirectory) + ? _config.Current.DataDirectory + : dataDirectory; + Directory.CreateDirectory(directory); + + var bootstrapPath = Path.GetFullPath(Path.Combine(directory, "journal_schema.sql")); + var statements = GetSchemaStatements() + .Select(pair => $"-- {pair.Key}\n{pair.Value.Trim()}") + .ToArray(); + var content = string.Join("\n\n", statements) + "\n"; + File.WriteAllText(bootstrapPath, content); + return bootstrapPath; + } + + public JournalDatabaseStatus GetStatus(string password, string? dataDirectory = null) + { + var tables = GetSchemaStatements().Keys.OrderBy(x => x, StringComparer.Ordinal).ToArray(); + var bootstrapPath = WriteSchemaBootstrap(dataDirectory); + var runtime = ProbeRuntime(password, dataDirectory); + return new JournalDatabaseStatus( + DatabasePath: GetDatabasePath(dataDirectory), + KeyLengthBytes: DeriveDatabaseKey(password).Length, + Iterations: Iterations, + KeyDerivation: "PBKDF2-HMAC-SHA256", + SchemaTables: tables, + SchemaBootstrapPath: bootstrapPath, + RuntimeReady: runtime.Ready, + RuntimeMessage: runtime.Message); + } + + public JournalDatabaseHydrationResult HydrateWorkspace(string password, string? dataDirectory = null) + { + var directory = string.IsNullOrWhiteSpace(dataDirectory) + ? _config.Current.DataDirectory + : dataDirectory; + Directory.CreateDirectory(directory); + + using var connection = OpenEncryptedConnection(password, directory); + EnsureSchema(connection); + var runtimeReady = HasRequiredTables(connection); + + var entryFilesProcessed = Directory.GetFiles(directory, "*.md", SearchOption.TopDirectoryOnly).Length; + var schemaPath = WriteSchemaBootstrap(directory); + + return new JournalDatabaseHydrationResult( + DatabasePath: GetDatabasePath(directory), + SchemaBootstrapPath: schemaPath, + EntryFilesProcessed: entryFilesProcessed, + RuntimeReady: runtimeReady, + Message: runtimeReady + ? "Workspace hydration completed with SQLCipher runtime schema validation." + : "Workspace hydration completed, but required schema tables were not found."); + } + + private static void EnsureSqliteInitialized() + { + if (_sqliteInitialized) + return; + + lock (SqliteInitLock) + { + if (_sqliteInitialized) + return; + + SQLitePCL.Batteries_V2.Init(); + _sqliteInitialized = true; + } + } + + public SqliteConnection OpenEncryptedConnection(string password, string? dataDirectory = null) + { + if (string.IsNullOrWhiteSpace(password)) + throw new ArgumentException("Password cannot be empty.", nameof(password)); + + EnsureSqliteInitialized(); + + var connection = new SqliteConnection($"Data Source={GetDatabasePath(dataDirectory)};Mode=ReadWriteCreate;Pooling=False"); + connection.Open(); + + using var keyCmd = connection.CreateCommand(); + keyCmd.CommandText = BuildPragmaKeyStatement(password) + ";"; + keyCmd.ExecuteNonQuery(); + + using var verifyCmd = connection.CreateCommand(); + verifyCmd.CommandText = "SELECT count(*) FROM sqlite_master;"; + _ = verifyCmd.ExecuteScalar(); + + return connection; + } + + public void EnsureSchema(SqliteConnection connection) + { + foreach (var statement in GetSchemaStatements().Values) + { + using var cmd = connection.CreateCommand(); + cmd.CommandText = statement; + cmd.ExecuteNonQuery(); + } + } + + private static bool HasRequiredTables(SqliteConnection connection) + { + var existing = new HashSet(StringComparer.OrdinalIgnoreCase); + using var cmd = connection.CreateCommand(); + cmd.CommandText = "SELECT name FROM sqlite_master WHERE type='table'"; + using var reader = cmd.ExecuteReader(); + while (reader.Read()) + { + if (!reader.IsDBNull(0)) + existing.Add(reader.GetString(0)); + } + + return RequiredSchemaTables.All(existing.Contains); + } + + private (bool Ready, string Message) ProbeRuntime(string password, string? dataDirectory) + { + try + { + using var connection = OpenEncryptedConnection(password, dataDirectory); + EnsureSchema(connection); + var ready = HasRequiredTables(connection); + return ready + ? (true, "SQLCipher runtime is available and schema tables are present.") + : (false, "SQLCipher runtime opened, but required schema tables are missing."); + } + catch (Exception ex) + { + return (false, $"SQLCipher runtime check failed: {ex.Message}"); + } + } +} diff --git a/Journal.Core/Services/Entries/EntryFileNaming.cs b/Journal.Core/Services/Entries/EntryFileNaming.cs new file mode 100644 index 0000000..7b800dd --- /dev/null +++ b/Journal.Core/Services/Entries/EntryFileNaming.cs @@ -0,0 +1,9 @@ +namespace Journal.Core.Services.Entries; + +internal static class EntryFileNaming +{ + internal const string TemplateSuffix = ".template.md"; + + internal static bool IsTemplateFileName(string fileName) + => fileName.EndsWith(TemplateSuffix, StringComparison.OrdinalIgnoreCase); +} diff --git a/Journal.Core/Services/Entries/EntryFileService.cs b/Journal.Core/Services/Entries/EntryFileService.cs new file mode 100644 index 0000000..450e859 --- /dev/null +++ b/Journal.Core/Services/Entries/EntryFileService.cs @@ -0,0 +1,170 @@ +using Journal.Core.Dtos; +using Journal.Core.Repositories; + +namespace Journal.Core.Services.Entries; + +public sealed class EntryFileService(IEntryFileRepository repo) : IEntryFileService +{ + private readonly IEntryFileRepository _repo = repo ?? throw new ArgumentNullException(nameof(repo)); + + public IReadOnlyList ListEntries(string dataDirectory) + { + return [.. _repo.ListMarkdownFiles(dataDirectory) + .Where(path => !EntryFileNaming.IsTemplateFileName(_repo.GetFileName(path))) + .Select(path => new EntryListItem( + FileName: _repo.GetFileName(path), + FilePath: _repo.GetFullPath(path)))]; + } + + public IReadOnlyList ListTemplates(string dataDirectory) + { + return [.. _repo.ListMarkdownFiles(dataDirectory) + .Where(path => EntryFileNaming.IsTemplateFileName(_repo.GetFileName(path))) + .Select(path => new EntryListItem( + FileName: _repo.GetFileName(path), + FilePath: _repo.GetFullPath(path)))]; + } + + public EntryLoadResult LoadEntry(string filePath) + { + var normalizedPath = _repo.GetFullPath(filePath); + if (!_repo.FileExists(normalizedPath)) + throw new FileNotFoundException($"Entry file not found: {normalizedPath}"); + + var rawContent = HtmlSanitizer.StripRichHtml(_repo.ReadFile(normalizedPath)); + var fileStem = _repo.GetFileNameWithoutExtension(normalizedPath); + var entry = JournalParser.ParseJournalContent(rawContent, fileStem); + + return new EntryLoadResult( + FileName: _repo.GetFileName(normalizedPath), + FilePath: normalizedPath, + Entry: entry.ToDto()); + } + + public EntryTemplateLoadResult LoadTemplate(string filePath) + { + var normalizedPath = _repo.GetFullPath(filePath); + if (!_repo.FileExists(normalizedPath)) + throw new FileNotFoundException($"Template file not found: {normalizedPath}"); + + var fileName = _repo.GetFileName(normalizedPath); + if (!EntryFileNaming.IsTemplateFileName(fileName)) + throw new ArgumentException("Template file name must end with .template.md."); + + var rawContent = HtmlSanitizer.StripRichHtml(_repo.ReadFile(normalizedPath)); + return new EntryTemplateLoadResult(fileName, normalizedPath, rawContent); + } + + public EntrySaveResult SaveEntry(EntrySavePayload payload, string defaultDataDirectory) + { + var targetPath = ResolveTargetPath(payload.FilePath, payload.FileName, defaultDataDirectory); + var mode = string.IsNullOrWhiteSpace(payload.Mode) ? "Daily" : payload.Mode.Trim(); + var sanitizedContent = HtmlSanitizer.StripRichHtml(payload.Content ?? ""); + _repo.EnsureDirectory(targetPath); + + if (string.Equals(mode, "Overwrite", StringComparison.OrdinalIgnoreCase)) + { + _repo.WriteFile(targetPath, sanitizedContent); + return new EntrySaveResult(targetPath); + } + + if (string.Equals(mode, "Fragment", StringComparison.OrdinalIgnoreCase)) + { + _repo.AppendFile(targetPath, "\n\n" + sanitizedContent.Trim()); + return new EntrySaveResult(targetPath); + } + + string finalContent; + if (_repo.FileExists(targetPath)) + { + var existingContent = _repo.ReadFile(targetPath); + var fileStem = _repo.GetFileNameWithoutExtension(targetPath); + var existingEntry = JournalParser.ParseJournalContent(existingContent, fileStem); + var newEntryData = JournalParser.ParseJournalContent(sanitizedContent, fileStem); + existingEntry.MergeWith(newEntryData); + finalContent = existingEntry.ToMarkdown(); + } + else + { + finalContent = sanitizedContent; + } + + _repo.WriteFile(targetPath, finalContent); + return new EntrySaveResult(targetPath); + } + + public EntrySaveResult SaveTemplate(EntryTemplateSavePayload payload, string defaultDataDirectory) + { + ArgumentNullException.ThrowIfNull(payload); + if (string.IsNullOrWhiteSpace(payload.Name)) + throw new ArgumentException("Template name is required."); + + var directory = string.IsNullOrWhiteSpace(payload.DataDirectory) + ? defaultDataDirectory + : payload.DataDirectory; + var targetPath = ResolveTemplatePath(payload.FilePath, payload.Name, directory); + var fileName = _repo.GetFileName(targetPath); + if (!EntryFileNaming.IsTemplateFileName(fileName)) + throw new ArgumentException("Template file name must end with .template.md."); + + var sanitizedContent = HtmlSanitizer.StripRichHtml(payload.Content ?? ""); + _repo.EnsureDirectory(targetPath); + _repo.WriteFile(targetPath, sanitizedContent); + return new EntrySaveResult(targetPath); + } + + public bool DeleteEntry(string filePath) + { + var normalizedPath = _repo.GetFullPath(filePath); + if (!_repo.FileExists(normalizedPath)) + return false; + _repo.DeleteFile(normalizedPath); + return true; + } + + public bool DeleteTemplate(string filePath) + { + var normalizedPath = _repo.GetFullPath(filePath); + if (!_repo.FileExists(normalizedPath)) + return false; + + var fileName = _repo.GetFileName(normalizedPath); + if (!EntryFileNaming.IsTemplateFileName(fileName)) + return false; + + _repo.DeleteFile(normalizedPath); + return true; + } + + private string ResolveTargetPath(string? filePath, string? fileName, string defaultDataDirectory) + { + if (!string.IsNullOrWhiteSpace(filePath)) + return _repo.GetFullPath(filePath); + + var name = !string.IsNullOrWhiteSpace(fileName) + ? SanitizeFileName(fileName) + : $"{DateTime.Now:yyyy-MM-dd}"; + + return _repo.GetFullPath(Path.Combine(defaultDataDirectory, $"{name}.md")); + } + + private string ResolveTemplatePath(string? filePath, string templateName, string defaultDataDirectory) + { + if (!string.IsNullOrWhiteSpace(filePath)) + return _repo.GetFullPath(filePath); + + var name = SanitizeFileName(templateName); + return _repo.GetFullPath(Path.Combine(defaultDataDirectory, $"{name}{EntryFileNaming.TemplateSuffix}")); + } + + private static string SanitizeFileName(string name) + { + var trimmed = name.Trim(); + if (trimmed.EndsWith(".md", StringComparison.OrdinalIgnoreCase)) + trimmed = trimmed[..^3]; + + var invalid = Path.GetInvalidFileNameChars(); + var sanitized = new string(trimmed.Select(c => Array.IndexOf(invalid, c) >= 0 ? '_' : c).ToArray()); + return string.IsNullOrWhiteSpace(sanitized) ? "untitled" : sanitized; + } +} diff --git a/Journal.Core/Services/Entries/EntrySearchService.cs b/Journal.Core/Services/Entries/EntrySearchService.cs new file mode 100644 index 0000000..b1df327 --- /dev/null +++ b/Journal.Core/Services/Entries/EntrySearchService.cs @@ -0,0 +1,111 @@ +using Journal.Core.Dtos; +using System.Globalization; + +namespace Journal.Core.Services.Entries; + +public class EntrySearchService : IEntrySearchService +{ + public Task> SearchEntriesAsync(EntrySearchRequestDto request) + { + ArgumentNullException.ThrowIfNull(request); + if (string.IsNullOrWhiteSpace(request.DataDirectory)) + throw new ArgumentException("Data directory is required.", nameof(request.DataDirectory)); + + if (!Directory.Exists(request.DataDirectory)) + return Task.FromResult>([]); + + var hasQuery = !string.IsNullOrWhiteSpace(request.Query); + var query = request.Query?.Trim() ?? ""; + var hasSectionFilter = !string.IsNullOrWhiteSpace(request.Section); + var section = request.Section?.Trim() ?? ""; + + var typeSet = NormalizeSet(request.Types); + var tagSet = NormalizeSet(request.Tags); + var checkedSet = NormalizeSet(request.Checked); + var uncheckedSet = NormalizeSet(request.Unchecked); + var hasFragmentFilters = typeSet.Count > 0 || tagSet.Count > 0; + var hasCheckboxFilters = checkedSet.Count > 0 || uncheckedSet.Count > 0; + + var startDate = ParseOptionalDate(request.StartDate, nameof(request.StartDate)); + var endDate = ParseOptionalDate(request.EndDate, nameof(request.EndDate)); + if (startDate.HasValue && endDate.HasValue && startDate.Value > endDate.Value) + throw new ArgumentException("startDate cannot be after endDate."); + + var results = new List(); + foreach (var filePath in Directory.GetFiles(request.DataDirectory, "*.md") + .OrderBy(Path.GetFileName, StringComparer.Ordinal)) + { + var fileName = Path.GetFileName(filePath); + if (EntryFileNaming.IsTemplateFileName(fileName)) + continue; + + var fileStem = Path.GetFileNameWithoutExtension(filePath); + var rawContent = File.ReadAllText(filePath); + var entry = JournalParser.ParseJournalContent(rawContent, fileStem); + + if (startDate.HasValue || endDate.HasValue) + { + if (!DateOnly.TryParseExact(entry.Date, "yyyy-MM-dd", CultureInfo.InvariantCulture, DateTimeStyles.None, out var entryDate)) + continue; + + if (startDate.HasValue && entryDate < startDate.Value) + continue; + if (endDate.HasValue && entryDate > endDate.Value) + continue; + } + + var contentMatch = true; + if (hasQuery) + { + var haystack = hasSectionFilter ? entry.GetSection(section) : entry.RawContent; + contentMatch = haystack.IndexOf(query, StringComparison.OrdinalIgnoreCase) >= 0; + } + if (!contentMatch) + continue; + + var fragmentMatch = !hasFragmentFilters || entry.Fragments.Any(fragment => + (typeSet.Count == 0 || typeSet.Contains(fragment.Type)) && + (tagSet.Count == 0 || fragment.Tags.Any(tagSet.Contains))); + if (!fragmentMatch) + continue; + + var checkboxMatch = !hasCheckboxFilters || entry.Sections.Values.Any(sectionValue => + sectionValue.Checkboxes.Any(checkbox => + (checkedSet.Count > 0 && checkbox.Value && checkedSet.Contains(checkbox.Key)) || + (uncheckedSet.Count > 0 && !checkbox.Value && uncheckedSet.Contains(checkbox.Key)))); + if (!checkboxMatch) + continue; + + results.Add(new EntrySearchResultDto(fileName, entry.ToDto())); + } + + return Task.FromResult>(results); + } + + private static HashSet NormalizeSet(IReadOnlyList? values) + { + if (values is null || values.Count == 0) + return []; + + var set = new HashSet(StringComparer.Ordinal); + foreach (var value in values) + { + if (string.IsNullOrWhiteSpace(value)) + continue; + set.Add(value.Trim()); + } + + return set; + } + + private static DateOnly? ParseOptionalDate(string? raw, string argumentName) + { + if (string.IsNullOrWhiteSpace(raw)) + return null; + + if (DateOnly.TryParseExact(raw.Trim(), "yyyy-MM-dd", CultureInfo.InvariantCulture, DateTimeStyles.None, out var date)) + return date; + + throw new ArgumentException($"Invalid {argumentName} value. Expected yyyy-MM-dd."); + } +} diff --git a/Journal.Core/Services/Entries/HtmlSanitizer.cs b/Journal.Core/Services/Entries/HtmlSanitizer.cs new file mode 100644 index 0000000..7b31c48 --- /dev/null +++ b/Journal.Core/Services/Entries/HtmlSanitizer.cs @@ -0,0 +1,81 @@ +using System.Net; +using System.Text.RegularExpressions; + +namespace Journal.Core.Services.Entries; + +public static partial class HtmlSanitizer +{ + [GeneratedRegex("<(script|style)\\b[^>]*>.*?", RegexOptions.IgnoreCase | RegexOptions.Singleline)] + private static partial Regex ScriptStyleRegex(); + + [GeneratedRegex("", RegexOptions.IgnoreCase)] + private static partial Regex BrTagRegex(); + + [GeneratedRegex("", RegexOptions.IgnoreCase)] + private static partial Regex BlockEndTagRegex(); + + [GeneratedRegex("]*>", RegexOptions.IgnoreCase)] + private static partial Regex LiStartTagRegex(); + + [GeneratedRegex("", RegexOptions.IgnoreCase)] + private static partial Regex LiEndTagRegex(); + + [GeneratedRegex("<(td|th)\\b[^>]*>", RegexOptions.IgnoreCase)] + private static partial Regex CellStartTagRegex(); + + [GeneratedRegex("", RegexOptions.IgnoreCase)] + private static partial Regex CellEndTagRegex(); + + [GeneratedRegex("]*>", RegexOptions.IgnoreCase)] + private static partial Regex HrTagRegex(); + + [GeneratedRegex("<[^>]+>", RegexOptions.Singleline)] + private static partial Regex AllTagsRegex(); + + [GeneratedRegex("[ \\t]{2,}")] + private static partial Regex MultipleSpacesRegex(); + + [GeneratedRegex("\n{3,}")] + private static partial Regex MultipleNewlinesRegex(); + + [GeneratedRegex("]*>")] + private static partial Regex HtmlTagCountRegex(); + public static string StripRichHtml(string content) + { + if (string.IsNullOrWhiteSpace(content)) + return content; + if (!LooksLikeRichHtml(content)) + return content; + + var text = content.Replace("\r\n", "\n").Replace("\r", "\n"); + text = ScriptStyleRegex().Replace(text, ""); + text = BrTagRegex().Replace(text, "\n"); + text = BlockEndTagRegex().Replace(text, "\n"); + text = LiStartTagRegex().Replace(text, "\n- "); + text = LiEndTagRegex().Replace(text, "\n"); + text = CellStartTagRegex().Replace(text, " | "); + text = CellEndTagRegex().Replace(text, " "); + text = HrTagRegex().Replace(text, "\n---\n"); + text = AllTagsRegex().Replace(text, ""); + text = WebUtility.HtmlDecode(text) + .Replace('\u00a0', ' ') + .Replace("\u200b", "", StringComparison.Ordinal); + text = string.Join("\n", text.Split('\n').Select(line => line.TrimEnd())); + text = MultipleSpacesRegex().Replace(text, " "); + text = MultipleNewlinesRegex().Replace(text, "\n\n").Trim(); + return string.IsNullOrEmpty(text) ? content : text; + } + + public static bool LooksLikeRichHtml(string content) + { + var lowered = content.ToLowerInvariant(); + string[] markers = + [ + "", " lowered.Contains(marker, StringComparison.Ordinal))) + return true; + return HtmlTagCountRegex().Matches(lowered).Count >= 8; + } +} diff --git a/Journal.Core/Services/Entries/IEntryFileService.cs b/Journal.Core/Services/Entries/IEntryFileService.cs new file mode 100644 index 0000000..3983272 --- /dev/null +++ b/Journal.Core/Services/Entries/IEntryFileService.cs @@ -0,0 +1,15 @@ +using Journal.Core.Dtos; + +namespace Journal.Core.Services.Entries; + +public interface IEntryFileService +{ + IReadOnlyList ListEntries(string dataDirectory); + IReadOnlyList ListTemplates(string dataDirectory); + EntryLoadResult LoadEntry(string filePath); + EntryTemplateLoadResult LoadTemplate(string filePath); + EntrySaveResult SaveEntry(EntrySavePayload payload, string defaultDataDirectory); + EntrySaveResult SaveTemplate(EntryTemplateSavePayload payload, string defaultDataDirectory); + bool DeleteEntry(string filePath); + bool DeleteTemplate(string filePath); +} diff --git a/Journal.Core/Services/Entries/IEntrySearchService.cs b/Journal.Core/Services/Entries/IEntrySearchService.cs new file mode 100644 index 0000000..6a2c24a --- /dev/null +++ b/Journal.Core/Services/Entries/IEntrySearchService.cs @@ -0,0 +1,8 @@ +using Journal.Core.Dtos; + +namespace Journal.Core.Services.Entries; + +public interface IEntrySearchService +{ + Task> SearchEntriesAsync(EntrySearchRequestDto request); +} diff --git a/Journal.Core/Services/Entries/JournalEntryDtoMapper.cs b/Journal.Core/Services/Entries/JournalEntryDtoMapper.cs new file mode 100644 index 0000000..1cce1d5 --- /dev/null +++ b/Journal.Core/Services/Entries/JournalEntryDtoMapper.cs @@ -0,0 +1,32 @@ +using Journal.Core.Dtos; +using Journal.Core.Models; + +namespace Journal.Core.Services.Entries; + +internal static class JournalEntryDtoMapper +{ + public static JournalEntryDto ToDto(this JournalEntry entry) + { + ArgumentNullException.ThrowIfNull(entry); + + return new JournalEntryDto( + Date: entry.Date, + Fragments: + [ + .. entry.Fragments.Select(fragment => new FragmentDto( + Id: fragment.Id, + Type: fragment.Type, + Description: fragment.Description, + Time: fragment.Time, + Tags: [.. fragment.Tags])) + ], + RawContent: entry.RawContent, + Sections: entry.Sections.ToDictionary( + section => section.Key, + section => new ParsedSectionDto( + Title: section.Value.Title, + Content: [.. section.Value.Content], + Checkboxes: section.Value.Checkboxes.ToDictionary(checkbox => checkbox.Key, checkbox => checkbox.Value)), + StringComparer.Ordinal)); + } +} diff --git a/Journal.Core/Services/Entries/JournalParser.cs b/Journal.Core/Services/Entries/JournalParser.cs new file mode 100644 index 0000000..7f74811 --- /dev/null +++ b/Journal.Core/Services/Entries/JournalParser.cs @@ -0,0 +1,175 @@ +using System.Text.RegularExpressions; +using Journal.Core.Models; + +namespace Journal.Core.Services.Entries; + +public static partial class JournalParser +{ + [GeneratedRegex(@"(?:\*\*Date:\*\*|\*\*Date:|Date:)\s*(.+)")] + private static partial Regex DatePattern(); + [GeneratedRegex(@"^\#\#+\s*(.*)$")] + private static partial Regex SectionHeaderPattern(); + [GeneratedRegex(@"^\s*[-*]\s*\[([xX ])\]\s*(.*)$")] + private static partial Regex CheckboxPattern(); + [GeneratedRegex(@"^(!\w+)\s*((?:@\S+\s*)?)(?:\s*((?:#\S+\s*)*))?\s*$")] + private static partial Regex FragmentHeaderPattern(); + [GeneratedRegex(@"^!\w+\s*")] + private static partial Regex FragmentBoundaryPattern(); + + public static JournalEntry ParseJournalContent(string content, string fileStem) + { + ArgumentNullException.ThrowIfNull(content); + return new JournalEntry( + date: ExtractDate(content, fileStem), + rawContent: content, + sections: ParseSections(content), + fragments: ParseFragments(content)); + } + + public static string ExtractDate(string content, string fileStem) + { + ArgumentNullException.ThrowIfNull(content); + if (string.IsNullOrWhiteSpace(fileStem)) + throw new ArgumentException("File stem is required", nameof(fileStem)); + + var match = DatePattern().Match(content); + if (match.Success) + { + var parsed = match.Groups[1].Value.Trim(); + if (!string.IsNullOrWhiteSpace(parsed)) + return parsed; + } + + return fileStem.Trim(); + } + + public static Dictionary ParseSections(string content) + { + ArgumentNullException.ThrowIfNull(content); + + var parsedSections = new Dictionary(); + string? currentSectionTitle = null; + var currentSectionContent = new List(); + var currentSectionCheckboxes = new Dictionary(); + + var lines = content.Split(["\r\n", "\n", "\r"], StringSplitOptions.None); + foreach (var line in lines) + { + var sectionHeaderMatch = SectionHeaderPattern().Match(line.Trim()); + if (sectionHeaderMatch.Success) + { + if (currentSectionTitle is not null) + { + parsedSections[currentSectionTitle] = new ParsedSection( + currentSectionTitle, + currentSectionContent, + currentSectionCheckboxes); + } + + var headerText = sectionHeaderMatch.Groups[1].Value.Trim(); + var foundTitle = FindCanonicalSectionTitle(headerText); + + if (foundTitle is not null) + { + currentSectionTitle = foundTitle; + currentSectionContent = []; + currentSectionCheckboxes = []; + } + else + { + currentSectionTitle = null; + currentSectionContent = []; + currentSectionCheckboxes = []; + } + + continue; + } + + if (currentSectionTitle is not null) + { + var checkboxMatch = CheckboxPattern().Match(line); + if (checkboxMatch.Success) + { + var isChecked = checkboxMatch.Groups[1].Value.Trim().Equals("x", StringComparison.OrdinalIgnoreCase); + var checkboxText = checkboxMatch.Groups[2].Value.Trim(); + currentSectionCheckboxes[checkboxText] = isChecked; + } + + currentSectionContent.Add(line); + } + } + + if (currentSectionTitle is not null) + { + parsedSections[currentSectionTitle] = new ParsedSection( + currentSectionTitle, + currentSectionContent, + currentSectionCheckboxes); + } + + return parsedSections; + } + + public static List ParseFragments(string content) + { + ArgumentNullException.ThrowIfNull(content); + + var fragments = new List(); + var lines = content.Split(["\r\n", "\n", "\r"], StringSplitOptions.None); + + for (var i = 0; i < lines.Length; i++) + { + var headerMatch = FragmentHeaderPattern().Match(lines[i]); + if (!headerMatch.Success) + continue; + + var type = headerMatch.Groups[1].Value.Trim(); + var timeToken = headerMatch.Groups[2].Value.Trim().TrimStart('@'); + var tagsToken = headerMatch.Groups[3].Value.Trim(); + + var descriptionLines = new List(); + var j = i + 1; + while (j < lines.Length && !FragmentBoundaryPattern().IsMatch(lines[j])) + { + descriptionLines.Add(lines[j]); + j++; + } + + var description = string.Join("\n", descriptionLines).Trim(); + if (!string.IsNullOrWhiteSpace(description)) + { + var fragment = new Fragment(type, description); + if (!string.IsNullOrWhiteSpace(timeToken) && DateTimeOffset.TryParse(timeToken, out var parsedTime)) + fragment.Time = parsedTime; + + if (!string.IsNullOrWhiteSpace(tagsToken)) + { + fragment.Tags = + [ + .. tagsToken.Split(' ', StringSplitOptions.RemoveEmptyEntries) + .Where(t => t.StartsWith('#')) + .Select(t => t.Trim().TrimStart('#')) + .Where(t => !string.IsNullOrWhiteSpace(t)) + ]; + } + + fragments.Add(fragment); + } + + i = j - 1; + } + + return fragments; + } + + private static string? FindCanonicalSectionTitle(string headerText) + { + foreach (var title in SectionTitles.Canonical) + { + if (headerText.Contains(title, StringComparison.OrdinalIgnoreCase)) + return title; + } + + return null; + } +} diff --git a/Journal.Core/Services/Fragments/FragmentService.cs b/Journal.Core/Services/Fragments/FragmentService.cs new file mode 100644 index 0000000..55917fa --- /dev/null +++ b/Journal.Core/Services/Fragments/FragmentService.cs @@ -0,0 +1,81 @@ +using System.ComponentModel.DataAnnotations; +using Journal.Core.Dtos; +using Journal.Core.Models; +using Journal.Core.Repositories; + +namespace Journal.Core.Services.Fragments; + +public class FragmentService(IFragmentRepository repo) : IFragmentService +{ + private readonly IFragmentRepository _repo = repo ?? throw new ArgumentNullException(nameof(repo)); + + private static FragmentDto Map(Fragment f) => new( + f.Id, + f.Type, + f.Description, + f.Time, + f.Tags != null ? [.. f.Tags] : [] + ); + + public FragmentDto Create(CreateFragmentDto dto) + { + ArgumentNullException.ThrowIfNull(dto); + + var ctx = new ValidationContext(dto); + Validator.ValidateObject(dto, ctx, validateAllProperties: true); + + var f = new Fragment(dto.Type, dto.Description); + if (dto.Tags != null) + f.Tags = [.. dto.Tags.Where(t => !string.IsNullOrWhiteSpace(t)).Select(t => t!.Trim())]; + + _repo.Add(f); + return Map(f); + } + + public bool Update(Guid id, UpdateFragmentDto dto) + { + ArgumentNullException.ThrowIfNull(dto); + if (dto.Type != null && string.IsNullOrWhiteSpace(dto.Type)) + throw new ValidationException("Type cannot be empty"); + if (dto.Description != null && string.IsNullOrWhiteSpace(dto.Description)) + throw new ValidationException("Description cannot be empty"); + + var type = dto.Type?.Trim(); + var description = dto.Description?.Trim(); + var tags = dto.Tags?.Where(t => !string.IsNullOrWhiteSpace(t)).Select(t => t!.Trim()).ToList(); + + return _repo.Update(id, type, description, tags, dto.Time); + } + + public bool Remove(Guid id) => _repo.Remove(id); + + public List Search(string? type = null, string? tag = null, DateTimeOffset? timeAfter = null) + { + var items = _repo.Search(type, tag, timeAfter); + return [.. items.Select(Map)]; + } + + public List GetByTag(string tag) + { + var items = _repo.GetByTag(tag); + return [.. items.Select(Map)]; + } + + public List GetByType(string type) + { + var items = _repo.GetByType(type); + return [.. items.Select(Map)]; + } + + public List GetAll() + { + var items = _repo.GetAll(); + return [.. items.Select(Map)]; + } + + public FragmentDto? GetById(Guid id) + { + var f = _repo.GetById(id); + return f is null ? null : Map(f); + } +} diff --git a/Journal.Core/Services/Fragments/IFragmentService.cs b/Journal.Core/Services/Fragments/IFragmentService.cs new file mode 100644 index 0000000..6087081 --- /dev/null +++ b/Journal.Core/Services/Fragments/IFragmentService.cs @@ -0,0 +1,15 @@ +using Journal.Core.Dtos; + +namespace Journal.Core.Services.Fragments; + +public interface IFragmentService +{ + FragmentDto Create(CreateFragmentDto dto); + bool Update(Guid id, UpdateFragmentDto dto); + bool Remove(Guid id); + List Search(string? type = null, string? tag = null, DateTimeOffset? timeAfter = null); + List GetByTag(string tag); + List GetByType(string type); + List GetAll(); + FragmentDto? GetById(Guid id); +} diff --git a/Journal.Core/Services/Lists/IListService.cs b/Journal.Core/Services/Lists/IListService.cs new file mode 100644 index 0000000..b727bb9 --- /dev/null +++ b/Journal.Core/Services/Lists/IListService.cs @@ -0,0 +1,12 @@ +using Journal.Core.Dtos; + +namespace Journal.Core.Services.Lists; + +public interface IListService +{ + List GetAll(); + ListDocumentDto? GetById(Guid id); + ListDocumentDto Create(CreateListDto dto); + bool Update(Guid id, UpdateListDto dto); + bool Remove(Guid id); +} diff --git a/Journal.Core/Services/Lists/ListService.cs b/Journal.Core/Services/Lists/ListService.cs new file mode 100644 index 0000000..8b425a7 --- /dev/null +++ b/Journal.Core/Services/Lists/ListService.cs @@ -0,0 +1,54 @@ +using System.ComponentModel.DataAnnotations; +using Journal.Core.Dtos; +using Journal.Core.Models; +using Journal.Core.Repositories; + +namespace Journal.Core.Services.Lists; + +public class ListService(IListRepository repo) : IListService +{ + private readonly IListRepository _repo = repo ?? throw new ArgumentNullException(nameof(repo)); + + private static ListDocumentDto Map(ListDocument d) => new( + d.Id, + d.Label, + d.Content, + d.CreatedAt, + d.UpdatedAt + ); + + public List GetAll() + { + var items = _repo.GetAll(); + return [.. items.Select(Map)]; + } + + public ListDocumentDto? GetById(Guid id) + { + var d = _repo.GetById(id); + return d is null ? null : Map(d); + } + + public ListDocumentDto Create(CreateListDto dto) + { + ArgumentNullException.ThrowIfNull(dto); + + var ctx = new ValidationContext(dto); + Validator.ValidateObject(dto, ctx, validateAllProperties: true); + + var doc = new ListDocument(dto.Label, dto.Content ?? ""); + _repo.Add(doc); + return Map(doc); + } + + public bool Update(Guid id, UpdateListDto dto) + { + ArgumentNullException.ThrowIfNull(dto); + if (dto.Label is not null && string.IsNullOrWhiteSpace(dto.Label)) + throw new ValidationException("Label cannot be empty"); + + return _repo.Update(id, dto.Label?.Trim(), dto.Content); + } + + public bool Remove(Guid id) => _repo.Remove(id); +} diff --git a/Journal.Core/Services/Logging/CommandLogger.cs b/Journal.Core/Services/Logging/CommandLogger.cs new file mode 100644 index 0000000..018dd5f --- /dev/null +++ b/Journal.Core/Services/Logging/CommandLogger.cs @@ -0,0 +1,73 @@ +using System.Globalization; +using System.Text.Json; + +namespace Journal.Core.Services.Logging; + +public sealed class CommandLogger +{ + public static void LogStart(string action, string correlationId, JsonElement? payload) + { + var redactedPayload = LogRedactor.RedactPayload(payload); + EmitLog("information", action, correlationId, "start", redactedPayload); + } + + public static void LogSuccess(string action, string correlationId) => EmitLog("information", action, correlationId, "success"); + + public static void LogFailure(string action, string correlationId, string errorType, string? message = null) + { + var details = string.IsNullOrWhiteSpace(message) + ? "" + : (message!.Length <= 160 ? message : $"{message[..160]}...(truncated)"); + EmitLog("warning", action, correlationId, "failure", errorType: errorType, details: details); + } + + private static void EmitLog( + string level, + string action, + string correlationId, + string outcome, + object? payload = null, + string? errorType = null, + string? details = null) + { + if (!ShouldLog(level)) + return; + + var envelope = new + { + timestamp = DateTime.UtcNow.ToString("O", CultureInfo.InvariantCulture), + level, + component = "Entry", + action, + correlation_id = correlationId, + outcome, + error_type = errorType, + details, + payload + }; + Console.Error.WriteLine(JsonSerializer.Serialize(envelope)); + } + + private static bool ShouldLog(string level) + { + var configured = (Environment.GetEnvironmentVariable("JOURNAL_LOG_LEVEL") ?? "warning") + .Trim() + .ToLowerInvariant(); + var configuredRank = LogLevelRank(configured); + var incomingRank = LogLevelRank(level); + return incomingRank >= configuredRank; + } + + private static int LogLevelRank(string level) => level switch + { + "trace" => 0, + "debug" => 1, + "information" => 2, + "info" => 2, + "warning" => 3, + "warn" => 3, + "error" => 4, + "critical" => 5, + _ => 3 + }; +} diff --git a/Journal.Core/Services/Logging/LogRedactor.cs b/Journal.Core/Services/Logging/LogRedactor.cs new file mode 100644 index 0000000..b116bb5 --- /dev/null +++ b/Journal.Core/Services/Logging/LogRedactor.cs @@ -0,0 +1,73 @@ +using System.Text.Json; + +namespace Journal.Core.Services.Logging; + +public static class LogRedactor +{ + private static readonly HashSet SensitiveKeys = new(StringComparer.OrdinalIgnoreCase) + { + "password", + "passphrase", + "secret", + "token", + "apiKey", + "api_key", + "cloudAiApiKey", + "content", + "rawContent", + "prompt", + "audioBase64", + "audio_base64", + "text" + }; + + public static object? RedactPayload(JsonElement? payload) + { + if (payload is null) + return null; + return RedactElement(payload.Value, parentKey: null); + } + + private static object? RedactElement(JsonElement element, string? parentKey) + { + if (parentKey is not null && SensitiveKeys.Contains(parentKey)) + return "[REDACTED]"; + + return element.ValueKind switch + { + JsonValueKind.Object => RedactObject(element), + JsonValueKind.Array => RedactArray(element), + JsonValueKind.String => RedactString(element.GetString() ?? "", parentKey), + JsonValueKind.Number => element.GetRawText(), + JsonValueKind.True => true, + JsonValueKind.False => false, + JsonValueKind.Null => null, + _ => element.GetRawText() + }; + } + + private static Dictionary RedactObject(JsonElement element) + { + var output = new Dictionary(StringComparer.OrdinalIgnoreCase); + foreach (var property in element.EnumerateObject()) + output[property.Name] = RedactElement(property.Value, property.Name); + return output; + } + + private static List RedactArray(JsonElement element) + { + var output = new List(); + foreach (var item in element.EnumerateArray()) + output.Add(RedactElement(item, parentKey: null)); + return output; + } + + private static object RedactString(string value, string? key) + { + if (key is not null && SensitiveKeys.Contains(key)) + return "[REDACTED]"; + if (value.Length <= 128) + return value; + return $"{value[..128]}...(truncated)"; + } +} diff --git a/Journal.Core/Services/Sidecar/PythonSidecarClient.cs b/Journal.Core/Services/Sidecar/PythonSidecarClient.cs new file mode 100644 index 0000000..01284bd --- /dev/null +++ b/Journal.Core/Services/Sidecar/PythonSidecarClient.cs @@ -0,0 +1,114 @@ +using System.Diagnostics; +using System.Text.Json; +using Journal.Core.Models; + +namespace Journal.Core.Services.Sidecar; + +public sealed class PythonSidecarClient(JournalConfig config) +{ + private static readonly JsonSerializerOptions JsonOptions = new() + { + PropertyNameCaseInsensitive = true + }; + + private readonly JournalConfig _config = config; + + public async Task SendAsync(string action, object payload, CancellationToken cancellationToken) + { + var request = JsonSerializer.Serialize(new { action, payload }, JsonOptions); + + using var process = new Process(); + process.StartInfo = new ProcessStartInfo + { + FileName = _config.PythonExecutable, + UseShellExecute = false, + RedirectStandardInput = true, + RedirectStandardOutput = true, + RedirectStandardError = true, + CreateNoWindow = true, + WorkingDirectory = _config.ProjectRoot + }; + process.StartInfo.ArgumentList.Add(_config.PythonAiSidecarPath); + + if (!process.Start()) + throw new InvalidOperationException("Failed to start Python sidecar process."); + + await process.StandardInput.WriteLineAsync(request); + process.StandardInput.Close(); + + using var timeoutCts = CancellationTokenSource.CreateLinkedTokenSource(cancellationToken); + timeoutCts.CancelAfter(_config.AiSidecarTimeoutMs); + + try + { + await process.WaitForExitAsync(timeoutCts.Token); + } + catch (OperationCanceledException) + { + TryKill(process); + throw new TimeoutException($"Python sidecar timed out after {_config.AiSidecarTimeoutMs} ms."); + } + + var stdout = await process.StandardOutput.ReadToEndAsync(); + var stderr = await process.StandardError.ReadToEndAsync(); + var line = LastJsonLine(stdout); + if (string.IsNullOrWhiteSpace(line)) + throw new InvalidOperationException($"Python sidecar returned no JSON response. stderr: {stderr}".Trim()); + + JsonDocument doc; + try + { + doc = JsonDocument.Parse(line); + } + catch (JsonException ex) + { + throw new InvalidOperationException($"Invalid JSON from Python sidecar: {line}", ex); + } + + using (doc) + { + var root = doc.RootElement; + if (!root.TryGetProperty("ok", out var okNode) || okNode.ValueKind != JsonValueKind.True && okNode.ValueKind != JsonValueKind.False) + throw new InvalidOperationException("Python sidecar response missing boolean 'ok' field."); + + if (!okNode.GetBoolean()) + { + var error = root.TryGetProperty("error", out var errorNode) + ? errorNode.GetString() ?? "Unknown sidecar error." + : "Unknown sidecar error."; + throw new InvalidOperationException(error); + } + + if (!root.TryGetProperty("data", out var dataNode)) + return null; + + return dataNode.Clone(); + } + } + + private static string LastJsonLine(string text) + { + var lines = text.Split(['\r', '\n'], StringSplitOptions.RemoveEmptyEntries); + for (var i = lines.Length - 1; i >= 0; i--) + { + var line = lines[i].Trim(); + if (line.StartsWith("{", StringComparison.Ordinal) && line.EndsWith("}", StringComparison.Ordinal)) + return line; + } + + return ""; + } + + private static void TryKill(Process process) + { + try + { + if (!process.HasExited) + process.Kill(entireProcessTree: true); + } + catch + { + // Ignore cleanup errors while handling timeout/failure path. + } + } +} diff --git a/Journal.Core/Services/Sidecar/SidecarCli.cs b/Journal.Core/Services/Sidecar/SidecarCli.cs new file mode 100644 index 0000000..f7d82fd --- /dev/null +++ b/Journal.Core/Services/Sidecar/SidecarCli.cs @@ -0,0 +1,385 @@ +using System.Text; +using Journal.Core.Dtos; +using Journal.Core.Services.Config; +using Journal.Core.Services.Entries; +using Journal.Core.Services.Vault; + +namespace Journal.Core.Services.Sidecar; + +public sealed class SidecarCli(IVaultStorageService vaultStorage, IEntrySearchService entrySearch, IJournalConfigService config) +{ + private readonly IVaultStorageService _vaultStorage = vaultStorage; + private readonly IEntrySearchService _entrySearch = entrySearch; + private readonly IJournalConfigService _config = config; + + public async Task RunAsync(string[] args, Entry entry) + { + ArgumentNullException.ThrowIfNull(args); + ArgumentNullException.ThrowIfNull(entry); + + if (args.Length == 0) + { + await entry.RunAsync(); + return 0; + } + + if (IsHelp(args[0])) + { + PrintUsage(); + return 0; + } + + if (string.Equals(args[0], "vault", StringComparison.OrdinalIgnoreCase)) + return RunVaultCommand([.. args.Skip(1)]); + if (string.Equals(args[0], "search", StringComparison.OrdinalIgnoreCase)) + return RunSearchCommand([.. args.Skip(1)]); + + Console.Error.WriteLine($"Unknown command: {args[0]}"); + PrintUsage(); + return 2; + } + + public int RunVaultCommand(string[] args) + { + ArgumentNullException.ThrowIfNull(args); + if (args.Length == 0 || IsHelp(args[0])) + { + PrintVaultUsage(); + return 2; + } + + var action = args[0].Trim().ToLowerInvariant(); + if (action is not ("load" or "save")) + { + Console.Error.WriteLine($"Unknown vault action: {args[0]}"); + PrintVaultUsage(); + return 2; + } + + if (!TryParseVaultOptions([.. args.Skip(1)], out var options, out var parseError)) + { + Console.Error.WriteLine(parseError); + PrintVaultUsage(); + return 2; + } + + var password = options.Password; + if (string.IsNullOrWhiteSpace(password)) + password = PromptPassword(); + + if (string.IsNullOrWhiteSpace(password)) + { + Console.Error.WriteLine("Vault password cannot be empty."); + return 2; + } + + var (vaultDirectory, dataDirectory) = ResolveDirectories(options.VaultDirectory, options.DataDirectory); + + try + { + if (action == "load") + { + var ok = _vaultStorage.LoadAllVaults(password, vaultDirectory, dataDirectory); + if (!ok) + { + Console.Error.WriteLine("Incorrect password."); + return 1; + } + + Console.WriteLine($"Vault loaded. Decrypted files are in {dataDirectory}"); + return 0; + } + + _vaultStorage.RebuildAllVaults(password, vaultDirectory, dataDirectory); + Console.WriteLine($"Vault saved from decrypted files in {dataDirectory}"); + return 0; + } + catch (Exception ex) + { + Console.Error.WriteLine($"Vault command failed: {ex.Message}"); + return 1; + } + } + + public int RunSearchCommand(string[] args) + { + ArgumentNullException.ThrowIfNull(args); + if (args.Length > 0 && IsHelp(args[0])) + { + PrintSearchUsage(); + return 0; + } + + if (!TryParseSearchOptions(args, out var options, out var parseError)) + { + Console.Error.WriteLine(parseError); + PrintSearchUsage(); + return 2; + } + + var (_, dataDirectory) = ResolveDirectories(vaultOverride: null, options.DataDirectory); + var entryCount = Directory.Exists(dataDirectory) + ? Directory.GetFiles(dataDirectory, "*.md") + .Count(path => !EntryFileNaming.IsTemplateFileName(Path.GetFileName(path))) + : 0; + if (entryCount == 0) + { + Console.WriteLine("No decrypted journal entries found. Please load the vault first: journal vault load"); + return 0; + } + + try + { + var request = new EntrySearchRequestDto( + DataDirectory: dataDirectory, + Query: options.Query, + Section: options.Section, + StartDate: options.StartDate, + EndDate: options.EndDate, + Tags: options.Tags, + Types: options.Types, + Checked: options.Checked, + Unchecked: options.Unchecked); + + var results = _entrySearch.SearchEntriesAsync(request).GetAwaiter().GetResult(); + if (results.Count == 0) + { + Console.WriteLine("No entries found matching the criteria."); + return 0; + } + + foreach (var result in results) + { + Console.WriteLine($"--- {result.Entry.Date} ---"); + Console.WriteLine(result.Entry.RawContent); + Console.WriteLine(); + } + + return 0; + } + catch (Exception ex) + { + Console.Error.WriteLine($"Search command failed: {ex.Message}"); + return 1; + } + } + + private static bool TryParseVaultOptions(string[] args, out VaultOptions options, out string error) + { + var parsed = new VaultOptions(); + for (var i = 0; i < args.Length; i++) + { + var token = args[i]; + if (IsHelp(token)) + { + options = parsed; + error = ""; + return false; + } + + if (i + 1 >= args.Length) + { + options = parsed; + error = $"Missing value for option '{token}'."; + return false; + } + + var value = args[i + 1]; + switch (token) + { + case "--password": + case "-p": + parsed.Password = value; + break; + case "--vault-dir": + parsed.VaultDirectory = value; + break; + case "--data-dir": + parsed.DataDirectory = value; + break; + default: + options = parsed; + error = $"Unknown option '{token}'."; + return false; + } + + i++; + } + + options = parsed; + error = ""; + return true; + } + + private static bool TryParseSearchOptions(string[] args, out SearchOptions options, out string error) + { + var parsed = new SearchOptions(); + for (var i = 0; i < args.Length; i++) + { + var token = args[i]; + if (IsHelp(token)) + { + options = parsed; + error = ""; + return false; + } + + if (!token.StartsWith("-", StringComparison.Ordinal)) + { + if (parsed.Query is null) + { + parsed.Query = token; + continue; + } + + options = parsed; + error = $"Unexpected positional argument '{token}'."; + return false; + } + + if (i + 1 >= args.Length) + { + options = parsed; + error = $"Missing value for option '{token}'."; + return false; + } + + var value = args[i + 1]; + switch (token) + { + case "--data-dir": + parsed.DataDirectory = value; + break; + case "--tag": + case "-t": + parsed.Tags.Add(value); + break; + case "--type": + case "-y": + parsed.Types.Add(value); + break; + case "--start-date": + case "-s": + parsed.StartDate = value; + break; + case "--end-date": + case "-e": + parsed.EndDate = value; + break; + case "--section": + case "-sec": + parsed.Section = value; + break; + case "--checked": + case "-chk": + parsed.Checked.Add(value); + break; + case "--unchecked": + case "-uchk": + parsed.Unchecked.Add(value); + break; + default: + options = parsed; + error = $"Unknown option '{token}'."; + return false; + } + + i++; + } + + options = parsed; + error = ""; + return true; + } + + private (string VaultDirectory, string DataDirectory) ResolveDirectories(string? vaultOverride, string? dataOverride) + { + var envVault = Environment.GetEnvironmentVariable("JOURNAL_VAULT_DIR"); + var envData = Environment.GetEnvironmentVariable("JOURNAL_DATA_DIR"); + var defaults = _config.Current; + + var vault = FirstNonEmpty(vaultOverride, envVault) ?? defaults.VaultDirectory; + var data = FirstNonEmpty(dataOverride, envData) ?? defaults.DataDirectory; + return (Path.GetFullPath(vault), Path.GetFullPath(data)); + } + + private static string? FirstNonEmpty(params string?[] values) => + values.FirstOrDefault(value => !string.IsNullOrWhiteSpace(value)); + + private static string PromptPassword() + { + if (Console.IsInputRedirected) + return Console.ReadLine() ?? ""; + + Console.Write("Vault password: "); + var builder = new StringBuilder(); + while (true) + { + var keyInfo = Console.ReadKey(intercept: true); + if (keyInfo.Key == ConsoleKey.Enter) + { + Console.WriteLine(); + break; + } + + if (keyInfo.Key == ConsoleKey.Backspace) + { + if (builder.Length > 0) + builder.Length--; + continue; + } + + if (!char.IsControl(keyInfo.KeyChar)) + builder.Append(keyInfo.KeyChar); + } + + return builder.ToString(); + } + + private static bool IsHelp(string token) => + string.Equals(token, "--help", StringComparison.OrdinalIgnoreCase) || + string.Equals(token, "-h", StringComparison.OrdinalIgnoreCase) || + string.Equals(token, "help", StringComparison.OrdinalIgnoreCase); + + private static void PrintUsage() + { + Console.WriteLine("Usage:"); + Console.WriteLine(" Journal.Sidecar # sidecar stdin/stdout mode"); + Console.WriteLine(" Journal.Sidecar vault load [--password ] [--vault-dir ] [--data-dir ]"); + Console.WriteLine(" Journal.Sidecar vault save [--password ] [--vault-dir ] [--data-dir ]"); + Console.WriteLine(" Journal.Sidecar search [query] [--tag ] [--type ] [--start-date ] [--end-date ] [--section ] [--checked <text>] [--unchecked <text>] [--data-dir <path>]"); + } + + private static void PrintVaultUsage() + { + Console.WriteLine("Vault usage:"); + Console.WriteLine(" Journal.Sidecar vault load [--password <value>] [--vault-dir <path>] [--data-dir <path>]"); + Console.WriteLine(" Journal.Sidecar vault save [--password <value>] [--vault-dir <path>] [--data-dir <path>]"); + } + + private static void PrintSearchUsage() + { + Console.WriteLine("Search usage:"); + Console.WriteLine(" Journal.Sidecar search [query] [--tag <value>] [--type <value>] [--start-date <yyyy-MM-dd>] [--end-date <yyyy-MM-dd>] [--section <title>] [--checked <text>] [--unchecked <text>] [--data-dir <path>]"); + } + + private sealed class VaultOptions + { + public string? Password { get; set; } + public string? VaultDirectory { get; set; } + public string? DataDirectory { get; set; } + } + + private sealed class SearchOptions + { + public string? Query { get; set; } + public string? DataDirectory { get; set; } + public string? StartDate { get; set; } + public string? EndDate { get; set; } + public string? Section { get; set; } + public List<string> Tags { get; } = []; + public List<string> Types { get; } = []; + public List<string> Checked { get; } = []; + public List<string> Unchecked { get; } = []; + } +} diff --git a/Journal.Core/Services/Speech/DisabledSpeechBridgeService.cs b/Journal.Core/Services/Speech/DisabledSpeechBridgeService.cs new file mode 100644 index 0000000..027ddc1 --- /dev/null +++ b/Journal.Core/Services/Speech/DisabledSpeechBridgeService.cs @@ -0,0 +1,26 @@ +using Journal.Core.Dtos; + +namespace Journal.Core.Services.Speech; + +public sealed class DisabledSpeechBridgeService(string provider = "none", string message = "Speech bridge is disabled.") : ISpeechBridgeService +{ + private readonly string _provider = string.IsNullOrWhiteSpace(provider) ? "none" : provider.Trim(); + private readonly string _message = string.IsNullOrWhiteSpace(message) ? "Speech bridge is disabled." : message.Trim(); + + public Task<SpeechDevicesResultDto> ListDevicesAsync(CancellationToken cancellationToken = default) + { + var warning = $"{_message} (provider={_provider})"; + return Task.FromResult(new SpeechDevicesResultDto([], warning)); + } + + public Task<SpeechTranscribeResultDto> TranscribeAsync( + SpeechTranscribeRequestDto request, + CancellationToken cancellationToken = default) + { + if (request is null) + throw new ArgumentNullException(nameof(request)); + var engine = string.IsNullOrWhiteSpace(request.Engine) ? "none" : request.Engine.Trim(); + var warning = $"{_message} (provider={_provider})"; + return Task.FromResult(new SpeechTranscribeResultDto("", engine, warning)); + } +} diff --git a/Journal.Core/Services/Speech/ISpeechBridgeService.cs b/Journal.Core/Services/Speech/ISpeechBridgeService.cs new file mode 100644 index 0000000..574ba78 --- /dev/null +++ b/Journal.Core/Services/Speech/ISpeechBridgeService.cs @@ -0,0 +1,9 @@ +using Journal.Core.Dtos; + +namespace Journal.Core.Services.Speech; + +public interface ISpeechBridgeService +{ + Task<SpeechDevicesResultDto> ListDevicesAsync(CancellationToken cancellationToken = default); + Task<SpeechTranscribeResultDto> TranscribeAsync(SpeechTranscribeRequestDto request, CancellationToken cancellationToken = default); +} diff --git a/Journal.Core/Services/Speech/PythonSidecarSpeechService.cs b/Journal.Core/Services/Speech/PythonSidecarSpeechService.cs new file mode 100644 index 0000000..7936f0d --- /dev/null +++ b/Journal.Core/Services/Speech/PythonSidecarSpeechService.cs @@ -0,0 +1,81 @@ +using System.Text.Json; +using Journal.Core.Dtos; +using Journal.Core.Models; +using Journal.Core.Services.Sidecar; + +namespace Journal.Core.Services.Speech; + +public sealed class PythonSidecarSpeechService : ISpeechBridgeService +{ + private readonly PythonSidecarClient _client; + + public PythonSidecarSpeechService(JournalConfig config) + { + if (string.IsNullOrWhiteSpace(config.PythonAiSidecarPath)) + throw new ArgumentException("Python sidecar path is required."); + if (!File.Exists(config.PythonAiSidecarPath)) + throw new FileNotFoundException($"Python sidecar not found: {config.PythonAiSidecarPath}"); + _client = new PythonSidecarClient(config); + } + + public async Task<SpeechDevicesResultDto> ListDevicesAsync(CancellationToken cancellationToken = default) + { + var data = await _client.SendAsync("speech.devices.list", new { }, cancellationToken); + if (data is null || data.Value.ValueKind != JsonValueKind.Object) + return new SpeechDevicesResultDto([], "Unexpected speech device response from Python sidecar."); + + var warning = data.Value.TryGetProperty("warning", out var warningNode) + ? warningNode.GetString() + : null; + + var devices = new List<SpeechDeviceDto>(); + if (data.Value.TryGetProperty("devices", out var devicesNode) && devicesNode.ValueKind == JsonValueKind.Array) + { + foreach (var device in devicesNode.EnumerateArray()) + { + if (device.ValueKind != JsonValueKind.Object) + continue; + + var index = device.TryGetProperty("index", out var indexNode) && indexNode.ValueKind == JsonValueKind.Number + ? indexNode.GetInt32() + : -1; + var name = device.TryGetProperty("name", out var nameNode) + ? nameNode.GetString() ?? "" + : ""; + devices.Add(new SpeechDeviceDto(index, name)); + } + } + + return new SpeechDevicesResultDto(devices, warning); + } + + public async Task<SpeechTranscribeResultDto> TranscribeAsync( + SpeechTranscribeRequestDto request, + CancellationToken cancellationToken = default) + { + ArgumentNullException.ThrowIfNull(request); + + var data = await _client.SendAsync("speech.transcribe", new + { + audio_base64 = request.AudioBase64, + engine = request.Engine, + whisper_model = request.WhisperModel, + text = request.Text, + simulate_delay_ms = request.SimulateDelayMs + }, cancellationToken); + + if (data is null || data.Value.ValueKind != JsonValueKind.Object) + throw new InvalidOperationException("Python sidecar speech response must be a JSON object."); + + var text = data.Value.TryGetProperty("text", out var textNode) + ? textNode.GetString() ?? "" + : ""; + var engine = data.Value.TryGetProperty("engine", out var engineNode) + ? engineNode.GetString() ?? (request.Engine ?? "whisper") + : (request.Engine ?? "whisper"); + var warning = data.Value.TryGetProperty("warning", out var warningNode) + ? warningNode.GetString() + : null; + return new SpeechTranscribeResultDto(text, engine, warning); + } +} diff --git a/Journal.Core/Services/Todos/ITodoService.cs b/Journal.Core/Services/Todos/ITodoService.cs new file mode 100644 index 0000000..9b14e8b --- /dev/null +++ b/Journal.Core/Services/Todos/ITodoService.cs @@ -0,0 +1,16 @@ +using Journal.Core.Dtos; + +namespace Journal.Core.Services.Todos; + +public interface ITodoService +{ + List<TodoListDto> GetAllLists(); + TodoListDto? GetListById(Guid id); + TodoListDto CreateList(CreateTodoListDto dto); + bool UpdateList(Guid id, UpdateTodoListDto dto); + bool RemoveList(Guid id); + + TodoItemDto CreateItem(CreateTodoItemDto dto); + bool UpdateItem(Guid id, UpdateTodoItemDto dto); + bool RemoveItem(Guid id); +} diff --git a/Journal.Core/Services/Todos/TodoService.cs b/Journal.Core/Services/Todos/TodoService.cs new file mode 100644 index 0000000..9d1f587 --- /dev/null +++ b/Journal.Core/Services/Todos/TodoService.cs @@ -0,0 +1,91 @@ +using System.ComponentModel.DataAnnotations; +using Journal.Core.Dtos; +using Journal.Core.Models; +using Journal.Core.Repositories; + +namespace Journal.Core.Services.Todos; + +public class TodoService(ITodoRepository repo) : ITodoService +{ + private readonly ITodoRepository _repo = repo ?? throw new ArgumentNullException(nameof(repo)); + + private static TodoItemDto MapItem(TodoItem i) => new( + i.Id, + i.ListId, + i.Text, + i.Done, + i.SortOrder + ); + + private TodoListDto MapList(TodoList l) + { + var items = _repo.GetItemsByListId(l.Id); + return new TodoListDto( + l.Id, + l.Label, + l.CreatedAt, + [.. items.Select(MapItem)] + ); + } + + public List<TodoListDto> GetAllLists() + { + var lists = _repo.GetAllLists(); + return [.. lists.Select(MapList)]; + } + + public TodoListDto? GetListById(Guid id) + { + var l = _repo.GetListById(id); + return l is null ? null : MapList(l); + } + + public TodoListDto CreateList(CreateTodoListDto dto) + { + ArgumentNullException.ThrowIfNull(dto); + + var ctx = new ValidationContext(dto); + Validator.ValidateObject(dto, ctx, validateAllProperties: true); + + var list = new TodoList(dto.Label); + _repo.AddList(list); + return new TodoListDto(list.Id, list.Label, list.CreatedAt, []); + } + + public bool UpdateList(Guid id, UpdateTodoListDto dto) + { + ArgumentNullException.ThrowIfNull(dto); + if (dto.Label is not null && string.IsNullOrWhiteSpace(dto.Label)) + throw new ValidationException("Label cannot be empty"); + + return _repo.UpdateList(id, dto.Label?.Trim()); + } + + public bool RemoveList(Guid id) => _repo.RemoveList(id); + + public TodoItemDto CreateItem(CreateTodoItemDto dto) + { + ArgumentNullException.ThrowIfNull(dto); + + var ctx = new ValidationContext(dto); + Validator.ValidateObject(dto, ctx, validateAllProperties: true); + + if (dto.ListId == Guid.Empty) + throw new ValidationException("ListId is required"); + + var item = new TodoItem(dto.ListId, dto.Text, dto.SortOrder ?? 0); + _repo.AddItem(item); + return MapItem(item); + } + + public bool UpdateItem(Guid id, UpdateTodoItemDto dto) + { + ArgumentNullException.ThrowIfNull(dto); + if (dto.Text is not null && string.IsNullOrWhiteSpace(dto.Text)) + throw new ValidationException("Text cannot be empty"); + + return _repo.UpdateItem(id, dto.Text?.Trim(), dto.Done, dto.SortOrder); + } + + public bool RemoveItem(Guid id) => _repo.RemoveItem(id); +} diff --git a/Journal.Core/Services/Vault/IVaultCryptoService.cs b/Journal.Core/Services/Vault/IVaultCryptoService.cs new file mode 100644 index 0000000..af9e388 --- /dev/null +++ b/Journal.Core/Services/Vault/IVaultCryptoService.cs @@ -0,0 +1,8 @@ +namespace Journal.Core.Services.Vault; + +public interface IVaultCryptoService +{ + byte[] DeriveKey(string password, byte[] salt); + byte[] EncryptData(byte[] data, string password); + byte[] DecryptData(byte[] encryptedData, string password); +} diff --git a/Journal.Core/Services/Vault/IVaultStorageService.cs b/Journal.Core/Services/Vault/IVaultStorageService.cs new file mode 100644 index 0000000..3a76b20 --- /dev/null +++ b/Journal.Core/Services/Vault/IVaultStorageService.cs @@ -0,0 +1,10 @@ +namespace Journal.Core.Services.Vault; + +public interface IVaultStorageService +{ + string GetMonthlyVaultFileName(DateTime date); + bool LoadAllVaults(string password, string vaultDirectory, string dataDirectory); + bool SaveCurrentMonthVault(string password, string vaultDirectory, string dataDirectory, DateTime now); + void RebuildAllVaults(string password, string vaultDirectory, string dataDirectory); + void ClearDataDirectory(string dataDirectory); +} diff --git a/Journal.Core/Services/Vault/VaultCryptoService.cs b/Journal.Core/Services/Vault/VaultCryptoService.cs new file mode 100644 index 0000000..8ef4e96 --- /dev/null +++ b/Journal.Core/Services/Vault/VaultCryptoService.cs @@ -0,0 +1,83 @@ +using System.Security.Cryptography; +using System.Text; + +namespace Journal.Core.Services.Vault; + +public class VaultCryptoService : IVaultCryptoService +{ + public const int SaltSize = 16; + public const int KeySize = 32; + public const int NonceSize = 12; + public const int TagSize = 16; + public const int Iterations = 600_000; + + public byte[] DeriveKey(string password, byte[] salt) + { + if (string.IsNullOrWhiteSpace(password)) + throw new ArgumentException("Password cannot be empty.", nameof(password)); + ArgumentNullException.ThrowIfNull(salt); + if (salt.Length != SaltSize) + throw new ArgumentException($"Salt must be {SaltSize} bytes.", nameof(salt)); + + return Rfc2898DeriveBytes.Pbkdf2( + Encoding.UTF8.GetBytes(password), + salt, + Iterations, + HashAlgorithmName.SHA256, + KeySize); + } + + public byte[] EncryptData(byte[] data, string password) + { + ArgumentNullException.ThrowIfNull(data); + + var salt = RandomNumberGenerator.GetBytes(SaltSize); + var nonce = RandomNumberGenerator.GetBytes(NonceSize); + return EncryptData(data, password, salt, nonce); + } + + public byte[] DecryptData(byte[] encryptedData, string password) + { + ArgumentNullException.ThrowIfNull(encryptedData); + + var minLength = SaltSize + NonceSize + TagSize; + if (encryptedData.Length < minLength) + throw new ArgumentException("Encrypted payload is too short.", nameof(encryptedData)); + + var salt = encryptedData.AsSpan(0, SaltSize).ToArray(); + var nonce = encryptedData.AsSpan(SaltSize, NonceSize).ToArray(); + var tag = encryptedData.AsSpan(SaltSize + NonceSize, TagSize).ToArray(); + var ciphertext = encryptedData.AsSpan(SaltSize + NonceSize + TagSize).ToArray(); + + var key = DeriveKey(password, salt); + var plaintext = new byte[ciphertext.Length]; + using var aes = new AesGcm(key, TagSize); + aes.Decrypt(nonce, ciphertext, tag, plaintext); + return plaintext; + } + + public byte[] EncryptData(byte[] data, string password, byte[] salt, byte[] nonce) + { + ArgumentNullException.ThrowIfNull(data); + ArgumentNullException.ThrowIfNull(salt); + ArgumentNullException.ThrowIfNull(nonce); + if (salt.Length != SaltSize) + throw new ArgumentException($"Salt must be {SaltSize} bytes.", nameof(salt)); + if (nonce.Length != NonceSize) + throw new ArgumentException($"Nonce must be {NonceSize} bytes.", nameof(nonce)); + + var key = DeriveKey(password, salt); + var ciphertext = new byte[data.Length]; + var tag = new byte[TagSize]; + + using var aes = new AesGcm(key, TagSize); + aes.Encrypt(nonce, data, ciphertext, tag); + + var payload = new byte[SaltSize + NonceSize + TagSize + ciphertext.Length]; + Buffer.BlockCopy(salt, 0, payload, 0, SaltSize); + Buffer.BlockCopy(nonce, 0, payload, SaltSize, NonceSize); + Buffer.BlockCopy(tag, 0, payload, SaltSize + NonceSize, TagSize); + Buffer.BlockCopy(ciphertext, 0, payload, SaltSize + NonceSize + TagSize, ciphertext.Length); + return payload; + } +} diff --git a/Journal.Core/Services/Vault/VaultStorageService.cs b/Journal.Core/Services/Vault/VaultStorageService.cs new file mode 100644 index 0000000..649663c --- /dev/null +++ b/Journal.Core/Services/Vault/VaultStorageService.cs @@ -0,0 +1,386 @@ +using System.Diagnostics; +using System.IO.Compression; +using System.Globalization; +using System.Security.Cryptography; +using System.Text; + +namespace Journal.Core.Services.Vault; + +public class VaultStorageService(IVaultCryptoService crypto) : IVaultStorageService +{ + private readonly IVaultCryptoService _crypto = crypto; + private readonly Dictionary<string, string> _monthFingerprintCache = new(StringComparer.Ordinal); + private readonly object _vaultIoLock = new(); + + public string GetMonthlyVaultFileName(DateTime date) => date.ToString("yyyy-MM") + ".vault"; + + public bool LoadAllVaults(string password, string vaultDirectory, string dataDirectory) + { + EnsureRequiredArguments(password, vaultDirectory, dataDirectory); + + lock (_vaultIoLock) + { + _monthFingerprintCache.Clear(); + PrepareDataDirectory(dataDirectory); + + if (!Directory.Exists(vaultDirectory)) + return true; + + var vaultFiles = Directory.GetFiles(vaultDirectory, "*.vault") + .OrderBy(Path.GetFileName, StringComparer.Ordinal) + .ToArray(); + if (vaultFiles.Length == 0) + return true; + + // Restore database vault files first + RestoreDatabaseVaults(password, vaultDirectory, dataDirectory); + + var anyDecrypted = false; + var anyVaultFiles = false; + foreach (var vaultFile in vaultFiles) + { + var fileName = Path.GetFileName(vaultFile); + if (string.Equals(fileName, "_init_vault.vault", StringComparison.OrdinalIgnoreCase)) + { + try + { + File.Delete(vaultFile); + } + catch (Exception ex) + { + Debug.WriteLine($"[VaultStorageService] Failed to delete legacy vault file {fileName}: {ex.Message}"); + } + continue; + } + + if (IsReservedVaultFile(fileName)) + continue; + + anyVaultFiles = true; + try + { + var encrypted = File.ReadAllBytes(vaultFile); + var decryptedZip = _crypto.DecryptData(encrypted, password); + ExtractZipContent(decryptedZip, dataDirectory); + anyDecrypted = true; + } + catch (CryptographicException) + { + Debug.WriteLine($"[VaultStorageService] Decryption failed for {fileName} (likely wrong password)"); + } + catch (Exception ex) + { + Debug.WriteLine($"[VaultStorageService] Failed to load vault {fileName}: {ex.GetType().Name} - {ex.Message}"); + } + } + + if (!anyDecrypted && anyVaultFiles) + return false; + + return true; + } + } + + public bool SaveCurrentMonthVault(string password, string vaultDirectory, string dataDirectory, DateTime now) + { + EnsureRequiredArguments(password, vaultDirectory, dataDirectory); + + lock (_vaultIoLock) + { + Directory.CreateDirectory(vaultDirectory); + if (!Directory.Exists(dataDirectory)) + return false; + + var monthKey = now.ToString("yyyy-MM", CultureInfo.InvariantCulture); + var filesInMonth = Directory.GetFiles(dataDirectory, "*.md") + .Where(path => Path.GetFileNameWithoutExtension(path).StartsWith(monthKey, StringComparison.Ordinal)) + .OrderBy(Path.GetFileName, StringComparer.Ordinal) + .ToList(); + + var savedMonth = false; + if (filesInMonth.Count > 0) + { + var currentFingerprint = ComputeMonthFingerprint(filesInMonth); + if (!_monthFingerprintCache.TryGetValue(monthKey, out var cachedFingerprint) || + !string.Equals(cachedFingerprint, currentFingerprint, StringComparison.Ordinal)) + { + SaveMonth(password, monthKey, filesInMonth, vaultDirectory); + savedMonth = true; + } + } + + // Also persist custom-named entries alongside the current month vault + SaveCustomEntries(password, vaultDirectory, dataDirectory); + + return savedMonth; + } + } + + public void RebuildAllVaults(string password, string vaultDirectory, string dataDirectory) + { + EnsureRequiredArguments(password, vaultDirectory, dataDirectory); + + lock (_vaultIoLock) + { + Directory.CreateDirectory(vaultDirectory); + if (!Directory.Exists(dataDirectory)) + return; + + var monthlyFiles = new Dictionary<string, List<string>>(StringComparer.Ordinal); + foreach (var filePath in Directory.GetFiles(dataDirectory, "*.md")) + { + var stem = Path.GetFileNameWithoutExtension(filePath); + if (!DateTime.TryParseExact(stem, "yyyy-MM-dd", CultureInfo.InvariantCulture, DateTimeStyles.None, out var fileDate)) + continue; + + var monthKey = fileDate.ToString("yyyy-MM", CultureInfo.InvariantCulture); + if (!monthlyFiles.TryGetValue(monthKey, out var files)) + { + files = []; + monthlyFiles[monthKey] = files; + } + + files.Add(filePath); + } + + foreach (var (monthKey, filesInMonth) in monthlyFiles.OrderBy(static pair => pair.Key, StringComparer.Ordinal)) + SaveMonth(password, monthKey, filesInMonth, vaultDirectory); + + SaveCustomEntries(password, vaultDirectory, dataDirectory); + SaveDatabaseVaults(password, vaultDirectory, dataDirectory); + } + } + + public void ClearDataDirectory(string dataDirectory) + { + if (string.IsNullOrWhiteSpace(dataDirectory)) + throw new ArgumentException("Data directory is required.", nameof(dataDirectory)); + + lock (_vaultIoLock) + { + PrepareDataDirectory(dataDirectory); + _monthFingerprintCache.Clear(); + } + } + + private static void PrepareDataDirectory(string dataDirectory) + { + DeleteDirectoryWithRetries(dataDirectory); + Directory.CreateDirectory(dataDirectory); + } + + private static void DeleteDirectoryWithRetries(string dataDirectory, int retries = 5, int delayMs = 200) + { + if (!Directory.Exists(dataDirectory)) + return; + + for (var attempt = 0; attempt < retries; attempt++) + { + try + { + Directory.Delete(dataDirectory, recursive: true); + return; + } + catch (IOException) when (attempt < retries - 1) + { + Thread.Sleep(delayMs); + } + catch (UnauthorizedAccessException) when (attempt < retries - 1) + { + Thread.Sleep(delayMs); + } + } + + Directory.Delete(dataDirectory, recursive: true); + } + + // ── Custom entries vault helpers ────────────────────────────── + + private const string CustomEntriesVaultFileName = "_custom_entries.vault"; + + private List<string> GetCustomEntryFiles(string dataDirectory) + { + return Directory.GetFiles(dataDirectory, "*.md") + .Where(path => + { + var stem = Path.GetFileNameWithoutExtension(path); + return !DateTime.TryParseExact(stem, "yyyy-MM-dd", CultureInfo.InvariantCulture, DateTimeStyles.None, out _); + }) + .OrderBy(Path.GetFileName, StringComparer.Ordinal) + .ToList(); + } + + private void SaveCustomEntries(string password, string vaultDirectory, string dataDirectory) + { + var customFiles = GetCustomEntryFiles(dataDirectory); + var vaultPath = Path.Combine(vaultDirectory, CustomEntriesVaultFileName); + + if (customFiles.Count == 0) + { + // Remove stale custom vault if no custom entries remain + if (File.Exists(vaultPath)) + File.Delete(vaultPath); + return; + } + + var zipBytes = CreateMonthlyArchive(customFiles); + var encrypted = _crypto.EncryptData(zipBytes, password); + File.WriteAllBytes(vaultPath, encrypted); + } + + private static bool IsCustomEntriesVaultFile(string fileName) + => string.Equals(fileName, CustomEntriesVaultFileName, StringComparison.OrdinalIgnoreCase); + + // ── Database vault helpers ───────────────────────────────────── + + private const string DatabaseVaultPrefix = "_db_"; + private const string DatabaseVaultSuffix = ".vault"; + + private static bool IsReservedVaultFile(string fileName) + => fileName.StartsWith(DatabaseVaultPrefix, StringComparison.OrdinalIgnoreCase); + + private void SaveDatabaseVaults(string password, string vaultDirectory, string dataDirectory) + { + var dbFiles = Directory.GetFiles(dataDirectory, "*.db"); + foreach (var dbPath in dbFiles) + { + try + { + var dbFileName = Path.GetFileName(dbPath); + var vaultFileName = $"{DatabaseVaultPrefix}{dbFileName}{DatabaseVaultSuffix}"; + var vaultPath = Path.Combine(vaultDirectory, vaultFileName); + + var dbBytes = File.ReadAllBytes(dbPath); + var encrypted = _crypto.EncryptData(dbBytes, password); + File.WriteAllBytes(vaultPath, encrypted); + + Debug.WriteLine($"[VaultStorageService] Saved database vault: {vaultFileName}"); + } + catch (Exception ex) + { + Debug.WriteLine($"[VaultStorageService] Failed to save database vault for {Path.GetFileName(dbPath)}: {ex.Message}"); + } + } + } + + private void RestoreDatabaseVaults(string password, string vaultDirectory, string dataDirectory) + { + var dbVaultFiles = Directory.GetFiles(vaultDirectory, $"{DatabaseVaultPrefix}*{DatabaseVaultSuffix}"); + foreach (var vaultFile in dbVaultFiles) + { + try + { + var vaultFileName = Path.GetFileName(vaultFile); + // Strip prefix and suffix to get original DB filename + var dbFileName = vaultFileName[DatabaseVaultPrefix.Length..^DatabaseVaultSuffix.Length]; + if (string.IsNullOrWhiteSpace(dbFileName)) + continue; + + var encrypted = File.ReadAllBytes(vaultFile); + var dbBytes = _crypto.DecryptData(encrypted, password); + var targetPath = Path.Combine(dataDirectory, dbFileName); + File.WriteAllBytes(targetPath, dbBytes); + + Debug.WriteLine($"[VaultStorageService] Restored database from vault: {vaultFileName} → {dbFileName}"); + } + catch (CryptographicException) + { + Debug.WriteLine($"[VaultStorageService] Database vault decryption failed for {Path.GetFileName(vaultFile)} (likely wrong password)"); + } + catch (Exception ex) + { + Debug.WriteLine($"[VaultStorageService] Failed to restore database vault {Path.GetFileName(vaultFile)}: {ex.Message}"); + } + } + } + + private static void EnsureRequiredArguments(string password, string vaultDirectory, string dataDirectory) + { + if (string.IsNullOrWhiteSpace(password)) + throw new ArgumentException("Password cannot be empty.", nameof(password)); + if (string.IsNullOrWhiteSpace(vaultDirectory)) + throw new ArgumentException("Vault directory is required.", nameof(vaultDirectory)); + if (string.IsNullOrWhiteSpace(dataDirectory)) + throw new ArgumentException("Data directory is required.", nameof(dataDirectory)); + } + + private void SaveMonth(string password, string monthKey, List<string> filesInMonth, string vaultDirectory) + { + var monthDate = DateTime.ParseExact(monthKey, "yyyy-MM", CultureInfo.InvariantCulture); + var monthlyVaultPath = Path.Combine(vaultDirectory, GetMonthlyVaultFileName(monthDate)); + + var zipBytes = CreateMonthlyArchive(filesInMonth); + var encryptedPayload = _crypto.EncryptData(zipBytes, password); + File.WriteAllBytes(monthlyVaultPath, encryptedPayload); + + _monthFingerprintCache[monthKey] = ComputeMonthFingerprint(filesInMonth); + } + + private static byte[] CreateMonthlyArchive(List<string> filesInMonth) + { + using var memoryStream = new MemoryStream(); + using (var archive = new ZipArchive(memoryStream, ZipArchiveMode.Create, leaveOpen: true)) + { + foreach (var filePath in filesInMonth.OrderBy(Path.GetFileName, StringComparer.Ordinal)) + { + var fileName = Path.GetFileName(filePath); + if (string.IsNullOrWhiteSpace(fileName)) + continue; + + var entry = archive.CreateEntry(fileName, CompressionLevel.Optimal); + using var entryStream = entry.Open(); + using var sourceStream = File.OpenRead(filePath); + sourceStream.CopyTo(entryStream); + } + } + + return memoryStream.ToArray(); + } + + private static string ComputeMonthFingerprint(List<string> files) + { + using var hash = IncrementalHash.CreateHash(HashAlgorithmName.SHA256); + + foreach (var filePath in files.OrderBy(Path.GetFileName, StringComparer.Ordinal)) + { + var fileInfo = new FileInfo(filePath); + if (!fileInfo.Exists) + continue; + + AppendUtf8(hash, fileInfo.Name); + AppendAscii(hash, fileInfo.LastWriteTimeUtc.Ticks.ToString(CultureInfo.InvariantCulture)); + AppendAscii(hash, fileInfo.Length.ToString(CultureInfo.InvariantCulture)); + } + + return Convert.ToHexString(hash.GetHashAndReset()).ToLowerInvariant(); + } + + private static void AppendUtf8(IncrementalHash hash, string value) => hash.AppendData(Encoding.UTF8.GetBytes(value)); + private static void AppendAscii(IncrementalHash hash, string value) => hash.AppendData(Encoding.ASCII.GetBytes(value)); + + private static void ExtractZipContent(byte[] zipBytes, string dataDirectory) + { + using var stream = new MemoryStream(zipBytes); + using var archive = new ZipArchive(stream, ZipArchiveMode.Read); + + var dataRoot = Path.GetFullPath(dataDirectory); + if (!dataRoot.EndsWith(Path.DirectorySeparatorChar)) + dataRoot += Path.DirectorySeparatorChar; + + foreach (var entry in archive.Entries) + { + if (string.IsNullOrEmpty(entry.Name)) + continue; + + var destinationPath = Path.GetFullPath(Path.Combine(dataDirectory, entry.FullName)); + if (!destinationPath.StartsWith(dataRoot, StringComparison.OrdinalIgnoreCase)) + throw new InvalidDataException("Zip entry path escapes target data directory."); + + var destinationDir = Path.GetDirectoryName(destinationPath); + if (!string.IsNullOrWhiteSpace(destinationDir)) + Directory.CreateDirectory(destinationDir); + + entry.ExtractToFile(destinationPath, overwrite: true); + } + } +} diff --git a/Journal.DevTool/Config/ConfigLoader.cs b/Journal.DevTool/Config/ConfigLoader.cs new file mode 100644 index 0000000..471003d --- /dev/null +++ b/Journal.DevTool/Config/ConfigLoader.cs @@ -0,0 +1,44 @@ +using System.Text.Json; + +namespace Sdt.Config; + +public static class ConfigLoader +{ + private static readonly JsonSerializerOptions JsonOptions = new() + { + PropertyNameCaseInsensitive = true, + PropertyNamingPolicy = JsonNamingPolicy.CamelCase, + AllowTrailingCommas = true, + ReadCommentHandling = JsonCommentHandling.Skip, + }; + + /// <summary> + /// Walks up from <paramref name="startDir"/> (or CWD) until it finds devtool.json. + /// Returns null if not found. + /// </summary> + public static (DevToolConfig Config, string ProjectRoot)? FindAndLoad(string? startDir = null) + { + var dir = new DirectoryInfo(startDir ?? Directory.GetCurrentDirectory()); + while (dir is not null) + { + var candidate = Path.Combine(dir.FullName, "devtool.json"); + if (File.Exists(candidate)) + { + try + { + var json = File.ReadAllText(candidate); + var config = JsonSerializer.Deserialize<DevToolConfig>(json, JsonOptions) + ?? throw new InvalidOperationException("devtool.json deserialized to null."); + return (config, dir.FullName); + } + catch (Exception ex) + { + throw new InvalidOperationException( + $"Failed to parse devtool.json at {candidate}: {ex.Message}", ex); + } + } + dir = dir.Parent!; + } + return null; + } +} diff --git a/Journal.DevTool/Config/DevToolConfig.cs b/Journal.DevTool/Config/DevToolConfig.cs new file mode 100644 index 0000000..fbb91a5 --- /dev/null +++ b/Journal.DevTool/Config/DevToolConfig.cs @@ -0,0 +1,86 @@ +namespace Sdt.Config; + +public sealed class DevToolConfig +{ + public string Name { get; init; } = "SDT Project"; + public string Version { get; init; } = "0.1.0"; + public List<BuildTarget> Targets { get; init; } = []; + public List<EnvVarDef> Env { get; init; } = []; + public ToolchainConfig? Toolchains { get; init; } +} + +public sealed class BuildTarget +{ + public string Id { get; init; } = ""; + public string Label { get; init; } = ""; + public string Description { get; init; } = ""; + public string Group { get; init; } = "General"; + + /// <summary>Executable name. Null = virtual aggregator (runs DependsOn only).</summary> + public string? Command { get; init; } + + public List<string> Args { get; init; } = []; + + /// <summary>Working directory relative to project root.</summary> + public string WorkingDir { get; init; } = "."; + + public List<string> DependsOn { get; init; } = []; +} + +public sealed class EnvVarDef +{ + public string Key { get; init; } = ""; + public string Description { get; init; } = ""; + + [System.Text.Json.Serialization.JsonPropertyName("default")] + public string DefaultValue { get; init; } = ""; + + /// <summary>If non-empty, shown as a dropdown. Otherwise free-text input.</summary> + public List<string> Options { get; init; } = []; +} + +// ── Toolchain config ────────────────────────────────────────────────────────── + +public sealed class ToolchainConfig +{ + public PythonToolchain? Python { get; init; } + public NodeToolchain? Node { get; init; } +} + +public sealed class PythonToolchain +{ + /// <summary>Python executable (e.g. "python3.14", "python").</summary> + public string Executable { get; init; } = "python"; + + /// <summary>Windows-specific override (e.g. "py" when using the launcher).</summary> + public string? WindowsExecutable { get; init; } + + /// <summary>Optional version flag to pass (e.g. "-3.14" for py launcher).</summary> + public string? LauncherVersion { get; init; } + + /// <summary>Venv directory relative to project root.</summary> + public string VenvDir { get; init; } = ".venv"; + + public List<PythonProfile> Profiles { get; init; } = []; + + /// <summary>Optional path to a pip wrapper script (relative to project root).</summary> + public string? PipScript { get; init; } +} + +public sealed class PythonProfile +{ + public string Id { get; init; } = ""; + public string Label { get; init; } = ""; + public string RequirementsFile { get; init; } = ""; + public string? ExtraIndexUrl { get; init; } + public List<string> PostInstallCommands { get; init; } = []; +} + +public sealed class NodeToolchain +{ + /// <summary>Package manager: "npm", "pnpm", or "yarn".</summary> + public string PackageManager { get; init; } = "npm"; + + /// <summary>Working directory for the frontend (relative to project root).</summary> + public string WorkingDir { get; init; } = "."; +} diff --git a/Journal.DevTool/Config/WorkspaceConfig.cs b/Journal.DevTool/Config/WorkspaceConfig.cs new file mode 100644 index 0000000..fce9cb7 --- /dev/null +++ b/Journal.DevTool/Config/WorkspaceConfig.cs @@ -0,0 +1,19 @@ +namespace Sdt.Config; + +public sealed class WorkspaceConfig +{ + public string Name { get; init; } = "SDT Workspace"; + public List<WorkspaceProject> Projects { get; init; } = []; +} + +public sealed class WorkspaceProject +{ + public string Name { get; init; } = ""; + public string Description { get; init; } = ""; + + /// <summary> + /// Relative path from the sdt-workspace.json directory to the project root + /// (the directory containing devtool.json). + /// </summary> + public string Path { get; init; } = ""; +} diff --git a/Journal.DevTool/Config/WorkspaceLoader.cs b/Journal.DevTool/Config/WorkspaceLoader.cs new file mode 100644 index 0000000..a01f324 --- /dev/null +++ b/Journal.DevTool/Config/WorkspaceLoader.cs @@ -0,0 +1,52 @@ +using System.Text.Json; + +namespace Sdt.Config; + +public static class WorkspaceLoader +{ + private const string FileName = "sdt-workspace.json"; + + private static readonly JsonSerializerOptions JsonOptions = new() + { + PropertyNameCaseInsensitive = true, + PropertyNamingPolicy = JsonNamingPolicy.CamelCase, + AllowTrailingCommas = true, + ReadCommentHandling = JsonCommentHandling.Skip, + }; + + /// <summary> + /// Walks up from <paramref name="startDir"/> (or CWD) to find sdt-workspace.json. + /// Returns null if not found. + /// </summary> + public static (WorkspaceConfig Config, string WorkspaceRoot)? FindAndLoad(string? startDir = null) + { + var dir = new DirectoryInfo(startDir ?? Directory.GetCurrentDirectory()); + while (dir is not null) + { + var candidate = Path.Combine(dir.FullName, FileName); + if (File.Exists(candidate)) + { + try + { + var json = File.ReadAllText(candidate); + var config = JsonSerializer.Deserialize<WorkspaceConfig>(json, JsonOptions) + ?? throw new InvalidOperationException($"{FileName} deserialized to null."); + return (config, dir.FullName); + } + catch (Exception ex) + { + throw new InvalidOperationException( + $"Failed to parse {FileName} at {candidate}: {ex.Message}", ex); + } + } + dir = dir.Parent!; + } + return null; + } + + /// <summary> + /// Resolves the absolute project root for a workspace project entry. + /// </summary> + public static string ResolveProjectRoot(string workspaceRoot, WorkspaceProject project) + => Path.GetFullPath(Path.Combine(workspaceRoot, project.Path)); +} diff --git a/Journal.DevTool/Journal.DevTool.csproj b/Journal.DevTool/Journal.DevTool.csproj new file mode 100644 index 0000000..5d8f248 --- /dev/null +++ b/Journal.DevTool/Journal.DevTool.csproj @@ -0,0 +1,17 @@ +<Project Sdk="Microsoft.NET.Sdk"> + + <PropertyGroup> + <OutputType>Exe</OutputType> + <TargetFramework>net10.0</TargetFramework> + <Nullable>enable</Nullable> + <ImplicitUsings>enable</ImplicitUsings> + <AssemblyName>sdt</AssemblyName> + <RootNamespace>Sdt</RootNamespace> + <AllowUnsafeBlocks>false</AllowUnsafeBlocks> + </PropertyGroup> + + <ItemGroup> + <PackageReference Include="Spectre.Console" Version="0.49.1" /> + </ItemGroup> + +</Project> diff --git a/Journal.DevTool/Program.cs b/Journal.DevTool/Program.cs new file mode 100644 index 0000000..756f812 --- /dev/null +++ b/Journal.DevTool/Program.cs @@ -0,0 +1,57 @@ +using Sdt.Config; +using Sdt.Tui; +using Spectre.Console; + +// ── Workspace + project discovery ──────────────────────────────────────────── + +var workspaceResult = WorkspaceLoader.FindAndLoad(); +var projectResult = ConfigLoader.FindAndLoad(); + +if (projectResult is null) +{ + AnsiConsole.MarkupLine($"[bold {Theme.Red}]SDT:[/] [{Theme.Amber}]No devtool.json found[/] in current directory or any parent."); + AnsiConsole.MarkupLine(Theme.Faint("Create a devtool.json in your project root to get started.")); + return 1; +} + +// ── Main run loop (handles workspace project switching) ─────────────────────── + +var (currentConfig, currentRoot) = projectResult.Value; +var (workspace, workspaceRoot) = workspaceResult.HasValue + ? (workspaceResult.Value.Config, workspaceResult.Value.WorkspaceRoot) + : ((WorkspaceConfig?)null, (string?)null); + +try +{ + while (true) + { + var app = new App(currentConfig, currentRoot, workspace, workspaceRoot); + var result = await app.RunAsync(); + + if (result.Reason == AppExitReason.Quit) + break; + + // User switched projects — reload config from new root + if (result.Reason == AppExitReason.SwitchProject && result.NewProjectRoot is not null) + { + var loaded = ConfigLoader.FindAndLoad(result.NewProjectRoot); + if (loaded is null) + { + AnsiConsole.MarkupLine(Theme.Fail($"No devtool.json found at: {result.NewProjectRoot}")); + AnsiConsole.MarkupLine(Theme.Faint("Press any key to stay on current project...")); + Console.ReadKey(intercept: true); + continue; // go back to current app + } + + (currentConfig, currentRoot) = loaded.Value; + } + } + + return 0; +} +catch (Exception ex) +{ + AnsiConsole.MarkupLine(Theme.Fail($"Fatal: {ex.Message}")); + AnsiConsole.WriteException(ex, ExceptionFormats.ShortenEverything); + return 1; +} diff --git a/Journal.DevTool/README.md b/Journal.DevTool/README.md new file mode 100644 index 0000000..1f03773 --- /dev/null +++ b/Journal.DevTool/README.md @@ -0,0 +1,234 @@ +# SDT — Stan's Dev Tools + +> **Status: v0.1 — active development** +> Phosphor-green TUI build orchestrator. Currently embedded in Project Journal; long-term goal is a standalone universal dev tool. + +--- + +## What It Is + +SDT is a terminal UI (TUI) application for managing builds, toolchains, and multi-project workspaces. It reads a `devtool.json` from your project root and presents a menu-driven interface so you never have to remember which script to run, in what order, with what flags. + +``` + ____ ____ _____ +/ ___|| _ \|_ _| +\___ \| | | | | | + ___) | |_| | | | +|____/|____/ |_| +─────────── Project Journal v0.1.0 ───────────── +root: E:\stansshit\csharp\journal-master\journal + + What would you like to do? + BUILD + > Publish Sidecar Build Journal.Sidecar as self-contained exe + Build Web UI Build SvelteKit bundle + Publish WebGateway Publish ASP.NET host with embedded web UI + Build Tauri Desktop App Build desktop exe (no installer) + Full Release Build ✦ Sidecar → Web → WebGateway → Tauri, in order + ... + SYSTEM + ⬡ Toolchain management python / node + ⚙ Edit environment variables + ✗ Quit +``` + +--- + +## Current Features (v0.1) + +### Build Target Runner +- Menu driven by `devtool.json` — add/remove targets without touching SDT code +- **Dependency resolution**: targets declare `dependsOn`; SDT topologically sorts them and runs each step exactly once. Select `webgateway` and `web` runs first automatically. Select `all` and everything runs in the right order. +- **Live output streaming**: stdout in phosphor green, stderr in amber — you see the build as it happens +- Each step reports exit code and elapsed time + +### Environment Variable Editor +- All configurable env vars declared in `devtool.json` +- Dropdown selection for known options (e.g. `none`/`python-sidecar` for AI provider) +- Free-text input for path overrides +- Changes apply to SDT's process environment for the current session + +### Toolchain Management +Python: +- Detect system Python and venv status in one health-check table +- Create / recreate venv (`python -m venv`) +- Install requirements profile — select cpu / gpu / nlp, handles `--extra-index-url` automatically +- Upgrade pip +- Cross-platform venv path resolution (`Scripts/` on Windows, `bin/` on Linux/Mac) + +Node / npm: +- Detect Node.js and npm versions +- Check `node_modules` status +- Run `npm install` (or `pnpm`/`yarn` — configurable per project) + +### Multi-Project Workspace Switcher +- Place `sdt-workspace.json` in any parent directory listing your projects +- SDT detects it automatically on startup +- **Switch Project** appears in SYSTEM menu when workspace is loaded with more than one project +- Selecting a different project hot-reloads config in-process — no restart needed +- Project table shows current (`►`), path, and whether `devtool.json` exists + +--- + +## Running SDT + +From the project root (where `devtool.json` lives): + +```powershell +dotnet run --project Journal.DevTool/Journal.DevTool.csproj +``` + +Or via `just`: +```powershell +just sdt +``` + +SDT walks up the directory tree from wherever you launch it to find `devtool.json`. You don't need to be in any specific directory. + +--- + +## Config Files + +### `devtool.json` (per project) + +```json +{ + "name": "My Project", + "version": "1.0.0", + "toolchains": { + "python": { + "executable": "python3", + "venvDir": ".venv", + "profiles": [ + { "id": "default", "label": "Default", "requirementsFile": "requirements.txt" } + ] + }, + "node": { "packageManager": "npm", "workingDir": "frontend" } + }, + "targets": [ + { + "id": "build", + "label": "Build", + "description": "Build everything", + "group": "Build", + "command": "dotnet", + "args": ["build"], + "workingDir": ".", + "dependsOn": [] + } + ], + "env": [ + { + "key": "MY_VAR", + "description": "Controls something", + "default": "value", + "options": ["value", "other"] + } + ] +} +``` + +**Target fields:** +| Field | Description | +|-------|-------------| +| `id` | Unique identifier, referenced by `dependsOn` | +| `label` | Display name in the menu | +| `description` | Short hint shown in the menu | +| `group` | Menu category (BUILD / DEV / TEST / etc.) | +| `command` | Executable to run (`dotnet`, `pwsh`, `npm`, etc.) — `null` for virtual aggregator | +| `args` | Argument array passed to the executable | +| `workingDir` | Working directory relative to project root | +| `dependsOn` | List of target IDs that must run first | + +### `sdt-workspace.json` (per workspace, any parent directory) + +```json +{ + "name": "My Dev Workspace", + "projects": [ + { "name": "Project A", "description": "Does X", "path": "project-a" }, + { "name": "Project B", "description": "Does Y", "path": "../other-repo/project-b" } + ] +} +``` + +Paths are relative to the `sdt-workspace.json` file. Absolute paths also work. + +--- + +## Project Structure + +``` +Journal.DevTool/ +├── Journal.DevTool.csproj net10.0 exe, outputs as 'sdt' +├── Program.cs Entry point — discovers workspace + project, run loop +├── Config/ +│ ├── DevToolConfig.cs devtool.json models (BuildTarget, EnvVarDef, ToolchainConfig) +│ ├── ConfigLoader.cs Walks up dirs to find and parse devtool.json +│ ├── WorkspaceConfig.cs sdt-workspace.json model +│ └── WorkspaceLoader.cs Finds and parses sdt-workspace.json +├── Runner/ +│ ├── ProcessRunner.cs Runs a process with live stdout/stderr streaming +│ └── TargetRunner.cs Topological dependency resolver +└── Tui/ + ├── Theme.cs Phosphor green palette (#00FF41 + amber + red) + ├── App.cs Main TUI loop — banner, menu, target runner, env editor + ├── ToolchainScreen.cs Python venv/pip + Node/npm management + └── WorkspaceScreen.cs Project switcher +``` + +--- + +## Roadmap + +### v0.2 — Usability & Polish +- [ ] `--target <id>` flag for non-interactive single-target run (CI use) +- [ ] `--list` flag to print targets and exit +- [ ] Config validation with clear error messages on startup +- [ ] Build history — last run result + timestamp per target (persisted to `.sdt-state.json`) +- [ ] Parallel target execution for independent steps (opt-in per target) + +### v0.3 — Package Manager Depth +- [ ] Full pip environment health: list installed packages, outdated check +- [ ] npm/pnpm/yarn: show scripts from `package.json`, run arbitrary script +- [ ] Python version manager integration (pyenv, py launcher on Windows) +- [ ] Virtual environment activation hint for the current shell + +### v0.4 — Multi-Project & Workspace +- [ ] Workspace-level targets that span multiple projects (e.g. build all repos in order) +- [ ] Project dependency graph across workspace (project A's publish feeds project B's build) +- [ ] Workspace health dashboard — all projects' last-build status in one table + +### v0.5 — Env & Secrets +- [ ] `.env` file load/save support (per project and per workspace) +- [ ] Secret redaction in log output (already in Journal's LogRedactor — port to SDT) +- [ ] Environment profiles: save/load named env var sets (e.g. "dev", "staging") + +### v1.0 — Standalone Universal Tool +- [ ] Extract from Journal repo into its own standalone repository +- [ ] Publish as a `dotnet tool` (`dotnet tool install sdt`) +- [ ] Plugin system: projects can register custom SDT commands via `IsdtPlugin` +- [ ] GUI mode (Avalonia or web UI) as an optional launch mode — default CLI, `--gui` for graphical +- [ ] Linux and macOS first-class support (already mostly there — mainly path/exe resolution) +- [ ] JSON schema for `devtool.json` with IDE autocompletion + +### Long-term Vision +SDT's goal is to be **the single tool you open when you sit down at a project** — regardless of language, framework, or OS. Instead of remembering 15 different CLI commands across `dotnet`, `npm`, `pip`, `cargo`, `just`, and `pwsh`, you open SDT and it knows your project's shape from `devtool.json`. + +The workspace layer means you can manage a portfolio of projects — switching between them, running cross-project builds, and keeping a consistent interface across everything you work on. + +--- + +## Dependencies + +- [`Spectre.Console`](https://spectreconsole.net/) `0.49.1` — TUI rendering, selection prompts, tables, progress + +No dependency on `Journal.Core` — SDT is intentionally standalone so it can be extracted cleanly. + +--- + +## Notes + +- SDT does **not** set background colour — it renders on whatever your terminal's background is. A dark terminal is strongly recommended for the phosphor look. +- Environment variable changes made in SDT apply to SDT's own process environment for the session. They are **not** written to your system or shell permanently — by design. +- When a build step fails, SDT stops the plan and does not run subsequent steps. diff --git a/Journal.DevTool/Runner/ProcessRunner.cs b/Journal.DevTool/Runner/ProcessRunner.cs new file mode 100644 index 0000000..33516cc --- /dev/null +++ b/Journal.DevTool/Runner/ProcessRunner.cs @@ -0,0 +1,60 @@ +using System.Diagnostics; + +namespace Sdt.Runner; + +public sealed record RunResult(int ExitCode, TimeSpan Elapsed) +{ + public bool Success => ExitCode == 0; +} + +public static class ProcessRunner +{ + /// <summary> + /// Runs a command with the given args, streaming stdout/stderr via <paramref name="onOutput"/>. + /// onOutput receives (line, isStderr). + /// </summary> + public static async Task<RunResult> RunAsync( + string command, + IEnumerable<string> args, + string workingDir, + Action<string, bool> onOutput, + CancellationToken cancellationToken = default) + { + var psi = new ProcessStartInfo + { + FileName = command, + RedirectStandardOutput = true, + RedirectStandardError = true, + UseShellExecute = false, + CreateNoWindow = true, + WorkingDirectory = workingDir, + }; + + foreach (var arg in args) + psi.ArgumentList.Add(arg); + + var sw = Stopwatch.StartNew(); + + using var process = new Process { StartInfo = psi }; + process.Start(); + + var stdoutTask = DrainAsync(process.StandardOutput, line => onOutput(line, false), cancellationToken); + var stderrTask = DrainAsync(process.StandardError, line => onOutput(line, true), cancellationToken); + + await Task.WhenAll(stdoutTask, stderrTask).ConfigureAwait(false); + await process.WaitForExitAsync(cancellationToken).ConfigureAwait(false); + + sw.Stop(); + return new RunResult(process.ExitCode, sw.Elapsed); + } + + private static async Task DrainAsync(StreamReader reader, Action<string> emit, CancellationToken ct) + { + string? line; + while ((line = await reader.ReadLineAsync(ct).ConfigureAwait(false)) is not null + && !ct.IsCancellationRequested) + { + emit(line); + } + } +} diff --git a/Journal.DevTool/Runner/TargetRunner.cs b/Journal.DevTool/Runner/TargetRunner.cs new file mode 100644 index 0000000..b4c670e --- /dev/null +++ b/Journal.DevTool/Runner/TargetRunner.cs @@ -0,0 +1,41 @@ +using Sdt.Config; + +namespace Sdt.Runner; + +public static class TargetRunner +{ + /// <summary> + /// Returns the ordered list of real (non-virtual) steps needed to execute <paramref name="target"/>, + /// respecting DependsOn chains. Each step appears at most once. + /// </summary> + public static List<BuildTarget> ResolvePlan( + BuildTarget target, + IReadOnlyDictionary<string, BuildTarget> allTargets) + { + var visited = new HashSet<string>(StringComparer.OrdinalIgnoreCase); + var plan = new List<BuildTarget>(); + Visit(target, allTargets, visited, plan); + return plan; + } + + private static void Visit( + BuildTarget target, + IReadOnlyDictionary<string, BuildTarget> allTargets, + HashSet<string> visited, + List<BuildTarget> plan) + { + if (!visited.Add(target.Id)) + return; + + // Recurse into dependencies first (topological order) + foreach (var depId in target.DependsOn) + { + if (allTargets.TryGetValue(depId, out var dep)) + Visit(dep, allTargets, visited, plan); + } + + // Virtual aggregator targets (null Command) are just dependency collectors + if (target.Command is not null) + plan.Add(target); + } +} diff --git a/Journal.DevTool/Tui/App.cs b/Journal.DevTool/Tui/App.cs new file mode 100644 index 0000000..36abb65 --- /dev/null +++ b/Journal.DevTool/Tui/App.cs @@ -0,0 +1,303 @@ +using Sdt.Config; +using Sdt.Runner; +using Spectre.Console; + +namespace Sdt.Tui; + +/// <summary>Thin wrapper used in Spectre.Console selection prompts.</summary> +internal sealed record MenuItem(string Display, string Value); + +public enum AppExitReason { Quit, SwitchProject } +public sealed record AppResult(AppExitReason Reason, string? NewProjectRoot = null); + +public sealed class App( + DevToolConfig config, + string projectRoot, + WorkspaceConfig? workspace = null, + string? workspaceRoot = null) +{ + private DevToolConfig _config = config; + private string _projectRoot = projectRoot; + private readonly WorkspaceConfig? _workspace = workspace; + private readonly string? _workspaceRoot = workspaceRoot; + + private IReadOnlyDictionary<string, BuildTarget> TargetMap => + _config.Targets.ToDictionary(t => t.Id, StringComparer.OrdinalIgnoreCase); + + public async Task<AppResult> RunAsync() + { + while (true) + { + AnsiConsole.Clear(); + RenderBanner(); + + var choice = ShowMainMenu(); + + switch (choice) + { + case "__env__": + EditEnvironment(); + break; + + case "__toolchains__": + await new ToolchainScreen(_config, _projectRoot).RunAsync(); + break; + + case "__workspace__": + if (_workspace is not null && _workspaceRoot is not null) + { + var switcher = new WorkspaceScreen(_workspace, _workspaceRoot, _projectRoot); + var newRoot = switcher.SelectProject(); + if (newRoot is not null) + return new AppResult(AppExitReason.SwitchProject, newRoot); + } + break; + + case "__quit__": + AnsiConsole.MarkupLine("\n" + Theme.Faint("Later.") + "\n"); + return new AppResult(AppExitReason.Quit); + + default: + var targetMap = TargetMap; + if (targetMap.TryGetValue(choice, out var target)) + await RunTargetAsync(target, targetMap); + break; + } + + if (choice != "__quit__") + { + AnsiConsole.MarkupLine("\n" + Theme.Faint("Press any key to return to the menu...")); + Console.ReadKey(intercept: true); + } + } + } + + // ── Banner ──────────────────────────────────────────────────────────────── + + private void RenderBanner() + { + // Phosphor green figlet + AnsiConsole.Write(new FigletText("SDT").Color(Theme.GreenColor)); + + // Project + workspace info line + var wsInfo = _workspace is not null + ? $" [{Theme.GreenDim}]∙ {Markup.Escape(_workspace.Name)}[/]" + : string.Empty; + + AnsiConsole.Write( + new Rule($"[bold {Theme.GreenBold}]{Markup.Escape(_config.Name)}[/] [{Theme.GreenDim}]v{Markup.Escape(_config.Version)}[/]{wsInfo}") + .RuleStyle(Theme.DimStyle)); + + AnsiConsole.MarkupLine(Theme.Faint($"root: {_projectRoot}") + "\n"); + } + + // ── Main menu ───────────────────────────────────────────────────────────── + + private string ShowMainMenu() + { + var prompt = new SelectionPrompt<MenuItem>() + .Title($"[{Theme.Green}]What would you like to do?[/]") + .PageSize(28) + .MoreChoicesText(Theme.Faint("(scroll to see more)")) + .UseConverter(m => m.Display); + + // Targets, grouped + var groups = _config.Targets + .Where(t => !string.IsNullOrWhiteSpace(t.Label)) + .GroupBy(t => string.IsNullOrWhiteSpace(t.Group) ? "General" : t.Group); + + foreach (var group in groups) + { + var header = new MenuItem( + $"[bold {Theme.Amber}]{Markup.Escape(group.Key.ToUpperInvariant())}[/]", + "__group__"); + + var items = group.Select(t => new MenuItem( + $"[{Theme.Green}]{Markup.Escape(t.Label)}[/] [{Theme.GreenDim}]{Markup.Escape(t.Description)}[/]", + t.Id)).ToList(); + + prompt.AddChoiceGroup(header, items); + } + + // System actions + var systemItems = new List<MenuItem> + { + new($"[{Theme.Green}]⚙ Edit environment variables[/]", "__env__"), + }; + + if (_config.Toolchains is not null) + systemItems.Insert(0, new MenuItem( + $"[{Theme.Green}]⬡ Toolchain management[/] [{Theme.GreenDim}]python / node[/]", + "__toolchains__")); + + if (_workspace is not null && (_workspace.Projects.Count > 1)) + systemItems.Insert(0, new MenuItem( + $"[{Theme.Green}]⇄ Switch project[/] [{Theme.GreenDim}]{Markup.Escape(_workspace.Name)}[/]", + "__workspace__")); + + systemItems.Add(new MenuItem($"[{Theme.GreenDim}]✗ Quit[/]", "__quit__")); + + prompt.AddChoiceGroup( + new MenuItem($"[bold {Theme.Amber}]SYSTEM[/]", "__group__"), + systemItems); + + return AnsiConsole.Prompt(prompt).Value; + } + + // ── Target execution ────────────────────────────────────────────────────── + + private async Task RunTargetAsync(BuildTarget target, IReadOnlyDictionary<string, BuildTarget> targetMap) + { + AnsiConsole.Clear(); + AnsiConsole.Write(Theme.SectionRule(target.Label)); + + var plan = TargetRunner.ResolvePlan(target, targetMap); + + if (plan.Count == 0) + { + AnsiConsole.MarkupLine(Theme.Warn("This target has no executable steps.")); + return; + } + + if (plan.Count > 1) + { + AnsiConsole.MarkupLine(Theme.Faint($"Execution plan — {plan.Count} steps:")); + foreach (var step in plan) + AnsiConsole.MarkupLine($" [{Theme.GreenDim}]→[/] [{Theme.Green}]{Markup.Escape(step.Label)}[/]"); + AnsiConsole.WriteLine(); + } + + var allOk = true; + var totalSw = System.Diagnostics.Stopwatch.StartNew(); + + foreach (var step in plan) + { + AnsiConsole.Write(Theme.DimRule()); + + var workingDir = Path.GetFullPath(Path.Combine(_projectRoot, step.WorkingDir)); + var cmdDisplay = $"{step.Command} {string.Join(" ", step.Args)}"; + + AnsiConsole.MarkupLine($"[{Theme.GreenDim}]$ {Markup.Escape(cmdDisplay)}[/]"); + AnsiConsole.MarkupLine($"[{Theme.GreenDim}] {Markup.Escape(workingDir)}[/]\n"); + + RunResult result; + try + { + result = await ProcessRunner.RunAsync( + step.Command!, + step.Args, + workingDir, + (line, isErr) => + { + var escaped = Markup.Escape(line); + AnsiConsole.MarkupLine(isErr + ? $"[{Theme.Amber}]{escaped}[/]" + : $"[{Theme.Green}]{escaped}[/]"); + }); + } + catch (Exception ex) + { + AnsiConsole.MarkupLine("\n" + Theme.Fail($"Failed to launch: {ex.Message}")); + allOk = false; + break; + } + + AnsiConsole.WriteLine(); + + if (result.Success) + AnsiConsole.MarkupLine(Theme.Ok($"{step.Label} ({result.Elapsed.TotalSeconds:F1}s)")); + else + { + AnsiConsole.MarkupLine(Theme.Fail($"{step.Label} — exited {result.ExitCode} ({result.Elapsed.TotalSeconds:F1}s)")); + allOk = false; + break; + } + } + + totalSw.Stop(); + AnsiConsole.Write(Theme.SectionRule()); + AnsiConsole.MarkupLine(allOk + ? "\n" + Theme.Ok($"Done! Total: {totalSw.Elapsed.TotalSeconds:F1}s") + : "\n" + Theme.Fail("Build failed. Check output above.")); + } + + // ── Environment editor ──────────────────────────────────────────────────── + + private void EditEnvironment() + { + AnsiConsole.Clear(); + + if (_config.Env.Count == 0) + { + AnsiConsole.MarkupLine(Theme.Warn("No environment variables defined in devtool.json.")); + AnsiConsole.MarkupLine("\n" + Theme.Faint("Press any key to go back...")); + Console.ReadKey(intercept: true); + return; + } + + while (true) + { + AnsiConsole.Write(Theme.SectionRule("ENVIRONMENT")); + + var table = new Table() + .Border(TableBorder.Rounded) + .BorderStyle(Theme.DimStyle) + .AddColumn(new TableColumn($"[{Theme.Amber}]Variable[/]")) + .AddColumn(new TableColumn($"[{Theme.Amber}]Current Value[/]")) + .AddColumn(new TableColumn($"[{Theme.Amber}]Description[/]")); + + foreach (var def in _config.Env) + { + var val = Environment.GetEnvironmentVariable(def.Key) ?? def.DefaultValue; + table.AddRow( + Theme.Warn(def.Key), + Theme.Bold(val.Length > 0 ? val : "(not set)"), + Theme.Faint(def.Description)); + } + + AnsiConsole.Write(table); + AnsiConsole.MarkupLine(Theme.Faint("Changes apply to this SDT session only.\n")); + + var choices = _config.Env + .Select(e => + { + var curr = Environment.GetEnvironmentVariable(e.Key) ?? e.DefaultValue; + return new MenuItem( + $"[{Theme.Amber}]{Markup.Escape(e.Key)}[/] [{Theme.GreenDim}]= {Markup.Escape(curr)}[/]", + e.Key); + }) + .Append(new MenuItem(Theme.Faint("← Back"), "__back__")) + .ToList(); + + var selected = AnsiConsole.Prompt( + new SelectionPrompt<MenuItem>() + .Title($"[{Theme.Green}]Select a variable to edit:[/]") + .UseConverter(m => m.Display) + .AddChoices(choices)); + + if (selected.Value == "__back__") break; + + var envDef = _config.Env.First(e => e.Key == selected.Value); + var current = Environment.GetEnvironmentVariable(envDef.Key) ?? envDef.DefaultValue; + + string newVal; + if (envDef.Options.Count > 0) + { + newVal = AnsiConsole.Prompt( + new SelectionPrompt<string>() + .Title($"[{Theme.Amber}]{Markup.Escape(envDef.Key)}[/] [{Theme.GreenDim}]current: {Markup.Escape(current)}[/]") + .AddChoices(envDef.Options)); + } + else + { + newVal = AnsiConsole.Ask( + $"[{Theme.Amber}]{Markup.Escape(envDef.Key)}[/]", current); + } + + Environment.SetEnvironmentVariable(envDef.Key, newVal); + AnsiConsole.MarkupLine("\n" + Theme.Ok($"{envDef.Key} = {newVal}") + "\n"); + Thread.Sleep(500); + AnsiConsole.Clear(); + } + } +} diff --git a/Journal.DevTool/Tui/Theme.cs b/Journal.DevTool/Tui/Theme.cs new file mode 100644 index 0000000..3593e86 --- /dev/null +++ b/Journal.DevTool/Tui/Theme.cs @@ -0,0 +1,54 @@ +using Spectre.Console; + +namespace Sdt.Tui; + +/// <summary> +/// SDT phosphor-green colour palette. +/// Primary text is classic terminal phosphor (#00FF41). +/// Modern accent colours are kept for highlights and status. +/// </summary> +internal static class Theme +{ + // ── Hex colour constants (use in Spectre markup strings) ───────────────── + public const string Green = "#00ff41"; // primary phosphor — all normal text + public const string GreenDim = "#005c1b"; // muted — borders, secondary info + public const string GreenBold = "#a8ff90"; // bright — selections, emphasis + public const string Amber = "#ffb300"; // warnings / group titles + public const string Red = "#ff4040"; // errors + public const string Ghost = "#003d12"; // near-invisible — decorative scanlines + + // ── Spectre Color instances (for FigletText, Rule styles, etc.) ────────── + public static readonly Color GreenColor = new(0, 255, 65); + public static readonly Color GreenDimColor = new(0, 92, 27); + public static readonly Color GreenBoldColor = new(168, 255, 144); + public static readonly Color AmberColor = new(255, 179, 0); + public static readonly Color RedColor = new(255, 64, 64); + + // ── Pre-built Style objects ─────────────────────────────────────────────── + public static readonly Style PrimaryStyle = new(GreenColor); + public static readonly Style DimStyle = new(GreenDimColor); + public static readonly Style BrightStyle = new(GreenBoldColor, decoration: Decoration.Bold); + public static readonly Style AmberStyle = new(AmberColor); + public static readonly Style RedStyle = new(RedColor, decoration: Decoration.Bold); + + // ── Markup helper methods (auto-escape user content) ───────────────────── + public static string G(string t) => $"[{Green}]{Markup.Escape(t)}[/]"; + public static string Faint(string t) => $"[{GreenDim}]{Markup.Escape(t)}[/]"; + public static string Bold(string t) => $"[bold {GreenBold}]{Markup.Escape(t)}[/]"; + public static string Warn(string t) => $"[{Amber}]{Markup.Escape(t)}[/]"; + public static string Err(string t) => $"[bold {Red}]{Markup.Escape(t)}[/]"; + public static string Ok(string t) => $"[bold {Green}]✓ {Markup.Escape(t)}[/]"; + public static string Fail(string t) => $"[bold {Red}]✗ {Markup.Escape(t)}[/]"; + + // ── Shared UI components ────────────────────────────────────────────────── + public static Rule SectionRule(string? title = null) => title is null + ? new Rule().RuleStyle(DimStyle) + : new Rule($"[bold {GreenBold}]{Markup.Escape(title)}[/]").RuleStyle(DimStyle); + + public static Rule DimRule() => new Rule().RuleStyle(new Style(new Color(0, 40, 12))); + + public static Panel StatusPanel(string markup) => + new Panel(markup) + .BorderStyle(DimStyle) + .Padding(1, 0); +} diff --git a/Journal.DevTool/Tui/ToolchainScreen.cs b/Journal.DevTool/Tui/ToolchainScreen.cs new file mode 100644 index 0000000..96a8ec4 --- /dev/null +++ b/Journal.DevTool/Tui/ToolchainScreen.cs @@ -0,0 +1,313 @@ +using Sdt.Config; +using Sdt.Runner; +using Sdt.Tui; +using Spectre.Console; + +namespace Sdt.Tui; + +public sealed class ToolchainScreen(DevToolConfig config, string projectRoot) +{ + private readonly DevToolConfig _config = config; + private readonly string _projectRoot = projectRoot; + + public async Task RunAsync() + { + while (true) + { + AnsiConsole.Clear(); + AnsiConsole.Write(Theme.SectionRule("TOOLCHAINS")); + AnsiConsole.WriteLine(); + + var tc = _config.Toolchains; + if (tc is null) + { + AnsiConsole.MarkupLine(Theme.Warn("No toolchains configured in devtool.json.")); + AnsiConsole.MarkupLine(Theme.Faint("Add a \"toolchains\" section with \"python\" and/or \"node\" entries.")); + AnsiConsole.MarkupLine("\n" + Theme.Faint("Press any key to go back...")); + Console.ReadKey(intercept: true); + return; + } + + // Build menu from available toolchains + var choices = new List<MenuItem>(); + + if (tc.Python is not null) + { + choices.Add(new MenuItem($"[bold {Theme.GreenBold}]PYTHON[/]", "__group__")); + choices.Add(new MenuItem($"{Theme.G("Check environment")} {Theme.Faint("detect python, venv, pip")}", "py:check")); + choices.Add(new MenuItem($"{Theme.G("Create / recreate venv")} {Theme.Faint($"python -m venv {tc.Python.VenvDir}")}", "py:venv")); + if (tc.Python.Profiles.Count > 0) + choices.Add(new MenuItem($"{Theme.G("Install requirements profile")} {Theme.Faint("select cpu / gpu / nlp...")}", "py:install")); + choices.Add(new MenuItem($"{Theme.G("Upgrade pip")} {Theme.Faint("pip install --upgrade pip")}", "py:upgradepip")); + } + + if (tc.Node is not null) + { + choices.Add(new MenuItem($"[bold {Theme.GreenBold}]NODE / NPM[/]", "__group__")); + choices.Add(new MenuItem($"{Theme.G("Check environment")} {Theme.Faint("detect node, npm, node_modules")}", "node:check")); + choices.Add(new MenuItem($"{Theme.G($"{tc.Node.PackageManager} install")} {Theme.Faint($"in {tc.Node.WorkingDir}")}", "node:install")); + } + + choices.Add(new MenuItem($"[bold {Theme.GreenBold}]──[/]", "__group__")); + choices.Add(new MenuItem(Theme.Faint("← Back"), "__back__")); + + var prompt = new SelectionPrompt<MenuItem>() + .Title($"[{Theme.Green}]Select a toolchain action:[/]") + .PageSize(20) + .UseConverter(m => m.Display) + .AddChoices(choices); + + var selected = AnsiConsole.Prompt(prompt); + if (selected.Value == "__back__" || selected.Value == "__group__") return; + + AnsiConsole.Clear(); + AnsiConsole.Write(Theme.SectionRule(selected.Value.Split(':')[0].ToUpperInvariant() + " › " + selected.Value.Split(':')[1])); + AnsiConsole.WriteLine(); + + await HandleActionAsync(selected.Value, tc); + + AnsiConsole.MarkupLine("\n" + Theme.Faint("Press any key to continue...")); + Console.ReadKey(intercept: true); + } + } + + // ── Actions ─────────────────────────────────────────────────────────────── + + private async Task HandleActionAsync(string action, ToolchainConfig tc) + { + switch (action) + { + case "py:check": await CheckPythonAsync(tc.Python!); break; + case "py:venv": await CreateVenvAsync(tc.Python!); break; + case "py:install": await InstallProfileAsync(tc.Python!); break; + case "py:upgradepip": await UpgradePipAsync(tc.Python!); break; + case "node:check": await CheckNodeAsync(tc.Node!); break; + case "node:install": await NodeInstallAsync(tc.Node!); break; + } + } + + // ── Python ──────────────────────────────────────────────────────────────── + + private async Task CheckPythonAsync(PythonToolchain py) + { + var exe = ResolvePythonExe(py); + var venvPath = Path.GetFullPath(Path.Combine(_projectRoot, py.VenvDir)); + var venvPython = GetVenvPython(venvPath); + + var table = new Table() + .Border(TableBorder.Rounded) + .BorderStyle(Theme.DimStyle) + .AddColumn(new TableColumn($"[{Theme.Amber}]Check[/]").Width(24)) + .AddColumn(new TableColumn($"[{Theme.GreenBold}]Result[/]")); + + // System Python + var pyVersion = await ProbeAsync(exe, "--version"); + table.AddRow(Theme.G("System Python"), pyVersion is not null + ? Theme.Ok(pyVersion.Trim()) + : Theme.Fail($"{exe} not found")); + + // Venv exists? + table.AddRow(Theme.G($"Venv ({py.VenvDir})"), Directory.Exists(venvPath) + ? Theme.Ok("exists " + venvPath) + : Theme.Warn("not found — use 'Create venv'")); + + // Venv Python + if (File.Exists(venvPython)) + { + var venvVersion = await ProbeAsync(venvPython, "--version"); + table.AddRow(Theme.G("Venv Python"), venvVersion is not null + ? Theme.Ok(venvVersion.Trim()) + : Theme.Fail("could not launch")); + } + + // Pip in venv + if (File.Exists(venvPython)) + { + var pipVersion = await ProbeAsync(venvPython, "-m", "pip", "--version"); + table.AddRow(Theme.G("Pip (venv)"), pipVersion is not null + ? Theme.Ok(pipVersion.Trim()) + : Theme.Fail("pip not available")); + } + + AnsiConsole.Write(table); + } + + private async Task CreateVenvAsync(PythonToolchain py) + { + var exe = ResolvePythonExe(py); + var venvDir = py.VenvDir; + var venvPath = Path.GetFullPath(Path.Combine(_projectRoot, venvDir)); + + if (Directory.Exists(venvPath)) + { + var overwrite = AnsiConsole.Confirm( + $"[{Theme.Amber}]Venv already exists at {venvDir}. Recreate it?[/]", defaultValue: false); + if (!overwrite) return; + Directory.Delete(venvPath, recursive: true); + } + + AnsiConsole.MarkupLine(Theme.G($"Creating venv: {exe} -m venv {venvDir}")); + AnsiConsole.WriteLine(); + + await RunLiveAsync(exe, ["-m", "venv", venvDir], _projectRoot); + } + + private async Task InstallProfileAsync(PythonToolchain py) + { + var venvPath = Path.GetFullPath(Path.Combine(_projectRoot, py.VenvDir)); + var venvPy = GetVenvPython(venvPath); + + if (!File.Exists(venvPy)) + { + AnsiConsole.MarkupLine(Theme.Warn("Venv not found. Create it first.")); + return; + } + + var profile = AnsiConsole.Prompt( + new SelectionPrompt<PythonProfile>() + .Title($"[{Theme.Green}]Select requirements profile:[/]") + .UseConverter(p => $"{Theme.Bold(p.Label)} {Theme.Faint(p.RequirementsFile)}") + .AddChoices(py.Profiles)); + + var reqFile = Path.GetFullPath(Path.Combine(_projectRoot, profile.RequirementsFile)); + if (!File.Exists(reqFile)) + { + AnsiConsole.MarkupLine(Theme.Fail($"Requirements file not found: {reqFile}")); + return; + } + + // Upgrade pip first + AnsiConsole.MarkupLine(Theme.Faint("Upgrading pip...")); + await RunLiveAsync(venvPy, ["-m", "pip", "install", "--upgrade", "pip"], _projectRoot); + + // Build install args + var installArgs = new List<string> { "-m", "pip", "install" }; + if (!string.IsNullOrWhiteSpace(profile.ExtraIndexUrl)) + { + installArgs.Add("--extra-index-url"); + installArgs.Add(profile.ExtraIndexUrl); + } + installArgs.Add("-r"); + installArgs.Add(reqFile); + + AnsiConsole.WriteLine(); + AnsiConsole.MarkupLine(Theme.G($"Installing {profile.Label}...")); + AnsiConsole.WriteLine(); + await RunLiveAsync(venvPy, installArgs, _projectRoot); + + // Post-install commands + foreach (var cmd in profile.PostInstallCommands) + { + AnsiConsole.WriteLine(); + AnsiConsole.MarkupLine(Theme.Faint($"Post-install: {cmd}")); + var parts = cmd.Split(' ', 2); + var postArgs = parts.Length > 1 ? parts[1].Split(' ') : Array.Empty<string>(); + await RunLiveAsync(venvPy, ["-m", .. postArgs], _projectRoot); + } + } + + private async Task UpgradePipAsync(PythonToolchain py) + { + var venvPath = Path.GetFullPath(Path.Combine(_projectRoot, py.VenvDir)); + var venvPy = GetVenvPython(venvPath); + var exe = File.Exists(venvPy) ? venvPy : ResolvePythonExe(py); + + AnsiConsole.MarkupLine(Theme.G($"Upgrading pip using: {exe}")); + AnsiConsole.WriteLine(); + await RunLiveAsync(exe, ["-m", "pip", "install", "--upgrade", "pip"], _projectRoot); + } + + // ── Node ────────────────────────────────────────────────────────────────── + + private async Task CheckNodeAsync(NodeToolchain node) + { + var nodeModules = Path.GetFullPath( + Path.Combine(_projectRoot, node.WorkingDir, "node_modules")); + + var table = new Table() + .Border(TableBorder.Rounded) + .BorderStyle(Theme.DimStyle) + .AddColumn(new TableColumn($"[{Theme.Amber}]Check[/]").Width(24)) + .AddColumn(new TableColumn($"[{Theme.GreenBold}]Result[/]")); + + var nodeVersion = await ProbeAsync("node", "--version"); + table.AddRow(Theme.G("Node.js"), nodeVersion is not null + ? Theme.Ok(nodeVersion.Trim()) + : Theme.Fail("node not found in PATH")); + + var npmVersion = await ProbeAsync(node.PackageManager, "--version"); + table.AddRow(Theme.G(node.PackageManager), npmVersion is not null + ? Theme.Ok(npmVersion.Trim()) + : Theme.Fail($"{node.PackageManager} not found in PATH")); + + table.AddRow(Theme.G("node_modules"), Directory.Exists(nodeModules) + ? Theme.Ok("exists") + : Theme.Warn($"not found — run {node.PackageManager} install")); + + AnsiConsole.Write(table); + } + + private async Task NodeInstallAsync(NodeToolchain node) + { + var workDir = Path.GetFullPath(Path.Combine(_projectRoot, node.WorkingDir)); + AnsiConsole.MarkupLine(Theme.G($"{node.PackageManager} install ({workDir})")); + AnsiConsole.WriteLine(); + await RunLiveAsync(node.PackageManager, ["install"], workDir); + } + + // ── Helpers ─────────────────────────────────────────────────────────────── + + private static string ResolvePythonExe(PythonToolchain py) + { + if (OperatingSystem.IsWindows() && !string.IsNullOrWhiteSpace(py.WindowsExecutable)) + return py.WindowsExecutable; + return py.Executable; + } + + private static string GetVenvPython(string venvPath) + { + // Windows: .venv\Scripts\python.exe | Linux/Mac: .venv/bin/python + return OperatingSystem.IsWindows() + ? Path.Combine(venvPath, "Scripts", "python.exe") + : Path.Combine(venvPath, "bin", "python"); + } + + private static async Task<string?> ProbeAsync(string command, params string[] args) + { + try + { + var psi = new System.Diagnostics.ProcessStartInfo + { + FileName = command, + RedirectStandardOutput = true, + RedirectStandardError = true, + UseShellExecute = false, + CreateNoWindow = true, + }; + foreach (var a in args) psi.ArgumentList.Add(a); + + using var p = new System.Diagnostics.Process { StartInfo = psi }; + p.Start(); + var output = await p.StandardOutput.ReadToEndAsync(); + var err = await p.StandardError.ReadToEndAsync(); + await p.WaitForExitAsync(); + return p.ExitCode == 0 ? (output + err) : null; + } + catch { return null; } + } + + private static async Task RunLiveAsync(string command, IEnumerable<string> args, string workingDir) + { + var result = await ProcessRunner.RunAsync( + command, args, workingDir, + (line, isErr) => AnsiConsole.MarkupLine( + isErr + ? $"[{Theme.Amber}]{Markup.Escape(line)}[/]" + : $"[{Theme.Green}]{Markup.Escape(line)}[/]")); + + AnsiConsole.WriteLine(); + AnsiConsole.MarkupLine(result.Success + ? Theme.Ok($"Done ({result.Elapsed.TotalSeconds:F1}s)") + : Theme.Fail($"Exited {result.ExitCode} ({result.Elapsed.TotalSeconds:F1}s)")); + } +} diff --git a/Journal.DevTool/Tui/WorkspaceScreen.cs b/Journal.DevTool/Tui/WorkspaceScreen.cs new file mode 100644 index 0000000..38d6a37 --- /dev/null +++ b/Journal.DevTool/Tui/WorkspaceScreen.cs @@ -0,0 +1,101 @@ +using Sdt.Config; +using Spectre.Console; + +namespace Sdt.Tui; + +public sealed class WorkspaceScreen(WorkspaceConfig workspace, string workspaceRoot, string currentProjectRoot) +{ + private readonly WorkspaceConfig _workspace = workspace; + private readonly string _workspaceRoot = workspaceRoot; + private readonly string _currentProjectRoot = currentProjectRoot; + + /// <summary> + /// Shows the project switcher. Returns the absolute path to the selected project root, + /// or null if the user cancelled. + /// </summary> + public string? SelectProject() + { + AnsiConsole.Clear(); + AnsiConsole.Write(Theme.SectionRule("WORKSPACE — " + _workspace.Name)); + AnsiConsole.WriteLine(); + + var projects = _workspace.Projects; + if (projects.Count == 0) + { + AnsiConsole.MarkupLine(Theme.Warn("No projects defined in sdt-workspace.json.")); + AnsiConsole.MarkupLine(Theme.Faint("Add entries to the \"projects\" array.")); + AnsiConsole.MarkupLine("\n" + Theme.Faint("Press any key to go back...")); + Console.ReadKey(intercept: true); + return null; + } + + // Build choice list with current project marked + var choices = new List<WorkspaceMenuItem>(); + foreach (var proj in projects) + { + var absPath = WorkspaceLoader.ResolveProjectRoot(_workspaceRoot, proj); + var devtoolPath = Path.Combine(absPath, "devtool.json"); + var isCurrent = string.Equals(absPath, _currentProjectRoot, StringComparison.OrdinalIgnoreCase); + var exists = File.Exists(devtoolPath); + + var label = isCurrent + ? $"[bold {Theme.GreenBold}]► {Markup.Escape(proj.Name)}[/] [{Theme.GreenDim}](current)[/]" + : $"[{Theme.Green}] {Markup.Escape(proj.Name)}[/]"; + + var desc = !exists + ? $" [{Theme.Red}]devtool.json not found[/]" + : string.IsNullOrWhiteSpace(proj.Description) + ? $" [{Theme.GreenDim}]{Markup.Escape(absPath)}[/]" + : $" [{Theme.GreenDim}]{Markup.Escape(proj.Description)}[/]"; + + choices.Add(new WorkspaceMenuItem(label + "\n" + desc, absPath, exists && !isCurrent)); + } + + choices.Add(new WorkspaceMenuItem($"[{Theme.GreenDim}]← Cancel[/]", null, true)); + + // Show project table for overview + var table = new Table() + .Border(TableBorder.Rounded) + .BorderStyle(Theme.DimStyle) + .AddColumn(new TableColumn($"[{Theme.Amber}]Project[/]")) + .AddColumn(new TableColumn($"[{Theme.Amber}]Path[/]")) + .AddColumn(new TableColumn($"[{Theme.Amber}]Status[/]").Width(12)); + + foreach (var proj in projects) + { + var absPath = WorkspaceLoader.ResolveProjectRoot(_workspaceRoot, proj); + var isCurrent = string.Equals(absPath, _currentProjectRoot, StringComparison.OrdinalIgnoreCase); + var hasConfig = File.Exists(Path.Combine(absPath, "devtool.json")); + + table.AddRow( + isCurrent + ? $"[bold {Theme.GreenBold}]► {Markup.Escape(proj.Name)}[/]" + : Theme.G(proj.Name), + Theme.Faint(proj.Path), + hasConfig ? Theme.Ok("ready") : Theme.Fail("no config")); + } + + AnsiConsole.Write(table); + AnsiConsole.WriteLine(); + + var switchable = choices.Where(c => c.Selectable).ToList(); + if (switchable.Count == 1) // only Cancel + { + AnsiConsole.MarkupLine(Theme.Warn("No other projects available to switch to.")); + AnsiConsole.MarkupLine("\n" + Theme.Faint("Press any key to go back...")); + Console.ReadKey(intercept: true); + return null; + } + + var selected = AnsiConsole.Prompt( + new SelectionPrompt<WorkspaceMenuItem>() + .Title($"[{Theme.Green}]Switch to project:[/]") + .PageSize(15) + .UseConverter(m => m.Display) + .AddChoices(switchable)); + + return selected.AbsPath; // null = cancelled + } + + private sealed record WorkspaceMenuItem(string Display, string? AbsPath, bool Selectable); +} diff --git a/Journal.Sidecar/App.cs b/Journal.Sidecar/App.cs new file mode 100644 index 0000000..e3246b5 --- /dev/null +++ b/Journal.Sidecar/App.cs @@ -0,0 +1,13 @@ +using Microsoft.Extensions.DependencyInjection; +using Journal.Core; +using Journal.Core.Services.Sidecar; + +var services = new ServiceCollection(); +services.AddFragmentServices(); +services.AddSingleton<Entry>(); +var provider = services.BuildServiceProvider(); + +var entry = provider.GetRequiredService<Entry>(); +var cli = provider.GetRequiredService<SidecarCli>(); +var exitCode = await cli.RunAsync(args, entry); +Environment.ExitCode = exitCode; diff --git a/Journal.Sidecar/Journal.Sidecar.csproj b/Journal.Sidecar/Journal.Sidecar.csproj new file mode 100644 index 0000000..d9b4688 --- /dev/null +++ b/Journal.Sidecar/Journal.Sidecar.csproj @@ -0,0 +1,18 @@ +<Project Sdk="Microsoft.NET.Sdk"> + + <PropertyGroup> + <OutputType>Exe</OutputType> + <TargetFramework>net10.0</TargetFramework> + <ImplicitUsings>enable</ImplicitUsings> + <Nullable>enable</Nullable> + </PropertyGroup> + + <ItemGroup> + <ProjectReference Include="..\Journal.Core\Journal.Core.csproj" /> + </ItemGroup> + + <ItemGroup> + <PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="10.0.3" /> + </ItemGroup> + +</Project> diff --git a/Journal.SmokeTests/Fixtures/transport_cases.json b/Journal.SmokeTests/Fixtures/transport_cases.json new file mode 100644 index 0000000..b6c84dd --- /dev/null +++ b/Journal.SmokeTests/Fixtures/transport_cases.json @@ -0,0 +1,50 @@ +[ + { + "name": "List returns array envelope", + "request": "{\"action\":\"fragments.list\"}", + "expectOk": true, + "dataKind": "array" + }, + { + "name": "Create returns object envelope", + "request": "{\"action\":\"fragments.create\",\"payload\":{\"type\":\"!NOTE\",\"description\":\"fixture create\"}}", + "expectOk": true, + "dataKind": "object" + }, + { + "name": "Get missing id returns null data", + "request": "{\"action\":\"fragments.get\",\"id\":\"00000000-0000-0000-0000-000000000001\"}", + "expectOk": true, + "dataKind": "null" + }, + { + "name": "Create missing payload fails", + "request": "{\"action\":\"fragments.create\"}", + "expectOk": false, + "errorContains": "payload" + }, + { + "name": "AI health returns object envelope", + "request": "{\"action\":\"ai.health\"}", + "expectOk": true, + "dataKind": "object" + }, + { + "name": "AI summarize entry returns string envelope", + "request": "{\"action\":\"ai.summarize_entry\",\"payload\":{\"content\":\"transport test\"}}", + "expectOk": true, + "dataKind": "string" + }, + { + "name": "Unknown action fails", + "request": "{\"action\":\"unknown.action\"}", + "expectOk": false, + "errorContains": "Unknown action" + }, + { + "name": "Malformed JSON fails", + "request": "{\"action\":\"fragments.list\"", + "expectOk": false, + "errorContains": "Invalid command JSON" + } +] diff --git a/Journal.SmokeTests/GlobalUsings.cs b/Journal.SmokeTests/GlobalUsings.cs new file mode 100644 index 0000000..9fe682e --- /dev/null +++ b/Journal.SmokeTests/GlobalUsings.cs @@ -0,0 +1,19 @@ +global using System.ComponentModel.DataAnnotations; +global using System.IO.Compression; +global using System.Security.Cryptography; +global using System.Text.Json; +global using Journal.Core; +global using Journal.Core.Dtos; +global using Journal.Core.Models; +global using Journal.Core.Repositories; +global using Journal.Core.Services.Ai; +global using Journal.Core.Services.Config; +global using Journal.Core.Services.Database; +global using Journal.Core.Services.Entries; +global using Journal.Core.Services.Fragments; +global using Journal.Core.Services.Logging; +global using Journal.Core.Services.Speech; +global using Journal.Core.Services.Sidecar; +global using Journal.Core.Services.Lists; +global using Journal.Core.Services.Todos; +global using Journal.Core.Services.Vault; diff --git a/Journal.SmokeTests/Journal.SmokeTests.csproj b/Journal.SmokeTests/Journal.SmokeTests.csproj new file mode 100644 index 0000000..a81680c --- /dev/null +++ b/Journal.SmokeTests/Journal.SmokeTests.csproj @@ -0,0 +1,20 @@ +<Project Sdk="Microsoft.NET.Sdk"> + + <PropertyGroup> + <OutputType>Exe</OutputType> + <TargetFramework>net10.0</TargetFramework> + <ImplicitUsings>enable</ImplicitUsings> + <Nullable>enable</Nullable> + </PropertyGroup> + + <ItemGroup> + <ProjectReference Include="..\Journal.Core\Journal.Core.csproj" /> + </ItemGroup> + + <ItemGroup> + <None Update="Fixtures\*.json"> + <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> + </None> + </ItemGroup> + +</Project> diff --git a/Journal.SmokeTests/Program.AiSpeechTests.cs b/Journal.SmokeTests/Program.AiSpeechTests.cs new file mode 100644 index 0000000..50f7fce --- /dev/null +++ b/Journal.SmokeTests/Program.AiSpeechTests.cs @@ -0,0 +1,342 @@ +internal static partial class Program +{ + static async Task TestEntryAiHealthDefaultAsync() + { + var entry = NewEntry(); + var response = await entry.HandleCommandAsync("""{"action":"ai.health"}"""); + using var doc = JsonDocument.Parse(response); + + Assert(doc.RootElement.GetProperty("ok").GetBoolean(), "Expected ok=true for ai.health."); + var data = doc.RootElement.GetProperty("data"); + Assert(data.GetProperty("Enabled").GetBoolean() is false, "Expected AI disabled by default."); + Assert(string.Equals(data.GetProperty("Provider").GetString(), "none", StringComparison.OrdinalIgnoreCase), "Expected default provider 'none'."); + } + + static async Task TestEntryAiSummarizeEntryDisabledAsync() + { + var entry = NewEntry(); + var request = JsonSerializer.Serialize(new + { + action = "ai.summarize_entry", + payload = new + { + content = "sample entry" + } + }); + + var response = await entry.HandleCommandAsync(request); + using var doc = JsonDocument.Parse(response); + + Assert(doc.RootElement.GetProperty("ok").GetBoolean(), "Expected ok=true for disabled ai.summarize_entry."); + var data = doc.RootElement.GetProperty("data").GetString() ?? ""; + Assert(data.Contains("disabled", StringComparison.OrdinalIgnoreCase), "Expected disabled provider message for ai.summarize_entry."); + } + + static async Task TestEntryAiSummarizeAllDisabledAsync() + { + var entry = NewEntry(); + var request = JsonSerializer.Serialize(new + { + action = "ai.summarize_all", + payload = new + { + entries = new[] { "entry one", "entry two" } + } + }); + + var response = await entry.HandleCommandAsync(request); + using var doc = JsonDocument.Parse(response); + + Assert(doc.RootElement.GetProperty("ok").GetBoolean(), "Expected ok=true for disabled ai.summarize_all."); + var data = doc.RootElement.GetProperty("data").GetString() ?? ""; + Assert(data.Contains("disabled", StringComparison.OrdinalIgnoreCase), "Expected disabled provider message for ai.summarize_all."); + } + + static async Task TestEntryAiChatDisabledAsync() + { + var entry = NewEntry(); + var request = JsonSerializer.Serialize(new + { + action = "ai.chat", + payload = new + { + prompt = "hello cloud" + } + }); + + var response = await entry.HandleCommandAsync(request); + using var doc = JsonDocument.Parse(response); + + Assert(doc.RootElement.GetProperty("ok").GetBoolean(), "Expected ok=true for disabled ai.chat."); + var data = doc.RootElement.GetProperty("data").GetString() ?? ""; + Assert(data.Contains("disabled", StringComparison.OrdinalIgnoreCase), "Expected disabled provider message for ai.chat."); + } + + static async Task TestEntryAiEmbedDisabledAsync() + { + var entry = NewEntry(); + var request = JsonSerializer.Serialize(new + { + action = "ai.embed", + payload = new + { + content = "embedding source text" + } + }); + + var response = await entry.HandleCommandAsync(request); + using var doc = JsonDocument.Parse(response); + + Assert(doc.RootElement.GetProperty("ok").GetBoolean(), "Expected ok=true for disabled ai.embed."); + var data = doc.RootElement.GetProperty("data"); + Assert(data.ValueKind == JsonValueKind.Array, "Expected ai.embed response to be a JSON array."); + Assert(data.GetArrayLength() == 0, "Expected disabled ai.embed to return an empty vector."); + } + + static async Task TestEntrySpeechDevicesListDisabledAsync() + { + var entry = NewEntry(); + var request = JsonSerializer.Serialize(new + { + action = "speech.devices.list", + payload = new { } + }); + + var response = await entry.HandleCommandAsync(request); + using var doc = JsonDocument.Parse(response); + Assert(doc.RootElement.GetProperty("ok").GetBoolean(), "Expected ok=true for speech.devices.list when disabled."); + var data = doc.RootElement.GetProperty("data"); + Assert(data.ValueKind == JsonValueKind.Object, "Expected speech.devices.list data to be an object."); + } + + static async Task TestEntrySpeechTranscribeDisabledAsync() + { + var entry = NewEntry(); + var request = JsonSerializer.Serialize(new + { + action = "speech.transcribe", + payload = new + { + text = "fixture transcript", + engine = "whisper" + } + }); + + var response = await entry.HandleCommandAsync(request); + using var doc = JsonDocument.Parse(response); + Assert(doc.RootElement.GetProperty("ok").GetBoolean(), "Expected ok=true for speech.transcribe when disabled."); + var data = doc.RootElement.GetProperty("data"); + Assert(data.ValueKind == JsonValueKind.Object, "Expected speech.transcribe data to be an object."); + var warning = data.TryGetProperty("Warning", out var warningNode) ? warningNode.GetString() ?? "" : ""; + Assert(warning.Contains("disabled", StringComparison.OrdinalIgnoreCase), "Expected disabled speech warning."); + } + + static async Task TestPythonSidecarAiServiceJsonLineAsync() + { + var root = Path.Combine(Path.GetTempPath(), "journal-ai-smoke", Guid.NewGuid().ToString("N")); + Directory.CreateDirectory(root); + var scriptPath = Path.Combine(root, "fake_ai_sidecar.py"); + File.WriteAllText(scriptPath, """ +import json, sys +request = json.loads(sys.stdin.readline()) +action = request.get("action", "") +print("DEBUG prelude") +if action == "health": + print(json.dumps({"ok": True, "data": {"provider": "python-sidecar", "healthy": True, "message": "ok"}})) +elif action == "summarize_entry": + payload = request.get("payload") or {} + print(json.dumps({"ok": True, "data": "ENTRY::" + str(payload.get("content", ""))})) +elif action == "summarize_all": + payload = request.get("payload") or {} + entries = payload.get("entries") or [] + print(json.dumps({"ok": True, "data": "ALL::" + str(len(entries))})) +elif action == "chat": + payload = request.get("payload") or {} + print(json.dumps({"ok": True, "data": "CHAT::" + str(payload.get("prompt", ""))})) +elif action == "embed": + payload = request.get("payload") or {} + text = str(payload.get("content", "")) + print(json.dumps({"ok": True, "data": [float(len(text)), 2.5, -1.0]})) +else: + print(json.dumps({"ok": False, "error": "unknown action"})) +"""); + + try + { + var config = BuildAiConfig(scriptPath, timeoutMs: 4000); + IAiService service = new PythonSidecarAiService(config); + + var health = await service.HealthAsync(); + Assert(health.Enabled, "Expected enabled=true for python-sidecar health."); + Assert(health.Healthy, "Expected healthy=true from fake sidecar health."); + + var one = await service.SummarizeEntryAsync("hello"); + Assert(one == "ENTRY::hello", "Unexpected summarize_entry response."); + + var all = await service.SummarizeAllAsync(["a", "b", "c"]); + Assert(all == "ALL::3", "Unexpected summarize_all response."); + + var chat = await service.ChatAsync("hello"); + Assert(chat == "CHAT::hello", "Unexpected chat response."); + + var vector = await service.EmbedAsync("hello"); + Assert(vector.Count == 3, "Unexpected embed vector length."); + Assert(Math.Abs(vector[0] - 5d) < 0.0001d, "Unexpected embed vector first value."); + Assert(Math.Abs(vector[1] - 2.5d) < 0.0001d, "Unexpected embed vector second value."); + Assert(Math.Abs(vector[2] + 1.0d) < 0.0001d, "Unexpected embed vector third value."); + } + finally + { + if (Directory.Exists(root)) + Directory.Delete(root, recursive: true); + } + } + + static async Task TestPythonSidecarAiServiceErrorAsync() + { + var root = Path.Combine(Path.GetTempPath(), "journal-ai-smoke", Guid.NewGuid().ToString("N")); + Directory.CreateDirectory(root); + var scriptPath = Path.Combine(root, "fake_ai_sidecar_error.py"); + File.WriteAllText(scriptPath, """ +import json, sys +_ = json.loads(sys.stdin.readline()) +print(json.dumps({"ok": False, "error": "simulated failure"})) +"""); + + try + { + var config = BuildAiConfig(scriptPath, timeoutMs: 4000); + IAiService service = new PythonSidecarAiService(config); + + try + { + _ = await service.SummarizeEntryAsync("hello"); + } + catch (InvalidOperationException ex) when (ex.Message.Contains("simulated failure", StringComparison.OrdinalIgnoreCase)) + { + return; + } + + throw new InvalidOperationException("Expected summarize_entry to surface sidecar error."); + } + finally + { + if (Directory.Exists(root)) + Directory.Delete(root, recursive: true); + } + } + + static async Task TestPythonSidecarSpeechServiceNoDevicesAsync() + { + var root = Path.Combine(Path.GetTempPath(), "journal-speech-smoke", Guid.NewGuid().ToString("N")); + Directory.CreateDirectory(root); + var scriptPath = Path.Combine(root, "fake_speech_sidecar_nodes.py"); + File.WriteAllText(scriptPath, """ +import json, sys +request = json.loads(sys.stdin.readline()) +action = request.get("action", "") +if action == "speech.devices.list": + print(json.dumps({"ok": True, "data": {"devices": [], "warning": "no devices"}})) +elif action == "speech.transcribe": + payload = request.get("payload") or {} + print(json.dumps({"ok": True, "data": {"text": payload.get("text", ""), "engine": payload.get("engine", "whisper")}})) +else: + print(json.dumps({"ok": False, "error": "unknown action"})) +"""); + + try + { + var config = BuildAiConfig(scriptPath, timeoutMs: 4000); + ISpeechBridgeService service = new PythonSidecarSpeechService(config); + + var devices = await service.ListDevicesAsync(); + Assert(devices.Devices.Count == 0, "Expected empty devices list."); + Assert((devices.Warning ?? "").Contains("no devices", StringComparison.OrdinalIgnoreCase), "Expected no-devices warning."); + + var transcript = await service.TranscribeAsync(new SpeechTranscribeRequestDto(Text: "fixture text", Engine: "whisper")); + Assert(transcript.Text == "fixture text", "Expected passthrough transcript text."); + Assert(transcript.Engine == "whisper", "Expected passthrough transcript engine."); + } + finally + { + if (Directory.Exists(root)) + Directory.Delete(root, recursive: true); + } + } + + static async Task TestPythonSidecarSpeechServiceErrorAsync() + { + var root = Path.Combine(Path.GetTempPath(), "journal-speech-smoke", Guid.NewGuid().ToString("N")); + Directory.CreateDirectory(root); + var scriptPath = Path.Combine(root, "fake_speech_sidecar_error.py"); + File.WriteAllText(scriptPath, """ +import json, sys +request = json.loads(sys.stdin.readline()) +action = request.get("action", "") +if action == "speech.transcribe": + print(json.dumps({"ok": False, "error": "engine unavailable"})) +else: + print(json.dumps({"ok": True, "data": {"devices": []}})) +"""); + + try + { + var config = BuildAiConfig(scriptPath, timeoutMs: 4000); + ISpeechBridgeService service = new PythonSidecarSpeechService(config); + + try + { + _ = await service.TranscribeAsync(new SpeechTranscribeRequestDto(Text: "fixture", Engine: "faster-whisper")); + } + catch (InvalidOperationException ex) when (ex.Message.Contains("engine unavailable", StringComparison.OrdinalIgnoreCase)) + { + return; + } + + throw new InvalidOperationException("Expected speech transcribe to surface sidecar engine error."); + } + finally + { + if (Directory.Exists(root)) + Directory.Delete(root, recursive: true); + } + } + + static async Task TestPythonSidecarSpeechServiceTimeoutAsync() + { + var root = Path.Combine(Path.GetTempPath(), "journal-speech-smoke", Guid.NewGuid().ToString("N")); + Directory.CreateDirectory(root); + var scriptPath = Path.Combine(root, "fake_speech_sidecar_timeout.py"); + File.WriteAllText(scriptPath, """ +import json, sys, time +request = json.loads(sys.stdin.readline()) +payload = request.get("payload") or {} +sleep_ms = int(payload.get("simulate_delay_ms") or 0) +time.sleep(max(0, sleep_ms) / 1000.0) +print(json.dumps({"ok": True, "data": {"text": "", "engine": "whisper"}})) +"""); + + try + { + var config = BuildAiConfig(scriptPath, timeoutMs: 100); + ISpeechBridgeService service = new PythonSidecarSpeechService(config); + + try + { + _ = await service.TranscribeAsync(new SpeechTranscribeRequestDto(Text: "fixture", SimulateDelayMs: 500)); + } + catch (TimeoutException) + { + return; + } + + throw new InvalidOperationException("Expected speech transcribe timeout path."); + } + finally + { + if (Directory.Exists(root)) + Directory.Delete(root, recursive: true); + } + } +} + diff --git a/Journal.SmokeTests/Program.DatabaseConfigTests.cs b/Journal.SmokeTests/Program.DatabaseConfigTests.cs new file mode 100644 index 0000000..2b51b89 --- /dev/null +++ b/Journal.SmokeTests/Program.DatabaseConfigTests.cs @@ -0,0 +1,249 @@ +internal static partial class Program +{ + static Task TestDatabaseKeyDerivationMatchesPythonAsync() + { + var service = NewDatabaseService(); + var keyHex = Convert.ToHexString(service.DeriveDatabaseKey("vault-pass-123")).ToLowerInvariant(); + var expected = "6a9de08e13357aa8f14e7eb0ccde119e7b4d277c60aaaca6493d9a1e1eaa5b04"; + Assert(keyHex == expected, "Database key derivation should match Python PBKDF2 fixture."); + return Task.CompletedTask; + } + + static Task TestDatabaseSchemaParityAsync() + { + var root = Path.Combine(Path.GetTempPath(), "journal-db-smoke", Guid.NewGuid().ToString("N")); + Directory.CreateDirectory(root); + + try + { + var service = NewDatabaseService(); + var schemaPath = service.WriteSchemaBootstrap(root); + var statements = service.GetSchemaStatements(); + var tableNames = new HashSet<string>(statements.Keys, StringComparer.OrdinalIgnoreCase); + + Assert(tableNames.Contains("entries"), "Schema should contain entries table."); + Assert(tableNames.Contains("sections"), "Schema should contain sections table."); + Assert(tableNames.Contains("fragments"), "Schema should contain fragments table."); + Assert(tableNames.Contains("tags"), "Schema should contain tags table."); + Assert(tableNames.Contains("fragment_tags"), "Schema should contain fragment_tags table."); + + Assert(File.Exists(schemaPath), "Schema bootstrap file should be written."); + var fragmentTagsSql = statements["fragment_tags"]; + Assert(fragmentTagsSql.Contains("PRIMARY KEY (fragment_id, tag_id)", StringComparison.OrdinalIgnoreCase), "fragment_tags should enforce composite primary key parity."); + Assert(fragmentTagsSql.Contains("FOREIGN KEY (fragment_id) REFERENCES fragments (id)", StringComparison.OrdinalIgnoreCase), "fragment_tags should contain fragment foreign key parity."); + Assert(fragmentTagsSql.Contains("FOREIGN KEY (tag_id) REFERENCES tags (id)", StringComparison.OrdinalIgnoreCase), "fragment_tags should contain tag foreign key parity."); + } + finally + { + if (Directory.Exists(root)) + Directory.Delete(root, recursive: true); + } + + return Task.CompletedTask; + } + + static async Task TestEntryDatabaseStatusAsync() + { + var root = Path.Combine(Path.GetTempPath(), "journal-db-smoke", Guid.NewGuid().ToString("N")); + Directory.CreateDirectory(root); + + try + { + var entry = NewEntry(); + var request = JsonSerializer.Serialize(new + { + action = "db.status", + payload = new + { + password = "vault-pass-123", + dataDirectory = root + } + }); + + var response = await entry.HandleCommandAsync(request); + using var doc = JsonDocument.Parse(response); + Assert(doc.RootElement.GetProperty("ok").GetBoolean(), "Expected ok=true for db.status."); + var data = doc.RootElement.GetProperty("data"); + Assert(data.TryGetProperty("DatabasePath", out var databasePath), "Expected DatabasePath in db.status payload."); + Assert(databasePath.ValueKind == JsonValueKind.String && !string.IsNullOrWhiteSpace(databasePath.GetString()), "Expected non-empty DatabasePath."); + Assert(data.TryGetProperty("KeyDerivation", out var keyDerivation), "Expected KeyDerivation in db.status payload."); + Assert(string.Equals(keyDerivation.GetString(), "PBKDF2-HMAC-SHA256", StringComparison.Ordinal), "Expected PBKDF2-HMAC-SHA256 key derivation."); + Assert(data.TryGetProperty("SchemaTables", out var schemaTables), "Expected SchemaTables list in db.status payload."); + Assert(schemaTables.ValueKind == JsonValueKind.Array && schemaTables.GetArrayLength() >= 5, "Expected schema table list in db.status payload."); + Assert(data.TryGetProperty("SchemaBootstrapPath", out var schemaBootstrapPath), "Expected SchemaBootstrapPath in db.status payload."); + Assert(schemaBootstrapPath.ValueKind == JsonValueKind.String && File.Exists(schemaBootstrapPath.GetString()), "Expected db.status to emit existing schema bootstrap file path."); + Assert(data.TryGetProperty("RuntimeReady", out var runtimeReady), "Expected RuntimeReady in db.status payload."); + Assert(runtimeReady.ValueKind == JsonValueKind.True, "Expected SQLCipher runtime-ready status in db.status payload."); + } + finally + { + if (Directory.Exists(root)) + Directory.Delete(root, recursive: true); + } + } + + static async Task TestEntryDatabaseInitializeSchemaAsync() + { + var root = Path.Combine(Path.GetTempPath(), "journal-db-smoke", Guid.NewGuid().ToString("N")); + Directory.CreateDirectory(root); + + try + { + var entry = NewEntry(); + var request = JsonSerializer.Serialize(new + { + action = "db.initialize_schema", + payload = new + { + password = "vault-pass-123", + dataDirectory = root + } + }); + + var response = await entry.HandleCommandAsync(request); + using var doc = JsonDocument.Parse(response); + Assert(doc.RootElement.GetProperty("ok").GetBoolean(), "Expected ok=true for db.initialize_schema."); + var data = doc.RootElement.GetProperty("data"); + Assert(data.TryGetProperty("schemaPath", out var schemaPath), "Expected schemaPath in db.initialize_schema response."); + Assert(schemaPath.ValueKind == JsonValueKind.String, "Expected string schemaPath value."); + var resolvedPath = schemaPath.GetString() ?? ""; + Assert(File.Exists(resolvedPath), "db.initialize_schema should write schema bootstrap file."); + var schemaText = File.ReadAllText(resolvedPath); + Assert(schemaText.Contains("CREATE TABLE IF NOT EXISTS entries", StringComparison.OrdinalIgnoreCase), "schema bootstrap should include entries table."); + } + finally + { + if (Directory.Exists(root)) + Directory.Delete(root, recursive: true); + } + } + + static async Task TestEntryDatabaseHydrateWorkspaceAsync() + { + var root = Path.Combine(Path.GetTempPath(), "journal-db-smoke", Guid.NewGuid().ToString("N")); + Directory.CreateDirectory(root); + + try + { + File.WriteAllText(Path.Combine(root, "2026-02-20.md"), "one"); + File.WriteAllText(Path.Combine(root, "2026-02-21.md"), "two"); + + var entry = NewEntry(); + var request = JsonSerializer.Serialize(new + { + action = "db.hydrate_workspace", + payload = new + { + password = "vault-pass-123", + dataDirectory = root + } + }); + + var response = await entry.HandleCommandAsync(request); + using var doc = JsonDocument.Parse(response); + Assert(doc.RootElement.GetProperty("ok").GetBoolean(), "Expected ok=true for db.hydrate_workspace."); + var data = doc.RootElement.GetProperty("data"); + + Assert(data.TryGetProperty("DatabasePath", out var databasePath), "Expected DatabasePath in hydrate payload."); + Assert(databasePath.ValueKind == JsonValueKind.String && !string.IsNullOrWhiteSpace(databasePath.GetString()), "Expected non-empty DatabasePath."); + Assert(data.TryGetProperty("SchemaBootstrapPath", out var schemaPath), "Expected SchemaBootstrapPath in hydrate payload."); + Assert(schemaPath.ValueKind == JsonValueKind.String && File.Exists(schemaPath.GetString()), "Expected hydrate to write schema bootstrap file."); + Assert(data.TryGetProperty("EntryFilesProcessed", out var filesProcessed), "Expected EntryFilesProcessed in hydrate payload."); + Assert(filesProcessed.ValueKind == JsonValueKind.Number && filesProcessed.GetInt32() == 2, "Expected hydrate to count markdown files in workspace."); + Assert(data.TryGetProperty("RuntimeReady", out var runtimeReady), "Expected RuntimeReady in hydrate payload."); + Assert(runtimeReady.ValueKind == JsonValueKind.True, "Expected RuntimeReady=true when SQLCipher runtime hydration succeeds."); + } + finally + { + if (Directory.Exists(root)) + Directory.Delete(root, recursive: true); + } + } + + static Task TestConfigServiceParityKeysAsync() + { + IJournalConfigService config = new JournalConfigService(); + var current = config.Current; + + Assert(!string.IsNullOrWhiteSpace(current.ProjectRoot), "Config ProjectRoot should not be empty."); + Assert(!string.IsNullOrWhiteSpace(current.AppDirectory), "Config AppDirectory should not be empty."); + Assert(!string.IsNullOrWhiteSpace(current.DataDirectory), "Config DataDirectory should not be empty."); + Assert(!string.IsNullOrWhiteSpace(current.VaultDirectory), "Config VaultDirectory should not be empty."); + Assert(current.MonthlyVaultFormat == "%Y-%m.vault", "Config MonthlyVaultFormat should match Python format token."); + + Assert(current.LlamaCppUrl == "http://127.0.0.1:8085/v1/completions", "Config LlamaCppUrl default mismatch."); + Assert(current.LlamaCppModel == "qwen/qwen3-4b", "Config LlamaCppModel default mismatch."); + Assert(current.EmbeddingApiUrl == "http://127.0.0.1:8086/v1/embeddings", "Config EmbeddingApiUrl default mismatch."); + Assert(current.SpeechRecognitionEngine == "whisper", "Config SpeechRecognitionEngine default mismatch."); + Assert(current.WhisperModelSize == "base", "Config WhisperModelSize default mismatch."); + Assert(current.AiProvider == "none", "Config AiProvider default mismatch."); + Assert(current.PythonExecutable == "python", "Config PythonExecutable default mismatch."); + Assert(current.AiSidecarTimeoutMs == 45000, "Config AiSidecarTimeoutMs default mismatch."); + Assert(current.PythonAiSidecarPath.EndsWith(Path.Combine("journal", "ai", "sidecar.py"), StringComparison.OrdinalIgnoreCase), "Config PythonAiSidecarPath default mismatch."); + + return Task.CompletedTask; + } + + static async Task TestEntryConfigGetAsync() + { + var entry = NewEntry(); + var response = await entry.HandleCommandAsync("""{"action":"config.get"}"""); + using var doc = JsonDocument.Parse(response); + + Assert(doc.RootElement.GetProperty("ok").GetBoolean(), "Expected ok=true for config.get."); + var data = doc.RootElement.GetProperty("data"); + Assert(data.ValueKind == JsonValueKind.Object, "Expected object payload for config.get."); + + Assert(data.TryGetProperty("DataDirectory", out var dataDirectory), "Expected DataDirectory in config payload."); + Assert(dataDirectory.ValueKind == JsonValueKind.String && !string.IsNullOrWhiteSpace(dataDirectory.GetString()), "Expected non-empty DataDirectory value."); + Assert(data.TryGetProperty("MonthlyVaultFormat", out var monthlyVaultFormat), "Expected MonthlyVaultFormat in config payload."); + Assert(monthlyVaultFormat.GetString() == "%Y-%m.vault", "Expected Python-compatible MonthlyVaultFormat value."); + Assert(data.TryGetProperty("LlamaCppUrl", out _), "Expected LlamaCppUrl in config payload."); + Assert(data.TryGetProperty("SpeechRecognitionEngine", out _), "Expected SpeechRecognitionEngine in config payload."); + } + + static Task TestLogRedactorScrubsSensitiveFieldsAsync() + { + var payload = JsonSerializer.SerializeToElement(new + { + password = "vault-pass-123", + content = "private journal body", + prompt = "private ai prompt", + nested = new + { + token = "abc123" + } + }); + + var redacted = LogRedactor.RedactPayload(payload); + var serialized = JsonSerializer.Serialize(redacted); + + Assert(!serialized.Contains("vault-pass-123", StringComparison.Ordinal), "Password should be redacted."); + Assert(!serialized.Contains("private journal body", StringComparison.Ordinal), "Entry content should be redacted."); + Assert(!serialized.Contains("private ai prompt", StringComparison.Ordinal), "Prompt should be redacted."); + Assert(!serialized.Contains("abc123", StringComparison.Ordinal), "Nested token should be redacted."); + Assert(serialized.Contains("[REDACTED]", StringComparison.Ordinal), "Redacted marker should be present."); + + return Task.CompletedTask; + } + + static Task TestLogRedactorPreservesNonSensitiveFieldsAsync() + { + var payload = JsonSerializer.SerializeToElement(new + { + action = "entries.save", + mode = "Daily", + filePath = "E:/journal/2026-02-24.md" + }); + + var redacted = LogRedactor.RedactPayload(payload); + var serialized = JsonSerializer.Serialize(redacted); + + Assert(serialized.Contains("entries.save", StringComparison.Ordinal), "Non-sensitive action field should be preserved."); + Assert(serialized.Contains("Daily", StringComparison.Ordinal), "Non-sensitive mode field should be preserved."); + Assert(serialized.Contains("2026-02-24.md", StringComparison.Ordinal), "Non-sensitive path field should be preserved."); + + return Task.CompletedTask; + } +} + diff --git a/Journal.SmokeTests/Program.EntryTests.cs b/Journal.SmokeTests/Program.EntryTests.cs new file mode 100644 index 0000000..ad8da7d --- /dev/null +++ b/Journal.SmokeTests/Program.EntryTests.cs @@ -0,0 +1,657 @@ +internal static partial class Program +{ + static async Task TestEntryUnknownActionAsync() + { + var entry = NewEntry(); + var response = await entry.HandleCommandAsync("""{"action":"unknown.action"}"""); + using var doc = JsonDocument.Parse(response); + + Assert(!doc.RootElement.GetProperty("ok").GetBoolean(), "Expected ok=false."); + Assert(doc.RootElement.GetProperty("error").GetString()!.Contains("Unknown action"), "Expected unknown action error."); + } + + static async Task TestEntryInvalidJsonAsync() + { + var entry = NewEntry(); + var response = await entry.HandleCommandAsync("{\"action\":\"fragments.list\""); + using var doc = JsonDocument.Parse(response); + + Assert(!doc.RootElement.GetProperty("ok").GetBoolean(), "Expected ok=false."); + Assert(doc.RootElement.GetProperty("error").GetString()!.Contains("Invalid command JSON"), "Expected invalid JSON error."); + } + + static async Task TestEntryGetMissingReturnsNullDataAsync() + { + var entry = NewEntry(); + var request = JsonSerializer.Serialize(new + { + action = "fragments.get", + id = Guid.NewGuid().ToString(), + }); + var response = await entry.HandleCommandAsync(request); + using var doc = JsonDocument.Parse(response); + + Assert(doc.RootElement.GetProperty("ok").GetBoolean(), "Expected ok=true."); + Assert(doc.RootElement.GetProperty("data").ValueKind == JsonValueKind.Null, "Expected data=null for missing fragment."); + } + + static async Task TestEntryCreateMissingPayloadAsync() + { + var entry = NewEntry(); + var response = await entry.HandleCommandAsync("""{"action":"fragments.create"}"""); + using var doc = JsonDocument.Parse(response); + + Assert(!doc.RootElement.GetProperty("ok").GetBoolean(), "Expected ok=false."); + Assert(doc.RootElement.GetProperty("error").GetString()!.Contains("payload", StringComparison.OrdinalIgnoreCase), "Expected payload validation error."); + } + + static async Task TestEntryEntriesSaveMergeAsync() + { + var root = Path.Combine(Path.GetTempPath(), "journal-entry-smoke", Guid.NewGuid().ToString("N")); + Directory.CreateDirectory(root); + + try + { + var filePath = Path.Combine(root, "2026-02-22.md"); + File.WriteAllText(filePath, """ +Date: 2026-02-22 +## Summary +old summary text +"""); + + var entry = NewEntry(); + var request = JsonSerializer.Serialize(new + { + action = "entries.save", + payload = new + { + filePath, + mode = "Daily", + content = """ +Date: 2026-02-22 +## Summary +new summary text +## Reflection +new reflection text +""" + } + }); + + var response = await entry.HandleCommandAsync(request); + using var doc = JsonDocument.Parse(response); + Assert(doc.RootElement.GetProperty("ok").GetBoolean(), "Expected ok=true for entries.save."); + + var saved = File.ReadAllText(filePath); + Assert(saved.Contains("new summary text", StringComparison.Ordinal), "Expected merged file to contain new summary text."); + Assert(!saved.Contains("old summary text", StringComparison.Ordinal), "Expected merged file to replace old summary section."); + Assert(saved.Contains("new reflection text", StringComparison.Ordinal), "Expected merged file to contain new reflection section."); + + var fragmentSaveRequest = JsonSerializer.Serialize(new + { + action = "entries.save", + payload = new + { + filePath, + mode = "Fragment", + content = "!NOTE\nfragment append text" + } + }); + + var fragmentResponse = await entry.HandleCommandAsync(fragmentSaveRequest); + using var fragmentDoc = JsonDocument.Parse(fragmentResponse); + Assert(fragmentDoc.RootElement.GetProperty("ok").GetBoolean(), "Expected ok=true for entries.save fragment mode."); + var appended = File.ReadAllText(filePath); + Assert(appended.Contains("fragment append text", StringComparison.Ordinal), "Expected fragment append text in saved file."); + } + finally + { + if (Directory.Exists(root)) + Directory.Delete(root, recursive: true); + } + } + + static async Task TestEntryEntriesLoadAsync() + { + var root = Path.Combine(Path.GetTempPath(), "journal-entry-smoke", Guid.NewGuid().ToString("N")); + Directory.CreateDirectory(root); + + try + { + var filePath = Path.Combine(root, "2026-02-22.md"); + var content = """ +Date: 2026-02-22 +## Summary +hello world +"""; + File.WriteAllText(filePath, content); + + var entry = NewEntry(); + var request = JsonSerializer.Serialize(new + { + action = "entries.load", + payload = new + { + filePath + } + }); + + var response = await entry.HandleCommandAsync(request); + using var doc = JsonDocument.Parse(response); + Assert(doc.RootElement.GetProperty("ok").GetBoolean(), "Expected ok=true for entries.load."); + + var data = doc.RootElement.GetProperty("data"); + var entryDto = data.GetProperty("Entry"); + Assert(entryDto.GetProperty("Date").GetString() == "2026-02-22", "Expected parsed date from entries.load."); + Assert(entryDto.GetProperty("RawContent").GetString() == content, "Expected raw content from entries.load."); + Assert(data.GetProperty("FileName").GetString() == "2026-02-22.md", "Expected file name from entries.load."); + } + finally + { + if (Directory.Exists(root)) + Directory.Delete(root, recursive: true); + } + } + + static async Task TestEntryEntriesListAsync() + { + var root = Path.Combine(Path.GetTempPath(), "journal-entry-smoke", Guid.NewGuid().ToString("N")); + Directory.CreateDirectory(root); + + try + { + File.WriteAllText(Path.Combine(root, "2026-02-03.md"), "c"); + File.WriteAllText(Path.Combine(root, "2026-02-01.md"), "a"); + File.WriteAllText(Path.Combine(root, "ignore.txt"), "x"); + + var entry = NewEntry(); + var request = JsonSerializer.Serialize(new + { + action = "entries.list", + payload = new + { + dataDirectory = root + } + }); + + var response = await entry.HandleCommandAsync(request); + using var doc = JsonDocument.Parse(response); + Assert(doc.RootElement.GetProperty("ok").GetBoolean(), "Expected ok=true for entries.list."); + + var data = doc.RootElement.GetProperty("data"); + Assert(data.ValueKind == JsonValueKind.Array, "Expected entries.list data array."); + Assert(data.GetArrayLength() == 2, "Expected entries.list to return only markdown files."); + Assert(data[0].GetProperty("FileName").GetString() == "2026-02-01.md", "Expected entries.list sort order by file name."); + Assert(data[1].GetProperty("FileName").GetString() == "2026-02-03.md", "Expected entries.list sort order by file name."); + } + finally + { + if (Directory.Exists(root)) + Directory.Delete(root, recursive: true); + } + } + + static async Task TestEntryTemplatesCrudExcludesFromEntriesListAsync() + { + var root = Path.Combine(Path.GetTempPath(), "journal-template-smoke", Guid.NewGuid().ToString("N")); + Directory.CreateDirectory(root); + + try + { + File.WriteAllText(Path.Combine(root, "2026-02-03.md"), "daily entry"); + + var entry = NewEntry(); + var saveRequest = JsonSerializer.Serialize(new + { + action = "templates.save", + payload = new + { + name = "Weekly Review", + content = "# Weekly Review\n\n## Wins\n- one", + dataDirectory = root + } + }); + var saveResponse = await entry.HandleCommandAsync(saveRequest); + using var saveDoc = JsonDocument.Parse(saveResponse); + Assert(saveDoc.RootElement.GetProperty("ok").GetBoolean(), "Expected ok=true for templates.save."); + var templatePath = saveDoc.RootElement.GetProperty("data").GetProperty("FilePath").GetString() ?? ""; + Assert(templatePath.EndsWith(".template.md", StringComparison.OrdinalIgnoreCase), "Template file should end with .template.md."); + Assert(File.Exists(templatePath), "Template file should exist."); + + var listTemplatesRequest = JsonSerializer.Serialize(new + { + action = "templates.list", + payload = new + { + dataDirectory = root + } + }); + var listTemplatesResponse = await entry.HandleCommandAsync(listTemplatesRequest); + using var listTemplatesDoc = JsonDocument.Parse(listTemplatesResponse); + Assert(listTemplatesDoc.RootElement.GetProperty("ok").GetBoolean(), "Expected ok=true for templates.list."); + var templateItems = listTemplatesDoc.RootElement.GetProperty("data"); + Assert(templateItems.GetArrayLength() == 1, "Expected one template in templates.list."); + Assert(templateItems[0].GetProperty("FileName").GetString() == "Weekly Review.template.md", "Template file name mismatch."); + + var listEntriesRequest = JsonSerializer.Serialize(new + { + action = "entries.list", + payload = new + { + dataDirectory = root + } + }); + var listEntriesResponse = await entry.HandleCommandAsync(listEntriesRequest); + using var listEntriesDoc = JsonDocument.Parse(listEntriesResponse); + Assert(listEntriesDoc.RootElement.GetProperty("ok").GetBoolean(), "Expected ok=true for entries.list."); + var entryItems = listEntriesDoc.RootElement.GetProperty("data"); + Assert(entryItems.GetArrayLength() == 1, "Expected entries.list to exclude template files."); + Assert(entryItems[0].GetProperty("FileName").GetString() == "2026-02-03.md", "Expected only daily entry file in entries.list."); + + var loadTemplateRequest = JsonSerializer.Serialize(new + { + action = "templates.load", + payload = new + { + filePath = templatePath + } + }); + var loadTemplateResponse = await entry.HandleCommandAsync(loadTemplateRequest); + using var loadTemplateDoc = JsonDocument.Parse(loadTemplateResponse); + Assert(loadTemplateDoc.RootElement.GetProperty("ok").GetBoolean(), "Expected ok=true for templates.load."); + var content = loadTemplateDoc.RootElement.GetProperty("data").GetProperty("Content").GetString() ?? ""; + Assert(content.Contains("## Wins", StringComparison.Ordinal), "Expected template content in templates.load result."); + + var deleteTemplateRequest = JsonSerializer.Serialize(new + { + action = "templates.delete", + payload = new + { + filePath = templatePath + } + }); + var deleteTemplateResponse = await entry.HandleCommandAsync(deleteTemplateRequest); + using var deleteTemplateDoc = JsonDocument.Parse(deleteTemplateResponse); + Assert(deleteTemplateDoc.RootElement.GetProperty("ok").GetBoolean(), "Expected ok=true for templates.delete."); + Assert(deleteTemplateDoc.RootElement.GetProperty("data").GetBoolean(), "Expected templates.delete to return true."); + Assert(!File.Exists(templatePath), "Template file should be deleted."); + } + finally + { + if (Directory.Exists(root)) + Directory.Delete(root, recursive: true); + } + } + + static async Task TestEntrySearchEntriesMatchesRawContentAsync() + { + var root = Path.Combine(Path.GetTempPath(), "journal-search-smoke", Guid.NewGuid().ToString("N")); + Directory.CreateDirectory(root); + + try + { + File.WriteAllText(Path.Combine(root, "2026-02-01.md"), "## Summary\nAlpha line\ncommon token"); + File.WriteAllText(Path.Combine(root, "2026-02-02.md"), "## Summary\nbeta line\nCOMMON token"); + File.WriteAllText(Path.Combine(root, "2026-02-03.md"), "## Summary\ngamma only"); + + var entry = NewEntry(); + var request = JsonSerializer.Serialize(new + { + action = "search.entries", + payload = new + { + dataDirectory = root, + query = "common token", + } + }); + + var response = await entry.HandleCommandAsync(request); + using var doc = JsonDocument.Parse(response); + + Assert(doc.RootElement.GetProperty("ok").GetBoolean(), "Expected ok=true for search.entries."); + var data = doc.RootElement.GetProperty("data"); + Assert(data.ValueKind == JsonValueKind.Array, "Expected data array from search.entries."); + Assert(data.GetArrayLength() == 2, "Expected two entries matching query across raw content."); + } + finally + { + if (Directory.Exists(root)) + Directory.Delete(root, recursive: true); + } + } + + static async Task TestEntrySearchEntriesWithoutQueryReturnsAllAsync() + { + var root = Path.Combine(Path.GetTempPath(), "journal-search-smoke", Guid.NewGuid().ToString("N")); + Directory.CreateDirectory(root); + + try + { + File.WriteAllText(Path.Combine(root, "2026-02-01.md"), "one"); + File.WriteAllText(Path.Combine(root, "2026-02-02.md"), "two"); + File.WriteAllText(Path.Combine(root, "ignore.txt"), "not markdown"); + + var entry = NewEntry(); + var request = JsonSerializer.Serialize(new + { + action = "search.entries", + payload = new + { + dataDirectory = root, + } + }); + + var response = await entry.HandleCommandAsync(request); + using var doc = JsonDocument.Parse(response); + + Assert(doc.RootElement.GetProperty("ok").GetBoolean(), "Expected ok=true for search.entries without query."); + var data = doc.RootElement.GetProperty("data"); + Assert(data.ValueKind == JsonValueKind.Array, "Expected data array from search.entries."); + Assert(data.GetArrayLength() == 2, "Expected all markdown files to be returned when query is omitted."); + } + finally + { + if (Directory.Exists(root)) + Directory.Delete(root, recursive: true); + } + } + + static async Task TestEntrySearchEntriesDateRangeFilterAsync() + { + var root = Path.Combine(Path.GetTempPath(), "journal-search-smoke", Guid.NewGuid().ToString("N")); + Directory.CreateDirectory(root); + + try + { + WriteSearchFixtureFiles(root); + var entry = NewEntry(); + var request = JsonSerializer.Serialize(new + { + action = "search.entries", + payload = new + { + dataDirectory = root, + startDate = "2026-02-02", + endDate = "2026-02-28", + } + }); + + var response = await entry.HandleCommandAsync(request); + using var doc = JsonDocument.Parse(response); + + Assert(doc.RootElement.GetProperty("ok").GetBoolean(), "Expected ok=true for date-range filtered search."); + var data = doc.RootElement.GetProperty("data"); + Assert(data.GetArrayLength() == 1, "Expected one result for filtered date range."); + Assert(data[0].GetProperty("FileName").GetString() == "2026-02-05.md", "Date-range result mismatch."); + } + finally + { + if (Directory.Exists(root)) + Directory.Delete(root, recursive: true); + } + } + + static async Task TestEntrySearchEntriesSectionFilterAsync() + { + var root = Path.Combine(Path.GetTempPath(), "journal-search-smoke", Guid.NewGuid().ToString("N")); + Directory.CreateDirectory(root); + + try + { + WriteSearchFixtureFiles(root); + var entry = NewEntry(); + var request = JsonSerializer.Serialize(new + { + action = "search.entries", + payload = new + { + dataDirectory = root, + query = "focus area", + section = "Reflection", + } + }); + + var response = await entry.HandleCommandAsync(request); + using var doc = JsonDocument.Parse(response); + + Assert(doc.RootElement.GetProperty("ok").GetBoolean(), "Expected ok=true for section-scoped search."); + var data = doc.RootElement.GetProperty("data"); + Assert(data.GetArrayLength() == 1, "Expected one section-scoped result."); + Assert(data[0].GetProperty("FileName").GetString() == "2026-02-01.md", "Section filter result mismatch."); + } + finally + { + if (Directory.Exists(root)) + Directory.Delete(root, recursive: true); + } + } + + static async Task TestEntrySearchEntriesTagTypeFilterAsync() + { + var root = Path.Combine(Path.GetTempPath(), "journal-search-smoke", Guid.NewGuid().ToString("N")); + Directory.CreateDirectory(root); + + try + { + WriteSearchFixtureFiles(root); + var entry = NewEntry(); + var request = JsonSerializer.Serialize(new + { + action = "search.entries", + payload = new + { + dataDirectory = root, + tags = new[] { "stress" }, + types = new[] { "!TRIGGER" }, + } + }); + + var response = await entry.HandleCommandAsync(request); + using var doc = JsonDocument.Parse(response); + + Assert(doc.RootElement.GetProperty("ok").GetBoolean(), "Expected ok=true for fragment tag/type filtered search."); + var data = doc.RootElement.GetProperty("data"); + Assert(data.GetArrayLength() == 1, "Expected one result for fragment tag/type filters."); + Assert(data[0].GetProperty("FileName").GetString() == "2026-02-01.md", "Tag/type filter result mismatch."); + } + finally + { + if (Directory.Exists(root)) + Directory.Delete(root, recursive: true); + } + } + + static async Task TestEntrySearchEntriesCheckboxFilterAsync() + { + var root = Path.Combine(Path.GetTempPath(), "journal-search-smoke", Guid.NewGuid().ToString("N")); + Directory.CreateDirectory(root); + + try + { + WriteSearchFixtureFiles(root); + var entry = NewEntry(); + var request = JsonSerializer.Serialize(new + { + action = "search.entries", + payload = new + { + dataDirectory = root, + @checked = new[] { "med taken" }, + @unchecked = new[] { "drink water" }, + } + }); + + var response = await entry.HandleCommandAsync(request); + using var doc = JsonDocument.Parse(response); + + Assert(doc.RootElement.GetProperty("ok").GetBoolean(), "Expected ok=true for checkbox filtered search."); + var data = doc.RootElement.GetProperty("data"); + Assert(data.GetArrayLength() == 2, "Expected OR-style checkbox match across checked/unchecked filters."); + } + finally + { + if (Directory.Exists(root)) + Directory.Delete(root, recursive: true); + } + } + + static async Task TestEntrySearchEntriesRejectsInvalidDateAsync() + { + var root = Path.Combine(Path.GetTempPath(), "journal-search-smoke", Guid.NewGuid().ToString("N")); + Directory.CreateDirectory(root); + + try + { + WriteSearchFixtureFiles(root); + var entry = NewEntry(); + var request = JsonSerializer.Serialize(new + { + action = "search.entries", + payload = new + { + dataDirectory = root, + startDate = "2026/02/01", + } + }); + + var response = await entry.HandleCommandAsync(request); + using var doc = JsonDocument.Parse(response); + + Assert(!doc.RootElement.GetProperty("ok").GetBoolean(), "Expected ok=false for invalid date format."); + var error = doc.RootElement.GetProperty("error").GetString() ?? ""; + Assert(error.Contains("invalid startdate value", StringComparison.OrdinalIgnoreCase), "Expected invalid startDate error."); + } + finally + { + if (Directory.Exists(root)) + Directory.Delete(root, recursive: true); + } + } + + static Task TestSidecarSearchCliFilteredAsync() + { + var root = Path.Combine(Path.GetTempPath(), "journal-sidecar-cli-smoke", Guid.NewGuid().ToString("N")); + var dataDir = Path.Combine(root, "data"); + Directory.CreateDirectory(dataDir); + + try + { + WriteSearchFixtureFiles(dataDir); + var cli = new SidecarCli(new VaultStorageService(new VaultCryptoService()), new EntrySearchService(), new JournalConfigService()); + + var (exitCode, stdout, stderr) = CaptureConsole(() => cli.RunSearchCommand( + [ + "common", + "--data-dir", dataDir, + "--start-date", "2026-02-01", + "--end-date", "2026-02-28", + "--tag", "stress", + "--type", "!TRIGGER", + "--checked", "med taken", + "--section", "Summary" + ])); + + Assert(exitCode == 0, "Expected search CLI command to succeed."); + Assert(string.IsNullOrWhiteSpace(stderr), "Expected no stderr output for successful search CLI command."); + Assert(stdout.Contains("--- 2026-02-01 ---", StringComparison.Ordinal), "Expected matching entry header in search CLI output."); + Assert(!stdout.Contains("--- 2026-02-05 ---", StringComparison.Ordinal), "Unexpected non-matching entry in filtered search CLI output."); + } + finally + { + if (Directory.Exists(root)) + Directory.Delete(root, recursive: true); + } + + return Task.CompletedTask; + } + + static Task TestSidecarSearchCliEmptyDataAsync() + { + var root = Path.Combine(Path.GetTempPath(), "journal-sidecar-cli-smoke", Guid.NewGuid().ToString("N")); + var dataDir = Path.Combine(root, "data"); + Directory.CreateDirectory(dataDir); + + try + { + var cli = new SidecarCli(new VaultStorageService(new VaultCryptoService()), new EntrySearchService(), new JournalConfigService()); + var (exitCode, stdout, _) = CaptureConsole(() => cli.RunSearchCommand(["--data-dir", dataDir])); + + Assert(exitCode == 0, "Expected search CLI command to return success for empty data directory."); + Assert(stdout.Contains("No decrypted journal entries found", StringComparison.OrdinalIgnoreCase), "Expected empty-data guidance message."); + } + finally + { + if (Directory.Exists(root)) + Directory.Delete(root, recursive: true); + } + + return Task.CompletedTask; + } + + static Task TestEntrySavePayloadFileNameDeserializationAsync() + { + // Simulate what DeserializePayload does: parse JSON to JsonElement, then Deserialize<T> + var json = """{"content":"hello","mode":"Overwrite","fileName":"My Custom Name"}"""; + var options = new JsonSerializerOptions { PropertyNameCaseInsensitive = true }; + var element = JsonSerializer.Deserialize<JsonElement>(json); + var payload = element.Deserialize<EntrySavePayload>(options); + + Assert(payload is not null, "Payload should not be null."); + Assert(payload!.Content == "hello", "Content should be deserialized."); + Assert(payload.Mode == "Overwrite", "Mode should be deserialized."); + Assert(payload.FileName == "My Custom Name", "FileName should be deserialized from camelCase JSON via JsonElement."); + Assert(payload.FilePath is null, "FilePath should be null when not provided."); + + return Task.CompletedTask; + } + + static async Task TestEntrySaveWithFileNameAsync() + { + var root = Path.Combine(Path.GetTempPath(), "journal-entry-smoke", Guid.NewGuid().ToString("N")); + Directory.CreateDirectory(root); + + try + { + // Use EntryFileService directly to test the full save path with fileName + var service = new EntryFileService(new DiskEntryFileRepository()); + var payload = new EntrySavePayload( + Content: "# Custom Entry\n\nHello world", + FilePath: null, + Mode: "Overwrite", + FileName: "My Custom Name"); + + var result = service.SaveEntry(payload, root); + + var expectedPath = Path.GetFullPath(Path.Combine(root, "My Custom Name.md")); + Assert(result.FilePath == expectedPath, $"Expected path '{expectedPath}' but got '{result.FilePath}'."); + Assert(File.Exists(expectedPath), "Custom-named file should exist on disk."); + Assert(File.ReadAllText(expectedPath).Contains("Hello world"), "File content should match."); + + // Also test via Entry.HandleCommandAsync with JSON to verify full deserialization chain + var entry = NewEntry(); + var request = JsonSerializer.Serialize(new + { + action = "entries.save", + payload = new + { + content = "# Second Entry", + mode = "Overwrite", + fileName = "Another Custom Name" + } + }); + + var response = await entry.HandleCommandAsync(request); + using var doc = JsonDocument.Parse(response); + Assert(doc.RootElement.GetProperty("ok").GetBoolean(), "Expected ok=true for entries.save with fileName."); + + var savedFilePath = doc.RootElement.GetProperty("data").GetProperty("FilePath").GetString() ?? ""; + Assert(savedFilePath.Contains("Another Custom Name.md", StringComparison.OrdinalIgnoreCase), + $"Expected file path to contain 'Another Custom Name.md' but got '{savedFilePath}'."); + } + finally + { + if (Directory.Exists(root)) + Directory.Delete(root, recursive: true); + } + } +} + diff --git a/Journal.SmokeTests/Program.FragmentTests.cs b/Journal.SmokeTests/Program.FragmentTests.cs new file mode 100644 index 0000000..c0e1f08 --- /dev/null +++ b/Journal.SmokeTests/Program.FragmentTests.cs @@ -0,0 +1,232 @@ +internal static partial class Program +{ + static Task TestCreateTrimsAsync() + { + var service = NewService(); + var created = service.Create(new CreateFragmentDto(" !TRIGGER ", " stomach drop ", [" stress ", "", " body "])); + + Assert(created.Type == "!TRIGGER", "Type should be trimmed."); + Assert(created.Description == "stomach drop", "Description should be trimmed."); + Assert(created.Tags.Count == 2, "Expected two normalized tags."); + Assert(created.Tags[0] == "stress" && created.Tags[1] == "body", "Tags should be trimmed and preserved."); + return Task.CompletedTask; + } + + static Task TestUpdateAcceptsTypeAsync() + { + var service = NewService(); + var created = service.Create(new CreateFragmentDto("!TRIGGER", "one")); + var ok = service.Update(created.Id, new UpdateFragmentDto(Type: " !FLASHBACK ", Description: " two ", Tags: [" memory "])); + + Assert(ok, "Expected update to succeed."); + var updated = service.GetById(created.Id); + Assert(updated is not null, "Updated fragment should exist."); + Assert(updated!.Type == "!FLASHBACK", "Updated type should be trimmed and stored."); + Assert(updated.Description == "two", "Updated description should be trimmed and stored."); + Assert(updated.Tags.Count == 1 && updated.Tags[0] == "memory", "Updated tags should be normalized."); + return Task.CompletedTask; + } + + static Task TestUpdateRejectsWhitespaceTypeAsync() + { + var service = NewService(); + var created = service.Create(new CreateFragmentDto("!TRIGGER", "desc")); + + try + { + _ = service.Update(created.Id, new UpdateFragmentDto(Type: " ")); + } + catch (ValidationException) + { + return Task.CompletedTask; + } + + throw new InvalidOperationException("Expected ValidationException for whitespace type update."); + } + + static Task TestFileRepositoryPersistsAsync() + { + var tempRoot = Path.Combine(Path.GetTempPath(), "journal-smoke", Guid.NewGuid().ToString("N")); + var dataDir = Path.Combine(tempRoot, "data"); + Directory.CreateDirectory(dataDir); + const string password = "smoke-test-password"; + + try + { + // Set up encrypted DB session + var configService = new JournalConfigService(); + var dbService = new JournalDatabaseService(configService); + + // First session: create a fragment + using var session1 = new DatabaseSessionService(dbService); + session1.SetPassword(password, dataDir); + var repo1 = new SqliteFragmentRepository(session1); + var service1 = new FragmentService(repo1); + var created = service1.Create(new CreateFragmentDto("!TRIGGER", "persist me", ["tag1"])); + + // Second session: verify persistence + using var session2 = new DatabaseSessionService(dbService); + session2.SetPassword(password, dataDir); + var repo2 = new SqliteFragmentRepository(session2); + var service2 = new FragmentService(repo2); + var loaded = service2.GetById(created.Id); + + Assert(loaded is not null, "Expected fragment to persist across repository instances."); + Assert(loaded!.Description == "persist me", "Persisted fragment description mismatch."); + Assert(loaded.Tags.Count == 1 && loaded.Tags[0] == "tag1", "Persisted tags mismatch."); + } + finally + { + if (Directory.Exists(tempRoot)) + Directory.Delete(tempRoot, recursive: true); + } + + return Task.CompletedTask; + } + + static Task TestJournalEntryModelAsync() + { + var fragment = new Fragment("!TRIGGER", "test fragment"); + var section = new ParsedSection( + "Summary", + content: ["line one", "- [x] completed thing"], + checkboxes: new Dictionary<string, bool> { ["completed thing"] = true }); + + var entry = new JournalEntry( + date: "2026-02-22", + fragments: [fragment], + rawContent: "raw markdown content", + sections: new Dictionary<string, ParsedSection> { ["Summary"] = section }); + + Assert(entry.Date == "2026-02-22", "JournalEntry date mismatch."); + Assert(entry.RawContent == "raw markdown content", "JournalEntry raw content mismatch."); + Assert(entry.Fragments.Count == 1, "JournalEntry fragment count mismatch."); + Assert(entry.Sections.Count == 1, "JournalEntry section count mismatch."); + Assert(entry.GetSection("Summary").Contains("line one"), "JournalEntry section content mismatch."); + Assert(entry.GetCheckboxState("Summary", "completed thing") is true, "JournalEntry checkbox state mismatch."); + Assert(entry.GetCheckboxState("Summary", "missing") is null, "JournalEntry checkbox should return null when missing."); + + return Task.CompletedTask; + } + + static Task TestMergeOverwritesMeaningfulSectionAsync() + { + var current = new JournalEntry( + date: "2026-02-22", + sections: new Dictionary<string, ParsedSection> + { + ["Summary"] = new ParsedSection("Summary", ["old content"]) + }); + + var incoming = new JournalEntry( + date: "2026-02-22", + sections: new Dictionary<string, ParsedSection> + { + ["Summary"] = new ParsedSection( + "Summary", + [" ", "new content line"], + new Dictionary<string, bool> { ["new check"] = true }), + ["Reflection"] = new ParsedSection("Reflection", ["reflective note"]) + }); + + current.MergeWith(incoming); + + Assert(current.GetSection("Summary").Contains("new content line"), "Meaningful section update should overwrite existing section."); + Assert(!current.GetSection("Summary").Contains("old content"), "Old section content should be replaced."); + Assert(current.GetCheckboxState("Summary", "new check") is true, "Overwritten section checkbox state should come from incoming section."); + Assert(current.GetSection("Reflection").Contains("reflective note"), "Meaningful new section should be added."); + + return Task.CompletedTask; + } + + static Task TestMergeIgnoresWhitespaceOnlySectionAsync() + { + var current = new JournalEntry( + date: "2026-02-22", + sections: new Dictionary<string, ParsedSection> + { + ["Summary"] = new ParsedSection("Summary", ["keep existing"]) + }); + + var incoming = new JournalEntry( + date: "2026-02-22", + sections: new Dictionary<string, ParsedSection> + { + ["Summary"] = new ParsedSection("Summary", [" ", "\t", ""]) + }); + + current.MergeWith(incoming); + + Assert(current.GetSection("Summary").Contains("keep existing"), "Whitespace-only section update should be ignored."); + + return Task.CompletedTask; + } + + static Task TestMergeAppendsNonDuplicateFragmentsAsync() + { + var current = new JournalEntry( + date: "2026-02-22", + fragments: + [ + new Fragment("!TRIGGER", "duplicate description") + ]); + + var incoming = new JournalEntry( + date: "2026-02-22", + fragments: + [ + new Fragment("!NOTE", "duplicate description"), + new Fragment("!NOTE", "new description") + ]); + + current.MergeWith(incoming); + + Assert(current.Fragments.Count == 2, "Expected only one new fragment to be appended."); + Assert(current.Fragments.Count(fragment => fragment.Description == "duplicate description") == 1, "Duplicate description should not be appended."); + Assert(current.Fragments.Any(fragment => fragment.Description == "new description"), "New fragment description should be appended."); + + return Task.CompletedTask; + } + + static Task TestToMarkdownCanonicalSectionOrderAsync() + { + var entry = new JournalEntry( + date: "2026-02-22", + sections: new Dictionary<string, ParsedSection> + { + ["Reflection"] = new ParsedSection("Reflection", ["reflection body"]), + ["Summary"] = new ParsedSection("Summary", ["summary body"]) + }); + + var markdown = entry.ToMarkdown(); + var summaryIdx = markdown.IndexOf("## Summary", StringComparison.Ordinal); + var reflectionIdx = markdown.IndexOf("## Reflection", StringComparison.Ordinal); + + Assert(summaryIdx >= 0, "Summary header should be emitted."); + Assert(reflectionIdx >= 0, "Reflection header should be emitted."); + Assert(summaryIdx < reflectionIdx, "Sections should be emitted in canonical order."); + + return Task.CompletedTask; + } + + static Task TestToMarkdownFragmentFormattingAsync() + { + var fragment = new Fragment("!TRIGGER", "fragment body") + { + Time = default, + Tags = ["stress", "body"] + }; + var entry = new JournalEntry( + date: "2026-02-22", + fragments: [fragment]); + + var markdown = entry.ToMarkdown(); + + Assert(markdown.Contains("# Fragments\n", StringComparison.Ordinal), "Fragments header should be present."); + Assert(markdown.Contains("!TRIGGER #stress #body\nfragment body\n", StringComparison.Ordinal), "Fragment block format should match parity shape."); + Assert(markdown.Contains("**Date:** 2026-02-22", StringComparison.Ordinal), "Date frontmatter line should be present."); + + return Task.CompletedTask; + } +} + diff --git a/Journal.SmokeTests/Program.ParserTests.cs b/Journal.SmokeTests/Program.ParserTests.cs new file mode 100644 index 0000000..df34165 --- /dev/null +++ b/Journal.SmokeTests/Program.ParserTests.cs @@ -0,0 +1,153 @@ +internal static partial class Program +{ + static Task TestParserExtractsBoldDateAsync() + { + var content = """ + --- + type: journal + --- + **Date:** 2026-02-22 + ## Summary + hello + """; + + var entry = JournalParser.ParseJournalContent(content, "2026-02-01"); + Assert(entry.Date == "2026-02-22", "Parser should read date from **Date:** marker."); + return Task.CompletedTask; + } + + static Task TestParserExtractsPlainDateAsync() + { + var content = """ + Date: 2026-02-23 + ## Summary + hello + """; + + var entry = JournalParser.ParseJournalContent(content, "2026-02-01"); + Assert(entry.Date == "2026-02-23", "Parser should read date from Date: marker."); + return Task.CompletedTask; + } + + static Task TestParserFallsBackToFileStemAsync() + { + var content = """ + ## Summary + no explicit date + """; + + var entry = JournalParser.ParseJournalContent(content, "2026-02-24"); + Assert(entry.Date == "2026-02-24", "Parser should fall back to file stem when no date marker is present."); + return Task.CompletedTask; + } + + static Task TestParserCapturesSectionsAsync() + { + var content = """ + Date: 2026-02-25 + ## Summary + line one + line two + ### Events / Triggers - Work + trigger line + ## reflection notes + anchor line + """; + + var entry = JournalParser.ParseJournalContent(content, "2026-02-01"); + + Assert(entry.Sections.ContainsKey("Summary"), "Parser should capture Summary section."); + Assert(entry.Sections.ContainsKey("Events / Triggers"), "Parser should capture Events / Triggers section."); + Assert(entry.Sections.ContainsKey("Reflection"), "Parser should match canonical section title by substring."); + Assert(entry.GetSection("Summary").Contains("line one"), "Summary section content mismatch."); + Assert(entry.GetSection("Events / Triggers").Contains("trigger line"), "Events / Triggers section content mismatch."); + Assert(entry.GetSection("Reflection").Contains("anchor line"), "Reflection section content mismatch."); + + return Task.CompletedTask; + } + + static Task TestParserIgnoresNonCanonicalHeadersAsync() + { + var content = """ + ## Summary + keep this + ## Totally Custom Header + should not be captured + ### Events / Triggers + keep this too + """; + + var entry = JournalParser.ParseJournalContent(content, "2026-02-01"); + + Assert(entry.GetSection("Summary").Contains("keep this"), "Summary section should be captured."); + Assert(!entry.GetSection("Summary").Contains("should not be captured"), "Non-canonical section content should not bleed into previous section."); + Assert(entry.GetSection("Events / Triggers").Contains("keep this too"), "Canonical section after custom header should be captured."); + + return Task.CompletedTask; + } + + static Task TestParserCapturesCheckboxStatesAsync() + { + var content = """ + ## Summary + - [x] took medication + - [ ] drank water + * [X] wrote reflection + ## Events / Triggers + - [ ] talked to manager + """; + + var entry = JournalParser.ParseJournalContent(content, "2026-02-01"); + + Assert(entry.GetCheckboxState("Summary", "took medication") is true, "Expected checked state for '- [x]' checkbox."); + Assert(entry.GetCheckboxState("Summary", "drank water") is false, "Expected unchecked state for '- [ ]' checkbox."); + Assert(entry.GetCheckboxState("Summary", "wrote reflection") is true, "Expected checked state for '* [X]' checkbox."); + Assert(entry.GetCheckboxState("Events / Triggers", "talked to manager") is false, "Expected unchecked state in Events / Triggers section."); + Assert(entry.GetCheckboxState("Summary", "missing item") is null, "Missing checkbox text should return null."); + + return Task.CompletedTask; + } + + static Task TestParserCapturesMultilineFragmentsAsync() + { + var content = """ + Date: 2026-02-26 + ## Summary + text + !TRIGGER @2026-02-26T10:15:00Z #stress #body + first line + second line + !NOTE #daily + short note + """; + + var entry = JournalParser.ParseJournalContent(content, "2026-02-01"); + + Assert(entry.Fragments.Count == 2, "Expected two parsed fragments."); + Assert(entry.Fragments[0].Type == "!TRIGGER", "First fragment type mismatch."); + Assert(entry.Fragments[0].Description == "first line\nsecond line", "First fragment multiline description mismatch."); + Assert(entry.Fragments[0].Tags.Count == 2, "First fragment tag count mismatch."); + Assert(entry.Fragments[0].Tags[0] == "stress" && entry.Fragments[0].Tags[1] == "body", "First fragment tags mismatch."); + Assert(entry.Fragments[1].Type == "!NOTE", "Second fragment type mismatch."); + Assert(entry.Fragments[1].Description == "short note", "Second fragment description mismatch."); + Assert(entry.Fragments[1].Tags.Count == 1 && entry.Fragments[1].Tags[0] == "daily", "Second fragment tags mismatch."); + + return Task.CompletedTask; + } + + static Task TestParserFragmentBoundaryBehaviorAsync() + { + var content = """ + !TRIGGER #a + line one + !NOTE this starts another fragment header + line two + """; + + var fragments = JournalParser.ParseFragments(content); + Assert(fragments.Count == 1, "Expected one parsed fragment because second boundary line is not a valid fragment header."); + Assert(fragments[0].Description == "line one", "First fragment boundary capture mismatch."); + return Task.CompletedTask; + } +} + diff --git a/Journal.SmokeTests/Program.Shared.cs b/Journal.SmokeTests/Program.Shared.cs new file mode 100644 index 0000000..21803d9 --- /dev/null +++ b/Journal.SmokeTests/Program.Shared.cs @@ -0,0 +1,169 @@ +internal static partial class Program +{ + static FragmentService NewService() + { + IFragmentRepository repo = new InMemoryFragmentRepository(); + return new FragmentService(repo); + } + + static Entry NewEntry() + { + var dbService = new JournalDatabaseService(new JournalConfigService()); + var session = new DatabaseSessionService(dbService); + return new Entry( + NewService(), + new EntrySearchService(), + new VaultStorageService(new VaultCryptoService()), + dbService, + session, + new JournalConfigService(), + new DisabledAiService("none"), + new DisabledSpeechBridgeService("none"), + new EntryFileService(new DiskEntryFileRepository()), + new ListService(new SqliteListRepository(session)), + new TodoService(new SqliteTodoRepository(session)), + new CommandLogger()); + } + + static IJournalDatabaseService NewDatabaseService() => new JournalDatabaseService(new JournalConfigService()); + + static Dictionary<string, string> ReadVaultEntryTexts(string vaultPath, string password) + { + var crypto = new VaultCryptoService(); + var encrypted = File.ReadAllBytes(vaultPath); + var zipBytes = crypto.DecryptData(encrypted, password); + + using var stream = new MemoryStream(zipBytes); + using var archive = new ZipArchive(stream, ZipArchiveMode.Read); + var result = new Dictionary<string, string>(StringComparer.Ordinal); + foreach (var entry in archive.Entries) + { + if (string.IsNullOrEmpty(entry.Name)) + continue; + + using var reader = new StreamReader(entry.Open()); + result[entry.Name] = reader.ReadToEnd(); + } + + return result; + } + + static byte[] CreateZipBytes(Dictionary<string, string> files) + { + using var stream = new MemoryStream(); + using (var archive = new ZipArchive(stream, ZipArchiveMode.Create, leaveOpen: true)) + { + foreach (var (name, content) in files) + { + var entry = archive.CreateEntry(name); + using var writer = new StreamWriter(entry.Open()); + writer.Write(content); + } + } + return stream.ToArray(); + } + + static void WriteSearchFixtureFiles(string root) + { + File.WriteAllText(Path.Combine(root, "2026-02-01.md"), """ +Date: 2026-02-01 +## Summary +Alpha common +## Reflection +focus area +- [x] med taken +!TRIGGER #stress +fragment one +"""); + + File.WriteAllText(Path.Combine(root, "2026-02-05.md"), """ +Date: 2026-02-05 +## Summary +Beta common +## Reflection +other notes +- [ ] drink water +!NOTE #daily +fragment two +"""); + + File.WriteAllText(Path.Combine(root, "2026-03-01.md"), """ +Date: 2026-03-01 +## Summary +Gamma unique +## Reflection +nothing related +!NOTE #other +fragment three +"""); + } + + static (int ExitCode, string Stdout, string Stderr) CaptureConsole(Func<int> action) + { + var originalOut = Console.Out; + var originalError = Console.Error; + using var stdout = new StringWriter(); + using var stderr = new StringWriter(); + + try + { + Console.SetOut(stdout); + Console.SetError(stderr); + var exitCode = action(); + return (exitCode, stdout.ToString(), stderr.ToString()); + } + finally + { + Console.SetOut(originalOut); + Console.SetError(originalError); + } + } + + static JournalConfig BuildAiConfig(string sidecarScriptPath, int timeoutMs) + { + var baseConfig = new JournalConfigService().Current; + var pythonExe = Environment.GetEnvironmentVariable("JOURNAL_PYTHON_EXE"); + if (string.IsNullOrWhiteSpace(pythonExe)) + pythonExe = "python"; + + return baseConfig with + { + AiProvider = "python-sidecar", + PythonExecutable = pythonExe, + PythonAiSidecarPath = sidecarScriptPath, + AiSidecarTimeoutMs = timeoutMs + }; + } + + static async Task<List<TransportFixture>> LoadTransportFixturesAsync() + { + var path = Path.Combine(AppContext.BaseDirectory, "Fixtures", "transport_cases.json"); + if (!File.Exists(path)) + throw new FileNotFoundException($"Transport fixture file not found: {path}"); + + var json = await File.ReadAllTextAsync(path); + return JsonSerializer.Deserialize<List<TransportFixture>>(json, new JsonSerializerOptions + { + PropertyNameCaseInsensitive = true + }) ?? []; + } + + static JsonValueKind ParseValueKind(string value) => value.Trim().ToLowerInvariant() switch + { + "array" => JsonValueKind.Array, + "object" => JsonValueKind.Object, + "null" => JsonValueKind.Null, + "string" => JsonValueKind.String, + "number" => JsonValueKind.Number, + "true" => JsonValueKind.True, + "false" => JsonValueKind.False, + _ => throw new InvalidOperationException($"Unsupported JsonValueKind '{value}' in transport fixture.") + }; + + static void Assert(bool condition, string message) + { + if (!condition) + throw new InvalidOperationException(message); + } +} + diff --git a/Journal.SmokeTests/Program.TransportTests.cs b/Journal.SmokeTests/Program.TransportTests.cs new file mode 100644 index 0000000..f24d5a7 --- /dev/null +++ b/Journal.SmokeTests/Program.TransportTests.cs @@ -0,0 +1,48 @@ +internal static partial class Program +{ + static async Task TestTransportFixturesAsync() + { + var fixtures = await LoadTransportFixturesAsync(); + Assert(fixtures.Count > 0, "Transport fixtures should not be empty."); + + foreach (var fixture in fixtures) + { + var entry = NewEntry(); + var response = await entry.HandleCommandAsync(fixture.Request); + + Assert(!response.Contains('\n') && !response.Contains('\r'), $"Fixture '{fixture.Name}' returned multiline output."); + + using var doc = JsonDocument.Parse(response); + var ok = doc.RootElement.GetProperty("ok").GetBoolean(); + Assert(ok == fixture.ExpectOk, $"Fixture '{fixture.Name}' expected ok={fixture.ExpectOk} but got ok={ok}."); + + if (fixture.ExpectOk) + { + Assert(doc.RootElement.TryGetProperty("data", out var data), $"Fixture '{fixture.Name}' expected data field."); + if (!string.IsNullOrWhiteSpace(fixture.DataKind)) + { + var expectedKind = ParseValueKind(fixture.DataKind!); + Assert(data.ValueKind == expectedKind, $"Fixture '{fixture.Name}' expected data kind {expectedKind} but got {data.ValueKind}."); + } + continue; + } + + Assert(doc.RootElement.TryGetProperty("error", out var error), $"Fixture '{fixture.Name}' expected error field."); + if (!string.IsNullOrWhiteSpace(fixture.ErrorContains)) + { + var message = error.GetString() ?? ""; + Assert(message.Contains(fixture.ErrorContains!, StringComparison.OrdinalIgnoreCase), $"Fixture '{fixture.Name}' expected error containing '{fixture.ErrorContains}'."); + } + } + } +} + +sealed class TransportFixture +{ + public string Name { get; init; } = ""; + public string Request { get; init; } = ""; + public bool ExpectOk { get; init; } + public string? DataKind { get; init; } + public string? ErrorContains { get; init; } +} + diff --git a/Journal.SmokeTests/Program.VaultTests.cs b/Journal.SmokeTests/Program.VaultTests.cs new file mode 100644 index 0000000..795250a --- /dev/null +++ b/Journal.SmokeTests/Program.VaultTests.cs @@ -0,0 +1,576 @@ +internal static partial class Program +{ + static Task TestVaultCryptoRoundtripAsync() + { + var crypto = new VaultCryptoService(); + var plaintext = "sample vault payload"; + var payload = crypto.EncryptData(System.Text.Encoding.UTF8.GetBytes(plaintext), "vault-pass-123"); + + Assert(payload.Length == VaultCryptoService.SaltSize + VaultCryptoService.NonceSize + VaultCryptoService.TagSize + plaintext.Length, "Vault payload length should match salt+nonce+tag+ciphertext layout."); + var decrypted = crypto.DecryptData(payload, "vault-pass-123"); + Assert(System.Text.Encoding.UTF8.GetString(decrypted) == plaintext, "Vault roundtrip decrypt should return original plaintext."); + + return Task.CompletedTask; + } + + static Task TestVaultCryptoDecryptsPythonFixtureAsync() + { + var crypto = new VaultCryptoService(); + + var payload = Convert.FromBase64String("AAECAwQFBgcICQoLDA0ODwABAgMEBQYHCAkKC6AErhDEMERBl7OFkG4L4oZ2JZckS0VzhxaZoVLckF7VXE+NIYXILsJ8f1I="); + var expectedPlaintext = Convert.FromBase64String("dmF1bHQgcGF5bG9hZCBleGFtcGxlCmxpbmUy"); + var decrypted = crypto.DecryptData(payload, "vault-pass-123"); + + Assert(decrypted.SequenceEqual(expectedPlaintext), "C# decrypt should match Python-generated payload plaintext."); + + return Task.CompletedTask; + } + + static Task TestVaultKeyDerivationMatchesPythonAsync() + { + var crypto = new VaultCryptoService(); + var salt = Enumerable.Range(0, VaultCryptoService.SaltSize).Select(i => (byte)i).ToArray(); + var key = crypto.DeriveKey("vault-pass-123", salt); + var expectedKeyHex = "b29f523f28bf178f6815c6ca9ee2a588d79b3bd9a822c92a2f0dde5bc853bb52"; + var actualKeyHex = Convert.ToHexString(key).ToLowerInvariant(); + + Assert(actualKeyHex == expectedKeyHex, "Derived key should match Python PBKDF2 fixture key."); + + return Task.CompletedTask; + } + + static Task TestVaultMonthlyFilenameParityAsync() + { + IVaultStorageService vaultStorage = new VaultStorageService(new VaultCryptoService()); + var name = vaultStorage.GetMonthlyVaultFileName(new DateTime(2026, 2, 7)); + Assert(name == "2026-02.vault", "Monthly vault filename must match yyyy-MM.vault format."); + return Task.CompletedTask; + } + + static Task TestVaultLoadClearsAndExtractsAsync() + { + var root = Path.Combine(Path.GetTempPath(), "journal-vault-smoke", Guid.NewGuid().ToString("N")); + var vaultDir = Path.Combine(root, "vault"); + var dataDir = Path.Combine(root, "data"); + Directory.CreateDirectory(vaultDir); + Directory.CreateDirectory(dataDir); + + try + { + File.WriteAllText(Path.Combine(dataDir, "old_file.md"), "stale"); + + var zipBytes = CreateZipBytes(new Dictionary<string, string> + { + ["2026-02-01.md"] = "hello from vault" + }); + var crypto = new VaultCryptoService(); + var encrypted = crypto.EncryptData(zipBytes, "vault-pass-123"); + File.WriteAllBytes(Path.Combine(vaultDir, "2026-02.vault"), encrypted); + + IVaultStorageService storage = new VaultStorageService(crypto); + var ok = storage.LoadAllVaults("vault-pass-123", vaultDir, dataDir); + + Assert(ok, "Expected vault load success with correct password."); + Assert(!File.Exists(Path.Combine(dataDir, "old_file.md")), "Data directory should be cleared before extraction."); + var extractedPath = Path.Combine(dataDir, "2026-02-01.md"); + Assert(File.Exists(extractedPath), "Expected markdown file extracted from vault archive."); + Assert(File.ReadAllText(extractedPath) == "hello from vault", "Extracted file content mismatch."); + } + finally + { + if (Directory.Exists(root)) + Directory.Delete(root, recursive: true); + } + + return Task.CompletedTask; + } + + static Task TestVaultLoadWrongPasswordPreservesVaultAsync() + { + var root = Path.Combine(Path.GetTempPath(), "journal-vault-smoke", Guid.NewGuid().ToString("N")); + var vaultDir = Path.Combine(root, "vault"); + var dataDir = Path.Combine(root, "data"); + Directory.CreateDirectory(vaultDir); + Directory.CreateDirectory(dataDir); + + try + { + var zipBytes = CreateZipBytes(new Dictionary<string, string> + { + ["2026-02-01.md"] = "hello from vault" + }); + var crypto = new VaultCryptoService(); + var encrypted = crypto.EncryptData(zipBytes, "vault-pass-123"); + var vaultPath = Path.Combine(vaultDir, "2026-02.vault"); + File.WriteAllBytes(vaultPath, encrypted); + var before = File.ReadAllBytes(vaultPath); + + IVaultStorageService storage = new VaultStorageService(crypto); + var ok = storage.LoadAllVaults("wrong-password", vaultDir, dataDir); + var after = File.ReadAllBytes(vaultPath); + + Assert(!ok, "Expected vault load failure with wrong password."); + Assert(before.SequenceEqual(after), "Vault file bytes should remain unchanged on wrong password."); + } + finally + { + if (Directory.Exists(root)) + Directory.Delete(root, recursive: true); + } + + return Task.CompletedTask; + } + + static Task TestVaultLoadLegacyInitVaultHandlingAsync() + { + var root = Path.Combine(Path.GetTempPath(), "journal-vault-smoke", Guid.NewGuid().ToString("N")); + var vaultDir = Path.Combine(root, "vault"); + var dataDir = Path.Combine(root, "data"); + Directory.CreateDirectory(vaultDir); + Directory.CreateDirectory(dataDir); + + try + { + var legacyPath = Path.Combine(vaultDir, "_init_vault.vault"); + File.WriteAllBytes(legacyPath, [1, 2, 3, 4]); + + IVaultStorageService storage = new VaultStorageService(new VaultCryptoService()); + var ok = storage.LoadAllVaults("vault-pass-123", vaultDir, dataDir); + + Assert(ok, "Legacy-only vault directory should still be treated as successful load state."); + Assert(!File.Exists(legacyPath), "Legacy _init_vault.vault should be removed during load."); + Assert(Directory.Exists(dataDir), "Data directory should exist after load workflow."); + } + finally + { + if (Directory.Exists(root)) + Directory.Delete(root, recursive: true); + } + + return Task.CompletedTask; + } + + static Task TestVaultCurrentMonthSaveOptimizedAsync() + { + var root = Path.Combine(Path.GetTempPath(), "journal-vault-smoke", Guid.NewGuid().ToString("N")); + var vaultDir = Path.Combine(root, "vault"); + var dataDir = Path.Combine(root, "data"); + Directory.CreateDirectory(vaultDir); + Directory.CreateDirectory(dataDir); + + try + { + File.WriteAllText(Path.Combine(dataDir, "2026-02-01.md"), "feb one"); + File.WriteAllText(Path.Combine(dataDir, "2026-02-18.md"), "feb two"); + File.WriteAllText(Path.Combine(dataDir, "2026-01-31.md"), "jan one"); + + IVaultStorageService storage = new VaultStorageService(new VaultCryptoService()); + var now = new DateTime(2026, 2, 22, 12, 0, 0, DateTimeKind.Utc); + + var firstSaved = storage.SaveCurrentMonthVault("vault-pass-123", vaultDir, dataDir, now); + Assert(firstSaved, "Expected first current-month save to write vault data."); + + var febVaultPath = Path.Combine(vaultDir, "2026-02.vault"); + var janVaultPath = Path.Combine(vaultDir, "2026-01.vault"); + Assert(File.Exists(febVaultPath), "Expected current-month vault file to be created."); + Assert(!File.Exists(janVaultPath), "Current-month save should not write non-current month vault files."); + + var entries = ReadVaultEntryTexts(febVaultPath, "vault-pass-123"); + Assert(entries.Count == 2, "Current-month vault should include only current-month markdown files."); + Assert(entries.ContainsKey("2026-02-01.md"), "Missing first current-month entry in vault archive."); + Assert(entries.ContainsKey("2026-02-18.md"), "Missing second current-month entry in vault archive."); + Assert(!entries.ContainsKey("2026-01-31.md"), "Current-month vault must not include previous-month files."); + + var beforeSkipBytes = File.ReadAllBytes(febVaultPath); + var secondSaved = storage.SaveCurrentMonthVault("vault-pass-123", vaultDir, dataDir, now); + var afterSkipBytes = File.ReadAllBytes(febVaultPath); + Assert(!secondSaved, "Expected unchanged current-month save to skip write."); + Assert(beforeSkipBytes.SequenceEqual(afterSkipBytes), "Vault bytes should remain unchanged when save is skipped."); + + File.WriteAllText(Path.Combine(dataDir, "2026-02-18.md"), "feb two changed"); + var thirdSaved = storage.SaveCurrentMonthVault("vault-pass-123", vaultDir, dataDir, now); + Assert(thirdSaved, "Expected save to run after current-month file change."); + } + finally + { + if (Directory.Exists(root)) + Directory.Delete(root, recursive: true); + } + + return Task.CompletedTask; + } + + static Task TestVaultRebuildAllVaultsAsync() + { + var root = Path.Combine(Path.GetTempPath(), "journal-vault-smoke", Guid.NewGuid().ToString("N")); + var vaultDir = Path.Combine(root, "vault"); + var dataDir = Path.Combine(root, "data"); + Directory.CreateDirectory(vaultDir); + Directory.CreateDirectory(dataDir); + + try + { + File.WriteAllText(Path.Combine(dataDir, "2026-01-31.md"), "jan body"); + File.WriteAllText(Path.Combine(dataDir, "2026-02-01.md"), "feb body"); + File.WriteAllText(Path.Combine(dataDir, "not-a-journal.md"), "should be ignored"); + + IVaultStorageService storage = new VaultStorageService(new VaultCryptoService()); + storage.RebuildAllVaults("vault-pass-123", vaultDir, dataDir); + + var janVaultPath = Path.Combine(vaultDir, "2026-01.vault"); + var febVaultPath = Path.Combine(vaultDir, "2026-02.vault"); + Assert(File.Exists(janVaultPath), "Expected January vault from rebuild flow."); + Assert(File.Exists(febVaultPath), "Expected February vault from rebuild flow."); + + var janEntries = ReadVaultEntryTexts(janVaultPath, "vault-pass-123"); + var febEntries = ReadVaultEntryTexts(febVaultPath, "vault-pass-123"); + + Assert(janEntries.Count == 1 && janEntries.ContainsKey("2026-01-31.md"), "January vault contents mismatch."); + Assert(febEntries.Count == 1 && febEntries.ContainsKey("2026-02-01.md"), "February vault contents mismatch."); + } + finally + { + if (Directory.Exists(root)) + Directory.Delete(root, recursive: true); + } + + return Task.CompletedTask; + } + + static Task TestVaultClearDataDirectoryAsync() + { + var root = Path.Combine(Path.GetTempPath(), "journal-vault-smoke", Guid.NewGuid().ToString("N")); + var dataDir = Path.Combine(root, "data"); + Directory.CreateDirectory(dataDir); + Directory.CreateDirectory(Path.Combine(dataDir, "nested")); + + try + { + File.WriteAllText(Path.Combine(dataDir, "2026-02-01.md"), "decrypted content"); + File.WriteAllText(Path.Combine(dataDir, "journal_cache.db"), "cache"); + File.WriteAllText(Path.Combine(dataDir, "nested", "tmp.txt"), "temp"); + + IVaultStorageService storage = new VaultStorageService(new VaultCryptoService()); + storage.ClearDataDirectory(dataDir); + + Assert(Directory.Exists(dataDir), "Data directory should be recreated after cleanup."); + Assert(!Directory.EnumerateFileSystemEntries(dataDir).Any(), "Data directory should be empty after cleanup."); + } + finally + { + if (Directory.Exists(root)) + Directory.Delete(root, recursive: true); + } + + return Task.CompletedTask; + } + + static async Task TestEntryVaultLoadAllEmptyAsync() + { + var root = Path.Combine(Path.GetTempPath(), "journal-sidecar-smoke", Guid.NewGuid().ToString("N")); + var vaultDir = Path.Combine(root, "vault"); + var dataDir = Path.Combine(root, "data"); + Directory.CreateDirectory(vaultDir); + + try + { + var entry = NewEntry(); + var request = JsonSerializer.Serialize(new + { + action = "vault.load_all", + payload = new + { + password = "vault-pass-123", + vaultDirectory = vaultDir, + dataDirectory = dataDir, + } + }); + + var response = await entry.HandleCommandAsync(request); + using var doc = JsonDocument.Parse(response); + + Assert(doc.RootElement.GetProperty("ok").GetBoolean(), "Expected ok=true for empty vault directory load."); + Assert(doc.RootElement.GetProperty("data").GetBoolean(), "Expected vault.load_all data=true for empty vault directory."); + Assert(Directory.Exists(dataDir), "Expected data directory to be created by load workflow."); + } + finally + { + if (Directory.Exists(root)) + Directory.Delete(root, recursive: true); + } + } + + static async Task TestEntryVaultClearDataDirectoryAsync() + { + var root = Path.Combine(Path.GetTempPath(), "journal-sidecar-smoke", Guid.NewGuid().ToString("N")); + var dataDir = Path.Combine(root, "data"); + Directory.CreateDirectory(dataDir); + File.WriteAllText(Path.Combine(dataDir, "tmp.md"), "x"); + + try + { + var entry = NewEntry(); + var request = JsonSerializer.Serialize(new + { + action = "vault.clear_data_directory", + payload = new + { + dataDirectory = dataDir, + } + }); + + var response = await entry.HandleCommandAsync(request); + using var doc = JsonDocument.Parse(response); + + Assert(doc.RootElement.GetProperty("ok").GetBoolean(), "Expected ok=true for clear_data_directory."); + Assert(doc.RootElement.GetProperty("data").GetBoolean(), "Expected clear_data_directory result=true."); + Assert(Directory.Exists(dataDir), "Expected data directory to exist after clear."); + Assert(!Directory.EnumerateFileSystemEntries(dataDir).Any(), "Expected data directory to be empty after clear."); + } + finally + { + if (Directory.Exists(root)) + Directory.Delete(root, recursive: true); + } + } + + static Task TestSidecarVaultCliLoadAsync() + { + var root = Path.Combine(Path.GetTempPath(), "journal-sidecar-cli-smoke", Guid.NewGuid().ToString("N")); + var vaultDir = Path.Combine(root, "vault"); + var dataDir = Path.Combine(root, "data"); + Directory.CreateDirectory(vaultDir); + + try + { + var cli = new SidecarCli(new VaultStorageService(new VaultCryptoService()), new EntrySearchService(), new JournalConfigService()); + var exitCode = cli.RunVaultCommand(["load", "--password", "vault-pass-123", "--vault-dir", vaultDir, "--data-dir", dataDir]); + + Assert(exitCode == 0, "Expected vault load CLI command to succeed on empty vault directory."); + Assert(Directory.Exists(dataDir), "Expected data directory to be created by vault load CLI command."); + } + finally + { + if (Directory.Exists(root)) + Directory.Delete(root, recursive: true); + } + + return Task.CompletedTask; + } + + static Task TestSidecarVaultCliSaveAsync() + { + var root = Path.Combine(Path.GetTempPath(), "journal-sidecar-cli-smoke", Guid.NewGuid().ToString("N")); + var vaultDir = Path.Combine(root, "vault"); + var dataDir = Path.Combine(root, "data"); + Directory.CreateDirectory(vaultDir); + Directory.CreateDirectory(dataDir); + + try + { + File.WriteAllText(Path.Combine(dataDir, "2026-02-22.md"), "entry body"); + + var cli = new SidecarCli(new VaultStorageService(new VaultCryptoService()), new EntrySearchService(), new JournalConfigService()); + var exitCode = cli.RunVaultCommand(["save", "--password", "vault-pass-123", "--vault-dir", vaultDir, "--data-dir", dataDir]); + + Assert(exitCode == 0, "Expected vault save CLI command to succeed."); + Assert(File.Exists(Path.Combine(vaultDir, "2026-02.vault")), "Expected monthly vault file to be written by save CLI command."); + } + finally + { + if (Directory.Exists(root)) + Directory.Delete(root, recursive: true); + } + + return Task.CompletedTask; + } + + static Task TestVaultCustomEntryRoundtripAsync() + { + var root = Path.Combine(Path.GetTempPath(), "journal-vault-smoke", Guid.NewGuid().ToString("N")); + var vaultDir = Path.Combine(root, "vault"); + var dataDir = Path.Combine(root, "data"); + Directory.CreateDirectory(vaultDir); + Directory.CreateDirectory(dataDir); + + try + { + // Create both date-named and custom-named entries + File.WriteAllText(Path.Combine(dataDir, "2026-02-01.md"), "date entry"); + File.WriteAllText(Path.Combine(dataDir, "My Custom Entry.md"), "custom entry body"); + File.WriteAllText(Path.Combine(dataDir, "Work Notes.md"), "work notes body"); + + // Rebuild vaults (simulates app close) + IVaultStorageService storage = new VaultStorageService(new VaultCryptoService()); + storage.RebuildAllVaults("vault-pass-123", vaultDir, dataDir); + + // Verify custom vault was created + var customVaultPath = Path.Combine(vaultDir, "_custom_entries.vault"); + Assert(File.Exists(customVaultPath), "Expected _custom_entries.vault to be created."); + Assert(File.Exists(Path.Combine(vaultDir, "2026-02.vault")), "Expected monthly vault for date entry."); + + // Clear data directory (simulates app close step 2) + storage.ClearDataDirectory(dataDir); + Assert(!Directory.EnumerateFileSystemEntries(dataDir).Any(), "Data directory should be empty after clear."); + + // Load vaults (simulates app restart) + var ok = storage.LoadAllVaults("vault-pass-123", vaultDir, dataDir); + Assert(ok, "Expected vault load to succeed."); + + // Verify all entries are restored + Assert(File.Exists(Path.Combine(dataDir, "2026-02-01.md")), "Date entry should be restored from vault."); + Assert(File.Exists(Path.Combine(dataDir, "My Custom Entry.md")), "Custom entry should be restored from vault."); + Assert(File.Exists(Path.Combine(dataDir, "Work Notes.md")), "Second custom entry should be restored from vault."); + Assert(File.ReadAllText(Path.Combine(dataDir, "My Custom Entry.md")) == "custom entry body", "Custom entry content mismatch."); + Assert(File.ReadAllText(Path.Combine(dataDir, "Work Notes.md")) == "work notes body", "Second custom entry content mismatch."); + } + finally + { + if (Directory.Exists(root)) + Directory.Delete(root, recursive: true); + } + + return Task.CompletedTask; + } + + static async Task TestEntryVaultLoadWrongPasswordKeepsSessionLockedAsync() + { + var root = Path.Combine(Path.GetTempPath(), "journal-vault-smoke", Guid.NewGuid().ToString("N")); + var vaultDir = Path.Combine(root, "vault"); + var dataDir = Path.Combine(root, "data"); + Directory.CreateDirectory(vaultDir); + Directory.CreateDirectory(dataDir); + + try + { + var zipBytes = CreateZipBytes(new Dictionary<string, string> + { + ["2026-02-01.md"] = "hello from vault" + }); + var crypto = new VaultCryptoService(); + var encrypted = crypto.EncryptData(zipBytes, "vault-pass-123"); + File.WriteAllBytes(Path.Combine(vaultDir, "2026-02.vault"), encrypted); + + var entry = NewEntry(); + + var loadRequest = JsonSerializer.Serialize(new + { + action = "vault.load_all", + payload = new + { + password = "wrong-password", + vaultDirectory = vaultDir, + dataDirectory = dataDir + } + }); + var loadResponse = await entry.HandleCommandAsync(loadRequest); + using var loadDoc = JsonDocument.Parse(loadResponse); + Assert(loadDoc.RootElement.GetProperty("ok").GetBoolean(), "Expected vault.load_all response envelope to be ok=true."); + Assert(!loadDoc.RootElement.GetProperty("data").GetBoolean(), "Expected vault.load_all data=false with wrong password."); + + var listRequest = JsonSerializer.Serialize(new + { + action = "lists.list" + }); + var listResponse = await entry.HandleCommandAsync(listRequest); + using var listDoc = JsonDocument.Parse(listResponse); + Assert(!listDoc.RootElement.GetProperty("ok").GetBoolean(), "Expected lists.list to fail while locked."); + var error = listDoc.RootElement.GetProperty("error").GetString() ?? ""; + Assert(error.Contains("database is locked", StringComparison.OrdinalIgnoreCase), "Expected locked-session error after failed vault.load_all."); + } + finally + { + if (Directory.Exists(root)) + Directory.Delete(root, recursive: true); + } + } + + static async Task TestEntryTemplateSaveAutoSyncsVaultAsync() + { + var root = Path.Combine(Path.GetTempPath(), "journal-entry-vault-sync-smoke", Guid.NewGuid().ToString("N")); + var projectRoot = Path.Combine(root, "project"); + var appDirectory = Path.Combine(projectRoot, "journal"); + var vaultDir = Path.Combine(appDirectory, "vault"); + var dataDir = Path.Combine(appDirectory, "data"); + Directory.CreateDirectory(vaultDir); + Directory.CreateDirectory(dataDir); + + var previousProjectRoot = Environment.GetEnvironmentVariable("JOURNAL_PROJECT_ROOT"); + var previousDataDir = Environment.GetEnvironmentVariable("JOURNAL_DATA_DIR"); + var previousVaultDir = Environment.GetEnvironmentVariable("JOURNAL_VAULT_DIR"); + Environment.SetEnvironmentVariable("JOURNAL_PROJECT_ROOT", projectRoot); + Environment.SetEnvironmentVariable("JOURNAL_DATA_DIR", dataDir); + Environment.SetEnvironmentVariable("JOURNAL_VAULT_DIR", vaultDir); + + try + { + var entry = NewEntry(); + var password = "vault-pass-123"; + + var unlockRequest = JsonSerializer.Serialize(new + { + action = "vault.load_all", + payload = new + { + password, + vaultDirectory = vaultDir, + dataDirectory = dataDir + } + }); + var unlockResponse = await entry.HandleCommandAsync(unlockRequest); + using var unlockDoc = JsonDocument.Parse(unlockResponse); + Assert(unlockDoc.RootElement.GetProperty("ok").GetBoolean(), "Expected vault.load_all envelope to succeed."); + Assert(unlockDoc.RootElement.GetProperty("data").GetBoolean(), "Expected vault.load_all data=true for empty vault."); + + var saveTemplateRequest = JsonSerializer.Serialize(new + { + action = "templates.save", + payload = new + { + name = "Weekly Review", + content = "## Wins\n- shipped feature", + dataDirectory = dataDir + } + }); + var saveTemplateResponse = await entry.HandleCommandAsync(saveTemplateRequest); + using var saveTemplateDoc = JsonDocument.Parse(saveTemplateResponse); + Assert(saveTemplateDoc.RootElement.GetProperty("ok").GetBoolean(), "Expected templates.save to succeed."); + + var customVaultPath = Path.Combine(vaultDir, "_custom_entries.vault"); + Assert(File.Exists(customVaultPath), "Expected template save to auto-sync custom entries vault."); + + var entries = ReadVaultEntryTexts(customVaultPath, password); + Assert(entries.ContainsKey("Weekly Review.template.md"), "Expected template file in custom vault archive."); + + var clearRequest = JsonSerializer.Serialize(new + { + action = "vault.clear_data_directory", + payload = new + { + dataDirectory = dataDir + } + }); + var clearResponse = await entry.HandleCommandAsync(clearRequest); + using var clearDoc = JsonDocument.Parse(clearResponse); + Assert(clearDoc.RootElement.GetProperty("ok").GetBoolean(), "Expected vault.clear_data_directory to succeed."); + + var reloadResponse = await entry.HandleCommandAsync(unlockRequest); + using var reloadDoc = JsonDocument.Parse(reloadResponse); + Assert(reloadDoc.RootElement.GetProperty("ok").GetBoolean(), "Expected second vault.load_all envelope to succeed."); + Assert(reloadDoc.RootElement.GetProperty("data").GetBoolean(), "Expected second vault.load_all data=true."); + + var restoredTemplatePath = Path.Combine(dataDir, "Weekly Review.template.md"); + Assert(File.Exists(restoredTemplatePath), "Expected template to be restored from vault after reload."); + } + finally + { + Environment.SetEnvironmentVariable("JOURNAL_PROJECT_ROOT", previousProjectRoot); + Environment.SetEnvironmentVariable("JOURNAL_DATA_DIR", previousDataDir); + Environment.SetEnvironmentVariable("JOURNAL_VAULT_DIR", previousVaultDir); + + if (Directory.Exists(root)) + Directory.Delete(root, recursive: true); + } + } +} + diff --git a/Journal.SmokeTests/Program.cs b/Journal.SmokeTests/Program.cs new file mode 100644 index 0000000..6e99b60 --- /dev/null +++ b/Journal.SmokeTests/Program.cs @@ -0,0 +1,103 @@ +internal static partial class Program +{ + private static async Task<int> Main() + { + var tests = new List<(string Name, Func<Task> Run)> + { + ("CreateAsync trims fields", TestCreateTrimsAsync), + ("UpdateAsync accepts valid type updates", TestUpdateAcceptsTypeAsync), + ("UpdateAsync rejects whitespace type", TestUpdateRejectsWhitespaceTypeAsync), + ("JournalEntry model stores parity fields", TestJournalEntryModelAsync), + ("MergeWith overwrites section when new content is meaningful", TestMergeOverwritesMeaningfulSectionAsync), + ("MergeWith ignores whitespace-only section updates", TestMergeIgnoresWhitespaceOnlySectionAsync), + ("MergeWith appends non-duplicate fragments by description", TestMergeAppendsNonDuplicateFragmentsAsync), + ("ToMarkdown writes canonical section order", TestToMarkdownCanonicalSectionOrderAsync), + ("ToMarkdown writes fragment blocks", TestToMarkdownFragmentFormattingAsync), + ("Vault crypto roundtrip preserves data and layout", TestVaultCryptoRoundtripAsync), + ("Vault crypto decrypts Python payload fixture", TestVaultCryptoDecryptsPythonFixtureAsync), + ("Vault key derivation matches Python fixture", TestVaultKeyDerivationMatchesPythonAsync), + ("Vault monthly filename matches parity format", TestVaultMonthlyFilenameParityAsync), + ("Vault load clears workspace and extracts decrypted files", TestVaultLoadClearsAndExtractsAsync), + ("Vault load wrong password does not modify vault files", TestVaultLoadWrongPasswordPreservesVaultAsync), + ("Vault load ignores and removes legacy _init_vault.vault", TestVaultLoadLegacyInitVaultHandlingAsync), + ("Vault current-month save writes only current month and skips unchanged state", TestVaultCurrentMonthSaveOptimizedAsync), + ("Vault rebuild saves grouped monthly archives from decrypted files", TestVaultRebuildAllVaultsAsync), + ("Vault clear data directory removes decrypted workspace artifacts", TestVaultClearDataDirectoryAsync), + ("Parser extracts date from **Date:** marker", TestParserExtractsBoldDateAsync), + ("Parser extracts date from Date: marker", TestParserExtractsPlainDateAsync), + ("Parser falls back to file stem when date missing", TestParserFallsBackToFileStemAsync), + ("Parser captures canonical sections and content", TestParserCapturesSectionsAsync), + ("Parser ignores non-canonical section headers", TestParserIgnoresNonCanonicalHeadersAsync), + ("Parser captures checkbox states per section", TestParserCapturesCheckboxStatesAsync), + ("Parser captures multiline fragment blocks", TestParserCapturesMultilineFragmentsAsync), + ("Parser fragment boundary follows header lines", TestParserFragmentBoundaryBehaviorAsync), + ("File repository persists fragments", TestFileRepositoryPersistsAsync), + ("Entry invalid JSON returns error envelope", TestEntryInvalidJsonAsync), + ("Entry unknown action returns error envelope", TestEntryUnknownActionAsync), + ("Entry get missing id returns ok with null data", TestEntryGetMissingReturnsNullDataAsync), + ("Entry create without payload returns error envelope", TestEntryCreateMissingPayloadAsync), + ("Entry entries.save writes and merges content", TestEntryEntriesSaveMergeAsync), + ("Entry entries.load returns raw content payload", TestEntryEntriesLoadAsync), + ("Entry entries.list returns markdown files", TestEntryEntriesListAsync), + ("Entry templates CRUD stores .template.md and entries.list excludes templates", TestEntryTemplatesCrudExcludesFromEntriesListAsync), + ("Entry search.entries matches query against full raw content", TestEntrySearchEntriesMatchesRawContentAsync), + ("Entry search.entries without query returns all markdown entries", TestEntrySearchEntriesWithoutQueryReturnsAllAsync), + ("Entry search.entries applies date range filter", TestEntrySearchEntriesDateRangeFilterAsync), + ("Entry search.entries applies section-scoped query filter", TestEntrySearchEntriesSectionFilterAsync), + ("Entry search.entries applies fragment tag and type filters", TestEntrySearchEntriesTagTypeFilterAsync), + ("Entry search.entries applies checkbox checked and unchecked filters", TestEntrySearchEntriesCheckboxFilterAsync), + ("Entry search.entries rejects invalid date filter format", TestEntrySearchEntriesRejectsInvalidDateAsync), + ("Database key derivation matches Python fixture", TestDatabaseKeyDerivationMatchesPythonAsync), + ("Database schema parity tables are created", TestDatabaseSchemaParityAsync), + ("Entry db.status returns database compatibility payload", TestEntryDatabaseStatusAsync), + ("Entry db.initialize_schema creates schema in data directory", TestEntryDatabaseInitializeSchemaAsync), + ("Entry db.hydrate_workspace returns hydration metadata", TestEntryDatabaseHydrateWorkspaceAsync), + ("Config service exposes parity path, vault, AI, and speech settings", TestConfigServiceParityKeysAsync), + ("Entry config.get returns config payload", TestEntryConfigGetAsync), + ("Log redactor scrubs sensitive payload fields", TestLogRedactorScrubsSensitiveFieldsAsync), + ("Log redactor preserves non-sensitive payload fields", TestLogRedactorPreservesNonSensitiveFieldsAsync), + ("Entry ai.health returns disabled by default", TestEntryAiHealthDefaultAsync), + ("Entry ai.summarize_entry succeeds when disabled", TestEntryAiSummarizeEntryDisabledAsync), + ("Entry ai.summarize_all succeeds when disabled", TestEntryAiSummarizeAllDisabledAsync), + ("Entry ai.chat succeeds when disabled", TestEntryAiChatDisabledAsync), + ("Entry ai.embed returns empty vector when disabled", TestEntryAiEmbedDisabledAsync), + ("Entry speech.devices.list returns envelope when disabled", TestEntrySpeechDevicesListDisabledAsync), + ("Entry speech.transcribe returns envelope when disabled", TestEntrySpeechTranscribeDisabledAsync), + ("Python sidecar AI service parses last JSON line", TestPythonSidecarAiServiceJsonLineAsync), + ("Python sidecar AI service surfaces sidecar errors", TestPythonSidecarAiServiceErrorAsync), + ("Python sidecar speech service handles empty devices payload", TestPythonSidecarSpeechServiceNoDevicesAsync), + ("Python sidecar speech service surfaces unavailable engine errors", TestPythonSidecarSpeechServiceErrorAsync), + ("Python sidecar speech service times out deterministically", TestPythonSidecarSpeechServiceTimeoutAsync), + ("Entry vault.load_all succeeds for empty vault directory", TestEntryVaultLoadAllEmptyAsync), + ("Entry vault.load_all wrong password keeps database session locked", TestEntryVaultLoadWrongPasswordKeepsSessionLockedAsync), + ("Entry vault.clear_data_directory removes files", TestEntryVaultClearDataDirectoryAsync), + ("Entry templates.save auto-syncs vault and survives reload", TestEntryTemplateSaveAutoSyncsVaultAsync), + ("Sidecar vault CLI load succeeds with --password", TestSidecarVaultCliLoadAsync), + ("Sidecar vault CLI save writes monthly vault with --password", TestSidecarVaultCliSaveAsync), + ("Sidecar search CLI returns matching entries with filters", TestSidecarSearchCliFilteredAsync), + ("Sidecar search CLI warns when no decrypted entries exist", TestSidecarSearchCliEmptyDataAsync), + ("Transport fixtures produce stable envelopes", TestTransportFixturesAsync), + ("EntrySavePayload deserializes camelCase fileName from JsonElement", TestEntrySavePayloadFileNameDeserializationAsync), + ("entries.save with fileName creates custom-named file", TestEntrySaveWithFileNameAsync), + ("Vault rebuild and load preserves custom-named entries", TestVaultCustomEntryRoundtripAsync), + }; + + var passed = 0; + foreach (var (name, run) in tests) + { + try + { + await run(); + Console.WriteLine($"PASS {name}"); + passed++; + } + catch (Exception ex) + { + Console.WriteLine($"FAIL {name}: {ex.Message}"); + } + } + + Console.WriteLine($"Summary: {passed}/{tests.Count} passed."); + return passed == tests.Count ? 0 : 1; + } +} diff --git a/Journal.WebGateway/Journal.WebGateway.csproj b/Journal.WebGateway/Journal.WebGateway.csproj new file mode 100644 index 0000000..511c2f0 --- /dev/null +++ b/Journal.WebGateway/Journal.WebGateway.csproj @@ -0,0 +1,13 @@ +<Project Sdk="Microsoft.NET.Sdk.Web"> + + <PropertyGroup> + <TargetFramework>net10.0</TargetFramework> + <Nullable>enable</Nullable> + <ImplicitUsings>enable</ImplicitUsings> + </PropertyGroup> + + <ItemGroup> + <ProjectReference Include="..\Journal.Core\Journal.Core.csproj" /> + </ItemGroup> + +</Project> diff --git a/Journal.WebGateway/Program.cs b/Journal.WebGateway/Program.cs new file mode 100644 index 0000000..fca14ce --- /dev/null +++ b/Journal.WebGateway/Program.cs @@ -0,0 +1,262 @@ +using System.Text.Json; +using System.Text.Json.Serialization; +using Journal.Core; +using Microsoft.Extensions.FileProviders; + +var gatewayJsonOptions = new JsonSerializerOptions +{ + PropertyNamingPolicy = JsonNamingPolicy.CamelCase, + PropertyNameCaseInsensitive = true, + DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull +}; + +var repoRoot = ResolveRepoRoot(); +Environment.SetEnvironmentVariable("JOURNAL_PROJECT_ROOT", repoRoot); +var webDistPath = ResolveWebDist(repoRoot); + +var builder = WebApplication.CreateBuilder(args); + +builder.Services.AddFragmentServices(); +builder.Services.AddSingleton<Entry>(); +builder.Services.AddSingleton(new SidecarRootState(repoRoot)); +builder.Services.AddSingleton(new WebUiState(webDistPath)); + +builder.Services.AddCors(options => +{ + options.AddPolicy("GatewayCors", policy => + { + policy.AllowAnyOrigin() + .AllowAnyHeader() + .AllowAnyMethod(); + }); +}); + +builder.Services.ConfigureHttpJsonOptions(options => +{ + options.SerializerOptions.PropertyNamingPolicy = JsonNamingPolicy.CamelCase; + options.SerializerOptions.PropertyNameCaseInsensitive = true; +}); + +var app = builder.Build(); + +app.UseCors("GatewayCors"); + +app.MapGet("/api/health", () => Results.Ok(new +{ + ok = true, + service = "Journal.WebGateway" +})); + +app.MapGet("/api/web/status", (WebUiState webUiState) => Results.Ok(new +{ + distPath = webUiState.DistPath, + exists = webUiState.Exists +})); + +app.MapPost("/api/command", async (CommandEnvelope? command, Entry entry) => +{ + if (command is null || string.IsNullOrWhiteSpace(command.Action)) + { + return Results.Content(ErrorResponse("Missing action"), "application/json"); + } + + var inputJson = JsonSerializer.Serialize(command, gatewayJsonOptions); + var responseJson = await entry.HandleCommandAsync(inputJson); + return Results.Content(responseJson, "application/json"); +}); + +app.MapGet("/api/sidecar/root", (SidecarRootState rootState) => +{ + var (root, isCustom) = rootState.Get(); + return Results.Ok(new + { + root, + isCustom + }); +}); + +app.MapPost("/api/sidecar/root", (SetSidecarRootRequest? request, SidecarRootState rootState) => +{ + var path = request?.Path ?? ""; + if (!string.IsNullOrWhiteSpace(path) && !Directory.Exists(path)) + { + return Results.BadRequest($"Directory '{path}' does not exist."); + } + + rootState.Set(path); + var (root, isCustom) = rootState.Get(); + Environment.SetEnvironmentVariable("JOURNAL_PROJECT_ROOT", root); + return Results.Ok(new + { + root, + isCustom + }); +}); + +if (Directory.Exists(webDistPath) && File.Exists(Path.Combine(webDistPath, "index.html"))) +{ + var fileProvider = new PhysicalFileProvider(webDistPath); + var indexPath = Path.Combine(webDistPath, "index.html"); + + app.UseDefaultFiles(new DefaultFilesOptions + { + FileProvider = fileProvider, + RequestPath = "" + }); + + app.UseStaticFiles(new StaticFileOptions + { + FileProvider = fileProvider, + RequestPath = "" + }); + + app.MapGet("/", async context => + { + context.Response.ContentType = "text/html; charset=utf-8"; + await context.Response.SendFileAsync(indexPath); + }); + + app.MapFallback(async context => + { + if (context.Request.Path.StartsWithSegments("/api")) + { + context.Response.StatusCode = StatusCodes.Status404NotFound; + return; + } + + context.Response.ContentType = "text/html; charset=utf-8"; + await context.Response.SendFileAsync(indexPath); + }); +} +else +{ + app.MapGet("/", () => Results.Ok(new + { + name = "Journal.WebGateway", + status = "ok", + uiAvailable = false, + message = "No built web UI found. Build Journal.App with ./scripts/publish-app.ps1 -Target web.", + expectedDist = webDistPath + })); +} + +app.Run(); + +string ResolveRepoRoot() +{ + var fromEnv = Environment.GetEnvironmentVariable("JOURNAL_PROJECT_ROOT"); + if (!string.IsNullOrWhiteSpace(fromEnv) && Directory.Exists(fromEnv)) + { + return Path.GetFullPath(fromEnv); + } + + foreach (var start in new[] { Directory.GetCurrentDirectory(), AppContext.BaseDirectory }) + { + var resolved = FindRepoRoot(start); + if (resolved is not null) + { + return resolved; + } + } + + return Path.GetFullPath(Directory.GetCurrentDirectory()); +} + +string? FindRepoRoot(string start) +{ + var cursor = Path.GetFullPath(start); + + while (!string.IsNullOrWhiteSpace(cursor)) + { + if (File.Exists(Path.Combine(cursor, "Journal.slnx")) || + Directory.Exists(Path.Combine(cursor, "Journal.Sidecar")) || + Directory.Exists(Path.Combine(cursor, "Journal.Core"))) + { + return cursor; + } + + var parent = Directory.GetParent(cursor); + if (parent is null || string.Equals(parent.FullName, cursor, StringComparison.OrdinalIgnoreCase)) + { + return null; + } + + cursor = parent.FullName; + } + + return null; +} + +string ResolveWebDist(string repoRootPath) +{ + var fromEnv = Environment.GetEnvironmentVariable("JOURNAL_WEB_DIST"); + if (!string.IsNullOrWhiteSpace(fromEnv)) + { + return Path.GetFullPath(fromEnv); + } + + var packagedWwwRoot = Path.Combine(AppContext.BaseDirectory, "wwwroot"); + if (Directory.Exists(packagedWwwRoot)) + { + return packagedWwwRoot; + } + + return Path.Combine(repoRootPath, "Journal.App", "build"); +} + +string ErrorResponse(string message) + => JsonSerializer.Serialize(new { ok = false, error = message }, gatewayJsonOptions); + +sealed class WebUiState(string distPath) +{ + public string DistPath { get; } = distPath; + + public bool Exists => Directory.Exists(DistPath) && File.Exists(Path.Combine(DistPath, "index.html")); +} + +sealed class SidecarRootState(string autoRoot) +{ + private readonly object _sync = new(); + private readonly string _autoRoot = autoRoot; + private string _currentRoot = autoRoot; + private bool _isCustom; + + public (string Root, bool IsCustom) Get() + { + lock (_sync) + { + return (_currentRoot, _isCustom); + } + } + + public void Set(string? path) + { + lock (_sync) + { + if (string.IsNullOrWhiteSpace(path)) + { + _currentRoot = _autoRoot; + _isCustom = false; + return; + } + + _currentRoot = Path.GetFullPath(path.Trim()); + _isCustom = true; + } + } +} + +sealed class SetSidecarRootRequest +{ + public string? Path { get; set; } +} + +sealed class CommandEnvelope +{ + public string Action { get; set; } = ""; + public string? CorrelationId { get; set; } + public string? Id { get; set; } + public string? Type { get; set; } + public string? Tag { get; set; } + public JsonElement? Payload { get; set; } +} diff --git a/Journal.slnx b/Journal.slnx new file mode 100644 index 0000000..090dfed --- /dev/null +++ b/Journal.slnx @@ -0,0 +1,7 @@ +<Solution> + <Project Path="Journal.Core/Journal.Core.csproj" /> + <Project Path="Journal.Sidecar/Journal.Sidecar.csproj" /> + <Project Path="Journal.SmokeTests/Journal.SmokeTests.csproj" /> + <Project Path="Journal.DevTool/Journal.DevTool.csproj" /> + <Project Path="Journal.WebGateway/Journal.WebGateway.csproj" /> +</Solution> diff --git a/README.md b/README.md new file mode 100644 index 0000000..9618106 --- /dev/null +++ b/README.md @@ -0,0 +1,538 @@ +# Project Journal + +A structured journaling system with encrypted monthly vaults, a Tauri desktop app, a web gateway server, CLI tools, and optional AI-assisted analysis. + +## Repository Layout + +``` +journal/ +├── Journal.Core/ .NET class library — all business logic and services +├── Journal.Sidecar/ Console app — stdin/stdout JSON protocol (Tauri sidecar bridge + CLI) +├── Journal.WebGateway/ ASP.NET Core app — HTTP wrapper for browser/web mode +├── Journal.SmokeTests/ Integration tests (~80 tests, no test framework dependency) +├── Journal.App/ SvelteKit + Tauri desktop app +│ ├── src/ SvelteKit frontend source +│ ├── src-tauri/ Rust Tauri shell (sidecar process manager) +│ └── static/ Static assets +├── scripts/ PowerShell dev, build, publish, and cache helpers +├── docs/ Internal design docs +└── journal/ Runtime data directories (vault/, data/) +``` + +## Deployment Modes + +The backend can run in three modes depending on the surface wired to it: + +| Mode | Host | Frontend | +|------|------|----------| +| **Tauri desktop app** | `Journal.App` (Tauri + Rust) | SvelteKit embedded via Tauri WebView | +| **WebGateway server** | `Journal.WebGateway` (ASP.NET Core) | SvelteKit build served from `wwwroot` | +| **Sidecar CLI / stdin** | `Journal.Sidecar` (console) | None — raw JSON protocol | + +All three modes share the same `Journal.Core` service layer and command protocol. + +--- + +## Platform Support + +- **Windows** — first-class (primary development target) +- **Linux** — first-class +- **macOS** — best effort + +### Prerequisites + +- [.NET 10 SDK](https://dotnet.microsoft.com/download) +- [Node.js](https://nodejs.org/) + npm (for `Journal.App` frontend) +- [Rust + Cargo](https://rustup.rs/) (for `Journal.Sidecar` Tauri desktop build) +- PowerShell 7+ (`pwsh`) recommended for scripts + +--- + +## Quickstart + +### Option A — Tauri Desktop App + +Build the sidecar, then the Tauri app: + +```powershell +cd Journal.App +npm install +npm run tauri build +``` + +Or via the publish scripts (recommended for clean environments): + +```powershell +.\scripts\publish-sidecar.ps1 -Configuration Release -Runtime win-x64 +.\scripts\publish-app.ps1 -Target tauri -TauriBundles none +``` + +Tauri auto-detects `Journal.Sidecar.exe` in the repository. On first launch it walks up from the working directory to find `Journal.Sidecar/` and resolves the built executable. + +### Option B — WebGateway Server (browser mode) + +Build the web UI bundle, then publish the gateway with web assets embedded: + +```powershell +.\scripts\publish-app.ps1 -Target web +.\scripts\publish-webgateway.ps1 -Configuration Release -Runtime win-x64 +``` + +Run the gateway: + +```powershell +.\scripts\run-webgateway.ps1 -Urls http://0.0.0.0:5180 +``` + +Open `http://localhost:5180` in your browser. The gateway automatically serves the SvelteKit build and proxies all `/api/command` calls to `Journal.Core`. + +Quick health check: + +```powershell +Invoke-RestMethod http://127.0.0.1:5180/api/health +``` + +### Option C — Sidecar / CLI only + +```powershell +cd Journal.Core +dotnet build + +# Run in stdin/stdout protocol mode +dotnet run --project Journal.Sidecar + +# CLI subcommands +dotnet run --project Journal.Sidecar -- vault load --password <value> +dotnet run --project Journal.Sidecar -- vault save --password <value> +dotnet run --project Journal.Sidecar -- search "your query" --tag stress --start-date 2026-02-01 +``` + +--- + +## C# Backend + +### Projects + +| Project | Type | Purpose | +|---------|------|---------| +| `Journal.Core` | Class library | Domain models, services, repositories, DTOs — all business logic | +| `Journal.Sidecar` | Console app | Stdin/stdout JSON protocol + vault/search CLI subcommands | +| `Journal.WebGateway` | ASP.NET Core | HTTP API wrapper; serves built SvelteKit UI from `wwwroot` | +| `Journal.SmokeTests` | Console app | ~80 integration tests (no xunit/nunit) | + +### Solution File + +``` +Journal.slnx (Visual Studio solution — Core + Sidecar + SmokeTests) +``` + +> `Journal.WebGateway` is not in the solution file; build/run it directly with `dotnet` or the `scripts/` wrappers. + +### Architecture + +``` +Entry (thin command dispatcher — shared by all three hosts) + ├── Fragments/ IFragmentService → FragmentService → SQLiteFragmentRepository (SQLCipher) + ├── Entries/ IEntryFileService → EntryFileService → DiskEntryFileRepository + │ IEntrySearchService → EntrySearchService (raw content + structured filters) + │ JournalParser (date / section / checkbox / fragment parsing) + ├── Lists/ IListService → ListService → SqliteListRepository + ├── Todos/ ITodoService → TodoService → SqliteTodoRepository + ├── Vault/ IVaultStorageService → VaultStorageService → IVaultCryptoService + ├── Database/ IJournalDatabaseService (SQLCipher schema/key derivation/hydration) + │ IDatabaseSessionService (encrypted connection lifecycle after auth) + ├── Ai/ IAiService → PythonSidecarAiService | DisabledAiService + ├── Speech/ ISpeechBridgeService → PythonSidecarSpeechService | DisabledSpeechBridgeService + ├── Sidecar/ PythonSidecarClient (shared Python process I/O), SidecarCli + ├── Logging/ CommandLogger, LogRedactor + └── Config/ IJournalConfigService → JournalConfigService +``` + +Services live under `Journal.Core/Services/` in domain-specific subdirectories, each with its own namespace (e.g. `Journal.Core.Services.Ai`). + +### Build + +```powershell +# Build all projects +dotnet build + +# Or use the resilient wrapper (handles proxy/NuGet quirks): +.\scripts\dotnet-min.ps1 build Journal.Sidecar/Journal.Sidecar.csproj +.\scripts\dotnet-min.ps1 build Journal.WebGateway/Journal.WebGateway.csproj +``` + +### Run Smoke Tests + +```powershell +dotnet run --project Journal.SmokeTests +``` + +### Dependencies + +- `Journal.Core` — `Microsoft.Data.Sqlite.Core`, `SQLitePCLRaw.bundle_e_sqlcipher`, `Microsoft.Extensions.DependencyInjection.Abstractions` +- `Journal.Sidecar` — `Microsoft.Extensions.DependencyInjection` + references `Journal.Core` +- `Journal.WebGateway` — `Microsoft.NET.Sdk.Web` + references `Journal.Core` +- `Journal.SmokeTests` — references `Journal.Core` + +### Encryption + +- **Vault**: AES-256-GCM with PBKDF2-HMAC-SHA256 key derivation (600k iterations) — wire format matches the Python implementation for cross-language parity +- **Database**: SQLCipher with PBKDF2-derived key +- Fragments and structured data are stored in the encrypted SQLCipher database; auth is required via `vault.load_all` or `db.hydrate_workspace` +- `DatabaseSessionService` holds the encryption password in memory after first auth and closes the connection on `vault.clear_data_directory` + +### Environment Variables + +| Variable | Default | Description | +|----------|---------|-------------| +| `JOURNAL_PROJECT_ROOT` | auto-detected | Override project root (vault + data path resolution) | +| `JOURNAL_DATA_DIR` | `<root>/journal/data` | Override decrypted data directory | +| `JOURNAL_VAULT_DIR` | `<root>/journal/vault` | Override vault directory | +| `JOURNAL_AI_PROVIDER` | `none` | `none` or `python-sidecar` | +| `JOURNAL_PYTHON_EXE` | `python` | Python executable for AI/speech sidecar | +| `JOURNAL_AI_SIDECAR_PATH` | auto | Path to Python AI sidecar script | +| `JOURNAL_AI_TIMEOUT_MS` | 30000 | AI sidecar timeout | +| `JOURNAL_NLP_BACKEND` | `auto` | `auto`, `spacy`, or `fallback` | +| `JOURNAL_LOG_LEVEL` | `warning` | `trace`, `debug`, `information`, `warning`, `error`, `critical` | +| `JOURNAL_WEB_DIST` | auto | Override web UI dist path for WebGateway | + +--- + +## Journal.WebGateway + +An ASP.NET Core minimal API that wraps `Journal.Core` for browser use. + +### Endpoints + +| Method | Path | Description | +|--------|------|-------------| +| `GET` | `/api/health` | Health check | +| `POST` | `/api/command` | Send a JSON command to `Entry.HandleCommandAsync` | +| `GET` | `/api/web/status` | Reports web dist path and whether UI is available | +| `GET` | `/api/sidecar/root` | Returns current project root (auto-detected or custom) | +| `POST` | `/api/sidecar/root` | Override project root at runtime | +| `GET` | `/*` | Serves built SvelteKit UI from `wwwroot` (SPA fallback) | + +### Web UI Resolution + +On startup, `Journal.WebGateway` resolves the web dist in this order: + +1. `JOURNAL_WEB_DIST` environment variable +2. `<AppContext.BaseDirectory>/wwwroot` (embedded in published output) +3. `Journal.App/build` (dev fallback — relative to repo root) + +If no dist is found, `/` returns a JSON status message instead of the UI. + +### Running WebGateway + +```powershell +dotnet run --project Journal.WebGateway +# or +.\scripts\run-webgateway.ps1 -Urls http://0.0.0.0:5180 -ProjectRoot E:\path\to\journal +``` + +--- + +## Journal.App (Tauri + SvelteKit) + +A Tauri 2 desktop application with a SvelteKit 5 / TypeScript frontend. + +### Tech Stack + +- **Frontend**: SvelteKit 5, TypeScript, Vite 6 +- **Tauri shell**: Rust (Tauri 2), `tokio` for async process I/O +- **Backend bridge**: `Journal.Sidecar.exe` managed as a long-lived child process + +### Tauri Sidecar Architecture + +The Rust layer (`src-tauri/src/lib.rs`) manages a persistent `Journal.Sidecar.exe` child process: + +- Sidecar is auto-started on first command and restarted if it dies +- Commands are sent as JSON lines to stdin, responses read from stdout +- `JOURNAL_PROJECT_ROOT` is set to the resolved repo root before spawning +- On Windows, the process is created with `CREATE_NO_WINDOW` + +Tauri commands exposed to the frontend: + +| Command | Description | +|---------|-------------| +| `sidecar_command` | Forward a `CommandEnvelope` to `Journal.Sidecar` and return parsed JSON | +| `get_sidecar_root` | Get the current resolved sidecar root path | +| `set_sidecar_root` | Override sidecar root path (saves to `settings.json`, restarts sidecar) | +| `get_ui_settings` | Load tag/fragment-type settings from `settings.json` | +| `set_ui_settings` | Persist tag/fragment-type settings | +| `shutdown` | Stop the sidecar and exit the app | + +Sidecar path resolution order (relative to root): + +1. `Journal.Sidecar.exe` in root +2. `publish/Journal.Sidecar.exe` +3. `Journal.Sidecar/bin/Debug/net10.0/Journal.Sidecar.exe` +4. `Journal.Sidecar/bin/Release/net10.0/win-x64/publish/Journal.Sidecar.exe` +5. Recursive scan of `Journal.Sidecar/` + +### Frontend State + +The frontend uses Svelte stores as the source of truth: + +| Store | State | Purpose | +|-------|-------|---------| +| `entries.ts` | `entriesStore` | Journal entry list and drafts | +| `fragments.ts` | `fragmentsStore` | Fragment CRUD + parse/serialize helpers | +| `todos.ts` | `todoListsStore`, `todosStore` | Todo lists and items | +| `lists.ts` | `listsStore` | Generic lists | +| `settings.ts` | `settingsTags`, `settingsFragmentTypes` | Tag/type configuration | + +**Store-First Rule**: components call store helpers for CRUD; they do not embed mutation or parsing logic directly. + +### Dev Setup + +```powershell +cd Journal.App +npm install +npm run dev # SvelteKit dev server at http://localhost:1420 +npm run tauri dev # Tauri dev mode (opens desktop window) +``` + +### Publishing + +```powershell +# Web bundle only (for WebGateway) +.\scripts\publish-app.ps1 -Target web +# Output: Journal.App/build/ + +# Tauri raw exe (no installer) +.\scripts\publish-app.ps1 -Target tauri -TauriBundles none +# Output: Journal.App/src-tauri/target/release/journalapp.exe + +# Tauri with NSIS installer +.\scripts\publish-app.ps1 -Target tauri -TauriBundles nsis +``` + +--- + +## Sidecar Protocol + +`Journal.Sidecar` communicates over **stdin/stdout** using newline-delimited JSON. One JSON object in, one JSON object out. + +### Command Format + +```json +{ + "action": "fragments.create", + "correlationId": null, + "id": null, + "type": null, + "tag": null, + "payload": { "type": "!TRIGGER", "description": "stomach drop" } +} +``` + +**Fields:** +- `action` — Operation to perform (e.g. `fragments.list`, `vault.load_all`) +- `correlationId` — Optional tracing ID (auto-generated if omitted) +- `id` — Target entity ID (for get/update/delete) +- `type` / `tag` — Filter parameters (for fragment search) +- `payload` — Request body, deserialized per action + +### Response Format + +Success: +```json +{ "ok": true, "data": { "id": "abc-123", "type": "!TRIGGER", "description": "...", "time": "...", "tags": [] } } +``` + +Error: +```json +{ "ok": false, "error": "Description is required" } +``` + +### Available Actions + +| Action | Description | Key Requirements | +|--------|-------------|------------------| +| `fragments.list` | List all fragments | — | +| `fragments.get` | Get by ID | `id` | +| `fragments.create` | Create fragment | `payload` (CreateFragmentDto) | +| `fragments.update` | Update fragment | `id`, `payload` (UpdateFragmentDto) | +| `fragments.delete` | Delete fragment | `id` | +| `fragments.search` | Filter by type/tag | `type` and/or `tag` | +| `lists.list` | List all lists | — | +| `lists.get` | Get list by ID | `id` | +| `lists.create` | Create list | `payload` | +| `lists.update` | Update list | `id`, `payload` | +| `lists.delete` | Delete list | `id` | +| `todos.list` | List all todo lists | — | +| `todos.get` | Get todo list by ID | `id` | +| `todos.create` | Create todo list | `payload` | +| `todos.update` | Update todo list | `id`, `payload` | +| `todos.delete` | Delete todo list | `id` | +| `todos.items.create` | Add todo item | `payload` | +| `todos.items.update` | Update todo item | `id`, `payload` | +| `todos.items.delete` | Delete todo item | `id` | +| `entries.list` | List decrypted `.md` entries | optional `payload.dataDirectory` | +| `entries.load` | Load one entry file | `payload.filePath` | +| `entries.save` | Save/merge entry content | `payload.content`, optional `payload.filePath`, `payload.mode`, `payload.fileName` | +| `entries.delete` | Delete an entry file | `payload.filePath` | +| `templates.list` | List `.template.md` files | optional `payload.dataDirectory` | +| `templates.load` | Load a template | `payload.filePath` | +| `templates.save` | Save/create a template | `payload.name` | +| `templates.delete` | Delete a template | `payload.filePath` | +| `search.entries` | Search entries with filters | `payload.dataDirectory`, optional query/section/date/tags/types/checked/unchecked | +| `vault.initialize` | Ensure vault directory exists | `payload.password`, `payload.vaultDirectory` | +| `vault.load_all` | Decrypt all monthly vaults → data dir | `payload.password`, `payload.vaultDirectory`, `payload.dataDirectory` | +| `vault.save_current_month` | Encrypt only current month (optimized) | `payload.password`, `payload.vaultDirectory`, `payload.dataDirectory` | +| `vault.rebuild_all` | Rebuild all monthly vaults from data | `payload.password`, `payload.vaultDirectory`, `payload.dataDirectory` | +| `vault.clear_data_directory` | Wipe decrypted data directory | `payload.dataDirectory` | +| `db.status` | DB key/schema compatibility snapshot | `payload.password`, optional `payload.dataDirectory` | +| `db.initialize_schema` | Write SQL schema bootstrap file | optional `payload.dataDirectory` | +| `db.hydrate_workspace` | Bootstrap DB + set session password | `payload.password`, optional `payload.dataDirectory` | +| `config.get` | Return current config snapshot | — | +| `ai.health` | AI provider health status | — | +| `ai.summarize_entry` | Summarize one entry | `payload.content`, optional `payload.fileStem` | +| `ai.summarize_all` | Summarize multiple entries | `payload.entries[]` | +| `ai.chat` | Chat via AI provider bridge | `payload.prompt` | +| `ai.embed` | Generate embedding vector | `payload.content` | +| `speech.devices.list` | List audio input devices | — | +| `speech.transcribe` | Transcribe audio (base64) or text | `payload.audioBase64` or `payload.text` | + +### Sidecar CLI Mode + +In addition to stdin/stdout protocol, `Journal.Sidecar` supports direct CLI subcommands: + +```powershell +# Load/decrypt all vaults into data workspace +dotnet run --project Journal.Sidecar -- vault load + +# Save (rebuild) monthly vaults from decrypted markdown files +dotnet run --project Journal.Sidecar -- vault save + +# Search entries (query + filters) +dotnet run --project Journal.Sidecar -- search "common text" --tag stress --type !TRIGGER --start-date 2026-02-01 --end-date 2026-02-28 --section Summary --checked "med taken" +``` + +**Password behavior:** +- Omit `--password` → prompts securely in terminal +- Pass `--password <value>` → non-interactive/automation mode + +**Optional path overrides:** +- `--vault-dir <path>` / `--data-dir <path>` +- Env fallback: `JOURNAL_VAULT_DIR`, `JOURNAL_DATA_DIR`, `JOURNAL_APP_DIR` + +**Search CLI flags:** +- positional `query` (optional) +- `--tag` / `-t` (repeatable) +- `--type` / `-y` (repeatable) +- `--start-date` / `-s` (`yyyy-MM-dd`) +- `--end-date` / `-e` (`yyyy-MM-dd`) +- `--section` / `-sec` +- `--checked` / `-chk` (repeatable) +- `--unchecked` / `-uchk` (repeatable) +- `--data-dir <path>` (optional override) + +--- + +## Publishing + +### Sidecar (self-contained executable) + +```powershell +.\scripts\publish-sidecar.ps1 -Configuration Release -Runtime win-x64 +# Output: output\Journal.Sidecar.exe (~70MB, all bundled) +``` + +Or raw `dotnet publish`: + +```powershell +dotnet publish Journal.Sidecar/Journal.Sidecar.csproj -c Release -r win-x64 --self-contained -p:PublishSingleFile=true -p:IncludeNativeLibrariesForSelfExtract=true +``` + +To exclude debug symbols: add `-p:DebugType=none` + +For a smaller build that requires .NET 10 on the target machine: + +```powershell +dotnet publish Journal.Sidecar/Journal.Sidecar.csproj -c Release -r win-x64 -p:PublishSingleFile=true +``` + +### WebGateway (with embedded web UI) + +```powershell +# Step 1: build web assets +.\scripts\publish-app.ps1 -Target web + +# Step 2: publish gateway (copies web assets into wwwroot automatically) +.\scripts\publish-webgateway.ps1 -Configuration Release -Runtime win-x64 +# Output: output\webgateway\ (with output\webgateway\wwwroot\ from Journal.App\build) +``` + +--- + +## DI Registration + +`ServiceCollectionExtensions.AddFragmentServices()` wires everything. Any host calls: + +```csharp +services.AddFragmentServices(); +services.AddSingleton<Entry>(); +``` + +Key registrations: +- `IDatabaseSessionService` → `DatabaseSessionService` (singleton) +- `IFragmentRepository` → `SqliteFragmentRepository` (singleton, SQLCipher-backed) +- `IFragmentService` → `FragmentService` (singleton) +- `IEntryFileRepository` → `DiskEntryFileRepository` (singleton) +- `IEntryFileService` → `EntryFileService` (singleton) +- `IListRepository` → `SqliteListRepository` (singleton) +- `IListService` → `ListService` (singleton) +- `ITodoRepository` → `SqliteTodoRepository` (singleton) +- `ITodoService` → `TodoService` (singleton) +- `IVaultCryptoService` → `VaultCryptoService` (singleton) +- `IVaultStorageService` → `VaultStorageService` (singleton) +- `IJournalDatabaseService` → `JournalDatabaseService` (singleton) +- `IAiService` → `PythonSidecarAiService` or `DisabledAiService` (per `JOURNAL_AI_PROVIDER`) +- `ISpeechBridgeService` → `PythonSidecarSpeechService` or `DisabledSpeechBridgeService` +- `IJournalConfigService` → `JournalConfigService` (singleton) +- `CommandLogger` (singleton) +- `SidecarCli` (singleton) + +--- + +## Extending with New Modules + +The `Command`/`Entry` pattern uses dot-notation actions. To add a module: + +1. Create model, DTO, repository, and service in `Journal.Core/Services/<Domain>/` +2. Register services in `ServiceCollectionExtensions.cs` +3. Inject the service into `Entry.cs` and add cases to the `switch` +4. No changes needed to `App.cs`, `Journal.WebGateway/Program.cs`, or the Tauri Rust shell + +--- + +## Scripts + +See [`scripts/README.md`](scripts/README.md) for the full reference and [`scripts/WORKFLOWS.md`](scripts/WORKFLOWS.md) for copy-paste command recipes. + +Quick reference: + +| Script | Purpose | +|--------|---------| +| `dev-shell.ps1` | Dot-source to configure current shell with repo-local env vars | +| `dotnet-min.ps1` | `dotnet` wrapper with resilient NuGet defaults | +| `pip-min.ps1` | `pip` wrapper with repo-local cache and Windows compat mapping | +| `publish-app.ps1` | Build web bundle or Tauri desktop app | +| `publish-sidecar.ps1` | Publish `Journal.Sidecar` single-file exe to `output/` | +| `publish-webgateway.ps1` | Publish `Journal.WebGateway` with optional web assets | +| `run-webgateway.ps1` | Run `Journal.WebGateway` with controlled env and project root | +| `migration-gate.ps1` | End-to-end build + smoke + parity + API check gate | +| `nuget-export-cache.ps1` | Export NuGet cache to zip for offline/transfer use | +| `nuget-import-cache.ps1` | Import NuGet cache zip and validate restore | + +--- + +## Notes + +- Decrypted journal data in `journal/data/` is cleared on graceful shutdown (`vault.clear_data_directory`). +- The legacy Python placeholder file `_init_vault.vault` is treated as obsolete — the C# backend ignores and removes it during vault load. +- `Journal.WebGateway` is intentionally excluded from `Journal.slnx`; it is built/run independently via `dotnet` or the scripts wrappers. +- On Windows + Tauri, the sidecar process is spawned with `CREATE_NO_WINDOW` to suppress the console window. diff --git a/devtool.json b/devtool.json new file mode 100644 index 0000000..ff9e98b --- /dev/null +++ b/devtool.json @@ -0,0 +1,335 @@ +{ + "name": "Project Journal", + "version": "0.1.0", + "toolchains": { + "python": { + "executable": "python3.14", + "windowsExecutable": "py", + "launcherVersion": "-3.14", + "venvDir": ".venv", + "pipScript": "scripts/pip-min.ps1", + "profiles": [ + { + "id": "cpu", + "label": "CPU only (default)", + "requirementsFile": "requirements_cpu_only.txt", + "extraIndexUrl": "https://download.pytorch.org/whl/cpu" + }, + { + "id": "gpu", + "label": "GPU / CUDA", + "requirementsFile": "requirements_gpu.txt" + }, + { + "id": "nlp", + "label": "NLP / spaCy (optional)", + "requirementsFile": "requirements_nlp_optional.txt", + "postInstallCommands": [ + "spacy download en_core_web_sm" + ] + } + ] + }, + "node": { + "packageManager": "npm", + "workingDir": "Journal.App" + } + }, + "targets": [ + { + "id": "sidecar", + "label": "Publish Sidecar", + "description": "Build Journal.Sidecar as self-contained exe → output/", + "group": "Build", + "command": "pwsh", + "args": [ + "-NoProfile", + "-ExecutionPolicy", + "Bypass", + "-File", + "scripts/publish-sidecar.ps1", + "-Configuration", + "Release", + "-Runtime", + "win-x64" + ], + "workingDir": ".", + "dependsOn": [] + }, + { + "id": "web", + "label": "Build Web UI", + "description": "Build SvelteKit bundle → Journal.App/build/", + "group": "Build", + "command": "pwsh", + "args": [ + "-NoProfile", + "-ExecutionPolicy", + "Bypass", + "-File", + "scripts/publish-app.ps1", + "-Target", + "web" + ], + "workingDir": ".", + "dependsOn": [] + }, + { + "id": "webgateway", + "label": "Publish WebGateway", + "description": "Publish ASP.NET host with embedded web UI → output/webgateway/", + "group": "Build", + "command": "pwsh", + "args": [ + "-NoProfile", + "-ExecutionPolicy", + "Bypass", + "-File", + "scripts/publish-webgateway.ps1", + "-Configuration", + "Release", + "-Runtime", + "win-x64" + ], + "workingDir": ".", + "dependsOn": [ + "web" + ] + }, + { + "id": "tauri", + "label": "Build Tauri Desktop App", + "description": "Build desktop exe (no installer) → Journal.App/src-tauri/target/release/", + "group": "Build", + "command": "pwsh", + "args": [ + "-NoProfile", + "-ExecutionPolicy", + "Bypass", + "-File", + "scripts/publish-app.ps1", + "-Target", + "tauri", + "-TauriBundles", + "none" + ], + "workingDir": ".", + "dependsOn": [ + "sidecar" + ] + }, + { + "id": "tauri-nsis", + "label": "Build Tauri + NSIS Installer", + "description": "Build desktop exe with NSIS installer package", + "group": "Build", + "command": "pwsh", + "args": [ + "-NoProfile", + "-ExecutionPolicy", + "Bypass", + "-File", + "scripts/publish-app.ps1", + "-Target", + "tauri", + "-TauriBundles", + "nsis" + ], + "workingDir": ".", + "dependsOn": [ + "sidecar" + ] + }, + { + "id": "build-dotnet", + "label": "Build .NET Projects", + "description": "dotnet build — all C# projects in solution", + "group": "Build", + "command": "dotnet", + "args": [ + "build" + ], + "workingDir": ".", + "dependsOn": [] + }, + { + "id": "all", + "label": "Full Release Build ✦", + "description": "Sidecar → Web → WebGateway → Tauri, in dependency order", + "group": "Build", + "command": null, + "args": [], + "workingDir": ".", + "dependsOn": [ + "sidecar", + "web", + "webgateway", + "tauri" + ] + }, + { + "id": "run-gateway", + "label": "Run WebGateway", + "description": "Start HTTP gateway dev server at http://localhost:5180", + "group": "Dev", + "command": "pwsh", + "args": [ + "-NoProfile", + "-ExecutionPolicy", + "Bypass", + "-File", + "scripts/run-webgateway.ps1" + ], + "workingDir": ".", + "dependsOn": [] + }, + { + "id": "test", + "label": "Run Smoke Tests", + "description": "Run all ~80 integration tests in Journal.SmokeTests", + "group": "Test", + "command": "dotnet", + "args": [ + "run", + "--project", + "Journal.SmokeTests/Journal.SmokeTests.csproj" + ], + "workingDir": ".", + "dependsOn": [] + }, + { + "id": "gate", + "label": "Run Migration Gate", + "description": "Full build + smoke tests + parity check", + "group": "Test", + "command": "pwsh", + "args": [ + "-NoProfile", + "-ExecutionPolicy", + "Bypass", + "-File", + "scripts/migration-gate.ps1" + ], + "workingDir": ".", + "dependsOn": [] + }, + { + "id": "nuget-export", + "label": "Export NuGet Cache", + "description": "Prime and export .nuget cache to zip for offline use", + "group": "Cache", + "command": "pwsh", + "args": [ + "-NoProfile", + "-ExecutionPolicy", + "Bypass", + "-File", + "scripts/nuget-export-cache.ps1" + ], + "workingDir": ".", + "dependsOn": [] + }, + { + "id": "nuget-import", + "label": "Import NuGet Cache", + "description": "Import cache zip and validate restore", + "group": "Cache", + "command": "pwsh", + "args": [ + "-NoProfile", + "-ExecutionPolicy", + "Bypass", + "-File", + "scripts/nuget-import-cache.ps1" + ], + "workingDir": ".", + "dependsOn": [] + } + , + { + "id": "npm-clean", + "label": "Clean Node Modules", + "description": "Remove Journal.App node_modules (kills node/tauri first)", + "group": "System", + "command": "pwsh", + "args": [ + "-NoProfile", + "-ExecutionPolicy", + "Bypass", + "-File", + "scripts/npm-clean.ps1" + ], + "workingDir": ".", + "dependsOn": [] + } + , + { + "id": "stage-output", + "label": "Stage Output Bundle", + "description": "Publish sidecar + web + webgateway + tauri, then stage journalapp.exe into output/", + "group": "Build", + "command": "pwsh", + "args": [ + "-NoProfile", + "-ExecutionPolicy", + "Bypass", + "-File", + "scripts/publish-output.ps1" + ], + "workingDir": ".", + "dependsOn": [] + } + ], + "env": [ + { + "key": "JOURNAL_AI_PROVIDER", + "description": "AI provider bridge mode", + "default": "none", + "options": [ + "none", + "python-sidecar" + ] + }, + { + "key": "JOURNAL_LOG_LEVEL", + "description": "Log verbosity for C# backend", + "default": "warning", + "options": [ + "trace", + "debug", + "information", + "warning", + "error", + "critical" + ] + }, + { + "key": "JOURNAL_NLP_BACKEND", + "description": "Python NLP backend selection", + "default": "auto", + "options": [ + "auto", + "spacy", + "fallback" + ] + }, + { + "key": "JOURNAL_PROJECT_ROOT", + "description": "Override project root path (blank = auto-detect)", + "default": "", + "options": [] + }, + { + "key": "JOURNAL_VAULT_DIR", + "description": "Override vault directory path", + "default": "", + "options": [] + }, + { + "key": "JOURNAL_DATA_DIR", + "description": "Override decrypted data directory path", + "default": "", + "options": [] + } + ] +} diff --git a/docs/frontend-csharp-backend-wiring.md b/docs/frontend-csharp-backend-wiring.md new file mode 100644 index 0000000..2dd6cce --- /dev/null +++ b/docs/frontend-csharp-backend-wiring.md @@ -0,0 +1,218 @@ +# Wiring Frontend to the C# Backend + +This document explains how to connect the `Journal.App` frontend to the C# backend in this repository. + +## Current Backend Reality + +In this repo today, the C# backend projects in `Journal.slnx` are: + +- `Journal.Core` +- `Journal.Sidecar` +- `Journal.SmokeTests` + +There is currently **no** `Journal.Api` project in the solution file, so the primary integration path is: + +- Frontend (Svelte/Tauri) -> Tauri bridge -> `Journal.Sidecar` (stdin/stdout JSON protocol) + +## Command Protocol (C#) + +`Journal.Core.Entry.HandleCommandAsync` accepts a JSON command envelope and returns: + +- success: `{ "ok": true, "data": ... }` +- failure: `{ "ok": false, "error": "..." }` + +Command model (`Journal.Core/Models/Command.cs`): + +```json +{ + "action": "entries.list", + "correlationId": "optional-string", + "id": "optional", + "type": "optional", + "tag": "optional", + "payload": {} +} +``` + +Useful actions for frontend wiring: + +- `entries.list` +- `entries.load` +- `entries.save` +- `search.entries` +- `vault.load_all` +- `vault.save_current_month` +- `db.status` +- `db.hydrate_workspace` + +## Recommended Integration (Sidecar Bridge) + +Use a small frontend client that sends commands through one bridge function. The bridge can be backed by: + +- a Tauri command that talks to a managed sidecar process, or +- a local HTTP adapter (if you add one). + +### 1. Define shared frontend command/response types + +Create `Journal.App/src/lib/backend/types.ts`: + +```ts +export type BackendCommand = { + action: string; + correlationId?: string; + id?: string; + type?: string; + tag?: string; + payload?: unknown; +}; + +export type BackendOk<T> = { ok: true; data: T }; +export type BackendErr = { ok: false; error: string }; +export type BackendResponse<T> = BackendOk<T> | BackendErr; +``` + +### 2. Create one backend client entrypoint + +Create `Journal.App/src/lib/backend/client.ts`: + +```ts +import { invoke } from "@tauri-apps/api/core"; +import type { BackendCommand, BackendResponse } from "./types"; + +export async function sendCommand<T>(command: BackendCommand): Promise<T> { + const response = await invoke<BackendResponse<T>>("sidecar_command", { command }); + + if (!response.ok) { + throw new Error(response.error || "Backend command failed"); + } + + return response.data; +} +``` + +This keeps all UI code backend-agnostic. + +### 3. Build domain helpers (entries example) + +Create `Journal.App/src/lib/backend/entries.ts`: + +```ts +import { sendCommand } from "./client"; + +export async function listEntries(dataDirectory?: string) { + return sendCommand<string[]>({ + action: "entries.list", + payload: { dataDirectory } + }); +} + +export async function loadEntry(filePath: string) { + return sendCommand<{ filePath: string; content: string; section?: string }>({ + action: "entries.load", + payload: { filePath } + }); +} + +export async function saveEntry(args: { + filePath?: string; + content: string; + title?: string; + section?: string; + date?: string; +}) { + return sendCommand<{ filePath: string }>({ + action: "entries.save", + payload: args + }); +} +``` + +### 4. Use client in UI state + +In page/component code: + +- on panel item click: call `loadEntry(filePath)` +- on editor save button: call `saveEntry({ filePath, content })` +- on app init: call `listEntries()` to populate list + +## Tauri Bridge Notes + +Your frontend should not spawn/process-manage the sidecar directly. Keep that in the Tauri layer. + +Bridge responsibilities: + +- start and keep one sidecar process alive +- write command JSON lines to sidecar stdin +- read stdout lines and map responses by `correlationId` +- return parsed response to frontend +- restart sidecar if it crashes + +If you have not implemented this yet, create one Tauri command such as: + +- `sidecar_command(command)` + +and route all frontend calls through it. + +## Vault/Auth Flow + +Recommended startup sequence: + +1. Prompt for vault password in UI. +2. Call `vault.load_all` (or `db.hydrate_workspace`) once. +3. Backend stores session password (`DatabaseSessionService`) for subsequent commands. +4. Continue with `entries.list`, `entries.load`, etc. + +Do not store raw vault password in long-lived frontend state. + +## Error Handling Pattern + +Always normalize backend errors in one place: + +- backend client throws `Error(message)` when `ok: false` +- UI catches and displays your custom modal +- include `correlationId` on commands for tracing/logging + +## Optional HTTP Path (If You Add Journal.Api) + +If you later add `Journal.Api` with `POST /api/command`, keep the same command envelope and swap transport only: + +- replace `invoke("sidecar_command", ...)` with `fetch("/api/command", ...)` +- keep `sendCommand` interface unchanged + +That lets UI code remain identical. + +## Minimal Next Steps + +1. Add `src/lib/backend/types.ts`, `client.ts`, `entries.ts`. +2. Wire `EditorPanel` save button to `entries.save`. +3. Wire `SidePanel` item load to `entries.load`. +4. Add vault unlock modal + `vault.load_all` on startup. +5. Keep all backend calls behind `sendCommand` only. + +## Frontend Store Architecture (Current) + +Current frontend uses feature stores in `Journal.App/src/lib/stores/`: + +- `entries.ts` -> `entriesStore` +- `fragments.ts` -> `fragmentsStore` +- `todos.ts` -> `todoListsStore`, `todosStore` +- `lists.ts` -> `listsStore` +- `settings.ts` -> `settingsTags`, `settingsFragmentTypes` + +Current pattern is store-first for most feature CRUD and parsing (especially fragments and todos), with UI components invoking store helpers. + +## State/CRUD Gaps Still Needed + +To fully standardize state management: + +1. Move settings add/edit/remove logic into `settings.ts` helper functions (currently in route component code). +2. Add full CRUD helpers for `entries.ts` and `lists.ts` (update/remove/reorder, not only draft creation). +3. Make todo list metadata + todo items update atomically through a single store API wrapper. +4. Move calendar-created entries out of local component state into a dedicated calendar store. +5. Add persistence/hydration strategy between stores and backend (`entries.load/save`, `vault.load_all`, etc.). + +## Recommended Rule + +- Keep all feature data mutations in store helper APIs. +- Keep route/component files focused on view state and command orchestration. +- Keep backend transport (`sendCommand`) separate from pure local store mutation helpers, then compose both in thin feature services. diff --git a/justfile b/justfile new file mode 100644 index 0000000..151bb9f --- /dev/null +++ b/justfile @@ -0,0 +1,105 @@ +# SDT — Project Journal Justfile +# Install just: https://just.systems/man/en/packages.html + +set windows-shell := ["pwsh", "-NoProfile", "-ExecutionPolicy", "Bypass", "-Command"] +set shell := ["pwsh", "-c"] + +# Detect runtime from OS +runtime := if os() == "windows" { "win-x64" } else { "linux-x64" } + +# ── Default: list available recipes ──────────────────────────────────────────── +default: + @just --list + +# ── Build ────────────────────────────────────────────────────────────────────── + +# Build Journal.Sidecar as self-contained single-file exe +sidecar: + & ./scripts/publish-sidecar.ps1 -Configuration Release -Runtime {{runtime}} + +# Build SvelteKit web bundle (output: Journal.App/build/) +web: + & ./scripts/publish-app.ps1 -Target web + +# Publish WebGateway with embedded web UI (depends: web) +webgateway: web + & ./scripts/publish-webgateway.ps1 -Configuration Release -Runtime {{runtime}} + +# Build Tauri desktop exe — no installer (depends: sidecar) +tauri: sidecar + & ./scripts/publish-app.ps1 -Target tauri -TauriBundles none + +# Build Tauri with NSIS installer (depends: sidecar) +tauri-nsis: sidecar + & ./scripts/publish-app.ps1 -Target tauri -TauriBundles nsis + +# Build Tauri with MSI installer (depends: sidecar) +tauri-msi: sidecar + & ./scripts/publish-app.ps1 -Target tauri -TauriBundles msi + +# Full release build — everything in correct order +all: sidecar web webgateway tauri + +# ── Dev ──────────────────────────────────────────────────────────────────────── + +# Run WebGateway dev server (http://localhost:5180) +run: + & ./scripts/run-webgateway.ps1 + +# Run WebGateway with pinned project root (avoids multi-clone ambiguity) +run-pinned: + & ./scripts/run-webgateway.ps1 -ProjectRoot {{justfile_directory()}} -Urls http://0.0.0.0:5180 + +# SvelteKit dev server only (http://localhost:1420) +dev-app: + Set-Location Journal.App; npm run dev + +# Tauri dev mode (desktop window + hot reload) +dev-tauri: sidecar + Set-Location Journal.App; npm run tauri dev + +# ── Test ─────────────────────────────────────────────────────────────────────── + +# Run all smoke tests (~80 integration tests) +test: + dotnet run --project Journal.SmokeTests/Journal.SmokeTests.csproj + +# Full migration gate (build + smoke + parity) +gate: + & ./scripts/migration-gate.ps1 + +# Migration gate — skip smoke tests +gate-fast: + & ./scripts/migration-gate.ps1 -SkipSmoke + +# Migration gate — skip API contract tests +gate-no-api: + & ./scripts/migration-gate.ps1 -SkipApi + +# ── .NET ─────────────────────────────────────────────────────────────────────── + +# dotnet build all projects +build: + dotnet build + +# dotnet build with resilient NuGet defaults (use in restricted environments) +build-safe: + & ./scripts/dotnet-min.ps1 build Journal.Core/Journal.Core.csproj + & ./scripts/dotnet-min.ps1 build Journal.Sidecar/Journal.Sidecar.csproj + & ./scripts/dotnet-min.ps1 build Journal.WebGateway/Journal.WebGateway.csproj + +# ── NuGet Cache ──────────────────────────────────────────────────────────────── + +# Export NuGet cache to zip for offline/transfer use +nuget-export zip="nuget-cache-export.zip": + & ./scripts/nuget-export-cache.ps1 -OutputZip {{zip}} + +# Import NuGet cache zip and validate restore +nuget-import zip="nuget-cache-export.zip": + & ./scripts/nuget-import-cache.ps1 -InputZip {{zip}} + +# ── SDT ──────────────────────────────────────────────────────────────────────── + +# Launch SDT dev tool TUI +sdt: + dotnet run --project Journal.DevTool/Journal.DevTool.csproj diff --git a/package-lock.json b/package-lock.json new file mode 100644 index 0000000..1a303e4 --- /dev/null +++ b/package-lock.json @@ -0,0 +1,6 @@ +{ + "name": "journal", + "lockfileVersion": 3, + "requires": true, + "packages": {} +} diff --git a/scripts/README.md b/scripts/README.md new file mode 100644 index 0000000..997637a --- /dev/null +++ b/scripts/README.md @@ -0,0 +1,328 @@ +# Scripts Reference + +This folder contains PowerShell wrappers for repeatable local development, build, publish, and cache operations. + +## Scope + +These scripts target the repository rooted at `E:\stansshit\csharp\journal-master\journal`. + +## Requirements + +- PowerShell 7+ (`pwsh` recommended) +- .NET SDK (current repo uses `net10.0` targets) +- Python (for `pip-min.ps1`, `migration-gate.ps1`) +- Node.js + npm (for `publish-app.ps1`) + +## Execution Policy + +If script execution is blocked on Windows, run commands with one of: + +```powershell +pwsh -NoProfile -ExecutionPolicy Bypass -File .\scripts\<script>.ps1 +``` + +or in-session: + +```powershell +Set-ExecutionPolicy -Scope Process Bypass +``` + +## Script Overview + +| Script | Purpose | +|---|---| +| `dev-shell.ps1` | Initializes current shell with repo-local .NET/pip/HuggingFace cache env vars. | +| `script-common.ps1` | Shared helper functions used by most scripts. | +| `dotnet-min.ps1` | Minimal `dotnet` wrapper with local NuGet cache and safe defaults. | +| `pip-min.ps1` | Minimal `pip` wrapper with repo-local target/cache and Windows compatibility mapping. | +| `pip_safe.py` | Python wrapper used by `pip-min.ps1` to patch temporary-directory behavior. | +| `publish-app.ps1` | Builds frontend web bundle or Tauri desktop app. | +| `publish-sidecar.ps1` | Publishes `Journal.Sidecar` single-file executable to `output/`. | +| `publish-webgateway.ps1` | Publishes `Journal.WebGateway` and optionally copies web assets into `wwwroot`. | +| `run-webgateway.ps1` | Runs `Journal.WebGateway` with configurable URLs and project root. | +| `migration-gate.ps1` | End-to-end migration/parity gate (build + smoke/parity/API checks). | +| `nuget-export-cache.ps1` | Primes and exports `.nuget` cache to zip for transfer. | +| `nuget-import-cache.ps1` | Imports exported cache zip and validates restore. | + +## Common Patterns Used Across Scripts + +- Proxy cleanup: `Clear-JournalProxyEnv` +- Repo root detection: `Resolve-JournalRepoRoot` +- Repo-local caches: + - `.dotnet_home` + - `.nuget\packages` + - `.nuget\http-cache` + - `.pip\cache` + - `.tmp\*` + - `.npm\cache` + +## Detailed Reference + +### `dev-shell.ps1` + +Dot-source this script to configure your *current shell*. + +```powershell +. .\scripts\dev-shell.ps1 +``` + +What it does: + +- loads `script-common.ps1` +- resolves repo root +- clears proxy env vars +- initializes repo-local .NET, pip, and HuggingFace env vars + +Use this once per shell session before running development commands manually. + +### `script-common.ps1` + +Shared helper functions: + +- `Clear-JournalProxyEnv` +- `Resolve-JournalRepoRoot` +- `Initialize-JournalDotnetEnv` +- `Initialize-JournalPipEnv` +- `Initialize-JournalHuggingFaceEnv` +- `Resolve-JournalSidecarProjectPath` +- `Resolve-JournalAppRoot` +- `Resolve-JournalWebGatewayProjectPath` + +Also supports optional override: + +- `JOURNAL_REPO_ROOT` + +### `dotnet-min.ps1` + +Wrapper around `dotnet` with resilient restore/build defaults. + +Usage: + +```powershell +.\scripts\dotnet-min.ps1 <dotnet args> +``` + +Examples: + +```powershell +.\scripts\dotnet-min.ps1 build Journal.Sidecar/Journal.Sidecar.csproj +.\scripts\dotnet-min.ps1 restore Journal.WebGateway/Journal.WebGateway.csproj +.\scripts\dotnet-min.ps1 run --project Journal.Sidecar/Journal.Sidecar.csproj +``` + +Behavior: + +- sets repo-local `DOTNET_CLI_HOME` and NuGet cache paths +- clears proxy env vars +- adds for common commands (`restore`, `build`, `run`, `test`, `publish`, `pack`): + - `-p:RestoreIgnoreFailedSources=true` + - `-p:NuGetAudit=false` +- for `restore`, also adds `--ignore-failed-sources` + +### `pip-min.ps1` + +Wrapper around `python -m pip` focused on constrained hosts. + +Usage: + +```powershell +.\scripts\pip-min.ps1 <pip args> +``` + +Examples: + +```powershell +.\scripts\pip-min.ps1 install requests +.\scripts\pip-min.ps1 install --index-url https://pypi.org/simple faster-whisper +``` + +Behavior: + +- initializes repo-local pip cache/temp paths +- clears proxy env vars +- for `install` without target/prefix: + - strips `--user` + - installs into `.pydeps\py314` +- on Windows, maps `pyaudio` to `pyaudiowpatch` +- uses `pip_safe.py` if present + +### `pip_safe.py` + +Compatibility wrapper for pip on some Windows + Python 3.14 setups. + +Behavior: + +- monkey-patches `tempfile.mkdtemp` to create writable temp directories (`0o777`) +- then forwards to pip internal CLI + +### `publish-app.ps1` + +Builds the frontend (`web`) or Tauri desktop app (`tauri`). + +Parameters: + +- `-Target web|tauri` (default `web`) +- `-Configuration Release|Debug` (default `Release`) +- `-TauriBundles none|nsis|msi` (default `none`) +- `-InstallDeps` +- `-SkipInstall` +- `-DryRun` + +Examples: + +```powershell +.\scripts\publish-app.ps1 -Target web +.\scripts\publish-app.ps1 -Target tauri -TauriBundles none +.\scripts\publish-app.ps1 -Target tauri -TauriBundles nsis +``` + +Notes: + +- uses repo-local npm cache/temp paths +- `-TauriBundles none` maps to `tauri build --no-bundle` (raw exe build) +- expected web output: `Journal.App\build` +- expected tauri exe location: `Journal.App\src-tauri\target\release\journalapp.exe` (Release) + +### `publish-sidecar.ps1` + +Publishes `Journal.Sidecar` as a self-contained single-file executable. + +Parameters: + +- `-Configuration` (default `Release`) +- `-Runtime` (default `win-x64`) + +Example: + +```powershell +.\scripts\publish-sidecar.ps1 -Configuration Release -Runtime win-x64 +``` + +Output: + +- `output\Journal.Sidecar.exe` (for Windows runtime) + +### `publish-webgateway.ps1` + +Publishes `Journal.WebGateway` and optionally embeds built web assets. + +Parameters: + +- `-Configuration Release|Debug` (default `Release`) +- `-Runtime` (default `win-x64`) +- `-SelfContained` (switch) +- `-SkipWebAssets` (switch) + +Example: + +```powershell +.\scripts\publish-app.ps1 -Target web +.\scripts\publish-webgateway.ps1 -Configuration Release -Runtime win-x64 +``` + +Output: + +- `output\webgateway\` +- optional `output\webgateway\wwwroot\` from `Journal.App\build` + +### `run-webgateway.ps1` + +Runs `Journal.WebGateway` directly with controlled environment. + +Parameters: + +- `-Configuration Release|Debug` (default `Release`) +- `-Urls` (default `http://0.0.0.0:5180`) +- `-ProjectRoot` (optional; if omitted, repo root) + +Examples: + +```powershell +.\scripts\run-webgateway.ps1 +.\scripts\run-webgateway.ps1 -Urls http://127.0.0.1:5180 +.\scripts\run-webgateway.ps1 -ProjectRoot E:\stansshit\csharp\journal-master\journal +``` + +Notes: + +- sets `JOURNAL_PROJECT_ROOT` for the gateway process +- useful when multiple repo clones exist and you need deterministic data/vault paths + +### `migration-gate.ps1` + +Runs migration quality gate. + +Parameters: + +- `-SkipSmoke` +- `-SkipApi` + +Current behavior: + +1. builds `Journal.Sidecar` +2. optionally runs `Journal.SmokeTests` +3. runs Python parity harness test discovery +4. optionally runs API contract test discovery + +If `tests/` is absent, Python parity and API contract steps are skipped automatically with a clear message — the sidecar build and smoke tests still run. + +### `nuget-export-cache.ps1` + +Primes and exports NuGet cache to zip. + +Parameters: + +- `-OutputZip` (default `nuget-cache-export.zip`) +- `-IncludeDotnetHome` + +Behavior: + +- runs restore for selected projects via `dotnet-min.ps1` +- copies `.nuget` (and optional `.dotnet_home`) to staging +- writes `nuget-cache-manifest.txt` +- outputs zip + +Primes restore for `Journal.Sidecar`, `Journal.WebGateway`, and `Journal.SmokeTests`. + +### `nuget-import-cache.ps1` + +Imports exported cache zip and validates by restore. + +Parameters: + +- `-InputZip` (default `nuget-cache-export.zip`) + +Behavior: + +- extracts zip into repo root +- runs restore for selected projects via `dotnet-min.ps1` + +Validates restore for `Journal.Sidecar`, `Journal.WebGateway`, and `Journal.SmokeTests`. + +## Environment Variables Used + +- `JOURNAL_REPO_ROOT` (optional override for repo detection) +- `JOURNAL_PROJECT_ROOT` (runtime project root for gateway/sidecar config) +- `DOTNET_CLI_HOME` +- `NUGET_PACKAGES` +- `NUGET_HTTP_CACHE_PATH` +- `NUGET_CERT_REVOCATION_MODE` +- `PIP_CACHE_DIR` +- `HF_HOME` +- `HUGGINGFACE_HUB_CACHE` + +## Output and Cache Directories + +- `output/` +- `output/webgateway/` +- `.dotnet_home/` +- `.nuget/packages/` +- `.nuget/http-cache/` +- `.npm/cache/` +- `.pip/cache/` +- `.tmp/` +- `.pydeps/` + +## See Also + +- [`WORKFLOWS.md`](./WORKFLOWS.md) for copy/paste command recipes. diff --git a/scripts/WORKFLOWS.md b/scripts/WORKFLOWS.md new file mode 100644 index 0000000..e3972b4 --- /dev/null +++ b/scripts/WORKFLOWS.md @@ -0,0 +1,140 @@ +# Script Workflows + +Practical command recipes for common tasks. + +## 1) Start a Clean Dev Shell + +```powershell +cd E:\stansshit\csharp\journal-master\journal +. .\scripts\dev-shell.ps1 +``` + +Use this when you want the current shell configured with repo-local cache paths. + +## 2) Build .NET Projects With Safe Defaults + +```powershell +.\scripts\dotnet-min.ps1 build Journal.Sidecar/Journal.Sidecar.csproj +.\scripts\dotnet-min.ps1 build Journal.WebGateway/Journal.WebGateway.csproj +``` + +## 3) Build Frontend or Desktop App + +Web build: + +```powershell +.\scripts\publish-app.ps1 -Target web +``` + +Tauri raw exe (no installer): + +```powershell +.\scripts\publish-app.ps1 -Target tauri -TauriBundles none +``` + +Tauri installer bundles: + +```powershell +.\scripts\publish-app.ps1 -Target tauri -TauriBundles nsis +.\scripts\publish-app.ps1 -Target tauri -TauriBundles msi +``` + +## 4) Publish Sidecar + +```powershell +.\scripts\publish-sidecar.ps1 -Configuration Release -Runtime win-x64 +``` + +Expected output under `output/`. + +## 5) Publish WebGateway Package + +```powershell +.\scripts\publish-app.ps1 -Target web +.\scripts\publish-webgateway.ps1 -Configuration Release -Runtime win-x64 +``` + +If you only want gateway binary refresh: + +```powershell +.\scripts\publish-webgateway.ps1 -SkipWebAssets +``` + +## 6) Run WebGateway Against Explicit Root + +When multiple clones exist, always pin project root: + +```powershell +.\scripts\run-webgateway.ps1 -ProjectRoot E:\stansshit\csharp\journal-master\journal -Urls http://0.0.0.0:5180 +``` + +Quick health check: + +```powershell +Invoke-RestMethod http://127.0.0.1:5180/api/health +``` + +Inspect active backend config: + +```powershell +$body = @{ action = 'config.get' } | ConvertTo-Json +Invoke-RestMethod -Uri http://127.0.0.1:5180/api/command -Method Post -ContentType 'application/json' -Body $body +``` + +## 7) Python Package Installs in Repo-Local Target + +```powershell +.\scripts\pip-min.ps1 install requests +``` + +Packages go to `.pydeps\py314` unless you pass your own `--target`/`--prefix`. + +## 8) Migration Gate (When Full Test Assets Exist) + +```powershell +.\scripts\migration-gate.ps1 +``` + +Partial run: + +```powershell +.\scripts\migration-gate.ps1 -SkipSmoke -SkipApi +``` + +If `tests/` is absent, Python parity and API contract steps are skipped with a clear message. + +## 9) NuGet Cache Export/Import (Offline-ish Restore) + +Export: + +```powershell +.\scripts\nuget-export-cache.ps1 -OutputZip .\nuget-cache-export.zip +``` + +Import: + +```powershell +.\scripts\nuget-import-cache.ps1 -InputZip .\nuget-cache-export.zip +``` + +Validates restore for `Journal.Sidecar`, `Journal.WebGateway`, and `Journal.SmokeTests`. + +## 10) Quick Troubleshooting + +Script blocked by execution policy: + +```powershell +pwsh -NoProfile -ExecutionPolicy Bypass -File .\scripts\publish-app.ps1 -Target web +``` + +Unexpected data/vault mismatch in WebGateway: + +1. Run with explicit `-ProjectRoot`. +2. Verify with `config.get` via `/api/command`. +3. Verify sidecar root via `/api/sidecar/root`. + +NuGet restore flakiness: + +1. Use `dotnet-min.ps1` wrappers. +2. Confirm proxy vars are cleared (`HTTP_PROXY`, `HTTPS_PROXY`, etc.). +3. Ensure `.nuget` directories are writable. diff --git a/scripts/dev-shell.ps1 b/scripts/dev-shell.ps1 new file mode 100644 index 0000000..eb262d0 --- /dev/null +++ b/scripts/dev-shell.ps1 @@ -0,0 +1,24 @@ +# Run this in PowerShell before development commands: +# . ./scripts/dev-shell.ps1 + +$commonScript = Join-Path $PSScriptRoot "script-common.ps1" +if (-not (Test-Path $commonScript)) { + throw "Missing helper script: $commonScript" +} +. $commonScript + +$repoRoot = Resolve-JournalRepoRoot -StartPath $PSScriptRoot + +# Clear dead proxy overrides and offline-only pip mode in current shell. +Clear-JournalProxyEnv + +# Keep .NET artifacts local to repo to avoid restricted user-profile paths. +Initialize-JournalDotnetEnv -RepoRoot $repoRoot + +# Keep pip artifacts local to repo. +Initialize-JournalPipEnv -RepoRoot $repoRoot + +# Keep Hugging Face cache local and silence symlink-only warning on Windows. +Initialize-JournalHuggingFaceEnv -RepoRoot $repoRoot + +Write-Host "Development shell initialized for repo-local dotnet/pip paths at: $repoRoot" diff --git a/scripts/dotnet-min.ps1 b/scripts/dotnet-min.ps1 new file mode 100644 index 0000000..9b36e3b --- /dev/null +++ b/scripts/dotnet-min.ps1 @@ -0,0 +1,62 @@ +param( + [Parameter(ValueFromRemainingArguments = $true)] + [string[]]$DotnetArgs +) + +$repoRoot = (Resolve-Path (Join-Path $PSScriptRoot "..")).Path + +# Keep dotnet and NuGet artifacts local to the repo for easy cleanup. +$env:DOTNET_CLI_HOME = Join-Path $repoRoot ".dotnet_home" +$env:NUGET_PACKAGES = Join-Path $repoRoot ".nuget\packages" +$env:NUGET_HTTP_CACHE_PATH = Join-Path $repoRoot ".nuget\http-cache" + +# Keep setup minimal and non-interactive. +$env:DOTNET_SKIP_FIRST_TIME_EXPERIENCE = "1" +$env:DOTNET_ADD_GLOBAL_TOOLS_TO_PATH = "0" +$env:DOTNET_GENERATE_ASPNET_CERTIFICATE = "0" +$env:DOTNET_CLI_TELEMETRY_OPTOUT = "1" + +# Clear proxy env vars for this process. The host machine currently points them +# to 127.0.0.1:9, which breaks NuGet restore. +Remove-Item Env:HTTP_PROXY -ErrorAction SilentlyContinue +Remove-Item Env:HTTPS_PROXY -ErrorAction SilentlyContinue +Remove-Item Env:ALL_PROXY -ErrorAction SilentlyContinue +Remove-Item Env:http_proxy -ErrorAction SilentlyContinue +Remove-Item Env:https_proxy -ErrorAction SilentlyContinue +Remove-Item Env:all_proxy -ErrorAction SilentlyContinue +Remove-Item Env:GIT_HTTP_PROXY -ErrorAction SilentlyContinue +Remove-Item Env:GIT_HTTPS_PROXY -ErrorAction SilentlyContinue + +# Prefer offline cert revocation checks to reduce flaky TLS behavior on constrained hosts. +$env:NUGET_CERT_REVOCATION_MODE = "offline" + +New-Item -ItemType Directory -Force -Path $env:DOTNET_CLI_HOME | Out-Null +New-Item -ItemType Directory -Force -Path $env:NUGET_PACKAGES | Out-Null +New-Item -ItemType Directory -Force -Path $env:NUGET_HTTP_CACHE_PATH | Out-Null + +if (-not $DotnetArgs -or $DotnetArgs.Count -eq 0) { + Write-Host "Usage: ./scripts/dotnet-min.ps1 <dotnet args>" + Write-Host "Example: ./scripts/dotnet-min.ps1 build Journal.Sidecar/Journal.Sidecar.csproj" + exit 2 +} + +$firstArg = $DotnetArgs[0].ToLowerInvariant() +$effectiveArgs = @($DotnetArgs) + +if ($firstArg -in @("restore", "build", "run", "test", "publish", "pack")) { + if (-not ($effectiveArgs -contains "-p:RestoreIgnoreFailedSources=true")) { + $effectiveArgs += "-p:RestoreIgnoreFailedSources=true" + } + if (-not ($effectiveArgs -contains "-p:NuGetAudit=false")) { + $effectiveArgs += "-p:NuGetAudit=false" + } +} + +if ($firstArg -eq "restore") { + if (-not ($effectiveArgs -contains "--ignore-failed-sources")) { + $effectiveArgs += "--ignore-failed-sources" + } +} + +& dotnet @effectiveArgs +exit $LASTEXITCODE diff --git a/scripts/migration-gate.ps1 b/scripts/migration-gate.ps1 new file mode 100644 index 0000000..c0d2e09 --- /dev/null +++ b/scripts/migration-gate.ps1 @@ -0,0 +1,57 @@ +param( + [switch]$SkipSmoke, + [switch]$SkipApi +) + +$ErrorActionPreference = "Stop" +$repoRoot = Split-Path -Parent $PSScriptRoot +$parityReport = Join-Path $repoRoot "logs\parity_harness_results.json" + +Write-Host "migration-gate: repo root = $repoRoot" + +Push-Location $repoRoot +try { + Write-Host "migration-gate: building sidecar binary..." + & "$repoRoot\scripts\dotnet-min.ps1" build Journal.Sidecar/Journal.Sidecar.csproj + if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE } + + if (-not $SkipSmoke) { + Write-Host "migration-gate: running csharp smoke tests..." + & "$repoRoot\scripts\dotnet-min.ps1" run --project Journal.SmokeTests/Journal.SmokeTests.csproj + if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE } + } + else { + Write-Host "migration-gate: skipping smoke tests (--SkipSmoke)." + } + + Write-Host "migration-gate: running parity harness + fixture matrix..." + $testsDir = Join-Path $repoRoot "tests" + if (Test-Path $testsDir) { + $env:PARITY_HARNESS_REPORT = $parityReport + & python -m unittest discover -s tests -p "test_parity_harness.py" -v + if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE } + } + else { + Write-Host "migration-gate: skipping parity harness — tests/ directory not found." + } + + if (-not $SkipApi) { + Write-Host "migration-gate: running API contract tests..." + if (Test-Path $testsDir) { + & python -m unittest discover -s tests -p "test_api_contract.py" -v + if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE } + } + else { + Write-Host "migration-gate: skipping API contract tests — tests/ directory not found." + } + } + else { + Write-Host "migration-gate: skipping API contract tests (--SkipApi)." + } + + Write-Host "migration-gate: PASS" + Write-Host "migration-gate: parity report => $parityReport" +} +finally { + Pop-Location +} diff --git a/scripts/npm-clean.ps1 b/scripts/npm-clean.ps1 new file mode 100644 index 0000000..ce838cd --- /dev/null +++ b/scripts/npm-clean.ps1 @@ -0,0 +1,62 @@ +param( + [switch]$RemoveLockfile, + [switch]$Force +) + +$commonScript = Join-Path $PSScriptRoot "script-common.ps1" +if (-not (Test-Path $commonScript)) { + throw "Missing helper script: $commonScript" +} +. $commonScript + +$repoRoot = Resolve-JournalRepoRoot -StartPath $PSScriptRoot +$appRoot = Resolve-JournalAppRoot -RepoRoot $repoRoot + +Write-Host "Cleaning npm artifacts for Journal.App" -ForegroundColor Cyan +Write-Host "Using app root: $appRoot" -ForegroundColor DarkGray + +$processNames = @("node", "journalapp", "tauri") +Get-Process -ErrorAction SilentlyContinue | + Where-Object { $processNames -contains $_.ProcessName } | + ForEach-Object { + try { + Stop-Process -Id $_.Id -Force -ErrorAction Stop + Write-Host "Stopped process: $($_.ProcessName) ($($_.Id))" -ForegroundColor DarkGray + } + catch { + Write-Warning "Failed to stop process $($_.ProcessName) ($($_.Id)): $($_.Exception.Message)" + } + } + +Push-Location $appRoot +try { + $nodeModulesPath = Join-Path $appRoot "node_modules" + $lockfilePath = Join-Path $appRoot "package-lock.json" + + if (Test-Path $nodeModulesPath) { + if (-not $Force) { + Write-Host "Removing node_modules (use -Force to suppress prompt)..." -ForegroundColor Yellow + } + Remove-Item -Recurse -Force $nodeModulesPath + Write-Host "Removed node_modules." -ForegroundColor Green + } + else { + Write-Host "node_modules not found; nothing to remove." -ForegroundColor DarkGray + } + + if ($RemoveLockfile) { + if (Test-Path $lockfilePath) { + Remove-Item -Force $lockfilePath + Write-Host "Removed package-lock.json." -ForegroundColor Green + } + else { + Write-Host "package-lock.json not found; nothing to remove." -ForegroundColor DarkGray + } + } + else { + Write-Host "Keeping package-lock.json (pass -RemoveLockfile to delete)." -ForegroundColor DarkGray + } +} +finally { + Pop-Location +} diff --git a/scripts/nuget-export-cache.ps1 b/scripts/nuget-export-cache.ps1 new file mode 100644 index 0000000..bee1a64 --- /dev/null +++ b/scripts/nuget-export-cache.ps1 @@ -0,0 +1,57 @@ +param( + [string]$OutputZip = "nuget-cache-export.zip", + [switch]$IncludeDotnetHome +) + +$repoRoot = (Resolve-Path (Join-Path $PSScriptRoot "..")).Path +$outputPath = if ([System.IO.Path]::IsPathRooted($OutputZip)) { $OutputZip } else { Join-Path $repoRoot $OutputZip } +$outputDir = Split-Path -Parent $outputPath +if (-not (Test-Path $outputDir)) { + New-Item -ItemType Directory -Force -Path $outputDir | Out-Null +} + +Write-Host "Priming restore cache..." +& (Join-Path $PSScriptRoot "dotnet-min.ps1") restore "Journal.Sidecar/Journal.Sidecar.csproj" +if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE } +& (Join-Path $PSScriptRoot "dotnet-min.ps1") restore "Journal.WebGateway/Journal.WebGateway.csproj" +if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE } +& (Join-Path $PSScriptRoot "dotnet-min.ps1") restore "Journal.SmokeTests/Journal.SmokeTests.csproj" +if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE } + +$staging = Join-Path $repoRoot ".nuget-export-staging" +if (Test-Path $staging) { + Remove-Item -Recurse -Force $staging +} +New-Item -ItemType Directory -Force -Path $staging | Out-Null + +$nugetRoot = Join-Path $repoRoot ".nuget" +if (-not (Test-Path $nugetRoot)) { + Write-Error "No .nuget directory found under $repoRoot" + exit 1 +} + +Copy-Item -Recurse -Force -Path $nugetRoot -Destination (Join-Path $staging ".nuget") +if ($IncludeDotnetHome) { + $dotnetHome = Join-Path $repoRoot ".dotnet_home" + if (Test-Path $dotnetHome) { + Copy-Item -Recurse -Force -Path $dotnetHome -Destination (Join-Path $staging ".dotnet_home") + } +} + +$manifest = @( + "exported_utc=$([DateTime]::UtcNow.ToString("o"))" + "repo_root=$repoRoot" + "include_dotnet_home=$($IncludeDotnetHome.IsPresent)" + "note=Copy this zip to target machine and run scripts/nuget-import-cache.ps1" +) +$manifest | Set-Content -Encoding UTF8 -Path (Join-Path $staging "nuget-cache-manifest.txt") + +if (Test-Path $outputPath) { + Remove-Item -Force $outputPath +} + +Compress-Archive -Path (Join-Path $staging "*") -DestinationPath $outputPath -Force +Remove-Item -Recurse -Force $staging + +Write-Host "NuGet cache export created at: $outputPath" + diff --git a/scripts/nuget-import-cache.ps1 b/scripts/nuget-import-cache.ps1 new file mode 100644 index 0000000..dad8f04 --- /dev/null +++ b/scripts/nuget-import-cache.ps1 @@ -0,0 +1,25 @@ +param( + [string]$InputZip = "nuget-cache-export.zip" +) + +$repoRoot = (Resolve-Path (Join-Path $PSScriptRoot "..")).Path +$inputPath = if ([System.IO.Path]::IsPathRooted($InputZip)) { $InputZip } else { Join-Path $repoRoot $InputZip } + +if (-not (Test-Path $inputPath)) { + Write-Error "Input zip not found: $inputPath" + exit 1 +} + +Write-Host "Importing cache from: $inputPath" +Expand-Archive -Path $inputPath -DestinationPath $repoRoot -Force + +Write-Host "Running restore with local cache..." +& (Join-Path $PSScriptRoot "dotnet-min.ps1") restore "Journal.Sidecar/Journal.Sidecar.csproj" +if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE } +& (Join-Path $PSScriptRoot "dotnet-min.ps1") restore "Journal.WebGateway/Journal.WebGateway.csproj" +if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE } +& (Join-Path $PSScriptRoot "dotnet-min.ps1") restore "Journal.SmokeTests/Journal.SmokeTests.csproj" +if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE } + +Write-Host "Cache import complete." + diff --git a/scripts/pip-min.ps1 b/scripts/pip-min.ps1 new file mode 100644 index 0000000..6bf7f2c --- /dev/null +++ b/scripts/pip-min.ps1 @@ -0,0 +1,56 @@ +param( + [Parameter(ValueFromRemainingArguments = $true)] + [string[]]$PipArgs +) + +$commonScript = Join-Path $PSScriptRoot "script-common.ps1" +if (-not (Test-Path $commonScript)) { + throw "Missing helper script: $commonScript" +} +. $commonScript + +$repoRoot = Resolve-JournalRepoRoot -StartPath $PSScriptRoot + +Initialize-JournalPipEnv -RepoRoot $repoRoot +Clear-JournalProxyEnv + +if (-not $PipArgs -or $PipArgs.Count -eq 0) { + Write-Host "Usage: ./scripts/pip-min.ps1 <pip args>" + Write-Host "Example: ./scripts/pip-min.ps1 install --index-url https://pypi.org/simple faster-whisper" + exit 2 +} + +# Default install target to a repo-local directory so installs do not require +# user/site-packages write access on constrained hosts. +$effectiveArgs = @($PipArgs) +$firstArg = $effectiveArgs[0].ToLowerInvariant() +if ($firstArg -eq "install") { + # On Windows, map PyAudio to pyaudiowpatch (wheel available for newer CPython), + # avoiding source builds that require PortAudio headers/toolchain wiring. + for ($i = 0; $i -lt $effectiveArgs.Count; $i++) { + $arg = $effectiveArgs[$i] + if ($arg -match '^(?i)pyaudio($|[<>=!~].*)') { + $suffix = $arg.Substring(7) + $effectiveArgs[$i] = "pyaudiowpatch$suffix" + Write-Host "pip-min: mapped '$arg' -> '$($effectiveArgs[$i])' on Windows." + } + } + + $hasTarget = $effectiveArgs -contains "--target" -or $effectiveArgs -contains "-t" -or $effectiveArgs -contains "--prefix" + if (-not $hasTarget) { + $effectiveArgs = $effectiveArgs | Where-Object { $_ -ne "--user" } + $localTarget = Join-Path $repoRoot ".pydeps\py314" + New-Item -ItemType Directory -Force -Path $localTarget | Out-Null + $effectiveArgs += @("--target", $localTarget) + Write-Host "pip-min: using local target $localTarget" + } +} + +$pipWrapper = Join-Path $PSScriptRoot "pip_safe.py" +if (Test-Path $pipWrapper) { + & python $pipWrapper @effectiveArgs +} +else { + & python -m pip @effectiveArgs +} +exit $LASTEXITCODE diff --git a/scripts/pip_safe.py b/scripts/pip_safe.py new file mode 100644 index 0000000..a02a307 --- /dev/null +++ b/scripts/pip_safe.py @@ -0,0 +1,46 @@ +from __future__ import annotations + +import os +import tempfile +from typing import Callable + + +def _mkdtemp_compat( + suffix: str | None = None, + prefix: str | None = None, + dir: str | None = None, +) -> str: + # Python 3.14 on some Windows hosts creates mkdtemp dirs that are + # immediately non-writable by the same process when mode=0o700 is used. + # pip relies heavily on tempfile; force 0o777 for compatibility. + if dir is None: + dir = tempfile.gettempdir() + if prefix is None: + prefix = tempfile.template + if suffix is None: + suffix = "" + + names = tempfile._get_candidate_names() + for _ in range(tempfile.TMP_MAX): + name = next(names) + path = os.path.join(dir, f"{prefix}{name}{suffix}") + try: + os.mkdir(path, 0o777) + return path + except FileExistsError: + continue + + raise FileExistsError("No usable temporary directory name found.") + + +def main(argv: list[str]) -> int: + tempfile.mkdtemp = _mkdtemp_compat # type: ignore[assignment] + + from pip._internal.cli.main import main as pip_main + + return int(pip_main(argv)) + + +if __name__ == "__main__": + raise SystemExit(main(__import__("sys").argv[1:])) + diff --git a/scripts/publish-app.ps1 b/scripts/publish-app.ps1 new file mode 100644 index 0000000..7d3a783 --- /dev/null +++ b/scripts/publish-app.ps1 @@ -0,0 +1,216 @@ +param( + [ValidateSet("web", "tauri")] + [string]$Target = "web", + [ValidateSet("Release", "Debug")] + [string]$Configuration = "Release", + [ValidateSet("none", "nsis", "msi")] + [string]$TauriBundles = "none", + [switch]$InstallDeps, + [switch]$SkipInstall, + [switch]$DryRun +) + +$commonScript = Join-Path $PSScriptRoot "script-common.ps1" +if (-not (Test-Path $commonScript)) { + throw "Missing helper script: $commonScript" +} +. $commonScript + +$repoRoot = Resolve-JournalRepoRoot -StartPath $PSScriptRoot +$appRoot = Resolve-JournalAppRoot -RepoRoot $repoRoot + +Clear-JournalProxyEnv + +# Keep npm cache and temp local to the repo. +$npmCacheDir = Join-Path $repoRoot ".npm\cache" +$npmTempDir = Join-Path $repoRoot ".tmp\npm-temp" +New-Item -ItemType Directory -Force -Path $npmCacheDir, $npmTempDir | Out-Null +$env:npm_config_cache = $npmCacheDir +$env:npm_config_update_notifier = "false" +$env:npm_config_fund = "false" +$env:npm_config_audit = "false" +$env:npm_config_offline = "false" +$env:npm_config_prefer_offline = "false" +$env:npm_config_prefer_online = "true" +$env:TEMP = $npmTempDir +$env:TMP = $npmTempDir + +if (-not (Get-Command npm -ErrorAction SilentlyContinue)) { + throw "npm is required but was not found in PATH." +} + +$nodeModulesPath = Join-Path $appRoot "node_modules" +$packageJsonPath = Join-Path $appRoot "package.json" +$packageLockPath = Join-Path $appRoot "package-lock.json" +$depsHashPath = Join-Path $appRoot "node_modules\.journal-deps.sha256" + +function Get-JournalNodeDepsHash { + param( + [Parameter(Mandatory = $true)] + [string[]]$Paths + ) + + $hashLines = foreach ($path in $Paths) { + if (-not (Test-Path $path)) { + continue + } + (Get-FileHash -Algorithm SHA256 -Path $path).Hash + } + return ($hashLines -join "`n").Trim() +} + +$hashInputs = @() +if (Test-Path $packageJsonPath) { + $hashInputs += $packageJsonPath +} +if (Test-Path $packageLockPath) { + $hashInputs += $packageLockPath +} +if ($hashInputs.Count -eq 0) { + throw "package.json not found under $appRoot." +} + +$expectedDepsHash = Get-JournalNodeDepsHash -Paths $hashInputs +$shouldInstall = $InstallDeps -or (-not (Test-Path $nodeModulesPath)) +$installReason = $null + +if (-not $shouldInstall -and -not $SkipInstall) { + if (-not (Test-Path $depsHashPath)) { + $shouldInstall = $true + $installReason = "dependency hash missing" + } + else { + $currentDepsHash = (Get-Content $depsHashPath -Raw).Trim() + if ($currentDepsHash -ne $expectedDepsHash) { + $shouldInstall = $true + $installReason = "package.json/lockfile changed" + } + } +} + +if ($SkipInstall) { + $shouldInstall = $false + if ($installReason) { + Write-Host "SkipInstall set; dependencies may be stale ($installReason)." -ForegroundColor Yellow + } +} + +Write-Host "Building Journal.App target '$Target' ($Configuration)..." -ForegroundColor Cyan +Write-Host "Using app root: $appRoot" -ForegroundColor DarkGray + +Push-Location $appRoot +try { + if ($shouldInstall) { + $installArgs = if (Test-Path $packageLockPath) { + @("ci", "--no-audit", "--fund=false") + } + else { + @("install", "--no-audit", "--fund=false") + } + + if ($installReason) { + Write-Host "Dependencies changed ($installReason). Installing..." -ForegroundColor Yellow + } + + Write-Host "> npm $($installArgs -join ' ')" -ForegroundColor DarkGray + if (-not $DryRun) { + & npm @installArgs + if ($LASTEXITCODE -ne 0) { + throw "Dependency install failed with exit code $LASTEXITCODE." + } + + $depsDir = Split-Path $depsHashPath -Parent + if (-not (Test-Path $depsDir)) { + New-Item -ItemType Directory -Force -Path $depsDir | Out-Null + } + $expectedDepsHash | Set-Content -Path $depsHashPath -NoNewline + } + } + else { + Write-Host "Skipping dependency install (node_modules present and deps unchanged)." -ForegroundColor DarkGray + } + + if ($Target -eq "web") { + $buildArgs = @("run", "build") + Write-Host "> npm $($buildArgs -join ' ')" -ForegroundColor DarkGray + if (-not $DryRun) { + & npm @buildArgs + if ($LASTEXITCODE -ne 0) { + throw "Frontend build failed with exit code $LASTEXITCODE." + } + } + + $outputPath = Join-Path $appRoot "build" + if ($DryRun) { + Write-Host "`nDry run complete (no commands executed)." -ForegroundColor Yellow + Write-Host "Expected output: $outputPath" -ForegroundColor Gray + } + else { + Write-Host "`nFrontend build successful." -ForegroundColor Green + Write-Host "Output: $outputPath" -ForegroundColor Gray + } + } + else { + $tauriArgs = @("run", "tauri", "build") + $tauriCliArgs = @() + if ($TauriBundles -eq "none") { + $tauriCliArgs += "--no-bundle" + } + else { + $tauriCliArgs += @("--bundles", $TauriBundles) + } + if ($Configuration -eq "Debug") { + $tauriCliArgs += "--debug" + } + if ($tauriCliArgs.Count -gt 0) { + $tauriArgs += "--" + $tauriArgs += $tauriCliArgs + } + + Write-Host "> npm $($tauriArgs -join ' ')" -ForegroundColor DarkGray + if (-not $DryRun) { + & npm @tauriArgs + if ($LASTEXITCODE -ne 0) { + throw "Tauri build failed with exit code $LASTEXITCODE." + } + } + + $targetConfigDir = if ($Configuration -eq "Debug") { "debug" } else { "release" } + $tauriTargetPath = Join-Path $appRoot "src-tauri\target" + $rawExePath = Join-Path $tauriTargetPath "$targetConfigDir\journalapp.exe" + if ($DryRun) { + Write-Host "`nDry run complete (no commands executed)." -ForegroundColor Yellow + if ($TauriBundles -eq "none") { + Write-Host "Expected executable: $rawExePath" -ForegroundColor Gray + } + else { + Write-Host "Expected output root: $tauriTargetPath" -ForegroundColor Gray + } + } + else { + Write-Host "`nTauri build successful." -ForegroundColor Green + if ($TauriBundles -eq "none") { + if (Test-Path $rawExePath) { + Write-Host "Executable location: $rawExePath" -ForegroundColor Gray + } + else { + $exeCandidates = Get-ChildItem -Path (Join-Path $tauriTargetPath $targetConfigDir) -File -Filter *.exe -ErrorAction SilentlyContinue | + Sort-Object LastWriteTime -Descending + if ($exeCandidates -and $exeCandidates.Count -gt 0) { + Write-Host "Executable location: $($exeCandidates[0].FullName)" -ForegroundColor Gray + } + else { + Write-Host "Output root: $tauriTargetPath" -ForegroundColor Gray + } + } + } + else { + Write-Host "Output root: $tauriTargetPath" -ForegroundColor Gray + } + } + } +} +finally { + Pop-Location +} + diff --git a/scripts/publish-output.ps1 b/scripts/publish-output.ps1 new file mode 100644 index 0000000..29663f6 --- /dev/null +++ b/scripts/publish-output.ps1 @@ -0,0 +1,103 @@ +param( + [ValidateSet("Release", "Debug")] + [string]$Configuration = "Release", + [string]$Runtime = "win-x64", + [switch]$SkipSidecar, + [switch]$SkipWeb, + [switch]$SkipWebGateway, + [switch]$SkipTauri, + [switch]$DryRun +) + +$commonScript = Join-Path $PSScriptRoot "script-common.ps1" +if (-not (Test-Path $commonScript)) { + throw "Missing helper script: $commonScript" +} +. $commonScript + +$repoRoot = Resolve-JournalRepoRoot -StartPath $PSScriptRoot +$appRoot = Resolve-JournalAppRoot -RepoRoot $repoRoot +$outputRoot = Join-Path $repoRoot "output" + +$publishSidecar = Join-Path $PSScriptRoot "publish-sidecar.ps1" +$publishApp = Join-Path $PSScriptRoot "publish-app.ps1" +$publishGateway = Join-Path $PSScriptRoot "publish-webgateway.ps1" + +Write-Host "Publishing all outputs to: $outputRoot" -ForegroundColor Cyan +Write-Host "Configuration: $Configuration Runtime: $Runtime" -ForegroundColor DarkGray + +if (-not (Test-Path $outputRoot)) { + New-Item -ItemType Directory -Force -Path $outputRoot | Out-Null +} + +function Invoke-Step { + param( + [string]$Label, + [string]$ScriptPath, + [string[]]$Args + ) + + Write-Host "`n> $Label" -ForegroundColor Cyan + Write-Host " $ScriptPath $($Args -join ' ')" -ForegroundColor DarkGray + if (-not $DryRun) { + & $ScriptPath @Args + } +} + +if (-not $SkipSidecar) { + Invoke-Step "Publish Sidecar" $publishSidecar @( + "-Configuration", $Configuration, + "-Runtime", $Runtime + ) +} +else { + Write-Host "Skipping sidecar publish." -ForegroundColor DarkGray +} + +if (-not $SkipWeb) { + Invoke-Step "Build Web UI" $publishApp @( + "-Target", "web", + "-Configuration", $Configuration + ) +} +else { + Write-Host "Skipping web build." -ForegroundColor DarkGray +} + +if (-not $SkipWebGateway) { + Invoke-Step "Publish WebGateway" $publishGateway @( + "-Configuration", $Configuration, + "-Runtime", $Runtime + ) +} +else { + Write-Host "Skipping WebGateway publish." -ForegroundColor DarkGray +} + +if (-not $SkipTauri) { + Invoke-Step "Build Tauri Desktop App" $publishApp @( + "-Target", "tauri", + "-Configuration", $Configuration, + "-TauriBundles", "none" + ) + + $targetConfigDir = if ($Configuration -eq "Debug") { "debug" } else { "release" } + $tauriExePath = Join-Path $appRoot "src-tauri\\target\\$targetConfigDir\\journalapp.exe" + $stagedExePath = Join-Path $outputRoot "journalapp.exe" + + if (Test-Path $tauriExePath) { + if ($DryRun) { + Write-Host "Would copy: $tauriExePath -> $stagedExePath" -ForegroundColor Yellow + } + else { + Copy-Item -Force $tauriExePath $stagedExePath + Write-Host "Staged desktop exe: $stagedExePath" -ForegroundColor Green + } + } + else { + Write-Warning "Tauri exe not found at $tauriExePath" + } +} +else { + Write-Host "Skipping Tauri build." -ForegroundColor DarkGray +} diff --git a/scripts/publish-sidecar.ps1 b/scripts/publish-sidecar.ps1 new file mode 100644 index 0000000..ab2a855 --- /dev/null +++ b/scripts/publish-sidecar.ps1 @@ -0,0 +1,54 @@ +param( + [string]$Configuration = "Release", + [string]$Runtime = "win-x64" +) + +$commonScript = Join-Path $PSScriptRoot "script-common.ps1" +if (-not (Test-Path $commonScript)) { + throw "Missing helper script: $commonScript" +} +. $commonScript + +$repoRoot = Resolve-JournalRepoRoot -StartPath $PSScriptRoot +$csproj = Resolve-JournalSidecarProjectPath -RepoRoot $repoRoot +$outputDir = Join-Path $repoRoot "output" + +# Setup local dotnet environment (matches dotnet-min.ps1 logic) +Clear-JournalProxyEnv +Initialize-JournalDotnetEnv -RepoRoot $repoRoot + +Write-Host "Publishing Journal.Sidecar ($Configuration, $Runtime)..." -ForegroundColor Cyan +Write-Host "Using project: $csproj" -ForegroundColor DarkGray + +$publishArgs = @( + "publish", $csproj, + "-c", $Configuration, + "-r", $Runtime, + "--self-contained", + "-p:PublishSingleFile=true", + "-p:IncludeNativeLibrariesForSelfExtract=true", + "-p:RestoreIgnoreFailedSources=true", + "-p:NuGetAudit=false", + "-o", $outputDir +) + +& dotnet @publishArgs + +if ($LASTEXITCODE -eq 0) { + $binaryName = [System.IO.Path]::GetFileNameWithoutExtension($csproj) + $isWindowsRuntime = $Runtime -like "win-*" + $binaryFile = if ($isWindowsRuntime) { "$binaryName.exe" } else { $binaryName } + $binaryPath = Join-Path $outputDir $binaryFile + + Write-Host "`nPublish successful!" -ForegroundColor Green + if (Test-Path $binaryPath) { + Write-Host "Executable location: $binaryPath" -ForegroundColor Gray + } + else { + Write-Host "Output directory: $outputDir" -ForegroundColor Gray + } +} +else { + Write-Host "`nPublish failed with exit code $LASTEXITCODE" -ForegroundColor Red + exit $LASTEXITCODE +} diff --git a/scripts/publish-webgateway.ps1 b/scripts/publish-webgateway.ps1 new file mode 100644 index 0000000..b3e3322 --- /dev/null +++ b/scripts/publish-webgateway.ps1 @@ -0,0 +1,55 @@ +param( + [ValidateSet("Release", "Debug")] + [string]$Configuration = "Release", + [string]$Runtime = "win-x64", + [switch]$SelfContained, + [switch]$SkipWebAssets +) + +$commonScript = Join-Path $PSScriptRoot "script-common.ps1" +if (-not (Test-Path $commonScript)) { + throw "Missing helper script: $commonScript" +} +. $commonScript + +$repoRoot = Resolve-JournalRepoRoot -StartPath $PSScriptRoot +$gatewayProject = Resolve-JournalWebGatewayProjectPath -RepoRoot $repoRoot +$outputDir = Join-Path $repoRoot "output\webgateway" +$webBuildDir = Join-Path $repoRoot "Journal.App\build" +$webOutputDir = Join-Path $outputDir "wwwroot" + +Clear-JournalProxyEnv +Initialize-JournalDotnetEnv -RepoRoot $repoRoot + +Write-Host "Publishing Journal.WebGateway ($Configuration, $Runtime)..." -ForegroundColor Cyan +Write-Host "Project: $gatewayProject" -ForegroundColor DarkGray + +$publishArgs = @( + "publish", $gatewayProject, + "-c", $Configuration, + "-r", $Runtime, + "--self-contained", ($SelfContained.IsPresent.ToString().ToLowerInvariant()), + "-p:RestoreIgnoreFailedSources=true", + "-p:NuGetAudit=false", + "-o", $outputDir +) + +& dotnet @publishArgs +if ($LASTEXITCODE -ne 0) { + Write-Host "`nPublish failed with exit code $LASTEXITCODE" -ForegroundColor Red + exit $LASTEXITCODE +} + +if (-not $SkipWebAssets) { + if (Test-Path $webBuildDir) { + New-Item -ItemType Directory -Force -Path $webOutputDir | Out-Null + Copy-Item -Path (Join-Path $webBuildDir "*") -Destination $webOutputDir -Recurse -Force + Write-Host "Copied web assets to: $webOutputDir" -ForegroundColor Gray + } + else { + Write-Warning "Journal.App build output not found at $webBuildDir. Run ./scripts/publish-app.ps1 -Target web first." + } +} + +Write-Host "`nPublish successful." -ForegroundColor Green +Write-Host "Output directory: $outputDir" -ForegroundColor Gray diff --git a/scripts/run-webgateway.ps1 b/scripts/run-webgateway.ps1 new file mode 100644 index 0000000..eb2c6d6 --- /dev/null +++ b/scripts/run-webgateway.ps1 @@ -0,0 +1,48 @@ +param( + [ValidateSet("Release", "Debug")] + [string]$Configuration = "Release", + [string]$Urls = "http://0.0.0.0:5180", + [string]$ProjectRoot +) + +$commonScript = Join-Path $PSScriptRoot "script-common.ps1" +if (-not (Test-Path $commonScript)) { + throw "Missing helper script: $commonScript" +} +. $commonScript + +$repoRoot = Resolve-JournalRepoRoot -StartPath $PSScriptRoot +$gatewayProject = Resolve-JournalWebGatewayProjectPath -RepoRoot $repoRoot + +$effectiveProjectRoot = if ([string]::IsNullOrWhiteSpace($ProjectRoot)) { + $repoRoot +} +else { + [System.IO.Path]::GetFullPath($ProjectRoot) +} + +if (-not (Test-Path $effectiveProjectRoot)) { + throw "ProjectRoot does not exist: $effectiveProjectRoot" +} + +Clear-JournalProxyEnv +Initialize-JournalDotnetEnv -RepoRoot $repoRoot +$env:JOURNAL_PROJECT_ROOT = $effectiveProjectRoot + +Write-Host "Running Journal.WebGateway ($Configuration)..." -ForegroundColor Cyan +Write-Host "Project: $gatewayProject" -ForegroundColor DarkGray +Write-Host "URLs: $Urls" -ForegroundColor DarkGray +Write-Host "JOURNAL_PROJECT_ROOT: $effectiveProjectRoot" -ForegroundColor DarkGray + +$runArgs = @( + "run", + "--project", $gatewayProject, + "-c", $Configuration, + "--no-launch-profile", + "--urls", $Urls, + "-p:RestoreIgnoreFailedSources=true", + "-p:NuGetAudit=false" +) + +& dotnet @runArgs +exit $LASTEXITCODE diff --git a/scripts/script-common.ps1 b/scripts/script-common.ps1 new file mode 100644 index 0000000..eda3a90 --- /dev/null +++ b/scripts/script-common.ps1 @@ -0,0 +1,240 @@ +function Clear-JournalProxyEnv { + # Clear proxy/no-index env vars that commonly break package restore. + Remove-Item Env:HTTP_PROXY -ErrorAction SilentlyContinue + Remove-Item Env:HTTPS_PROXY -ErrorAction SilentlyContinue + Remove-Item Env:ALL_PROXY -ErrorAction SilentlyContinue + Remove-Item Env:http_proxy -ErrorAction SilentlyContinue + Remove-Item Env:https_proxy -ErrorAction SilentlyContinue + Remove-Item Env:all_proxy -ErrorAction SilentlyContinue + Remove-Item Env:GIT_HTTP_PROXY -ErrorAction SilentlyContinue + Remove-Item Env:GIT_HTTPS_PROXY -ErrorAction SilentlyContinue + Remove-Item Env:PIP_NO_INDEX -ErrorAction SilentlyContinue +} + +function Test-JournalRepoRootCandidate { + param( + [string]$Path + ) + + if ([string]::IsNullOrWhiteSpace($Path)) { + return $false + } + + $markers = @( + "Journal.slnx", + "scripts\dev-shell.ps1", + "Journal.Sidecar\Journal.Sidecar.csproj" + ) + + foreach ($marker in $markers) { + if (Test-Path (Join-Path $Path $marker)) { + return $true + } + } + + return $false +} + +function Resolve-JournalRepoRoot { + param( + [string]$StartPath + ) + + $candidateStarts = @() + if (-not [string]::IsNullOrWhiteSpace($StartPath)) { + $candidateStarts += $StartPath + } + + $currentPath = (Get-Location).Path + if (-not [string]::IsNullOrWhiteSpace($currentPath) -and ($candidateStarts -notcontains $currentPath)) { + $candidateStarts += $currentPath + } + + $override = $env:JOURNAL_REPO_ROOT + if (-not [string]::IsNullOrWhiteSpace($override)) { + $overridePath = [System.IO.Path]::GetFullPath($override) + if (Test-JournalRepoRootCandidate -Path $overridePath) { + return $overridePath + } + Write-Warning "JOURNAL_REPO_ROOT is set but does not look like this repo: $overridePath" + } + + if (Get-Command git -ErrorAction SilentlyContinue) { + foreach ($start in $candidateStarts) { + try { + $gitRoot = & git -C $start rev-parse --show-toplevel 2>$null + if ($? -and -not [string]::IsNullOrWhiteSpace($gitRoot)) { + $gitRootPath = [System.IO.Path]::GetFullPath($gitRoot.Trim()) + if (Test-JournalRepoRootCandidate -Path $gitRootPath) { + return $gitRootPath + } + } + } + catch { + } + } + } + + foreach ($start in $candidateStarts) { + $cursor = [System.IO.Path]::GetFullPath($start) + while (-not [string]::IsNullOrWhiteSpace($cursor)) { + if (Test-JournalRepoRootCandidate -Path $cursor) { + return $cursor + } + + $parent = [System.IO.Directory]::GetParent($cursor) + if ($null -eq $parent) { + break + } + + if ($parent.FullName -eq $cursor) { + break + } + + $cursor = $parent.FullName + } + } + + throw "Could not locate repository root. Set JOURNAL_REPO_ROOT to the repo path." +} + +function Initialize-JournalDotnetEnv { + param( + [Parameter(Mandatory = $true)] + [string]$RepoRoot + ) + + $dotnetCliHome = Join-Path $RepoRoot ".dotnet_home" + $nugetPackages = Join-Path $RepoRoot ".nuget\packages" + $nugetHttpCachePath = Join-Path $RepoRoot ".nuget\http-cache" + + $env:DOTNET_CLI_HOME = $dotnetCliHome + $env:NUGET_PACKAGES = $nugetPackages + $env:NUGET_HTTP_CACHE_PATH = $nugetHttpCachePath + $env:DOTNET_SKIP_FIRST_TIME_EXPERIENCE = "1" + $env:DOTNET_ADD_GLOBAL_TOOLS_TO_PATH = "0" + $env:DOTNET_GENERATE_ASPNET_CERTIFICATE = "0" + $env:DOTNET_CLI_TELEMETRY_OPTOUT = "1" + $env:NUGET_CERT_REVOCATION_MODE = "offline" + + New-Item -ItemType Directory -Force -Path $dotnetCliHome, $nugetPackages, $nugetHttpCachePath | Out-Null +} + +function Initialize-JournalPipEnv { + param( + [Parameter(Mandatory = $true)] + [string]$RepoRoot + ) + + $pipCacheDir = Join-Path $RepoRoot ".pip\cache" + $pipTempDir = Join-Path $RepoRoot ".tmp\pip-temp" + + $env:PIP_CACHE_DIR = $pipCacheDir + $env:TEMP = $pipTempDir + $env:TMP = $pipTempDir + $env:PIP_DISABLE_PIP_VERSION_CHECK = "1" + $env:PIP_DEFAULT_TIMEOUT = "30" + $env:PIP_RETRIES = "2" + + New-Item -ItemType Directory -Force -Path $pipCacheDir, $pipTempDir | Out-Null +} + +function Initialize-JournalHuggingFaceEnv { + param( + [Parameter(Mandatory = $true)] + [string]$RepoRoot + ) + + $hfHome = Join-Path $RepoRoot ".cache\huggingface" + $hfHubCache = Join-Path $hfHome "hub" + + $env:HF_HOME = $hfHome + $env:HUGGINGFACE_HUB_CACHE = $hfHubCache + $env:HF_HUB_DISABLE_SYMLINKS_WARNING = "1" + + New-Item -ItemType Directory -Force -Path $hfHubCache | Out-Null +} + +function Resolve-JournalSidecarProjectPath { + param( + [Parameter(Mandatory = $true)] + [string]$RepoRoot + ) + + $defaultPath = Join-Path $RepoRoot "Journal.Sidecar\Journal.Sidecar.csproj" + if (Test-Path $defaultPath) { + return (Resolve-Path $defaultPath).Path + } + + $exactMatches = @(Get-ChildItem -Path $RepoRoot -Recurse -File -Filter "Journal.Sidecar.csproj" -ErrorAction SilentlyContinue) + if ($exactMatches.Count -eq 1) { + return $exactMatches[0].FullName + } + if ($exactMatches.Count -gt 1) { + $matchList = ($exactMatches | ForEach-Object { $_.FullName }) -join "; " + throw "Found multiple Journal.Sidecar.csproj files: $matchList" + } + + $fallbackMatches = @(Get-ChildItem -Path $RepoRoot -Recurse -File -Filter "*.csproj" -ErrorAction SilentlyContinue | Where-Object { + $_.BaseName -match "(?i)sidecar" -or $_.DirectoryName -match "(?i)sidecar" + }) + if ($fallbackMatches.Count -eq 1) { + return $fallbackMatches[0].FullName + } + if ($fallbackMatches.Count -gt 1) { + $matchList = ($fallbackMatches | ForEach-Object { $_.FullName }) -join "; " + throw "Found multiple sidecar-like csproj files: $matchList" + } + + throw "Could not locate a sidecar project file under: $RepoRoot" +} + +function Resolve-JournalAppRoot { + param( + [Parameter(Mandatory = $true)] + [string]$RepoRoot + ) + + $defaultPath = Join-Path $RepoRoot "Journal.App" + $defaultPackageJson = Join-Path $defaultPath "package.json" + $defaultTauriConfig = Join-Path $defaultPath "src-tauri\tauri.conf.json" + if ((Test-Path $defaultPackageJson) -and (Test-Path $defaultTauriConfig)) { + return (Resolve-Path $defaultPath).Path + } + + $packageJsonMatches = @(Get-ChildItem -Path $RepoRoot -Recurse -File -Filter "package.json" -ErrorAction SilentlyContinue | Where-Object { + Test-Path (Join-Path $_.DirectoryName "src-tauri\tauri.conf.json") + }) + if ($packageJsonMatches.Count -eq 1) { + return $packageJsonMatches[0].DirectoryName + } + if ($packageJsonMatches.Count -gt 1) { + $matchList = ($packageJsonMatches | ForEach-Object { $_.DirectoryName }) -join "; " + throw "Found multiple Tauri app roots under repo: $matchList" + } + + throw "Could not locate Journal.App root under: $RepoRoot" +} + +function Resolve-JournalWebGatewayProjectPath { + param( + [Parameter(Mandatory = $true)] + [string]$RepoRoot + ) + + $defaultPath = Join-Path $RepoRoot "Journal.WebGateway\Journal.WebGateway.csproj" + if (Test-Path $defaultPath) { + return (Resolve-Path $defaultPath).Path + } + + $exactMatches = @(Get-ChildItem -Path $RepoRoot -Recurse -File -Filter "Journal.WebGateway.csproj" -ErrorAction SilentlyContinue) + if ($exactMatches.Count -eq 1) { + return $exactMatches[0].FullName + } + if ($exactMatches.Count -gt 1) { + $matchList = ($exactMatches | ForEach-Object { $_.FullName }) -join "; " + throw "Found multiple Journal.WebGateway.csproj files: $matchList" + } + + throw "Could not locate Journal.WebGateway.csproj under: $RepoRoot" +} diff --git a/sdt-workspace.json b/sdt-workspace.json new file mode 100644 index 0000000..0df7071 --- /dev/null +++ b/sdt-workspace.json @@ -0,0 +1,10 @@ +{ + "name": "Stan's Dev Projects", + "projects": [ + { + "name": "Project Journal", + "description": "Encrypted journal — Tauri desktop + C#/.NET backend + SvelteKit UI", + "path": "journal" + } + ] +} \ No newline at end of file