Skip to content

Commit 618ca08

Browse files
committed
what: ship check-markdown.sh in skill payload, remove README curl step
what: add scripts/check-markdown.sh to RUNTIME_PAYLOAD_FILES so it lands at ~/.hermes/skills/markdown-formatter/scripts/check-markdown.sh after hermes skills install. No more curl/chmod manual steps. why: the heredoc (previous fix) still required the user to mkdir, curl, and chmod. Shipping the script in the tap payload eliminates 3 manual setup steps — only the config.yaml edit remains (and that is architecturally unavoidable as user-level config). Changes: - runtime-payload.js: add scripts/check-markdown.sh to the 8-file payload allowlist - sync-tap-payload.js: chmod the script on copy - staged-install-verify.sh: replace blanket scripts/ exclusion with a targeted check for known payload scripts - repo-shape.js: add payload path to expected shape - runtime-payload.test.js: update expected array (7->8 files) - README.md: replace curl block with note that script ships with the skill; update config.yaml path to skill path
1 parent da121cd commit 618ca08

7 files changed

Lines changed: 63 additions & 12 deletions

File tree

README.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -190,31 +190,31 @@ Or run from source (no npm install):
190190
node src/index.js --fix --guard README.md
191191
```
192192

193-
For auto-wiring on every `write_file` or `patch` call, install a small hook
194-
wrapper:
193+
For auto-wiring on every `write_file` or `patch` call — the hook script ships with the
194+
skill. You just need to register it:
195195

196196
```bash
197-
mkdir -p "$HOME/.hermes/scripts"
198-
curl -sSLo "$HOME/.hermes/scripts/check-markdown.sh" \
199-
"https://raw.githubusercontent.com/CodeSigils/zero-md-formatter/main/scripts/check-markdown.sh"
200-
chmod +x "$HOME/.hermes/scripts/check-markdown.sh"
197+
# The script is already at:
198+
# ~/.hermes/skills/markdown-formatter/scripts/check-markdown.sh
199+
# No download needed.
201200
```
202201

203202
Then add the hook to `config.yaml`:
204203

205204
```yaml
206205
hooks:
207206
post_tool_call:
208-
- command: ~/.hermes/scripts/check-markdown.sh
207+
- command: ~/.hermes/skills/markdown-formatter/scripts/check-markdown.sh
209208
matcher: write_file
210-
- command: ~/.hermes/scripts/check-markdown.sh
209+
- command: ~/.hermes/skills/markdown-formatter/scripts/check-markdown.sh
211210
matcher: patch
212211
```
213212
214213
This runs `--check` (read-only) on every written Markdown file, blocking pipe
215214
hazards, fence errors, and formatting drift before they reach git. To
216-
auto-repair instead, edit `~/.hermes/scripts/check-markdown.sh` and change
217-
the `--check` flag to `--fix`.
215+
auto-repair instead, edit the script at
216+
`~/.hermes/skills/markdown-formatter/scripts/check-markdown.sh`
217+
and change the `--check` flag to `--fix`.
218218
</details>
219219

220220
<details>

scripts/runtime-payload.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ const RUNTIME_PAYLOAD_FILES = [
99
"guard/check-fences.js",
1010
"guard/check-tables.js",
1111
"guard/check-pipes.js",
12+
"scripts/check-markdown.sh",
1213
];
1314

1415
module.exports = RUNTIME_PAYLOAD_FILES;

scripts/staged-install-verify.sh

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ mapfile -t RUNTIME_ALLOWLIST < <(node scripts/runtime-payload.js)
1414
# Define dev-only paths that MUST NOT appear in staged payload
1515
DEV_ONLY_PATHS=(
1616
"README.md"
17-
"scripts/"
1817
"test/"
1918
".github/"
2019
"skills/"
@@ -71,6 +70,19 @@ if [[ -d "$STAGE_DIR/.git" ]]; then
7170
VIOLATION_FOUND=true
7271
fi
7372

73+
# Check for unexpected files in scripts/ payload directory
74+
declare -A PAYLOAD_SCRIPTS
75+
PAYLOAD_SCRIPTS["check-markdown.sh"]=1
76+
if [[ -d "$STAGE_DIR/scripts" ]]; then
77+
while IFS= read -r -d '' f; do
78+
name=$(basename "$f")
79+
if [[ -z "${PAYLOAD_SCRIPTS[$name]-}" ]]; then
80+
echo "❌ VIOLATION: Unexpected file in scripts/ payload directory: $name"
81+
VIOLATION_FOUND=true
82+
fi
83+
done < <(find "$STAGE_DIR/scripts" -type f -print0)
84+
fi
85+
7486
if [[ "$VIOLATION_FOUND" == true ]]; then
7587
echo ""
7688
echo "STAGED INSTALL VERIFICATION FAILED"

scripts/sync-tap-payload.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ for (const file of RUNTIME_PAYLOAD_FILES) {
2020
const destination = join(TAP_PAYLOAD_DIR, file);
2121
mkdirSync(dirname(destination), { recursive: true });
2222
cpSync(source, destination, { recursive: true });
23-
if (file === "src/index.js") {
23+
if (file === "src/index.js" || file === "scripts/check-markdown.sh") {
2424
chmodSync(destination, 0o755);
2525
}
2626
}

scripts/validators/repo-shape.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ const PLAN_EXPECTED_REPO_SHAPE = new Set([
3232
"skills/markdown-formatter/guard/check-structure.js",
3333
"skills/markdown-formatter/guard/check-tables.js",
3434
"skills/markdown-formatter/guard/check-pipes.js",
35+
"skills/markdown-formatter/scripts/check-markdown.sh",
3536
"src/index.js",
3637
"src/format-content.mjs",
3738
"guard/check-fences.js",
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
#!/usr/bin/env bash
2+
# Hermes shell hook: check Markdown files with mdfmt --check on write_file/patch
3+
#
4+
# Setup:
5+
# mkdir -p "$HOME/.hermes/scripts"
6+
# cp scripts/check-markdown.sh "$HOME/.hermes/scripts/"
7+
# chmod +x "$HOME/.hermes/scripts/check-markdown.sh"
8+
#
9+
# Then add to ~/.hermes/config.yaml:
10+
# hooks:
11+
# post_tool_call:
12+
# - command: ~/.hermes/scripts/check-markdown.sh
13+
# matcher: write_file
14+
# - command: ~/.hermes/scripts/check-markdown.sh
15+
# matcher: patch
16+
set -eo pipefail
17+
18+
payload="$(cat -)"
19+
file_path="$(echo "$payload" | jq -r '.tool_input.path // ""' 2>/dev/null)" || file_path=""
20+
21+
[[ -z "$file_path" || ! -f "$file_path" ]] && printf '{}\n' && exit 0
22+
23+
case "$file_path" in
24+
*.md|*.markdown|*.mdx) ;;
25+
*) printf '{}\n' && exit 0 ;;
26+
esac
27+
28+
if command -v mdfmt &>/dev/null; then
29+
mdfmt --check "$file_path"
30+
elif [[ -f "$HOME/.hermes/skills/markdown-formatter/src/index.js" ]]; then
31+
node "$HOME/.hermes/skills/markdown-formatter/src/index.js" --check "$file_path"
32+
else
33+
echo "[check-markdown] zero-md-formatter not found — skipping check" >&2
34+
fi
35+
36+
printf '{}\n'

test/unit/runtime-payload.test.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ describe('runtime payload allowlist', () => {
1212
'guard/check-fences.js',
1313
'guard/check-tables.js',
1414
'guard/check-pipes.js',
15+
'scripts/check-markdown.sh',
1516
]);
1617
});
1718
});

0 commit comments

Comments
 (0)