mirror of
https://github.com/Dasemu/Logseq-SemiLinear-Graph.git
synced 2026-11-26 15:26:18 +00:00
chore: bootstrap Claude setup
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
1 parent
151d34a0e1
commit
9ff19e49e8
10 files changed
+197
-19
No files matched your search
@@ -0,0 +1 @@
|
|||||||
|
2
|
||||||
@@ -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"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -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.
|
||||||
@@ -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
|
||||||
@@ -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
|
||||||
@@ -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.
|
||||||
@@ -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.)
|
||||||
@@ -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 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.
|
the line; more peripheral notes drift further up.
|
||||||
|
|
||||||
## How it works
|
See [docs/architecture.md](docs/architecture.md) for how the generator and viewer work.
|
||||||
|
|
||||||
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.
|
|
||||||
|
|
||||||
## Usage
|
## 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
|
`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`).
|
`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
|
## Privacy
|
||||||
|
|
||||||
`graph_data.json` and `graph_view.html` are generated artifacts that contain the actual
|
`graph_data.json` and `graph_view.html` are generated artifacts that contain the actual
|
||||||
|
|||||||
@@ -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.
|
||||||
Reference in new issue
Block a user