( ctx context.Context, cmd *cobra.Command, deps commandDeps, originRef string, )
| 84 | } |
| 85 | |
| 86 | func 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 | |
| 140 | func skillListItems(allSkills []*skills.Skill, sourceFilter string) ([]skillListItem, error) { |
| 141 | filter, err := normalizeSkillSourceFilter(sourceFilter) |
no test coverage detected