Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
75 changes: 73 additions & 2 deletions CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ This file provides guidance to Claude Code (claude.ai/code) when working with co

## Project Overview

This is a Go-based CLI tool for interacting with JuliaHub, a platform for Julia computing. The CLI provides commands for authentication, dataset management, project management, user information, Git integration, and Julia integration.
This is a Go-based CLI tool for interacting with JuliaHub, a platform for Julia computing. The CLI provides commands for authentication, dataset management, registry management, package management, project management, user information, Git integration, and Julia integration.

## Architecture

Expand All @@ -13,6 +13,8 @@ The application follows a command-line interface pattern using the Cobra library
- **main.go**: Core CLI structure with command definitions and configuration management
- **auth.go**: OAuth2 device flow authentication with JWT token handling
- **datasets.go**: Dataset operations (list, download, upload, status) with REST API integration
- **registries.go**: Registry operations (list) with REST API integration
- **packages.go**: Package operations (search, info, dependency) with GraphQL API and documentation API integration
- **projects.go**: Project management using GraphQL API with user filtering
- **user.go**: User information retrieval using GraphQL API
- **git.go**: Git integration (clone, push, fetch, pull) with JuliaHub authentication
Expand All @@ -29,14 +31,16 @@ The application follows a command-line interface pattern using the Cobra library
- Stores tokens securely in `~/.juliahub` with 0600 permissions

2. **API Integration**:
- **REST API**: Used for dataset operations (`/api/v1/datasets`, `/datasets/{uuid}/url/{version}`)
- **REST API**: Used for dataset operations (`/api/v1/datasets`, `/datasets/{uuid}/url/{version}`) and registry operations (`/api/v1/ui/registries/descriptions`)
- **GraphQL API**: Used for projects and user info (`/v1/graphql`)
- **Headers**: All GraphQL requests require `X-Hasura-Role: jhuser` header
- **Authentication**: Uses ID tokens (`token.IDToken`) for API calls

3. **Command Structure**:
- `jh auth`: Authentication commands (login, refresh, status, env)
- `jh dataset`: Dataset operations (list, download, upload, status)
- `jh registry`: Registry operations (list with REST API, supports verbose mode)
- `jh package`: Package operations (search, info, dependency with GraphQL API and documentation API, supports filtering by registry, installation status, and failures)
- `jh project`: Project management (list with GraphQL, supports user filtering)
- `jh user`: User information (info with GraphQL)
- `jh clone`: Git clone with JuliaHub authentication and project name resolution
Expand Down Expand Up @@ -84,6 +88,32 @@ go run . dataset download <dataset-name>
go run . dataset upload --new ./file.tar.gz
```

### Test registry operations
```bash
go run . registry list
go run . registry list --verbose
```

### Test package operations
```bash
# Search for packages
go run . package search dataframes
go run . package search --verbose plots
go run . package search --limit 20 ml
go run . package search --registries General optimization
go run . package search --installed

# Get package info
go run . package info DataFrames
go run . package info Plots --registries General

# Get package dependencies
go run . package dependency DataFrames
go run . package dependency DataFrames --indirect
go run . package dependency DataFrames --all --indirect
go run . package dependency CSV --registry General
```

### Test project and user operations
```bash
go run . project list
Expand Down Expand Up @@ -163,6 +193,8 @@ The application uses OAuth2 device flow:

### REST API Integration
- **Dataset operations**: Use presigned URLs for upload/download
- **Registry operations**: `/api/v1/registry/registries/descriptions` for listing registries
- **Package documentation**: `/docs/{registry}/{package}/stable/pkg.json` for package dependency information
- **Authentication**: Bearer token with ID token
- **Upload workflow**: 3-step process (request presigned URL, upload to URL, close upload)

Expand Down Expand Up @@ -215,6 +247,41 @@ git clone https://github.com/user/repo.git # Ignored by
- **Token management**: Stores and refreshes tokens per server automatically
- **Error handling**: Graceful fallback to other credential helpers for non-JuliaHub URLs

## Package Management

The CLI provides comprehensive package discovery and dependency analysis:

### Package Search and Info
- **Search**: `jh package search` uses GraphQL API to search packages across registries
- **Info**: `jh package info` retrieves detailed package metadata
- **Filtering**: Supports filtering by registry, installation status, and failures

### Package Dependency (`jh package dependency`)
- **Endpoint**: Uses package documentation API at `/docs/{registry}/{package}/stable/pkg.json`
- **Registry resolution**: Automatically uses first registry package belongs to, or specific registry via `--registry` flag
- **Dependency types**: Distinguishes between direct and indirect dependencies via `direct` field in API response
- **Display limits**:
- Default: Shows up to 10 direct dependencies
- With `--indirect`: Shows up to 10 direct and 50 indirect dependencies
- With `--all`: Shows all dependencies without limits
- **Output format**:
- Direct-only mode: Single table with columns: NAME, REGISTRY, UUID, VERSIONS
- Indirect mode: Separate sections for direct and indirect dependencies with columns: NAME, REGISTRY, UUID, VERSIONS
- Registry column shows which registry each dependency belongs to (empty for stdlib packages)

