From b13007b576aca70b1509cd17d956dbb5ae27c897 Mon Sep 17 00:00:00 2001 From: Claude Date: Fri, 6 Nov 2026 05:27:50 +0000 Subject: [PATCH] Make AGENTS.md the main agent guide; CLAUDE.md imports it Move the CLAUDE.md content to AGENTS.md and reduce CLAUDE.md to @AGENTS.md so Claude Code still loads it. Add AGENTS.md to CODEOWNERS and the hygiene test's coverage list, and point the .coderabbit.yaml header comment at AGENTS.md. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01QehuQ5ppytPUa6qmAzL67V --- .coderabbit.yaml | 2 +- .github/CODEOWNERS | 1 + AGENTS.md | 57 ++++++++++++++++++++++++++++++++++++++++ CLAUDE.md | 58 +---------------------------------------- scripts/hygiene.test.sh | 2 +- 5 files changed, 61 insertions(+), 59 deletions(-) create mode 100644 AGENTS.md diff --git a/.coderabbit.yaml b/.coderabbit.yaml index e678d17..6c76999 100644 --- a/.coderabbit.yaml +++ b/.coderabbit.yaml @@ -1,5 +1,5 @@ # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json -# CodeRabbit review settings for SwiftGraphviz. CLAUDE.md is picked up as review +# CodeRabbit review settings for SwiftGraphviz. AGENTS.md is picked up as review # guidelines automatically; the instructions below add what matters per path. language: en-US diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index 0d9073a..bf9d606 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -12,6 +12,7 @@ /CGraphviz.artifactbundle/ @Vithanco /CGraphvizWasm.artifactbundle/ @Vithanco /artifacts.sha256 @Vithanco +/AGENTS.md @Vithanco /CLAUDE.md @Vithanco /.coderabbit.yaml @Vithanco /.github/ @Vithanco diff --git a/AGENTS.md b/AGENTS.md new file mode 100644 index 0000000..a7e85ab --- /dev/null +++ b/AGENTS.md @@ -0,0 +1,57 @@ +# AGENTS.md + +This file provides guidance to coding agents (Claude Code, Codex, Cursor, and others) when working with code in this repository. + +## Build & Test + +```bash +swift build # Build the library +swift test # Run tests (test target: SwiftGraphvizTests) +``` + +On macOS/iOS, the bundled `Graphviz.xcframework` is used automatically. On Linux, a pre-built static library is bundled as `CGraphviz.artifactbundle` (SE-0482, requires Swift 6.2+). + +To rebuild the Linux artifact bundle (run inside a Linux container): +```bash +./build_linux_static.sh # clones graphviz source +GRAPHVIZ_SRC=/path/to/graphviz ./build_linux_static.sh # use local copy +``` + +To rebuild the macOS/iOS xcframework: +```bash +./build_xcframework.sh +``` + +WebAssembly (`wasm32-unknown-wasip1`) is supported — see [WASM.md](WASM.md). +The Swift layer is Foundation-free and compiles under Embedded Swift. The Graphviz C +library **compiles to wasm** via `./build_wasm_static.sh` (verified: ~2.4 MB +`CGraphvizWasm.artifactbundle`), using `wasm-toolchain.cmake` + `wasm_compat.h` +against the WASI sysroot bundled in an installed Swift wasm SDK — no separate +wasi-sdk needed. VGraph links it in-process. Select the wasm binary target with +`GRAPHVIZ_WASM=1 swift build --swift-sdk <...wasm-embedded>`. + +Swift tools version: 6.0. Minimum platforms: macOS 15, iOS 18. Linux requires Swift 6.2+ (for artifact bundle support). + +## Architecture + +SwiftGraphviz is a Swift wrapper around the C Graphviz library for computing graph layouts. It has three layers: + +**CGraphviz** — Platform-specific pre-built Graphviz static library. On Apple it's `Graphviz.xcframework` (macOS, iOS, simulator slices). On Linux it's `CGraphviz.artifactbundle` (SE-0482). Both are `.binaryTarget` in Package.swift. + +**GraphvizBridge** (C) — Thin C bridge that wraps Graphviz macros as callable C functions, since Swift cannot invoke C macros directly. Two files: +- `builtins.c/h` — Plugin registration (`loadGraphvizLibraries()`) and accessor functions for node coords (`nd_coord`), edge splines (`ed_label`, `ed_lp`, etc.), and graph bounding boxes (`gd_bb`). +- `unflatten.c/h` — The `agUnflatten` algorithm exposed as a C function. + +**SwiftGraphviz** (Swift) — Public API layer. Key types: +- `GVGraph`, `GVNode`, `GVEdge`, `GVCluster` — typealiases for `UnsafeMutablePointer` with Swift extensions for setting attributes and reading layout results. +- `GVGeometry` — Cross-platform geometry types (`GVPoint`, `GVSize`, `GVRect`, `GVVector`) replacing CoreGraphics. `GVGeometry+Apple.swift` adds `cgPoint`/`cgSize`/`cgRect`/`cgVector` bridging via `#if canImport(CoreGraphics)`. +- `NodeLayout`, `EdgeLayout`, `ClusterLayout` — Value types that snapshot layout results from the Graphviz pointers. +- `GVParameters` — Enums for Graphviz attributes (`GVNodeParameters`, `GVEdgeParameters`, `GVGraphParameters`), unit types (`GVPoints`, `GVInches`), and style/direction enums. +- `GraphvizWrapper` — Global context (`gblGVContext`), `GVLayoutEngine` enum, `GVGlobalContextPointer` typealias. + +## Key Patterns + +- **Static plugin registration**: Graphviz plugins (dot, neato, core) are registered statically via `gvNEWcontext` + `gvAddLibrary` on all platforms. No dynamic plugin discovery. +- **Graphviz attributes**: Set defaults on the graph first (`g.setDefault(.node(.label))`), then set values on individual elements (`node.set(.width, "1.5")`). All attributes are string-based. +- **Units**: Graphviz uses 72 points per inch. Node dimensions come back in inches from the C layer; `GVInches`/`GVPoints` types handle conversion. +- **`staging/` directory**: Contains files moved out of the main source but kept for reference. Prefer moving unused files here rather than deleting them. diff --git a/CLAUDE.md b/CLAUDE.md index 0df0817..43c994c 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -1,57 +1 @@ -# CLAUDE.md - -This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository. - -## Build & Test - -```bash -swift build # Build the library -swift test # Run tests (test target: SwiftGraphvizTests) -``` - -On macOS/iOS, the bundled `Graphviz.xcframework` is used automatically. On Linux, a pre-built static library is bundled as `CGraphviz.artifactbundle` (SE-0482, requires Swift 6.2+). - -To rebuild the Linux artifact bundle (run inside a Linux container): -```bash -./build_linux_static.sh # clones graphviz source -GRAPHVIZ_SRC=/path/to/graphviz ./build_linux_static.sh # use local copy -``` - -To rebuild the macOS/iOS xcframework: -```bash -./build_xcframework.sh -``` - -WebAssembly (`wasm32-unknown-wasip1`) is supported — see [WASM.md](WASM.md). -The Swift layer is Foundation-free and compiles under Embedded Swift. The Graphviz C -library **compiles to wasm** via `./build_wasm_static.sh` (verified: ~2.4 MB -`CGraphvizWasm.artifactbundle`), using `wasm-toolchain.cmake` + `wasm_compat.h` -against the WASI sysroot bundled in an installed Swift wasm SDK — no separate -wasi-sdk needed. VGraph links it in-process. Select the wasm binary target with -`GRAPHVIZ_WASM=1 swift build --swift-sdk <...wasm-embedded>`. - -Swift tools version: 6.0. Minimum platforms: macOS 15, iOS 18. Linux requires Swift 6.2+ (for artifact bundle support). - -## Architecture - -SwiftGraphviz is a Swift wrapper around the C Graphviz library for computing graph layouts. It has three layers: - -**CGraphviz** — Platform-specific pre-built Graphviz static library. On Apple it's `Graphviz.xcframework` (macOS, iOS, simulator slices). On Linux it's `CGraphviz.artifactbundle` (SE-0482). Both are `.binaryTarget` in Package.swift. - -**GraphvizBridge** (C) — Thin C bridge that wraps Graphviz macros as callable C functions, since Swift cannot invoke C macros directly. Two files: -- `builtins.c/h` — Plugin registration (`loadGraphvizLibraries()`) and accessor functions for node coords (`nd_coord`), edge splines (`ed_label`, `ed_lp`, etc.), and graph bounding boxes (`gd_bb`). -- `unflatten.c/h` — The `agUnflatten` algorithm exposed as a C function. - -**SwiftGraphviz** (Swift) — Public API layer. Key types: -- `GVGraph`, `GVNode`, `GVEdge`, `GVCluster` — typealiases for `UnsafeMutablePointer` with Swift extensions for setting attributes and reading layout results. -- `GVGeometry` — Cross-platform geometry types (`GVPoint`, `GVSize`, `GVRect`, `GVVector`) replacing CoreGraphics. `GVGeometry+Apple.swift` adds `cgPoint`/`cgSize`/`cgRect`/`cgVector` bridging via `#if canImport(CoreGraphics)`. -- `NodeLayout`, `EdgeLayout`, `ClusterLayout` — Value types that snapshot layout results from the Graphviz pointers. -- `GVParameters` — Enums for Graphviz attributes (`GVNodeParameters`, `GVEdgeParameters`, `GVGraphParameters`), unit types (`GVPoints`, `GVInches`), and style/direction enums. -- `GraphvizWrapper` — Global context (`gblGVContext`), `GVLayoutEngine` enum, `GVGlobalContextPointer` typealias. - -## Key Patterns - -- **Static plugin registration**: Graphviz plugins (dot, neato, core) are registered statically via `gvNEWcontext` + `gvAddLibrary` on all platforms. No dynamic plugin discovery. -- **Graphviz attributes**: Set defaults on the graph first (`g.setDefault(.node(.label))`), then set values on individual elements (`node.set(.width, "1.5")`). All attributes are string-based. -- **Units**: Graphviz uses 72 points per inch. Node dimensions come back in inches from the C layer; `GVInches`/`GVPoints` types handle conversion. -- **`staging/` directory**: Contains files moved out of the main source but kept for reference. Prefer moving unused files here rather than deleting them. +@AGENTS.md diff --git a/scripts/hygiene.test.sh b/scripts/hygiene.test.sh index 6c5ef21..1baa33e 100755 --- a/scripts/hygiene.test.sh +++ b/scripts/hygiene.test.sh @@ -38,7 +38,7 @@ done <<< "$patterns" # 14 printf '%s\n' "$patterns" > "$TMP/.git/info/exclude"; bad=0 for path in Package.swift build_xcframework.sh build_linux_static.sh build_wasm_static.sh Containerfile.build \ - Graphviz.xcframework/x CGraphviz.artifactbundle/x CGraphvizWasm.artifactbundle/x CLAUDE.md .coderabbit.yaml .github/CODEOWNERS scripts/x.sh; do + Graphviz.xcframework/x CGraphviz.artifactbundle/x CGraphvizWasm.artifactbundle/x AGENTS.md CLAUDE.md .coderabbit.yaml .github/CODEOWNERS scripts/x.sh; do echo "$path" | git -C "$TMP" check-ignore --no-index -q --stdin || { fail "not covered by CODEOWNERS: $path"; bad=1; } done [ $bad -eq 0 ] && pass 'Given CODEOWNERS, when its patterns are read, then it covers the manifest, scripts, binaries, agent config and .github/'