npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@vforsh/seafile-cli

v0.1.0

Published

Automation-friendly CLI for discovering and downloading from multiple Seafile instances

Readme

seafile-cli

Automation-friendly CLI for discovering and downloading from multiple Seafile instances.

Scope

Version 1 supports:

  • Named Seafile instances with account tokens
  • Listing accessible libraries
  • Listing directories immediately or recursively
  • Finding files and directories by basename glob with depth and time bounds
  • Inspecting normalized file and directory metadata
  • Listing and downloading historical file revisions
  • Downloading files and directories in batches
  • Downloading directory ZIPs or extracting them locally
  • Human, stable plain-text, and JSON output
  • Read-only readiness diagnostics

It does not support indexed content search, encrypted-library access, uploads, or downloading an entire library root.

Install

Requires macOS and Bun 1.2 or newer.

bun add -g @vforsh/seafile-cli
seafile --version

From a source checkout:

bun install
bun link
seafile --help

Configure instances

Add an instance. The command reads the account token from a hidden prompt:

seafile instance add rshub https://cloud.rshub.io
seafile instance add stark https://art.stark.games

For non-interactive setup, pipe the token through stdin:

printf '%s' "$TOKEN" | seafile instance add rshub https://cloud.rshub.io

Tokens are stored in the XDG config file with mode 0600. They are never accepted as command-line arguments.

seafile instance list
seafile instance use rshub
seafile cfg path

The first added instance becomes the default. Override it per invocation:

seafile --instance stark list

For ephemeral automation, skip config entirely:

SEAFILE_URL=https://cloud.rshub.io \
SEAFILE_TOKEN="$TOKEN" \
seafile --json list

Remote paths

Remote targets use library:/absolute/path:

Assets:/
Assets:/Characters
Assets:/Characters/hero.png

A unique library name is convenient for humans. A library UUID is canonical and should be used in durable automation:

seafile list 'c0edc6fa-409f-492b-aa18-84cfcd297be8:/content'

You can also pass Seafile library browser links (/library/…), file view links (/lib/…/file/…), or smart links (/smart-link/…) directly to list, find, stat, and download. Quote the URL. The CLI uses the matching configured instance or a matching SEAFILE_URL and SEAFILE_TOKEN pair. With --instance, URLs use the named account's stored URL and token. Smart links need a server that supports resolving them with an account token.

List

List every accessible library:

seafile list
seafile ls
seafile --json list
seafile --plain list

List a directory's immediate children:

seafile list 'Assets:/Characters'
seafile --json list 'Assets:/Characters'

List all descendants, optionally filtering by entry type and limiting output:

seafile list 'Assets:/Characters' --recursive
seafile list 'Assets:/' --recursive --type file --limit 100

--plain list emits one canonical library-id:/path per entry. At the library level it emits one library UUID per line.

--require-match exits with an error when a directory listing is empty. Recursive results are sorted by canonical remote path before --limit is applied.

JSON directory entries use a stable normalized shape: id, name, type, parentPath, remotePath, permission, mtime, size, modifier, lock, and starred. Unrecognized server fields are not forwarded.

Use --sort mtime with list <target> or find to sort by newest first before applying --limit. Missing times sort last. Use --sort path to sort files and directories together by path. With --json, --fields selects which fields appear in each entry and keeps the surrounding JSON metadata.

seafile --json list 'Assets:/Characters' --sort mtime --limit 5 --fields remotePath,mtime,size

Find

Find descendants by a case-sensitive basename glob:

seafile find 'Assets:/' --name '*.png'
seafile find 'Assets:/Characters' --name 'hero*' --type file
seafile --json find 'Assets:/' --name '*.json' --limit 100

Quote globs so the local shell does not expand them. Matching is performed against each entry's basename, not its full path. --limit bounds emitted results after deterministic sorting; Seafile still enumerates the requested remote tree.

Use --require-match when an empty result should fail automation:

seafile find 'Assets:/' --name 'manifest.json' --require-match

Plain output contains one canonical library-id:/path per match.

Start in the closest known folder. For large trees, use --first to stop after the first breadth-first match, --max-depth 1 for direct children (increase it for deeper levels), or --deadline <seconds> for a total search budget including target resolution, requests, and retries.

seafile --json find 'Assets:/Characters' --name 'hero*' --first --max-depth 2 --deadline 5

With these bounds, JSON adds complete and stopReason. If stopped early, complete is false and total counts matches found so far. A first match is a success. A deadline exits 1 and still prints partial results when the target has been resolved. An exhaustive search within --max-depth is complete. --first uses breadth-first order and cannot be combined with --sort mtime.

