aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLouis <louis@dnge.de>2026-11-11 10:11:21 +0100
committerLouis <louis@dnge.de>2026-11-11 10:11:50 +0100
commit6f2bbe1f94e4321c329f92ec3420f6d32fd7b26d (patch)
treecfa53d98d960421b6bcfd777d881629878d33b08
parent2e433fcd0d1afadd8ab786dd30d7d4546bdee43d (diff)
downloadhw-toolchain-6f2bbe1f94e4321c329f92ec3420f6d32fd7b26d.tar.gz
link_toolchain.sh: link the notes into a host repo as per-file symlinks
IWE follows file symlinks but not directory symlinks. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
-rw-r--r--AGENTS.md2
-rw-r--r--README.md4
-rw-r--r--tools/link_toolchain.sh29
3 files changed, 33 insertions, 2 deletions
diff --git a/AGENTS.md b/AGENTS.md
index 0f57646..71fa964 100644
--- a/AGENTS.md
+++ b/AGENTS.md
@@ -2,7 +2,7 @@
Conventions for AI-assisted hardware development with KiCad 10 for electronics, a parametric CAD tool for mechanics (SolidCraft here; the rules apply to any), and a Markdown knowledge graph (IWE). The toolchain in `tools/` and the notes in `knowledge/tooling/` and `knowledge/topics/` come from this repo. Your own boards, libraries and notes live beside them.
-**Using this inside your own repo:** add this repo as a submodule (e.g. `toolchain/`) and symlink `tools` and `knowledge/tooling` to it, so that every path below holds. Your repo's own AGENTS.md should start with "Read `toolchain/AGENTS.md` first", then add what is yours: identity, hosting, project rules. Where the two disagree, your repo's file wins.
+**Using this inside your own repo:** add this repo as a submodule (e.g. `toolchain/`), symlink `tools` to `toolchain/tools`, and run `sh tools/link_toolchain.sh` to link the notes into `knowledge/`, so that every path below holds. Your repo's own AGENTS.md should start with "Read `toolchain/AGENTS.md` first", then add what is yours: identity, hosting, project rules. Where the two disagree, your repo's file wins.
## Layout
diff --git a/README.md b/README.md
index 5705eba..f6cbf0b 100644
--- a/README.md
+++ b/README.md
@@ -38,10 +38,12 @@ The tools are found relative to themselves. The board can live anywhere.
``` sh
git submodule add https://git.dnge.de/hw-toolchain toolchain
ln -s toolchain/tools tools
-mkdir -p knowledge && ln -s ../toolchain/knowledge/tooling knowledge/tooling
+sh tools/link_toolchain.sh # knowledge/tooling + topics as per-file symlinks
printf 'Read toolchain/AGENTS.md first; it holds the shared conventions.\n\n# My additions\n' > AGENTS.md
```
+Re-run `link_toolchain.sh` after updating the submodule to pick up new notes. Notes you keep in your own repo, such as project journals, can link to `../tooling/<tool>.md` as if the notes were local.
+
## Status
- Used on a dozen real 2-layer boards: industrial I/O modules on DIN rail, ESP32/CH32 + Ethernet, RTD front ends.
diff --git a/tools/link_toolchain.sh b/tools/link_toolchain.sh
new file mode 100644
index 0000000..8f488e1
--- /dev/null
+++ b/tools/link_toolchain.sh
@@ -0,0 +1,29 @@
+#!/bin/sh
+# Link the toolchain's notes into your repo's knowledge graph, one symlink per file (IWE and
+# other Markdown tools follow file symlinks, not directory symlinks).
+#
+# sh toolchain/tools/link_toolchain.sh [TOOLCHAIN_DIR] [--topics name ...]
+#
+# Run from your repo root. Links every knowledge/tooling/*.md of the toolchain into
+# knowledge/tooling/, and the topics named after --topics (default: all) into knowledge/topics/.
+# Existing regular files are left alone and reported; stale links into the toolchain are removed.
+set -e
+TC=${1:-toolchain}; [ $# -gt 0 ] && shift
+[ -d "$TC/knowledge/tooling" ] || { echo "no $TC/knowledge/tooling; pass the toolchain directory" >&2; exit 1; }
+TOPICS=""
+if [ "$1" = "--topics" ]; then shift; TOPICS="$*"; fi
+[ -n "$TOPICS" ] || TOPICS=$(cd "$TC/knowledge/topics" && ls *.md | sed 's/\.md$//')
+
+link() { # link SUBDIR NAME
+ mkdir -p "knowledge/$1"
+ dst="knowledge/$1/$2.md"
+ if [ -e "$dst" ] && [ ! -L "$dst" ]; then echo "kept (own file): $dst"; return; fi
+ ln -sfn "../../$TC/knowledge/$1/$2.md" "$dst"
+}
+
+for f in "$TC"/knowledge/tooling/*.md; do link tooling "$(basename "$f" .md)"; done
+for t in $TOPICS; do link topics "$t"; done
+for d in knowledge/tooling knowledge/topics; do
+ for l in "$d"/*.md; do [ -L "$l" ] && [ ! -e "$l" ] && { rm "$l"; echo "removed stale link: $l"; }; done
+done
+echo "linked $(ls "$TC"/knowledge/tooling/*.md | wc -l | tr -d ' ') tool notes"