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

Method workspaceRouteRef

internal/cli/client.go:3228–3254  ·  view source on GitHub ↗
(ctx context.Context, ref string)

Source from the content-addressed store, hash-verified

3226}
3227
3228func (c *unixSocketClient) workspaceRouteRef(ctx context.Context, ref string) (string, error) {
3229 trimmed := strings.TrimSpace(ref)
3230 if trimmed == "" {
3231 return "", errors.New("cli: workspace reference is required")
3232 }
3233 if !workspaceRefLooksLikePath(trimmed) {
3234 return trimmed, nil
3235 }
3236 target, err := canonicalCLIWorkspacePath(trimmed)
3237 if err != nil {
3238 return "", err
3239 }
3240 workspaces, err := c.ListWorkspaces(ctx)
3241 if err != nil {
3242 return "", fmt.Errorf("cli: list workspaces before resolving path %q: %w", target, err)
3243 }
3244 for _, workspace := range workspaces {
3245 root, err := canonicalCLIWorkspacePath(workspace.RootDir)
3246 if err != nil {
3247 continue
3248 }
3249 if root == target {
3250 return workspace.ID, nil
3251 }
3252 }
3253 return "", fmt.Errorf("cli: workspace path %q is not registered", target)
3254}
3255
3256func workspaceRefLooksLikePath(ref string) bool {
3257 return filepath.IsAbs(ref) ||

Callers 1

GetWorkspaceMethod · 0.95

Calls 3

ListWorkspacesMethod · 0.95

Tested by

no test coverage detected