Nikasa, home Request an invite
DocsCommands

Commands

The nk commands and the flags you will use. Run nk with no arguments to print every option for the version you have.

On this page

All commands #

Command What it does
nk demo [out-dir] Compares Nikasa's sample app and prints the report
nk setup [--check] [--rebuild] Builds the TLS key tools and pulls the capture images. It keeps those this version already made, so a second run makes nothing. --check lists what is there, and --rebuild makes every one again.
nk init [repo-dir] Drafts nk/app.yaml from your repository
nk init [repo-dir] --ci Writes nk/ci/github.yml, a CI job for GitHub Actions
nk try <image> Starts the draft once and says what the start shows
nk run <image> <out-dir> One run, kept as a folder; exits 1 when a request file failed
nk compare <old> <new> [out-dir] The whole compare: old runs, new runs, report
nk record <old> <pack-dir> <out-dir> Records what a command sends the old build as a pack
nk import pcap|har|gor <input> <packs-dir> Turns a capture into packs
nk import reviewed <pack-dir>... Marks packs whose review.md you have read, so a compare may use them
nk clear --slot <n> Removes what stopped runs left on a sandbox network that no run holds
nk diff <new.json>[,...] <old.json>... Compares saved observations without running anything
nk observe <run-dir>... Reads saved runs again, for example after upgrading Nikasa or adding a mask rule
nk accept <out-dir> Adds the changes a report listed to nk/accepted.yaml
nk mask Records a place, field, pattern or value in nk/masks.yaml
nk report list|show|check <out-dir> Reads a report and writes nothing
nk --version Prints the version

Some flags and commands below take a pack. A pack is a folder that holds a recorded session, made by nk record or nk import. The answers of any outside services are recorded in it. Nikasa sends the pack again to both builds, in place of request files.

nk compare #

text
nk compare <old-image> <new-image> [out-dir, default out/nk] [flags]

This is the whole compare: old runs, new runs and the report.

How many runs #

Nikasa starts each build several times. What differs between runs of the same build, such as ids and timestamps, is noise and is not counted.

  • A compare starts 3 old runs and 2 new runs.
  • A compare that finds nothing stops after the first 5 runs.
  • When every new run shows a difference, it makes more runs to confirm it, up to 8 old runs and 4 new runs. The difference counts as a change only if all 8 old runs agree on that point and all 4 new runs show it.
  • A difference that only some new runs show is listed as unstable and is not counted.

Set the number of old runs with --old-runs <n>, or with a number after the output folder. --fail-on-change fails the job when a counted change showed in every new run.

The What it does section of Your first compare walks through the steps.

What to run #

Flag What it does
--app <file> The app file; default nk/app.yaml
--specs <folder> A folder of .hurl files; default nk/specs
--pack <pack> A recorded pack instead of --specs: a folder, a link or an s3:// path; default nk/packs/main
--with <file> A project's own compose files, loaded first
--old-with <file>, --new-with <file> A compose file laid over one side only
--image <service>=<old>,<new> That service runs its own images, old then new
--host <url> The address requests go to; default the app file's x-nk: host, else http://app:8000
--env-file <path> The env file Compose fills the app file's variables from, in place of the files x-nk: env_file records. Give it again for more, later ones winning. nk try, nk run, nk record and nk init take it too. Env file paths says where each path starts.

How it runs #

Flag What it does
--old-runs <n> Old runs to start with; default 3
--new-runs <n> New runs to start with; default 2
--pause-ms <n> A wait after every request; default 0
--jobs <n> Runs at once, each on a sandbox network of its own; default 1
--slot <n> The sandbox network to use; default a free one of 16. Jobs that share a Docker do not need it
--replay Makes no run: reads the runs an earlier compare left in the output folder and reports again

The starting state #

Flag What it does
--seed-dump <dump> Start every database from a dump
--seed "<command>" Start every database from what a command makes
--start-migrated Start every run from the old build's migrated database

The report #

Flag What it does
--format text|json|markdown What is printed; every file is written either way
--all List each change seen while the app starts, or in the background (work that no request caused), instead of one line for each service and place. They count either way
--fail-on-change Exit 1 when the report lists a change in every new run. The Exit status section below lists the three exits
--ignore <place> Leave out changes there; * is any run of characters, ? one
--accepted <file>, --no-accepted Read this accepted file instead of nk/accepted.yaml, or none
--masks <file> Read these mask rules instead of nk/masks.yaml
--tracker <url>, --tracker-kind <kind> Where the link beside each change opens a new issue
--openapi <file or /path> The API description coverage is measured against
--proto <file or folder> Read gRPC messages by their schema

Outside the sandbox and TLS #

Flag What it does
--offline Nothing outside the sandbox can be reached or resolved; nk try takes it too
--live-outside Every run reaches outside hosts live and nothing is recorded
--https-issuer For an app that refuses an http login provider, as ASP.NET does by default. The stand-in provider that signs the tokens a pack sends again is given an https address. See Logins through an outside provider.
--no-ebpf No eBPF probes, which read TLS keys of Go and .NET 8 programs

