You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat: package dependency <package-name> cmd to list dependencies (#23)
* registry list cmd
* added verbose for detailed view
* package search cmd with flags
* fixed gql query issues
* refactoring
* display refactoring
* refactoring
* display registries the package belongs to
* package dependency cmd to display direct and indirect dependencies
* added openapi endpoints for package search, with fallback logic
* refactorings
* conflicts resolved
* undoing unrelated changes
* fixed conflicts
* fixed conflicts
* fixed conflicts
* some refactorings
* updated readme
* revert: move GQL query split to separate PR
Remove package_search_count.gql and restore the combined
package_search_with_count.gql approach. The split of search and count
into separate GraphQL queries will be handled in a dedicated PR.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
---------
Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
Copy file name to clipboardExpand all lines: CLAUDE.md
+50-8Lines changed: 50 additions & 8 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -3,7 +3,8 @@
3
3
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
4
4
5
5
## Project Overview
6
-
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, project management, user information, token management, Git integration, and Julia integration.
6
+
7
+
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, token management, Git integration, and Julia integration.
7
8
8
9
## Architecture
9
10
@@ -13,7 +14,7 @@ The application follows a command-line interface pattern using the Cobra library
13
14
-**auth.go**: OAuth2 device flow authentication with JWT token handling
14
15
-**datasets.go**: Dataset operations (list, download, upload, status) with REST API integration
15
16
-**registries.go**: Registry operations (list, config, add, update) with REST API integration
16
-
-**packages.go**: Package searchwith REST API primary path (`/packages/info`) and GraphQL fallback
17
+
-**packages.go**: Package operations (search, dependency) with REST API primary path (`/packages/info`), GraphQL fallback, and documentation API (`/docs/{registry}/{package}/stable/pkg.json`)
17
18
-**projects.go**: Project management using GraphQL API with user filtering
18
19
-**user.go**: User information retrieval using GraphQL API and REST API for listing users
19
20
-**tokens.go**: Token management operations (list) with REST API integration
@@ -42,9 +43,8 @@ The application follows a command-line interface pattern using the Cobra library
-`jh registry`: Registry operations (list, config — all via REST API)
44
45
-`jh registry config`: Show registry JSON config by name; subcommands add/update accept JSON via stdin or `--file`
45
-
-`jh package`: Package search and info (REST primary via `/packages/info`, GraphQL fallback; supports filtering by registry)
46
+
-`jh package`: Package search and dependency (REST primary via `/packages/info`, GraphQL fallback; dependency data from `/docs/{registry}/{package}/stable/pkg.json`)
46
47
-`jh project`: Project management (list with GraphQL, supports user filtering)
47
-
-`jh package`: Package search (REST primary via `/packages/info`, GraphQL fallback)
-**Filtering**: Supports filtering by registry, installation status, and failures
304
+
305
+
### Package Dependency (`jh package dependency`)
306
+
-**Endpoint**: Uses package documentation API at `/docs/{registry}/{package}/stable/pkg.json`
307
+
-**Registry resolution**: Automatically uses first registry package belongs to, or specific registry via `--registry` flag
308
+
-**Dependency types**: Distinguishes between direct and indirect dependencies via `direct` field in API response
309
+
-**Display limits**:
310
+
- Default: Shows up to 10 direct dependencies
311
+
- With `--indirect`: Shows up to 10 direct and 50 indirect dependencies
312
+
-**Output format**:
313
+
- Direct-only mode: Single table with columns: NAME, REGISTRY, UUID, VERSIONS
314
+
- Indirect mode: Separate sections for direct and indirect dependencies with columns: NAME, REGISTRY, UUID, VERSIONS
315
+
- Registry column shows which registry each dependency belongs to (empty for stdlib packages)
316
+
317
+
#### Implementation Details (`packages.go`)
318
+
-`getPackageDependencies()`: Main function for dependency retrieval
319
+
1. Fetches all registries to get registry IDs for GraphQL query
320
+
2. Searches for package using GraphQL to get registry information
321
+
3. Determines target registry (first registry or user-specified)
322
+
4. Fetches package documentation JSON from docs endpoint
323
+
5. Filters and limits dependencies based on flags
324
+
6. Displays results in formatted tables with separate sections
325
+
326
+
#### Data Structures
327
+
-`PackageDependency`: Represents a single dependency with fields for direct/indirect status, name, UUID, versions, registry, and slug
328
+
-`PackageDocsResponse`: Response from documentation API containing package metadata and dependencies array
329
+
289
330
## Julia Integration
290
331
291
332
The CLI provides Julia installation and execution with JuliaHub configuration:
@@ -362,14 +403,15 @@ jh run setup
362
403
- Landing page commands (`jh admin landing-page`) use REST API: GET `/app/homepage` (show), POST `/app/config/homepage` (update), DELETE `/app/config/homepage` (remove); require appropriate permissions
363
404
- Landing page `update` command accepts content inline as an argument, from a file via `--file`, or piped via stdin (priority: `--file` > arg > stdin)
364
405
- Landing page response uses custom JSON unmarshaling (`homepageResponse`) to handle `message` being either an object or a string
365
-
- Package search (`jh package search`) and info (`jh package info`) both try REST API (`/packages/info`) first, then fall back to GraphQL (`FilteredPackagesWithCount` via `/v1/graphql`) on failure; a warning is printed to stderr when the fallback is used
406
+
- Package search (`jh package search`) and info (`jh package info`) both try REST API (`/packages/info`) first, then fall back to GraphQL (`FilteredPackages` / `FilteredPackagesCount` via `/v1/graphql`) on failure; a warning is printed to stderr when the fallback is used
366
407
- REST API passes `--registries` as comma-separated registry names to the `registries` query param; GraphQL fallback passes registry IDs to the `registries` variable
367
-
-`fetchRegistries` in `registries.go` is used by `listRegistries`, `packageSearchCmd`, and `packageInfoCmd` to resolve registry names to IDs (for GraphQL) and names (for REST)
408
+
-`fetchRegistries` in `registries.go` is used by `listRegistries`, `packageSearchCmd`, `packageInfoCmd`, and `packageDependencyCmd` to resolve registry names to IDs (for GraphQL) and names (for REST)
368
409
- Both REST and GraphQL package search/info paths produce identical output columns (Registry and Owner); GraphQL resolves registry names from the `registryIDs`/`registryNames` already in `PackageSearchParams` — no extra API call needed
369
410
- A package in multiple registries appears as multiple rows (one per registry) in both REST and GraphQL paths, since the GraphQL view (`package_rank_vw`) is already flattened per package-registry combination
370
-
- GraphQL fallback uses `package_search_with_count.gql`which fetches both the package list and aggregate count in a single request (`package_search` + `package_search_aggregate` root fields)
411
+
- GraphQL fallback uses `package_search.gql`(`FilteredPackages`) for the package list and `package_search_count.gql` (`FilteredPackagesCount`) for the aggregate count as separate requests
371
412
-`executeGraphQL(server, token, req)` in `packages.go` is a shared helper for GraphQL POST requests (sets Authorization, Content-Type, Accept, X-Hasura-Role headers)
372
413
-`getPackageInfo` in `packages.go` implements exact name-match lookup using REST-first (`getPackageInfoREST`), GraphQL fallback (`getPackageInfoGraphQL`); `packageInfoCmd` in `main.go` resolves registries via `fetchRegistries`
414
+
-`getPackageDependencies` uses GraphQL (`fetchGraphQLPackages`) to locate the package, then fetches `/docs/{registry}/{package}/stable/pkg.json` for dependency data; no REST fallback (docs endpoint is authoritative)
jh package dependency DataFrames # Shows up to 10 direct dependencies
285
+
jh package dependency DataFrames --indirect # Includes indirect dependencies
286
+
jh package dependency CSV --registry General # Use specific registry
277
287
```
278
288
279
289
### Registry Operations
@@ -419,7 +429,7 @@ Note: Arguments after `--` are passed directly to Julia. The `jh run` command:
419
429
420
430
-**Built with Go** using the Cobra CLI framework
421
431
-**Authentication**: OAuth2 device flow with JWT token management
422
-
-**APIs**: REST API for datasets and package search/info (primary); GraphQL API for projects, user info, and package search/info fallback (single request returns results + total count)
432
+
-**APIs**: REST API for datasets and package search/info (primary); GraphQL API for projects, user info, package search/info fallback, and package dependency lookup
423
433
-**Git Integration**: Seamless authentication via HTTP headers or credential helper
424
434
-**Cross-platform**: Supports Windows, macOS, and Linux
0 commit comments