srk is a command-line tool for Standard Ranklist JSON files. It can validate ranklists, diagnose ranklists, apply patch files, start a browser preview, and render static HTML output.
npm i -g @algoux/standard-ranklist-cliNode.js >=22 is required.
srk --help
srk --version--help: Show command help.-v, --version: Print the current CLI version.
Quickly check whether an SRK JSON file has legal schema fields and field types.
srk validate ranklist.srk.jsonArguments:
<srk.json>: The SRK JSON file to validate.
Notes:
- The command validates JSON syntax, required fields, field types, enum values, tuple lengths, and schema formats.
- Unknown fields inside SRK objects are allowed.
- Validation failures print details and return a non-zero exit code.
- This command does not run semantic diagnostics such as first-blood conflicts or row-order checks.
Inspect an SRK JSON file and print a diagnostics report.
srk diagnose ranklist.srk.json
srk diagnose --format json ranklist.srk.json
srk diagnose --patch generated.patch.json ranklist.srk.jsonArguments and options:
<srk.json>: The SRK JSON file to inspect.-f, --format <format>: Output format. Supported values aretextandjson. Defaults totext.-p, --patch <patch.json>: Write auto-fixable issues as ansrk-patchJSON file.
Notes:
- Diagnostics findings do not make the command fail. Only argument, read/write, or JSON parse errors return a non-zero exit code.
Apply an srk-patch JSON file to an SRK JSON file.
srk patch ranklist.srk.json fix.patch.json > fixed.srk.json
srk patch -o fixed.srk.json ranklist.srk.json fix.patch.json
srk patch --in-place ranklist.srk.json fix.patch.jsonArguments and options:
<srk.json>: The SRK JSON file to patch.<patch.json>: Thesrk-patchJSON file to apply.-o, --output <fixed.json>: Write the patched SRK JSON to a file.--in-place: Overwrite the input SRK JSON file.
Notes:
- Without
-oor--in-place, the patched JSON is written to stdout. --outputand--in-placecannot be used together.
Start a local preview server and view one SRK file or an SRK directory in the browser.
srk preview ranklist.srk.json
srk preview ./ranklists
srk preview -w -p 3003 ./ranklists
srk preview --open --srk-asset-base https://cdn.algoux.cn/srk-storage ./ranklists
srk preview --git-diff-base main --git-diff-head HEAD ./ranklistsArguments and options:
<path>: The SRK JSON file or directory to preview.-w, --watch: Watch files and refresh the current ranklist and directory tree in the page.-h, --host <host>: Set the listen host. When omitted, preview listens on available local and LAN addresses.-p, --port <port>: Set the listen port. Defaults to3003.--open: Open the default browser after the server starts.--srk-asset-base <url>: Base URL for relative asset URLs. Defaults tohttps://cdn.algoux.cn/srk-storage.--git-diff-base <ref>: In directory mode, show only SRK files changed in the<base>...<head>range.--git-diff-head <ref>: Used with--git-diff-base. Defaults toHEAD.
Notes:
- File mode directly renders the selected SRK file.
- Directory mode shows a file tree on the left and only lists directories and
*.srk.jsonfiles. - Directory mode tries to show Git worktree status. If Git is unavailable, preview silently falls back to a plain tree.
- When the port is not explicitly specified and the default port is occupied, preview tries the next available port. If an explicitly specified port is occupied, preview exits with an error.
Render an SRK file or directory as static HTML output.
srk render ranklist.srk.json > ranklist.html
srk render -o ranklist.html ranklist.srk.json
srk render -o ./review-site ./ranklists
srk render -o ./review-site --git-diff-base main --git-diff-head HEAD ./ranklists
srk render -o ./review-site --git-diff-base main --pr-url https://github.com/algoux/example/pull/123 ./ranklists
srk render -o ./review-site --git-diff-base main --git-diff-head HEAD --static-data-root-url https://raw.githubusercontent.com/algoux/example/HEAD/ranklists ./ranklistsArguments and options:
<path>: The SRK JSON file or directory to render.-o, --output <path>: Output path. For file input, this is the HTML file path. For directory input, this is the output directory.--srk-asset-base <url>: Base URL for relative asset URLs. Defaults tohttps://cdn.algoux.cn/srk-storage.--git-diff-base <ref>: In directory mode, render only SRK files changed in the<base>...<head>range.--git-diff-head <ref>: Used with--git-diff-base. Defaults toHEAD.--pr-url <url>: Generate a PR Review page. The sidebar shows a PR link, and the page title includes the PR number.--static-data-root-url <url>: For directory render output, load SRK JSON files from this URL root instead of writing them intodata/. The rendered page appends the preview tree path to this URL. The CLI still validates the local or git-head SRK JSON before writingindex.html.
Notes:
- File input produces a single HTML document. Without
-o, the HTML is written to stdout. - Directory input requires
-o <out-dir>and generates<out-dir>/index.htmlplus<out-dir>/data/. - Normal directory mode copies all
*.srk.jsonfiles intodata/while preserving their relative directory structure. - Git diff directory mode writes changed SRK files from the target
headcommit intodata/<commit>/. Deleted files appear in the tree but cannot be selected. - With
--static-data-root-url, directory output writesindex.htmlwithoutdata/; serve the JSON files from the supplied URL root. --pr-urlmust be used with directory input and--git-diff-base.- Directory render output should be served by a static file server. Opening it directly with
file://may prevent some browsers from loading JSON files.
Rendered pages infer the ranklist id from the file name:
icpc2020ecfinal.srk.json -> icpc2020ecfinal
Asset URL handling:
- URLs starting with
http:,https:, ordata:are preserved. - Other relative URLs become
<assetBase>/<id>/<url>.
pnpm install
pnpm run build
# Run CLI commands from source
pnpm exec tsx src/index.ts ...pnpm run build: Compile TypeScript, build and inline the preview template, and generate publishabledist/output.pnpm run build:template: Build only the Svelte/Vite preview template.pnpm test: Build the template, run type checks, and run tests.pnpm run test:release: Full pre-release verification, including build, tests, and the packed consumer smoke test.pnpm run release:audit: Check publish metadata, Changesets configuration, and npm Trusted Publishing constraints.