Saved baselines #

Flag What it does
--baseline <dir> Save the old build's runs there, and read them next time
--baseline-expiry <days> The check age: how old a baseline may get before a fresh old run checks it, such as 7 or 7d; default 7 days
--no-drift-guard Do not check changes about to be counted with one fresh old run
--print-baseline-key Print the baseline key for these arguments and make no run

nk init #

Flag What it does
--from <file> Draft from this compose file; give it again to merge several, in order
--service <name> This service is the app. --service app builds the root Dockerfile beside the file's services, when none is called app and the repository's own name names no image in the file
--port <n> The port the app listens on
--image <ref> Draft the app alone from this image
--app-dockerfile <path> Draft the app from this Dockerfile, beside the services of --from
--docker-socket Keep mounts of the Docker socket
--yes Take the first choice of each question. It fills no setting and still lists what is missing
--verbose Print everything, not just the first lines
--ci Write the CI job and draft no app file; goes with none of the flags above
--env-file <path> Record this env file as x-nk: env_file, in place of the .env beside the compose file. It is written as a path from nk/, such as ../docker/.env. Give it again for more, later ones winning. The Env file paths section below says where the path you give starts

nk record #

text
nk record <old-image> <pack-dir> <out-dir> --app <file> [-- <command> [args]...]
Flag What it does
--driver playwright|cypress|bruno|newman Run this folder's suite or collection as it is; the app file's x-nk: tests can name it, and words after -- replace its args
--driver-version <version> Pick another version than the one your lockfile names
--driver-image <image> Run your command in a container of this image, with this folder at /work
--on-host Run your command on this machine, or wait for Enter with no command
--relay, --no-relay Turn the forwarder from localhost:<the app's port> to the app on or off
--seed-dump, --seed Start from a seed, kept in the pack's state.json
--env-file <path> The env file the app file's variables are filled from, in place of those x-nk: env_file records; its path is from the folder nk runs in, as the Env file paths section below says

nk import #

Flag What it does
--server <address> Which server is the app; default the one with the most requests
--state <dump> A dump taken when the capture started
--session <n>, --max-sessions <k> Keep fewer sessions
--dry-run Print the listing only
--check <old-image> --app <file> Run each pack twice against the old build and note each step that did not answer as captured
--check-dir <dir>, --keep-check Where those runs go, and keep them after
--keys <keylog> TLS keys for a pcap capture

A pack can have personal-looking fields left to review. Two commands deal with that:

  • nk compare --accept-imported-data lets such a pack run anyway.
  • nk import reviewed <pack-dir>... is the lasting form. Once you have read a pack's review.md, it marks the pack as reviewed.

nk accept and nk mask #

Flag What it does
--only <place> nk accept: take the places matching a glob
--any-value nk accept: record each place whatever its value; needs --only
--change <key> nk mask: mask the place of this change
--field nk mask: with --change, mask that field's name anywhere
--pattern <regex> nk mask: mask every match
--value nk mask: mask the value on standard input
--label <word> nk mask: the word in the marker, instead of masked
--plain nk mask: write a plain marker with no hash
--note "why" Both: a note kept with the entry
--file <path> Both: write this file instead

nk report #

text
nk report list <out-dir | report.json> [--page <n>] [--per-page <n>] [--area <name>] [--kind <KIND>]
               [--stability consistent|unstable] [--scenario <id>] [--place <place>]
               [--format text|json] [--unchecked]
nk report show <out-dir | report.json> <key> [--values] [--format text|json] [--unchecked]
nk report check <out-dir | report.json> [--values]

Env file paths #

Three places take an env file's path, and each starts from a different folder:

Where the path is written It starts from
x-nk: env_file in the app file The folder that holds the app file, so ../.env in nk/app.yaml is the .env at the repository's root
--env-file on nk try, nk run, nk record and nk compare The folder you run nk in
--env-file on nk init The repository nk init reads: the folder you run it in, or the [repo-dir] you give. nk init writes it into the app file as a path from nk/

Environment variables #

Name What it is
NK_SECRET_KEY_FILE The file holding the secret key; default $HOME/.config/nk/secret.key
NK_TOOLS The folder nk setup builds its tools into

Exit status #

nk compare exits with one of three numbers, and so does nk diff:

Exit Meaning
0 Nikasa compared. Changes may be listed in the report
1 Nikasa compared, --fail-on-change was given, and a change showed in every new run
2 Nikasa could not compare: a setup, start or file problem, and the log says which

nk demo exits 0 or 2. A few other commands keep an exit 1 of their own:

  • nk run when a request file failed.
  • nk setup --check when a tool is missing.
  • nk import ... --check when a pack did not answer as captured.
  • nk report when its check finds a suspect.

Written for nk 0.3.14. Something wrong or unclear? Write to hello@nikasa.dev.