88 "time"
99
1010 "github.com/voocel/agentcore"
11- "github.com/voocel/codebot/internal/config"
1211 "github.com/voocel/codebot/internal/skill"
1312)
1413
@@ -123,12 +122,6 @@ func (s *Session) ApplySkillDelta(name string, delta skill.Delta) error {
123122 }
124123 s .applyTemporarySkillThinking (delta .Effort )
125124
126- s .mu .Lock ()
127- if len (delta .Hooks ) > 0 {
128- s .skillRuntime .hooks = mergeHooksConfig (s .skillRuntime .hooks , toConfigHooks (delta .Hooks ))
129- }
130- s .mu .Unlock ()
131-
132125 if s .skillAllowsSetter != nil {
133126 s .skillAllowsSetter (delta .AllowedTools )
134127 }
@@ -143,12 +136,6 @@ func (s *Session) clearSkillDelta() {
143136 s .clearTemporarySkillOverrides ()
144137}
145138
146- func (s * Session ) CurrentSkillHooks () config.HooksConfig {
147- s .mu .Lock ()
148- defer s .mu .Unlock ()
149- return cloneHooksConfig (s .skillRuntime .hooks )
150- }
151-
152139func (s * Session ) recordInvokedSkill (name , promptText string , paths []string ) {
153140 name = strings .TrimSpace (name )
154141 promptText = strings .TrimSpace (promptText )
@@ -193,89 +180,6 @@ func (s *Session) recordInvokedSkill(name, promptText string, paths []string) {
193180 }
194181}
195182
196- func cloneHooksConfig (src config.HooksConfig ) config.HooksConfig {
197- if len (src ) == 0 {
198- return nil
199- }
200- dst := make (config.HooksConfig , len (src ))
201- for event , entries := range src {
202- cp := make ([]config.HookEntry , len (entries ))
203- copy (cp , entries )
204- dst [event ] = cp
205- }
206- return dst
207- }
208-
209- func toConfigHooks (src skill.HooksConfig ) config.HooksConfig {
210- if len (src ) == 0 {
211- return nil
212- }
213- dst := make (config.HooksConfig , len (src ))
214- for event , entries := range src {
215- cp := make ([]config.HookEntry , len (entries ))
216- for i , entry := range entries {
217- cp [i ] = config.HookEntry {
218- Type : entry .Type ,
219- Command : entry .Command ,
220- Matcher : entry .Matcher ,
221- Blocking : entry .Blocking ,
222- Timeout : entry .Timeout ,
223- }
224- }
225- dst [event ] = cp
226- }
227- return dst
228- }
229-
230- func mergeHooksConfig (base , add config.HooksConfig ) config.HooksConfig {
231- if len (add ) == 0 {
232- return cloneHooksConfig (base )
233- }
234- merged := cloneHooksConfig (base )
235- if merged == nil {
236- merged = make (config.HooksConfig , len (add ))
237- }
238- for event , entries := range add {
239- for _ , entry := range entries {
240- if ! containsHookEntry (merged [event ], entry ) {
241- merged [event ] = append (merged [event ], entry )
242- }
243- }
244- }
245- return merged
246- }
247-
248- func containsHookEntry (entries []config.HookEntry , target config.HookEntry ) bool {
249- for _ , entry := range entries {
250- if hookEntryEqual (entry , target ) {
251- return true
252- }
253- }
254- return false
255- }
256-
257- func hookEntryEqual (a , b config.HookEntry ) bool {
258- return a .Type == b .Type &&
259- a .Command == b .Command &&
260- a .Matcher == b .Matcher &&
261- boolPtrValue (a .Blocking ) == boolPtrValue (b .Blocking ) &&
262- intPtrValue (a .Timeout ) == intPtrValue (b .Timeout )
263- }
264-
265- func boolPtrValue (v * bool ) bool {
266- if v == nil {
267- return false
268- }
269- return * v
270- }
271-
272- func intPtrValue (v * int ) int {
273- if v == nil {
274- return 0
275- }
276- return * v
277- }
278-
279183func cloneInvocationCounts (src map [string ]int ) map [string ]int {
280184 if len (src ) == 0 {
281185 return nil
0 commit comments