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

pathprobe

v1.11.16

Published

Extract, resolve, and validate file and directory paths mentioned in text, with variable expansion, ignore rules, hidden-file control, and configurable search roots.

Readme

Language Option / 语言选项:

English | 简体中文


pathprobe

pathprobe finds references to existing files and directories inside natural-language text.

It can recognize absolute and relative paths, quoted paths, variable-based paths, and less explicit path references, then verify that the referenced filesystem entries actually exist.

Usage

import { findExistingPaths, MAX_LEVEL } from "pathprobe";

const matches = await findExistingPaths({
  text: "Please check src/index.ts and ./config/settings.json",
  directories: [process.cwd()],
  level: 2,
});

console.log(matches);

Example result:

[
  {
    kind: "file",
    path: "/project/src/index.ts",
    position: { start: 13, end: 25 },
  },
];

API

findExistingPaths(options): Promise<PathMatch[]>

Main options:

{
  text: string;
  directories: readonly string[];
  level: number;
  variables?: Record<string, string>;
  respectIgnore?: boolean;
  searchHidden?: boolean;
}

text is the text to inspect.

directories contains the search roots used to resolve relative paths. At least one directory is required.

level controls how aggressively paths are detected and must be between 1 and MAX_LEVEL. Higher levels can recognize less explicit references but may require more filesystem searching.

variables supplies values for references such as $HOME/project, ${WORKSPACE}/src, or %TEMP%\file.txt.

respectIgnore controls whether ignore rules such as .gitignore are respected.

searchHidden controls whether hidden files and directories are searchable.

Optional defaults are determined by the package configuration.

Search levels

Lower levels are useful when the input already contains clearly formatted paths.

level: 1;

Handles obvious references such as /tmp/file.txt, C:\work\file.ts, ./src/index.ts, and "docs/My File.md".

level: 2;

Also detects additional path-like tokens and variable-based paths.

level >= 3 progressively considers longer text spans, which is useful for paths containing spaces.

MAX_LEVEL performs the broadest search and can recognize names using the actual contents of the configured search directories.

When in doubt, start with level 1 or 2 and increase it only when broader matching is needed.

Line and column locations

A path may include a source location:

src/index.ts:20
src/index.ts:20:8
src/index.ts#L20

The result can then contain:

location: { line: 20, column: 8 }

Variables

await findExistingPaths({
  text: "$ROOT/src/index.ts",
  directories: [process.cwd()],
  level: 2,
  variables: {
    ROOT: "/project",
  },
});

Variables not supplied explicitly may also be resolved from the current process environment.

Result

Each PathMatch has the following shape:

{
  kind: "file" | "directory";
  path: string;
  position: { start: number; end: number };
  location?: { line: number; column?: number };
}

position refers to the matching range in the original input text.

Only paths that exist and satisfy the active hidden-file and ignore policies are returned.

Platforms

Common POSIX and Windows path formats are supported.

On Windows, drive paths, resolvable UNC paths, and Windows hidden attributes are also supported.