git clone https://github.com/forgesworn/nsec-tree-cli.git
cd nsec-tree-cli
npm install
npm test # 92 tests, should all pass
node ./bin/nsec-tree.js root createRequires Node.js 22 or later. ESM-only.
nsec-tree-cli is the application layer — it owns CLI grammar, formatting, profiles, and I/O. It does not own cryptography.
bin/nsec-tree.js entrypoint — delegates to runCli()
src/cli.js command dispatch and logic (one handle* per command group)
src/format.js ANSI colour, box-drawing, tree rendering
src/explain.js five built-in mini-tutorials
src/deps.js runtime dependency loading
src/profile-store.js profile CRUD (~/.nsec-tree/profiles/)
All crypto operations go through npm packages loaded by deps.js:
nsec-tree— derivation, proofs, verification@forgesworn/shamir-words— Shamir split/recover@scure/bip39— mnemonic generation
If logic is generally useful to applications, it belongs in a library. If it's about terminal UX, it belongs here.
npm test # all tests
node --test test/cli.test.js # single fileTests use node:test (built-in, no framework). The pattern: construct a MemoryIo instance, pass it to runCli(argv, io, options), assert on stdout/stderr buffers. No mocking. See test/helpers.js for the shared MemoryIo class.
- British English in all user-facing text (colour, licence, initialise)
- Two root types — always preserve the distinction between
mnemonic-backed(recoverable) andnsec-backed(tree-capable, no phrase recovery) --jsonoutput is stable and machine-readable — never add ANSI codes or formatting--quietemits bare values only--no-hintssuppresses "Try next" suggestions- HATEOAS pattern — every human-mode command shows contextual next-step suggestions
- npx detection — suggestions use
npx nsec-treewhen invoked via npx - Secrets written with mode
0o600, directories with0o700 - Path segments: lowercase, shell-friendly, max 32 chars, optional
@indexsuffix
- Create a feature branch from
main - Make your changes — keep commits focused and use
type: descriptionformat - Run
npm test— all tests must pass - Open a pull request against
main
If your change adds a new command or flag, add tests in the appropriate file:
test/cli.test.js— command happy pathstest/errors.test.js— error casestest/profile.test.js— profile lifecycletest/format.test.js— formatting and output modes
- Don't re-implement cryptographic logic that belongs in
nsec-treeor@forgesworn/shamir-words - Don't add network-dependent features — the CLI must stay offline-first
- Don't break
--jsonoutput shapes — scripts depend on them