commit 7f5c7738e526b2677d254d75625dbceefe96ed18 Author: Dasemu Date: Wed Oct 21 03:16:48 2026 +0200 chore: bootstrap Claude setup Co-Authored-By: Claude Opus 5.5 diff --git a/.claude/bootstrap-version b/.claude/bootstrap-version new file mode 100644 index 0000000..0cfbf08 --- /dev/null +++ b/.claude/bootstrap-version @@ -0,0 +1 @@ +2 diff --git a/.claude/hooks/format.sh b/.claude/hooks/format.sh new file mode 100755 index 0000000..4618fe9 --- /dev/null +++ b/.claude/hooks/format.sh @@ -0,0 +1,9 @@ +#!/usr/bin/env bash +# PostToolUse (Edit/Write): format the changed file. Never blocks. +f=$(jq -r '.tool_input.file_path // empty' 2>/dev/null) +[ -n "$f" ] && [ -f "$f" ] || exit 0 +case "$f" in + *.rs) command -v rustfmt >/dev/null && rustfmt --edition 2021 -q "$f" 2>/dev/null ;; + *.dart) command -v dart >/dev/null && dart format -o write "$f" >/dev/null 2>&1 ;; +esac +exit 0 diff --git a/.claude/hooks/stop-check.sh b/.claude/hooks/stop-check.sh new file mode 100755 index 0000000..f78831e --- /dev/null +++ b/.claude/hooks/stop-check.sh @@ -0,0 +1,12 @@ +#!/usr/bin/env bash +# Stop hook: lint + tests must pass before the turn ends (exit 2 blocks). +cd "$(git rev-parse --show-toplevel 2>/dev/null || pwd)" || exit 0 +fail() { echo "$1 failed:" >&2; echo "$2" | tail -40 >&2; exit 2; } +if [ -f Cargo.toml ]; then + out=$(cargo clippy --workspace --all-targets -q -- -D warnings 2>&1) || fail clippy "$out" + out=$(cargo test --workspace -q 2>&1) || fail "cargo test" "$out" +fi +if [ -f app/pubspec.yaml ] && command -v flutter >/dev/null; then + out=$(cd app && flutter analyze 2>&1) || fail "flutter analyze" "$out" +fi +exit 0 diff --git a/.claude/settings.json b/.claude/settings.json new file mode 100644 index 0000000..87a80eb --- /dev/null +++ b/.claude/settings.json @@ -0,0 +1,15 @@ +{ + "hooks": { + "PostToolUse": [ + { + "matcher": "Edit|Write", + "hooks": [{ "type": "command", "command": "\"$CLAUDE_PROJECT_DIR\"/.claude/hooks/format.sh" }] + } + ], + "Stop": [ + { + "hooks": [{ "type": "command", "command": "\"$CLAUDE_PROJECT_DIR\"/.claude/hooks/stop-check.sh", "timeout": 900 }] + } + ] + } +} diff --git a/.env.example b/.env.example new file mode 100644 index 0000000..9d7a636 --- /dev/null +++ b/.env.example @@ -0,0 +1,10 @@ +# Synapse server configuration (names only; never commit real values). + +# Address the sync server listens on, e.g. 127.0.0.1:7878 +SYNAPSE_BIND= +# Directory holding server-side graphs and blobs +SYNAPSE_DATA_DIR= +# Bearer token clients must present (generate a long random string) +SYNAPSE_AUTH_TOKEN= +# Log filter, e.g. info,synapse_server=debug +RUST_LOG= diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..2dca6f4 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,42 @@ +name: ci +on: + pull_request: + branches: [development] + push: + branches: [development, main] + +jobs: + rust: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: dtolnay/rust-toolchain@stable + with: + components: clippy, rustfmt + - uses: Swatinem/rust-cache@v2 + - name: Lint + run: | + cargo fmt --all -- --check + cargo clippy --workspace --all-targets -- -D warnings + - name: Test + run: cargo test --workspace + + flutter: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: subosito/flutter-action@v2 + if: hashFiles('app/pubspec.yaml') != '' + with: + channel: stable + cache: true + - name: Lint + if: hashFiles('app/pubspec.yaml') != '' + working-directory: app + run: | + flutter pub get + flutter analyze + - name: Test + if: hashFiles('app/test/**') != '' + working-directory: app + run: flutter test diff --git a/.github/workflows/version.yml b/.github/workflows/version.yml new file mode 100644 index 0000000..5841f7d --- /dev/null +++ b/.github/workflows/version.yml @@ -0,0 +1,50 @@ +name: version +on: + push: + branches: [development, main] + +permissions: + contents: write + +jobs: + bump: + if: >- + !contains(github.event.head_commit.message, '[skip ci]') && + github.actor != 'github-actions[bot]' && github.actor != 'gitea-actions' + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + - name: Bump version + env: + BEFORE: ${{ github.event.before }} + run: | + set -euo pipefail + git config user.name "version-bot" + git config user.email "version-bot@noreply.local" + branch="$GITHUB_REF_NAME" + IFS=. read -r MA MI PA < VERSION + if [ "$branch" = development ]; then + PA=$((PA + 1)) + else + git fetch origin development + zero=0000000000000000000000000000000000000000 + # MINOR bump only if every non-merge commit in this push is already on development. + if [ -n "$BEFORE" ] && [ "$BEFORE" != "$zero" ] && + [ -z "$(git rev-list --no-merges "$BEFORE..HEAD" --not origin/development)" ]; then + MI=$((MI + 1)); PA=0 + else + PA=$((PA + 1)) + fi + fi + new="$MA.$MI.$PA" + echo "$new" > VERSION + git commit -am "chore(release): v$new [skip ci]" + git push origin HEAD:"$branch" + if [ "$branch" = main ]; then + main_sha=$(git rev-parse HEAD) + git checkout -B development origin/development + git merge --no-ff -m "chore: merge main into development [skip ci]" "$main_sha" + git push origin development + fi diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..ec8d301 --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +/target +.env +.claude/settings.local.json diff --git a/CLAUDE.md b/CLAUDE.md new file mode 100644 index 0000000..fc9c60f --- /dev/null +++ b/CLAUDE.md @@ -0,0 +1,46 @@ +# Synapse + +## Overview +Native "second brain" notes app (Logseq-like outliner with linked pages and journals) for +Android, Linux and Windows. Rust core shared by a Flutter client (via flutter_rust_bridge) +and an optional self-hosted sync server. Local-only (standalone graph) or client-server +(online graph). No webviews. + +## Commands +- Format: `cargo fmt --all` (Rust), `dart format app/` (Flutter) +- Lint: `cargo clippy --workspace --all-targets -- -D warnings`, `cd app && flutter analyze` +- Test: `cargo test --workspace`, `cd app && flutter test` +- Run server: `cargo run -p synapse-server` +- Run app: `cd app && flutter run -d linux` (or `-d windows`, an Android device) +- Regenerate FFI bindings: `cd app && flutter_rust_bridge_codegen generate` + +## Architecture +Cargo workspace under `crates/`, Flutter app under `app/`. Details in `docs/architecture.md`, +roadmap in `docs/plan.md`. +- `synapse-core`: domain model (blocks, pages, journals, typed links), SQLite store, blob store. +- `synapse-search`: full-text (tantivy) + vector index; auto-link suggestions. +- `synapse-import`: Logseq graph importer (pages, journals, assets). +- `synapse-ai`: provider-agnostic LLM/embeddings clients (user-supplied API keys). +- `synapse-history`: automatic git-like snapshots of the graph. +- `synapse-caldav`: CalDAV calendar + VTODO tasks. +- `synapse-sync` / `synapse-server`: client-server protocol and axum server. +- `synapse-ffi`: the only API surface exposed to Flutter. + +## Conventions +- The Flutter app never touches storage directly; everything goes through `synapse-ffi`. +- Core crates are sync-free of UI concerns and must compile for Android (no desktop-only deps + in `synapse-core`). +- IDs are UUIDv7 (time-ordered). Journals are keyed by local date `YYYY-MM-DD`. +- Heavy files go to the content-addressed blob store, never into SQLite rows. +- Version lives in the root `VERSION` file (bumped by CI only). + +## Workflow quirks +- Hooks: `.claude/hooks/format.sh` formats after edits; `.claude/hooks/stop-check.sh` runs + clippy + tests before a turn ends. + +## Deployment +- Server: see `docs/server.md` (LXC/VPS + systemd, per the `web-deploy` skill). + +## Gotchas +- Logseq graphs mix `.md` and `.org`; the importer only parses Markdown fully and keeps org + files as raw blocks. diff --git a/LESSONS.md b/LESSONS.md new file mode 100644 index 0000000..8592c36 --- /dev/null +++ b/LESSONS.md @@ -0,0 +1,3 @@ +# Lessons + +Recurring mistakes and how to avoid them. Add an entry when a mistake repeats. diff --git a/README.md b/README.md new file mode 100644 index 0000000..11bf054 --- /dev/null +++ b/README.md @@ -0,0 +1,14 @@ +# Synapse + +A native, brain-like second brain: an outliner with linked pages, temporally chained journals, +semantic search, AI assistance and a self-hostable sync server. Runs natively on Android, +Linux and Windows (Rust core + Flutter UI, no webviews). + +## Quick start + +```bash +cargo test --workspace +cd app && flutter run -d linux +``` + +See [docs/](docs/README.md) for the plan and architecture. diff --git a/VERSION b/VERSION new file mode 100644 index 0000000..6e8bf73 --- /dev/null +++ b/VERSION @@ -0,0 +1 @@ +0.1.0 diff --git a/docs/README.md b/docs/README.md new file mode 100644 index 0000000..77b56e4 --- /dev/null +++ b/docs/README.md @@ -0,0 +1,5 @@ +# Docs + +- [plan.md](plan.md): product scope and roadmap. +- [architecture.md](architecture.md): crates, data model, storage and sync design. +- [server.md](server.md): running and deploying the sync server.