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

@tonyclaw/cloc-ai

v0.2.1

Published

跨 Code Agent 安装的业务代码与测试代码 cloc 统计 Skill

Readme

cloc-ai

基于 cloc 的代码统计工具:自动识别语言,将业务代码与测试代码分类,并生成 JSON、CSV、Markdown 汇总表。

报告明确拆分业务代码和测试代码,分别展示文件数、空行、注释行、代码行、语言明细和代码行占比。报告同时公开统计原理、分类规则、硬排除、判断证据、降级条件和 cloc 计数口径。输出包括 cloc-ai.md、cloc-ai.json、cloc-ai-rules.json、cloc-ai.csv、business-code.csv 和 test-code.csv。

.md 和 .markdown 文档始终排除,不计入业务代码或测试代码;报告会显示排除的 Markdown 文档数量。

核心模式不是让路径规则猜测最终分类,而是让 Code Agent 先理解工程、逐文件生成 cloc-ai.classification.v1 语义分类清单,再由 cloc 对业务代码和测试代码分别精确计数:

cloc-ai . --classification .\cloc-ai.classification.json -o cloc-ai-report

语义分类是默认强制要求。只有明确接受较低准确性时才使用 --heuristic,报告会标记 heuristic-fallback:

cloc-ai . --heuristic -o cloc-ai-report

npm 快速安装

npx @tonyclaw/cloc-ai install --host codex
npx @tonyclaw/cloc-ai install --host claude-code
npx @tonyclaw/cloc-ai install --host opencode
npx @tonyclaw/cloc-ai install --host coding-agent

默认安装到用户范围;项目范围使用 --scope project。也可以不安装 Skill,直接统计:

npx @tonyclaw/cloc-ai run . --classification .\cloc-ai.classification.json -o cloc-ai-report
python -m cloc_ai . --classification .\cloc-ai.classification.json -o cloc-ai-report
# 或源码直接运行
$env:PYTHONPATH = "src"
python -m cloc_ai project-a --classification project-a\cloc-ai.classification.json -o report-a
python -m cloc_ai project-b --classification project-b\cloc-ai.classification.json -o report-b

需要 Python 3.9+。Skill 首次执行时会把固定版本的官方 cloc 自动安装到自身的 tools/cloc/;如果安装失败,会自动回退使用本机 PATH 中的 cloc。仅当两者均不可用时才会报错。可通过 pip install -e . 安装 cloc-ai 命令。

Agent Skill 安装

先在本仓库执行 pip install -e .,再按 Agent 的技能目录约定复制或链接 skills/cloc-ai:

  • Claude Code:.claude/skills/cloc-ai
  • Codex:.codex/skills/cloc-ai 或用户技能目录
  • OpenCode:使用其兼容的 skills 目录加载 SKILL.md

支持 SubAgents 的环境可按项目并行统计;不支持时 CLI 会顺序处理多个项目。