v0.3.95 beceda1

before_start.go RawHistoryFolder

1package extensions
2
3import (
4	"context"
5	"encoding/json"
6	"fmt"
7
8	"github.com/patriceckhart/zot/packages/agent/extproto"
9)
10
11// MaxSystemPromptResponseSize limits the encoded system_prompt value. The
12// transport additionally limits each complete response frame to 4 MiB.
13const MaxSystemPromptResponseSize = 1024 * 1024
14
15// InterceptBeforeAgentStart chains exact prompt replacements in load order.
16// Failures are advisory, never permission decisions.
17func (m *Manager) InterceptBeforeAgentStart(ctx context.Context, ev extproto.EventInterceptFromHost) string {
18	current := ""
19	if ev.SystemPrompt != nil {
20		current = *ev.SystemPrompt
21	}
22	ev.Event = "before_agent_start"
23	_, ev.CWD = m.SessionContext()
24	if ev.CWD == "" {
25		ev.CWD = m.cwd
26	}
27	if ev.Provider == "" {
28		ev.Provider = m.provider
29	}
30	m.mu.RLock()
31	subs := append([]*Extension(nil), m.extOrder...)
32	m.mu.RUnlock()
33	for _, ext := range subs {
34		if ctx.Err() != nil {
35			break
36		}
37		ext.mu.Lock()
38		_, subscribed := ext.interceptSubs[ev.Event]
39		ext.mu.Unlock()
40		if !subscribed {
41			continue
42		}
43		ev.SystemPrompt = &current
44		callCtx, cancel := context.WithTimeout(ctx, interceptTimeout)
45		r := m.askIntercept(callCtx, ext, ev)
46		cancel()
47		failure := r.failure
48		if failure == "" && r.Block && len(r.SystemPrompt) == 0 {
49			failure = "extension returned a blocking response; startup hooks cannot block"
50		}
51		if failure == "" && len(r.SystemPrompt) > 0 {
52			var replacement string
53			switch {
54			case len(r.SystemPrompt) > MaxSystemPromptResponseSize:
55				failure = "system_prompt exceeds 1 MiB encoded limit"
56			case r.SystemPrompt[0] != '"' || json.Unmarshal(r.SystemPrompt, &replacement) != nil:
57				failure = "system_prompt must be a string"
58			default:
59				current = replacement
60			}
61		}
62		if failure != "" {
63			message := "before_agent_start: " + failure + "; keeping current system prompt"
64			fmt.Fprintln(ext.logFile, "[zot] "+message)
65			ext.recordDiagnostic(message)
66			if m.hooks != nil {
67				m.hooks.Notify(ext.Manifest.Name, "warn", message)
68			}
69		}
70	}
71	return current
72}

Keyboard shortcuts

Single-key shortcuts are on. ctrl k and esc work whatever this says.

ctrl k :
go to a section, branch, tag, file or repository
?
this list
j k
move the row cursor down / up
enter
open the row under the cursor; on Files, a directory opens or closes in place
↑ ↓ ← → home end
in the file tree (focus on a row): previous / next row, close / open a directory or go to its parent / first entry, first / last row. They never open a file
l h
on Files: open a directory or a file / close a directory or go up to its parent, then to the parent page. Elsewhere: into the side panel (on a merge request, its files) / back to the content; there j k move between its controls
g g G
first / last row
/
filter the list; on Files, find a file anywhere in the repository (esc clears, enter opens the best match)
b
switch branch or tag
g s g f g c g b g m g i g r g a
tabs: summary, files, commits, branches & tags, merge requests, issues, releases, actions (when available)
g h
home
w
wide mode: use the whole width of the screen, or not (remembered)
y
copy a permalink pinned to the commit
d u x
diff: split / unified / collapse or expand all
e E
diff: the whole file in view / every file, with the lines the hunks hide
n
merge request: next note in the diff
esc
close a dialog, leave a field

Branches 1

Tags 477

↑↓ moveenter openesc close