feat(hooks): add inject_prompt for simplified context injection#1683
Open
Dqz00116 wants to merge 6 commits intoMoonshotAI:feat/hooksfrom
Open
feat(hooks): add inject_prompt for simplified context injection#1683Dqz00116 wants to merge 6 commits intoMoonshotAI:feat/hooksfrom
Dqz00116 wants to merge 6 commits intoMoonshotAI:feat/hooksfrom
Conversation
- Add inject_prompt field as alternative to command - Add validator to ensure command and inject_prompt are mutually exclusive - Add tests for inject_prompt validation
- Add additional_context field to HookResult - Parse additionalContext from hookSpecificOutput in JSON response - Add _run_inject_prompt_hook and _resolve_inject_prompt methods to HookEngine - Support file path auto-detection and content reading - Add tests for additional_context parsing and injection
- Collect additional_context from hook results in KimiSoul.run() - Inject collected context as system reminder message before processing user input
- Document inject_prompt field as alternative to command - Add inject_prompt usage examples - Document additionalContext JSON output for dynamic injection
- Update config-files documentation - Update hooks documentation (zh)
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.
Related Issue
N/A - This is a new feature proposal for simplifying context injection in hooks.
Description
This PR adds a simplified way to inject context into conversations via the
UserPromptSubmithook.Changes
Added
inject_promptfield toHookDef(src/kimi_cli/hooks/config.py)commandfor simple static content injectioncommandandinject_promptare mutually exclusiveAdded
additional_contextsupport (src/kimi_cli/hooks/runner.py,src/kimi_cli/hooks/engine.py)HookResultto carry context from hookshookSpecificOutput.additionalContextin JSON responsesinject_promptwithout spawning subprocessContext injection in KimiSoul (
src/kimi_cli/soul/kimisoul.py)additional_contextfrom all hook resultsDocumentation (
docs/en/customization/hooks.md)inject_promptfield and usage examplesadditionalContextJSON outputTests (
tests/hooks/)inject_promptvalidationadditional_contextparsingUsage Example
Static content:
Checklist