You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
always-on hook keeps an empty frontmatter block in the injected ruleset (Node and OpenCode paths; sh/PowerShell strip it) #263
hooks/always-on.mjs strips a leading YAML frontmatter block with a pattern that requires at least one line between the delimiters. A block with no keys — --- on the first two lines — is still frontmatter, and the hook leaves both fences in the ruleset it injects at SessionStart. hooks/always-on.sh and hooks/always-on.ps1 strip the same file correctly, so the runtimes disagree about the same SKILL.md — exactly the divergence tests/test_always_on_hooks.py exists to catch.
Repro
skills/i-have-adhd/SKILL.md:
---
---
Fixture body.
$ CLAUDE_CONFIG_DIR=<dir with .i-have-adhd-always> node hooks/always-on.mjsADHD MODE ACTIVE (always-on). ... delete <dir>/.i-have-adhd-always to turn always-on off for good.------ <- the fences reach the modelFixture body.
Measured on main (1ecea19), one run per runtime, same plugin root (a path with spaces) and same config dir:
runtime
text after the banner
node hooks/always-on.mjs
---\n---\nFixture body.\n
sh hooks/always-on.sh
Fixture body.\n
pwsh hooks/always-on.ps1
Fixture body.\n
.opencode/plugins/i-have-adhd.mjs carries the same pattern in rulesetBody(), so OpenCode's always-on injection has the same shape on both the V1 (experimental.chat.system.transform) and V2 (context hook) paths.
Expected
An empty block is frontmatter like any other: both fences go, the body stays.
Impact
Small but visible: a SKILL.md that opens with an empty block gets two stray --- lines at the top of every session, and the three runtimes stop agreeing with each other. The shipped skills/i-have-adhd/SKILL.md has keys, so it is unaffected.
Fix
Making the body between the delimiters optional ((?:[\s\S]*?\r?\n)?) fixes it in the Node hook and the OpenCode plugin copy; both copies have unit-test seams, so the change is pinned by two new tests. PR to follow.
The two new tests fail on the base ref with only the source change reverted: FAILED (failures=3) — runtime='node', mode='context', mode='v1-context', all 'Fixture body.' != '---\n---\nFixture body.'. The sh and pwsh subtests already passed, which is the same divergence reported above.
The shipped skills/i-have-adhd/SKILL.md still injects a byte-identical body before and after (sha256 prefix 07613106189edb3f), so nothing users receive today moves.
extensions/i-have-adhd.ts carries the same pattern in stripFrontmatter() and is deliberately not in this diff: it has no unit-test seam, so the change would not be pinned by anything. Same one-line change applies if you want it in the same PR.
Opening the PR is currently refused for this account (CreatePullRequest FORBIDDEN via GraphQL; POST /repos/ayghri/i-have-adhd/pulls → 404) even though the token has repo, the fork's parent is this repo, and the API rate limit is healthy — so the branch is pushed and ready to open from here:
Activity
SU-AN-coder commentedon Oct 18, 2026
Fix is written and verified on a branch:
SU-AN-coder:fix/hooks-empty-frontmatter(head24eb4af), one commit on top ofmain.Change — make the body between the delimiters optional in the two copies that have unit-test seams:
Files:
hooks/always-on.mjs,.opencode/plugins/i-have-adhd.mjs(+42 −3 total with two new tests).Verification on the branch
python3 -m unittest discover -s tests -v— 80 tests, OK (78 before, +2).FAILED (failures=3)—runtime='node',mode='context',mode='v1-context', all'Fixture body.' != '---\n---\nFixture body.'. Theshandpwshsubtests already passed, which is the same divergence reported above.skills/i-have-adhd/SKILL.mdstill injects a byte-identical body before and after (sha256 prefix07613106189edb3f), so nothing users receive today moves.pwshwas run locally (PowerShell 7) alongside node and sh over 19 frontmatter shapes; the empty block is the only shape this change touches. The remaining PowerShell trailing-blank-line divergences are the pre-existing ones from hooks: PowerShell always-on fallback keeps trailing blank lines, so it disagrees with the Node and sh hooks #172 and are left alone.python3 scripts/run_evals.py validate— valid.extensions/i-have-adhd.tscarries the same pattern instripFrontmatter()and is deliberately not in this diff: it has no unit-test seam, so the change would not be pinned by anything. Same one-line change applies if you want it in the same PR.Opening the PR is currently refused for this account (
CreatePullRequestFORBIDDEN via GraphQL;POST /repos/ayghri/i-have-adhd/pulls→ 404) even though the token hasrepo, the fork's parent is this repo, and the API rate limit is healthy — so the branch is pushed and ready to open from here:https://github.com/ayghri/i-have-adhd/compare/main...SU-AN-coder:fix/hooks-empty-frontmatter?expand=1