MCPcopy Create free account
hub / github.com/GongShichen/LuminaCode / Execute

Method Execute

skills/tool.go:55–105  ·  view source on GitHub ↗
(ctx context.Context, execCtx coretools.ExecutionContext, input any)

Source from the content-addressed store, hash-verified

53}
54
55func (t *SkillTool) Execute(ctx context.Context, execCtx coretools.ExecutionContext, input any) (string, error) {
56 in := derefSkillToolInput(input)
57 cwd := "."
58 if raw, ok := execCtx["cwd"].(string); ok && raw != "" {
59 cwd = raw
60 }
61 skill := t.Registry.FindVisible(in.Skill, cwd)
62 if skill == nil {
63 return "Skill not found or not visible from the current path: " + in.Skill, nil
64 }
65 if skill.Frontmatter.DisableModelInvocation {
66 return "Skill '" + skill.CanonicalName + "' cannot be invoked automatically by the model.", nil
67 }
68 approve := func(req SkillShellPermissionRequest) bool {
69 requester, _ := execCtx["_request_skill_shell_permission"].(func(SkillShellPermissionRequest) bool)
70 if requester == nil {
71 return false
72 }
73 return requester(req)
74 }
75 sessionID, _ := execCtx["_session_id"].(string)
76 if sessionID == "" {
77 sessionID = uuid.NewString()[:12]
78 }
79 execution, err := t.Executor.Execute(ctx, *skill, in.Args, sessionID, approve, registryFromContext(execCtx), execCtx["parent_state"], execCtx)
80 if err != nil {
81 return "", err
82 }
83 prompt := ""
84 if execution.Prompt != nil {
85 prompt = *execution.Prompt
86 }
87 if persistence, _ := execCtx["_skill_persistence"].(*SkillPersistence); persistence != nil && prompt != "" {
88 scope, _ := execCtx["_skill_agent_scope"].(string)
89 if scope == "" {
90 scope = "main"
91 }
92 turnCount, _ := execCtx["_turn_count"].(int)
93 persistence.RecordInvocation(scope, skill.CanonicalName, skillPath(*skill), prompt, turnCount)
94 }
95 if execution.Mode == "inline" {
96 pending, _ := execCtx["_pending_skill_messages"].([]map[string]any)
97 pending = append(pending, t.Executor.BuildInlineSkillMessage(*skill, prompt, false))
98 execCtx["_pending_skill_messages"] = pending
99 return fmt.Sprintf("Skill '%s' injected into the conversation. Continue using the new skill context.", skill.CanonicalName), nil
100 }
101 if execution.ResultText != nil {
102 return *execution.ResultText, nil
103 }
104 return fmt.Sprintf("Skill '%s' completed.", skill.CanonicalName), nil
105}
106
107func (t *SkillTool) NeedsPermission(any) bool { return false }
108

Callers

nothing calls this directly

Calls 7

derefSkillToolInputFunction · 0.85
registryFromContextFunction · 0.85
skillPathFunction · 0.85
FindVisibleMethod · 0.80
RecordInvocationMethod · 0.80
ExecuteMethod · 0.65

Tested by

no test coverage detected