Documentation
¶
Index ¶
- Constants
- func AdditionalContext(enhanced string) string
- func EncodeHookOutput(w io.Writer, output HookOutput) error
- func EncodeHookOutputOrFallback(w io.Writer, output HookOutput) int
- func HasOpenPEHookConfig(path string) bool
- func HasUserOpenPEHookConfig() bool
- func HookCommand(bin string, envFile string) string
- func HookCommandForScope(bin string, envFile string, scope string) string
- func HooksConfigContainsOpenPEHook(data []byte) bool
- func IsOpenPEHookCommand(command string) bool
- func LastPreviewPath() (string, error)
- func LastPromptPath() (string, error)
- func MarkdownPreview(enhanced string, language string) string
- func MergeHooksConfig(existing []byte, command string, timeout int) ([]byte, error)
- func PreviewReason(cachePath string, language string) string
- func ProjectEnvFile(cwd string) string
- func ProjectHooksPath(cwd string) string
- func ReadLastPreview() (string, error)
- func ReadLastPrompt() (string, error)
- func SavePreview(enhanced string, language string) (string, error)
- func ShouldHandleHook(input HookInput, auto bool) (bool, bool)
- func ShouldSkipDuplicateHook(scope string, envFile string, cwd string) bool
- func UserHooksPath() string
- func WriteTerminalPreview(content string) error
- type HookInput
- type HookOptions
- type HookOutput
- func Block(reason string) HookOutput
- func BlockPreview(reason string, terminalPreview string, previewPrompt string) HookOutput
- func HandleHook(ctx context.Context, service *enhancer.Service, input HookInput, ...) (HookOutput, error)
- func HookError(manual bool, message string, language string) HookOutput
- func Skip(message string) HookOutput
- type HookSpecificOutput
- type Mode
Constants ¶
View Source
const (
ModePreview = manual.ModePreview
)
View Source
const UserPromptSubmit = "UserPromptSubmit"
Variables ¶
This section is empty.
Functions ¶
func AdditionalContext ¶
func EncodeHookOutput ¶
func EncodeHookOutput(w io.Writer, output HookOutput) error
func EncodeHookOutputOrFallback ¶
func EncodeHookOutputOrFallback(w io.Writer, output HookOutput) int
func HasOpenPEHookConfig ¶
func HasUserOpenPEHookConfig ¶
func HasUserOpenPEHookConfig() bool
func HookCommand ¶
func HookCommandForScope ¶
func IsOpenPEHookCommand ¶
func LastPreviewPath ¶
func LastPromptPath ¶
func MarkdownPreview ¶
func MergeHooksConfig ¶
func PreviewReason ¶
func ProjectEnvFile ¶
func ProjectHooksPath ¶
func ReadLastPreview ¶
func ReadLastPrompt ¶
func ShouldSkipDuplicateHook ¶
func UserHooksPath ¶
func UserHooksPath() string
func WriteTerminalPreview ¶
Types ¶
type HookInput ¶
type HookOptions ¶
type HookOptions struct {
Client string
Mode string
Auto bool
CWD string
Prompt string
Language string
Timeout time.Duration
History []enhancer.Message
// Inject makes a manual `pe` trigger inject the enhanced prompt as
// additional context (exit 0, hookSpecificOutput.additionalContext) instead
// of holding the original with a clipboard/preview review. Codex CLI
// consumes UserPromptSubmit additionalContext into the model context, so
// this is a real injection there. Default false preserves the review model.
Inject bool
// MaxContextTokens forwards the consumer-layer global token budget
// (config.Config.MaxContextTokens, sourced from
// OPENPE_MAX_CONTEXT_TOKENS) into enhancer.Request.Options. Zero
// means "no budget" so this field is purely additive — callers that
// do not set it preserve the historical unbounded behaviour.
MaxContextTokens int
CacheDir string
// SpecsDir / SpecMaxChars configure explicit user prompt-spec loading
// (`pe+<name> <task>`, config.Config.Specs). Empty dir means the per-user
// default ~/.config/openpe/specs; MaxChars <= 0 means the specs package
// default. Spec resolution failures BLOCK the enhancement (business
// contract D7: never silently drop a user-named spec).
SpecsDir string
SpecMaxChars int
}
type HookOutput ¶
type HookOutput struct {
Continue bool `json:"continue,omitempty"`
Decision string `json:"decision,omitempty"`
Reason string `json:"reason,omitempty"`
SystemMessage string `json:"systemMessage,omitempty"`
HookSpecificOutput *HookSpecificOutput `json:"hookSpecificOutput,omitempty"`
TerminalPreview string `json:"-"`
PreviewPrompt string `json:"-"`
// Warnings carries enhancer.Response.Warnings (out-of-context numbers /
// undecided actions / language guard) so the runner folds them into the
// user-facing disclosure before the user acts on the enhancement. Not part
// of the wire JSON.
Warnings []string `json:"-"`
// AppliedSpecs lists the user spec names appended to the enhanced prompt
// (`pe+<name>`), so the runner can disclose "applied specs: …" alongside
// the delivery status. Not part of the wire JSON.
AppliedSpecs []string `json:"-"`
}
func Block ¶
func Block(reason string) HookOutput
func BlockPreview ¶
func BlockPreview(reason string, terminalPreview string, previewPrompt string) HookOutput
func HandleHook ¶
func HandleHook(ctx context.Context, service *enhancer.Service, input HookInput, opts HookOptions) (HookOutput, error)
func Skip ¶
func Skip(message string) HookOutput
type HookSpecificOutput ¶
Click to show internal directories.
Click to hide internal directories.