Stat

Inspect a file, directory, or library root:

seafile stat 'Assets:/Characters/hero.png'
seafile --json stat 'Assets:/Characters'
seafile --plain stat 'Assets:/'

JSON output normalizes the target's type, size, modification time, object ID, current library revision ID, permission, modifier, and lock state. Fields unavailable on a server are returned as null, rather than guessed.

History

List a file's historical revisions:

seafile history 'Assets:/Characters/hero.png'
seafile --json history 'Assets:/Characters/hero.png' --limit 100
seafile --plain history 'Assets:/Characters/hero.png' --all

The default limit is 25 revisions. --all explicitly fetches the complete history available under the library's retention policy and cannot be combined with --limit. Plain output contains one full commit ID per line.

JSON revisions include the commit ID, file object ID, canonical historical remote path, previous path for rename events, timestamp, size, description, and author. Use the revision's own remotePath when downloading history from before a rename:

seafile download \
  'c0edc6fa-409f-492b-aa18-84cfcd297be8:/Old/hero.png' \
  --revision 0123456789abcdef0123456789abcdef01234567 \
  -o ./hero-old.png

Download

Download a file to its remote basename in the current directory:

seafile download 'Assets:/Characters/hero.png'

Choose an exact local output path:

seafile download 'Assets:/Characters/hero.png' -o ./hero.png

Download an exact historical file revision:

seafile download 'Assets:/Characters/hero.png' \
  --revision 0123456789abcdef0123456789abcdef01234567

Directories are prepared by Seafile and downloaded as ZIP archives:

seafile download 'Assets:/Characters'
# writes ./Characters.zip

Save several targets under their original names with --into. The directory is created if needed. With --extract, directory targets are unpacked into a subdirectory named after the remote directory. Extracted directories must have a fresh destination.

seafile --json download 'Assets:/hero.json' 'Assets:/hero.atlas' 'Assets:/hero.png' --into ./assets
seafile download 'Assets:/Characters' --into ./assets --extract

Batch JSON returns { results, failed } with one success or error per input in input order. Independent targets continue on failure and the command exits 1 if any target failed. Targets that would write the same name report a conflict before transferring bytes, using the destination filesystem's filename rules. --output selects an exact path for a single target.

Existing files are left untouched unless --force is passed. Downloads stream to a temporary sibling file and are published after transfer completes.

seafile download 'Assets:/Characters/hero.png' -o ./hero.png --force

Stream downloaded bytes to stdout:

seafile download 'Assets:/manifest.json' -o - | jq .

Binary stdout cannot be combined with --json or --plain.

Output contract

  • Default: concise human-readable text or tables
  • --plain: stable line-oriented IDs or paths
  • --json: one JSON object on stdout
  • Primary data: stdout
  • Progress, diagnostics, and human errors: stderr
  • JSON-mode errors: { "error": { "code", "message", "exitCode" } } on stdout
  • --quiet: suppress progress and diagnostics
  • --verbose: show sanitized request diagnostics

Exit codes:

  • 0: success
  • 1: runtime, config, authentication, network, or remote-operation failure
  • 2: invalid command usage
  • 130: interrupted secure input

Config

Default path:

${XDG_CONFIG_HOME:-~/.config}/seafile/config.json

SEAFILE_CONFIG overrides the full path.

seafile cfg list
seafile cfg get defaultInstance timeoutMs retries
seafile cfg set timeoutMs=45000 retries=3
seafile cfg unset defaultInstance

Secret keys must come from stdin:

printf '%s' "$TOKEN" | seafile cfg set instances.rshub.token -

Config can be round-tripped for agent setup:

seafile cfg export --json > seafile-config.json
seafile cfg import --json < seafile-config.json

cfg export --json includes account tokens. Treat its output as a secret.

Precedence, highest first:

  1. CLI flags
  2. SEAFILE_* environment variables
  3. XDG config

Supported environment variables:

  • SEAFILE_INSTANCE
  • SEAFILE_URL
  • SEAFILE_TOKEN
  • SEAFILE_CONFIG
  • SEAFILE_TIMEOUT_MS
  • SEAFILE_RETRIES
  • XDG_CONFIG_HOME
  • NO_COLOR

Diagnostics

doctor is read-only. It checks Bun, config parsing and access, selected credentials, authentication, reachability, and server version.

seafile doctor
seafile check --json

Agent skill

Print the installable skill URL:

seafile skill

Install it with:

npx skills add "$(seafile skill)"

Development

bun install
bun run typecheck
bun test
bun link

License

MIT