feature/hook discoverability 2603#228
Merged
Merged
Conversation
Owner
emesal
commented
Mar 15, 2026
- feat: add (harness docs) module with hooks-docs for hook discoverability
- fix: valid JSON in generated hooks.md + category validation test
Adds HOOK_METADATA as the single source of truth for all hook contracts, replacing the hand-authored docs/hooks.md hook reference. From it we derive: - hooks-docs: a scheme alist injected into every tein context, discoverable via (import (harness docs)) then (describe hooks-docs) or (module-doc hooks-docs 'pre_message) for a specific hook's payload/return contract - docs/hooks.md hook reference section: regenerated via `just generate-docs` (cargo test -p chibi-core --test generate_docs) HARNESS_PREAMBLE converts from &str to LazyLock<String> to splice the generated hooks-docs alist at startup. EVAL_PRELUDE imports (harness docs) so both hooks-docs and harness-tools-docs are pre-available in all contexts. Tests: completeness (every HookPoint variant has a HOOK_METADATA entry), scheme alist evaluation, (harness docs) module availability in both tiers, and markdown freshness (fails if docs/hooks.md is stale).
- json_block() now places commas after values (before // comments) so generated JSON blocks are syntactically valid once comments stripped; previously commas were appended after the comment text - replace split_once description-first-word heuristic for string examples with "..." placeholder (consistent with return fields, avoids corpus strings like "file_head," leaking into example values) - add test_hook_metadata_categories_valid: asserts every HOOK_METADATA entry's category appears in generate_hooks_markdown's category_order, preventing silent category drop on typo/new category - add explanatory comment to HARNESS_DOCS_MODULE explaining the intentional top-level binding re-export pattern (no local definitions) - regenerate docs/hooks.md from fixed generator
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.