From 9ff19e49e887d376ee27b4919ad8b01b02ed4bad Mon Sep 17 00:00:00 2001 From: Dasemu Date: Sun, 18 Oct 2026 15:08:51 +0200 Subject: [PATCH] chore: bootstrap Claude setup Co-Authored-By: Claude Sonnet 5 --- .claude/bootstrap-version | 1 + .claude/settings.json | 25 ++++++++++++++ .env.example | 3 ++ .github/workflows/ci.yml | 22 ++++++++++++ .github/workflows/version.yml | 65 +++++++++++++++++++++++++++++++++++ CLAUDE.md | 43 +++++++++++++++++++++++ LESSONS.md | 6 ++++ README.md | 20 +---------- VERSION | 1 + docs/architecture.md | 30 ++++++++++++++++ 10 files changed, 197 insertions(+), 19 deletions(-) create mode 100644 .claude/bootstrap-version create mode 100644 .claude/settings.json create mode 100644 .env.example create mode 100644 .github/workflows/ci.yml create mode 100644 .github/workflows/version.yml create mode 100644 CLAUDE.md create mode 100644 LESSONS.md create mode 100644 VERSION create mode 100644 docs/architecture.md 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/settings.json b/.claude/settings.json new file mode 100644 index 0000000..8eb5adf --- /dev/null +++ b/.claude/settings.json @@ -0,0 +1,25 @@ +{ + "hooks": { + "PostToolUse": [ + { + "matcher": "Edit|Write", + "hooks": [ + { + "type": "command", + "command": "file=$(cat | python3 -c 'import json,sys; print(json.load(sys.stdin).get(\"tool_input\",{}).get(\"file_path\",\"\"))'); case \"$file\" in *.py) python3 -m py_compile \"$file\" ;; esac" + } + ] + } + ], + "Stop": [ + { + "hooks": [ + { + "type": "command", + "command": "cd \"$CLAUDE_PROJECT_DIR\" && python3 -m py_compile build_html.py parse_graph.py" + } + ] + } + ] + } +} diff --git a/.env.example b/.env.example new file mode 100644 index 0000000..881be14 --- /dev/null +++ b/.env.example @@ -0,0 +1,3 @@ +# No environment variables are required by this project. +# parse_graph.py and build_html.py read their paths from constants at the top of +# each file (NOTAS, DATA_PATH, D3_PATH, OUT_PATH) instead of env vars. diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..022ea1e --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,22 @@ +name: CI + +on: + pull_request: + branches: [development] + push: + branches: [development, main] + +jobs: + check: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - uses: actions/setup-python@v5 + with: + python-version: "3.x" + + # No linter or test suite is set up in this repo yet; this is a syntax check + # that stands in for lint + test until one is added. + - name: Syntax check + run: python3 -m py_compile build_html.py parse_graph.py diff --git a/.github/workflows/version.yml b/.github/workflows/version.yml new file mode 100644 index 0000000..e6a1b1a --- /dev/null +++ b/.github/workflows/version.yml @@ -0,0 +1,65 @@ +name: Version + +on: + push: + branches: [development, main] + +permissions: + contents: write + +jobs: + bump: + if: github.actor != 'github-actions[bot]' + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + token: ${{ secrets.GITHUB_TOKEN }} + + - name: Configure git + run: | + git config user.name "github-actions[bot]" + git config user.email "github-actions[bot]@users.noreply.github.com" + + - name: Bump version + id: bump + run: | + set -e + current=$(cat VERSION) + IFS='.' read -r major minor patch <<< "$current" + + if [ "${{ github.ref_name }}" = "development" ]; then + patch=$((patch + 1)) + else + # push to main: MINOR bump only if every commit on this push came from + # development (i.e. this is a development -> main merge), otherwise it's + # a direct hotfix push and gets a PATCH bump. + merge_base=$(git merge-base origin/development HEAD 2>/dev/null || echo "") + if [ -n "$merge_base" ] && [ "$merge_base" = "$(git rev-parse HEAD)" ]; then + patch=$((patch + 1)) + elif [ -n "$merge_base" ] && git log --first-parent -1 --pretty=%P HEAD | grep -q "$merge_base"; then + minor=$((minor + 1)) + patch=0 + else + patch=$((patch + 1)) + fi + fi + + new="$major.$minor.$patch" + echo "$new" > VERSION + echo "new_version=$new" >> "$GITHUB_OUTPUT" + + - name: Commit version bump + run: | + git add VERSION + git commit -m "chore(release): v${{ steps.bump.outputs.new_version }} [skip ci]" + git push origin HEAD:${{ github.ref_name }} + + - name: Merge main back into development + if: github.ref_name == 'main' + run: | + git fetch origin development + git checkout development + git merge --no-edit origin/main + git push origin development diff --git a/CLAUDE.md b/CLAUDE.md new file mode 100644 index 0000000..11d243a --- /dev/null +++ b/CLAUDE.md @@ -0,0 +1,43 @@ +# CLAUDE.md + +## Overview + +Two standalone Python 3 scripts that turn a Logseq graph into a static, interactive +timeline visualization: `parse_graph.py` extracts the graph into `graph_data.json`, +`build_html.py` renders it into a self-contained `graph_view.html` (D3.js vendored, +no network dependencies, no external Python packages). + +## Commands + +- Run the generator: `python3 parse_graph.py /path/to/graph_data.json` +- Build the viewer: `python3 build_html.py` +- Syntax check (stand-in for lint/test, no linter or test suite in this repo): + `python3 -m py_compile build_html.py parse_graph.py` + +## Architecture + +See [docs/architecture.md](docs/architecture.md) for the parse → build pipeline and +viewer controls. + +## Conventions + +- No external dependencies (stdlib only). Don't add any without discussing it first. +- Both scripts default to `~/Notas`; path constants live at the top of each file + (`NOTAS`, `DATA_PATH`, `D3_PATH`, `OUT_PATH`). + +## Workflow quirks + +- `graph_data.json` and `graph_view.html` are generated, personal, and gitignored — + never commit them. +- No `development` branch exists yet; until it is created, treat `main` as the base + for PRs. + +## Deployment + +None — this produces a static HTML file to open locally or serve with +`python3 -m http.server`. + +## Gotchas + +- There is no linter, formatter, or test suite installed in this repo; CI and hooks + only run a `py_compile` syntax check. diff --git a/LESSONS.md b/LESSONS.md new file mode 100644 index 0000000..3fd65ca --- /dev/null +++ b/LESSONS.md @@ -0,0 +1,6 @@ +# Lessons + +Recurring mistakes and how to avoid them. Read before starting a task; add an entry +whenever the same mistake happens twice. + +(No entries yet.) diff --git a/README.md b/README.md index 07da8b0..9732c4b 100644 --- a/README.md +++ b/README.md @@ -8,15 +8,7 @@ rest of the pages ("notes") float above it, positioned by a force simulation The result is a kind of timeline: the more connected a note is, the closer it stays to the line; more peripheral notes drift further up. -## How it works - -1. **`parse_graph.py`** walks the `journals/` and `pages/` folders of a Logseq graph, - extracts `[[...]]` links and `#tags`, resolves journal-date links (format - `[[Apr 27th, 2026]]`) against the `yyyy_MM_dd.md` files, and dumps everything to - `graph_data.json` (nodes, edges, and each node's degree). -2. **`build_html.py`** takes `graph_data.json` and generates `graph_view.html`: a - self-contained page (D3.js vendored in `vendor/d3.min.js`, no network dependencies) - with the interactive visualizer. +See [docs/architecture.md](docs/architecture.md) for how the generator and viewer work. ## Usage @@ -29,16 +21,6 @@ By default both scripts read the graph from `~/Notas` (edit the `NOTAS`, `DATA_PATH`/`OUT_PATH` constants at the top of each script to point elsewhere). Open `graph_view.html` in a browser (or serve it with `python3 -m http.server`). -## Viewer - -- **Zoom / pan**: mouse wheel and drag on the background. -- **Drag a node**: pins it at that position. -- **Search box**: highlights notes by name. -- **"Layout forces" panel**: live controls for the simulation — vertical spread, - repulsion between notes, attraction to journals, cohesion between related notes, - distance to journal, and anti-collision padding. Buttons to reheat the simulation or - restore the defaults. - ## Privacy `graph_data.json` and `graph_view.html` are generated artifacts that contain the actual 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/architecture.md b/docs/architecture.md new file mode 100644 index 0000000..9953f84 --- /dev/null +++ b/docs/architecture.md @@ -0,0 +1,30 @@ +# Architecture + +## How it works + +1. **`parse_graph.py`** walks the `journals/` and `pages/` folders of a Logseq graph, + extracts `[[...]]` links and `#tags`, resolves journal-date links (format + `[[Apr 27th, 2026]]`) against the `yyyy_MM_dd.md` files, and dumps everything to + `graph_data.json` (nodes, edges, and each node's degree). +2. **`build_html.py`** takes `graph_data.json` and generates `graph_view.html`: a + self-contained page (D3.js vendored in `vendor/d3.min.js`, no network dependencies) + with the interactive visualizer. + +Both scripts default to reading the graph from `~/Notas`; edit the `NOTAS`, +`DATA_PATH`/`OUT_PATH` constants at the top of each script to point elsewhere. + +## Viewer + +- **Zoom / pan**: mouse wheel and drag on the background. +- **Drag a node**: pins it at that position. +- **Search box**: highlights notes by name. +- **"Layout forces" panel**: live controls for the simulation — vertical spread, + repulsion between notes, attraction to journals, cohesion between related notes, + distance to journal, and anti-collision padding. Buttons to reheat the simulation or + restore the defaults. + +## Generated artifacts + +`graph_data.json` and `graph_view.html` contain the actual content of a personal +Logseq graph (page names, dates, note titles) and are excluded via `.gitignore` — +they are never committed. Only the generator code is versioned.