Skip to content
18 changes: 13 additions & 5 deletions CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ 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}`), registry operations (`/api/v1/registry/registries/descriptions`, `/api/v1/registry/config/registry/{name}`), package search/info primary path (`/packages/info`), token management (`/app/token/activelist`), user management (`/app/config/features/manage`), and landing page management (`/app/homepage` GET, `/app/config/homepage` POST/DELETE)
- **GraphQL API**: Used for projects, user info, and package search/info fallback (`/v1/graphql`)
- **Headers**: All GraphQL requests require `X-Hasura-Role: jhuser` header
- **REST API**: Used for dataset operations (`/api/v1/datasets`, `/datasets/{uuid}/url/{version}`), registry operations (`/api/v1/registry/registries/descriptions`, `/api/v1/registry/config/registry/{name}`, `/api/v1/registry/config/registrator/{name}`), package search/info primary path (`/packages/info`), token management (`/app/token/activelist`), user management (`/app/config/features/manage`), admin group management (`/app/config/groups`), and landing page management (`/app/homepage` GET, `/app/config/homepage` POST/DELETE)
- **GraphQL API**: Used for projects, user info, user list (`public_users`), group list, and package search/info fallback (`/v1/graphql`)
- **Headers**: All GraphQL requests require `Authorization: Bearer <id_token>`, `X-Hasura-Role: jhuser`, and `X-Juliahub-Ensure-JS: true`
- **Authentication**: Uses ID tokens (`token.IDToken`) for API calls

3. **Command Structure**:
Expand Down Expand Up @@ -128,6 +128,8 @@ echo '{
"enabled": true, "display_apps": true, "owner": "", "sync_schedule": null,
"download_providers": [{
"type": "cacheserver", "host": "https://pkg.juliahub.com",
"credential_key": "JC Auth Token",
"server_type": "", "github_credential_type": "", "api_host": "", "url": "", "user_name": ""
"credential_key": "JC Auth Token"
}]
}' | go run . registry config add
Expand All @@ -143,8 +145,11 @@ go run . project list
go run . project list --user
go run . project list --user john
go run . user info
go run . user list
go run . group list
go run . admin user list
go run . admin user list --verbose
go run . admin group list
```

### Test token operations
Expand Down Expand Up @@ -372,7 +377,7 @@ jh run setup
## Development Notes

- All ID fields in GraphQL responses should be typed correctly (string for UUIDs, int64 for user IDs)
- GraphQL queries are embedded as strings (consider external .gql files for complex queries)
- GraphQL queries are embedded at compile time using `go:embed` from `.gql` files (`userinfo.gql`, `users.gql`, `groups.gql`, `projects.gql`)
- Error handling includes both HTTP and GraphQL error responses
- Token refresh is automatic via `ensureValidToken()`
- File uploads use multipart form data with proper content types
Expand All @@ -388,8 +393,11 @@ jh run setup
- Clone command supports `project` (without username) and defaults to the logged-in user's username
- 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
- `jh user list` uses GraphQL `public_users` query (via `users.gql`) and displays `<name> (<username>)` per line
- `jh group list` uses GraphQL groups query (via `groups.gql`) and displays one group name per line
- Admin user list command (`jh admin user list`) uses REST API endpoint `/app/config/features/manage` which requires appropriate permissions
- User list output is concise by default (Name and Email only); use `--verbose` flag for detailed information (UUID, groups, features)
- Admin group list command (`jh admin group list`) uses REST API endpoint `/app/config/groups` which requires appropriate permissions
- Admin user list output is compact by default (`<name> (<email>)`); use `--verbose` flag for detailed information (UUID, groups, features)
- Registry list output is concise by default (UUID and Name only); use `--verbose` flag for detailed information (owner, creation date, package count, description)
- Registry config command (`jh registry config <name>`) uses REST API endpoint `/api/v1/registry/config/registry/{name}` (GET) and prints the full JSON response
- Registry add/update commands (`jh registry config add` / `jh registry config update`) use REST API endpoint `/api/v1/registry/config/registry/{name}` (POST); the backend creates or updates based on whether the registry already exists
Expand Down
34 changes: 30 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ A command-line interface for interacting with JuliaHub, a platform for Julia com
- **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
- **User Management**: Display user information and view profile details
- **Administrative Commands**: Manage users, tokens, and system resources (requires admin permissions)
- **User Management**: Display user information, list users and groups
- **Administrative Commands**: Manage users, groups, tokens, and system resources (requires admin permissions)

## Installation

Expand Down Expand Up @@ -174,6 +174,9 @@ go build -o jh .
- `jh registry config <name>` - Show the full JSON configuration for a registry
- `jh registry config add` - Add a new registry (JSON payload via stdin or `--file`)
- `jh registry config update` - Update an existing registry (same JSON schema as add, same flags)
- `jh registry permission list <registry>` - List permissions for a registry
Comment on lines +174 to +177
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are these changes part of this PR

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same, checked out from the registry config pr, will undo after that is merged

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removed

- `jh registry permission set <registry> --user|--group <name> --privilege download|register` - Add or update a permission
- `jh registry permission remove <registry> --user|--group <name>` - Remove a permission


### Project Management (`jh project`)
Expand Down Expand Up @@ -202,15 +205,23 @@ go build -o jh .

### User Information (`jh user`)

- `jh user info` - Show detailed user information
- `jh user info` - Show detailed information about the logged-in user
- `jh user list` - List all users (`<name> (<username>)` format, via GraphQL)

### Group Information (`jh group`)

- `jh group list` - List all groups (one per line, via GraphQL)

### Administrative Commands (`jh admin`)

#### User Management
- `jh admin user list` - List all users (requires appropriate permissions)
- Default: Shows only Name and Email
- Default: Shows `<name> (<email>)` per line
- `jh admin user list --verbose` - Show detailed user information including UUID, groups, and features

#### Group Management
- `jh admin group list` - List all groups via REST API (requires appropriate permissions)

#### Token Management
- `jh admin token list` - List all tokens (requires appropriate permissions)
- Default: Shows only Subject, Created By, and Expired status
Expand Down Expand Up @@ -313,6 +324,8 @@ echo '{
"enabled": true, "display_apps": true, "owner": "", "sync_schedule": null,
"download_providers": [{
"type": "cacheserver", "host": "https://pkg.juliahub.com",
"credential_key": "JC Auth Token",
"server_type": "", "github_credential_type": "", "api_host": "", "url": "", "user_name": ""
"credential_key": "JC Auth Token"
}]
}' | jh registry config add
Expand All @@ -337,6 +350,16 @@ jh project list --user
jh project list --user alice
```

### User and Group Operations

```bash
# List users (GraphQL)
jh user list

# List groups (GraphQL)
jh group list
```

### Administrative Operations

```bash
Expand All @@ -346,6 +369,9 @@ jh admin user list
# List users with detailed information
jh admin user list --verbose

# List all groups via REST (requires admin permissions)
jh admin group list

# List all tokens (requires admin permissions)
jh admin token list

Expand Down
12 changes: 12 additions & 0 deletions groups.gql
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
query Groups($name: String = "%", $limit: Int = 100) {
groups(where: { name: { _ilike: $name } }, limit: $limit) {
name
group_id
}
products {
name
display_name
id
compute_type_name
}
}
Loading
Loading