Skip to content

refactor(harness): improve hooks and harness robustness and YAML parsing#16

Merged
kyaulabs-bot merged 7 commits into
developfrom
feat/kyau-f5fix-hooks-harness-fixes
Jul 6, 2026
Merged

refactor(harness): improve hooks and harness robustness and YAML parsing#16
kyaulabs-bot merged 7 commits into
developfrom
feat/kyau-f5fix-hooks-harness-fixes

Conversation

@kyau

@kyau kyau commented Jul 6, 2026

Copy link
Copy Markdown
Member

This pull request introduces several improvements to the repository's developer tooling and harness validation scripts, with a focus on reliability, maintainability, and correctness. The main changes include a complete overhaul of the git hooks installation process, robust YAML frontmatter parsing for harness validation, and a suite of tests to ensure correct hook installation behavior. Additionally, ESLint and workflow configurations are updated to support these enhancements.

Git hooks installation and validation improvements:

  • Replaces the previous per-file symlink mechanism in install-hooks.sh with git config core.hooksPath .github/hooks, eliminating issues with worktrees, symlink breakage, and file permission dirtiness. The script now only sets the hooks path and checks for the existence of the hooks directory.
  • Updates documentation and checks in .opencode/commands/doctor.md to verify hooks installation via core.hooksPath rather than checking individual hook files.
  • Adds a comprehensive shell test suite in tests/Shell/install-hooks_test.sh to verify correct installation, permissions, and handling of edge cases such as empty hooks directories.

Harness validation robustness and maintainability:

  • Refactors .github/scripts/validate-harness.sh to require Bash 4+ and Node.js, replacing brittle awk/sed YAML parsing with a new Node.js script, frontmatter-parser.js, which uses js-yaml for robust YAML frontmatter extraction. This ensures correct handling of quoted values, scalars, comments, and CRLF line endings. [1] [2] [3]
  • Converts all name registries and cross-reference lookups in validate-harness.sh to use Bash associative arrays for O(1) exact-match lookups, preventing regex injection and improving performance. [1] [2] [3] [4] [5]
  • Adds a guard in validate-harness.sh to fail if no skills, agents, or commands are found, preventing vacuous passes.

Tooling and workflow updates:

  • Adds js-yaml as a development dependency in package.json to support the new frontmatter parser.
  • Updates eslint.config.mjs to correctly lint Node.js scripts in .github/scripts, allowing Node.js globals and disabling noisy console warnings.
  • Adds a Shellcheck step to the CI workflow to lint shell scripts and hooks for best practices and errors.

Minor content and formatting fixes:

  • Fixes YAML frontmatter quoting in skill files to ensure compatibility with strict YAML parsers. [1] [2]

Git hooks installation and testing:

  • Overhauled install-hooks.sh to use git config core.hooksPath .github/hooks, removing all per-file symlink logic and related bugs.
  • Added a shell test suite install-hooks_test.sh to verify correct installation, permissions, and handling of edge cases.
  • Updated documentation and checks in doctor.md to reflect new installation method.

Harness validation robustness:

  • Replaced fragile awk/sed YAML parsing in validate-harness.sh with a new Node.js-based frontmatter-parser.js using js-yaml for correct YAML frontmatter extraction. [1] [2]
  • Switched all name registries and lookups in validate-harness.sh to Bash associative arrays for safe and fast cross-reference validation. [1] [2] [3] [4] [5]
  • Added a guard to fail validation if no skills, agents, or commands are found.

Tooling and workflow:

  • Added js-yaml to package.json for YAML parsing.
  • Updated ESLint configuration for Node.js scripts.
  • Added Shellcheck to CI workflow for shell script linting.

YAML formatting:

  • Fixed YAML frontmatter quoting in skill files for parser compatibility. [1] [2]

Plan-by: glm-5.2
Acked-by: deepseek-v4-pro
Signed-off-by: kyau git@kyaulabs.com

