Skip to content

Commit 39ec3e2

Browse files
authored
Merge pull request #15 from LD4P/agents-md-update
Add AGENTS.md and consolidate documentation
2 parents ea202d1 + 2655726 commit 39ec3e2

2 files changed

Lines changed: 57 additions & 69 deletions

File tree

‎AGENTS.md‎

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
# AGENTS.md
2+
3+
This file provides guidance to AI agents when working with code in this repository.
4+
5+
## Project Overview
6+
7+
Browser-only RDF graph editor (no backend/server): a React + React Flow canvas on top of an in-browser Python RDF engine. All RDF parsing, SHACL validation, and graph mutation happens in Python (rdflib/pyshacl), running client-side via PyScript/Pyodide — the two toolchains are connected through a JS↔Python bridge, not parallel/unconnected.
8+
9+
Hosted at https://ld4p.github.io/graph-editor/, deployed via `.github/workflows/deploy-pages.yml`.
10+
11+
## Architecture
12+
13+
- `public/py/rdf_service.py` — the RDF engine. Holds the single in-memory `rdflib.Graph`, undo/redo history, and all mutation functions (add/delete/rename node, add/delete edge, add/update/delete property, SHACL validation, namespace management). Every mutating function snapshots history first, then returns `_project(graph)`: a plain-dict `{nodes, edges}` projection of the graph for the UI. When run under PyScript, functions are registered on `sync.*` so JS can call them directly.
14+
- `src/lib/pyBridge.ts` — lazily boots the Pyodide worker (via PyScript's `PyWorker`, loaded from `public/py/pyscript.toml`) and exposes typed async wrappers around each `sync.*` function.
15+
- `src/model/rdfGraphModel.ts` — TS types mirroring the Python projection shapes (`RdfProjection`, `RdfNode`, `RdfEdge`, SHACL/namespace result types).
16+
- `src/state/graphStore.ts` (zustand) — holds the current projection, node positions, selection, and undo/redo status; `setProjection` also fires autosave to `localStorage`.
17+
- `src/lib/layout.ts` — lays out the projection as React Flow nodes/edges, with either the force-directed layout (default) or dagre, chosen by `layoutMode` in the store. Manually-dragged positions from the store are always kept.
18+
- `src/lib/forceLayout.ts` — Springy-style force simulation used by the default layout. CBD groups stay clustered, an overlap pass keeps cards and group boxes apart, dragged nodes stay pinned, and each run warm-starts from the previous `settled` positions (kept in `GraphCanvas`) so edits don't reshuffle the graph.
19+
- `src/components/` — `GraphCanvas.tsx` (React Flow canvas), `ResourceNode.tsx` / `ResourcePredicateEdge.tsx` (custom node/edge renderers with inline editing), `CbdGroupNode.tsx` (CBD group boxes), `Inspector.tsx`, `NamespacePanel.tsx`, `ValidationPanel.tsx`, `Toolbar.tsx`, `Dialog.tsx`, `AutosaveBanner.tsx`.
20+
- `src/lib/autosave.ts` — localStorage autosave logic.
21+
- `src/lib/rdfFormats.ts` — RDF serialization format utilities.
22+
- `src/lib/blankNodes.ts` — blank node ID generation and handling.
23+
- `src/state/dialogStore.ts` — dialog state management (zustand).
24+
- `src/state/panelStore.ts` — panel visibility state (zustand).
25+
26+
Python and TypeScript are edited in lockstep: a new mutation exposed from `rdf_service.py` needs a matching `sync.*` registration, a `pyBridge.ts` wrapper, and (if the projection shape changes) a `rdfGraphModel.ts` update.
27+
28+
## Setup
29+
30+
- **Python**: managed with [uv](https://docs.astral.sh/uv/), Python >=3.10 (pinned in `.python-version`). Deps (`rdflib`, `pyshacl`) and dev deps (`pytest`, `jupyterlab`) are declared in `pyproject.toml`.
31+
- **Node**: Vite + React 19 + TypeScript + `@xyflow/react` (React Flow) + `@dagrejs/dagre` + zustand. Deps in `package.json`.
32+
33+
## Common Commands
34+
35+
```bash
36+
# Frontend dev server
37+
npm run dev
38+
39+
# Type-check + production build
40+
npm run build
41+
42+
# Python tests (exercise rdf_service.py directly, no browser/Pyodide needed)
43+
uv run pytest
44+
45+
# TypeScript tests (Vitest; *.test.ts files next to the code they test)
46+
npm test
47+
```
48+
49+
`tests/test_rdf_service.py` imports `rdf_service` directly (pytest's `pythonpath` is set to `public/py` in `pyproject.toml`) and is the fast way to verify RDF-logic changes without spinning up the browser/Pyodide runtime. Test fixtures live in `tests/fixtures/`. `npm test` runs the Vitest suite, which covers layout code (`forceLayout.test.ts`, `layout.test.ts`) and blank node handling (`blankNodes.test.ts`).
50+
51+
## Before You Finish
52+
53+
1. Run tests: `uv run pytest` for Python changes, `npm test` for TypeScript changes.
54+
2. For any TypeScript change, also run `npm run build` to catch type errors.
55+
3. Work on a feature branch and open a PR (see history: PRs #12–#14).
56+
4. Never hand-edit `uv.lock` or `package-lock.json`; let the package managers handle them.

‎CLAUDE.md‎

Lines changed: 1 addition & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -1,69 +1 @@
1-
# CLAUDE.md
2-
3-
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
4-
5-
## Project overview
6-
7-
Browser-only RDF graph editor (no backend/server): a React + React Flow canvas on top of an
8-
in-browser Python RDF engine. All RDF parsing, SHACL validation, and graph mutation happens in
9-
Python (rdflib/pyshacl), running client-side via PyScript/Pyodide — the two toolchains are
10-
connected through a JS↔Python bridge, not parallel/unconnected.
11-
12-
Hosted at https://ld4p.github.io/graph-editor/, deployed via `.github/workflows/deploy-pages.yml`.
13-
14-
## Architecture
15-
16-
- `public/py/rdf_service.py` — the RDF engine. Holds the single in-memory `rdflib.Graph`,
17-
undo/redo history, and all mutation functions (add/delete/rename node, add/delete edge,
18-
add/update/delete property, SHACL validation, namespace management). Every mutating function
19-
snapshots history first, then returns `_project(graph)`: a plain-dict `{nodes, edges}`
20-
projection of the graph for the UI. When run under PyScript, functions are registered on
21-
`sync.*` so JS can call them directly.
22-
- `src/lib/pyBridge.ts` — lazily boots the Pyodide worker (via PyScript's `PyWorker`, loaded
23-
from `public/py/pyscript.toml`) and exposes typed async wrappers around each `sync.*` function.
24-
- `src/model/rdfGraphModel.ts` — TS types mirroring the Python projection shapes
25-
(`RdfProjection`, `RdfNode`, `RdfEdge`, SHACL/namespace result types).
26-
- `src/state/graphStore.ts` (zustand) — holds the current projection, node positions, selection,
27-
and undo/redo status; `setProjection` also fires autosave to `localStorage`.
28-
- `src/lib/layout.ts` — lays out the projection as React Flow nodes/edges, with either the
29-
force-directed layout (default) or dagre, chosen by `layoutMode` in the store. Manually-dragged
30-
positions from the store are always kept.
31-
- `src/lib/forceLayout.ts` — Springy-style force simulation used by the default layout. CBD groups
32-
stay clustered, an overlap pass keeps cards and group boxes apart, dragged nodes stay pinned, and
33-
each run warm-starts from the previous `settled` positions (kept in `GraphCanvas`) so edits
34-
don't reshuffle the graph.
35-
- `src/components/` — `GraphCanvas.tsx` (React Flow canvas), `ResourceNode.tsx` /
36-
`ResourcePredicateEdge.tsx` (custom node/edge renderers with inline editing), `Inspector.tsx`,
37-
`NamespacePanel.tsx`, `ValidationPanel.tsx`, `Toolbar.tsx`, `Dialog.tsx`, `AutosaveBanner.tsx`.
38-
39-
Python and TypeScript are edited in lockstep: a new mutation exposed from `rdf_service.py` needs
40-
a matching `sync.*` registration, a `pyBridge.ts` wrapper, and (if the projection shape changes) a
41-
`rdfGraphModel.ts` update.
42-
43-
## Setup
44-
45-
- **Python**: managed with [uv](https://docs.astral.sh/uv/), Python >=3.10 (pinned in
46-
`.python-version`). Deps (`rdflib`, `pyshacl`, `pytest` dev dep) are declared in `pyproject.toml`.
47-
- **Node**: Vite + React 19 + TypeScript + `@xyflow/react` (React Flow) + `@dagrejs/dagre` +
48-
zustand. Deps in `package.json`.
49-
50-
## Common commands
51-
52-
```bash
53-
# Frontend dev server
54-
npm run dev
55-
56-
# Type-check + production build
57-
npm run build
58-
59-
# Python tests (exercise rdf_service.py directly, no browser/Pyodide needed)
60-
uv run pytest
61-
62-
# TypeScript tests (Vitest; *.test.ts files next to the code they test)
63-
npm test
64-
```
65-
66-
`tests/test_rdf_service.py` imports `rdf_service` directly (pytest's `pythonpath` is set to
67-
`public/py` in `pyproject.toml`) and is the fast way to verify RDF-logic changes without spinning
68-
up the browser/Pyodide runtime. `npm test` runs the Vitest suite, which currently covers the
69-
layout code in `src/lib/` (`forceLayout.test.ts`, `layout.test.ts`).
1+
@AGENTS.md

0 commit comments

Comments
 (0)