From d59fc2ba59d7b265fbbd01caa3b817f4bc77184d Mon Sep 17 00:00:00 2001 From: Parfii-bot Date: Tue, 21 Apr 2026 19:44:30 +0800 Subject: [PATCH] feat(install): install _primitives/ + soft pandoc warning MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - install.sh: - mkdir $AGENTS_DIR/_primitives - copy *.sh + README.md from kit _primitives/ with backup_dir guard - chmod +x for the primitive scripts - extend hooks-copy loop to include tomd-preread.sh (skips if absent, preserving back-compat with kits that predate the primitive) - soft-warn (not hard-fail) if pandoc is missing — tomd primitive is opt-in and works without pandoc for CSV/code/JSON/images - settings-snippet.json: add PreToolUse(Read) entry for tomd-preread.sh with statusMessage. New matcher block (no existing Read matcher). Co-Authored-By: Claude Opus 4.7 (1M context) --- install.sh | 19 ++++++++++++++++++- settings-snippet.json | 10 ++++++++++ 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/install.sh b/install.sh index 9a3a60c..40c271b 100755 --- a/install.sh +++ b/install.sh @@ -189,12 +189,19 @@ if ! command -v jq >/dev/null 2>&1; then err " apt install jq (Debian/Ubuntu)" exit 1 fi +# Soft-warn on pandoc — the tomd primitive works without it for CSV / code / +# JSON / images, but fails on .docx / .pptx / .html. Opt-in use, so not +# promoted to a hard-fail. +if ! command -v pandoc >/dev/null 2>&1; then + warn "pandoc not found — tomd primitive will fail on .docx/.pptx. Install: brew install pandoc" +fi # --- create target dirs ----------------------------------------------------- say "creating directories" mkdir -p \ "$AGENTS_DIR/_blocks" \ "$AGENTS_DIR/_manifests" \ + "$AGENTS_DIR/_primitives" \ "$AGENTS_DIR/_templates" \ "$AGENTS_DIR/_assembler/src" \ "$AGENTS_DIR/_generated" \ @@ -221,6 +228,15 @@ say "copying shared blocks -> $AGENTS_DIR/_blocks/" backup_dir "$AGENTS_DIR/_blocks" cp -f "$KIT_DIR/_blocks/"*.md "$AGENTS_DIR/_blocks/" +# --- copy primitives (overwrite; primitives are SSoT from kit) ------------- +if [[ -d "$KIT_DIR/_primitives" ]]; then + say "copying primitives -> $AGENTS_DIR/_primitives/" + backup_dir "$AGENTS_DIR/_primitives" + cp -f "$KIT_DIR/_primitives/"*.sh "$AGENTS_DIR/_primitives/" 2>/dev/null || true + cp -f "$KIT_DIR/_primitives/README.md" "$AGENTS_DIR/_primitives/" 2>/dev/null || true + chmod +x "$AGENTS_DIR/_primitives/"*.sh 2>/dev/null || true +fi + # --- copy bridges (overwrite; templates are SSoT from kit) ----------------- if [[ -d "$KIT_DIR/_bridges" ]]; then say "copying bridge templates -> $AGENTS_DIR/_bridges/" @@ -272,7 +288,8 @@ fi # individually rather than the whole directory, so foreign hooks are not # dragged into .bak-TIMESTAMP snapshots on every re-run. say "copying hooks -> $HOOKS_DIR/" -for h in assemble-agents.sh assemble-validate.sh no-hand-edit-agents.sh; do +for h in assemble-agents.sh assemble-validate.sh no-hand-edit-agents.sh tomd-preread.sh; do + [ -f "$KIT_DIR/hooks/$h" ] || continue backup_file "$HOOKS_DIR/$h" cp -f "$KIT_DIR/hooks/$h" "$HOOKS_DIR/$h" chmod +x "$HOOKS_DIR/$h" diff --git a/settings-snippet.json b/settings-snippet.json index 8b88026..84f1317 100644 --- a/settings-snippet.json +++ b/settings-snippet.json @@ -30,6 +30,16 @@ "command": "~/.claude/hooks/no-hand-edit-agents.sh" } ] + }, + { + "matcher": "Read", + "hooks": [ + { + "type": "command", + "command": "~/.claude/hooks/tomd-preread.sh", + "statusMessage": "tomd pre-read auto-convert check..." + } + ] } ] }