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

tryscript

v0.1.4

Published

Golden testing for CLI applications - TypeScript port of trycmd

Downloads

734

Readme

tryscript

CI Coverage npm version X Follow

Golden testing for CLI applications - a TypeScript port of trycmd.

[!NOTE] 100% of the code and specs in this repository were written by Claude Code. The design and management and prompting was by me (jlevy) supported by the workflows, agent rules, and other research docs in Speculate.

You can see what you think, but I find the code quality higher than most agent-written code I've seen because of the spec-driven process. You can review the architecture doc and all of the specs all of the specs in docs/project. The general research, guideline, and rules docs I use are in docs/general.

What It Does

Write CLI tests as Markdown. tryscript runs commands, captures output, and compares against expected results. Tests become documentation; documentation becomes tests.

---
env:
  NO_COLOR: "1"
sandbox: true
---

# Test: CLI help

```console
$ my-cli --help
Usage: my-cli [options] <command>

Options:
  --version  Show version
  --help     Show this help
...
? 0
```

# Test: Version output

```console
$ my-cli --version
my-cli v[..]
? 0
```

# Test: Error handling

```console
$ my-cli unknown-command 2>&1
Error: unknown command 'unknown-command'
? 1
```

# Test: Check output file contents

```console
$ my-cli process data.json > output.txt && grep "success" output.txt
[..]success[..]
? 0
```

The [..] matches any text on that line. The ... matches zero or more lines. These "elision patterns" let tests handle dynamic output gracefully. Any shell command works - pipes, redirects, environment variables, etc.

Quick Start

# Install
pnpm add -D tryscript

# For coverage support (optional)
pnpm add -D c8

# For accurate line counts when merging with vitest (optional)
pnpm add -D c8 monocart-coverage-reports

# Run tests
npx tryscript run tests/

# Update expected output when behavior changes
npx tryscript run --update tests/

Features

  • Markdown format - Tests are readable documentation
  • Elision patterns - Handle variable output: [..], ..., [CWD], [ROOT], [EXE]
  • Custom patterns - Define regex patterns for timestamps, versions, UUIDs
  • Update mode - Regenerate expected output with --update
  • Sandbox mode - Isolate tests in temp directories
  • Code coverage - Track coverage from subprocess execution with --coverage (experimental; use --coverage-monocart for best accuracy)

CLI Reference

tryscript run [files...]          # Run golden tests
tryscript coverage <commands...>  # Run commands with merged coverage
tryscript docs                    # Show syntax quick reference
tryscript readme                  # Show this documentation
tryscript --help                  # Show all options

For complete syntax reference, run tryscript docs or see the reference documentation.

Common Options

| Option | Description | | --- | --- | | --update | Update test files with actual output | | --fail-fast | Stop on first failure | | --filter <regex> | Filter tests by name | | --verbose | Show detailed output | | --coverage | Collect code coverage (requires c8) | | --coverage-monocart | Use monocart for accurate line counts (requires monocart-coverage-reports) | | --coverage-exclude-node-modules | Exclude node_modules from coverage (default: true) | | --coverage-exclude <pattern> | Exclude patterns from coverage |

Note: Coverage features are experimental. See the reference documentation for details on merged coverage, monocart integration, and sourcemap requirements.

Development

# Clone and install
git clone https://github.com/jlevy/tryscript.git
cd tryscript
pnpm install

# Build and test
pnpm build
pnpm test

License

MIT