MCPcopy Create free account
hub / github.com/compozy/agh / resolveSkillCommandScope

Function resolveSkillCommandScope

internal/cli/skill_workspace.go:86–138  ·  view source on GitHub ↗
(
	ctx context.Context,
	cmd *cobra.Command,
	deps commandDeps,
	originRef string,
)

Source from the content-addressed store, hash-verified

84}
85
86func resolveSkillCommandScope(
87 ctx context.Context,
88 cmd *cobra.Command,
89 deps commandDeps,
90 originRef string,
91) (skillCommandScope, error) {
92 workspaceRef, err := commandWorkspaceFlag(cmd)
93 if err != nil {
94 return skillCommandScope{}, err
95 }
96 agentRef, err := commandSkillAgentFlag(cmd)
97 if err != nil {
98 return skillCommandScope{}, err
99 }
100
101 scope := skillCommandScope{
102 query: SkillQuery{
103 Workspace: workspaceRef,
104 ForAgent: agentRef,
105 },
106 useDaemon: workspaceRef != "",
107 }
108 if scope.useDaemon {
109 return scope, nil
110 }
111 if agentRef != "" {
112 return scope, nil
113 }
114
115 credentials := agentCredentialsFromEnv(deps)
116 if strings.TrimSpace(credentials.SessionID) == "" && strings.TrimSpace(credentials.AgentName) == "" {
117 return scope, nil
118 }
119
120 client, err := clientFromDeps(deps)
121 if err != nil {
122 return skillCommandScope{}, err
123 }
124 caller, err := resolveAgentCallerFromEnv(ctx, deps, client, "", originRef)
125 if err != nil {
126 return skillCommandScope{}, err
127 }
128
129 scope.query = SkillQuery{
130 Workspace: firstNonEmpty(
131 strings.TrimSpace(caller.Session.WorkspaceID),
132 strings.TrimSpace(caller.Session.WorkspacePath),
133 ),
134 ForAgent: strings.TrimSpace(caller.Session.AgentName),
135 }
136 scope.useDaemon = scope.query.Workspace != "" || scope.query.ForAgent != ""
137 return scope, nil
138}
139
140func skillListItems(allSkills []*skills.Skill, sourceFilter string) ([]skillListItem, error) {
141 filter, err := normalizeSkillSourceFilter(sourceFilter)

Callers 5

newSkillListCommandFunction · 0.85
runSkillViewCommandFunction · 0.85
newSkillInfoCommandFunction · 0.85
newSkillWhereCommandFunction · 0.85
newSkillActionCommandFunction · 0.85

Calls 6

commandWorkspaceFlagFunction · 0.85
commandSkillAgentFlagFunction · 0.85
agentCredentialsFromEnvFunction · 0.85
clientFromDepsFunction · 0.85
firstNonEmptyFunction · 0.70

Tested by

no test coverage detected