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

@nocoo/surety

v2.0.0

Published

Surety CLI — AI-facing command line interface for managing household insurance policies

Downloads

98

Readme

@nocoo/surety

Surety CLI — AI-facing command line interface for managing household insurance policies.

Designed for AI agents (Claude Code, Cursor, etc.) to read and mutate Surety data through a stable, JSON-only contract. All output is machine-parsable; errors go to stderr as { ok: false, error }.

Requirements

  • Bun 1.2+ (the CLI ships as src/index.ts and runs under Bun directly)

Install

bun add -g @nocoo/surety
# or one-shot
bunx @nocoo/surety --help

Quick start

# 1. Log in via browser (CF Access -> /api/auth/cli -> loopback token)
surety login

# 2. Confirm identity
surety whoami

# 3. List household members
surety members ls

Configuration

Config file: ~/.config/surety/config.json

| Key | Description | |-----|-------------| | apiUrl | Data-plane origin (Bearer token). Default https://surety-api.hexly.ai | | loginUrl | CF-Access-protected origin that mints CLI tokens. Default https://surety.hexly.ai | | token | Bearer token (set by surety login) | | email | Authenticated email (set by surety login) |

Environment overrides (highest priority):

| Env | Overrides | |-----|-----------| | SURETY_API_URL | apiUrl | | SURETY_LOGIN_URL | loginUrl | | SURETY_API_TOKEN | token | | SURETY_CLI_DEV | =1 writes to ./.surety-dev/config.json instead of ~/.config/surety |

Output contract

  • Every command emits one JSON value on stdout (object or array, depending on command).
  • Summary mode (default): compact projection of each record.
  • Full mode (--full): the complete upstream payload.
  • On error: exit code 1, stderr one-line { ok: false, error, detail? }.
surety members ls
# [{"id":1,"name":"张伟","relation":"self"}, ...]

surety members get 1 --full
# {"id":1,"name":"张伟","relation":"self","birthDate":"...", ...}

surety members rm 999
# stderr: {"ok":false,"error":"api error: 404 DELETE /api/members/999","detail":{"error":"not found"}}
# exit 1

JSON input for add / update

Mutating commands take the payload via one of (in priority order):

  1. --data '<inline json>'
  2. --data-file <path> (use - to read from stdin)
  3. piped stdin (when not a TTY)

Positional JSON arguments are not accepted.

Commands

Auth

| Command | Description | |---------|-------------| | surety login [--login-url] [--api-url] [--timeout] | Browser-based login via CF Access, saves token | | surety logout | Forget saved token and email | | surety whoami | Print authenticated identity |

Flat entities (CRUD)

All follow the same shape:

  • ls — list all
  • get <id> — fetch one
  • add --data '<json>' — create (also --data-file <path> / stdin)
  • update <id> --data '<json>' — replace
  • rm <id> — delete

| Command | Path | |---------|------| | surety members … | /api/members | | surety insurers … | /api/insurers | | surety assets … | /api/assets | | surety hospitals … | /api/hospitals | | surety doctors … | /api/doctors | | surety medical-visits … | /api/medical-visits |

Policies (with nested sub-resources)

surety policies ls
surety policies get <id> [--full]
surety policies add --data '<json>'
surety policies update <id> --data '<json>'
surety policies rm <id>

# Payments
surety policies payments ls <policyId>
surety policies payments add <policyId> --data '<json>'
surety policies payments update <policyId> <paymentId> --data '<json>'
surety policies payments rm <policyId> <paymentId>
surety policies payments generate <policyId>

# Beneficiaries (read-only in current Worker)
surety policies beneficiaries ls <policyId>

# Coverage items (full CRUD)
surety policies coverage-items ls <policyId>
surety policies coverage-items add <policyId> --data '<json>'
surety policies coverage-items update <policyId> <itemId> --data '<json>'
surety policies coverage-items rm <policyId> <itemId>

# Attachments (metadata only; upload not yet exposed in Worker)
surety policies attachments ls <policyId>
surety policies attachments get <policyId> <attachmentId>
surety policies attachments rm <policyId> <attachmentId>

Read-only

| Command | Description | |---------|-------------| | surety coverage --type <member\|asset> --id <id> | Query /api/coverage-lookup | | surety renewals | Upcoming renewals calendar | | surety dashboard | Dashboard summary payload |

Known backend gaps

These endpoints are not yet implemented in the Worker; the CLI will expose them once shipped:

  • PUT/DELETE /api/policies/:id/beneficiaries — beneficiaries are currently read-only
  • POST /api/policies/:id/attachments — attachment upload
  • GET /api/policies/:id does not nest sub-resources; use the sub-resource ls commands

AI usage examples

# Find the active health policy for 张伟
surety members ls                                                   # discover member id
surety coverage --type member --id 1                                # list policies
surety policies get 3 --full                                        # inspect one

# Record a new out-of-pocket payment
surety policies payments add 3 --data '{"amount":1200,"paidAt":"2026-04-01","note":"annual premium"}'

# Regenerate upcoming payment schedule after policy change
surety policies payments generate 3

Development

# From repo root
cd apps/cli
bun install
bun test
bun run typecheck

The CLI has no build step — bin in package.json points directly at src/index.ts.

License

MIT