#### Implementation Details (`packages.go`)
- `getPackageDependencies()`: Main function for dependency retrieval
1. Fetches all registries to get registry IDs for GraphQL query
2. Searches for package using GraphQL to get registry information
3. Determines target registry (first registry or user-specified)
4. Fetches package documentation JSON from docs endpoint
5. Filters and limits dependencies based on flags
6. Displays results in formatted tables with separate sections

#### Data Structures
- `PackageDependency`: Represents a single dependency with fields for direct/indirect status, name, UUID, versions, registry, and slug
- `PackageDocsResponse`: Response from documentation API containing package metadata and dependencies array

## Julia Integration

The CLI provides Julia installation and execution with JuliaHub configuration:
Expand Down Expand Up @@ -273,6 +340,10 @@ jh run setup
- Clone command automatically resolves `username/project` format to project UUIDs
- Folder naming conflicts are resolved with automatic numbering (project-1, project-2, etc.)
- Credential helper follows Git protocol: responds only to JuliaHub URLs, ignores others
- Registry list output is concise by default (UUID and Name only); use `--verbose` flag for detailed information (owner, creation date, package count, description)
- Package search output shows column headers (NAME, OWNER, VERSION, DESCRIPTION) by default; use `--verbose` flag for detailed key-value format
- Package info command performs exact name match (case-insensitive) and displays detailed package information
- Package commands support registry filtering via `--registries` flag (comma-separated list)

## Implementation Details

Expand Down
65 changes: 65 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ A command-line interface for interacting with JuliaHub, a platform for Julia com

- **Authentication**: OAuth2 device flow authentication with JWT token handling
- **Dataset Management**: List, download, upload, and check status of datasets
- **Registry Management**: List and manage Julia package registries
- **Package Management**: Search and explore Julia packages with filtering and detailed information
- **Project Management**: List and filter projects using GraphQL API
- **Git Integration**: Clone, push, fetch, and pull with automatic JuliaHub authentication
- **Julia Integration**: Install Julia and run with JuliaHub package server configuration
Expand Down Expand Up @@ -148,6 +150,31 @@ go build -o jh .
- `jh dataset upload [dataset-id] <file-path>` - Upload a dataset
- `jh dataset status <dataset-id> [version]` - Show dataset status

### Registry Management (`jh registry`)

- `jh registry list` - List all package registries on JuliaHub
- Default: Shows only UUID and Name
- `jh registry list --verbose` - Show detailed registry information including owner, creation date, package count, and description

### Package Management (`jh package`)

- `jh package search [search-term]` - Search for Julia packages
- Default: Shows concise output with NAME, OWNER, VERSION, and DESCRIPTION columns
- `jh package search --verbose` - Show detailed package information
- `jh package search --limit 20` - Limit number of results
- `jh package search --offset 10` - Skip first N results
- `jh package search --registries General` - Filter by specific registries
- `jh package search --installed` - Show only installed packages
- `jh package search --not-installed` - Show only packages not installed
- `jh package search --has-failures` - Show only packages with download failures
- `jh package info <package-name>` - Get detailed information about a specific package by exact name match
- `jh package info --registries General` - Search in specific registries only
- `jh package dependency <package-name>` - List package dependencies
- Default: Shows up to 10 direct dependencies
- `jh package dependency --indirect` - Include indirect dependencies (up to 10 direct, 50 indirect)
- `jh package dependency --all` - Show all dependencies without limits
- `jh package dependency --registry General` - Specify registry to use

### Project Management (`jh project`)

- `jh project list` - List all accessible projects
Expand Down Expand Up @@ -214,6 +241,44 @@ jh dataset upload --new ./my-data.tar.gz
jh dataset upload my-dataset ./updated-data.tar.gz
```

### Registry Operations

```bash
# List all registries (UUID and Name only)
jh registry list

# List registries with detailed information
jh registry list --verbose

# List registries on custom server
jh registry list -s yourinstall
```

### Package Operations

```bash
# Search for packages (shows concise output with columns)
jh package search dataframes

# Search with detailed information
jh package search --verbose plots

# Search with filters
jh package search --installed
jh package search --limit 20 ml
jh package search --registries General optimization

# Get detailed info about a specific package
jh package info DataFrames
jh package info Plots --registries General

# List package dependencies
jh package dependency DataFrames # Shows up to 10 direct dependencies
jh package dependency DataFrames --indirect # Includes indirect dependencies
jh package dependency DataFrames --all --indirect # Shows all dependencies
jh package dependency CSV --registry General # Use specific registry
```

### Project Operations

```bash
Expand Down
Loading