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

humanfile

v0.1.2

Published

Parse .human files and classify file protection levels for AI coding agents

Downloads

134

Readme

humanfile (core)

Core library for parsing .human files and classifying file protection levels.

Install

npm install humanfile

API

import {
  classify,
  classifyAll,
  collectProtectedViolations,
  discoverRuleSets,
  evaluateAiHeuristic,
  evaluateProtectedChangeSet,
  explain,
  parse,
  ruleSetsForPath,
} from 'humanfile'

parse(content, directory?)

function parse(content: string, directory?: string): HumanRuleSet

Parses .human content into one scoped rule set.

Parameters:

  • content: raw .human file text.
  • directory: directory containing the .human file, relative to repo root ("" for root).

Returns:

  • HumanRuleSet with ordered rules (last matching rule wins inside a rule set).

classify(filePath, ruleSets)

function classify(filePath: string, ruleSets: HumanRuleSet[]): ProtectionLevel

Classifies one repo-relative path.

Parameters:

  • filePath: repo-relative path using / separators.
  • ruleSets: rule sets ordered from root to deeper directories.

Returns:

  • ProtectionLevel ('free' | 'confirm' | 'readonly').

explain(filePath, ruleSets)

function explain(filePath: string, ruleSets: HumanRuleSet[]): ExplainResult

Explains why a path resolved to its final level.

Returns:

  • ExplainResult with:
    • level: final protection level.
    • matched: whether any rule matched.
    • decisiveRule: winning rule metadata or null.
    • trace: ordered per-rule evaluation trace.

classifyAll(repoRoot)

function classifyAll(repoRoot: string): Promise<Map<string, ProtectionLevel>>

Discovers .human files and classifies all files under repoRoot.

Returns:

  • Map<path, level> where keys are repo-relative paths.

discoverRuleSets(repoRoot)

function discoverRuleSets(repoRoot: string): Promise<HumanRuleSet[]>

Discovers and parses all .human files under repoRoot.

Returns:

  • HumanRuleSet[] sorted from shallow to deep directory scope.

ruleSetsForPath(filePath, ruleSets)

function ruleSetsForPath(filePath: string, ruleSets: HumanRuleSet[]): HumanRuleSet[]

Filters rule sets to only those whose directory scope applies to the given path. Root-scoped rule sets (directory "") apply to all paths.

collectProtectedViolations(changedFiles, ruleSets)

function collectProtectedViolations(
  changedFiles: ChangedFileStat[],
  ruleSets: HumanRuleSet[],
): ProtectedViolation[]

Classifies each changed file and returns only non-free entries with their resolved level.

evaluateAiHeuristic(changedFiles, threshold, commitMessages?)

function evaluateAiHeuristic(
  changedFiles: ChangedFileStat[],
  threshold: number,
  commitMessages?: string[],
): AiHeuristicResult

Estimates whether a change set is likely AI-generated based on total line count and commit message signals.

evaluateProtectedChangeSet(options)

function evaluateProtectedChangeSet(options: {
  changedFiles: ChangedFileStat[]
  ruleSets: HumanRuleSet[]
  aiThreshold: number
  commitMessages?: string[]
}): ProtectedPolicyEvaluation

Combines violation collection and AI heuristic evaluation in one call.

Exported Types

type ProtectionLevel = 'free' | 'confirm' | 'readonly'

interface HumanRule {
  pattern: string
  level: 'confirm' | 'readonly'
}

interface HumanRuleSet {
  directory: string
  rules: HumanRule[]
}

interface ExplainDecisiveRule {
  sourceFile: string
  sourceDirectory: string
  pattern: string
  level: 'confirm' | 'readonly'
}

interface ExplainTraceEntry {
  sourceFile: string
  sourceDirectory: string
  relativePath: string
  pattern: string
  ruleLevel: 'confirm' | 'readonly'
  matched: boolean
  effectiveLevelAfterRule: ProtectionLevel
}

interface ExplainResult {
  path: string
  level: ProtectionLevel
  matched: boolean
  decisiveRule: ExplainDecisiveRule | null
  trace: ExplainTraceEntry[]
}

interface ChangedFileStat {
  filename: string
  additions: number
  deletions: number
}

interface ProtectedViolation extends ChangedFileStat {
  level: 'confirm' | 'readonly'
}

interface AiHeuristicResult {
  likelyAiGenerated: boolean
  totalLinesChanged: number
}

interface ProtectedPolicyEvaluation {
  violations: ProtectedViolation[]
  likelyAiGenerated: boolean
  totalLinesChanged: number
}

For normative behavior specs, see ../../docs/specs/human-file-format.md and ../../docs/specs/cli-spec.md.

CLI

The humanfile binary ships with the package. Common commands:

humanfile check <path>
humanfile explain <path>
humanfile init
humanfile install
humanfile ls

For every subcommand, flag, and JSON output shape, see ../../docs/specs/cli-spec.md.

Developing this package (build/test scripts, editor QA harnesses, running the CLI from the monorepo, guard hooks): see DEVELOPMENT.md.