@kyau kyau changed the title Refactor hooks and harness for improved robustness and YAML parsing refactor(harness): improve hooks and harness robustness and YAML parsing Acked-by: deepseek-v4-pro Signed-off-by: kyau <git@kyaulabs.com> Jul 6, 2026
@kyau kyau changed the title refactor(harness): improve hooks and harness robustness and YAML parsing Acked-by: deepseek-v4-pro Signed-off-by: kyau <git@kyaulabs.com> refactor(harness): improve hooks and harness robustness and YAML parsing Acked-by: deepseek-v4-pro Signed-off-by: kyau <kyau@kyau.net> Jul 6, 2026
kyau added 5 commits July 5, 2026 22:54
Replace per-file symlink hooks in .git/hooks with git's native
core.hooksPath mechanism. This eliminates worktree crashes,
core.hooksPath bypass, exec-bit dirtiness, and nullglob edge cases.

Also commit the executable bit (100755) for post-checkout, post-merge,
and pre-push hooks so chmod +x is no longer needed.

Add shellcheck linting to CI pipeline for all .sh scripts.
Update doctor.md hook detection to check core.hooksPath instead of
individual symlink files.

Plan-by: glm-5.2
Acked-by: deepseek-v4-pro
Fixes: #12
Signed-off-by: Sean Bruen <kyau@kyau.net>
Resolve HARNESS_DIR relative to git rev-parse --show-toplevel to prevent
vacuous PASS when run from subdirectories. Fail on all-zero category counts.

Replace toggling frontmatter parser with counter-based awk that stops at the
second --- delimiter, preventing re-entry on Markdown horizontal rules.

Replace string+grep name registry with bash associative arrays for O(1)
exact-match lookup, eliminating regex injection from dotted filenames.

Replace grep -c || echo 0 with grep -c || true to prevent bogus 0\n0
count that breaks the integer expression test.

Fixes: #13
Plan-by: glm-5.2
Acked-by: deepseek-v4-pro
Signed-off-by: Sean Bruen <kyau@kyau.net>
Replace the awk+sed frontmatter parser with a small Node.js helper using
js-yaml. This handles quoted values, folded/block scalars, comments, and
CRLF line endings correctly — all cases the old parser got wrong.

Add js-yaml as a devDependency. Fix two skill files where unquoted colons
in description values were ambiguous YAML (Hard-gate: and Two-phase:).

Fixes: #14
Plan-by: glm-5.2
Acked-by: deepseek-v4-pro
Signed-off-by: Sean Bruen <kyau@kyau.net>
Remove always-green shellcheck fallback in CI (|| true masked failures).

Fix grep -c regression: use ''grep -c ...) || count=0'' instead of
''|| true'' (handles both zero-match and file-error cases correctly).

Add Node.js prerequisite check to validate-harness.sh before delegating
to the YAML frontmatter parser.

Add UTF-8 BOM stripping to frontmatter-parser.js for Windows editors.

Fix test harness: use exit code check instead of fragile error-message
substring; add trap for temp-dir cleanup; guard empty-string arithmetic.

Add Node.js globals config for .github/scripts/ JS files in ESLint.

Plan-by: glm-5.2
Acked-by: deepseek-v4-pro
Signed-off-by: Sean Bruen <kyau@kyau.net>
Plan-by: glm-5.2
Acked-by: deepseek-v4-pro
Signed-off-by: kyau <git@kyaulabs.com>
@kyau kyau changed the title refactor(harness): improve hooks and harness robustness and YAML parsing Acked-by: deepseek-v4-pro Signed-off-by: kyau <kyau@kyau.net> refactor(harness): improve hooks and harness robustness and YAML parsing Jul 6, 2026
@kyau
kyau force-pushed the feat/kyau-f5fix-hooks-harness-fixes branch from 4b278f6 to 3662da1 Compare July 6, 2026 06:10
kyau added 2 commits July 5, 2026 23:20
Plan-by: glm-5.2
Acked-by: deepseek-v4-pro
Signed-off-by: kyau <git@kyaulabs.com>
Plan-by: glm-5.2
Acked-by: deepseek-v4-pro
Signed-off-by: kyau <git@kyaulabs.com>
@kyau
kyau requested a review from kyaulabs-bot July 6, 2026 06:37
@kyaulabs-bot
kyaulabs-bot merged commit 4599700 into develop Jul 6, 2026
1 check passed
@kyau
kyau deleted the feat/kyau-f5fix-hooks-harness-fixes branch July 6, 2026 06:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants