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/lint-changed.sh b/.claude/hooks/lint-changed.sh new file mode 100755 index 0000000..749a7b6 --- /dev/null +++ b/.claude/hooks/lint-changed.sh @@ -0,0 +1,29 @@ +#!/usr/bin/env bash +# PostToolUse hook: lint/format the file that was just edited or written. +# Reads the hook JSON payload from stdin and dispatches by extension. +# Best-effort: missing tooling is reported but never blocks the edit. +set -u + +payload="$(cat)" +file_path="$(printf '%s' "$payload" | sed -n 's/.*"file_path"[[:space:]]*:[[:space:]]*"\([^"]*\)".*/\1/p' | head -n1)" + +[ -z "$file_path" ] && exit 0 +[ -f "$file_path" ] || exit 0 + +repo_root="$(cd "$(dirname "$0")/../.." && pwd)" +cd "$repo_root" || exit 0 + +case "$file_path" in + *.clj|*.cljs|*.cljc) + if command -v clojure >/dev/null 2>&1; then + clojure -M:clj-kondo --lint "$file_path" --cache false || true + fi + ;; + libs/*.ts|libs/*.tsx|libs/*.js) + if [ -f "libs/node_modules/.bin/prettier" ]; then + (cd libs && node_modules/.bin/prettier --write "${file_path#libs/}") || true + fi + ;; +esac + +exit 0 diff --git a/.claude/settings.json b/.claude/settings.json new file mode 100644 index 0000000..f4677f7 --- /dev/null +++ b/.claude/settings.json @@ -0,0 +1,25 @@ +{ + "hooks": { + "PostToolUse": [ + { + "matcher": "Edit|Write", + "hooks": [ + { + "type": "command", + "command": "bash .claude/hooks/lint-changed.sh" + } + ] + } + ], + "Stop": [ + { + "hooks": [ + { + "type": "command", + "command": "bb dev:lint-and-test" + } + ] + } + ] + } +} diff --git a/.env.example b/.env.example new file mode 100644 index 0000000..a33fe7e --- /dev/null +++ b/.env.example @@ -0,0 +1,13 @@ +# Build-time environment variables read by the build/CLI scripts. +# No runtime secrets are required to build or run this repo locally. + +# Standard Node environment ("development" | "production"). +NODE_ENV= + +# Set to "1" to skip bundling the OCaml CLI into desktop releases +# (used in CI; see .gitea/workflows/build.yml). +LOGSEQ_SKIP_CLI_BUNDLE= + +# Override the resolved CLI package version/build metadata (optional). +LOGSEQ_BUILD_TIME= +LOGSEQ_REVISION= diff --git a/.gitea/workflows/ci.yml b/.gitea/workflows/ci.yml new file mode 100644 index 0000000..beef106 --- /dev/null +++ b/.gitea/workflows/ci.yml @@ -0,0 +1,41 @@ +name: CI + +# Lint + unit tests, using the same `bb dev:lint-and-test` task documented in +# CLAUDE.md / AGENTS.md. Runs on pushes and on PRs against main (no +# `development` branch exists in this repo). +on: + push: + branches: + - main + pull_request: + branches: + - main + +jobs: + lint-and-test: + name: Lint and test + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - uses: actions/setup-java@v4 + with: + distribution: temurin + java-version: "21" + + - uses: DeLaGuardo/setup-clojure@13.1 + with: + cli: 1.12.5.1664 + bb: latest + + - uses: actions/setup-node@v4 + with: + node-version: "22" + cache: pnpm + + - uses: pnpm/action-setup@v4 + + - run: pnpm install --frozen-lockfile + + - name: Lint and test + run: bb dev:lint-and-test diff --git a/.gitignore b/.gitignore index 638365b..164c3bc 100644 --- a/.gitignore +++ b/.gitignore @@ -27,6 +27,7 @@ cli/_opam/ # Env / secrets .env .env.* +!.env.example *.pem *.key @@ -35,7 +36,7 @@ cli/_opam/ *.log .vscode/ .idea/ -.claude/ +.claude/settings.local.json # Python sidecar sidecar/.venv/ diff --git a/CLAUDE.md b/CLAUDE.md new file mode 100644 index 0000000..d4b6adc --- /dev/null +++ b/CLAUDE.md @@ -0,0 +1,48 @@ +# CLAUDE.md + +## Overview +Synapse is a personal fork of Logseq (DB-graph version): a self-hosted outliner/PKM with a +single daemon (`db-worker-node`) holding the authoritative graph, served to thin web, +Electron desktop, and Capacitor mobile (iOS/Android) clients over HTTP/WebSocket. Core app is +ClojureScript (shadow-cljs); supporting tools (CLI, scripts, libs) are Node/TypeScript, plus +an OCaml CLI companion and a Python embedding sidecar. + +## Commands +- Lint + unit tests: `bb dev:lint-and-test` +- Single test: `bb dev:test -v ` +- ClojureScript lint only: `pnpm cljs:lint` (clj-kondo) +- Unit tests only: `pnpm test` (compiles then runs cljs tests) +- App E2E: from `clj-e2e/`, `bb test` +- CLI E2E: `bb -f cli-e2e/bb.edn test --skip-build` +- Dev build (watch): `pnpm dev` / `pnpm watch` (web) / `pnpm electron-watch` / `pnpm mobile-watch` +- Release build: `pnpm release`, `pnpm release-electron`, `pnpm release-mobile` + +## Architecture +See `AGENTS.md` for detailed engineering conventions and +`docs/agent-guide/implemented/architecture/2026-08-24-logseq-runtime-and-engineering-guide.md` +for runtime/sync/CLI/rendering/search architecture. Workspace packages: `deps/*` (common, +db, db-sync, outliner, graph-parser, publish(ing), shui), `cli/` (OCaml CLI), `libs/` +(published JS/TS SDK), `scripts/`, `sidecar/` (Python embedding server). + +## Conventions +Full conventions live in `AGENTS.md` (coding style, i18n, testing, commit/PR rules) — read it +first; it takes precedence over this file for code changes. Directory-specific `AGENTS.md` +files override the root one. + +## Workflow quirks +- Repo-local skills live under `.agents/skills/`; load the matching `SKILL.md` before editing + (i18n changes mandatorily require `.agents/skills/logseq-i18n/SKILL.md`). +- No `development` branch here: work on a task branch off `main`, PR into `main`. +- No local formatter is wired for the main ClojureScript app; `libs/` uses Prettier for its + own TS code. + +## Deployment +Not a typical always-on web service: ships as Electron desktop, Capacitor mobile apps, and a +self-hosted `db-worker-node` daemon. See `deploy/logseq-daemon.service` (systemd unit) and +`deploy/Caddyfile` (reverse proxy) for the daemon-side deployment. + +## Gotchas +- `cli/` (OCaml/dune CLI) is not built in CI yet (`LOGSEQ_SKIP_CLI_BUNDLE=1` in + `.gitea/workflows/build.yml`); don't assume CLI release steps run there. +- This repo uses Gitea (git.zenvairo.es), not GitHub: CI workflows live in + `.gitea/workflows/`, matching the existing `build.yml`. diff --git a/LESSONS.md b/LESSONS.md new file mode 100644 index 0000000..55176bc --- /dev/null +++ b/LESSONS.md @@ -0,0 +1,10 @@ +# LESSONS.md + +Recurring mistakes and how to avoid them. Read before starting work; add an entry whenever a +mistake repeats. + +## Format +- **Mistake**: what went wrong. +- **Fix**: what to do instead. + +(No entries yet.)